52 lines
476 KiB
JavaScript
52 lines
476 KiB
JavaScript
(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 du={exports:{}},ji={},uu={exports:{}},le={};/**
|
||
* @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 Zr=Symbol.for("react.element"),sg=Symbol.for("react.portal"),ig=Symbol.for("react.fragment"),ag=Symbol.for("react.strict_mode"),og=Symbol.for("react.profiler"),cg=Symbol.for("react.provider"),dg=Symbol.for("react.context"),ug=Symbol.for("react.forward_ref"),pg=Symbol.for("react.suspense"),fg=Symbol.for("react.memo"),hg=Symbol.for("react.lazy"),Nc=Symbol.iterator;function gg(e){return e===null||typeof e!="object"?null:(e=Nc&&e[Nc]||e["@@iterator"],typeof e=="function"?e:null)}var pu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},fu=Object.assign,hu={};function Bl(e,t,l){this.props=e,this.context=t,this.refs=hu,this.updater=l||pu}Bl.prototype.isReactComponent={};Bl.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")};Bl.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function gu(){}gu.prototype=Bl.prototype;function jo(e,t,l){this.props=e,this.context=t,this.refs=hu,this.updater=l||pu}var bo=jo.prototype=new gu;bo.constructor=jo;fu(bo,Bl.prototype);bo.isPureReactComponent=!0;var Wc=Array.isArray,xu=Object.prototype.hasOwnProperty,So={current:null},mu={key:!0,ref:!0,__self:!0,__source:!0};function yu(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)xu.call(t,r)&&!mu.hasOwnProperty(r)&&(s[r]=t[r]);var d=arguments.length-2;if(d===1)s.children=l;else if(1<d){for(var p=Array(d),f=0;f<d;f++)p[f]=arguments[f+2];s.children=p}if(e&&e.defaultProps)for(r in d=e.defaultProps,d)s[r]===void 0&&(s[r]=d[r]);return{$$typeof:Zr,type:e,key:i,ref:a,props:s,_owner:So.current}}function xg(e,t){return{$$typeof:Zr,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function wo(e){return typeof e=="object"&&e!==null&&e.$$typeof===Zr}function mg(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(l){return t[l]})}var Bc=/\/+/g;function Qi(e,t){return typeof e=="object"&&e!==null&&e.key!=null?mg(""+e.key):t.toString(36)}function Ns(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 Zr:case sg:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+Qi(a,0):r,Wc(s)?(l="",e!=null&&(l=e.replace(Bc,"$&/")+"/"),Ns(s,t,l,"",function(f){return f})):s!=null&&(wo(s)&&(s=xg(s,l+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(Bc,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",Wc(e))for(var d=0;d<e.length;d++){i=e[d];var p=r+Qi(i,d);a+=Ns(i,t,l,p,s)}else if(p=gg(e),typeof p=="function")for(e=p.call(e),d=0;!(i=e.next()).done;)i=i.value,p=r+Qi(i,d++),a+=Ns(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 ps(e,t,l){if(e==null)return e;var r=[],s=0;return Ns(e,r,"","",function(i){return t.call(l,i,s++)}),r}function yg(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 nt={current:null},Ws={transition:null},vg={ReactCurrentDispatcher:nt,ReactCurrentBatchConfig:Ws,ReactCurrentOwner:So};function vu(){throw Error("act(...) is not supported in production builds of React.")}le.Children={map:ps,forEach:function(e,t,l){ps(e,function(){t.apply(this,arguments)},l)},count:function(e){var t=0;return ps(e,function(){t++}),t},toArray:function(e){return ps(e,function(t){return t})||[]},only:function(e){if(!wo(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};le.Component=Bl;le.Fragment=ig;le.Profiler=og;le.PureComponent=jo;le.StrictMode=ag;le.Suspense=pg;le.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=vg;le.act=vu;le.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=fu({},e.props),s=e.key,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=So.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var d=e.type.defaultProps;for(p in t)xu.call(t,p)&&!mu.hasOwnProperty(p)&&(r[p]=t[p]===void 0&&d!==void 0?d[p]:t[p])}var p=arguments.length-2;if(p===1)r.children=l;else if(1<p){d=Array(p);for(var f=0;f<p;f++)d[f]=arguments[f+2];r.children=d}return{$$typeof:Zr,type:e.type,key:s,ref:i,props:r,_owner:a}};le.createContext=function(e){return e={$$typeof:dg,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:cg,_context:e},e.Consumer=e};le.createElement=yu;le.createFactory=function(e){var t=yu.bind(null,e);return t.type=e,t};le.createRef=function(){return{current:null}};le.forwardRef=function(e){return{$$typeof:ug,render:e}};le.isValidElement=wo;le.lazy=function(e){return{$$typeof:hg,_payload:{_status:-1,_result:e},_init:yg}};le.memo=function(e,t){return{$$typeof:fg,type:e,compare:t===void 0?null:t}};le.startTransition=function(e){var t=Ws.transition;Ws.transition={};try{e()}finally{Ws.transition=t}};le.unstable_act=vu;le.useCallback=function(e,t){return nt.current.useCallback(e,t)};le.useContext=function(e){return nt.current.useContext(e)};le.useDebugValue=function(){};le.useDeferredValue=function(e){return nt.current.useDeferredValue(e)};le.useEffect=function(e,t){return nt.current.useEffect(e,t)};le.useId=function(){return nt.current.useId()};le.useImperativeHandle=function(e,t,l){return nt.current.useImperativeHandle(e,t,l)};le.useInsertionEffect=function(e,t){return nt.current.useInsertionEffect(e,t)};le.useLayoutEffect=function(e,t){return nt.current.useLayoutEffect(e,t)};le.useMemo=function(e,t){return nt.current.useMemo(e,t)};le.useReducer=function(e,t,l){return nt.current.useReducer(e,t,l)};le.useRef=function(e){return nt.current.useRef(e)};le.useState=function(e){return nt.current.useState(e)};le.useSyncExternalStore=function(e,t,l){return nt.current.useSyncExternalStore(e,t,l)};le.useTransition=function(){return nt.current.useTransition()};le.version="18.3.1";uu.exports=le;var S=uu.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 jg=S,bg=Symbol.for("react.element"),Sg=Symbol.for("react.fragment"),wg=Object.prototype.hasOwnProperty,kg=jg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,_g={key:!0,ref:!0,__self:!0,__source:!0};function ju(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)wg.call(t,r)&&!_g.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:bg,type:e,key:i,ref:a,props:s,_owner:kg.current}}ji.Fragment=Sg;ji.jsx=ju;ji.jsxs=ju;du.exports=ji;var n=du.exports,bu={exports:{}},mt={},Su={exports:{}},wu={};/**
|
||
* @license React
|
||
* scheduler.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/(function(e){function t(A,B){var H=A.length;A.push(B);e:for(;0<H;){var V=H-1>>>1,F=A[V];if(0<s(F,B))A[V]=B,A[H]=F,H=V;else break e}}function l(A){return A.length===0?null:A[0]}function r(A){if(A.length===0)return null;var B=A[0],H=A.pop();if(H!==B){A[0]=H;e:for(var V=0,F=A.length,je=F>>>1;V<je;){var R=2*(V+1)-1,q=A[R],$e=R+1,De=A[$e];if(0>s(q,H))$e<F&&0>s(De,q)?(A[V]=De,A[$e]=H,V=$e):(A[V]=q,A[R]=H,V=R);else if($e<F&&0>s(De,H))A[V]=De,A[$e]=H,V=$e;else break e}}return B}function s(A,B){var H=A.sortIndex-B.sortIndex;return H!==0?H:A.id-B.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var a=Date,d=a.now();e.unstable_now=function(){return a.now()-d}}var p=[],f=[],h=1,c=null,u=3,x=!1,v=!1,m=!1,z=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,o=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function g(A){for(var B=l(f);B!==null;){if(B.callback===null)r(f);else if(B.startTime<=A)r(f),B.sortIndex=B.expirationTime,t(p,B);else break;B=l(f)}}function j(A){if(m=!1,g(A),!v)if(l(p)!==null)v=!0,xe(b);else{var B=l(f);B!==null&&se(j,B.startTime-A)}}function b(A,B){v=!1,m&&(m=!1,y(C),C=-1),x=!0;var H=u;try{for(g(B),c=l(p);c!==null&&(!(c.expirationTime>B)||A&&!Q());){var V=c.callback;if(typeof V=="function"){c.callback=null,u=c.priorityLevel;var F=V(c.expirationTime<=B);B=e.unstable_now(),typeof F=="function"?c.callback=F:c===l(p)&&r(p),g(B)}else r(p);c=l(p)}if(c!==null)var je=!0;else{var R=l(f);R!==null&&se(j,R.startTime-B),je=!1}return je}finally{c=null,u=H,x=!1}}var w=!1,k=null,C=-1,O=5,U=-1;function Q(){return!(e.unstable_now()-U<O)}function X(){if(k!==null){var A=e.unstable_now();U=A;var B=!0;try{B=k(!0,A)}finally{B?$():(w=!1,k=null)}}else w=!1}var $;if(typeof o=="function")$=function(){o(X)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,Z=ee.port2;ee.port1.onmessage=X,$=function(){Z.postMessage(null)}}else $=function(){z(X,0)};function xe(A){k=A,w||(w=!0,$())}function se(A,B){C=z(function(){A(e.unstable_now())},B)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(A){A.callback=null},e.unstable_continueExecution=function(){v||x||(v=!0,xe(b))},e.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return u},e.unstable_getFirstCallbackNode=function(){return l(p)},e.unstable_next=function(A){switch(u){case 1:case 2:case 3:var B=3;break;default:B=u}var H=u;u=B;try{return A()}finally{u=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(A,B){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var H=u;u=A;try{return B()}finally{u=H}},e.unstable_scheduleCallback=function(A,B,H){var V=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?V+H:V):H=V,A){case 1:var F=-1;break;case 2:F=250;break;case 5:F=1073741823;break;case 4:F=1e4;break;default:F=5e3}return F=H+F,A={id:h++,callback:B,priorityLevel:A,startTime:H,expirationTime:F,sortIndex:-1},H>V?(A.sortIndex=H,t(f,A),l(p)===null&&A===l(f)&&(m?(y(C),C=-1):m=!0,se(j,H-V))):(A.sortIndex=F,t(p,A),v||x||(v=!0,xe(b))),A},e.unstable_shouldYield=Q,e.unstable_wrapCallback=function(A){var B=u;return function(){var H=u;u=B;try{return A.apply(this,arguments)}finally{u=H}}}})(wu);Su.exports=wu;var Cg=Su.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 zg=S,xt=Cg;function W(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 ku=new Set,Or={};function Yn(e,t){Pl(e,t),Pl(e+"Capture",t)}function Pl(e,t){for(Or[e]=t,e=0;e<t.length;e++)ku.add(t[e])}var tn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_a=Object.prototype.hasOwnProperty,Tg=/^[: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]*$/,$c={},Uc={};function Ig(e){return _a.call(Uc,e)?!0:_a.call($c,e)?!1:Tg.test(e)?Uc[e]=!0:($c[e]=!0,!1)}function Pg(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 Eg(e,t,l,r){if(t===null||typeof t>"u"||Pg(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 lt(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 Ge={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ge[e]=new lt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Ge[t]=new lt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ge[e]=new lt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ge[e]=new lt(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){Ge[e]=new lt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ge[e]=new lt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ge[e]=new lt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ge[e]=new lt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ge[e]=new lt(e,5,!1,e.toLowerCase(),null,!1,!1)});var ko=/[\-:]([a-z])/g;function _o(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(ko,_o);Ge[t]=new lt(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(ko,_o);Ge[t]=new lt(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(ko,_o);Ge[t]=new lt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ge[e]=new lt(e,1,!1,e.toLowerCase(),null,!1,!1)});Ge.xlinkHref=new lt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ge[e]=new lt(e,1,!1,e.toLowerCase(),null,!0,!0)});function Co(e,t,l,r){var s=Ge.hasOwnProperty(t)?Ge[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(Eg(t,l,s,r)&&(l=null),r||s===null?Ig(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 sn=zg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,fs=Symbol.for("react.element"),ul=Symbol.for("react.portal"),pl=Symbol.for("react.fragment"),zo=Symbol.for("react.strict_mode"),Ca=Symbol.for("react.profiler"),_u=Symbol.for("react.provider"),Cu=Symbol.for("react.context"),To=Symbol.for("react.forward_ref"),za=Symbol.for("react.suspense"),Ta=Symbol.for("react.suspense_list"),Io=Symbol.for("react.memo"),pn=Symbol.for("react.lazy"),zu=Symbol.for("react.offscreen"),Fc=Symbol.iterator;function tr(e){return e===null||typeof e!="object"?null:(e=Fc&&e[Fc]||e["@@iterator"],typeof e=="function"?e:null)}var we=Object.assign,Gi;function br(e){if(Gi===void 0)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);Gi=t&&t[1]||""}return`
|
||
`+Gi+e}var Yi=!1;function Xi(e,t){if(!e||Yi)return"";Yi=!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,d=i.length-1;1<=a&&0<=d&&s[a]!==i[d];)d--;for(;1<=a&&0<=d;a--,d--)if(s[a]!==i[d]){if(a!==1||d!==1)do if(a--,d--,0>d||s[a]!==i[d]){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<=d);break}}}finally{Yi=!1,Error.prepareStackTrace=l}return(e=e?e.displayName||e.name:"")?br(e):""}function Ag(e){switch(e.tag){case 5:return br(e.type);case 16:return br("Lazy");case 13:return br("Suspense");case 19:return br("SuspenseList");case 0:case 2:case 15:return e=Xi(e.type,!1),e;case 11:return e=Xi(e.type.render,!1),e;case 1:return e=Xi(e.type,!0),e;default:return""}}function Ia(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 pl:return"Fragment";case ul:return"Portal";case Ca:return"Profiler";case zo:return"StrictMode";case za:return"Suspense";case Ta:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Cu:return(e.displayName||"Context")+".Consumer";case _u:return(e._context.displayName||"Context")+".Provider";case To:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Io:return t=e.displayName||null,t!==null?t:Ia(e.type)||"Memo";case pn:t=e._payload,e=e._init;try{return Ia(e(t))}catch{}}return null}function Rg(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 Ia(t);case 8:return t===zo?"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 zn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Tu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Lg(e){var t=Tu(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 hs(e){e._valueTracker||(e._valueTracker=Lg(e))}function Iu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var l=t.getValue(),r="";return e&&(r=Tu(e)?e.checked?"true":"false":e.value),e=r,e!==l?(t.setValue(e),!0):!1}function Xs(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 Pa(e,t){var l=t.checked;return we({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??e._wrapperState.initialChecked})}function Mc(e,t){var l=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;l=zn(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 Pu(e,t){t=t.checked,t!=null&&Co(e,"checked",t,!1)}function Ea(e,t){Pu(e,t);var l=zn(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")?Aa(e,t.type,l):t.hasOwnProperty("defaultValue")&&Aa(e,t.type,zn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Hc(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 Aa(e,t,l){(t!=="number"||Xs(e.ownerDocument)!==e)&&(l==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+l&&(e.defaultValue=""+l))}var Sr=Array.isArray;function kl(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=""+zn(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 Ra(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(W(91));return we({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Kc(e,t){var l=t.value;if(l==null){if(l=t.children,t=t.defaultValue,l!=null){if(t!=null)throw Error(W(92));if(Sr(l)){if(1<l.length)throw Error(W(93));l=l[0]}t=l}t==null&&(t=""),l=t}e._wrapperState={initialValue:zn(l)}}function Eu(e,t){var l=zn(t.value),r=zn(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 Qc(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Au(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 La(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Au(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var gs,Ru=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(gs=gs||document.createElement("div"),gs.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=gs.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Dr(e,t){if(t){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=t;return}}e.textContent=t}var Cr={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},Og=["Webkit","ms","Moz","O"];Object.keys(Cr).forEach(function(e){Og.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Cr[t]=Cr[e]})});function Lu(e,t,l){return t==null||typeof t=="boolean"||t===""?"":l||typeof t!="number"||t===0||Cr.hasOwnProperty(e)&&Cr[e]?(""+t).trim():t+"px"}function Ou(e,t){e=e.style;for(var l in t)if(t.hasOwnProperty(l)){var r=l.indexOf("--")===0,s=Lu(l,t[l],r);l==="float"&&(l="cssFloat"),r?e.setProperty(l,s):e[l]=s}}var Dg=we({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 Oa(e,t){if(t){if(Dg[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(W(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(W(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(W(61))}if(t.style!=null&&typeof t.style!="object")throw Error(W(62))}}function Da(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 Na=null;function Po(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Wa=null,_l=null,Cl=null;function Gc(e){if(e=ts(e)){if(typeof Wa!="function")throw Error(W(280));var t=e.stateNode;t&&(t=_i(t),Wa(e.stateNode,e.type,t))}}function Du(e){_l?Cl?Cl.push(e):Cl=[e]:_l=e}function Nu(){if(_l){var e=_l,t=Cl;if(Cl=_l=null,Gc(e),t)for(e=0;e<t.length;e++)Gc(t[e])}}function Wu(e,t){return e(t)}function Bu(){}var Ji=!1;function $u(e,t,l){if(Ji)return e(t,l);Ji=!0;try{return Wu(e,t,l)}finally{Ji=!1,(_l!==null||Cl!==null)&&(Bu(),Nu())}}function Nr(e,t){var l=e.stateNode;if(l===null)return null;var r=_i(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(W(231,t,typeof l));return l}var Ba=!1;if(tn)try{var nr={};Object.defineProperty(nr,"passive",{get:function(){Ba=!0}}),window.addEventListener("test",nr,nr),window.removeEventListener("test",nr,nr)}catch{Ba=!1}function Ng(e,t,l,r,s,i,a,d,p){var f=Array.prototype.slice.call(arguments,3);try{t.apply(l,f)}catch(h){this.onError(h)}}var zr=!1,Js=null,qs=!1,$a=null,Wg={onError:function(e){zr=!0,Js=e}};function Bg(e,t,l,r,s,i,a,d,p){zr=!1,Js=null,Ng.apply(Wg,arguments)}function $g(e,t,l,r,s,i,a,d,p){if(Bg.apply(this,arguments),zr){if(zr){var f=Js;zr=!1,Js=null}else throw Error(W(198));qs||(qs=!0,$a=f)}}function Xn(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 Uu(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 Yc(e){if(Xn(e)!==e)throw Error(W(188))}function Ug(e){var t=e.alternate;if(!t){if(t=Xn(e),t===null)throw Error(W(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 Yc(s),e;if(i===r)return Yc(s),t;i=i.sibling}throw Error(W(188))}if(l.return!==r.return)l=s,r=i;else{for(var a=!1,d=s.child;d;){if(d===l){a=!0,l=s,r=i;break}if(d===r){a=!0,r=s,l=i;break}d=d.sibling}if(!a){for(d=i.child;d;){if(d===l){a=!0,l=i,r=s;break}if(d===r){a=!0,r=i,l=s;break}d=d.sibling}if(!a)throw Error(W(189))}}if(l.alternate!==r)throw Error(W(190))}if(l.tag!==3)throw Error(W(188));return l.stateNode.current===l?e:t}function Fu(e){return e=Ug(e),e!==null?Mu(e):null}function Mu(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Mu(e);if(t!==null)return t;e=e.sibling}return null}var Hu=xt.unstable_scheduleCallback,Xc=xt.unstable_cancelCallback,Fg=xt.unstable_shouldYield,Mg=xt.unstable_requestPaint,ze=xt.unstable_now,Hg=xt.unstable_getCurrentPriorityLevel,Eo=xt.unstable_ImmediatePriority,Ku=xt.unstable_UserBlockingPriority,Zs=xt.unstable_NormalPriority,Kg=xt.unstable_LowPriority,Qu=xt.unstable_IdlePriority,bi=null,Ut=null;function Qg(e){if(Ut&&typeof Ut.onCommitFiberRoot=="function")try{Ut.onCommitFiberRoot(bi,e,void 0,(e.current.flags&128)===128)}catch{}}var Rt=Math.clz32?Math.clz32:Xg,Gg=Math.log,Yg=Math.LN2;function Xg(e){return e>>>=0,e===0?32:31-(Gg(e)/Yg|0)|0}var xs=64,ms=4194304;function wr(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 Vs(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 d=a&~s;d!==0?r=wr(d):(i&=a,i!==0&&(r=wr(i)))}else a=l&~s,a!==0?r=wr(a):i!==0&&(r=wr(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 Jg(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 qg(e,t){for(var l=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,i=e.pendingLanes;0<i;){var a=31-Rt(i),d=1<<a,p=s[a];p===-1?(!(d&l)||d&r)&&(s[a]=Jg(d,t)):p<=t&&(e.expiredLanes|=d),i&=~d}}function Ua(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Gu(){var e=xs;return xs<<=1,!(xs&4194240)&&(xs=64),e}function qi(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function Vr(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 Zg(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 Ao(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 de=0;function Yu(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Xu,Ro,Ju,qu,Zu,Fa=!1,ys=[],vn=null,jn=null,bn=null,Wr=new Map,Br=new Map,hn=[],Vg="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 Jc(e,t){switch(e){case"focusin":case"focusout":vn=null;break;case"dragenter":case"dragleave":jn=null;break;case"mouseover":case"mouseout":bn=null;break;case"pointerover":case"pointerout":Wr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Br.delete(t.pointerId)}}function lr(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=ts(t),t!==null&&Ro(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function ex(e,t,l,r,s){switch(t){case"focusin":return vn=lr(vn,e,t,l,r,s),!0;case"dragenter":return jn=lr(jn,e,t,l,r,s),!0;case"mouseover":return bn=lr(bn,e,t,l,r,s),!0;case"pointerover":var i=s.pointerId;return Wr.set(i,lr(Wr.get(i)||null,e,t,l,r,s)),!0;case"gotpointercapture":return i=s.pointerId,Br.set(i,lr(Br.get(i)||null,e,t,l,r,s)),!0}return!1}function Vu(e){var t=Nn(e.target);if(t!==null){var l=Xn(t);if(l!==null){if(t=l.tag,t===13){if(t=Uu(l),t!==null){e.blockedOn=t,Zu(e.priority,function(){Ju(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 Bs(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var l=Ma(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(l===null){l=e.nativeEvent;var r=new l.constructor(l.type,l);Na=r,l.target.dispatchEvent(r),Na=null}else return t=ts(l),t!==null&&Ro(t),e.blockedOn=l,!1;t.shift()}return!0}function qc(e,t,l){Bs(e)&&l.delete(t)}function tx(){Fa=!1,vn!==null&&Bs(vn)&&(vn=null),jn!==null&&Bs(jn)&&(jn=null),bn!==null&&Bs(bn)&&(bn=null),Wr.forEach(qc),Br.forEach(qc)}function rr(e,t){e.blockedOn===t&&(e.blockedOn=null,Fa||(Fa=!0,xt.unstable_scheduleCallback(xt.unstable_NormalPriority,tx)))}function $r(e){function t(s){return rr(s,e)}if(0<ys.length){rr(ys[0],e);for(var l=1;l<ys.length;l++){var r=ys[l];r.blockedOn===e&&(r.blockedOn=null)}}for(vn!==null&&rr(vn,e),jn!==null&&rr(jn,e),bn!==null&&rr(bn,e),Wr.forEach(t),Br.forEach(t),l=0;l<hn.length;l++)r=hn[l],r.blockedOn===e&&(r.blockedOn=null);for(;0<hn.length&&(l=hn[0],l.blockedOn===null);)Vu(l),l.blockedOn===null&&hn.shift()}var zl=sn.ReactCurrentBatchConfig,ei=!0;function nx(e,t,l,r){var s=de,i=zl.transition;zl.transition=null;try{de=1,Lo(e,t,l,r)}finally{de=s,zl.transition=i}}function lx(e,t,l,r){var s=de,i=zl.transition;zl.transition=null;try{de=4,Lo(e,t,l,r)}finally{de=s,zl.transition=i}}function Lo(e,t,l,r){if(ei){var s=Ma(e,t,l,r);if(s===null)aa(e,t,r,ti,l),Jc(e,r);else if(ex(s,e,t,l,r))r.stopPropagation();else if(Jc(e,r),t&4&&-1<Vg.indexOf(e)){for(;s!==null;){var i=ts(s);if(i!==null&&Xu(i),i=Ma(e,t,l,r),i===null&&aa(e,t,r,ti,l),i===s)break;s=i}s!==null&&r.stopPropagation()}else aa(e,t,r,null,l)}}var ti=null;function Ma(e,t,l,r){if(ti=null,e=Po(r),e=Nn(e),e!==null)if(t=Xn(e),t===null)e=null;else if(l=t.tag,l===13){if(e=Uu(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 ti=e,null}function ep(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(Hg()){case Eo:return 1;case Ku:return 4;case Zs:case Kg:return 16;case Qu:return 536870912;default:return 16}default:return 16}}var xn=null,Oo=null,$s=null;function tp(){if($s)return $s;var e,t=Oo,l=t.length,r,s="value"in xn?xn.value:xn.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 $s=s.slice(e,1<r?1-r:void 0)}function Us(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 vs(){return!0}function Zc(){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 d in e)e.hasOwnProperty(d)&&(l=e[d],this[d]=l?l(i):i[d]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?vs:Zc,this.isPropagationStopped=Zc,this}return we(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=vs)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=vs)},persist:function(){},isPersistent:vs}),t}var $l={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Do=yt($l),es=we({},$l,{view:0,detail:0}),rx=yt(es),Zi,Vi,sr,Si=we({},es,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:No,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!==sr&&(sr&&e.type==="mousemove"?(Zi=e.screenX-sr.screenX,Vi=e.screenY-sr.screenY):Vi=Zi=0,sr=e),Zi)},movementY:function(e){return"movementY"in e?e.movementY:Vi}}),Vc=yt(Si),sx=we({},Si,{dataTransfer:0}),ix=yt(sx),ax=we({},es,{relatedTarget:0}),ea=yt(ax),ox=we({},$l,{animationName:0,elapsedTime:0,pseudoElement:0}),cx=yt(ox),dx=we({},$l,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),ux=yt(dx),px=we({},$l,{data:0}),ed=yt(px),fx={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},hx={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"},gx={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function xx(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=gx[e])?!!t[e]:!1}function No(){return xx}var mx=we({},es,{key:function(e){if(e.key){var t=fx[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Us(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?hx[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:No,charCode:function(e){return e.type==="keypress"?Us(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Us(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),yx=yt(mx),vx=we({},Si,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),td=yt(vx),jx=we({},es,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:No}),bx=yt(jx),Sx=we({},$l,{propertyName:0,elapsedTime:0,pseudoElement:0}),wx=yt(Sx),kx=we({},Si,{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}),_x=yt(kx),Cx=[9,13,27,32],Wo=tn&&"CompositionEvent"in window,Tr=null;tn&&"documentMode"in document&&(Tr=document.documentMode);var zx=tn&&"TextEvent"in window&&!Tr,np=tn&&(!Wo||Tr&&8<Tr&&11>=Tr),nd=" ",ld=!1;function lp(e,t){switch(e){case"keyup":return Cx.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function rp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var fl=!1;function Tx(e,t){switch(e){case"compositionend":return rp(t);case"keypress":return t.which!==32?null:(ld=!0,nd);case"textInput":return e=t.data,e===nd&&ld?null:e;default:return null}}function Ix(e,t){if(fl)return e==="compositionend"||!Wo&&lp(e,t)?(e=tp(),$s=Oo=xn=null,fl=!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 np&&t.locale!=="ko"?null:t.data;default:return null}}var Px={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 rd(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Px[e.type]:t==="textarea"}function sp(e,t,l,r){Du(r),t=ni(t,"onChange"),0<t.length&&(l=new Do("onChange","change",null,l,r),e.push({event:l,listeners:t}))}var Ir=null,Ur=null;function Ex(e){xp(e,0)}function wi(e){var t=xl(e);if(Iu(t))return e}function Ax(e,t){if(e==="change")return t}var ip=!1;if(tn){var ta;if(tn){var na="oninput"in document;if(!na){var sd=document.createElement("div");sd.setAttribute("oninput","return;"),na=typeof sd.oninput=="function"}ta=na}else ta=!1;ip=ta&&(!document.documentMode||9<document.documentMode)}function id(){Ir&&(Ir.detachEvent("onpropertychange",ap),Ur=Ir=null)}function ap(e){if(e.propertyName==="value"&&wi(Ur)){var t=[];sp(t,Ur,e,Po(e)),$u(Ex,t)}}function Rx(e,t,l){e==="focusin"?(id(),Ir=t,Ur=l,Ir.attachEvent("onpropertychange",ap)):e==="focusout"&&id()}function Lx(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return wi(Ur)}function Ox(e,t){if(e==="click")return wi(t)}function Dx(e,t){if(e==="input"||e==="change")return wi(t)}function Nx(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Ot=typeof Object.is=="function"?Object.is:Nx;function Fr(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(!_a.call(t,s)||!Ot(e[s],t[s]))return!1}return!0}function ad(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function od(e,t){var l=ad(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=ad(l)}}function op(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?op(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function cp(){for(var e=window,t=Xs();t instanceof e.HTMLIFrameElement;){try{var l=typeof t.contentWindow.location.href=="string"}catch{l=!1}if(l)e=t.contentWindow;else break;t=Xs(e.document)}return t}function Bo(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 Wx(e){var t=cp(),l=e.focusedElem,r=e.selectionRange;if(t!==l&&l&&l.ownerDocument&&op(l.ownerDocument.documentElement,l)){if(r!==null&&Bo(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=od(l,i);var a=od(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 Bx=tn&&"documentMode"in document&&11>=document.documentMode,hl=null,Ha=null,Pr=null,Ka=!1;function cd(e,t,l){var r=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Ka||hl==null||hl!==Xs(r)||(r=hl,"selectionStart"in r&&Bo(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}),Pr&&Fr(Pr,r)||(Pr=r,r=ni(Ha,"onSelect"),0<r.length&&(t=new Do("onSelect","select",null,t,l),e.push({event:t,listeners:r}),t.target=hl)))}function js(e,t){var l={};return l[e.toLowerCase()]=t.toLowerCase(),l["Webkit"+e]="webkit"+t,l["Moz"+e]="moz"+t,l}var gl={animationend:js("Animation","AnimationEnd"),animationiteration:js("Animation","AnimationIteration"),animationstart:js("Animation","AnimationStart"),transitionend:js("Transition","TransitionEnd")},la={},dp={};tn&&(dp=document.createElement("div").style,"AnimationEvent"in window||(delete gl.animationend.animation,delete gl.animationiteration.animation,delete gl.animationstart.animation),"TransitionEvent"in window||delete gl.transitionend.transition);function ki(e){if(la[e])return la[e];if(!gl[e])return e;var t=gl[e],l;for(l in t)if(t.hasOwnProperty(l)&&l in dp)return la[e]=t[l];return e}var up=ki("animationend"),pp=ki("animationiteration"),fp=ki("animationstart"),hp=ki("transitionend"),gp=new Map,dd="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){gp.set(e,t),Yn(t,[e])}for(var ra=0;ra<dd.length;ra++){var sa=dd[ra],$x=sa.toLowerCase(),Ux=sa[0].toUpperCase()+sa.slice(1);Pn($x,"on"+Ux)}Pn(up,"onAnimationEnd");Pn(pp,"onAnimationIteration");Pn(fp,"onAnimationStart");Pn("dblclick","onDoubleClick");Pn("focusin","onFocus");Pn("focusout","onBlur");Pn(hp,"onTransitionEnd");Pl("onMouseEnter",["mouseout","mouseover"]);Pl("onMouseLeave",["mouseout","mouseover"]);Pl("onPointerEnter",["pointerout","pointerover"]);Pl("onPointerLeave",["pointerout","pointerover"]);Yn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Yn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Yn("onBeforeInput",["compositionend","keypress","textInput","paste"]);Yn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Yn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Yn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var kr="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(" "),Fx=new Set("cancel close invalid load scroll toggle".split(" ").concat(kr));function ud(e,t,l){var r=e.type||"unknown-event";e.currentTarget=l,$g(r,t,void 0,e),e.currentTarget=null}function xp(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 d=r[a],p=d.instance,f=d.currentTarget;if(d=d.listener,p!==i&&s.isPropagationStopped())break e;ud(s,d,f),i=p}else for(a=0;a<r.length;a++){if(d=r[a],p=d.instance,f=d.currentTarget,d=d.listener,p!==i&&s.isPropagationStopped())break e;ud(s,d,f),i=p}}}if(qs)throw e=$a,qs=!1,$a=null,e}function he(e,t){var l=t[Ja];l===void 0&&(l=t[Ja]=new Set);var r=e+"__bubble";l.has(r)||(mp(t,e,2,!1),l.add(r))}function ia(e,t,l){var r=0;t&&(r|=4),mp(l,e,r,t)}var bs="_reactListening"+Math.random().toString(36).slice(2);function Mr(e){if(!e[bs]){e[bs]=!0,ku.forEach(function(l){l!=="selectionchange"&&(Fx.has(l)||ia(l,!1,e),ia(l,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[bs]||(t[bs]=!0,ia("selectionchange",!1,t))}}function mp(e,t,l,r){switch(ep(t)){case 1:var s=nx;break;case 4:s=lx;break;default:s=Lo}l=s.bind(null,t,l,e),s=void 0,!Ba||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 aa(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 d=r.stateNode.containerInfo;if(d===s||d.nodeType===8&&d.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(;d!==null;){if(a=Nn(d),a===null)return;if(p=a.tag,p===5||p===6){r=i=a;continue e}d=d.parentNode}}r=r.return}$u(function(){var f=i,h=Po(l),c=[];e:{var u=gp.get(e);if(u!==void 0){var x=Do,v=e;switch(e){case"keypress":if(Us(l)===0)break e;case"keydown":case"keyup":x=yx;break;case"focusin":v="focus",x=ea;break;case"focusout":v="blur",x=ea;break;case"beforeblur":case"afterblur":x=ea;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":x=Vc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":x=ix;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":x=bx;break;case up:case pp:case fp:x=cx;break;case hp:x=wx;break;case"scroll":x=rx;break;case"wheel":x=_x;break;case"copy":case"cut":case"paste":x=ux;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":x=td}var m=(t&4)!==0,z=!m&&e==="scroll",y=m?u!==null?u+"Capture":null:u;m=[];for(var o=f,g;o!==null;){g=o;var j=g.stateNode;if(g.tag===5&&j!==null&&(g=j,y!==null&&(j=Nr(o,y),j!=null&&m.push(Hr(o,j,g)))),z)break;o=o.return}0<m.length&&(u=new x(u,v,null,l,h),c.push({event:u,listeners:m}))}}if(!(t&7)){e:{if(u=e==="mouseover"||e==="pointerover",x=e==="mouseout"||e==="pointerout",u&&l!==Na&&(v=l.relatedTarget||l.fromElement)&&(Nn(v)||v[nn]))break e;if((x||u)&&(u=h.window===h?h:(u=h.ownerDocument)?u.defaultView||u.parentWindow:window,x?(v=l.relatedTarget||l.toElement,x=f,v=v?Nn(v):null,v!==null&&(z=Xn(v),v!==z||v.tag!==5&&v.tag!==6)&&(v=null)):(x=null,v=f),x!==v)){if(m=Vc,j="onMouseLeave",y="onMouseEnter",o="mouse",(e==="pointerout"||e==="pointerover")&&(m=td,j="onPointerLeave",y="onPointerEnter",o="pointer"),z=x==null?u:xl(x),g=v==null?u:xl(v),u=new m(j,o+"leave",x,l,h),u.target=z,u.relatedTarget=g,j=null,Nn(h)===f&&(m=new m(y,o+"enter",v,l,h),m.target=g,m.relatedTarget=z,j=m),z=j,x&&v)t:{for(m=x,y=v,o=0,g=m;g;g=rl(g))o++;for(g=0,j=y;j;j=rl(j))g++;for(;0<o-g;)m=rl(m),o--;for(;0<g-o;)y=rl(y),g--;for(;o--;){if(m===y||y!==null&&m===y.alternate)break t;m=rl(m),y=rl(y)}m=null}else m=null;x!==null&&pd(c,u,x,m,!1),v!==null&&z!==null&&pd(c,z,v,m,!0)}}e:{if(u=f?xl(f):window,x=u.nodeName&&u.nodeName.toLowerCase(),x==="select"||x==="input"&&u.type==="file")var b=Ax;else if(rd(u))if(ip)b=Dx;else{b=Lx;var w=Rx}else(x=u.nodeName)&&x.toLowerCase()==="input"&&(u.type==="checkbox"||u.type==="radio")&&(b=Ox);if(b&&(b=b(e,f))){sp(c,b,l,h);break e}w&&w(e,u,f),e==="focusout"&&(w=u._wrapperState)&&w.controlled&&u.type==="number"&&Aa(u,"number",u.value)}switch(w=f?xl(f):window,e){case"focusin":(rd(w)||w.contentEditable==="true")&&(hl=w,Ha=f,Pr=null);break;case"focusout":Pr=Ha=hl=null;break;case"mousedown":Ka=!0;break;case"contextmenu":case"mouseup":case"dragend":Ka=!1,cd(c,l,h);break;case"selectionchange":if(Bx)break;case"keydown":case"keyup":cd(c,l,h)}var k;if(Wo)e:{switch(e){case"compositionstart":var C="onCompositionStart";break e;case"compositionend":C="onCompositionEnd";break e;case"compositionupdate":C="onCompositionUpdate";break e}C=void 0}else fl?lp(e,l)&&(C="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(C="onCompositionStart");C&&(np&&l.locale!=="ko"&&(fl||C!=="onCompositionStart"?C==="onCompositionEnd"&&fl&&(k=tp()):(xn=h,Oo="value"in xn?xn.value:xn.textContent,fl=!0)),w=ni(f,C),0<w.length&&(C=new ed(C,e,null,l,h),c.push({event:C,listeners:w}),k?C.data=k:(k=rp(l),k!==null&&(C.data=k)))),(k=zx?Tx(e,l):Ix(e,l))&&(f=ni(f,"onBeforeInput"),0<f.length&&(h=new ed("onBeforeInput","beforeinput",null,l,h),c.push({event:h,listeners:f}),h.data=k))}xp(c,t)})}function Hr(e,t,l){return{instance:e,listener:t,currentTarget:l}}function ni(e,t){for(var l=t+"Capture",r=[];e!==null;){var s=e,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=Nr(e,l),i!=null&&r.unshift(Hr(e,i,s)),i=Nr(e,t),i!=null&&r.push(Hr(e,i,s))),e=e.return}return r}function rl(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function pd(e,t,l,r,s){for(var i=t._reactName,a=[];l!==null&&l!==r;){var d=l,p=d.alternate,f=d.stateNode;if(p!==null&&p===r)break;d.tag===5&&f!==null&&(d=f,s?(p=Nr(l,i),p!=null&&a.unshift(Hr(l,p,d))):s||(p=Nr(l,i),p!=null&&a.push(Hr(l,p,d)))),l=l.return}a.length!==0&&e.push({event:t,listeners:a})}var Mx=/\r\n?/g,Hx=/\u0000|\uFFFD/g;function fd(e){return(typeof e=="string"?e:""+e).replace(Mx,`
|
||
`).replace(Hx,"")}function Ss(e,t,l){if(t=fd(t),fd(e)!==t&&l)throw Error(W(425))}function li(){}var Qa=null,Ga=null;function Ya(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 Xa=typeof setTimeout=="function"?setTimeout:void 0,Kx=typeof clearTimeout=="function"?clearTimeout:void 0,hd=typeof Promise=="function"?Promise:void 0,Qx=typeof queueMicrotask=="function"?queueMicrotask:typeof hd<"u"?function(e){return hd.resolve(null).then(e).catch(Gx)}:Xa;function Gx(e){setTimeout(function(){throw e})}function oa(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),$r(t);return}r--}else l!=="$"&&l!=="$?"&&l!=="$!"||r++;l=s}while(l);$r(t)}function Sn(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 gd(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 Ul=Math.random().toString(36).slice(2),$t="__reactFiber$"+Ul,Kr="__reactProps$"+Ul,nn="__reactContainer$"+Ul,Ja="__reactEvents$"+Ul,Yx="__reactListeners$"+Ul,Xx="__reactHandles$"+Ul;function Nn(e){var t=e[$t];if(t)return t;for(var l=e.parentNode;l;){if(t=l[nn]||l[$t]){if(l=t.alternate,t.child!==null||l!==null&&l.child!==null)for(e=gd(e);e!==null;){if(l=e[$t])return l;e=gd(e)}return t}e=l,l=e.parentNode}return null}function ts(e){return e=e[$t]||e[nn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function xl(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(W(33))}function _i(e){return e[Kr]||null}var qa=[],ml=-1;function En(e){return{current:e}}function ge(e){0>ml||(e.current=qa[ml],qa[ml]=null,ml--)}function fe(e,t){ml++,qa[ml]=e.current,e.current=t}var Tn={},Ze=En(Tn),at=En(!1),Fn=Tn;function El(e,t){var l=e.type.contextTypes;if(!l)return Tn;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 ot(e){return e=e.childContextTypes,e!=null}function ri(){ge(at),ge(Ze)}function xd(e,t,l){if(Ze.current!==Tn)throw Error(W(168));fe(Ze,t),fe(at,l)}function yp(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(W(108,Rg(e)||"Unknown",s));return we({},l,r)}function si(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Tn,Fn=Ze.current,fe(Ze,e),fe(at,at.current),!0}function md(e,t,l){var r=e.stateNode;if(!r)throw Error(W(169));l?(e=yp(e,t,Fn),r.__reactInternalMemoizedMergedChildContext=e,ge(at),ge(Ze),fe(Ze,e)):ge(at),fe(at,l)}var qt=null,Ci=!1,ca=!1;function vp(e){qt===null?qt=[e]:qt.push(e)}function Jx(e){Ci=!0,vp(e)}function An(){if(!ca&&qt!==null){ca=!0;var e=0,t=de;try{var l=qt;for(de=1;e<l.length;e++){var r=l[e];do r=r(!0);while(r!==null)}qt=null,Ci=!1}catch(s){throw qt!==null&&(qt=qt.slice(e+1)),Hu(Eo,An),s}finally{de=t,ca=!1}}return null}var yl=[],vl=0,ii=null,ai=0,vt=[],jt=0,Mn=null,Zt=1,Vt="";function On(e,t){yl[vl++]=ai,yl[vl++]=ii,ii=e,ai=t}function jp(e,t,l){vt[jt++]=Zt,vt[jt++]=Vt,vt[jt++]=Mn,Mn=e;var r=Zt;e=Vt;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,Zt=1<<32-Rt(t)+s|l<<s|r,Vt=i+e}else Zt=1<<i|l<<s|r,Vt=e}function $o(e){e.return!==null&&(On(e,1),jp(e,1,0))}function Uo(e){for(;e===ii;)ii=yl[--vl],yl[vl]=null,ai=yl[--vl],yl[vl]=null;for(;e===Mn;)Mn=vt[--jt],vt[jt]=null,Vt=vt[--jt],vt[jt]=null,Zt=vt[--jt],vt[jt]=null}var gt=null,ht=null,ve=!1,Et=null;function bp(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 yd(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=Sn(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=Mn!==null?{id:Zt,overflow:Vt}: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 Za(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Va(e){if(ve){var t=ht;if(t){var l=t;if(!yd(e,t)){if(Za(e))throw Error(W(418));t=Sn(l.nextSibling);var r=gt;t&&yd(e,t)?bp(r,l):(e.flags=e.flags&-4097|2,ve=!1,gt=e)}}else{if(Za(e))throw Error(W(418));e.flags=e.flags&-4097|2,ve=!1,gt=e}}}function vd(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;gt=e}function ws(e){if(e!==gt)return!1;if(!ve)return vd(e),ve=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Ya(e.type,e.memoizedProps)),t&&(t=ht)){if(Za(e))throw Sp(),Error(W(418));for(;t;)bp(e,t),t=Sn(t.nextSibling)}if(vd(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(W(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var l=e.data;if(l==="/$"){if(t===0){ht=Sn(e.nextSibling);break e}t--}else l!=="$"&&l!=="$!"&&l!=="$?"||t++}e=e.nextSibling}ht=null}}else ht=gt?Sn(e.stateNode.nextSibling):null;return!0}function Sp(){for(var e=ht;e;)e=Sn(e.nextSibling)}function Al(){ht=gt=null,ve=!1}function Fo(e){Et===null?Et=[e]:Et.push(e)}var qx=sn.ReactCurrentBatchConfig;function ir(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(W(309));var r=l.stateNode}if(!r)throw Error(W(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 d=s.refs;a===null?delete d[i]:d[i]=a},t._stringRef=i,t)}if(typeof e!="string")throw Error(W(284));if(!l._owner)throw Error(W(290,e))}return e}function ks(e,t){throw e=Object.prototype.toString.call(t),Error(W(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function jd(e){var t=e._init;return t(e._payload)}function wp(e){function t(y,o){if(e){var g=y.deletions;g===null?(y.deletions=[o],y.flags|=16):g.push(o)}}function l(y,o){if(!e)return null;for(;o!==null;)t(y,o),o=o.sibling;return null}function r(y,o){for(y=new Map;o!==null;)o.key!==null?y.set(o.key,o):y.set(o.index,o),o=o.sibling;return y}function s(y,o){return y=Cn(y,o),y.index=0,y.sibling=null,y}function i(y,o,g){return y.index=g,e?(g=y.alternate,g!==null?(g=g.index,g<o?(y.flags|=2,o):g):(y.flags|=2,o)):(y.flags|=1048576,o)}function a(y){return e&&y.alternate===null&&(y.flags|=2),y}function d(y,o,g,j){return o===null||o.tag!==6?(o=xa(g,y.mode,j),o.return=y,o):(o=s(o,g),o.return=y,o)}function p(y,o,g,j){var b=g.type;return b===pl?h(y,o,g.props.children,j,g.key):o!==null&&(o.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===pn&&jd(b)===o.type)?(j=s(o,g.props),j.ref=ir(y,o,g),j.return=y,j):(j=Ys(g.type,g.key,g.props,null,y.mode,j),j.ref=ir(y,o,g),j.return=y,j)}function f(y,o,g,j){return o===null||o.tag!==4||o.stateNode.containerInfo!==g.containerInfo||o.stateNode.implementation!==g.implementation?(o=ma(g,y.mode,j),o.return=y,o):(o=s(o,g.children||[]),o.return=y,o)}function h(y,o,g,j,b){return o===null||o.tag!==7?(o=Un(g,y.mode,j,b),o.return=y,o):(o=s(o,g),o.return=y,o)}function c(y,o,g){if(typeof o=="string"&&o!==""||typeof o=="number")return o=xa(""+o,y.mode,g),o.return=y,o;if(typeof o=="object"&&o!==null){switch(o.$$typeof){case fs:return g=Ys(o.type,o.key,o.props,null,y.mode,g),g.ref=ir(y,null,o),g.return=y,g;case ul:return o=ma(o,y.mode,g),o.return=y,o;case pn:var j=o._init;return c(y,j(o._payload),g)}if(Sr(o)||tr(o))return o=Un(o,y.mode,g,null),o.return=y,o;ks(y,o)}return null}function u(y,o,g,j){var b=o!==null?o.key:null;if(typeof g=="string"&&g!==""||typeof g=="number")return b!==null?null:d(y,o,""+g,j);if(typeof g=="object"&&g!==null){switch(g.$$typeof){case fs:return g.key===b?p(y,o,g,j):null;case ul:return g.key===b?f(y,o,g,j):null;case pn:return b=g._init,u(y,o,b(g._payload),j)}if(Sr(g)||tr(g))return b!==null?null:h(y,o,g,j,null);ks(y,g)}return null}function x(y,o,g,j,b){if(typeof j=="string"&&j!==""||typeof j=="number")return y=y.get(g)||null,d(o,y,""+j,b);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case fs:return y=y.get(j.key===null?g:j.key)||null,p(o,y,j,b);case ul:return y=y.get(j.key===null?g:j.key)||null,f(o,y,j,b);case pn:var w=j._init;return x(y,o,g,w(j._payload),b)}if(Sr(j)||tr(j))return y=y.get(g)||null,h(o,y,j,b,null);ks(o,j)}return null}function v(y,o,g,j){for(var b=null,w=null,k=o,C=o=0,O=null;k!==null&&C<g.length;C++){k.index>C?(O=k,k=null):O=k.sibling;var U=u(y,k,g[C],j);if(U===null){k===null&&(k=O);break}e&&k&&U.alternate===null&&t(y,k),o=i(U,o,C),w===null?b=U:w.sibling=U,w=U,k=O}if(C===g.length)return l(y,k),ve&&On(y,C),b;if(k===null){for(;C<g.length;C++)k=c(y,g[C],j),k!==null&&(o=i(k,o,C),w===null?b=k:w.sibling=k,w=k);return ve&&On(y,C),b}for(k=r(y,k);C<g.length;C++)O=x(k,y,C,g[C],j),O!==null&&(e&&O.alternate!==null&&k.delete(O.key===null?C:O.key),o=i(O,o,C),w===null?b=O:w.sibling=O,w=O);return e&&k.forEach(function(Q){return t(y,Q)}),ve&&On(y,C),b}function m(y,o,g,j){var b=tr(g);if(typeof b!="function")throw Error(W(150));if(g=b.call(g),g==null)throw Error(W(151));for(var w=b=null,k=o,C=o=0,O=null,U=g.next();k!==null&&!U.done;C++,U=g.next()){k.index>C?(O=k,k=null):O=k.sibling;var Q=u(y,k,U.value,j);if(Q===null){k===null&&(k=O);break}e&&k&&Q.alternate===null&&t(y,k),o=i(Q,o,C),w===null?b=Q:w.sibling=Q,w=Q,k=O}if(U.done)return l(y,k),ve&&On(y,C),b;if(k===null){for(;!U.done;C++,U=g.next())U=c(y,U.value,j),U!==null&&(o=i(U,o,C),w===null?b=U:w.sibling=U,w=U);return ve&&On(y,C),b}for(k=r(y,k);!U.done;C++,U=g.next())U=x(k,y,C,U.value,j),U!==null&&(e&&U.alternate!==null&&k.delete(U.key===null?C:U.key),o=i(U,o,C),w===null?b=U:w.sibling=U,w=U);return e&&k.forEach(function(X){return t(y,X)}),ve&&On(y,C),b}function z(y,o,g,j){if(typeof g=="object"&&g!==null&&g.type===pl&&g.key===null&&(g=g.props.children),typeof g=="object"&&g!==null){switch(g.$$typeof){case fs:e:{for(var b=g.key,w=o;w!==null;){if(w.key===b){if(b=g.type,b===pl){if(w.tag===7){l(y,w.sibling),o=s(w,g.props.children),o.return=y,y=o;break e}}else if(w.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===pn&&jd(b)===w.type){l(y,w.sibling),o=s(w,g.props),o.ref=ir(y,w,g),o.return=y,y=o;break e}l(y,w);break}else t(y,w);w=w.sibling}g.type===pl?(o=Un(g.props.children,y.mode,j,g.key),o.return=y,y=o):(j=Ys(g.type,g.key,g.props,null,y.mode,j),j.ref=ir(y,o,g),j.return=y,y=j)}return a(y);case ul:e:{for(w=g.key;o!==null;){if(o.key===w)if(o.tag===4&&o.stateNode.containerInfo===g.containerInfo&&o.stateNode.implementation===g.implementation){l(y,o.sibling),o=s(o,g.children||[]),o.return=y,y=o;break e}else{l(y,o);break}else t(y,o);o=o.sibling}o=ma(g,y.mode,j),o.return=y,y=o}return a(y);case pn:return w=g._init,z(y,o,w(g._payload),j)}if(Sr(g))return v(y,o,g,j);if(tr(g))return m(y,o,g,j);ks(y,g)}return typeof g=="string"&&g!==""||typeof g=="number"?(g=""+g,o!==null&&o.tag===6?(l(y,o.sibling),o=s(o,g),o.return=y,y=o):(l(y,o),o=xa(g,y.mode,j),o.return=y,y=o),a(y)):l(y,o)}return z}var Rl=wp(!0),kp=wp(!1),oi=En(null),ci=null,jl=null,Mo=null;function Ho(){Mo=jl=ci=null}function Ko(e){var t=oi.current;ge(oi),e._currentValue=t}function eo(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 Tl(e,t){ci=e,Mo=jl=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(it=!0),e.firstContext=null)}function wt(e){var t=e._currentValue;if(Mo!==e)if(e={context:e,memoizedValue:t,next:null},jl===null){if(ci===null)throw Error(W(308));jl=e,ci.dependencies={lanes:0,firstContext:e}}else jl=jl.next=e;return t}var Wn=null;function Qo(e){Wn===null?Wn=[e]:Wn.push(e)}function _p(e,t,l,r){var s=t.interleaved;return s===null?(l.next=l,Qo(t)):(l.next=s.next,s.next=l),t.interleaved=l,ln(e,r)}function ln(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 fn=!1;function Go(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Cp(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 en(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function wn(e,t,l){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,oe&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,ln(e,l)}return s=r.interleaved,s===null?(t.next=t,Qo(r)):(t.next=s.next,s.next=t),r.interleaved=t,ln(e,l)}function Fs(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,Ao(e,l)}}function bd(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 di(e,t,l,r){var s=e.updateQueue;fn=!1;var i=s.firstBaseUpdate,a=s.lastBaseUpdate,d=s.shared.pending;if(d!==null){s.shared.pending=null;var p=d,f=p.next;p.next=null,a===null?i=f:a.next=f,a=p;var h=e.alternate;h!==null&&(h=h.updateQueue,d=h.lastBaseUpdate,d!==a&&(d===null?h.firstBaseUpdate=f:d.next=f,h.lastBaseUpdate=p))}if(i!==null){var c=s.baseState;a=0,h=f=p=null,d=i;do{var u=d.lane,x=d.eventTime;if((r&u)===u){h!==null&&(h=h.next={eventTime:x,lane:0,tag:d.tag,payload:d.payload,callback:d.callback,next:null});e:{var v=e,m=d;switch(u=t,x=l,m.tag){case 1:if(v=m.payload,typeof v=="function"){c=v.call(x,c,u);break e}c=v;break e;case 3:v.flags=v.flags&-65537|128;case 0:if(v=m.payload,u=typeof v=="function"?v.call(x,c,u):v,u==null)break e;c=we({},c,u);break e;case 2:fn=!0}}d.callback!==null&&d.lane!==0&&(e.flags|=64,u=s.effects,u===null?s.effects=[d]:u.push(d))}else x={eventTime:x,lane:u,tag:d.tag,payload:d.payload,callback:d.callback,next:null},h===null?(f=h=x,p=c):h=h.next=x,a|=u;if(d=d.next,d===null){if(d=s.shared.pending,d===null)break;u=d,d=u.next,u.next=null,s.lastBaseUpdate=u,s.shared.pending=null}}while(!0);if(h===null&&(p=c),s.baseState=p,s.firstBaseUpdate=f,s.lastBaseUpdate=h,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);Kn|=a,e.lanes=a,e.memoizedState=c}}function Sd(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(W(191,s));s.call(r)}}}var ns={},Ft=En(ns),Qr=En(ns),Gr=En(ns);function Bn(e){if(e===ns)throw Error(W(174));return e}function Yo(e,t){switch(fe(Gr,t),fe(Qr,e),fe(Ft,ns),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:La(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=La(t,e)}ge(Ft),fe(Ft,t)}function Ll(){ge(Ft),ge(Qr),ge(Gr)}function zp(e){Bn(Gr.current);var t=Bn(Ft.current),l=La(t,e.type);t!==l&&(fe(Qr,e),fe(Ft,l))}function Xo(e){Qr.current===e&&(ge(Ft),ge(Qr))}var be=En(0);function ui(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 da=[];function Jo(){for(var e=0;e<da.length;e++)da[e]._workInProgressVersionPrimary=null;da.length=0}var Ms=sn.ReactCurrentDispatcher,ua=sn.ReactCurrentBatchConfig,Hn=0,Se=null,We=null,Fe=null,pi=!1,Er=!1,Yr=0,Zx=0;function Xe(){throw Error(W(321))}function qo(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 Zo(e,t,l,r,s,i){if(Hn=i,Se=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Ms.current=e===null||e.memoizedState===null?nm:lm,e=l(r,s),Er){i=0;do{if(Er=!1,Yr=0,25<=i)throw Error(W(301));i+=1,Fe=We=null,t.updateQueue=null,Ms.current=rm,e=l(r,s)}while(Er)}if(Ms.current=fi,t=We!==null&&We.next!==null,Hn=0,Fe=We=Se=null,pi=!1,t)throw Error(W(300));return e}function Vo(){var e=Yr!==0;return Yr=0,e}function Bt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Fe===null?Se.memoizedState=Fe=e:Fe=Fe.next=e,Fe}function kt(){if(We===null){var e=Se.alternate;e=e!==null?e.memoizedState:null}else e=We.next;var t=Fe===null?Se.memoizedState:Fe.next;if(t!==null)Fe=t,We=e;else{if(e===null)throw Error(W(310));We=e,e={memoizedState:We.memoizedState,baseState:We.baseState,baseQueue:We.baseQueue,queue:We.queue,next:null},Fe===null?Se.memoizedState=Fe=e:Fe=Fe.next=e}return Fe}function Xr(e,t){return typeof t=="function"?t(e):t}function pa(e){var t=kt(),l=t.queue;if(l===null)throw Error(W(311));l.lastRenderedReducer=e;var r=We,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 d=a=null,p=null,f=i;do{var h=f.lane;if((Hn&h)===h)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:h,action:f.action,hasEagerState:f.hasEagerState,eagerState:f.eagerState,next:null};p===null?(d=p=c,a=r):p=p.next=c,Se.lanes|=h,Kn|=h}f=f.next}while(f!==null&&f!==i);p===null?a=r:p.next=d,Ot(r,t.memoizedState)||(it=!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,Se.lanes|=i,Kn|=i,s=s.next;while(s!==e)}else s===null&&(l.lanes=0);return[t.memoizedState,l.dispatch]}function fa(e){var t=kt(),l=t.queue;if(l===null)throw Error(W(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)||(it=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),l.lastRenderedState=i}return[i,r]}function Tp(){}function Ip(e,t){var l=Se,r=kt(),s=t(),i=!Ot(r.memoizedState,s);if(i&&(r.memoizedState=s,it=!0),r=r.queue,ec(Ap.bind(null,l,r,e),[e]),r.getSnapshot!==t||i||Fe!==null&&Fe.memoizedState.tag&1){if(l.flags|=2048,Jr(9,Ep.bind(null,l,r,s,t),void 0,null),Me===null)throw Error(W(349));Hn&30||Pp(l,t,s)}return s}function Pp(e,t,l){e.flags|=16384,e={getSnapshot:t,value:l},t=Se.updateQueue,t===null?(t={lastEffect:null,stores:null},Se.updateQueue=t,t.stores=[e]):(l=t.stores,l===null?t.stores=[e]:l.push(e))}function Ep(e,t,l,r){t.value=l,t.getSnapshot=r,Rp(t)&&Lp(e)}function Ap(e,t,l){return l(function(){Rp(t)&&Lp(e)})}function Rp(e){var t=e.getSnapshot;e=e.value;try{var l=t();return!Ot(e,l)}catch{return!0}}function Lp(e){var t=ln(e,1);t!==null&&Lt(t,e,1,-1)}function wd(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:Xr,lastRenderedState:e},t.queue=e,e=e.dispatch=tm.bind(null,Se,e),[t.memoizedState,e]}function Jr(e,t,l,r){return e={tag:e,create:t,destroy:l,deps:r,next:null},t=Se.updateQueue,t===null?(t={lastEffect:null,stores:null},Se.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 Op(){return kt().memoizedState}function Hs(e,t,l,r){var s=Bt();Se.flags|=e,s.memoizedState=Jr(1|t,l,void 0,r===void 0?null:r)}function zi(e,t,l,r){var s=kt();r=r===void 0?null:r;var i=void 0;if(We!==null){var a=We.memoizedState;if(i=a.destroy,r!==null&&qo(r,a.deps)){s.memoizedState=Jr(t,l,i,r);return}}Se.flags|=e,s.memoizedState=Jr(1|t,l,i,r)}function kd(e,t){return Hs(8390656,8,e,t)}function ec(e,t){return zi(2048,8,e,t)}function Dp(e,t){return zi(4,2,e,t)}function Np(e,t){return zi(4,4,e,t)}function Wp(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 Bp(e,t,l){return l=l!=null?l.concat([e]):null,zi(4,4,Wp.bind(null,t,e),l)}function tc(){}function $p(e,t){var l=kt();t=t===void 0?null:t;var r=l.memoizedState;return r!==null&&t!==null&&qo(t,r[1])?r[0]:(l.memoizedState=[e,t],e)}function Up(e,t){var l=kt();t=t===void 0?null:t;var r=l.memoizedState;return r!==null&&t!==null&&qo(t,r[1])?r[0]:(e=e(),l.memoizedState=[e,t],e)}function Fp(e,t,l){return Hn&21?(Ot(l,t)||(l=Gu(),Se.lanes|=l,Kn|=l,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,it=!0),e.memoizedState=l)}function Vx(e,t){var l=de;de=l!==0&&4>l?l:4,e(!0);var r=ua.transition;ua.transition={};try{e(!1),t()}finally{de=l,ua.transition=r}}function Mp(){return kt().memoizedState}function em(e,t,l){var r=_n(e);if(l={lane:r,action:l,hasEagerState:!1,eagerState:null,next:null},Hp(e))Kp(t,l);else if(l=_p(e,t,l,r),l!==null){var s=tt();Lt(l,e,r,s),Qp(l,t,r)}}function tm(e,t,l){var r=_n(e),s={lane:r,action:l,hasEagerState:!1,eagerState:null,next:null};if(Hp(e))Kp(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,d=i(a,l);if(s.hasEagerState=!0,s.eagerState=d,Ot(d,a)){var p=t.interleaved;p===null?(s.next=s,Qo(t)):(s.next=p.next,p.next=s),t.interleaved=s;return}}catch{}finally{}l=_p(e,t,s,r),l!==null&&(s=tt(),Lt(l,e,r,s),Qp(l,t,r))}}function Hp(e){var t=e.alternate;return e===Se||t!==null&&t===Se}function Kp(e,t){Er=pi=!0;var l=e.pending;l===null?t.next=t:(t.next=l.next,l.next=t),e.pending=t}function Qp(e,t,l){if(l&4194240){var r=t.lanes;r&=e.pendingLanes,l|=r,t.lanes=l,Ao(e,l)}}var fi={readContext:wt,useCallback:Xe,useContext:Xe,useEffect:Xe,useImperativeHandle:Xe,useInsertionEffect:Xe,useLayoutEffect:Xe,useMemo:Xe,useReducer:Xe,useRef:Xe,useState:Xe,useDebugValue:Xe,useDeferredValue:Xe,useTransition:Xe,useMutableSource:Xe,useSyncExternalStore:Xe,useId:Xe,unstable_isNewReconciler:!1},nm={readContext:wt,useCallback:function(e,t){return Bt().memoizedState=[e,t===void 0?null:t],e},useContext:wt,useEffect:kd,useImperativeHandle:function(e,t,l){return l=l!=null?l.concat([e]):null,Hs(4194308,4,Wp.bind(null,t,e),l)},useLayoutEffect:function(e,t){return Hs(4194308,4,e,t)},useInsertionEffect:function(e,t){return Hs(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=em.bind(null,Se,e),[r.memoizedState,e]},useRef:function(e){var t=Bt();return e={current:e},t.memoizedState=e},useState:wd,useDebugValue:tc,useDeferredValue:function(e){return Bt().memoizedState=e},useTransition:function(){var e=wd(!1),t=e[0];return e=Vx.bind(null,e[1]),Bt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,l){var r=Se,s=Bt();if(ve){if(l===void 0)throw Error(W(407));l=l()}else{if(l=t(),Me===null)throw Error(W(349));Hn&30||Pp(r,t,l)}s.memoizedState=l;var i={value:l,getSnapshot:t};return s.queue=i,kd(Ap.bind(null,r,i,e),[e]),r.flags|=2048,Jr(9,Ep.bind(null,r,i,l,t),void 0,null),l},useId:function(){var e=Bt(),t=Me.identifierPrefix;if(ve){var l=Vt,r=Zt;l=(r&~(1<<32-Rt(r)-1)).toString(32)+l,t=":"+t+"R"+l,l=Yr++,0<l&&(t+="H"+l.toString(32)),t+=":"}else l=Zx++,t=":"+t+"r"+l.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},lm={readContext:wt,useCallback:$p,useContext:wt,useEffect:ec,useImperativeHandle:Bp,useInsertionEffect:Dp,useLayoutEffect:Np,useMemo:Up,useReducer:pa,useRef:Op,useState:function(){return pa(Xr)},useDebugValue:tc,useDeferredValue:function(e){var t=kt();return Fp(t,We.memoizedState,e)},useTransition:function(){var e=pa(Xr)[0],t=kt().memoizedState;return[e,t]},useMutableSource:Tp,useSyncExternalStore:Ip,useId:Mp,unstable_isNewReconciler:!1},rm={readContext:wt,useCallback:$p,useContext:wt,useEffect:ec,useImperativeHandle:Bp,useInsertionEffect:Dp,useLayoutEffect:Np,useMemo:Up,useReducer:fa,useRef:Op,useState:function(){return fa(Xr)},useDebugValue:tc,useDeferredValue:function(e){var t=kt();return We===null?t.memoizedState=e:Fp(t,We.memoizedState,e)},useTransition:function(){var e=fa(Xr)[0],t=kt().memoizedState;return[e,t]},useMutableSource:Tp,useSyncExternalStore:Ip,useId:Mp,unstable_isNewReconciler:!1};function It(e,t){if(e&&e.defaultProps){t=we({},t),e=e.defaultProps;for(var l in e)t[l]===void 0&&(t[l]=e[l]);return t}return t}function to(e,t,l,r){t=e.memoizedState,l=l(r,t),l=l==null?t:we({},t,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var Ti={isMounted:function(e){return(e=e._reactInternals)?Xn(e)===e:!1},enqueueSetState:function(e,t,l){e=e._reactInternals;var r=tt(),s=_n(e),i=en(r,s);i.payload=t,l!=null&&(i.callback=l),t=wn(e,i,s),t!==null&&(Lt(t,e,s,r),Fs(t,e,s))},enqueueReplaceState:function(e,t,l){e=e._reactInternals;var r=tt(),s=_n(e),i=en(r,s);i.tag=1,i.payload=t,l!=null&&(i.callback=l),t=wn(e,i,s),t!==null&&(Lt(t,e,s,r),Fs(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var l=tt(),r=_n(e),s=en(l,r);s.tag=2,t!=null&&(s.callback=t),t=wn(e,s,r),t!==null&&(Lt(t,e,r,l),Fs(t,e,r))}};function _d(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?!Fr(l,r)||!Fr(s,i):!0}function Gp(e,t,l){var r=!1,s=Tn,i=t.contextType;return typeof i=="object"&&i!==null?i=wt(i):(s=ot(t)?Fn:Ze.current,r=t.contextTypes,i=(r=r!=null)?El(e,s):Tn),t=new t(l,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ti,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=i),t}function Cd(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&&Ti.enqueueReplaceState(t,t.state,null)}function no(e,t,l,r){var s=e.stateNode;s.props=l,s.state=e.memoizedState,s.refs={},Go(e);var i=t.contextType;typeof i=="object"&&i!==null?s.context=wt(i):(i=ot(t)?Fn:Ze.current,s.context=El(e,i)),s.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(to(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&&Ti.enqueueReplaceState(s,s.state,null),di(e,l,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function Ol(e,t){try{var l="",r=t;do l+=Ag(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 ha(e,t,l){return{value:e,source:null,stack:l??null,digest:t??null}}function lo(e,t){try{console.error(t.value)}catch(l){setTimeout(function(){throw l})}}var sm=typeof WeakMap=="function"?WeakMap:Map;function Yp(e,t,l){l=en(-1,l),l.tag=3,l.payload={element:null};var r=t.value;return l.callback=function(){gi||(gi=!0,ho=r),lo(e,t)},l}function Xp(e,t,l){l=en(-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(){lo(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(l.callback=function(){lo(e,t),typeof r!="function"&&(kn===null?kn=new Set([this]):kn.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),l}function zd(e,t,l){var r=e.pingCache;if(r===null){r=e.pingCache=new sm;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=vm.bind(null,e,t,l),t.then(e,e))}function Td(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 Id(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=en(-1,1),t.tag=2,wn(l,t,1))),l.lanes|=1),e)}var im=sn.ReactCurrentOwner,it=!1;function et(e,t,l,r){t.child=e===null?kp(t,null,l,r):Rl(t,e.child,l,r)}function Pd(e,t,l,r,s){l=l.render;var i=t.ref;return Tl(t,s),r=Zo(e,t,l,r,i,s),l=Vo(),e!==null&&!it?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,rn(e,t,s)):(ve&&l&&$o(t),t.flags|=1,et(e,t,r,s),t.child)}function Ed(e,t,l,r,s){if(e===null){var i=l.type;return typeof i=="function"&&!cc(i)&&i.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(t.tag=15,t.type=i,Jp(e,t,i,r,s)):(e=Ys(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:Fr,l(a,r)&&e.ref===t.ref)return rn(e,t,s)}return t.flags|=1,e=Cn(i,r),e.ref=t.ref,e.return=t,t.child=e}function Jp(e,t,l,r,s){if(e!==null){var i=e.memoizedProps;if(Fr(i,r)&&e.ref===t.ref)if(it=!1,t.pendingProps=r=i,(e.lanes&s)!==0)e.flags&131072&&(it=!0);else return t.lanes=e.lanes,rn(e,t,s)}return ro(e,t,l,r,s)}function qp(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},fe(Sl,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,fe(Sl,ft),ft|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:l,fe(Sl,ft),ft|=r}else i!==null?(r=i.baseLanes|l,t.memoizedState=null):r=l,fe(Sl,ft),ft|=r;return et(e,t,s,l),t.child}function Zp(e,t){var l=t.ref;(e===null&&l!==null||e!==null&&e.ref!==l)&&(t.flags|=512,t.flags|=2097152)}function ro(e,t,l,r,s){var i=ot(l)?Fn:Ze.current;return i=El(t,i),Tl(t,s),l=Zo(e,t,l,r,i,s),r=Vo(),e!==null&&!it?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,rn(e,t,s)):(ve&&r&&$o(t),t.flags|=1,et(e,t,l,s),t.child)}function Ad(e,t,l,r,s){if(ot(l)){var i=!0;si(t)}else i=!1;if(Tl(t,s),t.stateNode===null)Ks(e,t),Gp(t,l,r),no(t,l,r,s),r=!0;else if(e===null){var a=t.stateNode,d=t.memoizedProps;a.props=d;var p=a.context,f=l.contextType;typeof f=="object"&&f!==null?f=wt(f):(f=ot(l)?Fn:Ze.current,f=El(t,f));var h=l.getDerivedStateFromProps,c=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function";c||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(d!==r||p!==f)&&Cd(t,a,r,f),fn=!1;var u=t.memoizedState;a.state=u,di(t,r,a,s),p=t.memoizedState,d!==r||u!==p||at.current||fn?(typeof h=="function"&&(to(t,l,h,r),p=t.memoizedState),(d=fn||_d(t,l,d,r,u,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=d):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Cp(e,t),d=t.memoizedProps,f=t.type===t.elementType?d:It(t.type,d),a.props=f,c=t.pendingProps,u=a.context,p=l.contextType,typeof p=="object"&&p!==null?p=wt(p):(p=ot(l)?Fn:Ze.current,p=El(t,p));var x=l.getDerivedStateFromProps;(h=typeof x=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(d!==c||u!==p)&&Cd(t,a,r,p),fn=!1,u=t.memoizedState,a.state=u,di(t,r,a,s);var v=t.memoizedState;d!==c||u!==v||at.current||fn?(typeof x=="function"&&(to(t,l,x,r),v=t.memoizedState),(f=fn||_d(t,l,f,r,u,v,p)||!1)?(h||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,v,p),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,v,p)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||d===e.memoizedProps&&u===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||d===e.memoizedProps&&u===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=v),a.props=r,a.state=v,a.context=p,r=f):(typeof a.componentDidUpdate!="function"||d===e.memoizedProps&&u===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||d===e.memoizedProps&&u===e.memoizedState||(t.flags|=1024),r=!1)}return so(e,t,l,r,i,s)}function so(e,t,l,r,s,i){Zp(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&md(t,l,!1),rn(e,t,i);r=t.stateNode,im.current=t;var d=a&&typeof l.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=Rl(t,e.child,null,i),t.child=Rl(t,null,d,i)):et(e,t,d,i),t.memoizedState=r.state,s&&md(t,l,!0),t.child}function Vp(e){var t=e.stateNode;t.pendingContext?xd(e,t.pendingContext,t.pendingContext!==t.context):t.context&&xd(e,t.context,!1),Yo(e,t.containerInfo)}function Rd(e,t,l,r,s){return Al(),Fo(s),t.flags|=256,et(e,t,l,r),t.child}var io={dehydrated:null,treeContext:null,retryLane:0};function ao(e){return{baseLanes:e,cachePool:null,transitions:null}}function ef(e,t,l){var r=t.pendingProps,s=be.current,i=!1,a=(t.flags&128)!==0,d;if((d=a)||(d=e!==null&&e.memoizedState===null?!1:(s&2)!==0),d?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),fe(be,s&1),e===null)return Va(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=Ei(a,r,0,null),e=Un(e,r,l,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=ao(l),t.memoizedState=io,e):nc(t,a));if(s=e.memoizedState,s!==null&&(d=s.dehydrated,d!==null))return am(e,t,a,r,d,s,l);if(i){i=r.fallback,a=t.mode,s=e.child,d=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=Cn(s,p),r.subtreeFlags=s.subtreeFlags&14680064),d!==null?i=Cn(d,i):(i=Un(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?ao(l):{baseLanes:a.baseLanes|l,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~l,t.memoizedState=io,r}return i=e.child,e=i.sibling,r=Cn(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 nc(e,t){return t=Ei({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function _s(e,t,l,r){return r!==null&&Fo(r),Rl(t,e.child,null,l),e=nc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function am(e,t,l,r,s,i,a){if(l)return t.flags&256?(t.flags&=-257,r=ha(Error(W(422))),_s(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,s=t.mode,r=Ei({mode:"visible",children:r.children},s,0,null),i=Un(i,s,a,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&Rl(t,e.child,null,a),t.child.memoizedState=ao(a),t.memoizedState=io,i);if(!(t.mode&1))return _s(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var d=r.dgst;return r=d,i=Error(W(419)),r=ha(i,r,void 0),_s(e,t,a,r)}if(d=(a&e.childLanes)!==0,it||d){if(r=Me,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,ln(e,s),Lt(r,e,s,-1))}return oc(),r=ha(Error(W(421))),_s(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=jm.bind(null,e),s._reactRetry=t,null):(e=i.treeContext,ht=Sn(s.nextSibling),gt=t,ve=!0,Et=null,e!==null&&(vt[jt++]=Zt,vt[jt++]=Vt,vt[jt++]=Mn,Zt=e.id,Vt=e.overflow,Mn=t),t=nc(t,r.children),t.flags|=4096,t)}function Ld(e,t,l){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),eo(e.return,t,l)}function ga(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 tf(e,t,l){var r=t.pendingProps,s=r.revealOrder,i=r.tail;if(et(e,t,r.children,l),r=be.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&&Ld(e,l,t);else if(e.tag===19)Ld(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(fe(be,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&&ui(e)===null&&(s=l),l=l.sibling;l=s,l===null?(s=t.child,t.child=null):(s=l.sibling,l.sibling=null),ga(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&&ui(e)===null){t.child=s;break}e=s.sibling,s.sibling=l,l=s,s=e}ga(t,!0,l,null,i);break;case"together":ga(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Ks(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function rn(e,t,l){if(e!==null&&(t.dependencies=e.dependencies),Kn|=t.lanes,!(l&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(W(153));if(t.child!==null){for(e=t.child,l=Cn(e,e.pendingProps),t.child=l,l.return=t;e.sibling!==null;)e=e.sibling,l=l.sibling=Cn(e,e.pendingProps),l.return=t;l.sibling=null}return t.child}function om(e,t,l){switch(t.tag){case 3:Vp(t),Al();break;case 5:zp(t);break;case 1:ot(t.type)&&si(t);break;case 4:Yo(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;fe(oi,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(fe(be,be.current&1),t.flags|=128,null):l&t.child.childLanes?ef(e,t,l):(fe(be,be.current&1),e=rn(e,t,l),e!==null?e.sibling:null);fe(be,be.current&1);break;case 19:if(r=(l&t.childLanes)!==0,e.flags&128){if(r)return tf(e,t,l);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),fe(be,be.current),r)break;return null;case 22:case 23:return t.lanes=0,qp(e,t,l)}return rn(e,t,l)}var nf,oo,lf,rf;nf=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}};oo=function(){};lf=function(e,t,l,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Bn(Ft.current);var i=null;switch(l){case"input":s=Pa(e,s),r=Pa(e,r),i=[];break;case"select":s=we({},s,{value:void 0}),r=we({},r,{value:void 0}),i=[];break;case"textarea":s=Ra(e,s),r=Ra(e,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=li)}Oa(l,r);var a;l=null;for(f in s)if(!r.hasOwnProperty(f)&&s.hasOwnProperty(f)&&s[f]!=null)if(f==="style"){var d=s[f];for(a in d)d.hasOwnProperty(a)&&(l||(l={}),l[a]="")}else f!=="dangerouslySetInnerHTML"&&f!=="children"&&f!=="suppressContentEditableWarning"&&f!=="suppressHydrationWarning"&&f!=="autoFocus"&&(Or.hasOwnProperty(f)?i||(i=[]):(i=i||[]).push(f,null));for(f in r){var p=r[f];if(d=s!=null?s[f]:void 0,r.hasOwnProperty(f)&&p!==d&&(p!=null||d!=null))if(f==="style")if(d){for(a in d)!d.hasOwnProperty(a)||p&&p.hasOwnProperty(a)||(l||(l={}),l[a]="");for(a in p)p.hasOwnProperty(a)&&d[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,d=d?d.__html:void 0,p!=null&&d!==p&&(i=i||[]).push(f,p)):f==="children"?typeof p!="string"&&typeof p!="number"||(i=i||[]).push(f,""+p):f!=="suppressContentEditableWarning"&&f!=="suppressHydrationWarning"&&(Or.hasOwnProperty(f)?(p!=null&&f==="onScroll"&&he("scroll",e),i||d===p||(i=[])):(i=i||[]).push(f,p))}l&&(i=i||[]).push("style",l);var f=i;(t.updateQueue=f)&&(t.flags|=4)}};rf=function(e,t,l,r){l!==r&&(t.flags|=4)};function ar(e,t){if(!ve)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 Je(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 cm(e,t,l){var r=t.pendingProps;switch(Uo(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Je(t),null;case 1:return ot(t.type)&&ri(),Je(t),null;case 3:return r=t.stateNode,Ll(),ge(at),ge(Ze),Jo(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(ws(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Et!==null&&(mo(Et),Et=null))),oo(e,t),Je(t),null;case 5:Xo(t);var s=Bn(Gr.current);if(l=t.type,e!==null&&t.stateNode!=null)lf(e,t,l,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(W(166));return Je(t),null}if(e=Bn(Ft.current),ws(t)){r=t.stateNode,l=t.type;var i=t.memoizedProps;switch(r[$t]=t,r[Kr]=i,e=(t.mode&1)!==0,l){case"dialog":he("cancel",r),he("close",r);break;case"iframe":case"object":case"embed":he("load",r);break;case"video":case"audio":for(s=0;s<kr.length;s++)he(kr[s],r);break;case"source":he("error",r);break;case"img":case"image":case"link":he("error",r),he("load",r);break;case"details":he("toggle",r);break;case"input":Mc(r,i),he("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},he("invalid",r);break;case"textarea":Kc(r,i),he("invalid",r)}Oa(l,i),s=null;for(var a in i)if(i.hasOwnProperty(a)){var d=i[a];a==="children"?typeof d=="string"?r.textContent!==d&&(i.suppressHydrationWarning!==!0&&Ss(r.textContent,d,e),s=["children",d]):typeof d=="number"&&r.textContent!==""+d&&(i.suppressHydrationWarning!==!0&&Ss(r.textContent,d,e),s=["children",""+d]):Or.hasOwnProperty(a)&&d!=null&&a==="onScroll"&&he("scroll",r)}switch(l){case"input":hs(r),Hc(r,i,!0);break;case"textarea":hs(r),Qc(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=li)}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=Au(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[Kr]=r,nf(e,t,!1,!1),t.stateNode=e;e:{switch(a=Da(l,r),l){case"dialog":he("cancel",e),he("close",e),s=r;break;case"iframe":case"object":case"embed":he("load",e),s=r;break;case"video":case"audio":for(s=0;s<kr.length;s++)he(kr[s],e);s=r;break;case"source":he("error",e),s=r;break;case"img":case"image":case"link":he("error",e),he("load",e),s=r;break;case"details":he("toggle",e),s=r;break;case"input":Mc(e,r),s=Pa(e,r),he("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=we({},r,{value:void 0}),he("invalid",e);break;case"textarea":Kc(e,r),s=Ra(e,r),he("invalid",e);break;default:s=r}Oa(l,s),d=s;for(i in d)if(d.hasOwnProperty(i)){var p=d[i];i==="style"?Ou(e,p):i==="dangerouslySetInnerHTML"?(p=p?p.__html:void 0,p!=null&&Ru(e,p)):i==="children"?typeof p=="string"?(l!=="textarea"||p!=="")&&Dr(e,p):typeof p=="number"&&Dr(e,""+p):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Or.hasOwnProperty(i)?p!=null&&i==="onScroll"&&he("scroll",e):p!=null&&Co(e,i,p,a))}switch(l){case"input":hs(e),Hc(e,r,!1);break;case"textarea":hs(e),Qc(e);break;case"option":r.value!=null&&e.setAttribute("value",""+zn(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?kl(e,!!r.multiple,i,!1):r.defaultValue!=null&&kl(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=li)}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 Je(t),null;case 6:if(e&&t.stateNode!=null)rf(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(W(166));if(l=Bn(Gr.current),Bn(Ft.current),ws(t)){if(r=t.stateNode,l=t.memoizedProps,r[$t]=t,(i=r.nodeValue!==l)&&(e=gt,e!==null))switch(e.tag){case 3:Ss(r.nodeValue,l,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Ss(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 Je(t),null;case 13:if(ge(be),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ve&&ht!==null&&t.mode&1&&!(t.flags&128))Sp(),Al(),t.flags|=98560,i=!1;else if(i=ws(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(W(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(W(317));i[$t]=t}else Al(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Je(t),i=!1}else Et!==null&&(mo(Et),Et=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||be.current&1?Be===0&&(Be=3):oc())),t.updateQueue!==null&&(t.flags|=4),Je(t),null);case 4:return Ll(),oo(e,t),e===null&&Mr(t.stateNode.containerInfo),Je(t),null;case 10:return Ko(t.type._context),Je(t),null;case 17:return ot(t.type)&&ri(),Je(t),null;case 19:if(ge(be),i=t.memoizedState,i===null)return Je(t),null;if(r=(t.flags&128)!==0,a=i.rendering,a===null)if(r)ar(i,!1);else{if(Be!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=ui(e),a!==null){for(t.flags|=128,ar(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 fe(be,be.current&1|2),t.child}e=e.sibling}i.tail!==null&&ze()>Dl&&(t.flags|=128,r=!0,ar(i,!1),t.lanes=4194304)}else{if(!r)if(e=ui(a),e!==null){if(t.flags|=128,r=!0,l=e.updateQueue,l!==null&&(t.updateQueue=l,t.flags|=4),ar(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!ve)return Je(t),null}else 2*ze()-i.renderingStartTime>Dl&&l!==1073741824&&(t.flags|=128,r=!0,ar(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=ze(),t.sibling=null,l=be.current,fe(be,r?l&1|2:l&1),t):(Je(t),null);case 22:case 23:return ac(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ft&1073741824&&(Je(t),t.subtreeFlags&6&&(t.flags|=8192)):Je(t),null;case 24:return null;case 25:return null}throw Error(W(156,t.tag))}function dm(e,t){switch(Uo(t),t.tag){case 1:return ot(t.type)&&ri(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ll(),ge(at),ge(Ze),Jo(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Xo(t),null;case 13:if(ge(be),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(W(340));Al()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ge(be),null;case 4:return Ll(),null;case 10:return Ko(t.type._context),null;case 22:case 23:return ac(),null;case 24:return null;default:return null}}var Cs=!1,qe=!1,um=typeof WeakSet=="function"?WeakSet:Set,K=null;function bl(e,t){var l=e.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(r){ke(e,t,r)}else l.current=null}function co(e,t,l){try{l()}catch(r){ke(e,t,r)}}var Od=!1;function pm(e,t){if(Qa=ei,e=cp(),Bo(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,d=-1,p=-1,f=0,h=0,c=e,u=null;t:for(;;){for(var x;c!==l||s!==0&&c.nodeType!==3||(d=a+s),c!==i||r!==0&&c.nodeType!==3||(p=a+r),c.nodeType===3&&(a+=c.nodeValue.length),(x=c.firstChild)!==null;)u=c,c=x;for(;;){if(c===e)break t;if(u===l&&++f===s&&(d=a),u===i&&++h===r&&(p=a),(x=c.nextSibling)!==null)break;c=u,u=c.parentNode}c=x}l=d===-1||p===-1?null:{start:d,end:p}}else l=null}l=l||{start:0,end:0}}else l=null;for(Ga={focusedElem:e,selectionRange:l},ei=!1,K=t;K!==null;)if(t=K,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,K=e;else for(;K!==null;){t=K;try{var v=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(v!==null){var m=v.memoizedProps,z=v.memoizedState,y=t.stateNode,o=y.getSnapshotBeforeUpdate(t.elementType===t.type?m:It(t.type,m),z);y.__reactInternalSnapshotBeforeUpdate=o}break;case 3:var g=t.stateNode.containerInfo;g.nodeType===1?g.textContent="":g.nodeType===9&&g.documentElement&&g.removeChild(g.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(W(163))}}catch(j){ke(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,K=e;break}K=t.return}return v=Od,Od=!1,v}function Ar(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&&co(t,l,i)}s=s.next}while(s!==r)}}function Ii(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 uo(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 sf(e){var t=e.alternate;t!==null&&(e.alternate=null,sf(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[$t],delete t[Kr],delete t[Ja],delete t[Yx],delete t[Xx])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function af(e){return e.tag===5||e.tag===3||e.tag===4}function Dd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||af(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function po(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=li));else if(r!==4&&(e=e.child,e!==null))for(po(e,t,l),e=e.sibling;e!==null;)po(e,t,l),e=e.sibling}function fo(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(fo(e,t,l),e=e.sibling;e!==null;)fo(e,t,l),e=e.sibling}var Ke=null,Pt=!1;function dn(e,t,l){for(l=l.child;l!==null;)of(e,t,l),l=l.sibling}function of(e,t,l){if(Ut&&typeof Ut.onCommitFiberUnmount=="function")try{Ut.onCommitFiberUnmount(bi,l)}catch{}switch(l.tag){case 5:qe||bl(l,t);case 6:var r=Ke,s=Pt;Ke=null,dn(e,t,l),Ke=r,Pt=s,Ke!==null&&(Pt?(e=Ke,l=l.stateNode,e.nodeType===8?e.parentNode.removeChild(l):e.removeChild(l)):Ke.removeChild(l.stateNode));break;case 18:Ke!==null&&(Pt?(e=Ke,l=l.stateNode,e.nodeType===8?oa(e.parentNode,l):e.nodeType===1&&oa(e,l),$r(e)):oa(Ke,l.stateNode));break;case 4:r=Ke,s=Pt,Ke=l.stateNode.containerInfo,Pt=!0,dn(e,t,l),Ke=r,Pt=s;break;case 0:case 11:case 14:case 15:if(!qe&&(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)&&co(l,t,a),s=s.next}while(s!==r)}dn(e,t,l);break;case 1:if(!qe&&(bl(l,t),r=l.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=l.memoizedProps,r.state=l.memoizedState,r.componentWillUnmount()}catch(d){ke(l,t,d)}dn(e,t,l);break;case 21:dn(e,t,l);break;case 22:l.mode&1?(qe=(r=qe)||l.memoizedState!==null,dn(e,t,l),qe=r):dn(e,t,l);break;default:dn(e,t,l)}}function Nd(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var l=e.stateNode;l===null&&(l=e.stateNode=new um),t.forEach(function(r){var s=bm.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,d=a;e:for(;d!==null;){switch(d.tag){case 5:Ke=d.stateNode,Pt=!1;break e;case 3:Ke=d.stateNode.containerInfo,Pt=!0;break e;case 4:Ke=d.stateNode.containerInfo,Pt=!0;break e}d=d.return}if(Ke===null)throw Error(W(160));of(i,a,s),Ke=null,Pt=!1;var p=s.alternate;p!==null&&(p.return=null),s.return=null}catch(f){ke(s,t,f)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)cf(t,e),t=t.sibling}function cf(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{Ar(3,e,e.return),Ii(3,e)}catch(m){ke(e,e.return,m)}try{Ar(5,e,e.return)}catch(m){ke(e,e.return,m)}}break;case 1:Tt(t,e),Wt(e),r&512&&l!==null&&bl(l,l.return);break;case 5:if(Tt(t,e),Wt(e),r&512&&l!==null&&bl(l,l.return),e.flags&32){var s=e.stateNode;try{Dr(s,"")}catch(m){ke(e,e.return,m)}}if(r&4&&(s=e.stateNode,s!=null)){var i=e.memoizedProps,a=l!==null?l.memoizedProps:i,d=e.type,p=e.updateQueue;if(e.updateQueue=null,p!==null)try{d==="input"&&i.type==="radio"&&i.name!=null&&Pu(s,i),Da(d,a);var f=Da(d,i);for(a=0;a<p.length;a+=2){var h=p[a],c=p[a+1];h==="style"?Ou(s,c):h==="dangerouslySetInnerHTML"?Ru(s,c):h==="children"?Dr(s,c):Co(s,h,c,f)}switch(d){case"input":Ea(s,i);break;case"textarea":Eu(s,i);break;case"select":var u=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var x=i.value;x!=null?kl(s,!!i.multiple,x,!1):u!==!!i.multiple&&(i.defaultValue!=null?kl(s,!!i.multiple,i.defaultValue,!0):kl(s,!!i.multiple,i.multiple?[]:"",!1))}s[Kr]=i}catch(m){ke(e,e.return,m)}}break;case 6:if(Tt(t,e),Wt(e),r&4){if(e.stateNode===null)throw Error(W(162));s=e.stateNode,i=e.memoizedProps;try{s.nodeValue=i}catch(m){ke(e,e.return,m)}}break;case 3:if(Tt(t,e),Wt(e),r&4&&l!==null&&l.memoizedState.isDehydrated)try{$r(t.containerInfo)}catch(m){ke(e,e.return,m)}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||(sc=ze())),r&4&&Nd(e);break;case 22:if(h=l!==null&&l.memoizedState!==null,e.mode&1?(qe=(f=qe)||h,Tt(t,e),qe=f):Tt(t,e),Wt(e),r&8192){if(f=e.memoizedState!==null,(e.stateNode.isHidden=f)&&!h&&e.mode&1)for(K=e,h=e.child;h!==null;){for(c=K=h;K!==null;){switch(u=K,x=u.child,u.tag){case 0:case 11:case 14:case 15:Ar(4,u,u.return);break;case 1:bl(u,u.return);var v=u.stateNode;if(typeof v.componentWillUnmount=="function"){r=u,l=u.return;try{t=r,v.props=t.memoizedProps,v.state=t.memoizedState,v.componentWillUnmount()}catch(m){ke(r,l,m)}}break;case 5:bl(u,u.return);break;case 22:if(u.memoizedState!==null){Bd(c);continue}}x!==null?(x.return=u,K=x):Bd(c)}h=h.sibling}e:for(h=null,c=e;;){if(c.tag===5){if(h===null){h=c;try{s=c.stateNode,f?(i=s.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(d=c.stateNode,p=c.memoizedProps.style,a=p!=null&&p.hasOwnProperty("display")?p.display:null,d.style.display=Lu("display",a))}catch(m){ke(e,e.return,m)}}}else if(c.tag===6){if(h===null)try{c.stateNode.nodeValue=f?"":c.memoizedProps}catch(m){ke(e,e.return,m)}}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;h===c&&(h=null),c=c.return}h===c&&(h=null),c.sibling.return=c.return,c=c.sibling}}break;case 19:Tt(t,e),Wt(e),r&4&&Nd(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(af(l)){var r=l;break e}l=l.return}throw Error(W(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Dr(s,""),r.flags&=-33);var i=Dd(e);fo(e,i,s);break;case 3:case 4:var a=r.stateNode.containerInfo,d=Dd(e);po(e,d,a);break;default:throw Error(W(161))}}catch(p){ke(e,e.return,p)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function fm(e,t,l){K=e,df(e)}function df(e,t,l){for(var r=(e.mode&1)!==0;K!==null;){var s=K,i=s.child;if(s.tag===22&&r){var a=s.memoizedState!==null||Cs;if(!a){var d=s.alternate,p=d!==null&&d.memoizedState!==null||qe;d=Cs;var f=qe;if(Cs=a,(qe=p)&&!f)for(K=s;K!==null;)a=K,p=a.child,a.tag===22&&a.memoizedState!==null?$d(s):p!==null?(p.return=a,K=p):$d(s);for(;i!==null;)K=i,df(i),i=i.sibling;K=s,Cs=d,qe=f}Wd(e)}else s.subtreeFlags&8772&&i!==null?(i.return=s,K=i):Wd(e)}}function Wd(e){for(;K!==null;){var t=K;if(t.flags&8772){var l=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:qe||Ii(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!qe)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&&Sd(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}Sd(t,a,l)}break;case 5:var d=t.stateNode;if(l===null&&t.flags&4){l=d;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 h=f.memoizedState;if(h!==null){var c=h.dehydrated;c!==null&&$r(c)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(W(163))}qe||t.flags&512&&uo(t)}catch(u){ke(t,t.return,u)}}if(t===e){K=null;break}if(l=t.sibling,l!==null){l.return=t.return,K=l;break}K=t.return}}function Bd(e){for(;K!==null;){var t=K;if(t===e){K=null;break}var l=t.sibling;if(l!==null){l.return=t.return,K=l;break}K=t.return}}function $d(e){for(;K!==null;){var t=K;try{switch(t.tag){case 0:case 11:case 15:var l=t.return;try{Ii(4,t)}catch(p){ke(t,l,p)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(p){ke(t,s,p)}}var i=t.return;try{uo(t)}catch(p){ke(t,i,p)}break;case 5:var a=t.return;try{uo(t)}catch(p){ke(t,a,p)}}}catch(p){ke(t,t.return,p)}if(t===e){K=null;break}var d=t.sibling;if(d!==null){d.return=t.return,K=d;break}K=t.return}}var hm=Math.ceil,hi=sn.ReactCurrentDispatcher,lc=sn.ReactCurrentOwner,St=sn.ReactCurrentBatchConfig,oe=0,Me=null,Ee=null,Qe=0,ft=0,Sl=En(0),Be=0,qr=null,Kn=0,Pi=0,rc=0,Rr=null,st=null,sc=0,Dl=1/0,Jt=null,gi=!1,ho=null,kn=null,zs=!1,mn=null,xi=0,Lr=0,go=null,Qs=-1,Gs=0;function tt(){return oe&6?ze():Qs!==-1?Qs:Qs=ze()}function _n(e){return e.mode&1?oe&2&&Qe!==0?Qe&-Qe:qx.transition!==null?(Gs===0&&(Gs=Gu()),Gs):(e=de,e!==0||(e=window.event,e=e===void 0?16:ep(e.type)),e):1}function Lt(e,t,l,r){if(50<Lr)throw Lr=0,go=null,Error(W(185));Vr(e,l,r),(!(oe&2)||e!==Me)&&(e===Me&&(!(oe&2)&&(Pi|=l),Be===4&&gn(e,Qe)),ct(e,r),l===1&&oe===0&&!(t.mode&1)&&(Dl=ze()+500,Ci&&An()))}function ct(e,t){var l=e.callbackNode;qg(e,t);var r=Vs(e,e===Me?Qe:0);if(r===0)l!==null&&Xc(l),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(l!=null&&Xc(l),t===1)e.tag===0?Jx(Ud.bind(null,e)):vp(Ud.bind(null,e)),Qx(function(){!(oe&6)&&An()}),l=null;else{switch(Yu(r)){case 1:l=Eo;break;case 4:l=Ku;break;case 16:l=Zs;break;case 536870912:l=Qu;break;default:l=Zs}l=yf(l,uf.bind(null,e))}e.callbackPriority=t,e.callbackNode=l}}function uf(e,t){if(Qs=-1,Gs=0,oe&6)throw Error(W(327));var l=e.callbackNode;if(Il()&&e.callbackNode!==l)return null;var r=Vs(e,e===Me?Qe:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=mi(e,r);else{t=r;var s=oe;oe|=2;var i=ff();(Me!==e||Qe!==t)&&(Jt=null,Dl=ze()+500,$n(e,t));do try{mm();break}catch(d){pf(e,d)}while(!0);Ho(),hi.current=i,oe=s,Ee!==null?t=0:(Me=null,Qe=0,t=Be)}if(t!==0){if(t===2&&(s=Ua(e),s!==0&&(r=s,t=xo(e,s))),t===1)throw l=qr,$n(e,0),gn(e,r),ct(e,ze()),l;if(t===6)gn(e,r);else{if(s=e.current.alternate,!(r&30)&&!gm(s)&&(t=mi(e,r),t===2&&(i=Ua(e),i!==0&&(r=i,t=xo(e,i))),t===1))throw l=qr,$n(e,0),gn(e,r),ct(e,ze()),l;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(W(345));case 2:Dn(e,st,Jt);break;case 3:if(gn(e,r),(r&130023424)===r&&(t=sc+500-ze(),10<t)){if(Vs(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){tt(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=Xa(Dn.bind(null,e,st,Jt),t);break}Dn(e,st,Jt);break;case 4:if(gn(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=ze()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*hm(r/1960))-r,10<r){e.timeoutHandle=Xa(Dn.bind(null,e,st,Jt),r);break}Dn(e,st,Jt);break;case 5:Dn(e,st,Jt);break;default:throw Error(W(329))}}}return ct(e,ze()),e.callbackNode===l?uf.bind(null,e):null}function xo(e,t){var l=Rr;return e.current.memoizedState.isDehydrated&&($n(e,t).flags|=256),e=mi(e,t),e!==2&&(t=st,st=l,t!==null&&mo(t)),e}function mo(e){st===null?st=e:st.push.apply(st,e)}function gm(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 gn(e,t){for(t&=~rc,t&=~Pi,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 Ud(e){if(oe&6)throw Error(W(327));Il();var t=Vs(e,0);if(!(t&1))return ct(e,ze()),null;var l=mi(e,t);if(e.tag!==0&&l===2){var r=Ua(e);r!==0&&(t=r,l=xo(e,r))}if(l===1)throw l=qr,$n(e,0),gn(e,t),ct(e,ze()),l;if(l===6)throw Error(W(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Dn(e,st,Jt),ct(e,ze()),null}function ic(e,t){var l=oe;oe|=1;try{return e(t)}finally{oe=l,oe===0&&(Dl=ze()+500,Ci&&An())}}function Qn(e){mn!==null&&mn.tag===0&&!(oe&6)&&Il();var t=oe;oe|=1;var l=St.transition,r=de;try{if(St.transition=null,de=1,e)return e()}finally{de=r,St.transition=l,oe=t,!(oe&6)&&An()}}function ac(){ft=Sl.current,ge(Sl)}function $n(e,t){e.finishedWork=null,e.finishedLanes=0;var l=e.timeoutHandle;if(l!==-1&&(e.timeoutHandle=-1,Kx(l)),Ee!==null)for(l=Ee.return;l!==null;){var r=l;switch(Uo(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&ri();break;case 3:Ll(),ge(at),ge(Ze),Jo();break;case 5:Xo(r);break;case 4:Ll();break;case 13:ge(be);break;case 19:ge(be);break;case 10:Ko(r.type._context);break;case 22:case 23:ac()}l=l.return}if(Me=e,Ee=e=Cn(e.current,null),Qe=ft=t,Be=0,qr=null,rc=Pi=Kn=0,st=Rr=null,Wn!==null){for(t=0;t<Wn.length;t++)if(l=Wn[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}Wn=null}return e}function pf(e,t){do{var l=Ee;try{if(Ho(),Ms.current=fi,pi){for(var r=Se.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}pi=!1}if(Hn=0,Fe=We=Se=null,Er=!1,Yr=0,lc.current=null,l===null||l.return===null){Be=1,qr=t,Ee=null;break}e:{var i=e,a=l.return,d=l,p=t;if(t=Qe,d.flags|=32768,p!==null&&typeof p=="object"&&typeof p.then=="function"){var f=p,h=d,c=h.tag;if(!(h.mode&1)&&(c===0||c===11||c===15)){var u=h.alternate;u?(h.updateQueue=u.updateQueue,h.memoizedState=u.memoizedState,h.lanes=u.lanes):(h.updateQueue=null,h.memoizedState=null)}var x=Td(a);if(x!==null){x.flags&=-257,Id(x,a,d,i,t),x.mode&1&&zd(i,f,t),t=x,p=f;var v=t.updateQueue;if(v===null){var m=new Set;m.add(p),t.updateQueue=m}else v.add(p);break e}else{if(!(t&1)){zd(i,f,t),oc();break e}p=Error(W(426))}}else if(ve&&d.mode&1){var z=Td(a);if(z!==null){!(z.flags&65536)&&(z.flags|=256),Id(z,a,d,i,t),Fo(Ol(p,d));break e}}i=p=Ol(p,d),Be!==4&&(Be=2),Rr===null?Rr=[i]:Rr.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var y=Yp(i,p,t);bd(i,y);break e;case 1:d=p;var o=i.type,g=i.stateNode;if(!(i.flags&128)&&(typeof o.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(kn===null||!kn.has(g)))){i.flags|=65536,t&=-t,i.lanes|=t;var j=Xp(i,d,t);bd(i,j);break e}}i=i.return}while(i!==null)}gf(l)}catch(b){t=b,Ee===l&&l!==null&&(Ee=l=l.return);continue}break}while(!0)}function ff(){var e=hi.current;return hi.current=fi,e===null?fi:e}function oc(){(Be===0||Be===3||Be===2)&&(Be=4),Me===null||!(Kn&268435455)&&!(Pi&268435455)||gn(Me,Qe)}function mi(e,t){var l=oe;oe|=2;var r=ff();(Me!==e||Qe!==t)&&(Jt=null,$n(e,t));do try{xm();break}catch(s){pf(e,s)}while(!0);if(Ho(),oe=l,hi.current=r,Ee!==null)throw Error(W(261));return Me=null,Qe=0,Be}function xm(){for(;Ee!==null;)hf(Ee)}function mm(){for(;Ee!==null&&!Fg();)hf(Ee)}function hf(e){var t=mf(e.alternate,e,ft);e.memoizedProps=e.pendingProps,t===null?gf(e):Ee=t,lc.current=null}function gf(e){var t=e;do{var l=t.alternate;if(e=t.return,t.flags&32768){if(l=dm(l,t),l!==null){l.flags&=32767,Ee=l;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Be=6,Ee=null;return}}else if(l=cm(l,t,ft),l!==null){Ee=l;return}if(t=t.sibling,t!==null){Ee=t;return}Ee=t=e}while(t!==null);Be===0&&(Be=5)}function Dn(e,t,l){var r=de,s=St.transition;try{St.transition=null,de=1,ym(e,t,l,r)}finally{St.transition=s,de=r}return null}function ym(e,t,l,r){do Il();while(mn!==null);if(oe&6)throw Error(W(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(W(177));e.callbackNode=null,e.callbackPriority=0;var i=l.lanes|l.childLanes;if(Zg(e,i),e===Me&&(Ee=Me=null,Qe=0),!(l.subtreeFlags&2064)&&!(l.flags&2064)||zs||(zs=!0,yf(Zs,function(){return Il(),null})),i=(l.flags&15990)!==0,l.subtreeFlags&15990||i){i=St.transition,St.transition=null;var a=de;de=1;var d=oe;oe|=4,lc.current=null,pm(e,l),cf(l,e),Wx(Ga),ei=!!Qa,Ga=Qa=null,e.current=l,fm(l),Mg(),oe=d,de=a,St.transition=i}else e.current=l;if(zs&&(zs=!1,mn=e,xi=s),i=e.pendingLanes,i===0&&(kn=null),Qg(l.stateNode),ct(e,ze()),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(gi)throw gi=!1,e=ho,ho=null,e;return xi&1&&e.tag!==0&&Il(),i=e.pendingLanes,i&1?e===go?Lr++:(Lr=0,go=e):Lr=0,An(),null}function Il(){if(mn!==null){var e=Yu(xi),t=St.transition,l=de;try{if(St.transition=null,de=16>e?16:e,mn===null)var r=!1;else{if(e=mn,mn=null,xi=0,oe&6)throw Error(W(331));var s=oe;for(oe|=4,K=e.current;K!==null;){var i=K,a=i.child;if(K.flags&16){var d=i.deletions;if(d!==null){for(var p=0;p<d.length;p++){var f=d[p];for(K=f;K!==null;){var h=K;switch(h.tag){case 0:case 11:case 15:Ar(8,h,i)}var c=h.child;if(c!==null)c.return=h,K=c;else for(;K!==null;){h=K;var u=h.sibling,x=h.return;if(sf(h),h===f){K=null;break}if(u!==null){u.return=x,K=u;break}K=x}}}var v=i.alternate;if(v!==null){var m=v.child;if(m!==null){v.child=null;do{var z=m.sibling;m.sibling=null,m=z}while(m!==null)}}K=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,K=a;else e:for(;K!==null;){if(i=K,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Ar(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,K=y;break e}K=i.return}}var o=e.current;for(K=o;K!==null;){a=K;var g=a.child;if(a.subtreeFlags&2064&&g!==null)g.return=a,K=g;else e:for(a=o;K!==null;){if(d=K,d.flags&2048)try{switch(d.tag){case 0:case 11:case 15:Ii(9,d)}}catch(b){ke(d,d.return,b)}if(d===a){K=null;break e}var j=d.sibling;if(j!==null){j.return=d.return,K=j;break e}K=d.return}}if(oe=s,An(),Ut&&typeof Ut.onPostCommitFiberRoot=="function")try{Ut.onPostCommitFiberRoot(bi,e)}catch{}r=!0}return r}finally{de=l,St.transition=t}}return!1}function Fd(e,t,l){t=Ol(l,t),t=Yp(e,t,1),e=wn(e,t,1),t=tt(),e!==null&&(Vr(e,1,t),ct(e,t))}function ke(e,t,l){if(e.tag===3)Fd(e,e,l);else for(;t!==null;){if(t.tag===3){Fd(t,e,l);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(kn===null||!kn.has(r))){e=Ol(l,e),e=Xp(t,e,1),t=wn(t,e,1),e=tt(),t!==null&&(Vr(t,1,e),ct(t,e));break}}t=t.return}}function vm(e,t,l){var r=e.pingCache;r!==null&&r.delete(t),t=tt(),e.pingedLanes|=e.suspendedLanes&l,Me===e&&(Qe&l)===l&&(Be===4||Be===3&&(Qe&130023424)===Qe&&500>ze()-sc?$n(e,0):rc|=l),ct(e,t)}function xf(e,t){t===0&&(e.mode&1?(t=ms,ms<<=1,!(ms&130023424)&&(ms=4194304)):t=1);var l=tt();e=ln(e,t),e!==null&&(Vr(e,t,l),ct(e,l))}function jm(e){var t=e.memoizedState,l=0;t!==null&&(l=t.retryLane),xf(e,l)}function bm(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(W(314))}r!==null&&r.delete(t),xf(e,l)}var mf;mf=function(e,t,l){if(e!==null)if(e.memoizedProps!==t.pendingProps||at.current)it=!0;else{if(!(e.lanes&l)&&!(t.flags&128))return it=!1,om(e,t,l);it=!!(e.flags&131072)}else it=!1,ve&&t.flags&1048576&&jp(t,ai,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ks(e,t),e=t.pendingProps;var s=El(t,Ze.current);Tl(t,l),s=Zo(null,t,r,e,s,l);var i=Vo();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,ot(r)?(i=!0,si(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Go(t),s.updater=Ti,t.stateNode=s,s._reactInternals=t,no(t,r,e,l),t=so(null,t,r,!0,i,l)):(t.tag=0,ve&&i&&$o(t),et(null,t,s,l),t=t.child),t;case 16:r=t.elementType;e:{switch(Ks(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=wm(r),e=It(r,e),s){case 0:t=ro(null,t,r,e,l);break e;case 1:t=Ad(null,t,r,e,l);break e;case 11:t=Pd(null,t,r,e,l);break e;case 14:t=Ed(null,t,r,It(r.type,e),l);break e}throw Error(W(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:It(r,s),ro(e,t,r,s,l);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:It(r,s),Ad(e,t,r,s,l);case 3:e:{if(Vp(t),e===null)throw Error(W(387));r=t.pendingProps,i=t.memoizedState,s=i.element,Cp(e,t),di(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=Ol(Error(W(423)),t),t=Rd(e,t,r,l,s);break e}else if(r!==s){s=Ol(Error(W(424)),t),t=Rd(e,t,r,l,s);break e}else for(ht=Sn(t.stateNode.containerInfo.firstChild),gt=t,ve=!0,Et=null,l=kp(t,null,r,l),t.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Al(),r===s){t=rn(e,t,l);break e}et(e,t,r,l)}t=t.child}return t;case 5:return zp(t),e===null&&Va(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,a=s.children,Ya(r,s)?a=null:i!==null&&Ya(r,i)&&(t.flags|=32),Zp(e,t),et(e,t,a,l),t.child;case 6:return e===null&&Va(t),null;case 13:return ef(e,t,l);case 4:return Yo(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Rl(t,null,r,l):et(e,t,r,l),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:It(r,s),Pd(e,t,r,s,l);case 7:return et(e,t,t.pendingProps,l),t.child;case 8:return et(e,t,t.pendingProps.children,l),t.child;case 12:return et(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,fe(oi,r._currentValue),r._currentValue=a,i!==null)if(Ot(i.value,a)){if(i.children===s.children&&!at.current){t=rn(e,t,l);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var d=i.dependencies;if(d!==null){a=i.child;for(var p=d.firstContext;p!==null;){if(p.context===r){if(i.tag===1){p=en(-1,l&-l),p.tag=2;var f=i.updateQueue;if(f!==null){f=f.shared;var h=f.pending;h===null?p.next=p:(p.next=h.next,h.next=p),f.pending=p}}i.lanes|=l,p=i.alternate,p!==null&&(p.lanes|=l),eo(i.return,l,t),d.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(W(341));a.lanes|=l,d=a.alternate,d!==null&&(d.lanes|=l),eo(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}et(e,t,s.children,l),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Tl(t,l),s=wt(s),r=r(s),t.flags|=1,et(e,t,r,l),t.child;case 14:return r=t.type,s=It(r,t.pendingProps),s=It(r.type,s),Ed(e,t,r,s,l);case 15:return Jp(e,t,t.type,t.pendingProps,l);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:It(r,s),Ks(e,t),t.tag=1,ot(r)?(e=!0,si(t)):e=!1,Tl(t,l),Gp(t,r,s),no(t,r,s,l),so(null,t,r,!0,e,l);case 19:return tf(e,t,l);case 22:return qp(e,t,l)}throw Error(W(156,t.tag))};function yf(e,t){return Hu(e,t)}function Sm(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 Sm(e,t,l,r)}function cc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function wm(e){if(typeof e=="function")return cc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===To)return 11;if(e===Io)return 14}return 2}function Cn(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 Ys(e,t,l,r,s,i){var a=2;if(r=e,typeof e=="function")cc(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case pl:return Un(l.children,s,i,t);case zo:a=8,s|=8;break;case Ca:return e=bt(12,l,t,s|2),e.elementType=Ca,e.lanes=i,e;case za:return e=bt(13,l,t,s),e.elementType=za,e.lanes=i,e;case Ta:return e=bt(19,l,t,s),e.elementType=Ta,e.lanes=i,e;case zu:return Ei(l,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case _u:a=10;break e;case Cu:a=9;break e;case To:a=11;break e;case Io:a=14;break e;case pn:a=16,r=null;break e}throw Error(W(130,e==null?e:typeof e,""))}return t=bt(a,l,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function Un(e,t,l,r){return e=bt(7,e,r,t),e.lanes=l,e}function Ei(e,t,l,r){return e=bt(22,e,r,t),e.elementType=zu,e.lanes=l,e.stateNode={isHidden:!1},e}function xa(e,t,l){return e=bt(6,e,null,t),e.lanes=l,e}function ma(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 km(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=qi(0),this.expirationTimes=qi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=qi(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function dc(e,t,l,r,s,i,a,d,p){return e=new km(e,t,l,d,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},Go(i),e}function _m(e,t,l){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ul,key:r==null?null:""+r,children:e,containerInfo:t,implementation:l}}function vf(e){if(!e)return Tn;e=e._reactInternals;e:{if(Xn(e)!==e||e.tag!==1)throw Error(W(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(ot(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(W(171))}if(e.tag===1){var l=e.type;if(ot(l))return yp(e,l,t)}return t}function jf(e,t,l,r,s,i,a,d,p){return e=dc(l,r,!0,e,s,i,a,d,p),e.context=vf(null),l=e.current,r=tt(),s=_n(l),i=en(r,s),i.callback=t??null,wn(l,i,s),e.current.lanes=s,Vr(e,s,r),ct(e,r),e}function Ai(e,t,l,r){var s=t.current,i=tt(),a=_n(s);return l=vf(l),t.context===null?t.context=l:t.pendingContext=l,t=en(i,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=wn(s,t,a),e!==null&&(Lt(e,s,a,i),Fs(e,s,a)),a}function yi(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 Md(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<t?l:t}}function uc(e,t){Md(e,t),(e=e.alternate)&&Md(e,t)}function Cm(){return null}var bf=typeof reportError=="function"?reportError:function(e){console.error(e)};function pc(e){this._internalRoot=e}Ri.prototype.render=pc.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(W(409));Ai(e,t,null,null)};Ri.prototype.unmount=pc.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Qn(function(){Ai(null,e,null,null)}),t[nn]=null}};function Ri(e){this._internalRoot=e}Ri.prototype.unstable_scheduleHydration=function(e){if(e){var t=qu();e={blockedOn:null,target:e,priority:t};for(var l=0;l<hn.length&&t!==0&&t<hn[l].priority;l++);hn.splice(l,0,e),l===0&&Vu(e)}};function fc(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Li(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Hd(){}function zm(e,t,l,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var f=yi(a);i.call(f)}}var a=jf(t,r,e,0,null,!1,!1,"",Hd);return e._reactRootContainer=a,e[nn]=a.current,Mr(e.nodeType===8?e.parentNode:e),Qn(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var d=r;r=function(){var f=yi(p);d.call(f)}}var p=dc(e,0,!1,null,null,!1,!1,"",Hd);return e._reactRootContainer=p,e[nn]=p.current,Mr(e.nodeType===8?e.parentNode:e),Qn(function(){Ai(t,p,l,r)}),p}function Oi(e,t,l,r,s){var i=l._reactRootContainer;if(i){var a=i;if(typeof s=="function"){var d=s;s=function(){var p=yi(a);d.call(p)}}Ai(t,a,e,s)}else a=zm(l,t,e,s,r);return yi(a)}Xu=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var l=wr(t.pendingLanes);l!==0&&(Ao(t,l|1),ct(t,ze()),!(oe&6)&&(Dl=ze()+500,An()))}break;case 13:Qn(function(){var r=ln(e,1);if(r!==null){var s=tt();Lt(r,e,1,s)}}),uc(e,1)}};Ro=function(e){if(e.tag===13){var t=ln(e,134217728);if(t!==null){var l=tt();Lt(t,e,134217728,l)}uc(e,134217728)}};Ju=function(e){if(e.tag===13){var t=_n(e),l=ln(e,t);if(l!==null){var r=tt();Lt(l,e,t,r)}uc(e,t)}};qu=function(){return de};Zu=function(e,t){var l=de;try{return de=e,t()}finally{de=l}};Wa=function(e,t,l){switch(t){case"input":if(Ea(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=_i(r);if(!s)throw Error(W(90));Iu(r),Ea(r,s)}}}break;case"textarea":Eu(e,l);break;case"select":t=l.value,t!=null&&kl(e,!!l.multiple,t,!1)}};Wu=ic;Bu=Qn;var Tm={usingClientEntryPoint:!1,Events:[ts,xl,_i,Du,Nu,ic]},or={findFiberByHostInstance:Nn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Im={bundleType:or.bundleType,version:or.version,rendererPackageName:or.rendererPackageName,rendererConfig:or.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:sn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Fu(e),e===null?null:e.stateNode},findFiberByHostInstance:or.findFiberByHostInstance||Cm,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 Ts=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ts.isDisabled&&Ts.supportsFiber)try{bi=Ts.inject(Im),Ut=Ts}catch{}}mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Tm;mt.createPortal=function(e,t){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!fc(t))throw Error(W(200));return _m(e,t,null,l)};mt.createRoot=function(e,t){if(!fc(e))throw Error(W(299));var l=!1,r="",s=bf;return t!=null&&(t.unstable_strictMode===!0&&(l=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=dc(e,1,!1,null,null,l,!1,r,s),e[nn]=t.current,Mr(e.nodeType===8?e.parentNode:e),new pc(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(W(188)):(e=Object.keys(e).join(","),Error(W(268,e)));return e=Fu(t),e=e===null?null:e.stateNode,e};mt.flushSync=function(e){return Qn(e)};mt.hydrate=function(e,t,l){if(!Li(t))throw Error(W(200));return Oi(null,e,t,!0,l)};mt.hydrateRoot=function(e,t,l){if(!fc(e))throw Error(W(405));var r=l!=null&&l.hydratedSources||null,s=!1,i="",a=bf;if(l!=null&&(l.unstable_strictMode===!0&&(s=!0),l.identifierPrefix!==void 0&&(i=l.identifierPrefix),l.onRecoverableError!==void 0&&(a=l.onRecoverableError)),t=jf(t,null,e,1,l??null,s,!1,i,a),e[nn]=t.current,Mr(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 Ri(t)};mt.render=function(e,t,l){if(!Li(t))throw Error(W(200));return Oi(null,e,t,!1,l)};mt.unmountComponentAtNode=function(e){if(!Li(e))throw Error(W(40));return e._reactRootContainer?(Qn(function(){Oi(null,null,e,!1,function(){e._reactRootContainer=null,e[nn]=null})}),!0):!1};mt.unstable_batchedUpdates=ic;mt.unstable_renderSubtreeIntoContainer=function(e,t,l,r){if(!Li(l))throw Error(W(200));if(e==null||e._reactInternals===void 0)throw Error(W(38));return Oi(e,t,l,!1,r)};mt.version="18.3.1-next-f1338f8080-20240426";function Sf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Sf)}catch(e){console.error(e)}}Sf(),bu.exports=mt;var Pm=bu.exports,wf,Kd=Pm;wf=Kd.createRoot,Kd.hydrateRoot;const re="",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"},Em=[{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"}],Am=[{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"}],Rm=new Set(["users"]);function Lm(e){return e!=="Admin"&&e!=="Auditor"?[]:Am.filter(({id:t})=>e==="Admin"||!Rm.has(t))}const un=(e=[])=>[{key:"name1",label:"Name"},{key:"status",label:"Status"},...e,{key:"creation_date",label:"Created On"}],Om={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:un(),defaultColumns:["name1","status","creation_date"]},"idea-types":{label:"Idea Types",columns:un(),defaultColumns:["name1","status","creation_date"]},"order-types":{label:"Order Types",columns:un(),defaultColumns:["name1","status","creation_date"]},"process-types":{label:"Process Types",columns:un(),defaultColumns:["name1","status","creation_date"]},"incident-statuses":{label:"Incident Statuses",columns:un([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"idea-statuses":{label:"Idea Statuses",columns:un([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"order-statuses":{label:"Order Statuses",columns:un([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"process-statuses":{label:"Process Statuses",columns:un([{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"]}},Dm="modulepreload",Nm=function(e){return"/"+e},Qd={},Wm=function(t,l,r){let s=Promise.resolve();if(l&&l.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),d=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(l.map(p=>{if(p=Nm(p),p in Qd)return;Qd[p]=!0;const f=p.endsWith(".css"),h=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${h}`))return;const c=document.createElement("link");if(c.rel=f?"stylesheet":Dm,f||(c.as="script"),c.crossOrigin="",c.href=p,d&&c.setAttribute("nonce",d),document.head.appendChild(c),f)return new Promise((u,x)=>{c.addEventListener("load",u),c.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${p}`)))})}))}function i(a){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=a,window.dispatchEvent(d),!d.defaultPrevented)throw a}return s.then(a=>{for(const d of a||[])d.status==="rejected"&&i(d.reason);return t().catch(i)})};function kf(e,t){const l=e[t.key];return l==null||l===""?"":typeof l=="object"?JSON.stringify(l):String(l)}function Bm(e,t){const l=URL.createObjectURL(e),r=document.createElement("a");r.href=l,r.download=t,r.click(),URL.revokeObjectURL(l)}function $m(e,t,l){const r=e.map(a=>`"${a.label.replace(/"/g,'""')}"`).join(","),s=t.map(a=>e.map(d=>`"${kf(a,d).replace(/"/g,'""')}"`).join(",")).join(`
|
||
`),i=new Blob([r+`
|
||
`+s],{type:"text/csv;charset=utf-8;"});Bm(i,`${l}.csv`)}async function Um(e,t,l){const r=await Wm(()=>import("./xlsx-D_0l8YDs.js"),[]),s=t.map(d=>{const p={};for(const f of e)p[f.label]=kf(d,f);return p}),i=r.utils.json_to_sheet(s,{header:e.map(d=>d.label)}),a=r.utils.book_new();r.utils.book_append_sheet(a,i,"Export"),r.writeFile(a,`${l}.xlsx`)}const Is="#16a34a";function Fm({title:e,rows:t,columns:l,defaultColumnKeys:r,orgField:s,organizations:i,filenameBase:a,onClose:d}){const[p,f]=S.useState(""),[h,c]=S.useState("csv"),[u,x]=S.useState(new Set(r)),v=p?t.filter(j=>j[s||"organization"]===p):t,m=l.filter(j=>u.has(j.key)),z=j=>{x(b=>{const w=new Set(b);return w.has(j)?w.delete(j):w.add(j),w})},y=async()=>{m.length===0||v.length===0||(h==="csv"?$m(m,v,a):await Um(m,v,a),d())},o={fontSize:11,fontWeight:700,color:"#9ca3af",letterSpacing:.4,textTransform:"uppercase",marginBottom:10},g={background:"none",border:"none",color:"#2563eb",fontSize:12,fontWeight:600,cursor:"pointer",padding:0,fontFamily:"inherit"};return n.jsx("div",{onClick:d,style:{position:"fixed",inset:0,background:"rgba(15,23,42,0.55)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},children:n.jsxs("div",{onClick:j=>j.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:Is,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:d,style:{background:"rgba(255,255,255,0.15)",border:"none",color:"white",width:28,height:28,borderRadius:8,cursor:"pointer",fontSize:15,lineHeight:1},children:"✕"})]}),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:o,children:"Filter by Organization"}),n.jsxs("select",{value:p,onChange:j=>f(j.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(j=>n.jsx("option",{value:j.name,children:j.organization_name||j.name},j.name))]})]}),n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:o,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(j=>n.jsxs("div",{onClick:()=>c(j.id),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",borderRadius:10,cursor:"pointer",border:`2px solid ${h===j.id?Is:"#e5e7eb"}`,background:h===j.id?"#f0fdf4":"white"},children:[n.jsx("span",{style:{fontSize:20},children:j.id==="csv"?"📄":"📊"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:j.label}),n.jsx("div",{style:{fontSize:11,color:"#888"},children:j.desc})]})]},j.id))})]}),n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[n.jsx("div",{style:{...o,marginBottom:0},children:"Columns to Export"}),n.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[n.jsx("button",{onClick:()=>x(new Set(l.map(j=>j.key))),style:g,children:"Select All"}),n.jsx("span",{style:{color:"#d1d5db"},children:"|"}),n.jsx("button",{onClick:()=>x(new Set(r)),style:g,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(j=>n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:7,fontSize:13,color:"#374151",cursor:"pointer"},children:[n.jsx("input",{type:"checkbox",checked:u.has(j.key),onChange:()=>z(j.key),style:{accentColor:Is,cursor:"pointer"}}),j.label]},j.key))})}),n.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:6},children:[u.size," column",u.size!==1?"s":""," selected"]})]})]}),n.jsxs("div",{style:{padding:"14px 22px",borderTop:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[n.jsx("span",{style:{fontSize:12,color:"#888"},children:p?`Exporting ${v.length} filtered row${v.length!==1?"s":""}`:`Exporting all ${v.length} row${v.length!==1?"s":""}`}),n.jsxs("div",{style:{display:"flex",gap:10},children:[n.jsx("button",{onClick:d,style:{padding:"9px 18px",borderRadius:8,border:"1px solid #e5e7eb",background:"white",color:"#374151",fontWeight:600,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:"Cancel"}),n.jsx("button",{onClick:y,disabled:m.length===0||v.length===0,style:{padding:"9px 20px",borderRadius:8,border:"none",background:Is,color:"white",fontWeight:700,fontSize:13,cursor:m.length===0||v.length===0?"not-allowed":"pointer",opacity:m.length===0||v.length===0?.5:1,fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"})]})]})]})})}function _f({collapsed:e,onToggleCollapsed:t,activePage:l,onNavigate:r,hasDashboard:s,hasReports:i,hasDelegations:a,role:d,hideSettings:p,rtl:f,navLabels:h,settingsLabel:c}){const u=p?[]:Lm(d);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:[Em.filter(({id:x})=>(x!=="dashboard"||s)&&(x!=="reports"||i)&&(x!=="delegations"||a)).map(({id:x,icon:v})=>{const m=h[x]||x,z=x===l;return n.jsxs("div",{onClick:()=>r(x),title:e?m:void 0,style:{padding:e?"8px 0":"8px 14px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:9,background:z?"rgba(139,92,246,0.28)":"transparent",borderRadius:8,fontSize:e?15:12,color:"white",fontWeight:z?600:400,transition:"all 0.15s",whiteSpace:"nowrap",marginBottom:2},children:[n.jsx("span",{style:{flexShrink:0},children:v}),!e&&m]},x)}),u.length>0&&n.jsxs(n.Fragment,{children:[!e&&n.jsx("div",{style:{padding:"10px 14px 4px",fontSize:10,color:"rgba(255,255,255,0.6)",fontWeight:700,letterSpacing:1,textTransform:"uppercase",marginTop:8},children:c}),e&&n.jsx("div",{style:{margin:"10px auto",width:28,borderTop:"1px solid rgba(255,255,255,0.12)"}}),u.map(({id:x,icon:v})=>{const m=h[x]||x,z=x===l;return n.jsxs("div",{onClick:()=>r(x),title:e?m:void 0,style:{padding:e?"8px 0":"8px 14px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:9,background:z?"rgba(139,92,246,0.25)":"transparent",borderRadius:8,fontSize:e?15:12,color:"white",fontWeight:z?600:400,transition:"all 0.15s",whiteSpace:"nowrap",marginBottom:2},children:[n.jsx("span",{style:{flexShrink:0},children:v}),!e&&m]},x)})]})]})]})}const Cf="sidrah_rtl",yo="sidrah-lang-change";function wl(){try{return localStorage.getItem(Cf)==="1"}catch{return!1}}function zf(){const e=!wl();try{localStorage.setItem(Cf,e?"1":"0")}catch{}document.documentElement.setAttribute("dir",e?"rtl":"ltr"),document.documentElement.setAttribute("lang",e?"ar":"en-GB"),window.dispatchEvent(new CustomEvent(yo))}function J(){const[e,t]=S.useState(wl);return S.useEffect(()=>{const l=()=>t(wl());return window.addEventListener(yo,l),document.documentElement.setAttribute("dir",wl()?"rtl":"ltr"),document.documentElement.setAttribute("lang",wl()?"ar":"en-GB"),()=>window.removeEventListener(yo,l)},[]),e?Hm:Mm}const Mm={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"}},Hm={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:"بواسطة"}},ls=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 Gn="";async function hc(){try{const e=await fetch(`${re}/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 Gn=l,l}}catch(e){console.error("CSRF fetch error:",e)}return Gn}async function an(){return Gn||await hc(),Gn}function Gd(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(ls.has(e)){const a=`${re}/api/method/sidrah_business.api.get_sb_doc?doctype=${encodeURIComponent(e)}&name=${encodeURIComponent(t)}`,d=await fetch(a,{credentials:"include",headers:{Accept:"application/json"}});if(!d.ok)throw new Error(`API Error: ${d.status}`);return(await d.json()).message}const r=l.length?`?fields=${encodeURIComponent(JSON.stringify(l))}`:"",s=await fetch(`${re}/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 Tf(e,t){const l=await an();if(ls.has(e)){const s=new URLSearchParams({doctype:e,name:t}),i=await fetch(`${re}/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(Gd(a,`Error deleting ${t}`))}return}const r=await fetch(`${re}/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(Gd(s,`Error deleting ${t}`))}return await r.json()}async function ye(e){if(ls.has(e))try{const r=`${re}/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=`${re}/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 ya(e,t){const l=await an();if(ls.has(e)){const s=new URLSearchParams({doctype:e,data_json:JSON.stringify(t)}),i=await fetch(`${re}/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 d=await i.json().catch(()=>({}));throw new Error(d.message||d.exc||`Error creating ${e}`)}return{data:(await i.json()).message}}const r=`${re}/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 vi(e,t,l){const r=await an();if(ls.has(e)){const i=new URLSearchParams({doctype:e,name:t,data_json:JSON.stringify(l)}),a=await fetch(`${re}/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=`${re}/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 Km(){const e=`${re}/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 Qm(e,t){const l=new FormData;l.append("usr",e),l.append("pwd",t);const s=await(await fetch(`${re}/api/method/login`,{method:"POST",credentials:"include",body:l})).json();return s.csrf_token?Gn=s.csrf_token:await hc(),s}async function Gm(){const e=await an();try{await fetch(`${re}/api/method/logout`,{method:"POST",credentials:"include",headers:{"X-Frappe-CSRF-Token":e,Accept:"application/json"}})}catch{}Gn=""}function Ym(){return Gn}async function If(){try{const e=await fetch(`${re}/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 Xm(){const e=JSON.stringify([["name","not in",["Administrator","Guest"]]]),t=`${re}/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 Jm(){const e=`${re}/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 Pf(e,t){await vi("User",e,{new_password:t})}async function qm(e=20){try{const t=`${re}/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 Zm(){const e=await an();try{await fetch(`${re}/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 Vm(e){const t=await an();try{await fetch(`${re}/api/method/sidrah_business.api.mark_notification_read`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":t},body:new URLSearchParams({name:e}).toString()})}catch{}}async function ey(e){const t=await an(),l=new URLSearchParams({name:e});await fetch(`${re}/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 ty(e,t){try{const l=`${re}/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 ny(e,t,l){const r=await an(),s=new URLSearchParams({doctype:e,docname:t,content:l}),i=await fetch(`${re}/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 ly(e,t){try{const l=`${re}/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 Ef(e){try{const t=`${re}/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 Jn(e,t={}){const l=await an(),r=new URLSearchParams(t),s=await fetch(`${re}/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 ry(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),Jn("apply_order_workflow",a)}async function sy(e,t,l=""){return Jn("apply_incident_workflow",{name:e,action:t,fields_json:l})}async function iy(e,t,l=""){return Jn("apply_idea_workflow",{name:e,action:t,fields_json:l})}async function ay(e=""){const t=`${re}/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 oy(e,t={}){return Jn("get_report_data",{report_name:e,filters_json:JSON.stringify(t)})}async function cy(){try{const e=`${re}/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 dy(e,t,l="",r=""){return Jn("create_delegation",{manager:e,functions_json:JSON.stringify(t),organization:l,remarks:r})}async function uy(e,t,l=""){return Jn("respond_to_delegation",{name:e,response:t,remarks:l})}async function py(e,t=""){return Jn("revoke_delegation",{name:e,remarks:t})}async function fy(){try{const e=`${re}/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 hy(e){const t=`${re}/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 gy(){try{const e=`${re}/api/method/sidrah_business.api.get_my_delegated_functions`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function xy(){try{const e=`${re}/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 my(){const e=Ym();return e||hc()}async function _r(e){const t=await fetch(`${re}/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 yy(e,t,l={}){const r=await my(),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(`${re}/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 d=await i.json().catch(()=>({})),p=d.message||(d.exception?String(d.exception).split(`
|
||
`).pop():"")||d.exc_type||`Workflow action "${t}" failed (${i.status})`;throw new Error(p)}const a=await i.json();return a.message||a.data}function vy({onLogin:e}){const t=J(),[l,r]=S.useState(""),[s,i]=S.useState(""),[a,d]=S.useState(""),[p,f]=S.useState(!1),[h,c]=S.useState(!1),[u,x]=S.useState(!1),v=async()=>{if(!l||!s){d(t.login.emptyFields);return}f(!0),d("");try{const z=await Qm(l,s);if(z.message==="Logged In"){const o=await If()||l,g=await Ef(o),j=g.some(b=>["SB Admin","System Manager"].includes(b))?"Admin":g.includes("SB Auditor")?"Auditor":g.includes("SB Owner")?"Owner":g.includes("SB X-Auditor")?"XAuditor":g.includes("SB Manager")?"Manager":"Employee";e({name:o,full_name:z.full_name||l,role:j})}else d(t.login.invalidCreds)}catch(z){d(t.login.connError+(z instanceof Error?z.message:"Unknown"))}f(!1)},m=z=>({width:"100%",padding:"13px 16px",border:`1.5px solid ${z?"#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:z?"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:z=>r(z.target.value),onKeyDown:z=>z.key==="Enter"&&v(),onFocus:()=>c(!0),onBlur:()=>c(!1),style:m(h),placeholder:t.login.usernamePlaceholder,autoComplete:"username"}),n.jsx("input",{type:"password",value:s,onChange:z=>i(z.target.value),onKeyDown:z=>z.key==="Enter"&&v(),onFocus:()=>x(!0),onBlur:()=>x(!1),style:m(u),placeholder:t.login.passwordPlaceholder,autoComplete:"current-password"}),a&&n.jsx("div",{style:{padding:"10px 14px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:8,color:"#dc2626",fontSize:13},children:a}),n.jsx("button",{onClick:v,disabled: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:z=>{p||(z.currentTarget.style.background="#4338ca")},onMouseLeave:z=>{p||(z.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:zf,style:{fontSize:12,color:"#9ca3af",background:"none",border:"none",cursor:"pointer"},children:t.switchLang})})]})})}function jy(e,t){const l=parseInt(e.replace("#",""),16),r=l>>16&255,s=l>>8&255,i=l&255,a=d=>Math.round(d+(255-d)*t);return`rgb(${a(r)}, ${a(s)}, ${a(i)})`}function Ps({title:e,data:t,color:l}){const[,r]=t[0]??["Total",0],s=t.slice(1),i=Math.max(...s.map(([,d])=>d),1),a=jy(l,.85);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:r})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:s.map(([d,p])=>n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:8},children:[n.jsx("span",{style:{fontSize:12,color:"#64748b",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#334155",flexShrink:0},children:p})]}),n.jsx("div",{style:{height:6,borderRadius:3,background:a,overflow:"hidden"},children:n.jsx("div",{style:{height:"100%",width:`${p?Math.max(p/i*100,4):0}%`,borderRadius:3,background:l,transition:"width 0.25s ease"}})})]},d))})]})}function _t({value:e,onChange:t,organizations:l,placeholder:r="-- Choose organization --",disabled:s=!1,small:i=!1}){var c;const[a,d]=S.useState(!1),p=S.useRef(null);S.useEffect(()=>{const u=x=>{p.current&&!p.current.contains(x.target)&&d(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]);const f=e?((c=l.find(u=>u.organization_name===e||u.name===e))==null?void 0:c.organization_name)??e:r,h=l.filter(u=>!!u.is_active||u.organization_name===e||u.name===e);return n.jsxs("div",{ref:p,style:{position:"relative",width:"100%"},children:[n.jsxs("div",{onClick:()=>!s&&d(u=>!u),style:{width:"100%",padding:i?"4px 8px":"10px 14px",border:"1px solid #d1d5db",borderRadius:6,fontSize:i?11:14,cursor:s?"default":"pointer",height:i?28:void 0,background:s?"#f5f5f5":"white",color:e?"#333":"#aaa",display:"flex",justifyContent:"space-between",alignItems:"center",borderColor:a?"#3498db":"#d1d5db",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:i?9:10,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(Yd,{label:r,selected:!e,active:!0,isPlaceholder:!0,small:i,onClick:()=>{t(""),d(!1)}}),h.length===0&&n.jsx("div",{style:{padding:"12px 16px",color:"#aaa",fontSize:13},children:"No organizations"}),h.map(u=>n.jsx(Yd,{label:u.organization_name,selected:e===u.organization_name||e===u.name,active:!!u.is_active,isPlaceholder:!1,small:i,onClick:()=>{t(u.organization_name),d(!1)}},u.name))]})})]})}function Yd({label:e,selected:t,active:l,isPlaceholder:r,small:s,onClick:i}){const[a,d]=S.useState(!1),p=t?"#2563eb":a?"#f0f4ff":"transparent",f=t?"white":r?"#aaa":l?"#1a2332":"#e74c3c";return n.jsx("div",{onClick:i,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),style:{padding:s?"6px 12px":"10px 16px",cursor:"pointer",fontSize:s?12:14,background:p,color:f,transition:"background 0.1s"},children:e})}function yn({items:e,type:t,onNavigate:l}){const r=J();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 by({kpi:e}){const t=J();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 Sy({data:e}){if(!e.length)return n.jsx("p",{style:{color:"#aaa",fontSize:13},children:"No cycle data available for trend chart."});const t=Math.max(...e.map(r=>r.pass+r.fail+r.unknown),1),l=r=>r.replace(/^(\d{4})-(\d{2})$/,(s,i,a)=>`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][+a-1]} ${i}`);return n.jsxs("div",{children:[n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:e.map(r=>{const s=r.pass+r.fail+r.unknown,i=[["Pass",r.pass,"#27ae60"],["Fail",r.fail,"#e74c3c"],["Unknown",r.unknown,"#95a5a6"]].filter(([,p])=>p>0),a=s?Math.round(r.pass/s*100):null,d=s?Math.max(s/t*100,4):0;return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[n.jsx("div",{style:{width:62,flexShrink:0,fontSize:11,color:"#888",textAlign:"right"},children:l(r.month)}),n.jsx("div",{style:{flex:1,height:14,borderRadius:7,background:"#f1f5f9"},children:s>0&&n.jsx("div",{style:{width:`${d}%`,height:"100%",borderRadius:7,overflow:"hidden",display:"flex"},children:i.map(([p,f,h],c)=>n.jsx("div",{title:`${p}: ${f}`,style:{flex:`${f} 0 0`,background:h,borderRight:c<i.length-1?"2px solid #f1f5f9":"none"}},p))})}),n.jsx("div",{style:{width:38,flexShrink:0,fontSize:11,fontWeight:700,color:"#555",textAlign:"right"},children:a!=null?`${a}%`:"—"})]},r.month)})}),n.jsx("div",{style:{display:"flex",gap:16,marginTop:14},children:[["#27ae60","Pass"],["#e74c3c","Fail"],["#95a5a6","Unknown"]].map(([r,s])=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,fontSize:11},children:[n.jsx("div",{style:{width:10,height:10,background:r,borderRadius:2}}),n.jsx("span",{style:{color:"#666"},children:s})]},s))})]})}function 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 wy({dashData:e,fi:t,fid:l,fo:r,fp:s,incidentStatuses:i,ideaStatuses:a,orderStatuses:d,processStatuses:p,onNavigate:f}){const h=J(),c=(e==null?void 0:e.escalated_processes)||[],u=(e==null?void 0:e.escalated_orders)||[],x=(e==null?void 0:e.attention_processes)||[],v=(e==null?void 0:e.attention_orders)||[],m=(e==null?void 0:e.untriaged_incidents)||[],z=(e==null?void 0:e.overdue_triage)||[],y=c.length>0||u.length>0,o=x.length>0||v.length>0,g=[["Total",t.length],...i.map(k=>[k.name1||k.name,t.filter(C=>C.status===k.name).length])],j=[["Total",l.length],...a.map(k=>[k.name1||k.name,l.filter(C=>C.status===k.name).length])],b=[["Total",r.length],...d.map(k=>[k.name1||k.name,r.filter(C=>C.status===k.name).length])],w=[["Total",s.length],...p.map(k=>[k.name1||k.name,s.filter(C=>C.status===k.name).length])];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(Ps,{title:h.dash.incidents,color:N.orange,data:g})}),n.jsx("div",{onClick:()=>f("ideas"),style:{cursor:"pointer"},children:n.jsx(Ps,{title:h.dash.ideas,color:N.blue,data:j})}),n.jsx("div",{onClick:()=>f("orders"),style:{cursor:"pointer"},children:n.jsx(Ps,{title:h.dash.orders,color:N.purple,data:b})}),n.jsx("div",{onClick:()=>f("processes"),style:{cursor:"pointer"},children:n.jsx(Ps,{title:h.dash.processes,color:N.red,data:w})})]}),y&&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:h.dash.level2}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(yn,{items:c,type:"process",onNavigate:f}),n.jsx(yn,{items:u,type:"order",onNavigate:f})]})]}),o&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#b45309",marginBottom:10},children:h.dash.level1}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(yn,{items:x,type:"process",onNavigate:f}),n.jsx(yn,{items:v,type:"order",onNavigate:f})]})]}),z.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:[h.dash.overduePrefix,z.length,h.dash.overdueSuffix]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:z.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))})]}),m.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:[h.dash.untriaged," (",m.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:m.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 ky({dashData:e,selectedOrg:t,onNavigate:l}){const r=J(),[s,i]=S.useState([]),[a,d]=S.useState([]),[p,f]=S.useState(!1),h=(e==null?void 0:e.escalated_processes)||[],c=(e==null?void 0:e.escalated_orders)||[],u=(e==null?void 0:e.attention_processes)||[],x=(e==null?void 0:e.attention_orders)||[],v=(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(o=>o.json()).then(o=>{const g=o.message||[],j={};for(const b of g)j[b.month]||(j[b.month]={pass:0,fail:0,unknown:0}),b.status==="Pass"?j[b.month].pass=b.count:b.status==="Fail"?j[b.month].fail=b.count:b.status==="Unknown"&&(j[b.month].unknown=b.count);i(Object.entries(j).map(([b,w])=>({month:b,...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 o;d((((o=y.message)==null?void 0:o.rows)||[]).slice(0,50))}).catch(()=>{})},[t]);const m=h.length>0||c.length>0,z=u.length>0||x.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")})]}),v.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:10},children:r.dash.recentKpi}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12},children:v.map(y=>n.jsx(by,{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})]}),m&&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 (",h.length+c.length,")"]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(yn,{items:h,type:"process",onNavigate:l}),n.jsx(yn,{items:c,type:"order",onNavigate:l})]})]}),z&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#b45309",marginBottom:10},children:["Needs Attention — Level 1 (",u.length+x.length,")"]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(yn,{items:u,type:"process",onNavigate:l}),n.jsx(yn,{items:x,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(Sy,{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,o)=>n.jsxs("tr",{style:{borderTop:"1px solid #f0f0f0",background:o%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||"—"})]},o))})]})}),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 _y({incidents:e,ideas:t,orders:l,processes:r,organizations:s,incidentStatuses:i,ideaStatuses:a,orderStatuses:d,processStatuses:p,selectedOrg:f,onOrgChange:h,onNavigate:c,userRole:u}){const[x,v]=S.useState(null);S.useEffect(()=>{ay(f).then(v)},[f]);const m=f?e.filter(C=>C.organization===f):e,z=f?t.filter(C=>C.organization===f):t,y=f?l.filter(C=>C.organization===f):l,o=f?r.filter(C=>C.organization===f):r,g=u==="Admin",j=u==="Owner",[b,w]=S.useState("level2"),k=j||g&&b==="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:h,organizations:s,placeholder:"All Organizations",small:!0})}),g&&n.jsx("div",{style:{display:"flex",background:"#f1f0fe",borderRadius:7,padding:2,gap:2,flexShrink:0},children:["level1","level2"].map(C=>n.jsx("button",{onClick:()=>w(C),style:{padding:"4px 10px",borderRadius:5,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:b===C?C==="level2"?N.purple:N.blue:"transparent",color:b===C?"white":"#6b7280",transition:"all 0.15s"},children:C==="level1"?"Level 1":"Level 2"},C))}),!g&&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(ky,{dashData:x,selectedOrg:f,onNavigate:c}):n.jsx(wy,{dashData:x,fi:m,fid:z,fo:y,fp:o,incidentStatuses:i,ideaStatuses:a,orderStatuses:d,processStatuses:p,onNavigate:c})]})}const Cy=()=>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"})]}),zy=()=>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"})]}),Ty=()=>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 He({onView:e,onEdit:t,onDelete:l}){const[r,s]=S.useState(!1),i=(d,p,f,h,c)=>f?n.jsx("button",{onClick:u=>{u.stopPropagation(),f()},title:c,style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:d,color:p,flexShrink:0,transition:"opacity 0.15s"},onMouseEnter:u=>u.currentTarget.style.opacity="0.75",onMouseLeave:u=>u.currentTarget.style.opacity="1",children:h},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(Cy,{}),"View"),i("#dcfce7","#16a34a",t,n.jsx(zy,{}),"Edit"),l&&n.jsx("button",{onClick:d=>{d.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:d=>d.currentTarget.style.opacity="0.8",onMouseLeave:d=>d.currentTarget.style.opacity="1",onBlur:()=>s(!1),children:r?"✓ Sure?":n.jsx(Ty,{})})]})}const E={width:"100%",padding:"10px 12px",border:"1px solid #ddd",borderRadius:6,fontSize:14,boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif"},T={display:"block",marginBottom:6,fontSize:13,color:"#555",fontWeight:600};function Iy(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 ce(e,t){return e.filter(l=>Iy(l)||l.name===t)}function Nl(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 Wl={width:16,height:16,cursor:"pointer",accentColor:"#2563eb",flexShrink:0},In=(e,t)=>n.jsx("span",{style:{background:t,color:"white",padding:"4px 12px",borderRadius:12,fontSize:12,fontWeight:600,display:"inline-block"},children:e}),Di=e=>{switch(e){case"New":return"#e74c3c";case"Under Progress":return"#f39c12";case"Executed":return"#27ae60";case"Overdue":return"#7f1d1d";default:return"#95a5a6"}},Ae={fontSize:10,color:"#6b7280",fontWeight:600,marginBottom:3,display:"block",textTransform:"uppercase",letterSpacing:.4},Re={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 Ni({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,Xd=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 Le({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:Xd(e<=1),children:"Previous"}),n.jsx("button",{disabled:e>=s,onClick:()=>r(e+1),style:Xd(e>=s),children:"Next"})]})]})}function Py({incidents:e,organizations:t,departments:l,branches:r,incidentStatuses:s,initialOrg:i,canModify:a,onView:d,onEdit:p,onDelete:f}){const h=J(),[c,u]=S.useState({search:"",organization:i||"",department:"",branch:"",status:""}),x=(o,g)=>u(j=>({...j,[o]:g})),[v,m]=S.useState(1),z=e.filter(o=>!(c.search&&!`${o.number} ${o.title}`.toLowerCase().includes(c.search.toLowerCase())||c.organization&&o.organization!==c.organization||c.department&&o.department!==c.department||c.branch&&o.branch!==c.branch||c.status&&o.status!==c.status));S.useEffect(()=>{m(1)},[c]);const y=z.slice((v-1)*te,v*te);return n.jsxs(n.Fragment,{children:[n.jsx(Ni,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.numberTitle}),n.jsx("input",{style:Re,value:c.search,onChange:o=>x("search",o.target.value),placeholder:h.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.organization}),n.jsxs("select",{style:Re,value:c.organization,onChange:o=>x("organization",o.target.value),children:[n.jsx("option",{value:"",children:h.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.department}),n.jsxs("select",{style:Re,value:c.department,onChange:o=>x("department",o.target.value),children:[n.jsx("option",{value:"",children:h.filter.allDepts}),l.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.branch}),n.jsxs("select",{style:Re,value:c.branch,onChange:o=>x("branch",o.target.value),children:[n.jsx("option",{value:"",children:h.filter.allBranches}),r.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.status}),n.jsxs("select",{style:Re,value:c.status,onChange:o=>x("status",o.target.value),children:[n.jsx("option",{value:"",children:h.filter.allStatuses}),s.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>u({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:h.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:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.number}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.title}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.organization}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.type}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.status}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.actions})]})}),n.jsx("tbody",{children:z.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:h.noIncidents})}):y.map((o,g)=>n.jsxs("tr",{onClick:()=>d==null?void 0:d(o),style:{borderTop:"1px solid #f0f0f0",background:g%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",color:"#999"},children:o.number||"—"}),n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:o.title||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:o.type?In(o.type,"#e74c3c"):"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:o.status?In(o.status,Di(o.status)):"—"}),n.jsx("td",{style:{padding:"10px 18px"},onClick:j=>j.stopPropagation(),children:n.jsx(He,{onView:()=>d==null?void 0:d(o),onEdit:a&&p?()=>p(o):void 0,onDelete:a&&f?()=>f(o.name):void 0})})]},o.name))})]})}),n.jsx(Le,{page:v,total:z.length,onPageChange:m})]})}function Ey(e){if(!e)return"";const[t,l,r]=e.split("-");return!t||!l||!r?"":`${r}/${l}/${t}`}function ue({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:Ey(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 Ay({title:e,children:t}){return n.jsxs("div",{style:{background:"white",borderRadius:10,padding:"22px 24px",marginBottom:16,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[e&&n.jsx("div",{style:{fontSize:18,fontWeight:700,marginBottom:20,color:"#1e1b4b"},children:e}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:16},children:t})]})}function Oe({title:e,activePage:t,user:l,formStatus:r,buttonText:s,buttonColor:i,viewMode:a,hideSettings:d,rightPanel:p,onSubmit:f,onBack:h,onNavigate:c,onLogout:u,children:x}){const v=J(),m=v.nav[t]||t,z=(l.full_name||l.name||"U").charAt(0).toUpperCase(),y=l.role,o=y==="Admin"||y==="Owner"||y==="Auditor"||y==="Manager",g=y==="Admin"||y==="Owner"||y==="Auditor"||y==="Manager",j=y==="Admin"||y==="Auditor"||y==="Manager",b=o?"dashboard":"inbox",[w,k]=S.useState(()=>localStorage.getItem("sb_sidebar")==="1"),C=()=>k(X=>{const $=!X;return localStorage.setItem("sb_sidebar",$?"1":"0"),$}),[O,U]=S.useState(!1),Q=S.useRef(null);return S.useEffect(()=>{const X=$=>{Q.current&&!Q.current.contains($.target)&&U(!1)};return document.addEventListener("mousedown",X),()=>document.removeEventListener("mousedown",X)},[]),n.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:N.bg},children:[n.jsx(_f,{collapsed:w,onToggleCollapsed:C,activePage:t,onNavigate:c,hasDashboard:o,hasReports:g,hasDelegations:j,role:y,hideSettings:d,rtl:v.rtl,navLabels:v.nav,settingsLabel:v.nav.settings}),n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[n.jsxs("div",{style:{background:"white",padding:"12px 24px",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:12},children:[n.jsx("button",{onClick:h,title:v.back,style:{width:34,height:34,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:"16",height:"16",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:18,fontWeight:700,color:"#1e1b4b"},children:e}),n.jsxs("div",{style:{fontSize:12,color:"#9ca3af",marginTop:1},children:[n.jsx("span",{onClick:()=>c(b),style:{cursor:"pointer",color:"#4f46e5"},onMouseEnter:X=>X.currentTarget.style.textDecoration="underline",onMouseLeave:X=>X.currentTarget.style.textDecoration="none",children:v.home}),!d&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{margin:"0 4px"},children:"/"}),n.jsx("span",{onClick:h,style:{cursor:"pointer",color:"#4f46e5"},onMouseEnter:X=>X.currentTarget.style.textDecoration="underline",onMouseLeave:X=>X.currentTarget.style.textDecoration="none",children:m})]})]})]})]}),n.jsxs("div",{ref:Q,style:{position:"relative"},children:[n.jsxs("div",{onClick:()=>U(X=>!X),style:{display:"flex",alignItems:"center",gap:10,cursor:"pointer",padding:"4px 8px",borderRadius:8,transition:"background 0.15s",background:O?"#f3f4f6":"transparent"},onMouseEnter:X=>X.currentTarget.style.background="#f3f4f6",onMouseLeave:X=>{O||(X.currentTarget.style.background="transparent")},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end"},children:[n.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:l.full_name||l.name}),n.jsx("div",{style:{fontSize:11,color:"#9ca3af"},children:y})]}),n.jsx("div",{style:{width:34,height:34,borderRadius:"50%",background:"#4f46e5",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:700,flexShrink:0},children:z})]}),O&&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:y})]}),n.jsxs("button",{onClick:()=>{U(!1),u()},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:X=>X.currentTarget.style.background="#fef2f2",onMouseLeave:X=>X.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:p?"1fr auto":"1fr",gap:14,alignItems:"start"},children:[n.jsx("div",{style:{minWidth:0},children:n.jsxs(Ay,{children:[x,!a&&n.jsxs("div",{style:{display:"flex",gap:12,marginTop:24},children:[n.jsx("button",{onClick:h,style:{padding:"11px 26px",borderRadius:8,border:"1.5px solid #e5e7eb",cursor:"pointer",fontSize:14,fontWeight:600,background:"white",color:"#374151",fontFamily:"Segoe UI"},children:v.cancel}),n.jsx("button",{onClick:f,disabled:r==="loading",style:{padding:"11px 26px",borderRadius:8,background:i,color:"white",border:"none",cursor:"pointer",fontSize:14,fontWeight:600,opacity:r==="loading"?.7:1,boxShadow:"0 2px 10px rgba(79,70,229,0.18)",fontFamily:"Segoe UI"},children:r==="loading"?v.saving:s})]}),r==="success"&&n.jsx("div",{style:{padding:"12px",borderRadius:8,background:"#f0fdf4",border:"1px solid #86efac",color:"#166534",fontSize:14,marginTop:12},children:v.savedOk}),r!=="idle"&&r!=="loading"&&r!=="success"&&n.jsx("div",{style:{padding:"12px",borderRadius:8,background:"#fef2f2",border:"1px solid #fca5a5",color:"#991b1b",fontSize:14,marginTop:12},children:r})]})}),p&&n.jsx("div",{style:{position:"sticky",top:20,alignSelf:"start"},children:p})]})]})]})}function ae({value:e,onChange:t,items:l,placeholder:r="-- Select --",disabled:s=!1}){var c;const[i,a]=S.useState(!1),[d,p]=S.useState(""),f=S.useRef(null);S.useEffect(()=>{const u=x=>{f.current&&!f.current.contains(x.target)&&a(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]);const h=e?((c=l.find(u=>u.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(u=>!u),style:{width:"100%",padding:"10px 14px",border:"1px solid",borderColor:i?"#3498db":"#e0e0e0",borderRadius:6,fontSize:14,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:h}),n.jsx("span",{style:{fontSize:10,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:"10px 16px",cursor:"pointer",fontSize:14,color:"#aaa",background:d==="__placeholder"?"#f5f5f5":"transparent"},children:r}),l.length===0&&n.jsx("div",{style:{padding:"12px 16px",color:"#aaa",fontSize:13},children:"No records found"}),l.map(u=>n.jsx("div",{onClick:()=>{t(u.name),a(!1)},onMouseEnter:()=>p(u.name),onMouseLeave:()=>p(""),style:{padding:"10px 16px",cursor:"pointer",fontSize:14,background:e===u.name?"#2563eb":d===u.name?"#f0f4ff":"transparent",color:e===u.name?"white":"#1a2332",transition:"background 0.1s"},children:u.label},u.name))]})})]})}function Ry(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 Ly(e){return e.replace(/@.*/,"").replace(/[._-]/g," ").split(" ").filter(Boolean).slice(0,2).map(l=>l[0].toUpperCase()).join("")}function Wi({doctype:e,docname:t,currentUserName:l}){const r=J(),[s,i]=S.useState([]),[a,d]=S.useState(!1),[p,f]=S.useState(""),[h,c]=S.useState(!1),[u,x]=S.useState(!1),[v,m]=S.useState(!1),[z,y]=S.useState(""),o=5,g=S.useCallback(async()=>{d(!0);const C=await ty(e,t);i(C),d(!1)},[e,t]);S.useEffect(()=>{g()},[g]);const j=async()=>{const C=p.trim();if(!(!C||h)){c(!0),y("");try{await ny(e,t,C),f(""),await g()}catch{y("Failed to post comment. Please try again.")}c(!1)}},b=async C=>{if(window.confirm("Delete this comment?"))try{await Tf("Comment",C),i(O=>O.filter(U=>U.name!==C))}catch{alert("Failed to delete comment.")}},w=v?s:s.slice(-o),k=Math.max(0,s.length-o);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:()=>x(C=>!C),style:{padding:"12px 20px",borderBottom:u?"none":"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none",background:"white"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:"#1a2332"},children:["💬 ",r.comments.title,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:C=>{C.stopPropagation(),g()},style:{background:"none",border:"none",cursor:"pointer",color:"#aaa",fontSize:16,padding:"2px 4px",lineHeight:1},title:"Refresh",children:"↻"}),n.jsx("span",{style:{color:"#ccc",fontSize:11},children:u?"▼":"▲"})]})]}),!u&&n.jsxs("div",{style:{padding:"16px 20px"},children:[!v&&k>0&&n.jsxs("button",{onClick:()=>m(!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 ",k," older comment",k!==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(C=>{const O=C.comment_by||C.comment_email||C.owner||"Unknown",U=C.owner===l||C.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:Ly(O)}),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:O}),n.jsx("span",{style:{fontSize:11,color:"#aaa"},children:Ry(C.creation)})]}),U&&n.jsx("button",{onClick:()=>b(C.name),style:{background:"none",border:"none",cursor:"pointer",color:"#e74c3c",fontSize:16,padding:"0 2px",lineHeight:1},title:"Delete comment",children:"×"})]}),n.jsx("div",{style:{fontSize:13,color:"#374151",lineHeight:1.55,wordBreak:"break-word",whiteSpace:"pre-wrap"},dangerouslySetInnerHTML:{__html:C.content||""}})]})]},C.name)})}),n.jsxs("div",{style:{borderTop:s.length>0?"1px solid #f0f0f0":"none",paddingTop:s.length>0?14:0},children:[n.jsx("textarea",{value:p,onChange:C=>f(C.target.value),onKeyDown:C=>{C.key==="Enter"&&(C.ctrlKey||C.metaKey)&&j()},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"}}),z&&n.jsx("div",{style:{fontSize:12,color:"#e74c3c",marginTop:4},children:z}),n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:n.jsx("button",{onClick:j,disabled:!p.trim()||h,style:{padding:"8px 20px",background:"#3498db",color:"white",border:"none",borderRadius:6,cursor:!p.trim()||h?"not-allowed":"pointer",fontSize:13,fontWeight:600,fontFamily:"Segoe UI",opacity:!p.trim()||h?.6:1},children:h?r.saving:r.comments.post})})]})]})]})}function Jd(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 Oy(e){return(e||"").replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function qd(e){return e==null||e===""?"(empty)":typeof e=="object"?JSON.stringify(e):String(e)}function vo(e){return(e||"Unknown").replace(/@.*/,"").replace(/[._]/g," ")}function Zd(e){return vo(e).split(" ").filter(Boolean).slice(0,2).map(t=>t[0].toUpperCase()).join("")}function Dy(e){let t={};try{t=JSON.parse(e.data||"{}")}catch{}const l=(t.changed||[]).map(r=>({field:r[0]||"",oldVal:qd(r[1]),newVal:qd(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 Bi({doctype:e,docname:t,docCreation:l,docOwner:r}){const s=J(),[i,a]=S.useState([]),[d,p]=S.useState(!1),[f,h]=S.useState(!0),[c,u]=S.useState(!1),x=5,v=S.useCallback(async()=>{p(!0);const o=await ly(e,t);a(o.map(Dy)),p(!1)},[e,t]);S.useEffect(()=>{f||v()},[f,v]);const m=c?i:i.slice(0,x),z=i.length-x,y=(o,g=!1)=>({position:"absolute",left:-14,top:14,width:10,height:10,borderRadius:"50%",background:o,border:"2px solid white",boxShadow:g?`0 0 0 2px ${o}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:()=>h(o=>!o),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:o=>{o.stopPropagation(),v()},style:{background:"none",border:"none",cursor:"pointer",color:"#aaa",fontSize:16,padding:"2px 4px",lineHeight:1},title:"Refresh",children:"↻"}),n.jsx("span",{style:{color:"#ccc",fontSize:11},children:f?"▼":"▲"})]})]}),!f&&n.jsxs("div",{style:{padding:"16px 20px"},children:[d&&n.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:s.loading}),!d&&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:[m.map((o,g)=>n.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[n.jsx("div",{style:y(g===0?"#3498db":"#d1d5db",g===0)}),n.jsxs("div",{style:{background:g===0?"#eff6ff":"#f9fafb",border:`1px solid ${g===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:Zd(o.owner)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:vo(o.owner)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:Jd(o.creation)})]}),o.changes.length>0?n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:o.changes.map((j,b)=>n.jsxs("div",{style:{fontSize:12,lineHeight:1.5},children:[n.jsx("span",{style:{fontWeight:600,color:"#6d28d9"},children:Oy(j.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:j.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:j.newVal})]},b))}):n.jsxs("div",{style:{fontSize:12,color:"#9ca3af",fontStyle:"italic"},children:["Document updated",o.added>0&&n.jsxs("span",{children:[" · +",o.added," row(s)"]}),o.removed>0&&n.jsxs("span",{children:[" · -",o.removed," row(s)"]}),o.rowChanged>0&&n.jsxs("span",{children:[" · ~",o.rowChanged," row(s) modified"]})]})]})]},o.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:Zd(r)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:vo(r)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:Jd(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"})]})]}),!d&&z>0&&n.jsx("div",{style:{textAlign:"center",marginTop:12},children:n.jsx("button",{onClick:()=>u(o=>!o),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 cr={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},va={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},Ny={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 Wy(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...Ny[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function By({incForm:e,setIncForm:t,organizations:l,managements:r,departments:s,branches:i,incidentTypes:a,incidentClasses:d,incidentFields:p,incidentStatuses:f,users:h,userRoleMap:c={},formStatus:u,viewMode:x,userRole:v,onSubmit:m,onBack:z,onNavigate:y,onLogout:o,user:g,onRefresh:j}){const b=J(),w=P=>t({...e,...P}),k=x?{background:"#f9f9f9"}:{},C=Nl(h,c,"SB Employee"),O=Nl(h,c,"SB Manager"),[U,Q]=S.useState(""),[X,$]=S.useState(!1),ee=e.name?x?`${b.formTitle.viewIncident}${e.number||e.name}`:b.formTitle.editIncident:b.formTitle.newIncident,Z=ce(r,e.management).map(P=>({name:P.name,label:P.name1||P.name})),xe=ce(s,e.department).map(P=>({name:P.name,label:P.department_name||P.name})),se=ce(i,e.branch).map(P=>({name:P.name,label:P.branch||P.name})),A=ce(a,e.type).map(P=>({name:P.name,label:P.name1||P.name})),B=d.map(P=>({name:P.name,label:P.name1||P.name})),H=p.map(P=>({name:P.name,label:P.name1||P.name})),V=ce(f,e.status).map(P=>({name:P.name,label:P.name1||P.name})),F=e.workflow_state||"New",je=v==="Employee",R=v==="Auditor"||v==="Admin",q=v==="Manager",$e=e.name?F==="New"?[{label:b.wf.submit,action:"Submit",color:"#2563eb"}]:F==="Initial Evaluation"&&R?[{label:b.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:b.wf.reject,action:"Reject",color:"#dc2626"}]:F==="Accept & Under Progress"&&(q||R)?[{label:b.wf.submitSolution,action:"Submit Solution",color:"#059669"}]:F==="working on resolution"&&(q||R)?[{label:b.wf.resolutionComplete,action:"Resolution complete",color:"#166534"}]:[]:[];async function De(P){if(e.name){$(!0),Q("");try{const M={};P==="Assign to Manager"&&(e.assigned_to&&(M.assigned_to=e.assigned_to),e.priority&&(M.priority=e.priority),e.economy_class&&(M.economy_class=e.economy_class),e.entity_scope&&(M.entity_scope=e.entity_scope),e.hses_field&&(M.hses_field=e.hses_field),M.product_relation=String(e.product_relation??0),M.repeated=String(e.repeated??0)),P==="Submit Solution"&&(e.solution&&(M.solution=e.solution),e.summary&&(M.summary=e.summary),e.cost&&(M.cost=String(e.cost))),(P==="Resolution complete"||P==="Submit Solution")&&e.auditor_comment&&(M.auditor_comment=e.auditor_comment),await sy(e.name,P,JSON.stringify(M)),Q("Done"),j==null||j()}catch(M){Q(M.message||"Error")}finally{$(!1)}}}const I=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:b.wf.workflow}),n.jsx("span",{style:Wy(F),children:F})]}),F==="Initial Evaluation"&&R&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:b.wf.assignToManager}),n.jsxs("select",{style:E,value:e.assigned_to||"",onChange:P=>w({assigned_to:P.target.value}),children:[n.jsx("option",{value:"",children:b.field.selectMgr}),O.map(P=>n.jsx("option",{value:P.name,children:P.full_name||P.name},P.name))]})]}),(F==="Accept & Under Progress"||F==="working on resolution")&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:b.field.solution}),n.jsx("textarea",{style:{...E,height:80,resize:"vertical"},value:e.solution||"",onChange:P=>w({solution:P.target.value}),placeholder:b.field.solutionPlaceholder}),n.jsx("label",{style:{...T,marginTop:8},children:b.field.actualCost}),n.jsx("input",{type:"number",style:E,value:e.cost||"",onChange:P=>w({cost:parseFloat(P.target.value)||0}),placeholder:"0.00"})]}),F==="working on resolution"&&R&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:b.field.auditorComment}),n.jsx("textarea",{style:{...E,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:P=>w({auditor_comment:P.target.value}),placeholder:b.field.commentPlaceholder})]}),$e.length>0?n.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:$e.map(P=>n.jsx("button",{onClick:()=>De(P.action),disabled:X,style:{padding:"8px 18px",borderRadius:8,border:"none",background:P.color,color:"white",fontWeight:700,cursor:X?"not-allowed":"pointer",opacity:X?.7:1},children:X?b.wf.applying:P.label},P.action))}):n.jsx("div",{style:{fontSize:12,color:"#94a3b8",fontStyle:"italic"},children:b.wf.noActions}),U&&n.jsx("p",{style:{marginTop:8,fontSize:13,color:U==="Done"?N.green:N.red},children:U})]}),n.jsx(Wi,{doctype:D.incidents,docname:e.name,currentUserName:g.name}),n.jsx(Bi,{doctype:D.incidents,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):null;return n.jsxs(Oe,{title:ee,activePage:"incidents",user:g,formStatus:u,buttonText:b.saveIncident,buttonColor:N.accent,viewMode:x,rightPanel:I,onSubmit:m,onBack:z,onNavigate:y,onLogout:o,children:[n.jsxs("div",{style:cr,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.number}),n.jsx("input",{style:{...E,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:P=>w({organization:P}),organizations:l,disabled:x})]})]}),n.jsxs("div",{style:va,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.management}),n.jsx(ae,{value:e.management,onChange:P=>w({management:P}),items:Z,placeholder:b.field.select,disabled:x})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.department}),n.jsx(ae,{value:e.department,onChange:P=>w({department:P}),items:xe,placeholder:b.field.select,disabled:x})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.section}),n.jsx("input",{style:{...E,...k},value:e.section_field||"",disabled:x,onChange:P=>w({section_field:P.target.value})})]})]}),n.jsxs("div",{style:cr,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.branch}),n.jsx(ae,{value:e.branch,onChange:P=>w({branch:P}),items:se,placeholder:b.field.select,disabled:x})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.hsesField}),n.jsx("input",{style:{...E,...k},value:e.hses_field||"",disabled:x,onChange:P=>w({hses_field:P.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{style:cr,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.type}),n.jsx(ae,{value:e.type,onChange:P=>w({type:P}),items:A,placeholder:b.field.selectType,disabled:x})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.title}),n.jsx("input",{style:{...E,...k},value:e.title,disabled:x,onChange:P=>w({title:P.target.value})})]})]}),n.jsxs("div",{style:cr,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.incidentClass}),n.jsx(ae,{value:e.incident_class,onChange:P=>w({incident_class:P}),items:B,placeholder:b.field.selectClass,disabled:x})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.incidentField}),n.jsx(ae,{value:e.incident_field,onChange:P=>w({incident_field:P}),items:H,placeholder:b.field.selectField,disabled:x})]})]}),n.jsxs("div",{style:va,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.date}),n.jsx(ue,{value:e.date,onChange:P=>w({date:P}),disabled:x,style:{...E,...k}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.time}),n.jsx("input",{type:"time",style:{...E,...k},value:e.time,disabled:x,onChange:P=>w({time:P.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.assignedTo}),n.jsxs("select",{style:{...E,...k},value:e.assigned_to,disabled:x,onChange:P=>w({assigned_to:P.target.value}),children:[n.jsx("option",{value:"",children:b.field.select}),C.map(P=>n.jsx("option",{value:P.name,children:P.full_name||P.name},P.name))]})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.status}),n.jsx(ae,{value:e.status,onChange:P=>w({status:P}),items:V,placeholder:b.field.selectStatus,disabled:x})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.description}),n.jsx("textarea",{style:{...E,...k,height:120,resize:"vertical"},value:e.description,disabled:x,onChange:P=>w({description:P.target.value})})]}),!je&&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:b.steps.auditorTriage}),n.jsxs("div",{style:va,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.priority}),n.jsxs("select",{style:{...E,...x&&!R?{background:"#f9f9f9"}:{}},value:e.priority||"",disabled:x&&!R,onChange:P=>w({priority:P.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",{children:[n.jsx("label",{style:T,children:b.field.economyClass}),n.jsxs("select",{style:{...E,...x&&!R?{background:"#f9f9f9"}:{}},value:e.economy_class||"",disabled:x&&!R,onChange:P=>w({economy_class:P.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.entityScope}),n.jsxs("select",{style:{...E,...x&&!R?{background:"#f9f9f9"}:{}},value:e.entity_scope||"",disabled:x&&!R,onChange:P=>w({entity_scope:P.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",{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:x&&!R,onChange:P=>w({product_relation:P.target.checked?1:0})})," ",b.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:x&&!R,onChange:P=>w({repeated:P.target.checked?1:0})})," ",b.field.repeatedEvent]})]})]}),!je&&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:b.steps.managerSolution}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.solution}),n.jsx("textarea",{style:{...E,height:100,resize:"vertical",...x&&!q&&!R?{background:"#f9f9f9"}:{}},value:e.solution||"",disabled:x&&!q&&!R,onChange:P=>w({solution:P.target.value}),placeholder:b.field.solutionPlaceholder})]}),n.jsxs("div",{style:cr,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.actualCost}),n.jsx("input",{type:"number",style:{...E,...x&&!q&&!R?{background:"#f9f9f9"}:{}},value:e.cost||"",disabled:x&&!q&&!R,onChange:P=>w({cost:parseFloat(P.target.value)||0}),placeholder:"0.00"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.summary}),n.jsx("input",{style:{...E,...x&&!q&&!R?{background:"#f9f9f9"}:{}},value:e.summary||"",disabled:x&&!q&&!R,onChange:P=>w({summary:P.target.value}),placeholder:"Brief summary"})]})]})]}),!je&&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:b.steps.ownerComment}),n.jsx("textarea",{style:{...E,height:80,resize:"vertical",...x&&!R?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:x&&!R,onChange:P=>w({auditor_comment:P.target.value}),placeholder:b.field.commentPlaceholder})]})]})}function $y({ideas:e,organizations:t,departments:l,branches:r,ideaStatuses:s,initialOrg:i,canModify:a,onView:d,onEdit:p,onDelete:f}){const h=J(),[c,u]=S.useState({search:"",organization:i||"",department:"",branch:"",status:""}),x=(o,g)=>u(j=>({...j,[o]:g})),[v,m]=S.useState(1),z=e.filter(o=>!(c.search&&!`${o.number} ${o.title}`.toLowerCase().includes(c.search.toLowerCase())||c.organization&&o.organization!==c.organization||c.department&&o.department!==c.department||c.branch&&o.branch!==c.branch||c.status&&o.status!==c.status));S.useEffect(()=>{m(1)},[c]);const y=z.slice((v-1)*te,v*te);return n.jsxs(n.Fragment,{children:[n.jsx(Ni,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.numberTitle}),n.jsx("input",{style:Re,value:c.search,onChange:o=>x("search",o.target.value),placeholder:h.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.organization}),n.jsxs("select",{style:Re,value:c.organization,onChange:o=>x("organization",o.target.value),children:[n.jsx("option",{value:"",children:h.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.department}),n.jsxs("select",{style:Re,value:c.department,onChange:o=>x("department",o.target.value),children:[n.jsx("option",{value:"",children:h.filter.allDepts}),l.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.branch}),n.jsxs("select",{style:Re,value:c.branch,onChange:o=>x("branch",o.target.value),children:[n.jsx("option",{value:"",children:h.filter.allBranches}),r.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.status}),n.jsxs("select",{style:Re,value:c.status,onChange:o=>x("status",o.target.value),children:[n.jsx("option",{value:"",children:h.filter.allStatuses}),s.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>u({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:h.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:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.number}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.title}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.organization}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.status}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.actions})]})}),n.jsx("tbody",{children:z.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:h.noIdeas})}):y.map((o,g)=>n.jsxs("tr",{onClick:()=>d==null?void 0:d(o),style:{borderTop:"1px solid #f0f0f0",background:g%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",color:"#999"},children:o.number||"—"}),n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:o.title||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:o.status?In(o.status,Di(o.status)):"—"}),n.jsx("td",{style:{padding:"10px 18px"},onClick:j=>j.stopPropagation(),children:n.jsx(He,{onView:()=>d==null?void 0:d(o),onEdit:a&&p?()=>p(o):void 0,onDelete:a&&f?()=>f(o.name):void 0})})]},o.name))})]})}),n.jsx(Le,{page:v,total:z.length,onPageChange:m})]})}const Vd={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},ja={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},Uy={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 Fy(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...Uy[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function My({ideaForm:e,setIdeaForm:t,organizations:l,managements:r,departments:s,branches:i,ideaTypes:a,ideaStatuses:d,users:p=[],userRoleMap:f={},formStatus:h,viewMode:c,userRole:u,onSubmit:x,onBack:v,onNavigate:m,onLogout:z,user:y,onRefresh:o}){const g=J(),j=R=>t({...e,...R}),b=c?{background:"#f9f9f9"}:{},w=Nl(p,f,"SB Manager"),[k,C]=S.useState(""),[O,U]=S.useState(!1),Q=e.name?c?`${g.formTitle.viewIdea}${e.number||e.title||e.name}`:g.formTitle.editIdea:g.formTitle.newIdea,X=ce(r,e.management).map(R=>({name:R.name,label:R.name1||R.name})),$=ce(s,e.department).map(R=>({name:R.name,label:R.department_name||R.name})),ee=ce(i,e.branch).map(R=>({name:R.name,label:R.branch||R.name})),Z=ce(a,e.type).map(R=>({name:R.name,label:R.name1||R.name})),xe=ce(d,e.status).map(R=>({name:R.name,label:R.name1||R.name})),se=e.workflow_state||"New",A=u==="Employee",B=u==="Auditor"||u==="Admin",H=u==="Manager",V=e.name?se==="New"?[{label:g.wf.submit,action:"Submit",color:"#2563eb"}]:se==="Initial Evaluation"&&B?[{label:g.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:g.wf.reject,action:"Reject",color:"#dc2626"}]:se==="Accept & Under Progress"&&(H||B)?[{label:g.wf.submitSolution,action:"Submit Proposal",color:"#059669"}]:se==="working on proposal"&&B?[{label:g.wf.moveToOutsourcing,action:"Move to Outsourcing",color:"#0369a1"},{label:g.wf.reject,action:"Reject",color:"#dc2626"}]:[]:[];async function F(R){if(e.name){U(!0),C("");try{const q={};R==="Assign to Manager"&&(e.assigned_to&&(q.assigned_to=e.assigned_to),e.priority&&(q.priority=e.priority),e.economy_class&&(q.economy_class=e.economy_class),e.entity_scope&&(q.entity_scope=e.entity_scope),e.hses_field&&(q.hses_field=e.hses_field),q.product_relation=String(e.product_relation??0),q.repeated=String(e.repeated??0)),R==="Submit Proposal"&&(e.solution&&(q.solution=e.solution),e.proposed_condition&&(q.proposed_condition=e.proposed_condition),e.cost&&(q.cost=String(e.cost))),e.auditor_comment&&(R==="Move to Outsourcing"||R==="Reject")&&(q.auditor_comment=e.auditor_comment),await iy(e.name,R,JSON.stringify(q)),C("Done"),o==null||o()}catch(q){C(q.message||"Error")}finally{U(!1)}}}const je=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:g.wf.workflow}),n.jsx("span",{style:Fy(se),children:se})]}),se==="Initial Evaluation"&&B&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:g.wf.assignToManager}),n.jsxs("select",{style:E,value:e.assigned_to||"",onChange:R=>j({assigned_to:R.target.value}),children:[n.jsx("option",{value:"",children:g.field.selectMgr}),w.map(R=>n.jsx("option",{value:R.name,children:R.full_name||R.name},R.name))]})]}),se==="Accept & Under Progress"&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:g.field.solution}),n.jsx("textarea",{style:{...E,height:80,resize:"vertical"},value:e.solution||"",onChange:R=>j({solution:R.target.value}),placeholder:g.field.solutionPlaceholder}),n.jsx("label",{style:{...T,marginTop:8},children:g.field.actualCost}),n.jsx("input",{type:"number",style:E,value:e.cost||"",onChange:R=>j({cost:parseFloat(R.target.value)||0}),placeholder:"0.00"})]}),se==="working on proposal"&&B&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:g.field.auditorComment}),n.jsx("textarea",{style:{...E,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:R=>j({auditor_comment:R.target.value}),placeholder:g.field.commentPlaceholder})]}),V.length>0?n.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:V.map(R=>n.jsx("button",{onClick:()=>F(R.action),disabled:O,style:{padding:"8px 18px",borderRadius:8,border:"none",background:R.color,color:"white",fontWeight:700,cursor:O?"not-allowed":"pointer",opacity:O?.7:1},children:O?g.wf.applying:R.label},R.action))}):n.jsx("div",{style:{fontSize:12,color:"#94a3b8",fontStyle:"italic"},children:g.wf.noActions}),k&&n.jsx("p",{style:{marginTop:8,fontSize:13,color:k==="Done"?N.green:N.red},children:k})]}),n.jsx(Wi,{doctype:D.ideas,docname:e.name,currentUserName:y.name}),n.jsx(Bi,{doctype:D.ideas,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):null;return n.jsxs(Oe,{title:Q,activePage:"ideas",user:y,formStatus:h,buttonText:g.saveIdea,buttonColor:N.teal,viewMode:c,rightPanel:je,onSubmit:x,onBack:v,onNavigate:m,onLogout:z,children:[n.jsxs("div",{style:Vd,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.number}),n.jsx("input",{style:{...E,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.organization}),n.jsx(_t,{value:e.organization,onChange:R=>j({organization:R}),organizations:l,disabled:c})]})]}),n.jsxs("div",{style:ja,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.management}),n.jsx(ae,{value:e.management,onChange:R=>j({management:R}),items:X,placeholder:g.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.department}),n.jsx(ae,{value:e.department,onChange:R=>j({department:R}),items:$,placeholder:g.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.section}),n.jsx("input",{style:{...E,...b},value:e.section_field||"",disabled:c,onChange:R=>j({section_field:R.target.value})})]})]}),n.jsxs("div",{style:Vd,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.branch}),n.jsx(ae,{value:e.branch,onChange:R=>j({branch:R}),items:ee,placeholder:g.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.date}),n.jsx(ue,{value:e.date||"",onChange:R=>j({date:R}),disabled:c,style:{...E,...b}})]})]}),n.jsxs("div",{style:ja,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.type}),n.jsx(ae,{value:e.type,onChange:R=>j({type:R}),items:Z,placeholder:g.field.selectType,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.ideaClass}),n.jsxs("select",{style:{...E,...b},value:e.idea_class||"",disabled:c,onChange:R=>j({idea_class:R.target.value}),children:[n.jsx("option",{value:"",children:g.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:g.field.hsesField}),n.jsx("input",{style:{...E,...b},value:e.hses_field||"",disabled:c,onChange:R=>j({hses_field:R.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.title}),n.jsx("input",{style:{...E,...b},value:e.title,disabled:c,onChange:R=>j({title:R.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsx(ae,{value:e.status,onChange:R=>j({status:R}),items:xe,placeholder:g.field.selectStatus,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.currentCondition}),n.jsx("textarea",{style:{...E,...b,height:110,resize:"vertical"},value:e.current_condition,disabled:c,onChange:R=>j({current_condition:R.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.proposedCondition}),n.jsx("textarea",{style:{...E,...b,height:110,resize:"vertical"},value:e.proposed_condition,disabled:c,onChange:R=>j({proposed_condition:R.target.value})})]}),!A&&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:g.steps.auditorEval}),n.jsxs("div",{style:ja,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.priority}),n.jsxs("select",{style:{...E,...c&&!B?{background:"#f9f9f9"}:{}},value:e.priority||"",disabled:c&&!B,onChange:R=>j({priority:R.target.value}),children:[n.jsx("option",{value:"",children:g.field.select}),n.jsx("option",{value:"High",children:g.field.high}),n.jsx("option",{value:"Normal",children:g.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.economyClass}),n.jsxs("select",{style:{...E,...c&&!B?{background:"#f9f9f9"}:{}},value:e.economy_class||"",disabled:c&&!B,onChange:R=>j({economy_class:R.target.value}),children:[n.jsx("option",{value:"",children:g.field.select}),n.jsx("option",{value:"Expenses",children:g.field.expenses}),n.jsx("option",{value:"Capital",children:g.field.capital}),n.jsx("option",{value:"Earn",children:g.field.earn}),n.jsx("option",{value:"Pay/Loss",children:g.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.entityScope}),n.jsxs("select",{style:{...E,...c&&!B?{background:"#f9f9f9"}:{}},value:e.entity_scope||"",disabled:c&&!B,onChange:R=>j({entity_scope:R.target.value}),children:[n.jsx("option",{value:"",children:g.field.select}),n.jsx("option",{value:"Upstream",children:g.field.upstream}),n.jsx("option",{value:"On-stream",children:g.field.onstream}),n.jsx("option",{value:"Downstream",children:g.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&&!B,onChange:R=>j({product_relation:R.target.checked?1:0})})," ",g.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&&!B,onChange:R=>j({repeated:R.target.checked?1:0})})," ",g.field.repeatedEvent]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:T,children:g.wf.assignToManager}),n.jsxs("select",{style:{...E,...c&&!B?{background:"#f9f9f9"}:{}},value:e.assigned_to||"",disabled:c&&!B,onChange:R=>j({assigned_to:R.target.value}),children:[n.jsx("option",{value:"",children:g.field.select}),w.map(R=>n.jsx("option",{value:R.name,children:R.full_name||R.name},R.name))]})]})]}),!A&&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:g.steps.managerSolution}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.solution}),n.jsx("textarea",{style:{...E,height:100,resize:"vertical",...c&&!H&&!B?{background:"#f9f9f9"}:{}},value:e.solution||"",disabled:c&&!H&&!B,onChange:R=>j({solution:R.target.value}),placeholder:g.field.solutionPlaceholder})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:T,children:g.field.actualCost}),n.jsx("input",{type:"number",style:{...E,...c&&!H&&!B?{background:"#f9f9f9"}:{}},value:e.cost||"",disabled:c&&!H&&!B,onChange:R=>j({cost:parseFloat(R.target.value)||0}),placeholder:"0.00"})]})]}),!A&&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:g.steps.ownerComment}),n.jsx("textarea",{style:{...E,height:80,resize:"vertical",...c&&!B?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:c&&!B,onChange:R=>j({auditor_comment:R.target.value}),placeholder:g.field.commentPlaceholder})]})]})}function Hy({orders:e,organizations:t,departments:l,branches:r,orderStatuses:s,initialOrg:i,canModify:a,onView:d,onEdit:p,onDelete:f}){const h=J(),[c,u]=S.useState({search:"",organization:i||"",department:"",branch:"",status:""}),x=(o,g)=>u(j=>({...j,[o]:g})),[v,m]=S.useState(1),z=e.filter(o=>!(c.search&&!`${o.number} ${o.title}`.toLowerCase().includes(c.search.toLowerCase())||c.organization&&o.organization!==c.organization||c.department&&o.department!==c.department||c.branch&&o.branch!==c.branch||c.status&&o.status!==c.status));S.useEffect(()=>{m(1)},[c]);const y=z.slice((v-1)*te,v*te);return n.jsxs(n.Fragment,{children:[n.jsx(Ni,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.numberTitle}),n.jsx("input",{style:Re,value:c.search,onChange:o=>x("search",o.target.value),placeholder:h.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.organization}),n.jsxs("select",{style:Re,value:c.organization,onChange:o=>x("organization",o.target.value),children:[n.jsx("option",{value:"",children:h.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.department}),n.jsxs("select",{style:Re,value:c.department,onChange:o=>x("department",o.target.value),children:[n.jsx("option",{value:"",children:h.filter.allDepts}),l.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.branch}),n.jsxs("select",{style:Re,value:c.branch,onChange:o=>x("branch",o.target.value),children:[n.jsx("option",{value:"",children:h.filter.allBranches}),r.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.status}),n.jsxs("select",{style:Re,value:c.status,onChange:o=>x("status",o.target.value),children:[n.jsx("option",{value:"",children:h.filter.allStatuses}),s.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>u({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:h.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:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.number}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.title}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.organization}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.type}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.status}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.actions})]})}),n.jsx("tbody",{children:z.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:h.noOrders})}):y.map((o,g)=>n.jsxs("tr",{onClick:()=>d==null?void 0:d(o),style:{borderTop:"1px solid #f0f0f0",background:g%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",color:"#999"},children:o.number||"—"}),n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:o.title||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:o.type?In(o.type,"#8e44ad"):"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:o.status?In(o.status,Di(o.status)):"—"}),n.jsx("td",{style:{padding:"10px 18px"},onClick:j=>j.stopPropagation(),children:n.jsx(He,{onView:()=>d==null?void 0:d(o),onEdit:a&&p?()=>p(o):void 0,onDelete:a&&f?()=>f(o.name):void 0})})]},o.name))})]})}),n.jsx(Le,{page:v,total:z.length,onPageChange:m})]})}const Es={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},As={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},Ky={1:"Initiation / Bidding",2:"Execution begins",3:"Mid-execution review",4:"Near completion",5:"Closing"},Qy={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 Gy(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...Qy[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function Yy({orderForm:e,setOrderForm:t,organizations:l,managements:r,departments:s,branches:i,orderTypes:a,orderStatuses:d,cycles:p=[],users:f,userRoleMap:h={},formStatus:c,viewMode:u,currentUser:x,userRole:v,onSubmit:m,onBack:z,onNavigate:y,onLogout:o,user:g,onRefresh:j}){var on;const b=J(),w=L=>t({...e,...L}),k=u?{background:"#f9f9f9"}:{},C=Nl(f,h,"SB Employee"),[O,U]=S.useState(""),[Q,X]=S.useState(""),[$,ee]=S.useState(!1),[Z,xe]=S.useState("Agree"),se=e.name?u?`${b.formTitle.viewOrder}${e.number||e.title||e.name}`:b.formTitle.editOrder:b.formTitle.newOrder,A=ce(r,e.management).map(L=>({name:L.name,label:L.name1||L.name})),B=ce(s,e.department).map(L=>({name:L.name,label:L.department_name||L.name})),H=ce(i,e.branch).map(L=>({name:L.name,label:L.branch||L.name})),V=ce(a,e.type).map(L=>({name:L.name,label:L.name1||L.name})),F=ce(d,e.status).map(L=>({name:L.name,label:L.name1||L.name})),je=ce(p,e.cycle).map(L=>({name:L.name,label:L.name1||L.name})),R=!!e.name,q=e.workflow_state||"Draft",$e=Math.min(5,(e.stage||0)+1),[De,I]=S.useState($e);S.useEffect(()=>{I(Math.min(5,(e.stage||0)+1))},[e.stage]);const P=v==="Auditor"||v==="Admin"||v==="Manager",M=P||v==="Owner",Ct=!!(x&&(e.actor===x||e.assigned_to===x)),ss=R?q==="Closed"?[]:q==="Draft"&&P?[{label:"Submit for Review",action:"Submit for Review",color:"#2563eb"}]:q==="Pending Actor"&&(Ct||P)?[{label:"Update Status",action:"Update Status",color:"#d97706"}]:q==="Review"&&M?[{label:"Move to Study",action:"Move to Study",color:"#059669"},{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"}]:q==="In Study"&&M?[{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"},{label:"Close Order",action:"Close Order",color:"#475569"}]:[]:[];async function Rn(L){if(e.name){ee(!0),U("");try{let Ye;L==="Update Status"&&(Ye=Z);const qn=await ry(e.name,L,Q,L==="Update Status"?String(De):void 0,void 0,Ye);if(X(""),xe("Agree"),U("Done"),qn){const dt=qn;t({...e,...dt,stage:dt.stage??e.stage,completion_pct:dt.completion_pct??e.completion_pct,workflow_state:dt.workflow_state??e.workflow_state})}j==null||j()}catch(Ye){U(Ye.message||"Error")}finally{ee(!1)}}}const $i=R?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:b.wf.workflow}),n.jsx("span",{style:Gy(q),children:q})]}),q==="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) — ",De*20,"% complete"]}),n.jsx("input",{type:"number",min:1,max:5,style:{...E,maxWidth:80},value:De,onChange:L=>I(Math.min(5,Math.max(1,parseInt(L.target.value)||1)))})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Cycle Status"}),n.jsxs("select",{style:{...E,minWidth:140},value:Z,onChange:L=>xe(L.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 ",Z==="Deviate"&&q==="Pending Actor"?n.jsx("span",{style:{color:N.red},children:" * required for Deviate"}):"(optional)"]}),n.jsx("textarea",{style:{...E,height:64,resize:"vertical",borderColor:Z==="Deviate"&&!Q?"#fca5a5":void 0},value:Q,onChange:L=>X(L.target.value),placeholder:"Add a comment…"})]}),n.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:ss.map(L=>{const Ye=L.action==="Update Status"&&Z==="Deviate"&&!Q.trim();return n.jsx("button",{onClick:()=>Rn(L.action),disabled:$||Ye,title:Ye?"Comment required when status is Deviate":void 0,style:{padding:"8px 18px",borderRadius:8,border:"none",background:L.color,color:"white",fontWeight:700,cursor:$||Ye?"not-allowed":"pointer",opacity:$||Ye?.5:1},children:$?b.wf.applying:L.label},L.action)})}),O&&n.jsx("p",{style:{marginTop:8,fontSize:13,color:O==="Done"?N.green:N.red},children:O}),ss.length===0&&n.jsx("div",{style:{fontSize:12,color:"#94a3b8",fontStyle:"italic"},children:b.wf.noActions})]}),n.jsx(Wi,{doctype:D.orders,docname:e.name,currentUserName:g.name}),n.jsx(Bi,{doctype:D.orders,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):null;return n.jsxs(Oe,{title:se,activePage:"orders",user:g,formStatus:c,buttonText:b.saveOrder,buttonColor:N.purple,viewMode:u,rightPanel:$i,onSubmit:m,onBack:z,onNavigate:y,onLogout:o,children:[n.jsxs("div",{style:Es,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.number}),n.jsx("input",{style:{...E,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:L=>w({organization:L}),organizations:l,disabled:u})]})]}),n.jsxs("div",{style:As,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.management}),n.jsx(ae,{value:e.management,onChange:L=>w({management:L}),items:A,placeholder:b.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.department}),n.jsx(ae,{value:e.department,onChange:L=>w({department:L}),items:B,placeholder:b.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.section}),n.jsx("input",{style:{...E,...k},value:e.section_field||"",disabled:u,onChange:L=>w({section_field:L.target.value})})]})]}),n.jsxs("div",{style:Es,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.branch}),n.jsx(ae,{value:e.branch,onChange:L=>w({branch:L}),items:H,placeholder:b.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.type}),n.jsx(ae,{value:e.type,onChange:L=>w({type:L}),items:V,placeholder:b.field.selectType,disabled:u})]})]}),n.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:14,marginTop:4},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#475569",marginBottom:10},children:"Classification"}),n.jsxs("div",{style:As,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.priority}),n.jsxs("select",{style:{...E,...k},value:e.priority||"",disabled:u,onChange:L=>w({priority:L.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",{children:[n.jsx("label",{style:T,children:b.field.economyClass}),n.jsxs("select",{style:{...E,...k},value:e.economy_class||"",disabled:u,onChange:L=>w({economy_class:L.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.entityScope}),n.jsxs("select",{style:{...E,...k},value:e.entity_scope||"",disabled:u,onChange:L=>w({entity_scope:L.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",{style:{display:"flex",gap:24,marginTop:12,alignItems:"center",flexWrap:"wrap"},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.planned,disabled:u,onChange:L=>w({planned:L.target.checked?1:0})})," Planned"]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:u,onChange:L=>w({product_relation:L.target.checked?1:0})})," ",b.field.productRelation]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:T,children:b.field.hsesField}),n.jsx("input",{style:{...E,...k},value:e.hses_field||"",disabled:u,onChange:L=>w({hses_field:L.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.title}),n.jsx("input",{style:{...E,...k},value:e.title,disabled:u,onChange:L=>w({title:L.target.value})})]}),n.jsxs("div",{style:As,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.budget}),n.jsx("input",{type:"number",style:{...E,...k},value:e.budget||"",disabled:u,onChange:L=>w({budget:parseFloat(L.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.actualCost}),n.jsx("input",{type:"number",style:{...E,...k},value:e.actual_cost||"",disabled:u,onChange:L=>w({actual_cost:parseFloat(L.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Variance"}),(()=>{const L=(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:L>=0?"#f0fdf4":"#fef2f2",color:L>=0?"#166534":"#dc2626",border:`1px solid ${L>=0?"#bbf7d0":"#fecaca"}`},children:[L>=0?"+":"",L.toFixed(2)]})})()]})]}),n.jsxs("div",{style:Es,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.currency}),n.jsxs("select",{style:{...E,...k},value:e.currency||"",disabled:u,onChange:L=>w({currency:L.target.value}),children:[n.jsx("option",{value:"",children:b.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:b.field.status}),n.jsx(ae,{value:e.status,onChange:L=>w({status:L}),items:F,placeholder:b.field.selectStatus,disabled:u||q==="Closed"})]})]}),n.jsxs("div",{style:As,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.startingDate}),n.jsx(ue,{value:e.starting_date,onChange:L=>w({starting_date:L}),disabled:u,style:{...E,...k}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.endingDate}),n.jsx(ue,{value:e.ending_date,onChange:L=>w({ending_date:L}),disabled:u,style:{...E,...k}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.actor}),n.jsxs("select",{style:{...E,...k},value:e.actor||e.assigned_to||"",disabled:u,onChange:L=>w({actor:L.target.value,assigned_to:L.target.value}),children:[n.jsx("option",{value:"",children:b.field.select}),C.map(L=>n.jsx("option",{value:L.name,children:L.full_name||L.name},L.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:Es,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.cycle}),n.jsx(ae,{value:e.cycle||"",onChange:L=>w({cycle:L}),items:je,placeholder:b.field.select,disabled:u})]}),n.jsxs("div",{style:{display:"flex",gap:20,flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.stage}),n.jsx("input",{type:"number",min:1,max:5,style:{...E,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:{...E,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:Ky[e.stage||1]||"—"})]}),(e.escalation_level??0)>0&&n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.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]})]})]})]})]}),R&&((on=e.order_cycle_log)==null?void 0:on.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:13},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8fafc"},children:["Cycle","Date","Stage","Status","Actor","Comment"].map(L=>n.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#475569",borderBottom:"1px solid #e2e8f0"},children:L},L))})}),n.jsx("tbody",{children:(e.order_cycle_log||[]).map((L,Ye)=>{const qn=L.status==="Agree"?"#166534":L.status==="Deviate"?"#c2410c":"#92400e",dt=L.status==="Agree"?"#f0fdf4":L.status==="Deviate"?"#fff7ed":"#fefce8";return n.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:L.cycle||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:L.cycle_date||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155",textAlign:"center"},children:L.stage||"—"}),n.jsx("td",{style:{padding:"6px 10px"},children:n.jsx("span",{style:{background:dt,color:qn,padding:"2px 8px",borderRadius:12,fontWeight:600,fontSize:12},children:L.status||"—"})}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:L.actor||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#64748b",fontStyle:L.comment?"normal":"italic"},children:L.comment||"—"})]},Ye)})})]})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.description}),n.jsx("textarea",{style:{...E,...k,height:100,resize:"vertical"},value:e.description,disabled:u,onChange:L=>w({description:L.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:b.field.notes}),n.jsx("textarea",{style:{...E,...k,height:100,resize:"vertical"},value:e.notes,disabled:u,onChange:L=>w({notes:L.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:b.field.auditorComment}),n.jsx("textarea",{style:{...E,height:80,resize:"vertical",...u&&Ct&&!P?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:u&&Ct&&!P,onChange:L=>w({auditor_comment:L.target.value}),placeholder:b.field.commentPlaceholder})]})]})}function Xy({processes:e,organizations:t,departments:l,branches:r,processStatuses:s,initialOrg:i,canModify:a,onView:d,onEdit:p,onDelete:f}){const h=J(),[c,u]=S.useState({search:"",organization:i||"",department:"",branch:"",status:""}),x=(o,g)=>u(j=>({...j,[o]:g})),[v,m]=S.useState(1),z=e.filter(o=>!(c.search&&!`${o.number} ${o.title}`.toLowerCase().includes(c.search.toLowerCase())||c.organization&&o.organization!==c.organization||c.department&&o.department!==c.department||c.branch&&o.branch!==c.branch||c.status&&o.status!==c.status));S.useEffect(()=>{m(1)},[c]);const y=z.slice((v-1)*te,v*te);return n.jsxs(n.Fragment,{children:[n.jsx(Ni,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.numberTitle}),n.jsx("input",{style:Re,value:c.search,onChange:o=>x("search",o.target.value),placeholder:h.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.organization}),n.jsxs("select",{style:Re,value:c.organization,onChange:o=>x("organization",o.target.value),children:[n.jsx("option",{value:"",children:h.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.department}),n.jsxs("select",{style:Re,value:c.department,onChange:o=>x("department",o.target.value),children:[n.jsx("option",{value:"",children:h.filter.allDepts}),l.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.branch}),n.jsxs("select",{style:Re,value:c.branch,onChange:o=>x("branch",o.target.value),children:[n.jsx("option",{value:"",children:h.filter.allBranches}),r.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:Ae,children:h.filter.status}),n.jsxs("select",{style:Re,value:c.status,onChange:o=>x("status",o.target.value),children:[n.jsx("option",{value:"",children:h.filter.allStatuses}),s.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name)),n.jsx("option",{value:"Closed",children:"Closed"})]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>u({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:h.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:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.number}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.title}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.organization}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.field.cycleType}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.status}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:h.col.actions})]})}),n.jsx("tbody",{children:z.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:h.noProcesses})}):y.map((o,g)=>n.jsxs("tr",{onClick:()=>d==null?void 0:d(o),style:{borderTop:"1px solid #f0f0f0",background:g%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",color:"#999"},children:o.number||"—"}),n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:o.title||o.name||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:o.cycle_type?In(o.cycle_type,"#8e44ad"):"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:o.status?In(o.status,Di(o.status)):"—"}),n.jsx("td",{style:{padding:"10px 18px"},onClick:j=>j.stopPropagation(),children:n.jsx(He,{onView:()=>d==null?void 0:d(o),onEdit:a&&p?()=>p(o):void 0,onDelete:a&&f?()=>f(o.name):void 0})})]},o.name))})]})}),n.jsx(Le,{page:v,total:z.length,onPageChange:m})]})}const Jy={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"]}]},qy={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 eu(e){return{display:"inline-block",padding:"5px 14px",borderRadius:20,fontSize:13,fontWeight:700,...qy[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}const Rs={width:"100%",padding:"6px 8px",border:"1px solid #d1d5db",borderRadius:5,fontSize:12,fontFamily:"Segoe UI",boxSizing:"border-box"};function Zy({processName:e,userRole:t,onRefresh:l,canUpdateStatus:r=!0}){const[s,i]=S.useState(null),[a,d]=S.useState(!0),[p,f]=S.useState(""),[h,c]=S.useState(!1),[u,x]=S.useState(""),[v,m]=S.useState(""),[z,y]=S.useState("Pass"),[o,g]=S.useState(""),[j,b]=S.useState({}),w=S.useCallback(async()=>{if(!e){d(!1);return}d(!0),f("");try{const $=await _r(e);i($);const ee={};for(const Z of $.progress_indicators||[])ee[Z.name]=Z.actual_value!=null?String(Z.actual_value):"";b(ee)}catch($){f($ instanceof Error?$.message:"Failed to load process")}d(!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 k=s.workflow_state||"Draft",C=Jy[k]??[],O=t==="Employee"||t==="Manager",U=t!=="Manager"||r,Q=C.filter($=>(t==="Admin"||$.allowedRoles.includes(t))&&($.action!=="Update Status"||U)),X=async $=>{c(!0),x(""),m("");try{const ee={};if($==="Update Status"){ee.actor_status=z,ee.actor_comment=o;const xe=s.progress_indicators||[];xe.length>0&&(ee.progress_indicators=xe.map(se=>({name:se.name,actual_value:j[se.name]??""})))}$==="Add Comment"&&o&&(ee.actor_comment=o);const Z=await yy(s.name,$,ee);i(Z),g(""),m(`Done — now: ${Z.workflow_state||"updated"}`),l==null||l()}catch(ee){x(ee instanceof Error?ee.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:eu(k),children:k})]}),k==="Pending Actor"&&O&&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:j[$.name]??"",onChange:ee=>b(Z=>({...Z,[$.name]:ee.target.value})),style:{...Rs,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:z,onChange:$=>y($.target.value),style:Rs,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:o,onChange:$=>g($.target.value),style:{...Rs,height:52,resize:"vertical"},placeholder:"Add a comment…"})]})]}),(k==="Pending Comment"||k==="Review")&&!O&&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,ee=$[$.length-1],Z=ee.status==="Pass"?"#16a34a":ee.status==="Fail"?"#dc2626":"#9ca3af";return n.jsxs("div",{style:{fontSize:13,fontWeight:700,color:Z},children:[ee.status," ",ee.comment?`— ${ee.comment}`:""]})})()]}),n.jsx("textarea",{value:o,onChange:$=>g($.target.value),style:{...Rs,height:52,resize:"vertical"},placeholder:"Add a comment…"})]}),n.jsxs("div",{style:{padding:"12px 14px",borderBottom:Q.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"}),Q.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:k}),"."]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Q.map($=>n.jsxs("button",{onClick:()=>X($.action),disabled:h,style:{width:"100%",padding:"10px 14px",borderRadius:6,border:"none",background:$.action==="Close Process"?"#64748b":$.action==="Move to Study"?"#8e44ad":"#2563eb",color:"white",cursor:h?"not-allowed":"pointer",fontSize:13,fontWeight:600,opacity:h?.7:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsx("span",{children:h?"Applying…":$.action}),n.jsxs("span",{style:{fontSize:10,opacity:.7},children:["→ ",$.next]})]},$.action))}),u&&n.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,fontSize:12,color:"#991b1b",lineHeight:1.4},children:u}),v&&n.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,fontSize:12,color:"#166534"},children:v})]}),C.length>0&&n.jsxs("div",{style:{padding:"12px 14px"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Next States"}),C.map($=>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:eu($.next),children:$.next})]},$.action))]})]})})}const Ls={display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},sl={display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:16};function Vy({processForm:e,setProcessForm:t,organizations:l,managements:r,departments:s,branches:i,processTypes:a,processStatuses:d,cycles:p=[],users:f=[],userRoleMap:h={},formStatus:c,viewMode:u,userRole:x,delegatedFunctions:v=[],delegatedOrgs:m=null,onRefreshProcess:z,onSubmit:y,onBack:o,onNavigate:g,onLogout:j,user:b}){const w=J(),k=I=>t({...e,...I}),C=u?{background:"#f9f9f9"}:{},O=!u&&x==="Manager"&&Array.isArray(m),U=O?l.filter(I=>(m||[]).includes(I.organization_name||I.name)):l,Q=O&&(m||[]).length===1,X=ce(r,e.management).map(I=>({name:I.name,label:I.name1||I.name})),$=ce(s,e.department).map(I=>({name:I.name,label:I.department_name||I.name})),ee=ce(i,e.branch).map(I=>({name:I.name,label:I.branch||I.name})),Z=ce(a,e.type).map(I=>({name:I.name,label:I.name1||I.name})),xe=ce(d,e.status).map(I=>({name:I.name,label:I.name1||I.name})),se=ce(p,e.cycle).map(I=>({name:I.name,label:I.name1||I.name})),A=Nl(f,h,"SB Employee").map(I=>({name:I.name,label:I.full_name||I.name})),B=(I,P)=>{const M=[...e.cycle_logs||[]];M[I]={...M[I],...P},k({cycle_logs:M})},H=()=>{k({cycle_logs:[...e.cycle_logs||[],{cycle:"",cycle_date:"",status:"Pass",actor:"",comment:""}]})},V=I=>{const P=[...e.cycle_logs||[]];P.splice(I,1),k({cycle_logs:P})},F=(I,P)=>{const M=[...e.progress_indicators||[]];M[I]={...M[I],...P},k({progress_indicators:M})},je=()=>{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:""}]})},R=I=>{const P=[...e.progress_indicators||[]];P.splice(I,1),k({progress_indicators:P})},q=e.name?u?`${w.formTitle.viewProcess}${e.title||e.name}`:w.formTitle.editProcess:w.formTitle.newProcess,$e=x!=="Manager"||e.actor===b.name||v.includes("update_process_status"),De=e.name?n.jsxs("div",{style:{width:260,display:"flex",flexDirection:"column",gap:14},children:[n.jsx(Zy,{processName:e.name,userRole:x||b.role||"Employee",onRefresh:z,canUpdateStatus:$e}),n.jsx(Wi,{doctype:D.processes,docname:e.name,currentUserName:b.name}),n.jsx(Bi,{doctype:D.processes,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):void 0;return n.jsxs(Oe,{title:q,activePage:"processes",user:b,formStatus:c,buttonText:w.saveProcess,buttonColor:N.blue,viewMode:u,rightPanel:De,onSubmit:y,onBack:o,onNavigate:g,onLogout:j,children:[n.jsxs("div",{style:Ls,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.number}),n.jsx("input",{style:{...E,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:I=>k({organization:I}),organizations:U,disabled:u||Q}),O&&n.jsx("div",{style:{fontSize:11,color:"#888",marginTop:4},children:(m||[]).length===0?"You have no delegated organization for Processes.":`Restricted to your delegated organization${(m||[]).length>1?"s":""}: ${(m||[]).join(", ")}`})]})]}),n.jsxs("div",{style:Ls,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.title}),n.jsx("input",{style:{...E,...C},value:e.title,disabled:u,onChange:I=>k({title:I.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.type}),n.jsx(ae,{value:e.type,onChange:I=>k({type:I}),items:Z,placeholder:w.field.selectType,disabled:u})]})]}),n.jsxs("div",{style:sl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.management}),n.jsx(ae,{value:e.management,onChange:I=>k({management:I}),items:X,placeholder:w.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.department}),n.jsx(ae,{value:e.department,onChange:I=>k({department:I}),items:$,placeholder:w.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.section}),n.jsx("input",{style:{...E,...C},value:e.section_field||"",disabled:u,onChange:I=>k({section_field:I.target.value})})]})]}),n.jsxs("div",{style:Ls,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.branch}),n.jsx(ae,{value:e.branch,onChange:I=>k({branch:I}),items:ee,placeholder:w.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[w.field.status," ",n.jsx("span",{style:{fontSize:11,color:"#9ca3af",fontWeight:400},children:"(auto-updated from cycle)"})]}),n.jsx(ae,{value:e.status,onChange:I=>k({status:I}),items:xe,placeholder:w.field.selectStatus,disabled:u})]})]}),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:sl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.chainLocation}),n.jsxs("select",{style:{...E,...C},value:e.chain_location||"",disabled:u,onChange:I=>k({chain_location:I.target.value}),children:[n.jsx("option",{value:"",children:w.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:w.field.economyClass}),n.jsxs("select",{style:{...E,...C},value:e.economy_class||"",disabled:u,onChange:I=>k({economy_class:I.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.impactLevel}),n.jsxs("select",{style:{...E,...C},value:e.impact_level||"",disabled:u,onChange:I=>k({impact_level:I.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",{style:sl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.entityScope}),n.jsxs("select",{style:{...E,...C},value:e.entity_scope||"",disabled:u,onChange:I=>k({entity_scope:I.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",{children:[n.jsx("label",{style:T,children:w.field.hsesField}),n.jsx("input",{style:{...E,...C},value:e.hses_field||"",disabled:u,onChange:I=>k({hses_field:I.target.value}),placeholder:"Safety, Health, Environment…"})]}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,paddingTop:22},children:n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:u,onChange:I=>k({product_relation:I.target.checked?1:0})})," ",w.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:sl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.kpiName}),n.jsx("input",{style:{...E,...C},value:e.kpi_name||"",disabled:u,onChange:I=>k({kpi_name:I.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.kpiType}),n.jsxs("select",{style:{...E,...C},value:e.kpi_type||"",disabled:u,onChange:I=>k({kpi_type:I.target.value}),children:[n.jsx("option",{value:"",children:w.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:w.field.kpiMeasure}),n.jsx("input",{style:{...E,...C},value:e.kpi_measure||"",disabled:u,onChange:I=>k({kpi_measure:I.target.value}),placeholder:"Unit of measure"})]})]})]}),n.jsxs("div",{style:sl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.dateStart}),n.jsx(ue,{value:e.date_start,onChange:I=>k({date_start:I}),disabled:u,style:{...E,...C}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.dateEnd}),n.jsx(ue,{value:e.date_end,onChange:I=>k({date_end:I}),disabled:u,style:{...E,...C}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.cycleType}),n.jsxs("select",{style:{...E,...C},value:e.cycle_type||"",disabled:u,onChange:I=>k({cycle_type:I.target.value}),children:[n.jsx("option",{value:"",children:w.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:Ls,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Milestone 1"}),n.jsx(ue,{value:e.long_cycle_date_1||"",onChange:I=>k({long_cycle_date_1:I}),disabled:u,style:{...E,...C}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Milestone 2"}),n.jsx(ue,{value:e.long_cycle_date_2||"",onChange:I=>k({long_cycle_date_2:I}),disabled:u,style:{...E,...C}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Milestone 3"}),n.jsx(ue,{value:e.long_cycle_date_3||"",onChange:I=>k({long_cycle_date_3:I}),disabled:u,style:{...E,...C}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Milestone 4"}),n.jsx(ue,{value:e.long_cycle_date_4||"",onChange:I=>k({long_cycle_date_4:I}),disabled:u,style:{...E,...C}})]})]})]}),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"}),!u&&n.jsx("button",{type:"button",onClick:je,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:13,width:"max-content",minWidth:"100%"},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa"},children:[n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Order"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Name"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Type"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Unit"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Target"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Min"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Max"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Manager"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Actual Value"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle Status"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle Date"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle Comment"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Status"}),!u&&n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Actions"})]})}),n.jsxs("tbody",{children:[(e.progress_indicators||[]).length===0&&n.jsx("tr",{children:n.jsx("td",{colSpan:u?14:15,style:{padding:18,textAlign:"center",color:"#aaa"},children:"No progress indicators"})}),(e.progress_indicators||[]).map((I,P)=>n.jsxs("tr",{style:{background:P%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...C,width:60},value:I.order??"",disabled:u,onChange:M=>F(P,{order:M.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...C},value:I.name1,disabled:u,onChange:M=>F(P,{name1:M.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...E,...C},value:I.type,disabled:u,onChange:M=>F(P,{type:M.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:{...E,...C,width:70},type:"number",value:I.unit??"",disabled:u,onChange:M=>F(P,{unit:parseFloat(M.target.value)||""})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...C},value:I.cycle,disabled:u,onChange:M=>F(P,{cycle:M.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...C,width:80},value:I.target,disabled:u,onChange:M=>F(P,{target:M.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...C,width:80},value:I.minimum,disabled:u,onChange:M=>F(P,{minimum:M.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...C,width:80},value:I.maximum,disabled:u,onChange:M=>F(P,{maximum:M.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...C},value:I.manager,disabled:u,onChange:M=>F(P,{manager:M.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...C,width:90},type:"number",value:I.actual_value??"",disabled:u,onChange:M=>F(P,{actual_value:parseFloat(M.target.value)||""})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...E,...C},value:I.cycle_status??"",disabled:u,onChange:M=>F(P,{cycle_status:M.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(ue,{value:I.cycle_date||"",onChange:M=>F(P,{cycle_date:M}),disabled:u,style:{...E,...C,width:110}})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...C},value:I.cycle_comment??"",disabled:u,onChange:M=>F(P,{cycle_comment:M.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...E,...C},value:I.status??"",disabled:u,onChange:M=>F(P,{status:M.target.value}),children:[n.jsx("option",{value:"",children:"--"}),n.jsx("option",{children:"Normal"}),n.jsx("option",{children:"Below Min"}),n.jsx("option",{children:"Above Max"}),n.jsx("option",{children:"At Risk"})]})}),!u&&n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("button",{type:"button",onClick:()=>R(P),style:{padding:"6px 10px",border:"1px solid #e74c3c",background:"white",color:"#e74c3c",borderRadius:6,cursor:"pointer"},children:"Remove"})})]},P))]})]})})]}),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:sl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.cycle}),n.jsx(ae,{value:e.cycle||"",onChange:I=>k({cycle:I}),items:se,placeholder:w.field.select,disabled:u})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.actor}),n.jsxs("select",{style:{...E,...C},value:e.actor||"",disabled:u,onChange:I=>k({actor:I.target.value}),children:[n.jsx("option",{value:"",children:w.field.select}),A.map(I=>n.jsx("option",{value:I.name,children:I.label},I.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:w.field.costPerCycle}),n.jsx("input",{style:{...E,...C},type:"number",value:e.cost_per_cycle||"",disabled:u,onChange:I=>k({cost_per_cycle:parseFloat(I.target.value)||0}),placeholder:"0.00"})]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:T,children:w.field.escalationLevel}),n.jsx("input",{style:{...E,...C,maxWidth:120},type:"number",value:e.escalation_level||"",disabled:u,onChange:I=>k({escalation_level:parseInt(I.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"}),!u&&n.jsx("button",{type:"button",onClick:H,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:13,width:"max-content",minWidth:"100%"},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa"},children:[n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Cycle"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Date"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Status"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Actor"}),n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Comment"}),!u&&n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"Actions"})]})}),n.jsxs("tbody",{children:[(e.cycle_logs||[]).length===0&&n.jsx("tr",{children:n.jsx("td",{colSpan:u?5:6,style:{padding:18,textAlign:"center",color:"#aaa"},children:"No cycle history"})}),(e.cycle_logs||[]).map((I,P)=>n.jsxs("tr",{style:{background:P%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...E,...C},value:I.cycle||"",disabled:u,onChange:M=>B(P,{cycle:M.target.value}),children:[n.jsx("option",{value:"",children:"-- Select --"}),se.map(M=>n.jsx("option",{value:M.name,children:M.label},M.name))]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx(ue,{value:I.cycle_date||"",onChange:M=>B(P,{cycle_date:M}),disabled:u,style:{...E,...C,width:130}})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...E,...C},value:I.status,disabled:u,onChange:M=>B(P,{status:M.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:{...E,...C},value:I.actor||"",disabled:u,onChange:M=>B(P,{actor:M.target.value}),children:[n.jsx("option",{value:"",children:"-- Select --"}),A.map(M=>n.jsx("option",{value:M.name,children:M.label},M.name))]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...C},value:I.comment||"",disabled:u,onChange:M=>B(P,{comment:M.target.value})})}),!u&&n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("button",{type:"button",onClick:()=>V(P),style:{padding:"6px 10px",border:"1px solid #e74c3c",background:"white",color:"#e74c3c",borderRadius:6,cursor:"pointer"},children:"Remove"})})]},P))]})]})})]}),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:w.field.auditorComment}),n.jsx("textarea",{style:{...E,height:80,resize:"vertical",...u?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:u,onChange:I=>k({auditor_comment:I.target.value}),placeholder:w.field.commentPlaceholder})]})]})}const tu={"SB Process":"processes-form","SB Order":"orders-form","SB Incident":"incidents-form","SB Idea":"ideas-form","SB Delegation":"delegations"};function e1(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 t1({notifCount:e,darkMode:t,onCountChange:l,onToggleDark:r,onViewProfile:s,onLogout:i,onNavigate:a}){const[d,p]=S.useState(!1),[f,h]=S.useState([]),[c,u]=S.useState(!1),x=S.useRef(null);S.useEffect(()=>{const C=O=>{x.current&&!x.current.contains(O.target)&&p(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[]);const v=async()=>{u(!0);const C=await qm(30);h(C),u(!1)},m=()=>{const C=!d;p(C),C&&v()},z=async()=>{await Zm(),h(C=>C.map(O=>({...O,read:1}))),l(0)},y=C=>{C.read||(Vm(C.name),h(U=>U.map(Q=>Q.name===C.name?{...Q,read:1}:Q)),l(Math.max(0,e-1)));const O=C.document_type?tu[C.document_type]:void 0;O&&a&&(a(O,C.document_type==="SB Delegation"?void 0:C.document_name),p(!1))},o=f.filter(C=>!C.read).length,g=C=>({position:"relative",width:38,height:38,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:t?"#2d3748":"#f3f4f6",color:t?"#e2e8f0":"#6b7280",fontSize:16,transition:"background 0.15s",flexShrink:0,...C}),j=t,b=j?"#1a202c":"white",w=j?"#2d3748":"#e5e7eb",k=j?"#e2e8f0":"#1a2332";return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx("button",{style:g({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:x,style:{position:"relative"},children:[n.jsxs("button",{style:g(),onClick:m,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})]}),d&&n.jsxs("div",{style:{position:"absolute",right:0,top:"calc(100% + 8px)",width:340,background:b,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:b},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:k},children:["Notifications",o>0&&n.jsxs("span",{style:{background:"#ef4444",color:"white",fontSize:10,fontWeight:700,borderRadius:999,padding:"2px 7px"},children:[o," new"]})]}),o>0&&n.jsx("button",{onClick:z,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(C=>{const O=!!(C.document_type&&tu[C.document_type]&&a);return n.jsxs("div",{onClick:()=>y(C),style:{padding:"11px 16px",borderBottom:`1px solid ${j?"#2d3748":"#f5f5f5"}`,display:"flex",gap:10,background:C.read?b:j?"#1e3a5f":"#eff6ff",cursor:O?"pointer":"default",transition:"background 0.12s"},onMouseEnter:U=>{O&&(U.currentTarget.style.background=j?"#243244":"#e0ecfd")},onMouseLeave:U=>{U.currentTarget.style.background=C.read?b:j?"#1e3a5f":"#eff6ff"},children:[n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:13,fontWeight:C.read?400:600,color:k,marginBottom:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.subject||`${C.document_type}: ${C.document_name}`}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:C.document_type&&n.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#3b82f6",background:j?"rgba(59,130,246,0.15)":"#eff6ff",padding:"1px 7px",borderRadius:8},children:[C.document_type.replace("SB ",""),C.document_name?` · ${C.document_name}`:""]})}),n.jsx("div",{style:{fontSize:11,color:"#aaa",marginTop:3},children:e1(C.creation)})]}),!C.read&&n.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:"#3498db",flexShrink:0,marginTop:5}})]},C.name)})]})]})]}),n.jsx("button",{style:g(),onClick:zf,title:wl()?"Switch to English":"Switch to Arabic",children:n.jsx("span",{style:{fontSize:13,fontWeight:700,fontFamily:"serif"},children:"عA"})}),n.jsx("button",{style:g(),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:g({background:j?"#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 n1={Admin:"#7c3aed",Auditor:"#d97706",Owner:"#0369a1",XAuditor:"#0f766e",Manager:"#2563eb",Employee:"#6b7280",Chairman:"#0f766e"};function l1({user:e,profileUser:t,darkMode:l,canModify:r,onBack:s,organizations:i=[],managements:a=[],departments:d=[],branches:p=[]}){const f=t||{},h=!!r&&e.role==="Admin",[c,u]=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||""}),[x,v]=S.useState(""),[m,z]=S.useState(!1),[y,o]=S.useState({new:"",confirm:""}),[g,j]=S.useState(""),b=f.email||f.name||"",w=[c.first_name,c.middle_name,c.last_name].filter(Boolean).join(" ")||f.full_name||"",k=f.username||f.name||"",C=c.custom_category||"",O=f.enabled===0?"Inactive":"Active",U=n1[e.role]||"#6b7280",Q=l,X=Q?"#0f172a":"#f0f2f5",$=Q?"#1e293b":"white",ee=Q?"#2d3748":"#e5e7eb",Z=Q?"#e2e8f0":"#1a2332",xe=Q?"#94a3b8":"#6b7280",se=Q?"#374151":"white",A=Q?"#2d3748":"#f9fafb",B={width:"100%",padding:"9px 12px",borderRadius:8,border:`1px solid ${ee}`,fontSize:13,background:se,color:Z,fontFamily:"inherit",outline:"none"},H={...B,background:A,color:xe},V={...B,cursor:"pointer"},F={fontSize:12,fontWeight:600,color:xe,marginBottom:5,display:"block"},je={display:"grid",gridTemplateColumns:"1fr 1fr",gap:14},R={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:14},q=async()=>{if(r){v("saving");try{await vi("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}),v("saved"),setTimeout(()=>v(""),2e3)}catch{v("error"),setTimeout(()=>v(""),3e3)}}},$e=async()=>{if(!y.new){j("Enter a new password");return}if(y.new!==y.confirm){j("Passwords do not match");return}j("saving");try{await Pf(f.name,y.new),j("done"),o({new:"",confirm:""}),setTimeout(()=>{j(""),z(!1)},2e3)}catch{j("error")}},De=({title:I,icon:P,children:M})=>n.jsxs("div",{style:{background:$,borderRadius:12,padding:22,border:`1px solid ${ee}`,boxShadow:`0 1px 4px rgba(0,0,0,${Q?.3:.06})`},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,paddingBottom:14,borderBottom:`1px solid ${ee}`},children:[P,n.jsx("span",{style:{fontSize:14,fontWeight:700,color:Z},children:I})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:M})]});return n.jsxs("div",{style:{background:X,minHeight:"100%",padding:"0 0 32px"},children:[n.jsxs("div",{style:{background:$,borderBottom:`1px solid ${ee}`,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:Z,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:q,style:{display:"flex",alignItems:"center",gap:8,background:x==="saved"?"#16a34a":x==="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"})]}),x==="saving"?"Saving…":x==="saved"?"Saved!":x==="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||b}),n.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.75)",textAlign:"center"},children:b})]}),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:k},{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:C||"—"},{icon:n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:O==="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:O,valueColor:O==="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:b},{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:I,label:P,value:M,valueColor:Ct})=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 16px",borderBottom:`1px solid ${ee}`},children:[n.jsx("div",{style:{flexShrink:0,width:18,display:"flex",justifyContent:"center"},children:I}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:11,color:xe,marginBottom:1},children:P}),n.jsx("div",{style:{fontSize:13,fontWeight:600,color:Ct||Z,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:M})]})]},P))})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:18},children:[n.jsxs(De,{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:je,children:[n.jsxs("div",{children:[n.jsxs("label",{style:F,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:{...H,paddingLeft:32},value:b,readOnly:!0})]})]}),n.jsxs("div",{children:[n.jsxs("label",{style:F,children:["Full Name ",n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Auto-generated)"})]}),n.jsx("input",{style:H,value:w,readOnly:!0})]})]}),n.jsxs("div",{style:R,children:[n.jsxs("div",{children:[n.jsxs("label",{style:F,children:["First Name ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{style:r?B:H,value:c.first_name,readOnly:!r,onChange:I=>u(P=>({...P,first_name:I.target.value})),placeholder:"First name"})]}),n.jsxs("div",{children:[n.jsx("label",{style:F,children:"Middle Name"}),n.jsx("input",{style:r?B:H,value:c.middle_name,readOnly:!r,onChange:I=>u(P=>({...P,middle_name:I.target.value})),placeholder:"Middle name"})]}),n.jsxs("div",{children:[n.jsx("label",{style:F,children:"Last Name"}),n.jsx("input",{style:r?B:H,value:c.last_name,readOnly:!r,onChange:I=>u(P=>({...P,last_name:I.target.value})),placeholder:"Last name"})]})]}),n.jsxs("div",{style:je,children:[n.jsxs("div",{children:[n.jsx("label",{style:F,children:"Phone Number"}),n.jsx("input",{style:r?B:H,value:c.mobile_no,readOnly:!r,onChange:I=>u(P=>({...P,mobile_no:I.target.value})),placeholder:"Phone number"})]}),n.jsxs("div",{children:[n.jsx("label",{style:F,children:"User ID No"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx("input",{style:{...H,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:F,children:["Category ",!h&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),h?n.jsxs("select",{style:V,value:c.custom_category,onChange:I=>u(P=>({...P,custom_category:I.target.value})),children:[n.jsx("option",{value:"",children:"Select category"}),["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"].map(I=>n.jsx("option",{value:I,children:I},I))]}):n.jsx("input",{style:H,value:C||"—",readOnly:!0})]})]}),n.jsxs(De,{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:je,children:[n.jsxs("div",{children:[n.jsxs("label",{style:F,children:["Organization ",!h&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),h?n.jsxs("select",{style:V,value:c.custom_organization,onChange:I=>u(P=>({...P,custom_organization:I.target.value})),children:[n.jsx("option",{value:"",children:"Select organization"}),ce(i,c.custom_organization).map(I=>n.jsx("option",{value:I.name,children:I.organization_name||I.name},I.name))]}):n.jsx("input",{style:H,value:c.custom_organization||"—",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:F,children:["Management ",!h&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),h?n.jsxs("select",{style:V,value:c.custom_management,onChange:I=>u(P=>({...P,custom_management:I.target.value})),children:[n.jsx("option",{value:"",children:"Select management"}),ce(a,c.custom_management).map(I=>n.jsx("option",{value:I.name,children:I.name1||I.name},I.name))]}):n.jsx("input",{style:H,value:c.custom_management||"—",readOnly:!0})]})]}),n.jsxs("div",{style:je,children:[n.jsxs("div",{children:[n.jsxs("label",{style:F,children:["Department ",!h&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),h?n.jsxs("select",{style:V,value:c.custom_department,onChange:I=>u(P=>({...P,custom_department:I.target.value})),children:[n.jsx("option",{value:"",children:"Select department"}),ce(d,c.custom_department).map(I=>n.jsx("option",{value:I.name,children:I.department_name||I.name},I.name))]}):n.jsx("input",{style:H,value:c.custom_department||"—",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:F,children:["Branch ",!h&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),h?n.jsxs("select",{style:V,value:c.custom_branch,onChange:I=>u(P=>({...P,custom_branch:I.target.value})),children:[n.jsx("option",{value:"",children:"Select branch"}),ce(p,c.custom_branch).map(I=>n.jsx("option",{value:I.name,children:I.branch||I.name},I.name))]}):n.jsx("input",{style:H,value:c.custom_branch||"—",readOnly:!0})]})]})]}),n.jsxs("div",{style:{background:$,borderRadius:12,padding:22,border:`1px solid ${ee}`,boxShadow:`0 1px 4px rgba(0,0,0,${Q?.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:Z},children:"Change Password"})]}),r&&n.jsx("button",{onClick:()=>{z(I=>!I),j("")},style:{fontSize:13,color:"#3b82f6",background:"none",border:"none",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:m?"Cancel":"Change Password"})]}),m&&n.jsxs("div",{style:{marginTop:18,display:"flex",flexDirection:"column",gap:12},children:[n.jsxs("div",{style:R,children:[n.jsxs("div",{children:[n.jsxs("label",{style:F,children:["New Password ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{type:"password",style:B,value:y.new,onChange:I=>o(P=>({...P,new:I.target.value})),placeholder:"New password"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:F,children:["Confirm Password ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{type:"password",style:B,value:y.confirm,onChange:I=>o(P=>({...P,confirm:I.target.value})),placeholder:"Confirm password"})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:$e,style:{width:"100%",padding:"9px 0",borderRadius:8,border:"none",background:"#2563eb",color:"white",fontWeight:700,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:g==="saving"?"Saving…":"Update Password"})})]}),g&&g!=="saving"&&n.jsx("div",{style:{fontSize:13,color:g==="done"?"#16a34a":"#dc2626",fontWeight:500},children:g==="done"?"Password updated successfully":g==="error"?"Failed to update password":g})]})]})]})]})]})}function _e({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 Af={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151",boxSizing:"border-box"},r1={...Af,cursor:"pointer"};function rt({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:Af,placeholder:s.placeholder,value:s.value,onChange:a=>s.onChange(a.target.value)}):n.jsx("select",{style:r1,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 s1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function i1({organizations:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=J(),[a,d]=S.useState(""),[p,f]=S.useState("all"),[h,c]=S.useState("all"),u={padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},x=S.useMemo(()=>e.filter(y=>{const o=[y.organization_name,y.city].filter(Boolean).join(" ").toLowerCase();return!(a&&!o.includes(a.toLowerCase())||p!=="all"&&y.type!==p||h!=="all"&&(y.is_active?"Active":"Inactive")!==h)}),[e,a,p,h]),[v,m]=S.useState(1);S.useEffect(()=>{m(1)},[a,p,h]);const z=x.slice((v-1)*te,v*te);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(_e,{label:"Total",val:x.length,color:"#1a2332"}),n.jsx(_e,{label:"Active",val:x.filter(y=>y.is_active).length,color:N.green}),n.jsx(_e,{label:"Government",val:x.filter(y=>y.type==="Government").length,color:N.blue}),n.jsx(_e,{label:"Private",val:x.filter(y=>y.type==="Private").length,color:N.orange})]}),n.jsx(rt,{filters:[{type:"search",label:"Search",value:a,onChange:d,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:h,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:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:u,children:i.col.name}),n.jsx("th",{style:u,children:i.col.type}),n.jsx("th",{style:u,children:i.col.city}),n.jsx("th",{style:u,children:i.field.creationDate}),n.jsx("th",{style:u,children:i.col.status}),n.jsx("th",{style:u,children:i.col.actions})]})}),n.jsx("tbody",{children:x.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):z.map((y,o)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(y),style:{borderTop:"1px solid #f0f0f0",background:o%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:y.organization_name||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:y.type||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:y.city||"—"}),n.jsx("td",{style:{padding:"12px 18px",color:"#666"},children:s1(y.creation_date)}),n.jsx("td",{style:{padding:"12px 18px"},children:In(y.is_active?i.field.statusActive:i.field.statusInactive,y.is_active?N.green:N.gray)}),n.jsx("td",{style:{padding:"10px 18px"},onClick:g=>g.stopPropagation(),children:n.jsx(He,{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(Le,{page:v,total:x.length,onPageChange:m})]})}const Qt=e=>({background:e?"#f9f9f9":void 0});function a1({orgForm:e,setOrgForm:t,formStatus:l,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,user:p}){const f=J(),h=e.name?r&&e.organization_name||f.formTitle.editOrg:f.formTitle.newOrg;return n.jsxs(Oe,{title:h,activePage:"organizations",user:p,formStatus:l,buttonText:f.saveOrg,buttonColor:N.accent,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.orgName}),n.jsx("input",{type:"text",style:{...E,...Qt(r)},value:e.organization_name,disabled:r,onChange:c=>t({...e,organization_name:c.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.orgAcronym}),n.jsx("input",{type:"text",style:{...E,...Qt(r)},value:e.acronym||"",disabled:r,onChange:c=>t({...e,acronym:c.target.value})})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.organizationType}),n.jsxs("select",{style:{...E,...Qt(r)},value:e.type,disabled:r,onChange:c=>t({...e,type:c.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:f.field.orgCity}),n.jsx("input",{type:"text",style:{...E,...Qt(r)},value:e.city,disabled:r,onChange:c=>t({...e,city:c.target.value})})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.contactEmail}),n.jsx("input",{type:"email",style:{...E,...Qt(r)},value:e.contact_email,disabled:r,onChange:c=>t({...e,contact_email:c.target.value})})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.creationDate}),n.jsx(ue,{value:e.creation_date||"",onChange:c=>t({...e,creation_date:c}),disabled:r,style:{...E,...Qt(r)}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.status}),n.jsxs("select",{style:{...E,...Qt(r)},value:e.is_active?"Active":"Inactive",disabled:r,onChange:c=>t({...e,is_active:c.target.value==="Active"?1:0}),children:[n.jsx("option",{value:"Active",children:f.field.statusActive}),n.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.incidentTriageWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...E,...Qt(r)},value:e.incident_triage_window_days??3,disabled:r,onChange:c=>t({...e,incident_triage_window_days:parseInt(c.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:f.field.incidentResolutionWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...E,...Qt(r)},value:e.incident_resolution_window_days??5,disabled:r,onChange:c=>t({...e,incident_resolution_window_days:parseInt(c.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 o1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function c1({managements:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=J(),[a,d]=S.useState(""),[p,f]=S.useState("all"),h={padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},c=S.useMemo(()=>e.filter(m=>{const z=(m.name1||m.name||"").toLowerCase();return!(a&&!z.includes(a.toLowerCase())||p!=="all"&&(m.status||"Active")!==p)}),[e,a,p]),[u,x]=S.useState(1);S.useEffect(()=>{x(1)},[a,p]);const v=c.slice((u-1)*te,u*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:c.length,color:N.blue})}),n.jsx(rt,{filters:[{type:"search",label:"Search",value:a,onChange:d,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:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:h,children:i.col.name}),n.jsx("th",{style:h,children:i.field.creationDate}),n.jsx("th",{style:h,children:i.field.status}),n.jsx("th",{style:h,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})}):v.map((m,z)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(m),style:{borderTop:"1px solid #f0f0f0",background:z%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:m.name1||m.name||"—"}),n.jsx("td",{style:{padding:"12px 18px",color:"#666"},children:o1(m.creation_date)}),n.jsx("td",{style:{padding:"12px 18px"},children:n.jsx("span",{style:{color:m.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:m.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"10px 18px"},onClick:y=>y.stopPropagation(),children:n.jsx(He,{onView:()=>l==null?void 0:l(m),onEdit:t&&r?()=>r(m):void 0,onDelete:t&&s?()=>s(m.name):void 0})})]},m.name))})]})}),n.jsx(Le,{page:u,total:c.length,onPageChange:x})]})}function d1({form:e,setForm:t,organizations:l,formStatus:r,viewMode:s,onSubmit:i,onBack:a,onNavigate:d,onLogout:p,user:f}){const h=J(),c=v=>t(m=>({...m,...v})),u=s?{background:"#f9f9f9"}:{},x=e.name?s?`${h.formTitle.editMgmt}: ${e.name1||e.name}`:h.formTitle.editMgmt:h.formTitle.newMgmt;return n.jsxs(Oe,{title:x,activePage:"managements",user:f,formStatus:r,buttonText:h.saveMgmt,buttonColor:N.blue,viewMode:s,onSubmit:i,onBack:a,onNavigate:d,onLogout:p,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.organization}),n.jsx(_t,{value:e.organization,onChange:v=>c({organization:v}),organizations:l,disabled:s})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...u},value:e.name1,disabled:s,onChange:v=>c({name1:v.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:h.field.creationDate}),n.jsx(ue,{value:e.creation_date||"",onChange:v=>c({creation_date:v}),disabled:s,style:{...E,...u}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.status}),n.jsxs("select",{style:{...E,...u},value:e.status||"Active",disabled:s,onChange:v=>c({status:v.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})]})}function u1(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 p1({departments:e,managements:t,canModify:l,onView:r,onEdit:s,onDelete:i}){const a=J(),[d,p]=S.useState(""),[f,h]=S.useState(""),[c,u]=S.useState("all"),x=g=>{var j;return((j=t.find(b=>b.name===g))==null?void 0:j.name1)||g||"—"},v={padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},m=S.useMemo(()=>e.filter(g=>{const j=(g.department_name||g.name||"").toLowerCase();return!(d&&!j.includes(d.toLowerCase())||f&&g.custom_management!==f||c!=="all"&&(g.custom_status||"Active")!==c)}),[e,d,f,c]),[z,y]=S.useState(1);S.useEffect(()=>{y(1)},[d,f,c]);const o=m.slice((z-1)*te,z*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:m.length,color:N.teal})}),n.jsx(rt,{filters:[{type:"search",label:"Search",value:d,onChange:p,placeholder:"Search by name…"},{type:"select",label:a.col.management,value:f,onChange:h,options:[{value:"",label:"All Managements"},...t.map(g=>({value:g.name,label:g.name1||g.name}))]},{type:"select",label:"Status",value:c,onChange:u,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:a.col.name}),n.jsx("th",{style:v,children:a.col.management}),n.jsx("th",{style:v,children:a.field.creationDate}),n.jsx("th",{style:v,children:a.field.status}),n.jsx("th",{style:v,children:a.col.actions})]})}),n.jsx("tbody",{children:m.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):o.map((g,j)=>n.jsxs("tr",{onClick:()=>r==null?void 0:r(g),style:{borderTop:"1px solid #f0f0f0",background:j%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:g.department_name||g.name||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:x(g.custom_management)}),n.jsx("td",{style:{padding:"12px 18px",color:"#666"},children:u1(g.custom_creation_date)}),n.jsx("td",{style:{padding:"12px 18px"},children:n.jsx("span",{style:{color:g.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.custom_status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),n.jsx("td",{style:{padding:"10px 18px"},onClick:b=>b.stopPropagation(),children:n.jsx(He,{onView:()=>r==null?void 0:r(g),onEdit:l&&s?()=>s(g):void 0,onDelete:l&&i?()=>i(g.name):void 0})})]},g.name))})]})}),n.jsx(Le,{page:z,total:m.length,onPageChange:y})]})}const f1={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20};function h1({form:e,setForm:t,organizations:l,managements:r,formStatus:s,viewMode:i,onSubmit:a,onBack:d,onNavigate:p,onLogout:f,user:h}){const c=J(),u=z=>t(y=>({...y,...z})),x=i?{background:"#f9f9f9"}:{},v=e.name?i?`${c.formTitle.editDept}: ${e.department_name||e.name}`:c.formTitle.editDept:c.formTitle.newDept,m=ce(r,e.custom_management).map(z=>({name:z.name,label:z.name1||z.name}));return n.jsxs(Oe,{title:v,activePage:"departments",user:h,formStatus:s,buttonText:c.saveDept,buttonColor:N.teal,viewMode:i,onSubmit:a,onBack:d,onNavigate:p,onLogout:f,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.organization}),n.jsx(_t,{value:e.custom_organization,onChange:z=>u({custom_organization:z}),organizations:l,disabled:i})]}),n.jsxs("div",{style:f1,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[c.field.department," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...x},value:e.department_name,disabled:i,onChange:z=>u({department_name:z.target.value}),placeholder:"Department name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.management}),n.jsx(ae,{value:e.custom_management,onChange:z=>u({custom_management:z}),items:m,placeholder:c.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:c.field.creationDate}),n.jsx(ue,{value:e.custom_creation_date||"",onChange:z=>u({custom_creation_date:z}),disabled:i,style:{...E,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:c.field.status}),n.jsxs("select",{style:{...E,...x},value:e.custom_status||"Active",disabled:i,onChange:z=>u({custom_status:z.target.value}),children:[n.jsx("option",{value:"Active",children:c.field.statusActive}),n.jsx("option",{value:"Inactive",children:c.field.statusInactive})]})]})]})]})}function g1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function x1({branches:e,managements:t,departments:l,canModify:r,onView:s,onEdit:i,onDelete:a}){const d=J(),[p,f]=S.useState(""),[h,c]=S.useState(""),[u,x]=S.useState(""),[v,m]=S.useState("all"),z=k=>{var C;return((C=t.find(O=>O.name===k))==null?void 0:C.name1)||k||"—"},y=k=>{var C;return((C=l.find(O=>O.name===k))==null?void 0:C.department_name)||k||"—"},o={padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},g=S.useMemo(()=>e.filter(k=>{const C=(k.branch||k.name||"").toLowerCase();return!(p&&!C.includes(p.toLowerCase())||h&&k.management!==h||u&&k.department!==u||v!=="all"&&(k.custom_status||"Active")!==v)}),[e,p,h,u,v]),[j,b]=S.useState(1);S.useEffect(()=>{b(1)},[p,h,u,v]);const w=g.slice((j-1)*te,j*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:g.length,color:N.purple})}),n.jsx(rt,{filters:[{type:"search",label:"Search",value:p,onChange:f,placeholder:"Search by name…"},{type:"select",label:d.col.management,value:h,onChange:c,options:[{value:"",label:"All Managements"},...t.map(k=>({value:k.name,label:k.name1||k.name}))]},{type:"select",label:d.col.department,value:u,onChange:x,options:[{value:"",label:"All Departments"},...l.map(k=>({value:k.name,label:k.department_name||k.name}))]},{type:"select",label:"Status",value:v,onChange:m,options:[{value:"all",label:"All"},{value:"Active",label:d.field.statusActive},{value:"Inactive",label:d.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:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:o,children:d.col.branch}),n.jsx("th",{style:o,children:d.col.management}),n.jsx("th",{style:o,children:d.col.department}),n.jsx("th",{style:o,children:d.field.creationDate}),n.jsx("th",{style:o,children:d.field.status}),n.jsx("th",{style:o,children:d.col.actions})]})}),n.jsx("tbody",{children:g.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:d.noData})}):w.map((k,C)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(k),style:{borderTop:"1px solid #f0f0f0",background:C%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:k.branch||k.name||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:z(k.management)}),n.jsx("td",{style:{padding:"12px 18px"},children:y(k.department)}),n.jsx("td",{style:{padding:"12px 18px",color:"#666"},children:g1(k.custom_creation_date)}),n.jsx("td",{style:{padding:"12px 18px"},children:n.jsx("span",{style:{color:k.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:k.custom_status==="Inactive"?d.field.statusInactive:d.field.statusActive})}),n.jsx("td",{style:{padding:"10px 18px"},onClick:O=>O.stopPropagation(),children:n.jsx(He,{onView:()=>s==null?void 0:s(k),onEdit:r&&i?()=>i(k):void 0,onDelete:r&&a?()=>a(k.name):void 0})})]},k.name))})]})}),n.jsx(Le,{page:j,total:g.length,onPageChange:b})]})}const m1={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20};function y1({form:e,setForm:t,organizations:l,managements:r,departments:s,formStatus:i,viewMode:a,onSubmit:d,onBack:p,onNavigate:f,onLogout:h,user:c}){const u=J(),x=o=>t(g=>({...g,...o})),v=a?{background:"#f9f9f9"}:{},m=e.name?a?`${u.formTitle.editBranch}: ${e.branch||e.name}`:u.formTitle.editBranch:u.formTitle.newBranch,z=ce(r,e.management).map(o=>({name:o.name,label:o.name1||o.name})),y=ce(s,e.department).map(o=>({name:o.name,label:o.department_name||o.name}));return n.jsxs(Oe,{title:m,activePage:"branches",user:c,formStatus:i,buttonText:u.saveBranch,buttonColor:N.purple,viewMode:a,onSubmit:d,onBack:p,onNavigate:f,onLogout:h,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:u.field.organization}),n.jsx(_t,{value:e.organization,onChange:o=>x({organization:o}),organizations:l,disabled:a})]}),n.jsxs("div",{style:m1,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[u.field.branch," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...v},value:e.branch,disabled:a||!!e.name,onChange:o=>x({branch:o.target.value}),placeholder:"Branch name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:u.field.management}),n.jsx(ae,{value:e.management,onChange:o=>x({management:o}),items:z,placeholder:u.field.select,disabled:a})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:u.field.department}),n.jsx(ae,{value:e.department,onChange:o=>x({department:o}),items:y,placeholder:u.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:u.field.creationDate}),n.jsx(ue,{value:e.custom_creation_date||"",onChange:o=>x({custom_creation_date:o}),disabled:a,style:{...E,...v}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:u.field.status}),n.jsxs("select",{style:{...E,...v},value:e.custom_status||"Active",disabled:a,onChange:o=>x({custom_status:o.target.value}),children:[n.jsx("option",{value:"Active",children:u.field.statusActive}),n.jsx("option",{value:"Inactive",children:u.field.statusInactive})]})]})]})]})}function v1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function j1({incidentTypes:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=J(),[a,d]=S.useState(""),[p,f]=S.useState("all"),h={padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},c=S.useMemo(()=>e.filter(m=>{const z=(m.name1||m.name||"").toLowerCase();return!(a&&!z.includes(a.toLowerCase())||p!=="all"&&(m.status||"Active")!==p)}),[e,a,p]),[u,x]=S.useState(1);S.useEffect(()=>{x(1)},[a,p]);const v=c.slice((u-1)*te,u*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:c.length,color:N.red})}),n.jsx(rt,{filters:[{type:"search",label:"Search",value:a,onChange:d,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:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:h,children:i.col.name}),n.jsx("th",{style:h,children:i.field.creationDate}),n.jsx("th",{style:h,children:i.field.status}),n.jsx("th",{style:h,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})}):v.map((m,z)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(m),style:{borderTop:"1px solid #f0f0f0",background:z%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:m.name1||m.name||"—"}),n.jsx("td",{style:{padding:"12px 18px",color:"#666"},children:v1(m.creation_date)}),n.jsx("td",{style:{padding:"12px 18px"},children:n.jsx("span",{style:{color:m.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:m.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"10px 18px"},onClick:y=>y.stopPropagation(),children:n.jsx(He,{onView:()=>l==null?void 0:l(m),onEdit:t&&r?()=>r(m):void 0,onDelete:t&&s?()=>s(m.name):void 0})})]},m.name))})]})}),n.jsx(Le,{page:u,total:c.length,onPageChange:x})]})}function b1({form:e,setForm:t,formStatus:l,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,user:p}){const f=J(),h=x=>t(v=>({...v,...x})),c=r?{background:"#f9f9f9"}:{},u=e.name?r?`Incident Type: ${e.name1||e.name}`:"Edit Incident Type":"New Incident Type";return n.jsxs(Oe,{title:u,activePage:"incident-types",user:p,formStatus:l,buttonText:f.saveName,buttonColor:N.red,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[f.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...c},value:e.name1,disabled:r,onChange:x=>h({name1:x.target.value}),placeholder:"Incident type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.creationDate}),n.jsx(ue,{value:e.creation_date||"",onChange:x=>h({creation_date:x}),disabled:r,style:{...E,...c}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.status}),n.jsxs("select",{style:{...E,...c},value:e.status||"Active",disabled:r,onChange:x=>h({status:x.target.value}),children:[n.jsx("option",{value:"Active",children:f.field.statusActive}),n.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})}function S1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function w1({ideaTypes:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=J(),[a,d]=S.useState(""),[p,f]=S.useState("all"),h={padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},c=S.useMemo(()=>e.filter(m=>{const z=(m.name1||m.name||"").toLowerCase();return!(a&&!z.includes(a.toLowerCase())||p!=="all"&&(m.status||"Active")!==p)}),[e,a,p]),[u,x]=S.useState(1);S.useEffect(()=>{x(1)},[a,p]);const v=c.slice((u-1)*te,u*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:c.length,color:N.teal})}),n.jsx(rt,{filters:[{type:"search",label:"Search",value:a,onChange:d,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:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:h,children:i.col.name}),n.jsx("th",{style:h,children:i.field.creationDate}),n.jsx("th",{style:h,children:i.field.status}),n.jsx("th",{style:h,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})}):v.map((m,z)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(m),style:{borderTop:"1px solid #f0f0f0",background:z%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:m.name1||m.name||"—"}),n.jsx("td",{style:{padding:"12px 18px",color:"#666"},children:S1(m.creation_date)}),n.jsx("td",{style:{padding:"12px 18px"},children:n.jsx("span",{style:{color:m.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:m.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"10px 18px"},onClick:y=>y.stopPropagation(),children:n.jsx(He,{onView:()=>l==null?void 0:l(m),onEdit:t&&r?()=>r(m):void 0,onDelete:t&&s?()=>s(m.name):void 0})})]},m.name))})]})}),n.jsx(Le,{page:u,total:c.length,onPageChange:x})]})}function k1({form:e,setForm:t,formStatus:l,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,user:p}){const f=J(),h=x=>t(v=>({...v,...x})),c=r?{background:"#f9f9f9"}:{},u=e.name?r?`Idea Type: ${e.name1||e.name}`:"Edit Idea Type":"New Idea Type";return n.jsxs(Oe,{title:u,activePage:"idea-types",user:p,formStatus:l,buttonText:f.saveName,buttonColor:N.teal,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[f.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...c},value:e.name1,disabled:r,onChange:x=>h({name1:x.target.value}),placeholder:"Idea type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.creationDate}),n.jsx(ue,{value:e.creation_date||"",onChange:x=>h({creation_date:x}),disabled:r,style:{...E,...c}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.status}),n.jsxs("select",{style:{...E,...c},value:e.status||"Active",disabled:r,onChange:x=>h({status:x.target.value}),children:[n.jsx("option",{value:"Active",children:f.field.statusActive}),n.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})}function _1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function C1({orderTypes:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=J(),[a,d]=S.useState(""),[p,f]=S.useState("all"),h={padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},c=S.useMemo(()=>e.filter(m=>{const z=(m.name1||m.name||"").toLowerCase();return!(a&&!z.includes(a.toLowerCase())||p!=="all"&&(m.status||"Active")!==p)}),[e,a,p]),[u,x]=S.useState(1);S.useEffect(()=>{x(1)},[a,p]);const v=c.slice((u-1)*te,u*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:c.length,color:N.purple})}),n.jsx(rt,{filters:[{type:"search",label:"Search",value:a,onChange:d,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:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:h,children:i.col.name}),n.jsx("th",{style:h,children:i.field.creationDate}),n.jsx("th",{style:h,children:i.field.status}),n.jsx("th",{style:h,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})}):v.map((m,z)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(m),style:{borderTop:"1px solid #f0f0f0",background:z%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:m.name1||m.name||"—"}),n.jsx("td",{style:{padding:"12px 18px",color:"#666"},children:_1(m.creation_date)}),n.jsx("td",{style:{padding:"12px 18px"},children:n.jsx("span",{style:{color:m.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:m.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"10px 18px"},onClick:y=>y.stopPropagation(),children:n.jsx(He,{onView:()=>l==null?void 0:l(m),onEdit:t&&r?()=>r(m):void 0,onDelete:t&&s?()=>s(m.name):void 0})})]},m.name))})]})}),n.jsx(Le,{page:u,total:c.length,onPageChange:x})]})}function z1({form:e,setForm:t,formStatus:l,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,user:p}){const f=J(),h=x=>t(v=>({...v,...x})),c=r?{background:"#f9f9f9"}:{},u=e.name?r?`Order Type: ${e.name1||e.name}`:"Edit Order Type":"New Order Type";return n.jsxs(Oe,{title:u,activePage:"order-types",user:p,formStatus:l,buttonText:f.saveName,buttonColor:N.purple,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[f.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...c},value:e.name1,disabled:r,onChange:x=>h({name1:x.target.value}),placeholder:"Order type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.creationDate}),n.jsx(ue,{value:e.creation_date||"",onChange:x=>h({creation_date:x}),disabled:r,style:{...E,...c}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.status}),n.jsxs("select",{style:{...E,...c},value:e.status||"Active",disabled:r,onChange:x=>h({status:x.target.value}),children:[n.jsx("option",{value:"Active",children:f.field.statusActive}),n.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})}function T1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function I1({processTypes:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=J(),[a,d]=S.useState(""),[p,f]=S.useState("all"),h={padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},c=S.useMemo(()=>e.filter(m=>{const z=(m.name1||m.name||"").toLowerCase();return!(a&&!z.includes(a.toLowerCase())||p!=="all"&&(m.status||"Active")!==p)}),[e,a,p]),[u,x]=S.useState(1);S.useEffect(()=>{x(1)},[a,p]);const v=c.slice((u-1)*te,u*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:c.length,color:N.blue})}),n.jsx(rt,{filters:[{type:"search",label:"Search",value:a,onChange:d,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:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:h,children:i.col.name}),n.jsx("th",{style:h,children:i.field.creationDate}),n.jsx("th",{style:h,children:i.field.status}),n.jsx("th",{style:h,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})}):v.map((m,z)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(m),style:{borderTop:"1px solid #f0f0f0",background:z%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:m.name1||m.name||"—"}),n.jsx("td",{style:{padding:"12px 18px",color:"#666"},children:T1(m.creation_date)}),n.jsx("td",{style:{padding:"12px 18px"},children:n.jsx("span",{style:{color:m.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:m.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"10px 18px"},onClick:y=>y.stopPropagation(),children:n.jsx(He,{onView:()=>l==null?void 0:l(m),onEdit:t&&r?()=>r(m):void 0,onDelete:t&&s?()=>s(m.name):void 0})})]},m.name))})]})}),n.jsx(Le,{page:u,total:c.length,onPageChange:x})]})}function P1({form:e,setForm:t,formStatus:l,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,user:p}){const f=J(),h=x=>t(v=>({...v,...x})),c=r?{background:"#f9f9f9"}:{},u=e.name?r?`Process Type: ${e.name1||e.name}`:"Edit Process Type":"New Process Type";return n.jsxs(Oe,{title:u,activePage:"process-types",user:p,formStatus:l,buttonText:f.saveName,buttonColor:N.blue,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[f.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...c},value:e.name1,disabled:r,onChange:x=>h({name1:x.target.value}),placeholder:"Process type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.creationDate}),n.jsx(ue,{value:e.creation_date||"",onChange:x=>h({creation_date:x}),disabled:r,style:{...E,...c}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.status}),n.jsxs("select",{style:{...E,...c},value:e.status||"Active",disabled:r,onChange:x=>h({status:x.target.value}),children:[n.jsx("option",{value:"Active",children:f.field.statusActive}),n.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})}function E1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function A1({incidentStatuses:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=J(),[a,d]=S.useState(""),[p,f]=S.useState("all"),h={padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},c=S.useMemo(()=>e.filter(m=>{const z=(m.name1||m.name||"").toLowerCase();return!(a&&!z.includes(a.toLowerCase())||p!=="all"&&(m.status||"Active")!==p)}),[e,a,p]),[u,x]=S.useState(1);S.useEffect(()=>{x(1)},[a,p]);const v=c.slice((u-1)*te,u*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:c.length,color:N.red})}),n.jsx(rt,{filters:[{type:"search",label:"Search",value:a,onChange:d,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:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:h,children:i.col.name}),n.jsx("th",{style:h,children:i.field.notifyManager}),n.jsx("th",{style:h,children:i.field.creationDate}),n.jsx("th",{style:h,children:i.field.status}),n.jsx("th",{style:h,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})}):v.map((m,z)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(m),style:{borderTop:"1px solid #f0f0f0",background:z%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:m.name1||m.name||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:m.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"12px 18px",color:"#666"},children:E1(m.creation_date)}),n.jsx("td",{style:{padding:"12px 18px"},children:n.jsx("span",{style:{color:m.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:m.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"10px 18px"},onClick:y=>y.stopPropagation(),children:n.jsx(He,{onView:()=>l==null?void 0:l(m),onEdit:t&&r?()=>r(m):void 0,onDelete:t&&s?()=>s(m.name):void 0})})]},m.name))})]})}),n.jsx(Le,{page:u,total:c.length,onPageChange:x})]})}function R1({form:e,setForm:t,formStatus:l,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,user:p}){const f=J(),h=x=>t(v=>({...v,...x})),c=r?{background:"#f9f9f9"}:{},u=e.name?r?`Incident Status: ${e.name1||e.name}`:"Edit Incident Status":"New Incident Status";return n.jsxs(Oe,{title:u,activePage:"incident-statuses",user:p,formStatus:l,buttonText:f.saveName,buttonColor:N.red,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[f.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...c},value:e.name1,disabled:r,onChange:x=>h({name1:x.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:x=>h({notify_manager:x.target.checked?1:0}),style:Wl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:r?"default":"pointer"},children:f.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.creationDate}),n.jsx(ue,{value:e.creation_date||"",onChange:x=>h({creation_date:x}),disabled:r,style:{...E,...c}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.status}),n.jsxs("select",{style:{...E,...c},value:e.status||"Active",disabled:r,onChange:x=>h({status:x.target.value}),children:[n.jsx("option",{value:"Active",children:f.field.statusActive}),n.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})}function L1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function O1({ideaStatuses:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=J(),[a,d]=S.useState(""),[p,f]=S.useState("all"),h={padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},c=S.useMemo(()=>e.filter(m=>{const z=(m.name1||m.name||"").toLowerCase();return!(a&&!z.includes(a.toLowerCase())||p!=="all"&&(m.status||"Active")!==p)}),[e,a,p]),[u,x]=S.useState(1);S.useEffect(()=>{x(1)},[a,p]);const v=c.slice((u-1)*te,u*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:c.length,color:N.teal})}),n.jsx(rt,{filters:[{type:"search",label:"Search",value:a,onChange:d,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:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:h,children:i.col.name}),n.jsx("th",{style:h,children:i.field.notifyManager}),n.jsx("th",{style:h,children:i.field.creationDate}),n.jsx("th",{style:h,children:i.field.status}),n.jsx("th",{style:h,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})}):v.map((m,z)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(m),style:{borderTop:"1px solid #f0f0f0",background:z%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:m.name1||m.name||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:m.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"12px 18px",color:"#666"},children:L1(m.creation_date)}),n.jsx("td",{style:{padding:"12px 18px"},children:n.jsx("span",{style:{color:m.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:m.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"10px 18px"},onClick:y=>y.stopPropagation(),children:n.jsx(He,{onView:()=>l==null?void 0:l(m),onEdit:t&&r?()=>r(m):void 0,onDelete:t&&s?()=>s(m.name):void 0})})]},m.name))})]})}),n.jsx(Le,{page:u,total:c.length,onPageChange:x})]})}function D1({form:e,setForm:t,formStatus:l,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,user:p}){const f=J(),h=x=>t(v=>({...v,...x})),c=r?{background:"#f9f9f9"}:{},u=e.name?r?`Idea Status: ${e.name1||e.name}`:"Edit Idea Status":"New Idea Status";return n.jsxs(Oe,{title:u,activePage:"idea-statuses",user:p,formStatus:l,buttonText:f.saveName,buttonColor:N.teal,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[f.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...c},value:e.name1,disabled:r,onChange:x=>h({name1:x.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:x=>h({notify_manager:x.target.checked?1:0}),style:Wl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:r?"default":"pointer"},children:f.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.creationDate}),n.jsx(ue,{value:e.creation_date||"",onChange:x=>h({creation_date:x}),disabled:r,style:{...E,...c}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.status}),n.jsxs("select",{style:{...E,...c},value:e.status||"Active",disabled:r,onChange:x=>h({status:x.target.value}),children:[n.jsx("option",{value:"Active",children:f.field.statusActive}),n.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})}function N1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function W1({orderStatuses:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=J(),[a,d]=S.useState(""),[p,f]=S.useState("all"),h={padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},c=S.useMemo(()=>e.filter(m=>{const z=(m.name1||m.name||"").toLowerCase();return!(a&&!z.includes(a.toLowerCase())||p!=="all"&&(m.status||"Active")!==p)}),[e,a,p]),[u,x]=S.useState(1);S.useEffect(()=>{x(1)},[a,p]);const v=c.slice((u-1)*te,u*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:c.length,color:N.purple})}),n.jsx(rt,{filters:[{type:"search",label:"Search",value:a,onChange:d,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:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:h,children:i.col.name}),n.jsx("th",{style:h,children:i.field.notifyManager}),n.jsx("th",{style:h,children:i.field.creationDate}),n.jsx("th",{style:h,children:i.field.status}),n.jsx("th",{style:h,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})}):v.map((m,z)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(m),style:{borderTop:"1px solid #f0f0f0",background:z%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:m.name1||m.name||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:m.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"12px 18px",color:"#666"},children:N1(m.creation_date)}),n.jsx("td",{style:{padding:"12px 18px"},children:n.jsx("span",{style:{color:m.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:m.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"10px 18px"},onClick:y=>y.stopPropagation(),children:n.jsx(He,{onView:()=>l==null?void 0:l(m),onEdit:t&&r?()=>r(m):void 0,onDelete:t&&s?()=>s(m.name):void 0})})]},m.name))})]})}),n.jsx(Le,{page:u,total:c.length,onPageChange:x})]})}function B1({form:e,setForm:t,formStatus:l,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,user:p}){const f=J(),h=x=>t(v=>({...v,...x})),c=r?{background:"#f9f9f9"}:{},u=e.name?r?`Order Status: ${e.name1||e.name}`:"Edit Order Status":"New Order Status";return n.jsxs(Oe,{title:u,activePage:"order-statuses",user:p,formStatus:l,buttonText:f.saveName,buttonColor:N.purple,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[f.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...c},value:e.name1,disabled:r,onChange:x=>h({name1:x.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:x=>h({notify_manager:x.target.checked?1:0}),style:Wl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:r?"default":"pointer"},children:f.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.creationDate}),n.jsx(ue,{value:e.creation_date||"",onChange:x=>h({creation_date:x}),disabled:r,style:{...E,...c}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.status}),n.jsxs("select",{style:{...E,...c},value:e.status||"Active",disabled:r,onChange:x=>h({status:x.target.value}),children:[n.jsx("option",{value:"Active",children:f.field.statusActive}),n.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})}function $1(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function U1({processStatuses:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=J(),[a,d]=S.useState(""),[p,f]=S.useState("all"),h={padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},c=S.useMemo(()=>e.filter(m=>{const z=(m.name1||m.name||"").toLowerCase();return!(a&&!z.includes(a.toLowerCase())||p!=="all"&&(m.status||"Active")!==p)}),[e,a,p]),[u,x]=S.useState(1);S.useEffect(()=>{x(1)},[a,p]);const v=c.slice((u-1)*te,u*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total",val:c.length,color:N.blue})}),n.jsx(rt,{filters:[{type:"search",label:"Search",value:a,onChange:d,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:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:h,children:i.col.name}),n.jsx("th",{style:h,children:i.field.notifyManager}),n.jsx("th",{style:h,children:i.field.creationDate}),n.jsx("th",{style:h,children:i.field.status}),n.jsx("th",{style:h,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})}):v.map((m,z)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(m),style:{borderTop:"1px solid #f0f0f0",background:z%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:m.name1||m.name||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:m.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"12px 18px",color:"#666"},children:$1(m.creation_date)}),n.jsx("td",{style:{padding:"12px 18px"},children:n.jsx("span",{style:{color:m.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:m.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"10px 18px"},onClick:y=>y.stopPropagation(),children:n.jsx(He,{onView:()=>l==null?void 0:l(m),onEdit:t&&r?()=>r(m):void 0,onDelete:t&&s?()=>s(m.name):void 0})})]},m.name))})]})}),n.jsx(Le,{page:u,total:c.length,onPageChange:x})]})}function F1({form:e,setForm:t,formStatus:l,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,user:p}){const f=J(),h=x=>t(v=>({...v,...x})),c=r?{background:"#f9f9f9"}:{},u=e.name?r?`Process Status: ${e.name1||e.name}`:"Edit Process Status":"New Process Status";return n.jsxs(Oe,{title:u,activePage:"process-statuses",user:p,formStatus:l,buttonText:f.saveName,buttonColor:N.blue,viewMode:r,onSubmit:s,onBack:i,onNavigate:a,onLogout:d,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[f.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...c},value:e.name1,disabled:r,onChange:x=>h({name1:x.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:x=>h({notify_manager:x.target.checked?1:0}),style:Wl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:r?"default":"pointer"},children:f.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.creationDate}),n.jsx(ue,{value:e.creation_date||"",onChange:x=>h({creation_date:x}),disabled:r,style:{...E,...c}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:f.field.status}),n.jsxs("select",{style:{...E,...c},value:e.status||"Active",disabled:r,onChange:x=>h({status:x.target.value}),children:[n.jsx("option",{value:"Active",children:f.field.statusActive}),n.jsx("option",{value:"Inactive",children:f.field.statusInactive})]})]})]})}const M1={Admin:"#7c3aed",Chairman:"#0f766e",Auditor:"#d97706","X-Auditor":"#8b5cf6",Manager:"#2563eb",Employee:"#6b7280"};function H1(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 K1({users:e,canModify:t,onView:l,onEdit:r,onDisable:s}){const i=J(),[a,d]=S.useState(!1),[p,f]=S.useState(""),[h,c]=S.useState(""),[u,x]=S.useState(""),[v,m]=S.useState("active"),[z,y]=S.useState(1),[o,g]=S.useState(null),[j,b]=S.useState(""),[w,k]=S.useState("idle"),[C,O]=S.useState(null),U=async()=>{if(!(!o||!j.trim())){k("loading");try{await Pf(o.name,j.trim()),k("success"),setTimeout(()=>{g(null),b(""),k("idle")},1200)}catch{k("error")}}},Q=async A=>{if(window.confirm(i.users.disableConfirm)){O(A);try{await(s==null?void 0:s(A))}finally{O(null)}}},X=e.filter(A=>{if(v==="active"&&(A.enabled===0||A.enabled==="0")||v==="inactive"&&A.enabled!==0&&A.enabled!=="0")return!1;const B=A.custom_category||"";if(u&&B!==u)return!1;const H=A.custom_organization||"";if(h&&!H.toLowerCase().includes(h.toLowerCase()))return!1;if(p){const V=p.toLowerCase();if(![A.full_name,A.email,A.name,A.username,A.mobile_no].join(" ").toLowerCase().includes(V))return!1}return!0}),$=[...new Set(e.map(A=>A.custom_organization).filter(Boolean))],ee=["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"];S.useEffect(()=>{y(1)},[p,h,u,v]);const Z=X.slice((z-1)*te,z*te),xe={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151"},se={...xe,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: ",X.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:()=>d(A=>!A),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",padding:"12px 18px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",userSelect:"none"},children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:a?n.jsx("polyline",{points:"18,15 12,9 6,15"}):n.jsx("polyline",{points:"6,9 12,15 18,9"})}),n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{style:{color:"white",fontWeight:700,fontSize:14},children:"Filters"})]}),a&&n.jsx("div",{style:{padding:"18px 20px",display:"flex",flexDirection:"column",gap:14},children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gap:14},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Search"}),n.jsx("input",{style:xe,placeholder:"Name, email, username…",value:p,onChange:A=>f(A.target.value)})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Organization"}),n.jsxs("select",{style:se,value:h,onChange:A=>c(A.target.value),children:[n.jsx("option",{value:"",children:"All Organizations"}),$.map(A=>n.jsx("option",{value:A,children:A},A))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Category"}),n.jsxs("select",{style:se,value:u,onChange:A=>x(A.target.value),children:[n.jsx("option",{value:"",children:"All Categories"}),ee.map(A=>n.jsx("option",{value:A,children:A},A))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Status"}),n.jsxs("select",{style:se,value:v,onChange:A=>m(A.target.value),children:[n.jsx("option",{value:"all",children:"All"}),n.jsx("option",{value:"active",children:"Active"}),n.jsx("option",{value:"inactive",children:"Inactive"})]})]})]})})]}),n.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa",borderBottom:"2px solid #f0f0f0"},children:[{label:"Category",w:100},{label:"Number",w:80},{label:"Full Name",w:140},{label:"Username",w:120},{label:"Email Address",w:180},{label:"Phone Number",w:120},{label:"Organization",w:130},{label:"Management",w:120},{label:"Department",w:120},{label:"Branch",w:100},{label:"Since",w:90},{label:"Status",w:80},{label:"Tools",w:200}].map(({label:A,w:B})=>n.jsx("th",{style:{padding:"11px 14px",textAlign:"left",color:"#6b7280",fontSize:11,fontWeight:700,whiteSpace:"nowrap",minWidth:B,letterSpacing:.3,textTransform:"uppercase"},children:A},A))})}),n.jsx("tbody",{children:X.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"})}):Z.map((A,B)=>{const H=A.custom_category||"",V=M1[H]||"#6b7280";return n.jsxs("tr",{onClick:()=>l==null?void 0:l(A),style:{borderBottom:"1px solid #f3f4f6",background:B%2===0?"white":"#fafafa",transition:"background 0.1s",cursor:"pointer"},onMouseEnter:F=>F.currentTarget.style.background="#f0f7ff",onMouseLeave:F=>F.currentTarget.style.background=B%2===0?"white":"#fafafa",children:[n.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:H?n.jsx("span",{style:{background:V+"18",color:V,border:`1px solid ${V}44`,padding:"3px 10px",borderRadius:20,fontSize:11,fontWeight:700},children:H}):n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:A.custom_number||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",fontWeight:600,color:"#1a2332",whiteSpace:"nowrap"},children:A.full_name||A.first_name||"—"}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:A.username||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:A.email||A.name}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:A.mobile_no||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:A.custom_organization||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:A.custom_management||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:A.custom_department||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:A.custom_branch||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:H1(A.creation)}),n.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:n.jsx("span",{style:{color:A.enabled?"#16a34a":"#dc2626",fontWeight:600},children:A.enabled?i.users.active:i.users.inactive})}),n.jsx("td",{style:{padding:"10px 14px",whiteSpace:"nowrap"},onClick:F=>F.stopPropagation(),children:n.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[n.jsx("button",{onClick:F=>{F.stopPropagation(),l==null||l(A)},title:"View",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#e0f7fa",color:"#0891b2"},children:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),t&&r&&n.jsx("button",{onClick:F=>{F.stopPropagation(),r(A)},title:"Edit",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#dcfce7",color:"#16a34a"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),t&&n.jsx("button",{onClick:F=>{F.stopPropagation(),g({name:A.name,email:A.email||A.name}),b(""),k("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:F=>{F.stopPropagation(),Q(A.name)},disabled:C===A.name,title:"Disable",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#fee2e2",color:"#ef4444",opacity:C===A.name?.5:1},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("polyline",{points:"3 6 5 6 21 6"}),n.jsx("path",{d:"M19 6l-1 14H6L5 6"}),n.jsx("path",{d:"M10 11v6M14 11v6"}),n.jsx("path",{d:"M9 6V4h6v2"})]})})]})})]},A.name)})})]})}),n.jsx(Le,{page:z,total:X.length,onPageChange:y}),o&&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:o.email})]}),n.jsx("input",{type:"password",value:j,onChange:A=>b(A.target.value),placeholder:i.users.newPassword,style:{width:"100%",padding:"10px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,boxSizing:"border-box",marginBottom:16,fontFamily:"Segoe UI",outline:"none"},onKeyDown:A=>A.key==="Enter"&&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"||!j.trim(),style:{flex:1,padding:10,background:"#2563eb",color:"white",border:"none",borderRadius:8,cursor:"pointer",fontSize:13,fontWeight:700,fontFamily:"inherit",opacity:j.trim()?1:.5},children:w==="loading"?"Saving…":i.users.setPassword}),n.jsx("button",{onClick:()=>{g(null),b(""),k("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 dr={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20};function Q1({form:e,setForm:t,organizations:l,managements:r,departments:s,branches:i,formStatus:a,viewMode:d,isSelfProfile:p,onSubmit:f,onBack:h,onNavigate:c,onLogout:u,user:x}){const v=J(),m=w=>t(k=>({...k,...w})),z=d?{background:"#f9f9f9"}:{},y=!e.name,o=p?"My Profile":y?"New User":d?`User: ${e.full_name||e.email}`:`Edit User: ${e.full_name||e.email}`,g=ce(r,e.custom_management).map(w=>({name:w.name,label:w.name1||w.name})),j=ce(s,e.custom_department).map(w=>({name:w.name,label:w.department_name||w.name})),b=ce(i,e.custom_branch).map(w=>({name:w.name,label:w.branch||w.name}));return n.jsxs(Oe,{title:o,activePage:"users",user:x,formStatus:a,buttonText:v.saveUser,buttonColor:N.blue,viewMode:d,hideSettings:p,onSubmit:f,onBack:h,onNavigate:c,onLogout:u,children:[n.jsxs("div",{style:dr,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.organization}),n.jsx(_t,{value:e.custom_organization,onChange:w=>m({custom_organization:w}),organizations:l,disabled:d})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.management}),n.jsx(ae,{value:e.custom_management,onChange:w=>m({custom_management:w}),items:g,placeholder:"-- Select --",disabled:d})]})]}),n.jsxs("div",{style:dr,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.department}),n.jsx(ae,{value:e.custom_department,onChange:w=>m({custom_department:w}),items:j,placeholder:"-- Select --",disabled:d})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.branch}),n.jsx(ae,{value:e.custom_branch,onChange:w=>m({custom_branch:w}),items:b,placeholder:"-- Select --",disabled:d})]})]}),n.jsxs("div",{style:dr,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.number}),n.jsx("input",{style:{...E,...z},value:e.custom_number,disabled:d,onChange:w=>m({custom_number:w.target.value}),placeholder:"e.g. 10001"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[v.field.fullName," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...z},value:e.first_name,disabled:d,onChange:w=>m({first_name:w.target.value}),placeholder:"Full name",required:!0})]})]}),n.jsxs("div",{style:dr,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.username}),n.jsx("input",{style:{...E,...z},value:e.username,disabled:d,onChange:w=>m({username:w.target.value}),placeholder:"Username"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.phoneNumber}),n.jsx("input",{style:{...E,...z},value:e.mobile_no,disabled:d,onChange:w=>m({mobile_no:w.target.value}),placeholder:"Phone number"})]})]}),n.jsxs("div",{style:dr,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[v.field.emailAddress," ",y&&n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...d||!y?{background:"#f9f9f9"}:{}},value:e.email,disabled:d||!y,onChange:w=>m({email:w.target.value}),placeholder:"user@example.com",type:"email",required:y})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:v.field.category}),n.jsxs("select",{style:{...E,...z},value:e.custom_category,disabled:d,onChange:w=>m({custom_category:w.target.value}),children:[n.jsx("option",{value:"",children:v.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 nu={Active:N.green,Closed:N.gray};function G1({cycles:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=J(),[a,d]=S.useState(""),[p,f]=S.useState(""),[h,c]=S.useState("all"),u=S.useMemo(()=>[...new Set(e.map(g=>g.organization).filter(Boolean))],[e]),x=S.useMemo(()=>e.filter(g=>{const j=(g.name1||g.name||"").toLowerCase();return!(a&&!j.includes(a.toLowerCase())||p&&g.organization!==p||h!=="all"&&g.status!==h)}),[e,a,p,h]),[v,m]=S.useState(1);S.useEffect(()=>{m(1)},[a,p,h]);const z=x.slice((v-1)*te,v*te),y=x.filter(g=>g.status==="Active").length,o=x.filter(g=>g.status==="Closed").length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(_e,{label:"Total",val:x.length,color:N.teal}),n.jsx(_e,{label:"Active",val:y,color:N.green}),n.jsx(_e,{label:"Closed",val:o,color:N.gray})]}),n.jsx(rt,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:i.col.organization,value:p,onChange:f,options:[{value:"",label:"All Organizations"},...u.map(g=>({value:g,label:g}))]},{type:"select",label:"Status",value:h,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:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:i.col.name}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:i.col.organization}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:i.col.frequency}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:i.col.startDate}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:i.col.endDate}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:i.col.status}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:i.col.actions})]})}),n.jsx("tbody",{children:x.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):z.map((g,j)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:j%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:g.name1||g.name}),n.jsx("td",{style:{padding:"12px 18px"},children:g.organization||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:g.frequency||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:g.start_date||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:g.end_date||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:n.jsx("span",{style:{padding:"3px 10px",borderRadius:12,fontSize:12,background:nu[g.status]+"22",color:nu[g.status]||"#666"},children:g.status})}),n.jsx("td",{style:{padding:"10px 18px"},onClick:b=>b.stopPropagation(),children:n.jsx(He,{onView:()=>l==null?void 0:l(g),onEdit:t&&r?()=>r(g):void 0,onDelete:t&&s?()=>s(g.name):void 0})})]},g.name))})]})}),n.jsx(Le,{page:v,total:x.length,onPageChange:m})]})}const ba={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Y1=["Weekly","Bi-weekly","Monthly","Quarterly","Annually"],X1=["Active","Closed"];function J1({form:e,setForm:t,organizations:l,formStatus:r,viewMode:s,onSubmit:i,onBack:a,onNavigate:d,onLogout:p,user:f}){const h=J(),c=v=>t(m=>({...m,...v})),u=s?{background:"#f9f9f9"}:{},x=e.name?s?`${h.formTitle.editCycle}: ${e.name1||e.name}`:h.formTitle.editCycle:h.formTitle.newCycle;return n.jsxs(Oe,{title:x,activePage:"cycles",user:f,formStatus:r,buttonText:h.saveCycle,buttonColor:N.teal,viewMode:s,onSubmit:i,onBack:a,onNavigate:d,onLogout:p,children:[n.jsxs("div",{style:ba,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...u},value:e.name1||"",disabled:s||!!e.name,onChange:v=>c({name1:v.target.value}),placeholder:"e.g. Q1-2026"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.organization}),n.jsx(_t,{value:e.organization,onChange:v=>c({organization:v}),organizations:l,disabled:s})]})]}),n.jsxs("div",{style:ba,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.col.frequency}),n.jsx(ae,{value:e.frequency,onChange:v=>c({frequency:v}),items:Y1.map(v=>({name:v,label:v})),placeholder:"-- Select Frequency --",disabled:s})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.status}),n.jsx(ae,{value:e.status,onChange:v=>c({status:v}),items:X1.map(v=>({name:v,label:v})),placeholder:"-- Select Status --",disabled:s})]})]}),n.jsxs("div",{style:ba,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.dateStart}),n.jsx(ue,{value:e.start_date||"",onChange:v=>c({start_date:v}),disabled:s,style:{...E,...u}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.dateEnd}),n.jsx(ue,{value:e.end_date||"",onChange:v=>c({end_date:v}),disabled:s,style:{...E,...u}})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.updateWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...E,...u,maxWidth:160},value:e.update_window_days??2,disabled:s,onChange:v=>c({update_window_days:parseInt(v.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 q1({kpiInputs:e,canModify:t,onView:l,onEdit:r,onDelete:s}){const i=J(),[a,d]=S.useState(""),[p,f]=S.useState(""),h=S.useMemo(()=>[...new Set(e.map(m=>m.organization).filter(Boolean))],[e]),c=S.useMemo(()=>e.filter(m=>{const z=[m.organization,m.period].filter(Boolean).join(" ").toLowerCase();return!(a&&!z.includes(a.toLowerCase())||p&&m.organization!==p)}),[e,a,p]),[u,x]=S.useState(1);S.useEffect(()=>{x(1)},[a,p]);const v=c.slice((u-1)*te,u*te);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(_e,{label:"Total Records",val:c.length,color:N.blue})}),n.jsx(rt,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Organization or period…"},{type:"select",label:i.col.organization,value:p,onChange:f,options:[{value:"",label:"All Organizations"},...h.map(m=>({value:m,label:m}))]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:i.col.organization}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:i.col.period}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:i.field.revenue_growth}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:i.field.net_profit}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:i.dash.customerSat}),n.jsx("th",{style:{padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,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})}):v.map((m,z)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(m),style:{borderTop:"1px solid #f0f0f0",background:z%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:m.organization||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:m.period||"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:m.revenue_growth!=null?`${m.revenue_growth}%`:"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:m.net_profit!=null?m.net_profit.toLocaleString():"—"}),n.jsx("td",{style:{padding:"12px 18px"},children:m.customer_satisfaction!=null?m.customer_satisfaction:"—"}),n.jsx("td",{style:{padding:"10px 18px"},onClick:y=>y.stopPropagation(),children:n.jsx(He,{onView:()=>l==null?void 0:l(m),onEdit:t&&r?()=>r(m):void 0,onDelete:t&&s?()=>s(m.name):void 0})})]},m.name))})]})}),n.jsx(Le,{page:u,total:c.length,onPageChange:x})]})}const lu={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},ru={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20};function Z1({form:e,setForm:t,organizations:l,formStatus:r,viewMode:s,onSubmit:i,onBack:a,onNavigate:d,onLogout:p,user:f}){const h=J(),c=m=>t(z=>({...z,...m})),u=s?{background:"#f9f9f9"}:{},x=m=>z=>c({[m]:parseFloat(z.target.value)||0}),v=e.name?s?`${h.formTitle.editKpi}: ${e.period||e.name}`:h.formTitle.editKpi:h.formTitle.newKpi;return n.jsxs(Oe,{title:v,activePage:"kpi-input",user:f,formStatus:r,buttonText:h.saveKpi,buttonColor:N.blue,viewMode:s,onSubmit:i,onBack:a,onNavigate:d,onLogout:p,children:[n.jsxs("div",{style:lu,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.organization}),n.jsx(_t,{value:e.organization,onChange:m=>c({organization:m}),organizations:l,disabled:s})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[h.col.period," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...u},value:e.period||"",disabled:s,onChange:m=>c({period:m.target.value}),placeholder:"e.g. Q1 2026"})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",marginBottom:12},children:"Financial KPIs"}),n.jsxs("div",{style:ru,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.revenue_growth}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...u},value:e.revenue_growth||"",disabled:s,onChange:x("revenue_growth")})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.net_profit}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...u},value:e.net_profit||"",disabled:s,onChange:x("net_profit")})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.cash_flow}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...u},value:e.cash_flow||"",disabled:s,onChange:x("cash_flow")})]})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",marginBottom:12},children:"Operational KPIs"}),n.jsxs("div",{style:ru,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.strategic_goal_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...u},value:e.strategic_goal_pct||"",disabled:s,onChange:x("strategic_goal_pct")})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.customer_satisfaction}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...u},value:e.customer_satisfaction||"",disabled:s,onChange:x("customer_satisfaction")})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.employee_turnover_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...u},value:e.employee_turnover_pct||"",disabled:s,onChange:x("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:lu,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.open_safety_incidents}),n.jsx("input",{type:"number",min:0,style:{...E,...u},value:e.open_safety_incidents||"",disabled:s,onChange:m=>c({open_safety_incidents:parseInt(m.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.compliance_score}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...u},value:e.compliance_score||"",disabled:s,onChange:x("compliance_score")})]})]})]})]})}const V1={create_processes:"Create Processes",update_process_status:"Update Process Status"},su={Pending:N.orange,Accepted:N.green,Rejected:N.red,Revoked:N.gray};function e0(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 t0(e){const t=[];return e.create_processes&&t.push("create_processes"),e.update_process_status&&t.push("update_process_status"),t}function n0({delegations:e,organizations:t,userRole:l,currentUser:r,onView:s,onRevoke:i}){const a=J(),[d,p]=S.useState(""),[f,h]=S.useState(""),[c,u]=S.useState("all"),x={padding:"12px 18px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},v=S.useMemo(()=>e.filter(j=>{const b=`${j.auditor} ${j.manager}`.toLowerCase();return!(d&&!b.includes(d.toLowerCase())||f&&j.organization!==f||c!=="all"&&j.status!==c)}),[e,d,f,c]),[m,z]=S.useState(1);S.useEffect(()=>{z(1)},[d,f,c]);const y=v.slice((m-1)*te,m*te),o=v.filter(j=>j.status==="Pending").length,g=v.filter(j=>j.status==="Accepted").length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(_e,{label:"Total",val:v.length,color:N.purple}),n.jsx(_e,{label:"Pending",val:o,color:N.orange}),n.jsx(_e,{label:"Accepted",val:g,color:N.green})]}),n.jsx(rt,{filters:[{type:"search",label:"Search",value:d,onChange:p,placeholder:"Auditor or Manager…"},{type:"select",label:a.col.organization,value:f,onChange:h,options:[{value:"",label:"All Organizations"},...t.map(j=>({value:j.organization_name||j.name,label:j.organization_name||j.name}))]},{type:"select",label:"Status",value:c,onChange:u,options:[{value:"all",label:"All"},{value:"Pending",label:"Pending"},{value:"Accepted",label:"Accepted"},{value:"Rejected",label:"Rejected"},{value:"Revoked",label:"Revoked"}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:x,children:a.col.number}),n.jsx("th",{style:x,children:a.col.auditor}),n.jsx("th",{style:x,children:a.col.manager}),n.jsx("th",{style:x,children:a.col.organization}),n.jsx("th",{style:x,children:a.col.functions}),n.jsx("th",{style:x,children:a.col.status}),n.jsx("th",{style:x,children:a.col.requestedOn}),n.jsx("th",{style:x,children:a.col.actions})]})}),n.jsx("tbody",{children:v.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:8,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):y.map((j,b)=>{const w=!!i&&(j.status==="Pending"||j.status==="Accepted")&&(l==="Admin"||l==="Auditor"&&j.auditor===r);return n.jsxs("tr",{onClick:()=>s==null?void 0:s(j),style:{borderTop:"1px solid #f0f0f0",background:b%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"12px 18px",fontWeight:600},children:j.number||j.name}),n.jsx("td",{style:{padding:"12px 18px"},children:j.auditor}),n.jsx("td",{style:{padding:"12px 18px"},children:j.manager}),n.jsx("td",{style:{padding:"12px 18px"},children:j.organization||"All Organizations"}),n.jsx("td",{style:{padding:"12px 18px"},children:n.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:t0(j).map(k=>n.jsx("span",{style:{background:"#ede9fe",color:"#6d28d9",padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600},children:V1[k]||k},k))})}),n.jsx("td",{style:{padding:"12px 18px"},children:n.jsx("span",{style:{background:(su[j.status]||N.gray)+"22",color:su[j.status]||N.gray,padding:"3px 10px",borderRadius:12,fontSize:12,fontWeight:700},children:j.status})}),n.jsx("td",{style:{padding:"12px 18px",color:"#666"},children:e0(j.requested_on)}),n.jsx("td",{style:{padding:"10px 18px"},onClick:k=>k.stopPropagation(),children:n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("button",{onClick:()=>s==null?void 0:s(j),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(j.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"})]})})]},j.name)})})]})}),n.jsx(Le,{page:m,total:v.length,onPageChange:z})]})}const iu={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},au={Pending:N.orange,Accepted:N.green,Rejected:N.red,Revoked:N.gray};function l0(e){if(!e)return"—";const t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleString()}function r0({form:e,setForm:t,organizations:l,users:r,userRoleMap:s,formStatus:i,viewMode:a,onSubmit:d,onBack:p,onNavigate:f,onLogout:h,user:c}){var y;const u=J(),x=o=>t(g=>({...g,...o})),v=a?{background:"#f9f9f9"}:{},m=Nl(r,s,"SB Manager").map(o=>({name:o.name,label:o.full_name||o.name})),z=e.name?`${u.formTitle.viewDelegation}${e.number||e.name}`:u.formTitle.newDelegation;return n.jsxs(Oe,{title:z,activePage:"delegations",user:c,formStatus:i,buttonText:u.saveDelegation,buttonColor:N.purple,viewMode:a,onSubmit:d,onBack:p,onNavigate:f,onLogout:h,children:[a&&e.status&&n.jsx("div",{style:{marginBottom:20},children:n.jsx("span",{style:{background:(au[e.status]||N.gray)+"22",color:au[e.status]||N.gray,padding:"5px 14px",borderRadius:14,fontSize:13,fontWeight:700},children:e.status})}),n.jsxs("div",{style:iu,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:u.col.auditor}),n.jsx("input",{style:{...E,background:"#f9f9f9"},value:e.auditor||c.name,disabled:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[u.col.manager," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(ae,{value:e.manager,onChange:o=>x({manager:o}),items:m,placeholder:"-- Select Manager --",disabled:a})]})]}),n.jsx("div",{style:iu,children:n.jsxs("div",{children:[n.jsx("label",{style:T,children:u.col.organization}),n.jsx(_t,{value:e.organization,onChange:o=>x({organization:o}),organizations:l,placeholder:"-- All Organizations --",disabled:a})]})}),n.jsxs("div",{style:{marginTop:8},children:[n.jsxs("label",{style:T,children:[u.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:Wl,checked:!!e.create_processes,disabled:a,onChange:o=>x({create_processes:o.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:Wl,checked:!!e.update_process_status,disabled:a,onChange:o=>x({update_process_status:o.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:{...E,...v,minHeight:70,resize:"vertical"},value:e.remarks||"",onChange:o=>x({remarks:o.target.value}),placeholder:"Optional note for the Manager…"})]}),a&&(((y=e.delegation_log)==null?void 0:y.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:13},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((o,g)=>n.jsxs("tr",{style:{borderTop:"1px solid #f0f0f0"},children:[n.jsx("td",{style:{padding:"8px 14px",fontWeight:600},children:o.action}),n.jsx("td",{style:{padding:"8px 14px"},children:o.actor}),n.jsx("td",{style:{padding:"8px 14px",color:"#666"},children:l0(o.timestamp)}),n.jsx("td",{style:{padding:"8px 14px",color:"#666"},children:o.remarks||"—"})]},o.name||g))})]})})]})]})}const ou={process:"processes-form",order:"orders-form",incident:"incidents-form",idea:"ideas-form"},Sa={process:N.blue,order:N.purple,incident:N.red,idea:N.green,delegation:N.orange};function s0({onNavigate:e,onRefresh:t}){const l=J(),[r,s]=S.useState([]),[i,a]=S.useState(!0),[d,p]=S.useState(""),[f,h]=S.useState(""),c=()=>cy().then(z=>{s(z),a(!1)});S.useEffect(()=>{c()},[]);const u=r.filter(z=>z.requires_action),x=r.filter(z=>!z.requires_action),v=async(z,y)=>{p(z),h("");try{await uy(z,y),await c(),t==null||t()}catch{h(z)}p("")};function m(z,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:[z," (",y.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:y.map((o,g)=>{const j=o.type!=="delegation";return n.jsxs("div",{onClick:j?()=>e(ou[o.type],o.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 ${Sa[o.type]||N.gray}`,cursor:j?"pointer":"default",transition:"box-shadow 0.15s, transform 0.15s"},onMouseEnter:j?b=>{b.currentTarget.style.boxShadow="0 4px 14px rgba(0,0,0,0.12)",b.currentTarget.style.transform="translateY(-1px)"}:void 0,onMouseLeave:j?b=>{b.currentTarget.style.boxShadow="0 1px 4px rgba(0,0,0,0.07)",b.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:Sa[o.type]||N.gray,padding:"2px 8px",borderRadius:10},children:o.type.toUpperCase()}),n.jsx("span",{style:{fontWeight:700,fontSize:14},children:o.number}),n.jsx("span",{style:{fontSize:13,color:"#333",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.title})]}),n.jsxs("div",{style:{marginTop:4,fontSize:12,color:"#888"},children:[o.action," ",o.organization?`· ${o.organization}`:""," ",o.date?`· ${o.date}`:""]}),f===o.name&&n.jsx("div",{style:{marginTop:4,fontSize:12,color:"#e74c3c"},children:"Failed to respond — please try again."})]}),o.type==="delegation"?n.jsxs("div",{style:{display:"flex",gap:8,flexShrink:0},children:[n.jsx("button",{onClick:()=>v(o.name,"Accepted"),disabled:d===o.name,style:{padding:"7px 16px",borderRadius:8,border:"none",background:N.green,color:"white",fontWeight:600,fontSize:13,cursor:d===o.name?"wait":"pointer",opacity:d===o.name?.6:1},children:"Accept"}),n.jsx("button",{onClick:()=>v(o.name,"Rejected"),disabled:d===o.name,style:{padding:"7px 16px",borderRadius:8,border:"none",background:N.red,color:"white",fontWeight:600,fontSize:13,cursor:d===o.name?"wait":"pointer",opacity:d===o.name?.6:1},children:"Reject"})]}):n.jsx("button",{onClick:b=>{b.stopPropagation(),e(ou[o.type],o.name)},style:{padding:"7px 16px",borderRadius:8,border:"none",background:Sa[o.type]||N.accent,color:"white",fontWeight:600,fontSize:13,cursor:"pointer",flexShrink:0},children:o.requires_action?"Act":l.view})]},g)})})]})}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&&m("Needs Action",u),!i&&m("Informational",x)]})}const i0=[{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"]}],Rf={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 a0(e,t){const l=e.map(s=>Rf[s]||s).join(","),r=t.map(s=>e.map(i=>`"${s[i]??""}"`).join(",")).join(`
|
||
`);return l+`
|
||
`+r}function o0(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 Lf="report-print-area",wa="report-print-portal";function c0(){const e=document.getElementById(Lf);if(!e)return;const t=document.createElement("div");t.id=wa,t.innerHTML=e.innerHTML,document.body.appendChild(t);const l=document.createElement("style");l.id="report-print-style",l.textContent=`
|
||
#${wa} { display: none; }
|
||
@media print {
|
||
#root { display: none !important; }
|
||
#${wa} { display: block !important; }
|
||
}
|
||
`,document.head.appendChild(l);const r=()=>{t.remove(),l.remove(),window.removeEventListener("afterprint",r)};window.addEventListener("afterprint",r),window.print()}const cu={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",minWidth:180},ka={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white"};function d0({organizations:e,userRole:t}){const l=J(),r=i0.filter(O=>O.roles.includes(t)),[s,i]=S.useState(""),[a,d]=S.useState(""),[p,f]=S.useState(""),[h,c]=S.useState(""),[u,x]=S.useState(String(new Date().getFullYear())),[v,m]=S.useState([]),[z,y]=S.useState([]),[o,g]=S.useState(!1),[j,b]=S.useState(""),w=r.find(O=>O.id===s);async function k(){if(s){g(!0),b(""),y([]),m([]);try{const O={};a&&(O.organization=a),p&&(O.from_date=p),h&&(O.to_date=h),(w==null?void 0:w.extraFilter)==="year"&&u&&(O.year=u);const U=await oy(s,O);m(U.columns||[]),y(U.rows||[])}catch(O){b(O.message||"Error running report")}finally{g(!1)}}}const C=(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(O=>n.jsxs("div",{onClick:()=>i(O.id),style:{background:s===O.id?"#ebf5fb":"white",border:s===O.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:O.label}),n.jsx("div",{style:{fontSize:12,color:"#888"},children:O.description})]},O.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:cu,value:s,onChange:O=>i(O.target.value),children:[n.jsx("option",{value:"",children:"-- Select Report --"}),r.map(O=>n.jsx("option",{value:O.id,children:O.label},O.id))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"ORGANIZATION"}),n.jsxs("select",{style:cu,value:a,onChange:O=>d(O.target.value),children:[n.jsx("option",{value:"",children:l.filter.allOrgs}),e.map(O=>n.jsx("option",{value:O.name,children:O.organization_name||O.name},O.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:{...ka,width:90},value:u,onChange:O=>x(O.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(ue,{value:p,onChange:f,style:ka})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"TO"}),n.jsx(ue,{value:h,onChange:c,style:ka})]})]}),n.jsx("button",{onClick:k,disabled:!s||o,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:o?l.loading:l.reports.generate}),z.length>0&&n.jsx("button",{onClick:()=>o0(a0(v,z),`${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"}),z.length>0&&n.jsx("button",{onClick:c0,style:{padding:"9px 20px",borderRadius:8,border:"1px solid #888",background:"white",color:"#555",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Print / PDF"})]})}),j&&n.jsx("div",{style:{color:"#e74c3c",marginBottom:16},children:j}),z.length>0&&n.jsxs("div",{id:Lf,style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto"},children:[n.jsxs("div",{style:{padding:"14px 18px",borderBottom:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsx("span",{style:{fontWeight:700,color:"#333"},children:C}),n.jsxs("span",{style:{fontSize:12,color:"#888"},children:[z.length," rows"]})]}),n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa"},children:v.map(O=>n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700,whiteSpace:"nowrap"},children:Rf[O]||O.replace(/_/g," ").toUpperCase()},O))})}),n.jsx("tbody",{children:z.map((O,U)=>n.jsx("tr",{style:{borderTop:"1px solid #f0f0f0",background:U%2===0?"white":"#fafafa"},children:v.map(Q=>n.jsx("td",{style:{padding:"10px 14px",color:"#333"},children:O[Q]!=null?String(O[Q]):"—"},Q))},U))})]})]}),!o&&z.length===0&&s&&!j&&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 rs=()=>new Date().toISOString().split("T")[0],gc=()=>new Date(Date.now()+30*24*60*60*1e3).toISOString().split("T")[0],Gt=()=>({name:"",number:"",title:"",organization:"",type:"",incident_class:"",incident_field:"",date:rs(),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:""}),Yt=()=>({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:rs(),priority:"",economy_class:"",product_relation:0,repeated:0,entity_scope:"",solution:"",cost:0,auditor_comment:""}),Xt=()=>({name:"",number:"",title:"",organization:"",type:"Buy L",management:"",department:"",section_field:"",branch:"",starting_date:rs(),ending_date:gc(),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:""}),Os=()=>({name:"",title:"",date_start:rs(),date_end:gc(),number:"",status:"",cycle_type:"Normal",organization:"",type:"",management:"",department:"",section_field:"",branch:"",progress_indicators:[],cycle:"",actor:"",escalation_level:0,workflow_state:"",chain_location:"",economy_class:"",impact_level:"",product_relation:0,entity_scope:"",hses_field:"",kpi_name:"",kpi_type:"",kpi_measure:"",cost_per_cycle:0,auditor_comment:""}),ur=()=>({name:"",organization_name:"",type:"Government",city:"",contact_email:"",creation_date:new Date().toISOString().slice(0,10),is_active:1,acronym:"",incident_triage_window_days:3,incident_resolution_window_days:5}),il=()=>({name:"",organization:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),al=()=>({name:"",custom_organization:"",department_name:"",custom_management:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),ol=()=>({name:"",organization:"",branch:"",management:"",department:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),pr=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),fr=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),hr=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),gr=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),xr=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),mr=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),yr=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),vr=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ds=()=>({name:"",first_name:"",full_name:"",email:"",enabled:1,creation:"",username:"",mobile_no:"",custom_organization:"",custom_management:"",custom_department:"",custom_branch:"",custom_number:"",custom_category:""}),cl=()=>({name:"",name1:"",organization:"",frequency:"Monthly",status:"Active",start_date:rs(),end_date:gc(),update_window_days:2}),dl=()=>({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}),jr=()=>({name:"",number:"",auditor:"",manager:"",organization:"",create_processes:0,update_process_status:0,status:"Pending",requested_on:"",remarks:""}),u0=new Set(["incidents","incidents-form","ideas","ideas-form"]),p0=new Set(["orders","orders-form","incidents","incidents-form","ideas","ideas-form"]),f0=new Set(["Admin","Owner","Auditor","Manager"]),h0=new Set(["Admin","Owner","Auditor","Manager"]),g0=new Set(["Admin","Auditor","Manager"]);function x0({user:e,onLogout:t,darkMode:l,onToggleDark:r}){const s=J(),i=e.role,a=f0.has(i),d=h0.has(i),p=g0.has(i),f=_=>_==="users"||_==="users-form"?i==="Admin":i==="Admin"||i==="Auditor"?!0:i==="Owner"||i==="XAuditor"?!1:i==="Manager"?!!(p0.has(_)||(_==="processes"||_==="processes-form")&&yc.includes("create_processes")):u0.has(_),h=_=>i==="Employee"&&!!_&&_!=="New",[c,u]=S.useState(a?"dashboard":"inbox"),[x,v]=S.useState(""),[m,z]=S.useState(0),[y,o]=S.useState([]),[g,j]=S.useState([]),[b,w]=S.useState([]),[k,C]=S.useState([]),[O,U]=S.useState([]),[Q,X]=S.useState([]),[$,ee]=S.useState([]),[Z,xe]=S.useState([]),[se,A]=S.useState([]),[B,H]=S.useState([]),[V,F]=S.useState([]),[je,R]=S.useState([]),[q,$e]=S.useState([]),[De,I]=S.useState([]),[P,M]=S.useState([]),[Ct,ss]=S.useState([]),[Rn,$i]=S.useState([]),[on,L]=S.useState([]),[Ye,qn]=S.useState([]),[dt,Of]=S.useState({}),[Fl,Df]=S.useState([]),[is,Nf]=S.useState([]),[xc,Wf]=S.useState([]),[mc,Bf]=S.useState([]),[yc,$f]=S.useState([]),[vc,Uf]=S.useState({}),[me,ie]=S.useState(!0),[Te,ne]=S.useState("idle"),[Ie,Ve]=S.useState(!1),[jc,bc]=S.useState(!1),[as,Sc]=S.useState(null),[Ff,Mf]=S.useState(()=>localStorage.getItem("sb_sidebar")==="1"),Hf=()=>Mf(_=>{const Y=!_;return localStorage.setItem("sb_sidebar",Y?"1":"0"),Y}),[Kf,Ui]=S.useState(!1);S.useEffect(()=>{Ui(!1)},[c]);const[Ml,Mt]=S.useState(Gt()),[Hl,Ht]=S.useState(Yt()),[os,Kt]=S.useState(Xt()),[cs,Dt]=S.useState(Os()),[wc,Kl]=S.useState(ur()),[kc,Zn]=S.useState(il()),[_c,Vn]=S.useState(al()),[Cc,el]=S.useState(ol()),[zc,Ql]=S.useState(pr()),[Tc,Gl]=S.useState(fr()),[Ic,Yl]=S.useState(hr()),[Pc,Xl]=S.useState(gr()),[Ec,Jl]=S.useState(xr()),[Ac,ql]=S.useState(mr()),[Rc,Zl]=S.useState(yr()),[Lc,Vl]=S.useState(vr()),[ds,us]=S.useState(Ds()),[Oc,tl]=S.useState(cl()),[Dc,nl]=S.useState(dl()),[ll,er]=S.useState(jr()),Nt=async()=>{ie(!0);try{const[_,Y,ut,zt,cn,Pe,Ki,$h,Uh,Fh,Mh,Hh,Kh,Qh,Gh,Yh,Xh,Jh,qh,Zh,Vh,eg,tg,ng,lg,rg]=await Promise.all([ye(D.incidents),ye(D.organizations),ye(D.ideas),ye(D.orders),ye(D.processes),Km(),ye(D.managements),ye(D.departments),ye(D.branches),ye(D.incidentTypes),ye(D.incidentClass),ye(D.incidentField),ye(D.ideaTypes),ye(D.orderTypes),ye(D.processTypes),ye(D.incidentStatuses),ye(D.ideaStatuses),ye(D.orderStatuses),ye(D.processStatuses),Xm(),Jm(),ye(D.cycles),ye(D.kpiInput),fy(),gy(),xy()]);o(_||[]),j(Y||[]),w(ut||[]),C(zt||[]),U(cn||[]),Df(Pe||[]),X(Ki||[]),ee($h||[]),xe(Uh||[]),A(Fh||[]),H(Mh||[]),F(Hh||[]),R(Kh||[]),$e(Qh||[]),I(Gh||[]),M(Yh||[]),ss(Xh||[]),$i(Jh||[]),L(qh||[]),qn(Zh||[]),Of(Vh||{}),Nf(eg||[]),Wf(tg||[]),Bf(ng||[]),$f(lg||[]),Uf(rg||{})}catch(_){console.error("Error loading data:",_)}ie(!1)},Qf=async()=>{try{const _=await fetch("/api/method/sidrah_business.api.get_notification_count",{credentials:"include",headers:{Accept:"application/json"}});if(_.ok){const Y=await _.json();z(Number(Y.message)||0)}}catch{}};S.useEffect(()=>{Nt(),Qf()},[e.name]);const Ne=async(_,Y)=>{if(window.confirm(s.rtl?"هل أنت متأكد من حذف هذا السجل؟":"Are you sure you want to delete this record?")){ie(!0);try{await Tf(_,Y),await Nt()}catch(ut){console.error("Delete error:",ut),alert((ut==null?void 0:ut.message)||"Delete failed. Please try again.")}ie(!1)}},Gf=async _=>{try{await ey(_),await Nt()}catch(Y){console.error("Disable user error:",Y)}},Yf=async _=>{Ve(!0),ie(!0);try{const Y=await pt(D.incidents,_.name);Mt({...Gt(),...Y})}catch{Mt({...Gt(),..._})}u("incidents-form"),ie(!1)},Xf=async _=>{Ve(!0),ie(!0);try{const Y=await pt(D.ideas,_.name);Ht({...Yt(),...Y})}catch{Ht({...Yt(),..._})}u("ideas-form"),ie(!1)},Jf=async _=>{Ve(!0),ie(!0);try{const Y=await pt(D.orders,_.name);Kt({...Xt(),...Y})}catch{Kt({...Xt(),..._})}u("orders-form"),ie(!1)},qf=async _=>{Ve(!0),ie(!0);try{const Y=await _r(_.name);Dt({...Y,progress_indicators:Y.progress_indicators||[],cycle_logs:Y.cycle_logs||[]}),u("processes-form")}catch{Dt({..._,progress_indicators:_.progress_indicators||[]}),u("processes-form")}ie(!1)},Zf=_=>pe(D.organizations,_,Kl,ur(),"organizations-form",!0),Vf=async _=>{Ve(!0),ie(!0);try{const Y=await pt(D.managements,_.name);Zn({...il(),...Y})}catch{Zn({...il(),..._})}u("managements-form"),ie(!1)},eh=async _=>{Ve(!0),ie(!0);try{const Y=await pt(D.departments,_.name);Vn({...al(),...Y})}catch{Vn({...al(),..._})}u("departments-form"),ie(!1)},th=async _=>{Ve(!0),ie(!0);try{const Y=await pt(D.branches,_.name);el({...ol(),...Y})}catch{el({...ol(),..._})}u("branches-form"),ie(!1)},nh=async _=>{Ve(!0),ie(!0);try{const Y=await pt(D.cycles,_.name);tl({...cl(),...Y})}catch{tl({...cl(),..._})}u("cycles-form"),ie(!1)},lh=async _=>{Ve(!0),ie(!0);try{const Y=await pt(D.kpiInput,_.name);nl({...dl(),...Y})}catch{nl({...dl(),..._})}u("kpi-input-form"),ie(!1)},Ue=async(_,Y,ut,zt,cn)=>{ne("loading");try{if(Y.name)await vi(_,Y.name,Y),ne("success"),Nt(),setTimeout(()=>{ne("idle"),u(zt)},1500);else if(cn){const Pe=await ya(_,Y);cn(Pe),ne("success"),Nt(),setTimeout(()=>ne("idle"),1500)}else await ya(_,Y),ut(),ne("success"),Nt(),setTimeout(()=>{ne("idle"),u(zt)},1500)}catch(Pe){console.error("Submit error:",Pe),ne(Pe instanceof Error?Pe.message:"Error saving. Please try again.")}},Ce=async()=>{await Gm(),t()},pe=async(_,Y,ut,zt,cn,Pe)=>{Ve(Pe),ie(!0);try{const Ki=await pt(_,Y.name);ut({...zt,...Ki})}catch{ut({...zt,...Y})}u(cn),ie(!1)},rh=_=>pe(D.incidents,_,Mt,Gt(),"incidents-form",!1),sh=_=>pe(D.ideas,_,Ht,Yt(),"ideas-form",!1),ih=_=>pe(D.orders,_,Kt,Xt(),"orders-form",!1),ah=_=>{Ve(!1),ie(!0),_r(_.name).then(Y=>{Dt({...Y,progress_indicators:Y.progress_indicators||[],cycle_logs:Y.cycle_logs||[]})}).catch(()=>{Dt({..._,progress_indicators:_.progress_indicators||[]})}).finally(()=>{u("processes-form"),ie(!1)})},oh=_=>pe(D.organizations,_,Kl,ur(),"organizations-form",!1),ch=_=>pe(D.managements,_,Zn,il(),"managements-form",!1),dh=_=>pe(D.departments,_,Vn,al(),"departments-form",!1),uh=_=>pe(D.branches,_,el,ol(),"branches-form",!1),ph=_=>pe(D.cycles,_,tl,cl(),"cycles-form",!1),fh=_=>pe(D.kpiInput,_,nl,dl(),"kpi-input-form",!1),hh=async _=>{Ve(!0),ie(!0);try{const Y=await hy(_.name);er({...jr(),...Y})}catch{er({...jr(),..._})}u("delegations-form"),ie(!1)},gh=async()=>{ne("loading");try{const _=[];ll.create_processes&&_.push("create_processes"),ll.update_process_status&&_.push("update_process_status"),await dy(ll.manager,_,ll.organization,ll.remarks),er(jr()),ne("success"),Nt(),setTimeout(()=>{ne("idle"),u("delegations")},1500)}catch(_){console.error("Delegation submit error:",_),ne(_ instanceof Error?_.message:"Error saving. Please try again.")}},xh=async _=>{if(window.confirm(s.rtl?"هل أنت متأكد من إلغاء هذا التفويض؟":"Are you sure you want to revoke this delegation?")){ie(!0);try{await py(_),await Nt()}catch(Y){console.error("Revoke delegation error:",Y),alert(Y instanceof Error?Y.message:"Revoke failed. Please try again.")}ie(!1)}},mh=_=>pe(D.incidentTypes,_,Ql,pr(),"incident-types-form",!0),yh=_=>pe(D.incidentTypes,_,Ql,pr(),"incident-types-form",!1),vh=_=>pe(D.ideaTypes,_,Gl,fr(),"idea-types-form",!0),jh=_=>pe(D.ideaTypes,_,Gl,fr(),"idea-types-form",!1),bh=_=>pe(D.orderTypes,_,Yl,hr(),"order-types-form",!0),Sh=_=>pe(D.orderTypes,_,Yl,hr(),"order-types-form",!1),wh=_=>pe(D.processTypes,_,Xl,gr(),"process-types-form",!0),kh=_=>pe(D.processTypes,_,Xl,gr(),"process-types-form",!1),_h=_=>pe(D.incidentStatuses,_,Jl,xr(),"incident-statuses-form",!0),Ch=_=>pe(D.incidentStatuses,_,Jl,xr(),"incident-statuses-form",!1),zh=_=>pe(D.ideaStatuses,_,ql,mr(),"idea-statuses-form",!0),Th=_=>pe(D.ideaStatuses,_,ql,mr(),"idea-statuses-form",!1),Ih=_=>pe(D.orderStatuses,_,Zl,yr(),"order-statuses-form",!0),Ph=_=>pe(D.orderStatuses,_,Zl,yr(),"order-statuses-form",!1),Eh=_=>pe(D.processStatuses,_,Vl,vr(),"process-statuses-form",!0),Ah=_=>pe(D.processStatuses,_,Vl,vr(),"process-statuses-form",!1),Rh=async _=>{Sc(_),u("profile")},Lh=_=>{Ve(!1),bc(!1),us({...Ds(),..._}),u("users-form")},Oh=async()=>{ne("loading");try{if(!ds.name)await ya("User",{...ds,send_welcome_email:0,user_type:"System User"});else{const{name:Y,email:ut,creation:zt,full_name:cn,...Pe}=ds;await vi("User",Y,Pe)}us(Ds()),ne("success"),Nt(),setTimeout(()=>{ne("idle"),u("users")},1500)}catch(_){console.error("User submit error:",_),ne(_ instanceof Error?_.message:"Error saving. Please try again.")}},Fi=(_,Y)=>{if(Y){const zt={"processes-form":D.processes,"orders-form":D.orders,"incidents-form":D.incidents,"ideas-form":D.ideas}[_];if(zt){Ve(!0),ie(!0),(_==="processes-form"?_r(Y).then(Pe=>({...Pe,progress_indicators:Pe.progress_indicators||[],cycle_logs:Pe.cycle_logs||[]})):pt(zt,Y)).then(Pe=>{_==="processes-form"?Dt(Pe):_==="orders-form"?Kt({...Xt(),...Pe}):_==="incidents-form"?Mt({...Gt(),...Pe}):_==="ideas-form"&&Ht({...Yt(),...Pe}),u(_),ie(!1)}).catch(()=>{u(_),ie(!1)});return}}u(_)};if(c==="incidents-form")return n.jsx(By,{incForm:Ml,setIncForm:Mt,organizations:g,managements:Q,departments:$,branches:Z,incidentTypes:se,incidentClasses:B,incidentFields:V,incidentStatuses:P,users:Fl,userRoleMap:dt,formStatus:Te,viewMode:Ie||!f("incidents-form")||h(Ml.workflow_state),userRole:i,onSubmit:()=>Ue(D.incidents,Ml,()=>Mt(Gt()),"incidents",_=>Mt({...Gt(),..._})),onBack:()=>{u("incidents"),ne("idle")},onNavigate:u,onLogout:Ce,user:e,onRefresh:async()=>{if(Ml.name){const _=await pt(D.incidents,Ml.name).catch(()=>null);_&&Mt({...Gt(),..._})}ye(D.incidents).then(_=>o(_||[])).catch(()=>{})}});if(c==="ideas-form")return n.jsx(My,{ideaForm:Hl,setIdeaForm:Ht,organizations:g,managements:Q,departments:$,branches:Z,ideaTypes:je,ideaStatuses:Ct,users:Fl,userRoleMap:dt,formStatus:Te,viewMode:Ie||!f("ideas-form")||h(Hl.workflow_state),userRole:i,onSubmit:()=>Ue(D.ideas,Hl,()=>Ht(Yt()),"ideas",_=>Ht({...Yt(),..._})),onBack:()=>{u("ideas"),ne("idle")},onNavigate:u,onLogout:Ce,user:e,onRefresh:async()=>{if(Hl.name){const _=await pt(D.ideas,Hl.name).catch(()=>null);_&&Ht({...Yt(),..._})}ye(D.ideas).then(_=>w(_||[])).catch(()=>{})}});if(c==="orders-form")return n.jsx(Yy,{orderForm:os,setOrderForm:Kt,organizations:g,managements:Q,departments:$,branches:Z,orderTypes:q,orderStatuses:Rn,cycles:is,users:Fl,userRoleMap:dt,formStatus:Te,viewMode:Ie||!f("orders-form"),currentUser:e.name,userRole:i,onSubmit:()=>Ue(D.orders,os,()=>Kt(Xt()),"orders",_=>Kt({...Xt(),..._})),onBack:()=>{u("orders"),ne("idle")},onNavigate:u,onLogout:Ce,user:e,onRefresh:async()=>{if(os.name){const _=await pt(D.orders,os.name).catch(()=>null);_&&Kt({...Xt(),..._})}ye(D.orders).then(_=>C(_||[])).catch(()=>{})}});if(c==="processes-form")return n.jsx(Vy,{processForm:cs,setProcessForm:Dt,organizations:g,managements:Q,departments:$,branches:Z,processTypes:De,processStatuses:on,cycles:is,users:Fl,userRoleMap:dt,formStatus:Te,viewMode:Ie||!f("processes-form"),userRole:e.role,delegatedFunctions:yc,delegatedOrgs:vc.create_processes,onRefreshProcess:async()=>{if(cs.name)try{const _=await _r(cs.name);Dt({..._,progress_indicators:_.progress_indicators||[],cycle_logs:_.cycle_logs||[]})}catch{}ye(D.processes).then(_=>U(_||[])).catch(()=>{})},onSubmit:()=>Ue(D.processes,cs,()=>Dt(Os()),"processes",_=>Dt({...Os(),..._,progress_indicators:_.progress_indicators||[],cycle_logs:_.cycle_logs||[]})),onBack:()=>{u("processes"),ne("idle")},onNavigate:u,onLogout:Ce,user:e});if(c==="organizations-form")return n.jsx(a1,{orgForm:wc,setOrgForm:Kl,formStatus:Te,viewMode:Ie||!f("organizations-form"),onSubmit:()=>Ue(D.organizations,wc,()=>Kl(ur()),"organizations"),onBack:()=>{u("organizations"),ne("idle")},onNavigate:u,onLogout:Ce,user:e});if(c==="managements-form")return n.jsx(d1,{form:kc,setForm:Zn,organizations:g,formStatus:Te,viewMode:Ie||!f("managements-form"),onSubmit:()=>Ue(D.managements,kc,()=>Zn(il()),"managements"),onBack:()=>{u("managements"),ne("idle")},onNavigate:u,onLogout:Ce,user:e});if(c==="departments-form")return n.jsx(h1,{form:_c,setForm:Vn,organizations:g,managements:Q,formStatus:Te,viewMode:Ie||!f("departments-form"),onSubmit:()=>Ue(D.departments,_c,()=>Vn(al()),"departments"),onBack:()=>{u("departments"),ne("idle")},onNavigate:u,onLogout:Ce,user:e});if(c==="branches-form")return n.jsx(y1,{form:Cc,setForm:el,organizations:g,managements:Q,departments:$,formStatus:Te,viewMode:Ie||!f("branches-form"),onSubmit:()=>Ue(D.branches,Cc,()=>el(ol()),"branches"),onBack:()=>{u("branches"),ne("idle")},onNavigate:u,onLogout:Ce,user:e});if(c==="cycles-form")return n.jsx(J1,{form:Oc,setForm:tl,organizations:g,formStatus:Te,viewMode:Ie||!f("cycles-form"),onSubmit:()=>Ue(D.cycles,Oc,()=>tl(cl()),"cycles"),onBack:()=>{u("cycles"),ne("idle")},onNavigate:u,onLogout:Ce,user:e});if(c==="kpi-input-form")return n.jsx(Z1,{form:Dc,setForm:nl,organizations:g,formStatus:Te,viewMode:Ie||!f("kpi-input-form"),onSubmit:()=>Ue(D.kpiInput,Dc,()=>nl(dl()),"kpi-input"),onBack:()=>{u("kpi-input"),ne("idle")},onNavigate:u,onLogout:Ce,user:e});if(c==="incident-types-form")return n.jsx(b1,{form:zc,setForm:Ql,formStatus:Te,viewMode:Ie||!f("incident-types-form"),onSubmit:()=>Ue(D.incidentTypes,zc,()=>Ql(pr()),"incident-types"),onBack:()=>{u("incident-types"),ne("idle")},onNavigate:u,onLogout:Ce,user:e});if(c==="idea-types-form")return n.jsx(k1,{form:Tc,setForm:Gl,formStatus:Te,viewMode:Ie||!f("idea-types-form"),onSubmit:()=>Ue(D.ideaTypes,Tc,()=>Gl(fr()),"idea-types"),onBack:()=>{u("idea-types"),ne("idle")},onNavigate:u,onLogout:Ce,user:e});if(c==="order-types-form")return n.jsx(z1,{form:Ic,setForm:Yl,formStatus:Te,viewMode:Ie||!f("order-types-form"),onSubmit:()=>Ue(D.orderTypes,Ic,()=>Yl(hr()),"order-types"),onBack:()=>{u("order-types"),ne("idle")},onNavigate:u,onLogout:Ce,user:e});if(c==="process-types-form")return n.jsx(P1,{form:Pc,setForm:Xl,formStatus:Te,viewMode:Ie||!f("process-types-form"),onSubmit:()=>Ue(D.processTypes,Pc,()=>Xl(gr()),"process-types"),onBack:()=>{u("process-types"),ne("idle")},onNavigate:u,onLogout:Ce,user:e});if(c==="incident-statuses-form")return n.jsx(R1,{form:Ec,setForm:Jl,formStatus:Te,viewMode:Ie||!f("incident-statuses-form"),onSubmit:()=>Ue(D.incidentStatuses,Ec,()=>Jl(xr()),"incident-statuses"),onBack:()=>{u("incident-statuses"),ne("idle")},onNavigate:u,onLogout:Ce,user:e});if(c==="idea-statuses-form")return n.jsx(D1,{form:Ac,setForm:ql,formStatus:Te,viewMode:Ie||!f("idea-statuses-form"),onSubmit:()=>Ue(D.ideaStatuses,Ac,()=>ql(mr()),"idea-statuses"),onBack:()=>{u("idea-statuses"),ne("idle")},onNavigate:u,onLogout:Ce,user:e});if(c==="order-statuses-form")return n.jsx(B1,{form:Rc,setForm:Zl,formStatus:Te,viewMode:Ie||!f("order-statuses-form"),onSubmit:()=>Ue(D.orderStatuses,Rc,()=>Zl(yr()),"order-statuses"),onBack:()=>{u("order-statuses"),ne("idle")},onNavigate:u,onLogout:Ce,user:e});if(c==="process-statuses-form")return n.jsx(F1,{form:Lc,setForm:Vl,formStatus:Te,viewMode:Ie||!f("process-statuses-form"),onSubmit:()=>Ue(D.processStatuses,Lc,()=>Vl(vr()),"process-statuses"),onBack:()=>{u("process-statuses"),ne("idle")},onNavigate:u,onLogout:Ce,user:e});if(c==="users-form")return n.jsx(Q1,{form:ds,setForm:us,organizations:g,managements:Q,departments:$,branches:Z,formStatus:Te,viewMode:Ie||!f("users-form"),isSelfProfile:jc,onSubmit:Oh,onBack:()=>{u(jc?a?"dashboard":"inbox":"users"),ne("idle")},onNavigate:u,onLogout:Ce,user:e});if(c==="delegations-form")return n.jsx(r0,{form:ll,setForm:er,organizations:g,users:Fl,userRoleMap:dt,formStatus:Te,viewMode:Ie||!f("delegations-form"),onSubmit:gh,onBack:()=>{u("delegations"),ne("idle")},onNavigate:u,onLogout:Ce,user:e});const Dh=s.pages,Nh={incidents:{color:N.accent,formPage:"incidents-form",reset:()=>Mt({...Gt(),organization:x})},ideas:{color:N.teal,formPage:"ideas-form",reset:()=>Ht({...Yt(),organization:x})},orders:{color:N.purple,formPage:"orders-form",reset:()=>Kt({...Xt(),organization:x})},processes:{color:N.blue,formPage:"processes-form",reset:()=>{const _=vc.create_processes,Y=i==="Manager"&&_&&_.length===1?_[0]:x;Dt({...Os(),organization:Y})}},organizations:{color:N.accent,formPage:"organizations-form",reset:()=>Kl(ur())},managements:{color:N.blue,formPage:"managements-form",reset:()=>Zn({...il(),organization:x})},departments:{color:N.teal,formPage:"departments-form",reset:()=>Vn({...al(),custom_organization:x})},branches:{color:N.purple,formPage:"branches-form",reset:()=>el({...ol(),organization:x})},cycles:{color:N.teal,formPage:"cycles-form",reset:()=>tl({...cl(),organization:x})},"kpi-input":{color:N.blue,formPage:"kpi-input-form",reset:()=>nl({...dl(),organization:x})},"incident-types":{color:N.red,formPage:"incident-types-form",reset:()=>Ql(pr())},"idea-types":{color:N.orange,formPage:"idea-types-form",reset:()=>Gl(fr())},"order-types":{color:N.green,formPage:"order-types-form",reset:()=>Yl(hr())},"process-types":{color:N.accent,formPage:"process-types-form",reset:()=>Xl(gr())},"incident-statuses":{color:N.red,formPage:"incident-statuses-form",reset:()=>Jl(xr())},"idea-statuses":{color:N.teal,formPage:"idea-statuses-form",reset:()=>ql(mr())},"order-statuses":{color:N.purple,formPage:"order-statuses-form",reset:()=>Zl(yr())},"process-statuses":{color:N.blue,formPage:"process-statuses-form",reset:()=>Vl(vr())},users:{color:N.blue,formPage:"users-form",reset:()=>{us(Ds()),bc(!1)}},delegations:{color:N.purple,formPage:"delegations-form",reset:()=>er(jr())}},Wh={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"},Bh={incidents:y,ideas:b,orders:k,processes:O,organizations:g,managements:Q,departments:$,branches:Z,cycles:is,"kpi-input":xc,"incident-types":se,"idea-types":je,"order-types":q,"process-types":De,"incident-statuses":P,"idea-statuses":Ct,"order-statuses":Rn,"process-statuses":on,users:Ye,delegations:mc},Ln=Om[c],Mi=Bh[c],G=f(c),Hi=G?Nh[c]:null;return n.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:l?"#0f172a":N.bg},children:[n.jsx(_f,{collapsed:Ff,onToggleCollapsed:Hf,activePage:c,onNavigate:_=>u(_),hasDashboard:a,hasReports:d,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:"7px 24px",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(t1,{notifCount:m,darkMode:l,onCountChange:z,onToggleDark:r,onNavigate:Fi,onViewProfile:()=>{const _=Ye.find(Y=>Y.name===e.name||Y.username===e.name);Sc(_||{name:e.name,full_name:e.full_name,email:e.name,enabled:1}),u("profile")},onLogout:Ce})}),c!=="profile"&&n.jsxs("div",{style:{background:l?"#1e293b":"white",padding:"10px 24px",borderBottom:`1px solid ${l?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[n.jsx("div",{style:{fontSize:18,fontWeight:700,color:l?"#e2e8f0":"#1e1b4b"},children:Dh[c]||c}),n.jsxs("div",{style:{display:"flex",gap:8},children:[Ln&&Mi&&n.jsx("button",{onClick:()=>Ui(!0),style:{background:"#16a34a",color:"white",border:"none",padding:"7px 16px",borderRadius:7,fontSize:13,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"}),Hi&&n.jsxs("button",{onClick:()=>{Hi.reset(),Ve(!1),ne("idle"),u(Hi.formPage)},style:{background:"#4f46e5",color:"white",border:"none",padding:"7px 16px",borderRadius:7,fontSize:13,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI"},children:["+ ",Wh[c]||s.new]})]})]}),Ln&&Mi&&Kf&&n.jsx(Fm,{title:Ln.label,rows:Mi,columns:Ln.columns,defaultColumnKeys:Ln.defaultColumns,orgField:Ln.orgField,organizations:Ln.orgField?g:void 0,filenameBase:c,onClose:()=>Ui(!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:[me&&n.jsx("div",{style:{textAlign:"center",paddingTop:60,color:"#aaa",fontSize:15},children:s.loading}),!me&&c==="dashboard"&&a&&n.jsx(_y,{incidents:y,ideas:b,orders:k,processes:O,organizations:g,incidentStatuses:P,ideaStatuses:Ct,orderStatuses:Rn,processStatuses:on,selectedOrg:x,onOrgChange:v,onNavigate:Fi,userRole:i}),!me&&c==="inbox"&&n.jsx(s0,{onNavigate:Fi,onRefresh:Nt}),!me&&c==="reports"&&d&&n.jsx(d0,{organizations:g,userRole:i}),!me&&c==="incidents"&&n.jsx(Py,{incidents:y,organizations:g,departments:$,branches:Z,incidentStatuses:P,initialOrg:x,onView:Yf,onEdit:G?rh:void 0,onDelete:G?_=>Ne(D.incidents,_):void 0,canModify:G}),!me&&c==="ideas"&&n.jsx($y,{ideas:b,organizations:g,departments:$,branches:Z,ideaStatuses:Ct,initialOrg:x,onView:Xf,onEdit:G?sh:void 0,onDelete:G?_=>Ne(D.ideas,_):void 0,canModify:G}),!me&&c==="orders"&&n.jsx(Hy,{orders:k,organizations:g,departments:$,branches:Z,orderStatuses:Rn,initialOrg:x,onView:Jf,onEdit:G?ih:void 0,onDelete:G?_=>Ne(D.orders,_):void 0,canModify:G}),!me&&c==="processes"&&n.jsx(Xy,{processes:O,organizations:g,departments:$,branches:Z,processStatuses:on,initialOrg:x,onView:qf,onEdit:G?ah:void 0,onDelete:G?_=>Ne(D.processes,_):void 0,canModify:G}),!me&&c==="organizations"&&n.jsx(i1,{organizations:g,onView:Zf,onEdit:G?oh:void 0,onDelete:G?_=>Ne(D.organizations,_):void 0,canModify:G}),!me&&c==="managements"&&n.jsx(c1,{managements:Q,onView:Vf,onEdit:G?ch:void 0,onDelete:G?_=>Ne(D.managements,_):void 0,canModify:G}),!me&&c==="departments"&&n.jsx(p1,{departments:$,managements:Q,onView:eh,onEdit:G?dh:void 0,onDelete:G?_=>Ne(D.departments,_):void 0,canModify:G}),!me&&c==="branches"&&n.jsx(x1,{branches:Z,managements:Q,departments:$,onView:th,onEdit:G?uh:void 0,onDelete:G?_=>Ne(D.branches,_):void 0,canModify:G}),!me&&c==="cycles"&&n.jsx(G1,{cycles:is,canModify:G,onView:nh,onEdit:G?ph:void 0,onDelete:G?_=>Ne(D.cycles,_):void 0}),!me&&c==="kpi-input"&&n.jsx(q1,{kpiInputs:xc,canModify:G,onView:lh,onEdit:G?fh:void 0,onDelete:G?_=>Ne(D.kpiInput,_):void 0}),!me&&c==="incident-types"&&n.jsx(j1,{incidentTypes:se,onView:mh,onEdit:G?yh:void 0,onDelete:G?_=>Ne(D.incidentTypes,_):void 0,canModify:G}),!me&&c==="idea-types"&&n.jsx(w1,{ideaTypes:je,onView:vh,onEdit:G?jh:void 0,onDelete:G?_=>Ne(D.ideaTypes,_):void 0,canModify:G}),!me&&c==="order-types"&&n.jsx(C1,{orderTypes:q,onView:bh,onEdit:G?Sh:void 0,onDelete:G?_=>Ne(D.orderTypes,_):void 0,canModify:G}),!me&&c==="process-types"&&n.jsx(I1,{processTypes:De,onView:wh,onEdit:G?kh:void 0,onDelete:G?_=>Ne(D.processTypes,_):void 0,canModify:G}),!me&&c==="incident-statuses"&&n.jsx(A1,{incidentStatuses:P,onView:_h,onEdit:G?Ch:void 0,onDelete:G?_=>Ne(D.incidentStatuses,_):void 0,canModify:G}),!me&&c==="idea-statuses"&&n.jsx(O1,{ideaStatuses:Ct,onView:zh,onEdit:G?Th:void 0,onDelete:G?_=>Ne(D.ideaStatuses,_):void 0,canModify:G}),!me&&c==="order-statuses"&&n.jsx(W1,{orderStatuses:Rn,onView:Ih,onEdit:G?Ph:void 0,onDelete:G?_=>Ne(D.orderStatuses,_):void 0,canModify:G}),!me&&c==="process-statuses"&&n.jsx(U1,{processStatuses:on,onView:Eh,onEdit:G?Ah:void 0,onDelete:G?_=>Ne(D.processStatuses,_):void 0,canModify:G}),!me&&c==="users"&&n.jsx(K1,{users:Ye,roleMap:dt,onView:Rh,onEdit:G?Lh:void 0,onDelete:G?_=>Ne("User",_):void 0,onDisable:G?Gf:void 0,canModify:G}),!me&&c==="delegations"&&p&&n.jsx(n0,{delegations:mc,organizations:g,userRole:i,currentUser:e.name,onView:hh,onRevoke:G?xh:void 0}),c==="profile"&&(()=>{const _=!!as&&(as.name===e.name||as.email===e.name);return n.jsx(l1,{user:e,profileUser:as,sbUsers:Ye,organizations:g,managements:Q,departments:$,branches:Z,darkMode:l,canModify:G||_,onBack:()=>u(_?a?"dashboard":"inbox":"users"),onNavigate:u})})()]})]})]})}function m0(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 y0(){const[e,t]=S.useState(()=>{try{const d=localStorage.getItem("sidrah_user");return d?JSON.parse(d):null}catch{return null}}),[l,r]=S.useState(()=>localStorage.getItem("sb_dark")==="1"),s=()=>{const d=!l;r(d),localStorage.setItem("sb_dark",d?"1":"0"),document.documentElement.classList.toggle("dark",d)};S.useEffect(()=>{document.documentElement.classList.toggle("dark",l)},[]),S.useEffect(()=>{e&&If().then(async d=>{const p=d||e.name,f=await Ef(p);if(!f.length)return;const h=m0(f);if(h!==e.role||p!==e.name){const u={...e,name:p,role:h};t(u),localStorage.setItem("sidrah_user",JSON.stringify(u))}})},[e==null?void 0:e.name]);const i=d=>{t(d),localStorage.setItem("sidrah_user",JSON.stringify(d))},a=()=>{t(null),localStorage.removeItem("sidrah_user")};return e?n.jsx(x0,{user:e,onLogout:a,darkMode:l,onToggleDark:s}):n.jsx(vy,{onLogin:i})}wf(document.getElementById("root")).render(n.jsx(S.StrictMode,{children:n.jsx(y0,{})}));
|