53 lines
524 KiB
JavaScript
53 lines
524 KiB
JavaScript
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))s(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"&&s(a)}).observe(document,{childList:!0,subtree:!0});function r(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 s(l){if(l.ep)return;l.ep=!0;const i=r(l);fetch(l.href,i)}})();var Pu={exports:{}},$i={},Au={exports:{}},ue={};/**
|
||
* @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 Sl=Symbol.for("react.element"),Tg=Symbol.for("react.portal"),Ig=Symbol.for("react.fragment"),Eg=Symbol.for("react.strict_mode"),Pg=Symbol.for("react.profiler"),Ag=Symbol.for("react.provider"),Rg=Symbol.for("react.context"),Dg=Symbol.for("react.forward_ref"),Lg=Symbol.for("react.suspense"),Og=Symbol.for("react.memo"),Wg=Symbol.for("react.lazy"),lc=Symbol.iterator;function Ng(e){return e===null||typeof e!="object"?null:(e=lc&&e[lc]||e["@@iterator"],typeof e=="function"?e:null)}var Ru={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Du=Object.assign,Lu={};function ks(e,t,r){this.props=e,this.context=t,this.refs=Lu,this.updater=r||Ru}ks.prototype.isReactComponent={};ks.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")};ks.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Ou(){}Ou.prototype=ks.prototype;function Bo(e,t,r){this.props=e,this.context=t,this.refs=Lu,this.updater=r||Ru}var $o=Bo.prototype=new Ou;$o.constructor=Bo;Du($o,ks.prototype);$o.isPureReactComponent=!0;var ic=Array.isArray,Wu=Object.prototype.hasOwnProperty,Uo={current:null},Nu={key:!0,ref:!0,__self:!0,__source:!0};function Bu(e,t,r){var s,l={},i=null,a=null;if(t!=null)for(s in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(i=""+t.key),t)Wu.call(t,s)&&!Nu.hasOwnProperty(s)&&(l[s]=t[s]);var c=arguments.length-2;if(c===1)l.children=r;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(s in c=e.defaultProps,c)l[s]===void 0&&(l[s]=c[s]);return{$$typeof:Sl,type:e,key:i,ref:a,props:l,_owner:Uo.current}}function Bg(e,t){return{$$typeof:Sl,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Fo(e){return typeof e=="object"&&e!==null&&e.$$typeof===Sl}function $g(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(r){return t[r]})}var ac=/\/+/g;function ha(e,t){return typeof e=="object"&&e!==null&&e.key!=null?$g(""+e.key):t.toString(36)}function ti(e,t,r,s,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 Sl:case Tg:a=!0}}if(a)return a=e,l=l(a),e=s===""?"."+ha(a,0):s,ic(l)?(r="",e!=null&&(r=e.replace(ac,"$&/")+"/"),ti(l,t,r,"",function(p){return p})):l!=null&&(Fo(l)&&(l=Bg(l,r+(!l.key||a&&a.key===l.key?"":(""+l.key).replace(ac,"$&/")+"/")+e)),t.push(l)),1;if(a=0,s=s===""?".":s+":",ic(e))for(var c=0;c<e.length;c++){i=e[c];var d=s+ha(i,c);a+=ti(i,t,r,d,l)}else if(d=Ng(e),typeof d=="function")for(e=d.call(e),c=0;!(i=e.next()).done;)i=i.value,d=s+ha(i,c++),a+=ti(i,t,r,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 Rl(e,t,r){if(e==null)return e;var s=[],l=0;return ti(e,s,"","",function(i){return t.call(r,i,l++)}),s}function Ug(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(r){(e._status===0||e._status===-1)&&(e._status=1,e._result=r)},function(r){(e._status===0||e._status===-1)&&(e._status=2,e._result=r)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var mt={current:null},ni={transition:null},Fg={ReactCurrentDispatcher:mt,ReactCurrentBatchConfig:ni,ReactCurrentOwner:Uo};function $u(){throw Error("act(...) is not supported in production builds of React.")}ue.Children={map:Rl,forEach:function(e,t,r){Rl(e,function(){t.apply(this,arguments)},r)},count:function(e){var t=0;return Rl(e,function(){t++}),t},toArray:function(e){return Rl(e,function(t){return t})||[]},only:function(e){if(!Fo(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ue.Component=ks;ue.Fragment=Ig;ue.Profiler=Pg;ue.PureComponent=Bo;ue.StrictMode=Eg;ue.Suspense=Lg;ue.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Fg;ue.act=$u;ue.cloneElement=function(e,t,r){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var s=Du({},e.props),l=e.key,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=Uo.current),t.key!==void 0&&(l=""+t.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(d in t)Wu.call(t,d)&&!Nu.hasOwnProperty(d)&&(s[d]=t[d]===void 0&&c!==void 0?c[d]:t[d])}var d=arguments.length-2;if(d===1)s.children=r;else if(1<d){c=Array(d);for(var p=0;p<d;p++)c[p]=arguments[p+2];s.children=c}return{$$typeof:Sl,type:e.type,key:l,ref:i,props:s,_owner:a}};ue.createContext=function(e){return e={$$typeof:Rg,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Ag,_context:e},e.Consumer=e};ue.createElement=Bu;ue.createFactory=function(e){var t=Bu.bind(null,e);return t.type=e,t};ue.createRef=function(){return{current:null}};ue.forwardRef=function(e){return{$$typeof:Dg,render:e}};ue.isValidElement=Fo;ue.lazy=function(e){return{$$typeof:Wg,_payload:{_status:-1,_result:e},_init:Ug}};ue.memo=function(e,t){return{$$typeof:Og,type:e,compare:t===void 0?null:t}};ue.startTransition=function(e){var t=ni.transition;ni.transition={};try{e()}finally{ni.transition=t}};ue.unstable_act=$u;ue.useCallback=function(e,t){return mt.current.useCallback(e,t)};ue.useContext=function(e){return mt.current.useContext(e)};ue.useDebugValue=function(){};ue.useDeferredValue=function(e){return mt.current.useDeferredValue(e)};ue.useEffect=function(e,t){return mt.current.useEffect(e,t)};ue.useId=function(){return mt.current.useId()};ue.useImperativeHandle=function(e,t,r){return mt.current.useImperativeHandle(e,t,r)};ue.useInsertionEffect=function(e,t){return mt.current.useInsertionEffect(e,t)};ue.useLayoutEffect=function(e,t){return mt.current.useLayoutEffect(e,t)};ue.useMemo=function(e,t){return mt.current.useMemo(e,t)};ue.useReducer=function(e,t,r){return mt.current.useReducer(e,t,r)};ue.useRef=function(e){return mt.current.useRef(e)};ue.useState=function(e){return mt.current.useState(e)};ue.useSyncExternalStore=function(e,t,r){return mt.current.useSyncExternalStore(e,t,r)};ue.useTransition=function(){return mt.current.useTransition()};ue.version="18.3.1";Au.exports=ue;var w=Au.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 Mg=w,Hg=Symbol.for("react.element"),Gg=Symbol.for("react.fragment"),Kg=Object.prototype.hasOwnProperty,Qg=Mg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Yg={key:!0,ref:!0,__self:!0,__source:!0};function Uu(e,t,r){var s,l={},i=null,a=null;r!==void 0&&(i=""+r),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(a=t.ref);for(s in t)Kg.call(t,s)&&!Yg.hasOwnProperty(s)&&(l[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)l[s]===void 0&&(l[s]=t[s]);return{$$typeof:Hg,type:e,key:i,ref:a,props:l,_owner:Qg.current}}$i.Fragment=Gg;$i.jsx=Uu;$i.jsxs=Uu;Pu.exports=$i;var n=Pu.exports,Fu={exports:{}},Pt={},Mu={exports:{}},Hu={};/**
|
||
* @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(A,H){var Y=A.length;A.push(H);e:for(;0<Y;){var ee=Y-1>>>1,Z=A[ee];if(0<l(Z,H))A[ee]=H,A[Y]=Z,Y=ee;else break e}}function r(A){return A.length===0?null:A[0]}function s(A){if(A.length===0)return null;var H=A[0],Y=A.pop();if(Y!==H){A[0]=Y;e:for(var ee=0,Z=A.length,Ce=Z>>>1;ee<Ce;){var Be=2*(ee+1)-1,Le=A[Be],he=Be+1,Xe=A[he];if(0>l(Le,Y))he<Z&&0>l(Xe,Le)?(A[ee]=Xe,A[he]=Y,ee=he):(A[ee]=Le,A[Be]=Y,ee=Be);else if(he<Z&&0>l(Xe,Y))A[ee]=Xe,A[he]=Y,ee=he;else break e}}return H}function l(A,H){var Y=A.sortIndex-H.sortIndex;return Y!==0?Y:A.id-H.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var a=Date,c=a.now();e.unstable_now=function(){return a.now()-c}}var d=[],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(A){for(var H=r(p);H!==null;){if(H.callback===null)s(p);else if(H.startTime<=A)s(p),H.sortIndex=H.expirationTime,t(d,H);else break;H=r(p)}}function y(A){if(h=!1,o(A),!j)if(r(d)!==null)j=!0,Q(k);else{var H=r(p);H!==null&&G(y,H.startTime-A)}}function k(A,H){j=!1,h&&(h=!1,g(_),_=-1),m=!0;var Y=u;try{for(o(H),f=r(d);f!==null&&(!(f.expirationTime>H)||A&&!V());){var ee=f.callback;if(typeof ee=="function"){f.callback=null,u=f.priorityLevel;var Z=ee(f.expirationTime<=H);H=e.unstable_now(),typeof Z=="function"?f.callback=Z:f===r(d)&&s(d),o(H)}else s(d);f=r(d)}if(f!==null)var Ce=!0;else{var Be=r(p);Be!==null&&G(y,Be.startTime-H),Ce=!1}return Ce}finally{f=null,u=Y,m=!1}}var C=!1,P=null,_=-1,R=5,N=-1;function V(){return!(e.unstable_now()-N<R)}function de(){if(P!==null){var A=e.unstable_now();N=A;var H=!0;try{H=P(!0,A)}finally{H?D():(C=!1,P=null)}}else C=!1}var D;if(typeof x=="function")D=function(){x(de)};else if(typeof MessageChannel<"u"){var z=new MessageChannel,I=z.port2;z.port1.onmessage=de,D=function(){I.postMessage(null)}}else D=function(){S(de,0)};function Q(A){P=A,C||(C=!0,D())}function G(A,H){_=S(function(){A(e.unstable_now())},H)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(A){A.callback=null},e.unstable_continueExecution=function(){j||m||(j=!0,Q(k))},e.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return u},e.unstable_getFirstCallbackNode=function(){return r(d)},e.unstable_next=function(A){switch(u){case 1:case 2:case 3:var H=3;break;default:H=u}var Y=u;u=H;try{return A()}finally{u=Y}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(A,H){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var Y=u;u=A;try{return H()}finally{u=Y}},e.unstable_scheduleCallback=function(A,H,Y){var ee=e.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0<Y?ee+Y:ee):Y=ee,A){case 1:var Z=-1;break;case 2:Z=250;break;case 5:Z=1073741823;break;case 4:Z=1e4;break;default:Z=5e3}return Z=Y+Z,A={id:v++,callback:H,priorityLevel:A,startTime:Y,expirationTime:Z,sortIndex:-1},Y>ee?(A.sortIndex=Y,t(p,A),r(d)===null&&A===r(p)&&(h?(g(_),_=-1):h=!0,G(y,Y-ee))):(A.sortIndex=Z,t(d,A),j||m||(j=!0,Q(k))),A},e.unstable_shouldYield=V,e.unstable_wrapCallback=function(A){var H=u;return function(){var Y=u;u=H;try{return A.apply(this,arguments)}finally{u=Y}}}})(Hu);Mu.exports=Hu;var Xg=Mu.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 qg=w,Et=Xg;function F(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r<arguments.length;r++)t+="&args[]="+encodeURIComponent(arguments[r]);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 Gu=new Set,sl={};function kr(e,t){gs(e,t),gs(e+"Capture",t)}function gs(e,t){for(sl[e]=t,e=0;e<t.length;e++)Gu.add(t[e])}var jn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ma=Object.prototype.hasOwnProperty,Jg=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,oc={},dc={};function Vg(e){return Ma.call(dc,e)?!0:Ma.call(oc,e)?!1:Jg.test(e)?dc[e]=!0:(oc[e]=!0,!1)}function Zg(e,t,r,s){if(r!==null&&r.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return s?!1:r!==null?!r.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function ex(e,t,r,s){if(t===null||typeof t>"u"||Zg(e,t,r,s))return!0;if(s)return!1;if(r!==null)switch(r.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 yt(e,t,r,s,l,i,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=s,this.attributeNamespace=l,this.mustUseProperty=r,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=a}var at={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){at[e]=new yt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];at[t]=new yt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){at[e]=new yt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){at[e]=new yt(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){at[e]=new yt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){at[e]=new yt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){at[e]=new yt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){at[e]=new yt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){at[e]=new yt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Mo=/[\-:]([a-z])/g;function Ho(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Mo,Ho);at[t]=new yt(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Mo,Ho);at[t]=new yt(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Mo,Ho);at[t]=new yt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){at[e]=new yt(e,1,!1,e.toLowerCase(),null,!1,!1)});at.xlinkHref=new yt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){at[e]=new yt(e,1,!1,e.toLowerCase(),null,!0,!0)});function Go(e,t,r,s){var l=at.hasOwnProperty(t)?at[t]:null;(l!==null?l.type!==0:s||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(ex(t,r,l,s)&&(r=null),s||l===null?Vg(t)&&(r===null?e.removeAttribute(t):e.setAttribute(t,""+r)):l.mustUseProperty?e[l.propertyName]=r===null?l.type===3?!1:"":r:(t=l.attributeName,s=l.attributeNamespace,r===null?e.removeAttribute(t):(l=l.type,r=l===3||l===4&&r===!0?"":""+r,s?e.setAttributeNS(s,t,r):e.setAttribute(t,r))))}var kn=qg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Dl=Symbol.for("react.element"),qr=Symbol.for("react.portal"),Jr=Symbol.for("react.fragment"),Ko=Symbol.for("react.strict_mode"),Ha=Symbol.for("react.profiler"),Ku=Symbol.for("react.provider"),Qu=Symbol.for("react.context"),Qo=Symbol.for("react.forward_ref"),Ga=Symbol.for("react.suspense"),Ka=Symbol.for("react.suspense_list"),Yo=Symbol.for("react.memo"),En=Symbol.for("react.lazy"),Yu=Symbol.for("react.offscreen"),cc=Symbol.iterator;function As(e){return e===null||typeof e!="object"?null:(e=cc&&e[cc]||e["@@iterator"],typeof e=="function"?e:null)}var De=Object.assign,ga;function Hs(e){if(ga===void 0)try{throw Error()}catch(r){var t=r.stack.trim().match(/\n( *(at )?)/);ga=t&&t[1]||""}return`
|
||
`+ga+e}var xa=!1;function ma(e,t){if(!e||xa)return"";xa=!0;var r=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 s=p}Reflect.construct(e,[],t)}else{try{t.call()}catch(p){s=p}e.call(t.prototype)}else{try{throw Error()}catch(p){s=p}e()}}catch(p){if(p&&s&&typeof p.stack=="string"){for(var l=p.stack.split(`
|
||
`),i=s.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{xa=!1,Error.prepareStackTrace=r}return(e=e?e.displayName||e.name:"")?Hs(e):""}function tx(e){switch(e.tag){case 5:return Hs(e.type);case 16:return Hs("Lazy");case 13:return Hs("Suspense");case 19:return Hs("SuspenseList");case 0:case 2:case 15:return e=ma(e.type,!1),e;case 11:return e=ma(e.type.render,!1),e;case 1:return e=ma(e.type,!0),e;default:return""}}function Qa(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 Jr:return"Fragment";case qr:return"Portal";case Ha:return"Profiler";case Ko:return"StrictMode";case Ga:return"Suspense";case Ka:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Qu:return(e.displayName||"Context")+".Consumer";case Ku:return(e._context.displayName||"Context")+".Provider";case Qo:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Yo:return t=e.displayName||null,t!==null?t:Qa(e.type)||"Memo";case En:t=e._payload,e=e._init;try{return Qa(e(t))}catch{}}return null}function nx(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 Qa(t);case 8:return t===Ko?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Kn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Xu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function rx(e){var t=Xu(e)?"checked":"value",r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),s=""+e[t];if(!e.hasOwnProperty(t)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var l=r.get,i=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(a){s=""+a,i.call(this,a)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return s},setValue:function(a){s=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ll(e){e._valueTracker||(e._valueTracker=rx(e))}function qu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var r=t.getValue(),s="";return e&&(s=Xu(e)?e.checked?"true":"false":e.value),e=s,e!==r?(t.setValue(e),!0):!1}function hi(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 Ya(e,t){var r=t.checked;return De({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??e._wrapperState.initialChecked})}function uc(e,t){var r=t.defaultValue==null?"":t.defaultValue,s=t.checked!=null?t.checked:t.defaultChecked;r=Kn(t.value!=null?t.value:r),e._wrapperState={initialChecked:s,initialValue:r,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Ju(e,t){t=t.checked,t!=null&&Go(e,"checked",t,!1)}function Xa(e,t){Ju(e,t);var r=Kn(t.value),s=t.type;if(r!=null)s==="number"?(r===0&&e.value===""||e.value!=r)&&(e.value=""+r):e.value!==""+r&&(e.value=""+r);else if(s==="submit"||s==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?qa(e,t.type,r):t.hasOwnProperty("defaultValue")&&qa(e,t.type,Kn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function pc(e,t,r){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var s=t.type;if(!(s!=="submit"&&s!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,r||t===e.value||(e.value=t),e.defaultValue=t}r=e.name,r!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,r!==""&&(e.name=r)}function qa(e,t,r){(t!=="number"||hi(e.ownerDocument)!==e)&&(r==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+r&&(e.defaultValue=""+r))}var Gs=Array.isArray;function ds(e,t,r,s){if(e=e.options,t){t={};for(var l=0;l<r.length;l++)t["$"+r[l]]=!0;for(r=0;r<e.length;r++)l=t.hasOwnProperty("$"+e[r].value),e[r].selected!==l&&(e[r].selected=l),l&&s&&(e[r].defaultSelected=!0)}else{for(r=""+Kn(r),t=null,l=0;l<e.length;l++){if(e[l].value===r){e[l].selected=!0,s&&(e[l].defaultSelected=!0);return}t!==null||e[l].disabled||(t=e[l])}t!==null&&(t.selected=!0)}}function Ja(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(F(91));return De({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function fc(e,t){var r=t.value;if(r==null){if(r=t.children,t=t.defaultValue,r!=null){if(t!=null)throw Error(F(92));if(Gs(r)){if(1<r.length)throw Error(F(93));r=r[0]}t=r}t==null&&(t=""),r=t}e._wrapperState={initialValue:Kn(r)}}function Vu(e,t){var r=Kn(t.value),s=Kn(t.defaultValue);r!=null&&(r=""+r,r!==e.value&&(e.value=r),t.defaultValue==null&&e.defaultValue!==r&&(e.defaultValue=r)),s!=null&&(e.defaultValue=""+s)}function hc(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Zu(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Va(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Zu(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Ol,ep=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,r,s,l){MSApp.execUnsafeLocalFunction(function(){return e(t,r,s,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 ll(e,t){if(t){var r=e.firstChild;if(r&&r===e.lastChild&&r.nodeType===3){r.nodeValue=t;return}}e.textContent=t}var Xs={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},sx=["Webkit","ms","Moz","O"];Object.keys(Xs).forEach(function(e){sx.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Xs[t]=Xs[e]})});function tp(e,t,r){return t==null||typeof t=="boolean"||t===""?"":r||typeof t!="number"||t===0||Xs.hasOwnProperty(e)&&Xs[e]?(""+t).trim():t+"px"}function np(e,t){e=e.style;for(var r in t)if(t.hasOwnProperty(r)){var s=r.indexOf("--")===0,l=tp(r,t[r],s);r==="float"&&(r="cssFloat"),s?e.setProperty(r,l):e[r]=l}}var lx=De({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 Za(e,t){if(t){if(lx[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(F(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(F(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(F(61))}if(t.style!=null&&typeof t.style!="object")throw Error(F(62))}}function eo(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 to=null;function Xo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var no=null,cs=null,us=null;function gc(e){if(e=_l(e)){if(typeof no!="function")throw Error(F(280));var t=e.stateNode;t&&(t=Gi(t),no(e.stateNode,e.type,t))}}function rp(e){cs?us?us.push(e):us=[e]:cs=e}function sp(){if(cs){var e=cs,t=us;if(us=cs=null,gc(e),t)for(e=0;e<t.length;e++)gc(t[e])}}function lp(e,t){return e(t)}function ip(){}var ya=!1;function ap(e,t,r){if(ya)return e(t,r);ya=!0;try{return lp(e,t,r)}finally{ya=!1,(cs!==null||us!==null)&&(ip(),sp())}}function il(e,t){var r=e.stateNode;if(r===null)return null;var s=Gi(r);if(s===null)return null;r=s[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":(s=!s.disabled)||(e=e.type,s=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!s;break e;default:e=!1}if(e)return null;if(r&&typeof r!="function")throw Error(F(231,t,typeof r));return r}var ro=!1;if(jn)try{var Rs={};Object.defineProperty(Rs,"passive",{get:function(){ro=!0}}),window.addEventListener("test",Rs,Rs),window.removeEventListener("test",Rs,Rs)}catch{ro=!1}function ix(e,t,r,s,l,i,a,c,d){var p=Array.prototype.slice.call(arguments,3);try{t.apply(r,p)}catch(v){this.onError(v)}}var qs=!1,gi=null,xi=!1,so=null,ax={onError:function(e){qs=!0,gi=e}};function ox(e,t,r,s,l,i,a,c,d){qs=!1,gi=null,ix.apply(ax,arguments)}function dx(e,t,r,s,l,i,a,c,d){if(ox.apply(this,arguments),qs){if(qs){var p=gi;qs=!1,gi=null}else throw Error(F(198));xi||(xi=!0,so=p)}}function _r(e){var t=e,r=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(r=t.return),e=t.return;while(e)}return t.tag===3?r:null}function op(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function xc(e){if(_r(e)!==e)throw Error(F(188))}function cx(e){var t=e.alternate;if(!t){if(t=_r(e),t===null)throw Error(F(188));return t!==e?null:e}for(var r=e,s=t;;){var l=r.return;if(l===null)break;var i=l.alternate;if(i===null){if(s=l.return,s!==null){r=s;continue}break}if(l.child===i.child){for(i=l.child;i;){if(i===r)return xc(l),e;if(i===s)return xc(l),t;i=i.sibling}throw Error(F(188))}if(r.return!==s.return)r=l,s=i;else{for(var a=!1,c=l.child;c;){if(c===r){a=!0,r=l,s=i;break}if(c===s){a=!0,s=l,r=i;break}c=c.sibling}if(!a){for(c=i.child;c;){if(c===r){a=!0,r=i,s=l;break}if(c===s){a=!0,s=i,r=l;break}c=c.sibling}if(!a)throw Error(F(189))}}if(r.alternate!==s)throw Error(F(190))}if(r.tag!==3)throw Error(F(188));return r.stateNode.current===r?e:t}function dp(e){return e=cx(e),e!==null?cp(e):null}function cp(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=cp(e);if(t!==null)return t;e=e.sibling}return null}var up=Et.unstable_scheduleCallback,mc=Et.unstable_cancelCallback,ux=Et.unstable_shouldYield,px=Et.unstable_requestPaint,Fe=Et.unstable_now,fx=Et.unstable_getCurrentPriorityLevel,qo=Et.unstable_ImmediatePriority,pp=Et.unstable_UserBlockingPriority,mi=Et.unstable_NormalPriority,hx=Et.unstable_LowPriority,fp=Et.unstable_IdlePriority,Ui=null,sn=null;function gx(e){if(sn&&typeof sn.onCommitFiberRoot=="function")try{sn.onCommitFiberRoot(Ui,e,void 0,(e.current.flags&128)===128)}catch{}}var Kt=Math.clz32?Math.clz32:yx,xx=Math.log,mx=Math.LN2;function yx(e){return e>>>=0,e===0?32:31-(xx(e)/mx|0)|0}var Wl=64,Nl=4194304;function Ks(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 yi(e,t){var r=e.pendingLanes;if(r===0)return 0;var s=0,l=e.suspendedLanes,i=e.pingedLanes,a=r&268435455;if(a!==0){var c=a&~l;c!==0?s=Ks(c):(i&=a,i!==0&&(s=Ks(i)))}else a=r&~l,a!==0?s=Ks(a):i!==0&&(s=Ks(i));if(s===0)return 0;if(t!==0&&t!==s&&!(t&l)&&(l=s&-s,i=t&-t,l>=i||l===16&&(i&4194240)!==0))return t;if(s&4&&(s|=r&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=s;0<t;)r=31-Kt(t),l=1<<r,s|=e[r],t&=~l;return s}function vx(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 jx(e,t){for(var r=e.suspendedLanes,s=e.pingedLanes,l=e.expirationTimes,i=e.pendingLanes;0<i;){var a=31-Kt(i),c=1<<a,d=l[a];d===-1?(!(c&r)||c&s)&&(l[a]=vx(c,t)):d<=t&&(e.expiredLanes|=c),i&=~c}}function lo(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function hp(){var e=Wl;return Wl<<=1,!(Wl&4194240)&&(Wl=64),e}function va(e){for(var t=[],r=0;31>r;r++)t.push(e);return t}function wl(e,t,r){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Kt(t),e[t]=r}function bx(e,t){var r=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 s=e.eventTimes;for(e=e.expirationTimes;0<r;){var l=31-Kt(r),i=1<<l;t[l]=0,s[l]=-1,e[l]=-1,r&=~i}}function Jo(e,t){var r=e.entangledLanes|=t;for(e=e.entanglements;r;){var s=31-Kt(r),l=1<<s;l&t|e[s]&t&&(e[s]|=t),r&=~l}}var ye=0;function gp(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var xp,Vo,mp,yp,vp,io=!1,Bl=[],Nn=null,Bn=null,$n=null,al=new Map,ol=new Map,An=[],Sx="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function yc(e,t){switch(e){case"focusin":case"focusout":Nn=null;break;case"dragenter":case"dragleave":Bn=null;break;case"mouseover":case"mouseout":$n=null;break;case"pointerover":case"pointerout":al.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":ol.delete(t.pointerId)}}function Ds(e,t,r,s,l,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:r,eventSystemFlags:s,nativeEvent:i,targetContainers:[l]},t!==null&&(t=_l(t),t!==null&&Vo(t)),e):(e.eventSystemFlags|=s,t=e.targetContainers,l!==null&&t.indexOf(l)===-1&&t.push(l),e)}function wx(e,t,r,s,l){switch(t){case"focusin":return Nn=Ds(Nn,e,t,r,s,l),!0;case"dragenter":return Bn=Ds(Bn,e,t,r,s,l),!0;case"mouseover":return $n=Ds($n,e,t,r,s,l),!0;case"pointerover":var i=l.pointerId;return al.set(i,Ds(al.get(i)||null,e,t,r,s,l)),!0;case"gotpointercapture":return i=l.pointerId,ol.set(i,Ds(ol.get(i)||null,e,t,r,s,l)),!0}return!1}function jp(e){var t=fr(e.target);if(t!==null){var r=_r(t);if(r!==null){if(t=r.tag,t===13){if(t=op(r),t!==null){e.blockedOn=t,vp(e.priority,function(){mp(r)});return}}else if(t===3&&r.stateNode.current.memoizedState.isDehydrated){e.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}e.blockedOn=null}function ri(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var r=ao(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(r===null){r=e.nativeEvent;var s=new r.constructor(r.type,r);to=s,r.target.dispatchEvent(s),to=null}else return t=_l(r),t!==null&&Vo(t),e.blockedOn=r,!1;t.shift()}return!0}function vc(e,t,r){ri(e)&&r.delete(t)}function kx(){io=!1,Nn!==null&&ri(Nn)&&(Nn=null),Bn!==null&&ri(Bn)&&(Bn=null),$n!==null&&ri($n)&&($n=null),al.forEach(vc),ol.forEach(vc)}function Ls(e,t){e.blockedOn===t&&(e.blockedOn=null,io||(io=!0,Et.unstable_scheduleCallback(Et.unstable_NormalPriority,kx)))}function dl(e){function t(l){return Ls(l,e)}if(0<Bl.length){Ls(Bl[0],e);for(var r=1;r<Bl.length;r++){var s=Bl[r];s.blockedOn===e&&(s.blockedOn=null)}}for(Nn!==null&&Ls(Nn,e),Bn!==null&&Ls(Bn,e),$n!==null&&Ls($n,e),al.forEach(t),ol.forEach(t),r=0;r<An.length;r++)s=An[r],s.blockedOn===e&&(s.blockedOn=null);for(;0<An.length&&(r=An[0],r.blockedOn===null);)jp(r),r.blockedOn===null&&An.shift()}var ps=kn.ReactCurrentBatchConfig,vi=!0;function _x(e,t,r,s){var l=ye,i=ps.transition;ps.transition=null;try{ye=1,Zo(e,t,r,s)}finally{ye=l,ps.transition=i}}function Cx(e,t,r,s){var l=ye,i=ps.transition;ps.transition=null;try{ye=4,Zo(e,t,r,s)}finally{ye=l,ps.transition=i}}function Zo(e,t,r,s){if(vi){var l=ao(e,t,r,s);if(l===null)Ia(e,t,s,ji,r),yc(e,s);else if(wx(l,e,t,r,s))s.stopPropagation();else if(yc(e,s),t&4&&-1<Sx.indexOf(e)){for(;l!==null;){var i=_l(l);if(i!==null&&xp(i),i=ao(e,t,r,s),i===null&&Ia(e,t,s,ji,r),i===l)break;l=i}l!==null&&s.stopPropagation()}else Ia(e,t,s,null,r)}}var ji=null;function ao(e,t,r,s){if(ji=null,e=Xo(s),e=fr(e),e!==null)if(t=_r(e),t===null)e=null;else if(r=t.tag,r===13){if(e=op(t),e!==null)return e;e=null}else if(r===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return ji=e,null}function bp(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(fx()){case qo:return 1;case pp:return 4;case mi:case hx:return 16;case fp:return 536870912;default:return 16}default:return 16}}var Dn=null,ed=null,si=null;function Sp(){if(si)return si;var e,t=ed,r=t.length,s,l="value"in Dn?Dn.value:Dn.textContent,i=l.length;for(e=0;e<r&&t[e]===l[e];e++);var a=r-e;for(s=1;s<=a&&t[r-s]===l[i-s];s++);return si=l.slice(e,1<s?1-s:void 0)}function li(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function $l(){return!0}function jc(){return!1}function At(e){function t(r,s,l,i,a){this._reactName=r,this._targetInst=l,this.type=s,this.nativeEvent=i,this.target=a,this.currentTarget=null;for(var c in e)e.hasOwnProperty(c)&&(r=e[c],this[c]=r?r(i):i[c]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?$l:jc,this.isPropagationStopped=jc,this}return De(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=$l)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=$l)},persist:function(){},isPersistent:$l}),t}var _s={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},td=At(_s),kl=De({},_s,{view:0,detail:0}),zx=At(kl),ja,ba,Os,Fi=De({},kl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:nd,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Os&&(Os&&e.type==="mousemove"?(ja=e.screenX-Os.screenX,ba=e.screenY-Os.screenY):ba=ja=0,Os=e),ja)},movementY:function(e){return"movementY"in e?e.movementY:ba}}),bc=At(Fi),Tx=De({},Fi,{dataTransfer:0}),Ix=At(Tx),Ex=De({},kl,{relatedTarget:0}),Sa=At(Ex),Px=De({},_s,{animationName:0,elapsedTime:0,pseudoElement:0}),Ax=At(Px),Rx=De({},_s,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Dx=At(Rx),Lx=De({},_s,{data:0}),Sc=At(Lx),Ox={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Wx={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"},Nx={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Bx(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Nx[e])?!!t[e]:!1}function nd(){return Bx}var $x=De({},kl,{key:function(e){if(e.key){var t=Ox[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=li(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Wx[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:nd,charCode:function(e){return e.type==="keypress"?li(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?li(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Ux=At($x),Fx=De({},Fi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),wc=At(Fx),Mx=De({},kl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:nd}),Hx=At(Mx),Gx=De({},_s,{propertyName:0,elapsedTime:0,pseudoElement:0}),Kx=At(Gx),Qx=De({},Fi,{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}),Yx=At(Qx),Xx=[9,13,27,32],rd=jn&&"CompositionEvent"in window,Js=null;jn&&"documentMode"in document&&(Js=document.documentMode);var qx=jn&&"TextEvent"in window&&!Js,wp=jn&&(!rd||Js&&8<Js&&11>=Js),kc=" ",_c=!1;function kp(e,t){switch(e){case"keyup":return Xx.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function _p(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Vr=!1;function Jx(e,t){switch(e){case"compositionend":return _p(t);case"keypress":return t.which!==32?null:(_c=!0,kc);case"textInput":return e=t.data,e===kc&&_c?null:e;default:return null}}function Vx(e,t){if(Vr)return e==="compositionend"||!rd&&kp(e,t)?(e=Sp(),si=ed=Dn=null,Vr=!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 wp&&t.locale!=="ko"?null:t.data;default:return null}}var Zx={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Cc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Zx[e.type]:t==="textarea"}function Cp(e,t,r,s){rp(s),t=bi(t,"onChange"),0<t.length&&(r=new td("onChange","change",null,r,s),e.push({event:r,listeners:t}))}var Vs=null,cl=null;function em(e){Wp(e,0)}function Mi(e){var t=ts(e);if(qu(t))return e}function tm(e,t){if(e==="change")return t}var zp=!1;if(jn){var wa;if(jn){var ka="oninput"in document;if(!ka){var zc=document.createElement("div");zc.setAttribute("oninput","return;"),ka=typeof zc.oninput=="function"}wa=ka}else wa=!1;zp=wa&&(!document.documentMode||9<document.documentMode)}function Tc(){Vs&&(Vs.detachEvent("onpropertychange",Tp),cl=Vs=null)}function Tp(e){if(e.propertyName==="value"&&Mi(cl)){var t=[];Cp(t,cl,e,Xo(e)),ap(em,t)}}function nm(e,t,r){e==="focusin"?(Tc(),Vs=t,cl=r,Vs.attachEvent("onpropertychange",Tp)):e==="focusout"&&Tc()}function rm(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Mi(cl)}function sm(e,t){if(e==="click")return Mi(t)}function lm(e,t){if(e==="input"||e==="change")return Mi(t)}function im(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Yt=typeof Object.is=="function"?Object.is:im;function ul(e,t){if(Yt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;for(s=0;s<r.length;s++){var l=r[s];if(!Ma.call(t,l)||!Yt(e[l],t[l]))return!1}return!0}function Ic(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Ec(e,t){var r=Ic(e);e=0;for(var s;r;){if(r.nodeType===3){if(s=e+r.textContent.length,e<=t&&s>=t)return{node:r,offset:t-e};e=s}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=Ic(r)}}function Ip(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ip(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Ep(){for(var e=window,t=hi();t instanceof e.HTMLIFrameElement;){try{var r=typeof t.contentWindow.location.href=="string"}catch{r=!1}if(r)e=t.contentWindow;else break;t=hi(e.document)}return t}function sd(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 am(e){var t=Ep(),r=e.focusedElem,s=e.selectionRange;if(t!==r&&r&&r.ownerDocument&&Ip(r.ownerDocument.documentElement,r)){if(s!==null&&sd(r)){if(t=s.start,e=s.end,e===void 0&&(e=t),"selectionStart"in r)r.selectionStart=t,r.selectionEnd=Math.min(e,r.value.length);else if(e=(t=r.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=r.textContent.length,i=Math.min(s.start,l);s=s.end===void 0?i:Math.min(s.end,l),!e.extend&&i>s&&(l=s,s=i,i=l),l=Ec(r,i);var a=Ec(r,s);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>s?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=r;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r<t.length;r++)e=t[r],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var om=jn&&"documentMode"in document&&11>=document.documentMode,Zr=null,oo=null,Zs=null,co=!1;function Pc(e,t,r){var s=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;co||Zr==null||Zr!==hi(s)||(s=Zr,"selectionStart"in s&&sd(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),Zs&&ul(Zs,s)||(Zs=s,s=bi(oo,"onSelect"),0<s.length&&(t=new td("onSelect","select",null,t,r),e.push({event:t,listeners:s}),t.target=Zr)))}function Ul(e,t){var r={};return r[e.toLowerCase()]=t.toLowerCase(),r["Webkit"+e]="webkit"+t,r["Moz"+e]="moz"+t,r}var es={animationend:Ul("Animation","AnimationEnd"),animationiteration:Ul("Animation","AnimationIteration"),animationstart:Ul("Animation","AnimationStart"),transitionend:Ul("Transition","TransitionEnd")},_a={},Pp={};jn&&(Pp=document.createElement("div").style,"AnimationEvent"in window||(delete es.animationend.animation,delete es.animationiteration.animation,delete es.animationstart.animation),"TransitionEvent"in window||delete es.transitionend.transition);function Hi(e){if(_a[e])return _a[e];if(!es[e])return e;var t=es[e],r;for(r in t)if(t.hasOwnProperty(r)&&r in Pp)return _a[e]=t[r];return e}var Ap=Hi("animationend"),Rp=Hi("animationiteration"),Dp=Hi("animationstart"),Lp=Hi("transitionend"),Op=new Map,Ac="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Xn(e,t){Op.set(e,t),kr(t,[e])}for(var Ca=0;Ca<Ac.length;Ca++){var za=Ac[Ca],dm=za.toLowerCase(),cm=za[0].toUpperCase()+za.slice(1);Xn(dm,"on"+cm)}Xn(Ap,"onAnimationEnd");Xn(Rp,"onAnimationIteration");Xn(Dp,"onAnimationStart");Xn("dblclick","onDoubleClick");Xn("focusin","onFocus");Xn("focusout","onBlur");Xn(Lp,"onTransitionEnd");gs("onMouseEnter",["mouseout","mouseover"]);gs("onMouseLeave",["mouseout","mouseover"]);gs("onPointerEnter",["pointerout","pointerover"]);gs("onPointerLeave",["pointerout","pointerover"]);kr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));kr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));kr("onBeforeInput",["compositionend","keypress","textInput","paste"]);kr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));kr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));kr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Qs="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(" "),um=new Set("cancel close invalid load scroll toggle".split(" ").concat(Qs));function Rc(e,t,r){var s=e.type||"unknown-event";e.currentTarget=r,dx(s,t,void 0,e),e.currentTarget=null}function Wp(e,t){t=(t&4)!==0;for(var r=0;r<e.length;r++){var s=e[r],l=s.event;s=s.listeners;e:{var i=void 0;if(t)for(var a=s.length-1;0<=a;a--){var c=s[a],d=c.instance,p=c.currentTarget;if(c=c.listener,d!==i&&l.isPropagationStopped())break e;Rc(l,c,p),i=d}else for(a=0;a<s.length;a++){if(c=s[a],d=c.instance,p=c.currentTarget,c=c.listener,d!==i&&l.isPropagationStopped())break e;Rc(l,c,p),i=d}}}if(xi)throw e=so,xi=!1,so=null,e}function we(e,t){var r=t[go];r===void 0&&(r=t[go]=new Set);var s=e+"__bubble";r.has(s)||(Np(t,e,2,!1),r.add(s))}function Ta(e,t,r){var s=0;t&&(s|=4),Np(r,e,s,t)}var Fl="_reactListening"+Math.random().toString(36).slice(2);function pl(e){if(!e[Fl]){e[Fl]=!0,Gu.forEach(function(r){r!=="selectionchange"&&(um.has(r)||Ta(r,!1,e),Ta(r,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Fl]||(t[Fl]=!0,Ta("selectionchange",!1,t))}}function Np(e,t,r,s){switch(bp(t)){case 1:var l=_x;break;case 4:l=Cx;break;default:l=Zo}r=l.bind(null,t,r,e),l=void 0,!ro||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(l=!0),s?l!==void 0?e.addEventListener(t,r,{capture:!0,passive:l}):e.addEventListener(t,r,!0):l!==void 0?e.addEventListener(t,r,{passive:l}):e.addEventListener(t,r,!1)}function Ia(e,t,r,s,l){var i=s;if(!(t&1)&&!(t&2)&&s!==null)e:for(;;){if(s===null)return;var a=s.tag;if(a===3||a===4){var c=s.stateNode.containerInfo;if(c===l||c.nodeType===8&&c.parentNode===l)break;if(a===4)for(a=s.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=fr(c),a===null)return;if(d=a.tag,d===5||d===6){s=i=a;continue e}c=c.parentNode}}s=s.return}ap(function(){var p=i,v=Xo(r),f=[];e:{var u=Op.get(e);if(u!==void 0){var m=td,j=e;switch(e){case"keypress":if(li(r)===0)break e;case"keydown":case"keyup":m=Ux;break;case"focusin":j="focus",m=Sa;break;case"focusout":j="blur",m=Sa;break;case"beforeblur":case"afterblur":m=Sa;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":m=bc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=Ix;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=Hx;break;case Ap:case Rp:case Dp:m=Ax;break;case Lp:m=Kx;break;case"scroll":m=zx;break;case"wheel":m=Yx;break;case"copy":case"cut":case"paste":m=Dx;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=wc}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=il(x,g),y!=null&&h.push(fl(x,y,o)))),S)break;x=x.return}0<h.length&&(u=new m(u,j,null,r,v),f.push({event:u,listeners:h}))}}if(!(t&7)){e:{if(u=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",u&&r!==to&&(j=r.relatedTarget||r.fromElement)&&(fr(j)||j[bn]))break e;if((m||u)&&(u=v.window===v?v:(u=v.ownerDocument)?u.defaultView||u.parentWindow:window,m?(j=r.relatedTarget||r.toElement,m=p,j=j?fr(j):null,j!==null&&(S=_r(j),j!==S||j.tag!==5&&j.tag!==6)&&(j=null)):(m=null,j=p),m!==j)){if(h=bc,y="onMouseLeave",g="onMouseEnter",x="mouse",(e==="pointerout"||e==="pointerover")&&(h=wc,y="onPointerLeave",g="onPointerEnter",x="pointer"),S=m==null?u:ts(m),o=j==null?u:ts(j),u=new h(y,x+"leave",m,r,v),u.target=S,u.relatedTarget=o,y=null,fr(v)===p&&(h=new h(g,x+"enter",j,r,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=$r(o))x++;for(o=0,y=g;y;y=$r(y))o++;for(;0<x-o;)h=$r(h),x--;for(;0<o-x;)g=$r(g),o--;for(;x--;){if(h===g||g!==null&&h===g.alternate)break t;h=$r(h),g=$r(g)}h=null}else h=null;m!==null&&Dc(f,u,m,h,!1),j!==null&&S!==null&&Dc(f,S,j,h,!0)}}e:{if(u=p?ts(p):window,m=u.nodeName&&u.nodeName.toLowerCase(),m==="select"||m==="input"&&u.type==="file")var k=tm;else if(Cc(u))if(zp)k=lm;else{k=rm;var C=nm}else(m=u.nodeName)&&m.toLowerCase()==="input"&&(u.type==="checkbox"||u.type==="radio")&&(k=sm);if(k&&(k=k(e,p))){Cp(f,k,r,v);break e}C&&C(e,u,p),e==="focusout"&&(C=u._wrapperState)&&C.controlled&&u.type==="number"&&qa(u,"number",u.value)}switch(C=p?ts(p):window,e){case"focusin":(Cc(C)||C.contentEditable==="true")&&(Zr=C,oo=p,Zs=null);break;case"focusout":Zs=oo=Zr=null;break;case"mousedown":co=!0;break;case"contextmenu":case"mouseup":case"dragend":co=!1,Pc(f,r,v);break;case"selectionchange":if(om)break;case"keydown":case"keyup":Pc(f,r,v)}var P;if(rd)e:{switch(e){case"compositionstart":var _="onCompositionStart";break e;case"compositionend":_="onCompositionEnd";break e;case"compositionupdate":_="onCompositionUpdate";break e}_=void 0}else Vr?kp(e,r)&&(_="onCompositionEnd"):e==="keydown"&&r.keyCode===229&&(_="onCompositionStart");_&&(wp&&r.locale!=="ko"&&(Vr||_!=="onCompositionStart"?_==="onCompositionEnd"&&Vr&&(P=Sp()):(Dn=v,ed="value"in Dn?Dn.value:Dn.textContent,Vr=!0)),C=bi(p,_),0<C.length&&(_=new Sc(_,e,null,r,v),f.push({event:_,listeners:C}),P?_.data=P:(P=_p(r),P!==null&&(_.data=P)))),(P=qx?Jx(e,r):Vx(e,r))&&(p=bi(p,"onBeforeInput"),0<p.length&&(v=new Sc("onBeforeInput","beforeinput",null,r,v),f.push({event:v,listeners:p}),v.data=P))}Wp(f,t)})}function fl(e,t,r){return{instance:e,listener:t,currentTarget:r}}function bi(e,t){for(var r=t+"Capture",s=[];e!==null;){var l=e,i=l.stateNode;l.tag===5&&i!==null&&(l=i,i=il(e,r),i!=null&&s.unshift(fl(e,i,l)),i=il(e,t),i!=null&&s.push(fl(e,i,l))),e=e.return}return s}function $r(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Dc(e,t,r,s,l){for(var i=t._reactName,a=[];r!==null&&r!==s;){var c=r,d=c.alternate,p=c.stateNode;if(d!==null&&d===s)break;c.tag===5&&p!==null&&(c=p,l?(d=il(r,i),d!=null&&a.unshift(fl(r,d,c))):l||(d=il(r,i),d!=null&&a.push(fl(r,d,c)))),r=r.return}a.length!==0&&e.push({event:t,listeners:a})}var pm=/\r\n?/g,fm=/\u0000|\uFFFD/g;function Lc(e){return(typeof e=="string"?e:""+e).replace(pm,`
|
||
`).replace(fm,"")}function Ml(e,t,r){if(t=Lc(t),Lc(e)!==t&&r)throw Error(F(425))}function Si(){}var uo=null,po=null;function fo(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 ho=typeof setTimeout=="function"?setTimeout:void 0,hm=typeof clearTimeout=="function"?clearTimeout:void 0,Oc=typeof Promise=="function"?Promise:void 0,gm=typeof queueMicrotask=="function"?queueMicrotask:typeof Oc<"u"?function(e){return Oc.resolve(null).then(e).catch(xm)}:ho;function xm(e){setTimeout(function(){throw e})}function Ea(e,t){var r=t,s=0;do{var l=r.nextSibling;if(e.removeChild(r),l&&l.nodeType===8)if(r=l.data,r==="/$"){if(s===0){e.removeChild(l),dl(t);return}s--}else r!=="$"&&r!=="$?"&&r!=="$!"||s++;r=l}while(r);dl(t)}function Un(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 Wc(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var r=e.data;if(r==="$"||r==="$!"||r==="$?"){if(t===0)return e;t--}else r==="/$"&&t++}e=e.previousSibling}return null}var Cs=Math.random().toString(36).slice(2),rn="__reactFiber$"+Cs,hl="__reactProps$"+Cs,bn="__reactContainer$"+Cs,go="__reactEvents$"+Cs,mm="__reactListeners$"+Cs,ym="__reactHandles$"+Cs;function fr(e){var t=e[rn];if(t)return t;for(var r=e.parentNode;r;){if(t=r[bn]||r[rn]){if(r=t.alternate,t.child!==null||r!==null&&r.child!==null)for(e=Wc(e);e!==null;){if(r=e[rn])return r;e=Wc(e)}return t}e=r,r=e.parentNode}return null}function _l(e){return e=e[rn]||e[bn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function ts(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(F(33))}function Gi(e){return e[hl]||null}var xo=[],ns=-1;function qn(e){return{current:e}}function ke(e){0>ns||(e.current=xo[ns],xo[ns]=null,ns--)}function be(e,t){ns++,xo[ns]=e.current,e.current=t}var Qn={},pt=qn(Qn),St=qn(!1),yr=Qn;function xs(e,t){var r=e.type.contextTypes;if(!r)return Qn;var s=e.stateNode;if(s&&s.__reactInternalMemoizedUnmaskedChildContext===t)return s.__reactInternalMemoizedMaskedChildContext;var l={},i;for(i in r)l[i]=t[i];return s&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function wt(e){return e=e.childContextTypes,e!=null}function wi(){ke(St),ke(pt)}function Nc(e,t,r){if(pt.current!==Qn)throw Error(F(168));be(pt,t),be(St,r)}function Bp(e,t,r){var s=e.stateNode;if(t=t.childContextTypes,typeof s.getChildContext!="function")return r;s=s.getChildContext();for(var l in s)if(!(l in t))throw Error(F(108,nx(e)||"Unknown",l));return De({},r,s)}function ki(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Qn,yr=pt.current,be(pt,e),be(St,St.current),!0}function Bc(e,t,r){var s=e.stateNode;if(!s)throw Error(F(169));r?(e=Bp(e,t,yr),s.__reactInternalMemoizedMergedChildContext=e,ke(St),ke(pt),be(pt,e)):ke(St),be(St,r)}var xn=null,Ki=!1,Pa=!1;function $p(e){xn===null?xn=[e]:xn.push(e)}function vm(e){Ki=!0,$p(e)}function Jn(){if(!Pa&&xn!==null){Pa=!0;var e=0,t=ye;try{var r=xn;for(ye=1;e<r.length;e++){var s=r[e];do s=s(!0);while(s!==null)}xn=null,Ki=!1}catch(l){throw xn!==null&&(xn=xn.slice(e+1)),up(qo,Jn),l}finally{ye=t,Pa=!1}}return null}var rs=[],ss=0,_i=null,Ci=0,Rt=[],Dt=0,vr=null,mn=1,yn="";function ur(e,t){rs[ss++]=Ci,rs[ss++]=_i,_i=e,Ci=t}function Up(e,t,r){Rt[Dt++]=mn,Rt[Dt++]=yn,Rt[Dt++]=vr,vr=e;var s=mn;e=yn;var l=32-Kt(s)-1;s&=~(1<<l),r+=1;var i=32-Kt(t)+l;if(30<i){var a=l-l%5;i=(s&(1<<a)-1).toString(32),s>>=a,l-=a,mn=1<<32-Kt(t)+l|r<<l|s,yn=i+e}else mn=1<<i|r<<l|s,yn=e}function ld(e){e.return!==null&&(ur(e,1),Up(e,1,0))}function id(e){for(;e===_i;)_i=rs[--ss],rs[ss]=null,Ci=rs[--ss],rs[ss]=null;for(;e===vr;)vr=Rt[--Dt],Rt[Dt]=null,yn=Rt[--Dt],Rt[Dt]=null,mn=Rt[--Dt],Rt[Dt]=null}var It=null,Tt=null,Ee=!1,Ht=null;function Fp(e,t){var r=Lt(5,null,null,0);r.elementType="DELETED",r.stateNode=t,r.return=e,t=e.deletions,t===null?(e.deletions=[r],e.flags|=16):t.push(r)}function $c(e,t){switch(e.tag){case 5:var r=e.type;return t=t.nodeType!==1||r.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,It=e,Tt=Un(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,It=e,Tt=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(r=vr!==null?{id:mn,overflow:yn}:null,e.memoizedState={dehydrated:t,treeContext:r,retryLane:1073741824},r=Lt(18,null,null,0),r.stateNode=t,r.return=e,e.child=r,It=e,Tt=null,!0):!1;default:return!1}}function mo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function yo(e){if(Ee){var t=Tt;if(t){var r=t;if(!$c(e,t)){if(mo(e))throw Error(F(418));t=Un(r.nextSibling);var s=It;t&&$c(e,t)?Fp(s,r):(e.flags=e.flags&-4097|2,Ee=!1,It=e)}}else{if(mo(e))throw Error(F(418));e.flags=e.flags&-4097|2,Ee=!1,It=e}}}function Uc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;It=e}function Hl(e){if(e!==It)return!1;if(!Ee)return Uc(e),Ee=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!fo(e.type,e.memoizedProps)),t&&(t=Tt)){if(mo(e))throw Mp(),Error(F(418));for(;t;)Fp(e,t),t=Un(t.nextSibling)}if(Uc(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(F(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var r=e.data;if(r==="/$"){if(t===0){Tt=Un(e.nextSibling);break e}t--}else r!=="$"&&r!=="$!"&&r!=="$?"||t++}e=e.nextSibling}Tt=null}}else Tt=It?Un(e.stateNode.nextSibling):null;return!0}function Mp(){for(var e=Tt;e;)e=Un(e.nextSibling)}function ms(){Tt=It=null,Ee=!1}function ad(e){Ht===null?Ht=[e]:Ht.push(e)}var jm=kn.ReactCurrentBatchConfig;function Ws(e,t,r){if(e=r.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(r._owner){if(r=r._owner,r){if(r.tag!==1)throw Error(F(309));var s=r.stateNode}if(!s)throw Error(F(147,e));var l=s,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(F(284));if(!r._owner)throw Error(F(290,e))}return e}function Gl(e,t){throw e=Object.prototype.toString.call(t),Error(F(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Fc(e){var t=e._init;return t(e._payload)}function Hp(e){function t(g,x){if(e){var o=g.deletions;o===null?(g.deletions=[x],g.flags|=16):o.push(x)}}function r(g,x){if(!e)return null;for(;x!==null;)t(g,x),x=x.sibling;return null}function s(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=Gn(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=Na(o,g.mode,y),x.return=g,x):(x=l(x,o),x.return=g,x)}function d(g,x,o,y){var k=o.type;return k===Jr?v(g,x,o.props.children,y,o.key):x!==null&&(x.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===En&&Fc(k)===x.type)?(y=l(x,o.props),y.ref=Ws(g,x,o),y.return=g,y):(y=pi(o.type,o.key,o.props,null,g.mode,y),y.ref=Ws(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=Ba(o,g.mode,y),x.return=g,x):(x=l(x,o.children||[]),x.return=g,x)}function v(g,x,o,y,k){return x===null||x.tag!==7?(x=mr(o,g.mode,y,k),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=Na(""+x,g.mode,o),x.return=g,x;if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Dl:return o=pi(x.type,x.key,x.props,null,g.mode,o),o.ref=Ws(g,null,x),o.return=g,o;case qr:return x=Ba(x,g.mode,o),x.return=g,x;case En:var y=x._init;return f(g,y(x._payload),o)}if(Gs(x)||As(x))return x=mr(x,g.mode,o,null),x.return=g,x;Gl(g,x)}return null}function u(g,x,o,y){var k=x!==null?x.key:null;if(typeof o=="string"&&o!==""||typeof o=="number")return k!==null?null:c(g,x,""+o,y);if(typeof o=="object"&&o!==null){switch(o.$$typeof){case Dl:return o.key===k?d(g,x,o,y):null;case qr:return o.key===k?p(g,x,o,y):null;case En:return k=o._init,u(g,x,k(o._payload),y)}if(Gs(o)||As(o))return k!==null?null:v(g,x,o,y,null);Gl(g,o)}return null}function m(g,x,o,y,k){if(typeof y=="string"&&y!==""||typeof y=="number")return g=g.get(o)||null,c(x,g,""+y,k);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Dl:return g=g.get(y.key===null?o:y.key)||null,d(x,g,y,k);case qr:return g=g.get(y.key===null?o:y.key)||null,p(x,g,y,k);case En:var C=y._init;return m(g,x,o,C(y._payload),k)}if(Gs(y)||As(y))return g=g.get(o)||null,v(x,g,y,k,null);Gl(x,y)}return null}function j(g,x,o,y){for(var k=null,C=null,P=x,_=x=0,R=null;P!==null&&_<o.length;_++){P.index>_?(R=P,P=null):R=P.sibling;var N=u(g,P,o[_],y);if(N===null){P===null&&(P=R);break}e&&P&&N.alternate===null&&t(g,P),x=i(N,x,_),C===null?k=N:C.sibling=N,C=N,P=R}if(_===o.length)return r(g,P),Ee&&ur(g,_),k;if(P===null){for(;_<o.length;_++)P=f(g,o[_],y),P!==null&&(x=i(P,x,_),C===null?k=P:C.sibling=P,C=P);return Ee&&ur(g,_),k}for(P=s(g,P);_<o.length;_++)R=m(P,g,_,o[_],y),R!==null&&(e&&R.alternate!==null&&P.delete(R.key===null?_:R.key),x=i(R,x,_),C===null?k=R:C.sibling=R,C=R);return e&&P.forEach(function(V){return t(g,V)}),Ee&&ur(g,_),k}function h(g,x,o,y){var k=As(o);if(typeof k!="function")throw Error(F(150));if(o=k.call(o),o==null)throw Error(F(151));for(var C=k=null,P=x,_=x=0,R=null,N=o.next();P!==null&&!N.done;_++,N=o.next()){P.index>_?(R=P,P=null):R=P.sibling;var V=u(g,P,N.value,y);if(V===null){P===null&&(P=R);break}e&&P&&V.alternate===null&&t(g,P),x=i(V,x,_),C===null?k=V:C.sibling=V,C=V,P=R}if(N.done)return r(g,P),Ee&&ur(g,_),k;if(P===null){for(;!N.done;_++,N=o.next())N=f(g,N.value,y),N!==null&&(x=i(N,x,_),C===null?k=N:C.sibling=N,C=N);return Ee&&ur(g,_),k}for(P=s(g,P);!N.done;_++,N=o.next())N=m(P,g,_,N.value,y),N!==null&&(e&&N.alternate!==null&&P.delete(N.key===null?_:N.key),x=i(N,x,_),C===null?k=N:C.sibling=N,C=N);return e&&P.forEach(function(de){return t(g,de)}),Ee&&ur(g,_),k}function S(g,x,o,y){if(typeof o=="object"&&o!==null&&o.type===Jr&&o.key===null&&(o=o.props.children),typeof o=="object"&&o!==null){switch(o.$$typeof){case Dl:e:{for(var k=o.key,C=x;C!==null;){if(C.key===k){if(k=o.type,k===Jr){if(C.tag===7){r(g,C.sibling),x=l(C,o.props.children),x.return=g,g=x;break e}}else if(C.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===En&&Fc(k)===C.type){r(g,C.sibling),x=l(C,o.props),x.ref=Ws(g,C,o),x.return=g,g=x;break e}r(g,C);break}else t(g,C);C=C.sibling}o.type===Jr?(x=mr(o.props.children,g.mode,y,o.key),x.return=g,g=x):(y=pi(o.type,o.key,o.props,null,g.mode,y),y.ref=Ws(g,x,o),y.return=g,g=y)}return a(g);case qr:e:{for(C=o.key;x!==null;){if(x.key===C)if(x.tag===4&&x.stateNode.containerInfo===o.containerInfo&&x.stateNode.implementation===o.implementation){r(g,x.sibling),x=l(x,o.children||[]),x.return=g,g=x;break e}else{r(g,x);break}else t(g,x);x=x.sibling}x=Ba(o,g.mode,y),x.return=g,g=x}return a(g);case En:return C=o._init,S(g,x,C(o._payload),y)}if(Gs(o))return j(g,x,o,y);if(As(o))return h(g,x,o,y);Gl(g,o)}return typeof o=="string"&&o!==""||typeof o=="number"?(o=""+o,x!==null&&x.tag===6?(r(g,x.sibling),x=l(x,o),x.return=g,g=x):(r(g,x),x=Na(o,g.mode,y),x.return=g,g=x),a(g)):r(g,x)}return S}var ys=Hp(!0),Gp=Hp(!1),zi=qn(null),Ti=null,ls=null,od=null;function dd(){od=ls=Ti=null}function cd(e){var t=zi.current;ke(zi),e._currentValue=t}function vo(e,t,r){for(;e!==null;){var s=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,s!==null&&(s.childLanes|=t)):s!==null&&(s.childLanes&t)!==t&&(s.childLanes|=t),e===r)break;e=e.return}}function fs(e,t){Ti=e,od=ls=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(bt=!0),e.firstContext=null)}function Wt(e){var t=e._currentValue;if(od!==e)if(e={context:e,memoizedValue:t,next:null},ls===null){if(Ti===null)throw Error(F(308));ls=e,Ti.dependencies={lanes:0,firstContext:e}}else ls=ls.next=e;return t}var hr=null;function ud(e){hr===null?hr=[e]:hr.push(e)}function Kp(e,t,r,s){var l=t.interleaved;return l===null?(r.next=r,ud(t)):(r.next=l.next,l.next=r),t.interleaved=r,Sn(e,s)}function Sn(e,t){e.lanes|=t;var r=e.alternate;for(r!==null&&(r.lanes|=t),r=e,e=e.return;e!==null;)e.childLanes|=t,r=e.alternate,r!==null&&(r.childLanes|=t),r=e,e=e.return;return r.tag===3?r.stateNode:null}var Pn=!1;function pd(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Qp(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 vn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Fn(e,t,r){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,fe&2){var l=s.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),s.pending=t,Sn(e,r)}return l=s.interleaved,l===null?(t.next=t,ud(s)):(t.next=l.next,l.next=t),s.interleaved=t,Sn(e,r)}function ii(e,t,r){if(t=t.updateQueue,t!==null&&(t=t.shared,(r&4194240)!==0)){var s=t.lanes;s&=e.pendingLanes,r|=s,t.lanes=r,Jo(e,r)}}function Mc(e,t){var r=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,r===s)){var l=null,i=null;if(r=r.firstBaseUpdate,r!==null){do{var a={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};i===null?l=i=a:i=i.next=a,r=r.next}while(r!==null);i===null?l=i=t:i=i.next=t}else l=i=t;r={baseState:s.baseState,firstBaseUpdate:l,lastBaseUpdate:i,shared:s.shared,effects:s.effects},e.updateQueue=r;return}e=r.lastBaseUpdate,e===null?r.firstBaseUpdate=t:e.next=t,r.lastBaseUpdate=t}function Ii(e,t,r,s){var l=e.updateQueue;Pn=!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((s&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=r,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=De({},f,u);break e;case 2:Pn=!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);br|=a,e.lanes=a,e.memoizedState=f}}function Hc(e,t,r){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var s=e[t],l=s.callback;if(l!==null){if(s.callback=null,s=r,typeof l!="function")throw Error(F(191,l));l.call(s)}}}var Cl={},ln=qn(Cl),gl=qn(Cl),xl=qn(Cl);function gr(e){if(e===Cl)throw Error(F(174));return e}function fd(e,t){switch(be(xl,t),be(gl,e),be(ln,Cl),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Va(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Va(t,e)}ke(ln),be(ln,t)}function vs(){ke(ln),ke(gl),ke(xl)}function Yp(e){gr(xl.current);var t=gr(ln.current),r=Va(t,e.type);t!==r&&(be(gl,e),be(ln,r))}function hd(e){gl.current===e&&(ke(ln),ke(gl))}var Ae=qn(0);function Ei(e){for(var t=e;t!==null;){if(t.tag===13){var r=t.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||r.data==="$?"||r.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 Aa=[];function gd(){for(var e=0;e<Aa.length;e++)Aa[e]._workInProgressVersionPrimary=null;Aa.length=0}var ai=kn.ReactCurrentDispatcher,Ra=kn.ReactCurrentBatchConfig,jr=0,Re=null,Ze=null,nt=null,Pi=!1,el=!1,ml=0,bm=0;function dt(){throw Error(F(321))}function xd(e,t){if(t===null)return!1;for(var r=0;r<t.length&&r<e.length;r++)if(!Yt(e[r],t[r]))return!1;return!0}function md(e,t,r,s,l,i){if(jr=i,Re=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,ai.current=e===null||e.memoizedState===null?_m:Cm,e=r(s,l),el){i=0;do{if(el=!1,ml=0,25<=i)throw Error(F(301));i+=1,nt=Ze=null,t.updateQueue=null,ai.current=zm,e=r(s,l)}while(el)}if(ai.current=Ai,t=Ze!==null&&Ze.next!==null,jr=0,nt=Ze=Re=null,Pi=!1,t)throw Error(F(300));return e}function yd(){var e=ml!==0;return ml=0,e}function nn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return nt===null?Re.memoizedState=nt=e:nt=nt.next=e,nt}function Nt(){if(Ze===null){var e=Re.alternate;e=e!==null?e.memoizedState:null}else e=Ze.next;var t=nt===null?Re.memoizedState:nt.next;if(t!==null)nt=t,Ze=e;else{if(e===null)throw Error(F(310));Ze=e,e={memoizedState:Ze.memoizedState,baseState:Ze.baseState,baseQueue:Ze.baseQueue,queue:Ze.queue,next:null},nt===null?Re.memoizedState=nt=e:nt=nt.next=e}return nt}function yl(e,t){return typeof t=="function"?t(e):t}function Da(e){var t=Nt(),r=t.queue;if(r===null)throw Error(F(311));r.lastRenderedReducer=e;var s=Ze,l=s.baseQueue,i=r.pending;if(i!==null){if(l!==null){var a=l.next;l.next=i.next,i.next=a}s.baseQueue=l=i,r.pending=null}if(l!==null){i=l.next,s=s.baseState;var c=a=null,d=null,p=i;do{var v=p.lane;if((jr&v)===v)d!==null&&(d=d.next={lane:0,action:p.action,hasEagerState:p.hasEagerState,eagerState:p.eagerState,next:null}),s=p.hasEagerState?p.eagerState:e(s,p.action);else{var f={lane:v,action:p.action,hasEagerState:p.hasEagerState,eagerState:p.eagerState,next:null};d===null?(c=d=f,a=s):d=d.next=f,Re.lanes|=v,br|=v}p=p.next}while(p!==null&&p!==i);d===null?a=s:d.next=c,Yt(s,t.memoizedState)||(bt=!0),t.memoizedState=s,t.baseState=a,t.baseQueue=d,r.lastRenderedState=s}if(e=r.interleaved,e!==null){l=e;do i=l.lane,Re.lanes|=i,br|=i,l=l.next;while(l!==e)}else l===null&&(r.lanes=0);return[t.memoizedState,r.dispatch]}function La(e){var t=Nt(),r=t.queue;if(r===null)throw Error(F(311));r.lastRenderedReducer=e;var s=r.dispatch,l=r.pending,i=t.memoizedState;if(l!==null){r.pending=null;var a=l=l.next;do i=e(i,a.action),a=a.next;while(a!==l);Yt(i,t.memoizedState)||(bt=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),r.lastRenderedState=i}return[i,s]}function Xp(){}function qp(e,t){var r=Re,s=Nt(),l=t(),i=!Yt(s.memoizedState,l);if(i&&(s.memoizedState=l,bt=!0),s=s.queue,vd(Zp.bind(null,r,s,e),[e]),s.getSnapshot!==t||i||nt!==null&&nt.memoizedState.tag&1){if(r.flags|=2048,vl(9,Vp.bind(null,r,s,l,t),void 0,null),rt===null)throw Error(F(349));jr&30||Jp(r,t,l)}return l}function Jp(e,t,r){e.flags|=16384,e={getSnapshot:t,value:r},t=Re.updateQueue,t===null?(t={lastEffect:null,stores:null},Re.updateQueue=t,t.stores=[e]):(r=t.stores,r===null?t.stores=[e]:r.push(e))}function Vp(e,t,r,s){t.value=r,t.getSnapshot=s,ef(t)&&tf(e)}function Zp(e,t,r){return r(function(){ef(t)&&tf(e)})}function ef(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!Yt(e,r)}catch{return!0}}function tf(e){var t=Sn(e,1);t!==null&&Qt(t,e,1,-1)}function Gc(e){var t=nn();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:yl,lastRenderedState:e},t.queue=e,e=e.dispatch=km.bind(null,Re,e),[t.memoizedState,e]}function vl(e,t,r,s){return e={tag:e,create:t,destroy:r,deps:s,next:null},t=Re.updateQueue,t===null?(t={lastEffect:null,stores:null},Re.updateQueue=t,t.lastEffect=e.next=e):(r=t.lastEffect,r===null?t.lastEffect=e.next=e:(s=r.next,r.next=e,e.next=s,t.lastEffect=e)),e}function nf(){return Nt().memoizedState}function oi(e,t,r,s){var l=nn();Re.flags|=e,l.memoizedState=vl(1|t,r,void 0,s===void 0?null:s)}function Qi(e,t,r,s){var l=Nt();s=s===void 0?null:s;var i=void 0;if(Ze!==null){var a=Ze.memoizedState;if(i=a.destroy,s!==null&&xd(s,a.deps)){l.memoizedState=vl(t,r,i,s);return}}Re.flags|=e,l.memoizedState=vl(1|t,r,i,s)}function Kc(e,t){return oi(8390656,8,e,t)}function vd(e,t){return Qi(2048,8,e,t)}function rf(e,t){return Qi(4,2,e,t)}function sf(e,t){return Qi(4,4,e,t)}function lf(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 af(e,t,r){return r=r!=null?r.concat([e]):null,Qi(4,4,lf.bind(null,t,e),r)}function jd(){}function of(e,t){var r=Nt();t=t===void 0?null:t;var s=r.memoizedState;return s!==null&&t!==null&&xd(t,s[1])?s[0]:(r.memoizedState=[e,t],e)}function df(e,t){var r=Nt();t=t===void 0?null:t;var s=r.memoizedState;return s!==null&&t!==null&&xd(t,s[1])?s[0]:(e=e(),r.memoizedState=[e,t],e)}function cf(e,t,r){return jr&21?(Yt(r,t)||(r=hp(),Re.lanes|=r,br|=r,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,bt=!0),e.memoizedState=r)}function Sm(e,t){var r=ye;ye=r!==0&&4>r?r:4,e(!0);var s=Ra.transition;Ra.transition={};try{e(!1),t()}finally{ye=r,Ra.transition=s}}function uf(){return Nt().memoizedState}function wm(e,t,r){var s=Hn(e);if(r={lane:s,action:r,hasEagerState:!1,eagerState:null,next:null},pf(e))ff(t,r);else if(r=Kp(e,t,r,s),r!==null){var l=xt();Qt(r,e,s,l),hf(r,t,s)}}function km(e,t,r){var s=Hn(e),l={lane:s,action:r,hasEagerState:!1,eagerState:null,next:null};if(pf(e))ff(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,r);if(l.hasEagerState=!0,l.eagerState=c,Yt(c,a)){var d=t.interleaved;d===null?(l.next=l,ud(t)):(l.next=d.next,d.next=l),t.interleaved=l;return}}catch{}finally{}r=Kp(e,t,l,s),r!==null&&(l=xt(),Qt(r,e,s,l),hf(r,t,s))}}function pf(e){var t=e.alternate;return e===Re||t!==null&&t===Re}function ff(e,t){el=Pi=!0;var r=e.pending;r===null?t.next=t:(t.next=r.next,r.next=t),e.pending=t}function hf(e,t,r){if(r&4194240){var s=t.lanes;s&=e.pendingLanes,r|=s,t.lanes=r,Jo(e,r)}}var Ai={readContext:Wt,useCallback:dt,useContext:dt,useEffect:dt,useImperativeHandle:dt,useInsertionEffect:dt,useLayoutEffect:dt,useMemo:dt,useReducer:dt,useRef:dt,useState:dt,useDebugValue:dt,useDeferredValue:dt,useTransition:dt,useMutableSource:dt,useSyncExternalStore:dt,useId:dt,unstable_isNewReconciler:!1},_m={readContext:Wt,useCallback:function(e,t){return nn().memoizedState=[e,t===void 0?null:t],e},useContext:Wt,useEffect:Kc,useImperativeHandle:function(e,t,r){return r=r!=null?r.concat([e]):null,oi(4194308,4,lf.bind(null,t,e),r)},useLayoutEffect:function(e,t){return oi(4194308,4,e,t)},useInsertionEffect:function(e,t){return oi(4,2,e,t)},useMemo:function(e,t){var r=nn();return t=t===void 0?null:t,e=e(),r.memoizedState=[e,t],e},useReducer:function(e,t,r){var s=nn();return t=r!==void 0?r(t):t,s.memoizedState=s.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},s.queue=e,e=e.dispatch=wm.bind(null,Re,e),[s.memoizedState,e]},useRef:function(e){var t=nn();return e={current:e},t.memoizedState=e},useState:Gc,useDebugValue:jd,useDeferredValue:function(e){return nn().memoizedState=e},useTransition:function(){var e=Gc(!1),t=e[0];return e=Sm.bind(null,e[1]),nn().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,r){var s=Re,l=nn();if(Ee){if(r===void 0)throw Error(F(407));r=r()}else{if(r=t(),rt===null)throw Error(F(349));jr&30||Jp(s,t,r)}l.memoizedState=r;var i={value:r,getSnapshot:t};return l.queue=i,Kc(Zp.bind(null,s,i,e),[e]),s.flags|=2048,vl(9,Vp.bind(null,s,i,r,t),void 0,null),r},useId:function(){var e=nn(),t=rt.identifierPrefix;if(Ee){var r=yn,s=mn;r=(s&~(1<<32-Kt(s)-1)).toString(32)+r,t=":"+t+"R"+r,r=ml++,0<r&&(t+="H"+r.toString(32)),t+=":"}else r=bm++,t=":"+t+"r"+r.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Cm={readContext:Wt,useCallback:of,useContext:Wt,useEffect:vd,useImperativeHandle:af,useInsertionEffect:rf,useLayoutEffect:sf,useMemo:df,useReducer:Da,useRef:nf,useState:function(){return Da(yl)},useDebugValue:jd,useDeferredValue:function(e){var t=Nt();return cf(t,Ze.memoizedState,e)},useTransition:function(){var e=Da(yl)[0],t=Nt().memoizedState;return[e,t]},useMutableSource:Xp,useSyncExternalStore:qp,useId:uf,unstable_isNewReconciler:!1},zm={readContext:Wt,useCallback:of,useContext:Wt,useEffect:vd,useImperativeHandle:af,useInsertionEffect:rf,useLayoutEffect:sf,useMemo:df,useReducer:La,useRef:nf,useState:function(){return La(yl)},useDebugValue:jd,useDeferredValue:function(e){var t=Nt();return Ze===null?t.memoizedState=e:cf(t,Ze.memoizedState,e)},useTransition:function(){var e=La(yl)[0],t=Nt().memoizedState;return[e,t]},useMutableSource:Xp,useSyncExternalStore:qp,useId:uf,unstable_isNewReconciler:!1};function Ft(e,t){if(e&&e.defaultProps){t=De({},t),e=e.defaultProps;for(var r in e)t[r]===void 0&&(t[r]=e[r]);return t}return t}function jo(e,t,r,s){t=e.memoizedState,r=r(s,t),r=r==null?t:De({},t,r),e.memoizedState=r,e.lanes===0&&(e.updateQueue.baseState=r)}var Yi={isMounted:function(e){return(e=e._reactInternals)?_r(e)===e:!1},enqueueSetState:function(e,t,r){e=e._reactInternals;var s=xt(),l=Hn(e),i=vn(s,l);i.payload=t,r!=null&&(i.callback=r),t=Fn(e,i,l),t!==null&&(Qt(t,e,l,s),ii(t,e,l))},enqueueReplaceState:function(e,t,r){e=e._reactInternals;var s=xt(),l=Hn(e),i=vn(s,l);i.tag=1,i.payload=t,r!=null&&(i.callback=r),t=Fn(e,i,l),t!==null&&(Qt(t,e,l,s),ii(t,e,l))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var r=xt(),s=Hn(e),l=vn(r,s);l.tag=2,t!=null&&(l.callback=t),t=Fn(e,l,s),t!==null&&(Qt(t,e,s,r),ii(t,e,s))}};function Qc(e,t,r,s,l,i,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(s,i,a):t.prototype&&t.prototype.isPureReactComponent?!ul(r,s)||!ul(l,i):!0}function gf(e,t,r){var s=!1,l=Qn,i=t.contextType;return typeof i=="object"&&i!==null?i=Wt(i):(l=wt(t)?yr:pt.current,s=t.contextTypes,i=(s=s!=null)?xs(e,l):Qn),t=new t(r,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Yi,e.stateNode=t,t._reactInternals=e,s&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=l,e.__reactInternalMemoizedMaskedChildContext=i),t}function Yc(e,t,r,s){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(r,s),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(r,s),t.state!==e&&Yi.enqueueReplaceState(t,t.state,null)}function bo(e,t,r,s){var l=e.stateNode;l.props=r,l.state=e.memoizedState,l.refs={},pd(e);var i=t.contextType;typeof i=="object"&&i!==null?l.context=Wt(i):(i=wt(t)?yr:pt.current,l.context=xs(e,i)),l.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(jo(e,t,i,r),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&&Yi.enqueueReplaceState(l,l.state,null),Ii(e,r,l,s),l.state=e.memoizedState),typeof l.componentDidMount=="function"&&(e.flags|=4194308)}function js(e,t){try{var r="",s=t;do r+=tx(s),s=s.return;while(s);var l=r}catch(i){l=`
|
||
Error generating stack: `+i.message+`
|
||
`+i.stack}return{value:e,source:t,stack:l,digest:null}}function Oa(e,t,r){return{value:e,source:null,stack:r??null,digest:t??null}}function So(e,t){try{console.error(t.value)}catch(r){setTimeout(function(){throw r})}}var Tm=typeof WeakMap=="function"?WeakMap:Map;function xf(e,t,r){r=vn(-1,r),r.tag=3,r.payload={element:null};var s=t.value;return r.callback=function(){Di||(Di=!0,Ao=s),So(e,t)},r}function mf(e,t,r){r=vn(-1,r),r.tag=3;var s=e.type.getDerivedStateFromError;if(typeof s=="function"){var l=t.value;r.payload=function(){return s(l)},r.callback=function(){So(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(r.callback=function(){So(e,t),typeof s!="function"&&(Mn===null?Mn=new Set([this]):Mn.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),r}function Xc(e,t,r){var s=e.pingCache;if(s===null){s=e.pingCache=new Tm;var l=new Set;s.set(t,l)}else l=s.get(t),l===void 0&&(l=new Set,s.set(t,l));l.has(r)||(l.add(r),e=Fm.bind(null,e,t,r),t.then(e,e))}function qc(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function Jc(e,t,r,s,l){return e.mode&1?(e.flags|=65536,e.lanes=l,e):(e===t?e.flags|=65536:(e.flags|=128,r.flags|=131072,r.flags&=-52805,r.tag===1&&(r.alternate===null?r.tag=17:(t=vn(-1,1),t.tag=2,Fn(r,t,1))),r.lanes|=1),e)}var Im=kn.ReactCurrentOwner,bt=!1;function gt(e,t,r,s){t.child=e===null?Gp(t,null,r,s):ys(t,e.child,r,s)}function Vc(e,t,r,s,l){r=r.render;var i=t.ref;return fs(t,l),s=md(e,t,r,s,i,l),r=yd(),e!==null&&!bt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,wn(e,t,l)):(Ee&&r&&ld(t),t.flags|=1,gt(e,t,s,l),t.child)}function Zc(e,t,r,s,l){if(e===null){var i=r.type;return typeof i=="function"&&!Td(i)&&i.defaultProps===void 0&&r.compare===null&&r.defaultProps===void 0?(t.tag=15,t.type=i,yf(e,t,i,s,l)):(e=pi(r.type,null,s,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(r=r.compare,r=r!==null?r:ul,r(a,s)&&e.ref===t.ref)return wn(e,t,l)}return t.flags|=1,e=Gn(i,s),e.ref=t.ref,e.return=t,t.child=e}function yf(e,t,r,s,l){if(e!==null){var i=e.memoizedProps;if(ul(i,s)&&e.ref===t.ref)if(bt=!1,t.pendingProps=s=i,(e.lanes&l)!==0)e.flags&131072&&(bt=!0);else return t.lanes=e.lanes,wn(e,t,l)}return wo(e,t,r,s,l)}function vf(e,t,r){var s=t.pendingProps,l=s.children,i=e!==null?e.memoizedState:null;if(s.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},be(as,zt),zt|=r;else{if(!(r&1073741824))return e=i!==null?i.baseLanes|r:r,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,be(as,zt),zt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},s=i!==null?i.baseLanes:r,be(as,zt),zt|=s}else i!==null?(s=i.baseLanes|r,t.memoizedState=null):s=r,be(as,zt),zt|=s;return gt(e,t,l,r),t.child}function jf(e,t){var r=t.ref;(e===null&&r!==null||e!==null&&e.ref!==r)&&(t.flags|=512,t.flags|=2097152)}function wo(e,t,r,s,l){var i=wt(r)?yr:pt.current;return i=xs(t,i),fs(t,l),r=md(e,t,r,s,i,l),s=yd(),e!==null&&!bt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,wn(e,t,l)):(Ee&&s&&ld(t),t.flags|=1,gt(e,t,r,l),t.child)}function eu(e,t,r,s,l){if(wt(r)){var i=!0;ki(t)}else i=!1;if(fs(t,l),t.stateNode===null)di(e,t),gf(t,r,s),bo(t,r,s,l),s=!0;else if(e===null){var a=t.stateNode,c=t.memoizedProps;a.props=c;var d=a.context,p=r.contextType;typeof p=="object"&&p!==null?p=Wt(p):(p=wt(r)?yr:pt.current,p=xs(t,p));var v=r.getDerivedStateFromProps,f=typeof v=="function"||typeof a.getSnapshotBeforeUpdate=="function";f||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(c!==s||d!==p)&&Yc(t,a,s,p),Pn=!1;var u=t.memoizedState;a.state=u,Ii(t,s,a,l),d=t.memoizedState,c!==s||u!==d||St.current||Pn?(typeof v=="function"&&(jo(t,r,v,s),d=t.memoizedState),(c=Pn||Qc(t,r,c,s,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=s,t.memoizedState=d),a.props=s,a.state=d,a.context=p,s=c):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),s=!1)}else{a=t.stateNode,Qp(e,t),c=t.memoizedProps,p=t.type===t.elementType?c:Ft(t.type,c),a.props=p,f=t.pendingProps,u=a.context,d=r.contextType,typeof d=="object"&&d!==null?d=Wt(d):(d=wt(r)?yr:pt.current,d=xs(t,d));var m=r.getDerivedStateFromProps;(v=typeof m=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(c!==f||u!==d)&&Yc(t,a,s,d),Pn=!1,u=t.memoizedState,a.state=u,Ii(t,s,a,l);var j=t.memoizedState;c!==f||u!==j||St.current||Pn?(typeof m=="function"&&(jo(t,r,m,s),j=t.memoizedState),(p=Pn||Qc(t,r,p,s,u,j,d)||!1)?(v||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(s,j,d),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(s,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=s,t.memoizedState=j),a.props=s,a.state=j,a.context=d,s=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),s=!1)}return ko(e,t,r,s,i,l)}function ko(e,t,r,s,l,i){jf(e,t);var a=(t.flags&128)!==0;if(!s&&!a)return l&&Bc(t,r,!1),wn(e,t,i);s=t.stateNode,Im.current=t;var c=a&&typeof r.getDerivedStateFromError!="function"?null:s.render();return t.flags|=1,e!==null&&a?(t.child=ys(t,e.child,null,i),t.child=ys(t,null,c,i)):gt(e,t,c,i),t.memoizedState=s.state,l&&Bc(t,r,!0),t.child}function bf(e){var t=e.stateNode;t.pendingContext?Nc(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Nc(e,t.context,!1),fd(e,t.containerInfo)}function tu(e,t,r,s,l){return ms(),ad(l),t.flags|=256,gt(e,t,r,s),t.child}var _o={dehydrated:null,treeContext:null,retryLane:0};function Co(e){return{baseLanes:e,cachePool:null,transitions:null}}function Sf(e,t,r){var s=t.pendingProps,l=Ae.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),be(Ae,l&1),e===null)return yo(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=s.children,e=s.fallback,i?(s=t.mode,i=t.child,a={mode:"hidden",children:a},!(s&1)&&i!==null?(i.childLanes=0,i.pendingProps=a):i=Ji(a,s,0,null),e=mr(e,s,r,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=Co(r),t.memoizedState=_o,e):bd(t,a));if(l=e.memoizedState,l!==null&&(c=l.dehydrated,c!==null))return Em(e,t,a,s,c,l,r);if(i){i=s.fallback,a=t.mode,l=e.child,c=l.sibling;var d={mode:"hidden",children:s.children};return!(a&1)&&t.child!==l?(s=t.child,s.childLanes=0,s.pendingProps=d,t.deletions=null):(s=Gn(l,d),s.subtreeFlags=l.subtreeFlags&14680064),c!==null?i=Gn(c,i):(i=mr(i,a,r,null),i.flags|=2),i.return=t,s.return=t,s.sibling=i,t.child=s,s=i,i=t.child,a=e.child.memoizedState,a=a===null?Co(r):{baseLanes:a.baseLanes|r,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~r,t.memoizedState=_o,s}return i=e.child,e=i.sibling,s=Gn(i,{mode:"visible",children:s.children}),!(t.mode&1)&&(s.lanes=r),s.return=t,s.sibling=null,e!==null&&(r=t.deletions,r===null?(t.deletions=[e],t.flags|=16):r.push(e)),t.child=s,t.memoizedState=null,s}function bd(e,t){return t=Ji({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Kl(e,t,r,s){return s!==null&&ad(s),ys(t,e.child,null,r),e=bd(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Em(e,t,r,s,l,i,a){if(r)return t.flags&256?(t.flags&=-257,s=Oa(Error(F(422))),Kl(e,t,a,s)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=s.fallback,l=t.mode,s=Ji({mode:"visible",children:s.children},l,0,null),i=mr(i,l,a,null),i.flags|=2,s.return=t,i.return=t,s.sibling=i,t.child=s,t.mode&1&&ys(t,e.child,null,a),t.child.memoizedState=Co(a),t.memoizedState=_o,i);if(!(t.mode&1))return Kl(e,t,a,null);if(l.data==="$!"){if(s=l.nextSibling&&l.nextSibling.dataset,s)var c=s.dgst;return s=c,i=Error(F(419)),s=Oa(i,s,void 0),Kl(e,t,a,s)}if(c=(a&e.childLanes)!==0,bt||c){if(s=rt,s!==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&(s.suspendedLanes|a)?0:l,l!==0&&l!==i.retryLane&&(i.retryLane=l,Sn(e,l),Qt(s,e,l,-1))}return zd(),s=Oa(Error(F(421))),Kl(e,t,a,s)}return l.data==="$?"?(t.flags|=128,t.child=e.child,t=Mm.bind(null,e),l._reactRetry=t,null):(e=i.treeContext,Tt=Un(l.nextSibling),It=t,Ee=!0,Ht=null,e!==null&&(Rt[Dt++]=mn,Rt[Dt++]=yn,Rt[Dt++]=vr,mn=e.id,yn=e.overflow,vr=t),t=bd(t,s.children),t.flags|=4096,t)}function nu(e,t,r){e.lanes|=t;var s=e.alternate;s!==null&&(s.lanes|=t),vo(e.return,t,r)}function Wa(e,t,r,s,l){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:s,tail:r,tailMode:l}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=s,i.tail=r,i.tailMode=l)}function wf(e,t,r){var s=t.pendingProps,l=s.revealOrder,i=s.tail;if(gt(e,t,s.children,r),s=Ae.current,s&2)s=s&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&nu(e,r,t);else if(e.tag===19)nu(e,r,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}s&=1}if(be(Ae,s),!(t.mode&1))t.memoizedState=null;else switch(l){case"forwards":for(r=t.child,l=null;r!==null;)e=r.alternate,e!==null&&Ei(e)===null&&(l=r),r=r.sibling;r=l,r===null?(l=t.child,t.child=null):(l=r.sibling,r.sibling=null),Wa(t,!1,l,r,i);break;case"backwards":for(r=null,l=t.child,t.child=null;l!==null;){if(e=l.alternate,e!==null&&Ei(e)===null){t.child=l;break}e=l.sibling,l.sibling=r,r=l,l=e}Wa(t,!0,r,null,i);break;case"together":Wa(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function di(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function wn(e,t,r){if(e!==null&&(t.dependencies=e.dependencies),br|=t.lanes,!(r&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(F(153));if(t.child!==null){for(e=t.child,r=Gn(e,e.pendingProps),t.child=r,r.return=t;e.sibling!==null;)e=e.sibling,r=r.sibling=Gn(e,e.pendingProps),r.return=t;r.sibling=null}return t.child}function Pm(e,t,r){switch(t.tag){case 3:bf(t),ms();break;case 5:Yp(t);break;case 1:wt(t.type)&&ki(t);break;case 4:fd(t,t.stateNode.containerInfo);break;case 10:var s=t.type._context,l=t.memoizedProps.value;be(zi,s._currentValue),s._currentValue=l;break;case 13:if(s=t.memoizedState,s!==null)return s.dehydrated!==null?(be(Ae,Ae.current&1),t.flags|=128,null):r&t.child.childLanes?Sf(e,t,r):(be(Ae,Ae.current&1),e=wn(e,t,r),e!==null?e.sibling:null);be(Ae,Ae.current&1);break;case 19:if(s=(r&t.childLanes)!==0,e.flags&128){if(s)return wf(e,t,r);t.flags|=128}if(l=t.memoizedState,l!==null&&(l.rendering=null,l.tail=null,l.lastEffect=null),be(Ae,Ae.current),s)break;return null;case 22:case 23:return t.lanes=0,vf(e,t,r)}return wn(e,t,r)}var kf,zo,_f,Cf;kf=function(e,t){for(var r=t.child;r!==null;){if(r.tag===5||r.tag===6)e.appendChild(r.stateNode);else if(r.tag!==4&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return;r=r.return}r.sibling.return=r.return,r=r.sibling}};zo=function(){};_f=function(e,t,r,s){var l=e.memoizedProps;if(l!==s){e=t.stateNode,gr(ln.current);var i=null;switch(r){case"input":l=Ya(e,l),s=Ya(e,s),i=[];break;case"select":l=De({},l,{value:void 0}),s=De({},s,{value:void 0}),i=[];break;case"textarea":l=Ja(e,l),s=Ja(e,s),i=[];break;default:typeof l.onClick!="function"&&typeof s.onClick=="function"&&(e.onclick=Si)}Za(r,s);var a;r=null;for(p in l)if(!s.hasOwnProperty(p)&&l.hasOwnProperty(p)&&l[p]!=null)if(p==="style"){var c=l[p];for(a in c)c.hasOwnProperty(a)&&(r||(r={}),r[a]="")}else p!=="dangerouslySetInnerHTML"&&p!=="children"&&p!=="suppressContentEditableWarning"&&p!=="suppressHydrationWarning"&&p!=="autoFocus"&&(sl.hasOwnProperty(p)?i||(i=[]):(i=i||[]).push(p,null));for(p in s){var d=s[p];if(c=l!=null?l[p]:void 0,s.hasOwnProperty(p)&&d!==c&&(d!=null||c!=null))if(p==="style")if(c){for(a in c)!c.hasOwnProperty(a)||d&&d.hasOwnProperty(a)||(r||(r={}),r[a]="");for(a in d)d.hasOwnProperty(a)&&c[a]!==d[a]&&(r||(r={}),r[a]=d[a])}else r||(i||(i=[]),i.push(p,r)),r=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"&&(sl.hasOwnProperty(p)?(d!=null&&p==="onScroll"&&we("scroll",e),i||c===d||(i=[])):(i=i||[]).push(p,d))}r&&(i=i||[]).push("style",r);var p=i;(t.updateQueue=p)&&(t.flags|=4)}};Cf=function(e,t,r,s){r!==s&&(t.flags|=4)};function Ns(e,t){if(!Ee)switch(e.tailMode){case"hidden":t=e.tail;for(var r=null;t!==null;)t.alternate!==null&&(r=t),t=t.sibling;r===null?e.tail=null:r.sibling=null;break;case"collapsed":r=e.tail;for(var s=null;r!==null;)r.alternate!==null&&(s=r),r=r.sibling;s===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:s.sibling=null}}function ct(e){var t=e.alternate!==null&&e.alternate.child===e.child,r=0,s=0;if(t)for(var l=e.child;l!==null;)r|=l.lanes|l.childLanes,s|=l.subtreeFlags&14680064,s|=l.flags&14680064,l.return=e,l=l.sibling;else for(l=e.child;l!==null;)r|=l.lanes|l.childLanes,s|=l.subtreeFlags,s|=l.flags,l.return=e,l=l.sibling;return e.subtreeFlags|=s,e.childLanes=r,t}function Am(e,t,r){var s=t.pendingProps;switch(id(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ct(t),null;case 1:return wt(t.type)&&wi(),ct(t),null;case 3:return s=t.stateNode,vs(),ke(St),ke(pt),gd(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(Hl(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ht!==null&&(Lo(Ht),Ht=null))),zo(e,t),ct(t),null;case 5:hd(t);var l=gr(xl.current);if(r=t.type,e!==null&&t.stateNode!=null)_f(e,t,r,s,l),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!s){if(t.stateNode===null)throw Error(F(166));return ct(t),null}if(e=gr(ln.current),Hl(t)){s=t.stateNode,r=t.type;var i=t.memoizedProps;switch(s[rn]=t,s[hl]=i,e=(t.mode&1)!==0,r){case"dialog":we("cancel",s),we("close",s);break;case"iframe":case"object":case"embed":we("load",s);break;case"video":case"audio":for(l=0;l<Qs.length;l++)we(Qs[l],s);break;case"source":we("error",s);break;case"img":case"image":case"link":we("error",s),we("load",s);break;case"details":we("toggle",s);break;case"input":uc(s,i),we("invalid",s);break;case"select":s._wrapperState={wasMultiple:!!i.multiple},we("invalid",s);break;case"textarea":fc(s,i),we("invalid",s)}Za(r,i),l=null;for(var a in i)if(i.hasOwnProperty(a)){var c=i[a];a==="children"?typeof c=="string"?s.textContent!==c&&(i.suppressHydrationWarning!==!0&&Ml(s.textContent,c,e),l=["children",c]):typeof c=="number"&&s.textContent!==""+c&&(i.suppressHydrationWarning!==!0&&Ml(s.textContent,c,e),l=["children",""+c]):sl.hasOwnProperty(a)&&c!=null&&a==="onScroll"&&we("scroll",s)}switch(r){case"input":Ll(s),pc(s,i,!0);break;case"textarea":Ll(s),hc(s);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(s.onclick=Si)}s=l,t.updateQueue=s,s!==null&&(t.flags|=4)}else{a=l.nodeType===9?l:l.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Zu(r)),e==="http://www.w3.org/1999/xhtml"?r==="script"?(e=a.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof s.is=="string"?e=a.createElement(r,{is:s.is}):(e=a.createElement(r),r==="select"&&(a=e,s.multiple?a.multiple=!0:s.size&&(a.size=s.size))):e=a.createElementNS(e,r),e[rn]=t,e[hl]=s,kf(e,t,!1,!1),t.stateNode=e;e:{switch(a=eo(r,s),r){case"dialog":we("cancel",e),we("close",e),l=s;break;case"iframe":case"object":case"embed":we("load",e),l=s;break;case"video":case"audio":for(l=0;l<Qs.length;l++)we(Qs[l],e);l=s;break;case"source":we("error",e),l=s;break;case"img":case"image":case"link":we("error",e),we("load",e),l=s;break;case"details":we("toggle",e),l=s;break;case"input":uc(e,s),l=Ya(e,s),we("invalid",e);break;case"option":l=s;break;case"select":e._wrapperState={wasMultiple:!!s.multiple},l=De({},s,{value:void 0}),we("invalid",e);break;case"textarea":fc(e,s),l=Ja(e,s),we("invalid",e);break;default:l=s}Za(r,l),c=l;for(i in c)if(c.hasOwnProperty(i)){var d=c[i];i==="style"?np(e,d):i==="dangerouslySetInnerHTML"?(d=d?d.__html:void 0,d!=null&&ep(e,d)):i==="children"?typeof d=="string"?(r!=="textarea"||d!=="")&&ll(e,d):typeof d=="number"&&ll(e,""+d):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(sl.hasOwnProperty(i)?d!=null&&i==="onScroll"&&we("scroll",e):d!=null&&Go(e,i,d,a))}switch(r){case"input":Ll(e),pc(e,s,!1);break;case"textarea":Ll(e),hc(e);break;case"option":s.value!=null&&e.setAttribute("value",""+Kn(s.value));break;case"select":e.multiple=!!s.multiple,i=s.value,i!=null?ds(e,!!s.multiple,i,!1):s.defaultValue!=null&&ds(e,!!s.multiple,s.defaultValue,!0);break;default:typeof l.onClick=="function"&&(e.onclick=Si)}switch(r){case"button":case"input":case"select":case"textarea":s=!!s.autoFocus;break e;case"img":s=!0;break e;default:s=!1}}s&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return ct(t),null;case 6:if(e&&t.stateNode!=null)Cf(e,t,e.memoizedProps,s);else{if(typeof s!="string"&&t.stateNode===null)throw Error(F(166));if(r=gr(xl.current),gr(ln.current),Hl(t)){if(s=t.stateNode,r=t.memoizedProps,s[rn]=t,(i=s.nodeValue!==r)&&(e=It,e!==null))switch(e.tag){case 3:Ml(s.nodeValue,r,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Ml(s.nodeValue,r,(e.mode&1)!==0)}i&&(t.flags|=4)}else s=(r.nodeType===9?r:r.ownerDocument).createTextNode(s),s[rn]=t,t.stateNode=s}return ct(t),null;case 13:if(ke(Ae),s=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Ee&&Tt!==null&&t.mode&1&&!(t.flags&128))Mp(),ms(),t.flags|=98560,i=!1;else if(i=Hl(t),s!==null&&s.dehydrated!==null){if(e===null){if(!i)throw Error(F(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(F(317));i[rn]=t}else ms(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;ct(t),i=!1}else Ht!==null&&(Lo(Ht),Ht=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=r,t):(s=s!==null,s!==(e!==null&&e.memoizedState!==null)&&s&&(t.child.flags|=8192,t.mode&1&&(e===null||Ae.current&1?et===0&&(et=3):zd())),t.updateQueue!==null&&(t.flags|=4),ct(t),null);case 4:return vs(),zo(e,t),e===null&&pl(t.stateNode.containerInfo),ct(t),null;case 10:return cd(t.type._context),ct(t),null;case 17:return wt(t.type)&&wi(),ct(t),null;case 19:if(ke(Ae),i=t.memoizedState,i===null)return ct(t),null;if(s=(t.flags&128)!==0,a=i.rendering,a===null)if(s)Ns(i,!1);else{if(et!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Ei(e),a!==null){for(t.flags|=128,Ns(i,!1),s=a.updateQueue,s!==null&&(t.updateQueue=s,t.flags|=4),t.subtreeFlags=0,s=r,r=t.child;r!==null;)i=r,e=s,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}),r=r.sibling;return be(Ae,Ae.current&1|2),t.child}e=e.sibling}i.tail!==null&&Fe()>bs&&(t.flags|=128,s=!0,Ns(i,!1),t.lanes=4194304)}else{if(!s)if(e=Ei(a),e!==null){if(t.flags|=128,s=!0,r=e.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),Ns(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!Ee)return ct(t),null}else 2*Fe()-i.renderingStartTime>bs&&r!==1073741824&&(t.flags|=128,s=!0,Ns(i,!1),t.lanes=4194304);i.isBackwards?(a.sibling=t.child,t.child=a):(r=i.last,r!==null?r.sibling=a:t.child=a,i.last=a)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Fe(),t.sibling=null,r=Ae.current,be(Ae,s?r&1|2:r&1),t):(ct(t),null);case 22:case 23:return Cd(),s=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==s&&(t.flags|=8192),s&&t.mode&1?zt&1073741824&&(ct(t),t.subtreeFlags&6&&(t.flags|=8192)):ct(t),null;case 24:return null;case 25:return null}throw Error(F(156,t.tag))}function Rm(e,t){switch(id(t),t.tag){case 1:return wt(t.type)&&wi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return vs(),ke(St),ke(pt),gd(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return hd(t),null;case 13:if(ke(Ae),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(F(340));ms()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ke(Ae),null;case 4:return vs(),null;case 10:return cd(t.type._context),null;case 22:case 23:return Cd(),null;case 24:return null;default:return null}}var Ql=!1,ut=!1,Dm=typeof WeakSet=="function"?WeakSet:Set,q=null;function is(e,t){var r=e.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(s){Ne(e,t,s)}else r.current=null}function To(e,t,r){try{r()}catch(s){Ne(e,t,s)}}var ru=!1;function Lm(e,t){if(uo=vi,e=Ep(),sd(e)){if("selectionStart"in e)var r={start:e.selectionStart,end:e.selectionEnd};else e:{r=(r=e.ownerDocument)&&r.defaultView||window;var s=r.getSelection&&r.getSelection();if(s&&s.rangeCount!==0){r=s.anchorNode;var l=s.anchorOffset,i=s.focusNode;s=s.focusOffset;try{r.nodeType,i.nodeType}catch{r=null;break e}var a=0,c=-1,d=-1,p=0,v=0,f=e,u=null;t:for(;;){for(var m;f!==r||l!==0&&f.nodeType!==3||(c=a+l),f!==i||s!==0&&f.nodeType!==3||(d=a+s),f.nodeType===3&&(a+=f.nodeValue.length),(m=f.firstChild)!==null;)u=f,f=m;for(;;){if(f===e)break t;if(u===r&&++p===l&&(c=a),u===i&&++v===s&&(d=a),(m=f.nextSibling)!==null)break;f=u,u=f.parentNode}f=m}r=c===-1||d===-1?null:{start:c,end:d}}else r=null}r=r||{start:0,end:0}}else r=null;for(po={focusedElem:e,selectionRange:r},vi=!1,q=t;q!==null;)if(t=q,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,q=e;else for(;q!==null;){t=q;try{var 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:Ft(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(F(163))}}catch(y){Ne(t,t.return,y)}if(e=t.sibling,e!==null){e.return=t.return,q=e;break}q=t.return}return j=ru,ru=!1,j}function tl(e,t,r){var s=t.updateQueue;if(s=s!==null?s.lastEffect:null,s!==null){var l=s=s.next;do{if((l.tag&e)===e){var i=l.destroy;l.destroy=void 0,i!==void 0&&To(t,r,i)}l=l.next}while(l!==s)}}function Xi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var r=t=t.next;do{if((r.tag&e)===e){var s=r.create;r.destroy=s()}r=r.next}while(r!==t)}}function Io(e){var t=e.ref;if(t!==null){var r=e.stateNode;switch(e.tag){case 5:e=r;break;default:e=r}typeof t=="function"?t(e):t.current=e}}function zf(e){var t=e.alternate;t!==null&&(e.alternate=null,zf(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[rn],delete t[hl],delete t[go],delete t[mm],delete t[ym])),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 Tf(e){return e.tag===5||e.tag===3||e.tag===4}function su(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Tf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Eo(e,t,r){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?r.nodeType===8?r.parentNode.insertBefore(e,t):r.insertBefore(e,t):(r.nodeType===8?(t=r.parentNode,t.insertBefore(e,r)):(t=r,t.appendChild(e)),r=r._reactRootContainer,r!=null||t.onclick!==null||(t.onclick=Si));else if(s!==4&&(e=e.child,e!==null))for(Eo(e,t,r),e=e.sibling;e!==null;)Eo(e,t,r),e=e.sibling}function Po(e,t,r){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?r.insertBefore(e,t):r.appendChild(e);else if(s!==4&&(e=e.child,e!==null))for(Po(e,t,r),e=e.sibling;e!==null;)Po(e,t,r),e=e.sibling}var lt=null,Mt=!1;function Tn(e,t,r){for(r=r.child;r!==null;)If(e,t,r),r=r.sibling}function If(e,t,r){if(sn&&typeof sn.onCommitFiberUnmount=="function")try{sn.onCommitFiberUnmount(Ui,r)}catch{}switch(r.tag){case 5:ut||is(r,t);case 6:var s=lt,l=Mt;lt=null,Tn(e,t,r),lt=s,Mt=l,lt!==null&&(Mt?(e=lt,r=r.stateNode,e.nodeType===8?e.parentNode.removeChild(r):e.removeChild(r)):lt.removeChild(r.stateNode));break;case 18:lt!==null&&(Mt?(e=lt,r=r.stateNode,e.nodeType===8?Ea(e.parentNode,r):e.nodeType===1&&Ea(e,r),dl(e)):Ea(lt,r.stateNode));break;case 4:s=lt,l=Mt,lt=r.stateNode.containerInfo,Mt=!0,Tn(e,t,r),lt=s,Mt=l;break;case 0:case 11:case 14:case 15:if(!ut&&(s=r.updateQueue,s!==null&&(s=s.lastEffect,s!==null))){l=s=s.next;do{var i=l,a=i.destroy;i=i.tag,a!==void 0&&(i&2||i&4)&&To(r,t,a),l=l.next}while(l!==s)}Tn(e,t,r);break;case 1:if(!ut&&(is(r,t),s=r.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=r.memoizedProps,s.state=r.memoizedState,s.componentWillUnmount()}catch(c){Ne(r,t,c)}Tn(e,t,r);break;case 21:Tn(e,t,r);break;case 22:r.mode&1?(ut=(s=ut)||r.memoizedState!==null,Tn(e,t,r),ut=s):Tn(e,t,r);break;default:Tn(e,t,r)}}function lu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var r=e.stateNode;r===null&&(r=e.stateNode=new Dm),t.forEach(function(s){var l=Hm.bind(null,e,s);r.has(s)||(r.add(s),s.then(l,l))})}}function Ut(e,t){var r=t.deletions;if(r!==null)for(var s=0;s<r.length;s++){var l=r[s];try{var i=e,a=t,c=a;e:for(;c!==null;){switch(c.tag){case 5:lt=c.stateNode,Mt=!1;break e;case 3:lt=c.stateNode.containerInfo,Mt=!0;break e;case 4:lt=c.stateNode.containerInfo,Mt=!0;break e}c=c.return}if(lt===null)throw Error(F(160));If(i,a,l),lt=null,Mt=!1;var d=l.alternate;d!==null&&(d.return=null),l.return=null}catch(p){Ne(l,t,p)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Ef(t,e),t=t.sibling}function Ef(e,t){var r=e.alternate,s=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Ut(t,e),Zt(e),s&4){try{tl(3,e,e.return),Xi(3,e)}catch(h){Ne(e,e.return,h)}try{tl(5,e,e.return)}catch(h){Ne(e,e.return,h)}}break;case 1:Ut(t,e),Zt(e),s&512&&r!==null&&is(r,r.return);break;case 5:if(Ut(t,e),Zt(e),s&512&&r!==null&&is(r,r.return),e.flags&32){var l=e.stateNode;try{ll(l,"")}catch(h){Ne(e,e.return,h)}}if(s&4&&(l=e.stateNode,l!=null)){var i=e.memoizedProps,a=r!==null?r.memoizedProps:i,c=e.type,d=e.updateQueue;if(e.updateQueue=null,d!==null)try{c==="input"&&i.type==="radio"&&i.name!=null&&Ju(l,i),eo(c,a);var p=eo(c,i);for(a=0;a<d.length;a+=2){var v=d[a],f=d[a+1];v==="style"?np(l,f):v==="dangerouslySetInnerHTML"?ep(l,f):v==="children"?ll(l,f):Go(l,v,f,p)}switch(c){case"input":Xa(l,i);break;case"textarea":Vu(l,i);break;case"select":var u=l._wrapperState.wasMultiple;l._wrapperState.wasMultiple=!!i.multiple;var m=i.value;m!=null?ds(l,!!i.multiple,m,!1):u!==!!i.multiple&&(i.defaultValue!=null?ds(l,!!i.multiple,i.defaultValue,!0):ds(l,!!i.multiple,i.multiple?[]:"",!1))}l[hl]=i}catch(h){Ne(e,e.return,h)}}break;case 6:if(Ut(t,e),Zt(e),s&4){if(e.stateNode===null)throw Error(F(162));l=e.stateNode,i=e.memoizedProps;try{l.nodeValue=i}catch(h){Ne(e,e.return,h)}}break;case 3:if(Ut(t,e),Zt(e),s&4&&r!==null&&r.memoizedState.isDehydrated)try{dl(t.containerInfo)}catch(h){Ne(e,e.return,h)}break;case 4:Ut(t,e),Zt(e);break;case 13:Ut(t,e),Zt(e),l=e.child,l.flags&8192&&(i=l.memoizedState!==null,l.stateNode.isHidden=i,!i||l.alternate!==null&&l.alternate.memoizedState!==null||(kd=Fe())),s&4&&lu(e);break;case 22:if(v=r!==null&&r.memoizedState!==null,e.mode&1?(ut=(p=ut)||v,Ut(t,e),ut=p):Ut(t,e),Zt(e),s&8192){if(p=e.memoizedState!==null,(e.stateNode.isHidden=p)&&!v&&e.mode&1)for(q=e,v=e.child;v!==null;){for(f=q=v;q!==null;){switch(u=q,m=u.child,u.tag){case 0:case 11:case 14:case 15:tl(4,u,u.return);break;case 1:is(u,u.return);var j=u.stateNode;if(typeof j.componentWillUnmount=="function"){s=u,r=u.return;try{t=s,j.props=t.memoizedProps,j.state=t.memoizedState,j.componentWillUnmount()}catch(h){Ne(s,r,h)}}break;case 5:is(u,u.return);break;case 22:if(u.memoizedState!==null){au(f);continue}}m!==null?(m.return=u,q=m):au(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=tp("display",a))}catch(h){Ne(e,e.return,h)}}}else if(f.tag===6){if(v===null)try{f.stateNode.nodeValue=p?"":f.memoizedProps}catch(h){Ne(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:Ut(t,e),Zt(e),s&4&&lu(e);break;case 21:break;default:Ut(t,e),Zt(e)}}function Zt(e){var t=e.flags;if(t&2){try{e:{for(var r=e.return;r!==null;){if(Tf(r)){var s=r;break e}r=r.return}throw Error(F(160))}switch(s.tag){case 5:var l=s.stateNode;s.flags&32&&(ll(l,""),s.flags&=-33);var i=su(e);Po(e,i,l);break;case 3:case 4:var a=s.stateNode.containerInfo,c=su(e);Eo(e,c,a);break;default:throw Error(F(161))}}catch(d){Ne(e,e.return,d)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Om(e,t,r){q=e,Pf(e)}function Pf(e,t,r){for(var s=(e.mode&1)!==0;q!==null;){var l=q,i=l.child;if(l.tag===22&&s){var a=l.memoizedState!==null||Ql;if(!a){var c=l.alternate,d=c!==null&&c.memoizedState!==null||ut;c=Ql;var p=ut;if(Ql=a,(ut=d)&&!p)for(q=l;q!==null;)a=q,d=a.child,a.tag===22&&a.memoizedState!==null?ou(l):d!==null?(d.return=a,q=d):ou(l);for(;i!==null;)q=i,Pf(i),i=i.sibling;q=l,Ql=c,ut=p}iu(e)}else l.subtreeFlags&8772&&i!==null?(i.return=l,q=i):iu(e)}}function iu(e){for(;q!==null;){var t=q;if(t.flags&8772){var r=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:ut||Xi(5,t);break;case 1:var s=t.stateNode;if(t.flags&4&&!ut)if(r===null)s.componentDidMount();else{var l=t.elementType===t.type?r.memoizedProps:Ft(t.type,r.memoizedProps);s.componentDidUpdate(l,r.memoizedState,s.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Hc(t,i,s);break;case 3:var a=t.updateQueue;if(a!==null){if(r=null,t.child!==null)switch(t.child.tag){case 5:r=t.child.stateNode;break;case 1:r=t.child.stateNode}Hc(t,a,r)}break;case 5:var c=t.stateNode;if(r===null&&t.flags&4){r=c;var d=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":d.autoFocus&&r.focus();break;case"img":d.src&&(r.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&&dl(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(F(163))}ut||t.flags&512&&Io(t)}catch(u){Ne(t,t.return,u)}}if(t===e){q=null;break}if(r=t.sibling,r!==null){r.return=t.return,q=r;break}q=t.return}}function au(e){for(;q!==null;){var t=q;if(t===e){q=null;break}var r=t.sibling;if(r!==null){r.return=t.return,q=r;break}q=t.return}}function ou(e){for(;q!==null;){var t=q;try{switch(t.tag){case 0:case 11:case 15:var r=t.return;try{Xi(4,t)}catch(d){Ne(t,r,d)}break;case 1:var s=t.stateNode;if(typeof s.componentDidMount=="function"){var l=t.return;try{s.componentDidMount()}catch(d){Ne(t,l,d)}}var i=t.return;try{Io(t)}catch(d){Ne(t,i,d)}break;case 5:var a=t.return;try{Io(t)}catch(d){Ne(t,a,d)}}}catch(d){Ne(t,t.return,d)}if(t===e){q=null;break}var c=t.sibling;if(c!==null){c.return=t.return,q=c;break}q=t.return}}var Wm=Math.ceil,Ri=kn.ReactCurrentDispatcher,Sd=kn.ReactCurrentOwner,Ot=kn.ReactCurrentBatchConfig,fe=0,rt=null,Ke=null,it=0,zt=0,as=qn(0),et=0,jl=null,br=0,qi=0,wd=0,nl=null,jt=null,kd=0,bs=1/0,gn=null,Di=!1,Ao=null,Mn=null,Yl=!1,Ln=null,Li=0,rl=0,Ro=null,ci=-1,ui=0;function xt(){return fe&6?Fe():ci!==-1?ci:ci=Fe()}function Hn(e){return e.mode&1?fe&2&&it!==0?it&-it:jm.transition!==null?(ui===0&&(ui=hp()),ui):(e=ye,e!==0||(e=window.event,e=e===void 0?16:bp(e.type)),e):1}function Qt(e,t,r,s){if(50<rl)throw rl=0,Ro=null,Error(F(185));wl(e,r,s),(!(fe&2)||e!==rt)&&(e===rt&&(!(fe&2)&&(qi|=r),et===4&&Rn(e,it)),kt(e,s),r===1&&fe===0&&!(t.mode&1)&&(bs=Fe()+500,Ki&&Jn()))}function kt(e,t){var r=e.callbackNode;jx(e,t);var s=yi(e,e===rt?it:0);if(s===0)r!==null&&mc(r),e.callbackNode=null,e.callbackPriority=0;else if(t=s&-s,e.callbackPriority!==t){if(r!=null&&mc(r),t===1)e.tag===0?vm(du.bind(null,e)):$p(du.bind(null,e)),gm(function(){!(fe&6)&&Jn()}),r=null;else{switch(gp(s)){case 1:r=qo;break;case 4:r=pp;break;case 16:r=mi;break;case 536870912:r=fp;break;default:r=mi}r=Bf(r,Af.bind(null,e))}e.callbackPriority=t,e.callbackNode=r}}function Af(e,t){if(ci=-1,ui=0,fe&6)throw Error(F(327));var r=e.callbackNode;if(hs()&&e.callbackNode!==r)return null;var s=yi(e,e===rt?it:0);if(s===0)return null;if(s&30||s&e.expiredLanes||t)t=Oi(e,s);else{t=s;var l=fe;fe|=2;var i=Df();(rt!==e||it!==t)&&(gn=null,bs=Fe()+500,xr(e,t));do try{$m();break}catch(c){Rf(e,c)}while(!0);dd(),Ri.current=i,fe=l,Ke!==null?t=0:(rt=null,it=0,t=et)}if(t!==0){if(t===2&&(l=lo(e),l!==0&&(s=l,t=Do(e,l))),t===1)throw r=jl,xr(e,0),Rn(e,s),kt(e,Fe()),r;if(t===6)Rn(e,s);else{if(l=e.current.alternate,!(s&30)&&!Nm(l)&&(t=Oi(e,s),t===2&&(i=lo(e),i!==0&&(s=i,t=Do(e,i))),t===1))throw r=jl,xr(e,0),Rn(e,s),kt(e,Fe()),r;switch(e.finishedWork=l,e.finishedLanes=s,t){case 0:case 1:throw Error(F(345));case 2:pr(e,jt,gn);break;case 3:if(Rn(e,s),(s&130023424)===s&&(t=kd+500-Fe(),10<t)){if(yi(e,0)!==0)break;if(l=e.suspendedLanes,(l&s)!==s){xt(),e.pingedLanes|=e.suspendedLanes&l;break}e.timeoutHandle=ho(pr.bind(null,e,jt,gn),t);break}pr(e,jt,gn);break;case 4:if(Rn(e,s),(s&4194240)===s)break;for(t=e.eventTimes,l=-1;0<s;){var a=31-Kt(s);i=1<<a,a=t[a],a>l&&(l=a),s&=~i}if(s=l,s=Fe()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*Wm(s/1960))-s,10<s){e.timeoutHandle=ho(pr.bind(null,e,jt,gn),s);break}pr(e,jt,gn);break;case 5:pr(e,jt,gn);break;default:throw Error(F(329))}}}return kt(e,Fe()),e.callbackNode===r?Af.bind(null,e):null}function Do(e,t){var r=nl;return e.current.memoizedState.isDehydrated&&(xr(e,t).flags|=256),e=Oi(e,t),e!==2&&(t=jt,jt=r,t!==null&&Lo(t)),e}function Lo(e){jt===null?jt=e:jt.push.apply(jt,e)}function Nm(e){for(var t=e;;){if(t.flags&16384){var r=t.updateQueue;if(r!==null&&(r=r.stores,r!==null))for(var s=0;s<r.length;s++){var l=r[s],i=l.getSnapshot;l=l.value;try{if(!Yt(i(),l))return!1}catch{return!1}}}if(r=t.child,t.subtreeFlags&16384&&r!==null)r.return=t,t=r;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 Rn(e,t){for(t&=~wd,t&=~qi,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var r=31-Kt(t),s=1<<r;e[r]=-1,t&=~s}}function du(e){if(fe&6)throw Error(F(327));hs();var t=yi(e,0);if(!(t&1))return kt(e,Fe()),null;var r=Oi(e,t);if(e.tag!==0&&r===2){var s=lo(e);s!==0&&(t=s,r=Do(e,s))}if(r===1)throw r=jl,xr(e,0),Rn(e,t),kt(e,Fe()),r;if(r===6)throw Error(F(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,pr(e,jt,gn),kt(e,Fe()),null}function _d(e,t){var r=fe;fe|=1;try{return e(t)}finally{fe=r,fe===0&&(bs=Fe()+500,Ki&&Jn())}}function Sr(e){Ln!==null&&Ln.tag===0&&!(fe&6)&&hs();var t=fe;fe|=1;var r=Ot.transition,s=ye;try{if(Ot.transition=null,ye=1,e)return e()}finally{ye=s,Ot.transition=r,fe=t,!(fe&6)&&Jn()}}function Cd(){zt=as.current,ke(as)}function xr(e,t){e.finishedWork=null,e.finishedLanes=0;var r=e.timeoutHandle;if(r!==-1&&(e.timeoutHandle=-1,hm(r)),Ke!==null)for(r=Ke.return;r!==null;){var s=r;switch(id(s),s.tag){case 1:s=s.type.childContextTypes,s!=null&&wi();break;case 3:vs(),ke(St),ke(pt),gd();break;case 5:hd(s);break;case 4:vs();break;case 13:ke(Ae);break;case 19:ke(Ae);break;case 10:cd(s.type._context);break;case 22:case 23:Cd()}r=r.return}if(rt=e,Ke=e=Gn(e.current,null),it=zt=t,et=0,jl=null,wd=qi=br=0,jt=nl=null,hr!==null){for(t=0;t<hr.length;t++)if(r=hr[t],s=r.interleaved,s!==null){r.interleaved=null;var l=s.next,i=r.pending;if(i!==null){var a=i.next;i.next=l,s.next=a}r.pending=s}hr=null}return e}function Rf(e,t){do{var r=Ke;try{if(dd(),ai.current=Ai,Pi){for(var s=Re.memoizedState;s!==null;){var l=s.queue;l!==null&&(l.pending=null),s=s.next}Pi=!1}if(jr=0,nt=Ze=Re=null,el=!1,ml=0,Sd.current=null,r===null||r.return===null){et=1,jl=t,Ke=null;break}e:{var i=e,a=r.return,c=r,d=t;if(t=it,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=qc(a);if(m!==null){m.flags&=-257,Jc(m,a,c,i,t),m.mode&1&&Xc(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)){Xc(i,p,t),zd();break e}d=Error(F(426))}}else if(Ee&&c.mode&1){var S=qc(a);if(S!==null){!(S.flags&65536)&&(S.flags|=256),Jc(S,a,c,i,t),ad(js(d,c));break e}}i=d=js(d,c),et!==4&&(et=2),nl===null?nl=[i]:nl.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var g=xf(i,d,t);Mc(i,g);break e;case 1:c=d;var x=i.type,o=i.stateNode;if(!(i.flags&128)&&(typeof x.getDerivedStateFromError=="function"||o!==null&&typeof o.componentDidCatch=="function"&&(Mn===null||!Mn.has(o)))){i.flags|=65536,t&=-t,i.lanes|=t;var y=mf(i,c,t);Mc(i,y);break e}}i=i.return}while(i!==null)}Of(r)}catch(k){t=k,Ke===r&&r!==null&&(Ke=r=r.return);continue}break}while(!0)}function Df(){var e=Ri.current;return Ri.current=Ai,e===null?Ai:e}function zd(){(et===0||et===3||et===2)&&(et=4),rt===null||!(br&268435455)&&!(qi&268435455)||Rn(rt,it)}function Oi(e,t){var r=fe;fe|=2;var s=Df();(rt!==e||it!==t)&&(gn=null,xr(e,t));do try{Bm();break}catch(l){Rf(e,l)}while(!0);if(dd(),fe=r,Ri.current=s,Ke!==null)throw Error(F(261));return rt=null,it=0,et}function Bm(){for(;Ke!==null;)Lf(Ke)}function $m(){for(;Ke!==null&&!ux();)Lf(Ke)}function Lf(e){var t=Nf(e.alternate,e,zt);e.memoizedProps=e.pendingProps,t===null?Of(e):Ke=t,Sd.current=null}function Of(e){var t=e;do{var r=t.alternate;if(e=t.return,t.flags&32768){if(r=Rm(r,t),r!==null){r.flags&=32767,Ke=r;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{et=6,Ke=null;return}}else if(r=Am(r,t,zt),r!==null){Ke=r;return}if(t=t.sibling,t!==null){Ke=t;return}Ke=t=e}while(t!==null);et===0&&(et=5)}function pr(e,t,r){var s=ye,l=Ot.transition;try{Ot.transition=null,ye=1,Um(e,t,r,s)}finally{Ot.transition=l,ye=s}return null}function Um(e,t,r,s){do hs();while(Ln!==null);if(fe&6)throw Error(F(327));r=e.finishedWork;var l=e.finishedLanes;if(r===null)return null;if(e.finishedWork=null,e.finishedLanes=0,r===e.current)throw Error(F(177));e.callbackNode=null,e.callbackPriority=0;var i=r.lanes|r.childLanes;if(bx(e,i),e===rt&&(Ke=rt=null,it=0),!(r.subtreeFlags&2064)&&!(r.flags&2064)||Yl||(Yl=!0,Bf(mi,function(){return hs(),null})),i=(r.flags&15990)!==0,r.subtreeFlags&15990||i){i=Ot.transition,Ot.transition=null;var a=ye;ye=1;var c=fe;fe|=4,Sd.current=null,Lm(e,r),Ef(r,e),am(po),vi=!!uo,po=uo=null,e.current=r,Om(r),px(),fe=c,ye=a,Ot.transition=i}else e.current=r;if(Yl&&(Yl=!1,Ln=e,Li=l),i=e.pendingLanes,i===0&&(Mn=null),gx(r.stateNode),kt(e,Fe()),t!==null)for(s=e.onRecoverableError,r=0;r<t.length;r++)l=t[r],s(l.value,{componentStack:l.stack,digest:l.digest});if(Di)throw Di=!1,e=Ao,Ao=null,e;return Li&1&&e.tag!==0&&hs(),i=e.pendingLanes,i&1?e===Ro?rl++:(rl=0,Ro=e):rl=0,Jn(),null}function hs(){if(Ln!==null){var e=gp(Li),t=Ot.transition,r=ye;try{if(Ot.transition=null,ye=16>e?16:e,Ln===null)var s=!1;else{if(e=Ln,Ln=null,Li=0,fe&6)throw Error(F(331));var l=fe;for(fe|=4,q=e.current;q!==null;){var i=q,a=i.child;if(q.flags&16){var c=i.deletions;if(c!==null){for(var d=0;d<c.length;d++){var p=c[d];for(q=p;q!==null;){var v=q;switch(v.tag){case 0:case 11:case 15:tl(8,v,i)}var f=v.child;if(f!==null)f.return=v,q=f;else for(;q!==null;){v=q;var u=v.sibling,m=v.return;if(zf(v),v===p){q=null;break}if(u!==null){u.return=m,q=u;break}q=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)}}q=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,q=a;else e:for(;q!==null;){if(i=q,i.flags&2048)switch(i.tag){case 0:case 11:case 15:tl(9,i,i.return)}var g=i.sibling;if(g!==null){g.return=i.return,q=g;break e}q=i.return}}var x=e.current;for(q=x;q!==null;){a=q;var o=a.child;if(a.subtreeFlags&2064&&o!==null)o.return=a,q=o;else e:for(a=x;q!==null;){if(c=q,c.flags&2048)try{switch(c.tag){case 0:case 11:case 15:Xi(9,c)}}catch(k){Ne(c,c.return,k)}if(c===a){q=null;break e}var y=c.sibling;if(y!==null){y.return=c.return,q=y;break e}q=c.return}}if(fe=l,Jn(),sn&&typeof sn.onPostCommitFiberRoot=="function")try{sn.onPostCommitFiberRoot(Ui,e)}catch{}s=!0}return s}finally{ye=r,Ot.transition=t}}return!1}function cu(e,t,r){t=js(r,t),t=xf(e,t,1),e=Fn(e,t,1),t=xt(),e!==null&&(wl(e,1,t),kt(e,t))}function Ne(e,t,r){if(e.tag===3)cu(e,e,r);else for(;t!==null;){if(t.tag===3){cu(t,e,r);break}else if(t.tag===1){var s=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof s.componentDidCatch=="function"&&(Mn===null||!Mn.has(s))){e=js(r,e),e=mf(t,e,1),t=Fn(t,e,1),e=xt(),t!==null&&(wl(t,1,e),kt(t,e));break}}t=t.return}}function Fm(e,t,r){var s=e.pingCache;s!==null&&s.delete(t),t=xt(),e.pingedLanes|=e.suspendedLanes&r,rt===e&&(it&r)===r&&(et===4||et===3&&(it&130023424)===it&&500>Fe()-kd?xr(e,0):wd|=r),kt(e,t)}function Wf(e,t){t===0&&(e.mode&1?(t=Nl,Nl<<=1,!(Nl&130023424)&&(Nl=4194304)):t=1);var r=xt();e=Sn(e,t),e!==null&&(wl(e,t,r),kt(e,r))}function Mm(e){var t=e.memoizedState,r=0;t!==null&&(r=t.retryLane),Wf(e,r)}function Hm(e,t){var r=0;switch(e.tag){case 13:var s=e.stateNode,l=e.memoizedState;l!==null&&(r=l.retryLane);break;case 19:s=e.stateNode;break;default:throw Error(F(314))}s!==null&&s.delete(t),Wf(e,r)}var Nf;Nf=function(e,t,r){if(e!==null)if(e.memoizedProps!==t.pendingProps||St.current)bt=!0;else{if(!(e.lanes&r)&&!(t.flags&128))return bt=!1,Pm(e,t,r);bt=!!(e.flags&131072)}else bt=!1,Ee&&t.flags&1048576&&Up(t,Ci,t.index);switch(t.lanes=0,t.tag){case 2:var s=t.type;di(e,t),e=t.pendingProps;var l=xs(t,pt.current);fs(t,r),l=md(null,t,s,e,l,r);var i=yd();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,wt(s)?(i=!0,ki(t)):i=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,pd(t),l.updater=Yi,t.stateNode=l,l._reactInternals=t,bo(t,s,e,r),t=ko(null,t,s,!0,i,r)):(t.tag=0,Ee&&i&&ld(t),gt(null,t,l,r),t=t.child),t;case 16:s=t.elementType;e:{switch(di(e,t),e=t.pendingProps,l=s._init,s=l(s._payload),t.type=s,l=t.tag=Km(s),e=Ft(s,e),l){case 0:t=wo(null,t,s,e,r);break e;case 1:t=eu(null,t,s,e,r);break e;case 11:t=Vc(null,t,s,e,r);break e;case 14:t=Zc(null,t,s,Ft(s.type,e),r);break e}throw Error(F(306,s,""))}return t;case 0:return s=t.type,l=t.pendingProps,l=t.elementType===s?l:Ft(s,l),wo(e,t,s,l,r);case 1:return s=t.type,l=t.pendingProps,l=t.elementType===s?l:Ft(s,l),eu(e,t,s,l,r);case 3:e:{if(bf(t),e===null)throw Error(F(387));s=t.pendingProps,i=t.memoizedState,l=i.element,Qp(e,t),Ii(t,s,null,r);var a=t.memoizedState;if(s=a.element,i.isDehydrated)if(i={element:s,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){l=js(Error(F(423)),t),t=tu(e,t,s,r,l);break e}else if(s!==l){l=js(Error(F(424)),t),t=tu(e,t,s,r,l);break e}else for(Tt=Un(t.stateNode.containerInfo.firstChild),It=t,Ee=!0,Ht=null,r=Gp(t,null,s,r),t.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(ms(),s===l){t=wn(e,t,r);break e}gt(e,t,s,r)}t=t.child}return t;case 5:return Yp(t),e===null&&yo(t),s=t.type,l=t.pendingProps,i=e!==null?e.memoizedProps:null,a=l.children,fo(s,l)?a=null:i!==null&&fo(s,i)&&(t.flags|=32),jf(e,t),gt(e,t,a,r),t.child;case 6:return e===null&&yo(t),null;case 13:return Sf(e,t,r);case 4:return fd(t,t.stateNode.containerInfo),s=t.pendingProps,e===null?t.child=ys(t,null,s,r):gt(e,t,s,r),t.child;case 11:return s=t.type,l=t.pendingProps,l=t.elementType===s?l:Ft(s,l),Vc(e,t,s,l,r);case 7:return gt(e,t,t.pendingProps,r),t.child;case 8:return gt(e,t,t.pendingProps.children,r),t.child;case 12:return gt(e,t,t.pendingProps.children,r),t.child;case 10:e:{if(s=t.type._context,l=t.pendingProps,i=t.memoizedProps,a=l.value,be(zi,s._currentValue),s._currentValue=a,i!==null)if(Yt(i.value,a)){if(i.children===l.children&&!St.current){t=wn(e,t,r);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===s){if(i.tag===1){d=vn(-1,r&-r),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|=r,d=i.alternate,d!==null&&(d.lanes|=r),vo(i.return,r,t),c.lanes|=r;break}d=d.next}}else if(i.tag===10)a=i.type===t.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(F(341));a.lanes|=r,c=a.alternate,c!==null&&(c.lanes|=r),vo(a,r,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}gt(e,t,l.children,r),t=t.child}return t;case 9:return l=t.type,s=t.pendingProps.children,fs(t,r),l=Wt(l),s=s(l),t.flags|=1,gt(e,t,s,r),t.child;case 14:return s=t.type,l=Ft(s,t.pendingProps),l=Ft(s.type,l),Zc(e,t,s,l,r);case 15:return yf(e,t,t.type,t.pendingProps,r);case 17:return s=t.type,l=t.pendingProps,l=t.elementType===s?l:Ft(s,l),di(e,t),t.tag=1,wt(s)?(e=!0,ki(t)):e=!1,fs(t,r),gf(t,s,l),bo(t,s,l,r),ko(null,t,s,!0,e,r);case 19:return wf(e,t,r);case 22:return vf(e,t,r)}throw Error(F(156,t.tag))};function Bf(e,t){return up(e,t)}function Gm(e,t,r,s){this.tag=e,this.key=r,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=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Lt(e,t,r,s){return new Gm(e,t,r,s)}function Td(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Km(e){if(typeof e=="function")return Td(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Qo)return 11;if(e===Yo)return 14}return 2}function Gn(e,t){var r=e.alternate;return r===null?(r=Lt(e.tag,t,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=t,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&14680064,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,t=e.dependencies,r.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r}function pi(e,t,r,s,l,i){var a=2;if(s=e,typeof e=="function")Td(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Jr:return mr(r.children,l,i,t);case Ko:a=8,l|=8;break;case Ha:return e=Lt(12,r,t,l|2),e.elementType=Ha,e.lanes=i,e;case Ga:return e=Lt(13,r,t,l),e.elementType=Ga,e.lanes=i,e;case Ka:return e=Lt(19,r,t,l),e.elementType=Ka,e.lanes=i,e;case Yu:return Ji(r,l,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Ku:a=10;break e;case Qu:a=9;break e;case Qo:a=11;break e;case Yo:a=14;break e;case En:a=16,s=null;break e}throw Error(F(130,e==null?e:typeof e,""))}return t=Lt(a,r,t,l),t.elementType=e,t.type=s,t.lanes=i,t}function mr(e,t,r,s){return e=Lt(7,e,s,t),e.lanes=r,e}function Ji(e,t,r,s){return e=Lt(22,e,s,t),e.elementType=Yu,e.lanes=r,e.stateNode={isHidden:!1},e}function Na(e,t,r){return e=Lt(6,e,null,t),e.lanes=r,e}function Ba(e,t,r){return t=Lt(4,e.children!==null?e.children:[],e.key,t),t.lanes=r,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Qm(e,t,r,s,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=va(0),this.expirationTimes=va(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=va(0),this.identifierPrefix=s,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Id(e,t,r,s,l,i,a,c,d){return e=new Qm(e,t,r,c,d),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Lt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:s,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},pd(i),e}function Ym(e,t,r){var s=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:qr,key:s==null?null:""+s,children:e,containerInfo:t,implementation:r}}function $f(e){if(!e)return Qn;e=e._reactInternals;e:{if(_r(e)!==e||e.tag!==1)throw Error(F(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(wt(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(F(171))}if(e.tag===1){var r=e.type;if(wt(r))return Bp(e,r,t)}return t}function Uf(e,t,r,s,l,i,a,c,d){return e=Id(r,s,!0,e,l,i,a,c,d),e.context=$f(null),r=e.current,s=xt(),l=Hn(r),i=vn(s,l),i.callback=t??null,Fn(r,i,l),e.current.lanes=l,wl(e,l,s),kt(e,s),e}function Vi(e,t,r,s){var l=t.current,i=xt(),a=Hn(l);return r=$f(r),t.context===null?t.context=r:t.pendingContext=r,t=vn(i,a),t.payload={element:e},s=s===void 0?null:s,s!==null&&(t.callback=s),e=Fn(l,t,a),e!==null&&(Qt(e,l,a,i),ii(e,l,a)),a}function Wi(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function uu(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var r=e.retryLane;e.retryLane=r!==0&&r<t?r:t}}function Ed(e,t){uu(e,t),(e=e.alternate)&&uu(e,t)}function Xm(){return null}var Ff=typeof reportError=="function"?reportError:function(e){console.error(e)};function Pd(e){this._internalRoot=e}Zi.prototype.render=Pd.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(F(409));Vi(e,t,null,null)};Zi.prototype.unmount=Pd.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Sr(function(){Vi(null,e,null,null)}),t[bn]=null}};function Zi(e){this._internalRoot=e}Zi.prototype.unstable_scheduleHydration=function(e){if(e){var t=yp();e={blockedOn:null,target:e,priority:t};for(var r=0;r<An.length&&t!==0&&t<An[r].priority;r++);An.splice(r,0,e),r===0&&jp(e)}};function Ad(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ea(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function pu(){}function qm(e,t,r,s,l){if(l){if(typeof s=="function"){var i=s;s=function(){var p=Wi(a);i.call(p)}}var a=Uf(t,s,e,0,null,!1,!1,"",pu);return e._reactRootContainer=a,e[bn]=a.current,pl(e.nodeType===8?e.parentNode:e),Sr(),a}for(;l=e.lastChild;)e.removeChild(l);if(typeof s=="function"){var c=s;s=function(){var p=Wi(d);c.call(p)}}var d=Id(e,0,!1,null,null,!1,!1,"",pu);return e._reactRootContainer=d,e[bn]=d.current,pl(e.nodeType===8?e.parentNode:e),Sr(function(){Vi(t,d,r,s)}),d}function ta(e,t,r,s,l){var i=r._reactRootContainer;if(i){var a=i;if(typeof l=="function"){var c=l;l=function(){var d=Wi(a);c.call(d)}}Vi(t,a,e,l)}else a=qm(r,t,e,l,s);return Wi(a)}xp=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var r=Ks(t.pendingLanes);r!==0&&(Jo(t,r|1),kt(t,Fe()),!(fe&6)&&(bs=Fe()+500,Jn()))}break;case 13:Sr(function(){var s=Sn(e,1);if(s!==null){var l=xt();Qt(s,e,1,l)}}),Ed(e,1)}};Vo=function(e){if(e.tag===13){var t=Sn(e,134217728);if(t!==null){var r=xt();Qt(t,e,134217728,r)}Ed(e,134217728)}};mp=function(e){if(e.tag===13){var t=Hn(e),r=Sn(e,t);if(r!==null){var s=xt();Qt(r,e,t,s)}Ed(e,t)}};yp=function(){return ye};vp=function(e,t){var r=ye;try{return ye=e,t()}finally{ye=r}};no=function(e,t,r){switch(t){case"input":if(Xa(e,r),t=r.name,r.type==="radio"&&t!=null){for(r=e;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<r.length;t++){var s=r[t];if(s!==e&&s.form===e.form){var l=Gi(s);if(!l)throw Error(F(90));qu(s),Xa(s,l)}}}break;case"textarea":Vu(e,r);break;case"select":t=r.value,t!=null&&ds(e,!!r.multiple,t,!1)}};lp=_d;ip=Sr;var Jm={usingClientEntryPoint:!1,Events:[_l,ts,Gi,rp,sp,_d]},Bs={findFiberByHostInstance:fr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Vm={bundleType:Bs.bundleType,version:Bs.version,rendererPackageName:Bs.rendererPackageName,rendererConfig:Bs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:kn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=dp(e),e===null?null:e.stateNode},findFiberByHostInstance:Bs.findFiberByHostInstance||Xm,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 Xl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xl.isDisabled&&Xl.supportsFiber)try{Ui=Xl.inject(Vm),sn=Xl}catch{}}Pt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Jm;Pt.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ad(t))throw Error(F(200));return Ym(e,t,null,r)};Pt.createRoot=function(e,t){if(!Ad(e))throw Error(F(299));var r=!1,s="",l=Ff;return t!=null&&(t.unstable_strictMode===!0&&(r=!0),t.identifierPrefix!==void 0&&(s=t.identifierPrefix),t.onRecoverableError!==void 0&&(l=t.onRecoverableError)),t=Id(e,1,!1,null,null,r,!1,s,l),e[bn]=t.current,pl(e.nodeType===8?e.parentNode:e),new Pd(t)};Pt.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(F(188)):(e=Object.keys(e).join(","),Error(F(268,e)));return e=dp(t),e=e===null?null:e.stateNode,e};Pt.flushSync=function(e){return Sr(e)};Pt.hydrate=function(e,t,r){if(!ea(t))throw Error(F(200));return ta(null,e,t,!0,r)};Pt.hydrateRoot=function(e,t,r){if(!Ad(e))throw Error(F(405));var s=r!=null&&r.hydratedSources||null,l=!1,i="",a=Ff;if(r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(i=r.identifierPrefix),r.onRecoverableError!==void 0&&(a=r.onRecoverableError)),t=Uf(t,null,e,1,r??null,l,!1,i,a),e[bn]=t.current,pl(e),s)for(e=0;e<s.length;e++)r=s[e],l=r._getVersion,l=l(r._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[r,l]:t.mutableSourceEagerHydrationData.push(r,l);return new Zi(t)};Pt.render=function(e,t,r){if(!ea(t))throw Error(F(200));return ta(null,e,t,!1,r)};Pt.unmountComponentAtNode=function(e){if(!ea(e))throw Error(F(40));return e._reactRootContainer?(Sr(function(){ta(null,null,e,!1,function(){e._reactRootContainer=null,e[bn]=null})}),!0):!1};Pt.unstable_batchedUpdates=_d;Pt.unstable_renderSubtreeIntoContainer=function(e,t,r,s){if(!ea(r))throw Error(F(200));if(e==null||e._reactInternals===void 0)throw Error(F(38));return ta(e,t,r,!1,s)};Pt.version="18.3.1-next-f1338f8080-20240426";function Mf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Mf)}catch(e){console.error(e)}}Mf(),Fu.exports=Pt;var Zm=Fu.exports,Hf,fu=Zm;Hf=fu.createRoot,fu.hydrateRoot;const ce="",O={incidents:"SB Incident",ideas:"SB Idea",orders:"SB Order",organizations:"SB Organization",processes:"SB Process",managements:"Managements",departments:"Department",branches:"Branch",incidentTypes:"Incident Types",ideaTypes:"Idea Types",orderTypes:"Order Types",processTypes:"Process Types",incidentClass:"Incident Class",incidentField:"Incident Field",incidentStatuses:"Incident Statuses",ideaStatuses:"Idea Statuses",orderStatuses:"Order Statuses",processStatuses:"Process Statuses",users:"User",cycles:"SB Cycle",kpiInput:"SB KPI Input",delegations:"SB Delegation",groupCompanies:"SB Group Company"},U={bg:"#f5f6fa",accent:"#4f46e5",red:"#ef4444",orange:"#f59e0b",green:"#16a34a",purple:"#7c3aed",blue:"#2563eb",teal:"#0d9488",gray:"#94a3b8"},ey=[{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"}],Gf=[{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"}],ty=new Set(["users","group-companies"]);function ny(e){return e!=="Admin"&&e!=="Auditor"?[]:Gf.filter(({id:t})=>e==="Admin"||!ty.has(t))}const In=(e=[])=>[{key:"name1",label:"Name"},{key:"status",label:"Status"},...e,{key:"creation_date",label:"Created On"}],ry={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:In(),defaultColumns:["name1","status","creation_date"]},"idea-types":{label:"Idea Types",columns:In(),defaultColumns:["name1","status","creation_date"]},"order-types":{label:"Order Types",columns:In(),defaultColumns:["name1","status","creation_date"]},"process-types":{label:"Process Types",columns:In(),defaultColumns:["name1","status","creation_date"]},"incident-statuses":{label:"Incident Statuses",columns:In([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"idea-statuses":{label:"Idea Statuses",columns:In([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"order-statuses":{label:"Order Statuses",columns:In([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"process-statuses":{label:"Process Statuses",columns:In([{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"]}},sy=()=>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"})]}),ly=()=>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"})]}),iy=()=>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 tt({onView:e,onEdit:t,onDelete:r}){const s=(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:[s("#f0f9ff","#e0f2fe","#0284c7",e,n.jsx(sy,{}),"View"),s("#f0fdf4","#dcfce7","#16a34a",t,n.jsx(ly,{}),"Edit"),r&&s("#fff1f2","#fee2e2","#e11d48",r,n.jsx(iy,{}),"Delete")]})}const E={width:"100%",height:34,padding:"7px 10px",border:"1px solid #ddd",borderRadius:6,fontSize:12,boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif"},T={display:"block",marginBottom:5,fontSize:11,color:"#555",fontWeight:600};function ay(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 xe(e,t){return e.filter(r=>ay(r)||r.name===t)}const oy={incident:["Rejected","Executed & Closed"],idea:["Rejected","Executed & Closed"],order:["Closed"],process:["Closed"]};function On(e,t){return!!t&&oy[e].includes(t)}function Ss(e,t,r,s){return e.filter(l=>{const i=t[l.name]||[];return!(i.includes("SB Admin")||i.includes("System Manager")||!i.includes(r)||s&&l.custom_organization&&l.custom_organization!==s)})}const ws={width:16,height:16,cursor:"pointer",accentColor:"#2563eb",flexShrink:0};function fi(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 dy(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 bl=(e,t)=>{let r;return typeof t=="object"&&t!==null?r=t:typeof t=="string"&&t.startsWith("#")?r=fi(e):typeof t=="string"?r=fi(t):r=fi(e),n.jsx("span",{className:"status-badge",style:{background:r.bg,color:r.color,border:`1px solid ${r.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})},Yn=e=>bl(e,fi(e)),Rd=e=>bl(e,dy(e));function zl({deletedBy:e,deletedOn:t,reason:r,onRestore:s,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," "]}),r&&n.jsxs("div",{children:[n.jsx("strong",{children:"Reason:"})," ",r]})]})]}),s&&n.jsxs("button",{onClick:s,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 na({onDelete:e,disabled:t,title:r="Delete Request",btnText:s="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:r}),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:s})]})]})}function ie({title:e,children:t,style:r}){return n.jsxs("div",{style:{background:"#ffffff",borderRadius:10,border:"1px solid #e2e8f0",padding:"16px 20px",marginBottom:16,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.03)",...r},children:[n.jsx("div",{style:{fontSize:14,fontWeight:700,color:"#1e293b",marginBottom:14,display:"flex",alignItems:"center",gap:8},children:n.jsx("span",{children:e})}),t]})}function ra({title:e="Status Summary",priority:t,createdDate:r,modifiedDate:s,assignedTo:l,status:i}){const a=c=>{if(!c)return"—";try{const d=new Date(c);return isNaN(d.getTime())?c:d.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return c}};return n.jsxs("div",{style:{background:"#ffffff",borderRadius:10,padding:14,border:"1px solid #e2e8f0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:12},children:e}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t&&n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:3},children:"Priority"}),n.jsx("div",{style:{fontSize:13,fontWeight:700,color:t==="High"||t==="Urgent"?"#dc2626":"#1e293b"},children:t})]}),i&&n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:3},children:"Status"}),n.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#334155"},children:i})]}),l&&n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:3},children:"Assigned To"}),n.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#334155",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l})]}),r&&n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:2},children:"Created"}),n.jsx("div",{style:{fontSize:11,color:"#64748b"},children:a(r)})]}),s&&n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:2},children:"Last Modified"}),n.jsx("div",{style:{fontSize:11,color:"#64748b"},children:a(s)})]})]})]})}const cy="modulepreload",uy=function(e){return"/"+e},hu={},py=function(t,r,s){let l=Promise.resolve();if(r&&r.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(r.map(d=>{if(d=uy(d),d in hu)return;hu[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":cy,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 Kf(e,t){const r=e[t.key];return r==null||r===""?"":typeof r=="object"?JSON.stringify(r):String(r)}function fy(e,t){const r=URL.createObjectURL(e),s=document.createElement("a");s.href=r,s.download=t,s.click(),URL.revokeObjectURL(r)}function hy(e,t,r){const s=e.map(a=>`"${a.label.replace(/"/g,'""')}"`).join(","),l=t.map(a=>e.map(c=>`"${Kf(a,c).replace(/"/g,'""')}"`).join(",")).join(`
|
||
`),i=new Blob([s+`
|
||
`+l],{type:"text/csv;charset=utf-8;"});fy(i,`${r}.csv`)}async function gy(e,t,r){const s=await py(()=>import("./xlsx-D_0l8YDs.js"),[]),l=t.map(c=>{const d={};for(const p of e)d[p.label]=Kf(c,p);return d}),i=s.utils.json_to_sheet(l,{header:e.map(c=>c.label)}),a=s.utils.book_new();s.utils.book_append_sheet(a,i,"Export"),s.writeFile(a,`${r}.xlsx`)}const ql="#16a34a";function xy({title:e,rows:t,columns:r,defaultColumnKeys:s,orgField:l,organizations:i,filenameBase:a,onClose:c}){const[d,p]=w.useState(""),[v,f]=w.useState("csv"),[u,m]=w.useState(new Set(s)),j=d?t.filter(y=>y[l||"organization"]===d):t,h=r.filter(y=>u.has(y.key)),S=y=>{m(k=>{const C=new Set(k);return C.has(y)?C.delete(y):C.add(y),C})},g=async()=>{h.length===0||j.length===0||(v==="csv"?hy(h,j,a):await gy(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:ql,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?ql:"#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(r.map(y=>y.key))),style:o,children:"Select All"}),n.jsx("span",{style:{color:"#d1d5db"},children:"|"}),n.jsx("button",{onClick:()=>m(new Set(s)),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:r.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:ql,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:ql,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 Qf="sidrah_rtl",Oo="sidrah-lang-change";function os(){try{return localStorage.getItem(Qf)==="1"}catch{return!1}}function Yf(){const e=!os();try{localStorage.setItem(Qf,e?"1":"0")}catch{}document.documentElement.setAttribute("dir",e?"rtl":"ltr"),document.documentElement.setAttribute("lang",e?"ar":"en-GB"),window.dispatchEvent(new CustomEvent(Oo))}function re(){const[e,t]=w.useState(os);return w.useEffect(()=>{const r=()=>t(os());return window.addEventListener(Oo,r),document.documentElement.setAttribute("dir",os()?"rtl":"ltr"),document.documentElement.setAttribute("lang",os()?"ar":"en-GB"),()=>window.removeEventListener(Oo,r)},[]),e?yy:my}const my={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"}},yy={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 vy({isOpen:e,doctype:t,docname:r,docTitle:s,isAdmin:l,isDeleting:i,onClose:a,onConfirmSoftDelete:c,onConfirmPermanentDelete:d}){const p=re(),[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:s?`${s} (${r})`:r})]}),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 Xf="/assets/logo-BlYgMyx5.png";function qf({collapsed:e,onToggleCollapsed:t,activePage:r,onNavigate:s,hasDashboard:l,hasReports:i,hasDelegations:a,role:c,hideSettings:d,rtl:p,navLabels:v,settingsLabel:f}){const u=d?[]:ny(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:Xf,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:[ey.filter(({id:m})=>(m!=="dashboard"||l)&&(m!=="reports"||i)&&(m!=="delegations"||a)).map(({id:m,icon:j})=>{const h=v[m]||m,S=m===r;return n.jsxs("div",{onClick:()=>s(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===r;return n.jsxs("div",{onClick:()=>s(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 zs=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 wr="";async function Dd(){try{const e=await fetch(`${ce}/api/method/sidrah_business.api.get_csrf_token`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(e.ok){const r=(await e.json()).message||"";if(r)return wr=r,r}}catch(e){console.error("CSRF fetch error:",e)}return wr}async function Xt(){return wr||await Dd(),wr}function Ni(e,t){try{if(e!=null&&e._server_messages){const r=JSON.parse(e._server_messages);if(r.length){const s=JSON.parse(r[0]);if(s!=null&&s.message)return s.message.replace(/<[^>]+>/g,"")}}}catch{}return(e==null?void 0:e.message)||(e==null?void 0:e.exception)||t}async function Ct(e,t,r=[]){if(zs.has(e)){const a=`${ce}/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 s=r.length?`?fields=${encodeURIComponent(JSON.stringify(r))}`:"",l=await fetch(`${ce}/api/v1/resource/${e}/${encodeURIComponent(t)}${s}`,{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 Wo(e,t,r="",s=!1){const l=await Xt();if(zs.has(e)){const c=new URLSearchParams({doctype:e,name:t});r&&c.append("reason",r),s&&c.append("permanent","1");const d=await fetch(`${ce}/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(Ni(p,`Error deleting ${t}`))}return}const i=new URLSearchParams({doctype:e,name:t});r&&i.append("reason",r),s&&i.append("permanent","1");const a=await fetch(`${ce}/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(Ni(c,`Error deleting ${t}`))}return await a.json()}async function jy(e,t){const r=await Xt();if(zs.has(e)){const i=new URLSearchParams({doctype:e,name:t}),a=await fetch(`${ce}/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":r},body:i.toString()});if(!a.ok){const d=await a.json().catch(()=>({}));throw new Error(Ni(d,`Error restoring ${t}`))}return(await a.json()).message||{success:!0}}const s=new URLSearchParams({doctype:e,name:t}),l=await fetch(`${ce}/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":r},body:s.toString()});if(!l.ok){const i=await l.json().catch(()=>({}));throw new Error(Ni(i,`Error restoring ${t}`))}return await l.json()}async function Ie(e){if(zs.has(e))try{const s=`${ce}/api/method/sidrah_business.api.get_sb_list?doctype=${encodeURIComponent(e)}&limit=500`,l=await fetch(s,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||[]:[]}catch{return[]}const t=encodeURIComponent('["*"]'),r=`${ce}/api/v1/resource/${e}?limit_page_length=500&fields=${t}`;try{const s=await fetch(r,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return s.status===401||s.status===403?[]:s.ok?(await s.json()).data||[]:[]}catch(s){return console.error("Get error:",s),[]}}async function $a(e,t){const r=await Xt();if(zs.has(e)){const l=new URLSearchParams({doctype:e,data_json:JSON.stringify(t)}),i=await fetch(`${ce}/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":r},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 s=`${ce}/api/v1/resource/${e}`;try{const l=await fetch(s,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":r},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 Bi(e,t,r){const s=await Xt();if(zs.has(e)){const i=new URLSearchParams({doctype:e,name:t,data_json:JSON.stringify(r)}),a=await fetch(`${ce}/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":s},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=`${ce}/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":s},body:JSON.stringify(r)});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 by(){const e=`${ce}/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 Sy(e,t){const r=new FormData;r.append("usr",e),r.append("pwd",t);const l=await(await fetch(`${ce}/api/method/login`,{method:"POST",credentials:"include",body:r})).json();return l.csrf_token?wr=l.csrf_token:await Dd(),l}async function wy(){const e=await Xt();try{await fetch(`${ce}/api/method/logout`,{method:"POST",credentials:"include",headers:{"X-Frappe-CSRF-Token":e,Accept:"application/json"}})}catch{}wr=""}function ky(){return wr}async function Jf(){try{const e=await fetch(`${ce}/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 _y(){const e=JSON.stringify([["name","not in",["Administrator","Guest"]]]),t=`${ce}/api/v1/resource/User?limit_page_length=500&fields=${encodeURIComponent('["*"]')}&filters=${encodeURIComponent(e)}`;try{const r=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return r.ok?(await r.json()).data||[]:[]}catch{return[]}}async function Cy(){const e=`${ce}/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 Vf(e,t){await Bi("User",e,{new_password:t})}async function zy(e=20){try{const t=`${ce}/api/method/sidrah_business.api.get_notifications?limit=${e}`,r=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return r.ok?(await r.json()).message||[]:[]}catch{return[]}}async function Ty(){const e=await Xt();try{await fetch(`${ce}/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 Iy(e){const t=await Xt();try{await fetch(`${ce}/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 Ey(e){const t=await Xt(),r=new URLSearchParams({name:e});await fetch(`${ce}/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:r.toString()})}async function Py(e,t){try{const r=`${ce}/api/method/sidrah_business.api.get_doc_comments?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(t)}`,s=await fetch(r,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function Ay(e,t,r){const s=await Xt(),l=new URLSearchParams({doctype:e,docname:t,content:r}),i=await fetch(`${ce}/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":s},body:l.toString()});if(!i.ok)throw new Error("Failed to post comment");return(await i.json()).message}async function Ry(e,t){try{const r=`${ce}/api/method/sidrah_business.api.get_doc_versions?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(t)}`,s=await fetch(r,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function Zf(e){try{const t=`${ce}/api/method/sidrah_business.api.get_user_roles?user=${encodeURIComponent(e)}`,r=await fetch(t,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return r.ok?(await r.json()).message||[]:[]}catch{return[]}}async function Dy(){try{const e=`${ce}/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 Cr(e,t={}){const r=await Xt(),s=new URLSearchParams(t),l=await fetch(`${ce}/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":r},body:s.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 Ly(e,t,r="",s,l,i){const a={name:e,action:t,comment:r};return s!==void 0&&(a.stage=s),i!==void 0&&(a.cycle_status=i),Cr("apply_order_workflow",a)}async function Oy(e,t,r=""){return Cr("apply_incident_workflow",{name:e,action:t,fields_json:r})}async function Wy(e,t,r=""){return Cr("apply_idea_workflow",{name:e,action:t,fields_json:r})}async function Ny(e=""){const t=`${ce}/api/method/sidrah_business.api.get_dashboard_data${e?`?organization=${encodeURIComponent(e)}`:""}`,r=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return r.ok?(await r.json()).message||{}:{escalated_processes:[],escalated_orders:[],untriaged_incidents:[],kpi_inputs:[]}}async function By(e,t={}){return Cr("get_report_data",{report_name:e,filters_json:JSON.stringify(t)})}async function $y(){try{const e=`${ce}/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 Uy(e,t,r="",s=""){return Cr("create_delegation",{manager:e,functions_json:JSON.stringify(t),organization:r,remarks:s})}async function Fy(e,t,r=""){return Cr("respond_to_delegation",{name:e,response:t,remarks:r})}async function My(e,t=""){return Cr("revoke_delegation",{name:e,remarks:t})}async function Hy(){try{const e=`${ce}/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 Gy(e){const t=`${ce}/api/method/sidrah_business.api.get_delegation?name=${encodeURIComponent(e)}`,r=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});if(!r.ok)throw new Error("Failed to load delegation");return(await r.json()).message}async function Ky(){try{const e=`${ce}/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 Qy(){try{const e=`${ce}/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 Yy(){try{const e=await Xt(),t=await fetch(`${ce}/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 Xy(){const e=ky();return e||Dd()}async function Ys(e){const t=await fetch(`${ce}/api/method/sidrah_business.api.get_process?name=${encodeURIComponent(e)}`,{credentials:"include",headers:{Accept:"application/json"}});if(!t.ok){const s=await t.json().catch(()=>({}));throw new Error(s.message||`Failed to load process (${t.status})`)}const r=await t.json();return r.message||r.data}async function qy(e,t,r={}){const s=await Xy(),l=new URLSearchParams({name:e,action:t});r.actor_status&&l.set("actor_status",String(r.actor_status)),r.actor_comment&&l.set("actor_comment",String(r.actor_comment)),r.progress_indicators&&l.set("progress_indicators",JSON.stringify(r.progress_indicators));const i=await fetch(`${ce}/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":s},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 Jy=["dashboard","incidents","incidents-form","ideas","ideas-form","orders","orders-form","processes","processes-form","processes-workflow","organizations","organizations-form","managements","managements-form","departments","departments-form","branches","branches-form","incident-types","incident-types-form","idea-types","idea-types-form","order-types","order-types-form","process-types","process-types-form","incident-statuses","incident-statuses-form","idea-statuses","idea-statuses-form","order-statuses","order-statuses-form","process-statuses","process-statuses-form","users","users-form","cycles","cycles-form","kpi-input","kpi-input-form","delegations","delegations-form","inbox","reports","profile"],gu=new Set(Jy),Vy={"incidents-form":"incidents","ideas-form":"ideas","orders-form":"orders","processes-form":"processes","processes-workflow":"processes","organizations-form":"organizations","managements-form":"managements","departments-form":"departments","branches-form":"branches","incident-types-form":"incident-types","idea-types-form":"idea-types","order-types-form":"order-types","process-types-form":"process-types","incident-statuses-form":"incident-statuses","idea-statuses-form":"idea-statuses","order-statuses-form":"order-statuses","process-statuses-form":"process-statuses","users-form":"users","cycles-form":"cycles","kpi-input-form":"kpi-input","delegations-form":"delegations",profile:"dashboard"};function xu(){const e=window.location.hash.replace(/^#\/?/,"");if(e)return gu.has(e)?e:null;const t=window.location.pathname.split("/").filter(Boolean).pop()||"";return gu.has(t)?t:null}function Zy(e){return e?Vy[e]??e:null}function e0(e){return`#/${e}`}function t0({onLogin:e}){const t=re(),[r,s]=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(!r||!l){c(t.login.emptyFields);return}p(!0),c("");try{const S=await Sy(r,l);if(S.message==="Logged In"){const x=await Jf()||r,o=await Zf(x),y=o.some(k=>["SB Admin","System Manager"].includes(k))?"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||r,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:Xf,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:r,onChange:S=>s(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:Yf,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 n0(e,t){const r=parseInt(e.replace("#",""),16),s=r>>16&255,l=r>>8&255,i=r&255,a=c=>Math.round(c+(255-c)*t);return`rgb(${a(s)}, ${a(l)}, ${a(i)})`}function $s(e,t){const r=parseInt(e.replace("#",""),16),s=r>>16&255,l=r>>8&255,i=r&255;return`rgba(${s}, ${l}, ${i}, ${t})`}function Jl({title:e,data:t,color:r,onSelect:s}){const[,l]=t[0]??["Total",0,""],i=t.slice(1),a=i.map((d,p)=>n0(r,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, ${$s(r,.09)} 0%, transparent 55%)`}}),n.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:3,background:`linear-gradient(90deg, ${r}, ${$s(r,.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:r,lineHeight:1,minWidth:26,textAlign:"center",padding:"6px 9px",borderRadius:10,boxShadow:`0 4px 10px ${$s(r,.35)}`},children:l})]}),l>0&&n.jsx("div",{style:{display:"flex",height:9,borderRadius:999,overflow:"hidden",background:$s(r,.1),marginBottom:13},children:c.map(([d,p,v,f],u)=>n.jsx("div",{title:`${d}: ${p}`,onClick:m=>{m.stopPropagation(),s==null||s(v)},style:{flex:`${p} 0 0`,background:f,borderRight:u<c.length-1?"2px solid white":"none",cursor:s?"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(),s==null||s(v)}:void 0,style:{display:"flex",alignItems:"center",gap:9,padding:"4px 6px",borderRadius:8,cursor:p>0&&s?"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 ${$s(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 Bt({value:e,onChange:t,organizations:r,placeholder:s="-- 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=r.find(u=>u.organization_name===e||u.name===e))==null?void 0:f.organization_name)??e:s,v=r.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(mu,{label:s,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(mu,{label:u.organization_name,selected:e===u.organization_name||e===u.name,active:!!u.is_active,isPlaceholder:!1,small:i,onClick:()=>{t(u.organization_name),c(!1)}},u.name))]})})]})}function mu({label:e,selected:t,active:r,isPlaceholder:s,small:l,onClick:i}){const[a,c]=w.useState(!1),d=t?"#2563eb":a?"#f0f4ff":"transparent",p=t?"white":s?"#aaa":r?"#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 Wn({items:e,type:t,onNavigate:r}){const s=re();if(!e.length)return null;const l=t==="process"?"processes-form":"orders-form",i=t==="process"?s.dash.escalatedProcesses:s.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:()=>r(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:[s.dash.level," ",a.escalation_level]})]},a.name))})]})}function r0({kpi:e}){const t=re();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:r,val:s})=>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:r}),n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginTop:1},children:s})]},r))})]})}function s0({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(r=>r.pass+r.fail+r.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(r=>{const s=r.pass+r.fail+r.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: ${r.pass}`,style:{height:Math.round(r.pass/t*l),background:"#27ae60",borderRadius:"2px 2px 0 0",minHeight:r.pass?2:0}}),n.jsx("div",{title:`Fail: ${r.fail}`,style:{height:Math.round(r.fail/t*l),background:"#e74c3c",borderRadius:"2px 2px 0 0",minHeight:r.fail?2:0}}),n.jsx("div",{title:`Unknown: ${r.unknown}`,style:{height:Math.round(r.unknown/t*l),background:"#95a5a6",borderRadius:"2px 2px 0 0",minHeight:r.unknown?2:0}})]}),n.jsx("div",{style:{fontSize:9,color:"#999",textAlign:"center",lineHeight:1.2},children:r.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:s>1?Math.round(r.pass/s*100)+"%":"—"})]},r.month)})}),n.jsx("div",{style:{display:"flex",gap:16,marginTop:8},children:[["#27ae60","Pass"],["#e74c3c","Fail"],["#95a5a6","Unknown"]].map(([r,s])=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,fontSize:11},children:[n.jsx("div",{style:{width:10,height:10,background:r,borderRadius:2}}),n.jsx("span",{style:{color:"#666"},children:s})]},s))})]})}function Gt({label:e,icon:t,onClick:r}){return n.jsxs("button",{onClick:r,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:s=>s.currentTarget.style.boxShadow="0 3px 10px rgba(0,0,0,0.12)",onMouseLeave:s=>s.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 l0({dashData:e,fi:t,fid:r,fo:s,fp:l,incidentStatuses:i,ideaStatuses:a,orderStatuses:c,processStatuses:d,onNavigate:p,onNavigateStatus:v}){const f=re(),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(_=>[_.name1||_.name,t.filter(R=>R.status===_.name).length,_.name])],k=[["Total",r.length,""],...a.map(_=>[_.name1||_.name,r.filter(R=>R.status===_.name).length,_.name])],C=[["Total",s.length,""],...c.map(_=>[_.name1||_.name,s.filter(R=>R.status===_.name).length,_.name])],P=[["Total",l.length,""],...d.map(_=>[_.name1||_.name,l.filter(R=>R.status===_.name).length,_.name])];return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",marginBottom:4},children:[n.jsx(Gt,{label:"Incidents",icon:"⚠️",onClick:()=>p("incidents")}),n.jsx(Gt,{label:"Ideas",icon:"💡",onClick:()=>p("ideas")}),n.jsx(Gt,{label:"Orders",icon:"📦",onClick:()=>p("orders")}),n.jsx(Gt,{label:"Processes",icon:"⚙️",onClick:()=>p("processes")}),n.jsx(Gt,{label:"Inbox",icon:"📥",onClick:()=>p("inbox")}),n.jsx(Gt,{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(Jl,{title:f.dash.incidents,color:U.orange,data:y,onSelect:_=>v("incidents",_)})}),n.jsx("div",{onClick:()=>p("ideas"),style:{cursor:"pointer"},children:n.jsx(Jl,{title:f.dash.ideas,color:U.blue,data:k,onSelect:_=>v("ideas",_)})}),n.jsx("div",{onClick:()=>p("orders"),style:{cursor:"pointer"},children:n.jsx(Jl,{title:f.dash.orders,color:U.purple,data:C,onSelect:_=>v("orders",_)})}),n.jsx("div",{onClick:()=>p("processes"),style:{cursor:"pointer"},children:n.jsx(Jl,{title:f.dash.processes,color:U.red,data:P,onSelect:_=>v("processes",_)})})]}),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(Wn,{items:u,type:"process",onNavigate:p}),n.jsx(Wn,{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(Wn,{items:j,type:"process",onNavigate:p}),n.jsx(Wn,{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(_=>n.jsxs("div",{onClick:()=>p("incidents-form",_.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:_.number||_.name}),n.jsx("span",{style:{fontSize:12,color:"#666"},children:_.title}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:_.date})]},_.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:U.orange,marginBottom:8},children:[f.dash.untriaged," (",S.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:S.map(_=>n.jsxs("div",{onClick:()=>p("incidents-form",_.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:_.number||_.name}),n.jsx("span",{style:{fontSize:12,color:"#666"},children:_.title}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:_.date})]},_.name))})]})]})}function i0({dashData:e,selectedOrg:t,onNavigate:r}){const s=re(),[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 k of o)y[k.month]||(y[k.month]={pass:0,fail:0,unknown:0}),k.status==="Pass"?y[k.month].pass=k.count:k.status==="Fail"?y[k.month].fail=k.count:k.status==="Unknown"&&(y[k.month].unknown=k.count);i(Object.entries(y).map(([k,C])=>({month:k,...C})))}).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(Gt,{label:"Manage Users & Roles",icon:"👥",onClick:()=>r("users")}),n.jsx(Gt,{label:"Change Active Cycle",icon:"🔄",onClick:()=>r("cycles")}),n.jsx(Gt,{label:"KPI Inputs",icon:"📈",onClick:()=>r("kpi-input")}),n.jsx(Gt,{label:"Reports",icon:"📊",onClick:()=>r("reports")}),n.jsx(Gt,{label:"Organizations",icon:"🏢",onClick:()=>r("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:s.dash.recentKpi}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12},children:j.map(g=>n.jsx(r0,{kpi:g},g.name))}),n.jsx("button",{onClick:()=>r("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:s.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(Wn,{items:v,type:"process",onNavigate:r}),n.jsx(Wn,{items:f,type:"order",onNavigate:r})]})]}),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(Wn,{items:u,type:"process",onNavigate:r}),n.jsx(Wn,{items:m,type:"order",onNavigate:r})]})]}),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(s0,{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:()=>r("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 a0({incidents:e,ideas:t,orders:r,processes:s,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(()=>{Ny(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?r.filter(R=>R.organization===p):r,o=p?s.filter(R=>R.organization===p):s,y=m==="Admin",k=m==="Owner",[C,P]=w.useState("level1"),_=k||y&&C==="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(Bt,{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:()=>P(R),style:{padding:"4px 10px",borderRadius:5,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:C===R?R==="level2"?U.purple:U.blue:"transparent",color:C===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:_?U.purple:U.blue,padding:"3px 10px",borderRadius:20,flexShrink:0},children:_?"Level 2 — Owner":"Level 1 — Operational"})]}),_?n.jsx(i0,{dashData:j,selectedOrg:p,onNavigate:f}):n.jsx(l0,{dashData:j,fi:S,fid:g,fo:x,fp:o,incidentStatuses:i,ideaStatuses:a,orderStatuses:c,processStatuses:d,onNavigate:f,onNavigateStatus:u})]})}const Qe={fontSize:11,color:"#475569",fontWeight:600,marginBottom:4,display:"block",textTransform:"uppercase",letterSpacing:.4},Ye={width:"100%",padding:"6px 10px",border:"1px solid #cbd5e1",borderRadius:6,fontSize:12,background:"white",color:"#1e293b",boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif",height:32,outline:"none"};function sa({children:e}){const[t,r]=w.useState(!1);return n.jsxs("div",{style:{borderRadius:10,overflow:"hidden",boxShadow:"0 1px 3px rgba(0,0,0,0.06)",flexShrink:0,border:"1px solid #e2e8f0",marginBottom:14},children:[n.jsxs("div",{onClick:()=>r(s=>!s),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",color:"white",padding:"10px 18px",cursor:"pointer",display:"flex",alignItems:"center",gap:10,userSelect:"none",fontWeight:600,fontSize:13},children:[n.jsx("span",{style:{fontSize:12,opacity:.9},children:t?"▲":"▼"}),n.jsx("svg",{width:"14",height:"14",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",{children:"Filters"})]}),t&&n.jsx("div",{style:{background:"#f8fafc",padding:"14px 18px",borderTop:"1px solid #e2e8f0"},children:e})]})}const ae=20,yu=e=>({padding:"6px 16px",borderRadius:6,border:"1px solid #d1d5db",fontSize:12,fontWeight:600,background:e?"#f3f4f6":"white",color:e?"#c1c5cc":"#374151",cursor:e?"not-allowed":"pointer",fontFamily:"inherit"});function Me({page:e,pageSize:t=ae,total:r,onPageChange:s}){if(r===0)return null;const l=Math.max(1,Math.ceil(r/t)),i=(e-1)*t+1,a=Math.min(e*t,r);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 ",r," results"]}),n.jsxs("div",{style:{display:"flex",gap:8},children:[n.jsx("button",{disabled:e<=1,onClick:()=>s(e-1),style:yu(e<=1),children:"Previous"}),n.jsx("button",{disabled:e>=l,onClick:()=>s(e+1),style:yu(e>=l),children:"Next"})]})]})}function o0({incidents:e,organizations:t,departments:r,branches:s,incidentStatuses:l,initialOrg:i,initialStatus:a,canModify:c,onView:d,onEdit:p,onDelete:v}){const f=re(),[u,m]=w.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),j=(o,y)=>m(k=>({...k,[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)*ae,h*ae);return n.jsxs(n.Fragment,{children:[n.jsx(sa,{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:Qe,children:f.filter.numberTitle}),n.jsx("input",{style:Ye,value:u.search,onChange:o=>j("search",o.target.value),placeholder:f.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Qe,children:f.filter.organization}),n.jsxs("select",{style:Ye,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:Qe,children:f.filter.department}),n.jsxs("select",{style:Ye,value:u.department,onChange:o=>j("department",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allDepts}),r.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Qe,children:f.filter.branch}),n.jsxs("select",{style:Ye,value:u.branch,onChange:o=>j("branch",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allBranches}),s.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Qe,children:f.filter.status}),n.jsxs("select",{style:Ye,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?Rd(o.type):"—"}),n.jsx("td",{style:{padding:"12px 16px"},children:o.custom_is_deleted?Yn(f.deletedBadge):o.status?Yn(o.status):"—"}),n.jsx("td",{style:{padding:"10px 16px"},onClick:k=>k.stopPropagation(),children:n.jsx(tt,{onView:()=>d==null?void 0:d(o),onEdit:c&&p&&!o.custom_is_deleted&&!On("incident",o.workflow_state)?()=>p(o):void 0,onDelete:c&&v&&!o.custom_is_deleted?()=>v(o.name):void 0})})]},o.name))})]})}),n.jsx(Me,{page:h,total:g.length,onPageChange:S})]})}function d0(e){if(!e)return"";const[t,r,s]=e.split("-");return!t||!r||!s?"":`${s}/${r}/${t}`}function je({value:e,onChange:t,disabled:r,style:s,min:l,max:i}){return n.jsxs("div",{style:{position:"relative",width:"100%"},children:[n.jsx("input",{type:"text",readOnly:!0,tabIndex:-1,value:d0(e),placeholder:"DD/MM/YYYY",style:{...s,pointerEvents:"none",paddingRight:30}}),n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:r?"#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:r,min:l,max:i,onChange:a=>t(a.target.value),style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0,cursor:r?"default":"pointer",border:"none",padding:0,margin:0}})]})}const vu={"SB Process":"processes-form","SB Order":"orders-form","SB Incident":"incidents-form","SB Idea":"ideas-form","SB Delegation":"delegations"};function c0(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 eh({notifCount:e,darkMode:t,onCountChange:r,onToggleDark:s,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 N=V=>{h.current&&!h.current.contains(V.target)&&v(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const S=async()=>{j(!0);const N=await zy(30);u(N),j(!1)},g=()=>{const N=!p;v(N),N&&S()},x=async()=>{await Ty(),u(N=>N.map(V=>({...V,read:1}))),r(0)},o=N=>{N.read||(Iy(N.name),u(de=>de.map(D=>D.name===N.name?{...D,read:1}:D)),r(Math.max(0,e-1)));const V=N.document_type?vu[N.document_type]:void 0;V&&a&&(a(V,N.document_type==="SB Delegation"?void 0:N.document_name),v(!1))},y=f.filter(N=>!N.read).length,k=N=>({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,...N}),C=t,P=C?"#1a202c":"white",_=C?"#2d3748":"#e5e7eb",R=C?"#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:C?"#e2e8f0":"#1e293b",whiteSpace:"nowrap"},children:c}),d&&n.jsx("span",{style:{fontSize:11,color:C?"#94a3b8":"#6b7280",whiteSpace:"nowrap"},children:d})]}),n.jsx("button",{style:k({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:k(),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:P,borderRadius:12,boxShadow:"0 8px 32px rgba(0,0,0,0.2)",zIndex:1e4,border:`1px solid ${_}`,overflow:"hidden"},children:[n.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${_}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:P},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(N=>{const V=!!(N.document_type&&vu[N.document_type]&&a);return n.jsxs("div",{onClick:()=>o(N),style:{padding:"11px 16px",borderBottom:`1px solid ${C?"#2d3748":"#f5f5f5"}`,display:"flex",gap:10,background:N.read?P:C?"#1e3a5f":"#eff6ff",cursor:V?"pointer":"default",transition:"background 0.12s"},onMouseEnter:de=>{V&&(de.currentTarget.style.background=C?"#243244":"#e0ecfd")},onMouseLeave:de=>{de.currentTarget.style.background=N.read?P:C?"#1e3a5f":"#eff6ff"},children:[n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:13,fontWeight:N.read?400:600,color:R,marginBottom:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N.subject||`${N.document_type}: ${N.document_name}`}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:N.document_type&&n.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#3b82f6",background:C?"rgba(59,130,246,0.15)":"#eff6ff",padding:"1px 7px",borderRadius:8},children:[N.document_type.replace("SB ",""),N.document_name?` · ${N.document_name}`:""]})}),n.jsx("div",{style:{fontSize:11,color:"#aaa",marginTop:3},children:c0(N.creation)})]}),!N.read&&n.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:"#3498db",flexShrink:0,marginTop:5}})]},N.name)})]})]})]}),n.jsx("button",{style:k(),onClick:Yf,title:os()?"Switch to English":"Switch to Arabic",children:n.jsx("span",{style:{fontSize:13,fontWeight:700,fontFamily:"serif"},children:"عA"})}),n.jsx("button",{style:k(),onClick:s,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:k({background:C?"#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 He({title:e,activePage:t,user:r,formStatus:s,buttonText:l,viewMode:i,statusBadge:a,onEdit:c,onCancel:d,hideSettings:p,rightPanel:v,darkMode:f,notifCount:u,onToggleDark:m,onCountChange:j,onViewProfile:h,onSubmit:S,onBack:g,onNavigate:x,onLogout:o,children:y}){const k=re(),C=r.role,P=C==="Admin"||C==="Owner"||C==="Auditor"||C==="Manager",_=C==="Admin"||C==="Owner"||C==="Auditor"||C==="Manager",R=C==="Admin"||C==="Auditor"||C==="Manager",[N,V]=w.useState(()=>localStorage.getItem("sb_sidebar")==="1"),de=()=>V(z=>{const I=!z;return localStorage.setItem("sb_sidebar",I?"1":"0"),I}),D=d||g;return n.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:"#f8fafc"},children:[n.jsx(qf,{collapsed:N,onToggleCollapsed:de,activePage:t,onNavigate:x,hasDashboard:P,hasReports:_,hasDelegations:R,role:C,hideSettings:p,rtl:k.rtl,navLabels:k.nav,settingsLabel:k.nav.settings}),n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[n.jsxs("div",{style:{background:"white",padding:"10px 24px",borderBottom:"1px solid #e2e8f0",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,boxShadow:"0 1px 3px rgba(0,0,0,0.03)",position:"relative"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[n.jsx("button",{onClick:g,title:k.back,style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:"1px solid #e2e8f0",background:"#ffffff",cursor:"pointer",color:"#2563eb",flexShrink:0,transition:"all 0.15s ease"},onMouseEnter:z=>{z.currentTarget.style.background="#eff6ff",z.currentTarget.style.borderColor="#bfdbfe"},onMouseLeave:z=>{z.currentTarget.style.background="#ffffff",z.currentTarget.style.borderColor="#e2e8f0"},children:n.jsx("svg",{width:"15",height:"15",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",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[n.jsx("div",{style:{fontSize:16,fontWeight:700,color:"#0f172a"},children:e}),a&&(typeof a=="string"?n.jsx("span",{style:{padding:"3px 10px",borderRadius:16,fontSize:12,fontWeight:600,background:"#fef3c7",color:"#92400e",border:"1px solid #fde68a"},children:a}):a)]})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[i&&c&&n.jsxs("button",{onClick:c,style:{display:"flex",alignItems:"center",gap:6,padding:"7px 16px",borderRadius:6,border:"none",background:"#2563eb",color:"white",cursor:"pointer",fontSize:13,fontWeight:600,boxShadow:"0 1px 3px rgba(37,99,235,0.25)",transition:"all 0.15s ease"},onMouseEnter:z=>z.currentTarget.style.background="#1d4ed8",onMouseLeave:z=>z.currentTarget.style.background="#2563eb",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"})]}),k.edit]}),!i&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("button",{type:"button",onClick:D,style:{padding:"7px 16px",borderRadius:6,border:"1px solid #cbd5e1",background:"#ffffff",color:"#475569",fontSize:13,fontWeight:600,cursor:"pointer",transition:"all 0.15s ease"},onMouseEnter:z=>{z.currentTarget.style.background="#f1f5f9"},onMouseLeave:z=>{z.currentTarget.style.background="#ffffff"},children:k.cancel}),n.jsxs("button",{type:"button",onClick:S,disabled:s==="loading",style:{display:"flex",alignItems:"center",gap:6,padding:"7px 18px",borderRadius:6,border:"none",background:"#16a34a",color:"#ffffff",fontSize:13,fontWeight:600,cursor:s==="loading"?"not-allowed":"pointer",boxShadow:"0 1px 3px rgba(22, 163, 74, 0.3)",opacity:s==="loading"?.7:1,transition:"all 0.15s ease"},onMouseEnter:z=>{s!=="loading"&&(z.currentTarget.style.background="#15803d")},onMouseLeave:z=>{s!=="loading"&&(z.currentTarget.style.background="#16a34a")},children:[n.jsx("span",{children:"💾"}),n.jsx("span",{children:s==="loading"?k.saving:l||"Save Changes"})]})]}),n.jsx(eh,{notifCount:u,darkMode:f,onCountChange:j,onToggleDark:m,onNavigate:x,onViewProfile:h,onLogout:o,userName:r.full_name||r.name,userRole:r.role})]})]}),!i&&n.jsxs("div",{style:{background:"linear-gradient(90deg, #0284c7 0%, #0369a1 100%)",color:"white",padding:"5px 24px",fontSize:12,fontWeight:600,display:"flex",alignItems:"center",gap:6,boxShadow:"0 1px 2px rgba(0,0,0,0.05)"},children:[n.jsx("span",{children:"📝"}),n.jsx("span",{children:"Edit mode enabled / وضع التعديل مفعّل"})]}),n.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"grid",gridTemplateColumns:v?"1fr 240px":"1fr",gap:16,alignItems:"start"},children:[n.jsxs("div",{style:{minWidth:0},children:[y,s==="success"&&n.jsx("div",{style:{padding:"10px 14px",borderRadius:8,background:"#f0fdf4",border:"1px solid #86efac",color:"#166534",fontSize:13,marginTop:14},children:k.savedOk}),s!=="idle"&&s!=="loading"&&s!=="success"&&n.jsx("div",{style:{padding:"10px 14px",borderRadius:8,background:"#fef2f2",border:"1px solid #fca5a5",color:"#991b1b",fontSize:13,marginTop:14},children:s})]}),v&&n.jsx("div",{style:{position:"sticky",top:0,alignSelf:"start",width:240},children:v})]})]})]})}function ge({value:e,onChange:t,items:r,placeholder:s="-- 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=r.find(u=>u.name===e))==null?void 0:f.label)??e:s;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:s}),r.length===0&&n.jsx("div",{style:{padding:"10px 14px",color:"#aaa",fontSize:12},children:"No records found"}),r.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 u0(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 p0(e){return e.replace(/@.*/,"").replace(/[._-]/g," ").split(" ").filter(Boolean).slice(0,2).map(r=>r[0].toUpperCase()).join("")}function la({doctype:e,docname:t,currentUserName:r}){const s=re(),[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 _=await Py(e,t);i(_),c(!1)},[e,t]);w.useEffect(()=>{o()},[o]);const y=async()=>{const _=d.trim();if(!(!_||v)){f(!0),g("");try{await Ay(e,t,_),p(""),await o()}catch{g("Failed to post comment. Please try again.")}f(!1)}},k=async _=>{if(window.confirm("Delete this comment?"))try{await Wo("Comment",_),i(R=>R.filter(N=>N.name!==_))}catch{alert("Failed to delete comment.")}},C=j?l:l.slice(-x),P=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(_=>!_),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:["💬 ",s.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:_=>{_.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&&P>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 ",P," older comment",P!==1?"s":""]}),a&&n.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:s.loading}),!a&&l.length===0&&n.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:s.comments.noComments}),!a&&C.length>0&&n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:16},children:C.map(_=>{const R=_.comment_by||_.comment_email||_.owner||"Unknown",N=_.owner===r||_.comment_by===r;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:p0(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:u0(_.creation)})]}),N&&n.jsx("button",{onClick:()=>k(_.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:_.content||""}})]})]},_.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:_=>p(_.target.value),onKeyDown:_=>{_.key==="Enter"&&(_.ctrlKey||_.metaKey)&&y()},placeholder:s.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?s.saving:s.comments.post})})]})]})]})}function ju(e){if(!e)return"";const t=(Date.now()-new Date(e).getTime())/1e3;return t<60?`${Math.floor(t)}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:t<86400*7?`${Math.floor(t/86400)}d ago`:new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function f0(e){return(e||"").replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function bu(e){return e==null||e===""?"(empty)":typeof e=="object"?JSON.stringify(e):String(e)}function No(e){return(e||"Unknown").replace(/@.*/,"").replace(/[._]/g," ")}function Su(e){return No(e).split(" ").filter(Boolean).slice(0,2).map(t=>t[0].toUpperCase()).join("")}function h0(e){let t={};try{t=JSON.parse(e.data||"{}")}catch{}const r=(t.changed||[]).map(s=>({field:s[0]||"",oldVal:bu(s[1]),newVal:bu(s[2])}));return{name:e.name,owner:e.owner,creation:e.creation,changes:r,added:(t.added||[]).length,removed:(t.removed||[]).length,rowChanged:(t.row_changed||[]).length}}function ia({doctype:e,docname:t,docCreation:r,docOwner:s}){const l=re(),[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 Ry(e,t);a(x.map(h0)),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:Su(x.owner)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:No(x.owner)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:ju(x.creation)})]}),x.changes.length>0?n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:x.changes.map((y,k)=>n.jsxs("div",{style:{fontSize:12,lineHeight:1.5},children:[n.jsx("span",{style:{fontWeight:600,color:"#6d28d9"},children:f0(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})]},k))}):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)),r&&s&&n.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[n.jsx("div",{style:g("#22c55e")}),n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:"10px 14px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[n.jsx("div",{style:{width:26,height:26,borderRadius:"50%",background:"#22c55e",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flexShrink:0},children:Su(s)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:No(s)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:ju(r)})]}),n.jsxs("div",{style:{fontSize:12,color:"#15803d",fontWeight:600},children:["✓ ",l.activity.created]})]})]}),i.length===0&&!r&&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 g0={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 x0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...g0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function m0({incForm:e,setIncForm:t,organizations:r,managements:s,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:k,onViewProfile:C,userRole:P,onSubmit:_,onBack:R,onNavigate:N,onLogout:V,user:de,onRefresh:D}){var qe;const z=re(),I=$=>t({...e,...$}),Q=m?{background:"#f9f9f9"}:{},G=Ss(v,f,"SB Manager",e.organization),[A,H]=w.useState(""),[Y,ee]=w.useState(!1),Z=e.name?m?`${z.formTitle.viewIncident}${e.number||e.name}`:z.formTitle.editIncident:z.formTitle.newIncident,Ce=xe(s,e.management).map($=>({name:$.name,label:$.name1||$.name})),Be=xe(l,e.department).map($=>({name:$.name,label:$.department_name||$.name})),Le=xe(i,e.branch).map($=>({name:$.name,label:$.branch||$.name})),he=xe(a,e.type).map($=>({name:$.name,label:$.name1||$.name})),Xe=xe(c,e.incident_class).map($=>({name:$.name,label:$.name1||$.name})),K=xe(d,e.incident_field).map($=>({name:$.name,label:$.name1||$.name})),ne=e.workflow_state||"New",ht=P==="Employee",se=P==="Auditor"||P==="Admin",st=P==="Manager",vt=e.name?ne==="New"?[{label:z.wf.submit,action:"Submit",color:"#2563eb"}]:ne==="Initial Evaluation"&&se?[{label:z.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:z.wf.reject,action:"Reject",color:"#dc2626"}]:ne==="Accept & Under Progress"&&(st||se)?[{label:z.wf.submitSolution,action:"Submit Solution",color:"#059669"}]:ne==="working on resolution"&&(st||se)?[{label:z.wf.resolutionComplete,action:"Resolution complete",color:"#166534"}]:[]:[];async function Ge($){if(e.name){ee(!0),H("");try{const me={};$==="Assign to Manager"&&(e.assigned_to&&(me.assigned_to=e.assigned_to),e.priority&&(me.priority=e.priority),e.economy_class&&(me.economy_class=e.economy_class),e.entity_scope&&(me.entity_scope=e.entity_scope),e.hses_field&&(me.hses_field=e.hses_field),me.product_relation=String(e.product_relation??0),me.repeated=String(e.repeated??0)),$==="Submit Solution"&&(e.solution&&(me.solution=e.solution),e.summary&&(me.summary=e.summary),e.cost&&(me.cost=String(e.cost))),($==="Resolution complete"||$==="Submit Solution")&&e.auditor_comment&&(me.auditor_comment=e.auditor_comment),await Oy(e.name,$,JSON.stringify(me)),H("Done"),D==null||D()}catch(me){H(me.message||"Error")}finally{ee(!1)}}}const B=((qe=G.find($=>$.name===e.assigned_to))==null?void 0:qe.full_name)||e.assigned_to,ze=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.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:z.wf.workflow}),n.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px",marginBottom:12},children:[n.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:4},children:"Current State"}),n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b"},children:ne})]}),ne==="Initial Evaluation"&&se&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("label",{style:T,children:z.wf.assignToManager}),n.jsxs("select",{style:E,value:e.assigned_to||"",onChange:$=>I({assigned_to:$.target.value}),children:[n.jsx("option",{value:"",children:z.field.selectMgr}),G.map($=>n.jsx("option",{value:$.name,children:$.full_name||$.name},$.name))]})]}),(ne==="Accept & Under Progress"||ne==="working on resolution")&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("label",{style:T,children:z.field.solution}),n.jsx("textarea",{style:{...E,height:75,resize:"vertical"},value:e.solution||"",onChange:$=>I({solution:$.target.value}),placeholder:z.field.solutionPlaceholder}),n.jsx("label",{style:{...T,marginTop:6},children:z.field.actualCost}),n.jsx("input",{type:"number",style:E,value:e.cost||"",onChange:$=>I({cost:parseFloat($.target.value)||0}),placeholder:"0.00"})]}),ne==="working on resolution"&&se&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("label",{style:T,children:z.field.auditorComment}),n.jsx("textarea",{style:{...E,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:$=>I({auditor_comment:$.target.value}),placeholder:z.field.commentPlaceholder})]}),vt.length>0?n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:vt.map($=>n.jsx("button",{onClick:()=>Ge($.action),disabled:Y,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:$.color,color:"white",fontWeight:600,fontSize:12,cursor:Y?"not-allowed":"pointer",opacity:Y?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:n.jsx("span",{children:Y?z.wf.applying:$.label})},$.action))}):n.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:z.wf.noActions}),A&&n.jsx("p",{style:{marginTop:8,fontSize:12,color:A==="Done"?U.green:U.red},children:A})]}),n.jsx(ra,{priority:e.priority,status:ne,assignedTo:B,createdDate:e.date,modifiedDate:e.modified}),n.jsx(la,{doctype:O.incidents,docname:e.name,currentUserName:de.name}),n.jsx(ia,{doctype:O.incidents,docname:e.name,docCreation:e.creation,docOwner:e.owner}),j&&S&&!e.custom_is_deleted&&n.jsx(na,{title:"Delete Request",btnText:z.delete,onDelete:()=>S(e.name)})]}):null;return n.jsxs(He,{title:Z,activePage:"incidents",user:de,formStatus:u,statusBadge:n.jsx("span",{style:x0(ne),children:ne}),buttonText:z.saveIncident,buttonColor:"#16a34a",viewMode:m,onEdit:h,darkMode:x,notifCount:o,onToggleDark:y,onCountChange:k,onViewProfile:C,rightPanel:ze,onSubmit:_,onBack:R,onNavigate:N,onLogout:V,children:[e.custom_is_deleted===1&&n.jsx(zl,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:g?()=>g(e.name):void 0}),n.jsx(ie,{title:"Incident Information",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.number}),n.jsx("input",{style:{...E,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[z.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Bt,{value:e.organization,onChange:$=>I({organization:$}),organizations:r,disabled:m||!!de.custom_organization})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.title}),n.jsx("input",{style:{...E,...Q},value:e.title,disabled:m,onChange:$=>I({title:$.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.management}),n.jsx(ge,{value:e.management,onChange:$=>I({management:$}),items:Ce,placeholder:z.field.select,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.department}),n.jsx(ge,{value:e.department,onChange:$=>I({department:$}),items:Be,placeholder:z.field.select,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.section}),n.jsx("input",{style:{...E,...Q},value:e.section_field||"",disabled:m,onChange:$=>I({section_field:$.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.branch}),n.jsx(ge,{value:e.branch,onChange:$=>I({branch:$}),items:Le,placeholder:z.field.select,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.type}),n.jsx(ge,{value:e.type,onChange:$=>I({type:$}),items:he,placeholder:z.field.selectType,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.incidentClass}),n.jsx(ge,{value:e.incident_class,onChange:$=>I({incident_class:$}),items:Xe,placeholder:z.field.selectClass,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.incidentField}),n.jsx(ge,{value:e.incident_field,onChange:$=>I({incident_field:$}),items:K,placeholder:z.field.selectField,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.hsesField}),n.jsx("input",{style:{...E,...Q},value:e.hses_field||"",disabled:m,onChange:$=>I({hses_field:$.target.value}),placeholder:"Safety, Health, Environment…"})]})]})}),n.jsxs(ie,{title:"Incident Details & Timing",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.date}),n.jsx(je,{value:e.date,onChange:$=>I({date:$}),disabled:!0,style:{...E,background:"#f8fafc"}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.time}),n.jsx("input",{type:"time",style:{...E,background:"#f8fafc"},value:e.time,disabled:!0,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.assignedTo}),n.jsx("input",{style:{...E,background:"#f8fafc",fontWeight:600,color:"#334155"},value:B||"Unassigned",readOnly:!0,disabled:!0})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.description}),n.jsx("textarea",{style:{...E,...Q,height:100,resize:"vertical"},value:e.description,disabled:m,onChange:$=>I({description:$.target.value}),placeholder:"Detailed description of the incident..."})]})]}),!ht&&n.jsxs(ie,{title:z.steps.auditorTriage,children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.priority}),n.jsxs("select",{style:{...E,...m||!se?{background:"#f8fafc"}:{}},value:e.priority||"",disabled:m||!se,onChange:$=>I({priority:$.target.value}),children:[n.jsx("option",{value:"",children:z.field.select}),n.jsx("option",{value:"High",children:z.field.high}),n.jsx("option",{value:"Normal",children:z.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.economyClass}),n.jsxs("select",{style:{...E,...m||!se?{background:"#f8fafc"}:{}},value:e.economy_class||"",disabled:m||!se,onChange:$=>I({economy_class:$.target.value}),children:[n.jsx("option",{value:"",children:z.field.select}),n.jsx("option",{value:"Expenses",children:z.field.expenses}),n.jsx("option",{value:"Capital",children:z.field.capital}),n.jsx("option",{value:"Earn",children:z.field.earn}),n.jsx("option",{value:"Pay/Loss",children:z.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.entityScope}),n.jsxs("select",{style:{...E,...m||!se?{background:"#f8fafc"}:{}},value:e.entity_scope||"",disabled:m||!se,onChange:$=>I({entity_scope:$.target.value}),children:[n.jsx("option",{value:"",children:z.field.select}),n.jsx("option",{value:"Upstream",children:z.field.upstream}),n.jsx("option",{value:"On-stream",children:z.field.onstream}),n.jsx("option",{value:"Downstream",children:z.field.downstream})]})]})]}),n.jsxs("div",{style:{display:"flex",gap:20,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.product_relation,disabled:m||!se,onChange:$=>I({product_relation:$.target.checked?1:0})})," ",z.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||!se,onChange:$=>I({repeated:$.target.checked?1:0})})," ",z.field.repeatedEvent]})]})]}),!ht&&n.jsxs(ie,{title:z.steps.managerSolution,children:[n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:z.field.solution}),n.jsx("textarea",{style:{...E,height:90,resize:"vertical",...m&&!st&&!se?{background:"#f8fafc"}:{}},value:e.solution||"",disabled:m&&!st&&!se,onChange:$=>I({solution:$.target.value}),placeholder:z.field.solutionPlaceholder})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:12},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.actualCost}),n.jsx("input",{type:"number",style:{...E,...m&&!st&&!se?{background:"#f8fafc"}:{}},value:e.cost||"",disabled:m&&!st&&!se,onChange:$=>I({cost:parseFloat($.target.value)||0}),placeholder:"0.00"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.summary}),n.jsx("input",{style:{...E,...m&&!st&&!se?{background:"#f8fafc"}:{}},value:e.summary||"",disabled:m&&!st&&!se,onChange:$=>I({summary:$.target.value}),placeholder:"Brief summary"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:z.field.auditorComment}),n.jsx("textarea",{style:{...E,height:70,resize:"vertical",...m&&!se?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:m&&!se,onChange:$=>I({auditor_comment:$.target.value}),placeholder:z.field.commentPlaceholder})]})]})]})}function y0({ideas:e,organizations:t,departments:r,branches:s,ideaStatuses:l,initialOrg:i,initialStatus:a,canModify:c,onView:d,onEdit:p,onDelete:v}){const f=re(),[u,m]=w.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),j=(o,y)=>m(k=>({...k,[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)*ae,h*ae);return n.jsxs(n.Fragment,{children:[n.jsx(sa,{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:Qe,children:f.filter.numberTitle}),n.jsx("input",{style:Ye,value:u.search,onChange:o=>j("search",o.target.value),placeholder:f.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Qe,children:f.filter.organization}),n.jsxs("select",{style:Ye,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:Qe,children:f.filter.department}),n.jsxs("select",{style:Ye,value:u.department,onChange:o=>j("department",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allDepts}),r.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Qe,children:f.filter.branch}),n.jsxs("select",{style:Ye,value:u.branch,onChange:o=>j("branch",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allBranches}),s.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Qe,children:f.filter.status}),n.jsxs("select",{style:Ye,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?Yn(f.deletedBadge):o.status?Yn(o.status):"—"}),n.jsx("td",{style:{padding:"10px 16px"},onClick:k=>k.stopPropagation(),children:n.jsx(tt,{onView:()=>d==null?void 0:d(o),onEdit:c&&p&&!o.custom_is_deleted&&!On("idea",o.workflow_state)?()=>p(o):void 0,onDelete:c&&v&&!o.custom_is_deleted?()=>v(o.name):void 0})})]},o.name))})]})}),n.jsx(Me,{page:h,total:g.length,onPageChange:S})]})}const v0={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 j0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...v0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function b0({ideaForm:e,setIdeaForm:t,organizations:r,managements:s,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:k,userRole:C,onSubmit:P,onBack:_,onNavigate:R,onLogout:N,user:V,onRefresh:de}){var Ge;const D=re(),z=B=>t({...e,...B}),I=f?{background:"#f9f9f9"}:{},Q=Ss(d,p,"SB Manager",e.organization),[G,A]=w.useState(""),[H,Y]=w.useState(!1),ee=e.name?f?`${D.formTitle.viewIdea}${e.number||e.title||e.name}`:D.formTitle.editIdea:D.formTitle.newIdea,Z=xe(s,e.management).map(B=>({name:B.name,label:B.name1||B.name})),Ce=xe(l,e.department).map(B=>({name:B.name,label:B.department_name||B.name})),Be=xe(i,e.branch).map(B=>({name:B.name,label:B.branch||B.name})),Le=xe(a,e.type).map(B=>({name:B.name,label:B.name1||B.name})),he=e.workflow_state||"New",Xe=C==="Employee",K=C==="Auditor"||C==="Admin",ne=C==="Manager",ht=e.name?he==="New"?[{label:D.wf.submit,action:"Submit",color:"#2563eb"}]:he==="Initial Evaluation"&&K?[{label:D.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:D.wf.reject,action:"Reject",color:"#dc2626"}]:he==="Accept & Under Progress"&&(ne||K)?[{label:D.wf.submitSolution,action:"Submit Proposal",color:"#059669"}]:he==="working on proposal"&&K?[{label:D.wf.moveToOutsourcing,action:"Move to Outsourcing",color:"#0369a1"},{label:D.wf.reject,action:"Reject",color:"#dc2626"}]:[]:[];async function se(B){if(e.name){Y(!0),A("");try{const ze={};B==="Assign to Manager"&&(e.assigned_to&&(ze.assigned_to=e.assigned_to),e.priority&&(ze.priority=e.priority),e.economy_class&&(ze.economy_class=e.economy_class),e.entity_scope&&(ze.entity_scope=e.entity_scope),e.hses_field&&(ze.hses_field=e.hses_field),ze.product_relation=String(e.product_relation??0),ze.repeated=String(e.repeated??0)),B==="Submit Proposal"&&(e.solution&&(ze.solution=e.solution),e.proposed_condition&&(ze.proposed_condition=e.proposed_condition),e.cost&&(ze.cost=String(e.cost))),e.auditor_comment&&(B==="Move to Outsourcing"||B==="Reject")&&(ze.auditor_comment=e.auditor_comment);const qe=await Wy(e.name,B,JSON.stringify(ze));qe!=null&&qe.created_order&&z({sb_order:qe.created_order,workflow_state:"Executed & Closed",status:"Executed & Closed"}),A("Done"),de==null||de()}catch(ze){A(ze.message||"Error")}finally{Y(!1)}}}const st=((Ge=Q.find(B=>B.name===e.assigned_to))==null?void 0:Ge.full_name)||e.assigned_to,vt=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.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:D.wf.workflow}),n.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px",marginBottom:12},children:[n.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:4},children:"Current State"}),n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b"},children:he})]}),he==="Initial Evaluation"&&K&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("label",{style:T,children:D.wf.assignToManager}),n.jsxs("select",{style:E,value:e.assigned_to||"",onChange:B=>z({assigned_to:B.target.value}),children:[n.jsx("option",{value:"",children:D.field.selectMgr}),Q.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:T,children:D.field.solution}),n.jsx("textarea",{style:{...E,height:75,resize:"vertical"},value:e.solution||"",onChange:B=>z({solution:B.target.value}),placeholder:D.field.solutionPlaceholder}),n.jsx("label",{style:{...T,marginTop:6},children:D.field.actualCost}),n.jsx("input",{type:"number",style:E,value:e.cost||"",onChange:B=>z({cost:parseFloat(B.target.value)||0}),placeholder:"0.00"})]}),he==="working on proposal"&&K&&n.jsxs("div",{style:{marginBottom:10},children:[n.jsx("label",{style:T,children:D.field.auditorComment}),n.jsx("textarea",{style:{...E,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:B=>z({auditor_comment:B.target.value}),placeholder:D.field.commentPlaceholder})]}),ht.length>0?n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:ht.map(B=>n.jsx("button",{onClick:()=>se(B.action),disabled:H,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:B.color,color:"white",fontWeight:600,fontSize:12,cursor:H?"not-allowed":"pointer",opacity:H?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:n.jsx("span",{children:H?D.wf.applying:B.label})},B.action))}):n.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:D.wf.noActions}),G&&n.jsx("p",{style:{marginTop:8,fontSize:12,color:G==="Done"?U.green:U.red},children:G})]}),n.jsx(ra,{priority:e.priority,status:he,assignedTo:st,createdDate:e.date,modifiedDate:e.modified}),n.jsx(la,{doctype:O.ideas,docname:e.name,currentUserName:V.name}),n.jsx(ia,{doctype:O.ideas,docname:e.name,docCreation:e.creation,docOwner:e.owner}),u&&j&&!e.custom_is_deleted&&n.jsx(na,{title:"Delete Request",btnText:D.delete,onDelete:()=>j(e.name)})]}):null;return n.jsxs(He,{title:ee,activePage:"ideas",user:V,formStatus:v,statusBadge:n.jsx("span",{style:j0(he),children:he}),buttonText:D.saveIdea,buttonColor:"#16a34a",viewMode:f,onEdit:m,darkMode:g,notifCount:x,onToggleDark:o,onCountChange:y,onViewProfile:k,rightPanel:vt,onSubmit:P,onBack:_,onNavigate:R,onLogout:N,children:[e.custom_is_deleted===1&&n.jsx(zl,{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:"8px 14px",marginBottom:16,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:[D.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:[D.field.viewOrder," →"]})]}),n.jsx(ie,{title:"Idea Information",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.number}),n.jsx("input",{style:{...E,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[D.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Bt,{value:e.organization,onChange:B=>z({organization:B}),organizations:r,disabled:f||!!V.custom_organization})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.title}),n.jsx("input",{style:{...E,...I},value:e.title,disabled:f,onChange:B=>z({title:B.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.management}),n.jsx(ge,{value:e.management,onChange:B=>z({management:B}),items:Z,placeholder:D.field.select,disabled:f})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.department}),n.jsx(ge,{value:e.department,onChange:B=>z({department:B}),items:Ce,placeholder:D.field.select,disabled:f})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.section}),n.jsx("input",{style:{...E,...I},value:e.section_field||"",disabled:f,onChange:B=>z({section_field:B.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.branch}),n.jsx(ge,{value:e.branch,onChange:B=>z({branch:B}),items:Be,placeholder:D.field.select,disabled:f})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.type}),n.jsx(ge,{value:e.type,onChange:B=>z({type:B}),items:Le,placeholder:D.field.selectType,disabled:f})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.ideaClass}),n.jsxs("select",{style:{...E,...I},value:e.idea_class||"",disabled:f,onChange:B=>z({idea_class:B.target.value}),children:[n.jsx("option",{value:"",children:D.field.select}),n.jsx("option",{value:"Safety",children:"Safety"}),n.jsx("option",{value:"Non-safety",children:"Non-safety"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.hsesField}),n.jsx("input",{style:{...E,...I},value:e.hses_field||"",disabled:f,onChange:B=>z({hses_field:B.target.value}),placeholder:"Safety, Health, Environment…"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.date}),n.jsx(je,{value:e.date||"",onChange:B=>z({date:B}),disabled:!0,style:{...E,background:"#f8fafc"}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.assignedTo}),n.jsx("input",{style:{...E,background:"#f8fafc",fontWeight:600,color:"#334155"},value:st||"Unassigned",readOnly:!0,disabled:!0})]})]})}),n.jsx(ie,{title:"Condition Details & Description",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.currentCondition}),n.jsx("textarea",{style:{...E,...I,height:100,resize:"vertical"},value:e.current_condition,disabled:f,onChange:B=>z({current_condition:B.target.value}),placeholder:"Describe the current condition or problem..."})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.proposedCondition}),n.jsx("textarea",{style:{...E,...I,height:100,resize:"vertical"},value:e.proposed_condition,disabled:f,onChange:B=>z({proposed_condition:B.target.value}),placeholder:"Describe the proposed solution or improvement..."})]})]})}),!Xe&&n.jsxs(ie,{title:D.steps.auditorEval,children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.priority}),n.jsxs("select",{style:{...E,...f&&!K?{background:"#f8fafc"}:{}},value:e.priority||"",disabled:f&&!K,onChange:B=>z({priority:B.target.value}),children:[n.jsx("option",{value:"",children:D.field.select}),n.jsx("option",{value:"High",children:D.field.high}),n.jsx("option",{value:"Normal",children:D.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.economyClass}),n.jsxs("select",{style:{...E,...f&&!K?{background:"#f8fafc"}:{}},value:e.economy_class||"",disabled:f&&!K,onChange:B=>z({economy_class:B.target.value}),children:[n.jsx("option",{value:"",children:D.field.select}),n.jsx("option",{value:"Expenses",children:D.field.expenses}),n.jsx("option",{value:"Capital",children:D.field.capital}),n.jsx("option",{value:"Earn",children:D.field.earn}),n.jsx("option",{value:"Pay/Loss",children:D.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.entityScope}),n.jsxs("select",{style:{...E,...f&&!K?{background:"#f8fafc"}:{}},value:e.entity_scope||"",disabled:f&&!K,onChange:B=>z({entity_scope:B.target.value}),children:[n.jsx("option",{value:"",children:D.field.select}),n.jsx("option",{value:"Upstream",children:D.field.upstream}),n.jsx("option",{value:"On-stream",children:D.field.onstream}),n.jsx("option",{value:"Downstream",children:D.field.downstream})]})]})]}),n.jsxs("div",{style:{display:"flex",gap:20,marginTop:12,alignItems:"center",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.product_relation,disabled:f&&!K,onChange:B=>z({product_relation:B.target.checked?1:0})})," ",D.field.productRelation]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.repeated,disabled:f&&!K,onChange:B=>z({repeated:B.target.checked?1:0})})," ",D.field.repeatedEvent]})]})]}),!Xe&&n.jsxs(ie,{title:D.steps.managerSolution,children:[n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:D.field.solution}),n.jsx("textarea",{style:{...E,height:90,resize:"vertical",...f&&!ne&&!K?{background:"#f8fafc"}:{}},value:e.solution||"",disabled:f&&!ne&&!K,onChange:B=>z({solution:B.target.value}),placeholder:D.field.solutionPlaceholder})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.actualCost}),n.jsx("input",{type:"number",style:{...E,...f&&!ne&&!K?{background:"#f8fafc"}:{}},value:e.cost||"",disabled:f&&!ne&&!K,onChange:B=>z({cost:parseFloat(B.target.value)||0}),placeholder:"0.00"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:D.field.auditorComment}),n.jsx("textarea",{style:{...E,height:60,resize:"vertical",...f&&!K?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:f&&!K,onChange:B=>z({auditor_comment:B.target.value}),placeholder:D.field.commentPlaceholder})]})]})]})]})}function S0({orders:e,organizations:t,departments:r,branches:s,orderStatuses:l,initialOrg:i,initialStatus:a,canModify:c,onView:d,onEdit:p,onDelete:v}){const f=re(),[u,m]=w.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),j=(o,y)=>m(k=>({...k,[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)*ae,h*ae);return n.jsxs(n.Fragment,{children:[n.jsx(sa,{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:Qe,children:f.filter.numberTitle}),n.jsx("input",{style:Ye,value:u.search,onChange:o=>j("search",o.target.value),placeholder:f.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Qe,children:f.filter.organization}),n.jsxs("select",{style:Ye,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:Qe,children:f.filter.department}),n.jsxs("select",{style:Ye,value:u.department,onChange:o=>j("department",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allDepts}),r.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Qe,children:f.filter.branch}),n.jsxs("select",{style:Ye,value:u.branch,onChange:o=>j("branch",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allBranches}),s.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Qe,children:f.filter.status}),n.jsxs("select",{style:Ye,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?Rd(o.type):"—"}),n.jsx("td",{style:{padding:"12px 16px"},children:o.custom_is_deleted?Yn(f.deletedBadge):o.status?Yn(o.status):"—"}),n.jsx("td",{style:{padding:"10px 16px"},onClick:k=>k.stopPropagation(),children:n.jsx(tt,{onView:()=>d==null?void 0:d(o),onEdit:c&&p&&!o.custom_is_deleted&&!On("order",o.workflow_state)?()=>p(o):void 0,onDelete:c&&v&&!o.custom_is_deleted?()=>v(o.name):void 0})})]},o.name))})]})}),n.jsx(Me,{page:h,total:g.length,onPageChange:S})]})}const w0={1:"Initiation / Bidding",2:"Execution begins",3:"Mid-execution review",4:"Near completion",5:"Closing"},k0={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 _0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...k0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function C0({orderForm:e,setOrderForm:t,organizations:r,managements:s,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:k,onViewProfile:C,currentUser:P,userRole:_,onSubmit:R,onBack:N,onNavigate:V,onLogout:de,user:D,onRefresh:z}){var Il,an;const I=re(),Q=W=>t({...e,...W}),G=u?{background:"#f9f9f9"}:{},A=Ss(p,v,"SB Employee",e.organization),[H,Y]=w.useState(""),[ee,Z]=w.useState(""),[Ce,Be]=w.useState(!1),[Le,he]=w.useState("Agree"),Xe=e.name?u?`${I.formTitle.viewOrder}${e.number||e.title||e.name}`:I.formTitle.editOrder:I.formTitle.newOrder,K=xe(s,e.management).map(W=>({name:W.name,label:W.name1||W.name})),ne=xe(l,e.department).map(W=>({name:W.name,label:W.department_name||W.name})),ht=xe(i,e.branch).map(W=>({name:W.name,label:W.branch||W.name})),se=xe(a,e.type).map(W=>({name:W.name,label:W.name1||W.name})),st=xe(d,e.cycle).map(W=>({name:W.name,label:W.name1||W.cycle_name||W.name})),vt=!!e.name,Ge=e.workflow_state||"Draft",B=Math.min(5,(e.stage||0)+1),[ze,qe]=w.useState(B);w.useEffect(()=>{qe(Math.min(5,(e.stage||0)+1))},[e.stage]);const $=_==="Auditor"||_==="Admin",me=_==="Auditor"||_==="Admin"||_==="Manager",L=me||_==="Owner",le=!!(P&&(e.actor===P||e.assigned_to===P)),X=vt?Ge==="Closed"?[]:Ge==="Draft"&&me?[{label:"Submit for Review",action:"Submit for Review",color:"#2563eb"}]:Ge==="Pending Actor"&&(le||me)?[{label:"Update Status",action:"Update Status",color:"#d97706"}]:Ge==="Review"&&L?[{label:"Move to Study",action:"Move to Study",color:"#059669"},{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"}]:Ge==="In Study"&&L?[{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"},{label:"Close Order",action:"Close Order",color:"#475569"}]:[]:[];async function zr(W){if(e.name){Be(!0),Y("");try{let ot;W==="Update Status"&&(ot=Le);const Tr=await Ly(e.name,W,ee,W==="Update Status"?String(ze):void 0,void 0,ot);if(Z(""),he("Agree"),Y("Done"),Tr){const on=Tr;t({...e,...on,stage:on.stage??e.stage,completion_pct:on.completion_pct??e.completion_pct,workflow_state:on.workflow_state??e.workflow_state})}z==null||z()}catch(ot){Y(ot.message||"Error")}finally{Be(!1)}}}const aa=((Il=A.find(W=>W.name===(e.actor||e.assigned_to)))==null?void 0:Il.full_name)||e.actor||e.assigned_to,_n=vt?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.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b",marginBottom:10},children:I.wf.workflow}),n.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 12px",marginBottom:12},children:[n.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.4px",marginBottom:4},children:"Current State"}),n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1e293b"},children:Ge})]}),Ge==="Pending Actor"&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:12},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:["Stage (1–5) — ",ze*20,"% complete"]}),n.jsx("input",{type:"number",min:1,max:5,style:{...E,width:"100%"},value:ze,onChange:W=>qe(Math.min(5,Math.max(1,parseInt(W.target.value)||1)))})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Cycle Status"}),n.jsxs("select",{style:E,value:Le,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:T,children:["Comment ",Le==="Deviate"&&Ge==="Pending Actor"?n.jsx("span",{style:{color:U.red},children:" * required for Deviate"}):"(optional)"]}),n.jsx("textarea",{style:{...E,height:60,resize:"vertical",borderColor:Le==="Deviate"&&!ee?"#fca5a5":void 0},value:ee,onChange:W=>Z(W.target.value),placeholder:"Add a comment…"})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:X.map(W=>{const ot=W.action==="Update Status"&&Le==="Deviate"&&!ee.trim();return n.jsx("button",{onClick:()=>zr(W.action),disabled:Ce||ot,title:ot?"Comment required when status is Deviate":void 0,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"none",background:W.color,color:"white",fontWeight:600,fontSize:12,cursor:Ce||ot?"not-allowed":"pointer",opacity:Ce||ot?.5:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:n.jsx("span",{children:Ce?I.wf.applying:W.label})},W.action)})}),H&&n.jsx("p",{style:{marginTop:8,fontSize:12,color:H==="Done"?U.green:U.red},children:H}),X.length===0&&n.jsx("div",{style:{fontSize:11,color:"#94a3b8",fontStyle:"italic"},children:I.wf.noActions})]}),n.jsx(ra,{priority:e.priority,status:Ge,assignedTo:aa,createdDate:e.starting_date,modifiedDate:e.modified}),n.jsx(la,{doctype:O.orders,docname:e.name,currentUserName:D.name}),n.jsx(ia,{doctype:O.orders,docname:e.name,docCreation:e.creation,docOwner:e.owner}),m&&h&&!e.custom_is_deleted&&n.jsx(na,{title:"Delete Request",btnText:I.delete,onDelete:()=>h(e.name)})]}):null;return n.jsxs(He,{title:Xe,activePage:"orders",user:D,formStatus:f,statusBadge:n.jsx("span",{style:_0(Ge),children:Ge}),buttonText:I.saveOrder,buttonColor:"#16a34a",viewMode:u,onEdit:j,darkMode:x,notifCount:o,onToggleDark:y,onCountChange:k,onViewProfile:C,rightPanel:_n,onSubmit:R,onBack:N,onNavigate:V,onLogout:de,children:[e.custom_is_deleted===1&&n.jsx(zl,{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:"8px 14px",marginBottom:16,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:[I.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:[I.field.viewIdea," →"]})]}),n.jsx(ie,{title:"Order Information",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.number}),n.jsx("input",{style:{...E,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[I.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Bt,{value:e.organization,onChange:W=>Q({organization:W}),organizations:r,disabled:u||!!D.custom_organization})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.title}),n.jsx("input",{style:{...E,...G},value:e.title,disabled:u,onChange:W=>Q({title:W.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.management}),n.jsx(ge,{value:e.management,onChange:W=>Q({management:W}),items:K,placeholder:I.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.department}),n.jsx(ge,{value:e.department,onChange:W=>Q({department:W}),items:ne,placeholder:I.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.section}),n.jsx("input",{style:{...E,...G},value:e.section_field||"",disabled:u,onChange:W=>Q({section_field:W.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.branch}),n.jsx(ge,{value:e.branch,onChange:W=>Q({branch:W}),items:ht,placeholder:I.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.type}),n.jsx(ge,{value:e.type,onChange:W=>Q({type:W}),items:se,placeholder:I.field.selectType,disabled:u})]})]})}),n.jsxs(ie,{title:"Financial & Schedule",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.budget}),n.jsx("input",{type:"number",style:{...E,...G},value:e.budget||"",disabled:u,onChange:W=>Q({budget:parseFloat(W.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.actualCost}),n.jsx("input",{type:"number",style:{...E,...G},value:e.actual_cost||"",disabled:u,onChange:W=>Q({actual_cost:parseFloat(W.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Variance"}),(()=>{const W=(e.budget||0)-(e.actual_cost||0);return n.jsxs("div",{style:{padding:"7px 12px",borderRadius:6,fontWeight:700,fontSize:13,background:W>=0?"#f0fdf4":"#fef2f2",color:W>=0?"#166534":"#dc2626",border:`1px solid ${W>=0?"#bbf7d0":"#fecaca"}`,display:"inline-block",width:"100%",boxSizing:"border-box"},children:[W>=0?"+":"",W.toFixed(2)]})})()]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.currency}),n.jsxs("select",{style:{...E,...G},value:e.currency||"",disabled:u,onChange:W=>Q({currency:W.target.value}),children:[n.jsx("option",{value:"",children:I.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",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.startingDate}),n.jsx(je,{value:e.starting_date,onChange:W=>Q({starting_date:W}),disabled:u,style:{...E,...G}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.endingDate}),n.jsx(je,{value:e.ending_date,onChange:W=>Q({ending_date:W}),disabled:u,style:{...E,...G}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.actor}),n.jsxs("select",{style:{...E,...u||!$?{background:"#f8fafc"}:{}},value:e.actor||e.assigned_to||"",disabled:u||!$,onChange:W=>Q({actor:W.target.value,assigned_to:W.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),A.map(W=>n.jsx("option",{value:W.name,children:W.full_name||W.name},W.name))]})]})]})]}),n.jsxs(ie,{title:"Classification",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.priority}),n.jsxs("select",{style:{...E,...G},value:e.priority||"",disabled:u,onChange:W=>Q({priority:W.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:T,children:I.field.economyClass}),n.jsxs("select",{style:{...E,...G},value:e.economy_class||"",disabled:u,onChange:W=>Q({economy_class:W.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:T,children:I.field.entityScope}),n.jsxs("select",{style:{...E,...G},value:e.entity_scope||"",disabled:u,onChange:W=>Q({entity_scope:W.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: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=>Q({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=>Q({product_relation:W.target.checked?1:0})})," ",I.field.productRelation]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:T,children:I.field.hsesField}),n.jsx("input",{style:{...E,...G},value:e.hses_field||"",disabled:u,onChange:W=>Q({hses_field:W.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs(ie,{title:"Cycle & Progress Tracking",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.cycle}),n.jsx(ge,{value:e.cycle||"",onChange:W=>Q({cycle:W}),items:st,placeholder:I.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.stage}),n.jsx("input",{type:"number",min:1,max:5,style:{...E,background:"#f8fafc",color:"#334155",fontWeight:600},value:e.stage||1,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Completion"}),n.jsx("input",{style:{...E,background:"#f8fafc",color:"#334155",fontWeight:600},value:`${e.completion_pct||(e.stage||1)*20}%`,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Stage Description"}),n.jsx("span",{style:{display:"inline-block",padding:"7px 12px",borderRadius:6,fontSize:13,fontWeight:600,background:"#f0f9ff",color:"#0369a1",border:"1px solid #bae6fd",width:"100%",boxSizing:"border-box"},children:w0[e.stage||1]||"—"})]})]}),vt&&((an=e.order_cycle_log)==null?void 0:an.length)>0&&n.jsxs("div",{style:{borderTop:"1px solid #f1f5f9",paddingTop:14,marginTop:10},children:[n.jsx("p",{style:{fontWeight:700,color:"#334155",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,ot)=>{const Tr=W.status==="Agree"?"#166534":W.status==="Deviate"?"#c2410c":"#92400e",on=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:on,color:Tr,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||"—"})]},ot)})})]})})]})]}),n.jsxs(ie,{title:"Description & Notes",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.description}),n.jsx("textarea",{style:{...E,...G,height:90,resize:"vertical"},value:e.description,disabled:u,onChange:W=>Q({description:W.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.notes}),n.jsx("textarea",{style:{...E,...G,height:90,resize:"vertical"},value:e.notes,disabled:u,onChange:W=>Q({notes:W.target.value})})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.auditorComment}),n.jsx("textarea",{style:{...E,height:70,resize:"vertical",...u&&le&&!me?{background:"#f8fafc"}:{}},value:e.auditor_comment||"",disabled:u&&le&&!me,onChange:W=>Q({auditor_comment:W.target.value}),placeholder:I.field.commentPlaceholder})]})]})]})}function z0({processes:e,organizations:t,departments:r,branches:s,processStatuses:l,initialOrg:i,initialStatus:a,canModify:c,onView:d,onEdit:p,onDelete:v}){const f=re(),[u,m]=w.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),j=(o,y)=>m(k=>({...k,[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)*ae,h*ae);return n.jsxs(n.Fragment,{children:[n.jsx(sa,{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:Qe,children:f.filter.numberTitle}),n.jsx("input",{style:Ye,value:u.search,onChange:o=>j("search",o.target.value),placeholder:f.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Qe,children:f.filter.organization}),n.jsxs("select",{style:Ye,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:Qe,children:f.filter.department}),n.jsxs("select",{style:Ye,value:u.department,onChange:o=>j("department",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allDepts}),r.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Qe,children:f.filter.branch}),n.jsxs("select",{style:Ye,value:u.branch,onChange:o=>j("branch",o.target.value),children:[n.jsx("option",{value:"",children:f.filter.allBranches}),s.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Qe,children:f.filter.status}),n.jsxs("select",{style:Ye,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?Rd(o.cycle_type):"—"}),n.jsx("td",{style:{padding:"12px 16px"},children:o.custom_is_deleted?Yn(f.deletedBadge):o.status?Yn(o.status):"—"}),n.jsx("td",{style:{padding:"10px 16px"},onClick:k=>k.stopPropagation(),children:n.jsx(tt,{onView:()=>d==null?void 0:d(o),onEdit:c&&p&&!o.custom_is_deleted&&!On("process",o.workflow_state)?()=>p(o):void 0,onDelete:c&&v&&!o.custom_is_deleted?()=>v(o.name):void 0})})]},o.name))})]})}),n.jsx(Me,{page:h,total:g.length,onPageChange:S})]})}const T0={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"]}]},I0={Draft:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Pending Actor":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},"Pending Comment":{background:"#f5f3ff",color:"#6d28d9",border:"1px solid #ddd6fe"},Review:{background:"#f0fdf4",color:"#15803d",border:"1px solid #bbf7d0"},"In Study":{background:"#f1f5f9",color:"#475569",border:"1px solid #cbd5e1"},Closed:{background:"#f3f4f6",color:"#6b7280",border:"1px solid #9ca3af"}};function wu(e){return{display:"inline-block",padding:"5px 14px",borderRadius:20,fontSize:13,fontWeight:700,...I0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}const Vl={width:"100%",padding:"6px 8px",border:"1px solid #d1d5db",borderRadius:5,fontSize:12,fontFamily:"Segoe UI",boxSizing:"border-box"};function E0({processName:e,userRole:t,onRefresh:r,canUpdateStatus:s=!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,k]=w.useState({}),C=w.useCallback(async()=>{if(!e){c(!1);return}c(!0),p("");try{const D=await Ys(e);i(D);const z={};for(const I of D.progress_indicators||[])z[I.name]=I.actual_value!=null?String(I.actual_value):"";k(z)}catch(D){p(D instanceof Error?D.message:"Failed to load process")}c(!1)},[e]);if(w.useEffect(()=>{C()},[C]),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 P=l.workflow_state||"Draft",_=T0[P]??[],R=t==="Employee"||t==="Manager",N=t!=="Manager"||s,V=_.filter(D=>(t==="Admin"||D.allowedRoles.includes(t))&&(D.action!=="Update Status"||N)),de=async D=>{f(!0),m(""),h("");try{const z={};if(D==="Update Status"){z.actor_status=S,z.actor_comment=x;const Q=l.progress_indicators||[];Q.length>0&&(z.progress_indicators=Q.map(G=>({name:G.name,actual_value:y[G.name]??""})))}D==="Add Comment"&&x&&(z.actor_comment=x);const I=await qy(l.name,D,z);i(I),o(""),h(`Done — now: ${I.workflow_state||"updated"}`),r==null||r()}catch(z){m(z instanceof Error?z.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:wu(P),children:P})]}),P==="Pending Actor"&&R&&N&&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(D=>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:D.name1,children:D.name1||D.name}),n.jsx("input",{type:"number",value:y[D.name]??"",onChange:z=>k(I=>({...I,[D.name]:z.target.value})),style:{...Vl,width:70,flexShrink:0},placeholder:"0"})]},D.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:D=>g(D.target.value),style:Vl,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:D=>o(D.target.value),style:{...Vl,height:52,resize:"vertical"},placeholder:"Add a comment…"})]})]}),(P==="Pending Comment"||P==="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 D=l.cycle_logs,z=D[D.length-1],I=z.status==="Pass"?"#16a34a":z.status==="Fail"?"#dc2626":"#9ca3af";return n.jsxs("div",{style:{fontSize:13,fontWeight:700,color:I},children:[z.status," ",z.comment?`— ${z.comment}`:""]})})()]}),n.jsx("textarea",{value:x,onChange:D=>o(D.target.value),style:{...Vl,height:52,resize:"vertical"},placeholder:"Add a comment…"})]}),n.jsxs("div",{style:{padding:"12px 14px",borderBottom:V.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"}),V.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:P}),"."]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:V.map(D=>n.jsxs("button",{onClick:()=>de(D.action),disabled:v,style:{width:"100%",padding:"10px 14px",borderRadius:6,border:"none",background:D.action==="Close Process"?"#64748b":D.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…":D.action}),n.jsxs("span",{style:{fontSize:10,opacity:.7},children:["→ ",D.next]})]},D.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})]}),_.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"}),_.map(D=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6,fontSize:11},children:[n.jsx("span",{style:{color:"#555",flex:1},children:D.action}),n.jsx("span",{style:{color:"#bbb"},children:"→"}),n.jsx("span",{style:wu(D.next),children:D.next})]},D.action))]})]})})}function P0({processForm:e,setProcessForm:t,organizations:r,managements:s,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:k,userRole:C,delegatedFunctions:P=[],delegatedOrgs:_=null,onRefreshProcess:R,onSubmit:N,onBack:V,onNavigate:de,onLogout:D,user:z}){var me;const I=re(),Q=L=>t({...e,...L}),G=u?{background:"#f9f9f9"}:{},A=!u&&C==="Manager"&&Array.isArray(_),H=A?r.filter(L=>(_||[]).includes(L.organization_name||L.name)):r,Y=A&&(_||[]).length===1||!!z.custom_organization,ee=xe(s,e.management).map(L=>({name:L.name,label:L.name1||L.name})),Z=xe(l,e.department).map(L=>({name:L.name,label:L.department_name||L.name})),Ce=xe(i,e.branch).map(L=>({name:L.name,label:L.branch||L.name})),Be=xe(a,e.type).map(L=>({name:L.name,label:L.name1||L.name})),Le=xe(d,e.cycle).map(L=>({name:L.name,label:L.name1||L.name})),he=Ss(p,v,"SB Employee",e.organization).map(L=>({name:L.name,label:L.full_name||L.name})),Xe=Ss(p,v,"SB Manager",e.organization).map(L=>({name:L.name,label:L.full_name||L.name})),K=(L,le)=>{const X=[...e.cycle_logs||[]];X[L]={...X[L],...le},Q({cycle_logs:X})},ne=()=>{Q({cycle_logs:[...e.cycle_logs||[],{cycle:"",cycle_date:"",status:"Pass",actor:"",comment:""}]})},ht=L=>{const le=[...e.cycle_logs||[]];le.splice(L,1),Q({cycle_logs:le})},se=(L,le)=>{const X=[...e.progress_indicators||[]];X[L]={...X[L],...le},Q({progress_indicators:X})},st=()=>{Q({progress_indicators:[...e.progress_indicators||[],{name1:"",type:"Nominal",unit:"",cycle:"",target:"",maximum:"",minimum:"",manager:"",order:"",actual_value:"",cycle_status:"",cycle_date:"",cycle_comment:"",status:""}]})},vt=L=>{const le=[...e.progress_indicators||[]];le.splice(L,1),Q({progress_indicators:le})},Ge=e.name?u?`${I.formTitle.viewProcess}${e.title||e.name}`:I.formTitle.editProcess:I.formTitle.newProcess,B=C!=="Manager"||e.actor===z.name||P.includes("update_process_status"),ze=((me=he.find(L=>L.name===e.actor))==null?void 0:me.label)||e.actor,qe=e.workflow_state||"Draft",$=e.name?n.jsxs("div",{style:{width:240,display:"flex",flexDirection:"column",gap:12},children:[n.jsx(E0,{processName:e.name,userRole:C||z.role||"Employee",onRefresh:R,canUpdateStatus:B}),n.jsx(ra,{priority:e.impact_level,status:qe,assignedTo:ze,createdDate:e.date_start,modifiedDate:e.modified}),n.jsx(la,{doctype:O.processes,docname:e.name,currentUserName:z.name}),n.jsx(ia,{doctype:O.processes,docname:e.name,docCreation:e.creation,docOwner:e.owner}),m&&h&&!e.custom_is_deleted&&n.jsx(na,{title:"Delete Request",btnText:I.delete,onDelete:()=>h(e.name)})]}):void 0;return n.jsxs(He,{title:Ge,activePage:"processes",user:z,formStatus:f,statusBadge:n.jsx("span",{style:{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},children:qe}),buttonText:I.saveProcess,buttonColor:"#16a34a",viewMode:u,onEdit:j,darkMode:g,notifCount:x,onToggleDark:o,onCountChange:y,onViewProfile:k,rightPanel:$,onSubmit:N,onBack:V,onNavigate:de,onLogout:D,children:[e.custom_is_deleted===1&&n.jsx(zl,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:S?()=>S(e.name):void 0}),n.jsx(ie,{title:"Process Information",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[e.name&&n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.number}),n.jsx("input",{style:{...E,background:"#f8fafc",color:"#475569",fontWeight:600},value:e.number||"",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[I.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Bt,{value:e.organization,onChange:L=>Q({organization:L}),organizations:H,disabled:u||Y}),A&&n.jsx("div",{style:{fontSize:11,color:"#888",marginTop:4},children:(_||[]).length===0?"You have no delegated organization for Processes.":`Restricted to your delegated organization${(_||[]).length>1?"s":""}: ${(_||[]).join(", ")}`})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.title}),n.jsx("input",{style:{...E,...G},value:e.title,disabled:u,onChange:L=>Q({title:L.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.type}),n.jsx(ge,{value:e.type,onChange:L=>Q({type:L}),items:Be,placeholder:I.field.selectType,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.management}),n.jsx(ge,{value:e.management,onChange:L=>Q({management:L}),items:ee,placeholder:I.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.department}),n.jsx(ge,{value:e.department,onChange:L=>Q({department:L}),items:Z,placeholder:I.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.section}),n.jsx("input",{style:{...E,...G},value:e.section_field||"",disabled:u,onChange:L=>Q({section_field:L.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.branch}),n.jsx(ge,{value:e.branch,onChange:L=>Q({branch:L}),items:Ce,placeholder:I.field.select,disabled:u})]})]})}),n.jsxs(ie,{title:"Classification",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.chainLocation}),n.jsxs("select",{style:{...E,...G},value:e.chain_location||"",disabled:u,onChange:L=>Q({chain_location:L.target.value}),children:[n.jsx("option",{value:"",children:I.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:T,children:I.field.economyClass}),n.jsxs("select",{style:{...E,...G},value:e.economy_class||"",disabled:u,onChange:L=>Q({economy_class:L.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:T,children:I.field.impactLevel}),n.jsxs("select",{style:{...E,...G},value:e.impact_level||"",disabled:u,onChange:L=>Q({impact_level:L.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:T,children:I.field.entityScope}),n.jsxs("select",{style:{...E,...G},value:e.entity_scope||"",disabled:u,onChange:L=>Q({entity_scope:L.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:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"center"},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.hsesField}),n.jsx("input",{style:{...E,...G},value:e.hses_field||"",disabled:u,onChange:L=>Q({hses_field:L.target.value}),placeholder:"Safety, Health, Environment…"})]}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,paddingTop:18},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:L=>Q({product_relation:L.target.checked?1:0})})," ",I.field.productRelation]})})]})]}),n.jsxs(ie,{title:"KPI & Timeline",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.kpiName}),n.jsx("input",{style:{...E,...G},value:e.kpi_name||"",disabled:u,onChange:L=>Q({kpi_name:L.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.kpiType}),n.jsxs("select",{style:{...E,...G},value:e.kpi_type||"",disabled:u,onChange:L=>Q({kpi_type:L.target.value}),children:[n.jsx("option",{value:"",children:I.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:T,children:I.field.kpiMeasure}),n.jsx("input",{style:{...E,...G},value:e.kpi_measure||"",disabled:u,onChange:L=>Q({kpi_measure:L.target.value}),placeholder:"Unit of measure"})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.dateStart}),n.jsx(je,{value:e.date_start,onChange:L=>Q({date_start:L}),disabled:u,style:{...E,...G}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.dateEnd}),n.jsx(je,{value:e.date_end,onChange:L=>Q({date_end:L}),disabled:u,style:{...E,...G}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.cycleType}),n.jsxs("select",{style:{...E,...G},value:e.cycle_type||"",disabled:u,onChange:L=>Q({cycle_type:L.target.value}),children:[n.jsx("option",{value:"",children:I.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,marginTop:14},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#c2410c",marginBottom:10},children:"Long Cycle Milestone Dates"}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:12},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Milestone 1"}),n.jsx(je,{value:e.long_cycle_date_1||"",onChange:L=>Q({long_cycle_date_1:L}),disabled:u,style:{...E,...G}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Milestone 2"}),n.jsx(je,{value:e.long_cycle_date_2||"",onChange:L=>Q({long_cycle_date_2:L}),disabled:u,style:{...E,...G}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Milestone 3"}),n.jsx(je,{value:e.long_cycle_date_3||"",onChange:L=>Q({long_cycle_date_3:L}),disabled:u,style:{...E,...G}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Milestone 4"}),n.jsx(je,{value:e.long_cycle_date_4||"",onChange:L=>Q({long_cycle_date_4:L}),disabled:u,style:{...E,...G}})]})]})]})]}),n.jsxs(ie,{title:"Progress Indicators",children:[n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:12},children:!u&&n.jsx("button",{type:"button",onClick:st,style:{padding:"7px 14px",border:"none",background:"#2563eb",color:"white",borderRadius:6,fontWeight:600,fontSize:12,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:"#f8fafc"},children:[n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Order"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Name"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Type"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Unit"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Target"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Min"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Max"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Manager"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actual Value"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle Status"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle Date"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle Comment"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Status"}),!u&&n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},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:"#94a3b8"},children:"No progress indicators"})}),(e.progress_indicators||[]).map((L,le)=>n.jsxs("tr",{style:{background:le%2===0?"white":"#fafafa",borderBottom:"1px solid #f1f5f9"},children:[n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("input",{style:{...E,...G,width:60},value:L.order??"",disabled:u,onChange:X=>se(le,{order:X.target.value})})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("input",{style:{...E,...G},value:L.name1,disabled:u,onChange:X=>se(le,{name1:X.target.value})})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsxs("select",{style:{...E,...G},value:L.type,disabled:u,onChange:X=>se(le,{type:X.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:"8px 10px"},children:n.jsx("input",{style:{...E,...G,width:70},type:"text",value:L.unit??"",disabled:u,onChange:X=>se(le,{unit:X.target.value}),placeholder:"e.g. °C, kg, %"})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsxs("select",{style:{...E,...G,minWidth:120},value:L.cycle,disabled:u,onChange:X=>se(le,{cycle:X.target.value}),children:[n.jsx("option",{value:"",children:"--"}),Le.map(X=>n.jsx("option",{value:X.name,children:X.label},X.name)),L.cycle&&!Le.some(X=>X.name===L.cycle)&&n.jsx("option",{value:L.cycle,children:L.cycle})]})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("input",{style:{...E,...G,width:80},value:L.target,disabled:u,onChange:X=>se(le,{target:X.target.value})})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("input",{style:{...E,...G,width:80},value:L.minimum,disabled:u,onChange:X=>se(le,{minimum:X.target.value})})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("input",{style:{...E,...G,width:80},value:L.maximum,disabled:u,onChange:X=>se(le,{maximum:X.target.value})})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsxs("select",{style:{...E,...G,minWidth:140},value:L.manager,disabled:u,onChange:X=>se(le,{manager:X.target.value}),children:[n.jsx("option",{value:"",children:"--"}),Xe.map(X=>n.jsx("option",{value:X.name,children:X.label},X.name)),L.manager&&!Xe.some(X=>X.name===L.manager)&&n.jsx("option",{value:L.manager,children:L.manager})]})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("input",{style:{...E,...G,width:90},type:"number",value:L.actual_value??"",disabled:u,onChange:X=>se(le,{actual_value:parseFloat(X.target.value)||""})})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsxs("select",{style:{...E,...G},value:L.cycle_status??"",disabled:u,onChange:X=>se(le,{cycle_status:X.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:"8px 10px"},children:n.jsx(je,{value:L.cycle_date||"",onChange:X=>se(le,{cycle_date:X}),disabled:u,style:{...E,...G,width:110}})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("input",{style:{...E,...G},value:L.cycle_comment??"",disabled:u,onChange:X=>se(le,{cycle_comment:X.target.value})})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsxs("select",{style:{...E,...G},value:L.status??"",disabled:u,onChange:X=>se(le,{status:X.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:"8px 10px"},children:n.jsx("button",{type:"button",onClick:()=>vt(le),style:{padding:"4px 8px",border:"1px solid #fecaca",background:"#fef2f2",color:"#dc2626",borderRadius:4,cursor:"pointer",fontSize:11,fontWeight:600},children:"Remove"})})]},le))]})]})})]}),n.jsx(ie,{title:"Cycle & Assignment",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16,marginBottom:12},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.cycle}),n.jsx(ge,{value:e.cycle||"",onChange:L=>Q({cycle:L}),items:Le,placeholder:I.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.actor}),n.jsxs("select",{style:{...E,...G},value:e.actor||"",disabled:u,onChange:L=>Q({actor:L.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),he.map(L=>n.jsx("option",{value:L.name,children:L.label},L.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.costPerCycle}),n.jsx("input",{style:{...E,...G},type:"number",value:e.cost_per_cycle||"",disabled:u,onChange:L=>Q({cost_per_cycle:parseFloat(L.target.value)||0}),placeholder:"0.00"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.escalationLevel}),n.jsx("input",{style:{...E,...G},type:"number",value:e.escalation_level||"",disabled:u,onChange:L=>Q({escalation_level:parseInt(L.target.value)||0})})]})]})}),n.jsxs(ie,{title:"Cycle History",children:[n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:12},children:!u&&n.jsx("button",{type:"button",onClick:ne,style:{padding:"7px 14px",border:"none",background:"#2563eb",color:"white",borderRadius:6,fontWeight:600,fontSize:12,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:"#f8fafc"},children:[n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Cycle"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Date"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Status"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Actor"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},children:"Comment"}),!u&&n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#475569",fontWeight:600,borderBottom:"1px solid #e2e8f0"},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:"#94a3b8"},children:"No cycle history"})}),(e.cycle_logs||[]).map((L,le)=>n.jsxs("tr",{style:{background:le%2===0?"white":"#fafafa",borderBottom:"1px solid #f1f5f9"},children:[n.jsx("td",{style:{padding:"8px 10px"},children:n.jsxs("select",{style:{...E,...G},value:L.cycle||"",disabled:u,onChange:X=>K(le,{cycle:X.target.value}),children:[n.jsx("option",{value:"",children:"-- Select --"}),Le.map(X=>n.jsx("option",{value:X.name,children:X.label},X.name))]})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx(je,{value:L.cycle_date||"",onChange:X=>K(le,{cycle_date:X}),disabled:u,style:{...E,...G,width:130}})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsxs("select",{style:{...E,...G},value:L.status,disabled:u,onChange:X=>K(le,{status:X.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:"8px 10px"},children:n.jsxs("select",{style:{...E,...G},value:L.actor||"",disabled:u,onChange:X=>K(le,{actor:X.target.value}),children:[n.jsx("option",{value:"",children:"-- Select --"}),he.map(X=>n.jsx("option",{value:X.name,children:X.label},X.name))]})}),n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("input",{style:{...E,...G},value:L.comment||"",disabled:u,onChange:X=>K(le,{comment:X.target.value})})}),!u&&n.jsx("td",{style:{padding:"8px 10px"},children:n.jsx("button",{type:"button",onClick:()=>ht(le),style:{padding:"4px 8px",border:"1px solid #fecaca",background:"#fef2f2",color:"#dc2626",borderRadius:4,cursor:"pointer",fontSize:11,fontWeight:600},children:"Remove"})})]},le))]})]})})]}),n.jsx(ie,{title:I.field.auditorComment,children:n.jsx("textarea",{style:{...E,height:70,resize:"vertical",background:"#f8fafc"},value:e.auditor_comment||"",disabled:!0,readOnly:!0,placeholder:I.field.commentPlaceholder})})]})}const A0={Admin:"#7c3aed",Auditor:"#d97706",Owner:"#0369a1",XAuditor:"#0f766e",Manager:"#2563eb",Employee:"#6b7280",Chairman:"#0f766e"};function R0({user:e,profileUser:t,darkMode:r,canModify:s,onBack:l,organizations:i=[],managements:a=[],departments:c=[],branches:d=[]}){const p=t||{},v=!!s&&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(""),k=p.email||p.name||"",C=[f.first_name,f.middle_name,f.last_name].filter(Boolean).join(" ")||p.full_name||"",P=p.username||p.name||"",_=f.custom_category||"",R=p.enabled===0?"Inactive":"Active",N=A0[e.role]||"#6b7280",V=r,de=V?"#0f172a":"#f0f2f5",D=V?"#1e293b":"white",z=V?"#2d3748":"#e5e7eb",I=V?"#e2e8f0":"#1a2332",Q=V?"#94a3b8":"#6b7280",G=V?"#374151":"white",A=V?"#2d3748":"#f9fafb",H={width:"100%",padding:"9px 12px",borderRadius:8,border:`1px solid ${z}`,fontSize:13,background:G,color:I,fontFamily:"inherit",outline:"none"},Y={...H,background:A,color:Q},ee={...H,cursor:"pointer"},Z={fontSize:12,fontWeight:600,color:Q,marginBottom:5,display:"block"},Ce={display:"grid",gridTemplateColumns:"1fr 1fr",gap:14},Be={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:14},Le=async()=>{if(s){j("saving");try{await Bi("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 Vf(p.name,g.new),y("done"),x({new:"",confirm:""}),setTimeout(()=>{y(""),S(!1)},2e3)}catch{y("error")}},Xe=({title:K,icon:ne,children:ht})=>n.jsxs("div",{style:{background:D,borderRadius:12,padding:22,border:`1px solid ${z}`,boxShadow:`0 1px 4px rgba(0,0,0,${V?.3:.06})`},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,paddingBottom:14,borderBottom:`1px solid ${z}`},children:[ne,n.jsx("span",{style:{fontSize:14,fontWeight:700,color:I},children:K})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:ht})]});return n.jsxs("div",{style:{background:de,minHeight:"100%",padding:"0 0 32px"},children:[n.jsxs("div",{style:{background:D,borderBottom:`1px solid ${z}`,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:I,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"]}),s&&n.jsxs("button",{onClick:Le,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:C||k}),n.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.75)",textAlign:"center"},children:k})]}),n.jsx("div",{style:{background:D},children:[{icon:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:N,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:P},{icon:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:N,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:_||"—"},{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:N,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:k},{icon:n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:N,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:K,label:ne,value:ht,valueColor:se})=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 16px",borderBottom:`1px solid ${z}`},children:[n.jsx("div",{style:{flexShrink:0,width:18,display:"flex",justifyContent:"center"},children:K}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:11,color:Q,marginBottom:1},children:ne}),n.jsx("div",{style:{fontSize:13,fontWeight:600,color:se||I,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ht})]})]},ne))})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:18},children:[n.jsxs(Xe,{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:Ce,children:[n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["Email ",n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Read-only)"})]}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx("div",{style:{position:"absolute",left:11,top:"50%",transform:"translateY(-50%)"},children:n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#94a3b8",strokeWidth:"2",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),n.jsx("path",{d:"m2 7 10 7 10-7"})]})}),n.jsx("input",{style:{...Y,paddingLeft:32},value:k,readOnly:!0})]})]}),n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["Full Name ",n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Auto-generated)"})]}),n.jsx("input",{style:Y,value:C,readOnly:!0})]})]}),n.jsxs("div",{style:Be,children:[n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["First Name ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{style:s?H:Y,value:f.first_name,readOnly:!s,onChange:K=>u(ne=>({...ne,first_name:K.target.value})),placeholder:"First name"})]}),n.jsxs("div",{children:[n.jsx("label",{style:Z,children:"Middle Name"}),n.jsx("input",{style:s?H:Y,value:f.middle_name,readOnly:!s,onChange:K=>u(ne=>({...ne,middle_name:K.target.value})),placeholder:"Middle name"})]}),n.jsxs("div",{children:[n.jsx("label",{style:Z,children:"Last Name"}),n.jsx("input",{style:s?H:Y,value:f.last_name,readOnly:!s,onChange:K=>u(ne=>({...ne,last_name:K.target.value})),placeholder:"Last name"})]})]}),n.jsxs("div",{style:Ce,children:[n.jsxs("div",{children:[n.jsx("label",{style:Z,children:"Phone Number"}),n.jsx("input",{style:s?H:Y,value:f.mobile_no,readOnly:!s,onChange:K=>u(ne=>({...ne,mobile_no:K.target.value})),placeholder:"Phone number"})]}),n.jsxs("div",{children:[n.jsx("label",{style:Z,children:"User ID No"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx("input",{style:{...Y,paddingRight:44},value: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:Z,children:["Category ",!v&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),v?n.jsxs("select",{style:ee,value:f.custom_category,onChange:K=>u(ne=>({...ne,custom_category:K.target.value})),children:[n.jsx("option",{value:"",children:"Select category"}),["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"].map(K=>n.jsx("option",{value:K,children:K},K))]}):n.jsx("input",{style:Y,value:_||"—",readOnly:!0})]})]}),n.jsxs(Xe,{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:Ce,children:[n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["Organization ",!v&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),v?n.jsxs("select",{style:ee,value:f.custom_organization,onChange:K=>u(ne=>({...ne,custom_organization:K.target.value})),children:[n.jsx("option",{value:"",children:"Select organization"}),xe(i,f.custom_organization).map(K=>n.jsx("option",{value:K.name,children:K.organization_name||K.name},K.name))]}):n.jsx("input",{style:Y,value:f.custom_organization||"—",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["Management ",!v&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),v?n.jsxs("select",{style:ee,value:f.custom_management,onChange:K=>u(ne=>({...ne,custom_management:K.target.value})),children:[n.jsx("option",{value:"",children:"Select management"}),xe(a,f.custom_management).map(K=>n.jsx("option",{value:K.name,children:K.name1||K.name},K.name))]}):n.jsx("input",{style:Y,value:f.custom_management||"—",readOnly:!0})]})]}),n.jsxs("div",{style:Ce,children:[n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["Department ",!v&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),v?n.jsxs("select",{style:ee,value:f.custom_department,onChange:K=>u(ne=>({...ne,custom_department:K.target.value})),children:[n.jsx("option",{value:"",children:"Select department"}),xe(c,f.custom_department).map(K=>n.jsx("option",{value:K.name,children:K.department_name||K.name},K.name))]}):n.jsx("input",{style:Y,value:f.custom_department||"—",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["Branch ",!v&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),v?n.jsxs("select",{style:ee,value:f.custom_branch,onChange:K=>u(ne=>({...ne,custom_branch:K.target.value})),children:[n.jsx("option",{value:"",children:"Select branch"}),xe(d,f.custom_branch).map(K=>n.jsx("option",{value:K.name,children:K.branch||K.name},K.name))]}):n.jsx("input",{style:Y,value:f.custom_branch||"—",readOnly:!0})]})]})]}),n.jsxs("div",{style:{background:D,borderRadius:12,padding:22,border:`1px solid ${z}`,boxShadow:`0 1px 4px rgba(0,0,0,${V?.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:I},children:"Change Password"})]}),s&&n.jsx("button",{onClick:()=>{S(K=>!K),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:Be,children:[n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["New Password ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{type:"password",style:H,value:g.new,onChange:K=>x(ne=>({...ne,new:K.target.value})),placeholder:"New password"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:Z,children:["Confirm Password ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{type:"password",style:H,value:g.confirm,onChange:K=>x(ne=>({...ne,confirm:K.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 _e({label:e,val:t,color:r}){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 ${r}`,minWidth:0,display:"flex",alignItems:"baseline",gap:8},children:[n.jsx("div",{style:{fontSize:18,fontWeight:700,color:r},children:t}),n.jsx("div",{style:{fontSize:12,color:"#999"},children:e})]})}const th={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151",boxSizing:"border-box"},D0={...th,cursor:"pointer"};function ft({filters:e,defaultOpen:t=!1}){const[r,s]=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:()=>s(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:r?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"})]}),r&&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:th,placeholder:l.placeholder,value:l.value,onChange:a=>l.onChange(a.target.value)}):n.jsx("select",{style:D0,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 L0(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 O0({organizations:e,canModify:t,onView:r,onEdit:s,onDelete:l}){const i=re(),[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)*ae,j*ae);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(_e,{label:"Total",val:m.length,color:"#1a2332"}),n.jsx(_e,{label:"Active",val:m.filter(g=>g.is_active).length,color:U.green}),n.jsx(_e,{label:"Government",val:m.filter(g=>g.type==="Government").length,color:U.blue}),n.jsx(_e,{label:"Private",val:m.filter(g=>g.type==="Private").length,color:U.orange})]}),n.jsx(ft,{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:()=>r==null?void 0:r(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:L0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:bl(g.is_active?i.field.statusActive:i.field.statusInactive,g.is_active?U.green:U.gray)}),n.jsx("td",{style:{padding:"8px 14px"},onClick:o=>o.stopPropagation(),children:n.jsx(tt,{onView:()=>r==null?void 0:r(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&l?()=>l(g.name):void 0})})]},g.name))})]})}),n.jsx(Me,{page:j,total:m.length,onPageChange:h})]})}const fn=e=>({background:e?"#f9f9f9":void 0});function W0({orgForm:e,setOrgForm:t,groupCompanies:r=[],formStatus:s,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=re(),g=e.name?l&&e.organization_name||S.formTitle.editOrg:S.formTitle.newOrg,x=r.map(o=>({name:o.name,label:o.company_name?`${o.company_name} (${o.name})`:o.name}));return n.jsxs(He,{title:g,activePage:"organizations",user:h,formStatus:s,buttonText:S.saveOrg,buttonColor:"#16a34a",viewMode:l,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:p,onViewProfile:v,onSubmit:f,onBack:u,onNavigate:m,onLogout:j,children:[n.jsx(ie,{title:"Organization Information",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[S.field.orgName," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{type:"text",style:{...E,...fn(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:T,children:[S.field.orgAcronym," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{type:"text",style:{...E,...fn(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:T,children:"Group Company (Tenant)"}),n.jsx(ge,{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",{children:[n.jsx("label",{style:T,children:S.field.organizationType}),n.jsxs("select",{style:{...E,...fn(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:T,children:S.field.orgCity}),n.jsx("input",{type:"text",style:{...E,...fn(l)},value:e.city,disabled:l,onChange:o=>t({...e,city:o.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.contactEmail}),n.jsx("input",{type:"email",style:{...E,...fn(l)},value:e.contact_email,disabled:l,onChange:o=>t({...e,contact_email:o.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.creationDate}),n.jsx(je,{value:e.creation_date||"",onChange:o=>t({...e,creation_date:o}),disabled:l,style:{...E,...fn(l)}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.status}),n.jsxs("select",{style:{...E,...fn(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.jsx(ie,{title:"Incident SLA Windows",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.incidentTriageWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...E,...fn(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:"#64748b",display:"block",marginTop:4},children:"Days after creation before an untriaged Incident is flagged overdue"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.incidentResolutionWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...E,...fn(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:"#64748b",display:"block",marginTop:4},children:"Days without an update before an in-progress Incident is flagged overdue"})]})]})})]})}function N0({groupCompanies:e,canModify:t,onView:r,onEdit:s,onDelete:l}){const i=re(),[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)*ae,u*ae);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(_e,{label:"Total Group Cos",val:f.length,color:"#1a2332"}),n.jsx(_e,{label:"Active",val:f.filter(h=>(h.status||"Active")==="Active").length,color:U.green}),n.jsx(_e,{label:"Inactive",val:f.filter(h=>h.status==="Inactive").length,color:U.orange})]}),n.jsx(ft,{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:bl(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:bl(h.status||"Active",(h.status||"Active")==="Active"?U.green:U.orange)}),n.jsx("td",{style:{padding:"12px 14px"},children:n.jsx(tt,{onView:r?()=>r(h):void 0,onEdit:t&&s?()=>s(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(Me,{page:u,total:f.length,onPageChange:m})]})}function B0({form:e,setForm:t,users:r=[],formStatus:s,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=k=>t({...e,...k}),x=l?{background:"#f8fafc"}:{},o=e.name?l?`View Group Company: ${e.company_name}`:"Edit Group Company":"New Group Company",y=r.map(k=>({name:k.name,label:k.full_name?`${k.full_name} (${k.name})`:k.name}));return n.jsxs(He,{title:o,activePage:"group-companies",user:S,formStatus:s,buttonText:"Save Group Company",buttonColor:"#16a34a",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(zl,{deletedBy:e.custom_deleted_by,deletedOn:e.custom_deleted_on,reason:e.custom_deleted_reason,onRestore:a?()=>a(e.name):void 0}),n.jsxs(ie,{title:"Group Company Details",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:["Company Name ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...x},value:e.company_name||"",disabled:l||!!e.name,onChange:k=>g({company_name:k.target.value}),placeholder:"e.g. Company A Group"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Company Code"}),n.jsx("input",{style:{...E,...x},value:e.code||"",disabled:l,onChange:k=>g({code:k.target.value}),placeholder:"e.g. CO-A"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Acronym"}),n.jsx("input",{style:{...E,...x},value:e.acronym||"",disabled:l,onChange:k=>g({acronym:k.target.value}),placeholder:"e.g. CAG"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Status"}),n.jsxs("select",{style:{...E,...x},value:e.status||"Active",disabled:l,onChange:k=>g({status:k.target.value}),children:[n.jsx("option",{value:"Active",children:"Active"}),n.jsx("option",{value:"Inactive",children:"Inactive"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Group Co Owner / Admin User"}),n.jsx(ge,{value:e.owner_user||"",onChange:k=>g({owner_user:k}),items:y,placeholder:"Select owner user",disabled:l})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Notes"}),n.jsx("textarea",{style:{...E,...x,height:75,resize:"vertical"},value:e.notes||"",disabled:l,onChange:k=>g({notes:k.target.value}),placeholder:"Additional details regarding this tenant company…"})]})]})]})}function $0(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 U0({managements:e,canModify:t,onView:r,onEdit:s,onDelete:l}){const i=re(),[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)*ae,u*ae);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:f.length,color:U.blue})}),n.jsx(ft,{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:()=>r==null?void 0:r(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:$0(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(tt,{onView:()=>r==null?void 0:r(h),onEdit:t&&s?()=>s(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Me,{page:u,total:f.length,onPageChange:m})]})}function F0({form:e,setForm:t,organizations:r,formStatus:s,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=re(),g=y=>t(k=>({...k,...y})),x=l?{background:"#f8fafc"}:{},o=e.name?l?`${S.formTitle.editMgmt}: ${e.name1||e.name}`:S.formTitle.editMgmt:S.formTitle.newMgmt;return n.jsx(He,{title:o,activePage:"managements",user:h,formStatus:s,buttonText:S.saveMgmt,buttonColor:"#16a34a",viewMode:l,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:p,onViewProfile:v,onSubmit:f,onBack:u,onNavigate:m,onLogout:j,children:n.jsx(ie,{title:"Management Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Bt,{value:e.organization,onChange:y=>g({organization:y}),organizations:r,disabled:l||!!h.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[S.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...x},value:e.name1,disabled:l||!!e.name,onChange:y=>g({name1:y.target.value}),placeholder:"Management name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.creationDate}),n.jsx(je,{value:e.creation_date||"",onChange:y=>g({creation_date:y}),disabled:l,style:{...E,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.status}),n.jsxs("select",{style:{...E,...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 M0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function H0({departments:e,managements:t,canModify:r,onView:s,onEdit:l,onDelete:i}){const a=re(),[c,d]=w.useState(""),[p,v]=w.useState(""),[f,u]=w.useState("all"),m=o=>{var y;return((y=t.find(k=>k.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)*ae,S*ae);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:h.length,color:U.teal})}),n.jsx(ft,{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:()=>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.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:M0(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:k=>k.stopPropagation(),children:n.jsx(tt,{onView:()=>s==null?void 0:s(o),onEdit:r&&l?()=>l(o):void 0,onDelete:r&&i?()=>i(o.name):void 0})})]},o.name))})]})}),n.jsx(Me,{page:S,total:h.length,onPageChange:g})]})}function G0({form:e,setForm:t,organizations:r,managements:s,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=re(),x=C=>t(P=>({...P,...C})),o=i?{background:"#f8fafc"}:{},y=e.name?i?`${g.formTitle.editDept}: ${e.department_name||e.name}`:g.formTitle.editDept:g.formTitle.newDept,k=xe(s,e.custom_management).map(C=>({name:C.name,label:C.name1||C.name}));return n.jsx(He,{title:y,activePage:"departments",user:S,formStatus:l,buttonText:g.saveDept,buttonColor:"#16a34a",viewMode:i,onEdit:a,darkMode:c,notifCount:d,onToggleDark:p,onCountChange:v,onViewProfile:f,onSubmit:u,onBack:m,onNavigate:j,onLogout:h,children:n.jsx(ie,{title:"Department Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[g.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Bt,{value:e.custom_organization,onChange:C=>x({custom_organization:C}),organizations:r,disabled:i||!!S.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[g.field.department," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...o},value:e.department_name,disabled:i||!!e.name,onChange:C=>x({department_name:C.target.value}),placeholder:"Department name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.management}),n.jsx(ge,{value:e.custom_management,onChange:C=>x({custom_management:C}),items:k,placeholder:g.field.select,disabled:i})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(je,{value:e.custom_creation_date||"",onChange:C=>x({custom_creation_date:C}),disabled:i,style:{...E,...o}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...E,...o},value:e.custom_status||"Active",disabled:i,onChange:C=>x({custom_status:C.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})})})}function K0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function Q0({branches:e,managements:t,departments:r,canModify:s,onView:l,onEdit:i,onDelete:a}){const c=re(),[d,p]=w.useState(""),[v,f]=w.useState(""),[u,m]=w.useState(""),[j,h]=w.useState("all"),S=P=>{var _;return((_=t.find(R=>R.name===P))==null?void 0:_.name1)||P||"—"},g=P=>{var _;return((_=r.find(R=>R.name===P))==null?void 0:_.department_name)||P||"—"},x={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},o=w.useMemo(()=>e.filter(P=>{const _=(P.branch||P.name||"").toLowerCase();return!(d&&!_.includes(d.toLowerCase())||v&&P.management!==v||u&&P.department!==u||j!=="all"&&(P.custom_status||"Active")!==j)}),[e,d,v,u,j]),[y,k]=w.useState(1);w.useEffect(()=>{k(1)},[d,v,u,j]);const C=o.slice((y-1)*ae,y*ae);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:o.length,color:U.purple})}),n.jsx(ft,{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(P=>({value:P.name,label:P.name1||P.name}))]},{type:"select",label:c.col.department,value:u,onChange:m,options:[{value:"",label:"All Departments"},...r.map(P=>({value:P.name,label:P.department_name||P.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})}):C.map((P,_)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(P),style:{borderTop:"1px solid #f0f0f0",background:_%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:P.branch||P.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:S(P.management)}),n.jsx("td",{style:{padding:"10px 14px"},children:g(P.department)}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:K0(P.custom_creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:P.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:P.custom_status==="Inactive"?c.field.statusInactive:c.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:R=>R.stopPropagation(),children:n.jsx(tt,{onView:()=>l==null?void 0:l(P),onEdit:s&&i?()=>i(P):void 0,onDelete:s&&a?()=>a(P.name):void 0})})]},P.name))})]})}),n.jsx(Me,{page:y,total:o.length,onPageChange:k})]})}function Y0({form:e,setForm:t,organizations:r,managements:s,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=re(),o=_=>t(R=>({...R,..._})),y=a?{background:"#f8fafc"}:{},k=e.name?a?`${x.formTitle.editBranch}: ${e.branch||e.name}`:x.formTitle.editBranch:x.formTitle.newBranch,C=xe(s,e.management).map(_=>({name:_.name,label:_.name1||_.name})),P=xe(l,e.department).map(_=>({name:_.name,label:_.department_name||_.name}));return n.jsx(He,{title:k,activePage:"branches",user:g,formStatus:i,buttonText:x.saveBranch,buttonColor:"#16a34a",viewMode:a,onEdit:c,darkMode:d,notifCount:p,onToggleDark:v,onCountChange:f,onViewProfile:u,onSubmit:m,onBack:j,onNavigate:h,onLogout:S,children:n.jsx(ie,{title:"Branch Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[x.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Bt,{value:e.organization,onChange:_=>o({organization:_}),organizations:r,disabled:a||!!g.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[x.field.branch," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...y},value:e.branch,disabled:a||!!e.name,onChange:_=>o({branch:_.target.value}),placeholder:"Branch name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:x.field.management}),n.jsx(ge,{value:e.management,onChange:_=>o({management:_}),items:C,placeholder:x.field.select,disabled:a})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:x.field.department}),n.jsx(ge,{value:e.department,onChange:_=>o({department:_}),items:P,placeholder:x.field.select,disabled:a})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:x.field.creationDate}),n.jsx(je,{value:e.custom_creation_date||"",onChange:_=>o({custom_creation_date:_}),disabled:a,style:{...E,...y}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:x.field.status}),n.jsxs("select",{style:{...E,...y},value:e.custom_status||"Active",disabled:a,onChange:_=>o({custom_status:_.target.value}),children:[n.jsx("option",{value:"Active",children:x.field.statusActive}),n.jsx("option",{value:"Inactive",children:x.field.statusInactive})]})]})]})})})}function X0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function q0({incidentTypes:e,canModify:t,onView:r,onEdit:s,onDelete:l}){const i=re(),[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)*ae,u*ae);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:f.length,color:U.red})}),n.jsx(ft,{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:()=>r==null?void 0:r(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:X0(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(tt,{onView:()=>r==null?void 0:r(h),onEdit:t&&s?()=>s(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Me,{page:u,total:f.length,onPageChange:m})]})}function J0({form:e,setForm:t,formStatus:r,viewMode:s,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,user:j}){const h=re(),S=o=>t(y=>({...y,...o})),g=s?{background:"#f8fafc"}:{},x=e.name?s?`Incident Type: ${e.name1||e.name}`:"Edit Incident Type":"New Incident Type";return n.jsx(He,{title:x,activePage:"incident-types",user:j,formStatus:r,buttonText:h.saveName,buttonColor:"#16a34a",viewMode:s,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,children:n.jsx(ie,{title:"Incident Type Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...g},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Incident type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.creationDate}),n.jsx(je,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...E,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.status}),n.jsxs("select",{style:{...E,...g},value:e.status||"Active",disabled:s,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 V0(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 Z0({ideaTypes:e,canModify:t,onView:r,onEdit:s,onDelete:l}){const i=re(),[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)*ae,u*ae);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:f.length,color:U.teal})}),n.jsx(ft,{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:()=>r==null?void 0:r(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:V0(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(tt,{onView:()=>r==null?void 0:r(h),onEdit:t&&s?()=>s(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Me,{page:u,total:f.length,onPageChange:m})]})}function e1({form:e,setForm:t,formStatus:r,viewMode:s,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,user:j}){const h=re(),S=o=>t(y=>({...y,...o})),g=s?{background:"#f8fafc"}:{},x=e.name?s?`Idea Type: ${e.name1||e.name}`:"Edit Idea Type":"New Idea Type";return n.jsx(He,{title:x,activePage:"idea-types",user:j,formStatus:r,buttonText:h.saveName,buttonColor:"#16a34a",viewMode:s,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,children:n.jsx(ie,{title:"Idea Type Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...g},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Idea type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.creationDate}),n.jsx(je,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...E,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.status}),n.jsxs("select",{style:{...E,...g},value:e.status||"Active",disabled:s,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 n1({orderTypes:e,canModify:t,onView:r,onEdit:s,onDelete:l}){const i=re(),[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)*ae,u*ae);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:f.length,color:U.purple})}),n.jsx(ft,{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:()=>r==null?void 0:r(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: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(tt,{onView:()=>r==null?void 0:r(h),onEdit:t&&s?()=>s(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Me,{page:u,total:f.length,onPageChange:m})]})}function r1({form:e,setForm:t,formStatus:r,viewMode:s,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,user:j}){const h=re(),S=o=>t(y=>({...y,...o})),g=s?{background:"#f8fafc"}:{},x=e.name?s?`Order Type: ${e.name1||e.name}`:"Edit Order Type":"New Order Type";return n.jsx(He,{title:x,activePage:"order-types",user:j,formStatus:r,buttonText:h.saveName,buttonColor:"#16a34a",viewMode:s,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,children:n.jsx(ie,{title:"Order Type Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...g},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Order type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.creationDate}),n.jsx(je,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...E,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.status}),n.jsxs("select",{style:{...E,...g},value:e.status||"Active",disabled:s,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 l1({processTypes:e,canModify:t,onView:r,onEdit:s,onDelete:l}){const i=re(),[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)*ae,u*ae);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:f.length,color:U.blue})}),n.jsx(ft,{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:()=>r==null?void 0:r(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: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(tt,{onView:()=>r==null?void 0:r(h),onEdit:t&&s?()=>s(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Me,{page:u,total:f.length,onPageChange:m})]})}function i1({form:e,setForm:t,formStatus:r,viewMode:s,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,user:j}){const h=re(),S=o=>t(y=>({...y,...o})),g=s?{background:"#f8fafc"}:{},x=e.name?s?`Process Type: ${e.name1||e.name}`:"Edit Process Type":"New Process Type";return n.jsx(He,{title:x,activePage:"process-types",user:j,formStatus:r,buttonText:h.saveName,buttonColor:"#16a34a",viewMode:s,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,children:n.jsx(ie,{title:"Process Type Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...g},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Process type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.creationDate}),n.jsx(je,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...E,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.status}),n.jsxs("select",{style:{...E,...g},value:e.status||"Active",disabled:s,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 a1(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 o1({incidentStatuses:e,canModify:t,onView:r,onEdit:s,onDelete:l}){const i=re(),[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)*ae,u*ae);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:f.length,color:U.red})}),n.jsx(ft,{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:()=>r==null?void 0:r(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:a1(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(tt,{onView:()=>r==null?void 0:r(h),onEdit:t&&s?()=>s(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Me,{page:u,total:f.length,onPageChange:m})]})}function d1({form:e,setForm:t,formStatus:r,viewMode:s,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,user:j}){const h=re(),S=o=>t(y=>({...y,...o})),g=s?{background:"#f8fafc"}:{},x=e.name?s?`Incident Status: ${e.name1||e.name}`:"Edit Incident Status":"New Incident Status";return n.jsx(He,{title:x,activePage:"incident-statuses",user:j,formStatus:r,buttonText:h.saveName,buttonColor:"#16a34a",viewMode:s,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,children:n.jsxs(ie,{title:"Incident Status Details",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...g},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Incident status name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.creationDate}),n.jsx(je,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...E,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.status}),n.jsxs("select",{style:{...E,...g},value:e.status||"Active",disabled:s,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})]})]})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:s,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:ws}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:s?"default":"pointer"},children:h.field.notifyManager})]})]})})}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({ideaStatuses:e,canModify:t,onView:r,onEdit:s,onDelete:l}){const i=re(),[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)*ae,u*ae);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:f.length,color:U.teal})}),n.jsx(ft,{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:()=>r==null?void 0:r(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: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(tt,{onView:()=>r==null?void 0:r(h),onEdit:t&&s?()=>s(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Me,{page:u,total:f.length,onPageChange:m})]})}function p1({form:e,setForm:t,formStatus:r,viewMode:s,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,user:j}){const h=re(),S=o=>t(y=>({...y,...o})),g=s?{background:"#f8fafc"}:{},x=e.name?s?`Idea Status: ${e.name1||e.name}`:"Edit Idea Status":"New Idea Status";return n.jsx(He,{title:x,activePage:"idea-statuses",user:j,formStatus:r,buttonText:h.saveName,buttonColor:"#16a34a",viewMode:s,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,children:n.jsxs(ie,{title:"Idea Status Details",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...g},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Idea status name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.creationDate}),n.jsx(je,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...E,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.status}),n.jsxs("select",{style:{...E,...g},value:e.status||"Active",disabled:s,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})]})]})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:s,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:ws}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:s?"default":"pointer"},children:h.field.notifyManager})]})]})})}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({orderStatuses:e,canModify:t,onView:r,onEdit:s,onDelete:l}){const i=re(),[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)*ae,u*ae);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:f.length,color:U.purple})}),n.jsx(ft,{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:()=>r==null?void 0:r(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: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(tt,{onView:()=>r==null?void 0:r(h),onEdit:t&&s?()=>s(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Me,{page:u,total:f.length,onPageChange:m})]})}function g1({form:e,setForm:t,formStatus:r,viewMode:s,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,user:j}){const h=re(),S=o=>t(y=>({...y,...o})),g=s?{background:"#f8fafc"}:{},x=e.name?s?`Order Status: ${e.name1||e.name}`:"Edit Order Status":"New Order Status";return n.jsx(He,{title:x,activePage:"order-statuses",user:j,formStatus:r,buttonText:h.saveName,buttonColor:"#16a34a",viewMode:s,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,children:n.jsxs(ie,{title:"Order Status Details",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...g},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Order status name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.creationDate}),n.jsx(je,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...E,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.status}),n.jsxs("select",{style:{...E,...g},value:e.status||"Active",disabled:s,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})]})]})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:s,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:ws}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:s?"default":"pointer"},children:h.field.notifyManager})]})]})})}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({processStatuses:e,canModify:t,onView:r,onEdit:s,onDelete:l}){const i=re(),[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)*ae,u*ae);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:f.length,color:U.blue})}),n.jsx(ft,{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:()=>r==null?void 0:r(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: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(tt,{onView:()=>r==null?void 0:r(h),onEdit:t&&s?()=>s(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Me,{page:u,total:f.length,onPageChange:m})]})}function y1({form:e,setForm:t,formStatus:r,viewMode:s,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,user:j}){const h=re(),S=o=>t(y=>({...y,...o})),g=s?{background:"#f8fafc"}:{},x=e.name?s?`Process Status: ${e.name1||e.name}`:"Edit Process Status":"New Process Status";return n.jsx(He,{title:x,activePage:"process-statuses",user:j,formStatus:r,buttonText:h.saveName,buttonColor:"#16a34a",viewMode:s,onEdit:l,darkMode:i,notifCount:a,onToggleDark:c,onCountChange:d,onViewProfile:p,onSubmit:v,onBack:f,onNavigate:u,onLogout:m,children:n.jsxs(ie,{title:"Process Status Details",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...g},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Process status name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.creationDate}),n.jsx(je,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...E,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.status}),n.jsxs("select",{style:{...E,...g},value:e.status||"Active",disabled:s,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})]})]})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:s,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:ws}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:s?"default":"pointer"},children:h.field.notifyManager})]})]})})}const v1={Admin:"#7c3aed",Chairman:"#0f766e",Auditor:"#d97706","X-Auditor":"#8b5cf6",Manager:"#2563eb",Employee:"#6b7280"};function j1(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 b1({users:e,canModify:t,onView:r,onEdit:s,onDisable:l}){const i=re(),[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,k]=w.useState(""),[C,P]=w.useState("idle"),[_,R]=w.useState(null),N=async()=>{if(!(!x||!y.trim())){P("loading");try{await Vf(x.name,y.trim()),P("success"),setTimeout(()=>{o(null),k(""),P("idle")},1200)}catch{P("error")}}},V=async A=>{if(window.confirm(i.users.disableConfirm)){R(A);try{await(l==null?void 0:l(A))}finally{R(null)}}},de=e.filter(A=>{if(j==="active"&&(A.enabled===0||A.enabled==="0")||j==="inactive"&&A.enabled!==0&&A.enabled!=="0")return!1;const H=A.custom_category||"";if(u&&H!==u)return!1;const Y=A.custom_organization||"";if(v&&!Y.toLowerCase().includes(v.toLowerCase()))return!1;if(d){const ee=d.toLowerCase();if(![A.full_name,A.email,A.name,A.username,A.mobile_no].join(" ").toLowerCase().includes(ee))return!1}return!0}),D=[...new Set(e.map(A=>A.custom_organization).filter(Boolean))],z=["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"];w.useEffect(()=>{g(1)},[d,v,u,j]);const I=de.slice((S-1)*ae,S*ae),Q={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151"},G={...Q,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: ",de.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(A=>!A),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:Q,placeholder:"Name, email, username…",value:d,onChange:A=>p(A.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:A=>f(A.target.value),children:[n.jsx("option",{value:"",children:"All Organizations"}),D.map(A=>n.jsx("option",{value:A,children:A},A))]})]}),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:A=>m(A.target.value),children:[n.jsx("option",{value:"",children:"All Categories"}),z.map(A=>n.jsx("option",{value:A,children:A},A))]})]}),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:A=>h(A.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:A,w:H})=>n.jsx("th",{style:{padding:"11px 14px",textAlign:"left",color:"#6b7280",fontSize:11,fontWeight:700,whiteSpace:"nowrap",minWidth:H,letterSpacing:.3,textTransform:"uppercase"},children:A},A))})}),n.jsx("tbody",{children:de.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"})}):I.map((A,H)=>{const Y=A.custom_category||"",ee=v1[Y]||"#6b7280";return n.jsxs("tr",{onClick:()=>r==null?void 0:r(A),style:{borderBottom:"1px solid #f3f4f6",background:H%2===0?"white":"#fafafa",transition:"background 0.1s",cursor:"pointer"},onMouseEnter:Z=>Z.currentTarget.style.background="#f0f7ff",onMouseLeave:Z=>Z.currentTarget.style.background=H%2===0?"white":"#fafafa",children:[n.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:Y?n.jsx("span",{style:{background:ee+"18",color:ee,border:`1px solid ${ee}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:A.custom_number||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",fontWeight:600,color:"#1a2332",whiteSpace:"nowrap"},children:A.full_name||A.first_name||"—"}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:A.username||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:A.email||A.name}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:A.mobile_no||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:A.custom_organization||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:A.custom_management||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:A.custom_department||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:A.custom_branch||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:j1(A.creation)}),n.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:n.jsx("span",{style:{color:A.enabled?"#16a34a":"#dc2626",fontWeight:600},children:A.enabled?i.users.active:i.users.inactive})}),n.jsx("td",{style:{padding:"10px 14px",whiteSpace:"nowrap"},onClick:Z=>Z.stopPropagation(),children:n.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[n.jsx("button",{onClick:Z=>{Z.stopPropagation(),r==null||r(A)},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&&s&&n.jsx("button",{onClick:Z=>{Z.stopPropagation(),s(A)},title:"Edit",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#dcfce7",color:"#16a34a"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),t&&n.jsx("button",{onClick:Z=>{Z.stopPropagation(),o({name:A.name,email:A.email||A.name}),k(""),P("idle")},title:"Set Password",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#fef3c7",color:"#d97706"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}),t&&n.jsx("button",{onClick:Z=>{Z.stopPropagation(),V(A.name)},disabled:_===A.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:_===A.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"})]})})]})})]},A.name)})})]})}),n.jsx(Me,{page:S,total:de.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:A=>k(A.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:A=>A.key==="Enter"&&N(),autoFocus:!0}),C==="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"}),C==="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:N,disabled:C==="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:C==="loading"?"Saving…":i.users.setPassword}),n.jsx("button",{onClick:()=>{o(null),k(""),P("idle")},style:{flex:1,padding:10,background:"#f5f5f5",color:"#374151",border:"1px solid #e5e7eb",borderRadius:8,cursor:"pointer",fontSize:13,fontFamily:"inherit"},children:i.cancel})]})]})})]})}function S1({form:e,setForm:t,groupCompanies:r=[],organizations:s,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 k=re(),C=z=>t(I=>({...I,...z})),P=d?{background:"#f8fafc"}:{},_=!e.name,R=h?"My Profile":_?"New User":d?`User: ${e.full_name||e.email}`:`Edit User: ${e.full_name||e.email}`,N=r.map(z=>({name:z.name,label:z.company_name?`${z.company_name} (${z.name})`:z.name})),V=xe(l,e.custom_management).map(z=>({name:z.name,label:z.name1||z.name})),de=xe(i,e.custom_department).map(z=>({name:z.name,label:z.department_name||z.name})),D=xe(a,e.custom_branch).map(z=>({name:z.name,label:z.branch||z.name}));return n.jsxs(He,{title:R,activePage:"users",user:y,formStatus:c,buttonText:k.saveUser,buttonColor:"#16a34a",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.jsx(ie,{title:"User Organization & Assignment",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Group Company (Tenant)"}),n.jsx(ge,{value:e.custom_group_company||"",onChange:z=>C({custom_group_company:z}),items:N,placeholder:"-- Select Group Company --",disabled:d||!!y.custom_group_company})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:k.field.organization}),n.jsx(Bt,{value:e.custom_organization,onChange:z=>C({custom_organization:z}),organizations:s,disabled:d})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:k.field.management}),n.jsx(ge,{value:e.custom_management,onChange:z=>C({custom_management:z}),items:V,placeholder:"-- Select --",disabled:d})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:k.field.department}),n.jsx(ge,{value:e.custom_department,onChange:z=>C({custom_department:z}),items:de,placeholder:"-- Select --",disabled:d})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:k.field.branch}),n.jsx(ge,{value:e.custom_branch,onChange:z=>C({custom_branch:z}),items:D,placeholder:"-- Select --",disabled:d})]})]})}),n.jsx(ie,{title:"User Profile Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:k.field.number}),n.jsx("input",{style:{...E,...P},value:e.custom_number,disabled:d,onChange:z=>C({custom_number:z.target.value}),placeholder:"e.g. 10001"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[k.field.fullName," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...P},value:e.first_name,disabled:d,onChange:z=>C({first_name:z.target.value}),placeholder:"Full name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:k.field.username}),n.jsx("input",{style:{...E,...P},value:e.username,disabled:d,onChange:z=>C({username:z.target.value}),placeholder:"Username"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:k.field.phoneNumber}),n.jsx("input",{style:{...E,...P},value:e.mobile_no,disabled:d,onChange:z=>C({mobile_no:z.target.value}),placeholder:"Phone number"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[k.field.emailAddress," ",_&&n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...d||!_?{background:"#f8fafc"}:{}},value:e.email,disabled:d||!_,onChange:z=>C({email:z.target.value}),placeholder:"user@example.com",type:"email",required:_})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:k.field.category}),n.jsxs("select",{style:{...E,...P},value:e.custom_category,disabled:d,onChange:z=>C({custom_category:z.target.value}),children:[n.jsx("option",{value:"",children:k.field.select}),n.jsx("option",{children:"Admin"}),n.jsx("option",{children:"Chairman"}),n.jsx("option",{children:"Auditor"}),n.jsx("option",{children:"X-Auditor"}),n.jsx("option",{children:"Manager"}),n.jsx("option",{children:"Employee"})]})]})]})})]})}const ku={Active:U.green,Closed:U.gray};function w1({cycles:e,canModify:t,onView:r,onEdit:s,onDelete:l}){const i=re(),[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)*ae,j*ae),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(_e,{label:"Total",val:m.length,color:U.teal}),n.jsx(_e,{label:"Active",val:g,color:U.green}),n.jsx(_e,{label:"Closed",val:x,color:U.gray})]}),n.jsx(ft,{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:()=>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.name1||o.name}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.frequency||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.start_date||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.end_date||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{padding:"3px 10px",borderRadius:12,fontSize:12,background:ku[o.status]+"22",color:ku[o.status]||"#666"},children:o.status})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:k=>k.stopPropagation(),children:n.jsx(tt,{onView:()=>r==null?void 0:r(o),onEdit:t&&s?()=>s(o):void 0,onDelete:t&&l?()=>l(o.name):void 0})})]},o.name))})]})}),n.jsx(Me,{page:j,total:m.length,onPageChange:h})]})}const k1=["Weekly","Bi-weekly","Monthly","Quarterly","Annually"],_1=["Active","Closed"];function C1({form:e,setForm:t,organizations:r,formStatus:s,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=re(),g=y=>t(k=>({...k,...y})),x=l?{background:"#f8fafc"}:{},o=e.name?l?`${S.formTitle.editCycle}: ${e.name1||e.name}`:S.formTitle.editCycle:S.formTitle.newCycle;return n.jsx(He,{title:o,activePage:"cycles",user:h,formStatus:s,buttonText:S.saveCycle,buttonColor:"#16a34a",viewMode:l,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:p,onViewProfile:v,onSubmit:f,onBack:u,onNavigate:m,onLogout:j,children:n.jsx(ie,{title:"Cycle Details",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[S.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...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:T,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Bt,{value:e.organization,onChange:y=>g({organization:y}),organizations:r,disabled:l||!!h.custom_organization})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.col.frequency}),n.jsx(ge,{value:e.frequency,onChange:y=>g({frequency:y}),items:k1.map(y=>({name:y,label:y})),placeholder:"-- Select Frequency --",disabled:l})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.status}),n.jsx(ge,{value:e.status,onChange:y=>g({status:y}),items:_1.map(y=>({name:y,label:y})),placeholder:"-- Select Status --",disabled:l})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.dateStart}),n.jsx(je,{value:e.start_date||"",onChange:y=>g({start_date:y}),disabled:l,style:{...E,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.dateEnd}),n.jsx(je,{value:e.end_date||"",onChange:y=>g({end_date:y}),disabled:l,style:{...E,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.updateWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...E,...x},value:e.update_window_days??2,disabled:l,onChange:y=>g({update_window_days:parseInt(y.target.value)||2})}),n.jsx("span",{style:{fontSize:11,color:"#64748b",display:"block",marginTop:4},children:"Grace period before Unknown is auto-assigned"})]})]})})})}function z1({kpiInputs:e,canModify:t,onView:r,onEdit:s,onDelete:l}){const i=re(),[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)*ae,u*ae);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total Records",val:f.length,color:U.blue})}),n.jsx(ft,{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:()=>r==null?void 0:r(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(tt,{onView:()=>r==null?void 0:r(h),onEdit:t&&s?()=>s(h):void 0,onDelete:t&&l?()=>l(h.name):void 0})})]},h.name))})]})}),n.jsx(Me,{page:u,total:f.length,onPageChange:m})]})}function T1({form:e,setForm:t,organizations:r,formStatus:s,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=re(),g=k=>t(C=>({...C,...k})),x=l?{background:"#f8fafc"}:{},o=k=>C=>g({[k]:parseFloat(C.target.value)||0}),y=e.name?l?`${S.formTitle.editKpi}: ${e.period||e.name}`:S.formTitle.editKpi:S.formTitle.newKpi;return n.jsxs(He,{title:y,activePage:"kpi-input",user:h,formStatus:s,buttonText:S.saveKpi,buttonColor:"#16a34a",viewMode:l,onEdit:i,darkMode:a,notifCount:c,onToggleDark:d,onCountChange:p,onViewProfile:v,onSubmit:f,onBack:u,onNavigate:m,onLogout:j,children:[n.jsx(ie,{title:"Period & Organization",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Bt,{value:e.organization,onChange:k=>g({organization:k}),organizations:r,disabled:l||!!h.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[S.col.period," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...x},value:e.period||"",disabled:l,onChange:k=>g({period:k.target.value}),placeholder:"e.g. Q1 2026"})]})]})}),n.jsx(ie,{title:"Financial KPIs",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.revenue_growth}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...x},value:e.revenue_growth||"",disabled:l,onChange:o("revenue_growth")})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.net_profit}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...x},value:e.net_profit||"",disabled:l,onChange:o("net_profit")})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.cash_flow}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...x},value:e.cash_flow||"",disabled:l,onChange:o("cash_flow")})]})]})}),n.jsx(ie,{title:"Operational KPIs",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.strategic_goal_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...x},value:e.strategic_goal_pct||"",disabled:l,onChange:o("strategic_goal_pct")})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.customer_satisfaction}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...x},value:e.customer_satisfaction||"",disabled:l,onChange:o("customer_satisfaction")})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.employee_turnover_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...x},value:e.employee_turnover_pct||"",disabled:l,onChange:o("employee_turnover_pct")})]})]})}),n.jsx(ie,{title:"Safety & Compliance",children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.open_safety_incidents}),n.jsx("input",{type:"number",min:0,style:{...E,...x},value:e.open_safety_incidents||"",disabled:l,onChange:k=>g({open_safety_incidents:parseInt(k.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.compliance_score}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...x},value:e.compliance_score||"",disabled:l,onChange:o("compliance_score")})]})]})})]})}const I1={create_processes:"Create Processes",update_process_status:"Update Process Status"},_u={Pending:U.orange,Accepted:U.green,Rejected:U.red,Revoked:U.gray};function E1(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 P1(e){const t=[];return e.create_processes&&t.push("create_processes"),e.update_process_status&&t.push("update_process_status"),t}function A1({delegations:e,organizations:t,userRole:r,currentUser:s,onView:l,onRevoke:i}){const a=re(),[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 k=`${y.auditor} ${y.manager}`.toLowerCase();return!(c&&!k.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)*ae,h*ae),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(_e,{label:"Total",val:j.length,color:U.purple}),n.jsx(_e,{label:"Pending",val:x,color:U.orange}),n.jsx(_e,{label:"Accepted",val:o,color:U.green})]}),n.jsx(ft,{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,k)=>{const C=!!i&&(y.status==="Pending"||y.status==="Accepted")&&(r==="Admin"||r==="Auditor"&&y.auditor===s);return n.jsxs("tr",{onClick:()=>l==null?void 0:l(y),style:{borderTop:"1px solid #f0f0f0",background:k%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:P1(y).map(P=>n.jsx("span",{style:{background:"#ede9fe",color:"#6d28d9",padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600},children:I1[P]||P},P))})}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{background:(_u[y.status]||U.gray)+"22",color:_u[y.status]||U.gray,padding:"3px 10px",borderRadius:12,fontSize:12,fontWeight:700},children:y.status})}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:E1(y.requested_on)}),n.jsx("td",{style:{padding:"8px 14px"},onClick:P=>P.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"})]})}),C&&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(Me,{page:h,total:j.length,onPageChange:S})]})}const Cu={Pending:U.orange,Accepted:U.green,Rejected:U.red,Revoked:U.gray};function R1(e){if(!e)return"—";const t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleString()}function D1({form:e,setForm:t,organizations:r,users:s,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 P;const x=re(),o=_=>t(R=>({...R,..._})),y=a?{background:"#f8fafc"}:{},k=Ss(s,l,"SB Manager").map(_=>({name:_.name,label:_.full_name||_.name})),C=e.name?`${x.formTitle.viewDelegation}${e.number||e.name}`:x.formTitle.newDelegation;return n.jsxs(He,{title:C,activePage:"delegations",user:g,formStatus:i,statusBadge:e.status?n.jsx("span",{style:{background:(Cu[e.status]||U.gray)+"22",color:Cu[e.status]||U.gray,padding:"4px 12px",borderRadius:14,fontSize:13,fontWeight:700},children:e.status}):void 0,buttonText:x.saveDelegation,buttonColor:"#16a34a",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(ie,{title:"Delegation Information",children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,marginBottom:14},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:x.col.auditor}),n.jsx("input",{style:{...E,background:"#f8fafc",fontWeight:600,color:"#334155"},value:e.auditor||g.name,disabled:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[x.col.manager," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(ge,{value:e.manager,onChange:_=>o({manager:_}),items:k,placeholder:"-- Select Manager --",disabled:a})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:x.col.organization}),n.jsx(Bt,{value:e.organization,onChange:_=>o({organization:_}),organizations:r,placeholder:"-- All Organizations --",disabled:a})]})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[x.col.functions," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsxs("div",{style:{display:"flex",gap:20,marginTop:6,flexWrap:"wrap"},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:a?"default":"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",style:ws,checked:!!e.create_processes,disabled:a,onChange:_=>o({create_processes:_.target.checked?1:0})}),n.jsx("span",{children:"Create Processes"})]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:a?"default":"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",style:ws,checked:!!e.update_process_status,disabled:a,onChange:_=>o({update_process_status:_.target.checked?1:0})}),n.jsx("span",{children:"Update Process Status"})]})]})]}),!a&&n.jsxs("div",{style:{marginTop:14},children:[n.jsx("label",{style:T,children:"Remarks"}),n.jsx("textarea",{style:{...E,...y,minHeight:70,resize:"vertical"},value:e.remarks||"",onChange:_=>o({remarks:_.target.value}),placeholder:"Optional note for the Manager…"})]})]}),a&&(((P=e.delegation_log)==null?void 0:P.length)??0)>0&&n.jsx(ie,{title:"Audit Trail",children:n.jsx("div",{style:{overflowX:"auto"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8fafc"},children:[n.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Action"}),n.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Actor"}),n.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Timestamp"}),n.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#475569",fontSize:11,fontWeight:700,borderBottom:"1px solid #e2e8f0"},children:"Remarks"})]})}),n.jsx("tbody",{children:(e.delegation_log||[]).map((_,R)=>n.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[n.jsx("td",{style:{padding:"8px 12px",fontWeight:600,color:"#334155"},children:_.action}),n.jsx("td",{style:{padding:"8px 12px",color:"#334155"},children:_.actor}),n.jsx("td",{style:{padding:"8px 12px",color:"#64748b"},children:R1(_.timestamp)}),n.jsx("td",{style:{padding:"8px 12px",color:"#64748b"},children:_.remarks||"—"})]},_.name||R))})]})})})]})}const zu={process:"processes-form",order:"orders-form",incident:"incidents-form",idea:"ideas-form"},Us={process:U.blue,order:U.purple,incident:U.red,idea:U.green,delegation:U.orange},Tu={process:"🔄",order:"📦",incident:"🚨",idea:"💡",delegation:"🤝"};function Fs(e,t){const r=e.replace("#",""),s=parseInt(r.substring(0,2),16),l=parseInt(r.substring(2,4),16),i=parseInt(r.substring(4,6),16);return`rgba(${s}, ${l}, ${i}, ${t})`}function L1({onNavigate:e,onRefresh:t}){const r=re(),[s,l]=w.useState([]),[i,a]=w.useState(!0),[c,d]=w.useState(""),[p,v]=w.useState(""),f=()=>$y().then(g=>{l(g),a(!1)});w.useEffect(()=>{f()},[]);const u=s.filter(g=>g.requires_action),m=s.filter(g=>!g.requires_action),j={};for(const g of s)j[g.type]=(j[g.type]||0)+1;const h=async(g,x)=>{d(g),v("");try{await Fy(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?U.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?U.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,k)=>{const C=y.type!=="delegation",P=Us[y.type]||U.gray;return n.jsxs("div",{className:"inbox-card",onClick:C?()=>e(zu[y.type],y.name):void 0,style:{borderTop:`3px solid ${P}`,cursor:C?"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:Fs(P,.14)},children:Tu[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:P,letterSpacing:.3},children:y.number}),y.requires_action&&n.jsx("span",{style:{fontSize:10,fontWeight:700,color:U.red,background:Fs(U.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:U.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:U.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:U.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:_=>{_.stopPropagation(),e(zu[y.type],y.name)},style:{marginTop:14,width:"100%",padding:"8px 0",borderRadius:9,border:"none",background:y.requires_action?P:Fs(P,.12),color:y.requires_action?"white":P,fontWeight:700,fontSize:13,cursor:"pointer"},children:y.requires_action?"Act Now →":r.view})]},k)})})]})}return n.jsxs("div",{style:{maxWidth:1040,margin:"0 auto"},children:[!i&&s.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:Fs(Us[g]||U.gray,.1),border:`1px solid ${Fs(Us[g]||U.gray,.25)}`},children:[n.jsx("span",{style:{fontSize:13},children:Tu[g]}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:Us[g]||U.gray,textTransform:"capitalize"},children:g}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:Us[g]||U.gray,opacity:.7},children:x})]},g))}),i&&n.jsx("p",{style:{color:"#888"},children:r.loading}),!i&&s.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:r.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 O1=[{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"]}],Ld={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 W1(e,t){const r=e.map(l=>Ld[l]||l).join(","),s=t.map(l=>e.map(i=>`"${l[i]??""}"`).join(",")).join(`
|
||
`);return r+`
|
||
`+s}function N1(e,t){const r=new Blob([e],{type:"text/csv"}),s=URL.createObjectURL(r),l=document.createElement("a");l.href=s,l.download=t,l.click(),URL.revokeObjectURL(s)}const Iu=e=>String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");function B1(e,t,r){const s=e.map(p=>`<th style="background:#4f46e5;color:#fff;padding:6px 10px;text-align:left">${Iu(Ld[p]||p)}</th>`).join(""),l=t.map(p=>`<tr>${e.map(v=>`<td style="padding:4px 10px;border-bottom:1px solid #ddd">${Iu(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>${s}</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=r,d.click(),URL.revokeObjectURL(c)}const nh="report-print-area",Ua="report-print-portal";function $1(){const e=document.getElementById(nh);if(!e)return;const t=document.createElement("div");t.id=Ua,t.innerHTML=e.innerHTML,document.body.appendChild(t);const r=document.createElement("style");r.id="report-print-style",r.textContent=`
|
||
#${Ua} { display: none; }
|
||
@media print {
|
||
#root { display: none !important; }
|
||
#${Ua} { display: block !important; }
|
||
}
|
||
`,document.head.appendChild(r);const s=()=>{t.remove(),r.remove(),window.removeEventListener("afterprint",s)};window.addEventListener("afterprint",s),window.print()}const Eu={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",minWidth:180},Fa={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white"};function U1({organizations:e,userRole:t}){const r=re(),s=O1.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,k]=w.useState(""),C=s.find(R=>R.id===l);async function P(){if(l){o(!0),k(""),g([]),h([]);try{const R={};a&&(R.organization=a),d&&(R.from_date=d),v&&(R.to_date=v),(C==null?void 0:C.extraFilter)==="year"&&u&&(R.year=u);const N=await By(l,R);h(N.columns||[]),g(N.rows||[])}catch(R){k(R.message||"Error running report")}finally{o(!1)}}}const _=(C==null?void 0:C.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:s.map(R=>n.jsxs("div",{onClick:()=>i(R.id),style:{background:l===R.id?"#ebf5fb":"white",border:l===R.id?`2px solid ${U.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:Eu,value:l,onChange:R=>i(R.target.value),children:[n.jsx("option",{value:"",children:"-- Select Report --"}),s.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:Eu,value:a,onChange:R=>c(R.target.value),children:[n.jsx("option",{value:"",children:r.filter.allOrgs}),e.map(R=>n.jsx("option",{value:R.name,children:R.organization_name||R.name},R.name))]})]}),(C==null?void 0:C.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:{...Fa,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(je,{value:d,onChange:p,style:Fa})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"TO"}),n.jsx(je,{value:v,onChange:f,style:Fa})]})]}),n.jsx("button",{onClick:P,disabled:!l||x,style:{padding:"9px 20px",borderRadius:8,border:"none",background:U.accent,color:"white",fontWeight:700,fontSize:13,cursor:l?"pointer":"not-allowed",opacity:l?1:.5},children:x?r.loading:r.reports.generate}),S.length>0&&n.jsx("button",{onClick:()=>N1(W1(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:()=>B1(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:$1,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:nh,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:_}),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:Ld[R]||R.replace(/_/g," ").toUpperCase()},R))})}),n.jsx("tbody",{children:S.map((R,N)=>n.jsx("tr",{style:{borderTop:"1px solid #f0f0f0",background:N%2===0?"white":"#fafafa"},children:j.map(V=>n.jsx("td",{style:{padding:"10px 14px",color:"#333"},children:R[V]!=null?String(R[V]):"—"},V))},N))})]})]}),!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."}),s.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 Tl=()=>new Date().toISOString().split("T")[0],Od=()=>new Date(Date.now()+30*24*60*60*1e3).toISOString().split("T")[0],F1=()=>new Date().toTimeString().slice(0,5),hn=()=>({name:"",number:"",title:"",organization:"",type:"",incident_class:"",incident_field:"",date:Tl(),time:F1(),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:""}),en=()=>({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:Tl(),priority:"",economy_class:"",product_relation:0,repeated:0,entity_scope:"",solution:"",cost:0,auditor_comment:"",sb_order:""}),tn=()=>({name:"",number:"",title:"",organization:"",type:"Buy L",management:"",department:"",section_field:"",branch:"",starting_date:Tl(),ending_date:Od(),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:""}),Zl=()=>({name:"",title:"",date_start:Tl(),date_end:Od(),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:""}),Ur=()=>({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}),ir=()=>({name:"",organization:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ar=()=>({name:"",custom_organization:"",department_name:"",custom_management:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),or=()=>({name:"",organization:"",branch:"",management:"",department:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),Fr=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Mr=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Hr=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Gr=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Kr=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Qr=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Yr=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Xr=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ei=()=>({name:"",first_name:"",full_name:"",email:"",enabled:1,creation:"",username:"",mobile_no:"",custom_organization:"",custom_management:"",custom_department:"",custom_branch:"",custom_number:"",custom_category:""}),dr=()=>({name:"",name1:"",organization:"",frequency:"Monthly",status:"Active",start_date:Tl(),end_date:Od(),update_window_days:2}),cr=()=>({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}),Ms=()=>({name:"",number:"",auditor:"",manager:"",organization:"",create_processes:0,update_process_status:0,status:"Pending",requested_on:"",remarks:""}),M1=new Set(["incidents","incidents-form","ideas","ideas-form"]),H1=new Set(["orders","orders-form","incidents","incidents-form","ideas","ideas-form"]),G1=new Set(Gf.flatMap(({id:e})=>[e,`${e}-form`])),K1=new Set(["Admin","Owner","Auditor","Manager"]),Q1=new Set(["Admin","Owner","Auditor","Manager"]),Y1=new Set(["Admin","Auditor","Manager"]);function X1({user:e,onLogout:t,darkMode:r,onToggleDark:s}){const l=re(),i=e.role,a=K1.has(i),c=Q1.has(i),d=Y1.has(i),p=b=>b==="users"||b==="users-form"?i==="Admin":i==="Admin"||i==="Auditor"?!0:i==="Owner"||i==="XAuditor"?!1:i==="Manager"?!!(H1.has(b)||(b==="processes"||b==="processes-form")&&Nd.includes("create_processes")):M1.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":G1.has(b)?i==="Admin"||i==="Auditor":!0,[m,j]=w.useState(()=>{const b=Zy(xu());return b&&u(b)?b:f});w.useEffect(()=>{const b=e0(m);window.location.hash!==b&&window.history.pushState(null,"",b)},[m]),w.useEffect(()=>{const b=()=>{const M=xu();j(M&&u(M)?M: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,M)=>{o(M),j(b)},[k,C]=w.useState(0),[P,_]=w.useState([]),[R,N]=w.useState([]),[V,de]=w.useState([]),[D,z]=w.useState([]),[I,Q]=w.useState([]),[G,A]=w.useState([]),[H,Y]=w.useState([]),[ee,Z]=w.useState([]),[Ce,Be]=w.useState([]),[Le,he]=w.useState([]),[Xe,K]=w.useState([]),[ne,ht]=w.useState([]),[se,st]=w.useState([]),[vt,Ge]=w.useState([]),[B,ze]=w.useState([]),[qe,$]=w.useState([]),[me,L]=w.useState([]),[le,X]=w.useState([]),[zr,aa]=w.useState([]),[_n,Il]=w.useState({}),[an,W]=w.useState([]),[ot,Tr]=w.useState([]),[on,rh]=w.useState([]),[Wd,sh]=w.useState([]),[Nd,lh]=w.useState([]),[Bd,ih]=w.useState({}),[oa,ah]=w.useState([]),El=()=>({name:"",company_name:"",acronym:"",code:"",status:"Active",owner_user:"",notes:""}),[$d,Ir]=w.useState(El()),[Se,pe]=w.useState(!0),[$e,oe]=w.useState("idle"),[Ue,te]=w.useState(!1),[Ud,Fd]=w.useState(!1),[Pl,Md]=w.useState(null),[oh,dh]=w.useState(()=>localStorage.getItem("sb_sidebar")==="1"),ch=()=>dh(b=>{const M=!b;return localStorage.setItem("sb_sidebar",M?"1":"0"),M}),[uh,da]=w.useState(!1);w.useEffect(()=>{da(!1)},[m]);const[dn,cn]=w.useState(hn()),[un,qt]=w.useState(en()),[Vn,Jt]=w.useState(tn()),[Zn,Vt]=w.useState(Zl()),[Hd,Er]=w.useState(Ur()),[Gd,er]=w.useState(ir()),[Kd,tr]=w.useState(ar()),[Qd,nr]=w.useState(or()),[Yd,Pr]=w.useState(Fr()),[Xd,Ar]=w.useState(Mr()),[qd,Rr]=w.useState(Hr()),[Jd,Dr]=w.useState(Gr()),[Vd,Lr]=w.useState(Kr()),[Zd,Or]=w.useState(Qr()),[ec,Wr]=w.useState(Yr()),[tc,Nr]=w.useState(Xr()),[Ts,Al]=w.useState(ei()),[nc,rr]=w.useState(dr()),[rc,sr]=w.useState(cr()),[Br,Is]=w.useState(Ms()),_t=async()=>{pe(!0);try{const[b,M,Ve,$t,zn,Pe,fa,og,dg,cg,ug,pg,fg,hg,gg,xg,mg,yg,vg,jg,bg,Sg,wg,kg,_g,Cg,zg]=await Promise.all([Ie(O.incidents),Ie(O.organizations),Ie(O.ideas),Ie(O.orders),Ie(O.processes),by(),Ie(O.managements),Ie(O.departments),Ie(O.branches),Ie(O.incidentTypes),Ie(O.incidentClass),Ie(O.incidentField),Ie(O.ideaTypes),Ie(O.orderTypes),Ie(O.processTypes),Ie(O.incidentStatuses),Ie(O.ideaStatuses),Ie(O.orderStatuses),Ie(O.processStatuses),_y(),Cy(),Ie(O.cycles),Ie(O.kpiInput),Hy(),Ky(),Qy(),Yy()]);_(b||[]),N(M||[]),de(Ve||[]),z($t||[]),Q(zn||[]),W(Pe||[]),A(fa||[]),Y(og||[]),Z(dg||[]),Be(cg||[]),he(ug||[]),K(pg||[]),ht(fg||[]),st(hg||[]),Ge(gg||[]),ze(xg||[]),$(mg||[]),L(yg||[]),X(vg||[]),aa(jg||[]),Il(bg||{}),Tr(Sg||[]),rh(wg||[]),sh(kg||[]),lh(_g||[]),ih(Cg||{}),ah(zg||[])}catch(b){console.error("Error loading data:",b)}pe(!1)},sc=async()=>{try{const b=await fetch("/api/method/sidrah_business.api.get_notification_count",{credentials:"include",headers:{Accept:"application/json"}});if(b.ok){const M=await b.json();C(Number(M.message)||0)}}catch{}};w.useEffect(()=>{_t(),sc();const b=setInterval(sc,6e4);return()=>clearInterval(b)},[e.name]);const[pn,Cn]=w.useState({isOpen:!1,doctype:"",name:"",title:"",isDeleting:!1}),Te=(b,M,Ve)=>{Cn({isOpen:!0,doctype:b,name:M,title:Ve||M,isDeleting:!1})},ph=async b=>{Cn(M=>({...M,isDeleting:!0}));try{await Wo(pn.doctype,pn.name,b,!1),Cn(M=>({...M,isOpen:!1,isDeleting:!1})),await _t()}catch(M){console.error("Delete error:",M),alert((M==null?void 0:M.message)||"Delete failed. Please try again."),Cn(Ve=>({...Ve,isDeleting:!1}))}},fh=async b=>{Cn(M=>({...M,isDeleting:!0}));try{await Wo(pn.doctype,pn.name,b,!0),Cn(M=>({...M,isOpen:!1,isDeleting:!1})),await _t()}catch(M){console.error("Permanent delete error:",M),alert((M==null?void 0:M.message)||"Permanent delete failed. Please try again."),Cn(Ve=>({...Ve,isDeleting:!1}))}},Es=async(b,M)=>{if(window.confirm(l.rtl?"هل أنت متأكد من استعادة هذا السجل؟":"Are you sure you want to restore this record?")){pe(!0);try{await jy(b,M),alert(l.restoredOk||"Record restored successfully!"),await _t()}catch(Ve){console.error("Restore error:",Ve),alert((Ve==null?void 0:Ve.message)||"Restore failed. Please try again.")}pe(!1)}},hh=async b=>{try{await Ey(b),await _t()}catch(M){console.error("Disable user error:",M)}},gh=async b=>{te(!0),pe(!0);try{const M=await Ct(O.incidents,b.name);cn({...hn(),...M})}catch{cn({...hn(),...b})}j("incidents-form"),pe(!1)},xh=async b=>{te(!0),pe(!0);try{const M=await Ct(O.ideas,b.name);qt({...en(),...M})}catch{qt({...en(),...b})}j("ideas-form"),pe(!1)},mh=async b=>{te(!0),pe(!0);try{const M=await Ct(O.orders,b.name);Jt({...tn(),...M})}catch{Jt({...tn(),...b})}j("orders-form"),pe(!1)},yh=async b=>{te(!0),pe(!0);try{const M=await Ys(b.name);Vt({...M,progress_indicators:M.progress_indicators||[],cycle_logs:M.cycle_logs||[]}),j("processes-form")}catch{Vt({...b,progress_indicators:b.progress_indicators||[]}),j("processes-form")}pe(!1)},vh=b=>ve(O.organizations,b,Er,Ur(),"organizations-form",!0),jh=b=>{te(!0),Ir(b),j("group-companies-form")},bh=b=>{te(!1),Ir(b),j("group-companies-form")},Sh=async b=>{te(!0),pe(!0);try{const M=await Ct(O.managements,b.name);er({...ir(),...M})}catch{er({...ir(),...b})}j("managements-form"),pe(!1)},wh=async b=>{te(!0),pe(!0);try{const M=await Ct(O.departments,b.name);tr({...ar(),...M})}catch{tr({...ar(),...b})}j("departments-form"),pe(!1)},kh=async b=>{te(!0),pe(!0);try{const M=await Ct(O.branches,b.name);nr({...or(),...M})}catch{nr({...or(),...b})}j("branches-form"),pe(!1)},_h=async b=>{te(!0),pe(!0);try{const M=await Ct(O.cycles,b.name);rr({...dr(),...M})}catch{rr({...dr(),...b})}j("cycles-form"),pe(!1)},Ch=async b=>{te(!0),pe(!0);try{const M=await Ct(O.kpiInput,b.name);sr({...cr(),...M})}catch{sr({...cr(),...b})}j("kpi-input-form"),pe(!1)},Je=async(b,M,Ve,$t,zn)=>{oe("loading");try{if(M.name)await Bi(b,M.name,M),oe("success"),_t(),setTimeout(()=>{oe("idle"),j($t)},1500);else if(zn){const Pe=await $a(b,M);zn((Pe==null?void 0:Pe.data)??Pe),oe("success"),_t(),setTimeout(()=>oe("idle"),1500)}else await $a(b,M),Ve(),oe("success"),_t(),setTimeout(()=>{oe("idle"),j($t)},1500)}catch(Pe){console.error("Submit error:",Pe),oe(Pe instanceof Error?Pe.message:"Error saving. Please try again.")}},Oe=async()=>{await wy(),t()},ve=async(b,M,Ve,$t,zn,Pe)=>{te(Pe),pe(!0);try{const fa=await Ct(b,M.name);Ve({...$t,...fa})}catch{Ve({...$t,...M})}j(zn),pe(!1)},zh=b=>ve(O.incidents,b,cn,hn(),"incidents-form",!1),Th=b=>ve(O.ideas,b,qt,en(),"ideas-form",!1),Ih=b=>ve(O.orders,b,Jt,tn(),"orders-form",!1),Eh=b=>{te(!1),pe(!0),Ys(b.name).then(M=>{Vt({...M,progress_indicators:M.progress_indicators||[],cycle_logs:M.cycle_logs||[]})}).catch(()=>{Vt({...b,progress_indicators:b.progress_indicators||[]})}).finally(()=>{j("processes-form"),pe(!1)})},Ph=b=>ve(O.organizations,b,Er,Ur(),"organizations-form",!1),Ah=b=>ve(O.managements,b,er,ir(),"managements-form",!1),Rh=b=>ve(O.departments,b,tr,ar(),"departments-form",!1),Dh=b=>ve(O.branches,b,nr,or(),"branches-form",!1),Lh=b=>ve(O.cycles,b,rr,dr(),"cycles-form",!1),Oh=b=>ve(O.kpiInput,b,sr,cr(),"kpi-input-form",!1),Wh=async b=>{te(!0),pe(!0);try{const M=await Gy(b.name);Is({...Ms(),...M})}catch{Is({...Ms(),...b})}j("delegations-form"),pe(!1)},Nh=async()=>{oe("loading");try{const b=[];Br.create_processes&&b.push("create_processes"),Br.update_process_status&&b.push("update_process_status"),await Uy(Br.manager,b,Br.organization,Br.remarks),Is(Ms()),oe("success"),_t(),setTimeout(()=>{oe("idle"),j("delegations")},1500)}catch(b){console.error("Delegation submit error:",b),oe(b instanceof Error?b.message:"Error saving. Please try again.")}},Bh=async b=>{if(window.confirm(l.rtl?"هل أنت متأكد من إلغاء هذا التفويض؟":"Are you sure you want to revoke this delegation?")){pe(!0);try{await My(b),await _t()}catch(M){console.error("Revoke delegation error:",M),alert(M instanceof Error?M.message:"Revoke failed. Please try again.")}pe(!1)}},$h=b=>ve(O.incidentTypes,b,Pr,Fr(),"incident-types-form",!0),Uh=b=>ve(O.incidentTypes,b,Pr,Fr(),"incident-types-form",!1),Fh=b=>ve(O.ideaTypes,b,Ar,Mr(),"idea-types-form",!0),Mh=b=>ve(O.ideaTypes,b,Ar,Mr(),"idea-types-form",!1),Hh=b=>ve(O.orderTypes,b,Rr,Hr(),"order-types-form",!0),Gh=b=>ve(O.orderTypes,b,Rr,Hr(),"order-types-form",!1),Kh=b=>ve(O.processTypes,b,Dr,Gr(),"process-types-form",!0),Qh=b=>ve(O.processTypes,b,Dr,Gr(),"process-types-form",!1),Yh=b=>ve(O.incidentStatuses,b,Lr,Kr(),"incident-statuses-form",!0),Xh=b=>ve(O.incidentStatuses,b,Lr,Kr(),"incident-statuses-form",!1),qh=b=>ve(O.ideaStatuses,b,Or,Qr(),"idea-statuses-form",!0),Jh=b=>ve(O.ideaStatuses,b,Or,Qr(),"idea-statuses-form",!1),Vh=b=>ve(O.orderStatuses,b,Wr,Yr(),"order-statuses-form",!0),Zh=b=>ve(O.orderStatuses,b,Wr,Yr(),"order-statuses-form",!1),eg=b=>ve(O.processStatuses,b,Nr,Xr(),"process-statuses-form",!0),tg=b=>ve(O.processStatuses,b,Nr,Xr(),"process-statuses-form",!1),ng=async b=>{Md(b),j("profile")},rg=b=>{te(!1),Fd(!1),Al({...ei(),...b}),j("users-form")},sg=async()=>{oe("loading");try{if(!Ts.name){const M=await $a("User",{...Ts,send_welcome_email:0,user_type:"System User"});Al({...ei(),...Ts,...(M==null?void 0:M.data)??M}),te(!0),oe("success"),_t(),setTimeout(()=>oe("idle"),1500)}else{const{name:M,email:Ve,creation:$t,full_name:zn,...Pe}=Ts;await Bi("User",M,Pe),oe("success"),_t(),setTimeout(()=>{oe("idle"),j("users")},1500)}}catch(b){console.error("User submit error:",b),oe(b instanceof Error?b.message:"Error saving. Please try again.")}},We=()=>{const b=zr.find(M=>M.name===e.name||M.username===e.name);Md(b||{name:e.name,full_name:e.full_name,email:e.name,enabled:1}),j("profile")},ca=(b,M)=>{if(M){const $t={"processes-form":O.processes,"orders-form":O.orders,"incidents-form":O.incidents,"ideas-form":O.ideas}[b];if($t){te(!0),pe(!0),(b==="processes-form"?Ys(M).then(Pe=>({...Pe,progress_indicators:Pe.progress_indicators||[],cycle_logs:Pe.cycle_logs||[]})):Ct($t,M)).then(Pe=>{b==="processes-form"?Vt(Pe):b==="orders-form"?Jt({...tn(),...Pe}):b==="incidents-form"?cn({...hn(),...Pe}):b==="ideas-form"&&qt({...en(),...Pe}),j(b),pe(!1)}).catch(()=>{j(b),pe(!1)});return}}j(b)};if(m==="incidents-form")return n.jsx(m0,{incForm:dn,setIncForm:cn,organizations:R,managements:G,departments:H,branches:ee,incidentTypes:Ce,incidentClasses:Le,incidentFields:Xe,incidentStatuses:B,users:an,userRoleMap:_n,formStatus:$e,viewMode:Ue||!p("incidents-form")||v(dn.workflow_state),canModify:p("incidents-form"),onEdit:p("incidents-form")&&!v(dn.workflow_state)&&!On("incident",dn.workflow_state)?()=>te(!1):void 0,onDelete:p("incidents-form")?b=>Te(O.incidents,b,dn.title||dn.number):void 0,onRestore:i==="Admin"?b=>Es(O.incidents,b):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,userRole:i,onSubmit:()=>Je(O.incidents,dn,()=>cn(hn()),"incidents",b=>cn({...hn(),...b})),onBack:()=>{j("incidents"),oe("idle")},onNavigate:j,onLogout:Oe,user:e,onRefresh:async()=>{if(dn.name){const b=await Ct(O.incidents,dn.name).catch(()=>null);b&&cn({...hn(),...b})}Ie(O.incidents).then(b=>_(b||[])).catch(()=>{})}});if(m==="ideas-form")return n.jsx(b0,{ideaForm:un,setIdeaForm:qt,organizations:R,managements:G,departments:H,branches:ee,ideaTypes:ne,ideaStatuses:qe,users:an,userRoleMap:_n,formStatus:$e,viewMode:Ue||!p("ideas-form")||v(un.workflow_state),canModify:p("ideas-form"),onEdit:p("ideas-form")&&!v(un.workflow_state)&&!On("idea",un.workflow_state)?()=>te(!1):void 0,onDelete:p("ideas-form")?b=>Te(O.ideas,b,un.title||un.number):void 0,onRestore:i==="Admin"?b=>Es(O.ideas,b):void 0,onNavigateToOrder:b=>ve(O.orders,{name:b},Jt,tn(),"orders-form",!0),darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,userRole:i,onSubmit:()=>Je(O.ideas,un,()=>qt(en()),"ideas",b=>qt({...en(),...b})),onBack:()=>{j("ideas"),oe("idle")},onNavigate:j,onLogout:Oe,user:e,onRefresh:async()=>{if(un.name){const b=await Ct(O.ideas,un.name).catch(()=>null);b&&qt({...en(),...b})}Ie(O.ideas).then(b=>de(b||[])).catch(()=>{})}});if(m==="orders-form")return n.jsx(C0,{orderForm:Vn,setOrderForm:Jt,organizations:R,managements:G,departments:H,branches:ee,orderTypes:se,orderStatuses:me,cycles:ot,users:an,userRoleMap:_n,formStatus:$e,viewMode:Ue||!p("orders-form"),canModify:p("orders-form"),onEdit:p("orders-form")&&!On("order",Vn.workflow_state)?()=>te(!1):void 0,onDelete:p("orders-form")?b=>Te(O.orders,b,Vn.title||Vn.number):void 0,onRestore:i==="Admin"?b=>Es(O.orders,b):void 0,onNavigateToIdea:b=>ve(O.ideas,{name:b},qt,en(),"ideas-form",!0),darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,currentUser:e.name,userRole:i,onSubmit:()=>Je(O.orders,Vn,()=>Jt(tn()),"orders",b=>Jt({...tn(),...b})),onBack:()=>{j("orders"),oe("idle")},onNavigate:j,onLogout:Oe,user:e,onRefresh:async()=>{if(Vn.name){const b=await Ct(O.orders,Vn.name).catch(()=>null);b&&Jt({...tn(),...b})}Ie(O.orders).then(b=>z(b||[])).catch(()=>{})}});if(m==="processes-form")return n.jsx(P0,{processForm:Zn,setProcessForm:Vt,organizations:R,managements:G,departments:H,branches:ee,processTypes:vt,processStatuses:le,cycles:ot,users:an,userRoleMap:_n,formStatus:$e,viewMode:Ue||!p("processes-form"),canModify:p("processes-form"),onEdit:p("processes-form")&&!On("process",Zn.workflow_state)?()=>te(!1):void 0,onDelete:p("processes-form")?b=>Te(O.processes,b,Zn.title||Zn.number):void 0,onRestore:i==="Admin"?b=>Es(O.processes,b):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,userRole:e.role,delegatedFunctions:Nd,delegatedOrgs:Bd.create_processes,onRefreshProcess:async()=>{if(Zn.name)try{const b=await Ys(Zn.name);Vt({...b,progress_indicators:b.progress_indicators||[],cycle_logs:b.cycle_logs||[]})}catch{}Ie(O.processes).then(b=>Q(b||[])).catch(()=>{})},onSubmit:()=>Je(O.processes,Zn,()=>Vt(Zl()),"processes",b=>Vt({...Zl(),...b,progress_indicators:b.progress_indicators||[],cycle_logs:b.cycle_logs||[]})),onBack:()=>{j("processes"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});if(m==="organizations-form")return n.jsx(W0,{orgForm:Hd,setOrgForm:Er,groupCompanies:oa,formStatus:$e,viewMode:Ue||!p("organizations-form"),onEdit:p("organizations-form")?()=>te(!1):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,onSubmit:()=>Je(O.organizations,Hd,()=>Er(Ur()),"organizations",b=>{Er({...Ur(),...b}),te(!0)}),onBack:()=>{j("organizations"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});if(m==="managements-form")return n.jsx(F0,{form:Gd,setForm:er,organizations:R,formStatus:$e,viewMode:Ue||!p("managements-form"),onEdit:p("managements-form")?()=>te(!1):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,onSubmit:()=>Je(O.managements,Gd,()=>er(ir()),"managements",b=>{er({...ir(),...b}),te(!0)}),onBack:()=>{j("managements"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});if(m==="departments-form")return n.jsx(G0,{form:Kd,setForm:tr,organizations:R,managements:G,formStatus:$e,viewMode:Ue||!p("departments-form"),onEdit:p("departments-form")?()=>te(!1):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,onSubmit:()=>Je(O.departments,Kd,()=>tr(ar()),"departments",b=>{tr({...ar(),...b}),te(!0)}),onBack:()=>{j("departments"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});if(m==="branches-form")return n.jsx(Y0,{form:Qd,setForm:nr,organizations:R,managements:G,departments:H,formStatus:$e,viewMode:Ue||!p("branches-form"),onEdit:p("branches-form")?()=>te(!1):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,onSubmit:()=>Je(O.branches,Qd,()=>nr(or()),"branches",b=>{nr({...or(),...b}),te(!0)}),onBack:()=>{j("branches"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});if(m==="cycles-form")return n.jsx(C1,{form:nc,setForm:rr,organizations:R,formStatus:$e,viewMode:Ue||!p("cycles-form"),onEdit:p("cycles-form")?()=>te(!1):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,onSubmit:()=>Je(O.cycles,nc,()=>rr(dr()),"cycles",b=>{rr({...dr(),...b}),te(!0)}),onBack:()=>{j("cycles"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});if(m==="kpi-input-form")return n.jsx(T1,{form:rc,setForm:sr,organizations:R,formStatus:$e,viewMode:Ue||!p("kpi-input-form"),onEdit:p("kpi-input-form")?()=>te(!1):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,onSubmit:()=>Je(O.kpiInput,rc,()=>sr(cr()),"kpi-input",b=>{sr({...cr(),...b}),te(!0)}),onBack:()=>{j("kpi-input"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});if(m==="incident-types-form")return n.jsx(J0,{form:Yd,setForm:Pr,formStatus:$e,viewMode:Ue||!p("incident-types-form"),onEdit:p("incident-types-form")?()=>te(!1):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,onSubmit:()=>Je(O.incidentTypes,Yd,()=>Pr(Fr()),"incident-types",b=>{Pr({...Fr(),...b}),te(!0)}),onBack:()=>{j("incident-types"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});if(m==="idea-types-form")return n.jsx(e1,{form:Xd,setForm:Ar,formStatus:$e,viewMode:Ue||!p("idea-types-form"),onEdit:p("idea-types-form")?()=>te(!1):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,onSubmit:()=>Je(O.ideaTypes,Xd,()=>Ar(Mr()),"idea-types",b=>{Ar({...Mr(),...b}),te(!0)}),onBack:()=>{j("idea-types"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});if(m==="order-types-form")return n.jsx(r1,{form:qd,setForm:Rr,formStatus:$e,viewMode:Ue||!p("order-types-form"),onEdit:p("order-types-form")?()=>te(!1):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,onSubmit:()=>Je(O.orderTypes,qd,()=>Rr(Hr()),"order-types",b=>{Rr({...Hr(),...b}),te(!0)}),onBack:()=>{j("order-types"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});if(m==="process-types-form")return n.jsx(i1,{form:Jd,setForm:Dr,formStatus:$e,viewMode:Ue||!p("process-types-form"),onEdit:p("process-types-form")?()=>te(!1):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,onSubmit:()=>Je(O.processTypes,Jd,()=>Dr(Gr()),"process-types",b=>{Dr({...Gr(),...b}),te(!0)}),onBack:()=>{j("process-types"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});if(m==="incident-statuses-form")return n.jsx(d1,{form:Vd,setForm:Lr,formStatus:$e,viewMode:Ue||!p("incident-statuses-form"),onEdit:p("incident-statuses-form")?()=>te(!1):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,onSubmit:()=>Je(O.incidentStatuses,Vd,()=>Lr(Kr()),"incident-statuses",b=>{Lr({...Kr(),...b}),te(!0)}),onBack:()=>{j("incident-statuses"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});if(m==="idea-statuses-form")return n.jsx(p1,{form:Zd,setForm:Or,formStatus:$e,viewMode:Ue||!p("idea-statuses-form"),onEdit:p("idea-statuses-form")?()=>te(!1):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,onSubmit:()=>Je(O.ideaStatuses,Zd,()=>Or(Qr()),"idea-statuses",b=>{Or({...Qr(),...b}),te(!0)}),onBack:()=>{j("idea-statuses"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});if(m==="order-statuses-form")return n.jsx(g1,{form:ec,setForm:Wr,formStatus:$e,viewMode:Ue||!p("order-statuses-form"),onEdit:p("order-statuses-form")?()=>te(!1):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,onSubmit:()=>Je(O.orderStatuses,ec,()=>Wr(Yr()),"order-statuses",b=>{Wr({...Yr(),...b}),te(!0)}),onBack:()=>{j("order-statuses"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});if(m==="process-statuses-form")return n.jsx(y1,{form:tc,setForm:Nr,formStatus:$e,viewMode:Ue||!p("process-statuses-form"),onEdit:p("process-statuses-form")?()=>te(!1):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,onSubmit:()=>Je(O.processStatuses,tc,()=>Nr(Xr()),"process-statuses",b=>{Nr({...Xr(),...b}),te(!0)}),onBack:()=>{j("process-statuses"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});if(m==="users-form")return n.jsx(S1,{form:Ts,setForm:Al,groupCompanies:oa,organizations:R,managements:G,departments:H,branches:ee,formStatus:$e,viewMode:Ue||!p("users-form"),onEdit:p("users-form")?()=>te(!1):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,isSelfProfile:Ud,onSubmit:sg,onBack:()=>{j(Ud?a?"dashboard":"inbox":"users"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});if(m==="delegations-form")return n.jsx(D1,{form:Br,setForm:Is,organizations:R,users:an,userRoleMap:_n,formStatus:$e,viewMode:Ue||!p("delegations-form"),onEdit:p("delegations-form")?()=>te(!1):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,onSubmit:Nh,onBack:()=>{j("delegations"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});if(m==="group-companies-form")return n.jsx(B0,{form:$d,setForm:Ir,users:an,formStatus:$e,viewMode:Ue||!p("group-companies-form"),onEdit:p("group-companies-form")?()=>te(!1):void 0,onRestore:i==="Admin"?b=>Es(O.groupCompanies,b):void 0,darkMode:r,notifCount:k,onToggleDark:s,onCountChange:C,onViewProfile:We,onSubmit:()=>Je(O.groupCompanies,$d,()=>Ir(El()),"group-companies",b=>{Ir({...El(),...b}),te(!0)}),onBack:()=>{j("group-companies"),oe("idle")},onNavigate:j,onLogout:Oe,user:e});const ua={...l.pages,"group-companies":"Group Companies","group-companies-form":"Group Company Form"},lg={"group-companies":{color:U.purple,formPage:"group-companies-form",reset:()=>Ir(El())},incidents:{color:U.accent,formPage:"incidents-form",reset:()=>cn({...hn(),organization:h||S})},ideas:{color:U.teal,formPage:"ideas-form",reset:()=>qt({...en(),organization:h||S})},orders:{color:U.purple,formPage:"orders-form",reset:()=>Jt({...tn(),organization:h||S})},processes:{color:U.blue,formPage:"processes-form",reset:()=>{const b=Bd.create_processes,M=h||(i==="Manager"&&b&&b.length===1?b[0]:S);Vt({...Zl(),organization:M})}},organizations:{color:U.accent,formPage:"organizations-form",reset:()=>Er(Ur())},managements:{color:U.blue,formPage:"managements-form",reset:()=>er({...ir(),organization:h||S})},departments:{color:U.teal,formPage:"departments-form",reset:()=>tr({...ar(),custom_organization:h||S})},branches:{color:U.purple,formPage:"branches-form",reset:()=>nr({...or(),organization:h||S})},cycles:{color:U.teal,formPage:"cycles-form",reset:()=>rr({...dr(),organization:h||S})},"kpi-input":{color:U.blue,formPage:"kpi-input-form",reset:()=>sr({...cr(),organization:h||S})},"incident-types":{color:U.red,formPage:"incident-types-form",reset:()=>Pr(Fr())},"idea-types":{color:U.orange,formPage:"idea-types-form",reset:()=>Ar(Mr())},"order-types":{color:U.green,formPage:"order-types-form",reset:()=>Rr(Hr())},"process-types":{color:U.accent,formPage:"process-types-form",reset:()=>Dr(Gr())},"incident-statuses":{color:U.red,formPage:"incident-statuses-form",reset:()=>Lr(Kr())},"idea-statuses":{color:U.teal,formPage:"idea-statuses-form",reset:()=>Or(Qr())},"order-statuses":{color:U.purple,formPage:"order-statuses-form",reset:()=>Wr(Yr())},"process-statuses":{color:U.blue,formPage:"process-statuses-form",reset:()=>Nr(Xr())},users:{color:U.blue,formPage:"users-form",reset:()=>{Al(ei()),Fd(!1)}},delegations:{color:U.purple,formPage:"delegations-form",reset:()=>Is(Ms())}},ig={"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"},ag={incidents:P,ideas:V,orders:D,processes:I,organizations:R,managements:G,departments:H,branches:ee,cycles:ot,"kpi-input":on,"incident-types":Ce,"idea-types":ne,"order-types":se,"process-types":vt,"incident-statuses":B,"idea-statuses":qe,"order-statuses":me,"process-statuses":le,users:zr,delegations:Wd},lr=ry[m],Ps=ag[m],J=p(m),pa=J?lg[m]:null;return n.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:r?"#0f172a":U.bg},children:[n.jsx(qf,{collapsed:oh,onToggleCollapsed:ch,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:r?"#1e293b":"#ffffff",padding:"6px 20px",borderBottom:`1px solid ${r?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"flex-end",alignItems:"center",gap:6,flexShrink:0,boxShadow:r?"none":"0 1px 4px rgba(0,0,0,0.04)"},children:n.jsx(eh,{notifCount:k,darkMode:r,onCountChange:C,onToggleDark:s,onNavigate:ca,onViewProfile:We,onLogout:Oe,userName:e.full_name||e.name,userRole:i})}),m!=="profile"&&n.jsxs("div",{style:{background:r?"#1e293b":"white",padding:"12px 24px",borderBottom:`1px solid ${r?"#2d3748":"#e2e8f0"}`,display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:18,fontWeight:700,color:r?"#e2e8f0":"#0f172a"},children:ua[m]||m}),Ps&&n.jsxs("div",{style:{fontSize:12,color:"#64748b",marginTop:2,fontWeight:500},children:["Total: ",Ps.length," ",ua[m]?ua[m].toLowerCase():"records"]})]}),n.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[lr&&Ps&&n.jsx("button",{onClick:()=>da(!0),style:{background:"#16a34a",color:"white",border:"none",padding:"7px 16px",borderRadius:8,fontSize:13,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI",display:"flex",alignItems:"center",gap:6,boxShadow:"0 1px 2px rgba(0,0,0,0.06)"},children:"📊 Export"}),pa&&n.jsxs("button",{onClick:()=>{pa.reset(),te(!1),oe("idle"),j(pa.formPage)},style:{background:"#2563eb",color:"white",border:"none",padding:"7px 16px",borderRadius:8,fontSize:13,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI",display:"flex",alignItems:"center",gap:6,boxShadow:"0 1px 2px rgba(0,0,0,0.06)"},children:["+ ",ig[m]||l.new]})]})]}),lr&&Ps&&uh&&n.jsx(xy,{title:lr.label,rows:Ps,columns:lr.columns,defaultColumnKeys:lr.defaultColumns,orgField:lr.orgField,organizations:lr.orgField?R:void 0,filenameBase:m,onClose:()=>da(!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:[Se&&n.jsx("div",{style:{textAlign:"center",paddingTop:60,color:"#aaa",fontSize:15},children:l.loading}),!Se&&m==="dashboard"&&a&&n.jsx(a0,{incidents:P,ideas:V,orders:D,processes:I,organizations:R,incidentStatuses:B,ideaStatuses:qe,orderStatuses:me,processStatuses:le,selectedOrg:S,onOrgChange:g,onNavigate:ca,onNavigateStatus:y,userRole:i}),!Se&&m==="inbox"&&n.jsx(L1,{onNavigate:ca,onRefresh:_t}),!Se&&m==="reports"&&c&&n.jsx(U1,{organizations:R,userRole:i}),!Se&&m==="incidents"&&n.jsx(o0,{incidents:P,organizations:R,departments:H,branches:ee,incidentStatuses:B,initialOrg:S,initialStatus:x,onView:gh,onEdit:J?zh:void 0,onDelete:J?b=>Te(O.incidents,b):void 0,canModify:J}),!Se&&m==="ideas"&&n.jsx(y0,{ideas:V,organizations:R,departments:H,branches:ee,ideaStatuses:qe,initialOrg:S,initialStatus:x,onView:xh,onEdit:J?Th:void 0,onDelete:J?b=>Te(O.ideas,b):void 0,canModify:J}),!Se&&m==="orders"&&n.jsx(S0,{orders:D,organizations:R,departments:H,branches:ee,orderStatuses:me,initialOrg:S,initialStatus:x,onView:mh,onEdit:J?Ih:void 0,onDelete:J?b=>Te(O.orders,b):void 0,canModify:J}),!Se&&m==="processes"&&n.jsx(z0,{processes:I,organizations:R,departments:H,branches:ee,processStatuses:le,initialOrg:S,initialStatus:x,onView:yh,onEdit:J?Eh:void 0,onDelete:J?b=>Te(O.processes,b):void 0,canModify:J}),!Se&&m==="organizations"&&n.jsx(O0,{organizations:R,onView:vh,onEdit:J?Ph:void 0,onDelete:J?b=>Te(O.organizations,b):void 0,canModify:J}),!Se&&m==="group-companies"&&n.jsx(N0,{groupCompanies:oa,onView:jh,onEdit:J?bh:void 0,onDelete:J?b=>Te(O.groupCompanies,b):void 0,canModify:J}),!Se&&m==="managements"&&n.jsx(U0,{managements:G,onView:Sh,onEdit:J?Ah:void 0,onDelete:J?b=>Te(O.managements,b):void 0,canModify:J}),!Se&&m==="departments"&&n.jsx(H0,{departments:H,managements:G,onView:wh,onEdit:J?Rh:void 0,onDelete:J?b=>Te(O.departments,b):void 0,canModify:J}),!Se&&m==="branches"&&n.jsx(Q0,{branches:ee,managements:G,departments:H,onView:kh,onEdit:J?Dh:void 0,onDelete:J?b=>Te(O.branches,b):void 0,canModify:J}),!Se&&m==="cycles"&&n.jsx(w1,{cycles:ot,canModify:J,onView:_h,onEdit:J?Lh:void 0,onDelete:J?b=>Te(O.cycles,b):void 0}),!Se&&m==="kpi-input"&&n.jsx(z1,{kpiInputs:on,canModify:J,onView:Ch,onEdit:J?Oh:void 0,onDelete:J?b=>Te(O.kpiInput,b):void 0}),!Se&&m==="incident-types"&&n.jsx(q0,{incidentTypes:Ce,onView:$h,onEdit:J?Uh:void 0,onDelete:J?b=>Te(O.incidentTypes,b):void 0,canModify:J}),!Se&&m==="idea-types"&&n.jsx(Z0,{ideaTypes:ne,onView:Fh,onEdit:J?Mh:void 0,onDelete:J?b=>Te(O.ideaTypes,b):void 0,canModify:J}),!Se&&m==="order-types"&&n.jsx(n1,{orderTypes:se,onView:Hh,onEdit:J?Gh:void 0,onDelete:J?b=>Te(O.orderTypes,b):void 0,canModify:J}),!Se&&m==="process-types"&&n.jsx(l1,{processTypes:vt,onView:Kh,onEdit:J?Qh:void 0,onDelete:J?b=>Te(O.processTypes,b):void 0,canModify:J}),!Se&&m==="incident-statuses"&&n.jsx(o1,{incidentStatuses:B,onView:Yh,onEdit:J?Xh:void 0,onDelete:J?b=>Te(O.incidentStatuses,b):void 0,canModify:J}),!Se&&m==="idea-statuses"&&n.jsx(u1,{ideaStatuses:qe,onView:qh,onEdit:J?Jh:void 0,onDelete:J?b=>Te(O.ideaStatuses,b):void 0,canModify:J}),!Se&&m==="order-statuses"&&n.jsx(h1,{orderStatuses:me,onView:Vh,onEdit:J?Zh:void 0,onDelete:J?b=>Te(O.orderStatuses,b):void 0,canModify:J}),!Se&&m==="process-statuses"&&n.jsx(m1,{processStatuses:le,onView:eg,onEdit:J?tg:void 0,onDelete:J?b=>Te(O.processStatuses,b):void 0,canModify:J}),!Se&&m==="users"&&n.jsx(b1,{users:zr,roleMap:_n,onView:ng,onEdit:J?rg:void 0,onDelete:J?b=>Te("User",b):void 0,onDisable:J?hh:void 0,canModify:J}),!Se&&m==="delegations"&&d&&n.jsx(A1,{delegations:Wd,organizations:R,userRole:i,currentUser:e.name,onView:Wh,onRevoke:J?Bh:void 0}),m==="profile"&&(()=>{const b=!!Pl&&(Pl.name===e.name||Pl.email===e.name);return n.jsx(R0,{user:e,profileUser:Pl,sbUsers:zr,organizations:R,managements:G,departments:H,branches:ee,darkMode:r,canModify:J||b,onBack:()=>j(b?a?"dashboard":"inbox":"users"),onNavigate:j})})()]})]}),n.jsx(vy,{isOpen:pn.isOpen,doctype:pn.doctype,docname:pn.name,docTitle:pn.title,isAdmin:i==="Admin"||e.name==="Administrator",isDeleting:pn.isDeleting,onClose:()=>Cn(b=>({...b,isOpen:!1})),onConfirmSoftDelete:ph,onConfirmPermanentDelete:fh})]})}function q1(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 J1(){const[e,t]=w.useState(()=>{try{const c=localStorage.getItem("sidrah_user");return c?JSON.parse(c):null}catch{return null}}),[r,s]=w.useState(()=>localStorage.getItem("sb_dark")==="1"),l=()=>{const c=!r;s(c),localStorage.setItem("sb_dark",c?"1":"0"),document.documentElement.classList.toggle("dark",c)};w.useEffect(()=>{document.documentElement.classList.toggle("dark",r)},[]),w.useEffect(()=>{e&&Jf().then(async c=>{const d=c||e.name,p=await Zf(d);if(!p.length)return;const v=q1(p),f=await Dy();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(X1,{user:e,onLogout:a,darkMode:r,onToggleDark:l}):n.jsx(t0,{onLogin:i})}Hf(document.getElementById("root")).render(n.jsx(w.StrictMode,{children:n.jsx(J1,{})}));
|