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

53 lines
485 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

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

(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function l(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(r){if(r.ep)return;r.ep=!0;const i=l(r);fetch(r.href,i)}})();var vu={exports:{}},Pi={},ju={exports:{}},ae={};/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ar=Symbol.for("react.element"),hg=Symbol.for("react.portal"),gg=Symbol.for("react.fragment"),xg=Symbol.for("react.strict_mode"),mg=Symbol.for("react.profiler"),yg=Symbol.for("react.provider"),vg=Symbol.for("react.context"),jg=Symbol.for("react.forward_ref"),bg=Symbol.for("react.suspense"),Sg=Symbol.for("react.memo"),wg=Symbol.for("react.lazy"),Kc=Symbol.iterator;function kg(e){return e===null||typeof e!="object"?null:(e=Kc&&e[Kc]||e["@@iterator"],typeof e=="function"?e:null)}var bu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Su=Object.assign,wu={};function us(e,t,l){this.props=e,this.context=t,this.refs=wu,this.updater=l||bu}us.prototype.isReactComponent={};us.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")};us.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function ku(){}ku.prototype=us.prototype;function To(e,t,l){this.props=e,this.context=t,this.refs=wu,this.updater=l||bu}var Po=To.prototype=new ku;Po.constructor=To;Su(Po,us.prototype);Po.isPureReactComponent=!0;var Qc=Array.isArray,_u=Object.prototype.hasOwnProperty,Io={current:null},Cu={key:!0,ref:!0,__self:!0,__source:!0};function zu(e,t,l){var s,r={},i=null,a=null;if(t!=null)for(s in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(i=""+t.key),t)_u.call(t,s)&&!Cu.hasOwnProperty(s)&&(r[s]=t[s]);var d=arguments.length-2;if(d===1)r.children=l;else if(1<d){for(var u=Array(d),f=0;f<d;f++)u[f]=arguments[f+2];r.children=u}if(e&&e.defaultProps)for(s in d=e.defaultProps,d)r[s]===void 0&&(r[s]=d[s]);return{$$typeof:ar,type:e,key:i,ref:a,props:r,_owner:Io.current}}function _g(e,t){return{$$typeof:ar,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Eo(e){return typeof e=="object"&&e!==null&&e.$$typeof===ar}function Cg(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(l){return t[l]})}var Gc=/\/+/g;function ta(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Cg(""+e.key):t.toString(36)}function Qr(e,t,l,s,r){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(i){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case ar:case hg:a=!0}}if(a)return a=e,r=r(a),e=s===""?"."+ta(a,0):s,Qc(r)?(l="",e!=null&&(l=e.replace(Gc,"$&/")+"/"),Qr(r,t,l,"",function(f){return f})):r!=null&&(Eo(r)&&(r=_g(r,l+(!r.key||a&&a.key===r.key?"":(""+r.key).replace(Gc,"$&/")+"/")+e)),t.push(r)),1;if(a=0,s=s===""?".":s+":",Qc(e))for(var d=0;d<e.length;d++){i=e[d];var u=s+ta(i,d);a+=Qr(i,t,l,u,r)}else if(u=kg(e),typeof u=="function")for(e=u.call(e),d=0;!(i=e.next()).done;)i=i.value,u=s+ta(i,d++),a+=Qr(i,t,l,u,r);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return a}function br(e,t,l){if(e==null)return e;var s=[],r=0;return Qr(e,s,"","",function(i){return t.call(l,i,r++)}),s}function zg(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(l){(e._status===0||e._status===-1)&&(e._status=1,e._result=l)},function(l){(e._status===0||e._status===-1)&&(e._status=2,e._result=l)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var at={current:null},Gr={transition:null},Tg={ReactCurrentDispatcher:at,ReactCurrentBatchConfig:Gr,ReactCurrentOwner:Io};function Tu(){throw Error("act(...) is not supported in production builds of React.")}ae.Children={map:br,forEach:function(e,t,l){br(e,function(){t.apply(this,arguments)},l)},count:function(e){var t=0;return br(e,function(){t++}),t},toArray:function(e){return br(e,function(t){return t})||[]},only:function(e){if(!Eo(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ae.Component=us;ae.Fragment=gg;ae.Profiler=mg;ae.PureComponent=To;ae.StrictMode=xg;ae.Suspense=bg;ae.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Tg;ae.act=Tu;ae.cloneElement=function(e,t,l){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var s=Su({},e.props),r=e.key,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=Io.current),t.key!==void 0&&(r=""+t.key),e.type&&e.type.defaultProps)var d=e.type.defaultProps;for(u in t)_u.call(t,u)&&!Cu.hasOwnProperty(u)&&(s[u]=t[u]===void 0&&d!==void 0?d[u]:t[u])}var u=arguments.length-2;if(u===1)s.children=l;else if(1<u){d=Array(u);for(var f=0;f<u;f++)d[f]=arguments[f+2];s.children=d}return{$$typeof:ar,type:e.type,key:r,ref:i,props:s,_owner:a}};ae.createContext=function(e){return e={$$typeof:vg,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:yg,_context:e},e.Consumer=e};ae.createElement=zu;ae.createFactory=function(e){var t=zu.bind(null,e);return t.type=e,t};ae.createRef=function(){return{current:null}};ae.forwardRef=function(e){return{$$typeof:jg,render:e}};ae.isValidElement=Eo;ae.lazy=function(e){return{$$typeof:wg,_payload:{_status:-1,_result:e},_init:zg}};ae.memo=function(e,t){return{$$typeof:Sg,type:e,compare:t===void 0?null:t}};ae.startTransition=function(e){var t=Gr.transition;Gr.transition={};try{e()}finally{Gr.transition=t}};ae.unstable_act=Tu;ae.useCallback=function(e,t){return at.current.useCallback(e,t)};ae.useContext=function(e){return at.current.useContext(e)};ae.useDebugValue=function(){};ae.useDeferredValue=function(e){return at.current.useDeferredValue(e)};ae.useEffect=function(e,t){return at.current.useEffect(e,t)};ae.useId=function(){return at.current.useId()};ae.useImperativeHandle=function(e,t,l){return at.current.useImperativeHandle(e,t,l)};ae.useInsertionEffect=function(e,t){return at.current.useInsertionEffect(e,t)};ae.useLayoutEffect=function(e,t){return at.current.useLayoutEffect(e,t)};ae.useMemo=function(e,t){return at.current.useMemo(e,t)};ae.useReducer=function(e,t,l){return at.current.useReducer(e,t,l)};ae.useRef=function(e){return at.current.useRef(e)};ae.useState=function(e){return at.current.useState(e)};ae.useSyncExternalStore=function(e,t,l){return at.current.useSyncExternalStore(e,t,l)};ae.useTransition=function(){return at.current.useTransition()};ae.version="18.3.1";ju.exports=ae;var j=ju.exports;/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Pg=j,Ig=Symbol.for("react.element"),Eg=Symbol.for("react.fragment"),Ag=Object.prototype.hasOwnProperty,Rg=Pg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Lg={key:!0,ref:!0,__self:!0,__source:!0};function Pu(e,t,l){var s,r={},i=null,a=null;l!==void 0&&(i=""+l),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(a=t.ref);for(s in t)Ag.call(t,s)&&!Lg.hasOwnProperty(s)&&(r[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)r[s]===void 0&&(r[s]=t[s]);return{$$typeof:Ig,type:e,key:i,ref:a,props:r,_owner:Rg.current}}Pi.Fragment=Eg;Pi.jsx=Pu;Pi.jsxs=Pu;vu.exports=Pi;var n=vu.exports,Iu={exports:{}},St={},Eu={exports:{}},Au={};/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/(function(e){function t(L,M){var K=L.length;L.push(M);e:for(;0<K;){var ne=K-1>>>1,q=L[ne];if(0<r(q,M))L[ne]=M,L[K]=q,K=ne;else break e}}function l(L){return L.length===0?null:L[0]}function s(L){if(L.length===0)return null;var M=L[0],K=L.pop();if(K!==M){L[0]=K;e:for(var ne=0,q=L.length,me=q>>>1;ne<me;){var Ce=2*(ne+1)-1,re=L[Ce],ze=Ce+1,he=L[ze];if(0>r(re,K))ze<q&&0>r(he,re)?(L[ne]=he,L[ze]=K,ne=ze):(L[ne]=re,L[Ce]=K,ne=Ce);else if(ze<q&&0>r(he,K))L[ne]=he,L[ze]=K,ne=ze;else break e}}return M}function r(L,M){var K=L.sortIndex-M.sortIndex;return K!==0?K:L.id-M.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var a=Date,d=a.now();e.unstable_now=function(){return a.now()-d}}var u=[],f=[],y=1,p=null,c=3,v=!1,b=!1,g=!1,S=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,m=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function o(L){for(var M=l(f);M!==null;){if(M.callback===null)s(f);else if(M.startTime<=L)s(f),M.sortIndex=M.expirationTime,t(u,M);else break;M=l(f)}}function x(L){if(g=!1,o(L),!b)if(l(u)!==null)b=!0,xe(z);else{var M=l(f);M!==null&&le(x,M.startTime-L)}}function z(L,M){b=!1,g&&(g=!1,h(k),k=-1),v=!0;var K=c;try{for(o(M),p=l(u);p!==null&&(!(p.expirationTime>M)||L&&!I());){var ne=p.callback;if(typeof ne=="function"){p.callback=null,c=p.priorityLevel;var q=ne(p.expirationTime<=M);M=e.unstable_now(),typeof q=="function"?p.callback=q:p===l(u)&&s(u),o(M)}else s(u);p=l(u)}if(p!==null)var me=!0;else{var Ce=l(f);Ce!==null&&le(x,Ce.startTime-M),me=!1}return me}finally{p=null,c=K,v=!1}}var R=!1,P=null,k=-1,C=5,$=-1;function I(){return!(e.unstable_now()-$<C)}function E(){if(P!==null){var L=e.unstable_now();$=L;var M=!0;try{M=P(!0,L)}finally{M?O():(R=!1,P=null)}}else R=!1}var O;if(typeof m=="function")O=function(){m(E)};else if(typeof MessageChannel<"u"){var U=new MessageChannel,V=U.port2;U.port1.onmessage=E,O=function(){V.postMessage(null)}}else O=function(){S(E,0)};function xe(L){P=L,R||(R=!0,O())}function le(L,M){k=S(function(){L(e.unstable_now())},M)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(L){L.callback=null},e.unstable_continueExecution=function(){b||v||(b=!0,xe(z))},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"):C=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 M=3;break;default:M=c}var K=c;c=M;try{return L()}finally{c=K}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(L,M){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var K=c;c=L;try{return M()}finally{c=K}},e.unstable_scheduleCallback=function(L,M,K){var ne=e.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?ne+K:ne):K=ne,L){case 1:var q=-1;break;case 2:q=250;break;case 5:q=1073741823;break;case 4:q=1e4;break;default:q=5e3}return q=K+q,L={id:y++,callback:M,priorityLevel:L,startTime:K,expirationTime:q,sortIndex:-1},K>ne?(L.sortIndex=K,t(f,L),l(u)===null&&L===l(f)&&(g?(h(k),k=-1):g=!0,le(x,K-ne))):(L.sortIndex=q,t(u,L),b||v||(b=!0,xe(z))),L},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(L){var M=c;return function(){var K=c;c=M;try{return L.apply(this,arguments)}finally{c=K}}}})(Au);Eu.exports=Au;var Og=Eu.exports;/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Dg=j,bt=Og;function F(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,l=1;l<arguments.length;l++)t+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var Ru=new Set,Hs={};function ul(e,t){ls(e,t),ls(e+"Capture",t)}function ls(e,t){for(Hs[e]=t,e=0;e<t.length;e++)Ru.add(t[e])}var on=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ra=Object.prototype.hasOwnProperty,Ng=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Yc={},Xc={};function Wg(e){return Ra.call(Xc,e)?!0:Ra.call(Yc,e)?!1:Ng.test(e)?Xc[e]=!0:(Yc[e]=!0,!1)}function Bg(e,t,l,s){if(l!==null&&l.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return s?!1:l!==null?!l.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function $g(e,t,l,s){if(t===null||typeof t>"u"||Bg(e,t,l,s))return!0;if(s)return!1;if(l!==null)switch(l.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function ot(e,t,l,s,r,i,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=s,this.attributeNamespace=r,this.mustUseProperty=l,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=a}var et={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){et[e]=new ot(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];et[t]=new ot(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){et[e]=new ot(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){et[e]=new ot(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){et[e]=new ot(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){et[e]=new ot(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){et[e]=new ot(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){et[e]=new ot(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){et[e]=new ot(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ao=/[\-:]([a-z])/g;function Ro(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Ao,Ro);et[t]=new ot(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Ao,Ro);et[t]=new ot(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Ao,Ro);et[t]=new ot(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){et[e]=new ot(e,1,!1,e.toLowerCase(),null,!1,!1)});et.xlinkHref=new ot("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){et[e]=new ot(e,1,!1,e.toLowerCase(),null,!0,!0)});function Lo(e,t,l,s){var r=et.hasOwnProperty(t)?et[t]:null;(r!==null?r.type!==0:s||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&($g(t,l,r,s)&&(l=null),s||r===null?Wg(t)&&(l===null?e.removeAttribute(t):e.setAttribute(t,""+l)):r.mustUseProperty?e[r.propertyName]=l===null?r.type===3?!1:"":l:(t=r.attributeName,s=r.attributeNamespace,l===null?e.removeAttribute(t):(r=r.type,l=r===3||r===4&&l===!0?"":""+l,s?e.setAttributeNS(s,t,l):e.setAttribute(t,l))))}var pn=Dg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Sr=Symbol.for("react.element"),Wl=Symbol.for("react.portal"),Bl=Symbol.for("react.fragment"),Oo=Symbol.for("react.strict_mode"),La=Symbol.for("react.profiler"),Lu=Symbol.for("react.provider"),Ou=Symbol.for("react.context"),Do=Symbol.for("react.forward_ref"),Oa=Symbol.for("react.suspense"),Da=Symbol.for("react.suspense_list"),No=Symbol.for("react.memo"),mn=Symbol.for("react.lazy"),Du=Symbol.for("react.offscreen"),qc=Symbol.iterator;function xs(e){return e===null||typeof e!="object"?null:(e=qc&&e[qc]||e["@@iterator"],typeof e=="function"?e:null)}var Ie=Object.assign,na;function Is(e){if(na===void 0)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);na=t&&t[1]||""}return`
`+na+e}var la=!1;function sa(e,t){if(!e||la)return"";la=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(f){var s=f}Reflect.construct(e,[],t)}else{try{t.call()}catch(f){s=f}e.call(t.prototype)}else{try{throw Error()}catch(f){s=f}e()}}catch(f){if(f&&s&&typeof f.stack=="string"){for(var r=f.stack.split(`
`),i=s.stack.split(`
`),a=r.length-1,d=i.length-1;1<=a&&0<=d&&r[a]!==i[d];)d--;for(;1<=a&&0<=d;a--,d--)if(r[a]!==i[d]){if(a!==1||d!==1)do if(a--,d--,0>d||r[a]!==i[d]){var u=`
`+r[a].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}while(1<=a&&0<=d);break}}}finally{la=!1,Error.prepareStackTrace=l}return(e=e?e.displayName||e.name:"")?Is(e):""}function Ug(e){switch(e.tag){case 5:return Is(e.type);case 16:return Is("Lazy");case 13:return Is("Suspense");case 19:return Is("SuspenseList");case 0:case 2:case 15:return e=sa(e.type,!1),e;case 11:return e=sa(e.type.render,!1),e;case 1:return e=sa(e.type,!0),e;default:return""}}function Na(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Bl:return"Fragment";case Wl:return"Portal";case La:return"Profiler";case Oo:return"StrictMode";case Oa:return"Suspense";case Da:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Ou:return(e.displayName||"Context")+".Consumer";case Lu:return(e._context.displayName||"Context")+".Provider";case Do:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case No:return t=e.displayName||null,t!==null?t:Na(e.type)||"Memo";case mn:t=e._payload,e=e._init;try{return Na(e(t))}catch{}}return null}function Fg(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Na(t);case 8:return t===Oo?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function An(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Nu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Mg(e){var t=Nu(e)?"checked":"value",l=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),s=""+e[t];if(!e.hasOwnProperty(t)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var r=l.get,i=l.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return r.call(this)},set:function(a){s=""+a,i.call(this,a)}}),Object.defineProperty(e,t,{enumerable:l.enumerable}),{getValue:function(){return s},setValue:function(a){s=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function wr(e){e._valueTracker||(e._valueTracker=Mg(e))}function Wu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var l=t.getValue(),s="";return e&&(s=Nu(e)?e.checked?"true":"false":e.value),e=s,e!==l?(t.setValue(e),!0):!1}function si(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Wa(e,t){var l=t.checked;return Ie({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??e._wrapperState.initialChecked})}function Jc(e,t){var l=t.defaultValue==null?"":t.defaultValue,s=t.checked!=null?t.checked:t.defaultChecked;l=An(t.value!=null?t.value:l),e._wrapperState={initialChecked:s,initialValue:l,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Bu(e,t){t=t.checked,t!=null&&Lo(e,"checked",t,!1)}function Ba(e,t){Bu(e,t);var l=An(t.value),s=t.type;if(l!=null)s==="number"?(l===0&&e.value===""||e.value!=l)&&(e.value=""+l):e.value!==""+l&&(e.value=""+l);else if(s==="submit"||s==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?$a(e,t.type,l):t.hasOwnProperty("defaultValue")&&$a(e,t.type,An(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Zc(e,t,l){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var s=t.type;if(!(s!=="submit"&&s!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,l||t===e.value||(e.value=t),e.defaultValue=t}l=e.name,l!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,l!==""&&(e.name=l)}function $a(e,t,l){(t!=="number"||si(e.ownerDocument)!==e)&&(l==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+l&&(e.defaultValue=""+l))}var Es=Array.isArray;function Jl(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=""+An(l),t=null,r=0;r<e.length;r++){if(e[r].value===l){e[r].selected=!0,s&&(e[r].defaultSelected=!0);return}t!==null||e[r].disabled||(t=e[r])}t!==null&&(t.selected=!0)}}function Ua(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(F(91));return Ie({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Vc(e,t){var l=t.value;if(l==null){if(l=t.children,t=t.defaultValue,l!=null){if(t!=null)throw Error(F(92));if(Es(l)){if(1<l.length)throw Error(F(93));l=l[0]}t=l}t==null&&(t=""),l=t}e._wrapperState={initialValue:An(l)}}function $u(e,t){var l=An(t.value),s=An(t.defaultValue);l!=null&&(l=""+l,l!==e.value&&(e.value=l),t.defaultValue==null&&e.defaultValue!==l&&(e.defaultValue=l)),s!=null&&(e.defaultValue=""+s)}function ed(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Uu(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Fa(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Uu(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var kr,Fu=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,l,s,r){MSApp.execUnsafeLocalFunction(function(){return e(t,l,s,r)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(kr=kr||document.createElement("div"),kr.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=kr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ks(e,t){if(t){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=t;return}}e.textContent=t}var Os={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Hg=["Webkit","ms","Moz","O"];Object.keys(Os).forEach(function(e){Hg.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Os[t]=Os[e]})});function Mu(e,t,l){return t==null||typeof t=="boolean"||t===""?"":l||typeof t!="number"||t===0||Os.hasOwnProperty(e)&&Os[e]?(""+t).trim():t+"px"}function Hu(e,t){e=e.style;for(var l in t)if(t.hasOwnProperty(l)){var s=l.indexOf("--")===0,r=Mu(l,t[l],s);l==="float"&&(l="cssFloat"),s?e.setProperty(l,r):e[l]=r}}var Kg=Ie({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ma(e,t){if(t){if(Kg[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(F(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(F(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(F(61))}if(t.style!=null&&typeof t.style!="object")throw Error(F(62))}}function Ha(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ka=null;function Wo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Qa=null,Zl=null,Vl=null;function td(e){if(e=dr(e)){if(typeof Qa!="function")throw Error(F(280));var t=e.stateNode;t&&(t=Li(t),Qa(e.stateNode,e.type,t))}}function Ku(e){Zl?Vl?Vl.push(e):Vl=[e]:Zl=e}function Qu(){if(Zl){var e=Zl,t=Vl;if(Vl=Zl=null,td(e),t)for(e=0;e<t.length;e++)td(t[e])}}function Gu(e,t){return e(t)}function Yu(){}var ra=!1;function Xu(e,t,l){if(ra)return e(t,l);ra=!0;try{return Gu(e,t,l)}finally{ra=!1,(Zl!==null||Vl!==null)&&(Yu(),Qu())}}function Qs(e,t){var l=e.stateNode;if(l===null)return null;var s=Li(l);if(s===null)return null;l=s[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(s=!s.disabled)||(e=e.type,s=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!s;break e;default:e=!1}if(e)return null;if(l&&typeof l!="function")throw Error(F(231,t,typeof l));return l}var Ga=!1;if(on)try{var ms={};Object.defineProperty(ms,"passive",{get:function(){Ga=!0}}),window.addEventListener("test",ms,ms),window.removeEventListener("test",ms,ms)}catch{Ga=!1}function Qg(e,t,l,s,r,i,a,d,u){var f=Array.prototype.slice.call(arguments,3);try{t.apply(l,f)}catch(y){this.onError(y)}}var Ds=!1,ri=null,ii=!1,Ya=null,Gg={onError:function(e){Ds=!0,ri=e}};function Yg(e,t,l,s,r,i,a,d,u){Ds=!1,ri=null,Qg.apply(Gg,arguments)}function Xg(e,t,l,s,r,i,a,d,u){if(Yg.apply(this,arguments),Ds){if(Ds){var f=ri;Ds=!1,ri=null}else throw Error(F(198));ii||(ii=!0,Ya=f)}}function pl(e){var t=e,l=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(l=t.return),e=t.return;while(e)}return t.tag===3?l:null}function qu(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function nd(e){if(pl(e)!==e)throw Error(F(188))}function qg(e){var t=e.alternate;if(!t){if(t=pl(e),t===null)throw Error(F(188));return t!==e?null:e}for(var l=e,s=t;;){var r=l.return;if(r===null)break;var i=r.alternate;if(i===null){if(s=r.return,s!==null){l=s;continue}break}if(r.child===i.child){for(i=r.child;i;){if(i===l)return nd(r),e;if(i===s)return nd(r),t;i=i.sibling}throw Error(F(188))}if(l.return!==s.return)l=r,s=i;else{for(var a=!1,d=r.child;d;){if(d===l){a=!0,l=r,s=i;break}if(d===s){a=!0,s=r,l=i;break}d=d.sibling}if(!a){for(d=i.child;d;){if(d===l){a=!0,l=i,s=r;break}if(d===s){a=!0,s=i,l=r;break}d=d.sibling}if(!a)throw Error(F(189))}}if(l.alternate!==s)throw Error(F(190))}if(l.tag!==3)throw Error(F(188));return l.stateNode.current===l?e:t}function Ju(e){return e=qg(e),e!==null?Zu(e):null}function Zu(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Zu(e);if(t!==null)return t;e=e.sibling}return null}var Vu=bt.unstable_scheduleCallback,ld=bt.unstable_cancelCallback,Jg=bt.unstable_shouldYield,Zg=bt.unstable_requestPaint,Oe=bt.unstable_now,Vg=bt.unstable_getCurrentPriorityLevel,Bo=bt.unstable_ImmediatePriority,ep=bt.unstable_UserBlockingPriority,ai=bt.unstable_NormalPriority,ex=bt.unstable_LowPriority,tp=bt.unstable_IdlePriority,Ii=null,Qt=null;function tx(e){if(Qt&&typeof Qt.onCommitFiberRoot=="function")try{Qt.onCommitFiberRoot(Ii,e,void 0,(e.current.flags&128)===128)}catch{}}var Bt=Math.clz32?Math.clz32:sx,nx=Math.log,lx=Math.LN2;function sx(e){return e>>>=0,e===0?32:31-(nx(e)/lx|0)|0}var _r=64,Cr=4194304;function As(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function oi(e,t){var l=e.pendingLanes;if(l===0)return 0;var s=0,r=e.suspendedLanes,i=e.pingedLanes,a=l&268435455;if(a!==0){var d=a&~r;d!==0?s=As(d):(i&=a,i!==0&&(s=As(i)))}else a=l&~r,a!==0?s=As(a):i!==0&&(s=As(i));if(s===0)return 0;if(t!==0&&t!==s&&!(t&r)&&(r=s&-s,i=t&-t,r>=i||r===16&&(i&4194240)!==0))return t;if(s&4&&(s|=l&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=s;0<t;)l=31-Bt(t),r=1<<l,s|=e[l],t&=~r;return s}function rx(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ix(e,t){for(var l=e.suspendedLanes,s=e.pingedLanes,r=e.expirationTimes,i=e.pendingLanes;0<i;){var a=31-Bt(i),d=1<<a,u=r[a];u===-1?(!(d&l)||d&s)&&(r[a]=rx(d,t)):u<=t&&(e.expiredLanes|=d),i&=~d}}function Xa(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function np(){var e=_r;return _r<<=1,!(_r&4194240)&&(_r=64),e}function ia(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function or(e,t,l){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Bt(t),e[t]=l}function ax(e,t){var l=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var s=e.eventTimes;for(e=e.expirationTimes;0<l;){var r=31-Bt(l),i=1<<r;t[r]=0,s[r]=-1,e[r]=-1,l&=~i}}function $o(e,t){var l=e.entangledLanes|=t;for(e=e.entanglements;l;){var s=31-Bt(l),r=1<<s;r&t|e[s]&t&&(e[s]|=t),l&=~r}}var ge=0;function lp(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var sp,Uo,rp,ip,ap,qa=!1,zr=[],kn=null,_n=null,Cn=null,Gs=new Map,Ys=new Map,vn=[],ox="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function sd(e,t){switch(e){case"focusin":case"focusout":kn=null;break;case"dragenter":case"dragleave":_n=null;break;case"mouseover":case"mouseout":Cn=null;break;case"pointerover":case"pointerout":Gs.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ys.delete(t.pointerId)}}function ys(e,t,l,s,r,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:l,eventSystemFlags:s,nativeEvent:i,targetContainers:[r]},t!==null&&(t=dr(t),t!==null&&Uo(t)),e):(e.eventSystemFlags|=s,t=e.targetContainers,r!==null&&t.indexOf(r)===-1&&t.push(r),e)}function cx(e,t,l,s,r){switch(t){case"focusin":return kn=ys(kn,e,t,l,s,r),!0;case"dragenter":return _n=ys(_n,e,t,l,s,r),!0;case"mouseover":return Cn=ys(Cn,e,t,l,s,r),!0;case"pointerover":var i=r.pointerId;return Gs.set(i,ys(Gs.get(i)||null,e,t,l,s,r)),!0;case"gotpointercapture":return i=r.pointerId,Ys.set(i,ys(Ys.get(i)||null,e,t,l,s,r)),!0}return!1}function op(e){var t=el(e.target);if(t!==null){var l=pl(t);if(l!==null){if(t=l.tag,t===13){if(t=qu(l),t!==null){e.blockedOn=t,ap(e.priority,function(){rp(l)});return}}else if(t===3&&l.stateNode.current.memoizedState.isDehydrated){e.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Yr(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var l=Ja(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(l===null){l=e.nativeEvent;var s=new l.constructor(l.type,l);Ka=s,l.target.dispatchEvent(s),Ka=null}else return t=dr(l),t!==null&&Uo(t),e.blockedOn=l,!1;t.shift()}return!0}function rd(e,t,l){Yr(e)&&l.delete(t)}function dx(){qa=!1,kn!==null&&Yr(kn)&&(kn=null),_n!==null&&Yr(_n)&&(_n=null),Cn!==null&&Yr(Cn)&&(Cn=null),Gs.forEach(rd),Ys.forEach(rd)}function vs(e,t){e.blockedOn===t&&(e.blockedOn=null,qa||(qa=!0,bt.unstable_scheduleCallback(bt.unstable_NormalPriority,dx)))}function Xs(e){function t(r){return vs(r,e)}if(0<zr.length){vs(zr[0],e);for(var l=1;l<zr.length;l++){var s=zr[l];s.blockedOn===e&&(s.blockedOn=null)}}for(kn!==null&&vs(kn,e),_n!==null&&vs(_n,e),Cn!==null&&vs(Cn,e),Gs.forEach(t),Ys.forEach(t),l=0;l<vn.length;l++)s=vn[l],s.blockedOn===e&&(s.blockedOn=null);for(;0<vn.length&&(l=vn[0],l.blockedOn===null);)op(l),l.blockedOn===null&&vn.shift()}var es=pn.ReactCurrentBatchConfig,ci=!0;function ux(e,t,l,s){var r=ge,i=es.transition;es.transition=null;try{ge=1,Fo(e,t,l,s)}finally{ge=r,es.transition=i}}function px(e,t,l,s){var r=ge,i=es.transition;es.transition=null;try{ge=4,Fo(e,t,l,s)}finally{ge=r,es.transition=i}}function Fo(e,t,l,s){if(ci){var r=Ja(e,t,l,s);if(r===null)xa(e,t,s,di,l),sd(e,s);else if(cx(r,e,t,l,s))s.stopPropagation();else if(sd(e,s),t&4&&-1<ox.indexOf(e)){for(;r!==null;){var i=dr(r);if(i!==null&&sp(i),i=Ja(e,t,l,s),i===null&&xa(e,t,s,di,l),i===r)break;r=i}r!==null&&s.stopPropagation()}else xa(e,t,s,null,l)}}var di=null;function Ja(e,t,l,s){if(di=null,e=Wo(s),e=el(e),e!==null)if(t=pl(e),t===null)e=null;else if(l=t.tag,l===13){if(e=qu(t),e!==null)return e;e=null}else if(l===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return di=e,null}function cp(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Vg()){case Bo:return 1;case ep:return 4;case ai:case ex:return 16;case tp:return 536870912;default:return 16}default:return 16}}var bn=null,Mo=null,Xr=null;function dp(){if(Xr)return Xr;var e,t=Mo,l=t.length,s,r="value"in bn?bn.value:bn.textContent,i=r.length;for(e=0;e<l&&t[e]===r[e];e++);var a=l-e;for(s=1;s<=a&&t[l-s]===r[i-s];s++);return Xr=r.slice(e,1<s?1-s:void 0)}function qr(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Tr(){return!0}function id(){return!1}function wt(e){function t(l,s,r,i,a){this._reactName=l,this._targetInst=r,this.type=s,this.nativeEvent=i,this.target=a,this.currentTarget=null;for(var d in e)e.hasOwnProperty(d)&&(l=e[d],this[d]=l?l(i):i[d]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?Tr:id,this.isPropagationStopped=id,this}return Ie(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Tr)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Tr)},persist:function(){},isPersistent:Tr}),t}var ps={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ho=wt(ps),cr=Ie({},ps,{view:0,detail:0}),fx=wt(cr),aa,oa,js,Ei=Ie({},cr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ko,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==js&&(js&&e.type==="mousemove"?(aa=e.screenX-js.screenX,oa=e.screenY-js.screenY):oa=aa=0,js=e),aa)},movementY:function(e){return"movementY"in e?e.movementY:oa}}),ad=wt(Ei),hx=Ie({},Ei,{dataTransfer:0}),gx=wt(hx),xx=Ie({},cr,{relatedTarget:0}),ca=wt(xx),mx=Ie({},ps,{animationName:0,elapsedTime:0,pseudoElement:0}),yx=wt(mx),vx=Ie({},ps,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),jx=wt(vx),bx=Ie({},ps,{data:0}),od=wt(bx),Sx={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},wx={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},kx={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function _x(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=kx[e])?!!t[e]:!1}function Ko(){return _x}var Cx=Ie({},cr,{key:function(e){if(e.key){var t=Sx[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=qr(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?wx[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ko,charCode:function(e){return e.type==="keypress"?qr(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?qr(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),zx=wt(Cx),Tx=Ie({},Ei,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),cd=wt(Tx),Px=Ie({},cr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ko}),Ix=wt(Px),Ex=Ie({},ps,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ax=wt(Ex),Rx=Ie({},Ei,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Lx=wt(Rx),Ox=[9,13,27,32],Qo=on&&"CompositionEvent"in window,Ns=null;on&&"documentMode"in document&&(Ns=document.documentMode);var Dx=on&&"TextEvent"in window&&!Ns,up=on&&(!Qo||Ns&&8<Ns&&11>=Ns),dd=" ",ud=!1;function pp(e,t){switch(e){case"keyup":return Ox.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function fp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var $l=!1;function Nx(e,t){switch(e){case"compositionend":return fp(t);case"keypress":return t.which!==32?null:(ud=!0,dd);case"textInput":return e=t.data,e===dd&&ud?null:e;default:return null}}function Wx(e,t){if($l)return e==="compositionend"||!Qo&&pp(e,t)?(e=dp(),Xr=Mo=bn=null,$l=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return up&&t.locale!=="ko"?null:t.data;default:return null}}var Bx={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function pd(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Bx[e.type]:t==="textarea"}function hp(e,t,l,s){Ku(s),t=ui(t,"onChange"),0<t.length&&(l=new Ho("onChange","change",null,l,s),e.push({event:l,listeners:t}))}var Ws=null,qs=null;function $x(e){_p(e,0)}function Ai(e){var t=Ml(e);if(Wu(t))return e}function Ux(e,t){if(e==="change")return t}var gp=!1;if(on){var da;if(on){var ua="oninput"in document;if(!ua){var fd=document.createElement("div");fd.setAttribute("oninput","return;"),ua=typeof fd.oninput=="function"}da=ua}else da=!1;gp=da&&(!document.documentMode||9<document.documentMode)}function hd(){Ws&&(Ws.detachEvent("onpropertychange",xp),qs=Ws=null)}function xp(e){if(e.propertyName==="value"&&Ai(qs)){var t=[];hp(t,qs,e,Wo(e)),Xu($x,t)}}function Fx(e,t,l){e==="focusin"?(hd(),Ws=t,qs=l,Ws.attachEvent("onpropertychange",xp)):e==="focusout"&&hd()}function Mx(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Ai(qs)}function Hx(e,t){if(e==="click")return Ai(t)}function Kx(e,t){if(e==="input"||e==="change")return Ai(t)}function Qx(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Ut=typeof Object.is=="function"?Object.is:Qx;function Js(e,t){if(Ut(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var l=Object.keys(e),s=Object.keys(t);if(l.length!==s.length)return!1;for(s=0;s<l.length;s++){var r=l[s];if(!Ra.call(t,r)||!Ut(e[r],t[r]))return!1}return!0}function gd(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function xd(e,t){var l=gd(e);e=0;for(var s;l;){if(l.nodeType===3){if(s=e+l.textContent.length,e<=t&&s>=t)return{node:l,offset:t-e};e=s}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=gd(l)}}function mp(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?mp(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function yp(){for(var e=window,t=si();t instanceof e.HTMLIFrameElement;){try{var l=typeof t.contentWindow.location.href=="string"}catch{l=!1}if(l)e=t.contentWindow;else break;t=si(e.document)}return t}function Go(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Gx(e){var t=yp(),l=e.focusedElem,s=e.selectionRange;if(t!==l&&l&&l.ownerDocument&&mp(l.ownerDocument.documentElement,l)){if(s!==null&&Go(l)){if(t=s.start,e=s.end,e===void 0&&(e=t),"selectionStart"in l)l.selectionStart=t,l.selectionEnd=Math.min(e,l.value.length);else if(e=(t=l.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var r=l.textContent.length,i=Math.min(s.start,r);s=s.end===void 0?i:Math.min(s.end,r),!e.extend&&i>s&&(r=s,s=i,i=r),r=xd(l,i);var a=xd(l,s);r&&a&&(e.rangeCount!==1||e.anchorNode!==r.node||e.anchorOffset!==r.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(r.node,r.offset),e.removeAllRanges(),i>s?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=l;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<t.length;l++)e=t[l],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var Yx=on&&"documentMode"in document&&11>=document.documentMode,Ul=null,Za=null,Bs=null,Va=!1;function md(e,t,l){var s=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Va||Ul==null||Ul!==si(s)||(s=Ul,"selectionStart"in s&&Go(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),Bs&&Js(Bs,s)||(Bs=s,s=ui(Za,"onSelect"),0<s.length&&(t=new Ho("onSelect","select",null,t,l),e.push({event:t,listeners:s}),t.target=Ul)))}function Pr(e,t){var l={};return l[e.toLowerCase()]=t.toLowerCase(),l["Webkit"+e]="webkit"+t,l["Moz"+e]="moz"+t,l}var Fl={animationend:Pr("Animation","AnimationEnd"),animationiteration:Pr("Animation","AnimationIteration"),animationstart:Pr("Animation","AnimationStart"),transitionend:Pr("Transition","TransitionEnd")},pa={},vp={};on&&(vp=document.createElement("div").style,"AnimationEvent"in window||(delete Fl.animationend.animation,delete Fl.animationiteration.animation,delete Fl.animationstart.animation),"TransitionEvent"in window||delete Fl.transitionend.transition);function Ri(e){if(pa[e])return pa[e];if(!Fl[e])return e;var t=Fl[e],l;for(l in t)if(t.hasOwnProperty(l)&&l in vp)return pa[e]=t[l];return e}var jp=Ri("animationend"),bp=Ri("animationiteration"),Sp=Ri("animationstart"),wp=Ri("transitionend"),kp=new Map,yd="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function On(e,t){kp.set(e,t),ul(t,[e])}for(var fa=0;fa<yd.length;fa++){var ha=yd[fa],Xx=ha.toLowerCase(),qx=ha[0].toUpperCase()+ha.slice(1);On(Xx,"on"+qx)}On(jp,"onAnimationEnd");On(bp,"onAnimationIteration");On(Sp,"onAnimationStart");On("dblclick","onDoubleClick");On("focusin","onFocus");On("focusout","onBlur");On(wp,"onTransitionEnd");ls("onMouseEnter",["mouseout","mouseover"]);ls("onMouseLeave",["mouseout","mouseover"]);ls("onPointerEnter",["pointerout","pointerover"]);ls("onPointerLeave",["pointerout","pointerover"]);ul("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));ul("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));ul("onBeforeInput",["compositionend","keypress","textInput","paste"]);ul("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));ul("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));ul("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Rs="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Jx=new Set("cancel close invalid load scroll toggle".split(" ").concat(Rs));function vd(e,t,l){var s=e.type||"unknown-event";e.currentTarget=l,Xg(s,t,void 0,e),e.currentTarget=null}function _p(e,t){t=(t&4)!==0;for(var l=0;l<e.length;l++){var s=e[l],r=s.event;s=s.listeners;e:{var i=void 0;if(t)for(var a=s.length-1;0<=a;a--){var d=s[a],u=d.instance,f=d.currentTarget;if(d=d.listener,u!==i&&r.isPropagationStopped())break e;vd(r,d,f),i=u}else for(a=0;a<s.length;a++){if(d=s[a],u=d.instance,f=d.currentTarget,d=d.listener,u!==i&&r.isPropagationStopped())break e;vd(r,d,f),i=u}}}if(ii)throw e=Ya,ii=!1,Ya=null,e}function be(e,t){var l=t[so];l===void 0&&(l=t[so]=new Set);var s=e+"__bubble";l.has(s)||(Cp(t,e,2,!1),l.add(s))}function ga(e,t,l){var s=0;t&&(s|=4),Cp(l,e,s,t)}var Ir="_reactListening"+Math.random().toString(36).slice(2);function Zs(e){if(!e[Ir]){e[Ir]=!0,Ru.forEach(function(l){l!=="selectionchange"&&(Jx.has(l)||ga(l,!1,e),ga(l,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Ir]||(t[Ir]=!0,ga("selectionchange",!1,t))}}function Cp(e,t,l,s){switch(cp(t)){case 1:var r=ux;break;case 4:r=px;break;default:r=Fo}l=r.bind(null,t,l,e),r=void 0,!Ga||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(r=!0),s?r!==void 0?e.addEventListener(t,l,{capture:!0,passive:r}):e.addEventListener(t,l,!0):r!==void 0?e.addEventListener(t,l,{passive:r}):e.addEventListener(t,l,!1)}function xa(e,t,l,s,r){var i=s;if(!(t&1)&&!(t&2)&&s!==null)e:for(;;){if(s===null)return;var a=s.tag;if(a===3||a===4){var d=s.stateNode.containerInfo;if(d===r||d.nodeType===8&&d.parentNode===r)break;if(a===4)for(a=s.return;a!==null;){var u=a.tag;if((u===3||u===4)&&(u=a.stateNode.containerInfo,u===r||u.nodeType===8&&u.parentNode===r))return;a=a.return}for(;d!==null;){if(a=el(d),a===null)return;if(u=a.tag,u===5||u===6){s=i=a;continue e}d=d.parentNode}}s=s.return}Xu(function(){var f=i,y=Wo(l),p=[];e:{var c=kp.get(e);if(c!==void 0){var v=Ho,b=e;switch(e){case"keypress":if(qr(l)===0)break e;case"keydown":case"keyup":v=zx;break;case"focusin":b="focus",v=ca;break;case"focusout":b="blur",v=ca;break;case"beforeblur":case"afterblur":v=ca;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":v=ad;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":v=gx;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":v=Ix;break;case jp:case bp:case Sp:v=yx;break;case wp:v=Ax;break;case"scroll":v=fx;break;case"wheel":v=Lx;break;case"copy":case"cut":case"paste":v=jx;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":v=cd}var g=(t&4)!==0,S=!g&&e==="scroll",h=g?c!==null?c+"Capture":null:c;g=[];for(var m=f,o;m!==null;){o=m;var x=o.stateNode;if(o.tag===5&&x!==null&&(o=x,h!==null&&(x=Qs(m,h),x!=null&&g.push(Vs(m,x,o)))),S)break;m=m.return}0<g.length&&(c=new v(c,b,null,l,y),p.push({event:c,listeners:g}))}}if(!(t&7)){e:{if(c=e==="mouseover"||e==="pointerover",v=e==="mouseout"||e==="pointerout",c&&l!==Ka&&(b=l.relatedTarget||l.fromElement)&&(el(b)||b[cn]))break e;if((v||c)&&(c=y.window===y?y:(c=y.ownerDocument)?c.defaultView||c.parentWindow:window,v?(b=l.relatedTarget||l.toElement,v=f,b=b?el(b):null,b!==null&&(S=pl(b),b!==S||b.tag!==5&&b.tag!==6)&&(b=null)):(v=null,b=f),v!==b)){if(g=ad,x="onMouseLeave",h="onMouseEnter",m="mouse",(e==="pointerout"||e==="pointerover")&&(g=cd,x="onPointerLeave",h="onPointerEnter",m="pointer"),S=v==null?c:Ml(v),o=b==null?c:Ml(b),c=new g(x,m+"leave",v,l,y),c.target=S,c.relatedTarget=o,x=null,el(y)===f&&(g=new g(h,m+"enter",b,l,y),g.target=o,g.relatedTarget=S,x=g),S=x,v&&b)t:{for(g=v,h=b,m=0,o=g;o;o=zl(o))m++;for(o=0,x=h;x;x=zl(x))o++;for(;0<m-o;)g=zl(g),m--;for(;0<o-m;)h=zl(h),o--;for(;m--;){if(g===h||h!==null&&g===h.alternate)break t;g=zl(g),h=zl(h)}g=null}else g=null;v!==null&&jd(p,c,v,g,!1),b!==null&&S!==null&&jd(p,S,b,g,!0)}}e:{if(c=f?Ml(f):window,v=c.nodeName&&c.nodeName.toLowerCase(),v==="select"||v==="input"&&c.type==="file")var z=Ux;else if(pd(c))if(gp)z=Kx;else{z=Mx;var R=Fx}else(v=c.nodeName)&&v.toLowerCase()==="input"&&(c.type==="checkbox"||c.type==="radio")&&(z=Hx);if(z&&(z=z(e,f))){hp(p,z,l,y);break e}R&&R(e,c,f),e==="focusout"&&(R=c._wrapperState)&&R.controlled&&c.type==="number"&&$a(c,"number",c.value)}switch(R=f?Ml(f):window,e){case"focusin":(pd(R)||R.contentEditable==="true")&&(Ul=R,Za=f,Bs=null);break;case"focusout":Bs=Za=Ul=null;break;case"mousedown":Va=!0;break;case"contextmenu":case"mouseup":case"dragend":Va=!1,md(p,l,y);break;case"selectionchange":if(Yx)break;case"keydown":case"keyup":md(p,l,y)}var P;if(Qo)e:{switch(e){case"compositionstart":var k="onCompositionStart";break e;case"compositionend":k="onCompositionEnd";break e;case"compositionupdate":k="onCompositionUpdate";break e}k=void 0}else $l?pp(e,l)&&(k="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(k="onCompositionStart");k&&(up&&l.locale!=="ko"&&($l||k!=="onCompositionStart"?k==="onCompositionEnd"&&$l&&(P=dp()):(bn=y,Mo="value"in bn?bn.value:bn.textContent,$l=!0)),R=ui(f,k),0<R.length&&(k=new od(k,e,null,l,y),p.push({event:k,listeners:R}),P?k.data=P:(P=fp(l),P!==null&&(k.data=P)))),(P=Dx?Nx(e,l):Wx(e,l))&&(f=ui(f,"onBeforeInput"),0<f.length&&(y=new od("onBeforeInput","beforeinput",null,l,y),p.push({event:y,listeners:f}),y.data=P))}_p(p,t)})}function Vs(e,t,l){return{instance:e,listener:t,currentTarget:l}}function ui(e,t){for(var l=t+"Capture",s=[];e!==null;){var r=e,i=r.stateNode;r.tag===5&&i!==null&&(r=i,i=Qs(e,l),i!=null&&s.unshift(Vs(e,i,r)),i=Qs(e,t),i!=null&&s.push(Vs(e,i,r))),e=e.return}return s}function zl(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function jd(e,t,l,s,r){for(var i=t._reactName,a=[];l!==null&&l!==s;){var d=l,u=d.alternate,f=d.stateNode;if(u!==null&&u===s)break;d.tag===5&&f!==null&&(d=f,r?(u=Qs(l,i),u!=null&&a.unshift(Vs(l,u,d))):r||(u=Qs(l,i),u!=null&&a.push(Vs(l,u,d)))),l=l.return}a.length!==0&&e.push({event:t,listeners:a})}var Zx=/\r\n?/g,Vx=/\u0000|\uFFFD/g;function bd(e){return(typeof e=="string"?e:""+e).replace(Zx,`
`).replace(Vx,"")}function Er(e,t,l){if(t=bd(t),bd(e)!==t&&l)throw Error(F(425))}function pi(){}var eo=null,to=null;function no(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var lo=typeof setTimeout=="function"?setTimeout:void 0,em=typeof clearTimeout=="function"?clearTimeout:void 0,Sd=typeof Promise=="function"?Promise:void 0,tm=typeof queueMicrotask=="function"?queueMicrotask:typeof Sd<"u"?function(e){return Sd.resolve(null).then(e).catch(nm)}:lo;function nm(e){setTimeout(function(){throw e})}function ma(e,t){var l=t,s=0;do{var r=l.nextSibling;if(e.removeChild(l),r&&r.nodeType===8)if(l=r.data,l==="/$"){if(s===0){e.removeChild(r),Xs(t);return}s--}else l!=="$"&&l!=="$?"&&l!=="$!"||s++;l=r}while(l);Xs(t)}function zn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function wd(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var l=e.data;if(l==="$"||l==="$!"||l==="$?"){if(t===0)return e;t--}else l==="/$"&&t++}e=e.previousSibling}return null}var fs=Math.random().toString(36).slice(2),Kt="__reactFiber$"+fs,er="__reactProps$"+fs,cn="__reactContainer$"+fs,so="__reactEvents$"+fs,lm="__reactListeners$"+fs,sm="__reactHandles$"+fs;function el(e){var t=e[Kt];if(t)return t;for(var l=e.parentNode;l;){if(t=l[cn]||l[Kt]){if(l=t.alternate,t.child!==null||l!==null&&l.child!==null)for(e=wd(e);e!==null;){if(l=e[Kt])return l;e=wd(e)}return t}e=l,l=e.parentNode}return null}function dr(e){return e=e[Kt]||e[cn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Ml(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(F(33))}function Li(e){return e[er]||null}var ro=[],Hl=-1;function Dn(e){return{current:e}}function Se(e){0>Hl||(e.current=ro[Hl],ro[Hl]=null,Hl--)}function je(e,t){Hl++,ro[Hl]=e.current,e.current=t}var Rn={},st=Dn(Rn),pt=Dn(!1),rl=Rn;function ss(e,t){var l=e.type.contextTypes;if(!l)return Rn;var s=e.stateNode;if(s&&s.__reactInternalMemoizedUnmaskedChildContext===t)return s.__reactInternalMemoizedMaskedChildContext;var r={},i;for(i in l)r[i]=t[i];return s&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=r),r}function ft(e){return e=e.childContextTypes,e!=null}function fi(){Se(pt),Se(st)}function kd(e,t,l){if(st.current!==Rn)throw Error(F(168));je(st,t),je(pt,l)}function zp(e,t,l){var s=e.stateNode;if(t=t.childContextTypes,typeof s.getChildContext!="function")return l;s=s.getChildContext();for(var r in s)if(!(r in t))throw Error(F(108,Fg(e)||"Unknown",r));return Ie({},l,s)}function hi(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Rn,rl=st.current,je(st,e),je(pt,pt.current),!0}function _d(e,t,l){var s=e.stateNode;if(!s)throw Error(F(169));l?(e=zp(e,t,rl),s.__reactInternalMemoizedMergedChildContext=e,Se(pt),Se(st),je(st,e)):Se(pt),je(pt,l)}var ln=null,Oi=!1,ya=!1;function Tp(e){ln===null?ln=[e]:ln.push(e)}function rm(e){Oi=!0,Tp(e)}function Nn(){if(!ya&&ln!==null){ya=!0;var e=0,t=ge;try{var l=ln;for(ge=1;e<l.length;e++){var s=l[e];do s=s(!0);while(s!==null)}ln=null,Oi=!1}catch(r){throw ln!==null&&(ln=ln.slice(e+1)),Vu(Bo,Nn),r}finally{ge=t,ya=!1}}return null}var Kl=[],Ql=0,gi=null,xi=0,_t=[],Ct=0,il=null,sn=1,rn="";function Zn(e,t){Kl[Ql++]=xi,Kl[Ql++]=gi,gi=e,xi=t}function Pp(e,t,l){_t[Ct++]=sn,_t[Ct++]=rn,_t[Ct++]=il,il=e;var s=sn;e=rn;var r=32-Bt(s)-1;s&=~(1<<r),l+=1;var i=32-Bt(t)+r;if(30<i){var a=r-r%5;i=(s&(1<<a)-1).toString(32),s>>=a,r-=a,sn=1<<32-Bt(t)+r|l<<r|s,rn=i+e}else sn=1<<i|l<<r|s,rn=e}function Yo(e){e.return!==null&&(Zn(e,1),Pp(e,1,0))}function Xo(e){for(;e===gi;)gi=Kl[--Ql],Kl[Ql]=null,xi=Kl[--Ql],Kl[Ql]=null;for(;e===il;)il=_t[--Ct],_t[Ct]=null,rn=_t[--Ct],_t[Ct]=null,sn=_t[--Ct],_t[Ct]=null}var jt=null,vt=null,_e=!1,Nt=null;function Ip(e,t){var l=zt(5,null,null,0);l.elementType="DELETED",l.stateNode=t,l.return=e,t=e.deletions,t===null?(e.deletions=[l],e.flags|=16):t.push(l)}function Cd(e,t){switch(e.tag){case 5:var l=e.type;return t=t.nodeType!==1||l.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,jt=e,vt=zn(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=il!==null?{id:sn,overflow:rn}:null,e.memoizedState={dehydrated:t,treeContext:l,retryLane:1073741824},l=zt(18,null,null,0),l.stateNode=t,l.return=e,e.child=l,jt=e,vt=null,!0):!1;default:return!1}}function io(e){return(e.mode&1)!==0&&(e.flags&128)===0}function ao(e){if(_e){var t=vt;if(t){var l=t;if(!Cd(e,t)){if(io(e))throw Error(F(418));t=zn(l.nextSibling);var s=jt;t&&Cd(e,t)?Ip(s,l):(e.flags=e.flags&-4097|2,_e=!1,jt=e)}}else{if(io(e))throw Error(F(418));e.flags=e.flags&-4097|2,_e=!1,jt=e}}}function zd(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;jt=e}function Ar(e){if(e!==jt)return!1;if(!_e)return zd(e),_e=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!no(e.type,e.memoizedProps)),t&&(t=vt)){if(io(e))throw Ep(),Error(F(418));for(;t;)Ip(e,t),t=zn(t.nextSibling)}if(zd(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(F(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var l=e.data;if(l==="/$"){if(t===0){vt=zn(e.nextSibling);break e}t--}else l!=="$"&&l!=="$!"&&l!=="$?"||t++}e=e.nextSibling}vt=null}}else vt=jt?zn(e.stateNode.nextSibling):null;return!0}function Ep(){for(var e=vt;e;)e=zn(e.nextSibling)}function rs(){vt=jt=null,_e=!1}function qo(e){Nt===null?Nt=[e]:Nt.push(e)}var im=pn.ReactCurrentBatchConfig;function bs(e,t,l){if(e=l.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(F(309));var s=l.stateNode}if(!s)throw Error(F(147,e));var r=s,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(a){var d=r.refs;a===null?delete d[i]:d[i]=a},t._stringRef=i,t)}if(typeof e!="string")throw Error(F(284));if(!l._owner)throw Error(F(290,e))}return e}function Rr(e,t){throw e=Object.prototype.toString.call(t),Error(F(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Td(e){var t=e._init;return t(e._payload)}function Ap(e){function t(h,m){if(e){var o=h.deletions;o===null?(h.deletions=[m],h.flags|=16):o.push(m)}}function l(h,m){if(!e)return null;for(;m!==null;)t(h,m),m=m.sibling;return null}function s(h,m){for(h=new Map;m!==null;)m.key!==null?h.set(m.key,m):h.set(m.index,m),m=m.sibling;return h}function r(h,m){return h=En(h,m),h.index=0,h.sibling=null,h}function i(h,m,o){return h.index=o,e?(o=h.alternate,o!==null?(o=o.index,o<m?(h.flags|=2,m):o):(h.flags|=2,m)):(h.flags|=1048576,m)}function a(h){return e&&h.alternate===null&&(h.flags|=2),h}function d(h,m,o,x){return m===null||m.tag!==6?(m=_a(o,h.mode,x),m.return=h,m):(m=r(m,o),m.return=h,m)}function u(h,m,o,x){var z=o.type;return z===Bl?y(h,m,o.props.children,x,o.key):m!==null&&(m.elementType===z||typeof z=="object"&&z!==null&&z.$$typeof===mn&&Td(z)===m.type)?(x=r(m,o.props),x.ref=bs(h,m,o),x.return=h,x):(x=li(o.type,o.key,o.props,null,h.mode,x),x.ref=bs(h,m,o),x.return=h,x)}function f(h,m,o,x){return m===null||m.tag!==4||m.stateNode.containerInfo!==o.containerInfo||m.stateNode.implementation!==o.implementation?(m=Ca(o,h.mode,x),m.return=h,m):(m=r(m,o.children||[]),m.return=h,m)}function y(h,m,o,x,z){return m===null||m.tag!==7?(m=sl(o,h.mode,x,z),m.return=h,m):(m=r(m,o),m.return=h,m)}function p(h,m,o){if(typeof m=="string"&&m!==""||typeof m=="number")return m=_a(""+m,h.mode,o),m.return=h,m;if(typeof m=="object"&&m!==null){switch(m.$$typeof){case Sr:return o=li(m.type,m.key,m.props,null,h.mode,o),o.ref=bs(h,null,m),o.return=h,o;case Wl:return m=Ca(m,h.mode,o),m.return=h,m;case mn:var x=m._init;return p(h,x(m._payload),o)}if(Es(m)||xs(m))return m=sl(m,h.mode,o,null),m.return=h,m;Rr(h,m)}return null}function c(h,m,o,x){var z=m!==null?m.key:null;if(typeof o=="string"&&o!==""||typeof o=="number")return z!==null?null:d(h,m,""+o,x);if(typeof o=="object"&&o!==null){switch(o.$$typeof){case Sr:return o.key===z?u(h,m,o,x):null;case Wl:return o.key===z?f(h,m,o,x):null;case mn:return z=o._init,c(h,m,z(o._payload),x)}if(Es(o)||xs(o))return z!==null?null:y(h,m,o,x,null);Rr(h,o)}return null}function v(h,m,o,x,z){if(typeof x=="string"&&x!==""||typeof x=="number")return h=h.get(o)||null,d(m,h,""+x,z);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Sr:return h=h.get(x.key===null?o:x.key)||null,u(m,h,x,z);case Wl:return h=h.get(x.key===null?o:x.key)||null,f(m,h,x,z);case mn:var R=x._init;return v(h,m,o,R(x._payload),z)}if(Es(x)||xs(x))return h=h.get(o)||null,y(m,h,x,z,null);Rr(m,x)}return null}function b(h,m,o,x){for(var z=null,R=null,P=m,k=m=0,C=null;P!==null&&k<o.length;k++){P.index>k?(C=P,P=null):C=P.sibling;var $=c(h,P,o[k],x);if($===null){P===null&&(P=C);break}e&&P&&$.alternate===null&&t(h,P),m=i($,m,k),R===null?z=$:R.sibling=$,R=$,P=C}if(k===o.length)return l(h,P),_e&&Zn(h,k),z;if(P===null){for(;k<o.length;k++)P=p(h,o[k],x),P!==null&&(m=i(P,m,k),R===null?z=P:R.sibling=P,R=P);return _e&&Zn(h,k),z}for(P=s(h,P);k<o.length;k++)C=v(P,h,k,o[k],x),C!==null&&(e&&C.alternate!==null&&P.delete(C.key===null?k:C.key),m=i(C,m,k),R===null?z=C:R.sibling=C,R=C);return e&&P.forEach(function(I){return t(h,I)}),_e&&Zn(h,k),z}function g(h,m,o,x){var z=xs(o);if(typeof z!="function")throw Error(F(150));if(o=z.call(o),o==null)throw Error(F(151));for(var R=z=null,P=m,k=m=0,C=null,$=o.next();P!==null&&!$.done;k++,$=o.next()){P.index>k?(C=P,P=null):C=P.sibling;var I=c(h,P,$.value,x);if(I===null){P===null&&(P=C);break}e&&P&&I.alternate===null&&t(h,P),m=i(I,m,k),R===null?z=I:R.sibling=I,R=I,P=C}if($.done)return l(h,P),_e&&Zn(h,k),z;if(P===null){for(;!$.done;k++,$=o.next())$=p(h,$.value,x),$!==null&&(m=i($,m,k),R===null?z=$:R.sibling=$,R=$);return _e&&Zn(h,k),z}for(P=s(h,P);!$.done;k++,$=o.next())$=v(P,h,k,$.value,x),$!==null&&(e&&$.alternate!==null&&P.delete($.key===null?k:$.key),m=i($,m,k),R===null?z=$:R.sibling=$,R=$);return e&&P.forEach(function(E){return t(h,E)}),_e&&Zn(h,k),z}function S(h,m,o,x){if(typeof o=="object"&&o!==null&&o.type===Bl&&o.key===null&&(o=o.props.children),typeof o=="object"&&o!==null){switch(o.$$typeof){case Sr:e:{for(var z=o.key,R=m;R!==null;){if(R.key===z){if(z=o.type,z===Bl){if(R.tag===7){l(h,R.sibling),m=r(R,o.props.children),m.return=h,h=m;break e}}else if(R.elementType===z||typeof z=="object"&&z!==null&&z.$$typeof===mn&&Td(z)===R.type){l(h,R.sibling),m=r(R,o.props),m.ref=bs(h,R,o),m.return=h,h=m;break e}l(h,R);break}else t(h,R);R=R.sibling}o.type===Bl?(m=sl(o.props.children,h.mode,x,o.key),m.return=h,h=m):(x=li(o.type,o.key,o.props,null,h.mode,x),x.ref=bs(h,m,o),x.return=h,h=x)}return a(h);case Wl:e:{for(R=o.key;m!==null;){if(m.key===R)if(m.tag===4&&m.stateNode.containerInfo===o.containerInfo&&m.stateNode.implementation===o.implementation){l(h,m.sibling),m=r(m,o.children||[]),m.return=h,h=m;break e}else{l(h,m);break}else t(h,m);m=m.sibling}m=Ca(o,h.mode,x),m.return=h,h=m}return a(h);case mn:return R=o._init,S(h,m,R(o._payload),x)}if(Es(o))return b(h,m,o,x);if(xs(o))return g(h,m,o,x);Rr(h,o)}return typeof o=="string"&&o!==""||typeof o=="number"?(o=""+o,m!==null&&m.tag===6?(l(h,m.sibling),m=r(m,o),m.return=h,h=m):(l(h,m),m=_a(o,h.mode,x),m.return=h,h=m),a(h)):l(h,m)}return S}var is=Ap(!0),Rp=Ap(!1),mi=Dn(null),yi=null,Gl=null,Jo=null;function Zo(){Jo=Gl=yi=null}function Vo(e){var t=mi.current;Se(mi),e._currentValue=t}function oo(e,t,l){for(;e!==null;){var s=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,s!==null&&(s.childLanes|=t)):s!==null&&(s.childLanes&t)!==t&&(s.childLanes|=t),e===l)break;e=e.return}}function ts(e,t){yi=e,Jo=Gl=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ut=!0),e.firstContext=null)}function Pt(e){var t=e._currentValue;if(Jo!==e)if(e={context:e,memoizedValue:t,next:null},Gl===null){if(yi===null)throw Error(F(308));Gl=e,yi.dependencies={lanes:0,firstContext:e}}else Gl=Gl.next=e;return t}var tl=null;function ec(e){tl===null?tl=[e]:tl.push(e)}function Lp(e,t,l,s){var r=t.interleaved;return r===null?(l.next=l,ec(t)):(l.next=r.next,r.next=l),t.interleaved=l,dn(e,s)}function dn(e,t){e.lanes|=t;var l=e.alternate;for(l!==null&&(l.lanes|=t),l=e,e=e.return;e!==null;)e.childLanes|=t,l=e.alternate,l!==null&&(l.childLanes|=t),l=e,e=e.return;return l.tag===3?l.stateNode:null}var yn=!1;function tc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Op(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function an(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Tn(e,t,l){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,pe&2){var r=s.pending;return r===null?t.next=t:(t.next=r.next,r.next=t),s.pending=t,dn(e,l)}return r=s.interleaved,r===null?(t.next=t,ec(s)):(t.next=r.next,r.next=t),s.interleaved=t,dn(e,l)}function Jr(e,t,l){if(t=t.updateQueue,t!==null&&(t=t.shared,(l&4194240)!==0)){var s=t.lanes;s&=e.pendingLanes,l|=s,t.lanes=l,$o(e,l)}}function Pd(e,t){var l=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,l===s)){var r=null,i=null;if(l=l.firstBaseUpdate,l!==null){do{var a={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};i===null?r=i=a:i=i.next=a,l=l.next}while(l!==null);i===null?r=i=t:i=i.next=t}else r=i=t;l={baseState:s.baseState,firstBaseUpdate:r,lastBaseUpdate:i,shared:s.shared,effects:s.effects},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=t:e.next=t,l.lastBaseUpdate=t}function vi(e,t,l,s){var r=e.updateQueue;yn=!1;var i=r.firstBaseUpdate,a=r.lastBaseUpdate,d=r.shared.pending;if(d!==null){r.shared.pending=null;var u=d,f=u.next;u.next=null,a===null?i=f:a.next=f,a=u;var y=e.alternate;y!==null&&(y=y.updateQueue,d=y.lastBaseUpdate,d!==a&&(d===null?y.firstBaseUpdate=f:d.next=f,y.lastBaseUpdate=u))}if(i!==null){var p=r.baseState;a=0,y=f=u=null,d=i;do{var c=d.lane,v=d.eventTime;if((s&c)===c){y!==null&&(y=y.next={eventTime:v,lane:0,tag:d.tag,payload:d.payload,callback:d.callback,next:null});e:{var b=e,g=d;switch(c=t,v=l,g.tag){case 1:if(b=g.payload,typeof b=="function"){p=b.call(v,p,c);break e}p=b;break e;case 3:b.flags=b.flags&-65537|128;case 0:if(b=g.payload,c=typeof b=="function"?b.call(v,p,c):b,c==null)break e;p=Ie({},p,c);break e;case 2:yn=!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);ol|=a,e.lanes=a,e.memoizedState=p}}function Id(e,t,l){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var s=e[t],r=s.callback;if(r!==null){if(s.callback=null,s=l,typeof r!="function")throw Error(F(191,r));r.call(s)}}}var ur={},Gt=Dn(ur),tr=Dn(ur),nr=Dn(ur);function nl(e){if(e===ur)throw Error(F(174));return e}function nc(e,t){switch(je(nr,t),je(tr,e),je(Gt,ur),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Fa(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Fa(t,e)}Se(Gt),je(Gt,t)}function as(){Se(Gt),Se(tr),Se(nr)}function Dp(e){nl(nr.current);var t=nl(Gt.current),l=Fa(t,e.type);t!==l&&(je(tr,e),je(Gt,l))}function lc(e){tr.current===e&&(Se(Gt),Se(tr))}var Te=Dn(0);function ji(e){for(var t=e;t!==null;){if(t.tag===13){var l=t.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var va=[];function sc(){for(var e=0;e<va.length;e++)va[e]._workInProgressVersionPrimary=null;va.length=0}var Zr=pn.ReactCurrentDispatcher,ja=pn.ReactCurrentBatchConfig,al=0,Pe=null,Ke=null,Xe=null,bi=!1,$s=!1,lr=0,am=0;function tt(){throw Error(F(321))}function rc(e,t){if(t===null)return!1;for(var l=0;l<t.length&&l<e.length;l++)if(!Ut(e[l],t[l]))return!1;return!0}function ic(e,t,l,s,r,i){if(al=i,Pe=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Zr.current=e===null||e.memoizedState===null?um:pm,e=l(s,r),$s){i=0;do{if($s=!1,lr=0,25<=i)throw Error(F(301));i+=1,Xe=Ke=null,t.updateQueue=null,Zr.current=fm,e=l(s,r)}while($s)}if(Zr.current=Si,t=Ke!==null&&Ke.next!==null,al=0,Xe=Ke=Pe=null,bi=!1,t)throw Error(F(300));return e}function ac(){var e=lr!==0;return lr=0,e}function Ht(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Xe===null?Pe.memoizedState=Xe=e:Xe=Xe.next=e,Xe}function It(){if(Ke===null){var e=Pe.alternate;e=e!==null?e.memoizedState:null}else e=Ke.next;var t=Xe===null?Pe.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?Pe.memoizedState=Xe=e:Xe=Xe.next=e}return Xe}function sr(e,t){return typeof t=="function"?t(e):t}function ba(e){var t=It(),l=t.queue;if(l===null)throw Error(F(311));l.lastRenderedReducer=e;var s=Ke,r=s.baseQueue,i=l.pending;if(i!==null){if(r!==null){var a=r.next;r.next=i.next,i.next=a}s.baseQueue=r=i,l.pending=null}if(r!==null){i=r.next,s=s.baseState;var d=a=null,u=null,f=i;do{var y=f.lane;if((al&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,Pe.lanes|=y,ol|=y}f=f.next}while(f!==null&&f!==i);u===null?a=s:u.next=d,Ut(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,Pe.lanes|=i,ol|=i,r=r.next;while(r!==e)}else r===null&&(l.lanes=0);return[t.memoizedState,l.dispatch]}function Sa(e){var t=It(),l=t.queue;if(l===null)throw Error(F(311));l.lastRenderedReducer=e;var s=l.dispatch,r=l.pending,i=t.memoizedState;if(r!==null){l.pending=null;var a=r=r.next;do i=e(i,a.action),a=a.next;while(a!==r);Ut(i,t.memoizedState)||(ut=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),l.lastRenderedState=i}return[i,s]}function Np(){}function Wp(e,t){var l=Pe,s=It(),r=t(),i=!Ut(s.memoizedState,r);if(i&&(s.memoizedState=r,ut=!0),s=s.queue,oc(Up.bind(null,l,s,e),[e]),s.getSnapshot!==t||i||Xe!==null&&Xe.memoizedState.tag&1){if(l.flags|=2048,rr(9,$p.bind(null,l,s,r,t),void 0,null),qe===null)throw Error(F(349));al&30||Bp(l,t,r)}return r}function Bp(e,t,l){e.flags|=16384,e={getSnapshot:t,value:l},t=Pe.updateQueue,t===null?(t={lastEffect:null,stores:null},Pe.updateQueue=t,t.stores=[e]):(l=t.stores,l===null?t.stores=[e]:l.push(e))}function $p(e,t,l,s){t.value=l,t.getSnapshot=s,Fp(t)&&Mp(e)}function Up(e,t,l){return l(function(){Fp(t)&&Mp(e)})}function Fp(e){var t=e.getSnapshot;e=e.value;try{var l=t();return!Ut(e,l)}catch{return!0}}function Mp(e){var t=dn(e,1);t!==null&&$t(t,e,1,-1)}function Ed(e){var t=Ht();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:sr,lastRenderedState:e},t.queue=e,e=e.dispatch=dm.bind(null,Pe,e),[t.memoizedState,e]}function rr(e,t,l,s){return e={tag:e,create:t,destroy:l,deps:s,next:null},t=Pe.updateQueue,t===null?(t={lastEffect:null,stores:null},Pe.updateQueue=t,t.lastEffect=e.next=e):(l=t.lastEffect,l===null?t.lastEffect=e.next=e:(s=l.next,l.next=e,e.next=s,t.lastEffect=e)),e}function Hp(){return It().memoizedState}function Vr(e,t,l,s){var r=Ht();Pe.flags|=e,r.memoizedState=rr(1|t,l,void 0,s===void 0?null:s)}function Di(e,t,l,s){var r=It();s=s===void 0?null:s;var i=void 0;if(Ke!==null){var a=Ke.memoizedState;if(i=a.destroy,s!==null&&rc(s,a.deps)){r.memoizedState=rr(t,l,i,s);return}}Pe.flags|=e,r.memoizedState=rr(1|t,l,i,s)}function Ad(e,t){return Vr(8390656,8,e,t)}function oc(e,t){return Di(2048,8,e,t)}function Kp(e,t){return Di(4,2,e,t)}function Qp(e,t){return Di(4,4,e,t)}function Gp(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Yp(e,t,l){return l=l!=null?l.concat([e]):null,Di(4,4,Gp.bind(null,t,e),l)}function cc(){}function Xp(e,t){var l=It();t=t===void 0?null:t;var s=l.memoizedState;return s!==null&&t!==null&&rc(t,s[1])?s[0]:(l.memoizedState=[e,t],e)}function qp(e,t){var l=It();t=t===void 0?null:t;var s=l.memoizedState;return s!==null&&t!==null&&rc(t,s[1])?s[0]:(e=e(),l.memoizedState=[e,t],e)}function Jp(e,t,l){return al&21?(Ut(l,t)||(l=np(),Pe.lanes|=l,ol|=l,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ut=!0),e.memoizedState=l)}function om(e,t){var l=ge;ge=l!==0&&4>l?l:4,e(!0);var s=ja.transition;ja.transition={};try{e(!1),t()}finally{ge=l,ja.transition=s}}function Zp(){return It().memoizedState}function cm(e,t,l){var s=In(e);if(l={lane:s,action:l,hasEagerState:!1,eagerState:null,next:null},Vp(e))ef(t,l);else if(l=Lp(e,t,l,s),l!==null){var r=it();$t(l,e,s,r),tf(l,t,s)}}function dm(e,t,l){var s=In(e),r={lane:s,action:l,hasEagerState:!1,eagerState:null,next:null};if(Vp(e))ef(t,r);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var a=t.lastRenderedState,d=i(a,l);if(r.hasEagerState=!0,r.eagerState=d,Ut(d,a)){var u=t.interleaved;u===null?(r.next=r,ec(t)):(r.next=u.next,u.next=r),t.interleaved=r;return}}catch{}finally{}l=Lp(e,t,r,s),l!==null&&(r=it(),$t(l,e,s,r),tf(l,t,s))}}function Vp(e){var t=e.alternate;return e===Pe||t!==null&&t===Pe}function ef(e,t){$s=bi=!0;var l=e.pending;l===null?t.next=t:(t.next=l.next,l.next=t),e.pending=t}function tf(e,t,l){if(l&4194240){var s=t.lanes;s&=e.pendingLanes,l|=s,t.lanes=l,$o(e,l)}}var Si={readContext:Pt,useCallback:tt,useContext:tt,useEffect:tt,useImperativeHandle:tt,useInsertionEffect:tt,useLayoutEffect:tt,useMemo:tt,useReducer:tt,useRef:tt,useState:tt,useDebugValue:tt,useDeferredValue:tt,useTransition:tt,useMutableSource:tt,useSyncExternalStore:tt,useId:tt,unstable_isNewReconciler:!1},um={readContext:Pt,useCallback:function(e,t){return Ht().memoizedState=[e,t===void 0?null:t],e},useContext:Pt,useEffect:Ad,useImperativeHandle:function(e,t,l){return l=l!=null?l.concat([e]):null,Vr(4194308,4,Gp.bind(null,t,e),l)},useLayoutEffect:function(e,t){return Vr(4194308,4,e,t)},useInsertionEffect:function(e,t){return Vr(4,2,e,t)},useMemo:function(e,t){var l=Ht();return t=t===void 0?null:t,e=e(),l.memoizedState=[e,t],e},useReducer:function(e,t,l){var s=Ht();return t=l!==void 0?l(t):t,s.memoizedState=s.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},s.queue=e,e=e.dispatch=cm.bind(null,Pe,e),[s.memoizedState,e]},useRef:function(e){var t=Ht();return e={current:e},t.memoizedState=e},useState:Ed,useDebugValue:cc,useDeferredValue:function(e){return Ht().memoizedState=e},useTransition:function(){var e=Ed(!1),t=e[0];return e=om.bind(null,e[1]),Ht().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,l){var s=Pe,r=Ht();if(_e){if(l===void 0)throw Error(F(407));l=l()}else{if(l=t(),qe===null)throw Error(F(349));al&30||Bp(s,t,l)}r.memoizedState=l;var i={value:l,getSnapshot:t};return r.queue=i,Ad(Up.bind(null,s,i,e),[e]),s.flags|=2048,rr(9,$p.bind(null,s,i,l,t),void 0,null),l},useId:function(){var e=Ht(),t=qe.identifierPrefix;if(_e){var l=rn,s=sn;l=(s&~(1<<32-Bt(s)-1)).toString(32)+l,t=":"+t+"R"+l,l=lr++,0<l&&(t+="H"+l.toString(32)),t+=":"}else l=am++,t=":"+t+"r"+l.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},pm={readContext:Pt,useCallback:Xp,useContext:Pt,useEffect:oc,useImperativeHandle:Yp,useInsertionEffect:Kp,useLayoutEffect:Qp,useMemo:qp,useReducer:ba,useRef:Hp,useState:function(){return ba(sr)},useDebugValue:cc,useDeferredValue:function(e){var t=It();return Jp(t,Ke.memoizedState,e)},useTransition:function(){var e=ba(sr)[0],t=It().memoizedState;return[e,t]},useMutableSource:Np,useSyncExternalStore:Wp,useId:Zp,unstable_isNewReconciler:!1},fm={readContext:Pt,useCallback:Xp,useContext:Pt,useEffect:oc,useImperativeHandle:Yp,useInsertionEffect:Kp,useLayoutEffect:Qp,useMemo:qp,useReducer:Sa,useRef:Hp,useState:function(){return Sa(sr)},useDebugValue:cc,useDeferredValue:function(e){var t=It();return Ke===null?t.memoizedState=e:Jp(t,Ke.memoizedState,e)},useTransition:function(){var e=Sa(sr)[0],t=It().memoizedState;return[e,t]},useMutableSource:Np,useSyncExternalStore:Wp,useId:Zp,unstable_isNewReconciler:!1};function Ot(e,t){if(e&&e.defaultProps){t=Ie({},t),e=e.defaultProps;for(var l in e)t[l]===void 0&&(t[l]=e[l]);return t}return t}function co(e,t,l,s){t=e.memoizedState,l=l(s,t),l=l==null?t:Ie({},t,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var Ni={isMounted:function(e){return(e=e._reactInternals)?pl(e)===e:!1},enqueueSetState:function(e,t,l){e=e._reactInternals;var s=it(),r=In(e),i=an(s,r);i.payload=t,l!=null&&(i.callback=l),t=Tn(e,i,r),t!==null&&($t(t,e,r,s),Jr(t,e,r))},enqueueReplaceState:function(e,t,l){e=e._reactInternals;var s=it(),r=In(e),i=an(s,r);i.tag=1,i.payload=t,l!=null&&(i.callback=l),t=Tn(e,i,r),t!==null&&($t(t,e,r,s),Jr(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var l=it(),s=In(e),r=an(l,s);r.tag=2,t!=null&&(r.callback=t),t=Tn(e,r,s),t!==null&&($t(t,e,s,l),Jr(t,e,s))}};function Rd(e,t,l,s,r,i,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(s,i,a):t.prototype&&t.prototype.isPureReactComponent?!Js(l,s)||!Js(r,i):!0}function nf(e,t,l){var s=!1,r=Rn,i=t.contextType;return typeof i=="object"&&i!==null?i=Pt(i):(r=ft(t)?rl:st.current,s=t.contextTypes,i=(s=s!=null)?ss(e,r):Rn),t=new t(l,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ni,e.stateNode=t,t._reactInternals=e,s&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=r,e.__reactInternalMemoizedMaskedChildContext=i),t}function Ld(e,t,l,s){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(l,s),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(l,s),t.state!==e&&Ni.enqueueReplaceState(t,t.state,null)}function uo(e,t,l,s){var r=e.stateNode;r.props=l,r.state=e.memoizedState,r.refs={},tc(e);var i=t.contextType;typeof i=="object"&&i!==null?r.context=Pt(i):(i=ft(t)?rl:st.current,r.context=ss(e,i)),r.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(co(e,t,i,l),r.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(t=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),t!==r.state&&Ni.enqueueReplaceState(r,r.state,null),vi(e,l,r,s),r.state=e.memoizedState),typeof r.componentDidMount=="function"&&(e.flags|=4194308)}function os(e,t){try{var l="",s=t;do l+=Ug(s),s=s.return;while(s);var r=l}catch(i){r=`
Error generating stack: `+i.message+`
`+i.stack}return{value:e,source:t,stack:r,digest:null}}function wa(e,t,l){return{value:e,source:null,stack:l??null,digest:t??null}}function po(e,t){try{console.error(t.value)}catch(l){setTimeout(function(){throw l})}}var hm=typeof WeakMap=="function"?WeakMap:Map;function lf(e,t,l){l=an(-1,l),l.tag=3,l.payload={element:null};var s=t.value;return l.callback=function(){ki||(ki=!0,So=s),po(e,t)},l}function sf(e,t,l){l=an(-1,l),l.tag=3;var s=e.type.getDerivedStateFromError;if(typeof s=="function"){var r=t.value;l.payload=function(){return s(r)},l.callback=function(){po(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(l.callback=function(){po(e,t),typeof s!="function"&&(Pn===null?Pn=new Set([this]):Pn.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),l}function Od(e,t,l){var s=e.pingCache;if(s===null){s=e.pingCache=new hm;var r=new Set;s.set(t,r)}else r=s.get(t),r===void 0&&(r=new Set,s.set(t,r));r.has(l)||(r.add(l),e=Tm.bind(null,e,t,l),t.then(e,e))}function Dd(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function Nd(e,t,l,s,r){return e.mode&1?(e.flags|=65536,e.lanes=r,e):(e===t?e.flags|=65536:(e.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(t=an(-1,1),t.tag=2,Tn(l,t,1))),l.lanes|=1),e)}var gm=pn.ReactCurrentOwner,ut=!1;function rt(e,t,l,s){t.child=e===null?Rp(t,null,l,s):is(t,e.child,l,s)}function Wd(e,t,l,s,r){l=l.render;var i=t.ref;return ts(t,r),s=ic(e,t,l,s,i,r),l=ac(),e!==null&&!ut?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~r,un(e,t,r)):(_e&&l&&Yo(t),t.flags|=1,rt(e,t,s,r),t.child)}function Bd(e,t,l,s,r){if(e===null){var i=l.type;return typeof i=="function"&&!mc(i)&&i.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(t.tag=15,t.type=i,rf(e,t,i,s,r)):(e=li(l.type,null,s,t,t.mode,r),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&r)){var a=i.memoizedProps;if(l=l.compare,l=l!==null?l:Js,l(a,s)&&e.ref===t.ref)return un(e,t,r)}return t.flags|=1,e=En(i,s),e.ref=t.ref,e.return=t,t.child=e}function rf(e,t,l,s,r){if(e!==null){var i=e.memoizedProps;if(Js(i,s)&&e.ref===t.ref)if(ut=!1,t.pendingProps=s=i,(e.lanes&r)!==0)e.flags&131072&&(ut=!0);else return t.lanes=e.lanes,un(e,t,r)}return fo(e,t,l,s,r)}function af(e,t,l){var s=t.pendingProps,r=s.children,i=e!==null?e.memoizedState:null;if(s.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},je(Xl,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,je(Xl,yt),yt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},s=i!==null?i.baseLanes:l,je(Xl,yt),yt|=s}else i!==null?(s=i.baseLanes|l,t.memoizedState=null):s=l,je(Xl,yt),yt|=s;return rt(e,t,r,l),t.child}function of(e,t){var l=t.ref;(e===null&&l!==null||e!==null&&e.ref!==l)&&(t.flags|=512,t.flags|=2097152)}function fo(e,t,l,s,r){var i=ft(l)?rl:st.current;return i=ss(t,i),ts(t,r),l=ic(e,t,l,s,i,r),s=ac(),e!==null&&!ut?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~r,un(e,t,r)):(_e&&s&&Yo(t),t.flags|=1,rt(e,t,l,r),t.child)}function $d(e,t,l,s,r){if(ft(l)){var i=!0;hi(t)}else i=!1;if(ts(t,r),t.stateNode===null)ei(e,t),nf(t,l,s),uo(t,l,s,r),s=!0;else if(e===null){var a=t.stateNode,d=t.memoizedProps;a.props=d;var u=a.context,f=l.contextType;typeof f=="object"&&f!==null?f=Pt(f):(f=ft(l)?rl:st.current,f=ss(t,f));var y=l.getDerivedStateFromProps,p=typeof y=="function"||typeof a.getSnapshotBeforeUpdate=="function";p||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(d!==s||u!==f)&&Ld(t,a,s,f),yn=!1;var c=t.memoizedState;a.state=c,vi(t,s,a,r),u=t.memoizedState,d!==s||c!==u||pt.current||yn?(typeof y=="function"&&(co(t,l,y,s),u=t.memoizedState),(d=yn||Rd(t,l,d,s,c,u,f))?(p||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=s,t.memoizedState=u),a.props=s,a.state=u,a.context=f,s=d):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),s=!1)}else{a=t.stateNode,Op(e,t),d=t.memoizedProps,f=t.type===t.elementType?d:Ot(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)?rl:st.current,u=ss(t,u));var v=l.getDerivedStateFromProps;(y=typeof v=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(d!==p||c!==u)&&Ld(t,a,s,u),yn=!1,c=t.memoizedState,a.state=c,vi(t,s,a,r);var b=t.memoizedState;d!==p||c!==b||pt.current||yn?(typeof v=="function"&&(co(t,l,v,s),b=t.memoizedState),(f=yn||Rd(t,l,f,s,c,b,u)||!1)?(y||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(s,b,u),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(s,b,u)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||d===e.memoizedProps&&c===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||d===e.memoizedProps&&c===e.memoizedState||(t.flags|=1024),t.memoizedProps=s,t.memoizedState=b),a.props=s,a.state=b,a.context=u,s=f):(typeof a.componentDidUpdate!="function"||d===e.memoizedProps&&c===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||d===e.memoizedProps&&c===e.memoizedState||(t.flags|=1024),s=!1)}return ho(e,t,l,s,i,r)}function ho(e,t,l,s,r,i){of(e,t);var a=(t.flags&128)!==0;if(!s&&!a)return r&&_d(t,l,!1),un(e,t,i);s=t.stateNode,gm.current=t;var d=a&&typeof l.getDerivedStateFromError!="function"?null:s.render();return t.flags|=1,e!==null&&a?(t.child=is(t,e.child,null,i),t.child=is(t,null,d,i)):rt(e,t,d,i),t.memoizedState=s.state,r&&_d(t,l,!0),t.child}function cf(e){var t=e.stateNode;t.pendingContext?kd(e,t.pendingContext,t.pendingContext!==t.context):t.context&&kd(e,t.context,!1),nc(e,t.containerInfo)}function Ud(e,t,l,s,r){return rs(),qo(r),t.flags|=256,rt(e,t,l,s),t.child}var go={dehydrated:null,treeContext:null,retryLane:0};function xo(e){return{baseLanes:e,cachePool:null,transitions:null}}function df(e,t,l){var s=t.pendingProps,r=Te.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),je(Te,r&1),e===null)return ao(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(a=s.children,e=s.fallback,i?(s=t.mode,i=t.child,a={mode:"hidden",children:a},!(s&1)&&i!==null?(i.childLanes=0,i.pendingProps=a):i=$i(a,s,0,null),e=sl(e,s,l,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=xo(l),t.memoizedState=go,e):dc(t,a));if(r=e.memoizedState,r!==null&&(d=r.dehydrated,d!==null))return xm(e,t,a,s,d,r,l);if(i){i=s.fallback,a=t.mode,r=e.child,d=r.sibling;var u={mode:"hidden",children:s.children};return!(a&1)&&t.child!==r?(s=t.child,s.childLanes=0,s.pendingProps=u,t.deletions=null):(s=En(r,u),s.subtreeFlags=r.subtreeFlags&14680064),d!==null?i=En(d,i):(i=sl(i,a,l,null),i.flags|=2),i.return=t,s.return=t,s.sibling=i,t.child=s,s=i,i=t.child,a=e.child.memoizedState,a=a===null?xo(l):{baseLanes:a.baseLanes|l,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~l,t.memoizedState=go,s}return i=e.child,e=i.sibling,s=En(i,{mode:"visible",children:s.children}),!(t.mode&1)&&(s.lanes=l),s.return=t,s.sibling=null,e!==null&&(l=t.deletions,l===null?(t.deletions=[e],t.flags|=16):l.push(e)),t.child=s,t.memoizedState=null,s}function dc(e,t){return t=$i({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Lr(e,t,l,s){return s!==null&&qo(s),is(t,e.child,null,l),e=dc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function xm(e,t,l,s,r,i,a){if(l)return t.flags&256?(t.flags&=-257,s=wa(Error(F(422))),Lr(e,t,a,s)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=s.fallback,r=t.mode,s=$i({mode:"visible",children:s.children},r,0,null),i=sl(i,r,a,null),i.flags|=2,s.return=t,i.return=t,s.sibling=i,t.child=s,t.mode&1&&is(t,e.child,null,a),t.child.memoizedState=xo(a),t.memoizedState=go,i);if(!(t.mode&1))return Lr(e,t,a,null);if(r.data==="$!"){if(s=r.nextSibling&&r.nextSibling.dataset,s)var d=s.dgst;return s=d,i=Error(F(419)),s=wa(i,s,void 0),Lr(e,t,a,s)}if(d=(a&e.childLanes)!==0,ut||d){if(s=qe,s!==null){switch(a&-a){case 4:r=2;break;case 16:r=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:r=32;break;case 536870912:r=268435456;break;default:r=0}r=r&(s.suspendedLanes|a)?0:r,r!==0&&r!==i.retryLane&&(i.retryLane=r,dn(e,r),$t(s,e,r,-1))}return xc(),s=wa(Error(F(421))),Lr(e,t,a,s)}return r.data==="$?"?(t.flags|=128,t.child=e.child,t=Pm.bind(null,e),r._reactRetry=t,null):(e=i.treeContext,vt=zn(r.nextSibling),jt=t,_e=!0,Nt=null,e!==null&&(_t[Ct++]=sn,_t[Ct++]=rn,_t[Ct++]=il,sn=e.id,rn=e.overflow,il=t),t=dc(t,s.children),t.flags|=4096,t)}function Fd(e,t,l){e.lanes|=t;var s=e.alternate;s!==null&&(s.lanes|=t),oo(e.return,t,l)}function ka(e,t,l,s,r){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:s,tail:l,tailMode:r}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=s,i.tail=l,i.tailMode=r)}function uf(e,t,l){var s=t.pendingProps,r=s.revealOrder,i=s.tail;if(rt(e,t,s.children,l),s=Te.current,s&2)s=s&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Fd(e,l,t);else if(e.tag===19)Fd(e,l,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}s&=1}if(je(Te,s),!(t.mode&1))t.memoizedState=null;else switch(r){case"forwards":for(l=t.child,r=null;l!==null;)e=l.alternate,e!==null&&ji(e)===null&&(r=l),l=l.sibling;l=r,l===null?(r=t.child,t.child=null):(r=l.sibling,l.sibling=null),ka(t,!1,r,l,i);break;case"backwards":for(l=null,r=t.child,t.child=null;r!==null;){if(e=r.alternate,e!==null&&ji(e)===null){t.child=r;break}e=r.sibling,r.sibling=l,l=r,r=e}ka(t,!0,l,null,i);break;case"together":ka(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function ei(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function un(e,t,l){if(e!==null&&(t.dependencies=e.dependencies),ol|=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=En(e,e.pendingProps),t.child=l,l.return=t;e.sibling!==null;)e=e.sibling,l=l.sibling=En(e,e.pendingProps),l.return=t;l.sibling=null}return t.child}function mm(e,t,l){switch(t.tag){case 3:cf(t),rs();break;case 5:Dp(t);break;case 1:ft(t.type)&&hi(t);break;case 4:nc(t,t.stateNode.containerInfo);break;case 10:var s=t.type._context,r=t.memoizedProps.value;je(mi,s._currentValue),s._currentValue=r;break;case 13:if(s=t.memoizedState,s!==null)return s.dehydrated!==null?(je(Te,Te.current&1),t.flags|=128,null):l&t.child.childLanes?df(e,t,l):(je(Te,Te.current&1),e=un(e,t,l),e!==null?e.sibling:null);je(Te,Te.current&1);break;case 19:if(s=(l&t.childLanes)!==0,e.flags&128){if(s)return uf(e,t,l);t.flags|=128}if(r=t.memoizedState,r!==null&&(r.rendering=null,r.tail=null,r.lastEffect=null),je(Te,Te.current),s)break;return null;case 22:case 23:return t.lanes=0,af(e,t,l)}return un(e,t,l)}var pf,mo,ff,hf;pf=function(e,t){for(var l=t.child;l!==null;){if(l.tag===5||l.tag===6)e.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===t)break;for(;l.sibling===null;){if(l.return===null||l.return===t)return;l=l.return}l.sibling.return=l.return,l=l.sibling}};mo=function(){};ff=function(e,t,l,s){var r=e.memoizedProps;if(r!==s){e=t.stateNode,nl(Gt.current);var i=null;switch(l){case"input":r=Wa(e,r),s=Wa(e,s),i=[];break;case"select":r=Ie({},r,{value:void 0}),s=Ie({},s,{value:void 0}),i=[];break;case"textarea":r=Ua(e,r),s=Ua(e,s),i=[];break;default:typeof r.onClick!="function"&&typeof s.onClick=="function"&&(e.onclick=pi)}Ma(l,s);var a;l=null;for(f in r)if(!s.hasOwnProperty(f)&&r.hasOwnProperty(f)&&r[f]!=null)if(f==="style"){var d=r[f];for(a in d)d.hasOwnProperty(a)&&(l||(l={}),l[a]="")}else f!=="dangerouslySetInnerHTML"&&f!=="children"&&f!=="suppressContentEditableWarning"&&f!=="suppressHydrationWarning"&&f!=="autoFocus"&&(Hs.hasOwnProperty(f)?i||(i=[]):(i=i||[]).push(f,null));for(f in s){var u=s[f];if(d=r!=null?r[f]:void 0,s.hasOwnProperty(f)&&u!==d&&(u!=null||d!=null))if(f==="style")if(d){for(a in d)!d.hasOwnProperty(a)||u&&u.hasOwnProperty(a)||(l||(l={}),l[a]="");for(a in u)u.hasOwnProperty(a)&&d[a]!==u[a]&&(l||(l={}),l[a]=u[a])}else l||(i||(i=[]),i.push(f,l)),l=u;else f==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,d=d?d.__html:void 0,u!=null&&d!==u&&(i=i||[]).push(f,u)):f==="children"?typeof u!="string"&&typeof u!="number"||(i=i||[]).push(f,""+u):f!=="suppressContentEditableWarning"&&f!=="suppressHydrationWarning"&&(Hs.hasOwnProperty(f)?(u!=null&&f==="onScroll"&&be("scroll",e),i||d===u||(i=[])):(i=i||[]).push(f,u))}l&&(i=i||[]).push("style",l);var f=i;(t.updateQueue=f)&&(t.flags|=4)}};hf=function(e,t,l,s){l!==s&&(t.flags|=4)};function Ss(e,t){if(!_e)switch(e.tailMode){case"hidden":t=e.tail;for(var l=null;t!==null;)t.alternate!==null&&(l=t),t=t.sibling;l===null?e.tail=null:l.sibling=null;break;case"collapsed":l=e.tail;for(var s=null;l!==null;)l.alternate!==null&&(s=l),l=l.sibling;s===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:s.sibling=null}}function nt(e){var t=e.alternate!==null&&e.alternate.child===e.child,l=0,s=0;if(t)for(var r=e.child;r!==null;)l|=r.lanes|r.childLanes,s|=r.subtreeFlags&14680064,s|=r.flags&14680064,r.return=e,r=r.sibling;else for(r=e.child;r!==null;)l|=r.lanes|r.childLanes,s|=r.subtreeFlags,s|=r.flags,r.return=e,r=r.sibling;return e.subtreeFlags|=s,e.childLanes=l,t}function ym(e,t,l){var s=t.pendingProps;switch(Xo(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return nt(t),null;case 1:return ft(t.type)&&fi(),nt(t),null;case 3:return s=t.stateNode,as(),Se(pt),Se(st),sc(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(Ar(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Nt!==null&&(_o(Nt),Nt=null))),mo(e,t),nt(t),null;case 5:lc(t);var r=nl(nr.current);if(l=t.type,e!==null&&t.stateNode!=null)ff(e,t,l,s,r),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!s){if(t.stateNode===null)throw Error(F(166));return nt(t),null}if(e=nl(Gt.current),Ar(t)){s=t.stateNode,l=t.type;var i=t.memoizedProps;switch(s[Kt]=t,s[er]=i,e=(t.mode&1)!==0,l){case"dialog":be("cancel",s),be("close",s);break;case"iframe":case"object":case"embed":be("load",s);break;case"video":case"audio":for(r=0;r<Rs.length;r++)be(Rs[r],s);break;case"source":be("error",s);break;case"img":case"image":case"link":be("error",s),be("load",s);break;case"details":be("toggle",s);break;case"input":Jc(s,i),be("invalid",s);break;case"select":s._wrapperState={wasMultiple:!!i.multiple},be("invalid",s);break;case"textarea":Vc(s,i),be("invalid",s)}Ma(l,i),r=null;for(var a in i)if(i.hasOwnProperty(a)){var d=i[a];a==="children"?typeof d=="string"?s.textContent!==d&&(i.suppressHydrationWarning!==!0&&Er(s.textContent,d,e),r=["children",d]):typeof d=="number"&&s.textContent!==""+d&&(i.suppressHydrationWarning!==!0&&Er(s.textContent,d,e),r=["children",""+d]):Hs.hasOwnProperty(a)&&d!=null&&a==="onScroll"&&be("scroll",s)}switch(l){case"input":wr(s),Zc(s,i,!0);break;case"textarea":wr(s),ed(s);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(s.onclick=pi)}s=r,t.updateQueue=s,s!==null&&(t.flags|=4)}else{a=r.nodeType===9?r:r.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Uu(l)),e==="http://www.w3.org/1999/xhtml"?l==="script"?(e=a.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof s.is=="string"?e=a.createElement(l,{is:s.is}):(e=a.createElement(l),l==="select"&&(a=e,s.multiple?a.multiple=!0:s.size&&(a.size=s.size))):e=a.createElementNS(e,l),e[Kt]=t,e[er]=s,pf(e,t,!1,!1),t.stateNode=e;e:{switch(a=Ha(l,s),l){case"dialog":be("cancel",e),be("close",e),r=s;break;case"iframe":case"object":case"embed":be("load",e),r=s;break;case"video":case"audio":for(r=0;r<Rs.length;r++)be(Rs[r],e);r=s;break;case"source":be("error",e),r=s;break;case"img":case"image":case"link":be("error",e),be("load",e),r=s;break;case"details":be("toggle",e),r=s;break;case"input":Jc(e,s),r=Wa(e,s),be("invalid",e);break;case"option":r=s;break;case"select":e._wrapperState={wasMultiple:!!s.multiple},r=Ie({},s,{value:void 0}),be("invalid",e);break;case"textarea":Vc(e,s),r=Ua(e,s),be("invalid",e);break;default:r=s}Ma(l,r),d=r;for(i in d)if(d.hasOwnProperty(i)){var u=d[i];i==="style"?Hu(e,u):i==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,u!=null&&Fu(e,u)):i==="children"?typeof u=="string"?(l!=="textarea"||u!=="")&&Ks(e,u):typeof u=="number"&&Ks(e,""+u):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Hs.hasOwnProperty(i)?u!=null&&i==="onScroll"&&be("scroll",e):u!=null&&Lo(e,i,u,a))}switch(l){case"input":wr(e),Zc(e,s,!1);break;case"textarea":wr(e),ed(e);break;case"option":s.value!=null&&e.setAttribute("value",""+An(s.value));break;case"select":e.multiple=!!s.multiple,i=s.value,i!=null?Jl(e,!!s.multiple,i,!1):s.defaultValue!=null&&Jl(e,!!s.multiple,s.defaultValue,!0);break;default:typeof r.onClick=="function"&&(e.onclick=pi)}switch(l){case"button":case"input":case"select":case"textarea":s=!!s.autoFocus;break e;case"img":s=!0;break e;default:s=!1}}s&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return nt(t),null;case 6:if(e&&t.stateNode!=null)hf(e,t,e.memoizedProps,s);else{if(typeof s!="string"&&t.stateNode===null)throw Error(F(166));if(l=nl(nr.current),nl(Gt.current),Ar(t)){if(s=t.stateNode,l=t.memoizedProps,s[Kt]=t,(i=s.nodeValue!==l)&&(e=jt,e!==null))switch(e.tag){case 3:Er(s.nodeValue,l,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Er(s.nodeValue,l,(e.mode&1)!==0)}i&&(t.flags|=4)}else s=(l.nodeType===9?l:l.ownerDocument).createTextNode(s),s[Kt]=t,t.stateNode=s}return nt(t),null;case 13:if(Se(Te),s=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(_e&&vt!==null&&t.mode&1&&!(t.flags&128))Ep(),rs(),t.flags|=98560,i=!1;else if(i=Ar(t),s!==null&&s.dehydrated!==null){if(e===null){if(!i)throw Error(F(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(F(317));i[Kt]=t}else rs(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;nt(t),i=!1}else Nt!==null&&(_o(Nt),Nt=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||Te.current&1?Qe===0&&(Qe=3):xc())),t.updateQueue!==null&&(t.flags|=4),nt(t),null);case 4:return as(),mo(e,t),e===null&&Zs(t.stateNode.containerInfo),nt(t),null;case 10:return Vo(t.type._context),nt(t),null;case 17:return ft(t.type)&&fi(),nt(t),null;case 19:if(Se(Te),i=t.memoizedState,i===null)return nt(t),null;if(s=(t.flags&128)!==0,a=i.rendering,a===null)if(s)Ss(i,!1);else{if(Qe!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=ji(e),a!==null){for(t.flags|=128,Ss(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 je(Te,Te.current&1|2),t.child}e=e.sibling}i.tail!==null&&Oe()>cs&&(t.flags|=128,s=!0,Ss(i,!1),t.lanes=4194304)}else{if(!s)if(e=ji(a),e!==null){if(t.flags|=128,s=!0,l=e.updateQueue,l!==null&&(t.updateQueue=l,t.flags|=4),Ss(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!_e)return nt(t),null}else 2*Oe()-i.renderingStartTime>cs&&l!==1073741824&&(t.flags|=128,s=!0,Ss(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=Oe(),t.sibling=null,l=Te.current,je(Te,s?l&1|2:l&1),t):(nt(t),null);case 22:case 23:return gc(),s=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==s&&(t.flags|=8192),s&&t.mode&1?yt&1073741824&&(nt(t),t.subtreeFlags&6&&(t.flags|=8192)):nt(t),null;case 24:return null;case 25:return null}throw Error(F(156,t.tag))}function vm(e,t){switch(Xo(t),t.tag){case 1:return ft(t.type)&&fi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return as(),Se(pt),Se(st),sc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return lc(t),null;case 13:if(Se(Te),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(F(340));rs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Se(Te),null;case 4:return as(),null;case 10:return Vo(t.type._context),null;case 22:case 23:return gc(),null;case 24:return null;default:return null}}var Or=!1,lt=!1,jm=typeof WeakSet=="function"?WeakSet:Set,Q=null;function Yl(e,t){var l=e.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(s){Ee(e,t,s)}else l.current=null}function yo(e,t,l){try{l()}catch(s){Ee(e,t,s)}}var Md=!1;function bm(e,t){if(eo=ci,e=yp(),Go(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var s=l.getSelection&&l.getSelection();if(s&&s.rangeCount!==0){l=s.anchorNode;var r=s.anchorOffset,i=s.focusNode;s=s.focusOffset;try{l.nodeType,i.nodeType}catch{l=null;break e}var a=0,d=-1,u=-1,f=0,y=0,p=e,c=null;t:for(;;){for(var v;p!==l||r!==0&&p.nodeType!==3||(d=a+r),p!==i||s!==0&&p.nodeType!==3||(u=a+s),p.nodeType===3&&(a+=p.nodeValue.length),(v=p.firstChild)!==null;)c=p,p=v;for(;;){if(p===e)break t;if(c===l&&++f===r&&(d=a),c===i&&++y===s&&(u=a),(v=p.nextSibling)!==null)break;p=c,c=p.parentNode}p=v}l=d===-1||u===-1?null:{start:d,end:u}}else l=null}l=l||{start:0,end:0}}else l=null;for(to={focusedElem:e,selectionRange:l},ci=!1,Q=t;Q!==null;)if(t=Q,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Q=e;else for(;Q!==null;){t=Q;try{var b=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(b!==null){var g=b.memoizedProps,S=b.memoizedState,h=t.stateNode,m=h.getSnapshotBeforeUpdate(t.elementType===t.type?g:Ot(t.type,g),S);h.__reactInternalSnapshotBeforeUpdate=m}break;case 3:var o=t.stateNode.containerInfo;o.nodeType===1?o.textContent="":o.nodeType===9&&o.documentElement&&o.removeChild(o.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(F(163))}}catch(x){Ee(t,t.return,x)}if(e=t.sibling,e!==null){e.return=t.return,Q=e;break}Q=t.return}return b=Md,Md=!1,b}function Us(e,t,l){var s=t.updateQueue;if(s=s!==null?s.lastEffect:null,s!==null){var r=s=s.next;do{if((r.tag&e)===e){var i=r.destroy;r.destroy=void 0,i!==void 0&&yo(t,l,i)}r=r.next}while(r!==s)}}function Wi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var l=t=t.next;do{if((l.tag&e)===e){var s=l.create;l.destroy=s()}l=l.next}while(l!==t)}}function vo(e){var t=e.ref;if(t!==null){var l=e.stateNode;switch(e.tag){case 5:e=l;break;default:e=l}typeof t=="function"?t(e):t.current=e}}function gf(e){var t=e.alternate;t!==null&&(e.alternate=null,gf(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Kt],delete t[er],delete t[so],delete t[lm],delete t[sm])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function xf(e){return e.tag===5||e.tag===3||e.tag===4}function Hd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||xf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function jo(e,t,l){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?l.nodeType===8?l.parentNode.insertBefore(e,t):l.insertBefore(e,t):(l.nodeType===8?(t=l.parentNode,t.insertBefore(e,l)):(t=l,t.appendChild(e)),l=l._reactRootContainer,l!=null||t.onclick!==null||(t.onclick=pi));else if(s!==4&&(e=e.child,e!==null))for(jo(e,t,l),e=e.sibling;e!==null;)jo(e,t,l),e=e.sibling}function bo(e,t,l){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?l.insertBefore(e,t):l.appendChild(e);else if(s!==4&&(e=e.child,e!==null))for(bo(e,t,l),e=e.sibling;e!==null;)bo(e,t,l),e=e.sibling}var Ze=null,Dt=!1;function gn(e,t,l){for(l=l.child;l!==null;)mf(e,t,l),l=l.sibling}function mf(e,t,l){if(Qt&&typeof Qt.onCommitFiberUnmount=="function")try{Qt.onCommitFiberUnmount(Ii,l)}catch{}switch(l.tag){case 5:lt||Yl(l,t);case 6:var s=Ze,r=Dt;Ze=null,gn(e,t,l),Ze=s,Dt=r,Ze!==null&&(Dt?(e=Ze,l=l.stateNode,e.nodeType===8?e.parentNode.removeChild(l):e.removeChild(l)):Ze.removeChild(l.stateNode));break;case 18:Ze!==null&&(Dt?(e=Ze,l=l.stateNode,e.nodeType===8?ma(e.parentNode,l):e.nodeType===1&&ma(e,l),Xs(e)):ma(Ze,l.stateNode));break;case 4:s=Ze,r=Dt,Ze=l.stateNode.containerInfo,Dt=!0,gn(e,t,l),Ze=s,Dt=r;break;case 0:case 11:case 14:case 15:if(!lt&&(s=l.updateQueue,s!==null&&(s=s.lastEffect,s!==null))){r=s=s.next;do{var i=r,a=i.destroy;i=i.tag,a!==void 0&&(i&2||i&4)&&yo(l,t,a),r=r.next}while(r!==s)}gn(e,t,l);break;case 1:if(!lt&&(Yl(l,t),s=l.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=l.memoizedProps,s.state=l.memoizedState,s.componentWillUnmount()}catch(d){Ee(l,t,d)}gn(e,t,l);break;case 21:gn(e,t,l);break;case 22:l.mode&1?(lt=(s=lt)||l.memoizedState!==null,gn(e,t,l),lt=s):gn(e,t,l);break;default:gn(e,t,l)}}function Kd(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var l=e.stateNode;l===null&&(l=e.stateNode=new jm),t.forEach(function(s){var r=Im.bind(null,e,s);l.has(s)||(l.add(s),s.then(r,r))})}}function Lt(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,Dt=!1;break e;case 3:Ze=d.stateNode.containerInfo,Dt=!0;break e;case 4:Ze=d.stateNode.containerInfo,Dt=!0;break e}d=d.return}if(Ze===null)throw Error(F(160));mf(i,a,r),Ze=null,Dt=!1;var u=r.alternate;u!==null&&(u.return=null),r.return=null}catch(f){Ee(r,t,f)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)yf(t,e),t=t.sibling}function yf(e,t){var l=e.alternate,s=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Lt(t,e),Mt(e),s&4){try{Us(3,e,e.return),Wi(3,e)}catch(g){Ee(e,e.return,g)}try{Us(5,e,e.return)}catch(g){Ee(e,e.return,g)}}break;case 1:Lt(t,e),Mt(e),s&512&&l!==null&&Yl(l,l.return);break;case 5:if(Lt(t,e),Mt(e),s&512&&l!==null&&Yl(l,l.return),e.flags&32){var r=e.stateNode;try{Ks(r,"")}catch(g){Ee(e,e.return,g)}}if(s&4&&(r=e.stateNode,r!=null)){var i=e.memoizedProps,a=l!==null?l.memoizedProps:i,d=e.type,u=e.updateQueue;if(e.updateQueue=null,u!==null)try{d==="input"&&i.type==="radio"&&i.name!=null&&Bu(r,i),Ha(d,a);var f=Ha(d,i);for(a=0;a<u.length;a+=2){var y=u[a],p=u[a+1];y==="style"?Hu(r,p):y==="dangerouslySetInnerHTML"?Fu(r,p):y==="children"?Ks(r,p):Lo(r,y,p,f)}switch(d){case"input":Ba(r,i);break;case"textarea":$u(r,i);break;case"select":var c=r._wrapperState.wasMultiple;r._wrapperState.wasMultiple=!!i.multiple;var v=i.value;v!=null?Jl(r,!!i.multiple,v,!1):c!==!!i.multiple&&(i.defaultValue!=null?Jl(r,!!i.multiple,i.defaultValue,!0):Jl(r,!!i.multiple,i.multiple?[]:"",!1))}r[er]=i}catch(g){Ee(e,e.return,g)}}break;case 6:if(Lt(t,e),Mt(e),s&4){if(e.stateNode===null)throw Error(F(162));r=e.stateNode,i=e.memoizedProps;try{r.nodeValue=i}catch(g){Ee(e,e.return,g)}}break;case 3:if(Lt(t,e),Mt(e),s&4&&l!==null&&l.memoizedState.isDehydrated)try{Xs(t.containerInfo)}catch(g){Ee(e,e.return,g)}break;case 4:Lt(t,e),Mt(e);break;case 13:Lt(t,e),Mt(e),r=e.child,r.flags&8192&&(i=r.memoizedState!==null,r.stateNode.isHidden=i,!i||r.alternate!==null&&r.alternate.memoizedState!==null||(fc=Oe())),s&4&&Kd(e);break;case 22:if(y=l!==null&&l.memoizedState!==null,e.mode&1?(lt=(f=lt)||y,Lt(t,e),lt=f):Lt(t,e),Mt(e),s&8192){if(f=e.memoizedState!==null,(e.stateNode.isHidden=f)&&!y&&e.mode&1)for(Q=e,y=e.child;y!==null;){for(p=Q=y;Q!==null;){switch(c=Q,v=c.child,c.tag){case 0:case 11:case 14:case 15:Us(4,c,c.return);break;case 1:Yl(c,c.return);var b=c.stateNode;if(typeof b.componentWillUnmount=="function"){s=c,l=c.return;try{t=s,b.props=t.memoizedProps,b.state=t.memoizedState,b.componentWillUnmount()}catch(g){Ee(s,l,g)}}break;case 5:Yl(c,c.return);break;case 22:if(c.memoizedState!==null){Gd(p);continue}}v!==null?(v.return=c,Q=v):Gd(p)}y=y.sibling}e:for(y=null,p=e;;){if(p.tag===5){if(y===null){y=p;try{r=p.stateNode,f?(i=r.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(d=p.stateNode,u=p.memoizedProps.style,a=u!=null&&u.hasOwnProperty("display")?u.display:null,d.style.display=Mu("display",a))}catch(g){Ee(e,e.return,g)}}}else if(p.tag===6){if(y===null)try{p.stateNode.nodeValue=f?"":p.memoizedProps}catch(g){Ee(e,e.return,g)}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===e)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===e)break e;for(;p.sibling===null;){if(p.return===null||p.return===e)break e;y===p&&(y=null),p=p.return}y===p&&(y=null),p.sibling.return=p.return,p=p.sibling}}break;case 19:Lt(t,e),Mt(e),s&4&&Kd(e);break;case 21:break;default:Lt(t,e),Mt(e)}}function Mt(e){var t=e.flags;if(t&2){try{e:{for(var l=e.return;l!==null;){if(xf(l)){var s=l;break e}l=l.return}throw Error(F(160))}switch(s.tag){case 5:var r=s.stateNode;s.flags&32&&(Ks(r,""),s.flags&=-33);var i=Hd(e);bo(e,i,r);break;case 3:case 4:var a=s.stateNode.containerInfo,d=Hd(e);jo(e,d,a);break;default:throw Error(F(161))}}catch(u){Ee(e,e.return,u)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Sm(e,t,l){Q=e,vf(e)}function vf(e,t,l){for(var s=(e.mode&1)!==0;Q!==null;){var r=Q,i=r.child;if(r.tag===22&&s){var a=r.memoizedState!==null||Or;if(!a){var d=r.alternate,u=d!==null&&d.memoizedState!==null||lt;d=Or;var f=lt;if(Or=a,(lt=u)&&!f)for(Q=r;Q!==null;)a=Q,u=a.child,a.tag===22&&a.memoizedState!==null?Yd(r):u!==null?(u.return=a,Q=u):Yd(r);for(;i!==null;)Q=i,vf(i),i=i.sibling;Q=r,Or=d,lt=f}Qd(e)}else r.subtreeFlags&8772&&i!==null?(i.return=r,Q=i):Qd(e)}}function Qd(e){for(;Q!==null;){var t=Q;if(t.flags&8772){var l=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:lt||Wi(5,t);break;case 1:var s=t.stateNode;if(t.flags&4&&!lt)if(l===null)s.componentDidMount();else{var r=t.elementType===t.type?l.memoizedProps:Ot(t.type,l.memoizedProps);s.componentDidUpdate(r,l.memoizedState,s.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Id(t,i,s);break;case 3:var a=t.updateQueue;if(a!==null){if(l=null,t.child!==null)switch(t.child.tag){case 5:l=t.child.stateNode;break;case 1:l=t.child.stateNode}Id(t,a,l)}break;case 5:var d=t.stateNode;if(l===null&&t.flags&4){l=d;var u=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":u.autoFocus&&l.focus();break;case"img":u.src&&(l.src=u.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var f=t.alternate;if(f!==null){var y=f.memoizedState;if(y!==null){var p=y.dehydrated;p!==null&&Xs(p)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(F(163))}lt||t.flags&512&&vo(t)}catch(c){Ee(t,t.return,c)}}if(t===e){Q=null;break}if(l=t.sibling,l!==null){l.return=t.return,Q=l;break}Q=t.return}}function Gd(e){for(;Q!==null;){var t=Q;if(t===e){Q=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Q=l;break}Q=t.return}}function Yd(e){for(;Q!==null;){var t=Q;try{switch(t.tag){case 0:case 11:case 15:var l=t.return;try{Wi(4,t)}catch(u){Ee(t,l,u)}break;case 1:var s=t.stateNode;if(typeof s.componentDidMount=="function"){var r=t.return;try{s.componentDidMount()}catch(u){Ee(t,r,u)}}var i=t.return;try{vo(t)}catch(u){Ee(t,i,u)}break;case 5:var a=t.return;try{vo(t)}catch(u){Ee(t,a,u)}}}catch(u){Ee(t,t.return,u)}if(t===e){Q=null;break}var d=t.sibling;if(d!==null){d.return=t.return,Q=d;break}Q=t.return}}var wm=Math.ceil,wi=pn.ReactCurrentDispatcher,uc=pn.ReactCurrentOwner,Tt=pn.ReactCurrentBatchConfig,pe=0,qe=null,Be=null,Ve=0,yt=0,Xl=Dn(0),Qe=0,ir=null,ol=0,Bi=0,pc=0,Fs=null,dt=null,fc=0,cs=1/0,nn=null,ki=!1,So=null,Pn=null,Dr=!1,Sn=null,_i=0,Ms=0,wo=null,ti=-1,ni=0;function it(){return pe&6?Oe():ti!==-1?ti:ti=Oe()}function In(e){return e.mode&1?pe&2&&Ve!==0?Ve&-Ve:im.transition!==null?(ni===0&&(ni=np()),ni):(e=ge,e!==0||(e=window.event,e=e===void 0?16:cp(e.type)),e):1}function $t(e,t,l,s){if(50<Ms)throw Ms=0,wo=null,Error(F(185));or(e,l,s),(!(pe&2)||e!==qe)&&(e===qe&&(!(pe&2)&&(Bi|=l),Qe===4&&jn(e,Ve)),ht(e,s),l===1&&pe===0&&!(t.mode&1)&&(cs=Oe()+500,Oi&&Nn()))}function ht(e,t){var l=e.callbackNode;ix(e,t);var s=oi(e,e===qe?Ve:0);if(s===0)l!==null&&ld(l),e.callbackNode=null,e.callbackPriority=0;else if(t=s&-s,e.callbackPriority!==t){if(l!=null&&ld(l),t===1)e.tag===0?rm(Xd.bind(null,e)):Tp(Xd.bind(null,e)),tm(function(){!(pe&6)&&Nn()}),l=null;else{switch(lp(s)){case 1:l=Bo;break;case 4:l=ep;break;case 16:l=ai;break;case 536870912:l=tp;break;default:l=ai}l=zf(l,jf.bind(null,e))}e.callbackPriority=t,e.callbackNode=l}}function jf(e,t){if(ti=-1,ni=0,pe&6)throw Error(F(327));var l=e.callbackNode;if(ns()&&e.callbackNode!==l)return null;var s=oi(e,e===qe?Ve:0);if(s===0)return null;if(s&30||s&e.expiredLanes||t)t=Ci(e,s);else{t=s;var r=pe;pe|=2;var i=Sf();(qe!==e||Ve!==t)&&(nn=null,cs=Oe()+500,ll(e,t));do try{Cm();break}catch(d){bf(e,d)}while(!0);Zo(),wi.current=i,pe=r,Be!==null?t=0:(qe=null,Ve=0,t=Qe)}if(t!==0){if(t===2&&(r=Xa(e),r!==0&&(s=r,t=ko(e,r))),t===1)throw l=ir,ll(e,0),jn(e,s),ht(e,Oe()),l;if(t===6)jn(e,s);else{if(r=e.current.alternate,!(s&30)&&!km(r)&&(t=Ci(e,s),t===2&&(i=Xa(e),i!==0&&(s=i,t=ko(e,i))),t===1))throw l=ir,ll(e,0),jn(e,s),ht(e,Oe()),l;switch(e.finishedWork=r,e.finishedLanes=s,t){case 0:case 1:throw Error(F(345));case 2:Vn(e,dt,nn);break;case 3:if(jn(e,s),(s&130023424)===s&&(t=fc+500-Oe(),10<t)){if(oi(e,0)!==0)break;if(r=e.suspendedLanes,(r&s)!==s){it(),e.pingedLanes|=e.suspendedLanes&r;break}e.timeoutHandle=lo(Vn.bind(null,e,dt,nn),t);break}Vn(e,dt,nn);break;case 4:if(jn(e,s),(s&4194240)===s)break;for(t=e.eventTimes,r=-1;0<s;){var a=31-Bt(s);i=1<<a,a=t[a],a>r&&(r=a),s&=~i}if(s=r,s=Oe()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*wm(s/1960))-s,10<s){e.timeoutHandle=lo(Vn.bind(null,e,dt,nn),s);break}Vn(e,dt,nn);break;case 5:Vn(e,dt,nn);break;default:throw Error(F(329))}}}return ht(e,Oe()),e.callbackNode===l?jf.bind(null,e):null}function ko(e,t){var l=Fs;return e.current.memoizedState.isDehydrated&&(ll(e,t).flags|=256),e=Ci(e,t),e!==2&&(t=dt,dt=l,t!==null&&_o(t)),e}function _o(e){dt===null?dt=e:dt.push.apply(dt,e)}function km(e){for(var t=e;;){if(t.flags&16384){var l=t.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var s=0;s<l.length;s++){var r=l[s],i=r.getSnapshot;r=r.value;try{if(!Ut(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 jn(e,t){for(t&=~pc,t&=~Bi,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var l=31-Bt(t),s=1<<l;e[l]=-1,t&=~s}}function Xd(e){if(pe&6)throw Error(F(327));ns();var t=oi(e,0);if(!(t&1))return ht(e,Oe()),null;var l=Ci(e,t);if(e.tag!==0&&l===2){var s=Xa(e);s!==0&&(t=s,l=ko(e,s))}if(l===1)throw l=ir,ll(e,0),jn(e,t),ht(e,Oe()),l;if(l===6)throw Error(F(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Vn(e,dt,nn),ht(e,Oe()),null}function hc(e,t){var l=pe;pe|=1;try{return e(t)}finally{pe=l,pe===0&&(cs=Oe()+500,Oi&&Nn())}}function cl(e){Sn!==null&&Sn.tag===0&&!(pe&6)&&ns();var t=pe;pe|=1;var l=Tt.transition,s=ge;try{if(Tt.transition=null,ge=1,e)return e()}finally{ge=s,Tt.transition=l,pe=t,!(pe&6)&&Nn()}}function gc(){yt=Xl.current,Se(Xl)}function ll(e,t){e.finishedWork=null,e.finishedLanes=0;var l=e.timeoutHandle;if(l!==-1&&(e.timeoutHandle=-1,em(l)),Be!==null)for(l=Be.return;l!==null;){var s=l;switch(Xo(s),s.tag){case 1:s=s.type.childContextTypes,s!=null&&fi();break;case 3:as(),Se(pt),Se(st),sc();break;case 5:lc(s);break;case 4:as();break;case 13:Se(Te);break;case 19:Se(Te);break;case 10:Vo(s.type._context);break;case 22:case 23:gc()}l=l.return}if(qe=e,Be=e=En(e.current,null),Ve=yt=t,Qe=0,ir=null,pc=Bi=ol=0,dt=Fs=null,tl!==null){for(t=0;t<tl.length;t++)if(l=tl[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}tl=null}return e}function bf(e,t){do{var l=Be;try{if(Zo(),Zr.current=Si,bi){for(var s=Pe.memoizedState;s!==null;){var r=s.queue;r!==null&&(r.pending=null),s=s.next}bi=!1}if(al=0,Xe=Ke=Pe=null,$s=!1,lr=0,uc.current=null,l===null||l.return===null){Qe=1,ir=t,Be=null;break}e:{var i=e,a=l.return,d=l,u=t;if(t=Ve,d.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){var f=u,y=d,p=y.tag;if(!(y.mode&1)&&(p===0||p===11||p===15)){var c=y.alternate;c?(y.updateQueue=c.updateQueue,y.memoizedState=c.memoizedState,y.lanes=c.lanes):(y.updateQueue=null,y.memoizedState=null)}var v=Dd(a);if(v!==null){v.flags&=-257,Nd(v,a,d,i,t),v.mode&1&&Od(i,f,t),t=v,u=f;var b=t.updateQueue;if(b===null){var g=new Set;g.add(u),t.updateQueue=g}else b.add(u);break e}else{if(!(t&1)){Od(i,f,t),xc();break e}u=Error(F(426))}}else if(_e&&d.mode&1){var S=Dd(a);if(S!==null){!(S.flags&65536)&&(S.flags|=256),Nd(S,a,d,i,t),qo(os(u,d));break e}}i=u=os(u,d),Qe!==4&&(Qe=2),Fs===null?Fs=[i]:Fs.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var h=lf(i,u,t);Pd(i,h);break e;case 1:d=u;var m=i.type,o=i.stateNode;if(!(i.flags&128)&&(typeof m.getDerivedStateFromError=="function"||o!==null&&typeof o.componentDidCatch=="function"&&(Pn===null||!Pn.has(o)))){i.flags|=65536,t&=-t,i.lanes|=t;var x=sf(i,d,t);Pd(i,x);break e}}i=i.return}while(i!==null)}kf(l)}catch(z){t=z,Be===l&&l!==null&&(Be=l=l.return);continue}break}while(!0)}function Sf(){var e=wi.current;return wi.current=Si,e===null?Si:e}function xc(){(Qe===0||Qe===3||Qe===2)&&(Qe=4),qe===null||!(ol&268435455)&&!(Bi&268435455)||jn(qe,Ve)}function Ci(e,t){var l=pe;pe|=2;var s=Sf();(qe!==e||Ve!==t)&&(nn=null,ll(e,t));do try{_m();break}catch(r){bf(e,r)}while(!0);if(Zo(),pe=l,wi.current=s,Be!==null)throw Error(F(261));return qe=null,Ve=0,Qe}function _m(){for(;Be!==null;)wf(Be)}function Cm(){for(;Be!==null&&!Jg();)wf(Be)}function wf(e){var t=Cf(e.alternate,e,yt);e.memoizedProps=e.pendingProps,t===null?kf(e):Be=t,uc.current=null}function kf(e){var t=e;do{var l=t.alternate;if(e=t.return,t.flags&32768){if(l=vm(l,t),l!==null){l.flags&=32767,Be=l;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Qe=6,Be=null;return}}else if(l=ym(l,t,yt),l!==null){Be=l;return}if(t=t.sibling,t!==null){Be=t;return}Be=t=e}while(t!==null);Qe===0&&(Qe=5)}function Vn(e,t,l){var s=ge,r=Tt.transition;try{Tt.transition=null,ge=1,zm(e,t,l,s)}finally{Tt.transition=r,ge=s}return null}function zm(e,t,l,s){do ns();while(Sn!==null);if(pe&6)throw Error(F(327));l=e.finishedWork;var r=e.finishedLanes;if(l===null)return null;if(e.finishedWork=null,e.finishedLanes=0,l===e.current)throw Error(F(177));e.callbackNode=null,e.callbackPriority=0;var i=l.lanes|l.childLanes;if(ax(e,i),e===qe&&(Be=qe=null,Ve=0),!(l.subtreeFlags&2064)&&!(l.flags&2064)||Dr||(Dr=!0,zf(ai,function(){return ns(),null})),i=(l.flags&15990)!==0,l.subtreeFlags&15990||i){i=Tt.transition,Tt.transition=null;var a=ge;ge=1;var d=pe;pe|=4,uc.current=null,bm(e,l),yf(l,e),Gx(to),ci=!!eo,to=eo=null,e.current=l,Sm(l),Zg(),pe=d,ge=a,Tt.transition=i}else e.current=l;if(Dr&&(Dr=!1,Sn=e,_i=r),i=e.pendingLanes,i===0&&(Pn=null),tx(l.stateNode),ht(e,Oe()),t!==null)for(s=e.onRecoverableError,l=0;l<t.length;l++)r=t[l],s(r.value,{componentStack:r.stack,digest:r.digest});if(ki)throw ki=!1,e=So,So=null,e;return _i&1&&e.tag!==0&&ns(),i=e.pendingLanes,i&1?e===wo?Ms++:(Ms=0,wo=e):Ms=0,Nn(),null}function ns(){if(Sn!==null){var e=lp(_i),t=Tt.transition,l=ge;try{if(Tt.transition=null,ge=16>e?16:e,Sn===null)var s=!1;else{if(e=Sn,Sn=null,_i=0,pe&6)throw Error(F(331));var r=pe;for(pe|=4,Q=e.current;Q!==null;){var i=Q,a=i.child;if(Q.flags&16){var d=i.deletions;if(d!==null){for(var u=0;u<d.length;u++){var f=d[u];for(Q=f;Q!==null;){var y=Q;switch(y.tag){case 0:case 11:case 15:Us(8,y,i)}var p=y.child;if(p!==null)p.return=y,Q=p;else for(;Q!==null;){y=Q;var c=y.sibling,v=y.return;if(gf(y),y===f){Q=null;break}if(c!==null){c.return=v,Q=c;break}Q=v}}}var b=i.alternate;if(b!==null){var g=b.child;if(g!==null){b.child=null;do{var S=g.sibling;g.sibling=null,g=S}while(g!==null)}}Q=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,Q=a;else e:for(;Q!==null;){if(i=Q,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Us(9,i,i.return)}var h=i.sibling;if(h!==null){h.return=i.return,Q=h;break e}Q=i.return}}var m=e.current;for(Q=m;Q!==null;){a=Q;var o=a.child;if(a.subtreeFlags&2064&&o!==null)o.return=a,Q=o;else e:for(a=m;Q!==null;){if(d=Q,d.flags&2048)try{switch(d.tag){case 0:case 11:case 15:Wi(9,d)}}catch(z){Ee(d,d.return,z)}if(d===a){Q=null;break e}var x=d.sibling;if(x!==null){x.return=d.return,Q=x;break e}Q=d.return}}if(pe=r,Nn(),Qt&&typeof Qt.onPostCommitFiberRoot=="function")try{Qt.onPostCommitFiberRoot(Ii,e)}catch{}s=!0}return s}finally{ge=l,Tt.transition=t}}return!1}function qd(e,t,l){t=os(l,t),t=lf(e,t,1),e=Tn(e,t,1),t=it(),e!==null&&(or(e,1,t),ht(e,t))}function Ee(e,t,l){if(e.tag===3)qd(e,e,l);else for(;t!==null;){if(t.tag===3){qd(t,e,l);break}else if(t.tag===1){var s=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof s.componentDidCatch=="function"&&(Pn===null||!Pn.has(s))){e=os(l,e),e=sf(t,e,1),t=Tn(t,e,1),e=it(),t!==null&&(or(t,1,e),ht(t,e));break}}t=t.return}}function Tm(e,t,l){var s=e.pingCache;s!==null&&s.delete(t),t=it(),e.pingedLanes|=e.suspendedLanes&l,qe===e&&(Ve&l)===l&&(Qe===4||Qe===3&&(Ve&130023424)===Ve&&500>Oe()-fc?ll(e,0):pc|=l),ht(e,t)}function _f(e,t){t===0&&(e.mode&1?(t=Cr,Cr<<=1,!(Cr&130023424)&&(Cr=4194304)):t=1);var l=it();e=dn(e,t),e!==null&&(or(e,t,l),ht(e,l))}function Pm(e){var t=e.memoizedState,l=0;t!==null&&(l=t.retryLane),_f(e,l)}function Im(e,t){var l=0;switch(e.tag){case 13:var s=e.stateNode,r=e.memoizedState;r!==null&&(l=r.retryLane);break;case 19:s=e.stateNode;break;default:throw Error(F(314))}s!==null&&s.delete(t),_f(e,l)}var Cf;Cf=function(e,t,l){if(e!==null)if(e.memoizedProps!==t.pendingProps||pt.current)ut=!0;else{if(!(e.lanes&l)&&!(t.flags&128))return ut=!1,mm(e,t,l);ut=!!(e.flags&131072)}else ut=!1,_e&&t.flags&1048576&&Pp(t,xi,t.index);switch(t.lanes=0,t.tag){case 2:var s=t.type;ei(e,t),e=t.pendingProps;var r=ss(t,st.current);ts(t,l),r=ic(null,t,s,e,r,l);var i=ac();return t.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ft(s)?(i=!0,hi(t)):i=!1,t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,tc(t),r.updater=Ni,t.stateNode=r,r._reactInternals=t,uo(t,s,e,l),t=ho(null,t,s,!0,i,l)):(t.tag=0,_e&&i&&Yo(t),rt(null,t,r,l),t=t.child),t;case 16:s=t.elementType;e:{switch(ei(e,t),e=t.pendingProps,r=s._init,s=r(s._payload),t.type=s,r=t.tag=Am(s),e=Ot(s,e),r){case 0:t=fo(null,t,s,e,l);break e;case 1:t=$d(null,t,s,e,l);break e;case 11:t=Wd(null,t,s,e,l);break e;case 14:t=Bd(null,t,s,Ot(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:Ot(s,r),fo(e,t,s,r,l);case 1:return s=t.type,r=t.pendingProps,r=t.elementType===s?r:Ot(s,r),$d(e,t,s,r,l);case 3:e:{if(cf(t),e===null)throw Error(F(387));s=t.pendingProps,i=t.memoizedState,r=i.element,Op(e,t),vi(t,s,null,l);var a=t.memoizedState;if(s=a.element,i.isDehydrated)if(i={element:s,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){r=os(Error(F(423)),t),t=Ud(e,t,s,l,r);break e}else if(s!==r){r=os(Error(F(424)),t),t=Ud(e,t,s,l,r);break e}else for(vt=zn(t.stateNode.containerInfo.firstChild),jt=t,_e=!0,Nt=null,l=Rp(t,null,s,l),t.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(rs(),s===r){t=un(e,t,l);break e}rt(e,t,s,l)}t=t.child}return t;case 5:return Dp(t),e===null&&ao(t),s=t.type,r=t.pendingProps,i=e!==null?e.memoizedProps:null,a=r.children,no(s,r)?a=null:i!==null&&no(s,i)&&(t.flags|=32),of(e,t),rt(e,t,a,l),t.child;case 6:return e===null&&ao(t),null;case 13:return df(e,t,l);case 4:return nc(t,t.stateNode.containerInfo),s=t.pendingProps,e===null?t.child=is(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:Ot(s,r),Wd(e,t,s,r,l);case 7:return rt(e,t,t.pendingProps,l),t.child;case 8:return rt(e,t,t.pendingProps.children,l),t.child;case 12:return rt(e,t,t.pendingProps.children,l),t.child;case 10:e:{if(s=t.type._context,r=t.pendingProps,i=t.memoizedProps,a=r.value,je(mi,s._currentValue),s._currentValue=a,i!==null)if(Ut(i.value,a)){if(i.children===r.children&&!pt.current){t=un(e,t,l);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var d=i.dependencies;if(d!==null){a=i.child;for(var u=d.firstContext;u!==null;){if(u.context===s){if(i.tag===1){u=an(-1,l&-l),u.tag=2;var f=i.updateQueue;if(f!==null){f=f.shared;var y=f.pending;y===null?u.next=u:(u.next=y.next,y.next=u),f.pending=u}}i.lanes|=l,u=i.alternate,u!==null&&(u.lanes|=l),oo(i.return,l,t),d.lanes|=l;break}u=u.next}}else if(i.tag===10)a=i.type===t.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(F(341));a.lanes|=l,d=a.alternate,d!==null&&(d.lanes|=l),oo(a,l,t),a=i.sibling}else a=i.child;if(a!==null)a.return=i;else for(a=i;a!==null;){if(a===t){a=null;break}if(i=a.sibling,i!==null){i.return=a.return,a=i;break}a=a.return}i=a}rt(e,t,r.children,l),t=t.child}return t;case 9:return r=t.type,s=t.pendingProps.children,ts(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=Ot(s,t.pendingProps),r=Ot(s.type,r),Bd(e,t,s,r,l);case 15:return rf(e,t,t.type,t.pendingProps,l);case 17:return s=t.type,r=t.pendingProps,r=t.elementType===s?r:Ot(s,r),ei(e,t),t.tag=1,ft(s)?(e=!0,hi(t)):e=!1,ts(t,l),nf(t,s,r),uo(t,s,r,l),ho(null,t,s,!0,e,l);case 19:return uf(e,t,l);case 22:return af(e,t,l)}throw Error(F(156,t.tag))};function zf(e,t){return Vu(e,t)}function Em(e,t,l,s){this.tag=e,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function zt(e,t,l,s){return new Em(e,t,l,s)}function mc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Am(e){if(typeof e=="function")return mc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Do)return 11;if(e===No)return 14}return 2}function En(e,t){var l=e.alternate;return l===null?(l=zt(e.tag,t,e.key,e.mode),l.elementType=e.elementType,l.type=e.type,l.stateNode=e.stateNode,l.alternate=e,e.alternate=l):(l.pendingProps=t,l.type=e.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=e.flags&14680064,l.childLanes=e.childLanes,l.lanes=e.lanes,l.child=e.child,l.memoizedProps=e.memoizedProps,l.memoizedState=e.memoizedState,l.updateQueue=e.updateQueue,t=e.dependencies,l.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},l.sibling=e.sibling,l.index=e.index,l.ref=e.ref,l}function li(e,t,l,s,r,i){var a=2;if(s=e,typeof e=="function")mc(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Bl:return sl(l.children,r,i,t);case Oo:a=8,r|=8;break;case La:return e=zt(12,l,t,r|2),e.elementType=La,e.lanes=i,e;case Oa:return e=zt(13,l,t,r),e.elementType=Oa,e.lanes=i,e;case Da:return e=zt(19,l,t,r),e.elementType=Da,e.lanes=i,e;case Du:return $i(l,r,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Lu:a=10;break e;case Ou:a=9;break e;case Do:a=11;break e;case No:a=14;break e;case mn: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 sl(e,t,l,s){return e=zt(7,e,s,t),e.lanes=l,e}function $i(e,t,l,s){return e=zt(22,e,s,t),e.elementType=Du,e.lanes=l,e.stateNode={isHidden:!1},e}function _a(e,t,l){return e=zt(6,e,null,t),e.lanes=l,e}function Ca(e,t,l){return t=zt(4,e.children!==null?e.children:[],e.key,t),t.lanes=l,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Rm(e,t,l,s,r){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ia(0),this.expirationTimes=ia(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ia(0),this.identifierPrefix=s,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function yc(e,t,l,s,r,i,a,d,u){return e=new Rm(e,t,l,d,u),t===1?(t=1,i===!0&&(t|=8)):t=0,i=zt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:s,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},tc(i),e}function Lm(e,t,l){var s=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Wl,key:s==null?null:""+s,children:e,containerInfo:t,implementation:l}}function Tf(e){if(!e)return Rn;e=e._reactInternals;e:{if(pl(e)!==e||e.tag!==1)throw Error(F(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(ft(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(F(171))}if(e.tag===1){var l=e.type;if(ft(l))return zp(e,l,t)}return t}function Pf(e,t,l,s,r,i,a,d,u){return e=yc(l,s,!0,e,r,i,a,d,u),e.context=Tf(null),l=e.current,s=it(),r=In(l),i=an(s,r),i.callback=t??null,Tn(l,i,r),e.current.lanes=r,or(e,r,s),ht(e,s),e}function Ui(e,t,l,s){var r=t.current,i=it(),a=In(r);return l=Tf(l),t.context===null?t.context=l:t.pendingContext=l,t=an(i,a),t.payload={element:e},s=s===void 0?null:s,s!==null&&(t.callback=s),e=Tn(r,t,a),e!==null&&($t(e,r,a,i),Jr(e,r,a)),a}function zi(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function Jd(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<t?l:t}}function vc(e,t){Jd(e,t),(e=e.alternate)&&Jd(e,t)}function Om(){return null}var If=typeof reportError=="function"?reportError:function(e){console.error(e)};function jc(e){this._internalRoot=e}Fi.prototype.render=jc.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(F(409));Ui(e,t,null,null)};Fi.prototype.unmount=jc.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;cl(function(){Ui(null,e,null,null)}),t[cn]=null}};function Fi(e){this._internalRoot=e}Fi.prototype.unstable_scheduleHydration=function(e){if(e){var t=ip();e={blockedOn:null,target:e,priority:t};for(var l=0;l<vn.length&&t!==0&&t<vn[l].priority;l++);vn.splice(l,0,e),l===0&&op(e)}};function bc(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Mi(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Zd(){}function Dm(e,t,l,s,r){if(r){if(typeof s=="function"){var i=s;s=function(){var f=zi(a);i.call(f)}}var a=Pf(t,s,e,0,null,!1,!1,"",Zd);return e._reactRootContainer=a,e[cn]=a.current,Zs(e.nodeType===8?e.parentNode:e),cl(),a}for(;r=e.lastChild;)e.removeChild(r);if(typeof s=="function"){var d=s;s=function(){var f=zi(u);d.call(f)}}var u=yc(e,0,!1,null,null,!1,!1,"",Zd);return e._reactRootContainer=u,e[cn]=u.current,Zs(e.nodeType===8?e.parentNode:e),cl(function(){Ui(t,u,l,s)}),u}function Hi(e,t,l,s,r){var i=l._reactRootContainer;if(i){var a=i;if(typeof r=="function"){var d=r;r=function(){var u=zi(a);d.call(u)}}Ui(t,a,e,r)}else a=Dm(l,t,e,r,s);return zi(a)}sp=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var l=As(t.pendingLanes);l!==0&&($o(t,l|1),ht(t,Oe()),!(pe&6)&&(cs=Oe()+500,Nn()))}break;case 13:cl(function(){var s=dn(e,1);if(s!==null){var r=it();$t(s,e,1,r)}}),vc(e,1)}};Uo=function(e){if(e.tag===13){var t=dn(e,134217728);if(t!==null){var l=it();$t(t,e,134217728,l)}vc(e,134217728)}};rp=function(e){if(e.tag===13){var t=In(e),l=dn(e,t);if(l!==null){var s=it();$t(l,e,t,s)}vc(e,t)}};ip=function(){return ge};ap=function(e,t){var l=ge;try{return ge=e,t()}finally{ge=l}};Qa=function(e,t,l){switch(t){case"input":if(Ba(e,l),t=l.name,l.type==="radio"&&t!=null){for(l=e;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<l.length;t++){var s=l[t];if(s!==e&&s.form===e.form){var r=Li(s);if(!r)throw Error(F(90));Wu(s),Ba(s,r)}}}break;case"textarea":$u(e,l);break;case"select":t=l.value,t!=null&&Jl(e,!!l.multiple,t,!1)}};Gu=hc;Yu=cl;var Nm={usingClientEntryPoint:!1,Events:[dr,Ml,Li,Ku,Qu,hc]},ws={findFiberByHostInstance:el,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Wm={bundleType:ws.bundleType,version:ws.version,rendererPackageName:ws.rendererPackageName,rendererConfig:ws.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:pn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Ju(e),e===null?null:e.stateNode},findFiberByHostInstance:ws.findFiberByHostInstance||Om,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Nr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Nr.isDisabled&&Nr.supportsFiber)try{Ii=Nr.inject(Wm),Qt=Nr}catch{}}St.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Nm;St.createPortal=function(e,t){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!bc(t))throw Error(F(200));return Lm(e,t,null,l)};St.createRoot=function(e,t){if(!bc(e))throw Error(F(299));var l=!1,s="",r=If;return t!=null&&(t.unstable_strictMode===!0&&(l=!0),t.identifierPrefix!==void 0&&(s=t.identifierPrefix),t.onRecoverableError!==void 0&&(r=t.onRecoverableError)),t=yc(e,1,!1,null,null,l,!1,s,r),e[cn]=t.current,Zs(e.nodeType===8?e.parentNode:e),new jc(t)};St.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(F(188)):(e=Object.keys(e).join(","),Error(F(268,e)));return e=Ju(t),e=e===null?null:e.stateNode,e};St.flushSync=function(e){return cl(e)};St.hydrate=function(e,t,l){if(!Mi(t))throw Error(F(200));return Hi(null,e,t,!0,l)};St.hydrateRoot=function(e,t,l){if(!bc(e))throw Error(F(405));var s=l!=null&&l.hydratedSources||null,r=!1,i="",a=If;if(l!=null&&(l.unstable_strictMode===!0&&(r=!0),l.identifierPrefix!==void 0&&(i=l.identifierPrefix),l.onRecoverableError!==void 0&&(a=l.onRecoverableError)),t=Pf(t,null,e,1,l??null,r,!1,i,a),e[cn]=t.current,Zs(e),s)for(e=0;e<s.length;e++)l=s[e],r=l._getVersion,r=r(l._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[l,r]:t.mutableSourceEagerHydrationData.push(l,r);return new Fi(t)};St.render=function(e,t,l){if(!Mi(t))throw Error(F(200));return Hi(null,e,t,!1,l)};St.unmountComponentAtNode=function(e){if(!Mi(e))throw Error(F(40));return e._reactRootContainer?(cl(function(){Hi(null,null,e,!1,function(){e._reactRootContainer=null,e[cn]=null})}),!0):!1};St.unstable_batchedUpdates=hc;St.unstable_renderSubtreeIntoContainer=function(e,t,l,s){if(!Mi(l))throw Error(F(200));if(e==null||e._reactInternals===void 0)throw Error(F(38));return Hi(e,t,l,!1,s)};St.version="18.3.1-next-f1338f8080-20240426";function Ef(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Ef)}catch(e){console.error(e)}}Ef(),Iu.exports=St;var Bm=Iu.exports,Af,Vd=Bm;Af=Vd.createRoot,Vd.hydrateRoot;const ce="",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"},W={bg:"#f5f6fa",accent:"#4f46e5",red:"#ef4444",orange:"#f59e0b",green:"#16a34a",purple:"#7c3aed",blue:"#2563eb",teal:"#0d9488",gray:"#94a3b8"},$m=[{id:"dashboard",icon:"📊",label:"Dashboard"},{id:"inbox",icon:"📥",label:"Inbox"},{id:"incidents",icon:"📋",label:"Incidents"},{id:"ideas",icon:"💡",label:"Ideas"},{id:"orders",icon:"📦",label:"Orders"},{id:"processes",icon:"⚙️",label:"Processes"},{id:"delegations",icon:"🤝",label:"Delegations"},{id:"reports",icon:"📈",label:"Reports"}],Um=[{id:"users",icon:"👤",label:"Users"},{id:"organizations",icon:"🏢",label:"Organizations"},{id:"managements",icon:"🏗️",label:"Managements"},{id:"departments",icon:"🗂️",label:"Departments"},{id:"branches",icon:"🌿",label:"Branches"},{id:"cycles",icon:"🔄",label:"Cycles"},{id:"kpi-input",icon:"📊",label:"KPI Input"},{id:"incident-types",icon:"🚨",label:"Incident Types"},{id:"idea-types",icon:"💡",label:"Idea Types"},{id:"order-types",icon:"📦",label:"Order Types"},{id:"process-types",icon:"⚙️",label:"Process Types"},{id:"incident-statuses",icon:"🔴",label:"Incident Statuses"},{id:"idea-statuses",icon:"🟢",label:"Idea Statuses"},{id:"order-statuses",icon:"🟣",label:"Order Statuses"},{id:"process-statuses",icon:"🔵",label:"Process Statuses"}],Fm=new Set(["users"]);function Mm(e){return e!=="Admin"&&e!=="Auditor"?[]:Um.filter(({id:t})=>e==="Admin"||!Fm.has(t))}const xn=(e=[])=>[{key:"name1",label:"Name"},{key:"status",label:"Status"},...e,{key:"creation_date",label:"Created On"}],Hm={incidents:{label:"Incidents",orgField:"organization",columns:[{key:"number",label:"Number"},{key:"title",label:"Title"},{key:"organization",label:"Organization"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"management",label:"Management"},{key:"department",label:"Department"},{key:"branch",label:"Branch"},{key:"date",label:"Date"},{key:"assigned_to",label:"Assigned To"},{key:"priority",label:"Priority"},{key:"economy_class",label:"Economy Class"},{key:"entity_scope",label:"Entity Scope"},{key:"hses_field",label:"HSES Field"},{key:"workflow_state",label:"Workflow State"}],defaultColumns:["number","title","organization","type","status","date","assigned_to"]},ideas:{label:"Ideas",orgField:"organization",columns:[{key:"number",label:"Number"},{key:"title",label:"Title"},{key:"organization",label:"Organization"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"management",label:"Management"},{key:"department",label:"Department"},{key:"branch",label:"Branch"},{key:"date",label:"Date"},{key:"assigned_to",label:"Assigned To"},{key:"priority",label:"Priority"},{key:"economy_class",label:"Economy Class"},{key:"current_condition",label:"Current Condition"},{key:"proposed_condition",label:"Proposed Condition"},{key:"workflow_state",label:"Workflow State"}],defaultColumns:["number","title","organization","type","status","date","assigned_to"]},orders:{label:"Orders",orgField:"organization",columns:[{key:"number",label:"Number"},{key:"title",label:"Title"},{key:"organization",label:"Organization"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"management",label:"Management"},{key:"department",label:"Department"},{key:"branch",label:"Branch"},{key:"starting_date",label:"Start Date"},{key:"ending_date",label:"End Date"},{key:"assigned_to",label:"Assigned To"},{key:"budget",label:"Budget"},{key:"actual_cost",label:"Actual Cost"},{key:"currency",label:"Currency"},{key:"stage",label:"Stage"},{key:"completion_pct",label:"Completion %"},{key:"priority",label:"Priority"},{key:"workflow_state",label:"Workflow State"}],defaultColumns:["number","title","organization","type","status","starting_date","ending_date","assigned_to","budget"]},processes:{label:"Processes",orgField:"organization",columns:[{key:"number",label:"Number"},{key:"title",label:"Title"},{key:"organization",label:"Organization"},{key:"type",label:"Type"},{key:"status",label:"Status"},{key:"management",label:"Management"},{key:"department",label:"Department"},{key:"branch",label:"Branch"},{key:"date_start",label:"Start Date"},{key:"date_end",label:"End Date"},{key:"actor",label:"Actor"},{key:"cycle_type",label:"Cycle Type"},{key:"kpi_name",label:"KPI Name"},{key:"cost_per_cycle",label:"Cost / Cycle"},{key:"escalation_level",label:"Escalation"},{key:"workflow_state",label:"Workflow State"}],defaultColumns:["number","title","organization","type","status","date_start","date_end","actor"]},organizations:{label:"Organizations",columns:[{key:"name",label:"Code"},{key:"organization_name",label:"Organization Name"},{key:"type",label:"Type"},{key:"city",label:"City"},{key:"contact_email",label:"Contact Email"},{key:"is_active",label:"Active"},{key:"creation_date",label:"Created On"}],defaultColumns:["organization_name","type","city","contact_email","is_active"]},managements:{label:"Managements",orgField:"organization",columns:[{key:"name1",label:"Name"},{key:"organization",label:"Organization"},{key:"status",label:"Status"},{key:"creation_date",label:"Created On"}],defaultColumns:["name1","organization","status"]},departments:{label:"Departments",orgField:"custom_organization",columns:[{key:"department_name",label:"Department Name"},{key:"custom_organization",label:"Organization"},{key:"custom_management",label:"Management"},{key:"custom_status",label:"Status"},{key:"custom_creation_date",label:"Created On"}],defaultColumns:["department_name","custom_organization","custom_management","custom_status"]},branches:{label:"Branches",orgField:"organization",columns:[{key:"branch",label:"Branch"},{key:"organization",label:"Organization"},{key:"management",label:"Management"},{key:"department",label:"Department"},{key:"custom_status",label:"Status"},{key:"custom_creation_date",label:"Created On"}],defaultColumns:["branch","organization","management","department","custom_status"]},cycles:{label:"Cycles",orgField:"organization",columns:[{key:"name1",label:"Name"},{key:"organization",label:"Organization"},{key:"frequency",label:"Frequency"},{key:"status",label:"Status"},{key:"start_date",label:"Start Date"},{key:"end_date",label:"End Date"},{key:"update_window_days",label:"Update Window (days)"}],defaultColumns:["name1","organization","frequency","status","start_date","end_date"]},"kpi-input":{label:"KPI Input",orgField:"organization",columns:[{key:"organization",label:"Organization"},{key:"period",label:"Period"},{key:"revenue_growth",label:"Revenue Growth"},{key:"net_profit",label:"Net Profit"},{key:"cash_flow",label:"Cash Flow"},{key:"strategic_goal_pct",label:"Strategic Goal %"},{key:"customer_satisfaction",label:"Customer Satisfaction"},{key:"employee_turnover_pct",label:"Employee Turnover %"},{key:"open_safety_incidents",label:"Open Safety Incidents"},{key:"compliance_score",label:"Compliance Score"}],defaultColumns:["organization","period","revenue_growth","net_profit","cash_flow"]},"incident-types":{label:"Incident Types",columns:xn(),defaultColumns:["name1","status","creation_date"]},"idea-types":{label:"Idea Types",columns:xn(),defaultColumns:["name1","status","creation_date"]},"order-types":{label:"Order Types",columns:xn(),defaultColumns:["name1","status","creation_date"]},"process-types":{label:"Process Types",columns:xn(),defaultColumns:["name1","status","creation_date"]},"incident-statuses":{label:"Incident Statuses",columns:xn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"idea-statuses":{label:"Idea Statuses",columns:xn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"order-statuses":{label:"Order Statuses",columns:xn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},"process-statuses":{label:"Process Statuses",columns:xn([{key:"notify_manager",label:"Notify Manager"}]),defaultColumns:["name1","status","notify_manager"]},users:{label:"Users",orgField:"custom_organization",columns:[{key:"full_name",label:"Full Name"},{key:"email",label:"Email"},{key:"username",label:"Username"},{key:"mobile_no",label:"Phone"},{key:"custom_category",label:"Category"},{key:"custom_organization",label:"Organization"},{key:"custom_management",label:"Management"},{key:"custom_department",label:"Department"},{key:"custom_branch",label:"Branch"},{key:"custom_number",label:"User ID No"},{key:"enabled",label:"Active"},{key:"creation",label:"Created On"}],defaultColumns:["full_name","email","custom_category","custom_organization","enabled"]},delegations:{label:"Delegations",orgField:"organization",columns:[{key:"number",label:"Number"},{key:"auditor",label:"Auditor"},{key:"manager",label:"Manager"},{key:"organization",label:"Organization"},{key:"create_processes",label:"Create Processes"},{key:"update_process_status",label:"Update Process Status"},{key:"status",label:"Status"},{key:"requested_on",label:"Requested On"},{key:"responded_on",label:"Responded On"}],defaultColumns:["number","auditor","manager","organization","status","requested_on"]}},Km="modulepreload",Qm=function(e){return"/"+e},eu={},Gm=function(t,l,s){let r=Promise.resolve();if(l&&l.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),d=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));r=Promise.allSettled(l.map(u=>{if(u=Qm(u),u in eu)return;eu[u]=!0;const f=u.endsWith(".css"),y=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${y}`))return;const p=document.createElement("link");if(p.rel=f?"stylesheet":Km,f||(p.as="script"),p.crossOrigin="",p.href=u,d&&p.setAttribute("nonce",d),document.head.appendChild(p),f)return new Promise((c,v)=>{p.addEventListener("load",c),p.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(a){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=a,window.dispatchEvent(d),!d.defaultPrevented)throw a}return r.then(a=>{for(const d of a||[])d.status==="rejected"&&i(d.reason);return t().catch(i)})};function Rf(e,t){const l=e[t.key];return l==null||l===""?"":typeof l=="object"?JSON.stringify(l):String(l)}function Ym(e,t){const l=URL.createObjectURL(e),s=document.createElement("a");s.href=l,s.download=t,s.click(),URL.revokeObjectURL(l)}function Xm(e,t,l){const s=e.map(a=>`"${a.label.replace(/"/g,'""')}"`).join(","),r=t.map(a=>e.map(d=>`"${Rf(a,d).replace(/"/g,'""')}"`).join(",")).join(`
`),i=new Blob([s+`
`+r],{type:"text/csv;charset=utf-8;"});Ym(i,`${l}.csv`)}async function qm(e,t,l){const s=await Gm(()=>import("./xlsx-D_0l8YDs.js"),[]),r=t.map(d=>{const u={};for(const f of e)u[f.label]=Rf(d,f);return u}),i=s.utils.json_to_sheet(r,{header:e.map(d=>d.label)}),a=s.utils.book_new();s.utils.book_append_sheet(a,i,"Export"),s.writeFile(a,`${l}.xlsx`)}const Wr="#16a34a";function Jm({title:e,rows:t,columns:l,defaultColumnKeys:s,orgField:r,organizations:i,filenameBase:a,onClose:d}){const[u,f]=j.useState(""),[y,p]=j.useState("csv"),[c,v]=j.useState(new Set(s)),b=u?t.filter(x=>x[r||"organization"]===u):t,g=l.filter(x=>c.has(x.key)),S=x=>{v(z=>{const R=new Set(z);return R.has(x)?R.delete(x):R.add(x),R})},h=async()=>{g.length===0||b.length===0||(y==="csv"?Xm(g,b,a):await qm(g,b,a),d())},m={fontSize:11,fontWeight:700,color:"#9ca3af",letterSpacing:.4,textTransform:"uppercase",marginBottom:10},o={background:"none",border:"none",color:"#2563eb",fontSize:12,fontWeight:600,cursor:"pointer",padding:0,fontFamily:"inherit"};return n.jsx("div",{onClick:d,style:{position:"fixed",inset:0,background:"rgba(15,23,42,0.55)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},children:n.jsxs("div",{onClick:x=>x.stopPropagation(),style:{width:560,maxWidth:"92vw",maxHeight:"86vh",background:"white",borderRadius:12,boxShadow:"0 20px 60px rgba(0,0,0,0.3)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[n.jsxs("div",{style:{background:Wr,color:"white",padding:"16px 22px",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:16,fontWeight:700},children:[n.jsx("span",{style:{fontSize:18},children:"📤"})," Export ",e]}),n.jsx("button",{onClick:d,style:{background:"rgba(255,255,255,0.15)",border:"none",color:"white",width:28,height:28,borderRadius:8,cursor:"pointer",fontSize:15,lineHeight:1},children:"✕"})]}),n.jsxs("div",{style:{padding:"20px 22px",overflowY:"auto",flex:1},children:[r&&i&&i.length>0&&n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:m,children:"Filter by Organization"}),n.jsxs("select",{value:u,onChange:x=>f(x.target.value),style:{width:"100%",padding:"9px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",boxSizing:"border-box"},children:[n.jsxs("option",{value:"",children:["All Organizations (",t.length," total)"]}),i.map(x=>n.jsx("option",{value:x.name,children:x.organization_name||x.name},x.name))]})]}),n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:m,children:"File Format"}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[{id:"csv",label:"CSV",desc:"Comma-separated values"},{id:"xlsx",label:"Excel",desc:"XLSX spreadsheet"}].map(x=>n.jsxs("div",{onClick:()=>p(x.id),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",borderRadius:10,cursor:"pointer",border:`2px solid ${y===x.id?Wr:"#e5e7eb"}`,background:y===x.id?"#f0fdf4":"white"},children:[n.jsx("span",{style:{fontSize:20},children:x.id==="csv"?"📄":"📊"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:13,fontWeight:700,color:"#1a2332"},children:x.label}),n.jsx("div",{style:{fontSize:11,color:"#888"},children:x.desc})]})]},x.id))})]}),n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[n.jsx("div",{style:{...m,marginBottom:0},children:"Columns to Export"}),n.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[n.jsx("button",{onClick:()=>v(new Set(l.map(x=>x.key))),style:o,children:"Select All"}),n.jsx("span",{style:{color:"#d1d5db"},children:"|"}),n.jsx("button",{onClick:()=>v(new Set(s)),style:o,children:"Reset to Default"})]})]}),n.jsx("div",{style:{border:"1px solid #e5e7eb",borderRadius:8,padding:12,maxHeight:170,overflowY:"auto"},children:n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:"10px 12px"},children:l.map(x=>n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:7,fontSize:13,color:"#374151",cursor:"pointer"},children:[n.jsx("input",{type:"checkbox",checked:c.has(x.key),onChange:()=>S(x.key),style:{accentColor:Wr,cursor:"pointer"}}),x.label]},x.key))})}),n.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:6},children:[c.size," column",c.size!==1?"s":""," selected"]})]})]}),n.jsxs("div",{style:{padding:"14px 22px",borderTop:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[n.jsx("span",{style:{fontSize:12,color:"#888"},children:u?`Exporting ${b.length} filtered row${b.length!==1?"s":""}`:`Exporting all ${b.length} row${b.length!==1?"s":""}`}),n.jsxs("div",{style:{display:"flex",gap:10},children:[n.jsx("button",{onClick:d,style:{padding:"9px 18px",borderRadius:8,border:"1px solid #e5e7eb",background:"white",color:"#374151",fontWeight:600,fontSize:13,cursor:"pointer",fontFamily:"inherit"},children:"Cancel"}),n.jsx("button",{onClick:h,disabled:g.length===0||b.length===0,style:{padding:"9px 20px",borderRadius:8,border:"none",background:Wr,color:"white",fontWeight:700,fontSize:13,cursor:g.length===0||b.length===0?"not-allowed":"pointer",opacity:g.length===0||b.length===0?.5:1,fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"})]})]})]})})}function Lf({collapsed:e,onToggleCollapsed:t,activePage:l,onNavigate:s,hasDashboard:r,hasReports:i,hasDelegations:a,role:d,hideSettings:u,rtl:f,navLabels:y,settingsLabel:p}){const c=u?[]:Mm(d);return n.jsxs("div",{style:{width:e?58:230,background:"linear-gradient(175deg, #1a0f42 0%, #2a1260 45%, #102840 100%)",color:"white",flexShrink:0,display:"flex",flexDirection:"column",position:"sticky",top:0,height:"100vh",transition:"width 0.22s ease",overflow:"hidden"},children:[n.jsxs("div",{style:{padding:e?"16px 0":"16px 20px 14px",borderBottom:"1px solid rgba(255,255,255,0.08)",display:"flex",alignItems:"center",justifyContent:e?"center":"space-between",gap:8,flexShrink:0},children:[!e&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,overflow:"hidden"},children:[n.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"linear-gradient(135deg, #312e81 0%, #4f46e5 100%)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:n.jsx("span",{style:{fontSize:16,color:"white",fontWeight:800,fontFamily:"serif"},children:"S"})}),n.jsx("span",{style:{fontSize:16,fontWeight:700,whiteSpace:"nowrap",color:"white"},children:f?"صدرة":"Sidrah"})]}),n.jsx("button",{onClick:t,title:e?f?"توسيع":"Expand":f?"طي":"Collapse",style:{background:"rgba(255,255,255,0.08)",border:"none",borderRadius:7,color:"rgba(255,255,255,0.7)",cursor:"pointer",fontSize:12,padding:"5px 8px",flexShrink:0,lineHeight:1,transition:"background 0.15s"},children:e?"▶":"✕"})]}),n.jsxs("nav",{style:{padding:"12px 8px",flex:1,overflowY:"auto",overflowX:"hidden"},children:[$m.filter(({id:v})=>(v!=="dashboard"||r)&&(v!=="reports"||i)&&(v!=="delegations"||a)).map(({id:v,icon:b})=>{const g=y[v]||v,S=v===l;return n.jsxs("div",{onClick:()=>s(v),title:e?g:void 0,style:{padding:e?"8px 0":"8px 14px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:9,background:S?"rgba(139,92,246,0.28)":"transparent",borderRadius:8,fontSize:e?15:12,color:"white",fontWeight:S?600:400,transition:"all 0.15s",whiteSpace:"nowrap",marginBottom:2},children:[n.jsx("span",{style:{flexShrink:0},children:b}),!e&&g]},v)}),c.length>0&&n.jsxs(n.Fragment,{children:[!e&&n.jsx("div",{style:{padding:"10px 14px 4px",fontSize:10,color:"rgba(255,255,255,0.6)",fontWeight:700,letterSpacing:1,textTransform:"uppercase",marginTop:8},children:p}),e&&n.jsx("div",{style:{margin:"10px auto",width:28,borderTop:"1px solid rgba(255,255,255,0.12)"}}),c.map(({id:v,icon:b})=>{const g=y[v]||v,S=v===l;return n.jsxs("div",{onClick:()=>s(v),title:e?g:void 0,style:{padding:e?"8px 0":"8px 14px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:e?"center":"flex-start",gap:9,background:S?"rgba(139,92,246,0.25)":"transparent",borderRadius:8,fontSize:e?15:12,color:"white",fontWeight:S?600:400,transition:"all 0.15s",whiteSpace:"nowrap",marginBottom:2},children:[n.jsx("span",{style:{flexShrink:0},children:b}),!e&&g]},v)})]})]})]})}const Of="sidrah_rtl",Co="sidrah-lang-change";function ql(){try{return localStorage.getItem(Of)==="1"}catch{return!1}}function Df(){const e=!ql();try{localStorage.setItem(Of,e?"1":"0")}catch{}document.documentElement.setAttribute("dir",e?"rtl":"ltr"),document.documentElement.setAttribute("lang",e?"ar":"en-GB"),window.dispatchEvent(new CustomEvent(Co))}function ee(){const[e,t]=j.useState(ql);return j.useEffect(()=>{const l=()=>t(ql());return window.addEventListener(Co,l),document.documentElement.setAttribute("dir",ql()?"rtl":"ltr"),document.documentElement.setAttribute("lang",ql()?"ar":"en-GB"),()=>window.removeEventListener(Co,l)},[]),e?Vm:Zm}const Zm={rtl:!1,nav:{dashboard:"Dashboard",inbox:"Inbox",incidents:"Incidents",ideas:"Ideas",orders:"Orders",processes:"Processes",delegations:"Delegations",reports:"Reports",users:"Users",organizations:"Organizations",managements:"Managements",departments:"Departments",branches:"Branches",cycles:"Cycles","kpi-input":"KPI Input","incident-types":"Incident Types","idea-types":"Idea Types","order-types":"Order Types","process-types":"Process Types","incident-statuses":"Incident Statuses","idea-statuses":"Idea Statuses","order-statuses":"Order Statuses","process-statuses":"Process Statuses",settings:"Settings"},pages:{dashboard:"Dashboard",inbox:"Inbox",reports:"Reports",incidents:"Incidents",ideas:"Ideas",orders:"Orders",processes:"Processes",delegations:"Delegations",organizations:"Organizations",managements:"Managements",departments:"Departments",branches:"Branches",cycles:"Cycles","kpi-input":"KPI Input","incident-types":"Incident Types","idea-types":"Idea Types","order-types":"Order Types","process-types":"Process Types","incident-statuses":"Incident Statuses","idea-statuses":"Idea Statuses","order-statuses":"Order Statuses","process-statuses":"Process Statuses",users:"Users"},new:"+ New",save:"Save",cancel:"Cancel",edit:"Edit",delete:"Delete",view:"View",back:"← Back",clear:"Clear",search:"Search",loading:"Loading...",saving:"Saving...",savedOk:"Saved successfully!",home:"Home",noRecords:"No records found",login:{subtitle:"Sign in to continue",username:"USERNAME",password:"PASSWORD",usernamePlaceholder:"Enter username",passwordPlaceholder:"Enter password",signIn:"Sign In",signingIn:"Signing in...",invalidCreds:"Invalid username or password",emptyFields:"Please enter username and password",connError:"Connection error: "},myProfile:"My Profile",signOut:"Sign Out",switchLang:"العربية (RTL)",filter:{numberTitle:"Number / Title",searchPlaceholder:"Search...",organization:"Organization",department:"Department",branch:"Branch",status:"Status",allOrgs:"All Organizations",allDepts:"All Departments",allBranches:"All Branches",allStatuses:"All Statuses",allTypes:"All Types"},col:{number:"Number",title:"Title",organization:"Organization",type:"Type",status:"Status",actions:"Actions",name:"Name",department:"Department",branch:"Branch",city:"City",email:"Email",management:"Management",organization_type:"Type",frequency:"Frequency",period:"Period",startDate:"Start Date",endDate:"End Date",auditor:"Auditor",manager:"Manager",functions:"Functions",requestedOn:"Requested On"},field:{number:"Number",title:"Title",organization:"Organization",management:"Management",department:"Department",section:"Section",branch:"Branch",type:"Type",date:"Date",time:"Time",status:"Status",description:"Description",assignedTo:"Assigned To",hsesField:"HSES Field",priority:"Priority",economyClass:"Economy Class",entityScope:"Entity Scope",productRelation:"Product Relation",repeatedEvent:"Repeated Event",solution:"Solution / Action Plan",actualCost:"Actual Cost",summary:"Resolution Summary",auditorComment:"Auditor Comment",incidentClass:"Incident Class",incidentField:"Incident Field",currentCondition:"Current Condition",proposedCondition:"Proposed Condition",ideaClass:"Idea Class",startingDate:"Starting Date",endingDate:"Ending Date",budget:"Budget",currency:"Currency",notes:"Notes",cycle:"Cycle",stage:"Stage",completionPct:"Completion %",actor:"Actor",escalationLevel:"Escalation Level",dateStart:"Start Date",dateEnd:"End Date",cycleType:"Cycle Type",progressIndicators:"Progress Indicators",impactLevel:"Impact Level",kpiName:"KPI Name",kpiType:"KPI Type",kpiMeasure:"KPI Measure",costPerCycle:"Cost per Cycle",chainLocation:"Chain Location",notifyManager:"Notify Manager",creationDate:"Creation Date",statusActive:"Active",statusInactive:"Inactive",name1:"Name",fullName:"Full Name",username:"Username",emailAddress:"Email Address",phoneNumber:"Phone Number",category:"Category",since:"Since",active:"Active",inactive:"Inactive",enabled:"Enabled",selectMgr:"-- Select manager --",select:"-- Select --",selectType:"-- Select type --",selectClass:"-- Select class --",selectField:"-- Select field --",selectStatus:"-- Select status --",solutionPlaceholder:"Describe the solution or action taken…",commentPlaceholder:"Optional comment…",high:"High",normal:"Normal",expenses:"Expenses",capital:"Capital",earn:"Earn",payLoss:"Pay/Loss",upstream:"Upstream",onstream:"On-stream",downstream:"Downstream",government:"Government",private:"Private",monthly:"Monthly",quarterly:"Quarterly",yearly:"Yearly",cycleActive:"Active",cycleCompleted:"Completed",cyclePaused:"Paused",updateWindowDays:"Update Window (days)",incidentTriageWindowDays:"Triage Window (days)",incidentResolutionWindowDays:"Resolution Window (days)",orgAcronym:"Acronym",contactEmail:"Contact Email",orgCity:"City",orgName:"Organization Name",organizationType:"Organization Type",revenue_growth:"Revenue Growth (%)",net_profit:"Net Profit",cash_flow:"Cash Flow",strategic_goal_pct:"Strategic Goal (%)",customer_satisfaction:"Customer Satisfaction",employee_turnover_pct:"Employee Turnover (%)",open_safety_incidents:"Open Safety Incidents",compliance_score:"Compliance Score"},wf:{workflow:"Workflow",noActions:"No actions available for your role in this state.",applying:"Applying…",submit:"Submit",assignToManager:"Assign to Manager",reject:"Reject",submitSolution:"Submit Solution",resolutionComplete:"Resolution complete",moveToOutsourcing:"Move to Outsourcing",closeIdea:"Close Idea"},steps:{auditorTriage:"Auditor Triage (Step 2)",managerSolution:"Manager Solution (Step 3)",ownerComment:"Owner / Auditor Comment (Step 4)",auditorEval:"Auditor Evaluation (Step 2)",managerReview:"Manager Review (Step 3)"},formTitle:{newIncident:"New Incident",editIncident:"Edit Incident",viewIncident:"Incident: ",newIdea:"New Idea",editIdea:"Edit Idea",viewIdea:"Idea: ",newOrder:"New Order",editOrder:"Edit Order",viewOrder:"Order: ",newProcess:"New Process",editProcess:"Edit Process",viewProcess:"Process: ",newOrg:"New Organization",editOrg:"Edit Organization",newMgmt:"New Management",editMgmt:"Edit Management",newDept:"New Department",editDept:"Edit Department",newBranch:"New Branch",editBranch:"Edit Branch",newUser:"New User",editUser:"Edit User",viewUser:"User Profile",newCycle:"New Cycle",editCycle:"Edit Cycle",newKpi:"New KPI Input",editKpi:"Edit KPI Input",newDelegation:"New Delegation",viewDelegation:"Delegation: "},saveIncident:"Save Incident",saveIdea:"Save Idea",saveOrder:"Save Order",saveProcess:"Save Process",saveOrg:"Save Organization",saveMgmt:"Save Management",saveDept:"Save Department",saveBranch:"Save Branch",saveUser:"Save User",saveCycle:"Save Cycle",saveKpi:"Save KPI Input",saveDelegation:"Send Delegation",saveName:"Save",dash:{allOrgs:"All organizations",incidents:"Incidents",ideas:"Ideas",orders:"Orders",processes:"Processes",level2:"Level 2 — Critical Escalation",level1:"Level 1 — Auditor Review Needed",overduePrefix:"Overdue for Triage — ",overdueSuffix:" incident(s) past 3-day window",untriaged:"Untriaged Incidents",recentKpi:"Recent KPI Inputs",manageKpi:"Manage KPI Inputs",escalatedProcesses:"Escalated Processes",escalatedOrders:"Escalated Orders",level:"Level",revenueGrowth:"Revenue Growth",netProfit:"Net Profit",strategicGoal:"Strategic Goal",customerSat:"Customer Sat.",compliance:"Compliance",safetyInc:"Safety Incidents",total:"Total"},noIncidents:"No incidents found",noIdeas:"No ideas found",noOrders:"No orders found",noProcesses:"No processes found",noUsers:"No users found",noData:"No data found",users:{category:"Category",number:"Number",fullName:"Full Name",username:"Username",email:"Email Address",phone:"Phone Number",organization:"Organization",management:"Management",department:"Department",branch:"Branch",since:"Since",status:"Status",tools:"Tools",active:"Active",inactive:"Inactive",setPassword:"Set Password",newPassword:"New password",passwordUpdated:"Password updated!",passwordFailed:"Failed. Please try again.",disableConfirm:"Delete user? They will no longer appear in the list.",password:"Password"},inbox:{title:"Inbox",noMessages:"No messages"},reports:{title:"Reports",selectOrg:"Select Organization",generate:"Generate Report"},comments:{title:"Comments",placeholder:"Write a comment…",post:"Post",noComments:"No comments yet."},activity:{title:"Activity Log",created:"Created",by:"by"}},Vm={rtl:!0,nav:{dashboard:"لوحة التحكم",inbox:"البريد الوارد",incidents:"الحوادث",ideas:"الأفكار",orders:"الطلبات",processes:"العمليات",delegations:"التفويضات",reports:"التقارير",users:"المستخدمون",organizations:"المؤسسات",managements:"الإدارات",departments:"الأقسام",branches:"الفروع",cycles:"الدورات","kpi-input":"مؤشرات الأداء","incident-types":"أنواع الحوادث","idea-types":"أنواع الأفكار","order-types":"أنواع الطلبات","process-types":"أنواع العمليات","incident-statuses":"حالات الحوادث","idea-statuses":"حالات الأفكار","order-statuses":"حالات الطلبات","process-statuses":"حالات العمليات",settings:"الإعدادات"},pages:{dashboard:"لوحة التحكم",inbox:"البريد الوارد",reports:"التقارير",incidents:"الحوادث",ideas:"الأفكار",orders:"الطلبات",processes:"العمليات",delegations:"التفويضات",organizations:"المؤسسات",managements:"الإدارات",departments:"الأقسام",branches:"الفروع",cycles:"الدورات","kpi-input":"مؤشرات الأداء","incident-types":"أنواع الحوادث","idea-types":"أنواع الأفكار","order-types":"أنواع الطلبات","process-types":"أنواع العمليات","incident-statuses":"حالات الحوادث","idea-statuses":"حالات الأفكار","order-statuses":"حالات الطلبات","process-statuses":"حالات العمليات",users:"المستخدمون"},new:"+ جديد",save:"حفظ",cancel:"إلغاء",edit:"تعديل",delete:"حذف",view:"عرض",back:"رجوع →",clear:"مسح",search:"بحث",loading:"جارٍ التحميل...",saving:"جارٍ الحفظ...",savedOk:"تم الحفظ بنجاح!",home:"الرئيسية",noRecords:"لا توجد سجلات",login:{subtitle:"تسجيل الدخول للمتابعة",username:"اسم المستخدم",password:"كلمة المرور",usernamePlaceholder:"أدخل اسم المستخدم",passwordPlaceholder:"أدخل كلمة المرور",signIn:"تسجيل الدخول",signingIn:"جارٍ تسجيل الدخول...",invalidCreds:"اسم المستخدم أو كلمة المرور غير صحيحة",emptyFields:"الرجاء إدخال اسم المستخدم وكلمة المرور",connError:"خطأ في الاتصال: "},myProfile:"ملفي الشخصي",signOut:"تسجيل الخروج",switchLang:"English (LTR)",filter:{numberTitle:"الرقم / العنوان",searchPlaceholder:"بحث...",organization:"المؤسسة",department:"القسم",branch:"الفرع",status:"الحالة",allOrgs:"جميع المؤسسات",allDepts:"جميع الأقسام",allBranches:"جميع الفروع",allStatuses:"جميع الحالات",allTypes:"جميع الأنواع"},col:{number:"الرقم",title:"العنوان",organization:"المؤسسة",type:"النوع",status:"الحالة",actions:"الإجراءات",name:"الاسم",department:"القسم",branch:"الفرع",city:"المدينة",email:"البريد الإلكتروني",management:"الإدارة",organization_type:"النوع",frequency:"التكرار",period:"الفترة",startDate:"تاريخ البدء",endDate:"تاريخ الانتهاء",auditor:"المدقق",manager:"المدير",functions:"الوظائف",requestedOn:"تاريخ الطلب"},field:{number:"الرقم",title:"العنوان",organization:"المؤسسة",management:"الإدارة",department:"القسم",section:"القطاع",branch:"الفرع",type:"النوع",date:"التاريخ",time:"الوقت",status:"الحالة",description:"الوصف",assignedTo:"مُسند إلى",hsesField:"مجال السلامة والصحة",priority:"الأولوية",economyClass:"التصنيف الاقتصادي",entityScope:"نطاق الكيان",productRelation:"علاقة المنتج",repeatedEvent:"حدث متكرر",solution:"الحل / خطة العمل",actualCost:"التكلفة الفعلية",summary:"ملخص الحل",auditorComment:"تعليق المدقق",incidentClass:"تصنيف الحادث",incidentField:"مجال الحادث",currentCondition:"الوضع الراهن",proposedCondition:"الوضع المقترح",ideaClass:"تصنيف الفكرة",startingDate:"تاريخ البدء",endingDate:"تاريخ الانتهاء",budget:"الميزانية",currency:"العملة",notes:"الملاحظات",cycle:"الدورة",stage:"المرحلة",completionPct:"نسبة الاكتمال",actor:"المنفذ",escalationLevel:"مستوى التصعيد",dateStart:"تاريخ البدء",dateEnd:"تاريخ الانتهاء",cycleType:"نوع الدورة",progressIndicators:"مؤشرات التقدم",impactLevel:"مستوى التأثير",kpiName:"اسم المؤشر",kpiType:"نوع المؤشر",kpiMeasure:"قياس المؤشر",costPerCycle:"التكلفة لكل دورة",chainLocation:"موقع السلسلة",notifyManager:"إشعار المدير",creationDate:"تاريخ الإنشاء",statusActive:"نشط",statusInactive:"غير نشط",name1:"الاسم",fullName:"الاسم الكامل",username:"اسم المستخدم",emailAddress:"البريد الإلكتروني",phoneNumber:"رقم الهاتف",category:"الفئة",since:"منذ",active:"نشط",inactive:"غير نشط",enabled:"مفعّل",selectMgr:"-- اختر المدير --",select:"-- اختر --",selectType:"-- اختر النوع --",selectClass:"-- اختر التصنيف --",selectField:"-- اختر المجال --",selectStatus:"-- اختر الحالة --",solutionPlaceholder:"صف الحل أو الإجراء المتخذ…",commentPlaceholder:"تعليق اختياري…",high:"عالي",normal:"عادي",expenses:"مصروفات",capital:"رأس مال",earn:"إيرادات",payLoss:"دفع/خسارة",upstream:"مرحلة المنبع",onstream:"على الخط",downstream:"مرحلة المصب",government:"حكومي",private:"خاص",monthly:"شهري",quarterly:"ربع سنوي",yearly:"سنوي",cycleActive:"نشط",cycleCompleted:"مكتمل",cyclePaused:"موقوف",updateWindowDays:"نافذة التحديث (أيام)",incidentTriageWindowDays:"نافذة الفرز (أيام)",incidentResolutionWindowDays:"نافذة الحل (أيام)",orgAcronym:"الاختصار",contactEmail:"البريد الإلكتروني للتواصل",orgCity:"المدينة",orgName:"اسم المؤسسة",organizationType:"نوع المؤسسة",revenue_growth:"نمو الإيرادات (%)",net_profit:"صافي الربح",cash_flow:"التدفق النقدي",strategic_goal_pct:"الهدف الاستراتيجي (%)",customer_satisfaction:"رضا العملاء",employee_turnover_pct:"معدل دوران الموظفين (%)",open_safety_incidents:"حوادث السلامة المفتوحة",compliance_score:"درجة الامتثال"},wf:{workflow:"سير العمل",noActions:"لا توجد إجراءات متاحة لدورك في هذه الحالة.",applying:"جارٍ التطبيق...",submit:"إرسال",assignToManager:"تعيين للمدير",reject:"رفض",submitSolution:"إرسال الحل",resolutionComplete:"اكتمال الحل",moveToOutsourcing:"نقل للاستعانة بمصادر خارجية",closeIdea:"إغلاق الفكرة"},steps:{auditorTriage:"فرز المدقق (الخطوة 2)",managerSolution:"حل المدير (الخطوة 3)",ownerComment:"تعليق المالك / المدقق (الخطوة 4)",auditorEval:"تقييم المدقق (الخطوة 2)",managerReview:"مراجعة المدير (الخطوة 3)"},formTitle:{newIncident:"حادث جديد",editIncident:"تعديل الحادث",viewIncident:"الحادث: ",newIdea:"فكرة جديدة",editIdea:"تعديل الفكرة",viewIdea:"الفكرة: ",newOrder:"طلب جديد",editOrder:"تعديل الطلب",viewOrder:"الطلب: ",newProcess:"عملية جديدة",editProcess:"تعديل العملية",viewProcess:"العملية: ",newOrg:"مؤسسة جديدة",editOrg:"تعديل المؤسسة",newMgmt:"إدارة جديدة",editMgmt:"تعديل الإدارة",newDept:"قسم جديد",editDept:"تعديل القسم",newBranch:"فرع جديد",editBranch:"تعديل الفرع",newUser:"مستخدم جديد",editUser:"تعديل المستخدم",viewUser:"ملف المستخدم",newCycle:"دورة جديدة",editCycle:"تعديل الدورة",newKpi:"مؤشر أداء جديد",editKpi:"تعديل مؤشر الأداء",newDelegation:"تفويض جديد",viewDelegation:"التفويض: "},saveIncident:"حفظ الحادث",saveIdea:"حفظ الفكرة",saveOrder:"حفظ الطلب",saveProcess:"حفظ العملية",saveOrg:"حفظ المؤسسة",saveMgmt:"حفظ الإدارة",saveDept:"حفظ القسم",saveBranch:"حفظ الفرع",saveUser:"حفظ المستخدم",saveCycle:"حفظ الدورة",saveKpi:"حفظ مؤشر الأداء",saveDelegation:"إرسال التفويض",saveName:"حفظ",dash:{allOrgs:"جميع المؤسسات",incidents:"الحوادث",ideas:"الأفكار",orders:"الطلبات",processes:"العمليات",level2:"المستوى 2 — تصعيد حرج",level1:"المستوى 1 — مراجعة المدقق مطلوبة",overduePrefix:"متأخر للفرز — ",overdueSuffix:" حادث(ة) تجاوز نافذة 3 أيام",untriaged:"حوادث غير مفرزة",recentKpi:"مؤشرات الأداء الأخيرة",manageKpi:"إدارة مؤشرات الأداء",escalatedProcesses:"عمليات متصاعدة",escalatedOrders:"طلبات متصاعدة",level:"المستوى",revenueGrowth:"نمو الإيرادات",netProfit:"صافي الربح",strategicGoal:"الهدف الاستراتيجي",customerSat:"رضا العملاء",compliance:"الامتثال",safetyInc:"حوادث السلامة",total:"الإجمالي"},noIncidents:"لا توجد حوادث",noIdeas:"لا توجد أفكار",noOrders:"لا توجد طلبات",noProcesses:"لا توجد عمليات",noUsers:"لا يوجد مستخدمون",noData:"لا توجد بيانات",users:{category:"الفئة",number:"الرقم",fullName:"الاسم الكامل",username:"اسم المستخدم",email:"البريد الإلكتروني",phone:"رقم الهاتف",organization:"المؤسسة",management:"الإدارة",department:"القسم",branch:"الفرع",since:"منذ",status:"الحالة",tools:"الأدوات",active:"نشط",inactive:"غير نشط",setPassword:"تعيين كلمة المرور",newPassword:"كلمة مرور جديدة",passwordUpdated:"تم تحديث كلمة المرور!",passwordFailed:"فشل. الرجاء المحاولة مرة أخرى.",disableConfirm:"حذف المستخدم؟ لن يظهر في القائمة بعد الآن.",password:"كلمة المرور"},inbox:{title:"البريد الوارد",noMessages:"لا توجد رسائل"},reports:{title:"التقارير",selectOrg:"اختر المؤسسة",generate:"إنشاء التقرير"},comments:{title:"التعليقات",placeholder:"اكتب تعليقاً…",post:"نشر",noComments:"لا توجد تعليقات بعد."},activity:{title:"سجل النشاط",created:"أُنشئ",by:"بواسطة"}},pr=new Set(["SB Incident","SB Idea","SB Order","SB Process","SB Organization","SB Cycle","SB KPI Input","Managements","Department","Branch","Incident Types","Idea Types","Order Types","Process Types","Incident Class","Incident Field","Incident Statuses","Idea Statuses","Order Statuses","Process Statuses"]);let dl="";async function Sc(){try{const e=await fetch(`${ce}/api/method/sidrah_business.api.get_csrf_token`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(e.ok){const l=(await e.json()).message||"";if(l)return dl=l,l}}catch(e){console.error("CSRF fetch error:",e)}return dl}async function fn(){return dl||await Sc(),dl}function tu(e,t){try{if(e!=null&&e._server_messages){const l=JSON.parse(e._server_messages);if(l.length){const s=JSON.parse(l[0]);if(s!=null&&s.message)return s.message.replace(/<[^>]+>/g,"")}}}catch{}return(e==null?void 0:e.message)||(e==null?void 0:e.exception)||t}async function mt(e,t,l=[]){if(pr.has(e)){const a=`${ce}/api/method/sidrah_business.api.get_sb_doc?doctype=${encodeURIComponent(e)}&name=${encodeURIComponent(t)}`,d=await fetch(a,{credentials:"include",headers:{Accept:"application/json"}});if(!d.ok)throw new Error(`API Error: ${d.status}`);return(await d.json()).message}const s=l.length?`?fields=${encodeURIComponent(JSON.stringify(l))}`:"",r=await fetch(`${ce}/api/v1/resource/${e}/${encodeURIComponent(t)}${s}`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`API Error: ${r.status}`);return(await r.json()).data}async function Nf(e,t){const l=await fn();if(pr.has(e)){const r=new URLSearchParams({doctype:e,name:t}),i=await fetch(`${ce}/api/method/sidrah_business.api.delete_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":l},body:r.toString()});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(tu(a,`Error deleting ${t}`))}return}const s=await fetch(`${ce}/api/v1/resource/${e}/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"include",headers:{Accept:"application/json","X-Frappe-CSRF-Token":l}});if(!s.ok){const r=await s.json().catch(()=>({}));throw new Error(tu(r,`Error deleting ${t}`))}return await s.json()}async function ke(e){if(pr.has(e))try{const s=`${ce}/api/method/sidrah_business.api.get_sb_list?doctype=${encodeURIComponent(e)}&limit=500`,r=await fetch(s,{credentials:"include",headers:{Accept:"application/json"}});return r.ok?(await r.json()).message||[]:[]}catch{return[]}const t=encodeURIComponent('["*"]'),l=`${ce}/api/v1/resource/${e}?limit_page_length=500&fields=${t}`;try{const s=await fetch(l,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return s.status===401||s.status===403?[]:s.ok?(await s.json()).data||[]:[]}catch(s){return console.error("Get error:",s),[]}}async function za(e,t){const l=await fn();if(pr.has(e)){const r=new URLSearchParams({doctype:e,data_json:JSON.stringify(t)}),i=await fetch(`${ce}/api/method/sidrah_business.api.create_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":l},body:r.toString()});if(!i.ok){const d=await i.json().catch(()=>({}));throw new Error(d.message||d.exc||`Error creating ${e}`)}return{data:(await i.json()).message}}const s=`${ce}/api/v1/resource/${e}`;try{const r=await fetch(s,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":l},body:JSON.stringify(t)});if(r.status===401||r.status===403)throw new Error("Permission denied - login required");if(!r.ok){const i=await r.json();throw new Error(i.message||i.exc||`API Error: ${r.status}`)}return await r.json()}catch(r){throw console.error("Post error:",r),r}}async function Ti(e,t,l){const s=await fn();if(pr.has(e)){const i=new URLSearchParams({doctype:e,name:t,data_json:JSON.stringify(l)}),a=await fetch(`${ce}/api/method/sidrah_business.api.update_sb_doc`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:i.toString()});if(!a.ok){const u=await a.json().catch(()=>({}));throw new Error(u.message||u.exc||`Error updating ${e}`)}return{data:(await a.json()).message}}const r=`${ce}/api/v1/resource/${e}/${encodeURIComponent(t)}`;try{const i=await fetch(r,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":s},body:JSON.stringify(l)});if(i.status===401||i.status===403)throw new Error("Permission denied - login required");if(!i.ok){const a=await i.json();throw new Error(a.message||"Update Error")}return await i.json()}catch(i){throw console.error("Update error:",i),i}}async function ey(){const e=`${ce}/api/v1/resource/User?limit_page_length=500&fields=["name","full_name"]`;try{const t=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return t.status===401||t.status===403?[]:t.ok?(await t.json()).data||[]:[]}catch(t){return console.error("Get users error:",t),[]}}async function ty(e,t){const l=new FormData;l.append("usr",e),l.append("pwd",t);const r=await(await fetch(`${ce}/api/method/login`,{method:"POST",credentials:"include",body:l})).json();return r.csrf_token?dl=r.csrf_token:await Sc(),r}async function ny(){const e=await fn();try{await fetch(`${ce}/api/method/logout`,{method:"POST",credentials:"include",headers:{"X-Frappe-CSRF-Token":e,Accept:"application/json"}})}catch{}dl=""}function ly(){return dl}async function Wf(){try{const e=await fetch(`${ce}/api/method/frappe.auth.get_logged_user`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return e.ok&&(await e.json()).message||""}catch{return""}}async function sy(){const e=JSON.stringify([["name","not in",["Administrator","Guest"]]]),t=`${ce}/api/v1/resource/User?limit_page_length=500&fields=${encodeURIComponent('["*"]')}&filters=${encodeURIComponent(e)}`;try{const l=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).data||[]:[]}catch{return[]}}async function ry(){const e=`${ce}/api/method/sidrah_business.api.get_user_role_map`;try{const t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||{}:{}}catch{return{}}}async function Bf(e,t){await Ti("User",e,{new_password:t})}async function iy(e=20){try{const t=`${ce}/api/method/sidrah_business.api.get_notifications?limit=${e}`,l=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||[]:[]}catch{return[]}}async function ay(){const e=await fn();try{await fetch(`${ce}/api/method/sidrah_business.api.mark_notifications_read`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":e}})}catch{}}async function oy(e){const t=await fn();try{await fetch(`${ce}/api/method/sidrah_business.api.mark_notification_read`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":t},body:new URLSearchParams({name:e}).toString()})}catch{}}async function cy(e){const t=await fn(),l=new URLSearchParams({name:e});await fetch(`${ce}/api/method/sidrah_business.api.disable_user`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":t},body:l.toString()})}async function dy(e,t){try{const l=`${ce}/api/method/sidrah_business.api.get_doc_comments?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(t)}`,s=await fetch(l,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function uy(e,t,l){const s=await fn(),r=new URLSearchParams({doctype:e,docname:t,content:l}),i=await fetch(`${ce}/api/method/sidrah_business.api.post_doc_comment`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:r.toString()});if(!i.ok)throw new Error("Failed to post comment");return(await i.json()).message}async function py(e,t){try{const l=`${ce}/api/method/sidrah_business.api.get_doc_versions?doctype=${encodeURIComponent(e)}&docname=${encodeURIComponent(t)}`,s=await fetch(l,{credentials:"include",headers:{Accept:"application/json"}});return s.ok?(await s.json()).message||[]:[]}catch{return[]}}async function $f(e){try{const t=`${ce}/api/method/sidrah_business.api.get_user_roles?user=${encodeURIComponent(e)}`,l=await fetch(t,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||[]:[]}catch{return[]}}async function fy(){try{const e=`${ce}/api/method/sidrah_business.api.get_my_organization`,t=await fetch(e,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});return t.ok&&(await t.json()).message||""}catch{return""}}async function fl(e,t={}){const l=await fn(),s=new URLSearchParams(t),r=await fetch(`${ce}/api/method/sidrah_business.api.${e}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":l},body:s.toString()});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(a.message||a.exc||`Error calling ${e}`)}return(await r.json()).message}async function hy(e,t,l="",s,r,i){const a={name:e,action:t,comment:l};return s!==void 0&&(a.stage=s),i!==void 0&&(a.cycle_status=i),fl("apply_order_workflow",a)}async function gy(e,t,l=""){return fl("apply_incident_workflow",{name:e,action:t,fields_json:l})}async function xy(e,t,l=""){return fl("apply_idea_workflow",{name:e,action:t,fields_json:l})}async function my(e=""){const t=`${ce}/api/method/sidrah_business.api.get_dashboard_data${e?`?organization=${encodeURIComponent(e)}`:""}`,l=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});return l.ok?(await l.json()).message||{}:{escalated_processes:[],escalated_orders:[],untriaged_incidents:[],kpi_inputs:[]}}async function yy(e,t={}){return fl("get_report_data",{report_name:e,filters_json:JSON.stringify(t)})}async function vy(){try{const e=`${ce}/api/method/sidrah_business.api.get_inbox_items`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function jy(e,t,l="",s=""){return fl("create_delegation",{manager:e,functions_json:JSON.stringify(t),organization:l,remarks:s})}async function by(e,t,l=""){return fl("respond_to_delegation",{name:e,response:t,remarks:l})}async function Sy(e,t=""){return fl("revoke_delegation",{name:e,remarks:t})}async function wy(){try{const e=`${ce}/api/method/sidrah_business.api.get_delegations`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function ky(e){const t=`${ce}/api/method/sidrah_business.api.get_delegation?name=${encodeURIComponent(e)}`,l=await fetch(t,{credentials:"include",headers:{Accept:"application/json"}});if(!l.ok)throw new Error("Failed to load delegation");return(await l.json()).message}async function _y(){try{const e=`${ce}/api/method/sidrah_business.api.get_my_delegated_functions`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||[]:[]}catch{return[]}}async function Cy(){try{const e=`${ce}/api/method/sidrah_business.api.get_my_delegated_organizations`,t=await fetch(e,{credentials:"include",headers:{Accept:"application/json"}});return t.ok?(await t.json()).message||{}:{}}catch{return{}}}async function zy(){const e=ly();return e||Sc()}async function Ls(e){const t=await fetch(`${ce}/api/method/sidrah_business.api.get_process?name=${encodeURIComponent(e)}`,{credentials:"include",headers:{Accept:"application/json"}});if(!t.ok){const s=await t.json().catch(()=>({}));throw new Error(s.message||`Failed to load process (${t.status})`)}const l=await t.json();return l.message||l.data}async function Ty(e,t,l={}){const s=await zy(),r=new URLSearchParams({name:e,action:t});l.actor_status&&r.set("actor_status",String(l.actor_status)),l.actor_comment&&r.set("actor_comment",String(l.actor_comment)),l.progress_indicators&&r.set("progress_indicators",JSON.stringify(l.progress_indicators));const i=await fetch(`${ce}/api/method/sidrah_business.api.apply_process_workflow`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Frappe-CSRF-Token":s},body:r.toString()});if(!i.ok){const d=await i.json().catch(()=>({})),u=d.message||(d.exception?String(d.exception).split(`
`).pop():"")||d.exc_type||`Workflow action "${t}" failed (${i.status})`;throw new Error(u)}const a=await i.json();return a.message||a.data}function Py({onLogin:e}){const t=ee(),[l,s]=j.useState(""),[r,i]=j.useState(""),[a,d]=j.useState(""),[u,f]=j.useState(!1),[y,p]=j.useState(!1),[c,v]=j.useState(!1),b=async()=>{if(!l||!r){d(t.login.emptyFields);return}f(!0),d("");try{const S=await ty(l,r);if(S.message==="Logged In"){const m=await Wf()||l,o=await $f(m),x=o.some(z=>["SB Admin","System Manager"].includes(z))?"Admin":o.includes("SB Auditor")?"Auditor":o.includes("SB Owner")?"Owner":o.includes("SB X-Auditor")?"XAuditor":o.includes("SB Manager")?"Manager":"Employee";e({name:m,full_name:S.full_name||l,role:x})}else d(t.login.invalidCreds)}catch(S){d(t.login.connError+(S instanceof Error?S.message:"Unknown"))}f(!1)},g=S=>({width:"100%",padding:"13px 16px",border:`1.5px solid ${S?"#4f46e5":"#e5e7eb"}`,borderRadius:10,fontSize:15,background:"#ffffff",color:"#374151",outline:"none",transition:"border-color 0.2s, box-shadow 0.2s",boxSizing:"border-box",boxShadow:S?"0 0 0 3px rgba(79,70,229,0.12)":"none"});return n.jsx("div",{style:{minHeight:"100vh",background:"#f3f4f6",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"Segoe UI, system-ui, sans-serif"},children:n.jsxs("div",{style:{background:"white",borderRadius:20,padding:"48px 44px 40px",width:420,boxShadow:"0 4px 32px rgba(0,0,0,0.10)"},children:[n.jsxs("div",{style:{textAlign:"center",marginBottom:28},children:[n.jsx("div",{style:{width:72,height:72,borderRadius:18,background:"linear-gradient(135deg, #312e81 0%, #4f46e5 100%)",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 18px",boxShadow:"0 4px 16px rgba(79,70,229,0.3)"},children:n.jsx("span",{style:{fontSize:32,color:"white",fontWeight:800,fontFamily:"serif"},children:"S"})}),n.jsx("div",{style:{fontSize:24,fontWeight:700,color:"#1e1b4b"},children:t.rtl?"صدرة للأعمال":"Sidrah Business"}),n.jsx("div",{style:{fontSize:13,color:"#6b7280",marginTop:6},children:t.login.subtitle})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[n.jsx("input",{value:l,onChange:S=>s(S.target.value),onKeyDown:S=>S.key==="Enter"&&b(),onFocus:()=>p(!0),onBlur:()=>p(!1),style:g(y),placeholder:t.login.usernamePlaceholder,autoComplete:"username"}),n.jsx("input",{type:"password",value:r,onChange:S=>i(S.target.value),onKeyDown:S=>S.key==="Enter"&&b(),onFocus:()=>v(!0),onBlur:()=>v(!1),style:g(c),placeholder:t.login.passwordPlaceholder,autoComplete:"current-password"}),a&&n.jsx("div",{style:{padding:"10px 14px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:8,color:"#dc2626",fontSize:13},children:a}),n.jsx("button",{onClick:b,disabled:u,style:{background:u?"#a5b4fc":"#4f46e5",color:"white",border:"none",padding:"14px",borderRadius:10,fontSize:15,cursor:u?"not-allowed":"pointer",fontWeight:700,marginTop:4,transition:"background 0.2s, transform 0.1s",letterSpacing:"0.01em"},onMouseEnter:S=>{u||(S.currentTarget.style.background="#4338ca")},onMouseLeave:S=>{u||(S.currentTarget.style.background="#4f46e5")},children:u?t.login.signingIn:t.login.signIn})]}),n.jsx("div",{style:{textAlign:"center",marginTop:14},children:n.jsx("button",{onClick:Df,style:{fontSize:12,color:"#9ca3af",background:"none",border:"none",cursor:"pointer"},children:t.switchLang})})]})})}function Iy(e,t){const l=parseInt(e.replace("#",""),16),s=l>>16&255,r=l>>8&255,i=l&255,a=d=>Math.round(d+(255-d)*t);return`rgb(${a(s)}, ${a(r)}, ${a(i)})`}function ks(e,t){const l=parseInt(e.replace("#",""),16),s=l>>16&255,r=l>>8&255,i=l&255;return`rgba(${s}, ${r}, ${i}, ${t})`}function Br({title:e,data:t,color:l,onSelect:s}){const[,r]=t[0]??["Total",0,""],i=t.slice(1),a=i.map((u,f)=>Iy(l,Math.min(f*.16,.7))),d=i.map(([u,f,y],p)=>[u,f,y,a[p]]).filter(([,u])=>u>0);return n.jsxs("div",{className:"status-card",style:{borderRadius:18,padding:"16px 18px 18px",height:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",minWidth:0,position:"relative",overflow:"hidden"},children:[n.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",background:`linear-gradient(160deg, ${ks(l,.09)} 0%, transparent 55%)`}}),n.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:3,background:`linear-gradient(90deg, ${l}, ${ks(l,.35)})`}}),n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:14},children:[n.jsx("span",{className:"status-card-title",style:{fontSize:13,fontWeight:700,paddingTop:4},children:e}),n.jsx("span",{style:{fontSize:14,fontWeight:800,color:"white",background:l,lineHeight:1,minWidth:26,textAlign:"center",padding:"6px 9px",borderRadius:10,boxShadow:`0 4px 10px ${ks(l,.35)}`},children:r})]}),r>0&&n.jsx("div",{style:{display:"flex",height:9,borderRadius:999,overflow:"hidden",background:ks(l,.1),marginBottom:13},children:d.map(([u,f,y,p],c)=>n.jsx("div",{title:`${u}: ${f}`,onClick:v=>{v.stopPropagation(),s==null||s(y)},style:{flex:`${f} 0 0`,background:p,borderRight:c<d.length-1?"2px solid white":"none",cursor:s?"pointer":"default"}},u))}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:i.map(([u,f,y],p)=>n.jsxs("div",{className:"status-card-row",onClick:f>0?c=>{c.stopPropagation(),s==null||s(y)}:void 0,style:{display:"flex",alignItems:"center",gap:9,padding:"4px 6px",borderRadius:8,cursor:f>0&&s?"pointer":"default",transition:"background 0.12s"},children:[n.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:a[p],flexShrink:0,boxShadow:`0 0 0 3px ${ks(a[p],.18)}`}}),n.jsx("span",{className:"status-card-label",style:{flex:1,fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),n.jsx("span",{className:"status-card-count",style:{fontSize:12,fontWeight:700,flexShrink:0},children:f})]},u))})]})}function Et({value:e,onChange:t,organizations:l,placeholder:s="-- Choose organization --",disabled:r=!1,small:i=!1}){var p;const[a,d]=j.useState(!1),u=j.useRef(null);j.useEffect(()=>{const c=v=>{u.current&&!u.current.contains(v.target)&&d(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[]);const f=e?((p=l.find(c=>c.organization_name===e||c.name===e))==null?void 0:p.organization_name)??e:s,y=l.filter(c=>!!c.is_active||c.organization_name===e||c.name===e);return n.jsxs("div",{ref:u,style:{position:"relative",width:"100%"},children:[n.jsxs("div",{onClick:()=>!r&&d(c=>!c),style:{width:"100%",padding:i?"4px 8px":"7px 10px",border:"1px solid #ddd",borderRadius:6,fontSize:i?11:12,cursor:r?"default":"pointer",height:i?28:34,background:r?"#f5f5f5":"white",color:e?"#333":"#aaa",display:"flex",justifyContent:"space-between",alignItems:"center",borderColor:a?"#3498db":"#ddd",transition:"border-color 0.2s",userSelect:"none",boxSizing:"border-box",opacity:r?.75:1},children:[n.jsx("span",{children:f}),n.jsx("span",{style:{fontSize:9,color:"#999",transform:a?"rotate(180deg)":"none",transition:"transform 0.2s"},children:"▼"})]}),a&&n.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:9999,background:"white",border:"1px solid #e0e0e0",borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",overflow:"hidden"},children:n.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[n.jsx(nu,{label:s,selected:!e,active:!0,isPlaceholder:!0,small:i,onClick:()=>{t(""),d(!1)}}),y.length===0&&n.jsx("div",{style:{padding:"12px 16px",color:"#aaa",fontSize:13},children:"No organizations"}),y.map(c=>n.jsx(nu,{label:c.organization_name,selected:e===c.organization_name||e===c.name,active:!!c.is_active,isPlaceholder:!1,small:i,onClick:()=>{t(c.organization_name),d(!1)}},c.name))]})})]})}function nu({label:e,selected:t,active:l,isPlaceholder:s,small:r,onClick:i}){const[a,d]=j.useState(!1),u=t?"#2563eb":a?"#f0f4ff":"transparent",f=t?"white":s?"#aaa":l?"#1a2332":"#e74c3c";return n.jsx("div",{onClick:i,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),style:{padding:r?"6px 12px":"8px 14px",cursor:"pointer",fontSize:12,background:u,color:f,transition:"background 0.1s"},children:e})}function wn({items:e,type:t,onNavigate:l}){const s=ee();if(!e.length)return null;const r=t==="process"?"processes-form":"orders-form",i=t==="process"?s.dash.escalatedProcesses:s.dash.escalatedOrders;return n.jsxs("div",{children:[n.jsxs("h4",{style:{fontWeight:700,fontSize:12,color:"#e74c3c",marginBottom:6},children:[i," (",e.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:e.map(a=>n.jsxs("div",{onClick:()=>l(r,a.name),style:{padding:"8px 12px",background:"#fff5f5",borderRadius:7,border:"1px solid #fecaca",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsxs("div",{children:[n.jsx("span",{style:{fontWeight:700,fontSize:12},children:a.number||a.name}),n.jsx("span",{style:{fontSize:11,color:"#666",marginLeft:8},children:a.title})]}),n.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#e74c3c",background:"#fecaca",padding:"2px 8px",borderRadius:10},children:[s.dash.level," ",a.escalation_level]})]},a.name))})]})}function Ey({kpi:e}){const t=ee();return n.jsxs("div",{style:{background:"white",borderRadius:8,padding:12,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("div",{style:{fontWeight:700,fontSize:13,marginBottom:2},children:e.organization}),n.jsx("div",{style:{fontSize:11,color:"#888",marginBottom:8},children:e.period}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[{label:t.dash.revenueGrowth,val:e.revenue_growth!=null?`${e.revenue_growth}%`:"—"},{label:t.dash.netProfit,val:e.net_profit!=null?e.net_profit.toLocaleString():"—"},{label:t.dash.strategicGoal,val:e.strategic_goal_pct!=null?`${e.strategic_goal_pct}%`:"—"},{label:t.dash.customerSat,val:e.customer_satisfaction!=null?e.customer_satisfaction:"—"},{label:t.dash.compliance,val:e.compliance_score!=null?e.compliance_score:"—"},{label:t.dash.safetyInc,val:e.open_safety_incidents!=null?e.open_safety_incidents:"—"}].map(({label:l,val:s})=>n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700},children:l}),n.jsx("div",{style:{fontSize:15,fontWeight:700,color:"#1a2332"},children:s})]},l))})]})}function Ay({data:e}){if(!e.length)return n.jsx("p",{style:{color:"#aaa",fontSize:13},children:"No cycle data available for trend chart."});const t=Math.max(...e.map(l=>l.pass+l.fail+l.unknown),1);return n.jsxs("div",{children:[n.jsx("div",{style:{display:"flex",gap:10,alignItems:"flex-end",overflowX:"auto",paddingBottom:4},children:e.map(l=>{const s=l.pass+l.fail+l.unknown||1,r=80;return n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:3,minWidth:48},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column-reverse",gap:1,height:r,width:32},children:[n.jsx("div",{title:`Pass: ${l.pass}`,style:{height:Math.round(l.pass/t*r),background:"#27ae60",borderRadius:"2px 2px 0 0",minHeight:l.pass?2:0}}),n.jsx("div",{title:`Fail: ${l.fail}`,style:{height:Math.round(l.fail/t*r),background:"#e74c3c",borderRadius:"2px 2px 0 0",minHeight:l.fail?2:0}}),n.jsx("div",{title:`Unknown: ${l.unknown}`,style:{height:Math.round(l.unknown/t*r),background:"#95a5a6",borderRadius:"2px 2px 0 0",minHeight:l.unknown?2:0}})]}),n.jsx("div",{style:{fontSize:9,color:"#999",textAlign:"center",lineHeight:1.2},children:l.month.replace(/^(\d{4})-(\d{2})$/,(i,a,d)=>`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][+d-1]}
${a}`)}),n.jsx("div",{style:{fontSize:9,color:"#555",textAlign:"center"},children:s>1?Math.round(l.pass/s*100)+"%":"—"})]},l.month)})}),n.jsx("div",{style:{display:"flex",gap:16,marginTop:8},children:[["#27ae60","Pass"],["#e74c3c","Fail"],["#95a5a6","Unknown"]].map(([l,s])=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,fontSize:11},children:[n.jsx("div",{style:{width:10,height:10,background:l,borderRadius:2}}),n.jsx("span",{style:{color:"#666"},children:s})]},s))})]})}function Wt({label:e,icon:t,onClick:l}){return n.jsxs("button",{onClick:l,style:{display:"flex",alignItems:"center",gap:7,padding:"7px 12px",background:"white",border:"1px solid #e8e8e8",borderRadius:8,cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.06)",transition:"box-shadow 0.15s"},onMouseEnter:s=>s.currentTarget.style.boxShadow="0 3px 10px rgba(0,0,0,0.12)",onMouseLeave:s=>s.currentTarget.style.boxShadow="0 1px 3px rgba(0,0,0,0.06)",children:[n.jsx("span",{style:{fontSize:15},children:t}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#444",whiteSpace:"nowrap"},children:e})]})}function Ry({dashData:e,fi:t,fid:l,fo:s,fp:r,incidentStatuses:i,ideaStatuses:a,orderStatuses:d,processStatuses:u,onNavigate:f,onNavigateStatus:y}){const p=ee(),c=(e==null?void 0:e.escalated_processes)||[],v=(e==null?void 0:e.escalated_orders)||[],b=(e==null?void 0:e.attention_processes)||[],g=(e==null?void 0:e.attention_orders)||[],S=(e==null?void 0:e.untriaged_incidents)||[],h=(e==null?void 0:e.overdue_triage)||[],m=c.length>0||v.length>0,o=b.length>0||g.length>0,x=[["Total",t.length,""],...i.map(k=>[k.name1||k.name,t.filter(C=>C.status===k.name).length,k.name])],z=[["Total",l.length,""],...a.map(k=>[k.name1||k.name,l.filter(C=>C.status===k.name).length,k.name])],R=[["Total",s.length,""],...d.map(k=>[k.name1||k.name,s.filter(C=>C.status===k.name).length,k.name])],P=[["Total",r.length,""],...u.map(k=>[k.name1||k.name,r.filter(C=>C.status===k.name).length,k.name])];return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",marginBottom:4},children:[n.jsx(Wt,{label:"Incidents",icon:"⚠️",onClick:()=>f("incidents")}),n.jsx(Wt,{label:"Ideas",icon:"💡",onClick:()=>f("ideas")}),n.jsx(Wt,{label:"Orders",icon:"📦",onClick:()=>f("orders")}),n.jsx(Wt,{label:"Processes",icon:"⚙️",onClick:()=>f("processes")}),n.jsx(Wt,{label:"Inbox",icon:"📥",onClick:()=>f("inbox")}),n.jsx(Wt,{label:"Reports",icon:"📊",onClick:()=>f("reports")})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12},children:[n.jsx("div",{onClick:()=>f("incidents"),style:{cursor:"pointer"},children:n.jsx(Br,{title:p.dash.incidents,color:W.orange,data:x,onSelect:k=>y("incidents",k)})}),n.jsx("div",{onClick:()=>f("ideas"),style:{cursor:"pointer"},children:n.jsx(Br,{title:p.dash.ideas,color:W.blue,data:z,onSelect:k=>y("ideas",k)})}),n.jsx("div",{onClick:()=>f("orders"),style:{cursor:"pointer"},children:n.jsx(Br,{title:p.dash.orders,color:W.purple,data:R,onSelect:k=>y("orders",k)})}),n.jsx("div",{onClick:()=>f("processes"),style:{cursor:"pointer"},children:n.jsx(Br,{title:p.dash.processes,color:W.red,data:P,onSelect:k=>y("processes",k)})})]}),m&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #e74c3c"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:10},children:p.dash.level2}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(wn,{items:c,type:"process",onNavigate:f}),n.jsx(wn,{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(wn,{items:b,type:"process",onNavigate:f}),n.jsx(wn,{items:g,type:"order",onNavigate:f})]})]}),h.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #e74c3c"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:8},children:[p.dash.overduePrefix,h.length,p.dash.overdueSuffix]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:h.map(k=>n.jsxs("div",{onClick:()=>f("incidents-form",k.name),style:{padding:"8px 12px",background:"#fef2f2",borderRadius:8,border:"1px solid #fca5a5",cursor:"pointer",display:"flex",justifyContent:"space-between"},children:[n.jsx("span",{style:{fontWeight:700,fontSize:13},children:k.number||k.name}),n.jsx("span",{style:{fontSize:12,color:"#666"},children:k.title}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:k.date})]},k.name))})]}),S.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:W.orange,marginBottom:8},children:[p.dash.untriaged," (",S.length,")"]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:S.map(k=>n.jsxs("div",{onClick:()=>f("incidents-form",k.name),style:{padding:"8px 12px",background:"#fffbeb",borderRadius:8,border:"1px solid #fed7aa",cursor:"pointer",display:"flex",justifyContent:"space-between"},children:[n.jsx("span",{style:{fontWeight:700,fontSize:13},children:k.number||k.name}),n.jsx("span",{style:{fontSize:12,color:"#666"},children:k.title}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:k.date})]},k.name))})]})]})}function Ly({dashData:e,selectedOrg:t,onNavigate:l}){const s=ee(),[r,i]=j.useState([]),[a,d]=j.useState([]),[u,f]=j.useState(!1),y=(e==null?void 0:e.escalated_processes)||[],p=(e==null?void 0:e.escalated_orders)||[],c=(e==null?void 0:e.attention_processes)||[],v=(e==null?void 0:e.attention_orders)||[],b=(e==null?void 0:e.kpi_inputs)||[];j.useEffect(()=>{f(!0);const h=new URLSearchParams({months:"6"});t&&h.append("organization",t),fetch(`/api/method/sidrah_business.api.get_process_trend?${h}`,{credentials:"include",headers:{Accept:"application/json"}}).then(m=>m.json()).then(m=>{const o=m.message||[],x={};for(const z of o)x[z.month]||(x[z.month]={pass:0,fail:0,unknown:0}),z.status==="Pass"?x[z.month].pass=z.count:z.status==="Fail"?x[z.month].fail=z.count:z.status==="Unknown"&&(x[z.month].unknown=z.count);i(Object.entries(x).map(([z,R])=>({month:z,...R})))}).catch(()=>{}).finally(()=>f(!1))},[t]),j.useEffect(()=>{fetch("/api/method/sidrah_business.api.get_report_data",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json","X-Frappe-CSRF-Token":window.csrf_token||""},body:JSON.stringify({report_name:"user_activity_log",filters_json:"{}"})}).then(h=>h.json()).then(h=>{var m;d((((m=h.message)==null?void 0:m.rows)||[]).slice(0,50))}).catch(()=>{})},[t]);const g=y.length>0||p.length>0,S=c.length>0||v.length>0;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:[n.jsx(Wt,{label:"Manage Users & Roles",icon:"👥",onClick:()=>l("users")}),n.jsx(Wt,{label:"Change Active Cycle",icon:"🔄",onClick:()=>l("cycles")}),n.jsx(Wt,{label:"KPI Inputs",icon:"📈",onClick:()=>l("kpi-input")}),n.jsx(Wt,{label:"Reports",icon:"📊",onClick:()=>l("reports")}),n.jsx(Wt,{label:"Organizations",icon:"🏢",onClick:()=>l("organizations")})]}),b.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:10},children:s.dash.recentKpi}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:12},children:b.map(h=>n.jsx(Ey,{kpi:h},h.name))}),n.jsx("button",{onClick:()=>l("kpi-input"),style:{marginTop:10,padding:"6px 14px",borderRadius:7,border:"1px solid #2980b9",background:"white",color:"#2980b9",fontWeight:600,fontSize:12,cursor:"pointer"},children:s.dash.manageKpi})]}),g&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #e74c3c"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#e74c3c",marginBottom:10},children:["Critical Escalations — Level 2 (",y.length+p.length,")"]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(wn,{items:y,type:"process",onNavigate:l}),n.jsx(wn,{items:p,type:"order",onNavigate:l})]})]}),S&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderLeft:"4px solid #f59e0b"},children:[n.jsxs("h3",{style:{fontWeight:800,fontSize:13,color:"#b45309",marginBottom:10},children:["Needs Attention — Level 1 (",c.length+v.length,")"]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsx(wn,{items:c,type:"process",onNavigate:l}),n.jsx(wn,{items:v,type:"order",onNavigate:l})]})]}),n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:4},children:"Process Trend — Last 6 Months"}),n.jsx("p",{style:{fontSize:11,color:"#888",marginBottom:10},children:"Pass/Fail/Unknown ratio per month across all processes. Pass % shown at bottom of each bar."}),u?n.jsx("p",{style:{color:"#aaa",fontSize:13},children:"Loading trend data…"}):n.jsx(Ay,{data:r})]}),a.length>0&&n.jsxs("div",{style:{background:"white",borderRadius:10,padding:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[n.jsx("h3",{style:{fontWeight:800,fontSize:13,color:"#1a2332",marginBottom:10},children:"Log Book — Recent Activity"}),n.jsx("div",{style:{overflowX:"auto"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa"},children:["Timestamp","User","Entity Type","Entity","Fields Changed"].map(h=>n.jsx("th",{style:{padding:"8px 12px",textAlign:"left",color:"#999",fontWeight:700,fontSize:11,whiteSpace:"nowrap"},children:h},h))})}),n.jsx("tbody",{children:a.map((h,m)=>n.jsxs("tr",{style:{borderTop:"1px solid #f0f0f0",background:m%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"8px 12px",color:"#555",whiteSpace:"nowrap"},children:h.timestamp?String(h.timestamp).slice(0,16):"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#333"},children:h.user||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#555"},children:h.entity_type||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#555"},children:h.entity_name||"—"}),n.jsx("td",{style:{padding:"8px 12px",color:"#888",maxWidth:240,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.changes||"—"})]},m))})]})}),n.jsx("button",{onClick:()=>l("reports"),style:{marginTop:12,padding:"7px 16px",borderRadius:8,border:"1px solid #888",background:"white",color:"#555",fontWeight:600,fontSize:12,cursor:"pointer"},children:"Full Activity Log (Reports →)"})]})]})}function Oy({incidents:e,ideas:t,orders:l,processes:s,organizations:r,incidentStatuses:i,ideaStatuses:a,orderStatuses:d,processStatuses:u,selectedOrg:f,onOrgChange:y,onNavigate:p,onNavigateStatus:c,userRole:v}){const[b,g]=j.useState(null);j.useEffect(()=>{my(f).then(g)},[f]);const S=f?e.filter(C=>C.organization===f):e,h=f?t.filter(C=>C.organization===f):t,m=f?l.filter(C=>C.organization===f):l,o=f?s.filter(C=>C.organization===f):s,x=v==="Admin",z=v==="Owner",[R,P]=j.useState("level1"),k=z||x&&R==="level2";return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[n.jsxs("div",{style:{background:"white",borderRadius:10,padding:"8px 14px",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#4f46e5",strokeWidth:"2.5",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#1e1b4b",whiteSpace:"nowrap"},children:"Filter"})]}),n.jsx("div",{style:{flex:1,minWidth:160,maxWidth:260},children:n.jsx(Et,{value:f,onChange:y,organizations:r,placeholder:"All Organizations",small:!0})}),x&&n.jsx("div",{style:{display:"flex",background:"#f1f0fe",borderRadius:7,padding:2,gap:2,flexShrink:0},children:["level1","level2"].map(C=>n.jsx("button",{onClick:()=>P(C),style:{padding:"4px 10px",borderRadius:5,border:"none",fontWeight:700,fontSize:11,cursor:"pointer",background:R===C?C==="level2"?W.purple:W.blue:"transparent",color:R===C?"white":"#6b7280",transition:"all 0.15s"},children:C==="level1"?"Level 1":"Level 2"},C))}),!x&&n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"white",background:k?W.purple:W.blue,padding:"3px 10px",borderRadius:20,flexShrink:0},children:k?"Level 2 — Owner":"Level 1 — Operational"})]}),k?n.jsx(Ly,{dashData:b,selectedOrg:f,onNavigate:p}):n.jsx(Ry,{dashData:b,fi:S,fid:h,fo:m,fp:o,incidentStatuses:i,ideaStatuses:a,orderStatuses:d,processStatuses:u,onNavigate:p,onNavigateStatus:c})]})}const Dy=()=>n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Ny=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),Wy=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("polyline",{points:"3 6 5 6 21 6"}),n.jsx("path",{d:"M19 6l-1 14H6L5 6"}),n.jsx("path",{d:"M10 11v6M14 11v6"}),n.jsx("path",{d:"M9 6V4h6v2"})]});function Je({onView:e,onEdit:t,onDelete:l}){const[s,r]=j.useState(!1),i=(d,u,f,y,p)=>f?n.jsx("button",{onClick:c=>{c.stopPropagation(),f()},title:p,style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:d,color:u,flexShrink:0,transition:"opacity 0.15s"},onMouseEnter:c=>c.currentTarget.style.opacity="0.75",onMouseLeave:c=>c.currentTarget.style.opacity="1",children:y},p):null,a=l?()=>{s?(r(!1),l()):r(!0)}:void 0;return n.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[i("#e0f7fa","#0891b2",e,n.jsx(Dy,{}),"View"),i("#dcfce7","#16a34a",t,n.jsx(Ny,{}),"Edit"),l&&n.jsx("button",{onClick:d=>{d.stopPropagation(),a==null||a()},title:s?"Click again to confirm delete":"Delete",style:{minWidth:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:s?8:"50%",padding:s?"0 8px":0,border:"none",cursor:"pointer",background:s?"#ef4444":"#fee2e2",color:s?"white":"#ef4444",flexShrink:0,fontSize:s?11:14,fontWeight:700,transition:"all 0.15s",gap:4},onMouseEnter:d=>d.currentTarget.style.opacity="0.8",onMouseLeave:d=>d.currentTarget.style.opacity="1",onBlur:()=>r(!1),children:s?"✓ Sure?":n.jsx(Wy,{})})]})}const A={width:"100%",height:34,padding:"7px 10px",border:"1px solid #ddd",borderRadius:6,fontSize:12,boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif"},T={display:"block",marginBottom:5,fontSize:11,color:"#555",fontWeight:600};function By(e){return typeof(e==null?void 0:e.is_active)<"u"?!!e.is_active:typeof(e==null?void 0:e.status)<"u"?e.status!=="Inactive":typeof(e==null?void 0:e.custom_status)<"u"?e.custom_status!=="Inactive":!0}function fe(e,t){return e.filter(l=>By(l)||l.name===t)}function fr(e,t,l,s){return e.filter(r=>{const i=t[r.name]||[];return!(i.includes("SB Admin")||i.includes("System Manager")||!i.includes(l)||s&&r.custom_organization&&r.custom_organization!==s)})}const ds={width:16,height:16,cursor:"pointer",accentColor:"#2563eb",flexShrink:0},Ln=(e,t)=>n.jsx("span",{style:{background:t,color:"white",padding:"4px 12px",borderRadius:12,fontSize:12,fontWeight:600,display:"inline-block"},children:e}),Ki=e=>{switch(e){case"New":return"#e74c3c";case"Under Progress":return"#f39c12";case"Executed":return"#27ae60";case"Overdue":return"#7f1d1d";default:return"#95a5a6"}},$e={fontSize:10,color:"#6b7280",fontWeight:600,marginBottom:3,display:"block",textTransform:"uppercase",letterSpacing:.4},Ue={width:"100%",padding:"4px 8px",border:"1px solid #d1d5db",borderRadius:6,fontSize:11,background:"white",color:"#374151",boxSizing:"border-box",fontFamily:"Segoe UI, Arial, sans-serif",height:28};function Qi({children:e}){const[t,l]=j.useState(!1);return n.jsxs("div",{style:{borderRadius:8,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",flexShrink:0},children:[n.jsxs("div",{onClick:()=>l(s=>!s),style:{background:"#4f46e5",color:"white",padding:"9px 18px",cursor:"pointer",display:"flex",alignItems:"center",gap:10,userSelect:"none"},children:[n.jsx("span",{style:{fontSize:13,opacity:.9},children:t?"▲":"▼"}),n.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{style:{fontSize:13,fontWeight:600},children:"Filters"})]}),t&&n.jsx("div",{style:{background:"white",padding:"12px 16px",borderTop:"1px solid #e5e7eb"},children:e})]})}const se=20,lu=e=>({padding:"6px 16px",borderRadius:6,border:"1px solid #d1d5db",fontSize:12,fontWeight:600,background:e?"#f3f4f6":"white",color:e?"#c1c5cc":"#374151",cursor:e?"not-allowed":"pointer",fontFamily:"inherit"});function Fe({page:e,pageSize:t=se,total:l,onPageChange:s}){if(l===0)return null;const r=Math.max(1,Math.ceil(l/t)),i=(e-1)*t+1,a=Math.min(e*t,l);return n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 4px",fontSize:12,color:"#6b7280",flexShrink:0},children:[n.jsxs("span",{children:["Showing ",i," to ",a," of ",l," results"]}),n.jsxs("div",{style:{display:"flex",gap:8},children:[n.jsx("button",{disabled:e<=1,onClick:()=>s(e-1),style:lu(e<=1),children:"Previous"}),n.jsx("button",{disabled:e>=r,onClick:()=>s(e+1),style:lu(e>=r),children:"Next"})]})]})}function $y({incidents:e,organizations:t,departments:l,branches:s,incidentStatuses:r,initialOrg:i,initialStatus:a,canModify:d,onView:u,onEdit:f,onDelete:y}){const p=ee(),[c,v]=j.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),b=(o,x)=>v(z=>({...z,[o]:x})),[g,S]=j.useState(1),h=e.filter(o=>!(c.search&&!`${o.number} ${o.title}`.toLowerCase().includes(c.search.toLowerCase())||c.organization&&o.organization!==c.organization||c.department&&o.department!==c.department||c.branch&&o.branch!==c.branch||c.status&&o.status!==c.status));j.useEffect(()=>{S(1)},[c]);const m=h.slice((g-1)*se,g*se);return n.jsxs(n.Fragment,{children:[n.jsx(Qi,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.numberTitle}),n.jsx("input",{style:Ue,value:c.search,onChange:o=>b("search",o.target.value),placeholder:p.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.organization}),n.jsxs("select",{style:Ue,value:c.organization,onChange:o=>b("organization",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.department}),n.jsxs("select",{style:Ue,value:c.department,onChange:o=>b("department",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allDepts}),l.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.branch}),n.jsxs("select",{style:Ue,value:c.branch,onChange:o=>b("branch",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allBranches}),s.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.status}),n.jsxs("select",{style:Ue,value:c.status,onChange:o=>b("status",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allStatuses}),r.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>v({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"5px 12px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#6b7280",fontFamily:"Segoe UI"},children:p.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.number}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.title}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.type}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.actions})]})}),n.jsx("tbody",{children:h.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:p.noIncidents})}):m.map((o,x)=>n.jsxs("tr",{onClick:()=>u==null?void 0:u(o),style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",color:"#999"},children:o.number||"—"}),n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.title||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.type?Ln(o.type,"#e74c3c"):"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.status?Ln(o.status,Ki(o.status)):"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:z=>z.stopPropagation(),children:n.jsx(Je,{onView:()=>u==null?void 0:u(o),onEdit:d&&f?()=>f(o):void 0,onDelete:d&&y?()=>y(o.name):void 0})})]},o.name))})]})}),n.jsx(Fe,{page:g,total:h.length,onPageChange:S})]})}function Uy(e){if(!e)return"";const[t,l,s]=e.split("-");return!t||!l||!s?"":`${s}/${l}/${t}`}function ye({value:e,onChange:t,disabled:l,style:s,min:r,max:i}){return n.jsxs("div",{style:{position:"relative",width:"100%"},children:[n.jsx("input",{type:"text",readOnly:!0,tabIndex:-1,value:Uy(e),placeholder:"DD/MM/YYYY",style:{...s,pointerEvents:"none",paddingRight:30}}),n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:l?"#bbb":"#666",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",pointerEvents:"none"},children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}),n.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),n.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),n.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),n.jsx("input",{type:"date",value:e||"",disabled:l,min:r,max:i,onChange:a=>t(a.target.value),style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0,cursor:l?"default":"pointer",border:"none",padding:0,margin:0}})]})}function Fy({title:e,children:t}){return n.jsxs("div",{style:{background:"white",borderRadius:10,padding:"18px 20px",marginBottom:14,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[e&&n.jsx("div",{style:{fontSize:15,fontWeight:700,marginBottom:16,color:"#1e1b4b"},children:e}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:13},children:t})]})}const su={"SB Process":"processes-form","SB Order":"orders-form","SB Incident":"incidents-form","SB Idea":"ideas-form","SB Delegation":"delegations"};function My(e){const t=(Date.now()-new Date(e).getTime())/1e3;return t<60?`${Math.floor(t)}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function Uf({notifCount:e,darkMode:t,onCountChange:l,onToggleDark:s,onViewProfile:r,onLogout:i,onNavigate:a}){const[d,u]=j.useState(!1),[f,y]=j.useState([]),[p,c]=j.useState(!1),v=j.useRef(null);j.useEffect(()=>{const k=C=>{v.current&&!v.current.contains(C.target)&&u(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[]);const b=async()=>{c(!0);const k=await iy(30);y(k),c(!1)},g=()=>{const k=!d;u(k),k&&b()},S=async()=>{await ay(),y(k=>k.map(C=>({...C,read:1}))),l(0)},h=k=>{k.read||(oy(k.name),y($=>$.map(I=>I.name===k.name?{...I,read:1}:I)),l(Math.max(0,e-1)));const C=k.document_type?su[k.document_type]:void 0;C&&a&&(a(C,k.document_type==="SB Delegation"?void 0:k.document_name),u(!1))},m=f.filter(k=>!k.read).length,o=k=>({position:"relative",width:34,height:34,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:t?"#2d3748":"#f3f4f6",color:t?"#e2e8f0":"#6b7280",fontSize:14,transition:"background 0.15s",flexShrink:0,...k}),x=t,z=x?"#1a202c":"white",R=x?"#2d3748":"#e5e7eb",P=x?"#e2e8f0":"#1a2332";return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx("button",{style:o({background:"#4f46e5",color:"white"}),onClick:r,title:"My Profile",children:n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:[n.jsx("circle",{cx:"12",cy:"8",r:"4"}),n.jsx("path",{d:"M4 20c0-4 3.6-7 8-7s8 3 8 7",fill:"currentColor"})]})}),n.jsxs("div",{ref:v,style:{position:"relative"},children:[n.jsxs("button",{style:o(),onClick:g,title:"Notifications",children:[n.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),n.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),e>0&&n.jsx("span",{style:{position:"absolute",top:2,right:2,background:"#ef4444",color:"white",fontSize:9,fontWeight:700,borderRadius:999,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 3px",lineHeight:1},children:e>9?"9+":e})]}),d&&n.jsxs("div",{style:{position:"absolute",right:0,top:"calc(100% + 8px)",width:340,background:z,borderRadius:12,boxShadow:"0 8px 32px rgba(0,0,0,0.2)",zIndex:1e4,border:`1px solid ${R}`,overflow:"hidden"},children:[n.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${R}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:z},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:P},children:["Notifications",m>0&&n.jsxs("span",{style:{background:"#ef4444",color:"white",fontSize:10,fontWeight:700,borderRadius:999,padding:"2px 7px"},children:[m," new"]})]}),m>0&&n.jsx("button",{onClick:S,style:{fontSize:12,color:"#3498db",background:"none",border:"none",cursor:"pointer",fontFamily:"inherit"},children:"Mark all read"})]}),n.jsxs("div",{style:{maxHeight:380,overflowY:"auto"},children:[p&&n.jsx("div",{style:{padding:20,textAlign:"center",color:"#aaa",fontSize:13},children:"Loading…"}),!p&&f.length===0&&n.jsxs("div",{style:{padding:"36px 20px",textAlign:"center",color:"#aaa"},children:[n.jsx("div",{style:{fontSize:28,marginBottom:8},children:"🔔"}),n.jsx("div",{style:{fontSize:13},children:"No notifications"})]}),!p&&f.map(k=>{const C=!!(k.document_type&&su[k.document_type]&&a);return n.jsxs("div",{onClick:()=>h(k),style:{padding:"11px 16px",borderBottom:`1px solid ${x?"#2d3748":"#f5f5f5"}`,display:"flex",gap:10,background:k.read?z:x?"#1e3a5f":"#eff6ff",cursor:C?"pointer":"default",transition:"background 0.12s"},onMouseEnter:$=>{C&&($.currentTarget.style.background=x?"#243244":"#e0ecfd")},onMouseLeave:$=>{$.currentTarget.style.background=k.read?z:x?"#1e3a5f":"#eff6ff"},children:[n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:13,fontWeight:k.read?400:600,color:P,marginBottom:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.subject||`${k.document_type}: ${k.document_name}`}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:k.document_type&&n.jsxs("span",{style:{fontSize:10,fontWeight:700,color:"#3b82f6",background:x?"rgba(59,130,246,0.15)":"#eff6ff",padding:"1px 7px",borderRadius:8},children:[k.document_type.replace("SB ",""),k.document_name?` · ${k.document_name}`:""]})}),n.jsx("div",{style:{fontSize:11,color:"#aaa",marginTop:3},children:My(k.creation)})]}),!k.read&&n.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:"#3498db",flexShrink:0,marginTop:5}})]},k.name)})]})]})]}),n.jsx("button",{style:o(),onClick:Df,title:ql()?"Switch to English":"Switch to Arabic",children:n.jsx("span",{style:{fontSize:13,fontWeight:700,fontFamily:"serif"},children:"عA"})}),n.jsx("button",{style:o(),onClick:s,title:t?"Light mode":"Dark mode",children:t?n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"5"}),n.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),n.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),n.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),n.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),n.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),n.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),n.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),n.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}),n.jsx("button",{style:o({background:x?"#3d1515":"#fee2e2",color:"#ef4444"}),onClick:i,title:"Logout",children:n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),n.jsx("polyline",{points:"16,17 21,12 16,7"}),n.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]})})]})}function Me({title:e,activePage:t,user:l,formStatus:s,buttonText:r,buttonColor:i,viewMode:a,onEdit:d,hideSettings:u,rightPanel:f,darkMode:y,notifCount:p,onToggleDark:c,onCountChange:v,onViewProfile:b,onSubmit:g,onBack:S,onNavigate:h,onLogout:m,children:o}){const x=ee(),z=x.nav[t]||t,R=l.role,P=R==="Admin"||R==="Owner"||R==="Auditor"||R==="Manager",k=R==="Admin"||R==="Owner"||R==="Auditor"||R==="Manager",C=R==="Admin"||R==="Auditor"||R==="Manager",$=P?"dashboard":"inbox",[I,E]=j.useState(()=>localStorage.getItem("sb_sidebar")==="1"),O=()=>E(U=>{const V=!U;return localStorage.setItem("sb_sidebar",V?"1":"0"),V});return n.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:W.bg},children:[n.jsx(Lf,{collapsed:I,onToggleCollapsed:O,activePage:t,onNavigate:h,hasDashboard:P,hasReports:k,hasDelegations:C,role:R,hideSettings:u,rtl:x.rtl,navLabels:x.nav,settingsLabel:x.nav.settings}),n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[n.jsxs("div",{style:{background:"white",padding:"10px 20px",borderBottom:"1px solid #e9eaf0",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,boxShadow:"0 1px 4px rgba(0,0,0,0.04)"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[n.jsx("button",{onClick:S,title:x.back,style:{width:30,height:30,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"1.5px solid #e5e7eb",background:"white",cursor:"pointer",color:"#4f46e5",flexShrink:0},children:n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"15 18 9 12 15 6"})})}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:15,fontWeight:700,color:"#1e1b4b"},children:e}),n.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:1},children:[n.jsx("span",{onClick:()=>h($),style:{cursor:"pointer",color:"#4f46e5"},onMouseEnter:U=>U.currentTarget.style.textDecoration="underline",onMouseLeave:U=>U.currentTarget.style.textDecoration="none",children:x.home}),!u&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{margin:"0 4px"},children:"/"}),n.jsx("span",{onClick:S,style:{cursor:"pointer",color:"#4f46e5"},onMouseEnter:U=>U.currentTarget.style.textDecoration="underline",onMouseLeave:U=>U.currentTarget.style.textDecoration="none",children:z})]})]})]})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[a&&d&&n.jsxs("button",{onClick:d,style:{display:"flex",alignItems:"center",gap:6,padding:"7px 16px",borderRadius:7,border:"none",background:"#4f46e5",color:"white",cursor:"pointer",fontSize:13,fontWeight:600,fontFamily:"Segoe UI"},children:[n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),x.edit]}),n.jsx(Uf,{notifCount:p,darkMode:y,onCountChange:v,onToggleDark:c,onNavigate:h,onViewProfile:b,onLogout:m})]})]}),n.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px",display:"grid",gridTemplateColumns:f?"1fr auto":"1fr",gap:14,alignItems:"start"},children:[n.jsx("div",{style:{minWidth:0},children:n.jsxs(Fy,{children:[o,!a&&n.jsxs("div",{style:{display:"flex",gap:10,marginTop:20},children:[n.jsx("button",{onClick:S,style:{padding:"9px 22px",borderRadius:8,border:"1.5px solid #e5e7eb",cursor:"pointer",fontSize:13,fontWeight:600,background:"white",color:"#374151",fontFamily:"Segoe UI"},children:x.cancel}),n.jsx("button",{onClick:g,disabled:s==="loading",style:{padding:"9px 22px",borderRadius:8,background:i,color:"white",border:"none",cursor:"pointer",fontSize:13,fontWeight:600,opacity:s==="loading"?.7:1,boxShadow:"0 2px 10px rgba(79,70,229,0.18)",fontFamily:"Segoe UI"},children:s==="loading"?x.saving:r})]}),s==="success"&&n.jsx("div",{style:{padding:"10px",borderRadius:8,background:"#f0fdf4",border:"1px solid #86efac",color:"#166534",fontSize:13,marginTop:10},children:x.savedOk}),s!=="idle"&&s!=="loading"&&s!=="success"&&n.jsx("div",{style:{padding:"10px",borderRadius:8,background:"#fef2f2",border:"1px solid #fca5a5",color:"#991b1b",fontSize:13,marginTop:10},children:s})]})}),f&&n.jsx("div",{style:{position:"sticky",top:0,alignSelf:"start"},children:f})]})]})]})}function ue({value:e,onChange:t,items:l,placeholder:s="-- Select --",disabled:r=!1}){var p;const[i,a]=j.useState(!1),[d,u]=j.useState(""),f=j.useRef(null);j.useEffect(()=>{const c=v=>{f.current&&!f.current.contains(v.target)&&a(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[]);const y=e?((p=l.find(c=>c.name===e))==null?void 0:p.label)??e:s;return n.jsxs("div",{ref:f,style:{position:"relative",width:"100%"},children:[n.jsxs("div",{onClick:()=>!r&&a(c=>!c),style:{width:"100%",height:34,padding:"7px 10px",border:"1px solid",borderColor:i?"#3498db":"#ddd",borderRadius:6,fontSize:12,cursor:r?"default":"pointer",background:r?"#f5f5f5":"white",color:e?"#333":"#aaa",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"border-color 0.2s",userSelect:"none",boxSizing:"border-box",opacity:r?.75:1},children:[n.jsx("span",{children:y}),n.jsx("span",{style:{fontSize:9,color:"#999",transform:i?"rotate(180deg)":"none",transition:"transform 0.2s"},children:"▼"})]}),i&&n.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:9999,background:"white",border:"1px solid #e0e0e0",borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",overflow:"hidden"},children:n.jsxs("div",{style:{maxHeight:260,overflowY:"auto"},children:[n.jsx("div",{onClick:()=>{t(""),a(!1)},onMouseEnter:()=>u("__placeholder"),onMouseLeave:()=>u(""),style:{padding:"8px 14px",cursor:"pointer",fontSize:12,color:"#aaa",background:d==="__placeholder"?"#f5f5f5":"transparent"},children:s}),l.length===0&&n.jsx("div",{style:{padding:"10px 14px",color:"#aaa",fontSize:12},children:"No records found"}),l.map(c=>n.jsx("div",{onClick:()=>{t(c.name),a(!1)},onMouseEnter:()=>u(c.name),onMouseLeave:()=>u(""),style:{padding:"8px 14px",cursor:"pointer",fontSize:12,background:e===c.name?"#2563eb":d===c.name?"#f0f4ff":"transparent",color:e===c.name?"white":"#1a2332",transition:"background 0.1s"},children:c.label},c.name))]})})]})}function Hy(e){const t=(Date.now()-new Date(e).getTime())/1e3;return t<60?`${Math.floor(t)}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:t<86400*7?`${Math.floor(t/86400)}d ago`:new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Ky(e){return e.replace(/@.*/,"").replace(/[._-]/g," ").split(" ").filter(Boolean).slice(0,2).map(l=>l[0].toUpperCase()).join("")}function Gi({doctype:e,docname:t,currentUserName:l}){const s=ee(),[r,i]=j.useState([]),[a,d]=j.useState(!1),[u,f]=j.useState(""),[y,p]=j.useState(!1),[c,v]=j.useState(!1),[b,g]=j.useState(!1),[S,h]=j.useState(""),m=5,o=j.useCallback(async()=>{d(!0);const k=await dy(e,t);i(k),d(!1)},[e,t]);j.useEffect(()=>{o()},[o]);const x=async()=>{const k=u.trim();if(!(!k||y)){p(!0),h("");try{await uy(e,t,k),f(""),await o()}catch{h("Failed to post comment. Please try again.")}p(!1)}},z=async k=>{if(window.confirm("Delete this comment?"))try{await Nf("Comment",k),i(C=>C.filter($=>$.name!==k))}catch{alert("Failed to delete comment.")}},R=b?r:r.slice(-m),P=Math.max(0,r.length-m);return n.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[n.jsxs("div",{onClick:()=>v(k=>!k),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:k=>{k.stopPropagation(),o()},style:{background:"none",border:"none",cursor:"pointer",color:"#aaa",fontSize:16,padding:"2px 4px",lineHeight:1},title:"Refresh",children:"↻"}),n.jsx("span",{style:{color:"#ccc",fontSize:11},children:c?"▼":"▲"})]})]}),!c&&n.jsxs("div",{style:{padding:"16px 20px"},children:[!b&&P>0&&n.jsxs("button",{onClick:()=>g(!0),style:{width:"100%",padding:"8px",marginBottom:12,border:"none",background:"#f8f9fa",borderRadius:6,cursor:"pointer",fontSize:12,color:"#3498db",fontFamily:"Segoe UI"},children:["Show ",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&&R.length>0&&n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,marginBottom:16},children:R.map(k=>{const C=k.comment_by||k.comment_email||k.owner||"Unknown",$=k.owner===l||k.comment_by===l;return n.jsxs("div",{style:{display:"flex",gap:10,padding:"12px 14px",background:"#f9fafb",borderRadius:8,border:"1px solid #e8e8e8"},children:[n.jsx("div",{style:{width:34,height:34,borderRadius:"50%",background:"#3498db",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,fontWeight:700,flexShrink:0},children:Ky(C)}),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:C}),n.jsx("span",{style:{fontSize:11,color:"#aaa"},children:Hy(k.creation)})]}),$&&n.jsx("button",{onClick:()=>z(k.name),style:{background:"none",border:"none",cursor:"pointer",color:"#e74c3c",fontSize:16,padding:"0 2px",lineHeight:1},title:"Delete comment",children:"×"})]}),n.jsx("div",{style:{fontSize:13,color:"#374151",lineHeight:1.55,wordBreak:"break-word",whiteSpace:"pre-wrap"},dangerouslySetInnerHTML:{__html:k.content||""}})]})]},k.name)})}),n.jsxs("div",{style:{borderTop:r.length>0?"1px solid #f0f0f0":"none",paddingTop:r.length>0?14:0},children:[n.jsx("textarea",{value:u,onChange:k=>f(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.ctrlKey||k.metaKey)&&x()},placeholder:s.comments.placeholder,rows:3,style:{width:"100%",padding:"10px 12px",border:"1px solid #ddd",borderRadius:8,fontSize:13,fontFamily:"Segoe UI",resize:"vertical",boxSizing:"border-box",outline:"none",color:"#1a2332"}}),S&&n.jsx("div",{style:{fontSize:12,color:"#e74c3c",marginTop:4},children:S}),n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:n.jsx("button",{onClick:x,disabled:!u.trim()||y,style:{padding:"8px 20px",background:"#3498db",color:"white",border:"none",borderRadius:6,cursor:!u.trim()||y?"not-allowed":"pointer",fontSize:13,fontWeight:600,fontFamily:"Segoe UI",opacity:!u.trim()||y?.6:1},children:y?s.saving:s.comments.post})})]})]})]})}function ru(e){if(!e)return"";const t=(Date.now()-new Date(e).getTime())/1e3;return t<60?`${Math.floor(t)}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:t<86400*7?`${Math.floor(t/86400)}d ago`:new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Qy(e){return(e||"").replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function iu(e){return e==null||e===""?"(empty)":typeof e=="object"?JSON.stringify(e):String(e)}function zo(e){return(e||"Unknown").replace(/@.*/,"").replace(/[._]/g," ")}function au(e){return zo(e).split(" ").filter(Boolean).slice(0,2).map(t=>t[0].toUpperCase()).join("")}function Gy(e){let t={};try{t=JSON.parse(e.data||"{}")}catch{}const l=(t.changed||[]).map(s=>({field:s[0]||"",oldVal:iu(s[1]),newVal:iu(s[2])}));return{name:e.name,owner:e.owner,creation:e.creation,changes:l,added:(t.added||[]).length,removed:(t.removed||[]).length,rowChanged:(t.row_changed||[]).length}}function Yi({doctype:e,docname:t,docCreation:l,docOwner:s}){const r=ee(),[i,a]=j.useState([]),[d,u]=j.useState(!1),[f,y]=j.useState(!0),[p,c]=j.useState(!1),v=5,b=j.useCallback(async()=>{u(!0);const m=await py(e,t);a(m.map(Gy)),u(!1)},[e,t]);j.useEffect(()=>{f||b()},[f,b]);const g=p?i:i.slice(0,v),S=i.length-v,h=(m,o=!1)=>({position:"absolute",left:-14,top:14,width:10,height:10,borderRadius:"50%",background:m,border:"2px solid white",boxShadow:o?`0 0 0 2px ${m}44`:"none"});return n.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[n.jsxs("div",{onClick:()=>y(m=>!m),style:{padding:"12px 20px",borderBottom:f?"none":"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",userSelect:"none"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14,fontWeight:700,color:"#1a2332"},children:["📋 ",r.activity.title,!f&&i.length>0&&n.jsx("span",{style:{background:"#e8f4fd",color:"#2980b9",fontSize:11,fontWeight:700,borderRadius:10,padding:"2px 8px"},children:i.length})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!f&&n.jsx("button",{onClick:m=>{m.stopPropagation(),b()},style:{background:"none",border:"none",cursor:"pointer",color:"#aaa",fontSize:16,padding:"2px 4px",lineHeight:1},title:"Refresh",children:"↻"}),n.jsx("span",{style:{color:"#ccc",fontSize:11},children:f?"▼":"▲"})]})]}),!f&&n.jsxs("div",{style:{padding:"16px 20px"},children:[d&&n.jsx("div",{style:{textAlign:"center",color:"#aaa",fontSize:13,padding:"16px 0"},children:r.loading}),!d&&n.jsxs("div",{style:{position:"relative",paddingLeft:20},children:[n.jsx("div",{style:{position:"absolute",left:8,top:0,bottom:0,width:2,background:"#e5e7eb"}}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[g.map((m,o)=>n.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[n.jsx("div",{style:h(o===0?"#3498db":"#d1d5db",o===0)}),n.jsxs("div",{style:{background:o===0?"#eff6ff":"#f9fafb",border:`1px solid ${o===0?"#bfdbfe":"#e5e7eb"}`,borderRadius:8,padding:"10px 14px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[n.jsx("div",{style:{width:26,height:26,borderRadius:"50%",background:"#3498db",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flexShrink:0},children:au(m.owner)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:zo(m.owner)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:ru(m.creation)})]}),m.changes.length>0?n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:m.changes.map((x,z)=>n.jsxs("div",{style:{fontSize:12,lineHeight:1.5},children:[n.jsx("span",{style:{fontWeight:600,color:"#6d28d9"},children:Qy(x.field)}),n.jsx("span",{style:{color:"#6b7280"},children:" changed from "}),n.jsx("span",{style:{padding:"1px 5px",background:"#fee2e2",color:"#dc2626",borderRadius:3,fontSize:11,fontFamily:"monospace"},children:x.oldVal}),n.jsx("span",{style:{color:"#6b7280"},children:" → "}),n.jsx("span",{style:{padding:"1px 5px",background:"#dcfce7",color:"#16a34a",borderRadius:3,fontSize:11,fontFamily:"monospace"},children:x.newVal})]},z))}):n.jsxs("div",{style:{fontSize:12,color:"#9ca3af",fontStyle:"italic"},children:["Document updated",m.added>0&&n.jsxs("span",{children:[" · +",m.added," row(s)"]}),m.removed>0&&n.jsxs("span",{children:[" · -",m.removed," row(s)"]}),m.rowChanged>0&&n.jsxs("span",{children:[" · ~",m.rowChanged," row(s) modified"]})]})]})]},m.name)),l&&s&&n.jsxs("div",{style:{position:"relative",paddingLeft:12},children:[n.jsx("div",{style:h("#22c55e")}),n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:"10px 14px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[n.jsx("div",{style:{width:26,height:26,borderRadius:"50%",background:"#22c55e",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flexShrink:0},children:au(s)}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:zo(s)}),n.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto"},children:ru(l)})]}),n.jsxs("div",{style:{fontSize:12,color:"#15803d",fontWeight:600},children:["✓ ",r.activity.created]})]})]}),i.length===0&&!l&&n.jsx("div",{style:{textAlign:"center",color:"#bbb",fontSize:13,padding:"12px 0",fontStyle:"italic"},children:"No activity recorded"})]})]}),!d&&S>0&&n.jsx("div",{style:{textAlign:"center",marginTop:12},children:n.jsx("button",{onClick:()=>c(m=>!m),style:{background:"none",border:"none",cursor:"pointer",color:"#3498db",fontSize:12,fontFamily:"Segoe UI",padding:"4px 8px"},children:p?"▲ Show less":`▼ Show all (${i.length})`})})]})]})}const _s={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Ta={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},Yy={New:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Initial Evaluation":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},"Accept & Under Progress":{background:"#fefce8",color:"#92400e",border:"1px solid #fde68a"},"working on resolution":{background:"#f5f3ff",color:"#6d28d9",border:"1px solid #ddd6fe"},Rejected:{background:"#fef2f2",color:"#dc2626",border:"1px solid #fecaca"},"Executed & Closed":{background:"#f0fdf4",color:"#166534",border:"1px solid #bbf7d0"}};function Xy(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...Yy[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function qy({incForm:e,setIncForm:t,organizations:l,managements:s,departments:r,branches:i,incidentTypes:a,incidentClasses:d,incidentFields:u,incidentStatuses:f,users:y,userRoleMap:p={},formStatus:c,viewMode:v,onEdit:b,darkMode:g,notifCount:S,onToggleDark:h,onCountChange:m,onViewProfile:o,userRole:x,onSubmit:z,onBack:R,onNavigate:P,onLogout:k,user:C,onRefresh:$}){const I=ee(),E=_=>t({...e,..._}),O=v?{background:"#f9f9f9"}:{},U=fr(y,p,"SB Manager",e.organization),[V,xe]=j.useState(""),[le,L]=j.useState(!1),M=e.name?v?`${I.formTitle.viewIncident}${e.number||e.name}`:I.formTitle.editIncident:I.formTitle.newIncident,K=fe(s,e.management).map(_=>({name:_.name,label:_.name1||_.name})),ne=fe(r,e.department).map(_=>({name:_.name,label:_.department_name||_.name})),q=fe(i,e.branch).map(_=>({name:_.name,label:_.branch||_.name})),me=fe(a,e.type).map(_=>({name:_.name,label:_.name1||_.name})),Ce=d.map(_=>({name:_.name,label:_.name1||_.name})),re=u.map(_=>({name:_.name,label:_.name1||_.name})),ze=fe(f,e.status).map(_=>({name:_.name,label:_.name1||_.name})),he=e.workflow_state||"New",H=x==="Employee",J=x==="Auditor"||x==="Admin",N=x==="Manager",oe=e.name?he==="New"?[{label:I.wf.submit,action:"Submit",color:"#2563eb"}]:he==="Initial Evaluation"&&J?[{label:I.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:I.wf.reject,action:"Reject",color:"#dc2626"}]:he==="Accept & Under Progress"&&(N||J)?[{label:I.wf.submitSolution,action:"Submit Solution",color:"#059669"}]:he==="working on resolution"&&(N||J)?[{label:I.wf.resolutionComplete,action:"Resolution complete",color:"#166534"}]:[]:[];async function Wn(_){if(e.name){L(!0),xe("");try{const Y={};_==="Assign to Manager"&&(e.assigned_to&&(Y.assigned_to=e.assigned_to),e.priority&&(Y.priority=e.priority),e.economy_class&&(Y.economy_class=e.economy_class),e.entity_scope&&(Y.entity_scope=e.entity_scope),e.hses_field&&(Y.hses_field=e.hses_field),Y.product_relation=String(e.product_relation??0),Y.repeated=String(e.repeated??0)),_==="Submit Solution"&&(e.solution&&(Y.solution=e.solution),e.summary&&(Y.summary=e.summary),e.cost&&(Y.cost=String(e.cost))),(_==="Resolution complete"||_==="Submit Solution")&&e.auditor_comment&&(Y.auditor_comment=e.auditor_comment),await gy(e.name,_,JSON.stringify(Y)),xe("Done"),$==null||$()}catch(Y){xe(Y.message||"Error")}finally{L(!1)}}}const gt=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:I.wf.workflow}),n.jsx("span",{style:Xy(he),children:he})]}),he==="Initial Evaluation"&&J&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:I.wf.assignToManager}),n.jsxs("select",{style:A,value:e.assigned_to||"",onChange:_=>E({assigned_to:_.target.value}),children:[n.jsx("option",{value:"",children:I.field.selectMgr}),U.map(_=>n.jsx("option",{value:_.name,children:_.full_name||_.name},_.name))]})]}),(he==="Accept & Under Progress"||he==="working on resolution")&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:I.field.solution}),n.jsx("textarea",{style:{...A,height:80,resize:"vertical"},value:e.solution||"",onChange:_=>E({solution:_.target.value}),placeholder:I.field.solutionPlaceholder}),n.jsx("label",{style:{...T,marginTop:8},children:I.field.actualCost}),n.jsx("input",{type:"number",style:A,value:e.cost||"",onChange:_=>E({cost:parseFloat(_.target.value)||0}),placeholder:"0.00"})]}),he==="working on resolution"&&J&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:I.field.auditorComment}),n.jsx("textarea",{style:{...A,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:_=>E({auditor_comment:_.target.value}),placeholder:I.field.commentPlaceholder})]}),oe.length>0?n.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:oe.map(_=>n.jsx("button",{onClick:()=>Wn(_.action),disabled:le,style:{padding:"8px 18px",borderRadius:8,border:"none",background:_.color,color:"white",fontWeight:700,cursor:le?"not-allowed":"pointer",opacity:le?.7:1},children:le?I.wf.applying:_.label},_.action))}):n.jsx("div",{style:{fontSize:12,color:"#94a3b8",fontStyle:"italic"},children:I.wf.noActions}),V&&n.jsx("p",{style:{marginTop:8,fontSize:13,color:V==="Done"?W.green:W.red},children:V})]}),n.jsx(Gi,{doctype:B.incidents,docname:e.name,currentUserName:C.name}),n.jsx(Yi,{doctype:B.incidents,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):null;return n.jsxs(Me,{title:M,activePage:"incidents",user:C,formStatus:c,buttonText:I.saveIncident,buttonColor:W.accent,viewMode:v,onEdit:b,darkMode:g,notifCount:S,onToggleDark:h,onCountChange:m,onViewProfile:o,rightPanel:gt,onSubmit:z,onBack:R,onNavigate:P,onLogout:k,children:[n.jsxs("div",{style:_s,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.number}),n.jsx("input",{style:{...A,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[I.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.organization,onChange:_=>E({organization:_}),organizations:l,disabled:v||!!C.custom_organization})]})]}),n.jsxs("div",{style:Ta,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.management}),n.jsx(ue,{value:e.management,onChange:_=>E({management:_}),items:K,placeholder:I.field.select,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.department}),n.jsx(ue,{value:e.department,onChange:_=>E({department:_}),items:ne,placeholder:I.field.select,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.section}),n.jsx("input",{style:{...A,...O},value:e.section_field||"",disabled:v,onChange:_=>E({section_field:_.target.value})})]})]}),n.jsxs("div",{style:_s,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.branch}),n.jsx(ue,{value:e.branch,onChange:_=>E({branch:_}),items:q,placeholder:I.field.select,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.hsesField}),n.jsx("input",{style:{...A,...O},value:e.hses_field||"",disabled:v,onChange:_=>E({hses_field:_.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{style:_s,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.type}),n.jsx(ue,{value:e.type,onChange:_=>E({type:_}),items:me,placeholder:I.field.selectType,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.title}),n.jsx("input",{style:{...A,...O},value:e.title,disabled:v,onChange:_=>E({title:_.target.value})})]})]}),n.jsxs("div",{style:_s,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.incidentClass}),n.jsx(ue,{value:e.incident_class,onChange:_=>E({incident_class:_}),items:Ce,placeholder:I.field.selectClass,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.incidentField}),n.jsx(ue,{value:e.incident_field,onChange:_=>E({incident_field:_}),items:re,placeholder:I.field.selectField,disabled:v})]})]}),n.jsxs("div",{style:Ta,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.date}),n.jsx(ye,{value:e.date,onChange:_=>E({date:_}),disabled:v,style:{...A,...O}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.time}),n.jsx("input",{type:"time",style:{...A,...O},value:e.time,disabled:v,onChange:_=>E({time:_.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.assignedTo}),n.jsxs("select",{style:{...A,...O},value:e.assigned_to,disabled:v,onChange:_=>E({assigned_to:_.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),U.map(_=>n.jsx("option",{value:_.name,children:_.full_name||_.name},_.name))]})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.status}),n.jsx(ue,{value:e.status,onChange:_=>E({status:_}),items:ze,placeholder:I.field.selectStatus,disabled:v})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.description}),n.jsx("textarea",{style:{...A,...O,height:120,resize:"vertical"},value:e.description,disabled:v,onChange:_=>E({description:_.target.value})})]}),!H&&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:I.steps.auditorTriage}),n.jsxs("div",{style:Ta,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.priority}),n.jsxs("select",{style:{...A,...v&&!J?{background:"#f9f9f9"}:{}},value:e.priority||"",disabled:v&&!J,onChange:_=>E({priority:_.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),n.jsx("option",{value:"High",children:I.field.high}),n.jsx("option",{value:"Normal",children:I.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.economyClass}),n.jsxs("select",{style:{...A,...v&&!J?{background:"#f9f9f9"}:{}},value:e.economy_class||"",disabled:v&&!J,onChange:_=>E({economy_class:_.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),n.jsx("option",{value:"Expenses",children:I.field.expenses}),n.jsx("option",{value:"Capital",children:I.field.capital}),n.jsx("option",{value:"Earn",children:I.field.earn}),n.jsx("option",{value:"Pay/Loss",children:I.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.entityScope}),n.jsxs("select",{style:{...A,...v&&!J?{background:"#f9f9f9"}:{}},value:e.entity_scope||"",disabled:v&&!J,onChange:_=>E({entity_scope:_.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),n.jsx("option",{value:"Upstream",children:I.field.upstream}),n.jsx("option",{value:"On-stream",children:I.field.onstream}),n.jsx("option",{value:"Downstream",children:I.field.downstream})]})]})]}),n.jsxs("div",{style:{display:"flex",gap: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&&!J,onChange:_=>E({product_relation:_.target.checked?1:0})})," ",I.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&&!J,onChange:_=>E({repeated:_.target.checked?1:0})})," ",I.field.repeatedEvent]})]})]}),!H&&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:I.steps.managerSolution}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.solution}),n.jsx("textarea",{style:{...A,height:100,resize:"vertical",...v&&!N&&!J?{background:"#f9f9f9"}:{}},value:e.solution||"",disabled:v&&!N&&!J,onChange:_=>E({solution:_.target.value}),placeholder:I.field.solutionPlaceholder})]}),n.jsxs("div",{style:_s,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.actualCost}),n.jsx("input",{type:"number",style:{...A,...v&&!N&&!J?{background:"#f9f9f9"}:{}},value:e.cost||"",disabled:v&&!N&&!J,onChange:_=>E({cost:parseFloat(_.target.value)||0}),placeholder:"0.00"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.summary}),n.jsx("input",{style:{...A,...v&&!N&&!J?{background:"#f9f9f9"}:{}},value:e.summary||"",disabled:v&&!N&&!J,onChange:_=>E({summary:_.target.value}),placeholder:"Brief summary"})]})]})]}),!H&&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:I.steps.ownerComment}),n.jsx("textarea",{style:{...A,height:80,resize:"vertical",...v&&!J?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:v&&!J,onChange:_=>E({auditor_comment:_.target.value}),placeholder:I.field.commentPlaceholder})]})]})}function Jy({ideas:e,organizations:t,departments:l,branches:s,ideaStatuses:r,initialOrg:i,initialStatus:a,canModify:d,onView:u,onEdit:f,onDelete:y}){const p=ee(),[c,v]=j.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),b=(o,x)=>v(z=>({...z,[o]:x})),[g,S]=j.useState(1),h=e.filter(o=>!(c.search&&!`${o.number} ${o.title}`.toLowerCase().includes(c.search.toLowerCase())||c.organization&&o.organization!==c.organization||c.department&&o.department!==c.department||c.branch&&o.branch!==c.branch||c.status&&o.status!==c.status));j.useEffect(()=>{S(1)},[c]);const m=h.slice((g-1)*se,g*se);return n.jsxs(n.Fragment,{children:[n.jsx(Qi,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.numberTitle}),n.jsx("input",{style:Ue,value:c.search,onChange:o=>b("search",o.target.value),placeholder:p.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.organization}),n.jsxs("select",{style:Ue,value:c.organization,onChange:o=>b("organization",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.department}),n.jsxs("select",{style:Ue,value:c.department,onChange:o=>b("department",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allDepts}),l.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.branch}),n.jsxs("select",{style:Ue,value:c.branch,onChange:o=>b("branch",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allBranches}),s.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.status}),n.jsxs("select",{style:Ue,value:c.status,onChange:o=>b("status",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allStatuses}),r.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>v({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"5px 12px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#6b7280",fontFamily:"Segoe UI"},children:p.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.number}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.title}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.actions})]})}),n.jsx("tbody",{children:h.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:p.noIdeas})}):m.map((o,x)=>n.jsxs("tr",{onClick:()=>u==null?void 0:u(o),style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",color:"#999"},children:o.number||"—"}),n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.title||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.status?Ln(o.status,Ki(o.status)):"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:z=>z.stopPropagation(),children:n.jsx(Je,{onView:()=>u==null?void 0:u(o),onEdit:d&&f?()=>f(o):void 0,onDelete:d&&y?()=>y(o.name):void 0})})]},o.name))})]})}),n.jsx(Fe,{page:g,total:h.length,onPageChange:S})]})}const ou={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Pa={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},Zy={New:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Initial Evaluation":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},"Accept & Under Progress":{background:"#fefce8",color:"#92400e",border:"1px solid #fde68a"},"working on proposal":{background:"#f5f3ff",color:"#6d28d9",border:"1px solid #ddd6fe"},Rejected:{background:"#fef2f2",color:"#dc2626",border:"1px solid #fecaca"},"Executed & Closed":{background:"#f0fdf4",color:"#166534",border:"1px solid #bbf7d0"}};function Vy(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...Zy[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function e0({ideaForm:e,setIdeaForm:t,organizations:l,managements:s,departments:r,branches:i,ideaTypes:a,ideaStatuses:d,users:u=[],userRoleMap:f={},formStatus:y,viewMode:p,onEdit:c,darkMode:v,notifCount:b,onToggleDark:g,onCountChange:S,onViewProfile:h,userRole:m,onSubmit:o,onBack:x,onNavigate:z,onLogout:R,user:P,onRefresh:k}){const C=ee(),$=N=>t({...e,...N}),I=p?{background:"#f9f9f9"}:{},E=fr(u,f,"SB Manager",e.organization),[O,U]=j.useState(""),[V,xe]=j.useState(!1),le=e.name?p?`${C.formTitle.viewIdea}${e.number||e.title||e.name}`:C.formTitle.editIdea:C.formTitle.newIdea,L=fe(s,e.management).map(N=>({name:N.name,label:N.name1||N.name})),M=fe(r,e.department).map(N=>({name:N.name,label:N.department_name||N.name})),K=fe(i,e.branch).map(N=>({name:N.name,label:N.branch||N.name})),ne=fe(a,e.type).map(N=>({name:N.name,label:N.name1||N.name})),q=fe(d,e.status).map(N=>({name:N.name,label:N.name1||N.name})),me=e.workflow_state||"New",Ce=m==="Employee",re=m==="Auditor"||m==="Admin",ze=m==="Manager",he=e.name?me==="New"?[{label:C.wf.submit,action:"Submit",color:"#2563eb"}]:me==="Initial Evaluation"&&re?[{label:C.wf.assignToManager,action:"Assign to Manager",color:"#d97706"},{label:C.wf.reject,action:"Reject",color:"#dc2626"}]:me==="Accept & Under Progress"&&(ze||re)?[{label:C.wf.submitSolution,action:"Submit Proposal",color:"#059669"}]:me==="working on proposal"&&re?[{label:C.wf.moveToOutsourcing,action:"Move to Outsourcing",color:"#0369a1"},{label:C.wf.reject,action:"Reject",color:"#dc2626"}]:[]:[];async function H(N){if(e.name){xe(!0),U("");try{const oe={};N==="Assign to Manager"&&(e.assigned_to&&(oe.assigned_to=e.assigned_to),e.priority&&(oe.priority=e.priority),e.economy_class&&(oe.economy_class=e.economy_class),e.entity_scope&&(oe.entity_scope=e.entity_scope),e.hses_field&&(oe.hses_field=e.hses_field),oe.product_relation=String(e.product_relation??0),oe.repeated=String(e.repeated??0)),N==="Submit Proposal"&&(e.solution&&(oe.solution=e.solution),e.proposed_condition&&(oe.proposed_condition=e.proposed_condition),e.cost&&(oe.cost=String(e.cost))),e.auditor_comment&&(N==="Move to Outsourcing"||N==="Reject")&&(oe.auditor_comment=e.auditor_comment),await xy(e.name,N,JSON.stringify(oe)),U("Done"),k==null||k()}catch(oe){U(oe.message||"Error")}finally{xe(!1)}}}const J=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:C.wf.workflow}),n.jsx("span",{style:Vy(me),children:me})]}),me==="Initial Evaluation"&&re&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:C.wf.assignToManager}),n.jsxs("select",{style:A,value:e.assigned_to||"",onChange:N=>$({assigned_to:N.target.value}),children:[n.jsx("option",{value:"",children:C.field.selectMgr}),E.map(N=>n.jsx("option",{value:N.name,children:N.full_name||N.name},N.name))]})]}),me==="Accept & Under Progress"&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:C.field.solution}),n.jsx("textarea",{style:{...A,height:80,resize:"vertical"},value:e.solution||"",onChange:N=>$({solution:N.target.value}),placeholder:C.field.solutionPlaceholder}),n.jsx("label",{style:{...T,marginTop:8},children:C.field.actualCost}),n.jsx("input",{type:"number",style:A,value:e.cost||"",onChange:N=>$({cost:parseFloat(N.target.value)||0}),placeholder:"0.00"})]}),me==="working on proposal"&&re&&n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("label",{style:T,children:C.field.auditorComment}),n.jsx("textarea",{style:{...A,height:60,resize:"vertical"},value:e.auditor_comment||"",onChange:N=>$({auditor_comment:N.target.value}),placeholder:C.field.commentPlaceholder})]}),he.length>0?n.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:he.map(N=>n.jsx("button",{onClick:()=>H(N.action),disabled:V,style:{padding:"8px 18px",borderRadius:8,border:"none",background:N.color,color:"white",fontWeight:700,cursor:V?"not-allowed":"pointer",opacity:V?.7:1},children:V?C.wf.applying:N.label},N.action))}):n.jsx("div",{style:{fontSize:12,color:"#94a3b8",fontStyle:"italic"},children:C.wf.noActions}),O&&n.jsx("p",{style:{marginTop:8,fontSize:13,color:O==="Done"?W.green:W.red},children:O})]}),n.jsx(Gi,{doctype:B.ideas,docname:e.name,currentUserName:P.name}),n.jsx(Yi,{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:C.saveIdea,buttonColor:W.teal,viewMode:p,onEdit:c,darkMode:v,notifCount:b,onToggleDark:g,onCountChange:S,onViewProfile:h,rightPanel:J,onSubmit:o,onBack:x,onNavigate:z,onLogout:R,children:[n.jsxs("div",{style:ou,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:C.field.number}),n.jsx("input",{style:{...A,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[C.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.organization,onChange:N=>$({organization:N}),organizations:l,disabled:p||!!P.custom_organization})]})]}),n.jsxs("div",{style:Pa,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:C.field.management}),n.jsx(ue,{value:e.management,onChange:N=>$({management:N}),items:L,placeholder:C.field.select,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:C.field.department}),n.jsx(ue,{value:e.department,onChange:N=>$({department:N}),items:M,placeholder:C.field.select,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:C.field.section}),n.jsx("input",{style:{...A,...I},value:e.section_field||"",disabled:p,onChange:N=>$({section_field:N.target.value})})]})]}),n.jsxs("div",{style:ou,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:C.field.branch}),n.jsx(ue,{value:e.branch,onChange:N=>$({branch:N}),items:K,placeholder:C.field.select,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:C.field.date}),n.jsx(ye,{value:e.date||"",onChange:N=>$({date:N}),disabled:p,style:{...A,...I}})]})]}),n.jsxs("div",{style:Pa,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:C.field.type}),n.jsx(ue,{value:e.type,onChange:N=>$({type:N}),items:ne,placeholder:C.field.selectType,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:C.field.ideaClass}),n.jsxs("select",{style:{...A,...I},value:e.idea_class||"",disabled:p,onChange:N=>$({idea_class:N.target.value}),children:[n.jsx("option",{value:"",children:C.field.select}),n.jsx("option",{value:"Safety",children:"Safety"}),n.jsx("option",{value:"Non-safety",children:"Non-safety"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:C.field.hsesField}),n.jsx("input",{style:{...A,...I},value:e.hses_field||"",disabled:p,onChange:N=>$({hses_field:N.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:C.field.title}),n.jsx("input",{style:{...A,...I},value:e.title,disabled:p,onChange:N=>$({title:N.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:C.field.status}),n.jsx(ue,{value:e.status,onChange:N=>$({status:N}),items:q,placeholder:C.field.selectStatus,disabled:p})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:C.field.currentCondition}),n.jsx("textarea",{style:{...A,...I,height:110,resize:"vertical"},value:e.current_condition,disabled:p,onChange:N=>$({current_condition:N.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:C.field.proposedCondition}),n.jsx("textarea",{style:{...A,...I,height:110,resize:"vertical"},value:e.proposed_condition,disabled:p,onChange:N=>$({proposed_condition:N.target.value})})]}),!Ce&&n.jsxs("div",{style:{background:"#fffbeb",border:"1px solid #fde68a",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#92400e",marginBottom:10},children:C.steps.auditorEval}),n.jsxs("div",{style:Pa,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:C.field.priority}),n.jsxs("select",{style:{...A,...p&&!re?{background:"#f9f9f9"}:{}},value:e.priority||"",disabled:p&&!re,onChange:N=>$({priority:N.target.value}),children:[n.jsx("option",{value:"",children:C.field.select}),n.jsx("option",{value:"High",children:C.field.high}),n.jsx("option",{value:"Normal",children:C.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:C.field.economyClass}),n.jsxs("select",{style:{...A,...p&&!re?{background:"#f9f9f9"}:{}},value:e.economy_class||"",disabled:p&&!re,onChange:N=>$({economy_class:N.target.value}),children:[n.jsx("option",{value:"",children:C.field.select}),n.jsx("option",{value:"Expenses",children:C.field.expenses}),n.jsx("option",{value:"Capital",children:C.field.capital}),n.jsx("option",{value:"Earn",children:C.field.earn}),n.jsx("option",{value:"Pay/Loss",children:C.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:C.field.entityScope}),n.jsxs("select",{style:{...A,...p&&!re?{background:"#f9f9f9"}:{}},value:e.entity_scope||"",disabled:p&&!re,onChange:N=>$({entity_scope:N.target.value}),children:[n.jsx("option",{value:"",children:C.field.select}),n.jsx("option",{value:"Upstream",children:C.field.upstream}),n.jsx("option",{value:"On-stream",children:C.field.onstream}),n.jsx("option",{value:"Downstream",children:C.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:N=>$({product_relation:N.target.checked?1:0})})," ",C.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:N=>$({repeated:N.target.checked?1:0})})," ",C.field.repeatedEvent]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:T,children:C.wf.assignToManager}),n.jsxs("select",{style:{...A,...p&&!re?{background:"#f9f9f9"}:{}},value:e.assigned_to||"",disabled:p&&!re,onChange:N=>$({assigned_to:N.target.value}),children:[n.jsx("option",{value:"",children:C.field.select}),E.map(N=>n.jsx("option",{value:N.name,children:N.full_name||N.name},N.name))]})]})]}),!Ce&&n.jsxs("div",{style:{background:"#eff6ff",border:"1px solid #bfdbfe",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#1e40af",marginBottom:10},children:C.steps.managerSolution}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:C.field.solution}),n.jsx("textarea",{style:{...A,height:100,resize:"vertical",...p&&!ze&&!re?{background:"#f9f9f9"}:{}},value:e.solution||"",disabled:p&&!ze&&!re,onChange:N=>$({solution:N.target.value}),placeholder:C.field.solutionPlaceholder})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:T,children:C.field.actualCost}),n.jsx("input",{type:"number",style:{...A,...p&&!ze&&!re?{background:"#f9f9f9"}:{}},value:e.cost||"",disabled:p&&!ze&&!re,onChange:N=>$({cost:parseFloat(N.target.value)||0}),placeholder:"0.00"})]})]}),!Ce&&n.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:16,marginTop:8},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#166534",marginBottom:10},children:C.steps.ownerComment}),n.jsx("textarea",{style:{...A,height:80,resize:"vertical",...p&&!re?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:p&&!re,onChange:N=>$({auditor_comment:N.target.value}),placeholder:C.field.commentPlaceholder})]})]})}function t0({orders:e,organizations:t,departments:l,branches:s,orderStatuses:r,initialOrg:i,initialStatus:a,canModify:d,onView:u,onEdit:f,onDelete:y}){const p=ee(),[c,v]=j.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),b=(o,x)=>v(z=>({...z,[o]:x})),[g,S]=j.useState(1),h=e.filter(o=>!(c.search&&!`${o.number} ${o.title}`.toLowerCase().includes(c.search.toLowerCase())||c.organization&&o.organization!==c.organization||c.department&&o.department!==c.department||c.branch&&o.branch!==c.branch||c.status&&o.status!==c.status));j.useEffect(()=>{S(1)},[c]);const m=h.slice((g-1)*se,g*se);return n.jsxs(n.Fragment,{children:[n.jsx(Qi,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.numberTitle}),n.jsx("input",{style:Ue,value:c.search,onChange:o=>b("search",o.target.value),placeholder:p.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.organization}),n.jsxs("select",{style:Ue,value:c.organization,onChange:o=>b("organization",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.department}),n.jsxs("select",{style:Ue,value:c.department,onChange:o=>b("department",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allDepts}),l.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.branch}),n.jsxs("select",{style:Ue,value:c.branch,onChange:o=>b("branch",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allBranches}),s.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.status}),n.jsxs("select",{style:Ue,value:c.status,onChange:o=>b("status",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allStatuses}),r.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>v({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"5px 12px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#6b7280",fontFamily:"Segoe UI"},children:p.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.number}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.title}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.type}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.actions})]})}),n.jsx("tbody",{children:h.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:p.noOrders})}):m.map((o,x)=>n.jsxs("tr",{onClick:()=>u==null?void 0:u(o),style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",color:"#999"},children:o.number||"—"}),n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.title||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.type?Ln(o.type,"#8e44ad"):"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.status?Ln(o.status,Ki(o.status)):"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:z=>z.stopPropagation(),children:n.jsx(Je,{onView:()=>u==null?void 0:u(o),onEdit:d&&f?()=>f(o):void 0,onDelete:d&&y?()=>y(o.name):void 0})})]},o.name))})]})}),n.jsx(Fe,{page:g,total:h.length,onPageChange:S})]})}const $r={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},Ur={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20},n0={1:"Initiation / Bidding",2:"Execution begins",3:"Mid-execution review",4:"Near completion",5:"Closing"},l0={Draft:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Pending Actor":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},Review:{background:"#f0fdf4",color:"#15803d",border:"1px solid #bbf7d0"},"In Study":{background:"#f1f5f9",color:"#475569",border:"1px solid #cbd5e1"},Closed:{background:"#f0fdf4",color:"#166534",border:"1px solid #bbf7d0"}};function s0(e){return{display:"inline-block",padding:"4px 12px",borderRadius:20,fontSize:13,fontWeight:700,...l0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}function r0({orderForm:e,setOrderForm:t,organizations:l,managements:s,departments:r,branches:i,orderTypes:a,orderStatuses:d,cycles:u=[],users:f,userRoleMap:y={},formStatus:p,viewMode:c,onEdit:v,darkMode:b,notifCount:g,onToggleDark:S,onCountChange:h,onViewProfile:m,currentUser:o,userRole:x,onSubmit:z,onBack:R,onNavigate:P,onLogout:k,user:C,onRefresh:$}){var $n;const I=ee(),E=D=>t({...e,...D}),O=c?{background:"#f9f9f9"}:{},U=fr(f,y,"SB Employee",e.organization),[V,xe]=j.useState(""),[le,L]=j.useState(""),[M,K]=j.useState(!1),[ne,q]=j.useState("Agree"),me=e.name?c?`${I.formTitle.viewOrder}${e.number||e.title||e.name}`:I.formTitle.editOrder:I.formTitle.newOrder,Ce=fe(s,e.management).map(D=>({name:D.name,label:D.name1||D.name})),re=fe(r,e.department).map(D=>({name:D.name,label:D.department_name||D.name})),ze=fe(i,e.branch).map(D=>({name:D.name,label:D.branch||D.name})),he=fe(a,e.type).map(D=>({name:D.name,label:D.name1||D.name})),H=fe(d,e.status).map(D=>({name:D.name,label:D.name1||D.name})),J=fe(u,e.cycle).map(D=>({name:D.name,label:D.name1||D.name})),N=!!e.name,oe=e.workflow_state||"Draft",Wn=Math.min(5,(e.stage||0)+1),[gt,_]=j.useState(Wn);j.useEffect(()=>{_(Math.min(5,(e.stage||0)+1))},[e.stage]);const Y=x==="Auditor"||x==="Admin"||x==="Manager",Z=Y||x==="Owner",Yt=!!(o&&(e.actor===o||e.assigned_to===o)),gr=N?oe==="Closed"?[]:oe==="Draft"&&Y?[{label:"Submit for Review",action:"Submit for Review",color:"#2563eb"}]:oe==="Pending Actor"&&(Yt||Y)?[{label:"Update Status",action:"Update Status",color:"#d97706"}]:oe==="Review"&&Z?[{label:"Move to Study",action:"Move to Study",color:"#059669"},{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"}]:oe==="In Study"&&Z?[{label:"Start New Cycle",action:"Start New Cycle",color:"#2563eb"},{label:"Close Order",action:"Close Order",color:"#475569"}]:[]:[];async function Bn(D){if(e.name){K(!0),xe("");try{let Ge;D==="Update Status"&&(Ge=ne);const hl=await hy(e.name,D,le,D==="Update Status"?String(gt):void 0,void 0,Ge);if(L(""),q("Agree"),xe("Done"),hl){const kt=hl;t({...e,...kt,stage:kt.stage??e.stage,completion_pct:kt.completion_pct??e.completion_pct,workflow_state:kt.workflow_state??e.workflow_state})}$==null||$()}catch(Ge){xe(Ge.message||"Error")}finally{K(!1)}}}const Xi=N?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:I.wf.workflow}),n.jsx("span",{style:s0(oe),children:oe})]}),oe==="Pending Actor"&&n.jsxs("div",{style:{display:"flex",gap:16,marginBottom:14,flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:["Stage (1–5) — ",gt*20,"% complete"]}),n.jsx("input",{type:"number",min:1,max:5,style:{...A,maxWidth:80},value:gt,onChange:D=>_(Math.min(5,Math.max(1,parseInt(D.target.value)||1)))})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Cycle Status"}),n.jsxs("select",{style:{...A,minWidth:140},value:ne,onChange:D=>q(D.target.value),children:[n.jsx("option",{value:"Agree",children:"✅ Agree — on track"}),n.jsx("option",{value:"Deviate",children:"⚠️ Deviate — off plan"}),n.jsx("option",{value:"Unknown",children:"❓ Unknown"})]})]})]}),n.jsxs("div",{style:{marginBottom:14},children:[n.jsxs("label",{style:T,children:["Comment ",ne==="Deviate"&&oe==="Pending Actor"?n.jsx("span",{style:{color:W.red},children:" * required for Deviate"}):"(optional)"]}),n.jsx("textarea",{style:{...A,height:64,resize:"vertical",borderColor:ne==="Deviate"&&!le?"#fca5a5":void 0},value:le,onChange:D=>L(D.target.value),placeholder:"Add a comment…"})]}),n.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:gr.map(D=>{const Ge=D.action==="Update Status"&&ne==="Deviate"&&!le.trim();return n.jsx("button",{onClick:()=>Bn(D.action),disabled:M||Ge,title:Ge?"Comment required when status is Deviate":void 0,style:{padding:"8px 18px",borderRadius:8,border:"none",background:D.color,color:"white",fontWeight:700,cursor:M||Ge?"not-allowed":"pointer",opacity:M||Ge?.5:1},children:M?I.wf.applying:D.label},D.action)})}),V&&n.jsx("p",{style:{marginTop:8,fontSize:13,color:V==="Done"?W.green:W.red},children:V}),gr.length===0&&n.jsx("div",{style:{fontSize:12,color:"#94a3b8",fontStyle:"italic"},children:I.wf.noActions})]}),n.jsx(Gi,{doctype:B.orders,docname:e.name,currentUserName:C.name}),n.jsx(Yi,{doctype:B.orders,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):null;return n.jsxs(Me,{title:me,activePage:"orders",user:C,formStatus:p,buttonText:I.saveOrder,buttonColor:W.purple,viewMode:c,onEdit:v,darkMode:b,notifCount:g,onToggleDark:S,onCountChange:h,onViewProfile:m,rightPanel:Xi,onSubmit:z,onBack:R,onNavigate:P,onLogout:k,children:[n.jsxs("div",{style:$r,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.number}),n.jsx("input",{style:{...A,background:"#f9f9f9"},value:e.number,readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[I.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.organization,onChange:D=>E({organization:D}),organizations:l,disabled:c||!!C.custom_organization})]})]}),n.jsxs("div",{style:Ur,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.management}),n.jsx(ue,{value:e.management,onChange:D=>E({management:D}),items:Ce,placeholder:I.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.department}),n.jsx(ue,{value:e.department,onChange:D=>E({department:D}),items:re,placeholder:I.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.section}),n.jsx("input",{style:{...A,...O},value:e.section_field||"",disabled:c,onChange:D=>E({section_field:D.target.value})})]})]}),n.jsxs("div",{style:$r,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.branch}),n.jsx(ue,{value:e.branch,onChange:D=>E({branch:D}),items:ze,placeholder:I.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.type}),n.jsx(ue,{value:e.type,onChange:D=>E({type:D}),items:he,placeholder:I.field.selectType,disabled:c})]})]}),n.jsxs("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:14,marginTop:4},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#475569",marginBottom:10},children:"Classification"}),n.jsxs("div",{style:Ur,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.priority}),n.jsxs("select",{style:{...A,...O},value:e.priority||"",disabled:c,onChange:D=>E({priority:D.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),n.jsx("option",{value:"High",children:I.field.high}),n.jsx("option",{value:"Normal",children:I.field.normal})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.economyClass}),n.jsxs("select",{style:{...A,...O},value:e.economy_class||"",disabled:c,onChange:D=>E({economy_class:D.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),n.jsx("option",{value:"Expenses",children:I.field.expenses}),n.jsx("option",{value:"Capital",children:I.field.capital}),n.jsx("option",{value:"Earn",children:I.field.earn}),n.jsx("option",{value:"Pay/Loss",children:I.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.entityScope}),n.jsxs("select",{style:{...A,...O},value:e.entity_scope||"",disabled:c,onChange:D=>E({entity_scope:D.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),n.jsx("option",{value:"Upstream",children:I.field.upstream}),n.jsx("option",{value:"On-stream",children:I.field.onstream}),n.jsx("option",{value:"Downstream",children:I.field.downstream})]})]})]}),n.jsxs("div",{style:{display:"flex",gap:24,marginTop:12,alignItems:"center",flexWrap:"wrap"},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13},children:[n.jsx("input",{type:"checkbox",checked:!!e.planned,disabled:c,onChange:D=>E({planned:D.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:D=>E({product_relation:D.target.checked?1:0})})," ",I.field.productRelation]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:T,children:I.field.hsesField}),n.jsx("input",{style:{...A,...O},value:e.hses_field||"",disabled:c,onChange:D=>E({hses_field:D.target.value}),placeholder:"Safety, Health, Environment…"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.title}),n.jsx("input",{style:{...A,...O},value:e.title,disabled:c,onChange:D=>E({title:D.target.value})})]}),n.jsxs("div",{style:Ur,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.budget}),n.jsx("input",{type:"number",style:{...A,...O},value:e.budget||"",disabled:c,onChange:D=>E({budget:parseFloat(D.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.actualCost}),n.jsx("input",{type:"number",style:{...A,...O},value:e.actual_cost||"",disabled:c,onChange:D=>E({actual_cost:parseFloat(D.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Variance"}),(()=>{const D=(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:D>=0?"#f0fdf4":"#fef2f2",color:D>=0?"#166534":"#dc2626",border:`1px solid ${D>=0?"#bbf7d0":"#fecaca"}`},children:[D>=0?"+":"",D.toFixed(2)]})})()]})]}),n.jsxs("div",{style:$r,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.currency}),n.jsxs("select",{style:{...A,...O},value:e.currency||"",disabled:c,onChange:D=>E({currency:D.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),n.jsx("option",{value:"SAR",children:"SAR"}),n.jsx("option",{value:"USD",children:"USD"}),n.jsx("option",{value:"EUR",children:"EUR"}),n.jsx("option",{value:"AED",children:"AED"}),n.jsx("option",{value:"GBP",children:"GBP"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.status}),n.jsx(ue,{value:e.status,onChange:D=>E({status:D}),items:H,placeholder:I.field.selectStatus,disabled:c||oe==="Closed"})]})]}),n.jsxs("div",{style:Ur,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.startingDate}),n.jsx(ye,{value:e.starting_date,onChange:D=>E({starting_date:D}),disabled:c,style:{...A,...O}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.endingDate}),n.jsx(ye,{value:e.ending_date,onChange:D=>E({ending_date:D}),disabled:c,style:{...A,...O}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.actor}),n.jsxs("select",{style:{...A,...O},value:e.actor||e.assigned_to||"",disabled:c,onChange:D=>E({actor:D.target.value,assigned_to:D.target.value}),children:[n.jsx("option",{value:"",children:I.field.select}),U.map(D=>n.jsx("option",{value:D.name,children:D.full_name||D.name},D.name))]})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",fontSize:13,marginBottom:12},children:"Cycle & Progress"}),n.jsxs("div",{style:$r,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.cycle}),n.jsx(ue,{value:e.cycle||"",onChange:D=>E({cycle:D}),items:J,placeholder:I.field.select,disabled:c})]}),n.jsxs("div",{style:{display:"flex",gap:20,flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.stage}),n.jsx("input",{type:"number",min:1,max:5,style:{...A,background:"#f9f9f9",maxWidth:80},value:e.stage||1,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Completion"}),n.jsx("input",{style:{...A,background:"#f9f9f9",maxWidth:100},value:`${e.completion_pct||(e.stage||1)*20}%`,readOnly:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Stage Description"}),n.jsx("span",{style:{display:"inline-block",padding:"6px 12px",borderRadius:8,fontSize:13,fontWeight:600,background:"#f0f9ff",color:"#0369a1",border:"1px solid #bae6fd"},children:n0[e.stage||1]||"—"})]}),(e.escalation_level??0)>0&&n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.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]})]})]})]})]}),N&&(($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(D=>n.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#475569",borderBottom:"1px solid #e2e8f0"},children:D},D))})}),n.jsx("tbody",{children:(e.order_cycle_log||[]).map((D,Ge)=>{const hl=D.status==="Agree"?"#166534":D.status==="Deviate"?"#c2410c":"#92400e",kt=D.status==="Agree"?"#f0fdf4":D.status==="Deviate"?"#fff7ed":"#fefce8";return n.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:D.cycle||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:D.cycle_date||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155",textAlign:"center"},children:D.stage||"—"}),n.jsx("td",{style:{padding:"6px 10px"},children:n.jsx("span",{style:{background:kt,color:hl,padding:"2px 8px",borderRadius:12,fontWeight:600,fontSize:12},children:D.status||"—"})}),n.jsx("td",{style:{padding:"6px 10px",color:"#334155"},children:D.actor||"—"}),n.jsx("td",{style:{padding:"6px 10px",color:"#64748b",fontStyle:D.comment?"normal":"italic"},children:D.comment||"—"})]},Ge)})})]})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.description}),n.jsx("textarea",{style:{...A,...O,height:100,resize:"vertical"},value:e.description,disabled:c,onChange:D=>E({description:D.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:I.field.notes}),n.jsx("textarea",{style:{...A,...O,height:100,resize:"vertical"},value:e.notes,disabled:c,onChange:D=>E({notes:D.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:I.field.auditorComment}),n.jsx("textarea",{style:{...A,height:80,resize:"vertical",...c&&Yt&&!Y?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:c&&Yt&&!Y,onChange:D=>E({auditor_comment:D.target.value}),placeholder:I.field.commentPlaceholder})]})]})}function i0({processes:e,organizations:t,departments:l,branches:s,processStatuses:r,initialOrg:i,initialStatus:a,canModify:d,onView:u,onEdit:f,onDelete:y}){const p=ee(),[c,v]=j.useState({search:"",organization:i||"",department:"",branch:"",status:a||""}),b=(o,x)=>v(z=>({...z,[o]:x})),[g,S]=j.useState(1),h=e.filter(o=>!(c.search&&!`${o.number} ${o.title}`.toLowerCase().includes(c.search.toLowerCase())||c.organization&&o.organization!==c.organization||c.department&&o.department!==c.department||c.branch&&o.branch!==c.branch||c.status&&o.status!==c.status));j.useEffect(()=>{S(1)},[c]);const m=h.slice((g-1)*se,g*se);return n.jsxs(n.Fragment,{children:[n.jsx(Qi,{children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px 14px"},children:[n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.numberTitle}),n.jsx("input",{style:Ue,value:c.search,onChange:o=>b("search",o.target.value),placeholder:p.filter.searchPlaceholder})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.organization}),n.jsxs("select",{style:Ue,value:c.organization,onChange:o=>b("organization",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allOrgs}),t.map(o=>n.jsx("option",{value:o.name,children:o.organization_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.department}),n.jsxs("select",{style:Ue,value:c.department,onChange:o=>b("department",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allDepts}),l.map(o=>n.jsx("option",{value:o.name,children:o.department_name||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.branch}),n.jsxs("select",{style:Ue,value:c.branch,onChange:o=>b("branch",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allBranches}),s.map(o=>n.jsx("option",{value:o.name,children:o.branch||o.name},o.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:$e,children:p.filter.status}),n.jsxs("select",{style:Ue,value:c.status,onChange:o=>b("status",o.target.value),children:[n.jsx("option",{value:"",children:p.filter.allStatuses}),r.map(o=>n.jsx("option",{value:o.name,children:o.name1||o.name},o.name))]})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:()=>v({search:"",organization:"",department:"",branch:"",status:""}),style:{padding:"5px 12px",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:12,color:"#6b7280",fontFamily:"Segoe UI"},children:p.clear})})]})}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.number}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.title}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.field.cycleType}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:p.col.actions})]})}),n.jsx("tbody",{children:h.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:p.noProcesses})}):m.map((o,x)=>n.jsxs("tr",{onClick:()=>u==null?void 0:u(o),style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",color:"#999"},children:o.number||"—"}),n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.title||o.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.cycle_type?Ln(o.cycle_type,"#8e44ad"):"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.status?Ln(o.status,Ki(o.status)):"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:z=>z.stopPropagation(),children:n.jsx(Je,{onView:()=>u==null?void 0:u(o),onEdit:d&&f?()=>f(o):void 0,onDelete:d&&y?()=>y(o.name):void 0})})]},o.name))})]})}),n.jsx(Fe,{page:g,total:h.length,onPageChange:S})]})}const a0={Draft:[{action:"Submit for Review",next:"Pending Actor",allowedRoles:["Auditor","Manager"]}],"Pending Actor":[{action:"Update Status",next:"Pending Comment",allowedRoles:["Employee","Manager"]}],"Pending Comment":[{action:"Add Comment",next:"Review",allowedRoles:["Auditor","Manager"]}],Review:[{action:"Start New Cycle",next:"Pending Actor",allowedRoles:["Auditor","Manager"]},{action:"Move to Study",next:"In Study",allowedRoles:["Auditor","Manager"]}],"In Study":[{action:"Start New Cycle",next:"Pending Actor",allowedRoles:["Auditor","Manager"]},{action:"Close Process",next:"Closed",allowedRoles:["Auditor","Manager"]}]},o0={Draft:{background:"#eff6ff",color:"#1e40af",border:"1px solid #bfdbfe"},"Pending Actor":{background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa"},"Pending Comment":{background:"#f5f3ff",color:"#6d28d9",border:"1px solid #ddd6fe"},Review:{background:"#f0fdf4",color:"#15803d",border:"1px solid #bbf7d0"},"In Study":{background:"#f1f5f9",color:"#475569",border:"1px solid #cbd5e1"},Closed:{background:"#f3f4f6",color:"#6b7280",border:"1px solid #9ca3af"}};function cu(e){return{display:"inline-block",padding:"5px 14px",borderRadius:20,fontSize:13,fontWeight:700,...o0[e]??{background:"#f3f4f6",color:"#374151",border:"1px solid #e5e7eb"}}}const Fr={width:"100%",padding:"6px 8px",border:"1px solid #d1d5db",borderRadius:5,fontSize:12,fontFamily:"Segoe UI",boxSizing:"border-box"};function c0({processName:e,userRole:t,onRefresh:l,canUpdateStatus:s=!0}){const[r,i]=j.useState(null),[a,d]=j.useState(!0),[u,f]=j.useState(""),[y,p]=j.useState(!1),[c,v]=j.useState(""),[b,g]=j.useState(""),[S,h]=j.useState("Pass"),[m,o]=j.useState(""),[x,z]=j.useState({}),R=j.useCallback(async()=>{if(!e){d(!1);return}d(!0),f("");try{const O=await Ls(e);i(O);const U={};for(const V of O.progress_indicators||[])U[V.name]=V.actual_value!=null?String(V.actual_value):"";z(U)}catch(O){f(O instanceof Error?O.message:"Failed to load process")}d(!1)},[e]);if(j.useEffect(()=>{R()},[R]),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",k=a0[P]??[],C=t==="Employee"||t==="Manager",$=t!=="Manager"||s,I=k.filter(O=>(t==="Admin"||O.allowedRoles.includes(t))&&(O.action!=="Update Status"||$)),E=async O=>{p(!0),v(""),g("");try{const U={};if(O==="Update Status"){U.actor_status=S,U.actor_comment=m;const xe=r.progress_indicators||[];xe.length>0&&(U.progress_indicators=xe.map(le=>({name:le.name,actual_value:x[le.name]??""})))}O==="Add Comment"&&m&&(U.actor_comment=m);const V=await Ty(r.name,O,U);i(V),o(""),g(`Done — now: ${V.workflow_state||"updated"}`),l==null||l()}catch(U){v(U instanceof Error?U.message:"Action failed")}p(!1)};return n.jsx("div",{style:{width:260,flexShrink:0},children:n.jsxs("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden"},children:[n.jsx("div",{style:{background:"#1a2332",color:"white",padding:"10px 14px",fontSize:12,fontWeight:700,letterSpacing:.3},children:"Workflow"}),n.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #f0f0f0"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:8},children:"Current State"}),n.jsx("div",{style:cu(P),children:P})]}),P==="Pending Actor"&&C&&$&&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(O=>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:O.name1,children:O.name1||O.name}),n.jsx("input",{type:"number",value:x[O.name]??"",onChange:U=>z(V=>({...V,[O.name]:U.target.value})),style:{...Fr,width:70,flexShrink:0},placeholder:"0"})]},O.name))})]}),n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Cycle Status"}),n.jsxs("select",{value:S,onChange:O=>h(O.target.value),style:Fr,children:[n.jsx("option",{value:"Pass",children:"✅ Pass — on target"}),n.jsx("option",{value:"Fail",children:"❌ Fail — off target"})]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,color:"#555",marginBottom:4},children:"Comment (optional)"}),n.jsx("textarea",{value:m,onChange:O=>o(O.target.value),style:{...Fr,height:52,resize:"vertical"},placeholder:"Add a comment…"})]})]}),(P==="Pending Comment"||P==="Review")&&!C&&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 O=r.cycle_logs,U=O[O.length-1],V=U.status==="Pass"?"#16a34a":U.status==="Fail"?"#dc2626":"#9ca3af";return n.jsxs("div",{style:{fontSize:13,fontWeight:700,color:V},children:[U.status," ",U.comment?`— ${U.comment}`:""]})})()]}),n.jsx("textarea",{value:m,onChange:O=>o(O.target.value),style:{...Fr,height:52,resize:"vertical"},placeholder:"Add a comment…"})]}),n.jsxs("div",{style:{padding:"12px 14px",borderBottom:I.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"}),I.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:I.map(O=>n.jsxs("button",{onClick:()=>E(O.action),disabled:y,style:{width:"100%",padding:"10px 14px",borderRadius:6,border:"none",background:O.action==="Close Process"?"#64748b":O.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…":O.action}),n.jsxs("span",{style:{fontSize:10,opacity:.7},children:["→ ",O.next]})]},O.action))}),c&&n.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:6,fontSize:12,color:"#991b1b",lineHeight:1.4},children:c}),b&&n.jsx("div",{style:{marginTop:10,padding:"8px 12px",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:6,fontSize:12,color:"#166534"},children:b})]}),k.length>0&&n.jsxs("div",{style:{padding:"12px 14px"},children:[n.jsx("div",{style:{fontSize:10,color:"#999",fontWeight:700,textTransform:"uppercase",letterSpacing:.8,marginBottom:10},children:"Next States"}),k.map(O=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6,fontSize:11},children:[n.jsx("span",{style:{color:"#555",flex:1},children:O.action}),n.jsx("span",{style:{color:"#bbb"},children:"→"}),n.jsx("span",{style:cu(O.next),children:O.next})]},O.action))]})]})})}const Mr={display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:16},Tl={display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:16};function d0({processForm:e,setProcessForm:t,organizations:l,managements:s,departments:r,branches:i,processTypes:a,processStatuses:d,cycles:u=[],users:f=[],userRoleMap:y={},formStatus:p,viewMode:c,onEdit:v,darkMode:b,notifCount:g,onToggleDark:S,onCountChange:h,onViewProfile:m,userRole:o,delegatedFunctions:x=[],delegatedOrgs:z=null,onRefreshProcess:R,onSubmit:P,onBack:k,onNavigate:C,onLogout:$,user:I}){const E=ee(),O=_=>t({...e,..._}),U=c?{background:"#f9f9f9"}:{},V=!c&&o==="Manager"&&Array.isArray(z),xe=V?l.filter(_=>(z||[]).includes(_.organization_name||_.name)):l,le=V&&(z||[]).length===1||!!I.custom_organization,L=fe(s,e.management).map(_=>({name:_.name,label:_.name1||_.name})),M=fe(r,e.department).map(_=>({name:_.name,label:_.department_name||_.name})),K=fe(i,e.branch).map(_=>({name:_.name,label:_.branch||_.name})),ne=fe(a,e.type).map(_=>({name:_.name,label:_.name1||_.name})),q=fe(d,e.status).map(_=>({name:_.name,label:_.name1||_.name})),me=fe(u,e.cycle).map(_=>({name:_.name,label:_.name1||_.name})),Ce=fr(f,y,"SB Employee",e.organization).map(_=>({name:_.name,label:_.full_name||_.name})),re=(_,Y)=>{const Z=[...e.cycle_logs||[]];Z[_]={...Z[_],...Y},O({cycle_logs:Z})},ze=()=>{O({cycle_logs:[...e.cycle_logs||[],{cycle:"",cycle_date:"",status:"Pass",actor:"",comment:""}]})},he=_=>{const Y=[...e.cycle_logs||[]];Y.splice(_,1),O({cycle_logs:Y})},H=(_,Y)=>{const Z=[...e.progress_indicators||[]];Z[_]={...Z[_],...Y},O({progress_indicators:Z})},J=()=>{O({progress_indicators:[...e.progress_indicators||[],{name1:"",type:"Nominal",unit:"",cycle:"",target:"",maximum:"",minimum:"",manager:"",order:"",actual_value:"",cycle_status:"",cycle_date:"",cycle_comment:"",status:""}]})},N=_=>{const Y=[...e.progress_indicators||[]];Y.splice(_,1),O({progress_indicators:Y})},oe=e.name?c?`${E.formTitle.viewProcess}${e.title||e.name}`:E.formTitle.editProcess:E.formTitle.newProcess,Wn=o!=="Manager"||e.actor===I.name||x.includes("update_process_status"),gt=e.name?n.jsxs("div",{style:{width:260,display:"flex",flexDirection:"column",gap:14},children:[n.jsx(c0,{processName:e.name,userRole:o||I.role||"Employee",onRefresh:R,canUpdateStatus:Wn}),n.jsx(Gi,{doctype:B.processes,docname:e.name,currentUserName:I.name}),n.jsx(Yi,{doctype:B.processes,docname:e.name,docCreation:e.creation,docOwner:e.owner})]}):void 0;return n.jsxs(Me,{title:oe,activePage:"processes",user:I,formStatus:p,buttonText:E.saveProcess,buttonColor:W.blue,viewMode:c,onEdit:v,darkMode:b,notifCount:g,onToggleDark:S,onCountChange:h,onViewProfile:m,rightPanel:gt,onSubmit:P,onBack:k,onNavigate:C,onLogout:$,children:[n.jsxs("div",{style:Mr,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.number}),n.jsx("input",{style:{...A,background:"#f9f9f9"},value:e.number||"",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[E.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.organization,onChange:_=>O({organization:_}),organizations:xe,disabled:c||le}),V&&n.jsx("div",{style:{fontSize:11,color:"#888",marginTop:4},children:(z||[]).length===0?"You have no delegated organization for Processes.":`Restricted to your delegated organization${(z||[]).length>1?"s":""}: ${(z||[]).join(", ")}`})]})]}),n.jsxs("div",{style:Mr,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.title}),n.jsx("input",{style:{...A,...U},value:e.title,disabled:c,onChange:_=>O({title:_.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.type}),n.jsx(ue,{value:e.type,onChange:_=>O({type:_}),items:ne,placeholder:E.field.selectType,disabled:c})]})]}),n.jsxs("div",{style:Tl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.management}),n.jsx(ue,{value:e.management,onChange:_=>O({management:_}),items:L,placeholder:E.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.department}),n.jsx(ue,{value:e.department,onChange:_=>O({department:_}),items:M,placeholder:E.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.section}),n.jsx("input",{style:{...A,...U},value:e.section_field||"",disabled:c,onChange:_=>O({section_field:_.target.value})})]})]}),n.jsxs("div",{style:Mr,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.branch}),n.jsx(ue,{value:e.branch,onChange:_=>O({branch:_}),items:K,placeholder:E.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[E.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({status:_}),items:q,placeholder:E.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:Tl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.chainLocation}),n.jsxs("select",{style:{...A,...U},value:e.chain_location||"",disabled:c,onChange:_=>O({chain_location:_.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Upstream",children:"Upstream"}),n.jsx("option",{value:"On-stream",children:"On-stream"}),n.jsx("option",{value:"Downstream",children:"Downstream"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.economyClass}),n.jsxs("select",{style:{...A,...U},value:e.economy_class||"",disabled:c,onChange:_=>O({economy_class:_.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Expenses",children:E.field.expenses}),n.jsx("option",{value:"Capital",children:E.field.capital}),n.jsx("option",{value:"Earn",children:E.field.earn}),n.jsx("option",{value:"Pay/Loss",children:E.field.payLoss})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.impactLevel}),n.jsxs("select",{style:{...A,...U},value:e.impact_level||"",disabled:c,onChange:_=>O({impact_level:_.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"High",children:E.field.high}),n.jsx("option",{value:"Normal",children:E.field.normal})]})]})]}),n.jsxs("div",{style:Tl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.entityScope}),n.jsxs("select",{style:{...A,...U},value:e.entity_scope||"",disabled:c,onChange:_=>O({entity_scope:_.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Upstream",children:E.field.upstream}),n.jsx("option",{value:"On-stream",children:E.field.onstream}),n.jsx("option",{value:"Downstream",children:E.field.downstream})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.hsesField}),n.jsx("input",{style:{...A,...U},value:e.hses_field||"",disabled:c,onChange:_=>O({hses_field:_.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({product_relation:_.target.checked?1:0})})," ",E.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:Tl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.kpiName}),n.jsx("input",{style:{...A,...U},value:e.kpi_name||"",disabled:c,onChange:_=>O({kpi_name:_.target.value})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.kpiType}),n.jsxs("select",{style:{...A,...U},value:e.kpi_type||"",disabled:c,onChange:_=>O({kpi_type:_.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Human",children:"Human"}),n.jsx("option",{value:"Substantial",children:"Substantial"}),n.jsx("option",{value:"System",children:"System"}),n.jsx("option",{value:"Value",children:"Value"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.kpiMeasure}),n.jsx("input",{style:{...A,...U},value:e.kpi_measure||"",disabled:c,onChange:_=>O({kpi_measure:_.target.value}),placeholder:"Unit of measure"})]})]})]}),n.jsxs("div",{style:Tl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.dateStart}),n.jsx(ye,{value:e.date_start,onChange:_=>O({date_start:_}),disabled:c,style:{...A,...U}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.dateEnd}),n.jsx(ye,{value:e.date_end,onChange:_=>O({date_end:_}),disabled:c,style:{...A,...U}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.cycleType}),n.jsxs("select",{style:{...A,...U},value:e.cycle_type||"",disabled:c,onChange:_=>O({cycle_type:_.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),n.jsx("option",{value:"Normal",children:"Normal"}),n.jsx("option",{value:"Long",children:"Long"})]})]})]}),e.cycle_type==="Long"&&n.jsxs("div",{style:{background:"#fff7ed",border:"1px solid #fed7aa",borderRadius:8,padding:14},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#c2410c",marginBottom:10},children:"Long Cycle Milestone Dates"}),n.jsxs("div",{style:Mr,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Milestone 1"}),n.jsx(ye,{value:e.long_cycle_date_1||"",onChange:_=>O({long_cycle_date_1:_}),disabled:c,style:{...A,...U}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Milestone 2"}),n.jsx(ye,{value:e.long_cycle_date_2||"",onChange:_=>O({long_cycle_date_2:_}),disabled:c,style:{...A,...U}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Milestone 3"}),n.jsx(ye,{value:e.long_cycle_date_3||"",onChange:_=>O({long_cycle_date_3:_}),disabled:c,style:{...A,...U}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:"Milestone 4"}),n.jsx(ye,{value:e.long_cycle_date_4||"",onChange:_=>O({long_cycle_date_4:_}),disabled:c,style:{...A,...U}})]})]})]}),n.jsxs("div",{style:{marginTop:24,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[n.jsx("div",{style:{...T,margin:0,fontSize:15},children:"Progress Indicators"}),!c&&n.jsx("button",{type:"button",onClick:J,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((_,Y)=>n.jsxs("tr",{style:{background:Y%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...A,...U,width:60},value:_.order??"",disabled:c,onChange:Z=>H(Y,{order:Z.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...A,...U},value:_.name1,disabled:c,onChange:Z=>H(Y,{name1:Z.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...A,...U},value:_.type,disabled:c,onChange:Z=>H(Y,{type:Z.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:{...A,...U,width:70},type:"text",value:_.unit??"",disabled:c,onChange:Z=>H(Y,{unit:Z.target.value}),placeholder:"e.g. °C, kg, %"})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...A,...U},value:_.cycle,disabled:c,onChange:Z=>H(Y,{cycle:Z.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...A,...U,width:80},value:_.target,disabled:c,onChange:Z=>H(Y,{target:Z.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...A,...U,width:80},value:_.minimum,disabled:c,onChange:Z=>H(Y,{minimum:Z.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...A,...U,width:80},value:_.maximum,disabled:c,onChange:Z=>H(Y,{maximum:Z.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...A,...U},value:_.manager,disabled:c,onChange:Z=>H(Y,{manager:Z.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...A,...U,width:90},type:"number",value:_.actual_value??"",disabled:c,onChange:Z=>H(Y,{actual_value:parseFloat(Z.target.value)||""})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...A,...U},value:_.cycle_status??"",disabled:c,onChange:Z=>H(Y,{cycle_status:Z.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(ye,{value:_.cycle_date||"",onChange:Z=>H(Y,{cycle_date:Z}),disabled:c,style:{...A,...U,width:110}})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...A,...U},value:_.cycle_comment??"",disabled:c,onChange:Z=>H(Y,{cycle_comment:Z.target.value})})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...A,...U},value:_.status??"",disabled:c,onChange:Z=>H(Y,{status:Z.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:()=>N(Y),style:{padding:"6px 10px",border:"1px solid #e74c3c",background:"white",color:"#e74c3c",borderRadius:6,cursor:"pointer"},children:"Remove"})})]},Y))]})]})})]}),n.jsxs("div",{style:{marginTop:28,borderTop:"1px solid #e9ecef",paddingTop:20},children:[n.jsx("div",{style:{...T,fontSize:15,marginBottom:14},children:"Cycle & Assignment"}),n.jsxs("div",{style:Tl,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.cycle}),n.jsx(ue,{value:e.cycle||"",onChange:_=>O({cycle:_}),items:me,placeholder:E.field.select,disabled:c})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.actor}),n.jsxs("select",{style:{...A,...U},value:e.actor||"",disabled:c,onChange:_=>O({actor:_.target.value}),children:[n.jsx("option",{value:"",children:E.field.select}),Ce.map(_=>n.jsx("option",{value:_.name,children:_.label},_.name))]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:E.field.costPerCycle}),n.jsx("input",{style:{...A,...U},type:"number",value:e.cost_per_cycle||"",disabled:c,onChange:_=>O({cost_per_cycle:parseFloat(_.target.value)||0}),placeholder:"0.00"})]})]}),n.jsxs("div",{style:{marginTop:12},children:[n.jsx("label",{style:T,children:E.field.escalationLevel}),n.jsx("input",{style:{...A,...U,maxWidth:120},type:"number",value:e.escalation_level||"",disabled:c,onChange:_=>O({escalation_level:parseInt(_.target.value)||0})})]})]}),n.jsxs("div",{style:{marginTop:28,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[n.jsx("div",{style:{...T,margin:0,fontSize:15},children:"Cycle History"}),!c&&n.jsx("button",{type:"button",onClick:ze,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((_,Y)=>n.jsxs("tr",{style:{background:Y%2===0?"white":"#fafafa"},children:[n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...A,...U},value:_.cycle||"",disabled:c,onChange:Z=>re(Y,{cycle:Z.target.value}),children:[n.jsx("option",{value:"",children:"-- Select --"}),me.map(Z=>n.jsx("option",{value:Z.name,children:Z.label},Z.name))]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx(ye,{value:_.cycle_date||"",onChange:Z=>re(Y,{cycle_date:Z}),disabled:c,style:{...A,...U,width:130}})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsxs("select",{style:{...A,...U},value:_.status,disabled:c,onChange:Z=>re(Y,{status:Z.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:{...A,...U},value:_.actor||"",disabled:c,onChange:Z=>re(Y,{actor:Z.target.value}),children:[n.jsx("option",{value:"",children:"-- Select --"}),Ce.map(Z=>n.jsx("option",{value:Z.name,children:Z.label},Z.name))]})}),n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("input",{style:{...A,...U},value:_.comment||"",disabled:c,onChange:Z=>re(Y,{comment:Z.target.value})})}),!c&&n.jsx("td",{style:{padding:"10px 12px"},children:n.jsx("button",{type:"button",onClick:()=>he(Y),style:{padding:"6px 10px",border:"1px solid #e74c3c",background:"white",color:"#e74c3c",borderRadius:6,cursor:"pointer"},children:"Remove"})})]},Y))]})]})})]}),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:E.field.auditorComment}),n.jsx("textarea",{style:{...A,height:80,resize:"vertical",...c?{background:"#f9f9f9"}:{}},value:e.auditor_comment||"",disabled:c,onChange:_=>O({auditor_comment:_.target.value}),placeholder:E.field.commentPlaceholder})]})]})}const u0={Admin:"#7c3aed",Auditor:"#d97706",Owner:"#0369a1",XAuditor:"#0f766e",Manager:"#2563eb",Employee:"#6b7280",Chairman:"#0f766e"};function p0({user:e,profileUser:t,darkMode:l,canModify:s,onBack:r,organizations:i=[],managements:a=[],departments:d=[],branches:u=[]}){const f=t||{},y=!!s&&e.role==="Admin",[p,c]=j.useState({first_name:f.first_name||"",middle_name:f.middle_name||"",last_name:f.last_name||"",mobile_no:f.mobile_no||"",custom_organization:f.custom_organization||"",custom_management:f.custom_management||"",custom_department:f.custom_department||"",custom_branch:f.custom_branch||"",custom_number:f.custom_number||"",custom_category:f.custom_category||""}),[v,b]=j.useState(""),[g,S]=j.useState(!1),[h,m]=j.useState({new:"",confirm:""}),[o,x]=j.useState(""),z=f.email||f.name||"",R=[p.first_name,p.middle_name,p.last_name].filter(Boolean).join(" ")||f.full_name||"",P=f.username||f.name||"",k=p.custom_category||"",C=f.enabled===0?"Inactive":"Active",$=u0[e.role]||"#6b7280",I=l,E=I?"#0f172a":"#f0f2f5",O=I?"#1e293b":"white",U=I?"#2d3748":"#e5e7eb",V=I?"#e2e8f0":"#1a2332",xe=I?"#94a3b8":"#6b7280",le=I?"#374151":"white",L=I?"#2d3748":"#f9fafb",M={width:"100%",padding:"9px 12px",borderRadius:8,border:`1px solid ${U}`,fontSize:13,background:le,color:V,fontFamily:"inherit",outline:"none"},K={...M,background:L,color:xe},ne={...M,cursor:"pointer"},q={fontSize:12,fontWeight:600,color:xe,marginBottom:5,display:"block"},me={display:"grid",gridTemplateColumns:"1fr 1fr",gap:14},Ce={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:14},re=async()=>{if(s){b("saving");try{await Ti("User",f.name,{first_name:p.first_name,middle_name:p.middle_name,last_name:p.last_name,mobile_no:p.mobile_no,custom_organization:p.custom_organization,custom_management:p.custom_management,custom_department:p.custom_department,custom_branch:p.custom_branch,custom_number:p.custom_number,custom_category:p.custom_category}),b("saved"),setTimeout(()=>b(""),2e3)}catch{b("error"),setTimeout(()=>b(""),3e3)}}},ze=async()=>{if(!h.new){x("Enter a new password");return}if(h.new!==h.confirm){x("Passwords do not match");return}x("saving");try{await Bf(f.name,h.new),x("done"),m({new:"",confirm:""}),setTimeout(()=>{x(""),S(!1)},2e3)}catch{x("error")}},he=({title:H,icon:J,children:N})=>n.jsxs("div",{style:{background:O,borderRadius:12,padding:22,border:`1px solid ${U}`,boxShadow:`0 1px 4px rgba(0,0,0,${I?.3:.06})`},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,paddingBottom:14,borderBottom:`1px solid ${U}`},children:[J,n.jsx("span",{style:{fontSize:14,fontWeight:700,color:V},children:H})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:N})]});return n.jsxs("div",{style:{background:E,minHeight:"100%",padding:"0 0 32px"},children:[n.jsxs("div",{style:{background:O,borderBottom:`1px solid ${U}`,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:V,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:R||z}),n.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.75)",textAlign:"center"},children:z})]}),n.jsx("div",{style:{background:O},children:[{icon:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:$,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:$,strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),n.jsx("circle",{cx:"9",cy:"7",r:"4"}),n.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),n.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),label:"Role Profile",value:k||"—"},{icon:n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:C==="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:C,valueColor:C==="Active"?"#16a34a":"#dc2626"},{icon:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:$,strokeWidth:"2",strokeLinecap:"round",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),n.jsx("path",{d:"m2 7 10 7 10-7"})]}),label:"Email",value:z},{icon:n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:$,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:J,value:N,valueColor:oe})=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 16px",borderBottom:`1px solid ${U}`},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:xe,marginBottom:1},children:J}),n.jsx("div",{style:{fontSize:13,fontWeight:600,color:oe||V,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N})]})]},J))})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:18},children:[n.jsxs(he,{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:me,children:[n.jsxs("div",{children:[n.jsxs("label",{style:q,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:{...K,paddingLeft:32},value:z,readOnly:!0})]})]}),n.jsxs("div",{children:[n.jsxs("label",{style:q,children:["Full Name ",n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Auto-generated)"})]}),n.jsx("input",{style:K,value:R,readOnly:!0})]})]}),n.jsxs("div",{style:Ce,children:[n.jsxs("div",{children:[n.jsxs("label",{style:q,children:["First Name ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{style:s?M:K,value:p.first_name,readOnly:!s,onChange:H=>c(J=>({...J,first_name:H.target.value})),placeholder:"First name"})]}),n.jsxs("div",{children:[n.jsx("label",{style:q,children:"Middle Name"}),n.jsx("input",{style:s?M:K,value:p.middle_name,readOnly:!s,onChange:H=>c(J=>({...J,middle_name:H.target.value})),placeholder:"Middle name"})]}),n.jsxs("div",{children:[n.jsx("label",{style:q,children:"Last Name"}),n.jsx("input",{style:s?M:K,value:p.last_name,readOnly:!s,onChange:H=>c(J=>({...J,last_name:H.target.value})),placeholder:"Last name"})]})]}),n.jsxs("div",{style:me,children:[n.jsxs("div",{children:[n.jsx("label",{style:q,children:"Phone Number"}),n.jsx("input",{style:s?M:K,value:p.mobile_no,readOnly:!s,onChange:H=>c(J=>({...J,mobile_no:H.target.value})),placeholder:"Phone number"})]}),n.jsxs("div",{children:[n.jsx("label",{style:q,children:"User ID No"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx("input",{style:{...K,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:q,children:["Category ",!y&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),y?n.jsxs("select",{style:ne,value:p.custom_category,onChange:H=>c(J=>({...J,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:K,value:k||"—",readOnly:!0})]})]}),n.jsxs(he,{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:me,children:[n.jsxs("div",{children:[n.jsxs("label",{style:q,children:["Organization ",!y&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),y?n.jsxs("select",{style:ne,value:p.custom_organization,onChange:H=>c(J=>({...J,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:K,value:p.custom_organization||"—",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:q,children:["Management ",!y&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),y?n.jsxs("select",{style:ne,value:p.custom_management,onChange:H=>c(J=>({...J,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:K,value:p.custom_management||"—",readOnly:!0})]})]}),n.jsxs("div",{style:me,children:[n.jsxs("div",{children:[n.jsxs("label",{style:q,children:["Department ",!y&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),y?n.jsxs("select",{style:ne,value:p.custom_department,onChange:H=>c(J=>({...J,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:K,value:p.custom_department||"—",readOnly:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:q,children:["Branch ",!y&&n.jsx("span",{style:{fontSize:10,fontWeight:400},children:"(Admin only)"})]}),y?n.jsxs("select",{style:ne,value:p.custom_branch,onChange:H=>c(J=>({...J,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:K,value:p.custom_branch||"—",readOnly:!0})]})]})]}),n.jsxs("div",{style:{background:O,borderRadius:12,padding:22,border:`1px solid ${U}`,boxShadow:`0 1px 4px rgba(0,0,0,${I?.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:V},children:"Change Password"})]}),s&&n.jsx("button",{onClick:()=>{S(H=>!H),x("")},style:{fontSize:13,color:"#3b82f6",background:"none",border:"none",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:g?"Cancel":"Change Password"})]}),g&&n.jsxs("div",{style:{marginTop:18,display:"flex",flexDirection:"column",gap:12},children:[n.jsxs("div",{style:Ce,children:[n.jsxs("div",{children:[n.jsxs("label",{style:q,children:["New Password ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{type:"password",style:M,value:h.new,onChange:H=>m(J=>({...J,new:H.target.value})),placeholder:"New password"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:q,children:["Confirm Password ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("input",{type:"password",style:M,value:h.confirm,onChange:H=>m(J=>({...J,confirm:H.target.value})),placeholder:"Confirm password"})]}),n.jsx("div",{style:{display:"flex",alignItems:"flex-end"},children:n.jsx("button",{onClick:ze,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 Ae({label:e,val:t,color:l}){return n.jsxs("div",{style:{background:"white",borderRadius:8,padding:"8px 16px",flex:1,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",borderTop:`3px solid ${l}`,minWidth:0,display:"flex",alignItems:"baseline",gap:8},children:[n.jsx("div",{style:{fontSize:18,fontWeight:700,color:l},children:t}),n.jsx("div",{style:{fontSize:12,color:"#999"},children:e})]})}const Ff={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151",boxSizing:"border-box"},f0={...Ff,cursor:"pointer"};function ct({filters:e,defaultOpen:t=!1}){const[l,s]=j.useState(t);return n.jsxs("div",{style:{background:"white",borderRadius:12,overflow:"hidden",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:16},children:[n.jsxs("div",{onClick:()=>s(r=>!r),style:{background:"linear-gradient(90deg, #3b82f6 0%, #2563eb 100%)",padding:"12px 18px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",userSelect:"none"},children:[n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",children:l?n.jsx("polyline",{points:"18,15 12,9 6,15"}):n.jsx("polyline",{points:"6,9 12,15 18,9"})}),n.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),n.jsx("span",{style:{color:"white",fontWeight:700,fontSize:14},children:"Filters"})]}),l&&n.jsx("div",{style:{padding:"18px 20px"},children:n.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${Math.min(e.length,4)}, 1fr)`,gap:14},children:e.map((r,i)=>n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:r.label}),r.type==="search"?n.jsx("input",{style:Ff,placeholder:r.placeholder,value:r.value,onChange:a=>r.onChange(a.target.value)}):n.jsx("select",{style:f0,value:r.value,onChange:a=>r.onChange(a.target.value),children:r.options.map(a=>n.jsx("option",{value:a.value,children:a.label},a.value))})]},i))})})]})}function h0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function g0({organizations:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=ee(),[a,d]=j.useState(""),[u,f]=j.useState("all"),[y,p]=j.useState("all"),c={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},v=j.useMemo(()=>e.filter(h=>{const m=[h.organization_name,h.city].filter(Boolean).join(" ").toLowerCase();return!(a&&!m.includes(a.toLowerCase())||u!=="all"&&h.type!==u||y!=="all"&&(h.is_active?"Active":"Inactive")!==y)}),[e,a,u,y]),[b,g]=j.useState(1);j.useEffect(()=>{g(1)},[a,u,y]);const S=v.slice((b-1)*se,b*se);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(Ae,{label:"Total",val:v.length,color:"#1a2332"}),n.jsx(Ae,{label:"Active",val:v.filter(h=>h.is_active).length,color:W.green}),n.jsx(Ae,{label:"Government",val:v.filter(h=>h.type==="Government").length,color:W.blue}),n.jsx(Ae,{label:"Private",val:v.filter(h=>h.type==="Private").length,color:W.orange})]}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Name or city…"},{type:"select",label:i.col.type,value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Government",label:"Government"},{value:"Private",label:"Private"}]},{type:"select",label:"Status",value:y,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:c,children:i.col.name}),n.jsx("th",{style:c,children:i.col.type}),n.jsx("th",{style:c,children:i.col.city}),n.jsx("th",{style:c,children:i.field.creationDate}),n.jsx("th",{style:c,children:i.col.status}),n.jsx("th",{style:c,children:i.col.actions})]})}),n.jsx("tbody",{children:v.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):S.map((h,m)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(h),style:{borderTop:"1px solid #f0f0f0",background:m%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:h.organization_name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.type||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:h.city||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:h0(h.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:Ln(h.is_active?i.field.statusActive:i.field.statusInactive,h.is_active?W.green:W.gray)}),n.jsx("td",{style:{padding:"8px 14px"},onClick:o=>o.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(h),onEdit:t&&s?()=>s(h):void 0,onDelete:t&&r?()=>r(h.name):void 0})})]},h.name))})]})}),n.jsx(Fe,{page:b,total:v.length,onPageChange:g})]})}const Zt=e=>({background:e?"#f9f9f9":void 0});function x0({orgForm:e,setOrgForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=ee(),S=e.name?s&&e.organization_name||g.formTitle.editOrg:g.formTitle.newOrg;return n.jsxs(Me,{title:S,activePage:"organizations",user:b,formStatus:l,buttonText:g.saveOrg,buttonColor:W.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:T,children:[g.field.orgName," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{type:"text",style:{...A,...Zt(s||!!e.name)},value:e.organization_name,disabled:s||!!e.name,required:!0,onChange:h=>t({...e,organization_name:h.target.value})})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[g.field.orgAcronym," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{type:"text",style:{...A,...Zt(s||!!e.name)},value:e.acronym||"",disabled:s||!!e.name,required:!0,onChange:h=>t({...e,acronym:h.target.value})})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.organizationType}),n.jsxs("select",{style:{...A,...Zt(s)},value:e.type,disabled:s,onChange:h=>t({...e,type:h.target.value}),children:[n.jsx("option",{children:"Government"}),n.jsx("option",{children:"Private"}),n.jsx("option",{children:"Non-Profit"})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.orgCity}),n.jsx("input",{type:"text",style:{...A,...Zt(s)},value:e.city,disabled:s,onChange:h=>t({...e,city:h.target.value})})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.contactEmail}),n.jsx("input",{type:"email",style:{...A,...Zt(s)},value:e.contact_email,disabled:s,onChange:h=>t({...e,contact_email:h.target.value})})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(ye,{value:e.creation_date||"",onChange:h=>t({...e,creation_date:h}),disabled:s,style:{...A,...Zt(s)}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...A,...Zt(s)},value:e.is_active?"Active":"Inactive",disabled:s,onChange:h=>t({...e,is_active:h.target.value==="Active"?1:0}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.incidentTriageWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...A,...Zt(s)},value:e.incident_triage_window_days??3,disabled:s,onChange:h=>t({...e,incident_triage_window_days:parseInt(h.target.value)||3})}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:"Days after creation before an untriaged Incident is flagged overdue"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.incidentResolutionWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...A,...Zt(s)},value:e.incident_resolution_window_days??5,disabled:s,onChange:h=>t({...e,incident_resolution_window_days:parseInt(h.target.value)||5})}),n.jsx("span",{style:{fontSize:11,color:"#888"},children:"Days without an update before an in-progress Incident is flagged overdue"})]})]})]})}function m0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function y0({managements:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=ee(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*se,c*se);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ae,{label:"Total",val:p.length,color:W.blue})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:m0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function v0({form:e,setForm:t,organizations:l,formStatus:s,viewMode:r,onEdit:i,darkMode:a,notifCount:d,onToggleDark:u,onCountChange:f,onViewProfile:y,onSubmit:p,onBack:c,onNavigate:v,onLogout:b,user:g}){const S=ee(),h=x=>t(z=>({...z,...x})),m=r?{background:"#f9f9f9"}:{},o=e.name?r?`${S.formTitle.editMgmt}: ${e.name1||e.name}`:S.formTitle.editMgmt:S.formTitle.newMgmt;return n.jsxs(Me,{title:o,activePage:"managements",user:g,formStatus:s,buttonText:S.saveMgmt,buttonColor:W.blue,viewMode:r,onEdit:i,darkMode:a,notifCount:d,onToggleDark:u,onCountChange:f,onViewProfile:y,onSubmit:p,onBack:c,onNavigate:v,onLogout:b,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.organization,onChange:x=>h({organization:x}),organizations:l,disabled:r||!!g.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[S.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...A,...m},value:e.name1,disabled:r||!!e.name,onChange:x=>h({name1:x.target.value}),placeholder:"Management name",required:!0})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.creationDate}),n.jsx(ye,{value:e.creation_date||"",onChange:x=>h({creation_date:x}),disabled:r,style:{...A,...m}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.status}),n.jsxs("select",{style:{...A,...m},value:e.status||"Active",disabled:r,onChange:x=>h({status:x.target.value}),children:[n.jsx("option",{value:"Active",children:S.field.statusActive}),n.jsx("option",{value:"Inactive",children:S.field.statusInactive})]})]})]})]})}function j0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function b0({departments:e,managements:t,canModify:l,onView:s,onEdit:r,onDelete:i}){const a=ee(),[d,u]=j.useState(""),[f,y]=j.useState(""),[p,c]=j.useState("all"),v=o=>{var x;return((x=t.find(z=>z.name===o))==null?void 0:x.name1)||o||"—"},b={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},g=j.useMemo(()=>e.filter(o=>{const x=(o.department_name||o.name||"").toLowerCase();return!(d&&!x.includes(d.toLowerCase())||f&&o.custom_management!==f||p!=="all"&&(o.custom_status||"Active")!==p)}),[e,d,f,p]),[S,h]=j.useState(1);j.useEffect(()=>{h(1)},[d,f,p]);const m=g.slice((S-1)*se,S*se);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ae,{label:"Total",val:g.length,color:W.teal})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:d,onChange:u,placeholder:"Search by name…"},{type:"select",label:a.col.management,value:f,onChange:y,options:[{value:"",label:"All Managements"},...t.map(o=>({value:o.name,label:o.name1||o.name}))]},{type:"select",label:"Status",value:p,onChange:c,options:[{value:"all",label:"All"},{value:"Active",label:a.field.statusActive},{value:"Inactive",label:a.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:b,children:a.col.name}),n.jsx("th",{style:b,children:a.col.management}),n.jsx("th",{style:b,children:a.field.creationDate}),n.jsx("th",{style:b,children:a.field.status}),n.jsx("th",{style:b,children:a.col.actions})]})}),n.jsx("tbody",{children:g.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):m.map((o,x)=>n.jsxs("tr",{onClick:()=>s==null?void 0:s(o),style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.department_name||o.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:v(o.custom_management)}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:j0(o.custom_creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:o.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:o.custom_status==="Inactive"?a.field.statusInactive:a.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:z=>z.stopPropagation(),children:n.jsx(Je,{onView:()=>s==null?void 0:s(o),onEdit:l&&r?()=>r(o):void 0,onDelete:l&&i?()=>i(o.name):void 0})})]},o.name))})]})}),n.jsx(Fe,{page:S,total:g.length,onPageChange:h})]})}const S0={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20};function w0({form:e,setForm:t,organizations:l,managements:s,formStatus:r,viewMode:i,onEdit:a,darkMode:d,notifCount:u,onToggleDark:f,onCountChange:y,onViewProfile:p,onSubmit:c,onBack:v,onNavigate:b,onLogout:g,user:S}){const h=ee(),m=R=>t(P=>({...P,...R})),o=i?{background:"#f9f9f9"}:{},x=e.name?i?`${h.formTitle.editDept}: ${e.department_name||e.name}`:h.formTitle.editDept:h.formTitle.newDept,z=fe(s,e.custom_management).map(R=>({name:R.name,label:R.name1||R.name}));return n.jsxs(Me,{title:x,activePage:"departments",user:S,formStatus:r,buttonText:h.saveDept,buttonColor:W.teal,viewMode:i,onEdit:a,darkMode:d,notifCount:u,onToggleDark:f,onCountChange:y,onViewProfile:p,onSubmit:c,onBack:v,onNavigate:b,onLogout:g,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[h.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.custom_organization,onChange:R=>m({custom_organization:R}),organizations:l,disabled:i||!!S.custom_organization})]}),n.jsxs("div",{style:S0,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[h.field.department," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...A,...o},value:e.department_name,disabled:i||!!e.name,onChange:R=>m({department_name:R.target.value}),placeholder:"Department name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.management}),n.jsx(ue,{value:e.custom_management,onChange:R=>m({custom_management:R}),items:z,placeholder:h.field.select,disabled:i})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.creationDate}),n.jsx(ye,{value:e.custom_creation_date||"",onChange:R=>m({custom_creation_date:R}),disabled:i,style:{...A,...o}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:h.field.status}),n.jsxs("select",{style:{...A,...o},value:e.custom_status||"Active",disabled:i,onChange:R=>m({custom_status:R.target.value}),children:[n.jsx("option",{value:"Active",children:h.field.statusActive}),n.jsx("option",{value:"Inactive",children:h.field.statusInactive})]})]})]})]})}function k0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function _0({branches:e,managements:t,departments:l,canModify:s,onView:r,onEdit:i,onDelete:a}){const d=ee(),[u,f]=j.useState(""),[y,p]=j.useState(""),[c,v]=j.useState(""),[b,g]=j.useState("all"),S=P=>{var k;return((k=t.find(C=>C.name===P))==null?void 0:k.name1)||P||"—"},h=P=>{var k;return((k=l.find(C=>C.name===P))==null?void 0:k.department_name)||P||"—"},m={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},o=j.useMemo(()=>e.filter(P=>{const k=(P.branch||P.name||"").toLowerCase();return!(u&&!k.includes(u.toLowerCase())||y&&P.management!==y||c&&P.department!==c||b!=="all"&&(P.custom_status||"Active")!==b)}),[e,u,y,c,b]),[x,z]=j.useState(1);j.useEffect(()=>{z(1)},[u,y,c,b]);const R=o.slice((x-1)*se,x*se);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ae,{label:"Total",val:o.length,color:W.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:b,onChange:g,options:[{value:"all",label:"All"},{value:"Active",label:d.field.statusActive},{value:"Inactive",label:d.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:m,children:d.col.branch}),n.jsx("th",{style:m,children:d.col.management}),n.jsx("th",{style:m,children:d.col.department}),n.jsx("th",{style:m,children:d.field.creationDate}),n.jsx("th",{style:m,children:d.field.status}),n.jsx("th",{style:m,children:d.col.actions})]})}),n.jsx("tbody",{children:o.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:d.noData})}):R.map((P,k)=>n.jsxs("tr",{onClick:()=>r==null?void 0:r(P),style:{borderTop:"1px solid #f0f0f0",background:k%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:P.branch||P.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:S(P.management)}),n.jsx("td",{style:{padding:"10px 14px"},children:h(P.department)}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:k0(P.custom_creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:P.custom_status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:P.custom_status==="Inactive"?d.field.statusInactive:d.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:C=>C.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:x,total:o.length,onPageChange:z})]})}const C0={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20};function z0({form:e,setForm:t,organizations:l,managements:s,departments:r,formStatus:i,viewMode:a,onEdit:d,darkMode:u,notifCount:f,onToggleDark:y,onCountChange:p,onViewProfile:c,onSubmit:v,onBack:b,onNavigate:g,onLogout:S,user:h}){const m=ee(),o=k=>t(C=>({...C,...k})),x=a?{background:"#f9f9f9"}:{},z=e.name?a?`${m.formTitle.editBranch}: ${e.branch||e.name}`:m.formTitle.editBranch:m.formTitle.newBranch,R=fe(s,e.management).map(k=>({name:k.name,label:k.name1||k.name})),P=fe(r,e.department).map(k=>({name:k.name,label:k.department_name||k.name}));return n.jsxs(Me,{title:z,activePage:"branches",user:h,formStatus:i,buttonText:m.saveBranch,buttonColor:W.purple,viewMode:a,onEdit:d,darkMode:u,notifCount:f,onToggleDark:y,onCountChange:p,onViewProfile:c,onSubmit:v,onBack:b,onNavigate:g,onLogout:S,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[m.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.organization,onChange:k=>o({organization:k}),organizations:l,disabled:a||!!h.custom_organization})]}),n.jsxs("div",{style:C0,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[m.field.branch," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...A,...x},value:e.branch,disabled:a||!!e.name,onChange:k=>o({branch:k.target.value}),placeholder:"Branch name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:m.field.management}),n.jsx(ue,{value:e.management,onChange:k=>o({management:k}),items:R,placeholder:m.field.select,disabled:a})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:m.field.department}),n.jsx(ue,{value:e.department,onChange:k=>o({department:k}),items:P,placeholder:m.field.select,disabled:a})]})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:m.field.creationDate}),n.jsx(ye,{value:e.custom_creation_date||"",onChange:k=>o({custom_creation_date:k}),disabled:a,style:{...A,...x}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:m.field.status}),n.jsxs("select",{style:{...A,...x},value:e.custom_status||"Active",disabled:a,onChange:k=>o({custom_status:k.target.value}),children:[n.jsx("option",{value:"Active",children:m.field.statusActive}),n.jsx("option",{value:"Inactive",children:m.field.statusInactive})]})]})]})]})}function T0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function P0({incidentTypes:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=ee(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*se,c*se);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ae,{label:"Total",val:p.length,color:W.red})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:T0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function I0({form:e,setForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=ee(),S=o=>t(x=>({...x,...o})),h=s?{background:"#f9f9f9"}:{},m=e.name?s?`Incident Type: ${e.name1||e.name}`:"Edit Incident Type":"New Incident Type";return n.jsxs(Me,{title:m,activePage:"incident-types",user:b,formStatus:l,buttonText:g.saveName,buttonColor:W.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:T,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...A,...h},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Incident type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(ye,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...A,...h}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...A,...h},value:e.status||"Active",disabled:s,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}function E0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function A0({ideaTypes:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=ee(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*se,c*se);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ae,{label:"Total",val:p.length,color:W.teal})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:E0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function R0({form:e,setForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=ee(),S=o=>t(x=>({...x,...o})),h=s?{background:"#f9f9f9"}:{},m=e.name?s?`Idea Type: ${e.name1||e.name}`:"Edit Idea Type":"New Idea Type";return n.jsxs(Me,{title:m,activePage:"idea-types",user:b,formStatus:l,buttonText:g.saveName,buttonColor:W.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:T,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...A,...h},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Idea type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(ye,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...A,...h}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...A,...h},value:e.status||"Active",disabled:s,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}function L0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function O0({orderTypes:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=ee(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*se,c*se);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ae,{label:"Total",val:p.length,color:W.purple})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:L0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function D0({form:e,setForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=ee(),S=o=>t(x=>({...x,...o})),h=s?{background:"#f9f9f9"}:{},m=e.name?s?`Order Type: ${e.name1||e.name}`:"Edit Order Type":"New Order Type";return n.jsxs(Me,{title:m,activePage:"order-types",user:b,formStatus:l,buttonText:g.saveName,buttonColor:W.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:T,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...A,...h},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Order type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(ye,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...A,...h}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...A,...h},value:e.status||"Active",disabled:s,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}function N0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function W0({processTypes:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=ee(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*se,c*se);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ae,{label:"Total",val:p.length,color:W.blue})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:N0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function B0({form:e,setForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=ee(),S=o=>t(x=>({...x,...o})),h=s?{background:"#f9f9f9"}:{},m=e.name?s?`Process Type: ${e.name1||e.name}`:"Edit Process Type":"New Process Type";return n.jsxs(Me,{title:m,activePage:"process-types",user:b,formStatus:l,buttonText:g.saveName,buttonColor:W.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:T,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...A,...h},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Process type name",required:!0})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(ye,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...A,...h}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...A,...h},value:e.status||"Active",disabled:s,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}function $0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function U0({incidentStatuses:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=ee(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*se,c*se);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ae,{label:"Total",val:p.length,color:W.red})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.notifyManager}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:$0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function F0({form:e,setForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=ee(),S=o=>t(x=>({...x,...o})),h=s?{background:"#f9f9f9"}:{},m=e.name?s?`Incident Status: ${e.name1||e.name}`:"Edit Incident Status":"New Incident Status";return n.jsxs(Me,{title:m,activePage:"incident-statuses",user:b,formStatus:l,buttonText:g.saveName,buttonColor:W.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:T,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...A,...h},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Incident status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:s,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:ds}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:s?"default":"pointer"},children:g.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(ye,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...A,...h}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...A,...h},value:e.status||"Active",disabled:s,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}function M0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function H0({ideaStatuses:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=ee(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*se,c*se);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ae,{label:"Total",val:p.length,color:W.teal})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.notifyManager}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:M0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function K0({form:e,setForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=ee(),S=o=>t(x=>({...x,...o})),h=s?{background:"#f9f9f9"}:{},m=e.name?s?`Idea Status: ${e.name1||e.name}`:"Edit Idea Status":"New Idea Status";return n.jsxs(Me,{title:m,activePage:"idea-statuses",user:b,formStatus:l,buttonText:g.saveName,buttonColor:W.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:T,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...A,...h},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Idea status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:s,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:ds}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:s?"default":"pointer"},children:g.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(ye,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...A,...h}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...A,...h},value:e.status||"Active",disabled:s,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}function Q0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function G0({orderStatuses:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=ee(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*se,c*se);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ae,{label:"Total",val:p.length,color:W.purple})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.notifyManager}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:Q0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function Y0({form:e,setForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=ee(),S=o=>t(x=>({...x,...o})),h=s?{background:"#f9f9f9"}:{},m=e.name?s?`Order Status: ${e.name1||e.name}`:"Edit Order Status":"New Order Status";return n.jsxs(Me,{title:m,activePage:"order-statuses",user:b,formStatus:l,buttonText:g.saveName,buttonColor:W.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:T,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...A,...h},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Order status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:s,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:ds}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:s?"default":"pointer"},children:g.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(ye,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...A,...h}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...A,...h},value:e.status||"Active",disabled:s,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}function X0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function q0({processStatuses:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=ee(),[a,d]=j.useState(""),[u,f]=j.useState("all"),y={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},p=j.useMemo(()=>e.filter(g=>{const S=(g.name1||g.name||"").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u!=="all"&&(g.status||"Active")!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*se,c*se);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ae,{label:"Total",val:p.length,color:W.blue})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:"Status",value:u,onChange:f,options:[{value:"all",label:"All"},{value:"Active",label:i.field.statusActive},{value:"Inactive",label:i.field.statusInactive}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:y,children:i.col.name}),n.jsx("th",{style:y,children:i.field.notifyManager}),n.jsx("th",{style:y,children:i.field.creationDate}),n.jsx("th",{style:y,children:i.field.status}),n.jsx("th",{style:y,children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.name1||g.name||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.notify_manager?i.field.statusActive:"—"}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:X0(g.creation_date)}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{color:g.status==="Inactive"?"#e74c3c":"#16a34a",fontWeight:600},children:g.status==="Inactive"?i.field.statusInactive:i.field.statusActive})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}function J0({form:e,setForm:t,formStatus:l,viewMode:s,onEdit:r,darkMode:i,notifCount:a,onToggleDark:d,onCountChange:u,onViewProfile:f,onSubmit:y,onBack:p,onNavigate:c,onLogout:v,user:b}){const g=ee(),S=o=>t(x=>({...x,...o})),h=s?{background:"#f9f9f9"}:{},m=e.name?s?`Process Status: ${e.name1||e.name}`:"Edit Process Status":"New Process Status";return n.jsxs(Me,{title:m,activePage:"process-statuses",user:b,formStatus:l,buttonText:g.saveName,buttonColor:W.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:T,children:[g.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...A,...h},value:e.name1,disabled:s||!!e.name,onChange:o=>S({name1:o.target.value}),placeholder:"Process status name",required:!0})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8},children:[n.jsx("input",{type:"checkbox",id:"notify_manager",checked:!!e.notify_manager,disabled:s,onChange:o=>S({notify_manager:o.target.checked?1:0}),style:ds}),n.jsx("label",{htmlFor:"notify_manager",style:{fontSize:13,cursor:s?"default":"pointer"},children:g.field.notifyManager})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.creationDate}),n.jsx(ye,{value:e.creation_date||"",onChange:o=>S({creation_date:o}),disabled:s,style:{...A,...h}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:g.field.status}),n.jsxs("select",{style:{...A,...h},value:e.status||"Active",disabled:s,onChange:o=>S({status:o.target.value}),children:[n.jsx("option",{value:"Active",children:g.field.statusActive}),n.jsx("option",{value:"Inactive",children:g.field.statusInactive})]})]})]})}const Z0={Admin:"#7c3aed",Chairman:"#0f766e",Auditor:"#d97706","X-Auditor":"#8b5cf6",Manager:"#2563eb",Employee:"#6b7280"};function V0(e){if(!e)return"—";const t=new Date(e);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function e1({users:e,canModify:t,onView:l,onEdit:s,onDisable:r}){const i=ee(),[a,d]=j.useState(!1),[u,f]=j.useState(""),[y,p]=j.useState(""),[c,v]=j.useState(""),[b,g]=j.useState("active"),[S,h]=j.useState(1),[m,o]=j.useState(null),[x,z]=j.useState(""),[R,P]=j.useState("idle"),[k,C]=j.useState(null),$=async()=>{if(!(!m||!x.trim())){P("loading");try{await Bf(m.name,x.trim()),P("success"),setTimeout(()=>{o(null),z(""),P("idle")},1200)}catch{P("error")}}},I=async L=>{if(window.confirm(i.users.disableConfirm)){C(L);try{await(r==null?void 0:r(L))}finally{C(null)}}},E=e.filter(L=>{if(b==="active"&&(L.enabled===0||L.enabled==="0")||b==="inactive"&&L.enabled!==0&&L.enabled!=="0")return!1;const M=L.custom_category||"";if(c&&M!==c)return!1;const K=L.custom_organization||"";if(y&&!K.toLowerCase().includes(y.toLowerCase()))return!1;if(u){const ne=u.toLowerCase();if(![L.full_name,L.email,L.name,L.username,L.mobile_no].join(" ").toLowerCase().includes(ne))return!1}return!0}),O=[...new Set(e.map(L=>L.custom_organization).filter(Boolean))],U=["Admin","Chairman","Auditor","X-Auditor","Manager","Employee"];j.useEffect(()=>{h(1)},[u,y,c,b]);const V=E.slice((S-1)*se,S*se),xe={padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"white",width:"100%",fontFamily:"inherit",outline:"none",color:"#374151"},le={...xe,cursor:"pointer"};return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0,flex:1},children:[n.jsxs("div",{style:{fontSize:13,color:"#6b7280",marginBottom:16},children:["Total: ",E.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:xe,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"}),O.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"}),U.map(L=>n.jsx("option",{value:L,children:L},L))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#9ca3af",marginBottom:5,textTransform:"uppercase",letterSpacing:.5},children:"Status"}),n.jsxs("select",{style:le,value:b,onChange:L=>g(L.target.value),children:[n.jsx("option",{value:"all",children:"All"}),n.jsx("option",{value:"active",children:"Active"}),n.jsx("option",{value:"inactive",children:"Inactive"})]})]})]})})]}),n.jsx("div",{style:{background:"white",borderRadius:12,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa",borderBottom:"2px solid #f0f0f0"},children:[{label:"Category",w:100},{label:"Number",w:80},{label:"Full Name",w:140},{label:"Username",w:120},{label:"Email Address",w:180},{label:"Phone Number",w:120},{label:"Organization",w:130},{label:"Management",w:120},{label:"Department",w:120},{label:"Branch",w:100},{label:"Since",w:90},{label:"Status",w:80},{label:"Tools",w:200}].map(({label:L,w:M})=>n.jsx("th",{style:{padding:"11px 14px",textAlign:"left",color:"#6b7280",fontSize:11,fontWeight:700,whiteSpace:"nowrap",minWidth:M,letterSpacing:.3,textTransform:"uppercase"},children:L},L))})}),n.jsx("tbody",{children:E.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"})}):V.map((L,M)=>{const K=L.custom_category||"",ne=Z0[K]||"#6b7280";return n.jsxs("tr",{onClick:()=>l==null?void 0:l(L),style:{borderBottom:"1px solid #f3f4f6",background:M%2===0?"white":"#fafafa",transition:"background 0.1s",cursor:"pointer"},onMouseEnter:q=>q.currentTarget.style.background="#f0f7ff",onMouseLeave:q=>q.currentTarget.style.background=M%2===0?"white":"#fafafa",children:[n.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:K?n.jsx("span",{style:{background:ne+"18",color:ne,border:`1px solid ${ne}44`,padding:"3px 10px",borderRadius:20,fontSize:11,fontWeight:700},children:K}):n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.custom_number||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",fontWeight:600,color:"#1a2332",whiteSpace:"nowrap"},children:L.full_name||L.first_name||"—"}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:L.username||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:L.email||L.name}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.mobile_no||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#4b5563",whiteSpace:"nowrap"},children:L.custom_organization||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.custom_management||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.custom_department||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:L.custom_branch||n.jsx("span",{style:{color:"#d1d5db"},children:"—"})}),n.jsx("td",{style:{padding:"11px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:V0(L.creation)}),n.jsx("td",{style:{padding:"11px 14px",whiteSpace:"nowrap"},children:n.jsx("span",{style:{color:L.enabled?"#16a34a":"#dc2626",fontWeight:600},children:L.enabled?i.users.active:i.users.inactive})}),n.jsx("td",{style:{padding:"10px 14px",whiteSpace:"nowrap"},onClick:q=>q.stopPropagation(),children:n.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[n.jsx("button",{onClick:q=>{q.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:q=>{q.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:q=>{q.stopPropagation(),o({name:L.name,email:L.email||L.name}),z(""),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:q=>{q.stopPropagation(),I(L.name)},disabled:k===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:k===L.name?.5:1},children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("polyline",{points:"3 6 5 6 21 6"}),n.jsx("path",{d:"M19 6l-1 14H6L5 6"}),n.jsx("path",{d:"M10 11v6M14 11v6"}),n.jsx("path",{d:"M9 6V4h6v2"})]})})]})})]},L.name)})})]})}),n.jsx(Fe,{page:S,total:E.length,onPageChange:h}),m&&n.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"},children:n.jsxs("div",{style:{background:"white",borderRadius:14,padding:32,width:390,boxShadow:"0 20px 60px rgba(0,0,0,0.3)"},children:[n.jsx("div",{style:{fontSize:17,fontWeight:700,marginBottom:6,color:"#1a2332"},children:i.users.setPassword}),n.jsxs("div",{style:{fontSize:13,color:"#6b7280",marginBottom:20},children:["User: ",n.jsx("strong",{children:m.email})]}),n.jsx("input",{type:"password",value:x,onChange:L=>z(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"&&$(),autoFocus:!0}),R==="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"}),R==="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:$,disabled:R==="loading"||!x.trim(),style:{flex:1,padding:10,background:"#2563eb",color:"white",border:"none",borderRadius:8,cursor:"pointer",fontSize:13,fontWeight:700,fontFamily:"inherit",opacity:x.trim()?1:.5},children:R==="loading"?"Saving…":i.users.setPassword}),n.jsx("button",{onClick:()=>{o(null),z(""),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 Cs={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20};function t1({form:e,setForm:t,organizations:l,managements:s,departments:r,branches:i,formStatus:a,viewMode:d,onEdit:u,darkMode:f,notifCount:y,onToggleDark:p,onCountChange:c,onViewProfile:v,isSelfProfile:b,onSubmit:g,onBack:S,onNavigate:h,onLogout:m,user:o}){const x=ee(),z=E=>t(O=>({...O,...E})),R=d?{background:"#f9f9f9"}:{},P=!e.name,k=b?"My Profile":P?"New User":d?`User: ${e.full_name||e.email}`:`Edit User: ${e.full_name||e.email}`,C=fe(s,e.custom_management).map(E=>({name:E.name,label:E.name1||E.name})),$=fe(r,e.custom_department).map(E=>({name:E.name,label:E.department_name||E.name})),I=fe(i,e.custom_branch).map(E=>({name:E.name,label:E.branch||E.name}));return n.jsxs(Me,{title:k,activePage:"users",user:o,formStatus:a,buttonText:x.saveUser,buttonColor:W.blue,viewMode:d,onEdit:u,darkMode:f,notifCount:y,onToggleDark:p,onCountChange:c,onViewProfile:v,hideSettings:b,onSubmit:g,onBack:S,onNavigate:h,onLogout:m,children:[n.jsxs("div",{style:Cs,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:x.field.organization}),n.jsx(Et,{value:e.custom_organization,onChange:E=>z({custom_organization:E}),organizations:l,disabled:d})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:x.field.management}),n.jsx(ue,{value:e.custom_management,onChange:E=>z({custom_management:E}),items:C,placeholder:"-- Select --",disabled:d})]})]}),n.jsxs("div",{style:Cs,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:x.field.department}),n.jsx(ue,{value:e.custom_department,onChange:E=>z({custom_department:E}),items:$,placeholder:"-- Select --",disabled:d})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:x.field.branch}),n.jsx(ue,{value:e.custom_branch,onChange:E=>z({custom_branch:E}),items:I,placeholder:"-- Select --",disabled:d})]})]}),n.jsxs("div",{style:Cs,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:x.field.number}),n.jsx("input",{style:{...A,...R},value:e.custom_number,disabled:d,onChange:E=>z({custom_number:E.target.value}),placeholder:"e.g. 10001"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[x.field.fullName," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...A,...R},value:e.first_name,disabled:d,onChange:E=>z({first_name:E.target.value}),placeholder:"Full name",required:!0})]})]}),n.jsxs("div",{style:Cs,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:x.field.username}),n.jsx("input",{style:{...A,...R},value:e.username,disabled:d,onChange:E=>z({username:E.target.value}),placeholder:"Username"})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:x.field.phoneNumber}),n.jsx("input",{style:{...A,...R},value:e.mobile_no,disabled:d,onChange:E=>z({mobile_no:E.target.value}),placeholder:"Phone number"})]})]}),n.jsxs("div",{style:Cs,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[x.field.emailAddress," ",P&&n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...A,...d||!P?{background:"#f9f9f9"}:{}},value:e.email,disabled:d||!P,onChange:E=>z({email:E.target.value}),placeholder:"user@example.com",type:"email",required:P})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:x.field.category}),n.jsxs("select",{style:{...A,...R},value:e.custom_category,disabled:d,onChange:E=>z({custom_category:E.target.value}),children:[n.jsx("option",{value:"",children:x.field.select}),n.jsx("option",{children:"Admin"}),n.jsx("option",{children:"Chairman"}),n.jsx("option",{children:"Auditor"}),n.jsx("option",{children:"X-Auditor"}),n.jsx("option",{children:"Manager"}),n.jsx("option",{children:"Employee"})]})]})]})]})}const du={Active:W.green,Closed:W.gray};function n1({cycles:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=ee(),[a,d]=j.useState(""),[u,f]=j.useState(""),[y,p]=j.useState("all"),c=j.useMemo(()=>[...new Set(e.map(o=>o.organization).filter(Boolean))],[e]),v=j.useMemo(()=>e.filter(o=>{const x=(o.name1||o.name||"").toLowerCase();return!(a&&!x.includes(a.toLowerCase())||u&&o.organization!==u||y!=="all"&&o.status!==y)}),[e,a,u,y]),[b,g]=j.useState(1);j.useEffect(()=>{g(1)},[a,u,y]);const S=v.slice((b-1)*se,b*se),h=v.filter(o=>o.status==="Active").length,m=v.filter(o=>o.status==="Closed").length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(Ae,{label:"Total",val:v.length,color:W.teal}),n.jsx(Ae,{label:"Active",val:h,color:W.green}),n.jsx(Ae,{label:"Closed",val:m,color:W.gray})]}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Search by name…"},{type:"select",label:i.col.organization,value:u,onChange:f,options:[{value:"",label:"All Organizations"},...c.map(o=>({value:o,label:o}))]},{type:"select",label:"Status",value:y,onChange:p,options:[{value:"all",label:"All"},{value:"Active",label:"Active"},{value:"Closed",label:"Closed"}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.name}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.frequency}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.startDate}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.endDate}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.status}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.actions})]})}),n.jsx("tbody",{children:v.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:7,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):S.map((o,x)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(o),style:{borderTop:"1px solid #f0f0f0",background:x%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:o.name1||o.name}),n.jsx("td",{style:{padding:"10px 14px"},children:o.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.frequency||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.start_date||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:o.end_date||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{padding:"3px 10px",borderRadius:12,fontSize:12,background:du[o.status]+"22",color:du[o.status]||"#666"},children:o.status})}),n.jsx("td",{style:{padding:"8px 14px"},onClick:z=>z.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(o),onEdit:t&&s?()=>s(o):void 0,onDelete:t&&r?()=>r(o.name):void 0})})]},o.name))})]})}),n.jsx(Fe,{page:b,total:v.length,onPageChange:g})]})}const Ia={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},l1=["Weekly","Bi-weekly","Monthly","Quarterly","Annually"],s1=["Active","Closed"];function r1({form:e,setForm:t,organizations:l,formStatus:s,viewMode:r,onEdit:i,darkMode:a,notifCount:d,onToggleDark:u,onCountChange:f,onViewProfile:y,onSubmit:p,onBack:c,onNavigate:v,onLogout:b,user:g}){const S=ee(),h=x=>t(z=>({...z,...x})),m=r?{background:"#f9f9f9"}:{},o=e.name?r?`${S.formTitle.editCycle}: ${e.name1||e.name}`:S.formTitle.editCycle:S.formTitle.newCycle;return n.jsxs(Me,{title:o,activePage:"cycles",user:g,formStatus:s,buttonText:S.saveCycle,buttonColor:W.teal,viewMode:r,onEdit:i,darkMode:a,notifCount:d,onToggleDark:u,onCountChange:f,onViewProfile:y,onSubmit:p,onBack:c,onNavigate:v,onLogout:b,children:[n.jsxs("div",{style:Ia,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[S.field.name1," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...A,...m},value:e.name1||"",disabled:r||!!e.name,onChange:x=>h({name1:x.target.value}),placeholder:"e.g. Q1-2026"})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.organization,onChange:x=>h({organization:x}),organizations:l,disabled:r||!!g.custom_organization})]})]}),n.jsxs("div",{style:Ia,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.col.frequency}),n.jsx(ue,{value:e.frequency,onChange:x=>h({frequency:x}),items:l1.map(x=>({name:x,label:x})),placeholder:"-- Select Frequency --",disabled:r})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.status}),n.jsx(ue,{value:e.status,onChange:x=>h({status:x}),items:s1.map(x=>({name:x,label:x})),placeholder:"-- Select Status --",disabled:r})]})]}),n.jsxs("div",{style:Ia,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.dateStart}),n.jsx(ye,{value:e.start_date||"",onChange:x=>h({start_date:x}),disabled:r,style:{...A,...m}})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.dateEnd}),n.jsx(ye,{value:e.end_date||"",onChange:x=>h({end_date:x}),disabled:r,style:{...A,...m}})]})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.updateWindowDays}),n.jsx("input",{type:"number",min:1,max:30,style:{...A,...m,maxWidth:160},value:e.update_window_days??2,disabled:r,onChange:x=>h({update_window_days:parseInt(x.target.value)||2})}),n.jsx("span",{style:{fontSize:12,color:"#888",marginLeft:8},children:"Grace period after cycle ends before Unknown is auto-assigned"})]})]})}function i1({kpiInputs:e,canModify:t,onView:l,onEdit:s,onDelete:r}){const i=ee(),[a,d]=j.useState(""),[u,f]=j.useState(""),y=j.useMemo(()=>[...new Set(e.map(g=>g.organization).filter(Boolean))],[e]),p=j.useMemo(()=>e.filter(g=>{const S=[g.organization,g.period].filter(Boolean).join(" ").toLowerCase();return!(a&&!S.includes(a.toLowerCase())||u&&g.organization!==u)}),[e,a,u]),[c,v]=j.useState(1);j.useEffect(()=>{v(1)},[a,u]);const b=p.slice((c-1)*se,c*se);return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",gap:16},children:n.jsx(Ae,{label:"Total Records",val:p.length,color:W.blue})}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:a,onChange:d,placeholder:"Organization or period…"},{type:"select",label:i.col.organization,value:u,onChange:f,options:[{value:"",label:"All Organizations"},...y.map(g=>({value:g,label:g}))]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.organization}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.period}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.field.revenue_growth}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.field.net_profit}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.dash.customerSat}),n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},children:i.col.actions})]})}),n.jsx("tbody",{children:p.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:6,style:{padding:40,textAlign:"center",color:"#aaa"},children:i.noData})}):b.map((g,S)=>n.jsxs("tr",{onClick:()=>l==null?void 0:l(g),style:{borderTop:"1px solid #f0f0f0",background:S%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:g.organization||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.period||"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.revenue_growth!=null?`${g.revenue_growth}%`:"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.net_profit!=null?g.net_profit.toLocaleString():"—"}),n.jsx("td",{style:{padding:"10px 14px"},children:g.customer_satisfaction!=null?g.customer_satisfaction:"—"}),n.jsx("td",{style:{padding:"8px 14px"},onClick:h=>h.stopPropagation(),children:n.jsx(Je,{onView:()=>l==null?void 0:l(g),onEdit:t&&s?()=>s(g):void 0,onDelete:t&&r?()=>r(g.name):void 0})})]},g.name))})]})}),n.jsx(Fe,{page:c,total:p.length,onPageChange:v})]})}const uu={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},pu={display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:20};function a1({form:e,setForm:t,organizations:l,formStatus:s,viewMode:r,onEdit:i,darkMode:a,notifCount:d,onToggleDark:u,onCountChange:f,onViewProfile:y,onSubmit:p,onBack:c,onNavigate:v,onLogout:b,user:g}){const S=ee(),h=z=>t(R=>({...R,...z})),m=r?{background:"#f9f9f9"}:{},o=z=>R=>h({[z]:parseFloat(R.target.value)||0}),x=e.name?r?`${S.formTitle.editKpi}: ${e.period||e.name}`:S.formTitle.editKpi:S.formTitle.newKpi;return n.jsxs(Me,{title:x,activePage:"kpi-input",user:g,formStatus:s,buttonText:S.saveKpi,buttonColor:W.blue,viewMode:r,onEdit:i,darkMode:a,notifCount:d,onToggleDark:u,onCountChange:f,onViewProfile:y,onSubmit:p,onBack:c,onNavigate:v,onLogout:b,children:[n.jsxs("div",{style:uu,children:[n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[S.field.organization," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(Et,{value:e.organization,onChange:z=>h({organization:z}),organizations:l,disabled:r||!!g.custom_organization})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[S.col.period," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx("input",{style:{...A,...m},value:e.period||"",disabled:r,onChange:z=>h({period:z.target.value}),placeholder:"e.g. Q1 2026"})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",marginBottom:12},children:"Financial KPIs"}),n.jsxs("div",{style:pu,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.revenue_growth}),n.jsx("input",{type:"number",step:"0.01",style:{...A,...m},value:e.revenue_growth||"",disabled:r,onChange:o("revenue_growth")})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.net_profit}),n.jsx("input",{type:"number",step:"0.01",style:{...A,...m},value:e.net_profit||"",disabled:r,onChange:o("net_profit")})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.cash_flow}),n.jsx("input",{type:"number",step:"0.01",style:{...A,...m},value:e.cash_flow||"",disabled:r,onChange:o("cash_flow")})]})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",marginBottom:12},children:"Operational KPIs"}),n.jsxs("div",{style:pu,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.strategic_goal_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...A,...m},value:e.strategic_goal_pct||"",disabled:r,onChange:o("strategic_goal_pct")})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.customer_satisfaction}),n.jsx("input",{type:"number",step:"0.01",style:{...A,...m},value:e.customer_satisfaction||"",disabled:r,onChange:o("customer_satisfaction")})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.employee_turnover_pct}),n.jsx("input",{type:"number",step:"0.01",style:{...A,...m},value:e.employee_turnover_pct||"",disabled:r,onChange:o("employee_turnover_pct")})]})]})]}),n.jsxs("div",{style:{borderTop:"1px solid #f0f0f0",paddingTop:16},children:[n.jsx("p",{style:{fontWeight:700,color:"#555",marginBottom:12},children:"Safety & Compliance"}),n.jsxs("div",{style:uu,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.open_safety_incidents}),n.jsx("input",{type:"number",min:0,style:{...A,...m},value:e.open_safety_incidents||"",disabled:r,onChange:z=>h({open_safety_incidents:parseInt(z.target.value)||0})})]}),n.jsxs("div",{children:[n.jsx("label",{style:T,children:S.field.compliance_score}),n.jsx("input",{type:"number",step:"0.01",style:{...A,...m},value:e.compliance_score||"",disabled:r,onChange:o("compliance_score")})]})]})]})]})}const o1={create_processes:"Create Processes",update_process_status:"Update Process Status"},fu={Pending:W.orange,Accepted:W.green,Rejected:W.red,Revoked:W.gray};function c1(e){if(!e)return"—";const t=new Date(e);return isNaN(t.getTime())?"—":`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}function d1(e){const t=[];return e.create_processes&&t.push("create_processes"),e.update_process_status&&t.push("update_process_status"),t}function u1({delegations:e,organizations:t,userRole:l,currentUser:s,onView:r,onRevoke:i}){const a=ee(),[d,u]=j.useState(""),[f,y]=j.useState(""),[p,c]=j.useState("all"),v={padding:"10px 14px",textAlign:"left",color:"#999",fontSize:10,fontWeight:700},b=j.useMemo(()=>e.filter(x=>{const z=`${x.auditor} ${x.manager}`.toLowerCase();return!(d&&!z.includes(d.toLowerCase())||f&&x.organization!==f||p!=="all"&&x.status!==p)}),[e,d,f,p]),[g,S]=j.useState(1);j.useEffect(()=>{S(1)},[d,f,p]);const h=b.slice((g-1)*se,g*se),m=b.filter(x=>x.status==="Pending").length,o=b.filter(x=>x.status==="Accepted").length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:16},children:[n.jsx(Ae,{label:"Total",val:b.length,color:W.purple}),n.jsx(Ae,{label:"Pending",val:m,color:W.orange}),n.jsx(Ae,{label:"Accepted",val:o,color:W.green})]}),n.jsx(ct,{filters:[{type:"search",label:"Search",value:d,onChange:u,placeholder:"Auditor or Manager…"},{type:"select",label:a.col.organization,value:f,onChange:y,options:[{value:"",label:"All Organizations"},...t.map(x=>({value:x.organization_name||x.name,label:x.organization_name||x.name}))]},{type:"select",label:"Status",value:p,onChange:c,options:[{value:"all",label:"All"},{value:"Pending",label:"Pending"},{value:"Accepted",label:"Accepted"},{value:"Rejected",label:"Rejected"},{value:"Revoked",label:"Revoked"}]}]}),n.jsx("div",{style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto",flex:1},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa",position:"sticky",top:0},children:[n.jsx("th",{style:v,children:a.col.number}),n.jsx("th",{style:v,children:a.col.auditor}),n.jsx("th",{style:v,children:a.col.manager}),n.jsx("th",{style:v,children:a.col.organization}),n.jsx("th",{style:v,children:a.col.functions}),n.jsx("th",{style:v,children:a.col.status}),n.jsx("th",{style:v,children:a.col.requestedOn}),n.jsx("th",{style:v,children:a.col.actions})]})}),n.jsx("tbody",{children:b.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:8,style:{padding:40,textAlign:"center",color:"#aaa"},children:a.noData})}):h.map((x,z)=>{const R=!!i&&(x.status==="Pending"||x.status==="Accepted")&&(l==="Admin"||l==="Auditor"&&x.auditor===s);return n.jsxs("tr",{onClick:()=>r==null?void 0:r(x),style:{borderTop:"1px solid #f0f0f0",background:z%2===0?"white":"#fafafa",cursor:"pointer"},children:[n.jsx("td",{style:{padding:"10px 14px",fontWeight:600},children:x.number||x.name}),n.jsx("td",{style:{padding:"10px 14px"},children:x.auditor}),n.jsx("td",{style:{padding:"10px 14px"},children:x.manager}),n.jsx("td",{style:{padding:"10px 14px"},children:x.organization||"All Organizations"}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:d1(x).map(P=>n.jsx("span",{style:{background:"#ede9fe",color:"#6d28d9",padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600},children:o1[P]||P},P))})}),n.jsx("td",{style:{padding:"10px 14px"},children:n.jsx("span",{style:{background:(fu[x.status]||W.gray)+"22",color:fu[x.status]||W.gray,padding:"3px 10px",borderRadius:12,fontSize:12,fontWeight:700},children:x.status})}),n.jsx("td",{style:{padding:"10px 14px",color:"#666"},children:c1(x.requested_on)}),n.jsx("td",{style:{padding:"8px 14px"},onClick:P=>P.stopPropagation(),children:n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("button",{onClick:()=>r==null?void 0:r(x),title:"View",style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",cursor:"pointer",background:"#e0f7fa",color:"#0891b2"},children:n.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),R&&n.jsx("button",{onClick:()=>i==null?void 0:i(x.name),title:"Revoke",style:{padding:"0 12px",height:32,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,border:"none",cursor:"pointer",background:"#fee2e2",color:"#ef4444",fontSize:12,fontWeight:700},children:"Revoke"})]})})]},x.name)})})]})}),n.jsx(Fe,{page:g,total:b.length,onPageChange:S})]})}const hu={display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},gu={Pending:W.orange,Accepted:W.green,Rejected:W.red,Revoked:W.gray};function p1(e){if(!e)return"—";const t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleString()}function f1({form:e,setForm:t,organizations:l,users:s,userRoleMap:r,formStatus:i,viewMode:a,onEdit:d,darkMode:u,notifCount:f,onToggleDark:y,onCountChange:p,onViewProfile:c,onSubmit:v,onBack:b,onNavigate:g,onLogout:S,user:h}){var P;const m=ee(),o=k=>t(C=>({...C,...k})),x=a?{background:"#f9f9f9"}:{},z=fr(s,r,"SB Manager").map(k=>({name:k.name,label:k.full_name||k.name})),R=e.name?`${m.formTitle.viewDelegation}${e.number||e.name}`:m.formTitle.newDelegation;return n.jsxs(Me,{title:R,activePage:"delegations",user:h,formStatus:i,buttonText:m.saveDelegation,buttonColor:W.purple,viewMode:a,onEdit:d,darkMode:u,notifCount:f,onToggleDark:y,onCountChange:p,onViewProfile:c,onSubmit:v,onBack:b,onNavigate:g,onLogout:S,children:[a&&e.status&&n.jsx("div",{style:{marginBottom:20},children:n.jsx("span",{style:{background:(gu[e.status]||W.gray)+"22",color:gu[e.status]||W.gray,padding:"5px 14px",borderRadius:14,fontSize:13,fontWeight:700},children:e.status})}),n.jsxs("div",{style:hu,children:[n.jsxs("div",{children:[n.jsx("label",{style:T,children:m.col.auditor}),n.jsx("input",{style:{...A,background:"#f9f9f9"},value:e.auditor||h.name,disabled:!0})]}),n.jsxs("div",{children:[n.jsxs("label",{style:T,children:[m.col.manager," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsx(ue,{value:e.manager,onChange:k=>o({manager:k}),items:z,placeholder:"-- Select Manager --",disabled:a})]})]}),n.jsx("div",{style:hu,children:n.jsxs("div",{children:[n.jsx("label",{style:T,children:m.col.organization}),n.jsx(Et,{value:e.organization,onChange:k=>o({organization:k}),organizations:l,placeholder:"-- All Organizations --",disabled:a})]})}),n.jsxs("div",{style:{marginTop:8},children:[n.jsxs("label",{style:T,children:[m.col.functions," ",n.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,marginTop:6},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:a?"default":"pointer"},children:[n.jsx("input",{type:"checkbox",style:ds,checked:!!e.create_processes,disabled:a,onChange:k=>o({create_processes:k.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:ds,checked:!!e.update_process_status,disabled:a,onChange:k=>o({update_process_status:k.target.checked?1:0})}),n.jsx("span",{style:{fontSize:14},children:"Update Process Status"})]})]})]}),!a&&n.jsxs("div",{style:{marginTop:20},children:[n.jsx("label",{style:T,children:"Remarks"}),n.jsx("textarea",{style:{...A,...x,minHeight:70,resize:"vertical"},value:e.remarks||"",onChange:k=>o({remarks:k.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:T,children:"Audit Trail"}),n.jsx("div",{style:{background:"white",borderRadius:8,border:"1px solid #eee",overflow:"hidden"},children:n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsxs("tr",{style:{background:"#f8f9fa"},children:[n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Action"}),n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Actor"}),n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Timestamp"}),n.jsx("th",{style:{padding:"8px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700},children:"Remarks"})]})}),n.jsx("tbody",{children:(e.delegation_log||[]).map((k,C)=>n.jsxs("tr",{style:{borderTop:"1px solid #f0f0f0"},children:[n.jsx("td",{style:{padding:"8px 14px",fontWeight:600},children:k.action}),n.jsx("td",{style:{padding:"8px 14px"},children:k.actor}),n.jsx("td",{style:{padding:"8px 14px",color:"#666"},children:p1(k.timestamp)}),n.jsx("td",{style:{padding:"8px 14px",color:"#666"},children:k.remarks||"—"})]},k.name||C))})]})})]})]})}const xu={process:"processes-form",order:"orders-form",incident:"incidents-form",idea:"ideas-form"},zs={process:W.blue,order:W.purple,incident:W.red,idea:W.green,delegation:W.orange},mu={process:"🔄",order:"📦",incident:"🚨",idea:"💡",delegation:"🤝"};function Ts(e,t){const l=e.replace("#",""),s=parseInt(l.substring(0,2),16),r=parseInt(l.substring(2,4),16),i=parseInt(l.substring(4,6),16);return`rgba(${s}, ${r}, ${i}, ${t})`}function h1({onNavigate:e,onRefresh:t}){const l=ee(),[s,r]=j.useState([]),[i,a]=j.useState(!0),[d,u]=j.useState(""),[f,y]=j.useState(""),p=()=>vy().then(h=>{r(h),a(!1)});j.useEffect(()=>{p()},[]);const c=s.filter(h=>h.requires_action),v=s.filter(h=>!h.requires_action),b={};for(const h of s)b[h.type]=(b[h.type]||0)+1;const g=async(h,m)=>{u(h),y("");try{await by(h,m),await p(),t==null||t()}catch{y(h)}u("")};function S(h,m,o){return m.length===0?null:n.jsxs("div",{style:{marginBottom:28},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:14},children:[n.jsx("span",{style:{fontSize:12,fontWeight:800,letterSpacing:.6,textTransform:"uppercase",color:o?W.accent:"#8a8fa3"},children:h}),n.jsx("span",{style:{fontSize:11,fontWeight:700,minWidth:22,textAlign:"center",padding:"2px 7px",borderRadius:999,color:o?"white":"#6b7280",background:o?W.accent:"#e9eaf2"},children:m.length}),n.jsx("div",{style:{flex:1,height:1,background:"linear-gradient(90deg, #e6e7f0, transparent)"}})]}),n.jsx("div",{className:"inbox-card-grid",children:m.map((x,z)=>{const R=x.type!=="delegation",P=zs[x.type]||W.gray;return n.jsxs("div",{className:"inbox-card",onClick:R?()=>e(xu[x.type],x.name):void 0,style:{borderTop:`3px solid ${P}`,cursor:R?"pointer":"default"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:14},children:[n.jsx("div",{style:{width:38,height:38,borderRadius:12,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:17,background:Ts(P,.14)},children:mu[x.type]||"📌"}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[n.jsx("span",{style:{fontWeight:700,fontSize:13,color:P,letterSpacing:.3},children:x.number}),x.requires_action&&n.jsx("span",{style:{fontSize:10,fontWeight:700,color:W.red,background:Ts(W.red,.12),padding:"1px 7px",borderRadius:999,textTransform:"uppercase",letterSpacing:.4},children:"Action"})]}),n.jsx("div",{className:"inbox-card-title",style:{fontSize:14,fontWeight:600,marginTop:3,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.title}),n.jsxs("div",{className:"inbox-card-meta",style:{marginTop:5,fontSize:12},children:[x.action,x.organization&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{opacity:.5},children:" · "}),x.organization]}),x.date&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{opacity:.5},children:" · "}),x.date]})]}),f===x.name&&n.jsx("div",{style:{marginTop:6,fontSize:12,color:W.red,fontWeight:600},children:"Failed to respond — please try again."})]})]}),x.type==="delegation"?n.jsxs("div",{style:{display:"flex",gap:8,marginTop:14},children:[n.jsx("button",{onClick:()=>g(x.name,"Accepted"),disabled:d===x.name,style:{flex:1,padding:"8px 0",borderRadius:9,border:"none",background:W.green,color:"white",fontWeight:700,fontSize:13,cursor:d===x.name?"wait":"pointer",opacity:d===x.name?.6:1},children:"Accept"}),n.jsx("button",{onClick:()=>g(x.name,"Rejected"),disabled:d===x.name,style:{flex:1,padding:"8px 0",borderRadius:9,border:"none",background:W.red,color:"white",fontWeight:700,fontSize:13,cursor:d===x.name?"wait":"pointer",opacity:d===x.name?.6:1},children:"Reject"})]}):n.jsx("button",{onClick:k=>{k.stopPropagation(),e(xu[x.type],x.name)},style:{marginTop:14,width:"100%",padding:"8px 0",borderRadius:9,border:"none",background:x.requires_action?P:Ts(P,.12),color:x.requires_action?"white":P,fontWeight:700,fontSize:13,cursor:"pointer"},children:x.requires_action?"Act Now →":l.view})]},z)})})]})}return n.jsxs("div",{style:{maxWidth:1040,margin:"0 auto"},children:[!i&&s.length>0&&n.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap",marginBottom:24},children:Object.entries(b).map(([h,m])=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"6px 12px 6px 9px",borderRadius:999,background:Ts(zs[h]||W.gray,.1),border:`1px solid ${Ts(zs[h]||W.gray,.25)}`},children:[n.jsx("span",{style:{fontSize:13},children:mu[h]}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:zs[h]||W.gray,textTransform:"capitalize"},children:h}),n.jsx("span",{style:{fontSize:12,fontWeight:700,color:zs[h]||W.gray,opacity:.7},children:m})]},h))}),i&&n.jsx("p",{style:{color:"#888"},children:l.loading}),!i&&s.length===0&&n.jsxs("div",{className:"inbox-empty",children:[n.jsx("div",{style:{fontSize:46,marginBottom:10},children:"✨"}),n.jsx("p",{style:{fontSize:16,fontWeight:600},children:l.inbox.noMessages}),n.jsx("p",{style:{fontSize:13,marginTop:4,opacity:.7},children:"You're all caught up — nothing needs your attention right now."})]}),!i&&S("Needs Action",c,!0),!i&&S("Informational",v,!1)]})}const g1=[{id:"process_status_history",label:"Process Status History",description:"Full cycle-by-cycle status for any process, with actor, date, and escalation level",roles:["Admin","Auditor","Owner"]},{id:"order_tracker",label:"Outsourcing Order Tracker",description:"Stage-by-stage progress for all orders, with cost variance",roles:["Admin","Auditor","Manager","Owner"]},{id:"incident_register",label:"Incident Register",description:"All incidents with type, status, assigned manager, and resolution timeline",roles:["Admin","Auditor","Manager","Owner"]},{id:"ideas_pipeline",label:"Ideas Pipeline",description:"All ideas by status and type, conversion rate to Study",roles:["Admin","Auditor","Manager","Owner"]},{id:"department_performance",label:"Department Performance",description:"Aggregate Pass/Fail/Unknown per department per cycle",roles:["Admin","Auditor","Owner"]},{id:"escalation_report",label:"Escalation Report",description:"All Level 2 escalations with entity type and current status",roles:["Admin","Owner"]},{id:"cost_summary",label:"Cost Summary",description:"Total cost per order, per department — budget vs actual",roles:["Admin","Owner"]},{id:"process_year_end",label:"Process Year-End Summary",description:"Full status history and accumulated cost per process for a given year (Rule 11.1-6)",roles:["Admin","Auditor","Owner"],extraFilter:"year"},{id:"user_activity_log",label:"User Activity Log",description:"All actions by user with timestamp and entity reference — Admin only",roles:["Admin"]}],Mf={number:"Number",title:"Title",organization:"Organization",department:"Department",status:"Status",actor:"Actor",cycle:"Cycle",date_start:"Start Date",date_end:"End Date",escalation_level:"Escalation",stage:"Stage",completion_pct:"Completion %",budget:"Budget",starting_date:"Start",ending_date:"End",date:"Date",assigned_to:"Assigned To",type:"Type",entity_type:"Entity",pass_count:"Pass",fail_count:"Fail",unknown_count:"Unknown",total:"Total",cycle_type:"Cycle Type",cost_per_cycle:"Cost/Cycle",total_cycles:"Total Cycles",total_cost:"Total Cost",timestamp:"Timestamp",user:"User",entity_name:"Entity",changes:"Fields Changed"};function x1(e,t){const l=e.map(r=>Mf[r]||r).join(","),s=t.map(r=>e.map(i=>`"${r[i]??""}"`).join(",")).join(`
`);return l+`
`+s}function m1(e,t){const l=new Blob([e],{type:"text/csv"}),s=URL.createObjectURL(l),r=document.createElement("a");r.href=s,r.download=t,r.click(),URL.revokeObjectURL(s)}const Hf="report-print-area",Ea="report-print-portal";function y1(){const e=document.getElementById(Hf);if(!e)return;const t=document.createElement("div");t.id=Ea,t.innerHTML=e.innerHTML,document.body.appendChild(t);const l=document.createElement("style");l.id="report-print-style",l.textContent=`
#${Ea} { display: none; }
@media print {
#root { display: none !important; }
#${Ea} { display: block !important; }
}
`,document.head.appendChild(l);const s=()=>{t.remove(),l.remove(),window.removeEventListener("afterprint",s)};window.addEventListener("afterprint",s),window.print()}const yu={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white",minWidth:180},Aa={padding:"8px 12px",borderRadius:8,border:"1px solid #d1d5db",fontSize:13,background:"white"};function v1({organizations:e,userRole:t}){const l=ee(),s=g1.filter(C=>C.roles.includes(t)),[r,i]=j.useState(""),[a,d]=j.useState(""),[u,f]=j.useState(""),[y,p]=j.useState(""),[c,v]=j.useState(String(new Date().getFullYear())),[b,g]=j.useState([]),[S,h]=j.useState([]),[m,o]=j.useState(!1),[x,z]=j.useState(""),R=s.find(C=>C.id===r);async function P(){if(r){o(!0),z(""),h([]),g([]);try{const C={};a&&(C.organization=a),u&&(C.from_date=u),y&&(C.to_date=y),(R==null?void 0:R.extraFilter)==="year"&&c&&(C.year=c);const $=await yy(r,C);g($.columns||[]),h($.rows||[])}catch(C){z(C.message||"Error running report")}finally{o(!1)}}}const k=(R==null?void 0:R.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(C=>n.jsxs("div",{onClick:()=>i(C.id),style:{background:r===C.id?"#ebf5fb":"white",border:r===C.id?`2px solid ${W.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:C.label}),n.jsx("div",{style:{fontSize:12,color:"#888"},children:C.description})]},C.id))}),n.jsx("div",{style:{background:"white",borderRadius:12,padding:20,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",marginBottom:20},children:n.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",alignItems:"flex-end"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"REPORT"}),n.jsxs("select",{style:yu,value:r,onChange:C=>i(C.target.value),children:[n.jsx("option",{value:"",children:"-- Select Report --"}),s.map(C=>n.jsx("option",{value:C.id,children:C.label},C.id))]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"ORGANIZATION"}),n.jsxs("select",{style:yu,value:a,onChange:C=>d(C.target.value),children:[n.jsx("option",{value:"",children:l.filter.allOrgs}),e.map(C=>n.jsx("option",{value:C.name,children:C.organization_name||C.name},C.name))]})]}),(R==null?void 0:R.extraFilter)==="year"?n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"YEAR"}),n.jsx("input",{type:"number",style:{...Aa,width:90},value:c,onChange:C=>v(C.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(ye,{value:u,onChange:f,style:Aa})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#999",marginBottom:4},children:"TO"}),n.jsx(ye,{value:y,onChange:p,style:Aa})]})]}),n.jsx("button",{onClick:P,disabled:!r||m,style:{padding:"9px 20px",borderRadius:8,border:"none",background:W.accent,color:"white",fontWeight:700,fontSize:13,cursor:r?"pointer":"not-allowed",opacity:r?1:.5},children:m?l.loading:l.reports.generate}),S.length>0&&n.jsx("button",{onClick:()=>m1(x1(b,S),`${r}.csv`),style:{padding:"9px 20px",borderRadius:8,border:"1px solid #27ae60",background:"white",color:"#27ae60",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Export CSV"}),S.length>0&&n.jsx("button",{onClick:y1,style:{padding:"9px 20px",borderRadius:8,border:"1px solid #888",background:"white",color:"#555",fontWeight:700,fontSize:13,cursor:"pointer"},children:"Print / PDF"})]})}),x&&n.jsx("div",{style:{color:"#e74c3c",marginBottom:16},children:x}),S.length>0&&n.jsxs("div",{id:Hf,style:{background:"white",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"auto"},children:[n.jsxs("div",{style:{padding:"14px 18px",borderBottom:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsx("span",{style:{fontWeight:700,color:"#333"},children:k}),n.jsxs("span",{style:{fontSize:12,color:"#888"},children:[S.length," rows"]})]}),n.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[n.jsx("thead",{children:n.jsx("tr",{style:{background:"#f8f9fa"},children:b.map(C=>n.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"#999",fontSize:11,fontWeight:700,whiteSpace:"nowrap"},children:Mf[C]||C.replace(/_/g," ").toUpperCase()},C))})}),n.jsx("tbody",{children:S.map((C,$)=>n.jsx("tr",{style:{borderTop:"1px solid #f0f0f0",background:$%2===0?"white":"#fafafa"},children:b.map(I=>n.jsx("td",{style:{padding:"10px 14px",color:"#333"},children:C[I]!=null?String(C[I]):"—"},I))},$))})]})]}),!m&&S.length===0&&r&&!x&&n.jsx("div",{style:{background:"white",borderRadius:12,padding:40,textAlign:"center",color:"#aaa",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:"Select a report and click Run Report to see results."}),s.length===0&&n.jsx("div",{style:{background:"white",borderRadius:12,padding:40,textAlign:"center",color:"#aaa",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:"No reports are available for your role."})]})}const hr=()=>new Date().toISOString().split("T")[0],wc=()=>new Date(Date.now()+30*24*60*60*1e3).toISOString().split("T")[0],Vt=()=>({name:"",number:"",title:"",organization:"",type:"",incident_class:"",incident_field:"",date:hr(),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:hr(),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:hr(),ending_date:wc(),assigned_to:"",actor:"",status:"",budget:0,actual_cost:0,currency:"SAR",description:"",notes:"",cycle:"",stage:1,completion_pct:0,escalation_level:0,workflow_state:"Draft",planned:0,priority:"",product_relation:0,entity_scope:"",economy_class:"",hses_field:"",auditor_comment:""}),Hr=()=>({name:"",title:"",date_start:hr(),date_end:wc(),number:"",status:"",cycle_type:"Normal",organization:"",type:"",management:"",department:"",section_field:"",branch:"",progress_indicators:[],cycle:"",actor:"",escalation_level:0,workflow_state:"",chain_location:"",economy_class:"",impact_level:"",product_relation:0,entity_scope:"",hses_field:"",kpi_name:"",kpi_type:"",kpi_measure:"",cost_per_cycle:0,auditor_comment:""}),Pl=()=>({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}),Gn=()=>({name:"",organization:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Yn=()=>({name:"",custom_organization:"",department_name:"",custom_management:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),Xn=()=>({name:"",organization:"",branch:"",management:"",department:"",custom_creation_date:new Date().toISOString().slice(0,10),custom_status:"Active"}),Il=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),El=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Al=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Rl=()=>({name:"",name1:"",creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ll=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Ol=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Dl=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Nl=()=>({name:"",name1:"",notify_manager:0,creation_date:new Date().toISOString().slice(0,10),status:"Active"}),Kr=()=>({name:"",first_name:"",full_name:"",email:"",enabled:1,creation:"",username:"",mobile_no:"",custom_organization:"",custom_management:"",custom_department:"",custom_branch:"",custom_number:"",custom_category:""}),qn=()=>({name:"",name1:"",organization:"",frequency:"Monthly",status:"Active",start_date:hr(),end_date:wc(),update_window_days:2}),Jn=()=>({name:"",organization:"",period:"",revenue_growth:0,net_profit:0,cash_flow:0,strategic_goal_pct:0,customer_satisfaction:0,employee_turnover_pct:0,open_safety_incidents:0,compliance_score:0}),Ps=()=>({name:"",number:"",auditor:"",manager:"",organization:"",create_processes:0,update_process_status:0,status:"Pending",requested_on:"",remarks:""}),j1=new Set(["incidents","incidents-form","ideas","ideas-form"]),b1=new Set(["orders","orders-form","incidents","incidents-form","ideas","ideas-form"]),S1=new Set(["Admin","Owner","Auditor","Manager"]),w1=new Set(["Admin","Owner","Auditor","Manager"]),k1=new Set(["Admin","Auditor","Manager"]);function _1({user:e,onLogout:t,darkMode:l,onToggleDark:s}){const r=ee(),i=e.role,a=S1.has(i),d=w1.has(i),u=k1.has(i),f=w=>w==="users"||w==="users-form"?i==="Admin":i==="Admin"||i==="Auditor"?!0:i==="Owner"||i==="XAuditor"?!1:i==="Manager"?!!(b1.has(w)||(w==="processes"||w==="processes-form")&&Cc.includes("create_processes")):j1.has(w),y=w=>i==="Employee"&&!!w&&w!=="New",[p,c]=j.useState(a?"dashboard":"inbox"),v=e.custom_organization||"",[b,g]=j.useState(""),[S,h]=j.useState("");j.useEffect(()=>{if(!S)return;const w=setTimeout(()=>h(""),0);return()=>clearTimeout(w)},[S]);const m=(w,G)=>{h(G),c(w)},[o,x]=j.useState(0),[z,R]=j.useState([]),[P,k]=j.useState([]),[C,$]=j.useState([]),[I,E]=j.useState([]),[O,U]=j.useState([]),[V,xe]=j.useState([]),[le,L]=j.useState([]),[M,K]=j.useState([]),[ne,q]=j.useState([]),[me,Ce]=j.useState([]),[re,ze]=j.useState([]),[he,H]=j.useState([]),[J,N]=j.useState([]),[oe,Wn]=j.useState([]),[gt,_]=j.useState([]),[Y,Z]=j.useState([]),[Yt,gr]=j.useState([]),[Bn,Xi]=j.useState([]),[$n,D]=j.useState([]),[Ge,hl]=j.useState({}),[kt,Kf]=j.useState([]),[xr,Qf]=j.useState([]),[kc,Gf]=j.useState([]),[_c,Yf]=j.useState([]),[Cc,Xf]=j.useState([]),[zc,qf]=j.useState({}),[we,de]=j.useState(!0),[De,ie]=j.useState("idle"),[Ne,te]=j.useState(!1),[Tc,Pc]=j.useState(!1),[mr,Ic]=j.useState(null),[Jf,Zf]=j.useState(()=>localStorage.getItem("sb_sidebar")==="1"),Vf=()=>Zf(w=>{const G=!w;return localStorage.setItem("sb_sidebar",G?"1":"0"),G}),[eh,qi]=j.useState(!1);j.useEffect(()=>{qi(!1)},[p]);const[gl,Xt]=j.useState(Vt()),[xl,qt]=j.useState(en()),[yr,Jt]=j.useState(tn()),[vr,Ft]=j.useState(Hr()),[Ec,ml]=j.useState(Pl()),[Ac,Un]=j.useState(Gn()),[Rc,Fn]=j.useState(Yn()),[Lc,Mn]=j.useState(Xn()),[Oc,yl]=j.useState(Il()),[Dc,vl]=j.useState(El()),[Nc,jl]=j.useState(Al()),[Wc,bl]=j.useState(Rl()),[Bc,Sl]=j.useState(Ll()),[$c,wl]=j.useState(Ol()),[Uc,kl]=j.useState(Dl()),[Fc,_l]=j.useState(Nl()),[hs,jr]=j.useState(Kr()),[Mc,Hn]=j.useState(qn()),[Hc,Kn]=j.useState(Jn()),[Cl,gs]=j.useState(Ps()),At=async()=>{de(!0);try{const[w,G,xt,Rt,hn,We,ea,Xh,qh,Jh,Zh,Vh,eg,tg,ng,lg,sg,rg,ig,ag,og,cg,dg,ug,pg,fg]=await Promise.all([ke(B.incidents),ke(B.organizations),ke(B.ideas),ke(B.orders),ke(B.processes),ey(),ke(B.managements),ke(B.departments),ke(B.branches),ke(B.incidentTypes),ke(B.incidentClass),ke(B.incidentField),ke(B.ideaTypes),ke(B.orderTypes),ke(B.processTypes),ke(B.incidentStatuses),ke(B.ideaStatuses),ke(B.orderStatuses),ke(B.processStatuses),sy(),ry(),ke(B.cycles),ke(B.kpiInput),wy(),_y(),Cy()]);R(w||[]),k(G||[]),$(xt||[]),E(Rt||[]),U(hn||[]),Kf(We||[]),xe(ea||[]),L(Xh||[]),K(qh||[]),q(Jh||[]),Ce(Zh||[]),ze(Vh||[]),H(eg||[]),N(tg||[]),Wn(ng||[]),_(lg||[]),Z(sg||[]),gr(rg||[]),Xi(ig||[]),D(ag||[]),hl(og||{}),Qf(cg||[]),Gf(dg||[]),Yf(ug||[]),Xf(pg||[]),qf(fg||{})}catch(w){console.error("Error loading data:",w)}de(!1)},th=async()=>{try{const w=await fetch("/api/method/sidrah_business.api.get_notification_count",{credentials:"include",headers:{Accept:"application/json"}});if(w.ok){const G=await w.json();x(Number(G.message)||0)}}catch{}};j.useEffect(()=>{At(),th()},[e.name]);const He=async(w,G)=>{if(window.confirm(r.rtl?"هل أنت متأكد من حذف هذا السجل؟":"Are you sure you want to delete this record?")){de(!0);try{await Nf(w,G),await At()}catch(xt){console.error("Delete error:",xt),alert((xt==null?void 0:xt.message)||"Delete failed. Please try again.")}de(!1)}},nh=async w=>{try{await cy(w),await At()}catch(G){console.error("Disable user error:",G)}},lh=async w=>{te(!0),de(!0);try{const G=await mt(B.incidents,w.name);Xt({...Vt(),...G})}catch{Xt({...Vt(),...w})}c("incidents-form"),de(!1)},sh=async w=>{te(!0),de(!0);try{const G=await mt(B.ideas,w.name);qt({...en(),...G})}catch{qt({...en(),...w})}c("ideas-form"),de(!1)},rh=async w=>{te(!0),de(!0);try{const G=await mt(B.orders,w.name);Jt({...tn(),...G})}catch{Jt({...tn(),...w})}c("orders-form"),de(!1)},ih=async w=>{te(!0),de(!0);try{const G=await Ls(w.name);Ft({...G,progress_indicators:G.progress_indicators||[],cycle_logs:G.cycle_logs||[]}),c("processes-form")}catch{Ft({...w,progress_indicators:w.progress_indicators||[]}),c("processes-form")}de(!1)},ah=w=>ve(B.organizations,w,ml,Pl(),"organizations-form",!0),oh=async w=>{te(!0),de(!0);try{const G=await mt(B.managements,w.name);Un({...Gn(),...G})}catch{Un({...Gn(),...w})}c("managements-form"),de(!1)},ch=async w=>{te(!0),de(!0);try{const G=await mt(B.departments,w.name);Fn({...Yn(),...G})}catch{Fn({...Yn(),...w})}c("departments-form"),de(!1)},dh=async w=>{te(!0),de(!0);try{const G=await mt(B.branches,w.name);Mn({...Xn(),...G})}catch{Mn({...Xn(),...w})}c("branches-form"),de(!1)},uh=async w=>{te(!0),de(!0);try{const G=await mt(B.cycles,w.name);Hn({...qn(),...G})}catch{Hn({...qn(),...w})}c("cycles-form"),de(!1)},ph=async w=>{te(!0),de(!0);try{const G=await mt(B.kpiInput,w.name);Kn({...Jn(),...G})}catch{Kn({...Jn(),...w})}c("kpi-input-form"),de(!1)},Ye=async(w,G,xt,Rt,hn)=>{ie("loading");try{if(G.name)await Ti(w,G.name,G),ie("success"),At(),setTimeout(()=>{ie("idle"),c(Rt)},1500);else if(hn){const We=await za(w,G);hn(We),ie("success"),At(),setTimeout(()=>ie("idle"),1500)}else await za(w,G),xt(),ie("success"),At(),setTimeout(()=>{ie("idle"),c(Rt)},1500)}catch(We){console.error("Submit error:",We),ie(We instanceof Error?We.message:"Error saving. Please try again.")}},Re=async()=>{await ny(),t()},ve=async(w,G,xt,Rt,hn,We)=>{te(We),de(!0);try{const ea=await mt(w,G.name);xt({...Rt,...ea})}catch{xt({...Rt,...G})}c(hn),de(!1)},fh=w=>ve(B.incidents,w,Xt,Vt(),"incidents-form",!1),hh=w=>ve(B.ideas,w,qt,en(),"ideas-form",!1),gh=w=>ve(B.orders,w,Jt,tn(),"orders-form",!1),xh=w=>{te(!1),de(!0),Ls(w.name).then(G=>{Ft({...G,progress_indicators:G.progress_indicators||[],cycle_logs:G.cycle_logs||[]})}).catch(()=>{Ft({...w,progress_indicators:w.progress_indicators||[]})}).finally(()=>{c("processes-form"),de(!1)})},mh=w=>ve(B.organizations,w,ml,Pl(),"organizations-form",!1),yh=w=>ve(B.managements,w,Un,Gn(),"managements-form",!1),vh=w=>ve(B.departments,w,Fn,Yn(),"departments-form",!1),jh=w=>ve(B.branches,w,Mn,Xn(),"branches-form",!1),bh=w=>ve(B.cycles,w,Hn,qn(),"cycles-form",!1),Sh=w=>ve(B.kpiInput,w,Kn,Jn(),"kpi-input-form",!1),wh=async w=>{te(!0),de(!0);try{const G=await ky(w.name);gs({...Ps(),...G})}catch{gs({...Ps(),...w})}c("delegations-form"),de(!1)},kh=async()=>{ie("loading");try{const w=[];Cl.create_processes&&w.push("create_processes"),Cl.update_process_status&&w.push("update_process_status"),await jy(Cl.manager,w,Cl.organization,Cl.remarks),gs(Ps()),ie("success"),At(),setTimeout(()=>{ie("idle"),c("delegations")},1500)}catch(w){console.error("Delegation submit error:",w),ie(w instanceof Error?w.message:"Error saving. Please try again.")}},_h=async w=>{if(window.confirm(r.rtl?"هل أنت متأكد من إلغاء هذا التفويض؟":"Are you sure you want to revoke this delegation?")){de(!0);try{await Sy(w),await At()}catch(G){console.error("Revoke delegation error:",G),alert(G instanceof Error?G.message:"Revoke failed. Please try again.")}de(!1)}},Ch=w=>ve(B.incidentTypes,w,yl,Il(),"incident-types-form",!0),zh=w=>ve(B.incidentTypes,w,yl,Il(),"incident-types-form",!1),Th=w=>ve(B.ideaTypes,w,vl,El(),"idea-types-form",!0),Ph=w=>ve(B.ideaTypes,w,vl,El(),"idea-types-form",!1),Ih=w=>ve(B.orderTypes,w,jl,Al(),"order-types-form",!0),Eh=w=>ve(B.orderTypes,w,jl,Al(),"order-types-form",!1),Ah=w=>ve(B.processTypes,w,bl,Rl(),"process-types-form",!0),Rh=w=>ve(B.processTypes,w,bl,Rl(),"process-types-form",!1),Lh=w=>ve(B.incidentStatuses,w,Sl,Ll(),"incident-statuses-form",!0),Oh=w=>ve(B.incidentStatuses,w,Sl,Ll(),"incident-statuses-form",!1),Dh=w=>ve(B.ideaStatuses,w,wl,Ol(),"idea-statuses-form",!0),Nh=w=>ve(B.ideaStatuses,w,wl,Ol(),"idea-statuses-form",!1),Wh=w=>ve(B.orderStatuses,w,kl,Dl(),"order-statuses-form",!0),Bh=w=>ve(B.orderStatuses,w,kl,Dl(),"order-statuses-form",!1),$h=w=>ve(B.processStatuses,w,_l,Nl(),"process-statuses-form",!0),Uh=w=>ve(B.processStatuses,w,_l,Nl(),"process-statuses-form",!1),Fh=async w=>{Ic(w),c("profile")},Mh=w=>{te(!1),Pc(!1),jr({...Kr(),...w}),c("users-form")},Hh=async()=>{ie("loading");try{if(!hs.name){const G=await za("User",{...hs,send_welcome_email:0,user_type:"System User"});jr({...Kr(),...hs,...G}),te(!0),ie("success"),At(),setTimeout(()=>ie("idle"),1500)}else{const{name:G,email:xt,creation:Rt,full_name:hn,...We}=hs;await Ti("User",G,We),ie("success"),At(),setTimeout(()=>{ie("idle"),c("users")},1500)}}catch(w){console.error("User submit error:",w),ie(w instanceof Error?w.message:"Error saving. Please try again.")}},Le=()=>{const w=$n.find(G=>G.name===e.name||G.username===e.name);Ic(w||{name:e.name,full_name:e.full_name,email:e.name,enabled:1}),c("profile")},Ji=(w,G)=>{if(G){const Rt={"processes-form":B.processes,"orders-form":B.orders,"incidents-form":B.incidents,"ideas-form":B.ideas}[w];if(Rt){te(!0),de(!0),(w==="processes-form"?Ls(G).then(We=>({...We,progress_indicators:We.progress_indicators||[],cycle_logs:We.cycle_logs||[]})):mt(Rt,G)).then(We=>{w==="processes-form"?Ft(We):w==="orders-form"?Jt({...tn(),...We}):w==="incidents-form"?Xt({...Vt(),...We}):w==="ideas-form"&&qt({...en(),...We}),c(w),de(!1)}).catch(()=>{c(w),de(!1)});return}}c(w)};if(p==="incidents-form")return n.jsx(qy,{incForm:gl,setIncForm:Xt,organizations:P,managements:V,departments:le,branches:M,incidentTypes:ne,incidentClasses:me,incidentFields:re,incidentStatuses:gt,users:kt,userRoleMap:Ge,formStatus:De,viewMode:Ne||!f("incidents-form")||y(gl.workflow_state),onEdit:f("incidents-form")&&!y(gl.workflow_state)?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,userRole:i,onSubmit:()=>Ye(B.incidents,gl,()=>Xt(Vt()),"incidents",w=>Xt({...Vt(),...w})),onBack:()=>{c("incidents"),ie("idle")},onNavigate:c,onLogout:Re,user:e,onRefresh:async()=>{if(gl.name){const w=await mt(B.incidents,gl.name).catch(()=>null);w&&Xt({...Vt(),...w})}ke(B.incidents).then(w=>R(w||[])).catch(()=>{})}});if(p==="ideas-form")return n.jsx(e0,{ideaForm:xl,setIdeaForm:qt,organizations:P,managements:V,departments:le,branches:M,ideaTypes:he,ideaStatuses:Y,users:kt,userRoleMap:Ge,formStatus:De,viewMode:Ne||!f("ideas-form")||y(xl.workflow_state),onEdit:f("ideas-form")&&!y(xl.workflow_state)?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,userRole:i,onSubmit:()=>Ye(B.ideas,xl,()=>qt(en()),"ideas",w=>qt({...en(),...w})),onBack:()=>{c("ideas"),ie("idle")},onNavigate:c,onLogout:Re,user:e,onRefresh:async()=>{if(xl.name){const w=await mt(B.ideas,xl.name).catch(()=>null);w&&qt({...en(),...w})}ke(B.ideas).then(w=>$(w||[])).catch(()=>{})}});if(p==="orders-form")return n.jsx(r0,{orderForm:yr,setOrderForm:Jt,organizations:P,managements:V,departments:le,branches:M,orderTypes:J,orderStatuses:Yt,cycles:xr,users:kt,userRoleMap:Ge,formStatus:De,viewMode:Ne||!f("orders-form"),onEdit:f("orders-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,currentUser:e.name,userRole:i,onSubmit:()=>Ye(B.orders,yr,()=>Jt(tn()),"orders",w=>Jt({...tn(),...w})),onBack:()=>{c("orders"),ie("idle")},onNavigate:c,onLogout:Re,user:e,onRefresh:async()=>{if(yr.name){const w=await mt(B.orders,yr.name).catch(()=>null);w&&Jt({...tn(),...w})}ke(B.orders).then(w=>E(w||[])).catch(()=>{})}});if(p==="processes-form")return n.jsx(d0,{processForm:vr,setProcessForm:Ft,organizations:P,managements:V,departments:le,branches:M,processTypes:oe,processStatuses:Bn,cycles:xr,users:kt,userRoleMap:Ge,formStatus:De,viewMode:Ne||!f("processes-form"),onEdit:f("processes-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,userRole:e.role,delegatedFunctions:Cc,delegatedOrgs:zc.create_processes,onRefreshProcess:async()=>{if(vr.name)try{const w=await Ls(vr.name);Ft({...w,progress_indicators:w.progress_indicators||[],cycle_logs:w.cycle_logs||[]})}catch{}ke(B.processes).then(w=>U(w||[])).catch(()=>{})},onSubmit:()=>Ye(B.processes,vr,()=>Ft(Hr()),"processes",w=>Ft({...Hr(),...w,progress_indicators:w.progress_indicators||[],cycle_logs:w.cycle_logs||[]})),onBack:()=>{c("processes"),ie("idle")},onNavigate:c,onLogout:Re,user:e});if(p==="organizations-form")return n.jsx(x0,{orgForm:Ec,setOrgForm:ml,formStatus:De,viewMode:Ne||!f("organizations-form"),onEdit:f("organizations-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,onSubmit:()=>Ye(B.organizations,Ec,()=>ml(Pl()),"organizations",w=>{ml({...Pl(),...w}),te(!0)}),onBack:()=>{c("organizations"),ie("idle")},onNavigate:c,onLogout:Re,user:e});if(p==="managements-form")return n.jsx(v0,{form:Ac,setForm:Un,organizations:P,formStatus:De,viewMode:Ne||!f("managements-form"),onEdit:f("managements-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,onSubmit:()=>Ye(B.managements,Ac,()=>Un(Gn()),"managements",w=>{Un({...Gn(),...w}),te(!0)}),onBack:()=>{c("managements"),ie("idle")},onNavigate:c,onLogout:Re,user:e});if(p==="departments-form")return n.jsx(w0,{form:Rc,setForm:Fn,organizations:P,managements:V,formStatus:De,viewMode:Ne||!f("departments-form"),onEdit:f("departments-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,onSubmit:()=>Ye(B.departments,Rc,()=>Fn(Yn()),"departments",w=>{Fn({...Yn(),...w}),te(!0)}),onBack:()=>{c("departments"),ie("idle")},onNavigate:c,onLogout:Re,user:e});if(p==="branches-form")return n.jsx(z0,{form:Lc,setForm:Mn,organizations:P,managements:V,departments:le,formStatus:De,viewMode:Ne||!f("branches-form"),onEdit:f("branches-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,onSubmit:()=>Ye(B.branches,Lc,()=>Mn(Xn()),"branches",w=>{Mn({...Xn(),...w}),te(!0)}),onBack:()=>{c("branches"),ie("idle")},onNavigate:c,onLogout:Re,user:e});if(p==="cycles-form")return n.jsx(r1,{form:Mc,setForm:Hn,organizations:P,formStatus:De,viewMode:Ne||!f("cycles-form"),onEdit:f("cycles-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,onSubmit:()=>Ye(B.cycles,Mc,()=>Hn(qn()),"cycles",w=>{Hn({...qn(),...w}),te(!0)}),onBack:()=>{c("cycles"),ie("idle")},onNavigate:c,onLogout:Re,user:e});if(p==="kpi-input-form")return n.jsx(a1,{form:Hc,setForm:Kn,organizations:P,formStatus:De,viewMode:Ne||!f("kpi-input-form"),onEdit:f("kpi-input-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,onSubmit:()=>Ye(B.kpiInput,Hc,()=>Kn(Jn()),"kpi-input",w=>{Kn({...Jn(),...w}),te(!0)}),onBack:()=>{c("kpi-input"),ie("idle")},onNavigate:c,onLogout:Re,user:e});if(p==="incident-types-form")return n.jsx(I0,{form:Oc,setForm:yl,formStatus:De,viewMode:Ne||!f("incident-types-form"),onEdit:f("incident-types-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,onSubmit:()=>Ye(B.incidentTypes,Oc,()=>yl(Il()),"incident-types",w=>{yl({...Il(),...w}),te(!0)}),onBack:()=>{c("incident-types"),ie("idle")},onNavigate:c,onLogout:Re,user:e});if(p==="idea-types-form")return n.jsx(R0,{form:Dc,setForm:vl,formStatus:De,viewMode:Ne||!f("idea-types-form"),onEdit:f("idea-types-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,onSubmit:()=>Ye(B.ideaTypes,Dc,()=>vl(El()),"idea-types",w=>{vl({...El(),...w}),te(!0)}),onBack:()=>{c("idea-types"),ie("idle")},onNavigate:c,onLogout:Re,user:e});if(p==="order-types-form")return n.jsx(D0,{form:Nc,setForm:jl,formStatus:De,viewMode:Ne||!f("order-types-form"),onEdit:f("order-types-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,onSubmit:()=>Ye(B.orderTypes,Nc,()=>jl(Al()),"order-types",w=>{jl({...Al(),...w}),te(!0)}),onBack:()=>{c("order-types"),ie("idle")},onNavigate:c,onLogout:Re,user:e});if(p==="process-types-form")return n.jsx(B0,{form:Wc,setForm:bl,formStatus:De,viewMode:Ne||!f("process-types-form"),onEdit:f("process-types-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,onSubmit:()=>Ye(B.processTypes,Wc,()=>bl(Rl()),"process-types",w=>{bl({...Rl(),...w}),te(!0)}),onBack:()=>{c("process-types"),ie("idle")},onNavigate:c,onLogout:Re,user:e});if(p==="incident-statuses-form")return n.jsx(F0,{form:Bc,setForm:Sl,formStatus:De,viewMode:Ne||!f("incident-statuses-form"),onEdit:f("incident-statuses-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,onSubmit:()=>Ye(B.incidentStatuses,Bc,()=>Sl(Ll()),"incident-statuses",w=>{Sl({...Ll(),...w}),te(!0)}),onBack:()=>{c("incident-statuses"),ie("idle")},onNavigate:c,onLogout:Re,user:e});if(p==="idea-statuses-form")return n.jsx(K0,{form:$c,setForm:wl,formStatus:De,viewMode:Ne||!f("idea-statuses-form"),onEdit:f("idea-statuses-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,onSubmit:()=>Ye(B.ideaStatuses,$c,()=>wl(Ol()),"idea-statuses",w=>{wl({...Ol(),...w}),te(!0)}),onBack:()=>{c("idea-statuses"),ie("idle")},onNavigate:c,onLogout:Re,user:e});if(p==="order-statuses-form")return n.jsx(Y0,{form:Uc,setForm:kl,formStatus:De,viewMode:Ne||!f("order-statuses-form"),onEdit:f("order-statuses-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,onSubmit:()=>Ye(B.orderStatuses,Uc,()=>kl(Dl()),"order-statuses",w=>{kl({...Dl(),...w}),te(!0)}),onBack:()=>{c("order-statuses"),ie("idle")},onNavigate:c,onLogout:Re,user:e});if(p==="process-statuses-form")return n.jsx(J0,{form:Fc,setForm:_l,formStatus:De,viewMode:Ne||!f("process-statuses-form"),onEdit:f("process-statuses-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,onSubmit:()=>Ye(B.processStatuses,Fc,()=>_l(Nl()),"process-statuses",w=>{_l({...Nl(),...w}),te(!0)}),onBack:()=>{c("process-statuses"),ie("idle")},onNavigate:c,onLogout:Re,user:e});if(p==="users-form")return n.jsx(t1,{form:hs,setForm:jr,organizations:P,managements:V,departments:le,branches:M,formStatus:De,viewMode:Ne||!f("users-form"),onEdit:f("users-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,isSelfProfile:Tc,onSubmit:Hh,onBack:()=>{c(Tc?a?"dashboard":"inbox":"users"),ie("idle")},onNavigate:c,onLogout:Re,user:e});if(p==="delegations-form")return n.jsx(f1,{form:Cl,setForm:gs,organizations:P,users:kt,userRoleMap:Ge,formStatus:De,viewMode:Ne||!f("delegations-form"),onEdit:f("delegations-form")?()=>te(!1):void 0,darkMode:l,notifCount:o,onToggleDark:s,onCountChange:x,onViewProfile:Le,onSubmit:kh,onBack:()=>{c("delegations"),ie("idle")},onNavigate:c,onLogout:Re,user:e});const Kh=r.pages,Qh={incidents:{color:W.accent,formPage:"incidents-form",reset:()=>Xt({...Vt(),organization:v||b})},ideas:{color:W.teal,formPage:"ideas-form",reset:()=>qt({...en(),organization:v||b})},orders:{color:W.purple,formPage:"orders-form",reset:()=>Jt({...tn(),organization:v||b})},processes:{color:W.blue,formPage:"processes-form",reset:()=>{const w=zc.create_processes,G=v||(i==="Manager"&&w&&w.length===1?w[0]:b);Ft({...Hr(),organization:G})}},organizations:{color:W.accent,formPage:"organizations-form",reset:()=>ml(Pl())},managements:{color:W.blue,formPage:"managements-form",reset:()=>Un({...Gn(),organization:v||b})},departments:{color:W.teal,formPage:"departments-form",reset:()=>Fn({...Yn(),custom_organization:v||b})},branches:{color:W.purple,formPage:"branches-form",reset:()=>Mn({...Xn(),organization:v||b})},cycles:{color:W.teal,formPage:"cycles-form",reset:()=>Hn({...qn(),organization:v||b})},"kpi-input":{color:W.blue,formPage:"kpi-input-form",reset:()=>Kn({...Jn(),organization:v||b})},"incident-types":{color:W.red,formPage:"incident-types-form",reset:()=>yl(Il())},"idea-types":{color:W.orange,formPage:"idea-types-form",reset:()=>vl(El())},"order-types":{color:W.green,formPage:"order-types-form",reset:()=>jl(Al())},"process-types":{color:W.accent,formPage:"process-types-form",reset:()=>bl(Rl())},"incident-statuses":{color:W.red,formPage:"incident-statuses-form",reset:()=>Sl(Ll())},"idea-statuses":{color:W.teal,formPage:"idea-statuses-form",reset:()=>wl(Ol())},"order-statuses":{color:W.purple,formPage:"order-statuses-form",reset:()=>kl(Dl())},"process-statuses":{color:W.blue,formPage:"process-statuses-form",reset:()=>_l(Nl())},users:{color:W.blue,formPage:"users-form",reset:()=>{jr(Kr()),Pc(!1)}},delegations:{color:W.purple,formPage:"delegations-form",reset:()=>gs(Ps())}},Gh={incidents:r.formTitle.newIncident,ideas:r.formTitle.newIdea,orders:r.formTitle.newOrder,processes:r.formTitle.newProcess,organizations:r.formTitle.newOrg,managements:r.formTitle.newMgmt,departments:r.formTitle.newDept,branches:r.formTitle.newBranch,users:r.formTitle.newUser,cycles:r.formTitle.newCycle,"kpi-input":r.formTitle.newKpi,delegations:r.formTitle.newDelegation,"incident-types":"New Incident Type","idea-types":"New Idea Type","order-types":"New Order Type","process-types":"New Process Type","incident-statuses":"New Incident Status","idea-statuses":"New Idea Status","order-statuses":"New Order Status","process-statuses":"New Process Status"},Yh={incidents:z,ideas:C,orders:I,processes:O,organizations:P,managements:V,departments:le,branches:M,cycles:xr,"kpi-input":kc,"incident-types":ne,"idea-types":he,"order-types":J,"process-types":oe,"incident-statuses":gt,"idea-statuses":Y,"order-statuses":Yt,"process-statuses":Bn,users:$n,delegations:_c},Qn=Hm[p],Zi=Yh[p],X=f(p),Vi=X?Qh[p]:null;return n.jsxs("div",{style:{display:"flex",minHeight:"100vh",fontFamily:"Segoe UI",background:l?"#0f172a":W.bg},children:[n.jsx(Lf,{collapsed:Jf,onToggleCollapsed:Vf,activePage:p,onNavigate:w=>c(w),hasDashboard:a,hasReports:d,hasDelegations:u,role:i,rtl:r.rtl,navLabels:r.nav,settingsLabel:r.nav.settings}),n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[n.jsx("div",{style:{background:l?"#1e293b":"#ffffff",padding:"6px 20px",borderBottom:`1px solid ${l?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"flex-end",alignItems:"center",gap:6,flexShrink:0,boxShadow:l?"none":"0 1px 4px rgba(0,0,0,0.04)"},children:n.jsx(Uf,{notifCount:o,darkMode:l,onCountChange:x,onToggleDark:s,onNavigate:Ji,onViewProfile:Le,onLogout:Re})}),p!=="profile"&&n.jsxs("div",{style:{background:l?"#1e293b":"white",padding:"9px 20px",borderBottom:`1px solid ${l?"#2d3748":"#e9eaf0"}`,display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[n.jsx("div",{style:{fontSize:15,fontWeight:700,color:l?"#e2e8f0":"#1e1b4b"},children:Kh[p]||p}),n.jsxs("div",{style:{display:"flex",gap:8},children:[Qn&&Zi&&n.jsx("button",{onClick:()=>qi(!0),style:{background:"#16a34a",color:"white",border:"none",padding:"6px 14px",borderRadius:7,fontSize:12,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI",display:"flex",alignItems:"center",gap:6},children:"⬇ Export"}),Vi&&n.jsxs("button",{onClick:()=>{Vi.reset(),te(!1),ie("idle"),c(Vi.formPage)},style:{background:"#4f46e5",color:"white",border:"none",padding:"6px 14px",borderRadius:7,fontSize:12,cursor:"pointer",fontWeight:600,whiteSpace:"nowrap",fontFamily:"Segoe UI"},children:["+ ",Gh[p]||r.new]})]})]}),Qn&&Zi&&eh&&n.jsx(Jm,{title:Qn.label,rows:Zi,columns:Qn.columns,defaultColumnKeys:Qn.defaultColumns,orgField:Qn.orgField,organizations:Qn.orgField?P:void 0,filenameBase:p,onClose:()=>qi(!1)}),n.jsxs("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column",padding:p==="profile"?0:"20px 24px",gap:p==="profile"?0:16},children:[we&&n.jsx("div",{style:{textAlign:"center",paddingTop:60,color:"#aaa",fontSize:15},children:r.loading}),!we&&p==="dashboard"&&a&&n.jsx(Oy,{incidents:z,ideas:C,orders:I,processes:O,organizations:P,incidentStatuses:gt,ideaStatuses:Y,orderStatuses:Yt,processStatuses:Bn,selectedOrg:b,onOrgChange:g,onNavigate:Ji,onNavigateStatus:m,userRole:i}),!we&&p==="inbox"&&n.jsx(h1,{onNavigate:Ji,onRefresh:At}),!we&&p==="reports"&&d&&n.jsx(v1,{organizations:P,userRole:i}),!we&&p==="incidents"&&n.jsx($y,{incidents:z,organizations:P,departments:le,branches:M,incidentStatuses:gt,initialOrg:b,initialStatus:S,onView:lh,onEdit:X?fh:void 0,onDelete:X?w=>He(B.incidents,w):void 0,canModify:X}),!we&&p==="ideas"&&n.jsx(Jy,{ideas:C,organizations:P,departments:le,branches:M,ideaStatuses:Y,initialOrg:b,initialStatus:S,onView:sh,onEdit:X?hh:void 0,onDelete:X?w=>He(B.ideas,w):void 0,canModify:X}),!we&&p==="orders"&&n.jsx(t0,{orders:I,organizations:P,departments:le,branches:M,orderStatuses:Yt,initialOrg:b,initialStatus:S,onView:rh,onEdit:X?gh:void 0,onDelete:X?w=>He(B.orders,w):void 0,canModify:X}),!we&&p==="processes"&&n.jsx(i0,{processes:O,organizations:P,departments:le,branches:M,processStatuses:Bn,initialOrg:b,initialStatus:S,onView:ih,onEdit:X?xh:void 0,onDelete:X?w=>He(B.processes,w):void 0,canModify:X}),!we&&p==="organizations"&&n.jsx(g0,{organizations:P,onView:ah,onEdit:X?mh:void 0,onDelete:X?w=>He(B.organizations,w):void 0,canModify:X}),!we&&p==="managements"&&n.jsx(y0,{managements:V,onView:oh,onEdit:X?yh:void 0,onDelete:X?w=>He(B.managements,w):void 0,canModify:X}),!we&&p==="departments"&&n.jsx(b0,{departments:le,managements:V,onView:ch,onEdit:X?vh:void 0,onDelete:X?w=>He(B.departments,w):void 0,canModify:X}),!we&&p==="branches"&&n.jsx(_0,{branches:M,managements:V,departments:le,onView:dh,onEdit:X?jh:void 0,onDelete:X?w=>He(B.branches,w):void 0,canModify:X}),!we&&p==="cycles"&&n.jsx(n1,{cycles:xr,canModify:X,onView:uh,onEdit:X?bh:void 0,onDelete:X?w=>He(B.cycles,w):void 0}),!we&&p==="kpi-input"&&n.jsx(i1,{kpiInputs:kc,canModify:X,onView:ph,onEdit:X?Sh:void 0,onDelete:X?w=>He(B.kpiInput,w):void 0}),!we&&p==="incident-types"&&n.jsx(P0,{incidentTypes:ne,onView:Ch,onEdit:X?zh:void 0,onDelete:X?w=>He(B.incidentTypes,w):void 0,canModify:X}),!we&&p==="idea-types"&&n.jsx(A0,{ideaTypes:he,onView:Th,onEdit:X?Ph:void 0,onDelete:X?w=>He(B.ideaTypes,w):void 0,canModify:X}),!we&&p==="order-types"&&n.jsx(O0,{orderTypes:J,onView:Ih,onEdit:X?Eh:void 0,onDelete:X?w=>He(B.orderTypes,w):void 0,canModify:X}),!we&&p==="process-types"&&n.jsx(W0,{processTypes:oe,onView:Ah,onEdit:X?Rh:void 0,onDelete:X?w=>He(B.processTypes,w):void 0,canModify:X}),!we&&p==="incident-statuses"&&n.jsx(U0,{incidentStatuses:gt,onView:Lh,onEdit:X?Oh:void 0,onDelete:X?w=>He(B.incidentStatuses,w):void 0,canModify:X}),!we&&p==="idea-statuses"&&n.jsx(H0,{ideaStatuses:Y,onView:Dh,onEdit:X?Nh:void 0,onDelete:X?w=>He(B.ideaStatuses,w):void 0,canModify:X}),!we&&p==="order-statuses"&&n.jsx(G0,{orderStatuses:Yt,onView:Wh,onEdit:X?Bh:void 0,onDelete:X?w=>He(B.orderStatuses,w):void 0,canModify:X}),!we&&p==="process-statuses"&&n.jsx(q0,{processStatuses:Bn,onView:$h,onEdit:X?Uh:void 0,onDelete:X?w=>He(B.processStatuses,w):void 0,canModify:X}),!we&&p==="users"&&n.jsx(e1,{users:$n,roleMap:Ge,onView:Fh,onEdit:X?Mh:void 0,onDelete:X?w=>He("User",w):void 0,onDisable:X?nh:void 0,canModify:X}),!we&&p==="delegations"&&u&&n.jsx(u1,{delegations:_c,organizations:P,userRole:i,currentUser:e.name,onView:wh,onRevoke:X?_h:void 0}),p==="profile"&&(()=>{const w=!!mr&&(mr.name===e.name||mr.email===e.name);return n.jsx(p0,{user:e,profileUser:mr,sbUsers:$n,organizations:P,managements:V,departments:le,branches:M,darkMode:l,canModify:X||w,onBack:()=>c(w?a?"dashboard":"inbox":"users"),onNavigate:c})})()]})]})]})}function C1(e){return e.some(t=>["SB Admin","System Manager"].includes(t))?"Admin":e.includes("SB Auditor")?"Auditor":e.includes("SB Owner")?"Owner":e.includes("SB X-Auditor")?"XAuditor":e.includes("SB Manager")?"Manager":"Employee"}function z1(){const[e,t]=j.useState(()=>{try{const d=localStorage.getItem("sidrah_user");return d?JSON.parse(d):null}catch{return null}}),[l,s]=j.useState(()=>localStorage.getItem("sb_dark")==="1"),r=()=>{const d=!l;s(d),localStorage.setItem("sb_dark",d?"1":"0"),document.documentElement.classList.toggle("dark",d)};j.useEffect(()=>{document.documentElement.classList.toggle("dark",l)},[]),j.useEffect(()=>{e&&Wf().then(async d=>{const u=d||e.name,f=await $f(u);if(!f.length)return;const y=C1(f),p=await fy();if(y!==e.role||u!==e.name||p!==(e.custom_organization||"")){const v={...e,name:u,role:y,custom_organization:p};t(v),localStorage.setItem("sidrah_user",JSON.stringify(v))}})},[e==null?void 0:e.name]);const i=d=>{t(d),localStorage.setItem("sidrah_user",JSON.stringify(d))},a=()=>{t(null),localStorage.removeItem("sidrah_user")};return e?n.jsx(_1,{user:e,onLogout:a,darkMode:l,onToggleDark:r}):n.jsx(Py,{onLogin:i})}Af(document.getElementById("root")).render(n.jsx(j.StrictMode,{children:n.jsx(z1,{})}));