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

53 lines
479 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

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

(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function l(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=l(s);fetch(s.href,i)}})();var pu={exports:{}},Si={},fu={exports:{}},re={};/**
* @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 es=Symbol.for("react.element"),og=Symbol.for("react.portal"),dg=Symbol.for("react.fragment"),cg=Symbol.for("react.strict_mode"),ug=Symbol.for("react.profiler"),pg=Symbol.for("react.provider"),fg=Symbol.for("react.context"),hg=Symbol.for("react.forward_ref"),gg=Symbol.for("react.suspense"),xg=Symbol.for("react.memo"),mg=Symbol.for("react.lazy"),Bd=Symbol.iterator;function yg(e){return e===null||typeof e!="object"?null:(e=Bd&&e[Bd]||e["@@iterator"],typeof e=="function"?e:null)}var hu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},gu=Object.assign,xu={};function Ml(e,t,l){this.props=e,this.context=t,this.refs=xu,this.updater=l||hu}Ml.prototype.isReactComponent={};Ml.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")};Ml.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function mu(){}mu.prototype=Ml.prototype;function So(e,t,l){this.props=e,this.context=t,this.refs=xu,this.updater=l||hu}var wo=So.prototype=new mu;wo.constructor=So;gu(wo,Ml.prototype);wo.isPureReactComponent=!0;var $d=Array.isArray,yu=Object.prototype.hasOwnProperty,ko={current:null},vu={key:!0,ref:!0,__self:!0,__source:!0};function ju(e,t,l){var r,s={},i=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(i=""+t.key),t)yu.call(t,r)&&!vu.hasOwnProperty(r)&&(s[r]=t[r]);var u=arguments.length-2;if(u===1)s.children=l;else if(1<u){for(var p=Array(u),f=0;f<u;f++)p[f]=arguments[f+2];s.children=p}if(e&&e.defaultProps)for(r in u=e.defaultProps,u)s[r]===void 0&&(s[r]=u[r]);return{$$typeof:es,type:e,key:i,ref:a,props:s,_owner:ko.current}}function vg(e,t){return{$$typeof:es,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function _o(e){return typeof e=="object"&&e!==null&&e.$$typeof===es}function jg(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(l){return t[l]})}var Ud=/\/+/g;function Yi(e,t){return typeof e=="object"&&e!==null&&e.key!=null?jg(""+e.key):t.toString(36)}function Bs(e,t,l,r,s){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 es:case og:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+Yi(a,0):r,$d(s)?(l="",e!=null&&(l=e.replace(Ud,"$&/")+"/"),Bs(s,t,l,"",function(f){return f})):s!=null&&(_o(s)&&(s=vg(s,l+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(Ud,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",$d(e))for(var u=0;u<e.length;u++){i=e[u];var p=r+Yi(i,u);a+=Bs(i,t,l,p,s)}else if(p=yg(e),typeof p=="function")for(e=p.call(e),u=0;!(i=e.next()).done;)i=i.value,p=r+Yi(i,u++),a+=Bs(i,t,l,p,s);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 hs(e,t,l){if(e==null)return e;var r=[],s=0;return Bs(e,r,"","",function(i){return t.call(l,i,s++)}),r}function bg(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(l){(e._status===0||e._status===-1)&&(e._status=1,e._result=l)},function(l){(e._status===0||e._status===-1)&&(e._status=2,e._result=l)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var lt={current:null},$s={transition:null},Sg={ReactCurrentDispatcher:lt,ReactCurrentBatchConfig:$s,ReactCurrentOwner:ko};function bu(){throw Error("act(...) is not supported in production builds of React.")}re.Children={map:hs,forEach:function(e,t,l){hs(e,function(){t.apply(this,arguments)},l)},count:function(e){var t=0;return hs(e,function(){t++}),t},toArray:function(e){return hs(e,function(t){return t})||[]},only:function(e){if(!_o(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};re.Component=Ml;re.Fragment=dg;re.Profiler=ug;re.PureComponent=So;re.StrictMode=cg;re.Suspense=gg;re.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Sg;re.act=bu;re.cloneElement=function(e,t,l){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=gu({},e.props),s=e.key,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=ko.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var u=e.type.defaultProps;for(p in t)yu.call(t,p)&&!vu.hasOwnProperty(p)&&(r[p]=t[p]===void 0&&u!==void 0?u[p]:t[p])}var p=arguments.length-2;if(p===1)r.children=l;else if(1<p){u=Array(p);for(var f=0;f<p;f++)u[f]=arguments[f+2];r.children=u}return{$$typeof:es,type:e.type,key:s,ref:i,props:r,_owner:a}};re.createContext=function(e){return e={$$typeof:fg,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:pg,_context:e},e.Consumer=e};re.createElement=ju;re.createFactory=function(e){var t=ju.bind(null,e);return t.type=e,t};re.createRef=function(){return{current:null}};re.forwardRef=function(e){return{$$typeof:hg,render:e}};re.isValidElement=_o;re.lazy=function(e){return{$$typeof:mg,_payload:{_status:-1,_result:e},_init:bg}};re.memo=function(e,t){return{$$typeof:xg,type:e,compare:t===void 0?null:t}};re.startTransition=function(e){var t=$s.transition;$s.transition={};try{e()}finally{$s.transition=t}};re.unstable_act=bu;re.useCallback=function(e,t){return lt.current.useCallback(e,t)};re.useContext=function(e){return lt.current.useContext(e)};re.useDebugValue=function(){};re.useDeferredValue=function(e){return lt.current.useDeferredValue(e)};re.useEffect=function(e,t){return lt.current.useEffect(e,t)};re.useId=function(){return lt.current.useId()};re.useImperativeHandle=function(e,t,l){return lt.current.useImperativeHandle(e,t,l)};re.useInsertionEffect=function(e,t){return lt.current.useInsertionEffect(e,t)};re.useLayoutEffect=function(e,t){return lt.current.useLayoutEffect(e,t)};re.useMemo=function(e,t){return lt.current.useMemo(e,t)};re.useReducer=function(e,t,l){return lt.current.useReducer(e,t,l)};re.useRef=function(e){return lt.current.useRef(e)};re.useState=function(e){return lt.current.useState(e)};re.useSyncExternalStore=function(e,t,l){return lt.current.useSyncExternalStore(e,t,l)};re.useTransition=function(){return lt.current.useTransition()};re.version="18.3.1";fu.exports=re;var S=fu.exports;/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var wg=S,kg=Symbol.for("react.element"),_g=Symbol.for("react.fragment"),Cg=Object.prototype.hasOwnProperty,zg=wg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Tg={key:!0,ref:!0,__self:!0,__source:!0};function Su(e,t,l){var r,s={},i=null,a=null;l!==void 0&&(i=""+l),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)Cg.call(t,r)&&!Tg.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)s[r]===void 0&&(s[r]=t[r]);return{$$typeof:kg,type:e,key:i,ref:a,props:s,_owner:zg.current}}Si.Fragment=_g;Si.jsx=Su;Si.jsxs=Su;pu.exports=Si;var n=pu.exports,wu={exports:{}},mt={},ku={exports:{}},_u={};/**
* @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(E,M){var W=E.length;E.push(M);e:for(;0<W;){var V=W-1>>>1,X=E[V];if(0<s(X,M))E[V]=M,E[W]=X,W=V;else break e}}function l(E){return E.length===0?null:E[0]}function r(E){if(E.length===0)return null;var M=E[0],W=E.pop();if(W!==M){E[0]=W;e:for(var V=0,X=E.length,ee=X>>>1;V<ee;){var Ce=2*(V+1)-1,L=E[Ce],Z=Ce+1,Je=E[Z];if(0>s(L,W))Z<X&&0>s(Je,L)?(E[V]=Je,E[Z]=W,V=Z):(E[V]=L,E[Ce]=W,V=Ce);else if(Z<X&&0>s(Je,W))E[V]=Je,E[Z]=W,V=Z;else break e}}return M}function s(E,M){var W=E.sortIndex-M.sortIndex;return W!==0?W:E.id-M.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var a=Date,u=a.now();e.unstable_now=function(){return a.now()-u}}var p=[],f=[],g=1,c=null,o=3,m=!1,j=!1,h=!1,C=typeof setTimeout=="function"?setTimeout:null,y=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 d(E){for(var M=l(f);M!==null;){if(M.callback===null)r(f);else if(M.startTime<=E)r(f),M.sortIndex=M.expirationTime,t(p,M);else break;M=l(f)}}function v(E){if(h=!1,d(E),!j)if(l(p)!==null)j=!0,ne(z);else{var M=l(f);M!==null&&Se(v,M.startTime-E)}}function z(E,M){j=!1,h&&(h=!1,y(k),k=-1),m=!0;var W=o;try{for(d(M),c=l(p);c!==null&&(!(c.expirationTime>M)||E&&!J());){var V=c.callback;if(typeof V=="function"){c.callback=null,o=c.priorityLevel;var X=V(c.expirationTime<=M);M=e.unstable_now(),typeof X=="function"?c.callback=X:c===l(p)&&r(p),d(M)}else r(p);c=l(p)}if(c!==null)var ee=!0;else{var Ce=l(f);Ce!==null&&Se(v,Ce.startTime-M),ee=!1}return ee}finally{c=null,o=W,m=!1}}var w=!1,b=null,k=-1,I=5,U=-1;function J(){return!(e.unstable_now()-U<I)}function se(){if(b!==null){var E=e.unstable_now();U=E;var M=!0;try{M=b(!0,E)}finally{M?$():(w=!1,b=null)}}else w=!1}var $;if(typeof x=="function")$=function(){x(se)};else if(typeof MessageChannel<"u"){var G=new MessageChannel,pe=G.port2;G.port1.onmessage=se,$=function(){pe.postMessage(null)}}else $=function(){C(se,0)};function ne(E){b=E,w||(w=!0,$())}function Se(E,M){k=C(function(){E(e.unstable_now())},M)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(E){E.callback=null},e.unstable_continueExecution=function(){j||m||(j=!0,ne(z))},e.unstable_forceFrameRate=function(E){0>E||125<E?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<E?Math.floor(1e3/E):5},e.unstable_getCurrentPriorityLevel=function(){return o},e.unstable_getFirstCallbackNode=function(){return l(p)},e.unstable_next=function(E){switch(o){case 1:case 2:case 3:var M=3;break;default:M=o}var W=o;o=M;try{return E()}finally{o=W}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(E,M){switch(E){case 1:case 2:case 3:case 4:case 5:break;default:E=3}var W=o;o=E;try{return M()}finally{o=W}},e.unstable_scheduleCallback=function(E,M,W){var V=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?V+W:V):W=V,E){case 1:var X=-1;break;case 2:X=250;break;case 5:X=1073741823;break;case 4:X=1e4;break;default:X=5e3}return X=W+X,E={id:g++,callback:M,priorityLevel:E,startTime:W,expirationTime:X,sortIndex:-1},W>V?(E.sortIndex=W,t(f,E),l(p)===null&&E===l(f)&&(h?(y(k),k=-1):h=!0,Se(v,W-V))):(E.sortIndex=X,t(p,E),j||m||(j=!0,ne(z))),E},e.unstable_shouldYield=J,e.unstable_wrapCallback=function(E){var M=o;return function(){var W=o;o=M;try{return E.apply(this,arguments)}finally{o=W}}}})(_u);ku.exports=_u;var Ig=ku.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 Eg=S,xt=Ig;function B(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,l=1;l<arguments.length;l++)t+="&args[]="+encodeURIComponent(arguments[l]);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 Cu=new Set,Nr={};function Xn(e,t){Ll(e,t),Ll(e+"Capture",t)}function Ll(e,t){for(Nr[e]=t,e=0;e<t.length;e++)Cu.add(t[e])}var nn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),za=Object.prototype.hasOwnProperty,Pg=/^[: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]*$/,Fd={},Md={};function Ag(e){return za.call(Md,e)?!0:za.call(Fd,e)?!1:Pg.test(e)?Md[e]=!0:(Fd[e]=!0,!1)}function Rg(e,t,l,r){if(l!==null&&l.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:l!==null?!l.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Lg(e,t,l,r){if(t===null||typeof t>"u"||Rg(e,t,l,r))return!0;if(r)return!1;if(l!==null)switch(l.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 rt(e,t,l,r,s,i,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=l,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=a}var Xe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Xe[e]=new rt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Xe[t]=new rt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Xe[e]=new rt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Xe[e]=new rt(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){Xe[e]=new rt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Xe[e]=new rt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Xe[e]=new rt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Xe[e]=new rt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Xe[e]=new rt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Co=/[\-:]([a-z])/g;function zo(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(Co,zo);Xe[t]=new rt(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(Co,zo);Xe[t]=new rt(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(Co,zo);Xe[t]=new rt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Xe[e]=new rt(e,1,!1,e.toLowerCase(),null,!1,!1)});Xe.xlinkHref=new rt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Xe[e]=new rt(e,1,!1,e.toLowerCase(),null,!0,!0)});function To(e,t,l,r){var s=Xe.hasOwnProperty(t)?Xe[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(Lg(t,l,s,r)&&(l=null),r||s===null?Ag(t)&&(l===null?e.removeAttribute(t):e.setAttribute(t,""+l)):s.mustUseProperty?e[s.propertyName]=l===null?s.type===3?!1:"":l:(t=s.attributeName,r=s.attributeNamespace,l===null?e.removeAttribute(t):(s=s.type,l=s===3||s===4&&l===!0?"":""+l,r?e.setAttributeNS(r,t,l):e.setAttribute(t,l))))}var an=Eg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,gs=Symbol.for("react.element"),gl=Symbol.for("react.portal"),xl=Symbol.for("react.fragment"),Io=Symbol.for("react.strict_mode"),Ta=Symbol.for("react.profiler"),zu=Symbol.for("react.provider"),Tu=Symbol.for("react.context"),Eo=Symbol.for("react.forward_ref"),Ia=Symbol.for("react.suspense"),Ea=Symbol.for("react.suspense_list"),Po=Symbol.for("react.memo"),fn=Symbol.for("react.lazy"),Iu=Symbol.for("react.offscreen"),Hd=Symbol.iterator;function lr(e){return e===null||typeof e!="object"?null:(e=Hd&&e[Hd]||e["@@iterator"],typeof e=="function"?e:null)}var _e=Object.assign,Xi;function wr(e){if(Xi===void 0)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);Xi=t&&t[1]||""}return`
`+Xi+e}var Ji=!1;function qi(e,t){if(!e||Ji)return"";Ji=!0;var l=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(f){var r=f}Reflect.construct(e,[],t)}else{try{t.call()}catch(f){r=f}e.call(t.prototype)}else{try{throw Error()}catch(f){r=f}e()}}catch(f){if(f&&r&&typeof f.stack=="string"){for(var s=f.stack.split(`
`),i=r.stack.split(`
`),a=s.length-1,u=i.length-1;1<=a&&0<=u&&s[a]!==i[u];)u--;for(;1<=a&&0<=u;a--,u--)if(s[a]!==i[u]){if(a!==1||u!==1)do if(a--,u--,0>u||s[a]!==i[u]){var p=`
`+s[a].replace(" at new "," at ");return e.displayName&&p.includes("<anonymous>")&&(p=p.replace("<anonymous>",e.displayName)),p}while(1<=a&&0<=u);break}}}finally{Ji=!1,Error.prepareStackTrace=l}return(e=e?e.displayName||e.name:"")?wr(e):""}function Og(e){switch(e.tag){case 5:return wr(e.type);case 16:return wr("Lazy");case 13:return wr("Suspense");case 19:return wr("SuspenseList");case 0:case 2:case 15:return e=qi(e.type,!1),e;case 11:return e=qi(e.type.render,!1),e;case 1:return e=qi(e.type,!0),e;default:return""}}function Pa(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 xl:return"Fragment";case gl:return"Portal";case Ta:return"Profiler";case Io:return"StrictMode";case Ia:return"Suspense";case Ea:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Tu:return(e.displayName||"Context")+".Consumer";case zu:return(e._context.displayName||"Context")+".Provider";case Eo:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Po:return t=e.displayName||null,t!==null?t:Pa(e.type)||"Memo";case fn:t=e._payload,e=e._init;try{return Pa(e(t))}catch{}}return null}function Dg(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 Pa(t);case 8:return t===Io?"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 Tn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Eu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Ng(e){var t=Eu(e)?"checked":"value",l=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var s=l.get,i=l.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(a){r=""+a,i.call(this,a)}}),Object.defineProperty(e,t,{enumerable:l.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function xs(e){e._valueTracker||(e._valueTracker=Ng(e))}function Pu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var l=t.getValue(),r="";return e&&(r=Eu(e)?e.checked?"true":"false":e.value),e=r,e!==l?(t.setValue(e),!0):!1}function qs(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 Aa(e,t){var l=t.checked;return _e({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??e._wrapperState.initialChecked})}function Kd(e,t){var l=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;l=Tn(t.value!=null?t.value:l),e._wrapperState={initialChecked:r,initialValue:l,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Au(e,t){t=t.checked,t!=null&&To(e,"checked",t,!1)}function Ra(e,t){Au(e,t);var l=Tn(t.value),r=t.type;if(l!=null)r==="number"?(l===0&&e.value===""||e.value!=l)&&(e.value=""+l):e.value!==""+l&&(e.value=""+l);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?La(e,t.type,l):t.hasOwnProperty("defaultValue")&&La(e,t.type,Tn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Qd(e,t,l){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,l||t===e.value||(e.value=t),e.defaultValue=t}l=e.name,l!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,l!==""&&(e.name=l)}function La(e,t,l){(t!=="number"||qs(e.ownerDocument)!==e)&&(l==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+l&&(e.defaultValue=""+l))}var kr=Array.isArray;function Tl(e,t,l,r){if(e=e.options,t){t={};for(var s=0;s<l.length;s++)t["$"+l[s]]=!0;for(l=0;l<e.length;l++)s=t.hasOwnProperty("$"+e[l].value),e[l].selected!==s&&(e[l].selected=s),s&&r&&(e[l].defaultSelected=!0)}else{for(l=""+Tn(l),t=null,s=0;s<e.length;s++){if(e[s].value===l){e[s].selected=!0,r&&(e[s].defaultSelected=!0);return}t!==null||e[s].disabled||(t=e[s])}t!==null&&(t.selected=!0)}}function Oa(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(B(91));return _e({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Gd(e,t){var l=t.value;if(l==null){if(l=t.children,t=t.defaultValue,l!=null){if(t!=null)throw Error(B(92));if(kr(l)){if(1<l.length)throw Error(B(93));l=l[0]}t=l}t==null&&(t=""),l=t}e._wrapperState={initialValue:Tn(l)}}function Ru(e,t){var l=Tn(t.value),r=Tn(t.defaultValue);l!=null&&(l=""+l,l!==e.value&&(e.value=l),t.defaultValue==null&&e.defaultValue!==l&&(e.defaultValue=l)),r!=null&&(e.defaultValue=""+r)}function Yd(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Lu(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 Da(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Lu(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var ms,Ou=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,l,r,s){MSApp.execUnsafeLocalFunction(function(){return e(t,l,r,s)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(ms=ms||document.createElement("div"),ms.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=ms.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Wr(e,t){if(t){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=t;return}}e.textContent=t}var Tr={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},Wg=["Webkit","ms","Moz","O"];Object.keys(Tr).forEach(function(e){Wg.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Tr[t]=Tr[e]})});function Du(e,t,l){return t==null||typeof t=="boolean"||t===""?"":l||typeof t!="number"||t===0||Tr.hasOwnProperty(e)&&Tr[e]?(""+t).trim():t+"px"}function Nu(e,t){e=e.style;for(var l in t)if(t.hasOwnProperty(l)){var r=l.indexOf("--")===0,s=Du(l,t[l],r);l==="float"&&(l="cssFloat"),r?e.setProperty(l,s):e[l]=s}}var Bg=_e({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 Na(e,t){if(t){if(Bg[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(B(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(B(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(B(61))}if(t.style!=null&&typeof t.style!="object")throw Error(B(62))}}function Wa(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 Ba=null;function Ao(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var $a=null,Il=null,El=null;function Xd(e){if(e=ls(e)){if(typeof $a!="function")throw Error(B(280));var t=e.stateNode;t&&(t=zi(t),$a(e.stateNode,e.type,t))}}function Wu(e){Il?El?El.push(e):El=[e]:Il=e}function Bu(){if(Il){var e=Il,t=El;if(El=Il=null,Xd(e),t)for(e=0;e<t.length;e++)Xd(t[e])}}function $u(e,t){return e(t)}function Uu(){}var Zi=!1;function Fu(e,t,l){if(Zi)return e(t,l);Zi=!0;try{return $u(e,t,l)}finally{Zi=!1,(Il!==null||El!==null)&&(Uu(),Bu())}}function Br(e,t){var l=e.stateNode;if(l===null)return null;var r=zi(l);if(r===null)return null;l=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(l&&typeof l!="function")throw Error(B(231,t,typeof l));return l}var Ua=!1;if(nn)try{var rr={};Object.defineProperty(rr,"passive",{get:function(){Ua=!0}}),window.addEventListener("test",rr,rr),window.removeEventListener("test",rr,rr)}catch{Ua=!1}function $g(e,t,l,r,s,i,a,u,p){var f=Array.prototype.slice.call(arguments,3);try{t.apply(l,f)}catch(g){this.onError(g)}}var Ir=!1,Zs=null,Vs=!1,Fa=null,Ug={onError:function(e){Ir=!0,Zs=e}};function Fg(e,t,l,r,s,i,a,u,p){Ir=!1,Zs=null,$g.apply(Ug,arguments)}function Mg(e,t,l,r,s,i,a,u,p){if(Fg.apply(this,arguments),Ir){if(Ir){var f=Zs;Ir=!1,Zs=null}else throw Error(B(198));Vs||(Vs=!0,Fa=f)}}function Jn(e){var t=e,l=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(l=t.return),e=t.return;while(e)}return t.tag===3?l:null}function Mu(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 Jd(e){if(Jn(e)!==e)throw Error(B(188))}function Hg(e){var t=e.alternate;if(!t){if(t=Jn(e),t===null)throw Error(B(188));return t!==e?null:e}for(var l=e,r=t;;){var s=l.return;if(s===null)break;var i=s.alternate;if(i===null){if(r=s.return,r!==null){l=r;continue}break}if(s.child===i.child){for(i=s.child;i;){if(i===l)return Jd(s),e;if(i===r)return Jd(s),t;i=i.sibling}throw Error(B(188))}if(l.return!==r.return)l=s,r=i;else{for(var a=!1,u=s.child;u;){if(u===l){a=!0,l=s,r=i;break}if(u===r){a=!0,r=s,l=i;break}u=u.sibling}if(!a){for(u=i.child;u;){if(u===l){a=!0,l=i,r=s;break}if(u===r){a=!0,r=i,l=s;break}u=u.sibling}if(!a)throw Error(B(189))}}if(l.alternate!==r)throw Error(B(190))}if(l.tag!==3)throw Error(B(188));return l.stateNode.current===l?e:t}function Hu(e){return e=Hg(e),e!==null?Ku(e):null}function Ku(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Ku(e);if(t!==null)return t;e=e.sibling}return null}var Qu=xt.unstable_scheduleCallback,qd=xt.unstable_cancelCallback,Kg=xt.unstable_shouldYield,Qg=xt.unstable_requestPaint,Ee=xt.unstable_now,Gg=xt.unstable_getCurrentPriorityLevel,Ro=xt.unstable_ImmediatePriority,Gu=xt.unstable_UserBlockingPriority,ei=xt.unstable_NormalPriority,Yg=xt.unstable_LowPriority,Yu=xt.unstable_IdlePriority,wi=null,Ut=null;function Xg(e){if(Ut&&typeof Ut.onCommitFiberRoot=="function")try{Ut.onCommitFiberRoot(wi,e,void 0,(e.current.flags&128)===128)}catch{}}var Rt=Math.clz32?Math.clz32:Zg,Jg=Math.log,qg=Math.LN2;function Zg(e){return e>>>=0,e===0?32:31-(Jg(e)/qg|0)|0}var ys=64,vs=4194304;function _r(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 ti(e,t){var l=e.pendingLanes;if(l===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,a=l&268435455;if(a!==0){var u=a&~s;u!==0?r=_r(u):(i&=a,i!==0&&(r=_r(i)))}else a=l&~s,a!==0?r=_r(a):i!==0&&(r=_r(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(r&4&&(r|=l&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)l=31-Rt(t),s=1<<l,r|=e[l],t&=~s;return r}function Vg(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 ex(e,t){for(var l=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,i=e.pendingLanes;0<i;){var a=31-Rt(i),u=1<<a,p=s[a];p===-1?(!(u&l)||u&r)&&(s[a]=Vg(u,t)):p<=t&&(e.expiredLanes|=u),i&=~u}}function Ma(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Xu(){var e=ys;return ys<<=1,!(ys&4194240)&&(ys=64),e}function Vi(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function ts(e,t,l){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Rt(t),e[t]=l}function tx(e,t){var l=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<l;){var s=31-Rt(l),i=1<<s;t[s]=0,r[s]=-1,e[s]=-1,l&=~i}}function Lo(e,t){var l=e.entangledLanes|=t;for(e=e.entanglements;l;){var r=31-Rt(l),s=1<<r;s&t|e[r]&t&&(e[r]|=t),l&=~s}}var fe=0;function Ju(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var qu,Oo,Zu,Vu,ep,Ha=!1,js=[],jn=null,bn=null,Sn=null,$r=new Map,Ur=new Map,gn=[],nx="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 Zd(e,t){switch(e){case"focusin":case"focusout":jn=null;break;case"dragenter":case"dragleave":bn=null;break;case"mouseover":case"mouseout":Sn=null;break;case"pointerover":case"pointerout":$r.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ur.delete(t.pointerId)}}function sr(e,t,l,r,s,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:l,eventSystemFlags:r,nativeEvent:i,targetContainers:[s]},t!==null&&(t=ls(t),t!==null&&Oo(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function lx(e,t,l,r,s){switch(t){case"focusin":return jn=sr(jn,e,t,l,r,s),!0;case"dragenter":return bn=sr(bn,e,t,l,r,s),!0;case"mouseover":return Sn=sr(Sn,e,t,l,r,s),!0;case"pointerover":var i=s.pointerId;return $r.set(i,sr($r.get(i)||null,e,t,l,r,s)),!0;case"gotpointercapture":return i=s.pointerId,Ur.set(i,sr(Ur.get(i)||null,e,t,l,r,s)),!0}return!1}function tp(e){var t=Wn(e.target);if(t!==null){var l=Jn(t);if(l!==null){if(t=l.tag,t===13){if(t=Mu(l),t!==null){e.blockedOn=t,ep(e.priority,function(){Zu(l)});return}}else if(t===3&&l.stateNode.current.memoizedState.isDehydrated){e.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Us(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var l=Ka(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(l===null){l=e.nativeEvent;var r=new l.constructor(l.type,l);Ba=r,l.target.dispatchEvent(r),Ba=null}else return t=ls(l),t!==null&&Oo(t),e.blockedOn=l,!1;t.shift()}return!0}function Vd(e,t,l){Us(e)&&l.delete(t)}function rx(){Ha=!1,jn!==null&&Us(jn)&&(jn=null),bn!==null&&Us(bn)&&(bn=null),Sn!==null&&Us(Sn)&&(Sn=null),$r.forEach(Vd),Ur.forEach(Vd)}function ir(e,t){e.blockedOn===t&&(e.blockedOn=null,Ha||(Ha=!0,xt.unstable_scheduleCallback(xt.unstable_NormalPriority,rx)))}function Fr(e){function t(s){return ir(s,e)}if(0<js.length){ir(js[0],e);for(var l=1;l<js.length;l++){var r=js[l];r.blockedOn===e&&(r.blockedOn=null)}}for(jn!==null&&ir(jn,e),bn!==null&&ir(bn,e),Sn!==null&&ir(Sn,e),$r.forEach(t),Ur.forEach(t),l=0;l<gn.length;l++)r=gn[l],r.blockedOn===e&&(r.blockedOn=null);for(;0<gn.length&&(l=gn[0],l.blockedOn===null);)tp(l),l.blockedOn===null&&gn.shift()}var Pl=an.ReactCurrentBatchConfig,ni=!0;function sx(e,t,l,r){var s=fe,i=Pl.transition;Pl.transition=null;try{fe=1,Do(e,t,l,r)}finally{fe=s,Pl.transition=i}}function ix(e,t,l,r){var s=fe,i=Pl.transition;Pl.transition=null;try{fe=4,Do(e,t,l,r)}finally{fe=s,Pl.transition=i}}function Do(e,t,l,r){if(ni){var s=Ka(e,t,l,r);if(s===null)da(e,t,r,li,l),Zd(e,r);else if(lx(s,e,t,l,r))r.stopPropagation();else if(Zd(e,r),t&4&&-1<nx.indexOf(e)){for(;s!==null;){var i=ls(s);if(i!==null&&qu(i),i=Ka(e,t,l,r),i===null&&da(e,t,r,li,l),i===s)break;s=i}s!==null&&r.stopPropagation()}else da(e,t,r,null,l)}}var li=null;function Ka(e,t,l,r){if(li=null,e=Ao(r),e=Wn(e),e!==null)if(t=Jn(e),t===null)e=null;else if(l=t.tag,l===13){if(e=Mu(t),e!==null)return e;e=null}else if(l===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return li=e,null}function np(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(Gg()){case Ro:return 1;case Gu:return 4;case ei:case Yg:return 16;case Yu:return 536870912;default:return 16}default:return 16}}var mn=null,No=null,Fs=null;function lp(){if(Fs)return Fs;var e,t=No,l=t.length,r,s="value"in mn?mn.value:mn.textContent,i=s.length;for(e=0;e<l&&t[e]===s[e];e++);var a=l-e;for(r=1;r<=a&&t[l-r]===s[i-r];r++);return Fs=s.slice(e,1<r?1-r:void 0)}function Ms(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 bs(){return!0}function ec(){return!1}function yt(e){function t(l,r,s,i,a){this._reactName=l,this._targetInst=s,this.type=r,this.nativeEvent=i,this.target=a,this.currentTarget=null;for(var u in e)e.hasOwnProperty(u)&&(l=e[u],this[u]=l?l(i):i[u]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?bs:ec,this.isPropagationStopped=ec,this}return _e(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=bs)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=bs)},persist:function(){},isPersistent:bs}),t}var Hl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Wo=yt(Hl),ns=_e({},Hl,{view:0,detail:0}),ax=yt(ns),ea,ta,ar,ki=_e({},ns,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Bo,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==ar&&(ar&&e.type==="mousemove"?(ea=e.screenX-ar.screenX,ta=e.screenY-ar.screenY):ta=ea=0,ar=e),ea)},movementY:function(e){return"movementY"in e?e.movementY:ta}}),tc=yt(ki),ox=_e({},ki,{dataTransfer:0}),dx=yt(ox),cx=_e({},ns,{relatedTarget:0}),na=yt(cx),ux=_e({},Hl,{animationName:0,elapsedTime:0,pseudoElement:0}),px=yt(ux),fx=_e({},Hl,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),hx=yt(fx),gx=_e({},Hl,{data:0}),nc=yt(gx),xx={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},mx={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"},yx={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function vx(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=yx[e])?!!t[e]:!1}function Bo(){return vx}var jx=_e({},ns,{key:function(e){if(e.key){var t=xx[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Ms(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?mx[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Bo,charCode:function(e){return e.type==="keypress"?Ms(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Ms(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),bx=yt(jx),Sx=_e({},ki,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),lc=yt(Sx),wx=_e({},ns,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Bo}),kx=yt(wx),_x=_e({},Hl,{propertyName:0,elapsedTime:0,pseudoElement:0}),Cx=yt(_x),zx=_e({},ki,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Tx=yt(zx),Ix=[9,13,27,32],$o=nn&&"CompositionEvent"in window,Er=null;nn&&"documentMode"in document&&(Er=document.documentMode);var Ex=nn&&"TextEvent"in window&&!Er,rp=nn&&(!$o||Er&&8<Er&&11>=Er),rc=" ",sc=!1;function sp(e,t){switch(e){case"keyup":return Ix.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ip(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ml=!1;function Px(e,t){switch(e){case"compositionend":return ip(t);case"keypress":return t.which!==32?null:(sc=!0,rc);case"textInput":return e=t.data,e===rc&&sc?null:e;default:return null}}function Ax(e,t){if(ml)return e==="compositionend"||!$o&&sp(e,t)?(e=lp(),Fs=No=mn=null,ml=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return rp&&t.locale!=="ko"?null:t.data;default:return null}}var Rx={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 ic(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Rx[e.type]:t==="textarea"}function ap(e,t,l,r){Wu(r),t=ri(t,"onChange"),0<t.length&&(l=new Wo("onChange","change",null,l,r),e.push({event:l,listeners:t}))}var Pr=null,Mr=null;function Lx(e){yp(e,0)}function _i(e){var t=jl(e);if(Pu(t))return e}function Ox(e,t){if(e==="change")return t}var op=!1;if(nn){var la;if(nn){var ra="oninput"in document;if(!ra){var ac=document.createElement("div");ac.setAttribute("oninput","return;"),ra=typeof ac.oninput=="function"}la=ra}else la=!1;op=la&&(!document.documentMode||9<document.documentMode)}function oc(){Pr&&(Pr.detachEvent("onpropertychange",dp),Mr=Pr=null)}function dp(e){if(e.propertyName==="value"&&_i(Mr)){var t=[];ap(t,Mr,e,Ao(e)),Fu(Lx,t)}}function Dx(e,t,l){e==="focusin"?(oc(),Pr=t,Mr=l,Pr.attachEvent("onpropertychange",dp)):e==="focusout"&&oc()}function Nx(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return _i(Mr)}function Wx(e,t){if(e==="click")return _i(t)}function Bx(e,t){if(e==="input"||e==="change")return _i(t)}function $x(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Ot=typeof Object.is=="function"?Object.is:$x;function Hr(e,t){if(Ot(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var l=Object.keys(e),r=Object.keys(t);if(l.length!==r.length)return!1;for(r=0;r<l.length;r++){var s=l[r];if(!za.call(t,s)||!Ot(e[s],t[s]))return!1}return!0}function dc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function cc(e,t){var l=dc(e);e=0;for(var r;l;){if(l.nodeType===3){if(r=e+l.textContent.length,e<=t&&r>=t)return{node:l,offset:t-e};e=r}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=dc(l)}}function cp(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?cp(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function up(){for(var e=window,t=qs();t instanceof e.HTMLIFrameElement;){try{var l=typeof t.contentWindow.location.href=="string"}catch{l=!1}if(l)e=t.contentWindow;else break;t=qs(e.document)}return t}function Uo(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 Ux(e){var t=up(),l=e.focusedElem,r=e.selectionRange;if(t!==l&&l&&l.ownerDocument&&cp(l.ownerDocument.documentElement,l)){if(r!==null&&Uo(l)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in l)l.selectionStart=t,l.selectionEnd=Math.min(e,l.value.length);else if(e=(t=l.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=l.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=cc(l,i);var a=cc(l,r);s&&a&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=l;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<t.length;l++)e=t[l],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var Fx=nn&&"documentMode"in document&&11>=document.documentMode,yl=null,Qa=null,Ar=null,Ga=!1;function uc(e,t,l){var r=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Ga||yl==null||yl!==qs(r)||(r=yl,"selectionStart"in r&&Uo(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Ar&&Hr(Ar,r)||(Ar=r,r=ri(Qa,"onSelect"),0<r.length&&(t=new Wo("onSelect","select",null,t,l),e.push({event:t,listeners:r}),t.target=yl)))}function Ss(e,t){var l={};return l[e.toLowerCase()]=t.toLowerCase(),l["Webkit"+e]="webkit"+t,l["Moz"+e]="moz"+t,l}var vl={animationend:Ss("Animation","AnimationEnd"),animationiteration:Ss("Animation","AnimationIteration"),animationstart:Ss("Animation","AnimationStart"),transitionend:Ss("Transition","TransitionEnd")},sa={},pp={};nn&&(pp=document.createElement("div").style,"AnimationEvent"in window||(delete vl.animationend.animation,delete vl.animationiteration.animation,delete vl.animationstart.animation),"TransitionEvent"in window||delete vl.transitionend.transition);function Ci(e){if(sa[e])return sa[e];if(!vl[e])return e;var t=vl[e],l;for(l in t)if(t.hasOwnProperty(l)&&l in pp)return sa[e]=t[l];return e}var fp=Ci("animationend"),hp=Ci("animationiteration"),gp=Ci("animationstart"),xp=Ci("transitionend"),mp=new Map,pc="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 Pn(e,t){mp.set(e,t),Xn(t,[e])}for(var ia=0;ia<pc.length;ia++){var aa=pc[ia],Mx=aa.toLowerCase(),Hx=aa[0].toUpperCase()+aa.slice(1);Pn(Mx,"on"+Hx)}Pn(fp,"onAnimationEnd");Pn(hp,"onAnimationIteration");Pn(gp,"onAnimationStart");Pn("dblclick","onDoubleClick");Pn("focusin","onFocus");Pn("focusout","onBlur");Pn(xp,"onTransitionEnd");Ll("onMouseEnter",["mouseout","mouseover"]);Ll("onMouseLeave",["mouseout","mouseover"]);Ll("onPointerEnter",["pointerout","pointerover"]);Ll("onPointerLeave",["pointerout","pointerover"]);Xn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Xn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Xn("onBeforeInput",["compositionend","keypress","textInput","paste"]);Xn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Xn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Xn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Cr="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(" "),Kx=new Set("cancel close invalid load scroll toggle".split(" ").concat(Cr));function fc(e,t,l){var r=e.type||"unknown-event";e.currentTarget=l,Mg(r,t,void 0,e),e.currentTarget=null}function yp(e,t){t=(t&4)!==0;for(var l=0;l<e.length;l++){var r=e[l],s=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var a=r.length-1;0<=a;a--){var u=r[a],p=u.instance,f=u.currentTarget;if(u=u.listener,p!==i&&s.isPropagationStopped())break e;fc(s,u,f),i=p}else for(a=0;a<r.length;a++){if(u=r[a],p=u.instance,f=u.currentTarget,u=u.listener,p!==i&&s.isPropagationStopped())break e;fc(s,u,f),i=p}}}if(Vs)throw e=Fa,Vs=!1,Fa=null,e}function me(e,t){var l=t[Za];l===void 0&&(l=t[Za]=new Set);var r=e+"__bubble";l.has(r)||(vp(t,e,2,!1),l.add(r))}function oa(e,t,l){var r=0;t&&(r|=4),vp(l,e,r,t)}var ws="_reactListening"+Math.random().toString(36).slice(2);function Kr(e){if(!e[ws]){e[ws]=!0,Cu.forEach(function(l){l!=="selectionchange"&&(Kx.has(l)||oa(l,!1,e),oa(l,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[ws]||(t[ws]=!0,oa("selectionchange",!1,t))}}function vp(e,t,l,r){switch(np(t)){case 1:var s=sx;break;case 4:s=ix;break;default:s=Do}l=s.bind(null,t,l,e),s=void 0,!Ua||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(s=!0),r?s!==void 0?e.addEventListener(t,l,{capture:!0,passive:s}):e.addEventListener(t,l,!0):s!==void 0?e.addEventListener(t,l,{passive:s}):e.addEventListener(t,l,!1)}function da(e,t,l,r,s){var i=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var a=r.tag;if(a===3||a===4){var u=r.stateNode.containerInfo;if(u===s||u.nodeType===8&&u.parentNode===s)break;if(a===4)for(a=r.return;a!==null;){var p=a.tag;if((p===3||p===4)&&(p=a.stateNode.containerInfo,p===s||p.nodeType===8&&p.parentNode===s))return;a=a.return}for(;u!==null;){if(a=Wn(u),a===null)return;if(p=a.tag,p===5||p===6){r=i=a;continue e}u=u.parentNode}}r=r.return}Fu(function(){var f=i,g=Ao(l),c=[];e:{var o=mp.get(e);if(o!==void 0){var m=Wo,j=e;switch(e){case"keypress":if(Ms(l)===0)break e;case"keydown":case"keyup":m=bx;break;case"focusin":j="focus",m=na;break;case"focusout":j="blur",m=na;break;case"beforeblur":case"afterblur":m=na;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":m=tc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=dx;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=kx;break;case fp:case hp:case gp:m=px;break;case xp:m=Cx;break;case"scroll":m=ax;break;case"wheel":m=Tx;break;case"copy":case"cut":case"paste":m=hx;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=lc}var h=(t&4)!==0,C=!h&&e==="scroll",y=h?o!==null?o+"Capture":null:o;h=[];for(var x=f,d;x!==null;){d=x;var v=d.stateNode;if(d.tag===5&&v!==null&&(d=v,y!==null&&(v=Br(x,y),v!=null&&h.push(Qr(x,v,d)))),C)break;x=x.return}0<h.length&&(o=new m(o,j,null,l,g),c.push({event:o,listeners:h}))}}if(!(t&7)){e:{if(o=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",o&&l!==Ba&&(j=l.relatedTarget||l.fromElement)&&(Wn(j)||j[ln]))break e;if((m||o)&&(o=g.window===g?g:(o=g.ownerDocument)?o.defaultView||o.parentWindow:window,m?(j=l.relatedTarget||l.toElement,m=f,j=j?Wn(j):null,j!==null&&(C=Jn(j),j!==C||j.tag!==5&&j.tag!==6)&&(j=null)):(m=null,j=f),m!==j)){if(h=tc,v="onMouseLeave",y="onMouseEnter",x="mouse",(e==="pointerout"||e==="pointerover")&&(h=lc,v="onPointerLeave",y="onPointerEnter",x="pointer"),C=m==null?o:jl(m),d=j==null?o:jl(j),o=new h(v,x+"leave",m,l,g),o.target=C,o.relatedTarget=d,v=null,Wn(g)===f&&(h=new h(y,x+"enter",j,l,g),h.target=d,h.relatedTarget=C,v=h),C=v,m&&j)t:{for(h=m,y=j,x=0,d=h;d;d=ol(d))x++;for(d=0,v=y;v;v=ol(v))d++;for(;0<x-d;)h=ol(h),x--;for(;0<d-x;)y=ol(y),d--;for(;x--;){if(h===y||y!==null&&h===y.alternate)break t;h=ol(h),y=ol(y)}h=null}else h=null;m!==null&&hc(c,o,m,h,!1),j!==null&&C!==null&&hc(c,C,j,h,!0)}}e:{if(o=f?jl(f):window,m=o.nodeName&&o.nodeName.toLowerCase(),m==="select"||m==="input"&&o.type==="file")var z=Ox;else if(ic(o))if(op)z=Bx;else{z=Nx;var w=Dx}else(m=o.nodeName)&&m.toLowerCase()==="input"&&(o.type==="checkbox"||o.type==="radio")&&(z=Wx);if(z&&(z=z(e,f))){ap(c,z,l,g);break e}w&&w(e,o,f),e==="focusout"&&(w=o._wrapperState)&&w.controlled&&o.type==="number"&&La(o,"number",o.value)}switch(w=f?jl(f):window,e){case"focusin":(ic(w)||w.contentEditable==="true")&&(yl=w,Qa=f,Ar=null);break;case"focusout":Ar=Qa=yl=null;break;case"mousedown":Ga=!0;break;case"contextmenu":case"mouseup":case"dragend":Ga=!1,uc(c,l,g);break;case"selectionchange":if(Fx)break;case"keydown":case"keyup":uc(c,l,g)}var b;if($o)e:{switch(e){case"compositionstart":var k="onCompositionStart";break e;case"compositionend":k="onCompositionEnd";break e;case"compositionupdate":k="onCompositionUpdate";break e}k=void 0}else ml?sp(e,l)&&(k="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(k="onCompositionStart");k&&(rp&&l.locale!=="ko"&&(ml||k!=="onCompositionStart"?k==="onCompositionEnd"&&ml&&(b=lp()):(mn=g,No="value"in mn?mn.value:mn.textContent,ml=!0)),w=ri(f,k),0<w.length&&(k=new nc(k,e,null,l,g),c.push({event:k,listeners:w}),b?k.data=b:(b=ip(l),b!==null&&(k.data=b)))),(b=Ex?Px(e,l):Ax(e,l))&&(f=ri(f,"onBeforeInput"),0<f.length&&(g=new nc("onBeforeInput","beforeinput",null,l,g),c.push({event:g,listeners:f}),g.data=b))}yp(c,t)})}function Qr(e,t,l){return{instance:e,listener:t,currentTarget:l}}function ri(e,t){for(var l=t+"Capture",r=[];e!==null;){var s=e,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=Br(e,l),i!=null&&r.unshift(Qr(e,i,s)),i=Br(e,t),i!=null&&r.push(Qr(e,i,s))),e=e.return}return r}function ol(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function hc(e,t,l,r,s){for(var i=t._reactName,a=[];l!==null&&l!==r;){var u=l,p=u.alternate,f=u.stateNode;if(p!==null&&p===r)break;u.tag===5&&f!==null&&(u=f,s?(p=Br(l,i),p!=null&&a.unshift(Qr(l,p,u))):s||(p=Br(l,i),p!=null&&a.push(Qr(l,p,u)))),l=l.return}a.length!==0&&e.push({event:t,listeners:a})}var Qx=/\r\n?/g,Gx=/\u0000|\uFFFD/g;function gc(e){return(typeof e=="string"?e:""+e).replace(Qx,`
`).replace(Gx,"")}function ks(e,t,l){if(t=gc(t),gc(e)!==t&&l)throw Error(B(425))}function si(){}var Ya=null,Xa=null;function Ja(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 qa=typeof setTimeout=="function"?setTimeout:void 0,Yx=typeof clearTimeout=="function"?clearTimeout:void 0,xc=typeof Promise=="function"?Promise:void 0,Xx=typeof queueMicrotask=="function"?queueMicrotask:typeof xc<"u"?function(e){return xc.resolve(null).then(e).catch(Jx)}:qa;function Jx(e){setTimeout(function(){throw e})}function ca(e,t){var l=t,r=0;do{var s=l.nextSibling;if(e.removeChild(l),s&&s.nodeType===8)if(l=s.data,l==="/$"){if(r===0){e.removeChild(s),Fr(t);return}r--}else l!=="$"&&l!=="$?"&&l!=="$!"||r++;l=s}while(l);Fr(t)}function wn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function mc(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var l=e.data;if(l==="$"||l==="$!"||l==="$?"){if(t===0)return e;t--}else l==="/$"&&t++}e=e.previousSibling}return null}var Kl=Math.random().toString(36).slice(2),$t="__reactFiber$"+Kl,Gr="__reactProps$"+Kl,ln="__reactContainer$"+Kl,Za="__reactEvents$"+Kl,qx="__reactListeners$"+Kl,Zx="__reactHandles$"+Kl;function Wn(e){var t=e[$t];if(t)return t;for(var l=e.parentNode;l;){if(t=l[ln]||l[$t]){if(l=t.alternate,t.child!==null||l!==null&&l.child!==null)for(e=mc(e);e!==null;){if(l=e[$t])return l;e=mc(e)}return t}e=l,l=e.parentNode}return null}function ls(e){return e=e[$t]||e[ln],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function jl(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(B(33))}function zi(e){return e[Gr]||null}var Va=[],bl=-1;function An(e){return{current:e}}function ye(e){0>bl||(e.current=Va[bl],Va[bl]=null,bl--)}function xe(e,t){bl++,Va[bl]=e.current,e.current=t}var In={},et=An(In),ot=An(!1),Mn=In;function Ol(e,t){var l=e.type.contextTypes;if(!l)return In;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in l)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function dt(e){return e=e.childContextTypes,e!=null}function ii(){ye(ot),ye(et)}function yc(e,t,l){if(et.current!==In)throw Error(B(168));xe(et,t),xe(ot,l)}function jp(e,t,l){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return l;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(B(108,Dg(e)||"Unknown",s));return _e({},l,r)}function ai(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||In,Mn=et.current,xe(et,e),xe(ot,ot.current),!0}function vc(e,t,l){var r=e.stateNode;if(!r)throw Error(B(169));l?(e=jp(e,t,Mn),r.__reactInternalMemoizedMergedChildContext=e,ye(ot),ye(et),xe(et,e)):ye(ot),xe(ot,l)}var Zt=null,Ti=!1,ua=!1;function bp(e){Zt===null?Zt=[e]:Zt.push(e)}function Vx(e){Ti=!0,bp(e)}function Rn(){if(!ua&&Zt!==null){ua=!0;var e=0,t=fe;try{var l=Zt;for(fe=1;e<l.length;e++){var r=l[e];do r=r(!0);while(r!==null)}Zt=null,Ti=!1}catch(s){throw Zt!==null&&(Zt=Zt.slice(e+1)),Qu(Ro,Rn),s}finally{fe=t,ua=!1}}return null}var Sl=[],wl=0,oi=null,di=0,vt=[],jt=0,Hn=null,Vt=1,en="";function Dn(e,t){Sl[wl++]=di,Sl[wl++]=oi,oi=e,di=t}function Sp(e,t,l){vt[jt++]=Vt,vt[jt++]=en,vt[jt++]=Hn,Hn=e;var r=Vt;e=en;var s=32-Rt(r)-1;r&=~(1<<s),l+=1;var i=32-Rt(t)+s;if(30<i){var a=s-s%5;i=(r&(1<<a)-1).toString(32),r>>=a,s-=a,Vt=1<<32-Rt(t)+s|l<<s|r,en=i+e}else Vt=1<<i|l<<s|r,en=e}function Fo(e){e.return!==null&&(Dn(e,1),Sp(e,1,0))}function Mo(e){for(;e===oi;)oi=Sl[--wl],Sl[wl]=null,di=Sl[--wl],Sl[wl]=null;for(;e===Hn;)Hn=vt[--jt],vt[jt]=null,en=vt[--jt],vt[jt]=null,Vt=vt[--jt],vt[jt]=null}var gt=null,ht=null,be=!1,Pt=null;function wp(e,t){var l=bt(5,null,null,0);l.elementType="DELETED",l.stateNode=t,l.return=e,t=e.deletions,t===null?(e.deletions=[l],e.flags|=16):t.push(l)}function jc(e,t){switch(e.tag){case 5:var l=e.type;return t=t.nodeType!==1||l.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,gt=e,ht=wn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,gt=e,ht=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(l=Hn!==null?{id:Vt,overflow:en}:null,e.memoizedState={dehydrated:t,treeContext:l,retryLane:1073741824},l=bt(18,null,null,0),l.stateNode=t,l.return=e,e.child=l,gt=e,ht=null,!0):!1;default:return!1}}function eo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function to(e){if(be){var t=ht;if(t){var l=t;if(!jc(e,t)){if(eo(e))throw Error(B(418));t=wn(l.nextSibling);var r=gt;t&&jc(e,t)?wp(r,l):(e.flags=e.flags&-4097|2,be=!1,gt=e)}}else{if(eo(e))throw Error(B(418));e.flags=e.flags&-4097|2,be=!1,gt=e}}}function bc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;gt=e}function _s(e){if(e!==gt)return!1;if(!be)return bc(e),be=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Ja(e.type,e.memoizedProps)),t&&(t=ht)){if(eo(e))throw kp(),Error(B(418));for(;t;)wp(e,t),t=wn(t.nextSibling)}if(bc(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(B(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var l=e.data;if(l==="/$"){if(t===0){ht=wn(e.nextSibling);break e}t--}else l!=="$"&&l!=="$!"&&l!=="$?"||t++}e=e.nextSibling}ht=null}}else ht=gt?wn(e.stateNode.nextSibling):null;return!0}function kp(){for(var e=ht;e;)e=wn(e.nextSibling)}function Dl(){ht=gt=null,be=!1}function Ho(e){Pt===null?Pt=[e]:Pt.push(e)}var em=an.ReactCurrentBatchConfig;function or(e,t,l){if(e=l.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(B(309));var r=l.stateNode}if(!r)throw Error(B(147,e));var s=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(a){var u=s.refs;a===null?delete u[i]:u[i]=a},t._stringRef=i,t)}if(typeof e!="string")throw Error(B(284));if(!l._owner)throw Error(B(290,e))}return e}function Cs(e,t){throw e=Object.prototype.toString.call(t),Error(B(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Sc(e){var t=e._init;return t(e._payload)}function _p(e){function t(y,x){if(e){var d=y.deletions;d===null?(y.deletions=[x],y.flags|=16):d.push(x)}}function l(y,x){if(!e)return null;for(;x!==null;)t(y,x),x=x.sibling;return null}function r(y,x){for(y=new Map;x!==null;)x.key!==null?y.set(x.key,x):y.set(x.index,x),x=x.sibling;return y}function s(y,x){return y=zn(y,x),y.index=0,y.sibling=null,y}function i(y,x,d){return y.index=d,e?(d=y.alternate,d!==null?(d=d.index,d<x?(y.flags|=2,x):d):(y.flags|=2,x)):(y.flags|=1048576,x)}function a(y){return e&&y.alternate===null&&(y.flags|=2),y}function u(y,x,d,v){return x===null||x.tag!==6?(x=ya(d,y.mode,v),x.return=y,x):(x=s(x,d),x.return=y,x)}function p(y,x,d,v){var z=d.type;return z===xl?g(y,x,d.props.children,v,d.key):x!==null&&(x.elementType===z||typeof z=="object"&&z!==null&&z.$$typeof===fn&&Sc(z)===x.type)?(v=s(x,d.props),v.ref=or(y,x,d),v.return=y,v):(v=Js(d.type,d.key,d.props,null,y.mode,v),v.ref=or(y,x,d),v.return=y,v)}function f(y,x,d,v){return x===null||x.tag!==4||x.stateNode.containerInfo!==d.containerInfo||x.stateNode.implementation!==d.implementation?(x=va(d,y.mode,v),x.return=y,x):(x=s(x,d.children||[]),x.return=y,x)}function g(y,x,d,v,z){return x===null||x.tag!==7?(x=Fn(d,y.mode,v,z),x.return=y,x):(x=s(x,d),x.return=y,x)}function c(y,x,d){if(typeof x=="string"&&x!==""||typeof x=="number")return x=ya(""+x,y.mode,d),x.return=y,x;if(typeof x=="object"&&x!==null){switch(x.$$typeof){case gs:return d=Js(x.type,x.key,x.props,null,y.mode,d),d.ref=or(y,null,x),d.return=y,d;case gl:return x=va(x,y.mode,d),x.return=y,x;case fn:var v=x._init;return c(y,v(x._payload),d)}if(kr(x)||lr(x))return x=Fn(x,y.mode,d,null),x.return=y,x;Cs(y,x)}return null}function o(y,x,d,v){var z=x!==null?x.key:null;if(typeof d=="string"&&d!==""||typeof d=="number")return z!==null?null:u(y,x,""+d,v);if(typeof d=="object"&&d!==null){switch(d.$$typeof){case gs:return d.key===z?p(y,x,d,v):null;case gl:return d.key===z?f(y,x,d,v):null;case fn:return z=d._init,o(y,x,z(d._payload),v)}if(kr(d)||lr(d))return z!==null?null:g(y,x,d,v,null);Cs(y,d)}return null}function m(y,x,d,v,z){if(typeof v=="string"&&v!==""||typeof v=="number")return y=y.get(d)||null,u(x,y,""+v,z);if(typeof v=="object"&&v!==null){switch(v.$$typeof){case gs:return y=y.get(v.key===null?d:v.key)||null,p(x,y,v,z);case gl:return y=y.get(v.key===null?d:v.key)||null,f(x,y,v,z);case fn:var w=v._init;return m(y,x,d,w(v._payload),z)}if(kr(v)||lr(v))return y=y.get(d)||null,g(x,y,v,z,null);Cs(x,v)}return null}function j(y,x,d,v){for(var z=null,w=null,b=x,k=x=0,I=null;b!==null&&k<d.length;k++){b.index>k?(I=b,b=null):I=b.sibling;var U=o(y,b,d[k],v);if(U===null){b===null&&(b=I);break}e&&b&&U.alternate===null&&t(y,b),x=i(U,x,k),w===null?z=U:w.sibling=U,w=U,b=I}if(k===d.length)return l(y,b),be&&Dn(y,k),z;if(b===null){for(;k<d.length;k++)b=c(y,d[k],v),b!==null&&(x=i(b,x,k),w===null?z=b:w.sibling=b,w=b);return be&&Dn(y,k),z}for(b=r(y,b);k<d.length;k++)I=m(b,y,k,d[k],v),I!==null&&(e&&I.alternate!==null&&b.delete(I.key===null?k:I.key),x=i(I,x,k),w===null?z=I:w.sibling=I,w=I);return e&&b.forEach(function(J){return t(y,J)}),be&&Dn(y,k),z}function h(y,x,d,v){var z=lr(d);if(typeof z!="function")throw Error(B(150));if(d=z.call(d),d==null)throw Error(B(151));for(var w=z=null,b=x,k=x=0,I=null,U=d.next();b!==null&&!U.done;k++,U=d.next()){b.index>k?(I=b,b=null):I=b.sibling;var J=o(y,b,U.value,v);if(J===null){b===null&&(b=I);break}e&&b&&J.alternate===null&&t(y,b),x=i(J,x,k),w===null?z=J:w.sibling=J,w=J,b=I}if(U.done)return l(y,b),be&&Dn(y,k),z;if(b===null){for(;!U.done;k++,U=d.next())U=c(y,U.value,v),U!==null&&(x=i(U,x,k),w===null?z=U:w.sibling=U,w=U);return be&&Dn(y,k),z}for(b=r(y,b);!U.done;k++,U=d.next())U=m(b,y,k,U.value,v),U!==null&&(e&&U.alternate!==null&&b.delete(U.key===null?k:U.key),x=i(U,x,k),w===null?z=U:w.sibling=U,w=U);return e&&b.forEach(function(se){return t(y,se)}),be&&Dn(y,k),z}function C(y,x,d,v){if(typeof d=="object"&&d!==null&&d.type===xl&&d.key===null&&(d=d.props.children),typeof d=="object"&&d!==null){switch(d.$$typeof){case gs:e:{for(var z=d.key,w=x;w!==null;){if(w.key===z){if(z=d.type,z===xl){if(w.tag===7){l(y,w.sibling),x=s(w,d.props.children),x.return=y,y=x;break e}}else if(w.elementType===z||typeof z=="object"&&z!==null&&z.$$typeof===fn&&Sc(z)===w.type){l(y,w.sibling),x=s(w,d.props),x.ref=or(y,w,d),x.return=y,y=x;break e}l(y,w);break}else t(y,w);w=w.sibling}d.type===xl?(x=Fn(d.props.children,y.mode,v,d.key),x.return=y,y=x):(v=Js(d.type,d.key,d.props,null,y.mode,v),v.ref=or(y,x,d),v.return=y,y=v)}return a(y);case gl:e:{for(w=d.key;x!==null;){if(x.key===w)if(x.tag===4&&x.stateNode.containerInfo===d.containerInfo&&x.stateNode.implementation===d.implementation){l(y,x.sibling),x=s(x,d.children||[]),x.return=y,y=x;break e}else{l(y,x);break}else t(y,x);x=x.sibling}x=va(d,y.mode,v),x.return=y,y=x}return a(y);case fn:return w=d._init,C(y,x,w(d._payload),v)}if(kr(d))return j(y,x,d,v);if(lr(d))return h(y,x,d,v);Cs(y,d)}return typeof d=="string"&&d!==""||typeof d=="number"?(d=""+d,x!==null&&x.tag===6?(l(y,x.sibling),x=s(x,d),x.return=y,y=x):(l(y,x),x=ya(d,y.mode,v),x.return=y,y=x),a(y)):l(y,x)}return C}var Nl=_p(!0),Cp=_p(!1),ci=An(null),ui=null,kl=null,Ko=null;function Qo(){Ko=kl=ui=null}function Go(e){var t=ci.current;ye(ci),e._currentValue=t}function no(e,t,l){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===l)break;e=e.return}}function Al(e,t){ui=e,Ko=kl=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(at=!0),e.firstContext=null)}function wt(e){var t=e._currentValue;if(Ko!==e)if(e={context:e,memoizedValue:t,next:null},kl===null){if(ui===null)throw Error(B(308));kl=e,ui.dependencies={lanes:0,firstContext:e}}else kl=kl.next=e;return t}var Bn=null;function Yo(e){Bn===null?Bn=[e]:Bn.push(e)}function zp(e,t,l,r){var s=t.interleaved;return s===null?(l.next=l,Yo(t)):(l.next=s.next,s.next=l),t.interleaved=l,rn(e,r)}function rn(e,t){e.lanes|=t;var l=e.alternate;for(l!==null&&(l.lanes|=t),l=e,e=e.return;e!==null;)e.childLanes|=t,l=e.alternate,l!==null&&(l.childLanes|=t),l=e,e=e.return;return l.tag===3?l.stateNode:null}var hn=!1;function Xo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Tp(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 tn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function kn(e,t,l){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ce&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,rn(e,l)}return s=r.interleaved,s===null?(t.next=t,Yo(r)):(t.next=s.next,s.next=t),r.interleaved=t,rn(e,l)}function Hs(e,t,l){if(t=t.updateQueue,t!==null&&(t=t.shared,(l&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,l|=r,t.lanes=l,Lo(e,l)}}function wc(e,t){var l=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,l===r)){var s=null,i=null;if(l=l.firstBaseUpdate,l!==null){do{var a={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};i===null?s=i=a:i=i.next=a,l=l.next}while(l!==null);i===null?s=i=t:i=i.next=t}else s=i=t;l={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=t:e.next=t,l.lastBaseUpdate=t}function pi(e,t,l,r){var s=e.updateQueue;hn=!1;var i=s.firstBaseUpdate,a=s.lastBaseUpdate,u=s.shared.pending;if(u!==null){s.shared.pending=null;var p=u,f=p.next;p.next=null,a===null?i=f:a.next=f,a=p;var g=e.alternate;g!==null&&(g=g.updateQueue,u=g.lastBaseUpdate,u!==a&&(u===null?g.firstBaseUpdate=f:u.next=f,g.lastBaseUpdate=p))}if(i!==null){var c=s.baseState;a=0,g=f=p=null,u=i;do{var o=u.lane,m=u.eventTime;if((r&o)===o){g!==null&&(g=g.next={eventTime:m,lane:0,tag:u.tag,payload:u.payload,callback:u.callback,next:null});e:{var j=e,h=u;switch(o=t,m=l,h.tag){case 1:if(j=h.payload,typeof j=="function"){c=j.call(m,c,o);break e}c=j;break e;case 3:j.flags=j.flags&-65537|128;case 0:if(j=h.payload,o=typeof j=="function"?j.call(m,c,o):j,o==null)break e;c=_e({},c,o);break e;case 2:hn=!0}}u.callback!==null&&u.lane!==0&&(e.flags|=64,o=s.effects,o===null?s.effects=[u]:o.push(u))}else m={eventTime:m,lane:o,tag:u.tag,payload:u.payload,callback:u.callback,next:null},g===null?(f=g=m,p=c):g=g.next=m,a|=o;if(u=u.next,u===null){if(u=s.shared.pending,u===null)break;o=u,u=o.next,o.next=null,s.lastBaseUpdate=o,s.shared.pending=null}}while(!0);if(g===null&&(p=c),s.baseState=p,s.firstBaseUpdate=f,s.lastBaseUpdate=g,t=s.shared.interleaved,t!==null){s=t;do a|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);Qn|=a,e.lanes=a,e.memoizedState=c}}function kc(e,t,l){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],s=r.callback;if(s!==null){if(r.callback=null,r=l,typeof s!="function")throw Error(B(191,s));s.call(r)}}}var rs={},Ft=An(rs),Yr=An(rs),Xr=An(rs);function $n(e){if(e===rs)throw Error(B(174));return e}function Jo(e,t){switch(xe(Xr,t),xe(Yr,e),xe(Ft,rs),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Da(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Da(t,e)}ye(Ft),xe(Ft,t)}function Wl(){ye(Ft),ye(Yr),ye(Xr)}function Ip(e){$n(Xr.current);var t=$n(Ft.current),l=Da(t,e.type);t!==l&&(xe(Yr,e),xe(Ft,l))}function qo(e){Yr.current===e&&(ye(Ft),ye(Yr))}var we=An(0);function fi(e){for(var t=e;t!==null;){if(t.tag===13){var l=t.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var pa=[];function Zo(){for(var e=0;e<pa.length;e++)pa[e]._workInProgressVersionPrimary=null;pa.length=0}var Ks=an.ReactCurrentDispatcher,fa=an.ReactCurrentBatchConfig,Kn=0,ke=null,$e=null,Me=null,hi=!1,Rr=!1,Jr=0,tm=0;function qe(){throw Error(B(321))}function Vo(e,t){if(t===null)return!1;for(var l=0;l<t.length&&l<e.length;l++)if(!Ot(e[l],t[l]))return!1;return!0}function ed(e,t,l,r,s,i){if(Kn=i,ke=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Ks.current=e===null||e.memoizedState===null?sm:im,e=l(r,s),Rr){i=0;do{if(Rr=!1,Jr=0,25<=i)throw Error(B(301));i+=1,Me=$e=null,t.updateQueue=null,Ks.current=am,e=l(r,s)}while(Rr)}if(Ks.current=gi,t=$e!==null&&$e.next!==null,Kn=0,Me=$e=ke=null,hi=!1,t)throw Error(B(300));return e}function td(){var e=Jr!==0;return Jr=0,e}function Bt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Me===null?ke.memoizedState=Me=e:Me=Me.next=e,Me}function kt(){if($e===null){var e=ke.alternate;e=e!==null?e.memoizedState:null}else e=$e.next;var t=Me===null?ke.memoizedState:Me.next;if(t!==null)Me=t,$e=e;else{if(e===null)throw Error(B(310));$e=e,e={memoizedState:$e.memoizedState,baseState:$e.baseState,baseQueue:$e.baseQueue,queue:$e.queue,next:null},Me===null?ke.memoizedState=Me=e:Me=Me.next=e}return Me}function qr(e,t){return typeof t=="function"?t(e):t}function ha(e){var t=kt(),l=t.queue;if(l===null)throw Error(B(311));l.lastRenderedReducer=e;var r=$e,s=r.baseQueue,i=l.pending;if(i!==null){if(s!==null){var a=s.next;s.next=i.next,i.next=a}r.baseQueue=s=i,l.pending=null}if(s!==null){i=s.next,r=r.baseState;var u=a=null,p=null,f=i;do{var g=f.lane;if((Kn&g)===g)p!==null&&(p=p.next={lane:0,action:f.action,hasEagerState:f.hasEagerState,eagerState:f.eagerState,next:null}),r=f.hasEagerState?f.eagerState:e(r,f.action);else{var c={lane:g,action:f.action,hasEagerState:f.hasEagerState,eagerState:f.eagerState,next:null};p===null?(u=p=c,a=r):p=p.next=c,ke.lanes|=g,Qn|=g}f=f.next}while(f!==null&&f!==i);p===null?a=r:p.next=u,Ot(r,t.memoizedState)||(at=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=p,l.lastRenderedState=r}if(e=l.interleaved,e!==null){s=e;do i=s.lane,ke.lanes|=i,Qn|=i,s=s.next;while(s!==e)}else s===null&&(l.lanes=0);return[t.memoizedState,l.dispatch]}function ga(e){var t=kt(),l=t.queue;if(l===null)throw Error(B(311));l.lastRenderedReducer=e;var r=l.dispatch,s=l.pending,i=t.memoizedState;if(s!==null){l.pending=null;var a=s=s.next;do i=e(i,a.action),a=a.next;while(a!==s);Ot(i,t.memoizedState)||(at=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),l.lastRenderedState=i}return[i,r]}function Ep(){}function Pp(e,t){var l=ke,r=kt(),s=t(),i=!Ot(r.memoizedState,s);if(i&&(r.memoizedState=s,at=!0),r=r.queue,nd(Lp.bind(null,l,r,e),[e]),r.getSnapshot!==t||i||Me!==null&&Me.memoizedState.tag&1){if(l.flags|=2048,Zr(9,Rp.bind(null,l,r,s,t),void 0,null),He===null)throw Error(B(349));Kn&30||Ap(l,t,s)}return s}function Ap(e,t,l){e.flags|=16384,e={getSnapshot:t,value:l},t=ke.updateQueue,t===null?(t={lastEffect:null,stores:null},ke.updateQueue=t,t.stores=[e]):(l=t.stores,l===null?t.stores=[e]:l.push(e))}function Rp(e,t,l,r){t.value=l,t.getSnapshot=r,Op(t)&&Dp(e)}function Lp(e,t,l){return l(function(){Op(t)&&Dp(e)})}function Op(e){var t=e.getSnapshot;e=e.value;try{var l=t();return!Ot(e,l)}catch{return!0}}function Dp(e){var t=rn(e,1);t!==null&&Lt(t,e,1,-1)}function _c(e){var t=Bt();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:qr,lastRenderedState:e},t.queue=e,e=e.dispatch=rm.bind(null,ke,e),[t.memoizedState,e]}function Zr(e,t,l,r){return e={tag:e,create:t,destroy:l,deps:r,next:null},t=ke.updateQueue,t===null?(t={lastEffect:null,stores:null},ke.updateQueue=t,t.lastEffect=e.next=e):(l=t.lastEffect,l===null?t.lastEffect=e.next=e:(r=l.next,l.next=e,e.next=r,t.lastEffect=e)),e}function Np(){return kt().memoizedState}function Qs(e,t,l,r){var s=Bt();ke.flags|=e,s.memoizedState=Zr(1|t,l,void 0,r===void 0?null:r)}function Ii(e,t,l,r){var s=kt();r=r===void 0?null:r;var i=void 0;if($e!==null){var a=$e.memoizedState;if(i=a.destroy,r!==null&&Vo(r,a.deps)){s.memoizedState=Zr(t,l,i,r);return}}ke.flags|=e,s.memoizedState=Zr(1|t,l,i,r)}function Cc(e,t){return Qs(8390656,8,e,t)}function nd(e,t){return Ii(2048,8,e,t)}function Wp(e,t){return Ii(4,2,e,t)}function Bp(e,t){return Ii(4,4,e,t)}function $p(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 Up(e,t,l){return l=l!=null?l.concat([e]):null,Ii(4,4,$p.bind(null,t,e),l)}function ld(){}function Fp(e,t){var l=kt();t=t===void 0?null:t;var r=l.memoizedState;return r!==null&&t!==null&&Vo(t,r[1])?r[0]:(l.memoizedState=[e,t],e)}function Mp(e,t){var l=kt();t=t===void 0?null:t;var r=l.memoizedState;return r!==null&&t!==null&&Vo(t,r[1])?r[0]:(e=e(),l.memoizedState=[e,t],e)}function Hp(e,t,l){return Kn&21?(Ot(l,t)||(l=Xu(),ke.lanes|=l,Qn|=l,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,at=!0),e.memoizedState=l)}function nm(e,t){var l=fe;fe=l!==0&&4>l?l:4,e(!0);var r=fa.transition;fa.transition={};try{e(!1),t()}finally{fe=l,fa.transition=r}}function Kp(){return kt().memoizedState}function lm(e,t,l){var r=Cn(e);if(l={lane:r,action:l,hasEagerState:!1,eagerState:null,next:null},Qp(e))Gp(t,l);else if(l=zp(e,t,l,r),l!==null){var s=nt();Lt(l,e,r,s),Yp(l,t,r)}}function rm(e,t,l){var r=Cn(e),s={lane:r,action:l,hasEagerState:!1,eagerState:null,next:null};if(Qp(e))Gp(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var a=t.lastRenderedState,u=i(a,l);if(s.hasEagerState=!0,s.eagerState=u,Ot(u,a)){var p=t.interleaved;p===null?(s.next=s,Yo(t)):(s.next=p.next,p.next=s),t.interleaved=s;return}}catch{}finally{}l=zp(e,t,s,r),l!==null&&(s=nt(),Lt(l,e,r,s),Yp(l,t,r))}}function Qp(e){var t=e.alternate;return e===ke||t!==null&&t===ke}function Gp(e,t){Rr=hi=!0;var l=e.pending;l===null?t.next=t:(t.next=l.next,l.next=t),e.pending=t}function Yp(e,t,l){if(l&4194240){var r=t.lanes;r&=e.pendingLanes,l|=r,t.lanes=l,Lo(e,l)}}var gi={readContext:wt,useCallback:qe,useContext:qe,useEffect:qe,useImperativeHandle:qe,useInsertionEffect:qe,useLayoutEffect:qe,useMemo:qe,useReducer:qe,useRef:qe,useState:qe,useDebugValue:qe,useDeferredValue:qe,useTransition:qe,useMutableSource:qe,useSyncExternalStore:qe,useId:qe,unstable_isNewReconciler:!1},sm={readContext:wt,useCallback:function(e,t){return Bt().memoizedState=[e,t===void 0?null:t],e},useContext:wt,useEffect:Cc,useImperativeHandle:function(e,t,l){return l=l!=null?l.concat([e]):null,Qs(4194308,4,$p.bind(null,t,e),l)},useLayoutEffect:function(e,t){return Qs(4194308,4,e,t)},useInsertionEffect:function(e,t){return Qs(4,2,e,t)},useMemo:function(e,t){var l=Bt();return t=t===void 0?null:t,e=e(),l.memoizedState=[e,t],e},useReducer:function(e,t,l){var r=Bt();return t=l!==void 0?l(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=lm.bind(null,ke,e),[r.memoizedState,e]},useRef:function(e){var t=Bt();return e={current:e},t.memoizedState=e},useState:_c,useDebugValue:ld,useDeferredValue:function(e){return Bt().memoizedState=e},useTransition:function(){var e=_c(!1),t=e[0];return e=nm.bind(null,e[1]),Bt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,l){var r=ke,s=Bt();if(be){if(l===void 0)throw Error(B(407));l=l()}else{if(l=t(),He===null)throw Error(B(349));Kn&30||Ap(r,t,l)}s.memoizedState=l;var i={value:l,getSnapshot:t};return s.queue=i,Cc(Lp.bind(null,r,i,e),[e]),r.flags|=2048,Zr(9,Rp.bind(null,r,i,l,t),void 0,null),l},useId:function(){var e=Bt(),t=He.identifierPrefix;if(be){var l=en,r=Vt;l=(r&~(1<<32-Rt(r)-1)).toString(32)+l,t=":"+t+"R"+l,l=Jr++,0<l&&(t+="H"+l.toString(32)),t+=":"}else l=tm++,t=":"+t+"r"+l.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},im={readContext:wt,useCallback:Fp,useContext:wt,useEffect:nd,useImperativeHandle:Up,useInsertionEffect:Wp,useLayoutEffect:Bp,useMemo:Mp,useReducer:ha,useRef:Np,useState:function(){return ha(qr)},useDebugValue:ld,useDeferredValue:function(e){var t=kt();return Hp(t,$e.memoizedState,e)},useTransition:function(){var e=ha(qr)[0],t=kt().memoizedState;return[e,t]},useMutableSource:Ep,useSyncExternalStore:Pp,useId:Kp,unstable_isNewReconciler:!1},am={readContext:wt,useCallback:Fp,useContext:wt,useEffect:nd,useImperativeHandle:Up,useInsertionEffect:Wp,useLayoutEffect:Bp,useMemo:Mp,useReducer:ga,useRef:Np,useState:function(){return ga(qr)},useDebugValue:ld,useDeferredValue:function(e){var t=kt();return $e===null?t.memoizedState=e:Hp(t,$e.memoizedState,e)},useTransition:function(){var e=ga(qr)[0],t=kt().memoizedState;return[e,t]},useMutableSource:Ep,useSyncExternalStore:Pp,useId:Kp,unstable_isNewReconciler:!1};function It(e,t){if(e&&e.defaultProps){t=_e({},t),e=e.defaultProps;for(var l in e)t[l]===void 0&&(t[l]=e[l]);return t}return t}function lo(e,t,l,r){t=e.memoizedState,l=l(r,t),l=l==null?t:_e({},t,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var Ei={isMounted:function(e){return(e=e._reactInternals)?Jn(e)===e:!1},enqueueSetState:function(e,t,l){e=e._reactInternals;var r=nt(),s=Cn(e),i=tn(r,s);i.payload=t,l!=null&&(i.callback=l),t=kn(e,i,s),t!==null&&(Lt(t,e,s,r),Hs(t,e,s))},enqueueReplaceState:function(e,t,l){e=e._reactInternals;var r=nt(),s=Cn(e),i=tn(r,s);i.tag=1,i.payload=t,l!=null&&(i.callback=l),t=kn(e,i,s),t!==null&&(Lt(t,e,s,r),Hs(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var l=nt(),r=Cn(e),s=tn(l,r);s.tag=2,t!=null&&(s.callback=t),t=kn(e,s,r),t!==null&&(Lt(t,e,r,l),Hs(t,e,r))}};function zc(e,t,l,r,s,i,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,a):t.prototype&&t.prototype.isPureReactComponent?!Hr(l,r)||!Hr(s,i):!0}function Xp(e,t,l){var r=!1,s=In,i=t.contextType;return typeof i=="object"&&i!==null?i=wt(i):(s=dt(t)?Mn:et.current,r=t.contextTypes,i=(r=r!=null)?Ol(e,s):In),t=new t(l,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ei,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=i),t}function Tc(e,t,l,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(l,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(l,r),t.state!==e&&Ei.enqueueReplaceState(t,t.state,null)}function ro(e,t,l,r){var s=e.stateNode;s.props=l,s.state=e.memoizedState,s.refs={},Xo(e);var i=t.contextType;typeof i=="object"&&i!==null?s.context=wt(i):(i=dt(t)?Mn:et.current,s.context=Ol(e,i)),s.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(lo(e,t,i,l),s.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(t=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),t!==s.state&&Ei.enqueueReplaceState(s,s.state,null),pi(e,l,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function Bl(e,t){try{var l="",r=t;do l+=Og(r),r=r.return;while(r);var s=l}catch(i){s=`
Error generating stack: `+i.message+`
`+i.stack}return{value:e,source:t,stack:s,digest:null}}function xa(e,t,l){return{value:e,source:null,stack:l??null,digest:t??null}}function so(e,t){try{console.error(t.value)}catch(l){setTimeout(function(){throw l})}}var om=typeof WeakMap=="function"?WeakMap:Map;function Jp(e,t,l){l=tn(-1,l),l.tag=3,l.payload={element:null};var r=t.value;return l.callback=function(){mi||(mi=!0,xo=r),so(e,t)},l}function qp(e,t,l){l=tn(-1,l),l.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var s=t.value;l.payload=function(){return r(s)},l.callback=function(){so(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(l.callback=function(){so(e,t),typeof r!="function"&&(_n===null?_n=new Set([this]):_n.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),l}function Ic(e,t,l){var r=e.pingCache;if(r===null){r=e.pingCache=new om;var s=new Set;r.set(t,s)}else s=r.get(t),s===void 0&&(s=new Set,r.set(t,s));s.has(l)||(s.add(l),e=Sm.bind(null,e,t,l),t.then(e,e))}function Ec(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 Pc(e,t,l,r,s){return e.mode&1?(e.flags|=65536,e.lanes=s,e):(e===t?e.flags|=65536:(e.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(t=tn(-1,1),t.tag=2,kn(l,t,1))),l.lanes|=1),e)}var dm=an.ReactCurrentOwner,at=!1;function tt(e,t,l,r){t.child=e===null?Cp(t,null,l,r):Nl(t,e.child,l,r)}function Ac(e,t,l,r,s){l=l.render;var i=t.ref;return Al(t,s),r=ed(e,t,l,r,i,s),l=td(),e!==null&&!at?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,sn(e,t,s)):(be&&l&&Fo(t),t.flags|=1,tt(e,t,r,s),t.child)}function Rc(e,t,l,r,s){if(e===null){var i=l.type;return typeof i=="function"&&!ud(i)&&i.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(t.tag=15,t.type=i,Zp(e,t,i,r,s)):(e=Js(l.type,null,r,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&s)){var a=i.memoizedProps;if(l=l.compare,l=l!==null?l:Hr,l(a,r)&&e.ref===t.ref)return sn(e,t,s)}return t.flags|=1,e=zn(i,r),e.ref=t.ref,e.return=t,t.child=e}function Zp(e,t,l,r,s){if(e!==null){var i=e.memoizedProps;if(Hr(i,r)&&e.ref===t.ref)if(at=!1,t.pendingProps=r=i,(e.lanes&s)!==0)e.flags&131072&&(at=!0);else return t.lanes=e.lanes,sn(e,t,s)}return io(e,t,l,r,s)}function Vp(e,t,l){var r=t.pendingProps,s=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},xe(Cl,ft),ft|=l;else{if(!(l&1073741824))return e=i!==null?i.baseLanes|l:l,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,xe(Cl,ft),ft|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:l,xe(Cl,ft),ft|=r}else i!==null?(r=i.baseLanes|l,t.memoizedState=null):r=l,xe(Cl,ft),ft|=r;return tt(e,t,s,l),t.child}function ef(e,t){var l=t.ref;(e===null&&l!==null||e!==null&&e.ref!==l)&&(t.flags|=512,t.flags|=2097152)}function io(e,t,l,r,s){var i=dt(l)?Mn:et.current;return i=Ol(t,i),Al(t,s),l=ed(e,t,l,r,i,s),r=td(),e!==null&&!at?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,sn(e,t,s)):(be&&r&&Fo(t),t.flags|=1,tt(e,t,l,s),t.child)}function Lc(e,t,l,r,s){if(dt(l)){var i=!0;ai(t)}else i=!1;if(Al(t,s),t.stateNode===null)Gs(e,t),Xp(t,l,r),ro(t,l,r,s),r=!0;else if(e===null){var a=t.stateNode,u=t.memoizedProps;a.props=u;var p=a.context,f=l.contextType;typeof f=="object"&&f!==null?f=wt(f):(f=dt(l)?Mn:et.current,f=Ol(t,f));var g=l.getDerivedStateFromProps,c=typeof g=="function"||typeof a.getSnapshotBeforeUpdate=="function";c||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(u!==r||p!==f)&&Tc(t,a,r,f),hn=!1;var o=t.memoizedState;a.state=o,pi(t,r,a,s),p=t.memoizedState,u!==r||o!==p||ot.current||hn?(typeof g=="function"&&(lo(t,l,g,r),p=t.memoizedState),(u=hn||zc(t,l,u,r,o,p,f))?(c||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=f,r=u):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Tp(e,t),u=t.memoizedProps,f=t.type===t.elementType?u:It(t.type,u),a.props=f,c=t.pendingProps,o=a.context,p=l.contextType,typeof p=="object"&&p!==null?p=wt(p):(p=dt(l)?Mn:et.current,p=Ol(t,p));var m=l.getDerivedStateFromProps;(g=typeof m=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(u!==c||o!==p)&&Tc(t,a,r,p),hn=!1,o=t.memoizedState,a.state=o,pi(t,r,a,s);var j=t.memoizedState;u!==c||o!==j||ot.current||hn?(typeof m=="function"&&(lo(t,l,m,r),j=t.memoizedState),(f=hn||zc(t,l,f,r,o,j,p)||!1)?(g||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,j,p),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,j,p)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||u===e.memoizedProps&&o===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||u===e.memoizedProps&&o===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=j),a.props=r,a.state=j,a.context=p,r=f):(typeof a.componentDidUpdate!="function"||u===e.memoizedProps&&o===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||u===e.memoizedProps&&o===e.memoizedState||(t.flags|=1024),r=!1)}return ao(e,t,l,r,i,s)}function ao(e,t,l,r,s,i){ef(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&vc(t,l,!1),sn(e,t,i);r=t.stateNode,dm.current=t;var u=a&&typeof l.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=Nl(t,e.child,null,i),t.child=Nl(t,null,u,i)):tt(e,t,u,i),t.memoizedState=r.state,s&&vc(t,l,!0),t.child}function tf(e){var t=e.stateNode;t.pendingContext?yc(e,t.pendingContext,t.pendingContext!==t.context):t.context&&yc(e,t.context,!1),Jo(e,t.containerInfo)}function Oc(e,t,l,r,s){return Dl(),Ho(s),t.flags|=256,tt(e,t,l,r),t.child}var oo={dehydrated:null,treeContext:null,retryLane:0};function co(e){return{baseLanes:e,cachePool:null,transitions:null}}function nf(e,t,l){var r=t.pendingProps,s=we.current,i=!1,a=(t.flags&128)!==0,u;if((u=a)||(u=e!==null&&e.memoizedState===null?!1:(s&2)!==0),u?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),xe(we,s&1),e===null)return to(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(a=r.children,e=r.fallback,i?(r=t.mode,i=t.child,a={mode:"hidden",children:a},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=a):i=Ri(a,r,0,null),e=Fn(e,r,l,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=co(l),t.memoizedState=oo,e):rd(t,a));if(s=e.memoizedState,s!==null&&(u=s.dehydrated,u!==null))return cm(e,t,a,r,u,s,l);if(i){i=r.fallback,a=t.mode,s=e.child,u=s.sibling;var p={mode:"hidden",children:r.children};return!(a&1)&&t.child!==s?(r=t.child,r.childLanes=0,r.pendingProps=p,t.deletions=null):(r=zn(s,p),r.subtreeFlags=s.subtreeFlags&14680064),u!==null?i=zn(u,i):(i=Fn(i,a,l,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,a=e.child.memoizedState,a=a===null?co(l):{baseLanes:a.baseLanes|l,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~l,t.memoizedState=oo,r}return i=e.child,e=i.sibling,r=zn(i,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=l),r.return=t,r.sibling=null,e!==null&&(l=t.deletions,l===null?(t.deletions=[e],t.flags|=16):l.push(e)),t.child=r,t.memoizedState=null,r}function rd(e,t){return t=Ri({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function zs(e,t,l,r){return r!==null&&Ho(r),Nl(t,e.child,null,l),e=rd(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function cm(e,t,l,r,s,i,a){if(l)return t.flags&256?(t.flags&=-257,r=xa(Error(B(422))),zs(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,s=t.mode,r=Ri({mode:"visible",children:r.children},s,0,null),i=Fn(i,s,a,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&Nl(t,e.child,null,a),t.child.memoizedState=co(a),t.memoizedState=oo,i);if(!(t.mode&1))return zs(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var u=r.dgst;return r=u,i=Error(B(419)),r=xa(i,r,void 0),zs(e,t,a,r)}if(u=(a&e.childLanes)!==0,at||u){if(r=He,r!==null){switch(a&-a){case 4:s=2;break;case 16:s=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:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(r.suspendedLanes|a)?0:s,s!==0&&s!==i.retryLane&&(i.retryLane=s,rn(e,s),Lt(r,e,s,-1))}return cd(),r=xa(Error(B(421))),zs(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=wm.bind(null,e),s._reactRetry=t,null):(e=i.treeContext,ht=wn(s.nextSibling),gt=t,be=!0,Pt=null,e!==null&&(vt[jt++]=Vt,vt[jt++]=en,vt[jt++]=Hn,Vt=e.id,en=e.overflow,Hn=t),t=rd(t,r.children),t.flags|=4096,t)}function Dc(e,t,l){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),no(e.return,t,l)}function ma(e,t,l,r,s){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:l,tailMode:s}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=l,i.tailMode=s)}function lf(e,t,l){var r=t.pendingProps,s=r.revealOrder,i=r.tail;if(tt(e,t,r.children,l),r=we.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Dc(e,l,t);else if(e.tag===19)Dc(e,l,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(xe(we,r),!(t.mode&1))t.memoizedState=null;else switch(s){case"forwards":for(l=t.child,s=null;l!==null;)e=l.alternate,e!==null&&fi(e)===null&&(s=l),l=l.sibling;l=s,l===null?(s=t.child,t.child=null):(s=l.sibling,l.sibling=null),ma(t,!1,s,l,i);break;case"backwards":for(l=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&fi(e)===null){t.child=s;break}e=s.sibling,s.sibling=l,l=s,s=e}ma(t,!0,l,null,i);break;case"together":ma(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Gs(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function sn(e,t,l){if(e!==null&&(t.dependencies=e.dependencies),Qn|=t.lanes,!(l&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(B(153));if(t.child!==null){for(e=t.child,l=zn(e,e.pendingProps),t.child=l,l.return=t;e.sibling!==null;)e=e.sibling,l=l.sibling=zn(e,e.pendingProps),l.return=t;l.sibling=null}return t.child}function um(e,t,l){switch(t.tag){case 3:tf(t),Dl();break;case 5:Ip(t);break;case 1:dt(t.type)&&ai(t);break;case 4:Jo(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;xe(ci,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(xe(we,we.current&1),t.flags|=128,null):l&t.child.childLanes?nf(e,t,l):(xe(we,we.current&1),e=sn(e,t,l),e!==null?e.sibling:null);xe(we,we.current&1);break;case 19:if(r=(l&t.childLanes)!==0,e.flags&128){if(r)return lf(e,t,l);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),xe(we,we.current),r)break;return null;case 22:case 23:return t.lanes=0,Vp(e,t,l)}return sn(e,t,l)}var rf,uo,sf,af;rf=function(e,t){for(var l=t.child;l!==null;){if(l.tag===5||l.tag===6)e.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===t)break;for(;l.sibling===null;){if(l.return===null||l.return===t)return;l=l.return}l.sibling.return=l.return,l=l.sibling}};uo=function(){};sf=function(e,t,l,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,$n(Ft.current);var i=null;switch(l){case"input":s=Aa(e,s),r=Aa(e,r),i=[];break;case"select":s=_e({},s,{value:void 0}),r=_e({},r,{value:void 0}),i=[];break;case"textarea":s=Oa(e,s),r=Oa(e,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=si)}Na(l,r);var a;l=null;for(f in s)if(!r.hasOwnProperty(f)&&s.hasOwnProperty(f)&&s[f]!=null)if(f==="style"){var u=s[f];for(a in u)u.hasOwnProperty(a)&&(l||(l={}),l[a]="")}else f!=="dangerouslySetInnerHTML"&&f!=="children"&&f!=="suppressContentEditableWarning"&&f!=="suppressHydrationWarning"&&f!=="autoFocus"&&(Nr.hasOwnProperty(f)?i||(i=[]):(i=i||[]).push(f,null));for(f in r){var p=r[f];if(u=s!=null?s[f]:void 0,r.hasOwnProperty(f)&&p!==u&&(p!=null||u!=null))if(f==="style")if(u){for(a in u)!u.hasOwnProperty(a)||p&&p.hasOwnProperty(a)||(l||(l={}),l[a]="");for(a in p)p.hasOwnProperty(a)&&u[a]!==p[a]&&(l||(l={}),l[a]=p[a])}else l||(i||(i=[]),i.push(f,l)),l=p;else f==="dangerouslySetInnerHTML"?(p=p?p.__html:void 0,u=u?u.__html:void 0,p!=null&&u!==p&&(i=i||[]).push(f,p)):f==="children"?typeof p!="string"&&typeof p!="number"||(i=i||[]).push(f,""+p):f!=="suppressContentEditableWarning"&&f!=="suppressHydrationWarning"&&(Nr.hasOwnProperty(f)?(p!=null&&f==="onScroll"&&me("scroll",e),i||u===p||(i=[])):(i=i||[]).push(f,p))}l&&(i=i||[]).push("style",l);var f=i;(t.updateQueue=f)&&(t.flags|=4)}};af=function(e,t,l,r){l!==r&&(t.flags|=4)};function dr(e,t){if(!be)switch(e.tailMode){case"hidden":t=e.tail;for(var l=null;t!==null;)t.alternate!==null&&(l=t),t=t.sibling;l===null?e.tail=null:l.sibling=null;break;case"collapsed":l=e.tail;for(var r=null;l!==null;)l.alternate!==null&&(r=l),l=l.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Ze(e){var t=e.alternate!==null&&e.alternate.child===e.child,l=0,r=0;if(t)for(var s=e.child;s!==null;)l|=s.lanes|s.childLanes,r|=s.subtreeFlags&14680064,r|=s.flags&14680064,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)l|=s.lanes|s.childLanes,r|=s.subtreeFlags,r|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=r,e.childLanes=l,t}function pm(e,t,l){var r=t.pendingProps;switch(Mo(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ze(t),null;case 1:return dt(t.type)&&ii(),Ze(t),null;case 3:return r=t.stateNode,Wl(),ye(ot),ye(et),Zo(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(_s(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Pt!==null&&(vo(Pt),Pt=null))),uo(e,t),Ze(t),null;case 5:qo(t);var s=$n(Xr.current);if(l=t.type,e!==null&&t.stateNode!=null)sf(e,t,l,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(B(166));return Ze(t),null}if(e=$n(Ft.current),_s(t)){r=t.stateNode,l=t.type;var i=t.memoizedProps;switch(r[$t]=t,r[Gr]=i,e=(t.mode&1)!==0,l){case"dialog":me("cancel",r),me("close",r);break;case"iframe":case"object":case"embed":me("load",r);break;case"video":case"audio":for(s=0;s<Cr.length;s++)me(Cr[s],r);break;case"source":me("error",r);break;case"img":case"image":case"link":me("error",r),me("load",r);break;case"details":me("toggle",r);break;case"input":Kd(r,i),me("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},me("invalid",r);break;case"textarea":Gd(r,i),me("invalid",r)}Na(l,i),s=null;for(var a in i)if(i.hasOwnProperty(a)){var u=i[a];a==="children"?typeof u=="string"?r.textContent!==u&&(i.suppressHydrationWarning!==!0&&ks(r.textContent,u,e),s=["children",u]):typeof u=="number"&&r.textContent!==""+u&&(i.suppressHydrationWarning!==!0&&ks(r.textContent,u,e),s=["children",""+u]):Nr.hasOwnProperty(a)&&u!=null&&a==="onScroll"&&me("scroll",r)}switch(l){case"input":xs(r),Qd(r,i,!0);break;case"textarea":xs(r),Yd(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=si)}r=s,t.updateQueue=r,r!==null&&(t.flags|=4)}else{a=s.nodeType===9?s:s.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Lu(l)),e==="http://www.w3.org/1999/xhtml"?l==="script"?(e=a.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(l,{is:r.is}):(e=a.createElement(l),l==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,l),e[$t]=t,e[Gr]=r,rf(e,t,!1,!1),t.stateNode=e;e:{switch(a=Wa(l,r),l){case"dialog":me("cancel",e),me("close",e),s=r;break;case"iframe":case"object":case"embed":me("load",e),s=r;break;case"video":case"audio":for(s=0;s<Cr.length;s++)me(Cr[s],e);s=r;break;case"source":me("error",e),s=r;break;case"img":case"image":case"link":me("error",e),me("load",e),s=r;break;case"details":me("toggle",e),s=r;break;case"input":Kd(e,r),s=Aa(e,r),me("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=_e({},r,{value:void 0}),me("invalid",e);break;case"textarea":Gd(e,r),s=Oa(e,r),me("invalid",e);break;default:s=r}Na(l,s),u=s;for(i in u)if(u.hasOwnProperty(i)){var p=u[i];i==="style"?Nu(e,p):i==="dangerouslySetInnerHTML"?(p=p?p.__html:void 0,p!=null&&Ou(e,p)):i==="children"?typeof p=="string"?(l!=="textarea"||p!=="")&&Wr(e,p):typeof p=="number"&&Wr(e,""+p):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Nr.hasOwnProperty(i)?p!=null&&i==="onScroll"&&me("scroll",e):p!=null&&To(e,i,p,a))}switch(l){case"input":xs(e),Qd(e,r,!1);break;case"textarea":xs(e),Yd(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Tn(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?Tl(e,!!r.multiple,i,!1):r.defaultValue!=null&&Tl(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=si)}switch(l){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Ze(t),null;case 6:if(e&&t.stateNode!=null)af(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(B(166));if(l=$n(Xr.current),$n(Ft.current),_s(t)){if(r=t.stateNode,l=t.memoizedProps,r[$t]=t,(i=r.nodeValue!==l)&&(e=gt,e!==null))switch(e.tag){case 3:ks(r.nodeValue,l,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&ks(r.nodeValue,l,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(l.nodeType===9?l:l.ownerDocument).createTextNode(r),r[$t]=t,t.stateNode=r}return Ze(t),null;case 13:if(ye(we),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(be&&ht!==null&&t.mode&1&&!(t.flags&128))kp(),Dl(),t.flags|=98560,i=!1;else if(i=_s(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(B(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(B(317));i[$t]=t}else Dl(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ze(t),i=!1}else Pt!==null&&(vo(Pt),Pt=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=l,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||we.current&1?Ue===0&&(Ue=3):cd())),t.updateQueue!==null&&(t.flags|=4),Ze(t),null);case 4:return Wl(),uo(e,t),e===null&&Kr(t.stateNode.containerInfo),Ze(t),null;case 10:return Go(t.type._context),Ze(t),null;case 17:return dt(t.type)&&ii(),Ze(t),null;case 19:if(ye(we),i=t.memoizedState,i===null)return Ze(t),null;if(r=(t.flags&128)!==0,a=i.rendering,a===null)if(r)dr(i,!1);else{if(Ue!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=fi(e),a!==null){for(t.flags|=128,dr(i,!1),r=a.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=l,l=t.child;l!==null;)i=l,e=r,i.flags&=14680066,a=i.alternate,a===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,e=a.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),l=l.sibling;return xe(we,we.current&1|2),t.child}e=e.sibling}i.tail!==null&&Ee()>$l&&(t.flags|=128,r=!0,dr(i,!1),t.lanes=4194304)}else{if(!r)if(e=fi(a),e!==null){if(t.flags|=128,r=!0,l=e.updateQueue,l!==null&&(t.updateQueue=l,t.flags|=4),dr(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!be)return Ze(t),null}else 2*Ee()-i.renderingStartTime>$l&&l!==1073741824&&(t.flags|=128,r=!0,dr(i,!1),t.lanes=4194304);i.isBackwards?(a.sibling=t.child,t.child=a):(l=i.last,l!==null?l.sibling=a:t.child=a,i.last=a)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Ee(),t.sibling=null,l=we.current,xe(we,r?l&1|2:l&1),t):(Ze(t),null);case 22:case 23:return dd(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ft&1073741824&&(Ze(t),t.subtreeFlags&6&&(t.flags|=8192)):Ze(t),null;case 24:return null;case 25:return null}throw Error(B(156,t.tag))}function fm(e,t){switch(Mo(t),t.tag){case 1:return dt(t.type)&&ii(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Wl(),ye(ot),ye(et),Zo(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return qo(t),null;case 13:if(ye(we),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(B(340));Dl()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ye(we),null;case 4:return Wl(),null;case 10:return Go(t.type._context),null;case 22:case 23:return dd(),null;case 24:return null;default:return null}}var Ts=!1,Ve=!1,hm=typeof WeakSet=="function"?WeakSet:Set,H=null;function _l(e,t){var l=e.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(r){ze(e,t,r)}else l.current=null}function po(e,t,l){try{l()}catch(r){ze(e,t,r)}}var Nc=!1;function gm(e,t){if(Ya=ni,e=up(),Uo(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var r=l.getSelection&&l.getSelection();if(r&&r.rangeCount!==0){l=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{l.nodeType,i.nodeType}catch{l=null;break e}var a=0,u=-1,p=-1,f=0,g=0,c=e,o=null;t:for(;;){for(var m;c!==l||s!==0&&c.nodeType!==3||(u=a+s),c!==i||r!==0&&c.nodeType!==3||(p=a+r),c.nodeType===3&&(a+=c.nodeValue.length),(m=c.firstChild)!==null;)o=c,c=m;for(;;){if(c===e)break t;if(o===l&&++f===s&&(u=a),o===i&&++g===r&&(p=a),(m=c.nextSibling)!==null)break;c=o,o=c.parentNode}c=m}l=u===-1||p===-1?null:{start:u,end:p}}else l=null}l=l||{start:0,end:0}}else l=null;for(Xa={focusedElem:e,selectionRange:l},ni=!1,H=t;H!==null;)if(t=H,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,H=e;else for(;H!==null;){t=H;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,C=j.memoizedState,y=t.stateNode,x=y.getSnapshotBeforeUpdate(t.elementType===t.type?h:It(t.type,h),C);y.__reactInternalSnapshotBeforeUpdate=x}break;case 3:var d=t.stateNode.containerInfo;d.nodeType===1?d.textContent="":d.nodeType===9&&d.documentElement&&d.removeChild(d.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(B(163))}}catch(v){ze(t,t.return,v)}if(e=t.sibling,e!==null){e.return=t.return,H=e;break}H=t.return}return j=Nc,Nc=!1,j}function Lr(e,t,l){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&po(t,l,i)}s=s.next}while(s!==r)}}function Pi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var l=t=t.next;do{if((l.tag&e)===e){var r=l.create;l.destroy=r()}l=l.next}while(l!==t)}}function fo(e){var t=e.ref;if(t!==null){var l=e.stateNode;switch(e.tag){case 5:e=l;break;default:e=l}typeof t=="function"?t(e):t.current=e}}function of(e){var t=e.alternate;t!==null&&(e.alternate=null,of(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[$t],delete t[Gr],delete t[Za],delete t[qx],delete t[Zx])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function df(e){return e.tag===5||e.tag===3||e.tag===4}function Wc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||df(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ho(e,t,l){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?l.nodeType===8?l.parentNode.insertBefore(e,t):l.insertBefore(e,t):(l.nodeType===8?(t=l.parentNode,t.insertBefore(e,l)):(t=l,t.appendChild(e)),l=l._reactRootContainer,l!=null||t.onclick!==null||(t.onclick=si));else if(r!==4&&(e=e.child,e!==null))for(ho(e,t,l),e=e.sibling;e!==null;)ho(e,t,l),e=e.sibling}function go(e,t,l){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?l.insertBefore(e,t):l.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(go(e,t,l),e=e.sibling;e!==null;)go(e,t,l),e=e.sibling}var Ge=null,Et=!1;function un(e,t,l){for(l=l.child;l!==null;)cf(e,t,l),l=l.sibling}function cf(e,t,l){if(Ut&&typeof Ut.onCommitFiberUnmount=="function")try{Ut.onCommitFiberUnmount(wi,l)}catch{}switch(l.tag){case 5:Ve||_l(l,t);case 6:var r=Ge,s=Et;Ge=null,un(e,t,l),Ge=r,Et=s,Ge!==null&&(Et?(e=Ge,l=l.stateNode,e.nodeType===8?e.parentNode.removeChild(l):e.removeChild(l)):Ge.removeChild(l.stateNode));break;case 18:Ge!==null&&(Et?(e=Ge,l=l.stateNode,e.nodeType===8?ca(e.parentNode,l):e.nodeType===1&&ca(e,l),Fr(e)):ca(Ge,l.stateNode));break;case 4:r=Ge,s=Et,Ge=l.stateNode.containerInfo,Et=!0,un(e,t,l),Ge=r,Et=s;break;case 0:case 11:case 14:case 15:if(!Ve&&(r=l.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,a=i.destroy;i=i.tag,a!==void 0&&(i&2||i&4)&&po(l,t,a),s=s.next}while(s!==r)}un(e,t,l);break;case 1:if(!Ve&&(_l(l,t),r=l.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=l.memoizedProps,r.state=l.memoizedState,r.componentWillUnmount()}catch(u){ze(l,t,u)}un(e,t,l);break;case 21:un(e,t,l);break;case 22:l.mode&1?(Ve=(r=Ve)||l.memoizedState!==null,un(e,t,l),Ve=r):un(e,t,l);break;default:un(e,t,l)}}function Bc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var l=e.stateNode;l===null&&(l=e.stateNode=new hm),t.forEach(function(r){var s=km.bind(null,e,r);l.has(r)||(l.add(r),r.then(s,s))})}}function Tt(e,t){var l=t.deletions;if(l!==null)for(var r=0;r<l.length;r++){var s=l[r];try{var i=e,a=t,u=a;e:for(;u!==null;){switch(u.tag){case 5:Ge=u.stateNode,Et=!1;break e;case 3:Ge=u.stateNode.containerInfo,Et=!0;break e;case 4:Ge=u.stateNode.containerInfo,Et=!0;break e}u=u.return}if(Ge===null)throw Error(B(160));cf(i,a,s),Ge=null,Et=!1;var p=s.alternate;p!==null&&(p.return=null),s.return=null}catch(f){ze(s,t,f)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)uf(t,e),t=t.sibling}function uf(e,t){var l=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Tt(t,e),Wt(e),r&4){try{Lr(3,e,e.return),Pi(3,e)}catch(h){ze(e,e.return,h)}try{Lr(5,e,e.return)}catch(h){ze(e,e.return,h)}}break;case 1:Tt(t,e),Wt(e),r&512&&l!==null&&_l(l,l.return);break;case 5:if(Tt(t,e),Wt(e),r&512&&l!==null&&_l(l,l.return),e.flags&32){var s=e.stateNode;try{Wr(s,"")}catch(h){ze(e,e.return,h)}}if(r&4&&(s=e.stateNode,s!=null)){var i=e.memoizedProps,a=l!==null?l.memoizedProps:i,u=e.type,p=e.updateQueue;if(e.updateQueue=null,p!==null)try{u==="input"&&i.type==="radio"&&i.name!=null&&Au(s,i),Wa(u,a);var f=Wa(u,i);for(a=0;a<p.length;a+=2){var g=p[a],c=p[a+1];g==="style"?Nu(s,c):g==="dangerouslySetInnerHTML"?Ou(s,c):g==="children"?Wr(s,c):To(s,g,c,f)}switch(u){case"input":Ra(s,i);break;case"textarea":Ru(s,i);break;case"select":var o=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var m=i.value;m!=null?Tl(s,!!i.multiple,m,!1):o!==!!i.multiple&&(i.defaultValue!=null?Tl(s,!!i.multiple,i.defaultValue,!0):Tl(s,!!i.multiple,i.multiple?[]:"",!1))}s[Gr]=i}catch(h){ze(e,e.return,h)}}break;case 6:if(Tt(t,e),Wt(e),r&4){if(e.stateNode===null)throw Error(B(162));s=e.stateNode,i=e.memoizedProps;try{s.nodeValue=i}catch(h){ze(e,e.return,h)}}break;case 3:if(Tt(t,e),Wt(e),r&4&&l!==null&&l.memoizedState.isDehydrated)try{Fr(t.containerInfo)}catch(h){ze(e,e.return,h)}break;case 4:Tt(t,e),Wt(e);break;case 13:Tt(t,e),Wt(e),s=e.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(ad=Ee())),r&4&&Bc(e);break;case 22:if(g=l!==null&&l.memoizedState!==null,e.mode&1?(Ve=(f=Ve)||g,Tt(t,e),Ve=f):Tt(t,e),Wt(e),r&8192){if(f=e.memoizedState!==null,(e.stateNode.isHidden=f)&&!g&&e.mode&1)for(H=e,g=e.child;g!==null;){for(c=H=g;H!==null;){switch(o=H,m=o.child,o.tag){case 0:case 11:case 14:case 15:Lr(4,o,o.return);break;case 1:_l(o,o.return);var j=o.stateNode;if(typeof j.componentWillUnmount=="function"){r=o,l=o.return;try{t=r,j.props=t.memoizedProps,j.state=t.memoizedState,j.componentWillUnmount()}catch(h){ze(r,l,h)}}break;case 5:_l(o,o.return);break;case 22:if(o.memoizedState!==null){Uc(c);continue}}m!==null?(m.return=o,H=m):Uc(c)}g=g.sibling}e:for(g=null,c=e;;){if(c.tag===5){if(g===null){g=c;try{s=c.stateNode,f?(i=s.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(u=c.stateNode,p=c.memoizedProps.style,a=p!=null&&p.hasOwnProperty("display")?p.display:null,u.style.display=Du("display",a))}catch(h){ze(e,e.return,h)}}}else if(c.tag===6){if(g===null)try{c.stateNode.nodeValue=f?"":c.memoizedProps}catch(h){ze(e,e.return,h)}}else if((c.tag!==22&&c.tag!==23||c.memoizedState===null||c===e)&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===e)break e;for(;c.sibling===null;){if(c.return===null||c.return===e)break e;g===c&&(g=null),c=c.return}g===c&&(g=null),c.sibling.return=c.return,c=c.sibling}}break;case 19:Tt(t,e),Wt(e),r&4&&Bc(e);break;case 21:break;default:Tt(t,e),Wt(e)}}function Wt(e){var t=e.flags;if(t&2){try{e:{for(var l=e.return;l!==null;){if(df(l)){var r=l;break e}l=l.return}throw Error(B(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Wr(s,""),r.flags&=-33);var i=Wc(e);go(e,i,s);break;case 3:case 4:var a=r.stateNode.containerInfo,u=Wc(e);ho(e,u,a);break;default:throw Error(B(161))}}catch(p){ze(e,e.return,p)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function xm(e,t,l){H=e,pf(e)}function pf(e,t,l){for(var r=(e.mode&1)!==0;H!==null;){var s=H,i=s.child;if(s.tag===22&&r){var a=s.memoizedState!==null||Ts;if(!a){var u=s.alternate,p=u!==null&&u.memoizedState!==null||Ve;u=Ts;var f=Ve;if(Ts=a,(Ve=p)&&!f)for(H=s;H!==null;)a=H,p=a.child,a.tag===22&&a.memoizedState!==null?Fc(s):p!==null?(p.return=a,H=p):Fc(s);for(;i!==null;)H=i,pf(i),i=i.sibling;H=s,Ts=u,Ve=f}$c(e)}else s.subtreeFlags&8772&&i!==null?(i.return=s,H=i):$c(e)}}function $c(e){for(;H!==null;){var t=H;if(t.flags&8772){var l=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Ve||Pi(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Ve)if(l===null)r.componentDidMount();else{var s=t.elementType===t.type?l.memoizedProps:It(t.type,l.memoizedProps);r.componentDidUpdate(s,l.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&kc(t,i,r);break;case 3:var a=t.updateQueue;if(a!==null){if(l=null,t.child!==null)switch(t.child.tag){case 5:l=t.child.stateNode;break;case 1:l=t.child.stateNode}kc(t,a,l)}break;case 5:var u=t.stateNode;if(l===null&&t.flags&4){l=u;var p=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":p.autoFocus&&l.focus();break;case"img":p.src&&(l.src=p.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var f=t.alternate;if(f!==null){var g=f.memoizedState;if(g!==null){var c=g.dehydrated;c!==null&&Fr(c)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(B(163))}Ve||t.flags&512&&fo(t)}catch(o){ze(t,t.return,o)}}if(t===e){H=null;break}if(l=t.sibling,l!==null){l.return=t.return,H=l;break}H=t.return}}function Uc(e){for(;H!==null;){var t=H;if(t===e){H=null;break}var l=t.sibling;if(l!==null){l.return=t.return,H=l;break}H=t.return}}function Fc(e){for(;H!==null;){var t=H;try{switch(t.tag){case 0:case 11:case 15:var l=t.return;try{Pi(4,t)}catch(p){ze(t,l,p)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(p){ze(t,s,p)}}var i=t.return;try{fo(t)}catch(p){ze(t,i,p)}break;case 5:var a=t.return;try{fo(t)}catch(p){ze(t,a,p)}}}catch(p){ze(t,t.return,p)}if(t===e){H=null;break}var u=t.sibling;if(u!==null){u.return=t.return,H=u;break}H=t.return}}var mm=Math.ceil,xi=an.ReactCurrentDispatcher,sd=an.ReactCurrentOwner,St=an.ReactCurrentBatchConfig,ce=0,He=null,Le=null,Ye=0,ft=0,Cl=An(0),Ue=0,Vr=null,Qn=0,Ai=0,id=0,Or=null,it=null,ad=0,$l=1/0,qt=null,mi=!1,xo=null,_n=null,Is=!1,yn=null,yi=0,Dr=0,mo=null,Ys=-1,Xs=0;function nt(){return ce&6?Ee():Ys!==-1?Ys:Ys=Ee()}function Cn(e){return e.mode&1?ce&2&&Ye!==0?Ye&-Ye:em.transition!==null?(Xs===0&&(Xs=Xu()),Xs):(e=fe,e!==0||(e=window.event,e=e===void 0?16:np(e.type)),e):1}function Lt(e,t,l,r){if(50<Dr)throw Dr=0,mo=null,Error(B(185));ts(e,l,r),(!(ce&2)||e!==He)&&(e===He&&(!(ce&2)&&(Ai|=l),Ue===4&&xn(e,Ye)),ct(e,r),l===1&&ce===0&&!(t.mode&1)&&($l=Ee()+500,Ti&&Rn()))}function ct(e,t){var l=e.callbackNode;ex(e,t);var r=ti(e,e===He?Ye:0);if(r===0)l!==null&&qd(l),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(l!=null&&qd(l),t===1)e.tag===0?Vx(Mc.bind(null,e)):bp(Mc.bind(null,e)),Xx(function(){!(ce&6)&&Rn()}),l=null;else{switch(Ju(r)){case 1:l=Ro;break;case 4:l=Gu;break;case 16:l=ei;break;case 536870912:l=Yu;break;default:l=ei}l=jf(l,ff.bind(null,e))}e.callbackPriority=t,e.callbackNode=l}}function ff(e,t){if(Ys=-1,Xs=0,ce&6)throw Error(B(327));var l=e.callbackNode;if(Rl()&&e.callbackNode!==l)return null;var r=ti(e,e===He?Ye:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=vi(e,r);else{t=r;var s=ce;ce|=2;var i=gf();(He!==e||Ye!==t)&&(qt=null,$l=Ee()+500,Un(e,t));do try{jm();break}catch(u){hf(e,u)}while(!0);Qo(),xi.current=i,ce=s,Le!==null?t=0:(He=null,Ye=0,t=Ue)}if(t!==0){if(t===2&&(s=Ma(e),s!==0&&(r=s,t=yo(e,s))),t===1)throw l=Vr,Un(e,0),xn(e,r),ct(e,Ee()),l;if(t===6)xn(e,r);else{if(s=e.current.alternate,!(r&30)&&!ym(s)&&(t=vi(e,r),t===2&&(i=Ma(e),i!==0&&(r=i,t=yo(e,i))),t===1))throw l=Vr,Un(e,0),xn(e,r),ct(e,Ee()),l;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(B(345));case 2:Nn(e,it,qt);break;case 3:if(xn(e,r),(r&130023424)===r&&(t=ad+500-Ee(),10<t)){if(ti(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){nt(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=qa(Nn.bind(null,e,it,qt),t);break}Nn(e,it,qt);break;case 4:if(xn(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-Rt(r);i=1<<a,a=t[a],a>s&&(s=a),r&=~i}if(r=s,r=Ee()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*mm(r/1960))-r,10<r){e.timeoutHandle=qa(Nn.bind(null,e,it,qt),r);break}Nn(e,it,qt);break;case 5:Nn(e,it,qt);break;default:throw Error(B(329))}}}return ct(e,Ee()),e.callbackNode===l?ff.bind(null,e):null}function yo(e,t){var l=Or;return e.current.memoizedState.isDehydrated&&(Un(e,t).flags|=256),e=vi(e,t),e!==2&&(t=it,it=l,t!==null&&vo(t)),e}function vo(e){it===null?it=e:it.push.apply(it,e)}function ym(e){for(var t=e;;){if(t.flags&16384){var l=t.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var r=0;r<l.length;r++){var s=l[r],i=s.getSnapshot;s=s.value;try{if(!Ot(i(),s))return!1}catch{return!1}}}if(l=t.child,t.subtreeFlags&16384&&l!==null)l.return=t,t=l;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 xn(e,t){for(t&=~id,t&=~Ai,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var l=31-Rt(t),r=1<<l;e[l]=-1,t&=~r}}function Mc(e){if(ce&6)throw Error(B(327));Rl();var t=ti(e,0);if(!(t&1))return ct(e,Ee()),null;var l=vi(e,t);if(e.tag!==0&&l===2){var r=Ma(e);r!==0&&(t=r,l=yo(e,r))}if(l===1)throw l=Vr,Un(e,0),xn(e,t),ct(e,Ee()),l;if(l===6)throw Error(B(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Nn(e,it,qt),ct(e,Ee()),null}function od(e,t){var l=ce;ce|=1;try{return e(t)}finally{ce=l,ce===0&&($l=Ee()+500,Ti&&Rn())}}function Gn(e){yn!==null&&yn.tag===0&&!(ce&6)&&Rl();var t=ce;ce|=1;var l=St.transition,r=fe;try{if(St.transition=null,fe=1,e)return e()}finally{fe=r,St.transition=l,ce=t,!(ce&6)&&Rn()}}function dd(){ft=Cl.current,ye(Cl)}function Un(e,t){e.finishedWork=null,e.finishedLanes=0;var l=e.timeoutHandle;if(l!==-1&&(e.timeoutHandle=-1,Yx(l)),Le!==null)for(l=Le.return;l!==null;){var r=l;switch(Mo(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&ii();break;case 3:Wl(),ye(ot),ye(et),Zo();break;case 5:qo(r);break;case 4:Wl();break;case 13:ye(we);break;case 19:ye(we);break;case 10:Go(r.type._context);break;case 22:case 23:dd()}l=l.return}if(He=e,Le=e=zn(e.current,null),Ye=ft=t,Ue=0,Vr=null,id=Ai=Qn=0,it=Or=null,Bn!==null){for(t=0;t<Bn.length;t++)if(l=Bn[t],r=l.interleaved,r!==null){l.interleaved=null;var s=r.next,i=l.pending;if(i!==null){var a=i.next;i.next=s,r.next=a}l.pending=r}Bn=null}return e}function hf(e,t){do{var l=Le;try{if(Qo(),Ks.current=gi,hi){for(var r=ke.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}hi=!1}if(Kn=0,Me=$e=ke=null,Rr=!1,Jr=0,sd.current=null,l===null||l.return===null){Ue=1,Vr=t,Le=null;break}e:{var i=e,a=l.return,u=l,p=t;if(t=Ye,u.flags|=32768,p!==null&&typeof p=="object"&&typeof p.then=="function"){var f=p,g=u,c=g.tag;if(!(g.mode&1)&&(c===0||c===11||c===15)){var o=g.alternate;o?(g.updateQueue=o.updateQueue,g.memoizedState=o.memoizedState,g.lanes=o.lanes):(g.updateQueue=null,g.memoizedState=null)}var m=Ec(a);if(m!==null){m.flags&=-257,Pc(m,a,u,i,t),m.mode&1&&Ic(i,f,t),t=m,p=f;var j=t.updateQueue;if(j===null){var h=new Set;h.add(p),t.updateQueue=h}else j.add(p);break e}else{if(!(t&1)){Ic(i,f,t),cd();break e}p=Error(B(426))}}else if(be&&u.mode&1){var C=Ec(a);if(C!==null){!(C.flags&65536)&&(C.flags|=256),Pc(C,a,u,i,t),Ho(Bl(p,u));break e}}i=p=Bl(p,u),Ue!==4&&(Ue=2),Or===null?Or=[i]:Or.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var y=Jp(i,p,t);wc(i,y);break e;case 1:u=p;var x=i.type,d=i.stateNode;if(!(i.flags&128)&&(typeof x.getDerivedStateFromError=="function"||d!==null&&typeof d.componentDidCatch=="function"&&(_n===null||!_n.has(d)))){i.flags|=65536,t&=-t,i.lanes|=t;var v=qp(i,u,t);wc(i,v);break e}}i=i.return}while(i!==null)}mf(l)}catch(z){t=z,Le===l&&l!==null&&(Le=l=l.return);continue}break}while(!0)}function gf(){var e=xi.current;return xi.current=gi,e===null?gi:e}function cd(){(Ue===0||Ue===3||Ue===2)&&(Ue=4),He===null||!(Qn&268435455)&&!(Ai&268435455)||xn(He,Ye)}function vi(e,t){var l=ce;ce|=2;var r=gf();(He!==e||Ye!==t)&&(qt=null,Un(e,t));do try{vm();break}catch(s){hf(e,s)}while(!0);if(Qo(),ce=l,xi.current=r,Le!==null)throw Error(B(261));return He=null,Ye=0,Ue}function vm(){for(;Le!==null;)xf(Le)}function jm(){for(;Le!==null&&!Kg();)xf(Le)}function xf(e){var t=vf(e.alternate,e,ft);e.memoizedProps=e.pendingProps,t===null?mf(e):Le=t,sd.current=null}function mf(e){var t=e;do{var l=t.alternate;if(e=t.return,t.flags&32768){if(l=fm(l,t),l!==null){l.flags&=32767,Le=l;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Ue=6,Le=null;return}}else if(l=pm(l,t,ft),l!==null){Le=l;return}if(t=t.sibling,t!==null){Le=t;return}Le=t=e}while(t!==null);Ue===0&&(Ue=5)}function Nn(e,t,l){var r=fe,s=St.transition;try{St.transition=null,fe=1,bm(e,t,l,r)}finally{St.transition=s,fe=r}return null}function bm(e,t,l,r){do Rl();while(yn!==null);if(ce&6)throw Error(B(327));l=e.finishedWork;var s=e.finishedLanes;if(l===null)return null;if(e.finishedWork=null,e.finishedLanes=0,l===e.current)throw Error(B(177));e.callbackNode=null,e.callbackPriority=0;var i=l.lanes|l.childLanes;if(tx(e,i),e===He&&(Le=He=null,Ye=0),!(l.subtreeFlags&2064)&&!(l.flags&2064)||Is||(Is=!0,jf(ei,function(){return Rl(),null})),i=(l.flags&15990)!==0,l.subtreeFlags&15990||i){i=St.transition,St.transition=null;var a=fe;fe=1;var u=ce;ce|=4,sd.current=null,gm(e,l),uf(l,e),Ux(Xa),ni=!!Ya,Xa=Ya=null,e.current=l,xm(l),Qg(),ce=u,fe=a,St.transition=i}else e.current=l;if(Is&&(Is=!1,yn=e,yi=s),i=e.pendingLanes,i===0&&(_n=null),Xg(l.stateNode),ct(e,Ee()),t!==null)for(r=e.onRecoverableError,l=0;l<t.length;l++)s=t[l],r(s.value,{componentStack:s.stack,digest:s.digest});if(mi)throw mi=!1,e=xo,xo=null,e;return yi&1&&e.tag!==0&&Rl(),i=e.pendingLanes,i&1?e===mo?Dr++:(Dr=0,mo=e):Dr=0,Rn(),null}function Rl(){if(yn!==null){var e=Ju(yi),t=St.transition,l=fe;try{if(St.transition=null,fe=16>e?16:e,yn===null)var r=!1;else{if(e=yn,yn=null,yi=0,ce&6)throw Error(B(331));var s=ce;for(ce|=4,H=e.current;H!==null;){var i=H,a=i.child;if(H.flags&16){var u=i.deletions;if(u!==null){for(var p=0;p<u.length;p++){var f=u[p];for(H=f;H!==null;){var g=H;switch(g.tag){case 0:case 11:case 15:Lr(8,g,i)}var c=g.child;if(c!==null)c.return=g,H=c;else for(;H!==null;){g=H;var o=g.sibling,m=g.return;if(of(g),g===f){H=null;break}if(o!==null){o.return=m,H=o;break}H=m}}}var j=i.alternate;if(j!==null){var h=j.child;if(h!==null){j.child=null;do{var C=h.sibling;h.sibling=null,h=C}while(h!==null)}}H=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,H=a;else e:for(;H!==null;){if(i=H,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Lr(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,H=y;break e}H=i.return}}var x=e.current;for(H=x;H!==null;){a=H;var d=a.child;if(a.subtreeFlags&2064&&d!==null)d.return=a,H=d;else e:for(a=x;H!==null;){if(u=H,u.flags&2048)try{switch(u.tag){case 0:case 11:case 15:Pi(9,u)}}catch(z){ze(u,u.return,z)}if(u===a){H=null;break e}var v=u.sibling;if(v!==null){v.return=u.return,H=v;break e}H=u.return}}if(ce=s,Rn(),Ut&&typeof Ut.onPostCommitFiberRoot=="function")try{Ut.onPostCommitFiberRoot(wi,e)}catch{}r=!0}return r}finally{fe=l,St.transition=t}}return!1}function Hc(e,t,l){t=Bl(l,t),t=Jp(e,t,1),e=kn(e,t,1),t=nt(),e!==null&&(ts(e,1,t),ct(e,t))}function ze(e,t,l){if(e.tag===3)Hc(e,e,l);else for(;t!==null;){if(t.tag===3){Hc(t,e,l);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(_n===null||!_n.has(r))){e=Bl(l,e),e=qp(t,e,1),t=kn(t,e,1),e=nt(),t!==null&&(ts(t,1,e),ct(t,e));break}}t=t.return}}function Sm(e,t,l){var r=e.pingCache;r!==null&&r.delete(t),t=nt(),e.pingedLanes|=e.suspendedLanes&l,He===e&&(Ye&l)===l&&(Ue===4||Ue===3&&(Ye&130023424)===Ye&&500>Ee()-ad?Un(e,0):id|=l),ct(e,t)}function yf(e,t){t===0&&(e.mode&1?(t=vs,vs<<=1,!(vs&130023424)&&(vs=4194304)):t=1);var l=nt();e=rn(e,t),e!==null&&(ts(e,t,l),ct(e,l))}function wm(e){var t=e.memoizedState,l=0;t!==null&&(l=t.retryLane),yf(e,l)}function km(e,t){var l=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(l=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(B(314))}r!==null&&r.delete(t),yf(e,l)}var vf;vf=function(e,t,l){if(e!==null)if(e.memoizedProps!==t.pendingProps||ot.current)at=!0;else{if(!(e.lanes&l)&&!(t.flags&128))return at=!1,um(e,t,l);at=!!(e.flags&131072)}else at=!1,be&&t.flags&1048576&&Sp(t,di,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Gs(e,t),e=t.pendingProps;var s=Ol(t,et.current);Al(t,l),s=ed(null,t,r,e,s,l);var i=td();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,dt(r)?(i=!0,ai(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Xo(t),s.updater=Ei,t.stateNode=s,s._reactInternals=t,ro(t,r,e,l),t=ao(null,t,r,!0,i,l)):(t.tag=0,be&&i&&Fo(t),tt(null,t,s,l),t=t.child),t;case 16:r=t.elementType;e:{switch(Gs(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=Cm(r),e=It(r,e),s){case 0:t=io(null,t,r,e,l);break e;case 1:t=Lc(null,t,r,e,l);break e;case 11:t=Ac(null,t,r,e,l);break e;case 14:t=Rc(null,t,r,It(r.type,e),l);break e}throw Error(B(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:It(r,s),io(e,t,r,s,l);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:It(r,s),Lc(e,t,r,s,l);case 3:e:{if(tf(t),e===null)throw Error(B(387));r=t.pendingProps,i=t.memoizedState,s=i.element,Tp(e,t),pi(t,r,null,l);var a=t.memoizedState;if(r=a.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=Bl(Error(B(423)),t),t=Oc(e,t,r,l,s);break e}else if(r!==s){s=Bl(Error(B(424)),t),t=Oc(e,t,r,l,s);break e}else for(ht=wn(t.stateNode.containerInfo.firstChild),gt=t,be=!0,Pt=null,l=Cp(t,null,r,l),t.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Dl(),r===s){t=sn(e,t,l);break e}tt(e,t,r,l)}t=t.child}return t;case 5:return Ip(t),e===null&&to(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,a=s.children,Ja(r,s)?a=null:i!==null&&Ja(r,i)&&(t.flags|=32),ef(e,t),tt(e,t,a,l),t.child;case 6:return e===null&&to(t),null;case 13:return nf(e,t,l);case 4:return Jo(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Nl(t,null,r,l):tt(e,t,r,l),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:It(r,s),Ac(e,t,r,s,l);case 7:return tt(e,t,t.pendingProps,l),t.child;case 8:return tt(e,t,t.pendingProps.children,l),t.child;case 12:return tt(e,t,t.pendingProps.children,l),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,a=s.value,xe(ci,r._currentValue),r._currentValue=a,i!==null)if(Ot(i.value,a)){if(i.children===s.children&&!ot.current){t=sn(e,t,l);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var u=i.dependencies;if(u!==null){a=i.child;for(var p=u.firstContext;p!==null;){if(p.context===r){if(i.tag===1){p=tn(-1,l&-l),p.tag=2;var f=i.updateQueue;if(f!==null){f=f.shared;var g=f.pending;g===null?p.next=p:(p.next=g.next,g.next=p),f.pending=p}}i.lanes|=l,p=i.alternate,p!==null&&(p.lanes|=l),no(i.return,l,t),u.lanes|=l;break}p=p.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(B(341));a.lanes|=l,u=a.alternate,u!==null&&(u.lanes|=l),no(a,l,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}tt(e,t,s.children,l),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Al(t,l),s=wt(s),r=r(s),t.flags|=1,tt(e,t,r,l),t.child;case 14:return r=t.type,s=It(r,t.pendingProps),s=It(r.type,s),Rc(e,t,r,s,l);case 15:return Zp(e,t,t.type,t.pendingProps,l);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:It(r,s),Gs(e,t),t.tag=1,dt(r)?(e=!0,ai(t)):e=!1,Al(t,l),Xp(t,r,s),ro(t,r,s,l),ao(null,t,r,!0,e,l);case 19:return lf(e,t,l);case 22:return Vp(e,t,l)}throw Error(B(156,t.tag))};function jf(e,t){return Qu(e,t)}function _m(e,t,l,r){this.tag=e,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function bt(e,t,l,r){return new _m(e,t,l,r)}function ud(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Cm(e){if(typeof e=="function")return ud(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Eo)return 11;if(e===Po)return 14}return 2}function zn(e,t){var l=e.alternate;return l===null?(l=bt(e.tag,t,e.key,e.mode),l.elementType=e.elementType,l.type=e.type,l.stateNode=e.stateNode,l.alternate=e,e.alternate=l):(l.pendingProps=t,l.type=e.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=e.flags&14680064,l.childLanes=e.childLanes,l.lanes=e.lanes,l.child=e.child,l.memoizedProps=e.memoizedProps,l.memoizedState=e.memoizedState,l.updateQueue=e.updateQueue,t=e.dependencies,l.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},l.sibling=e.sibling,l.index=e.index,l.ref=e.ref,l}function Js(e,t,l,r,s,i){var a=2;if(r=e,typeof e=="function")ud(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case xl:return Fn(l.children,s,i,t);case Io:a=8,s|=8;break;case Ta:return e=bt(12,l,t,s|2),e.elementType=Ta,e.lanes=i,e;case Ia:return e=bt(13,l,t,s),e.elementType=Ia,e.lanes=i,e;case Ea:return e=bt(19,l,t,s),e.elementType=Ea,e.lanes=i,e;case Iu:return Ri(l,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case zu:a=10;break e;case Tu:a=9;break e;case Eo:a=11;break e;case Po:a=14;break e;case fn:a=16,r=null;break e}throw Error(B(130,e==null?e:typeof e,""))}return t=bt(a,l,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function Fn(e,t,l,r){return e=bt(7,e,r,t),e.lanes=l,e}function Ri(e,t,l,r){return e=bt(22,e,r,t),e.elementType=Iu,e.lanes=l,e.stateNode={isHidden:!1},e}function ya(e,t,l){return e=bt(6,e,null,t),e.lanes=l,e}function va(e,t,l){return t=bt(4,e.children!==null?e.children:[],e.key,t),t.lanes=l,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function zm(e,t,l,r,s){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=Vi(0),this.expirationTimes=Vi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Vi(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function pd(e,t,l,r,s,i,a,u,p){return e=new zm(e,t,l,u,p),t===1?(t=1,i===!0&&(t|=8)):t=0,i=bt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},Xo(i),e}function Tm(e,t,l){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:gl,key:r==null?null:""+r,children:e,containerInfo:t,implementation:l}}function bf(e){if(!e)return In;e=e._reactInternals;e:{if(Jn(e)!==e||e.tag!==1)throw Error(B(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(dt(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(B(171))}if(e.tag===1){var l=e.type;if(dt(l))return jp(e,l,t)}return t}function Sf(e,t,l,r,s,i,a,u,p){return e=pd(l,r,!0,e,s,i,a,u,p),e.context=bf(null),l=e.current,r=nt(),s=Cn(l),i=tn(r,s),i.callback=t??null,kn(l,i,s),e.current.lanes=s,ts(e,s,r),ct(e,r),e}function Li(e,t,l,r){var s=t.current,i=nt(),a=Cn(s);return l=bf(l),t.context===null?t.context=l:t.pendingContext=l,t=tn(i,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=kn(s,t,a),e!==null&&(Lt(e,s,a,i),Hs(e,s,a)),a}function ji(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 Kc(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<t?l:t}}function fd(e,t){Kc(e,t),(e=e.alternate)&&Kc(e,t)}function Im(){return null}var wf=typeof reportError=="function"?reportError:function(e){console.error(e)};function hd(e){this._internalRoot=e}Oi.prototype.render=hd.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(B(409));Li(e,t,null,null)};Oi.prototype.unmount=hd.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Gn(function(){Li(null,e,null,null)}),t[ln]=null}};function Oi(e){this._internalRoot=e}Oi.prototype.unstable_scheduleHydration=function(e){if(e){var t=Vu();e={blockedOn:null,target:e,priority:t};for(var l=0;l<gn.length&&t!==0&&t<gn[l].priority;l++);gn.splice(l,0,e),l===0&&tp(e)}};function gd(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Di(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Qc(){}function Em(e,t,l,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var f=ji(a);i.call(f)}}var a=Sf(t,r,e,0,null,!1,!1,"",Qc);return e._reactRootContainer=a,e[ln]=a.current,Kr(e.nodeType===8?e.parentNode:e),Gn(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var u=r;r=function(){var f=ji(p);u.call(f)}}var p=pd(e,0,!1,null,null,!1,!1,"",Qc);return e._reactRootContainer=p,e[ln]=p.current,Kr(e.nodeType===8?e.parentNode:e),Gn(function(){Li(t,p,l,r)}),p}function Ni(e,t,l,r,s){var i=l._reactRootContainer;if(i){var a=i;if(typeof s=="function"){var u=s;s=function(){var p=ji(a);u.call(p)}}Li(t,a,e,s)}else a=Em(l,t,e,s,r);return ji(a)}qu=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var l=_r(t.pendingLanes);l!==0&&(Lo(t,l|1),ct(t,Ee()),!(ce&6)&&($l=Ee()+500,Rn()))}break;case 13:Gn(function(){var r=rn(e,1);if(r!==null){var s=nt();Lt(r,e,1,s)}}),fd(e,1)}};Oo=function(e){if(e.tag===13){var t=rn(e,134217728);if(t!==null){var l=nt();Lt(t,e,134217728,l)}fd(e,134217728)}};Zu=function(e){if(e.tag===13){var t=Cn(e),l=rn(e,t);if(l!==null){var r=nt();Lt(l,e,t,r)}fd(e,t)}};Vu=function(){return fe};ep=function(e,t){var l=fe;try{return fe=e,t()}finally{fe=l}};$a=function(e,t,l){switch(t){case"input":if(Ra(e,l),t=l.name,l.type==="radio"&&t!=null){for(l=e;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<l.length;t++){var r=l[t];if(r!==e&&r.form===e.form){var s=zi(r);if(!s)throw Error(B(90));Pu(r),Ra(r,s)}}}break;case"textarea":Ru(e,l);break;case"select":t=l.value,t!=null&&Tl(e,!!l.multiple,t,!1)}};$u=od;Uu=Gn;var Pm={usingClientEntryPoint:!1,Events:[ls,jl,zi,Wu,Bu,od]},cr={findFiberByHostInstance:Wn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Am={bundleType:cr.bundleType,version:cr.version,rendererPackageName:cr.rendererPackageName,rendererConfig:cr.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:an.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Hu(e),e===null?null:e.stateNode},findFiberByHostInstance:cr.findFiberByHostInstance||Im,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 Es=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Es.isDisabled&&Es.supportsFiber)try{wi=Es.inject(Am),Ut=Es}catch{}}mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Pm;mt.createPortal=function(e,t){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!gd(t))throw Error(B(200));return Tm(e,t,null,l)};mt.createRoot=function(e,t){if(!gd(e))throw Error(B(299));var l=!1,r="",s=wf;return t!=null&&(t.unstable_strictMode===!0&&(l=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=pd(e,1,!1,null,null,l,!1,r,s),e[ln]=t.current,Kr(e.nodeType===8?e.parentNode:e),new hd(t)};mt.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(B(188)):(e=Object.keys(e).join(","),Error(B(268,e)));return e=Hu(t),e=e===null?null:e.stateNode,e};mt.flushSync=function(e){return Gn(e)};mt.hydrate=function(e,t,l){if(!Di(t))throw Error(B(200));return Ni(null,e,t,!0,l)};mt.hydrateRoot=function(e,t,l){if(!gd(e))throw Error(B(405));var r=l!=null&&l.hydratedSources||null,s=!1,i="",a=wf;if(l!=null&&(l.unstable_strictMode===!0&&(s=!0),l.identifierPrefix!==void 0&&(i=l.identifierPrefix),l.onRecoverableError!==void 0&&(a=l.onRecoverableError)),t=Sf(t,null,e,1,l??null,s,!1,i,a),e[ln]=t.current,Kr(e),r)for(e=0;e<r.length;e++)l=r[e],s=l._getVersion,s=s(l._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[l,s]:t.mutableSourceEagerHydrationData.push(l,s);return new Oi(t)};mt.render=function(e,t,l){if(!Di(t))throw Error(B(200));return Ni(null,e,t,!1,l)};mt.unmountComponentAtNode=function(e){if(!Di(e))throw Error(B(40));return e._reactRootContainer?(Gn(function(){Ni(null,null,e,!1,function(){e._reactRootContainer=null,e[ln]=null})}),!0):!1};mt.unstable_batchedUpdates=od;mt.unstable_renderSubtreeIntoContainer=function(e,t,l,r){if(!Di(l))throw Error(B(200));if(e==null||e._reactInternals===void 0)throw Error(B(38));return Ni(e,t,l,!1,r)};mt.version="18.3.1-next-f1338f8080-20240426";function kf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(kf)}catch(e){console.error(e)}}kf(),wu.exports=mt;var Rm=wu.exports,_f,Gc=Rm;_f=Gc.createRoot,Gc.hydrateRoot;const ae="",D={incidents:"SB Incident",ideas:"SB Idea",orders:"SB Order",organizations:"SB Organization",processes:"SB Process",managements:"Managements",departments:"Department",branches:"Branch",incidentTypes:"Incident Types",ideaTypes:"Idea Types",orderTypes:"Order Types",processTypes:"Process Types",incidentClass:"Incident Class",incidentField:"Incident Field",incidentStatuses:"Incident Statuses",ideaStatuses:"Idea Statuses",orderStatuses:"Order Statuses",processStatuses:"Process Statuses",users:"User",cycles:"SB Cycle",kpiInput:"SB KPI Input",delegations:"SB Delegation"},N={bg:"#f5f6fa",accent:"#4f46e5",red:"#ef4444",orange:"#f59e0b",green:"#16a34a",purple:"#7c3aed",blue:"#2563eb",teal:"#0d9488",gray:"#94a3b8"},Lm=[{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"}],Om=[{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"}],Dm=new Set(["users"]);function Nm(e){return e!=="Admin"&&e!=="Auditor"?[]:Om.filter(({id:t})=>e==="Admin"||!Dm.has(t))}const pn=(e=[])=>[{key:"name1",label:"Name"},{key:"status",label:"Status"},...e,{key:"creation_date",label:"Created On"}],Wm={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:pn(),defaultColumns:["name1","status","creation_date"]},"idea-types":{label:"Idea Types",columns:pn(),defaultColumns:["name1","status","creation_date"]},"order-types":{label:"Order Types",columns:pn(),defaultColumns:["name1","status","creation_date"]},"process-types":{label:"Process Types",columns:pn(),defaultColumns:["name1","status","creation_date"]},"incident-statuses":{label:"Incident Statuses",columns:pn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"idea-statuses":{label:"Idea Statuses",columns:pn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"order-statuses":{label:"Order Statuses",columns:pn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"process-statuses":{label:"Process Statuses",columns:pn([{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"]}},Bm="modulepreload",$m=function(e){return"/"+e},Yc={},Um=function(t,l,r){let s=Promise.resolve();if(l&&l.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),u=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(l.map(p=>{if(p=$m(p),p in Yc)return;Yc[p]=!0;const f=p.endsWith(".css"),g=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${g}`))return;const c=document.createElement("link");if(c.rel=f?"stylesheet":Bm,f||(c.as="script"),c.crossOrigin="",c.href=p,u&&c.setAttribute("nonce",u),document.head.appendChild(c),f)return new Promise((o,m)=>{c.addEventListener("load",o),c.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${p}`)))})}))}function i(a){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=a,window.dispatchEvent(u),!u.defaultPrevented)throw a}return s.then(a=>{for(const u of a||[])u.status==="rejected"&&i(u.reason);return t().catch(i)})};function Cf(e,t){const l=e[t.key];return l==null||l===""?"":typeof l=="object"?JSON.stringify(l):String(l)}function Fm(e,t){const l=URL.createObjectURL(e),r=document.createElement("a");r.href=l,r.download=t,r.click(),URL.revokeObjectURL(l)}function Mm(e,t,l){const r=e.map(a=>`"${a.label.replace(/"/g,'""')}"`).join(","),s=t.map(a=>e.map(u=>`"${Cf(a,u).replace(/"/g,'""')}"`).join(",")).join(`
`),i=new Blob([r+`
`+s],{type:"text/csv;charset=utf-8;"});Fm(i,`${l}.csv`)}async function Hm(e,t,l){const r=await Um(()=>import("./xlsx-D_0l8YDs.js"),[]),s=t.map(u=>{const p={};for(const f of e)p[f.label]=Cf(u,f);return p}),i=r.utils.json_to_sheet(s,{header:e.map(u=>u.label)}),a=r.utils.book_new();r.utils.book_append_sheet(a,i,"Export"),r.writeFile(a,`${l}.xlsx`)}const Ps="#16a34a";function Km({title:e,rows:t,columns:l,defaultColumnKeys:r,orgField:s,organizations:i,filenameBase:a,onClose:u}){const[p,f]=S.useState(""),[g,c]=S.useState("csv"),[o,m]=S.useState(new Set(r)),j=p?t.filter(v=>v[s||"organization"]===p):t,h=l.filter(v=>o.has(v.key)),C=v=>{m(z=>{const w=new Set(z);return w.has(v)?w.delete(v):w.add(v),w})},y=async()=>{h.length===0||j.length===0||(g==="csv"?Mm(h,j,a):await Hm(h,j,a),u())},x={fontSize:11,fontWeight:700,color:"#9ca3af",letterSpacing:.4,textTransform:"uppercase",marginBottom:10},d={background:"none",border:"none",color:"#2563eb",fontSize:12,fontWeight:600,cursor:"pointer",padding:0,fontFamily:"inherit"};return n.jsx("div",{onClick:u,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:v=>v.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:Ps,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:u,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:[s&&i&&i.length>0&&n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:x,children:"Filter by Organization"}),n.jsxs("select",{value:p,onChange:v=>f(v.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(v=>n.jsx("option",{value:v.name,children:v.organization_name||v.name},v.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(v=>n.jsxs("div",{onClick:()=>c(v.id),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",borderRadius:10,cursor:"pointer",border:`2px solid ${g===v.id?Ps:"#e5e7eb"}`,background:g===v.id?"#f0fdf4":"white"},children:[n.jsx("span",{style:{fontSize:20},children:v.id==="csv"?"📄":"📊"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:v.label}),n.jsx("div",{style:{fontSize:11,color:"#888"},children:v.desc})]})]},v.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(l.map(v=>v.key))),style:d,children:"Select All"}),n.jsx("span",{style:{color:"#d1d5db"},children:"|"}),n.jsx("button",{onClick:()=>m(new Set(r)),style:d,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:l.map(v=>n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:7,fontSize:13,color:"#374151",cursor:"pointer"},children:[n.jsx("input",{type:"checkbox",checked:o.has(v.key),onChange:()=>C(v.key),style:{accentColor:Ps,cursor:"pointer"}}),v.label]},v.key))})}),n.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:6},children:[o.size," column",o.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:p?`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:u,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:y,disabled:h.length===0||j.length===0,style:{padding:"9px 20px",borderRadius:8,border:"none",background:Ps,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"})]})]})]})})}function zf({collapsed:e,onToggleCollapsed:t,activePage:l,onNavigate:r,hasDashboard:s,hasReports:i,hasDelegations:a,role:u,hideSettings:p,rtl:f,navLabels:g,settingsLabel:c}){const o=p?[]:Nm(u);return n.jsxs("div",{style:{width:e?58:230,background:"linear-gradient(175deg, #1a0f42 0%, #2a1260 45%, #102840 100%)",color:"white",flexShrink:0,display:"flex",flexDirection:"column",position:"sticky",top:0,height:"100vh",transition:"width 0.22s ease",overflow:"hidden"},children:[n.jsxs("div",{style:{padding:e?"16px 0":"16px 20px 14px",borderBottom:"1px solid rgba(255,255,255,0.08)",display:"flex",alignItems:"center",justifyContent:e?"center":"space-between",gap:8,flexShrink:0},children:[!e&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,overflow:"hidden"},children:[n.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"linear-gradient(135deg, #312e81 0%, #4f46e5 100%)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:n.jsx("span",{style:{fontSize:16,color:"white",fontWeight:800,fontFamily:"serif"},children:"S"})}),n.jsx("span",{style:{fontSize:16,fontWeight:700,whiteSpace:"nowrap",color:"white"},children:f?"صدرة":"Sidrah"})]}),n.jsx("button",{onClick:t,title:e?f?"توسيع":"Expand":f?"طي":"Collapse",style:{background:"rgba(255,255,255,0.08)",border:"none",borderRadius:7,color:"rgba(255,255,255,0.7)",cursor:"pointer",fontSize:12,padding:"5px 8px",flexShrink:0,lineHeight:1,transition:"background 0.15s"},children:e?"▶":"✕"})]}),n.jsxs("nav",{style:{padding:"12px 8px",flex:1,overflowY:"auto",overflowX:"hidden"},children:[Lm.filter(({id:m})=>(m!=="dashboard"||s)&&(m!=="reports"||i)&&(m!=="delegations"||a)).map(({id:m,icon:j})=>{const h=g[m]||m,C=m===l;return n.jsxs("div",{onClick:()=>r(m),title:e?h:void 0,style:{padding:e?"8px 0":"8px 14px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:9,background:C?"rgba(139,92,246,0.28)":"transparent",borderRadius:8,fontSize:e?15:12,color:"white",fontWeight:C?600:400,transition:"all 0.15s",whiteSpace:"nowrap",marginBottom:2},children:[n.jsx("span",{style:{flexShrink:0},children:j}),!e&&h]},m)}),o.length>0&&n.jsxs(n.Fragment,{children:[!e&&n.jsx("div",{style:{padding:"10px 14px 4px",fontSize:10,color:"rgba(255,255,255,0.6)",fontWeight:700,letterSpacing:1,textTransform:"uppercase",marginTop:8},children:c}),e&&n.jsx("div",{style:{margin:"10px auto",width:28,borderTop:"1px solid rgba(255,255,255,0.12)"}}),o.map(({id:m,icon:j})=>{const h=g[m]||m,C=m===l;return n.jsxs("div",{onClick:()=>r(m),title:e?h:void 0,style:{padding:e?"8px 0":"8px 14px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:9,background:C?"rgba(139,92,246,0.25)":"transparent",borderRadius:8,fontSize:e?15:12,color:"white",fontWeight:C?600:400,transition:"all 0.15s",whiteSpace:"nowrap",marginBottom:2},children:[n.jsx("span",{style:{flexShrink:0},children:j}),!e&&h]},m)})]})]})]})}const Tf="sidrah_rtl",jo="sidrah-lang-change";function zl(){try{return localStorage.getItem(Tf)==="1"}catch{return!1}}function If(){const e=!zl();try{localStorage.setItem(Tf,e?"1":"0")}catch{}document.documentElement.setAttribute("dir",e?"rtl":"ltr"),document.documentElement.setAttribute("lang",e?"ar":"en-GB"),window.dispatchEvent(new CustomEvent(jo))}function q(){const[e,t]=S.useState(zl);return S.useEffect(()=>{const l=()=>t(zl());return window.addEventListener(jo,l),document.documentElement.setAttribute("dir",zl()?"rtl":"ltr"),document.documentElement.setAttribute("lang",zl()?"ar":"en-GB"),()=>window.removeEventListener(jo,l)},[]),e?Gm:Qm}const Qm={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",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",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"}},Gm={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:"حذف",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:"خاص",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:"بواسطة"}},ss=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"]);let Yn="";async function xd(){try{const e=await fetch(`${ae}/api/method/sidrah_business.api.get_csrf_token`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(e.ok){const l=(await e.json()).message||"";if(l)return Yn=l,l}}catch(e){console.error("CSRF fetch error:",e)}return Yn}async function on(){return Yn||await xd(),Yn}function Xc(e,t){try{if(e!=null&&e._server_messages){const l=JSON.parse(e._server_messages);if(l.length){const r=JSON.parse(l[0]);if(r!=null&&r.message)return r.message.replace(/<[^>]+>/g,"")}}}catch{}return(e==null?void 0:e.message)||(e==null?void 0:e.exception)||t}async function pt(e,t,l=[]){if(ss.has(e)){const a=`${ae}/api/method/sidrah_business.api.get_sb_doc?doctype=${encodeURIComponent(e)}&name=${encodeURIComponent(t)}`,u=await fetch(a,{credentials:"include",headers:{Accept:"application/json"}});if(!u.ok)throw new Error(`API Error: ${u.status}`);return(await u.json()).message}const r=l.length?`?fields=${encodeURIComponent(JSON.stringify(l))}`:"",s=await fetch(`${ae}/api/v1/resource/${e}/${encodeURIComponent(t)}${r}`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!s.ok)throw new Error(`API Error: ${s.status}`);return(await s.json()).data}async function Ef(e,t){const l=await on();if(ss.has(e)){const s=new URLSearchParams({doctype:e,name:t}),i=await fetch(`${ae}/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:s.toString()});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(Xc(a,`Error deleting ${t}`))}return}const r=await fetch(`${ae}/api/v1/resource/${e}/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"include",headers:{Accept:"application/json","X-Frappe-CSRF-Token":l}});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(Xc(s,`Error deleting ${t}`))}return await r.json()}async function je(e){if(ss.has(e))try{const r=`${ae}/api/method/sidrah_business.api.get_sb_list?doctype=${encodeURIComponent(e)}&limit=500`,s=await fetch(r,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}const t=encodeURIComponent('["*"]'),l=`${ae}/api/v1/resource/${e}?limit_page_length=500&fields=${t}`;try{const r=await fetch(l,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return r.status===401||r.status===403?[]:r.ok?(await r.json()).data||[]:[]}catch(r){return console.error("Get error:",r),[]}}async function ja(e,t){const l=await on();if(ss.has(e)){const s=new URLSearchParams({doctype:e,data_json:JSON.stringify(t)}),i=await fetch(`${ae}/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":l},body:s.toString()});if(!i.ok){const u=await i.json().catch(()=>({}));throw new Error(u.message||u.exc||`Error creating ${e}`)}return{data:(await i.json()).message}}const r=`${ae}/api/v1/resource/${e}`;try{const s=await fetch(r,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":l},body:JSON.stringify(t)});if(s.status===401||s.status===403)throw new Error("Permission denied - login required");if(!s.ok){const i=await s.json();throw new Error(i.message||i.exc||`API Error: ${s.status}`)}return await s.json()}catch(s){throw console.error("Post error:",s),s}}async function bi(e,t,l){const r=await on();if(ss.has(e)){const i=new URLSearchParams({doctype:e,name:t,data_json:JSON.stringify(l)}),a=await fetch(`${ae}/api/method/sidrah_business.api.update_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":r},body:i.toString()});if(!a.ok){const p=await a.json().catch(()=>({}));throw new Error(p.message||p.exc||`Error updating ${e}`)}return{data:(await a.json()).message}}const s=`${ae}/api/v1/resource/${e}/${encodeURIComponent(t)}`;try{const i=await fetch(s,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":r},body:JSON.stringify(l)});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 Ym(){const e=`${ae}/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 Xm(e,t){const l=new FormData;l.append("usr",e),l.append("pwd",t);const s=await(await fetch(`${ae}/api/method/login`,{method:"POST",credentials:"include",body:l})).json();return s.csrf_token?Yn=s.csrf_token:await xd(),s}async function Jm(){const e=await on();try{await fetch(`${ae}/api/method/logout`,{method:"POST",credentials:"include",headers:{"X-Frappe-CSRF-Token":e,Accept:"application/json"}})}catch{}Yn=""}function qm(){return Yn}async function Pf(){try{const e=await fetch(`${ae}/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 Zm(){const e=JSON.stringify([["name","not in",["Administrator","Guest"]]]),t=`${ae}/api/v1/resource/User?limit_page_length=500&fields=${encodeURIComponent('["*"]')}&filters=${encodeURIComponent(e)}`;try{const l=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).data||[]:[]}catch{return[]}}async function Vm(){const e=`${ae}/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 Af(e,t){await bi("User",e,{new_password:t})}async function ey(e=20){try{const t=`${ae}/api/method/sidrah_business.api.get_notifications?limit=${e}`,l=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||[]:[]}catch{return[]}}async function ty(){const e=await on();try{await fetch(`${ae}/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 ny(e){const t=await on();try{await fetch(`${ae}/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 ly(e){const t=await on(),l=new URLSearchParams({name:e});await fetch(`${ae}/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:l.toString()})}async function ry(e,t){try{const l=`${ae}/api/method/sidrah_business.api.get_doc_comments?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(t)}`,r=await fetch(l,{credentials:"include",headers:{Accept:"application/json"}});return r.ok?(await r.json()).message||[]:[]}catch{return[]}}async function sy(e,t,l){const r=await on(),s=new URLSearchParams({doctype:e,docname:t,content:l}),i=await fetch(`${ae}/api/method/sidrah_business.api.post_doc_comment`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":r},body:s.toString()});if(!i.ok)throw new Error("Failed to post comment");return(await i.json()).message}async function iy(e,t){try{const l=`${ae}/api/method/sidrah_business.api.get_doc_versions?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(t)}`,r=await fetch(l,{credentials:"include",headers:{Accept:"application/json"}});return r.ok?(await r.json()).message||[]:[]}catch{return[]}}async function Rf(e){try{const t=`${ae}/api/method/sidrah_business.api.get_user_roles?user=${encodeURIComponent(e)}`,l=await fetch(t,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||[]:[]}catch{return[]}}async function qn(e,t={}){const l=await on(),r=new URLSearchParams(t),s=await fetch(`${ae}/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":l},body:r.toString()});if(!s.ok){const a=await s.json().catch(()=>({}));throw new Error(a.message||a.exc||`Error calling ${e}`)}return(await s.json()).message}async function ay(e,t,l="",r,s,i){const a={name:e,action:t,comment:l};return r!==void 0&&(a.stage=r),i!==void 0&&(a.cycle_status=i),qn("apply_order_workflow",a)}async function oy(e,t,l=""){return qn("apply_incident_workflow",{name:e,action:t,fields_json:l})}async function dy(e,t,l=""){return qn("apply_idea_workflow",{name:e,action:t,fields_json:l})}async function cy(e=""){const t=`${ae}/api/method/sidrah_business.api.get_dashboard_data${e?`?organization=${encodeURIComponent(e)}`:""}`,l=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||{}:{escalated_processes:[],escalated_orders:[],untriaged_incidents:[],kpi_inputs:[]}}async function uy(e,t={}){return qn("get_report_data",{report_name:e,filters_json:JSON.stringify(t)})}async function py(){try{const e=`${ae}/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 fy(e,t,l="",r=""){return qn("create_delegation",{manager:e,functions_json:JSON.stringify(t),organization:l,remarks:r})}async function hy(e,t,l=""){return qn("respond_to_delegation",{name:e,response:t,remarks:l})}async function gy(e,t=""){return qn("revoke_delegation",{name:e,remarks:t})}async function xy(){try{const e=`${ae}/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 my(e){const t=`${ae}/api/method/sidrah_business.api.get_delegation?name=${encodeURIComponent(e)}`,l=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});if(!l.ok)throw new Error("Failed to load delegation");return(await l.json()).message}async function yy(){try{const e=`${ae}/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 vy(){try{const e=`${ae}/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 jy(){const e=qm();return e||xd()}async function zr(e){const t=await fetch(`${ae}/api/method/sidrah_business.api.get_process?name=${encodeURIComponent(e)}`,{credentials:"include",headers:{Accept:"application/json"}});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r.message||`Failed to load process (${t.status})`)}const l=await t.json();return l.message||l.data}async function by(e,t,l={}){const r=await jy(),s=new URLSearchParams({name:e,action:t});l.actor_status&&s.set("actor_status",String(l.actor_status)),l.actor_comment&&s.set("actor_comment",String(l.actor_comment)),l.progress_indicators&&s.set("progress_indicators",JSON.stringify(l.progress_indicators));const i=await fetch(`${ae}/api/method/sidrah_business.api.apply_process_workflow`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":r},body:s.toString()});if(!i.ok){const u=await i.json().catch(()=>({})),p=u.message||(u.exception?String(u.exception).split(`
`).pop():"")||u.exc_type||`Workflow action "${t}" failed (${i.status})`;throw new Error(p)}const a=await i.json();return a.message||a.data}function Sy({onLogin:e}){const t=q(),[l,r]=S.useState(""),[s,i]=S.useState(""),[a,u]=S.useState(""),[p,f]=S.useState(!1),[g,c]=S.useState(!1),[o,m]=S.useState(!1),j=async()=>{if(!l||!s){u(t.login.emptyFields);return}f(!0),u("");try{const C=await Xm(l,s);if(C.message==="Logged In"){const x=await Pf()||l,d=await Rf(x),v=d.some(z=>["SB Admin","System Manager"].includes(z))?"Admin":d.includes("SB Auditor")?"Auditor":d.includes("SB Owner")?"Owner":d.includes("SB X-Auditor")?"XAuditor":d.includes("SB Manager")?"Manager":"Employee";e({name:x,full_name:C.full_name||l,role:v})}else u(t.login.invalidCreds)}catch(C){u(t.login.connError+(C instanceof Error?C.message:"Unknown"))}f(!1)},h=C=>({width:"100%",padding:"13px 16px",border:`1.5px solid ${C?"#4f46e5":"#e5e7eb"}`,borderRadius:10,fontSize:15,background:"#ffffff",color:"#374151",outline:"none",transition:"border-color 0.2s, box-shadow 0.2s",boxSizing:"border-box",boxShadow:C?"0 0 0 3px rgba(79,70,229,0.12)":"none"});return n.jsx("div",{style:{minHeight:"100vh",background:"#f3f4f6",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"Segoe UI, system-ui, sans-serif"},children:n.jsxs("div",{style:{background:"white",borderRadius:20,padding:"48px 44px 40px",width:420,boxShadow:"0 4px 32px rgba(0,0,0,0.10)"},children:[n.jsxs("div",{style:{textAlign:"center",marginBottom:28},children:[n.jsx("div",{style:{width:72,height:72,borderRadius:18,background:"linear-gradient(135deg, #312e81 0%, #4f46e5 100%)",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 18px",boxShadow:"0 4px 16px rgba(79,70,229,0.3)"},children:n.jsx("span",{style:{fontSize:32,color:"white",fontWeight:800,fontFamily:"serif"},children:"S"})}),n.jsx("div",{style:{fontSize:24,fontWeight:700,color:"#1e1b4b"},children:t.rtl?"صدرة للأعمال":"Sidrah Business"}),n.jsx("div",{style:{fontSize:13,color:"#6b7280",marginTop:6},children:t.login.subtitle})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[n.jsx("input",{value:l,onChange:C=>r(C.target.value),onKeyDown:C=>C.key==="Enter"&&j(),onFocus:()=>c(!0),onBlur:()=>c(!1),style:h(g),placeholder:t.login.usernamePlaceholder,autoComplete:"username"}),n.jsx("input",{type:"password",value:s,onChange:C=>i(C.target.value),onKeyDown:C=>C.key==="Enter"&&j(),onFocus:()=>m(!0),onBlur:()=>m(!1),style:h(o),placeholder:t.login.passwordPlaceholder,autoComplete:"current-password"}),a&&n.jsx("div",{style:{padding:"10px 14px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:8,color:"#dc2626",fontSize:13},children:a}),n.jsx("button",{onClick:j,disabled:p,style:{background:p?"#a5b4fc":"#4f46e5",color:"white",border:"none",padding:"14px",borderRadius:10,fontSize:15,cursor:p?"not-allowed":"pointer",fontWeight:700,marginTop:4,transition:"background 0.2s, transform 0.1s",letterSpacing:"0.01em"},onMouseEnter:C=>{p||(C.currentTarget.style.background="#4338ca")},onMouseLeave:C=>{p||(C.currentTarget.style.background="#4f46e5")},children:p?t.login.signingIn:t.login.signIn})]}),n.jsx("div",{style:{textAlign:"center",marginTop:14},children:n.jsx("button",{onClick:If,style:{fontSize:12,color:"#9ca3af",background:"none",border:"none",cursor:"pointer"},children:t.switchLang})})]})})}function wy(e,t){const l=parseInt(e.replace("#",""),16),r=l>>16&255,s=l>>8&255,i=l&255,a=u=>Math.round(u+(255-u)*t);return`rgb(${a(r)}, ${a(s)}, ${a(i)})`}function As({title:e,data:t,color:l,onSelect:r}){const[,s]=t[0]??["Total",0,""],i=t.slice(1),a=i.map((p,f)=>wy(l,Math.min(f*.16,.7))),u=i.map(([p,f,g],c)=>[p,f,g,a[c]]).filter(([,p])=>p>0);return n.jsxs("div",{style:{background:"white",borderRadius:12,padding:"14px 16px",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderTop:`3px solid ${l}`,height:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10,paddingBottom:10,borderBottom:"1px solid #f1f5f9"},children:[n.jsx("span",{style:{fontSize:13,fontWeight:700,color:"#1e293b"},children:e}),n.jsx("span",{style:{fontSize:20,fontWeight:800,color:l},children:s})]}),s>0&&n.jsx("div",{style:{display:"flex",height:10,borderRadius:5,overflow:"hidden",background:"#f1f5f9",marginBottom:12},children:u.map(([p,f,g,c],o)=>n.jsx("div",{title:`${p}: ${f}`,onClick:m=>{m.stopPropagation(),r==null||r(g)},style:{flex:`${f} 0 0`,background:c,borderRight:o<u.length-1?"2px solid white":"none",cursor:r?"pointer":"default"}},p))}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:i.map(([p,f,g],c)=>n.jsxs("div",{onClick:f>0?o=>{o.stopPropagation(),r==null||r(g)}:void 0,style:{display:"flex",alignItems:"center",gap:8,padding:"2px 4px",borderRadius:4,cursor:f>0&&r?"pointer":"default",transition:"background 0.12s"},onMouseEnter:o=>{f>0&&r&&(o.currentTarget.style.background="#f8fafc")},onMouseLeave:o=>{o.currentTarget.style.background="transparent"},children:[n.jsx("span",{style:{width:8,height:8,borderRadius:2,background:a[c],flexShrink:0}}),n.jsx("span",{style:{flex:1,fontSize:12,color:"#64748b",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#334155",flexShrink:0},children:f})]},p))})]})}function _t({value:e,onChange:t,organizations:l,placeholder:r="-- Choose organization --",disabled:s=!1,small:i=!1}){var c;const[a,u]=S.useState(!1),p=S.useRef(null);S.useEffect(()=>{const o=m=>{p.current&&!p.current.contains(m.target)&&u(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[]);const f=e?((c=l.find(o=>o.organization_name===e||o.name===e))==null?void 0:c.organization_name)??e:r,g=l.filter(o=>!!o.is_active||o.organization_name===e||o.name===e);return n.jsxs("div",{ref:p,style:{position:"relative",width:"100%"},children:[n.jsxs("div",{onClick:()=>!s&&u(o=>!o),style:{width:"100%",padding:i?"4px 8px":"7px 10px",border:"1px solid #ddd",borderRadius:6,fontSize:i?11:12,cursor:s?"default":"pointer",height:i?28:34,background:s?"#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:s?.75:1},children:[n.jsx("span",{children:f}),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(Jc,{label:r,selected:!e,active:!0,isPlaceholder:!0,small:i,onClick:()=>{t(""),u(!1)}}),g.length===0&&n.jsx("div",{style:{padding:"12px 16px",color:"#aaa",fontSize:13},children:"No organizations"}),g.map(o=>n.jsx(Jc,{label:o.organization_name,selected:e===o.organization_name||e===o.name,active:!!o.is_active,isPlaceholder:!1,small:i,onClick:()=>{t(o.organization_name),u(!1)}},o.name))]})})]})}function Jc({label:e,selected:t,active:l,isPlaceholder:r,small:s,onClick:i}){const[a,u]=S.useState(!1),p=t?"#2563eb":a?"#f0f4ff":"transparent",f=t?"white":r?"#aaa":l?"#1a2332":"#e74c3c";return n.jsx("div",{onClick:i,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{padding:s?"6px 12px":"8px 14px",cursor:"pointer",fontSize:12,background:p,color:f,transition:"background 0.1s"},children:e})}function vn({items:e,type:t,onNavigate:l}){const r=q();if(!e.length)return null;const s=t==="process"?"processes-form":"orders-form",i=t==="process"?r.dash.escalatedProcesses:r.dash.escalatedOrders;return n.jsxs("div",{children:[n.jsxs("h4",{style:{fontWeight:700,fontSize:12,color:"#e74c3c",marginBottom:6},children:[i," (",e.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:e.map(a=>n.jsxs("div",{onClick:()=>l(s,a.name),style:{padding:"8px 12px",background:"#fff5f5",borderRadius:7,border:"1px solid #fecaca",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsxs("div",{children:[n.jsx("span",{style:{fontWeight:700,fontSize:12},children:a.number||a.name}),n.jsx("span",{style:{fontSize:11,color:"#666",marginLeft:8},children:a.title})]}),n.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#e74c3c",background:"#fecaca",padding:"2px 8px",borderRadius:10},children:[r.dash.level," ",a.escalation_level]})]},a.name))})]})}function ky({kpi:e}){const t=q();return n.jsxs("div",{style:{background:"white",borderRadius:8,padding:12,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("div",{style:{fontWeight:700,fontSize:13,marginBottom:2},children:e.organization}),n.jsx("div",{style:{fontSize:11,color:"#888",marginBottom:8},children:e.period}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[{label:t.dash.revenueGrowth,val:e.revenue_growth!=null?`${e.revenue_growth}%`:"—"},{label:t.dash.netProfit,val:e.net_profit!=null?e.net_profit.toLocaleString():"—"},{label:t.dash.strategicGoal,val:e.strategic_goal_pct!=null?`${e.strategic_goal_pct}%`:"—"},{label:t.dash.customerSat,val:e.customer_satisfaction!=null?e.customer_satisfaction:"—"},{label:t.dash.compliance,val:e.compliance_score!=null?e.compliance_score:"—"},{label:t.dash.safetyInc,val:e.open_safety_incidents!=null?e.open_safety_incidents:"—"}].map(({label:l,val:r})=>n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700},children:l}),n.jsx("div",{style:{fontSize:15,fontWeight:700,color:"#1a2332"},children:r})]},l))})]})}function _y({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(l=>l.pass+l.fail+l.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(l=>{const r=l.pass+l.fail+l.unknown||1,s=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:s,width:32},children:[n.jsx("div",{title:`Pass: ${l.pass}`,style:{height:Math.round(l.pass/t*s),background:"#27ae60",borderRadius:"2px 2px 0 0",minHeight:l.pass?2:0}}),n.jsx("div",{title:`Fail: ${l.fail}`,style:{height:Math.round(l.fail/t*s),background:"#e74c3c",borderRadius:"2px 2px 0 0",minHeight:l.fail?2:0}}),n.jsx("div",{title:`Unknown: ${l.unknown}`,style:{height:Math.round(l.unknown/t*s),background:"#95a5a6",borderRadius:"2px 2px 0 0",minHeight:l.unknown?2:0}})]}),n.jsx("div",{style:{fontSize:9,color:"#999",textAlign:"center",lineHeight:1.2},children:l.month.replace(/^(\d{4})-(\d{2})$/,(i,a,u)=>`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][+u-1]}
${a}`)}),n.jsx("div",{style:{fontSize:9,color:"#555",textAlign:"center"},children:r>1?Math.round(l.pass/r*100)+"%":"—"})]},l.month)})}),n.jsx("div",{style:{display:"flex",gap:16,marginTop:8},children:[["#27ae60","Pass"],["#e74c3c","Fail"],["#95a5a6","Unknown"]].map(([l,r])=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,fontSize:11},children:[n.jsx("div",{style:{width:10,height:10,background:l,borderRadius:2}}),n.jsx("span",{style:{color:"#666"},children:r})]},r))})]})}function At({label:e,icon:t,onClick:l}){return n.jsxs("button",{onClick:l,style:{display:"flex",alignItems:"center",gap:7,padding:"7px 12px",background:"white",border:"1px solid #e8e8e8",borderRadius:8,cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.06)",transition:"box-shadow 0.15s"},onMouseEnter:r=>r.currentTarget.style.boxShadow="0 3px 10px rgba(0,0,0,0.12)",onMouseLeave:r=>r.currentTarget.style.boxShadow="0 1px 3px rgba(0,0,0,0.06)",children:[n.jsx("span",{style:{fontSize:15},children:t}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#444",whiteSpace:"nowrap"},children:e})]})}function Cy({dashData:e,fi:t,fid:l,fo:r,fp:s,incidentStatuses:i,ideaStatuses:a,orderStatuses:u,processStatuses:p,onNavigate:f,onNavigateStatus:g}){const c=q(),o=(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)||[],C=(e==null?void 0:e.untriaged_incidents)||[],y=(e==null?void 0:e.overdue_triage)||[],x=o.length>0||m.length>0,d=j.length>0||h.length>0,v=[["Total",t.length,""],...i.map(k=>[k.name1||k.name,t.filter(I=>I.status===k.name).length,k.name])],z=[["Total",l.length,""],...a.map(k=>[k.name1||k.name,l.filter(I=>I.status===k.name).length,k.name])],w=[["Total",r.length,""],...u.map(k=>[k.name1||k.name,r.filter(I=>I.status===k.name).length,k.name])],b=[["Total",s.length,""],...p.map(k=>[k.name1||k.name,s.filter(I=>I.status===k.name).length,k.name])];return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",marginBottom:4},children:[n.jsx(At,{label:"Incidents",icon:"⚠️",onClick:()=>f("incidents")}),n.jsx(At,{label:"Ideas",icon:"💡",onClick:()=>f("ideas")}),n.jsx(At,{label:"Orders",icon:"📦",onClick:()=>f("orders")}),n.jsx(At,{label:"Processes",icon:"⚙️",onClick:()=>f("processes")}),n.jsx(At,{label:"Inbox",icon:"📥",onClick:()=>f("inbox")}),n.jsx(At,{label:"Reports",icon:"📊",onClick:()=>f("reports")})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12},children:[n.jsx("div",{onClick:()=>f("incidents"),style:{cursor:"pointer"},children:n.jsx(As,{title:c.dash.incidents,color:N.orange,data:v,onSelect:k=>g("incidents",k)})}),n.jsx("div",{onClick:()=>f("ideas"),style:{cursor:"pointer"},children:n.jsx(As,{title:c.dash.ideas,color:N.blue,data:z,onSelect:k=>g("ideas",k)})}),n.jsx("div",{onClick:()=>f("orders"),style:{cursor:"pointer"},children:n.jsx(As,{title:c.dash.orders,color:N.purple,data:w,onSelect:k=>g("orders",k)})}),n.jsx("div",{onClick:()=>f("processes"),style:{cursor:"pointer"},children:n.jsx(As,{title:c.dash.processes,color:N.red,data:b,onSelect:k=>g("processes",k)})})]}),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:c.dash.level2}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(vn,{items:o,type:"process",onNavigate:f}),n.jsx(vn,{items:m,type:"order",onNavigate:f})]})]}),d&&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:c.dash.level1}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(vn,{items:j,type:"process",onNavigate:f}),n.jsx(vn,{items:h,type:"order",onNavigate:f})]})]}),y.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:[c.dash.overduePrefix,y.length,c.dash.overdueSuffix]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:y.map(k=>n.jsxs("div",{onClick:()=>f("incidents-form",k.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:k.number||k.name}),n.jsx("span",{style:{fontSize:12,color:"#666"},children:k.title}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:k.date})]},k.name))})]}),C.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:N.orange,marginBottom:8},children:[c.dash.untriaged," (",C.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:C.map(k=>n.jsxs("div",{onClick:()=>f("incidents-form",k.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:k.number||k.name}),n.jsx("span",{style:{fontSize:12,color:"#666"},children:k.title}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:k.date})]},k.name))})]})]})}function zy({dashData:e,selectedOrg:t,onNavigate:l}){const r=q(),[s,i]=S.useState([]),[a,u]=S.useState([]),[p,f]=S.useState(!1),g=(e==null?void 0:e.escalated_processes)||[],c=(e==null?void 0:e.escalated_orders)||[],o=(e==null?void 0:e.attention_processes)||[],m=(e==null?void 0:e.attention_orders)||[],j=(e==null?void 0:e.kpi_inputs)||[];S.useEffect(()=>{f(!0);const y=new URLSearchParams({months:"6"});t&&y.append("organization",t),fetch(`/api/method/sidrah_business.api.get_process_trend?${y}`,{credentials:"include",headers:{Accept:"application/json"}}).then(x=>x.json()).then(x=>{const d=x.message||[],v={};for(const z of d)v[z.month]||(v[z.month]={pass:0,fail:0,unknown:0}),z.status==="Pass"?v[z.month].pass=z.count:z.status==="Fail"?v[z.month].fail=z.count:z.status==="Unknown"&&(v[z.month].unknown=z.count);i(Object.entries(v).map(([z,w])=>({month:z,...w})))}).catch(()=>{}).finally(()=>f(!1))},[t]),S.useEffect(()=>{fetch("/api/method/sidrah_business.api.get_report_data",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":window.csrf_token||""},body:JSON.stringify({report_name:"user_activity_log",filters_json:"{}"})}).then(y=>y.json()).then(y=>{var x;u((((x=y.message)==null?void 0:x.rows)||[]).slice(0,50))}).catch(()=>{})},[t]);const h=g.length>0||c.length>0,C=o.length>0||m.length>0;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:[n.jsx(At,{label:"Manage Users & Roles",icon:"👥",onClick:()=>l("users")}),n.jsx(At,{label:"Change Active Cycle",icon:"🔄",onClick:()=>l("cycles")}),n.jsx(At,{label:"KPI Inputs",icon:"📈",onClick:()=>l("kpi-input")}),n.jsx(At,{label:"Reports",icon:"📊",onClick:()=>l("reports")}),n.jsx(At,{label:"Organizations",icon:"🏢",onClick:()=>l("organizations")})]}),j.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:10},children:r.dash.recentKpi}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12},children:j.map(y=>n.jsx(ky,{kpi:y},y.name))}),n.jsx("button",{onClick:()=>l("kpi-input"),style:{marginTop:10,padding:"6px 14px",borderRadius:7,border:"1px solid #2980b9",background:"white",color:"#2980b9",fontWeight:600,fontSize:12,cursor:"pointer"},children:r.dash.manageKpi})]}),h&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #e74c3c"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:10},children:["Critical Escalations — Level 2 (",g.length+c.length,")"]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(vn,{items:g,type:"process",onNavigate:l}),n.jsx(vn,{items:c,type:"order",onNavigate:l})]})]}),C&&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 (",o.length+m.length,")"]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(vn,{items:o,type:"process",onNavigate:l}),n.jsx(vn,{items:m,type:"order",onNavigate:l})]})]}),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."}),p?n.jsx("p",{style:{color:"#aaa",fontSize:13},children:"Loading trend data…"}):n.jsx(_y,{data:s})]}),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(y=>n.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#999",fontWeight:700,fontSize:11,whiteSpace:"nowrap"},children:y},y))})}),n.jsx("tbody",{children:a.map((y,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:y.timestamp?String(y.timestamp).slice(0,16):"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#333"},children:y.user||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#555"},children:y.entity_type||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#555"},children:y.entity_name||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#888",maxWidth:240,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y.changes||"—"})]},x))})]})}),n.jsx("button",{onClick:()=>l("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 Ty({incidents:e,ideas:t,orders:l,processes:r,organizations:s,incidentStatuses:i,ideaStatuses:a,orderStatuses:u,processStatuses:p,selectedOrg:f,onOrgChange:g,onNavigate:c,onNavigateStatus:o,userRole:m}){const[j,h]=S.useState(null);S.useEffect(()=>{cy(f).then(h)},[f]);const C=f?e.filter(I=>I.organization===f):e,y=f?t.filter(I=>I.organization===f):t,x=f?l.filter(I=>I.organization===f):l,d=f?r.filter(I=>I.organization===f):r,v=m==="Admin",z=m==="Owner",[w,b]=S.useState("level2"),k=z||v&&w==="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(_t,{value:f,onChange:g,organizations:s,placeholder:"All Organizations",small:!0})}),v&&n.jsx("div",{style:{display:"flex",background:"#f1f0fe",borderRadius:7,padding:2,gap:2,flexShrink:0},children:["level1","level2"].map(I=>n.jsx("button",{onClick:()=>b(I),style:{padding:"4px 10px",borderRadius:5,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:w===I?I==="level2"?N.purple:N.blue:"transparent",color:w===I?"white":"#6b7280",transition:"all 0.15s"},children:I==="level1"?"Level 1":"Level 2"},I))}),!v&&n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"white",background:k?N.purple:N.blue,padding:"3px 10px",borderRadius:20,flexShrink:0},children:k?"Level 2 — Owner":"Level 1 — Operational"})]}),k?n.jsx(zy,{dashData:j,selectedOrg:f,onNavigate:c}):n.jsx(Cy,{dashData:j,fi:C,fid:y,fo:x,fp:d,incidentStatuses:i,ideaStatuses:a,orderStatuses:u,processStatuses:p,onNavigate:c,onNavigateStatus:o})]})}const Iy=()=>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"})]}),Ey=()=>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"})]}),Py=()=>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 Ke({onView:e,onEdit:t,onDelete:l}){const[r,s]=S.useState(!1),i=(u,p,f,g,c)=>f?n.jsx("button",{onClick:o=>{o.stopPropagation(),f()},title:c,style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:u,color:p,flexShrink:0,transition:"opacity 0.15s"},onMouseEnter:o=>o.currentTarget.style.opacity="0.75",onMouseLeave:o=>o.currentTarget.style.opacity="1",children:g},c):null,a=l?()=>{r?(s(!1),l()):s(!0)}:void 0;return n.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[i("#e0f7fa","#0891b2",e,n.jsx(Iy,{}),"View"),i("#dcfce7","#16a34a",t,n.jsx(Ey,{}),"Edit"),l&&n.jsx("button",{onClick:u=>{u.stopPropagation(),a==null||a()},title:r?"Click again to confirm delete":"Delete",style:{minWidth:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:r?8:"50%",padding:r?"0 8px":0,border:"none",cursor:"pointer",background:r?"#ef4444":"#fee2e2",color:r?"white":"#ef4444",flexShrink:0,fontSize:r?11:14,fontWeight:700,transition:"all 0.15s",gap:4},onMouseEnter:u=>u.currentTarget.style.opacity="0.8",onMouseLeave:u=>u.currentTarget.style.opacity="1",onBlur:()=>s(!1),children:r?"✓ Sure?":n.jsx(Py,{})})]})}const P={width:"100%",height:34,padding:"7px 10px",border:"1px solid #ddd",borderRadius:6,fontSize:12,boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif"},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 ue(e,t){return e.filter(l=>Ay(l)||l.name===t)}function Ul(e,t,l){return e.filter(r=>{const s=t[r.name]||[];return s.includes("SB Admin")||s.includes("System Manager")?!1:s.includes(l)})}const Fl={width:16,height:16,cursor:"pointer",accentColor:"#2563eb",flexShrink:0},En=(e,t)=>n.jsx("span",{style:{background:t,color:"white",padding:"4px 12px",borderRadius:12,fontSize:12,fontWeight:600,display:"inline-block"},children:e}),Wi=e=>{switch(e){case"New":return"#e74c3c";case"Under Progress":return"#f39c12";case"Executed":return"#27ae60";case"Overdue":return"#7f1d1d";default:return"#95a5a6"}},Oe={fontSize:10,color:"#6b7280",fontWeight:600,marginBottom:3,display:"block",textTransform:"uppercase",letterSpacing:.4},De={width:"100%",padding:"4px 8px",border:"1px solid #d1d5db",borderRadius:6,fontSize:11,background:"white",color:"#374151",boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif",height:28};function Bi({children:e}){const[t,l]=S.useState(!1);return n.jsxs("div",{style:{borderRadius:8,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",flexShrink:0},children:[n.jsxs("div",{onClick:()=>l(r=>!r),style:{background:"#4f46e5",color:"white",padding:"9px 18px",cursor:"pointer",display:"flex",alignItems:"center",gap:10,userSelect:"none"},children:[n.jsx("span",{style:{fontSize:13,opacity:.9},children:t?"▲":"▼"}),n.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{style:{fontSize:13,fontWeight:600},children:"Filters"})]}),t&&n.jsx("div",{style:{background:"white",padding:"12px 16px",borderTop:"1px solid #e5e7eb"},children:e})]})}const te=20,qc=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 Ne({page:e,pageSize:t=te,total:l,onPageChange:r}){if(l===0)return null;const s=Math.max(1,Math.ceil(l/t)),i=(e-1)*t+1,a=Math.min(e*t,l);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 ",l," results"]}),n.jsxs("div",{style:{display:"flex",gap:8},children:[n.jsx("button",{disabled:e<=1,onClick:()=>r(e-1),style:qc(e<=1),children:"Previous"}),n.jsx("button",{disabled:e>=s,onClick:()=>r(e+1),style:qc(e>=s),children:"Next"})]})]})}function Ry({incidents:e,organizations:t,departments:l,branches:r,incidentStatuses:s,initialOrg:i,initialStatus:a,canModify:u,onView:p,onEdit:f,onDelete:g}){const c=q(),[o,m]=S.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),j=(d,v)=>m(z=>({...z,[d]:v})),[h,C]=S.useState(1),y=e.filter(d=>!(o.search&&!`${d.number} ${d.title}`.toLowerCase().includes(o.search.toLowerCase())||o.organization&&d.organization!==o.organization||o.department&&d.department!==o.department||o.branch&&d.branch!==o.branch||o.status&&d.status!==o.status));S.useEffect(()=>{C(1)},[o]);const x=y.slice((h-1)*te,h*te);return n.jsxs(n.Fragment,{children:[n.jsx(Bi,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.numberTitle}),n.jsx("input",{style:De,value:o.search,onChange:d=>j("search",d.target.value),placeholder:c.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.organization}),n.jsxs("select",{style:De,value:o.organization,onChange:d=>j("organization",d.target.value),children:[n.jsx("option",{value:"",children:c.filter.allOrgs}),t.map(d=>n.jsx("option",{value:d.name,children:d.organization_name||d.name},d.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.department}),n.jsxs("select",{style:De,value:o.department,onChange:d=>j("department",d.target.value),children:[n.jsx("option",{value:"",children:c.filter.allDepts}),l.map(d=>n.jsx("option",{value:d.name,children:d.department_name||d.name},d.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.branch}),n.jsxs("select",{style:De,value:o.branch,onChange:d=>j("branch",d.target.value),children:[n.jsx("option",{value:"",children:c.filter.allBranches}),r.map(d=>n.jsx("option",{value:d.name,children:d.branch||d.name},d.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.status}),n.jsxs("select",{style:De,value:o.status,onChange:d=>j("status",d.target.value),children:[n.jsx("option",{value:"",children:c.filter.allStatuses}),s.map(d=>n.jsx("option",{value:d.name,children:d.name1||d.name},d.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>m({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"5px 12px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#6b7280",fontFamily:"Segoe UI"},children:c.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.number}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.title}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.type}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.actions})]})}),n.jsx("tbody",{children:y.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:c.noIncidents})}):x.map((d,v)=>n.jsxs("tr",{onClick:()=>p==null?void 0:p(d),style:{borderTop:"1px solid #f0f0f0",background:v%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",color:"#999"},children:d.number||"—"}),n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:d.title||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:d.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:d.type?En(d.type,"#e74c3c"):"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:d.status?En(d.status,Wi(d.status)):"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:z=>z.stopPropagation(),children:n.jsx(Ke,{onView:()=>p==null?void 0:p(d),onEdit:u&&f?()=>f(d):void 0,onDelete:u&&g?()=>g(d.name):void 0})})]},d.name))})]})}),n.jsx(Ne,{page:h,total:y.length,onPageChange:C})]})}function Ly(e){if(!e)return"";const[t,l,r]=e.split("-");return!t||!l||!r?"":`${r}/${l}/${t}`}function he({value:e,onChange:t,disabled:l,style:r,min:s,max:i}){return n.jsxs("div",{style:{position:"relative",width:"100%"},children:[n.jsx("input",{type:"text",readOnly:!0,tabIndex:-1,value:Ly(e),placeholder:"DD/MM/YYYY",style:{...r,pointerEvents:"none",paddingRight:30}}),n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:l?"#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:l,min:s,max:i,onChange:a=>t(a.target.value),style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0,cursor:l?"default":"pointer",border:"none",padding:0,margin:0}})]})}function Oy({title:e,children:t}){return n.jsxs("div",{style:{background:"white",borderRadius:10,padding:"18px 20px",marginBottom:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[e&&n.jsx("div",{style:{fontSize:15,fontWeight:700,marginBottom:16,color:"#1e1b4b"},children:e}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:13},children:t})]})}function We({title:e,activePage:t,user:l,formStatus:r,buttonText:s,buttonColor:i,viewMode:a,onEdit:u,hideSettings:p,rightPanel:f,onSubmit:g,onBack:c,onNavigate:o,onLogout:m,children:j}){const h=q(),C=h.nav[t]||t,y=(l.full_name||l.name||"U").charAt(0).toUpperCase(),x=l.role,d=x==="Admin"||x==="Owner"||x==="Auditor"||x==="Manager",v=x==="Admin"||x==="Owner"||x==="Auditor"||x==="Manager",z=x==="Admin"||x==="Auditor"||x==="Manager",w=d?"dashboard":"inbox",[b,k]=S.useState(()=>localStorage.getItem("sb_sidebar")==="1"),I=()=>k($=>{const G=!$;return localStorage.setItem("sb_sidebar",G?"1":"0"),G}),[U,J]=S.useState(!1),se=S.useRef(null);return S.useEffect(()=>{const $=G=>{se.current&&!se.current.contains(G.target)&&J(!1)};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]),n.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:N.bg},children:[n.jsx(zf,{collapsed:b,onToggleCollapsed:I,activePage:t,onNavigate:o,hasDashboard:d,hasReports:v,hasDelegations:z,role:x,hideSettings:p,rtl:h.rtl,navLabels:h.nav,settingsLabel:h.nav.settings}),n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[n.jsxs("div",{style:{background:"white",padding:"10px 20px",borderBottom:"1px solid #e9eaf0",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,boxShadow:"0 1px 4px rgba(0,0,0,0.04)"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[n.jsx("button",{onClick:c,title:h.back,style:{width:30,height:30,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"1.5px solid #e5e7eb",background:"white",cursor:"pointer",color:"#4f46e5",flexShrink:0},children:n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"15 18 9 12 15 6"})})}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:15,fontWeight:700,color:"#1e1b4b"},children:e}),n.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:1},children:[n.jsx("span",{onClick:()=>o(w),style:{cursor:"pointer",color:"#4f46e5"},onMouseEnter:$=>$.currentTarget.style.textDecoration="underline",onMouseLeave:$=>$.currentTarget.style.textDecoration="none",children:h.home}),!p&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{margin:"0 4px"},children:"/"}),n.jsx("span",{onClick:c,style:{cursor:"pointer",color:"#4f46e5"},onMouseEnter:$=>$.currentTarget.style.textDecoration="underline",onMouseLeave:$=>$.currentTarget.style.textDecoration="none",children:C})]})]})]})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a&&u&&n.jsxs("button",{onClick:u,style:{display:"flex",alignItems:"center",gap:6,padding:"7px 16px",borderRadius:7,border:"none",background:"#4f46e5",color:"white",cursor:"pointer",fontSize:13,fontWeight:600,fontFamily:"Segoe UI"},children:[n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),h.edit]}),n.jsxs("div",{ref:se,style:{position:"relative"},children:[n.jsxs("div",{onClick:()=>J($=>!$),style:{display:"flex",alignItems:"center",gap:10,cursor:"pointer",padding:"4px 8px",borderRadius:8,transition:"background 0.15s",background:U?"#f3f4f6":"transparent"},onMouseEnter:$=>$.currentTarget.style.background="#f3f4f6",onMouseLeave:$=>{U||($.currentTarget.style.background="transparent")},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end"},children:[n.jsx("div",{style:{fontSize:11,fontWeight:600,color:"#374151"},children:l.full_name||l.name}),n.jsx("div",{style:{fontSize:10,color:"#9ca3af"},children:x})]}),n.jsx("div",{style:{width:30,height:30,borderRadius:"50%",background:"#4f46e5",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:700,flexShrink:0},children:y})]}),U&&n.jsxs("div",{style:{position:"absolute",right:0,top:"calc(100% + 6px)",background:"white",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.14)",border:"1px solid #e9eaf0",minWidth:160,zIndex:9999,overflow:"hidden"},children:[n.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid #f3f4f6"},children:[n.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#1e1b4b"},children:l.full_name||l.name}),n.jsx("div",{style:{fontSize:11,color:"#9ca3af"},children:x})]}),n.jsxs("button",{onClick:()=>{J(!1),m()},style:{width:"100%",padding:"10px 14px",display:"flex",alignItems:"center",gap:8,border:"none",background:"none",cursor:"pointer",fontSize:13,color:"#ef4444",fontWeight:600,fontFamily:"inherit",textAlign:"left"},onMouseEnter:$=>$.currentTarget.style.background="#fef2f2",onMouseLeave:$=>$.currentTarget.style.background="none",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:"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"})]}),"Logout"]})]})]})]})]}),n.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px",display:"grid",gridTemplateColumns:f?"1fr auto":"1fr",gap:14,alignItems:"start"},children:[n.jsx("div",{style:{minWidth:0},children:n.jsxs(Oy,{children:[j,!a&&n.jsxs("div",{style:{display:"flex",gap:10,marginTop:20},children:[n.jsx("button",{onClick:c,style:{padding:"9px 22px",borderRadius:8,border:"1.5px solid #e5e7eb",cursor:"pointer",fontSize:13,fontWeight:600,background:"white",color:"#374151",fontFamily:"Segoe UI"},children:h.cancel}),n.jsx("button",{onClick:g,disabled:r==="loading",style:{padding:"9px 22px",borderRadius:8,background:i,color:"white",border:"none",cursor:"pointer",fontSize:13,fontWeight:600,opacity:r==="loading"?.7:1,boxShadow:"0 2px 10px rgba(79,70,229,0.18)",fontFamily:"Segoe UI"},children:r==="loading"?h.saving:s})]}),r==="success"&&n.jsx("div",{style:{padding:"10px",borderRadius:8,background:"#f0fdf4",border:"1px solid #86efac",color:"#166534",fontSize:13,marginTop:10},children:h.savedOk}),r!=="idle"&&r!=="loading"&&r!=="success"&&n.jsx("div",{style:{padding:"10px",borderRadius:8,background:"#fef2f2",border:"1px solid #fca5a5",color:"#991b1b",fontSize:13,marginTop:10},children:r})]})}),f&&n.jsx("div",{style:{position:"sticky",top:20,alignSelf:"start"},children:f})]})]})]})}function de({value:e,onChange:t,items:l,placeholder:r="-- Select --",disabled:s=!1}){var c;const[i,a]=S.useState(!1),[u,p]=S.useState(""),f=S.useRef(null);S.useEffect(()=>{const o=m=>{f.current&&!f.current.contains(m.target)&&a(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[]);const g=e?((c=l.find(o=>o.name===e))==null?void 0:c.label)??e:r;return n.jsxs("div",{ref:f,style:{position:"relative",width:"100%"},children:[n.jsxs("div",{onClick:()=>!s&&a(o=>!o),style:{width:"100%",height:34,padding:"7px 10px",border:"1px solid",borderColor:i?"#3498db":"#ddd",borderRadius:6,fontSize:12,cursor:s?"default":"pointer",background:s?"#f5f5f5":"white",color:e?"#333":"#aaa",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"border-color 0.2s",userSelect:"none",boxSizing:"border-box",opacity:s?.75:1},children:[n.jsx("span",{children:g}),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:()=>p("__placeholder"),onMouseLeave:()=>p(""),style:{padding:"8px 14px",cursor:"pointer",fontSize:12,color:"#aaa",background:u==="__placeholder"?"#f5f5f5":"transparent"},children:r}),l.length===0&&n.jsx("div",{style:{padding:"10px 14px",color:"#aaa",fontSize:12},children:"No records found"}),l.map(o=>n.jsx("div",{onClick:()=>{t(o.name),a(!1)},onMouseEnter:()=>p(o.name),onMouseLeave:()=>p(""),style:{padding:"8px 14px",cursor:"pointer",fontSize:12,background:e===o.name?"#2563eb":u===o.name?"#f0f4ff":"transparent",color:e===o.name?"white":"#1a2332",transition:"background 0.1s"},children:o.label},o.name))]})})]})}function Dy(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 Ny(e){return e.replace(/@.*/,"").replace(/[._-]/g," ").split(" ").filter(Boolean).slice(0,2).map(l=>l[0].toUpperCase()).join("")}function $i({doctype:e,docname:t,currentUserName:l}){const r=q(),[s,i]=S.useState([]),[a,u]=S.useState(!1),[p,f]=S.useState(""),[g,c]=S.useState(!1),[o,m]=S.useState(!1),[j,h]=S.useState(!1),[C,y]=S.useState(""),x=5,d=S.useCallback(async()=>{u(!0);const k=await ry(e,t);i(k),u(!1)},[e,t]);S.useEffect(()=>{d()},[d]);const v=async()=>{const k=p.trim();if(!(!k||g)){c(!0),y("");try{await sy(e,t,k),f(""),await d()}catch{y("Failed to post comment. Please try again.")}c(!1)}},z=async k=>{if(window.confirm("Delete this comment?"))try{await Ef("Comment",k),i(I=>I.filter(U=>U.name!==k))}catch{alert("Failed to delete comment.")}},w=j?s:s.slice(-x),b=Math.max(0,s.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(k=>!k),style:{padding:"12px 20px",borderBottom:o?"none":"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none",background:"white"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:"#1a2332"},children:["💬 ",r.comments.title,s.length>0&&n.jsx("span",{style:{background:"#e8f4fd",color:"#2980b9",fontSize:11,fontWeight:700,borderRadius:10,padding:"2px 8px"},children:s.length})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx("button",{onClick:k=>{k.stopPropagation(),d()},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:o?"▼":"▲"})]})]}),!o&&n.jsxs("div",{style:{padding:"16px 20px"},children:[!j&&b>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 ",b," older comment",b!==1?"s":""]}),a&&n.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:r.loading}),!a&&s.length===0&&n.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:r.comments.noComments}),!a&&w.length>0&&n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:16},children:w.map(k=>{const I=k.comment_by||k.comment_email||k.owner||"Unknown",U=k.owner===l||k.comment_by===l;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:Ny(I)}),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:I}),n.jsx("span",{style:{fontSize:11,color:"#aaa"},children:Dy(k.creation)})]}),U&&n.jsx("button",{onClick:()=>z(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:k.content||""}})]})]},k.name)})}),n.jsxs("div",{style:{borderTop:s.length>0?"1px solid #f0f0f0":"none",paddingTop:s.length>0?14:0},children:[n.jsx("textarea",{value:p,onChange:k=>f(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.ctrlKey||k.metaKey)&&v()},placeholder:r.comments.placeholder,rows:3,style:{width:"100%",padding:"10px 12px",border:"1px solid #ddd",borderRadius:8,fontSize:13,fontFamily:"Segoe UI",resize:"vertical",boxSizing:"border-box",outline:"none",color:"#1a2332"}}),C&&n.jsx("div",{style:{fontSize:12,color:"#e74c3c",marginTop:4},children:C}),n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:n.jsx("button",{onClick:v,disabled:!p.trim()||g,style:{padding:"8px 20px",background:"#3498db",color:"white",border:"none",borderRadius:6,cursor:!p.trim()||g?"not-allowed":"pointer",fontSize:13,fontWeight:600,fontFamily:"Segoe UI",opacity:!p.trim()||g?.6:1},children:g?r.saving:r.comments.post})})]})]})]})}function Zc(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 Wy(e){return(e||"").replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function Vc(e){return e==null||e===""?"(empty)":typeof e=="object"?JSON.stringify(e):String(e)}function bo(e){return(e||"Unknown").replace(/@.*/,"").replace(/[._]/g," ")}function eu(e){return bo(e).split(" ").filter(Boolean).slice(0,2).map(t=>t[0].toUpperCase()).join("")}function By(e){let t={};try{t=JSON.parse(e.data||"{}")}catch{}const l=(t.changed||[]).map(r=>({field:r[0]||"",oldVal:Vc(r[1]),newVal:Vc(r[2])}));return{name:e.name,owner:e.owner,creation:e.creation,changes:l,added:(t.added||[]).length,removed:(t.removed||[]).length,rowChanged:(t.row_changed||[]).length}}function Ui({doctype:e,docname:t,docCreation:l,docOwner:r}){const s=q(),[i,a]=S.useState([]),[u,p]=S.useState(!1),[f,g]=S.useState(!0),[c,o]=S.useState(!1),m=5,j=S.useCallback(async()=>{p(!0);const x=await iy(e,t);a(x.map(By)),p(!1)},[e,t]);S.useEffect(()=>{f||j()},[f,j]);const h=c?i:i.slice(0,m),C=i.length-m,y=(x,d=!1)=>({position:"absolute",left:-14,top:14,width:10,height:10,borderRadius:"50%",background:x,border:"2px solid white",boxShadow:d?`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:()=>g(x=>!x),style:{padding:"12px 20px",borderBottom:f?"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:["📋 ",s.activity.title,!f&&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:[!f&&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:f?"▼":"▲"})]})]}),!f&&n.jsxs("div",{style:{padding:"16px 20px"},children:[u&&n.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:s.loading}),!u&&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,d)=>n.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[n.jsx("div",{style:y(d===0?"#3498db":"#d1d5db",d===0)}),n.jsxs("div",{style:{background:d===0?"#eff6ff":"#f9fafb",border:`1px solid ${d===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:eu(x.owner)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:bo(x.owner)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:Zc(x.creation)})]}),x.changes.length>0?n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:x.changes.map((v,z)=>n.jsxs("div",{style:{fontSize:12,lineHeight:1.5},children:[n.jsx("span",{style:{fontWeight:600,color:"#6d28d9"},children:Wy(v.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:v.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:v.newVal})]},z))}):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)),l&&r&&n.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[n.jsx("div",{style:y("#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:eu(r)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:bo(r)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:Zc(l)})]}),n.jsxs("div",{style:{fontSize:12,color:"#15803d",fontWeight:600},children:["✓ ",s.activity.created]})]})]}),i.length===0&&!l&&n.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:"No activity recorded"})]})]}),!u&&C>0&&n.jsx("div",{style:{textAlign:"center",marginTop:12},children:n.jsx("button",{onClick:()=>o(x=>!x),style:{background:"none",border:"none",cursor:"pointer",color:"#3498db",fontSize:12,fontFamily:"Segoe UI",padding:"4px 8px"},children:c?"▲ Show less":`▼ Show all (${i.length})`})})]})]})}const ur={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},ba={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},$y={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 Uy(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...$y[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function Fy({incForm:e,setIncForm:t,organizations:l,managements:r,departments:s,branches:i,incidentTypes:a,incidentClasses:u,incidentFields:p,incidentStatuses:f,users:g,userRoleMap:c={},formStatus:o,viewMode:m,onEdit:j,userRole:h,onSubmit:C,onBack:y,onNavigate:x,onLogout:d,user:v,onRefresh:z}){const w=q(),b=R=>t({...e,...R}),k=m?{background:"#f9f9f9"}:{},I=Ul(g,c,"SB Employee"),U=Ul(g,c,"SB Manager"),[J,se]=S.useState(""),[$,G]=S.useState(!1),pe=e.name?m?`${w.formTitle.viewIncident}${e.number||e.name}`:w.formTitle.editIncident:w.formTitle.newIncident,ne=ue(r,e.management).map(R=>({name:R.name,label:R.name1||R.name})),Se=ue(s,e.department).map(R=>({name:R.name,label:R.department_name||R.name})),E=ue(i,e.branch).map(R=>({name:R.name,label:R.branch||R.name})),M=ue(a,e.type).map(R=>({name:R.name,label:R.name1||R.name})),W=u.map(R=>({name:R.name,label:R.name1||R.name})),V=p.map(R=>({name:R.name,label:R.name1||R.name})),X=ue(f,e.status).map(R=>({name:R.name,label:R.name1||R.name})),ee=e.workflow_state||"New",Ce=h==="Employee",L=h==="Auditor"||h==="Admin",Z=h==="Manager",Je=e.name?ee==="New"?[{label:w.wf.submit,action:"Submit",color:"#2563eb"}]:ee==="Initial Evaluation"&&L?[{label:w.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:w.wf.reject,action:"Reject",color:"#dc2626"}]:ee==="Accept & Under Progress"&&(Z||L)?[{label:w.wf.submitSolution,action:"Submit Solution",color:"#059669"}]:ee==="working on resolution"&&(Z||L)?[{label:w.wf.resolutionComplete,action:"Resolution complete",color:"#166534"}]:[]:[];async function K(R){if(e.name){G(!0),se("");try{const F={};R==="Assign to Manager"&&(e.assigned_to&&(F.assigned_to=e.assigned_to),e.priority&&(F.priority=e.priority),e.economy_class&&(F.economy_class=e.economy_class),e.entity_scope&&(F.entity_scope=e.entity_scope),e.hses_field&&(F.hses_field=e.hses_field),F.product_relation=String(e.product_relation??0),F.repeated=String(e.repeated??0)),R==="Submit Solution"&&(e.solution&&(F.solution=e.solution),e.summary&&(F.summary=e.summary),e.cost&&(F.cost=String(e.cost))),(R==="Resolution complete"||R==="Submit Solution")&&e.auditor_comment&&(F.auditor_comment=e.auditor_comment),await oy(e.name,R,JSON.stringify(F)),se("Done"),z==null||z()}catch(F){se(F.message||"Error")}finally{G(!1)}}}const A=e.name?n.jsxs("div",{style:{width:260,display:"flex",flexDirection:"column",gap:14},children:[n.jsxs("div",{style:{background:"#f8fafc",borderRadius:10,padding:16,border:"1px solid #e2e8f0"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:14},children:[n.jsx("h4",{style:{fontWeight:700,color:"#1e293b",margin:0,fontSize:14},children:w.wf.workflow}),n.jsx("span",{style:Uy(ee),children:ee})]}),ee==="Initial Evaluation"&&L&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:w.wf.assignToManager}),n.jsxs("select",{style:P,value:e.assigned_to||"",onChange:R=>b({assigned_to:R.target.value}),children:[n.jsx("option",{value:"",children:w.field.selectMgr}),U.map(R=>n.jsx("option",{value:R.name,children:R.full_name||R.name},R.name))]})]}),(ee==="Accept & Under Progress"||ee==="working on resolution")&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:w.field.solution}),n.jsx("textarea",{style:{...P,height:80,resize:"vertical"},value:e.solution||"",onChange:R=>b({solution:R.target.value}),placeholder:w.field.solutionPlaceholder}),n.jsx("label",{style:{...T,marginTop:8},children:w.field.actualCost}),n.jsx("input",{type:"number",style:P,value:e.cost||"",onChange:R=>b({cost:parseFloat(R.target.value)||0}),placeholder:"0.00"})]}),ee==="working on resolution"&&L&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:w.field.auditorComment}),n.jsx("textarea",{style:{...P,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:R=>b({auditor_comment:R.target.value}),placeholder:w.field.commentPlaceholder})]}),Je.length>0?n.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:Je.map(R=>n.jsx("button",{onClick:()=>K(R.action),disabled:$,style:{padding:"8px 18px",borderRadius:8,border:"none",background:R.color,color:"white",fontWeight:700,cursor:$?"not-allowed":"pointer",opacity:$?.7:1},children:$?w.wf.applying:R.label},R.action))}):n.jsx("div",{style:{fontSize:12,color:"#94a3b8",fontStyle:"italic"},children:w.wf.noActions}),J&&n.jsx("p",{style:{marginTop:8,fontSize:13,color:J==="Done"?N.green:N.red},children:J})]}),n.jsx($i,{doctype:D.incidents,docname:e.name,currentUserName:v.name}),n.jsx(Ui,{doctype:D.incidents,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):null;return n.jsxs(We,{title:pe,activePage:"incidents",user:v,formStatus:o,buttonText:w.saveIncident,buttonColor:N.accent,viewMode:m,onEdit:j,rightPanel:A,onSubmit:C,onBack:y,onNavigate:x,onLogout:d,children:[n.jsxs("div",{style:ur,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.number}),n.jsx("input",{style:{...P,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.organization}),n.jsx(_t,{value:e.organization,onChange:R=>b({organization:R}),organizations:l,disabled:m})]})]}),n.jsxs("div",{style:ba,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.management}),n.jsx(de,{value:e.management,onChange:R=>b({management:R}),items:ne,placeholder:w.field.select,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.department}),n.jsx(de,{value:e.department,onChange:R=>b({department:R}),items:Se,placeholder:w.field.select,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.section}),n.jsx("input",{style:{...P,...k},value:e.section_field||"",disabled:m,onChange:R=>b({section_field:R.target.value})})]})]}),n.jsxs("div",{style:ur,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.branch}),n.jsx(de,{value:e.branch,onChange:R=>b({branch:R}),items:E,placeholder:w.field.select,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.hsesField}),n.jsx("input",{style:{...P,...k},value:e.hses_field||"",disabled:m,onChange:R=>b({hses_field:R.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{style:ur,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.type}),n.jsx(de,{value:e.type,onChange:R=>b({type:R}),items:M,placeholder:w.field.selectType,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.title}),n.jsx("input",{style:{...P,...k},value:e.title,disabled:m,onChange:R=>b({title:R.target.value})})]})]}),n.jsxs("div",{style:ur,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.incidentClass}),n.jsx(de,{value:e.incident_class,onChange:R=>b({incident_class:R}),items:W,placeholder:w.field.selectClass,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.incidentField}),n.jsx(de,{value:e.incident_field,onChange:R=>b({incident_field:R}),items:V,placeholder:w.field.selectField,disabled:m})]})]}),n.jsxs("div",{style:ba,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.date}),n.jsx(he,{value:e.date,onChange:R=>b({date:R}),disabled:m,style:{...P,...k}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.time}),n.jsx("input",{type:"time",style:{...P,...k},value:e.time,disabled:m,onChange:R=>b({time:R.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.assignedTo}),n.jsxs("select",{style:{...P,...k},value:e.assigned_to,disabled:m,onChange:R=>b({assigned_to:R.target.value}),children:[n.jsx("option",{value:"",children:w.field.select}),I.map(R=>n.jsx("option",{value:R.name,children:R.full_name||R.name},R.name))]})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.status}),n.jsx(de,{value:e.status,onChange:R=>b({status:R}),items:X,placeholder:w.field.selectStatus,disabled:m})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.description}),n.jsx("textarea",{style:{...P,...k,height:120,resize:"vertical"},value:e.description,disabled:m,onChange:R=>b({description:R.target.value})})]}),!Ce&&n.jsxs("div",{style:{background:"#fffbeb",border:"1px solid #fde68a",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#92400e",marginBottom:10},children:w.steps.auditorTriage}),n.jsxs("div",{style:ba,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.priority}),n.jsxs("select",{style:{...P,...m&&!L?{background:"#f9f9f9"}:{}},value:e.priority||"",disabled:m&&!L,onChange:R=>b({priority:R.target.value}),children:[n.jsx("option",{value:"",children:w.field.select}),n.jsx("option",{value:"High",children:w.field.high}),n.jsx("option",{value:"Normal",children:w.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.economyClass}),n.jsxs("select",{style:{...P,...m&&!L?{background:"#f9f9f9"}:{}},value:e.economy_class||"",disabled:m&&!L,onChange:R=>b({economy_class:R.target.value}),children:[n.jsx("option",{value:"",children:w.field.select}),n.jsx("option",{value:"Expenses",children:w.field.expenses}),n.jsx("option",{value:"Capital",children:w.field.capital}),n.jsx("option",{value:"Earn",children:w.field.earn}),n.jsx("option",{value:"Pay/Loss",children:w.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.entityScope}),n.jsxs("select",{style:{...P,...m&&!L?{background:"#f9f9f9"}:{}},value:e.entity_scope||"",disabled:m&&!L,onChange:R=>b({entity_scope:R.target.value}),children:[n.jsx("option",{value:"",children:w.field.select}),n.jsx("option",{value:"Upstream",children:w.field.upstream}),n.jsx("option",{value:"On-stream",children:w.field.onstream}),n.jsx("option",{value:"Downstream",children:w.field.downstream})]})]})]}),n.jsxs("div",{style:{display:"flex",gap:20,marginTop:12,alignItems:"center"},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:m&&!L,onChange:R=>b({product_relation:R.target.checked?1:0})})," ",w.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&&!L,onChange:R=>b({repeated:R.target.checked?1:0})})," ",w.field.repeatedEvent]})]})]}),!Ce&&n.jsxs("div",{style:{background:"#eff6ff",border:"1px solid #bfdbfe",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#1e40af",marginBottom:10},children:w.steps.managerSolution}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.solution}),n.jsx("textarea",{style:{...P,height:100,resize:"vertical",...m&&!Z&&!L?{background:"#f9f9f9"}:{}},value:e.solution||"",disabled:m&&!Z&&!L,onChange:R=>b({solution:R.target.value}),placeholder:w.field.solutionPlaceholder})]}),n.jsxs("div",{style:ur,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.actualCost}),n.jsx("input",{type:"number",style:{...P,...m&&!Z&&!L?{background:"#f9f9f9"}:{}},value:e.cost||"",disabled:m&&!Z&&!L,onChange:R=>b({cost:parseFloat(R.target.value)||0}),placeholder:"0.00"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.summary}),n.jsx("input",{style:{...P,...m&&!Z&&!L?{background:"#f9f9f9"}:{}},value:e.summary||"",disabled:m&&!Z&&!L,onChange:R=>b({summary:R.target.value}),placeholder:"Brief summary"})]})]})]}),!Ce&&n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:10},children:w.steps.ownerComment}),n.jsx("textarea",{style:{...P,height:80,resize:"vertical",...m&&!L?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:m&&!L,onChange:R=>b({auditor_comment:R.target.value}),placeholder:w.field.commentPlaceholder})]})]})}function My({ideas:e,organizations:t,departments:l,branches:r,ideaStatuses:s,initialOrg:i,initialStatus:a,canModify:u,onView:p,onEdit:f,onDelete:g}){const c=q(),[o,m]=S.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),j=(d,v)=>m(z=>({...z,[d]:v})),[h,C]=S.useState(1),y=e.filter(d=>!(o.search&&!`${d.number} ${d.title}`.toLowerCase().includes(o.search.toLowerCase())||o.organization&&d.organization!==o.organization||o.department&&d.department!==o.department||o.branch&&d.branch!==o.branch||o.status&&d.status!==o.status));S.useEffect(()=>{C(1)},[o]);const x=y.slice((h-1)*te,h*te);return n.jsxs(n.Fragment,{children:[n.jsx(Bi,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.numberTitle}),n.jsx("input",{style:De,value:o.search,onChange:d=>j("search",d.target.value),placeholder:c.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.organization}),n.jsxs("select",{style:De,value:o.organization,onChange:d=>j("organization",d.target.value),children:[n.jsx("option",{value:"",children:c.filter.allOrgs}),t.map(d=>n.jsx("option",{value:d.name,children:d.organization_name||d.name},d.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.department}),n.jsxs("select",{style:De,value:o.department,onChange:d=>j("department",d.target.value),children:[n.jsx("option",{value:"",children:c.filter.allDepts}),l.map(d=>n.jsx("option",{value:d.name,children:d.department_name||d.name},d.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.branch}),n.jsxs("select",{style:De,value:o.branch,onChange:d=>j("branch",d.target.value),children:[n.jsx("option",{value:"",children:c.filter.allBranches}),r.map(d=>n.jsx("option",{value:d.name,children:d.branch||d.name},d.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.status}),n.jsxs("select",{style:De,value:o.status,onChange:d=>j("status",d.target.value),children:[n.jsx("option",{value:"",children:c.filter.allStatuses}),s.map(d=>n.jsx("option",{value:d.name,children:d.name1||d.name},d.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>m({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"5px 12px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#6b7280",fontFamily:"Segoe UI"},children:c.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.number}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.title}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.actions})]})}),n.jsx("tbody",{children:y.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:c.noIdeas})}):x.map((d,v)=>n.jsxs("tr",{onClick:()=>p==null?void 0:p(d),style:{borderTop:"1px solid #f0f0f0",background:v%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",color:"#999"},children:d.number||"—"}),n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:d.title||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:d.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:d.status?En(d.status,Wi(d.status)):"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:z=>z.stopPropagation(),children:n.jsx(Ke,{onView:()=>p==null?void 0:p(d),onEdit:u&&f?()=>f(d):void 0,onDelete:u&&g?()=>g(d.name):void 0})})]},d.name))})]})}),n.jsx(Ne,{page:h,total:y.length,onPageChange:C})]})}const tu={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Sa={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},Hy={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 Ky(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...Hy[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function Qy({ideaForm:e,setIdeaForm:t,organizations:l,managements:r,departments:s,branches:i,ideaTypes:a,ideaStatuses:u,users:p=[],userRoleMap:f={},formStatus:g,viewMode:c,onEdit:o,userRole:m,onSubmit:j,onBack:h,onNavigate:C,onLogout:y,user:x,onRefresh:d}){const v=q(),z=L=>t({...e,...L}),w=c?{background:"#f9f9f9"}:{},b=Ul(p,f,"SB Manager"),[k,I]=S.useState(""),[U,J]=S.useState(!1),se=e.name?c?`${v.formTitle.viewIdea}${e.number||e.title||e.name}`:v.formTitle.editIdea:v.formTitle.newIdea,$=ue(r,e.management).map(L=>({name:L.name,label:L.name1||L.name})),G=ue(s,e.department).map(L=>({name:L.name,label:L.department_name||L.name})),pe=ue(i,e.branch).map(L=>({name:L.name,label:L.branch||L.name})),ne=ue(a,e.type).map(L=>({name:L.name,label:L.name1||L.name})),Se=ue(u,e.status).map(L=>({name:L.name,label:L.name1||L.name})),E=e.workflow_state||"New",M=m==="Employee",W=m==="Auditor"||m==="Admin",V=m==="Manager",X=e.name?E==="New"?[{label:v.wf.submit,action:"Submit",color:"#2563eb"}]:E==="Initial Evaluation"&&W?[{label:v.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:v.wf.reject,action:"Reject",color:"#dc2626"}]:E==="Accept & Under Progress"&&(V||W)?[{label:v.wf.submitSolution,action:"Submit Proposal",color:"#059669"}]:E==="working on proposal"&&W?[{label:v.wf.moveToOutsourcing,action:"Move to Outsourcing",color:"#0369a1"},{label:v.wf.reject,action:"Reject",color:"#dc2626"}]:[]:[];async function ee(L){if(e.name){J(!0),I("");try{const Z={};L==="Assign to Manager"&&(e.assigned_to&&(Z.assigned_to=e.assigned_to),e.priority&&(Z.priority=e.priority),e.economy_class&&(Z.economy_class=e.economy_class),e.entity_scope&&(Z.entity_scope=e.entity_scope),e.hses_field&&(Z.hses_field=e.hses_field),Z.product_relation=String(e.product_relation??0),Z.repeated=String(e.repeated??0)),L==="Submit Proposal"&&(e.solution&&(Z.solution=e.solution),e.proposed_condition&&(Z.proposed_condition=e.proposed_condition),e.cost&&(Z.cost=String(e.cost))),e.auditor_comment&&(L==="Move to Outsourcing"||L==="Reject")&&(Z.auditor_comment=e.auditor_comment),await dy(e.name,L,JSON.stringify(Z)),I("Done"),d==null||d()}catch(Z){I(Z.message||"Error")}finally{J(!1)}}}const Ce=e.name?n.jsxs("div",{style:{width:260,display:"flex",flexDirection:"column",gap:14},children:[n.jsxs("div",{style:{background:"#f8fafc",borderRadius:10,padding:16,border:"1px solid #e2e8f0"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:14},children:[n.jsx("h4",{style:{fontWeight:700,color:"#1e293b",margin:0,fontSize:14},children:v.wf.workflow}),n.jsx("span",{style:Ky(E),children:E})]}),E==="Initial Evaluation"&&W&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:v.wf.assignToManager}),n.jsxs("select",{style:P,value:e.assigned_to||"",onChange:L=>z({assigned_to:L.target.value}),children:[n.jsx("option",{value:"",children:v.field.selectMgr}),b.map(L=>n.jsx("option",{value:L.name,children:L.full_name||L.name},L.name))]})]}),E==="Accept & Under Progress"&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:v.field.solution}),n.jsx("textarea",{style:{...P,height:80,resize:"vertical"},value:e.solution||"",onChange:L=>z({solution:L.target.value}),placeholder:v.field.solutionPlaceholder}),n.jsx("label",{style:{...T,marginTop:8},children:v.field.actualCost}),n.jsx("input",{type:"number",style:P,value:e.cost||"",onChange:L=>z({cost:parseFloat(L.target.value)||0}),placeholder:"0.00"})]}),E==="working on proposal"&&W&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:v.field.auditorComment}),n.jsx("textarea",{style:{...P,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:L=>z({auditor_comment:L.target.value}),placeholder:v.field.commentPlaceholder})]}),X.length>0?n.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:X.map(L=>n.jsx("button",{onClick:()=>ee(L.action),disabled:U,style:{padding:"8px 18px",borderRadius:8,border:"none",background:L.color,color:"white",fontWeight:700,cursor:U?"not-allowed":"pointer",opacity:U?.7:1},children:U?v.wf.applying:L.label},L.action))}):n.jsx("div",{style:{fontSize:12,color:"#94a3b8",fontStyle:"italic"},children:v.wf.noActions}),k&&n.jsx("p",{style:{marginTop:8,fontSize:13,color:k==="Done"?N.green:N.red},children:k})]}),n.jsx($i,{doctype:D.ideas,docname:e.name,currentUserName:x.name}),n.jsx(Ui,{doctype:D.ideas,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):null;return n.jsxs(We,{title:se,activePage:"ideas",user:x,formStatus:g,buttonText:v.saveIdea,buttonColor:N.teal,viewMode:c,onEdit:o,rightPanel:Ce,onSubmit:j,onBack:h,onNavigate:C,onLogout:y,children:[n.jsxs("div",{style:tu,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.number}),n.jsx("input",{style:{...P,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.organization}),n.jsx(_t,{value:e.organization,onChange:L=>z({organization:L}),organizations:l,disabled:c})]})]}),n.jsxs("div",{style:Sa,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.management}),n.jsx(de,{value:e.management,onChange:L=>z({management:L}),items:$,placeholder:v.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.department}),n.jsx(de,{value:e.department,onChange:L=>z({department:L}),items:G,placeholder:v.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.section}),n.jsx("input",{style:{...P,...w},value:e.section_field||"",disabled:c,onChange:L=>z({section_field:L.target.value})})]})]}),n.jsxs("div",{style:tu,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.branch}),n.jsx(de,{value:e.branch,onChange:L=>z({branch:L}),items:pe,placeholder:v.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.date}),n.jsx(he,{value:e.date||"",onChange:L=>z({date:L}),disabled:c,style:{...P,...w}})]})]}),n.jsxs("div",{style:Sa,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.type}),n.jsx(de,{value:e.type,onChange:L=>z({type:L}),items:ne,placeholder:v.field.selectType,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.ideaClass}),n.jsxs("select",{style:{...P,...w},value:e.idea_class||"",disabled:c,onChange:L=>z({idea_class:L.target.value}),children:[n.jsx("option",{value:"",children:v.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:v.field.hsesField}),n.jsx("input",{style:{...P,...w},value:e.hses_field||"",disabled:c,onChange:L=>z({hses_field:L.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.title}),n.jsx("input",{style:{...P,...w},value:e.title,disabled:c,onChange:L=>z({title:L.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.status}),n.jsx(de,{value:e.status,onChange:L=>z({status:L}),items:Se,placeholder:v.field.selectStatus,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.currentCondition}),n.jsx("textarea",{style:{...P,...w,height:110,resize:"vertical"},value:e.current_condition,disabled:c,onChange:L=>z({current_condition:L.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.proposedCondition}),n.jsx("textarea",{style:{...P,...w,height:110,resize:"vertical"},value:e.proposed_condition,disabled:c,onChange:L=>z({proposed_condition:L.target.value})})]}),!M&&n.jsxs("div",{style:{background:"#fffbeb",border:"1px solid #fde68a",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#92400e",marginBottom:10},children:v.steps.auditorEval}),n.jsxs("div",{style:Sa,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.priority}),n.jsxs("select",{style:{...P,...c&&!W?{background:"#f9f9f9"}:{}},value:e.priority||"",disabled:c&&!W,onChange:L=>z({priority:L.target.value}),children:[n.jsx("option",{value:"",children:v.field.select}),n.jsx("option",{value:"High",children:v.field.high}),n.jsx("option",{value:"Normal",children:v.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.economyClass}),n.jsxs("select",{style:{...P,...c&&!W?{background:"#f9f9f9"}:{}},value:e.economy_class||"",disabled:c&&!W,onChange:L=>z({economy_class:L.target.value}),children:[n.jsx("option",{value:"",children:v.field.select}),n.jsx("option",{value:"Expenses",children:v.field.expenses}),n.jsx("option",{value:"Capital",children:v.field.capital}),n.jsx("option",{value:"Earn",children:v.field.earn}),n.jsx("option",{value:"Pay/Loss",children:v.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.entityScope}),n.jsxs("select",{style:{...P,...c&&!W?{background:"#f9f9f9"}:{}},value:e.entity_scope||"",disabled:c&&!W,onChange:L=>z({entity_scope:L.target.value}),children:[n.jsx("option",{value:"",children:v.field.select}),n.jsx("option",{value:"Upstream",children:v.field.upstream}),n.jsx("option",{value:"On-stream",children:v.field.onstream}),n.jsx("option",{value:"Downstream",children:v.field.downstream})]})]})]}),n.jsxs("div",{style:{display:"flex",gap:20,marginTop:12,alignItems:"center"},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:c&&!W,onChange:L=>z({product_relation:L.target.checked?1:0})})," ",v.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:c&&!W,onChange:L=>z({repeated:L.target.checked?1:0})})," ",v.field.repeatedEvent]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:T,children:v.wf.assignToManager}),n.jsxs("select",{style:{...P,...c&&!W?{background:"#f9f9f9"}:{}},value:e.assigned_to||"",disabled:c&&!W,onChange:L=>z({assigned_to:L.target.value}),children:[n.jsx("option",{value:"",children:v.field.select}),b.map(L=>n.jsx("option",{value:L.name,children:L.full_name||L.name},L.name))]})]})]}),!M&&n.jsxs("div",{style:{background:"#eff6ff",border:"1px solid #bfdbfe",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#1e40af",marginBottom:10},children:v.steps.managerSolution}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.solution}),n.jsx("textarea",{style:{...P,height:100,resize:"vertical",...c&&!V&&!W?{background:"#f9f9f9"}:{}},value:e.solution||"",disabled:c&&!V&&!W,onChange:L=>z({solution:L.target.value}),placeholder:v.field.solutionPlaceholder})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:T,children:v.field.actualCost}),n.jsx("input",{type:"number",style:{...P,...c&&!V&&!W?{background:"#f9f9f9"}:{}},value:e.cost||"",disabled:c&&!V&&!W,onChange:L=>z({cost:parseFloat(L.target.value)||0}),placeholder:"0.00"})]})]}),!M&&n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:10},children:v.steps.ownerComment}),n.jsx("textarea",{style:{...P,height:80,resize:"vertical",...c&&!W?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:c&&!W,onChange:L=>z({auditor_comment:L.target.value}),placeholder:v.field.commentPlaceholder})]})]})}function Gy({orders:e,organizations:t,departments:l,branches:r,orderStatuses:s,initialOrg:i,initialStatus:a,canModify:u,onView:p,onEdit:f,onDelete:g}){const c=q(),[o,m]=S.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),j=(d,v)=>m(z=>({...z,[d]:v})),[h,C]=S.useState(1),y=e.filter(d=>!(o.search&&!`${d.number} ${d.title}`.toLowerCase().includes(o.search.toLowerCase())||o.organization&&d.organization!==o.organization||o.department&&d.department!==o.department||o.branch&&d.branch!==o.branch||o.status&&d.status!==o.status));S.useEffect(()=>{C(1)},[o]);const x=y.slice((h-1)*te,h*te);return n.jsxs(n.Fragment,{children:[n.jsx(Bi,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.numberTitle}),n.jsx("input",{style:De,value:o.search,onChange:d=>j("search",d.target.value),placeholder:c.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.organization}),n.jsxs("select",{style:De,value:o.organization,onChange:d=>j("organization",d.target.value),children:[n.jsx("option",{value:"",children:c.filter.allOrgs}),t.map(d=>n.jsx("option",{value:d.name,children:d.organization_name||d.name},d.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.department}),n.jsxs("select",{style:De,value:o.department,onChange:d=>j("department",d.target.value),children:[n.jsx("option",{value:"",children:c.filter.allDepts}),l.map(d=>n.jsx("option",{value:d.name,children:d.department_name||d.name},d.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.branch}),n.jsxs("select",{style:De,value:o.branch,onChange:d=>j("branch",d.target.value),children:[n.jsx("option",{value:"",children:c.filter.allBranches}),r.map(d=>n.jsx("option",{value:d.name,children:d.branch||d.name},d.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.status}),n.jsxs("select",{style:De,value:o.status,onChange:d=>j("status",d.target.value),children:[n.jsx("option",{value:"",children:c.filter.allStatuses}),s.map(d=>n.jsx("option",{value:d.name,children:d.name1||d.name},d.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>m({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"5px 12px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#6b7280",fontFamily:"Segoe UI"},children:c.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.number}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.title}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.type}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.actions})]})}),n.jsx("tbody",{children:y.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:c.noOrders})}):x.map((d,v)=>n.jsxs("tr",{onClick:()=>p==null?void 0:p(d),style:{borderTop:"1px solid #f0f0f0",background:v%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",color:"#999"},children:d.number||"—"}),n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:d.title||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:d.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:d.type?En(d.type,"#8e44ad"):"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:d.status?En(d.status,Wi(d.status)):"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:z=>z.stopPropagation(),children:n.jsx(Ke,{onView:()=>p==null?void 0:p(d),onEdit:u&&f?()=>f(d):void 0,onDelete:u&&g?()=>g(d.name):void 0})})]},d.name))})]})}),n.jsx(Ne,{page:h,total:y.length,onPageChange:C})]})}const Rs={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Ls={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},Yy={1:"Initiation / Bidding",2:"Execution begins",3:"Mid-execution review",4:"Near completion",5:"Closing"},Xy={Draft:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Pending Actor":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},Review:{background:"#f0fdf4",color:"#15803d",border:"1px solid #bbf7d0"},"In Study":{background:"#f1f5f9",color:"#475569",border:"1px solid #cbd5e1"},Closed:{background:"#f0fdf4",color:"#166534",border:"1px solid #bbf7d0"}};function Jy(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...Xy[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function qy({orderForm:e,setOrderForm:t,organizations:l,managements:r,departments:s,branches:i,orderTypes:a,orderStatuses:u,cycles:p=[],users:f,userRoleMap:g={},formStatus:c,viewMode:o,onEdit:m,currentUser:j,userRole:h,onSubmit:C,onBack:y,onNavigate:x,onLogout:d,user:v,onRefresh:z}){var dn;const w=q(),b=O=>t({...e,...O}),k=o?{background:"#f9f9f9"}:{},I=Ul(f,g,"SB Employee"),[U,J]=S.useState(""),[se,$]=S.useState(""),[G,pe]=S.useState(!1),[ne,Se]=S.useState("Agree"),E=e.name?o?`${w.formTitle.viewOrder}${e.number||e.title||e.name}`:w.formTitle.editOrder:w.formTitle.newOrder,M=ue(r,e.management).map(O=>({name:O.name,label:O.name1||O.name})),W=ue(s,e.department).map(O=>({name:O.name,label:O.department_name||O.name})),V=ue(i,e.branch).map(O=>({name:O.name,label:O.branch||O.name})),X=ue(a,e.type).map(O=>({name:O.name,label:O.name1||O.name})),ee=ue(u,e.status).map(O=>({name:O.name,label:O.name1||O.name})),Ce=ue(p,e.cycle).map(O=>({name:O.name,label:O.name1||O.name})),L=!!e.name,Z=e.workflow_state||"Draft",Je=Math.min(5,(e.stage||0)+1),[K,A]=S.useState(Je);S.useEffect(()=>{A(Math.min(5,(e.stage||0)+1))},[e.stage]);const R=h==="Auditor"||h==="Admin"||h==="Manager",F=R||h==="Owner",Mt=!!(j&&(e.actor===j||e.assigned_to===j)),as=L?Z==="Closed"?[]:Z==="Draft"&&R?[{label:"Submit for Review",action:"Submit for Review",color:"#2563eb"}]:Z==="Pending Actor"&&(Mt||R)?[{label:"Update Status",action:"Update Status",color:"#d97706"}]:Z==="Review"&&F?[{label:"Move to Study",action:"Move to Study",color:"#059669"},{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"}]:Z==="In Study"&&F?[{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"},{label:"Close Order",action:"Close Order",color:"#475569"}]:[]:[];async function Ln(O){if(e.name){pe(!0),J("");try{let Qe;O==="Update Status"&&(Qe=ne);const Zn=await ay(e.name,O,se,O==="Update Status"?String(K):void 0,void 0,Qe);if($(""),Se("Agree"),J("Done"),Zn){const Ct=Zn;t({...e,...Ct,stage:Ct.stage??e.stage,completion_pct:Ct.completion_pct??e.completion_pct,workflow_state:Ct.workflow_state??e.workflow_state})}z==null||z()}catch(Qe){J(Qe.message||"Error")}finally{pe(!1)}}}const Fi=L?n.jsxs("div",{style:{width:260,display:"flex",flexDirection:"column",gap:14},children:[n.jsxs("div",{style:{background:"#f8fafc",borderRadius:10,padding:16,border:"1px solid #e2e8f0"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:14},children:[n.jsx("h4",{style:{fontWeight:700,color:"#1e293b",margin:0,fontSize:14},children:w.wf.workflow}),n.jsx("span",{style:Jy(Z),children:Z})]}),Z==="Pending Actor"&&n.jsxs("div",{style:{display:"flex",gap:16,marginBottom:14,flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:["Stage (1–5) — ",K*20,"% complete"]}),n.jsx("input",{type:"number",min:1,max:5,style:{...P,maxWidth:80},value:K,onChange:O=>A(Math.min(5,Math.max(1,parseInt(O.target.value)||1)))})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Cycle Status"}),n.jsxs("select",{style:{...P,minWidth:140},value:ne,onChange:O=>Se(O.target.value),children:[n.jsx("option",{value:"Agree",children:"✅ Agree — on track"}),n.jsx("option",{value:"Deviate",children:"⚠️ Deviate — off plan"}),n.jsx("option",{value:"Unknown",children:"❓ Unknown"})]})]})]}),n.jsxs("div",{style:{marginBottom:14},children:[n.jsxs("label",{style:T,children:["Comment ",ne==="Deviate"&&Z==="Pending Actor"?n.jsx("span",{style:{color:N.red},children:" * required for Deviate"}):"(optional)"]}),n.jsx("textarea",{style:{...P,height:64,resize:"vertical",borderColor:ne==="Deviate"&&!se?"#fca5a5":void 0},value:se,onChange:O=>$(O.target.value),placeholder:"Add a comment…"})]}),n.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:as.map(O=>{const Qe=O.action==="Update Status"&&ne==="Deviate"&&!se.trim();return n.jsx("button",{onClick:()=>Ln(O.action),disabled:G||Qe,title:Qe?"Comment required when status is Deviate":void 0,style:{padding:"8px 18px",borderRadius:8,border:"none",background:O.color,color:"white",fontWeight:700,cursor:G||Qe?"not-allowed":"pointer",opacity:G||Qe?.5:1},children:G?w.wf.applying:O.label},O.action)})}),U&&n.jsx("p",{style:{marginTop:8,fontSize:13,color:U==="Done"?N.green:N.red},children:U}),as.length===0&&n.jsx("div",{style:{fontSize:12,color:"#94a3b8",fontStyle:"italic"},children:w.wf.noActions})]}),n.jsx($i,{doctype:D.orders,docname:e.name,currentUserName:v.name}),n.jsx(Ui,{doctype:D.orders,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):null;return n.jsxs(We,{title:E,activePage:"orders",user:v,formStatus:c,buttonText:w.saveOrder,buttonColor:N.purple,viewMode:o,onEdit:m,rightPanel:Fi,onSubmit:C,onBack:y,onNavigate:x,onLogout:d,children:[n.jsxs("div",{style:Rs,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.number}),n.jsx("input",{style:{...P,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.organization}),n.jsx(_t,{value:e.organization,onChange:O=>b({organization:O}),organizations:l,disabled:o})]})]}),n.jsxs("div",{style:Ls,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.management}),n.jsx(de,{value:e.management,onChange:O=>b({management:O}),items:M,placeholder:w.field.select,disabled:o})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.department}),n.jsx(de,{value:e.department,onChange:O=>b({department:O}),items:W,placeholder:w.field.select,disabled:o})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.section}),n.jsx("input",{style:{...P,...k},value:e.section_field||"",disabled:o,onChange:O=>b({section_field:O.target.value})})]})]}),n.jsxs("div",{style:Rs,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.branch}),n.jsx(de,{value:e.branch,onChange:O=>b({branch:O}),items:V,placeholder:w.field.select,disabled:o})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.type}),n.jsx(de,{value:e.type,onChange:O=>b({type:O}),items:X,placeholder:w.field.selectType,disabled:o})]})]}),n.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:14,marginTop:4},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#475569",marginBottom:10},children:"Classification"}),n.jsxs("div",{style:Ls,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.priority}),n.jsxs("select",{style:{...P,...k},value:e.priority||"",disabled:o,onChange:O=>b({priority:O.target.value}),children:[n.jsx("option",{value:"",children:w.field.select}),n.jsx("option",{value:"High",children:w.field.high}),n.jsx("option",{value:"Normal",children:w.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.economyClass}),n.jsxs("select",{style:{...P,...k},value:e.economy_class||"",disabled:o,onChange:O=>b({economy_class:O.target.value}),children:[n.jsx("option",{value:"",children:w.field.select}),n.jsx("option",{value:"Expenses",children:w.field.expenses}),n.jsx("option",{value:"Capital",children:w.field.capital}),n.jsx("option",{value:"Earn",children:w.field.earn}),n.jsx("option",{value:"Pay/Loss",children:w.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.entityScope}),n.jsxs("select",{style:{...P,...k},value:e.entity_scope||"",disabled:o,onChange:O=>b({entity_scope:O.target.value}),children:[n.jsx("option",{value:"",children:w.field.select}),n.jsx("option",{value:"Upstream",children:w.field.upstream}),n.jsx("option",{value:"On-stream",children:w.field.onstream}),n.jsx("option",{value:"Downstream",children:w.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:o,onChange:O=>b({planned:O.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:o,onChange:O=>b({product_relation:O.target.checked?1:0})})," ",w.field.productRelation]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:T,children:w.field.hsesField}),n.jsx("input",{style:{...P,...k},value:e.hses_field||"",disabled:o,onChange:O=>b({hses_field:O.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.title}),n.jsx("input",{style:{...P,...k},value:e.title,disabled:o,onChange:O=>b({title:O.target.value})})]}),n.jsxs("div",{style:Ls,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.budget}),n.jsx("input",{type:"number",style:{...P,...k},value:e.budget||"",disabled:o,onChange:O=>b({budget:parseFloat(O.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.actualCost}),n.jsx("input",{type:"number",style:{...P,...k},value:e.actual_cost||"",disabled:o,onChange:O=>b({actual_cost:parseFloat(O.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Variance"}),(()=>{const O=(e.budget||0)-(e.actual_cost||0);return n.jsxs("span",{style:{display:"inline-block",padding:"6px 12px",borderRadius:8,fontWeight:700,fontSize:13,background:O>=0?"#f0fdf4":"#fef2f2",color:O>=0?"#166534":"#dc2626",border:`1px solid ${O>=0?"#bbf7d0":"#fecaca"}`},children:[O>=0?"+":"",O.toFixed(2)]})})()]})]}),n.jsxs("div",{style:Rs,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.currency}),n.jsxs("select",{style:{...P,...k},value:e.currency||"",disabled:o,onChange:O=>b({currency:O.target.value}),children:[n.jsx("option",{value:"",children:w.field.select}),n.jsx("option",{value:"SAR",children:"SAR"}),n.jsx("option",{value:"USD",children:"USD"}),n.jsx("option",{value:"EUR",children:"EUR"}),n.jsx("option",{value:"AED",children:"AED"}),n.jsx("option",{value:"GBP",children:"GBP"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.status}),n.jsx(de,{value:e.status,onChange:O=>b({status:O}),items:ee,placeholder:w.field.selectStatus,disabled:o||Z==="Closed"})]})]}),n.jsxs("div",{style:Ls,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.startingDate}),n.jsx(he,{value:e.starting_date,onChange:O=>b({starting_date:O}),disabled:o,style:{...P,...k}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.endingDate}),n.jsx(he,{value:e.ending_date,onChange:O=>b({ending_date:O}),disabled:o,style:{...P,...k}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.actor}),n.jsxs("select",{style:{...P,...k},value:e.actor||e.assigned_to||"",disabled:o,onChange:O=>b({actor:O.target.value,assigned_to:O.target.value}),children:[n.jsx("option",{value:"",children:w.field.select}),I.map(O=>n.jsx("option",{value:O.name,children:O.full_name||O.name},O.name))]})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",fontSize:13,marginBottom:12},children:"Cycle & Progress"}),n.jsxs("div",{style:Rs,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.cycle}),n.jsx(de,{value:e.cycle||"",onChange:O=>b({cycle:O}),items:Ce,placeholder:w.field.select,disabled:o})]}),n.jsxs("div",{style:{display:"flex",gap:20,flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.stage}),n.jsx("input",{type:"number",min:1,max:5,style:{...P,background:"#f9f9f9",maxWidth:80},value:e.stage||1,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Completion"}),n.jsx("input",{style:{...P,background:"#f9f9f9",maxWidth:100},value:`${e.completion_pct||(e.stage||1)*20}%`,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Stage Description"}),n.jsx("span",{style:{display:"inline-block",padding:"6px 12px",borderRadius:8,fontSize:13,fontWeight:600,background:"#f0f9ff",color:"#0369a1",border:"1px solid #bae6fd"},children:Yy[e.stage||1]||"—"})]}),(e.escalation_level??0)>0&&n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.escalationLevel}),n.jsxs("span",{style:{display:"inline-block",padding:"6px 12px",background:"#fecaca",color:"#e74c3c",borderRadius:8,fontWeight:700,fontSize:13},children:["Level ",e.escalation_level]})]})]})]})]}),L&&((dn=e.order_cycle_log)==null?void 0:dn.length)>0&&n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",fontSize:13,marginBottom:10},children:"Cycle History"}),n.jsx("div",{style:{overflowX:"auto"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8fafc"},children:["Cycle","Date","Stage","Status","Actor","Comment"].map(O=>n.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#475569",borderBottom:"1px solid #e2e8f0"},children:O},O))})}),n.jsx("tbody",{children:(e.order_cycle_log||[]).map((O,Qe)=>{const Zn=O.status==="Agree"?"#166534":O.status==="Deviate"?"#c2410c":"#92400e",Ct=O.status==="Agree"?"#f0fdf4":O.status==="Deviate"?"#fff7ed":"#fefce8";return n.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:O.cycle||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:O.cycle_date||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155",textAlign:"center"},children:O.stage||"—"}),n.jsx("td",{style:{padding:"6px 10px"},children:n.jsx("span",{style:{background:Ct,color:Zn,padding:"2px 8px",borderRadius:12,fontWeight:600,fontSize:12},children:O.status||"—"})}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:O.actor||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#64748b",fontStyle:O.comment?"normal":"italic"},children:O.comment||"—"})]},Qe)})})]})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.description}),n.jsx("textarea",{style:{...P,...k,height:100,resize:"vertical"},value:e.description,disabled:o,onChange:O=>b({description:O.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.notes}),n.jsx("textarea",{style:{...P,...k,height:100,resize:"vertical"},value:e.notes,disabled:o,onChange:O=>b({notes:O.target.value})})]}),n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:16,marginTop:4},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:8},children:w.field.auditorComment}),n.jsx("textarea",{style:{...P,height:80,resize:"vertical",...o&&Mt&&!R?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:o&&Mt&&!R,onChange:O=>b({auditor_comment:O.target.value}),placeholder:w.field.commentPlaceholder})]})]})}function Zy({processes:e,organizations:t,departments:l,branches:r,processStatuses:s,initialOrg:i,initialStatus:a,canModify:u,onView:p,onEdit:f,onDelete:g}){const c=q(),[o,m]=S.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),j=(d,v)=>m(z=>({...z,[d]:v})),[h,C]=S.useState(1),y=e.filter(d=>!(o.search&&!`${d.number} ${d.title}`.toLowerCase().includes(o.search.toLowerCase())||o.organization&&d.organization!==o.organization||o.department&&d.department!==o.department||o.branch&&d.branch!==o.branch||o.status&&d.status!==o.status));S.useEffect(()=>{C(1)},[o]);const x=y.slice((h-1)*te,h*te);return n.jsxs(n.Fragment,{children:[n.jsx(Bi,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.numberTitle}),n.jsx("input",{style:De,value:o.search,onChange:d=>j("search",d.target.value),placeholder:c.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.organization}),n.jsxs("select",{style:De,value:o.organization,onChange:d=>j("organization",d.target.value),children:[n.jsx("option",{value:"",children:c.filter.allOrgs}),t.map(d=>n.jsx("option",{value:d.name,children:d.organization_name||d.name},d.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.department}),n.jsxs("select",{style:De,value:o.department,onChange:d=>j("department",d.target.value),children:[n.jsx("option",{value:"",children:c.filter.allDepts}),l.map(d=>n.jsx("option",{value:d.name,children:d.department_name||d.name},d.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.branch}),n.jsxs("select",{style:De,value:o.branch,onChange:d=>j("branch",d.target.value),children:[n.jsx("option",{value:"",children:c.filter.allBranches}),r.map(d=>n.jsx("option",{value:d.name,children:d.branch||d.name},d.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Oe,children:c.filter.status}),n.jsxs("select",{style:De,value:o.status,onChange:d=>j("status",d.target.value),children:[n.jsx("option",{value:"",children:c.filter.allStatuses}),s.map(d=>n.jsx("option",{value:d.name,children:d.name1||d.name},d.name)),n.jsx("option",{value:"Closed",children:"Closed"})]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>m({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"5px 12px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#6b7280",fontFamily:"Segoe UI"},children:c.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.number}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.title}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.field.cycleType}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:c.col.actions})]})}),n.jsx("tbody",{children:y.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:c.noProcesses})}):x.map((d,v)=>n.jsxs("tr",{onClick:()=>p==null?void 0:p(d),style:{borderTop:"1px solid #f0f0f0",background:v%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",color:"#999"},children:d.number||"—"}),n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:d.title||d.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:d.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:d.cycle_type?En(d.cycle_type,"#8e44ad"):"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:d.status?En(d.status,Wi(d.status)):"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:z=>z.stopPropagation(),children:n.jsx(Ke,{onView:()=>p==null?void 0:p(d),onEdit:u&&f?()=>f(d):void 0,onDelete:u&&g?()=>g(d.name):void 0})})]},d.name))})]})}),n.jsx(Ne,{page:h,total:y.length,onPageChange:C})]})}const Vy={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"]}]},e0={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 nu(e){return{display:"inline-block",padding:"5px 14px",borderRadius:20,fontSize:13,fontWeight:700,...e0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}const Os={width:"100%",padding:"6px 8px",border:"1px solid #d1d5db",borderRadius:5,fontSize:12,fontFamily:"Segoe UI",boxSizing:"border-box"};function t0({processName:e,userRole:t,onRefresh:l,canUpdateStatus:r=!0}){const[s,i]=S.useState(null),[a,u]=S.useState(!0),[p,f]=S.useState(""),[g,c]=S.useState(!1),[o,m]=S.useState(""),[j,h]=S.useState(""),[C,y]=S.useState("Pass"),[x,d]=S.useState(""),[v,z]=S.useState({}),w=S.useCallback(async()=>{if(!e){u(!1);return}u(!0),f("");try{const $=await zr(e);i($);const G={};for(const pe of $.progress_indicators||[])G[pe.name]=pe.actual_value!=null?String(pe.actual_value):"";z(G)}catch($){f($ instanceof Error?$.message:"Failed to load process")}u(!1)},[e]);if(S.useEffect(()=>{w()},[w]),a)return n.jsx("div",{style:{width:260,flexShrink:0},children:n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",padding:24,color:"#aaa",fontSize:13,textAlign:"center"},children:"Loading…"})});if(p||!s)return n.jsx("div",{style:{width:260,flexShrink:0},children:n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",padding:16},children:n.jsx("div",{style:{fontSize:12,color:"#991b1b",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,padding:"8px 12px"},children:p||"Could not load workflow"})})});const b=s.workflow_state||"Draft",k=Vy[b]??[],I=t==="Employee"||t==="Manager",U=t!=="Manager"||r,J=k.filter($=>(t==="Admin"||$.allowedRoles.includes(t))&&($.action!=="Update Status"||U)),se=async $=>{c(!0),m(""),h("");try{const G={};if($==="Update Status"){G.actor_status=C,G.actor_comment=x;const ne=s.progress_indicators||[];ne.length>0&&(G.progress_indicators=ne.map(Se=>({name:Se.name,actual_value:v[Se.name]??""})))}$==="Add Comment"&&x&&(G.actor_comment=x);const pe=await by(s.name,$,G);i(pe),d(""),h(`Done — now: ${pe.workflow_state||"updated"}`),l==null||l()}catch(G){m(G instanceof Error?G.message:"Action failed")}c(!1)};return n.jsx("div",{style:{width:260,flexShrink:0},children:n.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[n.jsx("div",{style:{background:"#1a2332",color:"white",padding:"10px 14px",fontSize:12,fontWeight:700,letterSpacing:.3},children:"Workflow"}),n.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:8},children:"Current State"}),n.jsx("div",{style:nu(b),children:b})]}),b==="Pending Actor"&&I&&U&&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(s.progress_indicators)&&s.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:s.progress_indicators.map($=>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:$.name1,children:$.name1||$.name}),n.jsx("input",{type:"number",value:v[$.name]??"",onChange:G=>z(pe=>({...pe,[$.name]:G.target.value})),style:{...Os,width:70,flexShrink:0},placeholder:"0"})]},$.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:C,onChange:$=>y($.target.value),style:Os,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($.target.value),style:{...Os,height:52,resize:"vertical"},placeholder:"Add a comment…"})]})]}),(b==="Pending Comment"||b==="Review")&&!I&&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(s.cycle_logs)&&s.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 $=s.cycle_logs,G=$[$.length-1],pe=G.status==="Pass"?"#16a34a":G.status==="Fail"?"#dc2626":"#9ca3af";return n.jsxs("div",{style:{fontSize:13,fontWeight:700,color:pe},children:[G.status," ",G.comment?`— ${G.comment}`:""]})})()]}),n.jsx("textarea",{value:x,onChange:$=>d($.target.value),style:{...Os,height:52,resize:"vertical"},placeholder:"Add a comment…"})]}),n.jsxs("div",{style:{padding:"12px 14px",borderBottom:J.length>0?"1px solid #f0f0f0":"none"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Actions"}),J.length===0&&n.jsxs("div",{style:{fontSize:12,color:"#aaa",fontStyle:"italic",lineHeight:1.5},children:["No actions for ",n.jsx("strong",{children:t})," in ",n.jsx("strong",{children:b}),"."]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:J.map($=>n.jsxs("button",{onClick:()=>se($.action),disabled:g,style:{width:"100%",padding:"10px 14px",borderRadius:6,border:"none",background:$.action==="Close Process"?"#64748b":$.action==="Move to Study"?"#8e44ad":"#2563eb",color:"white",cursor:g?"not-allowed":"pointer",fontSize:13,fontWeight:600,opacity:g?.7:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsx("span",{children:g?"Applying…":$.action}),n.jsxs("span",{style:{fontSize:10,opacity:.7},children:["→ ",$.next]})]},$.action))}),o&&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:o}),j&&n.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,fontSize:12,color:"#166534"},children:j})]}),k.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"}),k.map($=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6,fontSize:11},children:[n.jsx("span",{style:{color:"#555",flex:1},children:$.action}),n.jsx("span",{style:{color:"#bbb"},children:"→"}),n.jsx("span",{style:nu($.next),children:$.next})]},$.action))]})]})})}const Ds={display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},dl={display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:16};function n0({processForm:e,setProcessForm:t,organizations:l,managements:r,departments:s,branches:i,processTypes:a,processStatuses:u,cycles:p=[],users:f=[],userRoleMap:g={},formStatus:c,viewMode:o,onEdit:m,userRole:j,delegatedFunctions:h=[],delegatedOrgs:C=null,onRefreshProcess:y,onSubmit:x,onBack:d,onNavigate:v,onLogout:z,user:w}){const b=q(),k=A=>t({...e,...A}),I=o?{background:"#f9f9f9"}:{},U=!o&&j==="Manager"&&Array.isArray(C),J=U?l.filter(A=>(C||[]).includes(A.organization_name||A.name)):l,se=U&&(C||[]).length===1,$=ue(r,e.management).map(A=>({name:A.name,label:A.name1||A.name})),G=ue(s,e.department).map(A=>({name:A.name,label:A.department_name||A.name})),pe=ue(i,e.branch).map(A=>({name:A.name,label:A.branch||A.name})),ne=ue(a,e.type).map(A=>({name:A.name,label:A.name1||A.name})),Se=ue(u,e.status).map(A=>({name:A.name,label:A.name1||A.name})),E=ue(p,e.cycle).map(A=>({name:A.name,label:A.name1||A.name})),M=Ul(f,g,"SB Employee").map(A=>({name:A.name,label:A.full_name||A.name})),W=(A,R)=>{const F=[...e.cycle_logs||[]];F[A]={...F[A],...R},k({cycle_logs:F})},V=()=>{k({cycle_logs:[...e.cycle_logs||[],{cycle:"",cycle_date:"",status:"Pass",actor:"",comment:""}]})},X=A=>{const R=[...e.cycle_logs||[]];R.splice(A,1),k({cycle_logs:R})},ee=(A,R)=>{const F=[...e.progress_indicators||[]];F[A]={...F[A],...R},k({progress_indicators:F})},Ce=()=>{k({progress_indicators:[...e.progress_indicators||[],{name1:"",type:"Nominal",unit:"",cycle:"",target:"",maximum:"",minimum:"",manager:"",order:"",actual_value:"",cycle_status:"",cycle_date:"",cycle_comment:"",status:""}]})},L=A=>{const R=[...e.progress_indicators||[]];R.splice(A,1),k({progress_indicators:R})},Z=e.name?o?`${b.formTitle.viewProcess}${e.title||e.name}`:b.formTitle.editProcess:b.formTitle.newProcess,Je=j!=="Manager"||e.actor===w.name||h.includes("update_process_status"),K=e.name?n.jsxs("div",{style:{width:260,display:"flex",flexDirection:"column",gap:14},children:[n.jsx(t0,{processName:e.name,userRole:j||w.role||"Employee",onRefresh:y,canUpdateStatus:Je}),n.jsx($i,{doctype:D.processes,docname:e.name,currentUserName:w.name}),n.jsx(Ui,{doctype:D.processes,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):void 0;return n.jsxs(We,{title:Z,activePage:"processes",user:w,formStatus:c,buttonText:b.saveProcess,buttonColor:N.blue,viewMode:o,onEdit:m,rightPanel:K,onSubmit:x,onBack:d,onNavigate:v,onLogout:z,children:[n.jsxs("div",{style:Ds,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.number}),n.jsx("input",{style:{...P,background:"#f9f9f9"},value:e.number||"",readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.organization}),n.jsx(_t,{value:e.organization,onChange:A=>k({organization:A}),organizations:J,disabled:o||se}),U&&n.jsx("div",{style:{fontSize:11,color:"#888",marginTop:4},children:(C||[]).length===0?"You have no delegated organization for Processes.":`Restricted to your delegated organization${(C||[]).length>1?"s":""}: ${(C||[]).join(", ")}`})]})]}),n.jsxs("div",{style:Ds,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.title}),n.jsx("input",{style:{...P,...I},value:e.title,disabled:o,onChange:A=>k({title:A.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.type}),n.jsx(de,{value:e.type,onChange:A=>k({type:A}),items:ne,placeholder:b.field.selectType,disabled:o})]})]}),n.jsxs("div",{style:dl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.management}),n.jsx(de,{value:e.management,onChange:A=>k({management:A}),items:$,placeholder:b.field.select,disabled:o})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.department}),n.jsx(de,{value:e.department,onChange:A=>k({department:A}),items:G,placeholder:b.field.select,disabled:o})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.section}),n.jsx("input",{style:{...P,...I},value:e.section_field||"",disabled:o,onChange:A=>k({section_field:A.target.value})})]})]}),n.jsxs("div",{style:Ds,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.branch}),n.jsx(de,{value:e.branch,onChange:A=>k({branch:A}),items:pe,placeholder:b.field.select,disabled:o})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[b.field.status," ",n.jsx("span",{style:{fontSize:11,color:"#9ca3af",fontWeight:400},children:"(auto-updated from cycle)"})]}),n.jsx(de,{value:e.status,onChange:A=>k({status:A}),items:Se,placeholder:b.field.selectStatus,disabled:o})]})]}),n.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:14},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#475569",marginBottom:10},children:"Classification"}),n.jsxs("div",{style:dl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.chainLocation}),n.jsxs("select",{style:{...P,...I},value:e.chain_location||"",disabled:o,onChange:A=>k({chain_location:A.target.value}),children:[n.jsx("option",{value:"",children:b.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:b.field.economyClass}),n.jsxs("select",{style:{...P,...I},value:e.economy_class||"",disabled:o,onChange:A=>k({economy_class:A.target.value}),children:[n.jsx("option",{value:"",children:b.field.select}),n.jsx("option",{value:"Expenses",children:b.field.expenses}),n.jsx("option",{value:"Capital",children:b.field.capital}),n.jsx("option",{value:"Earn",children:b.field.earn}),n.jsx("option",{value:"Pay/Loss",children:b.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.impactLevel}),n.jsxs("select",{style:{...P,...I},value:e.impact_level||"",disabled:o,onChange:A=>k({impact_level:A.target.value}),children:[n.jsx("option",{value:"",children:b.field.select}),n.jsx("option",{value:"High",children:b.field.high}),n.jsx("option",{value:"Normal",children:b.field.normal})]})]})]}),n.jsxs("div",{style:dl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.entityScope}),n.jsxs("select",{style:{...P,...I},value:e.entity_scope||"",disabled:o,onChange:A=>k({entity_scope:A.target.value}),children:[n.jsx("option",{value:"",children:b.field.select}),n.jsx("option",{value:"Upstream",children:b.field.upstream}),n.jsx("option",{value:"On-stream",children:b.field.onstream}),n.jsx("option",{value:"Downstream",children:b.field.downstream})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.hsesField}),n.jsx("input",{style:{...P,...I},value:e.hses_field||"",disabled:o,onChange:A=>k({hses_field:A.target.value}),placeholder:"Safety, Health, Environment…"})]}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,paddingTop:22},children:n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:o,onChange:A=>k({product_relation:A.target.checked?1:0})})," ",b.field.productRelation]})})]})]}),n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:14},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:10},children:"KPI"}),n.jsxs("div",{style:dl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.kpiName}),n.jsx("input",{style:{...P,...I},value:e.kpi_name||"",disabled:o,onChange:A=>k({kpi_name:A.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.kpiType}),n.jsxs("select",{style:{...P,...I},value:e.kpi_type||"",disabled:o,onChange:A=>k({kpi_type:A.target.value}),children:[n.jsx("option",{value:"",children:b.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:b.field.kpiMeasure}),n.jsx("input",{style:{...P,...I},value:e.kpi_measure||"",disabled:o,onChange:A=>k({kpi_measure:A.target.value}),placeholder:"Unit of measure"})]})]})]}),n.jsxs("div",{style:dl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.dateStart}),n.jsx(he,{value:e.date_start,onChange:A=>k({date_start:A}),disabled:o,style:{...P,...I}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.dateEnd}),n.jsx(he,{value:e.date_end,onChange:A=>k({date_end:A}),disabled:o,style:{...P,...I}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.cycleType}),n.jsxs("select",{style:{...P,...I},value:e.cycle_type||"",disabled:o,onChange:A=>k({cycle_type:A.target.value}),children:[n.jsx("option",{value:"",children:b.field.select}),n.jsx("option",{value:"Normal",children:"Normal"}),n.jsx("option",{value:"Long",children:"Long"})]})]})]}),e.cycle_type==="Long"&&n.jsxs("div",{style:{background:"#fff7ed",border:"1px solid #fed7aa",borderRadius:8,padding:14},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#c2410c",marginBottom:10},children:"Long Cycle Milestone Dates"}),n.jsxs("div",{style:Ds,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Milestone 1"}),n.jsx(he,{value:e.long_cycle_date_1||"",onChange:A=>k({long_cycle_date_1:A}),disabled:o,style:{...P,...I}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Milestone 2"}),n.jsx(he,{value:e.long_cycle_date_2||"",onChange:A=>k({long_cycle_date_2:A}),disabled:o,style:{...P,...I}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Milestone 3"}),n.jsx(he,{value:e.long_cycle_date_3||"",onChange:A=>k({long_cycle_date_3:A}),disabled:o,style:{...P,...I}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Milestone 4"}),n.jsx(he,{value:e.long_cycle_date_4||"",onChange:A=>k({long_cycle_date_4:A}),disabled:o,style:{...P,...I}})]})]})]}),n.jsxs("div",{style:{marginTop:24,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[n.jsx("div",{style:{...T,margin:0,fontSize:15},children:"Progress Indicators"}),!o&&n.jsx("button",{type:"button",onClick:Ce,style:{padding:"8px 14px",border:"1px solid #3498db",background:"#3498db",color:"white",borderRadius:6,cursor:"pointer"},children:"Add row"})]}),n.jsx("div",{style:{overflowX:"auto",minWidth:0},children:n.jsxs("table",{style:{borderCollapse:"collapse",fontSize:12,width:"max-content",minWidth:"100%"},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa"},children:[n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Order"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Name"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Type"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Unit"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Target"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Min"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Max"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Manager"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Actual Value"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle Status"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle Date"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle Comment"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Status"}),!o&&n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Actions"})]})}),n.jsxs("tbody",{children:[(e.progress_indicators||[]).length===0&&n.jsx("tr",{children:n.jsx("td",{colSpan:o?14:15,style:{padding:18,textAlign:"center",color:"#aaa"},children:"No progress indicators"})}),(e.progress_indicators||[]).map((A,R)=>n.jsxs("tr",{style:{background:R%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...I,width:60},value:A.order??"",disabled:o,onChange:F=>ee(R,{order:F.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...I},value:A.name1,disabled:o,onChange:F=>ee(R,{name1:F.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...I},value:A.type,disabled:o,onChange:F=>ee(R,{type:F.target.value}),children:[n.jsx("option",{children:"Nominal"}),n.jsx("option",{children:"Ordinal"}),n.jsx("option",{children:"Interval"}),n.jsx("option",{children:"Ratio"})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...I,width:70},type:"number",value:A.unit??"",disabled:o,onChange:F=>ee(R,{unit:parseFloat(F.target.value)||""})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...I},value:A.cycle,disabled:o,onChange:F=>ee(R,{cycle:F.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...I,width:80},value:A.target,disabled:o,onChange:F=>ee(R,{target:F.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...I,width:80},value:A.minimum,disabled:o,onChange:F=>ee(R,{minimum:F.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...I,width:80},value:A.maximum,disabled:o,onChange:F=>ee(R,{maximum:F.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...I},value:A.manager,disabled:o,onChange:F=>ee(R,{manager:F.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...I,width:90},type:"number",value:A.actual_value??"",disabled:o,onChange:F=>ee(R,{actual_value:parseFloat(F.target.value)||""})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...I},value:A.cycle_status??"",disabled:o,onChange:F=>ee(R,{cycle_status:F.target.value}),children:[n.jsx("option",{value:"",children:"--"}),n.jsx("option",{children:"Normal"}),n.jsx("option",{children:"Below Min"}),n.jsx("option",{children:"Above Max"}),n.jsx("option",{children:"At Risk"})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx(he,{value:A.cycle_date||"",onChange:F=>ee(R,{cycle_date:F}),disabled:o,style:{...P,...I,width:110}})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...I},value:A.cycle_comment??"",disabled:o,onChange:F=>ee(R,{cycle_comment:F.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...I},value:A.status??"",disabled:o,onChange:F=>ee(R,{status:F.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"})]})}),!o&&n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("button",{type:"button",onClick:()=>L(R),style:{padding:"6px 10px",border:"1px solid #e74c3c",background:"white",color:"#e74c3c",borderRadius:6,cursor:"pointer"},children:"Remove"})})]},R))]})]})})]}),n.jsxs("div",{style:{marginTop:28,borderTop:"1px solid #e9ecef",paddingTop:20},children:[n.jsx("div",{style:{...T,fontSize:15,marginBottom:14},children:"Cycle & Assignment"}),n.jsxs("div",{style:dl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.cycle}),n.jsx(de,{value:e.cycle||"",onChange:A=>k({cycle:A}),items:E,placeholder:b.field.select,disabled:o})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.actor}),n.jsxs("select",{style:{...P,...I},value:e.actor||"",disabled:o,onChange:A=>k({actor:A.target.value}),children:[n.jsx("option",{value:"",children:b.field.select}),M.map(A=>n.jsx("option",{value:A.name,children:A.label},A.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.costPerCycle}),n.jsx("input",{style:{...P,...I},type:"number",value:e.cost_per_cycle||"",disabled:o,onChange:A=>k({cost_per_cycle:parseFloat(A.target.value)||0}),placeholder:"0.00"})]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:T,children:b.field.escalationLevel}),n.jsx("input",{style:{...P,...I,maxWidth:120},type:"number",value:e.escalation_level||"",disabled:o,onChange:A=>k({escalation_level:parseInt(A.target.value)||0})})]})]}),n.jsxs("div",{style:{marginTop:28,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[n.jsx("div",{style:{...T,margin:0,fontSize:15},children:"Cycle History"}),!o&&n.jsx("button",{type:"button",onClick:V,style:{padding:"8px 14px",border:"1px solid #3498db",background:"#3498db",color:"white",borderRadius:6,cursor:"pointer"},children:"Add row"})]}),n.jsx("div",{style:{overflowX:"auto",minWidth:0},children:n.jsxs("table",{style:{borderCollapse:"collapse",fontSize:12,width:"max-content",minWidth:"100%"},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa"},children:[n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Date"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Status"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Actor"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Comment"}),!o&&n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Actions"})]})}),n.jsxs("tbody",{children:[(e.cycle_logs||[]).length===0&&n.jsx("tr",{children:n.jsx("td",{colSpan:o?5:6,style:{padding:18,textAlign:"center",color:"#aaa"},children:"No cycle history"})}),(e.cycle_logs||[]).map((A,R)=>n.jsxs("tr",{style:{background:R%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...I},value:A.cycle||"",disabled:o,onChange:F=>W(R,{cycle:F.target.value}),children:[n.jsx("option",{value:"",children:"-- Select --"}),E.map(F=>n.jsx("option",{value:F.name,children:F.label},F.name))]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx(he,{value:A.cycle_date||"",onChange:F=>W(R,{cycle_date:F}),disabled:o,style:{...P,...I,width:130}})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...I},value:A.status,disabled:o,onChange:F=>W(R,{status:F.target.value}),children:[n.jsx("option",{value:"Pass",children:"Pass"}),n.jsx("option",{value:"Fail",children:"Fail"}),n.jsx("option",{value:"Unknown",children:"Unknown"})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...P,...I},value:A.actor||"",disabled:o,onChange:F=>W(R,{actor:F.target.value}),children:[n.jsx("option",{value:"",children:"-- Select --"}),M.map(F=>n.jsx("option",{value:F.name,children:F.label},F.name))]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...P,...I},value:A.comment||"",disabled:o,onChange:F=>W(R,{comment:F.target.value})})}),!o&&n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("button",{type:"button",onClick:()=>X(R),style:{padding:"6px 10px",border:"1px solid #e74c3c",background:"white",color:"#e74c3c",borderRadius:6,cursor:"pointer"},children:"Remove"})})]},R))]})]})})]}),n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:16,marginTop:16},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:8},children:b.field.auditorComment}),n.jsx("textarea",{style:{...P,height:80,resize:"vertical",...o?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:o,onChange:A=>k({auditor_comment:A.target.value}),placeholder:b.field.commentPlaceholder})]})]})}const lu={"SB Process":"processes-form","SB Order":"orders-form","SB Incident":"incidents-form","SB Idea":"ideas-form","SB Delegation":"delegations"};function l0(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 r0({notifCount:e,darkMode:t,onCountChange:l,onToggleDark:r,onViewProfile:s,onLogout:i,onNavigate:a}){const[u,p]=S.useState(!1),[f,g]=S.useState([]),[c,o]=S.useState(!1),m=S.useRef(null);S.useEffect(()=>{const k=I=>{m.current&&!m.current.contains(I.target)&&p(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[]);const j=async()=>{o(!0);const k=await ey(30);g(k),o(!1)},h=()=>{const k=!u;p(k),k&&j()},C=async()=>{await ty(),g(k=>k.map(I=>({...I,read:1}))),l(0)},y=k=>{k.read||(ny(k.name),g(U=>U.map(J=>J.name===k.name?{...J,read:1}:J)),l(Math.max(0,e-1)));const I=k.document_type?lu[k.document_type]:void 0;I&&a&&(a(I,k.document_type==="SB Delegation"?void 0:k.document_name),p(!1))},x=f.filter(k=>!k.read).length,d=k=>({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,...k}),v=t,z=v?"#1a202c":"white",w=v?"#2d3748":"#e5e7eb",b=v?"#e2e8f0":"#1a2332";return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx("button",{style:d({background:"#4f46e5",color:"white"}),onClick:s,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:m,style:{position:"relative"},children:[n.jsxs("button",{style:d(),onClick:h,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})]}),u&&n.jsxs("div",{style:{position:"absolute",right:0,top:"calc(100% + 8px)",width:340,background:z,borderRadius:12,boxShadow:"0 8px 32px rgba(0,0,0,0.2)",zIndex:1e4,border:`1px solid ${w}`,overflow:"hidden"},children:[n.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${w}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:z},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:b},children:["Notifications",x>0&&n.jsxs("span",{style:{background:"#ef4444",color:"white",fontSize:10,fontWeight:700,borderRadius:999,padding:"2px 7px"},children:[x," new"]})]}),x>0&&n.jsx("button",{onClick:C,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:[c&&n.jsx("div",{style:{padding:20,textAlign:"center",color:"#aaa",fontSize:13},children:"Loading…"}),!c&&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"})]}),!c&&f.map(k=>{const I=!!(k.document_type&&lu[k.document_type]&&a);return n.jsxs("div",{onClick:()=>y(k),style:{padding:"11px 16px",borderBottom:`1px solid ${v?"#2d3748":"#f5f5f5"}`,display:"flex",gap:10,background:k.read?z:v?"#1e3a5f":"#eff6ff",cursor:I?"pointer":"default",transition:"background 0.12s"},onMouseEnter:U=>{I&&(U.currentTarget.style.background=v?"#243244":"#e0ecfd")},onMouseLeave:U=>{U.currentTarget.style.background=k.read?z:v?"#1e3a5f":"#eff6ff"},children:[n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:13,fontWeight:k.read?400:600,color:b,marginBottom:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.subject||`${k.document_type}: ${k.document_name}`}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:k.document_type&&n.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#3b82f6",background:v?"rgba(59,130,246,0.15)":"#eff6ff",padding:"1px 7px",borderRadius:8},children:[k.document_type.replace("SB ",""),k.document_name?` · ${k.document_name}`:""]})}),n.jsx("div",{style:{fontSize:11,color:"#aaa",marginTop:3},children:l0(k.creation)})]}),!k.read&&n.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:"#3498db",flexShrink:0,marginTop:5}})]},k.name)})]})]})]}),n.jsx("button",{style:d(),onClick:If,title:zl()?"Switch to English":"Switch to Arabic",children:n.jsx("span",{style:{fontSize:13,fontWeight:700,fontFamily:"serif"},children:"عA"})}),n.jsx("button",{style:d(),onClick:r,title:t?"Light mode":"Dark mode",children:t?n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"5"}),n.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),n.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),n.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),n.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),n.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),n.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),n.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),n.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}),n.jsx("button",{style:d({background:v?"#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"})]})})]})}const s0={Admin:"#7c3aed",Auditor:"#d97706",Owner:"#0369a1",XAuditor:"#0f766e",Manager:"#2563eb",Employee:"#6b7280",Chairman:"#0f766e"};function i0({user:e,profileUser:t,darkMode:l,canModify:r,onBack:s,organizations:i=[],managements:a=[],departments:u=[],branches:p=[]}){const f=t||{},g=!!r&&e.role==="Admin",[c,o]=S.useState({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||""}),[m,j]=S.useState(""),[h,C]=S.useState(!1),[y,x]=S.useState({new:"",confirm:""}),[d,v]=S.useState(""),z=f.email||f.name||"",w=[c.first_name,c.middle_name,c.last_name].filter(Boolean).join(" ")||f.full_name||"",b=f.username||f.name||"",k=c.custom_category||"",I=f.enabled===0?"Inactive":"Active",U=s0[e.role]||"#6b7280",J=l,se=J?"#0f172a":"#f0f2f5",$=J?"#1e293b":"white",G=J?"#2d3748":"#e5e7eb",pe=J?"#e2e8f0":"#1a2332",ne=J?"#94a3b8":"#6b7280",Se=J?"#374151":"white",E=J?"#2d3748":"#f9fafb",M={width:"100%",padding:"9px 12px",borderRadius:8,border:`1px solid ${G}`,fontSize:13,background:Se,color:pe,fontFamily:"inherit",outline:"none"},W={...M,background:E,color:ne},V={...M,cursor:"pointer"},X={fontSize:12,fontWeight:600,color:ne,marginBottom:5,display:"block"},ee={display:"grid",gridTemplateColumns:"1fr 1fr",gap:14},Ce={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:14},L=async()=>{if(r){j("saving");try{await bi("User",f.name,{first_name:c.first_name,middle_name:c.middle_name,last_name:c.last_name,mobile_no:c.mobile_no,custom_organization:c.custom_organization,custom_management:c.custom_management,custom_department:c.custom_department,custom_branch:c.custom_branch,custom_number:c.custom_number,custom_category:c.custom_category}),j("saved"),setTimeout(()=>j(""),2e3)}catch{j("error"),setTimeout(()=>j(""),3e3)}}},Z=async()=>{if(!y.new){v("Enter a new password");return}if(y.new!==y.confirm){v("Passwords do not match");return}v("saving");try{await Af(f.name,y.new),v("done"),x({new:"",confirm:""}),setTimeout(()=>{v(""),C(!1)},2e3)}catch{v("error")}},Je=({title:K,icon:A,children:R})=>n.jsxs("div",{style:{background:$,borderRadius:12,padding:22,border:`1px solid ${G}`,boxShadow:`0 1px 4px rgba(0,0,0,${J?.3:.06})`},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,paddingBottom:14,borderBottom:`1px solid ${G}`},children:[A,n.jsx("span",{style:{fontSize:14,fontWeight:700,color:pe},children:K})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:R})]});return n.jsxs("div",{style:{background:se,minHeight:"100%",padding:"0 0 32px"},children:[n.jsxs("div",{style:{background:$,borderBottom:`1px solid ${G}`,padding:"12px 28px",display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:24},children:[n.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",gap:7,background:"none",border:"none",cursor:"pointer",fontSize:15,fontWeight:700,color:pe,fontFamily:"inherit"},children:[n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:n.jsx("polyline",{points:"15,18 9,12 15,6"})}),"User Profile"]}),r&&n.jsxs("button",{onClick:L,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:w||z}),n.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.75)",textAlign:"center"},children:z})]}),n.jsx("div",{style:{background:$},children:[{icon:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:U,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:b},{icon:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:U,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:k||"—"},{icon:n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:I==="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:I,valueColor:I==="Active"?"#16a34a":"#dc2626"},{icon:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:U,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:z},{icon:n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:U,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:c.mobile_no||"—"}].map(({icon:K,label:A,value:R,valueColor:F})=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 16px",borderBottom:`1px solid ${G}`},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:ne,marginBottom:1},children:A}),n.jsx("div",{style:{fontSize:13,fontWeight:600,color:F||pe,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:R})]})]},A))})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:18},children:[n.jsxs(Je,{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:ee,children:[n.jsxs("div",{children:[n.jsxs("label",{style:X,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:{...W,paddingLeft:32},value:z,readOnly:!0})]})]}),n.jsxs("div",{children:[n.jsxs("label",{style:X,children:["Full Name ",n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Auto-generated)"})]}),n.jsx("input",{style:W,value:w,readOnly:!0})]})]}),n.jsxs("div",{style:Ce,children:[n.jsxs("div",{children:[n.jsxs("label",{style:X,children:["First Name ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{style:r?M:W,value:c.first_name,readOnly:!r,onChange:K=>o(A=>({...A,first_name:K.target.value})),placeholder:"First name"})]}),n.jsxs("div",{children:[n.jsx("label",{style:X,children:"Middle Name"}),n.jsx("input",{style:r?M:W,value:c.middle_name,readOnly:!r,onChange:K=>o(A=>({...A,middle_name:K.target.value})),placeholder:"Middle name"})]}),n.jsxs("div",{children:[n.jsx("label",{style:X,children:"Last Name"}),n.jsx("input",{style:r?M:W,value:c.last_name,readOnly:!r,onChange:K=>o(A=>({...A,last_name:K.target.value})),placeholder:"Last name"})]})]}),n.jsxs("div",{style:ee,children:[n.jsxs("div",{children:[n.jsx("label",{style:X,children:"Phone Number"}),n.jsx("input",{style:r?M:W,value:c.mobile_no,readOnly:!r,onChange:K=>o(A=>({...A,mobile_no:K.target.value})),placeholder:"Phone number"})]}),n.jsxs("div",{children:[n.jsx("label",{style:X,children:"User ID No"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx("input",{style:{...W,paddingRight:44},value:c.custom_number||f.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:X,children:["Category ",!g&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),g?n.jsxs("select",{style:V,value:c.custom_category,onChange:K=>o(A=>({...A,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:W,value:k||"—",readOnly:!0})]})]}),n.jsxs(Je,{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:ee,children:[n.jsxs("div",{children:[n.jsxs("label",{style:X,children:["Organization ",!g&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),g?n.jsxs("select",{style:V,value:c.custom_organization,onChange:K=>o(A=>({...A,custom_organization:K.target.value})),children:[n.jsx("option",{value:"",children:"Select organization"}),ue(i,c.custom_organization).map(K=>n.jsx("option",{value:K.name,children:K.organization_name||K.name},K.name))]}):n.jsx("input",{style:W,value:c.custom_organization||"—",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:X,children:["Management ",!g&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),g?n.jsxs("select",{style:V,value:c.custom_management,onChange:K=>o(A=>({...A,custom_management:K.target.value})),children:[n.jsx("option",{value:"",children:"Select management"}),ue(a,c.custom_management).map(K=>n.jsx("option",{value:K.name,children:K.name1||K.name},K.name))]}):n.jsx("input",{style:W,value:c.custom_management||"—",readOnly:!0})]})]}),n.jsxs("div",{style:ee,children:[n.jsxs("div",{children:[n.jsxs("label",{style:X,children:["Department ",!g&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),g?n.jsxs("select",{style:V,value:c.custom_department,onChange:K=>o(A=>({...A,custom_department:K.target.value})),children:[n.jsx("option",{value:"",children:"Select department"}),ue(u,c.custom_department).map(K=>n.jsx("option",{value:K.name,children:K.department_name||K.name},K.name))]}):n.jsx("input",{style:W,value:c.custom_department||"—",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:X,children:["Branch ",!g&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),g?n.jsxs("select",{style:V,value:c.custom_branch,onChange:K=>o(A=>({...A,custom_branch:K.target.value})),children:[n.jsx("option",{value:"",children:"Select branch"}),ue(p,c.custom_branch).map(K=>n.jsx("option",{value:K.name,children:K.branch||K.name},K.name))]}):n.jsx("input",{style:W,value:c.custom_branch||"—",readOnly:!0})]})]})]}),n.jsxs("div",{style:{background:$,borderRadius:12,padding:22,border:`1px solid ${G}`,boxShadow:`0 1px 4px rgba(0,0,0,${J?.3:.06})`},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"#f59e0b",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),n.jsx("span",{style:{fontSize:14,fontWeight:700,color:pe},children:"Change Password"})]}),r&&n.jsx("button",{onClick:()=>{C(K=>!K),v("")},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:Ce,children:[n.jsxs("div",{children:[n.jsxs("label",{style:X,children:["New Password ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{type:"password",style:M,value:y.new,onChange:K=>x(A=>({...A,new:K.target.value})),placeholder:"New password"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:X,children:["Confirm Password ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{type:"password",style:M,value:y.confirm,onChange:K=>x(A=>({...A,confirm:K.target.value})),placeholder:"Confirm password"})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:Z,style:{width:"100%",padding:"9px 0",borderRadius:8,border:"none",background:"#2563eb",color:"white",fontWeight:700,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:d==="saving"?"Saving…":"Update Password"})})]}),d&&d!=="saving"&&n.jsx("div",{style:{fontSize:13,color:d==="done"?"#16a34a":"#dc2626",fontWeight:500},children:d==="done"?"Password updated successfully":d==="error"?"Failed to update password":d})]})]})]})]})]})}function Te({label:e,val:t,color:l}){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 ${l}`,minWidth:0,display:"flex",alignItems:"baseline",gap:8},children:[n.jsx("div",{style:{fontSize:18,fontWeight:700,color:l},children:t}),n.jsx("div",{style:{fontSize:12,color:"#999"},children:e})]})}const Lf={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151",boxSizing:"border-box"},a0={...Lf,cursor:"pointer"};function st({filters:e,defaultOpen:t=!1}){const[l,r]=S.useState(t);return n.jsxs("div",{style:{background:"white",borderRadius:12,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:16},children:[n.jsxs("div",{onClick:()=>r(s=>!s),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:l?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"})]}),l&&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((s,i)=>n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:s.label}),s.type==="search"?n.jsx("input",{style:Lf,placeholder:s.placeholder,value:s.value,onChange:a=>s.onChange(a.target.value)}):n.jsx("select",{style:a0,value:s.value,onChange:a=>s.onChange(a.target.value),children:s.options.map(a=>n.jsx("option",{value:a.value,children:a.label},a.value))})]},i))})})]})}function o0(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 d0({organizations:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=q(),[a,u]=S.useState(""),[p,f]=S.useState("all"),[g,c]=S.useState("all"),o={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},m=S.useMemo(()=>e.filter(y=>{const x=[y.organization_name,y.city].filter(Boolean).join(" ").toLowerCase();return!(a&&!x.includes(a.toLowerCase())||p!=="all"&&y.type!==p||g!=="all"&&(y.is_active?"Active":"Inactive")!==g)}),[e,a,p,g]),[j,h]=S.useState(1);S.useEffect(()=>{h(1)},[a,p,g]);const C=m.slice((j-1)*te,j*te);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(Te,{label:"Total",val:m.length,color:"#1a2332"}),n.jsx(Te,{label:"Active",val:m.filter(y=>y.is_active).length,color:N.green}),n.jsx(Te,{label:"Government",val:m.filter(y=>y.type==="Government").length,color:N.blue}),n.jsx(Te,{label:"Private",val:m.filter(y=>y.type==="Private").length,color:N.orange})]}),n.jsx(st,{filters:[{type:"search",label:"Search",value:a,onChange:u,placeholder:"Name or city…"},{type:"select",label:i.col.type,value:p,onChange:f,options:[{value:"all",label:"All"},{value:"Government",label:"Government"},{value:"Private",label:"Private"}]},{type:"select",label:"Status",value:g,onChange:c,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:o,children:i.col.name}),n.jsx("th",{style:o,children:i.col.type}),n.jsx("th",{style:o,children:i.col.city}),n.jsx("th",{style:o,children:i.field.creationDate}),n.jsx("th",{style:o,children:i.col.status}),n.jsx("th",{style:o,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})}):C.map((y,x)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(y),style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:y.organization_name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:y.type||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:y.city||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:o0(y.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:En(y.is_active?i.field.statusActive:i.field.statusInactive,y.is_active?N.green:N.gray)}),n.jsx("td",{style:{padding:"8px 14px"},onClick:d=>d.stopPropagation(),children:n.jsx(Ke,{onView:()=>l==null?void 0:l(y),onEdit:t&&r?()=>r(y):void 0,onDelete:t&&s?()=>s(y.name):void 0})})]},y.name))})]})}),n.jsx(Ne,{page:j,total:m.length,onPageChange:h})]})}const Gt=e=>({background:e?"#f9f9f9":void 0});function c0({orgForm:e,setOrgForm:t,formStatus:l,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,user:f}){const g=q(),c=e.name?r&&e.organization_name||g.formTitle.editOrg:g.formTitle.newOrg;return n.jsxs(We,{title:c,activePage:"organizations",user:f,formStatus:l,buttonText:g.saveOrg,buttonColor:N.accent,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.orgName}),n.jsx("input",{type:"text",style:{...P,...Gt(r)},value:e.organization_name,disabled:r,onChange:o=>t({...e,organization_name:o.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.orgAcronym}),n.jsx("input",{type:"text",style:{...P,...Gt(r)},value:e.acronym||"",disabled:r,onChange:o=>t({...e,acronym:o.target.value})})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.organizationType}),n.jsxs("select",{style:{...P,...Gt(r)},value:e.type,disabled:r,onChange:o=>t({...e,type:o.target.value}),children:[n.jsx("option",{children:"Government"}),n.jsx("option",{children:"Private"}),n.jsx("option",{children:"Non-Profit"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.orgCity}),n.jsx("input",{type:"text",style:{...P,...Gt(r)},value:e.city,disabled:r,onChange:o=>t({...e,city:o.target.value})})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.contactEmail}),n.jsx("input",{type:"email",style:{...P,...Gt(r)},value:e.contact_email,disabled:r,onChange:o=>t({...e,contact_email:o.target.value})})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(he,{value:e.creation_date||"",onChange:o=>t({...e,creation_date:o}),disabled:r,style:{...P,...Gt(r)}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...P,...Gt(r)},value:e.is_active?"Active":"Inactive",disabled:r,onChange:o=>t({...e,is_active:o.target.value==="Active"?1:0}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.incidentTriageWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...P,...Gt(r)},value:e.incident_triage_window_days??3,disabled:r,onChange:o=>t({...e,incident_triage_window_days:parseInt(o.target.value)||3})}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:"Days after creation before an untriaged Incident is flagged overdue"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.incidentResolutionWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...P,...Gt(r)},value:e.incident_resolution_window_days??5,disabled:r,onChange:o=>t({...e,incident_resolution_window_days:parseInt(o.target.value)||5})}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:"Days without an update before an in-progress Incident is flagged overdue"})]})]})]})}function u0(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 p0({managements:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=q(),[a,u]=S.useState(""),[p,f]=S.useState("all"),g={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},c=S.useMemo(()=>e.filter(h=>{const C=(h.name1||h.name||"").toLowerCase();return!(a&&!C.includes(a.toLowerCase())||p!=="all"&&(h.status||"Active")!==p)}),[e,a,p]),[o,m]=S.useState(1);S.useEffect(()=>{m(1)},[a,p]);const j=c.slice((o-1)*te,o*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Te,{label:"Total",val:c.length,color:N.blue})}),n.jsx(st,{filters:[{type:"search",label:"Search",value:a,onChange:u,placeholder:"Search by name…"},{type:"select",label:"Status",value:p,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:g,children:i.col.name}),n.jsx("th",{style:g,children:i.field.creationDate}),n.jsx("th",{style:g,children:i.field.status}),n.jsx("th",{style:g,children:i.col.actions})]})}),n.jsx("tbody",{children:c.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,C)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:C%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:u0(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:y=>y.stopPropagation(),children:n.jsx(Ke,{onView:()=>l==null?void 0:l(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&s?()=>s(h.name):void 0})})]},h.name))})]})}),n.jsx(Ne,{page:o,total:c.length,onPageChange:m})]})}function f0({form:e,setForm:t,organizations:l,formStatus:r,viewMode:s,onEdit:i,onSubmit:a,onBack:u,onNavigate:p,onLogout:f,user:g}){const c=q(),o=h=>t(C=>({...C,...h})),m=s?{background:"#f9f9f9"}:{},j=e.name?s?`${c.formTitle.editMgmt}: ${e.name1||e.name}`:c.formTitle.editMgmt:c.formTitle.newMgmt;return n.jsxs(We,{title:j,activePage:"managements",user:g,formStatus:r,buttonText:c.saveMgmt,buttonColor:N.blue,viewMode:s,onEdit:i,onSubmit:a,onBack:u,onNavigate:p,onLogout:f,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.organization}),n.jsx(_t,{value:e.organization,onChange:h=>o({organization:h}),organizations:l,disabled:s})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[c.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...m},value:e.name1,disabled:s,onChange:h=>o({name1:h.target.value}),placeholder:"Management name",required:!0})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.creationDate}),n.jsx(he,{value:e.creation_date||"",onChange:h=>o({creation_date:h}),disabled:s,style:{...P,...m}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.status}),n.jsxs("select",{style:{...P,...m},value:e.status||"Active",disabled:s,onChange:h=>o({status:h.target.value}),children:[n.jsx("option",{value:"Active",children:c.field.statusActive}),n.jsx("option",{value:"Inactive",children:c.field.statusInactive})]})]})]})]})}function h0(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 g0({departments:e,managements:t,canModify:l,onView:r,onEdit:s,onDelete:i}){const a=q(),[u,p]=S.useState(""),[f,g]=S.useState(""),[c,o]=S.useState("all"),m=d=>{var v;return((v=t.find(z=>z.name===d))==null?void 0:v.name1)||d||"—"},j={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},h=S.useMemo(()=>e.filter(d=>{const v=(d.department_name||d.name||"").toLowerCase();return!(u&&!v.includes(u.toLowerCase())||f&&d.custom_management!==f||c!=="all"&&(d.custom_status||"Active")!==c)}),[e,u,f,c]),[C,y]=S.useState(1);S.useEffect(()=>{y(1)},[u,f,c]);const x=h.slice((C-1)*te,C*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Te,{label:"Total",val:h.length,color:N.teal})}),n.jsx(st,{filters:[{type:"search",label:"Search",value:u,onChange:p,placeholder:"Search by name…"},{type:"select",label:a.col.management,value:f,onChange:g,options:[{value:"",label:"All Managements"},...t.map(d=>({value:d.name,label:d.name1||d.name}))]},{type:"select",label:"Status",value:c,onChange:o,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((d,v)=>n.jsxs("tr",{onClick:()=>r==null?void 0:r(d),style:{borderTop:"1px solid #f0f0f0",background:v%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:d.department_name||d.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:m(d.custom_management)}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:h0(d.custom_creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:d.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:d.custom_status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:z=>z.stopPropagation(),children:n.jsx(Ke,{onView:()=>r==null?void 0:r(d),onEdit:l&&s?()=>s(d):void 0,onDelete:l&&i?()=>i(d.name):void 0})})]},d.name))})]})}),n.jsx(Ne,{page:C,total:h.length,onPageChange:y})]})}const x0={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20};function m0({form:e,setForm:t,organizations:l,managements:r,formStatus:s,viewMode:i,onEdit:a,onSubmit:u,onBack:p,onNavigate:f,onLogout:g,user:c}){const o=q(),m=y=>t(x=>({...x,...y})),j=i?{background:"#f9f9f9"}:{},h=e.name?i?`${o.formTitle.editDept}: ${e.department_name||e.name}`:o.formTitle.editDept:o.formTitle.newDept,C=ue(r,e.custom_management).map(y=>({name:y.name,label:y.name1||y.name}));return n.jsxs(We,{title:h,activePage:"departments",user:c,formStatus:s,buttonText:o.saveDept,buttonColor:N.teal,viewMode:i,onEdit:a,onSubmit:u,onBack:p,onNavigate:f,onLogout:g,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:o.field.organization}),n.jsx(_t,{value:e.custom_organization,onChange:y=>m({custom_organization:y}),organizations:l,disabled:i})]}),n.jsxs("div",{style:x0,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[o.field.department," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...j},value:e.department_name,disabled:i,onChange:y=>m({department_name:y.target.value}),placeholder:"Department name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:o.field.management}),n.jsx(de,{value:e.custom_management,onChange:y=>m({custom_management:y}),items:C,placeholder:o.field.select,disabled:i})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:o.field.creationDate}),n.jsx(he,{value:e.custom_creation_date||"",onChange:y=>m({custom_creation_date:y}),disabled:i,style:{...P,...j}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:o.field.status}),n.jsxs("select",{style:{...P,...j},value:e.custom_status||"Active",disabled:i,onChange:y=>m({custom_status:y.target.value}),children:[n.jsx("option",{value:"Active",children:o.field.statusActive}),n.jsx("option",{value:"Inactive",children:o.field.statusInactive})]})]})]})]})}function y0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function v0({branches:e,managements:t,departments:l,canModify:r,onView:s,onEdit:i,onDelete:a}){const u=q(),[p,f]=S.useState(""),[g,c]=S.useState(""),[o,m]=S.useState(""),[j,h]=S.useState("all"),C=b=>{var k;return((k=t.find(I=>I.name===b))==null?void 0:k.name1)||b||"—"},y=b=>{var k;return((k=l.find(I=>I.name===b))==null?void 0:k.department_name)||b||"—"},x={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},d=S.useMemo(()=>e.filter(b=>{const k=(b.branch||b.name||"").toLowerCase();return!(p&&!k.includes(p.toLowerCase())||g&&b.management!==g||o&&b.department!==o||j!=="all"&&(b.custom_status||"Active")!==j)}),[e,p,g,o,j]),[v,z]=S.useState(1);S.useEffect(()=>{z(1)},[p,g,o,j]);const w=d.slice((v-1)*te,v*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Te,{label:"Total",val:d.length,color:N.purple})}),n.jsx(st,{filters:[{type:"search",label:"Search",value:p,onChange:f,placeholder:"Search by name…"},{type:"select",label:u.col.management,value:g,onChange:c,options:[{value:"",label:"All Managements"},...t.map(b=>({value:b.name,label:b.name1||b.name}))]},{type:"select",label:u.col.department,value:o,onChange:m,options:[{value:"",label:"All Departments"},...l.map(b=>({value:b.name,label:b.department_name||b.name}))]},{type:"select",label:"Status",value:j,onChange:h,options:[{value:"all",label:"All"},{value:"Active",label:u.field.statusActive},{value:"Inactive",label:u.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:u.col.branch}),n.jsx("th",{style:x,children:u.col.management}),n.jsx("th",{style:x,children:u.col.department}),n.jsx("th",{style:x,children:u.field.creationDate}),n.jsx("th",{style:x,children:u.field.status}),n.jsx("th",{style:x,children:u.col.actions})]})}),n.jsx("tbody",{children:d.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:u.noData})}):w.map((b,k)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(b),style:{borderTop:"1px solid #f0f0f0",background:k%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:b.branch||b.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:C(b.management)}),n.jsx("td",{style:{padding:"10px 14px"},children:y(b.department)}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:y0(b.custom_creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:b.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:b.custom_status==="Inactive"?u.field.statusInactive:u.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:I=>I.stopPropagation(),children:n.jsx(Ke,{onView:()=>s==null?void 0:s(b),onEdit:r&&i?()=>i(b):void 0,onDelete:r&&a?()=>a(b.name):void 0})})]},b.name))})]})}),n.jsx(Ne,{page:v,total:d.length,onPageChange:z})]})}const j0={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20};function b0({form:e,setForm:t,organizations:l,managements:r,departments:s,formStatus:i,viewMode:a,onEdit:u,onSubmit:p,onBack:f,onNavigate:g,onLogout:c,user:o}){const m=q(),j=d=>t(v=>({...v,...d})),h=a?{background:"#f9f9f9"}:{},C=e.name?a?`${m.formTitle.editBranch}: ${e.branch||e.name}`:m.formTitle.editBranch:m.formTitle.newBranch,y=ue(r,e.management).map(d=>({name:d.name,label:d.name1||d.name})),x=ue(s,e.department).map(d=>({name:d.name,label:d.department_name||d.name}));return n.jsxs(We,{title:C,activePage:"branches",user:o,formStatus:i,buttonText:m.saveBranch,buttonColor:N.purple,viewMode:a,onEdit:u,onSubmit:p,onBack:f,onNavigate:g,onLogout:c,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:m.field.organization}),n.jsx(_t,{value:e.organization,onChange:d=>j({organization:d}),organizations:l,disabled:a})]}),n.jsxs("div",{style:j0,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[m.field.branch," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...h},value:e.branch,disabled:a||!!e.name,onChange:d=>j({branch:d.target.value}),placeholder:"Branch name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:m.field.management}),n.jsx(de,{value:e.management,onChange:d=>j({management:d}),items:y,placeholder:m.field.select,disabled:a})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:m.field.department}),n.jsx(de,{value:e.department,onChange:d=>j({department:d}),items:x,placeholder:m.field.select,disabled:a})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:m.field.creationDate}),n.jsx(he,{value:e.custom_creation_date||"",onChange:d=>j({custom_creation_date:d}),disabled:a,style:{...P,...h}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:m.field.status}),n.jsxs("select",{style:{...P,...h},value:e.custom_status||"Active",disabled:a,onChange:d=>j({custom_status:d.target.value}),children:[n.jsx("option",{value:"Active",children:m.field.statusActive}),n.jsx("option",{value:"Inactive",children:m.field.statusInactive})]})]})]})]})}function S0(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 w0({incidentTypes:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=q(),[a,u]=S.useState(""),[p,f]=S.useState("all"),g={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},c=S.useMemo(()=>e.filter(h=>{const C=(h.name1||h.name||"").toLowerCase();return!(a&&!C.includes(a.toLowerCase())||p!=="all"&&(h.status||"Active")!==p)}),[e,a,p]),[o,m]=S.useState(1);S.useEffect(()=>{m(1)},[a,p]);const j=c.slice((o-1)*te,o*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Te,{label:"Total",val:c.length,color:N.red})}),n.jsx(st,{filters:[{type:"search",label:"Search",value:a,onChange:u,placeholder:"Search by name…"},{type:"select",label:"Status",value:p,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:g,children:i.col.name}),n.jsx("th",{style:g,children:i.field.creationDate}),n.jsx("th",{style:g,children:i.field.status}),n.jsx("th",{style:g,children:i.col.actions})]})}),n.jsx("tbody",{children:c.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,C)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:C%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:S0(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:y=>y.stopPropagation(),children:n.jsx(Ke,{onView:()=>l==null?void 0:l(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&s?()=>s(h.name):void 0})})]},h.name))})]})}),n.jsx(Ne,{page:o,total:c.length,onPageChange:m})]})}function k0({form:e,setForm:t,formStatus:l,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,user:f}){const g=q(),c=j=>t(h=>({...h,...j})),o=r?{background:"#f9f9f9"}:{},m=e.name?r?`Incident Type: ${e.name1||e.name}`:"Edit Incident Type":"New Incident Type";return n.jsxs(We,{title:m,activePage:"incident-types",user:f,formStatus:l,buttonText:g.saveName,buttonColor:N.red,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...o},value:e.name1,disabled:r,onChange:j=>c({name1:j.target.value}),placeholder:"Incident type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(he,{value:e.creation_date||"",onChange:j=>c({creation_date:j}),disabled:r,style:{...P,...o}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...P,...o},value:e.status||"Active",disabled:r,onChange:j=>c({status:j.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}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 C0({ideaTypes:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=q(),[a,u]=S.useState(""),[p,f]=S.useState("all"),g={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},c=S.useMemo(()=>e.filter(h=>{const C=(h.name1||h.name||"").toLowerCase();return!(a&&!C.includes(a.toLowerCase())||p!=="all"&&(h.status||"Active")!==p)}),[e,a,p]),[o,m]=S.useState(1);S.useEffect(()=>{m(1)},[a,p]);const j=c.slice((o-1)*te,o*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Te,{label:"Total",val:c.length,color:N.teal})}),n.jsx(st,{filters:[{type:"search",label:"Search",value:a,onChange:u,placeholder:"Search by name…"},{type:"select",label:"Status",value:p,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:g,children:i.col.name}),n.jsx("th",{style:g,children:i.field.creationDate}),n.jsx("th",{style:g,children:i.field.status}),n.jsx("th",{style:g,children:i.col.actions})]})}),n.jsx("tbody",{children:c.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,C)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:C%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:y=>y.stopPropagation(),children:n.jsx(Ke,{onView:()=>l==null?void 0:l(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&s?()=>s(h.name):void 0})})]},h.name))})]})}),n.jsx(Ne,{page:o,total:c.length,onPageChange:m})]})}function z0({form:e,setForm:t,formStatus:l,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,user:f}){const g=q(),c=j=>t(h=>({...h,...j})),o=r?{background:"#f9f9f9"}:{},m=e.name?r?`Idea Type: ${e.name1||e.name}`:"Edit Idea Type":"New Idea Type";return n.jsxs(We,{title:m,activePage:"idea-types",user:f,formStatus:l,buttonText:g.saveName,buttonColor:N.teal,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...o},value:e.name1,disabled:r,onChange:j=>c({name1:j.target.value}),placeholder:"Idea type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(he,{value:e.creation_date||"",onChange:j=>c({creation_date:j}),disabled:r,style:{...P,...o}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...P,...o},value:e.status||"Active",disabled:r,onChange:j=>c({status:j.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}function T0(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 I0({orderTypes:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=q(),[a,u]=S.useState(""),[p,f]=S.useState("all"),g={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},c=S.useMemo(()=>e.filter(h=>{const C=(h.name1||h.name||"").toLowerCase();return!(a&&!C.includes(a.toLowerCase())||p!=="all"&&(h.status||"Active")!==p)}),[e,a,p]),[o,m]=S.useState(1);S.useEffect(()=>{m(1)},[a,p]);const j=c.slice((o-1)*te,o*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Te,{label:"Total",val:c.length,color:N.purple})}),n.jsx(st,{filters:[{type:"search",label:"Search",value:a,onChange:u,placeholder:"Search by name…"},{type:"select",label:"Status",value:p,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:g,children:i.col.name}),n.jsx("th",{style:g,children:i.field.creationDate}),n.jsx("th",{style:g,children:i.field.status}),n.jsx("th",{style:g,children:i.col.actions})]})}),n.jsx("tbody",{children:c.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,C)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:C%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:T0(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:y=>y.stopPropagation(),children:n.jsx(Ke,{onView:()=>l==null?void 0:l(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&s?()=>s(h.name):void 0})})]},h.name))})]})}),n.jsx(Ne,{page:o,total:c.length,onPageChange:m})]})}function E0({form:e,setForm:t,formStatus:l,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,user:f}){const g=q(),c=j=>t(h=>({...h,...j})),o=r?{background:"#f9f9f9"}:{},m=e.name?r?`Order Type: ${e.name1||e.name}`:"Edit Order Type":"New Order Type";return n.jsxs(We,{title:m,activePage:"order-types",user:f,formStatus:l,buttonText:g.saveName,buttonColor:N.purple,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...o},value:e.name1,disabled:r,onChange:j=>c({name1:j.target.value}),placeholder:"Order type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(he,{value:e.creation_date||"",onChange:j=>c({creation_date:j}),disabled:r,style:{...P,...o}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...P,...o},value:e.status||"Active",disabled:r,onChange:j=>c({status:j.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}function P0(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 A0({processTypes:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=q(),[a,u]=S.useState(""),[p,f]=S.useState("all"),g={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},c=S.useMemo(()=>e.filter(h=>{const C=(h.name1||h.name||"").toLowerCase();return!(a&&!C.includes(a.toLowerCase())||p!=="all"&&(h.status||"Active")!==p)}),[e,a,p]),[o,m]=S.useState(1);S.useEffect(()=>{m(1)},[a,p]);const j=c.slice((o-1)*te,o*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Te,{label:"Total",val:c.length,color:N.blue})}),n.jsx(st,{filters:[{type:"search",label:"Search",value:a,onChange:u,placeholder:"Search by name…"},{type:"select",label:"Status",value:p,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:g,children:i.col.name}),n.jsx("th",{style:g,children:i.field.creationDate}),n.jsx("th",{style:g,children:i.field.status}),n.jsx("th",{style:g,children:i.col.actions})]})}),n.jsx("tbody",{children:c.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,C)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:C%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:P0(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:y=>y.stopPropagation(),children:n.jsx(Ke,{onView:()=>l==null?void 0:l(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&s?()=>s(h.name):void 0})})]},h.name))})]})}),n.jsx(Ne,{page:o,total:c.length,onPageChange:m})]})}function R0({form:e,setForm:t,formStatus:l,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,user:f}){const g=q(),c=j=>t(h=>({...h,...j})),o=r?{background:"#f9f9f9"}:{},m=e.name?r?`Process Type: ${e.name1||e.name}`:"Edit Process Type":"New Process Type";return n.jsxs(We,{title:m,activePage:"process-types",user:f,formStatus:l,buttonText:g.saveName,buttonColor:N.blue,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...o},value:e.name1,disabled:r,onChange:j=>c({name1:j.target.value}),placeholder:"Process type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(he,{value:e.creation_date||"",onChange:j=>c({creation_date:j}),disabled:r,style:{...P,...o}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...P,...o},value:e.status||"Active",disabled:r,onChange:j=>c({status:j.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}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({incidentStatuses:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=q(),[a,u]=S.useState(""),[p,f]=S.useState("all"),g={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},c=S.useMemo(()=>e.filter(h=>{const C=(h.name1||h.name||"").toLowerCase();return!(a&&!C.includes(a.toLowerCase())||p!=="all"&&(h.status||"Active")!==p)}),[e,a,p]),[o,m]=S.useState(1);S.useEffect(()=>{m(1)},[a,p]);const j=c.slice((o-1)*te,o*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Te,{label:"Total",val:c.length,color:N.red})}),n.jsx(st,{filters:[{type:"search",label:"Search",value:a,onChange:u,placeholder:"Search by name…"},{type:"select",label:"Status",value:p,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:g,children:i.col.name}),n.jsx("th",{style:g,children:i.field.notifyManager}),n.jsx("th",{style:g,children:i.field.creationDate}),n.jsx("th",{style:g,children:i.field.status}),n.jsx("th",{style:g,children:i.col.actions})]})}),n.jsx("tbody",{children:c.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,C)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:C%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:L0(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:y=>y.stopPropagation(),children:n.jsx(Ke,{onView:()=>l==null?void 0:l(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&s?()=>s(h.name):void 0})})]},h.name))})]})}),n.jsx(Ne,{page:o,total:c.length,onPageChange:m})]})}function D0({form:e,setForm:t,formStatus:l,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,user:f}){const g=q(),c=j=>t(h=>({...h,...j})),o=r?{background:"#f9f9f9"}:{},m=e.name?r?`Incident Status: ${e.name1||e.name}`:"Edit Incident Status":"New Incident Status";return n.jsxs(We,{title:m,activePage:"incident-statuses",user:f,formStatus:l,buttonText:g.saveName,buttonColor:N.red,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...o},value:e.name1,disabled:r,onChange:j=>c({name1:j.target.value}),placeholder:"Incident status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:r,onChange:j=>c({notify_manager:j.target.checked?1:0}),style:Fl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:r?"default":"pointer"},children:g.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(he,{value:e.creation_date||"",onChange:j=>c({creation_date:j}),disabled:r,style:{...P,...o}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...P,...o},value:e.status||"Active",disabled:r,onChange:j=>c({status:j.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}function N0(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 W0({ideaStatuses:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=q(),[a,u]=S.useState(""),[p,f]=S.useState("all"),g={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},c=S.useMemo(()=>e.filter(h=>{const C=(h.name1||h.name||"").toLowerCase();return!(a&&!C.includes(a.toLowerCase())||p!=="all"&&(h.status||"Active")!==p)}),[e,a,p]),[o,m]=S.useState(1);S.useEffect(()=>{m(1)},[a,p]);const j=c.slice((o-1)*te,o*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Te,{label:"Total",val:c.length,color:N.teal})}),n.jsx(st,{filters:[{type:"search",label:"Search",value:a,onChange:u,placeholder:"Search by name…"},{type:"select",label:"Status",value:p,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:g,children:i.col.name}),n.jsx("th",{style:g,children:i.field.notifyManager}),n.jsx("th",{style:g,children:i.field.creationDate}),n.jsx("th",{style:g,children:i.field.status}),n.jsx("th",{style:g,children:i.col.actions})]})}),n.jsx("tbody",{children:c.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,C)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:C%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:N0(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:y=>y.stopPropagation(),children:n.jsx(Ke,{onView:()=>l==null?void 0:l(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&s?()=>s(h.name):void 0})})]},h.name))})]})}),n.jsx(Ne,{page:o,total:c.length,onPageChange:m})]})}function B0({form:e,setForm:t,formStatus:l,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,user:f}){const g=q(),c=j=>t(h=>({...h,...j})),o=r?{background:"#f9f9f9"}:{},m=e.name?r?`Idea Status: ${e.name1||e.name}`:"Edit Idea Status":"New Idea Status";return n.jsxs(We,{title:m,activePage:"idea-statuses",user:f,formStatus:l,buttonText:g.saveName,buttonColor:N.teal,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...o},value:e.name1,disabled:r,onChange:j=>c({name1:j.target.value}),placeholder:"Idea status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:r,onChange:j=>c({notify_manager:j.target.checked?1:0}),style:Fl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:r?"default":"pointer"},children:g.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(he,{value:e.creation_date||"",onChange:j=>c({creation_date:j}),disabled:r,style:{...P,...o}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...P,...o},value:e.status||"Active",disabled:r,onChange:j=>c({status:j.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}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({orderStatuses:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=q(),[a,u]=S.useState(""),[p,f]=S.useState("all"),g={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},c=S.useMemo(()=>e.filter(h=>{const C=(h.name1||h.name||"").toLowerCase();return!(a&&!C.includes(a.toLowerCase())||p!=="all"&&(h.status||"Active")!==p)}),[e,a,p]),[o,m]=S.useState(1);S.useEffect(()=>{m(1)},[a,p]);const j=c.slice((o-1)*te,o*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Te,{label:"Total",val:c.length,color:N.purple})}),n.jsx(st,{filters:[{type:"search",label:"Search",value:a,onChange:u,placeholder:"Search by name…"},{type:"select",label:"Status",value:p,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:g,children:i.col.name}),n.jsx("th",{style:g,children:i.field.notifyManager}),n.jsx("th",{style:g,children:i.field.creationDate}),n.jsx("th",{style:g,children:i.field.status}),n.jsx("th",{style:g,children:i.col.actions})]})}),n.jsx("tbody",{children:c.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,C)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:C%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:$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:y=>y.stopPropagation(),children:n.jsx(Ke,{onView:()=>l==null?void 0:l(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&s?()=>s(h.name):void 0})})]},h.name))})]})}),n.jsx(Ne,{page:o,total:c.length,onPageChange:m})]})}function F0({form:e,setForm:t,formStatus:l,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,user:f}){const g=q(),c=j=>t(h=>({...h,...j})),o=r?{background:"#f9f9f9"}:{},m=e.name?r?`Order Status: ${e.name1||e.name}`:"Edit Order Status":"New Order Status";return n.jsxs(We,{title:m,activePage:"order-statuses",user:f,formStatus:l,buttonText:g.saveName,buttonColor:N.purple,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...o},value:e.name1,disabled:r,onChange:j=>c({name1:j.target.value}),placeholder:"Order status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:r,onChange:j=>c({notify_manager:j.target.checked?1:0}),style:Fl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:r?"default":"pointer"},children:g.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(he,{value:e.creation_date||"",onChange:j=>c({creation_date:j}),disabled:r,style:{...P,...o}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...P,...o},value:e.status||"Active",disabled:r,onChange:j=>c({status:j.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.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({processStatuses:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=q(),[a,u]=S.useState(""),[p,f]=S.useState("all"),g={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},c=S.useMemo(()=>e.filter(h=>{const C=(h.name1||h.name||"").toLowerCase();return!(a&&!C.includes(a.toLowerCase())||p!=="all"&&(h.status||"Active")!==p)}),[e,a,p]),[o,m]=S.useState(1);S.useEffect(()=>{m(1)},[a,p]);const j=c.slice((o-1)*te,o*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Te,{label:"Total",val:c.length,color:N.blue})}),n.jsx(st,{filters:[{type:"search",label:"Search",value:a,onChange:u,placeholder:"Search by name…"},{type:"select",label:"Status",value:p,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:g,children:i.col.name}),n.jsx("th",{style:g,children:i.field.notifyManager}),n.jsx("th",{style:g,children:i.field.creationDate}),n.jsx("th",{style:g,children:i.field.status}),n.jsx("th",{style:g,children:i.col.actions})]})}),n.jsx("tbody",{children:c.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,C)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:C%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:M0(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:y=>y.stopPropagation(),children:n.jsx(Ke,{onView:()=>l==null?void 0:l(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&s?()=>s(h.name):void 0})})]},h.name))})]})}),n.jsx(Ne,{page:o,total:c.length,onPageChange:m})]})}function K0({form:e,setForm:t,formStatus:l,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,user:f}){const g=q(),c=j=>t(h=>({...h,...j})),o=r?{background:"#f9f9f9"}:{},m=e.name?r?`Process Status: ${e.name1||e.name}`:"Edit Process Status":"New Process Status";return n.jsxs(We,{title:m,activePage:"process-statuses",user:f,formStatus:l,buttonText:g.saveName,buttonColor:N.blue,viewMode:r,onEdit:s,onSubmit:i,onBack:a,onNavigate:u,onLogout:p,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...o},value:e.name1,disabled:r,onChange:j=>c({name1:j.target.value}),placeholder:"Process status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:r,onChange:j=>c({notify_manager:j.target.checked?1:0}),style:Fl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:r?"default":"pointer"},children:g.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(he,{value:e.creation_date||"",onChange:j=>c({creation_date:j}),disabled:r,style:{...P,...o}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...P,...o},value:e.status||"Active",disabled:r,onChange:j=>c({status:j.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}const Q0={Admin:"#7c3aed",Chairman:"#0f766e",Auditor:"#d97706","X-Auditor":"#8b5cf6",Manager:"#2563eb",Employee:"#6b7280"};function G0(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 Y0({users:e,canModify:t,onView:l,onEdit:r,onDisable:s}){const i=q(),[a,u]=S.useState(!1),[p,f]=S.useState(""),[g,c]=S.useState(""),[o,m]=S.useState(""),[j,h]=S.useState("active"),[C,y]=S.useState(1),[x,d]=S.useState(null),[v,z]=S.useState(""),[w,b]=S.useState("idle"),[k,I]=S.useState(null),U=async()=>{if(!(!x||!v.trim())){b("loading");try{await Af(x.name,v.trim()),b("success"),setTimeout(()=>{d(null),z(""),b("idle")},1200)}catch{b("error")}}},J=async E=>{if(window.confirm(i.users.disableConfirm)){I(E);try{await(s==null?void 0:s(E))}finally{I(null)}}},se=e.filter(E=>{if(j==="active"&&(E.enabled===0||E.enabled==="0")||j==="inactive"&&E.enabled!==0&&E.enabled!=="0")return!1;const M=E.custom_category||"";if(o&&M!==o)return!1;const W=E.custom_organization||"";if(g&&!W.toLowerCase().includes(g.toLowerCase()))return!1;if(p){const V=p.toLowerCase();if(![E.full_name,E.email,E.name,E.username,E.mobile_no].join(" ").toLowerCase().includes(V))return!1}return!0}),$=[...new Set(e.map(E=>E.custom_organization).filter(Boolean))],G=["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"];S.useEffect(()=>{y(1)},[p,g,o,j]);const pe=se.slice((C-1)*te,C*te),ne={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151"},Se={...ne,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: ",se.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:()=>u(E=>!E),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:ne,placeholder:"Name, email, username…",value:p,onChange:E=>f(E.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:Se,value:g,onChange:E=>c(E.target.value),children:[n.jsx("option",{value:"",children:"All Organizations"}),$.map(E=>n.jsx("option",{value:E,children:E},E))]})]}),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:Se,value:o,onChange:E=>m(E.target.value),children:[n.jsx("option",{value:"",children:"All Categories"}),G.map(E=>n.jsx("option",{value:E,children:E},E))]})]}),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:Se,value:j,onChange:E=>h(E.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:E,w:M})=>n.jsx("th",{style:{padding:"11px 14px",textAlign:"left",color:"#6b7280",fontSize:11,fontWeight:700,whiteSpace:"nowrap",minWidth:M,letterSpacing:.3,textTransform:"uppercase"},children:E},E))})}),n.jsx("tbody",{children:se.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"})}):pe.map((E,M)=>{const W=E.custom_category||"",V=Q0[W]||"#6b7280";return n.jsxs("tr",{onClick:()=>l==null?void 0:l(E),style:{borderBottom:"1px solid #f3f4f6",background:M%2===0?"white":"#fafafa",transition:"background 0.1s",cursor:"pointer"},onMouseEnter:X=>X.currentTarget.style.background="#f0f7ff",onMouseLeave:X=>X.currentTarget.style.background=M%2===0?"white":"#fafafa",children:[n.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:W?n.jsx("span",{style:{background:V+"18",color:V,border:`1px solid ${V}44`,padding:"3px 10px",borderRadius:20,fontSize:11,fontWeight:700},children:W}):n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:E.custom_number||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",fontWeight:600,color:"#1a2332",whiteSpace:"nowrap"},children:E.full_name||E.first_name||"—"}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:E.username||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:E.email||E.name}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:E.mobile_no||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:E.custom_organization||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:E.custom_management||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:E.custom_department||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:E.custom_branch||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:G0(E.creation)}),n.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:n.jsx("span",{style:{color:E.enabled?"#16a34a":"#dc2626",fontWeight:600},children:E.enabled?i.users.active:i.users.inactive})}),n.jsx("td",{style:{padding:"10px 14px",whiteSpace:"nowrap"},onClick:X=>X.stopPropagation(),children:n.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[n.jsx("button",{onClick:X=>{X.stopPropagation(),l==null||l(E)},title:"View",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#e0f7fa",color:"#0891b2"},children:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),t&&r&&n.jsx("button",{onClick:X=>{X.stopPropagation(),r(E)},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:X=>{X.stopPropagation(),d({name:E.name,email:E.email||E.name}),z(""),b("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:X=>{X.stopPropagation(),J(E.name)},disabled:k===E.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:k===E.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"})]})})]})})]},E.name)})})]})}),n.jsx(Ne,{page:C,total:se.length,onPageChange:y}),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:v,onChange:E=>z(E.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:E=>E.key==="Enter"&&U(),autoFocus:!0}),w==="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"}),w==="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:U,disabled:w==="loading"||!v.trim(),style:{flex:1,padding:10,background:"#2563eb",color:"white",border:"none",borderRadius:8,cursor:"pointer",fontSize:13,fontWeight:700,fontFamily:"inherit",opacity:v.trim()?1:.5},children:w==="loading"?"Saving…":i.users.setPassword}),n.jsx("button",{onClick:()=>{d(null),z(""),b("idle")},style:{flex:1,padding:10,background:"#f5f5f5",color:"#374151",border:"1px solid #e5e7eb",borderRadius:8,cursor:"pointer",fontSize:13,fontFamily:"inherit"},children:i.cancel})]})]})})]})}const pr={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20};function X0({form:e,setForm:t,organizations:l,managements:r,departments:s,branches:i,formStatus:a,viewMode:u,onEdit:p,isSelfProfile:f,onSubmit:g,onBack:c,onNavigate:o,onLogout:m,user:j}){const h=q(),C=b=>t(k=>({...k,...b})),y=u?{background:"#f9f9f9"}:{},x=!e.name,d=f?"My Profile":x?"New User":u?`User: ${e.full_name||e.email}`:`Edit User: ${e.full_name||e.email}`,v=ue(r,e.custom_management).map(b=>({name:b.name,label:b.name1||b.name})),z=ue(s,e.custom_department).map(b=>({name:b.name,label:b.department_name||b.name})),w=ue(i,e.custom_branch).map(b=>({name:b.name,label:b.branch||b.name}));return n.jsxs(We,{title:d,activePage:"users",user:j,formStatus:a,buttonText:h.saveUser,buttonColor:N.blue,viewMode:u,onEdit:p,hideSettings:f,onSubmit:g,onBack:c,onNavigate:o,onLogout:m,children:[n.jsxs("div",{style:pr,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.organization}),n.jsx(_t,{value:e.custom_organization,onChange:b=>C({custom_organization:b}),organizations:l,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.management}),n.jsx(de,{value:e.custom_management,onChange:b=>C({custom_management:b}),items:v,placeholder:"-- Select --",disabled:u})]})]}),n.jsxs("div",{style:pr,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.department}),n.jsx(de,{value:e.custom_department,onChange:b=>C({custom_department:b}),items:z,placeholder:"-- Select --",disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.branch}),n.jsx(de,{value:e.custom_branch,onChange:b=>C({custom_branch:b}),items:w,placeholder:"-- Select --",disabled:u})]})]}),n.jsxs("div",{style:pr,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.number}),n.jsx("input",{style:{...P,...y},value:e.custom_number,disabled:u,onChange:b=>C({custom_number:b.target.value}),placeholder:"e.g. 10001"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[h.field.fullName," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...y},value:e.first_name,disabled:u,onChange:b=>C({first_name:b.target.value}),placeholder:"Full name",required:!0})]})]}),n.jsxs("div",{style:pr,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.username}),n.jsx("input",{style:{...P,...y},value:e.username,disabled:u,onChange:b=>C({username:b.target.value}),placeholder:"Username"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.phoneNumber}),n.jsx("input",{style:{...P,...y},value:e.mobile_no,disabled:u,onChange:b=>C({mobile_no:b.target.value}),placeholder:"Phone number"})]})]}),n.jsxs("div",{style:pr,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[h.field.emailAddress," ",x&&n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...u||!x?{background:"#f9f9f9"}:{}},value:e.email,disabled:u||!x,onChange:b=>C({email:b.target.value}),placeholder:"user@example.com",type:"email",required:x})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.category}),n.jsxs("select",{style:{...P,...y},value:e.custom_category,disabled:u,onChange:b=>C({custom_category:b.target.value}),children:[n.jsx("option",{value:"",children:h.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 ru={Active:N.green,Closed:N.gray};function J0({cycles:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=q(),[a,u]=S.useState(""),[p,f]=S.useState(""),[g,c]=S.useState("all"),o=S.useMemo(()=>[...new Set(e.map(d=>d.organization).filter(Boolean))],[e]),m=S.useMemo(()=>e.filter(d=>{const v=(d.name1||d.name||"").toLowerCase();return!(a&&!v.includes(a.toLowerCase())||p&&d.organization!==p||g!=="all"&&d.status!==g)}),[e,a,p,g]),[j,h]=S.useState(1);S.useEffect(()=>{h(1)},[a,p,g]);const C=m.slice((j-1)*te,j*te),y=m.filter(d=>d.status==="Active").length,x=m.filter(d=>d.status==="Closed").length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(Te,{label:"Total",val:m.length,color:N.teal}),n.jsx(Te,{label:"Active",val:y,color:N.green}),n.jsx(Te,{label:"Closed",val:x,color:N.gray})]}),n.jsx(st,{filters:[{type:"search",label:"Search",value:a,onChange:u,placeholder:"Search by name…"},{type:"select",label:i.col.organization,value:p,onChange:f,options:[{value:"",label:"All Organizations"},...o.map(d=>({value:d,label:d}))]},{type:"select",label:"Status",value:g,onChange:c,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})}):C.map((d,v)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(d),style:{borderTop:"1px solid #f0f0f0",background:v%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:d.name1||d.name}),n.jsx("td",{style:{padding:"10px 14px"},children:d.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:d.frequency||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:d.start_date||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:d.end_date||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{padding:"3px 10px",borderRadius:12,fontSize:12,background:ru[d.status]+"22",color:ru[d.status]||"#666"},children:d.status})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:z=>z.stopPropagation(),children:n.jsx(Ke,{onView:()=>l==null?void 0:l(d),onEdit:t&&r?()=>r(d):void 0,onDelete:t&&s?()=>s(d.name):void 0})})]},d.name))})]})}),n.jsx(Ne,{page:j,total:m.length,onPageChange:h})]})}const wa={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},q0=["Weekly","Bi-weekly","Monthly","Quarterly","Annually"],Z0=["Active","Closed"];function V0({form:e,setForm:t,organizations:l,formStatus:r,viewMode:s,onEdit:i,onSubmit:a,onBack:u,onNavigate:p,onLogout:f,user:g}){const c=q(),o=h=>t(C=>({...C,...h})),m=s?{background:"#f9f9f9"}:{},j=e.name?s?`${c.formTitle.editCycle}: ${e.name1||e.name}`:c.formTitle.editCycle:c.formTitle.newCycle;return n.jsxs(We,{title:j,activePage:"cycles",user:g,formStatus:r,buttonText:c.saveCycle,buttonColor:N.teal,viewMode:s,onEdit:i,onSubmit:a,onBack:u,onNavigate:p,onLogout:f,children:[n.jsxs("div",{style:wa,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[c.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...m},value:e.name1||"",disabled:s||!!e.name,onChange:h=>o({name1:h.target.value}),placeholder:"e.g. Q1-2026"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.organization}),n.jsx(_t,{value:e.organization,onChange:h=>o({organization:h}),organizations:l,disabled:s})]})]}),n.jsxs("div",{style:wa,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.col.frequency}),n.jsx(de,{value:e.frequency,onChange:h=>o({frequency:h}),items:q0.map(h=>({name:h,label:h})),placeholder:"-- Select Frequency --",disabled:s})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.status}),n.jsx(de,{value:e.status,onChange:h=>o({status:h}),items:Z0.map(h=>({name:h,label:h})),placeholder:"-- Select Status --",disabled:s})]})]}),n.jsxs("div",{style:wa,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.dateStart}),n.jsx(he,{value:e.start_date||"",onChange:h=>o({start_date:h}),disabled:s,style:{...P,...m}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.dateEnd}),n.jsx(he,{value:e.end_date||"",onChange:h=>o({end_date:h}),disabled:s,style:{...P,...m}})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.updateWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...P,...m,maxWidth:160},value:e.update_window_days??2,disabled:s,onChange:h=>o({update_window_days:parseInt(h.target.value)||2})}),n.jsx("span",{style:{fontSize:12,color:"#888",marginLeft:8},children:"Grace period after cycle ends before Unknown is auto-assigned"})]})]})}function e1({kpiInputs:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=q(),[a,u]=S.useState(""),[p,f]=S.useState(""),g=S.useMemo(()=>[...new Set(e.map(h=>h.organization).filter(Boolean))],[e]),c=S.useMemo(()=>e.filter(h=>{const C=[h.organization,h.period].filter(Boolean).join(" ").toLowerCase();return!(a&&!C.includes(a.toLowerCase())||p&&h.organization!==p)}),[e,a,p]),[o,m]=S.useState(1);S.useEffect(()=>{m(1)},[a,p]);const j=c.slice((o-1)*te,o*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Te,{label:"Total Records",val:c.length,color:N.blue})}),n.jsx(st,{filters:[{type:"search",label:"Search",value:a,onChange:u,placeholder:"Organization or period…"},{type:"select",label:i.col.organization,value:p,onChange:f,options:[{value:"",label:"All Organizations"},...g.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:c.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):j.map((h,C)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:C%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:y=>y.stopPropagation(),children:n.jsx(Ke,{onView:()=>l==null?void 0:l(h),onEdit:t&&r?()=>r(h):void 0,onDelete:t&&s?()=>s(h.name):void 0})})]},h.name))})]})}),n.jsx(Ne,{page:o,total:c.length,onPageChange:m})]})}const su={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},iu={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20};function t1({form:e,setForm:t,organizations:l,formStatus:r,viewMode:s,onEdit:i,onSubmit:a,onBack:u,onNavigate:p,onLogout:f,user:g}){const c=q(),o=C=>t(y=>({...y,...C})),m=s?{background:"#f9f9f9"}:{},j=C=>y=>o({[C]:parseFloat(y.target.value)||0}),h=e.name?s?`${c.formTitle.editKpi}: ${e.period||e.name}`:c.formTitle.editKpi:c.formTitle.newKpi;return n.jsxs(We,{title:h,activePage:"kpi-input",user:g,formStatus:r,buttonText:c.saveKpi,buttonColor:N.blue,viewMode:s,onEdit:i,onSubmit:a,onBack:u,onNavigate:p,onLogout:f,children:[n.jsxs("div",{style:su,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.organization}),n.jsx(_t,{value:e.organization,onChange:C=>o({organization:C}),organizations:l,disabled:s})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[c.col.period," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...P,...m},value:e.period||"",disabled:s,onChange:C=>o({period:C.target.value}),placeholder:"e.g. Q1 2026"})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",marginBottom:12},children:"Financial KPIs"}),n.jsxs("div",{style:iu,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.revenue_growth}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...m},value:e.revenue_growth||"",disabled:s,onChange:j("revenue_growth")})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.net_profit}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...m},value:e.net_profit||"",disabled:s,onChange:j("net_profit")})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.cash_flow}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...m},value:e.cash_flow||"",disabled:s,onChange:j("cash_flow")})]})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",marginBottom:12},children:"Operational KPIs"}),n.jsxs("div",{style:iu,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.strategic_goal_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...m},value:e.strategic_goal_pct||"",disabled:s,onChange:j("strategic_goal_pct")})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.customer_satisfaction}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...m},value:e.customer_satisfaction||"",disabled:s,onChange:j("customer_satisfaction")})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.employee_turnover_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...m},value:e.employee_turnover_pct||"",disabled:s,onChange:j("employee_turnover_pct")})]})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",marginBottom:12},children:"Safety & Compliance"}),n.jsxs("div",{style:su,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.open_safety_incidents}),n.jsx("input",{type:"number",min:0,style:{...P,...m},value:e.open_safety_incidents||"",disabled:s,onChange:C=>o({open_safety_incidents:parseInt(C.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.compliance_score}),n.jsx("input",{type:"number",step:"0.01",style:{...P,...m},value:e.compliance_score||"",disabled:s,onChange:j("compliance_score")})]})]})]})]})}const n1={create_processes:"Create Processes",update_process_status:"Update Process Status"},au={Pending:N.orange,Accepted:N.green,Rejected:N.red,Revoked:N.gray};function l1(e){if(!e)return"—";const t=new Date(e);return isNaN(t.getTime())?"—":`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function r1(e){const t=[];return e.create_processes&&t.push("create_processes"),e.update_process_status&&t.push("update_process_status"),t}function s1({delegations:e,organizations:t,userRole:l,currentUser:r,onView:s,onRevoke:i}){const a=q(),[u,p]=S.useState(""),[f,g]=S.useState(""),[c,o]=S.useState("all"),m={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},j=S.useMemo(()=>e.filter(v=>{const z=`${v.auditor} ${v.manager}`.toLowerCase();return!(u&&!z.includes(u.toLowerCase())||f&&v.organization!==f||c!=="all"&&v.status!==c)}),[e,u,f,c]),[h,C]=S.useState(1);S.useEffect(()=>{C(1)},[u,f,c]);const y=j.slice((h-1)*te,h*te),x=j.filter(v=>v.status==="Pending").length,d=j.filter(v=>v.status==="Accepted").length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(Te,{label:"Total",val:j.length,color:N.purple}),n.jsx(Te,{label:"Pending",val:x,color:N.orange}),n.jsx(Te,{label:"Accepted",val:d,color:N.green})]}),n.jsx(st,{filters:[{type:"search",label:"Search",value:u,onChange:p,placeholder:"Auditor or Manager…"},{type:"select",label:a.col.organization,value:f,onChange:g,options:[{value:"",label:"All Organizations"},...t.map(v=>({value:v.organization_name||v.name,label:v.organization_name||v.name}))]},{type:"select",label:"Status",value:c,onChange:o,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})}):y.map((v,z)=>{const w=!!i&&(v.status==="Pending"||v.status==="Accepted")&&(l==="Admin"||l==="Auditor"&&v.auditor===r);return n.jsxs("tr",{onClick:()=>s==null?void 0:s(v),style:{borderTop:"1px solid #f0f0f0",background:z%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:v.number||v.name}),n.jsx("td",{style:{padding:"10px 14px"},children:v.auditor}),n.jsx("td",{style:{padding:"10px 14px"},children:v.manager}),n.jsx("td",{style:{padding:"10px 14px"},children:v.organization||"All Organizations"}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:r1(v).map(b=>n.jsx("span",{style:{background:"#ede9fe",color:"#6d28d9",padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600},children:n1[b]||b},b))})}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{background:(au[v.status]||N.gray)+"22",color:au[v.status]||N.gray,padding:"3px 10px",borderRadius:12,fontSize:12,fontWeight:700},children:v.status})}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:l1(v.requested_on)}),n.jsx("td",{style:{padding:"8px 14px"},onClick:b=>b.stopPropagation(),children:n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("button",{onClick:()=>s==null?void 0:s(v),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"})]})}),w&&n.jsx("button",{onClick:()=>i==null?void 0:i(v.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"})]})})]},v.name)})})]})}),n.jsx(Ne,{page:h,total:j.length,onPageChange:C})]})}const ou={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},du={Pending:N.orange,Accepted:N.green,Rejected:N.red,Revoked:N.gray};function i1(e){if(!e)return"—";const t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleString()}function a1({form:e,setForm:t,organizations:l,users:r,userRoleMap:s,formStatus:i,viewMode:a,onEdit:u,onSubmit:p,onBack:f,onNavigate:g,onLogout:c,user:o}){var x;const m=q(),j=d=>t(v=>({...v,...d})),h=a?{background:"#f9f9f9"}:{},C=Ul(r,s,"SB Manager").map(d=>({name:d.name,label:d.full_name||d.name})),y=e.name?`${m.formTitle.viewDelegation}${e.number||e.name}`:m.formTitle.newDelegation;return n.jsxs(We,{title:y,activePage:"delegations",user:o,formStatus:i,buttonText:m.saveDelegation,buttonColor:N.purple,viewMode:a,onEdit:u,onSubmit:p,onBack:f,onNavigate:g,onLogout:c,children:[a&&e.status&&n.jsx("div",{style:{marginBottom:20},children:n.jsx("span",{style:{background:(du[e.status]||N.gray)+"22",color:du[e.status]||N.gray,padding:"5px 14px",borderRadius:14,fontSize:13,fontWeight:700},children:e.status})}),n.jsxs("div",{style:ou,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:m.col.auditor}),n.jsx("input",{style:{...P,background:"#f9f9f9"},value:e.auditor||o.name,disabled:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[m.col.manager," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(de,{value:e.manager,onChange:d=>j({manager:d}),items:C,placeholder:"-- Select Manager --",disabled:a})]})]}),n.jsx("div",{style:ou,children:n.jsxs("div",{children:[n.jsx("label",{style:T,children:m.col.organization}),n.jsx(_t,{value:e.organization,onChange:d=>j({organization:d}),organizations:l,placeholder:"-- All Organizations --",disabled:a})]})}),n.jsxs("div",{style:{marginTop:8},children:[n.jsxs("label",{style:T,children:[m.col.functions," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,marginTop:6},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:a?"default":"pointer"},children:[n.jsx("input",{type:"checkbox",style:Fl,checked:!!e.create_processes,disabled:a,onChange:d=>j({create_processes:d.target.checked?1:0})}),n.jsx("span",{style:{fontSize:14},children:"Create Processes"})]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:a?"default":"pointer"},children:[n.jsx("input",{type:"checkbox",style:Fl,checked:!!e.update_process_status,disabled:a,onChange:d=>j({update_process_status:d.target.checked?1:0})}),n.jsx("span",{style:{fontSize:14},children:"Update Process Status"})]})]})]}),!a&&n.jsxs("div",{style:{marginTop:20},children:[n.jsx("label",{style:T,children:"Remarks"}),n.jsx("textarea",{style:{...P,...h,minHeight:70,resize:"vertical"},value:e.remarks||"",onChange:d=>j({remarks:d.target.value}),placeholder:"Optional note for the Manager…"})]}),a&&(((x=e.delegation_log)==null?void 0:x.length)??0)>0&&n.jsxs("div",{style:{marginTop:28},children:[n.jsx("label",{style:T,children:"Audit Trail"}),n.jsx("div",{style:{background:"white",borderRadius:8,border:"1px solid #eee",overflow:"hidden"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa"},children:[n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Action"}),n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Actor"}),n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Timestamp"}),n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Remarks"})]})}),n.jsx("tbody",{children:(e.delegation_log||[]).map((d,v)=>n.jsxs("tr",{style:{borderTop:"1px solid #f0f0f0"},children:[n.jsx("td",{style:{padding:"8px 14px",fontWeight:600},children:d.action}),n.jsx("td",{style:{padding:"8px 14px"},children:d.actor}),n.jsx("td",{style:{padding:"8px 14px",color:"#666"},children:i1(d.timestamp)}),n.jsx("td",{style:{padding:"8px 14px",color:"#666"},children:d.remarks||"—"})]},d.name||v))})]})})]})]})}const cu={process:"processes-form",order:"orders-form",incident:"incidents-form",idea:"ideas-form"},ka={process:N.blue,order:N.purple,incident:N.red,idea:N.green,delegation:N.orange};function o1({onNavigate:e,onRefresh:t}){const l=q(),[r,s]=S.useState([]),[i,a]=S.useState(!0),[u,p]=S.useState(""),[f,g]=S.useState(""),c=()=>py().then(C=>{s(C),a(!1)});S.useEffect(()=>{c()},[]);const o=r.filter(C=>C.requires_action),m=r.filter(C=>!C.requires_action),j=async(C,y)=>{p(C),g("");try{await hy(C,y),await c(),t==null||t()}catch{g(C)}p("")};function h(C,y){return y.length===0?null:n.jsxs("div",{style:{marginBottom:24},children:[n.jsxs("h3",{style:{fontSize:14,fontWeight:700,color:"#555",marginBottom:12,textTransform:"uppercase",letterSpacing:1},children:[C," (",y.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:y.map((x,d)=>{const v=x.type!=="delegation";return n.jsxs("div",{onClick:v?()=>e(cu[x.type],x.name):void 0,style:{background:"white",borderRadius:10,padding:"14px 18px",boxShadow:"0 1px 4px rgba(0,0,0,0.07)",display:"flex",alignItems:"center",gap:16,borderLeft:`4px solid ${ka[x.type]||N.gray}`,cursor:v?"pointer":"default",transition:"box-shadow 0.15s, transform 0.15s"},onMouseEnter:v?z=>{z.currentTarget.style.boxShadow="0 4px 14px rgba(0,0,0,0.12)",z.currentTarget.style.transform="translateY(-1px)"}:void 0,onMouseLeave:v?z=>{z.currentTarget.style.boxShadow="0 1px 4px rgba(0,0,0,0.07)",z.currentTarget.style.transform="none"}:void 0,children:[n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[n.jsx("span",{style:{fontSize:11,fontWeight:700,color:"white",background:ka[x.type]||N.gray,padding:"2px 8px",borderRadius:10},children:x.type.toUpperCase()}),n.jsx("span",{style:{fontWeight:700,fontSize:14},children:x.number}),n.jsx("span",{style:{fontSize:13,color:"#333",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.title})]}),n.jsxs("div",{style:{marginTop:4,fontSize:12,color:"#888"},children:[x.action," ",x.organization?`· ${x.organization}`:""," ",x.date?`· ${x.date}`:""]}),f===x.name&&n.jsx("div",{style:{marginTop:4,fontSize:12,color:"#e74c3c"},children:"Failed to respond — please try again."})]}),x.type==="delegation"?n.jsxs("div",{style:{display:"flex",gap:8,flexShrink:0},children:[n.jsx("button",{onClick:()=>j(x.name,"Accepted"),disabled:u===x.name,style:{padding:"7px 16px",borderRadius:8,border:"none",background:N.green,color:"white",fontWeight:600,fontSize:13,cursor:u===x.name?"wait":"pointer",opacity:u===x.name?.6:1},children:"Accept"}),n.jsx("button",{onClick:()=>j(x.name,"Rejected"),disabled:u===x.name,style:{padding:"7px 16px",borderRadius:8,border:"none",background:N.red,color:"white",fontWeight:600,fontSize:13,cursor:u===x.name?"wait":"pointer",opacity:u===x.name?.6:1},children:"Reject"})]}):n.jsx("button",{onClick:z=>{z.stopPropagation(),e(cu[x.type],x.name)},style:{padding:"7px 16px",borderRadius:8,border:"none",background:ka[x.type]||N.accent,color:"white",fontWeight:600,fontSize:13,cursor:"pointer",flexShrink:0},children:x.requires_action?"Act":l.view})]},d)})})]})}return n.jsxs("div",{style:{maxWidth:900,margin:"0 auto"},children:[i&&n.jsx("p",{style:{color:"#888"},children:l.loading}),!i&&r.length===0&&n.jsxs("div",{style:{background:"white",borderRadius:12,padding:48,textAlign:"center",color:"#aaa",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("div",{style:{fontSize:48,marginBottom:12},children:"📥"}),n.jsx("p",{style:{fontSize:16},children:l.inbox.noMessages})]}),!i&&h("Needs Action",o),!i&&h("Informational",m)]})}const d1=[{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"]}],Of={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 c1(e,t){const l=e.map(s=>Of[s]||s).join(","),r=t.map(s=>e.map(i=>`"${s[i]??""}"`).join(",")).join(`
`);return l+`
`+r}function u1(e,t){const l=new Blob([e],{type:"text/csv"}),r=URL.createObjectURL(l),s=document.createElement("a");s.href=r,s.download=t,s.click(),URL.revokeObjectURL(r)}const Df="report-print-area",_a="report-print-portal";function p1(){const e=document.getElementById(Df);if(!e)return;const t=document.createElement("div");t.id=_a,t.innerHTML=e.innerHTML,document.body.appendChild(t);const l=document.createElement("style");l.id="report-print-style",l.textContent=`
#${_a} { display: none; }
@media print {
#root { display: none !important; }
#${_a} { display: block !important; }
}
`,document.head.appendChild(l);const r=()=>{t.remove(),l.remove(),window.removeEventListener("afterprint",r)};window.addEventListener("afterprint",r),window.print()}const uu={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",minWidth:180},Ca={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white"};function f1({organizations:e,userRole:t}){const l=q(),r=d1.filter(I=>I.roles.includes(t)),[s,i]=S.useState(""),[a,u]=S.useState(""),[p,f]=S.useState(""),[g,c]=S.useState(""),[o,m]=S.useState(String(new Date().getFullYear())),[j,h]=S.useState([]),[C,y]=S.useState([]),[x,d]=S.useState(!1),[v,z]=S.useState(""),w=r.find(I=>I.id===s);async function b(){if(s){d(!0),z(""),y([]),h([]);try{const I={};a&&(I.organization=a),p&&(I.from_date=p),g&&(I.to_date=g),(w==null?void 0:w.extraFilter)==="year"&&o&&(I.year=o);const U=await uy(s,I);h(U.columns||[]),y(U.rows||[])}catch(I){z(I.message||"Error running report")}finally{d(!1)}}}const k=(w==null?void 0:w.label)||s;return n.jsxs("div",{children:[n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12,marginBottom:20},children:r.map(I=>n.jsxs("div",{onClick:()=>i(I.id),style:{background:s===I.id?"#ebf5fb":"white",border:s===I.id?`2px solid ${N.accent}`:"2px solid transparent",borderRadius:10,padding:"14px 16px",cursor:"pointer",boxShadow:"0 1px 4px rgba(0,0,0,0.07)"},children:[n.jsx("div",{style:{fontWeight:700,fontSize:14,color:"#1a2332",marginBottom:4},children:I.label}),n.jsx("div",{style:{fontSize:12,color:"#888"},children:I.description})]},I.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:uu,value:s,onChange:I=>i(I.target.value),children:[n.jsx("option",{value:"",children:"-- Select Report --"}),r.map(I=>n.jsx("option",{value:I.id,children:I.label},I.id))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"ORGANIZATION"}),n.jsxs("select",{style:uu,value:a,onChange:I=>u(I.target.value),children:[n.jsx("option",{value:"",children:l.filter.allOrgs}),e.map(I=>n.jsx("option",{value:I.name,children:I.organization_name||I.name},I.name))]})]}),(w==null?void 0:w.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:{...Ca,width:90},value:o,onChange:I=>m(I.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(he,{value:p,onChange:f,style:Ca})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"TO"}),n.jsx(he,{value:g,onChange:c,style:Ca})]})]}),n.jsx("button",{onClick:b,disabled:!s||x,style:{padding:"9px 20px",borderRadius:8,border:"none",background:N.accent,color:"white",fontWeight:700,fontSize:13,cursor:s?"pointer":"not-allowed",opacity:s?1:.5},children:x?l.loading:l.reports.generate}),C.length>0&&n.jsx("button",{onClick:()=>u1(c1(j,C),`${s}.csv`),style:{padding:"9px 20px",borderRadius:8,border:"1px solid #27ae60",background:"white",color:"#27ae60",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Export CSV"}),C.length>0&&n.jsx("button",{onClick:p1,style:{padding:"9px 20px",borderRadius:8,border:"1px solid #888",background:"white",color:"#555",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Print / PDF"})]})}),v&&n.jsx("div",{style:{color:"#e74c3c",marginBottom:16},children:v}),C.length>0&&n.jsxs("div",{id:Df,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:k}),n.jsxs("span",{style:{fontSize:12,color:"#888"},children:[C.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(I=>n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700,whiteSpace:"nowrap"},children:Of[I]||I.replace(/_/g," ").toUpperCase()},I))})}),n.jsx("tbody",{children:C.map((I,U)=>n.jsx("tr",{style:{borderTop:"1px solid #f0f0f0",background:U%2===0?"white":"#fafafa"},children:j.map(J=>n.jsx("td",{style:{padding:"10px 14px",color:"#333"},children:I[J]!=null?String(I[J]):"—"},J))},U))})]})]}),!x&&C.length===0&&s&&!v&&n.jsx("div",{style:{background:"white",borderRadius:12,padding:40,textAlign:"center",color:"#aaa",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:"Select a report and click Run Report to see results."}),r.length===0&&n.jsx("div",{style:{background:"white",borderRadius:12,padding:40,textAlign:"center",color:"#aaa",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:"No reports are available for your role."})]})}const is=()=>new Date().toISOString().split("T")[0],md=()=>new Date(Date.now()+30*24*60*60*1e3).toISOString().split("T")[0],Yt=()=>({name:"",number:"",title:"",organization:"",type:"",incident_class:"",incident_field:"",date:is(),time:"",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:""}),Xt=()=>({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:is(),priority:"",economy_class:"",product_relation:0,repeated:0,entity_scope:"",solution:"",cost:0,auditor_comment:""}),Jt=()=>({name:"",number:"",title:"",organization:"",type:"Buy L",management:"",department:"",section_field:"",branch:"",starting_date:is(),ending_date:md(),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:""}),Ns=()=>({name:"",title:"",date_start:is(),date_end:md(),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:""}),fr=()=>({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}),cl=()=>({name:"",organization:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ul=()=>({name:"",custom_organization:"",department_name:"",custom_management:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),pl=()=>({name:"",organization:"",branch:"",management:"",department:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_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"}),xr=()=>({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"}),yr=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),vr=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),jr=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),br=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ws=()=>({name:"",first_name:"",full_name:"",email:"",enabled:1,creation:"",username:"",mobile_no:"",custom_organization:"",custom_management:"",custom_department:"",custom_branch:"",custom_number:"",custom_category:""}),fl=()=>({name:"",name1:"",organization:"",frequency:"Monthly",status:"Active",start_date:is(),end_date:md(),update_window_days:2}),hl=()=>({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}),Sr=()=>({name:"",number:"",auditor:"",manager:"",organization:"",create_processes:0,update_process_status:0,status:"Pending",requested_on:"",remarks:""}),h1=new Set(["incidents","incidents-form","ideas","ideas-form"]),g1=new Set(["orders","orders-form","incidents","incidents-form","ideas","ideas-form"]),x1=new Set(["Admin","Owner","Auditor","Manager"]),m1=new Set(["Admin","Owner","Auditor","Manager"]),y1=new Set(["Admin","Auditor","Manager"]);function v1({user:e,onLogout:t,darkMode:l,onToggleDark:r}){const s=q(),i=e.role,a=x1.has(i),u=m1.has(i),p=y1.has(i),f=_=>_==="users"||_==="users-form"?i==="Admin":i==="Admin"||i==="Auditor"?!0:i==="Owner"||i==="XAuditor"?!1:i==="Manager"?!!(g1.has(_)||(_==="processes"||_==="processes-form")&&jd.includes("create_processes")):h1.has(_),g=_=>i==="Employee"&&!!_&&_!=="New",[c,o]=S.useState(a?"dashboard":"inbox"),[m,j]=S.useState(""),[h,C]=S.useState("");S.useEffect(()=>{if(!h)return;const _=setTimeout(()=>C(""),0);return()=>clearTimeout(_)},[h]);const y=(_,Q)=>{C(Q),o(_)},[x,d]=S.useState(0),[v,z]=S.useState([]),[w,b]=S.useState([]),[k,I]=S.useState([]),[U,J]=S.useState([]),[se,$]=S.useState([]),[G,pe]=S.useState([]),[ne,Se]=S.useState([]),[E,M]=S.useState([]),[W,V]=S.useState([]),[X,ee]=S.useState([]),[Ce,L]=S.useState([]),[Z,Je]=S.useState([]),[K,A]=S.useState([]),[R,F]=S.useState([]),[Mt,as]=S.useState([]),[Ln,Fi]=S.useState([]),[dn,O]=S.useState([]),[Qe,Zn]=S.useState([]),[Ct,Nf]=S.useState([]),[Vn,Wf]=S.useState({}),[Ql,Bf]=S.useState([]),[os,$f]=S.useState([]),[yd,Uf]=S.useState([]),[vd,Ff]=S.useState([]),[jd,Mf]=S.useState([]),[bd,Hf]=S.useState({}),[ve,oe]=S.useState(!0),[Pe,le]=S.useState("idle"),[Ae,ie]=S.useState(!1),[Sd,wd]=S.useState(!1),[ds,kd]=S.useState(null),[Kf,Qf]=S.useState(()=>localStorage.getItem("sb_sidebar")==="1"),Gf=()=>Qf(_=>{const Q=!_;return localStorage.setItem("sb_sidebar",Q?"1":"0"),Q}),[Yf,Mi]=S.useState(!1);S.useEffect(()=>{Mi(!1)},[c]);const[el,Ht]=S.useState(Yt()),[tl,Kt]=S.useState(Xt()),[cs,Qt]=S.useState(Jt()),[us,Dt]=S.useState(Ns()),[_d,Gl]=S.useState(fr()),[Cd,nl]=S.useState(cl()),[zd,ll]=S.useState(ul()),[Td,rl]=S.useState(pl()),[Id,Yl]=S.useState(hr()),[Ed,Xl]=S.useState(gr()),[Pd,Jl]=S.useState(xr()),[Ad,ql]=S.useState(mr()),[Rd,Zl]=S.useState(yr()),[Ld,Vl]=S.useState(vr()),[Od,er]=S.useState(jr()),[Dd,tr]=S.useState(br()),[ps,fs]=S.useState(Ws()),[Nd,sl]=S.useState(fl()),[Wd,il]=S.useState(hl()),[al,nr]=S.useState(Sr()),Nt=async()=>{oe(!0);try{const[_,Q,ut,zt,cn,Re,Gi,Mh,Hh,Kh,Qh,Gh,Yh,Xh,Jh,qh,Zh,Vh,eg,tg,ng,lg,rg,sg,ig,ag]=await Promise.all([je(D.incidents),je(D.organizations),je(D.ideas),je(D.orders),je(D.processes),Ym(),je(D.managements),je(D.departments),je(D.branches),je(D.incidentTypes),je(D.incidentClass),je(D.incidentField),je(D.ideaTypes),je(D.orderTypes),je(D.processTypes),je(D.incidentStatuses),je(D.ideaStatuses),je(D.orderStatuses),je(D.processStatuses),Zm(),Vm(),je(D.cycles),je(D.kpiInput),xy(),yy(),vy()]);z(_||[]),b(Q||[]),I(ut||[]),J(zt||[]),$(cn||[]),Bf(Re||[]),pe(Gi||[]),Se(Mh||[]),M(Hh||[]),V(Kh||[]),ee(Qh||[]),L(Gh||[]),Je(Yh||[]),A(Xh||[]),F(Jh||[]),as(qh||[]),Fi(Zh||[]),O(Vh||[]),Zn(eg||[]),Nf(tg||[]),Wf(ng||{}),$f(lg||[]),Uf(rg||[]),Ff(sg||[]),Mf(ig||[]),Hf(ag||{})}catch(_){console.error("Error loading data:",_)}oe(!1)},Xf=async()=>{try{const _=await fetch("/api/method/sidrah_business.api.get_notification_count",{credentials:"include",headers:{Accept:"application/json"}});if(_.ok){const Q=await _.json();d(Number(Q.message)||0)}}catch{}};S.useEffect(()=>{Nt(),Xf()},[e.name]);const Be=async(_,Q)=>{if(window.confirm(s.rtl?"هل أنت متأكد من حذف هذا السجل؟":"Are you sure you want to delete this record?")){oe(!0);try{await Ef(_,Q),await Nt()}catch(ut){console.error("Delete error:",ut),alert((ut==null?void 0:ut.message)||"Delete failed. Please try again.")}oe(!1)}},Jf=async _=>{try{await ly(_),await Nt()}catch(Q){console.error("Disable user error:",Q)}},qf=async _=>{ie(!0),oe(!0);try{const Q=await pt(D.incidents,_.name);Ht({...Yt(),...Q})}catch{Ht({...Yt(),..._})}o("incidents-form"),oe(!1)},Zf=async _=>{ie(!0),oe(!0);try{const Q=await pt(D.ideas,_.name);Kt({...Xt(),...Q})}catch{Kt({...Xt(),..._})}o("ideas-form"),oe(!1)},Vf=async _=>{ie(!0),oe(!0);try{const Q=await pt(D.orders,_.name);Qt({...Jt(),...Q})}catch{Qt({...Jt(),..._})}o("orders-form"),oe(!1)},eh=async _=>{ie(!0),oe(!0);try{const Q=await zr(_.name);Dt({...Q,progress_indicators:Q.progress_indicators||[],cycle_logs:Q.cycle_logs||[]}),o("processes-form")}catch{Dt({..._,progress_indicators:_.progress_indicators||[]}),o("processes-form")}oe(!1)},th=_=>ge(D.organizations,_,Gl,fr(),"organizations-form",!0),nh=async _=>{ie(!0),oe(!0);try{const Q=await pt(D.managements,_.name);nl({...cl(),...Q})}catch{nl({...cl(),..._})}o("managements-form"),oe(!1)},lh=async _=>{ie(!0),oe(!0);try{const Q=await pt(D.departments,_.name);ll({...ul(),...Q})}catch{ll({...ul(),..._})}o("departments-form"),oe(!1)},rh=async _=>{ie(!0),oe(!0);try{const Q=await pt(D.branches,_.name);rl({...pl(),...Q})}catch{rl({...pl(),..._})}o("branches-form"),oe(!1)},sh=async _=>{ie(!0),oe(!0);try{const Q=await pt(D.cycles,_.name);sl({...fl(),...Q})}catch{sl({...fl(),..._})}o("cycles-form"),oe(!1)},ih=async _=>{ie(!0),oe(!0);try{const Q=await pt(D.kpiInput,_.name);il({...hl(),...Q})}catch{il({...hl(),..._})}o("kpi-input-form"),oe(!1)},Fe=async(_,Q,ut,zt,cn)=>{le("loading");try{if(Q.name)await bi(_,Q.name,Q),le("success"),Nt(),setTimeout(()=>{le("idle"),o(zt)},1500);else if(cn){const Re=await ja(_,Q);cn(Re),le("success"),Nt(),setTimeout(()=>le("idle"),1500)}else await ja(_,Q),ut(),le("success"),Nt(),setTimeout(()=>{le("idle"),o(zt)},1500)}catch(Re){console.error("Submit error:",Re),le(Re instanceof Error?Re.message:"Error saving. Please try again.")}},Ie=async()=>{await Jm(),t()},ge=async(_,Q,ut,zt,cn,Re)=>{ie(Re),oe(!0);try{const Gi=await pt(_,Q.name);ut({...zt,...Gi})}catch{ut({...zt,...Q})}o(cn),oe(!1)},ah=_=>ge(D.incidents,_,Ht,Yt(),"incidents-form",!1),oh=_=>ge(D.ideas,_,Kt,Xt(),"ideas-form",!1),dh=_=>ge(D.orders,_,Qt,Jt(),"orders-form",!1),ch=_=>{ie(!1),oe(!0),zr(_.name).then(Q=>{Dt({...Q,progress_indicators:Q.progress_indicators||[],cycle_logs:Q.cycle_logs||[]})}).catch(()=>{Dt({..._,progress_indicators:_.progress_indicators||[]})}).finally(()=>{o("processes-form"),oe(!1)})},uh=_=>ge(D.organizations,_,Gl,fr(),"organizations-form",!1),ph=_=>ge(D.managements,_,nl,cl(),"managements-form",!1),fh=_=>ge(D.departments,_,ll,ul(),"departments-form",!1),hh=_=>ge(D.branches,_,rl,pl(),"branches-form",!1),gh=_=>ge(D.cycles,_,sl,fl(),"cycles-form",!1),xh=_=>ge(D.kpiInput,_,il,hl(),"kpi-input-form",!1),mh=async _=>{ie(!0),oe(!0);try{const Q=await my(_.name);nr({...Sr(),...Q})}catch{nr({...Sr(),..._})}o("delegations-form"),oe(!1)},yh=async()=>{le("loading");try{const _=[];al.create_processes&&_.push("create_processes"),al.update_process_status&&_.push("update_process_status"),await fy(al.manager,_,al.organization,al.remarks),nr(Sr()),le("success"),Nt(),setTimeout(()=>{le("idle"),o("delegations")},1500)}catch(_){console.error("Delegation submit error:",_),le(_ instanceof Error?_.message:"Error saving. Please try again.")}},vh=async _=>{if(window.confirm(s.rtl?"هل أنت متأكد من إلغاء هذا التفويض؟":"Are you sure you want to revoke this delegation?")){oe(!0);try{await gy(_),await Nt()}catch(Q){console.error("Revoke delegation error:",Q),alert(Q instanceof Error?Q.message:"Revoke failed. Please try again.")}oe(!1)}},jh=_=>ge(D.incidentTypes,_,Yl,hr(),"incident-types-form",!0),bh=_=>ge(D.incidentTypes,_,Yl,hr(),"incident-types-form",!1),Sh=_=>ge(D.ideaTypes,_,Xl,gr(),"idea-types-form",!0),wh=_=>ge(D.ideaTypes,_,Xl,gr(),"idea-types-form",!1),kh=_=>ge(D.orderTypes,_,Jl,xr(),"order-types-form",!0),_h=_=>ge(D.orderTypes,_,Jl,xr(),"order-types-form",!1),Ch=_=>ge(D.processTypes,_,ql,mr(),"process-types-form",!0),zh=_=>ge(D.processTypes,_,ql,mr(),"process-types-form",!1),Th=_=>ge(D.incidentStatuses,_,Zl,yr(),"incident-statuses-form",!0),Ih=_=>ge(D.incidentStatuses,_,Zl,yr(),"incident-statuses-form",!1),Eh=_=>ge(D.ideaStatuses,_,Vl,vr(),"idea-statuses-form",!0),Ph=_=>ge(D.ideaStatuses,_,Vl,vr(),"idea-statuses-form",!1),Ah=_=>ge(D.orderStatuses,_,er,jr(),"order-statuses-form",!0),Rh=_=>ge(D.orderStatuses,_,er,jr(),"order-statuses-form",!1),Lh=_=>ge(D.processStatuses,_,tr,br(),"process-statuses-form",!0),Oh=_=>ge(D.processStatuses,_,tr,br(),"process-statuses-form",!1),Dh=async _=>{kd(_),o("profile")},Nh=_=>{ie(!1),wd(!1),fs({...Ws(),..._}),o("users-form")},Wh=async()=>{le("loading");try{if(!ps.name)await ja("User",{...ps,send_welcome_email:0,user_type:"System User"});else{const{name:Q,email:ut,creation:zt,full_name:cn,...Re}=ps;await bi("User",Q,Re)}fs(Ws()),le("success"),Nt(),setTimeout(()=>{le("idle"),o("users")},1500)}catch(_){console.error("User submit error:",_),le(_ instanceof Error?_.message:"Error saving. Please try again.")}},Hi=(_,Q)=>{if(Q){const zt={"processes-form":D.processes,"orders-form":D.orders,"incidents-form":D.incidents,"ideas-form":D.ideas}[_];if(zt){ie(!0),oe(!0),(_==="processes-form"?zr(Q).then(Re=>({...Re,progress_indicators:Re.progress_indicators||[],cycle_logs:Re.cycle_logs||[]})):pt(zt,Q)).then(Re=>{_==="processes-form"?Dt(Re):_==="orders-form"?Qt({...Jt(),...Re}):_==="incidents-form"?Ht({...Yt(),...Re}):_==="ideas-form"&&Kt({...Xt(),...Re}),o(_),oe(!1)}).catch(()=>{o(_),oe(!1)});return}}o(_)};if(c==="incidents-form")return n.jsx(Fy,{incForm:el,setIncForm:Ht,organizations:w,managements:G,departments:ne,branches:E,incidentTypes:W,incidentClasses:X,incidentFields:Ce,incidentStatuses:Mt,users:Ql,userRoleMap:Vn,formStatus:Pe,viewMode:Ae||!f("incidents-form")||g(el.workflow_state),onEdit:f("incidents-form")&&!g(el.workflow_state)?()=>ie(!1):void 0,userRole:i,onSubmit:()=>Fe(D.incidents,el,()=>Ht(Yt()),"incidents",_=>Ht({...Yt(),..._})),onBack:()=>{o("incidents"),le("idle")},onNavigate:o,onLogout:Ie,user:e,onRefresh:async()=>{if(el.name){const _=await pt(D.incidents,el.name).catch(()=>null);_&&Ht({...Yt(),..._})}je(D.incidents).then(_=>z(_||[])).catch(()=>{})}});if(c==="ideas-form")return n.jsx(Qy,{ideaForm:tl,setIdeaForm:Kt,organizations:w,managements:G,departments:ne,branches:E,ideaTypes:Z,ideaStatuses:Ln,users:Ql,userRoleMap:Vn,formStatus:Pe,viewMode:Ae||!f("ideas-form")||g(tl.workflow_state),onEdit:f("ideas-form")&&!g(tl.workflow_state)?()=>ie(!1):void 0,userRole:i,onSubmit:()=>Fe(D.ideas,tl,()=>Kt(Xt()),"ideas",_=>Kt({...Xt(),..._})),onBack:()=>{o("ideas"),le("idle")},onNavigate:o,onLogout:Ie,user:e,onRefresh:async()=>{if(tl.name){const _=await pt(D.ideas,tl.name).catch(()=>null);_&&Kt({...Xt(),..._})}je(D.ideas).then(_=>I(_||[])).catch(()=>{})}});if(c==="orders-form")return n.jsx(qy,{orderForm:cs,setOrderForm:Qt,organizations:w,managements:G,departments:ne,branches:E,orderTypes:K,orderStatuses:dn,cycles:os,users:Ql,userRoleMap:Vn,formStatus:Pe,viewMode:Ae||!f("orders-form"),onEdit:f("orders-form")?()=>ie(!1):void 0,currentUser:e.name,userRole:i,onSubmit:()=>Fe(D.orders,cs,()=>Qt(Jt()),"orders",_=>Qt({...Jt(),..._})),onBack:()=>{o("orders"),le("idle")},onNavigate:o,onLogout:Ie,user:e,onRefresh:async()=>{if(cs.name){const _=await pt(D.orders,cs.name).catch(()=>null);_&&Qt({...Jt(),..._})}je(D.orders).then(_=>J(_||[])).catch(()=>{})}});if(c==="processes-form")return n.jsx(n0,{processForm:us,setProcessForm:Dt,organizations:w,managements:G,departments:ne,branches:E,processTypes:R,processStatuses:Qe,cycles:os,users:Ql,userRoleMap:Vn,formStatus:Pe,viewMode:Ae||!f("processes-form"),onEdit:f("processes-form")?()=>ie(!1):void 0,userRole:e.role,delegatedFunctions:jd,delegatedOrgs:bd.create_processes,onRefreshProcess:async()=>{if(us.name)try{const _=await zr(us.name);Dt({..._,progress_indicators:_.progress_indicators||[],cycle_logs:_.cycle_logs||[]})}catch{}je(D.processes).then(_=>$(_||[])).catch(()=>{})},onSubmit:()=>Fe(D.processes,us,()=>Dt(Ns()),"processes",_=>Dt({...Ns(),..._,progress_indicators:_.progress_indicators||[],cycle_logs:_.cycle_logs||[]})),onBack:()=>{o("processes"),le("idle")},onNavigate:o,onLogout:Ie,user:e});if(c==="organizations-form")return n.jsx(c0,{orgForm:_d,setOrgForm:Gl,formStatus:Pe,viewMode:Ae||!f("organizations-form"),onEdit:f("organizations-form")?()=>ie(!1):void 0,onSubmit:()=>Fe(D.organizations,_d,()=>Gl(fr()),"organizations"),onBack:()=>{o("organizations"),le("idle")},onNavigate:o,onLogout:Ie,user:e});if(c==="managements-form")return n.jsx(f0,{form:Cd,setForm:nl,organizations:w,formStatus:Pe,viewMode:Ae||!f("managements-form"),onEdit:f("managements-form")?()=>ie(!1):void 0,onSubmit:()=>Fe(D.managements,Cd,()=>nl(cl()),"managements"),onBack:()=>{o("managements"),le("idle")},onNavigate:o,onLogout:Ie,user:e});if(c==="departments-form")return n.jsx(m0,{form:zd,setForm:ll,organizations:w,managements:G,formStatus:Pe,viewMode:Ae||!f("departments-form"),onEdit:f("departments-form")?()=>ie(!1):void 0,onSubmit:()=>Fe(D.departments,zd,()=>ll(ul()),"departments"),onBack:()=>{o("departments"),le("idle")},onNavigate:o,onLogout:Ie,user:e});if(c==="branches-form")return n.jsx(b0,{form:Td,setForm:rl,organizations:w,managements:G,departments:ne,formStatus:Pe,viewMode:Ae||!f("branches-form"),onEdit:f("branches-form")?()=>ie(!1):void 0,onSubmit:()=>Fe(D.branches,Td,()=>rl(pl()),"branches"),onBack:()=>{o("branches"),le("idle")},onNavigate:o,onLogout:Ie,user:e});if(c==="cycles-form")return n.jsx(V0,{form:Nd,setForm:sl,organizations:w,formStatus:Pe,viewMode:Ae||!f("cycles-form"),onEdit:f("cycles-form")?()=>ie(!1):void 0,onSubmit:()=>Fe(D.cycles,Nd,()=>sl(fl()),"cycles"),onBack:()=>{o("cycles"),le("idle")},onNavigate:o,onLogout:Ie,user:e});if(c==="kpi-input-form")return n.jsx(t1,{form:Wd,setForm:il,organizations:w,formStatus:Pe,viewMode:Ae||!f("kpi-input-form"),onEdit:f("kpi-input-form")?()=>ie(!1):void 0,onSubmit:()=>Fe(D.kpiInput,Wd,()=>il(hl()),"kpi-input"),onBack:()=>{o("kpi-input"),le("idle")},onNavigate:o,onLogout:Ie,user:e});if(c==="incident-types-form")return n.jsx(k0,{form:Id,setForm:Yl,formStatus:Pe,viewMode:Ae||!f("incident-types-form"),onEdit:f("incident-types-form")?()=>ie(!1):void 0,onSubmit:()=>Fe(D.incidentTypes,Id,()=>Yl(hr()),"incident-types"),onBack:()=>{o("incident-types"),le("idle")},onNavigate:o,onLogout:Ie,user:e});if(c==="idea-types-form")return n.jsx(z0,{form:Ed,setForm:Xl,formStatus:Pe,viewMode:Ae||!f("idea-types-form"),onEdit:f("idea-types-form")?()=>ie(!1):void 0,onSubmit:()=>Fe(D.ideaTypes,Ed,()=>Xl(gr()),"idea-types"),onBack:()=>{o("idea-types"),le("idle")},onNavigate:o,onLogout:Ie,user:e});if(c==="order-types-form")return n.jsx(E0,{form:Pd,setForm:Jl,formStatus:Pe,viewMode:Ae||!f("order-types-form"),onEdit:f("order-types-form")?()=>ie(!1):void 0,onSubmit:()=>Fe(D.orderTypes,Pd,()=>Jl(xr()),"order-types"),onBack:()=>{o("order-types"),le("idle")},onNavigate:o,onLogout:Ie,user:e});if(c==="process-types-form")return n.jsx(R0,{form:Ad,setForm:ql,formStatus:Pe,viewMode:Ae||!f("process-types-form"),onEdit:f("process-types-form")?()=>ie(!1):void 0,onSubmit:()=>Fe(D.processTypes,Ad,()=>ql(mr()),"process-types"),onBack:()=>{o("process-types"),le("idle")},onNavigate:o,onLogout:Ie,user:e});if(c==="incident-statuses-form")return n.jsx(D0,{form:Rd,setForm:Zl,formStatus:Pe,viewMode:Ae||!f("incident-statuses-form"),onEdit:f("incident-statuses-form")?()=>ie(!1):void 0,onSubmit:()=>Fe(D.incidentStatuses,Rd,()=>Zl(yr()),"incident-statuses"),onBack:()=>{o("incident-statuses"),le("idle")},onNavigate:o,onLogout:Ie,user:e});if(c==="idea-statuses-form")return n.jsx(B0,{form:Ld,setForm:Vl,formStatus:Pe,viewMode:Ae||!f("idea-statuses-form"),onEdit:f("idea-statuses-form")?()=>ie(!1):void 0,onSubmit:()=>Fe(D.ideaStatuses,Ld,()=>Vl(vr()),"idea-statuses"),onBack:()=>{o("idea-statuses"),le("idle")},onNavigate:o,onLogout:Ie,user:e});if(c==="order-statuses-form")return n.jsx(F0,{form:Od,setForm:er,formStatus:Pe,viewMode:Ae||!f("order-statuses-form"),onEdit:f("order-statuses-form")?()=>ie(!1):void 0,onSubmit:()=>Fe(D.orderStatuses,Od,()=>er(jr()),"order-statuses"),onBack:()=>{o("order-statuses"),le("idle")},onNavigate:o,onLogout:Ie,user:e});if(c==="process-statuses-form")return n.jsx(K0,{form:Dd,setForm:tr,formStatus:Pe,viewMode:Ae||!f("process-statuses-form"),onEdit:f("process-statuses-form")?()=>ie(!1):void 0,onSubmit:()=>Fe(D.processStatuses,Dd,()=>tr(br()),"process-statuses"),onBack:()=>{o("process-statuses"),le("idle")},onNavigate:o,onLogout:Ie,user:e});if(c==="users-form")return n.jsx(X0,{form:ps,setForm:fs,organizations:w,managements:G,departments:ne,branches:E,formStatus:Pe,viewMode:Ae||!f("users-form"),onEdit:f("users-form")?()=>ie(!1):void 0,isSelfProfile:Sd,onSubmit:Wh,onBack:()=>{o(Sd?a?"dashboard":"inbox":"users"),le("idle")},onNavigate:o,onLogout:Ie,user:e});if(c==="delegations-form")return n.jsx(a1,{form:al,setForm:nr,organizations:w,users:Ql,userRoleMap:Vn,formStatus:Pe,viewMode:Ae||!f("delegations-form"),onEdit:f("delegations-form")?()=>ie(!1):void 0,onSubmit:yh,onBack:()=>{o("delegations"),le("idle")},onNavigate:o,onLogout:Ie,user:e});const Bh=s.pages,$h={incidents:{color:N.accent,formPage:"incidents-form",reset:()=>Ht({...Yt(),organization:m})},ideas:{color:N.teal,formPage:"ideas-form",reset:()=>Kt({...Xt(),organization:m})},orders:{color:N.purple,formPage:"orders-form",reset:()=>Qt({...Jt(),organization:m})},processes:{color:N.blue,formPage:"processes-form",reset:()=>{const _=bd.create_processes,Q=i==="Manager"&&_&&_.length===1?_[0]:m;Dt({...Ns(),organization:Q})}},organizations:{color:N.accent,formPage:"organizations-form",reset:()=>Gl(fr())},managements:{color:N.blue,formPage:"managements-form",reset:()=>nl({...cl(),organization:m})},departments:{color:N.teal,formPage:"departments-form",reset:()=>ll({...ul(),custom_organization:m})},branches:{color:N.purple,formPage:"branches-form",reset:()=>rl({...pl(),organization:m})},cycles:{color:N.teal,formPage:"cycles-form",reset:()=>sl({...fl(),organization:m})},"kpi-input":{color:N.blue,formPage:"kpi-input-form",reset:()=>il({...hl(),organization:m})},"incident-types":{color:N.red,formPage:"incident-types-form",reset:()=>Yl(hr())},"idea-types":{color:N.orange,formPage:"idea-types-form",reset:()=>Xl(gr())},"order-types":{color:N.green,formPage:"order-types-form",reset:()=>Jl(xr())},"process-types":{color:N.accent,formPage:"process-types-form",reset:()=>ql(mr())},"incident-statuses":{color:N.red,formPage:"incident-statuses-form",reset:()=>Zl(yr())},"idea-statuses":{color:N.teal,formPage:"idea-statuses-form",reset:()=>Vl(vr())},"order-statuses":{color:N.purple,formPage:"order-statuses-form",reset:()=>er(jr())},"process-statuses":{color:N.blue,formPage:"process-statuses-form",reset:()=>tr(br())},users:{color:N.blue,formPage:"users-form",reset:()=>{fs(Ws()),wd(!1)}},delegations:{color:N.purple,formPage:"delegations-form",reset:()=>nr(Sr())}},Uh={incidents:s.formTitle.newIncident,ideas:s.formTitle.newIdea,orders:s.formTitle.newOrder,processes:s.formTitle.newProcess,organizations:s.formTitle.newOrg,managements:s.formTitle.newMgmt,departments:s.formTitle.newDept,branches:s.formTitle.newBranch,users:s.formTitle.newUser,cycles:s.formTitle.newCycle,"kpi-input":s.formTitle.newKpi,delegations:s.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"},Fh={incidents:v,ideas:k,orders:U,processes:se,organizations:w,managements:G,departments:ne,branches:E,cycles:os,"kpi-input":yd,"incident-types":W,"idea-types":Z,"order-types":K,"process-types":R,"incident-statuses":Mt,"idea-statuses":Ln,"order-statuses":dn,"process-statuses":Qe,users:Ct,delegations:vd},On=Wm[c],Ki=Fh[c],Y=f(c),Qi=Y?$h[c]:null;return n.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:l?"#0f172a":N.bg},children:[n.jsx(zf,{collapsed:Kf,onToggleCollapsed:Gf,activePage:c,onNavigate:_=>o(_),hasDashboard:a,hasReports:u,hasDelegations:p,role:i,rtl:s.rtl,navLabels:s.nav,settingsLabel:s.nav.settings}),n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[n.jsx("div",{style:{background:l?"#1e293b":"#ffffff",padding:"6px 20px",borderBottom:`1px solid ${l?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"flex-end",alignItems:"center",gap:6,flexShrink:0,boxShadow:l?"none":"0 1px 4px rgba(0,0,0,0.04)"},children:n.jsx(r0,{notifCount:x,darkMode:l,onCountChange:d,onToggleDark:r,onNavigate:Hi,onViewProfile:()=>{const _=Ct.find(Q=>Q.name===e.name||Q.username===e.name);kd(_||{name:e.name,full_name:e.full_name,email:e.name,enabled:1}),o("profile")},onLogout:Ie})}),c!=="profile"&&n.jsxs("div",{style:{background:l?"#1e293b":"white",padding:"9px 20px",borderBottom:`1px solid ${l?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[n.jsx("div",{style:{fontSize:15,fontWeight:700,color:l?"#e2e8f0":"#1e1b4b"},children:Bh[c]||c}),n.jsxs("div",{style:{display:"flex",gap:8},children:[On&&Ki&&n.jsx("button",{onClick:()=>Mi(!0),style:{background:"#16a34a",color:"white",border:"none",padding:"6px 14px",borderRadius:7,fontSize:12,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"}),Qi&&n.jsxs("button",{onClick:()=>{Qi.reset(),ie(!1),le("idle"),o(Qi.formPage)},style:{background:"#4f46e5",color:"white",border:"none",padding:"6px 14px",borderRadius:7,fontSize:12,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI"},children:["+ ",Uh[c]||s.new]})]})]}),On&&Ki&&Yf&&n.jsx(Km,{title:On.label,rows:Ki,columns:On.columns,defaultColumnKeys:On.defaultColumns,orgField:On.orgField,organizations:On.orgField?w:void 0,filenameBase:c,onClose:()=>Mi(!1)}),n.jsxs("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",padding:c==="profile"?0:"20px 24px",gap:c==="profile"?0:16},children:[ve&&n.jsx("div",{style:{textAlign:"center",paddingTop:60,color:"#aaa",fontSize:15},children:s.loading}),!ve&&c==="dashboard"&&a&&n.jsx(Ty,{incidents:v,ideas:k,orders:U,processes:se,organizations:w,incidentStatuses:Mt,ideaStatuses:Ln,orderStatuses:dn,processStatuses:Qe,selectedOrg:m,onOrgChange:j,onNavigate:Hi,onNavigateStatus:y,userRole:i}),!ve&&c==="inbox"&&n.jsx(o1,{onNavigate:Hi,onRefresh:Nt}),!ve&&c==="reports"&&u&&n.jsx(f1,{organizations:w,userRole:i}),!ve&&c==="incidents"&&n.jsx(Ry,{incidents:v,organizations:w,departments:ne,branches:E,incidentStatuses:Mt,initialOrg:m,initialStatus:h,onView:qf,onEdit:Y?ah:void 0,onDelete:Y?_=>Be(D.incidents,_):void 0,canModify:Y}),!ve&&c==="ideas"&&n.jsx(My,{ideas:k,organizations:w,departments:ne,branches:E,ideaStatuses:Ln,initialOrg:m,initialStatus:h,onView:Zf,onEdit:Y?oh:void 0,onDelete:Y?_=>Be(D.ideas,_):void 0,canModify:Y}),!ve&&c==="orders"&&n.jsx(Gy,{orders:U,organizations:w,departments:ne,branches:E,orderStatuses:dn,initialOrg:m,initialStatus:h,onView:Vf,onEdit:Y?dh:void 0,onDelete:Y?_=>Be(D.orders,_):void 0,canModify:Y}),!ve&&c==="processes"&&n.jsx(Zy,{processes:se,organizations:w,departments:ne,branches:E,processStatuses:Qe,initialOrg:m,initialStatus:h,onView:eh,onEdit:Y?ch:void 0,onDelete:Y?_=>Be(D.processes,_):void 0,canModify:Y}),!ve&&c==="organizations"&&n.jsx(d0,{organizations:w,onView:th,onEdit:Y?uh:void 0,onDelete:Y?_=>Be(D.organizations,_):void 0,canModify:Y}),!ve&&c==="managements"&&n.jsx(p0,{managements:G,onView:nh,onEdit:Y?ph:void 0,onDelete:Y?_=>Be(D.managements,_):void 0,canModify:Y}),!ve&&c==="departments"&&n.jsx(g0,{departments:ne,managements:G,onView:lh,onEdit:Y?fh:void 0,onDelete:Y?_=>Be(D.departments,_):void 0,canModify:Y}),!ve&&c==="branches"&&n.jsx(v0,{branches:E,managements:G,departments:ne,onView:rh,onEdit:Y?hh:void 0,onDelete:Y?_=>Be(D.branches,_):void 0,canModify:Y}),!ve&&c==="cycles"&&n.jsx(J0,{cycles:os,canModify:Y,onView:sh,onEdit:Y?gh:void 0,onDelete:Y?_=>Be(D.cycles,_):void 0}),!ve&&c==="kpi-input"&&n.jsx(e1,{kpiInputs:yd,canModify:Y,onView:ih,onEdit:Y?xh:void 0,onDelete:Y?_=>Be(D.kpiInput,_):void 0}),!ve&&c==="incident-types"&&n.jsx(w0,{incidentTypes:W,onView:jh,onEdit:Y?bh:void 0,onDelete:Y?_=>Be(D.incidentTypes,_):void 0,canModify:Y}),!ve&&c==="idea-types"&&n.jsx(C0,{ideaTypes:Z,onView:Sh,onEdit:Y?wh:void 0,onDelete:Y?_=>Be(D.ideaTypes,_):void 0,canModify:Y}),!ve&&c==="order-types"&&n.jsx(I0,{orderTypes:K,onView:kh,onEdit:Y?_h:void 0,onDelete:Y?_=>Be(D.orderTypes,_):void 0,canModify:Y}),!ve&&c==="process-types"&&n.jsx(A0,{processTypes:R,onView:Ch,onEdit:Y?zh:void 0,onDelete:Y?_=>Be(D.processTypes,_):void 0,canModify:Y}),!ve&&c==="incident-statuses"&&n.jsx(O0,{incidentStatuses:Mt,onView:Th,onEdit:Y?Ih:void 0,onDelete:Y?_=>Be(D.incidentStatuses,_):void 0,canModify:Y}),!ve&&c==="idea-statuses"&&n.jsx(W0,{ideaStatuses:Ln,onView:Eh,onEdit:Y?Ph:void 0,onDelete:Y?_=>Be(D.ideaStatuses,_):void 0,canModify:Y}),!ve&&c==="order-statuses"&&n.jsx(U0,{orderStatuses:dn,onView:Ah,onEdit:Y?Rh:void 0,onDelete:Y?_=>Be(D.orderStatuses,_):void 0,canModify:Y}),!ve&&c==="process-statuses"&&n.jsx(H0,{processStatuses:Qe,onView:Lh,onEdit:Y?Oh:void 0,onDelete:Y?_=>Be(D.processStatuses,_):void 0,canModify:Y}),!ve&&c==="users"&&n.jsx(Y0,{users:Ct,roleMap:Vn,onView:Dh,onEdit:Y?Nh:void 0,onDelete:Y?_=>Be("User",_):void 0,onDisable:Y?Jf:void 0,canModify:Y}),!ve&&c==="delegations"&&p&&n.jsx(s1,{delegations:vd,organizations:w,userRole:i,currentUser:e.name,onView:mh,onRevoke:Y?vh:void 0}),c==="profile"&&(()=>{const _=!!ds&&(ds.name===e.name||ds.email===e.name);return n.jsx(i0,{user:e,profileUser:ds,sbUsers:Ct,organizations:w,managements:G,departments:ne,branches:E,darkMode:l,canModify:Y||_,onBack:()=>o(_?a?"dashboard":"inbox":"users"),onNavigate:o})})()]})]})]})}function j1(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 b1(){const[e,t]=S.useState(()=>{try{const u=localStorage.getItem("sidrah_user");return u?JSON.parse(u):null}catch{return null}}),[l,r]=S.useState(()=>localStorage.getItem("sb_dark")==="1"),s=()=>{const u=!l;r(u),localStorage.setItem("sb_dark",u?"1":"0"),document.documentElement.classList.toggle("dark",u)};S.useEffect(()=>{document.documentElement.classList.toggle("dark",l)},[]),S.useEffect(()=>{e&&Pf().then(async u=>{const p=u||e.name,f=await Rf(p);if(!f.length)return;const g=j1(f);if(g!==e.role||p!==e.name){const o={...e,name:p,role:g};t(o),localStorage.setItem("sidrah_user",JSON.stringify(o))}})},[e==null?void 0:e.name]);const i=u=>{t(u),localStorage.setItem("sidrah_user",JSON.stringify(u))},a=()=>{t(null),localStorage.removeItem("sidrah_user")};return e?n.jsx(v1,{user:e,onLogout:a,darkMode:l,onToggleDark:s}):n.jsx(Sy,{onLogin:i})}_f(document.getElementById("root")).render(n.jsx(S.StrictMode,{children:n.jsx(b1,{})}));