53 lines
482 KiB
JavaScript
53 lines
482 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 xu={exports:{}},Ci={},mu={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 sr=Symbol.for("react.element"),ug=Symbol.for("react.portal"),pg=Symbol.for("react.fragment"),fg=Symbol.for("react.strict_mode"),hg=Symbol.for("react.profiler"),gg=Symbol.for("react.provider"),xg=Symbol.for("react.context"),mg=Symbol.for("react.forward_ref"),yg=Symbol.for("react.suspense"),vg=Symbol.for("react.memo"),jg=Symbol.for("react.lazy"),Mc=Symbol.iterator;function bg(e){return e===null||typeof e!="object"?null:(e=Mc&&e[Mc]||e["@@iterator"],typeof e=="function"?e:null)}var yu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},vu=Object.assign,ju={};function Yl(e,t,l){this.props=e,this.context=t,this.refs=ju,this.updater=l||yu}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 bu(){}bu.prototype=Yl.prototype;function Co(e,t,l){this.props=e,this.context=t,this.refs=ju,this.updater=l||yu}var zo=Co.prototype=new bu;zo.constructor=Co;vu(zo,Yl.prototype);zo.isPureReactComponent=!0;var Hc=Array.isArray,Su=Object.prototype.hasOwnProperty,To={current:null},wu={key:!0,ref:!0,__self:!0,__source:!0};function ku(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)Su.call(t,s)&&!wu.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:sr,type:e,key:i,ref:a,props:r,_owner:To.current}}function Sg(e,t){return{$$typeof:sr,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Po(e){return typeof e=="object"&&e!==null&&e.$$typeof===sr}function wg(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(l){return t[l]})}var Kc=/\/+/g;function Zi(e,t){return typeof e=="object"&&e!==null&&e.key!=null?wg(""+e.key):t.toString(36)}function Mr(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 sr:case ug:a=!0}}if(a)return a=e,r=r(a),e=s===""?"."+Zi(a,0):s,Hc(r)?(l="",e!=null&&(l=e.replace(Kc,"$&/")+"/"),Mr(r,t,l,"",function(f){return f})):r!=null&&(Po(r)&&(r=Sg(r,l+(!r.key||a&&a.key===r.key?"":(""+r.key).replace(Kc,"$&/")+"/")+e)),t.push(r)),1;if(a=0,s=s===""?".":s+":",Hc(e))for(var d=0;d<e.length;d++){i=e[d];var u=s+Zi(i,d);a+=Mr(i,t,l,u,r)}else if(u=bg(e),typeof u=="function")for(e=u.call(e),d=0;!(i=e.next()).done;)i=i.value,u=s+Zi(i,d++),a+=Mr(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 yr(e,t,l){if(e==null)return e;var s=[],r=0;return Mr(e,s,"","",function(i){return t.call(l,i,r++)}),s}function kg(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},Hr={transition:null},_g={ReactCurrentDispatcher:at,ReactCurrentBatchConfig:Hr,ReactCurrentOwner:To};function _u(){throw Error("act(...) is not supported in production builds of React.")}ae.Children={map:yr,forEach:function(e,t,l){yr(e,function(){t.apply(this,arguments)},l)},count:function(e){var t=0;return yr(e,function(){t++}),t},toArray:function(e){return yr(e,function(t){return t})||[]},only:function(e){if(!Po(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ae.Component=Yl;ae.Fragment=pg;ae.Profiler=hg;ae.PureComponent=Co;ae.StrictMode=fg;ae.Suspense=yg;ae.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=_g;ae.act=_u;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=vu({},e.props),r=e.key,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=To.current),t.key!==void 0&&(r=""+t.key),e.type&&e.type.defaultProps)var d=e.type.defaultProps;for(u in t)Su.call(t,u)&&!wu.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:sr,type:e.type,key:r,ref:i,props:s,_owner:a}};ae.createContext=function(e){return e={$$typeof:xg,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:gg,_context:e},e.Consumer=e};ae.createElement=ku;ae.createFactory=function(e){var t=ku.bind(null,e);return t.type=e,t};ae.createRef=function(){return{current:null}};ae.forwardRef=function(e){return{$$typeof:mg,render:e}};ae.isValidElement=Po;ae.lazy=function(e){return{$$typeof:jg,_payload:{_status:-1,_result:e},_init:kg}};ae.memo=function(e,t){return{$$typeof:vg,type:e,compare:t===void 0?null:t}};ae.startTransition=function(e){var t=Hr.transition;Hr.transition={};try{e()}finally{Hr.transition=t}};ae.unstable_act=_u;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";mu.exports=ae;var b=mu.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 Cg=b,zg=Symbol.for("react.element"),Tg=Symbol.for("react.fragment"),Pg=Object.prototype.hasOwnProperty,Ig=Cg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Eg={key:!0,ref:!0,__self:!0,__source:!0};function Cu(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)Pg.call(t,s)&&!Eg.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:zg,type:e,key:i,ref:a,props:r,_owner:Ig.current}}Ci.Fragment=Tg;Ci.jsx=Cu;Ci.jsxs=Cu;xu.exports=Ci;var n=xu.exports,zu={exports:{}},St={},Tu={exports:{}},Pu={};/**
|
||
* @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,S=!1,h=!1,j=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,g=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 m(L){if(h=!1,o(L),!S)if(l(u)!==null)S=!0,ge(C);else{var K=l(f);K!==null&&le(m,K.startTime-L)}}function C(L,K){S=!1,h&&(h=!1,x(w),w=-1),v=!0;var G=c;try{for(o(K),p=l(u);p!==null&&(!(p.expirationTime>K)||L&&!T());){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(m,_e.startTime-K),xe=!1}return xe}finally{p=null,c=G,v=!1}}var A=!1,P=null,w=-1,_=5,U=-1;function T(){return!(e.unstable_now()-U<_)}function I(){if(P!==null){var L=e.unstable_now();U=L;var K=!0;try{K=P(!0,L)}finally{K?N():(A=!1,P=null)}}else A=!1}var N;if(typeof g=="function")N=function(){g(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(){j(I,0)};function ge(L){P=L,A||(A=!0,N())}function le(L,K){w=j(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(){S||v||(S=!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)&&(h?(x(w),w=-1):h=!0,le(m,G-ee))):(L.sortIndex=J,t(u,L),S||v||(S=!0,ge(C))),L},e.unstable_shouldYield=T,e.unstable_wrapCallback=function(L){var K=c;return function(){var G=c;c=K;try{return L.apply(this,arguments)}finally{c=G}}}})(Pu);Tu.exports=Pu;var Ag=Tu.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 Rg=b,bt=Ag;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 Iu=new Set,Us={};function tl(e,t){Bl(e,t),Bl(e+"Capture",t)}function Bl(e,t){for(Us[e]=t,e=0;e<t.length;e++)Iu.add(t[e])}var on=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ea=Object.prototype.hasOwnProperty,Lg=/^[: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]*$/,Qc={},Gc={};function Og(e){return Ea.call(Gc,e)?!0:Ea.call(Qc,e)?!1:Lg.test(e)?Gc[e]=!0:(Qc[e]=!0,!1)}function Dg(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 Ng(e,t,l,s){if(t===null||typeof t>"u"||Dg(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 Io=/[\-:]([a-z])/g;function Eo(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(Io,Eo);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(Io,Eo);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(Io,Eo);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 Ao(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")&&(Ng(t,l,r,s)&&(l=null),s||r===null?Og(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=Rg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,vr=Symbol.for("react.element"),jl=Symbol.for("react.portal"),bl=Symbol.for("react.fragment"),Ro=Symbol.for("react.strict_mode"),Aa=Symbol.for("react.profiler"),Eu=Symbol.for("react.provider"),Au=Symbol.for("react.context"),Lo=Symbol.for("react.forward_ref"),Ra=Symbol.for("react.suspense"),La=Symbol.for("react.suspense_list"),Oo=Symbol.for("react.memo"),yn=Symbol.for("react.lazy"),Ru=Symbol.for("react.offscreen"),Yc=Symbol.iterator;function as(e){return e===null||typeof e!="object"?null:(e=Yc&&e[Yc]||e["@@iterator"],typeof e=="function"?e:null)}var Pe=Object.assign,Vi;function zs(e){if(Vi===void 0)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);Vi=t&&t[1]||""}return`
|
||
`+Vi+e}var ea=!1;function ta(e,t){if(!e||ea)return"";ea=!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{ea=!1,Error.prepareStackTrace=l}return(e=e?e.displayName||e.name:"")?zs(e):""}function Wg(e){switch(e.tag){case 5:return zs(e.type);case 16:return zs("Lazy");case 13:return zs("Suspense");case 19:return zs("SuspenseList");case 0:case 2:case 15:return e=ta(e.type,!1),e;case 11:return e=ta(e.type.render,!1),e;case 1:return e=ta(e.type,!0),e;default:return""}}function Oa(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 Aa:return"Profiler";case Ro:return"StrictMode";case Ra:return"Suspense";case La:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Au:return(e.displayName||"Context")+".Consumer";case Eu:return(e._context.displayName||"Context")+".Provider";case Lo:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Oo:return t=e.displayName||null,t!==null?t:Oa(e.type)||"Memo";case yn:t=e._payload,e=e._init;try{return Oa(e(t))}catch{}}return null}function Bg(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 Oa(t);case 8:return t===Ro?"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 Lu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function $g(e){var t=Lu(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 jr(e){e._valueTracker||(e._valueTracker=$g(e))}function Ou(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var l=t.getValue(),s="";return e&&(s=Lu(e)?e.checked?"true":"false":e.value),e=s,e!==l?(t.setValue(e),!0):!1}function ti(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 Da(e,t){var l=t.checked;return Pe({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??e._wrapperState.initialChecked})}function Xc(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 Du(e,t){t=t.checked,t!=null&&Ao(e,"checked",t,!1)}function Na(e,t){Du(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")?Wa(e,t.type,l):t.hasOwnProperty("defaultValue")&&Wa(e,t.type,Rn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function qc(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 Wa(e,t,l){(t!=="number"||ti(e.ownerDocument)!==e)&&(l==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+l&&(e.defaultValue=""+l))}var Ts=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 Ba(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(F(91));return Pe({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Jc(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(Ts(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 Nu(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 Zc(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Wu(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 $a(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Wu(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var br,Bu=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(br=br||document.createElement("div"),br.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=br.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Fs(e,t){if(t){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=t;return}}e.textContent=t}var As={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},Ug=["Webkit","ms","Moz","O"];Object.keys(As).forEach(function(e){Ug.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),As[t]=As[e]})});function $u(e,t,l){return t==null||typeof t=="boolean"||t===""?"":l||typeof t!="number"||t===0||As.hasOwnProperty(e)&&As[e]?(""+t).trim():t+"px"}function Uu(e,t){e=e.style;for(var l in t)if(t.hasOwnProperty(l)){var s=l.indexOf("--")===0,r=$u(l,t[l],s);l==="float"&&(l="cssFloat"),s?e.setProperty(l,r):e[l]=r}}var Fg=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 Ua(e,t){if(t){if(Fg[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 Fa(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 Ma=null;function Do(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ha=null,Ll=null,Ol=null;function Vc(e){if(e=ar(e)){if(typeof Ha!="function")throw Error(F(280));var t=e.stateNode;t&&(t=Ei(t),Ha(e.stateNode,e.type,t))}}function Fu(e){Ll?Ol?Ol.push(e):Ol=[e]:Ll=e}function Mu(){if(Ll){var e=Ll,t=Ol;if(Ol=Ll=null,Vc(e),t)for(e=0;e<t.length;e++)Vc(t[e])}}function Hu(e,t){return e(t)}function Ku(){}var na=!1;function Qu(e,t,l){if(na)return e(t,l);na=!0;try{return Hu(e,t,l)}finally{na=!1,(Ll!==null||Ol!==null)&&(Ku(),Mu())}}function Ms(e,t){var l=e.stateNode;if(l===null)return null;var s=Ei(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 Ka=!1;if(on)try{var os={};Object.defineProperty(os,"passive",{get:function(){Ka=!0}}),window.addEventListener("test",os,os),window.removeEventListener("test",os,os)}catch{Ka=!1}function Mg(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 Rs=!1,ni=null,li=!1,Qa=null,Hg={onError:function(e){Rs=!0,ni=e}};function Kg(e,t,l,s,r,i,a,d,u){Rs=!1,ni=null,Mg.apply(Hg,arguments)}function Qg(e,t,l,s,r,i,a,d,u){if(Kg.apply(this,arguments),Rs){if(Rs){var f=ni;Rs=!1,ni=null}else throw Error(F(198));li||(li=!0,Qa=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 Gu(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 ed(e){if(nl(e)!==e)throw Error(F(188))}function Gg(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 ed(r),e;if(i===s)return ed(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 Yu(e){return e=Gg(e),e!==null?Xu(e):null}function Xu(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Xu(e);if(t!==null)return t;e=e.sibling}return null}var qu=bt.unstable_scheduleCallback,td=bt.unstable_cancelCallback,Yg=bt.unstable_shouldYield,Xg=bt.unstable_requestPaint,Le=bt.unstable_now,qg=bt.unstable_getCurrentPriorityLevel,No=bt.unstable_ImmediatePriority,Ju=bt.unstable_UserBlockingPriority,si=bt.unstable_NormalPriority,Jg=bt.unstable_LowPriority,Zu=bt.unstable_IdlePriority,zi=null,Qt=null;function Zg(e){if(Qt&&typeof Qt.onCommitFiberRoot=="function")try{Qt.onCommitFiberRoot(zi,e,void 0,(e.current.flags&128)===128)}catch{}}var Wt=Math.clz32?Math.clz32:tx,Vg=Math.log,ex=Math.LN2;function tx(e){return e>>>=0,e===0?32:31-(Vg(e)/ex|0)|0}var Sr=64,wr=4194304;function Ps(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 ri(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=Ps(d):(i&=a,i!==0&&(s=Ps(i)))}else a=l&~r,a!==0?s=Ps(a):i!==0&&(s=Ps(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 nx(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 lx(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]=nx(d,t)):u<=t&&(e.expiredLanes|=d),i&=~d}}function Ga(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Vu(){var e=Sr;return Sr<<=1,!(Sr&4194240)&&(Sr=64),e}function la(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function rr(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 sx(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 Wo(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 ep(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var tp,Bo,np,lp,sp,Ya=!1,kr=[],_n=null,Cn=null,zn=null,Hs=new Map,Ks=new Map,jn=[],rx="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 nd(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":Hs.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ks.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=ar(t),t!==null&&Bo(t)),e):(e.eventSystemFlags|=s,t=e.targetContainers,r!==null&&t.indexOf(r)===-1&&t.push(r),e)}function ix(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 Hs.set(i,cs(Hs.get(i)||null,e,t,l,s,r)),!0;case"gotpointercapture":return i=r.pointerId,Ks.set(i,cs(Ks.get(i)||null,e,t,l,s,r)),!0}return!1}function rp(e){var t=Hn(e.target);if(t!==null){var l=nl(t);if(l!==null){if(t=l.tag,t===13){if(t=Gu(l),t!==null){e.blockedOn=t,sp(e.priority,function(){np(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 Kr(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var l=Xa(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(l===null){l=e.nativeEvent;var s=new l.constructor(l.type,l);Ma=s,l.target.dispatchEvent(s),Ma=null}else return t=ar(l),t!==null&&Bo(t),e.blockedOn=l,!1;t.shift()}return!0}function ld(e,t,l){Kr(e)&&l.delete(t)}function ax(){Ya=!1,_n!==null&&Kr(_n)&&(_n=null),Cn!==null&&Kr(Cn)&&(Cn=null),zn!==null&&Kr(zn)&&(zn=null),Hs.forEach(ld),Ks.forEach(ld)}function ds(e,t){e.blockedOn===t&&(e.blockedOn=null,Ya||(Ya=!0,bt.unstable_scheduleCallback(bt.unstable_NormalPriority,ax)))}function Qs(e){function t(r){return ds(r,e)}if(0<kr.length){ds(kr[0],e);for(var l=1;l<kr.length;l++){var s=kr[l];s.blockedOn===e&&(s.blockedOn=null)}}for(_n!==null&&ds(_n,e),Cn!==null&&ds(Cn,e),zn!==null&&ds(zn,e),Hs.forEach(t),Ks.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);)rp(l),l.blockedOn===null&&jn.shift()}var Dl=pn.ReactCurrentBatchConfig,ii=!0;function ox(e,t,l,s){var r=he,i=Dl.transition;Dl.transition=null;try{he=1,$o(e,t,l,s)}finally{he=r,Dl.transition=i}}function cx(e,t,l,s){var r=he,i=Dl.transition;Dl.transition=null;try{he=4,$o(e,t,l,s)}finally{he=r,Dl.transition=i}}function $o(e,t,l,s){if(ii){var r=Xa(e,t,l,s);if(r===null)fa(e,t,s,ai,l),nd(e,s);else if(ix(r,e,t,l,s))s.stopPropagation();else if(nd(e,s),t&4&&-1<rx.indexOf(e)){for(;r!==null;){var i=ar(r);if(i!==null&&tp(i),i=Xa(e,t,l,s),i===null&&fa(e,t,s,ai,l),i===r)break;r=i}r!==null&&s.stopPropagation()}else fa(e,t,s,null,l)}}var ai=null;function Xa(e,t,l,s){if(ai=null,e=Do(s),e=Hn(e),e!==null)if(t=nl(e),t===null)e=null;else if(l=t.tag,l===13){if(e=Gu(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 ai=e,null}function ip(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(qg()){case No:return 1;case Ju:return 4;case si:case Jg:return 16;case Zu:return 536870912;default:return 16}default:return 16}}var Sn=null,Uo=null,Qr=null;function ap(){if(Qr)return Qr;var e,t=Uo,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 Qr=r.slice(e,1<s?1-s:void 0)}function Gr(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 _r(){return!0}function sd(){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)?_r:sd,this.isPropagationStopped=sd,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=_r)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=_r)},persist:function(){},isPersistent:_r}),t}var Xl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Fo=wt(Xl),ir=Pe({},Xl,{view:0,detail:0}),dx=wt(ir),sa,ra,us,Ti=Pe({},ir,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Mo,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"?(sa=e.screenX-us.screenX,ra=e.screenY-us.screenY):ra=sa=0,us=e),sa)},movementY:function(e){return"movementY"in e?e.movementY:ra}}),rd=wt(Ti),ux=Pe({},Ti,{dataTransfer:0}),px=wt(ux),fx=Pe({},ir,{relatedTarget:0}),ia=wt(fx),hx=Pe({},Xl,{animationName:0,elapsedTime:0,pseudoElement:0}),gx=wt(hx),xx=Pe({},Xl,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),mx=wt(xx),yx=Pe({},Xl,{data:0}),id=wt(yx),vx={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},jx={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"},bx={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Sx(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=bx[e])?!!t[e]:!1}function Mo(){return Sx}var wx=Pe({},ir,{key:function(e){if(e.key){var t=vx[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Gr(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?jx[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Mo,charCode:function(e){return e.type==="keypress"?Gr(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Gr(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),kx=wt(wx),_x=Pe({},Ti,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ad=wt(_x),Cx=Pe({},ir,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Mo}),zx=wt(Cx),Tx=Pe({},Xl,{propertyName:0,elapsedTime:0,pseudoElement:0}),Px=wt(Tx),Ix=Pe({},Ti,{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}),Ex=wt(Ix),Ax=[9,13,27,32],Ho=on&&"CompositionEvent"in window,Ls=null;on&&"documentMode"in document&&(Ls=document.documentMode);var Rx=on&&"TextEvent"in window&&!Ls,op=on&&(!Ho||Ls&&8<Ls&&11>=Ls),od=" ",cd=!1;function cp(e,t){switch(e){case"keyup":return Ax.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function dp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Sl=!1;function Lx(e,t){switch(e){case"compositionend":return dp(t);case"keypress":return t.which!==32?null:(cd=!0,od);case"textInput":return e=t.data,e===od&&cd?null:e;default:return null}}function Ox(e,t){if(Sl)return e==="compositionend"||!Ho&&cp(e,t)?(e=ap(),Qr=Uo=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 op&&t.locale!=="ko"?null:t.data;default:return null}}var Dx={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 dd(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Dx[e.type]:t==="textarea"}function up(e,t,l,s){Fu(s),t=oi(t,"onChange"),0<t.length&&(l=new Fo("onChange","change",null,l,s),e.push({event:l,listeners:t}))}var Os=null,Gs=null;function Nx(e){Sp(e,0)}function Pi(e){var t=_l(e);if(Ou(t))return e}function Wx(e,t){if(e==="change")return t}var pp=!1;if(on){var aa;if(on){var oa="oninput"in document;if(!oa){var ud=document.createElement("div");ud.setAttribute("oninput","return;"),oa=typeof ud.oninput=="function"}aa=oa}else aa=!1;pp=aa&&(!document.documentMode||9<document.documentMode)}function pd(){Os&&(Os.detachEvent("onpropertychange",fp),Gs=Os=null)}function fp(e){if(e.propertyName==="value"&&Pi(Gs)){var t=[];up(t,Gs,e,Do(e)),Qu(Nx,t)}}function Bx(e,t,l){e==="focusin"?(pd(),Os=t,Gs=l,Os.attachEvent("onpropertychange",fp)):e==="focusout"&&pd()}function $x(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Pi(Gs)}function Ux(e,t){if(e==="click")return Pi(t)}function Fx(e,t){if(e==="input"||e==="change")return Pi(t)}function Mx(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var $t=typeof Object.is=="function"?Object.is:Mx;function Ys(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(!Ea.call(t,r)||!$t(e[r],t[r]))return!1}return!0}function fd(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function hd(e,t){var l=fd(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=fd(l)}}function hp(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?hp(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function gp(){for(var e=window,t=ti();t instanceof e.HTMLIFrameElement;){try{var l=typeof t.contentWindow.location.href=="string"}catch{l=!1}if(l)e=t.contentWindow;else break;t=ti(e.document)}return t}function Ko(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 Hx(e){var t=gp(),l=e.focusedElem,s=e.selectionRange;if(t!==l&&l&&l.ownerDocument&&hp(l.ownerDocument.documentElement,l)){if(s!==null&&Ko(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=hd(l,i);var a=hd(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 Kx=on&&"documentMode"in document&&11>=document.documentMode,wl=null,qa=null,Ds=null,Ja=!1;function gd(e,t,l){var s=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Ja||wl==null||wl!==ti(s)||(s=wl,"selectionStart"in s&&Ko(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}),Ds&&Ys(Ds,s)||(Ds=s,s=oi(qa,"onSelect"),0<s.length&&(t=new Fo("onSelect","select",null,t,l),e.push({event:t,listeners:s}),t.target=wl)))}function Cr(e,t){var l={};return l[e.toLowerCase()]=t.toLowerCase(),l["Webkit"+e]="webkit"+t,l["Moz"+e]="moz"+t,l}var kl={animationend:Cr("Animation","AnimationEnd"),animationiteration:Cr("Animation","AnimationIteration"),animationstart:Cr("Animation","AnimationStart"),transitionend:Cr("Transition","TransitionEnd")},ca={},xp={};on&&(xp=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 Ii(e){if(ca[e])return ca[e];if(!kl[e])return e;var t=kl[e],l;for(l in t)if(t.hasOwnProperty(l)&&l in xp)return ca[e]=t[l];return e}var mp=Ii("animationend"),yp=Ii("animationiteration"),vp=Ii("animationstart"),jp=Ii("transitionend"),bp=new Map,xd="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){bp.set(e,t),tl(t,[e])}for(var da=0;da<xd.length;da++){var ua=xd[da],Qx=ua.toLowerCase(),Gx=ua[0].toUpperCase()+ua.slice(1);Dn(Qx,"on"+Gx)}Dn(mp,"onAnimationEnd");Dn(yp,"onAnimationIteration");Dn(vp,"onAnimationStart");Dn("dblclick","onDoubleClick");Dn("focusin","onFocus");Dn("focusout","onBlur");Dn(jp,"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 Is="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(" "),Yx=new Set("cancel close invalid load scroll toggle".split(" ").concat(Is));function md(e,t,l){var s=e.type||"unknown-event";e.currentTarget=l,Qg(s,t,void 0,e),e.currentTarget=null}function Sp(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;md(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;md(r,d,f),i=u}}}if(li)throw e=Qa,li=!1,Qa=null,e}function je(e,t){var l=t[no];l===void 0&&(l=t[no]=new Set);var s=e+"__bubble";l.has(s)||(wp(t,e,2,!1),l.add(s))}function pa(e,t,l){var s=0;t&&(s|=4),wp(l,e,s,t)}var zr="_reactListening"+Math.random().toString(36).slice(2);function Xs(e){if(!e[zr]){e[zr]=!0,Iu.forEach(function(l){l!=="selectionchange"&&(Yx.has(l)||pa(l,!1,e),pa(l,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[zr]||(t[zr]=!0,pa("selectionchange",!1,t))}}function wp(e,t,l,s){switch(ip(t)){case 1:var r=ox;break;case 4:r=cx;break;default:r=$o}l=r.bind(null,t,l,e),r=void 0,!Ka||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 fa(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}Qu(function(){var f=i,y=Do(l),p=[];e:{var c=bp.get(e);if(c!==void 0){var v=Fo,S=e;switch(e){case"keypress":if(Gr(l)===0)break e;case"keydown":case"keyup":v=kx;break;case"focusin":S="focus",v=ia;break;case"focusout":S="blur",v=ia;break;case"beforeblur":case"afterblur":v=ia;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=rd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":v=px;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":v=zx;break;case mp:case yp:case vp:v=gx;break;case jp:v=Px;break;case"scroll":v=dx;break;case"wheel":v=Ex;break;case"copy":case"cut":case"paste":v=mx;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":v=ad}var h=(t&4)!==0,j=!h&&e==="scroll",x=h?c!==null?c+"Capture":null:c;h=[];for(var g=f,o;g!==null;){o=g;var m=o.stateNode;if(o.tag===5&&m!==null&&(o=m,x!==null&&(m=Ms(g,x),m!=null&&h.push(qs(g,m,o)))),j)break;g=g.return}0<h.length&&(c=new v(c,S,null,l,y),p.push({event:c,listeners:h}))}}if(!(t&7)){e:{if(c=e==="mouseover"||e==="pointerover",v=e==="mouseout"||e==="pointerout",c&&l!==Ma&&(S=l.relatedTarget||l.fromElement)&&(Hn(S)||S[cn]))break e;if((v||c)&&(c=y.window===y?y:(c=y.ownerDocument)?c.defaultView||c.parentWindow:window,v?(S=l.relatedTarget||l.toElement,v=f,S=S?Hn(S):null,S!==null&&(j=nl(S),S!==j||S.tag!==5&&S.tag!==6)&&(S=null)):(v=null,S=f),v!==S)){if(h=rd,m="onMouseLeave",x="onMouseEnter",g="mouse",(e==="pointerout"||e==="pointerover")&&(h=ad,m="onPointerLeave",x="onPointerEnter",g="pointer"),j=v==null?c:_l(v),o=S==null?c:_l(S),c=new h(m,g+"leave",v,l,y),c.target=j,c.relatedTarget=o,m=null,Hn(y)===f&&(h=new h(x,g+"enter",S,l,y),h.target=o,h.relatedTarget=j,m=h),j=m,v&&S)t:{for(h=v,x=S,g=0,o=h;o;o=fl(o))g++;for(o=0,m=x;m;m=fl(m))o++;for(;0<g-o;)h=fl(h),g--;for(;0<o-g;)x=fl(x),o--;for(;g--;){if(h===x||x!==null&&h===x.alternate)break t;h=fl(h),x=fl(x)}h=null}else h=null;v!==null&&yd(p,c,v,h,!1),S!==null&&j!==null&&yd(p,j,S,h,!0)}}e:{if(c=f?_l(f):window,v=c.nodeName&&c.nodeName.toLowerCase(),v==="select"||v==="input"&&c.type==="file")var C=Wx;else if(dd(c))if(pp)C=Fx;else{C=$x;var A=Bx}else(v=c.nodeName)&&v.toLowerCase()==="input"&&(c.type==="checkbox"||c.type==="radio")&&(C=Ux);if(C&&(C=C(e,f))){up(p,C,l,y);break e}A&&A(e,c,f),e==="focusout"&&(A=c._wrapperState)&&A.controlled&&c.type==="number"&&Wa(c,"number",c.value)}switch(A=f?_l(f):window,e){case"focusin":(dd(A)||A.contentEditable==="true")&&(wl=A,qa=f,Ds=null);break;case"focusout":Ds=qa=wl=null;break;case"mousedown":Ja=!0;break;case"contextmenu":case"mouseup":case"dragend":Ja=!1,gd(p,l,y);break;case"selectionchange":if(Kx)break;case"keydown":case"keyup":gd(p,l,y)}var P;if(Ho)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?cp(e,l)&&(w="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(w="onCompositionStart");w&&(op&&l.locale!=="ko"&&(Sl||w!=="onCompositionStart"?w==="onCompositionEnd"&&Sl&&(P=ap()):(Sn=y,Uo="value"in Sn?Sn.value:Sn.textContent,Sl=!0)),A=oi(f,w),0<A.length&&(w=new id(w,e,null,l,y),p.push({event:w,listeners:A}),P?w.data=P:(P=dp(l),P!==null&&(w.data=P)))),(P=Rx?Lx(e,l):Ox(e,l))&&(f=oi(f,"onBeforeInput"),0<f.length&&(y=new id("onBeforeInput","beforeinput",null,l,y),p.push({event:y,listeners:f}),y.data=P))}Sp(p,t)})}function qs(e,t,l){return{instance:e,listener:t,currentTarget:l}}function oi(e,t){for(var l=t+"Capture",s=[];e!==null;){var r=e,i=r.stateNode;r.tag===5&&i!==null&&(r=i,i=Ms(e,l),i!=null&&s.unshift(qs(e,i,r)),i=Ms(e,t),i!=null&&s.push(qs(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 yd(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=Ms(l,i),u!=null&&a.unshift(qs(l,u,d))):r||(u=Ms(l,i),u!=null&&a.push(qs(l,u,d)))),l=l.return}a.length!==0&&e.push({event:t,listeners:a})}var Xx=/\r\n?/g,qx=/\u0000|\uFFFD/g;function vd(e){return(typeof e=="string"?e:""+e).replace(Xx,`
|
||
`).replace(qx,"")}function Tr(e,t,l){if(t=vd(t),vd(e)!==t&&l)throw Error(F(425))}function ci(){}var Za=null,Va=null;function eo(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 to=typeof setTimeout=="function"?setTimeout:void 0,Jx=typeof clearTimeout=="function"?clearTimeout:void 0,jd=typeof Promise=="function"?Promise:void 0,Zx=typeof queueMicrotask=="function"?queueMicrotask:typeof jd<"u"?function(e){return jd.resolve(null).then(e).catch(Vx)}:to;function Vx(e){setTimeout(function(){throw e})}function ha(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),Qs(t);return}s--}else l!=="$"&&l!=="$?"&&l!=="$!"||s++;l=r}while(l);Qs(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 bd(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,Js="__reactProps$"+ql,cn="__reactContainer$"+ql,no="__reactEvents$"+ql,em="__reactListeners$"+ql,tm="__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=bd(e);e!==null;){if(l=e[Kt])return l;e=bd(e)}return t}e=l,l=e.parentNode}return null}function ar(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 Ei(e){return e[Js]||null}var lo=[],Cl=-1;function Nn(e){return{current:e}}function be(e){0>Cl||(e.current=lo[Cl],lo[Cl]=null,Cl--)}function ve(e,t){Cl++,lo[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 di(){be(pt),be(st)}function Sd(e,t,l){if(st.current!==Ln)throw Error(F(168));ve(st,t),ve(pt,l)}function kp(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,Bg(e)||"Unknown",r));return Pe({},l,s)}function ui(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ln,Xn=st.current,ve(st,e),ve(pt,pt.current),!0}function wd(e,t,l){var s=e.stateNode;if(!s)throw Error(F(169));l?(e=kp(e,t,Xn),s.__reactInternalMemoizedMergedChildContext=e,be(pt),be(st),ve(st,e)):be(pt),ve(pt,l)}var ln=null,Ai=!1,ga=!1;function _p(e){ln===null?ln=[e]:ln.push(e)}function nm(e){Ai=!0,_p(e)}function Wn(){if(!ga&&ln!==null){ga=!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,Ai=!1}catch(r){throw ln!==null&&(ln=ln.slice(e+1)),qu(No,Wn),r}finally{he=t,ga=!1}}return null}var zl=[],Tl=0,pi=null,fi=0,_t=[],Ct=0,qn=null,sn=1,rn="";function Fn(e,t){zl[Tl++]=fi,zl[Tl++]=pi,pi=e,fi=t}function Cp(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 Qo(e){e.return!==null&&(Fn(e,1),Cp(e,1,0))}function Go(e){for(;e===pi;)pi=zl[--Tl],zl[Tl]=null,fi=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 zp(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 kd(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 so(e){return(e.mode&1)!==0&&(e.flags&128)===0}function ro(e){if(ke){var t=vt;if(t){var l=t;if(!kd(e,t)){if(so(e))throw Error(F(418));t=Tn(l.nextSibling);var s=jt;t&&kd(e,t)?zp(s,l):(e.flags=e.flags&-4097|2,ke=!1,jt=e)}}else{if(so(e))throw Error(F(418));e.flags=e.flags&-4097|2,ke=!1,jt=e}}}function _d(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;jt=e}function Pr(e){if(e!==jt)return!1;if(!ke)return _d(e),ke=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!eo(e.type,e.memoizedProps)),t&&(t=vt)){if(so(e))throw Tp(),Error(F(418));for(;t;)zp(e,t),t=Tn(t.nextSibling)}if(_d(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 Tp(){for(var e=vt;e;)e=Tn(e.nextSibling)}function Ul(){vt=jt=null,ke=!1}function Yo(e){Dt===null?Dt=[e]:Dt.push(e)}var lm=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 Ir(e,t){throw e=Object.prototype.toString.call(t),Error(F(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Cd(e){var t=e._init;return t(e._payload)}function Pp(e){function t(x,g){if(e){var o=x.deletions;o===null?(x.deletions=[g],x.flags|=16):o.push(g)}}function l(x,g){if(!e)return null;for(;g!==null;)t(x,g),g=g.sibling;return null}function s(x,g){for(x=new Map;g!==null;)g.key!==null?x.set(g.key,g):x.set(g.index,g),g=g.sibling;return x}function r(x,g){return x=An(x,g),x.index=0,x.sibling=null,x}function i(x,g,o){return x.index=o,e?(o=x.alternate,o!==null?(o=o.index,o<g?(x.flags|=2,g):o):(x.flags|=2,g)):(x.flags|=1048576,g)}function a(x){return e&&x.alternate===null&&(x.flags|=2),x}function d(x,g,o,m){return g===null||g.tag!==6?(g=Sa(o,x.mode,m),g.return=x,g):(g=r(g,o),g.return=x,g)}function u(x,g,o,m){var C=o.type;return C===bl?y(x,g,o.props.children,m,o.key):g!==null&&(g.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===yn&&Cd(C)===g.type)?(m=r(g,o.props),m.ref=ps(x,g,o),m.return=x,m):(m=ei(o.type,o.key,o.props,null,x.mode,m),m.ref=ps(x,g,o),m.return=x,m)}function f(x,g,o,m){return g===null||g.tag!==4||g.stateNode.containerInfo!==o.containerInfo||g.stateNode.implementation!==o.implementation?(g=wa(o,x.mode,m),g.return=x,g):(g=r(g,o.children||[]),g.return=x,g)}function y(x,g,o,m,C){return g===null||g.tag!==7?(g=Yn(o,x.mode,m,C),g.return=x,g):(g=r(g,o),g.return=x,g)}function p(x,g,o){if(typeof g=="string"&&g!==""||typeof g=="number")return g=Sa(""+g,x.mode,o),g.return=x,g;if(typeof g=="object"&&g!==null){switch(g.$$typeof){case vr:return o=ei(g.type,g.key,g.props,null,x.mode,o),o.ref=ps(x,null,g),o.return=x,o;case jl:return g=wa(g,x.mode,o),g.return=x,g;case yn:var m=g._init;return p(x,m(g._payload),o)}if(Ts(g)||as(g))return g=Yn(g,x.mode,o,null),g.return=x,g;Ir(x,g)}return null}function c(x,g,o,m){var C=g!==null?g.key:null;if(typeof o=="string"&&o!==""||typeof o=="number")return C!==null?null:d(x,g,""+o,m);if(typeof o=="object"&&o!==null){switch(o.$$typeof){case vr:return o.key===C?u(x,g,o,m):null;case jl:return o.key===C?f(x,g,o,m):null;case yn:return C=o._init,c(x,g,C(o._payload),m)}if(Ts(o)||as(o))return C!==null?null:y(x,g,o,m,null);Ir(x,o)}return null}function v(x,g,o,m,C){if(typeof m=="string"&&m!==""||typeof m=="number")return x=x.get(o)||null,d(g,x,""+m,C);if(typeof m=="object"&&m!==null){switch(m.$$typeof){case vr:return x=x.get(m.key===null?o:m.key)||null,u(g,x,m,C);case jl:return x=x.get(m.key===null?o:m.key)||null,f(g,x,m,C);case yn:var A=m._init;return v(x,g,o,A(m._payload),C)}if(Ts(m)||as(m))return x=x.get(o)||null,y(g,x,m,C,null);Ir(g,m)}return null}function S(x,g,o,m){for(var C=null,A=null,P=g,w=g=0,_=null;P!==null&&w<o.length;w++){P.index>w?(_=P,P=null):_=P.sibling;var U=c(x,P,o[w],m);if(U===null){P===null&&(P=_);break}e&&P&&U.alternate===null&&t(x,P),g=i(U,g,w),A===null?C=U:A.sibling=U,A=U,P=_}if(w===o.length)return l(x,P),ke&&Fn(x,w),C;if(P===null){for(;w<o.length;w++)P=p(x,o[w],m),P!==null&&(g=i(P,g,w),A===null?C=P:A.sibling=P,A=P);return ke&&Fn(x,w),C}for(P=s(x,P);w<o.length;w++)_=v(P,x,w,o[w],m),_!==null&&(e&&_.alternate!==null&&P.delete(_.key===null?w:_.key),g=i(_,g,w),A===null?C=_:A.sibling=_,A=_);return e&&P.forEach(function(T){return t(x,T)}),ke&&Fn(x,w),C}function h(x,g,o,m){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,P=g,w=g=0,_=null,U=o.next();P!==null&&!U.done;w++,U=o.next()){P.index>w?(_=P,P=null):_=P.sibling;var T=c(x,P,U.value,m);if(T===null){P===null&&(P=_);break}e&&P&&T.alternate===null&&t(x,P),g=i(T,g,w),A===null?C=T:A.sibling=T,A=T,P=_}if(U.done)return l(x,P),ke&&Fn(x,w),C;if(P===null){for(;!U.done;w++,U=o.next())U=p(x,U.value,m),U!==null&&(g=i(U,g,w),A===null?C=U:A.sibling=U,A=U);return ke&&Fn(x,w),C}for(P=s(x,P);!U.done;w++,U=o.next())U=v(P,x,w,U.value,m),U!==null&&(e&&U.alternate!==null&&P.delete(U.key===null?w:U.key),g=i(U,g,w),A===null?C=U:A.sibling=U,A=U);return e&&P.forEach(function(I){return t(x,I)}),ke&&Fn(x,w),C}function j(x,g,o,m){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 vr:e:{for(var C=o.key,A=g;A!==null;){if(A.key===C){if(C=o.type,C===bl){if(A.tag===7){l(x,A.sibling),g=r(A,o.props.children),g.return=x,x=g;break e}}else if(A.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===yn&&Cd(C)===A.type){l(x,A.sibling),g=r(A,o.props),g.ref=ps(x,A,o),g.return=x,x=g;break e}l(x,A);break}else t(x,A);A=A.sibling}o.type===bl?(g=Yn(o.props.children,x.mode,m,o.key),g.return=x,x=g):(m=ei(o.type,o.key,o.props,null,x.mode,m),m.ref=ps(x,g,o),m.return=x,x=m)}return a(x);case jl:e:{for(A=o.key;g!==null;){if(g.key===A)if(g.tag===4&&g.stateNode.containerInfo===o.containerInfo&&g.stateNode.implementation===o.implementation){l(x,g.sibling),g=r(g,o.children||[]),g.return=x,x=g;break e}else{l(x,g);break}else t(x,g);g=g.sibling}g=wa(o,x.mode,m),g.return=x,x=g}return a(x);case yn:return A=o._init,j(x,g,A(o._payload),m)}if(Ts(o))return S(x,g,o,m);if(as(o))return h(x,g,o,m);Ir(x,o)}return typeof o=="string"&&o!==""||typeof o=="number"?(o=""+o,g!==null&&g.tag===6?(l(x,g.sibling),g=r(g,o),g.return=x,x=g):(l(x,g),g=Sa(o,x.mode,m),g.return=x,x=g),a(x)):l(x,g)}return j}var Fl=Pp(!0),Ip=Pp(!1),hi=Nn(null),gi=null,Pl=null,Xo=null;function qo(){Xo=Pl=gi=null}function Jo(e){var t=hi.current;be(hi),e._currentValue=t}function io(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){gi=e,Xo=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(Xo!==e)if(e={context:e,memoizedValue:t,next:null},Pl===null){if(gi===null)throw Error(F(308));Pl=e,gi.dependencies={lanes:0,firstContext:e}}else Pl=Pl.next=e;return t}var Kn=null;function Zo(e){Kn===null?Kn=[e]:Kn.push(e)}function Ep(e,t,l,s){var r=t.interleaved;return r===null?(l.next=l,Zo(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 Vo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ap(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,Zo(s)):(t.next=r.next,r.next=t),s.interleaved=t,dn(e,l)}function Yr(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,Wo(e,l)}}function zd(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 xi(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 S=e,h=d;switch(c=t,v=l,h.tag){case 1:if(S=h.payload,typeof S=="function"){p=S.call(v,p,c);break e}p=S;break e;case 3:S.flags=S.flags&-65537|128;case 0:if(S=h.payload,c=typeof S=="function"?S.call(v,p,c):S,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 Td(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 or={},Gt=Nn(or),Zs=Nn(or),Vs=Nn(or);function Qn(e){if(e===or)throw Error(F(174));return e}function ec(e,t){switch(ve(Vs,t),ve(Zs,e),ve(Gt,or),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:$a(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=$a(t,e)}be(Gt),ve(Gt,t)}function Ml(){be(Gt),be(Zs),be(Vs)}function Rp(e){Qn(Vs.current);var t=Qn(Gt.current),l=$a(t,e.type);t!==l&&(ve(Zs,e),ve(Gt,l))}function tc(e){Zs.current===e&&(be(Gt),be(Zs))}var ze=Nn(0);function mi(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 xa=[];function nc(){for(var e=0;e<xa.length;e++)xa[e]._workInProgressVersionPrimary=null;xa.length=0}var Xr=pn.ReactCurrentDispatcher,ma=pn.ReactCurrentBatchConfig,Jn=0,Te=null,Ke=null,Xe=null,yi=!1,Ns=!1,er=0,sm=0;function tt(){throw Error(F(321))}function lc(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 sc(e,t,l,s,r,i){if(Jn=i,Te=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Xr.current=e===null||e.memoizedState===null?om:cm,e=l(s,r),Ns){i=0;do{if(Ns=!1,er=0,25<=i)throw Error(F(301));i+=1,Xe=Ke=null,t.updateQueue=null,Xr.current=dm,e=l(s,r)}while(Ns)}if(Xr.current=vi,t=Ke!==null&&Ke.next!==null,Jn=0,Xe=Ke=Te=null,yi=!1,t)throw Error(F(300));return e}function rc(){var e=er!==0;return er=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 tr(e,t){return typeof t=="function"?t(e):t}function ya(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 va(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 Lp(){}function Op(e,t){var l=Te,s=It(),r=t(),i=!$t(s.memoizedState,r);if(i&&(s.memoizedState=r,ut=!0),s=s.queue,ic(Wp.bind(null,l,s,e),[e]),s.getSnapshot!==t||i||Xe!==null&&Xe.memoizedState.tag&1){if(l.flags|=2048,nr(9,Np.bind(null,l,s,r,t),void 0,null),qe===null)throw Error(F(349));Jn&30||Dp(l,t,r)}return r}function Dp(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 Np(e,t,l,s){t.value=l,t.getSnapshot=s,Bp(t)&&$p(e)}function Wp(e,t,l){return l(function(){Bp(t)&&$p(e)})}function Bp(e){var t=e.getSnapshot;e=e.value;try{var l=t();return!$t(e,l)}catch{return!0}}function $p(e){var t=dn(e,1);t!==null&&Bt(t,e,1,-1)}function Pd(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:tr,lastRenderedState:e},t.queue=e,e=e.dispatch=am.bind(null,Te,e),[t.memoizedState,e]}function nr(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 Up(){return It().memoizedState}function qr(e,t,l,s){var r=Ht();Te.flags|=e,r.memoizedState=nr(1|t,l,void 0,s===void 0?null:s)}function Ri(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&&lc(s,a.deps)){r.memoizedState=nr(t,l,i,s);return}}Te.flags|=e,r.memoizedState=nr(1|t,l,i,s)}function Id(e,t){return qr(8390656,8,e,t)}function ic(e,t){return Ri(2048,8,e,t)}function Fp(e,t){return Ri(4,2,e,t)}function Mp(e,t){return Ri(4,4,e,t)}function Hp(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 Kp(e,t,l){return l=l!=null?l.concat([e]):null,Ri(4,4,Hp.bind(null,t,e),l)}function ac(){}function Qp(e,t){var l=It();t=t===void 0?null:t;var s=l.memoizedState;return s!==null&&t!==null&&lc(t,s[1])?s[0]:(l.memoizedState=[e,t],e)}function Gp(e,t){var l=It();t=t===void 0?null:t;var s=l.memoizedState;return s!==null&&t!==null&&lc(t,s[1])?s[0]:(e=e(),l.memoizedState=[e,t],e)}function Yp(e,t,l){return Jn&21?($t(l,t)||(l=Vu(),Te.lanes|=l,Zn|=l,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ut=!0),e.memoizedState=l)}function rm(e,t){var l=he;he=l!==0&&4>l?l:4,e(!0);var s=ma.transition;ma.transition={};try{e(!1),t()}finally{he=l,ma.transition=s}}function Xp(){return It().memoizedState}function im(e,t,l){var s=En(e);if(l={lane:s,action:l,hasEagerState:!1,eagerState:null,next:null},qp(e))Jp(t,l);else if(l=Ep(e,t,l,s),l!==null){var r=it();Bt(l,e,s,r),Zp(l,t,s)}}function am(e,t,l){var s=En(e),r={lane:s,action:l,hasEagerState:!1,eagerState:null,next:null};if(qp(e))Jp(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,Zo(t)):(r.next=u.next,u.next=r),t.interleaved=r;return}}catch{}finally{}l=Ep(e,t,r,s),l!==null&&(r=it(),Bt(l,e,s,r),Zp(l,t,s))}}function qp(e){var t=e.alternate;return e===Te||t!==null&&t===Te}function Jp(e,t){Ns=yi=!0;var l=e.pending;l===null?t.next=t:(t.next=l.next,l.next=t),e.pending=t}function Zp(e,t,l){if(l&4194240){var s=t.lanes;s&=e.pendingLanes,l|=s,t.lanes=l,Wo(e,l)}}var vi={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},om={readContext:Pt,useCallback:function(e,t){return Ht().memoizedState=[e,t===void 0?null:t],e},useContext:Pt,useEffect:Id,useImperativeHandle:function(e,t,l){return l=l!=null?l.concat([e]):null,qr(4194308,4,Hp.bind(null,t,e),l)},useLayoutEffect:function(e,t){return qr(4194308,4,e,t)},useInsertionEffect:function(e,t){return qr(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=im.bind(null,Te,e),[s.memoizedState,e]},useRef:function(e){var t=Ht();return e={current:e},t.memoizedState=e},useState:Pd,useDebugValue:ac,useDeferredValue:function(e){return Ht().memoizedState=e},useTransition:function(){var e=Pd(!1),t=e[0];return e=rm.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||Dp(s,t,l)}r.memoizedState=l;var i={value:l,getSnapshot:t};return r.queue=i,Id(Wp.bind(null,s,i,e),[e]),s.flags|=2048,nr(9,Np.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=er++,0<l&&(t+="H"+l.toString(32)),t+=":"}else l=sm++,t=":"+t+"r"+l.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},cm={readContext:Pt,useCallback:Qp,useContext:Pt,useEffect:ic,useImperativeHandle:Kp,useInsertionEffect:Fp,useLayoutEffect:Mp,useMemo:Gp,useReducer:ya,useRef:Up,useState:function(){return ya(tr)},useDebugValue:ac,useDeferredValue:function(e){var t=It();return Yp(t,Ke.memoizedState,e)},useTransition:function(){var e=ya(tr)[0],t=It().memoizedState;return[e,t]},useMutableSource:Lp,useSyncExternalStore:Op,useId:Xp,unstable_isNewReconciler:!1},dm={readContext:Pt,useCallback:Qp,useContext:Pt,useEffect:ic,useImperativeHandle:Kp,useInsertionEffect:Fp,useLayoutEffect:Mp,useMemo:Gp,useReducer:va,useRef:Up,useState:function(){return va(tr)},useDebugValue:ac,useDeferredValue:function(e){var t=It();return Ke===null?t.memoizedState=e:Yp(t,Ke.memoizedState,e)},useTransition:function(){var e=va(tr)[0],t=It().memoizedState;return[e,t]},useMutableSource:Lp,useSyncExternalStore:Op,useId:Xp,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 ao(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 Li={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),Yr(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),Yr(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),Yr(t,e,s))}};function Ed(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?!Ys(l,s)||!Ys(r,i):!0}function Vp(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=Li,e.stateNode=t,t._reactInternals=e,s&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=r,e.__reactInternalMemoizedMaskedChildContext=i),t}function Ad(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&&Li.enqueueReplaceState(t,t.state,null)}function oo(e,t,l,s){var r=e.stateNode;r.props=l,r.state=e.memoizedState,r.refs={},Vo(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"&&(ao(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&&Li.enqueueReplaceState(r,r.state,null),xi(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+=Wg(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 ja(e,t,l){return{value:e,source:null,stack:l??null,digest:t??null}}function co(e,t){try{console.error(t.value)}catch(l){setTimeout(function(){throw l})}}var um=typeof WeakMap=="function"?WeakMap:Map;function ef(e,t,l){l=an(-1,l),l.tag=3,l.payload={element:null};var s=t.value;return l.callback=function(){bi||(bi=!0,jo=s),co(e,t)},l}function tf(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(){co(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(l.callback=function(){co(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 Rd(e,t,l){var s=e.pingCache;if(s===null){s=e.pingCache=new um;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=_m.bind(null,e,t,l),t.then(e,e))}function Ld(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 Od(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 pm=pn.ReactCurrentOwner,ut=!1;function rt(e,t,l,s){t.child=e===null?Ip(t,null,l,s):Fl(t,e.child,l,s)}function Dd(e,t,l,s,r){l=l.render;var i=t.ref;return Nl(t,r),s=sc(e,t,l,s,i,r),l=rc(),e!==null&&!ut?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~r,un(e,t,r)):(ke&&l&&Qo(t),t.flags|=1,rt(e,t,s,r),t.child)}function Nd(e,t,l,s,r){if(e===null){var i=l.type;return typeof i=="function"&&!gc(i)&&i.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(t.tag=15,t.type=i,nf(e,t,i,s,r)):(e=ei(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:Ys,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 nf(e,t,l,s,r){if(e!==null){var i=e.memoizedProps;if(Ys(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 uo(e,t,l,s,r)}function lf(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 sf(e,t){var l=t.ref;(e===null&&l!==null||e!==null&&e.ref!==l)&&(t.flags|=512,t.flags|=2097152)}function uo(e,t,l,s,r){var i=ft(l)?Xn:st.current;return i=$l(t,i),Nl(t,r),l=sc(e,t,l,s,i,r),s=rc(),e!==null&&!ut?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~r,un(e,t,r)):(ke&&s&&Qo(t),t.flags|=1,rt(e,t,l,r),t.child)}function Wd(e,t,l,s,r){if(ft(l)){var i=!0;ui(t)}else i=!1;if(Nl(t,r),t.stateNode===null)Jr(e,t),Vp(t,l,s),oo(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)&&Ad(t,a,s,f),vn=!1;var c=t.memoizedState;a.state=c,xi(t,s,a,r),u=t.memoizedState,d!==s||c!==u||pt.current||vn?(typeof y=="function"&&(ao(t,l,y,s),u=t.memoizedState),(d=vn||Ed(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,Ap(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)&&Ad(t,a,s,u),vn=!1,c=t.memoizedState,a.state=c,xi(t,s,a,r);var S=t.memoizedState;d!==p||c!==S||pt.current||vn?(typeof v=="function"&&(ao(t,l,v,s),S=t.memoizedState),(f=vn||Ed(t,l,f,s,c,S,u)||!1)?(y||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(s,S,u),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(s,S,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=S),a.props=s,a.state=S,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 po(e,t,l,s,i,r)}function po(e,t,l,s,r,i){sf(e,t);var a=(t.flags&128)!==0;if(!s&&!a)return r&&wd(t,l,!1),un(e,t,i);s=t.stateNode,pm.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&&wd(t,l,!0),t.child}function rf(e){var t=e.stateNode;t.pendingContext?Sd(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Sd(e,t.context,!1),ec(e,t.containerInfo)}function Bd(e,t,l,s,r){return Ul(),Yo(r),t.flags|=256,rt(e,t,l,s),t.child}var fo={dehydrated:null,treeContext:null,retryLane:0};function ho(e){return{baseLanes:e,cachePool:null,transitions:null}}function af(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 ro(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=Ni(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=ho(l),t.memoizedState=fo,e):oc(t,a));if(r=e.memoizedState,r!==null&&(d=r.dehydrated,d!==null))return fm(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?ho(l):{baseLanes:a.baseLanes|l,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~l,t.memoizedState=fo,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 oc(e,t){return t=Ni({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Er(e,t,l,s){return s!==null&&Yo(s),Fl(t,e.child,null,l),e=oc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function fm(e,t,l,s,r,i,a){if(l)return t.flags&256?(t.flags&=-257,s=ja(Error(F(422))),Er(e,t,a,s)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=s.fallback,r=t.mode,s=Ni({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=ho(a),t.memoizedState=fo,i);if(!(t.mode&1))return Er(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=ja(i,s,void 0),Er(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 hc(),s=ja(Error(F(421))),Er(e,t,a,s)}return r.data==="$?"?(t.flags|=128,t.child=e.child,t=Cm.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=oc(t,s.children),t.flags|=4096,t)}function $d(e,t,l){e.lanes|=t;var s=e.alternate;s!==null&&(s.lanes|=t),io(e.return,t,l)}function ba(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 of(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&&$d(e,l,t);else if(e.tag===19)$d(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&&mi(e)===null&&(r=l),l=l.sibling;l=r,l===null?(r=t.child,t.child=null):(r=l.sibling,l.sibling=null),ba(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&&mi(e)===null){t.child=r;break}e=r.sibling,r.sibling=l,l=r,r=e}ba(t,!0,l,null,i);break;case"together":ba(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Jr(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 hm(e,t,l){switch(t.tag){case 3:rf(t),Ul();break;case 5:Rp(t);break;case 1:ft(t.type)&&ui(t);break;case 4:ec(t,t.stateNode.containerInfo);break;case 10:var s=t.type._context,r=t.memoizedProps.value;ve(hi,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?af(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 of(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,lf(e,t,l)}return un(e,t,l)}var cf,go,df,uf;cf=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}};go=function(){};df=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=Da(e,r),s=Da(e,s),i=[];break;case"select":r=Pe({},r,{value:void 0}),s=Pe({},s,{value:void 0}),i=[];break;case"textarea":r=Ba(e,r),s=Ba(e,s),i=[];break;default:typeof r.onClick!="function"&&typeof s.onClick=="function"&&(e.onclick=ci)}Ua(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"&&(Us.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"&&(Us.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)}};uf=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 gm(e,t,l){var s=t.pendingProps;switch(Go(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)&&di(),nt(t),null;case 3:return s=t.stateNode,Ml(),be(pt),be(st),nc(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(Pr(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Dt!==null&&(wo(Dt),Dt=null))),go(e,t),nt(t),null;case 5:tc(t);var r=Qn(Vs.current);if(l=t.type,e!==null&&t.stateNode!=null)df(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),Pr(t)){s=t.stateNode,l=t.type;var i=t.memoizedProps;switch(s[Kt]=t,s[Js]=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<Is.length;r++)je(Is[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":Xc(s,i),je("invalid",s);break;case"select":s._wrapperState={wasMultiple:!!i.multiple},je("invalid",s);break;case"textarea":Jc(s,i),je("invalid",s)}Ua(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&&Tr(s.textContent,d,e),r=["children",d]):typeof d=="number"&&s.textContent!==""+d&&(i.suppressHydrationWarning!==!0&&Tr(s.textContent,d,e),r=["children",""+d]):Us.hasOwnProperty(a)&&d!=null&&a==="onScroll"&&je("scroll",s)}switch(l){case"input":jr(s),qc(s,i,!0);break;case"textarea":jr(s),Zc(s);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(s.onclick=ci)}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=Wu(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[Js]=s,cf(e,t,!1,!1),t.stateNode=e;e:{switch(a=Fa(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<Is.length;r++)je(Is[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":Xc(e,s),r=Da(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":Jc(e,s),r=Ba(e,s),je("invalid",e);break;default:r=s}Ua(l,r),d=r;for(i in d)if(d.hasOwnProperty(i)){var u=d[i];i==="style"?Uu(e,u):i==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,u!=null&&Bu(e,u)):i==="children"?typeof u=="string"?(l!=="textarea"||u!=="")&&Fs(e,u):typeof u=="number"&&Fs(e,""+u):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Us.hasOwnProperty(i)?u!=null&&i==="onScroll"&&je("scroll",e):u!=null&&Ao(e,i,u,a))}switch(l){case"input":jr(e),qc(e,s,!1);break;case"textarea":jr(e),Zc(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=ci)}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)uf(e,t,e.memoizedProps,s);else{if(typeof s!="string"&&t.stateNode===null)throw Error(F(166));if(l=Qn(Vs.current),Qn(Gt.current),Pr(t)){if(s=t.stateNode,l=t.memoizedProps,s[Kt]=t,(i=s.nodeValue!==l)&&(e=jt,e!==null))switch(e.tag){case 3:Tr(s.nodeValue,l,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Tr(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))Tp(),Ul(),t.flags|=98560,i=!1;else if(i=Pr(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&&(wo(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):hc())),t.updateQueue!==null&&(t.flags|=4),nt(t),null);case 4:return Ml(),go(e,t),e===null&&Xs(t.stateNode.containerInfo),nt(t),null;case 10:return Jo(t.type._context),nt(t),null;case 17:return ft(t.type)&&di(),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=mi(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=mi(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 fc(),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 xm(e,t){switch(Go(t),t.tag){case 1:return ft(t.type)&&di(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ml(),be(pt),be(st),nc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return tc(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 Jo(t.type._context),null;case 22:case 23:return fc(),null;case 24:return null;default:return null}}var Ar=!1,lt=!1,mm=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 xo(e,t,l){try{l()}catch(s){Ie(e,t,s)}}var Ud=!1;function ym(e,t){if(Za=ii,e=gp(),Ko(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(Va={focusedElem:e,selectionRange:l},ii=!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 S=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(S!==null){var h=S.memoizedProps,j=S.memoizedState,x=t.stateNode,g=x.getSnapshotBeforeUpdate(t.elementType===t.type?h:Lt(t.type,h),j);x.__reactInternalSnapshotBeforeUpdate=g}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(m){Ie(t,t.return,m)}if(e=t.sibling,e!==null){e.return=t.return,Y=e;break}Y=t.return}return S=Ud,Ud=!1,S}function Ws(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&&xo(t,l,i)}r=r.next}while(r!==s)}}function Oi(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 mo(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 pf(e){var t=e.alternate;t!==null&&(e.alternate=null,pf(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Kt],delete t[Js],delete t[no],delete t[em],delete t[tm])),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 ff(e){return e.tag===5||e.tag===3||e.tag===4}function Fd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ff(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 yo(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=ci));else if(s!==4&&(e=e.child,e!==null))for(yo(e,t,l),e=e.sibling;e!==null;)yo(e,t,l),e=e.sibling}function vo(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(vo(e,t,l),e=e.sibling;e!==null;)vo(e,t,l),e=e.sibling}var Ze=null,Ot=!1;function xn(e,t,l){for(l=l.child;l!==null;)hf(e,t,l),l=l.sibling}function hf(e,t,l){if(Qt&&typeof Qt.onCommitFiberUnmount=="function")try{Qt.onCommitFiberUnmount(zi,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?ha(e.parentNode,l):e.nodeType===1&&ha(e,l),Qs(e)):ha(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)&&xo(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 Md(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var l=e.stateNode;l===null&&(l=e.stateNode=new mm),t.forEach(function(s){var r=zm.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));hf(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;)gf(t,e),t=t.sibling}function gf(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{Ws(3,e,e.return),Oi(3,e)}catch(h){Ie(e,e.return,h)}try{Ws(5,e,e.return)}catch(h){Ie(e,e.return,h)}}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{Fs(r,"")}catch(h){Ie(e,e.return,h)}}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&&Du(r,i),Fa(d,a);var f=Fa(d,i);for(a=0;a<u.length;a+=2){var y=u[a],p=u[a+1];y==="style"?Uu(r,p):y==="dangerouslySetInnerHTML"?Bu(r,p):y==="children"?Fs(r,p):Ao(r,y,p,f)}switch(d){case"input":Na(r,i);break;case"textarea":Nu(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[Js]=i}catch(h){Ie(e,e.return,h)}}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(h){Ie(e,e.return,h)}}break;case 3:if(Rt(t,e),Mt(e),s&4&&l!==null&&l.memoizedState.isDehydrated)try{Qs(t.containerInfo)}catch(h){Ie(e,e.return,h)}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||(uc=Le())),s&4&&Md(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:Ws(4,c,c.return);break;case 1:Il(c,c.return);var S=c.stateNode;if(typeof S.componentWillUnmount=="function"){s=c,l=c.return;try{t=s,S.props=t.memoizedProps,S.state=t.memoizedState,S.componentWillUnmount()}catch(h){Ie(s,l,h)}}break;case 5:Il(c,c.return);break;case 22:if(c.memoizedState!==null){Kd(p);continue}}v!==null?(v.return=c,Y=v):Kd(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=$u("display",a))}catch(h){Ie(e,e.return,h)}}}else if(p.tag===6){if(y===null)try{p.stateNode.nodeValue=f?"":p.memoizedProps}catch(h){Ie(e,e.return,h)}}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&&Md(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(ff(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&&(Fs(r,""),s.flags&=-33);var i=Fd(e);vo(e,i,r);break;case 3:case 4:var a=s.stateNode.containerInfo,d=Fd(e);yo(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 vm(e,t,l){Y=e,xf(e)}function xf(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||Ar;if(!a){var d=r.alternate,u=d!==null&&d.memoizedState!==null||lt;d=Ar;var f=lt;if(Ar=a,(lt=u)&&!f)for(Y=r;Y!==null;)a=Y,u=a.child,a.tag===22&&a.memoizedState!==null?Qd(r):u!==null?(u.return=a,Y=u):Qd(r);for(;i!==null;)Y=i,xf(i),i=i.sibling;Y=r,Ar=d,lt=f}Hd(e)}else r.subtreeFlags&8772&&i!==null?(i.return=r,Y=i):Hd(e)}}function Hd(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||Oi(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&&Td(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}Td(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&&Qs(p)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(F(163))}lt||t.flags&512&&mo(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 Kd(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 Qd(e){for(;Y!==null;){var t=Y;try{switch(t.tag){case 0:case 11:case 15:var l=t.return;try{Oi(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{mo(t)}catch(u){Ie(t,i,u)}break;case 5:var a=t.return;try{mo(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 jm=Math.ceil,ji=pn.ReactCurrentDispatcher,cc=pn.ReactCurrentOwner,Tt=pn.ReactCurrentBatchConfig,pe=0,qe=null,Be=null,Ve=0,yt=0,El=Nn(0),Qe=0,lr=null,Zn=0,Di=0,dc=0,Bs=null,dt=null,uc=0,Kl=1/0,nn=null,bi=!1,jo=null,In=null,Rr=!1,wn=null,Si=0,$s=0,bo=null,Zr=-1,Vr=0;function it(){return pe&6?Le():Zr!==-1?Zr:Zr=Le()}function En(e){return e.mode&1?pe&2&&Ve!==0?Ve&-Ve:lm.transition!==null?(Vr===0&&(Vr=Vu()),Vr):(e=he,e!==0||(e=window.event,e=e===void 0?16:ip(e.type)),e):1}function Bt(e,t,l,s){if(50<$s)throw $s=0,bo=null,Error(F(185));rr(e,l,s),(!(pe&2)||e!==qe)&&(e===qe&&(!(pe&2)&&(Di|=l),Qe===4&&bn(e,Ve)),ht(e,s),l===1&&pe===0&&!(t.mode&1)&&(Kl=Le()+500,Ai&&Wn()))}function ht(e,t){var l=e.callbackNode;lx(e,t);var s=ri(e,e===qe?Ve:0);if(s===0)l!==null&&td(l),e.callbackNode=null,e.callbackPriority=0;else if(t=s&-s,e.callbackPriority!==t){if(l!=null&&td(l),t===1)e.tag===0?nm(Gd.bind(null,e)):_p(Gd.bind(null,e)),Zx(function(){!(pe&6)&&Wn()}),l=null;else{switch(ep(s)){case 1:l=No;break;case 4:l=Ju;break;case 16:l=si;break;case 536870912:l=Zu;break;default:l=si}l=kf(l,mf.bind(null,e))}e.callbackPriority=t,e.callbackNode=l}}function mf(e,t){if(Zr=-1,Vr=0,pe&6)throw Error(F(327));var l=e.callbackNode;if(Wl()&&e.callbackNode!==l)return null;var s=ri(e,e===qe?Ve:0);if(s===0)return null;if(s&30||s&e.expiredLanes||t)t=wi(e,s);else{t=s;var r=pe;pe|=2;var i=vf();(qe!==e||Ve!==t)&&(nn=null,Kl=Le()+500,Gn(e,t));do try{wm();break}catch(d){yf(e,d)}while(!0);qo(),ji.current=i,pe=r,Be!==null?t=0:(qe=null,Ve=0,t=Qe)}if(t!==0){if(t===2&&(r=Ga(e),r!==0&&(s=r,t=So(e,r))),t===1)throw l=lr,Gn(e,0),bn(e,s),ht(e,Le()),l;if(t===6)bn(e,s);else{if(r=e.current.alternate,!(s&30)&&!bm(r)&&(t=wi(e,s),t===2&&(i=Ga(e),i!==0&&(s=i,t=So(e,i))),t===1))throw l=lr,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=uc+500-Le(),10<t)){if(ri(e,0)!==0)break;if(r=e.suspendedLanes,(r&s)!==s){it(),e.pingedLanes|=e.suspendedLanes&r;break}e.timeoutHandle=to(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*jm(s/1960))-s,10<s){e.timeoutHandle=to(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?mf.bind(null,e):null}function So(e,t){var l=Bs;return e.current.memoizedState.isDehydrated&&(Gn(e,t).flags|=256),e=wi(e,t),e!==2&&(t=dt,dt=l,t!==null&&wo(t)),e}function wo(e){dt===null?dt=e:dt.push.apply(dt,e)}function bm(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&=~dc,t&=~Di,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 Gd(e){if(pe&6)throw Error(F(327));Wl();var t=ri(e,0);if(!(t&1))return ht(e,Le()),null;var l=wi(e,t);if(e.tag!==0&&l===2){var s=Ga(e);s!==0&&(t=s,l=So(e,s))}if(l===1)throw l=lr,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 pc(e,t){var l=pe;pe|=1;try{return e(t)}finally{pe=l,pe===0&&(Kl=Le()+500,Ai&&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 fc(){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,Jx(l)),Be!==null)for(l=Be.return;l!==null;){var s=l;switch(Go(s),s.tag){case 1:s=s.type.childContextTypes,s!=null&&di();break;case 3:Ml(),be(pt),be(st),nc();break;case 5:tc(s);break;case 4:Ml();break;case 13:be(ze);break;case 19:be(ze);break;case 10:Jo(s.type._context);break;case 22:case 23:fc()}l=l.return}if(qe=e,Be=e=An(e.current,null),Ve=yt=t,Qe=0,lr=null,dc=Di=Zn=0,dt=Bs=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 yf(e,t){do{var l=Be;try{if(qo(),Xr.current=vi,yi){for(var s=Te.memoizedState;s!==null;){var r=s.queue;r!==null&&(r.pending=null),s=s.next}yi=!1}if(Jn=0,Xe=Ke=Te=null,Ns=!1,er=0,cc.current=null,l===null||l.return===null){Qe=1,lr=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=Ld(a);if(v!==null){v.flags&=-257,Od(v,a,d,i,t),v.mode&1&&Rd(i,f,t),t=v,u=f;var S=t.updateQueue;if(S===null){var h=new Set;h.add(u),t.updateQueue=h}else S.add(u);break e}else{if(!(t&1)){Rd(i,f,t),hc();break e}u=Error(F(426))}}else if(ke&&d.mode&1){var j=Ld(a);if(j!==null){!(j.flags&65536)&&(j.flags|=256),Od(j,a,d,i,t),Yo(Hl(u,d));break e}}i=u=Hl(u,d),Qe!==4&&(Qe=2),Bs===null?Bs=[i]:Bs.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var x=ef(i,u,t);zd(i,x);break e;case 1:d=u;var g=i.type,o=i.stateNode;if(!(i.flags&128)&&(typeof g.getDerivedStateFromError=="function"||o!==null&&typeof o.componentDidCatch=="function"&&(In===null||!In.has(o)))){i.flags|=65536,t&=-t,i.lanes|=t;var m=tf(i,d,t);zd(i,m);break e}}i=i.return}while(i!==null)}bf(l)}catch(C){t=C,Be===l&&l!==null&&(Be=l=l.return);continue}break}while(!0)}function vf(){var e=ji.current;return ji.current=vi,e===null?vi:e}function hc(){(Qe===0||Qe===3||Qe===2)&&(Qe=4),qe===null||!(Zn&268435455)&&!(Di&268435455)||bn(qe,Ve)}function wi(e,t){var l=pe;pe|=2;var s=vf();(qe!==e||Ve!==t)&&(nn=null,Gn(e,t));do try{Sm();break}catch(r){yf(e,r)}while(!0);if(qo(),pe=l,ji.current=s,Be!==null)throw Error(F(261));return qe=null,Ve=0,Qe}function Sm(){for(;Be!==null;)jf(Be)}function wm(){for(;Be!==null&&!Yg();)jf(Be)}function jf(e){var t=wf(e.alternate,e,yt);e.memoizedProps=e.pendingProps,t===null?bf(e):Be=t,cc.current=null}function bf(e){var t=e;do{var l=t.alternate;if(e=t.return,t.flags&32768){if(l=xm(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=gm(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,km(e,t,l,s)}finally{Tt.transition=r,he=s}return null}function km(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(sx(e,i),e===qe&&(Be=qe=null,Ve=0),!(l.subtreeFlags&2064)&&!(l.flags&2064)||Rr||(Rr=!0,kf(si,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,cc.current=null,ym(e,l),gf(l,e),Hx(Va),ii=!!Za,Va=Za=null,e.current=l,vm(l),Xg(),pe=d,he=a,Tt.transition=i}else e.current=l;if(Rr&&(Rr=!1,wn=e,Si=r),i=e.pendingLanes,i===0&&(In=null),Zg(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(bi)throw bi=!1,e=jo,jo=null,e;return Si&1&&e.tag!==0&&Wl(),i=e.pendingLanes,i&1?e===bo?$s++:($s=0,bo=e):$s=0,Wn(),null}function Wl(){if(wn!==null){var e=ep(Si),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,Si=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:Ws(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(pf(y),y===f){Y=null;break}if(c!==null){c.return=v,Y=c;break}Y=v}}}var S=i.alternate;if(S!==null){var h=S.child;if(h!==null){S.child=null;do{var j=h.sibling;h.sibling=null,h=j}while(h!==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:Ws(9,i,i.return)}var x=i.sibling;if(x!==null){x.return=i.return,Y=x;break e}Y=i.return}}var g=e.current;for(Y=g;Y!==null;){a=Y;var o=a.child;if(a.subtreeFlags&2064&&o!==null)o.return=a,Y=o;else e:for(a=g;Y!==null;){if(d=Y,d.flags&2048)try{switch(d.tag){case 0:case 11:case 15:Oi(9,d)}}catch(C){Ie(d,d.return,C)}if(d===a){Y=null;break e}var m=d.sibling;if(m!==null){m.return=d.return,Y=m;break e}Y=d.return}}if(pe=r,Wn(),Qt&&typeof Qt.onPostCommitFiberRoot=="function")try{Qt.onPostCommitFiberRoot(zi,e)}catch{}s=!0}return s}finally{he=l,Tt.transition=t}}return!1}function Yd(e,t,l){t=Hl(l,t),t=ef(e,t,1),e=Pn(e,t,1),t=it(),e!==null&&(rr(e,1,t),ht(e,t))}function Ie(e,t,l){if(e.tag===3)Yd(e,e,l);else for(;t!==null;){if(t.tag===3){Yd(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=tf(t,e,1),t=Pn(t,e,1),e=it(),t!==null&&(rr(t,1,e),ht(t,e));break}}t=t.return}}function _m(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()-uc?Gn(e,0):dc|=l),ht(e,t)}function Sf(e,t){t===0&&(e.mode&1?(t=wr,wr<<=1,!(wr&130023424)&&(wr=4194304)):t=1);var l=it();e=dn(e,t),e!==null&&(rr(e,t,l),ht(e,l))}function Cm(e){var t=e.memoizedState,l=0;t!==null&&(l=t.retryLane),Sf(e,l)}function zm(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),Sf(e,l)}var wf;wf=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,hm(e,t,l);ut=!!(e.flags&131072)}else ut=!1,ke&&t.flags&1048576&&Cp(t,fi,t.index);switch(t.lanes=0,t.tag){case 2:var s=t.type;Jr(e,t),e=t.pendingProps;var r=$l(t,st.current);Nl(t,l),r=sc(null,t,s,e,r,l);var i=rc();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,ui(t)):i=!1,t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,Vo(t),r.updater=Li,t.stateNode=r,r._reactInternals=t,oo(t,s,e,l),t=po(null,t,s,!0,i,l)):(t.tag=0,ke&&i&&Qo(t),rt(null,t,r,l),t=t.child),t;case 16:s=t.elementType;e:{switch(Jr(e,t),e=t.pendingProps,r=s._init,s=r(s._payload),t.type=s,r=t.tag=Pm(s),e=Lt(s,e),r){case 0:t=uo(null,t,s,e,l);break e;case 1:t=Wd(null,t,s,e,l);break e;case 11:t=Dd(null,t,s,e,l);break e;case 14:t=Nd(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),uo(e,t,s,r,l);case 1:return s=t.type,r=t.pendingProps,r=t.elementType===s?r:Lt(s,r),Wd(e,t,s,r,l);case 3:e:{if(rf(t),e===null)throw Error(F(387));s=t.pendingProps,i=t.memoizedState,r=i.element,Ap(e,t),xi(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=Bd(e,t,s,l,r);break e}else if(s!==r){r=Hl(Error(F(424)),t),t=Bd(e,t,s,l,r);break e}else for(vt=Tn(t.stateNode.containerInfo.firstChild),jt=t,ke=!0,Dt=null,l=Ip(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 Rp(t),e===null&&ro(t),s=t.type,r=t.pendingProps,i=e!==null?e.memoizedProps:null,a=r.children,eo(s,r)?a=null:i!==null&&eo(s,i)&&(t.flags|=32),sf(e,t),rt(e,t,a,l),t.child;case 6:return e===null&&ro(t),null;case 13:return af(e,t,l);case 4:return ec(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),Dd(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(hi,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),io(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),io(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),Nd(e,t,s,r,l);case 15:return nf(e,t,t.type,t.pendingProps,l);case 17:return s=t.type,r=t.pendingProps,r=t.elementType===s?r:Lt(s,r),Jr(e,t),t.tag=1,ft(s)?(e=!0,ui(t)):e=!1,Nl(t,l),Vp(t,s,r),oo(t,s,r,l),po(null,t,s,!0,e,l);case 19:return of(e,t,l);case 22:return lf(e,t,l)}throw Error(F(156,t.tag))};function kf(e,t){return qu(e,t)}function Tm(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 Tm(e,t,l,s)}function gc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Pm(e){if(typeof e=="function")return gc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Lo)return 11;if(e===Oo)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 ei(e,t,l,s,r,i){var a=2;if(s=e,typeof e=="function")gc(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case bl:return Yn(l.children,r,i,t);case Ro:a=8,r|=8;break;case Aa:return e=zt(12,l,t,r|2),e.elementType=Aa,e.lanes=i,e;case Ra:return e=zt(13,l,t,r),e.elementType=Ra,e.lanes=i,e;case La:return e=zt(19,l,t,r),e.elementType=La,e.lanes=i,e;case Ru:return Ni(l,r,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Eu:a=10;break e;case Au:a=9;break e;case Lo:a=11;break e;case Oo: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 Ni(e,t,l,s){return e=zt(22,e,s,t),e.elementType=Ru,e.lanes=l,e.stateNode={isHidden:!1},e}function Sa(e,t,l){return e=zt(6,e,null,t),e.lanes=l,e}function wa(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 Im(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=la(0),this.expirationTimes=la(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=la(0),this.identifierPrefix=s,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function xc(e,t,l,s,r,i,a,d,u){return e=new Im(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},Vo(i),e}function Em(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 _f(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 kp(e,l,t)}return t}function Cf(e,t,l,s,r,i,a,d,u){return e=xc(l,s,!0,e,r,i,a,d,u),e.context=_f(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,rr(e,r,s),ht(e,s),e}function Wi(e,t,l,s){var r=t.current,i=it(),a=En(r);return l=_f(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),Yr(e,r,a)),a}function ki(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 Xd(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<t?l:t}}function mc(e,t){Xd(e,t),(e=e.alternate)&&Xd(e,t)}function Am(){return null}var zf=typeof reportError=="function"?reportError:function(e){console.error(e)};function yc(e){this._internalRoot=e}Bi.prototype.render=yc.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(F(409));Wi(e,t,null,null)};Bi.prototype.unmount=yc.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Vn(function(){Wi(null,e,null,null)}),t[cn]=null}};function Bi(e){this._internalRoot=e}Bi.prototype.unstable_scheduleHydration=function(e){if(e){var t=lp();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&&rp(e)}};function vc(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function $i(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function qd(){}function Rm(e,t,l,s,r){if(r){if(typeof s=="function"){var i=s;s=function(){var f=ki(a);i.call(f)}}var a=Cf(t,s,e,0,null,!1,!1,"",qd);return e._reactRootContainer=a,e[cn]=a.current,Xs(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=ki(u);d.call(f)}}var u=xc(e,0,!1,null,null,!1,!1,"",qd);return e._reactRootContainer=u,e[cn]=u.current,Xs(e.nodeType===8?e.parentNode:e),Vn(function(){Wi(t,u,l,s)}),u}function Ui(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=ki(a);d.call(u)}}Wi(t,a,e,r)}else a=Rm(l,t,e,r,s);return ki(a)}tp=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var l=Ps(t.pendingLanes);l!==0&&(Wo(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)}}),mc(e,1)}};Bo=function(e){if(e.tag===13){var t=dn(e,134217728);if(t!==null){var l=it();Bt(t,e,134217728,l)}mc(e,134217728)}};np=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)}mc(e,t)}};lp=function(){return he};sp=function(e,t){var l=he;try{return he=e,t()}finally{he=l}};Ha=function(e,t,l){switch(t){case"input":if(Na(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=Ei(s);if(!r)throw Error(F(90));Ou(s),Na(s,r)}}}break;case"textarea":Nu(e,l);break;case"select":t=l.value,t!=null&&Rl(e,!!l.multiple,t,!1)}};Hu=pc;Ku=Vn;var Lm={usingClientEntryPoint:!1,Events:[ar,_l,Ei,Fu,Mu,pc]},hs={findFiberByHostInstance:Hn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Om={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=Yu(e),e===null?null:e.stateNode},findFiberByHostInstance:hs.findFiberByHostInstance||Am,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 Lr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Lr.isDisabled&&Lr.supportsFiber)try{zi=Lr.inject(Om),Qt=Lr}catch{}}St.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Lm;St.createPortal=function(e,t){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!vc(t))throw Error(F(200));return Em(e,t,null,l)};St.createRoot=function(e,t){if(!vc(e))throw Error(F(299));var l=!1,s="",r=zf;return t!=null&&(t.unstable_strictMode===!0&&(l=!0),t.identifierPrefix!==void 0&&(s=t.identifierPrefix),t.onRecoverableError!==void 0&&(r=t.onRecoverableError)),t=xc(e,1,!1,null,null,l,!1,s,r),e[cn]=t.current,Xs(e.nodeType===8?e.parentNode:e),new yc(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=Yu(t),e=e===null?null:e.stateNode,e};St.flushSync=function(e){return Vn(e)};St.hydrate=function(e,t,l){if(!$i(t))throw Error(F(200));return Ui(null,e,t,!0,l)};St.hydrateRoot=function(e,t,l){if(!vc(e))throw Error(F(405));var s=l!=null&&l.hydratedSources||null,r=!1,i="",a=zf;if(l!=null&&(l.unstable_strictMode===!0&&(r=!0),l.identifierPrefix!==void 0&&(i=l.identifierPrefix),l.onRecoverableError!==void 0&&(a=l.onRecoverableError)),t=Cf(t,null,e,1,l??null,r,!1,i,a),e[cn]=t.current,Xs(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 Bi(t)};St.render=function(e,t,l){if(!$i(t))throw Error(F(200));return Ui(null,e,t,!1,l)};St.unmountComponentAtNode=function(e){if(!$i(e))throw Error(F(40));return e._reactRootContainer?(Vn(function(){Ui(null,null,e,!1,function(){e._reactRootContainer=null,e[cn]=null})}),!0):!1};St.unstable_batchedUpdates=pc;St.unstable_renderSubtreeIntoContainer=function(e,t,l,s){if(!$i(l))throw Error(F(200));if(e==null||e._reactInternals===void 0)throw Error(F(38));return Ui(e,t,l,!1,s)};St.version="18.3.1-next-f1338f8080-20240426";function Tf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Tf)}catch(e){console.error(e)}}Tf(),zu.exports=St;var Dm=zu.exports,Pf,Jd=Dm;Pf=Jd.createRoot,Jd.hydrateRoot;const ce="",B={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"},$={bg:"#f5f6fa",accent:"#4f46e5",red:"#ef4444",orange:"#f59e0b",green:"#16a34a",purple:"#7c3aed",blue:"#2563eb",teal:"#0d9488",gray:"#94a3b8"},Nm=[{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"}],Wm=[{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"}],Bm=new Set(["users"]);function $m(e){return e!=="Admin"&&e!=="Auditor"?[]:Wm.filter(({id:t})=>e==="Admin"||!Bm.has(t))}const mn=(e=[])=>[{key:"name1",label:"Name"},{key:"status",label:"Status"},...e,{key:"creation_date",label:"Created On"}],Um={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"]}},Fm="modulepreload",Mm=function(e){return"/"+e},Zd={},Hm=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=Mm(u),u in Zd)return;Zd[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":Fm,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 If(e,t){const l=e[t.key];return l==null||l===""?"":typeof l=="object"?JSON.stringify(l):String(l)}function Km(e,t){const l=URL.createObjectURL(e),s=document.createElement("a");s.href=l,s.download=t,s.click(),URL.revokeObjectURL(l)}function Qm(e,t,l){const s=e.map(a=>`"${a.label.replace(/"/g,'""')}"`).join(","),r=t.map(a=>e.map(d=>`"${If(a,d).replace(/"/g,'""')}"`).join(",")).join(`
|
||
`),i=new Blob([s+`
|
||
`+r],{type:"text/csv;charset=utf-8;"});Km(i,`${l}.csv`)}async function Gm(e,t,l){const s=await Hm(()=>import("./xlsx-D_0l8YDs.js"),[]),r=t.map(d=>{const u={};for(const f of e)u[f.label]=If(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 Or="#16a34a";function Ym({title:e,rows:t,columns:l,defaultColumnKeys:s,orgField:r,organizations:i,filenameBase:a,onClose:d}){const[u,f]=b.useState(""),[y,p]=b.useState("csv"),[c,v]=b.useState(new Set(s)),S=u?t.filter(m=>m[r||"organization"]===u):t,h=l.filter(m=>c.has(m.key)),j=m=>{v(C=>{const A=new Set(C);return A.has(m)?A.delete(m):A.add(m),A})},x=async()=>{h.length===0||S.length===0||(y==="csv"?Qm(h,S,a):await Gm(h,S,a),d())},g={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:m=>m.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:Or,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:g,children:"Filter by Organization"}),n.jsxs("select",{value:u,onChange:m=>f(m.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(m=>n.jsx("option",{value:m.name,children:m.organization_name||m.name},m.name))]})]}),n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:g,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(m=>n.jsxs("div",{onClick:()=>p(m.id),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",borderRadius:10,cursor:"pointer",border:`2px solid ${y===m.id?Or:"#e5e7eb"}`,background:y===m.id?"#f0fdf4":"white"},children:[n.jsx("span",{style:{fontSize:20},children:m.id==="csv"?"📄":"📊"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:m.label}),n.jsx("div",{style:{fontSize:11,color:"#888"},children:m.desc})]})]},m.id))})]}),n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[n.jsx("div",{style:{...g,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(m=>m.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(m=>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(m.key),onChange:()=>j(m.key),style:{accentColor:Or,cursor:"pointer"}}),m.label]},m.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 ${S.length} filtered row${S.length!==1?"s":""}`:`Exporting all ${S.length} row${S.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:x,disabled:h.length===0||S.length===0,style:{padding:"9px 20px",borderRadius:8,border:"none",background:Or,color:"white",fontWeight:700,fontSize:13,cursor:h.length===0||S.length===0?"not-allowed":"pointer",opacity:h.length===0||S.length===0?.5:1,fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"})]})]})]})})}function Ef({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?[]:$m(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:[Nm.filter(({id:v})=>(v!=="dashboard"||r)&&(v!=="reports"||i)&&(v!=="delegations"||a)).map(({id:v,icon:S})=>{const h=y[v]||v,j=v===l;return n.jsxs("div",{onClick:()=>s(v),title:e?h:void 0,style:{padding:e?"8px 0":"8px 14px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:9,background:j?"rgba(139,92,246,0.28)":"transparent",borderRadius:8,fontSize:e?15:12,color:"white",fontWeight:j?600:400,transition:"all 0.15s",whiteSpace:"nowrap",marginBottom:2},children:[n.jsx("span",{style:{flexShrink:0},children:S}),!e&&h]},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:S})=>{const h=y[v]||v,j=v===l;return n.jsxs("div",{onClick:()=>s(v),title:e?h:void 0,style:{padding:e?"8px 0":"8px 14px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:9,background:j?"rgba(139,92,246,0.25)":"transparent",borderRadius:8,fontSize:e?15:12,color:"white",fontWeight:j?600:400,transition:"all 0.15s",whiteSpace:"nowrap",marginBottom:2},children:[n.jsx("span",{style:{flexShrink:0},children:S}),!e&&h]},v)})]})]})]})}const Af="sidrah_rtl",ko="sidrah-lang-change";function Al(){try{return localStorage.getItem(Af)==="1"}catch{return!1}}function Rf(){const e=!Al();try{localStorage.setItem(Af,e?"1":"0")}catch{}document.documentElement.setAttribute("dir",e?"rtl":"ltr"),document.documentElement.setAttribute("lang",e?"ar":"en-GB"),window.dispatchEvent(new CustomEvent(ko))}function V(){const[e,t]=b.useState(Al);return b.useEffect(()=>{const l=()=>t(Al());return window.addEventListener(ko,l),document.documentElement.setAttribute("dir",Al()?"rtl":"ltr"),document.documentElement.setAttribute("lang",Al()?"ar":"en-GB"),()=>window.removeEventListener(ko,l)},[]),e?qm:Xm}const Xm={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"}},qm={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:"بواسطة"}},cr=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 jc(){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 jc(),el}function Vd(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(cr.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 Lf(e,t){const l=await fn();if(cr.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(Vd(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(Vd(r,`Error deleting ${t}`))}return await s.json()}async function we(e){if(cr.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 ka(e,t){const l=await fn();if(cr.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 _i(e,t,l){const s=await fn();if(cr.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 Jm(){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 Zm(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 jc(),r}async function Vm(){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 ey(){return el}async function Of(){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 ty(){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 ny(){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 Df(e,t){await _i("User",e,{new_password:t})}async function ly(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 sy(){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 ry(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 iy(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 ay(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 oy(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 cy(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 Nf(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 dy(){try{const e=`${ce}/api/method/sidrah_business.api.get_my_organization`,t=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return t.ok&&(await t.json()).message||""}catch{return""}}async function 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 uy(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 py(e,t,l=""){return ll("apply_incident_workflow",{name:e,action:t,fields_json:l})}async function fy(e,t,l=""){return ll("apply_idea_workflow",{name:e,action:t,fields_json:l})}async function hy(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 gy(e,t={}){return ll("get_report_data",{report_name:e,filters_json:JSON.stringify(t)})}async function xy(){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 my(e,t,l="",s=""){return ll("create_delegation",{manager:e,functions_json:JSON.stringify(t),organization:l,remarks:s})}async function yy(e,t,l=""){return ll("respond_to_delegation",{name:e,response:t,remarks:l})}async function vy(e,t=""){return ll("revoke_delegation",{name:e,remarks:t})}async function jy(){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 by(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 Sy(){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 wy(){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 ky(){const e=ey();return e||jc()}async function Es(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 _y(e,t,l={}){const s=await ky(),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 Cy({onLogin:e}){const t=V(),[l,s]=b.useState(""),[r,i]=b.useState(""),[a,d]=b.useState(""),[u,f]=b.useState(!1),[y,p]=b.useState(!1),[c,v]=b.useState(!1),S=async()=>{if(!l||!r){d(t.login.emptyFields);return}f(!0),d("");try{const j=await Zm(l,r);if(j.message==="Logged In"){const g=await Of()||l,o=await Nf(g),m=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:g,full_name:j.full_name||l,role:m})}else d(t.login.invalidCreds)}catch(j){d(t.login.connError+(j instanceof Error?j.message:"Unknown"))}f(!1)},h=j=>({width:"100%",padding:"13px 16px",border:`1.5px solid ${j?"#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:j?"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:j=>s(j.target.value),onKeyDown:j=>j.key==="Enter"&&S(),onFocus:()=>p(!0),onBlur:()=>p(!1),style:h(y),placeholder:t.login.usernamePlaceholder,autoComplete:"username"}),n.jsx("input",{type:"password",value:r,onChange:j=>i(j.target.value),onKeyDown:j=>j.key==="Enter"&&S(),onFocus:()=>v(!0),onBlur:()=>v(!1),style:h(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:S,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:j=>{u||(j.currentTarget.style.background="#4338ca")},onMouseLeave:j=>{u||(j.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:Rf,style:{fontSize:12,color:"#9ca3af",background:"none",border:"none",cursor:"pointer"},children:t.switchLang})})]})})}function zy(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 Dr({title:e,data:t,color:l,onSelect:s}){const[,r]=t[0]??["Total",0,""],i=t.slice(1),a=i.map((u,f)=>zy(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",{style:{background:"white",borderRadius:12,padding:"14px 16px",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderTop:`3px solid ${l}`,height:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10,paddingBottom:10,borderBottom:"1px solid #f1f5f9"},children:[n.jsx("span",{style:{fontSize:13,fontWeight:700,color:"#1e293b"},children:e}),n.jsx("span",{style:{fontSize:20,fontWeight:800,color:l},children:r})]}),r>0&&n.jsx("div",{style:{display:"flex",height:10,borderRadius:5,overflow:"hidden",background:"#f1f5f9",marginBottom:12},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:4},children:i.map(([u,f,y],p)=>n.jsxs("div",{onClick:f>0?c=>{c.stopPropagation(),s==null||s(y)}:void 0,style:{display:"flex",alignItems:"center",gap:8,padding:"2px 4px",borderRadius:4,cursor:f>0&&s?"pointer":"default",transition:"background 0.12s"},onMouseEnter:c=>{f>0&&s&&(c.currentTarget.style.background="#f8fafc")},onMouseLeave:c=>{c.currentTarget.style.background="transparent"},children:[n.jsx("span",{style:{width:8,height:8,borderRadius:2,background:a[p],flexShrink:0}}),n.jsx("span",{style:{flex:1,fontSize:12,color:"#64748b",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#334155",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]=b.useState(!1),u=b.useRef(null);b.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(eu,{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(eu,{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 eu({label:e,selected:t,active:l,isPlaceholder:s,small:r,onClick:i}){const[a,d]=b.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 Ty({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 Py({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 Iy({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)||[],S=(e==null?void 0:e.attention_processes)||[],h=(e==null?void 0:e.attention_orders)||[],j=(e==null?void 0:e.untriaged_incidents)||[],x=(e==null?void 0:e.overdue_triage)||[],g=c.length>0||v.length>0,o=S.length>0||h.length>0,m=[["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])],P=[["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(Dr,{title:p.dash.incidents,color:$.orange,data:m,onSelect:w=>y("incidents",w)})}),n.jsx("div",{onClick:()=>f("ideas"),style:{cursor:"pointer"},children:n.jsx(Dr,{title:p.dash.ideas,color:$.blue,data:C,onSelect:w=>y("ideas",w)})}),n.jsx("div",{onClick:()=>f("orders"),style:{cursor:"pointer"},children:n.jsx(Dr,{title:p.dash.orders,color:$.purple,data:A,onSelect:w=>y("orders",w)})}),n.jsx("div",{onClick:()=>f("processes"),style:{cursor:"pointer"},children:n.jsx(Dr,{title:p.dash.processes,color:$.red,data:P,onSelect:w=>y("processes",w)})})]}),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.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:S,type:"process",onNavigate:f}),n.jsx(kn,{items:h,type:"order",onNavigate:f})]})]}),x.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,x.length,p.dash.overdueSuffix]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:x.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))})]}),j.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:$.orange,marginBottom:8},children:[p.dash.untriaged," (",j.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:j.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 Ey({dashData:e,selectedOrg:t,onNavigate:l}){const s=V(),[r,i]=b.useState([]),[a,d]=b.useState([]),[u,f]=b.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)||[],S=(e==null?void 0:e.kpi_inputs)||[];b.useEffect(()=>{f(!0);const x=new URLSearchParams({months:"6"});t&&x.append("organization",t),fetch(`/api/method/sidrah_business.api.get_process_trend?${x}`,{credentials:"include",headers:{Accept:"application/json"}}).then(g=>g.json()).then(g=>{const o=g.message||[],m={};for(const C of o)m[C.month]||(m[C.month]={pass:0,fail:0,unknown:0}),C.status==="Pass"?m[C.month].pass=C.count:C.status==="Fail"?m[C.month].fail=C.count:C.status==="Unknown"&&(m[C.month].unknown=C.count);i(Object.entries(m).map(([C,A])=>({month:C,...A})))}).catch(()=>{}).finally(()=>f(!1))},[t]),b.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(x=>x.json()).then(x=>{var g;d((((g=x.message)==null?void 0:g.rows)||[]).slice(0,50))}).catch(()=>{})},[t]);const h=y.length>0||p.length>0,j=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")})]}),S.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:S.map(x=>n.jsx(Ty,{kpi:x},x.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})]}),h&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #e74c3c"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:10},children:["Critical Escalations — Level 2 (",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})]})]}),j&&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(Py,{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(x=>n.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#999",fontWeight:700,fontSize:11,whiteSpace:"nowrap"},children:x},x))})}),n.jsx("tbody",{children:a.map((x,g)=>n.jsxs("tr",{style:{borderTop:"1px solid #f0f0f0",background:g%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"8px 12px",color:"#555",whiteSpace:"nowrap"},children:x.timestamp?String(x.timestamp).slice(0,16):"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#333"},children:x.user||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#555"},children:x.entity_type||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#555"},children:x.entity_name||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#888",maxWidth:240,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.changes||"—"})]},g))})]})}),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 Ay({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[S,h]=b.useState(null);b.useEffect(()=>{hy(f).then(h)},[f]);const j=f?e.filter(_=>_.organization===f):e,x=f?t.filter(_=>_.organization===f):t,g=f?l.filter(_=>_.organization===f):l,o=f?s.filter(_=>_.organization===f):s,m=v==="Admin",C=v==="Owner",[A,P]=b.useState("level2"),w=C||m&&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})}),m&&n.jsx("div",{style:{display:"flex",background:"#f1f0fe",borderRadius:7,padding:2,gap:2,flexShrink:0},children:["level1","level2"].map(_=>n.jsx("button",{onClick:()=>P(_),style:{padding:"4px 10px",borderRadius:5,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:A===_?_==="level2"?$.purple:$.blue:"transparent",color:A===_?"white":"#6b7280",transition:"all 0.15s"},children:_==="level1"?"Level 1":"Level 2"},_))}),!m&&n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"white",background:w?$.purple:$.blue,padding:"3px 10px",borderRadius:20,flexShrink:0},children:w?"Level 2 — Owner":"Level 1 — Operational"})]}),w?n.jsx(Ey,{dashData:S,selectedOrg:f,onNavigate:p}):n.jsx(Iy,{dashData:S,fi:j,fid:x,fo:g,fp:o,incidentStatuses:i,ideaStatuses:a,orderStatuses:d,processStatuses:u,onNavigate:p,onNavigateStatus:c})]})}const Ry=()=>n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Ly=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),Oy=()=>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]=b.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(Ry,{}),"View"),i("#dcfce7","#16a34a",t,n.jsx(Ly,{}),"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(Oy,{})})]})}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 Dy(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=>Dy(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}),Fi=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 Mi({children:e}){const[t,l]=b.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,tu=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:tu(e<=1),children:"Previous"}),n.jsx("button",{disabled:e>=r,onClick:()=>s(e+1),style:tu(e>=r),children:"Next"})]})]})}function Ny({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]=b.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),S=(o,m)=>v(C=>({...C,[o]:m})),[h,j]=b.useState(1),x=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));b.useEffect(()=>{j(1)},[c]);const g=x.slice((h-1)*ne,h*ne);return n.jsxs(n.Fragment,{children:[n.jsx(Mi,{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=>S("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=>S("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=>S("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=>S("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=>S("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:x.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:p.noIncidents})}):g.map((o,m)=>n.jsxs("tr",{onClick:()=>u==null?void 0:u(o),style:{borderTop:"1px solid #f0f0f0",background:m%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,Fi(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:h,total:x.length,onPageChange:j})]})}function Wy(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:Wy(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 By({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 nu={"SB Process":"processes-form","SB Order":"orders-form","SB Incident":"incidents-form","SB Idea":"ideas-form","SB Delegation":"delegations"};function $y(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 Wf({notifCount:e,darkMode:t,onCountChange:l,onToggleDark:s,onViewProfile:r,onLogout:i,onNavigate:a}){const[d,u]=b.useState(!1),[f,y]=b.useState([]),[p,c]=b.useState(!1),v=b.useRef(null);b.useEffect(()=>{const w=_=>{v.current&&!v.current.contains(_.target)&&u(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]);const S=async()=>{c(!0);const w=await ly(30);y(w),c(!1)},h=()=>{const w=!d;u(w),w&&S()},j=async()=>{await sy(),y(w=>w.map(_=>({..._,read:1}))),l(0)},x=w=>{w.read||(ry(w.name),y(U=>U.map(T=>T.name===w.name?{...T,read:1}:T)),l(Math.max(0,e-1)));const _=w.document_type?nu[w.document_type]:void 0;_&&a&&(a(_,w.document_type==="SB Delegation"?void 0:w.document_name),u(!1))},g=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}),m=t,C=m?"#1a202c":"white",A=m?"#2d3748":"#e5e7eb",P=m?"#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:h,title:"Notifications",children:[n.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),n.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),e>0&&n.jsx("span",{style:{position:"absolute",top:2,right:2,background:"#ef4444",color:"white",fontSize:9,fontWeight:700,borderRadius:999,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 3px",lineHeight:1},children:e>9?"9+":e})]}),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:P},children:["Notifications",g>0&&n.jsxs("span",{style:{background:"#ef4444",color:"white",fontSize:10,fontWeight:700,borderRadius:999,padding:"2px 7px"},children:[g," new"]})]}),g>0&&n.jsx("button",{onClick:j,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&&nu[w.document_type]&&a);return n.jsxs("div",{onClick:()=>x(w),style:{padding:"11px 16px",borderBottom:`1px solid ${m?"#2d3748":"#f5f5f5"}`,display:"flex",gap:10,background:w.read?C:m?"#1e3a5f":"#eff6ff",cursor:_?"pointer":"default",transition:"background 0.12s"},onMouseEnter:U=>{_&&(U.currentTarget.style.background=m?"#243244":"#e0ecfd")},onMouseLeave:U=>{U.currentTarget.style.background=w.read?C:m?"#1e3a5f":"#eff6ff"},children:[n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:13,fontWeight:w.read?400:600,color:P,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:m?"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:$y(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:Rf,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:m?"#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:S,onSubmit:h,onBack:j,onNavigate:x,onLogout:g,children:o}){const m=V(),C=m.nav[t]||t,A=l.role,P=A==="Admin"||A==="Owner"||A==="Auditor"||A==="Manager",w=A==="Admin"||A==="Owner"||A==="Auditor"||A==="Manager",_=A==="Admin"||A==="Auditor"||A==="Manager",U=P?"dashboard":"inbox",[T,I]=b.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:$.bg},children:[n.jsx(Ef,{collapsed:T,onToggleCollapsed:N,activePage:t,onNavigate:x,hasDashboard:P,hasReports:w,hasDelegations:_,role:A,hideSettings:u,rtl:m.rtl,navLabels:m.nav,settingsLabel:m.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:j,title:m.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:()=>x(U),style:{cursor:"pointer",color:"#4f46e5"},onMouseEnter:M=>M.currentTarget.style.textDecoration="underline",onMouseLeave:M=>M.currentTarget.style.textDecoration="none",children:m.home}),!u&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{margin:"0 4px"},children:"/"}),n.jsx("span",{onClick:j,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"})]}),m.edit]}),n.jsx(Wf,{notifCount:p,darkMode:y,onCountChange:v,onToggleDark:c,onNavigate:x,onViewProfile:S,onLogout:g})]})]}),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(By,{children:[o,!a&&n.jsxs("div",{style:{display:"flex",gap:10,marginTop:20},children:[n.jsx("button",{onClick:j,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:m.cancel}),n.jsx("button",{onClick:h,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"?m.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:m.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]=b.useState(!1),[d,u]=b.useState(""),f=b.useRef(null);b.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 Uy(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 Fy(e){return e.replace(/@.*/,"").replace(/[._-]/g," ").split(" ").filter(Boolean).slice(0,2).map(l=>l[0].toUpperCase()).join("")}function Hi({doctype:e,docname:t,currentUserName:l}){const s=V(),[r,i]=b.useState([]),[a,d]=b.useState(!1),[u,f]=b.useState(""),[y,p]=b.useState(!1),[c,v]=b.useState(!1),[S,h]=b.useState(!1),[j,x]=b.useState(""),g=5,o=b.useCallback(async()=>{d(!0);const w=await ay(e,t);i(w),d(!1)},[e,t]);b.useEffect(()=>{o()},[o]);const m=async()=>{const w=u.trim();if(!(!w||y)){p(!0),x("");try{await oy(e,t,w),f(""),await o()}catch{x("Failed to post comment. Please try again.")}p(!1)}},C=async w=>{if(window.confirm("Delete this comment?"))try{await Lf("Comment",w),i(_=>_.filter(U=>U.name!==w))}catch{alert("Failed to delete comment.")}},A=S?r:r.slice(-g),P=Math.max(0,r.length-g);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:[!S&&P>0&&n.jsxs("button",{onClick:()=>h(!0),style:{width:"100%",padding:"8px",marginBottom:12,border:"none",background:"#f8f9fa",borderRadius:6,cursor:"pointer",fontSize:12,color:"#3498db",fontFamily:"Segoe UI"},children:["Show ",P," older comment",P!==1?"s":""]}),a&&n.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:s.loading}),!a&&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:Fy(_)}),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:Uy(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)&&m()},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"}}),j&&n.jsx("div",{style:{fontSize:12,color:"#e74c3c",marginTop:4},children:j}),n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:n.jsx("button",{onClick:m,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 lu(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 My(e){return(e||"").replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function su(e){return e==null||e===""?"(empty)":typeof e=="object"?JSON.stringify(e):String(e)}function _o(e){return(e||"Unknown").replace(/@.*/,"").replace(/[._]/g," ")}function ru(e){return _o(e).split(" ").filter(Boolean).slice(0,2).map(t=>t[0].toUpperCase()).join("")}function Hy(e){let t={};try{t=JSON.parse(e.data||"{}")}catch{}const l=(t.changed||[]).map(s=>({field:s[0]||"",oldVal:su(s[1]),newVal:su(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 Ki({doctype:e,docname:t,docCreation:l,docOwner:s}){const r=V(),[i,a]=b.useState([]),[d,u]=b.useState(!1),[f,y]=b.useState(!0),[p,c]=b.useState(!1),v=5,S=b.useCallback(async()=>{u(!0);const g=await cy(e,t);a(g.map(Hy)),u(!1)},[e,t]);b.useEffect(()=>{f||S()},[f,S]);const h=p?i:i.slice(0,v),j=i.length-v,x=(g,o=!1)=>({position:"absolute",left:-14,top:14,width:10,height:10,borderRadius:"50%",background:g,border:"2px solid white",boxShadow:o?`0 0 0 2px ${g}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(g=>!g),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:g=>{g.stopPropagation(),S()},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:[h.map((g,o)=>n.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[n.jsx("div",{style:x(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:ru(g.owner)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:_o(g.owner)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:lu(g.creation)})]}),g.changes.length>0?n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:g.changes.map((m,C)=>n.jsxs("div",{style:{fontSize:12,lineHeight:1.5},children:[n.jsx("span",{style:{fontWeight:600,color:"#6d28d9"},children:My(m.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:m.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:m.newVal})]},C))}):n.jsxs("div",{style:{fontSize:12,color:"#9ca3af",fontStyle:"italic"},children:["Document updated",g.added>0&&n.jsxs("span",{children:[" · +",g.added," row(s)"]}),g.removed>0&&n.jsxs("span",{children:[" · -",g.removed," row(s)"]}),g.rowChanged>0&&n.jsxs("span",{children:[" · ~",g.rowChanged," row(s) modified"]})]})]})]},g.name)),l&&s&&n.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[n.jsx("div",{style:x("#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:ru(s)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:_o(s)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:lu(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&&j>0&&n.jsx("div",{style:{textAlign:"center",marginTop:12},children:n.jsx("button",{onClick:()=>c(g=>!g),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 gs={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},_a={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},Ky={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 Qy(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...Ky[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function Gy({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:S,darkMode:h,notifCount:j,onToggleDark:x,onCountChange:g,onViewProfile:o,userRole:m,onSubmit:C,onBack:A,onNavigate:P,onLogout:w,user:_,onRefresh:U}){const T=V(),I=R=>t({...e,...R}),N=v?{background:"#f9f9f9"}:{},M=Ql(y,p,"SB Employee"),Z=Ql(y,p,"SB Manager"),[ge,le]=b.useState(""),[L,K]=b.useState(!1),G=e.name?v?`${T.formTitle.viewIncident}${e.number||e.name}`:T.formTitle.editIncident:T.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=m==="Employee",D=m==="Auditor"||m==="Admin",te=m==="Manager",hn=e.name?H==="New"?[{label:T.wf.submit,action:"Submit",color:"#2563eb"}]:H==="Initial Evaluation"&&D?[{label:T.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:T.wf.reject,action:"Reject",color:"#dc2626"}]:H==="Accept & Under Progress"&&(te||D)?[{label:T.wf.submitSolution,action:"Submit Solution",color:"#059669"}]:H==="working on resolution"&&(te||D)?[{label:T.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 py(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:T.wf.workflow}),n.jsx("span",{style:Qy(H),children:H})]}),H==="Initial Evaluation"&&D&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:z,children:T.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:T.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:T.field.solution}),n.jsx("textarea",{style:{...E,height:80,resize:"vertical"},value:e.solution||"",onChange:R=>I({solution:R.target.value}),placeholder:T.field.solutionPlaceholder}),n.jsx("label",{style:{...z,marginTop:8},children:T.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:T.field.auditorComment}),n.jsx("textarea",{style:{...E,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:R=>I({auditor_comment:R.target.value}),placeholder:T.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?T.wf.applying:R.label},R.action))}):n.jsx("div",{style:{fontSize:12,color:"#94a3b8",fontStyle:"italic"},children:T.wf.noActions}),ge&&n.jsx("p",{style:{marginTop:8,fontSize:13,color:ge==="Done"?$.green:$.red},children:ge})]}),n.jsx(Hi,{doctype:B.incidents,docname:e.name,currentUserName:_.name}),n.jsx(Ki,{doctype:B.incidents,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):null;return n.jsxs(Me,{title:G,activePage:"incidents",user:_,formStatus:c,buttonText:T.saveIncident,buttonColor:$.accent,viewMode:v,onEdit:S,darkMode:h,notifCount:j,onToggleDark:x,onCountChange:g,onViewProfile:o,rightPanel:O,onSubmit:C,onBack:A,onNavigate:P,onLogout:w,children:[n.jsxs("div",{style:gs,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.number}),n.jsx("input",{style:{...E,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.organization}),n.jsx(Et,{value:e.organization,onChange:R=>I({organization:R}),organizations:l,disabled:v||!!_.custom_organization})]})]}),n.jsxs("div",{style:_a,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.management}),n.jsx(ue,{value:e.management,onChange:R=>I({management:R}),items:ee,placeholder:T.field.select,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.department}),n.jsx(ue,{value:e.department,onChange:R=>I({department:R}),items:J,placeholder:T.field.select,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.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:gs,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.branch}),n.jsx(ue,{value:e.branch,onChange:R=>I({branch:R}),items:xe,placeholder:T.field.select,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.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:gs,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.type}),n.jsx(ue,{value:e.type,onChange:R=>I({type:R}),items:_e,placeholder:T.field.selectType,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.title}),n.jsx("input",{style:{...E,...N},value:e.title,disabled:v,onChange:R=>I({title:R.target.value})})]})]}),n.jsxs("div",{style:gs,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.incidentClass}),n.jsx(ue,{value:e.incident_class,onChange:R=>I({incident_class:R}),items:re,placeholder:T.field.selectClass,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.incidentField}),n.jsx(ue,{value:e.incident_field,onChange:R=>I({incident_field:R}),items:Ce,placeholder:T.field.selectField,disabled:v})]})]}),n.jsxs("div",{style:_a,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.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:T.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:T.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:T.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:T.field.status}),n.jsx(ue,{value:e.status,onChange:R=>I({status:R}),items:Oe,placeholder:T.field.selectStatus,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.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:T.steps.auditorTriage}),n.jsxs("div",{style:_a,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.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:T.field.select}),n.jsx("option",{value:"High",children:T.field.high}),n.jsx("option",{value:"Normal",children:T.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.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:T.field.select}),n.jsx("option",{value:"Expenses",children:T.field.expenses}),n.jsx("option",{value:"Capital",children:T.field.capital}),n.jsx("option",{value:"Earn",children:T.field.earn}),n.jsx("option",{value:"Pay/Loss",children:T.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.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:T.field.select}),n.jsx("option",{value:"Upstream",children:T.field.upstream}),n.jsx("option",{value:"On-stream",children:T.field.onstream}),n.jsx("option",{value:"Downstream",children:T.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})})," ",T.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})})," ",T.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:T.steps.managerSolution}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.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:T.field.solutionPlaceholder})]}),n.jsxs("div",{style:gs,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.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:T.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:T.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:T.field.commentPlaceholder})]})]})}function Yy({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]=b.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),S=(o,m)=>v(C=>({...C,[o]:m})),[h,j]=b.useState(1),x=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));b.useEffect(()=>{j(1)},[c]);const g=x.slice((h-1)*ne,h*ne);return n.jsxs(n.Fragment,{children:[n.jsx(Mi,{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=>S("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=>S("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=>S("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=>S("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=>S("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:x.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:p.noIdeas})}):g.map((o,m)=>n.jsxs("tr",{onClick:()=>u==null?void 0:u(o),style:{borderTop:"1px solid #f0f0f0",background:m%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,Fi(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:h,total:x.length,onPageChange:j})]})}const iu={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Ca={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},Xy={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 qy(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...Xy[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function Jy({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:S,onToggleDark:h,onCountChange:j,onViewProfile:x,userRole:g,onSubmit:o,onBack:m,onNavigate:C,onLogout:A,user:P,onRefresh:w}){const _=V(),U=D=>t({...e,...D}),T=p?{background:"#f9f9f9"}:{},I=Ql(u,f,"SB Manager"),[N,M]=b.useState(""),[Z,ge]=b.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=g==="Employee",re=g==="Auditor"||g==="Admin",Ce=g==="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 fy(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:qy(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"?$.green:$.red},children:N})]}),n.jsx(Hi,{doctype:B.ideas,docname:e.name,currentUserName:P.name}),n.jsx(Ki,{doctype:B.ideas,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):null;return n.jsxs(Me,{title:le,activePage:"ideas",user:P,formStatus:y,buttonText:_.saveIdea,buttonColor:$.teal,viewMode:p,onEdit:c,darkMode:v,notifCount:S,onToggleDark:h,onCountChange:j,onViewProfile:x,rightPanel:se,onSubmit:o,onBack:m,onNavigate:C,onLogout:A,children:[n.jsxs("div",{style:iu,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.jsx("label",{style:z,children:_.field.organization}),n.jsx(Et,{value:e.organization,onChange:D=>U({organization:D}),organizations:l,disabled:p||!!P.custom_organization})]})]}),n.jsxs("div",{style:Ca,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,...T},value:e.section_field||"",disabled:p,onChange:D=>U({section_field:D.target.value})})]})]}),n.jsxs("div",{style:iu,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,...T}})]})]}),n.jsxs("div",{style:Ca,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,...T},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,...T},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,...T},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,...T,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,...T,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:Ca,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 Zy({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]=b.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),S=(o,m)=>v(C=>({...C,[o]:m})),[h,j]=b.useState(1),x=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));b.useEffect(()=>{j(1)},[c]);const g=x.slice((h-1)*ne,h*ne);return n.jsxs(n.Fragment,{children:[n.jsx(Mi,{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=>S("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=>S("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=>S("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=>S("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=>S("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:x.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:p.noOrders})}):g.map((o,m)=>n.jsxs("tr",{onClick:()=>u==null?void 0:u(o),style:{borderTop:"1px solid #f0f0f0",background:m%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,Fi(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:h,total:x.length,onPageChange:j})]})}const Nr={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Wr={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},Vy={1:"Initiation / Bidding",2:"Execution begins",3:"Mid-execution review",4:"Near completion",5:"Closing"},e0={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 t0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...e0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function n0({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:S,notifCount:h,onToggleDark:j,onCountChange:x,onViewProfile:g,currentUser:o,userRole:m,onSubmit:C,onBack:A,onNavigate:P,onLogout:w,user:_,onRefresh:U}){var $n;const T=V(),I=W=>t({...e,...W}),N=c?{background:"#f9f9f9"}:{},M=Ql(f,y,"SB Employee"),[Z,ge]=b.useState(""),[le,L]=b.useState(""),[K,G]=b.useState(!1),[ee,J]=b.useState("Agree"),xe=e.name?c?`${T.formTitle.viewOrder}${e.number||e.title||e.name}`:T.formTitle.editOrder:T.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]=b.useState(hn);b.useEffect(()=>{O(Math.min(5,(e.stage||0)+1))},[e.stage]);const R=m==="Auditor"||m==="Admin"||m==="Manager",Q=R||m==="Owner",Yt=!!(o&&(e.actor===o||e.assigned_to===o)),ur=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 uy(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 Qi=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:T.wf.workflow}),n.jsx("span",{style:t0(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:$.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:ur.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?T.wf.applying:W.label},W.action)})}),Z&&n.jsx("p",{style:{marginTop:8,fontSize:13,color:Z==="Done"?$.green:$.red},children:Z}),ur.length===0&&n.jsx("div",{style:{fontSize:12,color:"#94a3b8",fontStyle:"italic"},children:T.wf.noActions})]}),n.jsx(Hi,{doctype:B.orders,docname:e.name,currentUserName:_.name}),n.jsx(Ki,{doctype:B.orders,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):null;return n.jsxs(Me,{title:xe,activePage:"orders",user:_,formStatus:p,buttonText:T.saveOrder,buttonColor:$.purple,viewMode:c,onEdit:v,darkMode:S,notifCount:h,onToggleDark:j,onCountChange:x,onViewProfile:g,rightPanel:Qi,onSubmit:C,onBack:A,onNavigate:P,onLogout:w,children:[n.jsxs("div",{style:Nr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.number}),n.jsx("input",{style:{...E,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.organization}),n.jsx(Et,{value:e.organization,onChange:W=>I({organization:W}),organizations:l,disabled:c||!!_.custom_organization})]})]}),n.jsxs("div",{style:Wr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.management}),n.jsx(ue,{value:e.management,onChange:W=>I({management:W}),items:_e,placeholder:T.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.department}),n.jsx(ue,{value:e.department,onChange:W=>I({department:W}),items:re,placeholder:T.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.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:Nr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.branch}),n.jsx(ue,{value:e.branch,onChange:W=>I({branch:W}),items:Ce,placeholder:T.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.type}),n.jsx(ue,{value:e.type,onChange:W=>I({type:W}),items:Oe,placeholder:T.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:Wr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.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:T.field.select}),n.jsx("option",{value:"High",children:T.field.high}),n.jsx("option",{value:"Normal",children:T.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.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:T.field.select}),n.jsx("option",{value:"Expenses",children:T.field.expenses}),n.jsx("option",{value:"Capital",children:T.field.capital}),n.jsx("option",{value:"Earn",children:T.field.earn}),n.jsx("option",{value:"Pay/Loss",children:T.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.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:T.field.select}),n.jsx("option",{value:"Upstream",children:T.field.upstream}),n.jsx("option",{value:"On-stream",children:T.field.onstream}),n.jsx("option",{value:"Downstream",children:T.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})})," ",T.field.productRelation]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:z,children:T.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:T.field.title}),n.jsx("input",{style:{...E,...N},value:e.title,disabled:c,onChange:W=>I({title:W.target.value})})]}),n.jsxs("div",{style:Wr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.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:T.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:Nr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.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:T.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:T.field.status}),n.jsx(ue,{value:e.status,onChange:W=>I({status:W}),items:H,placeholder:T.field.selectStatus,disabled:c||te==="Closed"})]})]}),n.jsxs("div",{style:Wr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.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:T.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:T.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:T.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:Nr,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.field.cycle}),n.jsx(ue,{value:e.cycle||"",onChange:W=>I({cycle:W}),items:se,placeholder:T.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:T.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:Vy[e.stage||1]||"—"})]}),(e.escalation_level??0)>0&&n.jsxs("div",{children:[n.jsx("label",{style:z,children:T.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:T.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:T.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:T.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:T.field.commentPlaceholder})]})]})}function l0({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]=b.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),S=(o,m)=>v(C=>({...C,[o]:m})),[h,j]=b.useState(1),x=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));b.useEffect(()=>{j(1)},[c]);const g=x.slice((h-1)*ne,h*ne);return n.jsxs(n.Fragment,{children:[n.jsx(Mi,{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=>S("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=>S("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=>S("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=>S("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=>S("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:x.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:p.noProcesses})}):g.map((o,m)=>n.jsxs("tr",{onClick:()=>u==null?void 0:u(o),style:{borderTop:"1px solid #f0f0f0",background:m%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,Fi(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:h,total:x.length,onPageChange:j})]})}const s0={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"]}]},r0={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 au(e){return{display:"inline-block",padding:"5px 14px",borderRadius:20,fontSize:13,fontWeight:700,...r0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}const Br={width:"100%",padding:"6px 8px",border:"1px solid #d1d5db",borderRadius:5,fontSize:12,fontFamily:"Segoe UI",boxSizing:"border-box"};function i0({processName:e,userRole:t,onRefresh:l,canUpdateStatus:s=!0}){const[r,i]=b.useState(null),[a,d]=b.useState(!0),[u,f]=b.useState(""),[y,p]=b.useState(!1),[c,v]=b.useState(""),[S,h]=b.useState(""),[j,x]=b.useState("Pass"),[g,o]=b.useState(""),[m,C]=b.useState({}),A=b.useCallback(async()=>{if(!e){d(!1);return}d(!0),f("");try{const N=await Es(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(b.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 P=r.workflow_state||"Draft",w=s0[P]??[],_=t==="Employee"||t==="Manager",U=t!=="Manager"||s,T=w.filter(N=>(t==="Admin"||N.allowedRoles.includes(t))&&(N.action!=="Update Status"||U)),I=async N=>{p(!0),v(""),h("");try{const M={};if(N==="Update Status"){M.actor_status=j,M.actor_comment=g;const ge=r.progress_indicators||[];ge.length>0&&(M.progress_indicators=ge.map(le=>({name:le.name,actual_value:m[le.name]??""})))}N==="Add Comment"&&g&&(M.actor_comment=g);const Z=await _y(r.name,N,M);i(Z),o(""),h(`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:au(P),children:P})]}),P==="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:m[N.name]??"",onChange:M=>C(Z=>({...Z,[N.name]:M.target.value})),style:{...Br,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:j,onChange:N=>x(N.target.value),style:Br,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:g,onChange:N=>o(N.target.value),style:{...Br,height:52,resize:"vertical"},placeholder:"Add a comment…"})]})]}),(P==="Pending Comment"||P==="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:g,onChange:N=>o(N.target.value),style:{...Br,height:52,resize:"vertical"},placeholder:"Add a comment…"})]}),n.jsxs("div",{style:{padding:"12px 14px",borderBottom:T.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"}),T.length===0&&n.jsxs("div",{style:{fontSize:12,color:"#aaa",fontStyle:"italic",lineHeight:1.5},children:["No actions for ",n.jsx("strong",{children:t})," in ",n.jsx("strong",{children:P}),"."]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:T.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}),S&&n.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,fontSize:12,color:"#166534"},children:S})]}),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:au(N.next),children:N.next})]},N.action))]})]})})}const $r={display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},hl={display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:16};function a0({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:S,notifCount:h,onToggleDark:j,onCountChange:x,onViewProfile:g,userRole:o,delegatedFunctions:m=[],delegatedOrgs:C=null,onRefreshProcess:A,onSubmit:P,onBack:w,onNavigate:_,onLogout:U,user:T}){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||!!T.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===T.name||m.includes("update_process_status"),gt=e.name?n.jsxs("div",{style:{width:260,display:"flex",flexDirection:"column",gap:14},children:[n.jsx(i0,{processName:e.name,userRole:o||T.role||"Employee",onRefresh:A,canUpdateStatus:hn}),n.jsx(Hi,{doctype:B.processes,docname:e.name,currentUserName:T.name}),n.jsx(Ki,{doctype:B.processes,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):void 0;return n.jsxs(Me,{title:te,activePage:"processes",user:T,formStatus:p,buttonText:I.saveProcess,buttonColor:$.blue,viewMode:c,onEdit:v,darkMode:S,notifCount:h,onToggleDark:j,onCountChange:x,onViewProfile:g,rightPanel:gt,onSubmit:P,onBack:w,onNavigate:_,onLogout:U,children:[n.jsxs("div",{style:$r,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.jsx("label",{style:z,children:I.field.organization}),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:$r,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:$r,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:$r,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 o0={Admin:"#7c3aed",Auditor:"#d97706",Owner:"#0369a1",XAuditor:"#0f766e",Manager:"#2563eb",Employee:"#6b7280",Chairman:"#0f766e"};function c0({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]=b.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,S]=b.useState(""),[h,j]=b.useState(!1),[x,g]=b.useState({new:"",confirm:""}),[o,m]=b.useState(""),C=f.email||f.name||"",A=[p.first_name,p.middle_name,p.last_name].filter(Boolean).join(" ")||f.full_name||"",P=f.username||f.name||"",w=p.custom_category||"",_=f.enabled===0?"Inactive":"Active",U=o0[e.role]||"#6b7280",T=l,I=T?"#0f172a":"#f0f2f5",N=T?"#1e293b":"white",M=T?"#2d3748":"#e5e7eb",Z=T?"#e2e8f0":"#1a2332",ge=T?"#94a3b8":"#6b7280",le=T?"#374151":"white",L=T?"#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){S("saving");try{await _i("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}),S("saved"),setTimeout(()=>S(""),2e3)}catch{S("error"),setTimeout(()=>S(""),3e3)}}},Ce=async()=>{if(!x.new){m("Enter a new password");return}if(x.new!==x.confirm){m("Passwords do not match");return}m("saving");try{await Df(f.name,x.new),m("done"),g({new:"",confirm:""}),setTimeout(()=>{m(""),j(!1)},2e3)}catch{m("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,${T?.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:P},{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,${T?.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:()=>{j(H=>!H),m("")},style:{fontSize:13,color:"#3b82f6",background:"none",border:"none",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:h?"Cancel":"Change Password"})]}),h&&n.jsxs("div",{style:{marginTop:18,display:"flex",flexDirection:"column",gap:12},children:[n.jsxs("div",{style:_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:x.new,onChange:H=>g(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:x.confirm,onChange:H=>g(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 Bf={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151",boxSizing:"border-box"},d0={...Bf,cursor:"pointer"};function ct({filters:e,defaultOpen:t=!1}){const[l,s]=b.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:Bf,placeholder:r.placeholder,value:r.value,onChange:a=>r.onChange(a.target.value)}):n.jsx("select",{style:d0,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 u0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function p0({organizations:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=b.useState(""),[u,f]=b.useState("all"),[y,p]=b.useState("all"),c={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},v=b.useMemo(()=>e.filter(x=>{const g=[x.organization_name,x.city].filter(Boolean).join(" ").toLowerCase();return!(a&&!g.includes(a.toLowerCase())||u!=="all"&&x.type!==u||y!=="all"&&(x.is_active?"Active":"Inactive")!==y)}),[e,a,u,y]),[S,h]=b.useState(1);b.useEffect(()=>{h(1)},[a,u,y]);const j=v.slice((S-1)*ne,S*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(x=>x.is_active).length,color:$.green}),n.jsx(Ee,{label:"Government",val:v.filter(x=>x.type==="Government").length,color:$.blue}),n.jsx(Ee,{label:"Private",val:v.filter(x=>x.type==="Private").length,color:$.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})}):j.map((x,g)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(x),style:{borderTop:"1px solid #f0f0f0",background:g%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:x.organization_name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:x.type||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:x.city||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:u0(x.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:On(x.is_active?i.field.statusActive:i.field.statusInactive,x.is_active?$.green:$.gray)}),n.jsx("td",{style:{padding:"8px 14px"},onClick:o=>o.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(x),onEdit:t&&s?()=>s(x):void 0,onDelete:t&&r?()=>r(x.name):void 0})})]},x.name))})]})}),n.jsx(Fe,{page:S,total:v.length,onPageChange:h})]})}const Zt=e=>({background:e?"#f9f9f9":void 0});function f0({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:S}){const h=V(),j=e.name?s&&e.organization_name||h.formTitle.editOrg:h.formTitle.newOrg;return n.jsxs(Me,{title:j,activePage:"organizations",user:S,formStatus:l,buttonText:h.saveOrg,buttonColor:$.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:[h.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:x=>t({...e,organization_name:x.target.value})})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[h.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:x=>t({...e,acronym:x.target.value})})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.organizationType}),n.jsxs("select",{style:{...E,...Zt(s)},value:e.type,disabled:s,onChange:x=>t({...e,type:x.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:h.field.orgCity}),n.jsx("input",{type:"text",style:{...E,...Zt(s)},value:e.city,disabled:s,onChange:x=>t({...e,city:x.target.value})})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.contactEmail}),n.jsx("input",{type:"email",style:{...E,...Zt(s)},value:e.contact_email,disabled:s,onChange:x=>t({...e,contact_email:x.target.value})})]}),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.creation_date||"",onChange:x=>t({...e,creation_date:x}),disabled:s,style:{...E,...Zt(s)}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...E,...Zt(s)},value:e.is_active?"Active":"Inactive",disabled:s,onChange:x=>t({...e,is_active:x.target.value==="Active"?1:0}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.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:x=>t({...e,incident_triage_window_days:parseInt(x.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:h.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:x=>t({...e,incident_resolution_window_days:parseInt(x.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 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({managements:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=b.useState(""),[u,f]=b.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=b.useMemo(()=>e.filter(h=>{const j=(h.name1||h.name||"").toLowerCase();return!(a&&!j.includes(a.toLowerCase())||u!=="all"&&(h.status||"Active")!==u)}),[e,a,u]),[c,v]=b.useState(1);b.useEffect(()=>{v(1)},[a,u]);const S=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:$.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})}):S.map((h,j)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:j%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:h0(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.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:c,total:p.length,onPageChange:v})]})}function x0({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:S,user:h}){const j=V(),x=m=>t(C=>({...C,...m})),g=r?{background:"#f9f9f9"}:{},o=e.name?r?`${j.formTitle.editMgmt}: ${e.name1||e.name}`:j.formTitle.editMgmt:j.formTitle.newMgmt;return n.jsxs(Me,{title:o,activePage:"managements",user:h,formStatus:s,buttonText:j.saveMgmt,buttonColor:$.blue,viewMode:r,onEdit:i,darkMode:a,notifCount:d,onToggleDark:u,onCountChange:f,onViewProfile:y,onSubmit:p,onBack:c,onNavigate:v,onLogout:S,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:j.field.organization}),n.jsx(Et,{value:e.organization,onChange:m=>x({organization:m}),organizations:l,disabled:r||!!h.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[j.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...g},value:e.name1,disabled:r||!!e.name,onChange:m=>x({name1:m.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:j.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:m=>x({creation_date:m}),disabled:r,style:{...E,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:j.field.status}),n.jsxs("select",{style:{...E,...g},value:e.status||"Active",disabled:r,onChange:m=>x({status:m.target.value}),children:[n.jsx("option",{value:"Active",children:j.field.statusActive}),n.jsx("option",{value:"Inactive",children:j.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 y0({departments:e,managements:t,canModify:l,onView:s,onEdit:r,onDelete:i}){const a=V(),[d,u]=b.useState(""),[f,y]=b.useState(""),[p,c]=b.useState("all"),v=o=>{var m;return((m=t.find(C=>C.name===o))==null?void 0:m.name1)||o||"—"},S={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},h=b.useMemo(()=>e.filter(o=>{const m=(o.department_name||o.name||"").toLowerCase();return!(d&&!m.includes(d.toLowerCase())||f&&o.custom_management!==f||p!=="all"&&(o.custom_status||"Active")!==p)}),[e,d,f,p]),[j,x]=b.useState(1);b.useEffect(()=>{x(1)},[d,f,p]);const g=h.slice((j-1)*ne,j*ne);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ee,{label:"Total",val:h.length,color:$.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:S,children:a.col.name}),n.jsx("th",{style:S,children:a.col.management}),n.jsx("th",{style:S,children:a.field.creationDate}),n.jsx("th",{style:S,children:a.field.status}),n.jsx("th",{style:S,children:a.col.actions})]})}),n.jsx("tbody",{children:h.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):g.map((o,m)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:m%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:m0(o.custom_creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:o.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.custom_status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick: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:j,total:h.length,onPageChange:x})]})}const v0={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20};function j0({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:S,onLogout:h,user:j}){const x=V(),g=A=>t(P=>({...P,...A})),o=i?{background:"#f9f9f9"}:{},m=e.name?i?`${x.formTitle.editDept}: ${e.department_name||e.name}`:x.formTitle.editDept:x.formTitle.newDept,C=fe(s,e.custom_management).map(A=>({name:A.name,label:A.name1||A.name}));return n.jsxs(Me,{title:m,activePage:"departments",user:j,formStatus:r,buttonText:x.saveDept,buttonColor:$.teal,viewMode:i,onEdit:a,darkMode:d,notifCount:u,onToggleDark:f,onCountChange:y,onViewProfile:p,onSubmit:c,onBack:v,onNavigate:S,onLogout:h,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.organization}),n.jsx(Et,{value:e.custom_organization,onChange:A=>g({custom_organization:A}),organizations:l,disabled:i||!!j.custom_organization})]}),n.jsxs("div",{style:v0,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[x.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=>g({department_name:A.target.value}),placeholder:"Department name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.management}),n.jsx(ue,{value:e.custom_management,onChange:A=>g({custom_management:A}),items:C,placeholder:x.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:x.field.creationDate}),n.jsx(me,{value:e.custom_creation_date||"",onChange:A=>g({custom_creation_date:A}),disabled:i,style:{...E,...o}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:x.field.status}),n.jsxs("select",{style:{...E,...o},value:e.custom_status||"Active",disabled:i,onChange:A=>g({custom_status:A.target.value}),children:[n.jsx("option",{value:"Active",children:x.field.statusActive}),n.jsx("option",{value:"Inactive",children:x.field.statusInactive})]})]})]})]})}function b0(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 S0({branches:e,managements:t,departments:l,canModify:s,onView:r,onEdit:i,onDelete:a}){const d=V(),[u,f]=b.useState(""),[y,p]=b.useState(""),[c,v]=b.useState(""),[S,h]=b.useState("all"),j=P=>{var w;return((w=t.find(_=>_.name===P))==null?void 0:w.name1)||P||"—"},x=P=>{var w;return((w=l.find(_=>_.name===P))==null?void 0:w.department_name)||P||"—"},g={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},o=b.useMemo(()=>e.filter(P=>{const w=(P.branch||P.name||"").toLowerCase();return!(u&&!w.includes(u.toLowerCase())||y&&P.management!==y||c&&P.department!==c||S!=="all"&&(P.custom_status||"Active")!==S)}),[e,u,y,c,S]),[m,C]=b.useState(1);b.useEffect(()=>{C(1)},[u,y,c,S]);const A=o.slice((m-1)*ne,m*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:$.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(P=>({value:P.name,label:P.name1||P.name}))]},{type:"select",label:d.col.department,value:c,onChange:v,options:[{value:"",label:"All Departments"},...l.map(P=>({value:P.name,label:P.department_name||P.name}))]},{type:"select",label:"Status",value:S,onChange:h,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:g,children:d.col.branch}),n.jsx("th",{style:g,children:d.col.management}),n.jsx("th",{style:g,children:d.col.department}),n.jsx("th",{style:g,children:d.field.creationDate}),n.jsx("th",{style:g,children:d.field.status}),n.jsx("th",{style:g,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((P,w)=>n.jsxs("tr",{onClick:()=>r==null?void 0:r(P),style:{borderTop:"1px solid #f0f0f0",background:w%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:P.branch||P.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:j(P.management)}),n.jsx("td",{style:{padding:"10px 14px"},children:x(P.department)}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:b0(P.custom_creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:P.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:P.custom_status==="Inactive"?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(P),onEdit:s&&i?()=>i(P):void 0,onDelete:s&&a?()=>a(P.name):void 0})})]},P.name))})]})}),n.jsx(Fe,{page:m,total:o.length,onPageChange:C})]})}const w0={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20};function k0({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:S,onNavigate:h,onLogout:j,user:x}){const g=V(),o=w=>t(_=>({..._,...w})),m=a?{background:"#f9f9f9"}:{},C=e.name?a?`${g.formTitle.editBranch}: ${e.branch||e.name}`:g.formTitle.editBranch:g.formTitle.newBranch,A=fe(s,e.management).map(w=>({name:w.name,label:w.name1||w.name})),P=fe(r,e.department).map(w=>({name:w.name,label:w.department_name||w.name}));return n.jsxs(Me,{title:C,activePage:"branches",user:x,formStatus:i,buttonText:g.saveBranch,buttonColor:$.purple,viewMode:a,onEdit:d,darkMode:u,notifCount:f,onToggleDark:y,onCountChange:p,onViewProfile:c,onSubmit:v,onBack:S,onNavigate:h,onLogout:j,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.organization}),n.jsx(Et,{value:e.organization,onChange:w=>o({organization:w}),organizations:l,disabled:a||!!x.custom_organization})]}),n.jsxs("div",{style:w0,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[g.field.branch," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...m},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:g.field.management}),n.jsx(ue,{value:e.management,onChange:w=>o({management:w}),items:A,placeholder:g.field.select,disabled:a})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.department}),n.jsx(ue,{value:e.department,onChange:w=>o({department:w}),items:P,placeholder:g.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:g.field.creationDate}),n.jsx(me,{value:e.custom_creation_date||"",onChange:w=>o({custom_creation_date:w}),disabled:a,style:{...E,...m}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.field.status}),n.jsxs("select",{style:{...E,...m},value:e.custom_status||"Active",disabled:a,onChange:w=>o({custom_status:w.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})]})}function _0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function C0({incidentTypes:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=b.useState(""),[u,f]=b.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=b.useMemo(()=>e.filter(h=>{const j=(h.name1||h.name||"").toLowerCase();return!(a&&!j.includes(a.toLowerCase())||u!=="all"&&(h.status||"Active")!==u)}),[e,a,u]),[c,v]=b.useState(1);b.useEffect(()=>{v(1)},[a,u]);const S=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:$.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})}):S.map((h,j)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:j%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:_0(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.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:c,total:p.length,onPageChange:v})]})}function z0({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:S}){const h=V(),j=o=>t(m=>({...m,...o})),x=s?{background:"#f9f9f9"}:{},g=e.name?s?`Incident Type: ${e.name1||e.name}`:"Edit Incident Type":"New Incident Type";return n.jsxs(Me,{title:g,activePage:"incident-types",user:S,formStatus:l,buttonText:h.saveName,buttonColor:$.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:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...x},value:e.name1,disabled:s||!!e.name,onChange:o=>j({name1:o.target.value}),placeholder:"Incident type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>j({creation_date:o}),disabled:s,style:{...E,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...E,...x},value:e.status||"Active",disabled:s,onChange:o=>j({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.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({ideaTypes:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=b.useState(""),[u,f]=b.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=b.useMemo(()=>e.filter(h=>{const j=(h.name1||h.name||"").toLowerCase();return!(a&&!j.includes(a.toLowerCase())||u!=="all"&&(h.status||"Active")!==u)}),[e,a,u]),[c,v]=b.useState(1);b.useEffect(()=>{v(1)},[a,u]);const S=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:$.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})}):S.map((h,j)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:j%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:T0(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.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: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:S}){const h=V(),j=o=>t(m=>({...m,...o})),x=s?{background:"#f9f9f9"}:{},g=e.name?s?`Idea Type: ${e.name1||e.name}`:"Edit Idea Type":"New Idea Type";return n.jsxs(Me,{title:g,activePage:"idea-types",user:S,formStatus:l,buttonText:h.saveName,buttonColor:$.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:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...x},value:e.name1,disabled:s||!!e.name,onChange:o=>j({name1:o.target.value}),placeholder:"Idea type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>j({creation_date:o}),disabled:s,style:{...E,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...E,...x},value:e.status||"Active",disabled:s,onChange:o=>j({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.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({orderTypes:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=b.useState(""),[u,f]=b.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=b.useMemo(()=>e.filter(h=>{const j=(h.name1||h.name||"").toLowerCase();return!(a&&!j.includes(a.toLowerCase())||u!=="all"&&(h.status||"Active")!==u)}),[e,a,u]),[c,v]=b.useState(1);b.useEffect(()=>{v(1)},[a,u]);const S=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:$.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})}):S.map((h,j)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:j%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:E0(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.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: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:S}){const h=V(),j=o=>t(m=>({...m,...o})),x=s?{background:"#f9f9f9"}:{},g=e.name?s?`Order Type: ${e.name1||e.name}`:"Edit Order Type":"New Order Type";return n.jsxs(Me,{title:g,activePage:"order-types",user:S,formStatus:l,buttonText:h.saveName,buttonColor:$.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:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...x},value:e.name1,disabled:s||!!e.name,onChange:o=>j({name1:o.target.value}),placeholder:"Order type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>j({creation_date:o}),disabled:s,style:{...E,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...E,...x},value:e.status||"Active",disabled:s,onChange:o=>j({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.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({processTypes:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=b.useState(""),[u,f]=b.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=b.useMemo(()=>e.filter(h=>{const j=(h.name1||h.name||"").toLowerCase();return!(a&&!j.includes(a.toLowerCase())||u!=="all"&&(h.status||"Active")!==u)}),[e,a,u]),[c,v]=b.useState(1);b.useEffect(()=>{v(1)},[a,u]);const S=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:$.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})}):S.map((h,j)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:j%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:L0(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.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: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:S}){const h=V(),j=o=>t(m=>({...m,...o})),x=s?{background:"#f9f9f9"}:{},g=e.name?s?`Process Type: ${e.name1||e.name}`:"Edit Process Type":"New Process Type";return n.jsxs(Me,{title:g,activePage:"process-types",user:S,formStatus:l,buttonText:h.saveName,buttonColor:$.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:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...x},value:e.name1,disabled:s||!!e.name,onChange:o=>j({name1:o.target.value}),placeholder:"Process type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>j({creation_date:o}),disabled:s,style:{...E,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...E,...x},value:e.status||"Active",disabled:s,onChange:o=>j({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.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({incidentStatuses:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=b.useState(""),[u,f]=b.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=b.useMemo(()=>e.filter(h=>{const j=(h.name1||h.name||"").toLowerCase();return!(a&&!j.includes(a.toLowerCase())||u!=="all"&&(h.status||"Active")!==u)}),[e,a,u]),[c,v]=b.useState(1);b.useEffect(()=>{v(1)},[a,u]);const S=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:$.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})}):S.map((h,j)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:j%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:N0(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.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: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:S}){const h=V(),j=o=>t(m=>({...m,...o})),x=s?{background:"#f9f9f9"}:{},g=e.name?s?`Incident Status: ${e.name1||e.name}`:"Edit Incident Status":"New Incident Status";return n.jsxs(Me,{title:g,activePage:"incident-statuses",user:S,formStatus:l,buttonText:h.saveName,buttonColor:$.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:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...x},value:e.name1,disabled:s||!!e.name,onChange:o=>j({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=>j({notify_manager:o.target.checked?1:0}),style:Gl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:s?"default":"pointer"},children:h.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>j({creation_date:o}),disabled:s,style:{...E,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...E,...x},value:e.status||"Active",disabled:s,onChange:o=>j({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.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({ideaStatuses:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=b.useState(""),[u,f]=b.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=b.useMemo(()=>e.filter(h=>{const j=(h.name1||h.name||"").toLowerCase();return!(a&&!j.includes(a.toLowerCase())||u!=="all"&&(h.status||"Active")!==u)}),[e,a,u]),[c,v]=b.useState(1);b.useEffect(()=>{v(1)},[a,u]);const S=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:$.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})}):S.map((h,j)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:j%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:$0(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.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: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:S}){const h=V(),j=o=>t(m=>({...m,...o})),x=s?{background:"#f9f9f9"}:{},g=e.name?s?`Idea Status: ${e.name1||e.name}`:"Edit Idea Status":"New Idea Status";return n.jsxs(Me,{title:g,activePage:"idea-statuses",user:S,formStatus:l,buttonText:h.saveName,buttonColor:$.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:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...x},value:e.name1,disabled:s||!!e.name,onChange:o=>j({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=>j({notify_manager:o.target.checked?1:0}),style:Gl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:s?"default":"pointer"},children:h.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>j({creation_date:o}),disabled:s,style:{...E,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...E,...x},value:e.status||"Active",disabled:s,onChange:o=>j({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.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({orderStatuses:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=b.useState(""),[u,f]=b.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=b.useMemo(()=>e.filter(h=>{const j=(h.name1||h.name||"").toLowerCase();return!(a&&!j.includes(a.toLowerCase())||u!=="all"&&(h.status||"Active")!==u)}),[e,a,u]),[c,v]=b.useState(1);b.useEffect(()=>{v(1)},[a,u]);const S=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:$.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})}):S.map((h,j)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:j%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:M0(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.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: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:S}){const h=V(),j=o=>t(m=>({...m,...o})),x=s?{background:"#f9f9f9"}:{},g=e.name?s?`Order Status: ${e.name1||e.name}`:"Edit Order Status":"New Order Status";return n.jsxs(Me,{title:g,activePage:"order-statuses",user:S,formStatus:l,buttonText:h.saveName,buttonColor:$.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:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...x},value:e.name1,disabled:s||!!e.name,onChange:o=>j({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=>j({notify_manager:o.target.checked?1:0}),style:Gl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:s?"default":"pointer"},children:h.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>j({creation_date:o}),disabled:s,style:{...E,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...E,...x},value:e.status||"Active",disabled:s,onChange:o=>j({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.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({processStatuses:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=b.useState(""),[u,f]=b.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=b.useMemo(()=>e.filter(h=>{const j=(h.name1||h.name||"").toLowerCase();return!(a&&!j.includes(a.toLowerCase())||u!=="all"&&(h.status||"Active")!==u)}),[e,a,u]),[c,v]=b.useState(1);b.useEffect(()=>{v(1)},[a,u]);const S=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:$.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})}):S.map((h,j)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:j%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.name1||h.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:Q0(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:h.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:h.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.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: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:S}){const h=V(),j=o=>t(m=>({...m,...o})),x=s?{background:"#f9f9f9"}:{},g=e.name?s?`Process Status: ${e.name1||e.name}`:"Edit Process Status":"New Process Status";return n.jsxs(Me,{title:g,activePage:"process-statuses",user:S,formStatus:l,buttonText:h.saveName,buttonColor:$.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:[h.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...x},value:e.name1,disabled:s||!!e.name,onChange:o=>j({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=>j({notify_manager:o.target.checked?1:0}),style:Gl}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:s?"default":"pointer"},children:h.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.creationDate}),n.jsx(me,{value:e.creation_date||"",onChange:o=>j({creation_date:o}),disabled:s,style:{...E,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:h.field.status}),n.jsxs("select",{style:{...E,...x},value:e.status||"Active",disabled:s,onChange:o=>j({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})}const X0={Admin:"#7c3aed",Chairman:"#0f766e",Auditor:"#d97706","X-Auditor":"#8b5cf6",Manager:"#2563eb",Employee:"#6b7280"};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 J0({users:e,canModify:t,onView:l,onEdit:s,onDisable:r}){const i=V(),[a,d]=b.useState(!1),[u,f]=b.useState(""),[y,p]=b.useState(""),[c,v]=b.useState(""),[S,h]=b.useState("active"),[j,x]=b.useState(1),[g,o]=b.useState(null),[m,C]=b.useState(""),[A,P]=b.useState("idle"),[w,_]=b.useState(null),U=async()=>{if(!(!g||!m.trim())){P("loading");try{await Df(g.name,m.trim()),P("success"),setTimeout(()=>{o(null),C(""),P("idle")},1200)}catch{P("error")}}},T=async L=>{if(window.confirm(i.users.disableConfirm)){_(L);try{await(r==null?void 0:r(L))}finally{_(null)}}},I=e.filter(L=>{if(S==="active"&&(L.enabled===0||L.enabled==="0")||S==="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"];b.useEffect(()=>{x(1)},[u,y,c,S]);const Z=I.slice((j-1)*ne,j*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:S,onChange:L=>h(L.target.value),children:[n.jsx("option",{value:"all",children:"All"}),n.jsx("option",{value:"active",children:"Active"}),n.jsx("option",{value:"inactive",children:"Inactive"})]})]})]})})]}),n.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa",borderBottom:"2px solid #f0f0f0"},children:[{label:"Category",w:100},{label:"Number",w:80},{label:"Full Name",w:140},{label:"Username",w:120},{label:"Email Address",w:180},{label:"Phone Number",w:120},{label:"Organization",w:130},{label:"Management",w:120},{label:"Department",w:120},{label:"Branch",w:100},{label:"Since",w:90},{label:"Status",w:80},{label:"Tools",w:200}].map(({label:L,w: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=X0[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:q0(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(""),P("idle")},title:"Set Password",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#fef3c7",color:"#d97706"},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),n.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}),t&&n.jsx("button",{onClick:J=>{J.stopPropagation(),T(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:j,total:I.length,onPageChange:x}),g&&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:g.email})]}),n.jsx("input",{type:"password",value:m,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"||!m.trim(),style:{flex:1,padding:10,background:"#2563eb",color:"white",border:"none",borderRadius:8,cursor:"pointer",fontSize:13,fontWeight:700,fontFamily:"inherit",opacity:m.trim()?1:.5},children:A==="loading"?"Saving…":i.users.setPassword}),n.jsx("button",{onClick:()=>{o(null),C(""),P("idle")},style:{flex:1,padding:10,background:"#f5f5f5",color:"#374151",border:"1px solid #e5e7eb",borderRadius:8,cursor:"pointer",fontSize:13,fontFamily:"inherit"},children:i.cancel})]})]})})]})}const xs={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20};function Z0({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:S,onSubmit:h,onBack:j,onNavigate:x,onLogout:g,user:o}){const m=V(),C=I=>t(N=>({...N,...I})),A=d?{background:"#f9f9f9"}:{},P=!e.name,w=S?"My Profile":P?"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})),T=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:m.saveUser,buttonColor:$.blue,viewMode:d,onEdit:u,darkMode:f,notifCount:y,onToggleDark:p,onCountChange:c,onViewProfile:v,hideSettings:S,onSubmit:h,onBack:j,onNavigate:x,onLogout:g,children:[n.jsxs("div",{style:xs,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:m.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:m.field.management}),n.jsx(ue,{value:e.custom_management,onChange:I=>C({custom_management:I}),items:_,placeholder:"-- Select --",disabled:d})]})]}),n.jsxs("div",{style:xs,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:m.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:m.field.branch}),n.jsx(ue,{value:e.custom_branch,onChange:I=>C({custom_branch:I}),items:T,placeholder:"-- Select --",disabled:d})]})]}),n.jsxs("div",{style:xs,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:m.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:[m.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:xs,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:m.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:m.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:xs,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[m.field.emailAddress," ",P&&n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...d||!P?{background:"#f9f9f9"}:{}},value:e.email,disabled:d||!P,onChange:I=>C({email:I.target.value}),placeholder:"user@example.com",type:"email",required:P})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:m.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:m.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 ou={Active:$.green,Closed:$.gray};function V0({cycles:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=b.useState(""),[u,f]=b.useState(""),[y,p]=b.useState("all"),c=b.useMemo(()=>[...new Set(e.map(o=>o.organization).filter(Boolean))],[e]),v=b.useMemo(()=>e.filter(o=>{const m=(o.name1||o.name||"").toLowerCase();return!(a&&!m.includes(a.toLowerCase())||u&&o.organization!==u||y!=="all"&&o.status!==y)}),[e,a,u,y]),[S,h]=b.useState(1);b.useEffect(()=>{h(1)},[a,u,y]);const j=v.slice((S-1)*ne,S*ne),x=v.filter(o=>o.status==="Active").length,g=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:$.teal}),n.jsx(Ee,{label:"Active",val:x,color:$.green}),n.jsx(Ee,{label:"Closed",val:g,color:$.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})}):j.map((o,m)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(o),style:{borderTop:"1px solid #f0f0f0",background:m%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:ou[o.status]+"22",color:ou[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:S,total:v.length,onPageChange:h})]})}const za={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},e1=["Weekly","Bi-weekly","Monthly","Quarterly","Annually"],t1=["Active","Closed"];function n1({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:S,user:h}){const j=V(),x=m=>t(C=>({...C,...m})),g=r?{background:"#f9f9f9"}:{},o=e.name?r?`${j.formTitle.editCycle}: ${e.name1||e.name}`:j.formTitle.editCycle:j.formTitle.newCycle;return n.jsxs(Me,{title:o,activePage:"cycles",user:h,formStatus:s,buttonText:j.saveCycle,buttonColor:$.teal,viewMode:r,onEdit:i,darkMode:a,notifCount:d,onToggleDark:u,onCountChange:f,onViewProfile:y,onSubmit:p,onBack:c,onNavigate:v,onLogout:S,children:[n.jsxs("div",{style:za,children:[n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[j.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...g},value:e.name1||"",disabled:r||!!e.name,onChange:m=>x({name1:m.target.value}),placeholder:"e.g. Q1-2026"})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:j.field.organization}),n.jsx(Et,{value:e.organization,onChange:m=>x({organization:m}),organizations:l,disabled:r||!!h.custom_organization})]})]}),n.jsxs("div",{style:za,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:j.col.frequency}),n.jsx(ue,{value:e.frequency,onChange:m=>x({frequency:m}),items:e1.map(m=>({name:m,label:m})),placeholder:"-- Select Frequency --",disabled:r})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:j.field.status}),n.jsx(ue,{value:e.status,onChange:m=>x({status:m}),items:t1.map(m=>({name:m,label:m})),placeholder:"-- Select Status --",disabled:r})]})]}),n.jsxs("div",{style:za,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:j.field.dateStart}),n.jsx(me,{value:e.start_date||"",onChange:m=>x({start_date:m}),disabled:r,style:{...E,...g}})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:j.field.dateEnd}),n.jsx(me,{value:e.end_date||"",onChange:m=>x({end_date:m}),disabled:r,style:{...E,...g}})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:j.field.updateWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...E,...g,maxWidth:160},value:e.update_window_days??2,disabled:r,onChange:m=>x({update_window_days:parseInt(m.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 l1({kpiInputs:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=V(),[a,d]=b.useState(""),[u,f]=b.useState(""),y=b.useMemo(()=>[...new Set(e.map(h=>h.organization).filter(Boolean))],[e]),p=b.useMemo(()=>e.filter(h=>{const j=[h.organization,h.period].filter(Boolean).join(" ").toLowerCase();return!(a&&!j.includes(a.toLowerCase())||u&&h.organization!==u)}),[e,a,u]),[c,v]=b.useState(1);b.useEffect(()=>{v(1)},[a,u]);const S=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:$.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(h=>({value:h,label:h}))]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.period}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.field.revenue_growth}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.field.net_profit}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.dash.customerSat}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):S.map((h,j)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:j%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.period||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.revenue_growth!=null?`${h.revenue_growth}%`:"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.net_profit!=null?h.net_profit.toLocaleString():"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.customer_satisfaction!=null?h.customer_satisfaction:"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:x=>x.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:c,total:p.length,onPageChange:v})]})}const cu={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},du={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20};function s1({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:S,user:h}){const j=V(),x=C=>t(A=>({...A,...C})),g=r?{background:"#f9f9f9"}:{},o=C=>A=>x({[C]:parseFloat(A.target.value)||0}),m=e.name?r?`${j.formTitle.editKpi}: ${e.period||e.name}`:j.formTitle.editKpi:j.formTitle.newKpi;return n.jsxs(Me,{title:m,activePage:"kpi-input",user:h,formStatus:s,buttonText:j.saveKpi,buttonColor:$.blue,viewMode:r,onEdit:i,darkMode:a,notifCount:d,onToggleDark:u,onCountChange:f,onViewProfile:y,onSubmit:p,onBack:c,onNavigate:v,onLogout:S,children:[n.jsxs("div",{style:cu,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:j.field.organization}),n.jsx(Et,{value:e.organization,onChange:C=>x({organization:C}),organizations:l,disabled:r||!!h.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[j.col.period," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...E,...g},value:e.period||"",disabled:r,onChange:C=>x({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:du,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:j.field.revenue_growth}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...g},value:e.revenue_growth||"",disabled:r,onChange:o("revenue_growth")})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:j.field.net_profit}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...g},value:e.net_profit||"",disabled:r,onChange:o("net_profit")})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:j.field.cash_flow}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...g},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:du,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:j.field.strategic_goal_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...g},value:e.strategic_goal_pct||"",disabled:r,onChange:o("strategic_goal_pct")})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:j.field.customer_satisfaction}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...g},value:e.customer_satisfaction||"",disabled:r,onChange:o("customer_satisfaction")})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:j.field.employee_turnover_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...g},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:cu,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:j.field.open_safety_incidents}),n.jsx("input",{type:"number",min:0,style:{...E,...g},value:e.open_safety_incidents||"",disabled:r,onChange:C=>x({open_safety_incidents:parseInt(C.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:z,children:j.field.compliance_score}),n.jsx("input",{type:"number",step:"0.01",style:{...E,...g},value:e.compliance_score||"",disabled:r,onChange:o("compliance_score")})]})]})]})]})}const r1={create_processes:"Create Processes",update_process_status:"Update Process Status"},uu={Pending:$.orange,Accepted:$.green,Rejected:$.red,Revoked:$.gray};function i1(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 a1(e){const t=[];return e.create_processes&&t.push("create_processes"),e.update_process_status&&t.push("update_process_status"),t}function o1({delegations:e,organizations:t,userRole:l,currentUser:s,onView:r,onRevoke:i}){const a=V(),[d,u]=b.useState(""),[f,y]=b.useState(""),[p,c]=b.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},S=b.useMemo(()=>e.filter(m=>{const C=`${m.auditor} ${m.manager}`.toLowerCase();return!(d&&!C.includes(d.toLowerCase())||f&&m.organization!==f||p!=="all"&&m.status!==p)}),[e,d,f,p]),[h,j]=b.useState(1);b.useEffect(()=>{j(1)},[d,f,p]);const x=S.slice((h-1)*ne,h*ne),g=S.filter(m=>m.status==="Pending").length,o=S.filter(m=>m.status==="Accepted").length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(Ee,{label:"Total",val:S.length,color:$.purple}),n.jsx(Ee,{label:"Pending",val:g,color:$.orange}),n.jsx(Ee,{label:"Accepted",val:o,color:$.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(m=>({value:m.organization_name||m.name,label:m.organization_name||m.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:S.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:8,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):x.map((m,C)=>{const A=!!i&&(m.status==="Pending"||m.status==="Accepted")&&(l==="Admin"||l==="Auditor"&&m.auditor===s);return n.jsxs("tr",{onClick:()=>r==null?void 0:r(m),style:{borderTop:"1px solid #f0f0f0",background:C%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:m.number||m.name}),n.jsx("td",{style:{padding:"10px 14px"},children:m.auditor}),n.jsx("td",{style:{padding:"10px 14px"},children:m.manager}),n.jsx("td",{style:{padding:"10px 14px"},children:m.organization||"All Organizations"}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:a1(m).map(P=>n.jsx("span",{style:{background:"#ede9fe",color:"#6d28d9",padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600},children:r1[P]||P},P))})}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{background:(uu[m.status]||$.gray)+"22",color:uu[m.status]||$.gray,padding:"3px 10px",borderRadius:12,fontSize:12,fontWeight:700},children:m.status})}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:i1(m.requested_on)}),n.jsx("td",{style:{padding:"8px 14px"},onClick:P=>P.stopPropagation(),children:n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("button",{onClick:()=>r==null?void 0:r(m),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(m.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"})]})})]},m.name)})})]})}),n.jsx(Fe,{page:h,total:S.length,onPageChange:j})]})}const pu={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},fu={Pending:$.orange,Accepted:$.green,Rejected:$.red,Revoked:$.gray};function c1(e){if(!e)return"—";const t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleString()}function d1({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:S,onNavigate:h,onLogout:j,user:x}){var P;const g=V(),o=w=>t(_=>({..._,...w})),m=a?{background:"#f9f9f9"}:{},C=Ql(s,r,"SB Manager").map(w=>({name:w.name,label:w.full_name||w.name})),A=e.name?`${g.formTitle.viewDelegation}${e.number||e.name}`:g.formTitle.newDelegation;return n.jsxs(Me,{title:A,activePage:"delegations",user:x,formStatus:i,buttonText:g.saveDelegation,buttonColor:$.purple,viewMode:a,onEdit:d,darkMode:u,notifCount:f,onToggleDark:y,onCountChange:p,onViewProfile:c,onSubmit:v,onBack:S,onNavigate:h,onLogout:j,children:[a&&e.status&&n.jsx("div",{style:{marginBottom:20},children:n.jsx("span",{style:{background:(fu[e.status]||$.gray)+"22",color:fu[e.status]||$.gray,padding:"5px 14px",borderRadius:14,fontSize:13,fontWeight:700},children:e.status})}),n.jsxs("div",{style:pu,children:[n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.col.auditor}),n.jsx("input",{style:{...E,background:"#f9f9f9"},value:e.auditor||x.name,disabled:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:z,children:[g.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:pu,children:n.jsxs("div",{children:[n.jsx("label",{style:z,children:g.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:[g.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,...m,minHeight:70,resize:"vertical"},value:e.remarks||"",onChange:w=>o({remarks:w.target.value}),placeholder:"Optional note for the Manager…"})]}),a&&(((P=e.delegation_log)==null?void 0:P.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:c1(w.timestamp)}),n.jsx("td",{style:{padding:"8px 14px",color:"#666"},children:w.remarks||"—"})]},w.name||_))})]})})]})]})}const hu={process:"processes-form",order:"orders-form",incident:"incidents-form",idea:"ideas-form"},Ta={process:$.blue,order:$.purple,incident:$.red,idea:$.green,delegation:$.orange};function u1({onNavigate:e,onRefresh:t}){const l=V(),[s,r]=b.useState([]),[i,a]=b.useState(!0),[d,u]=b.useState(""),[f,y]=b.useState(""),p=()=>xy().then(j=>{r(j),a(!1)});b.useEffect(()=>{p()},[]);const c=s.filter(j=>j.requires_action),v=s.filter(j=>!j.requires_action),S=async(j,x)=>{u(j),y("");try{await yy(j,x),await p(),t==null||t()}catch{y(j)}u("")};function h(j,x){return x.length===0?null:n.jsxs("div",{style:{marginBottom:24},children:[n.jsxs("h3",{style:{fontSize:14,fontWeight:700,color:"#555",marginBottom:12,textTransform:"uppercase",letterSpacing:1},children:[j," (",x.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:x.map((g,o)=>{const m=g.type!=="delegation";return n.jsxs("div",{onClick:m?()=>e(hu[g.type],g.name):void 0,style:{background:"white",borderRadius:10,padding:"14px 18px",boxShadow:"0 1px 4px rgba(0,0,0,0.07)",display:"flex",alignItems:"center",gap:16,borderLeft:`4px solid ${Ta[g.type]||$.gray}`,cursor:m?"pointer":"default",transition:"box-shadow 0.15s, transform 0.15s"},onMouseEnter:m?C=>{C.currentTarget.style.boxShadow="0 4px 14px rgba(0,0,0,0.12)",C.currentTarget.style.transform="translateY(-1px)"}:void 0,onMouseLeave:m?C=>{C.currentTarget.style.boxShadow="0 1px 4px rgba(0,0,0,0.07)",C.currentTarget.style.transform="none"}:void 0,children:[n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[n.jsx("span",{style:{fontSize:11,fontWeight:700,color:"white",background:Ta[g.type]||$.gray,padding:"2px 8px",borderRadius:10},children:g.type.toUpperCase()}),n.jsx("span",{style:{fontWeight:700,fontSize:14},children:g.number}),n.jsx("span",{style:{fontSize:13,color:"#333",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.title})]}),n.jsxs("div",{style:{marginTop:4,fontSize:12,color:"#888"},children:[g.action," ",g.organization?`· ${g.organization}`:""," ",g.date?`· ${g.date}`:""]}),f===g.name&&n.jsx("div",{style:{marginTop:4,fontSize:12,color:"#e74c3c"},children:"Failed to respond — please try again."})]}),g.type==="delegation"?n.jsxs("div",{style:{display:"flex",gap:8,flexShrink:0},children:[n.jsx("button",{onClick:()=>S(g.name,"Accepted"),disabled:d===g.name,style:{padding:"7px 16px",borderRadius:8,border:"none",background:$.green,color:"white",fontWeight:600,fontSize:13,cursor:d===g.name?"wait":"pointer",opacity:d===g.name?.6:1},children:"Accept"}),n.jsx("button",{onClick:()=>S(g.name,"Rejected"),disabled:d===g.name,style:{padding:"7px 16px",borderRadius:8,border:"none",background:$.red,color:"white",fontWeight:600,fontSize:13,cursor:d===g.name?"wait":"pointer",opacity:d===g.name?.6:1},children:"Reject"})]}):n.jsx("button",{onClick:C=>{C.stopPropagation(),e(hu[g.type],g.name)},style:{padding:"7px 16px",borderRadius:8,border:"none",background:Ta[g.type]||$.accent,color:"white",fontWeight:600,fontSize:13,cursor:"pointer",flexShrink:0},children:g.requires_action?"Act":l.view})]},o)})})]})}return n.jsxs("div",{style:{maxWidth:900,margin:"0 auto"},children:[i&&n.jsx("p",{style:{color:"#888"},children:l.loading}),!i&&s.length===0&&n.jsxs("div",{style:{background:"white",borderRadius:12,padding:48,textAlign:"center",color:"#aaa",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("div",{style:{fontSize:48,marginBottom:12},children:"📥"}),n.jsx("p",{style:{fontSize:16},children:l.inbox.noMessages})]}),!i&&h("Needs Action",c),!i&&h("Informational",v)]})}const p1=[{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"]}],$f={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 f1(e,t){const l=e.map(r=>$f[r]||r).join(","),s=t.map(r=>e.map(i=>`"${r[i]??""}"`).join(",")).join(`
|
||
`);return l+`
|
||
`+s}function h1(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 Uf="report-print-area",Pa="report-print-portal";function g1(){const e=document.getElementById(Uf);if(!e)return;const t=document.createElement("div");t.id=Pa,t.innerHTML=e.innerHTML,document.body.appendChild(t);const l=document.createElement("style");l.id="report-print-style",l.textContent=`
|
||
#${Pa} { display: none; }
|
||
@media print {
|
||
#root { display: none !important; }
|
||
#${Pa} { display: block !important; }
|
||
}
|
||
`,document.head.appendChild(l);const s=()=>{t.remove(),l.remove(),window.removeEventListener("afterprint",s)};window.addEventListener("afterprint",s),window.print()}const gu={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",minWidth:180},Ia={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white"};function x1({organizations:e,userRole:t}){const l=V(),s=p1.filter(_=>_.roles.includes(t)),[r,i]=b.useState(""),[a,d]=b.useState(""),[u,f]=b.useState(""),[y,p]=b.useState(""),[c,v]=b.useState(String(new Date().getFullYear())),[S,h]=b.useState([]),[j,x]=b.useState([]),[g,o]=b.useState(!1),[m,C]=b.useState(""),A=s.find(_=>_.id===r);async function P(){if(r){o(!0),C(""),x([]),h([]);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 gy(r,_);h(U.columns||[]),x(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 ${$.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:gu,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:gu,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:{...Ia,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:Ia})]}),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:Ia})]})]}),n.jsx("button",{onClick:P,disabled:!r||g,style:{padding:"9px 20px",borderRadius:8,border:"none",background:$.accent,color:"white",fontWeight:700,fontSize:13,cursor:r?"pointer":"not-allowed",opacity:r?1:.5},children:g?l.loading:l.reports.generate}),j.length>0&&n.jsx("button",{onClick:()=>h1(f1(S,j),`${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"}),j.length>0&&n.jsx("button",{onClick:g1,style:{padding:"9px 20px",borderRadius:8,border:"1px solid #888",background:"white",color:"#555",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Print / PDF"})]})}),m&&n.jsx("div",{style:{color:"#e74c3c",marginBottom:16},children:m}),j.length>0&&n.jsxs("div",{id:Uf,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:[j.length," rows"]})]}),n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa"},children:S.map(_=>n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700,whiteSpace:"nowrap"},children:$f[_]||_.replace(/_/g," ").toUpperCase()},_))})}),n.jsx("tbody",{children:j.map((_,U)=>n.jsx("tr",{style:{borderTop:"1px solid #f0f0f0",background:U%2===0?"white":"#fafafa"},children:S.map(T=>n.jsx("td",{style:{padding:"10px 14px",color:"#333"},children:_[T]!=null?String(_[T]):"—"},T))},U))})]})]}),!g&&j.length===0&&r&&!m&&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 dr=()=>new Date().toISOString().split("T")[0],bc=()=>new Date(Date.now()+30*24*60*60*1e3).toISOString().split("T")[0],Vt=()=>({name:"",number:"",title:"",organization:"",type:"",incident_class:"",incident_field:"",date:dr(),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:dr(),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:dr(),ending_date:bc(),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:""}),Ur=()=>({name:"",title:"",date_start:dr(),date_end:bc(),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:""}),ms=()=>({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"}),ys=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),vs=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),js=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),bs=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ss=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ws=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),ks=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),_s=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Fr=()=>({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:dr(),end_date:bc(),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}),Cs=()=>({name:"",number:"",auditor:"",manager:"",organization:"",create_processes:0,update_process_status:0,status:"Pending",requested_on:"",remarks:""}),m1=new Set(["incidents","incidents-form","ideas","ideas-form"]),y1=new Set(["orders","orders-form","incidents","incidents-form","ideas","ideas-form"]),v1=new Set(["Admin","Owner","Auditor","Manager"]),j1=new Set(["Admin","Owner","Auditor","Manager"]),b1=new Set(["Admin","Auditor","Manager"]);function S1({user:e,onLogout:t,darkMode:l,onToggleDark:s}){const r=V(),i=e.role,a=v1.has(i),d=j1.has(i),u=b1.has(i),f=k=>k==="users"||k==="users-form"?i==="Admin":i==="Admin"||i==="Auditor"?!0:i==="Owner"||i==="XAuditor"?!1:i==="Manager"?!!(y1.has(k)||(k==="processes"||k==="processes-form")&&kc.includes("create_processes")):m1.has(k),y=k=>i==="Employee"&&!!k&&k!=="New",[p,c]=b.useState(a?"dashboard":"inbox"),v=e.custom_organization||"",[S,h]=b.useState(""),[j,x]=b.useState("");b.useEffect(()=>{if(!j)return;const k=setTimeout(()=>x(""),0);return()=>clearTimeout(k)},[j]);const g=(k,X)=>{x(X),c(k)},[o,m]=b.useState(0),[C,A]=b.useState([]),[P,w]=b.useState([]),[_,U]=b.useState([]),[T,I]=b.useState([]),[N,M]=b.useState([]),[Z,ge]=b.useState([]),[le,L]=b.useState([]),[K,G]=b.useState([]),[ee,J]=b.useState([]),[xe,_e]=b.useState([]),[re,Ce]=b.useState([]),[Oe,H]=b.useState([]),[se,D]=b.useState([]),[te,hn]=b.useState([]),[gt,O]=b.useState([]),[R,Q]=b.useState([]),[Yt,ur]=b.useState([]),[Bn,Qi]=b.useState([]),[$n,W]=b.useState([]),[Ge,sl]=b.useState({}),[kt,Ff]=b.useState([]),[pr,Mf]=b.useState([]),[Sc,Hf]=b.useState([]),[wc,Kf]=b.useState([]),[kc,Qf]=b.useState([]),[_c,Gf]=b.useState({}),[Se,de]=b.useState(!0),[De,ie]=b.useState("idle"),[Ne,oe]=b.useState(!1),[Cc,zc]=b.useState(!1),[fr,Tc]=b.useState(null),[Yf,Xf]=b.useState(()=>localStorage.getItem("sb_sidebar")==="1"),qf=()=>Xf(k=>{const X=!k;return localStorage.setItem("sb_sidebar",X?"1":"0"),X}),[Jf,Gi]=b.useState(!1);b.useEffect(()=>{Gi(!1)},[p]);const[rl,Xt]=b.useState(Vt()),[il,qt]=b.useState(en()),[hr,Jt]=b.useState(tn()),[gr,Ut]=b.useState(Ur()),[Pc,Jl]=b.useState(ms()),[Ic,al]=b.useState(gl()),[Ec,ol]=b.useState(xl()),[Ac,cl]=b.useState(ml()),[Rc,Zl]=b.useState(ys()),[Lc,Vl]=b.useState(vs()),[Oc,es]=b.useState(js()),[Dc,ts]=b.useState(bs()),[Nc,ns]=b.useState(Ss()),[Wc,ls]=b.useState(ws()),[Bc,ss]=b.useState(ks()),[$c,rs]=b.useState(_s()),[xr,mr]=b.useState(Fr()),[Uc,dl]=b.useState(yl()),[Fc,ul]=b.useState(vl()),[pl,is]=b.useState(Cs()),Ft=async()=>{de(!0);try{const[k,X,xt,At,gn,We,Ji,Qh,Gh,Yh,Xh,qh,Jh,Zh,Vh,eg,tg,ng,lg,sg,rg,ig,ag,og,cg,dg]=await Promise.all([we(B.incidents),we(B.organizations),we(B.ideas),we(B.orders),we(B.processes),Jm(),we(B.managements),we(B.departments),we(B.branches),we(B.incidentTypes),we(B.incidentClass),we(B.incidentField),we(B.ideaTypes),we(B.orderTypes),we(B.processTypes),we(B.incidentStatuses),we(B.ideaStatuses),we(B.orderStatuses),we(B.processStatuses),ty(),ny(),we(B.cycles),we(B.kpiInput),jy(),Sy(),wy()]);A(k||[]),w(X||[]),U(xt||[]),I(At||[]),M(gn||[]),Ff(We||[]),ge(Ji||[]),L(Qh||[]),G(Gh||[]),J(Yh||[]),_e(Xh||[]),Ce(qh||[]),H(Jh||[]),D(Zh||[]),hn(Vh||[]),O(eg||[]),Q(tg||[]),ur(ng||[]),Qi(lg||[]),W(sg||[]),sl(rg||{}),Mf(ig||[]),Hf(ag||[]),Kf(og||[]),Qf(cg||[]),Gf(dg||{})}catch(k){console.error("Error loading data:",k)}de(!1)},Zf=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();m(Number(X.message)||0)}}catch{}};b.useEffect(()=>{Ft(),Zf()},[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 Lf(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)}},Vf=async k=>{try{await iy(k),await Ft()}catch(X){console.error("Disable user error:",X)}},eh=async k=>{oe(!0),de(!0);try{const X=await mt(B.incidents,k.name);Xt({...Vt(),...X})}catch{Xt({...Vt(),...k})}c("incidents-form"),de(!1)},th=async k=>{oe(!0),de(!0);try{const X=await mt(B.ideas,k.name);qt({...en(),...X})}catch{qt({...en(),...k})}c("ideas-form"),de(!1)},nh=async k=>{oe(!0),de(!0);try{const X=await mt(B.orders,k.name);Jt({...tn(),...X})}catch{Jt({...tn(),...k})}c("orders-form"),de(!1)},lh=async k=>{oe(!0),de(!0);try{const X=await Es(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)},sh=k=>ye(B.organizations,k,Jl,ms(),"organizations-form",!0),rh=async k=>{oe(!0),de(!0);try{const X=await mt(B.managements,k.name);al({...gl(),...X})}catch{al({...gl(),...k})}c("managements-form"),de(!1)},ih=async k=>{oe(!0),de(!0);try{const X=await mt(B.departments,k.name);ol({...xl(),...X})}catch{ol({...xl(),...k})}c("departments-form"),de(!1)},ah=async k=>{oe(!0),de(!0);try{const X=await mt(B.branches,k.name);cl({...ml(),...X})}catch{cl({...ml(),...k})}c("branches-form"),de(!1)},oh=async k=>{oe(!0),de(!0);try{const X=await mt(B.cycles,k.name);dl({...yl(),...X})}catch{dl({...yl(),...k})}c("cycles-form"),de(!1)},ch=async k=>{oe(!0),de(!0);try{const X=await mt(B.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 _i(k,X.name,X),ie("success"),Ft(),setTimeout(()=>{ie("idle"),c(At)},1500);else if(gn){const We=await ka(k,X);gn(We),ie("success"),Ft(),setTimeout(()=>ie("idle"),1500)}else await ka(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 Vm(),t()},ye=async(k,X,xt,At,gn,We)=>{oe(We),de(!0);try{const Ji=await mt(k,X.name);xt({...At,...Ji})}catch{xt({...At,...X})}c(gn),de(!1)},dh=k=>ye(B.incidents,k,Xt,Vt(),"incidents-form",!1),uh=k=>ye(B.ideas,k,qt,en(),"ideas-form",!1),ph=k=>ye(B.orders,k,Jt,tn(),"orders-form",!1),fh=k=>{oe(!1),de(!0),Es(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)})},hh=k=>ye(B.organizations,k,Jl,ms(),"organizations-form",!1),gh=k=>ye(B.managements,k,al,gl(),"managements-form",!1),xh=k=>ye(B.departments,k,ol,xl(),"departments-form",!1),mh=k=>ye(B.branches,k,cl,ml(),"branches-form",!1),yh=k=>ye(B.cycles,k,dl,yl(),"cycles-form",!1),vh=k=>ye(B.kpiInput,k,ul,vl(),"kpi-input-form",!1),jh=async k=>{oe(!0),de(!0);try{const X=await by(k.name);is({...Cs(),...X})}catch{is({...Cs(),...k})}c("delegations-form"),de(!1)},bh=async()=>{ie("loading");try{const k=[];pl.create_processes&&k.push("create_processes"),pl.update_process_status&&k.push("update_process_status"),await my(pl.manager,k,pl.organization,pl.remarks),is(Cs()),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.")}},Sh=async k=>{if(window.confirm(r.rtl?"هل أنت متأكد من إلغاء هذا التفويض؟":"Are you sure you want to revoke this delegation?")){de(!0);try{await vy(k),await Ft()}catch(X){console.error("Revoke delegation error:",X),alert(X instanceof Error?X.message:"Revoke failed. Please try again.")}de(!1)}},wh=k=>ye(B.incidentTypes,k,Zl,ys(),"incident-types-form",!0),kh=k=>ye(B.incidentTypes,k,Zl,ys(),"incident-types-form",!1),_h=k=>ye(B.ideaTypes,k,Vl,vs(),"idea-types-form",!0),Ch=k=>ye(B.ideaTypes,k,Vl,vs(),"idea-types-form",!1),zh=k=>ye(B.orderTypes,k,es,js(),"order-types-form",!0),Th=k=>ye(B.orderTypes,k,es,js(),"order-types-form",!1),Ph=k=>ye(B.processTypes,k,ts,bs(),"process-types-form",!0),Ih=k=>ye(B.processTypes,k,ts,bs(),"process-types-form",!1),Eh=k=>ye(B.incidentStatuses,k,ns,Ss(),"incident-statuses-form",!0),Ah=k=>ye(B.incidentStatuses,k,ns,Ss(),"incident-statuses-form",!1),Rh=k=>ye(B.ideaStatuses,k,ls,ws(),"idea-statuses-form",!0),Lh=k=>ye(B.ideaStatuses,k,ls,ws(),"idea-statuses-form",!1),Oh=k=>ye(B.orderStatuses,k,ss,ks(),"order-statuses-form",!0),Dh=k=>ye(B.orderStatuses,k,ss,ks(),"order-statuses-form",!1),Nh=k=>ye(B.processStatuses,k,rs,_s(),"process-statuses-form",!0),Wh=k=>ye(B.processStatuses,k,rs,_s(),"process-statuses-form",!1),Bh=async k=>{Tc(k),c("profile")},$h=k=>{oe(!1),zc(!1),mr({...Fr(),...k}),c("users-form")},Uh=async()=>{ie("loading");try{if(!xr.name)await ka("User",{...xr,send_welcome_email:0,user_type:"System User"});else{const{name:X,email:xt,creation:At,full_name:gn,...We}=xr;await _i("User",X,We)}mr(Fr()),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);Tc(k||{name:e.name,full_name:e.full_name,email:e.name,enabled:1}),c("profile")},Yi=(k,X)=>{if(X){const At={"processes-form":B.processes,"orders-form":B.orders,"incidents-form":B.incidents,"ideas-form":B.ideas}[k];if(At){oe(!0),de(!0),(k==="processes-form"?Es(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(Gy,{incForm:rl,setIncForm:Xt,organizations:P,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:m,onViewProfile:Re,userRole:i,onSubmit:()=>Ye(B.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(B.incidents,rl.name).catch(()=>null);k&&Xt({...Vt(),...k})}we(B.incidents).then(k=>A(k||[])).catch(()=>{})}});if(p==="ideas-form")return n.jsx(Jy,{ideaForm:il,setIdeaForm:qt,organizations:P,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:m,onViewProfile:Re,userRole:i,onSubmit:()=>Ye(B.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(B.ideas,il.name).catch(()=>null);k&&qt({...en(),...k})}we(B.ideas).then(k=>U(k||[])).catch(()=>{})}});if(p==="orders-form")return n.jsx(n0,{orderForm:hr,setOrderForm:Jt,organizations:P,managements:Z,departments:le,branches:K,orderTypes:se,orderStatuses:Yt,cycles:pr,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:m,onViewProfile:Re,currentUser:e.name,userRole:i,onSubmit:()=>Ye(B.orders,hr,()=>Jt(tn()),"orders",k=>Jt({...tn(),...k})),onBack:()=>{c("orders"),ie("idle")},onNavigate:c,onLogout:Ae,user:e,onRefresh:async()=>{if(hr.name){const k=await mt(B.orders,hr.name).catch(()=>null);k&&Jt({...tn(),...k})}we(B.orders).then(k=>I(k||[])).catch(()=>{})}});if(p==="processes-form")return n.jsx(a0,{processForm:gr,setProcessForm:Ut,organizations:P,managements:Z,departments:le,branches:K,processTypes:te,processStatuses:Bn,cycles:pr,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:m,onViewProfile:Re,userRole:e.role,delegatedFunctions:kc,delegatedOrgs:_c.create_processes,onRefreshProcess:async()=>{if(gr.name)try{const k=await Es(gr.name);Ut({...k,progress_indicators:k.progress_indicators||[],cycle_logs:k.cycle_logs||[]})}catch{}we(B.processes).then(k=>M(k||[])).catch(()=>{})},onSubmit:()=>Ye(B.processes,gr,()=>Ut(Ur()),"processes",k=>Ut({...Ur(),...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(f0,{orgForm:Pc,setOrgForm:Jl,formStatus:De,viewMode:Ne||!f("organizations-form"),onEdit:f("organizations-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:m,onViewProfile:Re,onSubmit:()=>Ye(B.organizations,Pc,()=>Jl(ms()),"organizations"),onBack:()=>{c("organizations"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="managements-form")return n.jsx(x0,{form:Ic,setForm:al,organizations:P,formStatus:De,viewMode:Ne||!f("managements-form"),onEdit:f("managements-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:m,onViewProfile:Re,onSubmit:()=>Ye(B.managements,Ic,()=>al(gl()),"managements"),onBack:()=>{c("managements"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="departments-form")return n.jsx(j0,{form:Ec,setForm:ol,organizations:P,managements:Z,formStatus:De,viewMode:Ne||!f("departments-form"),onEdit:f("departments-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:m,onViewProfile:Re,onSubmit:()=>Ye(B.departments,Ec,()=>ol(xl()),"departments"),onBack:()=>{c("departments"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="branches-form")return n.jsx(k0,{form:Ac,setForm:cl,organizations:P,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:m,onViewProfile:Re,onSubmit:()=>Ye(B.branches,Ac,()=>cl(ml()),"branches"),onBack:()=>{c("branches"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="cycles-form")return n.jsx(n1,{form:Uc,setForm:dl,organizations:P,formStatus:De,viewMode:Ne||!f("cycles-form"),onEdit:f("cycles-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:m,onViewProfile:Re,onSubmit:()=>Ye(B.cycles,Uc,()=>dl(yl()),"cycles"),onBack:()=>{c("cycles"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="kpi-input-form")return n.jsx(s1,{form:Fc,setForm:ul,organizations:P,formStatus:De,viewMode:Ne||!f("kpi-input-form"),onEdit:f("kpi-input-form")?()=>oe(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:m,onViewProfile:Re,onSubmit:()=>Ye(B.kpiInput,Fc,()=>ul(vl()),"kpi-input"),onBack:()=>{c("kpi-input"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="incident-types-form")return n.jsx(z0,{form:Rc,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:m,onViewProfile:Re,onSubmit:()=>Ye(B.incidentTypes,Rc,()=>Zl(ys()),"incident-types"),onBack:()=>{c("incident-types"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="idea-types-form")return n.jsx(I0,{form:Lc,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:m,onViewProfile:Re,onSubmit:()=>Ye(B.ideaTypes,Lc,()=>Vl(vs()),"idea-types"),onBack:()=>{c("idea-types"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="order-types-form")return n.jsx(R0,{form:Oc,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:m,onViewProfile:Re,onSubmit:()=>Ye(B.orderTypes,Oc,()=>es(js()),"order-types"),onBack:()=>{c("order-types"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="process-types-form")return n.jsx(D0,{form:Dc,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:m,onViewProfile:Re,onSubmit:()=>Ye(B.processTypes,Dc,()=>ts(bs()),"process-types"),onBack:()=>{c("process-types"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="incident-statuses-form")return n.jsx(B0,{form:Nc,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:m,onViewProfile:Re,onSubmit:()=>Ye(B.incidentStatuses,Nc,()=>ns(Ss()),"incident-statuses"),onBack:()=>{c("incident-statuses"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="idea-statuses-form")return n.jsx(F0,{form:Wc,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:m,onViewProfile:Re,onSubmit:()=>Ye(B.ideaStatuses,Wc,()=>ls(ws()),"idea-statuses"),onBack:()=>{c("idea-statuses"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="order-statuses-form")return n.jsx(K0,{form:Bc,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:m,onViewProfile:Re,onSubmit:()=>Ye(B.orderStatuses,Bc,()=>ss(ks()),"order-statuses"),onBack:()=>{c("order-statuses"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="process-statuses-form")return n.jsx(Y0,{form:$c,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:m,onViewProfile:Re,onSubmit:()=>Ye(B.processStatuses,$c,()=>rs(_s()),"process-statuses"),onBack:()=>{c("process-statuses"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="users-form")return n.jsx(Z0,{form:xr,setForm:mr,organizations:P,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:m,onViewProfile:Re,isSelfProfile:Cc,onSubmit:Uh,onBack:()=>{c(Cc?a?"dashboard":"inbox":"users"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});if(p==="delegations-form")return n.jsx(d1,{form:pl,setForm:is,organizations:P,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:m,onViewProfile:Re,onSubmit:bh,onBack:()=>{c("delegations"),ie("idle")},onNavigate:c,onLogout:Ae,user:e});const Fh=r.pages,Mh={incidents:{color:$.accent,formPage:"incidents-form",reset:()=>Xt({...Vt(),organization:v||S})},ideas:{color:$.teal,formPage:"ideas-form",reset:()=>qt({...en(),organization:v||S})},orders:{color:$.purple,formPage:"orders-form",reset:()=>Jt({...tn(),organization:v||S})},processes:{color:$.blue,formPage:"processes-form",reset:()=>{const k=_c.create_processes,X=v||(i==="Manager"&&k&&k.length===1?k[0]:S);Ut({...Ur(),organization:X})}},organizations:{color:$.accent,formPage:"organizations-form",reset:()=>Jl(ms())},managements:{color:$.blue,formPage:"managements-form",reset:()=>al({...gl(),organization:v||S})},departments:{color:$.teal,formPage:"departments-form",reset:()=>ol({...xl(),custom_organization:v||S})},branches:{color:$.purple,formPage:"branches-form",reset:()=>cl({...ml(),organization:v||S})},cycles:{color:$.teal,formPage:"cycles-form",reset:()=>dl({...yl(),organization:v||S})},"kpi-input":{color:$.blue,formPage:"kpi-input-form",reset:()=>ul({...vl(),organization:v||S})},"incident-types":{color:$.red,formPage:"incident-types-form",reset:()=>Zl(ys())},"idea-types":{color:$.orange,formPage:"idea-types-form",reset:()=>Vl(vs())},"order-types":{color:$.green,formPage:"order-types-form",reset:()=>es(js())},"process-types":{color:$.accent,formPage:"process-types-form",reset:()=>ts(bs())},"incident-statuses":{color:$.red,formPage:"incident-statuses-form",reset:()=>ns(Ss())},"idea-statuses":{color:$.teal,formPage:"idea-statuses-form",reset:()=>ls(ws())},"order-statuses":{color:$.purple,formPage:"order-statuses-form",reset:()=>ss(ks())},"process-statuses":{color:$.blue,formPage:"process-statuses-form",reset:()=>rs(_s())},users:{color:$.blue,formPage:"users-form",reset:()=>{mr(Fr()),zc(!1)}},delegations:{color:$.purple,formPage:"delegations-form",reset:()=>is(Cs())}},Hh={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"},Kh={incidents:C,ideas:_,orders:T,processes:N,organizations:P,managements:Z,departments:le,branches:K,cycles:pr,"kpi-input":Sc,"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:wc},Un=Um[p],Xi=Kh[p],q=f(p),qi=q?Mh[p]:null;return n.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:l?"#0f172a":$.bg},children:[n.jsx(Ef,{collapsed:Yf,onToggleCollapsed:qf,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(Wf,{notifCount:o,darkMode:l,onCountChange:m,onToggleDark:s,onNavigate:Yi,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:Fh[p]||p}),n.jsxs("div",{style:{display:"flex",gap:8},children:[Un&&Xi&&n.jsx("button",{onClick:()=>Gi(!0),style:{background:"#16a34a",color:"white",border:"none",padding:"6px 14px",borderRadius:7,fontSize:12,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"}),qi&&n.jsxs("button",{onClick:()=>{qi.reset(),oe(!1),ie("idle"),c(qi.formPage)},style:{background:"#4f46e5",color:"white",border:"none",padding:"6px 14px",borderRadius:7,fontSize:12,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI"},children:["+ ",Hh[p]||r.new]})]})]}),Un&&Xi&&Jf&&n.jsx(Ym,{title:Un.label,rows:Xi,columns:Un.columns,defaultColumnKeys:Un.defaultColumns,orgField:Un.orgField,organizations:Un.orgField?P:void 0,filenameBase:p,onClose:()=>Gi(!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(Ay,{incidents:C,ideas:_,orders:T,processes:N,organizations:P,incidentStatuses:gt,ideaStatuses:R,orderStatuses:Yt,processStatuses:Bn,selectedOrg:S,onOrgChange:h,onNavigate:Yi,onNavigateStatus:g,userRole:i}),!Se&&p==="inbox"&&n.jsx(u1,{onNavigate:Yi,onRefresh:Ft}),!Se&&p==="reports"&&d&&n.jsx(x1,{organizations:P,userRole:i}),!Se&&p==="incidents"&&n.jsx(Ny,{incidents:C,organizations:P,departments:le,branches:K,incidentStatuses:gt,initialOrg:S,initialStatus:j,onView:eh,onEdit:q?dh:void 0,onDelete:q?k=>He(B.incidents,k):void 0,canModify:q}),!Se&&p==="ideas"&&n.jsx(Yy,{ideas:_,organizations:P,departments:le,branches:K,ideaStatuses:R,initialOrg:S,initialStatus:j,onView:th,onEdit:q?uh:void 0,onDelete:q?k=>He(B.ideas,k):void 0,canModify:q}),!Se&&p==="orders"&&n.jsx(Zy,{orders:T,organizations:P,departments:le,branches:K,orderStatuses:Yt,initialOrg:S,initialStatus:j,onView:nh,onEdit:q?ph:void 0,onDelete:q?k=>He(B.orders,k):void 0,canModify:q}),!Se&&p==="processes"&&n.jsx(l0,{processes:N,organizations:P,departments:le,branches:K,processStatuses:Bn,initialOrg:S,initialStatus:j,onView:lh,onEdit:q?fh:void 0,onDelete:q?k=>He(B.processes,k):void 0,canModify:q}),!Se&&p==="organizations"&&n.jsx(p0,{organizations:P,onView:sh,onEdit:q?hh:void 0,onDelete:q?k=>He(B.organizations,k):void 0,canModify:q}),!Se&&p==="managements"&&n.jsx(g0,{managements:Z,onView:rh,onEdit:q?gh:void 0,onDelete:q?k=>He(B.managements,k):void 0,canModify:q}),!Se&&p==="departments"&&n.jsx(y0,{departments:le,managements:Z,onView:ih,onEdit:q?xh:void 0,onDelete:q?k=>He(B.departments,k):void 0,canModify:q}),!Se&&p==="branches"&&n.jsx(S0,{branches:K,managements:Z,departments:le,onView:ah,onEdit:q?mh:void 0,onDelete:q?k=>He(B.branches,k):void 0,canModify:q}),!Se&&p==="cycles"&&n.jsx(V0,{cycles:pr,canModify:q,onView:oh,onEdit:q?yh:void 0,onDelete:q?k=>He(B.cycles,k):void 0}),!Se&&p==="kpi-input"&&n.jsx(l1,{kpiInputs:Sc,canModify:q,onView:ch,onEdit:q?vh:void 0,onDelete:q?k=>He(B.kpiInput,k):void 0}),!Se&&p==="incident-types"&&n.jsx(C0,{incidentTypes:ee,onView:wh,onEdit:q?kh:void 0,onDelete:q?k=>He(B.incidentTypes,k):void 0,canModify:q}),!Se&&p==="idea-types"&&n.jsx(P0,{ideaTypes:Oe,onView:_h,onEdit:q?Ch:void 0,onDelete:q?k=>He(B.ideaTypes,k):void 0,canModify:q}),!Se&&p==="order-types"&&n.jsx(A0,{orderTypes:se,onView:zh,onEdit:q?Th:void 0,onDelete:q?k=>He(B.orderTypes,k):void 0,canModify:q}),!Se&&p==="process-types"&&n.jsx(O0,{processTypes:te,onView:Ph,onEdit:q?Ih:void 0,onDelete:q?k=>He(B.processTypes,k):void 0,canModify:q}),!Se&&p==="incident-statuses"&&n.jsx(W0,{incidentStatuses:gt,onView:Eh,onEdit:q?Ah:void 0,onDelete:q?k=>He(B.incidentStatuses,k):void 0,canModify:q}),!Se&&p==="idea-statuses"&&n.jsx(U0,{ideaStatuses:R,onView:Rh,onEdit:q?Lh:void 0,onDelete:q?k=>He(B.ideaStatuses,k):void 0,canModify:q}),!Se&&p==="order-statuses"&&n.jsx(H0,{orderStatuses:Yt,onView:Oh,onEdit:q?Dh:void 0,onDelete:q?k=>He(B.orderStatuses,k):void 0,canModify:q}),!Se&&p==="process-statuses"&&n.jsx(G0,{processStatuses:Bn,onView:Nh,onEdit:q?Wh:void 0,onDelete:q?k=>He(B.processStatuses,k):void 0,canModify:q}),!Se&&p==="users"&&n.jsx(J0,{users:$n,roleMap:Ge,onView:Bh,onEdit:q?$h:void 0,onDelete:q?k=>He("User",k):void 0,onDisable:q?Vf:void 0,canModify:q}),!Se&&p==="delegations"&&u&&n.jsx(o1,{delegations:wc,organizations:P,userRole:i,currentUser:e.name,onView:jh,onRevoke:q?Sh:void 0}),p==="profile"&&(()=>{const k=!!fr&&(fr.name===e.name||fr.email===e.name);return n.jsx(c0,{user:e,profileUser:fr,sbUsers:$n,organizations:P,managements:Z,departments:le,branches:K,darkMode:l,canModify:q||k,onBack:()=>c(k?a?"dashboard":"inbox":"users"),onNavigate:c})})()]})]})]})}function w1(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 k1(){const[e,t]=b.useState(()=>{try{const d=localStorage.getItem("sidrah_user");return d?JSON.parse(d):null}catch{return null}}),[l,s]=b.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)};b.useEffect(()=>{document.documentElement.classList.toggle("dark",l)},[]),b.useEffect(()=>{e&&Of().then(async d=>{const u=d||e.name,f=await Nf(u);if(!f.length)return;const y=w1(f),p=await dy();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(S1,{user:e,onLogout:a,darkMode:l,onToggleDark:r}):n.jsx(Cy,{onLogin:i})}Pf(document.getElementById("root")).render(n.jsx(b.StrictMode,{children:n.jsx(k1,{})}));
|