53 lines
484 KiB
JavaScript
53 lines
484 KiB
JavaScript
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function l(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(r){if(r.ep)return;r.ep=!0;const i=l(r);fetch(r.href,i)}})();var vu={exports:{}},Pi={},ju={exports:{}},ae={};/**
|
||
* @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 ar=Symbol.for("react.element"),hg=Symbol.for("react.portal"),gg=Symbol.for("react.fragment"),xg=Symbol.for("react.strict_mode"),mg=Symbol.for("react.profiler"),yg=Symbol.for("react.provider"),vg=Symbol.for("react.context"),jg=Symbol.for("react.forward_ref"),bg=Symbol.for("react.suspense"),Sg=Symbol.for("react.memo"),wg=Symbol.for("react.lazy"),Kc=Symbol.iterator;function kg(e){return e===null||typeof e!="object"?null:(e=Kc&&e[Kc]||e["@@iterator"],typeof e=="function"?e:null)}var bu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Su=Object.assign,wu={};function Yl(e,t,l){this.props=e,this.context=t,this.refs=wu,this.updater=l||bu}Yl.prototype.isReactComponent={};Yl.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")};Yl.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function ku(){}ku.prototype=Yl.prototype;function To(e,t,l){this.props=e,this.context=t,this.refs=wu,this.updater=l||bu}var Po=To.prototype=new ku;Po.constructor=To;Su(Po,Yl.prototype);Po.isPureReactComponent=!0;var Qc=Array.isArray,_u=Object.prototype.hasOwnProperty,Io={current:null},Cu={key:!0,ref:!0,__self:!0,__source:!0};function zu(e,t,l){var s,r={},i=null,a=null;if(t!=null)for(s in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(i=""+t.key),t)_u.call(t,s)&&!Cu.hasOwnProperty(s)&&(r[s]=t[s]);var d=arguments.length-2;if(d===1)r.children=l;else if(1<d){for(var u=Array(d),f=0;f<d;f++)u[f]=arguments[f+2];r.children=u}if(e&&e.defaultProps)for(s in d=e.defaultProps,d)r[s]===void 0&&(r[s]=d[s]);return{$$typeof:ar,type:e,key:i,ref:a,props:r,_owner:Io.current}}function _g(e,t){return{$$typeof:ar,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Eo(e){return typeof e=="object"&&e!==null&&e.$$typeof===ar}function Cg(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(l){return t[l]})}var Gc=/\/+/g;function ta(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Cg(""+e.key):t.toString(36)}function Qr(e,t,l,s,r){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 ar:case hg:a=!0}}if(a)return a=e,r=r(a),e=s===""?"."+ta(a,0):s,Qc(r)?(l="",e!=null&&(l=e.replace(Gc,"$&/")+"/"),Qr(r,t,l,"",function(f){return f})):r!=null&&(Eo(r)&&(r=_g(r,l+(!r.key||a&&a.key===r.key?"":(""+r.key).replace(Gc,"$&/")+"/")+e)),t.push(r)),1;if(a=0,s=s===""?".":s+":",Qc(e))for(var d=0;d<e.length;d++){i=e[d];var u=s+ta(i,d);a+=Qr(i,t,l,u,r)}else if(u=kg(e),typeof u=="function")for(e=u.call(e),d=0;!(i=e.next()).done;)i=i.value,u=s+ta(i,d++),a+=Qr(i,t,l,u,r);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 br(e,t,l){if(e==null)return e;var s=[],r=0;return Qr(e,s,"","",function(i){return t.call(l,i,r++)}),s}function zg(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 at={current:null},Gr={transition:null},Tg={ReactCurrentDispatcher:at,ReactCurrentBatchConfig:Gr,ReactCurrentOwner:Io};function Tu(){throw Error("act(...) is not supported in production builds of React.")}ae.Children={map:br,forEach:function(e,t,l){br(e,function(){t.apply(this,arguments)},l)},count:function(e){var t=0;return br(e,function(){t++}),t},toArray:function(e){return br(e,function(t){return t})||[]},only:function(e){if(!Eo(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ae.Component=Yl;ae.Fragment=gg;ae.Profiler=mg;ae.PureComponent=To;ae.StrictMode=xg;ae.Suspense=bg;ae.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Tg;ae.act=Tu;ae.cloneElement=function(e,t,l){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var s=Su({},e.props),r=e.key,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=Io.current),t.key!==void 0&&(r=""+t.key),e.type&&e.type.defaultProps)var d=e.type.defaultProps;for(u in t)_u.call(t,u)&&!Cu.hasOwnProperty(u)&&(s[u]=t[u]===void 0&&d!==void 0?d[u]:t[u])}var u=arguments.length-2;if(u===1)s.children=l;else if(1<u){d=Array(u);for(var f=0;f<u;f++)d[f]=arguments[f+2];s.children=d}return{$$typeof:ar,type:e.type,key:r,ref:i,props:s,_owner:a}};ae.createContext=function(e){return e={$$typeof:vg,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:yg,_context:e},e.Consumer=e};ae.createElement=zu;ae.createFactory=function(e){var t=zu.bind(null,e);return t.type=e,t};ae.createRef=function(){return{current:null}};ae.forwardRef=function(e){return{$$typeof:jg,render:e}};ae.isValidElement=Eo;ae.lazy=function(e){return{$$typeof:wg,_payload:{_status:-1,_result:e},_init:zg}};ae.memo=function(e,t){return{$$typeof:Sg,type:e,compare:t===void 0?null:t}};ae.startTransition=function(e){var t=Gr.transition;Gr.transition={};try{e()}finally{Gr.transition=t}};ae.unstable_act=Tu;ae.useCallback=function(e,t){return at.current.useCallback(e,t)};ae.useContext=function(e){return at.current.useContext(e)};ae.useDebugValue=function(){};ae.useDeferredValue=function(e){return at.current.useDeferredValue(e)};ae.useEffect=function(e,t){return at.current.useEffect(e,t)};ae.useId=function(){return at.current.useId()};ae.useImperativeHandle=function(e,t,l){return at.current.useImperativeHandle(e,t,l)};ae.useInsertionEffect=function(e,t){return at.current.useInsertionEffect(e,t)};ae.useLayoutEffect=function(e,t){return at.current.useLayoutEffect(e,t)};ae.useMemo=function(e,t){return at.current.useMemo(e,t)};ae.useReducer=function(e,t,l){return at.current.useReducer(e,t,l)};ae.useRef=function(e){return at.current.useRef(e)};ae.useState=function(e){return at.current.useState(e)};ae.useSyncExternalStore=function(e,t,l){return at.current.useSyncExternalStore(e,t,l)};ae.useTransition=function(){return at.current.useTransition()};ae.version="18.3.1";ju.exports=ae;var j=ju.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 Pg=j,Ig=Symbol.for("react.element"),Eg=Symbol.for("react.fragment"),Ag=Object.prototype.hasOwnProperty,Rg=Pg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Lg={key:!0,ref:!0,__self:!0,__source:!0};function Pu(e,t,l){var s,r={},i=null,a=null;l!==void 0&&(i=""+l),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(a=t.ref);for(s in t)Ag.call(t,s)&&!Lg.hasOwnProperty(s)&&(r[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)r[s]===void 0&&(r[s]=t[s]);return{$$typeof:Ig,type:e,key:i,ref:a,props:r,_owner:Rg.current}}Pi.Fragment=Eg;Pi.jsx=Pu;Pi.jsxs=Pu;vu.exports=Pi;var n=vu.exports,Iu={exports:{}},St={},Eu={exports:{}},Au={};/**
|
||
* @license React
|
||
* scheduler.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/(function(e){function t(L,K){var G=L.length;L.push(K);e:for(;0<G;){var ee=G-1>>>1,J=L[ee];if(0<r(J,K))L[ee]=K,L[G]=J,G=ee;else break e}}function l(L){return L.length===0?null:L[0]}function s(L){if(L.length===0)return null;var K=L[0],G=L.pop();if(G!==K){L[0]=G;e:for(var ee=0,J=L.length,xe=J>>>1;ee<xe;){var _e=2*(ee+1)-1,re=L[_e],Ce=_e+1,Oe=L[Ce];if(0>r(re,G))Ce<J&&0>r(Oe,re)?(L[ee]=Oe,L[Ce]=G,ee=Ce):(L[ee]=re,L[_e]=G,ee=_e);else if(Ce<J&&0>r(Oe,G))L[ee]=Oe,L[Ce]=G,ee=Ce;else break e}}return K}function r(L,K){var G=L.sortIndex-K.sortIndex;return G!==0?G:L.id-K.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 u=[],f=[],y=1,p=null,c=3,v=!1,b=!1,g=!1,S=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,m=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function o(L){for(var K=l(f);K!==null;){if(K.callback===null)s(f);else if(K.startTime<=L)s(f),K.sortIndex=K.expirationTime,t(u,K);else break;K=l(f)}}function x(L){if(g=!1,o(L),!b)if(l(u)!==null)b=!0,ge(C);else{var K=l(f);K!==null&&le(x,K.startTime-L)}}function C(L,K){b=!1,g&&(g=!1,h(w),w=-1),v=!0;var G=c;try{for(o(K),p=l(u);p!==null&&(!(p.expirationTime>K)||L&&!P());){var ee=p.callback;if(typeof ee=="function"){p.callback=null,c=p.priorityLevel;var J=ee(p.expirationTime<=K);K=e.unstable_now(),typeof J=="function"?p.callback=J:p===l(u)&&s(u),o(K)}else s(u);p=l(u)}if(p!==null)var xe=!0;else{var _e=l(f);_e!==null&&le(x,_e.startTime-K),xe=!1}return xe}finally{p=null,c=G,v=!1}}var A=!1,T=null,w=-1,_=5,U=-1;function P(){return!(e.unstable_now()-U<_)}function I(){if(T!==null){var L=e.unstable_now();U=L;var K=!0;try{K=T(!0,L)}finally{K?N():(A=!1,T=null)}}else A=!1}var N;if(typeof m=="function")N=function(){m(I)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,Z=M.port2;M.port1.onmessage=I,N=function(){Z.postMessage(null)}}else N=function(){S(I,0)};function ge(L){T=L,A||(A=!0,N())}function le(L,K){w=S(function(){L(e.unstable_now())},K)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(L){L.callback=null},e.unstable_continueExecution=function(){b||v||(b=!0,ge(C))},e.unstable_forceFrameRate=function(L){0>L||125<L?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):_=0<L?Math.floor(1e3/L):5},e.unstable_getCurrentPriorityLevel=function(){return c},e.unstable_getFirstCallbackNode=function(){return l(u)},e.unstable_next=function(L){switch(c){case 1:case 2:case 3:var K=3;break;default:K=c}var G=c;c=K;try{return L()}finally{c=G}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(L,K){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var G=c;c=L;try{return K()}finally{c=G}},e.unstable_scheduleCallback=function(L,K,G){var ee=e.unstable_now();switch(typeof G=="object"&&G!==null?(G=G.delay,G=typeof G=="number"&&0<G?ee+G:ee):G=ee,L){case 1:var J=-1;break;case 2:J=250;break;case 5:J=1073741823;break;case 4:J=1e4;break;default:J=5e3}return J=G+J,L={id:y++,callback:K,priorityLevel:L,startTime:G,expirationTime:J,sortIndex:-1},G>ee?(L.sortIndex=G,t(f,L),l(u)===null&&L===l(f)&&(g?(h(w),w=-1):g=!0,le(x,G-ee))):(L.sortIndex=J,t(u,L),b||v||(b=!0,ge(C))),L},e.unstable_shouldYield=P,e.unstable_wrapCallback=function(L){var K=c;return function(){var G=c;c=K;try{return L.apply(this,arguments)}finally{c=G}}}})(Au);Eu.exports=Au;var Og=Eu.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 Dg=j,bt=Og;function F(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 Ru=new Set,Hs={};function tl(e,t){Bl(e,t),Bl(e+"Capture",t)}function Bl(e,t){for(Hs[e]=t,e=0;e<t.length;e++)Ru.add(t[e])}var on=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ra=Object.prototype.hasOwnProperty,Ng=/^[: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]*$/,Yc={},Xc={};function Wg(e){return Ra.call(Xc,e)?!0:Ra.call(Yc,e)?!1:Ng.test(e)?Xc[e]=!0:(Yc[e]=!0,!1)}function Bg(e,t,l,s){if(l!==null&&l.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return s?!1:l!==null?!l.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function $g(e,t,l,s){if(t===null||typeof t>"u"||Bg(e,t,l,s))return!0;if(s)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 ot(e,t,l,s,r,i,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=s,this.attributeNamespace=r,this.mustUseProperty=l,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=a}var et={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){et[e]=new ot(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];et[t]=new ot(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){et[e]=new ot(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){et[e]=new ot(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){et[e]=new ot(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){et[e]=new ot(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){et[e]=new ot(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){et[e]=new ot(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){et[e]=new ot(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ao=/[\-:]([a-z])/g;function Ro(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(Ao,Ro);et[t]=new ot(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(Ao,Ro);et[t]=new ot(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(Ao,Ro);et[t]=new ot(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){et[e]=new ot(e,1,!1,e.toLowerCase(),null,!1,!1)});et.xlinkHref=new ot("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){et[e]=new ot(e,1,!1,e.toLowerCase(),null,!0,!0)});function Lo(e,t,l,s){var r=et.hasOwnProperty(t)?et[t]:null;(r!==null?r.type!==0:s||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&($g(t,l,r,s)&&(l=null),s||r===null?Wg(t)&&(l===null?e.removeAttribute(t):e.setAttribute(t,""+l)):r.mustUseProperty?e[r.propertyName]=l===null?r.type===3?!1:"":l:(t=r.attributeName,s=r.attributeNamespace,l===null?e.removeAttribute(t):(r=r.type,l=r===3||r===4&&l===!0?"":""+l,s?e.setAttributeNS(s,t,l):e.setAttribute(t,l))))}var pn=Dg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Sr=Symbol.for("react.element"),jl=Symbol.for("react.portal"),bl=Symbol.for("react.fragment"),Oo=Symbol.for("react.strict_mode"),La=Symbol.for("react.profiler"),Lu=Symbol.for("react.provider"),Ou=Symbol.for("react.context"),Do=Symbol.for("react.forward_ref"),Oa=Symbol.for("react.suspense"),Da=Symbol.for("react.suspense_list"),No=Symbol.for("react.memo"),yn=Symbol.for("react.lazy"),Du=Symbol.for("react.offscreen"),qc=Symbol.iterator;function as(e){return e===null||typeof e!="object"?null:(e=qc&&e[qc]||e["@@iterator"],typeof e=="function"?e:null)}var Pe=Object.assign,na;function Is(e){if(na===void 0)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);na=t&&t[1]||""}return`
|
||
`+na+e}var la=!1;function sa(e,t){if(!e||la)return"";la=!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 s=f}Reflect.construct(e,[],t)}else{try{t.call()}catch(f){s=f}e.call(t.prototype)}else{try{throw Error()}catch(f){s=f}e()}}catch(f){if(f&&s&&typeof f.stack=="string"){for(var r=f.stack.split(`
|
||
`),i=s.stack.split(`
|
||
`),a=r.length-1,d=i.length-1;1<=a&&0<=d&&r[a]!==i[d];)d--;for(;1<=a&&0<=d;a--,d--)if(r[a]!==i[d]){if(a!==1||d!==1)do if(a--,d--,0>d||r[a]!==i[d]){var u=`
|
||
`+r[a].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}while(1<=a&&0<=d);break}}}finally{la=!1,Error.prepareStackTrace=l}return(e=e?e.displayName||e.name:"")?Is(e):""}function Ug(e){switch(e.tag){case 5:return Is(e.type);case 16:return Is("Lazy");case 13:return Is("Suspense");case 19:return Is("SuspenseList");case 0:case 2:case 15:return e=sa(e.type,!1),e;case 11:return e=sa(e.type.render,!1),e;case 1:return e=sa(e.type,!0),e;default:return""}}function Na(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 bl:return"Fragment";case jl:return"Portal";case La:return"Profiler";case Oo:return"StrictMode";case Oa:return"Suspense";case Da:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Ou:return(e.displayName||"Context")+".Consumer";case Lu:return(e._context.displayName||"Context")+".Provider";case Do:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case No:return t=e.displayName||null,t!==null?t:Na(e.type)||"Memo";case yn:t=e._payload,e=e._init;try{return Na(e(t))}catch{}}return null}function Fg(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 Na(t);case 8:return t===Oo?"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 Rn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Nu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Mg(e){var t=Nu(e)?"checked":"value",l=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),s=""+e[t];if(!e.hasOwnProperty(t)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var r=l.get,i=l.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return r.call(this)},set:function(a){s=""+a,i.call(this,a)}}),Object.defineProperty(e,t,{enumerable:l.enumerable}),{getValue:function(){return s},setValue:function(a){s=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function wr(e){e._valueTracker||(e._valueTracker=Mg(e))}function Wu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var l=t.getValue(),s="";return e&&(s=Nu(e)?e.checked?"true":"false":e.value),e=s,e!==l?(t.setValue(e),!0):!1}function si(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 Wa(e,t){var l=t.checked;return Pe({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??e._wrapperState.initialChecked})}function Jc(e,t){var l=t.defaultValue==null?"":t.defaultValue,s=t.checked!=null?t.checked:t.defaultChecked;l=Rn(t.value!=null?t.value:l),e._wrapperState={initialChecked:s,initialValue:l,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Bu(e,t){t=t.checked,t!=null&&Lo(e,"checked",t,!1)}function Ba(e,t){Bu(e,t);var l=Rn(t.value),s=t.type;if(l!=null)s==="number"?(l===0&&e.value===""||e.value!=l)&&(e.value=""+l):e.value!==""+l&&(e.value=""+l);else if(s==="submit"||s==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?$a(e,t.type,l):t.hasOwnProperty("defaultValue")&&$a(e,t.type,Rn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Zc(e,t,l){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var s=t.type;if(!(s!=="submit"&&s!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,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 $a(e,t,l){(t!=="number"||si(e.ownerDocument)!==e)&&(l==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+l&&(e.defaultValue=""+l))}var Es=Array.isArray;function Rl(e,t,l,s){if(e=e.options,t){t={};for(var r=0;r<l.length;r++)t["$"+l[r]]=!0;for(l=0;l<e.length;l++)r=t.hasOwnProperty("$"+e[l].value),e[l].selected!==r&&(e[l].selected=r),r&&s&&(e[l].defaultSelected=!0)}else{for(l=""+Rn(l),t=null,r=0;r<e.length;r++){if(e[r].value===l){e[r].selected=!0,s&&(e[r].defaultSelected=!0);return}t!==null||e[r].disabled||(t=e[r])}t!==null&&(t.selected=!0)}}function Ua(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(F(91));return Pe({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Vc(e,t){var l=t.value;if(l==null){if(l=t.children,t=t.defaultValue,l!=null){if(t!=null)throw Error(F(92));if(Es(l)){if(1<l.length)throw Error(F(93));l=l[0]}t=l}t==null&&(t=""),l=t}e._wrapperState={initialValue:Rn(l)}}function $u(e,t){var l=Rn(t.value),s=Rn(t.defaultValue);l!=null&&(l=""+l,l!==e.value&&(e.value=l),t.defaultValue==null&&e.defaultValue!==l&&(e.defaultValue=l)),s!=null&&(e.defaultValue=""+s)}function ed(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Uu(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 Fa(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Uu(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var kr,Fu=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,l,s,r){MSApp.execUnsafeLocalFunction(function(){return e(t,l,s,r)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(kr=kr||document.createElement("div"),kr.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=kr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ks(e,t){if(t){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=t;return}}e.textContent=t}var Os={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},Hg=["Webkit","ms","Moz","O"];Object.keys(Os).forEach(function(e){Hg.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Os[t]=Os[e]})});function Mu(e,t,l){return t==null||typeof t=="boolean"||t===""?"":l||typeof t!="number"||t===0||Os.hasOwnProperty(e)&&Os[e]?(""+t).trim():t+"px"}function Hu(e,t){e=e.style;for(var l in t)if(t.hasOwnProperty(l)){var s=l.indexOf("--")===0,r=Mu(l,t[l],s);l==="float"&&(l="cssFloat"),s?e.setProperty(l,r):e[l]=r}}var Kg=Pe({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ma(e,t){if(t){if(Kg[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(F(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(F(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(F(61))}if(t.style!=null&&typeof t.style!="object")throw Error(F(62))}}function Ha(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 Ka=null;function Wo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Qa=null,Ll=null,Ol=null;function td(e){if(e=dr(e)){if(typeof Qa!="function")throw Error(F(280));var t=e.stateNode;t&&(t=Li(t),Qa(e.stateNode,e.type,t))}}function Ku(e){Ll?Ol?Ol.push(e):Ol=[e]:Ll=e}function Qu(){if(Ll){var e=Ll,t=Ol;if(Ol=Ll=null,td(e),t)for(e=0;e<t.length;e++)td(t[e])}}function Gu(e,t){return e(t)}function Yu(){}var ra=!1;function Xu(e,t,l){if(ra)return e(t,l);ra=!0;try{return Gu(e,t,l)}finally{ra=!1,(Ll!==null||Ol!==null)&&(Yu(),Qu())}}function Qs(e,t){var l=e.stateNode;if(l===null)return null;var s=Li(l);if(s===null)return null;l=s[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(s=!s.disabled)||(e=e.type,s=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!s;break e;default:e=!1}if(e)return null;if(l&&typeof l!="function")throw Error(F(231,t,typeof l));return l}var Ga=!1;if(on)try{var os={};Object.defineProperty(os,"passive",{get:function(){Ga=!0}}),window.addEventListener("test",os,os),window.removeEventListener("test",os,os)}catch{Ga=!1}function Qg(e,t,l,s,r,i,a,d,u){var f=Array.prototype.slice.call(arguments,3);try{t.apply(l,f)}catch(y){this.onError(y)}}var Ds=!1,ri=null,ii=!1,Ya=null,Gg={onError:function(e){Ds=!0,ri=e}};function Yg(e,t,l,s,r,i,a,d,u){Ds=!1,ri=null,Qg.apply(Gg,arguments)}function Xg(e,t,l,s,r,i,a,d,u){if(Yg.apply(this,arguments),Ds){if(Ds){var f=ri;Ds=!1,ri=null}else throw Error(F(198));ii||(ii=!0,Ya=f)}}function nl(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 qu(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 nd(e){if(nl(e)!==e)throw Error(F(188))}function qg(e){var t=e.alternate;if(!t){if(t=nl(e),t===null)throw Error(F(188));return t!==e?null:e}for(var l=e,s=t;;){var r=l.return;if(r===null)break;var i=r.alternate;if(i===null){if(s=r.return,s!==null){l=s;continue}break}if(r.child===i.child){for(i=r.child;i;){if(i===l)return nd(r),e;if(i===s)return nd(r),t;i=i.sibling}throw Error(F(188))}if(l.return!==s.return)l=r,s=i;else{for(var a=!1,d=r.child;d;){if(d===l){a=!0,l=r,s=i;break}if(d===s){a=!0,s=r,l=i;break}d=d.sibling}if(!a){for(d=i.child;d;){if(d===l){a=!0,l=i,s=r;break}if(d===s){a=!0,s=i,l=r;break}d=d.sibling}if(!a)throw Error(F(189))}}if(l.alternate!==s)throw Error(F(190))}if(l.tag!==3)throw Error(F(188));return l.stateNode.current===l?e:t}function Ju(e){return e=qg(e),e!==null?Zu(e):null}function Zu(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Zu(e);if(t!==null)return t;e=e.sibling}return null}var Vu=bt.unstable_scheduleCallback,ld=bt.unstable_cancelCallback,Jg=bt.unstable_shouldYield,Zg=bt.unstable_requestPaint,Le=bt.unstable_now,Vg=bt.unstable_getCurrentPriorityLevel,Bo=bt.unstable_ImmediatePriority,ep=bt.unstable_UserBlockingPriority,ai=bt.unstable_NormalPriority,ex=bt.unstable_LowPriority,tp=bt.unstable_IdlePriority,Ii=null,Qt=null;function tx(e){if(Qt&&typeof Qt.onCommitFiberRoot=="function")try{Qt.onCommitFiberRoot(Ii,e,void 0,(e.current.flags&128)===128)}catch{}}var Wt=Math.clz32?Math.clz32:sx,nx=Math.log,lx=Math.LN2;function sx(e){return e>>>=0,e===0?32:31-(nx(e)/lx|0)|0}var _r=64,Cr=4194304;function As(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 oi(e,t){var l=e.pendingLanes;if(l===0)return 0;var s=0,r=e.suspendedLanes,i=e.pingedLanes,a=l&268435455;if(a!==0){var d=a&~r;d!==0?s=As(d):(i&=a,i!==0&&(s=As(i)))}else a=l&~r,a!==0?s=As(a):i!==0&&(s=As(i));if(s===0)return 0;if(t!==0&&t!==s&&!(t&r)&&(r=s&-s,i=t&-t,r>=i||r===16&&(i&4194240)!==0))return t;if(s&4&&(s|=l&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=s;0<t;)l=31-Wt(t),r=1<<l,s|=e[l],t&=~r;return s}function rx(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 ix(e,t){for(var l=e.suspendedLanes,s=e.pingedLanes,r=e.expirationTimes,i=e.pendingLanes;0<i;){var a=31-Wt(i),d=1<<a,u=r[a];u===-1?(!(d&l)||d&s)&&(r[a]=rx(d,t)):u<=t&&(e.expiredLanes|=d),i&=~d}}function Xa(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function np(){var e=_r;return _r<<=1,!(_r&4194240)&&(_r=64),e}function ia(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function or(e,t,l){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Wt(t),e[t]=l}function ax(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 s=e.eventTimes;for(e=e.expirationTimes;0<l;){var r=31-Wt(l),i=1<<r;t[r]=0,s[r]=-1,e[r]=-1,l&=~i}}function $o(e,t){var l=e.entangledLanes|=t;for(e=e.entanglements;l;){var s=31-Wt(l),r=1<<s;r&t|e[s]&t&&(e[s]|=t),l&=~r}}var he=0;function lp(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var sp,Uo,rp,ip,ap,qa=!1,zr=[],_n=null,Cn=null,zn=null,Gs=new Map,Ys=new Map,jn=[],ox="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 sd(e,t){switch(e){case"focusin":case"focusout":_n=null;break;case"dragenter":case"dragleave":Cn=null;break;case"mouseover":case"mouseout":zn=null;break;case"pointerover":case"pointerout":Gs.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ys.delete(t.pointerId)}}function cs(e,t,l,s,r,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:l,eventSystemFlags:s,nativeEvent:i,targetContainers:[r]},t!==null&&(t=dr(t),t!==null&&Uo(t)),e):(e.eventSystemFlags|=s,t=e.targetContainers,r!==null&&t.indexOf(r)===-1&&t.push(r),e)}function cx(e,t,l,s,r){switch(t){case"focusin":return _n=cs(_n,e,t,l,s,r),!0;case"dragenter":return Cn=cs(Cn,e,t,l,s,r),!0;case"mouseover":return zn=cs(zn,e,t,l,s,r),!0;case"pointerover":var i=r.pointerId;return Gs.set(i,cs(Gs.get(i)||null,e,t,l,s,r)),!0;case"gotpointercapture":return i=r.pointerId,Ys.set(i,cs(Ys.get(i)||null,e,t,l,s,r)),!0}return!1}function op(e){var t=Hn(e.target);if(t!==null){var l=nl(t);if(l!==null){if(t=l.tag,t===13){if(t=qu(l),t!==null){e.blockedOn=t,ap(e.priority,function(){rp(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 Yr(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var l=Ja(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(l===null){l=e.nativeEvent;var s=new l.constructor(l.type,l);Ka=s,l.target.dispatchEvent(s),Ka=null}else return t=dr(l),t!==null&&Uo(t),e.blockedOn=l,!1;t.shift()}return!0}function rd(e,t,l){Yr(e)&&l.delete(t)}function dx(){qa=!1,_n!==null&&Yr(_n)&&(_n=null),Cn!==null&&Yr(Cn)&&(Cn=null),zn!==null&&Yr(zn)&&(zn=null),Gs.forEach(rd),Ys.forEach(rd)}function ds(e,t){e.blockedOn===t&&(e.blockedOn=null,qa||(qa=!0,bt.unstable_scheduleCallback(bt.unstable_NormalPriority,dx)))}function Xs(e){function t(r){return ds(r,e)}if(0<zr.length){ds(zr[0],e);for(var l=1;l<zr.length;l++){var s=zr[l];s.blockedOn===e&&(s.blockedOn=null)}}for(_n!==null&&ds(_n,e),Cn!==null&&ds(Cn,e),zn!==null&&ds(zn,e),Gs.forEach(t),Ys.forEach(t),l=0;l<jn.length;l++)s=jn[l],s.blockedOn===e&&(s.blockedOn=null);for(;0<jn.length&&(l=jn[0],l.blockedOn===null);)op(l),l.blockedOn===null&&jn.shift()}var Dl=pn.ReactCurrentBatchConfig,ci=!0;function ux(e,t,l,s){var r=he,i=Dl.transition;Dl.transition=null;try{he=1,Fo(e,t,l,s)}finally{he=r,Dl.transition=i}}function px(e,t,l,s){var r=he,i=Dl.transition;Dl.transition=null;try{he=4,Fo(e,t,l,s)}finally{he=r,Dl.transition=i}}function Fo(e,t,l,s){if(ci){var r=Ja(e,t,l,s);if(r===null)xa(e,t,s,di,l),sd(e,s);else if(cx(r,e,t,l,s))s.stopPropagation();else if(sd(e,s),t&4&&-1<ox.indexOf(e)){for(;r!==null;){var i=dr(r);if(i!==null&&sp(i),i=Ja(e,t,l,s),i===null&&xa(e,t,s,di,l),i===r)break;r=i}r!==null&&s.stopPropagation()}else xa(e,t,s,null,l)}}var di=null;function Ja(e,t,l,s){if(di=null,e=Wo(s),e=Hn(e),e!==null)if(t=nl(e),t===null)e=null;else if(l=t.tag,l===13){if(e=qu(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 di=e,null}function cp(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(Vg()){case Bo:return 1;case ep:return 4;case ai:case ex:return 16;case tp:return 536870912;default:return 16}default:return 16}}var Sn=null,Mo=null,Xr=null;function dp(){if(Xr)return Xr;var e,t=Mo,l=t.length,s,r="value"in Sn?Sn.value:Sn.textContent,i=r.length;for(e=0;e<l&&t[e]===r[e];e++);var a=l-e;for(s=1;s<=a&&t[l-s]===r[i-s];s++);return Xr=r.slice(e,1<s?1-s:void 0)}function qr(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 Tr(){return!0}function id(){return!1}function wt(e){function t(l,s,r,i,a){this._reactName=l,this._targetInst=r,this.type=s,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)?Tr:id,this.isPropagationStopped=id,this}return Pe(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=Tr)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Tr)},persist:function(){},isPersistent:Tr}),t}var Xl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ho=wt(Xl),cr=Pe({},Xl,{view:0,detail:0}),fx=wt(cr),aa,oa,us,Ei=Pe({},cr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ko,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!==us&&(us&&e.type==="mousemove"?(aa=e.screenX-us.screenX,oa=e.screenY-us.screenY):oa=aa=0,us=e),aa)},movementY:function(e){return"movementY"in e?e.movementY:oa}}),ad=wt(Ei),hx=Pe({},Ei,{dataTransfer:0}),gx=wt(hx),xx=Pe({},cr,{relatedTarget:0}),ca=wt(xx),mx=Pe({},Xl,{animationName:0,elapsedTime:0,pseudoElement:0}),yx=wt(mx),vx=Pe({},Xl,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),jx=wt(vx),bx=Pe({},Xl,{data:0}),od=wt(bx),Sx={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},wx={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},kx={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function _x(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=kx[e])?!!t[e]:!1}function Ko(){return _x}var Cx=Pe({},cr,{key:function(e){if(e.key){var t=Sx[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=qr(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?wx[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ko,charCode:function(e){return e.type==="keypress"?qr(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?qr(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),zx=wt(Cx),Tx=Pe({},Ei,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),cd=wt(Tx),Px=Pe({},cr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ko}),Ix=wt(Px),Ex=Pe({},Xl,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ax=wt(Ex),Rx=Pe({},Ei,{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}),Lx=wt(Rx),Ox=[9,13,27,32],Qo=on&&"CompositionEvent"in window,Ns=null;on&&"documentMode"in document&&(Ns=document.documentMode);var Dx=on&&"TextEvent"in window&&!Ns,up=on&&(!Qo||Ns&&8<Ns&&11>=Ns),dd=" ",ud=!1;function pp(e,t){switch(e){case"keyup":return Ox.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function fp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Sl=!1;function Nx(e,t){switch(e){case"compositionend":return fp(t);case"keypress":return t.which!==32?null:(ud=!0,dd);case"textInput":return e=t.data,e===dd&&ud?null:e;default:return null}}function Wx(e,t){if(Sl)return e==="compositionend"||!Qo&&pp(e,t)?(e=dp(),Xr=Mo=Sn=null,Sl=!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 up&&t.locale!=="ko"?null:t.data;default:return null}}var Bx={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 pd(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Bx[e.type]:t==="textarea"}function hp(e,t,l,s){Ku(s),t=ui(t,"onChange"),0<t.length&&(l=new Ho("onChange","change",null,l,s),e.push({event:l,listeners:t}))}var Ws=null,qs=null;function $x(e){_p(e,0)}function Ai(e){var t=_l(e);if(Wu(t))return e}function Ux(e,t){if(e==="change")return t}var gp=!1;if(on){var da;if(on){var ua="oninput"in document;if(!ua){var fd=document.createElement("div");fd.setAttribute("oninput","return;"),ua=typeof fd.oninput=="function"}da=ua}else da=!1;gp=da&&(!document.documentMode||9<document.documentMode)}function hd(){Ws&&(Ws.detachEvent("onpropertychange",xp),qs=Ws=null)}function xp(e){if(e.propertyName==="value"&&Ai(qs)){var t=[];hp(t,qs,e,Wo(e)),Xu($x,t)}}function Fx(e,t,l){e==="focusin"?(hd(),Ws=t,qs=l,Ws.attachEvent("onpropertychange",xp)):e==="focusout"&&hd()}function Mx(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Ai(qs)}function Hx(e,t){if(e==="click")return Ai(t)}function Kx(e,t){if(e==="input"||e==="change")return Ai(t)}function Qx(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var $t=typeof Object.is=="function"?Object.is:Qx;function Js(e,t){if($t(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var l=Object.keys(e),s=Object.keys(t);if(l.length!==s.length)return!1;for(s=0;s<l.length;s++){var r=l[s];if(!Ra.call(t,r)||!$t(e[r],t[r]))return!1}return!0}function gd(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function xd(e,t){var l=gd(e);e=0;for(var s;l;){if(l.nodeType===3){if(s=e+l.textContent.length,e<=t&&s>=t)return{node:l,offset:t-e};e=s}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=gd(l)}}function mp(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?mp(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function yp(){for(var e=window,t=si();t instanceof e.HTMLIFrameElement;){try{var l=typeof t.contentWindow.location.href=="string"}catch{l=!1}if(l)e=t.contentWindow;else break;t=si(e.document)}return t}function Go(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 Gx(e){var t=yp(),l=e.focusedElem,s=e.selectionRange;if(t!==l&&l&&l.ownerDocument&&mp(l.ownerDocument.documentElement,l)){if(s!==null&&Go(l)){if(t=s.start,e=s.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 r=l.textContent.length,i=Math.min(s.start,r);s=s.end===void 0?i:Math.min(s.end,r),!e.extend&&i>s&&(r=s,s=i,i=r),r=xd(l,i);var a=xd(l,s);r&&a&&(e.rangeCount!==1||e.anchorNode!==r.node||e.anchorOffset!==r.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(r.node,r.offset),e.removeAllRanges(),i>s?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=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 Yx=on&&"documentMode"in document&&11>=document.documentMode,wl=null,Za=null,Bs=null,Va=!1;function md(e,t,l){var s=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Va||wl==null||wl!==si(s)||(s=wl,"selectionStart"in s&&Go(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),Bs&&Js(Bs,s)||(Bs=s,s=ui(Za,"onSelect"),0<s.length&&(t=new Ho("onSelect","select",null,t,l),e.push({event:t,listeners:s}),t.target=wl)))}function Pr(e,t){var l={};return l[e.toLowerCase()]=t.toLowerCase(),l["Webkit"+e]="webkit"+t,l["Moz"+e]="moz"+t,l}var kl={animationend:Pr("Animation","AnimationEnd"),animationiteration:Pr("Animation","AnimationIteration"),animationstart:Pr("Animation","AnimationStart"),transitionend:Pr("Transition","TransitionEnd")},pa={},vp={};on&&(vp=document.createElement("div").style,"AnimationEvent"in window||(delete kl.animationend.animation,delete kl.animationiteration.animation,delete kl.animationstart.animation),"TransitionEvent"in window||delete kl.transitionend.transition);function Ri(e){if(pa[e])return pa[e];if(!kl[e])return e;var t=kl[e],l;for(l in t)if(t.hasOwnProperty(l)&&l in vp)return pa[e]=t[l];return e}var jp=Ri("animationend"),bp=Ri("animationiteration"),Sp=Ri("animationstart"),wp=Ri("transitionend"),kp=new Map,yd="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 Dn(e,t){kp.set(e,t),tl(t,[e])}for(var fa=0;fa<yd.length;fa++){var ha=yd[fa],Xx=ha.toLowerCase(),qx=ha[0].toUpperCase()+ha.slice(1);Dn(Xx,"on"+qx)}Dn(jp,"onAnimationEnd");Dn(bp,"onAnimationIteration");Dn(Sp,"onAnimationStart");Dn("dblclick","onDoubleClick");Dn("focusin","onFocus");Dn("focusout","onBlur");Dn(wp,"onTransitionEnd");Bl("onMouseEnter",["mouseout","mouseover"]);Bl("onMouseLeave",["mouseout","mouseover"]);Bl("onPointerEnter",["pointerout","pointerover"]);Bl("onPointerLeave",["pointerout","pointerover"]);tl("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));tl("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));tl("onBeforeInput",["compositionend","keypress","textInput","paste"]);tl("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));tl("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));tl("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Rs="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(" "),Jx=new Set("cancel close invalid load scroll toggle".split(" ").concat(Rs));function vd(e,t,l){var s=e.type||"unknown-event";e.currentTarget=l,Xg(s,t,void 0,e),e.currentTarget=null}function _p(e,t){t=(t&4)!==0;for(var l=0;l<e.length;l++){var s=e[l],r=s.event;s=s.listeners;e:{var i=void 0;if(t)for(var a=s.length-1;0<=a;a--){var d=s[a],u=d.instance,f=d.currentTarget;if(d=d.listener,u!==i&&r.isPropagationStopped())break e;vd(r,d,f),i=u}else for(a=0;a<s.length;a++){if(d=s[a],u=d.instance,f=d.currentTarget,d=d.listener,u!==i&&r.isPropagationStopped())break e;vd(r,d,f),i=u}}}if(ii)throw e=Ya,ii=!1,Ya=null,e}function je(e,t){var l=t[so];l===void 0&&(l=t[so]=new Set);var s=e+"__bubble";l.has(s)||(Cp(t,e,2,!1),l.add(s))}function ga(e,t,l){var s=0;t&&(s|=4),Cp(l,e,s,t)}var Ir="_reactListening"+Math.random().toString(36).slice(2);function Zs(e){if(!e[Ir]){e[Ir]=!0,Ru.forEach(function(l){l!=="selectionchange"&&(Jx.has(l)||ga(l,!1,e),ga(l,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Ir]||(t[Ir]=!0,ga("selectionchange",!1,t))}}function Cp(e,t,l,s){switch(cp(t)){case 1:var r=ux;break;case 4:r=px;break;default:r=Fo}l=r.bind(null,t,l,e),r=void 0,!Ga||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(r=!0),s?r!==void 0?e.addEventListener(t,l,{capture:!0,passive:r}):e.addEventListener(t,l,!0):r!==void 0?e.addEventListener(t,l,{passive:r}):e.addEventListener(t,l,!1)}function xa(e,t,l,s,r){var i=s;if(!(t&1)&&!(t&2)&&s!==null)e:for(;;){if(s===null)return;var a=s.tag;if(a===3||a===4){var d=s.stateNode.containerInfo;if(d===r||d.nodeType===8&&d.parentNode===r)break;if(a===4)for(a=s.return;a!==null;){var u=a.tag;if((u===3||u===4)&&(u=a.stateNode.containerInfo,u===r||u.nodeType===8&&u.parentNode===r))return;a=a.return}for(;d!==null;){if(a=Hn(d),a===null)return;if(u=a.tag,u===5||u===6){s=i=a;continue e}d=d.parentNode}}s=s.return}Xu(function(){var f=i,y=Wo(l),p=[];e:{var c=kp.get(e);if(c!==void 0){var v=Ho,b=e;switch(e){case"keypress":if(qr(l)===0)break e;case"keydown":case"keyup":v=zx;break;case"focusin":b="focus",v=ca;break;case"focusout":b="blur",v=ca;break;case"beforeblur":case"afterblur":v=ca;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":v=ad;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":v=gx;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":v=Ix;break;case jp:case bp:case Sp:v=yx;break;case wp:v=Ax;break;case"scroll":v=fx;break;case"wheel":v=Lx;break;case"copy":case"cut":case"paste":v=jx;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":v=cd}var g=(t&4)!==0,S=!g&&e==="scroll",h=g?c!==null?c+"Capture":null:c;g=[];for(var m=f,o;m!==null;){o=m;var x=o.stateNode;if(o.tag===5&&x!==null&&(o=x,h!==null&&(x=Qs(m,h),x!=null&&g.push(Vs(m,x,o)))),S)break;m=m.return}0<g.length&&(c=new v(c,b,null,l,y),p.push({event:c,listeners:g}))}}if(!(t&7)){e:{if(c=e==="mouseover"||e==="pointerover",v=e==="mouseout"||e==="pointerout",c&&l!==Ka&&(b=l.relatedTarget||l.fromElement)&&(Hn(b)||b[cn]))break e;if((v||c)&&(c=y.window===y?y:(c=y.ownerDocument)?c.defaultView||c.parentWindow:window,v?(b=l.relatedTarget||l.toElement,v=f,b=b?Hn(b):null,b!==null&&(S=nl(b),b!==S||b.tag!==5&&b.tag!==6)&&(b=null)):(v=null,b=f),v!==b)){if(g=ad,x="onMouseLeave",h="onMouseEnter",m="mouse",(e==="pointerout"||e==="pointerover")&&(g=cd,x="onPointerLeave",h="onPointerEnter",m="pointer"),S=v==null?c:_l(v),o=b==null?c:_l(b),c=new g(x,m+"leave",v,l,y),c.target=S,c.relatedTarget=o,x=null,Hn(y)===f&&(g=new g(h,m+"enter",b,l,y),g.target=o,g.relatedTarget=S,x=g),S=x,v&&b)t:{for(g=v,h=b,m=0,o=g;o;o=fl(o))m++;for(o=0,x=h;x;x=fl(x))o++;for(;0<m-o;)g=fl(g),m--;for(;0<o-m;)h=fl(h),o--;for(;m--;){if(g===h||h!==null&&g===h.alternate)break t;g=fl(g),h=fl(h)}g=null}else g=null;v!==null&&jd(p,c,v,g,!1),b!==null&&S!==null&&jd(p,S,b,g,!0)}}e:{if(c=f?_l(f):window,v=c.nodeName&&c.nodeName.toLowerCase(),v==="select"||v==="input"&&c.type==="file")var C=Ux;else if(pd(c))if(gp)C=Kx;else{C=Mx;var A=Fx}else(v=c.nodeName)&&v.toLowerCase()==="input"&&(c.type==="checkbox"||c.type==="radio")&&(C=Hx);if(C&&(C=C(e,f))){hp(p,C,l,y);break e}A&&A(e,c,f),e==="focusout"&&(A=c._wrapperState)&&A.controlled&&c.type==="number"&&$a(c,"number",c.value)}switch(A=f?_l(f):window,e){case"focusin":(pd(A)||A.contentEditable==="true")&&(wl=A,Za=f,Bs=null);break;case"focusout":Bs=Za=wl=null;break;case"mousedown":Va=!0;break;case"contextmenu":case"mouseup":case"dragend":Va=!1,md(p,l,y);break;case"selectionchange":if(Yx)break;case"keydown":case"keyup":md(p,l,y)}var T;if(Qo)e:{switch(e){case"compositionstart":var w="onCompositionStart";break e;case"compositionend":w="onCompositionEnd";break e;case"compositionupdate":w="onCompositionUpdate";break e}w=void 0}else Sl?pp(e,l)&&(w="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(w="onCompositionStart");w&&(up&&l.locale!=="ko"&&(Sl||w!=="onCompositionStart"?w==="onCompositionEnd"&&Sl&&(T=dp()):(Sn=y,Mo="value"in Sn?Sn.value:Sn.textContent,Sl=!0)),A=ui(f,w),0<A.length&&(w=new od(w,e,null,l,y),p.push({event:w,listeners:A}),T?w.data=T:(T=fp(l),T!==null&&(w.data=T)))),(T=Dx?Nx(e,l):Wx(e,l))&&(f=ui(f,"onBeforeInput"),0<f.length&&(y=new od("onBeforeInput","beforeinput",null,l,y),p.push({event:y,listeners:f}),y.data=T))}_p(p,t)})}function Vs(e,t,l){return{instance:e,listener:t,currentTarget:l}}function ui(e,t){for(var l=t+"Capture",s=[];e!==null;){var r=e,i=r.stateNode;r.tag===5&&i!==null&&(r=i,i=Qs(e,l),i!=null&&s.unshift(Vs(e,i,r)),i=Qs(e,t),i!=null&&s.push(Vs(e,i,r))),e=e.return}return s}function fl(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function jd(e,t,l,s,r){for(var i=t._reactName,a=[];l!==null&&l!==s;){var d=l,u=d.alternate,f=d.stateNode;if(u!==null&&u===s)break;d.tag===5&&f!==null&&(d=f,r?(u=Qs(l,i),u!=null&&a.unshift(Vs(l,u,d))):r||(u=Qs(l,i),u!=null&&a.push(Vs(l,u,d)))),l=l.return}a.length!==0&&e.push({event:t,listeners:a})}var Zx=/\r\n?/g,Vx=/\u0000|\uFFFD/g;function bd(e){return(typeof e=="string"?e:""+e).replace(Zx,`
|
||
`).replace(Vx,"")}function Er(e,t,l){if(t=bd(t),bd(e)!==t&&l)throw Error(F(425))}function pi(){}var eo=null,to=null;function no(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 lo=typeof setTimeout=="function"?setTimeout:void 0,em=typeof clearTimeout=="function"?clearTimeout:void 0,Sd=typeof Promise=="function"?Promise:void 0,tm=typeof queueMicrotask=="function"?queueMicrotask:typeof Sd<"u"?function(e){return Sd.resolve(null).then(e).catch(nm)}:lo;function nm(e){setTimeout(function(){throw e})}function ma(e,t){var l=t,s=0;do{var r=l.nextSibling;if(e.removeChild(l),r&&r.nodeType===8)if(l=r.data,l==="/$"){if(s===0){e.removeChild(r),Xs(t);return}s--}else l!=="$"&&l!=="$?"&&l!=="$!"||s++;l=r}while(l);Xs(t)}function Tn(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 wd(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 ql=Math.random().toString(36).slice(2),Kt="__reactFiber$"+ql,er="__reactProps$"+ql,cn="__reactContainer$"+ql,so="__reactEvents$"+ql,lm="__reactListeners$"+ql,sm="__reactHandles$"+ql;function Hn(e){var t=e[Kt];if(t)return t;for(var l=e.parentNode;l;){if(t=l[cn]||l[Kt]){if(l=t.alternate,t.child!==null||l!==null&&l.child!==null)for(e=wd(e);e!==null;){if(l=e[Kt])return l;e=wd(e)}return t}e=l,l=e.parentNode}return null}function dr(e){return e=e[Kt]||e[cn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function _l(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(F(33))}function Li(e){return e[er]||null}var ro=[],Cl=-1;function Nn(e){return{current:e}}function be(e){0>Cl||(e.current=ro[Cl],ro[Cl]=null,Cl--)}function ve(e,t){Cl++,ro[Cl]=e.current,e.current=t}var Ln={},st=Nn(Ln),pt=Nn(!1),Xn=Ln;function $l(e,t){var l=e.type.contextTypes;if(!l)return Ln;var s=e.stateNode;if(s&&s.__reactInternalMemoizedUnmaskedChildContext===t)return s.__reactInternalMemoizedMaskedChildContext;var r={},i;for(i in l)r[i]=t[i];return s&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=r),r}function ft(e){return e=e.childContextTypes,e!=null}function fi(){be(pt),be(st)}function kd(e,t,l){if(st.current!==Ln)throw Error(F(168));ve(st,t),ve(pt,l)}function zp(e,t,l){var s=e.stateNode;if(t=t.childContextTypes,typeof s.getChildContext!="function")return l;s=s.getChildContext();for(var r in s)if(!(r in t))throw Error(F(108,Fg(e)||"Unknown",r));return Pe({},l,s)}function hi(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ln,Xn=st.current,ve(st,e),ve(pt,pt.current),!0}function _d(e,t,l){var s=e.stateNode;if(!s)throw Error(F(169));l?(e=zp(e,t,Xn),s.__reactInternalMemoizedMergedChildContext=e,be(pt),be(st),ve(st,e)):be(pt),ve(pt,l)}var ln=null,Oi=!1,ya=!1;function Tp(e){ln===null?ln=[e]:ln.push(e)}function rm(e){Oi=!0,Tp(e)}function Wn(){if(!ya&&ln!==null){ya=!0;var e=0,t=he;try{var l=ln;for(he=1;e<l.length;e++){var s=l[e];do s=s(!0);while(s!==null)}ln=null,Oi=!1}catch(r){throw ln!==null&&(ln=ln.slice(e+1)),Vu(Bo,Wn),r}finally{he=t,ya=!1}}return null}var zl=[],Tl=0,gi=null,xi=0,_t=[],Ct=0,qn=null,sn=1,rn="";function Fn(e,t){zl[Tl++]=xi,zl[Tl++]=gi,gi=e,xi=t}function Pp(e,t,l){_t[Ct++]=sn,_t[Ct++]=rn,_t[Ct++]=qn,qn=e;var s=sn;e=rn;var r=32-Wt(s)-1;s&=~(1<<r),l+=1;var i=32-Wt(t)+r;if(30<i){var a=r-r%5;i=(s&(1<<a)-1).toString(32),s>>=a,r-=a,sn=1<<32-Wt(t)+r|l<<r|s,rn=i+e}else sn=1<<i|l<<r|s,rn=e}function Yo(e){e.return!==null&&(Fn(e,1),Pp(e,1,0))}function Xo(e){for(;e===gi;)gi=zl[--Tl],zl[Tl]=null,xi=zl[--Tl],zl[Tl]=null;for(;e===qn;)qn=_t[--Ct],_t[Ct]=null,rn=_t[--Ct],_t[Ct]=null,sn=_t[--Ct],_t[Ct]=null}var jt=null,vt=null,ke=!1,Dt=null;function Ip(e,t){var l=zt(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 Cd(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,jt=e,vt=Tn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,jt=e,vt=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(l=qn!==null?{id:sn,overflow:rn}:null,e.memoizedState={dehydrated:t,treeContext:l,retryLane:1073741824},l=zt(18,null,null,0),l.stateNode=t,l.return=e,e.child=l,jt=e,vt=null,!0):!1;default:return!1}}function io(e){return(e.mode&1)!==0&&(e.flags&128)===0}function ao(e){if(ke){var t=vt;if(t){var l=t;if(!Cd(e,t)){if(io(e))throw Error(F(418));t=Tn(l.nextSibling);var s=jt;t&&Cd(e,t)?Ip(s,l):(e.flags=e.flags&-4097|2,ke=!1,jt=e)}}else{if(io(e))throw Error(F(418));e.flags=e.flags&-4097|2,ke=!1,jt=e}}}function zd(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;jt=e}function Ar(e){if(e!==jt)return!1;if(!ke)return zd(e),ke=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!no(e.type,e.memoizedProps)),t&&(t=vt)){if(io(e))throw Ep(),Error(F(418));for(;t;)Ip(e,t),t=Tn(t.nextSibling)}if(zd(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(F(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var l=e.data;if(l==="/$"){if(t===0){vt=Tn(e.nextSibling);break e}t--}else l!=="$"&&l!=="$!"&&l!=="$?"||t++}e=e.nextSibling}vt=null}}else vt=jt?Tn(e.stateNode.nextSibling):null;return!0}function Ep(){for(var e=vt;e;)e=Tn(e.nextSibling)}function Ul(){vt=jt=null,ke=!1}function qo(e){Dt===null?Dt=[e]:Dt.push(e)}var im=pn.ReactCurrentBatchConfig;function ps(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(F(309));var s=l.stateNode}if(!s)throw Error(F(147,e));var r=s,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(a){var d=r.refs;a===null?delete d[i]:d[i]=a},t._stringRef=i,t)}if(typeof e!="string")throw Error(F(284));if(!l._owner)throw Error(F(290,e))}return e}function Rr(e,t){throw e=Object.prototype.toString.call(t),Error(F(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Td(e){var t=e._init;return t(e._payload)}function Ap(e){function t(h,m){if(e){var o=h.deletions;o===null?(h.deletions=[m],h.flags|=16):o.push(m)}}function l(h,m){if(!e)return null;for(;m!==null;)t(h,m),m=m.sibling;return null}function s(h,m){for(h=new Map;m!==null;)m.key!==null?h.set(m.key,m):h.set(m.index,m),m=m.sibling;return h}function r(h,m){return h=An(h,m),h.index=0,h.sibling=null,h}function i(h,m,o){return h.index=o,e?(o=h.alternate,o!==null?(o=o.index,o<m?(h.flags|=2,m):o):(h.flags|=2,m)):(h.flags|=1048576,m)}function a(h){return e&&h.alternate===null&&(h.flags|=2),h}function d(h,m,o,x){return m===null||m.tag!==6?(m=_a(o,h.mode,x),m.return=h,m):(m=r(m,o),m.return=h,m)}function u(h,m,o,x){var C=o.type;return C===bl?y(h,m,o.props.children,x,o.key):m!==null&&(m.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===yn&&Td(C)===m.type)?(x=r(m,o.props),x.ref=ps(h,m,o),x.return=h,x):(x=li(o.type,o.key,o.props,null,h.mode,x),x.ref=ps(h,m,o),x.return=h,x)}function f(h,m,o,x){return m===null||m.tag!==4||m.stateNode.containerInfo!==o.containerInfo||m.stateNode.implementation!==o.implementation?(m=Ca(o,h.mode,x),m.return=h,m):(m=r(m,o.children||[]),m.return=h,m)}function y(h,m,o,x,C){return m===null||m.tag!==7?(m=Yn(o,h.mode,x,C),m.return=h,m):(m=r(m,o),m.return=h,m)}function p(h,m,o){if(typeof m=="string"&&m!==""||typeof m=="number")return m=_a(""+m,h.mode,o),m.return=h,m;if(typeof m=="object"&&m!==null){switch(m.$$typeof){case Sr:return o=li(m.type,m.key,m.props,null,h.mode,o),o.ref=ps(h,null,m),o.return=h,o;case jl:return m=Ca(m,h.mode,o),m.return=h,m;case yn:var x=m._init;return p(h,x(m._payload),o)}if(Es(m)||as(m))return m=Yn(m,h.mode,o,null),m.return=h,m;Rr(h,m)}return null}function c(h,m,o,x){var C=m!==null?m.key:null;if(typeof o=="string"&&o!==""||typeof o=="number")return C!==null?null:d(h,m,""+o,x);if(typeof o=="object"&&o!==null){switch(o.$$typeof){case Sr:return o.key===C?u(h,m,o,x):null;case jl:return o.key===C?f(h,m,o,x):null;case yn:return C=o._init,c(h,m,C(o._payload),x)}if(Es(o)||as(o))return C!==null?null:y(h,m,o,x,null);Rr(h,o)}return null}function v(h,m,o,x,C){if(typeof x=="string"&&x!==""||typeof x=="number")return h=h.get(o)||null,d(m,h,""+x,C);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Sr:return h=h.get(x.key===null?o:x.key)||null,u(m,h,x,C);case jl:return h=h.get(x.key===null?o:x.key)||null,f(m,h,x,C);case yn:var A=x._init;return v(h,m,o,A(x._payload),C)}if(Es(x)||as(x))return h=h.get(o)||null,y(m,h,x,C,null);Rr(m,x)}return null}function b(h,m,o,x){for(var C=null,A=null,T=m,w=m=0,_=null;T!==null&&w<o.length;w++){T.index>w?(_=T,T=null):_=T.sibling;var U=c(h,T,o[w],x);if(U===null){T===null&&(T=_);break}e&&T&&U.alternate===null&&t(h,T),m=i(U,m,w),A===null?C=U:A.sibling=U,A=U,T=_}if(w===o.length)return l(h,T),ke&&Fn(h,w),C;if(T===null){for(;w<o.length;w++)T=p(h,o[w],x),T!==null&&(m=i(T,m,w),A===null?C=T:A.sibling=T,A=T);return ke&&Fn(h,w),C}for(T=s(h,T);w<o.length;w++)_=v(T,h,w,o[w],x),_!==null&&(e&&_.alternate!==null&&T.delete(_.key===null?w:_.key),m=i(_,m,w),A===null?C=_:A.sibling=_,A=_);return e&&T.forEach(function(P){return t(h,P)}),ke&&Fn(h,w),C}function g(h,m,o,x){var C=as(o);if(typeof C!="function")throw Error(F(150));if(o=C.call(o),o==null)throw Error(F(151));for(var A=C=null,T=m,w=m=0,_=null,U=o.next();T!==null&&!U.done;w++,U=o.next()){T.index>w?(_=T,T=null):_=T.sibling;var P=c(h,T,U.value,x);if(P===null){T===null&&(T=_);break}e&&T&&P.alternate===null&&t(h,T),m=i(P,m,w),A===null?C=P:A.sibling=P,A=P,T=_}if(U.done)return l(h,T),ke&&Fn(h,w),C;if(T===null){for(;!U.done;w++,U=o.next())U=p(h,U.value,x),U!==null&&(m=i(U,m,w),A===null?C=U:A.sibling=U,A=U);return ke&&Fn(h,w),C}for(T=s(h,T);!U.done;w++,U=o.next())U=v(T,h,w,U.value,x),U!==null&&(e&&U.alternate!==null&&T.delete(U.key===null?w:U.key),m=i(U,m,w),A===null?C=U:A.sibling=U,A=U);return e&&T.forEach(function(I){return t(h,I)}),ke&&Fn(h,w),C}function S(h,m,o,x){if(typeof o=="object"&&o!==null&&o.type===bl&&o.key===null&&(o=o.props.children),typeof o=="object"&&o!==null){switch(o.$$typeof){case Sr:e:{for(var C=o.key,A=m;A!==null;){if(A.key===C){if(C=o.type,C===bl){if(A.tag===7){l(h,A.sibling),m=r(A,o.props.children),m.return=h,h=m;break e}}else if(A.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===yn&&Td(C)===A.type){l(h,A.sibling),m=r(A,o.props),m.ref=ps(h,A,o),m.return=h,h=m;break e}l(h,A);break}else t(h,A);A=A.sibling}o.type===bl?(m=Yn(o.props.children,h.mode,x,o.key),m.return=h,h=m):(x=li(o.type,o.key,o.props,null,h.mode,x),x.ref=ps(h,m,o),x.return=h,h=x)}return a(h);case jl:e:{for(A=o.key;m!==null;){if(m.key===A)if(m.tag===4&&m.stateNode.containerInfo===o.containerInfo&&m.stateNode.implementation===o.implementation){l(h,m.sibling),m=r(m,o.children||[]),m.return=h,h=m;break e}else{l(h,m);break}else t(h,m);m=m.sibling}m=Ca(o,h.mode,x),m.return=h,h=m}return a(h);case yn:return A=o._init,S(h,m,A(o._payload),x)}if(Es(o))return b(h,m,o,x);if(as(o))return g(h,m,o,x);Rr(h,o)}return typeof o=="string"&&o!==""||typeof o=="number"?(o=""+o,m!==null&&m.tag===6?(l(h,m.sibling),m=r(m,o),m.return=h,h=m):(l(h,m),m=_a(o,h.mode,x),m.return=h,h=m),a(h)):l(h,m)}return S}var Fl=Ap(!0),Rp=Ap(!1),mi=Nn(null),yi=null,Pl=null,Jo=null;function Zo(){Jo=Pl=yi=null}function Vo(e){var t=mi.current;be(mi),e._currentValue=t}function oo(e,t,l){for(;e!==null;){var s=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,s!==null&&(s.childLanes|=t)):s!==null&&(s.childLanes&t)!==t&&(s.childLanes|=t),e===l)break;e=e.return}}function Nl(e,t){yi=e,Jo=Pl=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ut=!0),e.firstContext=null)}function Pt(e){var t=e._currentValue;if(Jo!==e)if(e={context:e,memoizedValue:t,next:null},Pl===null){if(yi===null)throw Error(F(308));Pl=e,yi.dependencies={lanes:0,firstContext:e}}else Pl=Pl.next=e;return t}var Kn=null;function ec(e){Kn===null?Kn=[e]:Kn.push(e)}function Lp(e,t,l,s){var r=t.interleaved;return r===null?(l.next=l,ec(t)):(l.next=r.next,r.next=l),t.interleaved=l,dn(e,s)}function dn(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 vn=!1;function tc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Op(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 an(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Pn(e,t,l){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,pe&2){var r=s.pending;return r===null?t.next=t:(t.next=r.next,r.next=t),s.pending=t,dn(e,l)}return r=s.interleaved,r===null?(t.next=t,ec(s)):(t.next=r.next,r.next=t),s.interleaved=t,dn(e,l)}function Jr(e,t,l){if(t=t.updateQueue,t!==null&&(t=t.shared,(l&4194240)!==0)){var s=t.lanes;s&=e.pendingLanes,l|=s,t.lanes=l,$o(e,l)}}function Pd(e,t){var l=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,l===s)){var r=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?r=i=a:i=i.next=a,l=l.next}while(l!==null);i===null?r=i=t:i=i.next=t}else r=i=t;l={baseState:s.baseState,firstBaseUpdate:r,lastBaseUpdate:i,shared:s.shared,effects:s.effects},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=t:e.next=t,l.lastBaseUpdate=t}function vi(e,t,l,s){var r=e.updateQueue;vn=!1;var i=r.firstBaseUpdate,a=r.lastBaseUpdate,d=r.shared.pending;if(d!==null){r.shared.pending=null;var u=d,f=u.next;u.next=null,a===null?i=f:a.next=f,a=u;var y=e.alternate;y!==null&&(y=y.updateQueue,d=y.lastBaseUpdate,d!==a&&(d===null?y.firstBaseUpdate=f:d.next=f,y.lastBaseUpdate=u))}if(i!==null){var p=r.baseState;a=0,y=f=u=null,d=i;do{var c=d.lane,v=d.eventTime;if((s&c)===c){y!==null&&(y=y.next={eventTime:v,lane:0,tag:d.tag,payload:d.payload,callback:d.callback,next:null});e:{var b=e,g=d;switch(c=t,v=l,g.tag){case 1:if(b=g.payload,typeof b=="function"){p=b.call(v,p,c);break e}p=b;break e;case 3:b.flags=b.flags&-65537|128;case 0:if(b=g.payload,c=typeof b=="function"?b.call(v,p,c):b,c==null)break e;p=Pe({},p,c);break e;case 2:vn=!0}}d.callback!==null&&d.lane!==0&&(e.flags|=64,c=r.effects,c===null?r.effects=[d]:c.push(d))}else v={eventTime:v,lane:c,tag:d.tag,payload:d.payload,callback:d.callback,next:null},y===null?(f=y=v,u=p):y=y.next=v,a|=c;if(d=d.next,d===null){if(d=r.shared.pending,d===null)break;c=d,d=c.next,c.next=null,r.lastBaseUpdate=c,r.shared.pending=null}}while(!0);if(y===null&&(u=p),r.baseState=u,r.firstBaseUpdate=f,r.lastBaseUpdate=y,t=r.shared.interleaved,t!==null){r=t;do a|=r.lane,r=r.next;while(r!==t)}else i===null&&(r.shared.lanes=0);Zn|=a,e.lanes=a,e.memoizedState=p}}function Id(e,t,l){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var s=e[t],r=s.callback;if(r!==null){if(s.callback=null,s=l,typeof r!="function")throw Error(F(191,r));r.call(s)}}}var ur={},Gt=Nn(ur),tr=Nn(ur),nr=Nn(ur);function Qn(e){if(e===ur)throw Error(F(174));return e}function nc(e,t){switch(ve(nr,t),ve(tr,e),ve(Gt,ur),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Fa(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Fa(t,e)}be(Gt),ve(Gt,t)}function Ml(){be(Gt),be(tr),be(nr)}function Dp(e){Qn(nr.current);var t=Qn(Gt.current),l=Fa(t,e.type);t!==l&&(ve(tr,e),ve(Gt,l))}function lc(e){tr.current===e&&(be(Gt),be(tr))}var ze=Nn(0);function ji(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 va=[];function sc(){for(var e=0;e<va.length;e++)va[e]._workInProgressVersionPrimary=null;va.length=0}var Zr=pn.ReactCurrentDispatcher,ja=pn.ReactCurrentBatchConfig,Jn=0,Te=null,Ke=null,Xe=null,bi=!1,$s=!1,lr=0,am=0;function tt(){throw Error(F(321))}function rc(e,t){if(t===null)return!1;for(var l=0;l<t.length&&l<e.length;l++)if(!$t(e[l],t[l]))return!1;return!0}function ic(e,t,l,s,r,i){if(Jn=i,Te=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Zr.current=e===null||e.memoizedState===null?um:pm,e=l(s,r),$s){i=0;do{if($s=!1,lr=0,25<=i)throw Error(F(301));i+=1,Xe=Ke=null,t.updateQueue=null,Zr.current=fm,e=l(s,r)}while($s)}if(Zr.current=Si,t=Ke!==null&&Ke.next!==null,Jn=0,Xe=Ke=Te=null,bi=!1,t)throw Error(F(300));return e}function ac(){var e=lr!==0;return lr=0,e}function Ht(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Xe===null?Te.memoizedState=Xe=e:Xe=Xe.next=e,Xe}function It(){if(Ke===null){var e=Te.alternate;e=e!==null?e.memoizedState:null}else e=Ke.next;var t=Xe===null?Te.memoizedState:Xe.next;if(t!==null)Xe=t,Ke=e;else{if(e===null)throw Error(F(310));Ke=e,e={memoizedState:Ke.memoizedState,baseState:Ke.baseState,baseQueue:Ke.baseQueue,queue:Ke.queue,next:null},Xe===null?Te.memoizedState=Xe=e:Xe=Xe.next=e}return Xe}function sr(e,t){return typeof t=="function"?t(e):t}function ba(e){var t=It(),l=t.queue;if(l===null)throw Error(F(311));l.lastRenderedReducer=e;var s=Ke,r=s.baseQueue,i=l.pending;if(i!==null){if(r!==null){var a=r.next;r.next=i.next,i.next=a}s.baseQueue=r=i,l.pending=null}if(r!==null){i=r.next,s=s.baseState;var d=a=null,u=null,f=i;do{var y=f.lane;if((Jn&y)===y)u!==null&&(u=u.next={lane:0,action:f.action,hasEagerState:f.hasEagerState,eagerState:f.eagerState,next:null}),s=f.hasEagerState?f.eagerState:e(s,f.action);else{var p={lane:y,action:f.action,hasEagerState:f.hasEagerState,eagerState:f.eagerState,next:null};u===null?(d=u=p,a=s):u=u.next=p,Te.lanes|=y,Zn|=y}f=f.next}while(f!==null&&f!==i);u===null?a=s:u.next=d,$t(s,t.memoizedState)||(ut=!0),t.memoizedState=s,t.baseState=a,t.baseQueue=u,l.lastRenderedState=s}if(e=l.interleaved,e!==null){r=e;do i=r.lane,Te.lanes|=i,Zn|=i,r=r.next;while(r!==e)}else r===null&&(l.lanes=0);return[t.memoizedState,l.dispatch]}function Sa(e){var t=It(),l=t.queue;if(l===null)throw Error(F(311));l.lastRenderedReducer=e;var s=l.dispatch,r=l.pending,i=t.memoizedState;if(r!==null){l.pending=null;var a=r=r.next;do i=e(i,a.action),a=a.next;while(a!==r);$t(i,t.memoizedState)||(ut=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),l.lastRenderedState=i}return[i,s]}function Np(){}function Wp(e,t){var l=Te,s=It(),r=t(),i=!$t(s.memoizedState,r);if(i&&(s.memoizedState=r,ut=!0),s=s.queue,oc(Up.bind(null,l,s,e),[e]),s.getSnapshot!==t||i||Xe!==null&&Xe.memoizedState.tag&1){if(l.flags|=2048,rr(9,$p.bind(null,l,s,r,t),void 0,null),qe===null)throw Error(F(349));Jn&30||Bp(l,t,r)}return r}function Bp(e,t,l){e.flags|=16384,e={getSnapshot:t,value:l},t=Te.updateQueue,t===null?(t={lastEffect:null,stores:null},Te.updateQueue=t,t.stores=[e]):(l=t.stores,l===null?t.stores=[e]:l.push(e))}function $p(e,t,l,s){t.value=l,t.getSnapshot=s,Fp(t)&&Mp(e)}function Up(e,t,l){return l(function(){Fp(t)&&Mp(e)})}function Fp(e){var t=e.getSnapshot;e=e.value;try{var l=t();return!$t(e,l)}catch{return!0}}function Mp(e){var t=dn(e,1);t!==null&&Bt(t,e,1,-1)}function Ed(e){var t=Ht();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:sr,lastRenderedState:e},t.queue=e,e=e.dispatch=dm.bind(null,Te,e),[t.memoizedState,e]}function rr(e,t,l,s){return e={tag:e,create:t,destroy:l,deps:s,next:null},t=Te.updateQueue,t===null?(t={lastEffect:null,stores:null},Te.updateQueue=t,t.lastEffect=e.next=e):(l=t.lastEffect,l===null?t.lastEffect=e.next=e:(s=l.next,l.next=e,e.next=s,t.lastEffect=e)),e}function Hp(){return It().memoizedState}function Vr(e,t,l,s){var r=Ht();Te.flags|=e,r.memoizedState=rr(1|t,l,void 0,s===void 0?null:s)}function Di(e,t,l,s){var r=It();s=s===void 0?null:s;var i=void 0;if(Ke!==null){var a=Ke.memoizedState;if(i=a.destroy,s!==null&&rc(s,a.deps)){r.memoizedState=rr(t,l,i,s);return}}Te.flags|=e,r.memoizedState=rr(1|t,l,i,s)}function Ad(e,t){return Vr(8390656,8,e,t)}function oc(e,t){return Di(2048,8,e,t)}function Kp(e,t){return Di(4,2,e,t)}function Qp(e,t){return Di(4,4,e,t)}function Gp(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 Yp(e,t,l){return l=l!=null?l.concat([e]):null,Di(4,4,Gp.bind(null,t,e),l)}function cc(){}function Xp(e,t){var l=It();t=t===void 0?null:t;var s=l.memoizedState;return s!==null&&t!==null&&rc(t,s[1])?s[0]:(l.memoizedState=[e,t],e)}function qp(e,t){var l=It();t=t===void 0?null:t;var s=l.memoizedState;return s!==null&&t!==null&&rc(t,s[1])?s[0]:(e=e(),l.memoizedState=[e,t],e)}function Jp(e,t,l){return Jn&21?($t(l,t)||(l=np(),Te.lanes|=l,Zn|=l,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ut=!0),e.memoizedState=l)}function om(e,t){var l=he;he=l!==0&&4>l?l:4,e(!0);var s=ja.transition;ja.transition={};try{e(!1),t()}finally{he=l,ja.transition=s}}function Zp(){return It().memoizedState}function cm(e,t,l){var s=En(e);if(l={lane:s,action:l,hasEagerState:!1,eagerState:null,next:null},Vp(e))ef(t,l);else if(l=Lp(e,t,l,s),l!==null){var r=it();Bt(l,e,s,r),tf(l,t,s)}}function dm(e,t,l){var s=En(e),r={lane:s,action:l,hasEagerState:!1,eagerState:null,next:null};if(Vp(e))ef(t,r);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(r.hasEagerState=!0,r.eagerState=d,$t(d,a)){var u=t.interleaved;u===null?(r.next=r,ec(t)):(r.next=u.next,u.next=r),t.interleaved=r;return}}catch{}finally{}l=Lp(e,t,r,s),l!==null&&(r=it(),Bt(l,e,s,r),tf(l,t,s))}}function Vp(e){var t=e.alternate;return e===Te||t!==null&&t===Te}function ef(e,t){$s=bi=!0;var l=e.pending;l===null?t.next=t:(t.next=l.next,l.next=t),e.pending=t}function tf(e,t,l){if(l&4194240){var s=t.lanes;s&=e.pendingLanes,l|=s,t.lanes=l,$o(e,l)}}var Si={readContext:Pt,useCallback:tt,useContext:tt,useEffect:tt,useImperativeHandle:tt,useInsertionEffect:tt,useLayoutEffect:tt,useMemo:tt,useReducer:tt,useRef:tt,useState:tt,useDebugValue:tt,useDeferredValue:tt,useTransition:tt,useMutableSource:tt,useSyncExternalStore:tt,useId:tt,unstable_isNewReconciler:!1},um={readContext:Pt,useCallback:function(e,t){return Ht().memoizedState=[e,t===void 0?null:t],e},useContext:Pt,useEffect:Ad,useImperativeHandle:function(e,t,l){return l=l!=null?l.concat([e]):null,Vr(4194308,4,Gp.bind(null,t,e),l)},useLayoutEffect:function(e,t){return Vr(4194308,4,e,t)},useInsertionEffect:function(e,t){return Vr(4,2,e,t)},useMemo:function(e,t){var l=Ht();return t=t===void 0?null:t,e=e(),l.memoizedState=[e,t],e},useReducer:function(e,t,l){var s=Ht();return t=l!==void 0?l(t):t,s.memoizedState=s.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},s.queue=e,e=e.dispatch=cm.bind(null,Te,e),[s.memoizedState,e]},useRef:function(e){var t=Ht();return e={current:e},t.memoizedState=e},useState:Ed,useDebugValue:cc,useDeferredValue:function(e){return Ht().memoizedState=e},useTransition:function(){var e=Ed(!1),t=e[0];return e=om.bind(null,e[1]),Ht().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,l){var s=Te,r=Ht();if(ke){if(l===void 0)throw Error(F(407));l=l()}else{if(l=t(),qe===null)throw Error(F(349));Jn&30||Bp(s,t,l)}r.memoizedState=l;var i={value:l,getSnapshot:t};return r.queue=i,Ad(Up.bind(null,s,i,e),[e]),s.flags|=2048,rr(9,$p.bind(null,s,i,l,t),void 0,null),l},useId:function(){var e=Ht(),t=qe.identifierPrefix;if(ke){var l=rn,s=sn;l=(s&~(1<<32-Wt(s)-1)).toString(32)+l,t=":"+t+"R"+l,l=lr++,0<l&&(t+="H"+l.toString(32)),t+=":"}else l=am++,t=":"+t+"r"+l.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},pm={readContext:Pt,useCallback:Xp,useContext:Pt,useEffect:oc,useImperativeHandle:Yp,useInsertionEffect:Kp,useLayoutEffect:Qp,useMemo:qp,useReducer:ba,useRef:Hp,useState:function(){return ba(sr)},useDebugValue:cc,useDeferredValue:function(e){var t=It();return Jp(t,Ke.memoizedState,e)},useTransition:function(){var e=ba(sr)[0],t=It().memoizedState;return[e,t]},useMutableSource:Np,useSyncExternalStore:Wp,useId:Zp,unstable_isNewReconciler:!1},fm={readContext:Pt,useCallback:Xp,useContext:Pt,useEffect:oc,useImperativeHandle:Yp,useInsertionEffect:Kp,useLayoutEffect:Qp,useMemo:qp,useReducer:Sa,useRef:Hp,useState:function(){return Sa(sr)},useDebugValue:cc,useDeferredValue:function(e){var t=It();return Ke===null?t.memoizedState=e:Jp(t,Ke.memoizedState,e)},useTransition:function(){var e=Sa(sr)[0],t=It().memoizedState;return[e,t]},useMutableSource:Np,useSyncExternalStore:Wp,useId:Zp,unstable_isNewReconciler:!1};function Lt(e,t){if(e&&e.defaultProps){t=Pe({},t),e=e.defaultProps;for(var l in e)t[l]===void 0&&(t[l]=e[l]);return t}return t}function co(e,t,l,s){t=e.memoizedState,l=l(s,t),l=l==null?t:Pe({},t,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var Ni={isMounted:function(e){return(e=e._reactInternals)?nl(e)===e:!1},enqueueSetState:function(e,t,l){e=e._reactInternals;var s=it(),r=En(e),i=an(s,r);i.payload=t,l!=null&&(i.callback=l),t=Pn(e,i,r),t!==null&&(Bt(t,e,r,s),Jr(t,e,r))},enqueueReplaceState:function(e,t,l){e=e._reactInternals;var s=it(),r=En(e),i=an(s,r);i.tag=1,i.payload=t,l!=null&&(i.callback=l),t=Pn(e,i,r),t!==null&&(Bt(t,e,r,s),Jr(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var l=it(),s=En(e),r=an(l,s);r.tag=2,t!=null&&(r.callback=t),t=Pn(e,r,s),t!==null&&(Bt(t,e,s,l),Jr(t,e,s))}};function Rd(e,t,l,s,r,i,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(s,i,a):t.prototype&&t.prototype.isPureReactComponent?!Js(l,s)||!Js(r,i):!0}function nf(e,t,l){var s=!1,r=Ln,i=t.contextType;return typeof i=="object"&&i!==null?i=Pt(i):(r=ft(t)?Xn:st.current,s=t.contextTypes,i=(s=s!=null)?$l(e,r):Ln),t=new t(l,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ni,e.stateNode=t,t._reactInternals=e,s&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=r,e.__reactInternalMemoizedMaskedChildContext=i),t}function Ld(e,t,l,s){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(l,s),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(l,s),t.state!==e&&Ni.enqueueReplaceState(t,t.state,null)}function uo(e,t,l,s){var r=e.stateNode;r.props=l,r.state=e.memoizedState,r.refs={},tc(e);var i=t.contextType;typeof i=="object"&&i!==null?r.context=Pt(i):(i=ft(t)?Xn:st.current,r.context=$l(e,i)),r.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(co(e,t,i,l),r.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(t=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),t!==r.state&&Ni.enqueueReplaceState(r,r.state,null),vi(e,l,r,s),r.state=e.memoizedState),typeof r.componentDidMount=="function"&&(e.flags|=4194308)}function Hl(e,t){try{var l="",s=t;do l+=Ug(s),s=s.return;while(s);var r=l}catch(i){r=`
|
||
Error generating stack: `+i.message+`
|
||
`+i.stack}return{value:e,source:t,stack:r,digest:null}}function wa(e,t,l){return{value:e,source:null,stack:l??null,digest:t??null}}function po(e,t){try{console.error(t.value)}catch(l){setTimeout(function(){throw l})}}var hm=typeof WeakMap=="function"?WeakMap:Map;function lf(e,t,l){l=an(-1,l),l.tag=3,l.payload={element:null};var s=t.value;return l.callback=function(){ki||(ki=!0,So=s),po(e,t)},l}function sf(e,t,l){l=an(-1,l),l.tag=3;var s=e.type.getDerivedStateFromError;if(typeof s=="function"){var r=t.value;l.payload=function(){return s(r)},l.callback=function(){po(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(l.callback=function(){po(e,t),typeof s!="function"&&(In===null?In=new Set([this]):In.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),l}function Od(e,t,l){var s=e.pingCache;if(s===null){s=e.pingCache=new hm;var r=new Set;s.set(t,r)}else r=s.get(t),r===void 0&&(r=new Set,s.set(t,r));r.has(l)||(r.add(l),e=Tm.bind(null,e,t,l),t.then(e,e))}function Dd(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 Nd(e,t,l,s,r){return e.mode&1?(e.flags|=65536,e.lanes=r,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=an(-1,1),t.tag=2,Pn(l,t,1))),l.lanes|=1),e)}var gm=pn.ReactCurrentOwner,ut=!1;function rt(e,t,l,s){t.child=e===null?Rp(t,null,l,s):Fl(t,e.child,l,s)}function Wd(e,t,l,s,r){l=l.render;var i=t.ref;return Nl(t,r),s=ic(e,t,l,s,i,r),l=ac(),e!==null&&!ut?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~r,un(e,t,r)):(ke&&l&&Yo(t),t.flags|=1,rt(e,t,s,r),t.child)}function Bd(e,t,l,s,r){if(e===null){var i=l.type;return typeof i=="function"&&!mc(i)&&i.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(t.tag=15,t.type=i,rf(e,t,i,s,r)):(e=li(l.type,null,s,t,t.mode,r),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&r)){var a=i.memoizedProps;if(l=l.compare,l=l!==null?l:Js,l(a,s)&&e.ref===t.ref)return un(e,t,r)}return t.flags|=1,e=An(i,s),e.ref=t.ref,e.return=t,t.child=e}function rf(e,t,l,s,r){if(e!==null){var i=e.memoizedProps;if(Js(i,s)&&e.ref===t.ref)if(ut=!1,t.pendingProps=s=i,(e.lanes&r)!==0)e.flags&131072&&(ut=!0);else return t.lanes=e.lanes,un(e,t,r)}return fo(e,t,l,s,r)}function af(e,t,l){var s=t.pendingProps,r=s.children,i=e!==null?e.memoizedState:null;if(s.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},ve(El,yt),yt|=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,ve(El,yt),yt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},s=i!==null?i.baseLanes:l,ve(El,yt),yt|=s}else i!==null?(s=i.baseLanes|l,t.memoizedState=null):s=l,ve(El,yt),yt|=s;return rt(e,t,r,l),t.child}function of(e,t){var l=t.ref;(e===null&&l!==null||e!==null&&e.ref!==l)&&(t.flags|=512,t.flags|=2097152)}function fo(e,t,l,s,r){var i=ft(l)?Xn:st.current;return i=$l(t,i),Nl(t,r),l=ic(e,t,l,s,i,r),s=ac(),e!==null&&!ut?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~r,un(e,t,r)):(ke&&s&&Yo(t),t.flags|=1,rt(e,t,l,r),t.child)}function $d(e,t,l,s,r){if(ft(l)){var i=!0;hi(t)}else i=!1;if(Nl(t,r),t.stateNode===null)ei(e,t),nf(t,l,s),uo(t,l,s,r),s=!0;else if(e===null){var a=t.stateNode,d=t.memoizedProps;a.props=d;var u=a.context,f=l.contextType;typeof f=="object"&&f!==null?f=Pt(f):(f=ft(l)?Xn:st.current,f=$l(t,f));var y=l.getDerivedStateFromProps,p=typeof y=="function"||typeof a.getSnapshotBeforeUpdate=="function";p||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(d!==s||u!==f)&&Ld(t,a,s,f),vn=!1;var c=t.memoizedState;a.state=c,vi(t,s,a,r),u=t.memoizedState,d!==s||c!==u||pt.current||vn?(typeof y=="function"&&(co(t,l,y,s),u=t.memoizedState),(d=vn||Rd(t,l,d,s,c,u,f))?(p||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=s,t.memoizedState=u),a.props=s,a.state=u,a.context=f,s=d):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),s=!1)}else{a=t.stateNode,Op(e,t),d=t.memoizedProps,f=t.type===t.elementType?d:Lt(t.type,d),a.props=f,p=t.pendingProps,c=a.context,u=l.contextType,typeof u=="object"&&u!==null?u=Pt(u):(u=ft(l)?Xn:st.current,u=$l(t,u));var v=l.getDerivedStateFromProps;(y=typeof v=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(d!==p||c!==u)&&Ld(t,a,s,u),vn=!1,c=t.memoizedState,a.state=c,vi(t,s,a,r);var b=t.memoizedState;d!==p||c!==b||pt.current||vn?(typeof v=="function"&&(co(t,l,v,s),b=t.memoizedState),(f=vn||Rd(t,l,f,s,c,b,u)||!1)?(y||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(s,b,u),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(s,b,u)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||d===e.memoizedProps&&c===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||d===e.memoizedProps&&c===e.memoizedState||(t.flags|=1024),t.memoizedProps=s,t.memoizedState=b),a.props=s,a.state=b,a.context=u,s=f):(typeof a.componentDidUpdate!="function"||d===e.memoizedProps&&c===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||d===e.memoizedProps&&c===e.memoizedState||(t.flags|=1024),s=!1)}return ho(e,t,l,s,i,r)}function ho(e,t,l,s,r,i){of(e,t);var a=(t.flags&128)!==0;if(!s&&!a)return r&&_d(t,l,!1),un(e,t,i);s=t.stateNode,gm.current=t;var d=a&&typeof l.getDerivedStateFromError!="function"?null:s.render();return t.flags|=1,e!==null&&a?(t.child=Fl(t,e.child,null,i),t.child=Fl(t,null,d,i)):rt(e,t,d,i),t.memoizedState=s.state,r&&_d(t,l,!0),t.child}function cf(e){var t=e.stateNode;t.pendingContext?kd(e,t.pendingContext,t.pendingContext!==t.context):t.context&&kd(e,t.context,!1),nc(e,t.containerInfo)}function Ud(e,t,l,s,r){return Ul(),qo(r),t.flags|=256,rt(e,t,l,s),t.child}var go={dehydrated:null,treeContext:null,retryLane:0};function xo(e){return{baseLanes:e,cachePool:null,transitions:null}}function df(e,t,l){var s=t.pendingProps,r=ze.current,i=!1,a=(t.flags&128)!==0,d;if((d=a)||(d=e!==null&&e.memoizedState===null?!1:(r&2)!==0),d?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(r|=1),ve(ze,r&1),e===null)return ao(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(a=s.children,e=s.fallback,i?(s=t.mode,i=t.child,a={mode:"hidden",children:a},!(s&1)&&i!==null?(i.childLanes=0,i.pendingProps=a):i=$i(a,s,0,null),e=Yn(e,s,l,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=xo(l),t.memoizedState=go,e):dc(t,a));if(r=e.memoizedState,r!==null&&(d=r.dehydrated,d!==null))return xm(e,t,a,s,d,r,l);if(i){i=s.fallback,a=t.mode,r=e.child,d=r.sibling;var u={mode:"hidden",children:s.children};return!(a&1)&&t.child!==r?(s=t.child,s.childLanes=0,s.pendingProps=u,t.deletions=null):(s=An(r,u),s.subtreeFlags=r.subtreeFlags&14680064),d!==null?i=An(d,i):(i=Yn(i,a,l,null),i.flags|=2),i.return=t,s.return=t,s.sibling=i,t.child=s,s=i,i=t.child,a=e.child.memoizedState,a=a===null?xo(l):{baseLanes:a.baseLanes|l,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~l,t.memoizedState=go,s}return i=e.child,e=i.sibling,s=An(i,{mode:"visible",children:s.children}),!(t.mode&1)&&(s.lanes=l),s.return=t,s.sibling=null,e!==null&&(l=t.deletions,l===null?(t.deletions=[e],t.flags|=16):l.push(e)),t.child=s,t.memoizedState=null,s}function dc(e,t){return t=$i({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Lr(e,t,l,s){return s!==null&&qo(s),Fl(t,e.child,null,l),e=dc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function xm(e,t,l,s,r,i,a){if(l)return t.flags&256?(t.flags&=-257,s=wa(Error(F(422))),Lr(e,t,a,s)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=s.fallback,r=t.mode,s=$i({mode:"visible",children:s.children},r,0,null),i=Yn(i,r,a,null),i.flags|=2,s.return=t,i.return=t,s.sibling=i,t.child=s,t.mode&1&&Fl(t,e.child,null,a),t.child.memoizedState=xo(a),t.memoizedState=go,i);if(!(t.mode&1))return Lr(e,t,a,null);if(r.data==="$!"){if(s=r.nextSibling&&r.nextSibling.dataset,s)var d=s.dgst;return s=d,i=Error(F(419)),s=wa(i,s,void 0),Lr(e,t,a,s)}if(d=(a&e.childLanes)!==0,ut||d){if(s=qe,s!==null){switch(a&-a){case 4:r=2;break;case 16:r=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:r=32;break;case 536870912:r=268435456;break;default:r=0}r=r&(s.suspendedLanes|a)?0:r,r!==0&&r!==i.retryLane&&(i.retryLane=r,dn(e,r),Bt(s,e,r,-1))}return xc(),s=wa(Error(F(421))),Lr(e,t,a,s)}return r.data==="$?"?(t.flags|=128,t.child=e.child,t=Pm.bind(null,e),r._reactRetry=t,null):(e=i.treeContext,vt=Tn(r.nextSibling),jt=t,ke=!0,Dt=null,e!==null&&(_t[Ct++]=sn,_t[Ct++]=rn,_t[Ct++]=qn,sn=e.id,rn=e.overflow,qn=t),t=dc(t,s.children),t.flags|=4096,t)}function Fd(e,t,l){e.lanes|=t;var s=e.alternate;s!==null&&(s.lanes|=t),oo(e.return,t,l)}function ka(e,t,l,s,r){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:s,tail:l,tailMode:r}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=s,i.tail=l,i.tailMode=r)}function uf(e,t,l){var s=t.pendingProps,r=s.revealOrder,i=s.tail;if(rt(e,t,s.children,l),s=ze.current,s&2)s=s&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Fd(e,l,t);else if(e.tag===19)Fd(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}s&=1}if(ve(ze,s),!(t.mode&1))t.memoizedState=null;else switch(r){case"forwards":for(l=t.child,r=null;l!==null;)e=l.alternate,e!==null&&ji(e)===null&&(r=l),l=l.sibling;l=r,l===null?(r=t.child,t.child=null):(r=l.sibling,l.sibling=null),ka(t,!1,r,l,i);break;case"backwards":for(l=null,r=t.child,t.child=null;r!==null;){if(e=r.alternate,e!==null&&ji(e)===null){t.child=r;break}e=r.sibling,r.sibling=l,l=r,r=e}ka(t,!0,l,null,i);break;case"together":ka(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function ei(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function un(e,t,l){if(e!==null&&(t.dependencies=e.dependencies),Zn|=t.lanes,!(l&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(F(153));if(t.child!==null){for(e=t.child,l=An(e,e.pendingProps),t.child=l,l.return=t;e.sibling!==null;)e=e.sibling,l=l.sibling=An(e,e.pendingProps),l.return=t;l.sibling=null}return t.child}function mm(e,t,l){switch(t.tag){case 3:cf(t),Ul();break;case 5:Dp(t);break;case 1:ft(t.type)&&hi(t);break;case 4:nc(t,t.stateNode.containerInfo);break;case 10:var s=t.type._context,r=t.memoizedProps.value;ve(mi,s._currentValue),s._currentValue=r;break;case 13:if(s=t.memoizedState,s!==null)return s.dehydrated!==null?(ve(ze,ze.current&1),t.flags|=128,null):l&t.child.childLanes?df(e,t,l):(ve(ze,ze.current&1),e=un(e,t,l),e!==null?e.sibling:null);ve(ze,ze.current&1);break;case 19:if(s=(l&t.childLanes)!==0,e.flags&128){if(s)return uf(e,t,l);t.flags|=128}if(r=t.memoizedState,r!==null&&(r.rendering=null,r.tail=null,r.lastEffect=null),ve(ze,ze.current),s)break;return null;case 22:case 23:return t.lanes=0,af(e,t,l)}return un(e,t,l)}var pf,mo,ff,hf;pf=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}};mo=function(){};ff=function(e,t,l,s){var r=e.memoizedProps;if(r!==s){e=t.stateNode,Qn(Gt.current);var i=null;switch(l){case"input":r=Wa(e,r),s=Wa(e,s),i=[];break;case"select":r=Pe({},r,{value:void 0}),s=Pe({},s,{value:void 0}),i=[];break;case"textarea":r=Ua(e,r),s=Ua(e,s),i=[];break;default:typeof r.onClick!="function"&&typeof s.onClick=="function"&&(e.onclick=pi)}Ma(l,s);var a;l=null;for(f in r)if(!s.hasOwnProperty(f)&&r.hasOwnProperty(f)&&r[f]!=null)if(f==="style"){var d=r[f];for(a in d)d.hasOwnProperty(a)&&(l||(l={}),l[a]="")}else f!=="dangerouslySetInnerHTML"&&f!=="children"&&f!=="suppressContentEditableWarning"&&f!=="suppressHydrationWarning"&&f!=="autoFocus"&&(Hs.hasOwnProperty(f)?i||(i=[]):(i=i||[]).push(f,null));for(f in s){var u=s[f];if(d=r!=null?r[f]:void 0,s.hasOwnProperty(f)&&u!==d&&(u!=null||d!=null))if(f==="style")if(d){for(a in d)!d.hasOwnProperty(a)||u&&u.hasOwnProperty(a)||(l||(l={}),l[a]="");for(a in u)u.hasOwnProperty(a)&&d[a]!==u[a]&&(l||(l={}),l[a]=u[a])}else l||(i||(i=[]),i.push(f,l)),l=u;else f==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,d=d?d.__html:void 0,u!=null&&d!==u&&(i=i||[]).push(f,u)):f==="children"?typeof u!="string"&&typeof u!="number"||(i=i||[]).push(f,""+u):f!=="suppressContentEditableWarning"&&f!=="suppressHydrationWarning"&&(Hs.hasOwnProperty(f)?(u!=null&&f==="onScroll"&&je("scroll",e),i||d===u||(i=[])):(i=i||[]).push(f,u))}l&&(i=i||[]).push("style",l);var f=i;(t.updateQueue=f)&&(t.flags|=4)}};hf=function(e,t,l,s){l!==s&&(t.flags|=4)};function fs(e,t){if(!ke)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 s=null;l!==null;)l.alternate!==null&&(s=l),l=l.sibling;s===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:s.sibling=null}}function nt(e){var t=e.alternate!==null&&e.alternate.child===e.child,l=0,s=0;if(t)for(var r=e.child;r!==null;)l|=r.lanes|r.childLanes,s|=r.subtreeFlags&14680064,s|=r.flags&14680064,r.return=e,r=r.sibling;else for(r=e.child;r!==null;)l|=r.lanes|r.childLanes,s|=r.subtreeFlags,s|=r.flags,r.return=e,r=r.sibling;return e.subtreeFlags|=s,e.childLanes=l,t}function ym(e,t,l){var s=t.pendingProps;switch(Xo(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return nt(t),null;case 1:return ft(t.type)&&fi(),nt(t),null;case 3:return s=t.stateNode,Ml(),be(pt),be(st),sc(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(Ar(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Dt!==null&&(_o(Dt),Dt=null))),mo(e,t),nt(t),null;case 5:lc(t);var r=Qn(nr.current);if(l=t.type,e!==null&&t.stateNode!=null)ff(e,t,l,s,r),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!s){if(t.stateNode===null)throw Error(F(166));return nt(t),null}if(e=Qn(Gt.current),Ar(t)){s=t.stateNode,l=t.type;var i=t.memoizedProps;switch(s[Kt]=t,s[er]=i,e=(t.mode&1)!==0,l){case"dialog":je("cancel",s),je("close",s);break;case"iframe":case"object":case"embed":je("load",s);break;case"video":case"audio":for(r=0;r<Rs.length;r++)je(Rs[r],s);break;case"source":je("error",s);break;case"img":case"image":case"link":je("error",s),je("load",s);break;case"details":je("toggle",s);break;case"input":Jc(s,i),je("invalid",s);break;case"select":s._wrapperState={wasMultiple:!!i.multiple},je("invalid",s);break;case"textarea":Vc(s,i),je("invalid",s)}Ma(l,i),r=null;for(var a in i)if(i.hasOwnProperty(a)){var d=i[a];a==="children"?typeof d=="string"?s.textContent!==d&&(i.suppressHydrationWarning!==!0&&Er(s.textContent,d,e),r=["children",d]):typeof d=="number"&&s.textContent!==""+d&&(i.suppressHydrationWarning!==!0&&Er(s.textContent,d,e),r=["children",""+d]):Hs.hasOwnProperty(a)&&d!=null&&a==="onScroll"&&je("scroll",s)}switch(l){case"input":wr(s),Zc(s,i,!0);break;case"textarea":wr(s),ed(s);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(s.onclick=pi)}s=r,t.updateQueue=s,s!==null&&(t.flags|=4)}else{a=r.nodeType===9?r:r.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Uu(l)),e==="http://www.w3.org/1999/xhtml"?l==="script"?(e=a.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof s.is=="string"?e=a.createElement(l,{is:s.is}):(e=a.createElement(l),l==="select"&&(a=e,s.multiple?a.multiple=!0:s.size&&(a.size=s.size))):e=a.createElementNS(e,l),e[Kt]=t,e[er]=s,pf(e,t,!1,!1),t.stateNode=e;e:{switch(a=Ha(l,s),l){case"dialog":je("cancel",e),je("close",e),r=s;break;case"iframe":case"object":case"embed":je("load",e),r=s;break;case"video":case"audio":for(r=0;r<Rs.length;r++)je(Rs[r],e);r=s;break;case"source":je("error",e),r=s;break;case"img":case"image":case"link":je("error",e),je("load",e),r=s;break;case"details":je("toggle",e),r=s;break;case"input":Jc(e,s),r=Wa(e,s),je("invalid",e);break;case"option":r=s;break;case"select":e._wrapperState={wasMultiple:!!s.multiple},r=Pe({},s,{value:void 0}),je("invalid",e);break;case"textarea":Vc(e,s),r=Ua(e,s),je("invalid",e);break;default:r=s}Ma(l,r),d=r;for(i in d)if(d.hasOwnProperty(i)){var u=d[i];i==="style"?Hu(e,u):i==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,u!=null&&Fu(e,u)):i==="children"?typeof u=="string"?(l!=="textarea"||u!=="")&&Ks(e,u):typeof u=="number"&&Ks(e,""+u):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Hs.hasOwnProperty(i)?u!=null&&i==="onScroll"&&je("scroll",e):u!=null&&Lo(e,i,u,a))}switch(l){case"input":wr(e),Zc(e,s,!1);break;case"textarea":wr(e),ed(e);break;case"option":s.value!=null&&e.setAttribute("value",""+Rn(s.value));break;case"select":e.multiple=!!s.multiple,i=s.value,i!=null?Rl(e,!!s.multiple,i,!1):s.defaultValue!=null&&Rl(e,!!s.multiple,s.defaultValue,!0);break;default:typeof r.onClick=="function"&&(e.onclick=pi)}switch(l){case"button":case"input":case"select":case"textarea":s=!!s.autoFocus;break e;case"img":s=!0;break e;default:s=!1}}s&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return nt(t),null;case 6:if(e&&t.stateNode!=null)hf(e,t,e.memoizedProps,s);else{if(typeof s!="string"&&t.stateNode===null)throw Error(F(166));if(l=Qn(nr.current),Qn(Gt.current),Ar(t)){if(s=t.stateNode,l=t.memoizedProps,s[Kt]=t,(i=s.nodeValue!==l)&&(e=jt,e!==null))switch(e.tag){case 3:Er(s.nodeValue,l,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Er(s.nodeValue,l,(e.mode&1)!==0)}i&&(t.flags|=4)}else s=(l.nodeType===9?l:l.ownerDocument).createTextNode(s),s[Kt]=t,t.stateNode=s}return nt(t),null;case 13:if(be(ze),s=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ke&&vt!==null&&t.mode&1&&!(t.flags&128))Ep(),Ul(),t.flags|=98560,i=!1;else if(i=Ar(t),s!==null&&s.dehydrated!==null){if(e===null){if(!i)throw Error(F(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(F(317));i[Kt]=t}else Ul(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;nt(t),i=!1}else Dt!==null&&(_o(Dt),Dt=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=l,t):(s=s!==null,s!==(e!==null&&e.memoizedState!==null)&&s&&(t.child.flags|=8192,t.mode&1&&(e===null||ze.current&1?Qe===0&&(Qe=3):xc())),t.updateQueue!==null&&(t.flags|=4),nt(t),null);case 4:return Ml(),mo(e,t),e===null&&Zs(t.stateNode.containerInfo),nt(t),null;case 10:return Vo(t.type._context),nt(t),null;case 17:return ft(t.type)&&fi(),nt(t),null;case 19:if(be(ze),i=t.memoizedState,i===null)return nt(t),null;if(s=(t.flags&128)!==0,a=i.rendering,a===null)if(s)fs(i,!1);else{if(Qe!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=ji(e),a!==null){for(t.flags|=128,fs(i,!1),s=a.updateQueue,s!==null&&(t.updateQueue=s,t.flags|=4),t.subtreeFlags=0,s=l,l=t.child;l!==null;)i=l,e=s,i.flags&=14680066,a=i.alternate,a===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,e=a.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),l=l.sibling;return ve(ze,ze.current&1|2),t.child}e=e.sibling}i.tail!==null&&Le()>Kl&&(t.flags|=128,s=!0,fs(i,!1),t.lanes=4194304)}else{if(!s)if(e=ji(a),e!==null){if(t.flags|=128,s=!0,l=e.updateQueue,l!==null&&(t.updateQueue=l,t.flags|=4),fs(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!ke)return nt(t),null}else 2*Le()-i.renderingStartTime>Kl&&l!==1073741824&&(t.flags|=128,s=!0,fs(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=Le(),t.sibling=null,l=ze.current,ve(ze,s?l&1|2:l&1),t):(nt(t),null);case 22:case 23:return gc(),s=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==s&&(t.flags|=8192),s&&t.mode&1?yt&1073741824&&(nt(t),t.subtreeFlags&6&&(t.flags|=8192)):nt(t),null;case 24:return null;case 25:return null}throw Error(F(156,t.tag))}function vm(e,t){switch(Xo(t),t.tag){case 1:return ft(t.type)&&fi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ml(),be(pt),be(st),sc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return lc(t),null;case 13:if(be(ze),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(F(340));Ul()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return be(ze),null;case 4:return Ml(),null;case 10:return Vo(t.type._context),null;case 22:case 23:return gc(),null;case 24:return null;default:return null}}var Or=!1,lt=!1,jm=typeof WeakSet=="function"?WeakSet:Set,Y=null;function Il(e,t){var l=e.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(s){Ie(e,t,s)}else l.current=null}function yo(e,t,l){try{l()}catch(s){Ie(e,t,s)}}var Md=!1;function bm(e,t){if(eo=ci,e=yp(),Go(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var s=l.getSelection&&l.getSelection();if(s&&s.rangeCount!==0){l=s.anchorNode;var r=s.anchorOffset,i=s.focusNode;s=s.focusOffset;try{l.nodeType,i.nodeType}catch{l=null;break e}var a=0,d=-1,u=-1,f=0,y=0,p=e,c=null;t:for(;;){for(var v;p!==l||r!==0&&p.nodeType!==3||(d=a+r),p!==i||s!==0&&p.nodeType!==3||(u=a+s),p.nodeType===3&&(a+=p.nodeValue.length),(v=p.firstChild)!==null;)c=p,p=v;for(;;){if(p===e)break t;if(c===l&&++f===r&&(d=a),c===i&&++y===s&&(u=a),(v=p.nextSibling)!==null)break;p=c,c=p.parentNode}p=v}l=d===-1||u===-1?null:{start:d,end:u}}else l=null}l=l||{start:0,end:0}}else l=null;for(to={focusedElem:e,selectionRange:l},ci=!1,Y=t;Y!==null;)if(t=Y,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Y=e;else for(;Y!==null;){t=Y;try{var b=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(b!==null){var g=b.memoizedProps,S=b.memoizedState,h=t.stateNode,m=h.getSnapshotBeforeUpdate(t.elementType===t.type?g:Lt(t.type,g),S);h.__reactInternalSnapshotBeforeUpdate=m}break;case 3:var o=t.stateNode.containerInfo;o.nodeType===1?o.textContent="":o.nodeType===9&&o.documentElement&&o.removeChild(o.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(F(163))}}catch(x){Ie(t,t.return,x)}if(e=t.sibling,e!==null){e.return=t.return,Y=e;break}Y=t.return}return b=Md,Md=!1,b}function Us(e,t,l){var s=t.updateQueue;if(s=s!==null?s.lastEffect:null,s!==null){var r=s=s.next;do{if((r.tag&e)===e){var i=r.destroy;r.destroy=void 0,i!==void 0&&yo(t,l,i)}r=r.next}while(r!==s)}}function Wi(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 s=l.create;l.destroy=s()}l=l.next}while(l!==t)}}function vo(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 gf(e){var t=e.alternate;t!==null&&(e.alternate=null,gf(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Kt],delete t[er],delete t[so],delete t[lm],delete t[sm])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function xf(e){return e.tag===5||e.tag===3||e.tag===4}function Hd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||xf(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 jo(e,t,l){var s=e.tag;if(s===5||s===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=pi));else if(s!==4&&(e=e.child,e!==null))for(jo(e,t,l),e=e.sibling;e!==null;)jo(e,t,l),e=e.sibling}function bo(e,t,l){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?l.insertBefore(e,t):l.appendChild(e);else if(s!==4&&(e=e.child,e!==null))for(bo(e,t,l),e=e.sibling;e!==null;)bo(e,t,l),e=e.sibling}var Ze=null,Ot=!1;function xn(e,t,l){for(l=l.child;l!==null;)mf(e,t,l),l=l.sibling}function mf(e,t,l){if(Qt&&typeof Qt.onCommitFiberUnmount=="function")try{Qt.onCommitFiberUnmount(Ii,l)}catch{}switch(l.tag){case 5:lt||Il(l,t);case 6:var s=Ze,r=Ot;Ze=null,xn(e,t,l),Ze=s,Ot=r,Ze!==null&&(Ot?(e=Ze,l=l.stateNode,e.nodeType===8?e.parentNode.removeChild(l):e.removeChild(l)):Ze.removeChild(l.stateNode));break;case 18:Ze!==null&&(Ot?(e=Ze,l=l.stateNode,e.nodeType===8?ma(e.parentNode,l):e.nodeType===1&&ma(e,l),Xs(e)):ma(Ze,l.stateNode));break;case 4:s=Ze,r=Ot,Ze=l.stateNode.containerInfo,Ot=!0,xn(e,t,l),Ze=s,Ot=r;break;case 0:case 11:case 14:case 15:if(!lt&&(s=l.updateQueue,s!==null&&(s=s.lastEffect,s!==null))){r=s=s.next;do{var i=r,a=i.destroy;i=i.tag,a!==void 0&&(i&2||i&4)&&yo(l,t,a),r=r.next}while(r!==s)}xn(e,t,l);break;case 1:if(!lt&&(Il(l,t),s=l.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=l.memoizedProps,s.state=l.memoizedState,s.componentWillUnmount()}catch(d){Ie(l,t,d)}xn(e,t,l);break;case 21:xn(e,t,l);break;case 22:l.mode&1?(lt=(s=lt)||l.memoizedState!==null,xn(e,t,l),lt=s):xn(e,t,l);break;default:xn(e,t,l)}}function Kd(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var l=e.stateNode;l===null&&(l=e.stateNode=new jm),t.forEach(function(s){var r=Im.bind(null,e,s);l.has(s)||(l.add(s),s.then(r,r))})}}function Rt(e,t){var l=t.deletions;if(l!==null)for(var s=0;s<l.length;s++){var r=l[s];try{var i=e,a=t,d=a;e:for(;d!==null;){switch(d.tag){case 5:Ze=d.stateNode,Ot=!1;break e;case 3:Ze=d.stateNode.containerInfo,Ot=!0;break e;case 4:Ze=d.stateNode.containerInfo,Ot=!0;break e}d=d.return}if(Ze===null)throw Error(F(160));mf(i,a,r),Ze=null,Ot=!1;var u=r.alternate;u!==null&&(u.return=null),r.return=null}catch(f){Ie(r,t,f)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)yf(t,e),t=t.sibling}function yf(e,t){var l=e.alternate,s=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Rt(t,e),Mt(e),s&4){try{Us(3,e,e.return),Wi(3,e)}catch(g){Ie(e,e.return,g)}try{Us(5,e,e.return)}catch(g){Ie(e,e.return,g)}}break;case 1:Rt(t,e),Mt(e),s&512&&l!==null&&Il(l,l.return);break;case 5:if(Rt(t,e),Mt(e),s&512&&l!==null&&Il(l,l.return),e.flags&32){var r=e.stateNode;try{Ks(r,"")}catch(g){Ie(e,e.return,g)}}if(s&4&&(r=e.stateNode,r!=null)){var i=e.memoizedProps,a=l!==null?l.memoizedProps:i,d=e.type,u=e.updateQueue;if(e.updateQueue=null,u!==null)try{d==="input"&&i.type==="radio"&&i.name!=null&&Bu(r,i),Ha(d,a);var f=Ha(d,i);for(a=0;a<u.length;a+=2){var y=u[a],p=u[a+1];y==="style"?Hu(r,p):y==="dangerouslySetInnerHTML"?Fu(r,p):y==="children"?Ks(r,p):Lo(r,y,p,f)}switch(d){case"input":Ba(r,i);break;case"textarea":$u(r,i);break;case"select":var c=r._wrapperState.wasMultiple;r._wrapperState.wasMultiple=!!i.multiple;var v=i.value;v!=null?Rl(r,!!i.multiple,v,!1):c!==!!i.multiple&&(i.defaultValue!=null?Rl(r,!!i.multiple,i.defaultValue,!0):Rl(r,!!i.multiple,i.multiple?[]:"",!1))}r[er]=i}catch(g){Ie(e,e.return,g)}}break;case 6:if(Rt(t,e),Mt(e),s&4){if(e.stateNode===null)throw Error(F(162));r=e.stateNode,i=e.memoizedProps;try{r.nodeValue=i}catch(g){Ie(e,e.return,g)}}break;case 3:if(Rt(t,e),Mt(e),s&4&&l!==null&&l.memoizedState.isDehydrated)try{Xs(t.containerInfo)}catch(g){Ie(e,e.return,g)}break;case 4:Rt(t,e),Mt(e);break;case 13:Rt(t,e),Mt(e),r=e.child,r.flags&8192&&(i=r.memoizedState!==null,r.stateNode.isHidden=i,!i||r.alternate!==null&&r.alternate.memoizedState!==null||(fc=Le())),s&4&&Kd(e);break;case 22:if(y=l!==null&&l.memoizedState!==null,e.mode&1?(lt=(f=lt)||y,Rt(t,e),lt=f):Rt(t,e),Mt(e),s&8192){if(f=e.memoizedState!==null,(e.stateNode.isHidden=f)&&!y&&e.mode&1)for(Y=e,y=e.child;y!==null;){for(p=Y=y;Y!==null;){switch(c=Y,v=c.child,c.tag){case 0:case 11:case 14:case 15:Us(4,c,c.return);break;case 1:Il(c,c.return);var b=c.stateNode;if(typeof b.componentWillUnmount=="function"){s=c,l=c.return;try{t=s,b.props=t.memoizedProps,b.state=t.memoizedState,b.componentWillUnmount()}catch(g){Ie(s,l,g)}}break;case 5:Il(c,c.return);break;case 22:if(c.memoizedState!==null){Gd(p);continue}}v!==null?(v.return=c,Y=v):Gd(p)}y=y.sibling}e:for(y=null,p=e;;){if(p.tag===5){if(y===null){y=p;try{r=p.stateNode,f?(i=r.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(d=p.stateNode,u=p.memoizedProps.style,a=u!=null&&u.hasOwnProperty("display")?u.display:null,d.style.display=Mu("display",a))}catch(g){Ie(e,e.return,g)}}}else if(p.tag===6){if(y===null)try{p.stateNode.nodeValue=f?"":p.memoizedProps}catch(g){Ie(e,e.return,g)}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===e)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===e)break e;for(;p.sibling===null;){if(p.return===null||p.return===e)break e;y===p&&(y=null),p=p.return}y===p&&(y=null),p.sibling.return=p.return,p=p.sibling}}break;case 19:Rt(t,e),Mt(e),s&4&&Kd(e);break;case 21:break;default:Rt(t,e),Mt(e)}}function Mt(e){var t=e.flags;if(t&2){try{e:{for(var l=e.return;l!==null;){if(xf(l)){var s=l;break e}l=l.return}throw Error(F(160))}switch(s.tag){case 5:var r=s.stateNode;s.flags&32&&(Ks(r,""),s.flags&=-33);var i=Hd(e);bo(e,i,r);break;case 3:case 4:var a=s.stateNode.containerInfo,d=Hd(e);jo(e,d,a);break;default:throw Error(F(161))}}catch(u){Ie(e,e.return,u)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Sm(e,t,l){Y=e,vf(e)}function vf(e,t,l){for(var s=(e.mode&1)!==0;Y!==null;){var r=Y,i=r.child;if(r.tag===22&&s){var a=r.memoizedState!==null||Or;if(!a){var d=r.alternate,u=d!==null&&d.memoizedState!==null||lt;d=Or;var f=lt;if(Or=a,(lt=u)&&!f)for(Y=r;Y!==null;)a=Y,u=a.child,a.tag===22&&a.memoizedState!==null?Yd(r):u!==null?(u.return=a,Y=u):Yd(r);for(;i!==null;)Y=i,vf(i),i=i.sibling;Y=r,Or=d,lt=f}Qd(e)}else r.subtreeFlags&8772&&i!==null?(i.return=r,Y=i):Qd(e)}}function Qd(e){for(;Y!==null;){var t=Y;if(t.flags&8772){var l=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:lt||Wi(5,t);break;case 1:var s=t.stateNode;if(t.flags&4&&!lt)if(l===null)s.componentDidMount();else{var r=t.elementType===t.type?l.memoizedProps:Lt(t.type,l.memoizedProps);s.componentDidUpdate(r,l.memoizedState,s.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Id(t,i,s);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}Id(t,a,l)}break;case 5:var d=t.stateNode;if(l===null&&t.flags&4){l=d;var u=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":u.autoFocus&&l.focus();break;case"img":u.src&&(l.src=u.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 y=f.memoizedState;if(y!==null){var p=y.dehydrated;p!==null&&Xs(p)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(F(163))}lt||t.flags&512&&vo(t)}catch(c){Ie(t,t.return,c)}}if(t===e){Y=null;break}if(l=t.sibling,l!==null){l.return=t.return,Y=l;break}Y=t.return}}function Gd(e){for(;Y!==null;){var t=Y;if(t===e){Y=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Y=l;break}Y=t.return}}function Yd(e){for(;Y!==null;){var t=Y;try{switch(t.tag){case 0:case 11:case 15:var l=t.return;try{Wi(4,t)}catch(u){Ie(t,l,u)}break;case 1:var s=t.stateNode;if(typeof s.componentDidMount=="function"){var r=t.return;try{s.componentDidMount()}catch(u){Ie(t,r,u)}}var i=t.return;try{vo(t)}catch(u){Ie(t,i,u)}break;case 5:var a=t.return;try{vo(t)}catch(u){Ie(t,a,u)}}}catch(u){Ie(t,t.return,u)}if(t===e){Y=null;break}var d=t.sibling;if(d!==null){d.return=t.return,Y=d;break}Y=t.return}}var wm=Math.ceil,wi=pn.ReactCurrentDispatcher,uc=pn.ReactCurrentOwner,Tt=pn.ReactCurrentBatchConfig,pe=0,qe=null,Be=null,Ve=0,yt=0,El=Nn(0),Qe=0,ir=null,Zn=0,Bi=0,pc=0,Fs=null,dt=null,fc=0,Kl=1/0,nn=null,ki=!1,So=null,In=null,Dr=!1,wn=null,_i=0,Ms=0,wo=null,ti=-1,ni=0;function it(){return pe&6?Le():ti!==-1?ti:ti=Le()}function En(e){return e.mode&1?pe&2&&Ve!==0?Ve&-Ve:im.transition!==null?(ni===0&&(ni=np()),ni):(e=he,e!==0||(e=window.event,e=e===void 0?16:cp(e.type)),e):1}function Bt(e,t,l,s){if(50<Ms)throw Ms=0,wo=null,Error(F(185));or(e,l,s),(!(pe&2)||e!==qe)&&(e===qe&&(!(pe&2)&&(Bi|=l),Qe===4&&bn(e,Ve)),ht(e,s),l===1&&pe===0&&!(t.mode&1)&&(Kl=Le()+500,Oi&&Wn()))}function ht(e,t){var l=e.callbackNode;ix(e,t);var s=oi(e,e===qe?Ve:0);if(s===0)l!==null&&ld(l),e.callbackNode=null,e.callbackPriority=0;else if(t=s&-s,e.callbackPriority!==t){if(l!=null&&ld(l),t===1)e.tag===0?rm(Xd.bind(null,e)):Tp(Xd.bind(null,e)),tm(function(){!(pe&6)&&Wn()}),l=null;else{switch(lp(s)){case 1:l=Bo;break;case 4:l=ep;break;case 16:l=ai;break;case 536870912:l=tp;break;default:l=ai}l=zf(l,jf.bind(null,e))}e.callbackPriority=t,e.callbackNode=l}}function jf(e,t){if(ti=-1,ni=0,pe&6)throw Error(F(327));var l=e.callbackNode;if(Wl()&&e.callbackNode!==l)return null;var s=oi(e,e===qe?Ve:0);if(s===0)return null;if(s&30||s&e.expiredLanes||t)t=Ci(e,s);else{t=s;var r=pe;pe|=2;var i=Sf();(qe!==e||Ve!==t)&&(nn=null,Kl=Le()+500,Gn(e,t));do try{Cm();break}catch(d){bf(e,d)}while(!0);Zo(),wi.current=i,pe=r,Be!==null?t=0:(qe=null,Ve=0,t=Qe)}if(t!==0){if(t===2&&(r=Xa(e),r!==0&&(s=r,t=ko(e,r))),t===1)throw l=ir,Gn(e,0),bn(e,s),ht(e,Le()),l;if(t===6)bn(e,s);else{if(r=e.current.alternate,!(s&30)&&!km(r)&&(t=Ci(e,s),t===2&&(i=Xa(e),i!==0&&(s=i,t=ko(e,i))),t===1))throw l=ir,Gn(e,0),bn(e,s),ht(e,Le()),l;switch(e.finishedWork=r,e.finishedLanes=s,t){case 0:case 1:throw Error(F(345));case 2:Mn(e,dt,nn);break;case 3:if(bn(e,s),(s&130023424)===s&&(t=fc+500-Le(),10<t)){if(oi(e,0)!==0)break;if(r=e.suspendedLanes,(r&s)!==s){it(),e.pingedLanes|=e.suspendedLanes&r;break}e.timeoutHandle=lo(Mn.bind(null,e,dt,nn),t);break}Mn(e,dt,nn);break;case 4:if(bn(e,s),(s&4194240)===s)break;for(t=e.eventTimes,r=-1;0<s;){var a=31-Wt(s);i=1<<a,a=t[a],a>r&&(r=a),s&=~i}if(s=r,s=Le()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*wm(s/1960))-s,10<s){e.timeoutHandle=lo(Mn.bind(null,e,dt,nn),s);break}Mn(e,dt,nn);break;case 5:Mn(e,dt,nn);break;default:throw Error(F(329))}}}return ht(e,Le()),e.callbackNode===l?jf.bind(null,e):null}function ko(e,t){var l=Fs;return e.current.memoizedState.isDehydrated&&(Gn(e,t).flags|=256),e=Ci(e,t),e!==2&&(t=dt,dt=l,t!==null&&_o(t)),e}function _o(e){dt===null?dt=e:dt.push.apply(dt,e)}function km(e){for(var t=e;;){if(t.flags&16384){var l=t.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var s=0;s<l.length;s++){var r=l[s],i=r.getSnapshot;r=r.value;try{if(!$t(i(),r))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 bn(e,t){for(t&=~pc,t&=~Bi,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var l=31-Wt(t),s=1<<l;e[l]=-1,t&=~s}}function Xd(e){if(pe&6)throw Error(F(327));Wl();var t=oi(e,0);if(!(t&1))return ht(e,Le()),null;var l=Ci(e,t);if(e.tag!==0&&l===2){var s=Xa(e);s!==0&&(t=s,l=ko(e,s))}if(l===1)throw l=ir,Gn(e,0),bn(e,t),ht(e,Le()),l;if(l===6)throw Error(F(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Mn(e,dt,nn),ht(e,Le()),null}function hc(e,t){var l=pe;pe|=1;try{return e(t)}finally{pe=l,pe===0&&(Kl=Le()+500,Oi&&Wn())}}function Vn(e){wn!==null&&wn.tag===0&&!(pe&6)&&Wl();var t=pe;pe|=1;var l=Tt.transition,s=he;try{if(Tt.transition=null,he=1,e)return e()}finally{he=s,Tt.transition=l,pe=t,!(pe&6)&&Wn()}}function gc(){yt=El.current,be(El)}function Gn(e,t){e.finishedWork=null,e.finishedLanes=0;var l=e.timeoutHandle;if(l!==-1&&(e.timeoutHandle=-1,em(l)),Be!==null)for(l=Be.return;l!==null;){var s=l;switch(Xo(s),s.tag){case 1:s=s.type.childContextTypes,s!=null&&fi();break;case 3:Ml(),be(pt),be(st),sc();break;case 5:lc(s);break;case 4:Ml();break;case 13:be(ze);break;case 19:be(ze);break;case 10:Vo(s.type._context);break;case 22:case 23:gc()}l=l.return}if(qe=e,Be=e=An(e.current,null),Ve=yt=t,Qe=0,ir=null,pc=Bi=Zn=0,dt=Fs=null,Kn!==null){for(t=0;t<Kn.length;t++)if(l=Kn[t],s=l.interleaved,s!==null){l.interleaved=null;var r=s.next,i=l.pending;if(i!==null){var a=i.next;i.next=r,s.next=a}l.pending=s}Kn=null}return e}function bf(e,t){do{var l=Be;try{if(Zo(),Zr.current=Si,bi){for(var s=Te.memoizedState;s!==null;){var r=s.queue;r!==null&&(r.pending=null),s=s.next}bi=!1}if(Jn=0,Xe=Ke=Te=null,$s=!1,lr=0,uc.current=null,l===null||l.return===null){Qe=1,ir=t,Be=null;break}e:{var i=e,a=l.return,d=l,u=t;if(t=Ve,d.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){var f=u,y=d,p=y.tag;if(!(y.mode&1)&&(p===0||p===11||p===15)){var c=y.alternate;c?(y.updateQueue=c.updateQueue,y.memoizedState=c.memoizedState,y.lanes=c.lanes):(y.updateQueue=null,y.memoizedState=null)}var v=Dd(a);if(v!==null){v.flags&=-257,Nd(v,a,d,i,t),v.mode&1&&Od(i,f,t),t=v,u=f;var b=t.updateQueue;if(b===null){var g=new Set;g.add(u),t.updateQueue=g}else b.add(u);break e}else{if(!(t&1)){Od(i,f,t),xc();break e}u=Error(F(426))}}else if(ke&&d.mode&1){var S=Dd(a);if(S!==null){!(S.flags&65536)&&(S.flags|=256),Nd(S,a,d,i,t),qo(Hl(u,d));break e}}i=u=Hl(u,d),Qe!==4&&(Qe=2),Fs===null?Fs=[i]:Fs.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var h=lf(i,u,t);Pd(i,h);break e;case 1:d=u;var m=i.type,o=i.stateNode;if(!(i.flags&128)&&(typeof m.getDerivedStateFromError=="function"||o!==null&&typeof o.componentDidCatch=="function"&&(In===null||!In.has(o)))){i.flags|=65536,t&=-t,i.lanes|=t;var x=sf(i,d,t);Pd(i,x);break e}}i=i.return}while(i!==null)}kf(l)}catch(C){t=C,Be===l&&l!==null&&(Be=l=l.return);continue}break}while(!0)}function Sf(){var e=wi.current;return wi.current=Si,e===null?Si:e}function xc(){(Qe===0||Qe===3||Qe===2)&&(Qe=4),qe===null||!(Zn&268435455)&&!(Bi&268435455)||bn(qe,Ve)}function Ci(e,t){var l=pe;pe|=2;var s=Sf();(qe!==e||Ve!==t)&&(nn=null,Gn(e,t));do try{_m();break}catch(r){bf(e,r)}while(!0);if(Zo(),pe=l,wi.current=s,Be!==null)throw Error(F(261));return qe=null,Ve=0,Qe}function _m(){for(;Be!==null;)wf(Be)}function Cm(){for(;Be!==null&&!Jg();)wf(Be)}function wf(e){var t=Cf(e.alternate,e,yt);e.memoizedProps=e.pendingProps,t===null?kf(e):Be=t,uc.current=null}function kf(e){var t=e;do{var l=t.alternate;if(e=t.return,t.flags&32768){if(l=vm(l,t),l!==null){l.flags&=32767,Be=l;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Qe=6,Be=null;return}}else if(l=ym(l,t,yt),l!==null){Be=l;return}if(t=t.sibling,t!==null){Be=t;return}Be=t=e}while(t!==null);Qe===0&&(Qe=5)}function Mn(e,t,l){var s=he,r=Tt.transition;try{Tt.transition=null,he=1,zm(e,t,l,s)}finally{Tt.transition=r,he=s}return null}function zm(e,t,l,s){do Wl();while(wn!==null);if(pe&6)throw Error(F(327));l=e.finishedWork;var r=e.finishedLanes;if(l===null)return null;if(e.finishedWork=null,e.finishedLanes=0,l===e.current)throw Error(F(177));e.callbackNode=null,e.callbackPriority=0;var i=l.lanes|l.childLanes;if(ax(e,i),e===qe&&(Be=qe=null,Ve=0),!(l.subtreeFlags&2064)&&!(l.flags&2064)||Dr||(Dr=!0,zf(ai,function(){return Wl(),null})),i=(l.flags&15990)!==0,l.subtreeFlags&15990||i){i=Tt.transition,Tt.transition=null;var a=he;he=1;var d=pe;pe|=4,uc.current=null,bm(e,l),yf(l,e),Gx(to),ci=!!eo,to=eo=null,e.current=l,Sm(l),Zg(),pe=d,he=a,Tt.transition=i}else e.current=l;if(Dr&&(Dr=!1,wn=e,_i=r),i=e.pendingLanes,i===0&&(In=null),tx(l.stateNode),ht(e,Le()),t!==null)for(s=e.onRecoverableError,l=0;l<t.length;l++)r=t[l],s(r.value,{componentStack:r.stack,digest:r.digest});if(ki)throw ki=!1,e=So,So=null,e;return _i&1&&e.tag!==0&&Wl(),i=e.pendingLanes,i&1?e===wo?Ms++:(Ms=0,wo=e):Ms=0,Wn(),null}function Wl(){if(wn!==null){var e=lp(_i),t=Tt.transition,l=he;try{if(Tt.transition=null,he=16>e?16:e,wn===null)var s=!1;else{if(e=wn,wn=null,_i=0,pe&6)throw Error(F(331));var r=pe;for(pe|=4,Y=e.current;Y!==null;){var i=Y,a=i.child;if(Y.flags&16){var d=i.deletions;if(d!==null){for(var u=0;u<d.length;u++){var f=d[u];for(Y=f;Y!==null;){var y=Y;switch(y.tag){case 0:case 11:case 15:Us(8,y,i)}var p=y.child;if(p!==null)p.return=y,Y=p;else for(;Y!==null;){y=Y;var c=y.sibling,v=y.return;if(gf(y),y===f){Y=null;break}if(c!==null){c.return=v,Y=c;break}Y=v}}}var b=i.alternate;if(b!==null){var g=b.child;if(g!==null){b.child=null;do{var S=g.sibling;g.sibling=null,g=S}while(g!==null)}}Y=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,Y=a;else e:for(;Y!==null;){if(i=Y,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Us(9,i,i.return)}var h=i.sibling;if(h!==null){h.return=i.return,Y=h;break e}Y=i.return}}var m=e.current;for(Y=m;Y!==null;){a=Y;var o=a.child;if(a.subtreeFlags&2064&&o!==null)o.return=a,Y=o;else e:for(a=m;Y!==null;){if(d=Y,d.flags&2048)try{switch(d.tag){case 0:case 11:case 15:Wi(9,d)}}catch(C){Ie(d,d.return,C)}if(d===a){Y=null;break e}var x=d.sibling;if(x!==null){x.return=d.return,Y=x;break e}Y=d.return}}if(pe=r,Wn(),Qt&&typeof Qt.onPostCommitFiberRoot=="function")try{Qt.onPostCommitFiberRoot(Ii,e)}catch{}s=!0}return s}finally{he=l,Tt.transition=t}}return!1}function qd(e,t,l){t=Hl(l,t),t=lf(e,t,1),e=Pn(e,t,1),t=it(),e!==null&&(or(e,1,t),ht(e,t))}function Ie(e,t,l){if(e.tag===3)qd(e,e,l);else for(;t!==null;){if(t.tag===3){qd(t,e,l);break}else if(t.tag===1){var s=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof s.componentDidCatch=="function"&&(In===null||!In.has(s))){e=Hl(l,e),e=sf(t,e,1),t=Pn(t,e,1),e=it(),t!==null&&(or(t,1,e),ht(t,e));break}}t=t.return}}function Tm(e,t,l){var s=e.pingCache;s!==null&&s.delete(t),t=it(),e.pingedLanes|=e.suspendedLanes&l,qe===e&&(Ve&l)===l&&(Qe===4||Qe===3&&(Ve&130023424)===Ve&&500>Le()-fc?Gn(e,0):pc|=l),ht(e,t)}function _f(e,t){t===0&&(e.mode&1?(t=Cr,Cr<<=1,!(Cr&130023424)&&(Cr=4194304)):t=1);var l=it();e=dn(e,t),e!==null&&(or(e,t,l),ht(e,l))}function Pm(e){var t=e.memoizedState,l=0;t!==null&&(l=t.retryLane),_f(e,l)}function Im(e,t){var l=0;switch(e.tag){case 13:var s=e.stateNode,r=e.memoizedState;r!==null&&(l=r.retryLane);break;case 19:s=e.stateNode;break;default:throw Error(F(314))}s!==null&&s.delete(t),_f(e,l)}var Cf;Cf=function(e,t,l){if(e!==null)if(e.memoizedProps!==t.pendingProps||pt.current)ut=!0;else{if(!(e.lanes&l)&&!(t.flags&128))return ut=!1,mm(e,t,l);ut=!!(e.flags&131072)}else ut=!1,ke&&t.flags&1048576&&Pp(t,xi,t.index);switch(t.lanes=0,t.tag){case 2:var s=t.type;ei(e,t),e=t.pendingProps;var r=$l(t,st.current);Nl(t,l),r=ic(null,t,s,e,r,l);var i=ac();return t.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ft(s)?(i=!0,hi(t)):i=!1,t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,tc(t),r.updater=Ni,t.stateNode=r,r._reactInternals=t,uo(t,s,e,l),t=ho(null,t,s,!0,i,l)):(t.tag=0,ke&&i&&Yo(t),rt(null,t,r,l),t=t.child),t;case 16:s=t.elementType;e:{switch(ei(e,t),e=t.pendingProps,r=s._init,s=r(s._payload),t.type=s,r=t.tag=Am(s),e=Lt(s,e),r){case 0:t=fo(null,t,s,e,l);break e;case 1:t=$d(null,t,s,e,l);break e;case 11:t=Wd(null,t,s,e,l);break e;case 14:t=Bd(null,t,s,Lt(s.type,e),l);break e}throw Error(F(306,s,""))}return t;case 0:return s=t.type,r=t.pendingProps,r=t.elementType===s?r:Lt(s,r),fo(e,t,s,r,l);case 1:return s=t.type,r=t.pendingProps,r=t.elementType===s?r:Lt(s,r),$d(e,t,s,r,l);case 3:e:{if(cf(t),e===null)throw Error(F(387));s=t.pendingProps,i=t.memoizedState,r=i.element,Op(e,t),vi(t,s,null,l);var a=t.memoizedState;if(s=a.element,i.isDehydrated)if(i={element:s,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){r=Hl(Error(F(423)),t),t=Ud(e,t,s,l,r);break e}else if(s!==r){r=Hl(Error(F(424)),t),t=Ud(e,t,s,l,r);break e}else for(vt=Tn(t.stateNode.containerInfo.firstChild),jt=t,ke=!0,Dt=null,l=Rp(t,null,s,l),t.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Ul(),s===r){t=un(e,t,l);break e}rt(e,t,s,l)}t=t.child}return t;case 5:return Dp(t),e===null&&ao(t),s=t.type,r=t.pendingProps,i=e!==null?e.memoizedProps:null,a=r.children,no(s,r)?a=null:i!==null&&no(s,i)&&(t.flags|=32),of(e,t),rt(e,t,a,l),t.child;case 6:return e===null&&ao(t),null;case 13:return df(e,t,l);case 4:return nc(t,t.stateNode.containerInfo),s=t.pendingProps,e===null?t.child=Fl(t,null,s,l):rt(e,t,s,l),t.child;case 11:return s=t.type,r=t.pendingProps,r=t.elementType===s?r:Lt(s,r),Wd(e,t,s,r,l);case 7:return rt(e,t,t.pendingProps,l),t.child;case 8:return rt(e,t,t.pendingProps.children,l),t.child;case 12:return rt(e,t,t.pendingProps.children,l),t.child;case 10:e:{if(s=t.type._context,r=t.pendingProps,i=t.memoizedProps,a=r.value,ve(mi,s._currentValue),s._currentValue=a,i!==null)if($t(i.value,a)){if(i.children===r.children&&!pt.current){t=un(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 u=d.firstContext;u!==null;){if(u.context===s){if(i.tag===1){u=an(-1,l&-l),u.tag=2;var f=i.updateQueue;if(f!==null){f=f.shared;var y=f.pending;y===null?u.next=u:(u.next=y.next,y.next=u),f.pending=u}}i.lanes|=l,u=i.alternate,u!==null&&(u.lanes|=l),oo(i.return,l,t),d.lanes|=l;break}u=u.next}}else if(i.tag===10)a=i.type===t.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(F(341));a.lanes|=l,d=a.alternate,d!==null&&(d.lanes|=l),oo(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}rt(e,t,r.children,l),t=t.child}return t;case 9:return r=t.type,s=t.pendingProps.children,Nl(t,l),r=Pt(r),s=s(r),t.flags|=1,rt(e,t,s,l),t.child;case 14:return s=t.type,r=Lt(s,t.pendingProps),r=Lt(s.type,r),Bd(e,t,s,r,l);case 15:return rf(e,t,t.type,t.pendingProps,l);case 17:return s=t.type,r=t.pendingProps,r=t.elementType===s?r:Lt(s,r),ei(e,t),t.tag=1,ft(s)?(e=!0,hi(t)):e=!1,Nl(t,l),nf(t,s,r),uo(t,s,r,l),ho(null,t,s,!0,e,l);case 19:return uf(e,t,l);case 22:return af(e,t,l)}throw Error(F(156,t.tag))};function zf(e,t){return Vu(e,t)}function Em(e,t,l,s){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=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function zt(e,t,l,s){return new Em(e,t,l,s)}function mc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Am(e){if(typeof e=="function")return mc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Do)return 11;if(e===No)return 14}return 2}function An(e,t){var l=e.alternate;return l===null?(l=zt(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 li(e,t,l,s,r,i){var a=2;if(s=e,typeof e=="function")mc(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case bl:return Yn(l.children,r,i,t);case Oo:a=8,r|=8;break;case La:return e=zt(12,l,t,r|2),e.elementType=La,e.lanes=i,e;case Oa:return e=zt(13,l,t,r),e.elementType=Oa,e.lanes=i,e;case Da:return e=zt(19,l,t,r),e.elementType=Da,e.lanes=i,e;case Du:return $i(l,r,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Lu:a=10;break e;case Ou:a=9;break e;case Do:a=11;break e;case No:a=14;break e;case yn:a=16,s=null;break e}throw Error(F(130,e==null?e:typeof e,""))}return t=zt(a,l,t,r),t.elementType=e,t.type=s,t.lanes=i,t}function Yn(e,t,l,s){return e=zt(7,e,s,t),e.lanes=l,e}function $i(e,t,l,s){return e=zt(22,e,s,t),e.elementType=Du,e.lanes=l,e.stateNode={isHidden:!1},e}function _a(e,t,l){return e=zt(6,e,null,t),e.lanes=l,e}function Ca(e,t,l){return t=zt(4,e.children!==null?e.children:[],e.key,t),t.lanes=l,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Rm(e,t,l,s,r){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=ia(0),this.expirationTimes=ia(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ia(0),this.identifierPrefix=s,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function yc(e,t,l,s,r,i,a,d,u){return e=new Rm(e,t,l,d,u),t===1?(t=1,i===!0&&(t|=8)):t=0,i=zt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:s,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},tc(i),e}function Lm(e,t,l){var s=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:jl,key:s==null?null:""+s,children:e,containerInfo:t,implementation:l}}function Tf(e){if(!e)return Ln;e=e._reactInternals;e:{if(nl(e)!==e||e.tag!==1)throw Error(F(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(ft(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(F(171))}if(e.tag===1){var l=e.type;if(ft(l))return zp(e,l,t)}return t}function Pf(e,t,l,s,r,i,a,d,u){return e=yc(l,s,!0,e,r,i,a,d,u),e.context=Tf(null),l=e.current,s=it(),r=En(l),i=an(s,r),i.callback=t??null,Pn(l,i,r),e.current.lanes=r,or(e,r,s),ht(e,s),e}function Ui(e,t,l,s){var r=t.current,i=it(),a=En(r);return l=Tf(l),t.context===null?t.context=l:t.pendingContext=l,t=an(i,a),t.payload={element:e},s=s===void 0?null:s,s!==null&&(t.callback=s),e=Pn(r,t,a),e!==null&&(Bt(e,r,a,i),Jr(e,r,a)),a}function zi(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 Jd(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<t?l:t}}function vc(e,t){Jd(e,t),(e=e.alternate)&&Jd(e,t)}function Om(){return null}var If=typeof reportError=="function"?reportError:function(e){console.error(e)};function jc(e){this._internalRoot=e}Fi.prototype.render=jc.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(F(409));Ui(e,t,null,null)};Fi.prototype.unmount=jc.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Vn(function(){Ui(null,e,null,null)}),t[cn]=null}};function Fi(e){this._internalRoot=e}Fi.prototype.unstable_scheduleHydration=function(e){if(e){var t=ip();e={blockedOn:null,target:e,priority:t};for(var l=0;l<jn.length&&t!==0&&t<jn[l].priority;l++);jn.splice(l,0,e),l===0&&op(e)}};function bc(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Mi(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Zd(){}function Dm(e,t,l,s,r){if(r){if(typeof s=="function"){var i=s;s=function(){var f=zi(a);i.call(f)}}var a=Pf(t,s,e,0,null,!1,!1,"",Zd);return e._reactRootContainer=a,e[cn]=a.current,Zs(e.nodeType===8?e.parentNode:e),Vn(),a}for(;r=e.lastChild;)e.removeChild(r);if(typeof s=="function"){var d=s;s=function(){var f=zi(u);d.call(f)}}var u=yc(e,0,!1,null,null,!1,!1,"",Zd);return e._reactRootContainer=u,e[cn]=u.current,Zs(e.nodeType===8?e.parentNode:e),Vn(function(){Ui(t,u,l,s)}),u}function Hi(e,t,l,s,r){var i=l._reactRootContainer;if(i){var a=i;if(typeof r=="function"){var d=r;r=function(){var u=zi(a);d.call(u)}}Ui(t,a,e,r)}else a=Dm(l,t,e,r,s);return zi(a)}sp=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var l=As(t.pendingLanes);l!==0&&($o(t,l|1),ht(t,Le()),!(pe&6)&&(Kl=Le()+500,Wn()))}break;case 13:Vn(function(){var s=dn(e,1);if(s!==null){var r=it();Bt(s,e,1,r)}}),vc(e,1)}};Uo=function(e){if(e.tag===13){var t=dn(e,134217728);if(t!==null){var l=it();Bt(t,e,134217728,l)}vc(e,134217728)}};rp=function(e){if(e.tag===13){var t=En(e),l=dn(e,t);if(l!==null){var s=it();Bt(l,e,t,s)}vc(e,t)}};ip=function(){return he};ap=function(e,t){var l=he;try{return he=e,t()}finally{he=l}};Qa=function(e,t,l){switch(t){case"input":if(Ba(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 s=l[t];if(s!==e&&s.form===e.form){var r=Li(s);if(!r)throw Error(F(90));Wu(s),Ba(s,r)}}}break;case"textarea":$u(e,l);break;case"select":t=l.value,t!=null&&Rl(e,!!l.multiple,t,!1)}};Gu=hc;Yu=Vn;var Nm={usingClientEntryPoint:!1,Events:[dr,_l,Li,Ku,Qu,hc]},hs={findFiberByHostInstance:Hn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Wm={bundleType:hs.bundleType,version:hs.version,rendererPackageName:hs.rendererPackageName,rendererConfig:hs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:pn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Ju(e),e===null?null:e.stateNode},findFiberByHostInstance:hs.findFiberByHostInstance||Om,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 Nr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Nr.isDisabled&&Nr.supportsFiber)try{Ii=Nr.inject(Wm),Qt=Nr}catch{}}St.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Nm;St.createPortal=function(e,t){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!bc(t))throw Error(F(200));return Lm(e,t,null,l)};St.createRoot=function(e,t){if(!bc(e))throw Error(F(299));var l=!1,s="",r=If;return t!=null&&(t.unstable_strictMode===!0&&(l=!0),t.identifierPrefix!==void 0&&(s=t.identifierPrefix),t.onRecoverableError!==void 0&&(r=t.onRecoverableError)),t=yc(e,1,!1,null,null,l,!1,s,r),e[cn]=t.current,Zs(e.nodeType===8?e.parentNode:e),new jc(t)};St.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(F(188)):(e=Object.keys(e).join(","),Error(F(268,e)));return e=Ju(t),e=e===null?null:e.stateNode,e};St.flushSync=function(e){return Vn(e)};St.hydrate=function(e,t,l){if(!Mi(t))throw Error(F(200));return Hi(null,e,t,!0,l)};St.hydrateRoot=function(e,t,l){if(!bc(e))throw Error(F(405));var s=l!=null&&l.hydratedSources||null,r=!1,i="",a=If;if(l!=null&&(l.unstable_strictMode===!0&&(r=!0),l.identifierPrefix!==void 0&&(i=l.identifierPrefix),l.onRecoverableError!==void 0&&(a=l.onRecoverableError)),t=Pf(t,null,e,1,l??null,r,!1,i,a),e[cn]=t.current,Zs(e),s)for(e=0;e<s.length;e++)l=s[e],r=l._getVersion,r=r(l._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[l,r]:t.mutableSourceEagerHydrationData.push(l,r);return new Fi(t)};St.render=function(e,t,l){if(!Mi(t))throw Error(F(200));return Hi(null,e,t,!1,l)};St.unmountComponentAtNode=function(e){if(!Mi(e))throw Error(F(40));return e._reactRootContainer?(Vn(function(){Hi(null,null,e,!1,function(){e._reactRootContainer=null,e[cn]=null})}),!0):!1};St.unstable_batchedUpdates=hc;St.unstable_renderSubtreeIntoContainer=function(e,t,l,s){if(!Mi(l))throw Error(F(200));if(e==null||e._reactInternals===void 0)throw Error(F(38));return Hi(e,t,l,!1,s)};St.version="18.3.1-next-f1338f8080-20240426";function Ef(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Ef)}catch(e){console.error(e)}}Ef(),Iu.exports=St;var Bm=Iu.exports,Af,Vd=Bm;Af=Vd.createRoot,Vd.hydrateRoot;const ce="",$={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"},B={bg:"#f5f6fa",accent:"#4f46e5",red:"#ef4444",orange:"#f59e0b",green:"#16a34a",purple:"#7c3aed",blue:"#2563eb",teal:"#0d9488",gray:"#94a3b8"},$m=[{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"}],Um=[{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"}],Fm=new Set(["users"]);function Mm(e){return e!=="Admin"&&e!=="Auditor"?[]:Um.filter(({id:t})=>e==="Admin"||!Fm.has(t))}const mn=(e=[])=>[{key:"name1",label:"Name"},{key:"status",label:"Status"},...e,{key:"creation_date",label:"Created On"}],Hm={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:mn(),defaultColumns:["name1","status","creation_date"]},"idea-types":{label:"Idea Types",columns:mn(),defaultColumns:["name1","status","creation_date"]},"order-types":{label:"Order Types",columns:mn(),defaultColumns:["name1","status","creation_date"]},"process-types":{label:"Process Types",columns:mn(),defaultColumns:["name1","status","creation_date"]},"incident-statuses":{label:"Incident Statuses",columns:mn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"idea-statuses":{label:"Idea Statuses",columns:mn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"order-statuses":{label:"Order Statuses",columns:mn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"process-statuses":{label:"Process Statuses",columns:mn([{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"]}},Km="modulepreload",Qm=function(e){return"/"+e},eu={},Gm=function(t,l,s){let r=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"));r=Promise.allSettled(l.map(u=>{if(u=Qm(u),u in eu)return;eu[u]=!0;const f=u.endsWith(".css"),y=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${y}`))return;const p=document.createElement("link");if(p.rel=f?"stylesheet":Km,f||(p.as="script"),p.crossOrigin="",p.href=u,d&&p.setAttribute("nonce",d),document.head.appendChild(p),f)return new Promise((c,v)=>{p.addEventListener("load",c),p.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(a){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=a,window.dispatchEvent(d),!d.defaultPrevented)throw a}return r.then(a=>{for(const d of a||[])d.status==="rejected"&&i(d.reason);return t().catch(i)})};function Rf(e,t){const l=e[t.key];return l==null||l===""?"":typeof l=="object"?JSON.stringify(l):String(l)}function Ym(e,t){const l=URL.createObjectURL(e),s=document.createElement("a");s.href=l,s.download=t,s.click(),URL.revokeObjectURL(l)}function Xm(e,t,l){const s=e.map(a=>`"${a.label.replace(/"/g,'""')}"`).join(","),r=t.map(a=>e.map(d=>`"${Rf(a,d).replace(/"/g,'""')}"`).join(",")).join(`
|
||
`),i=new Blob([s+`
|
||
`+r],{type:"text/csv;charset=utf-8;"});Ym(i,`${l}.csv`)}async function qm(e,t,l){const s=await Gm(()=>import("./xlsx-D_0l8YDs.js"),[]),r=t.map(d=>{const u={};for(const f of e)u[f.label]=Rf(d,f);return u}),i=s.utils.json_to_sheet(r,{header:e.map(d=>d.label)}),a=s.utils.book_new();s.utils.book_append_sheet(a,i,"Export"),s.writeFile(a,`${l}.xlsx`)}const Wr="#16a34a";function Jm({title:e,rows:t,columns:l,defaultColumnKeys:s,orgField:r,organizations:i,filenameBase:a,onClose:d}){const[u,f]=j.useState(""),[y,p]=j.useState("csv"),[c,v]=j.useState(new Set(s)),b=u?t.filter(x=>x[r||"organization"]===u):t,g=l.filter(x=>c.has(x.key)),S=x=>{v(C=>{const A=new Set(C);return A.has(x)?A.delete(x):A.add(x),A})},h=async()=>{g.length===0||b.length===0||(y==="csv"?Xm(g,b,a):await qm(g,b,a),d())},m={fontSize:11,fontWeight:700,color:"#9ca3af",letterSpacing:.4,textTransform:"uppercase",marginBottom:10},o={background:"none",border:"none",color:"#2563eb",fontSize:12,fontWeight:600,cursor:"pointer",padding:0,fontFamily:"inherit"};return n.jsx("div",{onClick: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:x=>x.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:Wr,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:[r&&i&&i.length>0&&n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:m,children:"Filter by Organization"}),n.jsxs("select",{value:u,onChange:x=>f(x.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(x=>n.jsx("option",{value:x.name,children:x.organization_name||x.name},x.name))]})]}),n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:m,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(x=>n.jsxs("div",{onClick:()=>p(x.id),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",borderRadius:10,cursor:"pointer",border:`2px solid ${y===x.id?Wr:"#e5e7eb"}`,background:y===x.id?"#f0fdf4":"white"},children:[n.jsx("span",{style:{fontSize:20},children:x.id==="csv"?"📄":"📊"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:x.label}),n.jsx("div",{style:{fontSize:11,color:"#888"},children:x.desc})]})]},x.id))})]}),n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[n.jsx("div",{style:{...m,marginBottom:0},children:"Columns to Export"}),n.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[n.jsx("button",{onClick:()=>v(new Set(l.map(x=>x.key))),style:o,children:"Select All"}),n.jsx("span",{style:{color:"#d1d5db"},children:"|"}),n.jsx("button",{onClick:()=>v(new Set(s)),style:o,children:"Reset to Default"})]})]}),n.jsx("div",{style:{border:"1px solid #e5e7eb",borderRadius:8,padding:12,maxHeight:170,overflowY:"auto"},children:n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"10px 12px"},children:l.map(x=>n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:7,fontSize:13,color:"#374151",cursor:"pointer"},children:[n.jsx("input",{type:"checkbox",checked:c.has(x.key),onChange:()=>S(x.key),style:{accentColor:Wr,cursor:"pointer"}}),x.label]},x.key))})}),n.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:6},children:[c.size," column",c.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:u?`Exporting ${b.length} filtered row${b.length!==1?"s":""}`:`Exporting all ${b.length} row${b.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:h,disabled:g.length===0||b.length===0,style:{padding:"9px 20px",borderRadius:8,border:"none",background:Wr,color:"white",fontWeight:700,fontSize:13,cursor:g.length===0||b.length===0?"not-allowed":"pointer",opacity:g.length===0||b.length===0?.5:1,fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"})]})]})]})})}function Lf({collapsed:e,onToggleCollapsed:t,activePage:l,onNavigate:s,hasDashboard:r,hasReports:i,hasDelegations:a,role:d,hideSettings:u,rtl:f,navLabels:y,settingsLabel:p}){const c=u?[]:Mm(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:[$m.filter(({id:v})=>(v!=="dashboard"||r)&&(v!=="reports"||i)&&(v!=="delegations"||a)).map(({id:v,icon:b})=>{const g=y[v]||v,S=v===l;return n.jsxs("div",{onClick:()=>s(v),title:e?g:void 0,style:{padding:e?"8px 0":"8px 14px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:9,background:S?"rgba(139,92,246,0.28)":"transparent",borderRadius:8,fontSize:e?15:12,color:"white",fontWeight:S?600:400,transition:"all 0.15s",whiteSpace:"nowrap",marginBottom:2},children:[n.jsx("span",{style:{flexShrink:0},children:b}),!e&&g]},v)}),c.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:p}),e&&n.jsx("div",{style:{margin:"10px auto",width:28,borderTop:"1px solid rgba(255,255,255,0.12)"}}),c.map(({id:v,icon:b})=>{const g=y[v]||v,S=v===l;return n.jsxs("div",{onClick:()=>s(v),title:e?g:void 0,style:{padding:e?"8px 0":"8px 14px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:9,background:S?"rgba(139,92,246,0.25)":"transparent",borderRadius:8,fontSize:e?15:12,color:"white",fontWeight:S?600:400,transition:"all 0.15s",whiteSpace:"nowrap",marginBottom:2},children:[n.jsx("span",{style:{flexShrink:0},children:b}),!e&&g]},v)})]})]})]})}const Of="sidrah_rtl",Co="sidrah-lang-change";function Al(){try{return localStorage.getItem(Of)==="1"}catch{return!1}}function Df(){const e=!Al();try{localStorage.setItem(Of,e?"1":"0")}catch{}document.documentElement.setAttribute("dir",e?"rtl":"ltr"),document.documentElement.setAttribute("lang",e?"ar":"en-GB"),window.dispatchEvent(new CustomEvent(Co))}function V(){const[e,t]=j.useState(Al);return j.useEffect(()=>{const l=()=>t(Al());return window.addEventListener(Co,l),document.documentElement.setAttribute("dir",Al()?"rtl":"ltr"),document.documentElement.setAttribute("lang",Al()?"ar":"en-GB"),()=>window.removeEventListener(Co,l)},[]),e?Vm:Zm}const Zm={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"}},Vm={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:"بواسطة"}},pr=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 el="";async function Sc(){try{const e=await fetch(`${ce}/api/method/sidrah_business.api.get_csrf_token`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(e.ok){const l=(await e.json()).message||"";if(l)return el=l,l}}catch(e){console.error("CSRF fetch error:",e)}return el}async function fn(){return el||await Sc(),el}function tu(e,t){try{if(e!=null&&e._server_messages){const l=JSON.parse(e._server_messages);if(l.length){const s=JSON.parse(l[0]);if(s!=null&&s.message)return s.message.replace(/<[^>]+>/g,"")}}}catch{}return(e==null?void 0:e.message)||(e==null?void 0:e.exception)||t}async function mt(e,t,l=[]){if(pr.has(e)){const a=`${ce}/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 s=l.length?`?fields=${encodeURIComponent(JSON.stringify(l))}`:"",r=await fetch(`${ce}/api/v1/resource/${e}/${encodeURIComponent(t)}${s}`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`API Error: ${r.status}`);return(await r.json()).data}async function Nf(e,t){const l=await fn();if(pr.has(e)){const r=new URLSearchParams({doctype:e,name:t}),i=await fetch(`${ce}/api/method/sidrah_business.api.delete_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":l},body:r.toString()});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(tu(a,`Error deleting ${t}`))}return}const s=await fetch(`${ce}/api/v1/resource/${e}/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"include",headers:{Accept:"application/json","X-Frappe-CSRF-Token":l}});if(!s.ok){const r=await s.json().catch(()=>({}));throw new Error(tu(r,`Error deleting ${t}`))}return await s.json()}async function we(e){if(pr.has(e))try{const s=`${ce}/api/method/sidrah_business.api.get_sb_list?doctype=${encodeURIComponent(e)}&limit=500`,r=await fetch(s,{credentials:"include",headers:{Accept:"application/json"}});return r.ok?(await r.json()).message||[]:[]}catch{return[]}const t=encodeURIComponent('["*"]'),l=`${ce}/api/v1/resource/${e}?limit_page_length=500&fields=${t}`;try{const s=await fetch(l,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return s.status===401||s.status===403?[]:s.ok?(await s.json()).data||[]:[]}catch(s){return console.error("Get error:",s),[]}}async function za(e,t){const l=await fn();if(pr.has(e)){const r=new URLSearchParams({doctype:e,data_json:JSON.stringify(t)}),i=await fetch(`${ce}/api/method/sidrah_business.api.create_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":l},body:r.toString()});if(!i.ok){const d=await i.json().catch(()=>({}));throw new Error(d.message||d.exc||`Error creating ${e}`)}return{data:(await i.json()).message}}const s=`${ce}/api/v1/resource/${e}`;try{const r=await fetch(s,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":l},body:JSON.stringify(t)});if(r.status===401||r.status===403)throw new Error("Permission denied - login required");if(!r.ok){const i=await r.json();throw new Error(i.message||i.exc||`API Error: ${r.status}`)}return await r.json()}catch(r){throw console.error("Post error:",r),r}}async function Ti(e,t,l){const s=await fn();if(pr.has(e)){const i=new URLSearchParams({doctype:e,name:t,data_json:JSON.stringify(l)}),a=await fetch(`${ce}/api/method/sidrah_business.api.update_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:i.toString()});if(!a.ok){const u=await a.json().catch(()=>({}));throw new Error(u.message||u.exc||`Error updating ${e}`)}return{data:(await a.json()).message}}const r=`${ce}/api/v1/resource/${e}/${encodeURIComponent(t)}`;try{const i=await fetch(r,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":s},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 ey(){const e=`${ce}/api/v1/resource/User?limit_page_length=500&fields=["name","full_name"]`;try{const t=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return t.status===401||t.status===403?[]:t.ok?(await t.json()).data||[]:[]}catch(t){return console.error("Get users error:",t),[]}}async function ty(e,t){const l=new FormData;l.append("usr",e),l.append("pwd",t);const r=await(await fetch(`${ce}/api/method/login`,{method:"POST",credentials:"include",body:l})).json();return r.csrf_token?el=r.csrf_token:await Sc(),r}async function ny(){const e=await fn();try{await fetch(`${ce}/api/method/logout`,{method:"POST",credentials:"include",headers:{"X-Frappe-CSRF-Token":e,Accept:"application/json"}})}catch{}el=""}function ly(){return el}async function Wf(){try{const e=await fetch(`${ce}/api/method/frappe.auth.get_logged_user`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return e.ok&&(await e.json()).message||""}catch{return""}}async function sy(){const e=JSON.stringify([["name","not in",["Administrator","Guest"]]]),t=`${ce}/api/v1/resource/User?limit_page_length=500&fields=${encodeURIComponent('["*"]')}&filters=${encodeURIComponent(e)}`;try{const l=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).data||[]:[]}catch{return[]}}async function ry(){const e=`${ce}/api/method/sidrah_business.api.get_user_role_map`;try{const t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||{}:{}}catch{return{}}}async function Bf(e,t){await Ti("User",e,{new_password:t})}async function iy(e=20){try{const t=`${ce}/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 ay(){const e=await fn();try{await fetch(`${ce}/api/method/sidrah_business.api.mark_notifications_read`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":e}})}catch{}}async function oy(e){const t=await fn();try{await fetch(`${ce}/api/method/sidrah_business.api.mark_notification_read`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":t},body:new URLSearchParams({name:e}).toString()})}catch{}}async function cy(e){const t=await fn(),l=new URLSearchParams({name:e});await fetch(`${ce}/api/method/sidrah_business.api.disable_user`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":t},body:l.toString()})}async function dy(e,t){try{const l=`${ce}/api/method/sidrah_business.api.get_doc_comments?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(t)}`,s=await fetch(l,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function uy(e,t,l){const s=await fn(),r=new URLSearchParams({doctype:e,docname:t,content:l}),i=await fetch(`${ce}/api/method/sidrah_business.api.post_doc_comment`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:r.toString()});if(!i.ok)throw new Error("Failed to post comment");return(await i.json()).message}async function py(e,t){try{const l=`${ce}/api/method/sidrah_business.api.get_doc_versions?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(t)}`,s=await fetch(l,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function $f(e){try{const t=`${ce}/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 fy(){try{const e=`${ce}/api/method/sidrah_business.api.get_my_organization`,t=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return t.ok&&(await t.json()).message||""}catch{return""}}async function ll(e,t={}){const l=await fn(),s=new URLSearchParams(t),r=await fetch(`${ce}/api/method/sidrah_business.api.${e}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":l},body:s.toString()});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(a.message||a.exc||`Error calling ${e}`)}return(await r.json()).message}async function hy(e,t,l="",s,r,i){const a={name:e,action:t,comment:l};return s!==void 0&&(a.stage=s),i!==void 0&&(a.cycle_status=i),ll("apply_order_workflow",a)}async function gy(e,t,l=""){return ll("apply_incident_workflow",{name:e,action:t,fields_json:l})}async function xy(e,t,l=""){return ll("apply_idea_workflow",{name:e,action:t,fields_json:l})}async function my(e=""){const t=`${ce}/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 yy(e,t={}){return ll("get_report_data",{report_name:e,filters_json:JSON.stringify(t)})}async function vy(){try{const e=`${ce}/api/method/sidrah_business.api.get_inbox_items`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function jy(e,t,l="",s=""){return ll("create_delegation",{manager:e,functions_json:JSON.stringify(t),organization:l,remarks:s})}async function by(e,t,l=""){return ll("respond_to_delegation",{name:e,response:t,remarks:l})}async function Sy(e,t=""){return ll("revoke_delegation",{name:e,remarks:t})}async function wy(){try{const e=`${ce}/api/method/sidrah_business.api.get_delegations`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function ky(e){const t=`${ce}/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 _y(){try{const e=`${ce}/api/method/sidrah_business.api.get_my_delegated_functions`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function Cy(){try{const e=`${ce}/api/method/sidrah_business.api.get_my_delegated_organizations`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||{}:{}}catch{return{}}}async function zy(){const e=ly();return e||Sc()}async function Ls(e){const t=await fetch(`${ce}/api/method/sidrah_business.api.get_process?name=${encodeURIComponent(e)}`,{credentials:"include",headers:{Accept:"application/json"}});if(!t.ok){const s=await t.json().catch(()=>({}));throw new Error(s.message||`Failed to load process (${t.status})`)}const l=await t.json();return l.message||l.data}async function Ty(e,t,l={}){const s=await zy(),r=new URLSearchParams({name:e,action:t});l.actor_status&&r.set("actor_status",String(l.actor_status)),l.actor_comment&&r.set("actor_comment",String(l.actor_comment)),l.progress_indicators&&r.set("progress_indicators",JSON.stringify(l.progress_indicators));const i=await fetch(`${ce}/api/method/sidrah_business.api.apply_process_workflow`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:r.toString()});if(!i.ok){const d=await i.json().catch(()=>({})),u=d.message||(d.exception?String(d.exception).split(`
|
||
`).pop():"")||d.exc_type||`Workflow action "${t}" failed (${i.status})`;throw new Error(u)}const a=await i.json();return a.message||a.data}function Py({onLogin:e}){const t=V(),[l,s]=j.useState(""),[r,i]=j.useState(""),[a,d]=j.useState(""),[u,f]=j.useState(!1),[y,p]=j.useState(!1),[c,v]=j.useState(!1),b=async()=>{if(!l||!r){d(t.login.emptyFields);return}f(!0),d("");try{const S=await ty(l,r);if(S.message==="Logged In"){const m=await Wf()||l,o=await $f(m),x=o.some(C=>["SB Admin","System Manager"].includes(C))?"Admin":o.includes("SB Auditor")?"Auditor":o.includes("SB Owner")?"Owner":o.includes("SB X-Auditor")?"XAuditor":o.includes("SB Manager")?"Manager":"Employee";e({name:m,full_name:S.full_name||l,role:x})}else d(t.login.invalidCreds)}catch(S){d(t.login.connError+(S instanceof Error?S.message:"Unknown"))}f(!1)},g=S=>({width:"100%",padding:"13px 16px",border:`1.5px solid ${S?"#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:S?"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:S=>s(S.target.value),onKeyDown:S=>S.key==="Enter"&&b(),onFocus:()=>p(!0),onBlur:()=>p(!1),style:g(y),placeholder:t.login.usernamePlaceholder,autoComplete:"username"}),n.jsx("input",{type:"password",value:r,onChange:S=>i(S.target.value),onKeyDown:S=>S.key==="Enter"&&b(),onFocus:()=>v(!0),onBlur:()=>v(!1),style:g(c),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:b,disabled:u,style:{background:u?"#a5b4fc":"#4f46e5",color:"white",border:"none",padding:"14px",borderRadius:10,fontSize:15,cursor:u?"not-allowed":"pointer",fontWeight:700,marginTop:4,transition:"background 0.2s, transform 0.1s",letterSpacing:"0.01em"},onMouseEnter:S=>{u||(S.currentTarget.style.background="#4338ca")},onMouseLeave:S=>{u||(S.currentTarget.style.background="#4f46e5")},children:u?t.login.signingIn:t.login.signIn})]}),n.jsx("div",{style:{textAlign:"center",marginTop:14},children:n.jsx("button",{onClick:Df,style:{fontSize:12,color:"#9ca3af",background:"none",border:"none",cursor:"pointer"},children:t.switchLang})})]})})}function Iy(e,t){const l=parseInt(e.replace("#",""),16),s=l>>16&255,r=l>>8&255,i=l&255,a=d=>Math.round(d+(255-d)*t);return`rgb(${a(s)}, ${a(r)}, ${a(i)})`}function gs(e,t){const l=parseInt(e.replace("#",""),16),s=l>>16&255,r=l>>8&255,i=l&255;return`rgba(${s}, ${r}, ${i}, ${t})`}function Br({title:e,data:t,color:l,onSelect:s}){const[,r]=t[0]??["Total",0,""],i=t.slice(1),a=i.map((u,f)=>Iy(l,Math.min(f*.16,.7))),d=i.map(([u,f,y],p)=>[u,f,y,a[p]]).filter(([,u])=>u>0);return n.jsxs("div",{className:"status-card",style:{borderRadius:18,padding:"16px 18px 18px",height:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",minWidth:0,position:"relative",overflow:"hidden"},children:[n.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",background:`linear-gradient(160deg, ${gs(l,.09)} 0%, transparent 55%)`}}),n.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:3,background:`linear-gradient(90deg, ${l}, ${gs(l,.35)})`}}),n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:14},children:[n.jsx("span",{className:"status-card-title",style:{fontSize:13,fontWeight:700,paddingTop:4},children:e}),n.jsx("span",{style:{fontSize:14,fontWeight:800,color:"white",background:l,lineHeight:1,minWidth:26,textAlign:"center",padding:"6px 9px",borderRadius:10,boxShadow:`0 4px 10px ${gs(l,.35)}`},children:r})]}),r>0&&n.jsx("div",{style:{display:"flex",height:9,borderRadius:999,overflow:"hidden",background:gs(l,.1),marginBottom:13},children:d.map(([u,f,y,p],c)=>n.jsx("div",{title:`${u}: ${f}`,onClick:v=>{v.stopPropagation(),s==null||s(y)},style:{flex:`${f} 0 0`,background:p,borderRight:c<d.length-1?"2px solid white":"none",cursor:s?"pointer":"default"}},u))}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:i.map(([u,f,y],p)=>n.jsxs("div",{className:"status-card-row",onClick:f>0?c=>{c.stopPropagation(),s==null||s(y)}:void 0,style:{display:"flex",alignItems:"center",gap:9,padding:"4px 6px",borderRadius:8,cursor:f>0&&s?"pointer":"default",transition:"background 0.12s"},children:[n.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:a[p],flexShrink:0,boxShadow:`0 0 0 3px ${gs(a[p],.18)}`}}),n.jsx("span",{className:"status-card-label",style:{flex:1,fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),n.jsx("span",{className:"status-card-count",style:{fontSize:12,fontWeight:700,flexShrink:0},children:f})]},u))})]})}function Et({value:e,onChange:t,organizations:l,placeholder:s="-- Choose organization --",disabled:r=!1,small:i=!1}){var p;const[a,d]=j.useState(!1),u=j.useRef(null);j.useEffect(()=>{const c=v=>{u.current&&!u.current.contains(v.target)&&d(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[]);const f=e?((p=l.find(c=>c.organization_name===e||c.name===e))==null?void 0:p.organization_name)??e:s,y=l.filter(c=>!!c.is_active||c.organization_name===e||c.name===e);return n.jsxs("div",{ref:u,style:{position:"relative",width:"100%"},children:[n.jsxs("div",{onClick:()=>!r&&d(c=>!c),style:{width:"100%",padding:i?"4px 8px":"7px 10px",border:"1px solid #ddd",borderRadius:6,fontSize:i?11:12,cursor:r?"default":"pointer",height:i?28:34,background:r?"#f5f5f5":"white",color:e?"#333":"#aaa",display:"flex",justifyContent:"space-between",alignItems:"center",borderColor:a?"#3498db":"#ddd",transition:"border-color 0.2s",userSelect:"none",boxSizing:"border-box",opacity:r?.75:1},children:[n.jsx("span",{children:f}),n.jsx("span",{style:{fontSize:9,color:"#999",transform:a?"rotate(180deg)":"none",transition:"transform 0.2s"},children:"▼"})]}),a&&n.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:9999,background:"white",border:"1px solid #e0e0e0",borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",overflow:"hidden"},children:n.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[n.jsx(nu,{label:s,selected:!e,active:!0,isPlaceholder:!0,small:i,onClick:()=>{t(""),d(!1)}}),y.length===0&&n.jsx("div",{style:{padding:"12px 16px",color:"#aaa",fontSize:13},children:"No organizations"}),y.map(c=>n.jsx(nu,{label:c.organization_name,selected:e===c.organization_name||e===c.name,active:!!c.is_active,isPlaceholder:!1,small:i,onClick:()=>{t(c.organization_name),d(!1)}},c.name))]})})]})}function nu({label:e,selected:t,active:l,isPlaceholder:s,small:r,onClick:i}){const[a,d]=j.useState(!1),u=t?"#2563eb":a?"#f0f4ff":"transparent",f=t?"white":s?"#aaa":l?"#1a2332":"#e74c3c";return n.jsx("div",{onClick:i,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),style:{padding:r?"6px 12px":"8px 14px",cursor:"pointer",fontSize:12,background:u,color:f,transition:"background 0.1s"},children:e})}function kn({items:e,type:t,onNavigate:l}){const s=V();if(!e.length)return null;const r=t==="process"?"processes-form":"orders-form",i=t==="process"?s.dash.escalatedProcesses:s.dash.escalatedOrders;return n.jsxs("div",{children:[n.jsxs("h4",{style:{fontWeight:700,fontSize:12,color:"#e74c3c",marginBottom:6},children:[i," (",e.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:e.map(a=>n.jsxs("div",{onClick:()=>l(r,a.name),style:{padding:"8px 12px",background:"#fff5f5",borderRadius:7,border:"1px solid #fecaca",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsxs("div",{children:[n.jsx("span",{style:{fontWeight:700,fontSize:12},children:a.number||a.name}),n.jsx("span",{style:{fontSize:11,color:"#666",marginLeft:8},children:a.title})]}),n.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#e74c3c",background:"#fecaca",padding:"2px 8px",borderRadius:10},children:[s.dash.level," ",a.escalation_level]})]},a.name))})]})}function Ey({kpi:e}){const t=V();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:s})=>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:s})]},l))})]})}function Ay({data:e}){if(!e.length)return n.jsx("p",{style:{color:"#aaa",fontSize:13},children:"No cycle data available for trend chart."});const t=Math.max(...e.map(l=>l.pass+l.fail+l.unknown),1);return n.jsxs("div",{children:[n.jsx("div",{style:{display:"flex",gap:10,alignItems:"flex-end",overflowX:"auto",paddingBottom:4},children:e.map(l=>{const s=l.pass+l.fail+l.unknown||1,r=80;return n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:3,minWidth:48},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column-reverse",gap:1,height:r,width:32},children:[n.jsx("div",{title:`Pass: ${l.pass}`,style:{height:Math.round(l.pass/t*r),background:"#27ae60",borderRadius:"2px 2px 0 0",minHeight:l.pass?2:0}}),n.jsx("div",{title:`Fail: ${l.fail}`,style:{height:Math.round(l.fail/t*r),background:"#e74c3c",borderRadius:"2px 2px 0 0",minHeight:l.fail?2:0}}),n.jsx("div",{title:`Unknown: ${l.unknown}`,style:{height:Math.round(l.unknown/t*r),background:"#95a5a6",borderRadius:"2px 2px 0 0",minHeight:l.unknown?2:0}})]}),n.jsx("div",{style:{fontSize:9,color:"#999",textAlign:"center",lineHeight:1.2},children:l.month.replace(/^(\d{4})-(\d{2})$/,(i,a,d)=>`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][+d-1]}
|
||
${a}`)}),n.jsx("div",{style:{fontSize:9,color:"#555",textAlign:"center"},children:s>1?Math.round(l.pass/s*100)+"%":"—"})]},l.month)})}),n.jsx("div",{style:{display:"flex",gap:16,marginTop:8},children:[["#27ae60","Pass"],["#e74c3c","Fail"],["#95a5a6","Unknown"]].map(([l,s])=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,fontSize:11},children:[n.jsx("div",{style:{width:10,height:10,background:l,borderRadius:2}}),n.jsx("span",{style:{color:"#666"},children:s})]},s))})]})}function Nt({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:s=>s.currentTarget.style.boxShadow="0 3px 10px rgba(0,0,0,0.12)",onMouseLeave:s=>s.currentTarget.style.boxShadow="0 1px 3px rgba(0,0,0,0.06)",children:[n.jsx("span",{style:{fontSize:15},children:t}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#444",whiteSpace:"nowrap"},children:e})]})}function Ry({dashData:e,fi:t,fid:l,fo:s,fp:r,incidentStatuses:i,ideaStatuses:a,orderStatuses:d,processStatuses:u,onNavigate:f,onNavigateStatus:y}){const p=V(),c=(e==null?void 0:e.escalated_processes)||[],v=(e==null?void 0:e.escalated_orders)||[],b=(e==null?void 0:e.attention_processes)||[],g=(e==null?void 0:e.attention_orders)||[],S=(e==null?void 0:e.untriaged_incidents)||[],h=(e==null?void 0:e.overdue_triage)||[],m=c.length>0||v.length>0,o=b.length>0||g.length>0,x=[["Total",t.length,""],...i.map(w=>[w.name1||w.name,t.filter(_=>_.status===w.name).length,w.name])],C=[["Total",l.length,""],...a.map(w=>[w.name1||w.name,l.filter(_=>_.status===w.name).length,w.name])],A=[["Total",s.length,""],...d.map(w=>[w.name1||w.name,s.filter(_=>_.status===w.name).length,w.name])],T=[["Total",r.length,""],...u.map(w=>[w.name1||w.name,r.filter(_=>_.status===w.name).length,w.name])];return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",marginBottom:4},children:[n.jsx(Nt,{label:"Incidents",icon:"⚠️",onClick:()=>f("incidents")}),n.jsx(Nt,{label:"Ideas",icon:"💡",onClick:()=>f("ideas")}),n.jsx(Nt,{label:"Orders",icon:"📦",onClick:()=>f("orders")}),n.jsx(Nt,{label:"Processes",icon:"⚙️",onClick:()=>f("processes")}),n.jsx(Nt,{label:"Inbox",icon:"📥",onClick:()=>f("inbox")}),n.jsx(Nt,{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(Br,{title:p.dash.incidents,color:B.orange,data:x,onSelect:w=>y("incidents",w)})}),n.jsx("div",{onClick:()=>f("ideas"),style:{cursor:"pointer"},children:n.jsx(Br,{title:p.dash.ideas,color:B.blue,data:C,onSelect:w=>y("ideas",w)})}),n.jsx("div",{onClick:()=>f("orders"),style:{cursor:"pointer"},children:n.jsx(Br,{title:p.dash.orders,color:B.purple,data:A,onSelect:w=>y("orders",w)})}),n.jsx("div",{onClick:()=>f("processes"),style:{cursor:"pointer"},children:n.jsx(Br,{title:p.dash.processes,color:B.red,data:T,onSelect:w=>y("processes",w)})})]}),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.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:10},children:p.dash.level2}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(kn,{items:c,type:"process",onNavigate:f}),n.jsx(kn,{items:v,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:p.dash.level1}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(kn,{items:b,type:"process",onNavigate:f}),n.jsx(kn,{items:g,type:"order",onNavigate:f})]})]}),h.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:[p.dash.overduePrefix,h.length,p.dash.overdueSuffix]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:h.map(w=>n.jsxs("div",{onClick:()=>f("incidents-form",w.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:w.number||w.name}),n.jsx("span",{style:{fontSize:12,color:"#666"},children:w.title}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:w.date})]},w.name))})]}),S.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:B.orange,marginBottom:8},children:[p.dash.untriaged," (",S.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:S.map(w=>n.jsxs("div",{onClick:()=>f("incidents-form",w.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:w.number||w.name}),n.jsx("span",{style:{fontSize:12,color:"#666"},children:w.title}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:w.date})]},w.name))})]})]})}function Ly({dashData:e,selectedOrg:t,onNavigate:l}){const s=V(),[r,i]=j.useState([]),[a,d]=j.useState([]),[u,f]=j.useState(!1),y=(e==null?void 0:e.escalated_processes)||[],p=(e==null?void 0:e.escalated_orders)||[],c=(e==null?void 0:e.attention_processes)||[],v=(e==null?void 0:e.attention_orders)||[],b=(e==null?void 0:e.kpi_inputs)||[];j.useEffect(()=>{f(!0);const h=new URLSearchParams({months:"6"});t&&h.append("organization",t),fetch(`/api/method/sidrah_business.api.get_process_trend?${h}`,{credentials:"include",headers:{Accept:"application/json"}}).then(m=>m.json()).then(m=>{const o=m.message||[],x={};for(const C of o)x[C.month]||(x[C.month]={pass:0,fail:0,unknown:0}),C.status==="Pass"?x[C.month].pass=C.count:C.status==="Fail"?x[C.month].fail=C.count:C.status==="Unknown"&&(x[C.month].unknown=C.count);i(Object.entries(x).map(([C,A])=>({month:C,...A})))}).catch(()=>{}).finally(()=>f(!1))},[t]),j.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(h=>h.json()).then(h=>{var m;d((((m=h.message)==null?void 0:m.rows)||[]).slice(0,50))}).catch(()=>{})},[t]);const g=y.length>0||p.length>0,S=c.length>0||v.length>0;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:[n.jsx(Nt,{label:"Manage Users & Roles",icon:"👥",onClick:()=>l("users")}),n.jsx(Nt,{label:"Change Active Cycle",icon:"🔄",onClick:()=>l("cycles")}),n.jsx(Nt,{label:"KPI Inputs",icon:"📈",onClick:()=>l("kpi-input")}),n.jsx(Nt,{label:"Reports",icon:"📊",onClick:()=>l("reports")}),n.jsx(Nt,{label:"Organizations",icon:"🏢",onClick:()=>l("organizations")})]}),b.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:10},children:s.dash.recentKpi}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12},children:b.map(h=>n.jsx(Ey,{kpi:h},h.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:s.dash.manageKpi})]}),g&&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 (",y.length+p.length,")"]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(kn,{items:y,type:"process",onNavigate:l}),n.jsx(kn,{items:p,type:"order",onNavigate:l})]})]}),S&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#b45309",marginBottom:10},children:["Needs Attention — Level 1 (",c.length+v.length,")"]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(kn,{items:c,type:"process",onNavigate:l}),n.jsx(kn,{items:v,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."}),u?n.jsx("p",{style:{color:"#aaa",fontSize:13},children:"Loading trend data…"}):n.jsx(Ay,{data:r})]}),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(h=>n.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#999",fontWeight:700,fontSize:11,whiteSpace:"nowrap"},children:h},h))})}),n.jsx("tbody",{children:a.map((h,m)=>n.jsxs("tr",{style:{borderTop:"1px solid #f0f0f0",background:m%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"8px 12px",color:"#555",whiteSpace:"nowrap"},children:h.timestamp?String(h.timestamp).slice(0,16):"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#333"},children:h.user||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#555"},children:h.entity_type||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#555"},children:h.entity_name||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#888",maxWidth:240,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.changes||"—"})]},m))})]})}),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 Oy({incidents:e,ideas:t,orders:l,processes:s,organizations:r,incidentStatuses:i,ideaStatuses:a,orderStatuses:d,processStatuses:u,selectedOrg:f,onOrgChange:y,onNavigate:p,onNavigateStatus:c,userRole:v}){const[b,g]=j.useState(null);j.useEffect(()=>{my(f).then(g)},[f]);const S=f?e.filter(_=>_.organization===f):e,h=f?t.filter(_=>_.organization===f):t,m=f?l.filter(_=>_.organization===f):l,o=f?s.filter(_=>_.organization===f):s,x=v==="Admin",C=v==="Owner",[A,T]=j.useState("level1"),w=C||x&&A==="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(Et,{value:f,onChange:y,organizations:r,placeholder:"All Organizations",small:!0})}),x&&n.jsx("div",{style:{display:"flex",background:"#f1f0fe",borderRadius:7,padding:2,gap:2,flexShrink:0},children:["level1","level2"].map(_=>n.jsx("button",{onClick:()=>T(_),style:{padding:"4px 10px",borderRadius:5,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:A===_?_==="level2"?B.purple:B.blue:"transparent",color:A===_?"white":"#6b7280",transition:"all 0.15s"},children:_==="level1"?"Level 1":"Level 2"},_))}),!x&&n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"white",background:w?B.purple:B.blue,padding:"3px 10px",borderRadius:20,flexShrink:0},children:w?"Level 2 — Owner":"Level 1 — Operational"})]}),w?n.jsx(Ly,{dashData:b,selectedOrg:f,onNavigate:p}):n.jsx(Ry,{dashData:b,fi:S,fid:h,fo:m,fp:o,incidentStatuses:i,ideaStatuses:a,orderStatuses:d,processStatuses:u,onNavigate:p,onNavigateStatus:c})]})}const Dy=()=>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"})]}),Ny=()=>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"})]}),Wy=()=>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 Je({onView:e,onEdit:t,onDelete:l}){const[s,r]=j.useState(!1),i=(d,u,f,y,p)=>f?n.jsx("button",{onClick:c=>{c.stopPropagation(),f()},title:p,style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:d,color:u,flexShrink:0,transition:"opacity 0.15s"},onMouseEnter:c=>c.currentTarget.style.opacity="0.75",onMouseLeave:c=>c.currentTarget.style.opacity="1",children:y},p):null,a=l?()=>{s?(r(!1),l()):r(!0)}:void 0;return n.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[i("#e0f7fa","#0891b2",e,n.jsx(Dy,{}),"View"),i("#dcfce7","#16a34a",t,n.jsx(Ny,{}),"Edit"),l&&n.jsx("button",{onClick:d=>{d.stopPropagation(),a==null||a()},title:s?"Click again to confirm delete":"Delete",style:{minWidth:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:s?8:"50%",padding:s?"0 8px":0,border:"none",cursor:"pointer",background:s?"#ef4444":"#fee2e2",color:s?"white":"#ef4444",flexShrink:0,fontSize:s?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:()=>r(!1),children:s?"✓ Sure?":n.jsx(Wy,{})})]})}const E={width:"100%",height:34,padding:"7px 10px",border:"1px solid #ddd",borderRadius:6,fontSize:12,boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif"},z={display:"block",marginBottom:5,fontSize:11,color:"#555",fontWeight:600};function By(e){return typeof(e==null?void 0:e.is_active)<"u"?!!e.is_active:typeof(e==null?void 0:e.status)<"u"?e.status!=="Inactive":typeof(e==null?void 0:e.custom_status)<"u"?e.custom_status!=="Inactive":!0}function fe(e,t){return e.filter(l=>By(l)||l.name===t)}function Ql(e,t,l){return e.filter(s=>{const r=t[s.name]||[];return r.includes("SB Admin")||r.includes("System Manager")?!1:r.includes(l)})}const Gl={width:16,height:16,cursor:"pointer",accentColor:"#2563eb",flexShrink:0},On=(e,t)=>n.jsx("span",{style:{background:t,color:"white",padding:"4px 12px",borderRadius:12,fontSize:12,fontWeight:600,display:"inline-block"},children:e}),Ki=e=>{switch(e){case"New":return"#e74c3c";case"Under Progress":return"#f39c12";case"Executed":return"#27ae60";case"Overdue":return"#7f1d1d";default:return"#95a5a6"}},$e={fontSize:10,color:"#6b7280",fontWeight:600,marginBottom:3,display:"block",textTransform:"uppercase",letterSpacing:.4},Ue={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 Qi({children:e}){const[t,l]=j.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(s=>!s),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 ne=20,lu=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 Fe({page:e,pageSize:t=ne,total:l,onPageChange:s}){if(l===0)return null;const r=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:()=>s(e-1),style:lu(e<=1),children:"Previous"}),n.jsx("button",{disabled:e>=r,onClick:()=>s(e+1),style:lu(e>=r),children:"Next"})]})]})}function $y({incidents:e,organizations:t,departments:l,branches:s,incidentStatuses:r,initialOrg:i,initialStatus:a,canModify:d,onView:u,onEdit:f,onDelete:y}){const p=V(),[c,v]=j.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),b=(o,x)=>v(C=>({...C,[o]:x})),[g,S]=j.useState(1),h=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));j.useEffect(()=>{S(1)},[c]);const m=h.slice((g-1)*ne,g*ne);return n.jsxs(n.Fragment,{children:[n.jsx(Qi,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.numberTitle}),n.jsx("input",{style:Ue,value:c.search,onChange:o=>b("search",o.target.value),placeholder:p.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.organization}),n.jsxs("select",{style:Ue,value:c.organization,onChange:o=>b("organization",o.target.value),children:[n.jsx("option",{value:"",children:p.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:$e,children:p.filter.department}),n.jsxs("select",{style:Ue,value:c.department,onChange:o=>b("department",o.target.value),children:[n.jsx("option",{value:"",children:p.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:$e,children:p.filter.branch}),n.jsxs("select",{style:Ue,value:c.branch,onChange:o=>b("branch",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allBranches}),s.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.status}),n.jsxs("select",{style:Ue,value:c.status,onChange:o=>b("status",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allStatuses}),r.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:()=>v({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:p.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.number}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.title}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.type}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.actions})]})}),n.jsx("tbody",{children:h.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:p.noIncidents})}):m.map((o,x)=>n.jsxs("tr",{onClick:()=>u==null?void 0:u(o),style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",color:"#999"},children:o.number||"—"}),n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.title||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.type?On(o.type,"#e74c3c"):"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.status?On(o.status,Ki(o.status)):"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:C=>C.stopPropagation(),children:n.jsx(Je,{onView:()=>u==null?void 0:u(o),onEdit:d&&f?()=>f(o):void 0,onDelete:d&&y?()=>y(o.name):void 0})})]},o.name))})]})}),n.jsx(Fe,{page:g,total:h.length,onPageChange:S})]})}function Uy(e){if(!e)return"";const[t,l,s]=e.split("-");return!t||!l||!s?"":`${s}/${l}/${t}`}function me({value:e,onChange:t,disabled:l,style:s,min:r,max:i}){return n.jsxs("div",{style:{position:"relative",width:"100%"},children:[n.jsx("input",{type:"text",readOnly:!0,tabIndex:-1,value:Uy(e),placeholder:"DD/MM/YYYY",style:{...s,pointerEvents:"none",paddingRight:30}}),n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke: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:r,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 Fy({title:e,children:t}){return n.jsxs("div",{style:{background:"white",borderRadius:10,padding:"18px 20px",marginBottom:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[e&&n.jsx("div",{style:{fontSize:15,fontWeight:700,marginBottom:16,color:"#1e1b4b"},children:e}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:13},children:t})]})}const su={"SB Process":"processes-form","SB Order":"orders-form","SB Incident":"incidents-form","SB Idea":"ideas-form","SB Delegation":"delegations"};function My(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 Uf({notifCount:e,darkMode:t,onCountChange:l,onToggleDark:s,onViewProfile:r,onLogout:i,onNavigate:a}){const[d,u]=j.useState(!1),[f,y]=j.useState([]),[p,c]=j.useState(!1),v=j.useRef(null);j.useEffect(()=>{const w=_=>{v.current&&!v.current.contains(_.target)&&u(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]);const b=async()=>{c(!0);const w=await iy(30);y(w),c(!1)},g=()=>{const w=!d;u(w),w&&b()},S=async()=>{await ay(),y(w=>w.map(_=>({..._,read:1}))),l(0)},h=w=>{w.read||(oy(w.name),y(U=>U.map(P=>P.name===w.name?{...P,read:1}:P)),l(Math.max(0,e-1)));const _=w.document_type?su[w.document_type]:void 0;_&&a&&(a(_,w.document_type==="SB Delegation"?void 0:w.document_name),u(!1))},m=f.filter(w=>!w.read).length,o=w=>({position:"relative",width:34,height:34,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:t?"#2d3748":"#f3f4f6",color:t?"#e2e8f0":"#6b7280",fontSize:14,transition:"background 0.15s",flexShrink:0,...w}),x=t,C=x?"#1a202c":"white",A=x?"#2d3748":"#e5e7eb",T=x?"#e2e8f0":"#1a2332";return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx("button",{style:o({background:"#4f46e5",color:"white"}),onClick:r,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:v,style:{position:"relative"},children:[n.jsxs("button",{style:o(),onClick:g,title:"Notifications",children:[n.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),n.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),e>0&&n.jsx("span",{style:{position:"absolute",top:2,right:2,background:"#ef4444",color:"white",fontSize:9,fontWeight:700,borderRadius:999,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 3px",lineHeight:1},children:e>9?"9+":e})]}),d&&n.jsxs("div",{style:{position:"absolute",right:0,top:"calc(100% + 8px)",width:340,background:C,borderRadius:12,boxShadow:"0 8px 32px rgba(0,0,0,0.2)",zIndex:1e4,border:`1px solid ${A}`,overflow:"hidden"},children:[n.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${A}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:C},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:T},children:["Notifications",m>0&&n.jsxs("span",{style:{background:"#ef4444",color:"white",fontSize:10,fontWeight:700,borderRadius:999,padding:"2px 7px"},children:[m," new"]})]}),m>0&&n.jsx("button",{onClick:S,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:[p&&n.jsx("div",{style:{padding:20,textAlign:"center",color:"#aaa",fontSize:13},children:"Loading…"}),!p&&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"})]}),!p&&f.map(w=>{const _=!!(w.document_type&&su[w.document_type]&&a);return n.jsxs("div",{onClick:()=>h(w),style:{padding:"11px 16px",borderBottom:`1px solid ${x?"#2d3748":"#f5f5f5"}`,display:"flex",gap:10,background:w.read?C:x?"#1e3a5f":"#eff6ff",cursor:_?"pointer":"default",transition:"background 0.12s"},onMouseEnter:U=>{_&&(U.currentTarget.style.background=x?"#243244":"#e0ecfd")},onMouseLeave:U=>{U.currentTarget.style.background=w.read?C:x?"#1e3a5f":"#eff6ff"},children:[n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:13,fontWeight:w.read?400:600,color:T,marginBottom:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.subject||`${w.document_type}: ${w.document_name}`}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:w.document_type&&n.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#3b82f6",background:x?"rgba(59,130,246,0.15)":"#eff6ff",padding:"1px 7px",borderRadius:8},children:[w.document_type.replace("SB ",""),w.document_name?` · ${w.document_name}`:""]})}),n.jsx("div",{style:{fontSize:11,color:"#aaa",marginTop:3},children:My(w.creation)})]}),!w.read&&n.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:"#3498db",flexShrink:0,marginTop:5}})]},w.name)})]})]})]}),n.jsx("button",{style:o(),onClick:Df,title:Al()?"Switch to English":"Switch to Arabic",children:n.jsx("span",{style:{fontSize:13,fontWeight:700,fontFamily:"serif"},children:"عA"})}),n.jsx("button",{style:o(),onClick:s,title:t?"Light mode":"Dark mode",children:t?n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"5"}),n.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),n.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),n.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),n.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),n.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),n.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),n.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),n.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}),n.jsx("button",{style:o({background:x?"#3d1515":"#fee2e2",color:"#ef4444"}),onClick:i,title:"Logout",children:n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),n.jsx("polyline",{points:"16,17 21,12 16,7"}),n.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]})})]})}function Me({title:e,activePage:t,user:l,formStatus:s,buttonText:r,buttonColor:i,viewMode:a,onEdit:d,hideSettings:u,rightPanel:f,darkMode:y,notifCount:p,onToggleDark:c,onCountChange:v,onViewProfile:b,onSubmit:g,onBack:S,onNavigate:h,onLogout:m,children:o}){const x=V(),C=x.nav[t]||t,A=l.role,T=A==="Admin"||A==="Owner"||A==="Auditor"||A==="Manager",w=A==="Admin"||A==="Owner"||A==="Auditor"||A==="Manager",_=A==="Admin"||A==="Auditor"||A==="Manager",U=T?"dashboard":"inbox",[P,I]=j.useState(()=>localStorage.getItem("sb_sidebar")==="1"),N=()=>I(M=>{const Z=!M;return localStorage.setItem("sb_sidebar",Z?"1":"0"),Z});return n.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:B.bg},children:[n.jsx(Lf,{collapsed:P,onToggleCollapsed:N,activePage:t,onNavigate:h,hasDashboard:T,hasReports:w,hasDelegations:_,role:A,hideSettings:u,rtl:x.rtl,navLabels:x.nav,settingsLabel:x.nav.settings}),n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[n.jsxs("div",{style:{background:"white",padding:"10px 20px",borderBottom:"1px solid #e9eaf0",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,boxShadow:"0 1px 4px rgba(0,0,0,0.04)"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[n.jsx("button",{onClick:S,title:x.back,style:{width:30,height:30,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"1.5px solid #e5e7eb",background:"white",cursor:"pointer",color:"#4f46e5",flexShrink:0},children:n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"15 18 9 12 15 6"})})}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:15,fontWeight:700,color:"#1e1b4b"},children:e}),n.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:1},children:[n.jsx("span",{onClick:()=>h(U),style:{cursor:"pointer",color:"#4f46e5"},onMouseEnter:M=>M.currentTarget.style.textDecoration="underline",onMouseLeave:M=>M.currentTarget.style.textDecoration="none",children:x.home}),!u&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{margin:"0 4px"},children:"/"}),n.jsx("span",{onClick:S,style:{cursor:"pointer",color:"#4f46e5"},onMouseEnter:M=>M.currentTarget.style.textDecoration="underline",onMouseLeave:M=>M.currentTarget.style.textDecoration="none",children:C})]})]})]})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[a&&d&&n.jsxs("button",{onClick:d,style:{display:"flex",alignItems:"center",gap:6,padding:"7px 16px",borderRadius:7,border:"none",background:"#4f46e5",color:"white",cursor:"pointer",fontSize:13,fontWeight:600,fontFamily:"Segoe UI"},children:[n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),x.edit]}),n.jsx(Uf,{notifCount:p,darkMode:y,onCountChange:v,onToggleDark:c,onNavigate:h,onViewProfile:b,onLogout:m})]})]}),n.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px",display:"grid",gridTemplateColumns:f?"1fr auto":"1fr",gap:14,alignItems:"start"},children:[n.jsx("div",{style:{minWidth:0},children:n.jsxs(Fy,{children:[o,!a&&n.jsxs("div",{style:{display:"flex",gap:10,marginTop:20},children:[n.jsx("button",{onClick:S,style:{padding:"9px 22px",borderRadius:8,border:"1.5px solid #e5e7eb",cursor:"pointer",fontSize:13,fontWeight:600,background:"white",color:"#374151",fontFamily:"Segoe UI"},children:x.cancel}),n.jsx("button",{onClick:g,disabled:s==="loading",style:{padding:"9px 22px",borderRadius:8,background:i,color:"white",border:"none",cursor:"pointer",fontSize:13,fontWeight:600,opacity:s==="loading"?.7:1,boxShadow:"0 2px 10px rgba(79,70,229,0.18)",fontFamily:"Segoe UI"},children:s==="loading"?x.saving:r})]}),s==="success"&&n.jsx("div",{style:{padding:"10px",borderRadius:8,background:"#f0fdf4",border:"1px solid #86efac",color:"#166534",fontSize:13,marginTop:10},children:x.savedOk}),s!=="idle"&&s!=="loading"&&s!=="success"&&n.jsx("div",{style:{padding:"10px",borderRadius:8,background:"#fef2f2",border:"1px solid #fca5a5",color:"#991b1b",fontSize:13,marginTop:10},children:s})]})}),f&&n.jsx("div",{style:{position:"sticky",top:0,alignSelf:"start"},children:f})]})]})]})}function ue({value:e,onChange:t,items:l,placeholder:s="-- Select --",disabled:r=!1}){var p;const[i,a]=j.useState(!1),[d,u]=j.useState(""),f=j.useRef(null);j.useEffect(()=>{const c=v=>{f.current&&!f.current.contains(v.target)&&a(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[]);const y=e?((p=l.find(c=>c.name===e))==null?void 0:p.label)??e:s;return n.jsxs("div",{ref:f,style:{position:"relative",width:"100%"},children:[n.jsxs("div",{onClick:()=>!r&&a(c=>!c),style:{width:"100%",height:34,padding:"7px 10px",border:"1px solid",borderColor:i?"#3498db":"#ddd",borderRadius:6,fontSize:12,cursor:r?"default":"pointer",background:r?"#f5f5f5":"white",color:e?"#333":"#aaa",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"border-color 0.2s",userSelect:"none",boxSizing:"border-box",opacity:r?.75:1},children:[n.jsx("span",{children:y}),n.jsx("span",{style:{fontSize:9,color:"#999",transform:i?"rotate(180deg)":"none",transition:"transform 0.2s"},children:"▼"})]}),i&&n.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:9999,background:"white",border:"1px solid #e0e0e0",borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",overflow:"hidden"},children:n.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[n.jsx("div",{onClick:()=>{t(""),a(!1)},onMouseEnter:()=>u("__placeholder"),onMouseLeave:()=>u(""),style:{padding:"8px 14px",cursor:"pointer",fontSize:12,color:"#aaa",background:d==="__placeholder"?"#f5f5f5":"transparent"},children:s}),l.length===0&&n.jsx("div",{style:{padding:"10px 14px",color:"#aaa",fontSize:12},children:"No records found"}),l.map(c=>n.jsx("div",{onClick:()=>{t(c.name),a(!1)},onMouseEnter:()=>u(c.name),onMouseLeave:()=>u(""),style:{padding:"8px 14px",cursor:"pointer",fontSize:12,background:e===c.name?"#2563eb":d===c.name?"#f0f4ff":"transparent",color:e===c.name?"white":"#1a2332",transition:"background 0.1s"},children:c.label},c.name))]})})]})}function Hy(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 Ky(e){return e.replace(/@.*/,"").replace(/[._-]/g," ").split(" ").filter(Boolean).slice(0,2).map(l=>l[0].toUpperCase()).join("")}function Gi({doctype:e,docname:t,currentUserName:l}){const s=V(),[r,i]=j.useState([]),[a,d]=j.useState(!1),[u,f]=j.useState(""),[y,p]=j.useState(!1),[c,v]=j.useState(!1),[b,g]=j.useState(!1),[S,h]=j.useState(""),m=5,o=j.useCallback(async()=>{d(!0);const w=await dy(e,t);i(w),d(!1)},[e,t]);j.useEffect(()=>{o()},[o]);const x=async()=>{const w=u.trim();if(!(!w||y)){p(!0),h("");try{await uy(e,t,w),f(""),await o()}catch{h("Failed to post comment. Please try again.")}p(!1)}},C=async w=>{if(window.confirm("Delete this comment?"))try{await Nf("Comment",w),i(_=>_.filter(U=>U.name!==w))}catch{alert("Failed to delete comment.")}},A=b?r:r.slice(-m),T=Math.max(0,r.length-m);return n.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[n.jsxs("div",{onClick:()=>v(w=>!w),style:{padding:"12px 20px",borderBottom:c?"none":"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none",background:"white"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:"#1a2332"},children:["💬 ",s.comments.title,r.length>0&&n.jsx("span",{style:{background:"#e8f4fd",color:"#2980b9",fontSize:11,fontWeight:700,borderRadius:10,padding:"2px 8px"},children:r.length})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx("button",{onClick:w=>{w.stopPropagation(),o()},style:{background:"none",border:"none",cursor:"pointer",color:"#aaa",fontSize:16,padding:"2px 4px",lineHeight:1},title:"Refresh",children:"↻"}),n.jsx("span",{style:{color:"#ccc",fontSize:11},children:c?"▼":"▲"})]})]}),!c&&n.jsxs("div",{style:{padding:"16px 20px"},children:[!b&&T>0&&n.jsxs("button",{onClick:()=>g(!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 ",T," older comment",T!==1?"s":""]}),a&&n.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:s.loading}),!a&&r.length===0&&n.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:s.comments.noComments}),!a&&A.length>0&&n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:16},children:A.map(w=>{const _=w.comment_by||w.comment_email||w.owner||"Unknown",U=w.owner===l||w.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:Ky(_)}),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:_}),n.jsx("span",{style:{fontSize:11,color:"#aaa"},children:Hy(w.creation)})]}),U&&n.jsx("button",{onClick:()=>C(w.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:w.content||""}})]})]},w.name)})}),n.jsxs("div",{style:{borderTop:r.length>0?"1px solid #f0f0f0":"none",paddingTop:r.length>0?14:0},children:[n.jsx("textarea",{value:u,onChange:w=>f(w.target.value),onKeyDown:w=>{w.key==="Enter"&&(w.ctrlKey||w.metaKey)&&x()},placeholder:s.comments.placeholder,rows:3,style:{width:"100%",padding:"10px 12px",border:"1px solid #ddd",borderRadius:8,fontSize:13,fontFamily:"Segoe UI",resize:"vertical",boxSizing:"border-box",outline:"none",color:"#1a2332"}}),S&&n.jsx("div",{style:{fontSize:12,color:"#e74c3c",marginTop:4},children:S}),n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:n.jsx("button",{onClick:x,disabled:!u.trim()||y,style:{padding:"8px 20px",background:"#3498db",color:"white",border:"none",borderRadius:6,cursor:!u.trim()||y?"not-allowed":"pointer",fontSize:13,fontWeight:600,fontFamily:"Segoe UI",opacity:!u.trim()||y?.6:1},children:y?s.saving:s.comments.post})})]})]})]})}function ru(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 Qy(e){return(e||"").replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function iu(e){return e==null||e===""?"(empty)":typeof e=="object"?JSON.stringify(e):String(e)}function zo(e){return(e||"Unknown").replace(/@.*/,"").replace(/[._]/g," ")}function au(e){return zo(e).split(" ").filter(Boolean).slice(0,2).map(t=>t[0].toUpperCase()).join("")}function Gy(e){let t={};try{t=JSON.parse(e.data||"{}")}catch{}const l=(t.changed||[]).map(s=>({field:s[0]||"",oldVal:iu(s[1]),newVal:iu(s[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 Yi({doctype:e,docname:t,docCreation:l,docOwner:s}){const r=V(),[i,a]=j.useState([]),[d,u]=j.useState(!1),[f,y]=j.useState(!0),[p,c]=j.useState(!1),v=5,b=j.useCallback(async()=>{u(!0);const m=await py(e,t);a(m.map(Gy)),u(!1)},[e,t]);j.useEffect(()=>{f||b()},[f,b]);const g=p?i:i.slice(0,v),S=i.length-v,h=(m,o=!1)=>({position:"absolute",left:-14,top:14,width:10,height:10,borderRadius:"50%",background:m,border:"2px solid white",boxShadow:o?`0 0 0 2px ${m}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:()=>y(m=>!m),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:["📋 ",r.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:m=>{m.stopPropagation(),b()},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:r.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:[g.map((m,o)=>n.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[n.jsx("div",{style:h(o===0?"#3498db":"#d1d5db",o===0)}),n.jsxs("div",{style:{background:o===0?"#eff6ff":"#f9fafb",border:`1px solid ${o===0?"#bfdbfe":"#e5e7eb"}`,borderRadius:8,padding:"10px 14px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[n.jsx("div",{style:{width:26,height:26,borderRadius:"50%",background:"#3498db",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flexShrink:0},children:au(m.owner)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:zo(m.owner)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:ru(m.creation)})]}),m.changes.length>0?n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:m.changes.map((x,C)=>n.jsxs("div",{style:{fontSize:12,lineHeight:1.5},children:[n.jsx("span",{style:{fontWeight:600,color:"#6d28d9"},children:Qy(x.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:x.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:x.newVal})]},C))}):n.jsxs("div",{style:{fontSize:12,color:"#9ca3af",fontStyle:"italic"},children:["Document updated",m.added>0&&n.jsxs("span",{children:[" · +",m.added," row(s)"]}),m.removed>0&&n.jsxs("span",{children:[" · -",m.removed," row(s)"]}),m.rowChanged>0&&n.jsxs("span",{children:[" · ~",m.rowChanged," row(s) modified"]})]})]})]},m.name)),l&&s&&n.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[n.jsx("div",{style:h("#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:au(s)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:zo(s)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:ru(l)})]}),n.jsxs("div",{style:{fontSize:12,color:"#15803d",fontWeight:600},children:["✓ ",r.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&&S>0&&n.jsx("div",{style:{textAlign:"center",marginTop:12},children:n.jsx("button",{onClick:()=>c(m=>!m),style:{background:"none",border:"none",cursor:"pointer",color:"#3498db",fontSize:12,fontFamily:"Segoe UI",padding:"4px 8px"},children:p?"▲ Show less":`▼ Show all (${i.length})`})})]})]})}const xs={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Ta={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},Yy={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 Xy(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...Yy[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function qy({incForm:e,setIncForm:t,organizations:l,managements:s,departments:r,branches:i,incidentTypes:a,incidentClasses:d,incidentFields:u,incidentStatuses:f,users:y,userRoleMap:p={},formStatus:c,viewMode:v,onEdit:b,darkMode:g,notifCount:S,onToggleDark:h,onCountChange:m,onViewProfile:o,userRole:x,onSubmit:C,onBack:A,onNavigate:T,onLogout:w,user:_,onRefresh:U}){const P=V(),I=R=>t({...e,...R}),N=v?{background:"#f9f9f9"}:{},M=Ql(y,p,"SB Employee"),Z=Ql(y,p,"SB Manager"),[ge,le]=j.useState(""),[L,K]=j.useState(!1),G=e.name?v?`${P.formTitle.viewIncident}${e.number||e.name}`:P.formTitle.editIncident:P.formTitle.newIncident,ee=fe(s,e.management).map(R=>({name:R.name,label:R.name1||R.name})),J=fe(r,e.department).map(R=>({name:R.name,label:R.department_name||R.name})),xe=fe(i,e.branch).map(R=>({name:R.name,label:R.branch||R.name})),_e=fe(a,e.type).map(R=>({name:R.name,label:R.name1||R.name})),re=d.map(R=>({name:R.name,label:R.name1||R.name})),Ce=u.map(R=>({name:R.name,label:R.name1||R.name})),Oe=fe(f,e.status).map(R=>({name:R.name,label:R.name1||R.name})),H=e.workflow_state||"New",se=x==="Employee",D=x==="Auditor"||x==="Admin",te=x==="Manager",hn=e.name?H==="New"?[{label:P.wf.submit,action:"Submit",color:"#2563eb"}]:H==="Initial Evaluation"&&D?[{label:P.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:P.wf.reject,action:"Reject",color:"#dc2626"}]:H==="Accept & Under Progress"&&(te||D)?[{label:P.wf.submitSolution,action:"Submit Solution",color:"#059669"}]:H==="working on resolution"&&(te||D)?[{label:P.wf.resolutionComplete,action:"Resolution complete",color:"#166534"}]:[]:[];async function gt(R){if(e.name){K(!0),le("");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 Solution"&&(e.solution&&(Q.solution=e.solution),e.summary&&(Q.summary=e.summary),e.cost&&(Q.cost=String(e.cost))),(R==="Resolution complete"||R==="Submit Solution")&&e.auditor_comment&&(Q.auditor_comment=e.auditor_comment),await gy(e.name,R,JSON.stringify(Q)),le("Done"),U==null||U()}catch(Q){le(Q.message||"Error")}finally{K(!1)}}}const O=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:P.wf.workflow}),n.jsx("span",{style:Xy(H),children:H})]}),H==="Initial Evaluation"&&D&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:z,children:P.wf.assignToManager}),n.jsxs("select",{style:E,value:e.assigned_to||"",onChange:R=>I({assigned_to:R.target.value}),children:[n.jsx("option",{value:"",children:P.field.selectMgr}),Z.map(R=>n.jsx("option",{value:R.name,children:R.full_name||R.name},R.name))]})]}),(H==="Accept & Under Progress"||H==="working on resolution")&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:z,children:P.field.solution}),n.jsx("textarea",{style:{...E,height:80,resize:"vertical"},value:e.solution||"",onChange:R=>I({solution:R.target.value}),placeholder:P.field.solutionPlaceholder}),n.jsx("label",{style:{...z,marginTop:8},children:P.field.actualCost}),n.jsx("input",{type:"number",style:E,value:e.cost||"",onChange:R=>I({cost:parseFloat(R.target.value)||0}),placeholder:"0.00"})]}),H==="working on resolution"&&D&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:z,children:P.field.auditorComment}),n.jsx("textarea",{style:{...E,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:R=>I({auditor_comment:R.target.value}),placeholder:P.field.commentPlaceholder})]}),hn.length>0?n.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:hn.map(R=>n.jsx("button",{onClick:()=>gt(R.action),disabled:L,style:{padding:"8px 18px",borderRadius:8,border:"none",background:R.color,color:"white",fontWeight:700,cursor:L?"not-allowed":"pointer",opacity:L?.7:1},children:L?P.wf.applying:R.label},R.action))}):n.jsx("div",{style:{fontSize:12,color:"#94a3b8",fontStyle:"italic"},children:P.wf.noActions}),ge&&n.jsx("p",{style:{marginTop:8,fontSize:13,color:ge==="Done"?B.green:B.red},children:ge})]}),n.jsx(Gi,{doctype:$.incidents,docname:e.name,currentUserName:_.name}),n.jsx(Yi,{doctype:$.incidents,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):null;return n.jsxs(Me,{title:G,activePage:"incidents",user:_,formStatus:c,buttonText:P.saveIncident,buttonColor:B.accent,viewMode:v,onEdit:b,darkMode:g,notifCount:S,onToggleDark:h,onCountChange:m,onViewProfile:o,rightPanel:O,onSubmit:C,onBack:A,onNavigate:T,onLogout:w,children:[n.jsxs("div",{style:xs,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.number}),n.jsx("input",{style:{...E,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[P.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.organization,onChange:R=>I({organization:R}),organizations:l,disabled:v||!!_.custom_organization})]})]}),n.jsxs("div",{style:Ta,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.management}),n.jsx(ue,{value:e.management,onChange:R=>I({management:R}),items:ee,placeholder:P.field.select,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.department}),n.jsx(ue,{value:e.department,onChange:R=>I({department:R}),items:J,placeholder:P.field.select,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.section}),n.jsx("input",{style:{...E,...N},value:e.section_field||"",disabled:v,onChange:R=>I({section_field:R.target.value})})]})]}),n.jsxs("div",{style:xs,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.branch}),n.jsx(ue,{value:e.branch,onChange:R=>I({branch:R}),items:xe,placeholder:P.field.select,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.hsesField}),n.jsx("input",{style:{...E,...N},value:e.hses_field||"",disabled:v,onChange:R=>I({hses_field:R.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{style:xs,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.type}),n.jsx(ue,{value:e.type,onChange:R=>I({type:R}),items:_e,placeholder:P.field.selectType,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.title}),n.jsx("input",{style:{...E,...N},value:e.title,disabled:v,onChange:R=>I({title:R.target.value})})]})]}),n.jsxs("div",{style:xs,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.incidentClass}),n.jsx(ue,{value:e.incident_class,onChange:R=>I({incident_class:R}),items:re,placeholder:P.field.selectClass,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.incidentField}),n.jsx(ue,{value:e.incident_field,onChange:R=>I({incident_field:R}),items:Ce,placeholder:P.field.selectField,disabled:v})]})]}),n.jsxs("div",{style:Ta,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.date}),n.jsx(me,{value:e.date,onChange:R=>I({date:R}),disabled:v,style:{...E,...N}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.time}),n.jsx("input",{type:"time",style:{...E,...N},value:e.time,disabled:v,onChange:R=>I({time:R.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.assignedTo}),n.jsxs("select",{style:{...E,...N},value:e.assigned_to,disabled:v,onChange:R=>I({assigned_to:R.target.value}),children:[n.jsx("option",{value:"",children:P.field.select}),M.map(R=>n.jsx("option",{value:R.name,children:R.full_name||R.name},R.name))]})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.status}),n.jsx(ue,{value:e.status,onChange:R=>I({status:R}),items:Oe,placeholder:P.field.selectStatus,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.description}),n.jsx("textarea",{style:{...E,...N,height:120,resize:"vertical"},value:e.description,disabled:v,onChange:R=>I({description:R.target.value})})]}),!se&&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:P.steps.auditorTriage}),n.jsxs("div",{style:Ta,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.priority}),n.jsxs("select",{style:{...E,...v&&!D?{background:"#f9f9f9"}:{}},value:e.priority||"",disabled:v&&!D,onChange:R=>I({priority:R.target.value}),children:[n.jsx("option",{value:"",children:P.field.select}),n.jsx("option",{value:"High",children:P.field.high}),n.jsx("option",{value:"Normal",children:P.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.economyClass}),n.jsxs("select",{style:{...E,...v&&!D?{background:"#f9f9f9"}:{}},value:e.economy_class||"",disabled:v&&!D,onChange:R=>I({economy_class:R.target.value}),children:[n.jsx("option",{value:"",children:P.field.select}),n.jsx("option",{value:"Expenses",children:P.field.expenses}),n.jsx("option",{value:"Capital",children:P.field.capital}),n.jsx("option",{value:"Earn",children:P.field.earn}),n.jsx("option",{value:"Pay/Loss",children:P.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.entityScope}),n.jsxs("select",{style:{...E,...v&&!D?{background:"#f9f9f9"}:{}},value:e.entity_scope||"",disabled:v&&!D,onChange:R=>I({entity_scope:R.target.value}),children:[n.jsx("option",{value:"",children:P.field.select}),n.jsx("option",{value:"Upstream",children:P.field.upstream}),n.jsx("option",{value:"On-stream",children:P.field.onstream}),n.jsx("option",{value:"Downstream",children:P.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:v&&!D,onChange:R=>I({product_relation:R.target.checked?1:0})})," ",P.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:v&&!D,onChange:R=>I({repeated:R.target.checked?1:0})})," ",P.field.repeatedEvent]})]})]}),!se&&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:P.steps.managerSolution}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.solution}),n.jsx("textarea",{style:{...E,height:100,resize:"vertical",...v&&!te&&!D?{background:"#f9f9f9"}:{}},value:e.solution||"",disabled:v&&!te&&!D,onChange:R=>I({solution:R.target.value}),placeholder:P.field.solutionPlaceholder})]}),n.jsxs("div",{style:xs,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.actualCost}),n.jsx("input",{type:"number",style:{...E,...v&&!te&&!D?{background:"#f9f9f9"}:{}},value:e.cost||"",disabled:v&&!te&&!D,onChange:R=>I({cost:parseFloat(R.target.value)||0}),placeholder:"0.00"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.summary}),n.jsx("input",{style:{...E,...v&&!te&&!D?{background:"#f9f9f9"}:{}},value:e.summary||"",disabled:v&&!te&&!D,onChange:R=>I({summary:R.target.value}),placeholder:"Brief summary"})]})]})]}),!se&&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:P.steps.ownerComment}),n.jsx("textarea",{style:{...E,height:80,resize:"vertical",...v&&!D?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:v&&!D,onChange:R=>I({auditor_comment:R.target.value}),placeholder:P.field.commentPlaceholder})]})]})}function Jy({ideas:e,organizations:t,departments:l,branches:s,ideaStatuses:r,initialOrg:i,initialStatus:a,canModify:d,onView:u,onEdit:f,onDelete:y}){const p=V(),[c,v]=j.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),b=(o,x)=>v(C=>({...C,[o]:x})),[g,S]=j.useState(1),h=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));j.useEffect(()=>{S(1)},[c]);const m=h.slice((g-1)*ne,g*ne);return n.jsxs(n.Fragment,{children:[n.jsx(Qi,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.numberTitle}),n.jsx("input",{style:Ue,value:c.search,onChange:o=>b("search",o.target.value),placeholder:p.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.organization}),n.jsxs("select",{style:Ue,value:c.organization,onChange:o=>b("organization",o.target.value),children:[n.jsx("option",{value:"",children:p.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:$e,children:p.filter.department}),n.jsxs("select",{style:Ue,value:c.department,onChange:o=>b("department",o.target.value),children:[n.jsx("option",{value:"",children:p.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:$e,children:p.filter.branch}),n.jsxs("select",{style:Ue,value:c.branch,onChange:o=>b("branch",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allBranches}),s.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.status}),n.jsxs("select",{style:Ue,value:c.status,onChange:o=>b("status",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allStatuses}),r.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:()=>v({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:p.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.number}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.title}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.actions})]})}),n.jsx("tbody",{children:h.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:p.noIdeas})}):m.map((o,x)=>n.jsxs("tr",{onClick:()=>u==null?void 0:u(o),style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",color:"#999"},children:o.number||"—"}),n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.title||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.status?On(o.status,Ki(o.status)):"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:C=>C.stopPropagation(),children:n.jsx(Je,{onView:()=>u==null?void 0:u(o),onEdit:d&&f?()=>f(o):void 0,onDelete:d&&y?()=>y(o.name):void 0})})]},o.name))})]})}),n.jsx(Fe,{page:g,total:h.length,onPageChange:S})]})}const ou={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Pa={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},Zy={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 Vy(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...Zy[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function e0({ideaForm:e,setIdeaForm:t,organizations:l,managements:s,departments:r,branches:i,ideaTypes:a,ideaStatuses:d,users:u=[],userRoleMap:f={},formStatus:y,viewMode:p,onEdit:c,darkMode:v,notifCount:b,onToggleDark:g,onCountChange:S,onViewProfile:h,userRole:m,onSubmit:o,onBack:x,onNavigate:C,onLogout:A,user:T,onRefresh:w}){const _=V(),U=D=>t({...e,...D}),P=p?{background:"#f9f9f9"}:{},I=Ql(u,f,"SB Manager"),[N,M]=j.useState(""),[Z,ge]=j.useState(!1),le=e.name?p?`${_.formTitle.viewIdea}${e.number||e.title||e.name}`:_.formTitle.editIdea:_.formTitle.newIdea,L=fe(s,e.management).map(D=>({name:D.name,label:D.name1||D.name})),K=fe(r,e.department).map(D=>({name:D.name,label:D.department_name||D.name})),G=fe(i,e.branch).map(D=>({name:D.name,label:D.branch||D.name})),ee=fe(a,e.type).map(D=>({name:D.name,label:D.name1||D.name})),J=fe(d,e.status).map(D=>({name:D.name,label:D.name1||D.name})),xe=e.workflow_state||"New",_e=m==="Employee",re=m==="Auditor"||m==="Admin",Ce=m==="Manager",Oe=e.name?xe==="New"?[{label:_.wf.submit,action:"Submit",color:"#2563eb"}]:xe==="Initial Evaluation"&&re?[{label:_.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:_.wf.reject,action:"Reject",color:"#dc2626"}]:xe==="Accept & Under Progress"&&(Ce||re)?[{label:_.wf.submitSolution,action:"Submit Proposal",color:"#059669"}]:xe==="working on proposal"&&re?[{label:_.wf.moveToOutsourcing,action:"Move to Outsourcing",color:"#0369a1"},{label:_.wf.reject,action:"Reject",color:"#dc2626"}]:[]:[];async function H(D){if(e.name){ge(!0),M("");try{const te={};D==="Assign to Manager"&&(e.assigned_to&&(te.assigned_to=e.assigned_to),e.priority&&(te.priority=e.priority),e.economy_class&&(te.economy_class=e.economy_class),e.entity_scope&&(te.entity_scope=e.entity_scope),e.hses_field&&(te.hses_field=e.hses_field),te.product_relation=String(e.product_relation??0),te.repeated=String(e.repeated??0)),D==="Submit Proposal"&&(e.solution&&(te.solution=e.solution),e.proposed_condition&&(te.proposed_condition=e.proposed_condition),e.cost&&(te.cost=String(e.cost))),e.auditor_comment&&(D==="Move to Outsourcing"||D==="Reject")&&(te.auditor_comment=e.auditor_comment),await xy(e.name,D,JSON.stringify(te)),M("Done"),w==null||w()}catch(te){M(te.message||"Error")}finally{ge(!1)}}}const se=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:_.wf.workflow}),n.jsx("span",{style:Vy(xe),children:xe})]}),xe==="Initial Evaluation"&&re&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:z,children:_.wf.assignToManager}),n.jsxs("select",{style:E,value:e.assigned_to||"",onChange:D=>U({assigned_to:D.target.value}),children:[n.jsx("option",{value:"",children:_.field.selectMgr}),I.map(D=>n.jsx("option",{value:D.name,children:D.full_name||D.name},D.name))]})]}),xe==="Accept & Under Progress"&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:z,children:_.field.solution}),n.jsx("textarea",{style:{...E,height:80,resize:"vertical"},value:e.solution||"",onChange:D=>U({solution:D.target.value}),placeholder:_.field.solutionPlaceholder}),n.jsx("label",{style:{...z,marginTop:8},children:_.field.actualCost}),n.jsx("input",{type:"number",style:E,value:e.cost||"",onChange:D=>U({cost:parseFloat(D.target.value)||0}),placeholder:"0.00"})]}),xe==="working on proposal"&&re&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:z,children:_.field.auditorComment}),n.jsx("textarea",{style:{...E,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:D=>U({auditor_comment:D.target.value}),placeholder:_.field.commentPlaceholder})]}),Oe.length>0?n.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:Oe.map(D=>n.jsx("button",{onClick:()=>H(D.action),disabled:Z,style:{padding:"8px 18px",borderRadius:8,border:"none",background:D.color,color:"white",fontWeight:700,cursor:Z?"not-allowed":"pointer",opacity:Z?.7:1},children:Z?_.wf.applying:D.label},D.action))}):n.jsx("div",{style:{fontSize:12,color:"#94a3b8",fontStyle:"italic"},children:_.wf.noActions}),N&&n.jsx("p",{style:{marginTop:8,fontSize:13,color:N==="Done"?B.green:B.red},children:N})]}),n.jsx(Gi,{doctype:$.ideas,docname:e.name,currentUserName:T.name}),n.jsx(Yi,{doctype:$.ideas,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):null;return n.jsxs(Me,{title:le,activePage:"ideas",user:T,formStatus:y,buttonText:_.saveIdea,buttonColor:B.teal,viewMode:p,onEdit:c,darkMode:v,notifCount:b,onToggleDark:g,onCountChange:S,onViewProfile:h,rightPanel:se,onSubmit:o,onBack:x,onNavigate:C,onLogout:A,children:[n.jsxs("div",{style:ou,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.number}),n.jsx("input",{style:{...E,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[_.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.organization,onChange:D=>U({organization:D}),organizations:l,disabled:p||!!T.custom_organization})]})]}),n.jsxs("div",{style:Pa,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.management}),n.jsx(ue,{value:e.management,onChange:D=>U({management:D}),items:L,placeholder:_.field.select,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.department}),n.jsx(ue,{value:e.department,onChange:D=>U({department:D}),items:K,placeholder:_.field.select,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.section}),n.jsx("input",{style:{...E,...P},value:e.section_field||"",disabled:p,onChange:D=>U({section_field:D.target.value})})]})]}),n.jsxs("div",{style:ou,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.branch}),n.jsx(ue,{value:e.branch,onChange:D=>U({branch:D}),items:G,placeholder:_.field.select,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.date}),n.jsx(me,{value:e.date||"",onChange:D=>U({date:D}),disabled:p,style:{...E,...P}})]})]}),n.jsxs("div",{style:Pa,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.type}),n.jsx(ue,{value:e.type,onChange:D=>U({type:D}),items:ee,placeholder:_.field.selectType,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.ideaClass}),n.jsxs("select",{style:{...E,...P},value:e.idea_class||"",disabled:p,onChange:D=>U({idea_class:D.target.value}),children:[n.jsx("option",{value:"",children:_.field.select}),n.jsx("option",{value:"Safety",children:"Safety"}),n.jsx("option",{value:"Non-safety",children:"Non-safety"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.hsesField}),n.jsx("input",{style:{...E,...P},value:e.hses_field||"",disabled:p,onChange:D=>U({hses_field:D.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.title}),n.jsx("input",{style:{...E,...P},value:e.title,disabled:p,onChange:D=>U({title:D.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.status}),n.jsx(ue,{value:e.status,onChange:D=>U({status:D}),items:J,placeholder:_.field.selectStatus,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.currentCondition}),n.jsx("textarea",{style:{...E,...P,height:110,resize:"vertical"},value:e.current_condition,disabled:p,onChange:D=>U({current_condition:D.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.proposedCondition}),n.jsx("textarea",{style:{...E,...P,height:110,resize:"vertical"},value:e.proposed_condition,disabled:p,onChange:D=>U({proposed_condition:D.target.value})})]}),!_e&&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:_.steps.auditorEval}),n.jsxs("div",{style:Pa,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.priority}),n.jsxs("select",{style:{...E,...p&&!re?{background:"#f9f9f9"}:{}},value:e.priority||"",disabled:p&&!re,onChange:D=>U({priority:D.target.value}),children:[n.jsx("option",{value:"",children:_.field.select}),n.jsx("option",{value:"High",children:_.field.high}),n.jsx("option",{value:"Normal",children:_.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.economyClass}),n.jsxs("select",{style:{...E,...p&&!re?{background:"#f9f9f9"}:{}},value:e.economy_class||"",disabled:p&&!re,onChange:D=>U({economy_class:D.target.value}),children:[n.jsx("option",{value:"",children:_.field.select}),n.jsx("option",{value:"Expenses",children:_.field.expenses}),n.jsx("option",{value:"Capital",children:_.field.capital}),n.jsx("option",{value:"Earn",children:_.field.earn}),n.jsx("option",{value:"Pay/Loss",children:_.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.entityScope}),n.jsxs("select",{style:{...E,...p&&!re?{background:"#f9f9f9"}:{}},value:e.entity_scope||"",disabled:p&&!re,onChange:D=>U({entity_scope:D.target.value}),children:[n.jsx("option",{value:"",children:_.field.select}),n.jsx("option",{value:"Upstream",children:_.field.upstream}),n.jsx("option",{value:"On-stream",children:_.field.onstream}),n.jsx("option",{value:"Downstream",children:_.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:p&&!re,onChange:D=>U({product_relation:D.target.checked?1:0})})," ",_.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:p&&!re,onChange:D=>U({repeated:D.target.checked?1:0})})," ",_.field.repeatedEvent]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:z,children:_.wf.assignToManager}),n.jsxs("select",{style:{...E,...p&&!re?{background:"#f9f9f9"}:{}},value:e.assigned_to||"",disabled:p&&!re,onChange:D=>U({assigned_to:D.target.value}),children:[n.jsx("option",{value:"",children:_.field.select}),I.map(D=>n.jsx("option",{value:D.name,children:D.full_name||D.name},D.name))]})]})]}),!_e&&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:_.steps.managerSolution}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:_.field.solution}),n.jsx("textarea",{style:{...E,height:100,resize:"vertical",...p&&!Ce&&!re?{background:"#f9f9f9"}:{}},value:e.solution||"",disabled:p&&!Ce&&!re,onChange:D=>U({solution:D.target.value}),placeholder:_.field.solutionPlaceholder})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:z,children:_.field.actualCost}),n.jsx("input",{type:"number",style:{...E,...p&&!Ce&&!re?{background:"#f9f9f9"}:{}},value:e.cost||"",disabled:p&&!Ce&&!re,onChange:D=>U({cost:parseFloat(D.target.value)||0}),placeholder:"0.00"})]})]}),!_e&&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:_.steps.ownerComment}),n.jsx("textarea",{style:{...E,height:80,resize:"vertical",...p&&!re?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:p&&!re,onChange:D=>U({auditor_comment:D.target.value}),placeholder:_.field.commentPlaceholder})]})]})}function t0({orders:e,organizations:t,departments:l,branches:s,orderStatuses:r,initialOrg:i,initialStatus:a,canModify:d,onView:u,onEdit:f,onDelete:y}){const p=V(),[c,v]=j.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),b=(o,x)=>v(C=>({...C,[o]:x})),[g,S]=j.useState(1),h=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));j.useEffect(()=>{S(1)},[c]);const m=h.slice((g-1)*ne,g*ne);return n.jsxs(n.Fragment,{children:[n.jsx(Qi,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.numberTitle}),n.jsx("input",{style:Ue,value:c.search,onChange:o=>b("search",o.target.value),placeholder:p.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.organization}),n.jsxs("select",{style:Ue,value:c.organization,onChange:o=>b("organization",o.target.value),children:[n.jsx("option",{value:"",children:p.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:$e,children:p.filter.department}),n.jsxs("select",{style:Ue,value:c.department,onChange:o=>b("department",o.target.value),children:[n.jsx("option",{value:"",children:p.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:$e,children:p.filter.branch}),n.jsxs("select",{style:Ue,value:c.branch,onChange:o=>b("branch",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allBranches}),s.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.status}),n.jsxs("select",{style:Ue,value:c.status,onChange:o=>b("status",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allStatuses}),r.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:()=>v({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:p.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.number}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.title}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.type}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.actions})]})}),n.jsx("tbody",{children:h.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:p.noOrders})}):m.map((o,x)=>n.jsxs("tr",{onClick:()=>u==null?void 0:u(o),style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",color:"#999"},children:o.number||"—"}),n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.title||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.type?On(o.type,"#8e44ad"):"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.status?On(o.status,Ki(o.status)):"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:C=>C.stopPropagation(),children:n.jsx(Je,{onView:()=>u==null?void 0:u(o),onEdit:d&&f?()=>f(o):void 0,onDelete:d&&y?()=>y(o.name):void 0})})]},o.name))})]})}),n.jsx(Fe,{page:g,total:h.length,onPageChange:S})]})}const $r={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Ur={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},n0={1:"Initiation / Bidding",2:"Execution begins",3:"Mid-execution review",4:"Near completion",5:"Closing"},l0={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 s0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...l0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function r0({orderForm:e,setOrderForm:t,organizations:l,managements:s,departments:r,branches:i,orderTypes:a,orderStatuses:d,cycles:u=[],users:f,userRoleMap:y={},formStatus:p,viewMode:c,onEdit:v,darkMode:b,notifCount:g,onToggleDark:S,onCountChange:h,onViewProfile:m,currentUser:o,userRole:x,onSubmit:C,onBack:A,onNavigate:T,onLogout:w,user:_,onRefresh:U}){var $n;const P=V(),I=W=>t({...e,...W}),N=c?{background:"#f9f9f9"}:{},M=Ql(f,y,"SB Employee"),[Z,ge]=j.useState(""),[le,L]=j.useState(""),[K,G]=j.useState(!1),[ee,J]=j.useState("Agree"),xe=e.name?c?`${P.formTitle.viewOrder}${e.number||e.title||e.name}`:P.formTitle.editOrder:P.formTitle.newOrder,_e=fe(s,e.management).map(W=>({name:W.name,label:W.name1||W.name})),re=fe(r,e.department).map(W=>({name:W.name,label:W.department_name||W.name})),Ce=fe(i,e.branch).map(W=>({name:W.name,label:W.branch||W.name})),Oe=fe(a,e.type).map(W=>({name:W.name,label:W.name1||W.name})),H=fe(d,e.status).map(W=>({name:W.name,label:W.name1||W.name})),se=fe(u,e.cycle).map(W=>({name:W.name,label:W.name1||W.name})),D=!!e.name,te=e.workflow_state||"Draft",hn=Math.min(5,(e.stage||0)+1),[gt,O]=j.useState(hn);j.useEffect(()=>{O(Math.min(5,(e.stage||0)+1))},[e.stage]);const R=x==="Auditor"||x==="Admin"||x==="Manager",Q=R||x==="Owner",Yt=!!(o&&(e.actor===o||e.assigned_to===o)),hr=D?te==="Closed"?[]:te==="Draft"&&R?[{label:"Submit for Review",action:"Submit for Review",color:"#2563eb"}]:te==="Pending Actor"&&(Yt||R)?[{label:"Update Status",action:"Update Status",color:"#d97706"}]:te==="Review"&&Q?[{label:"Move to Study",action:"Move to Study",color:"#059669"},{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"}]:te==="In Study"&&Q?[{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"},{label:"Close Order",action:"Close Order",color:"#475569"}]:[]:[];async function Bn(W){if(e.name){G(!0),ge("");try{let Ge;W==="Update Status"&&(Ge=ee);const sl=await hy(e.name,W,le,W==="Update Status"?String(gt):void 0,void 0,Ge);if(L(""),J("Agree"),ge("Done"),sl){const kt=sl;t({...e,...kt,stage:kt.stage??e.stage,completion_pct:kt.completion_pct??e.completion_pct,workflow_state:kt.workflow_state??e.workflow_state})}U==null||U()}catch(Ge){ge(Ge.message||"Error")}finally{G(!1)}}}const Xi=D?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:P.wf.workflow}),n.jsx("span",{style:s0(te),children:te})]}),te==="Pending Actor"&&n.jsxs("div",{style:{display:"flex",gap:16,marginBottom:14,flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:["Stage (1–5) — ",gt*20,"% complete"]}),n.jsx("input",{type:"number",min:1,max:5,style:{...E,maxWidth:80},value:gt,onChange:W=>O(Math.min(5,Math.max(1,parseInt(W.target.value)||1)))})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Cycle Status"}),n.jsxs("select",{style:{...E,minWidth:140},value:ee,onChange:W=>J(W.target.value),children:[n.jsx("option",{value:"Agree",children:"✅ Agree — on track"}),n.jsx("option",{value:"Deviate",children:"⚠️ Deviate — off plan"}),n.jsx("option",{value:"Unknown",children:"❓ Unknown"})]})]})]}),n.jsxs("div",{style:{marginBottom:14},children:[n.jsxs("label",{style:z,children:["Comment ",ee==="Deviate"&&te==="Pending Actor"?n.jsx("span",{style:{color:B.red},children:" * required for Deviate"}):"(optional)"]}),n.jsx("textarea",{style:{...E,height:64,resize:"vertical",borderColor:ee==="Deviate"&&!le?"#fca5a5":void 0},value:le,onChange:W=>L(W.target.value),placeholder:"Add a comment…"})]}),n.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:hr.map(W=>{const Ge=W.action==="Update Status"&&ee==="Deviate"&&!le.trim();return n.jsx("button",{onClick:()=>Bn(W.action),disabled:K||Ge,title:Ge?"Comment required when status is Deviate":void 0,style:{padding:"8px 18px",borderRadius:8,border:"none",background:W.color,color:"white",fontWeight:700,cursor:K||Ge?"not-allowed":"pointer",opacity:K||Ge?.5:1},children:K?P.wf.applying:W.label},W.action)})}),Z&&n.jsx("p",{style:{marginTop:8,fontSize:13,color:Z==="Done"?B.green:B.red},children:Z}),hr.length===0&&n.jsx("div",{style:{fontSize:12,color:"#94a3b8",fontStyle:"italic"},children:P.wf.noActions})]}),n.jsx(Gi,{doctype:$.orders,docname:e.name,currentUserName:_.name}),n.jsx(Yi,{doctype:$.orders,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):null;return n.jsxs(Me,{title:xe,activePage:"orders",user:_,formStatus:p,buttonText:P.saveOrder,buttonColor:B.purple,viewMode:c,onEdit:v,darkMode:b,notifCount:g,onToggleDark:S,onCountChange:h,onViewProfile:m,rightPanel:Xi,onSubmit:C,onBack:A,onNavigate:T,onLogout:w,children:[n.jsxs("div",{style:$r,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.number}),n.jsx("input",{style:{...E,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[P.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.organization,onChange:W=>I({organization:W}),organizations:l,disabled:c||!!_.custom_organization})]})]}),n.jsxs("div",{style:Ur,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.management}),n.jsx(ue,{value:e.management,onChange:W=>I({management:W}),items:_e,placeholder:P.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.department}),n.jsx(ue,{value:e.department,onChange:W=>I({department:W}),items:re,placeholder:P.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.section}),n.jsx("input",{style:{...E,...N},value:e.section_field||"",disabled:c,onChange:W=>I({section_field:W.target.value})})]})]}),n.jsxs("div",{style:$r,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.branch}),n.jsx(ue,{value:e.branch,onChange:W=>I({branch:W}),items:Ce,placeholder:P.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.type}),n.jsx(ue,{value:e.type,onChange:W=>I({type:W}),items:Oe,placeholder:P.field.selectType,disabled:c})]})]}),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:Ur,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.priority}),n.jsxs("select",{style:{...E,...N},value:e.priority||"",disabled:c,onChange:W=>I({priority:W.target.value}),children:[n.jsx("option",{value:"",children:P.field.select}),n.jsx("option",{value:"High",children:P.field.high}),n.jsx("option",{value:"Normal",children:P.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.economyClass}),n.jsxs("select",{style:{...E,...N},value:e.economy_class||"",disabled:c,onChange:W=>I({economy_class:W.target.value}),children:[n.jsx("option",{value:"",children:P.field.select}),n.jsx("option",{value:"Expenses",children:P.field.expenses}),n.jsx("option",{value:"Capital",children:P.field.capital}),n.jsx("option",{value:"Earn",children:P.field.earn}),n.jsx("option",{value:"Pay/Loss",children:P.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.entityScope}),n.jsxs("select",{style:{...E,...N},value:e.entity_scope||"",disabled:c,onChange:W=>I({entity_scope:W.target.value}),children:[n.jsx("option",{value:"",children:P.field.select}),n.jsx("option",{value:"Upstream",children:P.field.upstream}),n.jsx("option",{value:"On-stream",children:P.field.onstream}),n.jsx("option",{value:"Downstream",children:P.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:c,onChange:W=>I({planned:W.target.checked?1:0})})," Planned"]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.product_relation,disabled:c,onChange:W=>I({product_relation:W.target.checked?1:0})})," ",P.field.productRelation]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:z,children:P.field.hsesField}),n.jsx("input",{style:{...E,...N},value:e.hses_field||"",disabled:c,onChange:W=>I({hses_field:W.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.title}),n.jsx("input",{style:{...E,...N},value:e.title,disabled:c,onChange:W=>I({title:W.target.value})})]}),n.jsxs("div",{style:Ur,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.budget}),n.jsx("input",{type:"number",style:{...E,...N},value:e.budget||"",disabled:c,onChange:W=>I({budget:parseFloat(W.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.actualCost}),n.jsx("input",{type:"number",style:{...E,...N},value:e.actual_cost||"",disabled:c,onChange:W=>I({actual_cost:parseFloat(W.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Variance"}),(()=>{const W=(e.budget||0)-(e.actual_cost||0);return n.jsxs("span",{style:{display:"inline-block",padding:"6px 12px",borderRadius:8,fontWeight:700,fontSize:13,background:W>=0?"#f0fdf4":"#fef2f2",color:W>=0?"#166534":"#dc2626",border:`1px solid ${W>=0?"#bbf7d0":"#fecaca"}`},children:[W>=0?"+":"",W.toFixed(2)]})})()]})]}),n.jsxs("div",{style:$r,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.currency}),n.jsxs("select",{style:{...E,...N},value:e.currency||"",disabled:c,onChange:W=>I({currency:W.target.value}),children:[n.jsx("option",{value:"",children:P.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:z,children:P.field.status}),n.jsx(ue,{value:e.status,onChange:W=>I({status:W}),items:H,placeholder:P.field.selectStatus,disabled:c||te==="Closed"})]})]}),n.jsxs("div",{style:Ur,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.startingDate}),n.jsx(me,{value:e.starting_date,onChange:W=>I({starting_date:W}),disabled:c,style:{...E,...N}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.endingDate}),n.jsx(me,{value:e.ending_date,onChange:W=>I({ending_date:W}),disabled:c,style:{...E,...N}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.actor}),n.jsxs("select",{style:{...E,...N},value:e.actor||e.assigned_to||"",disabled:c,onChange:W=>I({actor:W.target.value,assigned_to:W.target.value}),children:[n.jsx("option",{value:"",children:P.field.select}),M.map(W=>n.jsx("option",{value:W.name,children:W.full_name||W.name},W.name))]})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",fontSize:13,marginBottom:12},children:"Cycle & Progress"}),n.jsxs("div",{style:$r,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.cycle}),n.jsx(ue,{value:e.cycle||"",onChange:W=>I({cycle:W}),items:se,placeholder:P.field.select,disabled:c})]}),n.jsxs("div",{style:{display:"flex",gap:20,flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.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:z,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:z,children:"Stage Description"}),n.jsx("span",{style:{display:"inline-block",padding:"6px 12px",borderRadius:8,fontSize:13,fontWeight:600,background:"#f0f9ff",color:"#0369a1",border:"1px solid #bae6fd"},children:n0[e.stage||1]||"—"})]}),(e.escalation_level??0)>0&&n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.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]})]})]})]})]}),D&&(($n=e.order_cycle_log)==null?void 0:$n.length)>0&&n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",fontSize:13,marginBottom:10},children:"Cycle History"}),n.jsx("div",{style:{overflowX:"auto"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8fafc"},children:["Cycle","Date","Stage","Status","Actor","Comment"].map(W=>n.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#475569",borderBottom:"1px solid #e2e8f0"},children:W},W))})}),n.jsx("tbody",{children:(e.order_cycle_log||[]).map((W,Ge)=>{const sl=W.status==="Agree"?"#166534":W.status==="Deviate"?"#c2410c":"#92400e",kt=W.status==="Agree"?"#f0fdf4":W.status==="Deviate"?"#fff7ed":"#fefce8";return n.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:W.cycle||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:W.cycle_date||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155",textAlign:"center"},children:W.stage||"—"}),n.jsx("td",{style:{padding:"6px 10px"},children:n.jsx("span",{style:{background:kt,color:sl,padding:"2px 8px",borderRadius:12,fontWeight:600,fontSize:12},children:W.status||"—"})}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:W.actor||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#64748b",fontStyle:W.comment?"normal":"italic"},children:W.comment||"—"})]},Ge)})})]})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.description}),n.jsx("textarea",{style:{...E,...N,height:100,resize:"vertical"},value:e.description,disabled:c,onChange:W=>I({description:W.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:P.field.notes}),n.jsx("textarea",{style:{...E,...N,height:100,resize:"vertical"},value:e.notes,disabled:c,onChange:W=>I({notes:W.target.value})})]}),n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:16,marginTop:4},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:8},children:P.field.auditorComment}),n.jsx("textarea",{style:{...E,height:80,resize:"vertical",...c&&Yt&&!R?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:c&&Yt&&!R,onChange:W=>I({auditor_comment:W.target.value}),placeholder:P.field.commentPlaceholder})]})]})}function i0({processes:e,organizations:t,departments:l,branches:s,processStatuses:r,initialOrg:i,initialStatus:a,canModify:d,onView:u,onEdit:f,onDelete:y}){const p=V(),[c,v]=j.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),b=(o,x)=>v(C=>({...C,[o]:x})),[g,S]=j.useState(1),h=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));j.useEffect(()=>{S(1)},[c]);const m=h.slice((g-1)*ne,g*ne);return n.jsxs(n.Fragment,{children:[n.jsx(Qi,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.numberTitle}),n.jsx("input",{style:Ue,value:c.search,onChange:o=>b("search",o.target.value),placeholder:p.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.organization}),n.jsxs("select",{style:Ue,value:c.organization,onChange:o=>b("organization",o.target.value),children:[n.jsx("option",{value:"",children:p.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:$e,children:p.filter.department}),n.jsxs("select",{style:Ue,value:c.department,onChange:o=>b("department",o.target.value),children:[n.jsx("option",{value:"",children:p.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:$e,children:p.filter.branch}),n.jsxs("select",{style:Ue,value:c.branch,onChange:o=>b("branch",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allBranches}),s.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.status}),n.jsxs("select",{style:Ue,value:c.status,onChange:o=>b("status",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allStatuses}),r.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:()=>v({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:p.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.number}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.title}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.field.cycleType}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.actions})]})}),n.jsx("tbody",{children:h.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:p.noProcesses})}):m.map((o,x)=>n.jsxs("tr",{onClick:()=>u==null?void 0:u(o),style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",color:"#999"},children:o.number||"—"}),n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.title||o.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.cycle_type?On(o.cycle_type,"#8e44ad"):"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.status?On(o.status,Ki(o.status)):"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:C=>C.stopPropagation(),children:n.jsx(Je,{onView:()=>u==null?void 0:u(o),onEdit:d&&f?()=>f(o):void 0,onDelete:d&&y?()=>y(o.name):void 0})})]},o.name))})]})}),n.jsx(Fe,{page:g,total:h.length,onPageChange:S})]})}const a0={Draft:[{action:"Submit for Review",next:"Pending Actor",allowedRoles:["Auditor","Manager"]}],"Pending Actor":[{action:"Update Status",next:"Pending Comment",allowedRoles:["Employee","Manager"]}],"Pending Comment":[{action:"Add Comment",next:"Review",allowedRoles:["Auditor","Manager"]}],Review:[{action:"Start New Cycle",next:"Pending Actor",allowedRoles:["Auditor","Manager"]},{action:"Move to Study",next:"In Study",allowedRoles:["Auditor","Manager"]}],"In Study":[{action:"Start New Cycle",next:"Pending Actor",allowedRoles:["Auditor","Manager"]},{action:"Close Process",next:"Closed",allowedRoles:["Auditor","Manager"]}]},o0={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 cu(e){return{display:"inline-block",padding:"5px 14px",borderRadius:20,fontSize:13,fontWeight:700,...o0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}const Fr={width:"100%",padding:"6px 8px",border:"1px solid #d1d5db",borderRadius:5,fontSize:12,fontFamily:"Segoe UI",boxSizing:"border-box"};function c0({processName:e,userRole:t,onRefresh:l,canUpdateStatus:s=!0}){const[r,i]=j.useState(null),[a,d]=j.useState(!0),[u,f]=j.useState(""),[y,p]=j.useState(!1),[c,v]=j.useState(""),[b,g]=j.useState(""),[S,h]=j.useState("Pass"),[m,o]=j.useState(""),[x,C]=j.useState({}),A=j.useCallback(async()=>{if(!e){d(!1);return}d(!0),f("");try{const N=await Ls(e);i(N);const M={};for(const Z of N.progress_indicators||[])M[Z.name]=Z.actual_value!=null?String(Z.actual_value):"";C(M)}catch(N){f(N instanceof Error?N.message:"Failed to load process")}d(!1)},[e]);if(j.useEffect(()=>{A()},[A]),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(u||!r)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:u||"Could not load workflow"})})});const T=r.workflow_state||"Draft",w=a0[T]??[],_=t==="Employee"||t==="Manager",U=t!=="Manager"||s,P=w.filter(N=>(t==="Admin"||N.allowedRoles.includes(t))&&(N.action!=="Update Status"||U)),I=async N=>{p(!0),v(""),g("");try{const M={};if(N==="Update Status"){M.actor_status=S,M.actor_comment=m;const ge=r.progress_indicators||[];ge.length>0&&(M.progress_indicators=ge.map(le=>({name:le.name,actual_value:x[le.name]??""})))}N==="Add Comment"&&m&&(M.actor_comment=m);const Z=await Ty(r.name,N,M);i(Z),o(""),g(`Done — now: ${Z.workflow_state||"updated"}`),l==null||l()}catch(M){v(M instanceof Error?M.message:"Action failed")}p(!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:cu(T),children:T})]}),T==="Pending Actor"&&_&&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(r.progress_indicators)&&r.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:r.progress_indicators.map(N=>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:N.name1,children:N.name1||N.name}),n.jsx("input",{type:"number",value:x[N.name]??"",onChange:M=>C(Z=>({...Z,[N.name]:M.target.value})),style:{...Fr,width:70,flexShrink:0},placeholder:"0"})]},N.name))})]}),n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Cycle Status"}),n.jsxs("select",{value:S,onChange:N=>h(N.target.value),style:Fr,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:m,onChange:N=>o(N.target.value),style:{...Fr,height:52,resize:"vertical"},placeholder:"Add a comment…"})]})]}),(T==="Pending Comment"||T==="Review")&&!_&&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(r.cycle_logs)&&r.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 N=r.cycle_logs,M=N[N.length-1],Z=M.status==="Pass"?"#16a34a":M.status==="Fail"?"#dc2626":"#9ca3af";return n.jsxs("div",{style:{fontSize:13,fontWeight:700,color:Z},children:[M.status," ",M.comment?`— ${M.comment}`:""]})})()]}),n.jsx("textarea",{value:m,onChange:N=>o(N.target.value),style:{...Fr,height:52,resize:"vertical"},placeholder:"Add a comment…"})]}),n.jsxs("div",{style:{padding:"12px 14px",borderBottom:P.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"}),P.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:T}),"."]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:P.map(N=>n.jsxs("button",{onClick:()=>I(N.action),disabled:y,style:{width:"100%",padding:"10px 14px",borderRadius:6,border:"none",background:N.action==="Close Process"?"#64748b":N.action==="Move to Study"?"#8e44ad":"#2563eb",color:"white",cursor:y?"not-allowed":"pointer",fontSize:13,fontWeight:600,opacity:y?.7:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsx("span",{children:y?"Applying…":N.action}),n.jsxs("span",{style:{fontSize:10,opacity:.7},children:["→ ",N.next]})]},N.action))}),c&&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:c}),b&&n.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,fontSize:12,color:"#166534"},children:b})]}),w.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"}),w.map(N=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6,fontSize:11},children:[n.jsx("span",{style:{color:"#555",flex:1},children:N.action}),n.jsx("span",{style:{color:"#bbb"},children:"→"}),n.jsx("span",{style:cu(N.next),children:N.next})]},N.action))]})]})})}const Mr={display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},hl={display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:16};function d0({processForm:e,setProcessForm:t,organizations:l,managements:s,departments:r,branches:i,processTypes:a,processStatuses:d,cycles:u=[],users:f=[],userRoleMap:y={},formStatus:p,viewMode:c,onEdit:v,darkMode:b,notifCount:g,onToggleDark:S,onCountChange:h,onViewProfile:m,userRole:o,delegatedFunctions:x=[],delegatedOrgs:C=null,onRefreshProcess:A,onSubmit:T,onBack:w,onNavigate:_,onLogout:U,user:P}){const I=V(),N=O=>t({...e,...O}),M=c?{background:"#f9f9f9"}:{},Z=!c&&o==="Manager"&&Array.isArray(C),ge=Z?l.filter(O=>(C||[]).includes(O.organization_name||O.name)):l,le=Z&&(C||[]).length===1||!!P.custom_organization,L=fe(s,e.management).map(O=>({name:O.name,label:O.name1||O.name})),K=fe(r,e.department).map(O=>({name:O.name,label:O.department_name||O.name})),G=fe(i,e.branch).map(O=>({name:O.name,label:O.branch||O.name})),ee=fe(a,e.type).map(O=>({name:O.name,label:O.name1||O.name})),J=fe(d,e.status).map(O=>({name:O.name,label:O.name1||O.name})),xe=fe(u,e.cycle).map(O=>({name:O.name,label:O.name1||O.name})),_e=Ql(f,y,"SB Employee").map(O=>({name:O.name,label:O.full_name||O.name})),re=(O,R)=>{const Q=[...e.cycle_logs||[]];Q[O]={...Q[O],...R},N({cycle_logs:Q})},Ce=()=>{N({cycle_logs:[...e.cycle_logs||[],{cycle:"",cycle_date:"",status:"Pass",actor:"",comment:""}]})},Oe=O=>{const R=[...e.cycle_logs||[]];R.splice(O,1),N({cycle_logs:R})},H=(O,R)=>{const Q=[...e.progress_indicators||[]];Q[O]={...Q[O],...R},N({progress_indicators:Q})},se=()=>{N({progress_indicators:[...e.progress_indicators||[],{name1:"",type:"Nominal",unit:"",cycle:"",target:"",maximum:"",minimum:"",manager:"",order:"",actual_value:"",cycle_status:"",cycle_date:"",cycle_comment:"",status:""}]})},D=O=>{const R=[...e.progress_indicators||[]];R.splice(O,1),N({progress_indicators:R})},te=e.name?c?`${I.formTitle.viewProcess}${e.title||e.name}`:I.formTitle.editProcess:I.formTitle.newProcess,hn=o!=="Manager"||e.actor===P.name||x.includes("update_process_status"),gt=e.name?n.jsxs("div",{style:{width:260,display:"flex",flexDirection:"column",gap:14},children:[n.jsx(c0,{processName:e.name,userRole:o||P.role||"Employee",onRefresh:A,canUpdateStatus:hn}),n.jsx(Gi,{doctype:$.processes,docname:e.name,currentUserName:P.name}),n.jsx(Yi,{doctype:$.processes,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):void 0;return n.jsxs(Me,{title:te,activePage:"processes",user:P,formStatus:p,buttonText:I.saveProcess,buttonColor:B.blue,viewMode:c,onEdit:v,darkMode:b,notifCount:g,onToggleDark:S,onCountChange:h,onViewProfile:m,rightPanel:gt,onSubmit:T,onBack:w,onNavigate:_,onLogout:U,children:[n.jsxs("div",{style:Mr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.number}),n.jsx("input",{style:{...E,background:"#f9f9f9"},value:e.number||"",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[I.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.organization,onChange:O=>N({organization:O}),organizations:ge,disabled:c||le}),Z&&n.jsx("div",{style:{fontSize:11,color:"#888",marginTop:4},children:(C||[]).length===0?"You have no delegated organization for Processes.":`Restricted to your delegated organization${(C||[]).length>1?"s":""}: ${(C||[]).join(", ")}`})]})]}),n.jsxs("div",{style:Mr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.title}),n.jsx("input",{style:{...E,...M},value:e.title,disabled:c,onChange:O=>N({title:O.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.type}),n.jsx(ue,{value:e.type,onChange:O=>N({type:O}),items:ee,placeholder:I.field.selectType,disabled:c})]})]}),n.jsxs("div",{style:hl,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.management}),n.jsx(ue,{value:e.management,onChange:O=>N({management:O}),items:L,placeholder:I.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.department}),n.jsx(ue,{value:e.department,onChange:O=>N({department:O}),items:K,placeholder:I.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.section}),n.jsx("input",{style:{...E,...M},value:e.section_field||"",disabled:c,onChange:O=>N({section_field:O.target.value})})]})]}),n.jsxs("div",{style:Mr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.branch}),n.jsx(ue,{value:e.branch,onChange:O=>N({branch:O}),items:G,placeholder:I.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[I.field.status," ",n.jsx("span",{style:{fontSize:11,color:"#9ca3af",fontWeight:400},children:"(auto-updated from cycle)"})]}),n.jsx(ue,{value:e.status,onChange:O=>N({status:O}),items:J,placeholder:I.field.selectStatus,disabled:c})]})]}),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:hl,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.chainLocation}),n.jsxs("select",{style:{...E,...M},value:e.chain_location||"",disabled:c,onChange:O=>N({chain_location:O.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),n.jsx("option",{value:"Upstream",children:"Upstream"}),n.jsx("option",{value:"On-stream",children:"On-stream"}),n.jsx("option",{value:"Downstream",children:"Downstream"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.economyClass}),n.jsxs("select",{style:{...E,...M},value:e.economy_class||"",disabled:c,onChange:O=>N({economy_class:O.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),n.jsx("option",{value:"Expenses",children:I.field.expenses}),n.jsx("option",{value:"Capital",children:I.field.capital}),n.jsx("option",{value:"Earn",children:I.field.earn}),n.jsx("option",{value:"Pay/Loss",children:I.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.impactLevel}),n.jsxs("select",{style:{...E,...M},value:e.impact_level||"",disabled:c,onChange:O=>N({impact_level:O.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),n.jsx("option",{value:"High",children:I.field.high}),n.jsx("option",{value:"Normal",children:I.field.normal})]})]})]}),n.jsxs("div",{style:hl,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.entityScope}),n.jsxs("select",{style:{...E,...M},value:e.entity_scope||"",disabled:c,onChange:O=>N({entity_scope:O.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),n.jsx("option",{value:"Upstream",children:I.field.upstream}),n.jsx("option",{value:"On-stream",children:I.field.onstream}),n.jsx("option",{value:"Downstream",children:I.field.downstream})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.hsesField}),n.jsx("input",{style:{...E,...M},value:e.hses_field||"",disabled:c,onChange:O=>N({hses_field:O.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:c,onChange:O=>N({product_relation:O.target.checked?1:0})})," ",I.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:hl,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.kpiName}),n.jsx("input",{style:{...E,...M},value:e.kpi_name||"",disabled:c,onChange:O=>N({kpi_name:O.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.kpiType}),n.jsxs("select",{style:{...E,...M},value:e.kpi_type||"",disabled:c,onChange:O=>N({kpi_type:O.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),n.jsx("option",{value:"Human",children:"Human"}),n.jsx("option",{value:"Substantial",children:"Substantial"}),n.jsx("option",{value:"System",children:"System"}),n.jsx("option",{value:"Value",children:"Value"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.kpiMeasure}),n.jsx("input",{style:{...E,...M},value:e.kpi_measure||"",disabled:c,onChange:O=>N({kpi_measure:O.target.value}),placeholder:"Unit of measure"})]})]})]}),n.jsxs("div",{style:hl,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.dateStart}),n.jsx(me,{value:e.date_start,onChange:O=>N({date_start:O}),disabled:c,style:{...E,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.dateEnd}),n.jsx(me,{value:e.date_end,onChange:O=>N({date_end:O}),disabled:c,style:{...E,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.cycleType}),n.jsxs("select",{style:{...E,...M},value:e.cycle_type||"",disabled:c,onChange:O=>N({cycle_type:O.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),n.jsx("option",{value:"Normal",children:"Normal"}),n.jsx("option",{value:"Long",children:"Long"})]})]})]}),e.cycle_type==="Long"&&n.jsxs("div",{style:{background:"#fff7ed",border:"1px solid #fed7aa",borderRadius:8,padding:14},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#c2410c",marginBottom:10},children:"Long Cycle Milestone Dates"}),n.jsxs("div",{style:Mr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Milestone 1"}),n.jsx(me,{value:e.long_cycle_date_1||"",onChange:O=>N({long_cycle_date_1:O}),disabled:c,style:{...E,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Milestone 2"}),n.jsx(me,{value:e.long_cycle_date_2||"",onChange:O=>N({long_cycle_date_2:O}),disabled:c,style:{...E,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Milestone 3"}),n.jsx(me,{value:e.long_cycle_date_3||"",onChange:O=>N({long_cycle_date_3:O}),disabled:c,style:{...E,...M}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:"Milestone 4"}),n.jsx(me,{value:e.long_cycle_date_4||"",onChange:O=>N({long_cycle_date_4:O}),disabled:c,style:{...E,...M}})]})]})]}),n.jsxs("div",{style:{marginTop:24,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[n.jsx("div",{style:{...z,margin:0,fontSize:15},children:"Progress Indicators"}),!c&&n.jsx("button",{type:"button",onClick:se,style:{padding:"8px 14px",border:"1px solid #3498db",background:"#3498db",color:"white",borderRadius:6,cursor:"pointer"},children:"Add row"})]}),n.jsx("div",{style:{overflowX:"auto",minWidth:0},children:n.jsxs("table",{style:{borderCollapse:"collapse",fontSize:12,width:"max-content",minWidth:"100%"},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa"},children:[n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"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"}),!c&&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:c?14:15,style:{padding:18,textAlign:"center",color:"#aaa"},children:"No progress indicators"})}),(e.progress_indicators||[]).map((O,R)=>n.jsxs("tr",{style:{background:R%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...M,width:60},value:O.order??"",disabled:c,onChange:Q=>H(R,{order:Q.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...M},value:O.name1,disabled:c,onChange:Q=>H(R,{name1:Q.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...E,...M},value:O.type,disabled:c,onChange:Q=>H(R,{type:Q.target.value}),children:[n.jsx("option",{children:"Nominal"}),n.jsx("option",{children:"Ordinal"}),n.jsx("option",{children:"Interval"}),n.jsx("option",{children:"Ratio"})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...M,width:70},type:"number",value:O.unit??"",disabled:c,onChange:Q=>H(R,{unit:parseFloat(Q.target.value)||""})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...M},value:O.cycle,disabled:c,onChange:Q=>H(R,{cycle:Q.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...M,width:80},value:O.target,disabled:c,onChange:Q=>H(R,{target:Q.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...M,width:80},value:O.minimum,disabled:c,onChange:Q=>H(R,{minimum:Q.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...M,width:80},value:O.maximum,disabled:c,onChange:Q=>H(R,{maximum:Q.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...M},value:O.manager,disabled:c,onChange:Q=>H(R,{manager:Q.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...M,width:90},type:"number",value:O.actual_value??"",disabled:c,onChange:Q=>H(R,{actual_value:parseFloat(Q.target.value)||""})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...E,...M},value:O.cycle_status??"",disabled:c,onChange:Q=>H(R,{cycle_status:Q.target.value}),children:[n.jsx("option",{value:"",children:"--"}),n.jsx("option",{children:"Normal"}),n.jsx("option",{children:"Below Min"}),n.jsx("option",{children:"Above Max"}),n.jsx("option",{children:"At Risk"})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx(me,{value:O.cycle_date||"",onChange:Q=>H(R,{cycle_date:Q}),disabled:c,style:{...E,...M,width:110}})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...M},value:O.cycle_comment??"",disabled:c,onChange:Q=>H(R,{cycle_comment:Q.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...E,...M},value:O.status??"",disabled:c,onChange:Q=>H(R,{status:Q.target.value}),children:[n.jsx("option",{value:"",children:"--"}),n.jsx("option",{children:"Normal"}),n.jsx("option",{children:"Below Min"}),n.jsx("option",{children:"Above Max"}),n.jsx("option",{children:"At Risk"})]})}),!c&&n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("button",{type:"button",onClick:()=>D(R),style:{padding:"6px 10px",border:"1px solid #e74c3c",background:"white",color:"#e74c3c",borderRadius:6,cursor:"pointer"},children:"Remove"})})]},R))]})]})})]}),n.jsxs("div",{style:{marginTop:28,borderTop:"1px solid #e9ecef",paddingTop:20},children:[n.jsx("div",{style:{...z,fontSize:15,marginBottom:14},children:"Cycle & Assignment"}),n.jsxs("div",{style:hl,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.cycle}),n.jsx(ue,{value:e.cycle||"",onChange:O=>N({cycle:O}),items:xe,placeholder:I.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.actor}),n.jsxs("select",{style:{...E,...M},value:e.actor||"",disabled:c,onChange:O=>N({actor:O.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),_e.map(O=>n.jsx("option",{value:O.name,children:O.label},O.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:I.field.costPerCycle}),n.jsx("input",{style:{...E,...M},type:"number",value:e.cost_per_cycle||"",disabled:c,onChange:O=>N({cost_per_cycle:parseFloat(O.target.value)||0}),placeholder:"0.00"})]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:z,children:I.field.escalationLevel}),n.jsx("input",{style:{...E,...M,maxWidth:120},type:"number",value:e.escalation_level||"",disabled:c,onChange:O=>N({escalation_level:parseInt(O.target.value)||0})})]})]}),n.jsxs("div",{style:{marginTop:28,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[n.jsx("div",{style:{...z,margin:0,fontSize:15},children:"Cycle History"}),!c&&n.jsx("button",{type:"button",onClick:Ce,style:{padding:"8px 14px",border:"1px solid #3498db",background:"#3498db",color:"white",borderRadius:6,cursor:"pointer"},children:"Add row"})]}),n.jsx("div",{style:{overflowX:"auto",minWidth:0},children:n.jsxs("table",{style:{borderCollapse:"collapse",fontSize:12,width:"max-content",minWidth:"100%"},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa"},children:[n.jsx("th",{style:{padding:"10px 12px",textAlign:"left",color:"#555"},children:"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"}),!c&&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:c?5:6,style:{padding:18,textAlign:"center",color:"#aaa"},children:"No cycle history"})}),(e.cycle_logs||[]).map((O,R)=>n.jsxs("tr",{style:{background:R%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...E,...M},value:O.cycle||"",disabled:c,onChange:Q=>re(R,{cycle:Q.target.value}),children:[n.jsx("option",{value:"",children:"-- Select --"}),xe.map(Q=>n.jsx("option",{value:Q.name,children:Q.label},Q.name))]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx(me,{value:O.cycle_date||"",onChange:Q=>re(R,{cycle_date:Q}),disabled:c,style:{...E,...M,width:130}})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...E,...M},value:O.status,disabled:c,onChange:Q=>re(R,{status:Q.target.value}),children:[n.jsx("option",{value:"Pass",children:"Pass"}),n.jsx("option",{value:"Fail",children:"Fail"}),n.jsx("option",{value:"Unknown",children:"Unknown"})]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...E,...M},value:O.actor||"",disabled:c,onChange:Q=>re(R,{actor:Q.target.value}),children:[n.jsx("option",{value:"",children:"-- Select --"}),_e.map(Q=>n.jsx("option",{value:Q.name,children:Q.label},Q.name))]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...E,...M},value:O.comment||"",disabled:c,onChange:Q=>re(R,{comment:Q.target.value})})}),!c&&n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("button",{type:"button",onClick:()=>Oe(R),style:{padding:"6px 10px",border:"1px solid #e74c3c",background:"white",color:"#e74c3c",borderRadius:6,cursor:"pointer"},children:"Remove"})})]},R))]})]})})]}),n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:16,marginTop:16},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:8},children:I.field.auditorComment}),n.jsx("textarea",{style:{...E,height:80,resize:"vertical",...c?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:c,onChange:O=>N({auditor_comment:O.target.value}),placeholder:I.field.commentPlaceholder})]})]})}const u0={Admin:"#7c3aed",Auditor:"#d97706",Owner:"#0369a1",XAuditor:"#0f766e",Manager:"#2563eb",Employee:"#6b7280",Chairman:"#0f766e"};function p0({user:e,profileUser:t,darkMode:l,canModify:s,onBack:r,organizations:i=[],managements:a=[],departments:d=[],branches:u=[]}){const f=t||{},y=!!s&&e.role==="Admin",[p,c]=j.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||""}),[v,b]=j.useState(""),[g,S]=j.useState(!1),[h,m]=j.useState({new:"",confirm:""}),[o,x]=j.useState(""),C=f.email||f.name||"",A=[p.first_name,p.middle_name,p.last_name].filter(Boolean).join(" ")||f.full_name||"",T=f.username||f.name||"",w=p.custom_category||"",_=f.enabled===0?"Inactive":"Active",U=u0[e.role]||"#6b7280",P=l,I=P?"#0f172a":"#f0f2f5",N=P?"#1e293b":"white",M=P?"#2d3748":"#e5e7eb",Z=P?"#e2e8f0":"#1a2332",ge=P?"#94a3b8":"#6b7280",le=P?"#374151":"white",L=P?"#2d3748":"#f9fafb",K={width:"100%",padding:"9px 12px",borderRadius:8,border:`1px solid ${M}`,fontSize:13,background:le,color:Z,fontFamily:"inherit",outline:"none"},G={...K,background:L,color:ge},ee={...K,cursor:"pointer"},J={fontSize:12,fontWeight:600,color:ge,marginBottom:5,display:"block"},xe={display:"grid",gridTemplateColumns:"1fr 1fr",gap:14},_e={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:14},re=async()=>{if(s){b("saving");try{await Ti("User",f.name,{first_name:p.first_name,middle_name:p.middle_name,last_name:p.last_name,mobile_no:p.mobile_no,custom_organization:p.custom_organization,custom_management:p.custom_management,custom_department:p.custom_department,custom_branch:p.custom_branch,custom_number:p.custom_number,custom_category:p.custom_category}),b("saved"),setTimeout(()=>b(""),2e3)}catch{b("error"),setTimeout(()=>b(""),3e3)}}},Ce=async()=>{if(!h.new){x("Enter a new password");return}if(h.new!==h.confirm){x("Passwords do not match");return}x("saving");try{await Bf(f.name,h.new),x("done"),m({new:"",confirm:""}),setTimeout(()=>{x(""),S(!1)},2e3)}catch{x("error")}},Oe=({title:H,icon:se,children:D})=>n.jsxs("div",{style:{background:N,borderRadius:12,padding:22,border:`1px solid ${M}`,boxShadow:`0 1px 4px rgba(0,0,0,${P?.3:.06})`},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,paddingBottom:14,borderBottom:`1px solid ${M}`},children:[se,n.jsx("span",{style:{fontSize:14,fontWeight:700,color:Z},children:H})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:D})]});return n.jsxs("div",{style:{background:I,minHeight:"100%",padding:"0 0 32px"},children:[n.jsxs("div",{style:{background:N,borderBottom:`1px solid ${M}`,padding:"12px 28px",display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:24},children:[n.jsxs("button",{onClick:r,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"]}),s&&n.jsxs("button",{onClick:re,style:{display:"flex",alignItems:"center",gap:8,background:v==="saved"?"#16a34a":v==="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"})]}),v==="saving"?"Saving…":v==="saved"?"Saved!":v==="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:A||C}),n.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.75)",textAlign:"center"},children:C})]}),n.jsx("div",{style:{background:N},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:T},{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:w||"—"},{icon:n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:_==="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:_,valueColor:_==="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:C},{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:p.mobile_no||"—"}].map(({icon:H,label:se,value:D,valueColor:te})=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 16px",borderBottom:`1px solid ${M}`},children:[n.jsx("div",{style:{flexShrink:0,width:18,display:"flex",justifyContent:"center"},children:H}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:11,color:ge,marginBottom:1},children:se}),n.jsx("div",{style:{fontSize:13,fontWeight:600,color:te||Z,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:D})]})]},se))})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:18},children:[n.jsxs(Oe,{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:xe,children:[n.jsxs("div",{children:[n.jsxs("label",{style:J,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:{...G,paddingLeft:32},value:C,readOnly:!0})]})]}),n.jsxs("div",{children:[n.jsxs("label",{style:J,children:["Full Name ",n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Auto-generated)"})]}),n.jsx("input",{style:G,value:A,readOnly:!0})]})]}),n.jsxs("div",{style:_e,children:[n.jsxs("div",{children:[n.jsxs("label",{style:J,children:["First Name ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{style:s?K:G,value:p.first_name,readOnly:!s,onChange:H=>c(se=>({...se,first_name:H.target.value})),placeholder:"First name"})]}),n.jsxs("div",{children:[n.jsx("label",{style:J,children:"Middle Name"}),n.jsx("input",{style:s?K:G,value:p.middle_name,readOnly:!s,onChange:H=>c(se=>({...se,middle_name:H.target.value})),placeholder:"Middle name"})]}),n.jsxs("div",{children:[n.jsx("label",{style:J,children:"Last Name"}),n.jsx("input",{style:s?K:G,value:p.last_name,readOnly:!s,onChange:H=>c(se=>({...se,last_name:H.target.value})),placeholder:"Last name"})]})]}),n.jsxs("div",{style:xe,children:[n.jsxs("div",{children:[n.jsx("label",{style:J,children:"Phone Number"}),n.jsx("input",{style:s?K:G,value:p.mobile_no,readOnly:!s,onChange:H=>c(se=>({...se,mobile_no:H.target.value})),placeholder:"Phone number"})]}),n.jsxs("div",{children:[n.jsx("label",{style:J,children:"User ID No"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx("input",{style:{...G,paddingRight:44},value:p.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:J,children:["Category ",!y&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),y?n.jsxs("select",{style:ee,value:p.custom_category,onChange:H=>c(se=>({...se,custom_category:H.target.value})),children:[n.jsx("option",{value:"",children:"Select category"}),["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"].map(H=>n.jsx("option",{value:H,children:H},H))]}):n.jsx("input",{style:G,value:w||"—",readOnly:!0})]})]}),n.jsxs(Oe,{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:xe,children:[n.jsxs("div",{children:[n.jsxs("label",{style:J,children:["Organization ",!y&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),y?n.jsxs("select",{style:ee,value:p.custom_organization,onChange:H=>c(se=>({...se,custom_organization:H.target.value})),children:[n.jsx("option",{value:"",children:"Select organization"}),fe(i,p.custom_organization).map(H=>n.jsx("option",{value:H.name,children:H.organization_name||H.name},H.name))]}):n.jsx("input",{style:G,value:p.custom_organization||"—",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:J,children:["Management ",!y&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),y?n.jsxs("select",{style:ee,value:p.custom_management,onChange:H=>c(se=>({...se,custom_management:H.target.value})),children:[n.jsx("option",{value:"",children:"Select management"}),fe(a,p.custom_management).map(H=>n.jsx("option",{value:H.name,children:H.name1||H.name},H.name))]}):n.jsx("input",{style:G,value:p.custom_management||"—",readOnly:!0})]})]}),n.jsxs("div",{style:xe,children:[n.jsxs("div",{children:[n.jsxs("label",{style:J,children:["Department ",!y&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),y?n.jsxs("select",{style:ee,value:p.custom_department,onChange:H=>c(se=>({...se,custom_department:H.target.value})),children:[n.jsx("option",{value:"",children:"Select department"}),fe(d,p.custom_department).map(H=>n.jsx("option",{value:H.name,children:H.department_name||H.name},H.name))]}):n.jsx("input",{style:G,value:p.custom_department||"—",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:J,children:["Branch ",!y&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),y?n.jsxs("select",{style:ee,value:p.custom_branch,onChange:H=>c(se=>({...se,custom_branch:H.target.value})),children:[n.jsx("option",{value:"",children:"Select branch"}),fe(u,p.custom_branch).map(H=>n.jsx("option",{value:H.name,children:H.branch||H.name},H.name))]}):n.jsx("input",{style:G,value:p.custom_branch||"—",readOnly:!0})]})]})]}),n.jsxs("div",{style:{background:N,borderRadius:12,padding:22,border:`1px solid ${M}`,boxShadow:`0 1px 4px rgba(0,0,0,${P?.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"})]}),s&&n.jsx("button",{onClick:()=>{S(H=>!H),x("")},style:{fontSize:13,color:"#3b82f6",background:"none",border:"none",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:g?"Cancel":"Change Password"})]}),g&&n.jsxs("div",{style:{marginTop:18,display:"flex",flexDirection:"column",gap:12},children:[n.jsxs("div",{style:_e,children:[n.jsxs("div",{children:[n.jsxs("label",{style:J,children:["New Password ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{type:"password",style:K,value:h.new,onChange:H=>m(se=>({...se,new:H.target.value})),placeholder:"New password"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:J,children:["Confirm Password ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{type:"password",style:K,value:h.confirm,onChange:H=>m(se=>({...se,confirm:H.target.value})),placeholder:"Confirm password"})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:Ce,style:{width:"100%",padding:"9px 0",borderRadius:8,border:"none",background:"#2563eb",color:"white",fontWeight:700,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:o==="saving"?"Saving…":"Update Password"})})]}),o&&o!=="saving"&&n.jsx("div",{style:{fontSize:13,color:o==="done"?"#16a34a":"#dc2626",fontWeight:500},children:o==="done"?"Password updated successfully":o==="error"?"Failed to update password":o})]})]})]})]})]})}function Ee({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 Ff={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151",boxSizing:"border-box"},f0={...Ff,cursor:"pointer"};function ct({filters:e,defaultOpen:t=!1}){const[l,s]=j.useState(t);return n.jsxs("div",{style:{background:"white",borderRadius:12,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:16},children:[n.jsxs("div",{onClick:()=>s(r=>!r),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",padding:"12px 18px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",userSelect:"none"},children:[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((r,i)=>n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:r.label}),r.type==="search"?n.jsx("input",{style:Ff,placeholder:r.placeholder,value:r.value,onChange:a=>r.onChange(a.target.value)}):n.jsx("select",{style:f0,value:r.value,onChange:a=>r.onChange(a.target.value),children:r.options.map(a=>n.jsx("option",{value:a.value,children:a.label},a.value))})]},i))})})]})}function h0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function g0({organizations:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=j.useState(""),[u,f]=j.useState("all"),[y,p]=j.useState("all"),c={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},v=j.useMemo(()=>e.filter(h=>{const m=[h.organization_name,h.city].filter(Boolean).join(" ").toLowerCase();return!(a&&!m.includes(a.toLowerCase())||u!=="all"&&h.type!==u||y!=="all"&&(h.is_active?"Active":"Inactive")!==y)}),[e,a,u,y]),[b,g]=j.useState(1);j.useEffect(()=>{g(1)},[a,u,y]);const S=v.slice((b-1)*ne,b*ne);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(Ee,{label:"Total",val:v.length,color:"#1a2332"}),n.jsx(Ee,{label:"Active",val:v.filter(h=>h.is_active).length,color:B.green}),n.jsx(Ee,{label:"Government",val:v.filter(h=>h.type==="Government").length,color:B.blue}),n.jsx(Ee,{label:"Private",val:v.filter(h=>h.type==="Private").length,color:B.orange})]}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Name or city…"},{type:"select",label:i.col.type,value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Government",label:"Government"},{value:"Private",label:"Private"}]},{type:"select",label:"Status",value:y,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:c,children:i.col.name}),n.jsx("th",{style:c,children:i.col.type}),n.jsx("th",{style:c,children:i.col.city}),n.jsx("th",{style:c,children:i.field.creationDate}),n.jsx("th",{style:c,children:i.col.status}),n.jsx("th",{style:c,children:i.col.actions})]})}),n.jsx("tbody",{children:v.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):S.map((h,m)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:m%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.organization_name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.type||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.city||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:h0(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:On(h.is_active?i.field.statusActive:i.field.statusInactive,h.is_active?B.green:B.gray)}),n.jsx("td",{style:{padding:"8px 14px"},onClick:o=>o.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(h),onEdit:t&&s?()=>s(h):void 0,onDelete:t&&r?()=>r(h.name):void 0})})]},h.name))})]})}),n.jsx(Fe,{page:b,total:v.length,onPageChange:g})]})}const Zt=e=>({background:e?"#f9f9f9":void 0});function x0({orgForm:e,setOrgForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=V(),S=e.name?s&&e.organization_name||g.formTitle.editOrg:g.formTitle.newOrg;return n.jsxs(Me,{title:S,activePage:"organizations",user:b,formStatus:l,buttonText:g.saveOrg,buttonColor:B.accent,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,children:[n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[g.field.orgName," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{type:"text",style:{...E,...Zt(s||!!e.name)},value:e.organization_name,disabled:s||!!e.name,required:!0,onChange:h=>t({...e,organization_name:h.target.value})})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[g.field.orgAcronym," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{type:"text",style:{...E,...Zt(s||!!e.name)},value:e.acronym||"",disabled:s||!!e.name,required:!0,onChange:h=>t({...e,acronym:h.target.value})})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.organizationType}),n.jsxs("select",{style:{...E,...Zt(s)},value:e.type,disabled:s,onChange:h=>t({...e,type:h.target.value}),children:[n.jsx("option",{children:"Government"}),n.jsx("option",{children:"Private"}),n.jsx("option",{children:"Non-Profit"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.orgCity}),n.jsx("input",{type:"text",style:{...E,...Zt(s)},value:e.city,disabled:s,onChange:h=>t({...e,city:h.target.value})})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.contactEmail}),n.jsx("input",{type:"email",style:{...E,...Zt(s)},value:e.contact_email,disabled:s,onChange:h=>t({...e,contact_email:h.target.value})})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:h=>t({...e,creation_date:h}),disabled:s,style:{...E,...Zt(s)}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.status}),n.jsxs("select",{style:{...E,...Zt(s)},value:e.is_active?"Active":"Inactive",disabled:s,onChange:h=>t({...e,is_active:h.target.value==="Active"?1:0}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.incidentTriageWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...E,...Zt(s)},value:e.incident_triage_window_days??3,disabled:s,onChange:h=>t({...e,incident_triage_window_days:parseInt(h.target.value)||3})}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:"Days after creation before an untriaged Incident is flagged overdue"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.incidentResolutionWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...E,...Zt(s)},value:e.incident_resolution_window_days??5,disabled:s,onChange:h=>t({...e,incident_resolution_window_days:parseInt(h.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 m0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function y0({managements:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*ne,c*ne);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ee,{label:"Total",val:p.length,color:B.blue})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:m0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function v0({form:e,setForm:t,organizations:l,formStatus:s,viewMode:r,onEdit:i,darkMode:a,notifCount:d,onToggleDark:u,onCountChange:f,onViewProfile:y,onSubmit:p,onBack:c,onNavigate:v,onLogout:b,user:g}){const S=V(),h=x=>t(C=>({...C,...x})),m=r?{background:"#f9f9f9"}:{},o=e.name?r?`${S.formTitle.editMgmt}: ${e.name1||e.name}`:S.formTitle.editMgmt:S.formTitle.newMgmt;return n.jsxs(Me,{title:o,activePage:"managements",user:g,formStatus:s,buttonText:S.saveMgmt,buttonColor:B.blue,viewMode:r,onEdit:i,darkMode:a,notifCount:d,onToggleDark:u,onCountChange:f,onViewProfile:y,onSubmit:p,onBack:c,onNavigate:v,onLogout:b,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.organization,onChange:x=>h({organization:x}),organizations:l,disabled:r||!!g.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...m},value:e.name1,disabled:r||!!e.name,onChange:x=>h({name1:x.target.value}),placeholder:"Management name",required:!0})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:x=>h({creation_date:x}),disabled:r,style:{...E,...m}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.status}),n.jsxs("select",{style:{...E,...m},value:e.status||"Active",disabled:r,onChange:x=>h({status:x.target.value}),children:[n.jsx("option",{value:"Active",children:S.field.statusActive}),n.jsx("option",{value:"Inactive",children:S.field.statusInactive})]})]})]})]})}function j0(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 b0({departments:e,managements:t,canModify:l,onView:s,onEdit:r,onDelete:i}){const a=V(),[d,u]=j.useState(""),[f,y]=j.useState(""),[p,c]=j.useState("all"),v=o=>{var x;return((x=t.find(C=>C.name===o))==null?void 0:x.name1)||o||"—"},b={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},g=j.useMemo(()=>e.filter(o=>{const x=(o.department_name||o.name||"").toLowerCase();return!(d&&!x.includes(d.toLowerCase())||f&&o.custom_management!==f||p!=="all"&&(o.custom_status||"Active")!==p)}),[e,d,f,p]),[S,h]=j.useState(1);j.useEffect(()=>{h(1)},[d,f,p]);const m=g.slice((S-1)*ne,S*ne);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ee,{label:"Total",val:g.length,color:B.teal})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:d,onChange:u,placeholder:"Search by name…"},{type:"select",label:a.col.management,value:f,onChange:y,options:[{value:"",label:"All Managements"},...t.map(o=>({value:o.name,label:o.name1||o.name}))]},{type:"select",label:"Status",value:p,onChange:c,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:b,children:a.col.name}),n.jsx("th",{style:b,children:a.col.management}),n.jsx("th",{style:b,children:a.field.creationDate}),n.jsx("th",{style:b,children:a.field.status}),n.jsx("th",{style:b,children:a.col.actions})]})}),n.jsx("tbody",{children:g.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):m.map((o,x)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.department_name||o.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:v(o.custom_management)}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:j0(o.custom_creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:o.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.custom_status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:C=>C.stopPropagation(),children:n.jsx(Je,{onView:()=>s==null?void 0:s(o),onEdit:l&&r?()=>r(o):void 0,onDelete:l&&i?()=>i(o.name):void 0})})]},o.name))})]})}),n.jsx(Fe,{page:S,total:g.length,onPageChange:h})]})}const S0={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20};function w0({form:e,setForm:t,organizations:l,managements:s,formStatus:r,viewMode:i,onEdit:a,darkMode:d,notifCount:u,onToggleDark:f,onCountChange:y,onViewProfile:p,onSubmit:c,onBack:v,onNavigate:b,onLogout:g,user:S}){const h=V(),m=A=>t(T=>({...T,...A})),o=i?{background:"#f9f9f9"}:{},x=e.name?i?`${h.formTitle.editDept}: ${e.department_name||e.name}`:h.formTitle.editDept:h.formTitle.newDept,C=fe(s,e.custom_management).map(A=>({name:A.name,label:A.name1||A.name}));return n.jsxs(Me,{title:x,activePage:"departments",user:S,formStatus:r,buttonText:h.saveDept,buttonColor:B.teal,viewMode:i,onEdit:a,darkMode:d,notifCount:u,onToggleDark:f,onCountChange:y,onViewProfile:p,onSubmit:c,onBack:v,onNavigate:b,onLogout:g,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.custom_organization,onChange:A=>m({custom_organization:A}),organizations:l,disabled:i||!!S.custom_organization})]}),n.jsxs("div",{style:S0,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.field.department," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...o},value:e.department_name,disabled:i||!!e.name,onChange:A=>m({department_name:A.target.value}),placeholder:"Department name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.management}),n.jsx(ue,{value:e.custom_management,onChange:A=>m({custom_management:A}),items:C,placeholder:h.field.select,disabled:i})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(me,{value:e.custom_creation_date||"",onChange:A=>m({custom_creation_date:A}),disabled:i,style:{...E,...o}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...E,...o},value:e.custom_status||"Active",disabled:i,onChange:A=>m({custom_status:A.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})]})}function k0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function _0({branches:e,managements:t,departments:l,canModify:s,onView:r,onEdit:i,onDelete:a}){const d=V(),[u,f]=j.useState(""),[y,p]=j.useState(""),[c,v]=j.useState(""),[b,g]=j.useState("all"),S=T=>{var w;return((w=t.find(_=>_.name===T))==null?void 0:w.name1)||T||"—"},h=T=>{var w;return((w=l.find(_=>_.name===T))==null?void 0:w.department_name)||T||"—"},m={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},o=j.useMemo(()=>e.filter(T=>{const w=(T.branch||T.name||"").toLowerCase();return!(u&&!w.includes(u.toLowerCase())||y&&T.management!==y||c&&T.department!==c||b!=="all"&&(T.custom_status||"Active")!==b)}),[e,u,y,c,b]),[x,C]=j.useState(1);j.useEffect(()=>{C(1)},[u,y,c,b]);const A=o.slice((x-1)*ne,x*ne);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ee,{label:"Total",val:o.length,color:B.purple})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:u,onChange:f,placeholder:"Search by name…"},{type:"select",label:d.col.management,value:y,onChange:p,options:[{value:"",label:"All Managements"},...t.map(T=>({value:T.name,label:T.name1||T.name}))]},{type:"select",label:d.col.department,value:c,onChange:v,options:[{value:"",label:"All Departments"},...l.map(T=>({value:T.name,label:T.department_name||T.name}))]},{type:"select",label:"Status",value:b,onChange:g,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:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:m,children:d.col.branch}),n.jsx("th",{style:m,children:d.col.management}),n.jsx("th",{style:m,children:d.col.department}),n.jsx("th",{style:m,children:d.field.creationDate}),n.jsx("th",{style:m,children:d.field.status}),n.jsx("th",{style:m,children:d.col.actions})]})}),n.jsx("tbody",{children:o.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:d.noData})}):A.map((T,w)=>n.jsxs("tr",{onClick:()=>r==null?void 0:r(T),style:{borderTop:"1px solid #f0f0f0",background:w%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:T.branch||T.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:S(T.management)}),n.jsx("td",{style:{padding:"10px 14px"},children:h(T.department)}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:k0(T.custom_creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:T.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:T.custom_status==="Inactive"?d.field.statusInactive:d.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:_=>_.stopPropagation(),children:n.jsx(Je,{onView:()=>r==null?void 0:r(T),onEdit:s&&i?()=>i(T):void 0,onDelete:s&&a?()=>a(T.name):void 0})})]},T.name))})]})}),n.jsx(Fe,{page:x,total:o.length,onPageChange:C})]})}const C0={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20};function z0({form:e,setForm:t,organizations:l,managements:s,departments:r,formStatus:i,viewMode:a,onEdit:d,darkMode:u,notifCount:f,onToggleDark:y,onCountChange:p,onViewProfile:c,onSubmit:v,onBack:b,onNavigate:g,onLogout:S,user:h}){const m=V(),o=w=>t(_=>({..._,...w})),x=a?{background:"#f9f9f9"}:{},C=e.name?a?`${m.formTitle.editBranch}: ${e.branch||e.name}`:m.formTitle.editBranch:m.formTitle.newBranch,A=fe(s,e.management).map(w=>({name:w.name,label:w.name1||w.name})),T=fe(r,e.department).map(w=>({name:w.name,label:w.department_name||w.name}));return n.jsxs(Me,{title:C,activePage:"branches",user:h,formStatus:i,buttonText:m.saveBranch,buttonColor:B.purple,viewMode:a,onEdit:d,darkMode:u,notifCount:f,onToggleDark:y,onCountChange:p,onViewProfile:c,onSubmit:v,onBack:b,onNavigate:g,onLogout:S,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[m.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.organization,onChange:w=>o({organization:w}),organizations:l,disabled:a||!!h.custom_organization})]}),n.jsxs("div",{style:C0,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[m.field.branch," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...x},value:e.branch,disabled:a||!!e.name,onChange:w=>o({branch:w.target.value}),placeholder:"Branch name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:m.field.management}),n.jsx(ue,{value:e.management,onChange:w=>o({management:w}),items:A,placeholder:m.field.select,disabled:a})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:m.field.department}),n.jsx(ue,{value:e.department,onChange:w=>o({department:w}),items:T,placeholder:m.field.select,disabled:a})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:m.field.creationDate}),n.jsx(me,{value:e.custom_creation_date||"",onChange:w=>o({custom_creation_date:w}),disabled:a,style:{...E,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:m.field.status}),n.jsxs("select",{style:{...E,...x},value:e.custom_status||"Active",disabled:a,onChange:w=>o({custom_status:w.target.value}),children:[n.jsx("option",{value:"Active",children:m.field.statusActive}),n.jsx("option",{value:"Inactive",children:m.field.statusInactive})]})]})]})]})}function T0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function P0({incidentTypes:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*ne,c*ne);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ee,{label:"Total",val:p.length,color:B.red})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:T0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function I0({form:e,setForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=V(),S=o=>t(x=>({...x,...o})),h=s?{background:"#f9f9f9"}:{},m=e.name?s?`Incident Type: ${e.name1||e.name}`:"Edit Incident Type":"New Incident Type";return n.jsxs(Me,{title:m,activePage:"incident-types",user:b,formStatus:l,buttonText:g.saveName,buttonColor:B.red,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...h},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Incident type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...E,...h}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.status}),n.jsxs("select",{style:{...E,...h},value:e.status||"Active",disabled:s,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}function E0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function A0({ideaTypes:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*ne,c*ne);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ee,{label:"Total",val:p.length,color:B.teal})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:E0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function R0({form:e,setForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=V(),S=o=>t(x=>({...x,...o})),h=s?{background:"#f9f9f9"}:{},m=e.name?s?`Idea Type: ${e.name1||e.name}`:"Edit Idea Type":"New Idea Type";return n.jsxs(Me,{title:m,activePage:"idea-types",user:b,formStatus:l,buttonText:g.saveName,buttonColor:B.teal,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...h},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Idea type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...E,...h}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.status}),n.jsxs("select",{style:{...E,...h},value:e.status||"Active",disabled:s,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}function L0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function O0({orderTypes:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*ne,c*ne);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ee,{label:"Total",val:p.length,color:B.purple})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:L0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function D0({form:e,setForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=V(),S=o=>t(x=>({...x,...o})),h=s?{background:"#f9f9f9"}:{},m=e.name?s?`Order Type: ${e.name1||e.name}`:"Edit Order Type":"New Order Type";return n.jsxs(Me,{title:m,activePage:"order-types",user:b,formStatus:l,buttonText:g.saveName,buttonColor:B.purple,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...h},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Order type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...E,...h}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.status}),n.jsxs("select",{style:{...E,...h},value:e.status||"Active",disabled:s,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}function N0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function W0({processTypes:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*ne,c*ne);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ee,{label:"Total",val:p.length,color:B.blue})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:N0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function B0({form:e,setForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=V(),S=o=>t(x=>({...x,...o})),h=s?{background:"#f9f9f9"}:{},m=e.name?s?`Process Type: ${e.name1||e.name}`:"Edit Process Type":"New Process Type";return n.jsxs(Me,{title:m,activePage:"process-types",user:b,formStatus:l,buttonText:g.saveName,buttonColor:B.blue,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...h},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Process type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...E,...h}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.status}),n.jsxs("select",{style:{...E,...h},value:e.status||"Active",disabled:s,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}function $0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function U0({incidentStatuses:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*ne,c*ne);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ee,{label:"Total",val:p.length,color:B.red})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.notifyManager}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:$0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function F0({form:e,setForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=V(),S=o=>t(x=>({...x,...o})),h=s?{background:"#f9f9f9"}:{},m=e.name?s?`Incident Status: ${e.name1||e.name}`:"Edit Incident Status":"New Incident Status";return n.jsxs(Me,{title:m,activePage:"incident-statuses",user:b,formStatus:l,buttonText:g.saveName,buttonColor:B.red,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...h},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Incident status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:s,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:Gl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:s?"default":"pointer"},children:g.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...E,...h}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.status}),n.jsxs("select",{style:{...E,...h},value:e.status||"Active",disabled:s,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}function M0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function H0({ideaStatuses:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*ne,c*ne);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ee,{label:"Total",val:p.length,color:B.teal})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.notifyManager}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:M0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function K0({form:e,setForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=V(),S=o=>t(x=>({...x,...o})),h=s?{background:"#f9f9f9"}:{},m=e.name?s?`Idea Status: ${e.name1||e.name}`:"Edit Idea Status":"New Idea Status";return n.jsxs(Me,{title:m,activePage:"idea-statuses",user:b,formStatus:l,buttonText:g.saveName,buttonColor:B.teal,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...h},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Idea status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:s,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:Gl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:s?"default":"pointer"},children:g.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...E,...h}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.status}),n.jsxs("select",{style:{...E,...h},value:e.status||"Active",disabled:s,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}function Q0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function G0({orderStatuses:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*ne,c*ne);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ee,{label:"Total",val:p.length,color:B.purple})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.notifyManager}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:Q0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function Y0({form:e,setForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=V(),S=o=>t(x=>({...x,...o})),h=s?{background:"#f9f9f9"}:{},m=e.name?s?`Order Status: ${e.name1||e.name}`:"Edit Order Status":"New Order Status";return n.jsxs(Me,{title:m,activePage:"order-statuses",user:b,formStatus:l,buttonText:g.saveName,buttonColor:B.purple,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...h},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Order status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:s,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:Gl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:s?"default":"pointer"},children:g.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...E,...h}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.status}),n.jsxs("select",{style:{...E,...h},value:e.status||"Active",disabled:s,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}function X0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function q0({processStatuses:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*ne,c*ne);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ee,{label:"Total",val:p.length,color:B.blue})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.notifyManager}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:X0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function J0({form:e,setForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=V(),S=o=>t(x=>({...x,...o})),h=s?{background:"#f9f9f9"}:{},m=e.name?s?`Process Status: ${e.name1||e.name}`:"Edit Process Status":"New Process Status";return n.jsxs(Me,{title:m,activePage:"process-statuses",user:b,formStatus:l,buttonText:g.saveName,buttonColor:B.blue,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...h},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Process status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:s,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:Gl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:s?"default":"pointer"},children:g.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...E,...h}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.status}),n.jsxs("select",{style:{...E,...h},value:e.status||"Active",disabled:s,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}const Z0={Admin:"#7c3aed",Chairman:"#0f766e",Auditor:"#d97706","X-Auditor":"#8b5cf6",Manager:"#2563eb",Employee:"#6b7280"};function V0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function e1({users:e,canModify:t,onView:l,onEdit:s,onDisable:r}){const i=V(),[a,d]=j.useState(!1),[u,f]=j.useState(""),[y,p]=j.useState(""),[c,v]=j.useState(""),[b,g]=j.useState("active"),[S,h]=j.useState(1),[m,o]=j.useState(null),[x,C]=j.useState(""),[A,T]=j.useState("idle"),[w,_]=j.useState(null),U=async()=>{if(!(!m||!x.trim())){T("loading");try{await Bf(m.name,x.trim()),T("success"),setTimeout(()=>{o(null),C(""),T("idle")},1200)}catch{T("error")}}},P=async L=>{if(window.confirm(i.users.disableConfirm)){_(L);try{await(r==null?void 0:r(L))}finally{_(null)}}},I=e.filter(L=>{if(b==="active"&&(L.enabled===0||L.enabled==="0")||b==="inactive"&&L.enabled!==0&&L.enabled!=="0")return!1;const K=L.custom_category||"";if(c&&K!==c)return!1;const G=L.custom_organization||"";if(y&&!G.toLowerCase().includes(y.toLowerCase()))return!1;if(u){const ee=u.toLowerCase();if(![L.full_name,L.email,L.name,L.username,L.mobile_no].join(" ").toLowerCase().includes(ee))return!1}return!0}),N=[...new Set(e.map(L=>L.custom_organization).filter(Boolean))],M=["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"];j.useEffect(()=>{h(1)},[u,y,c,b]);const Z=I.slice((S-1)*ne,S*ne),ge={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151"},le={...ge,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: ",I.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(L=>!L),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",padding:"12px 18px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",userSelect:"none"},children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:a?n.jsx("polyline",{points:"18,15 12,9 6,15"}):n.jsx("polyline",{points:"6,9 12,15 18,9"})}),n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{style:{color:"white",fontWeight:700,fontSize:14},children:"Filters"})]}),a&&n.jsx("div",{style:{padding:"18px 20px",display:"flex",flexDirection:"column",gap:14},children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gap:14},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Search"}),n.jsx("input",{style:ge,placeholder:"Name, email, username…",value:u,onChange:L=>f(L.target.value)})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Organization"}),n.jsxs("select",{style:le,value:y,onChange:L=>p(L.target.value),children:[n.jsx("option",{value:"",children:"All Organizations"}),N.map(L=>n.jsx("option",{value:L,children:L},L))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Category"}),n.jsxs("select",{style:le,value:c,onChange:L=>v(L.target.value),children:[n.jsx("option",{value:"",children:"All Categories"}),M.map(L=>n.jsx("option",{value:L,children:L},L))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Status"}),n.jsxs("select",{style:le,value:b,onChange:L=>g(L.target.value),children:[n.jsx("option",{value:"all",children:"All"}),n.jsx("option",{value:"active",children:"Active"}),n.jsx("option",{value:"inactive",children:"Inactive"})]})]})]})})]}),n.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa",borderBottom:"2px solid #f0f0f0"},children:[{label:"Category",w:100},{label:"Number",w:80},{label:"Full Name",w:140},{label:"Username",w:120},{label:"Email Address",w:180},{label:"Phone Number",w:120},{label:"Organization",w:130},{label:"Management",w:120},{label:"Department",w:120},{label:"Branch",w:100},{label:"Since",w:90},{label:"Status",w:80},{label:"Tools",w:200}].map(({label:L,w:K})=>n.jsx("th",{style:{padding:"11px 14px",textAlign:"left",color:"#6b7280",fontSize:11,fontWeight:700,whiteSpace:"nowrap",minWidth:K,letterSpacing:.3,textTransform:"uppercase"},children:L},L))})}),n.jsx("tbody",{children:I.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((L,K)=>{const G=L.custom_category||"",ee=Z0[G]||"#6b7280";return n.jsxs("tr",{onClick:()=>l==null?void 0:l(L),style:{borderBottom:"1px solid #f3f4f6",background:K%2===0?"white":"#fafafa",transition:"background 0.1s",cursor:"pointer"},onMouseEnter:J=>J.currentTarget.style.background="#f0f7ff",onMouseLeave:J=>J.currentTarget.style.background=K%2===0?"white":"#fafafa",children:[n.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:G?n.jsx("span",{style:{background:ee+"18",color:ee,border:`1px solid ${ee}44`,padding:"3px 10px",borderRadius:20,fontSize:11,fontWeight:700},children:G}):n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.custom_number||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",fontWeight:600,color:"#1a2332",whiteSpace:"nowrap"},children:L.full_name||L.first_name||"—"}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:L.username||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:L.email||L.name}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.mobile_no||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:L.custom_organization||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.custom_management||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.custom_department||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.custom_branch||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:V0(L.creation)}),n.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:n.jsx("span",{style:{color:L.enabled?"#16a34a":"#dc2626",fontWeight:600},children:L.enabled?i.users.active:i.users.inactive})}),n.jsx("td",{style:{padding:"10px 14px",whiteSpace:"nowrap"},onClick:J=>J.stopPropagation(),children:n.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[n.jsx("button",{onClick:J=>{J.stopPropagation(),l==null||l(L)},title:"View",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#e0f7fa",color:"#0891b2"},children:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),t&&s&&n.jsx("button",{onClick:J=>{J.stopPropagation(),s(L)},title:"Edit",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#dcfce7",color:"#16a34a"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),t&&n.jsx("button",{onClick:J=>{J.stopPropagation(),o({name:L.name,email:L.email||L.name}),C(""),T("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:J=>{J.stopPropagation(),P(L.name)},disabled:w===L.name,title:"Disable",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#fee2e2",color:"#ef4444",opacity:w===L.name?.5:1},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("polyline",{points:"3 6 5 6 21 6"}),n.jsx("path",{d:"M19 6l-1 14H6L5 6"}),n.jsx("path",{d:"M10 11v6M14 11v6"}),n.jsx("path",{d:"M9 6V4h6v2"})]})})]})})]},L.name)})})]})}),n.jsx(Fe,{page:S,total:I.length,onPageChange:h}),m&&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:m.email})]}),n.jsx("input",{type:"password",value:x,onChange:L=>C(L.target.value),placeholder:i.users.newPassword,style:{width:"100%",padding:"10px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,boxSizing:"border-box",marginBottom:16,fontFamily:"Segoe UI",outline:"none"},onKeyDown:L=>L.key==="Enter"&&U(),autoFocus:!0}),A==="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"}),A==="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:A==="loading"||!x.trim(),style:{flex:1,padding:10,background:"#2563eb",color:"white",border:"none",borderRadius:8,cursor:"pointer",fontSize:13,fontWeight:700,fontFamily:"inherit",opacity:x.trim()?1:.5},children:A==="loading"?"Saving…":i.users.setPassword}),n.jsx("button",{onClick:()=>{o(null),C(""),T("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 ms={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20};function t1({form:e,setForm:t,organizations:l,managements:s,departments:r,branches:i,formStatus:a,viewMode:d,onEdit:u,darkMode:f,notifCount:y,onToggleDark:p,onCountChange:c,onViewProfile:v,isSelfProfile:b,onSubmit:g,onBack:S,onNavigate:h,onLogout:m,user:o}){const x=V(),C=I=>t(N=>({...N,...I})),A=d?{background:"#f9f9f9"}:{},T=!e.name,w=b?"My Profile":T?"New User":d?`User: ${e.full_name||e.email}`:`Edit User: ${e.full_name||e.email}`,_=fe(s,e.custom_management).map(I=>({name:I.name,label:I.name1||I.name})),U=fe(r,e.custom_department).map(I=>({name:I.name,label:I.department_name||I.name})),P=fe(i,e.custom_branch).map(I=>({name:I.name,label:I.branch||I.name}));return n.jsxs(Me,{title:w,activePage:"users",user:o,formStatus:a,buttonText:x.saveUser,buttonColor:B.blue,viewMode:d,onEdit:u,darkMode:f,notifCount:y,onToggleDark:p,onCountChange:c,onViewProfile:v,hideSettings:b,onSubmit:g,onBack:S,onNavigate:h,onLogout:m,children:[n.jsxs("div",{style:ms,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.organization}),n.jsx(Et,{value:e.custom_organization,onChange:I=>C({custom_organization:I}),organizations:l,disabled:d})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.management}),n.jsx(ue,{value:e.custom_management,onChange:I=>C({custom_management:I}),items:_,placeholder:"-- Select --",disabled:d})]})]}),n.jsxs("div",{style:ms,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.department}),n.jsx(ue,{value:e.custom_department,onChange:I=>C({custom_department:I}),items:U,placeholder:"-- Select --",disabled:d})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.branch}),n.jsx(ue,{value:e.custom_branch,onChange:I=>C({custom_branch:I}),items:P,placeholder:"-- Select --",disabled:d})]})]}),n.jsxs("div",{style:ms,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.number}),n.jsx("input",{style:{...E,...A},value:e.custom_number,disabled:d,onChange:I=>C({custom_number:I.target.value}),placeholder:"e.g. 10001"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[x.field.fullName," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...A},value:e.first_name,disabled:d,onChange:I=>C({first_name:I.target.value}),placeholder:"Full name",required:!0})]})]}),n.jsxs("div",{style:ms,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.username}),n.jsx("input",{style:{...E,...A},value:e.username,disabled:d,onChange:I=>C({username:I.target.value}),placeholder:"Username"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.phoneNumber}),n.jsx("input",{style:{...E,...A},value:e.mobile_no,disabled:d,onChange:I=>C({mobile_no:I.target.value}),placeholder:"Phone number"})]})]}),n.jsxs("div",{style:ms,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[x.field.emailAddress," ",T&&n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...d||!T?{background:"#f9f9f9"}:{}},value:e.email,disabled:d||!T,onChange:I=>C({email:I.target.value}),placeholder:"user@example.com",type:"email",required:T})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.category}),n.jsxs("select",{style:{...E,...A},value:e.custom_category,disabled:d,onChange:I=>C({custom_category:I.target.value}),children:[n.jsx("option",{value:"",children:x.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 du={Active:B.green,Closed:B.gray};function n1({cycles:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=j.useState(""),[u,f]=j.useState(""),[y,p]=j.useState("all"),c=j.useMemo(()=>[...new Set(e.map(o=>o.organization).filter(Boolean))],[e]),v=j.useMemo(()=>e.filter(o=>{const x=(o.name1||o.name||"").toLowerCase();return!(a&&!x.includes(a.toLowerCase())||u&&o.organization!==u||y!=="all"&&o.status!==y)}),[e,a,u,y]),[b,g]=j.useState(1);j.useEffect(()=>{g(1)},[a,u,y]);const S=v.slice((b-1)*ne,b*ne),h=v.filter(o=>o.status==="Active").length,m=v.filter(o=>o.status==="Closed").length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(Ee,{label:"Total",val:v.length,color:B.teal}),n.jsx(Ee,{label:"Active",val:h,color:B.green}),n.jsx(Ee,{label:"Closed",val:m,color:B.gray})]}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:i.col.organization,value:u,onChange:f,options:[{value:"",label:"All Organizations"},...c.map(o=>({value:o,label:o}))]},{type:"select",label:"Status",value:y,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:"Active"},{value:"Closed",label:"Closed"}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.name}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.frequency}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.startDate}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.endDate}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.actions})]})}),n.jsx("tbody",{children:v.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):S.map((o,x)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(o),style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.frequency||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.start_date||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.end_date||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{padding:"3px 10px",borderRadius:12,fontSize:12,background:du[o.status]+"22",color:du[o.status]||"#666"},children:o.status})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:C=>C.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(o),onEdit:t&&s?()=>s(o):void 0,onDelete:t&&r?()=>r(o.name):void 0})})]},o.name))})]})}),n.jsx(Fe,{page:b,total:v.length,onPageChange:g})]})}const Ia={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},l1=["Weekly","Bi-weekly","Monthly","Quarterly","Annually"],s1=["Active","Closed"];function r1({form:e,setForm:t,organizations:l,formStatus:s,viewMode:r,onEdit:i,darkMode:a,notifCount:d,onToggleDark:u,onCountChange:f,onViewProfile:y,onSubmit:p,onBack:c,onNavigate:v,onLogout:b,user:g}){const S=V(),h=x=>t(C=>({...C,...x})),m=r?{background:"#f9f9f9"}:{},o=e.name?r?`${S.formTitle.editCycle}: ${e.name1||e.name}`:S.formTitle.editCycle:S.formTitle.newCycle;return n.jsxs(Me,{title:o,activePage:"cycles",user:g,formStatus:s,buttonText:S.saveCycle,buttonColor:B.teal,viewMode:r,onEdit:i,darkMode:a,notifCount:d,onToggleDark:u,onCountChange:f,onViewProfile:y,onSubmit:p,onBack:c,onNavigate:v,onLogout:b,children:[n.jsxs("div",{style:Ia,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...m},value:e.name1||"",disabled:r||!!e.name,onChange:x=>h({name1:x.target.value}),placeholder:"e.g. Q1-2026"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.organization,onChange:x=>h({organization:x}),organizations:l,disabled:r||!!g.custom_organization})]})]}),n.jsxs("div",{style:Ia,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.col.frequency}),n.jsx(ue,{value:e.frequency,onChange:x=>h({frequency:x}),items:l1.map(x=>({name:x,label:x})),placeholder:"-- Select Frequency --",disabled:r})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.status}),n.jsx(ue,{value:e.status,onChange:x=>h({status:x}),items:s1.map(x=>({name:x,label:x})),placeholder:"-- Select Status --",disabled:r})]})]}),n.jsxs("div",{style:Ia,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.dateStart}),n.jsx(me,{value:e.start_date||"",onChange:x=>h({start_date:x}),disabled:r,style:{...E,...m}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.dateEnd}),n.jsx(me,{value:e.end_date||"",onChange:x=>h({end_date:x}),disabled:r,style:{...E,...m}})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.updateWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...E,...m,maxWidth:160},value:e.update_window_days??2,disabled:r,onChange:x=>h({update_window_days:parseInt(x.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 i1({kpiInputs:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=j.useState(""),[u,f]=j.useState(""),y=j.useMemo(()=>[...new Set(e.map(g=>g.organization).filter(Boolean))],[e]),p=j.useMemo(()=>e.filter(g=>{const S=[g.organization,g.period].filter(Boolean).join(" ").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u&&g.organization!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*ne,c*ne);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ee,{label:"Total Records",val:p.length,color:B.blue})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Organization or period…"},{type:"select",label:i.col.organization,value:u,onChange:f,options:[{value:"",label:"All Organizations"},...y.map(g=>({value:g,label:g}))]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.period}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.field.revenue_growth}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.field.net_profit}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.dash.customerSat}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.period||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.revenue_growth!=null?`${g.revenue_growth}%`:"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.net_profit!=null?g.net_profit.toLocaleString():"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.customer_satisfaction!=null?g.customer_satisfaction:"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}const uu={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},pu={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20};function a1({form:e,setForm:t,organizations:l,formStatus:s,viewMode:r,onEdit:i,darkMode:a,notifCount:d,onToggleDark:u,onCountChange:f,onViewProfile:y,onSubmit:p,onBack:c,onNavigate:v,onLogout:b,user:g}){const S=V(),h=C=>t(A=>({...A,...C})),m=r?{background:"#f9f9f9"}:{},o=C=>A=>h({[C]:parseFloat(A.target.value)||0}),x=e.name?r?`${S.formTitle.editKpi}: ${e.period||e.name}`:S.formTitle.editKpi:S.formTitle.newKpi;return n.jsxs(Me,{title:x,activePage:"kpi-input",user:g,formStatus:s,buttonText:S.saveKpi,buttonColor:B.blue,viewMode:r,onEdit:i,darkMode:a,notifCount:d,onToggleDark:u,onCountChange:f,onViewProfile:y,onSubmit:p,onBack:c,onNavigate:v,onLogout:b,children:[n.jsxs("div",{style:uu,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.organization,onChange:C=>h({organization:C}),organizations:l,disabled:r||!!g.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[S.col.period," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...m},value:e.period||"",disabled:r,onChange:C=>h({period:C.target.value}),placeholder:"e.g. Q1 2026"})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",marginBottom:12},children:"Financial KPIs"}),n.jsxs("div",{style:pu,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.revenue_growth}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...m},value:e.revenue_growth||"",disabled:r,onChange:o("revenue_growth")})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.net_profit}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...m},value:e.net_profit||"",disabled:r,onChange:o("net_profit")})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.cash_flow}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...m},value:e.cash_flow||"",disabled:r,onChange:o("cash_flow")})]})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",marginBottom:12},children:"Operational KPIs"}),n.jsxs("div",{style:pu,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.strategic_goal_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...m},value:e.strategic_goal_pct||"",disabled:r,onChange:o("strategic_goal_pct")})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.customer_satisfaction}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...m},value:e.customer_satisfaction||"",disabled:r,onChange:o("customer_satisfaction")})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.employee_turnover_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...m},value:e.employee_turnover_pct||"",disabled:r,onChange:o("employee_turnover_pct")})]})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",marginBottom:12},children:"Safety & Compliance"}),n.jsxs("div",{style:uu,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.open_safety_incidents}),n.jsx("input",{type:"number",min:0,style:{...E,...m},value:e.open_safety_incidents||"",disabled:r,onChange:C=>h({open_safety_incidents:parseInt(C.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:S.field.compliance_score}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...m},value:e.compliance_score||"",disabled:r,onChange:o("compliance_score")})]})]})]})]})}const o1={create_processes:"Create Processes",update_process_status:"Update Process Status"},fu={Pending:B.orange,Accepted:B.green,Rejected:B.red,Revoked:B.gray};function c1(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 d1(e){const t=[];return e.create_processes&&t.push("create_processes"),e.update_process_status&&t.push("update_process_status"),t}function u1({delegations:e,organizations:t,userRole:l,currentUser:s,onView:r,onRevoke:i}){const a=V(),[d,u]=j.useState(""),[f,y]=j.useState(""),[p,c]=j.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=j.useMemo(()=>e.filter(x=>{const C=`${x.auditor} ${x.manager}`.toLowerCase();return!(d&&!C.includes(d.toLowerCase())||f&&x.organization!==f||p!=="all"&&x.status!==p)}),[e,d,f,p]),[g,S]=j.useState(1);j.useEffect(()=>{S(1)},[d,f,p]);const h=b.slice((g-1)*ne,g*ne),m=b.filter(x=>x.status==="Pending").length,o=b.filter(x=>x.status==="Accepted").length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(Ee,{label:"Total",val:b.length,color:B.purple}),n.jsx(Ee,{label:"Pending",val:m,color:B.orange}),n.jsx(Ee,{label:"Accepted",val:o,color:B.green})]}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:d,onChange:u,placeholder:"Auditor or Manager…"},{type:"select",label:a.col.organization,value:f,onChange:y,options:[{value:"",label:"All Organizations"},...t.map(x=>({value:x.organization_name||x.name,label:x.organization_name||x.name}))]},{type:"select",label:"Status",value:p,onChange:c,options:[{value:"all",label:"All"},{value:"Pending",label:"Pending"},{value:"Accepted",label:"Accepted"},{value:"Rejected",label:"Rejected"},{value:"Revoked",label:"Revoked"}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:a.col.number}),n.jsx("th",{style:v,children:a.col.auditor}),n.jsx("th",{style:v,children:a.col.manager}),n.jsx("th",{style:v,children:a.col.organization}),n.jsx("th",{style:v,children:a.col.functions}),n.jsx("th",{style:v,children:a.col.status}),n.jsx("th",{style:v,children:a.col.requestedOn}),n.jsx("th",{style:v,children:a.col.actions})]})}),n.jsx("tbody",{children:b.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:8,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):h.map((x,C)=>{const A=!!i&&(x.status==="Pending"||x.status==="Accepted")&&(l==="Admin"||l==="Auditor"&&x.auditor===s);return n.jsxs("tr",{onClick:()=>r==null?void 0:r(x),style:{borderTop:"1px solid #f0f0f0",background:C%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:x.number||x.name}),n.jsx("td",{style:{padding:"10px 14px"},children:x.auditor}),n.jsx("td",{style:{padding:"10px 14px"},children:x.manager}),n.jsx("td",{style:{padding:"10px 14px"},children:x.organization||"All Organizations"}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:d1(x).map(T=>n.jsx("span",{style:{background:"#ede9fe",color:"#6d28d9",padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600},children:o1[T]||T},T))})}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{background:(fu[x.status]||B.gray)+"22",color:fu[x.status]||B.gray,padding:"3px 10px",borderRadius:12,fontSize:12,fontWeight:700},children:x.status})}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:c1(x.requested_on)}),n.jsx("td",{style:{padding:"8px 14px"},onClick:T=>T.stopPropagation(),children:n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("button",{onClick:()=>r==null?void 0:r(x),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"})]})}),A&&n.jsx("button",{onClick:()=>i==null?void 0:i(x.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"})]})})]},x.name)})})]})}),n.jsx(Fe,{page:g,total:b.length,onPageChange:S})]})}const hu={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},gu={Pending:B.orange,Accepted:B.green,Rejected:B.red,Revoked:B.gray};function p1(e){if(!e)return"—";const t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleString()}function f1({form:e,setForm:t,organizations:l,users:s,userRoleMap:r,formStatus:i,viewMode:a,onEdit:d,darkMode:u,notifCount:f,onToggleDark:y,onCountChange:p,onViewProfile:c,onSubmit:v,onBack:b,onNavigate:g,onLogout:S,user:h}){var T;const m=V(),o=w=>t(_=>({..._,...w})),x=a?{background:"#f9f9f9"}:{},C=Ql(s,r,"SB Manager").map(w=>({name:w.name,label:w.full_name||w.name})),A=e.name?`${m.formTitle.viewDelegation}${e.number||e.name}`:m.formTitle.newDelegation;return n.jsxs(Me,{title:A,activePage:"delegations",user:h,formStatus:i,buttonText:m.saveDelegation,buttonColor:B.purple,viewMode:a,onEdit:d,darkMode:u,notifCount:f,onToggleDark:y,onCountChange:p,onViewProfile:c,onSubmit:v,onBack:b,onNavigate:g,onLogout:S,children:[a&&e.status&&n.jsx("div",{style:{marginBottom:20},children:n.jsx("span",{style:{background:(gu[e.status]||B.gray)+"22",color:gu[e.status]||B.gray,padding:"5px 14px",borderRadius:14,fontSize:13,fontWeight:700},children:e.status})}),n.jsxs("div",{style:hu,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:m.col.auditor}),n.jsx("input",{style:{...E,background:"#f9f9f9"},value:e.auditor||h.name,disabled:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[m.col.manager," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(ue,{value:e.manager,onChange:w=>o({manager:w}),items:C,placeholder:"-- Select Manager --",disabled:a})]})]}),n.jsx("div",{style:hu,children:n.jsxs("div",{children:[n.jsx("label",{style:z,children:m.col.organization}),n.jsx(Et,{value:e.organization,onChange:w=>o({organization:w}),organizations:l,placeholder:"-- All Organizations --",disabled:a})]})}),n.jsxs("div",{style:{marginTop:8},children:[n.jsxs("label",{style:z,children:[m.col.functions," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,marginTop:6},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:a?"default":"pointer"},children:[n.jsx("input",{type:"checkbox",style:Gl,checked:!!e.create_processes,disabled:a,onChange:w=>o({create_processes:w.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:Gl,checked:!!e.update_process_status,disabled:a,onChange:w=>o({update_process_status:w.target.checked?1:0})}),n.jsx("span",{style:{fontSize:14},children:"Update Process Status"})]})]})]}),!a&&n.jsxs("div",{style:{marginTop:20},children:[n.jsx("label",{style:z,children:"Remarks"}),n.jsx("textarea",{style:{...E,...x,minHeight:70,resize:"vertical"},value:e.remarks||"",onChange:w=>o({remarks:w.target.value}),placeholder:"Optional note for the Manager…"})]}),a&&(((T=e.delegation_log)==null?void 0:T.length)??0)>0&&n.jsxs("div",{style:{marginTop:28},children:[n.jsx("label",{style:z,children:"Audit Trail"}),n.jsx("div",{style:{background:"white",borderRadius:8,border:"1px solid #eee",overflow:"hidden"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa"},children:[n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Action"}),n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Actor"}),n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Timestamp"}),n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Remarks"})]})}),n.jsx("tbody",{children:(e.delegation_log||[]).map((w,_)=>n.jsxs("tr",{style:{borderTop:"1px solid #f0f0f0"},children:[n.jsx("td",{style:{padding:"8px 14px",fontWeight:600},children:w.action}),n.jsx("td",{style:{padding:"8px 14px"},children:w.actor}),n.jsx("td",{style:{padding:"8px 14px",color:"#666"},children:p1(w.timestamp)}),n.jsx("td",{style:{padding:"8px 14px",color:"#666"},children:w.remarks||"—"})]},w.name||_))})]})})]})]})}const xu={process:"processes-form",order:"orders-form",incident:"incidents-form",idea:"ideas-form"},ys={process:B.blue,order:B.purple,incident:B.red,idea:B.green,delegation:B.orange},mu={process:"🔄",order:"📦",incident:"🚨",idea:"💡",delegation:"🤝"};function vs(e,t){const l=e.replace("#",""),s=parseInt(l.substring(0,2),16),r=parseInt(l.substring(2,4),16),i=parseInt(l.substring(4,6),16);return`rgba(${s}, ${r}, ${i}, ${t})`}function h1({onNavigate:e,onRefresh:t}){const l=V(),[s,r]=j.useState([]),[i,a]=j.useState(!0),[d,u]=j.useState(""),[f,y]=j.useState(""),p=()=>vy().then(h=>{r(h),a(!1)});j.useEffect(()=>{p()},[]);const c=s.filter(h=>h.requires_action),v=s.filter(h=>!h.requires_action),b={};for(const h of s)b[h.type]=(b[h.type]||0)+1;const g=async(h,m)=>{u(h),y("");try{await by(h,m),await p(),t==null||t()}catch{y(h)}u("")};function S(h,m,o){return m.length===0?null:n.jsxs("div",{style:{marginBottom:28},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:14},children:[n.jsx("span",{style:{fontSize:12,fontWeight:800,letterSpacing:.6,textTransform:"uppercase",color:o?B.accent:"#8a8fa3"},children:h}),n.jsx("span",{style:{fontSize:11,fontWeight:700,minWidth:22,textAlign:"center",padding:"2px 7px",borderRadius:999,color:o?"white":"#6b7280",background:o?B.accent:"#e9eaf2"},children:m.length}),n.jsx("div",{style:{flex:1,height:1,background:"linear-gradient(90deg, #e6e7f0, transparent)"}})]}),n.jsx("div",{className:"inbox-card-grid",children:m.map((x,C)=>{const A=x.type!=="delegation",T=ys[x.type]||B.gray;return n.jsxs("div",{className:"inbox-card",onClick:A?()=>e(xu[x.type],x.name):void 0,style:{borderTop:`3px solid ${T}`,cursor:A?"pointer":"default"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:14},children:[n.jsx("div",{style:{width:38,height:38,borderRadius:12,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:17,background:vs(T,.14)},children:mu[x.type]||"📌"}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[n.jsx("span",{style:{fontWeight:700,fontSize:13,color:T,letterSpacing:.3},children:x.number}),x.requires_action&&n.jsx("span",{style:{fontSize:10,fontWeight:700,color:B.red,background:vs(B.red,.12),padding:"1px 7px",borderRadius:999,textTransform:"uppercase",letterSpacing:.4},children:"Action"})]}),n.jsx("div",{className:"inbox-card-title",style:{fontSize:14,fontWeight:600,marginTop:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.title}),n.jsxs("div",{className:"inbox-card-meta",style:{marginTop:5,fontSize:12},children:[x.action,x.organization&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{opacity:.5},children:" · "}),x.organization]}),x.date&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{opacity:.5},children:" · "}),x.date]})]}),f===x.name&&n.jsx("div",{style:{marginTop:6,fontSize:12,color:B.red,fontWeight:600},children:"Failed to respond — please try again."})]})]}),x.type==="delegation"?n.jsxs("div",{style:{display:"flex",gap:8,marginTop:14},children:[n.jsx("button",{onClick:()=>g(x.name,"Accepted"),disabled:d===x.name,style:{flex:1,padding:"8px 0",borderRadius:9,border:"none",background:B.green,color:"white",fontWeight:700,fontSize:13,cursor:d===x.name?"wait":"pointer",opacity:d===x.name?.6:1},children:"Accept"}),n.jsx("button",{onClick:()=>g(x.name,"Rejected"),disabled:d===x.name,style:{flex:1,padding:"8px 0",borderRadius:9,border:"none",background:B.red,color:"white",fontWeight:700,fontSize:13,cursor:d===x.name?"wait":"pointer",opacity:d===x.name?.6:1},children:"Reject"})]}):n.jsx("button",{onClick:w=>{w.stopPropagation(),e(xu[x.type],x.name)},style:{marginTop:14,width:"100%",padding:"8px 0",borderRadius:9,border:"none",background:x.requires_action?T:vs(T,.12),color:x.requires_action?"white":T,fontWeight:700,fontSize:13,cursor:"pointer"},children:x.requires_action?"Act Now →":l.view})]},C)})})]})}return n.jsxs("div",{style:{maxWidth:1040,margin:"0 auto"},children:[!i&&s.length>0&&n.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap",marginBottom:24},children:Object.entries(b).map(([h,m])=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"6px 12px 6px 9px",borderRadius:999,background:vs(ys[h]||B.gray,.1),border:`1px solid ${vs(ys[h]||B.gray,.25)}`},children:[n.jsx("span",{style:{fontSize:13},children:mu[h]}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:ys[h]||B.gray,textTransform:"capitalize"},children:h}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:ys[h]||B.gray,opacity:.7},children:m})]},h))}),i&&n.jsx("p",{style:{color:"#888"},children:l.loading}),!i&&s.length===0&&n.jsxs("div",{className:"inbox-empty",children:[n.jsx("div",{style:{fontSize:46,marginBottom:10},children:"✨"}),n.jsx("p",{style:{fontSize:16,fontWeight:600},children:l.inbox.noMessages}),n.jsx("p",{style:{fontSize:13,marginTop:4,opacity:.7},children:"You're all caught up — nothing needs your attention right now."})]}),!i&&S("Needs Action",c,!0),!i&&S("Informational",v,!1)]})}const g1=[{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"]}],Mf={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 x1(e,t){const l=e.map(r=>Mf[r]||r).join(","),s=t.map(r=>e.map(i=>`"${r[i]??""}"`).join(",")).join(`
|
||
`);return l+`
|
||
`+s}function m1(e,t){const l=new Blob([e],{type:"text/csv"}),s=URL.createObjectURL(l),r=document.createElement("a");r.href=s,r.download=t,r.click(),URL.revokeObjectURL(s)}const Hf="report-print-area",Ea="report-print-portal";function y1(){const e=document.getElementById(Hf);if(!e)return;const t=document.createElement("div");t.id=Ea,t.innerHTML=e.innerHTML,document.body.appendChild(t);const l=document.createElement("style");l.id="report-print-style",l.textContent=`
|
||
#${Ea} { display: none; }
|
||
@media print {
|
||
#root { display: none !important; }
|
||
#${Ea} { display: block !important; }
|
||
}
|
||
`,document.head.appendChild(l);const s=()=>{t.remove(),l.remove(),window.removeEventListener("afterprint",s)};window.addEventListener("afterprint",s),window.print()}const yu={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",minWidth:180},Aa={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white"};function v1({organizations:e,userRole:t}){const l=V(),s=g1.filter(_=>_.roles.includes(t)),[r,i]=j.useState(""),[a,d]=j.useState(""),[u,f]=j.useState(""),[y,p]=j.useState(""),[c,v]=j.useState(String(new Date().getFullYear())),[b,g]=j.useState([]),[S,h]=j.useState([]),[m,o]=j.useState(!1),[x,C]=j.useState(""),A=s.find(_=>_.id===r);async function T(){if(r){o(!0),C(""),h([]),g([]);try{const _={};a&&(_.organization=a),u&&(_.from_date=u),y&&(_.to_date=y),(A==null?void 0:A.extraFilter)==="year"&&c&&(_.year=c);const U=await yy(r,_);g(U.columns||[]),h(U.rows||[])}catch(_){C(_.message||"Error running report")}finally{o(!1)}}}const w=(A==null?void 0:A.label)||r;return n.jsxs("div",{children:[n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12,marginBottom:20},children:s.map(_=>n.jsxs("div",{onClick:()=>i(_.id),style:{background:r===_.id?"#ebf5fb":"white",border:r===_.id?`2px solid ${B.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:_.label}),n.jsx("div",{style:{fontSize:12,color:"#888"},children:_.description})]},_.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:yu,value:r,onChange:_=>i(_.target.value),children:[n.jsx("option",{value:"",children:"-- Select Report --"}),s.map(_=>n.jsx("option",{value:_.id,children:_.label},_.id))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"ORGANIZATION"}),n.jsxs("select",{style:yu,value:a,onChange:_=>d(_.target.value),children:[n.jsx("option",{value:"",children:l.filter.allOrgs}),e.map(_=>n.jsx("option",{value:_.name,children:_.organization_name||_.name},_.name))]})]}),(A==null?void 0:A.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:{...Aa,width:90},value:c,onChange:_=>v(_.target.value),min:2020,max:2099})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"FROM"}),n.jsx(me,{value:u,onChange:f,style:Aa})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"TO"}),n.jsx(me,{value:y,onChange:p,style:Aa})]})]}),n.jsx("button",{onClick:T,disabled:!r||m,style:{padding:"9px 20px",borderRadius:8,border:"none",background:B.accent,color:"white",fontWeight:700,fontSize:13,cursor:r?"pointer":"not-allowed",opacity:r?1:.5},children:m?l.loading:l.reports.generate}),S.length>0&&n.jsx("button",{onClick:()=>m1(x1(b,S),`${r}.csv`),style:{padding:"9px 20px",borderRadius:8,border:"1px solid #27ae60",background:"white",color:"#27ae60",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Export CSV"}),S.length>0&&n.jsx("button",{onClick:y1,style:{padding:"9px 20px",borderRadius:8,border:"1px solid #888",background:"white",color:"#555",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Print / PDF"})]})}),x&&n.jsx("div",{style:{color:"#e74c3c",marginBottom:16},children:x}),S.length>0&&n.jsxs("div",{id:Hf,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:w}),n.jsxs("span",{style:{fontSize:12,color:"#888"},children:[S.length," rows"]})]}),n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa"},children:b.map(_=>n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700,whiteSpace:"nowrap"},children:Mf[_]||_.replace(/_/g," ").toUpperCase()},_))})}),n.jsx("tbody",{children:S.map((_,U)=>n.jsx("tr",{style:{borderTop:"1px solid #f0f0f0",background:U%2===0?"white":"#fafafa"},children:b.map(P=>n.jsx("td",{style:{padding:"10px 14px",color:"#333"},children:_[P]!=null?String(_[P]):"—"},P))},U))})]})]}),!m&&S.length===0&&r&&!x&&n.jsx("div",{style:{background:"white",borderRadius:12,padding:40,textAlign:"center",color:"#aaa",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:"Select a report and click Run Report to see results."}),s.length===0&&n.jsx("div",{style:{background:"white",borderRadius:12,padding:40,textAlign:"center",color:"#aaa",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:"No reports are available for your role."})]})}const fr=()=>new Date().toISOString().split("T")[0],wc=()=>new Date(Date.now()+30*24*60*60*1e3).toISOString().split("T")[0],Vt=()=>({name:"",number:"",title:"",organization:"",type:"",incident_class:"",incident_field:"",date:fr(),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:""}),en=()=>({name:"",number:"",title:"",organization:"",type:"",management:"",department:"",section_field:"",branch:"",current_condition:"",proposed_condition:"",status:"",assigned_to:"",workflow_state:"New",idea_class:"",hses_field:"",date:fr(),priority:"",economy_class:"",product_relation:0,repeated:0,entity_scope:"",solution:"",cost:0,auditor_comment:""}),tn=()=>({name:"",number:"",title:"",organization:"",type:"Buy L",management:"",department:"",section_field:"",branch:"",starting_date:fr(),ending_date:wc(),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:""}),Hr=()=>({name:"",title:"",date_start:fr(),date_end:wc(),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:""}),js=()=>({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}),gl=()=>({name:"",organization:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),xl=()=>({name:"",custom_organization:"",department_name:"",custom_management:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),ml=()=>({name:"",organization:"",branch:"",management:"",department:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),bs=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ss=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ws=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ks=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),_s=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Cs=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),zs=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ts=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Kr=()=>({name:"",first_name:"",full_name:"",email:"",enabled:1,creation:"",username:"",mobile_no:"",custom_organization:"",custom_management:"",custom_department:"",custom_branch:"",custom_number:"",custom_category:""}),yl=()=>({name:"",name1:"",organization:"",frequency:"Monthly",status:"Active",start_date:fr(),end_date:wc(),update_window_days:2}),vl=()=>({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}),Ps=()=>({name:"",number:"",auditor:"",manager:"",organization:"",create_processes:0,update_process_status:0,status:"Pending",requested_on:"",remarks:""}),j1=new Set(["incidents","incidents-form","ideas","ideas-form"]),b1=new Set(["orders","orders-form","incidents","incidents-form","ideas","ideas-form"]),S1=new Set(["Admin","Owner","Auditor","Manager"]),w1=new Set(["Admin","Owner","Auditor","Manager"]),k1=new Set(["Admin","Auditor","Manager"]);function _1({user:e,onLogout:t,darkMode:l,onToggleDark:s}){const r=V(),i=e.role,a=S1.has(i),d=w1.has(i),u=k1.has(i),f=k=>k==="users"||k==="users-form"?i==="Admin":i==="Admin"||i==="Auditor"?!0:i==="Owner"||i==="XAuditor"?!1:i==="Manager"?!!(b1.has(k)||(k==="processes"||k==="processes-form")&&Cc.includes("create_processes")):j1.has(k),y=k=>i==="Employee"&&!!k&&k!=="New",[p,c]=j.useState(a?"dashboard":"inbox"),v=e.custom_organization||"",[b,g]=j.useState(""),[S,h]=j.useState("");j.useEffect(()=>{if(!S)return;const k=setTimeout(()=>h(""),0);return()=>clearTimeout(k)},[S]);const m=(k,X)=>{h(X),c(k)},[o,x]=j.useState(0),[C,A]=j.useState([]),[T,w]=j.useState([]),[_,U]=j.useState([]),[P,I]=j.useState([]),[N,M]=j.useState([]),[Z,ge]=j.useState([]),[le,L]=j.useState([]),[K,G]=j.useState([]),[ee,J]=j.useState([]),[xe,_e]=j.useState([]),[re,Ce]=j.useState([]),[Oe,H]=j.useState([]),[se,D]=j.useState([]),[te,hn]=j.useState([]),[gt,O]=j.useState([]),[R,Q]=j.useState([]),[Yt,hr]=j.useState([]),[Bn,Xi]=j.useState([]),[$n,W]=j.useState([]),[Ge,sl]=j.useState({}),[kt,Kf]=j.useState([]),[gr,Qf]=j.useState([]),[kc,Gf]=j.useState([]),[_c,Yf]=j.useState([]),[Cc,Xf]=j.useState([]),[zc,qf]=j.useState({}),[Se,de]=j.useState(!0),[De,ie]=j.useState("idle"),[Ne,oe]=j.useState(!1),[Tc,Pc]=j.useState(!1),[xr,Ic]=j.useState(null),[Jf,Zf]=j.useState(()=>localStorage.getItem("sb_sidebar")==="1"),Vf=()=>Zf(k=>{const X=!k;return localStorage.setItem("sb_sidebar",X?"1":"0"),X}),[eh,qi]=j.useState(!1);j.useEffect(()=>{qi(!1)},[p]);const[rl,Xt]=j.useState(Vt()),[il,qt]=j.useState(en()),[mr,Jt]=j.useState(tn()),[yr,Ut]=j.useState(Hr()),[Ec,Jl]=j.useState(js()),[Ac,al]=j.useState(gl()),[Rc,ol]=j.useState(xl()),[Lc,cl]=j.useState(ml()),[Oc,Zl]=j.useState(bs()),[Dc,Vl]=j.useState(Ss()),[Nc,es]=j.useState(ws()),[Wc,ts]=j.useState(ks()),[Bc,ns]=j.useState(_s()),[$c,ls]=j.useState(Cs()),[Uc,ss]=j.useState(zs()),[Fc,rs]=j.useState(Ts()),[vr,jr]=j.useState(Kr()),[Mc,dl]=j.useState(yl()),[Hc,ul]=j.useState(vl()),[pl,is]=j.useState(Ps()),Ft=async()=>{de(!0);try{const[k,X,xt,At,gn,We,ea,Xh,qh,Jh,Zh,Vh,eg,tg,ng,lg,sg,rg,ig,ag,og,cg,dg,ug,pg,fg]=await Promise.all([we($.incidents),we($.organizations),we($.ideas),we($.orders),we($.processes),ey(),we($.managements),we($.departments),we($.branches),we($.incidentTypes),we($.incidentClass),we($.incidentField),we($.ideaTypes),we($.orderTypes),we($.processTypes),we($.incidentStatuses),we($.ideaStatuses),we($.orderStatuses),we($.processStatuses),sy(),ry(),we($.cycles),we($.kpiInput),wy(),_y(),Cy()]);A(k||[]),w(X||[]),U(xt||[]),I(At||[]),M(gn||[]),Kf(We||[]),ge(ea||[]),L(Xh||[]),G(qh||[]),J(Jh||[]),_e(Zh||[]),Ce(Vh||[]),H(eg||[]),D(tg||[]),hn(ng||[]),O(lg||[]),Q(sg||[]),hr(rg||[]),Xi(ig||[]),W(ag||[]),sl(og||{}),Qf(cg||[]),Gf(dg||[]),Yf(ug||[]),Xf(pg||[]),qf(fg||{})}catch(k){console.error("Error loading data:",k)}de(!1)},th=async()=>{try{const k=await fetch("/api/method/sidrah_business.api.get_notification_count",{credentials:"include",headers:{Accept:"application/json"}});if(k.ok){const X=await k.json();x(Number(X.message)||0)}}catch{}};j.useEffect(()=>{Ft(),th()},[e.name]);const He=async(k,X)=>{if(window.confirm(r.rtl?"هل أنت متأكد من حذف هذا السجل؟":"Are you sure you want to delete this record?")){de(!0);try{await Nf(k,X),await Ft()}catch(xt){console.error("Delete error:",xt),alert((xt==null?void 0:xt.message)||"Delete failed. Please try again.")}de(!1)}},nh=async k=>{try{await cy(k),await Ft()}catch(X){console.error("Disable user error:",X)}},lh=async k=>{oe(!0),de(!0);try{const X=await mt($.incidents,k.name);Xt({...Vt(),...X})}catch{Xt({...Vt(),...k})}c("incidents-form"),de(!1)},sh=async k=>{oe(!0),de(!0);try{const X=await mt($.ideas,k.name);qt({...en(),...X})}catch{qt({...en(),...k})}c("ideas-form"),de(!1)},rh=async k=>{oe(!0),de(!0);try{const X=await mt($.orders,k.name);Jt({...tn(),...X})}catch{Jt({...tn(),...k})}c("orders-form"),de(!1)},ih=async k=>{oe(!0),de(!0);try{const X=await Ls(k.name);Ut({...X,progress_indicators:X.progress_indicators||[],cycle_logs:X.cycle_logs||[]}),c("processes-form")}catch{Ut({...k,progress_indicators:k.progress_indicators||[]}),c("processes-form")}de(!1)},ah=k=>ye($.organizations,k,Jl,js(),"organizations-form",!0),oh=async k=>{oe(!0),de(!0);try{const X=await mt($.managements,k.name);al({...gl(),...X})}catch{al({...gl(),...k})}c("managements-form"),de(!1)},ch=async k=>{oe(!0),de(!0);try{const X=await mt($.departments,k.name);ol({...xl(),...X})}catch{ol({...xl(),...k})}c("departments-form"),de(!1)},dh=async k=>{oe(!0),de(!0);try{const X=await mt($.branches,k.name);cl({...ml(),...X})}catch{cl({...ml(),...k})}c("branches-form"),de(!1)},uh=async k=>{oe(!0),de(!0);try{const X=await mt($.cycles,k.name);dl({...yl(),...X})}catch{dl({...yl(),...k})}c("cycles-form"),de(!1)},ph=async k=>{oe(!0),de(!0);try{const X=await mt($.kpiInput,k.name);ul({...vl(),...X})}catch{ul({...vl(),...k})}c("kpi-input-form"),de(!1)},Ye=async(k,X,xt,At,gn)=>{ie("loading");try{if(X.name)await Ti(k,X.name,X),ie("success"),Ft(),setTimeout(()=>{ie("idle"),c(At)},1500);else if(gn){const We=await za(k,X);gn(We),ie("success"),Ft(),setTimeout(()=>ie("idle"),1500)}else await za(k,X),xt(),ie("success"),Ft(),setTimeout(()=>{ie("idle"),c(At)},1500)}catch(We){console.error("Submit error:",We),ie(We instanceof Error?We.message:"Error saving. Please try again.")}},Ae=async()=>{await ny(),t()},ye=async(k,X,xt,At,gn,We)=>{oe(We),de(!0);try{const ea=await mt(k,X.name);xt({...At,...ea})}catch{xt({...At,...X})}c(gn),de(!1)},fh=k=>ye($.incidents,k,Xt,Vt(),"incidents-form",!1),hh=k=>ye($.ideas,k,qt,en(),"ideas-form",!1),gh=k=>ye($.orders,k,Jt,tn(),"orders-form",!1),xh=k=>{oe(!1),de(!0),Ls(k.name).then(X=>{Ut({...X,progress_indicators:X.progress_indicators||[],cycle_logs:X.cycle_logs||[]})}).catch(()=>{Ut({...k,progress_indicators:k.progress_indicators||[]})}).finally(()=>{c("processes-form"),de(!1)})},mh=k=>ye($.organizations,k,Jl,js(),"organizations-form",!1),yh=k=>ye($.managements,k,al,gl(),"managements-form",!1),vh=k=>ye($.departments,k,ol,xl(),"departments-form",!1),jh=k=>ye($.branches,k,cl,ml(),"branches-form",!1),bh=k=>ye($.cycles,k,dl,yl(),"cycles-form",!1),Sh=k=>ye($.kpiInput,k,ul,vl(),"kpi-input-form",!1),wh=async k=>{oe(!0),de(!0);try{const X=await ky(k.name);is({...Ps(),...X})}catch{is({...Ps(),...k})}c("delegations-form"),de(!1)},kh=async()=>{ie("loading");try{const k=[];pl.create_processes&&k.push("create_processes"),pl.update_process_status&&k.push("update_process_status"),await jy(pl.manager,k,pl.organization,pl.remarks),is(Ps()),ie("success"),Ft(),setTimeout(()=>{ie("idle"),c("delegations")},1500)}catch(k){console.error("Delegation submit error:",k),ie(k instanceof Error?k.message:"Error saving. Please try again.")}},_h=async k=>{if(window.confirm(r.rtl?"هل أنت متأكد من إلغاء هذا التفويض؟":"Are you sure you want to revoke this delegation?")){de(!0);try{await Sy(k),await Ft()}catch(X){console.error("Revoke delegation error:",X),alert(X instanceof Error?X.message:"Revoke failed. Please try again.")}de(!1)}},Ch=k=>ye($.incidentTypes,k,Zl,bs(),"incident-types-form",!0),zh=k=>ye($.incidentTypes,k,Zl,bs(),"incident-types-form",!1),Th=k=>ye($.ideaTypes,k,Vl,Ss(),"idea-types-form",!0),Ph=k=>ye($.ideaTypes,k,Vl,Ss(),"idea-types-form",!1),Ih=k=>ye($.orderTypes,k,es,ws(),"order-types-form",!0),Eh=k=>ye($.orderTypes,k,es,ws(),"order-types-form",!1),Ah=k=>ye($.processTypes,k,ts,ks(),"process-types-form",!0),Rh=k=>ye($.processTypes,k,ts,ks(),"process-types-form",!1),Lh=k=>ye($.incidentStatuses,k,ns,_s(),"incident-statuses-form",!0),Oh=k=>ye($.incidentStatuses,k,ns,_s(),"incident-statuses-form",!1),Dh=k=>ye($.ideaStatuses,k,ls,Cs(),"idea-statuses-form",!0),Nh=k=>ye($.ideaStatuses,k,ls,Cs(),"idea-statuses-form",!1),Wh=k=>ye($.orderStatuses,k,ss,zs(),"order-statuses-form",!0),Bh=k=>ye($.orderStatuses,k,ss,zs(),"order-statuses-form",!1),$h=k=>ye($.processStatuses,k,rs,Ts(),"process-statuses-form",!0),Uh=k=>ye($.processStatuses,k,rs,Ts(),"process-statuses-form",!1),Fh=async k=>{Ic(k),c("profile")},Mh=k=>{oe(!1),Pc(!1),jr({...Kr(),...k}),c("users-form")},Hh=async()=>{ie("loading");try{if(!vr.name)await za("User",{...vr,send_welcome_email:0,user_type:"System User"});else{const{name:X,email:xt,creation:At,full_name:gn,...We}=vr;await Ti("User",X,We)}jr(Kr()),ie("success"),Ft(),setTimeout(()=>{ie("idle"),c("users")},1500)}catch(k){console.error("User submit error:",k),ie(k instanceof Error?k.message:"Error saving. Please try again.")}},Re=()=>{const k=$n.find(X=>X.name===e.name||X.username===e.name);Ic(k||{name:e.name,full_name:e.full_name,email:e.name,enabled:1}),c("profile")},Ji=(k,X)=>{if(X){const At={"processes-form":$.processes,"orders-form":$.orders,"incidents-form":$.incidents,"ideas-form":$.ideas}[k];if(At){oe(!0),de(!0),(k==="processes-form"?Ls(X).then(We=>({...We,progress_indicators:We.progress_indicators||[],cycle_logs:We.cycle_logs||[]})):mt(At,X)).then(We=>{k==="processes-form"?Ut(We):k==="orders-form"?Jt({...tn(),...We}):k==="incidents-form"?Xt({...Vt(),...We}):k==="ideas-form"&&qt({...en(),...We}),c(k),de(!1)}).catch(()=>{c(k),de(!1)});return}}c(k)};if(p==="incidents-form")return n.jsx(qy,{incForm:rl,setIncForm:Xt,organizations:T,managements:Z,departments:le,branches:K,incidentTypes:ee,incidentClasses:xe,incidentFields:re,incidentStatuses:gt,users:kt,userRoleMap:Ge,formStatus:De,viewMode:Ne||!f("incidents-form")||y(rl.workflow_state),onEdit:f("incidents-form")&&!y(rl.workflow_state)?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,userRole:i,onSubmit:()=>Ye($.incidents,rl,()=>Xt(Vt()),"incidents",k=>Xt({...Vt(),...k})),onBack:()=>{c("incidents"),ie("idle")},onNavigate:c,onLogout:Ae,user:e,onRefresh:async()=>{if(rl.name){const k=await mt($.incidents,rl.name).catch(()=>null);k&&Xt({...Vt(),...k})}we($.incidents).then(k=>A(k||[])).catch(()=>{})}});if(p==="ideas-form")return n.jsx(e0,{ideaForm:il,setIdeaForm:qt,organizations:T,managements:Z,departments:le,branches:K,ideaTypes:Oe,ideaStatuses:R,users:kt,userRoleMap:Ge,formStatus:De,viewMode:Ne||!f("ideas-form")||y(il.workflow_state),onEdit:f("ideas-form")&&!y(il.workflow_state)?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,userRole:i,onSubmit:()=>Ye($.ideas,il,()=>qt(en()),"ideas",k=>qt({...en(),...k})),onBack:()=>{c("ideas"),ie("idle")},onNavigate:c,onLogout:Ae,user:e,onRefresh:async()=>{if(il.name){const k=await mt($.ideas,il.name).catch(()=>null);k&&qt({...en(),...k})}we($.ideas).then(k=>U(k||[])).catch(()=>{})}});if(p==="orders-form")return n.jsx(r0,{orderForm:mr,setOrderForm:Jt,organizations:T,managements:Z,departments:le,branches:K,orderTypes:se,orderStatuses:Yt,cycles:gr,users:kt,userRoleMap:Ge,formStatus:De,viewMode:Ne||!f("orders-form"),onEdit:f("orders-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,currentUser:e.name,userRole:i,onSubmit:()=>Ye($.orders,mr,()=>Jt(tn()),"orders",k=>Jt({...tn(),...k})),onBack:()=>{c("orders"),ie("idle")},onNavigate:c,onLogout:Ae,user:e,onRefresh:async()=>{if(mr.name){const k=await mt($.orders,mr.name).catch(()=>null);k&&Jt({...tn(),...k})}we($.orders).then(k=>I(k||[])).catch(()=>{})}});if(p==="processes-form")return n.jsx(d0,{processForm:yr,setProcessForm:Ut,organizations:T,managements:Z,departments:le,branches:K,processTypes:te,processStatuses:Bn,cycles:gr,users:kt,userRoleMap:Ge,formStatus:De,viewMode:Ne||!f("processes-form"),onEdit:f("processes-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,userRole:e.role,delegatedFunctions:Cc,delegatedOrgs:zc.create_processes,onRefreshProcess:async()=>{if(yr.name)try{const k=await Ls(yr.name);Ut({...k,progress_indicators:k.progress_indicators||[],cycle_logs:k.cycle_logs||[]})}catch{}we($.processes).then(k=>M(k||[])).catch(()=>{})},onSubmit:()=>Ye($.processes,yr,()=>Ut(Hr()),"processes",k=>Ut({...Hr(),...k,progress_indicators:k.progress_indicators||[],cycle_logs:k.cycle_logs||[]})),onBack:()=>{c("processes"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="organizations-form")return n.jsx(x0,{orgForm:Ec,setOrgForm:Jl,formStatus:De,viewMode:Ne||!f("organizations-form"),onEdit:f("organizations-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,onSubmit:()=>Ye($.organizations,Ec,()=>Jl(js()),"organizations"),onBack:()=>{c("organizations"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="managements-form")return n.jsx(v0,{form:Ac,setForm:al,organizations:T,formStatus:De,viewMode:Ne||!f("managements-form"),onEdit:f("managements-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,onSubmit:()=>Ye($.managements,Ac,()=>al(gl()),"managements"),onBack:()=>{c("managements"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="departments-form")return n.jsx(w0,{form:Rc,setForm:ol,organizations:T,managements:Z,formStatus:De,viewMode:Ne||!f("departments-form"),onEdit:f("departments-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,onSubmit:()=>Ye($.departments,Rc,()=>ol(xl()),"departments"),onBack:()=>{c("departments"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="branches-form")return n.jsx(z0,{form:Lc,setForm:cl,organizations:T,managements:Z,departments:le,formStatus:De,viewMode:Ne||!f("branches-form"),onEdit:f("branches-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,onSubmit:()=>Ye($.branches,Lc,()=>cl(ml()),"branches"),onBack:()=>{c("branches"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="cycles-form")return n.jsx(r1,{form:Mc,setForm:dl,organizations:T,formStatus:De,viewMode:Ne||!f("cycles-form"),onEdit:f("cycles-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,onSubmit:()=>Ye($.cycles,Mc,()=>dl(yl()),"cycles"),onBack:()=>{c("cycles"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="kpi-input-form")return n.jsx(a1,{form:Hc,setForm:ul,organizations:T,formStatus:De,viewMode:Ne||!f("kpi-input-form"),onEdit:f("kpi-input-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,onSubmit:()=>Ye($.kpiInput,Hc,()=>ul(vl()),"kpi-input"),onBack:()=>{c("kpi-input"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="incident-types-form")return n.jsx(I0,{form:Oc,setForm:Zl,formStatus:De,viewMode:Ne||!f("incident-types-form"),onEdit:f("incident-types-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,onSubmit:()=>Ye($.incidentTypes,Oc,()=>Zl(bs()),"incident-types"),onBack:()=>{c("incident-types"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="idea-types-form")return n.jsx(R0,{form:Dc,setForm:Vl,formStatus:De,viewMode:Ne||!f("idea-types-form"),onEdit:f("idea-types-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,onSubmit:()=>Ye($.ideaTypes,Dc,()=>Vl(Ss()),"idea-types"),onBack:()=>{c("idea-types"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="order-types-form")return n.jsx(D0,{form:Nc,setForm:es,formStatus:De,viewMode:Ne||!f("order-types-form"),onEdit:f("order-types-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,onSubmit:()=>Ye($.orderTypes,Nc,()=>es(ws()),"order-types"),onBack:()=>{c("order-types"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="process-types-form")return n.jsx(B0,{form:Wc,setForm:ts,formStatus:De,viewMode:Ne||!f("process-types-form"),onEdit:f("process-types-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,onSubmit:()=>Ye($.processTypes,Wc,()=>ts(ks()),"process-types"),onBack:()=>{c("process-types"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="incident-statuses-form")return n.jsx(F0,{form:Bc,setForm:ns,formStatus:De,viewMode:Ne||!f("incident-statuses-form"),onEdit:f("incident-statuses-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,onSubmit:()=>Ye($.incidentStatuses,Bc,()=>ns(_s()),"incident-statuses"),onBack:()=>{c("incident-statuses"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="idea-statuses-form")return n.jsx(K0,{form:$c,setForm:ls,formStatus:De,viewMode:Ne||!f("idea-statuses-form"),onEdit:f("idea-statuses-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,onSubmit:()=>Ye($.ideaStatuses,$c,()=>ls(Cs()),"idea-statuses"),onBack:()=>{c("idea-statuses"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="order-statuses-form")return n.jsx(Y0,{form:Uc,setForm:ss,formStatus:De,viewMode:Ne||!f("order-statuses-form"),onEdit:f("order-statuses-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,onSubmit:()=>Ye($.orderStatuses,Uc,()=>ss(zs()),"order-statuses"),onBack:()=>{c("order-statuses"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="process-statuses-form")return n.jsx(J0,{form:Fc,setForm:rs,formStatus:De,viewMode:Ne||!f("process-statuses-form"),onEdit:f("process-statuses-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,onSubmit:()=>Ye($.processStatuses,Fc,()=>rs(Ts()),"process-statuses"),onBack:()=>{c("process-statuses"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="users-form")return n.jsx(t1,{form:vr,setForm:jr,organizations:T,managements:Z,departments:le,branches:K,formStatus:De,viewMode:Ne||!f("users-form"),onEdit:f("users-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,isSelfProfile:Tc,onSubmit:Hh,onBack:()=>{c(Tc?a?"dashboard":"inbox":"users"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="delegations-form")return n.jsx(f1,{form:pl,setForm:is,organizations:T,users:kt,userRoleMap:Ge,formStatus:De,viewMode:Ne||!f("delegations-form"),onEdit:f("delegations-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Re,onSubmit:kh,onBack:()=>{c("delegations"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});const Kh=r.pages,Qh={incidents:{color:B.accent,formPage:"incidents-form",reset:()=>Xt({...Vt(),organization:v||b})},ideas:{color:B.teal,formPage:"ideas-form",reset:()=>qt({...en(),organization:v||b})},orders:{color:B.purple,formPage:"orders-form",reset:()=>Jt({...tn(),organization:v||b})},processes:{color:B.blue,formPage:"processes-form",reset:()=>{const k=zc.create_processes,X=v||(i==="Manager"&&k&&k.length===1?k[0]:b);Ut({...Hr(),organization:X})}},organizations:{color:B.accent,formPage:"organizations-form",reset:()=>Jl(js())},managements:{color:B.blue,formPage:"managements-form",reset:()=>al({...gl(),organization:v||b})},departments:{color:B.teal,formPage:"departments-form",reset:()=>ol({...xl(),custom_organization:v||b})},branches:{color:B.purple,formPage:"branches-form",reset:()=>cl({...ml(),organization:v||b})},cycles:{color:B.teal,formPage:"cycles-form",reset:()=>dl({...yl(),organization:v||b})},"kpi-input":{color:B.blue,formPage:"kpi-input-form",reset:()=>ul({...vl(),organization:v||b})},"incident-types":{color:B.red,formPage:"incident-types-form",reset:()=>Zl(bs())},"idea-types":{color:B.orange,formPage:"idea-types-form",reset:()=>Vl(Ss())},"order-types":{color:B.green,formPage:"order-types-form",reset:()=>es(ws())},"process-types":{color:B.accent,formPage:"process-types-form",reset:()=>ts(ks())},"incident-statuses":{color:B.red,formPage:"incident-statuses-form",reset:()=>ns(_s())},"idea-statuses":{color:B.teal,formPage:"idea-statuses-form",reset:()=>ls(Cs())},"order-statuses":{color:B.purple,formPage:"order-statuses-form",reset:()=>ss(zs())},"process-statuses":{color:B.blue,formPage:"process-statuses-form",reset:()=>rs(Ts())},users:{color:B.blue,formPage:"users-form",reset:()=>{jr(Kr()),Pc(!1)}},delegations:{color:B.purple,formPage:"delegations-form",reset:()=>is(Ps())}},Gh={incidents:r.formTitle.newIncident,ideas:r.formTitle.newIdea,orders:r.formTitle.newOrder,processes:r.formTitle.newProcess,organizations:r.formTitle.newOrg,managements:r.formTitle.newMgmt,departments:r.formTitle.newDept,branches:r.formTitle.newBranch,users:r.formTitle.newUser,cycles:r.formTitle.newCycle,"kpi-input":r.formTitle.newKpi,delegations:r.formTitle.newDelegation,"incident-types":"New Incident Type","idea-types":"New Idea Type","order-types":"New Order Type","process-types":"New Process Type","incident-statuses":"New Incident Status","idea-statuses":"New Idea Status","order-statuses":"New Order Status","process-statuses":"New Process Status"},Yh={incidents:C,ideas:_,orders:P,processes:N,organizations:T,managements:Z,departments:le,branches:K,cycles:gr,"kpi-input":kc,"incident-types":ee,"idea-types":Oe,"order-types":se,"process-types":te,"incident-statuses":gt,"idea-statuses":R,"order-statuses":Yt,"process-statuses":Bn,users:$n,delegations:_c},Un=Hm[p],Zi=Yh[p],q=f(p),Vi=q?Qh[p]:null;return n.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:l?"#0f172a":B.bg},children:[n.jsx(Lf,{collapsed:Jf,onToggleCollapsed:Vf,activePage:p,onNavigate:k=>c(k),hasDashboard:a,hasReports:d,hasDelegations:u,role:i,rtl:r.rtl,navLabels:r.nav,settingsLabel:r.nav.settings}),n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[n.jsx("div",{style:{background:l?"#1e293b":"#ffffff",padding:"6px 20px",borderBottom:`1px solid ${l?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"flex-end",alignItems:"center",gap:6,flexShrink:0,boxShadow:l?"none":"0 1px 4px rgba(0,0,0,0.04)"},children:n.jsx(Uf,{notifCount:o,darkMode:l,onCountChange:x,onToggleDark:s,onNavigate:Ji,onViewProfile:Re,onLogout:Ae})}),p!=="profile"&&n.jsxs("div",{style:{background:l?"#1e293b":"white",padding:"9px 20px",borderBottom:`1px solid ${l?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[n.jsx("div",{style:{fontSize:15,fontWeight:700,color:l?"#e2e8f0":"#1e1b4b"},children:Kh[p]||p}),n.jsxs("div",{style:{display:"flex",gap:8},children:[Un&&Zi&&n.jsx("button",{onClick:()=>qi(!0),style:{background:"#16a34a",color:"white",border:"none",padding:"6px 14px",borderRadius:7,fontSize:12,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"}),Vi&&n.jsxs("button",{onClick:()=>{Vi.reset(),oe(!1),ie("idle"),c(Vi.formPage)},style:{background:"#4f46e5",color:"white",border:"none",padding:"6px 14px",borderRadius:7,fontSize:12,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI"},children:["+ ",Gh[p]||r.new]})]})]}),Un&&Zi&&eh&&n.jsx(Jm,{title:Un.label,rows:Zi,columns:Un.columns,defaultColumnKeys:Un.defaultColumns,orgField:Un.orgField,organizations:Un.orgField?T:void 0,filenameBase:p,onClose:()=>qi(!1)}),n.jsxs("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",padding:p==="profile"?0:"20px 24px",gap:p==="profile"?0:16},children:[Se&&n.jsx("div",{style:{textAlign:"center",paddingTop:60,color:"#aaa",fontSize:15},children:r.loading}),!Se&&p==="dashboard"&&a&&n.jsx(Oy,{incidents:C,ideas:_,orders:P,processes:N,organizations:T,incidentStatuses:gt,ideaStatuses:R,orderStatuses:Yt,processStatuses:Bn,selectedOrg:b,onOrgChange:g,onNavigate:Ji,onNavigateStatus:m,userRole:i}),!Se&&p==="inbox"&&n.jsx(h1,{onNavigate:Ji,onRefresh:Ft}),!Se&&p==="reports"&&d&&n.jsx(v1,{organizations:T,userRole:i}),!Se&&p==="incidents"&&n.jsx($y,{incidents:C,organizations:T,departments:le,branches:K,incidentStatuses:gt,initialOrg:b,initialStatus:S,onView:lh,onEdit:q?fh:void 0,onDelete:q?k=>He($.incidents,k):void 0,canModify:q}),!Se&&p==="ideas"&&n.jsx(Jy,{ideas:_,organizations:T,departments:le,branches:K,ideaStatuses:R,initialOrg:b,initialStatus:S,onView:sh,onEdit:q?hh:void 0,onDelete:q?k=>He($.ideas,k):void 0,canModify:q}),!Se&&p==="orders"&&n.jsx(t0,{orders:P,organizations:T,departments:le,branches:K,orderStatuses:Yt,initialOrg:b,initialStatus:S,onView:rh,onEdit:q?gh:void 0,onDelete:q?k=>He($.orders,k):void 0,canModify:q}),!Se&&p==="processes"&&n.jsx(i0,{processes:N,organizations:T,departments:le,branches:K,processStatuses:Bn,initialOrg:b,initialStatus:S,onView:ih,onEdit:q?xh:void 0,onDelete:q?k=>He($.processes,k):void 0,canModify:q}),!Se&&p==="organizations"&&n.jsx(g0,{organizations:T,onView:ah,onEdit:q?mh:void 0,onDelete:q?k=>He($.organizations,k):void 0,canModify:q}),!Se&&p==="managements"&&n.jsx(y0,{managements:Z,onView:oh,onEdit:q?yh:void 0,onDelete:q?k=>He($.managements,k):void 0,canModify:q}),!Se&&p==="departments"&&n.jsx(b0,{departments:le,managements:Z,onView:ch,onEdit:q?vh:void 0,onDelete:q?k=>He($.departments,k):void 0,canModify:q}),!Se&&p==="branches"&&n.jsx(_0,{branches:K,managements:Z,departments:le,onView:dh,onEdit:q?jh:void 0,onDelete:q?k=>He($.branches,k):void 0,canModify:q}),!Se&&p==="cycles"&&n.jsx(n1,{cycles:gr,canModify:q,onView:uh,onEdit:q?bh:void 0,onDelete:q?k=>He($.cycles,k):void 0}),!Se&&p==="kpi-input"&&n.jsx(i1,{kpiInputs:kc,canModify:q,onView:ph,onEdit:q?Sh:void 0,onDelete:q?k=>He($.kpiInput,k):void 0}),!Se&&p==="incident-types"&&n.jsx(P0,{incidentTypes:ee,onView:Ch,onEdit:q?zh:void 0,onDelete:q?k=>He($.incidentTypes,k):void 0,canModify:q}),!Se&&p==="idea-types"&&n.jsx(A0,{ideaTypes:Oe,onView:Th,onEdit:q?Ph:void 0,onDelete:q?k=>He($.ideaTypes,k):void 0,canModify:q}),!Se&&p==="order-types"&&n.jsx(O0,{orderTypes:se,onView:Ih,onEdit:q?Eh:void 0,onDelete:q?k=>He($.orderTypes,k):void 0,canModify:q}),!Se&&p==="process-types"&&n.jsx(W0,{processTypes:te,onView:Ah,onEdit:q?Rh:void 0,onDelete:q?k=>He($.processTypes,k):void 0,canModify:q}),!Se&&p==="incident-statuses"&&n.jsx(U0,{incidentStatuses:gt,onView:Lh,onEdit:q?Oh:void 0,onDelete:q?k=>He($.incidentStatuses,k):void 0,canModify:q}),!Se&&p==="idea-statuses"&&n.jsx(H0,{ideaStatuses:R,onView:Dh,onEdit:q?Nh:void 0,onDelete:q?k=>He($.ideaStatuses,k):void 0,canModify:q}),!Se&&p==="order-statuses"&&n.jsx(G0,{orderStatuses:Yt,onView:Wh,onEdit:q?Bh:void 0,onDelete:q?k=>He($.orderStatuses,k):void 0,canModify:q}),!Se&&p==="process-statuses"&&n.jsx(q0,{processStatuses:Bn,onView:$h,onEdit:q?Uh:void 0,onDelete:q?k=>He($.processStatuses,k):void 0,canModify:q}),!Se&&p==="users"&&n.jsx(e1,{users:$n,roleMap:Ge,onView:Fh,onEdit:q?Mh:void 0,onDelete:q?k=>He("User",k):void 0,onDisable:q?nh:void 0,canModify:q}),!Se&&p==="delegations"&&u&&n.jsx(u1,{delegations:_c,organizations:T,userRole:i,currentUser:e.name,onView:wh,onRevoke:q?_h:void 0}),p==="profile"&&(()=>{const k=!!xr&&(xr.name===e.name||xr.email===e.name);return n.jsx(p0,{user:e,profileUser:xr,sbUsers:$n,organizations:T,managements:Z,departments:le,branches:K,darkMode:l,canModify:q||k,onBack:()=>c(k?a?"dashboard":"inbox":"users"),onNavigate:c})})()]})]})]})}function C1(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 z1(){const[e,t]=j.useState(()=>{try{const d=localStorage.getItem("sidrah_user");return d?JSON.parse(d):null}catch{return null}}),[l,s]=j.useState(()=>localStorage.getItem("sb_dark")==="1"),r=()=>{const d=!l;s(d),localStorage.setItem("sb_dark",d?"1":"0"),document.documentElement.classList.toggle("dark",d)};j.useEffect(()=>{document.documentElement.classList.toggle("dark",l)},[]),j.useEffect(()=>{e&&Wf().then(async d=>{const u=d||e.name,f=await $f(u);if(!f.length)return;const y=C1(f),p=await fy();if(y!==e.role||u!==e.name||p!==(e.custom_organization||"")){const v={...e,name:u,role:y,custom_organization:p};t(v),localStorage.setItem("sidrah_user",JSON.stringify(v))}})},[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(_1,{user:e,onLogout:a,darkMode:l,onToggleDark:r}):n.jsx(Py,{onLogin:i})}Af(document.getElementById("root")).render(n.jsx(j.StrictMode,{children:n.jsx(z1,{})}));
|