Duradundi Hadimani cbffc877fc chore(asm_app): rebuild frontend bundle and refresh asset cache versions
- Run production build; replace hashed JS chunk with index-jhfEVwZH.js
- Update inject-image-version timestamps in Login, Sidebar, and index.html
- Sync public/asm_app and www/asm_app entry HTML

Made-with: Cursor
2026-03-27 12:06:52 +00:00

2197 lines
2.2 MiB
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

var AN=Object.defineProperty,ON=Object.defineProperties;var DN=Object.getOwnPropertyDescriptors;var Rm=Object.getOwnPropertySymbols;var Tv=Object.prototype.hasOwnProperty,Ev=Object.prototype.propertyIsEnumerable;var yd=(t,a)=>(a=Symbol[t])?a:Symbol.for("Symbol."+t),MN=t=>{throw TypeError(t)};var Ff=(t,a,r)=>a in t?AN(t,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[a]=r,ue=(t,a)=>{for(var r in a||(a={}))Tv.call(a,r)&&Ff(t,r,a[r]);if(Rm)for(var r of Rm(a))Ev.call(a,r)&&Ff(t,r,a[r]);return t},Se=(t,a)=>ON(t,DN(a));var Dn=(t,a)=>{var r={};for(var s in t)Tv.call(t,s)&&a.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&Rm)for(var s of Rm(t))a.indexOf(s)<0&&Ev.call(t,s)&&(r[s]=t[s]);return r};var LN=(t,a)=>()=>(a||t((a={exports:{}}).exports,a),a.exports);var Mn=(t,a,r)=>Ff(t,typeof a!="symbol"?a+"":a,r);var Q=(t,a,r)=>new Promise((s,i)=>{var c=h=>{try{m(r.next(h))}catch(g){i(g)}},d=h=>{try{m(r.throw(h))}catch(g){i(g)}},m=h=>h.done?s(h.value):Promise.resolve(h.value).then(c,d);m((r=r.apply(t,a)).next())}),nc=function(t,a){this[0]=t,this[1]=a},If=(t,a,r)=>{var s=(d,m,h,g)=>{try{var p=r[d](m),b=(m=p.value)instanceof nc,j=p.done;Promise.resolve(b?m[0]:m).then(_=>b?s(d==="return"?d:"next",m[1]?{done:_.done,value:_.value}:_,h,g):h({value:_,done:j})).catch(_=>s("throw",_,h,g))}catch(_){g(_)}},i=d=>c[d]=m=>new Promise((h,g)=>s(d,m,h,g)),c={};return r=r.apply(t,a),c[yd("asyncIterator")]=()=>c,i("next"),i("throw"),i("return"),c},zf=t=>{var a=t[yd("asyncIterator")],r=!1,s,i={};return a==null?(a=t[yd("iterator")](),s=c=>i[c]=d=>a[c](d)):(a=a.call(t),s=c=>i[c]=d=>{if(r){if(r=!1,c==="throw")throw d;return d}return r=!0,{done:!1,value:new nc(new Promise(m=>{var h=a[c](d);h instanceof Object||MN("Object expected"),m(h)}),1)}}),i[yd("iterator")]=()=>i,s("next"),"throw"in a?s("throw"):i.throw=c=>{throw c},"return"in a&&s("return"),i},Av=(t,a,r)=>(a=t[yd("asyncIterator")])?a.call(t):(t=t[yd("iterator")](),a={},r=(s,i)=>(i=t[s])&&(a[s]=c=>new Promise((d,m,h)=>(c=i.call(t,c),h=c.done,Promise.resolve(c.value).then(g=>d({value:g,done:h}),m)))),r("next"),r("return"),a);var aF=LN(Le=>{(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const c of i)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&s(d)}).observe(document,{childList:!0,subtree:!0});function r(i){const c={};return i.integrity&&(c.integrity=i.integrity),i.referrerPolicy&&(c.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?c.credentials="include":i.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function s(i){if(i.ep)return;i.ep=!0;const c=r(i);fetch(i.href,c)}})();function $_(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Bf={exports:{}},U0={};var Ov;function RN(){if(Ov)return U0;Ov=1;var t=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function r(s,i,c){var d=null;if(c!==void 0&&(d=""+c),i.key!==void 0&&(d=""+i.key),"key"in i){c={};for(var m in i)m!=="key"&&(c[m]=i[m])}else c=i;return i=c.ref,{$$typeof:t,type:s,key:d,ref:i!==void 0?i:null,props:c}}return U0.Fragment=a,U0.jsx=r,U0.jsxs=r,U0}var Dv;function PN(){return Dv||(Dv=1,Bf.exports=RN()),Bf.exports}var e=PN(),Uf={exports:{}},Ca={};var Mv;function FN(){if(Mv)return Ca;Mv=1;var t=Symbol.for("react.transitional.element"),a=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),j=Symbol.iterator;function _(F){return F===null||typeof F!="object"?null:(F=j&&F[j]||F["@@iterator"],typeof F=="function"?F:null)}var N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,C={};function D(F,M,B){this.props=F,this.context=M,this.refs=C,this.updater=B||N}D.prototype.isReactComponent={},D.prototype.setState=function(F,M){if(typeof F!="object"&&typeof F!="function"&&F!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,F,M,"setState")},D.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function T(){}T.prototype=D.prototype;function E(F,M,B){this.props=F,this.context=M,this.refs=C,this.updater=B||N}var O=E.prototype=new T;O.constructor=E,k(O,D.prototype),O.isPureReactComponent=!0;var R=Array.isArray;function Y(){}var P={H:null,A:null,T:null,S:null},U=Object.prototype.hasOwnProperty;function J(F,M,B){var X=B.ref;return{$$typeof:t,type:F,key:M,ref:X!==void 0?X:null,props:B}}function ne(F,M){return J(F.type,M,F.props)}function ye(F){return typeof F=="object"&&F!==null&&F.$$typeof===t}function he(F){var M={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(B){return M[B]})}var ce=/\/+/g;function se(F,M){return typeof F=="object"&&F!==null&&F.key!=null?he(""+F.key):M.toString(36)}function ee(F){switch(F.status){case"fulfilled":return F.value;case"rejected":throw F.reason;default:switch(typeof F.status=="string"?F.then(Y,Y):(F.status="pending",F.then(function(M){F.status==="pending"&&(F.status="fulfilled",F.value=M)},function(M){F.status==="pending"&&(F.status="rejected",F.reason=M)})),F.status){case"fulfilled":return F.value;case"rejected":throw F.reason}}throw F}function te(F,M,B,X,K){var we=typeof F;(we==="undefined"||we==="boolean")&&(F=null);var be=!1;if(F===null)be=!0;else switch(we){case"bigint":case"string":case"number":be=!0;break;case"object":switch(F.$$typeof){case t:case a:be=!0;break;case p:return be=F._init,te(be(F._payload),M,B,X,K)}}if(be)return K=K(F),be=X===""?"."+se(F,0):X,R(K)?(B="",be!=null&&(B=be.replace(ce,"$&/")+"/"),te(K,M,B,"",function(z){return z})):K!=null&&(ye(K)&&(K=ne(K,B+(K.key==null||F&&F.key===K.key?"":(""+K.key).replace(ce,"$&/")+"/")+be)),M.push(K)),1;be=0;var ke=X===""?".":X+":";if(R(F))for(var Me=0;Me<F.length;Me++)X=F[Me],we=ke+se(X,Me),be+=te(X,M,B,we,K);else if(Me=_(F),typeof Me=="function")for(F=Me.call(F),Me=0;!(X=F.next()).done;)X=X.value,we=ke+se(X,Me++),be+=te(X,M,B,we,K);else if(we==="object"){if(typeof F.then=="function")return te(ee(F),M,B,X,K);throw M=String(F),Error("Objects are not valid as a React child (found: "+(M==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":M)+"). If you meant to render a collection of children, use an array instead.")}return be}function W(F,M,B){if(F==null)return F;var X=[],K=0;return te(F,X,"","",function(we){return M.call(B,we,K++)}),X}function I(F){if(F._status===-1){var M=F._result;M=M(),M.then(function(B){(F._status===0||F._status===-1)&&(F._status=1,F._result=B)},function(B){(F._status===0||F._status===-1)&&(F._status=2,F._result=B)}),F._status===-1&&(F._status=0,F._result=M)}if(F._status===1)return F._result.default;throw F._result}var oe=typeof reportError=="function"?reportError:function(F){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var M=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof F=="object"&&F!==null&&typeof F.message=="string"?String(F.message):String(F),error:F});if(!window.dispatchEvent(M))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",F);return}console.error(F)},ae={map:W,forEach:function(F,M,B){W(F,function(){M.apply(this,arguments)},B)},count:function(F){var M=0;return W(F,function(){M++}),M},toArray:function(F){return W(F,function(M){return M})||[]},only:function(F){if(!ye(F))throw Error("React.Children.only expected to receive a single React element child.");return F}};return Ca.Activity=b,Ca.Children=ae,Ca.Component=D,Ca.Fragment=r,Ca.Profiler=i,Ca.PureComponent=E,Ca.StrictMode=s,Ca.Suspense=h,Ca.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=P,Ca.__COMPILER_RUNTIME={__proto__:null,c:function(F){return P.H.useMemoCache(F)}},Ca.cache=function(F){return function(){return F.apply(null,arguments)}},Ca.cacheSignal=function(){return null},Ca.cloneElement=function(F,M,B){if(F==null)throw Error("The argument must be a React element, but you passed "+F+".");var X=k({},F.props),K=F.key;if(M!=null)for(we in M.key!==void 0&&(K=""+M.key),M)!U.call(M,we)||we==="key"||we==="__self"||we==="__source"||we==="ref"&&M.ref===void 0||(X[we]=M[we]);var we=arguments.length-2;if(we===1)X.children=B;else if(1<we){for(var be=Array(we),ke=0;ke<we;ke++)be[ke]=arguments[ke+2];X.children=be}return J(F.type,K,X)},Ca.createContext=function(F){return F={$$typeof:d,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null},F.Provider=F,F.Consumer={$$typeof:c,_context:F},F},Ca.createElement=function(F,M,B){var X,K={},we=null;if(M!=null)for(X in M.key!==void 0&&(we=""+M.key),M)U.call(M,X)&&X!=="key"&&X!=="__self"&&X!=="__source"&&(K[X]=M[X]);var be=arguments.length-2;if(be===1)K.children=B;else if(1<be){for(var ke=Array(be),Me=0;Me<be;Me++)ke[Me]=arguments[Me+2];K.children=ke}if(F&&F.defaultProps)for(X in be=F.defaultProps,be)K[X]===void 0&&(K[X]=be[X]);return J(F,we,K)},Ca.createRef=function(){return{current:null}},Ca.forwardRef=function(F){return{$$typeof:m,render:F}},Ca.isValidElement=ye,Ca.lazy=function(F){return{$$typeof:p,_payload:{_status:-1,_result:F},_init:I}},Ca.memo=function(F,M){return{$$typeof:g,type:F,compare:M===void 0?null:M}},Ca.startTransition=function(F){var M=P.T,B={};P.T=B;try{var X=F(),K=P.S;K!==null&&K(B,X),typeof X=="object"&&X!==null&&typeof X.then=="function"&&X.then(Y,oe)}catch(we){oe(we)}finally{M!==null&&B.types!==null&&(M.types=B.types),P.T=M}},Ca.unstable_useCacheRefresh=function(){return P.H.useCacheRefresh()},Ca.use=function(F){return P.H.use(F)},Ca.useActionState=function(F,M,B){return P.H.useActionState(F,M,B)},Ca.useCallback=function(F,M){return P.H.useCallback(F,M)},Ca.useContext=function(F){return P.H.useContext(F)},Ca.useDebugValue=function(){},Ca.useDeferredValue=function(F,M){return P.H.useDeferredValue(F,M)},Ca.useEffect=function(F,M){return P.H.useEffect(F,M)},Ca.useEffectEvent=function(F){return P.H.useEffectEvent(F)},Ca.useId=function(){return P.H.useId()},Ca.useImperativeHandle=function(F,M,B){return P.H.useImperativeHandle(F,M,B)},Ca.useInsertionEffect=function(F,M){return P.H.useInsertionEffect(F,M)},Ca.useLayoutEffect=function(F,M){return P.H.useLayoutEffect(F,M)},Ca.useMemo=function(F,M){return P.H.useMemo(F,M)},Ca.useOptimistic=function(F,M){return P.H.useOptimistic(F,M)},Ca.useReducer=function(F,M,B){return P.H.useReducer(F,M,B)},Ca.useRef=function(F){return P.H.useRef(F)},Ca.useState=function(F){return P.H.useState(F)},Ca.useSyncExternalStore=function(F,M,B){return P.H.useSyncExternalStore(F,M,B)},Ca.useTransition=function(){return P.H.useTransition()},Ca.version="19.2.1",Ca}var Lv;function Oh(){return Lv||(Lv=1,Uf.exports=FN()),Uf.exports}var y=Oh();const pa=$_(y);var $f={exports:{}},$0={},Hf={exports:{}},Wf={};var Rv;function IN(){return Rv||(Rv=1,(function(t){function a(te,W){var I=te.length;te.push(W);e:for(;0<I;){var oe=I-1>>>1,ae=te[oe];if(0<i(ae,W))te[oe]=W,te[I]=ae,I=oe;else break e}}function r(te){return te.length===0?null:te[0]}function s(te){if(te.length===0)return null;var W=te[0],I=te.pop();if(I!==W){te[0]=I;e:for(var oe=0,ae=te.length,F=ae>>>1;oe<F;){var M=2*(oe+1)-1,B=te[M],X=M+1,K=te[X];if(0>i(B,I))X<ae&&0>i(K,B)?(te[oe]=K,te[X]=I,oe=X):(te[oe]=B,te[M]=I,oe=M);else if(X<ae&&0>i(K,I))te[oe]=K,te[X]=I,oe=X;else break e}}return W}function i(te,W){var I=te.sortIndex-W.sortIndex;return I!==0?I:te.id-W.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;t.unstable_now=function(){return c.now()}}else{var d=Date,m=d.now();t.unstable_now=function(){return d.now()-m}}var h=[],g=[],p=1,b=null,j=3,_=!1,N=!1,k=!1,C=!1,D=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate!="undefined"?setImmediate:null;function O(te){for(var W=r(g);W!==null;){if(W.callback===null)s(g);else if(W.startTime<=te)s(g),W.sortIndex=W.expirationTime,a(h,W);else break;W=r(g)}}function R(te){if(k=!1,O(te),!N)if(r(h)!==null)N=!0,Y||(Y=!0,he());else{var W=r(g);W!==null&&ee(R,W.startTime-te)}}var Y=!1,P=-1,U=5,J=-1;function ne(){return C?!0:!(t.unstable_now()-J<U)}function ye(){if(C=!1,Y){var te=t.unstable_now();J=te;var W=!0;try{e:{N=!1,k&&(k=!1,T(P),P=-1),_=!0;var I=j;try{t:{for(O(te),b=r(h);b!==null&&!(b.expirationTime>te&&ne());){var oe=b.callback;if(typeof oe=="function"){b.callback=null,j=b.priorityLevel;var ae=oe(b.expirationTime<=te);if(te=t.unstable_now(),typeof ae=="function"){b.callback=ae,O(te),W=!0;break t}b===r(h)&&s(h),O(te)}else s(h);b=r(h)}if(b!==null)W=!0;else{var F=r(g);F!==null&&ee(R,F.startTime-te),W=!1}}break e}finally{b=null,j=I,_=!1}W=void 0}}finally{W?he():Y=!1}}}var he;if(typeof E=="function")he=function(){E(ye)};else if(typeof MessageChannel!="undefined"){var ce=new MessageChannel,se=ce.port2;ce.port1.onmessage=ye,he=function(){se.postMessage(null)}}else he=function(){D(ye,0)};function ee(te,W){P=D(function(){te(t.unstable_now())},W)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(te){te.callback=null},t.unstable_forceFrameRate=function(te){0>te||125<te?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<te?Math.floor(1e3/te):5},t.unstable_getCurrentPriorityLevel=function(){return j},t.unstable_next=function(te){switch(j){case 1:case 2:case 3:var W=3;break;default:W=j}var I=j;j=W;try{return te()}finally{j=I}},t.unstable_requestPaint=function(){C=!0},t.unstable_runWithPriority=function(te,W){switch(te){case 1:case 2:case 3:case 4:case 5:break;default:te=3}var I=j;j=te;try{return W()}finally{j=I}},t.unstable_scheduleCallback=function(te,W,I){var oe=t.unstable_now();switch(typeof I=="object"&&I!==null?(I=I.delay,I=typeof I=="number"&&0<I?oe+I:oe):I=oe,te){case 1:var ae=-1;break;case 2:ae=250;break;case 5:ae=1073741823;break;case 4:ae=1e4;break;default:ae=5e3}return ae=I+ae,te={id:p++,callback:W,priorityLevel:te,startTime:I,expirationTime:ae,sortIndex:-1},I>oe?(te.sortIndex=I,a(g,te),r(h)===null&&te===r(g)&&(k?(T(P),P=-1):k=!0,ee(R,I-oe))):(te.sortIndex=ae,a(h,te),N||_||(N=!0,Y||(Y=!0,he()))),te},t.unstable_shouldYield=ne,t.unstable_wrapCallback=function(te){var W=j;return function(){var I=j;j=W;try{return te.apply(this,arguments)}finally{j=I}}}})(Wf)),Wf}var Pv;function zN(){return Pv||(Pv=1,Hf.exports=IN()),Hf.exports}var Vf={exports:{}},sn={};var Fv;function BN(){if(Fv)return sn;Fv=1;var t=Oh();function a(h){var g="https://react.dev/errors/"+h;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)g+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+h+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(){}var s={d:{f:r,r:function(){throw Error(a(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},i=Symbol.for("react.portal");function c(h,g,p){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:b==null?null:""+b,children:h,containerInfo:g,implementation:p}}var d=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function m(h,g){if(h==="font")return"";if(typeof g=="string")return g==="use-credentials"?g:""}return sn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,sn.createPortal=function(h,g){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)throw Error(a(299));return c(h,g,null,p)},sn.flushSync=function(h){var g=d.T,p=s.p;try{if(d.T=null,s.p=2,h)return h()}finally{d.T=g,s.p=p,s.d.f()}},sn.preconnect=function(h,g){typeof h=="string"&&(g?(g=g.crossOrigin,g=typeof g=="string"?g==="use-credentials"?g:"":void 0):g=null,s.d.C(h,g))},sn.prefetchDNS=function(h){typeof h=="string"&&s.d.D(h)},sn.preinit=function(h,g){if(typeof h=="string"&&g&&typeof g.as=="string"){var p=g.as,b=m(p,g.crossOrigin),j=typeof g.integrity=="string"?g.integrity:void 0,_=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;p==="style"?s.d.S(h,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:b,integrity:j,fetchPriority:_}):p==="script"&&s.d.X(h,{crossOrigin:b,integrity:j,fetchPriority:_,nonce:typeof g.nonce=="string"?g.nonce:void 0})}},sn.preinitModule=function(h,g){if(typeof h=="string")if(typeof g=="object"&&g!==null){if(g.as==null||g.as==="script"){var p=m(g.as,g.crossOrigin);s.d.M(h,{crossOrigin:p,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0})}}else g==null&&s.d.M(h)},sn.preload=function(h,g){if(typeof h=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var p=g.as,b=m(p,g.crossOrigin);s.d.L(h,p,{crossOrigin:b,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0,type:typeof g.type=="string"?g.type:void 0,fetchPriority:typeof g.fetchPriority=="string"?g.fetchPriority:void 0,referrerPolicy:typeof g.referrerPolicy=="string"?g.referrerPolicy:void 0,imageSrcSet:typeof g.imageSrcSet=="string"?g.imageSrcSet:void 0,imageSizes:typeof g.imageSizes=="string"?g.imageSizes:void 0,media:typeof g.media=="string"?g.media:void 0})}},sn.preloadModule=function(h,g){if(typeof h=="string")if(g){var p=m(g.as,g.crossOrigin);s.d.m(h,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:p,integrity:typeof g.integrity=="string"?g.integrity:void 0})}else s.d.m(h)},sn.requestFormReset=function(h){s.d.r(h)},sn.unstable_batchedUpdates=function(h,g){return h(g)},sn.useFormState=function(h,g,p){return d.H.useFormState(h,g,p)},sn.useFormStatus=function(){return d.H.useHostTransitionStatus()},sn.version="19.2.1",sn}var Iv;function H_(){if(Iv)return Vf.exports;Iv=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__=="undefined"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(a){console.error(a)}}return t(),Vf.exports=BN(),Vf.exports}var zv;function UN(){if(zv)return $0;zv=1;var t=zN(),a=Oh(),r=H_();function s(n){var o="https://react.dev/errors/"+n;if(1<arguments.length){o+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)o+="&args[]="+encodeURIComponent(arguments[u])}return"Minified React error #"+n+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function c(n){var o=n,u=n;if(n.alternate)for(;o.return;)o=o.return;else{n=o;do o=n,(o.flags&4098)!==0&&(u=o.return),n=o.return;while(n)}return o.tag===3?u:null}function d(n){if(n.tag===13){var o=n.memoizedState;if(o===null&&(n=n.alternate,n!==null&&(o=n.memoizedState)),o!==null)return o.dehydrated}return null}function m(n){if(n.tag===31){var o=n.memoizedState;if(o===null&&(n=n.alternate,n!==null&&(o=n.memoizedState)),o!==null)return o.dehydrated}return null}function h(n){if(c(n)!==n)throw Error(s(188))}function g(n){var o=n.alternate;if(!o){if(o=c(n),o===null)throw Error(s(188));return o!==n?null:n}for(var u=n,x=o;;){var w=u.return;if(w===null)break;var S=w.alternate;if(S===null){if(x=w.return,x!==null){u=x;continue}break}if(w.child===S.child){for(S=w.child;S;){if(S===u)return h(w),n;if(S===x)return h(w),o;S=S.sibling}throw Error(s(188))}if(u.return!==x.return)u=w,x=S;else{for(var q=!1,ge=w.child;ge;){if(ge===u){q=!0,u=w,x=S;break}if(ge===x){q=!0,x=w,u=S;break}ge=ge.sibling}if(!q){for(ge=S.child;ge;){if(ge===u){q=!0,u=S,x=w;break}if(ge===x){q=!0,x=S,u=w;break}ge=ge.sibling}if(!q)throw Error(s(189))}}if(u.alternate!==x)throw Error(s(190))}if(u.tag!==3)throw Error(s(188));return u.stateNode.current===u?n:o}function p(n){var o=n.tag;if(o===5||o===26||o===27||o===6)return n;for(n=n.child;n!==null;){if(o=p(n),o!==null)return o;n=n.sibling}return null}var b=Object.assign,j=Symbol.for("react.element"),_=Symbol.for("react.transitional.element"),N=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),D=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),E=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),Y=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),ne=Symbol.for("react.memo_cache_sentinel"),ye=Symbol.iterator;function he(n){return n===null||typeof n!="object"?null:(n=ye&&n[ye]||n["@@iterator"],typeof n=="function"?n:null)}var ce=Symbol.for("react.client.reference");function se(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===ce?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case k:return"Fragment";case D:return"Profiler";case C:return"StrictMode";case R:return"Suspense";case Y:return"SuspenseList";case J:return"Activity"}if(typeof n=="object")switch(n.$$typeof){case N:return"Portal";case E:return n.displayName||"Context";case T:return(n._context.displayName||"Context")+".Consumer";case O:var o=n.render;return n=n.displayName,n||(n=o.displayName||o.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case P:return o=n.displayName||null,o!==null?o:se(n.type)||"Memo";case U:o=n._payload,n=n._init;try{return se(n(o))}catch(u){}}return null}var ee=Array.isArray,te=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},oe=[],ae=-1;function F(n){return{current:n}}function M(n){0>ae||(n.current=oe[ae],oe[ae]=null,ae--)}function B(n,o){ae++,oe[ae]=n.current,n.current=o}var X=F(null),K=F(null),we=F(null),be=F(null);function ke(n,o){switch(B(we,o),B(K,n),B(X,null),o.nodeType){case 9:case 11:n=(n=o.documentElement)&&(n=n.namespaceURI)?Xb(n):0;break;default:if(n=o.tagName,o=o.namespaceURI)o=Xb(o),n=Kb(o,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}M(X),B(X,n)}function Me(){M(X),M(K),M(we)}function z(n){n.memoizedState!==null&&B(be,n);var o=X.current,u=Kb(o,n.type);o!==u&&(B(K,n),B(X,u))}function Ne(n){K.current===n&&(M(X),M(K)),be.current===n&&(M(be),F0._currentValue=I)}var Xe,gt;function St(n){if(Xe===void 0)try{throw Error()}catch(u){var o=u.stack.trim().match(/\n( *(at )?)/);Xe=o&&o[1]||"",gt=-1<u.stack.indexOf(`
at`)?" (<anonymous>)":-1<u.stack.indexOf("@")?"@unknown:0:0":""}return`
`+Xe+n+gt}var Ht=!1;function Mt(n,o){if(!n||Ht)return"";Ht=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var x={DetermineComponentFrameRoot:function(){try{if(o){var Et=function(){throw Error()};if(Object.defineProperty(Et.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Et,[])}catch(ut){var at=ut}Reflect.construct(n,[],Et)}else{try{Et.call()}catch(ut){at=ut}n.call(Et.prototype)}}else{try{throw Error()}catch(ut){at=ut}(Et=n())&&typeof Et.catch=="function"&&Et.catch(function(){})}}catch(ut){if(ut&&at&&typeof ut.stack=="string")return[ut.stack,at.stack]}return[null,null]}};x.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var w=Object.getOwnPropertyDescriptor(x.DetermineComponentFrameRoot,"name");w&&w.configurable&&Object.defineProperty(x.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var S=x.DetermineComponentFrameRoot(),q=S[0],ge=S[1];if(q&&ge){var Ae=q.split(`
`),Ke=ge.split(`
`);for(w=x=0;x<Ae.length&&!Ae[x].includes("DetermineComponentFrameRoot");)x++;for(;w<Ke.length&&!Ke[w].includes("DetermineComponentFrameRoot");)w++;if(x===Ae.length||w===Ke.length)for(x=Ae.length-1,w=Ke.length-1;1<=x&&0<=w&&Ae[x]!==Ke[w];)w--;for(;1<=x&&0<=w;x--,w--)if(Ae[x]!==Ke[w]){if(x!==1||w!==1)do if(x--,w--,0>w||Ae[x]!==Ke[w]){var vt=`
`+Ae[x].replace(" at new "," at ");return n.displayName&&vt.includes("<anonymous>")&&(vt=vt.replace("<anonymous>",n.displayName)),vt}while(1<=x&&0<=w);break}}}finally{Ht=!1,Error.prepareStackTrace=u}return(u=n?n.displayName||n.name:"")?St(u):""}function Te(n,o){switch(n.tag){case 26:case 27:case 5:return St(n.type);case 16:return St("Lazy");case 13:return n.child!==o&&o!==null?St("Suspense Fallback"):St("Suspense");case 19:return St("SuspenseList");case 0:case 15:return Mt(n.type,!1);case 11:return Mt(n.type.render,!1);case 1:return Mt(n.type,!0);case 31:return St("Activity");default:return""}}function Qt(n){try{var o="",u=null;do o+=Te(n,u),u=n,n=n.return;while(n);return o}catch(x){return`
Error generating stack: `+x.message+`
`+x.stack}}var zt=Object.prototype.hasOwnProperty,Wt=t.unstable_scheduleCallback,Vt=t.unstable_cancelCallback,va=t.unstable_shouldYield,ta=t.unstable_requestPaint,sa=t.unstable_now,ra=t.unstable_getCurrentPriorityLevel,Ye=t.unstable_ImmediatePriority,ft=t.unstable_UserBlockingPriority,$t=t.unstable_NormalPriority,na=t.unstable_LowPriority,Ze=t.unstable_IdlePriority,lt=t.log,aa=t.unstable_setDisableYieldValue,Ie=null,Nt=null;function ve(n){if(typeof lt=="function"&&aa(n),Nt&&typeof Nt.setStrictMode=="function")try{Nt.setStrictMode(Ie,n)}catch(o){}}var Oe=Math.clz32?Math.clz32:Be,ht=Math.log,et=Math.LN2;function Be(n){return n>>>=0,n===0?32:31-(ht(n)/et|0)|0}var kt=256,it=262144,xt=4194304;function Dt(n){var o=n&42;if(o!==0)return o;switch(n&-n){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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function Ot(n,o,u){var x=n.pendingLanes;if(x===0)return 0;var w=0,S=n.suspendedLanes,q=n.pingedLanes;n=n.warmLanes;var ge=x&134217727;return ge!==0?(x=ge&~S,x!==0?w=Dt(x):(q&=ge,q!==0?w=Dt(q):u||(u=ge&~n,u!==0&&(w=Dt(u))))):(ge=x&~S,ge!==0?w=Dt(ge):q!==0?w=Dt(q):u||(u=x&~n,u!==0&&(w=Dt(u)))),w===0?0:o!==0&&o!==w&&(o&S)===0&&(S=w&-w,u=o&-o,S>=u||S===32&&(u&4194048)!==0)?o:w}function Rt(n,o){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&o)===0}function De(n,o){switch(n){case 1:case 2:case 4:case 8:case 64:return o+250;case 16:case 32: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 o+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Qe(){var n=xt;return xt<<=1,(xt&62914560)===0&&(xt=4194304),n}function fe(n){for(var o=[],u=0;31>u;u++)o.push(n);return o}function re(n,o){n.pendingLanes|=o,o!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function Ee(n,o,u,x,w,S){var q=n.pendingLanes;n.pendingLanes=u,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=u,n.entangledLanes&=u,n.errorRecoveryDisabledLanes&=u,n.shellSuspendCounter=0;var ge=n.entanglements,Ae=n.expirationTimes,Ke=n.hiddenUpdates;for(u=q&~u;0<u;){var vt=31-Oe(u),Et=1<<vt;ge[vt]=0,Ae[vt]=-1;var at=Ke[vt];if(at!==null)for(Ke[vt]=null,vt=0;vt<at.length;vt++){var ut=at[vt];ut!==null&&(ut.lane&=-536870913)}u&=~Et}x!==0&&Ge(n,x,0),S!==0&&w===0&&n.tag!==0&&(n.suspendedLanes|=S&~(q&~o))}function Ge(n,o,u){n.pendingLanes|=o,n.suspendedLanes&=~o;var x=31-Oe(o);n.entangledLanes|=o,n.entanglements[x]=n.entanglements[x]|1073741824|u&261930}function ct(n,o){var u=n.entangledLanes|=o;for(n=n.entanglements;u;){var x=31-Oe(u),w=1<<x;w&o|n[x]&o&&(n[x]|=o),u&=~w}}function It(n,o){var u=o&-o;return u=(u&42)!==0?1:st(u),(u&(n.suspendedLanes|o))!==0?0:u}function st(n){switch(n){case 2:n=1;break;case 8:n=4;break;case 32:n=16;break;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:n=128;break;case 268435456:n=134217728;break;default:n=0}return n}function rt(n){return n&=-n,2<n?8<n?(n&134217727)!==0?32:268435456:8:2}function V(){var n=W.p;return n!==0?n:(n=window.event,n===void 0?32:_v(n.type))}function me(n,o){var u=W.p;try{return W.p=n,o()}finally{W.p=u}}var de=Math.random().toString(36).slice(2),ie="__reactFiber$"+de,xe="__reactProps$"+de,_e="__reactContainer$"+de,He="__reactEvents$"+de,Ue="__reactListeners$"+de,Pe="__reactHandles$"+de,Re="__reactResources$"+de,We="__reactMarker$"+de;function _t(n){delete n[ie],delete n[xe],delete n[He],delete n[Ue],delete n[Pe]}function Ft(n){var o=n[ie];if(o)return o;for(var u=n.parentNode;u;){if(o=u[_e]||u[ie]){if(u=o.alternate,o.child!==null||u!==null&&u.child!==null)for(n=nv(n);n!==null;){if(u=n[ie])return u;n=nv(n)}return o}n=u,u=n.parentNode}return null}function dt(n){if(n=n[ie]||n[_e]){var o=n.tag;if(o===5||o===6||o===13||o===31||o===26||o===27||o===3)return n}return null}function pt(n){var o=n.tag;if(o===5||o===26||o===27||o===6)return n.stateNode;throw Error(s(33))}function At(n){var o=n[Re];return o||(o=n[Re]={hoistableStyles:new Map,hoistableScripts:new Map}),o}function Zt(n){n[We]=!0}var Fa=new Set,La={};function Ya(n,o){gr(n,o),gr(n+"Capture",o)}function gr(n,o){for(La[n]=o,n=0;n<o.length;n++)Fa.add(o[n])}var ar=RegExp("^[: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]*$"),Ir={},kr={};function hs(n){return zt.call(kr,n)?!0:zt.call(Ir,n)?!1:ar.test(n)?kr[n]=!0:(Ir[n]=!0,!1)}function ha(n,o,u){if(hs(o))if(u===null)n.removeAttribute(o);else{switch(typeof u){case"undefined":case"function":case"symbol":n.removeAttribute(o);return;case"boolean":var x=o.toLowerCase().slice(0,5);if(x!=="data-"&&x!=="aria-"){n.removeAttribute(o);return}}n.setAttribute(o,""+u)}}function Ia(n,o,u){if(u===null)n.removeAttribute(o);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(o);return}n.setAttribute(o,""+u)}}function qr(n,o,u,x){if(x===null)n.removeAttribute(u);else{switch(typeof x){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(u);return}n.setAttributeNS(o,u,""+x)}}function fr(n){switch(typeof n){case"bigint":case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function G(n){var o=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function $e(n,o,u){var x=Object.getOwnPropertyDescriptor(n.constructor.prototype,o);if(!n.hasOwnProperty(o)&&typeof x!="undefined"&&typeof x.get=="function"&&typeof x.set=="function"){var w=x.get,S=x.set;return Object.defineProperty(n,o,{configurable:!0,get:function(){return w.call(this)},set:function(q){u=""+q,S.call(this,q)}}),Object.defineProperty(n,o,{enumerable:x.enumerable}),{getValue:function(){return u},setValue:function(q){u=""+q},stopTracking:function(){n._valueTracker=null,delete n[o]}}}}function Bt(n){if(!n._valueTracker){var o=G(n)?"checked":"value";n._valueTracker=$e(n,o,""+n[o])}}function Kt(n){if(!n)return!1;var o=n._valueTracker;if(!o)return!0;var u=o.getValue(),x="";return n&&(x=G(n)?n.checked?"true":"false":n.value),n=x,n!==u?(o.setValue(n),!0):!1}function _a(n){if(n=n||(typeof document!="undefined"?document:void 0),typeof n=="undefined")return null;try{return n.activeElement||n.body}catch(o){return n.body}}var zr=/[\n"\\]/g;function Aa(n){return n.replace(zr,function(o){return"\\"+o.charCodeAt(0).toString(16)+" "})}function Ds(n,o,u,x,w,S,q,ge){n.name="",q!=null&&typeof q!="function"&&typeof q!="symbol"&&typeof q!="boolean"?n.type=q:n.removeAttribute("type"),o!=null?q==="number"?(o===0&&n.value===""||n.value!=o)&&(n.value=""+fr(o)):n.value!==""+fr(o)&&(n.value=""+fr(o)):q!=="submit"&&q!=="reset"||n.removeAttribute("value"),o!=null?wa(n,q,fr(o)):u!=null?wa(n,q,fr(u)):x!=null&&n.removeAttribute("value"),w==null&&S!=null&&(n.defaultChecked=!!S),w!=null&&(n.checked=w&&typeof w!="function"&&typeof w!="symbol"),ge!=null&&typeof ge!="function"&&typeof ge!="symbol"&&typeof ge!="boolean"?n.name=""+fr(ge):n.removeAttribute("name")}function xr(n,o,u,x,w,S,q,ge){if(S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(n.type=S),o!=null||u!=null){if(!(S!=="submit"&&S!=="reset"||o!=null)){Bt(n);return}u=u!=null?""+fr(u):"",o=o!=null?""+fr(o):u,ge||o===n.value||(n.value=o),n.defaultValue=o}x=x!=null?x:w,x=typeof x!="function"&&typeof x!="symbol"&&!!x,n.checked=ge?n.checked:!!x,n.defaultChecked=!!x,q!=null&&typeof q!="function"&&typeof q!="symbol"&&typeof q!="boolean"&&(n.name=q),Bt(n)}function wa(n,o,u){o==="number"&&_a(n.ownerDocument)===n||n.defaultValue===""+u||(n.defaultValue=""+u)}function Za(n,o,u,x){if(n=n.options,o){o={};for(var w=0;w<u.length;w++)o["$"+u[w]]=!0;for(u=0;u<n.length;u++)w=o.hasOwnProperty("$"+n[u].value),n[u].selected!==w&&(n[u].selected=w),w&&x&&(n[u].defaultSelected=!0)}else{for(u=""+fr(u),o=null,w=0;w<n.length;w++){if(n[w].value===u){n[w].selected=!0,x&&(n[w].defaultSelected=!0);return}o!==null||n[w].disabled||(o=n[w])}o!==null&&(o.selected=!0)}}function cn(n,o,u){if(o!=null&&(o=""+fr(o),o!==n.value&&(n.value=o),u==null)){n.defaultValue!==o&&(n.defaultValue=o);return}n.defaultValue=u!=null?""+fr(u):""}function _s(n,o,u,x){if(o==null){if(x!=null){if(u!=null)throw Error(s(92));if(ee(x)){if(1<x.length)throw Error(s(93));x=x[0]}u=x}u==null&&(u=""),o=u}u=fr(o),n.defaultValue=u,x=n.textContent,x===u&&x!==""&&x!==null&&(n.value=x),Bt(n)}function Gr(n,o){if(o){var u=n.firstChild;if(u&&u===n.lastChild&&u.nodeType===3){u.nodeValue=o;return}}n.textContent=o}var yo=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function ii(n,o,u){var x=o.indexOf("--")===0;u==null||typeof u=="boolean"||u===""?x?n.setProperty(o,""):o==="float"?n.cssFloat="":n[o]="":x?n.setProperty(o,u):typeof u!="number"||u===0||yo.has(o)?o==="float"?n.cssFloat=u:n[o]=(""+u).trim():n[o]=u+"px"}function Ms(n,o,u){if(o!=null&&typeof o!="object")throw Error(s(62));if(n=n.style,u!=null){for(var x in u)!u.hasOwnProperty(x)||o!=null&&o.hasOwnProperty(x)||(x.indexOf("--")===0?n.setProperty(x,""):x==="float"?n.cssFloat="":n[x]="");for(var w in o)x=o[w],o.hasOwnProperty(w)&&u[w]!==x&&ii(n,w,x)}else for(var S in o)o.hasOwnProperty(S)&&ii(n,S,o[S])}function oi(n){if(n.indexOf("-")===-1)return!1;switch(n){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 wi=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),ze=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function yt(n){return ze.test(""+n)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":n}function Sa(){}var _r=null;function Sr(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Yr=null,oa=null;function Zr(n){var o=dt(n);if(o&&(n=o.stateNode)){var u=n[xe]||null;e:switch(n=o.stateNode,o.type){case"input":if(Ds(n,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name),o=u.name,u.type==="radio"&&o!=null){for(u=n;u.parentNode;)u=u.parentNode;for(u=u.querySelectorAll('input[name="'+Aa(""+o)+'"][type="radio"]'),o=0;o<u.length;o++){var x=u[o];if(x!==n&&x.form===n.form){var w=x[xe]||null;if(!w)throw Error(s(90));Ds(x,w.value,w.defaultValue,w.defaultValue,w.checked,w.defaultChecked,w.type,w.name)}}for(o=0;o<u.length;o++)x=u[o],x.form===n.form&&Kt(x)}break e;case"textarea":cn(n,u.value,u.defaultValue);break e;case"select":o=u.value,o!=null&&Za(n,!!u.multiple,o,!1)}}}var za=!1;function _n(n,o,u){if(za)return n(o,u);za=!0;try{var x=n(o);return x}finally{if(za=!1,(Yr!==null||oa!==null)&&(hm(),Yr&&(o=Yr,n=oa,oa=Yr=null,Zr(o),n)))for(o=0;o<n.length;o++)Zr(n[o])}}function wn(n,o){var u=n.stateNode;if(u===null)return null;var x=u[xe]||null;if(x===null)return null;u=x[o];e:switch(o){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(x=!x.disabled)||(n=n.type,x=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!x;break e;default:n=!1}if(n)return null;if(u&&typeof u!="function")throw Error(s(231,o,typeof u));return u}var ws=!(typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"),ki=!1;if(ws)try{var gs={};Object.defineProperty(gs,"passive",{get:function(){ki=!0}}),window.addEventListener("test",gs,gs),window.removeEventListener("test",gs,gs)}catch(n){ki=!1}var Ls=null,zn=null,Cr=null;function Bn(){if(Cr)return Cr;var n,o=zn,u=o.length,x,w="value"in Ls?Ls.value:Ls.textContent,S=w.length;for(n=0;n<u&&o[n]===w[n];n++);var q=u-n;for(x=1;x<=q&&o[u-x]===w[S-x];x++);return Cr=w.slice(n,1<x?1-x:void 0)}function Un(n){var o=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&o===13&&(n=13)):n=o,n===10&&(n=13),32<=n||n===13?n:0}function Wi(){return!0}function Rl(){return!1}function Qr(n){function o(u,x,w,S,q){this._reactName=u,this._targetInst=w,this.type=x,this.nativeEvent=S,this.target=q,this.currentTarget=null;for(var ge in n)n.hasOwnProperty(ge)&&(u=n[ge],this[ge]=u?u(S):S[ge]);return this.isDefaultPrevented=(S.defaultPrevented!=null?S.defaultPrevented:S.returnValue===!1)?Wi:Rl,this.isPropagationStopped=Rl,this}return b(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var u=this.nativeEvent;u&&(u.preventDefault?u.preventDefault():typeof u.returnValue!="unknown"&&(u.returnValue=!1),this.isDefaultPrevented=Wi)},stopPropagation:function(){var u=this.nativeEvent;u&&(u.stopPropagation?u.stopPropagation():typeof u.cancelBubble!="unknown"&&(u.cancelBubble=!0),this.isPropagationStopped=Wi)},persist:function(){},isPersistent:Wi}),o}var kn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},bo=Qr(kn),Vi=b({},kn,{view:0,detail:0}),Ra=Qr(Vi),Pl,Rs,es,dn=b({},Vi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Bl,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==es&&(es&&n.type==="mousemove"?(Pl=n.screenX-es.screenX,Rs=n.screenY-es.screenY):Rs=Pl=0,es=n),Pl)},movementY:function(n){return"movementY"in n?n.movementY:Rs}}),qi=Qr(dn),vo=b({},dn,{dataTransfer:0}),li=Qr(vo),Fc=b({},Vi,{relatedTarget:0}),Fl=Qr(Fc),Qd=b({},kn,{animationName:0,elapsedTime:0,pseudoElement:0}),Il=Qr(Qd),ci=b({},kn,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),fs=Qr(ci),tl=b({},kn,{data:0}),_o=Qr(tl),$n={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ic={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"},zc={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function zl(n){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(n):(n=zc[n])?!!o[n]:!1}function Bl(){return zl}var Bc=b({},Vi,{key:function(n){if(n.key){var o=$n[n.key]||n.key;if(o!=="Unidentified")return o}return n.type==="keypress"?(n=Un(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?Ic[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Bl,charCode:function(n){return n.type==="keypress"?Un(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Un(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),Uc=Qr(Bc),e0=b({},dn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),al=Qr(e0),Ul=b({},Vi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Bl}),t0=Qr(Ul),$c=b({},kn,{propertyName:0,elapsedTime:0,pseudoElement:0}),Hc=Qr($c),wo=b({},dn,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),un=Qr(wo),$l=b({},kn,{newState:0,oldState:0}),di=Qr($l),tn=[9,13,27,32],rl=ws&&"CompositionEvent"in window,Gi=null;ws&&"documentMode"in document&&(Gi=document.documentMode);var a0=ws&&"TextEvent"in window&&!Gi,ko=ws&&(!rl||Gi&&8<Gi&&11>=Gi),jr=" ",Hl=!1;function Wc(n,o){switch(n){case"keyup":return tn.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wl(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Yi=!1;function mn(n,o){switch(n){case"compositionend":return Wl(o);case"keypress":return o.which!==32?null:(Hl=!0,jr);case"textInput":return n=o.data,n===jr&&Hl?null:n;default:return null}}function Zi(n,o){if(Yi)return n==="compositionend"||!rl&&Wc(n,o)?(n=Bn(),Cr=zn=Ls=null,Yi=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return ko&&o.locale!=="ko"?null:o.data;default:return null}}var r0={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 jn(n){var o=n&&n.nodeName&&n.nodeName.toLowerCase();return o==="input"?!!r0[n.type]:o==="textarea"}function Vc(n,o,u,x){Yr?oa?oa.push(x):oa=[x]:Yr=x,o=vm(o,"onChange"),0<o.length&&(u=new bo("onChange","change",null,u,x),n.push({event:u,listeners:o}))}var Ps=null,jo=null;function No(n){Vb(n,0)}function So(n){var o=pt(n);if(Kt(o))return n}function Ji(n,o){if(n==="change")return o}var qc=!1;if(ws){var hn;if(ws){var Xi="oninput"in document;if(!Xi){var Nn=document.createElement("div");Nn.setAttribute("oninput","return;"),Xi=typeof Nn.oninput=="function"}hn=Xi}else hn=!1;qc=hn&&(!document.documentMode||9<document.documentMode)}function Hn(){Ps&&(Ps.detachEvent("onpropertychange",sl),jo=Ps=null)}function sl(n){if(n.propertyName==="value"&&So(jo)){var o=[];Vc(o,jo,n,Sr(n)),_n(No,o)}}function Fs(n,o,u){n==="focusin"?(Hn(),Ps=o,jo=u,Ps.attachEvent("onpropertychange",sl)):n==="focusout"&&Hn()}function s0(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return So(jo)}function Ki(n,o){if(n==="click")return So(o)}function Iu(n,o){if(n==="input"||n==="change")return So(o)}function Wn(n,o){return n===o&&(n!==0||1/n===1/o)||n!==n&&o!==o}var ts=typeof Object.is=="function"?Object.is:Wn;function Qi(n,o){if(ts(n,o))return!0;if(typeof n!="object"||n===null||typeof o!="object"||o===null)return!1;var u=Object.keys(n),x=Object.keys(o);if(u.length!==x.length)return!1;for(x=0;x<u.length;x++){var w=u[x];if(!zt.call(o,w)||!ts(n[w],o[w]))return!1}return!0}function nl(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function eo(n,o){var u=nl(n);n=0;for(var x;u;){if(u.nodeType===3){if(x=n+u.textContent.length,n<=o&&x>=o)return{node:u,offset:o-n};n=x}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=nl(u)}}function to(n,o){return n&&o?n===o?!0:n&&n.nodeType===3?!1:o&&o.nodeType===3?to(n,o.parentNode):"contains"in n?n.contains(o):n.compareDocumentPosition?!!(n.compareDocumentPosition(o)&16):!1:!1}function ji(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var o=_a(n.document);o instanceof n.HTMLIFrameElement;){try{var u=typeof o.contentWindow.location.href=="string"}catch(x){u=!1}if(u)n=o.contentWindow;else break;o=_a(n.document)}return o}function ui(n){var o=n&&n.nodeName&&n.nodeName.toLowerCase();return o&&(o==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||o==="textarea"||n.contentEditable==="true")}var Co=ws&&"documentMode"in document&&11>=document.documentMode,Vn=null,To=null,Z=null,pe=!1;function je(n,o,u){var x=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;pe||Vn==null||Vn!==_a(x)||(x=Vn,"selectionStart"in x&&ui(x)?x={start:x.selectionStart,end:x.selectionEnd}:(x=(x.ownerDocument&&x.ownerDocument.defaultView||window).getSelection(),x={anchorNode:x.anchorNode,anchorOffset:x.anchorOffset,focusNode:x.focusNode,focusOffset:x.focusOffset}),Z&&Qi(Z,x)||(Z=x,x=vm(To,"onSelect"),0<x.length&&(o=new bo("onSelect","select",null,o,u),n.push({event:o,listeners:x}),o.target=Vn)))}function Ct(n,o){var u={};return u[n.toLowerCase()]=o.toLowerCase(),u["Webkit"+n]="webkit"+o,u["Moz"+n]="moz"+o,u}var Jt={animationend:Ct("Animation","AnimationEnd"),animationiteration:Ct("Animation","AnimationIteration"),animationstart:Ct("Animation","AnimationStart"),transitionrun:Ct("Transition","TransitionRun"),transitionstart:Ct("Transition","TransitionStart"),transitioncancel:Ct("Transition","TransitionCancel"),transitionend:Ct("Transition","TransitionEnd")},Pt={},ma={};ws&&(ma=document.createElement("div").style,"AnimationEvent"in window||(delete Jt.animationend.animation,delete Jt.animationiteration.animation,delete Jt.animationstart.animation),"TransitionEvent"in window||delete Jt.transitionend.transition);function xa(n){if(Pt[n])return Pt[n];if(!Jt[n])return n;var o=Jt[n],u;for(u in o)if(o.hasOwnProperty(u)&&u in ma)return Pt[n]=o[u];return n}var Tr=xa("animationend"),Ba=xa("animationiteration"),Br=xa("animationstart"),an=xa("transitionrun"),as=xa("transitionstart"),Is=xa("transitioncancel"),Pa=xa("transitionend"),qn=new Map,Rr="abort auxClick beforeToggle 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(" ");Rr.push("scrollEnd");function zs(n,o){qn.set(n,o),Ya(o,[n])}var Bs=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var o=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof n=="object"&&n!==null&&typeof n.message=="string"?String(n.message):String(n),error:n});if(!window.dispatchEvent(o))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)},Nr=[],xs=0,Gc=0;function Vl(){for(var n=xs,o=Gc=xs=0;o<n;){var u=Nr[o];Nr[o++]=null;var x=Nr[o];Nr[o++]=null;var w=Nr[o];Nr[o++]=null;var S=Nr[o];if(Nr[o++]=null,x!==null&&w!==null){var q=x.pending;q===null?w.next=w:(w.next=q.next,q.next=w),x.pending=w}S!==0&&il(u,w,S)}}function ao(n,o,u,x){Nr[xs++]=n,Nr[xs++]=o,Nr[xs++]=u,Nr[xs++]=x,Gc|=x,n.lanes|=x,n=n.alternate,n!==null&&(n.lanes|=x)}function n0(n,o,u,x){return ao(n,o,u,x),ql(n)}function mi(n,o){return ao(n,null,null,o),ql(n)}function il(n,o,u){n.lanes|=u;var x=n.alternate;x!==null&&(x.lanes|=u);for(var w=!1,S=n.return;S!==null;)S.childLanes|=u,x=S.alternate,x!==null&&(x.childLanes|=u),S.tag===22&&(n=S.stateNode,n===null||n._visibility&1||(w=!0)),n=S,S=S.return;return n.tag===3?(S=n.stateNode,w&&o!==null&&(w=31-Oe(u),n=S.hiddenUpdates,x=n[w],x===null?n[w]=[o]:x.push(o),o.lane=u|536870912),S):null}function ql(n){if(50<A0)throw A0=0,of=null,Error(s(185));for(var o=n.return;o!==null;)n=o,o=n.return;return n.tag===3?n.stateNode:null}var Eo={};function ng(n,o,u,x){this.tag=n,this.key=u,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=x,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function rn(n,o,u,x){return new ng(n,o,u,x)}function Yc(n){return n=n.prototype,!(!n||!n.isReactComponent)}function hi(n,o){var u=n.alternate;return u===null?(u=rn(n.tag,o,n.key,n.mode),u.elementType=n.elementType,u.type=n.type,u.stateNode=n.stateNode,u.alternate=n,n.alternate=u):(u.pendingProps=o,u.type=n.type,u.flags=0,u.subtreeFlags=0,u.deletions=null),u.flags=n.flags&65011712,u.childLanes=n.childLanes,u.lanes=n.lanes,u.child=n.child,u.memoizedProps=n.memoizedProps,u.memoizedState=n.memoizedState,u.updateQueue=n.updateQueue,o=n.dependencies,u.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},u.sibling=n.sibling,u.index=n.index,u.ref=n.ref,u.refCleanup=n.refCleanup,u}function i0(n,o){n.flags&=65011714;var u=n.alternate;return u===null?(n.childLanes=0,n.lanes=o,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=u.childLanes,n.lanes=u.lanes,n.child=u.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=u.memoizedProps,n.memoizedState=u.memoizedState,n.updateQueue=u.updateQueue,n.type=u.type,o=u.dependencies,n.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),n}function Gl(n,o,u,x,w,S){var q=0;if(x=n,typeof n=="function")Yc(n)&&(q=1);else if(typeof n=="string")q=yN(n,u,X.current)?26:n==="html"||n==="head"||n==="body"?27:5;else e:switch(n){case J:return n=rn(31,u,o,w),n.elementType=J,n.lanes=S,n;case k:return Ao(u.children,w,S,o);case C:q=8,w|=24;break;case D:return n=rn(12,u,o,w|2),n.elementType=D,n.lanes=S,n;case R:return n=rn(13,u,o,w),n.elementType=R,n.lanes=S,n;case Y:return n=rn(19,u,o,w),n.elementType=Y,n.lanes=S,n;default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case E:q=10;break e;case T:q=9;break e;case O:q=11;break e;case P:q=14;break e;case U:q=16,x=null;break e}q=29,u=Error(s(130,n===null?"null":typeof n,"")),x=null}return o=rn(q,u,o,w),o.elementType=n,o.type=x,o.lanes=S,o}function Ao(n,o,u,x){return n=rn(7,n,x,o),n.lanes=u,n}function Zc(n,o,u){return n=rn(6,n,null,o),n.lanes=u,n}function o0(n){var o=rn(18,null,null,0);return o.stateNode=n,o}function l0(n,o,u){return o=rn(4,n.children!==null?n.children:[],n.key,o),o.lanes=u,o.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},o}var l=new WeakMap;function f(n,o){if(typeof n=="object"&&n!==null){var u=l.get(n);return u!==void 0?u:(o={value:n,source:o,stack:Qt(o)},l.set(n,o),o)}return{value:n,source:o,stack:Qt(o)}}var v=[],A=0,H=null,le=0,Ce=[],qe=0,tt=null,Tt=1,Xt="";function ua(n,o){v[A++]=le,v[A++]=H,H=n,le=o}function Oa(n,o,u){Ce[qe++]=Tt,Ce[qe++]=Xt,Ce[qe++]=tt,tt=n;var x=Tt;n=Xt;var w=32-Oe(x)-1;x&=~(1<<w),u+=1;var S=32-Oe(o)+w;if(30<S){var q=w-w%5;S=(x&(1<<q)-1).toString(32),x>>=q,w-=q,Tt=1<<32-Oe(o)+w|u<<w|x,Xt=S+n}else Tt=1<<S|u<<w|x,Xt=n}function ps(n){n.return!==null&&(ua(n,1),Oa(n,1,0))}function Ur(n){for(;n===H;)H=v[--A],v[A]=null,le=v[--A],v[A]=null;for(;n===tt;)tt=Ce[--qe],Ce[qe]=null,Xt=Ce[--qe],Ce[qe]=null,Tt=Ce[--qe],Ce[qe]=null}function gn(n,o){Ce[qe++]=Tt,Ce[qe++]=Xt,Ce[qe++]=tt,Tt=o.id,Xt=o.overflow,tt=n}var Xa=null,Ka=null,Ua=!1,ro=null,Sn=!1,Jc=Error(s(519));function so(n){var o=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Yl(f(o,n)),Jc}function c0(n){var o=n.stateNode,u=n.type,x=n.memoizedProps;switch(o[ie]=n,o[xe]=x,u){case"dialog":Ha("cancel",o),Ha("close",o);break;case"iframe":case"object":case"embed":Ha("load",o);break;case"video":case"audio":for(u=0;u<D0.length;u++)Ha(D0[u],o);break;case"source":Ha("error",o);break;case"img":case"image":case"link":Ha("error",o),Ha("load",o);break;case"details":Ha("toggle",o);break;case"input":Ha("invalid",o),xr(o,x.value,x.defaultValue,x.checked,x.defaultChecked,x.type,x.name,!0);break;case"select":Ha("invalid",o);break;case"textarea":Ha("invalid",o),_s(o,x.value,x.defaultValue,x.children)}u=x.children,typeof u!="string"&&typeof u!="number"&&typeof u!="bigint"||o.textContent===""+u||x.suppressHydrationWarning===!0||Zb(o.textContent,u)?(x.popover!=null&&(Ha("beforetoggle",o),Ha("toggle",o)),x.onScroll!=null&&Ha("scroll",o),x.onScrollEnd!=null&&Ha("scrollend",o),x.onClick!=null&&(o.onclick=Sa),o=!0):o=!1,o||so(n,!0)}function Pr(n){for(Xa=n.return;Xa;)switch(Xa.tag){case 5:case 31:case 13:Sn=!1;return;case 27:case 3:Sn=!0;return;default:Xa=Xa.return}}function Ni(n){if(n!==Xa)return!1;if(!Ua)return Pr(n),Ua=!0,!1;var o=n.tag,u;if((u=o!==3&&o!==27)&&((u=o===5)&&(u=n.type,u=!(u!=="form"&&u!=="button")||wf(n.type,n.memoizedProps)),u=!u),u&&Ka&&so(n),Pr(n),o===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(317));Ka=sv(n)}else if(o===31){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(317));Ka=sv(n)}else o===27?(o=Ka,vl(n.type)?(n=Cf,Cf=null,Ka=n):Ka=o):Ka=Xa?fi(n.stateNode.nextSibling):null;return!0}function Oo(){Ka=Xa=null,Ua=!1}function d0(){var n=ro;return n!==null&&(An===null?An=n:An.push.apply(An,n),ro=null),n}function Yl(n){ro===null?ro=[n]:ro.push(n)}var Zl=F(null),no=null,Si=null;function ol(n,o,u){B(Zl,o._currentValue),o._currentValue=u}function Do(n){n._currentValue=Zl.current,M(Zl)}function ig(n,o,u){for(;n!==null;){var x=n.alternate;if((n.childLanes&o)!==o?(n.childLanes|=o,x!==null&&(x.childLanes|=o)):x!==null&&(x.childLanes&o)!==o&&(x.childLanes|=o),n===u)break;n=n.return}}function og(n,o,u,x){var w=n.child;for(w!==null&&(w.return=n);w!==null;){var S=w.dependencies;if(S!==null){var q=w.child;S=S.firstContext;e:for(;S!==null;){var ge=S;S=w;for(var Ae=0;Ae<o.length;Ae++)if(ge.context===o[Ae]){S.lanes|=u,ge=S.alternate,ge!==null&&(ge.lanes|=u),ig(S.return,u,n),x||(q=null);break e}S=ge.next}}else if(w.tag===18){if(q=w.return,q===null)throw Error(s(341));q.lanes|=u,S=q.alternate,S!==null&&(S.lanes|=u),ig(q,u,n),q=null}else q=w.child;if(q!==null)q.return=w;else for(q=w;q!==null;){if(q===n){q=null;break}if(w=q.sibling,w!==null){w.return=q.return,q=w;break}q=q.return}w=q}}function Xc(n,o,u,x){n=null;for(var w=o,S=!1;w!==null;){if(!S){if((w.flags&524288)!==0)S=!0;else if((w.flags&262144)!==0)break}if(w.tag===10){var q=w.alternate;if(q===null)throw Error(s(387));if(q=q.memoizedProps,q!==null){var ge=w.type;ts(w.pendingProps.value,q.value)||(n!==null?n.push(ge):n=[ge])}}else if(w===be.current){if(q=w.alternate,q===null)throw Error(s(387));q.memoizedState.memoizedState!==w.memoizedState.memoizedState&&(n!==null?n.push(F0):n=[F0])}w=w.return}n!==null&&og(o,n,u,x),o.flags|=262144}function zu(n){for(n=n.firstContext;n!==null;){if(!ts(n.context._currentValue,n.memoizedValue))return!0;n=n.next}return!1}function Jl(n){no=n,Si=null,n=n.dependencies,n!==null&&(n.firstContext=null)}function Us(n){return Lp(no,n)}function Bu(n,o){return no===null&&Jl(n),Lp(n,o)}function Lp(n,o){var u=o._currentValue;if(o={context:o,memoizedValue:u,next:null},Si===null){if(n===null)throw Error(s(308));Si=o,n.dependencies={lanes:0,firstContext:o},n.flags|=524288}else Si=Si.next=o;return u}var gj=typeof AbortController!="undefined"?AbortController:function(){var n=[],o=this.signal={aborted:!1,addEventListener:function(u,x){n.push(x)}};this.abort=function(){o.aborted=!0,n.forEach(function(u){return u()})}},fj=t.unstable_scheduleCallback,xj=t.unstable_NormalPriority,rs={$$typeof:E,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function lg(){return{controller:new gj,data:new Map,refCount:0}}function u0(n){n.refCount--,n.refCount===0&&fj(xj,function(){n.controller.abort()})}var m0=null,cg=0,Kc=0,Qc=null;function pj(n,o){if(m0===null){var u=m0=[];cg=0,Kc=hf(),Qc={status:"pending",value:void 0,then:function(x){u.push(x)}}}return cg++,o.then(Rp,Rp),o}function Rp(){if(--cg===0&&m0!==null){Qc!==null&&(Qc.status="fulfilled");var n=m0;m0=null,Kc=0,Qc=null;for(var o=0;o<n.length;o++)(0,n[o])()}}function yj(n,o){var u=[],x={status:"pending",value:null,reason:null,then:function(w){u.push(w)}};return n.then(function(){x.status="fulfilled",x.value=o;for(var w=0;w<u.length;w++)(0,u[w])(o)},function(w){for(x.status="rejected",x.reason=w,w=0;w<u.length;w++)(0,u[w])(void 0)}),x}var Pp=te.S;te.S=function(n,o){bb=sa(),typeof o=="object"&&o!==null&&typeof o.then=="function"&&pj(n,o),Pp!==null&&Pp(n,o)};var Xl=F(null);function dg(){var n=Xl.current;return n!==null?n:wr.pooledCache}function Uu(n,o){o===null?B(Xl,Xl.current):B(Xl,o.pool)}function Fp(){var n=dg();return n===null?null:{parent:rs._currentValue,pool:n}}var ed=Error(s(460)),ug=Error(s(474)),$u=Error(s(542)),Hu={then:function(){}};function Ip(n){return n=n.status,n==="fulfilled"||n==="rejected"}function zp(n,o,u){switch(u=n[u],u===void 0?n.push(o):u!==o&&(o.then(Sa,Sa),o=u),o.status){case"fulfilled":return o.value;case"rejected":throw n=o.reason,Up(n),n;default:if(typeof o.status=="string")o.then(Sa,Sa);else{if(n=wr,n!==null&&100<n.shellSuspendCounter)throw Error(s(482));n=o,n.status="pending",n.then(function(x){if(o.status==="pending"){var w=o;w.status="fulfilled",w.value=x}},function(x){if(o.status==="pending"){var w=o;w.status="rejected",w.reason=x}})}switch(o.status){case"fulfilled":return o.value;case"rejected":throw n=o.reason,Up(n),n}throw Ql=o,ed}}function Kl(n){try{var o=n._init;return o(n._payload)}catch(u){throw u!==null&&typeof u=="object"&&typeof u.then=="function"?(Ql=u,ed):u}}var Ql=null;function Bp(){if(Ql===null)throw Error(s(459));var n=Ql;return Ql=null,n}function Up(n){if(n===ed||n===$u)throw Error(s(483))}var td=null,h0=0;function Wu(n){var o=h0;return h0+=1,td===null&&(td=[]),zp(td,n,o)}function g0(n,o){o=o.props.ref,n.ref=o!==void 0?o:null}function Vu(n,o){throw o.$$typeof===j?Error(s(525)):(n=Object.prototype.toString.call(o),Error(s(31,n==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":n)))}function $p(n){function o(Ve,Fe){if(n){var Je=Ve.deletions;Je===null?(Ve.deletions=[Fe],Ve.flags|=16):Je.push(Fe)}}function u(Ve,Fe){if(!n)return null;for(;Fe!==null;)o(Ve,Fe),Fe=Fe.sibling;return null}function x(Ve){for(var Fe=new Map;Ve!==null;)Ve.key!==null?Fe.set(Ve.key,Ve):Fe.set(Ve.index,Ve),Ve=Ve.sibling;return Fe}function w(Ve,Fe){return Ve=hi(Ve,Fe),Ve.index=0,Ve.sibling=null,Ve}function S(Ve,Fe,Je){return Ve.index=Je,n?(Je=Ve.alternate,Je!==null?(Je=Je.index,Je<Fe?(Ve.flags|=67108866,Fe):Je):(Ve.flags|=67108866,Fe)):(Ve.flags|=1048576,Fe)}function q(Ve){return n&&Ve.alternate===null&&(Ve.flags|=67108866),Ve}function ge(Ve,Fe,Je,jt){return Fe===null||Fe.tag!==6?(Fe=Zc(Je,Ve.mode,jt),Fe.return=Ve,Fe):(Fe=w(Fe,Je),Fe.return=Ve,Fe)}function Ae(Ve,Fe,Je,jt){var ga=Je.type;return ga===k?vt(Ve,Fe,Je.props.children,jt,Je.key):Fe!==null&&(Fe.elementType===ga||typeof ga=="object"&&ga!==null&&ga.$$typeof===U&&Kl(ga)===Fe.type)?(Fe=w(Fe,Je.props),g0(Fe,Je),Fe.return=Ve,Fe):(Fe=Gl(Je.type,Je.key,Je.props,null,Ve.mode,jt),g0(Fe,Je),Fe.return=Ve,Fe)}function Ke(Ve,Fe,Je,jt){return Fe===null||Fe.tag!==4||Fe.stateNode.containerInfo!==Je.containerInfo||Fe.stateNode.implementation!==Je.implementation?(Fe=l0(Je,Ve.mode,jt),Fe.return=Ve,Fe):(Fe=w(Fe,Je.children||[]),Fe.return=Ve,Fe)}function vt(Ve,Fe,Je,jt,ga){return Fe===null||Fe.tag!==7?(Fe=Ao(Je,Ve.mode,jt,ga),Fe.return=Ve,Fe):(Fe=w(Fe,Je),Fe.return=Ve,Fe)}function Et(Ve,Fe,Je){if(typeof Fe=="string"&&Fe!==""||typeof Fe=="number"||typeof Fe=="bigint")return Fe=Zc(""+Fe,Ve.mode,Je),Fe.return=Ve,Fe;if(typeof Fe=="object"&&Fe!==null){switch(Fe.$$typeof){case _:return Je=Gl(Fe.type,Fe.key,Fe.props,null,Ve.mode,Je),g0(Je,Fe),Je.return=Ve,Je;case N:return Fe=l0(Fe,Ve.mode,Je),Fe.return=Ve,Fe;case U:return Fe=Kl(Fe),Et(Ve,Fe,Je)}if(ee(Fe)||he(Fe))return Fe=Ao(Fe,Ve.mode,Je,null),Fe.return=Ve,Fe;if(typeof Fe.then=="function")return Et(Ve,Wu(Fe),Je);if(Fe.$$typeof===E)return Et(Ve,Bu(Ve,Fe),Je);Vu(Ve,Fe)}return null}function at(Ve,Fe,Je,jt){var ga=Fe!==null?Fe.key:null;if(typeof Je=="string"&&Je!==""||typeof Je=="number"||typeof Je=="bigint")return ga!==null?null:ge(Ve,Fe,""+Je,jt);if(typeof Je=="object"&&Je!==null){switch(Je.$$typeof){case _:return Je.key===ga?Ae(Ve,Fe,Je,jt):null;case N:return Je.key===ga?Ke(Ve,Fe,Je,jt):null;case U:return Je=Kl(Je),at(Ve,Fe,Je,jt)}if(ee(Je)||he(Je))return ga!==null?null:vt(Ve,Fe,Je,jt,null);if(typeof Je.then=="function")return at(Ve,Fe,Wu(Je),jt);if(Je.$$typeof===E)return at(Ve,Fe,Bu(Ve,Je),jt);Vu(Ve,Je)}return null}function ut(Ve,Fe,Je,jt,ga){if(typeof jt=="string"&&jt!==""||typeof jt=="number"||typeof jt=="bigint")return Ve=Ve.get(Je)||null,ge(Fe,Ve,""+jt,ga);if(typeof jt=="object"&&jt!==null){switch(jt.$$typeof){case _:return Ve=Ve.get(jt.key===null?Je:jt.key)||null,Ae(Fe,Ve,jt,ga);case N:return Ve=Ve.get(jt.key===null?Je:jt.key)||null,Ke(Fe,Ve,jt,ga);case U:return jt=Kl(jt),ut(Ve,Fe,Je,jt,ga)}if(ee(jt)||he(jt))return Ve=Ve.get(Je)||null,vt(Fe,Ve,jt,ga,null);if(typeof jt.then=="function")return ut(Ve,Fe,Je,Wu(jt),ga);if(jt.$$typeof===E)return ut(Ve,Fe,Je,Bu(Fe,jt),ga);Vu(Fe,jt)}return null}function la(Ve,Fe,Je,jt){for(var ga=null,Qa=null,da=Fe,Da=Fe=0,Va=null;da!==null&&Da<Je.length;Da++){da.index>Da?(Va=da,da=null):Va=da.sibling;var er=at(Ve,da,Je[Da],jt);if(er===null){da===null&&(da=Va);break}n&&da&&er.alternate===null&&o(Ve,da),Fe=S(er,Fe,Da),Qa===null?ga=er:Qa.sibling=er,Qa=er,da=Va}if(Da===Je.length)return u(Ve,da),Ua&&ua(Ve,Da),ga;if(da===null){for(;Da<Je.length;Da++)da=Et(Ve,Je[Da],jt),da!==null&&(Fe=S(da,Fe,Da),Qa===null?ga=da:Qa.sibling=da,Qa=da);return Ua&&ua(Ve,Da),ga}for(da=x(da);Da<Je.length;Da++)Va=ut(da,Ve,Da,Je[Da],jt),Va!==null&&(n&&Va.alternate!==null&&da.delete(Va.key===null?Da:Va.key),Fe=S(Va,Fe,Da),Qa===null?ga=Va:Qa.sibling=Va,Qa=Va);return n&&da.forEach(function(Nl){return o(Ve,Nl)}),Ua&&ua(Ve,Da),ga}function ba(Ve,Fe,Je,jt){if(Je==null)throw Error(s(151));for(var ga=null,Qa=null,da=Fe,Da=Fe=0,Va=null,er=Je.next();da!==null&&!er.done;Da++,er=Je.next()){da.index>Da?(Va=da,da=null):Va=da.sibling;var Nl=at(Ve,da,er.value,jt);if(Nl===null){da===null&&(da=Va);break}n&&da&&Nl.alternate===null&&o(Ve,da),Fe=S(Nl,Fe,Da),Qa===null?ga=Nl:Qa.sibling=Nl,Qa=Nl,da=Va}if(er.done)return u(Ve,da),Ua&&ua(Ve,Da),ga;if(da===null){for(;!er.done;Da++,er=Je.next())er=Et(Ve,er.value,jt),er!==null&&(Fe=S(er,Fe,Da),Qa===null?ga=er:Qa.sibling=er,Qa=er);return Ua&&ua(Ve,Da),ga}for(da=x(da);!er.done;Da++,er=Je.next())er=ut(da,Ve,Da,er.value,jt),er!==null&&(n&&er.alternate!==null&&da.delete(er.key===null?Da:er.key),Fe=S(er,Fe,Da),Qa===null?ga=er:Qa.sibling=er,Qa=er);return n&&da.forEach(function(EN){return o(Ve,EN)}),Ua&&ua(Ve,Da),ga}function br(Ve,Fe,Je,jt){if(typeof Je=="object"&&Je!==null&&Je.type===k&&Je.key===null&&(Je=Je.props.children),typeof Je=="object"&&Je!==null){switch(Je.$$typeof){case _:e:{for(var ga=Je.key;Fe!==null;){if(Fe.key===ga){if(ga=Je.type,ga===k){if(Fe.tag===7){u(Ve,Fe.sibling),jt=w(Fe,Je.props.children),jt.return=Ve,Ve=jt;break e}}else if(Fe.elementType===ga||typeof ga=="object"&&ga!==null&&ga.$$typeof===U&&Kl(ga)===Fe.type){u(Ve,Fe.sibling),jt=w(Fe,Je.props),g0(jt,Je),jt.return=Ve,Ve=jt;break e}u(Ve,Fe);break}else o(Ve,Fe);Fe=Fe.sibling}Je.type===k?(jt=Ao(Je.props.children,Ve.mode,jt,Je.key),jt.return=Ve,Ve=jt):(jt=Gl(Je.type,Je.key,Je.props,null,Ve.mode,jt),g0(jt,Je),jt.return=Ve,Ve=jt)}return q(Ve);case N:e:{for(ga=Je.key;Fe!==null;){if(Fe.key===ga)if(Fe.tag===4&&Fe.stateNode.containerInfo===Je.containerInfo&&Fe.stateNode.implementation===Je.implementation){u(Ve,Fe.sibling),jt=w(Fe,Je.children||[]),jt.return=Ve,Ve=jt;break e}else{u(Ve,Fe);break}else o(Ve,Fe);Fe=Fe.sibling}jt=l0(Je,Ve.mode,jt),jt.return=Ve,Ve=jt}return q(Ve);case U:return Je=Kl(Je),br(Ve,Fe,Je,jt)}if(ee(Je))return la(Ve,Fe,Je,jt);if(he(Je)){if(ga=he(Je),typeof ga!="function")throw Error(s(150));return Je=ga.call(Je),ba(Ve,Fe,Je,jt)}if(typeof Je.then=="function")return br(Ve,Fe,Wu(Je),jt);if(Je.$$typeof===E)return br(Ve,Fe,Bu(Ve,Je),jt);Vu(Ve,Je)}return typeof Je=="string"&&Je!==""||typeof Je=="number"||typeof Je=="bigint"?(Je=""+Je,Fe!==null&&Fe.tag===6?(u(Ve,Fe.sibling),jt=w(Fe,Je),jt.return=Ve,Ve=jt):(u(Ve,Fe),jt=Zc(Je,Ve.mode,jt),jt.return=Ve,Ve=jt),q(Ve)):u(Ve,Fe)}return function(Ve,Fe,Je,jt){try{h0=0;var ga=br(Ve,Fe,Je,jt);return td=null,ga}catch(da){if(da===ed||da===$u)throw da;var Qa=rn(29,da,null,Ve.mode);return Qa.lanes=jt,Qa.return=Ve,Qa}finally{}}}var ec=$p(!0),Hp=$p(!1),ll=!1;function mg(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function hg(n,o){n=n.updateQueue,o.updateQueue===n&&(o.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function cl(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function dl(n,o,u){var x=n.updateQueue;if(x===null)return null;if(x=x.shared,(rr&2)!==0){var w=x.pending;return w===null?o.next=o:(o.next=w.next,w.next=o),x.pending=o,o=ql(n),il(n,null,u),o}return ao(n,x,o,u),ql(n)}function f0(n,o,u){if(o=o.updateQueue,o!==null&&(o=o.shared,(u&4194048)!==0)){var x=o.lanes;x&=n.pendingLanes,u|=x,o.lanes=u,ct(n,u)}}function gg(n,o){var u=n.updateQueue,x=n.alternate;if(x!==null&&(x=x.updateQueue,u===x)){var w=null,S=null;if(u=u.firstBaseUpdate,u!==null){do{var q={lane:u.lane,tag:u.tag,payload:u.payload,callback:null,next:null};S===null?w=S=q:S=S.next=q,u=u.next}while(u!==null);S===null?w=S=o:S=S.next=o}else w=S=o;u={baseState:x.baseState,firstBaseUpdate:w,lastBaseUpdate:S,shared:x.shared,callbacks:x.callbacks},n.updateQueue=u;return}n=u.lastBaseUpdate,n===null?u.firstBaseUpdate=o:n.next=o,u.lastBaseUpdate=o}var fg=!1;function x0(){if(fg){var n=Qc;if(n!==null)throw n}}function p0(n,o,u,x){fg=!1;var w=n.updateQueue;ll=!1;var S=w.firstBaseUpdate,q=w.lastBaseUpdate,ge=w.shared.pending;if(ge!==null){w.shared.pending=null;var Ae=ge,Ke=Ae.next;Ae.next=null,q===null?S=Ke:q.next=Ke,q=Ae;var vt=n.alternate;vt!==null&&(vt=vt.updateQueue,ge=vt.lastBaseUpdate,ge!==q&&(ge===null?vt.firstBaseUpdate=Ke:ge.next=Ke,vt.lastBaseUpdate=Ae))}if(S!==null){var Et=w.baseState;q=0,vt=Ke=Ae=null,ge=S;do{var at=ge.lane&-536870913,ut=at!==ge.lane;if(ut?(Wa&at)===at:(x&at)===at){at!==0&&at===Kc&&(fg=!0),vt!==null&&(vt=vt.next={lane:0,tag:ge.tag,payload:ge.payload,callback:null,next:null});e:{var la=n,ba=ge;at=o;var br=u;switch(ba.tag){case 1:if(la=ba.payload,typeof la=="function"){Et=la.call(br,Et,at);break e}Et=la;break e;case 3:la.flags=la.flags&-65537|128;case 0:if(la=ba.payload,at=typeof la=="function"?la.call(br,Et,at):la,at==null)break e;Et=b({},Et,at);break e;case 2:ll=!0}}at=ge.callback,at!==null&&(n.flags|=64,ut&&(n.flags|=8192),ut=w.callbacks,ut===null?w.callbacks=[at]:ut.push(at))}else ut={lane:at,tag:ge.tag,payload:ge.payload,callback:ge.callback,next:null},vt===null?(Ke=vt=ut,Ae=Et):vt=vt.next=ut,q|=at;if(ge=ge.next,ge===null){if(ge=w.shared.pending,ge===null)break;ut=ge,ge=ut.next,ut.next=null,w.lastBaseUpdate=ut,w.shared.pending=null}}while(!0);vt===null&&(Ae=Et),w.baseState=Ae,w.firstBaseUpdate=Ke,w.lastBaseUpdate=vt,S===null&&(w.shared.lanes=0),fl|=q,n.lanes=q,n.memoizedState=Et}}function Wp(n,o){if(typeof n!="function")throw Error(s(191,n));n.call(o)}function Vp(n,o){var u=n.callbacks;if(u!==null)for(n.callbacks=null,n=0;n<u.length;n++)Wp(u[n],o)}var ad=F(null),qu=F(0);function qp(n,o){n=Uo,B(qu,n),B(ad,o),Uo=n|o.baseLanes}function xg(){B(qu,Uo),B(ad,ad.current)}function pg(){Uo=qu.current,M(ad),M(qu)}var Gn=F(null),gi=null;function ul(n){var o=n.alternate;B(Jr,Jr.current&1),B(Gn,n),gi===null&&(o===null||ad.current!==null||o.memoizedState!==null)&&(gi=n)}function yg(n){B(Jr,Jr.current),B(Gn,n),gi===null&&(gi=n)}function Gp(n){n.tag===22?(B(Jr,Jr.current),B(Gn,n),gi===null&&(gi=n)):ml()}function ml(){B(Jr,Jr.current),B(Gn,Gn.current)}function Yn(n){M(Gn),gi===n&&(gi=null),M(Jr)}var Jr=F(0);function Gu(n){for(var o=n;o!==null;){if(o.tag===13){var u=o.memoizedState;if(u!==null&&(u=u.dehydrated,u===null||Nf(u)||Sf(u)))return o}else if(o.tag===19&&(o.memoizedProps.revealOrder==="forwards"||o.memoizedProps.revealOrder==="backwards"||o.memoizedProps.revealOrder==="unstable_legacy-backwards"||o.memoizedProps.revealOrder==="together")){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===n)break;for(;o.sibling===null;){if(o.return===null||o.return===n)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var Mo=0,Ta=null,pr=null,ss=null,Yu=!1,rd=!1,tc=!1,Zu=0,y0=0,sd=null,bj=0;function $r(){throw Error(s(321))}function bg(n,o){if(o===null)return!1;for(var u=0;u<o.length&&u<n.length;u++)if(!ts(n[u],o[u]))return!1;return!0}function vg(n,o,u,x,w,S){return Mo=S,Ta=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,te.H=n===null||n.memoizedState===null?Ay:Rg,tc=!1,S=u(x,w),tc=!1,rd&&(S=Zp(o,u,x,w)),Yp(n),S}function Yp(n){te.H=_0;var o=pr!==null&&pr.next!==null;if(Mo=0,ss=pr=Ta=null,Yu=!1,y0=0,sd=null,o)throw Error(s(300));n===null||ns||(n=n.dependencies,n!==null&&zu(n)&&(ns=!0))}function Zp(n,o,u,x){Ta=n;var w=0;do{if(rd&&(sd=null),y0=0,rd=!1,25<=w)throw Error(s(301));if(w+=1,ss=pr=null,n.updateQueue!=null){var S=n.updateQueue;S.lastEffect=null,S.events=null,S.stores=null,S.memoCache!=null&&(S.memoCache.index=0)}te.H=Oy,S=o(u,x)}while(rd);return S}function vj(){var n=te.H,o=n.useState()[0];return o=typeof o.then=="function"?b0(o):o,n=n.useState()[0],(pr!==null?pr.memoizedState:null)!==n&&(Ta.flags|=1024),o}function _g(){var n=Zu!==0;return Zu=0,n}function wg(n,o,u){o.updateQueue=n.updateQueue,o.flags&=-2053,n.lanes&=~u}function kg(n){if(Yu){for(n=n.memoizedState;n!==null;){var o=n.queue;o!==null&&(o.pending=null),n=n.next}Yu=!1}Mo=0,ss=pr=Ta=null,rd=!1,y0=Zu=0,sd=null}function fn(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ss===null?Ta.memoizedState=ss=n:ss=ss.next=n,ss}function Xr(){if(pr===null){var n=Ta.alternate;n=n!==null?n.memoizedState:null}else n=pr.next;var o=ss===null?Ta.memoizedState:ss.next;if(o!==null)ss=o,pr=n;else{if(n===null)throw Ta.alternate===null?Error(s(467)):Error(s(310));pr=n,n={memoizedState:pr.memoizedState,baseState:pr.baseState,baseQueue:pr.baseQueue,queue:pr.queue,next:null},ss===null?Ta.memoizedState=ss=n:ss=ss.next=n}return ss}function Ju(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function b0(n){var o=y0;return y0+=1,sd===null&&(sd=[]),n=zp(sd,n,o),o=Ta,(ss===null?o.memoizedState:ss.next)===null&&(o=o.alternate,te.H=o===null||o.memoizedState===null?Ay:Rg),n}function Xu(n){if(n!==null&&typeof n=="object"){if(typeof n.then=="function")return b0(n);if(n.$$typeof===E)return Us(n)}throw Error(s(438,String(n)))}function jg(n){var o=null,u=Ta.updateQueue;if(u!==null&&(o=u.memoCache),o==null){var x=Ta.alternate;x!==null&&(x=x.updateQueue,x!==null&&(x=x.memoCache,x!=null&&(o={data:x.data.map(function(w){return w.slice()}),index:0})))}if(o==null&&(o={data:[],index:0}),u===null&&(u=Ju(),Ta.updateQueue=u),u.memoCache=o,u=o.data[o.index],u===void 0)for(u=o.data[o.index]=Array(n),x=0;x<n;x++)u[x]=ne;return o.index++,u}function Lo(n,o){return typeof o=="function"?o(n):o}function Ku(n){var o=Xr();return Ng(o,pr,n)}function Ng(n,o,u){var x=n.queue;if(x===null)throw Error(s(311));x.lastRenderedReducer=u;var w=n.baseQueue,S=x.pending;if(S!==null){if(w!==null){var q=w.next;w.next=S.next,S.next=q}o.baseQueue=w=S,x.pending=null}if(S=n.baseState,w===null)n.memoizedState=S;else{o=w.next;var ge=q=null,Ae=null,Ke=o,vt=!1;do{var Et=Ke.lane&-536870913;if(Et!==Ke.lane?(Wa&Et)===Et:(Mo&Et)===Et){var at=Ke.revertLane;if(at===0)Ae!==null&&(Ae=Ae.next={lane:0,revertLane:0,gesture:null,action:Ke.action,hasEagerState:Ke.hasEagerState,eagerState:Ke.eagerState,next:null}),Et===Kc&&(vt=!0);else if((Mo&at)===at){Ke=Ke.next,at===Kc&&(vt=!0);continue}else Et={lane:0,revertLane:Ke.revertLane,gesture:null,action:Ke.action,hasEagerState:Ke.hasEagerState,eagerState:Ke.eagerState,next:null},Ae===null?(ge=Ae=Et,q=S):Ae=Ae.next=Et,Ta.lanes|=at,fl|=at;Et=Ke.action,tc&&u(S,Et),S=Ke.hasEagerState?Ke.eagerState:u(S,Et)}else at={lane:Et,revertLane:Ke.revertLane,gesture:Ke.gesture,action:Ke.action,hasEagerState:Ke.hasEagerState,eagerState:Ke.eagerState,next:null},Ae===null?(ge=Ae=at,q=S):Ae=Ae.next=at,Ta.lanes|=Et,fl|=Et;Ke=Ke.next}while(Ke!==null&&Ke!==o);if(Ae===null?q=S:Ae.next=ge,!ts(S,n.memoizedState)&&(ns=!0,vt&&(u=Qc,u!==null)))throw u;n.memoizedState=S,n.baseState=q,n.baseQueue=Ae,x.lastRenderedState=S}return w===null&&(x.lanes=0),[n.memoizedState,x.dispatch]}function Sg(n){var o=Xr(),u=o.queue;if(u===null)throw Error(s(311));u.lastRenderedReducer=n;var x=u.dispatch,w=u.pending,S=o.memoizedState;if(w!==null){u.pending=null;var q=w=w.next;do S=n(S,q.action),q=q.next;while(q!==w);ts(S,o.memoizedState)||(ns=!0),o.memoizedState=S,o.baseQueue===null&&(o.baseState=S),u.lastRenderedState=S}return[S,x]}function Jp(n,o,u){var x=Ta,w=Xr(),S=Ua;if(S){if(u===void 0)throw Error(s(407));u=u()}else u=o();var q=!ts((pr||w).memoizedState,u);if(q&&(w.memoizedState=u,ns=!0),w=w.queue,Eg(Qp.bind(null,x,w,n),[n]),w.getSnapshot!==o||q||ss!==null&&ss.memoizedState.tag&1){if(x.flags|=2048,nd(9,{destroy:void 0},Kp.bind(null,x,w,u,o),null),wr===null)throw Error(s(349));S||(Mo&127)!==0||Xp(x,o,u)}return u}function Xp(n,o,u){n.flags|=16384,n={getSnapshot:o,value:u},o=Ta.updateQueue,o===null?(o=Ju(),Ta.updateQueue=o,o.stores=[n]):(u=o.stores,u===null?o.stores=[n]:u.push(n))}function Kp(n,o,u,x){o.value=u,o.getSnapshot=x,ey(o)&&ty(n)}function Qp(n,o,u){return u(function(){ey(o)&&ty(n)})}function ey(n){var o=n.getSnapshot;n=n.value;try{var u=o();return!ts(n,u)}catch(x){return!0}}function ty(n){var o=mi(n,2);o!==null&&On(o,n,2)}function Cg(n){var o=fn();if(typeof n=="function"){var u=n;if(n=u(),tc){ve(!0);try{u()}finally{ve(!1)}}}return o.memoizedState=o.baseState=n,o.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:n},o}function ay(n,o,u,x){return n.baseState=u,Ng(n,pr,typeof x=="function"?x:Lo)}function _j(n,o,u,x,w){if(tm(n))throw Error(s(485));if(n=o.action,n!==null){var S={payload:w,action:n,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(q){S.listeners.push(q)}};te.T!==null?u(!0):S.isTransition=!1,x(S),u=o.pending,u===null?(S.next=o.pending=S,ry(o,S)):(S.next=u.next,o.pending=u.next=S)}}function ry(n,o){var u=o.action,x=o.payload,w=n.state;if(o.isTransition){var S=te.T,q={};te.T=q;try{var ge=u(w,x),Ae=te.S;Ae!==null&&Ae(q,ge),sy(n,o,ge)}catch(Ke){Tg(n,o,Ke)}finally{S!==null&&q.types!==null&&(S.types=q.types),te.T=S}}else try{S=u(w,x),sy(n,o,S)}catch(Ke){Tg(n,o,Ke)}}function sy(n,o,u){u!==null&&typeof u=="object"&&typeof u.then=="function"?u.then(function(x){ny(n,o,x)},function(x){return Tg(n,o,x)}):ny(n,o,u)}function ny(n,o,u){o.status="fulfilled",o.value=u,iy(o),n.state=u,o=n.pending,o!==null&&(u=o.next,u===o?n.pending=null:(u=u.next,o.next=u,ry(n,u)))}function Tg(n,o,u){var x=n.pending;if(n.pending=null,x!==null){x=x.next;do o.status="rejected",o.reason=u,iy(o),o=o.next;while(o!==x)}n.action=null}function iy(n){n=n.listeners;for(var o=0;o<n.length;o++)(0,n[o])()}function oy(n,o){return o}function ly(n,o){if(Ua){var u=wr.formState;if(u!==null){e:{var x=Ta;if(Ua){if(Ka){t:{for(var w=Ka,S=Sn;w.nodeType!==8;){if(!S){w=null;break t}if(w=fi(w.nextSibling),w===null){w=null;break t}}S=w.data,w=S==="F!"||S==="F"?w:null}if(w){Ka=fi(w.nextSibling),x=w.data==="F!";break e}}so(x)}x=!1}x&&(o=u[0])}}return u=fn(),u.memoizedState=u.baseState=o,x={pending:null,lanes:0,dispatch:null,lastRenderedReducer:oy,lastRenderedState:o},u.queue=x,u=Cy.bind(null,Ta,x),x.dispatch=u,x=Cg(!1),S=Lg.bind(null,Ta,!1,x.queue),x=fn(),w={state:o,dispatch:null,action:n,pending:null},x.queue=w,u=_j.bind(null,Ta,w,S,u),w.dispatch=u,x.memoizedState=n,[o,u,!1]}function cy(n){var o=Xr();return dy(o,pr,n)}function dy(n,o,u){if(o=Ng(n,o,oy)[0],n=Ku(Lo)[0],typeof o=="object"&&o!==null&&typeof o.then=="function")try{var x=b0(o)}catch(q){throw q===ed?$u:q}else x=o;o=Xr();var w=o.queue,S=w.dispatch;return u!==o.memoizedState&&(Ta.flags|=2048,nd(9,{destroy:void 0},wj.bind(null,w,u),null)),[x,S,n]}function wj(n,o){n.action=o}function uy(n){var o=Xr(),u=pr;if(u!==null)return dy(o,u,n);Xr(),o=o.memoizedState,u=Xr();var x=u.queue.dispatch;return u.memoizedState=n,[o,x,!1]}function nd(n,o,u,x){return n={tag:n,create:u,deps:x,inst:o,next:null},o=Ta.updateQueue,o===null&&(o=Ju(),Ta.updateQueue=o),u=o.lastEffect,u===null?o.lastEffect=n.next=n:(x=u.next,u.next=n,n.next=x,o.lastEffect=n),n}function my(){return Xr().memoizedState}function Qu(n,o,u,x){var w=fn();Ta.flags|=n,w.memoizedState=nd(1|o,{destroy:void 0},u,x===void 0?null:x)}function em(n,o,u,x){var w=Xr();x=x===void 0?null:x;var S=w.memoizedState.inst;pr!==null&&x!==null&&bg(x,pr.memoizedState.deps)?w.memoizedState=nd(o,S,u,x):(Ta.flags|=n,w.memoizedState=nd(1|o,S,u,x))}function hy(n,o){Qu(8390656,8,n,o)}function Eg(n,o){em(2048,8,n,o)}function kj(n){Ta.flags|=4;var o=Ta.updateQueue;if(o===null)o=Ju(),Ta.updateQueue=o,o.events=[n];else{var u=o.events;u===null?o.events=[n]:u.push(n)}}function gy(n){var o=Xr().memoizedState;return kj({ref:o,nextImpl:n}),function(){if((rr&2)!==0)throw Error(s(440));return o.impl.apply(void 0,arguments)}}function fy(n,o){return em(4,2,n,o)}function xy(n,o){return em(4,4,n,o)}function py(n,o){if(typeof o=="function"){n=n();var u=o(n);return function(){typeof u=="function"?u():o(null)}}if(o!=null)return n=n(),o.current=n,function(){o.current=null}}function yy(n,o,u){u=u!=null?u.concat([n]):null,em(4,4,py.bind(null,o,n),u)}function Ag(){}function by(n,o){var u=Xr();o=o===void 0?null:o;var x=u.memoizedState;return o!==null&&bg(o,x[1])?x[0]:(u.memoizedState=[n,o],n)}function vy(n,o){var u=Xr();o=o===void 0?null:o;var x=u.memoizedState;if(o!==null&&bg(o,x[1]))return x[0];if(x=n(),tc){ve(!0);try{n()}finally{ve(!1)}}return u.memoizedState=[x,o],x}function Og(n,o,u){return u===void 0||(Mo&1073741824)!==0&&(Wa&261930)===0?n.memoizedState=o:(n.memoizedState=u,n=_b(),Ta.lanes|=n,fl|=n,u)}function _y(n,o,u,x){return ts(u,o)?u:ad.current!==null?(n=Og(n,u,x),ts(n,o)||(ns=!0),n):(Mo&42)===0||(Mo&1073741824)!==0&&(Wa&261930)===0?(ns=!0,n.memoizedState=u):(n=_b(),Ta.lanes|=n,fl|=n,o)}function wy(n,o,u,x,w){var S=W.p;W.p=S!==0&&8>S?S:8;var q=te.T,ge={};te.T=ge,Lg(n,!1,o,u);try{var Ae=w(),Ke=te.S;if(Ke!==null&&Ke(ge,Ae),Ae!==null&&typeof Ae=="object"&&typeof Ae.then=="function"){var vt=yj(Ae,x);v0(n,o,vt,Xn(n))}else v0(n,o,x,Xn(n))}catch(Et){v0(n,o,{then:function(){},status:"rejected",reason:Et},Xn())}finally{W.p=S,q!==null&&ge.types!==null&&(q.types=ge.types),te.T=q}}function jj(){}function Dg(n,o,u,x){if(n.tag!==5)throw Error(s(476));var w=ky(n).queue;wy(n,w,o,I,u===null?jj:function(){return jy(n),u(x)})}function ky(n){var o=n.memoizedState;if(o!==null)return o;o={memoizedState:I,baseState:I,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:I},next:null};var u={};return o.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:u},next:null},n.memoizedState=o,n=n.alternate,n!==null&&(n.memoizedState=o),o}function jy(n){var o=ky(n);o.next===null&&(o=n.alternate.memoizedState),v0(n,o.next.queue,{},Xn())}function Mg(){return Us(F0)}function Ny(){return Xr().memoizedState}function Sy(){return Xr().memoizedState}function Nj(n){for(var o=n.return;o!==null;){switch(o.tag){case 24:case 3:var u=Xn();n=cl(u);var x=dl(o,n,u);x!==null&&(On(x,o,u),f0(x,o,u)),o={cache:lg()},n.payload=o;return}o=o.return}}function Sj(n,o,u){var x=Xn();u={lane:x,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},tm(n)?Ty(o,u):(u=n0(n,o,u,x),u!==null&&(On(u,n,x),Ey(u,o,x)))}function Cy(n,o,u){var x=Xn();v0(n,o,u,x)}function v0(n,o,u,x){var w={lane:x,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(tm(n))Ty(o,w);else{var S=n.alternate;if(n.lanes===0&&(S===null||S.lanes===0)&&(S=o.lastRenderedReducer,S!==null))try{var q=o.lastRenderedState,ge=S(q,u);if(w.hasEagerState=!0,w.eagerState=ge,ts(ge,q))return ao(n,o,w,0),wr===null&&Vl(),!1}catch(Ae){}finally{}if(u=n0(n,o,w,x),u!==null)return On(u,n,x),Ey(u,o,x),!0}return!1}function Lg(n,o,u,x){if(x={lane:2,revertLane:hf(),gesture:null,action:x,hasEagerState:!1,eagerState:null,next:null},tm(n)){if(o)throw Error(s(479))}else o=n0(n,u,x,2),o!==null&&On(o,n,2)}function tm(n){var o=n.alternate;return n===Ta||o!==null&&o===Ta}function Ty(n,o){rd=Yu=!0;var u=n.pending;u===null?o.next=o:(o.next=u.next,u.next=o),n.pending=o}function Ey(n,o,u){if((u&4194048)!==0){var x=o.lanes;x&=n.pendingLanes,u|=x,o.lanes=u,ct(n,u)}}var _0={readContext:Us,use:Xu,useCallback:$r,useContext:$r,useEffect:$r,useImperativeHandle:$r,useLayoutEffect:$r,useInsertionEffect:$r,useMemo:$r,useReducer:$r,useRef:$r,useState:$r,useDebugValue:$r,useDeferredValue:$r,useTransition:$r,useSyncExternalStore:$r,useId:$r,useHostTransitionStatus:$r,useFormState:$r,useActionState:$r,useOptimistic:$r,useMemoCache:$r,useCacheRefresh:$r};_0.useEffectEvent=$r;var Ay={readContext:Us,use:Xu,useCallback:function(n,o){return fn().memoizedState=[n,o===void 0?null:o],n},useContext:Us,useEffect:hy,useImperativeHandle:function(n,o,u){u=u!=null?u.concat([n]):null,Qu(4194308,4,py.bind(null,o,n),u)},useLayoutEffect:function(n,o){return Qu(4194308,4,n,o)},useInsertionEffect:function(n,o){Qu(4,2,n,o)},useMemo:function(n,o){var u=fn();o=o===void 0?null:o;var x=n();if(tc){ve(!0);try{n()}finally{ve(!1)}}return u.memoizedState=[x,o],x},useReducer:function(n,o,u){var x=fn();if(u!==void 0){var w=u(o);if(tc){ve(!0);try{u(o)}finally{ve(!1)}}}else w=o;return x.memoizedState=x.baseState=w,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:w},x.queue=n,n=n.dispatch=Sj.bind(null,Ta,n),[x.memoizedState,n]},useRef:function(n){var o=fn();return n={current:n},o.memoizedState=n},useState:function(n){n=Cg(n);var o=n.queue,u=Cy.bind(null,Ta,o);return o.dispatch=u,[n.memoizedState,u]},useDebugValue:Ag,useDeferredValue:function(n,o){var u=fn();return Og(u,n,o)},useTransition:function(){var n=Cg(!1);return n=wy.bind(null,Ta,n.queue,!0,!1),fn().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,o,u){var x=Ta,w=fn();if(Ua){if(u===void 0)throw Error(s(407));u=u()}else{if(u=o(),wr===null)throw Error(s(349));(Wa&127)!==0||Xp(x,o,u)}w.memoizedState=u;var S={value:u,getSnapshot:o};return w.queue=S,hy(Qp.bind(null,x,S,n),[n]),x.flags|=2048,nd(9,{destroy:void 0},Kp.bind(null,x,S,u,o),null),u},useId:function(){var n=fn(),o=wr.identifierPrefix;if(Ua){var u=Xt,x=Tt;u=(x&~(1<<32-Oe(x)-1)).toString(32)+u,o="_"+o+"R_"+u,u=Zu++,0<u&&(o+="H"+u.toString(32)),o+="_"}else u=bj++,o="_"+o+"r_"+u.toString(32)+"_";return n.memoizedState=o},useHostTransitionStatus:Mg,useFormState:ly,useActionState:ly,useOptimistic:function(n){var o=fn();o.memoizedState=o.baseState=n;var u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return o.queue=u,o=Lg.bind(null,Ta,!0,u),u.dispatch=o,[n,o]},useMemoCache:jg,useCacheRefresh:function(){return fn().memoizedState=Nj.bind(null,Ta)},useEffectEvent:function(n){var o=fn(),u={impl:n};return o.memoizedState=u,function(){if((rr&2)!==0)throw Error(s(440));return u.impl.apply(void 0,arguments)}}},Rg={readContext:Us,use:Xu,useCallback:by,useContext:Us,useEffect:Eg,useImperativeHandle:yy,useInsertionEffect:fy,useLayoutEffect:xy,useMemo:vy,useReducer:Ku,useRef:my,useState:function(){return Ku(Lo)},useDebugValue:Ag,useDeferredValue:function(n,o){var u=Xr();return _y(u,pr.memoizedState,n,o)},useTransition:function(){var n=Ku(Lo)[0],o=Xr().memoizedState;return[typeof n=="boolean"?n:b0(n),o]},useSyncExternalStore:Jp,useId:Ny,useHostTransitionStatus:Mg,useFormState:cy,useActionState:cy,useOptimistic:function(n,o){var u=Xr();return ay(u,pr,n,o)},useMemoCache:jg,useCacheRefresh:Sy};Rg.useEffectEvent=gy;var Oy={readContext:Us,use:Xu,useCallback:by,useContext:Us,useEffect:Eg,useImperativeHandle:yy,useInsertionEffect:fy,useLayoutEffect:xy,useMemo:vy,useReducer:Sg,useRef:my,useState:function(){return Sg(Lo)},useDebugValue:Ag,useDeferredValue:function(n,o){var u=Xr();return pr===null?Og(u,n,o):_y(u,pr.memoizedState,n,o)},useTransition:function(){var n=Sg(Lo)[0],o=Xr().memoizedState;return[typeof n=="boolean"?n:b0(n),o]},useSyncExternalStore:Jp,useId:Ny,useHostTransitionStatus:Mg,useFormState:uy,useActionState:uy,useOptimistic:function(n,o){var u=Xr();return pr!==null?ay(u,pr,n,o):(u.baseState=n,[n,u.queue.dispatch])},useMemoCache:jg,useCacheRefresh:Sy};Oy.useEffectEvent=gy;function Pg(n,o,u,x){o=n.memoizedState,u=u(x,o),u=u==null?o:b({},o,u),n.memoizedState=u,n.lanes===0&&(n.updateQueue.baseState=u)}var Fg={enqueueSetState:function(n,o,u){n=n._reactInternals;var x=Xn(),w=cl(x);w.payload=o,u!=null&&(w.callback=u),o=dl(n,w,x),o!==null&&(On(o,n,x),f0(o,n,x))},enqueueReplaceState:function(n,o,u){n=n._reactInternals;var x=Xn(),w=cl(x);w.tag=1,w.payload=o,u!=null&&(w.callback=u),o=dl(n,w,x),o!==null&&(On(o,n,x),f0(o,n,x))},enqueueForceUpdate:function(n,o){n=n._reactInternals;var u=Xn(),x=cl(u);x.tag=2,o!=null&&(x.callback=o),o=dl(n,x,u),o!==null&&(On(o,n,u),f0(o,n,u))}};function Dy(n,o,u,x,w,S,q){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(x,S,q):o.prototype&&o.prototype.isPureReactComponent?!Qi(u,x)||!Qi(w,S):!0}function My(n,o,u,x){n=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(u,x),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(u,x),o.state!==n&&Fg.enqueueReplaceState(o,o.state,null)}function ac(n,o){var u=o;if("ref"in o){u={};for(var x in o)x!=="ref"&&(u[x]=o[x])}if(n=n.defaultProps){u===o&&(u=b({},u));for(var w in n)u[w]===void 0&&(u[w]=n[w])}return u}function Ly(n){Bs(n)}function Ry(n){console.error(n)}function Py(n){Bs(n)}function am(n,o){try{var u=n.onUncaughtError;u(o.value,{componentStack:o.stack})}catch(x){setTimeout(function(){throw x})}}function Fy(n,o,u){try{var x=n.onCaughtError;x(u.value,{componentStack:u.stack,errorBoundary:o.tag===1?o.stateNode:null})}catch(w){setTimeout(function(){throw w})}}function Ig(n,o,u){return u=cl(u),u.tag=3,u.payload={element:null},u.callback=function(){am(n,o)},u}function Iy(n){return n=cl(n),n.tag=3,n}function zy(n,o,u,x){var w=u.type.getDerivedStateFromError;if(typeof w=="function"){var S=x.value;n.payload=function(){return w(S)},n.callback=function(){Fy(o,u,x)}}var q=u.stateNode;q!==null&&typeof q.componentDidCatch=="function"&&(n.callback=function(){Fy(o,u,x),typeof w!="function"&&(xl===null?xl=new Set([this]):xl.add(this));var ge=x.stack;this.componentDidCatch(x.value,{componentStack:ge!==null?ge:""})})}function Cj(n,o,u,x,w){if(u.flags|=32768,x!==null&&typeof x=="object"&&typeof x.then=="function"){if(o=u.alternate,o!==null&&Xc(o,u,w,!0),u=Gn.current,u!==null){switch(u.tag){case 31:case 13:return gi===null?gm():u.alternate===null&&Hr===0&&(Hr=3),u.flags&=-257,u.flags|=65536,u.lanes=w,x===Hu?u.flags|=16384:(o=u.updateQueue,o===null?u.updateQueue=new Set([x]):o.add(x),df(n,x,w)),!1;case 22:return u.flags|=65536,x===Hu?u.flags|=16384:(o=u.updateQueue,o===null?(o={transitions:null,markerInstances:null,retryQueue:new Set([x])},u.updateQueue=o):(u=o.retryQueue,u===null?o.retryQueue=new Set([x]):u.add(x)),df(n,x,w)),!1}throw Error(s(435,u.tag))}return df(n,x,w),gm(),!1}if(Ua)return o=Gn.current,o!==null?((o.flags&65536)===0&&(o.flags|=256),o.flags|=65536,o.lanes=w,x!==Jc&&(n=Error(s(422),{cause:x}),Yl(f(n,u)))):(x!==Jc&&(o=Error(s(423),{cause:x}),Yl(f(o,u))),n=n.current.alternate,n.flags|=65536,w&=-w,n.lanes|=w,x=f(x,u),w=Ig(n.stateNode,x,w),gg(n,w),Hr!==4&&(Hr=2)),!1;var S=Error(s(520),{cause:x});if(S=f(S,u),E0===null?E0=[S]:E0.push(S),Hr!==4&&(Hr=2),o===null)return!0;x=f(x,u),u=o;do{switch(u.tag){case 3:return u.flags|=65536,n=w&-w,u.lanes|=n,n=Ig(u.stateNode,x,n),gg(u,n),!1;case 1:if(o=u.type,S=u.stateNode,(u.flags&128)===0&&(typeof o.getDerivedStateFromError=="function"||S!==null&&typeof S.componentDidCatch=="function"&&(xl===null||!xl.has(S))))return u.flags|=65536,w&=-w,u.lanes|=w,w=Iy(w),zy(w,n,u,x),gg(u,w),!1}u=u.return}while(u!==null);return!1}var zg=Error(s(461)),ns=!1;function $s(n,o,u,x){o.child=n===null?Hp(o,null,u,x):ec(o,n.child,u,x)}function By(n,o,u,x,w){u=u.render;var S=o.ref;if("ref"in x){var q={};for(var ge in x)ge!=="ref"&&(q[ge]=x[ge])}else q=x;return Jl(o),x=vg(n,o,u,q,S,w),ge=_g(),n!==null&&!ns?(wg(n,o,w),Ro(n,o,w)):(Ua&&ge&&ps(o),o.flags|=1,$s(n,o,x,w),o.child)}function Uy(n,o,u,x,w){if(n===null){var S=u.type;return typeof S=="function"&&!Yc(S)&&S.defaultProps===void 0&&u.compare===null?(o.tag=15,o.type=S,$y(n,o,S,x,w)):(n=Gl(u.type,null,x,o,o.mode,w),n.ref=o.ref,n.return=o,o.child=n)}if(S=n.child,!Gg(n,w)){var q=S.memoizedProps;if(u=u.compare,u=u!==null?u:Qi,u(q,x)&&n.ref===o.ref)return Ro(n,o,w)}return o.flags|=1,n=hi(S,x),n.ref=o.ref,n.return=o,o.child=n}function $y(n,o,u,x,w){if(n!==null){var S=n.memoizedProps;if(Qi(S,x)&&n.ref===o.ref)if(ns=!1,o.pendingProps=x=S,Gg(n,w))(n.flags&131072)!==0&&(ns=!0);else return o.lanes=n.lanes,Ro(n,o,w)}return Bg(n,o,u,x,w)}function Hy(n,o,u,x){var w=x.children,S=n!==null?n.memoizedState:null;if(n===null&&o.stateNode===null&&(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),x.mode==="hidden"){if((o.flags&128)!==0){if(S=S!==null?S.baseLanes|u:u,n!==null){for(x=o.child=n.child,w=0;x!==null;)w=w|x.lanes|x.childLanes,x=x.sibling;x=w&~S}else x=0,o.child=null;return Wy(n,o,S,u,x)}if((u&536870912)!==0)o.memoizedState={baseLanes:0,cachePool:null},n!==null&&Uu(o,S!==null?S.cachePool:null),S!==null?qp(o,S):xg(),Gp(o);else return x=o.lanes=536870912,Wy(n,o,S!==null?S.baseLanes|u:u,u,x)}else S!==null?(Uu(o,S.cachePool),qp(o,S),ml(),o.memoizedState=null):(n!==null&&Uu(o,null),xg(),ml());return $s(n,o,w,u),o.child}function w0(n,o){return n!==null&&n.tag===22||o.stateNode!==null||(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.sibling}function Wy(n,o,u,x,w){var S=dg();return S=S===null?null:{parent:rs._currentValue,pool:S},o.memoizedState={baseLanes:u,cachePool:S},n!==null&&Uu(o,null),xg(),Gp(o),n!==null&&Xc(n,o,x,!0),o.childLanes=w,null}function rm(n,o){return o=nm({mode:o.mode,children:o.children},n.mode),o.ref=n.ref,n.child=o,o.return=n,o}function Vy(n,o,u){return ec(o,n.child,null,u),n=rm(o,o.pendingProps),n.flags|=2,Yn(o),o.memoizedState=null,n}function Tj(n,o,u){var x=o.pendingProps,w=(o.flags&128)!==0;if(o.flags&=-129,n===null){if(Ua){if(x.mode==="hidden")return n=rm(o,x),o.lanes=536870912,w0(null,n);if(yg(o),(n=Ka)?(n=rv(n,Sn),n=n!==null&&n.data==="&"?n:null,n!==null&&(o.memoizedState={dehydrated:n,treeContext:tt!==null?{id:Tt,overflow:Xt}:null,retryLane:536870912,hydrationErrors:null},u=o0(n),u.return=o,o.child=u,Xa=o,Ka=null)):n=null,n===null)throw so(o);return o.lanes=536870912,null}return rm(o,x)}var S=n.memoizedState;if(S!==null){var q=S.dehydrated;if(yg(o),w)if(o.flags&256)o.flags&=-257,o=Vy(n,o,u);else if(o.memoizedState!==null)o.child=n.child,o.flags|=128,o=null;else throw Error(s(558));else if(ns||Xc(n,o,u,!1),w=(u&n.childLanes)!==0,ns||w){if(x=wr,x!==null&&(q=It(x,u),q!==0&&q!==S.retryLane))throw S.retryLane=q,mi(n,q),On(x,n,q),zg;gm(),o=Vy(n,o,u)}else n=S.treeContext,Ka=fi(q.nextSibling),Xa=o,Ua=!0,ro=null,Sn=!1,n!==null&&gn(o,n),o=rm(o,x),o.flags|=4096;return o}return n=hi(n.child,{mode:x.mode,children:x.children}),n.ref=o.ref,o.child=n,n.return=o,n}function sm(n,o){var u=o.ref;if(u===null)n!==null&&n.ref!==null&&(o.flags|=4194816);else{if(typeof u!="function"&&typeof u!="object")throw Error(s(284));(n===null||n.ref!==u)&&(o.flags|=4194816)}}function Bg(n,o,u,x,w){return Jl(o),u=vg(n,o,u,x,void 0,w),x=_g(),n!==null&&!ns?(wg(n,o,w),Ro(n,o,w)):(Ua&&x&&ps(o),o.flags|=1,$s(n,o,u,w),o.child)}function qy(n,o,u,x,w,S){return Jl(o),o.updateQueue=null,u=Zp(o,x,u,w),Yp(n),x=_g(),n!==null&&!ns?(wg(n,o,S),Ro(n,o,S)):(Ua&&x&&ps(o),o.flags|=1,$s(n,o,u,S),o.child)}function Gy(n,o,u,x,w){if(Jl(o),o.stateNode===null){var S=Eo,q=u.contextType;typeof q=="object"&&q!==null&&(S=Us(q)),S=new u(x,S),o.memoizedState=S.state!==null&&S.state!==void 0?S.state:null,S.updater=Fg,o.stateNode=S,S._reactInternals=o,S=o.stateNode,S.props=x,S.state=o.memoizedState,S.refs={},mg(o),q=u.contextType,S.context=typeof q=="object"&&q!==null?Us(q):Eo,S.state=o.memoizedState,q=u.getDerivedStateFromProps,typeof q=="function"&&(Pg(o,u,q,x),S.state=o.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof S.getSnapshotBeforeUpdate=="function"||typeof S.UNSAFE_componentWillMount!="function"&&typeof S.componentWillMount!="function"||(q=S.state,typeof S.componentWillMount=="function"&&S.componentWillMount(),typeof S.UNSAFE_componentWillMount=="function"&&S.UNSAFE_componentWillMount(),q!==S.state&&Fg.enqueueReplaceState(S,S.state,null),p0(o,x,S,w),x0(),S.state=o.memoizedState),typeof S.componentDidMount=="function"&&(o.flags|=4194308),x=!0}else if(n===null){S=o.stateNode;var ge=o.memoizedProps,Ae=ac(u,ge);S.props=Ae;var Ke=S.context,vt=u.contextType;q=Eo,typeof vt=="object"&&vt!==null&&(q=Us(vt));var Et=u.getDerivedStateFromProps;vt=typeof Et=="function"||typeof S.getSnapshotBeforeUpdate=="function",ge=o.pendingProps!==ge,vt||typeof S.UNSAFE_componentWillReceiveProps!="function"&&typeof S.componentWillReceiveProps!="function"||(ge||Ke!==q)&&My(o,S,x,q),ll=!1;var at=o.memoizedState;S.state=at,p0(o,x,S,w),x0(),Ke=o.memoizedState,ge||at!==Ke||ll?(typeof Et=="function"&&(Pg(o,u,Et,x),Ke=o.memoizedState),(Ae=ll||Dy(o,u,Ae,x,at,Ke,q))?(vt||typeof S.UNSAFE_componentWillMount!="function"&&typeof S.componentWillMount!="function"||(typeof S.componentWillMount=="function"&&S.componentWillMount(),typeof S.UNSAFE_componentWillMount=="function"&&S.UNSAFE_componentWillMount()),typeof S.componentDidMount=="function"&&(o.flags|=4194308)):(typeof S.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=x,o.memoizedState=Ke),S.props=x,S.state=Ke,S.context=q,x=Ae):(typeof S.componentDidMount=="function"&&(o.flags|=4194308),x=!1)}else{S=o.stateNode,hg(n,o),q=o.memoizedProps,vt=ac(u,q),S.props=vt,Et=o.pendingProps,at=S.context,Ke=u.contextType,Ae=Eo,typeof Ke=="object"&&Ke!==null&&(Ae=Us(Ke)),ge=u.getDerivedStateFromProps,(Ke=typeof ge=="function"||typeof S.getSnapshotBeforeUpdate=="function")||typeof S.UNSAFE_componentWillReceiveProps!="function"&&typeof S.componentWillReceiveProps!="function"||(q!==Et||at!==Ae)&&My(o,S,x,Ae),ll=!1,at=o.memoizedState,S.state=at,p0(o,x,S,w),x0();var ut=o.memoizedState;q!==Et||at!==ut||ll||n!==null&&n.dependencies!==null&&zu(n.dependencies)?(typeof ge=="function"&&(Pg(o,u,ge,x),ut=o.memoizedState),(vt=ll||Dy(o,u,vt,x,at,ut,Ae)||n!==null&&n.dependencies!==null&&zu(n.dependencies))?(Ke||typeof S.UNSAFE_componentWillUpdate!="function"&&typeof S.componentWillUpdate!="function"||(typeof S.componentWillUpdate=="function"&&S.componentWillUpdate(x,ut,Ae),typeof S.UNSAFE_componentWillUpdate=="function"&&S.UNSAFE_componentWillUpdate(x,ut,Ae)),typeof S.componentDidUpdate=="function"&&(o.flags|=4),typeof S.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof S.componentDidUpdate!="function"||q===n.memoizedProps&&at===n.memoizedState||(o.flags|=4),typeof S.getSnapshotBeforeUpdate!="function"||q===n.memoizedProps&&at===n.memoizedState||(o.flags|=1024),o.memoizedProps=x,o.memoizedState=ut),S.props=x,S.state=ut,S.context=Ae,x=vt):(typeof S.componentDidUpdate!="function"||q===n.memoizedProps&&at===n.memoizedState||(o.flags|=4),typeof S.getSnapshotBeforeUpdate!="function"||q===n.memoizedProps&&at===n.memoizedState||(o.flags|=1024),x=!1)}return S=x,sm(n,o),x=(o.flags&128)!==0,S||x?(S=o.stateNode,u=x&&typeof u.getDerivedStateFromError!="function"?null:S.render(),o.flags|=1,n!==null&&x?(o.child=ec(o,n.child,null,w),o.child=ec(o,null,u,w)):$s(n,o,u,w),o.memoizedState=S.state,n=o.child):n=Ro(n,o,w),n}function Yy(n,o,u,x){return Oo(),o.flags|=256,$s(n,o,u,x),o.child}var Ug={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function $g(n){return{baseLanes:n,cachePool:Fp()}}function Hg(n,o,u){return n=n!==null?n.childLanes&~u:0,o&&(n|=Jn),n}function Zy(n,o,u){var x=o.pendingProps,w=!1,S=(o.flags&128)!==0,q;if((q=S)||(q=n!==null&&n.memoizedState===null?!1:(Jr.current&2)!==0),q&&(w=!0,o.flags&=-129),q=(o.flags&32)!==0,o.flags&=-33,n===null){if(Ua){if(w?ul(o):ml(),(n=Ka)?(n=rv(n,Sn),n=n!==null&&n.data!=="&"?n:null,n!==null&&(o.memoizedState={dehydrated:n,treeContext:tt!==null?{id:Tt,overflow:Xt}:null,retryLane:536870912,hydrationErrors:null},u=o0(n),u.return=o,o.child=u,Xa=o,Ka=null)):n=null,n===null)throw so(o);return Sf(n)?o.lanes=32:o.lanes=536870912,null}var ge=x.children;return x=x.fallback,w?(ml(),w=o.mode,ge=nm({mode:"hidden",children:ge},w),x=Ao(x,w,u,null),ge.return=o,x.return=o,ge.sibling=x,o.child=ge,x=o.child,x.memoizedState=$g(u),x.childLanes=Hg(n,q,u),o.memoizedState=Ug,w0(null,x)):(ul(o),Wg(o,ge))}var Ae=n.memoizedState;if(Ae!==null&&(ge=Ae.dehydrated,ge!==null)){if(S)o.flags&256?(ul(o),o.flags&=-257,o=Vg(n,o,u)):o.memoizedState!==null?(ml(),o.child=n.child,o.flags|=128,o=null):(ml(),ge=x.fallback,w=o.mode,x=nm({mode:"visible",children:x.children},w),ge=Ao(ge,w,u,null),ge.flags|=2,x.return=o,ge.return=o,x.sibling=ge,o.child=x,ec(o,n.child,null,u),x=o.child,x.memoizedState=$g(u),x.childLanes=Hg(n,q,u),o.memoizedState=Ug,o=w0(null,x));else if(ul(o),Sf(ge)){if(q=ge.nextSibling&&ge.nextSibling.dataset,q)var Ke=q.dgst;q=Ke,x=Error(s(419)),x.stack="",x.digest=q,Yl({value:x,source:null,stack:null}),o=Vg(n,o,u)}else if(ns||Xc(n,o,u,!1),q=(u&n.childLanes)!==0,ns||q){if(q=wr,q!==null&&(x=It(q,u),x!==0&&x!==Ae.retryLane))throw Ae.retryLane=x,mi(n,x),On(q,n,x),zg;Nf(ge)||gm(),o=Vg(n,o,u)}else Nf(ge)?(o.flags|=192,o.child=n.child,o=null):(n=Ae.treeContext,Ka=fi(ge.nextSibling),Xa=o,Ua=!0,ro=null,Sn=!1,n!==null&&gn(o,n),o=Wg(o,x.children),o.flags|=4096);return o}return w?(ml(),ge=x.fallback,w=o.mode,Ae=n.child,Ke=Ae.sibling,x=hi(Ae,{mode:"hidden",children:x.children}),x.subtreeFlags=Ae.subtreeFlags&65011712,Ke!==null?ge=hi(Ke,ge):(ge=Ao(ge,w,u,null),ge.flags|=2),ge.return=o,x.return=o,x.sibling=ge,o.child=x,w0(null,x),x=o.child,ge=n.child.memoizedState,ge===null?ge=$g(u):(w=ge.cachePool,w!==null?(Ae=rs._currentValue,w=w.parent!==Ae?{parent:Ae,pool:Ae}:w):w=Fp(),ge={baseLanes:ge.baseLanes|u,cachePool:w}),x.memoizedState=ge,x.childLanes=Hg(n,q,u),o.memoizedState=Ug,w0(n.child,x)):(ul(o),u=n.child,n=u.sibling,u=hi(u,{mode:"visible",children:x.children}),u.return=o,u.sibling=null,n!==null&&(q=o.deletions,q===null?(o.deletions=[n],o.flags|=16):q.push(n)),o.child=u,o.memoizedState=null,u)}function Wg(n,o){return o=nm({mode:"visible",children:o},n.mode),o.return=n,n.child=o}function nm(n,o){return n=rn(22,n,null,o),n.lanes=0,n}function Vg(n,o,u){return ec(o,n.child,null,u),n=Wg(o,o.pendingProps.children),n.flags|=2,o.memoizedState=null,n}function Jy(n,o,u){n.lanes|=o;var x=n.alternate;x!==null&&(x.lanes|=o),ig(n.return,o,u)}function qg(n,o,u,x,w,S){var q=n.memoizedState;q===null?n.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:x,tail:u,tailMode:w,treeForkCount:S}:(q.isBackwards=o,q.rendering=null,q.renderingStartTime=0,q.last=x,q.tail=u,q.tailMode=w,q.treeForkCount=S)}function Xy(n,o,u){var x=o.pendingProps,w=x.revealOrder,S=x.tail;x=x.children;var q=Jr.current,ge=(q&2)!==0;if(ge?(q=q&1|2,o.flags|=128):q&=1,B(Jr,q),$s(n,o,x,u),x=Ua?le:0,!ge&&n!==null&&(n.flags&128)!==0)e:for(n=o.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&Jy(n,u,o);else if(n.tag===19)Jy(n,u,o);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===o)break e;for(;n.sibling===null;){if(n.return===null||n.return===o)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}switch(w){case"forwards":for(u=o.child,w=null;u!==null;)n=u.alternate,n!==null&&Gu(n)===null&&(w=u),u=u.sibling;u=w,u===null?(w=o.child,o.child=null):(w=u.sibling,u.sibling=null),qg(o,!1,w,u,S,x);break;case"backwards":case"unstable_legacy-backwards":for(u=null,w=o.child,o.child=null;w!==null;){if(n=w.alternate,n!==null&&Gu(n)===null){o.child=w;break}n=w.sibling,w.sibling=u,u=w,w=n}qg(o,!0,u,null,S,x);break;case"together":qg(o,!1,null,null,void 0,x);break;default:o.memoizedState=null}return o.child}function Ro(n,o,u){if(n!==null&&(o.dependencies=n.dependencies),fl|=o.lanes,(u&o.childLanes)===0)if(n!==null){if(Xc(n,o,u,!1),(u&o.childLanes)===0)return null}else return null;if(n!==null&&o.child!==n.child)throw Error(s(153));if(o.child!==null){for(n=o.child,u=hi(n,n.pendingProps),o.child=u,u.return=o;n.sibling!==null;)n=n.sibling,u=u.sibling=hi(n,n.pendingProps),u.return=o;u.sibling=null}return o.child}function Gg(n,o){return(n.lanes&o)!==0?!0:(n=n.dependencies,!!(n!==null&&zu(n)))}function Ej(n,o,u){switch(o.tag){case 3:ke(o,o.stateNode.containerInfo),ol(o,rs,n.memoizedState.cache),Oo();break;case 27:case 5:z(o);break;case 4:ke(o,o.stateNode.containerInfo);break;case 10:ol(o,o.type,o.memoizedProps.value);break;case 31:if(o.memoizedState!==null)return o.flags|=128,yg(o),null;break;case 13:var x=o.memoizedState;if(x!==null)return x.dehydrated!==null?(ul(o),o.flags|=128,null):(u&o.child.childLanes)!==0?Zy(n,o,u):(ul(o),n=Ro(n,o,u),n!==null?n.sibling:null);ul(o);break;case 19:var w=(n.flags&128)!==0;if(x=(u&o.childLanes)!==0,x||(Xc(n,o,u,!1),x=(u&o.childLanes)!==0),w){if(x)return Xy(n,o,u);o.flags|=128}if(w=o.memoizedState,w!==null&&(w.rendering=null,w.tail=null,w.lastEffect=null),B(Jr,Jr.current),x)break;return null;case 22:return o.lanes=0,Hy(n,o,u,o.pendingProps);case 24:ol(o,rs,n.memoizedState.cache)}return Ro(n,o,u)}function Ky(n,o,u){if(n!==null)if(n.memoizedProps!==o.pendingProps)ns=!0;else{if(!Gg(n,u)&&(o.flags&128)===0)return ns=!1,Ej(n,o,u);ns=(n.flags&131072)!==0}else ns=!1,Ua&&(o.flags&1048576)!==0&&Oa(o,le,o.index);switch(o.lanes=0,o.tag){case 16:e:{var x=o.pendingProps;if(n=Kl(o.elementType),o.type=n,typeof n=="function")Yc(n)?(x=ac(n,x),o.tag=1,o=Gy(null,o,n,x,u)):(o.tag=0,o=Bg(null,o,n,x,u));else{if(n!=null){var w=n.$$typeof;if(w===O){o.tag=11,o=By(null,o,n,x,u);break e}else if(w===P){o.tag=14,o=Uy(null,o,n,x,u);break e}}throw o=se(n)||n,Error(s(306,o,""))}}return o;case 0:return Bg(n,o,o.type,o.pendingProps,u);case 1:return x=o.type,w=ac(x,o.pendingProps),Gy(n,o,x,w,u);case 3:e:{if(ke(o,o.stateNode.containerInfo),n===null)throw Error(s(387));x=o.pendingProps;var S=o.memoizedState;w=S.element,hg(n,o),p0(o,x,null,u);var q=o.memoizedState;if(x=q.cache,ol(o,rs,x),x!==S.cache&&og(o,[rs],u,!0),x0(),x=q.element,S.isDehydrated)if(S={element:x,isDehydrated:!1,cache:q.cache},o.updateQueue.baseState=S,o.memoizedState=S,o.flags&256){o=Yy(n,o,x,u);break e}else if(x!==w){w=f(Error(s(424)),o),Yl(w),o=Yy(n,o,x,u);break e}else{switch(n=o.stateNode.containerInfo,n.nodeType){case 9:n=n.body;break;default:n=n.nodeName==="HTML"?n.ownerDocument.body:n}for(Ka=fi(n.firstChild),Xa=o,Ua=!0,ro=null,Sn=!0,u=Hp(o,null,x,u),o.child=u;u;)u.flags=u.flags&-3|4096,u=u.sibling}else{if(Oo(),x===w){o=Ro(n,o,u);break e}$s(n,o,x,u)}o=o.child}return o;case 26:return sm(n,o),n===null?(u=cv(o.type,null,o.pendingProps,null))?o.memoizedState=u:Ua||(u=o.type,n=o.pendingProps,x=_m(we.current).createElement(u),x[ie]=o,x[xe]=n,Hs(x,u,n),Zt(x),o.stateNode=x):o.memoizedState=cv(o.type,n.memoizedProps,o.pendingProps,n.memoizedState),null;case 27:return z(o),n===null&&Ua&&(x=o.stateNode=iv(o.type,o.pendingProps,we.current),Xa=o,Sn=!0,w=Ka,vl(o.type)?(Cf=w,Ka=fi(x.firstChild)):Ka=w),$s(n,o,o.pendingProps.children,u),sm(n,o),n===null&&(o.flags|=4194304),o.child;case 5:return n===null&&Ua&&((w=x=Ka)&&(x=nN(x,o.type,o.pendingProps,Sn),x!==null?(o.stateNode=x,Xa=o,Ka=fi(x.firstChild),Sn=!1,w=!0):w=!1),w||so(o)),z(o),w=o.type,S=o.pendingProps,q=n!==null?n.memoizedProps:null,x=S.children,wf(w,S)?x=null:q!==null&&wf(w,q)&&(o.flags|=32),o.memoizedState!==null&&(w=vg(n,o,vj,null,null,u),F0._currentValue=w),sm(n,o),$s(n,o,x,u),o.child;case 6:return n===null&&Ua&&((n=u=Ka)&&(u=iN(u,o.pendingProps,Sn),u!==null?(o.stateNode=u,Xa=o,Ka=null,n=!0):n=!1),n||so(o)),null;case 13:return Zy(n,o,u);case 4:return ke(o,o.stateNode.containerInfo),x=o.pendingProps,n===null?o.child=ec(o,null,x,u):$s(n,o,x,u),o.child;case 11:return By(n,o,o.type,o.pendingProps,u);case 7:return $s(n,o,o.pendingProps,u),o.child;case 8:return $s(n,o,o.pendingProps.children,u),o.child;case 12:return $s(n,o,o.pendingProps.children,u),o.child;case 10:return x=o.pendingProps,ol(o,o.type,x.value),$s(n,o,x.children,u),o.child;case 9:return w=o.type._context,x=o.pendingProps.children,Jl(o),w=Us(w),x=x(w),o.flags|=1,$s(n,o,x,u),o.child;case 14:return Uy(n,o,o.type,o.pendingProps,u);case 15:return $y(n,o,o.type,o.pendingProps,u);case 19:return Xy(n,o,u);case 31:return Tj(n,o,u);case 22:return Hy(n,o,u,o.pendingProps);case 24:return Jl(o),x=Us(rs),n===null?(w=dg(),w===null&&(w=wr,S=lg(),w.pooledCache=S,S.refCount++,S!==null&&(w.pooledCacheLanes|=u),w=S),o.memoizedState={parent:x,cache:w},mg(o),ol(o,rs,w)):((n.lanes&u)!==0&&(hg(n,o),p0(o,null,null,u),x0()),w=n.memoizedState,S=o.memoizedState,w.parent!==x?(w={parent:x,cache:x},o.memoizedState=w,o.lanes===0&&(o.memoizedState=o.updateQueue.baseState=w),ol(o,rs,x)):(x=S.cache,ol(o,rs,x),x!==w.cache&&og(o,[rs],u,!0))),$s(n,o,o.pendingProps.children,u),o.child;case 29:throw o.pendingProps}throw Error(s(156,o.tag))}function Po(n){n.flags|=4}function Yg(n,o,u,x,w){if((o=(n.mode&32)!==0)&&(o=!1),o){if(n.flags|=16777216,(w&335544128)===w)if(n.stateNode.complete)n.flags|=8192;else if(Nb())n.flags|=8192;else throw Ql=Hu,ug}else n.flags&=-16777217}function Qy(n,o){if(o.type!=="stylesheet"||(o.state.loading&4)!==0)n.flags&=-16777217;else if(n.flags|=16777216,!gv(o))if(Nb())n.flags|=8192;else throw Ql=Hu,ug}function im(n,o){o!==null&&(n.flags|=4),n.flags&16384&&(o=n.tag!==22?Qe():536870912,n.lanes|=o,cd|=o)}function k0(n,o){if(!Ua)switch(n.tailMode){case"hidden":o=n.tail;for(var u=null;o!==null;)o.alternate!==null&&(u=o),o=o.sibling;u===null?n.tail=null:u.sibling=null;break;case"collapsed":u=n.tail;for(var x=null;u!==null;)u.alternate!==null&&(x=u),u=u.sibling;x===null?o||n.tail===null?n.tail=null:n.tail.sibling=null:x.sibling=null}}function Er(n){var o=n.alternate!==null&&n.alternate.child===n.child,u=0,x=0;if(o)for(var w=n.child;w!==null;)u|=w.lanes|w.childLanes,x|=w.subtreeFlags&65011712,x|=w.flags&65011712,w.return=n,w=w.sibling;else for(w=n.child;w!==null;)u|=w.lanes|w.childLanes,x|=w.subtreeFlags,x|=w.flags,w.return=n,w=w.sibling;return n.subtreeFlags|=x,n.childLanes=u,o}function Aj(n,o,u){var x=o.pendingProps;switch(Ur(o),o.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Er(o),null;case 1:return Er(o),null;case 3:return u=o.stateNode,x=null,n!==null&&(x=n.memoizedState.cache),o.memoizedState.cache!==x&&(o.flags|=2048),Do(rs),Me(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(n===null||n.child===null)&&(Ni(o)?Po(o):n===null||n.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,d0())),Er(o),null;case 26:var w=o.type,S=o.memoizedState;return n===null?(Po(o),S!==null?(Er(o),Qy(o,S)):(Er(o),Yg(o,w,null,x,u))):S?S!==n.memoizedState?(Po(o),Er(o),Qy(o,S)):(Er(o),o.flags&=-16777217):(n=n.memoizedProps,n!==x&&Po(o),Er(o),Yg(o,w,n,x,u)),null;case 27:if(Ne(o),u=we.current,w=o.type,n!==null&&o.stateNode!=null)n.memoizedProps!==x&&Po(o);else{if(!x){if(o.stateNode===null)throw Error(s(166));return Er(o),null}n=X.current,Ni(o)?c0(o):(n=iv(w,x,u),o.stateNode=n,Po(o))}return Er(o),null;case 5:if(Ne(o),w=o.type,n!==null&&o.stateNode!=null)n.memoizedProps!==x&&Po(o);else{if(!x){if(o.stateNode===null)throw Error(s(166));return Er(o),null}if(S=X.current,Ni(o))c0(o);else{var q=_m(we.current);switch(S){case 1:S=q.createElementNS("http://www.w3.org/2000/svg",w);break;case 2:S=q.createElementNS("http://www.w3.org/1998/Math/MathML",w);break;default:switch(w){case"svg":S=q.createElementNS("http://www.w3.org/2000/svg",w);break;case"math":S=q.createElementNS("http://www.w3.org/1998/Math/MathML",w);break;case"script":S=q.createElement("div"),S.innerHTML="<script><\/script>",S=S.removeChild(S.firstChild);break;case"select":S=typeof x.is=="string"?q.createElement("select",{is:x.is}):q.createElement("select"),x.multiple?S.multiple=!0:x.size&&(S.size=x.size);break;default:S=typeof x.is=="string"?q.createElement(w,{is:x.is}):q.createElement(w)}}S[ie]=o,S[xe]=x;e:for(q=o.child;q!==null;){if(q.tag===5||q.tag===6)S.appendChild(q.stateNode);else if(q.tag!==4&&q.tag!==27&&q.child!==null){q.child.return=q,q=q.child;continue}if(q===o)break e;for(;q.sibling===null;){if(q.return===null||q.return===o)break e;q=q.return}q.sibling.return=q.return,q=q.sibling}o.stateNode=S;e:switch(Hs(S,w,x),w){case"button":case"input":case"select":case"textarea":x=!!x.autoFocus;break e;case"img":x=!0;break e;default:x=!1}x&&Po(o)}}return Er(o),Yg(o,o.type,n===null?null:n.memoizedProps,o.pendingProps,u),null;case 6:if(n&&o.stateNode!=null)n.memoizedProps!==x&&Po(o);else{if(typeof x!="string"&&o.stateNode===null)throw Error(s(166));if(n=we.current,Ni(o)){if(n=o.stateNode,u=o.memoizedProps,x=null,w=Xa,w!==null)switch(w.tag){case 27:case 5:x=w.memoizedProps}n[ie]=o,n=!!(n.nodeValue===u||x!==null&&x.suppressHydrationWarning===!0||Zb(n.nodeValue,u)),n||so(o,!0)}else n=_m(n).createTextNode(x),n[ie]=o,o.stateNode=n}return Er(o),null;case 31:if(u=o.memoizedState,n===null||n.memoizedState!==null){if(x=Ni(o),u!==null){if(n===null){if(!x)throw Error(s(318));if(n=o.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(557));n[ie]=o}else Oo(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Er(o),n=!1}else u=d0(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=u),n=!0;if(!n)return o.flags&256?(Yn(o),o):(Yn(o),null);if((o.flags&128)!==0)throw Error(s(558))}return Er(o),null;case 13:if(x=o.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(w=Ni(o),x!==null&&x.dehydrated!==null){if(n===null){if(!w)throw Error(s(318));if(w=o.memoizedState,w=w!==null?w.dehydrated:null,!w)throw Error(s(317));w[ie]=o}else Oo(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Er(o),w=!1}else w=d0(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=w),w=!0;if(!w)return o.flags&256?(Yn(o),o):(Yn(o),null)}return Yn(o),(o.flags&128)!==0?(o.lanes=u,o):(u=x!==null,n=n!==null&&n.memoizedState!==null,u&&(x=o.child,w=null,x.alternate!==null&&x.alternate.memoizedState!==null&&x.alternate.memoizedState.cachePool!==null&&(w=x.alternate.memoizedState.cachePool.pool),S=null,x.memoizedState!==null&&x.memoizedState.cachePool!==null&&(S=x.memoizedState.cachePool.pool),S!==w&&(x.flags|=2048)),u!==n&&u&&(o.child.flags|=8192),im(o,o.updateQueue),Er(o),null);case 4:return Me(),n===null&&pf(o.stateNode.containerInfo),Er(o),null;case 10:return Do(o.type),Er(o),null;case 19:if(M(Jr),x=o.memoizedState,x===null)return Er(o),null;if(w=(o.flags&128)!==0,S=x.rendering,S===null)if(w)k0(x,!1);else{if(Hr!==0||n!==null&&(n.flags&128)!==0)for(n=o.child;n!==null;){if(S=Gu(n),S!==null){for(o.flags|=128,k0(x,!1),n=S.updateQueue,o.updateQueue=n,im(o,n),o.subtreeFlags=0,n=u,u=o.child;u!==null;)i0(u,n),u=u.sibling;return B(Jr,Jr.current&1|2),Ua&&ua(o,x.treeForkCount),o.child}n=n.sibling}x.tail!==null&&sa()>um&&(o.flags|=128,w=!0,k0(x,!1),o.lanes=4194304)}else{if(!w)if(n=Gu(S),n!==null){if(o.flags|=128,w=!0,n=n.updateQueue,o.updateQueue=n,im(o,n),k0(x,!0),x.tail===null&&x.tailMode==="hidden"&&!S.alternate&&!Ua)return Er(o),null}else 2*sa()-x.renderingStartTime>um&&u!==536870912&&(o.flags|=128,w=!0,k0(x,!1),o.lanes=4194304);x.isBackwards?(S.sibling=o.child,o.child=S):(n=x.last,n!==null?n.sibling=S:o.child=S,x.last=S)}return x.tail!==null?(n=x.tail,x.rendering=n,x.tail=n.sibling,x.renderingStartTime=sa(),n.sibling=null,u=Jr.current,B(Jr,w?u&1|2:u&1),Ua&&ua(o,x.treeForkCount),n):(Er(o),null);case 22:case 23:return Yn(o),pg(),x=o.memoizedState!==null,n!==null?n.memoizedState!==null!==x&&(o.flags|=8192):x&&(o.flags|=8192),x?(u&536870912)!==0&&(o.flags&128)===0&&(Er(o),o.subtreeFlags&6&&(o.flags|=8192)):Er(o),u=o.updateQueue,u!==null&&im(o,u.retryQueue),u=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(u=n.memoizedState.cachePool.pool),x=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(x=o.memoizedState.cachePool.pool),x!==u&&(o.flags|=2048),n!==null&&M(Xl),null;case 24:return u=null,n!==null&&(u=n.memoizedState.cache),o.memoizedState.cache!==u&&(o.flags|=2048),Do(rs),Er(o),null;case 25:return null;case 30:return null}throw Error(s(156,o.tag))}function Oj(n,o){switch(Ur(o),o.tag){case 1:return n=o.flags,n&65536?(o.flags=n&-65537|128,o):null;case 3:return Do(rs),Me(),n=o.flags,(n&65536)!==0&&(n&128)===0?(o.flags=n&-65537|128,o):null;case 26:case 27:case 5:return Ne(o),null;case 31:if(o.memoizedState!==null){if(Yn(o),o.alternate===null)throw Error(s(340));Oo()}return n=o.flags,n&65536?(o.flags=n&-65537|128,o):null;case 13:if(Yn(o),n=o.memoizedState,n!==null&&n.dehydrated!==null){if(o.alternate===null)throw Error(s(340));Oo()}return n=o.flags,n&65536?(o.flags=n&-65537|128,o):null;case 19:return M(Jr),null;case 4:return Me(),null;case 10:return Do(o.type),null;case 22:case 23:return Yn(o),pg(),n!==null&&M(Xl),n=o.flags,n&65536?(o.flags=n&-65537|128,o):null;case 24:return Do(rs),null;case 25:return null;default:return null}}function eb(n,o){switch(Ur(o),o.tag){case 3:Do(rs),Me();break;case 26:case 27:case 5:Ne(o);break;case 4:Me();break;case 31:o.memoizedState!==null&&Yn(o);break;case 13:Yn(o);break;case 19:M(Jr);break;case 10:Do(o.type);break;case 22:case 23:Yn(o),pg(),n!==null&&M(Xl);break;case 24:Do(rs)}}function j0(n,o){try{var u=o.updateQueue,x=u!==null?u.lastEffect:null;if(x!==null){var w=x.next;u=w;do{if((u.tag&n)===n){x=void 0;var S=u.create,q=u.inst;x=S(),q.destroy=x}u=u.next}while(u!==w)}}catch(ge){cr(o,o.return,ge)}}function hl(n,o,u){try{var x=o.updateQueue,w=x!==null?x.lastEffect:null;if(w!==null){var S=w.next;x=S;do{if((x.tag&n)===n){var q=x.inst,ge=q.destroy;if(ge!==void 0){q.destroy=void 0,w=o;var Ae=u,Ke=ge;try{Ke()}catch(vt){cr(w,Ae,vt)}}}x=x.next}while(x!==S)}}catch(vt){cr(o,o.return,vt)}}function tb(n){var o=n.updateQueue;if(o!==null){var u=n.stateNode;try{Vp(o,u)}catch(x){cr(n,n.return,x)}}}function ab(n,o,u){u.props=ac(n.type,n.memoizedProps),u.state=n.memoizedState;try{u.componentWillUnmount()}catch(x){cr(n,o,x)}}function N0(n,o){try{var u=n.ref;if(u!==null){switch(n.tag){case 26:case 27:case 5:var x=n.stateNode;break;case 30:x=n.stateNode;break;default:x=n.stateNode}typeof u=="function"?n.refCleanup=u(x):u.current=x}}catch(w){cr(n,o,w)}}function io(n,o){var u=n.ref,x=n.refCleanup;if(u!==null)if(typeof x=="function")try{x()}catch(w){cr(n,o,w)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof u=="function")try{u(null)}catch(w){cr(n,o,w)}else u.current=null}function rb(n){var o=n.type,u=n.memoizedProps,x=n.stateNode;try{e:switch(o){case"button":case"input":case"select":case"textarea":u.autoFocus&&x.focus();break e;case"img":u.src?x.src=u.src:u.srcSet&&(x.srcset=u.srcSet)}}catch(w){cr(n,n.return,w)}}function Zg(n,o,u){try{var x=n.stateNode;Qj(x,n.type,u,o),x[xe]=o}catch(w){cr(n,n.return,w)}}function sb(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&vl(n.type)||n.tag===4}function Jg(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||sb(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&vl(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function Xg(n,o,u){var x=n.tag;if(x===5||x===6)n=n.stateNode,o?(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u).insertBefore(n,o):(o=u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,o.appendChild(n),u=u._reactRootContainer,u!=null||o.onclick!==null||(o.onclick=Sa));else if(x!==4&&(x===27&&vl(n.type)&&(u=n.stateNode,o=null),n=n.child,n!==null))for(Xg(n,o,u),n=n.sibling;n!==null;)Xg(n,o,u),n=n.sibling}function om(n,o,u){var x=n.tag;if(x===5||x===6)n=n.stateNode,o?u.insertBefore(n,o):u.appendChild(n);else if(x!==4&&(x===27&&vl(n.type)&&(u=n.stateNode),n=n.child,n!==null))for(om(n,o,u),n=n.sibling;n!==null;)om(n,o,u),n=n.sibling}function nb(n){var o=n.stateNode,u=n.memoizedProps;try{for(var x=n.type,w=o.attributes;w.length;)o.removeAttributeNode(w[0]);Hs(o,x,u),o[ie]=n,o[xe]=u}catch(S){cr(n,n.return,S)}}var Fo=!1,is=!1,Kg=!1,ib=typeof WeakSet=="function"?WeakSet:Set,ks=null;function Dj(n,o){if(n=n.containerInfo,vf=Tm,n=ji(n),ui(n)){if("selectionStart"in n)var u={start:n.selectionStart,end:n.selectionEnd};else e:{u=(u=n.ownerDocument)&&u.defaultView||window;var x=u.getSelection&&u.getSelection();if(x&&x.rangeCount!==0){u=x.anchorNode;var w=x.anchorOffset,S=x.focusNode;x=x.focusOffset;try{u.nodeType,S.nodeType}catch(ba){u=null;break e}var q=0,ge=-1,Ae=-1,Ke=0,vt=0,Et=n,at=null;t:for(;;){for(var ut;Et!==u||w!==0&&Et.nodeType!==3||(ge=q+w),Et!==S||x!==0&&Et.nodeType!==3||(Ae=q+x),Et.nodeType===3&&(q+=Et.nodeValue.length),(ut=Et.firstChild)!==null;)at=Et,Et=ut;for(;;){if(Et===n)break t;if(at===u&&++Ke===w&&(ge=q),at===S&&++vt===x&&(Ae=q),(ut=Et.nextSibling)!==null)break;Et=at,at=Et.parentNode}Et=ut}u=ge===-1||Ae===-1?null:{start:ge,end:Ae}}else u=null}u=u||{start:0,end:0}}else u=null;for(_f={focusedElem:n,selectionRange:u},Tm=!1,ks=o;ks!==null;)if(o=ks,n=o.child,(o.subtreeFlags&1028)!==0&&n!==null)n.return=o,ks=n;else for(;ks!==null;){switch(o=ks,S=o.alternate,n=o.flags,o.tag){case 0:if((n&4)!==0&&(n=o.updateQueue,n=n!==null?n.events:null,n!==null))for(u=0;u<n.length;u++)w=n[u],w.ref.impl=w.nextImpl;break;case 11:case 15:break;case 1:if((n&1024)!==0&&S!==null){n=void 0,u=o,w=S.memoizedProps,S=S.memoizedState,x=u.stateNode;try{var la=ac(u.type,w);n=x.getSnapshotBeforeUpdate(la,S),x.__reactInternalSnapshotBeforeUpdate=n}catch(ba){cr(u,u.return,ba)}}break;case 3:if((n&1024)!==0){if(n=o.stateNode.containerInfo,u=n.nodeType,u===9)jf(n);else if(u===1)switch(n.nodeName){case"HEAD":case"HTML":case"BODY":jf(n);break;default:n.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((n&1024)!==0)throw Error(s(163))}if(n=o.sibling,n!==null){n.return=o.return,ks=n;break}ks=o.return}}function ob(n,o,u){var x=u.flags;switch(u.tag){case 0:case 11:case 15:zo(n,u),x&4&&j0(5,u);break;case 1:if(zo(n,u),x&4)if(n=u.stateNode,o===null)try{n.componentDidMount()}catch(q){cr(u,u.return,q)}else{var w=ac(u.type,o.memoizedProps);o=o.memoizedState;try{n.componentDidUpdate(w,o,n.__reactInternalSnapshotBeforeUpdate)}catch(q){cr(u,u.return,q)}}x&64&&tb(u),x&512&&N0(u,u.return);break;case 3:if(zo(n,u),x&64&&(n=u.updateQueue,n!==null)){if(o=null,u.child!==null)switch(u.child.tag){case 27:case 5:o=u.child.stateNode;break;case 1:o=u.child.stateNode}try{Vp(n,o)}catch(q){cr(u,u.return,q)}}break;case 27:o===null&&x&4&&nb(u);case 26:case 5:zo(n,u),o===null&&x&4&&rb(u),x&512&&N0(u,u.return);break;case 12:zo(n,u);break;case 31:zo(n,u),x&4&&db(n,u);break;case 13:zo(n,u),x&4&&ub(n,u),x&64&&(n=u.memoizedState,n!==null&&(n=n.dehydrated,n!==null&&(u=Uj.bind(null,u),oN(n,u))));break;case 22:if(x=u.memoizedState!==null||Fo,!x){o=o!==null&&o.memoizedState!==null||is,w=Fo;var S=is;Fo=x,(is=o)&&!S?Bo(n,u,(u.subtreeFlags&8772)!==0):zo(n,u),Fo=w,is=S}break;case 30:break;default:zo(n,u)}}function lb(n){var o=n.alternate;o!==null&&(n.alternate=null,lb(o)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(o=n.stateNode,o!==null&&_t(o)),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}var Mr=null,Cn=!1;function Io(n,o,u){for(u=u.child;u!==null;)cb(n,o,u),u=u.sibling}function cb(n,o,u){if(Nt&&typeof Nt.onCommitFiberUnmount=="function")try{Nt.onCommitFiberUnmount(Ie,u)}catch(S){}switch(u.tag){case 26:is||io(u,o),Io(n,o,u),u.memoizedState?u.memoizedState.count--:u.stateNode&&(u=u.stateNode,u.parentNode.removeChild(u));break;case 27:is||io(u,o);var x=Mr,w=Cn;vl(u.type)&&(Mr=u.stateNode,Cn=!1),Io(n,o,u),L0(u.stateNode),Mr=x,Cn=w;break;case 5:is||io(u,o);case 6:if(x=Mr,w=Cn,Mr=null,Io(n,o,u),Mr=x,Cn=w,Mr!==null)if(Cn)try{(Mr.nodeType===9?Mr.body:Mr.nodeName==="HTML"?Mr.ownerDocument.body:Mr).removeChild(u.stateNode)}catch(S){cr(u,o,S)}else try{Mr.removeChild(u.stateNode)}catch(S){cr(u,o,S)}break;case 18:Mr!==null&&(Cn?(n=Mr,tv(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,u.stateNode),pd(n)):tv(Mr,u.stateNode));break;case 4:x=Mr,w=Cn,Mr=u.stateNode.containerInfo,Cn=!0,Io(n,o,u),Mr=x,Cn=w;break;case 0:case 11:case 14:case 15:hl(2,u,o),is||hl(4,u,o),Io(n,o,u);break;case 1:is||(io(u,o),x=u.stateNode,typeof x.componentWillUnmount=="function"&&ab(u,o,x)),Io(n,o,u);break;case 21:Io(n,o,u);break;case 22:is=(x=is)||u.memoizedState!==null,Io(n,o,u),is=x;break;default:Io(n,o,u)}}function db(n,o){if(o.memoizedState===null&&(n=o.alternate,n!==null&&(n=n.memoizedState,n!==null))){n=n.dehydrated;try{pd(n)}catch(u){cr(o,o.return,u)}}}function ub(n,o){if(o.memoizedState===null&&(n=o.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null))))try{pd(n)}catch(u){cr(o,o.return,u)}}function Mj(n){switch(n.tag){case 31:case 13:case 19:var o=n.stateNode;return o===null&&(o=n.stateNode=new ib),o;case 22:return n=n.stateNode,o=n._retryCache,o===null&&(o=n._retryCache=new ib),o;default:throw Error(s(435,n.tag))}}function lm(n,o){var u=Mj(n);o.forEach(function(x){if(!u.has(x)){u.add(x);var w=$j.bind(null,n,x);x.then(w,w)}})}function Tn(n,o){var u=o.deletions;if(u!==null)for(var x=0;x<u.length;x++){var w=u[x],S=n,q=o,ge=q;e:for(;ge!==null;){switch(ge.tag){case 27:if(vl(ge.type)){Mr=ge.stateNode,Cn=!1;break e}break;case 5:Mr=ge.stateNode,Cn=!1;break e;case 3:case 4:Mr=ge.stateNode.containerInfo,Cn=!0;break e}ge=ge.return}if(Mr===null)throw Error(s(160));cb(S,q,w),Mr=null,Cn=!1,S=w.alternate,S!==null&&(S.return=null),w.return=null}if(o.subtreeFlags&13886)for(o=o.child;o!==null;)mb(o,n),o=o.sibling}var Ci=null;function mb(n,o){var u=n.alternate,x=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:Tn(o,n),En(n),x&4&&(hl(3,n,n.return),j0(3,n),hl(5,n,n.return));break;case 1:Tn(o,n),En(n),x&512&&(is||u===null||io(u,u.return)),x&64&&Fo&&(n=n.updateQueue,n!==null&&(x=n.callbacks,x!==null&&(u=n.shared.hiddenCallbacks,n.shared.hiddenCallbacks=u===null?x:u.concat(x))));break;case 26:var w=Ci;if(Tn(o,n),En(n),x&512&&(is||u===null||io(u,u.return)),x&4){var S=u!==null?u.memoizedState:null;if(x=n.memoizedState,u===null)if(x===null)if(n.stateNode===null){e:{x=n.type,u=n.memoizedProps,w=w.ownerDocument||w;t:switch(x){case"title":S=w.getElementsByTagName("title")[0],(!S||S[We]||S[ie]||S.namespaceURI==="http://www.w3.org/2000/svg"||S.hasAttribute("itemprop"))&&(S=w.createElement(x),w.head.insertBefore(S,w.querySelector("head > title"))),Hs(S,x,u),S[ie]=n,Zt(S),x=S;break e;case"link":var q=mv("link","href",w).get(x+(u.href||""));if(q){for(var ge=0;ge<q.length;ge++)if(S=q[ge],S.getAttribute("href")===(u.href==null||u.href===""?null:u.href)&&S.getAttribute("rel")===(u.rel==null?null:u.rel)&&S.getAttribute("title")===(u.title==null?null:u.title)&&S.getAttribute("crossorigin")===(u.crossOrigin==null?null:u.crossOrigin)){q.splice(ge,1);break t}}S=w.createElement(x),Hs(S,x,u),w.head.appendChild(S);break;case"meta":if(q=mv("meta","content",w).get(x+(u.content||""))){for(ge=0;ge<q.length;ge++)if(S=q[ge],S.getAttribute("content")===(u.content==null?null:""+u.content)&&S.getAttribute("name")===(u.name==null?null:u.name)&&S.getAttribute("property")===(u.property==null?null:u.property)&&S.getAttribute("http-equiv")===(u.httpEquiv==null?null:u.httpEquiv)&&S.getAttribute("charset")===(u.charSet==null?null:u.charSet)){q.splice(ge,1);break t}}S=w.createElement(x),Hs(S,x,u),w.head.appendChild(S);break;default:throw Error(s(468,x))}S[ie]=n,Zt(S),x=S}n.stateNode=x}else hv(w,n.type,n.stateNode);else n.stateNode=uv(w,x,n.memoizedProps);else S!==x?(S===null?u.stateNode!==null&&(u=u.stateNode,u.parentNode.removeChild(u)):S.count--,x===null?hv(w,n.type,n.stateNode):uv(w,x,n.memoizedProps)):x===null&&n.stateNode!==null&&Zg(n,n.memoizedProps,u.memoizedProps)}break;case 27:Tn(o,n),En(n),x&512&&(is||u===null||io(u,u.return)),u!==null&&x&4&&Zg(n,n.memoizedProps,u.memoizedProps);break;case 5:if(Tn(o,n),En(n),x&512&&(is||u===null||io(u,u.return)),n.flags&32){w=n.stateNode;try{Gr(w,"")}catch(la){cr(n,n.return,la)}}x&4&&n.stateNode!=null&&(w=n.memoizedProps,Zg(n,w,u!==null?u.memoizedProps:w)),x&1024&&(Kg=!0);break;case 6:if(Tn(o,n),En(n),x&4){if(n.stateNode===null)throw Error(s(162));x=n.memoizedProps,u=n.stateNode;try{u.nodeValue=x}catch(la){cr(n,n.return,la)}}break;case 3:if(jm=null,w=Ci,Ci=wm(o.containerInfo),Tn(o,n),Ci=w,En(n),x&4&&u!==null&&u.memoizedState.isDehydrated)try{pd(o.containerInfo)}catch(la){cr(n,n.return,la)}Kg&&(Kg=!1,hb(n));break;case 4:x=Ci,Ci=wm(n.stateNode.containerInfo),Tn(o,n),En(n),Ci=x;break;case 12:Tn(o,n),En(n);break;case 31:Tn(o,n),En(n),x&4&&(x=n.updateQueue,x!==null&&(n.updateQueue=null,lm(n,x)));break;case 13:Tn(o,n),En(n),n.child.flags&8192&&n.memoizedState!==null!=(u!==null&&u.memoizedState!==null)&&(dm=sa()),x&4&&(x=n.updateQueue,x!==null&&(n.updateQueue=null,lm(n,x)));break;case 22:w=n.memoizedState!==null;var Ae=u!==null&&u.memoizedState!==null,Ke=Fo,vt=is;if(Fo=Ke||w,is=vt||Ae,Tn(o,n),is=vt,Fo=Ke,En(n),x&8192)e:for(o=n.stateNode,o._visibility=w?o._visibility&-2:o._visibility|1,w&&(u===null||Ae||Fo||is||rc(n)),u=null,o=n;;){if(o.tag===5||o.tag===26){if(u===null){Ae=u=o;try{if(S=Ae.stateNode,w)q=S.style,typeof q.setProperty=="function"?q.setProperty("display","none","important"):q.display="none";else{ge=Ae.stateNode;var Et=Ae.memoizedProps.style,at=Et!=null&&Et.hasOwnProperty("display")?Et.display:null;ge.style.display=at==null||typeof at=="boolean"?"":(""+at).trim()}}catch(la){cr(Ae,Ae.return,la)}}}else if(o.tag===6){if(u===null){Ae=o;try{Ae.stateNode.nodeValue=w?"":Ae.memoizedProps}catch(la){cr(Ae,Ae.return,la)}}}else if(o.tag===18){if(u===null){Ae=o;try{var ut=Ae.stateNode;w?av(ut,!0):av(Ae.stateNode,!1)}catch(la){cr(Ae,Ae.return,la)}}}else if((o.tag!==22&&o.tag!==23||o.memoizedState===null||o===n)&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===n)break e;for(;o.sibling===null;){if(o.return===null||o.return===n)break e;u===o&&(u=null),o=o.return}u===o&&(u=null),o.sibling.return=o.return,o=o.sibling}x&4&&(x=n.updateQueue,x!==null&&(u=x.retryQueue,u!==null&&(x.retryQueue=null,lm(n,u))));break;case 19:Tn(o,n),En(n),x&4&&(x=n.updateQueue,x!==null&&(n.updateQueue=null,lm(n,x)));break;case 30:break;case 21:break;default:Tn(o,n),En(n)}}function En(n){var o=n.flags;if(o&2){try{for(var u,x=n.return;x!==null;){if(sb(x)){u=x;break}x=x.return}if(u==null)throw Error(s(160));switch(u.tag){case 27:var w=u.stateNode,S=Jg(n);om(n,S,w);break;case 5:var q=u.stateNode;u.flags&32&&(Gr(q,""),u.flags&=-33);var ge=Jg(n);om(n,ge,q);break;case 3:case 4:var Ae=u.stateNode.containerInfo,Ke=Jg(n);Xg(n,Ke,Ae);break;default:throw Error(s(161))}}catch(vt){cr(n,n.return,vt)}n.flags&=-3}o&4096&&(n.flags&=-4097)}function hb(n){if(n.subtreeFlags&1024)for(n=n.child;n!==null;){var o=n;hb(o),o.tag===5&&o.flags&1024&&o.stateNode.reset(),n=n.sibling}}function zo(n,o){if(o.subtreeFlags&8772)for(o=o.child;o!==null;)ob(n,o.alternate,o),o=o.sibling}function rc(n){for(n=n.child;n!==null;){var o=n;switch(o.tag){case 0:case 11:case 14:case 15:hl(4,o,o.return),rc(o);break;case 1:io(o,o.return);var u=o.stateNode;typeof u.componentWillUnmount=="function"&&ab(o,o.return,u),rc(o);break;case 27:L0(o.stateNode);case 26:case 5:io(o,o.return),rc(o);break;case 22:o.memoizedState===null&&rc(o);break;case 30:rc(o);break;default:rc(o)}n=n.sibling}}function Bo(n,o,u){for(u=u&&(o.subtreeFlags&8772)!==0,o=o.child;o!==null;){var x=o.alternate,w=n,S=o,q=S.flags;switch(S.tag){case 0:case 11:case 15:Bo(w,S,u),j0(4,S);break;case 1:if(Bo(w,S,u),x=S,w=x.stateNode,typeof w.componentDidMount=="function")try{w.componentDidMount()}catch(Ke){cr(x,x.return,Ke)}if(x=S,w=x.updateQueue,w!==null){var ge=x.stateNode;try{var Ae=w.shared.hiddenCallbacks;if(Ae!==null)for(w.shared.hiddenCallbacks=null,w=0;w<Ae.length;w++)Wp(Ae[w],ge)}catch(Ke){cr(x,x.return,Ke)}}u&&q&64&&tb(S),N0(S,S.return);break;case 27:nb(S);case 26:case 5:Bo(w,S,u),u&&x===null&&q&4&&rb(S),N0(S,S.return);break;case 12:Bo(w,S,u);break;case 31:Bo(w,S,u),u&&q&4&&db(w,S);break;case 13:Bo(w,S,u),u&&q&4&&ub(w,S);break;case 22:S.memoizedState===null&&Bo(w,S,u),N0(S,S.return);break;case 30:break;default:Bo(w,S,u)}o=o.sibling}}function Qg(n,o){var u=null;n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(u=n.memoizedState.cachePool.pool),n=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(n=o.memoizedState.cachePool.pool),n!==u&&(n!=null&&n.refCount++,u!=null&&u0(u))}function ef(n,o){n=null,o.alternate!==null&&(n=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==n&&(o.refCount++,n!=null&&u0(n))}function Ti(n,o,u,x){if(o.subtreeFlags&10256)for(o=o.child;o!==null;)gb(n,o,u,x),o=o.sibling}function gb(n,o,u,x){var w=o.flags;switch(o.tag){case 0:case 11:case 15:Ti(n,o,u,x),w&2048&&j0(9,o);break;case 1:Ti(n,o,u,x);break;case 3:Ti(n,o,u,x),w&2048&&(n=null,o.alternate!==null&&(n=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==n&&(o.refCount++,n!=null&&u0(n)));break;case 12:if(w&2048){Ti(n,o,u,x),n=o.stateNode;try{var S=o.memoizedProps,q=S.id,ge=S.onPostCommit;typeof ge=="function"&&ge(q,o.alternate===null?"mount":"update",n.passiveEffectDuration,-0)}catch(Ae){cr(o,o.return,Ae)}}else Ti(n,o,u,x);break;case 31:Ti(n,o,u,x);break;case 13:Ti(n,o,u,x);break;case 23:break;case 22:S=o.stateNode,q=o.alternate,o.memoizedState!==null?S._visibility&2?Ti(n,o,u,x):S0(n,o):S._visibility&2?Ti(n,o,u,x):(S._visibility|=2,id(n,o,u,x,(o.subtreeFlags&10256)!==0||!1)),w&2048&&Qg(q,o);break;case 24:Ti(n,o,u,x),w&2048&&ef(o.alternate,o);break;default:Ti(n,o,u,x)}}function id(n,o,u,x,w){for(w=w&&((o.subtreeFlags&10256)!==0||!1),o=o.child;o!==null;){var S=n,q=o,ge=u,Ae=x,Ke=q.flags;switch(q.tag){case 0:case 11:case 15:id(S,q,ge,Ae,w),j0(8,q);break;case 23:break;case 22:var vt=q.stateNode;q.memoizedState!==null?vt._visibility&2?id(S,q,ge,Ae,w):S0(S,q):(vt._visibility|=2,id(S,q,ge,Ae,w)),w&&Ke&2048&&Qg(q.alternate,q);break;case 24:id(S,q,ge,Ae,w),w&&Ke&2048&&ef(q.alternate,q);break;default:id(S,q,ge,Ae,w)}o=o.sibling}}function S0(n,o){if(o.subtreeFlags&10256)for(o=o.child;o!==null;){var u=n,x=o,w=x.flags;switch(x.tag){case 22:S0(u,x),w&2048&&Qg(x.alternate,x);break;case 24:S0(u,x),w&2048&&ef(x.alternate,x);break;default:S0(u,x)}o=o.sibling}}var C0=8192;function od(n,o,u){if(n.subtreeFlags&C0)for(n=n.child;n!==null;)fb(n,o,u),n=n.sibling}function fb(n,o,u){switch(n.tag){case 26:od(n,o,u),n.flags&C0&&n.memoizedState!==null&&bN(u,Ci,n.memoizedState,n.memoizedProps);break;case 5:od(n,o,u);break;case 3:case 4:var x=Ci;Ci=wm(n.stateNode.containerInfo),od(n,o,u),Ci=x;break;case 22:n.memoizedState===null&&(x=n.alternate,x!==null&&x.memoizedState!==null?(x=C0,C0=16777216,od(n,o,u),C0=x):od(n,o,u));break;default:od(n,o,u)}}function xb(n){var o=n.alternate;if(o!==null&&(n=o.child,n!==null)){o.child=null;do o=n.sibling,n.sibling=null,n=o;while(n!==null)}}function T0(n){var o=n.deletions;if((n.flags&16)!==0){if(o!==null)for(var u=0;u<o.length;u++){var x=o[u];ks=x,yb(x,n)}xb(n)}if(n.subtreeFlags&10256)for(n=n.child;n!==null;)pb(n),n=n.sibling}function pb(n){switch(n.tag){case 0:case 11:case 15:T0(n),n.flags&2048&&hl(9,n,n.return);break;case 3:T0(n);break;case 12:T0(n);break;case 22:var o=n.stateNode;n.memoizedState!==null&&o._visibility&2&&(n.return===null||n.return.tag!==13)?(o._visibility&=-3,cm(n)):T0(n);break;default:T0(n)}}function cm(n){var o=n.deletions;if((n.flags&16)!==0){if(o!==null)for(var u=0;u<o.length;u++){var x=o[u];ks=x,yb(x,n)}xb(n)}for(n=n.child;n!==null;){switch(o=n,o.tag){case 0:case 11:case 15:hl(8,o,o.return),cm(o);break;case 22:u=o.stateNode,u._visibility&2&&(u._visibility&=-3,cm(o));break;default:cm(o)}n=n.sibling}}function yb(n,o){for(;ks!==null;){var u=ks;switch(u.tag){case 0:case 11:case 15:hl(8,u,o);break;case 23:case 22:if(u.memoizedState!==null&&u.memoizedState.cachePool!==null){var x=u.memoizedState.cachePool.pool;x!=null&&x.refCount++}break;case 24:u0(u.memoizedState.cache)}if(x=u.child,x!==null)x.return=u,ks=x;else e:for(u=n;ks!==null;){x=ks;var w=x.sibling,S=x.return;if(lb(x),x===u){ks=null;break e}if(w!==null){w.return=S,ks=w;break e}ks=S}}}var Lj={getCacheForType:function(n){var o=Us(rs),u=o.data.get(n);return u===void 0&&(u=n(),o.data.set(n,u)),u},cacheSignal:function(){return Us(rs).controller.signal}},Rj=typeof WeakMap=="function"?WeakMap:Map,rr=0,wr=null,$a=null,Wa=0,lr=0,Zn=null,gl=!1,ld=!1,tf=!1,Uo=0,Hr=0,fl=0,sc=0,af=0,Jn=0,cd=0,E0=null,An=null,rf=!1,dm=0,bb=0,um=1/0,mm=null,xl=null,ys=0,pl=null,dd=null,$o=0,sf=0,nf=null,vb=null,A0=0,of=null;function Xn(){return(rr&2)!==0&&Wa!==0?Wa&-Wa:te.T!==null?hf():V()}function _b(){if(Jn===0)if((Wa&536870912)===0||Ua){var n=it;it<<=1,(it&3932160)===0&&(it=262144),Jn=n}else Jn=536870912;return n=Gn.current,n!==null&&(n.flags|=32),Jn}function On(n,o,u){(n===wr&&(lr===2||lr===9)||n.cancelPendingCommit!==null)&&(ud(n,0),yl(n,Wa,Jn,!1)),re(n,u),((rr&2)===0||n!==wr)&&(n===wr&&((rr&2)===0&&(sc|=u),Hr===4&&yl(n,Wa,Jn,!1)),oo(n))}function wb(n,o,u){if((rr&6)!==0)throw Error(s(327));var x=!u&&(o&127)===0&&(o&n.expiredLanes)===0||Rt(n,o),w=x?Ij(n,o):cf(n,o,!0),S=x;do{if(w===0){ld&&!x&&yl(n,o,0,!1);break}else{if(u=n.current.alternate,S&&!Pj(u)){w=cf(n,o,!1),S=!1;continue}if(w===2){if(S=o,n.errorRecoveryDisabledLanes&S)var q=0;else q=n.pendingLanes&-536870913,q=q!==0?q:q&536870912?536870912:0;if(q!==0){o=q;e:{var ge=n;w=E0;var Ae=ge.current.memoizedState.isDehydrated;if(Ae&&(ud(ge,q).flags|=256),q=cf(ge,q,!1),q!==2){if(tf&&!Ae){ge.errorRecoveryDisabledLanes|=S,sc|=S,w=4;break e}S=An,An=w,S!==null&&(An===null?An=S:An.push.apply(An,S))}w=q}if(S=!1,w!==2)continue}}if(w===1){ud(n,0),yl(n,o,0,!0);break}e:{switch(x=n,S=w,S){case 0:case 1:throw Error(s(345));case 4:if((o&4194048)!==o)break;case 6:yl(x,o,Jn,!gl);break e;case 2:An=null;break;case 3:case 5:break;default:throw Error(s(329))}if((o&62914560)===o&&(w=dm+300-sa(),10<w)){if(yl(x,o,Jn,!gl),Ot(x,0,!0)!==0)break e;$o=o,x.timeoutHandle=Qb(kb.bind(null,x,u,An,mm,rf,o,Jn,sc,cd,gl,S,"Throttled",-0,0),w);break e}kb(x,u,An,mm,rf,o,Jn,sc,cd,gl,S,null,-0,0)}}break}while(!0);oo(n)}function kb(n,o,u,x,w,S,q,ge,Ae,Ke,vt,Et,at,ut){if(n.timeoutHandle=-1,Et=o.subtreeFlags,Et&8192||(Et&16785408)===16785408){Et={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Sa},fb(o,S,Et);var la=(S&62914560)===S?dm-sa():(S&4194048)===S?bb-sa():0;if(la=vN(Et,la),la!==null){$o=S,n.cancelPendingCommit=la(Ob.bind(null,n,o,S,u,x,w,q,ge,Ae,vt,Et,null,at,ut)),yl(n,S,q,!Ke);return}}Ob(n,o,S,u,x,w,q,ge,Ae)}function Pj(n){for(var o=n;;){var u=o.tag;if((u===0||u===11||u===15)&&o.flags&16384&&(u=o.updateQueue,u!==null&&(u=u.stores,u!==null)))for(var x=0;x<u.length;x++){var w=u[x],S=w.getSnapshot;w=w.value;try{if(!ts(S(),w))return!1}catch(q){return!1}}if(u=o.child,o.subtreeFlags&16384&&u!==null)u.return=o,o=u;else{if(o===n)break;for(;o.sibling===null;){if(o.return===null||o.return===n)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function yl(n,o,u,x){o&=~af,o&=~sc,n.suspendedLanes|=o,n.pingedLanes&=~o,x&&(n.warmLanes|=o),x=n.expirationTimes;for(var w=o;0<w;){var S=31-Oe(w),q=1<<S;x[S]=-1,w&=~q}u!==0&&Ge(n,u,o)}function hm(){return(rr&6)===0?(O0(0),!1):!0}function lf(){if($a!==null){if(lr===0)var n=$a.return;else n=$a,Si=no=null,kg(n),td=null,h0=0,n=$a;for(;n!==null;)eb(n.alternate,n),n=n.return;$a=null}}function ud(n,o){var u=n.timeoutHandle;u!==-1&&(n.timeoutHandle=-1,aN(u)),u=n.cancelPendingCommit,u!==null&&(n.cancelPendingCommit=null,u()),$o=0,lf(),wr=n,$a=u=hi(n.current,null),Wa=o,lr=0,Zn=null,gl=!1,ld=Rt(n,o),tf=!1,cd=Jn=af=sc=fl=Hr=0,An=E0=null,rf=!1,(o&8)!==0&&(o|=o&32);var x=n.entangledLanes;if(x!==0)for(n=n.entanglements,x&=o;0<x;){var w=31-Oe(x),S=1<<w;o|=n[w],x&=~S}return Uo=o,Vl(),u}function jb(n,o){Ta=null,te.H=_0,o===ed||o===$u?(o=Bp(),lr=3):o===ug?(o=Bp(),lr=4):lr=o===zg?8:o!==null&&typeof o=="object"&&typeof o.then=="function"?6:1,Zn=o,$a===null&&(Hr=1,am(n,f(o,n.current)))}function Nb(){var n=Gn.current;return n===null?!0:(Wa&4194048)===Wa?gi===null:(Wa&62914560)===Wa||(Wa&536870912)!==0?n===gi:!1}function Sb(){var n=te.H;return te.H=_0,n===null?_0:n}function Cb(){var n=te.A;return te.A=Lj,n}function gm(){Hr=4,gl||(Wa&4194048)!==Wa&&Gn.current!==null||(ld=!0),(fl&134217727)===0&&(sc&134217727)===0||wr===null||yl(wr,Wa,Jn,!1)}function cf(n,o,u){var x=rr;rr|=2;var w=Sb(),S=Cb();(wr!==n||Wa!==o)&&(mm=null,ud(n,o)),o=!1;var q=Hr;e:do try{if(lr!==0&&$a!==null){var ge=$a,Ae=Zn;switch(lr){case 8:lf(),q=6;break e;case 3:case 2:case 9:case 6:Gn.current===null&&(o=!0);var Ke=lr;if(lr=0,Zn=null,md(n,ge,Ae,Ke),u&&ld){q=0;break e}break;default:Ke=lr,lr=0,Zn=null,md(n,ge,Ae,Ke)}}Fj(),q=Hr;break}catch(vt){jb(n,vt)}while(!0);return o&&n.shellSuspendCounter++,Si=no=null,rr=x,te.H=w,te.A=S,$a===null&&(wr=null,Wa=0,Vl()),q}function Fj(){for(;$a!==null;)Tb($a)}function Ij(n,o){var u=rr;rr|=2;var x=Sb(),w=Cb();wr!==n||Wa!==o?(mm=null,um=sa()+500,ud(n,o)):ld=Rt(n,o);e:do try{if(lr!==0&&$a!==null){o=$a;var S=Zn;t:switch(lr){case 1:lr=0,Zn=null,md(n,o,S,1);break;case 2:case 9:if(Ip(S)){lr=0,Zn=null,Eb(o);break}o=function(){lr!==2&&lr!==9||wr!==n||(lr=7),oo(n)},S.then(o,o);break e;case 3:lr=7;break e;case 4:lr=5;break e;case 7:Ip(S)?(lr=0,Zn=null,Eb(o)):(lr=0,Zn=null,md(n,o,S,7));break;case 5:var q=null;switch($a.tag){case 26:q=$a.memoizedState;case 5:case 27:var ge=$a;if(q?gv(q):ge.stateNode.complete){lr=0,Zn=null;var Ae=ge.sibling;if(Ae!==null)$a=Ae;else{var Ke=ge.return;Ke!==null?($a=Ke,fm(Ke)):$a=null}break t}}lr=0,Zn=null,md(n,o,S,5);break;case 6:lr=0,Zn=null,md(n,o,S,6);break;case 8:lf(),Hr=6;break e;default:throw Error(s(462))}}zj();break}catch(vt){jb(n,vt)}while(!0);return Si=no=null,te.H=x,te.A=w,rr=u,$a!==null?0:(wr=null,Wa=0,Vl(),Hr)}function zj(){for(;$a!==null&&!va();)Tb($a)}function Tb(n){var o=Ky(n.alternate,n,Uo);n.memoizedProps=n.pendingProps,o===null?fm(n):$a=o}function Eb(n){var o=n,u=o.alternate;switch(o.tag){case 15:case 0:o=qy(u,o,o.pendingProps,o.type,void 0,Wa);break;case 11:o=qy(u,o,o.pendingProps,o.type.render,o.ref,Wa);break;case 5:kg(o);default:eb(u,o),o=$a=i0(o,Uo),o=Ky(u,o,Uo)}n.memoizedProps=n.pendingProps,o===null?fm(n):$a=o}function md(n,o,u,x){Si=no=null,kg(o),td=null,h0=0;var w=o.return;try{if(Cj(n,w,o,u,Wa)){Hr=1,am(n,f(u,n.current)),$a=null;return}}catch(S){if(w!==null)throw $a=w,S;Hr=1,am(n,f(u,n.current)),$a=null;return}o.flags&32768?(Ua||x===1?n=!0:ld||(Wa&536870912)!==0?n=!1:(gl=n=!0,(x===2||x===9||x===3||x===6)&&(x=Gn.current,x!==null&&x.tag===13&&(x.flags|=16384))),Ab(o,n)):fm(o)}function fm(n){var o=n;do{if((o.flags&32768)!==0){Ab(o,gl);return}n=o.return;var u=Aj(o.alternate,o,Uo);if(u!==null){$a=u;return}if(o=o.sibling,o!==null){$a=o;return}$a=o=n}while(o!==null);Hr===0&&(Hr=5)}function Ab(n,o){do{var u=Oj(n.alternate,n);if(u!==null){u.flags&=32767,$a=u;return}if(u=n.return,u!==null&&(u.flags|=32768,u.subtreeFlags=0,u.deletions=null),!o&&(n=n.sibling,n!==null)){$a=n;return}$a=n=u}while(n!==null);Hr=6,$a=null}function Ob(n,o,u,x,w,S,q,ge,Ae){n.cancelPendingCommit=null;do xm();while(ys!==0);if((rr&6)!==0)throw Error(s(327));if(o!==null){if(o===n.current)throw Error(s(177));if(S=o.lanes|o.childLanes,S|=Gc,Ee(n,u,S,q,ge,Ae),n===wr&&($a=wr=null,Wa=0),dd=o,pl=n,$o=u,sf=S,nf=w,vb=x,(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?(n.callbackNode=null,n.callbackPriority=0,Hj($t,function(){return Pb(),null})):(n.callbackNode=null,n.callbackPriority=0),x=(o.flags&13878)!==0,(o.subtreeFlags&13878)!==0||x){x=te.T,te.T=null,w=W.p,W.p=2,q=rr,rr|=4;try{Dj(n,o,u)}finally{rr=q,W.p=w,te.T=x}}ys=1,Db(),Mb(),Lb()}}function Db(){if(ys===1){ys=0;var n=pl,o=dd,u=(o.flags&13878)!==0;if((o.subtreeFlags&13878)!==0||u){u=te.T,te.T=null;var x=W.p;W.p=2;var w=rr;rr|=4;try{mb(o,n);var S=_f,q=ji(n.containerInfo),ge=S.focusedElem,Ae=S.selectionRange;if(q!==ge&&ge&&ge.ownerDocument&&to(ge.ownerDocument.documentElement,ge)){if(Ae!==null&&ui(ge)){var Ke=Ae.start,vt=Ae.end;if(vt===void 0&&(vt=Ke),"selectionStart"in ge)ge.selectionStart=Ke,ge.selectionEnd=Math.min(vt,ge.value.length);else{var Et=ge.ownerDocument||document,at=Et&&Et.defaultView||window;if(at.getSelection){var ut=at.getSelection(),la=ge.textContent.length,ba=Math.min(Ae.start,la),br=Ae.end===void 0?ba:Math.min(Ae.end,la);!ut.extend&&ba>br&&(q=br,br=ba,ba=q);var Ve=eo(ge,ba),Fe=eo(ge,br);if(Ve&&Fe&&(ut.rangeCount!==1||ut.anchorNode!==Ve.node||ut.anchorOffset!==Ve.offset||ut.focusNode!==Fe.node||ut.focusOffset!==Fe.offset)){var Je=Et.createRange();Je.setStart(Ve.node,Ve.offset),ut.removeAllRanges(),ba>br?(ut.addRange(Je),ut.extend(Fe.node,Fe.offset)):(Je.setEnd(Fe.node,Fe.offset),ut.addRange(Je))}}}}for(Et=[],ut=ge;ut=ut.parentNode;)ut.nodeType===1&&Et.push({element:ut,left:ut.scrollLeft,top:ut.scrollTop});for(typeof ge.focus=="function"&&ge.focus(),ge=0;ge<Et.length;ge++){var jt=Et[ge];jt.element.scrollLeft=jt.left,jt.element.scrollTop=jt.top}}Tm=!!vf,_f=vf=null}finally{rr=w,W.p=x,te.T=u}}n.current=o,ys=2}}function Mb(){if(ys===2){ys=0;var n=pl,o=dd,u=(o.flags&8772)!==0;if((o.subtreeFlags&8772)!==0||u){u=te.T,te.T=null;var x=W.p;W.p=2;var w=rr;rr|=4;try{ob(n,o.alternate,o)}finally{rr=w,W.p=x,te.T=u}}ys=3}}function Lb(){if(ys===4||ys===3){ys=0,ta();var n=pl,o=dd,u=$o,x=vb;(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?ys=5:(ys=0,dd=pl=null,Rb(n,n.pendingLanes));var w=n.pendingLanes;if(w===0&&(xl=null),rt(u),o=o.stateNode,Nt&&typeof Nt.onCommitFiberRoot=="function")try{Nt.onCommitFiberRoot(Ie,o,void 0,(o.current.flags&128)===128)}catch(Ae){}if(x!==null){o=te.T,w=W.p,W.p=2,te.T=null;try{for(var S=n.onRecoverableError,q=0;q<x.length;q++){var ge=x[q];S(ge.value,{componentStack:ge.stack})}}finally{te.T=o,W.p=w}}($o&3)!==0&&xm(),oo(n),w=n.pendingLanes,(u&261930)!==0&&(w&42)!==0?n===of?A0++:(A0=0,of=n):A0=0,O0(0)}}function Rb(n,o){(n.pooledCacheLanes&=o)===0&&(o=n.pooledCache,o!=null&&(n.pooledCache=null,u0(o)))}function xm(){return Db(),Mb(),Lb(),Pb()}function Pb(){if(ys!==5)return!1;var n=pl,o=sf;sf=0;var u=rt($o),x=te.T,w=W.p;try{W.p=32>u?32:u,te.T=null,u=nf,nf=null;var S=pl,q=$o;if(ys=0,dd=pl=null,$o=0,(rr&6)!==0)throw Error(s(331));var ge=rr;if(rr|=4,pb(S.current),gb(S,S.current,q,u),rr=ge,O0(0,!1),Nt&&typeof Nt.onPostCommitFiberRoot=="function")try{Nt.onPostCommitFiberRoot(Ie,S)}catch(Ae){}return!0}finally{W.p=w,te.T=x,Rb(n,o)}}function Fb(n,o,u){o=f(u,o),o=Ig(n.stateNode,o,2),n=dl(n,o,2),n!==null&&(re(n,2),oo(n))}function cr(n,o,u){if(n.tag===3)Fb(n,n,u);else for(;o!==null;){if(o.tag===3){Fb(o,n,u);break}else if(o.tag===1){var x=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof x.componentDidCatch=="function"&&(xl===null||!xl.has(x))){n=f(u,n),u=Iy(2),x=dl(o,u,2),x!==null&&(zy(u,x,o,n),re(x,2),oo(x));break}}o=o.return}}function df(n,o,u){var x=n.pingCache;if(x===null){x=n.pingCache=new Rj;var w=new Set;x.set(o,w)}else w=x.get(o),w===void 0&&(w=new Set,x.set(o,w));w.has(u)||(tf=!0,w.add(u),n=Bj.bind(null,n,o,u),o.then(n,n))}function Bj(n,o,u){var x=n.pingCache;x!==null&&x.delete(o),n.pingedLanes|=n.suspendedLanes&u,n.warmLanes&=~u,wr===n&&(Wa&u)===u&&(Hr===4||Hr===3&&(Wa&62914560)===Wa&&300>sa()-dm?(rr&2)===0&&ud(n,0):af|=u,cd===Wa&&(cd=0)),oo(n)}function Ib(n,o){o===0&&(o=Qe()),n=mi(n,o),n!==null&&(re(n,o),oo(n))}function Uj(n){var o=n.memoizedState,u=0;o!==null&&(u=o.retryLane),Ib(n,u)}function $j(n,o){var u=0;switch(n.tag){case 31:case 13:var x=n.stateNode,w=n.memoizedState;w!==null&&(u=w.retryLane);break;case 19:x=n.stateNode;break;case 22:x=n.stateNode._retryCache;break;default:throw Error(s(314))}x!==null&&x.delete(o),Ib(n,u)}function Hj(n,o){return Wt(n,o)}var pm=null,hd=null,uf=!1,ym=!1,mf=!1,bl=0;function oo(n){n!==hd&&n.next===null&&(hd===null?pm=hd=n:hd=hd.next=n),ym=!0,uf||(uf=!0,Vj())}function O0(n,o){if(!mf&&ym){mf=!0;do for(var u=!1,x=pm;x!==null;){if(n!==0){var w=x.pendingLanes;if(w===0)var S=0;else{var q=x.suspendedLanes,ge=x.pingedLanes;S=(1<<31-Oe(42|n)+1)-1,S&=w&~(q&~ge),S=S&201326741?S&201326741|1:S?S|2:0}S!==0&&(u=!0,$b(x,S))}else S=Wa,S=Ot(x,x===wr?S:0,x.cancelPendingCommit!==null||x.timeoutHandle!==-1),(S&3)===0||Rt(x,S)||(u=!0,$b(x,S));x=x.next}while(u);mf=!1}}function Wj(){zb()}function zb(){ym=uf=!1;var n=0;bl!==0&&tN()&&(n=bl);for(var o=sa(),u=null,x=pm;x!==null;){var w=x.next,S=Bb(x,o);S===0?(x.next=null,u===null?pm=w:u.next=w,w===null&&(hd=u)):(u=x,(n!==0||(S&3)!==0)&&(ym=!0)),x=w}ys!==0&&ys!==5||O0(n),bl!==0&&(bl=0)}function Bb(n,o){for(var u=n.suspendedLanes,x=n.pingedLanes,w=n.expirationTimes,S=n.pendingLanes&-62914561;0<S;){var q=31-Oe(S),ge=1<<q,Ae=w[q];Ae===-1?((ge&u)===0||(ge&x)!==0)&&(w[q]=De(ge,o)):Ae<=o&&(n.expiredLanes|=ge),S&=~ge}if(o=wr,u=Wa,u=Ot(n,n===o?u:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),x=n.callbackNode,u===0||n===o&&(lr===2||lr===9)||n.cancelPendingCommit!==null)return x!==null&&x!==null&&Vt(x),n.callbackNode=null,n.callbackPriority=0;if((u&3)===0||Rt(n,u)){if(o=u&-u,o===n.callbackPriority)return o;switch(x!==null&&Vt(x),rt(u)){case 2:case 8:u=ft;break;case 32:u=$t;break;case 268435456:u=Ze;break;default:u=$t}return x=Ub.bind(null,n),u=Wt(u,x),n.callbackPriority=o,n.callbackNode=u,o}return x!==null&&x!==null&&Vt(x),n.callbackPriority=2,n.callbackNode=null,2}function Ub(n,o){if(ys!==0&&ys!==5)return n.callbackNode=null,n.callbackPriority=0,null;var u=n.callbackNode;if(xm()&&n.callbackNode!==u)return null;var x=Wa;return x=Ot(n,n===wr?x:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),x===0?null:(wb(n,x,o),Bb(n,sa()),n.callbackNode!=null&&n.callbackNode===u?Ub.bind(null,n):null)}function $b(n,o){if(xm())return null;wb(n,o,!0)}function Vj(){rN(function(){(rr&6)!==0?Wt(Ye,Wj):zb()})}function hf(){if(bl===0){var n=Kc;n===0&&(n=kt,kt<<=1,(kt&261888)===0&&(kt=256)),bl=n}return bl}function Hb(n){return n==null||typeof n=="symbol"||typeof n=="boolean"?null:typeof n=="function"?n:yt(""+n)}function Wb(n,o){var u=o.ownerDocument.createElement("input");return u.name=o.name,u.value=o.value,n.id&&u.setAttribute("form",n.id),o.parentNode.insertBefore(u,o),n=new FormData(n),u.parentNode.removeChild(u),n}function qj(n,o,u,x,w){if(o==="submit"&&u&&u.stateNode===w){var S=Hb((w[xe]||null).action),q=x.submitter;q&&(o=(o=q[xe]||null)?Hb(o.formAction):q.getAttribute("formAction"),o!==null&&(S=o,q=null));var ge=new bo("action","action",null,x,w);n.push({event:ge,listeners:[{instance:null,listener:function(){if(x.defaultPrevented){if(bl!==0){var Ae=q?Wb(w,q):new FormData(w);Dg(u,{pending:!0,data:Ae,method:w.method,action:S},null,Ae)}}else typeof S=="function"&&(ge.preventDefault(),Ae=q?Wb(w,q):new FormData(w),Dg(u,{pending:!0,data:Ae,method:w.method,action:S},S,Ae))},currentTarget:w}]})}}for(var gf=0;gf<Rr.length;gf++){var ff=Rr[gf],Gj=ff.toLowerCase(),Yj=ff[0].toUpperCase()+ff.slice(1);zs(Gj,"on"+Yj)}zs(Tr,"onAnimationEnd"),zs(Ba,"onAnimationIteration"),zs(Br,"onAnimationStart"),zs("dblclick","onDoubleClick"),zs("focusin","onFocus"),zs("focusout","onBlur"),zs(an,"onTransitionRun"),zs(as,"onTransitionStart"),zs(Is,"onTransitionCancel"),zs(Pa,"onTransitionEnd"),gr("onMouseEnter",["mouseout","mouseover"]),gr("onMouseLeave",["mouseout","mouseover"]),gr("onPointerEnter",["pointerout","pointerover"]),gr("onPointerLeave",["pointerout","pointerover"]),Ya("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ya("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ya("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ya("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ya("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ya("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var D0="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(" "),Zj=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(D0));function Vb(n,o){o=(o&4)!==0;for(var u=0;u<n.length;u++){var x=n[u],w=x.event;x=x.listeners;e:{var S=void 0;if(o)for(var q=x.length-1;0<=q;q--){var ge=x[q],Ae=ge.instance,Ke=ge.currentTarget;if(ge=ge.listener,Ae!==S&&w.isPropagationStopped())break e;S=ge,w.currentTarget=Ke;try{S(w)}catch(vt){Bs(vt)}w.currentTarget=null,S=Ae}else for(q=0;q<x.length;q++){if(ge=x[q],Ae=ge.instance,Ke=ge.currentTarget,ge=ge.listener,Ae!==S&&w.isPropagationStopped())break e;S=ge,w.currentTarget=Ke;try{S(w)}catch(vt){Bs(vt)}w.currentTarget=null,S=Ae}}}}function Ha(n,o){var u=o[He];u===void 0&&(u=o[He]=new Set);var x=n+"__bubble";u.has(x)||(qb(o,n,2,!1),u.add(x))}function xf(n,o,u){var x=0;o&&(x|=4),qb(u,n,x,o)}var bm="_reactListening"+Math.random().toString(36).slice(2);function pf(n){if(!n[bm]){n[bm]=!0,Fa.forEach(function(u){u!=="selectionchange"&&(Zj.has(u)||xf(u,!1,n),xf(u,!0,n))});var o=n.nodeType===9?n:n.ownerDocument;o===null||o[bm]||(o[bm]=!0,xf("selectionchange",!1,o))}}function qb(n,o,u,x){switch(_v(o)){case 2:var w=kN;break;case 8:w=jN;break;default:w=Df}u=w.bind(null,o,u,n),w=void 0,!ki||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(w=!0),x?w!==void 0?n.addEventListener(o,u,{capture:!0,passive:w}):n.addEventListener(o,u,!0):w!==void 0?n.addEventListener(o,u,{passive:w}):n.addEventListener(o,u,!1)}function yf(n,o,u,x,w){var S=x;if((o&1)===0&&(o&2)===0&&x!==null)e:for(;;){if(x===null)return;var q=x.tag;if(q===3||q===4){var ge=x.stateNode.containerInfo;if(ge===w)break;if(q===4)for(q=x.return;q!==null;){var Ae=q.tag;if((Ae===3||Ae===4)&&q.stateNode.containerInfo===w)return;q=q.return}for(;ge!==null;){if(q=Ft(ge),q===null)return;if(Ae=q.tag,Ae===5||Ae===6||Ae===26||Ae===27){x=S=q;continue e}ge=ge.parentNode}}x=x.return}_n(function(){var Ke=S,vt=Sr(u),Et=[];e:{var at=qn.get(n);if(at!==void 0){var ut=bo,la=n;switch(n){case"keypress":if(Un(u)===0)break e;case"keydown":case"keyup":ut=Uc;break;case"focusin":la="focus",ut=Fl;break;case"focusout":la="blur",ut=Fl;break;case"beforeblur":case"afterblur":ut=Fl;break;case"click":if(u.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ut=qi;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ut=li;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ut=t0;break;case Tr:case Ba:case Br:ut=Il;break;case Pa:ut=Hc;break;case"scroll":case"scrollend":ut=Ra;break;case"wheel":ut=un;break;case"copy":case"cut":case"paste":ut=fs;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ut=al;break;case"toggle":case"beforetoggle":ut=di}var ba=(o&4)!==0,br=!ba&&(n==="scroll"||n==="scrollend"),Ve=ba?at!==null?at+"Capture":null:at;ba=[];for(var Fe=Ke,Je;Fe!==null;){var jt=Fe;if(Je=jt.stateNode,jt=jt.tag,jt!==5&&jt!==26&&jt!==27||Je===null||Ve===null||(jt=wn(Fe,Ve),jt!=null&&ba.push(M0(Fe,jt,Je))),br)break;Fe=Fe.return}0<ba.length&&(at=new ut(at,la,null,u,vt),Et.push({event:at,listeners:ba}))}}if((o&7)===0){e:{if(at=n==="mouseover"||n==="pointerover",ut=n==="mouseout"||n==="pointerout",at&&u!==_r&&(la=u.relatedTarget||u.fromElement)&&(Ft(la)||la[_e]))break e;if((ut||at)&&(at=vt.window===vt?vt:(at=vt.ownerDocument)?at.defaultView||at.parentWindow:window,ut?(la=u.relatedTarget||u.toElement,ut=Ke,la=la?Ft(la):null,la!==null&&(br=c(la),ba=la.tag,la!==br||ba!==5&&ba!==27&&ba!==6)&&(la=null)):(ut=null,la=Ke),ut!==la)){if(ba=qi,jt="onMouseLeave",Ve="onMouseEnter",Fe="mouse",(n==="pointerout"||n==="pointerover")&&(ba=al,jt="onPointerLeave",Ve="onPointerEnter",Fe="pointer"),br=ut==null?at:pt(ut),Je=la==null?at:pt(la),at=new ba(jt,Fe+"leave",ut,u,vt),at.target=br,at.relatedTarget=Je,jt=null,Ft(vt)===Ke&&(ba=new ba(Ve,Fe+"enter",la,u,vt),ba.target=Je,ba.relatedTarget=br,jt=ba),br=jt,ut&&la)t:{for(ba=Jj,Ve=ut,Fe=la,Je=0,jt=Ve;jt;jt=ba(jt))Je++;jt=0;for(var ga=Fe;ga;ga=ba(ga))jt++;for(;0<Je-jt;)Ve=ba(Ve),Je--;for(;0<jt-Je;)Fe=ba(Fe),jt--;for(;Je--;){if(Ve===Fe||Fe!==null&&Ve===Fe.alternate){ba=Ve;break t}Ve=ba(Ve),Fe=ba(Fe)}ba=null}else ba=null;ut!==null&&Gb(Et,at,ut,ba,!1),la!==null&&br!==null&&Gb(Et,br,la,ba,!0)}}e:{if(at=Ke?pt(Ke):window,ut=at.nodeName&&at.nodeName.toLowerCase(),ut==="select"||ut==="input"&&at.type==="file")var Qa=Ji;else if(jn(at))if(qc)Qa=Iu;else{Qa=s0;var da=Fs}else ut=at.nodeName,!ut||ut.toLowerCase()!=="input"||at.type!=="checkbox"&&at.type!=="radio"?Ke&&oi(Ke.elementType)&&(Qa=Ji):Qa=Ki;if(Qa&&(Qa=Qa(n,Ke))){Vc(Et,Qa,u,vt);break e}da&&da(n,at,Ke),n==="focusout"&&Ke&&at.type==="number"&&Ke.memoizedProps.value!=null&&wa(at,"number",at.value)}switch(da=Ke?pt(Ke):window,n){case"focusin":(jn(da)||da.contentEditable==="true")&&(Vn=da,To=Ke,Z=null);break;case"focusout":Z=To=Vn=null;break;case"mousedown":pe=!0;break;case"contextmenu":case"mouseup":case"dragend":pe=!1,je(Et,u,vt);break;case"selectionchange":if(Co)break;case"keydown":case"keyup":je(Et,u,vt)}var Da;if(rl)e:{switch(n){case"compositionstart":var Va="onCompositionStart";break e;case"compositionend":Va="onCompositionEnd";break e;case"compositionupdate":Va="onCompositionUpdate";break e}Va=void 0}else Yi?Wc(n,u)&&(Va="onCompositionEnd"):n==="keydown"&&u.keyCode===229&&(Va="onCompositionStart");Va&&(ko&&u.locale!=="ko"&&(Yi||Va!=="onCompositionStart"?Va==="onCompositionEnd"&&Yi&&(Da=Bn()):(Ls=vt,zn="value"in Ls?Ls.value:Ls.textContent,Yi=!0)),da=vm(Ke,Va),0<da.length&&(Va=new _o(Va,n,null,u,vt),Et.push({event:Va,listeners:da}),Da?Va.data=Da:(Da=Wl(u),Da!==null&&(Va.data=Da)))),(Da=a0?mn(n,u):Zi(n,u))&&(Va=vm(Ke,"onBeforeInput"),0<Va.length&&(da=new _o("onBeforeInput","beforeinput",null,u,vt),Et.push({event:da,listeners:Va}),da.data=Da)),qj(Et,n,Ke,u,vt)}Vb(Et,o)})}function M0(n,o,u){return{instance:n,listener:o,currentTarget:u}}function vm(n,o){for(var u=o+"Capture",x=[];n!==null;){var w=n,S=w.stateNode;if(w=w.tag,w!==5&&w!==26&&w!==27||S===null||(w=wn(n,u),w!=null&&x.unshift(M0(n,w,S)),w=wn(n,o),w!=null&&x.push(M0(n,w,S))),n.tag===3)return x;n=n.return}return[]}function Jj(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5&&n.tag!==27);return n||null}function Gb(n,o,u,x,w){for(var S=o._reactName,q=[];u!==null&&u!==x;){var ge=u,Ae=ge.alternate,Ke=ge.stateNode;if(ge=ge.tag,Ae!==null&&Ae===x)break;ge!==5&&ge!==26&&ge!==27||Ke===null||(Ae=Ke,w?(Ke=wn(u,S),Ke!=null&&q.unshift(M0(u,Ke,Ae))):w||(Ke=wn(u,S),Ke!=null&&q.push(M0(u,Ke,Ae)))),u=u.return}q.length!==0&&n.push({event:o,listeners:q})}var Xj=/\r\n?/g,Kj=/\u0000|\uFFFD/g;function Yb(n){return(typeof n=="string"?n:""+n).replace(Xj,`
`).replace(Kj,"")}function Zb(n,o){return o=Yb(o),Yb(n)===o}function yr(n,o,u,x,w,S){switch(u){case"children":typeof x=="string"?o==="body"||o==="textarea"&&x===""||Gr(n,x):(typeof x=="number"||typeof x=="bigint")&&o!=="body"&&Gr(n,""+x);break;case"className":Ia(n,"class",x);break;case"tabIndex":Ia(n,"tabindex",x);break;case"dir":case"role":case"viewBox":case"width":case"height":Ia(n,u,x);break;case"style":Ms(n,x,S);break;case"data":if(o!=="object"){Ia(n,"data",x);break}case"src":case"href":if(x===""&&(o!=="a"||u!=="href")){n.removeAttribute(u);break}if(x==null||typeof x=="function"||typeof x=="symbol"||typeof x=="boolean"){n.removeAttribute(u);break}x=yt(""+x),n.setAttribute(u,x);break;case"action":case"formAction":if(typeof x=="function"){n.setAttribute(u,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof S=="function"&&(u==="formAction"?(o!=="input"&&yr(n,o,"name",w.name,w,null),yr(n,o,"formEncType",w.formEncType,w,null),yr(n,o,"formMethod",w.formMethod,w,null),yr(n,o,"formTarget",w.formTarget,w,null)):(yr(n,o,"encType",w.encType,w,null),yr(n,o,"method",w.method,w,null),yr(n,o,"target",w.target,w,null)));if(x==null||typeof x=="symbol"||typeof x=="boolean"){n.removeAttribute(u);break}x=yt(""+x),n.setAttribute(u,x);break;case"onClick":x!=null&&(n.onclick=Sa);break;case"onScroll":x!=null&&Ha("scroll",n);break;case"onScrollEnd":x!=null&&Ha("scrollend",n);break;case"dangerouslySetInnerHTML":if(x!=null){if(typeof x!="object"||!("__html"in x))throw Error(s(61));if(u=x.__html,u!=null){if(w.children!=null)throw Error(s(60));n.innerHTML=u}}break;case"multiple":n.multiple=x&&typeof x!="function"&&typeof x!="symbol";break;case"muted":n.muted=x&&typeof x!="function"&&typeof x!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(x==null||typeof x=="function"||typeof x=="boolean"||typeof x=="symbol"){n.removeAttribute("xlink:href");break}u=yt(""+x),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",u);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":x!=null&&typeof x!="function"&&typeof x!="symbol"?n.setAttribute(u,""+x):n.removeAttribute(u);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":x&&typeof x!="function"&&typeof x!="symbol"?n.setAttribute(u,""):n.removeAttribute(u);break;case"capture":case"download":x===!0?n.setAttribute(u,""):x!==!1&&x!=null&&typeof x!="function"&&typeof x!="symbol"?n.setAttribute(u,x):n.removeAttribute(u);break;case"cols":case"rows":case"size":case"span":x!=null&&typeof x!="function"&&typeof x!="symbol"&&!isNaN(x)&&1<=x?n.setAttribute(u,x):n.removeAttribute(u);break;case"rowSpan":case"start":x==null||typeof x=="function"||typeof x=="symbol"||isNaN(x)?n.removeAttribute(u):n.setAttribute(u,x);break;case"popover":Ha("beforetoggle",n),Ha("toggle",n),ha(n,"popover",x);break;case"xlinkActuate":qr(n,"http://www.w3.org/1999/xlink","xlink:actuate",x);break;case"xlinkArcrole":qr(n,"http://www.w3.org/1999/xlink","xlink:arcrole",x);break;case"xlinkRole":qr(n,"http://www.w3.org/1999/xlink","xlink:role",x);break;case"xlinkShow":qr(n,"http://www.w3.org/1999/xlink","xlink:show",x);break;case"xlinkTitle":qr(n,"http://www.w3.org/1999/xlink","xlink:title",x);break;case"xlinkType":qr(n,"http://www.w3.org/1999/xlink","xlink:type",x);break;case"xmlBase":qr(n,"http://www.w3.org/XML/1998/namespace","xml:base",x);break;case"xmlLang":qr(n,"http://www.w3.org/XML/1998/namespace","xml:lang",x);break;case"xmlSpace":qr(n,"http://www.w3.org/XML/1998/namespace","xml:space",x);break;case"is":ha(n,"is",x);break;case"innerText":case"textContent":break;default:(!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(u=wi.get(u)||u,ha(n,u,x))}}function bf(n,o,u,x,w,S){switch(u){case"style":Ms(n,x,S);break;case"dangerouslySetInnerHTML":if(x!=null){if(typeof x!="object"||!("__html"in x))throw Error(s(61));if(u=x.__html,u!=null){if(w.children!=null)throw Error(s(60));n.innerHTML=u}}break;case"children":typeof x=="string"?Gr(n,x):(typeof x=="number"||typeof x=="bigint")&&Gr(n,""+x);break;case"onScroll":x!=null&&Ha("scroll",n);break;case"onScrollEnd":x!=null&&Ha("scrollend",n);break;case"onClick":x!=null&&(n.onclick=Sa);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!La.hasOwnProperty(u))e:{if(u[0]==="o"&&u[1]==="n"&&(w=u.endsWith("Capture"),o=u.slice(2,w?u.length-7:void 0),S=n[xe]||null,S=S!=null?S[u]:null,typeof S=="function"&&n.removeEventListener(o,S,w),typeof x=="function")){typeof S!="function"&&S!==null&&(u in n?n[u]=null:n.hasAttribute(u)&&n.removeAttribute(u)),n.addEventListener(o,x,w);break e}u in n?n[u]=x:x===!0?n.setAttribute(u,""):ha(n,u,x)}}}function Hs(n,o,u){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ha("error",n),Ha("load",n);var x=!1,w=!1,S;for(S in u)if(u.hasOwnProperty(S)){var q=u[S];if(q!=null)switch(S){case"src":x=!0;break;case"srcSet":w=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,o));default:yr(n,o,S,q,u,null)}}w&&yr(n,o,"srcSet",u.srcSet,u,null),x&&yr(n,o,"src",u.src,u,null);return;case"input":Ha("invalid",n);var ge=S=q=w=null,Ae=null,Ke=null;for(x in u)if(u.hasOwnProperty(x)){var vt=u[x];if(vt!=null)switch(x){case"name":w=vt;break;case"type":q=vt;break;case"checked":Ae=vt;break;case"defaultChecked":Ke=vt;break;case"value":S=vt;break;case"defaultValue":ge=vt;break;case"children":case"dangerouslySetInnerHTML":if(vt!=null)throw Error(s(137,o));break;default:yr(n,o,x,vt,u,null)}}xr(n,S,ge,Ae,Ke,q,w,!1);return;case"select":Ha("invalid",n),x=q=S=null;for(w in u)if(u.hasOwnProperty(w)&&(ge=u[w],ge!=null))switch(w){case"value":S=ge;break;case"defaultValue":q=ge;break;case"multiple":x=ge;default:yr(n,o,w,ge,u,null)}o=S,u=q,n.multiple=!!x,o!=null?Za(n,!!x,o,!1):u!=null&&Za(n,!!x,u,!0);return;case"textarea":Ha("invalid",n),S=w=x=null;for(q in u)if(u.hasOwnProperty(q)&&(ge=u[q],ge!=null))switch(q){case"value":x=ge;break;case"defaultValue":w=ge;break;case"children":S=ge;break;case"dangerouslySetInnerHTML":if(ge!=null)throw Error(s(91));break;default:yr(n,o,q,ge,u,null)}_s(n,x,w,S);return;case"option":for(Ae in u)if(u.hasOwnProperty(Ae)&&(x=u[Ae],x!=null))switch(Ae){case"selected":n.selected=x&&typeof x!="function"&&typeof x!="symbol";break;default:yr(n,o,Ae,x,u,null)}return;case"dialog":Ha("beforetoggle",n),Ha("toggle",n),Ha("cancel",n),Ha("close",n);break;case"iframe":case"object":Ha("load",n);break;case"video":case"audio":for(x=0;x<D0.length;x++)Ha(D0[x],n);break;case"image":Ha("error",n),Ha("load",n);break;case"details":Ha("toggle",n);break;case"embed":case"source":case"link":Ha("error",n),Ha("load",n);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Ke in u)if(u.hasOwnProperty(Ke)&&(x=u[Ke],x!=null))switch(Ke){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,o));default:yr(n,o,Ke,x,u,null)}return;default:if(oi(o)){for(vt in u)u.hasOwnProperty(vt)&&(x=u[vt],x!==void 0&&bf(n,o,vt,x,u,void 0));return}}for(ge in u)u.hasOwnProperty(ge)&&(x=u[ge],x!=null&&yr(n,o,ge,x,u,null))}function Qj(n,o,u,x){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var w=null,S=null,q=null,ge=null,Ae=null,Ke=null,vt=null;for(ut in u){var Et=u[ut];if(u.hasOwnProperty(ut)&&Et!=null)switch(ut){case"checked":break;case"value":break;case"defaultValue":Ae=Et;default:x.hasOwnProperty(ut)||yr(n,o,ut,null,x,Et)}}for(var at in x){var ut=x[at];if(Et=u[at],x.hasOwnProperty(at)&&(ut!=null||Et!=null))switch(at){case"type":S=ut;break;case"name":w=ut;break;case"checked":Ke=ut;break;case"defaultChecked":vt=ut;break;case"value":q=ut;break;case"defaultValue":ge=ut;break;case"children":case"dangerouslySetInnerHTML":if(ut!=null)throw Error(s(137,o));break;default:ut!==Et&&yr(n,o,at,ut,x,Et)}}Ds(n,q,ge,Ae,Ke,vt,S,w);return;case"select":ut=q=ge=at=null;for(S in u)if(Ae=u[S],u.hasOwnProperty(S)&&Ae!=null)switch(S){case"value":break;case"multiple":ut=Ae;default:x.hasOwnProperty(S)||yr(n,o,S,null,x,Ae)}for(w in x)if(S=x[w],Ae=u[w],x.hasOwnProperty(w)&&(S!=null||Ae!=null))switch(w){case"value":at=S;break;case"defaultValue":ge=S;break;case"multiple":q=S;default:S!==Ae&&yr(n,o,w,S,x,Ae)}o=ge,u=q,x=ut,at!=null?Za(n,!!u,at,!1):!!x!=!!u&&(o!=null?Za(n,!!u,o,!0):Za(n,!!u,u?[]:"",!1));return;case"textarea":ut=at=null;for(ge in u)if(w=u[ge],u.hasOwnProperty(ge)&&w!=null&&!x.hasOwnProperty(ge))switch(ge){case"value":break;case"children":break;default:yr(n,o,ge,null,x,w)}for(q in x)if(w=x[q],S=u[q],x.hasOwnProperty(q)&&(w!=null||S!=null))switch(q){case"value":at=w;break;case"defaultValue":ut=w;break;case"children":break;case"dangerouslySetInnerHTML":if(w!=null)throw Error(s(91));break;default:w!==S&&yr(n,o,q,w,x,S)}cn(n,at,ut);return;case"option":for(var la in u)if(at=u[la],u.hasOwnProperty(la)&&at!=null&&!x.hasOwnProperty(la))switch(la){case"selected":n.selected=!1;break;default:yr(n,o,la,null,x,at)}for(Ae in x)if(at=x[Ae],ut=u[Ae],x.hasOwnProperty(Ae)&&at!==ut&&(at!=null||ut!=null))switch(Ae){case"selected":n.selected=at&&typeof at!="function"&&typeof at!="symbol";break;default:yr(n,o,Ae,at,x,ut)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var ba in u)at=u[ba],u.hasOwnProperty(ba)&&at!=null&&!x.hasOwnProperty(ba)&&yr(n,o,ba,null,x,at);for(Ke in x)if(at=x[Ke],ut=u[Ke],x.hasOwnProperty(Ke)&&at!==ut&&(at!=null||ut!=null))switch(Ke){case"children":case"dangerouslySetInnerHTML":if(at!=null)throw Error(s(137,o));break;default:yr(n,o,Ke,at,x,ut)}return;default:if(oi(o)){for(var br in u)at=u[br],u.hasOwnProperty(br)&&at!==void 0&&!x.hasOwnProperty(br)&&bf(n,o,br,void 0,x,at);for(vt in x)at=x[vt],ut=u[vt],!x.hasOwnProperty(vt)||at===ut||at===void 0&&ut===void 0||bf(n,o,vt,at,x,ut);return}}for(var Ve in u)at=u[Ve],u.hasOwnProperty(Ve)&&at!=null&&!x.hasOwnProperty(Ve)&&yr(n,o,Ve,null,x,at);for(Et in x)at=x[Et],ut=u[Et],!x.hasOwnProperty(Et)||at===ut||at==null&&ut==null||yr(n,o,Et,at,x,ut)}function Jb(n){switch(n){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function eN(){if(typeof performance.getEntriesByType=="function"){for(var n=0,o=0,u=performance.getEntriesByType("resource"),x=0;x<u.length;x++){var w=u[x],S=w.transferSize,q=w.initiatorType,ge=w.duration;if(S&&ge&&Jb(q)){for(q=0,ge=w.responseEnd,x+=1;x<u.length;x++){var Ae=u[x],Ke=Ae.startTime;if(Ke>ge)break;var vt=Ae.transferSize,Et=Ae.initiatorType;vt&&Jb(Et)&&(Ae=Ae.responseEnd,q+=vt*(Ae<ge?1:(ge-Ke)/(Ae-Ke)))}if(--x,o+=8*(S+q)/(w.duration/1e3),n++,10<n)break}}if(0<n)return o/n/1e6}return navigator.connection&&(n=navigator.connection.downlink,typeof n=="number")?n:5}var vf=null,_f=null;function _m(n){return n.nodeType===9?n:n.ownerDocument}function Xb(n){switch(n){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Kb(n,o){if(n===0)switch(o){case"svg":return 1;case"math":return 2;default:return 0}return n===1&&o==="foreignObject"?0:n}function wf(n,o){return n==="textarea"||n==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.children=="bigint"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var kf=null;function tN(){var n=window.event;return n&&n.type==="popstate"?n===kf?!1:(kf=n,!0):(kf=null,!1)}var Qb=typeof setTimeout=="function"?setTimeout:void 0,aN=typeof clearTimeout=="function"?clearTimeout:void 0,ev=typeof Promise=="function"?Promise:void 0,rN=typeof queueMicrotask=="function"?queueMicrotask:typeof ev!="undefined"?function(n){return ev.resolve(null).then(n).catch(sN)}:Qb;function sN(n){setTimeout(function(){throw n})}function vl(n){return n==="head"}function tv(n,o){var u=o,x=0;do{var w=u.nextSibling;if(n.removeChild(u),w&&w.nodeType===8)if(u=w.data,u==="/$"||u==="/&"){if(x===0){n.removeChild(w),pd(o);return}x--}else if(u==="$"||u==="$?"||u==="$~"||u==="$!"||u==="&")x++;else if(u==="html")L0(n.ownerDocument.documentElement);else if(u==="head"){u=n.ownerDocument.head,L0(u);for(var S=u.firstChild;S;){var q=S.nextSibling,ge=S.nodeName;S[We]||ge==="SCRIPT"||ge==="STYLE"||ge==="LINK"&&S.rel.toLowerCase()==="stylesheet"||u.removeChild(S),S=q}}else u==="body"&&L0(n.ownerDocument.body);u=w}while(u);pd(o)}function av(n,o){var u=n;n=0;do{var x=u.nextSibling;if(u.nodeType===1?o?(u._stashedDisplay=u.style.display,u.style.display="none"):(u.style.display=u._stashedDisplay||"",u.getAttribute("style")===""&&u.removeAttribute("style")):u.nodeType===3&&(o?(u._stashedText=u.nodeValue,u.nodeValue=""):u.nodeValue=u._stashedText||""),x&&x.nodeType===8)if(u=x.data,u==="/$"){if(n===0)break;n--}else u!=="$"&&u!=="$?"&&u!=="$~"&&u!=="$!"||n++;u=x}while(u)}function jf(n){var o=n.firstChild;for(o&&o.nodeType===10&&(o=o.nextSibling);o;){var u=o;switch(o=o.nextSibling,u.nodeName){case"HTML":case"HEAD":case"BODY":jf(u),_t(u);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(u.rel.toLowerCase()==="stylesheet")continue}n.removeChild(u)}}function nN(n,o,u,x){for(;n.nodeType===1;){var w=u;if(n.nodeName.toLowerCase()!==o.toLowerCase()){if(!x&&(n.nodeName!=="INPUT"||n.type!=="hidden"))break}else if(x){if(!n[We])switch(o){case"meta":if(!n.hasAttribute("itemprop"))break;return n;case"link":if(S=n.getAttribute("rel"),S==="stylesheet"&&n.hasAttribute("data-precedence"))break;if(S!==w.rel||n.getAttribute("href")!==(w.href==null||w.href===""?null:w.href)||n.getAttribute("crossorigin")!==(w.crossOrigin==null?null:w.crossOrigin)||n.getAttribute("title")!==(w.title==null?null:w.title))break;return n;case"style":if(n.hasAttribute("data-precedence"))break;return n;case"script":if(S=n.getAttribute("src"),(S!==(w.src==null?null:w.src)||n.getAttribute("type")!==(w.type==null?null:w.type)||n.getAttribute("crossorigin")!==(w.crossOrigin==null?null:w.crossOrigin))&&S&&n.hasAttribute("async")&&!n.hasAttribute("itemprop"))break;return n;default:return n}}else if(o==="input"&&n.type==="hidden"){var S=w.name==null?null:""+w.name;if(w.type==="hidden"&&n.getAttribute("name")===S)return n}else return n;if(n=fi(n.nextSibling),n===null)break}return null}function iN(n,o,u){if(o==="")return null;for(;n.nodeType!==3;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!u||(n=fi(n.nextSibling),n===null))return null;return n}function rv(n,o){for(;n.nodeType!==8;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!o||(n=fi(n.nextSibling),n===null))return null;return n}function Nf(n){return n.data==="$?"||n.data==="$~"}function Sf(n){return n.data==="$!"||n.data==="$?"&&n.ownerDocument.readyState!=="loading"}function oN(n,o){var u=n.ownerDocument;if(n.data==="$~")n._reactRetry=o;else if(n.data!=="$?"||u.readyState!=="loading")o();else{var x=function(){o(),u.removeEventListener("DOMContentLoaded",x)};u.addEventListener("DOMContentLoaded",x),n._reactRetry=x}}function fi(n){for(;n!=null;n=n.nextSibling){var o=n.nodeType;if(o===1||o===3)break;if(o===8){if(o=n.data,o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"||o==="F!"||o==="F")break;if(o==="/$"||o==="/&")return null}}return n}var Cf=null;function sv(n){n=n.nextSibling;for(var o=0;n;){if(n.nodeType===8){var u=n.data;if(u==="/$"||u==="/&"){if(o===0)return fi(n.nextSibling);o--}else u!=="$"&&u!=="$!"&&u!=="$?"&&u!=="$~"&&u!=="&"||o++}n=n.nextSibling}return null}function nv(n){n=n.previousSibling;for(var o=0;n;){if(n.nodeType===8){var u=n.data;if(u==="$"||u==="$!"||u==="$?"||u==="$~"||u==="&"){if(o===0)return n;o--}else u!=="/$"&&u!=="/&"||o++}n=n.previousSibling}return null}function iv(n,o,u){switch(o=_m(u),n){case"html":if(n=o.documentElement,!n)throw Error(s(452));return n;case"head":if(n=o.head,!n)throw Error(s(453));return n;case"body":if(n=o.body,!n)throw Error(s(454));return n;default:throw Error(s(451))}}function L0(n){for(var o=n.attributes;o.length;)n.removeAttributeNode(o[0]);_t(n)}var xi=new Map,ov=new Set;function wm(n){return typeof n.getRootNode=="function"?n.getRootNode():n.nodeType===9?n:n.ownerDocument}var Ho=W.d;W.d={f:lN,r:cN,D:dN,C:uN,L:mN,m:hN,X:fN,S:gN,M:xN};function lN(){var n=Ho.f(),o=hm();return n||o}function cN(n){var o=dt(n);o!==null&&o.tag===5&&o.type==="form"?jy(o):Ho.r(n)}var gd=typeof document=="undefined"?null:document;function lv(n,o,u){var x=gd;if(x&&typeof o=="string"&&o){var w=Aa(o);w='link[rel="'+n+'"][href="'+w+'"]',typeof u=="string"&&(w+='[crossorigin="'+u+'"]'),ov.has(w)||(ov.add(w),n={rel:n,crossOrigin:u,href:o},x.querySelector(w)===null&&(o=x.createElement("link"),Hs(o,"link",n),Zt(o),x.head.appendChild(o)))}}function dN(n){Ho.D(n),lv("dns-prefetch",n,null)}function uN(n,o){Ho.C(n,o),lv("preconnect",n,o)}function mN(n,o,u){Ho.L(n,o,u);var x=gd;if(x&&n&&o){var w='link[rel="preload"][as="'+Aa(o)+'"]';o==="image"&&u&&u.imageSrcSet?(w+='[imagesrcset="'+Aa(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(w+='[imagesizes="'+Aa(u.imageSizes)+'"]')):w+='[href="'+Aa(n)+'"]';var S=w;switch(o){case"style":S=fd(n);break;case"script":S=xd(n)}xi.has(S)||(n=b({rel:"preload",href:o==="image"&&u&&u.imageSrcSet?void 0:n,as:o},u),xi.set(S,n),x.querySelector(w)!==null||o==="style"&&x.querySelector(R0(S))||o==="script"&&x.querySelector(P0(S))||(o=x.createElement("link"),Hs(o,"link",n),Zt(o),x.head.appendChild(o)))}}function hN(n,o){Ho.m(n,o);var u=gd;if(u&&n){var x=o&&typeof o.as=="string"?o.as:"script",w='link[rel="modulepreload"][as="'+Aa(x)+'"][href="'+Aa(n)+'"]',S=w;switch(x){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":S=xd(n)}if(!xi.has(S)&&(n=b({rel:"modulepreload",href:n},o),xi.set(S,n),u.querySelector(w)===null)){switch(x){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(P0(S)))return}x=u.createElement("link"),Hs(x,"link",n),Zt(x),u.head.appendChild(x)}}}function gN(n,o,u){Ho.S(n,o,u);var x=gd;if(x&&n){var w=At(x).hoistableStyles,S=fd(n);o=o||"default";var q=w.get(S);if(!q){var ge={loading:0,preload:null};if(q=x.querySelector(R0(S)))ge.loading=5;else{n=b({rel:"stylesheet",href:n,"data-precedence":o},u),(u=xi.get(S))&&Tf(n,u);var Ae=q=x.createElement("link");Zt(Ae),Hs(Ae,"link",n),Ae._p=new Promise(function(Ke,vt){Ae.onload=Ke,Ae.onerror=vt}),Ae.addEventListener("load",function(){ge.loading|=1}),Ae.addEventListener("error",function(){ge.loading|=2}),ge.loading|=4,km(q,o,x)}q={type:"stylesheet",instance:q,count:1,state:ge},w.set(S,q)}}}function fN(n,o){Ho.X(n,o);var u=gd;if(u&&n){var x=At(u).hoistableScripts,w=xd(n),S=x.get(w);S||(S=u.querySelector(P0(w)),S||(n=b({src:n,async:!0},o),(o=xi.get(w))&&Ef(n,o),S=u.createElement("script"),Zt(S),Hs(S,"link",n),u.head.appendChild(S)),S={type:"script",instance:S,count:1,state:null},x.set(w,S))}}function xN(n,o){Ho.M(n,o);var u=gd;if(u&&n){var x=At(u).hoistableScripts,w=xd(n),S=x.get(w);S||(S=u.querySelector(P0(w)),S||(n=b({src:n,async:!0,type:"module"},o),(o=xi.get(w))&&Ef(n,o),S=u.createElement("script"),Zt(S),Hs(S,"link",n),u.head.appendChild(S)),S={type:"script",instance:S,count:1,state:null},x.set(w,S))}}function cv(n,o,u,x){var w=(w=we.current)?wm(w):null;if(!w)throw Error(s(446));switch(n){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(o=fd(u.href),u=At(w).hoistableStyles,x=u.get(o),x||(x={type:"style",instance:null,count:0,state:null},u.set(o,x)),x):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){n=fd(u.href);var S=At(w).hoistableStyles,q=S.get(n);if(q||(w=w.ownerDocument||w,q={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},S.set(n,q),(S=w.querySelector(R0(n)))&&!S._p&&(q.instance=S,q.state.loading=5),xi.has(n)||(u={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},xi.set(n,u),S||pN(w,n,u,q.state))),o&&x===null)throw Error(s(528,""));return q}if(o&&x!==null)throw Error(s(529,""));return null;case"script":return o=u.async,u=u.src,typeof u=="string"&&o&&typeof o!="function"&&typeof o!="symbol"?(o=xd(u),u=At(w).hoistableScripts,x=u.get(o),x||(x={type:"script",instance:null,count:0,state:null},u.set(o,x)),x):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,n))}}function fd(n){return'href="'+Aa(n)+'"'}function R0(n){return'link[rel="stylesheet"]['+n+"]"}function dv(n){return b({},n,{"data-precedence":n.precedence,precedence:null})}function pN(n,o,u,x){n.querySelector('link[rel="preload"][as="style"]['+o+"]")?x.loading=1:(o=n.createElement("link"),x.preload=o,o.addEventListener("load",function(){return x.loading|=1}),o.addEventListener("error",function(){return x.loading|=2}),Hs(o,"link",u),Zt(o),n.head.appendChild(o))}function xd(n){return'[src="'+Aa(n)+'"]'}function P0(n){return"script[async]"+n}function uv(n,o,u){if(o.count++,o.instance===null)switch(o.type){case"style":var x=n.querySelector('style[data-href~="'+Aa(u.href)+'"]');if(x)return o.instance=x,Zt(x),x;var w=b({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return x=(n.ownerDocument||n).createElement("style"),Zt(x),Hs(x,"style",w),km(x,u.precedence,n),o.instance=x;case"stylesheet":w=fd(u.href);var S=n.querySelector(R0(w));if(S)return o.state.loading|=4,o.instance=S,Zt(S),S;x=dv(u),(w=xi.get(w))&&Tf(x,w),S=(n.ownerDocument||n).createElement("link"),Zt(S);var q=S;return q._p=new Promise(function(ge,Ae){q.onload=ge,q.onerror=Ae}),Hs(S,"link",x),o.state.loading|=4,km(S,u.precedence,n),o.instance=S;case"script":return S=xd(u.src),(w=n.querySelector(P0(S)))?(o.instance=w,Zt(w),w):(x=u,(w=xi.get(S))&&(x=b({},u),Ef(x,w)),n=n.ownerDocument||n,w=n.createElement("script"),Zt(w),Hs(w,"link",x),n.head.appendChild(w),o.instance=w);case"void":return null;default:throw Error(s(443,o.type))}else o.type==="stylesheet"&&(o.state.loading&4)===0&&(x=o.instance,o.state.loading|=4,km(x,u.precedence,n));return o.instance}function km(n,o,u){for(var x=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),w=x.length?x[x.length-1]:null,S=w,q=0;q<x.length;q++){var ge=x[q];if(ge.dataset.precedence===o)S=ge;else if(S!==w)break}S?S.parentNode.insertBefore(n,S.nextSibling):(o=u.nodeType===9?u.head:u,o.insertBefore(n,o.firstChild))}function Tf(n,o){n.crossOrigin==null&&(n.crossOrigin=o.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=o.referrerPolicy),n.title==null&&(n.title=o.title)}function Ef(n,o){n.crossOrigin==null&&(n.crossOrigin=o.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=o.referrerPolicy),n.integrity==null&&(n.integrity=o.integrity)}var jm=null;function mv(n,o,u){if(jm===null){var x=new Map,w=jm=new Map;w.set(u,x)}else w=jm,x=w.get(u),x||(x=new Map,w.set(u,x));if(x.has(n))return x;for(x.set(n,null),u=u.getElementsByTagName(n),w=0;w<u.length;w++){var S=u[w];if(!(S[We]||S[ie]||n==="link"&&S.getAttribute("rel")==="stylesheet")&&S.namespaceURI!=="http://www.w3.org/2000/svg"){var q=S.getAttribute(o)||"";q=n+q;var ge=x.get(q);ge?ge.push(S):x.set(q,[S])}}return x}function hv(n,o,u){n=n.ownerDocument||n,n.head.insertBefore(u,o==="title"?n.querySelector("head > title"):null)}function yN(n,o,u){if(u===1||o.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof o.precedence!="string"||typeof o.href!="string"||o.href==="")break;return!0;case"link":if(typeof o.rel!="string"||typeof o.href!="string"||o.href===""||o.onLoad||o.onError)break;switch(o.rel){case"stylesheet":return n=o.disabled,typeof o.precedence=="string"&&n==null;default:return!0}case"script":if(o.async&&typeof o.async!="function"&&typeof o.async!="symbol"&&!o.onLoad&&!o.onError&&o.src&&typeof o.src=="string")return!0}return!1}function gv(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function bN(n,o,u,x){if(u.type==="stylesheet"&&(typeof x.media!="string"||matchMedia(x.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var w=fd(x.href),S=o.querySelector(R0(w));if(S){o=S._p,o!==null&&typeof o=="object"&&typeof o.then=="function"&&(n.count++,n=Nm.bind(n),o.then(n,n)),u.state.loading|=4,u.instance=S,Zt(S);return}S=o.ownerDocument||o,x=dv(x),(w=xi.get(w))&&Tf(x,w),S=S.createElement("link"),Zt(S);var q=S;q._p=new Promise(function(ge,Ae){q.onload=ge,q.onerror=Ae}),Hs(S,"link",x),u.instance=S}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(u,o),(o=u.state.preload)&&(u.state.loading&3)===0&&(n.count++,u=Nm.bind(n),o.addEventListener("load",u),o.addEventListener("error",u))}}var Af=0;function vN(n,o){return n.stylesheets&&n.count===0&&Cm(n,n.stylesheets),0<n.count||0<n.imgCount?function(u){var x=setTimeout(function(){if(n.stylesheets&&Cm(n,n.stylesheets),n.unsuspend){var S=n.unsuspend;n.unsuspend=null,S()}},6e4+o);0<n.imgBytes&&Af===0&&(Af=62500*eN());var w=setTimeout(function(){if(n.waitingForImages=!1,n.count===0&&(n.stylesheets&&Cm(n,n.stylesheets),n.unsuspend)){var S=n.unsuspend;n.unsuspend=null,S()}},(n.imgBytes>Af?50:800)+o);return n.unsuspend=u,function(){n.unsuspend=null,clearTimeout(x),clearTimeout(w)}}:null}function Nm(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Cm(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var Sm=null;function Cm(n,o){n.stylesheets=null,n.unsuspend!==null&&(n.count++,Sm=new Map,o.forEach(_N,n),Sm=null,Nm.call(n))}function _N(n,o){if(!(o.state.loading&4)){var u=Sm.get(n);if(u)var x=u.get(null);else{u=new Map,Sm.set(n,u);for(var w=n.querySelectorAll("link[data-precedence],style[data-precedence]"),S=0;S<w.length;S++){var q=w[S];(q.nodeName==="LINK"||q.getAttribute("media")!=="not all")&&(u.set(q.dataset.precedence,q),x=q)}x&&u.set(null,x)}w=o.instance,q=w.getAttribute("data-precedence"),S=u.get(q)||x,S===x&&u.set(null,w),u.set(q,w),this.count++,x=Nm.bind(this),w.addEventListener("load",x),w.addEventListener("error",x),S?S.parentNode.insertBefore(w,S.nextSibling):(n=n.nodeType===9?n.head:n,n.insertBefore(w,n.firstChild)),o.state.loading|=4}}var F0={$$typeof:E,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function wN(n,o,u,x,w,S,q,ge,Ae){this.tag=1,this.containerInfo=n,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=fe(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=fe(0),this.hiddenUpdates=fe(null),this.identifierPrefix=x,this.onUncaughtError=w,this.onCaughtError=S,this.onRecoverableError=q,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Ae,this.incompleteTransitions=new Map}function fv(n,o,u,x,w,S,q,ge,Ae,Ke,vt,Et){return n=new wN(n,o,u,q,Ae,Ke,vt,Et,ge),o=1,S===!0&&(o|=24),S=rn(3,null,null,o),n.current=S,S.stateNode=n,o=lg(),o.refCount++,n.pooledCache=o,o.refCount++,S.memoizedState={element:x,isDehydrated:u,cache:o},mg(S),n}function xv(n){return n?(n=Eo,n):Eo}function pv(n,o,u,x,w,S){w=xv(w),x.context===null?x.context=w:x.pendingContext=w,x=cl(o),x.payload={element:u},S=S===void 0?null:S,S!==null&&(x.callback=S),u=dl(n,x,o),u!==null&&(On(u,n,o),f0(u,n,o))}function yv(n,o){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var u=n.retryLane;n.retryLane=u!==0&&u<o?u:o}}function Of(n,o){yv(n,o),(n=n.alternate)&&yv(n,o)}function bv(n){if(n.tag===13||n.tag===31){var o=mi(n,67108864);o!==null&&On(o,n,67108864),Of(n,67108864)}}function vv(n){if(n.tag===13||n.tag===31){var o=Xn();o=st(o);var u=mi(n,o);u!==null&&On(u,n,o),Of(n,o)}}var Tm=!0;function kN(n,o,u,x){var w=te.T;te.T=null;var S=W.p;try{W.p=2,Df(n,o,u,x)}finally{W.p=S,te.T=w}}function jN(n,o,u,x){var w=te.T;te.T=null;var S=W.p;try{W.p=8,Df(n,o,u,x)}finally{W.p=S,te.T=w}}function Df(n,o,u,x){if(Tm){var w=Mf(x);if(w===null)yf(n,o,x,Em,u),wv(n,x);else if(SN(w,n,o,u,x))x.stopPropagation();else if(wv(n,x),o&4&&-1<NN.indexOf(n)){for(;w!==null;){var S=dt(w);if(S!==null)switch(S.tag){case 3:if(S=S.stateNode,S.current.memoizedState.isDehydrated){var q=Dt(S.pendingLanes);if(q!==0){var ge=S;for(ge.pendingLanes|=2,ge.entangledLanes|=2;q;){var Ae=1<<31-Oe(q);ge.entanglements[1]|=Ae,q&=~Ae}oo(S),(rr&6)===0&&(um=sa()+500,O0(0))}}break;case 31:case 13:ge=mi(S,2),ge!==null&&On(ge,S,2),hm(),Of(S,2)}if(S=Mf(x),S===null&&yf(n,o,x,Em,u),S===w)break;w=S}w!==null&&x.stopPropagation()}else yf(n,o,x,null,u)}}function Mf(n){return n=Sr(n),Lf(n)}var Em=null;function Lf(n){if(Em=null,n=Ft(n),n!==null){var o=c(n);if(o===null)n=null;else{var u=o.tag;if(u===13){if(n=d(o),n!==null)return n;n=null}else if(u===31){if(n=m(o),n!==null)return n;n=null}else if(u===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;n=null}else o!==n&&(n=null)}}return Em=n,null}function _v(n){switch(n){case"beforetoggle":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"toggle":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 2;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"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ra()){case Ye:return 2;case ft:return 8;case $t:case na:return 32;case Ze:return 268435456;default:return 32}default:return 32}}var Rf=!1,_l=null,wl=null,kl=null,I0=new Map,z0=new Map,jl=[],NN="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".split(" ");function wv(n,o){switch(n){case"focusin":case"focusout":_l=null;break;case"dragenter":case"dragleave":wl=null;break;case"mouseover":case"mouseout":kl=null;break;case"pointerover":case"pointerout":I0.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":z0.delete(o.pointerId)}}function B0(n,o,u,x,w,S){return n===null||n.nativeEvent!==S?(n={blockedOn:o,domEventName:u,eventSystemFlags:x,nativeEvent:S,targetContainers:[w]},o!==null&&(o=dt(o),o!==null&&bv(o)),n):(n.eventSystemFlags|=x,o=n.targetContainers,w!==null&&o.indexOf(w)===-1&&o.push(w),n)}function SN(n,o,u,x,w){switch(o){case"focusin":return _l=B0(_l,n,o,u,x,w),!0;case"dragenter":return wl=B0(wl,n,o,u,x,w),!0;case"mouseover":return kl=B0(kl,n,o,u,x,w),!0;case"pointerover":var S=w.pointerId;return I0.set(S,B0(I0.get(S)||null,n,o,u,x,w)),!0;case"gotpointercapture":return S=w.pointerId,z0.set(S,B0(z0.get(S)||null,n,o,u,x,w)),!0}return!1}function kv(n){var o=Ft(n.target);if(o!==null){var u=c(o);if(u!==null){if(o=u.tag,o===13){if(o=d(u),o!==null){n.blockedOn=o,me(n.priority,function(){vv(u)});return}}else if(o===31){if(o=m(u),o!==null){n.blockedOn=o,me(n.priority,function(){vv(u)});return}}else if(o===3&&u.stateNode.current.memoizedState.isDehydrated){n.blockedOn=u.tag===3?u.stateNode.containerInfo:null;return}}}n.blockedOn=null}function Am(n){if(n.blockedOn!==null)return!1;for(var o=n.targetContainers;0<o.length;){var u=Mf(n.nativeEvent);if(u===null){u=n.nativeEvent;var x=new u.constructor(u.type,u);_r=x,u.target.dispatchEvent(x),_r=null}else return o=dt(u),o!==null&&bv(o),n.blockedOn=u,!1;o.shift()}return!0}function jv(n,o,u){Am(n)&&u.delete(o)}function CN(){Rf=!1,_l!==null&&Am(_l)&&(_l=null),wl!==null&&Am(wl)&&(wl=null),kl!==null&&Am(kl)&&(kl=null),I0.forEach(jv),z0.forEach(jv)}function Om(n,o){n.blockedOn===o&&(n.blockedOn=null,Rf||(Rf=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,CN)))}var Dm=null;function Nv(n){Dm!==n&&(Dm=n,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Dm===n&&(Dm=null);for(var o=0;o<n.length;o+=3){var u=n[o],x=n[o+1],w=n[o+2];if(typeof x!="function"){if(Lf(x||u)===null)continue;break}var S=dt(u);S!==null&&(n.splice(o,3),o-=3,Dg(S,{pending:!0,data:w,method:u.method,action:x},x,w))}}))}function pd(n){function o(Ae){return Om(Ae,n)}_l!==null&&Om(_l,n),wl!==null&&Om(wl,n),kl!==null&&Om(kl,n),I0.forEach(o),z0.forEach(o);for(var u=0;u<jl.length;u++){var x=jl[u];x.blockedOn===n&&(x.blockedOn=null)}for(;0<jl.length&&(u=jl[0],u.blockedOn===null);)kv(u),u.blockedOn===null&&jl.shift();if(u=(n.ownerDocument||n).$$reactFormReplay,u!=null)for(x=0;x<u.length;x+=3){var w=u[x],S=u[x+1],q=w[xe]||null;if(typeof S=="function")q||Nv(u);else if(q){var ge=null;if(S&&S.hasAttribute("formAction")){if(w=S,q=S[xe]||null)ge=q.formAction;else if(Lf(w)!==null)continue}else ge=q.action;typeof ge=="function"?u[x+1]=ge:(u.splice(x,3),x-=3),Nv(u)}}}function Sv(){function n(S){S.canIntercept&&S.info==="react-transition"&&S.intercept({handler:function(){return new Promise(function(q){return w=q})},focusReset:"manual",scroll:"manual"})}function o(){w!==null&&(w(),w=null),x||setTimeout(u,20)}function u(){if(!x&&!navigation.transition){var S=navigation.currentEntry;S&&S.url!=null&&navigation.navigate(S.url,{state:S.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var x=!1,w=null;return navigation.addEventListener("navigate",n),navigation.addEventListener("navigatesuccess",o),navigation.addEventListener("navigateerror",o),setTimeout(u,100),function(){x=!0,navigation.removeEventListener("navigate",n),navigation.removeEventListener("navigatesuccess",o),navigation.removeEventListener("navigateerror",o),w!==null&&(w(),w=null)}}}function Pf(n){this._internalRoot=n}Mm.prototype.render=Pf.prototype.render=function(n){var o=this._internalRoot;if(o===null)throw Error(s(409));var u=o.current,x=Xn();pv(u,x,n,o,null,null)},Mm.prototype.unmount=Pf.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var o=n.containerInfo;pv(n.current,2,null,n,null,null),hm(),o[_e]=null}};function Mm(n){this._internalRoot=n}Mm.prototype.unstable_scheduleHydration=function(n){if(n){var o=V();n={blockedOn:null,target:n,priority:o};for(var u=0;u<jl.length&&o!==0&&o<jl[u].priority;u++);jl.splice(u,0,n),u===0&&kv(n)}};var Cv=a.version;if(Cv!=="19.2.1")throw Error(s(527,Cv,"19.2.1"));W.findDOMNode=function(n){var o=n._reactInternals;if(o===void 0)throw typeof n.render=="function"?Error(s(188)):(n=Object.keys(n).join(","),Error(s(268,n)));return n=g(o),n=n!==null?p(n):null,n=n===null?null:n.stateNode,n};var TN={bundleType:0,version:"19.2.1",rendererPackageName:"react-dom",currentDispatcherRef:te,reconcilerVersion:"19.2.1"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"){var Lm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Lm.isDisabled&&Lm.supportsFiber)try{Ie=Lm.inject(TN),Nt=Lm}catch(n){}}return $0.createRoot=function(n,o){if(!i(n))throw Error(s(299));var u=!1,x="",w=Ly,S=Ry,q=Py;return o!=null&&(o.unstable_strictMode===!0&&(u=!0),o.identifierPrefix!==void 0&&(x=o.identifierPrefix),o.onUncaughtError!==void 0&&(w=o.onUncaughtError),o.onCaughtError!==void 0&&(S=o.onCaughtError),o.onRecoverableError!==void 0&&(q=o.onRecoverableError)),o=fv(n,1,!1,null,null,u,x,null,w,S,q,Sv),n[_e]=o.current,pf(n),new Pf(o)},$0.hydrateRoot=function(n,o,u){if(!i(n))throw Error(s(299));var x=!1,w="",S=Ly,q=Ry,ge=Py,Ae=null;return u!=null&&(u.unstable_strictMode===!0&&(x=!0),u.identifierPrefix!==void 0&&(w=u.identifierPrefix),u.onUncaughtError!==void 0&&(S=u.onUncaughtError),u.onCaughtError!==void 0&&(q=u.onCaughtError),u.onRecoverableError!==void 0&&(ge=u.onRecoverableError),u.formState!==void 0&&(Ae=u.formState)),o=fv(n,1,!0,o,u!=null?u:null,x,w,Ae,S,q,ge,Sv),o.context=xv(null),u=o.current,x=Xn(),x=st(x),w=cl(x),w.callback=null,dl(u,w,x),u=x,o.current.lanes=u,re(o,u),oo(o),n[_e]=o.current,pf(n),new Mm(o)},$0.version="19.2.1",$0}var Bv;function $N(){if(Bv)return $f.exports;Bv=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__=="undefined"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(a){console.error(a)}}return t(),$f.exports=UN(),$f.exports}var HN=$N();const ja=t=>typeof t=="string",H0=()=>{let t,a;const r=new Promise((s,i)=>{t=s,a=i});return r.resolve=t,r.reject=a,r},Uv=t=>t==null?"":""+t,WN=(t,a,r)=>{t.forEach(s=>{a[s]&&(r[s]=a[s])})},VN=/###/g,$v=t=>t&&t.indexOf("###")>-1?t.replace(VN,"."):t,Hv=t=>!t||ja(t),eu=(t,a,r)=>{const s=ja(a)?a.split("."):a;let i=0;for(;i<s.length-1;){if(Hv(t))return{};const c=$v(s[i]);!t[c]&&r&&(t[c]=new r),Object.prototype.hasOwnProperty.call(t,c)?t=t[c]:t={},++i}return Hv(t)?{}:{obj:t,k:$v(s[i])}},Wv=(t,a,r)=>{const{obj:s,k:i}=eu(t,a,Object);if(s!==void 0||a.length===1){s[i]=r;return}let c=a[a.length-1],d=a.slice(0,a.length-1),m=eu(t,d,Object);for(;m.obj===void 0&&d.length;)c=`${d[d.length-1]}.${c}`,d=d.slice(0,d.length-1),m=eu(t,d,Object),m!=null&&m.obj&&typeof m.obj[`${m.k}.${c}`]!="undefined"&&(m.obj=void 0);m.obj[`${m.k}.${c}`]=r},qN=(t,a,r,s)=>{const{obj:i,k:c}=eu(t,a,Object);i[c]=i[c]||[],i[c].push(r)},sh=(t,a)=>{const{obj:r,k:s}=eu(t,a);if(r&&Object.prototype.hasOwnProperty.call(r,s))return r[s]},GN=(t,a,r)=>{const s=sh(t,r);return s!==void 0?s:sh(a,r)},W_=(t,a,r)=>{for(const s in a)s!=="__proto__"&&s!=="constructor"&&(s in t?ja(t[s])||t[s]instanceof String||ja(a[s])||a[s]instanceof String?r&&(t[s]=a[s]):W_(t[s],a[s],r):t[s]=a[s]);return t},bd=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var YN={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const ZN=t=>ja(t)?t.replace(/[&<>"'\/]/g,a=>YN[a]):t;class JN{constructor(a){this.capacity=a,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(a){const r=this.regExpMap.get(a);if(r!==void 0)return r;const s=new RegExp(a);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(a,s),this.regExpQueue.push(a),s}}const XN=[" ",",","?","!",";"],KN=new JN(20),QN=(t,a,r)=>{a=a||"",r=r||"";const s=XN.filter(d=>a.indexOf(d)<0&&r.indexOf(d)<0);if(s.length===0)return!0;const i=KN.getRegExp(`(${s.map(d=>d==="?"?"\\?":d).join("|")})`);let c=!i.test(t);if(!c){const d=t.indexOf(r);d>0&&!i.test(t.substring(0,d))&&(c=!0)}return c},yx=(t,a,r=".")=>{if(!t)return;if(t[a])return Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0;const s=a.split(r);let i=t;for(let c=0;c<s.length;){if(!i||typeof i!="object")return;let d,m="";for(let h=c;h<s.length;++h)if(h!==c&&(m+=r),m+=s[h],d=i[m],d!==void 0){if(["string","number","boolean"].indexOf(typeof d)>-1&&h<s.length-1)continue;c+=h-c+1;break}i=d}return i},uu=t=>t==null?void 0:t.replace("_","-"),e4={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,a){var r,s;(s=(r=console==null?void 0:console[t])==null?void 0:r.apply)==null||s.call(r,console,a)}};class nh{constructor(a,r={}){this.init(a,r)}init(a,r={}){this.prefix=r.prefix||"i18next:",this.logger=a||e4,this.options=r,this.debug=r.debug}log(...a){return this.forward(a,"log","",!0)}warn(...a){return this.forward(a,"warn","",!0)}error(...a){return this.forward(a,"error","")}deprecate(...a){return this.forward(a,"warn","WARNING DEPRECATED: ",!0)}forward(a,r,s,i){return i&&!this.debug?null:(ja(a[0])&&(a[0]=`${s}${this.prefix} ${a[0]}`),this.logger[r](a))}create(a){return new nh(this.logger,ue({prefix:`${this.prefix}:${a}:`},this.options))}clone(a){return a=a||this.options,a.prefix=a.prefix||this.prefix,new nh(this.logger,a)}}var ho=new nh;class Dh{constructor(){this.observers={}}on(a,r){return a.split(" ").forEach(s=>{this.observers[s]||(this.observers[s]=new Map);const i=this.observers[s].get(r)||0;this.observers[s].set(r,i+1)}),this}off(a,r){if(this.observers[a]){if(!r){delete this.observers[a];return}this.observers[a].delete(r)}}emit(a,...r){this.observers[a]&&Array.from(this.observers[a].entries()).forEach(([i,c])=>{for(let d=0;d<c;d++)i(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,c])=>{for(let d=0;d<c;d++)i.apply(i,[a,...r])})}}class Vv extends Dh{constructor(a,r={ns:["translation"],defaultNS:"translation"}){super(),this.data=a||{},this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(a){this.options.ns.indexOf(a)<0&&this.options.ns.push(a)}removeNamespaces(a){const r=this.options.ns.indexOf(a);r>-1&&this.options.ns.splice(r,1)}getResource(a,r,s,i={}){var g,p;const c=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,d=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let m;a.indexOf(".")>-1?m=a.split("."):(m=[a,r],s&&(Array.isArray(s)?m.push(...s):ja(s)&&c?m.push(...s.split(c)):m.push(s)));const h=sh(this.data,m);return!h&&!r&&!s&&a.indexOf(".")>-1&&(a=m[0],r=m[1],s=m.slice(2).join(".")),h||!d||!ja(s)?h:yx((p=(g=this.data)==null?void 0:g[a])==null?void 0:p[r],s,c)}addResource(a,r,s,i,c={silent:!1}){const d=c.keySeparator!==void 0?c.keySeparator:this.options.keySeparator;let m=[a,r];s&&(m=m.concat(d?s.split(d):s)),a.indexOf(".")>-1&&(m=a.split("."),i=r,r=m[1]),this.addNamespaces(r),Wv(this.data,m,i),c.silent||this.emit("added",a,r,s,i)}addResources(a,r,s,i={silent:!1}){for(const c in s)(ja(s[c])||Array.isArray(s[c]))&&this.addResource(a,r,c,s[c],{silent:!0});i.silent||this.emit("added",a,r,s)}addResourceBundle(a,r,s,i,c,d={silent:!1,skipCopy:!1}){let m=[a,r];a.indexOf(".")>-1&&(m=a.split("."),i=s,s=r,r=m[1]),this.addNamespaces(r);let h=sh(this.data,m)||{};d.skipCopy||(s=JSON.parse(JSON.stringify(s))),i?W_(h,s,c):h=ue(ue({},h),s),Wv(this.data,m,h),d.silent||this.emit("added",a,r,s)}removeResourceBundle(a,r){this.hasResourceBundle(a,r)&&delete this.data[a][r],this.removeNamespaces(r),this.emit("removed",a,r)}hasResourceBundle(a,r){return this.getResource(a,r)!==void 0}getResourceBundle(a,r){return r||(r=this.options.defaultNS),this.getResource(a,r)}getDataByLanguage(a){return this.data[a]}hasLanguageSomeTranslations(a){const r=this.getDataByLanguage(a);return!!(r&&Object.keys(r)||[]).find(i=>r[i]&&Object.keys(r[i]).length>0)}toJSON(){return this.data}}var V_={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,a,r,s,i){return t.forEach(c=>{var d,m;a=(m=(d=this.processors[c])==null?void 0:d.process(a,r,s,i))!=null?m:a}),a}};const q_=Symbol("i18next/PATH_KEY");function t4(){const t=[],a=Object.create(null);let r;return a.get=(s,i)=>{var c;return(c=r==null?void 0:r.revoke)==null||c.call(r),i===q_?t:(t.push(i),r=Proxy.revocable(s,a),r.proxy)},Proxy.revocable(Object.create(null),a).proxy}function bx(t,a){var s;const{[q_]:r}=t(t4());return r.join((s=a==null?void 0:a.keySeparator)!=null?s:".")}const qv={},qf=t=>!ja(t)&&typeof t!="boolean"&&typeof t!="number";class ih extends Dh{constructor(a,r={}){super(),WN(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],a,this),this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=ho.create("translator")}changeLanguage(a){a&&(this.language=a)}exists(a,r={interpolation:{}}){const s=ue({},r);if(a==null)return!1;const i=this.resolve(a,s);if((i==null?void 0:i.res)===void 0)return!1;const c=qf(i.res);return!(s.returnObjects===!1&&c)}extractFromKey(a,r){let s=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");const i=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator;let c=r.ns||this.options.defaultNS||[];const d=s&&a.indexOf(s)>-1,m=!this.options.userDefinedKeySeparator&&!r.keySeparator&&!this.options.userDefinedNsSeparator&&!r.nsSeparator&&!QN(a,s,i);if(d&&!m){const h=a.match(this.interpolator.nestingRegexp);if(h&&h.length>0)return{key:a,namespaces:ja(c)?[c]:c};const g=a.split(s);(s!==i||s===i&&this.options.ns.indexOf(g[0])>-1)&&(c=g.shift()),a=g.join(i)}return{key:a,namespaces:ja(c)?[c]:c}}translate(a,r,s){let i=typeof r=="object"?ue({},r):r;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i=ue({},i)),i||(i={}),a==null)return"";typeof a=="function"&&(a=bx(a,ue(ue({},this.options),i))),Array.isArray(a)||(a=[String(a)]);const c=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,d=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:m,namespaces:h}=this.extractFromKey(a[a.length-1],i),g=h[h.length-1];let p=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;p===void 0&&(p=":");const b=i.lng||this.language,j=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((b==null?void 0:b.toLowerCase())==="cimode")return j?c?{res:`${g}${p}${m}`,usedKey:m,exactUsedKey:m,usedLng:b,usedNS:g,usedParams:this.getUsedParamsDetails(i)}:`${g}${p}${m}`:c?{res:m,usedKey:m,exactUsedKey:m,usedLng:b,usedNS:g,usedParams:this.getUsedParamsDetails(i)}:m;const _=this.resolve(a,i);let N=_==null?void 0:_.res;const k=(_==null?void 0:_.usedKey)||m,C=(_==null?void 0:_.exactUsedKey)||m,D=["[object Number]","[object Function]","[object RegExp]"],T=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,E=!this.i18nFormat||this.i18nFormat.handleAsObject,O=i.count!==void 0&&!ja(i.count),R=ih.hasDefaultValue(i),Y=O?this.pluralResolver.getSuffix(b,i.count,i):"",P=i.ordinal&&O?this.pluralResolver.getSuffix(b,i.count,{ordinal:!1}):"",U=O&&!i.ordinal&&i.count===0,J=U&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${Y}`]||i[`defaultValue${P}`]||i.defaultValue;let ne=N;E&&!N&&R&&(ne=J);const ye=qf(ne),he=Object.prototype.toString.apply(ne);if(E&&ne&&ye&&D.indexOf(he)<0&&!(ja(T)&&Array.isArray(ne))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const ce=this.options.returnedObjectHandler?this.options.returnedObjectHandler(k,ne,Se(ue({},i),{ns:h})):`key '${m} (${this.language})' returned an object instead of string.`;return c?(_.res=ce,_.usedParams=this.getUsedParamsDetails(i),_):ce}if(d){const ce=Array.isArray(ne),se=ce?[]:{},ee=ce?C:k;for(const te in ne)if(Object.prototype.hasOwnProperty.call(ne,te)){const W=`${ee}${d}${te}`;R&&!N?se[te]=this.translate(W,Se(ue({},i),{defaultValue:qf(J)?J[te]:void 0,joinArrays:!1,ns:h})):se[te]=this.translate(W,Se(ue({},i),{joinArrays:!1,ns:h})),se[te]===W&&(se[te]=ne[te])}N=se}}else if(E&&ja(T)&&Array.isArray(N))N=N.join(T),N&&(N=this.extendTranslation(N,a,i,s));else{let ce=!1,se=!1;!this.isValidLookup(N)&&R&&(ce=!0,N=J),this.isValidLookup(N)||(se=!0,N=m);const te=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&se?void 0:N,W=R&&J!==N&&this.options.updateMissing;if(se||ce||W){if(this.logger.log(W?"updateKey":"missingKey",b,g,m,W?J:N),d){const F=this.resolve(m,Se(ue({},i),{keySeparator:!1}));F&&F.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let I=[];const oe=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&oe&&oe[0])for(let F=0;F<oe.length;F++)I.push(oe[F]);else this.options.saveMissingTo==="all"?I=this.languageUtils.toResolveHierarchy(i.lng||this.language):I.push(i.lng||this.language);const ae=(F,M,B)=>{var K;const X=R&&B!==N?B:te;this.options.missingKeyHandler?this.options.missingKeyHandler(F,g,M,X,W,i):(K=this.backendConnector)!=null&&K.saveMissing&&this.backendConnector.saveMissing(F,g,M,X,W,i),this.emit("missingKey",F,g,M,N)};this.options.saveMissing&&(this.options.saveMissingPlurals&&O?I.forEach(F=>{const M=this.pluralResolver.getSuffixes(F,i);U&&i[`defaultValue${this.options.pluralSeparator}zero`]&&M.indexOf(`${this.options.pluralSeparator}zero`)<0&&M.push(`${this.options.pluralSeparator}zero`),M.forEach(B=>{ae([F],m+B,i[`defaultValue${B}`]||J)})}):ae(I,m,J))}N=this.extendTranslation(N,a,i,_,s),se&&N===m&&this.options.appendNamespaceToMissingKey&&(N=`${g}${p}${m}`),(se||ce)&&this.options.parseMissingKeyHandler&&(N=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${g}${p}${m}`:m,ce?N:void 0,i))}return c?(_.res=N,_.usedParams=this.getUsedParamsDetails(i),_):N}extendTranslation(a,r,s,i,c){var h,g;if((h=this.i18nFormat)!=null&&h.parse)a=this.i18nFormat.parse(a,ue(ue({},this.options.interpolation.defaultVariables),s),s.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init(Se(ue({},s),{interpolation:ue(ue({},this.options.interpolation),s.interpolation)}));const p=ja(a)&&(((g=s==null?void 0:s.interpolation)==null?void 0:g.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let b;if(p){const _=a.match(this.interpolator.nestingRegexp);b=_&&_.length}let j=s.replace&&!ja(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(j=ue(ue({},this.options.interpolation.defaultVariables),j)),a=this.interpolator.interpolate(a,j,s.lng||this.language||i.usedLng,s),p){const _=a.match(this.interpolator.nestingRegexp),N=_&&_.length;b<N&&(s.nest=!1)}!s.lng&&i&&i.res&&(s.lng=this.language||i.usedLng),s.nest!==!1&&(a=this.interpolator.nest(a,(..._)=>(c==null?void 0:c[0])===_[0]&&!s.context?(this.logger.warn(`It seems you are nesting recursively key: ${_[0]} in key: ${r[0]}`),null):this.translate(..._,r),s)),s.interpolation&&this.interpolator.reset()}const d=s.postProcess||this.options.postProcess,m=ja(d)?[d]:d;return a!=null&&(m!=null&&m.length)&&s.applyPostProcessor!==!1&&(a=V_.handle(m,a,r,this.options&&this.options.postProcessPassResolved?ue({i18nResolved:Se(ue({},i),{usedParams:this.getUsedParamsDetails(s)})},s):s,this)),a}resolve(a,r={}){let s,i,c,d,m;return ja(a)&&(a=[a]),a.forEach(h=>{if(this.isValidLookup(s))return;const g=this.extractFromKey(h,r),p=g.key;i=p;let b=g.namespaces;this.options.fallbackNS&&(b=b.concat(this.options.fallbackNS));const j=r.count!==void 0&&!ja(r.count),_=j&&!r.ordinal&&r.count===0,N=r.context!==void 0&&(ja(r.context)||typeof r.context=="number")&&r.context!=="",k=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);b.forEach(C=>{var D,T;this.isValidLookup(s)||(m=C,!qv[`${k[0]}-${C}`]&&((D=this.utils)!=null&&D.hasLoadedNamespace)&&!((T=this.utils)!=null&&T.hasLoadedNamespace(m))&&(qv[`${k[0]}-${C}`]=!0,this.logger.warn(`key "${i}" for languages "${k.join(", ")}" won't get resolved as namespace "${m}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),k.forEach(E=>{var Y;if(this.isValidLookup(s))return;d=E;const O=[p];if((Y=this.i18nFormat)!=null&&Y.addLookupKeys)this.i18nFormat.addLookupKeys(O,p,E,C,r);else{let P;j&&(P=this.pluralResolver.getSuffix(E,r.count,r));const U=`${this.options.pluralSeparator}zero`,J=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(j&&(r.ordinal&&P.indexOf(J)===0&&O.push(p+P.replace(J,this.options.pluralSeparator)),O.push(p+P),_&&O.push(p+U)),N){const ne=`${p}${this.options.contextSeparator||"_"}${r.context}`;O.push(ne),j&&(r.ordinal&&P.indexOf(J)===0&&O.push(ne+P.replace(J,this.options.pluralSeparator)),O.push(ne+P),_&&O.push(ne+U))}}let R;for(;R=O.pop();)this.isValidLookup(s)||(c=R,s=this.getResource(E,C,R,r))}))})}),{res:s,usedKey:i,exactUsedKey:c,usedLng:d,usedNS:m}}isValidLookup(a){return a!==void 0&&!(!this.options.returnNull&&a===null)&&!(!this.options.returnEmptyString&&a==="")}getResource(a,r,s,i={}){var c;return(c=this.i18nFormat)!=null&&c.getResource?this.i18nFormat.getResource(a,r,s,i):this.resourceStore.getResource(a,r,s,i)}getUsedParamsDetails(a={}){const r=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=a.replace&&!ja(a.replace);let i=s?a.replace:a;if(s&&typeof a.count!="undefined"&&(i.count=a.count),this.options.interpolation.defaultVariables&&(i=ue(ue({},this.options.interpolation.defaultVariables),i)),!s){i=ue({},i);for(const c of r)delete i[c]}return i}static hasDefaultValue(a){const r="defaultValue";for(const s in a)if(Object.prototype.hasOwnProperty.call(a,s)&&r===s.substring(0,r.length)&&a[s]!==void 0)return!0;return!1}}class Gv{constructor(a){this.options=a,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ho.create("languageUtils")}getScriptPartFromCode(a){if(a=uu(a),!a||a.indexOf("-")<0)return null;const r=a.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}getLanguagePartFromCode(a){if(a=uu(a),!a||a.indexOf("-")<0)return a;const r=a.split("-");return this.formatLanguageCode(r[0])}formatLanguageCode(a){if(ja(a)&&a.indexOf("-")>-1){let r;try{r=Intl.getCanonicalLocales(a)[0]}catch(s){}return r&&this.options.lowerCaseLng&&(r=r.toLowerCase()),r||(this.options.lowerCaseLng?a.toLowerCase():a)}return this.options.cleanCode||this.options.lowerCaseLng?a.toLowerCase():a}isSupportedCode(a){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(a=this.getLanguagePartFromCode(a)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(a)>-1}getBestMatchFromCodes(a){if(!a)return null;let r;return a.forEach(s=>{if(r)return;const i=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(i))&&(r=i)}),!r&&this.options.supportedLngs&&a.forEach(s=>{if(r)return;const i=this.getScriptPartFromCode(s);if(this.isSupportedCode(i))return r=i;const c=this.getLanguagePartFromCode(s);if(this.isSupportedCode(c))return r=c;r=this.options.supportedLngs.find(d=>{if(d===c)return d;if(!(d.indexOf("-")<0&&c.indexOf("-")<0)&&(d.indexOf("-")>0&&c.indexOf("-")<0&&d.substring(0,d.indexOf("-"))===c||d.indexOf(c)===0&&c.length>1))return d})}),r||(r=this.getFallbackCodes(this.options.fallbackLng)[0]),r}getFallbackCodes(a,r){if(!a)return[];if(typeof a=="function"&&(a=a(r)),ja(a)&&(a=[a]),Array.isArray(a))return a;if(!r)return a.default||[];let s=a[r];return s||(s=a[this.getScriptPartFromCode(r)]),s||(s=a[this.formatLanguageCode(r)]),s||(s=a[this.getLanguagePartFromCode(r)]),s||(s=a.default),s||[]}toResolveHierarchy(a,r){const s=this.getFallbackCodes((r===!1?[]:r)||this.options.fallbackLng||[],a),i=[],c=d=>{d&&(this.isSupportedCode(d)?i.push(d):this.logger.warn(`rejecting language code not found in supportedLngs: ${d}`))};return ja(a)&&(a.indexOf("-")>-1||a.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&c(this.formatLanguageCode(a)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&c(this.getScriptPartFromCode(a)),this.options.load!=="currentOnly"&&c(this.getLanguagePartFromCode(a))):ja(a)&&c(this.formatLanguageCode(a)),s.forEach(d=>{i.indexOf(d)<0&&c(this.formatLanguageCode(d))}),i}}const Yv={zero:0,one:1,two:2,few:3,many:4,other:5},Zv={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class a4{constructor(a,r={}){this.languageUtils=a,this.options=r,this.logger=ho.create("pluralResolver"),this.pluralRulesCache={}}addRule(a,r){this.rules[a]=r}clearCache(){this.pluralRulesCache={}}getRule(a,r={}){const s=uu(a==="dev"?"en":a),i=r.ordinal?"ordinal":"cardinal",c=JSON.stringify({cleanedCode:s,type:i});if(c in this.pluralRulesCache)return this.pluralRulesCache[c];let d;try{d=new Intl.PluralRules(s,{type:i})}catch(m){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),Zv;if(!a.match(/-|_/))return Zv;const h=this.languageUtils.getLanguagePartFromCode(a);d=this.getRule(h,r)}return this.pluralRulesCache[c]=d,d}needsPlural(a,r={}){let s=this.getRule(a,r);return s||(s=this.getRule("dev",r)),(s==null?void 0:s.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(a,r,s={}){return this.getSuffixes(a,s).map(i=>`${r}${i}`)}getSuffixes(a,r={}){let s=this.getRule(a,r);return s||(s=this.getRule("dev",r)),s?s.resolvedOptions().pluralCategories.sort((i,c)=>Yv[i]-Yv[c]).map(i=>`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(a,r,s={}){const i=this.getRule(a,s);return i?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(r)}`:(this.logger.warn(`no plural rule found for: ${a}`),this.getSuffix("dev",r,s))}}const Jv=(t,a,r,s=".",i=!0)=>{let c=GN(t,a,r);return!c&&i&&ja(r)&&(c=yx(t,r,s),c===void 0&&(c=yx(a,r,s))),c},Gf=t=>t.replace(/\$/g,"$$$$");class Xv{constructor(a={}){var r;this.logger=ho.create("interpolator"),this.options=a,this.format=((r=a==null?void 0:a.interpolation)==null?void 0:r.format)||(s=>s),this.init(a)}init(a={}){a.interpolation||(a.interpolation={escapeValue:!0});const{escape:r,escapeValue:s,useRawValueToEscape:i,prefix:c,prefixEscaped:d,suffix:m,suffixEscaped:h,formatSeparator:g,unescapeSuffix:p,unescapePrefix:b,nestingPrefix:j,nestingPrefixEscaped:_,nestingSuffix:N,nestingSuffixEscaped:k,nestingOptionsSeparator:C,maxReplaces:D,alwaysFormat:T}=a.interpolation;this.escape=r!==void 0?r:ZN,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=c?bd(c):d||"{{",this.suffix=m?bd(m):h||"}}",this.formatSeparator=g||",",this.unescapePrefix=p?"":b||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=j?bd(j):_||bd("$t("),this.nestingSuffix=N?bd(N):k||bd(")"),this.nestingOptionsSeparator=C||",",this.maxReplaces=D||1e3,this.alwaysFormat=T!==void 0?T:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const a=(r,s)=>(r==null?void 0:r.source)===s?(r.lastIndex=0,r):new RegExp(s,"g");this.regexp=a(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=a(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=a(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(a,r,s,i){var _;let c,d,m;const h=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},g=N=>{if(N.indexOf(this.formatSeparator)<0){const T=Jv(r,h,N,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(T,void 0,s,Se(ue(ue({},i),r),{interpolationkey:N})):T}const k=N.split(this.formatSeparator),C=k.shift().trim(),D=k.join(this.formatSeparator).trim();return this.format(Jv(r,h,C,this.options.keySeparator,this.options.ignoreJSONStructure),D,s,Se(ue(ue({},i),r),{interpolationkey:C}))};this.resetRegExp();const p=(i==null?void 0:i.missingInterpolationHandler)||this.options.missingInterpolationHandler,b=((_=i==null?void 0:i.interpolation)==null?void 0:_.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:N=>Gf(N)},{regex:this.regexp,safeValue:N=>this.escapeValue?Gf(this.escape(N)):Gf(N)}].forEach(N=>{for(m=0;c=N.regex.exec(a);){const k=c[1].trim();if(d=g(k),d===void 0)if(typeof p=="function"){const D=p(a,c,i);d=ja(D)?D:""}else if(i&&Object.prototype.hasOwnProperty.call(i,k))d="";else if(b){d=c[0];continue}else this.logger.warn(`missed to pass in variable ${k} for interpolating ${a}`),d="";else!ja(d)&&!this.useRawValueToEscape&&(d=Uv(d));const C=N.safeValue(d);if(a=a.replace(c[0],C),b?(N.regex.lastIndex+=d.length,N.regex.lastIndex-=c[0].length):N.regex.lastIndex=0,m++,m>=this.maxReplaces)break}}),a}nest(a,r,s={}){let i,c,d;const m=(h,g)=>{var k;const p=this.nestingOptionsSeparator;if(h.indexOf(p)<0)return h;const b=h.split(new RegExp(`${p}[ ]*{`));let j=`{${b[1]}`;h=b[0],j=this.interpolate(j,d);const _=j.match(/'/g),N=j.match(/"/g);(((k=_==null?void 0:_.length)!=null?k:0)%2===0&&!N||N.length%2!==0)&&(j=j.replace(/'/g,'"'));try{d=JSON.parse(j),g&&(d=ue(ue({},g),d))}catch(C){return this.logger.warn(`failed parsing options string in nesting for key ${h}`,C),`${h}${p}${j}`}return d.defaultValue&&d.defaultValue.indexOf(this.prefix)>-1&&delete d.defaultValue,h};for(;i=this.nestingRegexp.exec(a);){let h=[];d=ue({},s),d=d.replace&&!ja(d.replace)?d.replace:d,d.applyPostProcessor=!1,delete d.defaultValue;const g=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(g!==-1&&(h=i[1].slice(g).split(this.formatSeparator).map(p=>p.trim()).filter(Boolean),i[1]=i[1].slice(0,g)),c=r(m.call(this,i[1].trim(),d),d),c&&i[0]===a&&!ja(c))return c;ja(c)||(c=Uv(c)),c||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${a}`),c=""),h.length&&(c=h.reduce((p,b)=>this.format(p,b,s.lng,Se(ue({},s),{interpolationkey:i[1].trim()})),c.trim())),a=a.replace(i[0],c),this.regexp.lastIndex=0}return a}}const r4=t=>{let a=t.toLowerCase().trim();const r={};if(t.indexOf("(")>-1){const s=t.split("(");a=s[0].toLowerCase().trim();const i=s[1].substring(0,s[1].length-1);a==="currency"&&i.indexOf(":")<0?r.currency||(r.currency=i.trim()):a==="relativetime"&&i.indexOf(":")<0?r.range||(r.range=i.trim()):i.split(";").forEach(d=>{if(d){const[m,...h]=d.split(":"),g=h.join(":").trim().replace(/^'+|'+$/g,""),p=m.trim();r[p]||(r[p]=g),g==="false"&&(r[p]=!1),g==="true"&&(r[p]=!0),isNaN(g)||(r[p]=parseInt(g,10))}})}return{formatName:a,formatOptions:r}},Kv=t=>{const a={};return(r,s,i)=>{let c=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(c=Se(ue({},c),{[i.interpolationkey]:void 0}));const d=s+JSON.stringify(c);let m=a[d];return m||(m=t(uu(s),i),a[d]=m),m(r)}},s4=t=>(a,r,s)=>t(uu(r),s)(a);class n4{constructor(a={}){this.logger=ho.create("formatter"),this.options=a,this.init(a)}init(a,r={interpolation:{}}){this.formatSeparator=r.interpolation.formatSeparator||",";const s=r.cacheInBuiltFormats?Kv:s4;this.formats={number:s((i,c)=>{const d=new Intl.NumberFormat(i,ue({},c));return m=>d.format(m)}),currency:s((i,c)=>{const d=new Intl.NumberFormat(i,Se(ue({},c),{style:"currency"}));return m=>d.format(m)}),datetime:s((i,c)=>{const d=new Intl.DateTimeFormat(i,ue({},c));return m=>d.format(m)}),relativetime:s((i,c)=>{const d=new Intl.RelativeTimeFormat(i,ue({},c));return m=>d.format(m,c.range||"day")}),list:s((i,c)=>{const d=new Intl.ListFormat(i,ue({},c));return m=>d.format(m)})}}add(a,r){this.formats[a.toLowerCase().trim()]=r}addCached(a,r){this.formats[a.toLowerCase().trim()]=Kv(r)}format(a,r,s,i={}){const c=r.split(this.formatSeparator);if(c.length>1&&c[0].indexOf("(")>1&&c[0].indexOf(")")<0&&c.find(m=>m.indexOf(")")>-1)){const m=c.findIndex(h=>h.indexOf(")")>-1);c[0]=[c[0],...c.splice(1,m)].join(this.formatSeparator)}return c.reduce((m,h)=>{var b;const{formatName:g,formatOptions:p}=r4(h);if(this.formats[g]){let j=m;try{const _=((b=i==null?void 0:i.formatParams)==null?void 0:b[i.interpolationkey])||{},N=_.locale||_.lng||i.locale||i.lng||s;j=this.formats[g](m,N,ue(ue(ue({},p),i),_))}catch(_){this.logger.warn(_)}return j}else this.logger.warn(`there was no format function for ${g}`);return m},a)}}const i4=(t,a)=>{t.pending[a]!==void 0&&(delete t.pending[a],t.pendingCount--)};class o4 extends Dh{constructor(a,r,s,i={}){var c,d;super(),this.backend=a,this.store=r,this.services=s,this.languageUtils=s.languageUtils,this.options=i,this.logger=ho.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],(d=(c=this.backend)==null?void 0:c.init)==null||d.call(c,s,i.backend,i)}queueLoad(a,r,s,i){const c={},d={},m={},h={};return a.forEach(g=>{let p=!0;r.forEach(b=>{const j=`${g}|${b}`;!s.reload&&this.store.hasResourceBundle(g,b)?this.state[j]=2:this.state[j]<0||(this.state[j]===1?d[j]===void 0&&(d[j]=!0):(this.state[j]=1,p=!1,d[j]===void 0&&(d[j]=!0),c[j]===void 0&&(c[j]=!0),h[b]===void 0&&(h[b]=!0)))}),p||(m[g]=!0)}),(Object.keys(c).length||Object.keys(d).length)&&this.queue.push({pending:d,pendingCount:Object.keys(d).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(c),pending:Object.keys(d),toLoadLanguages:Object.keys(m),toLoadNamespaces:Object.keys(h)}}loaded(a,r,s){const i=a.split("|"),c=i[0],d=i[1];r&&this.emit("failedLoading",c,d,r),!r&&s&&this.store.addResourceBundle(c,d,s,void 0,void 0,{skipCopy:!0}),this.state[a]=r?-1:2,r&&s&&(this.state[a]=0);const m={};this.queue.forEach(h=>{qN(h.loaded,[c],d),i4(h,a),r&&h.errors.push(r),h.pendingCount===0&&!h.done&&(Object.keys(h.loaded).forEach(g=>{m[g]||(m[g]={});const p=h.loaded[g];p.length&&p.forEach(b=>{m[g][b]===void 0&&(m[g][b]=!0)})}),h.done=!0,h.errors.length?h.callback(h.errors):h.callback())}),this.emit("loaded",m),this.queue=this.queue.filter(h=>!h.done)}read(a,r,s,i=0,c=this.retryTimeout,d){if(!a.length)return d(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:a,ns:r,fcName:s,tried:i,wait:c,callback:d});return}this.readingCalls++;const m=(g,p)=>{if(this.readingCalls--,this.waitingReads.length>0){const b=this.waitingReads.shift();this.read(b.lng,b.ns,b.fcName,b.tried,b.wait,b.callback)}if(g&&p&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,a,r,s,i+1,c*2,d)},c);return}d(g,p)},h=this.backend[s].bind(this.backend);if(h.length===2){try{const g=h(a,r);g&&typeof g.then=="function"?g.then(p=>m(null,p)).catch(m):m(null,g)}catch(g){m(g)}return}return h(a,r,m)}prepareLoading(a,r,s={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();ja(a)&&(a=this.languageUtils.toResolveHierarchy(a)),ja(r)&&(r=[r]);const c=this.queueLoad(a,r,s,i);if(!c.toLoad.length)return c.pending.length||i(),null;c.toLoad.forEach(d=>{this.loadOne(d)})}load(a,r,s){this.prepareLoading(a,r,{},s)}reload(a,r,s){this.prepareLoading(a,r,{reload:!0},s)}loadOne(a,r=""){const s=a.split("|"),i=s[0],c=s[1];this.read(i,c,"read",void 0,void 0,(d,m)=>{d&&this.logger.warn(`${r}loading namespace ${c} for language ${i} failed`,d),!d&&m&&this.logger.log(`${r}loaded namespace ${c} for language ${i}`,m),this.loaded(a,d,m)})}saveMissing(a,r,s,i,c,d={},m=()=>{}){var h,g,p,b,j;if((g=(h=this.services)==null?void 0:h.utils)!=null&&g.hasLoadedNamespace&&!((b=(p=this.services)==null?void 0:p.utils)!=null&&b.hasLoadedNamespace(r))){this.logger.warn(`did not save key "${s}" as the namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(s==null||s==="")){if((j=this.backend)!=null&&j.create){const _=Se(ue({},d),{isUpdate:c}),N=this.backend.create.bind(this.backend);if(N.length<6)try{let k;N.length===5?k=N(a,r,s,i,_):k=N(a,r,s,i),k&&typeof k.then=="function"?k.then(C=>m(null,C)).catch(m):m(null,k)}catch(k){m(k)}else N(a,r,s,i,m,_)}!a||!a[0]||this.store.addResource(a[0],r,s,i)}}}const Qv=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let a={};if(typeof t[1]=="object"&&(a=t[1]),ja(t[1])&&(a.defaultValue=t[1]),ja(t[2])&&(a.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const r=t[3]||t[2];Object.keys(r).forEach(s=>{a[s]=r[s]})}return a},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),e1=t=>{var a,r;return ja(t.ns)&&(t.ns=[t.ns]),ja(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),ja(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),((r=(a=t.supportedLngs)==null?void 0:a.indexOf)==null?void 0:r.call(a,"cimode"))<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t},Pm=()=>{},l4=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(r=>{typeof t[r]=="function"&&(t[r]=t[r].bind(t))})};class tu extends Dh{constructor(a={},r){if(super(),this.options=e1(a),this.services={},this.logger=ho,this.modules={external:[]},l4(this),r&&!this.isInitialized&&!a.isClone){if(!this.options.initAsync)return this.init(a,r),this;setTimeout(()=>{this.init(a,r)},0)}}init(a={},r){this.isInitializing=!0,typeof a=="function"&&(r=a,a={}),a.defaultNS==null&&a.ns&&(ja(a.ns)?a.defaultNS=a.ns:a.ns.indexOf("translation")<0&&(a.defaultNS=a.ns[0]));const s=Qv();this.options=ue(ue(ue({},s),this.options),e1(a)),this.options.interpolation=ue(ue({},s.interpolation),this.options.interpolation),a.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=a.keySeparator),a.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=a.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=s.overloadTranslationOptionHandler);const i=g=>g?typeof g=="function"?new g:g:null;if(!this.options.isClone){this.modules.logger?ho.init(i(this.modules.logger),this.options):ho.init(null,this.options);let g;this.modules.formatter?g=this.modules.formatter:g=n4;const p=new Gv(this.options);this.store=new Vv(this.options.resources,this.options);const b=this.services;b.logger=ho,b.resourceStore=this.store,b.languageUtils=p,b.pluralResolver=new a4(p,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==s.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),g&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(b.formatter=i(g),b.formatter.init&&b.formatter.init(b,this.options),this.options.interpolation.format=b.formatter.format.bind(b.formatter)),b.interpolator=new Xv(this.options),b.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},b.backendConnector=new o4(i(this.modules.backend),b.resourceStore,b,this.options),b.backendConnector.on("*",(_,...N)=>{this.emit(_,...N)}),this.modules.languageDetector&&(b.languageDetector=i(this.modules.languageDetector),b.languageDetector.init&&b.languageDetector.init(b,this.options.detection,this.options)),this.modules.i18nFormat&&(b.i18nFormat=i(this.modules.i18nFormat),b.i18nFormat.init&&b.i18nFormat.init(this)),this.translator=new ih(this.services,this.options),this.translator.on("*",(_,...N)=>{this.emit(_,...N)}),this.modules.external.forEach(_=>{_.init&&_.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Pm),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const g=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);g.length>0&&g[0]!=="dev"&&(this.options.lng=g[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(g=>{this[g]=(...p)=>this.store[g](...p)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(g=>{this[g]=(...p)=>(this.store[g](...p),this)});const m=H0(),h=()=>{const g=(p,b)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),m.resolve(b),r(p,b)};if(this.languages&&!this.isInitialized)return g(null,this.t.bind(this));this.changeLanguage(this.options.lng,g)};return this.options.resources||!this.options.initAsync?h():setTimeout(h,0),m}loadResources(a,r=Pm){var c,d;let s=r;const i=ja(a)?a:this.language;if(typeof a=="function"&&(s=a),!this.options.resources||this.options.partialBundledLanguages){if((i==null?void 0:i.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return s();const m=[],h=g=>{if(!g||g==="cimode")return;this.services.languageUtils.toResolveHierarchy(g).forEach(b=>{b!=="cimode"&&m.indexOf(b)<0&&m.push(b)})};i?h(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(p=>h(p)),(d=(c=this.options.preload)==null?void 0:c.forEach)==null||d.call(c,g=>h(g)),this.services.backendConnector.load(m,this.options.ns,g=>{!g&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(g)})}else s(null)}reloadResources(a,r,s){const i=H0();return typeof a=="function"&&(s=a,a=void 0),typeof r=="function"&&(s=r,r=void 0),a||(a=this.languages),r||(r=this.options.ns),s||(s=Pm),this.services.backendConnector.reload(a,r,c=>{i.resolve(),s(c)}),i}use(a){if(!a)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!a.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return a.type==="backend"&&(this.modules.backend=a),(a.type==="logger"||a.log&&a.warn&&a.error)&&(this.modules.logger=a),a.type==="languageDetector"&&(this.modules.languageDetector=a),a.type==="i18nFormat"&&(this.modules.i18nFormat=a),a.type==="postProcessor"&&V_.addPostProcessor(a),a.type==="formatter"&&(this.modules.formatter=a),a.type==="3rdParty"&&this.modules.external.push(a),this}setResolvedLanguage(a){if(!(!a||!this.languages)&&!(["cimode","dev"].indexOf(a)>-1)){for(let r=0;r<this.languages.length;r++){const s=this.languages[r];if(!(["cimode","dev"].indexOf(s)>-1)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;break}}!this.resolvedLanguage&&this.languages.indexOf(a)<0&&this.store.hasLanguageSomeTranslations(a)&&(this.resolvedLanguage=a,this.languages.unshift(a))}}changeLanguage(a,r){this.isLanguageChangingTo=a;const s=H0();this.emit("languageChanging",a);const i=m=>{this.language=m,this.languages=this.services.languageUtils.toResolveHierarchy(m),this.resolvedLanguage=void 0,this.setResolvedLanguage(m)},c=(m,h)=>{h?this.isLanguageChangingTo===a&&(i(h),this.translator.changeLanguage(h),this.isLanguageChangingTo=void 0,this.emit("languageChanged",h),this.logger.log("languageChanged",h)):this.isLanguageChangingTo=void 0,s.resolve((...g)=>this.t(...g)),r&&r(m,(...g)=>this.t(...g))},d=m=>{var p,b;!a&&!m&&this.services.languageDetector&&(m=[]);const h=ja(m)?m:m&&m[0],g=this.store.hasLanguageSomeTranslations(h)?h:this.services.languageUtils.getBestMatchFromCodes(ja(m)?[m]:m);g&&(this.language||i(g),this.translator.language||this.translator.changeLanguage(g),(b=(p=this.services.languageDetector)==null?void 0:p.cacheUserLanguage)==null||b.call(p,g)),this.loadResources(g,j=>{c(j,g)})};return!a&&this.services.languageDetector&&!this.services.languageDetector.async?d(this.services.languageDetector.detect()):!a&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(d):this.services.languageDetector.detect(d):d(a),s}getFixedT(a,r,s){const i=(c,d,...m)=>{let h;typeof d!="object"?h=this.options.overloadTranslationOptionHandler([c,d].concat(m)):h=ue({},d),h.lng=h.lng||i.lng,h.lngs=h.lngs||i.lngs,h.ns=h.ns||i.ns,h.keyPrefix!==""&&(h.keyPrefix=h.keyPrefix||s||i.keyPrefix);const g=this.options.keySeparator||".";let p;return h.keyPrefix&&Array.isArray(c)?p=c.map(b=>(typeof b=="function"&&(b=bx(b,ue(ue({},this.options),d))),`${h.keyPrefix}${g}${b}`)):(typeof c=="function"&&(c=bx(c,ue(ue({},this.options),d))),p=h.keyPrefix?`${h.keyPrefix}${g}${c}`:c),this.t(p,h)};return ja(a)?i.lng=a:i.lngs=a,i.ns=r,i.keyPrefix=s,i}t(...a){var r;return(r=this.translator)==null?void 0:r.translate(...a)}exists(...a){var r;return(r=this.translator)==null?void 0:r.exists(...a)}setDefaultNamespace(a){this.options.defaultNS=a}hasLoadedNamespace(a,r={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=r.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,c=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const d=(m,h)=>{const g=this.services.backendConnector.state[`${m}|${h}`];return g===-1||g===0||g===2};if(r.precheck){const m=r.precheck(this,d);if(m!==void 0)return m}return!!(this.hasResourceBundle(s,a)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||d(s,a)&&(!i||d(c,a)))}loadNamespaces(a,r){const s=H0();return this.options.ns?(ja(a)&&(a=[a]),a.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{s.resolve(),r&&r(i)}),s):(r&&r(),Promise.resolve())}loadLanguages(a,r){const s=H0();ja(a)&&(a=[a]);const i=this.options.preload||[],c=a.filter(d=>i.indexOf(d)<0&&this.services.languageUtils.isSupportedCode(d));return c.length?(this.options.preload=i.concat(c),this.loadResources(d=>{s.resolve(),r&&r(d)}),s):(r&&r(),Promise.resolve())}dir(a){var i,c;if(a||(a=this.resolvedLanguage||(((i=this.languages)==null?void 0:i.length)>0?this.languages[0]:this.language)),!a)return"rtl";try{const d=new Intl.Locale(a);if(d&&d.getTextInfo){const m=d.getTextInfo();if(m&&m.direction)return m.direction}}catch(d){}const r=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],s=((c=this.services)==null?void 0:c.languageUtils)||new Gv(Qv());return a.toLowerCase().indexOf("-latn")>1?"ltr":r.indexOf(s.getLanguagePartFromCode(a))>-1||a.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(a={},r){const s=new tu(a,r);return s.createInstance=tu.createInstance,s}cloneInstance(a={},r=Pm){const s=a.forkResourceStore;s&&delete a.forkResourceStore;const i=Se(ue(ue({},this.options),a),{isClone:!0}),c=new tu(i);if((a.debug!==void 0||a.prefix!==void 0)&&(c.logger=c.logger.clone(a)),["store","services","language"].forEach(m=>{c[m]=this[m]}),c.services=ue({},this.services),c.services.utils={hasLoadedNamespace:c.hasLoadedNamespace.bind(c)},s){const m=Object.keys(this.store.data).reduce((h,g)=>(h[g]=ue({},this.store.data[g]),h[g]=Object.keys(h[g]).reduce((p,b)=>(p[b]=ue({},h[g][b]),p),h[g]),h),{});c.store=new Vv(m,i),c.services.resourceStore=c.store}return a.interpolation&&(c.services.interpolator=new Xv(i)),c.translator=new ih(c.services,i),c.translator.on("*",(m,...h)=>{c.emit(m,...h)}),c.init(i,r),c.translator.options=i,c.translator.backendConnector.services.utils={hasLoadedNamespace:c.hasLoadedNamespace.bind(c)},c}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Ts=tu.createInstance();Ts.createInstance;Ts.dir;Ts.init;Ts.loadResources;Ts.reloadResources;Ts.use;Ts.changeLanguage;Ts.getFixedT;Ts.t;Ts.exists;Ts.setDefaultNamespace;Ts.hasLoadedNamespace;Ts.loadNamespaces;Ts.loadLanguages;const c4=(t,a,r,s)=>{var c,d,m,h;const i=[r,ue({code:a},s||{})];if((d=(c=t==null?void 0:t.services)==null?void 0:c.logger)!=null&&d.forward)return t.services.logger.forward(i,"warn","react-i18next::",!0);vc(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),(h=(m=t==null?void 0:t.services)==null?void 0:m.logger)!=null&&h.warn?t.services.logger.warn(...i):console!=null&&console.warn&&console.warn(...i)},t1={},G_=(t,a,r,s)=>{vc(r)&&t1[r]||(vc(r)&&(t1[r]=new Date),c4(t,a,r,s))},Y_=(t,a)=>()=>{if(t.isInitialized)a();else{const r=()=>{setTimeout(()=>{t.off("initialized",r)},0),a()};t.on("initialized",r)}},vx=(t,a,r)=>{t.loadNamespaces(a,Y_(t,r))},a1=(t,a,r,s)=>{if(vc(r)&&(r=[r]),t.options.preload&&t.options.preload.indexOf(a)>-1)return vx(t,r,s);r.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(a,Y_(t,s))},d4=(t,a,r={})=>!a.languages||!a.languages.length?(G_(a,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:a.languages}),!0):a.hasLoadedNamespace(t,{lng:r.lng,precheck:(s,i)=>{if(r.bindI18n&&r.bindI18n.indexOf("languageChanging")>-1&&s.services.backendConnector.backend&&s.isLanguageChangingTo&&!i(s.isLanguageChangingTo,t))return!1}}),vc=t=>typeof t=="string",u4=t=>typeof t=="object"&&t!==null,m4=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,h4={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},g4=t=>h4[t],f4=t=>t.replace(m4,g4);let _x={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:f4};const x4=(t={})=>{_x=ue(ue({},_x),t)},p4=()=>_x;let Z_;const y4=t=>{Z_=t},b4=()=>Z_,v4={type:"3rdParty",init(t){x4(t.options.react),y4(t)}},_4=y.createContext();class w4{constructor(){this.usedNamespaces={}}addUsedNamespaces(a){a.forEach(r=>{this.usedNamespaces[r]||(this.usedNamespaces[r]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var Yf={exports:{}},Zf={};var r1;function k4(){if(r1)return Zf;r1=1;var t=Oh();function a(b,j){return b===j&&(b!==0||1/b===1/j)||b!==b&&j!==j}var r=typeof Object.is=="function"?Object.is:a,s=t.useState,i=t.useEffect,c=t.useLayoutEffect,d=t.useDebugValue;function m(b,j){var _=j(),N=s({inst:{value:_,getSnapshot:j}}),k=N[0].inst,C=N[1];return c(function(){k.value=_,k.getSnapshot=j,h(k)&&C({inst:k})},[b,_,j]),i(function(){return h(k)&&C({inst:k}),b(function(){h(k)&&C({inst:k})})},[b]),d(_),_}function h(b){var j=b.getSnapshot;b=b.value;try{var _=j();return!r(b,_)}catch(N){return!0}}function g(b,j){return j()}var p=typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"?g:m;return Zf.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,Zf}var s1;function j4(){return s1||(s1=1,Yf.exports=k4()),Yf.exports}var N4=j4();const S4=(t,a)=>vc(a)?a:u4(a)&&vc(a.defaultValue)?a.defaultValue:Array.isArray(t)?t[t.length-1]:t,C4={t:S4,ready:!1},T4=()=>()=>{},ca=(t,a={})=>{var J,ne,ye;const{i18n:r}=a,{i18n:s,defaultNS:i}=y.useContext(_4)||{},c=r||s||b4();c&&!c.reportNamespaces&&(c.reportNamespaces=new w4),c||G_(c,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const d=y.useMemo(()=>{var he;return ue(ue(ue({},p4()),(he=c==null?void 0:c.options)==null?void 0:he.react),a)},[c,a]),{useSuspense:m,keyPrefix:h}=d,g=i||((J=c==null?void 0:c.options)==null?void 0:J.defaultNS),p=vc(g)?[g]:g||["translation"],b=y.useMemo(()=>p,p);(ye=(ne=c==null?void 0:c.reportNamespaces)==null?void 0:ne.addUsedNamespaces)==null||ye.call(ne,b);const j=y.useRef(0),_=y.useCallback(he=>{if(!c)return T4;const{bindI18n:ce,bindI18nStore:se}=d,ee=()=>{j.current+=1,he()};return ce&&c.on(ce,ee),se&&c.store.on(se,ee),()=>{ce&&ce.split(" ").forEach(te=>c.off(te,ee)),se&&se.split(" ").forEach(te=>c.store.off(te,ee))}},[c,d]),N=y.useRef(),k=y.useCallback(()=>{if(!c)return C4;const he=!!(c.isInitialized||c.initializedStoreOnce)&&b.every(I=>d4(I,c,d)),ce=a.lng||c.language,se=j.current,ee=N.current;if(ee&&ee.ready===he&&ee.lng===ce&&ee.keyPrefix===h&&ee.revision===se)return ee;const W={t:c.getFixedT(ce,d.nsMode==="fallback"?b:b[0],h),ready:he,lng:ce,keyPrefix:h,revision:se};return N.current=W,W},[c,b,h,d,a.lng]),[C,D]=y.useState(0),{t:T,ready:E}=N4.useSyncExternalStore(_,k,k);y.useEffect(()=>{if(c&&!E&&!m){const he=()=>D(ce=>ce+1);a.lng?a1(c,a.lng,b,he):vx(c,b,he)}},[c,a.lng,b,E,m,C]);const O=c||{},R=y.useRef(null),Y=y.useRef(),P=he=>{const ce=Object.getOwnPropertyDescriptors(he);ce.__original&&delete ce.__original;const se=Object.create(Object.getPrototypeOf(he),ce);if(!Object.prototype.hasOwnProperty.call(se,"__original"))try{Object.defineProperty(se,"__original",{value:he,writable:!1,enumerable:!1,configurable:!1})}catch(ee){}return se},U=y.useMemo(()=>{const he=O,ce=he==null?void 0:he.language;let se=he;he&&(R.current&&R.current.__original===he?Y.current!==ce?(se=P(he),R.current=se,Y.current=ce):se=R.current:(se=P(he),R.current=se,Y.current=ce));const ee=[T,se,E];return ee.t=T,ee.i18n=se,ee.ready=E,ee},[T,O,E,O.resolvedLanguage,O.language,O.languages]);if(c&&m&&!E)throw new Promise(he=>{const ce=()=>he();a.lng?a1(c,a.lng,b,ce):vx(c,b,ce)});return U},{slice:E4,forEach:A4}=[];function O4(t){return A4.call(E4.call(arguments,1),a=>{if(a)for(const r in a)t[r]===void 0&&(t[r]=a[r])}),t}function D4(t){return typeof t!="string"?!1:[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(r=>r.test(t))}const n1=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,M4=function(t,a){const s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(a);let c=`${t}=${i}`;if(s.maxAge>0){const d=s.maxAge-0;if(Number.isNaN(d))throw new Error("maxAge should be a Number");c+=`; Max-Age=${Math.floor(d)}`}if(s.domain){if(!n1.test(s.domain))throw new TypeError("option domain is invalid");c+=`; Domain=${s.domain}`}if(s.path){if(!n1.test(s.path))throw new TypeError("option path is invalid");c+=`; Path=${s.path}`}if(s.expires){if(typeof s.expires.toUTCString!="function")throw new TypeError("option expires is invalid");c+=`; Expires=${s.expires.toUTCString()}`}if(s.httpOnly&&(c+="; HttpOnly"),s.secure&&(c+="; Secure"),s.sameSite)switch(typeof s.sameSite=="string"?s.sameSite.toLowerCase():s.sameSite){case!0:c+="; SameSite=Strict";break;case"lax":c+="; SameSite=Lax";break;case"strict":c+="; SameSite=Strict";break;case"none":c+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return s.partitioned&&(c+="; Partitioned"),c},i1={create(t,a,r,s){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+r*60*1e3)),s&&(i.domain=s),document.cookie=M4(t,a,i)},read(t){const a=`${t}=`,r=document.cookie.split(";");for(let s=0;s<r.length;s++){let i=r[s];for(;i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(a)===0)return i.substring(a.length,i.length)}return null},remove(t,a){this.create(t,"",-1,a)}};var L4={name:"cookie",lookup(t){let{lookupCookie:a}=t;if(a&&typeof document!="undefined")return i1.read(a)||void 0},cacheUserLanguage(t,a){let{lookupCookie:r,cookieMinutes:s,cookieDomain:i,cookieOptions:c}=a;r&&typeof document!="undefined"&&i1.create(r,t,s,i,c)}},R4={name:"querystring",lookup(t){var s;let{lookupQuerystring:a}=t,r;if(typeof window!="undefined"){let{search:i}=window.location;!window.location.search&&((s=window.location.hash)==null?void 0:s.indexOf("?"))>-1&&(i=window.location.hash.substring(window.location.hash.indexOf("?")));const d=i.substring(1).split("&");for(let m=0;m<d.length;m++){const h=d[m].indexOf("=");h>0&&d[m].substring(0,h)===a&&(r=d[m].substring(h+1))}}return r}},P4={name:"hash",lookup(t){var i;let{lookupHash:a,lookupFromHashIndex:r}=t,s;if(typeof window!="undefined"){const{hash:c}=window.location;if(c&&c.length>2){const d=c.substring(1);if(a){const m=d.split("&");for(let h=0;h<m.length;h++){const g=m[h].indexOf("=");g>0&&m[h].substring(0,g)===a&&(s=m[h].substring(g+1))}}if(s)return s;if(!s&&r>-1){const m=c.match(/\/([a-zA-Z-]*)/g);return Array.isArray(m)?(i=m[typeof r=="number"?r:0])==null?void 0:i.replace("/",""):void 0}}}return s}};let vd=null;const o1=()=>{if(vd!==null)return vd;try{if(vd=typeof window!="undefined"&&window.localStorage!==null,!vd)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch(t){vd=!1}return vd};var F4={name:"localStorage",lookup(t){let{lookupLocalStorage:a}=t;if(a&&o1())return window.localStorage.getItem(a)||void 0},cacheUserLanguage(t,a){let{lookupLocalStorage:r}=a;r&&o1()&&window.localStorage.setItem(r,t)}};let _d=null;const l1=()=>{if(_d!==null)return _d;try{if(_d=typeof window!="undefined"&&window.sessionStorage!==null,!_d)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch(t){_d=!1}return _d};var I4={name:"sessionStorage",lookup(t){let{lookupSessionStorage:a}=t;if(a&&l1())return window.sessionStorage.getItem(a)||void 0},cacheUserLanguage(t,a){let{lookupSessionStorage:r}=a;r&&l1()&&window.sessionStorage.setItem(r,t)}},z4={name:"navigator",lookup(t){const a=[];if(typeof navigator!="undefined"){const{languages:r,userLanguage:s,language:i}=navigator;if(r)for(let c=0;c<r.length;c++)a.push(r[c]);s&&a.push(s),i&&a.push(i)}return a.length>0?a:void 0}},B4={name:"htmlTag",lookup(t){let{htmlTag:a}=t,r;const s=a||(typeof document!="undefined"?document.documentElement:null);return s&&typeof s.getAttribute=="function"&&(r=s.getAttribute("lang")),r}},U4={name:"path",lookup(t){var i;let{lookupFromPathIndex:a}=t;if(typeof window=="undefined")return;const r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(r)?(i=r[typeof a=="number"?a:0])==null?void 0:i.replace("/",""):void 0}},$4={name:"subdomain",lookup(t){var i,c;let{lookupFromSubdomainIndex:a}=t;const r=typeof a=="number"?a+1:1,s=typeof window!="undefined"&&((c=(i=window.location)==null?void 0:i.hostname)==null?void 0:c.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i));if(s)return s[r]}};let J_=!1;try{document.cookie,J_=!0}catch(t){}const X_=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];J_||X_.splice(1,1);const H4=()=>({order:X_,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class K_{constructor(a){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(a,r)}init(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=a,this.options=O4(r,this.options||{},H4()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=i=>i.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=s,this.addDetector(L4),this.addDetector(R4),this.addDetector(F4),this.addDetector(I4),this.addDetector(z4),this.addDetector(B4),this.addDetector(U4),this.addDetector($4),this.addDetector(P4)}addDetector(a){return this.detectors[a.name]=a,this}detect(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,r=[];return a.forEach(s=>{if(this.detectors[s]){let i=this.detectors[s].lookup(this.options);i&&typeof i=="string"&&(i=[i]),i&&(r=r.concat(i))}}),r=r.filter(s=>s!=null&&!D4(s)).map(s=>this.options.convertDetectedLanguage(s)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?r:r.length>0?r[0]:null}cacheUserLanguage(a){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(a)>-1||r.forEach(s=>{this.detectors[s]&&this.detectors[s].cacheUserLanguage(a,this.options)}))}}K_.type="languageDetector";const W4={dashboard:"Dashboard",assets:"Assets",workOrders:"Work Orders",maintenance:"Asset Maintenance",ppm:"PPM",logout:"Logout",login:"Login",email:"Email",password:"Password",submit:"Submit",cancel:"Cancel",save:"Save",saveChanges:"Save Changes",delete:"Delete",deleting:"Deleting...",edit:"Edit",create:"Create",search:"Search",filter:"Filter",export:"Export",import:"Import",loading:"Loading...",noData:"No data available",error:"Error",success:"Success",darkMode:"Dark Mode",lightMode:"Light Mode",language:"Language",english:"English",arabic:"Arabic",backToDashboard:"Back to Dashboard",back:"Back",saving:"Saving...",tryAgain:"Try Again",filters:"Filters",enterFilterName:"Enter filter name",saveFilterPreset:"Save Filter Preset",saveFilter:"Save Filter",filtering:"Filtering...",updating:"Updating...",clearFilters:"Clear filters",total:"Total",selected:"selected",rows:"rows",actions:"Actions",selectAllTitle:"Select all",deselectAllTitle:"Deselect all",typeToSearch:"Type to search...",typing:"typing...",enterFilterNameExample:"Enter filter name (e.g., 'Open High Priority')"},V4={title:"SEERA-ASM",loggedInAs:"Logged in as:",version:"Seera-ASM v1.0",inventory:"Inventory",ppmPlanner:"PPM Planner",maintenanceCalendar:"Maintenance Calendar",activeMap:"Active Map",maintenanceTeam:"Maintenance Team",procurement:"Procurement",sla:"Service Level Agreement (SLA)",support:"Support",inspection:"Inspection",deleteRequests:"Delete Requests",userProfile:"User Profile"},q4={title:"SEERA-ASM",subtitle:"Asset Management System",signIn:"Sign in to continue",emailPlaceholder:"Enter your email",passwordPlaceholder:"Enter your password",loginFailed:"Login failed. Please check your credentials.",demoLogin:"Demo Login",or:"or"},G4={title:"Dashboard",loading:"Loading dashboard...",totalAssets:"TOTAL NO. OF ASSETS",assetsDown:"Assets Down",openWorkOrders:"OPEN WORK ORDERS",workOrdersInProgress:"WORK ORDERS IN PROGRESS",completedWorkOrders:"COMPLETED WORK ORDERS",totalWorkOrders:"TOTAL WORK ORDERS",overdueWorkOrders:"OVERDUE WORK ORDERS",closedWorkOrders:"Closed Work Orders",upTime:"Up Time",downTime:"Down Time",workOrderStatus:"Work Order Status",workOrderByType:"Work Order by Type",maintenanceByAsset:"Maintenance - Asset wise Count",assigneesStatus:"Asset Maintenance Assignees Status Count",assigneesCount:"Assignees",totalTasksAssigned:"Tasks Assigned",maintenanceFrequency:"Asset Maintenance Frequency Chart",maintenanceLogs:"MAINTENANCE LOGS",assetUptime:"Asset Uptime",avgResponseTime:"Avg Response Time",maintenanceEfficiency:"Maintenance Efficiency",overdueMaintenance:"Overdue Maintenance",upDownTimeChart:"Up & Down Time Chart",ppmStatus:"PPM Status",completionRate:"Contractor Completion Rate",completionRateChartHint:"Completion % over last 7 months — hover a point for details",completionRateTooltip:"{{value}}% completion rate",viewFullReport:"View Full Report",noDataAvailable:"No data available",loadingTechnicianHours:"Loading technician hours...",loadingTechnicianWorkData:"Loading technician work data...",welcome:"Welcome,",user:"User",failedToLoad:"Failed to load dashboard data",recentRecords:"Recent Records",latestEntries:"Latest entries from your Frappe backend",quickActions:"Quick Actions",cardTotalAssets:"Total Assets",cardOpenWorkOrders:"Open Work Orders",cardInProgress:"In Progress",cardCompletedWorkOrders:"Completed Work Orders",viewUsers:"View Users",manageUserAccounts:"Manage user accounts",settings:"Settings",configurePreferences:"Configure your preferences",events:"Events",viewCalendarEvents:"View calendar events",reports:"Reports",viewAnalyticsReports:"View analytics and reports",ppmTemplateCounts:"PPM Template Counts",repairCost:"Repair Cost",dashboardFilter:"Dashboard Filter",allDepartments:"All Departments",workOrderStatusDistribution:"Work Order Status Distribution",workOrderInspectionSummary:"Work Order Inspection Summary",woRejectionSummary:"WO Rejection Summary",total:"Total",inProgress:"In Progress",completed:"Completed",totalSales:"Total Sales",average:"Average",noChartDataAvailable:"No chart data available",loadingInspectionData:"Loading inspection data...",noInspectionDataAvailable:"No inspection data available",totalRejections:"Total rejections",loadingRejectionData:"Loading rejection data...",noRejectionDataAvailable:"No rejection data available",department:"Department",allOperational:"All Operational",low:"Low",highPriority:"High Priority",allClear:"All Clear",fastResponse:"Fast Response",monitor:"Monitor",onTrack:"On Track",needsAttention:"Needs Attention",totalHours:"Total: {{value}} hours",technicianWorkingHours:"Technicians Working Hours",techniciansWorked:"Technicians Work Summary",pendingReviewWorkOrders:"Pending Review",clear:"Clear",clearFilter:"Clear Filter",label:"Label",open:"Open"},Y4={assetId:"Asset ID",assetName:"Asset Name",serialNumber:"Serial Number",company:"Company/Hospital",building:"Building",roomNumber:"Room Number",location:"Location",department:"Department",deviceStatus:"Device Status",modality:"Modality",manufacturer:"Manufacturer",supplier:"Supplier",assetCategory:"Asset Category",purchaseDate:"Purchase Date",purchaseAmount:"Purchase Amount",availableForUseDate:"Available For Use Date",createdOn:"Created On",modifiedOn:"Modified On",createdBy:"Created By",modifiedBy:"Modified By",workOrderId:"Work Order ID",workOrderType:"Type",status:"Status",priority:"Priority",description:"Description",assignedTo:"Assigned To",scheduledDate:"Scheduled Date",completedDate:"Completed Date",hospital:"Hospital",assetType:"Asset Type",siteName:"Site Name",assignedSupervisor:"Assigned Supervisor",assignedContractor:"Assigned Contractor",serialNumberShort:"Serial",departmentShort:"Dept",manufacturerShort:"Mfr",workOrderIdShort:"WO ID",assetShort:"Asset",typeShort:"Type",nameShort:"Name",pmId:"PM ID",name:"Name"},Z4={filterBy:"Filter By",createdDate:"Created Date",latestModifiedDate:"Latest Modified Date",startDate:"Start Date",endDate:"End Date",assetId:"Asset ID",hospital:"Hospital",name:"Name",serial:"Serial",status:"Status",location:"Location",dept:"Dept",modality:"Modality",mfr:"Mfr",supplier:"Supplier",workOrderId:"WO ID",asset:"Asset",type:"Type",priority:"Priority",workflowState:"Workflow State",allStatuses:"All Statuses",allStates:"All States",allTypes:"All Types",allPriorities:"All priorities",allHospitals:"All Hospitals",allModalities:"All Modalities",filterByCompany:"Filter by Company",allManufacturers:"All Manufacturers",sortBy:"Sort by",sortCreationNewest:"Creation (newest first)",sortCreationOldest:"Creation (oldest first)",sortModifiedNewest:"Modified (newest first)",sortModifiedOldest:"Modified (oldest first)",sortNameAsc:"Name (A-Z)",sortNameDesc:"Name (Z-A)",sortAssetNameAsc:"Asset Name (A-Z)",sortAssetNameDesc:"Asset Name (Z-A)",sortItemNameAsc:"Item Name (A-Z)",sortItemNameDesc:"Item Name (Z-A)",sortTeamNameAsc:"Team Name (A-Z)",sortTeamNameDesc:"Team Name (Z-A)"},J4={addNew:"Add New",searchPlaceholder:"Search...",noResults:"No results found",showing:"Showing",of:"of",results:"results",selectAll:"Select All",deselectAll:"Deselect All",selected:"selected",actions:"Actions",view:"View",edit:"Edit",delete:"Delete",duplicate:"Duplicate",export:"Export",print:"Print",filters:"Filters",clearFilters:"Clear Filters",applyFilters:"Apply Filters",columns:"Columns",exportSelected:"Export Selected",exportAllOnPage:"Export All on Page",exportAllWithFilters:"Export All with Filters",exportFormat:"Export Format",csv:"CSV",excel:"Excel",exporting:"Exporting...",exportComplete:"Export Complete",close:"Close",loading:"Loading...",refresh:"Refresh",deselectAllTitle:"Deselect all",selectAllTitle:"Select all",typeToSearch:"Type to search...",enterFilterName:"Enter filter name",enterFilterNameExample:"Enter filter name (e.g., 'Open High Priority')",allStatuses:"All Statuses",noIssuesFound:"No issues found",createFirstIssue:"Create your first issue",saveFilterPreset:"Save Filter Preset",saveFilter:"Save Filter",savedFilters:"Saved Filters",clear:"Clear",typing:"typing...",filtering:"Filtering...",noMaintenanceTeamsFound:"No maintenance teams found",createFirstTeam:"Create your first team",all:"All",tryAdjustingFilters:"Try adjusting your search or filters",getStartedCreateFirst:"Get started by creating your first PPM Planner",noMaintenanceLogsFound:"No maintenance logs found",createFirstMaintenanceLog:"Create your first maintenance log",total:"Total",noPPMSchedulesFound:"No PPM schedules found",createFirstPPMSchedule:"Create your first PPM schedule",deleteConfirmCannotUndo:"This action cannot be undone."},X4={title:"Assets",addAsset:"Add New Asset",assetDetails:"Asset Details",assetInformation:"Asset Information",newAsset:"New Asset",duplicateAsset:"Duplicate Asset",fromAsset:"From Asset",creatingFromAsset:"Creating Work Order from Asset",assetInfoPrefilled:"Asset information prefilled from",pleaseSelectWorkOrderType:"Please select a Work Order type and add any additional details",loadingAssetDetails:"Loading asset details...",pleaseEnterAssetName:"Please enter an Asset Name",pleaseSelectCategory:"Please select a Category",assetDuplicatedSuccessfully:"Asset duplicated successfully!",assetCreatedSuccessfully:"Asset created successfully!",assetUpdatedSuccessfully:"Asset updated successfully!",sourceAssetNotFound:"Source Asset Not Found",assetNotFoundMessage:"The asset you're trying to duplicate could not be found.",backToAssetsList:"Back to Assets List",backToList:"Back to assets list",createNewAsset:"Create New Asset",newAssetDetails:"New Asset Details",noAssetsFound:"No assets found",createFirstAsset:"Create your first asset",deleteConfirmTitle:"Delete Asset",deleteConfirmMessage:"Are you sure you want to delete this asset? This action cannot be undone.",noDataToExport:"No data to export",loadingPermissions:"Loading permissions...",selectAssetId:"Select Asset ID",selectHospital:"Hospital",viewDetails:"View Details",editAsset:"Edit Asset",createWorkOrder:"Create Work Order",viewLinkedWOs:"View Linked Work Orders",moreActions:"More Actions",exportAsJson:"Export as JSON",printAsset:"Print",status:{up:"Up",down:"Down"},deviceStatus:"Device Status",apiNotAvailable:"Asset API Not Available",apiNotDeployed:"The Asset API endpoint is not deployed yet.",tryCreatingNew:"Try Creating a New Asset (Demo)",listTotal:"Total: ",table:{assetName:"Asset Name",serialNo:"Serial No",company:"Company",location:"Location",status:"Status",updatedOn:"Updated on",actions:"Actions"},export:{title:"Export Assets",selectData:"Select Data to Export",selectedRows:"Selected Rows",selectedCount:"Export {{count}} selected asset ",currentPage:"Current Page",currentPageCount:"Export {{count}} asset on current page",allWithFilters:"All Records (with current filters)",allWithFiltersCount:"Export all {{count}} asset matching current filters",csvDesc:"Comma-separated values",excelDesc:"XLSX spreadsheet",columnsToExport:"Columns to Export",selectAll:"Select All",resetToDefault:"Reset to Default",columnsSelected:"{{count}} column selected",exporting:"Exporting...",exportButton:"Export",exportingSelected:"Exporting {{count}} selected row ",exportingPage:"Exporting {{count}} row from current page",exportingAll:"Exporting all {{count}} row "},detail:{assetInformation:"Asset Information",technicalSpecs:"Technical Specs",financialDetails:"Financial Details",assetFinanceBooks:"Asset Finance Books",addRow:"Add Row",duplicatingFrom:"Duplicating from:",noDepartmentsMapped:"No departments mapped to this building",departmentsAvailable:"{{count}} department(s) available (filtered by building)",selectDepartmentForRoom:"Select Department to enable Room Number",depreciationMethodNote:"The depreciation method is an accounting method used to allocate the cost of a tangible asset over its useful life.",calculateDepreciation:"Calculate Depreciation",noFinanceBooksYet:'No finance books added yet. Click "Add Row" to add one.',noSparePartsYet:'No spare parts added yet. Click "Add Row" to add one.',assetName:"Asset Name",category:"Category",type:"Asset Type",modality:"Modality",class:"Class",assetId:"Asset ID",deviceStatus:"Device Status",serialCode:"Serial Code",technicalDepartment:"Technical Department",manufacturer:"Manufacturer",model:"Model",totalHours:"Total Hours",downTimeHours:"Down Time (Hours)",upTimeHours:"Up Time (Hours)",placeholderAssetName:"e.g. Laptop Model X",placeholderSerialCode:"e.g. SN-12345",placeholderModelNumber:"Model number",placeholderZero:"0",placeholderDescription:"Brief description of the asset",placeholderPONumber:"PO number",selectClass:"Select class",classA:"Class A",classB:"Class B",classC:"Class C",autoGenerated:"Auto-generated",calculatedFromAvailableDate:"Calculated from Available For Use Date",calculatedTotalMinusDown:"Calculated: Total Hours - Down Time",hospital:"Hospital",siteName:"Site name",selectSite:"Select Site",building:"Building",department:"Department",roomNumber:"Room Number",location:"Location",selectStatus:"Select status",operational:"Operational",underMaintenance:"Under Maintenance",decommissioned:"Decommissioned",selectServiceAgreement:"Select Service Agreement",warranty:"Warranty",contract:"Contract",frameWork:"Frame Work",mainContractor:"Main Contractor",outOfWarranty:"Out of warranty",underDismantle:"Under Dismantle",underInstallation:"Under Installation",selectServiceCoverage:"Select Service Coverage",pmOnly:"PM Only",labour:"Labour",labourAndParts:"Labour & Parts",comprehensive:"Comprehensive",supplierVendor:"Supplier/Vendor",selectMethod:"Select Method",straightLine:"Straight Line",doubleDecliningBalance:"Double Declining Balance",writtenDownValue:"Written Down Value",manual:"Manual",recycling:"Recycling",donation:"Donation",sale:"Sale",assetDuplicatedSuccess:"Asset duplicated successfully!",assetCreatedSuccess:"Asset created successfully!",assetUpdatedSuccess:"Asset updated successfully!",failedToSave:"Failed to save asset",cannotSubmitNotSaved:"Cannot submit: Asset not saved yet",confirmSubmit:'Are you sure you want to submit this asset? Once submitted, only fields marked as "Allow on Submit" can be edited.',assetSubmittedSuccess:"Asset submitted successfully!",failedToSubmit:"Failed to submit asset",pleaseSaveFirstForPPM:"Please save the asset first to view PPM Plan",pleaseSaveFirstForHistory:"Please save the asset first to view Asset History",failedToLoadPPMPlan:"Failed to load PPM Plan. Please try again.",noPlannedMaintenance:"No planned maintenance found for this asset",noWorkOrdersFound:"No Work Orders Found",noSparePartsUsed:"No Spare Parts Used",noMaintenanceRecords:"No Maintenance Records Found",noMaintenanceTasks:"No Maintenance Tasks Found",selectBuildingFirst:"Select Building first to enable Department",coverage:"Coverage",siteContractor:"Site Contractor",contractNumber:"Contract Number",serviceAgreement:"Service Agreement",serviceCoverage:"Service Coverage",purchaseOrderNumber:"Purchase Order Number",grossPurchaseAmount:"Gross Purchase Amount",purchaseDate:"Purchase Date",installationDate:"Installation Date",availableForUseDate:"Available For Use Date",financeBook:"Finance Book",depreciationMethod:"Depreciation Method",totalDepreciations:"Total Depreciations",frequencyMonths:"Frequency (Months)",depreciationPostingDate:"Depreciation Posting Date",startDate:"Start Date",endDate:"End Date",totalAmount:"Total Amount",selectRoomFirst:"Select Room Number to enable Location",autoSetFromRoom:"Auto-set from room mapping",moreDetails:"More Details"}},K4=JSON.parse(`{"title":"Work Orders","addWorkOrder":"Add New Work Order","workOrderDetails":"Work Order Details","newWorkOrder":"New Work Order","duplicateWorkOrder":"Duplicate Work Order","createFromAsset":"Create Work Order from Asset","closeWorkOrders":"Close Work Orders","closeConfirmTitle":"Close Work Orders","closeConfirmMessage":"Are you sure you want to close the selected work order(s)?","deleteConfirmMessage":"Are you sure you want to delete this work order? This action cannot be undone.","cancelConfirmMessage":"Are you sure you want to cancel this work order? This will mark the work order as cancelled and you can then delete it if needed.","assignConfirmMessage":"Are you sure you want to assign this work order to the following technician(s)?","deleteWorkOrder":"Delete Work Order","cancelWorkOrder":"Cancel Work Order","loadingWorkOrders":"Loading work orders...","loadingDetails":"Loading work order details...","backToList":"Back to work orders list","status":{"open":"Open","work_in_progress":"Work In Progress","pending_review":"Pending Review","completed":"Completed","cancelled":"Cancelled","closed":"Closed"},"priorityNormal":"Normal","priorityUrgent":"Urgent","workflowState":{"draft":"Draft"},"priority":{"normal":"Normal","urgent":"Urgent"},"table":{"workOrderId":"Work Order ID","asset":"Asset","type":"Type","technicalReport":"Technical Report","department":"Department","workflowState":"Workflow State","priority":"Priority","noWorkOrdersFound":"No work orders found","createFirstWorkOrder":"Create your first work order"},"export":{"title":"Export Work Orders","selectData":"What to Export","selectedRows":"Selected Rows","selectedCount":"Export {{count}} selected work order ","currentPage":"Current Page","currentPageCount":"Export {{count}} work order on current page","allWithFilters":"All Records (with current filters)","allWithFiltersCount":"Export all {{count}} work order matching current filters","csvDesc":"Comma-separated values","excelDesc":"XLSX spreadsheet","columnsToExport":"Columns to Export","selectAll":"Select All","resetToDefault":"Reset to Default","columnsSelected":"{{count}} column selected","exporting":"Exporting...","exportButton":"Export","exportingSelected":"Exporting {{count}} selected row ","exportingPage":"Exporting {{count}} row from current page","exportingAll":"Exporting all {{count}} row "},"closeModal":{"title":"Close Work Orders","confirmBulkClose":"Confirm Bulk Close Operation","aboutToClose":"You are about to close {{count}} work order . This action will change their workflow state to Closed.","alreadyClosedNote":"Note: {{count}} work order{{count !== 1 ? 's are' : ' is'}} already closed and will be skipped.","selectedWorkOrders":"Selected Work Orders ({{count}})","workOrderId":"Work Order ID","currentStatus":"Current Status","workflowState":"Workflow State","alreadyClosed":"(already closed)","willClose":"Will close {{count}} work order ","allAlreadyClosed":"All selected work orders are already closed","cancel":"Cancel","close":"Close","closing":"Closing..."},"detail":{"workOrderInformation":"Work Order Information","assignments":"Assignments","statusSummary":"Status Summary","existingWorkOrders":"Existing Work Order(s):","created":"Created","proceedCreateNew":"Do you still want to proceed with creating a new Work Order?","loadingTechnicians":"Loading technicians...","feedbackBy":"Feedback By","overallSatisfaction":"Overall Satisfaction","overallRatingPreview":"Overall Rating Preview","uploading":"Uploading...","uploadOpeningFile":"Upload Opening File","uploadClosingFile":"Upload Closing File","noAttachment":"No attachment","noClosingAttachment":"No closing attachment","closingAttachment":"Closing Attachment","currentState":"Current State","loadingActions":"Loading actions...","actionResults":"Action Results:","checkingFeedback":"Checking feedback...","yourRating":"Your Rating","repairStatus":"Repair Status","priority":"Priority","lastModified":"Last Modified","documentStatus":"Document Status","loadingActivity":"Loading activity...","added":"Added:","removed":"Removed:","modified":"Modified:","items":"item(s)","rows":"row(s)","pleaseAllowPopupsServiceReport":"Please allow popups for this site to print the Service Report.","pleaseProvideAtLeastOneRating":"Please provide at least one rating","feedbackSubmittedSuccessfully":"Feedback submitted successfully!","failedToSubmitFeedback":"Failed to submit feedback","feedbackUpdatedSuccessfully":"Feedback updated successfully!","failedToUpdateFeedback":"Failed to update feedback","locationAutoSetTo":"Location auto-set to: {{location}}","noTechniciansSelected":"No technicians selected","techniciansAssignedSuccessfully":"{{count}} additional technician(s) assigned successfully","removedTechnician":"Removed {{name}}","itemAlreadyAdded":"Item \\"{{itemCode}}\\" is already added in row {{row}}. Please select a different item.","insufficientStock":"Insufficient stock for {{itemCode}}. Available: {{available}}, Required: {{required}}","pleaseEnterSerialNumberToSearch":"Please enter a serial number to search","assetFound":"Asset found: {{name}}","noAssetFoundWithSerialNumber":"No asset found with this serial number","fileSizeExceeds":"File size exceeds 10MB limit","fileUploadedSuccessfully":"File uploaded successfully","failedToUploadFile":"Failed to upload file","attachmentRemoved":"Attachment removed","failureDateSetToCurrentTime":"Failure Date set to current time","firstRespondedOnSetToCurrentTime":"First Responded On set to current time","completionDateSetToCurrentTime":"Completion Date set to current time","firstRespondedOnSetTo":"First Responded On set to {{datetime}}","completionDateSetTo":"Completion Date set to {{datetime}}","assignedSupervisorMandatory":"Assigned Supervisor is mandatory for Work Control role.","assignedEngineerMandatory":"Assigned Engineer is mandatory for Work Control role.","assignedTechnicianMandatory":"Assigned Technician is mandatory when workflow is \\"Sent to Engineer\\".","workOrderCancelledSuccessfully":"Work Order cancelled successfully!","failedToCancel":"Failed to cancel: {{error}}","workOrderDeletedSuccessfully":"Work Order deleted successfully!","failedToDelete":"Failed to delete: {{error}}","pleaseSelectWorkOrderType":"Please select a Work Order Type","workOrderUpdatedSuccessfully":"Work order updated successfully!","workOrderCreatedSuccessfully":"Work order created successfully!","workOrderCreatedFromAssetSuccessfully":"Work order created from asset successfully!","workOrderDuplicatedSuccessfully":"Work order duplicated successfully!","documentModifiedByAnotherUser":"Document was modified by another user. Refreshing...","pleaseReviewLatestChanges":"Please review the latest changes and try saving again.","failedToSaveWorkOrder":"Failed to save work order: {{error}}","technicalReportMandatoryForSupervisor":"Technical Report is mandatory when sending directly to Supervisor. Please fill in the Technical Report field before proceeding.","applyingAction":"Applying action \\"{{action}}\\"...","assignedTo":"Assigned to: {{name}}","actionCompletedSuccessfully":"Action \\"{{action}}\\" completed successfully!","documentModifiedRefreshing":"Document was modified. Refreshing...","tryActionAgainAfterReview":"Please try the action again after reviewing the latest changes.","failedToApplyAction":"Failed to apply action \\"{{action}}\\". {{error}}","editModeEnabled":"Edit mode enabled","editCancelledChangesDiscarded":"Edit cancelled - changes discarded","closingAttachmentRemoved":"Closing attachment removed","closingAttachmentUploadedSuccessfully":"Closing attachment uploaded successfully","failedToUploadClosingAttachment":"Failed to upload closing attachment","newStockItemRowAdded":"New stock item row added","stockItemRemoved":"Stock item {{item}} removed","activityLogRefreshed":"Activity log refreshed","errorLabel":"Error","backToList":"Back to work orders list","duplicateWorkOrder":"Duplicate Work Order","createFromAsset":"Create Work Order from Asset","newWorkOrder":"New Work Order","workOrderDetails":"Work Order Details","existingWorkOrderFound":"Existing Work Order Found","workOrderExistsForAsset":"A Work Order already exists for this Asset with workflow state not yet Approved or Closed.","workOrderExistsForTypeAndRoom":"A Work Order already exists for this Work Order Type and Room No with workflow state not yet Approved or Closed.","proceedWithNewWO":"Do you still want to proceed with creating a new Work Order?","proceedAnyway":"Proceed Anyway","noGoBack":"No, Go Back","yesCancel":"Yes, Cancel","cancelling":"Cancelling...","deleting":"Deleting...","selectAdditionalTechnicians":"Select Additional Technicians","searchTechnicians":"Search technicians...","techniciansSelected":"{{count}} technician(s) selected","clearAll":"Clear all","noTechniciansMatchSearch":"No technicians match your search","noTechniciansFound":"No technicians found","hospital":"Hospital","technicalDepartment":"Technical Department","woType":"WO Type","assetId":"Asset ID","assetName":"Asset Name","extensionNo":"Extension No","building":"Building","departmentName":"Department Name","roomNo":"Room No","location":"Location","manufacturer":"Manufacturer","supplier":"Supplier","assignedSupervisor":"Assigned Supervisor","assignedEngineer":"Assigned Engineer","assignedTechnician":"Assigned Technician","fromAsset":"From Asset","assetDetailsAutoPopulated":"Asset details auto-populated","selectBuildingFirst":"Select Building first to enable Department","printServiceReport":"Print Service Report","removeAttachment":"Remove attachment","removeClosingAttachment":"Remove closing attachment","setToCurrentDateTime":"Set to current date & time","selectItem":"Select Item","selectWarehouse":"Select Warehouse","autoPopulatedFromStock":"Auto-populated from stock","removeItem":"Remove item","noItemsAddedYet":"No items added yet","commentsDiscussion":"Comments & Discussion","refreshActivityLog":"Refresh activity log","supervisorsAvailableForType":"{{count}} Assigned Supervisor(s) available for this type","civilWorkCategory":"Civil Work Category","selectCivilWorkCategory":"Select Civil Work Category","selectPendingReason":"Select Pending Reason","pleaseSpecifyReason":"Please specify the reason...","selectServiceAgreement":"Select Service Agreement","selectServiceCoverage":"Select Service Coverage","describeComplaint":"Describe the nature of complaint...","describeWorkPerformed":"Describe the work performed...","enterSerialNumber":"Enter serial number","searchAssetBySerial":"Search asset by serial number","workOrder":"Work Order:","giveFeedback":"Give Feedback","editFeedback":"Edit Feedback","feedbackDetails":"Feedback Details","confirmAssignment":"Confirm Assignment","notRated":"Not rated","serviceReport":"Service Report","assetInfoPrefilled":"Asset information has been pre-filled from","linkedFromAsset":"Linked from Asset:","loadingAssetDetails":"Loading asset details...","cancelled":"Cancelled","workOrderId":"Work Order ID","pendingReason":"Pending Reason","otherReason":"Other Reason","serviceAgreementDetails":"Service Agreement Details","siteContractor":"Site Contractor","subcontractor":"Subcontractor","model":"Model","description":"Description","natureOfComplaint":"Nature of Complaint","technicalReport":"Technical Report","selectWoTypeFirstForSupervisors":"Select Work Order Type first to filter Assigned Supervisors","noSupervisorsFound":"No Assigned Supervisors found for this Work Order Type","requiredForExistingWO":"* Required for existing Work Orders","selectWoTypeFirstForEngineers":"Select Work Order Type first to filter Engineers","noEngineersFound":"No Engineers (Contractor Engineer role) found for this Work Order Type","engineersAvailable":"{{count}} Engineer(s) available","selectWoTypeFirstForTechnicians":"Select Work Order Type first to filter Technicians","noTechniciansFoundForType":"No Technicians found for this Work Order Type","techniciansAvailable":"{{count}} Technician(s) available","requiredForSentToEngineer":"* Required for \\"Sent to Engineer\\" state","autoCalculated":"(Auto-calculated)","autoSetOnRepairStart":"(Auto-set on repair start)","autoSetOnClose":"(Auto-set on close)","totalItems":"Total Items:","confirmAction":"Confirm Action","confirmActionMessage":"Are you sure you want to {{action}} this work order?","processing":"Processing...","yesAction":"Yes, {{action}}","systemManagerNote":"System Manager: Showing all valid actions for this state (conditions evaluated).","saveToSeeActions":"Save your changes to see all available actions.","availableActions":"Available Actions","allOptionsAvailable":"All Options Available","bothFilledMessage":"Both Technician and Technical Report are filled. You can now use any available workflow action above.","technicianAssigned":"Technician Assigned","assignedTechnicianLabel":"Assigned Technician:","wantToEnableSendToSupervisor":"Want to also enable \\"Send to Supervisor\\"?","fillTechnicalReportToUnlock":"Fill the \\"Technical Report\\" field to unlock this option","technicalReportFilled":"Technical Report Filled","howWasService":"How was the service for this work order?","noFeedbackYet":"No feedback has been given yet","statusInfoAfterCreation":"Status information will appear after creation","activityLog":"Activity Log","refreshActivityLogTitle":"Refresh activity log","noChangesRecorded":"No changes recorded yet","createdThisWorkOrder":"Created this Work Order","showLess":"Show Less","showAll":"Show All","entries":"entries","changedFrom":"changed from","documentUpdated":"Document updated","addItem":"Add Item","addFirstItem":"+ Add first item","item":"Item","valuationRate":"Valuation Rate","warehouse":"Warehouse","consumedQty":"Consumed Qty","availableStock":"Available Stock","totalValue":"Total Value","action":"Action","open":"Open","autoGenerated":"Auto-generated","updating":"Updating...","submitting":"Submitting...","updateFeedback":"Update Feedback","submitFeedback":"Submit Feedback","editRating":"Edit Rating","saveSelection":"Save Selection"}}`),Q4={title:"Asset Maintenance",maintenanceLogs:"Maintenance Logs",maintenanceDetails:"Maintenance Details",addMaintenance:"Add New Maintenance",listTotal:"Total: {{count}} maintenance log ",apiNotAvailable:"Maintenance API Not Available",apiNotDeployed:"The Asset Maintenance API endpoint is not deployed yet.",tryCreatingNew:"Try Creating New (Demo)",deletedSuccessfully:"Maintenance log deleted successfully!",status:{planned:"Planned",completed:"Completed",overdue:"Overdue",cancelled:"Cancelled"},maintenanceTeam:"Maintenance Team",newMaintenanceTeam:"New Maintenance Team",teamId:"Team ID",teamName:"Team Name",managerEmail:"Manager Email",managerName:"Supervisor Name",expertise:"Expertise",selectTeam:"Select Team",viewDetails:"View Details",editTeam:"Edit Team",duplicateTeam:"Duplicate Team",deleteTeam:"Delete Team",selectHospital:"Select Hospital",selectExpertise:"Select Expertise",selectManager:"Select Manager",enterTeamName:"Enter Team Name",teamInformation:"Team Information",selectUser:"Select User",selectRole:"Select Role",totalMembers:"Total Members",teamSummary:"Team Summary",addFirstMember:"Add First Member",manager:"Supervisor Email",loadingTeams:"Loading maintenance teams...",errorLoadingTeams:"Error Loading Maintenance Teams",deleteConfirmMessage:"Are you sure you want to delete this maintenance team? This action cannot be undone.",team:"Team",deleteTeamButton:"Delete Team",listTitle:"Maintenance Teams",statsTotalTeams:"Total Teams",statsManagers:"Managers",statsHospitals:"Hospitals",export:{title:"Export Maintenance Teams",selectData:"Select Data to Export",selectedRows:"Selected Rows",selectedCount:"Export {{count}} selected team ",currentPage:"Current Page",currentPageCount:"Export {{count}} team on current page",allWithFilters:"All Records (with current filters)",allWithFiltersCount:"Export all {{count}} team matching current filters",exportFormat:"Export Format",csv:"CSV",csvDesc:"Comma-separated values",excel:"Excel",excelDesc:"XLSX spreadsheet",columnsToExport:"Columns to Export",selectAll:"Select All",resetToDefault:"Reset to Default",columnsSelected:"{{count}} column selected",exporting:"Exporting...",exportButton:"Export",exportingSelected:"Exporting {{count}} selected row ",exportingPage:"Exporting {{count}} row from current page",exportingAll:"Exporting all {{count}} row "}},e3={title:"PPM",ppmDetails:"PPM Details",addPPM:"Add New PPM",periodicity:"Periodicity",dueDate:"Due Date",manageSchedules:"Manage PM Schedules",pmId:"PM ID",name:"Name",manufacturer:"Manufacturer",listTotal:"Total: {{count}} PPM schedule ",searchPlaceholder:"Search by ID, asset, company...",filterByCompany:"Filter by Company",company:"Company",asset:"Asset",assetType:"Asset Type",frequency:"Frequency",noOfPMs:"No. of PMs",totalAmount:"Total Amount",apiNotAvailable:"PPM API Not Available",apiNotDeployed:"The PPM API endpoint is not deployed yet.",tryCreatingNew:"Try Creating New (Demo)",deletedSuccessfully:"PPM schedule deleted successfully!",noSchedulesFound:"No PPM schedules found",createFirstSchedule:"Create your first PPM schedule",confirmDelete:"Confirm Delete",deleteConfirmMessage:"Are you sure you want to delete this PPM schedule? This action cannot be undone.",detail:{duplicateSchedule:"Duplicate PPM Schedule",newSchedule:"New PPM Schedule",scheduleDetails:"PPM Schedule Details",basicInformation:"Basic Information",financialInformation:"Financial Information",scheduleInformation:"Schedule Information",maintenanceTeam:"Maintenance Team",numberOfPMs:"Number of PMs",pricePerPM:"Price per PM",frequencyPlaceholder:"e.g., Monthly, Quarterly, Yearly",scheduleInfoAfterCreation:"Schedule information will appear after creation",assetName:"Asset Name",pleaseEnterAssetName:"Please enter Asset Name",duplicatedSuccessfully:"PPM schedule duplicated successfully!",createdSuccessfully:"PPM schedule created successfully!",updatedSuccessfully:"PPM schedule updated successfully!",failedToSave:"Failed to save",saveChanges:"Save Changes",loadingSchedule:"Loading PPM schedule...",backToSchedules:"Back to PPM schedules",errorLoading:"Error"}},t3={listTitle:"PPM Schedules",export:{title:"Export PPM Schedules",selectData:"Export Scope",selectedRows:"Selected Rows",selectedCount:"Export {{count}} selected schedule ",currentPage:"Current Page",currentPageCount:"Export {{count}} schedule on current page",allWithFilters:"All Records (with current filters)",allWithFiltersCount:"Export all {{count}} schedule matching current filters",csvDesc:"Comma-separated values",excelDesc:"XLSX spreadsheet",columnsToExport:"Columns to Export",selectAll:"Select All",resetToDefault:"Reset to Default",columnsSelected:"{{count}} column selected",exporting:"Exporting...",exportButton:"Export",exportingSelected:"Exporting {{count}} selected row ",exportingPage:"Exporting {{count}} row from current page",exportingAll:"Exporting all {{count}} row "}},a3={title:"Export",whatToExport:"What to Export",selectedRows:"Selected Rows",currentPage:"Current Page",allWithFilters:"All with Filters",exportSelected:"Export {count} selected",exportPage:"Export {count} on current page",exportAll:"Export all {count}",columnsToExport:"Columns to Export",selectAll:"Select All",selectDefault:"Select Default",exporting:"Exporting...",exportingSelected:"Exporting {count} selected row(s)",exportingPage:"Exporting {count} row(s) from current page",exportingAll:"Exporting all {count} row(s)",selected:"selected",rows:"rows"},r3={title:"Items",itemDetails:"Item Details",newItem:"New Item",addItem:"Add New Item",itemId:"Item ID",itemCode:"Item Code",itemName:"Item Name",itemGroup:"Item Group",stockUOM:"Stock UOM",partDescription:"Part Description",brand:"Brand",valuationRate:"Valuation Rate",openingStock:"Opening Stock",lastCalibrationDate:"Last Calibration Date",nextCalibrationDate:"Next Calibration Date",selectItem:"Select Item",selectItemGroup:"Select Item Group",selectHospital:"Select Hospital",serialNo:"Serial No",dateIn:"Date In",watts:"Watts",volts:"Volts",type:"Type",code:"Code",viewDetails:"View Details",editItem:"Edit Item",duplicateItem:"Duplicate Item",deleteItem:"Delete Item",technicalDepartment:"Technical Department",selectTechnicalDepartment:"Select Technical Department",basicInformation:"Basic Information",inventoryDetails:"Inventory Details",stockInformation:"Stock Information",isStockItem:"Is Stock Item",isFixedAsset:"Is Fixed Asset",balanceQty:"Balance Qty",calibrationInformation:"Calibration Information",additionalInformation:"Additional Information",refreshBalanceQty:"Refresh Balance Qty",warrantyMonths:"Warranty (Months)",errorLoadingItems:"Error Loading Items",loadingItems:"Loading items...",deleteConfirmMessage:"Are you sure you want to delete this item? This action cannot be undone.",backToInventory:"Back to Inventory",loadingItem:"Loading item...",errorLoadingItem:"Error Loading Item",createNewItem:"Create a new item",itemCodeLabel:"Item Code",itemUpdatedSuccessfully:"Item updated successfully!",pleaseSaveFirst:"Please save the item first before submitting.",submittedSuccessfully:"Item submitted successfully!",failedToSave:"Failed to save",failedToSubmit:"Failed to submit",noItemsFound:"No items found",createFirstItem:"Create your first item",listTitle:"Inventory",listTotal:"Total: {{count}} item ",failedToLoadItems:"Failed to load items.",listAddItem:"Add Item",export:{title:"Export Items",selectData:"Select Data to Export",selectedRows:"Selected Rows",selectedCount:"Export {{count}} selected item ",currentPage:"Current Page",currentPageCount:"Export {{count}} item on current page",allWithFilters:"All Records (with current filters)",allWithFiltersCount:"Export all {{count}} item matching current filters",csvDesc:"Comma-separated values",excelDesc:"XLSX spreadsheet",columnsToExport:"Columns to Export",selectAll:"Select All",resetToDefault:"Reset to Default",columnsSelected:"{{count}} column selected",exporting:"Exporting...",exportButton:"Export",exportingSelected:"Exporting {{count}} selected row ",exportingPage:"Exporting {{count}} row from current page",exportingAll:"Exporting all {{count}} row "}},s3={title:"Issues",issueDetails:"Issue Details",newIssue:"New Issue",addIssue:"Add New Issue",issueId:"Issue ID",subject:"Subject",raisedBy:"Raised By",contact:"Contact",issueType:"Issue Type",openingDate:"Opening Date",resolutionDate:"Resolution Date",resolvedBy:"Resolved By",firstRespondedOn:"First Responded On",resolutionDetails:"Resolution Details",selectIssue:"Select Issue",allPriorities:"All Priorities",allCompanies:"All Companies",viewDetails:"View Details",editIssue:"Edit Issue",deleteIssue:"Delete Issue",enterSubject:"Enter issue subject",selectPriority:"Select priority",selectIssueType:"Select issue type",describeIssue:"Describe the issue in detail...",contactInformation:"Contact Information",createNewIssue:"Create a new support issue",resolution:"Resolution",describeResolution:"Describe how the issue was resolved...",selectCompany:"Select company",statusInformation:"Status Information",currentStatus:"Current Status",timeline:"Timeline",loadingIssues:"Loading issues...",errorLoadingIssues:"Error Loading Issues",deleteConfirmMessage:"Are you sure you want to delete this issue? This action cannot be undone.",deletedSuccessfully:"Issue deleted successfully!",listTitle:"Support Issues",listTotal:"Total",listSelected:"selected",statsTotalIssues:"Total Issues",statsOpen:"Open",statsResolved:"Resolved",statsClosed:"Closed",export:{title:"Export Issues",selectData:"Select Data to Export",selectedRows:"Selected Rows",selectedCount:"Export {{count}} selected issue ",currentPage:"Current Page",currentPageCount:"Export {{count}} issue on current page",allWithFilters:"All Records (with current filters)",allWithFiltersCount:"Export all {{count}} issue matching current filters",exportFormat:"Export Format",csv:"CSV",csvDesc:"Comma-separated values",excel:"Excel",excelDesc:"XLSX spreadsheet",columnsToExport:"Columns to Export",selectAll:"Select All",resetToDefault:"Reset to Default",columnsSelected:"{{count}} column selected",exporting:"Exporting...",exportButton:"Export",exportingSelected:"Exporting {{count}} selected row ",exportingPage:"Exporting {{count}} row from current page",exportingAll:"Exporting all {{count}} row "},status:{open:"Open",replied:"Replied",on_hold:"On Hold",resolved:"Resolved",closed:"Closed"},priority:{low:"Low",medium:"Medium",high:"High",critical:"Critical"}},n3={title:"Users",userDetails:"User Details",newUser:"New User",addUser:"Add New User",searchUsers:"Search users...",manageUsers:"Manage user accounts and permissions",noUsersFound:"No users found",tryAdjustingSearch:"Try adjusting your search terms.",noUsersAvailable:"No users available.",backToDashboard:"Back to Dashboard",refresh:"Refresh",active:"Active",inactive:"Inactive",noEmail:"No email",created:"Created"},i3={title:"Events",eventDetails:"Event Details",newEvent:"New Event",addEvent:"Add New Event",upcomingEvents:"Upcoming Events",eventsFromFrappe:"Events from your Frappe backend",noEventsFound:"No events found",noEventsScheduled:"No events are currently scheduled.",refreshEvents:"Refresh Events"},o3={previous:"Previous",next:"Next",goTo:"Go to",go:"Go",page:"Page",showingToOf:"Showing {{start}} to {{end}} of {{total}} {{label}}",showingTo:"Showing {{start}} to {{end}} {{label}}",items:"items",assets:"assets",workOrders:"work orders",issues:"issues",teams:"teams",inspections:"inspections",plans:"plans"},l3={loading:"Loading...",noResultsFound:"No results found",createNewDoctype:"Create New {{doctype}}",selectLabel:"Select {{label}}"},c3={loadingSupportPlans:"Loading support plans...",errorLoadingSupportPlans:"Error Loading Support Plans",deleteConfirmMessage:"Are you sure you want to delete this support plan? This action cannot be undone.",planId:"Plan ID",deletedSuccessfully:"Support Plan deleted successfully!",deleteSupportPlan:"Delete Support Plan",noSupportPlansFound:"No support plans found",createFirstSupportPlan:"Create your first support plan",table:{planName:"Plan Name",type:"Type",frequency:"Frequency",contractValue:"Contract Value",warrantyStatus:"Warranty Status",contractStatus:"Contract Status"},status:{active:"Active",expired:"Expired",pending:"Pending",terminated:"Terminated"},statusLabel:{warrantyPrefix:"W:",contractPrefix:"C:"},viewDetails:"View Support Plan",editSupportPlan:"Edit Support Plan",listTitle:"Support Plans",statsTotalPlans:"Total Plans",statsContracts:"Contracts",statsWarranties:"Warranties",statsActive:"Active",export:{title:"Export Support Plans",selectData:"Select Data to Export",selectedRows:"Selected Rows",selectedCount:"Export {{count}} selected plan ",currentPage:"Current Page",currentPageCount:"Export {{count}} plan on current page",allWithFilters:"All Records (with current filters)",allWithFiltersCount:"Export all {{count}} plan ",exportFormat:"Export Format",csv:"CSV",csvDesc:"Comma-separated values",excel:"Excel",excelDesc:"XLSX spreadsheet",columnsToExport:"Columns to Export",selectAll:"Select All",resetToDefault:"Reset to Default",columnsSelected:"{{count}} column selected",exporting:"Exporting...",exportButton:"Export",exportingSelected:"Exporting {{count}} selected row ",exportingPage:"Exporting {{count}} row from current page",exportingAll:"Exporting all {{count}} row "}},d3={title:"Inspections",loadingInspections:"Loading inspections...",errorLoadingInspections:"Error Loading Inspections",deleteConfirmMessage:"Are you sure you want to delete this inspection? This action cannot be undone.",inspectionId:"Inspection ID",deleteInspection:"Delete Inspection",deletedSuccessfully:"Inspection deleted successfully!",noInspectionsFound:"No inspections found",createFirstInspection:"Create your first inspection",type:"Inspection Type",workflowStateHeader:"Workflow State",targetDate:"Target Date",requestedBy:"Requested By",linkedWorkOrder:"Linked Work Order",savedFilters:"Saved Filters",newInspection:"New Inspection",inspectionReport:"Inspection Report",technicalDepartment:"Technical Department",filterStatus:"Status",filterWorkflow:"Workflow",filterType:"Type",filterWorkOrder:"Work Order",filterDepartment:"Department",selectWorkOrder:"Select Work Order",selectDepartment:"Select Department",stats:{draft:"Draft",pendingApproval:"Pending Approval",closed:"Closed"},status:{open:"Open",in_progress:"In Progress",pending_review:"Pending Review",closed:"Closed"},workflowState:{draft:"Draft",sent_to_work_control:"Sent to Work Control",sent_to_technician:"Sent to technician",sent_to_supervisor:"Sent to Supervisor",closed:"Closed"},typeMap:{inspection:"Inspection",safety_inspection:"Safety Inspection"},viewDetails:"View Details",editInspection:"Edit Inspection",export:{title:"Export Inspections",selectData:"Select Data to Export",extensionNo:"Extension No",department:"Department",location:"Location",assignedTechnician:"Assigned Technician",selectedRows:"Selected Rows",selectedCount:"Export {{count}} selected inspection(s)",currentPage:"Current Page",currentPageCount:"Export {{count}} inspection(s) on current page",allWithFilters:"All Records (with current filters)",allWithFiltersCount:"Export all {{count}} inspection(s) matching current filters",exportFormat:"Export Format",csv:"CSV",csvDesc:"Comma-separated values",excel:"Excel",excelDesc:"XLSX spreadsheet",columnsToExport:"Columns to Export",selectAll:"Select All",resetToDefault:"Reset to Default",columnsSelected:"{{count}} column(s) selected",exporting:"Exporting...",exportButton:"Export",exportingSelected:"Exporting {{count}} selected row(s)",exportingPage:"Exporting {{count}} row(s) from current page",exportingAll:"Exporting all {{count}} row(s)",inspectionId:"Inspection ID",inspectionType:"Inspection Type",status:"Status",workflowState:"Workflow State",inspectionDate:"Inspection Date",targetClosureDate:"Target Closure Date",requestedBy:"Requested By",technicalDepartment:"Technical Department",linkedWorkOrder:"Linked Work Order",observationNote:"Observation Note",technicalResponse:"Technical Response",createdOn:"Created On",modifiedOn:"Modified On",createdBy:"Created By"},detail:{loadingDetails:"Loading inspection details...",errorLoading:"Error Loading Inspection",backToList:"Back to Inspections",newInspection:"New Inspection",inspectionDetails:"Inspection Details",createNewRecord:"Create a new inspection record",cancelInspection:"Cancel Inspection",cancelConfirmMessage:"Are you sure you want to cancel this inspection? This will mark the inspection as cancelled and you can then delete it if needed.",noGoBack:"No, Go Back",yesCancel:"Yes, Cancel",cancelling:"Cancelling...",selectType:"Select Type",workOrderType:"Work Order Type",selectWorkOrderType:"Select Work Order Type",techniciansAvailable:"{{count}} Technician(s) available for this type",selectDepartment:"Select Department",selectLocation:"Select Location",extensionNo:"Extension No *",selectExtension:"Select Extension",inspectionDate:"Inspection Date",targetClosureDate:"Target Closure Date",cannotBeInPast:"Cannot be in the past",cannotBeEarlier:"Cannot be earlier than Inspection Date or in the past",openingAttachment:"Opening Attachment",closingAttachment:"Closing Attachment",uploading:"Uploading...",uploadFile:"Upload File",uploadClosingFile:"Upload Closing File",noAttachment:"No attachment",removeAttachment:"Remove attachment",assignmentInformation:"Assignment Information",requestedBy:"Requested By",selectUser:"Select User",technicalDepartment:"Technical Department",assignedTechnician:"Assigned Technician",selectTechnician:"Select Technician",selectWOTypeFirst:"Select Work Order Type first to filter Technicians",noTechniciansForType:"No Technicians found for this Work Order Type",notesAndResponse:"Notes & Response",observationNote:"Observation Note",placeholderObservation:"Enter observation notes...",technicalResponse:"Technical Response",placeholderTechnicalResponse:"Enter technical response...",linkedWorkOrder:"Linked Work Order",linkedCorrectiveWO:"Linked Corrective Work Order",readOnly:"Read-only",viewWorkOrder:"View Work Order",noLinkedWorkOrder:"No linked work order",workflowActions:"Workflow Actions",workflowProgress:"Workflow Progress",workControl:"Work Control",technicianStep:"Technician",supervisorStep:"Supervisor",draftStep:"Draft",closedStep:"Closed",statusInfo:"Status Info",documentStatus:"Document Status",woType:"WO Type",assignedTo:"Assigned To",submitted:"Submitted",cancelled:"Cancelled",added:"Added:",removed:"Removed:",modified:"Modified:",items:"item(s)",rows:"row(s)",activityLog:"Activity Log",activityLogRefreshed:"Activity log refreshed",refreshActivityLog:"Refresh activity log",noChangesRecorded:"No changes recorded yet",createdThisInspection:"Created this Inspection",changedFrom:"changed from",documentUpdated:"Document updated",showLess:"Show Less",showAll:"Show All",department:"Department",location:"Location",inspectionType:"Inspection Type",status:"Status",removeClosingAttachment:"Remove closing attachment",noClosingAttachment:"No closing attachment",cancelledSuccessfully:"Inspection cancelled successfully!",failedToCancel:"Failed to cancel: {{error}}",failedToSave:"Failed to save: {{error}}",failedToDelete:"Failed to delete: {{error}}",targetClosureMandatory:"Target Closure Date is mandatory to save.",attachmentMandatory:"Attachment is mandatory to save.",extensionMandatory:"Extension No is mandatory to save.",createdSuccessfully:"Inspection created successfully!",updatedSuccessfully:"Inspection updated successfully!",deletedSuccessfully:"Inspection deleted successfully!",inspectionDateInPast:"Inspection Date cannot be in the past.",targetClosureEarlier:"Target Closure Date cannot be earlier than Inspection Date.",targetClosureInPast:"Target Closure Date cannot be in the past.",fileSizeExceeds:"File size exceeds 10MB limit",fileUploadedSuccess:"File uploaded successfully",failedToUpload:"Failed to upload file",closingAttachmentRemoved:"Closing attachment removed",closingAttachmentUploadedSuccess:"Closing attachment uploaded successfully",failedToUploadClosing:"Failed to upload closing attachment",attachmentRemoved:"Attachment removed",systemManager:"System Manager",workflow:"Workflow"}},u3={title:"Active Map",loading:"Loading map data...",hospital:"Hospital",departmentWoType:"Department (Work Order Type)",selectHospital:"Select hospital",selectDepartment:"Select department",clearDepartmentHint:"Clear department to filter by hospital",clearHospitalHint:"Clear hospital to filter by department",clearFilters:"Clear Filters",legendHospital:"Hospital",legendDepartment:"Department (WO Type)",legendHasUrgent:"Has Urgent WOs",totalAssets:"Total Assets",workOrderStatus:"Work Order Status",status:"Status",count:"Count",normal:"Normal",urgent:"Urgent",open:"Open",workInProgress:"Work In Progress",pendingReview:"Pending Review",completed:"Completed",closed:"Closed",preventiveMaintenance:"Preventive Maintenance",planned:"Planned",overdue:"Overdue",viewAssets:"View Assets",viewWorkOrders:"View Work Orders",viewAllWorkOrders:"View All Work Orders",showingWorkOrdersByType:"Showing Work Orders by Type",deptWoType:"Department / Work Order Type",tooltipDept:"Dept",tooltipHospital:"Hospital",tooltipUrgent:"URGENT! ",normalWos:"Normal WOs:",urgentWos:"Urgent WOs:",closedWos:"Closed WOs:",plannedPms:"Planned PMs:",completedPms:"Completed PMs:",assets:"Assets"},m3={title:"Maintenance Calendar",viewType:"View Type",maintenanceLog:"Maintenance Log",ppmPlanner:"PPM Planner",filters:"Filters",yearlyMap:"Yearly Map",yearlyMapTitle:"View Yearly PPM Planner Map",mapShort:"Map",hospital:"Hospital",selectHospital:"Select Hospital",department:"Department",allDepartments:"All Departments",status:"Status",allStatuses:"All Statuses",planned:"Planned",completed:"Completed",overdue:"Overdue",cancelled:"Cancelled",assignedTo:"Assigned To",allTechnicians:"All Technicians",clearFilters:"Clear Filters",months:{january:"January",february:"February",march:"March",april:"April",may:"May",june:"June",july:"July",august:"August",september:"September",october:"October",november:"November",december:"December"},days:{sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"},previousMonth:"Previous Month",today:"Today",nextMonth:"Next Month",loadingLogs:"Loading maintenance logs...",loadingPpm:"Loading PPM Planners...",overdueInTooltip:"(Overdue)",clickToViewDetails:"Click to view details",clickToViewPpmPlanner:"Click to view PPM Planner",ppmPlannerDefault:"PPM Planner",legendCompleted:"Completed",legendPlanned:"Planned",legendOverdue:"Overdue",legendToday:"Today",summaryPpmPlanners:"PPM Planners"},h3={common:W4,sidebar:V4,login:q4,dashboard:G4,commonFields:Y4,filters:Z4,listPages:J4,assets:X4,workOrders:K4,maintenance:Q4,ppm:e3,ppmPlanner:t3,exportModal:a3,items:r3,issues:s3,users:n3,events:i3,pagination:o3,linkField:l3,supportPlans:c3,inspections:d3,activeMap:u3,maintenanceCalendarPage:m3},g3={dashboard:"لوحة التحكم",assets:"الأصول",workOrders:"أوامر العمل",maintenance:"صيانة الأصول",ppm:"الصيانة الوقائية",logout:"تسجيل الخروج",login:"تسجيل الدخول",email:"البريد الإلكتروني",password:"كلمة المرور",submit:"إرسال",cancel:"إلغاء",save:"حفظ",saveChanges:"حفظ التغييرات",delete:"حذف",deleting:"جاري الحذف...",edit:"تعديل",create:"إنشاء",search:"بحث",filter:"تصفية",export:"تصدير",import:"استيراد",loading:"جاري التحميل...",noData:"لا توجد بيانات",error:"خطأ",success:"نجح",darkMode:"الوضع الداكن",lightMode:"الوضع الفاتح",language:"اللغة",english:"الإنجليزية",arabic:"العربية",backToDashboard:"العودة إلى لوحة التحكم",back:"رجوع",saving:"جاري الحفظ...",tryAgain:"حاول مرة أخرى",filters:"المرشحات",enterFilterName:"أدخل اسم المرشح",saveFilterPreset:"حفظ مجموعة المرشحات",saveFilter:"حفظ المرشح",filtering:"جاري التصفية...",updating:"جاري التحديث...",clearFilters:"مسح المرشحات",total:"الإجمالي",selected:"محدد",rows:"صفوف",actions:"إجراءات",selectAllTitle:"تحديد الكل",deselectAllTitle:"إلغاء تحديد الكل",typeToSearch:"اكتب للبحث...",typing:"جاري الكتابة...",enterFilterNameExample:"أدخل اسم المرشح (مثال: 'مفتوح أولوية عالية')"},f3={title:"أصول سيرا",loggedInAs:"تم تسجيل الدخول كـ:",version:"أصول سيرا نظام إدارة الأصول الإصدار 1.0",inventory:"المخزون",ppmPlanner:"مخطط الصيانة الوقائية",maintenanceCalendar:"تقويم الصيانة",activeMap:"الخريطة النشطة",maintenanceTeam:"فريق الصيانة",procurement:"المشتريات",sla:"اتفاقية مستوى الخدمة",support:"الدعم",inspection:"التفتيش",userProfile:"الملف الشخصي"},x3={title:"أصول سيرا",subtitle:"نظام إدارة الأصول",signIn:"قم بتسجيل الدخول للمتابعة",emailPlaceholder:"أدخل بريدك الإلكتروني",passwordPlaceholder:"أدخل كلمة المرور",loginFailed:"فشل تسجيل الدخول. يرجى التحقق من بيانات الاعتماد الخاصة بك.",demoLogin:"تسجيل دخول تجريبي",or:"أو"},p3={title:"لوحة التحكم",loading:"جاري تحميل لوحة التحكم...",totalAssets:"إجمالي عدد الأصول",assetsDown:"الأصول إلى أسفل",openWorkOrders:"أوامر العمل المفتوحة",workOrdersInProgress:"أوامر العمل قيد التنفيذ",completedWorkOrders:"أوامر العمل المكتملة",totalWorkOrders:"إجمالي أوامر العمل",overdueWorkOrders:"أوامر العمل المتأخرة",closedWorkOrders:"أوامر العمل المغلقة",upTime:"وقت التشغيل",downTime:"وقت التوقف",workOrderStatus:"حالة أمر العمل",workOrderByType:"أمر العمل حسب النوع",maintenanceByAsset:"الصيانة حسب الأصل",assigneesStatus:"حالة المكلفين",assigneesCount:"المكلفون",totalTasksAssigned:"المهام المعينة",maintenanceFrequency:"تكرار الصيانة",maintenanceLogs:"سجلات الصيانة",assetUptime:"وقت تشغيل الأصل",avgResponseTime:"متوسط وقت الاستجابة",maintenanceEfficiency:"كفاءة الصيانة",overdueMaintenance:"صيانة متأخرة",upDownTimeChart:"مخطط وقت التشغيل والتوقف",ppmStatus:"حالة الصيانة الوقائية",completionRate:"معدل الإكمال",completionRateChartHint:"نسبة الإكمال خلال آخر 7 أشهر — مرر المؤشر على النقطة للتفاصيل",completionRateTooltip:"{{value}}% معدل الإكمال",viewFullReport:"عرض التقرير الكامل",noDataAvailable:"لا توجد بيانات",loadingTechnicianHours:"جاري تحميل ساعات الفنيين...",loadingTechnicianWorkData:"جاري تحميل بيانات عمل الفنيين...",welcome:"مرحباً،",user:"المستخدم",failedToLoad:"فشل تحميل بيانات لوحة التحكم",recentRecords:"السجلات الأخيرة",latestEntries:"أحدث الإدخالات من النظام الخلفي",quickActions:"إجراءات سريعة",cardTotalAssets:"إجمالي الأصول",cardOpenWorkOrders:"أوامر العمل المفتوحة",cardInProgress:"قيد التنفيذ",cardCompletedWorkOrders:"أوامر العمل المكتملة",viewUsers:"عرض المستخدمين",manageUserAccounts:"إدارة حسابات المستخدمين",settings:"الإعدادات",configurePreferences:"تكوين التفضيلات",events:"الأحداث",viewCalendarEvents:"عرض أحداث التقويم",reports:"التقارير",viewAnalyticsReports:"عرض التحليلات والتقارير",ppmTemplateCounts:"عدادات قوالب الصيانة الوقائية",repairCost:"تكلفة الإصلاح",dashboardFilter:"فلتر لوحة التحكم",allDepartments:"جميع الأقسام",workOrderStatusDistribution:"توزيع حالة أوامر العمل",workOrderInspectionSummary:"ملخص تفتيش أوامر العمل",woRejectionSummary:"ملخص رفض أوامر العمل",total:"الإجمالي",inProgress:"قيد التنفيذ",completed:"مكتمل",totalSales:"إجمالي المبيعات",average:"متوسط",noChartDataAvailable:"لا توجد بيانات للمخطط",loadingInspectionData:"جاري تحميل بيانات التفتيش...",noInspectionDataAvailable:"لا توجد بيانات تفتيش",totalRejections:"إجمالي الرفض",loadingRejectionData:"جاري تحميل بيانات الرفض...",noRejectionDataAvailable:"لا توجد بيانات رفض",department:"القسم",allOperational:"جميع الأنظمة تعمل",low:"منخفض",highPriority:"أولوية عالية",allClear:"الكل واضح",fastResponse:"استجابة سريعة",monitor:"مراقبة",onTrack:"وفق الخطة",needsAttention:"يحتاج اهتمام",totalHours:"الإجمالي: {{value}} ساعة",technicianWorkingHours:"ساعات عمل الفنيين",techniciansWorked:"ملخص عمل الفنيين",pendingReviewWorkOrders:"قيد المراجعة",clear:"مسح",clearFilter:"مسح الفلتر",label:"التسمية",open:"مفتوح"},y3={assetId:"معرف الأصل",assetName:"اسم الأصل",serialNumber:"الرقم التسلسلي",company:"الشركة/المستشفى",location:"الموقع",department:"القسم",deviceStatus:"حالة الجهاز",modality:"الطريقة",manufacturer:"الشركة المصنعة",supplier:"المورد",assetCategory:"فئة الأصل",purchaseDate:"تاريخ الشراء",purchaseAmount:"مبلغ الشراء",availableForUseDate:"تاريخ التوفر للاستخدام",createdOn:"تم الإنشاء في",modifiedOn:"تم التعديل في",createdBy:"تم الإنشاء بواسطة",modifiedBy:"تم التعديل بواسطة",workOrderId:"معرف أمر العمل",workOrderType:"النوع",status:"الحالة",priority:"الأولوية",description:"الوصف",assignedTo:"مكلف إلى",scheduledDate:"التاريخ المجدول",completedDate:"تاريخ الإكمال",hospital:"المستشفى",assetType:"نوع الأصل",siteName:"اسم الموقع",assignedSupervisor:"المشرف المعين",assignedContractor:"المقاول المعين",serialNumberShort:"الرقم التسلسلي",departmentShort:"القسم",manufacturerShort:"الشركة المصنعة",workOrderIdShort:"معرف أمر العمل",assetShort:"الأصل",typeShort:"النوع",nameShort:"الاسم",pmId:"معرف الصيانة الوقائية",name:"الاسم"},b3={filterBy:"تصفية حسب",createdDate:"تاريخ الإنشاء",latestModifiedDate:"آخر تاريخ تعديل",startDate:"تاريخ البداية",endDate:"تاريخ النهاية",assetId:"معرف الأصل",hospital:"المستشفى",name:"الاسم",serial:"الرقم التسلسلي",status:"الحالة",location:"الموقع",dept:"القسم",modality:"الطريقة",mfr:"الشركة المصنعة",supplier:"المورد",workOrderId:"معرف أمر العمل",asset:"الأصل",type:"النوع",priority:"الأولوية",workflowState:"حالة سير العمل",allStatuses:"أي حالة",allStates:"جميع الحالات",allTypes:"جميع الأنواع",allPriorities:"أي أولوية",allHospitals:"جميع المستشفيات",allModalities:"جميع الطرق",filterByCompany:"تصفية حسب الشركة",allManufacturers:"جميع الشركات المصنعة",sortBy:"ترتيب حسب",sortCreationNewest:"تاريخ الإنشاء (الأحدث أولاً)",sortCreationOldest:"تاريخ الإنشاء (الأقدم أولاً)",sortModifiedNewest:"آخر تعديل (الأحدث أولاً)",sortModifiedOldest:"آخر تعديل (الأقدم أولاً)",sortNameAsc:"الاسم (أ-ي)",sortNameDesc:"الاسم (ي-أ)",sortAssetNameAsc:"اسم الأصل (أ-ي)",sortAssetNameDesc:"اسم الأصل (ي-أ)",sortItemNameAsc:"اسم العنصر (أ-ي)",sortItemNameDesc:"اسم العنصر (ي-أ)",sortTeamNameAsc:"اسم الفريق (أ-ي)",sortTeamNameDesc:"اسم الفريق (ي-أ)"},v3={addNew:"إضافة جديد",searchPlaceholder:"بحث...",noResults:"لم يتم العثور على نتائج",showing:"عرض",of:"من",results:"نتائج",selectAll:"تحديد الكل",deselectAll:"إلغاء تحديد الكل",selected:"محدد",actions:"الإجراءات",view:"عرض",edit:"تعديل",delete:"حذف",duplicate:"نسخ",export:"تصدير",print:"طباعة",filters:"المرشحات",clearFilters:"مسح المرشحات",applyFilters:"تطبيق المرشحات",columns:"الأعمدة",exportSelected:"تصدير المحدد",exportAllOnPage:"تصدير الكل في الصفحة",exportAllWithFilters:"تصدير الكل مع المرشحات",exportFormat:"تنسيق التصدير",csv:"CSV",excel:"Excel",exporting:"جاري التصدير...",exportComplete:"اكتمل التصدير",close:"إغلاق",loading:"جاري التحميل...",refresh:"تحديث",deselectAllTitle:"إلغاء تحديد الكل",selectAllTitle:"تحديد الكل",typeToSearch:"اكتب للبحث...",enterFilterName:"أدخل اسم المرشح",enterFilterNameExample:"أدخل اسم المرشح (مثال: 'مفتوح أولوية عالية')",allStatuses:"أي حالة",savedFilters:"المرشحات المحفوظة",clear:"مسح",noIssuesFound:"لم يتم العثور على تذاكر",createFirstIssue:"أنشئ تذكرتك الأولى",saveFilterPreset:"حفظ مجموعة المرشحات",saveFilter:"حفظ المرشح",filtering:"جاري التصفية...",noMaintenanceTeamsFound:"لم يتم العثور على فرق صيانة",createFirstTeam:"أنشئ فريقك الأول",all:"الكل",tryAdjustingFilters:"حاول تعديل البحث أو المرشحات",getStartedCreateFirst:"ابدأ بإنشاء مخطط الصيانة الوقائية الأول",noMaintenanceLogsFound:"لم يتم العثور على سجلات صيانة",createFirstMaintenanceLog:"أنشئ سجل الصيانة الأول",total:"الإجمالي",noPPMSchedulesFound:"لم يتم العثور على جداول صيانة وقائية",createFirstPPMSchedule:"أنشئ جدول الصيانة الوقائية الأول",deleteConfirmCannotUndo:"لا يمكن التراجع عن هذا الإجراء."},_3={title:"الأصول",addAsset:"إضافة أصل جديد",assetDetails:"تفاصيل الأصل",assetInformation:"معلومات الأصل",newAsset:"أصل جديد",duplicateAsset:"نسخ الأصل",fromAsset:"من الأصل",creatingFromAsset:"جاري إنشاء أمر العمل من الأصل",assetInfoPrefilled:"معلومات الأصل معبأة مسبقاً من",pleaseSelectWorkOrderType:"يرجى اختيار نوع أمر العمل وإضافة أي تفاصيل",loadingAssetDetails:"جاري تحميل تفاصيل الأصل...",pleaseEnterAssetName:"يرجى إدخال اسم الأصل",pleaseSelectCategory:"يرجى اختيار الفئة",assetDuplicatedSuccessfully:"تم نسخ الأصل بنجاح!",assetCreatedSuccessfully:"تم إنشاء الأصل بنجاح!",assetUpdatedSuccessfully:"تم تحديث الأصل بنجاح!",sourceAssetNotFound:"الأصل المصدر غير موجود",assetNotFoundMessage:"لم يتم العثور على الأصل الذي تحاول نسخه.",backToAssetsList:"العودة إلى قائمة الأصول",backToList:"العودة إلى قائمة الأصول",createNewAsset:"إنشاء أصل جديد",newAssetDetails:"تفاصيل أصل جديد",noAssetsFound:"لم يتم العثور على أصول",createFirstAsset:"أنشئ أول أصل",deleteConfirmTitle:"حذف الأصل",deleteConfirmMessage:"هل أنت متأكد من حذف هذا الأصل؟ لا يمكن التراجع عن هذا الإجراء.",noDataToExport:"لا توجد بيانات للتصدير",loadingPermissions:"جاري تحميل الصلاحيات...",selectAssetId:"اختر معرف الأصل",selectHospital:"المستشفى",viewDetails:"عرض التفاصيل",editAsset:"تعديل الأصل",createWorkOrder:"إنشاء أمر عمل",viewLinkedWOs:"عرض أوامر العمل المرتبطة",moreActions:"المزيد من الإجراءات",exportAsJson:"تصدير كـ JSON",printAsset:"طباعة",deviceStatus:"حالة الجهاز",status:{up:"يعمل",down:"متوقف"},apiNotAvailable:"واجهة برمجة الأصول غير متاحة",apiNotDeployed:"نقطة نهاية واجهة برمجة الأصول غير مُنشأة بعد.",tryCreatingNew:"حاول إنشاء أصل جديد (تجريبي)",listTotal:"الإجمالي: ",table:{assetName:"اسم الأصل",serialNo:"الرقم التسلسلي",company:"الشركة",location:"الموقع",status:"الحالة",updatedOn:"آخر تحديث",actions:"إجراءات"},export:{title:"تصدير الأصول",selectData:"اختر البيانات للتصدير",selectedRows:"الصفوف المحددة",selectedCount:"تصدير {{count}} أصل{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",currentPage:"الصفحة الحالية",currentPageCount:"تصدير {{count}} أصل{{count !== 1 ? 'اً' : ''}} في الصفحة الحالية",allWithFilters:"جميع السجلات (مع الفلاتر الحالية)",allWithFiltersCount:"تصدير جميع {{count}} أصل{{count !== 1 ? 'اً' : ''}} المطابقة للفلاتر الحالية",csvDesc:"قيم مفصولة بفاصلة",excelDesc:"جدول XLSX",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",resetToDefault:"إعادة التعيين للافتراضي",columnsSelected:"{{count}} عمود{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",exporting:"جاري التصدير...",exportButton:"تصدير",exportingSelected:"جاري تصدير {{count}} صف{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",exportingPage:"جاري تصدير {{count}} صف{{count !== 1 ? 'اً' : ''}} من الصفحة الحالية",exportingAll:"جاري تصدير جميع {{count}} صف{{count !== 1 ? 'اً' : ''}}"},detail:{assetInformation:"معلومات الأصل",technicalSpecs:"المواصفات الفنية",financialDetails:"التفاصيل المالية",assetFinanceBooks:"دفاتر أصول التمويل",addRow:"إضافة صف",duplicatingFrom:"النسخ من:",noDepartmentsMapped:"لا توجد أقسام معينة لهذا المبنى",departmentsAvailable:"{{count}} قسم متاح (مُصفى حسب المبنى)",selectDepartmentForRoom:"اختر القسم لتفعيل رقم الغرفة",depreciationMethodNote:"طريقة الاستهلاك هي طريقة محاسبية لتوزيع تكلفة أصل ملموس على عمره الإنتاجي.",calculateDepreciation:"حساب الاستهلاك",noFinanceBooksYet:'لم تتم إضافة دفاتر مالية بعد. انقر "إضافة صف" للإضافة.',noSparePartsYet:'لم تتم إضافة قطع غيار بعد. انقر "إضافة صف" للإضافة.',assetName:"اسم الأصل",category:"الفئة",modality:"الطريقة",class:"الفئة",assetId:"معرف الأصل",deviceStatus:"حالة الجهاز",serialCode:"الرمز التسلسلي",technicalDepartment:"القسم الفني",manufacturer:"الشركة المصنعة",model:"الموديل",totalHours:"إجمالي الساعات",downTimeHours:"وقت التوقف (بالساعات)",upTimeHours:"وقت التشغيل (بالساعات)",placeholderAssetName:"مثال: كمبيوتر محمول موديل X",placeholderSerialCode:"مثال: SN-12345",placeholderModelNumber:"رقم الموديل",placeholderZero:"0",placeholderDescription:"وصف موجز للأصل",placeholderPONumber:"رقم أمر الشراء",selectClass:"اختر الفئة",classA:"فئة أ",classB:"فئة ب",classC:"فئة ج",autoGenerated:"يُولد تلقائياً",calculatedFromAvailableDate:"محسوب من تاريخ التوفر للاستخدام",calculatedTotalMinusDown:"محسوب: إجمالي الساعات - وقت التوقف",hospital:"المستشفى",siteName:"اسم الموقع",selectSite:"اختر الموقع",building:"المبنى",department:"القسم",roomNumber:"رقم الغرفة",location:"الموقع",selectStatus:"اختر الحالة",operational:"يعمل",underMaintenance:"قيد الصيانة",decommissioned:"مُوقف",selectServiceAgreement:"اختر اتفاقية الخدمة",warranty:"ضمان",contract:"عقد",frameWork:"إطار عمل",mainContractor:"المقاول الرئيسي",outOfWarranty:"خارج الضمان",underDismantle:"قيد التفكيك",underInstallation:"قيد التركيب",selectServiceCoverage:"اختر تغطية الخدمة",pmOnly:"صيانة وقائية فقط",labour:"عمالة",labourAndParts:"عمالة وقطع غيار",comprehensive:"شامل",supplierVendor:"المورد/البائع",selectMethod:"اختر الطريقة",straightLine:"الطريقة الخطية",doubleDecliningBalance:"الرصيد المتناقص المزدوج",writtenDownValue:"القيمة المكتوبة",manual:"يدوي",recycling:"إعادة التدوير",donation:"تبرع",sale:"بيع",assetDuplicatedSuccess:"تم نسخ الأصل بنجاح!",assetCreatedSuccess:"تم إنشاء الأصل بنجاح!",assetUpdatedSuccess:"تم تحديث الأصل بنجاح!",failedToSave:"فشل حفظ الأصل",cannotSubmitNotSaved:"لا يمكن الإرسال: الأصل غير محفوظ بعد",confirmSubmit:'هل أنت متأكد من إرسال هذا الأصل؟ بعد الإرسال، يمكن تعديل الحقول المحددة بـ "السماح عند الإرسال" فقط.',assetSubmittedSuccess:"تم إرسال الأصل بنجاح!",failedToSubmit:"فشل إرسال الأصل",pleaseSaveFirstForPPM:"يرجى حفظ الأصل أولاً لعرض خطة الصيانة الوقائية",pleaseSaveFirstForHistory:"يرجى حفظ الأصل أولاً لعرض سجل الأصل",failedToLoadPPMPlan:"فشل تحميل خطة الصيانة الوقائية. يرجى المحاولة مرة أخرى.",noPlannedMaintenance:"لم يتم العثور على صيانة مخطط لها لهذا الأصل",noWorkOrdersFound:"لم يتم العثور على أوامر عمل",noSparePartsUsed:"لم تُستخدم قطع غيار",noMaintenanceRecords:"لم يتم العثور على سجلات صيانة",noMaintenanceTasks:"لم يتم العثور على مهام صيانة",selectBuildingFirst:"اختر المبنى أولاً لتفعيل القسم",coverage:"التغطية",siteContractor:"مقاول الموقع",contractNumber:"رقم العقد",serviceAgreement:"اتفاقية الخدمة",serviceCoverage:"تغطية الخدمة",purchaseOrderNumber:"رقم أمر الشراء",grossPurchaseAmount:"مبلغ الشراء الإجمالي",purchaseDate:"تاريخ الشراء",installationDate:"تاريخ التركيب",availableForUseDate:"تاريخ التوفر للاستخدام",financeBook:"دفتر المالية",depreciationMethod:"طريقة الاستهلاك",totalDepreciations:"إجمالي الاستهلاك",frequencyMonths:"التكرار (بالأشهر)",depreciationPostingDate:"تاريخ ترحيل الاستهلاك",startDate:"تاريخ البداية",endDate:"تاريخ النهاية",totalAmount:"المبلغ الإجمالي",selectRoomFirst:"اختر رقم الغرفة لتفعيل الموقع",autoSetFromRoom:"تم التعيين تلقائياً من خريطة الغرفة",moreDetails:"تفاصيل إضافية"}},w3=JSON.parse(`{"title":"أوامر العمل","addWorkOrder":"إضافة أمر عمل جديد","workOrderDetails":"تفاصيل أمر العمل","newWorkOrder":"أمر عمل جديد","duplicateWorkOrder":"نسخ أمر العمل","createFromAsset":"إنشاء أمر عمل من الأصل","closeWorkOrders":"إغلاق أوامر العمل","closeConfirmTitle":"إغلاق أوامر العمل","closeConfirmMessage":"هل أنت متأكد من إغلاق أمر/أوامر العمل المحددة؟","deleteConfirmMessage":"هل أنت متأكد من حذف أمر العمل هذا؟ لا يمكن التراجع عن هذا الإجراء.","cancelConfirmMessage":"هل أنت متأكد من إلغاء أمر العمل هذا؟ سيتم وضع علامة ملغى ويمكنك حذفه لاحقاً إذا لزم الأمر.","assignConfirmMessage":"هل أنت متأكد من تعيين أمر العمل هذا للفني/الفنيين التاليين؟","deleteWorkOrder":"حذف أمر العمل","cancelWorkOrder":"إلغاء أمر العمل","loadingWorkOrders":"جاري تحميل أوامر العمل...","loadingDetails":"جاري تحميل تفاصيل أمر العمل...","backToList":"العودة إلى قائمة أوامر العمل","status":{"open":"مفتوح","work_in_progress":"جاري العمل","pending_review":"قيد المراجعة","completed":"مكتمل","cancelled":"ملغى","closed":"مغلق"},"priorityNormal":"عادي","priorityUrgent":"عاجل","workflowState":{"draft":"مسودة"},"priority":{"normal":"عادي","urgent":"عاجل"},"table":{"workOrderId":"معرف أمر العمل","asset":"الأصل","type":"النوع","technicalReport":"التقرير الفني","department":"القسم","workflowState":"حالة سير العمل","priority":"الأولوية","noWorkOrdersFound":"لم يتم العثور على أوامر عمل","createFirstWorkOrder":"أنشئ أول أمر عمل"},"export":{"title":"تصدير أوامر العمل","selectData":"ماذا تُصدّر","selectedRows":"الصفوف المحددة","selectedCount":"تصدير {{count}} أمر عمل{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}","currentPage":"الصفحة الحالية","currentPageCount":"تصدير {{count}} أمر عمل{{count !== 1 ? 'اً' : ''}} في الصفحة الحالية","allWithFilters":"جميع السجلات (مع الفلاتر الحالية)","allWithFiltersCount":"تصدير جميع {{count}} أمر عمل{{count !== 1 ? 'اً' : ''}} المطابقة للفلاتر الحالية","csvDesc":"قيم مفصولة بفاصلة","excelDesc":"جدول XLSX","columnsToExport":"الأعمدة للتصدير","selectAll":"تحديد الكل","resetToDefault":"إعادة التعيين للافتراضي","columnsSelected":"{{count}} عمود{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}","exporting":"جاري التصدير...","exportButton":"تصدير","exportingSelected":"جاري تصدير {{count}} صف{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}","exportingPage":"جاري تصدير {{count}} صف{{count !== 1 ? 'اً' : ''}} من الصفحة الحالية","exportingAll":"جاري تصدير جميع {{count}} صف{{count !== 1 ? 'اً' : ''}}"},"closeModal":{"title":"إغلاق أوامر العمل","confirmBulkClose":"تأكيد عملية الإغلاق الجماعي","aboutToClose":"أنت على وشك إغلاق {{count}} أمر عمل{{count !== 1 ? 'اً' : ''}}. سيتم تغيير حالة سير العمل إلى \\"مغلق\\".","alreadyClosedNote":"ملاحظة: {{count}} أمر عمل{{count !== 1 ? ' مغلقة' : ' مغلق'}} بالفعل وسيتم تخطيها.","selectedWorkOrders":"أوامر العمل المحددة ({{count}})","workOrderId":"معرف أمر العمل","currentStatus":"الحالة الحالية","workflowState":"حالة سير العمل","alreadyClosed":"(مغلق بالفعل)","willClose":"سيتم إغلاق {{count}} أمر عمل{{count !== 1 ? 'اً' : ''}}","allAlreadyClosed":"جميع أوامر العمل المحددة مغلقة بالفعل","cancel":"إلغاء","close":"إغلاق","closing":"جاري الإغلاق..."},"detail":{"workOrderInformation":"معلومات أمر العمل","assignments":"التعيينات","statusSummary":"ملخص الحالة","existingWorkOrders":"أمر/أوامر العمل الموجودة:","created":"تاريخ الإنشاء","proceedCreateNew":"هل تريد المتابعة لإنشاء أمر عمل جديد؟","loadingTechnicians":"جاري تحميل الفنيين...","feedbackBy":"التقييم بواسطة","overallSatisfaction":"رضا إجمالي","overallRatingPreview":"معاينة التقييم الإجمالي","uploading":"جاري الرفع...","uploadOpeningFile":"رفع ملف الفتح","uploadClosingFile":"رفع ملف الإغلاق","noAttachment":"لا يوجد مرفق","noClosingAttachment":"لا يوجد مرفق إغلاق","closingAttachment":"مرفق الإغلاق","currentState":"الحالة الحالية","loadingActions":"جاري تحميل الإجراءات...","actionResults":"نتائج الإجراء:","checkingFeedback":"جاري التحقق من التقييم...","yourRating":"تقييمك","repairStatus":"حالة الإصلاح","priority":"الأولوية","lastModified":"آخر تعديل","documentStatus":"حالة المستند","loadingActivity":"جاري تحميل النشاط...","added":"تمت الإضافة:","removed":"تمت الإزالة:","modified":"تم التعديل:","items":"عنصر/عناصر","rows":"صف/صفوف","pleaseAllowPopupsServiceReport":"يرجى السماح بالنوافذ المنبثقة لهذا الموقع لطباعة تقرير الخدمة.","pleaseProvideAtLeastOneRating":"يرجى تقديم تقييم واحد على الأقل","feedbackSubmittedSuccessfully":"تم إرسال التقييم بنجاح!","failedToSubmitFeedback":"فشل إرسال التقييم","feedbackUpdatedSuccessfully":"تم تحديث التقييم بنجاح!","failedToUpdateFeedback":"فشل تحديث التقييم","locationAutoSetTo":"تم تعيين الموقع تلقائياً إلى: {{location}}","noTechniciansSelected":"لم يتم تحديد فنيين","techniciansAssignedSuccessfully":"تم تعيين {{count}} فني/فنيين إضافي بنجاح","removedTechnician":"تمت إزالة {{name}}","itemAlreadyAdded":"الصنف \\"{{itemCode}}\\" مضاف بالفعل في الصف {{row}}. يرجى اختيار صنف مختلف.","insufficientStock":"مخزون غير كافٍ لـ {{itemCode}}. المتوفر: {{available}}، المطلوب: {{required}}","pleaseEnterSerialNumberToSearch":"يرجى إدخال الرقم التسلسلي للبحث","assetFound":"تم العثور على الأصل: {{name}}","noAssetFoundWithSerialNumber":"لم يتم العثور على أصل بهذا الرقم التسلسلي","fileSizeExceeds":"حجم الملف يتجاوز حد 10 ميجابايت","fileUploadedSuccessfully":"تم رفع الملف بنجاح","failedToUploadFile":"فشل رفع الملف","attachmentRemoved":"تم إزالة المرفق","failureDateSetToCurrentTime":"تم تعيين تاريخ العطل على الوقت الحالي","firstRespondedOnSetToCurrentTime":"تم تعيين وقت أول استجابة على الوقت الحالي","completionDateSetToCurrentTime":"تم تعيين تاريخ الإكمال على الوقت الحالي","firstRespondedOnSetTo":"تم تعيين وقت أول استجابة على {{datetime}}","completionDateSetTo":"تم تعيين تاريخ الإكمال على {{datetime}}","assignedSupervisorMandatory":"المشرف المعيّن إلزامي لدور مراقبة العمل.","assignedEngineerMandatory":"المهندس المعيّن إلزامي لدور مراقبة العمل.","assignedTechnicianMandatory":"الفني المعيّن إلزامي عندما تكون الحالة \\"إرسال إلى المهندس\\".","workOrderCancelledSuccessfully":"تم إلغاء أمر العمل بنجاح!","failedToCancel":"فشل الإلغاء: {{error}}","workOrderDeletedSuccessfully":"تم حذف أمر العمل بنجاح!","failedToDelete":"فشل الحذف: {{error}}","pleaseSelectWorkOrderType":"يرجى اختيار نوع أمر العمل","workOrderUpdatedSuccessfully":"تم تحديث أمر العمل بنجاح!","workOrderCreatedSuccessfully":"تم إنشاء أمر العمل بنجاح!","workOrderCreatedFromAssetSuccessfully":"تم إنشاء أمر العمل من الأصل بنجاح!","workOrderDuplicatedSuccessfully":"تم نسخ أمر العمل بنجاح!","documentModifiedByAnotherUser":"تم تعديل المستند من قبل مستخدم آخر. جاري التحديث...","pleaseReviewLatestChanges":"يرجى مراجعة أحدث التغييرات والمحاولة مرة أخرى.","failedToSaveWorkOrder":"فشل حفظ أمر العمل: {{error}}","technicalReportMandatoryForSupervisor":"التقرير الفني إلزامي عند الإرسال مباشرة إلى المشرف. يرجى ملء حقل التقرير الفني قبل المتابعة.","applyingAction":"جاري تطبيق الإجراء \\"{{action}}\\"...","assignedTo":"معيّن إلى: {{name}}","actionCompletedSuccessfully":"تم إكمال الإجراء \\"{{action}}\\" بنجاح!","documentModifiedRefreshing":"تم تعديل المستند. جاري التحديث...","tryActionAgainAfterReview":"يرجى المحاولة مرة أخرى بعد مراجعة أحدث التغييرات.","failedToApplyAction":"فشل تطبيق الإجراء \\"{{action}}\\". {{error}}","editModeEnabled":"تم تفعيل وضع التحرير","editCancelledChangesDiscarded":"تم إلغاء التحرير - تم تجاهل التغييرات","closingAttachmentRemoved":"تم إزالة مرفق الإغلاق","closingAttachmentUploadedSuccessfully":"تم رفع مرفق الإغلاق بنجاح","failedToUploadClosingAttachment":"فشل رفع مرفق الإغلاق","newStockItemRowAdded":"تمت إضافة صف صنف جديد","stockItemRemoved":"تمت إزالة صنف المخزون {{item}}","activityLogRefreshed":"تم تحديث سجل النشاط","errorLabel":"خطأ","backToList":"العودة إلى قائمة أوامر العمل","duplicateWorkOrder":"نسخ أمر العمل","createFromAsset":"إنشاء أمر عمل من الأصل","newWorkOrder":"أمر عمل جديد","workOrderDetails":"تفاصيل أمر العمل","existingWorkOrderFound":"تم العثور على أمر عمل موجود","workOrderExistsForAsset":"يوجد أمر عمل بالفعل لهذا الأصل بحالة سير عمل غير معتمدة أو مغلقة.","workOrderExistsForTypeAndRoom":"يوجد أمر عمل بالفعل لهذا النوع ورقم الغرفة بحالة سير عمل غير معتمدة أو مغلقة.","proceedWithNewWO":"هل ما زلت تريد المتابعة بإنشاء أمر عمل جديد؟","proceedAnyway":"متابعة على أي حال","noGoBack":"لا، تراجع","yesCancel":"نعم، إلغاء","cancelling":"جاري الإلغاء...","deleting":"جاري الحذف...","selectAdditionalTechnicians":"اختر فنيين إضافيين","searchTechnicians":"البحث عن فنيين...","techniciansSelected":"{{count}} فني/فنيين محدد","clearAll":"مسح الكل","noTechniciansMatchSearch":"لا يوجد فنيون يطابقون بحثك","noTechniciansFound":"لم يتم العثور على فنيين","hospital":"المستشفى","technicalDepartment":"القسم الفني","woType":"نوع أمر العمل","assetId":"معرف الأصل","assetName":"اسم الأصل","extensionNo":"رقم الامتداد","building":"المبنى","departmentName":"اسم القسم","roomNo":"رقم الغرفة","location":"الموقع","manufacturer":"الشركة المصنعة","supplier":"المورد","assignedSupervisor":"المشرف المعيّن","assignedEngineer":"المهندس المعيّن","assignedTechnician":"الفني المعيّن","fromAsset":"من الأصل","assetDetailsAutoPopulated":"تم تعبئة تفاصيل الأصل تلقائياً","selectBuildingFirst":"اختر المبنى أولاً لتفعيل القسم","printServiceReport":"طباعة تقرير الخدمة","removeAttachment":"إزالة المرفق","removeClosingAttachment":"إزالة مرفق الإغلاق","setToCurrentDateTime":"تعيين على التاريخ والوقت الحالي","selectItem":"اختر الصنف","selectWarehouse":"اختر المستودع","autoPopulatedFromStock":"تم تعبئته تلقائياً من المخزون","removeItem":"إزالة الصنف","noItemsAddedYet":"لم تتم إضافة أصناف بعد","commentsDiscussion":"التعليقات والنقاش","refreshActivityLog":"تحديث سجل النشاط","supervisorsAvailableForType":"{{count}} مشرف/مشرفين معيّن متاح لهذا النوع","civilWorkCategory":"فئة الأعمال المدنية","selectCivilWorkCategory":"اختر فئة الأعمال المدنية","selectPendingReason":"اختر سبب الانتظار","pleaseSpecifyReason":"يرجى تحديد السبب...","selectServiceAgreement":"اختر اتفاقية الخدمة","selectServiceCoverage":"اختر تغطية الخدمة","describeComplaint":"صف طبيعة الشكوى...","describeWorkPerformed":"صف العمل المنفذ...","enterSerialNumber":"أدخل الرقم التسلسلي","searchAssetBySerial":"البحث عن الأصل بالرقم التسلسلي","workOrder":"أمر العمل:","giveFeedback":"تقديم التقييم","editFeedback":"تعديل التقييم","feedbackDetails":"تفاصيل التقييم","confirmAssignment":"تأكيد التعيين","notRated":"غير مُقيّم","serviceReport":"تقرير الخدمة","assetInfoPrefilled":"تم تعبئة معلومات الأصل تلقائياً من","linkedFromAsset":"مرتبط من الأصل:","loadingAssetDetails":"جاري تحميل تفاصيل الأصل...","cancelled":"ملغى","workOrderId":"معرف أمر العمل","pendingReason":"سبب الانتظار","otherReason":"سبب آخر","serviceAgreementDetails":"تفاصيل اتفاقية الخدمة","siteContractor":"متعاقد الموقع","subcontractor":"المقاول من الباطن","model":"الموديل","description":"الوصف","natureOfComplaint":"طبيعة الشكوى","technicalReport":"التقرير الفني","selectWoTypeFirstForSupervisors":"اختر نوع أمر العمل أولاً لتصفية المشرفين المعيّنين","noSupervisorsFound":"لم يتم العثور على مشرفين معيّنين لهذا النوع من أمر العمل","requiredForExistingWO":"* مطلوب لأوامر العمل الموجودة","selectWoTypeFirstForEngineers":"اختر نوع أمر العمل أولاً لتصفية المهندسين","noEngineersFound":"لم يتم العثور على مهندسين (دور مهندس المقاول) لهذا النوع من أمر العمل","engineersAvailable":"{{count}} مهندس/مهندسين متاح","selectWoTypeFirstForTechnicians":"اختر نوع أمر العمل أولاً لتصفية الفنيين","noTechniciansFoundForType":"لم يتم العثور على فنيين لهذا النوع من أمر العمل","techniciansAvailable":"{{count}} فني/فنيين متاح","requiredForSentToEngineer":"* مطلوب لحالة \\"إرسال إلى المهندس\\"","autoCalculated":"(محسوب تلقائياً)","autoSetOnRepairStart":"(يُعيّن عند بدء الإصلاح)","autoSetOnClose":"(يُعيّن عند الإغلاق)","totalItems":"إجمالي الأصناف:","confirmAction":"تأكيد الإجراء","confirmActionMessage":"هل أنت متأكد أنك تريد {{action}} أمر العمل هذا؟","processing":"جاري المعالجة...","yesAction":"نعم، {{action}}","systemManagerNote":"مدير النظام: عرض جميع الإجراءات الصالحة لهذه الحالة.","saveToSeeActions":"احفظ التغييرات لرؤية جميع الإجراءات المتاحة.","availableActions":"الإجراءات المتاحة","allOptionsAvailable":"جميع الخيارات متاحة","bothFilledMessage":"تم ملء الفني والتقرير الفني. يمكنك الآن استخدام أي إجراء سير عمل متاح أعلاه.","technicianAssigned":"تم تعيين الفني","assignedTechnicianLabel":"الفني المعيّن:","wantToEnableSendToSupervisor":"هل تريد أيضاً تمكين \\"إرسال إلى المشرف\\"؟","fillTechnicalReportToUnlock":"املأ حقل \\"التقرير الفني\\" لفتح هذا الخيار","technicalReportFilled":"تم ملء التقرير الفني","howWasService":"كيف كانت الخدمة لأمر العمل هذا؟","noFeedbackYet":"لم يُقدّم أي تقييم بعد","statusInfoAfterCreation":"ستظهر معلومات الحالة بعد الإنشاء","activityLog":"سجل النشاط","refreshActivityLogTitle":"تحديث سجل النشاط","noChangesRecorded":"لم يُسجّل أي تغيير بعد","createdThisWorkOrder":"أنشأ أمر العمل هذا","showLess":"عرض أقل","showAll":"عرض الكل","entries":"إدخالات","changedFrom":"تغيّر من","documentUpdated":"تم تحديث المستند","addItem":"إضافة صنف","addFirstItem":"+ إضافة الصنف الأول","item":"الصنف","valuationRate":"معدل التقييم","warehouse":"المستودع","consumedQty":"الكمية المستهلكة","availableStock":"المخزون المتاح","totalValue":"إجمالي القيمة","action":"الإجراء","open":"مفتوح","autoGenerated":"يُنشأ تلقائياً","updating":"جاري التحديث...","submitting":"جاري الإرسال...","updateFeedback":"تحديث التقييم","submitFeedback":"إرسال التقييم","editRating":"تعديل التقييم","saveSelection":"حفظ التحديد"}}`),k3={title:"صيانة الأصول",maintenanceLogs:"سجلات الصيانة",maintenanceDetails:"تفاصيل الصيانة",addMaintenance:"إضافة صيانة جديدة",listTotal:"الإجمالي: {{count}} سجل صيانة{{count !== 1 ? '' : ''}}",apiNotAvailable:"واجهة صيانة الأصول غير متاحة",apiNotDeployed:"لم يتم نشر نقطة نهاية واجهة صيانة الأصول بعد.",tryCreatingNew:"جرب الإنشاء (تجريبي)",deletedSuccessfully:"تم حذف فريق الصيانة بنجاح!",status:{planned:"مخطط",completed:"مكتمل",overdue:"متأخر",cancelled:"ملغى"},maintenanceTeam:"فريق الصيانة",newMaintenanceTeam:"فريق صيانة جديد",teamId:"معرف الفريق",teamName:"اسم الفريق",managerEmail:"بريد المشرف",managerName:"اسم المشرف",expertise:"الاختصاص",selectTeam:"اختر الفريق",viewDetails:"عرض التفاصيل",editTeam:"تعديل الفريق",duplicateTeam:"نسخ الفريق",deleteTeam:"حذف الفريق",selectHospital:"اختر المستشفى",selectExpertise:"اختر الاختصاص",selectManager:"اختر المشرف",enterTeamName:"أدخل اسم الفريق",teamInformation:"معلومات الفريق",selectUser:"اختر المستخدم",selectRole:"اختر الدور",totalMembers:"إجمالي الأعضاء",teamSummary:"ملخص الفريق",addFirstMember:"أضف العضو الأول",manager:"بريد المشرف",loadingTeams:"جاري تحميل فرق الصيانة...",errorLoadingTeams:"خطأ في تحميل فرق الصيانة",deleteConfirmMessage:"هل أنت متأكد من حذف فريق الصيانة هذا؟ لا يمكن التراجع عن هذا الإجراء.",team:"الفريق",deleteTeamButton:"حذف الفريق",listTitle:"فرق الصيانة",statsTotalTeams:"إجمالي الفرق",statsManagers:"المديرون",statsHospitals:"المستشفيات",export:{title:"تصدير فرق الصيانة",selectData:"اختر البيانات للتصدير",selectedRows:"الصفوف المحددة",selectedCount:"تصدير {{count}} فريق صيانة محدد",currentPage:"الصفحة الحالية",currentPageCount:"تصدير {{count}} فريق صيانة في الصفحة الحالية",allWithFilters:"جميع السجلات (مع المرشحات الحالية)",allWithFiltersCount:"تصدير كل {{count}} فريق صيانة مطابق للمرشحات",exportFormat:"تنسيق التصدير",csv:"CSV",csvDesc:"قيم مفصولة بفواصل",excel:"Excel",excelDesc:"جدول XLSX",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",resetToDefault:"إعادة إلى الافتراضي",columnsSelected:"{{count}} عمود محدد",exporting:"جاري التصدير...",exportButton:"تصدير",exportingSelected:"تصدير {{count}} صف محدد",exportingPage:"تصدير {{count}} صف من الصفحة الحالية",exportingAll:"تصدير كل {{count}} صف"}},j3={title:"الصيانة الوقائية",ppmDetails:"تفاصيل الصيانة الوقائية",addPPM:"إضافة صيانة وقائية جديدة",periodicity:"الدورية",dueDate:"تاريخ الاستحقاق",manageSchedules:"إدارة الجداول",pmId:"معرف الصيانة الوقائية",name:"الاسم",manufacturer:"الشركة المصنعة",listTotal:"الإجمالي: {{count}} جدول صيانة وقائية{{count !== 1 ? '' : ''}}",searchPlaceholder:"ابحث بالمعرف أو الأصل أو الشركة...",filterByCompany:"تصفية حسب الشركة",company:"الشركة",asset:"الأصل",assetType:"نوع الأصل",frequency:"التكرار",noOfPMs:"عدد الصيانات الوقائية",totalAmount:"المبلغ الإجمالي",apiNotAvailable:"واجهة الصيانة الوقائية غير متاحة",apiNotDeployed:"لم يتم نشر نقطة نهاية واجهة الصيانة الوقائية بعد.",tryCreatingNew:"جرب الإنشاء (تجريبي)",deletedSuccessfully:"تم حذف جدول الصيانة الوقائية بنجاح!",noSchedulesFound:"لم يتم العثور على جداول صيانة وقائية",createFirstSchedule:"أنشئ أول جدول صيانة وقائية",confirmDelete:"تأكيد الحذف",deleteConfirmMessage:"هل أنت متأكد من حذف جدول الصيانة الوقائية هذا؟ لا يمكن التراجع عن هذا الإجراء.",detail:{duplicateSchedule:"نسخ جدول الصيانة الوقائية",newSchedule:"جدول صيانة وقائية جديد",scheduleDetails:"تفاصيل جدول الصيانة الوقائية",basicInformation:"المعلومات الأساسية",financialInformation:"المعلومات المالية",scheduleInformation:"معلومات الجدول",maintenanceTeam:"فريق الصيانة",numberOfPMs:"عدد الصيانات الوقائية",pricePerPM:"السعر لكل صيانة وقائية",frequencyPlaceholder:"مثال: شهري، ربع سنوي، سنوي",scheduleInfoAfterCreation:"ستظهر معلومات الجدول بعد الإنشاء",assetName:"اسم الأصل",pleaseEnterAssetName:"يرجى إدخال اسم الأصل",duplicatedSuccessfully:"تم نسخ جدول الصيانة الوقائية بنجاح!",createdSuccessfully:"تم إنشاء جدول الصيانة الوقائية بنجاح!",updatedSuccessfully:"تم تحديث جدول الصيانة الوقائية بنجاح!",failedToSave:"فشل الحفظ",saveChanges:"حفظ التغييرات",loadingSchedule:"جاري تحميل جدول الصيانة الوقائية...",backToSchedules:"العودة إلى جداول الصيانة الوقائية",errorLoading:"خطأ"}},N3={listTitle:"جداول الصيانة الوقائية",export:{title:"تصدير جداول الصيانة الوقائية",selectData:"نطاق التصدير",selectedRows:"الصفوف المحددة",selectedCount:"تصدير {{count}} جدول{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",currentPage:"الصفحة الحالية",currentPageCount:"تصدير {{count}} جدول{{count !== 1 ? 'اً' : ''}} في الصفحة الحالية",allWithFilters:"جميع السجلات (مع الفلاتر الحالية)",allWithFiltersCount:"تصدير جميع {{count}} جدول{{count !== 1 ? 'اً' : ''}} المطابقة للفلاتر الحالية",csvDesc:"قيم مفصولة بفاصلة",excelDesc:"جدول XLSX",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",resetToDefault:"إعادة التعيين للافتراضي",columnsSelected:"{{count}} عمود{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",exporting:"جاري التصدير...",exportButton:"تصدير",exportingSelected:"جاري تصدير {{count}} صف{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",exportingPage:"جاري تصدير {{count}} صف{{count !== 1 ? 'اً' : ''}} من الصفحة الحالية",exportingAll:"جاري تصدير جميع {{count}} صف{{count !== 1 ? 'اً' : ''}}"}},S3={title:"تصدير",whatToExport:"ما الذي سيتم تصديره",selectedRows:"الصفوف المحددة",currentPage:"الصفحة الحالية",allWithFilters:"الكل مع المرشحات",exportSelected:"تصدير {count} محدد",exportPage:"تصدير {count} في الصفحة الحالية",exportAll:"تصدير الكل {count}",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",selectDefault:"تحديد الافتراضي",exporting:"جاري التصدير...",exportingSelected:"جاري تصدير {count} صف(وف) محدد(ة)",exportingPage:"جاري تصدير {count} صف(وف) من الصفحة الحالية",exportingAll:"جاري تصدير جميع {count} صف(وف)",selected:"محدد",rows:"صفوف"},C3={title:"الأصناف",itemDetails:"تفاصيل الصنف",newItem:"صنف جديد",addItem:"إضافة صنف جديد",itemId:"معرف الصنف",itemCode:"كود الصنف",itemName:"اسم الصنف",itemGroup:"مجموعة الأصناف",stockUOM:"وحدة المخزون",partDescription:"وصف القطعة",brand:"العلامة التجارية",valuationRate:"معدل التقييم",openingStock:"رصيد الافتتاح",lastCalibrationDate:"تاريخ المعايرة الأخير",nextCalibrationDate:"تاريخ المعايرة القادم",selectItem:"اختر الصنف",selectItemGroup:"اختر مجموعة الأصناف",selectHospital:"اختر المستشفى",serialNo:"الرقم التسلسلي",dateIn:"تاريخ الدخول",watts:"واط",volts:"فولت",type:"النوع",code:"الرمز",viewDetails:"عرض التفاصيل",editItem:"تعديل الصنف",duplicateItem:"نسخ الصنف",deleteItem:"حذف الصنف",basicInformation:"المعلومات الأساسية",inventoryDetails:"تفاصيل المخزون",stockInformation:"معلومات المخزون",isStockItem:"صنف مخزني",isFixedAsset:"أصل ثابت",balanceQty:"الرصيد",calibrationInformation:"معلومات المعايرة",additionalInformation:"معلومات إضافية",refreshBalanceQty:"تحديث الرصيد",warrantyMonths:"الضمان (بالأشهر)",errorLoadingItems:"خطأ في تحميل الأصناف",loadingItems:"جاري تحميل الأصناف...",deleteConfirmMessage:"هل أنت متأكد من حذف هذا الصنف؟ لا يمكن التراجع عن هذا الإجراء.",backToInventory:"العودة إلى المخزون",loadingItem:"جاري تحميل الصنف...",errorLoadingItem:"خطأ في تحميل الصنف",createNewItem:"إنشاء صنف جديد",itemCodeLabel:"كود الصنف",itemUpdatedSuccessfully:"تم تحديث الصنف بنجاح!",pleaseSaveFirst:"يرجى حفظ الصنف أولاً قبل الإرسال.",submittedSuccessfully:"تم إرسال الصنف بنجاح!",failedToSave:"فشل الحفظ",failedToSubmit:"فشل الإرسال",noItemsFound:"لم يتم العثور على عناصر",createFirstItem:"أنشئ عنصرك الأول",listTitle:"المخزون",listTotal:"الإجمالي: {{count}} عنصر{{count !== 1 ? 'اً' : ''}}",failedToLoadItems:"فشل تحميل العناصر.",listAddItem:"إضافة عنصر",export:{title:"تصدير العناصر",selectData:"اختر البيانات للتصدير",selectedRows:"الصفوف المحددة",selectedCount:"تصدير {{count}} عنصر{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",currentPage:"الصفحة الحالية",currentPageCount:"تصدير {{count}} عنصر{{count !== 1 ? 'اً' : ''}} في الصفحة الحالية",allWithFilters:"جميع السجلات (مع الفلاتر الحالية)",allWithFiltersCount:"تصدير جميع {{count}} عنصر{{count !== 1 ? 'اً' : ''}} المطابقة للفلاتر الحالية",csvDesc:"قيم مفصولة بفاصلة",excelDesc:"جدول XLSX",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",resetToDefault:"إعادة التعيين للافتراضي",columnsSelected:"{{count}} عمود{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",exporting:"جاري التصدير...",exportButton:"تصدير",exportingSelected:"جاري تصدير {{count}} صف{{count !== 1 ? 'اً' : ''}} محدد{{count !== 1 ? 'ة' : ''}}",exportingPage:"جاري تصدير {{count}} صف{{count !== 1 ? 'اً' : ''}} من الصفحة الحالية",exportingAll:"جاري تصدير جميع {{count}} صف{{count !== 1 ? 'اً' : ''}}"}},T3={title:"التذاكر",issueDetails:"تفاصيل التذكرة",newIssue:"تذكرة جديدة",addIssue:"إضافة تذكرة جديدة",issueId:"معرف التذكرة",subject:"الموضوع",raisedBy:"أُبلغ بها",contact:"جهة الاتصال",issueType:"نوع التذكرة",openingDate:"تاريخ الفتح",resolutionDate:"تاريخ الحل",resolvedBy:"تم الحل بواسطة",firstRespondedOn:"أول رد في",resolutionDetails:"تفاصيل الحل",selectIssue:"اختر التذكرة",allPriorities:"أي أولوية",allCompanies:"جميع الشركات",viewDetails:"عرض التفاصيل",editIssue:"تعديل التذكرة",deleteIssue:"حذف التذكرة",enterSubject:"أدخل موضوع التذكرة",selectPriority:"اختر الأولوية",selectIssueType:"اختر نوع التذكرة",describeIssue:"صف التذكرة بالتفصيل...",contactInformation:"معلومات الاتصال",createNewIssue:"إنشاء تذكرة دعم جديدة",resolution:"الحل",describeResolution:"صف كيف تم حل التذكرة...",selectCompany:"اختر الشركة",statusInformation:"معلومات الحالة",currentStatus:"الحالة الحالية",timeline:"الجدول الزمني",loadingIssues:"جاري تحميل التذاكر...",errorLoadingIssues:"خطأ في تحميل التذاكر",deleteConfirmMessage:"هل أنت متأكد من حذف هذه التذكرة؟ لا يمكن التراجع عن هذا الإجراء.",deletedSuccessfully:"تم حذف التذكرة بنجاح!",listTitle:"تذاكر الدعم",listTotal:"الإجمالي",listSelected:"محدد",statsTotalIssues:"إجمالي التذاكر",statsOpen:"مفتوحة",statsResolved:"محلولة",statsClosed:"مغلقة",export:{title:"تصدير التذاكر",selectData:"اختر البيانات للتصدير",selectedRows:"الصفوف المحددة",selectedCount:"تصدير {{count}} تذكرة محددة",currentPage:"الصفحة الحالية",currentPageCount:"تصدير {{count}} تذكرة في الصفحة الحالية",allWithFilters:"جميع السجلات (مع المرشحات الحالية)",allWithFiltersCount:"تصدير كل {{count}} تذكرة مطابقة للمرشحات",exportFormat:"تنسيق التصدير",csv:"CSV",csvDesc:"قيم مفصولة بفواصل",excel:"Excel",excelDesc:"جدول XLSX",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",resetToDefault:"إعادة إلى الافتراضي",columnsSelected:"{{count}} عمود محدد",exporting:"جاري التصدير...",exportButton:"تصدير",exportingSelected:"تصدير {{count}} صف محدد",exportingPage:"تصدير {{count}} صف من الصفحة الحالية",exportingAll:"تصدير كل {{count}} صف"},status:{open:"مفتوحة",replied:"تم الرد",on_hold:"قيد الانتظار",resolved:"محلولة",closed:"مغلقة"},priority:{low:"منخفضة",medium:"متوسطة",high:"عالية",critical:"حرجة"}},E3={title:"المستخدمون",userDetails:"تفاصيل المستخدم",newUser:"مستخدم جديد",addUser:"إضافة مستخدم جديد",searchUsers:"بحث عن مستخدمين...",manageUsers:"إدارة حسابات المستخدمين والصلاحيات",noUsersFound:"لم يتم العثور على مستخدمين",tryAdjustingSearch:"حاول تعديل مصطلحات البحث.",noUsersAvailable:"لا يوجد مستخدمون متاحون.",backToDashboard:"العودة إلى لوحة التحكم",refresh:"تحديث",active:"نشط",inactive:"غير نشط",noEmail:"لا يوجد بريد إلكتروني",created:"تاريخ الإنشاء"},A3={title:"الفعاليات",eventDetails:"تفاصيل الفعالية",newEvent:"فعالية جديدة",addEvent:"إضافة فعالية",upcomingEvents:"الفعاليات القادمة",eventsFromFrappe:"فعاليات من نظام Frappe",noEventsFound:"لم يتم العثور على فعاليات",noEventsScheduled:"لا توجد فعاليات مجدولة حالياً.",refreshEvents:"تحديث الفعاليات"},O3={previous:"السابق",next:"التالي",goTo:"انتقل إلى",go:"انتقال",page:"صفحة",showingToOf:"عرض {{start}} إلى {{end}} من {{total}} {{label}}",showingTo:"عرض {{start}} إلى {{end}} {{label}}",items:"أصناف",assets:"أصول",workOrders:"أوامر عمل",issues:"تذاكر",teams:"فرق",inspections:"عمليات تفتيش",plans:"خطط"},D3={loading:"جاري التحميل...",noResultsFound:"لم يتم العثور على نتائج",createNewDoctype:"إنشاء {{doctype}} جديد",selectLabel:"اختر {{label}}"},M3={loadingSupportPlans:"جاري تحميل خطط الدعم...",errorLoadingSupportPlans:"خطأ في تحميل خطط الدعم",deleteConfirmMessage:"هل أنت متأكد من حذف خطة الدعم هذه؟ لا يمكن التراجع عن هذا الإجراء.",planId:"معرف الخطة",deletedSuccessfully:"تم حذف خطة الدعم بنجاح!",deleteSupportPlan:"حذف خطة الدعم",noSupportPlansFound:"لم يتم العثور على خطط دعم",createFirstSupportPlan:"أنشئ أول خطة دعم",table:{planName:"اسم الخطة",type:"النوع",frequency:"التكرار",contractValue:"قيمة العقد",warrantyStatus:"حالة الضمان",contractStatus:"حالة العقد"},status:{active:"نشط",expired:"منتهي",pending:"قيد الانتظار",terminated:"منتهي مبكرًا"},statusLabel:{warrantyPrefix:"ض:",contractPrefix:"ع:"},viewDetails:"عرض خطة الدعم",editSupportPlan:"تعديل خطة الدعم",listTitle:"خطط الدعم",statsTotalPlans:"إجمالي الخطط",statsContracts:"العقود",statsWarranties:"الضمانات",statsActive:"نشطة",export:{title:"تصدير خطط الدعم",selectData:"اختر البيانات للتصدير",selectedRows:"الصفوف المحددة",selectedCount:"تصدير {{count}} خطة دعم محددة",currentPage:"الصفحة الحالية",currentPageCount:"تصدير {{count}} خطة دعم في الصفحة الحالية",allWithFilters:"جميع السجلات (مع المرشحات الحالية)",allWithFiltersCount:"تصدير كل {{count}} خطة دعم مطابقة للمرشحات",exportFormat:"تنسيق التصدير",csv:"CSV",csvDesc:"قيم مفصولة بفواصل",excel:"Excel",excelDesc:"جدول XLSX",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",resetToDefault:"إعادة إلى الافتراضي",columnsSelected:"{{count}} عمود محدد",exporting:"جاري التصدير...",exportButton:"تصدير",exportingSelected:"تصدير {{count}} صف محدد",exportingPage:"تصدير {{count}} صف من الصفحة الحالية",exportingAll:"تصدير كل {{count}} صف"}},L3={title:"عمليات التفتيش",loadingInspections:"جاري تحميل عمليات التفتيش...",errorLoadingInspections:"خطأ في تحميل عمليات التفتيش",deleteConfirmMessage:"هل أنت متأكد من حذف عملية التفتيش هذه؟ لا يمكن التراجع عن هذا الإجراء.",inspectionId:"معرف التفتيش",deleteInspection:"حذف التفتيش",deletedSuccessfully:"تم حذف التفتيش بنجاح!",noInspectionsFound:"لم يتم العثور على عمليات تفتيش",createFirstInspection:"أنشئ أول عملية تفتيش",type:"نوع التفتيش",workflowStateHeader:"حالة سير العمل",targetDate:"تاريخ الاستهداف",requestedBy:"طُلِبت بواسطة",linkedWorkOrder:"أمر العمل المرتبط",savedFilters:"المرشحات المحفوظة",newInspection:"تفتيش جديد",inspectionReport:"تقرير التفتيش",technicalDepartment:"القسم الفني",filterStatus:"الحالة",filterWorkflow:"سير العمل",filterType:"النوع",filterWorkOrder:"أمر العمل",filterDepartment:"القسم",selectWorkOrder:"اختر أمر العمل",selectDepartment:"اختر القسم",stats:{draft:"مسودة",pendingApproval:"بانتظار الموافقة",closed:"مغلقة"},status:{open:"مفتوحة",in_progress:"قيد التنفيذ",pending_review:"بانتظار المراجعة",closed:"مغلقة"},workflowState:{draft:"مسودة",sent_to_work_control:"مرسل إلى التحكم بالعمل",sent_to_technician:"مرسل إلى الفني",sent_to_supervisor:"مرسلة إلى المشرف",closed:"مغلقة"},typeMap:{inspection:"تفتيش",safety_inspection:"تفتيش سلامة"},viewDetails:"عرض التفاصيل",editInspection:"تعديل التفتيش",export:{title:"تصدير عمليات التفتيش",selectData:"اختر البيانات للتصدير",selectedRows:"الصفوف المحددة",selectedCount:"تصدير {{count}} عملية تفتيش محددة",currentPage:"الصفحة الحالية",currentPageCount:"تصدير {{count}} عملية تفتيش في الصفحة الحالية",allWithFilters:"جميع السجلات (مع المرشحات الحالية)",allWithFiltersCount:"تصدير كل {{count}} عملية تفتيش مطابقة للمرشحات",exportFormat:"تنسيق التصدير",csv:"CSV",csvDesc:"قيم مفصولة بفواصل",excel:"Excel",excelDesc:"جدول XLSX",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",resetToDefault:"إعادة إلى الافتراضي",columnsSelected:"{{count}} عمود محدد",exporting:"جاري التصدير...",exportButton:"تصدير",exportingSelected:"تصدير {{count}} صف محدد",exportingPage:"تصدير {{count}} صف من الصفحة الحالية",exportingAll:"تصدير كل {{count}} صف",inspectionId:"معرف التفتيش",inspectionType:"نوع التفتيش",status:"الحالة",workflowState:"حالة سير العمل",inspectionDate:"تاريخ التفتيش",targetClosureDate:"تاريخ الإغلاق المستهدف",requestedBy:"طُلِبت بواسطة",technicalDepartment:"القسم الفني",linkedWorkOrder:"أمر العمل المرتبط",observationNote:"ملاحظة الملاحظة",technicalResponse:"الرد الفني",createdOn:"تاريخ الإنشاء",modifiedOn:"تاريخ التعديل",createdBy:"أنشئ بواسطة"},detail:{loadingDetails:"جاري تحميل تفاصيل التفتيش...",errorLoading:"خطأ في تحميل التفتيش",backToList:"العودة إلى التفتيشات",newInspection:"تفتيش جديد",inspectionDetails:"تفاصيل التفتيش",createNewRecord:"إنشاء سجل تفتيش جديد",cancelInspection:"إلغاء التفتيش",cancelConfirmMessage:"هل أنت متأكد أنك تريد إلغاء هذا التفتيش؟ سيتم تمييز التفتيش كملغى ويمكنك حذفه بعد ذلك إذا لزم الأمر.",noGoBack:"لا، تراجع",yesCancel:"نعم، إلغاء",cancelling:"جاري الإلغاء...",selectType:"اختر النوع",workOrderType:"نوع أمر العمل",selectWorkOrderType:"اختر نوع أمر العمل",techniciansAvailable:"{{count}} فني/فنيين متاح لهذا النوع",selectDepartment:"اختر القسم",selectLocation:"اختر الموقع",extensionNo:"رقم الامتداد *",selectExtension:"اختر الامتداد",inspectionDate:"تاريخ التفتيش",targetClosureDate:"تاريخ الإغلاق المستهدف",cannotBeInPast:"لا يمكن أن يكون في الماضي",cannotBeEarlier:"لا يمكن أن يكون أقدم من تاريخ التفتيش أو في الماضي",openingAttachment:"مرفق الافتتاح",closingAttachment:"مرفق الإغلاق",uploading:"جاري الرفع...",uploadFile:"رفع ملف",uploadClosingFile:"رفع ملف الإغلاق",noAttachment:"لا يوجد مرفق",removeAttachment:"إزالة المرفق",assignmentInformation:"معلومات التعيين",requestedBy:"طُلِبت بواسطة",selectUser:"اختر المستخدم",technicalDepartment:"القسم الفني",assignedTechnician:"الفني المعيّن",selectTechnician:"اختر الفني",selectWOTypeFirst:"اختر نوع أمر العمل أولاً لتصفية الفنيين",noTechniciansForType:"لم يتم العثور على فنيين لهذا النوع من أمر العمل",notesAndResponse:"الملاحظات والرد",observationNote:"ملاحظة الملاحظة",placeholderObservation:"أدخل ملاحظات الملاحظة...",technicalResponse:"الرد الفني",placeholderTechnicalResponse:"أدخل الرد الفني...",linkedWorkOrder:"أمر العمل المرتبط",linkedCorrectiveWO:"أمر العمل التصحيحي المرتبط",readOnly:"للقراءة فقط",viewWorkOrder:"عرض أمر العمل",noLinkedWorkOrder:"لا يوجد أمر عمل مرتبط",workflowActions:"إجراءات سير العمل",workflowProgress:"تقدم سير العمل",workControl:"مراقبة العمل",technicianStep:"الفني",supervisorStep:"المشرف",draftStep:"مسودة",closedStep:"مغلق",statusInfo:"معلومات الحالة",documentStatus:"حالة المستند",woType:"نوع أمر العمل",assignedTo:"معيّن إلى",submitted:"مُرسل",cancelled:"ملغى",added:"مضاف:",removed:"مُزال:",modified:"مُعدّل:",items:"عنصر/عناصر",rows:"صف/صفوف",activityLog:"سجل النشاط",activityLogRefreshed:"تم تحديث سجل النشاط",refreshActivityLog:"تحديث سجل النشاط",noChangesRecorded:"لم يتم تسجيل أي تغييرات بعد",createdThisInspection:"أنشأ هذا التفتيش",changedFrom:"تم التغيير من",documentUpdated:"تم تحديث المستند",showLess:"عرض أقل",showAll:"عرض الكل",department:"القسم",location:"الموقع",inspectionType:"نوع التفتيش",status:"الحالة",removeClosingAttachment:"إزالة مرفق الإغلاق",noClosingAttachment:"لا يوجد مرفق إغلاق",cancelledSuccessfully:"تم إلغاء التفتيش بنجاح!",failedToCancel:"فشل الإلغاء: {{error}}",failedToSave:"فشل الحفظ: {{error}}",failedToDelete:"فشل الحذف: {{error}}",targetClosureMandatory:"تاريخ الإغلاق المستهدف إلزامي للحفظ.",attachmentMandatory:"المرفق إلزامي للحفظ.",extensionMandatory:"رقم الامتداد إلزامي للحفظ.",createdSuccessfully:"تم إنشاء التفتيش بنجاح!",updatedSuccessfully:"تم تحديث التفتيش بنجاح!",deletedSuccessfully:"تم حذف التفتيش بنجاح!",inspectionDateInPast:"لا يمكن أن يكون تاريخ التفتيش في الماضي.",targetClosureEarlier:"لا يمكن أن يكون تاريخ الإغلاق المستهدف أقدم من تاريخ التفتيش.",targetClosureInPast:"لا يمكن أن يكون تاريخ الإغلاق المستهدف في الماضي.",fileSizeExceeds:"حجم الملف يتجاوز حد 10 ميجابايت",fileUploadedSuccess:"تم رفع الملف بنجاح",failedToUpload:"فشل رفع الملف",closingAttachmentRemoved:"تم إزالة مرفق الإغلاق",closingAttachmentUploadedSuccess:"تم رفع مرفق الإغلاق بنجاح",failedToUploadClosing:"فشل رفع مرفق الإغلاق",attachmentRemoved:"تم إزالة المرفق",systemManager:"مدير النظام",workflow:"سير العمل"}},R3={title:"الخريطة النشطة",loading:"جاري تحميل بيانات الخريطة...",hospital:"المستشفى",departmentWoType:"القسم (نوع أمر العمل)",selectHospital:"اختر المستشفى",selectDepartment:"اختر القسم",clearDepartmentHint:"مسح القسم للتصفية حسب المستشفى",clearHospitalHint:"مسح المستشفى للتصفية حسب القسم",clearFilters:"مسح المرشحات",legendHospital:"المستشفى",legendDepartment:"القسم (نوع أمر العمل)",legendHasUrgent:"يوجد أوامر عمل عاجلة",totalAssets:"إجمالي الأصول",workOrderStatus:"حالة أمر العمل",status:"الحالة",count:"العدد",normal:"عادي",urgent:"عاجل",open:"مفتوح",workInProgress:"قيد التنفيذ",pendingReview:"بانتظار المراجعة",completed:"مكتمل",closed:"مغلق",preventiveMaintenance:"الصيانة الوقائية",planned:"مخطط",overdue:"متأخر",viewAssets:"عرض الأصول",viewWorkOrders:"عرض أوامر العمل",viewAllWorkOrders:"عرض جميع أوامر العمل",showingWorkOrdersByType:"عرض أوامر العمل حسب النوع",deptWoType:"القسم / نوع أمر العمل",tooltipDept:"قسم",tooltipHospital:"مستشفى",tooltipUrgent:"عاجل! ",normalWos:"أوامر عادية:",urgentWos:"أوامر عاجلة:",closedWos:"أوامر مغلقة:",plannedPms:"صيانة مخطط لها:",completedPms:"صيانة مكتملة:",assets:"الأصول"},P3={title:"تقويم الصيانة",viewType:"نوع العرض",maintenanceLog:"سجل الصيانة",ppmPlanner:"مخطط الصيانة الوقائية",filters:"المرشحات",yearlyMap:"الخريطة السنوية",yearlyMapTitle:"عرض خريطة مخطط الصيانة الوقائية السنوية",mapShort:"خريطة",hospital:"المستشفى",selectHospital:"اختر المستشفى",department:"القسم",allDepartments:"جميع الأقسام",status:"الحالة",allStatuses:"جميع الحالات",planned:"مخطط",completed:"مكتمل",overdue:"متأخر",cancelled:"ملغى",assignedTo:"مكلف إلى",allTechnicians:"جميع الفنيين",clearFilters:"مسح المرشحات",months:{january:"يناير",february:"فبراير",march:"مارس",april:"أبريل",may:"مايو",june:"يونيو",july:"يوليو",august:"أغسطس",september:"سبتمبر",october:"أكتوبر",november:"نوفمبر",december:"ديسمبر"},days:{sun:"الأحد",mon:"الإثنين",tue:"الثلاثاء",wed:"الأربعاء",thu:"الخميس",fri:"الجمعة",sat:"السبت"},previousMonth:"الشهر السابق",today:"اليوم",nextMonth:"الشهر التالي",loadingLogs:"جاري تحميل سجلات الصيانة...",loadingPpm:"جاري تحميل مخططات الصيانة الوقائية...",overdueInTooltip:"(متأخر)",clickToViewDetails:"انقر لعرض التفاصيل",clickToViewPpmPlanner:"انقر لعرض مخطط الصيانة الوقائية",ppmPlannerDefault:"مخطط الصيانة الوقائية",legendCompleted:"مكتمل",legendPlanned:"مخطط",legendOverdue:"متأخر",legendToday:"اليوم",summaryPpmPlanners:"مخططات الصيانة الوقائية"},F3={common:g3,sidebar:f3,login:x3,dashboard:p3,commonFields:y3,filters:b3,listPages:v3,assets:_3,workOrders:w3,maintenance:k3,ppm:j3,ppmPlanner:N3,exportModal:S3,items:C3,issues:T3,users:E3,events:A3,pagination:O3,linkField:D3,supportPlans:M3,inspections:L3,activeMap:R3,maintenanceCalendarPage:P3},ia={BASE_URL:"https://kfsh-dammam-asm.seeraarabia.com",ENDPOINTS:{USER_DETAILS:"/api/method/asset_lite.api.custom_api.get_user_details",DOCTYPE_RECORDS:"/api/method/asset_lite.api.custom_api.get_doctype_records",DASHBOARD_STATS:"/api/method/asset_lite.api.custom_api.get_dashboard_stats",DASHBOARD_NUMBER_CARDS:"/api/method/asset_lite.api.dashboard_api.get_number_cards",DASHBOARD_LIST_CHARTS:"/api/method/asset_lite.api.dashboard_api.list_dashboard_charts",DASHBOARD_CHART_DATA:"/api/method/asset_lite.api.dashboard_api.get_dashboard_chart_data",DASHBOARD_REPAIR_COST:"/api/method/asset_lite.api.dashboard_api.get_repair_cost_by_item",TECHNICIAN_WORKING_HOURS:"/api/method/asset_lite.api.dashboard_api.get_technician_working_hours",TECHNICIAN_WORK_SUMMARY:"/api/method/asset_lite.api.dashboard_api.get_technician_work_summary",KYC_DETAILS:"/api/method/asset_lite.api.custom_api.get_kyc_details",GET_ASSETS:"/api/method/asset_lite.api.asset_api.get_assets",GET_ASSET_DETAILS:"/api/method/asset_lite.api.asset_api.get_asset_details",CREATE_ASSET:"/api/method/asset_lite.api.asset_api.create_asset",UPDATE_ASSET:"/api/method/asset_lite.api.asset_api.update_asset",DELETE_ASSET:"/api/method/asset_lite.api.asset_api.delete_asset",GET_ASSET_FILTERS:"/api/method/asset_lite.api.asset_api.get_asset_filters",GET_ASSET_STATS:"/api/method/asset_lite.api.asset_api.get_asset_stats",SEARCH_ASSETS:"/api/method/asset_lite.api.asset_api.search_assets",SUBMIT_ASSET:"/api/method/asset_lite.api.asset_api.submit_asset",CANCEL_ASSET:"/api/method/asset_lite.api.asset_api.cancel_asset",GET_WORK_ORDERS:"/api/method/asset_lite.api.work_order_api.get_work_orders",GET_WORK_ORDER_DETAILS:"/api/method/asset_lite.api.work_order_api.get_work_order_details",CREATE_WORK_ORDER:"/api/method/asset_lite.api.work_order_api.create_work_order",UPDATE_WORK_ORDER:"/api/method/asset_lite.api.work_order_api.update_work_order",DELETE_WORK_ORDER:"/api/method/asset_lite.api.work_order_api.delete_work_order",UPDATE_WORK_ORDER_STATUS:"/api/method/asset_lite.api.work_order_api.update_work_order_status",GET_ASSET_MAINTENANCE_LOGS:"/api/method/asset_lite.api.asset_maintenance_api.get_asset_maintenance_logs",GET_ASSET_MAINTENANCE_LOG_DETAILS:"/api/method/asset_lite.api.asset_maintenance_api.get_asset_maintenance_log_details",CREATE_ASSET_MAINTENANCE_LOG:"/api/method/asset_lite.api.asset_maintenance_api.create_asset_maintenance_log",UPDATE_ASSET_MAINTENANCE_LOG:"/api/method/asset_lite.api.asset_maintenance_api.update_asset_maintenance_log",DELETE_ASSET_MAINTENANCE_LOG:"/api/method/asset_lite.api.asset_maintenance_api.delete_asset_maintenance_log",UPDATE_MAINTENANCE_STATUS:"/api/method/asset_lite.api.asset_maintenance_api.update_maintenance_status",GET_MAINTENANCE_LOGS_BY_ASSET:"/api/method/asset_lite.api.asset_maintenance_api.get_maintenance_logs_by_asset",GET_OVERDUE_MAINTENANCE_LOGS:"/api/method/asset_lite.api.asset_maintenance_api.get_overdue_maintenance_logs",GET_ASSET_MAINTENANCES:"/api/method/asset_lite.api.ppm_api.get_asset_maintenances",GET_ASSET_MAINTENANCE_DETAILS:"/api/method/asset_lite.api.ppm_api.get_asset_maintenance_details",CREATE_ASSET_MAINTENANCE:"/api/method/asset_lite.api.ppm_api.create_asset_maintenance",UPDATE_ASSET_MAINTENANCE:"/api/method/asset_lite.api.ppm_api.update_asset_maintenance",DELETE_ASSET_MAINTENANCE:"/api/method/asset_lite.api.ppm_api.delete_asset_maintenance",GET_MAINTENANCE_TASKS:"/api/method/asset_lite.api.ppm_api.get_maintenance_tasks",GET_SERVICE_COVERAGE:"/api/method/asset_lite.api.ppm_api.get_service_coverage",GET_MAINTENANCES_BY_ASSET:"/api/method/asset_lite.api.ppm_api.get_maintenances_by_asset",GET_ACTIVE_SERVICE_CONTRACTS:"/api/method/asset_lite.api.ppm_api.get_active_service_contracts",LOGIN:"/api/method/login",LOGOUT:"/api/method/logout",CSRF_TOKEN:"/api/method/frappe.sessions.get_csrf_token",UPLOAD_FILE:"/api/method/upload_file",GET_USER_PERMISSIONS:"/api/method/asset_lite.api.userperm_api.get_user_permissions",GET_PERMISSION_FILTERS:"/api/method/asset_lite.api.userperm_api.get_permission_filters",GET_ALLOWED_VALUES:"/api/method/asset_lite.api.userperm_api.get_allowed_values",CHECK_DOCUMENT_ACCESS:"/api/method/asset_lite.api.userperm_api.check_document_access",GET_CONFIGURED_DOCTYPES:"/api/method/asset_lite.api.userperm_api.get_configured_doctypes",GET_USER_DEFAULTS:"/api/method/asset_lite.api.userperm_api.get_user_defaults"},DEFAULT_HEADERS:{"Content-Type":"application/json",Accept:"application/json"},TIMEOUT:parseInt("60000")};class I3{constructor(){Mn(this,"baseURL");Mn(this,"endpoints");Mn(this,"defaultHeaders");Mn(this,"timeout");this.baseURL=ia.BASE_URL,this.endpoints=ia.ENDPOINTS,this.defaultHeaders=ia.DEFAULT_HEADERS,this.timeout=ia.TIMEOUT}getCSRFToken(){return Q(this,null,function*(){try{if(typeof window!="undefined"&&window.csrf_token)return window.csrf_token;if(!localStorage.getItem("user"))return null;const r=yield fetch(`${this.baseURL}${this.endpoints.CSRF_TOKEN}`,{method:"GET",headers:{Accept:"application/json"},credentials:"include"});return r.ok&&(yield r.json()).message||null}catch(a){return null}})}apiCall(s){return Q(this,arguments,function*(a,r={}){const i=`${this.baseURL}${a}`,c=ue({method:"GET",headers:ue(ue({},this.defaultHeaders),r.headers)},r),d=yield this.getCSRFToken();d&&(c.headers["X-Frappe-CSRF-Token"]=d);try{const m=new AbortController,h=setTimeout(()=>m.abort(),this.timeout),g=yield fetch(i,Se(ue({},c),{signal:m.signal}));if(clearTimeout(h),!g.ok){const b=yield g.json().catch(()=>({}));throw new mc(b.error||`HTTP error! status: ${g.status}`,g.status)}const p=yield g.json();return p.message!==void 0?p.message:p}catch(m){throw m instanceof Error?(console.error("API call failed:",m),new mc(m.message)):m}})}login(a){return Q(this,null,function*(){const r=new FormData;r.append("usr",a.email),r.append("pwd",a.password);const s=`${this.baseURL}${this.endpoints.LOGIN}`;try{const i=new AbortController,c=setTimeout(()=>i.abort(),this.timeout),d=yield fetch(s,{method:"POST",headers:{Accept:"application/json"},body:r,credentials:"include",signal:i.signal});if(clearTimeout(c),!d.ok){const h=yield d.json().catch(()=>({})),g="Invalid credentials. Please try again.";throw new mc(g,d.status)}const m=yield d.json();return typeof m.message=="string"&&m.message==="Logged In"?{message:{full_name:m.full_name,user_id:m.user||m.email,home_page:m.home_page,sid:m.sid}}:m.message&&typeof m.message=="object"?{message:m.message}:m.full_name||m.user?{message:m}:{message:m}}catch(i){throw i instanceof Error?new mc("Login failed. Please try again."):i}})}logout(){return Q(this,null,function*(){yield this.apiCall(this.endpoints.LOGOUT,{method:"POST"})})}getUserDetails(a){return Q(this,null,function*(){const r=a?`?user_id=${a}`:"";return this.apiCall(`${this.endpoints.USER_DETAILS}${r}`)})}getDoctypeRecords(a,r,s,i=20,c=0){return Q(this,null,function*(){const d=new URLSearchParams({doctype:a,limit:i.toString(),offset:c.toString()});return r&&d.append("filters",JSON.stringify(r)),s&&d.append("fields",JSON.stringify(s)),this.apiCall(`${this.endpoints.DOCTYPE_RECORDS}?${d}`)})}getDashboardStats(){return Q(this,null,function*(){return this.apiCall(this.endpoints.DASHBOARD_STATS)})}getNumberCards(){return Q(this,null,function*(){return this.apiCall(this.endpoints.DASHBOARD_NUMBER_CARDS)})}listDashboardCharts(a=!0){return Q(this,null,function*(){const r=new URLSearchParams({public_only:a?"1":"0"});return this.apiCall(`${this.endpoints.DASHBOARD_LIST_CHARTS}?${r}`)})}getDashboardChartData(a,r){return Q(this,null,function*(){const s=new URLSearchParams({chart_name:a});return r&&s.append("report_filters",JSON.stringify(r)),this.apiCall(`${this.endpoints.DASHBOARD_CHART_DATA}?${s}`)})}getKycDetails(){return Q(this,null,function*(){return this.apiCall(this.endpoints.KYC_DETAILS)})}uploadFile(a){return Q(this,null,function*(){const r=new FormData;return r.append("file",a.file),r.append("doctype",a.doctype),r.append("docname",a.docname),r.append("fieldname",a.fieldname),this.apiCall(this.endpoints.UPLOAD_FILE,{method:"POST",headers:{},body:r})})}getUserPermissions(a){return Q(this,null,function*(){const r=a?`?user=${encodeURIComponent(a)}`:"";return this.apiCall(`${this.endpoints.GET_USER_PERMISSIONS}${r}`)})}getPermissionFilters(a,r){return Q(this,null,function*(){const s=new URLSearchParams({target_doctype:a});return r&&s.append("user",r),this.apiCall(`${this.endpoints.GET_PERMISSION_FILTERS}?${s}`)})}getAllowedValues(a,r){return Q(this,null,function*(){const s=new URLSearchParams({allow_doctype:a});return r&&s.append("user",r),this.apiCall(`${this.endpoints.GET_ALLOWED_VALUES}?${s}`)})}checkDocumentAccess(a,r,s){return Q(this,null,function*(){const i=new URLSearchParams({doctype:a,docname:r});return s&&i.append("user",s),this.apiCall(`${this.endpoints.CHECK_DOCUMENT_ACCESS}?${i}`)})}getConfiguredDoctypes(){return Q(this,null,function*(){return this.apiCall(this.endpoints.GET_CONFIGURED_DOCTYPES)})}getUserDefaults(a){return Q(this,null,function*(){const r=a?`?user=${encodeURIComponent(a)}`:"";return this.apiCall(`${this.endpoints.GET_USER_DEFAULTS}${r}`)})}isAuthenticated(){return!!localStorage.getItem("frappe_session_id")}getSessionId(){return localStorage.getItem("frappe_session_id")}setSessionId(a){localStorage.setItem("frappe_session_id",a)}}class mc extends Error{constructor(r,s,i){super(r);Mn(this,"status");Mn(this,"code");this.name="ApiError",this.status=s,this.code=i}}const mt=new I3,z3=Object.freeze(Object.defineProperty({__proto__:null,ApiError:mc,default:mt},Symbol.toStringTag,{value:"Module"}));function B3(t){return Q(this,null,function*(){try{const a=yield mt.getDoctypeRecords("Translation",{language:t},["source_text","translated_text","context"],1e4,0),r={};return a.records&&a.records.length>0&&a.records.forEach(s=>{const i=s.source_text,c=s.translated_text||i;if(s.context){const d=`${s.context}.${i}`;r[d]=c}else i.includes("."),r[i]=c}),r}catch(a){return console.error("Error fetching translations from Frappe:",a),{}}})}function U3(t){const a={};return Object.keys(t).forEach(r=>{if(r.includes(".")){const s=r.split(".");let i=a;for(let c=0;c<s.length-1;c++){const d=s[c];i[d]||(i[d]={}),i=i[d]}i[s[s.length-1]]=t[r]}else a[r]=t[r]}),a}function c1(t){return Q(this,null,function*(){const a=yield B3(t);return U3(a)})}Ts.use(K_).use(v4).init({resources:{en:{translation:h3},ar:{translation:F3}},fallbackLng:"en",defaultNS:"translation",interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator"],caches:["localStorage"]}});function oh(){return Q(this,null,function*(){try{if(!localStorage.getItem("user"))return;const a=yield c1("en");Object.keys(a).length>0&&Ts.addResourceBundle("en","translation",a,!0,!0);const r=yield c1("ar");Object.keys(r).length>0&&Ts.addResourceBundle("ar","translation",r,!0,!0),console.log("✓ Translations loaded from Frappe")}catch(t){console.warn("⚠ Could not load translations from Frappe, using static translations:",t)}})}Ts.on("initialized",()=>{oh()});var d1="popstate";function $3(t={}){function a(s,i){let{pathname:c,search:d,hash:m}=s.location;return wx("",{pathname:c,search:d,hash:m},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function r(s,i){return typeof i=="string"?i:mu(i)}return W3(a,r,null,t)}function Lr(t,a){if(t===!1||t===null||typeof t=="undefined")throw new Error(a)}function si(t,a){if(!t){typeof console!="undefined"&&console.warn(a);try{throw new Error(a)}catch(r){}}}function H3(){return Math.random().toString(36).substring(2,10)}function u1(t,a){return{usr:t.state,key:t.key,idx:a}}function wx(t,a,r=null,s){return Se(ue({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof a=="string"?Ud(a):a),{state:r,key:a&&a.key||s||H3()})}function mu({pathname:t="/",search:a="",hash:r=""}){return a&&a!=="?"&&(t+=a.charAt(0)==="?"?a:"?"+a),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function Ud(t){let a={};if(t){let r=t.indexOf("#");r>=0&&(a.hash=t.substring(r),t=t.substring(0,r));let s=t.indexOf("?");s>=0&&(a.search=t.substring(s),t=t.substring(0,s)),t&&(a.pathname=t)}return a}function W3(t,a,r,s={}){let{window:i=document.defaultView,v5Compat:c=!1}=s,d=i.history,m="POP",h=null,g=p();g==null&&(g=0,d.replaceState(Se(ue({},d.state),{idx:g}),""));function p(){return(d.state||{idx:null}).idx}function b(){m="POP";let C=p(),D=C==null?null:C-g;g=C,h&&h({action:m,location:k.location,delta:D})}function j(C,D){m="PUSH";let T=wx(k.location,C,D);g=p()+1;let E=u1(T,g),O=k.createHref(T);try{d.pushState(E,"",O)}catch(R){if(R instanceof DOMException&&R.name==="DataCloneError")throw R;i.location.assign(O)}c&&h&&h({action:m,location:k.location,delta:1})}function _(C,D){m="REPLACE";let T=wx(k.location,C,D);g=p();let E=u1(T,g),O=k.createHref(T);d.replaceState(E,"",O),c&&h&&h({action:m,location:k.location,delta:0})}function N(C){return V3(C)}let k={get action(){return m},get location(){return t(i,d)},listen(C){if(h)throw new Error("A history only accepts one active listener");return i.addEventListener(d1,b),h=C,()=>{i.removeEventListener(d1,b),h=null}},createHref(C){return a(i,C)},createURL:N,encodeLocation(C){let D=N(C);return{pathname:D.pathname,search:D.search,hash:D.hash}},push:j,replace:_,go(C){return d.go(C)}};return k}function V3(t,a=!1){let r="http://localhost";typeof window!="undefined"&&(r=window.location.origin!=="null"?window.location.origin:window.location.href),Lr(r,"No window.location.(origin|href) available to create URL");let s=typeof t=="string"?t:mu(t);return s=s.replace(/ $/,"%20"),!a&&s.startsWith("//")&&(s=r+s),new URL(s,r)}function Q_(t,a,r="/"){return q3(t,a,r,!1)}function q3(t,a,r,s){let i=typeof a=="string"?Ud(a):a,c=Zo(i.pathname||"/",r);if(c==null)return null;let d=e2(t);G3(d);let m=null;for(let h=0;m==null&&h<d.length;++h){let g=sS(c);m=aS(d[h],g,s)}return m}function e2(t,a=[],r=[],s="",i=!1){let c=(d,m,h=i,g)=>{let p={relativePath:g===void 0?d.path||"":g,caseSensitive:d.caseSensitive===!0,childrenIndex:m,route:d};if(p.relativePath.startsWith("/")){if(!p.relativePath.startsWith(s)&&h)return;Lr(p.relativePath.startsWith(s),`Absolute route path "${p.relativePath}" nested under path "${s}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),p.relativePath=p.relativePath.slice(s.length)}let b=Vo([s,p.relativePath]),j=r.concat(p);d.children&&d.children.length>0&&(Lr(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${b}".`),e2(d.children,a,j,b,h)),!(d.path==null&&!d.index)&&a.push({path:b,score:eS(b,d.index),routesMeta:j})};return t.forEach((d,m)=>{var h;if(d.path===""||!((h=d.path)!=null&&h.includes("?")))c(d,m);else for(let g of t2(d.path))c(d,m,!0,g)}),a}function t2(t){let a=t.split("/");if(a.length===0)return[];let[r,...s]=a,i=r.endsWith("?"),c=r.replace(/\?$/,"");if(s.length===0)return i?[c,""]:[c];let d=t2(s.join("/")),m=[];return m.push(...d.map(h=>h===""?c:[c,h].join("/"))),i&&m.push(...d),m.map(h=>t.startsWith("/")&&h===""?"/":h)}function G3(t){t.sort((a,r)=>a.score!==r.score?r.score-a.score:tS(a.routesMeta.map(s=>s.childrenIndex),r.routesMeta.map(s=>s.childrenIndex)))}var Y3=/^:[\w-]+$/,Z3=3,J3=2,X3=1,K3=10,Q3=-2,m1=t=>t==="*";function eS(t,a){let r=t.split("/"),s=r.length;return r.some(m1)&&(s+=Q3),a&&(s+=J3),r.filter(i=>!m1(i)).reduce((i,c)=>i+(Y3.test(c)?Z3:c===""?X3:K3),s)}function tS(t,a){return t.length===a.length&&t.slice(0,-1).every((s,i)=>s===a[i])?t[t.length-1]-a[a.length-1]:0}function aS(t,a,r=!1){let{routesMeta:s}=t,i={},c="/",d=[];for(let m=0;m<s.length;++m){let h=s[m],g=m===s.length-1,p=c==="/"?a:a.slice(c.length)||"/",b=lh({path:h.relativePath,caseSensitive:h.caseSensitive,end:g},p),j=h.route;if(!b&&g&&r&&!s[s.length-1].route.index&&(b=lh({path:h.relativePath,caseSensitive:h.caseSensitive,end:!1},p)),!b)return null;Object.assign(i,b.params),d.push({params:i,pathname:Vo([c,b.pathname]),pathnameBase:cS(Vo([c,b.pathnameBase])),route:j}),b.pathnameBase!=="/"&&(c=Vo([c,b.pathnameBase]))}return d}function lh(t,a){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[r,s]=rS(t.path,t.caseSensitive,t.end),i=a.match(r);if(!i)return null;let c=i[0],d=c.replace(/(.)\/+$/,"$1"),m=i.slice(1);return{params:s.reduce((g,{paramName:p,isOptional:b},j)=>{if(p==="*"){let N=m[j]||"";d=c.slice(0,c.length-N.length).replace(/(.)\/+$/,"$1")}const _=m[j];return b&&!_?g[p]=void 0:g[p]=(_||"").replace(/%2F/g,"/"),g},{}),pathname:c,pathnameBase:d,pattern:t}}function rS(t,a=!1,r=!0){si(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let s=[],i="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,m,h)=>(s.push({paramName:m,isOptional:h!=null}),h?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(s.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,a?void 0:"i"),s]}function sS(t){try{return t.split("/").map(a=>decodeURIComponent(a).replace(/\//g,"%2F")).join("/")}catch(a){return si(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${a}).`),t}}function Zo(t,a){if(a==="/")return t;if(!t.toLowerCase().startsWith(a.toLowerCase()))return null;let r=a.endsWith("/")?a.length-1:a.length,s=t.charAt(r);return s&&s!=="/"?null:t.slice(r)||"/"}var nS=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,iS=t=>nS.test(t);function oS(t,a="/"){let{pathname:r,search:s="",hash:i=""}=typeof t=="string"?Ud(t):t,c;if(r)if(iS(r))c=r;else{if(r.includes("//")){let d=r;r=r.replace(/\/\/+/g,"/"),si(!1,`Pathnames cannot have embedded double slashes - normalizing ${d} -> ${r}`)}r.startsWith("/")?c=h1(r.substring(1),"/"):c=h1(r,a)}else c=a;return{pathname:c,search:dS(s),hash:uS(i)}}function h1(t,a){let r=a.replace(/\/+$/,"").split("/");return t.split("/").forEach(i=>{i===".."?r.length>1&&r.pop():i!=="."&&r.push(i)}),r.length>1?r.join("/"):"/"}function Jf(t,a,r,s){return`Cannot include a '${t}' character in a manually specified \`to.${a}\` field [${JSON.stringify(s)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function lS(t){return t.filter((a,r)=>r===0||a.route.path&&a.route.path.length>0)}function Bx(t){let a=lS(t);return a.map((r,s)=>s===a.length-1?r.pathname:r.pathnameBase)}function Ux(t,a,r,s=!1){let i;typeof t=="string"?i=Ud(t):(i=ue({},t),Lr(!i.pathname||!i.pathname.includes("?"),Jf("?","pathname","search",i)),Lr(!i.pathname||!i.pathname.includes("#"),Jf("#","pathname","hash",i)),Lr(!i.search||!i.search.includes("#"),Jf("#","search","hash",i)));let c=t===""||i.pathname==="",d=c?"/":i.pathname,m;if(d==null)m=r;else{let b=a.length-1;if(!s&&d.startsWith("..")){let j=d.split("/");for(;j[0]==="..";)j.shift(),b-=1;i.pathname=j.join("/")}m=b>=0?a[b]:"/"}let h=oS(i,m),g=d&&d!=="/"&&d.endsWith("/"),p=(c||d===".")&&r.endsWith("/");return!h.pathname.endsWith("/")&&(g||p)&&(h.pathname+="/"),h}var Vo=t=>t.join("/").replace(/\/\/+/g,"/"),cS=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),dS=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,uS=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function mS(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function hS(t){return t.map(a=>a.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var a2=["POST","PUT","PATCH","DELETE"];new Set(a2);var gS=["GET",...a2];new Set(gS);var $d=y.createContext(null);$d.displayName="DataRouter";var Mh=y.createContext(null);Mh.displayName="DataRouterState";y.createContext(!1);var r2=y.createContext({isTransitioning:!1});r2.displayName="ViewTransition";var fS=y.createContext(new Map);fS.displayName="Fetchers";var xS=y.createContext(null);xS.displayName="Await";var vi=y.createContext(null);vi.displayName="Navigation";var wu=y.createContext(null);wu.displayName="Location";var Ii=y.createContext({outlet:null,matches:[],isDataRoute:!1});Ii.displayName="Route";var $x=y.createContext(null);$x.displayName="RouteError";function pS(t,{relative:a}={}){Lr(Hd(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:s}=y.useContext(vi),{hash:i,pathname:c,search:d}=ku(t,{relative:a}),m=c;return r!=="/"&&(m=c==="/"?r:Vo([r,c])),s.createHref({pathname:m,search:d,hash:i})}function Hd(){return y.useContext(wu)!=null}function zi(){return Lr(Hd(),"useLocation() may be used only in the context of a <Router> component."),y.useContext(wu).location}var s2="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function n2(t){y.useContext(vi).static||y.useLayoutEffect(t)}function qa(){let{isDataRoute:t}=y.useContext(Ii);return t?AS():yS()}function yS(){Lr(Hd(),"useNavigate() may be used only in the context of a <Router> component.");let t=y.useContext($d),{basename:a,navigator:r}=y.useContext(vi),{matches:s}=y.useContext(Ii),{pathname:i}=zi(),c=JSON.stringify(Bx(s)),d=y.useRef(!1);return n2(()=>{d.current=!0}),y.useCallback((h,g={})=>{if(si(d.current,s2),!d.current)return;if(typeof h=="number"){r.go(h);return}let p=Ux(h,JSON.parse(c),i,g.relative==="path");t==null&&a!=="/"&&(p.pathname=p.pathname==="/"?a:Vo([a,p.pathname])),(g.replace?r.replace:r.push)(p,g.state,g)},[a,r,c,i,t])}y.createContext(null);function xo(){let{matches:t}=y.useContext(Ii),a=t[t.length-1];return a?a.params:{}}function ku(t,{relative:a}={}){let{matches:r}=y.useContext(Ii),{pathname:s}=zi(),i=JSON.stringify(Bx(r));return y.useMemo(()=>Ux(t,JSON.parse(i),s,a==="path"),[t,i,s,a])}function bS(t,a){return i2(t,a)}function i2(t,a,r,s,i){var T;Lr(Hd(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:c}=y.useContext(vi),{matches:d}=y.useContext(Ii),m=d[d.length-1],h=m?m.params:{},g=m?m.pathname:"/",p=m?m.pathnameBase:"/",b=m&&m.route;{let E=b&&b.path||"";o2(g,!b||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (under <Route path="${E}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
Please change the parent <Route path="${E}"> to <Route path="${E==="/"?"*":`${E}/*`}">.`)}let j=zi(),_;if(a){let E=typeof a=="string"?Ud(a):a;Lr(p==="/"||((T=E.pathname)==null?void 0:T.startsWith(p)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${p}" but pathname "${E.pathname}" was given in the \`location\` prop.`),_=E}else _=j;let N=_.pathname||"/",k=N;if(p!=="/"){let E=p.replace(/^\//,"").split("/");k="/"+N.replace(/^\//,"").split("/").slice(E.length).join("/")}let C=Q_(t,{pathname:k});si(b||C!=null,`No routes matched location "${_.pathname}${_.search}${_.hash}" `),si(C==null||C[C.length-1].route.element!==void 0||C[C.length-1].route.Component!==void 0||C[C.length-1].route.lazy!==void 0,`Matched leaf route at location "${_.pathname}${_.search}${_.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let D=jS(C&&C.map(E=>Object.assign({},E,{params:Object.assign({},h,E.params),pathname:Vo([p,c.encodeLocation?c.encodeLocation(E.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?p:Vo([p,c.encodeLocation?c.encodeLocation(E.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),d,r,s,i);return a&&D?y.createElement(wu.Provider,{value:{location:ue({pathname:"/",search:"",hash:"",state:null,key:"default"},_),navigationType:"POP"}},D):D}function vS(){let t=ES(),a=mS(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),r=t instanceof Error?t.stack:null,s="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:s},c={padding:"2px 4px",backgroundColor:s},d=null;return console.error("Error handled by React Router default ErrorBoundary:",t),d=y.createElement(y.Fragment,null,y.createElement("p",null,"💿 Hey developer 👋"),y.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",y.createElement("code",{style:c},"ErrorBoundary")," or"," ",y.createElement("code",{style:c},"errorElement")," prop on your route.")),y.createElement(y.Fragment,null,y.createElement("h2",null,"Unexpected Application Error!"),y.createElement("h3",{style:{fontStyle:"italic"}},a),r?y.createElement("pre",{style:i},r):null,d)}var _S=y.createElement(vS,null),wS=class extends y.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,a){return a.location!==t.location||a.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:a.error,location:a.location,revalidation:t.revalidation||a.revalidation}}componentDidCatch(t,a){this.props.onError?this.props.onError(t,a):console.error("React Router caught the following error during render",t)}render(){return this.state.error!==void 0?y.createElement(Ii.Provider,{value:this.props.routeContext},y.createElement($x.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function kS({routeContext:t,match:a,children:r}){let s=y.useContext($d);return s&&s.static&&s.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=a.route.id),y.createElement(Ii.Provider,{value:t},r)}function jS(t,a=[],r=null,s=null,i=null){if(t==null){if(!r)return null;if(r.errors)t=r.matches;else if(a.length===0&&!r.initialized&&r.matches.length>0)t=r.matches;else return null}let c=t,d=r==null?void 0:r.errors;if(d!=null){let p=c.findIndex(b=>b.route.id&&(d==null?void 0:d[b.route.id])!==void 0);Lr(p>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(d).join(",")}`),c=c.slice(0,Math.min(c.length,p+1))}let m=!1,h=-1;if(r)for(let p=0;p<c.length;p++){let b=c[p];if((b.route.HydrateFallback||b.route.hydrateFallbackElement)&&(h=p),b.route.id){let{loaderData:j,errors:_}=r,N=b.route.loader&&!j.hasOwnProperty(b.route.id)&&(!_||_[b.route.id]===void 0);if(b.route.lazy||N){m=!0,h>=0?c=c.slice(0,h+1):c=[c[0]];break}}}let g=r&&s?(p,b)=>{var j,_,N;s(p,{location:r.location,params:(N=(_=(j=r.matches)==null?void 0:j[0])==null?void 0:_.params)!=null?N:{},unstable_pattern:hS(r.matches),errorInfo:b})}:void 0;return c.reduceRight((p,b,j)=>{let _,N=!1,k=null,C=null;r&&(_=d&&b.route.id?d[b.route.id]:void 0,k=b.route.errorElement||_S,m&&(h<0&&j===0?(o2("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),N=!0,C=null):h===j&&(N=!0,C=b.route.hydrateFallbackElement||null)));let D=a.concat(c.slice(0,j+1)),T=()=>{let E;return _?E=k:N?E=C:b.route.Component?E=y.createElement(b.route.Component,null):b.route.element?E=b.route.element:E=p,y.createElement(kS,{match:b,routeContext:{outlet:p,matches:D,isDataRoute:r!=null},children:E})};return r&&(b.route.ErrorBoundary||b.route.errorElement||j===0)?y.createElement(wS,{location:r.location,revalidation:r.revalidation,component:k,error:_,children:T(),routeContext:{outlet:null,matches:D,isDataRoute:!0},onError:g}):T()},null)}function Hx(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function NS(t){let a=y.useContext($d);return Lr(a,Hx(t)),a}function SS(t){let a=y.useContext(Mh);return Lr(a,Hx(t)),a}function CS(t){let a=y.useContext(Ii);return Lr(a,Hx(t)),a}function Wx(t){let a=CS(t),r=a.matches[a.matches.length-1];return Lr(r.route.id,`${t} can only be used on routes that contain a unique "id"`),r.route.id}function TS(){return Wx("useRouteId")}function ES(){var s;let t=y.useContext($x),a=SS("useRouteError"),r=Wx("useRouteError");return t!==void 0?t:(s=a.errors)==null?void 0:s[r]}function AS(){let{router:t}=NS("useNavigate"),a=Wx("useNavigate"),r=y.useRef(!1);return n2(()=>{r.current=!0}),y.useCallback((d,...m)=>Q(null,[d,...m],function*(i,c={}){si(r.current,s2),r.current&&(typeof i=="number"?yield t.navigate(i):yield t.navigate(i,ue({fromRouteId:a},c)))}),[t,a])}var g1={};function o2(t,a,r){!a&&!g1[t]&&(g1[t]=!0,si(!1,r))}y.memo(OS);function OS({routes:t,future:a,state:r,unstable_onError:s}){return i2(t,void 0,r,s,a)}function kx({to:t,replace:a,state:r,relative:s}){Lr(Hd(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=y.useContext(vi);si(!i,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:c}=y.useContext(Ii),{pathname:d}=zi(),m=qa(),h=Ux(t,Bx(c),d,s==="path"),g=JSON.stringify(h);return y.useEffect(()=>{m(JSON.parse(g),{replace:a,state:r,relative:s})},[m,g,s,a,r]),null}function Ga(t){Lr(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function DS({basename:t="/",children:a=null,location:r,navigationType:s="POP",navigator:i,static:c=!1,unstable_useTransitions:d}){Lr(!Hd(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let m=t.replace(/^\/*/,"/"),h=y.useMemo(()=>({basename:m,navigator:i,static:c,unstable_useTransitions:d,future:{}}),[m,i,c,d]);typeof r=="string"&&(r=Ud(r));let{pathname:g="/",search:p="",hash:b="",state:j=null,key:_="default"}=r,N=y.useMemo(()=>{let k=Zo(g,m);return k==null?null:{location:{pathname:k,search:p,hash:b,state:j,key:_},navigationType:s}},[m,g,p,b,j,_,s]);return si(N!=null,`<Router basename="${m}"> is not able to match the URL "${g}${p}${b}" because it does not start with the basename, so the <Router> won't render anything.`),N==null?null:y.createElement(vi.Provider,{value:h},y.createElement(wu.Provider,{children:a,value:N}))}function MS({children:t,location:a}){return bS(jx(t),a)}function jx(t,a=[]){let r=[];return y.Children.forEach(t,(s,i)=>{if(!y.isValidElement(s))return;let c=[...a,i];if(s.type===y.Fragment){r.push.apply(r,jx(s.props.children,c));return}Lr(s.type===Ga,`[${typeof s.type=="string"?s.type:s.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Lr(!s.props.index||!s.props.children,"An index route cannot have child routes.");let d={id:s.props.id||c.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,middleware:s.props.middleware,loader:s.props.loader,action:s.props.action,hydrateFallbackElement:s.props.hydrateFallbackElement,HydrateFallback:s.props.HydrateFallback,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.hasErrorBoundary===!0||s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(d.children=jx(s.props.children,c)),r.push(d)}),r}var Xm="get",Km="application/x-www-form-urlencoded";function Lh(t){return typeof HTMLElement!="undefined"&&t instanceof HTMLElement}function LS(t){return Lh(t)&&t.tagName.toLowerCase()==="button"}function RS(t){return Lh(t)&&t.tagName.toLowerCase()==="form"}function PS(t){return Lh(t)&&t.tagName.toLowerCase()==="input"}function FS(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function IS(t,a){return t.button===0&&(!a||a==="_self")&&!FS(t)}function Nx(t=""){return new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((a,r)=>{let s=t[r];return a.concat(Array.isArray(s)?s.map(i=>[r,i]):[[r,s]])},[]))}function zS(t,a){let r=Nx(t);return a&&a.forEach((s,i)=>{r.has(i)||a.getAll(i).forEach(c=>{r.append(i,c)})}),r}var Fm=null;function BS(){if(Fm===null)try{new FormData(document.createElement("form"),0),Fm=!1}catch(t){Fm=!0}return Fm}var US=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Xf(t){return t!=null&&!US.has(t)?(si(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Km}"`),null):t}function $S(t,a){let r,s,i,c,d;if(RS(t)){let m=t.getAttribute("action");s=m?Zo(m,a):null,r=t.getAttribute("method")||Xm,i=Xf(t.getAttribute("enctype"))||Km,c=new FormData(t)}else if(LS(t)||PS(t)&&(t.type==="submit"||t.type==="image")){let m=t.form;if(m==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let h=t.getAttribute("formaction")||m.getAttribute("action");if(s=h?Zo(h,a):null,r=t.getAttribute("formmethod")||m.getAttribute("method")||Xm,i=Xf(t.getAttribute("formenctype"))||Xf(m.getAttribute("enctype"))||Km,c=new FormData(m,t),!BS()){let{name:g,type:p,value:b}=t;if(p==="image"){let j=g?`${g}.`:"";c.append(`${j}x`,"0"),c.append(`${j}y`,"0")}else g&&c.append(g,b)}}else{if(Lh(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=Xm,s=null,i=Km,d=t}return c&&i==="text/plain"&&(d=c,c=void 0),{action:s,method:r.toLowerCase(),encType:i,formData:c,body:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Vx(t,a){if(t===!1||t===null||typeof t=="undefined")throw new Error(a)}function HS(t,a,r){let s=typeof t=="string"?new URL(t,typeof window=="undefined"?"server://singlefetch/":window.location.origin):t;return s.pathname==="/"?s.pathname=`_root.${r}`:a&&Zo(s.pathname,a)==="/"?s.pathname=`${a.replace(/\/$/,"")}/_root.${r}`:s.pathname=`${s.pathname.replace(/\/$/,"")}.${r}`,s}function WS(t,a){return Q(this,null,function*(){if(t.id in a)return a[t.id];try{let r=yield import(t.module);return a[t.id]=r,r}catch(r){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(r),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}})}function VS(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}function qS(t,a,r){return Q(this,null,function*(){let s=yield Promise.all(t.map(i=>Q(null,null,function*(){let c=a.routes[i.route.id];if(c){let d=yield WS(c,r);return d.links?d.links():[]}return[]})));return JS(s.flat(1).filter(VS).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?Se(ue({},i),{rel:"prefetch",as:"style"}):Se(ue({},i),{rel:"prefetch"})))})}function f1(t,a,r,s,i,c){let d=(h,g)=>r[g]?h.route.id!==r[g].route.id:!0,m=(h,g)=>{var p;return r[g].pathname!==h.pathname||((p=r[g].route.path)==null?void 0:p.endsWith("*"))&&r[g].params["*"]!==h.params["*"]};return c==="assets"?a.filter((h,g)=>d(h,g)||m(h,g)):c==="data"?a.filter((h,g)=>{var b;let p=s.routes[h.route.id];if(!p||!p.hasLoader)return!1;if(d(h,g)||m(h,g))return!0;if(h.route.shouldRevalidate){let j=h.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:((b=r[0])==null?void 0:b.params)||{},nextUrl:new URL(t,window.origin),nextParams:h.params,defaultShouldRevalidate:!0});if(typeof j=="boolean")return j}return!0}):[]}function GS(t,a,{includeHydrateFallback:r}={}){return YS(t.map(s=>{let i=a.routes[s.route.id];if(!i)return[];let c=[i.module];return i.clientActionModule&&(c=c.concat(i.clientActionModule)),i.clientLoaderModule&&(c=c.concat(i.clientLoaderModule)),r&&i.hydrateFallbackModule&&(c=c.concat(i.hydrateFallbackModule)),i.imports&&(c=c.concat(i.imports)),c}).flat(1))}function YS(t){return[...new Set(t)]}function ZS(t){let a={},r=Object.keys(t).sort();for(let s of r)a[s]=t[s];return a}function JS(t,a){let r=new Set;return new Set(a),t.reduce((s,i)=>{let c=JSON.stringify(ZS(i));return r.has(c)||(r.add(c),s.push({key:c,link:i})),s},[])}function l2(){let t=y.useContext($d);return Vx(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function XS(){let t=y.useContext(Mh);return Vx(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var qx=y.createContext(void 0);qx.displayName="FrameworkContext";function c2(){let t=y.useContext(qx);return Vx(t,"You must render this element inside a <HydratedRouter> element"),t}function KS(t,a){let r=y.useContext(qx),[s,i]=y.useState(!1),[c,d]=y.useState(!1),{onFocus:m,onBlur:h,onMouseEnter:g,onMouseLeave:p,onTouchStart:b}=a,j=y.useRef(null);y.useEffect(()=>{if(t==="render"&&d(!0),t==="viewport"){let k=D=>{D.forEach(T=>{d(T.isIntersecting)})},C=new IntersectionObserver(k,{threshold:.5});return j.current&&C.observe(j.current),()=>{C.disconnect()}}},[t]),y.useEffect(()=>{if(s){let k=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(k)}}},[s]);let _=()=>{i(!0)},N=()=>{i(!1),d(!1)};return r?t!=="intent"?[c,j,{}]:[c,j,{onFocus:W0(m,_),onBlur:W0(h,N),onMouseEnter:W0(g,_),onMouseLeave:W0(p,N),onTouchStart:W0(b,_)}]:[!1,j,{}]}function W0(t,a){return r=>{t&&t(r),r.defaultPrevented||a(r)}}function QS(r){var s=r,{page:t}=s,a=Dn(s,["page"]);let{router:i}=l2(),c=y.useMemo(()=>Q_(i.routes,t,i.basename),[i.routes,t,i.basename]);return c?y.createElement(t5,ue({page:t,matches:c},a)):null}function e5(t){let{manifest:a,routeModules:r}=c2(),[s,i]=y.useState([]);return y.useEffect(()=>{let c=!1;return qS(t,a,r).then(d=>{c||i(d)}),()=>{c=!0}},[t,a,r]),s}function t5(s){var i=s,{page:t,matches:a}=i,r=Dn(i,["page","matches"]);let c=zi(),{manifest:d,routeModules:m}=c2(),{basename:h}=l2(),{loaderData:g,matches:p}=XS(),b=y.useMemo(()=>f1(t,a,p,d,c,"data"),[t,a,p,d,c]),j=y.useMemo(()=>f1(t,a,p,d,c,"assets"),[t,a,p,d,c]),_=y.useMemo(()=>{if(t===c.pathname+c.search+c.hash)return[];let C=new Set,D=!1;if(a.forEach(E=>{var R;let O=d.routes[E.route.id];!O||!O.hasLoader||(!b.some(Y=>Y.route.id===E.route.id)&&E.route.id in g&&((R=m[E.route.id])!=null&&R.shouldRevalidate)||O.hasClientLoader?D=!0:C.add(E.route.id))}),C.size===0)return[];let T=HS(t,h,"data");return D&&C.size>0&&T.searchParams.set("_routes",a.filter(E=>C.has(E.route.id)).map(E=>E.route.id).join(",")),[T.pathname+T.search]},[h,g,c,d,b,a,t,m]),N=y.useMemo(()=>GS(j,d),[j,d]),k=e5(j);return y.createElement(y.Fragment,null,_.map(C=>y.createElement("link",ue({key:C,rel:"prefetch",as:"fetch",href:C},r))),N.map(C=>y.createElement("link",ue({key:C,rel:"modulepreload",href:C},r))),k.map(({key:C,link:D})=>y.createElement("link",ue({key:C,nonce:r.nonce},D))))}function a5(...t){return a=>{t.forEach(r=>{typeof r=="function"?r(a):r!=null&&(r.current=a)})}}var d2=typeof window!="undefined"&&typeof window.document!="undefined"&&typeof window.document.createElement!="undefined";try{d2&&(window.__reactRouterVersion="7.10.0")}catch(t){}function r5({basename:t,children:a,unstable_useTransitions:r,window:s}){let i=y.useRef();i.current==null&&(i.current=$3({window:s,v5Compat:!0}));let c=i.current,[d,m]=y.useState({action:c.action,location:c.location}),h=y.useCallback(g=>{r===!1?m(g):y.startTransition(()=>m(g))},[r]);return y.useLayoutEffect(()=>c.listen(h),[c,h]),y.createElement(DS,{basename:t,children:a,location:d.location,navigationType:d.action,navigator:c,unstable_useTransitions:r===!0})}var u2=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Gx=y.forwardRef(function(N,_){var k=N,{onClick:a,discover:r="render",prefetch:s="none",relative:i,reloadDocument:c,replace:d,state:m,target:h,to:g,preventScrollReset:p,viewTransition:b}=k,j=Dn(k,["onClick","discover","prefetch","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"]);let{basename:C,unstable_useTransitions:D}=y.useContext(vi),T=typeof g=="string"&&u2.test(g),E,O=!1;if(typeof g=="string"&&T&&(E=g,d2))try{let he=new URL(window.location.href),ce=g.startsWith("//")?new URL(he.protocol+g):new URL(g),se=Zo(ce.pathname,C);ce.origin===he.origin&&se!=null?g=se+ce.search+ce.hash:O=!0}catch(he){si(!1,`<Link to="${g}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let R=pS(g,{relative:i}),[Y,P,U]=KS(s,j),J=o5(g,{replace:d,state:m,target:h,preventScrollReset:p,relative:i,viewTransition:b,unstable_useTransitions:D});function ne(he){a&&a(he),he.defaultPrevented||J(he)}let ye=y.createElement("a",Se(ue(ue({},j),U),{href:E||R,onClick:O||c?a:ne,ref:a5(_,P),target:h,"data-discover":!T&&r==="render"?"true":void 0}));return Y&&!T?y.createElement(y.Fragment,null,ye,y.createElement(QS,{page:R})):ye});Gx.displayName="Link";var s5=y.forwardRef(function(b,p){var j=b,{"aria-current":a="page",caseSensitive:r=!1,className:s="",end:i=!1,style:c,to:d,viewTransition:m,children:h}=j,g=Dn(j,["aria-current","caseSensitive","className","end","style","to","viewTransition","children"]);let _=ku(d,{relative:g.relative}),N=zi(),k=y.useContext(Mh),{navigator:C,basename:D}=y.useContext(vi),T=k!=null&&m5(_)&&m===!0,E=C.encodeLocation?C.encodeLocation(_).pathname:_.pathname,O=N.pathname,R=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;r||(O=O.toLowerCase(),R=R?R.toLowerCase():null,E=E.toLowerCase()),R&&D&&(R=Zo(R,D)||R);const Y=E!=="/"&&E.endsWith("/")?E.length-1:E.length;let P=O===E||!i&&O.startsWith(E)&&O.charAt(Y)==="/",U=R!=null&&(R===E||!i&&R.startsWith(E)&&R.charAt(E.length)==="/"),J={isActive:P,isPending:U,isTransitioning:T},ne=P?a:void 0,ye;typeof s=="function"?ye=s(J):ye=[s,P?"active":null,U?"pending":null,T?"transitioning":null].filter(Boolean).join(" ");let he=typeof c=="function"?c(J):c;return y.createElement(Gx,Se(ue({},g),{"aria-current":ne,className:ye,ref:p,style:he,to:d,viewTransition:m}),typeof h=="function"?h(J):h)});s5.displayName="NavLink";var n5=y.forwardRef((N,_)=>{var k=N,{discover:t="render",fetcherKey:a,navigate:r,reloadDocument:s,replace:i,state:c,method:d=Xm,action:m,onSubmit:h,relative:g,preventScrollReset:p,viewTransition:b}=k,j=Dn(k,["discover","fetcherKey","navigate","reloadDocument","replace","state","method","action","onSubmit","relative","preventScrollReset","viewTransition"]);let{unstable_useTransitions:C}=y.useContext(vi),D=d5(),T=u5(m,{relative:g}),E=d.toLowerCase()==="get"?"get":"post",O=typeof m=="string"&&u2.test(m),R=Y=>{if(h&&h(Y),Y.defaultPrevented)return;Y.preventDefault();let P=Y.nativeEvent.submitter,U=(P==null?void 0:P.getAttribute("formmethod"))||d,J=()=>D(P||Y.currentTarget,{fetcherKey:a,method:U,navigate:r,replace:i,state:c,relative:g,preventScrollReset:p,viewTransition:b});C&&r!==!1?y.startTransition(()=>J()):J()};return y.createElement("form",Se(ue({ref:_,method:E,action:T,onSubmit:s?h:R},j),{"data-discover":!O&&t==="render"?"true":void 0}))});n5.displayName="Form";function i5(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function m2(t){let a=y.useContext($d);return Lr(a,i5(t)),a}function o5(t,{target:a,replace:r,state:s,preventScrollReset:i,relative:c,viewTransition:d,unstable_useTransitions:m}={}){let h=qa(),g=zi(),p=ku(t,{relative:c});return y.useCallback(b=>{if(IS(b,a)){b.preventDefault();let j=r!==void 0?r:mu(g)===mu(p),_=()=>h(t,{replace:j,state:s,preventScrollReset:i,relative:c,viewTransition:d});m?y.startTransition(()=>_()):_()}},[g,h,p,r,s,a,t,i,c,d,m])}function Qs(t){si(typeof URLSearchParams!="undefined","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let a=y.useRef(Nx(t)),r=y.useRef(!1),s=zi(),i=y.useMemo(()=>zS(s.search,r.current?null:a.current),[s.search]),c=qa(),d=y.useCallback((m,h)=>{const g=Nx(typeof m=="function"?m(new URLSearchParams(i)):m);r.current=!0,c("?"+g,h)},[c,i]);return[i,d]}var l5=0,c5=()=>`__${String(++l5)}__`;function d5(){let{router:t}=m2("useSubmit"),{basename:a}=y.useContext(vi),r=TS(),s=t.fetch,i=t.navigate;return y.useCallback((m,...h)=>Q(null,[m,...h],function*(c,d={}){let{action:g,method:p,encType:b,formData:j,body:_}=$S(c,a);if(d.navigate===!1){let N=d.fetcherKey||c5();yield s(N,r,d.action||g,{preventScrollReset:d.preventScrollReset,formData:j,body:_,formMethod:d.method||p,formEncType:d.encType||b,flushSync:d.flushSync})}else yield i(d.action||g,{preventScrollReset:d.preventScrollReset,formData:j,body:_,formMethod:d.method||p,formEncType:d.encType||b,replace:d.replace,state:d.state,fromRouteId:r,flushSync:d.flushSync,viewTransition:d.viewTransition})}),[s,i,a,r])}function u5(t,{relative:a}={}){let{basename:r}=y.useContext(vi),s=y.useContext(Ii);Lr(s,"useFormAction must be used inside a RouteContext");let[i]=s.matches.slice(-1),c=ue({},ku(t||".",{relative:a})),d=zi();if(t==null){c.search=d.search;let m=new URLSearchParams(c.search),h=m.getAll("index");if(h.some(p=>p==="")){m.delete("index"),h.filter(b=>b).forEach(b=>m.append("index",b));let p=m.toString();c.search=p?`?${p}`:""}}return(!t||t===".")&&i.route.index&&(c.search=c.search?c.search.replace(/^\?/,"?index&"):"?index"),r!=="/"&&(c.pathname=c.pathname==="/"?r:Vo([r,c.pathname])),mu(c)}function m5(t,{relative:a}={}){let r=y.useContext(r2);Lr(r!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:s}=m2("useViewTransitionState"),i=ku(t,{relative:a});if(!r.isTransitioning)return!1;let c=Zo(r.currentLocation.pathname,s)||r.currentLocation.pathname,d=Zo(r.nextLocation.pathname,s)||r.nextLocation.pathname;return lh(i.pathname,d)!=null||lh(i.pathname,c)!=null}var h2=H_();const h5="modulepreload",g5=function(t){return"/assets/asm_ui_app/asm_app/"+t},x1={},hu=function(a,r,s){let i=Promise.resolve();if(r&&r.length>0){let g=function(p){return Promise.all(p.map(b=>Promise.resolve(b).then(j=>({status:"fulfilled",value:j}),j=>({status:"rejected",reason:j}))))};var d=g;document.getElementsByTagName("link");const m=document.querySelector("meta[property=csp-nonce]"),h=(m==null?void 0:m.nonce)||(m==null?void 0:m.getAttribute("nonce"));i=g(r.map(p=>{if(p=g5(p),p in x1)return;x1[p]=!0;const b=p.endsWith(".css"),j=b?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${j}`))return;const _=document.createElement("link");if(_.rel=b?"stylesheet":h5,b||(_.as="script"),_.crossOrigin="",_.href=p,h&&_.setAttribute("nonce",h),document.head.appendChild(_),b)return new Promise((N,k)=>{_.addEventListener("load",N),_.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${p}`)))})}))}function c(m){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=m,window.dispatchEvent(h),!h.defaultPrevented)throw m}return i.then(m=>{for(const h of m||[])h.status==="rejected"&&c(h.reason);return a().catch(c)})},g2=y.createContext(void 0),f5=({children:t})=>{const{i18n:a}=ca(),[r,s]=y.useState(()=>localStorage.getItem("i18nextLng")==="ar"?"ar":"en"),i=r==="ar";y.useEffect(()=>{const d=document.documentElement,m=document.documentElement;a.changeLanguage(r),m.setAttribute("lang",r),i?(m.setAttribute("dir","rtl"),d.classList.add("rtl"),d.classList.remove("ltr")):(m.setAttribute("dir","ltr"),d.classList.add("ltr"),d.classList.remove("rtl"))},[r,a,i]);const c=d=>Q(null,null,function*(){s(d),localStorage.setItem("i18nextLng",d),yield oh()});return e.jsx(g2.Provider,{value:{language:r,changeLanguage:c,isRTL:i},children:t})},Yx=()=>{const t=y.useContext(g2);if(!t)throw new Error("useLanguage must be used within LanguageProvider");return t},x5=()=>{const[t,a]=y.useState({email:"",password:""}),[r,s]=y.useState(!1),[i,c]=y.useState(null),d=qa(),{t:m}=ca(),{isRTL:h}=Yx(),g="/assets/asm_ui_app/asm_app/",p="?v=1774269853",b=N=>{const{name:k,value:C}=N.target;a(D=>Se(ue({},D),{[k]:C})),c(null)},j=N=>Q(null,null,function*(){N.preventDefault(),s(!0),c(null);try{const{useAuth:k}=yield hu(()=>Q(null,null,function*(){const{useAuth:T}=yield Promise.resolve().then(()=>p5);return{useAuth:T}}),[]),C=(yield hu(()=>Q(null,null,function*(){const{default:T}=yield Promise.resolve().then(()=>z3);return{default:T}}),void 0)).default,D=yield C.login(t);if(D&&D.message){const T=Se(ue({},D.message),{email:t.email});localStorage.setItem("user",JSON.stringify(T)),D.message.sid&&C.setSessionId(D.message.sid);try{yield oh()}catch(E){console.warn("Could not load translations after login:",E)}d("/dashboard")}else c(m("login.loginFailed"))}catch(k){console.error("Login error:",k),c(k.message||m("login.loginFailed"))}finally{s(!1)}}),_=()=>Q(null,null,function*(){const N={full_name:"Demo User",email:"demo@seeraarabia.com",user_image:"",roles:["System Manager","Administrator"]};localStorage.setItem("user",JSON.stringify(N));try{yield oh()}catch(k){console.warn("Could not load translations after demo login:",k)}d("/dashboard")});return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900 py-12 px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"max-w-md w-full space-y-8",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsxs("div",{className:"w-32 h-32 flex items-center justify-center bg-white dark:bg-gray-800 rounded-2xl shadow-2xl p-4",children:[e.jsx("img",{src:`${g}${g.endsWith("/")?"":"/"}seera-logo.png${p}`,alt:"Seera Arabia",className:"w-full h-full object-contain",onError:N=>{const k=N.currentTarget.parentElement;k&&k.classList.add("bg-gradient-to-br","from-indigo-600","to-purple-600"),N.currentTarget.style.display="none";const C=N.currentTarget.nextElementSibling;C&&C.classList.remove("hidden")}}),e.jsxs("svg",{className:"w-20 h-20 hidden",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"white",fillOpacity:"0.9"}),e.jsx("path",{d:"M2 17L12 22L22 17V12L12 17L2 12V17Z",fill:"white",fillOpacity:"0.7"}),e.jsx("path",{d:"M12 12V17",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]})]})}),e.jsx("h2",{className:"text-center text-3xl font-semibold text-gray-900 dark:text-white",children:m("login.title")}),e.jsx("p",{className:"mt-2 text-center text-sm font-medium text-indigo-600 dark:text-indigo-400",children:m("login.subtitle")}),e.jsx("p",{className:"mt-1 text-center text-xs text-gray-600 dark:text-gray-400",children:m("login.signIn")})]}),e.jsxs("form",{className:"mt-8 space-y-6",onSubmit:j,children:[e.jsxs("div",{className:"rounded-md shadow-sm -space-y-px",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"sr-only",children:m("common.email")}),e.jsx("input",{id:"email",name:"email",type:"email",required:!0,className:"appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 dark:border-gray-600 placeholder-gray-500 dark:placeholder-gray-400 text-gray-900 dark:text-white bg-white dark:bg-gray-800 rounded-t-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",placeholder:m("login.emailPlaceholder"),value:t.email,onChange:b})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"sr-only",children:m("common.password")}),e.jsx("input",{id:"password",name:"password",type:"password",required:!0,className:"appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 dark:border-gray-600 placeholder-gray-500 dark:placeholder-gray-400 text-gray-900 dark:text-white bg-white dark:bg-gray-800 rounded-b-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",placeholder:m("login.passwordPlaceholder"),value:t.password,onChange:b})]})]}),i&&e.jsx("div",{className:"rounded-md bg-red-50 dark:bg-red-900/20 p-4",children:e.jsx("div",{className:"text-sm text-red-700 dark:text-red-400",children:i})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{type:"submit",disabled:r,className:"group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed",children:r?e.jsxs("div",{className:"flex items-center",children:[e.jsxs("svg",{className:"animate-spin -ml-1 mr-3 h-5 w-5 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),m("common.loading")]}):m("common.login")}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-gray-300 dark:border-gray-600"})}),e.jsx("div",{className:"relative flex justify-center text-sm",children:e.jsx("span",{className:"px-2 bg-gray-50 dark:bg-gray-900 text-gray-500 dark:text-gray-400",children:m("login.or")})})]}),e.jsxs("button",{type:"button",onClick:_,className:"w-full flex justify-center py-2 px-4 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",children:["🚀 ",m("login.demoLogin")]})]})]})]})})};function ju(t,a=[]){const[r,s]=y.useState(null),[i,c]=y.useState(!0),[d,m]=y.useState(null),h=y.useCallback(()=>Q(null,null,function*(){try{c(!0),m(null);const p=yield t();s(p)}catch(p){p instanceof mc?m(p.message):m(p instanceof Error?p.message:"Unknown error")}finally{c(!1)}}),a);y.useEffect(()=>{h()},[h]);const g=y.useCallback(()=>{h()},[h]);return{data:r,loading:i,error:d,refetch:g}}function f2(t){return ju(()=>mt.getUserDetails(t),[t])}function x2(){return ju(()=>mt.getDashboardStats())}function Zx(){return ju(()=>mt.getNumberCards())}function lc(t,a){return ju(()=>mt.getDashboardChartData(t,a),[t,JSON.stringify(a||{})])}function p2(){const[t,a]=y.useState(mt.isAuthenticated());return{isAuthenticated:t,login:i=>Q(null,null,function*(){try{const c=yield mt.login(i);if(c&&c.message)return c.message.sid&&mt.setSessionId(c.message.sid),a(!0),c;throw new Error("Login failed")}catch(c){throw a(!1),c}}),logout:()=>Q(null,null,function*(){try{yield mt.logout()}finally{mt.setSessionId(""),a(!1)}})}}const p5=Object.freeze(Object.defineProperty({__proto__:null,useApi:ju,useAuth:p2,useDashboardChart:lc,useDashboardStats:x2,useNumberCards:Zx,useUserDetails:f2},Symbol.toStringTag,{value:"Module"})),y5=()=>{const[t,a]=y.useState({}),[r,s]=y.useState(!1),i=()=>Q(null,null,function*(){s(!0);const c={};try{console.log("Testing basic connectivity...");try{const d=yield fetch("/api/method/frappe.desk.doctype.event.event.get_events",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({start:new Date().toISOString().split("T")[0],end:new Date(Date.now()+2592e6).toISOString().split("T")[0]}),signal:AbortSignal.timeout(1e4)});d.ok?c.csrfToken="✅ Basic Connectivity: SUCCESS":c.csrfToken=`❌ Basic Connectivity: HTTP ${d.status}`}catch(d){c.csrfToken=`❌ Basic Connectivity: ${d instanceof Error?d.message:"Unknown error"}`}console.log("Testing Frappe system endpoint...");try{yield mt.apiCall("/api/method/frappe.auth.get_logged_user",{method:"GET",headers:{"Content-Type":"application/json"}}),c.dashboardStats="✅ Frappe System API: SUCCESS"}catch(d){const m=d instanceof Error?d.message:"Unknown";m.includes("403")||m.includes("401")?c.dashboardStats="✅ Frappe System API: SUCCESS (auth required)":c.dashboardStats=`❌ Frappe System API: ${m}`}console.log("Testing Custom User Details...");try{const d=yield mt.getUserDetails();c.userDetails=d?"✅ Custom API: SUCCESS":"❌ Custom API: Failed"}catch(d){c.userDetails=`❌ Custom API (Expected): ${d instanceof Error?d.message:"Unknown"}`}console.log("Testing Custom Dashboard Stats...");try{const d=yield mt.getDashboardStats();c.doctypeRecords=d?"✅ Custom Stats: SUCCESS":"❌ Custom Stats: Failed"}catch(d){c.doctypeRecords=`❌ Custom Stats (Expected): ${d instanceof Error?d.message:"Unknown"}`}}catch(d){console.error("API Test Error:",d),d instanceof mc?c.error=`${d.message} (Status: ${d.status})`:c.error=d instanceof Error?d.message:"Unknown error"}a(c),s(!1)});return e.jsxs("div",{style:{padding:"20px",border:"1px solid #ccc",margin:"20px"},children:[e.jsx("h2",{children:"API Connection Test"}),e.jsx("button",{onClick:i,disabled:r,style:{padding:"10px 20px",marginBottom:"20px",backgroundColor:r?"#ccc":"#007bff",color:"white",border:"none",borderRadius:"4px",cursor:r?"not-allowed":"pointer"},children:r?"Testing...":"Test API Connection"}),e.jsxs("div",{children:[e.jsx("h3",{children:"Test Results:"}),e.jsxs("div",{style:{background:"#f5f5f5",padding:"15px",borderRadius:"5px",fontSize:"14px"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:"1. Basic Connectivity:"})," ",t.csrfToken||"Not tested"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"2. Frappe System API:"})," ",t.dashboardStats||"Not tested"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"3. Custom User API:"})," ",t.userDetails||"Not tested"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"4. Custom Stats API:"})," ",t.doctypeRecords||"Not tested"]}),t.error&&e.jsxs("div",{style:{color:"red"},children:[e.jsx("strong",{children:"Error:"})," ",t.error]})]}),e.jsxs("div",{style:{marginTop:"10px",fontSize:"12px",color:"#666"},children:[e.jsx("p",{children:e.jsx("strong",{children:"Expected Results:"})}),e.jsxs("ul",{children:[e.jsx("li",{children:"✅ Basic Connectivity should succeed (tests proxy connection)"}),e.jsx("li",{children:"✅ Frappe System API should succeed (tests Frappe API)"}),e.jsx("li",{children:"❌ Custom APIs will fail until you deploy the API file to your server"})]}),e.jsxs("p",{children:[e.jsx("strong",{children:"If Basic Connectivity fails:"})," Check your Frappe server is running and accessible"]})]})]})]})},Kf=t=>Number.isFinite(t)?Math.max(0,t):0;function b5({type:t,labels:a,datasets:r,height:s=220}){if(!(a!=null&&a.length)||!(r!=null&&r.length))return e.jsx("div",{className:"text-sm text-gray-500",children:"No data"});if(t.toLowerCase()==="pie"){const g=r[0].values.map(Kf),p=g.reduce((C,D)=>C+D,0)||1,b=Math.min(100,s/2-10),j=b+10,_=b+10;let N=0;const k=r[0].values.map((C,D)=>r[0].color||p1(D));return e.jsx("svg",{width:j*2,height:_*2,viewBox:`0 0 ${j*2} ${_*2}`,children:g.map((C,D)=>{const T=N/p*2*Math.PI;N+=C;const E=N/p*2*Math.PI,O=E-T>Math.PI?1:0,R=j+b*Math.cos(T),Y=_+b*Math.sin(T),P=j+b*Math.cos(E),U=_+b*Math.sin(E),J=`M ${j} ${_} L ${R} ${Y} A ${b} ${b} 0 ${O} 1 ${P} ${U} Z`;return e.jsx("path",{d:J,fill:k[D]},D)})})}const i=r,c=Math.max(...i.flatMap(g=>g.values.map(Kf)),1),d=Math.max(a.length*60,300),m=s-40,h=Math.max(20,(d-40)/a.length-10);return e.jsxs("svg",{width:d,height:s,viewBox:`0 0 ${d} ${s}`,children:[e.jsx("line",{x1:30,y1:10,x2:30,y2:m,stroke:"#e5e7eb"}),e.jsx("line",{x1:30,y1:m,x2:d-10,y2:m,stroke:"#e5e7eb"}),a.map((g,p)=>{const b=40+p*(h+10);let j=0;return e.jsxs("g",{children:[i.map((_,N)=>{const C=Kf(_.values[p]||0)/c*(m-20),D=m-C-j,T=_.color||p1(N);return j+=C,e.jsx("rect",{x:b,y:D,width:h,height:C,fill:T,rx:2},N)}),e.jsx("text",{x:b+h/2,y:s-5,textAnchor:"middle",fontSize:"10",fill:"#6b7280",children:v5(g,8)})]},p)})]})}function p1(t){const a=["#4F46E5","#10B981","#F59E0B","#EF4444","#6366F1","#22C55E","#E11D48"];return a[t%a.length]}function v5(t,a){return t.length>a?t.slice(0,a-1)+"…":t}const _5=({chartName:t,filters:a})=>{const{data:r,loading:s,error:i}=lc(t,a);return e.jsxs("div",{className:"bg-white rounded-lg shadow p-4 overflow-auto",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx("h4",{className:"text-sm font-semibold text-gray-800",children:t})}),s&&e.jsx("div",{className:"text-sm text-gray-500",children:"Loading…"}),i&&e.jsx("div",{className:"text-sm text-red-600",children:i}),!s&&!i&&r&&e.jsx(b5,{type:r.type,labels:r.labels,datasets:r.datasets})]})},w5=()=>{var _,N,k,C;const[t,a]=y.useState(null),[r,s]=y.useState([]),i=qa(),{logout:c}=p2(),{loading:d,error:m}=x2(),{data:h}=Zx(),{data:g,loading:p,error:b}=f2();y.useEffect(()=>{const D=localStorage.getItem("user");D?a(JSON.parse(D)):g&&a(g);const T=[{name:"USER001",full_name:"John Doe",email:"john.doe@seeraarabia.com",creation:new Date().toISOString(),modified:new Date().toISOString(),modified_by:"system",owner:"system",docstatus:0},{name:"USER002",full_name:"Jane Smith",email:"jane.smith@seeraarabia.com",creation:new Date(Date.now()-864e5).toISOString(),modified:new Date().toISOString(),modified_by:"system",owner:"system",docstatus:0},{name:"USER003",full_name:"Ahmed Al-Rashid",email:"ahmed.alrashid@seeraarabia.com",creation:new Date(Date.now()-1728e5).toISOString(),modified:new Date().toISOString(),modified_by:"system",owner:"system",docstatus:0},{name:"USER004",full_name:"Sarah Johnson",email:"sarah.johnson@seeraarabia.com",creation:new Date(Date.now()-2592e5).toISOString(),modified:new Date().toISOString(),modified_by:"system",owner:"system",docstatus:0},{name:"USER005",full_name:"Mohammed Hassan",email:"mohammed.hassan@seeraarabia.com",creation:new Date(Date.now()-3456e5).toISOString(),modified:new Date().toISOString(),modified_by:"system",owner:"system",docstatus:0}];s(T)},[g]);const j=()=>Q(null,null,function*(){try{yield c(),localStorage.removeItem("user"),i("/login")}catch(D){console.error("Logout error:",D),localStorage.removeItem("user"),i("/login")}});return d||p?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900",children:e.jsx("div",{className:"animate-spin rounded-full h-32 w-32 border-b-2 border-indigo-600"})}):e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900",children:[e.jsx("header",{className:"bg-white dark:bg-gray-800 shadow",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"flex justify-between items-center py-6",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white",children:"Dashboard"})}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Welcome, ",(t==null?void 0:t.full_name)||"User"]}),e.jsx("button",{onClick:j,className:"bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-md text-sm font-medium",children:"Logout"})]})]})})}),e.jsxs("main",{className:"max-w-7xl mx-auto py-6 sm:px-6 lg:px-8",children:[(m||b)&&e.jsx("div",{className:"mb-6 rounded-md bg-red-50 dark:bg-red-900/20 p-4",children:e.jsx("div",{className:"text-sm text-red-700 dark:text-red-400",children:m||b||"Failed to load dashboard data"})}),e.jsxs("div",{className:"grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-4 mb-8",children:[e.jsx("div",{className:"bg-white dark:bg-gray-800 overflow-hidden shadow rounded-lg",children:e.jsx("div",{className:"p-5",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 bg-indigo-500 rounded-md flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsx("div",{className:"ml-5 w-0 flex-1",children:e.jsxs("dl",{children:[e.jsx("dt",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 truncate",children:"Total Assets"}),e.jsx("dd",{className:"text-lg font-medium text-gray-900 dark:text-white",children:(_=h==null?void 0:h.total_assets)!=null?_:"-"})]})})]})})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 overflow-hidden shadow rounded-lg",children:e.jsx("div",{className:"p-5",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 bg-green-500 rounded-md flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})})}),e.jsx("div",{className:"ml-5 w-0 flex-1",children:e.jsxs("dl",{children:[e.jsx("dt",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 truncate",children:"Open Work Orders"}),e.jsx("dd",{className:"text-lg font-medium text-gray-900 dark:text-white",children:(N=h==null?void 0:h.work_orders_open)!=null?N:"-"})]})})]})})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 overflow-hidden shadow rounded-lg",children:e.jsx("div",{className:"p-5",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 bg-yellow-500 rounded-md flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})})}),e.jsx("div",{className:"ml-5 w-0 flex-1",children:e.jsxs("dl",{children:[e.jsx("dt",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 truncate",children:"In Progress"}),e.jsx("dd",{className:"text-lg font-medium text-gray-900 dark:text-white",children:(k=h==null?void 0:h.work_orders_in_progress)!=null?k:"-"})]})})]})})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 overflow-hidden shadow rounded-lg",children:e.jsx("div",{className:"p-5",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 bg-purple-500 rounded-md flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M3 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z",clipRule:"evenodd"})})})}),e.jsx("div",{className:"ml-5 w-0 flex-1",children:e.jsxs("dl",{children:[e.jsx("dt",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 truncate",children:"Completed Work Orders"}),e.jsx("dd",{className:"text-lg font-medium text-gray-900 dark:text-white",children:(C=h==null?void 0:h.work_orders_completed)!=null?C:"-"})]})})]})})})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-6 mb-8",children:["Up & Down Time Chart","Work Order Status Chart","Maintenance - Asset wise Count","Asset Maintenance Assignees Status Count","Asset Maintenance Frequency Chart","PPM Status","PPM Template Counts","Repair Cost"].map(D=>e.jsx(_5,{chartName:D},D))}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow overflow-hidden sm:rounded-md",children:[e.jsxs("div",{className:"px-4 py-5 sm:px-6",children:[e.jsx("h3",{className:"text-lg leading-6 font-medium text-gray-900 dark:text-white",children:"Recent Records"}),e.jsx("p",{className:"mt-1 max-w-2xl text-sm text-gray-500 dark:text-gray-400",children:"Latest entries from your Frappe backend"})]}),e.jsx("ul",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:r.map(D=>{var T;return e.jsx("li",{children:e.jsxs("div",{className:"px-4 py-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"flex-shrink-0 h-10 w-10",children:e.jsx("div",{className:"h-10 w-10 rounded-full bg-indigo-100 flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-medium text-indigo-600",children:((T=D.full_name)==null?void 0:T.charAt(0))||D.name.charAt(0)})})}),e.jsxs("div",{className:"ml-4",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:D.full_name||D.name}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:D.email||"No email"})]})]}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(D.creation).toLocaleDateString()})]})},D.name)})})]}),e.jsxs("div",{className:"mt-8",children:[e.jsx("h3",{className:"text-lg leading-6 font-medium text-gray-900 dark:text-white mb-4",children:"Quick Actions"}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsx("button",{onClick:()=>i("/users"),className:"bg-white dark:bg-gray-800 p-6 rounded-lg shadow hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 bg-blue-500 rounded-md flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M9 6a3 3 0 11-6 0 3 3 0 016 0zM17 6a3 3 0 11-6 0 3 3 0 016 0zM12.93 17c.046-.327.07-.66.07-1a6.97 6.97 0 00-1.5-4.33A5 5 0 0119 16v1h-6.07zM6 11a5 5 0 015 5v1H1v-1a5 5 0 015-5z"})})})}),e.jsxs("div",{className:"ml-4",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"View Users"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Manage user accounts"})]})]})}),e.jsx("button",{onClick:()=>i("/settings"),className:"bg-white dark:bg-gray-800 p-6 rounded-lg shadow hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 bg-gray-500 rounded-md flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z",clipRule:"evenodd"})})})}),e.jsxs("div",{className:"ml-4",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Settings"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Configure your preferences"})]})]})}),e.jsx("button",{onClick:()=>i("/events"),className:"bg-white dark:bg-gray-800 p-6 rounded-lg shadow hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 bg-purple-500 rounded-md flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})})}),e.jsxs("div",{className:"ml-4",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Events"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"View calendar events"})]})]})}),e.jsx("button",{onClick:()=>i("/reports"),className:"bg-white dark:bg-gray-800 p-6 rounded-lg shadow hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 bg-green-500 rounded-md flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M3 3a1 1 0 000 2v8a2 2 0 002 2h2.586l-1.293 1.293a1 1 0 101.414 1.414L10 15.414l2.293 2.293a1 1 0 001.414-1.414L12.414 15H15a2 2 0 002-2V5a1 1 0 100-2H3zm11.707 4.707a1 1 0 00-1.414-1.414L10 9.586 8.707 8.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})})}),e.jsxs("div",{className:"ml-4",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Reports"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"View analytics and reports"})]})]})})]})]}),e.jsx("div",{className:"mt-8",children:e.jsx(y5,{})})]})]})},k5=["*"];class j5{getWorkOrders(a,r,s=20,i=0,c,d){return Q(this,null,function*(){try{const{toFrappeFilterArray:m}=yield hu(()=>Q(null,null,function*(){const{toFrappeFilterArray:C}=yield Promise.resolve().then(()=>Np);return{toFrappeFilterArray:C}}),void 0),h=m(a||{}),g={doctype:"Work_Order",filters:h.length>0?h:{},fields:r||k5,limit_start:i,limit_page_length:s,order_by:c||"creation desc"};d&&d.length>0&&(g.or_filters=d),console.log("[workOrderService] getWorkOrders request:",g);const p=yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);const j=(yield p.json()).message||[];let _=0;const N={doctype:"Work_Order",filters:h.length>0?h:{},fields:["name"],limit_page_length:0};d&&d.length>0&&(N.or_filters=d);const k=yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N)});return k.ok&&(_=((yield k.json()).message||[]).length),{work_orders:j,total_count:_,limit:s,offset:i,has_more:i+s<_}}catch(m){throw console.error("[workOrderService] getWorkOrders error:",m),m}})}getWorkOrderDetails(a){return Q(this,null,function*(){const r=`${ia.ENDPOINTS.GET_WORK_ORDER_DETAILS}?work_order_name=${encodeURIComponent(a)}`;return mt.apiCall(r)})}createWorkOrder(a){return Q(this,null,function*(){return mt.apiCall(ia.ENDPOINTS.CREATE_WORK_ORDER,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({work_order_data:a})})})}updateWorkOrder(a,r){return Q(this,null,function*(){return mt.apiCall(ia.ENDPOINTS.UPDATE_WORK_ORDER,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({work_order_name:a,work_order_data:r})})})}deleteWorkOrder(a){return Q(this,null,function*(){return mt.apiCall(ia.ENDPOINTS.DELETE_WORK_ORDER,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({work_order_name:a})})})}updateWorkOrderStatus(a,r,s){return Q(this,null,function*(){return mt.apiCall(ia.ENDPOINTS.UPDATE_WORK_ORDER_STATUS,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({work_order_name:a,repair_status:r,workflow_state:s})})})}getWorkOrderFilters(){return Q(this,null,function*(){return mt.apiCall(ia.ENDPOINTS.GET_WORK_ORDER_FILTERS)})}getWorkOrderStats(){return Q(this,null,function*(){return mt.apiCall(ia.ENDPOINTS.GET_WORK_ORDER_STATS)})}searchWorkOrders(a,r=10){return Q(this,null,function*(){const s=`${ia.ENDPOINTS.SEARCH_WORK_ORDERS}?search_term=${encodeURIComponent(a)}&limit=${r}`;return mt.apiCall(s)})}submitWorkOrder(a){return Q(this,null,function*(){return mt.apiCall("/api/method/frappe.client.submit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doc:{doctype:"Asset Repair",name:a}})})})}cancelWorkOrder(a){return Q(this,null,function*(){return mt.apiCall("/api/method/frappe.client.cancel",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doc:{doctype:"Asset Repair",name:a}})})})}getWorkOrdersByAsset(a,r=50){return Q(this,null,function*(){const s={asset:a};return(yield this.getWorkOrders(s,void 0,r,0,"creation desc")).work_orders})}getOpenWorkOrders(a=50){return Q(this,null,function*(){const r={repair_status:["not in",["Completed","Cancelled"]]};return(yield this.getWorkOrders(r,void 0,a,0,"creation desc")).work_orders})}getWorkOrdersByPriority(a,r=50){return Q(this,null,function*(){const s={custom_priority_:a};return(yield this.getWorkOrders(s,void 0,r,0,"creation desc")).work_orders})}}const cc=new j5,N5=(t,a)=>{const r=ue({},t||{});for(const[s,i]of Object.entries(a))if(!r[s])r[s]=i;else if(Array.isArray(i)&&i[0]==="in"){const c=i[1],d=r[s];if(typeof d=="string")c.includes(d)||(r[s]=["in",[]]);else if(Array.isArray(d)&&d[0]==="in"){const h=d[1].filter(g=>c.includes(g));r[s]=["in",h]}else r[s]=i}return r};function y2(t,a=20,r=0,s,i={},c){const[d,m]=y.useState([]),[h,g]=y.useState(0),[p,b]=y.useState(!1),[j,_]=y.useState(!0),[N,k]=y.useState(null),[C,D]=y.useState(0),T=y.useRef(!1),E=JSON.stringify(t),O=JSON.stringify(i),R=JSON.stringify(c);y.useEffect(()=>{if(T.current&&N)return;let P=!1;return T.current=!0,Q(null,null,function*(){try{_(!0);const J=N5(t,i);console.log("[useWorkOrders] User filters:",t),console.log("[useWorkOrders] Permission filters:",i),console.log("[useWorkOrders] OR filters:",c),console.log("[useWorkOrders] Merged filters:",J);const ne=yield cc.getWorkOrders(J,void 0,a,r,s,c);P||(m(ne.work_orders),g(ne.total_count),b(ne.has_more),k(null))}catch(J){if(!P){const ne=J instanceof Error?J.message:"Failed to fetch work orders";ne.includes("417")||ne.includes("Expectation Failed")||ne.includes("has no attribute")?k("API endpoint not deployed or misconfigured. Please check FIX_417_ERROR.md for solutions."):k(ne),m([]),g(0),b(!1)}}finally{P||_(!1)}}),()=>{P=!0}},[E,O,R,a,r,s,C]);const Y=y.useCallback(()=>{T.current=!1,D(P=>P+1)},[]);return{workOrders:d,totalCount:h,hasMore:p,loading:j,error:N,refetch:Y}}function S5(t){const[a,r]=y.useState(null),[s,i]=y.useState(!0),[c,d]=y.useState(null),m=y.useCallback(()=>Q(null,null,function*(){if(!t){r(null),i(!1);return}try{i(!0),d(null);const g=yield cc.getWorkOrderDetails(t);r(g)}catch(g){d(g instanceof Error?g.message:"Failed to fetch work order details")}finally{i(!1)}}),[t]);y.useEffect(()=>{m()},[m]);const h=y.useCallback(()=>{m()},[m]);return{workOrder:a,loading:s,error:c,refetch:h}}function b2(){const[t,a]=y.useState(!1),[r,s]=y.useState(null);return{createWorkOrder:g=>Q(null,null,function*(){try{a(!0),s(null),console.log("[useWorkOrderMutations] Creating work order with data:",g);const p=yield cc.createWorkOrder(g);if(console.log("[useWorkOrderMutations] Create work order response:",p),p.success)return p.work_order;{const b=p.error||"Failed to create work order";throw new Error(b)}}catch(p){console.error("[useWorkOrderMutations] Create work order error:",p);const b=p instanceof Error?p.message:"Failed to create work order";throw s(b),p}finally{a(!1)}}),updateWorkOrder:(g,p)=>Q(null,null,function*(){try{a(!0),s(null),console.log("[useWorkOrderMutations] Updating work order:",g,"with data:",p);const b=yield cc.updateWorkOrder(g,p);if(console.log("[useWorkOrderMutations] Update work order response:",b),b.success)return b.work_order;{const j=b.error||"Failed to update work order";throw new Error(j)}}catch(b){console.error("[useWorkOrderMutations] Update work order error:",b);const j=b instanceof Error?b.message:"Failed to update work order";throw s(j),b}finally{a(!1)}}),deleteWorkOrder:g=>Q(null,null,function*(){try{a(!0),s(null);const p=yield cc.deleteWorkOrder(g);if(!p.success)throw new Error("Failed to delete work order");return p}catch(p){const b=p instanceof Error?p.message:"Failed to delete work order";throw s(b),p}finally{a(!1)}}),submitWorkOrder:g=>Q(null,null,function*(){try{a(!0),s(null),console.log("[useWorkOrderMutations] Submitting work order:",g);const p=yield cc.submitWorkOrder(g);return console.log("[useWorkOrderMutations] Submit work order response:",p),p}catch(p){console.error("[useWorkOrderMutations] Submit work order error:",p);const b=p instanceof Error?p.message:"Failed to submit work order";throw s(b),p}finally{a(!1)}}),updateStatus:(g,p,b)=>Q(null,null,function*(){try{a(!0),s(null);const j=yield cc.updateWorkOrderStatus(g,p,b);if(j.success)return j.work_order;throw new Error("Failed to update work order status")}catch(j){const _=j instanceof Error?j.message:"Failed to update status";throw s(_),j}finally{a(!1)}}),loading:t,error:r}}const Ei=mt;class C5{getMaintenanceLogs(a,r,s=20,i=0,c){return Q(this,null,function*(){const d=new URLSearchParams;a&&d.append("filters",JSON.stringify(a)),r&&r.length>0&&d.append("fields",JSON.stringify(r)),d.append("limit",s.toString()),d.append("offset",i.toString()),c&&d.append("order_by",c),d.append("include_child_tables","true");const m=`${ia.ENDPOINTS.GET_ASSET_MAINTENANCE_LOGS}?${d.toString()}`;return Ei.apiCall(m)})}getMaintenanceLogDetails(a){return Q(this,null,function*(){const r=new URLSearchParams;r.append("log_name",a),r.append("include_child_tables","true");const s=`${ia.ENDPOINTS.GET_ASSET_MAINTENANCE_LOG_DETAILS}?${r.toString()}`;return Ei.apiCall(s)})}createMaintenanceLog(a){return Q(this,null,function*(){const r=this.prepareLogData(a);return Ei.apiCall(ia.ENDPOINTS.CREATE_ASSET_MAINTENANCE_LOG,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_data:r})})})}updateMaintenanceLog(a,r){return Q(this,null,function*(){const s=this.prepareLogData(r);return Ei.apiCall(ia.ENDPOINTS.UPDATE_ASSET_MAINTENANCE_LOG,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_name:a,log_data:s})})})}deleteMaintenanceLog(a){return Q(this,null,function*(){return Ei.apiCall(ia.ENDPOINTS.DELETE_ASSET_MAINTENANCE_LOG,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_name:a})})})}updateMaintenanceStatus(a,r,s){return Q(this,null,function*(){return Ei.apiCall(ia.ENDPOINTS.UPDATE_MAINTENANCE_STATUS,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_name:a,maintenance_status:r,workflow_state:s})})})}getMaintenanceLogsByAsset(a,r,s=20,i=0){return Q(this,null,function*(){const c=new URLSearchParams;c.append("asset_name",a),r&&c.append("filters",JSON.stringify(r)),c.append("limit",s.toString()),c.append("offset",i.toString()),c.append("include_child_tables","true");const d=`${ia.ENDPOINTS.GET_MAINTENANCE_LOGS_BY_ASSET}?${c.toString()}`;return Ei.apiCall(d)})}getOverdueMaintenanceLogs(a,r=20,s=0){return Q(this,null,function*(){const i=new URLSearchParams;a&&i.append("filters",JSON.stringify(a)),i.append("limit",r.toString()),i.append("offset",s.toString()),i.append("include_child_tables","true");const c=`${ia.ENDPOINTS.GET_OVERDUE_MAINTENANCE_LOGS}?${i.toString()}`;return Ei.apiCall(c)})}addPPMTableRow(a,r){return Q(this,null,function*(){return Ei.apiCall(ia.ENDPOINTS.ADD_PPM_TABLE_ROW||"/api/method/asset_lite.api.asset_maintenance_api.add_ppm_table_row",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_name:a,row_data:this.cleanPPMRow(r)})})})}removePPMTableRow(a,r){return Q(this,null,function*(){return Ei.apiCall(ia.ENDPOINTS.REMOVE_PPM_TABLE_ROW||"/api/method/asset_lite.api.asset_maintenance_api.remove_ppm_table_row",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_name:a,row_name:r})})})}updatePPMTableRow(a,r,s){return Q(this,null,function*(){return Ei.apiCall(ia.ENDPOINTS.UPDATE_PPM_TABLE_ROW||"/api/method/asset_lite.api.asset_maintenance_api.update_ppm_table_row",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_name:a,row_name:r,row_data:this.cleanPPMRow(s)})})})}cleanPPMRow(a){return Se(ue({},a.name&&!a.name.startsWith("new-")?{name:a.name}:{}),{maintenance_name:a.maintenance_name||"",working:typeof a.working=="boolean"?a.working?1:0:a.working||0,defect_found:typeof a.defect_found=="boolean"?a.defect_found?1:0:a.defect_found||0,not_working:typeof a.not_working=="boolean"?a.not_working?1:0:a.not_working||0})}prepareLogData(a){const r={},s=["asset_name","custom_asset_type","item_code","item_name","custom_asset_names","custom_hospital_name","task","task_name","maintenance_type","periodicity","custom_template","maintenance_status","due_date","completion_date","assign_to_name","has_certificate","custom_early_completion","custom_early_completion_reason","custom_accepted_by_moh","custom_accepted_by_moh_","custom_pm_overdue_reason","description","custom_table"];for(const i of s)a[i]!==void 0&&a[i]!==null&&a[i]!==""&&(r[i]=a[i]);return typeof r.has_certificate=="boolean"&&(r.has_certificate=r.has_certificate?1:0),typeof r.custom_accepted_by_moh=="boolean"&&(r.custom_accepted_by_moh=r.custom_accepted_by_moh?1:0),typeof r.custom_accepted_by_moh_=="boolean"&&(r.custom_accepted_by_moh_=r.custom_accepted_by_moh_?1:0),r.custom_table&&Array.isArray(r.custom_table)&&(r.custom_table=r.custom_table.map(i=>this.cleanPPMRow(i))),r}}const Td=new C5;function Rh(t,a=20,r=0,s){const[i,c]=y.useState([]),[d,m]=y.useState(0),[h,g]=y.useState(!1),[p,b]=y.useState(!0),[j,_]=y.useState(null),[N,k]=y.useState(0),C=y.useRef(!1),D=JSON.stringify(t);y.useEffect(()=>{if(C.current&&j)return;let E=!1;return C.current=!0,Q(null,null,function*(){try{b(!0);const R=yield Td.getMaintenanceLogs(t,void 0,a,r,s);E||(c(R.asset_maintenance_logs),m(R.total_count),g(R.has_more),_(null))}catch(R){if(!E){const Y=R instanceof Error?R.message:"Failed to fetch maintenance logs";Y.includes("417")||Y.includes("Expectation Failed")||Y.includes("has no attribute")?_("API endpoint not deployed. Please deploy asset_maintenance_api.py to your Frappe server."):_(Y),c([]),m(0),g(!1)}}finally{E||b(!1)}}),()=>{E=!0}},[D,a,r,s,N]);const T=y.useCallback(()=>{C.current=!1,k(E=>E+1)},[]);return{logs:i,totalCount:d,hasMore:h,loading:p,error:j,refetch:T}}function T5(t){const[a,r]=y.useState(null),[s,i]=y.useState(!0),[c,d]=y.useState(null),m=y.useCallback(()=>Q(null,null,function*(){if(!t){r(null),i(!1);return}try{i(!0),d(null);const g=yield Td.getMaintenanceLogDetails(t);r(g)}catch(g){d(g instanceof Error?g.message:"Failed to fetch maintenance log details")}finally{i(!1)}}),[t]);y.useEffect(()=>{m()},[m]);const h=y.useCallback(()=>{m()},[m]);return{log:a,loading:s,error:c,refetch:h}}function v2(){const[t,a]=y.useState(!1),[r,s]=y.useState(null);return{createLog:h=>Q(null,null,function*(){try{a(!0),s(null),console.log("[useMaintenanceMutations] Creating maintenance log:",h);const g=yield Td.createMaintenanceLog(h);if(console.log("[useMaintenanceMutations] Create response:",g),g.success)return g.asset_maintenance_log;{const p=g.error||"Failed to create maintenance log";throw new Error(p)}}catch(g){console.error("[useMaintenanceMutations] Create error:",g);const p=g instanceof Error?g.message:"Failed to create maintenance log";throw s(p),g}finally{a(!1)}}),updateLog:(h,g)=>Q(null,null,function*(){try{a(!0),s(null),console.log("[useMaintenanceMutations] Updating maintenance log:",h,g);const p=yield Td.updateMaintenanceLog(h,g);if(console.log("[useMaintenanceMutations] Update response:",p),p.success)return p.asset_maintenance_log;{const b=p.error||"Failed to update maintenance log";throw new Error(b)}}catch(p){console.error("[useMaintenanceMutations] Update error:",p);const b=p instanceof Error?p.message:"Failed to update maintenance log";throw s(b),p}finally{a(!1)}}),deleteLog:h=>Q(null,null,function*(){try{a(!0),s(null);const g=yield Td.deleteMaintenanceLog(h);if(!g.success)throw new Error("Failed to delete maintenance log");return g}catch(g){const p=g instanceof Error?g.message:"Failed to delete maintenance log";throw s(p),g}finally{a(!1)}}),updateStatus:(h,g,p)=>Q(null,null,function*(){try{a(!0),s(null);const b=yield Td.updateMaintenanceStatus(h,g,p);if(b.success)return b.asset_maintenance_log;throw new Error("Failed to update maintenance status")}catch(b){const j=b instanceof Error?b.message:"Failed to update status";throw s(j),b}finally{a(!1)}}),loading:t,error:r}}class E5{getAssets(a,r,s=20,i=0,c){return Q(this,null,function*(){const d=new URLSearchParams;if(a&&Object.keys(a).length>0){const{toFrappeFilterArray:h}=yield hu(()=>Q(null,null,function*(){const{toFrappeFilterArray:p}=yield Promise.resolve().then(()=>Np);return{toFrappeFilterArray:p}}),void 0),g=h(a);g.length>0&&d.append("filters",JSON.stringify(g))}r&&r.length>0&&d.append("fields",JSON.stringify(r)),d.append("limit",s.toString()),d.append("offset",i.toString()),c&&d.append("order_by",c);const m=`${ia.ENDPOINTS.GET_ASSETS}?${d.toString()}`;return mt.apiCall(m)})}getAssetDetails(a){return Q(this,null,function*(){const r=`${ia.ENDPOINTS.GET_ASSET_DETAILS}?asset_name=${encodeURIComponent(a)}`;return mt.apiCall(r)})}createAsset(a){return Q(this,null,function*(){return mt.apiCall(ia.ENDPOINTS.CREATE_ASSET,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({asset_data:a})})})}updateAsset(a,r){return Q(this,null,function*(){return mt.apiCall(ia.ENDPOINTS.UPDATE_ASSET,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({asset_name:a,asset_data:r})})})}deleteAsset(a){return Q(this,null,function*(){return mt.apiCall(ia.ENDPOINTS.DELETE_ASSET,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({asset_name:a})})})}getAssetFilters(){return Q(this,null,function*(){return mt.apiCall(ia.ENDPOINTS.GET_ASSET_FILTERS)})}getAssetStats(){return Q(this,null,function*(){return mt.apiCall(ia.ENDPOINTS.GET_ASSET_STATS)})}searchAssets(a,r=10){return Q(this,null,function*(){const s=`${ia.ENDPOINTS.SEARCH_ASSETS}?search_term=${encodeURIComponent(a)}&limit=${r}`;return mt.apiCall(s)})}submitAsset(a){return Q(this,null,function*(){return mt.apiCall(ia.ENDPOINTS.SUBMIT_ASSET||"/api/method/asset_lite.api.asset_api.submit_asset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({asset_name:a})})})}}const Ed=new E5,A5=(t,a)=>{const r=ue({},t||{});for(const[s,i]of Object.entries(a))if(!r[s])r[s]=i;else if(Array.isArray(i)&&i[0]==="in"){const c=i[1],d=r[s];if(typeof d=="string")c.includes(d)||(r[s]=["in",[]]);else if(Array.isArray(d)&&d[0]==="in"){const h=d[1].filter(g=>c.includes(g));r[s]=["in",h]}else r[s]=i}return r};function _2(t,a=20,r=0,s,i={}){const[c,d]=y.useState([]),[m,h]=y.useState(0),[g,p]=y.useState(!1),[b,j]=y.useState(!0),[_,N]=y.useState(null),[k,C]=y.useState(0),D=y.useRef(!1),T=JSON.stringify(t),E=JSON.stringify(i);y.useEffect(()=>{if(D.current&&_)return;let R=!1;return D.current=!0,Q(null,null,function*(){try{j(!0);const P=A5(t,i);console.log("[useAssets] User filters:",t),console.log("[useAssets] Permission filters:",i),console.log("[useAssets] Merged filters:",P);const U=yield Ed.getAssets(P,void 0,a,r,s);R||(d(U.assets),h(U.total_count),p(U.has_more),N(null))}catch(P){if(!R){const U=P instanceof Error?P.message:"Failed to fetch assets";U.includes("417")||U.includes("Expectation Failed")||U.includes("has no attribute")?N("API endpoint not deployed or misconfigured. Please check FIX_417_ERROR.md for solutions."):N(U),d([]),h(0),p(!1)}}finally{R||j(!1)}}),()=>{R=!0}},[T,E,a,r,s,k]);const O=y.useCallback(()=>{D.current=!1,C(R=>R+1)},[]);return{assets:c,totalCount:m,hasMore:g,loading:b,error:_,refetch:O}}function O5(t){const[a,r]=y.useState(null),[s,i]=y.useState(!0),[c,d]=y.useState(null),m=y.useCallback(()=>Q(null,null,function*(){if(!t){r(null),i(!1);return}try{i(!0),d(null);const g=yield Ed.getAssetDetails(t);r(g)}catch(g){d(g instanceof Error?g.message:"Failed to fetch asset details")}finally{i(!1)}}),[t]);y.useEffect(()=>{m()},[m]);const h=y.useCallback(()=>{m()},[m]);return{asset:a,loading:s,error:c,refetch:h}}function w2(){const[t,a]=y.useState(!1),[r,s]=y.useState(null);return{createAsset:h=>Q(null,null,function*(){try{a(!0),s(null),console.log("[useAssetMutations] Creating asset with data:",h);const g=yield Ed.createAsset(h);if(console.log("[useAssetMutations] Create asset response:",g),g.success)return g.asset;{const p=g.error||"Failed to create asset";throw new Error(p)}}catch(g){console.error("[useAssetMutations] Create asset error:",g);const p=g instanceof Error?g.message:"Failed to create asset";throw s(p),g}finally{a(!1)}}),updateAsset:(h,g)=>Q(null,null,function*(){try{a(!0),s(null),console.log("[useAssetMutations] Updating asset:",h,"with data:",g);const p=yield Ed.updateAsset(h,g);if(console.log("[useAssetMutations] Update asset response:",p),p.success)return p.asset;{const b=p.error||"Failed to update asset";throw new Error(b)}}catch(p){console.error("[useAssetMutations] Update asset error:",p);const b=p instanceof Error?p.message:"Failed to update asset";throw s(b),p}finally{a(!1)}}),deleteAsset:h=>Q(null,null,function*(){try{a(!0),s(null);const g=yield Ed.deleteAsset(h);if(!g.success)throw new Error("Failed to delete asset");return g}catch(g){const p=g instanceof Error?g.message:"Failed to delete asset";throw s(p),g}finally{a(!1)}}),submitAsset:h=>Q(null,null,function*(){try{a(!0),s(null),console.log("[useAssetMutations] Submitting asset:",h);const g=yield Ed.submitAsset(h);return console.log("[useAssetMutations] Submit asset response:",g),g}catch(g){console.error("[useAssetMutations] Submit asset error:",g);const p=g instanceof Error?g.message:"Failed to submit asset";throw s(p),g}finally{a(!1)}}),loading:t,error:r}}var k2={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},y1=pa.createContext&&pa.createContext(k2),D5=["attr","size","title"];function M5(t,a){if(t==null)return{};var r=L5(t,a),s,i;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(t);for(i=0;i<c.length;i++)s=c[i],!(a.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(t,s)&&(r[s]=t[s])}return r}function L5(t,a){if(t==null)return{};var r={};for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s)){if(a.indexOf(s)>=0)continue;r[s]=t[s]}return r}function ch(){return ch=Object.assign?Object.assign.bind():function(t){for(var a=1;a<arguments.length;a++){var r=arguments[a];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},ch.apply(this,arguments)}function b1(t,a){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);a&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,s)}return r}function dh(t){for(var a=1;a<arguments.length;a++){var r=arguments[a]!=null?arguments[a]:{};a%2?b1(Object(r),!0).forEach(function(s){R5(t,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):b1(Object(r)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(r,s))})}return t}function R5(t,a,r){return a=P5(a),a in t?Object.defineProperty(t,a,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[a]=r,t}function P5(t){var a=F5(t,"string");return typeof a=="symbol"?a:a+""}function F5(t,a){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var s=r.call(t,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(t)}function j2(t){return t&&t.map((a,r)=>pa.createElement(a.tag,dh({key:r},a.attr),j2(a.child)))}function Yt(t){return a=>pa.createElement(I5,ch({attr:dh({},t.attr)},a),j2(t.child))}function I5(t){var a=r=>{var{attr:s,size:i,title:c}=t,d=M5(t,D5),m=i||r.size||"1em",h;return r.className&&(h=r.className),t.className&&(h=(h?h+" ":"")+t.className),pa.createElement("svg",ch({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,s,d,{className:h,style:dh(dh({color:t.color||r.color},r.style),t.style),height:m,width:m,xmlns:"http://www.w3.org/2000/svg"}),c&&pa.createElement("title",null,c),t.children)};return y1!==void 0?pa.createElement(y1.Consumer,null,r=>a(r)):a(k2)}function z5(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z"},child:[]}]})(t)}function en(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M257.5 445.1l-22.2 22.2c-9.4 9.4-24.6 9.4-33.9 0L7 273c-9.4-9.4-9.4-24.6 0-33.9L201.4 44.7c9.4-9.4 24.6-9.4 33.9 0l22.2 22.2c9.5 9.5 9.3 25-.4 34.3L136.6 216H424c13.3 0 24 10.7 24 24v32c0 13.3-10.7 24-24 24H136.6l120.5 114.8c9.8 9.3 10 24.8.4 34.3z"},child:[]}]})(t)}function B5(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z"},child:[]}]})(t)}function ei(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 8C119.034 8 8 119.033 8 256s111.034 248 248 248 248-111.034 248-248S392.967 8 256 8zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676zM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676z"},child:[]}]})(t)}function v1(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M224 512c35.32 0 63.97-28.65 63.97-64H160.03c0 35.35 28.65 64 63.97 64zm215.39-149.71c-19.32-20.76-55.47-51.99-55.47-154.29 0-77.7-54.48-139.9-127.94-155.16V32c0-17.67-14.32-32-31.98-32s-31.98 14.33-31.98 32v20.84C118.56 68.1 64.08 130.3 64.08 208c0 102.3-36.15 133.53-55.47 154.29-6 6.45-8.66 14.16-8.61 21.71.11 16.4 12.98 32 32.1 32h383.8c19.12 0 32-15.6 32.1-32 .05-7.55-2.61-15.27-8.61-21.71z"},child:[]}]})(t)}function U5(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M509.5 184.6L458.9 32.8C452.4 13.2 434.1 0 413.4 0H272v192h238.7c-.4-2.5-.4-5-1.2-7.4zM240 0H98.6c-20.7 0-39 13.2-45.5 32.8L2.5 184.6c-.8 2.4-.8 4.9-1.2 7.4H240V0zM0 224v240c0 26.5 21.5 48 48 48h416c26.5 0 48-21.5 48-48V224H0z"},child:[]}]})(t)}function Sx(t){return Yt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M560 288h-80v96l-32-21.3-32 21.3v-96h-80c-8.8 0-16 7.2-16 16v192c0 8.8 7.2 16 16 16h224c8.8 0 16-7.2 16-16V304c0-8.8-7.2-16-16-16zm-384-64h224c8.8 0 16-7.2 16-16V16c0-8.8-7.2-16-16-16h-80v96l-32-21.3L256 96V0h-80c-8.8 0-16 7.2-16 16v192c0 8.8 7.2 16 16 16zm64 64h-80v96l-32-21.3L96 384v-96H16c-8.8 0-16 7.2-16 16v192c0 8.8 7.2 16 16 16h224c8.8 0 16-7.2 16-16V304c0-8.8-7.2-16-16-16z"},child:[]}]})(t)}function Jx(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M436 480h-20V24c0-13.255-10.745-24-24-24H56C42.745 0 32 10.745 32 24v456H12c-6.627 0-12 5.373-12 12v20h448v-20c0-6.627-5.373-12-12-12zM128 76c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v40c0 6.627-5.373 12-12 12h-40c-6.627 0-12-5.373-12-12V76zm0 96c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v40c0 6.627-5.373 12-12 12h-40c-6.627 0-12-5.373-12-12v-40zm52 148h-40c-6.627 0-12-5.373-12-12v-40c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v40c0 6.627-5.373 12-12 12zm76 160h-64v-84c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v84zm64-172c0 6.627-5.373 12-12 12h-40c-6.627 0-12-5.373-12-12v-40c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v40zm0-96c0 6.627-5.373 12-12 12h-40c-6.627 0-12-5.373-12-12v-40c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v40zm0-96c0 6.627-5.373 12-12 12h-40c-6.627 0-12-5.373-12-12V76c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v40z"},child:[]}]})(t)}function go(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M0 464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V192H0v272zm320-196c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zm0 128c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zM192 268c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zm0 128c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zM64 268c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H76c-6.6 0-12-5.4-12-12v-40zm0 128c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H76c-6.6 0-12-5.4-12-12v-40zM400 64h-48V16c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v48H160V16c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v48H48C21.5 64 0 85.5 0 112v48h448v-48c0-26.5-21.5-48-48-48z"},child:[]}]})(t)}function Xx(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M436 160H12c-6.627 0-12-5.373-12-12v-36c0-26.51 21.49-48 48-48h48V12c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v52h128V12c0-6.627 5.373-12 12-12h40c6.627 0 12 5.373 12 12v52h48c26.51 0 48 21.49 48 48v36c0 6.627-5.373 12-12 12zM12 192h424c6.627 0 12 5.373 12 12v260c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V204c0-6.627 5.373-12 12-12zm333.296 95.947l-28.169-28.398c-4.667-4.705-12.265-4.736-16.97-.068L194.12 364.665l-45.98-46.352c-4.667-4.705-12.266-4.736-16.971-.068l-28.397 28.17c-4.705 4.667-4.736 12.265-.068 16.97l82.601 83.269c4.667 4.705 12.265 4.736 16.97.068l142.953-141.805c4.705-4.667 4.736-12.265.068-16.97z"},child:[]}]})(t)}function Qm(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12 192h424c6.6 0 12 5.4 12 12v260c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V204c0-6.6 5.4-12 12-12zm436-44v-36c0-26.5-21.5-48-48-48h-48V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H160V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H48C21.5 64 0 85.5 0 112v36c0 6.6 5.4 12 12 12h424c6.6 0 12-5.4 12-12z"},child:[]}]})(t)}function N2(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M496 384H64V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-32c0-8.84-7.16-16-16-16zM464 96H345.94c-21.38 0-32.09 25.85-16.97 40.97l32.4 32.4L288 242.75l-73.37-73.37c-12.5-12.5-32.76-12.5-45.25 0l-68.69 68.69c-6.25 6.25-6.25 16.38 0 22.63l22.62 22.62c6.25 6.25 16.38 6.25 22.63 0L192 237.25l73.37 73.37c12.5 12.5 32.76 12.5 45.25 0l96-96 32.4 32.4c15.12 15.12 40.97 4.41 40.97-16.97V112c.01-8.84-7.15-16-15.99-16z"},child:[]}]})(t)}function ea(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z"},child:[]}]})(t)}function Es(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 480H48c-26.51 0-48-21.49-48-48V80c0-26.51 21.49-48 48-48h352c26.51 0 48 21.49 48 48v352c0 26.51-21.49 48-48 48zm-204.686-98.059l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.248-16.379-6.249-22.628 0L184 302.745l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.25 16.379 6.25 22.628.001z"},child:[]}]})(t)}function dc(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"},child:[]}]})(t)}function cs(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z"},child:[]}]})(t)}function S2(t){return Yt({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z"},child:[]}]})(t)}function C2(t){return Yt({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"},child:[]}]})(t)}function As(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M240.971 130.524l194.343 194.343c9.373 9.373 9.373 24.569 0 33.941l-22.667 22.667c-9.357 9.357-24.522 9.375-33.901.04L224 227.495 69.255 381.516c-9.379 9.335-24.544 9.317-33.901-.04l-22.667-22.667c-9.373-9.373-9.373-24.569 0-33.941L207.03 130.525c9.372-9.373 24.568-9.373 33.941-.001z"},child:[]}]})(t)}function bi(t){return Yt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M336 64h-80c0-35.3-28.7-64-64-64s-64 28.7-64 64H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V112c0-26.5-21.5-48-48-48zM192 40c13.3 0 24 10.7 24 24s-10.7 24-24 24-24-10.7-24-24 10.7-24 24-24zm121.2 231.8l-143 141.8c-4.7 4.7-12.3 4.6-17-.1l-82.6-83.3c-4.7-4.7-4.6-12.3.1-17L99.1 285c4.7-4.7 12.3-4.6 17 .1l46 46.4 106-105.2c4.7-4.7 12.3-4.6 17 .1l28.2 28.4c4.7 4.8 4.6 12.3-.1 17z"},child:[]}]})(t)}function _1(t){return Yt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M336 64h-80c0-35.3-28.7-64-64-64s-64 28.7-64 64H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V112c0-26.5-21.5-48-48-48zM96 424c-13.3 0-24-10.7-24-24s10.7-24 24-24 24 10.7 24 24-10.7 24-24 24zm0-96c-13.3 0-24-10.7-24-24s10.7-24 24-24 24 10.7 24 24-10.7 24-24 24zm0-96c-13.3 0-24-10.7-24-24s10.7-24 24-24 24 10.7 24 24-10.7 24-24 24zm96-192c13.3 0 24 10.7 24 24s-10.7 24-24 24-24-10.7-24-24 10.7-24 24-24zm128 368c0 4.4-3.6 8-8 8H168c-4.4 0-8-3.6-8-8v-16c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16zm0-96c0 4.4-3.6 8-8 8H168c-4.4 0-8-3.6-8-8v-16c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16zm0-96c0 4.4-3.6 8-8 8H168c-4.4 0-8-3.6-8-8v-16c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16z"},child:[]}]})(t)}function or(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256,8C119,8,8,119,8,256S119,504,256,504,504,393,504,256,393,8,256,8Zm92.49,313h0l-20,25a16,16,0,0,1-22.49,2.5h0l-67-49.72a40,40,0,0,1-15-31.23V112a16,16,0,0,1,16-16h32a16,16,0,0,1,16,16V256l58,42.5A16,16,0,0,1,348.49,321Z"},child:[]}]})(t)}function uh(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z"},child:[]}]})(t)}function $5(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 32C114.6 32 0 125.1 0 240c0 49.6 21.4 95 57 130.7C44.5 421.1 2.7 466 2.2 466.5c-2.2 2.3-2.8 5.7-1.5 8.7S4.8 480 8 480c66.3 0 116-31.8 140.6-51.4 32.7 12.3 69 19.4 107.4 19.4 141.4 0 256-93.1 256-208S397.4 32 256 32z"},child:[]}]})(t)}function eh(t){return Yt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M416 192c0-88.4-93.1-160-208-160S0 103.6 0 192c0 34.3 14.1 65.9 38 92-13.4 30.2-35.5 54.2-35.8 54.5-2.2 2.3-2.8 5.7-1.5 8.7S4.8 352 8 352c36.6 0 66.9-12.3 88.7-25 32.2 15.7 70.3 25 111.3 25 114.9 0 208-71.6 208-160zm122 220c23.9-26 38-57.7 38-92 0-66.9-53.5-124.2-129.3-148.1.9 6.6 1.3 13.3 1.3 20.1 0 105.9-107.7 192-240 192-10.8 0-21.3-.8-31.7-1.9C207.8 439.6 281.8 480 368 480c41 0 79.1-9.2 111.3-25 21.8 12.7 52.1 25 88.7 25 3.2 0 6.1-1.9 7.3-4.8 1.3-2.9.7-6.3-1.5-8.7-.3-.3-22.4-24.2-35.8-54.5z"},child:[]}]})(t)}function Wd(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z"},child:[]}]})(t)}function po(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"},child:[]}]})(t)}function Fr(t){return Yt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M402.6 83.2l90.2 90.2c3.8 3.8 3.8 10 0 13.8L274.4 405.6l-92.8 10.3c-12.4 1.4-22.9-9.1-21.5-21.5l10.3-92.8L388.8 83.2c3.8-3.8 10-3.8 13.8 0zm162-22.9l-48.8-48.8c-15.2-15.2-39.9-15.2-55.2 0l-35.4 35.4c-3.8 3.8-3.8 10 0 13.8l90.2 90.2c3.8 3.8 10 3.8 13.8 0l35.4-35.4c15.2-15.3 15.2-40 0-55.2zM384 346.2V448H64V128h229.8c3.2 0 6.2-1.3 8.5-3.5l40-40c7.6-7.6 2.2-20.5-8.5-20.5H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V306.2c0-10.7-12.9-16-20.5-8.5l-40 40c-2.2 2.3-3.5 5.3-3.5 8.5z"},child:[]}]})(t)}function Nu(t){return Yt({attr:{viewBox:"0 0 192 512"},child:[{tag:"path",attr:{d:"M96 184c39.8 0 72 32.2 72 72s-32.2 72-72 72-72-32.2-72-72 32.2-72 72-72zM24 80c0 39.8 32.2 72 72 72s72-32.2 72-72S135.8 8 96 8 24 40.2 24 80zm0 352c0 39.8 32.2 72 72 72s72-32.2 72-72-32.2-72-72-72-72 32.2-72 72z"},child:[]}]})(t)}function T2(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M502.3 190.8c3.9-3.1 9.7-.2 9.7 4.7V400c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V195.6c0-5 5.7-7.8 9.7-4.7 22.4 17.4 52.1 39.5 154.1 113.6 21.1 15.4 56.7 47.8 92.2 47.6 35.7.3 72-32.8 92.3-47.6 102-74.1 131.6-96.3 154-113.7zM256 320c23.2.4 56.6-29.2 73.4-41.4 132.7-96.3 142.8-104.7 173.4-128.7 5.8-4.5 9.2-11.5 9.2-18.9v-19c0-26.5-21.5-48-48-48H48C21.5 64 0 85.5 0 112v19c0 7.4 3.4 14.3 9.2 18.9 30.6 23.9 40.7 32.4 173.4 128.7 16.8 12.2 50.2 41.8 73.4 41.4z"},child:[]}]})(t)}function H5(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"},child:[]}]})(t)}function fa(t){return Yt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"},child:[]}]})(t)}function vs(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M432,320H400a16,16,0,0,0-16,16V448H64V128H208a16,16,0,0,0,16-16V80a16,16,0,0,0-16-16H48A48,48,0,0,0,0,112V464a48,48,0,0,0,48,48H400a48,48,0,0,0,48-48V336A16,16,0,0,0,432,320ZM488,0h-128c-21.37,0-32.05,25.91-17,41l35.73,35.73L135,320.37a24,24,0,0,0,0,34L157.67,377a24,24,0,0,0,34,0L435.28,133.32,471,169c15,15,41,4.5,41-17V24A24,24,0,0,0,488,0Z"},child:[]}]})(t)}function Qf(t){return Yt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M320 400c-75.85 0-137.25-58.71-142.9-133.11L72.2 185.82c-13.79 17.3-26.48 35.59-36.72 55.59a32.35 32.35 0 0 0 0 29.19C89.71 376.41 197.07 448 320 448c26.91 0 52.87-4 77.89-10.46L346 397.39a144.13 144.13 0 0 1-26 2.61zm313.82 58.1l-110.55-85.44a331.25 331.25 0 0 0 81.25-102.07 32.35 32.35 0 0 0 0-29.19C550.29 135.59 442.93 64 320 64a308.15 308.15 0 0 0-147.32 37.7L45.46 3.37A16 16 0 0 0 23 6.18L3.37 31.45A16 16 0 0 0 6.18 53.9l588.36 454.73a16 16 0 0 0 22.46-2.81l19.64-25.27a16 16 0 0 0-2.82-22.45zm-183.72-142l-39.3-30.38A94.75 94.75 0 0 0 416 256a94.76 94.76 0 0 0-121.31-92.21A47.65 47.65 0 0 1 304 192a46.64 46.64 0 0 1-1.54 10l-73.61-56.89A142.31 142.31 0 0 1 320 112a143.92 143.92 0 0 1 144 144c0 21.63-5.29 41.79-13.9 60.11z"},child:[]}]})(t)}function ri(t){return Yt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M572.52 241.4C518.29 135.59 410.93 64 288 64S57.68 135.64 3.48 241.41a32.35 32.35 0 0 0 0 29.19C57.71 376.41 165.07 448 288 448s230.32-71.64 284.52-177.41a32.35 32.35 0 0 0 0-29.19zM288 400a144 144 0 1 1 144-144 143.93 143.93 0 0 1-144 144zm0-240a95.31 95.31 0 0 0-25.31 3.79 47.85 47.85 0 0 1-66.9 66.9A95.78 95.78 0 1 0 288 160z"},child:[]}]})(t)}function W5(t){return Yt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm64 236c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12v8zm0-64c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12v8zm0-72v8c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12zm96-114.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"},child:[]}]})(t)}function au(t){return Yt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zM64 72c0-4.42 3.58-8 8-8h80c4.42 0 8 3.58 8 8v16c0 4.42-3.58 8-8 8H72c-4.42 0-8-3.58-8-8V72zm0 64c0-4.42 3.58-8 8-8h80c4.42 0 8 3.58 8 8v16c0 4.42-3.58 8-8 8H72c-4.42 0-8-3.58-8-8v-16zm192.81 248H304c8.84 0 16 7.16 16 16s-7.16 16-16 16h-47.19c-16.45 0-31.27-9.14-38.64-23.86-2.95-5.92-8.09-6.52-10.17-6.52s-7.22.59-10.02 6.19l-7.67 15.34a15.986 15.986 0 0 1-14.31 8.84c-.38 0-.75-.02-1.14-.05-6.45-.45-12-4.75-14.03-10.89L144 354.59l-10.61 31.88c-5.89 17.66-22.38 29.53-41 29.53H80c-8.84 0-16-7.16-16-16s7.16-16 16-16h12.39c4.83 0 9.11-3.08 10.64-7.66l18.19-54.64c3.3-9.81 12.44-16.41 22.78-16.41s19.48 6.59 22.77 16.41l13.88 41.64c19.77-16.19 54.05-9.7 66 14.16 2.02 4.06 5.96 6.5 10.16 6.5zM377 105L279.1 7c-4.5-4.5-10.6-7-17-7H256v128h128v-6.1c0-6.3-2.5-12.4-7-16.9z"},child:[]}]})(t)}function Bi(t){return Yt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm-96 144c0 4.42-3.58 8-8 8h-8c-8.84 0-16 7.16-16 16v32c0 8.84 7.16 16 16 16h8c4.42 0 8 3.58 8 8v16c0 4.42-3.58 8-8 8h-8c-26.51 0-48-21.49-48-48v-32c0-26.51 21.49-48 48-48h8c4.42 0 8 3.58 8 8v16zm44.27 104H160c-4.42 0-8-3.58-8-8v-16c0-4.42 3.58-8 8-8h12.27c5.95 0 10.41-3.5 10.41-6.62 0-1.3-.75-2.66-2.12-3.84l-21.89-18.77c-8.47-7.22-13.33-17.48-13.33-28.14 0-21.3 19.02-38.62 42.41-38.62H200c4.42 0 8 3.58 8 8v16c0 4.42-3.58 8-8 8h-12.27c-5.95 0-10.41 3.5-10.41 6.62 0 1.3.75 2.66 2.12 3.84l21.89 18.77c8.47 7.22 13.33 17.48 13.33 28.14.01 21.29-19 38.62-42.39 38.62zM256 264v20.8c0 20.27 5.7 40.17 16 56.88 10.3-16.7 16-36.61 16-56.88V264c0-4.42 3.58-8 8-8h16c4.42 0 8 3.58 8 8v20.8c0 35.48-12.88 68.89-36.28 94.09-3.02 3.25-7.27 5.11-11.72 5.11s-8.7-1.86-11.72-5.11c-23.4-25.2-36.28-58.61-36.28-94.09V264c0-4.42 3.58-8 8-8h16c4.42 0 8 3.58 8 8zm121-159L279.1 7c-4.5-4.5-10.6-7-17-7H256v128h128v-6.1c0-6.3-2.5-12.4-7-16.9z"},child:[]}]})(t)}function Ui(t){return Yt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm60.1 106.5L224 336l60.1 93.5c5.1 8-.6 18.5-10.1 18.5h-34.9c-4.4 0-8.5-2.4-10.6-6.3C208.9 405.5 192 373 192 373c-6.4 14.8-10 20-36.6 68.8-2.1 3.9-6.1 6.3-10.5 6.3H110c-9.5 0-15.2-10.5-10.1-18.5l60.3-93.5-60.3-93.5c-5.2-8 .6-18.5 10.1-18.5h34.8c4.4 0 8.5 2.4 10.6 6.3 26.1 48.8 20 33.6 36.6 68.5 0 0 6.1-11.7 36.6-68.5 2.1-3.9 6.2-6.3 10.6-6.3H274c9.5-.1 15.2 10.4 10.1 18.4zM384 121.9v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"},child:[]}]})(t)}function Os(t){return Yt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M384 121.9c0-6.3-2.5-12.4-7-16.9L279.1 7c-4.5-4.5-10.6-7-17-7H256v128h128zM571 308l-95.7-96.4c-10.1-10.1-27.4-3-27.4 11.3V288h-64v64h64v65.2c0 14.3 17.3 21.4 27.4 11.3L571 332c6.6-6.6 6.6-17.4 0-24zm-379 28v-32c0-8.8 7.2-16 16-16h176V160H248c-13.2 0-24-10.8-24-24V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V352H208c-8.8 0-16-7.2-16-16z"},child:[]}]})(t)}function Ph(t){return Yt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M181.9 256.1c-5-16-4.9-46.9-2-46.9 8.4 0 7.6 36.9 2 46.9zm-1.7 47.2c-7.7 20.2-17.3 43.3-28.4 62.7 18.3-7 39-17.2 62.9-21.9-12.7-9.6-24.9-23.4-34.5-40.8zM86.1 428.1c0 .8 13.2-5.4 34.9-40.2-6.7 6.3-29.1 24.5-34.9 40.2zM248 160h136v328c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V24C0 10.7 10.7 0 24 0h200v136c0 13.2 10.8 24 24 24zm-8 171.8c-20-12.2-33.3-29-42.7-53.8 4.5-18.5 11.6-46.6 6.2-64.2-4.7-29.4-42.4-26.5-47.8-6.8-5 18.3-.4 44.1 8.1 77-11.6 27.6-28.7 64.6-40.8 85.8-.1 0-.1.1-.2.1-27.1 13.9-73.6 44.5-54.5 68 5.6 6.9 16 10 21.5 10 17.9 0 35.7-18 61.1-61.8 25.8-8.5 54.1-19.1 79-23.2 21.7 11.8 47.1 19.5 64 19.5 29.2 0 31.2-32 19.7-43.4-13.9-13.6-54.3-9.7-73.6-7.2zM377 105L279 7c-4.5-4.5-10.6-7-17-7h-6v128h128v-6.1c0-6.3-2.5-12.4-7-16.9zm-74.1 255.3c4.1-2.7-2.5-11.9-42.8-9 37.1 15.8 42.8 9 42.8 9z"},child:[]}]})(t)}function mh(t){return Yt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm160-14.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"},child:[]}]})(t)}function ds(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M487.976 0H24.028C2.71 0-8.047 25.866 7.058 40.971L192 225.941V432c0 7.831 3.821 15.17 10.237 19.662l80 55.98C298.02 518.69 320 507.493 320 487.98V225.941l184.947-184.97C520.021 25.896 509.338 0 487.976 0z"},child:[]}]})(t)}function hh(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M480 288c0-80.25-49.28-148.92-119.19-177.62L320 192V80a16 16 0 0 0-16-16h-96a16 16 0 0 0-16 16v112l-40.81-81.62C81.28 139.08 32 207.75 32 288v64h448zm16 96H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h480a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(t)}function w1(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M192 208c0-17.67-14.33-32-32-32h-16c-35.35 0-64 28.65-64 64v48c0 35.35 28.65 64 64 64h16c17.67 0 32-14.33 32-32V208zm176 144c35.35 0 64-28.65 64-64v-48c0-35.35-28.65-64-64-64h-16c-17.67 0-32 14.33-32 32v112c0 17.67 14.33 32 32 32h16zM256 0C113.18 0 4.58 118.83 0 256v16c0 8.84 7.16 16 16 16h16c8.84 0 16-7.16 16-16v-16c0-114.69 93.31-208 208-208s208 93.31 208 208h-.12c.08 2.43.12 165.72.12 165.72 0 23.35-18.93 42.28-42.28 42.28H320c0-26.51-21.49-48-48-48h-32c-26.51 0-48 21.49-48 48s21.49 48 48 48h181.72c49.86 0 90.28-40.42 90.28-90.28V256C507.42 118.83 398.82 0 256 0z"},child:[]}]})(t)}function _c(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M504 255.531c.253 136.64-111.18 248.372-247.82 248.468-59.015.042-113.223-20.53-155.822-54.911-11.077-8.94-11.905-25.541-1.839-35.607l11.267-11.267c8.609-8.609 22.353-9.551 31.891-1.984C173.062 425.135 212.781 440 256 440c101.705 0 184-82.311 184-184 0-101.705-82.311-184-184-184-48.814 0-93.149 18.969-126.068 49.932l50.754 50.754c10.08 10.08 2.941 27.314-11.313 27.314H24c-8.837 0-16-7.163-16-16V38.627c0-14.254 17.234-21.393 27.314-11.314l49.372 49.372C129.209 34.136 189.552 8 256 8c136.81 0 247.747 110.78 248 247.531zm-180.912 78.784l9.823-12.63c8.138-10.463 6.253-25.542-4.21-33.679L288 256.349V152c0-13.255-10.745-24-24-24h-16c-13.255 0-24 10.745-24 24v135.651l65.409 50.874c10.463 8.137 25.541 6.253 33.679-4.21z"},child:[]}]})(t)}function V5(t){return Yt({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M336 0H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V48c0-26.5-21.5-48-48-48zM144 32h96c8.8 0 16 7.2 16 16s-7.2 16-16 16h-96c-8.8 0-16-7.2-16-16s7.2-16 16-16zm48 128c35.3 0 64 28.7 64 64s-28.7 64-64 64-64-28.7-64-64 28.7-64 64-64zm112 236.8c0 10.6-10 19.2-22.4 19.2H102.4C90 416 80 407.4 80 396.8v-19.2c0-31.8 30.1-57.6 67.2-57.6h5c12.3 5.1 25.7 8 39.8 8s27.6-2.9 39.8-8h5c37.1 0 67.2 25.8 67.2 57.6v19.2z"},child:[]}]})(t)}function Di(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 110c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z"},child:[]}]})(t)}function ex(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M512 176.001C512 273.203 433.202 352 336 352c-11.22 0-22.19-1.062-32.827-3.069l-24.012 27.014A23.999 23.999 0 0 1 261.223 384H224v40c0 13.255-10.745 24-24 24h-40v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24v-78.059c0-6.365 2.529-12.47 7.029-16.971l161.802-161.802C163.108 213.814 160 195.271 160 176 160 78.798 238.797.001 335.999 0 433.488-.001 512 78.511 512 176.001zM336 128c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z"},child:[]}]})(t)}function tx(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(t)}function q5(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(t)}function Cx(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 224h-24v-72C376 68.2 307.8 0 224 0S72 68.2 72 152v72H48c-26.5 0-48 21.5-48 48v192c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V272c0-26.5-21.5-48-48-48zm-104 0H152v-72c0-39.7 32.3-72 72-72s72 32.3 72 72v72z"},child:[]}]})(t)}function G5(t){return Yt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M0 117.66v346.32c0 11.32 11.43 19.06 21.94 14.86L160 416V32L20.12 87.95A32.006 32.006 0 0 0 0 117.66zM192 416l192 64V96L192 32v384zM554.06 33.16L416 96v384l139.88-55.95A31.996 31.996 0 0 0 576 394.34V48.02c0-11.32-11.43-19.06-21.94-14.86z"},child:[]}]})(t)}function Y5(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M43.246 466.142c-58.43-60.289-57.341-157.511 1.386-217.581L254.392 34c44.316-45.332 116.351-45.336 160.671 0 43.89 44.894 43.943 117.329 0 162.276L232.214 383.128c-29.855 30.537-78.633 30.111-107.982-.998-28.275-29.97-27.368-77.473 1.452-106.953l143.743-146.835c6.182-6.314 16.312-6.422 22.626-.241l22.861 22.379c6.315 6.182 6.422 16.312.241 22.626L171.427 319.927c-4.932 5.045-5.236 13.428-.648 18.292 4.372 4.634 11.245 4.711 15.688.165l182.849-186.851c19.613-20.062 19.613-52.725-.011-72.798-19.189-19.627-49.957-19.637-69.154 0L90.39 293.295c-34.763 35.56-35.299 93.12-1.191 128.313 34.01 35.093 88.985 35.137 123.058.286l172.06-175.999c6.177-6.319 16.307-6.433 22.626-.256l22.877 22.364c6.319 6.177 6.434 16.307.256 22.626l-172.06 175.998c-59.576 60.938-155.943 60.216-214.77-.485z"},child:[]}]})(t)}function Zs(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"},child:[]}]})(t)}function Fi(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M448 192V77.25c0-8.49-3.37-16.62-9.37-22.63L393.37 9.37c-6-6-14.14-9.37-22.63-9.37H96C78.33 0 64 14.33 64 32v160c-35.35 0-64 28.65-64 64v112c0 8.84 7.16 16 16 16h48v96c0 17.67 14.33 32 32 32h320c17.67 0 32-14.33 32-32v-96h48c8.84 0 16-7.16 16-16V256c0-35.35-28.65-64-64-64zm-64 256H128v-96h256v96zm0-224H128V64h192v48c0 8.84 7.16 16 16 16h48v96zm48 72c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24z"},child:[]}]})(t)}function Cl(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M0 224h192V32H0v192zM64 96h64v64H64V96zm192-64v192h192V32H256zm128 128h-64V96h64v64zM0 480h192V288H0v192zm64-128h64v64H64v-64zm352-64h32v128h-96v-32h-32v96h-64V288h96v32h64v-32zm0 160h32v32h-32v-32zm-64 0h32v32h-32v-32z"},child:[]}]})(t)}function Or(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z"},child:[]}]})(t)}function Js(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"},child:[]}]})(t)}function Kx(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M466.5 83.7l-192-80a48.15 48.15 0 0 0-36.9 0l-192 80C27.7 91.1 16 108.6 16 128c0 198.5 114.5 335.7 221.5 380.3 11.8 4.9 25.1 4.9 36.9 0C360.1 472.6 496 349.3 496 128c0-19.4-11.7-36.9-29.5-44.3zM256.1 446.3l-.1-381 175.9 73.3c-3.3 151.4-82.1 261.1-175.8 307.7z"},child:[]}]})(t)}function Z5(t){return Yt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M528.12 301.319l47.273-208C578.806 78.301 567.391 64 551.99 64H159.208l-9.166-44.81C147.758 8.021 137.93 0 126.529 0H24C10.745 0 0 10.745 0 24v16c0 13.255 10.745 24 24 24h69.883l70.248 343.435C147.325 417.1 136 435.222 136 456c0 30.928 25.072 56 56 56s56-25.072 56-56c0-15.674-6.447-29.835-16.824-40h209.647C430.447 426.165 424 440.326 424 456c0 30.928 25.072 56 56 56s56-25.072 56-56c0-22.172-12.888-41.332-31.579-50.405l5.517-24.276c3.413-15.018-8.002-29.319-23.403-29.319H218.117l-6.545-32h293.145c11.206 0 20.92-7.754 23.403-18.681z"},child:[]}]})(t)}function ya(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z"},child:[]}]})(t)}function Ar(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z"},child:[]}]})(t)}function Tc(t){return Yt({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M259.3 17.8L194 150.2 47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5 105.7-103c19-18.5 8.5-50.8-17.7-54.6L382 150.2 316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0z"},child:[]}]})(t)}function J5(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M312 320h136V56c0-13.3-10.7-24-24-24H24C10.7 32 0 42.7 0 56v400c0 13.3 10.7 24 24 24h264V344c0-13.2 10.8-24 24-24zm129 55l-98 98c-4.5 4.5-10.6 7-17 7h-6V352h128v6.1c0 6.3-2.5 12.4-7 16.9z"},child:[]}]})(t)}function vn(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M440.65 12.57l4 82.77A247.16 247.16 0 0 0 255.83 8C134.73 8 33.91 94.92 12.29 209.82A12 12 0 0 0 24.09 224h49.05a12 12 0 0 0 11.67-9.26 175.91 175.91 0 0 1 317-56.94l-101.46-4.86a12 12 0 0 0-12.57 12v47.41a12 12 0 0 0 12 12H500a12 12 0 0 0 12-12V12a12 12 0 0 0-12-12h-47.37a12 12 0 0 0-11.98 12.57zM255.83 432a175.61 175.61 0 0 1-146-77.8l101.8 4.87a12 12 0 0 0 12.57-12v-47.4a12 12 0 0 0-12-12H12a12 12 0 0 0-12 12V500a12 12 0 0 0 12 12h47.35a12 12 0 0 0 12-12.6l-4.15-82.57A247.17 247.17 0 0 0 255.83 504c121.11 0 221.93-86.92 243.55-201.82a12 12 0 0 0-11.8-14.18h-49.05a12 12 0 0 0-11.67 9.26A175.86 175.86 0 0 1 255.83 432z"},child:[]}]})(t)}function E2(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z"},child:[]}]})(t)}function X5(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 252.118V48C0 21.49 21.49 0 48 0h204.118a48 48 0 0 1 33.941 14.059l211.882 211.882c18.745 18.745 18.745 49.137 0 67.882L293.823 497.941c-18.745 18.745-49.137 18.745-67.882 0L14.059 286.059A48 48 0 0 1 0 252.118zM112 64c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48z"},child:[]}]})(t)}function X0(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M104 224H24c-13.255 0-24 10.745-24 24v240c0 13.255 10.745 24 24 24h80c13.255 0 24-10.745 24-24V248c0-13.255-10.745-24-24-24zM64 472c-13.255 0-24-10.745-24-24s10.745-24 24-24 24 10.745 24 24-10.745 24-24 24zM384 81.452c0 42.416-25.97 66.208-33.277 94.548h101.723c33.397 0 59.397 27.746 59.553 58.098.084 17.938-7.546 37.249-19.439 49.197l-.11.11c9.836 23.337 8.237 56.037-9.308 79.469 8.681 25.895-.069 57.704-16.382 74.757 4.298 17.598 2.244 32.575-6.148 44.632C440.202 511.587 389.616 512 346.839 512l-2.845-.001c-48.287-.017-87.806-17.598-119.56-31.725-15.957-7.099-36.821-15.887-52.651-16.178-6.54-.12-11.783-5.457-11.783-11.998v-213.77c0-3.2 1.282-6.271 3.558-8.521 39.614-39.144 56.648-80.587 89.117-113.111 14.804-14.832 20.188-37.236 25.393-58.902C282.515 39.293 291.817 0 312 0c24 0 72 8 72 81.452z"},child:[]}]})(t)}function ka(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z"},child:[]}]})(t)}function wt(t){return Yt({attr:{viewBox:"0 0 352 512"},child:[{tag:"path",attr:{d:"M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"},child:[]}]})(t)}function A2(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M501.1 395.7L384 278.6c-23.1-23.1-57.6-27.6-85.4-13.9L192 158.1V96L64 0 0 64l96 128h62.1l106.6 106.6c-13.6 27.8-9.2 62.3 13.9 85.4l117.1 117.1c14.6 14.6 38.2 14.6 52.7 0l52.7-52.7c14.5-14.6 14.5-38.2 0-52.7zM331.7 225c28.3 0 54.9 11 74.9 31l19.4 19.4c15.8-6.9 30.8-16.5 43.8-29.5 37.1-37.1 49.7-89.3 37.9-136.7-2.2-9-13.5-12.1-20.1-5.5l-74.4 74.4-67.9-11.3L334 98.9l74.4-74.4c6.6-6.6 3.4-17.9-5.7-20.2-47.4-11.7-99.6.9-136.6 37.9-28.5 28.5-41.9 66.1-41.2 103.6l82.1 82.1c8.1-1.9 16.5-2.9 24.7-2.9zm-103.9 82l-56.7-56.7L18.7 402.8c-25 25-25 65.5 0 90.5s65.5 25 90.5 0l123.6-123.6c-7.6-19.9-9.9-41.6-5-62.7zM64 472c-13.2 0-24-10.8-24-24 0-13.3 10.7-24 24-24s24 10.7 24 24c0 13.2-10.7 24-24 24z"},child:[]}]})(t)}function K5(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M32 464a48 48 0 0 0 48 48h288a48 48 0 0 0 48-48V128H32zm272-256a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zm-96 0a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zm-96 0a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zM432 32H312l-9.4-18.7A24 24 0 0 0 281.1 0H166.8a23.72 23.72 0 0 0-21.4 13.3L136 32H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16z"},child:[]}]})(t)}function Na(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M432 32H312l-9.4-18.7A24 24 0 0 0 281.1 0H166.8a23.72 23.72 0 0 0-21.4 13.3L136 32H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16zM53.2 467a48 48 0 0 0 47.9 45h245.8a48 48 0 0 0 47.9-45L416 128H32z"},child:[]}]})(t)}function gh(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M296 384h-80c-13.3 0-24-10.7-24-24V192h-87.7c-17.8 0-26.7-21.5-14.1-34.1L242.3 5.7c7.5-7.5 19.8-7.5 27.3 0l152.2 152.2c12.6 12.6 3.7 34.1-14.1 34.1H320v168c0 13.3-10.7 24-24 24zm216-8v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h136v8c0 30.9 25.1 56 56 56h80c30.9 0 56-25.1 56-56v-8h136c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"},child:[]}]})(t)}function k1(t){return Yt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M496 224c-79.6 0-144 64.4-144 144s64.4 144 144 144 144-64.4 144-144-64.4-144-144-144zm64 150.3c0 5.3-4.4 9.7-9.7 9.7h-60.6c-5.3 0-9.7-4.4-9.7-9.7v-76.6c0-5.3 4.4-9.7 9.7-9.7h12.6c5.3 0 9.7 4.4 9.7 9.7V352h38.3c5.3 0 9.7 4.4 9.7 9.7v12.6zM320 368c0-27.8 6.7-54.1 18.2-77.5-8-1.5-16.2-2.5-24.6-2.5h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h347.1c-45.3-31.9-75.1-84.5-75.1-144zm-96-112c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128z"},child:[]}]})(t)}function j1(t){return Yt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M610.5 373.3c2.6-14.1 2.6-28.5 0-42.6l25.8-14.9c3-1.7 4.3-5.2 3.3-8.5-6.7-21.6-18.2-41.2-33.2-57.4-2.3-2.5-6-3.1-9-1.4l-25.8 14.9c-10.9-9.3-23.4-16.5-36.9-21.3v-29.8c0-3.4-2.4-6.4-5.7-7.1-22.3-5-45-4.8-66.2 0-3.3.7-5.7 3.7-5.7 7.1v29.8c-13.5 4.8-26 12-36.9 21.3l-25.8-14.9c-2.9-1.7-6.7-1.1-9 1.4-15 16.2-26.5 35.8-33.2 57.4-1 3.3.4 6.8 3.3 8.5l25.8 14.9c-2.6 14.1-2.6 28.5 0 42.6l-25.8 14.9c-3 1.7-4.3 5.2-3.3 8.5 6.7 21.6 18.2 41.1 33.2 57.4 2.3 2.5 6 3.1 9 1.4l25.8-14.9c10.9 9.3 23.4 16.5 36.9 21.3v29.8c0 3.4 2.4 6.4 5.7 7.1 22.3 5 45 4.8 66.2 0 3.3-.7 5.7-3.7 5.7-7.1v-29.8c13.5-4.8 26-12 36.9-21.3l25.8 14.9c2.9 1.7 6.7 1.1 9-1.4 15-16.2 26.5-35.8 33.2-57.4 1-3.3-.4-6.8-3.3-8.5l-25.8-14.9zM496 400.5c-26.8 0-48.5-21.8-48.5-48.5s21.8-48.5 48.5-48.5 48.5 21.8 48.5 48.5-21.7 48.5-48.5 48.5zM224 256c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm201.2 226.5c-2.3-1.2-4.6-2.6-6.8-3.9l-7.9 4.6c-6 3.4-12.8 5.3-19.6 5.3-10.9 0-21.4-4.6-28.9-12.6-18.3-19.8-32.3-43.9-40.2-69.6-5.5-17.7 1.9-36.4 17.9-45.7l7.9-4.6c-.1-2.6-.1-5.2 0-7.8l-7.9-4.6c-16-9.2-23.4-28-17.9-45.7.9-2.9 2.2-5.8 3.2-8.7-3.8-.3-7.5-1.2-11.4-1.2h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c10.1 0 19.5-3.2 27.2-8.5-1.2-3.8-2-7.7-2-11.8v-9.2z"},child:[]}]})(t)}function Q5(t){return Yt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M624 208h-64v-64c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v64h-64c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h64v64c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-64h64c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm-400 48c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm89.6 32h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-74.2-60.2-134.4-134.4-134.4z"},child:[]}]})(t)}function e6(t){return Yt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M630.6 364.9l-90.3-90.2c-12-12-28.3-18.7-45.3-18.7h-79.3c-17.7 0-32 14.3-32 32v79.2c0 17 6.7 33.2 18.7 45.2l90.3 90.2c12.5 12.5 32.8 12.5 45.3 0l92.5-92.5c12.6-12.5 12.6-32.7.1-45.2zm-182.8-21c-13.3 0-24-10.7-24-24s10.7-24 24-24 24 10.7 24 24c0 13.2-10.7 24-24 24zm-223.8-88c70.7 0 128-57.3 128-128C352 57.3 294.7 0 224 0S96 57.3 96 128c0 70.6 57.3 127.9 128 127.9zm127.8 111.2V294c-12.2-3.6-24.9-6.2-38.2-6.2h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 287.9 0 348.1 0 422.3v41.6c0 26.5 21.5 48 48 48h352c15.5 0 29.1-7.5 37.9-18.9l-58-58c-18.1-18.1-28.1-42.2-28.1-67.9z"},child:[]}]})(t)}function t6(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M224 256c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm95.8 32.6L272 480l-32-136 32-56h-96l32 56-32 136-47.8-191.4C56.9 292 0 350.3 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-72.1-56.9-130.4-128.2-133.8z"},child:[]}]})(t)}function js(t){return Yt({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M224 256c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm89.6 32h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-74.2-60.2-134.4-134.4-134.4z"},child:[]}]})(t)}function fc(t){return Yt({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M96 224c35.3 0 64-28.7 64-64s-28.7-64-64-64-64 28.7-64 64 28.7 64 64 64zm448 0c35.3 0 64-28.7 64-64s-28.7-64-64-64-64 28.7-64 64 28.7 64 64 64zm32 32h-64c-17.6 0-33.5 7.1-45.1 18.6 40.3 22.1 68.9 62 75.1 109.4h66c17.7 0 32-14.3 32-32v-32c0-35.3-28.7-64-64-64zm-256 0c61.9 0 112-50.1 112-112S381.9 32 320 32 208 82.1 208 144s50.1 112 112 112zm76.8 32h-8.3c-20.8 10-43.9 16-68.5 16s-47.6-6-68.5-16h-8.3C179.6 288 128 339.6 128 403.2V432c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48v-28.8c0-63.6-51.6-115.2-115.2-115.2zm-223.7-13.4C161.5 263.1 145.6 256 128 256H64c-35.3 0-64 28.7-64 64v32c0 17.7 14.3 32 32 32h65.9c6.3-47.4 34.9-87.3 75.2-109.4z"},child:[]}]})(t)}function wc(t){return Yt({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M507.73 109.1c-2.24-9.03-13.54-12.09-20.12-5.51l-74.36 74.36-67.88-11.31-11.31-67.88 74.36-74.36c6.62-6.62 3.43-17.9-5.66-20.16-47.38-11.74-99.55.91-136.58 37.93-39.64 39.64-50.55 97.1-34.05 147.2L18.74 402.76c-24.99 24.99-24.99 65.51 0 90.5 24.99 24.99 65.51 24.99 90.5 0l213.21-213.21c50.12 16.71 107.47 5.68 147.37-34.22 37.07-37.07 49.7-89.32 37.91-136.73zM64 472c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24z"},child:[]}]})(t)}var fh={};fh.version="0.18.5";var O2=1252,a6=[874,932,936,949,950,1250,1251,1252,1253,1254,1255,1256,1257,1258,1e4],D2=function(t){a6.indexOf(t)!=-1&&(O2=t)};function r6(){D2(1252)}var gu=function(t){D2(t)};function s6(){gu(1200),r6()}var Im=function(a){return String.fromCharCode(a)},N1=function(a){return String.fromCharCode(a)},xh,Tl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function fu(t){for(var a="",r=0,s=0,i=0,c=0,d=0,m=0,h=0,g=0;g<t.length;)r=t.charCodeAt(g++),c=r>>2,s=t.charCodeAt(g++),d=(r&3)<<4|s>>4,i=t.charCodeAt(g++),m=(s&15)<<2|i>>6,h=i&63,isNaN(s)?m=h=64:isNaN(i)&&(h=64),a+=Tl.charAt(c)+Tl.charAt(d)+Tl.charAt(m)+Tl.charAt(h);return a}function Jo(t){var a="",r=0,s=0,i=0,c=0,d=0,m=0,h=0;t=t.replace(/[^\w\+\/\=]/g,"");for(var g=0;g<t.length;)c=Tl.indexOf(t.charAt(g++)),d=Tl.indexOf(t.charAt(g++)),r=c<<2|d>>4,a+=String.fromCharCode(r),m=Tl.indexOf(t.charAt(g++)),s=(d&15)<<4|m>>2,m!==64&&(a+=String.fromCharCode(s)),h=Tl.indexOf(t.charAt(g++)),i=(m&3)<<6|h,h!==64&&(a+=String.fromCharCode(i));return a}var ir=(function(){return typeof Buffer!="undefined"&&typeof process!="undefined"&&typeof process.versions!="undefined"&&!!process.versions.node})(),Qo=(function(){if(typeof Buffer!="undefined"){var t=!Buffer.from;if(!t)try{Buffer.from("foo","utf8")}catch(a){t=!0}return t?function(a,r){return r?new Buffer(a,r):new Buffer(a)}:Buffer.from.bind(Buffer)}return function(){}})();function kc(t){return ir?Buffer.alloc?Buffer.alloc(t):new Buffer(t):typeof Uint8Array!="undefined"?new Uint8Array(t):new Array(t)}function S1(t){return ir?Buffer.allocUnsafe?Buffer.allocUnsafe(t):new Buffer(t):typeof Uint8Array!="undefined"?new Uint8Array(t):new Array(t)}var Mi=function(a){return ir?Qo(a,"binary"):a.split("").map(function(r){return r.charCodeAt(0)&255})};function Fh(t){if(typeof ArrayBuffer=="undefined")return Mi(t);for(var a=new ArrayBuffer(t.length),r=new Uint8Array(a),s=0;s!=t.length;++s)r[s]=t.charCodeAt(s)&255;return a}function Su(t){if(Array.isArray(t))return t.map(function(s){return String.fromCharCode(s)}).join("");for(var a=[],r=0;r<t.length;++r)a[r]=String.fromCharCode(t[r]);return a.join("")}function n6(t){if(typeof Uint8Array=="undefined")throw new Error("Unsupported");return new Uint8Array(t)}var qs=ir?function(t){return Buffer.concat(t.map(function(a){return Buffer.isBuffer(a)?a:Qo(a)}))}:function(t){if(typeof Uint8Array!="undefined"){var a=0,r=0;for(a=0;a<t.length;++a)r+=t[a].length;var s=new Uint8Array(r),i=0;for(a=0,r=0;a<t.length;r+=i,++a)if(i=t[a].length,t[a]instanceof Uint8Array)s.set(t[a],r);else{if(typeof t[a]=="string")throw"wtf";s.set(new Uint8Array(t[a]),r)}return s}return[].concat.apply([],t.map(function(c){return Array.isArray(c)?c:[].slice.call(c)}))};function i6(t){for(var a=[],r=0,s=t.length+250,i=kc(t.length+255),c=0;c<t.length;++c){var d=t.charCodeAt(c);if(d<128)i[r++]=d;else if(d<2048)i[r++]=192|d>>6&31,i[r++]=128|d&63;else if(d>=55296&&d<57344){d=(d&1023)+64;var m=t.charCodeAt(++c)&1023;i[r++]=240|d>>8&7,i[r++]=128|d>>2&63,i[r++]=128|m>>6&15|(d&3)<<4,i[r++]=128|m&63}else i[r++]=224|d>>12&15,i[r++]=128|d>>6&63,i[r++]=128|d&63;r>s&&(a.push(i.slice(0,r)),r=0,i=kc(65535),s=65530)}return a.push(i.slice(0,r)),qs(a)}var ru=/\u0000/g,zm=/[\u0001-\u0006]/g;function Ld(t){for(var a="",r=t.length-1;r>=0;)a+=t.charAt(r--);return a}function Li(t,a){var r=""+t;return r.length>=a?r:Wr("0",a-r.length)+r}function Qx(t,a){var r=""+t;return r.length>=a?r:Wr(" ",a-r.length)+r}function ph(t,a){var r=""+t;return r.length>=a?r:r+Wr(" ",a-r.length)}function o6(t,a){var r=""+Math.round(t);return r.length>=a?r:Wr("0",a-r.length)+r}function l6(t,a){var r=""+t;return r.length>=a?r:Wr("0",a-r.length)+r}var C1=Math.pow(2,32);function wd(t,a){if(t>C1||t<-C1)return o6(t,a);var r=Math.round(t);return l6(r,a)}function yh(t,a){return a=a||0,t.length>=7+a&&(t.charCodeAt(a)|32)===103&&(t.charCodeAt(a+1)|32)===101&&(t.charCodeAt(a+2)|32)===110&&(t.charCodeAt(a+3)|32)===101&&(t.charCodeAt(a+4)|32)===114&&(t.charCodeAt(a+5)|32)===97&&(t.charCodeAt(a+6)|32)===108}var T1=[["Sun","Sunday"],["Mon","Monday"],["Tue","Tuesday"],["Wed","Wednesday"],["Thu","Thursday"],["Fri","Friday"],["Sat","Saturday"]],ax=[["J","Jan","January"],["F","Feb","February"],["M","Mar","March"],["A","Apr","April"],["M","May","May"],["J","Jun","June"],["J","Jul","July"],["A","Aug","August"],["S","Sep","September"],["O","Oct","October"],["N","Nov","November"],["D","Dec","December"]];function c6(t){return t||(t={}),t[0]="General",t[1]="0",t[2]="0.00",t[3]="#,##0",t[4]="#,##0.00",t[9]="0%",t[10]="0.00%",t[11]="0.00E+00",t[12]="# ?/?",t[13]="# ??/??",t[14]="m/d/yy",t[15]="d-mmm-yy",t[16]="d-mmm",t[17]="mmm-yy",t[18]="h:mm AM/PM",t[19]="h:mm:ss AM/PM",t[20]="h:mm",t[21]="h:mm:ss",t[22]="m/d/yy h:mm",t[37]="#,##0 ;(#,##0)",t[38]="#,##0 ;[Red](#,##0)",t[39]="#,##0.00;(#,##0.00)",t[40]="#,##0.00;[Red](#,##0.00)",t[45]="mm:ss",t[46]="[h]:mm:ss",t[47]="mmss.0",t[48]="##0.0E+0",t[49]="@",t[56]='"上午/下午 "hh"時"mm"分"ss"秒 "',t}var Vr={0:"General",1:"0",2:"0.00",3:"#,##0",4:"#,##0.00",9:"0%",10:"0.00%",11:"0.00E+00",12:"# ?/?",13:"# ??/??",14:"m/d/yy",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"m/d/yy h:mm",37:"#,##0 ;(#,##0)",38:"#,##0 ;[Red](#,##0)",39:"#,##0.00;(#,##0.00)",40:"#,##0.00;[Red](#,##0.00)",45:"mm:ss",46:"[h]:mm:ss",47:"mmss.0",48:"##0.0E+0",49:"@",56:'"上午/下午 "hh"時"mm"分"ss"秒 "'},E1={5:37,6:38,7:39,8:40,23:0,24:0,25:0,26:0,27:14,28:14,29:14,30:14,31:14,50:14,51:14,52:14,53:14,54:14,55:14,56:14,57:14,58:14,59:1,60:2,61:3,62:4,67:9,68:10,69:12,70:13,71:14,72:14,73:15,74:16,75:17,76:20,77:21,78:22,79:45,80:46,81:47,82:0},d6={5:'"$"#,##0_);\\("$"#,##0\\)',63:'"$"#,##0_);\\("$"#,##0\\)',6:'"$"#,##0_);[Red]\\("$"#,##0\\)',64:'"$"#,##0_);[Red]\\("$"#,##0\\)',7:'"$"#,##0.00_);\\("$"#,##0.00\\)',65:'"$"#,##0.00_);\\("$"#,##0.00\\)',8:'"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',66:'"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',41:'_(* #,##0_);_(* \\(#,##0\\);_(* "-"_);_(@_)',42:'_("$"* #,##0_);_("$"* \\(#,##0\\);_("$"* "-"_);_(@_)',43:'_(* #,##0.00_);_(* \\(#,##0.00\\);_(* "-"??_);_(@_)',44:'_("$"* #,##0.00_);_("$"* \\(#,##0.00\\);_("$"* "-"??_);_(@_)'};function bh(t,a,r){for(var s=t<0?-1:1,i=t*s,c=0,d=1,m=0,h=1,g=0,p=0,b=Math.floor(i);g<a&&(b=Math.floor(i),m=b*d+c,p=b*g+h,!(i-b<5e-8));)i=1/(i-b),c=d,d=m,h=g,g=p;if(p>a&&(g>a?(p=h,m=c):(p=g,m=d)),!r)return[0,s*m,p];var j=Math.floor(s*m/p);return[j,s*m-j*p,p]}function Bm(t,a,r){if(t>2958465||t<0)return null;var s=t|0,i=Math.floor(86400*(t-s)),c=0,d=[],m={D:s,T:i,u:86400*(t-s)-i,y:0,m:0,d:0,H:0,M:0,S:0,q:0};if(Math.abs(m.u)<1e-6&&(m.u=0),a&&a.date1904&&(s+=1462),m.u>.9999&&(m.u=0,++i==86400&&(m.T=i=0,++s,++m.D)),s===60)d=r?[1317,10,29]:[1900,2,29],c=3;else if(s===0)d=r?[1317,8,29]:[1900,1,0],c=6;else{s>60&&--s;var h=new Date(1900,0,1);h.setDate(h.getDate()+s-1),d=[h.getFullYear(),h.getMonth()+1,h.getDate()],c=h.getDay(),s<60&&(c=(c+6)%7),r&&(c=p6(h,d))}return m.y=d[0],m.m=d[1],m.d=d[2],m.S=i%60,i=Math.floor(i/60),m.M=i%60,i=Math.floor(i/60),m.H=i,m.q=c,m}var M2=new Date(1899,11,31,0,0,0),u6=M2.getTime(),m6=new Date(1900,2,1,0,0,0);function L2(t,a){var r=t.getTime();return a?r-=1461*24*60*60*1e3:t>=m6&&(r+=1440*60*1e3),(r-(u6+(t.getTimezoneOffset()-M2.getTimezoneOffset())*6e4))/(1440*60*1e3)}function ep(t){return t.indexOf(".")==-1?t:t.replace(/(?:\.0*|(\.\d*[1-9])0+)$/,"$1")}function h6(t){return t.indexOf("E")==-1?t:t.replace(/(?:\.0*|(\.\d*[1-9])0+)[Ee]/,"$1E").replace(/(E[+-])(\d)$/,"$10$2")}function g6(t){var a=t<0?12:11,r=ep(t.toFixed(12));return r.length<=a||(r=t.toPrecision(10),r.length<=a)?r:t.toExponential(5)}function f6(t){var a=ep(t.toFixed(11));return a.length>(t<0?12:11)||a==="0"||a==="-0"?t.toPrecision(6):a}function x6(t){var a=Math.floor(Math.log(Math.abs(t))*Math.LOG10E),r;return a>=-4&&a<=-1?r=t.toPrecision(10+a):Math.abs(a)<=9?r=g6(t):a===10?r=t.toFixed(10).substr(0,12):r=f6(t),ep(h6(r.toUpperCase()))}function Tx(t,a){switch(typeof t){case"string":return t;case"boolean":return t?"TRUE":"FALSE";case"number":return(t|0)===t?t.toString(10):x6(t);case"undefined":return"";case"object":if(t==null)return"";if(t instanceof Date)return Al(14,L2(t,a&&a.date1904),a)}throw new Error("unsupported value in General format: "+t)}function p6(t,a){a[0]-=581;var r=t.getDay();return t<60&&(r=(r+6)%7),r}function y6(t,a,r,s){var i="",c=0,d=0,m=r.y,h,g=0;switch(t){case 98:m=r.y+543;case 121:switch(a.length){case 1:case 2:h=m%100,g=2;break;default:h=m%1e4,g=4;break}break;case 109:switch(a.length){case 1:case 2:h=r.m,g=a.length;break;case 3:return ax[r.m-1][1];case 5:return ax[r.m-1][0];default:return ax[r.m-1][2]}break;case 100:switch(a.length){case 1:case 2:h=r.d,g=a.length;break;case 3:return T1[r.q][0];default:return T1[r.q][1]}break;case 104:switch(a.length){case 1:case 2:h=1+(r.H+11)%12,g=a.length;break;default:throw"bad hour format: "+a}break;case 72:switch(a.length){case 1:case 2:h=r.H,g=a.length;break;default:throw"bad hour format: "+a}break;case 77:switch(a.length){case 1:case 2:h=r.M,g=a.length;break;default:throw"bad minute format: "+a}break;case 115:if(a!="s"&&a!="ss"&&a!=".0"&&a!=".00"&&a!=".000")throw"bad second format: "+a;return r.u===0&&(a=="s"||a=="ss")?Li(r.S,a.length):(s>=2?d=s===3?1e3:100:d=s===1?10:1,c=Math.round(d*(r.S+r.u)),c>=60*d&&(c=0),a==="s"?c===0?"0":""+c/d:(i=Li(c,2+s),a==="ss"?i.substr(0,2):"."+i.substr(2,a.length-1)));case 90:switch(a){case"[h]":case"[hh]":h=r.D*24+r.H;break;case"[m]":case"[mm]":h=(r.D*24+r.H)*60+r.M;break;case"[s]":case"[ss]":h=((r.D*24+r.H)*60+r.M)*60+Math.round(r.S+r.u);break;default:throw"bad abstime format: "+a}g=a.length===3?1:2;break;case 101:h=m,g=1;break}var p=g>0?Li(h,g):"";return p}function El(t){var a=3;if(t.length<=a)return t;for(var r=t.length%a,s=t.substr(0,r);r!=t.length;r+=a)s+=(s.length>0?",":"")+t.substr(r,a);return s}var R2=/%/g;function b6(t,a,r){var s=a.replace(R2,""),i=a.length-s.length;return qo(t,s,r*Math.pow(10,2*i))+Wr("%",i)}function v6(t,a,r){for(var s=a.length-1;a.charCodeAt(s-1)===44;)--s;return qo(t,a.substr(0,s),r/Math.pow(10,3*(a.length-s)))}function P2(t,a){var r,s=t.indexOf("E")-t.indexOf(".")-1;if(t.match(/^#+0.0E\+0$/)){if(a==0)return"0.0E+0";if(a<0)return"-"+P2(t,-a);var i=t.indexOf(".");i===-1&&(i=t.indexOf("E"));var c=Math.floor(Math.log(a)*Math.LOG10E)%i;if(c<0&&(c+=i),r=(a/Math.pow(10,c)).toPrecision(s+1+(i+c)%i),r.indexOf("e")===-1){var d=Math.floor(Math.log(a)*Math.LOG10E);for(r.indexOf(".")===-1?r=r.charAt(0)+"."+r.substr(1)+"E+"+(d-r.length+c):r+="E+"+(d-c);r.substr(0,2)==="0.";)r=r.charAt(0)+r.substr(2,i)+"."+r.substr(2+i),r=r.replace(/^0+([1-9])/,"$1").replace(/^0+\./,"0.");r=r.replace(/\+-/,"-")}r=r.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/,function(m,h,g,p){return h+g+p.substr(0,(i+c)%i)+"."+p.substr(c)+"E"})}else r=a.toExponential(s);return t.match(/E\+00$/)&&r.match(/e[+-]\d$/)&&(r=r.substr(0,r.length-1)+"0"+r.charAt(r.length-1)),t.match(/E\-/)&&r.match(/e\+/)&&(r=r.replace(/e\+/,"e")),r.replace("e","E")}var F2=/# (\?+)( ?)\/( ?)(\d+)/;function _6(t,a,r){var s=parseInt(t[4],10),i=Math.round(a*s),c=Math.floor(i/s),d=i-c*s,m=s;return r+(c===0?"":""+c)+" "+(d===0?Wr(" ",t[1].length+1+t[4].length):Qx(d,t[1].length)+t[2]+"/"+t[3]+Li(m,t[4].length))}function w6(t,a,r){return r+(a===0?"":""+a)+Wr(" ",t[1].length+2+t[4].length)}var I2=/^#*0*\.([0#]+)/,z2=/\).*[0#]/,B2=/\(###\) ###\\?-####/;function xn(t){for(var a="",r,s=0;s!=t.length;++s)switch(r=t.charCodeAt(s)){case 35:break;case 63:a+=" ";break;case 48:a+="0";break;default:a+=String.fromCharCode(r)}return a}function A1(t,a){var r=Math.pow(10,a);return""+Math.round(t*r)/r}function O1(t,a){var r=t-Math.floor(t),s=Math.pow(10,a);return a<(""+Math.round(r*s)).length?0:Math.round(r*s)}function k6(t,a){return a<(""+Math.round((t-Math.floor(t))*Math.pow(10,a))).length?1:0}function j6(t){return t<2147483647&&t>-2147483648?""+(t>=0?t|0:t-1|0):""+Math.floor(t)}function pi(t,a,r){if(t.charCodeAt(0)===40&&!a.match(z2)){var s=a.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");return r>=0?pi("n",s,r):"("+pi("n",s,-r)+")"}if(a.charCodeAt(a.length-1)===44)return v6(t,a,r);if(a.indexOf("%")!==-1)return b6(t,a,r);if(a.indexOf("E")!==-1)return P2(a,r);if(a.charCodeAt(0)===36)return"$"+pi(t,a.substr(a.charAt(1)==" "?2:1),r);var i,c,d,m,h=Math.abs(r),g=r<0?"-":"";if(a.match(/^00+$/))return g+wd(h,a.length);if(a.match(/^[#?]+$/))return i=wd(r,0),i==="0"&&(i=""),i.length>a.length?i:xn(a.substr(0,a.length-i.length))+i;if(c=a.match(F2))return _6(c,h,g);if(a.match(/^#+0+$/))return g+wd(h,a.length-a.indexOf("0"));if(c=a.match(I2))return i=A1(r,c[1].length).replace(/^([^\.]+)$/,"$1."+xn(c[1])).replace(/\.$/,"."+xn(c[1])).replace(/\.(\d*)$/,function(N,k){return"."+k+Wr("0",xn(c[1]).length-k.length)}),a.indexOf("0.")!==-1?i:i.replace(/^0\./,".");if(a=a.replace(/^#+([0.])/,"$1"),c=a.match(/^(0*)\.(#*)$/))return g+A1(h,c[2].length).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,c[1].length?"0.":".");if(c=a.match(/^#{1,3},##0(\.?)$/))return g+El(wd(h,0));if(c=a.match(/^#,##0\.([#0]*0)$/))return r<0?"-"+pi(t,a,-r):El(""+(Math.floor(r)+k6(r,c[1].length)))+"."+Li(O1(r,c[1].length),c[1].length);if(c=a.match(/^#,#*,#0/))return pi(t,a.replace(/^#,#*,/,""),r);if(c=a.match(/^([0#]+)(\\?-([0#]+))+$/))return i=Ld(pi(t,a.replace(/[\\-]/g,""),r)),d=0,Ld(Ld(a.replace(/\\/g,"")).replace(/[0#]/g,function(N){return d<i.length?i.charAt(d++):N==="0"?"0":""}));if(a.match(B2))return i=pi(t,"##########",r),"("+i.substr(0,3)+") "+i.substr(3,3)+"-"+i.substr(6);var p="";if(c=a.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))return d=Math.min(c[4].length,7),m=bh(h,Math.pow(10,d)-1,!1),i=""+g,p=qo("n",c[1],m[1]),p.charAt(p.length-1)==" "&&(p=p.substr(0,p.length-1)+"0"),i+=p+c[2]+"/"+c[3],p=ph(m[2],d),p.length<c[4].length&&(p=xn(c[4].substr(c[4].length-p.length))+p),i+=p,i;if(c=a.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))return d=Math.min(Math.max(c[1].length,c[4].length),7),m=bh(h,Math.pow(10,d)-1,!0),g+(m[0]||(m[1]?"":"0"))+" "+(m[1]?Qx(m[1],d)+c[2]+"/"+c[3]+ph(m[2],d):Wr(" ",2*d+1+c[2].length+c[3].length));if(c=a.match(/^[#0?]+$/))return i=wd(r,0),a.length<=i.length?i:xn(a.substr(0,a.length-i.length))+i;if(c=a.match(/^([#0?]+)\.([#0]+)$/)){i=""+r.toFixed(Math.min(c[2].length,10)).replace(/([^0])0+$/,"$1"),d=i.indexOf(".");var b=a.indexOf(".")-d,j=a.length-i.length-b;return xn(a.substr(0,b)+i+a.substr(a.length-j))}if(c=a.match(/^00,000\.([#0]*0)$/))return d=O1(r,c[1].length),r<0?"-"+pi(t,a,-r):El(j6(r)).replace(/^\d,\d{3}$/,"0$&").replace(/^\d*$/,function(N){return"00,"+(N.length<3?Li(0,3-N.length):"")+N})+"."+Li(d,c[1].length);switch(a){case"###,##0.00":return pi(t,"#,##0.00",r);case"###,###":case"##,###":case"#,###":var _=El(wd(h,0));return _!=="0"?g+_:"";case"###,###.00":return pi(t,"###,##0.00",r).replace(/^0\./,".");case"#,###.00":return pi(t,"#,##0.00",r).replace(/^0\./,".")}throw new Error("unsupported format |"+a+"|")}function N6(t,a,r){for(var s=a.length-1;a.charCodeAt(s-1)===44;)--s;return qo(t,a.substr(0,s),r/Math.pow(10,3*(a.length-s)))}function S6(t,a,r){var s=a.replace(R2,""),i=a.length-s.length;return qo(t,s,r*Math.pow(10,2*i))+Wr("%",i)}function U2(t,a){var r,s=t.indexOf("E")-t.indexOf(".")-1;if(t.match(/^#+0.0E\+0$/)){if(a==0)return"0.0E+0";if(a<0)return"-"+U2(t,-a);var i=t.indexOf(".");i===-1&&(i=t.indexOf("E"));var c=Math.floor(Math.log(a)*Math.LOG10E)%i;if(c<0&&(c+=i),r=(a/Math.pow(10,c)).toPrecision(s+1+(i+c)%i),!r.match(/[Ee]/)){var d=Math.floor(Math.log(a)*Math.LOG10E);r.indexOf(".")===-1?r=r.charAt(0)+"."+r.substr(1)+"E+"+(d-r.length+c):r+="E+"+(d-c),r=r.replace(/\+-/,"-")}r=r.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/,function(m,h,g,p){return h+g+p.substr(0,(i+c)%i)+"."+p.substr(c)+"E"})}else r=a.toExponential(s);return t.match(/E\+00$/)&&r.match(/e[+-]\d$/)&&(r=r.substr(0,r.length-1)+"0"+r.charAt(r.length-1)),t.match(/E\-/)&&r.match(/e\+/)&&(r=r.replace(/e\+/,"e")),r.replace("e","E")}function uo(t,a,r){if(t.charCodeAt(0)===40&&!a.match(z2)){var s=a.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");return r>=0?uo("n",s,r):"("+uo("n",s,-r)+")"}if(a.charCodeAt(a.length-1)===44)return N6(t,a,r);if(a.indexOf("%")!==-1)return S6(t,a,r);if(a.indexOf("E")!==-1)return U2(a,r);if(a.charCodeAt(0)===36)return"$"+uo(t,a.substr(a.charAt(1)==" "?2:1),r);var i,c,d,m,h=Math.abs(r),g=r<0?"-":"";if(a.match(/^00+$/))return g+Li(h,a.length);if(a.match(/^[#?]+$/))return i=""+r,r===0&&(i=""),i.length>a.length?i:xn(a.substr(0,a.length-i.length))+i;if(c=a.match(F2))return w6(c,h,g);if(a.match(/^#+0+$/))return g+Li(h,a.length-a.indexOf("0"));if(c=a.match(I2))return i=(""+r).replace(/^([^\.]+)$/,"$1."+xn(c[1])).replace(/\.$/,"."+xn(c[1])),i=i.replace(/\.(\d*)$/,function(N,k){return"."+k+Wr("0",xn(c[1]).length-k.length)}),a.indexOf("0.")!==-1?i:i.replace(/^0\./,".");if(a=a.replace(/^#+([0.])/,"$1"),c=a.match(/^(0*)\.(#*)$/))return g+(""+h).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,c[1].length?"0.":".");if(c=a.match(/^#{1,3},##0(\.?)$/))return g+El(""+h);if(c=a.match(/^#,##0\.([#0]*0)$/))return r<0?"-"+uo(t,a,-r):El(""+r)+"."+Wr("0",c[1].length);if(c=a.match(/^#,#*,#0/))return uo(t,a.replace(/^#,#*,/,""),r);if(c=a.match(/^([0#]+)(\\?-([0#]+))+$/))return i=Ld(uo(t,a.replace(/[\\-]/g,""),r)),d=0,Ld(Ld(a.replace(/\\/g,"")).replace(/[0#]/g,function(N){return d<i.length?i.charAt(d++):N==="0"?"0":""}));if(a.match(B2))return i=uo(t,"##########",r),"("+i.substr(0,3)+") "+i.substr(3,3)+"-"+i.substr(6);var p="";if(c=a.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))return d=Math.min(c[4].length,7),m=bh(h,Math.pow(10,d)-1,!1),i=""+g,p=qo("n",c[1],m[1]),p.charAt(p.length-1)==" "&&(p=p.substr(0,p.length-1)+"0"),i+=p+c[2]+"/"+c[3],p=ph(m[2],d),p.length<c[4].length&&(p=xn(c[4].substr(c[4].length-p.length))+p),i+=p,i;if(c=a.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))return d=Math.min(Math.max(c[1].length,c[4].length),7),m=bh(h,Math.pow(10,d)-1,!0),g+(m[0]||(m[1]?"":"0"))+" "+(m[1]?Qx(m[1],d)+c[2]+"/"+c[3]+ph(m[2],d):Wr(" ",2*d+1+c[2].length+c[3].length));if(c=a.match(/^[#0?]+$/))return i=""+r,a.length<=i.length?i:xn(a.substr(0,a.length-i.length))+i;if(c=a.match(/^([#0]+)\.([#0]+)$/)){i=""+r.toFixed(Math.min(c[2].length,10)).replace(/([^0])0+$/,"$1"),d=i.indexOf(".");var b=a.indexOf(".")-d,j=a.length-i.length-b;return xn(a.substr(0,b)+i+a.substr(a.length-j))}if(c=a.match(/^00,000\.([#0]*0)$/))return r<0?"-"+uo(t,a,-r):El(""+r).replace(/^\d,\d{3}$/,"0$&").replace(/^\d*$/,function(N){return"00,"+(N.length<3?Li(0,3-N.length):"")+N})+"."+Li(0,c[1].length);switch(a){case"###,###":case"##,###":case"#,###":var _=El(""+h);return _!=="0"?g+_:"";default:if(a.match(/\.[0#?]*$/))return uo(t,a.slice(0,a.lastIndexOf(".")),r)+xn(a.slice(a.lastIndexOf(".")))}throw new Error("unsupported format |"+a+"|")}function qo(t,a,r){return(r|0)===r?uo(t,a,r):pi(t,a,r)}function C6(t){for(var a=[],r=!1,s=0,i=0;s<t.length;++s)switch(t.charCodeAt(s)){case 34:r=!r;break;case 95:case 42:case 92:++s;break;case 59:a[a.length]=t.substr(i,s-i),i=s+1}if(a[a.length]=t.substr(i),r===!0)throw new Error("Format |"+t+"| unterminated string ");return a}var $2=/\[[HhMmSs\u0E0A\u0E19\u0E17]*\]/;function H2(t){for(var a=0,r="",s="";a<t.length;)switch(r=t.charAt(a)){case"G":yh(t,a)&&(a+=6),a++;break;case'"':for(;t.charCodeAt(++a)!==34&&a<t.length;);++a;break;case"\\":a+=2;break;case"_":a+=2;break;case"@":++a;break;case"B":case"b":if(t.charAt(a+1)==="1"||t.charAt(a+1)==="2")return!0;case"M":case"D":case"Y":case"H":case"S":case"E":case"m":case"d":case"y":case"h":case"s":case"e":case"g":return!0;case"A":case"a":case"上":if(t.substr(a,3).toUpperCase()==="A/P"||t.substr(a,5).toUpperCase()==="AM/PM"||t.substr(a,5).toUpperCase()==="上午/下午")return!0;++a;break;case"[":for(s=r;t.charAt(a++)!=="]"&&a<t.length;)s+=t.charAt(a);if(s.match($2))return!0;break;case".":case"0":case"#":for(;a<t.length&&("0#?.,E+-%".indexOf(r=t.charAt(++a))>-1||r=="\\"&&t.charAt(a+1)=="-"&&"0#".indexOf(t.charAt(a+2))>-1););break;case"?":for(;t.charAt(++a)===r;);break;case"*":++a,(t.charAt(a)==" "||t.charAt(a)=="*")&&++a;break;case"(":case")":++a;break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(;a<t.length&&"0123456789".indexOf(t.charAt(++a))>-1;);break;case" ":++a;break;default:++a;break}return!1}function T6(t,a,r,s){for(var i=[],c="",d=0,m="",h="t",g,p,b,j="H";d<t.length;)switch(m=t.charAt(d)){case"G":if(!yh(t,d))throw new Error("unrecognized character "+m+" in "+t);i[i.length]={t:"G",v:"General"},d+=7;break;case'"':for(c="";(b=t.charCodeAt(++d))!==34&&d<t.length;)c+=String.fromCharCode(b);i[i.length]={t:"t",v:c},++d;break;case"\\":var _=t.charAt(++d),N=_==="("||_===")"?_:"t";i[i.length]={t:N,v:_},++d;break;case"_":i[i.length]={t:"t",v:" "},d+=2;break;case"@":i[i.length]={t:"T",v:a},++d;break;case"B":case"b":if(t.charAt(d+1)==="1"||t.charAt(d+1)==="2"){if(g==null&&(g=Bm(a,r,t.charAt(d+1)==="2"),g==null))return"";i[i.length]={t:"X",v:t.substr(d,2)},h=m,d+=2;break}case"M":case"D":case"Y":case"H":case"S":case"E":m=m.toLowerCase();case"m":case"d":case"y":case"h":case"s":case"e":case"g":if(a<0||g==null&&(g=Bm(a,r),g==null))return"";for(c=m;++d<t.length&&t.charAt(d).toLowerCase()===m;)c+=m;m==="m"&&h.toLowerCase()==="h"&&(m="M"),m==="h"&&(m=j),i[i.length]={t:m,v:c},h=m;break;case"A":case"a":case"上":var k={t:m,v:m};if(g==null&&(g=Bm(a,r)),t.substr(d,3).toUpperCase()==="A/P"?(g!=null&&(k.v=g.H>=12?"P":"A"),k.t="T",j="h",d+=3):t.substr(d,5).toUpperCase()==="AM/PM"?(g!=null&&(k.v=g.H>=12?"PM":"AM"),k.t="T",d+=5,j="h"):t.substr(d,5).toUpperCase()==="上午/下午"?(g!=null&&(k.v=g.H>=12?"下午":"上午"),k.t="T",d+=5,j="h"):(k.t="t",++d),g==null&&k.t==="T")return"";i[i.length]=k,h=m;break;case"[":for(c=m;t.charAt(d++)!=="]"&&d<t.length;)c+=t.charAt(d);if(c.slice(-1)!=="]")throw'unterminated "[" block: |'+c+"|";if(c.match($2)){if(g==null&&(g=Bm(a,r),g==null))return"";i[i.length]={t:"Z",v:c.toLowerCase()},h=c.charAt(1)}else c.indexOf("$")>-1&&(c=(c.match(/\$([^-\[\]]*)/)||[])[1]||"$",H2(t)||(i[i.length]={t:"t",v:c}));break;case".":if(g!=null){for(c=m;++d<t.length&&(m=t.charAt(d))==="0";)c+=m;i[i.length]={t:"s",v:c};break}case"0":case"#":for(c=m;++d<t.length&&"0#?.,E+-%".indexOf(m=t.charAt(d))>-1;)c+=m;i[i.length]={t:"n",v:c};break;case"?":for(c=m;t.charAt(++d)===m;)c+=m;i[i.length]={t:m,v:c},h=m;break;case"*":++d,(t.charAt(d)==" "||t.charAt(d)=="*")&&++d;break;case"(":case")":i[i.length]={t:s===1?"t":m,v:m},++d;break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(c=m;d<t.length&&"0123456789".indexOf(t.charAt(++d))>-1;)c+=t.charAt(d);i[i.length]={t:"D",v:c};break;case" ":i[i.length]={t:m,v:m},++d;break;case"$":i[i.length]={t:"t",v:"$"},++d;break;default:if(",$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP".indexOf(m)===-1)throw new Error("unrecognized character "+m+" in "+t);i[i.length]={t:"t",v:m},++d;break}var C=0,D=0,T;for(d=i.length-1,h="t";d>=0;--d)switch(i[d].t){case"h":case"H":i[d].t=j,h="h",C<1&&(C=1);break;case"s":(T=i[d].v.match(/\.0+$/))&&(D=Math.max(D,T[0].length-1)),C<3&&(C=3);case"d":case"y":case"M":case"e":h=i[d].t;break;case"m":h==="s"&&(i[d].t="M",C<2&&(C=2));break;case"X":break;case"Z":C<1&&i[d].v.match(/[Hh]/)&&(C=1),C<2&&i[d].v.match(/[Mm]/)&&(C=2),C<3&&i[d].v.match(/[Ss]/)&&(C=3)}switch(C){case 0:break;case 1:g.u>=.5&&(g.u=0,++g.S),g.S>=60&&(g.S=0,++g.M),g.M>=60&&(g.M=0,++g.H);break;case 2:g.u>=.5&&(g.u=0,++g.S),g.S>=60&&(g.S=0,++g.M);break}var E="",O;for(d=0;d<i.length;++d)switch(i[d].t){case"t":case"T":case" ":case"D":break;case"X":i[d].v="",i[d].t=";";break;case"d":case"m":case"y":case"h":case"H":case"M":case"s":case"e":case"b":case"Z":i[d].v=y6(i[d].t.charCodeAt(0),i[d].v,g,D),i[d].t="t";break;case"n":case"?":for(O=d+1;i[O]!=null&&((m=i[O].t)==="?"||m==="D"||(m===" "||m==="t")&&i[O+1]!=null&&(i[O+1].t==="?"||i[O+1].t==="t"&&i[O+1].v==="/")||i[d].t==="("&&(m===" "||m==="n"||m===")")||m==="t"&&(i[O].v==="/"||i[O].v===" "&&i[O+1]!=null&&i[O+1].t=="?"));)i[d].v+=i[O].v,i[O]={v:"",t:";"},++O;E+=i[d].v,d=O-1;break;case"G":i[d].t="t",i[d].v=Tx(a,r);break}var R="",Y,P;if(E.length>0){E.charCodeAt(0)==40?(Y=a<0&&E.charCodeAt(0)===45?-a:a,P=qo("n",E,Y)):(Y=a<0&&s>1?-a:a,P=qo("n",E,Y),Y<0&&i[0]&&i[0].t=="t"&&(P=P.substr(1),i[0].v="-"+i[0].v)),O=P.length-1;var U=i.length;for(d=0;d<i.length;++d)if(i[d]!=null&&i[d].t!="t"&&i[d].v.indexOf(".")>-1){U=d;break}var J=i.length;if(U===i.length&&P.indexOf("E")===-1){for(d=i.length-1;d>=0;--d)i[d]==null||"n?".indexOf(i[d].t)===-1||(O>=i[d].v.length-1?(O-=i[d].v.length,i[d].v=P.substr(O+1,i[d].v.length)):O<0?i[d].v="":(i[d].v=P.substr(0,O+1),O=-1),i[d].t="t",J=d);O>=0&&J<i.length&&(i[J].v=P.substr(0,O+1)+i[J].v)}else if(U!==i.length&&P.indexOf("E")===-1){for(O=P.indexOf(".")-1,d=U;d>=0;--d)if(!(i[d]==null||"n?".indexOf(i[d].t)===-1)){for(p=i[d].v.indexOf(".")>-1&&d===U?i[d].v.indexOf(".")-1:i[d].v.length-1,R=i[d].v.substr(p+1);p>=0;--p)O>=0&&(i[d].v.charAt(p)==="0"||i[d].v.charAt(p)==="#")&&(R=P.charAt(O--)+R);i[d].v=R,i[d].t="t",J=d}for(O>=0&&J<i.length&&(i[J].v=P.substr(0,O+1)+i[J].v),O=P.indexOf(".")+1,d=U;d<i.length;++d)if(!(i[d]==null||"n?(".indexOf(i[d].t)===-1&&d!==U)){for(p=i[d].v.indexOf(".")>-1&&d===U?i[d].v.indexOf(".")+1:0,R=i[d].v.substr(0,p);p<i[d].v.length;++p)O<P.length&&(R+=P.charAt(O++));i[d].v=R,i[d].t="t",J=d}}}for(d=0;d<i.length;++d)i[d]!=null&&"n?".indexOf(i[d].t)>-1&&(Y=s>1&&a<0&&d>0&&i[d-1].v==="-"?-a:a,i[d].v=qo(i[d].t,i[d].v,Y),i[d].t="t");var ne="";for(d=0;d!==i.length;++d)i[d]!=null&&(ne+=i[d].v);return ne}var D1=/\[(=|>[=]?|<[>=]?)(-?\d+(?:\.\d*)?)\]/;function M1(t,a){if(a==null)return!1;var r=parseFloat(a[2]);switch(a[1]){case"=":if(t==r)return!0;break;case">":if(t>r)return!0;break;case"<":if(t<r)return!0;break;case"<>":if(t!=r)return!0;break;case">=":if(t>=r)return!0;break;case"<=":if(t<=r)return!0;break}return!1}function E6(t,a){var r=C6(t),s=r.length,i=r[s-1].indexOf("@");if(s<4&&i>-1&&--s,r.length>4)throw new Error("cannot find right format for |"+r.join("|")+"|");if(typeof a!="number")return[4,r.length===4||i>-1?r[r.length-1]:"@"];switch(r.length){case 1:r=i>-1?["General","General","General",r[0]]:[r[0],r[0],r[0],"@"];break;case 2:r=i>-1?[r[0],r[0],r[0],r[1]]:[r[0],r[1],r[0],"@"];break;case 3:r=i>-1?[r[0],r[1],r[0],r[2]]:[r[0],r[1],r[2],"@"];break}var c=a>0?r[0]:a<0?r[1]:r[2];if(r[0].indexOf("[")===-1&&r[1].indexOf("[")===-1)return[s,c];if(r[0].match(/\[[=<>]/)!=null||r[1].match(/\[[=<>]/)!=null){var d=r[0].match(D1),m=r[1].match(D1);return M1(a,d)?[s,r[0]]:M1(a,m)?[s,r[1]]:[s,r[d!=null&&m!=null?2:1]]}return[s,c]}function Al(t,a,r){r==null&&(r={});var s="";switch(typeof t){case"string":t=="m/d/yy"&&r.dateNF?s=r.dateNF:s=t;break;case"number":t==14&&r.dateNF?s=r.dateNF:s=(r.table!=null?r.table:Vr)[t],s==null&&(s=r.table&&r.table[E1[t]]||Vr[E1[t]]),s==null&&(s=d6[t]||"General");break}if(yh(s,0))return Tx(a,r);a instanceof Date&&(a=L2(a,r.date1904));var i=E6(s,a);if(yh(i[1]))return Tx(a,r);if(a===!0)a="TRUE";else if(a===!1)a="FALSE";else if(a===""||a==null)return"";return T6(i[1],a,r,i[0])}function W2(t,a){if(typeof a!="number"){a=+a||-1;for(var r=0;r<392;++r){if(Vr[r]==null){a<0&&(a=r);continue}if(Vr[r]==t){a=r;break}}a<0&&(a=391)}return Vr[a]=t,a}function Ih(t){for(var a=0;a!=392;++a)t[a]!==void 0&&W2(t[a],a)}function zh(){Vr=c6()}var V2=/[dD]+|[mM]+|[yYeE]+|[Hh]+|[Ss]+/g;function A6(t){var a=typeof t=="number"?Vr[t]:t;return a=a.replace(V2,"(\\d+)"),new RegExp("^"+a+"$")}function O6(t,a,r){var s=-1,i=-1,c=-1,d=-1,m=-1,h=-1;(a.match(V2)||[]).forEach(function(b,j){var _=parseInt(r[j+1],10);switch(b.toLowerCase().charAt(0)){case"y":s=_;break;case"d":c=_;break;case"h":d=_;break;case"s":h=_;break;case"m":d>=0?m=_:i=_;break}}),h>=0&&m==-1&&i>=0&&(m=i,i=-1);var g=(""+(s>=0?s:new Date().getFullYear())).slice(-4)+"-"+("00"+(i>=1?i:1)).slice(-2)+"-"+("00"+(c>=1?c:1)).slice(-2);g.length==7&&(g="0"+g),g.length==8&&(g="20"+g);var p=("00"+(d>=0?d:0)).slice(-2)+":"+("00"+(m>=0?m:0)).slice(-2)+":"+("00"+(h>=0?h:0)).slice(-2);return d==-1&&m==-1&&h==-1?g:s==-1&&i==-1&&c==-1?p:g+"T"+p}var D6=(function(){var t={};t.version="1.2.0";function a(){for(var P=0,U=new Array(256),J=0;J!=256;++J)P=J,P=P&1?-306674912^P>>>1:P>>>1,P=P&1?-306674912^P>>>1:P>>>1,P=P&1?-306674912^P>>>1:P>>>1,P=P&1?-306674912^P>>>1:P>>>1,P=P&1?-306674912^P>>>1:P>>>1,P=P&1?-306674912^P>>>1:P>>>1,P=P&1?-306674912^P>>>1:P>>>1,P=P&1?-306674912^P>>>1:P>>>1,U[J]=P;return typeof Int32Array!="undefined"?new Int32Array(U):U}var r=a();function s(P){var U=0,J=0,ne=0,ye=typeof Int32Array!="undefined"?new Int32Array(4096):new Array(4096);for(ne=0;ne!=256;++ne)ye[ne]=P[ne];for(ne=0;ne!=256;++ne)for(J=P[ne],U=256+ne;U<4096;U+=256)J=ye[U]=J>>>8^P[J&255];var he=[];for(ne=1;ne!=16;++ne)he[ne-1]=typeof Int32Array!="undefined"?ye.subarray(ne*256,ne*256+256):ye.slice(ne*256,ne*256+256);return he}var i=s(r),c=i[0],d=i[1],m=i[2],h=i[3],g=i[4],p=i[5],b=i[6],j=i[7],_=i[8],N=i[9],k=i[10],C=i[11],D=i[12],T=i[13],E=i[14];function O(P,U){for(var J=U^-1,ne=0,ye=P.length;ne<ye;)J=J>>>8^r[(J^P.charCodeAt(ne++))&255];return~J}function R(P,U){for(var J=U^-1,ne=P.length-15,ye=0;ye<ne;)J=E[P[ye++]^J&255]^T[P[ye++]^J>>8&255]^D[P[ye++]^J>>16&255]^C[P[ye++]^J>>>24]^k[P[ye++]]^N[P[ye++]]^_[P[ye++]]^j[P[ye++]]^b[P[ye++]]^p[P[ye++]]^g[P[ye++]]^h[P[ye++]]^m[P[ye++]]^d[P[ye++]]^c[P[ye++]]^r[P[ye++]];for(ne+=15;ye<ne;)J=J>>>8^r[(J^P[ye++])&255];return~J}function Y(P,U){for(var J=U^-1,ne=0,ye=P.length,he=0,ce=0;ne<ye;)he=P.charCodeAt(ne++),he<128?J=J>>>8^r[(J^he)&255]:he<2048?(J=J>>>8^r[(J^(192|he>>6&31))&255],J=J>>>8^r[(J^(128|he&63))&255]):he>=55296&&he<57344?(he=(he&1023)+64,ce=P.charCodeAt(ne++)&1023,J=J>>>8^r[(J^(240|he>>8&7))&255],J=J>>>8^r[(J^(128|he>>2&63))&255],J=J>>>8^r[(J^(128|ce>>6&15|(he&3)<<4))&255],J=J>>>8^r[(J^(128|ce&63))&255]):(J=J>>>8^r[(J^(224|he>>12&15))&255],J=J>>>8^r[(J^(128|he>>6&63))&255],J=J>>>8^r[(J^(128|he&63))&255]);return~J}return t.table=r,t.bstr=O,t.buf=R,t.str=Y,t})(),vr=(function(){var a={};a.version="1.2.1";function r(V,me){for(var de=V.split("/"),ie=me.split("/"),xe=0,_e=0,He=Math.min(de.length,ie.length);xe<He;++xe){if(_e=de[xe].length-ie[xe].length)return _e;if(de[xe]!=ie[xe])return de[xe]<ie[xe]?-1:1}return de.length-ie.length}function s(V){if(V.charAt(V.length-1)=="/")return V.slice(0,-1).indexOf("/")===-1?V:s(V.slice(0,-1));var me=V.lastIndexOf("/");return me===-1?V:V.slice(0,me+1)}function i(V){if(V.charAt(V.length-1)=="/")return i(V.slice(0,-1));var me=V.lastIndexOf("/");return me===-1?V:V.slice(me+1)}function c(V,me){typeof me=="string"&&(me=new Date(me));var de=me.getHours();de=de<<6|me.getMinutes(),de=de<<5|me.getSeconds()>>>1,V.write_shift(2,de);var ie=me.getFullYear()-1980;ie=ie<<4|me.getMonth()+1,ie=ie<<5|me.getDate(),V.write_shift(2,ie)}function d(V){var me=V.read_shift(2)&65535,de=V.read_shift(2)&65535,ie=new Date,xe=de&31;de>>>=5;var _e=de&15;de>>>=4,ie.setMilliseconds(0),ie.setFullYear(de+1980),ie.setMonth(_e-1),ie.setDate(xe);var He=me&31;me>>>=5;var Ue=me&63;return me>>>=6,ie.setHours(me),ie.setMinutes(Ue),ie.setSeconds(He<<1),ie}function m(V){Qn(V,0);for(var me={},de=0;V.l<=V.length-4;){var ie=V.read_shift(2),xe=V.read_shift(2),_e=V.l+xe,He={};switch(ie){case 21589:de=V.read_shift(1),de&1&&(He.mtime=V.read_shift(4)),xe>5&&(de&2&&(He.atime=V.read_shift(4)),de&4&&(He.ctime=V.read_shift(4))),He.mtime&&(He.mt=new Date(He.mtime*1e3));break}V.l=_e,me[ie]=He}return me}var h;function g(){return h||(h={})}function p(V,me){if(V[0]==80&&V[1]==75)return kt(V,me);if((V[0]|32)==109&&(V[1]|32)==105)return re(V,me);if(V.length<512)throw new Error("CFB file size "+V.length+" < 512");var de=3,ie=512,xe=0,_e=0,He=0,Ue=0,Pe=0,Re=[],We=V.slice(0,512);Qn(We,0);var _t=b(We);switch(de=_t[0],de){case 3:ie=512;break;case 4:ie=4096;break;case 0:if(_t[1]==0)return kt(V,me);default:throw new Error("Major Version: Expected 3 or 4 saw "+de)}ie!==512&&(We=V.slice(0,ie),Qn(We,28));var Ft=V.slice(0,ie);j(We,de);var dt=We.read_shift(4,"i");if(de===3&&dt!==0)throw new Error("# Directory Sectors: Expected 0 saw "+dt);We.l+=4,He=We.read_shift(4,"i"),We.l+=4,We.chk("00100000","Mini Stream Cutoff Size: "),Ue=We.read_shift(4,"i"),xe=We.read_shift(4,"i"),Pe=We.read_shift(4,"i"),_e=We.read_shift(4,"i");for(var pt=-1,At=0;At<109&&(pt=We.read_shift(4,"i"),!(pt<0));++At)Re[At]=pt;var Zt=_(V,ie);C(Pe,_e,Zt,ie,Re);var Fa=T(Zt,He,Re,ie);Fa[He].name="!Directory",xe>0&&Ue!==ce&&(Fa[Ue].name="!MiniFAT"),Fa[Re[0]].name="!FAT",Fa.fat_addrs=Re,Fa.ssz=ie;var La={},Ya=[],gr=[],ar=[];E(He,Fa,Zt,Ya,xe,La,gr,Ue),N(gr,ar,Ya),Ya.shift();var Ir={FileIndex:gr,FullPaths:ar};return me&&me.raw&&(Ir.raw={header:Ft,sectors:Zt}),Ir}function b(V){if(V[V.l]==80&&V[V.l+1]==75)return[0,0];V.chk(se,"Header Signature: "),V.l+=16;var me=V.read_shift(2,"u");return[V.read_shift(2,"u"),me]}function j(V,me){var de=9;switch(V.l+=2,de=V.read_shift(2)){case 9:if(me!=3)throw new Error("Sector Shift: Expected 9 saw "+de);break;case 12:if(me!=4)throw new Error("Sector Shift: Expected 12 saw "+de);break;default:throw new Error("Sector Shift: Expected 9 or 12 saw "+de)}V.chk("0600","Mini Sector Shift: "),V.chk("000000000000","Reserved: ")}function _(V,me){for(var de=Math.ceil(V.length/me)-1,ie=[],xe=1;xe<de;++xe)ie[xe-1]=V.slice(xe*me,(xe+1)*me);return ie[de-1]=V.slice(de*me),ie}function N(V,me,de){for(var ie=0,xe=0,_e=0,He=0,Ue=0,Pe=de.length,Re=[],We=[];ie<Pe;++ie)Re[ie]=We[ie]=ie,me[ie]=de[ie];for(;Ue<We.length;++Ue)ie=We[Ue],xe=V[ie].L,_e=V[ie].R,He=V[ie].C,Re[ie]===ie&&(xe!==-1&&Re[xe]!==xe&&(Re[ie]=Re[xe]),_e!==-1&&Re[_e]!==_e&&(Re[ie]=Re[_e])),He!==-1&&(Re[He]=ie),xe!==-1&&ie!=Re[ie]&&(Re[xe]=Re[ie],We.lastIndexOf(xe)<Ue&&We.push(xe)),_e!==-1&&ie!=Re[ie]&&(Re[_e]=Re[ie],We.lastIndexOf(_e)<Ue&&We.push(_e));for(ie=1;ie<Pe;++ie)Re[ie]===ie&&(_e!==-1&&Re[_e]!==_e?Re[ie]=Re[_e]:xe!==-1&&Re[xe]!==xe&&(Re[ie]=Re[xe]));for(ie=1;ie<Pe;++ie)if(V[ie].type!==0){if(Ue=ie,Ue!=Re[Ue])do Ue=Re[Ue],me[ie]=me[Ue]+"/"+me[ie];while(Ue!==0&&Re[Ue]!==-1&&Ue!=Re[Ue]);Re[ie]=-1}for(me[0]+="/",ie=1;ie<Pe;++ie)V[ie].type!==2&&(me[ie]+="/")}function k(V,me,de){for(var ie=V.start,xe=V.size,_e=[],He=ie;de&&xe>0&&He>=0;)_e.push(me.slice(He*he,He*he+he)),xe-=he,He=uc(de,He*4);return _e.length===0?bt(0):qs(_e).slice(0,V.size)}function C(V,me,de,ie,xe){var _e=ce;if(V===ce){if(me!==0)throw new Error("DIFAT chain shorter than expected")}else if(V!==-1){var He=de[V],Ue=(ie>>>2)-1;if(!He)return;for(var Pe=0;Pe<Ue&&(_e=uc(He,Pe*4))!==ce;++Pe)xe.push(_e);C(uc(He,ie-4),me-1,de,ie,xe)}}function D(V,me,de,ie,xe){var _e=[],He=[];xe||(xe=[]);var Ue=ie-1,Pe=0,Re=0;for(Pe=me;Pe>=0;){xe[Pe]=!0,_e[_e.length]=Pe,He.push(V[Pe]);var We=de[Math.floor(Pe*4/ie)];if(Re=Pe*4&Ue,ie<4+Re)throw new Error("FAT boundary crossed: "+Pe+" 4 "+ie);if(!V[We])break;Pe=uc(V[We],Re)}return{nodes:_e,data:U1([He])}}function T(V,me,de,ie){var xe=V.length,_e=[],He=[],Ue=[],Pe=[],Re=ie-1,We=0,_t=0,Ft=0,dt=0;for(We=0;We<xe;++We)if(Ue=[],Ft=We+me,Ft>=xe&&(Ft-=xe),!He[Ft]){Pe=[];var pt=[];for(_t=Ft;_t>=0;){pt[_t]=!0,He[_t]=!0,Ue[Ue.length]=_t,Pe.push(V[_t]);var At=de[Math.floor(_t*4/ie)];if(dt=_t*4&Re,ie<4+dt)throw new Error("FAT boundary crossed: "+_t+" 4 "+ie);if(!V[At]||(_t=uc(V[At],dt),pt[_t]))break}_e[Ft]={nodes:Ue,data:U1([Pe])}}return _e}function E(V,me,de,ie,xe,_e,He,Ue){for(var Pe=0,Re=ie.length?2:0,We=me[V].data,_t=0,Ft=0,dt;_t<We.length;_t+=128){var pt=We.slice(_t,_t+128);Qn(pt,64),Ft=pt.read_shift(2),dt=np(pt,0,Ft-Re),ie.push(dt);var At={name:dt,type:pt.read_shift(1),color:pt.read_shift(1),L:pt.read_shift(4,"i"),R:pt.read_shift(4,"i"),C:pt.read_shift(4,"i"),clsid:pt.read_shift(16),state:pt.read_shift(4,"i"),start:0,size:0},Zt=pt.read_shift(2)+pt.read_shift(2)+pt.read_shift(2)+pt.read_shift(2);Zt!==0&&(At.ct=O(pt,pt.l-8));var Fa=pt.read_shift(2)+pt.read_shift(2)+pt.read_shift(2)+pt.read_shift(2);Fa!==0&&(At.mt=O(pt,pt.l-8)),At.start=pt.read_shift(4,"i"),At.size=pt.read_shift(4,"i"),At.size<0&&At.start<0&&(At.size=At.type=0,At.start=ce,At.name=""),At.type===5?(Pe=At.start,xe>0&&Pe!==ce&&(me[Pe].name="!StreamData")):At.size>=4096?(At.storage="fat",me[At.start]===void 0&&(me[At.start]=D(de,At.start,me.fat_addrs,me.ssz)),me[At.start].name=At.name,At.content=me[At.start].data.slice(0,At.size)):(At.storage="minifat",At.size<0?At.size=0:Pe!==ce&&At.start!==ce&&me[Pe]&&(At.content=k(At,me[Pe].data,(me[Ue]||{}).data))),At.content&&Qn(At.content,0),_e[dt]=At,He.push(At)}}function O(V,me){return new Date((ai(V,me+4)/1e7*Math.pow(2,32)+ai(V,me)/1e7-11644473600)*1e3)}function R(V,me){return g(),p(h.readFileSync(V),me)}function Y(V,me){var de=me&&me.type;switch(de||ir&&Buffer.isBuffer(V)&&(de="buffer"),de||"base64"){case"file":return R(V,me);case"base64":return p(Mi(Jo(V)),me);case"binary":return p(Mi(V),me)}return p(V,me)}function P(V,me){var de=me||{},ie=de.root||"Root Entry";if(V.FullPaths||(V.FullPaths=[]),V.FileIndex||(V.FileIndex=[]),V.FullPaths.length!==V.FileIndex.length)throw new Error("inconsistent CFB structure");V.FullPaths.length===0&&(V.FullPaths[0]=ie+"/",V.FileIndex[0]={name:ie,type:5}),de.CLSID&&(V.FileIndex[0].clsid=de.CLSID),U(V)}function U(V){var me="Sh33tJ5";if(!vr.find(V,"/"+me)){var de=bt(4);de[0]=55,de[1]=de[3]=50,de[2]=54,V.FileIndex.push({name:me,type:2,content:de,size:4,L:69,R:69,C:69}),V.FullPaths.push(V.FullPaths[0]+me),J(V)}}function J(V,me){P(V);for(var de=!1,ie=!1,xe=V.FullPaths.length-1;xe>=0;--xe){var _e=V.FileIndex[xe];switch(_e.type){case 0:ie?de=!0:(V.FileIndex.pop(),V.FullPaths.pop());break;case 1:case 2:case 5:ie=!0,isNaN(_e.R*_e.L*_e.C)&&(de=!0),_e.R>-1&&_e.L>-1&&_e.R==_e.L&&(de=!0);break;default:de=!0;break}}if(!(!de&&!me)){var He=new Date(1987,1,19),Ue=0,Pe=Object.create?Object.create(null):{},Re=[];for(xe=0;xe<V.FullPaths.length;++xe)Pe[V.FullPaths[xe]]=!0,V.FileIndex[xe].type!==0&&Re.push([V.FullPaths[xe],V.FileIndex[xe]]);for(xe=0;xe<Re.length;++xe){var We=s(Re[xe][0]);ie=Pe[We],ie||(Re.push([We,{name:i(We).replace("/",""),type:1,clsid:te,ct:He,mt:He,content:null}]),Pe[We]=!0)}for(Re.sort(function(dt,pt){return r(dt[0],pt[0])}),V.FullPaths=[],V.FileIndex=[],xe=0;xe<Re.length;++xe)V.FullPaths[xe]=Re[xe][0],V.FileIndex[xe]=Re[xe][1];for(xe=0;xe<Re.length;++xe){var _t=V.FileIndex[xe],Ft=V.FullPaths[xe];if(_t.name=i(Ft).replace("/",""),_t.L=_t.R=_t.C=-(_t.color=1),_t.size=_t.content?_t.content.length:0,_t.start=0,_t.clsid=_t.clsid||te,xe===0)_t.C=Re.length>1?1:-1,_t.size=0,_t.type=5;else if(Ft.slice(-1)=="/"){for(Ue=xe+1;Ue<Re.length&&s(V.FullPaths[Ue])!=Ft;++Ue);for(_t.C=Ue>=Re.length?-1:Ue,Ue=xe+1;Ue<Re.length&&s(V.FullPaths[Ue])!=s(Ft);++Ue);_t.R=Ue>=Re.length?-1:Ue,_t.type=1}else s(V.FullPaths[xe+1]||"")==s(Ft)&&(_t.R=xe+1),_t.type=2}}}function ne(V,me){var de=me||{};if(de.fileType=="mad")return Ee(V,de);switch(J(V),de.fileType){case"zip":return xt(V,de)}var ie=(function(dt){for(var pt=0,At=0,Zt=0;Zt<dt.FileIndex.length;++Zt){var Fa=dt.FileIndex[Zt];if(Fa.content){var La=Fa.content.length;La>0&&(La<4096?pt+=La+63>>6:At+=La+511>>9)}}for(var Ya=dt.FullPaths.length+3>>2,gr=pt+7>>3,ar=pt+127>>7,Ir=gr+At+Ya+ar,kr=Ir+127>>7,hs=kr<=109?0:Math.ceil((kr-109)/127);Ir+kr+hs+127>>7>kr;)hs=++kr<=109?0:Math.ceil((kr-109)/127);var ha=[1,hs,kr,ar,Ya,At,pt,0];return dt.FileIndex[0].size=pt<<6,ha[7]=(dt.FileIndex[0].start=ha[0]+ha[1]+ha[2]+ha[3]+ha[4]+ha[5])+(ha[6]+7>>3),ha})(V),xe=bt(ie[7]<<9),_e=0,He=0;{for(_e=0;_e<8;++_e)xe.write_shift(1,ee[_e]);for(_e=0;_e<8;++_e)xe.write_shift(2,0);for(xe.write_shift(2,62),xe.write_shift(2,3),xe.write_shift(2,65534),xe.write_shift(2,9),xe.write_shift(2,6),_e=0;_e<3;++_e)xe.write_shift(2,0);for(xe.write_shift(4,0),xe.write_shift(4,ie[2]),xe.write_shift(4,ie[0]+ie[1]+ie[2]+ie[3]-1),xe.write_shift(4,0),xe.write_shift(4,4096),xe.write_shift(4,ie[3]?ie[0]+ie[1]+ie[2]-1:ce),xe.write_shift(4,ie[3]),xe.write_shift(-4,ie[1]?ie[0]-1:ce),xe.write_shift(4,ie[1]),_e=0;_e<109;++_e)xe.write_shift(-4,_e<ie[2]?ie[1]+_e:-1)}if(ie[1])for(He=0;He<ie[1];++He){for(;_e<236+He*127;++_e)xe.write_shift(-4,_e<ie[2]?ie[1]+_e:-1);xe.write_shift(-4,He===ie[1]-1?ce:He+1)}var Ue=function(dt){for(He+=dt;_e<He-1;++_e)xe.write_shift(-4,_e+1);dt&&(++_e,xe.write_shift(-4,ce))};for(He=_e=0,He+=ie[1];_e<He;++_e)xe.write_shift(-4,W.DIFSECT);for(He+=ie[2];_e<He;++_e)xe.write_shift(-4,W.FATSECT);Ue(ie[3]),Ue(ie[4]);for(var Pe=0,Re=0,We=V.FileIndex[0];Pe<V.FileIndex.length;++Pe)We=V.FileIndex[Pe],We.content&&(Re=We.content.length,!(Re<4096)&&(We.start=He,Ue(Re+511>>9)));for(Ue(ie[6]+7>>3);xe.l&511;)xe.write_shift(-4,W.ENDOFCHAIN);for(He=_e=0,Pe=0;Pe<V.FileIndex.length;++Pe)We=V.FileIndex[Pe],We.content&&(Re=We.content.length,!(!Re||Re>=4096)&&(We.start=He,Ue(Re+63>>6)));for(;xe.l&511;)xe.write_shift(-4,W.ENDOFCHAIN);for(_e=0;_e<ie[4]<<2;++_e){var _t=V.FullPaths[_e];if(!_t||_t.length===0){for(Pe=0;Pe<17;++Pe)xe.write_shift(4,0);for(Pe=0;Pe<3;++Pe)xe.write_shift(4,-1);for(Pe=0;Pe<12;++Pe)xe.write_shift(4,0);continue}We=V.FileIndex[_e],_e===0&&(We.start=We.size?We.start-1:ce);var Ft=_e===0&&de.root||We.name;if(Re=2*(Ft.length+1),xe.write_shift(64,Ft,"utf16le"),xe.write_shift(2,Re),xe.write_shift(1,We.type),xe.write_shift(1,We.color),xe.write_shift(-4,We.L),xe.write_shift(-4,We.R),xe.write_shift(-4,We.C),We.clsid)xe.write_shift(16,We.clsid,"hex");else for(Pe=0;Pe<4;++Pe)xe.write_shift(4,0);xe.write_shift(4,We.state||0),xe.write_shift(4,0),xe.write_shift(4,0),xe.write_shift(4,0),xe.write_shift(4,0),xe.write_shift(4,We.start),xe.write_shift(4,We.size),xe.write_shift(4,0)}for(_e=1;_e<V.FileIndex.length;++_e)if(We=V.FileIndex[_e],We.size>=4096)if(xe.l=We.start+1<<9,ir&&Buffer.isBuffer(We.content))We.content.copy(xe,xe.l,0,We.size),xe.l+=We.size+511&-512;else{for(Pe=0;Pe<We.size;++Pe)xe.write_shift(1,We.content[Pe]);for(;Pe&511;++Pe)xe.write_shift(1,0)}for(_e=1;_e<V.FileIndex.length;++_e)if(We=V.FileIndex[_e],We.size>0&&We.size<4096)if(ir&&Buffer.isBuffer(We.content))We.content.copy(xe,xe.l,0,We.size),xe.l+=We.size+63&-64;else{for(Pe=0;Pe<We.size;++Pe)xe.write_shift(1,We.content[Pe]);for(;Pe&63;++Pe)xe.write_shift(1,0)}if(ir)xe.l=xe.length;else for(;xe.l<xe.length;)xe.write_shift(1,0);return xe}function ye(V,me){var de=V.FullPaths.map(function(Pe){return Pe.toUpperCase()}),ie=de.map(function(Pe){var Re=Pe.split("/");return Re[Re.length-(Pe.slice(-1)=="/"?2:1)]}),xe=!1;me.charCodeAt(0)===47?(xe=!0,me=de[0].slice(0,-1)+me):xe=me.indexOf("/")!==-1;var _e=me.toUpperCase(),He=xe===!0?de.indexOf(_e):ie.indexOf(_e);if(He!==-1)return V.FileIndex[He];var Ue=!_e.match(zm);for(_e=_e.replace(ru,""),Ue&&(_e=_e.replace(zm,"!")),He=0;He<de.length;++He)if((Ue?de[He].replace(zm,"!"):de[He]).replace(ru,"")==_e||(Ue?ie[He].replace(zm,"!"):ie[He]).replace(ru,"")==_e)return V.FileIndex[He];return null}var he=64,ce=-2,se="d0cf11e0a1b11ae1",ee=[208,207,17,224,161,177,26,225],te="00000000000000000000000000000000",W={MAXREGSECT:-6,DIFSECT:-4,FATSECT:-3,ENDOFCHAIN:ce,FREESECT:-1,HEADER_SIGNATURE:se,HEADER_MINOR_VERSION:"3e00",MAXREGSID:-6,NOSTREAM:-1,HEADER_CLSID:te,EntryTypes:["unknown","storage","stream","lockbytes","property","root"]};function I(V,me,de){g();var ie=ne(V,de);h.writeFileSync(me,ie)}function oe(V){for(var me=new Array(V.length),de=0;de<V.length;++de)me[de]=String.fromCharCode(V[de]);return me.join("")}function ae(V,me){var de=ne(V,me);switch(me&&me.type||"buffer"){case"file":return g(),h.writeFileSync(me.filename,de),de;case"binary":return typeof de=="string"?de:oe(de);case"base64":return fu(typeof de=="string"?de:oe(de));case"buffer":if(ir)return Buffer.isBuffer(de)?de:Qo(de);case"array":return typeof de=="string"?Mi(de):de}return de}var F;function M(V){try{var me=V.InflateRaw,de=new me;if(de._processChunk(new Uint8Array([3,0]),de._finishFlushFlag),de.bytesRead)F=V;else throw new Error("zlib does not expose bytesRead")}catch(ie){console.error("cannot use native zlib: "+(ie.message||ie))}}function B(V,me){if(!F)return et(V,me);var de=F.InflateRaw,ie=new de,xe=ie._processChunk(V.slice(V.l),ie._finishFlushFlag);return V.l+=ie.bytesRead,xe}function X(V){return F?F.deflateRawSync(V):Ze(V)}var K=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],we=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],be=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577];function ke(V){var me=(V<<1|V<<11)&139536|(V<<5|V<<15)&558144;return(me>>16|me>>8|me)&255}for(var Me=typeof Uint8Array!="undefined",z=Me?new Uint8Array(256):[],Ne=0;Ne<256;++Ne)z[Ne]=ke(Ne);function Xe(V,me){var de=z[V&255];return me<=8?de>>>8-me:(de=de<<8|z[V>>8&255],me<=16?de>>>16-me:(de=de<<8|z[V>>16&255],de>>>24-me))}function gt(V,me){var de=me&7,ie=me>>>3;return(V[ie]|(de<=6?0:V[ie+1]<<8))>>>de&3}function St(V,me){var de=me&7,ie=me>>>3;return(V[ie]|(de<=5?0:V[ie+1]<<8))>>>de&7}function Ht(V,me){var de=me&7,ie=me>>>3;return(V[ie]|(de<=4?0:V[ie+1]<<8))>>>de&15}function Mt(V,me){var de=me&7,ie=me>>>3;return(V[ie]|(de<=3?0:V[ie+1]<<8))>>>de&31}function Te(V,me){var de=me&7,ie=me>>>3;return(V[ie]|(de<=1?0:V[ie+1]<<8))>>>de&127}function Qt(V,me,de){var ie=me&7,xe=me>>>3,_e=(1<<de)-1,He=V[xe]>>>ie;return de<8-ie||(He|=V[xe+1]<<8-ie,de<16-ie)||(He|=V[xe+2]<<16-ie,de<24-ie)||(He|=V[xe+3]<<24-ie),He&_e}function zt(V,me,de){var ie=me&7,xe=me>>>3;return ie<=5?V[xe]|=(de&7)<<ie:(V[xe]|=de<<ie&255,V[xe+1]=(de&7)>>8-ie),me+3}function Wt(V,me,de){var ie=me&7,xe=me>>>3;return de=(de&1)<<ie,V[xe]|=de,me+1}function Vt(V,me,de){var ie=me&7,xe=me>>>3;return de<<=ie,V[xe]|=de&255,de>>>=8,V[xe+1]=de,me+8}function va(V,me,de){var ie=me&7,xe=me>>>3;return de<<=ie,V[xe]|=de&255,de>>>=8,V[xe+1]=de&255,V[xe+2]=de>>>8,me+16}function ta(V,me){var de=V.length,ie=2*de>me?2*de:me+5,xe=0;if(de>=me)return V;if(ir){var _e=S1(ie);if(V.copy)V.copy(_e);else for(;xe<V.length;++xe)_e[xe]=V[xe];return _e}else if(Me){var He=new Uint8Array(ie);if(He.set)He.set(V);else for(;xe<de;++xe)He[xe]=V[xe];return He}return V.length=ie,V}function sa(V){for(var me=new Array(V),de=0;de<V;++de)me[de]=0;return me}function ra(V,me,de){var ie=1,xe=0,_e=0,He=0,Ue=0,Pe=V.length,Re=Me?new Uint16Array(32):sa(32);for(_e=0;_e<32;++_e)Re[_e]=0;for(_e=Pe;_e<de;++_e)V[_e]=0;Pe=V.length;var We=Me?new Uint16Array(Pe):sa(Pe);for(_e=0;_e<Pe;++_e)Re[xe=V[_e]]++,ie<xe&&(ie=xe),We[_e]=0;for(Re[0]=0,_e=1;_e<=ie;++_e)Re[_e+16]=Ue=Ue+Re[_e-1]<<1;for(_e=0;_e<Pe;++_e)Ue=V[_e],Ue!=0&&(We[_e]=Re[Ue+16]++);var _t=0;for(_e=0;_e<Pe;++_e)if(_t=V[_e],_t!=0)for(Ue=Xe(We[_e],ie)>>ie-_t,He=(1<<ie+4-_t)-1;He>=0;--He)me[Ue|He<<_t]=_t&15|_e<<4;return ie}var Ye=Me?new Uint16Array(512):sa(512),ft=Me?new Uint16Array(32):sa(32);if(!Me){for(var $t=0;$t<512;++$t)Ye[$t]=0;for($t=0;$t<32;++$t)ft[$t]=0}(function(){for(var V=[],me=0;me<32;me++)V.push(5);ra(V,ft,32);var de=[];for(me=0;me<=143;me++)de.push(8);for(;me<=255;me++)de.push(9);for(;me<=279;me++)de.push(7);for(;me<=287;me++)de.push(8);ra(de,Ye,288)})();var na=(function(){for(var me=Me?new Uint8Array(32768):[],de=0,ie=0;de<be.length-1;++de)for(;ie<be[de+1];++ie)me[ie]=de;for(;ie<32768;++ie)me[ie]=29;var xe=Me?new Uint8Array(259):[];for(de=0,ie=0;de<we.length-1;++de)for(;ie<we[de+1];++ie)xe[ie]=de;function _e(Ue,Pe){for(var Re=0;Re<Ue.length;){var We=Math.min(65535,Ue.length-Re),_t=Re+We==Ue.length;for(Pe.write_shift(1,+_t),Pe.write_shift(2,We),Pe.write_shift(2,~We&65535);We-- >0;)Pe[Pe.l++]=Ue[Re++]}return Pe.l}function He(Ue,Pe){for(var Re=0,We=0,_t=Me?new Uint16Array(32768):[];We<Ue.length;){var Ft=Math.min(65535,Ue.length-We);if(Ft<10){for(Re=zt(Pe,Re,+(We+Ft==Ue.length)),Re&7&&(Re+=8-(Re&7)),Pe.l=Re/8|0,Pe.write_shift(2,Ft),Pe.write_shift(2,~Ft&65535);Ft-- >0;)Pe[Pe.l++]=Ue[We++];Re=Pe.l*8;continue}Re=zt(Pe,Re,+(We+Ft==Ue.length)+2);for(var dt=0;Ft-- >0;){var pt=Ue[We];dt=(dt<<5^pt)&32767;var At=-1,Zt=0;if((At=_t[dt])&&(At|=We&-32768,At>We&&(At-=32768),At<We))for(;Ue[At+Zt]==Ue[We+Zt]&&Zt<250;)++Zt;if(Zt>2){pt=xe[Zt],pt<=22?Re=Vt(Pe,Re,z[pt+1]>>1)-1:(Vt(Pe,Re,3),Re+=5,Vt(Pe,Re,z[pt-23]>>5),Re+=3);var Fa=pt<8?0:pt-4>>2;Fa>0&&(va(Pe,Re,Zt-we[pt]),Re+=Fa),pt=me[We-At],Re=Vt(Pe,Re,z[pt]>>3),Re-=3;var La=pt<4?0:pt-2>>1;La>0&&(va(Pe,Re,We-At-be[pt]),Re+=La);for(var Ya=0;Ya<Zt;++Ya)_t[dt]=We&32767,dt=(dt<<5^Ue[We])&32767,++We;Ft-=Zt-1}else pt<=143?pt=pt+48:Re=Wt(Pe,Re,1),Re=Vt(Pe,Re,z[pt]),_t[dt]=We&32767,++We}Re=Vt(Pe,Re,0)-1}return Pe.l=(Re+7)/8|0,Pe.l}return function(Pe,Re){return Pe.length<8?_e(Pe,Re):He(Pe,Re)}})();function Ze(V){var me=bt(50+Math.floor(V.length*1.1)),de=na(V,me);return me.slice(0,de)}var lt=Me?new Uint16Array(32768):sa(32768),aa=Me?new Uint16Array(32768):sa(32768),Ie=Me?new Uint16Array(128):sa(128),Nt=1,ve=1;function Oe(V,me){var de=Mt(V,me)+257;me+=5;var ie=Mt(V,me)+1;me+=5;var xe=Ht(V,me)+4;me+=4;for(var _e=0,He=Me?new Uint8Array(19):sa(19),Ue=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Pe=1,Re=Me?new Uint8Array(8):sa(8),We=Me?new Uint8Array(8):sa(8),_t=He.length,Ft=0;Ft<xe;++Ft)He[K[Ft]]=_e=St(V,me),Pe<_e&&(Pe=_e),Re[_e]++,me+=3;var dt=0;for(Re[0]=0,Ft=1;Ft<=Pe;++Ft)We[Ft]=dt=dt+Re[Ft-1]<<1;for(Ft=0;Ft<_t;++Ft)(dt=He[Ft])!=0&&(Ue[Ft]=We[dt]++);var pt=0;for(Ft=0;Ft<_t;++Ft)if(pt=He[Ft],pt!=0){dt=z[Ue[Ft]]>>8-pt;for(var At=(1<<7-pt)-1;At>=0;--At)Ie[dt|At<<pt]=pt&7|Ft<<3}var Zt=[];for(Pe=1;Zt.length<de+ie;)switch(dt=Ie[Te(V,me)],me+=dt&7,dt>>>=3){case 16:for(_e=3+gt(V,me),me+=2,dt=Zt[Zt.length-1];_e-- >0;)Zt.push(dt);break;case 17:for(_e=3+St(V,me),me+=3;_e-- >0;)Zt.push(0);break;case 18:for(_e=11+Te(V,me),me+=7;_e-- >0;)Zt.push(0);break;default:Zt.push(dt),Pe<dt&&(Pe=dt);break}var Fa=Zt.slice(0,de),La=Zt.slice(de);for(Ft=de;Ft<286;++Ft)Fa[Ft]=0;for(Ft=ie;Ft<30;++Ft)La[Ft]=0;return Nt=ra(Fa,lt,286),ve=ra(La,aa,30),me}function ht(V,me){if(V[0]==3&&!(V[1]&3))return[kc(me),2];for(var de=0,ie=0,xe=S1(me||1<<18),_e=0,He=xe.length>>>0,Ue=0,Pe=0;(ie&1)==0;){if(ie=St(V,de),de+=3,ie>>>1)ie>>1==1?(Ue=9,Pe=5):(de=Oe(V,de),Ue=Nt,Pe=ve);else{de&7&&(de+=8-(de&7));var Re=V[de>>>3]|V[(de>>>3)+1]<<8;if(de+=32,Re>0)for(!me&&He<_e+Re&&(xe=ta(xe,_e+Re),He=xe.length);Re-- >0;)xe[_e++]=V[de>>>3],de+=8;continue}for(;;){!me&&He<_e+32767&&(xe=ta(xe,_e+32767),He=xe.length);var We=Qt(V,de,Ue),_t=ie>>>1==1?Ye[We]:lt[We];if(de+=_t&15,_t>>>=4,(_t>>>8&255)===0)xe[_e++]=_t;else{if(_t==256)break;_t-=257;var Ft=_t<8?0:_t-4>>2;Ft>5&&(Ft=0);var dt=_e+we[_t];Ft>0&&(dt+=Qt(V,de,Ft),de+=Ft),We=Qt(V,de,Pe),_t=ie>>>1==1?ft[We]:aa[We],de+=_t&15,_t>>>=4;var pt=_t<4?0:_t-2>>1,At=be[_t];for(pt>0&&(At+=Qt(V,de,pt),de+=pt),!me&&He<dt&&(xe=ta(xe,dt+100),He=xe.length);_e<dt;)xe[_e]=xe[_e-At],++_e}}}return me?[xe,de+7>>>3]:[xe.slice(0,_e),de+7>>>3]}function et(V,me){var de=V.slice(V.l||0),ie=ht(de,me);return V.l+=ie[1],ie[0]}function Be(V,me){if(V)typeof console!="undefined"&&console.error(me);else throw new Error(me)}function kt(V,me){var de=V;Qn(de,0);var ie=[],xe=[],_e={FileIndex:ie,FullPaths:xe};P(_e,{root:me.root});for(var He=de.length-4;(de[He]!=80||de[He+1]!=75||de[He+2]!=5||de[He+3]!=6)&&He>=0;)--He;de.l=He+4,de.l+=4;var Ue=de.read_shift(2);de.l+=6;var Pe=de.read_shift(4);for(de.l=Pe,He=0;He<Ue;++He){de.l+=20;var Re=de.read_shift(4),We=de.read_shift(4),_t=de.read_shift(2),Ft=de.read_shift(2),dt=de.read_shift(2);de.l+=8;var pt=de.read_shift(4),At=m(de.slice(de.l+_t,de.l+_t+Ft));de.l+=_t+Ft+dt;var Zt=de.l;de.l=pt+4,it(de,Re,We,_e,At),de.l=Zt}return _e}function it(V,me,de,ie,xe){V.l+=2;var _e=V.read_shift(2),He=V.read_shift(2),Ue=d(V);if(_e&8257)throw new Error("Unsupported ZIP encryption");for(var Pe=V.read_shift(4),Re=V.read_shift(4),We=V.read_shift(4),_t=V.read_shift(2),Ft=V.read_shift(2),dt="",pt=0;pt<_t;++pt)dt+=String.fromCharCode(V[V.l++]);if(Ft){var At=m(V.slice(V.l,V.l+Ft));(At[21589]||{}).mt&&(Ue=At[21589].mt),((xe||{})[21589]||{}).mt&&(Ue=xe[21589].mt)}V.l+=Ft;var Zt=V.slice(V.l,V.l+Re);switch(He){case 8:Zt=B(V,We);break;case 0:break;default:throw new Error("Unsupported ZIP Compression method "+He)}var Fa=!1;_e&8&&(Pe=V.read_shift(4),Pe==134695760&&(Pe=V.read_shift(4),Fa=!0),Re=V.read_shift(4),We=V.read_shift(4)),Re!=me&&Be(Fa,"Bad compressed size: "+me+" != "+Re),We!=de&&Be(Fa,"Bad uncompressed size: "+de+" != "+We),ct(ie,dt,Zt,{unsafe:!0,mt:Ue})}function xt(V,me){var de=me||{},ie=[],xe=[],_e=bt(1),He=de.compression?8:0,Ue=0,Pe=0,Re=0,We=0,_t=0,Ft=V.FullPaths[0],dt=Ft,pt=V.FileIndex[0],At=[],Zt=0;for(Pe=1;Pe<V.FullPaths.length;++Pe)if(dt=V.FullPaths[Pe].slice(Ft.length),pt=V.FileIndex[Pe],!(!pt.size||!pt.content||dt=="Sh33tJ5")){var Fa=We,La=bt(dt.length);for(Re=0;Re<dt.length;++Re)La.write_shift(1,dt.charCodeAt(Re)&127);La=La.slice(0,La.l),At[_t]=D6.buf(pt.content,0);var Ya=pt.content;He==8&&(Ya=X(Ya)),_e=bt(30),_e.write_shift(4,67324752),_e.write_shift(2,20),_e.write_shift(2,Ue),_e.write_shift(2,He),pt.mt?c(_e,pt.mt):_e.write_shift(4,0),_e.write_shift(-4,At[_t]),_e.write_shift(4,Ya.length),_e.write_shift(4,pt.content.length),_e.write_shift(2,La.length),_e.write_shift(2,0),We+=_e.length,ie.push(_e),We+=La.length,ie.push(La),We+=Ya.length,ie.push(Ya),_e=bt(46),_e.write_shift(4,33639248),_e.write_shift(2,0),_e.write_shift(2,20),_e.write_shift(2,Ue),_e.write_shift(2,He),_e.write_shift(4,0),_e.write_shift(-4,At[_t]),_e.write_shift(4,Ya.length),_e.write_shift(4,pt.content.length),_e.write_shift(2,La.length),_e.write_shift(2,0),_e.write_shift(2,0),_e.write_shift(2,0),_e.write_shift(2,0),_e.write_shift(4,0),_e.write_shift(4,Fa),Zt+=_e.l,xe.push(_e),Zt+=La.length,xe.push(La),++_t}return _e=bt(22),_e.write_shift(4,101010256),_e.write_shift(2,0),_e.write_shift(2,0),_e.write_shift(2,_t),_e.write_shift(2,_t),_e.write_shift(4,Zt),_e.write_shift(4,We),_e.write_shift(2,0),qs([qs(ie),qs(xe),_e])}var Dt={htm:"text/html",xml:"text/xml",gif:"image/gif",jpg:"image/jpeg",png:"image/png",mso:"application/x-mso",thmx:"application/vnd.ms-officetheme",sh33tj5:"application/octet-stream"};function Ot(V,me){if(V.ctype)return V.ctype;var de=V.name||"",ie=de.match(/\.([^\.]+)$/);return ie&&Dt[ie[1]]||me&&(ie=(de=me).match(/[\.\\]([^\.\\])+$/),ie&&Dt[ie[1]])?Dt[ie[1]]:"application/octet-stream"}function Rt(V){for(var me=fu(V),de=[],ie=0;ie<me.length;ie+=76)de.push(me.slice(ie,ie+76));return de.join(`\r
`)+`\r
`}function De(V){var me=V.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7E-\xFF=]/g,function(Re){var We=Re.charCodeAt(0).toString(16).toUpperCase();return"="+(We.length==1?"0"+We:We)});me=me.replace(/ $/mg,"=20").replace(/\t$/mg,"=09"),me.charAt(0)==`
`&&(me="=0D"+me.slice(1)),me=me.replace(/\r(?!\n)/mg,"=0D").replace(/\n\n/mg,`
=0A`).replace(/([^\r\n])\n/mg,"$1=0A");for(var de=[],ie=me.split(`\r
`),xe=0;xe<ie.length;++xe){var _e=ie[xe];if(_e.length==0){de.push("");continue}for(var He=0;He<_e.length;){var Ue=76,Pe=_e.slice(He,He+Ue);Pe.charAt(Ue-1)=="="?Ue--:Pe.charAt(Ue-2)=="="?Ue-=2:Pe.charAt(Ue-3)=="="&&(Ue-=3),Pe=_e.slice(He,He+Ue),He+=Ue,He<_e.length&&(Pe+="="),de.push(Pe)}}return de.join(`\r
`)}function Qe(V){for(var me=[],de=0;de<V.length;++de){for(var ie=V[de];de<=V.length&&ie.charAt(ie.length-1)=="=";)ie=ie.slice(0,ie.length-1)+V[++de];me.push(ie)}for(var xe=0;xe<me.length;++xe)me[xe]=me[xe].replace(/[=][0-9A-Fa-f]{2}/g,function(_e){return String.fromCharCode(parseInt(_e.slice(1),16))});return Mi(me.join(`\r
`))}function fe(V,me,de){for(var ie="",xe="",_e="",He,Ue=0;Ue<10;++Ue){var Pe=me[Ue];if(!Pe||Pe.match(/^\s*$/))break;var Re=Pe.match(/^(.*?):\s*([^\s].*)$/);if(Re)switch(Re[1].toLowerCase()){case"content-location":ie=Re[2].trim();break;case"content-type":_e=Re[2].trim();break;case"content-transfer-encoding":xe=Re[2].trim();break}}switch(++Ue,xe.toLowerCase()){case"base64":He=Mi(Jo(me.slice(Ue).join("")));break;case"quoted-printable":He=Qe(me.slice(Ue));break;default:throw new Error("Unsupported Content-Transfer-Encoding "+xe)}var We=ct(V,ie.slice(de.length),He,{unsafe:!0});_e&&(We.ctype=_e)}function re(V,me){if(oe(V.slice(0,13)).toLowerCase()!="mime-version:")throw new Error("Unsupported MAD header");var de=me&&me.root||"",ie=(ir&&Buffer.isBuffer(V)?V.toString("binary"):oe(V)).split(`\r
`),xe=0,_e="";for(xe=0;xe<ie.length;++xe)if(_e=ie[xe],!!/^Content-Location:/i.test(_e)&&(_e=_e.slice(_e.indexOf("file")),de||(de=_e.slice(0,_e.lastIndexOf("/")+1)),_e.slice(0,de.length)!=de))for(;de.length>0&&(de=de.slice(0,de.length-1),de=de.slice(0,de.lastIndexOf("/")+1),_e.slice(0,de.length)!=de););var He=(ie[1]||"").match(/boundary="(.*?)"/);if(!He)throw new Error("MAD cannot find boundary");var Ue="--"+(He[1]||""),Pe=[],Re=[],We={FileIndex:Pe,FullPaths:Re};P(We);var _t,Ft=0;for(xe=0;xe<ie.length;++xe){var dt=ie[xe];dt!==Ue&&dt!==Ue+"--"||(Ft++&&fe(We,ie.slice(_t,xe),de),_t=xe)}return We}function Ee(V,me){var de=me||{},ie=de.boundary||"SheetJS";ie="------="+ie;for(var xe=["MIME-Version: 1.0",'Content-Type: multipart/related; boundary="'+ie.slice(2)+'"',"","",""],_e=V.FullPaths[0],He=_e,Ue=V.FileIndex[0],Pe=1;Pe<V.FullPaths.length;++Pe)if(He=V.FullPaths[Pe].slice(_e.length),Ue=V.FileIndex[Pe],!(!Ue.size||!Ue.content||He=="Sh33tJ5")){He=He.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7E-\xFF]/g,function(Zt){return"_x"+Zt.charCodeAt(0).toString(16)+"_"}).replace(/[\u0080-\uFFFF]/g,function(Zt){return"_u"+Zt.charCodeAt(0).toString(16)+"_"});for(var Re=Ue.content,We=ir&&Buffer.isBuffer(Re)?Re.toString("binary"):oe(Re),_t=0,Ft=Math.min(1024,We.length),dt=0,pt=0;pt<=Ft;++pt)(dt=We.charCodeAt(pt))>=32&&dt<128&&++_t;var At=_t>=Ft*4/5;xe.push(ie),xe.push("Content-Location: "+(de.root||"file:///C:/SheetJS/")+He),xe.push("Content-Transfer-Encoding: "+(At?"quoted-printable":"base64")),xe.push("Content-Type: "+Ot(Ue,He)),xe.push(""),xe.push(At?De(We):Rt(We))}return xe.push(ie+`--\r
`),xe.join(`\r
`)}function Ge(V){var me={};return P(me,V),me}function ct(V,me,de,ie){var xe=ie&&ie.unsafe;xe||P(V);var _e=!xe&&vr.find(V,me);if(!_e){var He=V.FullPaths[0];me.slice(0,He.length)==He?He=me:(He.slice(-1)!="/"&&(He+="/"),He=(He+me).replace("//","/")),_e={name:i(me),type:2},V.FileIndex.push(_e),V.FullPaths.push(He),xe||vr.utils.cfb_gc(V)}return _e.content=de,_e.size=de?de.length:0,ie&&(ie.CLSID&&(_e.clsid=ie.CLSID),ie.mt&&(_e.mt=ie.mt),ie.ct&&(_e.ct=ie.ct)),_e}function It(V,me){P(V);var de=vr.find(V,me);if(de){for(var ie=0;ie<V.FileIndex.length;++ie)if(V.FileIndex[ie]==de)return V.FileIndex.splice(ie,1),V.FullPaths.splice(ie,1),!0}return!1}function st(V,me,de){P(V);var ie=vr.find(V,me);if(ie){for(var xe=0;xe<V.FileIndex.length;++xe)if(V.FileIndex[xe]==ie)return V.FileIndex[xe].name=i(de),V.FullPaths[xe]=de,!0}return!1}function rt(V){J(V,!0)}return a.find=ye,a.read=Y,a.parse=p,a.write=ae,a.writeFile=I,a.utils={cfb_new:Ge,cfb_add:ct,cfb_del:It,cfb_mov:st,cfb_gc:rt,ReadShift:nu,CheckField:cw,prep_blob:Qn,bconcat:qs,use_zlib:M,_deflateRaw:Ze,_inflateRaw:et,consts:W},a})();function M6(t){return typeof t=="string"?Fh(t):Array.isArray(t)?n6(t):t}function Cu(t,a,r){if(typeof Deno!="undefined"){if(r&&typeof a=="string")switch(r){case"utf8":a=new TextEncoder(r).encode(a);break;case"binary":a=Fh(a);break;default:throw new Error("Unsupported encoding "+r)}return Deno.writeFileSync(t,a)}var s=r=="utf8"?pu(a):a;if(typeof IE_SaveFile!="undefined")return IE_SaveFile(s,t);if(typeof Blob!="undefined"){var i=new Blob([M6(s)],{type:"application/octet-stream"});if(typeof navigator!="undefined"&&navigator.msSaveBlob)return navigator.msSaveBlob(i,t);if(typeof saveAs!="undefined")return saveAs(i,t);if(typeof URL!="undefined"&&typeof document!="undefined"&&document.createElement&&URL.createObjectURL){var c=URL.createObjectURL(i);if(typeof chrome=="object"&&typeof(chrome.downloads||{}).download=="function")return URL.revokeObjectURL&&typeof setTimeout!="undefined"&&setTimeout(function(){URL.revokeObjectURL(c)},6e4),chrome.downloads.download({url:c,filename:t,saveAs:!0});var d=document.createElement("a");if(d.download!=null)return d.download=t,d.href=c,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL&&typeof setTimeout!="undefined"&&setTimeout(function(){URL.revokeObjectURL(c)},6e4),c}}if(typeof $!="undefined"&&typeof File!="undefined"&&typeof Folder!="undefined")try{var m=File(t);return m.open("w"),m.encoding="binary",Array.isArray(a)&&(a=Su(a)),m.write(a),m.close(),a}catch(h){if(!h.message||!h.message.match(/onstruct/))throw h}throw new Error("cannot save file "+t)}function Xs(t){for(var a=Object.keys(t),r=[],s=0;s<a.length;++s)Object.prototype.hasOwnProperty.call(t,a[s])&&r.push(a[s]);return r}function L1(t,a){for(var r=[],s=Xs(t),i=0;i!==s.length;++i)r[t[s[i]][a]]==null&&(r[t[s[i]][a]]=s[i]);return r}function tp(t){for(var a=[],r=Xs(t),s=0;s!==r.length;++s)a[t[r[s]]]=r[s];return a}function Bh(t){for(var a=[],r=Xs(t),s=0;s!==r.length;++s)a[t[r[s]]]=parseInt(r[s],10);return a}function L6(t){for(var a=[],r=Xs(t),s=0;s!==r.length;++s)a[t[r[s]]]==null&&(a[t[r[s]]]=[]),a[t[r[s]]].push(r[s]);return a}var vh=new Date(1899,11,30,0,0,0);function Fn(t,a){var r=t.getTime(),s=vh.getTime()+(t.getTimezoneOffset()-vh.getTimezoneOffset())*6e4;return(r-s)/(1440*60*1e3)}var q2=new Date,R6=vh.getTime()+(q2.getTimezoneOffset()-vh.getTimezoneOffset())*6e4,R1=q2.getTimezoneOffset();function G2(t){var a=new Date;return a.setTime(t*24*60*60*1e3+R6),a.getTimezoneOffset()!==R1&&a.setTime(a.getTime()+(a.getTimezoneOffset()-R1)*6e4),a}var P1=new Date("2017-02-19T19:06:09.000Z"),Y2=isNaN(P1.getFullYear())?new Date("2/19/17"):P1,P6=Y2.getFullYear()==2017;function bn(t,a){var r=new Date(t);if(P6)return a>0?r.setTime(r.getTime()+r.getTimezoneOffset()*60*1e3):a<0&&r.setTime(r.getTime()-r.getTimezoneOffset()*60*1e3),r;if(t instanceof Date)return t;if(Y2.getFullYear()==1917&&!isNaN(r.getFullYear())){var s=r.getFullYear();return t.indexOf(""+s)>-1||r.setFullYear(r.getFullYear()+100),r}var i=t.match(/\d+/g)||["2017","2","19","0","0","0"],c=new Date(+i[0],+i[1]-1,+i[2],+i[3]||0,+i[4]||0,+i[5]||0);return t.indexOf("Z")>-1&&(c=new Date(c.getTime()-c.getTimezoneOffset()*60*1e3)),c}function Uh(t,a){if(ir&&Buffer.isBuffer(t))return t.toString("binary");if(typeof TextDecoder!="undefined")try{var r={"€":"€","":"‚",ƒ:"ƒ","„":"„","…":"…","†":"†","‡":"‡","ˆ":"ˆ","‰":"‰",Š:"Š","":"‹",Œ:"Œ",Ž:"Ž","":"‘","":"’","“":"“","”":"”","•":"•","":"–","—":"—","˜":"˜","™":"™",š:"š","":"›",œ:"œ",ž:"ž",Ÿ:"Ÿ"};return Array.isArray(t)&&(t=new Uint8Array(t)),new TextDecoder("latin1").decode(t).replace(/[€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ]/g,function(c){return r[c]||c})}catch(c){}for(var s=[],i=0;i!=t.length;++i)s.push(String.fromCharCode(t[i]));return s.join("")}function In(t){if(typeof JSON!="undefined"&&!Array.isArray(t))return JSON.parse(JSON.stringify(t));if(typeof t!="object"||t==null)return t;if(t instanceof Date)return new Date(t.getTime());var a={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(a[r]=In(t[r]));return a}function Wr(t,a){for(var r="";r.length<a;)r+=t;return r}function Go(t){var a=Number(t);if(!isNaN(a))return isFinite(a)?a:NaN;if(!/\d/.test(t))return a;var r=1,s=t.replace(/([\d]),([\d])/g,"$1$2").replace(/[$]/g,"").replace(/[%]/g,function(){return r*=100,""});return!isNaN(a=Number(s))||(s=s.replace(/[(](.*)[)]/,function(i,c){return r=-r,c}),!isNaN(a=Number(s)))?a/r:a}var F6=["january","february","march","april","may","june","july","august","september","october","november","december"];function xu(t){var a=new Date(t),r=new Date(NaN),s=a.getYear(),i=a.getMonth(),c=a.getDate();if(isNaN(c))return r;var d=t.toLowerCase();if(d.match(/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/)){if(d=d.replace(/[^a-z]/g,"").replace(/([^a-z]|^)[ap]m?([^a-z]|$)/,""),d.length>3&&F6.indexOf(d)==-1)return r}else if(d.match(/[a-z]/))return r;return s<0||s>8099?r:(i>0||c>1)&&s!=101?a:t.match(/[^-0-9:,\/\\]/)?r:a}function Ma(t,a,r){if(t.FullPaths){if(typeof r=="string"){var s;return ir?s=Qo(r):s=i6(r),vr.utils.cfb_add(t,a,s)}vr.utils.cfb_add(t,a,r)}else t.file(a,r)}function ap(){return vr.utils.cfb_new()}var us=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
`,I6={"&quot;":'"',"&apos;":"'","&gt;":">","&lt;":"<","&amp;":"&"},rp=tp(I6),sp=/[&<>'"]/g,z6=/[\u0000-\u0008\u000b-\u001f]/g;function mr(t){var a=t+"";return a.replace(sp,function(r){return rp[r]}).replace(z6,function(r){return"_x"+("000"+r.charCodeAt(0).toString(16)).slice(-4)+"_"})}function F1(t){return mr(t).replace(/ /g,"_x0020_")}var Z2=/[\u0000-\u001f]/g;function B6(t){var a=t+"";return a.replace(sp,function(r){return rp[r]}).replace(/\n/g,"<br/>").replace(Z2,function(r){return"&#x"+("000"+r.charCodeAt(0).toString(16)).slice(-4)+";"})}function U6(t){var a=t+"";return a.replace(sp,function(r){return rp[r]}).replace(Z2,function(r){return"&#x"+r.charCodeAt(0).toString(16).toUpperCase()+";"})}function $6(t){return t.replace(/(\r\n|[\r\n])/g,"&#10;")}function H6(t){switch(t){case 1:case!0:case"1":case"true":case"TRUE":return!0;default:return!1}}function rx(t){for(var a="",r=0,s=0,i=0,c=0,d=0,m=0;r<t.length;){if(s=t.charCodeAt(r++),s<128){a+=String.fromCharCode(s);continue}if(i=t.charCodeAt(r++),s>191&&s<224){d=(s&31)<<6,d|=i&63,a+=String.fromCharCode(d);continue}if(c=t.charCodeAt(r++),s<240){a+=String.fromCharCode((s&15)<<12|(i&63)<<6|c&63);continue}d=t.charCodeAt(r++),m=((s&7)<<18|(i&63)<<12|(c&63)<<6|d&63)-65536,a+=String.fromCharCode(55296+(m>>>10&1023)),a+=String.fromCharCode(56320+(m&1023))}return a}function I1(t){var a=kc(2*t.length),r,s,i=1,c=0,d=0,m;for(s=0;s<t.length;s+=i)i=1,(m=t.charCodeAt(s))<128?r=m:m<224?(r=(m&31)*64+(t.charCodeAt(s+1)&63),i=2):m<240?(r=(m&15)*4096+(t.charCodeAt(s+1)&63)*64+(t.charCodeAt(s+2)&63),i=3):(i=4,r=(m&7)*262144+(t.charCodeAt(s+1)&63)*4096+(t.charCodeAt(s+2)&63)*64+(t.charCodeAt(s+3)&63),r-=65536,d=55296+(r>>>10&1023),r=56320+(r&1023)),d!==0&&(a[c++]=d&255,a[c++]=d>>>8,d=0),a[c++]=r%256,a[c++]=r>>>8;return a.slice(0,c).toString("ucs2")}function z1(t){return Qo(t,"binary").toString("utf8")}var Um="foo bar baz☃🍣",su=ir&&(z1(Um)==rx(Um)&&z1||I1(Um)==rx(Um)&&I1)||rx,pu=ir?function(t){return Qo(t,"utf8").toString("binary")}:function(t){for(var a=[],r=0,s=0,i=0;r<t.length;)switch(s=t.charCodeAt(r++),!0){case s<128:a.push(String.fromCharCode(s));break;case s<2048:a.push(String.fromCharCode(192+(s>>6))),a.push(String.fromCharCode(128+(s&63)));break;case(s>=55296&&s<57344):s-=55296,i=t.charCodeAt(r++)-56320+(s<<10),a.push(String.fromCharCode(240+(i>>18&7))),a.push(String.fromCharCode(144+(i>>12&63))),a.push(String.fromCharCode(128+(i>>6&63))),a.push(String.fromCharCode(128+(i&63)));break;default:a.push(String.fromCharCode(224+(s>>12))),a.push(String.fromCharCode(128+(s>>6&63))),a.push(String.fromCharCode(128+(s&63)))}return a.join("")},W6=(function(){var t=[["nbsp"," "],["middot","·"],["quot",'"'],["apos","'"],["gt",">"],["lt","<"],["amp","&"]].map(function(a){return[new RegExp("&"+a[0]+";","ig"),a[1]]});return function(r){for(var s=r.replace(/^[\t\n\r ]+/,"").replace(/[\t\n\r ]+$/,"").replace(/>\s+/g,">").replace(/\s+</g,"<").replace(/[\t\n\r ]+/g," ").replace(/<\s*[bB][rR]\s*\/?>/g,`
`).replace(/<[^>]*>/g,""),i=0;i<t.length;++i)s=s.replace(t[i][0],t[i][1]);return s}})(),J2=/(^\s|\s$|\n)/;function Gs(t,a){return"<"+t+(a.match(J2)?' xml:space="preserve"':"")+">"+a+"</"+t+">"}function yu(t){return Xs(t).map(function(a){return" "+a+'="'+t[a]+'"'}).join("")}function qt(t,a,r){return"<"+t+(r!=null?yu(r):"")+(a!=null?(a.match(J2)?' xml:space="preserve"':"")+">"+a+"</"+t:"/")+">"}function Ex(t,a){try{return t.toISOString().replace(/\.\d*/,"")}catch(r){if(a)throw r}return""}function V6(t,a){switch(typeof t){case"string":var r=qt("vt:lpwstr",mr(t));return r=r.replace(/&quot;/g,"_x0022_"),r;case"number":return qt((t|0)==t?"vt:i4":"vt:r8",mr(String(t)));case"boolean":return qt("vt:bool",t?"true":"false")}if(t instanceof Date)return qt("vt:filetime",Ex(t));throw new Error("Unable to serialize "+t)}var Ns={CORE_PROPS:"http://schemas.openxmlformats.org/package/2006/metadata/core-properties",CUST_PROPS:"http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",EXT_PROPS:"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",CT:"http://schemas.openxmlformats.org/package/2006/content-types",RELS:"http://schemas.openxmlformats.org/package/2006/relationships",TCMNT:"http://schemas.microsoft.com/office/spreadsheetml/2018/threadedcomments",dc:"http://purl.org/dc/elements/1.1/",dcterms:"http://purl.org/dc/terms/",dcmitype:"http://purl.org/dc/dcmitype/",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",vt:"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes",xsi:"http://www.w3.org/2001/XMLSchema-instance",xsd:"http://www.w3.org/2001/XMLSchema"},Vd=["http://schemas.openxmlformats.org/spreadsheetml/2006/main","http://purl.oclc.org/ooxml/spreadsheetml/main","http://schemas.microsoft.com/office/excel/2006/main","http://schemas.microsoft.com/office/excel/2006/2"],ti={o:"urn:schemas-microsoft-com:office:office",x:"urn:schemas-microsoft-com:office:excel",ss:"urn:schemas-microsoft-com:office:spreadsheet",dt:"uuid:C2F41010-65B3-11d1-A29F-00AA00C14882",mv:"http://macVmlSchemaUri",v:"urn:schemas-microsoft-com:vml",html:"http://www.w3.org/TR/REC-html40"};function q6(t,a){for(var r=1-2*(t[a+7]>>>7),s=((t[a+7]&127)<<4)+(t[a+6]>>>4&15),i=t[a+6]&15,c=5;c>=0;--c)i=i*256+t[a+c];return s==2047?i==0?r*(1/0):NaN:(s==0?s=-1022:(s-=1023,i+=Math.pow(2,52)),r*Math.pow(2,s-52)*i)}function G6(t,a,r){var s=(a<0||1/a==-1/0?1:0)<<7,i=0,c=0,d=s?-a:a;isFinite(d)?d==0?i=c=0:(i=Math.floor(Math.log(d)/Math.LN2),c=d*Math.pow(2,52-i),i<=-1023&&(!isFinite(c)||c<Math.pow(2,52))?i=-1022:(c-=Math.pow(2,52),i+=1023)):(i=2047,c=isNaN(a)?26985:0);for(var m=0;m<=5;++m,c/=256)t[r+m]=c&255;t[r+6]=(i&15)<<4|c&15,t[r+7]=i>>4|s}var B1=function(t){for(var a=[],r=10240,s=0;s<t[0].length;++s)if(t[0][s])for(var i=0,c=t[0][s].length;i<c;i+=r)a.push.apply(a,t[0][s].slice(i,i+r));return a},U1=ir?function(t){return t[0].length>0&&Buffer.isBuffer(t[0][0])?Buffer.concat(t[0].map(function(a){return Buffer.isBuffer(a)?a:Qo(a)})):B1(t)}:B1,$1=function(t,a,r){for(var s=[],i=a;i<r;i+=2)s.push(String.fromCharCode(K0(t,i)));return s.join("").replace(ru,"")},np=ir?function(t,a,r){return Buffer.isBuffer(t)?t.toString("utf16le",a,r).replace(ru,""):$1(t,a,r)}:$1,H1=function(t,a,r){for(var s=[],i=a;i<a+r;++i)s.push(("0"+t[i].toString(16)).slice(-2));return s.join("")},X2=ir?function(t,a,r){return Buffer.isBuffer(t)?t.toString("hex",a,a+r):H1(t,a,r)}:H1,W1=function(t,a,r){for(var s=[],i=a;i<r;i++)s.push(String.fromCharCode(Cd(t,i)));return s.join("")},Tu=ir?function(a,r,s){return Buffer.isBuffer(a)?a.toString("utf8",r,s):W1(a,r,s)}:W1,K2=function(t,a){var r=ai(t,a);return r>0?Tu(t,a+4,a+4+r-1):""},Q2=K2,ew=function(t,a){var r=ai(t,a);return r>0?Tu(t,a+4,a+4+r-1):""},tw=ew,aw=function(t,a){var r=2*ai(t,a);return r>0?Tu(t,a+4,a+4+r-1):""},rw=aw,sw=function(a,r){var s=ai(a,r);return s>0?np(a,r+4,r+4+s):""},nw=sw,iw=function(t,a){var r=ai(t,a);return r>0?Tu(t,a+4,a+4+r):""},ow=iw,lw=function(t,a){return q6(t,a)},_h=lw,ip=function(a){return Array.isArray(a)||typeof Uint8Array!="undefined"&&a instanceof Uint8Array};ir&&(Q2=function(a,r){if(!Buffer.isBuffer(a))return K2(a,r);var s=a.readUInt32LE(r);return s>0?a.toString("utf8",r+4,r+4+s-1):""},tw=function(a,r){if(!Buffer.isBuffer(a))return ew(a,r);var s=a.readUInt32LE(r);return s>0?a.toString("utf8",r+4,r+4+s-1):""},rw=function(a,r){if(!Buffer.isBuffer(a))return aw(a,r);var s=2*a.readUInt32LE(r);return a.toString("utf16le",r+4,r+4+s-1)},nw=function(a,r){if(!Buffer.isBuffer(a))return sw(a,r);var s=a.readUInt32LE(r);return a.toString("utf16le",r+4,r+4+s)},ow=function(a,r){if(!Buffer.isBuffer(a))return iw(a,r);var s=a.readUInt32LE(r);return a.toString("utf8",r+4,r+4+s)},_h=function(a,r){return Buffer.isBuffer(a)?a.readDoubleLE(r):lw(a,r)},ip=function(a){return Buffer.isBuffer(a)||Array.isArray(a)||typeof Uint8Array!="undefined"&&a instanceof Uint8Array});var Cd=function(t,a){return t[a]},K0=function(t,a){return t[a+1]*256+t[a]},Y6=function(t,a){var r=t[a+1]*256+t[a];return r<32768?r:(65535-r+1)*-1},ai=function(t,a){return t[a+3]*(1<<24)+(t[a+2]<<16)+(t[a+1]<<8)+t[a]},uc=function(t,a){return t[a+3]<<24|t[a+2]<<16|t[a+1]<<8|t[a]},Z6=function(t,a){return t[a]<<24|t[a+1]<<16|t[a+2]<<8|t[a+3]};function nu(t,a){var r="",s,i,c=[],d,m,h,g;switch(a){case"dbcs":if(g=this.l,ir&&Buffer.isBuffer(this))r=this.slice(this.l,this.l+2*t).toString("utf16le");else for(h=0;h<t;++h)r+=String.fromCharCode(K0(this,g)),g+=2;t*=2;break;case"utf8":r=Tu(this,this.l,this.l+t);break;case"utf16le":t*=2,r=np(this,this.l,this.l+t);break;case"wstr":return nu.call(this,t,"dbcs");case"lpstr-ansi":r=Q2(this,this.l),t=4+ai(this,this.l);break;case"lpstr-cp":r=tw(this,this.l),t=4+ai(this,this.l);break;case"lpwstr":r=rw(this,this.l),t=4+2*ai(this,this.l);break;case"lpp4":t=4+ai(this,this.l),r=nw(this,this.l),t&2&&(t+=2);break;case"8lpp4":t=4+ai(this,this.l),r=ow(this,this.l),t&3&&(t+=4-(t&3));break;case"cstr":for(t=0,r="";(d=Cd(this,this.l+t++))!==0;)c.push(Im(d));r=c.join("");break;case"_wstr":for(t=0,r="";(d=K0(this,this.l+t))!==0;)c.push(Im(d)),t+=2;t+=2,r=c.join("");break;case"dbcs-cont":for(r="",g=this.l,h=0;h<t;++h){if(this.lens&&this.lens.indexOf(g)!==-1)return d=Cd(this,g),this.l=g+1,m=nu.call(this,t-h,d?"dbcs-cont":"sbcs-cont"),c.join("")+m;c.push(Im(K0(this,g))),g+=2}r=c.join(""),t*=2;break;case"cpstr":case"sbcs-cont":for(r="",g=this.l,h=0;h!=t;++h){if(this.lens&&this.lens.indexOf(g)!==-1)return d=Cd(this,g),this.l=g+1,m=nu.call(this,t-h,d?"dbcs-cont":"sbcs-cont"),c.join("")+m;c.push(Im(Cd(this,g))),g+=1}r=c.join("");break;default:switch(t){case 1:return s=Cd(this,this.l),this.l++,s;case 2:return s=(a==="i"?Y6:K0)(this,this.l),this.l+=2,s;case 4:case-4:return a==="i"||(this[this.l+3]&128)===0?(s=(t>0?uc:Z6)(this,this.l),this.l+=4,s):(i=ai(this,this.l),this.l+=4,i);case 8:case-8:if(a==="f")return t==8?i=_h(this,this.l):i=_h([this[this.l+7],this[this.l+6],this[this.l+5],this[this.l+4],this[this.l+3],this[this.l+2],this[this.l+1],this[this.l+0]],0),this.l+=8,i;t=8;case 16:r=X2(this,this.l,t);break}}return this.l+=t,r}var J6=function(t,a,r){t[r]=a&255,t[r+1]=a>>>8&255,t[r+2]=a>>>16&255,t[r+3]=a>>>24&255},X6=function(t,a,r){t[r]=a&255,t[r+1]=a>>8&255,t[r+2]=a>>16&255,t[r+3]=a>>24&255},K6=function(t,a,r){t[r]=a&255,t[r+1]=a>>>8&255};function Q6(t,a,r){var s=0,i=0;if(r==="dbcs"){for(i=0;i!=a.length;++i)K6(this,a.charCodeAt(i),this.l+2*i);s=2*a.length}else if(r==="sbcs"){for(a=a.replace(/[^\x00-\x7F]/g,"_"),i=0;i!=a.length;++i)this[this.l+i]=a.charCodeAt(i)&255;s=a.length}else if(r==="hex"){for(;i<t;++i)this[this.l++]=parseInt(a.slice(2*i,2*i+2),16)||0;return this}else if(r==="utf16le"){var c=Math.min(this.l+t,this.length);for(i=0;i<Math.min(a.length,t);++i){var d=a.charCodeAt(i);this[this.l++]=d&255,this[this.l++]=d>>8}for(;this.l<c;)this[this.l++]=0;return this}else switch(t){case 1:s=1,this[this.l]=a&255;break;case 2:s=2,this[this.l]=a&255,a>>>=8,this[this.l+1]=a&255;break;case 3:s=3,this[this.l]=a&255,a>>>=8,this[this.l+1]=a&255,a>>>=8,this[this.l+2]=a&255;break;case 4:s=4,J6(this,a,this.l);break;case 8:if(s=8,r==="f"){G6(this,a,this.l);break}case 16:break;case-4:s=4,X6(this,a,this.l);break}return this.l+=s,this}function cw(t,a){var r=X2(this,this.l,t.length>>1);if(r!==t)throw new Error(a+"Expected "+t+" saw "+r);this.l+=t.length>>1}function Qn(t,a){t.l=a,t.read_shift=nu,t.chk=cw,t.write_shift=Q6}function fo(t,a){t.l+=a}function bt(t){var a=kc(t);return Qn(a,0),a}function Ln(){var t=[],a=ir?256:2048,r=function(g){var p=bt(g);return Qn(p,0),p},s=r(a),i=function(){s&&(s.length>s.l&&(s=s.slice(0,s.l),s.l=s.length),s.length>0&&t.push(s),s=null)},c=function(g){return s&&g<s.length-s.l?s:(i(),s=r(Math.max(g+1,a)))},d=function(){return i(),qs(t)},m=function(g){i(),s=g,s.l==null&&(s.l=s.length),c(a)};return{next:c,push:m,end:d,_bufs:t}}function Lt(t,a,r,s){var i=+a,c;if(!isNaN(i)){s||(s=qA[i].p||(r||[]).length||0),c=1+(i>=128?1:0)+1,s>=128&&++c,s>=16384&&++c,s>=2097152&&++c;var d=t.next(c);i<=127?d.write_shift(1,i):(d.write_shift(1,(i&127)+128),d.write_shift(1,i>>7));for(var m=0;m!=4;++m)if(s>=128)d.write_shift(1,(s&127)+128),s>>=7;else{d.write_shift(1,s);break}s>0&&ip(r)&&t.push(r)}}function iu(t,a,r){var s=In(t);if(a.s?(s.cRel&&(s.c+=a.s.c),s.rRel&&(s.r+=a.s.r)):(s.cRel&&(s.c+=a.c),s.rRel&&(s.r+=a.r)),!r||r.biff<12){for(;s.c>=256;)s.c-=256;for(;s.r>=65536;)s.r-=65536}return s}function V1(t,a,r){var s=In(t);return s.s=iu(s.s,a.s,r),s.e=iu(s.e,a.s,r),s}function ou(t,a){if(t.cRel&&t.c<0)for(t=In(t);t.c<0;)t.c+=a>8?16384:256;if(t.rRel&&t.r<0)for(t=In(t);t.r<0;)t.r+=a>8?1048576:a>5?65536:16384;var r=hr(t);return!t.cRel&&t.cRel!=null&&(r=aC(r)),!t.rRel&&t.rRel!=null&&(r=eC(r)),r}function sx(t,a){return t.s.r==0&&!t.s.rRel&&t.e.r==(a.biff>=12?1048575:a.biff>=8?65536:16384)&&!t.e.rRel?(t.s.cRel?"":"$")+on(t.s.c)+":"+(t.e.cRel?"":"$")+on(t.e.c):t.s.c==0&&!t.s.cRel&&t.e.c==(a.biff>=12?16383:255)&&!t.e.cRel?(t.s.rRel?"":"$")+Ys(t.s.r)+":"+(t.e.rRel?"":"$")+Ys(t.e.r):ou(t.s,a.biff)+":"+ou(t.e,a.biff)}function op(t){return parseInt(tC(t),10)-1}function Ys(t){return""+(t+1)}function eC(t){return t.replace(/([A-Z]|^)(\d+)$/,"$1$$$2")}function tC(t){return t.replace(/\$(\d+)$/,"$1")}function lp(t){for(var a=rC(t),r=0,s=0;s!==a.length;++s)r=26*r+a.charCodeAt(s)-64;return r-1}function on(t){if(t<0)throw new Error("invalid column "+t);var a="";for(++t;t;t=Math.floor((t-1)/26))a=String.fromCharCode((t-1)%26+65)+a;return a}function aC(t){return t.replace(/^([A-Z])/,"$$$1")}function rC(t){return t.replace(/^\$([A-Z])/,"$1")}function sC(t){return t.replace(/(\$?[A-Z]*)(\$?\d*)/,"$1,$2").split(",")}function Ss(t){for(var a=0,r=0,s=0;s<t.length;++s){var i=t.charCodeAt(s);i>=48&&i<=57?a=10*a+(i-48):i>=65&&i<=90&&(r=26*r+(i-64))}return{c:r-1,r:a-1}}function hr(t){for(var a=t.c+1,r="";a;a=(a-1)/26|0)r=String.fromCharCode((a-1)%26+65)+r;return r+(t.r+1)}function ni(t){var a=t.indexOf(":");return a==-1?{s:Ss(t),e:Ss(t)}:{s:Ss(t.slice(0,a)),e:Ss(t.slice(a+1))}}function ls(t,a){return typeof a=="undefined"||typeof a=="number"?ls(t.s,t.e):(typeof t!="string"&&(t=hr(t)),typeof a!="string"&&(a=hr(a)),t==a?t:t+":"+a)}function Dr(t){var a={s:{c:0,r:0},e:{c:0,r:0}},r=0,s=0,i=0,c=t.length;for(r=0;s<c&&!((i=t.charCodeAt(s)-64)<1||i>26);++s)r=26*r+i;for(a.s.c=--r,r=0;s<c&&!((i=t.charCodeAt(s)-48)<0||i>9);++s)r=10*r+i;if(a.s.r=--r,s===c||i!=10)return a.e.c=a.s.c,a.e.r=a.s.r,a;for(++s,r=0;s!=c&&!((i=t.charCodeAt(s)-64)<1||i>26);++s)r=26*r+i;for(a.e.c=--r,r=0;s!=c&&!((i=t.charCodeAt(s)-48)<0||i>9);++s)r=10*r+i;return a.e.r=--r,a}function q1(t,a){var r=t.t=="d"&&a instanceof Date;if(t.z!=null)try{return t.w=Al(t.z,r?Fn(a):a)}catch(s){}try{return t.w=Al((t.XF||{}).numFmtId||(r?14:0),r?Fn(a):a)}catch(s){return""+a}}function Xo(t,a,r){return t==null||t.t==null||t.t=="z"?"":t.w!==void 0?t.w:(t.t=="d"&&!t.z&&r&&r.dateNF&&(t.z=r.dateNF),t.t=="e"?Eu[t.v]||t.v:a==null?q1(t,t.v):q1(t,a))}function Ec(t,a){var r=a&&a.sheet?a.sheet:"Sheet1",s={};return s[r]=t,{SheetNames:[r],Sheets:s}}function dw(t,a,r){var s=r||{},i=t?Array.isArray(t):s.dense,c=t||(i?[]:{}),d=0,m=0;if(c&&s.origin!=null){if(typeof s.origin=="number")d=s.origin;else{var h=typeof s.origin=="string"?Ss(s.origin):s.origin;d=h.r,m=h.c}c["!ref"]||(c["!ref"]="A1:A1")}var g={s:{c:1e7,r:1e7},e:{c:0,r:0}};if(c["!ref"]){var p=Dr(c["!ref"]);g.s.c=p.s.c,g.s.r=p.s.r,g.e.c=Math.max(g.e.c,p.e.c),g.e.r=Math.max(g.e.r,p.e.r),d==-1&&(g.e.r=d=p.e.r+1)}for(var b=0;b!=a.length;++b)if(a[b]){if(!Array.isArray(a[b]))throw new Error("aoa_to_sheet expects an array of arrays");for(var j=0;j!=a[b].length;++j)if(typeof a[b][j]!="undefined"){var _={v:a[b][j]},N=d+b,k=m+j;if(g.s.r>N&&(g.s.r=N),g.s.c>k&&(g.s.c=k),g.e.r<N&&(g.e.r=N),g.e.c<k&&(g.e.c=k),a[b][j]&&typeof a[b][j]=="object"&&!Array.isArray(a[b][j])&&!(a[b][j]instanceof Date))_=a[b][j];else if(Array.isArray(_.v)&&(_.f=a[b][j][1],_.v=_.v[0]),_.v===null)if(_.f)_.t="n";else if(s.nullError)_.t="e",_.v=0;else if(s.sheetStubs)_.t="z";else continue;else typeof _.v=="number"?_.t="n":typeof _.v=="boolean"?_.t="b":_.v instanceof Date?(_.z=s.dateNF||Vr[14],s.cellDates?(_.t="d",_.w=Al(_.z,Fn(_.v))):(_.t="n",_.v=Fn(_.v),_.w=Al(_.z,_.v))):_.t="s";if(i)c[N]||(c[N]=[]),c[N][k]&&c[N][k].z&&(_.z=c[N][k].z),c[N][k]=_;else{var C=hr({c:k,r:N});c[C]&&c[C].z&&(_.z=c[C].z),c[C]=_}}}return g.s.c<1e7&&(c["!ref"]=ls(g)),c}function qd(t,a){return dw(null,t,a)}function nC(t){return t.read_shift(4,"i")}function Ri(t,a){return a||(a=bt(4)),a.write_shift(4,t),a}function ln(t){var a=t.read_shift(4);return a===0?"":t.read_shift(a,"dbcs")}function Cs(t,a){var r=!1;return a==null&&(r=!0,a=bt(4+2*t.length)),a.write_shift(4,t.length),t.length>0&&a.write_shift(0,t,"dbcs"),r?a.slice(0,a.l):a}function iC(t){return{ich:t.read_shift(2),ifnt:t.read_shift(2)}}function oC(t,a){return a||(a=bt(4)),a.write_shift(2,0),a.write_shift(2,0),a}function cp(t,a){var r=t.l,s=t.read_shift(1),i=ln(t),c=[],d={t:i,h:i};if((s&1)!==0){for(var m=t.read_shift(4),h=0;h!=m;++h)c.push(iC(t));d.r=c}else d.r=[{ich:0,ifnt:0}];return t.l=r+a,d}function lC(t,a){var r=!1;return a==null&&(r=!0,a=bt(15+4*t.t.length)),a.write_shift(1,0),Cs(t.t,a),r?a.slice(0,a.l):a}var cC=cp;function dC(t,a){var r=!1;return a==null&&(r=!0,a=bt(23+4*t.t.length)),a.write_shift(1,1),Cs(t.t,a),a.write_shift(4,1),oC({},a),r?a.slice(0,a.l):a}function _i(t){var a=t.read_shift(4),r=t.read_shift(2);return r+=t.read_shift(1)<<16,t.l++,{c:a,iStyleRef:r}}function Ac(t,a){return a==null&&(a=bt(8)),a.write_shift(-4,t.c),a.write_shift(3,t.iStyleRef||t.s),a.write_shift(1,0),a}function Oc(t){var a=t.read_shift(2);return a+=t.read_shift(1)<<16,t.l++,{c:-1,iStyleRef:a}}function Dc(t,a){return a==null&&(a=bt(4)),a.write_shift(3,t.iStyleRef||t.s),a.write_shift(1,0),a}var uC=ln,uw=Cs;function dp(t){var a=t.read_shift(4);return a===0||a===4294967295?"":t.read_shift(a,"dbcs")}function wh(t,a){var r=!1;return a==null&&(r=!0,a=bt(127)),a.write_shift(4,t.length>0?t.length:4294967295),t.length>0&&a.write_shift(0,t,"dbcs"),r?a.slice(0,a.l):a}var mC=ln,Ax=dp,up=wh;function mw(t){var a=t.slice(t.l,t.l+4),r=a[0]&1,s=a[0]&2;t.l+=4;var i=s===0?_h([0,0,0,0,a[0]&252,a[1],a[2],a[3]],0):uc(a,0)>>2;return r?i/100:i}function hw(t,a){a==null&&(a=bt(4));var r=0,s=0,i=t*100;if(t==(t|0)&&t>=-536870912&&t<1<<29?s=1:i==(i|0)&&i>=-536870912&&i<1<<29&&(s=1,r=1),s)a.write_shift(-4,((r?i:t)<<2)+(r+2));else throw new Error("unsupported RkNumber "+t)}function gw(t){var a={s:{},e:{}};return a.s.r=t.read_shift(4),a.e.r=t.read_shift(4),a.s.c=t.read_shift(4),a.e.c=t.read_shift(4),a}function hC(t,a){return a||(a=bt(16)),a.write_shift(4,t.s.r),a.write_shift(4,t.e.r),a.write_shift(4,t.s.c),a.write_shift(4,t.e.c),a}var Mc=gw,Gd=hC;function Yd(t){if(t.length-t.l<8)throw"XLS Xnum Buffer underflow";return t.read_shift(8,"f")}function jc(t,a){return(a||bt(8)).write_shift(8,t,"f")}function gC(t){var a={},r=t.read_shift(1),s=r>>>1,i=t.read_shift(1),c=t.read_shift(2,"i"),d=t.read_shift(1),m=t.read_shift(1),h=t.read_shift(1);switch(t.l++,s){case 0:a.auto=1;break;case 1:a.index=i;var g=kC[i];g&&(a.rgb=r_(g));break;case 2:a.rgb=r_([d,m,h]);break;case 3:a.theme=i;break}return c!=0&&(a.tint=c>0?c/32767:c/32768),a}function kh(t,a){if(a||(a=bt(8)),!t||t.auto)return a.write_shift(4,0),a.write_shift(4,0),a;t.index!=null?(a.write_shift(1,2),a.write_shift(1,t.index)):t.theme!=null?(a.write_shift(1,6),a.write_shift(1,t.theme)):(a.write_shift(1,5),a.write_shift(1,0));var r=t.tint||0;if(r>0?r*=32767:r<0&&(r*=32768),a.write_shift(2,r),!t.rgb||t.theme!=null)a.write_shift(2,0),a.write_shift(1,0),a.write_shift(1,0);else{var s=t.rgb||"FFFFFF";typeof s=="number"&&(s=("000000"+s.toString(16)).slice(-6)),a.write_shift(1,parseInt(s.slice(0,2),16)),a.write_shift(1,parseInt(s.slice(2,4),16)),a.write_shift(1,parseInt(s.slice(4,6),16)),a.write_shift(1,255)}return a}function fC(t){var a=t.read_shift(1);t.l++;var r={fBold:a&1,fItalic:a&2,fUnderline:a&4,fStrikeout:a&8,fOutline:a&16,fShadow:a&32,fCondense:a&64,fExtend:a&128};return r}function xC(t,a){a||(a=bt(2));var r=(t.italic?2:0)|(t.strike?8:0)|(t.outline?16:0)|(t.shadow?32:0)|(t.condense?64:0)|(t.extend?128:0);return a.write_shift(1,r),a.write_shift(1,0),a}var fw=2,Kn=3,$m=11,jh=19,Hm=64,pC=65,yC=71,bC=4108,vC=4126,Vs=80,G1={1:{n:"CodePage",t:fw},2:{n:"Category",t:Vs},3:{n:"PresentationFormat",t:Vs},4:{n:"ByteCount",t:Kn},5:{n:"LineCount",t:Kn},6:{n:"ParagraphCount",t:Kn},7:{n:"SlideCount",t:Kn},8:{n:"NoteCount",t:Kn},9:{n:"HiddenCount",t:Kn},10:{n:"MultimediaClipCount",t:Kn},11:{n:"ScaleCrop",t:$m},12:{n:"HeadingPairs",t:bC},13:{n:"TitlesOfParts",t:vC},14:{n:"Manager",t:Vs},15:{n:"Company",t:Vs},16:{n:"LinksUpToDate",t:$m},17:{n:"CharacterCount",t:Kn},19:{n:"SharedDoc",t:$m},22:{n:"HyperlinksChanged",t:$m},23:{n:"AppVersion",t:Kn,p:"version"},24:{n:"DigSig",t:pC},26:{n:"ContentType",t:Vs},27:{n:"ContentStatus",t:Vs},28:{n:"Language",t:Vs},29:{n:"Version",t:Vs},255:{},2147483648:{n:"Locale",t:jh},2147483651:{n:"Behavior",t:jh},1919054434:{}},Y1={1:{n:"CodePage",t:fw},2:{n:"Title",t:Vs},3:{n:"Subject",t:Vs},4:{n:"Author",t:Vs},5:{n:"Keywords",t:Vs},6:{n:"Comments",t:Vs},7:{n:"Template",t:Vs},8:{n:"LastAuthor",t:Vs},9:{n:"RevNumber",t:Vs},10:{n:"EditTime",t:Hm},11:{n:"LastPrinted",t:Hm},12:{n:"CreatedDate",t:Hm},13:{n:"ModifiedDate",t:Hm},14:{n:"PageCount",t:Kn},15:{n:"WordCount",t:Kn},16:{n:"CharCount",t:Kn},17:{n:"Thumbnail",t:yC},18:{n:"Application",t:Vs},19:{n:"DocSecurity",t:Kn},255:{},2147483648:{n:"Locale",t:jh},2147483651:{n:"Behavior",t:jh},1919054434:{}};function _C(t){return t.map(function(a){return[a>>16&255,a>>8&255,a&255]})}var wC=_C([0,16777215,16711680,65280,255,16776960,16711935,65535,0,16777215,16711680,65280,255,16776960,16711935,65535,8388608,32768,128,8421376,8388736,32896,12632256,8421504,10066431,10040166,16777164,13434879,6684774,16744576,26316,13421823,128,16711935,16776960,65535,8388736,8388608,32896,255,52479,13434879,13434828,16777113,10079487,16751052,13408767,16764057,3368703,3394764,10079232,16763904,16750848,16737792,6710937,9868950,13158,3381606,13056,3355392,10040064,10040166,3355545,3355443,16777215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),kC=In(wC),Eu={0:"#NULL!",7:"#DIV/0!",15:"#VALUE!",23:"#REF!",29:"#NAME?",36:"#NUM!",42:"#N/A",43:"#GETTING_DATA",255:"#WTF?"},jC={"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml":"workbooks","application/vnd.ms-excel.sheet.macroEnabled.main+xml":"workbooks","application/vnd.ms-excel.sheet.binary.macroEnabled.main":"workbooks","application/vnd.ms-excel.addin.macroEnabled.main+xml":"workbooks","application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml":"workbooks","application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml":"sheets","application/vnd.ms-excel.worksheet":"sheets","application/vnd.ms-excel.binIndexWs":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml":"charts","application/vnd.ms-excel.chartsheet":"charts","application/vnd.ms-excel.macrosheet+xml":"macros","application/vnd.ms-excel.macrosheet":"macros","application/vnd.ms-excel.intlmacrosheet":"TODO","application/vnd.ms-excel.binIndexMs":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml":"dialogs","application/vnd.ms-excel.dialogsheet":"dialogs","application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml":"strs","application/vnd.ms-excel.sharedStrings":"strs","application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml":"styles","application/vnd.ms-excel.styles":"styles","application/vnd.openxmlformats-package.core-properties+xml":"coreprops","application/vnd.openxmlformats-officedocument.custom-properties+xml":"custprops","application/vnd.openxmlformats-officedocument.extended-properties+xml":"extprops","application/vnd.openxmlformats-officedocument.customXmlProperties+xml":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.customProperty":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml":"comments","application/vnd.ms-excel.comments":"comments","application/vnd.ms-excel.threadedcomments+xml":"threadedcomments","application/vnd.ms-excel.person+xml":"people","application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml":"metadata","application/vnd.ms-excel.sheetMetadata":"metadata","application/vnd.ms-excel.pivotTable":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml":"TODO","application/vnd.openxmlformats-officedocument.drawingml.chart+xml":"TODO","application/vnd.ms-office.chartcolorstyle+xml":"TODO","application/vnd.ms-office.chartstyle+xml":"TODO","application/vnd.ms-office.chartex+xml":"TODO","application/vnd.ms-excel.calcChain":"calcchains","application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml":"calcchains","application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings":"TODO","application/vnd.ms-office.activeX":"TODO","application/vnd.ms-office.activeX+xml":"TODO","application/vnd.ms-excel.attachedToolbars":"TODO","application/vnd.ms-excel.connections":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml":"TODO","application/vnd.ms-excel.externalLink":"links","application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml":"links","application/vnd.ms-excel.pivotCacheDefinition":"TODO","application/vnd.ms-excel.pivotCacheRecords":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml":"TODO","application/vnd.ms-excel.queryTable":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml":"TODO","application/vnd.ms-excel.userNames":"TODO","application/vnd.ms-excel.revisionHeaders":"TODO","application/vnd.ms-excel.revisionLog":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.userNames+xml":"TODO","application/vnd.ms-excel.tableSingleCells":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml":"TODO","application/vnd.ms-excel.slicer":"TODO","application/vnd.ms-excel.slicerCache":"TODO","application/vnd.ms-excel.slicer+xml":"TODO","application/vnd.ms-excel.slicerCache+xml":"TODO","application/vnd.ms-excel.wsSortMap":"TODO","application/vnd.ms-excel.table":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml":"TODO","application/vnd.openxmlformats-officedocument.theme+xml":"themes","application/vnd.openxmlformats-officedocument.themeOverride+xml":"TODO","application/vnd.ms-excel.Timeline+xml":"TODO","application/vnd.ms-excel.TimelineCache+xml":"TODO","application/vnd.ms-office.vbaProject":"vba","application/vnd.ms-office.vbaProjectSignature":"TODO","application/vnd.ms-office.volatileDependencies":"TODO","application/vnd.openxmlformats-officedocument.spreadsheetml.volatileDependencies+xml":"TODO","application/vnd.ms-excel.controlproperties+xml":"TODO","application/vnd.openxmlformats-officedocument.model+data":"TODO","application/vnd.ms-excel.Survey+xml":"TODO","application/vnd.openxmlformats-officedocument.drawing+xml":"drawings","application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml":"TODO","application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml":"TODO","application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml":"TODO","application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml":"TODO","application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml":"TODO","application/vnd.openxmlformats-officedocument.vmlDrawing":"TODO","application/vnd.openxmlformats-package.relationships+xml":"rels","application/vnd.openxmlformats-officedocument.oleObject":"TODO","image/png":"TODO",sheet:"js"},Wm={workbooks:{xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",xlsm:"application/vnd.ms-excel.sheet.macroEnabled.main+xml",xlsb:"application/vnd.ms-excel.sheet.binary.macroEnabled.main",xlam:"application/vnd.ms-excel.addin.macroEnabled.main+xml",xltx:"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml"},strs:{xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",xlsb:"application/vnd.ms-excel.sharedStrings"},comments:{xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml",xlsb:"application/vnd.ms-excel.comments"},sheets:{xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",xlsb:"application/vnd.ms-excel.worksheet"},charts:{xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml",xlsb:"application/vnd.ms-excel.chartsheet"},dialogs:{xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml",xlsb:"application/vnd.ms-excel.dialogsheet"},macros:{xlsx:"application/vnd.ms-excel.macrosheet+xml",xlsb:"application/vnd.ms-excel.macrosheet"},metadata:{xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml",xlsb:"application/vnd.ms-excel.sheetMetadata"},styles:{xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",xlsb:"application/vnd.ms-excel.styles"}};function xw(){return{workbooks:[],sheets:[],charts:[],dialogs:[],macros:[],rels:[],strs:[],comments:[],threadedcomments:[],links:[],coreprops:[],extprops:[],custprops:[],themes:[],styles:[],calcchains:[],vba:[],drawings:[],metadata:[],people:[],TODO:[],xmlns:""}}function pw(t,a){var r=L6(jC),s=[],i;s[s.length]=us,s[s.length]=qt("Types",null,{xmlns:Ns.CT,"xmlns:xsd":Ns.xsd,"xmlns:xsi":Ns.xsi}),s=s.concat([["xml","application/xml"],["bin","application/vnd.ms-excel.sheet.binary.macroEnabled.main"],["vml","application/vnd.openxmlformats-officedocument.vmlDrawing"],["data","application/vnd.openxmlformats-officedocument.model+data"],["bmp","image/bmp"],["png","image/png"],["gif","image/gif"],["emf","image/x-emf"],["wmf","image/x-wmf"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["tif","image/tiff"],["tiff","image/tiff"],["pdf","application/pdf"],["rels","application/vnd.openxmlformats-package.relationships+xml"]].map(function(h){return qt("Default",null,{Extension:h[0],ContentType:h[1]})}));var c=function(h){t[h]&&t[h].length>0&&(i=t[h][0],s[s.length]=qt("Override",null,{PartName:(i[0]=="/"?"":"/")+i,ContentType:Wm[h][a.bookType]||Wm[h].xlsx}))},d=function(h){(t[h]||[]).forEach(function(g){s[s.length]=qt("Override",null,{PartName:(g[0]=="/"?"":"/")+g,ContentType:Wm[h][a.bookType]||Wm[h].xlsx})})},m=function(h){(t[h]||[]).forEach(function(g){s[s.length]=qt("Override",null,{PartName:(g[0]=="/"?"":"/")+g,ContentType:r[h][0]})})};return c("workbooks"),d("sheets"),d("charts"),m("themes"),["strs","styles"].forEach(c),["coreprops","extprops","custprops"].forEach(m),m("vba"),m("comments"),m("threadedcomments"),m("drawings"),d("metadata"),m("people"),s.length>2&&(s[s.length]="</Types>",s[1]=s[1].replace("/>",">")),s.join("")}var tr={WB:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",HLINK:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",VML:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",XPATH:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath",XMISS:"http://schemas.microsoft.com/office/2006/relationships/xlExternalLinkPath/xlPathMissing",CMNT:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",CORE_PROPS:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",EXT_PROPS:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",CUST_PROPS:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties",SST:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",STY:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",THEME:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",WS:["http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet","http://purl.oclc.org/ooxml/officeDocument/relationships/worksheet"],DRAW:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",XLMETA:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sheetMetadata",TCMNT:"http://schemas.microsoft.com/office/2017/10/relationships/threadedComment",PEOPLE:"http://schemas.microsoft.com/office/2017/10/relationships/person",VBA:"http://schemas.microsoft.com/office/2006/relationships/vbaProject"};function yw(t){var a=t.lastIndexOf("/");return t.slice(0,a+1)+"_rels/"+t.slice(a+1)+".rels"}function Rd(t){var a=[us,qt("Relationships",null,{xmlns:Ns.RELS})];return Xs(t["!id"]).forEach(function(r){a[a.length]=qt("Relationship",null,t["!id"][r])}),a.length>2&&(a[a.length]="</Relationships>",a[1]=a[1].replace("/>",">")),a.join("")}function ur(t,a,r,s,i,c){if(i||(i={}),t["!id"]||(t["!id"]={}),t["!idx"]||(t["!idx"]=1),a<0)for(a=t["!idx"];t["!id"]["rId"+a];++a);if(t["!idx"]=a+1,i.Id="rId"+a,i.Type=s,i.Target=r,[tr.HLINK,tr.XPATH,tr.XMISS].indexOf(i.Type)>-1&&(i.TargetMode="External"),t["!id"][i.Id])throw new Error("Cannot rewrite rId "+a);return t["!id"][i.Id]=i,t[("/"+i.Target).replace("//","/")]=i,a}function NC(t){var a=[us];a.push(`<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.2">
`),a.push(` <manifest:file-entry manifest:full-path="/" manifest:version="1.2" manifest:media-type="application/vnd.oasis.opendocument.spreadsheet"/>
`);for(var r=0;r<t.length;++r)a.push(' <manifest:file-entry manifest:full-path="'+t[r][0]+'" manifest:media-type="'+t[r][1]+`"/>
`);return a.push("</manifest:manifest>"),a.join("")}function Z1(t,a,r){return[' <rdf:Description rdf:about="'+t+`">
`,' <rdf:type rdf:resource="http://docs.oasis-open.org/ns/office/1.2/meta/'+(r||"odf")+"#"+a+`"/>
`,` </rdf:Description>
`].join("")}function SC(t,a){return[' <rdf:Description rdf:about="'+t+`">
`,' <ns0:hasPart xmlns:ns0="http://docs.oasis-open.org/ns/office/1.2/meta/pkg#" rdf:resource="'+a+`"/>
`,` </rdf:Description>
`].join("")}function CC(t){var a=[us];a.push(`<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
`);for(var r=0;r!=t.length;++r)a.push(Z1(t[r][0],t[r][1])),a.push(SC("",t[r][0]));return a.push(Z1("","Document","pkg")),a.push("</rdf:RDF>"),a.join("")}function bw(){return'<office:document-meta xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xlink="http://www.w3.org/1999/xlink" office:version="1.2"><office:meta><meta:generator>SheetJS '+fh.version+"</meta:generator></office:meta></office:document-meta>"}var xc=[["cp:category","Category"],["cp:contentStatus","ContentStatus"],["cp:keywords","Keywords"],["cp:lastModifiedBy","LastAuthor"],["cp:lastPrinted","LastPrinted"],["cp:revision","RevNumber"],["cp:version","Version"],["dc:creator","Author"],["dc:description","Comments"],["dc:identifier","Identifier"],["dc:language","Language"],["dc:subject","Subject"],["dc:title","Title"],["dcterms:created","CreatedDate","date"],["dcterms:modified","ModifiedDate","date"]];function nx(t,a,r,s,i){i[t]!=null||a==null||a===""||(i[t]=a,a=mr(a),s[s.length]=r?qt(t,a,r):Gs(t,a))}function vw(t,a){var r=a||{},s=[us,qt("cp:coreProperties",null,{"xmlns:cp":Ns.CORE_PROPS,"xmlns:dc":Ns.dc,"xmlns:dcterms":Ns.dcterms,"xmlns:dcmitype":Ns.dcmitype,"xmlns:xsi":Ns.xsi})],i={};if(!t&&!r.Props)return s.join("");t&&(t.CreatedDate!=null&&nx("dcterms:created",typeof t.CreatedDate=="string"?t.CreatedDate:Ex(t.CreatedDate,r.WTF),{"xsi:type":"dcterms:W3CDTF"},s,i),t.ModifiedDate!=null&&nx("dcterms:modified",typeof t.ModifiedDate=="string"?t.ModifiedDate:Ex(t.ModifiedDate,r.WTF),{"xsi:type":"dcterms:W3CDTF"},s,i));for(var c=0;c!=xc.length;++c){var d=xc[c],m=r.Props&&r.Props[d[1]]!=null?r.Props[d[1]]:t?t[d[1]]:null;m===!0?m="1":m===!1?m="0":typeof m=="number"&&(m=String(m)),m!=null&&nx(d[0],m,null,s,i)}return s.length>2&&(s[s.length]="</cp:coreProperties>",s[1]=s[1].replace("/>",">")),s.join("")}var Pd=[["Application","Application","string"],["AppVersion","AppVersion","string"],["Company","Company","string"],["DocSecurity","DocSecurity","string"],["Manager","Manager","string"],["HyperlinksChanged","HyperlinksChanged","bool"],["SharedDoc","SharedDoc","bool"],["LinksUpToDate","LinksUpToDate","bool"],["ScaleCrop","ScaleCrop","bool"],["HeadingPairs","HeadingPairs","raw"],["TitlesOfParts","TitlesOfParts","raw"]],_w=["Worksheets","SheetNames","NamedRanges","DefinedNames","Chartsheets","ChartNames"];function ww(t){var a=[],r=qt;return t||(t={}),t.Application="SheetJS",a[a.length]=us,a[a.length]=qt("Properties",null,{xmlns:Ns.EXT_PROPS,"xmlns:vt":Ns.vt}),Pd.forEach(function(s){if(t[s[1]]!==void 0){var i;switch(s[2]){case"string":i=mr(String(t[s[1]]));break;case"bool":i=t[s[1]]?"true":"false";break}i!==void 0&&(a[a.length]=r(s[0],i))}}),a[a.length]=r("HeadingPairs",r("vt:vector",r("vt:variant","<vt:lpstr>Worksheets</vt:lpstr>")+r("vt:variant",r("vt:i4",String(t.Worksheets))),{size:2,baseType:"variant"})),a[a.length]=r("TitlesOfParts",r("vt:vector",t.SheetNames.map(function(s){return"<vt:lpstr>"+mr(s)+"</vt:lpstr>"}).join(""),{size:t.Worksheets,baseType:"lpstr"})),a.length>2&&(a[a.length]="</Properties>",a[1]=a[1].replace("/>",">")),a.join("")}function kw(t){var a=[us,qt("Properties",null,{xmlns:Ns.CUST_PROPS,"xmlns:vt":Ns.vt})];if(!t)return a.join("");var r=1;return Xs(t).forEach(function(i){++r,a[a.length]=qt("property",V6(t[i]),{fmtid:"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",pid:r,name:mr(i)})}),a.length>2&&(a[a.length]="</Properties>",a[1]=a[1].replace("/>",">")),a.join("")}var J1={Title:"Title",Subject:"Subject",Author:"Author",Keywords:"Keywords",Comments:"Description",LastAuthor:"LastAuthor",RevNumber:"Revision",Application:"AppName",LastPrinted:"LastPrinted",CreatedDate:"Created",ModifiedDate:"LastSaved",Category:"Category",Manager:"Manager",Company:"Company",AppVersion:"Version",ContentStatus:"ContentStatus",Identifier:"Identifier",Language:"Language"};function TC(t,a){var r=[];return Xs(J1).map(function(s){for(var i=0;i<xc.length;++i)if(xc[i][1]==s)return xc[i];for(i=0;i<Pd.length;++i)if(Pd[i][1]==s)return Pd[i];throw s}).forEach(function(s){if(t[s[1]]!=null){var i=a&&a.Props&&a.Props[s[1]]!=null?a.Props[s[1]]:t[s[1]];switch(s[2]){case"date":i=new Date(i).toISOString().replace(/\.\d*Z/,"Z");break}typeof i=="number"?i=String(i):i===!0||i===!1?i=i?"1":"0":i instanceof Date&&(i=new Date(i).toISOString().replace(/\.\d*Z/,"")),r.push(Gs(J1[s[1]]||s[1],i))}}),qt("DocumentProperties",r.join(""),{xmlns:ti.o})}function EC(t,a){var r=["Worksheets","SheetNames"],s="CustomDocumentProperties",i=[];return t&&Xs(t).forEach(function(c){if(Object.prototype.hasOwnProperty.call(t,c)){for(var d=0;d<xc.length;++d)if(c==xc[d][1])return;for(d=0;d<Pd.length;++d)if(c==Pd[d][1])return;for(d=0;d<r.length;++d)if(c==r[d])return;var m=t[c],h="string";typeof m=="number"?(h="float",m=String(m)):m===!0||m===!1?(h="boolean",m=m?"1":"0"):m=String(m),i.push(qt(F1(c),m,{"dt:dt":h}))}}),a&&Xs(a).forEach(function(c){if(Object.prototype.hasOwnProperty.call(a,c)&&!(t&&Object.prototype.hasOwnProperty.call(t,c))){var d=a[c],m="string";typeof d=="number"?(m="float",d=String(d)):d===!0||d===!1?(m="boolean",d=d?"1":"0"):d instanceof Date?(m="dateTime.tz",d=d.toISOString()):d=String(d),i.push(qt(F1(c),d,{"dt:dt":m}))}}),"<"+s+' xmlns="'+ti.o+'">'+i.join("")+"</"+s+">"}function AC(t){var a=typeof t=="string"?new Date(Date.parse(t)):t,r=a.getTime()/1e3+11644473600,s=r%Math.pow(2,32),i=(r-s)/Math.pow(2,32);s*=1e7,i*=1e7;var c=s/Math.pow(2,32)|0;c>0&&(s=s%Math.pow(2,32),i+=c);var d=bt(8);return d.write_shift(4,s),d.write_shift(4,i),d}function X1(t,a){var r=bt(4),s=bt(4);switch(r.write_shift(4,t==80?31:t),t){case 3:s.write_shift(-4,a);break;case 5:s=bt(8),s.write_shift(8,a,"f");break;case 11:s.write_shift(4,a?1:0);break;case 64:s=AC(a);break;case 31:case 80:for(s=bt(4+2*(a.length+1)+(a.length%2?0:2)),s.write_shift(4,a.length+1),s.write_shift(0,a,"dbcs");s.l!=s.length;)s.write_shift(1,0);break;default:throw new Error("TypedPropertyValue unrecognized type "+t+" "+a)}return qs([r,s])}var jw=["CodePage","Thumbnail","_PID_LINKBASE","_PID_HLINKS","SystemIdentifier","FMTID"];function OC(t){switch(typeof t){case"boolean":return 11;case"number":return(t|0)==t?3:5;case"string":return 31;case"object":if(t instanceof Date)return 64;break}return-1}function K1(t,a,r){var s=bt(8),i=[],c=[],d=8,m=0,h=bt(8),g=bt(8);if(h.write_shift(4,2),h.write_shift(4,1200),g.write_shift(4,1),c.push(h),i.push(g),d+=8+h.length,!a){g=bt(8),g.write_shift(4,0),i.unshift(g);var p=[bt(4)];for(p[0].write_shift(4,t.length),m=0;m<t.length;++m){var b=t[m][0];for(h=bt(8+2*(b.length+1)+(b.length%2?0:2)),h.write_shift(4,m+2),h.write_shift(4,b.length+1),h.write_shift(0,b,"dbcs");h.l!=h.length;)h.write_shift(1,0);p.push(h)}h=qs(p),c.unshift(h),d+=8+h.length}for(m=0;m<t.length;++m)if(!(a&&!a[t[m][0]])&&!(jw.indexOf(t[m][0])>-1||_w.indexOf(t[m][0])>-1)&&t[m][1]!=null){var j=t[m][1],_=0;if(a){_=+a[t[m][0]];var N=r[_];if(N.p=="version"&&typeof j=="string"){var k=j.split(".");j=(+k[0]<<16)+(+k[1]||0)}h=X1(N.t,j)}else{var C=OC(j);C==-1&&(C=31,j=String(j)),h=X1(C,j)}c.push(h),g=bt(8),g.write_shift(4,a?_:2+m),i.push(g),d+=8+h.length}var D=8*(c.length+1);for(m=0;m<c.length;++m)i[m].write_shift(4,D),D+=c[m].length;return s.write_shift(4,d),s.write_shift(4,c.length),qs([s].concat(i).concat(c))}function Q1(t,a,r,s,i,c){var d=bt(i?68:48),m=[d];d.write_shift(2,65534),d.write_shift(2,0),d.write_shift(4,842412599),d.write_shift(16,vr.utils.consts.HEADER_CLSID,"hex"),d.write_shift(4,i?2:1),d.write_shift(16,a,"hex"),d.write_shift(4,i?68:48);var h=K1(t,r,s);if(m.push(h),i){var g=K1(i,null,null);d.write_shift(16,c,"hex"),d.write_shift(4,68+h.length),m.push(g)}return qs(m)}function DC(t,a){a||(a=bt(t));for(var r=0;r<t;++r)a.write_shift(1,0);return a}function MC(t,a){return t.read_shift(a)===1}function pn(t,a){return a||(a=bt(2)),a.write_shift(2,+!!t),a}function Nw(t){return t.read_shift(2,"u")}function yi(t,a){return a||(a=bt(2)),a.write_shift(2,t),a}function Sw(t,a,r){return r||(r=bt(2)),r.write_shift(1,a=="e"?+t:+!!t),r.write_shift(1,a=="e"?1:0),r}function Cw(t,a,r){var s=t.read_shift(r&&r.biff>=12?2:1),i="sbcs-cont";if(r&&r.biff>=8,!r||r.biff==8){var c=t.read_shift(1);c&&(i="dbcs-cont")}else r.biff==12&&(i="wstr");r.biff>=2&&r.biff<=5&&(i="cpstr");var d=s?t.read_shift(s,i):"";return d}function LC(t){var a=t.t||"",r=bt(3);r.write_shift(2,a.length),r.write_shift(1,1);var s=bt(2*a.length);s.write_shift(2*a.length,a,"utf16le");var i=[r,s];return qs(i)}function RC(t,a,r){var s;if(r){if(r.biff>=2&&r.biff<=5)return t.read_shift(a,"cpstr");if(r.biff>=12)return t.read_shift(a,"dbcs-cont")}var i=t.read_shift(1);return i===0?s=t.read_shift(a,"sbcs-cont"):s=t.read_shift(a,"dbcs-cont"),s}function PC(t,a,r){var s=t.read_shift(r&&r.biff==2?1:2);return s===0?(t.l++,""):RC(t,s,r)}function FC(t,a,r){if(r.biff>5)return PC(t,a,r);var s=t.read_shift(1);return s===0?(t.l++,""):t.read_shift(s,r.biff<=4||!t.lens?"cpstr":"sbcs-cont")}function Tw(t,a,r){return r||(r=bt(3+2*t.length)),r.write_shift(2,t.length),r.write_shift(1,1),r.write_shift(31,t,"utf16le"),r}function e_(t,a){a||(a=bt(6+t.length*2)),a.write_shift(4,1+t.length);for(var r=0;r<t.length;++r)a.write_shift(2,t.charCodeAt(r));return a.write_shift(2,0),a}function IC(t){var a=bt(512),r=0,s=t.Target;s.slice(0,7)=="file://"&&(s=s.slice(7));var i=s.indexOf("#"),c=i>-1?31:23;switch(s.charAt(0)){case"#":c=28;break;case".":c&=-3;break}a.write_shift(4,2),a.write_shift(4,c);var d=[8,6815827,6619237,4849780,83];for(r=0;r<d.length;++r)a.write_shift(4,d[r]);if(c==28)s=s.slice(1),e_(s,a);else if(c&2){for(d="e0 c9 ea 79 f9 ba ce 11 8c 82 00 aa 00 4b a9 0b".split(" "),r=0;r<d.length;++r)a.write_shift(1,parseInt(d[r],16));var m=i>-1?s.slice(0,i):s;for(a.write_shift(4,2*(m.length+1)),r=0;r<m.length;++r)a.write_shift(2,m.charCodeAt(r));a.write_shift(2,0),c&8&&e_(i>-1?s.slice(i+1):"",a)}else{for(d="03 03 00 00 00 00 00 00 c0 00 00 00 00 00 00 46".split(" "),r=0;r<d.length;++r)a.write_shift(1,parseInt(d[r],16));for(var h=0;s.slice(h*3,h*3+3)=="../"||s.slice(h*3,h*3+3)=="..\\";)++h;for(a.write_shift(2,h),a.write_shift(4,s.length-3*h+1),r=0;r<s.length-3*h;++r)a.write_shift(1,s.charCodeAt(r+3*h)&255);for(a.write_shift(1,0),a.write_shift(2,65535),a.write_shift(2,57005),r=0;r<6;++r)a.write_shift(4,0)}return a.slice(0,a.l)}function Nc(t,a,r,s){return s||(s=bt(6)),s.write_shift(2,t),s.write_shift(2,a),s.write_shift(2,r||0),s}function zC(t,a,r){var s=r.biff>8?4:2,i=t.read_shift(s),c=t.read_shift(s,"i"),d=t.read_shift(s,"i");return[i,c,d]}function BC(t){var a=t.read_shift(2),r=t.read_shift(2),s=t.read_shift(2),i=t.read_shift(2);return{s:{c:s,r:a},e:{c:i,r}}}function Ew(t,a){return a||(a=bt(8)),a.write_shift(2,t.s.r),a.write_shift(2,t.e.r),a.write_shift(2,t.s.c),a.write_shift(2,t.e.c),a}function mp(t,a,r){var s=1536,i=16;switch(r.bookType){case"biff8":break;case"biff5":s=1280,i=8;break;case"biff4":s=4,i=6;break;case"biff3":s=3,i=6;break;case"biff2":s=2,i=4;break;case"xla":break;default:throw new Error("unsupported BIFF version")}var c=bt(i);return c.write_shift(2,s),c.write_shift(2,a),i>4&&c.write_shift(2,29282),i>6&&c.write_shift(2,1997),i>8&&(c.write_shift(2,49161),c.write_shift(2,1),c.write_shift(2,1798),c.write_shift(2,0)),c}function UC(t,a){var r=!a||a.biff==8,s=bt(r?112:54);for(s.write_shift(a.biff==8?2:1,7),r&&s.write_shift(1,0),s.write_shift(4,859007059),s.write_shift(4,5458548|(r?0:536870912));s.l<s.length;)s.write_shift(1,r?0:32);return s}function $C(t,a){var r=!a||a.biff>=8?2:1,s=bt(8+r*t.name.length);s.write_shift(4,t.pos),s.write_shift(1,t.hs||0),s.write_shift(1,t.dt),s.write_shift(1,t.name.length),a.biff>=8&&s.write_shift(1,1),s.write_shift(r*t.name.length,t.name,a.biff<8?"sbcs":"utf16le");var i=s.slice(0,s.l);return i.l=s.l,i}function HC(t,a){var r=bt(8);r.write_shift(4,t.Count),r.write_shift(4,t.Unique);for(var s=[],i=0;i<t.length;++i)s[i]=LC(t[i]);var c=qs([r].concat(s));return c.parts=[r.length].concat(s.map(function(d){return d.length})),c}function WC(){var t=bt(18);return t.write_shift(2,0),t.write_shift(2,0),t.write_shift(2,29280),t.write_shift(2,17600),t.write_shift(2,56),t.write_shift(2,0),t.write_shift(2,0),t.write_shift(2,1),t.write_shift(2,500),t}function VC(t){var a=bt(18),r=1718;return t&&t.RTL&&(r|=64),a.write_shift(2,r),a.write_shift(4,0),a.write_shift(4,64),a.write_shift(4,0),a.write_shift(4,0),a}function qC(t,a){var r=t.name||"Arial",s=a&&a.biff==5,i=s?15+r.length:16+2*r.length,c=bt(i);return c.write_shift(2,t.sz*20),c.write_shift(4,0),c.write_shift(2,400),c.write_shift(4,0),c.write_shift(2,0),c.write_shift(1,r.length),s||c.write_shift(1,1),c.write_shift((s?1:2)*r.length,r,s?"sbcs":"utf16le"),c}function GC(t,a,r,s){var i=bt(10);return Nc(t,a,s,i),i.write_shift(4,r),i}function YC(t,a,r,s,i){var c=!i||i.biff==8,d=bt(8+ +c+(1+c)*r.length);return Nc(t,a,s,d),d.write_shift(2,r.length),c&&d.write_shift(1,1),d.write_shift((1+c)*r.length,r,c?"utf16le":"sbcs"),d}function ZC(t,a,r,s){var i=r&&r.biff==5;s||(s=bt(i?3+a.length:5+2*a.length)),s.write_shift(2,t),s.write_shift(i?1:2,a.length),i||s.write_shift(1,1),s.write_shift((i?1:2)*a.length,a,i?"sbcs":"utf16le");var c=s.length>s.l?s.slice(0,s.l):s;return c.l==null&&(c.l=c.length),c}function JC(t,a){var r=a.biff==8||!a.biff?4:2,s=bt(2*r+6);return s.write_shift(r,t.s.r),s.write_shift(r,t.e.r+1),s.write_shift(2,t.s.c),s.write_shift(2,t.e.c+1),s.write_shift(2,0),s}function t_(t,a,r,s){var i=r&&r.biff==5;s||(s=bt(i?16:20)),s.write_shift(2,0),t.style?(s.write_shift(2,t.numFmtId||0),s.write_shift(2,65524)):(s.write_shift(2,t.numFmtId||0),s.write_shift(2,a<<4));var c=0;return t.numFmtId>0&&i&&(c|=1024),s.write_shift(4,c),s.write_shift(4,0),i||s.write_shift(4,0),s.write_shift(2,0),s}function XC(t){var a=bt(8);return a.write_shift(4,0),a.write_shift(2,0),a.write_shift(2,0),a}function KC(t,a,r,s,i,c){var d=bt(8);return Nc(t,a,s,d),Sw(r,c,d),d}function QC(t,a,r,s){var i=bt(14);return Nc(t,a,s,i),jc(r,i),i}function eT(t,a,r){if(r.biff<8)return tT(t,a,r);for(var s=[],i=t.l+a,c=t.read_shift(r.biff>8?4:2);c--!==0;)s.push(zC(t,r.biff>8?12:6,r));if(t.l!=i)throw new Error("Bad ExternSheet: "+t.l+" != "+i);return s}function tT(t,a,r){t[t.l+1]==3&&t[t.l]++;var s=Cw(t,a,r);return s.charCodeAt(0)==3?s.slice(1):s}function aT(t){var a=bt(2+t.length*8);a.write_shift(2,t.length);for(var r=0;r<t.length;++r)Ew(t[r],a);return a}function rT(t){var a=bt(24),r=Ss(t[0]);a.write_shift(2,r.r),a.write_shift(2,r.r),a.write_shift(2,r.c),a.write_shift(2,r.c);for(var s="d0 c9 ea 79 f9 ba ce 11 8c 82 00 aa 00 4b a9 0b".split(" "),i=0;i<16;++i)a.write_shift(1,parseInt(s[i],16));return qs([a,IC(t[1])])}function sT(t){var a=t[1].Tooltip,r=bt(10+2*(a.length+1));r.write_shift(2,2048);var s=Ss(t[0]);r.write_shift(2,s.r),r.write_shift(2,s.r),r.write_shift(2,s.c),r.write_shift(2,s.c);for(var i=0;i<a.length;++i)r.write_shift(2,a.charCodeAt(i));return r.write_shift(2,0),r}function nT(t){return t||(t=bt(4)),t.write_shift(2,1),t.write_shift(2,1),t}function iT(t,a,r){if(!r.cellStyles)return fo(t,a);var s=r&&r.biff>=12?4:2,i=t.read_shift(s),c=t.read_shift(s),d=t.read_shift(s),m=t.read_shift(s),h=t.read_shift(2);s==2&&(t.l+=2);var g={s:i,e:c,w:d,ixfe:m,flags:h};return(r.biff>=5||!r.biff)&&(g.level=h>>8&7),g}function oT(t,a){var r=bt(12);r.write_shift(2,a),r.write_shift(2,a),r.write_shift(2,t.width*256),r.write_shift(2,0);var s=0;return t.hidden&&(s|=1),r.write_shift(1,s),s=t.level||0,r.write_shift(1,s),r.write_shift(2,0),r}function lT(t){for(var a=bt(2*t),r=0;r<t;++r)a.write_shift(2,r+1);return a}function cT(t,a,r){var s=bt(15);return Ou(s,t,a),s.write_shift(8,r,"f"),s}function dT(t,a,r){var s=bt(9);return Ou(s,t,a),s.write_shift(2,r),s}var uT=(function(){var t={1:437,2:850,3:1252,4:1e4,100:852,101:866,102:865,103:861,104:895,105:620,106:737,107:857,120:950,121:949,122:936,123:932,124:874,125:1255,126:1256,150:10007,151:10029,152:10006,200:1250,201:1251,202:1254,203:1253,0:20127,8:865,9:437,10:850,11:437,13:437,14:850,15:437,16:850,17:437,18:850,19:932,20:850,21:437,22:850,23:865,24:437,25:437,26:850,27:437,28:863,29:850,31:852,34:852,35:852,36:860,37:850,38:866,55:850,64:852,77:936,78:949,79:950,80:874,87:1252,88:1252,89:1252,108:863,134:737,135:852,136:857,204:1257,255:16969},a=tp({1:437,2:850,3:1252,4:1e4,100:852,101:866,102:865,103:861,104:895,105:620,106:737,107:857,120:950,121:949,122:936,123:932,124:874,125:1255,126:1256,150:10007,151:10029,152:10006,200:1250,201:1251,202:1254,203:1253,0:20127});function r(m,h){var g=[],p=kc(1);switch(h.type){case"base64":p=Mi(Jo(m));break;case"binary":p=Mi(m);break;case"buffer":case"array":p=m;break}Qn(p,0);var b=p.read_shift(1),j=!!(b&136),_=!1,N=!1;switch(b){case 2:break;case 3:break;case 48:_=!0,j=!0;break;case 49:_=!0,j=!0;break;case 131:break;case 139:break;case 140:N=!0;break;case 245:break;default:throw new Error("DBF Unsupported Version: "+b.toString(16))}var k=0,C=521;b==2&&(k=p.read_shift(2)),p.l+=3,b!=2&&(k=p.read_shift(4)),k>1048576&&(k=1e6),b!=2&&(C=p.read_shift(2));var D=p.read_shift(2),T=h.codepage||1252;b!=2&&(p.l+=16,p.read_shift(1),p[p.l]!==0&&(T=t[p[p.l]]),p.l+=1,p.l+=2),N&&(p.l+=36);for(var E=[],O={},R=Math.min(p.length,b==2?521:C-10-(_?264:0)),Y=N?32:11;p.l<R&&p[p.l]!=13;)switch(O={},O.name=xh.utils.decode(T,p.slice(p.l,p.l+Y)).replace(/[\u0000\r\n].*$/g,""),p.l+=Y,O.type=String.fromCharCode(p.read_shift(1)),b!=2&&!N&&(O.offset=p.read_shift(4)),O.len=p.read_shift(1),b==2&&(O.offset=p.read_shift(2)),O.dec=p.read_shift(1),O.name.length&&E.push(O),b!=2&&(p.l+=N?13:14),O.type){case"B":(!_||O.len!=8)&&h.WTF&&console.log("Skipping "+O.name+":"+O.type);break;case"G":case"P":h.WTF&&console.log("Skipping "+O.name+":"+O.type);break;case"+":case"0":case"@":case"C":case"D":case"F":case"I":case"L":case"M":case"N":case"O":case"T":case"Y":break;default:throw new Error("Unknown Field Type: "+O.type)}if(p[p.l]!==13&&(p.l=C-1),p.read_shift(1)!==13)throw new Error("DBF Terminator not found "+p.l+" "+p[p.l]);p.l=C;var P=0,U=0;for(g[0]=[],U=0;U!=E.length;++U)g[0][U]=E[U].name;for(;k-- >0;){if(p[p.l]===42){p.l+=D;continue}for(++p.l,g[++P]=[],U=0,U=0;U!=E.length;++U){var J=p.slice(p.l,p.l+E[U].len);p.l+=E[U].len,Qn(J,0);var ne=xh.utils.decode(T,J);switch(E[U].type){case"C":ne.trim().length&&(g[P][U]=ne.replace(/\s+$/,""));break;case"D":ne.length===8?g[P][U]=new Date(+ne.slice(0,4),+ne.slice(4,6)-1,+ne.slice(6,8)):g[P][U]=ne;break;case"F":g[P][U]=parseFloat(ne.trim());break;case"+":case"I":g[P][U]=N?J.read_shift(-4,"i")^2147483648:J.read_shift(4,"i");break;case"L":switch(ne.trim().toUpperCase()){case"Y":case"T":g[P][U]=!0;break;case"N":case"F":g[P][U]=!1;break;case"":case"?":break;default:throw new Error("DBF Unrecognized L:|"+ne+"|")}break;case"M":if(!j)throw new Error("DBF Unexpected MEMO for type "+b.toString(16));g[P][U]="##MEMO##"+(N?parseInt(ne.trim(),10):J.read_shift(4));break;case"N":ne=ne.replace(/\u0000/g,"").trim(),ne&&ne!="."&&(g[P][U]=+ne||0);break;case"@":g[P][U]=new Date(J.read_shift(-8,"f")-621356832e5);break;case"T":g[P][U]=new Date((J.read_shift(4)-2440588)*864e5+J.read_shift(4));break;case"Y":g[P][U]=J.read_shift(4,"i")/1e4+J.read_shift(4,"i")/1e4*Math.pow(2,32);break;case"O":g[P][U]=-J.read_shift(-8,"f");break;case"B":if(_&&E[U].len==8){g[P][U]=J.read_shift(8,"f");break}case"G":case"P":J.l+=E[U].len;break;case"0":if(E[U].name==="_NullFlags")break;default:throw new Error("DBF Unsupported data type "+E[U].type)}}}if(b!=2&&p.l<p.length&&p[p.l++]!=26)throw new Error("DBF EOF Marker missing "+(p.l-1)+" of "+p.length+" "+p[p.l-1].toString(16));return h&&h.sheetRows&&(g=g.slice(0,h.sheetRows)),h.DBF=E,g}function s(m,h){var g=h||{};g.dateNF||(g.dateNF="yyyymmdd");var p=qd(r(m,g),g);return p["!cols"]=g.DBF.map(function(b){return{wch:b.len,DBF:b}}),delete g.DBF,p}function i(m,h){try{return Ec(s(m,h),h)}catch(g){if(h&&h.WTF)throw g}return{SheetNames:[],Sheets:{}}}var c={B:8,C:250,L:1,D:8,"?":0,"":0};function d(m,h){var g=h||{};if(+g.codepage>=0&&gu(+g.codepage),g.type=="string")throw new Error("Cannot write DBF to JS string");var p=Ln(),b=Eh(m,{header:1,raw:!0,cellDates:!0}),j=b[0],_=b.slice(1),N=m["!cols"]||[],k=0,C=0,D=0,T=1;for(k=0;k<j.length;++k){if(((N[k]||{}).DBF||{}).name){j[k]=N[k].DBF.name,++D;continue}if(j[k]!=null){if(++D,typeof j[k]=="number"&&(j[k]=j[k].toString(10)),typeof j[k]!="string")throw new Error("DBF Invalid column name "+j[k]+" |"+typeof j[k]+"|");if(j.indexOf(j[k])!==k){for(C=0;C<1024;++C)if(j.indexOf(j[k]+"_"+C)==-1){j[k]+="_"+C;break}}}}var E=Dr(m["!ref"]),O=[],R=[],Y=[];for(k=0;k<=E.e.c-E.s.c;++k){var P="",U="",J=0,ne=[];for(C=0;C<_.length;++C)_[C][k]!=null&&ne.push(_[C][k]);if(ne.length==0||j[k]==null){O[k]="?";continue}for(C=0;C<ne.length;++C){switch(typeof ne[C]){case"number":U="B";break;case"string":U="C";break;case"boolean":U="L";break;case"object":U=ne[C]instanceof Date?"D":"C";break;default:U="C"}J=Math.max(J,String(ne[C]).length),P=P&&P!=U?"C":U}J>250&&(J=250),U=((N[k]||{}).DBF||{}).type,U=="C"&&N[k].DBF.len>J&&(J=N[k].DBF.len),P=="B"&&U=="N"&&(P="N",Y[k]=N[k].DBF.dec,J=N[k].DBF.len),R[k]=P=="C"||U=="N"?J:c[P]||0,T+=R[k],O[k]=P}var ye=p.next(32);for(ye.write_shift(4,318902576),ye.write_shift(4,_.length),ye.write_shift(2,296+32*D),ye.write_shift(2,T),k=0;k<4;++k)ye.write_shift(4,0);for(ye.write_shift(4,0|(+a[O2]||3)<<8),k=0,C=0;k<j.length;++k)if(j[k]!=null){var he=p.next(32),ce=(j[k].slice(-10)+"\0\0\0\0\0\0\0\0\0\0\0").slice(0,11);he.write_shift(1,ce,"sbcs"),he.write_shift(1,O[k]=="?"?"C":O[k],"sbcs"),he.write_shift(4,C),he.write_shift(1,R[k]||c[O[k]]||0),he.write_shift(1,Y[k]||0),he.write_shift(1,2),he.write_shift(4,0),he.write_shift(1,0),he.write_shift(4,0),he.write_shift(4,0),C+=R[k]||c[O[k]]||0}var se=p.next(264);for(se.write_shift(4,13),k=0;k<65;++k)se.write_shift(4,0);for(k=0;k<_.length;++k){var ee=p.next(T);for(ee.write_shift(1,0),C=0;C<j.length;++C)if(j[C]!=null)switch(O[C]){case"L":ee.write_shift(1,_[k][C]==null?63:_[k][C]?84:70);break;case"B":ee.write_shift(8,_[k][C]||0,"f");break;case"N":var te="0";for(typeof _[k][C]=="number"&&(te=_[k][C].toFixed(Y[C]||0)),D=0;D<R[C]-te.length;++D)ee.write_shift(1,32);ee.write_shift(1,te,"sbcs");break;case"D":_[k][C]?(ee.write_shift(4,("0000"+_[k][C].getFullYear()).slice(-4),"sbcs"),ee.write_shift(2,("00"+(_[k][C].getMonth()+1)).slice(-2),"sbcs"),ee.write_shift(2,("00"+_[k][C].getDate()).slice(-2),"sbcs")):ee.write_shift(8,"00000000","sbcs");break;case"C":var W=String(_[k][C]!=null?_[k][C]:"").slice(0,R[C]);for(ee.write_shift(1,W,"sbcs"),D=0;D<R[C]-W.length;++D)ee.write_shift(1,32);break}}return p.next(1).write_shift(1,26),p.end()}return{to_workbook:i,to_sheet:s,from_sheet:d}})(),mT=(function(){var t={AA:"À",BA:"Á",CA:"Â",DA:195,HA:"Ä",JA:197,AE:"È",BE:"É",CE:"Ê",HE:"Ë",AI:"Ì",BI:"Í",CI:"Î",HI:"Ï",AO:"Ò",BO:"Ó",CO:"Ô",DO:213,HO:"Ö",AU:"Ù",BU:"Ú",CU:"Û",HU:"Ü",Aa:"à",Ba:"á",Ca:"â",Da:227,Ha:"ä",Ja:229,Ae:"è",Be:"é",Ce:"ê",He:"ë",Ai:"ì",Bi:"í",Ci:"î",Hi:"ï",Ao:"ò",Bo:"ó",Co:"ô",Do:245,Ho:"ö",Au:"ù",Bu:"ú",Cu:"û",Hu:"ü",KC:"Ç",Kc:"ç",q:"æ",z:"œ",a:"Æ",j:"Œ",DN:209,Dn:241,Hy:255,S:169,c:170,R:174,"B ":180,0:176,1:177,2:178,3:179,5:181,6:182,7:183,Q:185,k:186,b:208,i:216,l:222,s:240,y:248,"!":161,'"':162,"#":163,"(":164,"%":165,"'":167,"H ":168,"+":171,";":187,"<":188,"=":189,">":190,"?":191,"{":223},a=new RegExp("\x1BN("+Xs(t).join("|").replace(/\|\|\|/,"|\\||").replace(/([?()+])/g,"\\$1")+"|\\|)","gm"),r=function(j,_){var N=t[_];return typeof N=="number"?N1(N):N},s=function(j,_,N){var k=_.charCodeAt(0)-32<<4|N.charCodeAt(0)-48;return k==59?j:N1(k)};t["|"]=254;function i(j,_){switch(_.type){case"base64":return c(Jo(j),_);case"binary":return c(j,_);case"buffer":return c(ir&&Buffer.isBuffer(j)?j.toString("binary"):Su(j),_);case"array":return c(Uh(j),_)}throw new Error("Unrecognized type "+_.type)}function c(j,_){var N=j.split(/[\n\r]+/),k=-1,C=-1,D=0,T=0,E=[],O=[],R=null,Y={},P=[],U=[],J=[],ne=0,ye;for(+_.codepage>=0&&gu(+_.codepage);D!==N.length;++D){ne=0;var he=N[D].trim().replace(/\x1B([\x20-\x2F])([\x30-\x3F])/g,s).replace(a,r),ce=he.replace(/;;/g,"\0").split(";").map(function(K){return K.replace(/\u0000/g,";")}),se=ce[0],ee;if(he.length>0)switch(se){case"ID":break;case"E":break;case"B":break;case"O":break;case"W":break;case"P":ce[1].charAt(0)=="P"&&O.push(he.slice(3).replace(/;;/g,";"));break;case"C":var te=!1,W=!1,I=!1,oe=!1,ae=-1,F=-1;for(T=1;T<ce.length;++T)switch(ce[T].charAt(0)){case"A":break;case"X":C=parseInt(ce[T].slice(1))-1,W=!0;break;case"Y":for(k=parseInt(ce[T].slice(1))-1,W||(C=0),ye=E.length;ye<=k;++ye)E[ye]=[];break;case"K":ee=ce[T].slice(1),ee.charAt(0)==='"'?ee=ee.slice(1,ee.length-1):ee==="TRUE"?ee=!0:ee==="FALSE"?ee=!1:isNaN(Go(ee))?isNaN(xu(ee).getDate())||(ee=bn(ee)):(ee=Go(ee),R!==null&&H2(R)&&(ee=G2(ee))),te=!0;break;case"E":oe=!0;var M=dE(ce[T].slice(1),{r:k,c:C});E[k][C]=[E[k][C],M];break;case"S":I=!0,E[k][C]=[E[k][C],"S5S"];break;case"G":break;case"R":ae=parseInt(ce[T].slice(1))-1;break;case"C":F=parseInt(ce[T].slice(1))-1;break;default:if(_&&_.WTF)throw new Error("SYLK bad record "+he)}if(te&&(E[k][C]&&E[k][C].length==2?E[k][C][0]=ee:E[k][C]=ee,R=null),I){if(oe)throw new Error("SYLK shared formula cannot have own formula");var B=ae>-1&&E[ae][F];if(!B||!B[1])throw new Error("SYLK shared formula cannot find base");E[k][C][1]=uE(B[1],{r:k-ae,c:C-F})}break;case"F":var X=0;for(T=1;T<ce.length;++T)switch(ce[T].charAt(0)){case"X":C=parseInt(ce[T].slice(1))-1,++X;break;case"Y":for(k=parseInt(ce[T].slice(1))-1,ye=E.length;ye<=k;++ye)E[ye]=[];break;case"M":ne=parseInt(ce[T].slice(1))/20;break;case"F":break;case"G":break;case"P":R=O[parseInt(ce[T].slice(1))];break;case"S":break;case"D":break;case"N":break;case"W":for(J=ce[T].slice(1).split(" "),ye=parseInt(J[0],10);ye<=parseInt(J[1],10);++ye)ne=parseInt(J[2],10),U[ye-1]=ne===0?{hidden:!0}:{wch:ne},hp(U[ye-1]);break;case"C":C=parseInt(ce[T].slice(1))-1,U[C]||(U[C]={});break;case"R":k=parseInt(ce[T].slice(1))-1,P[k]||(P[k]={}),ne>0?(P[k].hpt=ne,P[k].hpx=Lw(ne)):ne===0&&(P[k].hidden=!0);break;default:if(_&&_.WTF)throw new Error("SYLK bad record "+he)}X<1&&(R=null);break;default:if(_&&_.WTF)throw new Error("SYLK bad record "+he)}}return P.length>0&&(Y["!rows"]=P),U.length>0&&(Y["!cols"]=U),_&&_.sheetRows&&(E=E.slice(0,_.sheetRows)),[E,Y]}function d(j,_){var N=i(j,_),k=N[0],C=N[1],D=qd(k,_);return Xs(C).forEach(function(T){D[T]=C[T]}),D}function m(j,_){return Ec(d(j,_),_)}function h(j,_,N,k){var C="C;Y"+(N+1)+";X"+(k+1)+";K";switch(j.t){case"n":C+=j.v||0,j.f&&!j.F&&(C+=";E"+fp(j.f,{r:N,c:k}));break;case"b":C+=j.v?"TRUE":"FALSE";break;case"e":C+=j.w||j.v;break;case"d":C+='"'+(j.w||j.v)+'"';break;case"s":C+='"'+j.v.replace(/"/g,"").replace(/;/g,";;")+'"';break}return C}function g(j,_){_.forEach(function(N,k){var C="F;W"+(k+1)+" "+(k+1)+" ";N.hidden?C+="0":(typeof N.width=="number"&&!N.wpx&&(N.wpx=Nh(N.width)),typeof N.wpx=="number"&&!N.wch&&(N.wch=Sh(N.wpx)),typeof N.wch=="number"&&(C+=Math.round(N.wch))),C.charAt(C.length-1)!=" "&&j.push(C)})}function p(j,_){_.forEach(function(N,k){var C="F;";N.hidden?C+="M0;":N.hpt?C+="M"+20*N.hpt+";":N.hpx&&(C+="M"+20*Ch(N.hpx)+";"),C.length>2&&j.push(C+"R"+(k+1))})}function b(j,_){var N=["ID;PWXL;N;E"],k=[],C=Dr(j["!ref"]),D,T=Array.isArray(j),E=`\r
`;N.push("P;PGeneral"),N.push("F;P0;DG0G8;M255"),j["!cols"]&&g(N,j["!cols"]),j["!rows"]&&p(N,j["!rows"]),N.push("B;Y"+(C.e.r-C.s.r+1)+";X"+(C.e.c-C.s.c+1)+";D"+[C.s.c,C.s.r,C.e.c,C.e.r].join(" "));for(var O=C.s.r;O<=C.e.r;++O)for(var R=C.s.c;R<=C.e.c;++R){var Y=hr({r:O,c:R});D=T?(j[O]||[])[R]:j[Y],!(!D||D.v==null&&(!D.f||D.F))&&k.push(h(D,j,O,R))}return N.join(E)+E+k.join(E)+E+"E"+E}return{to_workbook:m,to_sheet:d,from_sheet:b}})(),hT=(function(){function t(c,d){switch(d.type){case"base64":return a(Jo(c),d);case"binary":return a(c,d);case"buffer":return a(ir&&Buffer.isBuffer(c)?c.toString("binary"):Su(c),d);case"array":return a(Uh(c),d)}throw new Error("Unrecognized type "+d.type)}function a(c,d){for(var m=c.split(`
`),h=-1,g=-1,p=0,b=[];p!==m.length;++p){if(m[p].trim()==="BOT"){b[++h]=[],g=0;continue}if(!(h<0)){var j=m[p].trim().split(","),_=j[0],N=j[1];++p;for(var k=m[p]||"";(k.match(/["]/g)||[]).length&1&&p<m.length-1;)k+=`
`+m[++p];switch(k=k.trim(),+_){case-1:if(k==="BOT"){b[++h]=[],g=0;continue}else if(k!=="EOD")throw new Error("Unrecognized DIF special command "+k);break;case 0:k==="TRUE"?b[h][g]=!0:k==="FALSE"?b[h][g]=!1:isNaN(Go(N))?isNaN(xu(N).getDate())?b[h][g]=N:b[h][g]=bn(N):b[h][g]=Go(N),++g;break;case 1:k=k.slice(1,k.length-1),k=k.replace(/""/g,'"'),k&&k.match(/^=".*"$/)&&(k=k.slice(2,-1)),b[h][g++]=k!==""?k:null;break}if(k==="EOD")break}}return d&&d.sheetRows&&(b=b.slice(0,d.sheetRows)),b}function r(c,d){return qd(t(c,d),d)}function s(c,d){return Ec(r(c,d),d)}var i=(function(){var c=function(h,g,p,b,j){h.push(g),h.push(p+","+b),h.push('"'+j.replace(/"/g,'""')+'"')},d=function(h,g,p,b){h.push(g+","+p),h.push(g==1?'"'+b.replace(/"/g,'""')+'"':b)};return function(h){var g=[],p=Dr(h["!ref"]),b,j=Array.isArray(h);c(g,"TABLE",0,1,"sheetjs"),c(g,"VECTORS",0,p.e.r-p.s.r+1,""),c(g,"TUPLES",0,p.e.c-p.s.c+1,""),c(g,"DATA",0,0,"");for(var _=p.s.r;_<=p.e.r;++_){d(g,-1,0,"BOT");for(var N=p.s.c;N<=p.e.c;++N){var k=hr({r:_,c:N});if(b=j?(h[_]||[])[N]:h[k],!b){d(g,1,0,"");continue}switch(b.t){case"n":var C=b.w;!C&&b.v!=null&&(C=b.v),C==null?b.f&&!b.F?d(g,1,0,"="+b.f):d(g,1,0,""):d(g,0,C,"V");break;case"b":d(g,0,b.v?1:0,b.v?"TRUE":"FALSE");break;case"s":d(g,1,0,isNaN(b.v)?b.v:'="'+b.v+'"');break;case"d":b.w||(b.w=Al(b.z||Vr[14],Fn(bn(b.v)))),d(g,0,b.w,"V");break;default:d(g,1,0,"")}}}d(g,-1,0,"EOD");var D=`\r
`,T=g.join(D);return T}})();return{to_workbook:s,to_sheet:r,from_sheet:i}})(),Aw=(function(){function t(b){return b.replace(/\\b/g,"\\").replace(/\\c/g,":").replace(/\\n/g,`
`)}function a(b){return b.replace(/\\/g,"\\b").replace(/:/g,"\\c").replace(/\n/g,"\\n")}function r(b,j){for(var _=b.split(`
`),N=-1,k=-1,C=0,D=[];C!==_.length;++C){var T=_[C].trim().split(":");if(T[0]==="cell"){var E=Ss(T[1]);if(D.length<=E.r)for(N=D.length;N<=E.r;++N)D[N]||(D[N]=[]);switch(N=E.r,k=E.c,T[2]){case"t":D[N][k]=t(T[3]);break;case"v":D[N][k]=+T[3];break;case"vtf":var O=T[T.length-1];case"vtc":switch(T[3]){case"nl":D[N][k]=!!+T[4];break;default:D[N][k]=+T[4];break}T[2]=="vtf"&&(D[N][k]=[D[N][k],O])}}}return j&&j.sheetRows&&(D=D.slice(0,j.sheetRows)),D}function s(b,j){return qd(r(b,j),j)}function i(b,j){return Ec(s(b,j),j)}var c=["socialcalc:version:1.5","MIME-Version: 1.0","Content-Type: multipart/mixed; boundary=SocialCalcSpreadsheetControlSave"].join(`
`),d=["--SocialCalcSpreadsheetControlSave","Content-type: text/plain; charset=UTF-8"].join(`
`)+`
`,m=["# SocialCalc Spreadsheet Control Save","part:sheet"].join(`
`),h="--SocialCalcSpreadsheetControlSave--";function g(b){if(!b||!b["!ref"])return"";for(var j=[],_=[],N,k="",C=ni(b["!ref"]),D=Array.isArray(b),T=C.s.r;T<=C.e.r;++T)for(var E=C.s.c;E<=C.e.c;++E)if(k=hr({r:T,c:E}),N=D?(b[T]||[])[E]:b[k],!(!N||N.v==null||N.t==="z")){switch(_=["cell",k,"t"],N.t){case"s":case"str":_.push(a(N.v));break;case"n":N.f?(_[2]="vtf",_[3]="n",_[4]=N.v,_[5]=a(N.f)):(_[2]="v",_[3]=N.v);break;case"b":_[2]="vt"+(N.f?"f":"c"),_[3]="nl",_[4]=N.v?"1":"0",_[5]=a(N.f||(N.v?"TRUE":"FALSE"));break;case"d":var O=Fn(bn(N.v));_[2]="vtc",_[3]="nd",_[4]=""+O,_[5]=N.w||Al(N.z||Vr[14],O);break;case"e":continue}j.push(_.join(":"))}return j.push("sheet:c:"+(C.e.c-C.s.c+1)+":r:"+(C.e.r-C.s.r+1)+":tvf:1"),j.push("valueformat:1:text-wiki"),j.join(`
`)}function p(b){return[c,d,m,d,g(b),h].join(`
`)}return{to_workbook:i,to_sheet:s,from_sheet:p}})(),gT=(function(){function t(p,b,j,_,N){N.raw?b[j][_]=p:p===""||(p==="TRUE"?b[j][_]=!0:p==="FALSE"?b[j][_]=!1:isNaN(Go(p))?isNaN(xu(p).getDate())?b[j][_]=p:b[j][_]=bn(p):b[j][_]=Go(p))}function a(p,b){var j=b||{},_=[];if(!p||p.length===0)return _;for(var N=p.split(/[\r\n]/),k=N.length-1;k>=0&&N[k].length===0;)--k;for(var C=10,D=0,T=0;T<=k;++T)D=N[T].indexOf(" "),D==-1?D=N[T].length:D++,C=Math.max(C,D);for(T=0;T<=k;++T){_[T]=[];var E=0;for(t(N[T].slice(0,C).trim(),_,T,E,j),E=1;E<=(N[T].length-C)/10+1;++E)t(N[T].slice(C+(E-1)*10,C+E*10).trim(),_,T,E,j)}return j.sheetRows&&(_=_.slice(0,j.sheetRows)),_}var r={44:",",9:" ",59:";",124:"|"},s={44:3,9:2,59:1,124:0};function i(p){for(var b={},j=!1,_=0,N=0;_<p.length;++_)(N=p.charCodeAt(_))==34?j=!j:!j&&N in r&&(b[N]=(b[N]||0)+1);N=[];for(_ in b)Object.prototype.hasOwnProperty.call(b,_)&&N.push([b[_],_]);if(!N.length){b=s;for(_ in b)Object.prototype.hasOwnProperty.call(b,_)&&N.push([b[_],_])}return N.sort(function(k,C){return k[0]-C[0]||s[k[1]]-s[C[1]]}),r[N.pop()[1]]||44}function c(p,b){var j=b||{},_="",N=j.dense?[]:{},k={s:{c:0,r:0},e:{c:0,r:0}};p.slice(0,4)=="sep="?p.charCodeAt(5)==13&&p.charCodeAt(6)==10?(_=p.charAt(4),p=p.slice(7)):p.charCodeAt(5)==13||p.charCodeAt(5)==10?(_=p.charAt(4),p=p.slice(6)):_=i(p.slice(0,1024)):j&&j.FS?_=j.FS:_=i(p.slice(0,1024));var C=0,D=0,T=0,E=0,O=0,R=_.charCodeAt(0),Y=!1,P=0,U=p.charCodeAt(0);p=p.replace(/\r\n/mg,`
`);var J=j.dateNF!=null?A6(j.dateNF):null;function ne(){var ye=p.slice(E,O),he={};if(ye.charAt(0)=='"'&&ye.charAt(ye.length-1)=='"'&&(ye=ye.slice(1,-1).replace(/""/g,'"')),ye.length===0)he.t="z";else if(j.raw)he.t="s",he.v=ye;else if(ye.trim().length===0)he.t="s",he.v=ye;else if(ye.charCodeAt(0)==61)ye.charCodeAt(1)==34&&ye.charCodeAt(ye.length-1)==34?(he.t="s",he.v=ye.slice(2,-1).replace(/""/g,'"')):mE(ye)?(he.t="n",he.f=ye.slice(1)):(he.t="s",he.v=ye);else if(ye=="TRUE")he.t="b",he.v=!0;else if(ye=="FALSE")he.t="b",he.v=!1;else if(!isNaN(T=Go(ye)))he.t="n",j.cellText!==!1&&(he.w=ye),he.v=T;else if(!isNaN(xu(ye).getDate())||J&&ye.match(J)){he.z=j.dateNF||Vr[14];var ce=0;J&&ye.match(J)&&(ye=O6(ye,j.dateNF,ye.match(J)||[]),ce=1),j.cellDates?(he.t="d",he.v=bn(ye,ce)):(he.t="n",he.v=Fn(bn(ye,ce))),j.cellText!==!1&&(he.w=Al(he.z,he.v instanceof Date?Fn(he.v):he.v)),j.cellNF||delete he.z}else he.t="s",he.v=ye;if(he.t=="z"||(j.dense?(N[C]||(N[C]=[]),N[C][D]=he):N[hr({c:D,r:C})]=he),E=O+1,U=p.charCodeAt(E),k.e.c<D&&(k.e.c=D),k.e.r<C&&(k.e.r=C),P==R)++D;else if(D=0,++C,j.sheetRows&&j.sheetRows<=C)return!0}e:for(;O<p.length;++O)switch(P=p.charCodeAt(O)){case 34:U===34&&(Y=!Y);break;case R:case 10:case 13:if(!Y&&ne())break e;break}return O-E>0&&ne(),N["!ref"]=ls(k),N}function d(p,b){return!(b&&b.PRN)||b.FS||p.slice(0,4)=="sep="||p.indexOf(" ")>=0||p.indexOf(",")>=0||p.indexOf(";")>=0?c(p,b):qd(a(p,b),b)}function m(p,b){var j="",_=b.type=="string"?[0,0,0,0]:S9(p,b);switch(b.type){case"base64":j=Jo(p);break;case"binary":j=p;break;case"buffer":b.codepage==65001?j=p.toString("utf8"):b.codepage&&typeof xh!="undefined"||(j=ir&&Buffer.isBuffer(p)?p.toString("binary"):Su(p));break;case"array":j=Uh(p);break;case"string":j=p;break;default:throw new Error("Unrecognized type "+b.type)}return _[0]==239&&_[1]==187&&_[2]==191?j=su(j.slice(3)):b.type!="string"&&b.type!="buffer"&&b.codepage==65001?j=su(j):b.type=="binary",j.slice(0,19)=="socialcalc:version:"?Aw.to_sheet(b.type=="string"?j:su(j),b):d(j,b)}function h(p,b){return Ec(m(p,b),b)}function g(p){for(var b=[],j=Dr(p["!ref"]),_,N=Array.isArray(p),k=j.s.r;k<=j.e.r;++k){for(var C=[],D=j.s.c;D<=j.e.c;++D){var T=hr({r:k,c:D});if(_=N?(p[k]||[])[D]:p[T],!_||_.v==null){C.push(" ");continue}for(var E=(_.w||(Xo(_),_.w)||"").slice(0,10);E.length<10;)E+=" ";C.push(E+(D===0?" ":""))}b.push(C.join(""))}return b.join(`
`)}return{to_workbook:h,to_sheet:m,from_sheet:g}})(),a_=(function(){function t(M,B,X){if(M){Qn(M,M.l||0);for(var K=X.Enum||ae;M.l<M.length;){var we=M.read_shift(2),be=K[we]||K[65535],ke=M.read_shift(2),Me=M.l+ke,z=be.f&&be.f(M,ke,X);if(M.l=Me,B(z,be,we))return}}}function a(M,B){switch(B.type){case"base64":return r(Mi(Jo(M)),B);case"binary":return r(Mi(M),B);case"buffer":case"array":return r(M,B)}throw"Unsupported type "+B.type}function r(M,B){if(!M)return M;var X=B||{},K=X.dense?[]:{},we="Sheet1",be="",ke=0,Me={},z=[],Ne=[],Xe={s:{r:0,c:0},e:{r:0,c:0}},gt=X.sheetRows||0;if(M[2]==0&&(M[3]==8||M[3]==9)&&M.length>=16&&M[14]==5&&M[15]===108)throw new Error("Unsupported Works 3 for Mac file");if(M[2]==2)X.Enum=ae,t(M,function(Te,Qt,zt){switch(zt){case 0:X.vers=Te,Te>=4096&&(X.qpro=!0);break;case 6:Xe=Te;break;case 204:Te&&(be=Te);break;case 222:be=Te;break;case 15:case 51:X.qpro||(Te[1].v=Te[1].v.slice(1));case 13:case 14:case 16:zt==14&&(Te[2]&112)==112&&(Te[2]&15)>1&&(Te[2]&15)<15&&(Te[1].z=X.dateNF||Vr[14],X.cellDates&&(Te[1].t="d",Te[1].v=G2(Te[1].v))),X.qpro&&Te[3]>ke&&(K["!ref"]=ls(Xe),Me[we]=K,z.push(we),K=X.dense?[]:{},Xe={s:{r:0,c:0},e:{r:0,c:0}},ke=Te[3],we=be||"Sheet"+(ke+1),be="");var Wt=X.dense?(K[Te[0].r]||[])[Te[0].c]:K[hr(Te[0])];if(Wt){Wt.t=Te[1].t,Wt.v=Te[1].v,Te[1].z!=null&&(Wt.z=Te[1].z),Te[1].f!=null&&(Wt.f=Te[1].f);break}X.dense?(K[Te[0].r]||(K[Te[0].r]=[]),K[Te[0].r][Te[0].c]=Te[1]):K[hr(Te[0])]=Te[1];break}},X);else if(M[2]==26||M[2]==14)X.Enum=F,M[2]==14&&(X.qpro=!0,M.l=0),t(M,function(Te,Qt,zt){switch(zt){case 204:we=Te;break;case 22:Te[1].v=Te[1].v.slice(1);case 23:case 24:case 25:case 37:case 39:case 40:if(Te[3]>ke&&(K["!ref"]=ls(Xe),Me[we]=K,z.push(we),K=X.dense?[]:{},Xe={s:{r:0,c:0},e:{r:0,c:0}},ke=Te[3],we="Sheet"+(ke+1)),gt>0&&Te[0].r>=gt)break;X.dense?(K[Te[0].r]||(K[Te[0].r]=[]),K[Te[0].r][Te[0].c]=Te[1]):K[hr(Te[0])]=Te[1],Xe.e.c<Te[0].c&&(Xe.e.c=Te[0].c),Xe.e.r<Te[0].r&&(Xe.e.r=Te[0].r);break;case 27:Te[14e3]&&(Ne[Te[14e3][0]]=Te[14e3][1]);break;case 1537:Ne[Te[0]]=Te[1],Te[0]==ke&&(we=Te[1]);break}},X);else throw new Error("Unrecognized LOTUS BOF "+M[2]);if(K["!ref"]=ls(Xe),Me[be||we]=K,z.push(be||we),!Ne.length)return{SheetNames:z,Sheets:Me};for(var St={},Ht=[],Mt=0;Mt<Ne.length;++Mt)Me[z[Mt]]?(Ht.push(Ne[Mt]||z[Mt]),St[Ne[Mt]]=Me[Ne[Mt]]||Me[z[Mt]]):(Ht.push(Ne[Mt]),St[Ne[Mt]]={"!ref":"A1"});return{SheetNames:Ht,Sheets:St}}function s(M,B){var X=B||{};if(+X.codepage>=0&&gu(+X.codepage),X.type=="string")throw new Error("Cannot write WK1 to JS string");var K=Ln(),we=Dr(M["!ref"]),be=Array.isArray(M),ke=[];Gt(K,0,c(1030)),Gt(K,6,h(we));for(var Me=Math.min(we.e.r,8191),z=we.s.r;z<=Me;++z)for(var Ne=Ys(z),Xe=we.s.c;Xe<=we.e.c;++Xe){z===we.s.r&&(ke[Xe]=on(Xe));var gt=ke[Xe]+Ne,St=be?(M[z]||[])[Xe]:M[gt];if(!(!St||St.t=="z"))if(St.t=="n")(St.v|0)==St.v&&St.v>=-32768&&St.v<=32767?Gt(K,13,_(z,Xe,St.v)):Gt(K,14,k(z,Xe,St.v));else{var Ht=Xo(St);Gt(K,15,b(z,Xe,Ht.slice(0,239)))}}return Gt(K,1),K.end()}function i(M,B){var X=B||{};if(+X.codepage>=0&&gu(+X.codepage),X.type=="string")throw new Error("Cannot write WK3 to JS string");var K=Ln();Gt(K,0,d(M));for(var we=0,be=0;we<M.SheetNames.length;++we)(M.Sheets[M.SheetNames[we]]||{})["!ref"]&&Gt(K,27,oe(M.SheetNames[we],be++));var ke=0;for(we=0;we<M.SheetNames.length;++we){var Me=M.Sheets[M.SheetNames[we]];if(!(!Me||!Me["!ref"])){for(var z=Dr(Me["!ref"]),Ne=Array.isArray(Me),Xe=[],gt=Math.min(z.e.r,8191),St=z.s.r;St<=gt;++St)for(var Ht=Ys(St),Mt=z.s.c;Mt<=z.e.c;++Mt){St===z.s.r&&(Xe[Mt]=on(Mt));var Te=Xe[Mt]+Ht,Qt=Ne?(Me[St]||[])[Mt]:Me[Te];if(!(!Qt||Qt.t=="z"))if(Qt.t=="n")Gt(K,23,ne(St,Mt,ke,Qt.v));else{var zt=Xo(Qt);Gt(K,22,P(St,Mt,ke,zt.slice(0,239)))}}++ke}}return Gt(K,1),K.end()}function c(M){var B=bt(2);return B.write_shift(2,M),B}function d(M){var B=bt(26);B.write_shift(2,4096),B.write_shift(2,4),B.write_shift(4,0);for(var X=0,K=0,we=0,be=0;be<M.SheetNames.length;++be){var ke=M.SheetNames[be],Me=M.Sheets[ke];if(!(!Me||!Me["!ref"])){++we;var z=ni(Me["!ref"]);X<z.e.r&&(X=z.e.r),K<z.e.c&&(K=z.e.c)}}return X>8191&&(X=8191),B.write_shift(2,X),B.write_shift(1,we),B.write_shift(1,K),B.write_shift(2,0),B.write_shift(2,0),B.write_shift(1,1),B.write_shift(1,2),B.write_shift(4,0),B.write_shift(4,0),B}function m(M,B,X){var K={s:{c:0,r:0},e:{c:0,r:0}};return B==8&&X.qpro?(K.s.c=M.read_shift(1),M.l++,K.s.r=M.read_shift(2),K.e.c=M.read_shift(1),M.l++,K.e.r=M.read_shift(2),K):(K.s.c=M.read_shift(2),K.s.r=M.read_shift(2),B==12&&X.qpro&&(M.l+=2),K.e.c=M.read_shift(2),K.e.r=M.read_shift(2),B==12&&X.qpro&&(M.l+=2),K.s.c==65535&&(K.s.c=K.e.c=K.s.r=K.e.r=0),K)}function h(M){var B=bt(8);return B.write_shift(2,M.s.c),B.write_shift(2,M.s.r),B.write_shift(2,M.e.c),B.write_shift(2,M.e.r),B}function g(M,B,X){var K=[{c:0,r:0},{t:"n",v:0},0,0];return X.qpro&&X.vers!=20768?(K[0].c=M.read_shift(1),K[3]=M.read_shift(1),K[0].r=M.read_shift(2),M.l+=2):(K[2]=M.read_shift(1),K[0].c=M.read_shift(2),K[0].r=M.read_shift(2)),K}function p(M,B,X){var K=M.l+B,we=g(M,B,X);if(we[1].t="s",X.vers==20768){M.l++;var be=M.read_shift(1);return we[1].v=M.read_shift(be,"utf8"),we}return X.qpro&&M.l++,we[1].v=M.read_shift(K-M.l,"cstr"),we}function b(M,B,X){var K=bt(7+X.length);K.write_shift(1,255),K.write_shift(2,B),K.write_shift(2,M),K.write_shift(1,39);for(var we=0;we<K.length;++we){var be=X.charCodeAt(we);K.write_shift(1,be>=128?95:be)}return K.write_shift(1,0),K}function j(M,B,X){var K=g(M,B,X);return K[1].v=M.read_shift(2,"i"),K}function _(M,B,X){var K=bt(7);return K.write_shift(1,255),K.write_shift(2,B),K.write_shift(2,M),K.write_shift(2,X,"i"),K}function N(M,B,X){var K=g(M,B,X);return K[1].v=M.read_shift(8,"f"),K}function k(M,B,X){var K=bt(13);return K.write_shift(1,255),K.write_shift(2,B),K.write_shift(2,M),K.write_shift(8,X,"f"),K}function C(M,B,X){var K=M.l+B,we=g(M,B,X);if(we[1].v=M.read_shift(8,"f"),X.qpro)M.l=K;else{var be=M.read_shift(2);O(M.slice(M.l,M.l+be),we),M.l+=be}return we}function D(M,B,X){var K=B&32768;return B&=-32769,B=(K?M:0)+(B>=8192?B-16384:B),(K?"":"$")+(X?on(B):Ys(B))}var T={51:["FALSE",0],52:["TRUE",0],70:["LEN",1],80:["SUM",69],81:["AVERAGEA",69],82:["COUNTA",69],83:["MINA",69],84:["MAXA",69],111:["T",1]},E=["","","","","","","","","","+","-","*","/","^","=","<>","<=",">=","<",">","","","","","&","","","","","","",""];function O(M,B){Qn(M,0);for(var X=[],K=0,we="",be="",ke="",Me="";M.l<M.length;){var z=M[M.l++];switch(z){case 0:X.push(M.read_shift(8,"f"));break;case 1:be=D(B[0].c,M.read_shift(2),!0),we=D(B[0].r,M.read_shift(2),!1),X.push(be+we);break;case 2:{var Ne=D(B[0].c,M.read_shift(2),!0),Xe=D(B[0].r,M.read_shift(2),!1);be=D(B[0].c,M.read_shift(2),!0),we=D(B[0].r,M.read_shift(2),!1),X.push(Ne+Xe+":"+be+we)}break;case 3:if(M.l<M.length){console.error("WK1 premature formula end");return}break;case 4:X.push("("+X.pop()+")");break;case 5:X.push(M.read_shift(2));break;case 6:{for(var gt="";z=M[M.l++];)gt+=String.fromCharCode(z);X.push('"'+gt.replace(/"/g,'""')+'"')}break;case 8:X.push("-"+X.pop());break;case 23:X.push("+"+X.pop());break;case 22:X.push("NOT("+X.pop()+")");break;case 20:case 21:Me=X.pop(),ke=X.pop(),X.push(["AND","OR"][z-20]+"("+ke+","+Me+")");break;default:if(z<32&&E[z])Me=X.pop(),ke=X.pop(),X.push(ke+E[z]+Me);else if(T[z]){if(K=T[z][1],K==69&&(K=M[M.l++]),K>X.length){console.error("WK1 bad formula parse 0x"+z.toString(16)+":|"+X.join("|")+"|");return}var St=X.slice(-K);X.length-=K,X.push(T[z][0]+"("+St.join(",")+")")}else return z<=7?console.error("WK1 invalid opcode "+z.toString(16)):z<=24?console.error("WK1 unsupported op "+z.toString(16)):z<=30?console.error("WK1 invalid opcode "+z.toString(16)):z<=115?console.error("WK1 unsupported function opcode "+z.toString(16)):console.error("WK1 unrecognized opcode "+z.toString(16))}}X.length==1?B[1].f=""+X[0]:console.error("WK1 bad formula parse |"+X.join("|")+"|")}function R(M){var B=[{c:0,r:0},{t:"n",v:0},0];return B[0].r=M.read_shift(2),B[3]=M[M.l++],B[0].c=M[M.l++],B}function Y(M,B){var X=R(M);return X[1].t="s",X[1].v=M.read_shift(B-4,"cstr"),X}function P(M,B,X,K){var we=bt(6+K.length);we.write_shift(2,M),we.write_shift(1,X),we.write_shift(1,B),we.write_shift(1,39);for(var be=0;be<K.length;++be){var ke=K.charCodeAt(be);we.write_shift(1,ke>=128?95:ke)}return we.write_shift(1,0),we}function U(M,B){var X=R(M);X[1].v=M.read_shift(2);var K=X[1].v>>1;if(X[1].v&1)switch(K&7){case 0:K=(K>>3)*5e3;break;case 1:K=(K>>3)*500;break;case 2:K=(K>>3)/20;break;case 3:K=(K>>3)/200;break;case 4:K=(K>>3)/2e3;break;case 5:K=(K>>3)/2e4;break;case 6:K=(K>>3)/16;break;case 7:K=(K>>3)/64;break}return X[1].v=K,X}function J(M,B){var X=R(M),K=M.read_shift(4),we=M.read_shift(4),be=M.read_shift(2);if(be==65535)return K===0&&we===3221225472?(X[1].t="e",X[1].v=15):K===0&&we===3489660928?(X[1].t="e",X[1].v=42):X[1].v=0,X;var ke=be&32768;return be=(be&32767)-16446,X[1].v=(1-ke*2)*(we*Math.pow(2,be+32)+K*Math.pow(2,be)),X}function ne(M,B,X,K){var we=bt(14);if(we.write_shift(2,M),we.write_shift(1,X),we.write_shift(1,B),K==0)return we.write_shift(4,0),we.write_shift(4,0),we.write_shift(2,65535),we;var be=0,ke=0,Me=0,z=0;return K<0&&(be=1,K=-K),ke=Math.log2(K)|0,K/=Math.pow(2,ke-31),z=K>>>0,(z&2147483648)==0&&(K/=2,++ke,z=K>>>0),K-=z,z|=2147483648,z>>>=0,K*=Math.pow(2,32),Me=K>>>0,we.write_shift(4,Me),we.write_shift(4,z),ke+=16383+(be?32768:0),we.write_shift(2,ke),we}function ye(M,B){var X=J(M);return M.l+=B-14,X}function he(M,B){var X=R(M),K=M.read_shift(4);return X[1].v=K>>6,X}function ce(M,B){var X=R(M),K=M.read_shift(8,"f");return X[1].v=K,X}function se(M,B){var X=ce(M);return M.l+=B-10,X}function ee(M,B){return M[M.l+B-1]==0?M.read_shift(B,"cstr"):""}function te(M,B){var X=M[M.l++];X>B-1&&(X=B-1);for(var K="";K.length<X;)K+=String.fromCharCode(M[M.l++]);return K}function W(M,B,X){if(!(!X.qpro||B<21)){var K=M.read_shift(1);M.l+=17,M.l+=1,M.l+=2;var we=M.read_shift(B-21,"cstr");return[K,we]}}function I(M,B){for(var X={},K=M.l+B;M.l<K;){var we=M.read_shift(2);if(we==14e3){for(X[we]=[0,""],X[we][0]=M.read_shift(2);M[M.l];)X[we][1]+=String.fromCharCode(M[M.l]),M.l++;M.l++}}return X}function oe(M,B){var X=bt(5+M.length);X.write_shift(2,14e3),X.write_shift(2,B);for(var K=0;K<M.length;++K){var we=M.charCodeAt(K);X[X.l++]=we>127?95:we}return X[X.l++]=0,X}var ae={0:{n:"BOF",f:Nw},1:{n:"EOF"},2:{n:"CALCMODE"},3:{n:"CALCORDER"},4:{n:"SPLIT"},5:{n:"SYNC"},6:{n:"RANGE",f:m},7:{n:"WINDOW1"},8:{n:"COLW1"},9:{n:"WINTWO"},10:{n:"COLW2"},11:{n:"NAME"},12:{n:"BLANK"},13:{n:"INTEGER",f:j},14:{n:"NUMBER",f:N},15:{n:"LABEL",f:p},16:{n:"FORMULA",f:C},24:{n:"TABLE"},25:{n:"ORANGE"},26:{n:"PRANGE"},27:{n:"SRANGE"},28:{n:"FRANGE"},29:{n:"KRANGE1"},32:{n:"HRANGE"},35:{n:"KRANGE2"},36:{n:"PROTEC"},37:{n:"FOOTER"},38:{n:"HEADER"},39:{n:"SETUP"},40:{n:"MARGINS"},41:{n:"LABELFMT"},42:{n:"TITLES"},43:{n:"SHEETJS"},45:{n:"GRAPH"},46:{n:"NGRAPH"},47:{n:"CALCCOUNT"},48:{n:"UNFORMATTED"},49:{n:"CURSORW12"},50:{n:"WINDOW"},51:{n:"STRING",f:p},55:{n:"PASSWORD"},56:{n:"LOCKED"},60:{n:"QUERY"},61:{n:"QUERYNAME"},62:{n:"PRINT"},63:{n:"PRINTNAME"},64:{n:"GRAPH2"},65:{n:"GRAPHNAME"},66:{n:"ZOOM"},67:{n:"SYMSPLIT"},68:{n:"NSROWS"},69:{n:"NSCOLS"},70:{n:"RULER"},71:{n:"NNAME"},72:{n:"ACOMM"},73:{n:"AMACRO"},74:{n:"PARSE"},102:{n:"PRANGES??"},103:{n:"RRANGES??"},104:{n:"FNAME??"},105:{n:"MRANGES??"},204:{n:"SHEETNAMECS",f:ee},222:{n:"SHEETNAMELP",f:te},65535:{n:""}},F={0:{n:"BOF"},1:{n:"EOF"},2:{n:"PASSWORD"},3:{n:"CALCSET"},4:{n:"WINDOWSET"},5:{n:"SHEETCELLPTR"},6:{n:"SHEETLAYOUT"},7:{n:"COLUMNWIDTH"},8:{n:"HIDDENCOLUMN"},9:{n:"USERRANGE"},10:{n:"SYSTEMRANGE"},11:{n:"ZEROFORCE"},12:{n:"SORTKEYDIR"},13:{n:"FILESEAL"},14:{n:"DATAFILLNUMS"},15:{n:"PRINTMAIN"},16:{n:"PRINTSTRING"},17:{n:"GRAPHMAIN"},18:{n:"GRAPHSTRING"},19:{n:"??"},20:{n:"ERRCELL"},21:{n:"NACELL"},22:{n:"LABEL16",f:Y},23:{n:"NUMBER17",f:J},24:{n:"NUMBER18",f:U},25:{n:"FORMULA19",f:ye},26:{n:"FORMULA1A"},27:{n:"XFORMAT",f:I},28:{n:"DTLABELMISC"},29:{n:"DTLABELCELL"},30:{n:"GRAPHWINDOW"},31:{n:"CPA"},32:{n:"LPLAUTO"},33:{n:"QUERY"},34:{n:"HIDDENSHEET"},35:{n:"??"},37:{n:"NUMBER25",f:he},38:{n:"??"},39:{n:"NUMBER27",f:ce},40:{n:"FORMULA28",f:se},142:{n:"??"},147:{n:"??"},150:{n:"??"},151:{n:"??"},152:{n:"??"},153:{n:"??"},154:{n:"??"},155:{n:"??"},156:{n:"??"},163:{n:"??"},174:{n:"??"},175:{n:"??"},176:{n:"??"},177:{n:"??"},184:{n:"??"},185:{n:"??"},186:{n:"??"},187:{n:"??"},188:{n:"??"},195:{n:"??"},201:{n:"??"},204:{n:"SHEETNAMECS",f:ee},205:{n:"??"},206:{n:"??"},207:{n:"??"},208:{n:"??"},256:{n:"??"},259:{n:"??"},260:{n:"??"},261:{n:"??"},262:{n:"??"},263:{n:"??"},265:{n:"??"},266:{n:"??"},267:{n:"??"},268:{n:"??"},270:{n:"??"},271:{n:"??"},384:{n:"??"},389:{n:"??"},390:{n:"??"},393:{n:"??"},396:{n:"??"},512:{n:"??"},514:{n:"??"},513:{n:"??"},516:{n:"??"},517:{n:"??"},640:{n:"??"},641:{n:"??"},642:{n:"??"},643:{n:"??"},644:{n:"??"},645:{n:"??"},646:{n:"??"},647:{n:"??"},648:{n:"??"},658:{n:"??"},659:{n:"??"},660:{n:"??"},661:{n:"??"},662:{n:"??"},665:{n:"??"},666:{n:"??"},768:{n:"??"},772:{n:"??"},1537:{n:"SHEETINFOQP",f:W},1600:{n:"??"},1602:{n:"??"},1793:{n:"??"},1794:{n:"??"},1795:{n:"??"},1796:{n:"??"},1920:{n:"??"},2048:{n:"??"},2049:{n:"??"},2052:{n:"??"},2688:{n:"??"},10998:{n:"??"},12849:{n:"??"},28233:{n:"??"},28484:{n:"??"},65535:{n:""}};return{sheet_to_wk1:s,book_to_wk3:i,to_workbook:a}})(),fT=/^\s|\s$|[\t\n\r]/;function Ow(t,a){if(!a.bookSST)return"";var r=[us];r[r.length]=qt("sst",null,{xmlns:Vd[0],count:t.Count,uniqueCount:t.Unique});for(var s=0;s!=t.length;++s)if(t[s]!=null){var i=t[s],c="<si>";i.r?c+=i.r:(c+="<t",i.t||(i.t=""),i.t.match(fT)&&(c+=' xml:space="preserve"'),c+=">"+mr(i.t)+"</t>"),c+="</si>",r[r.length]=c}return r.length>2&&(r[r.length]="</sst>",r[1]=r[1].replace("/>",">")),r.join("")}function xT(t){return[t.read_shift(4),t.read_shift(4)]}function pT(t,a){return a||(a=bt(8)),a.write_shift(4,t.Count),a.write_shift(4,t.Unique),a}var yT=lC;function bT(t){var a=Ln();Lt(a,159,pT(t));for(var r=0;r<t.length;++r)Lt(a,19,yT(t[r]));return Lt(a,160),a.end()}function vT(t){for(var a=[],r=t.split(""),s=0;s<r.length;++s)a[s]=r[s].charCodeAt(0);return a}function Dw(t){var a=0,r,s=vT(t),i=s.length+1,c,d,m,h,g;for(r=kc(i),r[0]=s.length,c=1;c!=i;++c)r[c]=s[c-1];for(c=i-1;c>=0;--c)d=r[c],m=(a&16384)===0?0:1,h=a<<1&32767,g=m|h,a=g^d;return a^52811}var _T=(function(){function t(i,c){switch(c.type){case"base64":return a(Jo(i),c);case"binary":return a(i,c);case"buffer":return a(ir&&Buffer.isBuffer(i)?i.toString("binary"):Su(i),c);case"array":return a(Uh(i),c)}throw new Error("Unrecognized type "+c.type)}function a(i,c){var d=c||{},m=d.dense?[]:{},h=i.match(/\\trowd.*?\\row\b/g);if(!h.length)throw new Error("RTF missing table");var g={s:{c:0,r:0},e:{c:0,r:h.length-1}};return h.forEach(function(p,b){Array.isArray(m)&&(m[b]=[]);for(var j=/\\\w+\b/g,_=0,N,k=-1;N=j.exec(p);){switch(N[0]){case"\\cell":var C=p.slice(_,j.lastIndex-N[0].length);if(C[0]==" "&&(C=C.slice(1)),++k,C.length){var D={v:C,t:"s"};Array.isArray(m)?m[b][k]=D:m[hr({r:b,c:k})]=D}break}_=j.lastIndex}k>g.e.c&&(g.e.c=k)}),m["!ref"]=ls(g),m}function r(i,c){return Ec(t(i,c),c)}function s(i){for(var c=["{\\rtf1\\ansi"],d=Dr(i["!ref"]),m,h=Array.isArray(i),g=d.s.r;g<=d.e.r;++g){c.push("\\trowd\\trautofit1");for(var p=d.s.c;p<=d.e.c;++p)c.push("\\cellx"+(p+1));for(c.push("\\pard\\intbl"),p=d.s.c;p<=d.e.c;++p){var b=hr({r:g,c:p});m=h?(i[g]||[])[p]:i[b],!(!m||m.v==null&&(!m.f||m.F))&&(c.push(" "+(m.w||(Xo(m),m.w))),c.push("\\cell"))}c.push("\\pard\\intbl\\row")}return c.join("")+"}"}return{to_workbook:r,to_sheet:t,from_sheet:s}})();function r_(t){for(var a=0,r=1;a!=3;++a)r=r*256+(t[a]>255?255:t[a]<0?0:t[a]);return r.toString(16).toUpperCase().slice(1)}var wT=6,Yo=wT;function Nh(t){return Math.floor((t+Math.round(128/Yo)/256)*Yo)}function Sh(t){return Math.floor((t-5)/Yo*100+.5)/100}function Ox(t){return Math.round((t*Yo+5)/Yo*256)/256}function hp(t){t.width?(t.wpx=Nh(t.width),t.wch=Sh(t.wpx),t.MDW=Yo):t.wpx?(t.wch=Sh(t.wpx),t.width=Ox(t.wch),t.MDW=Yo):typeof t.wch=="number"&&(t.width=Ox(t.wch),t.wpx=Nh(t.width),t.MDW=Yo),t.customWidth&&delete t.customWidth}var kT=96,Mw=kT;function Ch(t){return t*96/Mw}function Lw(t){return t*Mw/96}function jT(t){var a=["<numFmts>"];return[[5,8],[23,26],[41,44],[50,392]].forEach(function(r){for(var s=r[0];s<=r[1];++s)t[s]!=null&&(a[a.length]=qt("numFmt",null,{numFmtId:s,formatCode:mr(t[s])}))}),a.length===1?"":(a[a.length]="</numFmts>",a[0]=qt("numFmts",null,{count:a.length-2}).replace("/>",">"),a.join(""))}function NT(t){var a=[];return a[a.length]=qt("cellXfs",null),t.forEach(function(r){a[a.length]=qt("xf",null,r)}),a[a.length]="</cellXfs>",a.length===2?"":(a[0]=qt("cellXfs",null,{count:a.length-2}).replace("/>",">"),a.join(""))}function Rw(t,a){var r=[us,qt("styleSheet",null,{xmlns:Vd[0],"xmlns:vt":Ns.vt})],s;return t.SSF&&(s=jT(t.SSF))!=null&&(r[r.length]=s),r[r.length]='<fonts count="1"><font><sz val="12"/><color theme="1"/><name val="Calibri"/><family val="2"/><scheme val="minor"/></font></fonts>',r[r.length]='<fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills>',r[r.length]='<borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders>',r[r.length]='<cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs>',(s=NT(a.cellXfs))&&(r[r.length]=s),r[r.length]='<cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>',r[r.length]='<dxfs count="0"/>',r[r.length]='<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleMedium4"/>',r.length>2&&(r[r.length]="</styleSheet>",r[1]=r[1].replace("/>",">")),r.join("")}function ST(t,a){var r=t.read_shift(2),s=ln(t);return[r,s]}function CT(t,a,r){r||(r=bt(6+4*a.length)),r.write_shift(2,t),Cs(a,r);var s=r.length>r.l?r.slice(0,r.l):r;return r.l==null&&(r.l=r.length),s}function TT(t,a,r){var s={};s.sz=t.read_shift(2)/20;var i=fC(t);i.fItalic&&(s.italic=1),i.fCondense&&(s.condense=1),i.fExtend&&(s.extend=1),i.fShadow&&(s.shadow=1),i.fOutline&&(s.outline=1),i.fStrikeout&&(s.strike=1);var c=t.read_shift(2);switch(c===700&&(s.bold=1),t.read_shift(2)){case 1:s.vertAlign="superscript";break;case 2:s.vertAlign="subscript";break}var d=t.read_shift(1);d!=0&&(s.underline=d);var m=t.read_shift(1);m>0&&(s.family=m);var h=t.read_shift(1);switch(h>0&&(s.charset=h),t.l++,s.color=gC(t),t.read_shift(1)){case 1:s.scheme="major";break;case 2:s.scheme="minor";break}return s.name=ln(t),s}function ET(t,a){a||(a=bt(153)),a.write_shift(2,t.sz*20),xC(t,a),a.write_shift(2,t.bold?700:400);var r=0;t.vertAlign=="superscript"?r=1:t.vertAlign=="subscript"&&(r=2),a.write_shift(2,r),a.write_shift(1,t.underline||0),a.write_shift(1,t.family||0),a.write_shift(1,t.charset||0),a.write_shift(1,0),kh(t.color,a);var s=0;return s=2,a.write_shift(1,s),Cs(t.name,a),a.length>a.l?a.slice(0,a.l):a}var AT=["none","solid","mediumGray","darkGray","lightGray","darkHorizontal","darkVertical","darkDown","darkUp","darkGrid","darkTrellis","lightHorizontal","lightVertical","lightDown","lightUp","lightGrid","lightTrellis","gray125","gray0625"],ix,OT=fo;function s_(t,a){a||(a=bt(84)),ix||(ix=tp(AT));var r=ix[t.patternType];r==null&&(r=40),a.write_shift(4,r);var s=0;if(r!=40)for(kh({auto:1},a),kh({auto:1},a);s<12;++s)a.write_shift(4,0);else{for(;s<4;++s)a.write_shift(4,0);for(;s<12;++s)a.write_shift(4,0)}return a.length>a.l?a.slice(0,a.l):a}function DT(t,a){var r=t.l+a,s=t.read_shift(2),i=t.read_shift(2);return t.l=r,{ixfe:s,numFmtId:i}}function Pw(t,a,r){r||(r=bt(16)),r.write_shift(2,a||0),r.write_shift(2,t.numFmtId||0),r.write_shift(2,0),r.write_shift(2,0),r.write_shift(2,0),r.write_shift(1,0),r.write_shift(1,0);var s=0;return r.write_shift(1,s),r.write_shift(1,0),r.write_shift(1,0),r.write_shift(1,0),r}function V0(t,a){return a||(a=bt(10)),a.write_shift(1,0),a.write_shift(1,0),a.write_shift(4,0),a.write_shift(4,0),a}var MT=fo;function LT(t,a){return a||(a=bt(51)),a.write_shift(1,0),V0(null,a),V0(null,a),V0(null,a),V0(null,a),V0(null,a),a.length>a.l?a.slice(0,a.l):a}function RT(t,a){return a||(a=bt(52)),a.write_shift(4,t.xfId),a.write_shift(2,1),a.write_shift(1,0),a.write_shift(1,0),wh(t.name||"",a),a.length>a.l?a.slice(0,a.l):a}function PT(t,a,r){var s=bt(2052);return s.write_shift(4,t),wh(a,s),wh(r,s),s.length>s.l?s.slice(0,s.l):s}function FT(t,a){if(a){var r=0;[[5,8],[23,26],[41,44],[50,392]].forEach(function(s){for(var i=s[0];i<=s[1];++i)a[i]!=null&&++r}),r!=0&&(Lt(t,615,Ri(r)),[[5,8],[23,26],[41,44],[50,392]].forEach(function(s){for(var i=s[0];i<=s[1];++i)a[i]!=null&&Lt(t,44,CT(i,a[i]))}),Lt(t,616))}}function IT(t){var a=1;Lt(t,611,Ri(a)),Lt(t,43,ET({sz:12,color:{theme:1},name:"Calibri",family:2})),Lt(t,612)}function zT(t){var a=2;Lt(t,603,Ri(a)),Lt(t,45,s_({patternType:"none"})),Lt(t,45,s_({patternType:"gray125"})),Lt(t,604)}function BT(t){var a=1;Lt(t,613,Ri(a)),Lt(t,46,LT()),Lt(t,614)}function UT(t){var a=1;Lt(t,626,Ri(a)),Lt(t,47,Pw({numFmtId:0},65535)),Lt(t,627)}function $T(t,a){Lt(t,617,Ri(a.length)),a.forEach(function(r){Lt(t,47,Pw(r,0))}),Lt(t,618)}function HT(t){var a=1;Lt(t,619,Ri(a)),Lt(t,48,RT({xfId:0,name:"Normal"})),Lt(t,620)}function WT(t){var a=0;Lt(t,505,Ri(a)),Lt(t,506)}function VT(t){var a=0;Lt(t,508,PT(a,"TableStyleMedium9","PivotStyleMedium4")),Lt(t,509)}function qT(t,a){var r=Ln();return Lt(r,278),FT(r,t.SSF),IT(r),zT(r),BT(r),UT(r),$T(r,a.cellXfs),HT(r),WT(r),VT(r),Lt(r,279),r.end()}function Fw(t,a){if(a&&a.themeXLSX)return a.themeXLSX;if(t&&typeof t.raw=="string")return t.raw;var r=[us];return r[r.length]='<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme">',r[r.length]="<a:themeElements>",r[r.length]='<a:clrScheme name="Office">',r[r.length]='<a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1>',r[r.length]='<a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1>',r[r.length]='<a:dk2><a:srgbClr val="1F497D"/></a:dk2>',r[r.length]='<a:lt2><a:srgbClr val="EEECE1"/></a:lt2>',r[r.length]='<a:accent1><a:srgbClr val="4F81BD"/></a:accent1>',r[r.length]='<a:accent2><a:srgbClr val="C0504D"/></a:accent2>',r[r.length]='<a:accent3><a:srgbClr val="9BBB59"/></a:accent3>',r[r.length]='<a:accent4><a:srgbClr val="8064A2"/></a:accent4>',r[r.length]='<a:accent5><a:srgbClr val="4BACC6"/></a:accent5>',r[r.length]='<a:accent6><a:srgbClr val="F79646"/></a:accent6>',r[r.length]='<a:hlink><a:srgbClr val="0000FF"/></a:hlink>',r[r.length]='<a:folHlink><a:srgbClr val="800080"/></a:folHlink>',r[r.length]="</a:clrScheme>",r[r.length]='<a:fontScheme name="Office">',r[r.length]="<a:majorFont>",r[r.length]='<a:latin typeface="Cambria"/>',r[r.length]='<a:ea typeface=""/>',r[r.length]='<a:cs typeface=""/>',r[r.length]='<a:font script="Jpan" typeface=" Pゴシック"/>',r[r.length]='<a:font script="Hang" typeface="맑은 고딕"/>',r[r.length]='<a:font script="Hans" typeface="宋体"/>',r[r.length]='<a:font script="Hant" typeface="新細明體"/>',r[r.length]='<a:font script="Arab" typeface="Times New Roman"/>',r[r.length]='<a:font script="Hebr" typeface="Times New Roman"/>',r[r.length]='<a:font script="Thai" typeface="Tahoma"/>',r[r.length]='<a:font script="Ethi" typeface="Nyala"/>',r[r.length]='<a:font script="Beng" typeface="Vrinda"/>',r[r.length]='<a:font script="Gujr" typeface="Shruti"/>',r[r.length]='<a:font script="Khmr" typeface="MoolBoran"/>',r[r.length]='<a:font script="Knda" typeface="Tunga"/>',r[r.length]='<a:font script="Guru" typeface="Raavi"/>',r[r.length]='<a:font script="Cans" typeface="Euphemia"/>',r[r.length]='<a:font script="Cher" typeface="Plantagenet Cherokee"/>',r[r.length]='<a:font script="Yiii" typeface="Microsoft Yi Baiti"/>',r[r.length]='<a:font script="Tibt" typeface="Microsoft Himalaya"/>',r[r.length]='<a:font script="Thaa" typeface="MV Boli"/>',r[r.length]='<a:font script="Deva" typeface="Mangal"/>',r[r.length]='<a:font script="Telu" typeface="Gautami"/>',r[r.length]='<a:font script="Taml" typeface="Latha"/>',r[r.length]='<a:font script="Syrc" typeface="Estrangelo Edessa"/>',r[r.length]='<a:font script="Orya" typeface="Kalinga"/>',r[r.length]='<a:font script="Mlym" typeface="Kartika"/>',r[r.length]='<a:font script="Laoo" typeface="DokChampa"/>',r[r.length]='<a:font script="Sinh" typeface="Iskoola Pota"/>',r[r.length]='<a:font script="Mong" typeface="Mongolian Baiti"/>',r[r.length]='<a:font script="Viet" typeface="Times New Roman"/>',r[r.length]='<a:font script="Uigh" typeface="Microsoft Uighur"/>',r[r.length]='<a:font script="Geor" typeface="Sylfaen"/>',r[r.length]="</a:majorFont>",r[r.length]="<a:minorFont>",r[r.length]='<a:latin typeface="Calibri"/>',r[r.length]='<a:ea typeface=""/>',r[r.length]='<a:cs typeface=""/>',r[r.length]='<a:font script="Jpan" typeface=" Pゴシック"/>',r[r.length]='<a:font script="Hang" typeface="맑은 고딕"/>',r[r.length]='<a:font script="Hans" typeface="宋体"/>',r[r.length]='<a:font script="Hant" typeface="新細明體"/>',r[r.length]='<a:font script="Arab" typeface="Arial"/>',r[r.length]='<a:font script="Hebr" typeface="Arial"/>',r[r.length]='<a:font script="Thai" typeface="Tahoma"/>',r[r.length]='<a:font script="Ethi" typeface="Nyala"/>',r[r.length]='<a:font script="Beng" typeface="Vrinda"/>',r[r.length]='<a:font script="Gujr" typeface="Shruti"/>',r[r.length]='<a:font script="Khmr" typeface="DaunPenh"/>',r[r.length]='<a:font script="Knda" typeface="Tunga"/>',r[r.length]='<a:font script="Guru" typeface="Raavi"/>',r[r.length]='<a:font script="Cans" typeface="Euphemia"/>',r[r.length]='<a:font script="Cher" typeface="Plantagenet Cherokee"/>',r[r.length]='<a:font script="Yiii" typeface="Microsoft Yi Baiti"/>',r[r.length]='<a:font script="Tibt" typeface="Microsoft Himalaya"/>',r[r.length]='<a:font script="Thaa" typeface="MV Boli"/>',r[r.length]='<a:font script="Deva" typeface="Mangal"/>',r[r.length]='<a:font script="Telu" typeface="Gautami"/>',r[r.length]='<a:font script="Taml" typeface="Latha"/>',r[r.length]='<a:font script="Syrc" typeface="Estrangelo Edessa"/>',r[r.length]='<a:font script="Orya" typeface="Kalinga"/>',r[r.length]='<a:font script="Mlym" typeface="Kartika"/>',r[r.length]='<a:font script="Laoo" typeface="DokChampa"/>',r[r.length]='<a:font script="Sinh" typeface="Iskoola Pota"/>',r[r.length]='<a:font script="Mong" typeface="Mongolian Baiti"/>',r[r.length]='<a:font script="Viet" typeface="Arial"/>',r[r.length]='<a:font script="Uigh" typeface="Microsoft Uighur"/>',r[r.length]='<a:font script="Geor" typeface="Sylfaen"/>',r[r.length]="</a:minorFont>",r[r.length]="</a:fontScheme>",r[r.length]='<a:fmtScheme name="Office">',r[r.length]="<a:fillStyleLst>",r[r.length]='<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>',r[r.length]='<a:gradFill rotWithShape="1">',r[r.length]="<a:gsLst>",r[r.length]='<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs>',r[r.length]='<a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod val="300000"/></a:schemeClr></a:gs>',r[r.length]='<a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs>',r[r.length]="</a:gsLst>",r[r.length]='<a:lin ang="16200000" scaled="1"/>',r[r.length]="</a:gradFill>",r[r.length]='<a:gradFill rotWithShape="1">',r[r.length]="<a:gsLst>",r[r.length]='<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="100000"/><a:shade val="100000"/><a:satMod val="130000"/></a:schemeClr></a:gs>',r[r.length]='<a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="50000"/><a:shade val="100000"/><a:satMod val="350000"/></a:schemeClr></a:gs>',r[r.length]="</a:gsLst>",r[r.length]='<a:lin ang="16200000" scaled="0"/>',r[r.length]="</a:gradFill>",r[r.length]="</a:fillStyleLst>",r[r.length]="<a:lnStyleLst>",r[r.length]='<a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln>',r[r.length]='<a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln>',r[r.length]='<a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln>',r[r.length]="</a:lnStyleLst>",r[r.length]="<a:effectStyleLst>",r[r.length]="<a:effectStyle>",r[r.length]="<a:effectLst>",r[r.length]='<a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw>',r[r.length]="</a:effectLst>",r[r.length]="</a:effectStyle>",r[r.length]="<a:effectStyle>",r[r.length]="<a:effectLst>",r[r.length]='<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw>',r[r.length]="</a:effectLst>",r[r.length]="</a:effectStyle>",r[r.length]="<a:effectStyle>",r[r.length]="<a:effectLst>",r[r.length]='<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw>',r[r.length]="</a:effectLst>",r[r.length]='<a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera><a:lightRig rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d>',r[r.length]='<a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d>',r[r.length]="</a:effectStyle>",r[r.length]="</a:effectStyleLst>",r[r.length]="<a:bgFillStyleLst>",r[r.length]='<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>',r[r.length]='<a:gradFill rotWithShape="1">',r[r.length]="<a:gsLst>",r[r.length]='<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs>',r[r.length]='<a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs>',r[r.length]='<a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs>',r[r.length]="</a:gsLst>",r[r.length]='<a:path path="circle"><a:fillToRect l="50000" t="-80000" r="50000" b="180000"/></a:path>',r[r.length]="</a:gradFill>",r[r.length]='<a:gradFill rotWithShape="1">',r[r.length]="<a:gsLst>",r[r.length]='<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs>',r[r.length]='<a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs>',r[r.length]="</a:gsLst>",r[r.length]='<a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path>',r[r.length]="</a:gradFill>",r[r.length]="</a:bgFillStyleLst>",r[r.length]="</a:fmtScheme>",r[r.length]="</a:themeElements>",r[r.length]="<a:objectDefaults>",r[r.length]="<a:spDef>",r[r.length]='<a:spPr/><a:bodyPr/><a:lstStyle/><a:style><a:lnRef idx="1"><a:schemeClr val="accent1"/></a:lnRef><a:fillRef idx="3"><a:schemeClr val="accent1"/></a:fillRef><a:effectRef idx="2"><a:schemeClr val="accent1"/></a:effectRef><a:fontRef idx="minor"><a:schemeClr val="lt1"/></a:fontRef></a:style>',r[r.length]="</a:spDef>",r[r.length]="<a:lnDef>",r[r.length]='<a:spPr/><a:bodyPr/><a:lstStyle/><a:style><a:lnRef idx="2"><a:schemeClr val="accent1"/></a:lnRef><a:fillRef idx="0"><a:schemeClr val="accent1"/></a:fillRef><a:effectRef idx="1"><a:schemeClr val="accent1"/></a:effectRef><a:fontRef idx="minor"><a:schemeClr val="tx1"/></a:fontRef></a:style>',r[r.length]="</a:lnDef>",r[r.length]="</a:objectDefaults>",r[r.length]="<a:extraClrSchemeLst/>",r[r.length]="</a:theme>",r.join("")}function GT(t,a){return{flags:t.read_shift(4),version:t.read_shift(4),name:ln(t)}}function YT(t){var a=bt(12+2*t.name.length);return a.write_shift(4,t.flags),a.write_shift(4,t.version),Cs(t.name,a),a.slice(0,a.l)}function ZT(t){for(var a=[],r=t.read_shift(4);r-- >0;)a.push([t.read_shift(4),t.read_shift(4)]);return a}function JT(t){var a=bt(4+8*t.length);a.write_shift(4,t.length);for(var r=0;r<t.length;++r)a.write_shift(4,t[r][0]),a.write_shift(4,t[r][1]);return a}function XT(t,a){var r=bt(8+2*a.length);return r.write_shift(4,t),Cs(a,r),r.slice(0,r.l)}function KT(t){return t.l+=4,t.read_shift(4)!=0}function QT(t,a){var r=bt(8);return r.write_shift(4,t),r.write_shift(4,1),r}function eE(){var t=Ln();return Lt(t,332),Lt(t,334,Ri(1)),Lt(t,335,YT({name:"XLDAPR",version:12e4,flags:3496657072})),Lt(t,336),Lt(t,339,XT(1,"XLDAPR")),Lt(t,52),Lt(t,35,Ri(514)),Lt(t,4096,Ri(0)),Lt(t,4097,yi(1)),Lt(t,36),Lt(t,53),Lt(t,340),Lt(t,337,QT(1)),Lt(t,51,JT([[1,0]])),Lt(t,338),Lt(t,333),t.end()}function Iw(){var t=[us];return t.push(`<metadata xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:xlrd="http://schemas.microsoft.com/office/spreadsheetml/2017/richdata" xmlns:xda="http://schemas.microsoft.com/office/spreadsheetml/2017/dynamicarray">
<metadataTypes count="1">
<metadataType name="XLDAPR" minSupportedVersion="120000" copy="1" pasteAll="1" pasteValues="1" merge="1" splitFirst="1" rowColShift="1" clearFormats="1" clearComments="1" assign="1" coerce="1" cellMeta="1"/>
</metadataTypes>
<futureMetadata name="XLDAPR" count="1">
<bk>
<extLst>
<ext uri="{bdbb8cdc-fa1e-496e-a857-3c3f30c029c3}">
<xda:dynamicArrayProperties fDynamic="1" fCollapsed="0"/>
</ext>
</extLst>
</bk>
</futureMetadata>
<cellMetadata count="1">
<bk>
<rc t="1" v="0"/>
</bk>
</cellMetadata>
</metadata>`),t.join("")}function tE(t){var a={};a.i=t.read_shift(4);var r={};r.r=t.read_shift(4),r.c=t.read_shift(4),a.r=hr(r);var s=t.read_shift(1);return s&2&&(a.l="1"),s&8&&(a.a="1"),a}var Ad=1024;function zw(t,a){for(var r=[21600,21600],s=["m0,0l0",r[1],r[0],r[1],r[0],"0xe"].join(","),i=[qt("xml",null,{"xmlns:v":ti.v,"xmlns:o":ti.o,"xmlns:x":ti.x,"xmlns:mv":ti.mv}).replace(/\/>/,">"),qt("o:shapelayout",qt("o:idmap",null,{"v:ext":"edit",data:t}),{"v:ext":"edit"}),qt("v:shapetype",[qt("v:stroke",null,{joinstyle:"miter"}),qt("v:path",null,{gradientshapeok:"t","o:connecttype":"rect"})].join(""),{id:"_x0000_t202","o:spt":202,coordsize:r.join(","),path:s})];Ad<t*1e3;)Ad+=1e3;return a.forEach(function(c){var d=Ss(c[0]),m={color2:"#BEFF82",type:"gradient"};m.type=="gradient"&&(m.angle="-180");var h=m.type=="gradient"?qt("o:fill",null,{type:"gradientUnscaled","v:ext":"view"}):null,g=qt("v:fill",h,m),p={on:"t",obscured:"t"};++Ad,i=i.concat(["<v:shape"+yu({id:"_x0000_s"+Ad,type:"#_x0000_t202",style:"position:absolute; margin-left:80pt;margin-top:5pt;width:104pt;height:64pt;z-index:10"+(c[1].hidden?";visibility:hidden":""),fillcolor:"#ECFAD4",strokecolor:"#edeaa1"})+">",g,qt("v:shadow",null,p),qt("v:path",null,{"o:connecttype":"none"}),'<v:textbox><div style="text-align:left"></div></v:textbox>','<x:ClientData ObjectType="Note">',"<x:MoveWithCells/>","<x:SizeWithCells/>",Gs("x:Anchor",[d.c+1,0,d.r+1,0,d.c+3,20,d.r+5,20].join(",")),Gs("x:AutoFill","False"),Gs("x:Row",String(d.r)),Gs("x:Column",String(d.c)),c[1].hidden?"":"<x:Visible/>","</x:ClientData>","</v:shape>"])}),i.push("</xml>"),i.join("")}function Bw(t){var a=[us,qt("comments",null,{xmlns:Vd[0]})],r=[];return a.push("<authors>"),t.forEach(function(s){s[1].forEach(function(i){var c=mr(i.a);r.indexOf(c)==-1&&(r.push(c),a.push("<author>"+c+"</author>")),i.T&&i.ID&&r.indexOf("tc="+i.ID)==-1&&(r.push("tc="+i.ID),a.push("<author>tc="+i.ID+"</author>"))})}),r.length==0&&(r.push("SheetJ5"),a.push("<author>SheetJ5</author>")),a.push("</authors>"),a.push("<commentList>"),t.forEach(function(s){var i=0,c=[];if(s[1][0]&&s[1][0].T&&s[1][0].ID?i=r.indexOf("tc="+s[1][0].ID):s[1].forEach(function(h){h.a&&(i=r.indexOf(mr(h.a))),c.push(h.t||"")}),a.push('<comment ref="'+s[0]+'" authorId="'+i+'"><text>'),c.length<=1)a.push(Gs("t",mr(c[0]||"")));else{for(var d=`Comment:
`+c[0]+`
`,m=1;m<c.length;++m)d+=`Reply:
`+c[m]+`
`;a.push(Gs("t",mr(d)))}a.push("</text></comment>")}),a.push("</commentList>"),a.length>2&&(a[a.length]="</comments>",a[1]=a[1].replace("/>",">")),a.join("")}function aE(t,a,r){var s=[us,qt("ThreadedComments",null,{xmlns:Ns.TCMNT}).replace(/[\/]>/,">")];return t.forEach(function(i){var c="";(i[1]||[]).forEach(function(d,m){if(!d.T){delete d.ID;return}d.a&&a.indexOf(d.a)==-1&&a.push(d.a);var h={ref:i[0],id:"{54EE7951-7262-4200-6969-"+("000000000000"+r.tcid++).slice(-12)+"}"};m==0?c=h.id:h.parentId=c,d.ID=h.id,d.a&&(h.personId="{54EE7950-7262-4200-6969-"+("000000000000"+a.indexOf(d.a)).slice(-12)+"}"),s.push(qt("threadedComment",Gs("text",d.t||""),h))})}),s.push("</ThreadedComments>"),s.join("")}function rE(t){var a=[us,qt("personList",null,{xmlns:Ns.TCMNT,"xmlns:x":Vd[0]}).replace(/[\/]>/,">")];return t.forEach(function(r,s){a.push(qt("person",null,{displayName:r,id:"{54EE7950-7262-4200-6969-"+("000000000000"+s).slice(-12)+"}",userId:r,providerId:"None"}))}),a.push("</personList>"),a.join("")}function sE(t){var a={};a.iauthor=t.read_shift(4);var r=Mc(t);return a.rfx=r.s,a.ref=hr(r.s),t.l+=16,a}function nE(t,a){return a==null&&(a=bt(36)),a.write_shift(4,t[1].iauthor),Gd(t[0],a),a.write_shift(4,0),a.write_shift(4,0),a.write_shift(4,0),a.write_shift(4,0),a}var iE=ln;function oE(t){return Cs(t.slice(0,54))}function lE(t){var a=Ln(),r=[];return Lt(a,628),Lt(a,630),t.forEach(function(s){s[1].forEach(function(i){r.indexOf(i.a)>-1||(r.push(i.a.slice(0,54)),Lt(a,632,oE(i.a)))})}),Lt(a,631),Lt(a,633),t.forEach(function(s){s[1].forEach(function(i){i.iauthor=r.indexOf(i.a);var c={s:Ss(s[0]),e:Ss(s[0])};Lt(a,635,nE([c,i])),i.t&&i.t.length>0&&Lt(a,637,dC(i)),Lt(a,636),delete i.iauthor})}),Lt(a,634),Lt(a,629),a.end()}function cE(t,a){a.FullPaths.forEach(function(r,s){if(s!=0){var i=r.replace(/[^\/]*[\/]/,"/_VBA_PROJECT_CUR/");i.slice(-1)!=="/"&&vr.utils.cfb_add(t,i,a.FileIndex[s].content)}})}var Uw=["xlsb","xlsm","xlam","biff8","xla"],dE=(function(){var t=/(^|[^A-Za-z_])R(\[?-?\d+\]|[1-9]\d*|)C(\[?-?\d+\]|[1-9]\d*|)(?![A-Za-z0-9_])/g,a={r:0,c:0};function r(s,i,c,d){var m=!1,h=!1;c.length==0?h=!0:c.charAt(0)=="["&&(h=!0,c=c.slice(1,-1)),d.length==0?m=!0:d.charAt(0)=="["&&(m=!0,d=d.slice(1,-1));var g=c.length>0?parseInt(c,10)|0:0,p=d.length>0?parseInt(d,10)|0:0;return m?p+=a.c:--p,h?g+=a.r:--g,i+(m?"":"$")+on(p)+(h?"":"$")+Ys(g)}return function(i,c){return a=c,i.replace(t,r)}})(),gp=/(^|[^._A-Z0-9])([$]?)([A-Z]{1,2}|[A-W][A-Z]{2}|X[A-E][A-Z]|XF[A-D])([$]?)(10[0-3]\d{4}|104[0-7]\d{3}|1048[0-4]\d{2}|10485[0-6]\d|104857[0-6]|[1-9]\d{0,5})(?![_.\(A-Za-z0-9])/g,fp=(function(){return function(a,r){return a.replace(gp,function(s,i,c,d,m,h){var g=lp(d)-(c?0:r.c),p=op(h)-(m?0:r.r),b=p==0?"":m?p+1:"["+p+"]",j=g==0?"":c?g+1:"["+g+"]";return i+"R"+b+"C"+j})}})();function uE(t,a){return t.replace(gp,function(r,s,i,c,d,m){return s+(i=="$"?i+c:on(lp(c)+a.c))+(d=="$"?d+m:Ys(op(m)+a.r))})}function mE(t){return t.length!=1}function os(t){t.l+=1}function Ol(t,a){var r=t.read_shift(2);return[r&16383,r>>14&1,r>>15&1]}function $w(t,a,r){var s=2;if(r){if(r.biff>=2&&r.biff<=5)return Hw(t);r.biff==12&&(s=4)}var i=t.read_shift(s),c=t.read_shift(s),d=Ol(t),m=Ol(t);return{s:{r:i,c:d[0],cRel:d[1],rRel:d[2]},e:{r:c,c:m[0],cRel:m[1],rRel:m[2]}}}function Hw(t){var a=Ol(t),r=Ol(t),s=t.read_shift(1),i=t.read_shift(1);return{s:{r:a[0],c:s,cRel:a[1],rRel:a[2]},e:{r:r[0],c:i,cRel:r[1],rRel:r[2]}}}function hE(t,a,r){if(r.biff<8)return Hw(t);var s=t.read_shift(r.biff==12?4:2),i=t.read_shift(r.biff==12?4:2),c=Ol(t),d=Ol(t);return{s:{r:s,c:c[0],cRel:c[1],rRel:c[2]},e:{r:i,c:d[0],cRel:d[1],rRel:d[2]}}}function Ww(t,a,r){if(r&&r.biff>=2&&r.biff<=5)return gE(t);var s=t.read_shift(r&&r.biff==12?4:2),i=Ol(t);return{r:s,c:i[0],cRel:i[1],rRel:i[2]}}function gE(t){var a=Ol(t),r=t.read_shift(1);return{r:a[0],c:r,cRel:a[1],rRel:a[2]}}function fE(t){var a=t.read_shift(2),r=t.read_shift(2);return{r:a,c:r&255,fQuoted:!!(r&16384),cRel:r>>15,rRel:r>>15}}function xE(t,a,r){var s=r&&r.biff?r.biff:8;if(s>=2&&s<=5)return pE(t);var i=t.read_shift(s>=12?4:2),c=t.read_shift(2),d=(c&16384)>>14,m=(c&32768)>>15;if(c&=16383,m==1)for(;i>524287;)i-=1048576;if(d==1)for(;c>8191;)c=c-16384;return{r:i,c,cRel:d,rRel:m}}function pE(t){var a=t.read_shift(2),r=t.read_shift(1),s=(a&32768)>>15,i=(a&16384)>>14;return a&=16383,s==1&&a>=8192&&(a=a-16384),i==1&&r>=128&&(r=r-256),{r:a,c:r,cRel:i,rRel:s}}function yE(t,a,r){var s=(t[t.l++]&96)>>5,i=$w(t,r.biff>=2&&r.biff<=5?6:8,r);return[s,i]}function bE(t,a,r){var s=(t[t.l++]&96)>>5,i=t.read_shift(2,"i"),c=8;if(r)switch(r.biff){case 5:t.l+=12,c=6;break;case 12:c=12;break}var d=$w(t,c,r);return[s,i,d]}function vE(t,a,r){var s=(t[t.l++]&96)>>5;return t.l+=r&&r.biff>8?12:r.biff<8?6:8,[s]}function _E(t,a,r){var s=(t[t.l++]&96)>>5,i=t.read_shift(2),c=8;if(r)switch(r.biff){case 5:t.l+=12,c=6;break;case 12:c=12;break}return t.l+=c,[s,i]}function wE(t,a,r){var s=(t[t.l++]&96)>>5,i=hE(t,a-1,r);return[s,i]}function kE(t,a,r){var s=(t[t.l++]&96)>>5;return t.l+=r.biff==2?6:r.biff==12?14:7,[s]}function n_(t){var a=t[t.l+1]&1,r=1;return t.l+=4,[a,r]}function jE(t,a,r){t.l+=2;for(var s=t.read_shift(r&&r.biff==2?1:2),i=[],c=0;c<=s;++c)i.push(t.read_shift(r&&r.biff==2?1:2));return i}function NE(t,a,r){var s=t[t.l+1]&255?1:0;return t.l+=2,[s,t.read_shift(r&&r.biff==2?1:2)]}function SE(t,a,r){var s=t[t.l+1]&255?1:0;return t.l+=2,[s,t.read_shift(r&&r.biff==2?1:2)]}function CE(t){var a=t[t.l+1]&255?1:0;return t.l+=2,[a,t.read_shift(2)]}function TE(t,a,r){var s=t[t.l+1]&255?1:0;return t.l+=r&&r.biff==2?3:4,[s]}function Vw(t){var a=t.read_shift(1),r=t.read_shift(1);return[a,r]}function EE(t){return t.read_shift(2),Vw(t)}function AE(t){return t.read_shift(2),Vw(t)}function OE(t,a,r){var s=(t[t.l]&96)>>5;t.l+=1;var i=Ww(t,0,r);return[s,i]}function DE(t,a,r){var s=(t[t.l]&96)>>5;t.l+=1;var i=xE(t,0,r);return[s,i]}function ME(t,a,r){var s=(t[t.l]&96)>>5;t.l+=1;var i=t.read_shift(2);r&&r.biff==5&&(t.l+=12);var c=Ww(t,0,r);return[s,i,c]}function LE(t,a,r){var s=(t[t.l]&96)>>5;t.l+=1;var i=t.read_shift(r&&r.biff<=3?1:2);return[L7[i],Yw[i],s]}function RE(t,a,r){var s=t[t.l++],i=t.read_shift(1),c=r&&r.biff<=3?[s==88?-1:0,t.read_shift(1)]:PE(t);return[i,(c[0]===0?Yw:M7)[c[1]]]}function PE(t){return[t[t.l+1]>>7,t.read_shift(2)&32767]}function FE(t,a,r){t.l+=r&&r.biff==2?3:4}function IE(t,a,r){if(t.l++,r&&r.biff==12)return[t.read_shift(4,"i"),0];var s=t.read_shift(2),i=t.read_shift(r&&r.biff==2?1:2);return[s,i]}function zE(t){return t.l++,Eu[t.read_shift(1)]}function BE(t){return t.l++,t.read_shift(2)}function UE(t){return t.l++,t.read_shift(1)!==0}function $E(t){return t.l++,Yd(t)}function HE(t,a,r){return t.l++,Cw(t,a-1,r)}function WE(t,a){var r=[t.read_shift(1)];if(a==12)switch(r[0]){case 2:r[0]=4;break;case 4:r[0]=16;break;case 0:r[0]=1;break;case 1:r[0]=2;break}switch(r[0]){case 4:r[1]=MC(t,1)?"TRUE":"FALSE",a!=12&&(t.l+=7);break;case 37:case 16:r[1]=Eu[t[t.l]],t.l+=a==12?4:8;break;case 0:t.l+=8;break;case 1:r[1]=Yd(t);break;case 2:r[1]=FC(t,0,{biff:a>0&&a<8?2:a});break;default:throw new Error("Bad SerAr: "+r[0])}return r}function VE(t,a,r){for(var s=t.read_shift(r.biff==12?4:2),i=[],c=0;c!=s;++c)i.push((r.biff==12?Mc:BC)(t));return i}function qE(t,a,r){var s=0,i=0;r.biff==12?(s=t.read_shift(4),i=t.read_shift(4)):(i=1+t.read_shift(1),s=1+t.read_shift(2)),r.biff>=2&&r.biff<8&&(--s,--i==0&&(i=256));for(var c=0,d=[];c!=s&&(d[c]=[]);++c)for(var m=0;m!=i;++m)d[c][m]=WE(t,r.biff);return d}function GE(t,a,r){var s=t.read_shift(1)>>>5&3,i=!r||r.biff>=8?4:2,c=t.read_shift(i);switch(r.biff){case 2:t.l+=5;break;case 3:case 4:t.l+=8;break;case 5:t.l+=12;break}return[s,0,c]}function YE(t,a,r){if(r.biff==5)return ZE(t);var s=t.read_shift(1)>>>5&3,i=t.read_shift(2),c=t.read_shift(4);return[s,i,c]}function ZE(t){var a=t.read_shift(1)>>>5&3,r=t.read_shift(2,"i");t.l+=8;var s=t.read_shift(2);return t.l+=12,[a,r,s]}function JE(t,a,r){var s=t.read_shift(1)>>>5&3;t.l+=r&&r.biff==2?3:4;var i=t.read_shift(r&&r.biff==2?1:2);return[s,i]}function XE(t,a,r){var s=t.read_shift(1)>>>5&3,i=t.read_shift(r&&r.biff==2?1:2);return[s,i]}function KE(t,a,r){var s=t.read_shift(1)>>>5&3;return t.l+=4,r.biff<8&&t.l--,r.biff==12&&(t.l+=2),[s]}function QE(t,a,r){var s=(t[t.l++]&96)>>5,i=t.read_shift(2),c=4;if(r)switch(r.biff){case 5:c=15;break;case 12:c=6;break}return t.l+=c,[s,i]}var e7=fo,t7=fo,a7=fo;function Au(t,a,r){return t.l+=2,[fE(t)]}function xp(t){return t.l+=6,[]}var r7=Au,s7=xp,n7=xp,i7=Au;function qw(t){return t.l+=2,[Nw(t),t.read_shift(2)&1]}var o7=Au,l7=qw,c7=xp,d7=Au,u7=Au,m7=["Data","All","Headers","??","?Data2","??","?DataHeaders","??","Totals","??","??","??","?DataTotals","??","??","??","?Current"];function h7(t){t.l+=2;var a=t.read_shift(2),r=t.read_shift(2),s=t.read_shift(4),i=t.read_shift(2),c=t.read_shift(2),d=m7[r>>2&31];return{ixti:a,coltype:r&3,rt:d,idx:s,c:i,C:c}}function g7(t){return t.l+=2,[t.read_shift(4)]}function f7(t,a,r){return t.l+=5,t.l+=2,t.l+=r.biff==2?1:4,["PTGSHEET"]}function x7(t,a,r){return t.l+=r.biff==2?4:5,["PTGENDSHEET"]}function p7(t){var a=t.read_shift(1)>>>5&3,r=t.read_shift(2);return[a,r]}function y7(t){var a=t.read_shift(1)>>>5&3,r=t.read_shift(2);return[a,r]}function b7(t){return t.l+=4,[0,0]}var i_={1:{n:"PtgExp",f:IE},2:{n:"PtgTbl",f:a7},3:{n:"PtgAdd",f:os},4:{n:"PtgSub",f:os},5:{n:"PtgMul",f:os},6:{n:"PtgDiv",f:os},7:{n:"PtgPower",f:os},8:{n:"PtgConcat",f:os},9:{n:"PtgLt",f:os},10:{n:"PtgLe",f:os},11:{n:"PtgEq",f:os},12:{n:"PtgGe",f:os},13:{n:"PtgGt",f:os},14:{n:"PtgNe",f:os},15:{n:"PtgIsect",f:os},16:{n:"PtgUnion",f:os},17:{n:"PtgRange",f:os},18:{n:"PtgUplus",f:os},19:{n:"PtgUminus",f:os},20:{n:"PtgPercent",f:os},21:{n:"PtgParen",f:os},22:{n:"PtgMissArg",f:os},23:{n:"PtgStr",f:HE},26:{n:"PtgSheet",f:f7},27:{n:"PtgEndSheet",f:x7},28:{n:"PtgErr",f:zE},29:{n:"PtgBool",f:UE},30:{n:"PtgInt",f:BE},31:{n:"PtgNum",f:$E},32:{n:"PtgArray",f:kE},33:{n:"PtgFunc",f:LE},34:{n:"PtgFuncVar",f:RE},35:{n:"PtgName",f:GE},36:{n:"PtgRef",f:OE},37:{n:"PtgArea",f:yE},38:{n:"PtgMemArea",f:JE},39:{n:"PtgMemErr",f:e7},40:{n:"PtgMemNoMem",f:t7},41:{n:"PtgMemFunc",f:XE},42:{n:"PtgRefErr",f:KE},43:{n:"PtgAreaErr",f:vE},44:{n:"PtgRefN",f:DE},45:{n:"PtgAreaN",f:wE},46:{n:"PtgMemAreaN",f:p7},47:{n:"PtgMemNoMemN",f:y7},57:{n:"PtgNameX",f:YE},58:{n:"PtgRef3d",f:ME},59:{n:"PtgArea3d",f:bE},60:{n:"PtgRefErr3d",f:QE},61:{n:"PtgAreaErr3d",f:_E},255:{}},v7={64:32,96:32,65:33,97:33,66:34,98:34,67:35,99:35,68:36,100:36,69:37,101:37,70:38,102:38,71:39,103:39,72:40,104:40,73:41,105:41,74:42,106:42,75:43,107:43,76:44,108:44,77:45,109:45,78:46,110:46,79:47,111:47,88:34,120:34,89:57,121:57,90:58,122:58,91:59,123:59,92:60,124:60,93:61,125:61},_7={1:{n:"PtgElfLel",f:qw},2:{n:"PtgElfRw",f:d7},3:{n:"PtgElfCol",f:r7},6:{n:"PtgElfRwV",f:u7},7:{n:"PtgElfColV",f:i7},10:{n:"PtgElfRadical",f:o7},11:{n:"PtgElfRadicalS",f:c7},13:{n:"PtgElfColS",f:s7},15:{n:"PtgElfColSV",f:n7},16:{n:"PtgElfRadicalLel",f:l7},25:{n:"PtgList",f:h7},29:{n:"PtgSxName",f:g7},255:{}},w7={0:{n:"PtgAttrNoop",f:b7},1:{n:"PtgAttrSemi",f:TE},2:{n:"PtgAttrIf",f:SE},4:{n:"PtgAttrChoose",f:jE},8:{n:"PtgAttrGoto",f:NE},16:{n:"PtgAttrSum",f:FE},32:{n:"PtgAttrBaxcel",f:n_},33:{n:"PtgAttrBaxcel",f:n_},64:{n:"PtgAttrSpace",f:EE},65:{n:"PtgAttrSpaceSemi",f:AE},128:{n:"PtgAttrIfError",f:CE},255:{}};function k7(t,a,r,s){if(s.biff<8)return fo(t,a);for(var i=t.l+a,c=[],d=0;d!==r.length;++d)switch(r[d][0]){case"PtgArray":r[d][1]=qE(t,0,s),c.push(r[d][1]);break;case"PtgMemArea":r[d][2]=VE(t,r[d][1],s),c.push(r[d][2]);break;case"PtgExp":s&&s.biff==12&&(r[d][1][1]=t.read_shift(4),c.push(r[d][1]));break;case"PtgList":case"PtgElfRadicalS":case"PtgElfColS":case"PtgElfColSV":throw"Unsupported "+r[d][0]}return a=i-t.l,a!==0&&c.push(fo(t,a)),c}function j7(t,a,r){for(var s=t.l+a,i,c,d=[];s!=t.l;)a=s-t.l,c=t[t.l],i=i_[c]||i_[v7[c]],(c===24||c===25)&&(i=(c===24?_7:w7)[t[t.l+1]]),!i||!i.f?fo(t,a):d.push([i.n,i.f(t,a,r)]);return d}function N7(t){for(var a=[],r=0;r<t.length;++r){for(var s=t[r],i=[],c=0;c<s.length;++c){var d=s[c];if(d)switch(d[0]){case 2:i.push('"'+d[1].replace(/"/g,'""')+'"');break;default:i.push(d[1])}else i.push("")}a.push(i.join(","))}return a.join(";")}var S7={PtgAdd:"+",PtgConcat:"&",PtgDiv:"/",PtgEq:"=",PtgGe:">=",PtgGt:">",PtgLe:"<=",PtgLt:"<",PtgMul:"*",PtgNe:"<>",PtgPower:"^",PtgSub:"-"};function C7(t,a){if(!t&&!(a&&a.biff<=5&&a.biff>=2))throw new Error("empty sheet name");return/[^\w\u4E00-\u9FFF\u3040-\u30FF]/.test(t)?"'"+t+"'":t}function Gw(t,a,r){if(!t)return"SH33TJSERR0";if(r.biff>8&&(!t.XTI||!t.XTI[a]))return t.SheetNames[a];if(!t.XTI)return"SH33TJSERR6";var s=t.XTI[a];if(r.biff<8)return a>1e4&&(a-=65536),a<0&&(a=-a),a==0?"":t.XTI[a-1];if(!s)return"SH33TJSERR1";var i="";if(r.biff>8)switch(t[s[0]][0]){case 357:return i=s[1]==-1?"#REF":t.SheetNames[s[1]],s[1]==s[2]?i:i+":"+t.SheetNames[s[2]];case 358:return r.SID!=null?t.SheetNames[r.SID]:"SH33TJSSAME"+t[s[0]][0];case 355:default:return"SH33TJSSRC"+t[s[0]][0]}switch(t[s[0]][0][0]){case 1025:return i=s[1]==-1?"#REF":t.SheetNames[s[1]]||"SH33TJSERR3",s[1]==s[2]?i:i+":"+t.SheetNames[s[2]];case 14849:return t[s[0]].slice(1).map(function(c){return c.Name}).join(";;");default:return t[s[0]][0][3]?(i=s[1]==-1?"#REF":t[s[0]][0][3][s[1]]||"SH33TJSERR4",s[1]==s[2]?i:i+":"+t[s[0]][0][3][s[2]]):"SH33TJSERR2"}}function o_(t,a,r){var s=Gw(t,a,r);return s=="#REF"?s:C7(s,r)}function zd(t,a,r,s,i){var c=i&&i.biff||8,d={s:{c:0,r:0}},m=[],h,g,p,b=0,j=0,_,N="";if(!t[0]||!t[0][0])return"";for(var k=-1,C="",D=0,T=t[0].length;D<T;++D){var E=t[0][D];switch(E[0]){case"PtgUminus":m.push("-"+m.pop());break;case"PtgUplus":m.push("+"+m.pop());break;case"PtgPercent":m.push(m.pop()+"%");break;case"PtgAdd":case"PtgConcat":case"PtgDiv":case"PtgEq":case"PtgGe":case"PtgGt":case"PtgLe":case"PtgLt":case"PtgMul":case"PtgNe":case"PtgPower":case"PtgSub":if(h=m.pop(),g=m.pop(),k>=0){switch(t[0][k][1][0]){case 0:C=Wr(" ",t[0][k][1][1]);break;case 1:C=Wr("\r",t[0][k][1][1]);break;default:if(C="",i.WTF)throw new Error("Unexpected PtgAttrSpaceType "+t[0][k][1][0])}g=g+C,k=-1}m.push(g+S7[E[0]]+h);break;case"PtgIsect":h=m.pop(),g=m.pop(),m.push(g+" "+h);break;case"PtgUnion":h=m.pop(),g=m.pop(),m.push(g+","+h);break;case"PtgRange":h=m.pop(),g=m.pop(),m.push(g+":"+h);break;case"PtgAttrChoose":break;case"PtgAttrGoto":break;case"PtgAttrIf":break;case"PtgAttrIfError":break;case"PtgRef":p=iu(E[1][1],d,i),m.push(ou(p,c));break;case"PtgRefN":p=r?iu(E[1][1],r,i):E[1][1],m.push(ou(p,c));break;case"PtgRef3d":b=E[1][1],p=iu(E[1][2],d,i),N=o_(s,b,i),m.push(N+"!"+ou(p,c));break;case"PtgFunc":case"PtgFuncVar":var O=E[1][0],R=E[1][1];O||(O=0),O&=127;var Y=O==0?[]:m.slice(-O);m.length-=O,R==="User"&&(R=Y.shift()),m.push(R+"("+Y.join(",")+")");break;case"PtgBool":m.push(E[1]?"TRUE":"FALSE");break;case"PtgInt":m.push(E[1]);break;case"PtgNum":m.push(String(E[1]));break;case"PtgStr":m.push('"'+E[1].replace(/"/g,'""')+'"');break;case"PtgErr":m.push(E[1]);break;case"PtgAreaN":_=V1(E[1][1],r?{s:r}:d,i),m.push(sx(_,i));break;case"PtgArea":_=V1(E[1][1],d,i),m.push(sx(_,i));break;case"PtgArea3d":b=E[1][1],_=E[1][2],N=o_(s,b,i),m.push(N+"!"+sx(_,i));break;case"PtgAttrSum":m.push("SUM("+m.pop()+")");break;case"PtgAttrBaxcel":case"PtgAttrSemi":break;case"PtgName":j=E[1][2];var P=(s.names||[])[j-1]||(s[0]||[])[j],U=P?P.Name:"SH33TJSNAME"+String(j);U&&U.slice(0,6)=="_xlfn."&&!i.xlfn&&(U=U.slice(6)),m.push(U);break;case"PtgNameX":var J=E[1][1];j=E[1][2];var ne;if(i.biff<=5)J<0&&(J=-J),s[J]&&(ne=s[J][j]);else{var ye="";if(((s[J]||[])[0]||[])[0]==14849||(((s[J]||[])[0]||[])[0]==1025?s[J][j]&&s[J][j].itab>0&&(ye=s.SheetNames[s[J][j].itab-1]+"!"):ye=s.SheetNames[j-1]+"!"),s[J]&&s[J][j])ye+=s[J][j].Name;else if(s[0]&&s[0][j])ye+=s[0][j].Name;else{var he=(Gw(s,J,i)||"").split(";;");he[j-1]?ye=he[j-1]:ye+="SH33TJSERRX"}m.push(ye);break}ne||(ne={Name:"SH33TJSERRY"}),m.push(ne.Name);break;case"PtgParen":var ce="(",se=")";if(k>=0){switch(C="",t[0][k][1][0]){case 2:ce=Wr(" ",t[0][k][1][1])+ce;break;case 3:ce=Wr("\r",t[0][k][1][1])+ce;break;case 4:se=Wr(" ",t[0][k][1][1])+se;break;case 5:se=Wr("\r",t[0][k][1][1])+se;break;default:if(i.WTF)throw new Error("Unexpected PtgAttrSpaceType "+t[0][k][1][0])}k=-1}m.push(ce+m.pop()+se);break;case"PtgRefErr":m.push("#REF!");break;case"PtgRefErr3d":m.push("#REF!");break;case"PtgExp":p={c:E[1][1],r:E[1][0]};var ee={c:r.c,r:r.r};if(s.sharedf[hr(p)]){var te=s.sharedf[hr(p)];m.push(zd(te,d,ee,s,i))}else{var W=!1;for(h=0;h!=s.arrayf.length;++h)if(g=s.arrayf[h],!(p.c<g[0].s.c||p.c>g[0].e.c)&&!(p.r<g[0].s.r||p.r>g[0].e.r)){m.push(zd(g[1],d,ee,s,i)),W=!0;break}W||m.push(E[1])}break;case"PtgArray":m.push("{"+N7(E[1])+"}");break;case"PtgMemArea":break;case"PtgAttrSpace":case"PtgAttrSpaceSemi":k=D;break;case"PtgTbl":break;case"PtgMemErr":break;case"PtgMissArg":m.push("");break;case"PtgAreaErr":m.push("#REF!");break;case"PtgAreaErr3d":m.push("#REF!");break;case"PtgList":m.push("Table"+E[1].idx+"[#"+E[1].rt+"]");break;case"PtgMemAreaN":case"PtgMemNoMemN":case"PtgAttrNoop":case"PtgSheet":case"PtgEndSheet":break;case"PtgMemFunc":break;case"PtgMemNoMem":break;case"PtgElfCol":case"PtgElfColS":case"PtgElfColSV":case"PtgElfColV":case"PtgElfLel":case"PtgElfRadical":case"PtgElfRadicalLel":case"PtgElfRadicalS":case"PtgElfRw":case"PtgElfRwV":throw new Error("Unsupported ELFs");case"PtgSxName":throw new Error("Unrecognized Formula Token: "+String(E));default:throw new Error("Unrecognized Formula Token: "+String(E))}var I=["PtgAttrSpace","PtgAttrSpaceSemi","PtgAttrGoto"];if(i.biff!=3&&k>=0&&I.indexOf(t[0][D][0])==-1){E=t[0][k];var oe=!0;switch(E[1][0]){case 4:oe=!1;case 0:C=Wr(" ",E[1][1]);break;case 5:oe=!1;case 1:C=Wr("\r",E[1][1]);break;default:if(C="",i.WTF)throw new Error("Unexpected PtgAttrSpaceType "+E[1][0])}m.push((oe?C:"")+m.pop()+(oe?"":C)),k=-1}}if(m.length>1&&i.WTF)throw new Error("bad formula stack");return m[0]}function T7(t){if(t==null){var a=bt(8);return a.write_shift(1,3),a.write_shift(1,0),a.write_shift(2,0),a.write_shift(2,0),a.write_shift(2,65535),a}else if(typeof t=="number")return jc(t);return jc(0)}function E7(t,a,r,s,i){var c=Nc(a,r,i),d=T7(t.v),m=bt(6),h=33;m.write_shift(2,h),m.write_shift(4,0);for(var g=bt(t.bf.length),p=0;p<t.bf.length;++p)g[p]=t.bf[p];var b=qs([c,d,m,g]);return b}function $h(t,a,r){var s=t.read_shift(4),i=j7(t,s,r),c=t.read_shift(4),d=c>0?k7(t,c,i,r):null;return[i,d]}var A7=$h,Hh=$h,O7=$h,D7=$h,M7={0:"BEEP",1:"OPEN",2:"OPEN.LINKS",3:"CLOSE.ALL",4:"SAVE",5:"SAVE.AS",6:"FILE.DELETE",7:"PAGE.SETUP",8:"PRINT",9:"PRINTER.SETUP",10:"QUIT",11:"NEW.WINDOW",12:"ARRANGE.ALL",13:"WINDOW.SIZE",14:"WINDOW.MOVE",15:"FULL",16:"CLOSE",17:"RUN",22:"SET.PRINT.AREA",23:"SET.PRINT.TITLES",24:"SET.PAGE.BREAK",25:"REMOVE.PAGE.BREAK",26:"FONT",27:"DISPLAY",28:"PROTECT.DOCUMENT",29:"PRECISION",30:"A1.R1C1",31:"CALCULATE.NOW",32:"CALCULATION",34:"DATA.FIND",35:"EXTRACT",36:"DATA.DELETE",37:"SET.DATABASE",38:"SET.CRITERIA",39:"SORT",40:"DATA.SERIES",41:"TABLE",42:"FORMAT.NUMBER",43:"ALIGNMENT",44:"STYLE",45:"BORDER",46:"CELL.PROTECTION",47:"COLUMN.WIDTH",48:"UNDO",49:"CUT",50:"COPY",51:"PASTE",52:"CLEAR",53:"PASTE.SPECIAL",54:"EDIT.DELETE",55:"INSERT",56:"FILL.RIGHT",57:"FILL.DOWN",61:"DEFINE.NAME",62:"CREATE.NAMES",63:"FORMULA.GOTO",64:"FORMULA.FIND",65:"SELECT.LAST.CELL",66:"SHOW.ACTIVE.CELL",67:"GALLERY.AREA",68:"GALLERY.BAR",69:"GALLERY.COLUMN",70:"GALLERY.LINE",71:"GALLERY.PIE",72:"GALLERY.SCATTER",73:"COMBINATION",74:"PREFERRED",75:"ADD.OVERLAY",76:"GRIDLINES",77:"SET.PREFERRED",78:"AXES",79:"LEGEND",80:"ATTACH.TEXT",81:"ADD.ARROW",82:"SELECT.CHART",83:"SELECT.PLOT.AREA",84:"PATTERNS",85:"MAIN.CHART",86:"OVERLAY",87:"SCALE",88:"FORMAT.LEGEND",89:"FORMAT.TEXT",90:"EDIT.REPEAT",91:"PARSE",92:"JUSTIFY",93:"HIDE",94:"UNHIDE",95:"WORKSPACE",96:"FORMULA",97:"FORMULA.FILL",98:"FORMULA.ARRAY",99:"DATA.FIND.NEXT",100:"DATA.FIND.PREV",101:"FORMULA.FIND.NEXT",102:"FORMULA.FIND.PREV",103:"ACTIVATE",104:"ACTIVATE.NEXT",105:"ACTIVATE.PREV",106:"UNLOCKED.NEXT",107:"UNLOCKED.PREV",108:"COPY.PICTURE",109:"SELECT",110:"DELETE.NAME",111:"DELETE.FORMAT",112:"VLINE",113:"HLINE",114:"VPAGE",115:"HPAGE",116:"VSCROLL",117:"HSCROLL",118:"ALERT",119:"NEW",120:"CANCEL.COPY",121:"SHOW.CLIPBOARD",122:"MESSAGE",124:"PASTE.LINK",125:"APP.ACTIVATE",126:"DELETE.ARROW",127:"ROW.HEIGHT",128:"FORMAT.MOVE",129:"FORMAT.SIZE",130:"FORMULA.REPLACE",131:"SEND.KEYS",132:"SELECT.SPECIAL",133:"APPLY.NAMES",134:"REPLACE.FONT",135:"FREEZE.PANES",136:"SHOW.INFO",137:"SPLIT",138:"ON.WINDOW",139:"ON.DATA",140:"DISABLE.INPUT",142:"OUTLINE",143:"LIST.NAMES",144:"FILE.CLOSE",145:"SAVE.WORKBOOK",146:"DATA.FORM",147:"COPY.CHART",148:"ON.TIME",149:"WAIT",150:"FORMAT.FONT",151:"FILL.UP",152:"FILL.LEFT",153:"DELETE.OVERLAY",155:"SHORT.MENUS",159:"SET.UPDATE.STATUS",161:"COLOR.PALETTE",162:"DELETE.STYLE",163:"WINDOW.RESTORE",164:"WINDOW.MAXIMIZE",166:"CHANGE.LINK",167:"CALCULATE.DOCUMENT",168:"ON.KEY",169:"APP.RESTORE",170:"APP.MOVE",171:"APP.SIZE",172:"APP.MINIMIZE",173:"APP.MAXIMIZE",174:"BRING.TO.FRONT",175:"SEND.TO.BACK",185:"MAIN.CHART.TYPE",186:"OVERLAY.CHART.TYPE",187:"SELECT.END",188:"OPEN.MAIL",189:"SEND.MAIL",190:"STANDARD.FONT",191:"CONSOLIDATE",192:"SORT.SPECIAL",193:"GALLERY.3D.AREA",194:"GALLERY.3D.COLUMN",195:"GALLERY.3D.LINE",196:"GALLERY.3D.PIE",197:"VIEW.3D",198:"GOAL.SEEK",199:"WORKGROUP",200:"FILL.GROUP",201:"UPDATE.LINK",202:"PROMOTE",203:"DEMOTE",204:"SHOW.DETAIL",206:"UNGROUP",207:"OBJECT.PROPERTIES",208:"SAVE.NEW.OBJECT",209:"SHARE",210:"SHARE.NAME",211:"DUPLICATE",212:"APPLY.STYLE",213:"ASSIGN.TO.OBJECT",214:"OBJECT.PROTECTION",215:"HIDE.OBJECT",216:"SET.EXTRACT",217:"CREATE.PUBLISHER",218:"SUBSCRIBE.TO",219:"ATTRIBUTES",220:"SHOW.TOOLBAR",222:"PRINT.PREVIEW",223:"EDIT.COLOR",224:"SHOW.LEVELS",225:"FORMAT.MAIN",226:"FORMAT.OVERLAY",227:"ON.RECALC",228:"EDIT.SERIES",229:"DEFINE.STYLE",240:"LINE.PRINT",243:"ENTER.DATA",249:"GALLERY.RADAR",250:"MERGE.STYLES",251:"EDITION.OPTIONS",252:"PASTE.PICTURE",253:"PASTE.PICTURE.LINK",254:"SPELLING",256:"ZOOM",259:"INSERT.OBJECT",260:"WINDOW.MINIMIZE",265:"SOUND.NOTE",266:"SOUND.PLAY",267:"FORMAT.SHAPE",268:"EXTEND.POLYGON",269:"FORMAT.AUTO",272:"GALLERY.3D.BAR",273:"GALLERY.3D.SURFACE",274:"FILL.AUTO",276:"CUSTOMIZE.TOOLBAR",277:"ADD.TOOL",278:"EDIT.OBJECT",279:"ON.DOUBLECLICK",280:"ON.ENTRY",281:"WORKBOOK.ADD",282:"WORKBOOK.MOVE",283:"WORKBOOK.COPY",284:"WORKBOOK.OPTIONS",285:"SAVE.WORKSPACE",288:"CHART.WIZARD",289:"DELETE.TOOL",290:"MOVE.TOOL",291:"WORKBOOK.SELECT",292:"WORKBOOK.ACTIVATE",293:"ASSIGN.TO.TOOL",295:"COPY.TOOL",296:"RESET.TOOL",297:"CONSTRAIN.NUMERIC",298:"PASTE.TOOL",302:"WORKBOOK.NEW",305:"SCENARIO.CELLS",306:"SCENARIO.DELETE",307:"SCENARIO.ADD",308:"SCENARIO.EDIT",309:"SCENARIO.SHOW",310:"SCENARIO.SHOW.NEXT",311:"SCENARIO.SUMMARY",312:"PIVOT.TABLE.WIZARD",313:"PIVOT.FIELD.PROPERTIES",314:"PIVOT.FIELD",315:"PIVOT.ITEM",316:"PIVOT.ADD.FIELDS",318:"OPTIONS.CALCULATION",319:"OPTIONS.EDIT",320:"OPTIONS.VIEW",321:"ADDIN.MANAGER",322:"MENU.EDITOR",323:"ATTACH.TOOLBARS",324:"VBAActivate",325:"OPTIONS.CHART",328:"VBA.INSERT.FILE",330:"VBA.PROCEDURE.DEFINITION",336:"ROUTING.SLIP",338:"ROUTE.DOCUMENT",339:"MAIL.LOGON",342:"INSERT.PICTURE",343:"EDIT.TOOL",344:"GALLERY.DOUGHNUT",350:"CHART.TREND",352:"PIVOT.ITEM.PROPERTIES",354:"WORKBOOK.INSERT",355:"OPTIONS.TRANSITION",356:"OPTIONS.GENERAL",370:"FILTER.ADVANCED",373:"MAIL.ADD.MAILER",374:"MAIL.DELETE.MAILER",375:"MAIL.REPLY",376:"MAIL.REPLY.ALL",377:"MAIL.FORWARD",378:"MAIL.NEXT.LETTER",379:"DATA.LABEL",380:"INSERT.TITLE",381:"FONT.PROPERTIES",382:"MACRO.OPTIONS",383:"WORKBOOK.HIDE",384:"WORKBOOK.UNHIDE",385:"WORKBOOK.DELETE",386:"WORKBOOK.NAME",388:"GALLERY.CUSTOM",390:"ADD.CHART.AUTOFORMAT",391:"DELETE.CHART.AUTOFORMAT",392:"CHART.ADD.DATA",393:"AUTO.OUTLINE",394:"TAB.ORDER",395:"SHOW.DIALOG",396:"SELECT.ALL",397:"UNGROUP.SHEETS",398:"SUBTOTAL.CREATE",399:"SUBTOTAL.REMOVE",400:"RENAME.OBJECT",412:"WORKBOOK.SCROLL",413:"WORKBOOK.NEXT",414:"WORKBOOK.PREV",415:"WORKBOOK.TAB.SPLIT",416:"FULL.SCREEN",417:"WORKBOOK.PROTECT",420:"SCROLLBAR.PROPERTIES",421:"PIVOT.SHOW.PAGES",422:"TEXT.TO.COLUMNS",423:"FORMAT.CHARTTYPE",424:"LINK.FORMAT",425:"TRACER.DISPLAY",430:"TRACER.NAVIGATE",431:"TRACER.CLEAR",432:"TRACER.ERROR",433:"PIVOT.FIELD.GROUP",434:"PIVOT.FIELD.UNGROUP",435:"CHECKBOX.PROPERTIES",436:"LABEL.PROPERTIES",437:"LISTBOX.PROPERTIES",438:"EDITBOX.PROPERTIES",439:"PIVOT.REFRESH",440:"LINK.COMBO",441:"OPEN.TEXT",442:"HIDE.DIALOG",443:"SET.DIALOG.FOCUS",444:"ENABLE.OBJECT",445:"PUSHBUTTON.PROPERTIES",446:"SET.DIALOG.DEFAULT",447:"FILTER",448:"FILTER.SHOW.ALL",449:"CLEAR.OUTLINE",450:"FUNCTION.WIZARD",451:"ADD.LIST.ITEM",452:"SET.LIST.ITEM",453:"REMOVE.LIST.ITEM",454:"SELECT.LIST.ITEM",455:"SET.CONTROL.VALUE",456:"SAVE.COPY.AS",458:"OPTIONS.LISTS.ADD",459:"OPTIONS.LISTS.DELETE",460:"SERIES.AXES",461:"SERIES.X",462:"SERIES.Y",463:"ERRORBAR.X",464:"ERRORBAR.Y",465:"FORMAT.CHART",466:"SERIES.ORDER",467:"MAIL.LOGOFF",468:"CLEAR.ROUTING.SLIP",469:"APP.ACTIVATE.MICROSOFT",470:"MAIL.EDIT.MAILER",471:"ON.SHEET",472:"STANDARD.WIDTH",473:"SCENARIO.MERGE",474:"SUMMARY.INFO",475:"FIND.FILE",476:"ACTIVE.CELL.FONT",477:"ENABLE.TIPWIZARD",478:"VBA.MAKE.ADDIN",480:"INSERTDATATABLE",481:"WORKGROUP.OPTIONS",482:"MAIL.SEND.MAILER",485:"AUTOCORRECT",489:"POST.DOCUMENT",491:"PICKLIST",493:"VIEW.SHOW",494:"VIEW.DEFINE",495:"VIEW.DELETE",509:"SHEET.BACKGROUND",510:"INSERT.MAP.OBJECT",511:"OPTIONS.MENONO",517:"MSOCHECKS",518:"NORMAL",519:"LAYOUT",520:"RM.PRINT.AREA",521:"CLEAR.PRINT.AREA",522:"ADD.PRINT.AREA",523:"MOVE.BRK",545:"HIDECURR.NOTE",546:"HIDEALL.NOTES",547:"DELETE.NOTE",548:"TRAVERSE.NOTES",549:"ACTIVATE.NOTES",620:"PROTECT.REVISIONS",621:"UNPROTECT.REVISIONS",647:"OPTIONS.ME",653:"WEB.PUBLISH",667:"NEWWEBQUERY",673:"PIVOT.TABLE.CHART",753:"OPTIONS.SAVE",755:"OPTIONS.SPELL",808:"HIDEALL.INKANNOTS"},Yw={0:"COUNT",1:"IF",2:"ISNA",3:"ISERROR",4:"SUM",5:"AVERAGE",6:"MIN",7:"MAX",8:"ROW",9:"COLUMN",10:"NA",11:"NPV",12:"STDEV",13:"DOLLAR",14:"FIXED",15:"SIN",16:"COS",17:"TAN",18:"ATAN",19:"PI",20:"SQRT",21:"EXP",22:"LN",23:"LOG10",24:"ABS",25:"INT",26:"SIGN",27:"ROUND",28:"LOOKUP",29:"INDEX",30:"REPT",31:"MID",32:"LEN",33:"VALUE",34:"TRUE",35:"FALSE",36:"AND",37:"OR",38:"NOT",39:"MOD",40:"DCOUNT",41:"DSUM",42:"DAVERAGE",43:"DMIN",44:"DMAX",45:"DSTDEV",46:"VAR",47:"DVAR",48:"TEXT",49:"LINEST",50:"TREND",51:"LOGEST",52:"GROWTH",53:"GOTO",54:"HALT",55:"RETURN",56:"PV",57:"FV",58:"NPER",59:"PMT",60:"RATE",61:"MIRR",62:"IRR",63:"RAND",64:"MATCH",65:"DATE",66:"TIME",67:"DAY",68:"MONTH",69:"YEAR",70:"WEEKDAY",71:"HOUR",72:"MINUTE",73:"SECOND",74:"NOW",75:"AREAS",76:"ROWS",77:"COLUMNS",78:"OFFSET",79:"ABSREF",80:"RELREF",81:"ARGUMENT",82:"SEARCH",83:"TRANSPOSE",84:"ERROR",85:"STEP",86:"TYPE",87:"ECHO",88:"SET.NAME",89:"CALLER",90:"DEREF",91:"WINDOWS",92:"SERIES",93:"DOCUMENTS",94:"ACTIVE.CELL",95:"SELECTION",96:"RESULT",97:"ATAN2",98:"ASIN",99:"ACOS",100:"CHOOSE",101:"HLOOKUP",102:"VLOOKUP",103:"LINKS",104:"INPUT",105:"ISREF",106:"GET.FORMULA",107:"GET.NAME",108:"SET.VALUE",109:"LOG",110:"EXEC",111:"CHAR",112:"LOWER",113:"UPPER",114:"PROPER",115:"LEFT",116:"RIGHT",117:"EXACT",118:"TRIM",119:"REPLACE",120:"SUBSTITUTE",121:"CODE",122:"NAMES",123:"DIRECTORY",124:"FIND",125:"CELL",126:"ISERR",127:"ISTEXT",128:"ISNUMBER",129:"ISBLANK",130:"T",131:"N",132:"FOPEN",133:"FCLOSE",134:"FSIZE",135:"FREADLN",136:"FREAD",137:"FWRITELN",138:"FWRITE",139:"FPOS",140:"DATEVALUE",141:"TIMEVALUE",142:"SLN",143:"SYD",144:"DDB",145:"GET.DEF",146:"REFTEXT",147:"TEXTREF",148:"INDIRECT",149:"REGISTER",150:"CALL",151:"ADD.BAR",152:"ADD.MENU",153:"ADD.COMMAND",154:"ENABLE.COMMAND",155:"CHECK.COMMAND",156:"RENAME.COMMAND",157:"SHOW.BAR",158:"DELETE.MENU",159:"DELETE.COMMAND",160:"GET.CHART.ITEM",161:"DIALOG.BOX",162:"CLEAN",163:"MDETERM",164:"MINVERSE",165:"MMULT",166:"FILES",167:"IPMT",168:"PPMT",169:"COUNTA",170:"CANCEL.KEY",171:"FOR",172:"WHILE",173:"BREAK",174:"NEXT",175:"INITIATE",176:"REQUEST",177:"POKE",178:"EXECUTE",179:"TERMINATE",180:"RESTART",181:"HELP",182:"GET.BAR",183:"PRODUCT",184:"FACT",185:"GET.CELL",186:"GET.WORKSPACE",187:"GET.WINDOW",188:"GET.DOCUMENT",189:"DPRODUCT",190:"ISNONTEXT",191:"GET.NOTE",192:"NOTE",193:"STDEVP",194:"VARP",195:"DSTDEVP",196:"DVARP",197:"TRUNC",198:"ISLOGICAL",199:"DCOUNTA",200:"DELETE.BAR",201:"UNREGISTER",204:"USDOLLAR",205:"FINDB",206:"SEARCHB",207:"REPLACEB",208:"LEFTB",209:"RIGHTB",210:"MIDB",211:"LENB",212:"ROUNDUP",213:"ROUNDDOWN",214:"ASC",215:"DBCS",216:"RANK",219:"ADDRESS",220:"DAYS360",221:"TODAY",222:"VDB",223:"ELSE",224:"ELSE.IF",225:"END.IF",226:"FOR.CELL",227:"MEDIAN",228:"SUMPRODUCT",229:"SINH",230:"COSH",231:"TANH",232:"ASINH",233:"ACOSH",234:"ATANH",235:"DGET",236:"CREATE.OBJECT",237:"VOLATILE",238:"LAST.ERROR",239:"CUSTOM.UNDO",240:"CUSTOM.REPEAT",241:"FORMULA.CONVERT",242:"GET.LINK.INFO",243:"TEXT.BOX",244:"INFO",245:"GROUP",246:"GET.OBJECT",247:"DB",248:"PAUSE",251:"RESUME",252:"FREQUENCY",253:"ADD.TOOLBAR",254:"DELETE.TOOLBAR",255:"User",256:"RESET.TOOLBAR",257:"EVALUATE",258:"GET.TOOLBAR",259:"GET.TOOL",260:"SPELLING.CHECK",261:"ERROR.TYPE",262:"APP.TITLE",263:"WINDOW.TITLE",264:"SAVE.TOOLBAR",265:"ENABLE.TOOL",266:"PRESS.TOOL",267:"REGISTER.ID",268:"GET.WORKBOOK",269:"AVEDEV",270:"BETADIST",271:"GAMMALN",272:"BETAINV",273:"BINOMDIST",274:"CHIDIST",275:"CHIINV",276:"COMBIN",277:"CONFIDENCE",278:"CRITBINOM",279:"EVEN",280:"EXPONDIST",281:"FDIST",282:"FINV",283:"FISHER",284:"FISHERINV",285:"FLOOR",286:"GAMMADIST",287:"GAMMAINV",288:"CEILING",289:"HYPGEOMDIST",290:"LOGNORMDIST",291:"LOGINV",292:"NEGBINOMDIST",293:"NORMDIST",294:"NORMSDIST",295:"NORMINV",296:"NORMSINV",297:"STANDARDIZE",298:"ODD",299:"PERMUT",300:"POISSON",301:"TDIST",302:"WEIBULL",303:"SUMXMY2",304:"SUMX2MY2",305:"SUMX2PY2",306:"CHITEST",307:"CORREL",308:"COVAR",309:"FORECAST",310:"FTEST",311:"INTERCEPT",312:"PEARSON",313:"RSQ",314:"STEYX",315:"SLOPE",316:"TTEST",317:"PROB",318:"DEVSQ",319:"GEOMEAN",320:"HARMEAN",321:"SUMSQ",322:"KURT",323:"SKEW",324:"ZTEST",325:"LARGE",326:"SMALL",327:"QUARTILE",328:"PERCENTILE",329:"PERCENTRANK",330:"MODE",331:"TRIMMEAN",332:"TINV",334:"MOVIE.COMMAND",335:"GET.MOVIE",336:"CONCATENATE",337:"POWER",338:"PIVOT.ADD.DATA",339:"GET.PIVOT.TABLE",340:"GET.PIVOT.FIELD",341:"GET.PIVOT.ITEM",342:"RADIANS",343:"DEGREES",344:"SUBTOTAL",345:"SUMIF",346:"COUNTIF",347:"COUNTBLANK",348:"SCENARIO.GET",349:"OPTIONS.LISTS.GET",350:"ISPMT",351:"DATEDIF",352:"DATESTRING",353:"NUMBERSTRING",354:"ROMAN",355:"OPEN.DIALOG",356:"SAVE.DIALOG",357:"VIEW.GET",358:"GETPIVOTDATA",359:"HYPERLINK",360:"PHONETIC",361:"AVERAGEA",362:"MAXA",363:"MINA",364:"STDEVPA",365:"VARPA",366:"STDEVA",367:"VARA",368:"BAHTTEXT",369:"THAIDAYOFWEEK",370:"THAIDIGIT",371:"THAIMONTHOFYEAR",372:"THAINUMSOUND",373:"THAINUMSTRING",374:"THAISTRINGLENGTH",375:"ISTHAIDIGIT",376:"ROUNDBAHTDOWN",377:"ROUNDBAHTUP",378:"THAIYEAR",379:"RTD",380:"CUBEVALUE",381:"CUBEMEMBER",382:"CUBEMEMBERPROPERTY",383:"CUBERANKEDMEMBER",384:"HEX2BIN",385:"HEX2DEC",386:"HEX2OCT",387:"DEC2BIN",388:"DEC2HEX",389:"DEC2OCT",390:"OCT2BIN",391:"OCT2HEX",392:"OCT2DEC",393:"BIN2DEC",394:"BIN2OCT",395:"BIN2HEX",396:"IMSUB",397:"IMDIV",398:"IMPOWER",399:"IMABS",400:"IMSQRT",401:"IMLN",402:"IMLOG2",403:"IMLOG10",404:"IMSIN",405:"IMCOS",406:"IMEXP",407:"IMARGUMENT",408:"IMCONJUGATE",409:"IMAGINARY",410:"IMREAL",411:"COMPLEX",412:"IMSUM",413:"IMPRODUCT",414:"SERIESSUM",415:"FACTDOUBLE",416:"SQRTPI",417:"QUOTIENT",418:"DELTA",419:"GESTEP",420:"ISEVEN",421:"ISODD",422:"MROUND",423:"ERF",424:"ERFC",425:"BESSELJ",426:"BESSELK",427:"BESSELY",428:"BESSELI",429:"XIRR",430:"XNPV",431:"PRICEMAT",432:"YIELDMAT",433:"INTRATE",434:"RECEIVED",435:"DISC",436:"PRICEDISC",437:"YIELDDISC",438:"TBILLEQ",439:"TBILLPRICE",440:"TBILLYIELD",441:"PRICE",442:"YIELD",443:"DOLLARDE",444:"DOLLARFR",445:"NOMINAL",446:"EFFECT",447:"CUMPRINC",448:"CUMIPMT",449:"EDATE",450:"EOMONTH",451:"YEARFRAC",452:"COUPDAYBS",453:"COUPDAYS",454:"COUPDAYSNC",455:"COUPNCD",456:"COUPNUM",457:"COUPPCD",458:"DURATION",459:"MDURATION",460:"ODDLPRICE",461:"ODDLYIELD",462:"ODDFPRICE",463:"ODDFYIELD",464:"RANDBETWEEN",465:"WEEKNUM",466:"AMORDEGRC",467:"AMORLINC",468:"CONVERT",724:"SHEETJS",469:"ACCRINT",470:"ACCRINTM",471:"WORKDAY",472:"NETWORKDAYS",473:"GCD",474:"MULTINOMIAL",475:"LCM",476:"FVSCHEDULE",477:"CUBEKPIMEMBER",478:"CUBESET",479:"CUBESETCOUNT",480:"IFERROR",481:"COUNTIFS",482:"SUMIFS",483:"AVERAGEIF",484:"AVERAGEIFS"},L7={2:1,3:1,10:0,15:1,16:1,17:1,18:1,19:0,20:1,21:1,22:1,23:1,24:1,25:1,26:1,27:2,30:2,31:3,32:1,33:1,34:0,35:0,38:1,39:2,40:3,41:3,42:3,43:3,44:3,45:3,47:3,48:2,53:1,61:3,63:0,65:3,66:3,67:1,68:1,69:1,70:1,71:1,72:1,73:1,74:0,75:1,76:1,77:1,79:2,80:2,83:1,85:0,86:1,89:0,90:1,94:0,95:0,97:2,98:1,99:1,101:3,102:3,105:1,106:1,108:2,111:1,112:1,113:1,114:1,117:2,118:1,119:4,121:1,126:1,127:1,128:1,129:1,130:1,131:1,133:1,134:1,135:1,136:2,137:2,138:2,140:1,141:1,142:3,143:4,144:4,161:1,162:1,163:1,164:1,165:2,172:1,175:2,176:2,177:3,178:2,179:1,184:1,186:1,189:3,190:1,195:3,196:3,197:1,198:1,199:3,201:1,207:4,210:3,211:1,212:2,213:2,214:1,215:1,225:0,229:1,230:1,231:1,232:1,233:1,234:1,235:3,244:1,247:4,252:2,257:1,261:1,271:1,273:4,274:2,275:2,276:2,277:3,278:3,279:1,280:3,281:3,282:3,283:1,284:1,285:2,286:4,287:3,288:2,289:4,290:3,291:3,292:3,293:4,294:1,295:3,296:1,297:3,298:1,299:2,300:3,301:3,302:4,303:2,304:2,305:2,306:2,307:2,308:2,309:3,310:2,311:2,312:2,313:2,314:2,315:2,316:4,325:2,326:2,327:2,328:2,331:2,332:2,337:2,342:1,343:1,346:2,347:1,350:4,351:3,352:1,353:2,360:1,368:1,369:1,370:1,371:1,372:1,373:1,374:1,375:1,376:1,377:1,378:1,382:3,385:1,392:1,393:1,396:2,397:2,398:2,399:1,400:1,401:1,402:1,403:1,404:1,405:1,406:1,407:1,408:1,409:1,410:1,414:4,415:1,416:1,417:2,420:1,421:1,422:2,424:1,425:2,426:2,427:2,428:2,430:3,438:3,439:3,440:3,443:2,444:2,445:2,446:2,447:6,448:6,449:2,450:2,464:2,468:3,476:2,479:1,480:2,65535:0};function R7(t){var a="of:="+t.replace(gp,"$1[.$2$3$4$5]").replace(/\]:\[/g,":");return a.replace(/;/g,"|").replace(/,/g,";")}function P7(t){return t.replace(/\./,"!")}var lu=typeof Map!="undefined";function pp(t,a,r){var s=0,i=t.length;if(r){if(lu?r.has(a):Object.prototype.hasOwnProperty.call(r,a)){for(var c=lu?r.get(a):r[a];s<c.length;++s)if(t[c[s]].t===a)return t.Count++,c[s]}}else for(;s<i;++s)if(t[s].t===a)return t.Count++,s;return t[i]={t:a},t.Count++,t.Unique++,r&&(lu?(r.has(a)||r.set(a,[]),r.get(a).push(i)):(Object.prototype.hasOwnProperty.call(r,a)||(r[a]=[]),r[a].push(i))),i}function Wh(t,a){var r={min:t+1,max:t+1},s=-1;return a.MDW&&(Yo=a.MDW),a.width!=null?r.customWidth=1:a.wpx!=null?s=Sh(a.wpx):a.wch!=null&&(s=a.wch),s>-1?(r.width=Ox(s),r.customWidth=1):a.width!=null&&(r.width=a.width),a.hidden&&(r.hidden=!0),a.level!=null&&(r.outlineLevel=r.level=a.level),r}function Zw(t,a){if(t){var r=[.7,.7,.75,.75,.3,.3];t.left==null&&(t.left=r[0]),t.right==null&&(t.right=r[1]),t.top==null&&(t.top=r[2]),t.bottom==null&&(t.bottom=r[3]),t.header==null&&(t.header=r[4]),t.footer==null&&(t.footer=r[5])}}function Ml(t,a,r){var s=r.revssf[a.z!=null?a.z:"General"],i=60,c=t.length;if(s==null&&r.ssf){for(;i<392;++i)if(r.ssf[i]==null){W2(a.z,i),r.ssf[i]=a.z,r.revssf[a.z]=s=i;break}}for(i=0;i!=c;++i)if(t[i].numFmtId===s)return i;return t[c]={numFmtId:s,fontId:0,fillId:0,borderId:0,xfId:0,applyNumberFormat:1},c}function F7(t,a,r){if(t&&t["!ref"]){var s=Dr(t["!ref"]);if(s.e.c<s.s.c||s.e.r<s.s.r)throw new Error("Bad range ("+r+"): "+t["!ref"])}}function I7(t){if(t.length===0)return"";for(var a='<mergeCells count="'+t.length+'">',r=0;r!=t.length;++r)a+='<mergeCell ref="'+ls(t[r])+'"/>';return a+"</mergeCells>"}function z7(t,a,r,s,i){var c=!1,d={},m=null;if(s.bookType!=="xlsx"&&a.vbaraw){var h=a.SheetNames[r];try{a.Workbook&&(h=a.Workbook.Sheets[r].CodeName||h)}catch(p){}c=!0,d.codeName=pu(mr(h))}if(t&&t["!outline"]){var g={summaryBelow:1,summaryRight:1};t["!outline"].above&&(g.summaryBelow=0),t["!outline"].left&&(g.summaryRight=0),m=(m||"")+qt("outlinePr",null,g)}!c&&!m||(i[i.length]=qt("sheetPr",m,d))}var B7=["objects","scenarios","selectLockedCells","selectUnlockedCells"],U7=["formatColumns","formatRows","formatCells","insertColumns","insertRows","insertHyperlinks","deleteColumns","deleteRows","sort","autoFilter","pivotTables"];function $7(t){var a={sheet:1};return B7.forEach(function(r){t[r]!=null&&t[r]&&(a[r]="1")}),U7.forEach(function(r){t[r]!=null&&!t[r]&&(a[r]="0")}),t.password&&(a.password=Dw(t.password).toString(16).toUpperCase()),qt("sheetProtection",null,a)}function H7(t){return Zw(t),qt("pageMargins",null,t)}function W7(t,a){for(var r=["<cols>"],s,i=0;i!=a.length;++i)(s=a[i])&&(r[r.length]=qt("col",null,Wh(i,s)));return r[r.length]="</cols>",r.join("")}function V7(t,a,r,s){var i=typeof t.ref=="string"?t.ref:ls(t.ref);r.Workbook||(r.Workbook={Sheets:[]}),r.Workbook.Names||(r.Workbook.Names=[]);var c=r.Workbook.Names,d=ni(i);d.s.r==d.e.r&&(d.e.r=ni(a["!ref"]).e.r,i=ls(d));for(var m=0;m<c.length;++m){var h=c[m];if(h.Name=="_xlnm._FilterDatabase"&&h.Sheet==s){h.Ref="'"+r.SheetNames[s]+"'!"+i;break}}return m==c.length&&c.push({Name:"_xlnm._FilterDatabase",Sheet:s,Ref:"'"+r.SheetNames[s]+"'!"+i}),qt("autoFilter",null,{ref:i})}function q7(t,a,r,s){var i={workbookViewId:"0"};return(((s||{}).Workbook||{}).Views||[])[0]&&(i.rightToLeft=s.Workbook.Views[0].RTL?"1":"0"),qt("sheetViews",qt("sheetView",null,i),{})}function G7(t,a,r,s){if(t.c&&r["!comments"].push([a,t.c]),t.v===void 0&&typeof t.f!="string"||t.t==="z"&&!t.f)return"";var i="",c=t.t,d=t.v;if(t.t!=="z")switch(t.t){case"b":i=t.v?"1":"0";break;case"n":i=""+t.v;break;case"e":i=Eu[t.v];break;case"d":s&&s.cellDates?i=bn(t.v,-1).toISOString():(t=In(t),t.t="n",i=""+(t.v=Fn(bn(t.v)))),typeof t.z=="undefined"&&(t.z=Vr[14]);break;default:i=t.v;break}var m=Gs("v",mr(i)),h={r:a},g=Ml(s.cellXfs,t,s);switch(g!==0&&(h.s=g),t.t){case"n":break;case"d":h.t="d";break;case"b":h.t="b";break;case"e":h.t="e";break;case"z":break;default:if(t.v==null){delete t.t;break}if(t.v.length>32767)throw new Error("Text length must not exceed 32767 characters");if(s&&s.bookSST){m=Gs("v",""+pp(s.Strings,t.v,s.revStrings)),h.t="s";break}h.t="str";break}if(t.t!=c&&(t.t=c,t.v=d),typeof t.f=="string"&&t.f){var p=t.F&&t.F.slice(0,a.length)==a?{t:"array",ref:t.F}:null;m=qt("f",mr(t.f),p)+(t.v!=null?m:"")}return t.l&&r["!links"].push([a,t.l]),t.D&&(h.cm=1),qt("c",m,h)}function Y7(t,a,r,s){var i=[],c=[],d=Dr(t["!ref"]),m="",h,g="",p=[],b=0,j=0,_=t["!rows"],N=Array.isArray(t),k={r:g},C,D=-1;for(j=d.s.c;j<=d.e.c;++j)p[j]=on(j);for(b=d.s.r;b<=d.e.r;++b){for(c=[],g=Ys(b),j=d.s.c;j<=d.e.c;++j){h=p[j]+g;var T=N?(t[b]||[])[j]:t[h];T!==void 0&&(m=G7(T,h,t,a))!=null&&c.push(m)}(c.length>0||_&&_[b])&&(k={r:g},_&&_[b]&&(C=_[b],C.hidden&&(k.hidden=1),D=-1,C.hpx?D=Ch(C.hpx):C.hpt&&(D=C.hpt),D>-1&&(k.ht=D,k.customHeight=1),C.level&&(k.outlineLevel=C.level)),i[i.length]=qt("row",c.join(""),k))}if(_)for(;b<_.length;++b)_&&_[b]&&(k={r:b+1},C=_[b],C.hidden&&(k.hidden=1),D=-1,C.hpx?D=Ch(C.hpx):C.hpt&&(D=C.hpt),D>-1&&(k.ht=D,k.customHeight=1),C.level&&(k.outlineLevel=C.level),i[i.length]=qt("row","",k));return i.join("")}function Jw(t,a,r,s){var i=[us,qt("worksheet",null,{xmlns:Vd[0],"xmlns:r":Ns.r})],c=r.SheetNames[t],d=0,m="",h=r.Sheets[c];h==null&&(h={});var g=h["!ref"]||"A1",p=Dr(g);if(p.e.c>16383||p.e.r>1048575){if(a.WTF)throw new Error("Range "+g+" exceeds format limit A1:XFD1048576");p.e.c=Math.min(p.e.c,16383),p.e.r=Math.min(p.e.c,1048575),g=ls(p)}s||(s={}),h["!comments"]=[];var b=[];z7(h,r,t,a,i),i[i.length]=qt("dimension",null,{ref:g}),i[i.length]=q7(h,a,t,r),a.sheetFormat&&(i[i.length]=qt("sheetFormatPr",null,{defaultRowHeight:a.sheetFormat.defaultRowHeight||"16",baseColWidth:a.sheetFormat.baseColWidth||"10",outlineLevelRow:a.sheetFormat.outlineLevelRow||"7"})),h["!cols"]!=null&&h["!cols"].length>0&&(i[i.length]=W7(h,h["!cols"])),i[d=i.length]="<sheetData/>",h["!links"]=[],h["!ref"]!=null&&(m=Y7(h,a),m.length>0&&(i[i.length]=m)),i.length>d+1&&(i[i.length]="</sheetData>",i[d]=i[d].replace("/>",">")),h["!protect"]&&(i[i.length]=$7(h["!protect"])),h["!autofilter"]!=null&&(i[i.length]=V7(h["!autofilter"],h,r,t)),h["!merges"]!=null&&h["!merges"].length>0&&(i[i.length]=I7(h["!merges"]));var j=-1,_,N=-1;return h["!links"].length>0&&(i[i.length]="<hyperlinks>",h["!links"].forEach(function(k){k[1].Target&&(_={ref:k[0]},k[1].Target.charAt(0)!="#"&&(N=ur(s,-1,mr(k[1].Target).replace(/#.*$/,""),tr.HLINK),_["r:id"]="rId"+N),(j=k[1].Target.indexOf("#"))>-1&&(_.location=mr(k[1].Target.slice(j+1))),k[1].Tooltip&&(_.tooltip=mr(k[1].Tooltip)),i[i.length]=qt("hyperlink",null,_))}),i[i.length]="</hyperlinks>"),delete h["!links"],h["!margins"]!=null&&(i[i.length]=H7(h["!margins"])),(!a||a.ignoreEC||a.ignoreEC==null)&&(i[i.length]=Gs("ignoredErrors",qt("ignoredError",null,{numberStoredAsText:1,sqref:g}))),b.length>0&&(N=ur(s,-1,"../drawings/drawing"+(t+1)+".xml",tr.DRAW),i[i.length]=qt("drawing",null,{"r:id":"rId"+N}),h["!drawing"]=b),h["!comments"].length>0&&(N=ur(s,-1,"../drawings/vmlDrawing"+(t+1)+".vml",tr.VML),i[i.length]=qt("legacyDrawing",null,{"r:id":"rId"+N}),h["!legacy"]=N),i.length>1&&(i[i.length]="</worksheet>",i[1]=i[1].replace("/>",">")),i.join("")}function Z7(t,a){var r={},s=t.l+a;r.r=t.read_shift(4),t.l+=4;var i=t.read_shift(2);t.l+=1;var c=t.read_shift(1);return t.l=s,c&7&&(r.level=c&7),c&16&&(r.hidden=!0),c&32&&(r.hpt=i/20),r}function J7(t,a,r){var s=bt(145),i=(r["!rows"]||[])[t]||{};s.write_shift(4,t),s.write_shift(4,0);var c=320;i.hpx?c=Ch(i.hpx)*20:i.hpt&&(c=i.hpt*20),s.write_shift(2,c),s.write_shift(1,0);var d=0;i.level&&(d|=i.level),i.hidden&&(d|=16),(i.hpx||i.hpt)&&(d|=32),s.write_shift(1,d),s.write_shift(1,0);var m=0,h=s.l;s.l+=4;for(var g={r:t,c:0},p=0;p<16;++p)if(!(a.s.c>p+1<<10||a.e.c<p<<10)){for(var b=-1,j=-1,_=p<<10;_<p+1<<10;++_){g.c=_;var N=Array.isArray(r)?(r[g.r]||[])[g.c]:r[hr(g)];N&&(b<0&&(b=_),j=_)}b<0||(++m,s.write_shift(4,b),s.write_shift(4,j))}var k=s.l;return s.l=h,s.write_shift(4,m),s.l=k,s.length>s.l?s.slice(0,s.l):s}function X7(t,a,r,s){var i=J7(s,r,a);(i.length>17||(a["!rows"]||[])[s])&&Lt(t,0,i)}var K7=Mc,Q7=Gd;function e8(){}function t8(t,a){var r={},s=t[t.l];return++t.l,r.above=!(s&64),r.left=!(s&128),t.l+=18,r.name=uC(t),r}function a8(t,a,r){r==null&&(r=bt(84+4*t.length));var s=192;a&&(a.above&&(s&=-65),a.left&&(s&=-129)),r.write_shift(1,s);for(var i=1;i<3;++i)r.write_shift(1,0);return kh({auto:1},r),r.write_shift(-4,-1),r.write_shift(-4,-1),uw(t,r),r.slice(0,r.l)}function r8(t){var a=_i(t);return[a]}function s8(t,a,r){return r==null&&(r=bt(8)),Ac(a,r)}function n8(t){var a=Oc(t);return[a]}function i8(t,a,r){return r==null&&(r=bt(4)),Dc(a,r)}function o8(t){var a=_i(t),r=t.read_shift(1);return[a,r,"b"]}function l8(t,a,r){return r==null&&(r=bt(9)),Ac(a,r),r.write_shift(1,t.v?1:0),r}function c8(t){var a=Oc(t),r=t.read_shift(1);return[a,r,"b"]}function d8(t,a,r){return r==null&&(r=bt(5)),Dc(a,r),r.write_shift(1,t.v?1:0),r}function u8(t){var a=_i(t),r=t.read_shift(1);return[a,r,"e"]}function m8(t,a,r){return r==null&&(r=bt(9)),Ac(a,r),r.write_shift(1,t.v),r}function h8(t){var a=Oc(t),r=t.read_shift(1);return[a,r,"e"]}function g8(t,a,r){return r==null&&(r=bt(8)),Dc(a,r),r.write_shift(1,t.v),r.write_shift(2,0),r.write_shift(1,0),r}function f8(t){var a=_i(t),r=t.read_shift(4);return[a,r,"s"]}function x8(t,a,r){return r==null&&(r=bt(12)),Ac(a,r),r.write_shift(4,a.v),r}function p8(t){var a=Oc(t),r=t.read_shift(4);return[a,r,"s"]}function y8(t,a,r){return r==null&&(r=bt(8)),Dc(a,r),r.write_shift(4,a.v),r}function b8(t){var a=_i(t),r=Yd(t);return[a,r,"n"]}function v8(t,a,r){return r==null&&(r=bt(16)),Ac(a,r),jc(t.v,r),r}function _8(t){var a=Oc(t),r=Yd(t);return[a,r,"n"]}function w8(t,a,r){return r==null&&(r=bt(12)),Dc(a,r),jc(t.v,r),r}function k8(t){var a=_i(t),r=mw(t);return[a,r,"n"]}function j8(t,a,r){return r==null&&(r=bt(12)),Ac(a,r),hw(t.v,r),r}function N8(t){var a=Oc(t),r=mw(t);return[a,r,"n"]}function S8(t,a,r){return r==null&&(r=bt(8)),Dc(a,r),hw(t.v,r),r}function C8(t){var a=_i(t),r=cp(t);return[a,r,"is"]}function T8(t){var a=_i(t),r=ln(t);return[a,r,"str"]}function E8(t,a,r){return r==null&&(r=bt(12+4*t.v.length)),Ac(a,r),Cs(t.v,r),r.length>r.l?r.slice(0,r.l):r}function A8(t){var a=Oc(t),r=ln(t);return[a,r,"str"]}function O8(t,a,r){return r==null&&(r=bt(8+4*t.v.length)),Dc(a,r),Cs(t.v,r),r.length>r.l?r.slice(0,r.l):r}function D8(t,a,r){var s=t.l+a,i=_i(t);i.r=r["!row"];var c=t.read_shift(1),d=[i,c,"b"];if(r.cellFormula){t.l+=2;var m=Hh(t,s-t.l,r);d[3]=zd(m,null,i,r.supbooks,r)}else t.l=s;return d}function M8(t,a,r){var s=t.l+a,i=_i(t);i.r=r["!row"];var c=t.read_shift(1),d=[i,c,"e"];if(r.cellFormula){t.l+=2;var m=Hh(t,s-t.l,r);d[3]=zd(m,null,i,r.supbooks,r)}else t.l=s;return d}function L8(t,a,r){var s=t.l+a,i=_i(t);i.r=r["!row"];var c=Yd(t),d=[i,c,"n"];if(r.cellFormula){t.l+=2;var m=Hh(t,s-t.l,r);d[3]=zd(m,null,i,r.supbooks,r)}else t.l=s;return d}function R8(t,a,r){var s=t.l+a,i=_i(t);i.r=r["!row"];var c=ln(t),d=[i,c,"str"];if(r.cellFormula){t.l+=2;var m=Hh(t,s-t.l,r);d[3]=zd(m,null,i,r.supbooks,r)}else t.l=s;return d}var P8=Mc,F8=Gd;function I8(t,a){return a==null&&(a=bt(4)),a.write_shift(4,t),a}function z8(t,a){var r=t.l+a,s=Mc(t),i=dp(t),c=ln(t),d=ln(t),m=ln(t);t.l=r;var h={rfx:s,relId:i,loc:c,display:m};return d&&(h.Tooltip=d),h}function B8(t,a){var r=bt(50+4*(t[1].Target.length+(t[1].Tooltip||"").length));Gd({s:Ss(t[0]),e:Ss(t[0])},r),up("rId"+a,r);var s=t[1].Target.indexOf("#"),i=s==-1?"":t[1].Target.slice(s+1);return Cs(i||"",r),Cs(t[1].Tooltip||"",r),Cs("",r),r.slice(0,r.l)}function U8(){}function $8(t,a,r){var s=t.l+a,i=gw(t),c=t.read_shift(1),d=[i];if(d[2]=c,r.cellFormula){var m=A7(t,s-t.l,r);d[1]=m}else t.l=s;return d}function H8(t,a,r){var s=t.l+a,i=Mc(t),c=[i];if(r.cellFormula){var d=D7(t,s-t.l,r);c[1]=d,t.l=s}else t.l=s;return c}function W8(t,a,r){r==null&&(r=bt(18));var s=Wh(t,a);r.write_shift(-4,t),r.write_shift(-4,t),r.write_shift(4,(s.width||10)*256),r.write_shift(4,0);var i=0;return a.hidden&&(i|=1),typeof s.width=="number"&&(i|=2),a.level&&(i|=a.level<<8),r.write_shift(2,i),r}var Xw=["left","right","top","bottom","header","footer"];function V8(t){var a={};return Xw.forEach(function(r){a[r]=Yd(t)}),a}function q8(t,a){return a==null&&(a=bt(48)),Zw(t),Xw.forEach(function(r){jc(t[r],a)}),a}function G8(t){var a=t.read_shift(2);return t.l+=28,{RTL:a&32}}function Y8(t,a,r){r==null&&(r=bt(30));var s=924;return(((a||{}).Views||[])[0]||{}).RTL&&(s|=32),r.write_shift(2,s),r.write_shift(4,0),r.write_shift(4,0),r.write_shift(4,0),r.write_shift(1,0),r.write_shift(1,0),r.write_shift(2,0),r.write_shift(2,100),r.write_shift(2,0),r.write_shift(2,0),r.write_shift(2,0),r.write_shift(4,0),r}function Z8(t){var a=bt(24);return a.write_shift(4,4),a.write_shift(4,1),Gd(t,a),a}function J8(t,a){return a==null&&(a=bt(66)),a.write_shift(2,t.password?Dw(t.password):0),a.write_shift(4,1),[["objects",!1],["scenarios",!1],["formatCells",!0],["formatColumns",!0],["formatRows",!0],["insertColumns",!0],["insertRows",!0],["insertHyperlinks",!0],["deleteColumns",!0],["deleteRows",!0],["selectLockedCells",!1],["sort",!0],["autoFilter",!0],["pivotTables",!0],["selectUnlockedCells",!1]].forEach(function(r){r[1]?a.write_shift(4,t[r[0]]!=null&&!t[r[0]]?1:0):a.write_shift(4,t[r[0]]!=null&&t[r[0]]?0:1)}),a}function X8(){}function K8(){}function Q8(t,a,r,s,i,c,d){if(a.v===void 0)return!1;var m="";switch(a.t){case"b":m=a.v?"1":"0";break;case"d":a=In(a),a.z=a.z||Vr[14],a.v=Fn(bn(a.v)),a.t="n";break;case"n":case"e":m=""+a.v;break;default:m=a.v;break}var h={r,c:s};switch(h.s=Ml(i.cellXfs,a,i),a.l&&c["!links"].push([hr(h),a.l]),a.c&&c["!comments"].push([hr(h),a.c]),a.t){case"s":case"str":return i.bookSST?(m=pp(i.Strings,a.v,i.revStrings),h.t="s",h.v=m,d?Lt(t,18,y8(a,h)):Lt(t,7,x8(a,h))):(h.t="str",d?Lt(t,17,O8(a,h)):Lt(t,6,E8(a,h))),!0;case"n":return a.v==(a.v|0)&&a.v>-1e3&&a.v<1e3?d?Lt(t,13,S8(a,h)):Lt(t,2,j8(a,h)):d?Lt(t,16,w8(a,h)):Lt(t,5,v8(a,h)),!0;case"b":return h.t="b",d?Lt(t,15,d8(a,h)):Lt(t,4,l8(a,h)),!0;case"e":return h.t="e",d?Lt(t,14,g8(a,h)):Lt(t,3,m8(a,h)),!0}return d?Lt(t,12,i8(a,h)):Lt(t,1,s8(a,h)),!0}function eA(t,a,r,s){var i=Dr(a["!ref"]||"A1"),c,d="",m=[];Lt(t,145);var h=Array.isArray(a),g=i.e.r;a["!rows"]&&(g=Math.max(i.e.r,a["!rows"].length-1));for(var p=i.s.r;p<=g;++p){d=Ys(p),X7(t,a,i,p);var b=!1;if(p<=i.e.r)for(var j=i.s.c;j<=i.e.c;++j){p===i.s.r&&(m[j]=on(j)),c=m[j]+d;var _=h?(a[p]||[])[j]:a[c];if(!_){b=!1;continue}b=Q8(t,_,p,j,s,a,b)}}Lt(t,146)}function tA(t,a){!a||!a["!merges"]||(Lt(t,177,I8(a["!merges"].length)),a["!merges"].forEach(function(r){Lt(t,176,F8(r))}),Lt(t,178))}function aA(t,a){!a||!a["!cols"]||(Lt(t,390),a["!cols"].forEach(function(r,s){r&&Lt(t,60,W8(s,r))}),Lt(t,391))}function rA(t,a){!a||!a["!ref"]||(Lt(t,648),Lt(t,649,Z8(Dr(a["!ref"]))),Lt(t,650))}function sA(t,a,r){a["!links"].forEach(function(s){if(s[1].Target){var i=ur(r,-1,s[1].Target.replace(/#.*$/,""),tr.HLINK);Lt(t,494,B8(s,i))}}),delete a["!links"]}function nA(t,a,r,s){if(a["!comments"].length>0){var i=ur(s,-1,"../drawings/vmlDrawing"+(r+1)+".vml",tr.VML);Lt(t,551,up("rId"+i)),a["!legacy"]=i}}function iA(t,a,r,s){if(a["!autofilter"]){var i=a["!autofilter"],c=typeof i.ref=="string"?i.ref:ls(i.ref);r.Workbook||(r.Workbook={Sheets:[]}),r.Workbook.Names||(r.Workbook.Names=[]);var d=r.Workbook.Names,m=ni(c);m.s.r==m.e.r&&(m.e.r=ni(a["!ref"]).e.r,c=ls(m));for(var h=0;h<d.length;++h){var g=d[h];if(g.Name=="_xlnm._FilterDatabase"&&g.Sheet==s){g.Ref="'"+r.SheetNames[s]+"'!"+c;break}}h==d.length&&d.push({Name:"_xlnm._FilterDatabase",Sheet:s,Ref:"'"+r.SheetNames[s]+"'!"+c}),Lt(t,161,Gd(Dr(c))),Lt(t,162)}}function oA(t,a,r){Lt(t,133),Lt(t,137,Y8(a,r)),Lt(t,138),Lt(t,134)}function lA(t,a){a["!protect"]&&Lt(t,535,J8(a["!protect"]))}function cA(t,a,r,s){var i=Ln(),c=r.SheetNames[t],d=r.Sheets[c]||{},m=c;try{r&&r.Workbook&&(m=r.Workbook.Sheets[t].CodeName||m)}catch(g){}var h=Dr(d["!ref"]||"A1");if(h.e.c>16383||h.e.r>1048575){if(a.WTF)throw new Error("Range "+(d["!ref"]||"A1")+" exceeds format limit A1:XFD1048576");h.e.c=Math.min(h.e.c,16383),h.e.r=Math.min(h.e.c,1048575)}return d["!links"]=[],d["!comments"]=[],Lt(i,129),(r.vbaraw||d["!outline"])&&Lt(i,147,a8(m,d["!outline"])),Lt(i,148,Q7(h)),oA(i,d,r.Workbook),aA(i,d),eA(i,d,t,a),lA(i,d),iA(i,d,r,t),tA(i,d),sA(i,d,s),d["!margins"]&&Lt(i,476,q8(d["!margins"])),(!a||a.ignoreEC||a.ignoreEC==null)&&rA(i,d),nA(i,d,t,s),Lt(i,130),i.end()}function dA(t,a){t.l+=10;var r=ln(t);return{name:r}}var uA=[["allowRefreshQuery",!1,"bool"],["autoCompressPictures",!0,"bool"],["backupFile",!1,"bool"],["checkCompatibility",!1,"bool"],["CodeName",""],["date1904",!1,"bool"],["defaultThemeVersion",0,"int"],["filterPrivacy",!1,"bool"],["hidePivotFieldList",!1,"bool"],["promptedSolutions",!1,"bool"],["publishItems",!1,"bool"],["refreshAllConnections",!1,"bool"],["saveExternalLinkValues",!0,"bool"],["showBorderUnselectedTables",!0,"bool"],["showInkAnnotation",!0,"bool"],["showObjects","all"],["showPivotChartFilter",!1,"bool"],["updateLinks","userSet"]];function mA(t){return!t.Workbook||!t.Workbook.WBProps?"false":H6(t.Workbook.WBProps.date1904)?"true":"false"}var hA="][*?/\\".split("");function Kw(t,a){if(t.length>31)throw new Error("Sheet names cannot exceed 31 chars");var r=!0;return hA.forEach(function(s){if(t.indexOf(s)!=-1)throw new Error("Sheet name cannot contain : \\ / ? * [ ]")}),r}function gA(t,a,r){t.forEach(function(s,i){Kw(s);for(var c=0;c<i;++c)if(s==t[c])throw new Error("Duplicate Sheet Name: "+s);if(r){var d=a&&a[i]&&a[i].CodeName||s;if(d.charCodeAt(0)==95&&d.length>22)throw new Error("Bad Code Name: Worksheet"+d)}})}function fA(t){if(!t||!t.SheetNames||!t.Sheets)throw new Error("Invalid Workbook");if(!t.SheetNames.length)throw new Error("Workbook is empty");var a=t.Workbook&&t.Workbook.Sheets||[];gA(t.SheetNames,a,!!t.vbaraw);for(var r=0;r<t.SheetNames.length;++r)F7(t.Sheets[t.SheetNames[r]],t.SheetNames[r],r)}function Qw(t){var a=[us];a[a.length]=qt("workbook",null,{xmlns:Vd[0],"xmlns:r":Ns.r});var r=t.Workbook&&(t.Workbook.Names||[]).length>0,s={codeName:"ThisWorkbook"};t.Workbook&&t.Workbook.WBProps&&(uA.forEach(function(m){t.Workbook.WBProps[m[0]]!=null&&t.Workbook.WBProps[m[0]]!=m[1]&&(s[m[0]]=t.Workbook.WBProps[m[0]])}),t.Workbook.WBProps.CodeName&&(s.codeName=t.Workbook.WBProps.CodeName,delete s.CodeName)),a[a.length]=qt("workbookPr",null,s);var i=t.Workbook&&t.Workbook.Sheets||[],c=0;if(i&&i[0]&&i[0].Hidden){for(a[a.length]="<bookViews>",c=0;c!=t.SheetNames.length&&!(!i[c]||!i[c].Hidden);++c);c==t.SheetNames.length&&(c=0),a[a.length]='<workbookView firstSheet="'+c+'" activeTab="'+c+'"/>',a[a.length]="</bookViews>"}for(a[a.length]="<sheets>",c=0;c!=t.SheetNames.length;++c){var d={name:mr(t.SheetNames[c].slice(0,31))};if(d.sheetId=""+(c+1),d["r:id"]="rId"+(c+1),i[c])switch(i[c].Hidden){case 1:d.state="hidden";break;case 2:d.state="veryHidden";break}a[a.length]=qt("sheet",null,d)}return a[a.length]="</sheets>",r&&(a[a.length]="<definedNames>",t.Workbook&&t.Workbook.Names&&t.Workbook.Names.forEach(function(m){var h={name:m.Name};m.Comment&&(h.comment=m.Comment),m.Sheet!=null&&(h.localSheetId=""+m.Sheet),m.Hidden&&(h.hidden="1"),m.Ref&&(a[a.length]=qt("definedName",mr(m.Ref),h))}),a[a.length]="</definedNames>"),a.length>2&&(a[a.length]="</workbook>",a[1]=a[1].replace("/>",">")),a.join("")}function xA(t,a){var r={};return r.Hidden=t.read_shift(4),r.iTabID=t.read_shift(4),r.strRelID=Ax(t),r.name=ln(t),r}function pA(t,a){return a||(a=bt(127)),a.write_shift(4,t.Hidden),a.write_shift(4,t.iTabID),up(t.strRelID,a),Cs(t.name.slice(0,31),a),a.length>a.l?a.slice(0,a.l):a}function yA(t,a){var r={},s=t.read_shift(4);r.defaultThemeVersion=t.read_shift(4);var i=a>8?ln(t):"";return i.length>0&&(r.CodeName=i),r.autoCompressPictures=!!(s&65536),r.backupFile=!!(s&64),r.checkCompatibility=!!(s&4096),r.date1904=!!(s&1),r.filterPrivacy=!!(s&8),r.hidePivotFieldList=!!(s&1024),r.promptedSolutions=!!(s&16),r.publishItems=!!(s&2048),r.refreshAllConnections=!!(s&262144),r.saveExternalLinkValues=!!(s&128),r.showBorderUnselectedTables=!!(s&4),r.showInkAnnotation=!!(s&32),r.showObjects=["all","placeholders","none"][s>>13&3],r.showPivotChartFilter=!!(s&32768),r.updateLinks=["userSet","never","always"][s>>8&3],r}function bA(t,a){a||(a=bt(72));var r=0;return t&&t.filterPrivacy&&(r|=8),a.write_shift(4,r),a.write_shift(4,0),uw(t&&t.CodeName||"ThisWorkbook",a),a.slice(0,a.l)}function vA(t,a,r){var s=t.l+a;t.l+=4,t.l+=1;var i=t.read_shift(4),c=mC(t),d=O7(t,0,r),m=dp(t);t.l=s;var h={Name:c,Ptg:d};return i<268435455&&(h.Sheet=i),m&&(h.Comment=m),h}function _A(t,a){Lt(t,143);for(var r=0;r!=a.SheetNames.length;++r){var s=a.Workbook&&a.Workbook.Sheets&&a.Workbook.Sheets[r]&&a.Workbook.Sheets[r].Hidden||0,i={Hidden:s,iTabID:r+1,strRelID:"rId"+(r+1),name:a.SheetNames[r]};Lt(t,156,pA(i))}Lt(t,144)}function wA(t,a){a||(a=bt(127));for(var r=0;r!=4;++r)a.write_shift(4,0);return Cs("SheetJS",a),Cs(fh.version,a),Cs(fh.version,a),Cs("7262",a),a.length>a.l?a.slice(0,a.l):a}function kA(t,a){a||(a=bt(29)),a.write_shift(-4,0),a.write_shift(-4,460),a.write_shift(4,28800),a.write_shift(4,17600),a.write_shift(4,500),a.write_shift(4,t),a.write_shift(4,t);var r=120;return a.write_shift(1,r),a.length>a.l?a.slice(0,a.l):a}function jA(t,a){if(!(!a.Workbook||!a.Workbook.Sheets)){for(var r=a.Workbook.Sheets,s=0,i=-1,c=-1;s<r.length;++s)!r[s]||!r[s].Hidden&&i==-1?i=s:r[s].Hidden==1&&c==-1&&(c=s);c>i||(Lt(t,135),Lt(t,158,kA(i)),Lt(t,136))}}function NA(t,a){var r=Ln();return Lt(r,131),Lt(r,128,wA()),Lt(r,153,bA(t.Workbook&&t.Workbook.WBProps||null)),jA(r,t),_A(r,t),Lt(r,132),r.end()}function SA(t,a,r){return(a.slice(-4)===".bin"?NA:Qw)(t)}function CA(t,a,r,s,i){return(a.slice(-4)===".bin"?cA:Jw)(t,r,s,i)}function TA(t,a,r){return(a.slice(-4)===".bin"?qT:Rw)(t,r)}function EA(t,a,r){return(a.slice(-4)===".bin"?bT:Ow)(t,r)}function AA(t,a,r){return(a.slice(-4)===".bin"?lE:Bw)(t)}function OA(t){return(t.slice(-4)===".bin"?eE:Iw)()}function DA(t,a){var r=[];return t.Props&&r.push(TC(t.Props,a)),t.Custprops&&r.push(EC(t.Props,t.Custprops)),r.join("")}function MA(){return""}function LA(t,a){var r=['<Style ss:ID="Default" ss:Name="Normal"><NumberFormat/></Style>'];return a.cellXfs.forEach(function(s,i){var c=[];c.push(qt("NumberFormat",null,{"ss:Format":mr(Vr[s.numFmtId])}));var d={"ss:ID":"s"+(21+i)};r.push(qt("Style",c.join(""),d))}),qt("Styles",r.join(""))}function ek(t){return qt("NamedRange",null,{"ss:Name":t.Name,"ss:RefersTo":"="+fp(t.Ref,{r:0,c:0})})}function RA(t){if(!((t||{}).Workbook||{}).Names)return"";for(var a=t.Workbook.Names,r=[],s=0;s<a.length;++s){var i=a[s];i.Sheet==null&&(i.Name.match(/^_xlfn\./)||r.push(ek(i)))}return qt("Names",r.join(""))}function PA(t,a,r,s){if(!t||!((s||{}).Workbook||{}).Names)return"";for(var i=s.Workbook.Names,c=[],d=0;d<i.length;++d){var m=i[d];m.Sheet==r&&(m.Name.match(/^_xlfn\./)||c.push(ek(m)))}return c.join("")}function FA(t,a,r,s){if(!t)return"";var i=[];if(t["!margins"]&&(i.push("<PageSetup>"),t["!margins"].header&&i.push(qt("Header",null,{"x:Margin":t["!margins"].header})),t["!margins"].footer&&i.push(qt("Footer",null,{"x:Margin":t["!margins"].footer})),i.push(qt("PageMargins",null,{"x:Bottom":t["!margins"].bottom||"0.75","x:Left":t["!margins"].left||"0.7","x:Right":t["!margins"].right||"0.7","x:Top":t["!margins"].top||"0.75"})),i.push("</PageSetup>")),s&&s.Workbook&&s.Workbook.Sheets&&s.Workbook.Sheets[r])if(s.Workbook.Sheets[r].Hidden)i.push(qt("Visible",s.Workbook.Sheets[r].Hidden==1?"SheetHidden":"SheetVeryHidden",{}));else{for(var c=0;c<r&&!(s.Workbook.Sheets[c]&&!s.Workbook.Sheets[c].Hidden);++c);c==r&&i.push("<Selected/>")}return((((s||{}).Workbook||{}).Views||[])[0]||{}).RTL&&i.push("<DisplayRightToLeft/>"),t["!protect"]&&(i.push(Gs("ProtectContents","True")),t["!protect"].objects&&i.push(Gs("ProtectObjects","True")),t["!protect"].scenarios&&i.push(Gs("ProtectScenarios","True")),t["!protect"].selectLockedCells!=null&&!t["!protect"].selectLockedCells?i.push(Gs("EnableSelection","NoSelection")):t["!protect"].selectUnlockedCells!=null&&!t["!protect"].selectUnlockedCells&&i.push(Gs("EnableSelection","UnlockedCells")),[["formatCells","AllowFormatCells"],["formatColumns","AllowSizeCols"],["formatRows","AllowSizeRows"],["insertColumns","AllowInsertCols"],["insertRows","AllowInsertRows"],["insertHyperlinks","AllowInsertHyperlinks"],["deleteColumns","AllowDeleteCols"],["deleteRows","AllowDeleteRows"],["sort","AllowSort"],["autoFilter","AllowFilter"],["pivotTables","AllowUsePivotTables"]].forEach(function(d){t["!protect"][d[0]]&&i.push("<"+d[1]+"/>")})),i.length==0?"":qt("WorksheetOptions",i.join(""),{xmlns:ti.x})}function IA(t){return t.map(function(a){var r=$6(a.t||""),s=qt("ss:Data",r,{xmlns:"http://www.w3.org/TR/REC-html40"});return qt("Comment",s,{"ss:Author":a.a})}).join("")}function zA(t,a,r,s,i,c,d){if(!t||t.v==null&&t.f==null)return"";var m={};if(t.f&&(m["ss:Formula"]="="+mr(fp(t.f,d))),t.F&&t.F.slice(0,a.length)==a){var h=Ss(t.F.slice(a.length+1));m["ss:ArrayRange"]="RC:R"+(h.r==d.r?"":"["+(h.r-d.r)+"]")+"C"+(h.c==d.c?"":"["+(h.c-d.c)+"]")}if(t.l&&t.l.Target&&(m["ss:HRef"]=mr(t.l.Target),t.l.Tooltip&&(m["x:HRefScreenTip"]=mr(t.l.Tooltip))),r["!merges"])for(var g=r["!merges"],p=0;p!=g.length;++p)g[p].s.c!=d.c||g[p].s.r!=d.r||(g[p].e.c>g[p].s.c&&(m["ss:MergeAcross"]=g[p].e.c-g[p].s.c),g[p].e.r>g[p].s.r&&(m["ss:MergeDown"]=g[p].e.r-g[p].s.r));var b="",j="";switch(t.t){case"z":if(!s.sheetStubs)return"";break;case"n":b="Number",j=String(t.v);break;case"b":b="Boolean",j=t.v?"1":"0";break;case"e":b="Error",j=Eu[t.v];break;case"d":b="DateTime",j=new Date(t.v).toISOString(),t.z==null&&(t.z=t.z||Vr[14]);break;case"s":b="String",j=U6(t.v||"");break}var _=Ml(s.cellXfs,t,s);m["ss:StyleID"]="s"+(21+_),m["ss:Index"]=d.c+1;var N=t.v!=null?j:"",k=t.t=="z"?"":'<Data ss:Type="'+b+'">'+N+"</Data>";return(t.c||[]).length>0&&(k+=IA(t.c)),qt("Cell",k,m)}function BA(t,a){var r='<Row ss:Index="'+(t+1)+'"';return a&&(a.hpt&&!a.hpx&&(a.hpx=Lw(a.hpt)),a.hpx&&(r+=' ss:AutoFitHeight="0" ss:Height="'+a.hpx+'"'),a.hidden&&(r+=' ss:Hidden="1"')),r+">"}function UA(t,a,r,s){if(!t["!ref"])return"";var i=Dr(t["!ref"]),c=t["!merges"]||[],d=0,m=[];t["!cols"]&&t["!cols"].forEach(function(C,D){hp(C);var T=!!C.width,E=Wh(D,C),O={"ss:Index":D+1};T&&(O["ss:Width"]=Nh(E.width)),C.hidden&&(O["ss:Hidden"]="1"),m.push(qt("Column",null,O))});for(var h=Array.isArray(t),g=i.s.r;g<=i.e.r;++g){for(var p=[BA(g,(t["!rows"]||[])[g])],b=i.s.c;b<=i.e.c;++b){var j=!1;for(d=0;d!=c.length;++d)if(!(c[d].s.c>b)&&!(c[d].s.r>g)&&!(c[d].e.c<b)&&!(c[d].e.r<g)){(c[d].s.c!=b||c[d].s.r!=g)&&(j=!0);break}if(!j){var _={r:g,c:b},N=hr(_),k=h?(t[g]||[])[b]:t[N];p.push(zA(k,N,t,a,r,s,_))}}p.push("</Row>"),p.length>2&&m.push(p.join(""))}return m.join("")}function $A(t,a,r){var s=[],i=r.SheetNames[t],c=r.Sheets[i],d=c?PA(c,a,t,r):"";return d.length>0&&s.push("<Names>"+d+"</Names>"),d=c?UA(c,a,t,r):"",d.length>0&&s.push("<Table>"+d+"</Table>"),s.push(FA(c,a,t,r)),s.join("")}function HA(t,a){a||(a={}),t.SSF||(t.SSF=In(Vr)),t.SSF&&(zh(),Ih(t.SSF),a.revssf=Bh(t.SSF),a.revssf[t.SSF[65535]]=0,a.ssf=t.SSF,a.cellXfs=[],Ml(a.cellXfs,{},{revssf:{General:0}}));var r=[];r.push(DA(t,a)),r.push(MA()),r.push(""),r.push("");for(var s=0;s<t.SheetNames.length;++s)r.push(qt("Worksheet",$A(s,a,t),{"ss:Name":mr(t.SheetNames[s])}));return r[2]=LA(t,a),r[3]=RA(t),us+qt("Workbook",r.join(""),{xmlns:ti.ss,"xmlns:o":ti.o,"xmlns:x":ti.x,"xmlns:ss":ti.ss,"xmlns:dt":ti.dt,"xmlns:html":ti.html})}var ox={SI:"e0859ff2f94f6810ab9108002b27b3d9",DSI:"02d5cdd59c2e1b10939708002b2cf9ae",UDI:"05d5cdd59c2e1b10939708002b2cf9ae"};function WA(t,a){var r=[],s=[],i=[],c=0,d,m=L1(G1,"n"),h=L1(Y1,"n");if(t.Props)for(d=Xs(t.Props),c=0;c<d.length;++c)(Object.prototype.hasOwnProperty.call(m,d[c])?r:Object.prototype.hasOwnProperty.call(h,d[c])?s:i).push([d[c],t.Props[d[c]]]);if(t.Custprops)for(d=Xs(t.Custprops),c=0;c<d.length;++c)Object.prototype.hasOwnProperty.call(t.Props||{},d[c])||(Object.prototype.hasOwnProperty.call(m,d[c])?r:Object.prototype.hasOwnProperty.call(h,d[c])?s:i).push([d[c],t.Custprops[d[c]]]);var g=[];for(c=0;c<i.length;++c)jw.indexOf(i[c][0])>-1||_w.indexOf(i[c][0])>-1||i[c][1]!=null&&g.push(i[c]);s.length&&vr.utils.cfb_add(a,"/SummaryInformation",Q1(s,ox.SI,h,Y1)),(r.length||g.length)&&vr.utils.cfb_add(a,"/DocumentSummaryInformation",Q1(r,ox.DSI,m,G1,g.length?g:null,ox.UDI))}function VA(t,a){var r=a||{},s=vr.utils.cfb_new({root:"R"}),i="/Workbook";switch(r.bookType||"xls"){case"xls":r.bookType="biff8";case"xla":r.bookType||(r.bookType="xla");case"biff8":i="/Workbook",r.biff=8;break;case"biff5":i="/Book",r.biff=5;break;default:throw new Error("invalid type "+r.bookType+" for XLS CFB")}return vr.utils.cfb_add(s,i,tk(t,r)),r.biff==8&&(t.Props||t.Custprops)&&WA(t,s),r.biff==8&&t.vbaraw&&cE(s,vr.read(t.vbaraw,{type:typeof t.vbaraw=="string"?"binary":"buffer"})),s}var qA={0:{f:Z7},1:{f:r8},2:{f:k8},3:{f:u8},4:{f:o8},5:{f:b8},6:{f:T8},7:{f:f8},8:{f:R8},9:{f:L8},10:{f:D8},11:{f:M8},12:{f:n8},13:{f:N8},14:{f:h8},15:{f:c8},16:{f:_8},17:{f:A8},18:{f:p8},19:{f:cp},20:{},21:{},22:{},23:{},24:{},25:{},26:{},27:{},28:{},29:{},30:{},31:{},32:{},33:{},34:{},35:{T:1},36:{T:-1},37:{T:1},38:{T:-1},39:{f:vA},40:{},42:{},43:{f:TT},44:{f:ST},45:{f:OT},46:{f:MT},47:{f:DT},48:{},49:{f:nC},50:{},51:{f:ZT},52:{T:1},53:{T:-1},54:{T:1},55:{T:-1},56:{T:1},57:{T:-1},58:{},59:{},60:{f:iT},62:{f:C8},63:{f:tE},64:{f:X8},65:{},66:{},67:{},68:{},69:{},70:{},128:{},129:{T:1},130:{T:-1},131:{T:1,f:fo,p:0},132:{T:-1},133:{T:1},134:{T:-1},135:{T:1},136:{T:-1},137:{T:1,f:G8},138:{T:-1},139:{T:1},140:{T:-1},141:{T:1},142:{T:-1},143:{T:1},144:{T:-1},145:{T:1},146:{T:-1},147:{f:t8},148:{f:K7,p:16},151:{f:U8},152:{},153:{f:yA},154:{},155:{},156:{f:xA},157:{},158:{},159:{T:1,f:xT},160:{T:-1},161:{T:1,f:Mc},162:{T:-1},163:{T:1},164:{T:-1},165:{T:1},166:{T:-1},167:{},168:{},169:{},170:{},171:{},172:{T:1},173:{T:-1},174:{},175:{},176:{f:P8},177:{T:1},178:{T:-1},179:{T:1},180:{T:-1},181:{T:1},182:{T:-1},183:{T:1},184:{T:-1},185:{T:1},186:{T:-1},187:{T:1},188:{T:-1},189:{T:1},190:{T:-1},191:{T:1},192:{T:-1},193:{T:1},194:{T:-1},195:{T:1},196:{T:-1},197:{T:1},198:{T:-1},199:{T:1},200:{T:-1},201:{T:1},202:{T:-1},203:{T:1},204:{T:-1},205:{T:1},206:{T:-1},207:{T:1},208:{T:-1},209:{T:1},210:{T:-1},211:{T:1},212:{T:-1},213:{T:1},214:{T:-1},215:{T:1},216:{T:-1},217:{T:1},218:{T:-1},219:{T:1},220:{T:-1},221:{T:1},222:{T:-1},223:{T:1},224:{T:-1},225:{T:1},226:{T:-1},227:{T:1},228:{T:-1},229:{T:1},230:{T:-1},231:{T:1},232:{T:-1},233:{T:1},234:{T:-1},235:{T:1},236:{T:-1},237:{T:1},238:{T:-1},239:{T:1},240:{T:-1},241:{T:1},242:{T:-1},243:{T:1},244:{T:-1},245:{T:1},246:{T:-1},247:{T:1},248:{T:-1},249:{T:1},250:{T:-1},251:{T:1},252:{T:-1},253:{T:1},254:{T:-1},255:{T:1},256:{T:-1},257:{T:1},258:{T:-1},259:{T:1},260:{T:-1},261:{T:1},262:{T:-1},263:{T:1},264:{T:-1},265:{T:1},266:{T:-1},267:{T:1},268:{T:-1},269:{T:1},270:{T:-1},271:{T:1},272:{T:-1},273:{T:1},274:{T:-1},275:{T:1},276:{T:-1},277:{},278:{T:1},279:{T:-1},280:{T:1},281:{T:-1},282:{T:1},283:{T:1},284:{T:-1},285:{T:1},286:{T:-1},287:{T:1},288:{T:-1},289:{T:1},290:{T:-1},291:{T:1},292:{T:-1},293:{T:1},294:{T:-1},295:{T:1},296:{T:-1},297:{T:1},298:{T:-1},299:{T:1},300:{T:-1},301:{T:1},302:{T:-1},303:{T:1},304:{T:-1},305:{T:1},306:{T:-1},307:{T:1},308:{T:-1},309:{T:1},310:{T:-1},311:{T:1},312:{T:-1},313:{T:-1},314:{T:1},315:{T:-1},316:{T:1},317:{T:-1},318:{T:1},319:{T:-1},320:{T:1},321:{T:-1},322:{T:1},323:{T:-1},324:{T:1},325:{T:-1},326:{T:1},327:{T:-1},328:{T:1},329:{T:-1},330:{T:1},331:{T:-1},332:{T:1},333:{T:-1},334:{T:1},335:{f:GT},336:{T:-1},337:{f:KT,T:1},338:{T:-1},339:{T:1},340:{T:-1},341:{T:1},342:{T:-1},343:{T:1},344:{T:-1},345:{T:1},346:{T:-1},347:{T:1},348:{T:-1},349:{T:1},350:{T:-1},351:{},352:{},353:{T:1},354:{T:-1},355:{f:Ax},357:{},358:{},359:{},360:{T:1},361:{},362:{f:eT},363:{},364:{},366:{},367:{},368:{},369:{},370:{},371:{},372:{T:1},373:{T:-1},374:{T:1},375:{T:-1},376:{T:1},377:{T:-1},378:{T:1},379:{T:-1},380:{T:1},381:{T:-1},382:{T:1},383:{T:-1},384:{T:1},385:{T:-1},386:{T:1},387:{T:-1},388:{T:1},389:{T:-1},390:{T:1},391:{T:-1},392:{T:1},393:{T:-1},394:{T:1},395:{T:-1},396:{},397:{},398:{},399:{},400:{},401:{T:1},403:{},404:{},405:{},406:{},407:{},408:{},409:{},410:{},411:{},412:{},413:{},414:{},415:{},416:{},417:{},418:{},419:{},420:{},421:{},422:{T:1},423:{T:1},424:{T:-1},425:{T:-1},426:{f:$8},427:{f:H8},428:{},429:{T:1},430:{T:-1},431:{T:1},432:{T:-1},433:{T:1},434:{T:-1},435:{T:1},436:{T:-1},437:{T:1},438:{T:-1},439:{T:1},440:{T:-1},441:{T:1},442:{T:-1},443:{T:1},444:{T:-1},445:{T:1},446:{T:-1},447:{T:1},448:{T:-1},449:{T:1},450:{T:-1},451:{T:1},452:{T:-1},453:{T:1},454:{T:-1},455:{T:1},456:{T:-1},457:{T:1},458:{T:-1},459:{T:1},460:{T:-1},461:{T:1},462:{T:-1},463:{T:1},464:{T:-1},465:{T:1},466:{T:-1},467:{T:1},468:{T:-1},469:{T:1},470:{T:-1},471:{},472:{},473:{T:1},474:{T:-1},475:{},476:{f:V8},477:{},478:{},479:{T:1},480:{T:-1},481:{T:1},482:{T:-1},483:{T:1},484:{T:-1},485:{f:e8},486:{T:1},487:{T:-1},488:{T:1},489:{T:-1},490:{T:1},491:{T:-1},492:{T:1},493:{T:-1},494:{f:z8},495:{T:1},496:{T:-1},497:{T:1},498:{T:-1},499:{},500:{T:1},501:{T:-1},502:{T:1},503:{T:-1},504:{},505:{T:1},506:{T:-1},507:{},508:{T:1},509:{T:-1},510:{T:1},511:{T:-1},512:{},513:{},514:{T:1},515:{T:-1},516:{T:1},517:{T:-1},518:{T:1},519:{T:-1},520:{T:1},521:{T:-1},522:{},523:{},524:{},525:{},526:{},527:{},528:{T:1},529:{T:-1},530:{T:1},531:{T:-1},532:{T:1},533:{T:-1},534:{},535:{},536:{},537:{},538:{T:1},539:{T:-1},540:{T:1},541:{T:-1},542:{T:1},548:{},549:{},550:{f:Ax},551:{},552:{},553:{},554:{T:1},555:{T:-1},556:{T:1},557:{T:-1},558:{T:1},559:{T:-1},560:{T:1},561:{T:-1},562:{},564:{},565:{T:1},566:{T:-1},569:{T:1},570:{T:-1},572:{},573:{T:1},574:{T:-1},577:{},578:{},579:{},580:{},581:{},582:{},583:{},584:{},585:{},586:{},587:{},588:{T:-1},589:{},590:{T:1},591:{T:-1},592:{T:1},593:{T:-1},594:{T:1},595:{T:-1},596:{},597:{T:1},598:{T:-1},599:{T:1},600:{T:-1},601:{T:1},602:{T:-1},603:{T:1},604:{T:-1},605:{T:1},606:{T:-1},607:{},608:{T:1},609:{T:-1},610:{},611:{T:1},612:{T:-1},613:{T:1},614:{T:-1},615:{T:1},616:{T:-1},617:{T:1},618:{T:-1},619:{T:1},620:{T:-1},625:{},626:{T:1},627:{T:-1},628:{T:1},629:{T:-1},630:{T:1},631:{T:-1},632:{f:iE},633:{T:1},634:{T:-1},635:{T:1,f:sE},636:{T:-1},637:{f:cC},638:{T:1},639:{},640:{T:-1},641:{T:1},642:{T:-1},643:{T:1},644:{},645:{T:-1},646:{T:1},648:{T:1},649:{},650:{T:-1},651:{f:dA},652:{},653:{T:1},654:{T:-1},655:{T:1},656:{T:-1},657:{T:1},658:{T:-1},659:{},660:{T:1},661:{},662:{T:-1},663:{},664:{T:1},665:{},666:{T:-1},667:{},668:{},669:{},671:{T:1},672:{T:-1},673:{T:1},674:{T:-1},675:{},676:{},677:{},678:{},679:{},680:{},681:{},1024:{},1025:{},1026:{T:1},1027:{T:-1},1028:{T:1},1029:{T:-1},1030:{},1031:{T:1},1032:{T:-1},1033:{T:1},1034:{T:-1},1035:{},1036:{},1037:{},1038:{T:1},1039:{T:-1},1040:{},1041:{T:1},1042:{T:-1},1043:{},1044:{},1045:{},1046:{T:1},1047:{T:-1},1048:{T:1},1049:{T:-1},1050:{},1051:{T:1},1052:{T:1},1053:{f:K8},1054:{T:1},1055:{},1056:{T:1},1057:{T:-1},1058:{T:1},1059:{T:-1},1061:{},1062:{T:1},1063:{T:-1},1064:{T:1},1065:{T:-1},1066:{T:1},1067:{T:-1},1068:{T:1},1069:{T:-1},1070:{T:1},1071:{T:-1},1072:{T:1},1073:{T:-1},1075:{T:1},1076:{T:-1},1077:{T:1},1078:{T:-1},1079:{T:1},1080:{T:-1},1081:{T:1},1082:{T:-1},1083:{T:1},1084:{T:-1},1085:{},1086:{T:1},1087:{T:-1},1088:{T:1},1089:{T:-1},1090:{T:1},1091:{T:-1},1092:{T:1},1093:{T:-1},1094:{T:1},1095:{T:-1},1096:{},1097:{T:1},1098:{},1099:{T:-1},1100:{T:1},1101:{T:-1},1102:{},1103:{},1104:{},1105:{},1111:{},1112:{},1113:{T:1},1114:{T:-1},1115:{T:1},1116:{T:-1},1117:{},1118:{T:1},1119:{T:-1},1120:{T:1},1121:{T:-1},1122:{T:1},1123:{T:-1},1124:{T:1},1125:{T:-1},1126:{},1128:{T:1},1129:{T:-1},1130:{},1131:{T:1},1132:{T:-1},1133:{T:1},1134:{T:-1},1135:{T:1},1136:{T:-1},1137:{T:1},1138:{T:-1},1139:{T:1},1140:{T:-1},1141:{},1142:{T:1},1143:{T:-1},1144:{T:1},1145:{T:-1},1146:{},1147:{T:1},1148:{T:-1},1149:{T:1},1150:{T:-1},1152:{T:1},1153:{T:-1},1154:{T:-1},1155:{T:-1},1156:{T:-1},1157:{T:1},1158:{T:-1},1159:{T:1},1160:{T:-1},1161:{T:1},1162:{T:-1},1163:{T:1},1164:{T:-1},1165:{T:1},1166:{T:-1},1167:{T:1},1168:{T:-1},1169:{T:1},1170:{T:-1},1171:{},1172:{T:1},1173:{T:-1},1177:{},1178:{T:1},1180:{},1181:{},1182:{},2048:{T:1},2049:{T:-1},2050:{},2051:{T:1},2052:{T:-1},2053:{},2054:{},2055:{T:1},2056:{T:-1},2057:{T:1},2058:{T:-1},2060:{},2067:{},2068:{T:1},2069:{T:-1},2070:{},2071:{},2072:{T:1},2073:{T:-1},2075:{},2076:{},2077:{T:1},2078:{T:-1},2079:{},2080:{T:1},2081:{T:-1},2082:{},2083:{T:1},2084:{T:-1},2085:{T:1},2086:{T:-1},2087:{T:1},2088:{T:-1},2089:{T:1},2090:{T:-1},2091:{},2092:{},2093:{T:1},2094:{T:-1},2095:{},2096:{T:1},2097:{T:-1},2098:{T:1},2099:{T:-1},2100:{T:1},2101:{T:-1},2102:{},2103:{T:1},2104:{T:-1},2105:{},2106:{T:1},2107:{T:-1},2108:{},2109:{T:1},2110:{T:-1},2111:{T:1},2112:{T:-1},2113:{T:1},2114:{T:-1},2115:{},2116:{},2117:{},2118:{T:1},2119:{T:-1},2120:{},2121:{T:1},2122:{T:-1},2123:{T:1},2124:{T:-1},2125:{},2126:{T:1},2127:{T:-1},2128:{},2129:{T:1},2130:{T:-1},2131:{T:1},2132:{T:-1},2133:{T:1},2134:{},2135:{},2136:{},2137:{T:1},2138:{T:-1},2139:{T:1},2140:{T:-1},2141:{},3072:{},3073:{},4096:{T:1},4097:{T:-1},5002:{T:1},5003:{T:-1},5081:{T:1},5082:{T:-1},5083:{},5084:{T:1},5085:{T:-1},5086:{T:1},5087:{T:-1},5088:{},5089:{},5090:{},5092:{T:1},5093:{T:-1},5094:{},5095:{T:1},5096:{T:-1},5097:{},5099:{},65535:{n:""}};function Gt(t,a,r,s){var i=a;if(!isNaN(i)){var c=s||(r||[]).length||0,d=t.next(4);d.write_shift(2,i),d.write_shift(2,c),c>0&&ip(r)&&t.push(r)}}function GA(t,a,r,s){var i=(r||[]).length||0;if(i<=8224)return Gt(t,a,r,i);var c=a;if(!isNaN(c)){for(var d=r.parts||[],m=0,h=0,g=0;g+(d[m]||8224)<=8224;)g+=d[m]||8224,m++;var p=t.next(4);for(p.write_shift(2,c),p.write_shift(2,g),t.push(r.slice(h,h+g)),h+=g;h<i;){for(p=t.next(4),p.write_shift(2,60),g=0;g+(d[m]||8224)<=8224;)g+=d[m]||8224,m++;p.write_shift(2,g),t.push(r.slice(h,h+g)),h+=g}}}function Ou(t,a,r){return t||(t=bt(7)),t.write_shift(2,a),t.write_shift(2,r),t.write_shift(2,0),t.write_shift(1,0),t}function YA(t,a,r,s){var i=bt(9);return Ou(i,t,a),Sw(r,s||"b",i),i}function ZA(t,a,r){var s=bt(8+2*r.length);return Ou(s,t,a),s.write_shift(1,r.length),s.write_shift(r.length,r,"sbcs"),s.l<s.length?s.slice(0,s.l):s}function JA(t,a,r,s){if(a.v!=null)switch(a.t){case"d":case"n":var i=a.t=="d"?Fn(bn(a.v)):a.v;i==(i|0)&&i>=0&&i<65536?Gt(t,2,dT(r,s,i)):Gt(t,3,cT(r,s,i));return;case"b":case"e":Gt(t,5,YA(r,s,a.v,a.t));return;case"s":case"str":Gt(t,4,ZA(r,s,(a.v||"").slice(0,255)));return}Gt(t,1,Ou(null,r,s))}function XA(t,a,r,s){var i=Array.isArray(a),c=Dr(a["!ref"]||"A1"),d,m="",h=[];if(c.e.c>255||c.e.r>16383){if(s.WTF)throw new Error("Range "+(a["!ref"]||"A1")+" exceeds format limit A1:IV16384");c.e.c=Math.min(c.e.c,255),c.e.r=Math.min(c.e.c,16383),d=ls(c)}for(var g=c.s.r;g<=c.e.r;++g){m=Ys(g);for(var p=c.s.c;p<=c.e.c;++p){g===c.s.r&&(h[p]=on(p)),d=h[p]+m;var b=i?(a[g]||[])[p]:a[d];b&&JA(t,b,g,p)}}}function KA(t,a){for(var r=a||{},s=Ln(),i=0,c=0;c<t.SheetNames.length;++c)t.SheetNames[c]==r.sheet&&(i=c);if(i==0&&r.sheet&&t.SheetNames[0]!=r.sheet)throw new Error("Sheet not found: "+r.sheet);return Gt(s,r.biff==4?1033:r.biff==3?521:9,mp(t,16,r)),XA(s,t.Sheets[t.SheetNames[i]],i,r),Gt(s,10),s.end()}function QA(t,a,r){Gt(t,49,qC({sz:12,name:"Arial"},r))}function e9(t,a,r){a&&[[5,8],[23,26],[41,44],[50,392]].forEach(function(s){for(var i=s[0];i<=s[1];++i)a[i]!=null&&Gt(t,1054,ZC(i,a[i],r))})}function t9(t,a){var r=bt(19);r.write_shift(4,2151),r.write_shift(4,0),r.write_shift(4,0),r.write_shift(2,3),r.write_shift(1,1),r.write_shift(4,0),Gt(t,2151,r),r=bt(39),r.write_shift(4,2152),r.write_shift(4,0),r.write_shift(4,0),r.write_shift(2,3),r.write_shift(1,0),r.write_shift(4,0),r.write_shift(2,1),r.write_shift(4,4),r.write_shift(2,0),Ew(Dr(a["!ref"]||"A1"),r),r.write_shift(4,4),Gt(t,2152,r)}function a9(t,a){for(var r=0;r<16;++r)Gt(t,224,t_({numFmtId:0,style:!0},0,a));a.cellXfs.forEach(function(s){Gt(t,224,t_(s,0,a))})}function r9(t,a){for(var r=0;r<a["!links"].length;++r){var s=a["!links"][r];Gt(t,440,rT(s)),s[1].Tooltip&&Gt(t,2048,sT(s))}delete a["!links"]}function s9(t,a){if(a){var r=0;a.forEach(function(s,i){++r<=256&&s&&Gt(t,125,oT(Wh(i,s),i))})}}function n9(t,a,r,s,i){var c=16+Ml(i.cellXfs,a,i);if(a.v==null&&!a.bf){Gt(t,513,Nc(r,s,c));return}if(a.bf)Gt(t,6,E7(a,r,s,i,c));else switch(a.t){case"d":case"n":var d=a.t=="d"?Fn(bn(a.v)):a.v;Gt(t,515,QC(r,s,d,c));break;case"b":case"e":Gt(t,517,KC(r,s,a.v,c,i,a.t));break;case"s":case"str":if(i.bookSST){var m=pp(i.Strings,a.v,i.revStrings);Gt(t,253,GC(r,s,m,c))}else Gt(t,516,YC(r,s,(a.v||"").slice(0,255),c,i));break;default:Gt(t,513,Nc(r,s,c))}}function i9(t,a,r){var s=Ln(),i=r.SheetNames[t],c=r.Sheets[i]||{},d=(r||{}).Workbook||{},m=(d.Sheets||[])[t]||{},h=Array.isArray(c),g=a.biff==8,p,b="",j=[],_=Dr(c["!ref"]||"A1"),N=g?65536:16384;if(_.e.c>255||_.e.r>=N){if(a.WTF)throw new Error("Range "+(c["!ref"]||"A1")+" exceeds format limit A1:IV16384");_.e.c=Math.min(_.e.c,255),_.e.r=Math.min(_.e.c,N-1)}Gt(s,2057,mp(r,16,a)),Gt(s,13,yi(1)),Gt(s,12,yi(100)),Gt(s,15,pn(!0)),Gt(s,17,pn(!1)),Gt(s,16,jc(.001)),Gt(s,95,pn(!0)),Gt(s,42,pn(!1)),Gt(s,43,pn(!1)),Gt(s,130,yi(1)),Gt(s,128,XC()),Gt(s,131,pn(!1)),Gt(s,132,pn(!1)),g&&s9(s,c["!cols"]),Gt(s,512,JC(_,a)),g&&(c["!links"]=[]);for(var k=_.s.r;k<=_.e.r;++k){b=Ys(k);for(var C=_.s.c;C<=_.e.c;++C){k===_.s.r&&(j[C]=on(C)),p=j[C]+b;var D=h?(c[k]||[])[C]:c[p];D&&(n9(s,D,k,C,a),g&&D.l&&c["!links"].push([p,D.l]))}}var T=m.CodeName||m.name||i;return g&&Gt(s,574,VC((d.Views||[])[0])),g&&(c["!merges"]||[]).length&&Gt(s,229,aT(c["!merges"])),g&&r9(s,c),Gt(s,442,Tw(T)),g&&t9(s,c),Gt(s,10),s.end()}function o9(t,a,r){var s=Ln(),i=(t||{}).Workbook||{},c=i.Sheets||[],d=i.WBProps||{},m=r.biff==8,h=r.biff==5;if(Gt(s,2057,mp(t,5,r)),r.bookType=="xla"&&Gt(s,135),Gt(s,225,m?yi(1200):null),Gt(s,193,DC(2)),h&&Gt(s,191),h&&Gt(s,192),Gt(s,226),Gt(s,92,UC("SheetJS",r)),Gt(s,66,yi(m?1200:1252)),m&&Gt(s,353,yi(0)),m&&Gt(s,448),Gt(s,317,lT(t.SheetNames.length)),m&&t.vbaraw&&Gt(s,211),m&&t.vbaraw){var g=d.CodeName||"ThisWorkbook";Gt(s,442,Tw(g))}Gt(s,156,yi(17)),Gt(s,25,pn(!1)),Gt(s,18,pn(!1)),Gt(s,19,yi(0)),m&&Gt(s,431,pn(!1)),m&&Gt(s,444,yi(0)),Gt(s,61,WC()),Gt(s,64,pn(!1)),Gt(s,141,yi(0)),Gt(s,34,pn(mA(t)=="true")),Gt(s,14,pn(!0)),m&&Gt(s,439,pn(!1)),Gt(s,218,yi(0)),QA(s,t,r),e9(s,t.SSF,r),a9(s,r),m&&Gt(s,352,pn(!1));var p=s.end(),b=Ln();m&&Gt(b,140,nT()),m&&r.Strings&&GA(b,252,HC(r.Strings)),Gt(b,10);var j=b.end(),_=Ln(),N=0,k=0;for(k=0;k<t.SheetNames.length;++k)N+=(m?12:11)+(m?2:1)*t.SheetNames[k].length;var C=p.length+N+j.length;for(k=0;k<t.SheetNames.length;++k){var D=c[k]||{};Gt(_,133,$C({pos:C,hs:D.Hidden||0,dt:0,name:t.SheetNames[k]},r)),C+=a[k].length}var T=_.end();if(N!=T.length)throw new Error("BS8 "+N+" != "+T.length);var E=[];return p.length&&E.push(p),T.length&&E.push(T),j.length&&E.push(j),qs(E)}function l9(t,a){var r=a||{},s=[];t&&!t.SSF&&(t.SSF=In(Vr)),t&&t.SSF&&(zh(),Ih(t.SSF),r.revssf=Bh(t.SSF),r.revssf[t.SSF[65535]]=0,r.ssf=t.SSF),r.Strings=[],r.Strings.Count=0,r.Strings.Unique=0,yp(r),r.cellXfs=[],Ml(r.cellXfs,{},{revssf:{General:0}}),t.Props||(t.Props={});for(var i=0;i<t.SheetNames.length;++i)s[s.length]=i9(i,r,t);return s.unshift(o9(t,s,r)),qs(s)}function tk(t,a){for(var r=0;r<=t.SheetNames.length;++r){var s=t.Sheets[t.SheetNames[r]];if(!(!s||!s["!ref"])){var i=ni(s["!ref"]);i.e.c>255&&typeof console!="undefined"&&console.error&&console.error("Worksheet '"+t.SheetNames[r]+"' extends beyond column IV (255). Data may be lost.")}}var c=a||{};switch(c.biff||2){case 8:case 5:return l9(t,a);case 4:case 3:case 2:return KA(t,a)}throw new Error("invalid type "+c.bookType+" for BIFF")}function c9(t,a,r,s){for(var i=t["!merges"]||[],c=[],d=a.s.c;d<=a.e.c;++d){for(var m=0,h=0,g=0;g<i.length;++g)if(!(i[g].s.r>r||i[g].s.c>d)&&!(i[g].e.r<r||i[g].e.c<d)){if(i[g].s.r<r||i[g].s.c<d){m=-1;break}m=i[g].e.r-i[g].s.r+1,h=i[g].e.c-i[g].s.c+1;break}if(!(m<0)){var p=hr({r,c:d}),b=s.dense?(t[r]||[])[d]:t[p],j=b&&b.v!=null&&(b.h||B6(b.w||(Xo(b),b.w)||""))||"",_={};m>1&&(_.rowspan=m),h>1&&(_.colspan=h),s.editable?j='<span contenteditable="true">'+j+"</span>":b&&(_["data-t"]=b&&b.t||"z",b.v!=null&&(_["data-v"]=b.v),b.z!=null&&(_["data-z"]=b.z),b.l&&(b.l.Target||"#").charAt(0)!="#"&&(j='<a href="'+b.l.Target+'">'+j+"</a>")),_.id=(s.id||"sjs")+"-"+p,c.push(qt("td",j,_))}}var N="<tr>";return N+c.join("")+"</tr>"}var d9='<html><head><meta charset="utf-8"/><title>SheetJS Table Export</title></head><body>',u9="</body></html>";function m9(t,a,r){var s=[];return s.join("")+"<table"+(r&&r.id?' id="'+r.id+'"':"")+">"}function ak(t,a){var r=a||{},s=r.header!=null?r.header:d9,i=r.footer!=null?r.footer:u9,c=[s],d=ni(t["!ref"]);r.dense=Array.isArray(t),c.push(m9(t,d,r));for(var m=d.s.r;m<=d.e.r;++m)c.push(c9(t,d,m,r));return c.push("</table>"+i),c.join("")}function rk(t,a,r){var s=r||{},i=0,c=0;if(s.origin!=null)if(typeof s.origin=="number")i=s.origin;else{var d=typeof s.origin=="string"?Ss(s.origin):s.origin;i=d.r,c=d.c}var m=a.getElementsByTagName("tr"),h=Math.min(s.sheetRows||1e7,m.length),g={s:{r:0,c:0},e:{r:i,c}};if(t["!ref"]){var p=ni(t["!ref"]);g.s.r=Math.min(g.s.r,p.s.r),g.s.c=Math.min(g.s.c,p.s.c),g.e.r=Math.max(g.e.r,p.e.r),g.e.c=Math.max(g.e.c,p.e.c),i==-1&&(g.e.r=i=p.e.r+1)}var b=[],j=0,_=t["!rows"]||(t["!rows"]=[]),N=0,k=0,C=0,D=0,T=0,E=0;for(t["!cols"]||(t["!cols"]=[]);N<m.length&&k<h;++N){var O=m[N];if(l_(O)){if(s.display)continue;_[k]={hidden:!0}}var R=O.children;for(C=D=0;C<R.length;++C){var Y=R[C];if(!(s.display&&l_(Y))){var P=Y.hasAttribute("data-v")?Y.getAttribute("data-v"):Y.hasAttribute("v")?Y.getAttribute("v"):W6(Y.innerHTML),U=Y.getAttribute("data-z")||Y.getAttribute("z");for(j=0;j<b.length;++j){var J=b[j];J.s.c==D+c&&J.s.r<k+i&&k+i<=J.e.r&&(D=J.e.c+1-c,j=-1)}E=+Y.getAttribute("colspan")||1,((T=+Y.getAttribute("rowspan")||1)>1||E>1)&&b.push({s:{r:k+i,c:D+c},e:{r:k+i+(T||1)-1,c:D+c+(E||1)-1}});var ne={t:"s",v:P},ye=Y.getAttribute("data-t")||Y.getAttribute("t")||"";P!=null&&(P.length==0?ne.t=ye||"z":s.raw||P.trim().length==0||ye=="s"||(P==="TRUE"?ne={t:"b",v:!0}:P==="FALSE"?ne={t:"b",v:!1}:isNaN(Go(P))?isNaN(xu(P).getDate())||(ne={t:"d",v:bn(P)},s.cellDates||(ne={t:"n",v:Fn(ne.v)}),ne.z=s.dateNF||Vr[14]):ne={t:"n",v:Go(P)})),ne.z===void 0&&U!=null&&(ne.z=U);var he="",ce=Y.getElementsByTagName("A");if(ce&&ce.length)for(var se=0;se<ce.length&&!(ce[se].hasAttribute("href")&&(he=ce[se].getAttribute("href"),he.charAt(0)!="#"));++se);he&&he.charAt(0)!="#"&&(ne.l={Target:he}),s.dense?(t[k+i]||(t[k+i]=[]),t[k+i][D+c]=ne):t[hr({c:D+c,r:k+i})]=ne,g.e.c<D+c&&(g.e.c=D+c),D+=E}}++k}return b.length&&(t["!merges"]=(t["!merges"]||[]).concat(b)),g.e.r=Math.max(g.e.r,k-1+i),t["!ref"]=ls(g),k>=h&&(t["!fullref"]=ls((g.e.r=m.length-N+k-1+i,g))),t}function sk(t,a){var r=a||{},s=r.dense?[]:{};return rk(s,t,a)}function h9(t,a){return Ec(sk(t,a),a)}function l_(t){var a="",r=g9(t);return r&&(a=r(t).getPropertyValue("display")),a||(a=t.style&&t.style.display),a==="none"}function g9(t){return t.ownerDocument.defaultView&&typeof t.ownerDocument.defaultView.getComputedStyle=="function"?t.ownerDocument.defaultView.getComputedStyle:typeof getComputedStyle=="function"?getComputedStyle:null}var f9=(function(){var t=["<office:master-styles>",'<style:master-page style:name="mp1" style:page-layout-name="mp1">',"<style:header/>",'<style:header-left style:display="false"/>',"<style:footer/>",'<style:footer-left style:display="false"/>',"</style:master-page>","</office:master-styles>"].join(""),a="<office:document-styles "+yu({"xmlns:office":"urn:oasis:names:tc:opendocument:xmlns:office:1.0","xmlns:table":"urn:oasis:names:tc:opendocument:xmlns:table:1.0","xmlns:style":"urn:oasis:names:tc:opendocument:xmlns:style:1.0","xmlns:text":"urn:oasis:names:tc:opendocument:xmlns:text:1.0","xmlns:draw":"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0","xmlns:fo":"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0","xmlns:xlink":"http://www.w3.org/1999/xlink","xmlns:dc":"http://purl.org/dc/elements/1.1/","xmlns:number":"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0","xmlns:svg":"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0","xmlns:of":"urn:oasis:names:tc:opendocument:xmlns:of:1.2","office:version":"1.2"})+">"+t+"</office:document-styles>";return function(){return us+a}})(),c_=(function(){var t=function(c){return mr(c).replace(/ +/g,function(d){return'<text:s text:c="'+d.length+'"/>'}).replace(/\t/g,"<text:tab/>").replace(/\n/g,"</text:p><text:p>").replace(/^ /,"<text:s/>").replace(/ $/,"<text:s/>")},a=` <table:table-cell />
`,r=` <table:covered-table-cell/>
`,s=function(c,d,m){var h=[];h.push(' <table:table table:name="'+mr(d.SheetNames[m])+`" table:style-name="ta1">
`);var g=0,p=0,b=ni(c["!ref"]||"A1"),j=c["!merges"]||[],_=0,N=Array.isArray(c);if(c["!cols"])for(p=0;p<=b.e.c;++p)h.push(" <table:table-column"+(c["!cols"][p]?' table:style-name="co'+c["!cols"][p].ods+'"':"")+`></table:table-column>
`);var k="",C=c["!rows"]||[];for(g=0;g<b.s.r;++g)k=C[g]?' table:style-name="ro'+C[g].ods+'"':"",h.push(" <table:table-row"+k+`></table:table-row>
`);for(;g<=b.e.r;++g){for(k=C[g]?' table:style-name="ro'+C[g].ods+'"':"",h.push(" <table:table-row"+k+`>
`),p=0;p<b.s.c;++p)h.push(a);for(;p<=b.e.c;++p){var D=!1,T={},E="";for(_=0;_!=j.length;++_)if(!(j[_].s.c>p)&&!(j[_].s.r>g)&&!(j[_].e.c<p)&&!(j[_].e.r<g)){(j[_].s.c!=p||j[_].s.r!=g)&&(D=!0),T["table:number-columns-spanned"]=j[_].e.c-j[_].s.c+1,T["table:number-rows-spanned"]=j[_].e.r-j[_].s.r+1;break}if(D){h.push(r);continue}var O=hr({r:g,c:p}),R=N?(c[g]||[])[p]:c[O];if(R&&R.f&&(T["table:formula"]=mr(R7(R.f)),R.F&&R.F.slice(0,O.length)==O)){var Y=ni(R.F);T["table:number-matrix-columns-spanned"]=Y.e.c-Y.s.c+1,T["table:number-matrix-rows-spanned"]=Y.e.r-Y.s.r+1}if(!R){h.push(a);continue}switch(R.t){case"b":E=R.v?"TRUE":"FALSE",T["office:value-type"]="boolean",T["office:boolean-value"]=R.v?"true":"false";break;case"n":E=R.w||String(R.v||0),T["office:value-type"]="float",T["office:value"]=R.v||0;break;case"s":case"str":E=R.v==null?"":R.v,T["office:value-type"]="string";break;case"d":E=R.w||bn(R.v).toISOString(),T["office:value-type"]="date",T["office:date-value"]=bn(R.v).toISOString(),T["table:style-name"]="ce1";break;default:h.push(a);continue}var P=t(E);if(R.l&&R.l.Target){var U=R.l.Target;U=U.charAt(0)=="#"?"#"+P7(U.slice(1)):U,U.charAt(0)!="#"&&!U.match(/^\w+:/)&&(U="../"+U),P=qt("text:a",P,{"xlink:href":U.replace(/&/g,"&amp;")})}h.push(" "+qt("table:table-cell",qt("text:p",P,{}),T)+`
`)}h.push(` </table:table-row>
`)}return h.push(` </table:table>
`),h.join("")},i=function(c,d){c.push(` <office:automatic-styles>
`),c.push(` <number:date-style style:name="N37" number:automatic-order="true">
`),c.push(` <number:month number:style="long"/>
`),c.push(` <number:text>/</number:text>
`),c.push(` <number:day number:style="long"/>
`),c.push(` <number:text>/</number:text>
`),c.push(` <number:year/>
`),c.push(` </number:date-style>
`);var m=0;d.SheetNames.map(function(g){return d.Sheets[g]}).forEach(function(g){if(g&&g["!cols"]){for(var p=0;p<g["!cols"].length;++p)if(g["!cols"][p]){var b=g["!cols"][p];if(b.width==null&&b.wpx==null&&b.wch==null)continue;hp(b),b.ods=m;var j=g["!cols"][p].wpx+"px";c.push(' <style:style style:name="co'+m+`" style:family="table-column">
`),c.push(' <style:table-column-properties fo:break-before="auto" style:column-width="'+j+`"/>
`),c.push(` </style:style>
`),++m}}});var h=0;d.SheetNames.map(function(g){return d.Sheets[g]}).forEach(function(g){if(g&&g["!rows"]){for(var p=0;p<g["!rows"].length;++p)if(g["!rows"][p]){g["!rows"][p].ods=h;var b=g["!rows"][p].hpx+"px";c.push(' <style:style style:name="ro'+h+`" style:family="table-row">
`),c.push(' <style:table-row-properties fo:break-before="auto" style:row-height="'+b+`"/>
`),c.push(` </style:style>
`),++h}}}),c.push(` <style:style style:name="ta1" style:family="table" style:master-page-name="mp1">
`),c.push(` <style:table-properties table:display="true" style:writing-mode="lr-tb"/>
`),c.push(` </style:style>
`),c.push(` <style:style style:name="ce1" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N37"/>
`),c.push(` </office:automatic-styles>
`)};return function(d,m){var h=[us],g=yu({"xmlns:office":"urn:oasis:names:tc:opendocument:xmlns:office:1.0","xmlns:table":"urn:oasis:names:tc:opendocument:xmlns:table:1.0","xmlns:style":"urn:oasis:names:tc:opendocument:xmlns:style:1.0","xmlns:text":"urn:oasis:names:tc:opendocument:xmlns:text:1.0","xmlns:draw":"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0","xmlns:fo":"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0","xmlns:xlink":"http://www.w3.org/1999/xlink","xmlns:dc":"http://purl.org/dc/elements/1.1/","xmlns:meta":"urn:oasis:names:tc:opendocument:xmlns:meta:1.0","xmlns:number":"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0","xmlns:presentation":"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0","xmlns:svg":"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0","xmlns:chart":"urn:oasis:names:tc:opendocument:xmlns:chart:1.0","xmlns:dr3d":"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0","xmlns:math":"http://www.w3.org/1998/Math/MathML","xmlns:form":"urn:oasis:names:tc:opendocument:xmlns:form:1.0","xmlns:script":"urn:oasis:names:tc:opendocument:xmlns:script:1.0","xmlns:ooo":"http://openoffice.org/2004/office","xmlns:ooow":"http://openoffice.org/2004/writer","xmlns:oooc":"http://openoffice.org/2004/calc","xmlns:dom":"http://www.w3.org/2001/xml-events","xmlns:xforms":"http://www.w3.org/2002/xforms","xmlns:xsd":"http://www.w3.org/2001/XMLSchema","xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","xmlns:sheet":"urn:oasis:names:tc:opendocument:sh33tjs:1.0","xmlns:rpt":"http://openoffice.org/2005/report","xmlns:of":"urn:oasis:names:tc:opendocument:xmlns:of:1.2","xmlns:xhtml":"http://www.w3.org/1999/xhtml","xmlns:grddl":"http://www.w3.org/2003/g/data-view#","xmlns:tableooo":"http://openoffice.org/2009/table","xmlns:drawooo":"http://openoffice.org/2010/draw","xmlns:calcext":"urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0","xmlns:loext":"urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0","xmlns:field":"urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0","xmlns:formx":"urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0","xmlns:css3t":"http://www.w3.org/TR/css3-text/","office:version":"1.2"}),p=yu({"xmlns:config":"urn:oasis:names:tc:opendocument:xmlns:config:1.0","office:mimetype":"application/vnd.oasis.opendocument.spreadsheet"});m.bookType=="fods"?(h.push("<office:document"+g+p+`>
`),h.push(bw().replace(/office:document-meta/g,"office:meta"))):h.push("<office:document-content"+g+`>
`),i(h,d),h.push(` <office:body>
`),h.push(` <office:spreadsheet>
`);for(var b=0;b!=d.SheetNames.length;++b)h.push(s(d.Sheets[d.SheetNames[b]],d,b));return h.push(` </office:spreadsheet>
`),h.push(` </office:body>
`),m.bookType=="fods"?h.push("</office:document>"):h.push("</office:document-content>"),h.join("")}})();function nk(t,a){if(a.bookType=="fods")return c_(t,a);var r=ap(),s="",i=[],c=[];return s="mimetype",Ma(r,s,"application/vnd.oasis.opendocument.spreadsheet"),s="content.xml",Ma(r,s,c_(t,a)),i.push([s,"text/xml"]),c.push([s,"ContentFile"]),s="styles.xml",Ma(r,s,f9(t,a)),i.push([s,"text/xml"]),c.push([s,"StylesFile"]),s="meta.xml",Ma(r,s,us+bw()),i.push([s,"text/xml"]),c.push([s,"MetadataFile"]),s="manifest.rdf",Ma(r,s,CC(c)),i.push([s,"application/rdf+xml"]),s="META-INF/manifest.xml",Ma(r,s,NC(i)),r}function Th(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function x9(t){return typeof TextEncoder!="undefined"?new TextEncoder().encode(t):Mi(pu(t))}function p9(t,a){e:for(var r=0;r<=t.length-a.length;++r){for(var s=0;s<a.length;++s)if(t[r+s]!=a[s])continue e;return!0}return!1}function Dl(t){var a=t.reduce(function(i,c){return i+c.length},0),r=new Uint8Array(a),s=0;return t.forEach(function(i){r.set(i,s),s+=i.length}),r}function y9(t,a,r){var s=Math.floor(r==0?0:Math.LOG10E*Math.log(Math.abs(r)))+6176-20,i=r/Math.pow(10,s-6176);t[a+15]|=s>>7,t[a+14]|=(s&127)<<1;for(var c=0;i>=1;++c,i/=256)t[a+c]=i&255;t[a+15]|=r>=0?0:128}function bu(t,a){var r=a?a[0]:0,s=t[r]&127;e:if(t[r++]>=128&&(s|=(t[r]&127)<<7,t[r++]<128||(s|=(t[r]&127)<<14,t[r++]<128)||(s|=(t[r]&127)<<21,t[r++]<128)||(s+=(t[r]&127)*Math.pow(2,28),++r,t[r++]<128)||(s+=(t[r]&127)*Math.pow(2,35),++r,t[r++]<128)||(s+=(t[r]&127)*Math.pow(2,42),++r,t[r++]<128)))break e;return a&&(a[0]=r),s}function dr(t){var a=new Uint8Array(7);a[0]=t&127;var r=1;e:if(t>127){if(a[r-1]|=128,a[r]=t>>7&127,++r,t<=16383||(a[r-1]|=128,a[r]=t>>14&127,++r,t<=2097151)||(a[r-1]|=128,a[r]=t>>21&127,++r,t<=268435455)||(a[r-1]|=128,a[r]=t/256>>>21&127,++r,t<=34359738367)||(a[r-1]|=128,a[r]=t/65536>>>21&127,++r,t<=4398046511103))break e;a[r-1]|=128,a[r]=t/16777216>>>21&127,++r}return a.slice(0,r)}function Fd(t){var a=0,r=t[a]&127;e:if(t[a++]>=128){if(r|=(t[a]&127)<<7,t[a++]<128||(r|=(t[a]&127)<<14,t[a++]<128)||(r|=(t[a]&127)<<21,t[a++]<128))break e;r|=(t[a]&127)<<28}return r}function bs(t){for(var a=[],r=[0];r[0]<t.length;){var s=r[0],i=bu(t,r),c=i&7;i=Math.floor(i/8);var d=0,m;if(i==0)break;switch(c){case 0:{for(var h=r[0];t[r[0]++]>=128;);m=t.slice(h,r[0])}break;case 5:d=4,m=t.slice(r[0],r[0]+d),r[0]+=d;break;case 1:d=8,m=t.slice(r[0],r[0]+d),r[0]+=d;break;case 2:d=bu(t,r),m=t.slice(r[0],r[0]+d),r[0]+=d;break;case 3:case 4:default:throw new Error("PB Type ".concat(c," for Field ").concat(i," at offset ").concat(s))}var g={data:m,type:c};a[i]==null?a[i]=[g]:a[i].push(g)}return a}function Ws(t){var a=[];return t.forEach(function(r,s){r.forEach(function(i){i.data&&(a.push(dr(s*8+i.type)),i.type==2&&a.push(dr(i.data.length)),a.push(i.data))})}),Dl(a)}function Ai(t){for(var a,r=[],s=[0];s[0]<t.length;){var i=bu(t,s),c=bs(t.slice(s[0],s[0]+i));s[0]+=i;var d={id:Fd(c[1][0].data),messages:[]};c[2].forEach(function(m){var h=bs(m.data),g=Fd(h[3][0].data);d.messages.push({meta:h,data:t.slice(s[0],s[0]+g)}),s[0]+=g}),(a=c[3])!=null&&a[0]&&(d.merge=Fd(c[3][0].data)>>>0>0),r.push(d)}return r}function kd(t){var a=[];return t.forEach(function(r){var s=[];s[1]=[{data:dr(r.id),type:0}],s[2]=[],r.merge!=null&&(s[3]=[{data:dr(+!!r.merge),type:0}]);var i=[];r.messages.forEach(function(d){i.push(d.data),d.meta[3]=[{type:0,data:dr(d.data.length)}],s[2].push({data:Ws(d.meta),type:2})});var c=Ws(s);a.push(dr(c.length)),a.push(c),i.forEach(function(d){return a.push(d)})}),Dl(a)}function b9(t,a){if(t!=0)throw new Error("Unexpected Snappy chunk type ".concat(t));for(var r=[0],s=bu(a,r),i=[];r[0]<a.length;){var c=a[r[0]]&3;if(c==0){var d=a[r[0]++]>>2;if(d<60)++d;else{var m=d-59;d=a[r[0]],m>1&&(d|=a[r[0]+1]<<8),m>2&&(d|=a[r[0]+2]<<16),m>3&&(d|=a[r[0]+3]<<24),d>>>=0,d++,r[0]+=m}i.push(a.slice(r[0],r[0]+d)),r[0]+=d;continue}else{var h=0,g=0;if(c==1?(g=(a[r[0]]>>2&7)+4,h=(a[r[0]++]&224)<<3,h|=a[r[0]++]):(g=(a[r[0]++]>>2)+1,c==2?(h=a[r[0]]|a[r[0]+1]<<8,r[0]+=2):(h=(a[r[0]]|a[r[0]+1]<<8|a[r[0]+2]<<16|a[r[0]+3]<<24)>>>0,r[0]+=4)),i=[Dl(i)],h==0)throw new Error("Invalid offset 0");if(h>i[0].length)throw new Error("Invalid offset beyond length");if(g>=h)for(i.push(i[0].slice(-h)),g-=h;g>=i[i.length-1].length;)i.push(i[i.length-1]),g-=i[i.length-1].length;i.push(i[0].slice(-h,-h+g))}}var p=Dl(i);if(p.length!=s)throw new Error("Unexpected length: ".concat(p.length," != ").concat(s));return p}function Oi(t){for(var a=[],r=0;r<t.length;){var s=t[r++],i=t[r]|t[r+1]<<8|t[r+2]<<16;r+=3,a.push(b9(s,t.slice(r,r+i))),r+=i}if(r!==t.length)throw new Error("data is not a valid framed stream!");return Dl(a)}function jd(t){for(var a=[],r=0;r<t.length;){var s=Math.min(t.length-r,268435455),i=new Uint8Array(4);a.push(i);var c=dr(s),d=c.length;a.push(c),s<=60?(d++,a.push(new Uint8Array([s-1<<2]))):s<=256?(d+=2,a.push(new Uint8Array([240,s-1&255]))):s<=65536?(d+=3,a.push(new Uint8Array([244,s-1&255,s-1>>8&255]))):s<=16777216?(d+=4,a.push(new Uint8Array([248,s-1&255,s-1>>8&255,s-1>>16&255]))):s<=4294967296&&(d+=5,a.push(new Uint8Array([252,s-1&255,s-1>>8&255,s-1>>16&255,s-1>>>24&255]))),a.push(t.slice(r,r+s)),d+=s,i[0]=0,i[1]=d&255,i[2]=d>>8&255,i[3]=d>>16&255,r+=s}return Dl(a)}function lx(t,a){var r=new Uint8Array(32),s=Th(r),i=12,c=0;switch(r[0]=5,t.t){case"n":r[1]=2,y9(r,i,t.v),c|=1,i+=16;break;case"b":r[1]=6,s.setFloat64(i,t.v?1:0,!0),c|=2,i+=8;break;case"s":if(a.indexOf(t.v)==-1)throw new Error("Value ".concat(t.v," missing from SST!"));r[1]=3,s.setUint32(i,a.indexOf(t.v),!0),c|=8,i+=4;break;default:throw"unsupported cell type "+t.t}return s.setUint32(8,c,!0),r.slice(0,i)}function cx(t,a){var r=new Uint8Array(32),s=Th(r),i=12,c=0;switch(r[0]=3,t.t){case"n":r[2]=2,s.setFloat64(i,t.v,!0),c|=32,i+=8;break;case"b":r[2]=6,s.setFloat64(i,t.v?1:0,!0),c|=32,i+=8;break;case"s":if(a.indexOf(t.v)==-1)throw new Error("Value ".concat(t.v," missing from SST!"));r[2]=3,s.setUint32(i,a.indexOf(t.v),!0),c|=16,i+=4;break;default:throw"unsupported cell type "+t.t}return s.setUint32(4,c,!0),r.slice(0,i)}function Sl(t){var a=bs(t);return bu(a[1][0].data)}function v9(t,a,r){var s,i,c,d;if(!((s=t[6])!=null&&s[0])||!((i=t[7])!=null&&i[0]))throw"Mutation only works on post-BNC storages!";var m=((d=(c=t[8])==null?void 0:c[0])==null?void 0:d.data)&&Fd(t[8][0].data)>0||!1;if(m)throw"Math only works with normal offsets";for(var h=0,g=Th(t[7][0].data),p=0,b=[],j=Th(t[4][0].data),_=0,N=[],k=0;k<a.length;++k){if(a[k]==null){g.setUint16(k*2,65535,!0),j.setUint16(k*2,65535);continue}g.setUint16(k*2,p,!0),j.setUint16(k*2,_,!0);var C,D;switch(typeof a[k]){case"string":C=lx({t:"s",v:a[k]},r),D=cx({t:"s",v:a[k]},r);break;case"number":C=lx({t:"n",v:a[k]},r),D=cx({t:"n",v:a[k]},r);break;case"boolean":C=lx({t:"b",v:a[k]},r),D=cx({t:"b",v:a[k]},r);break;default:throw new Error("Unsupported value "+a[k])}b.push(C),p+=C.length,N.push(D),_+=D.length,++h}for(t[2][0].data=dr(h);k<t[7][0].data.length/2;++k)g.setUint16(k*2,65535,!0),j.setUint16(k*2,65535,!0);return t[6][0].data=Dl(b),t[3][0].data=Dl(N),h}function _9(t,a){if(!a||!a.numbers)throw new Error("Must pass a `numbers` option -- check the README");var r=t.Sheets[t.SheetNames[0]];t.SheetNames.length>1&&console.error("The Numbers writer currently writes only the first table");var s=ni(r["!ref"]);s.s.r=s.s.c=0;var i=!1;s.e.c>9&&(i=!0,s.e.c=9),s.e.r>49&&(i=!0,s.e.r=49),i&&console.error("The Numbers writer is currently limited to ".concat(ls(s)));var c=Eh(r,{range:s,header:1}),d=["~Sh33tJ5~"];c.forEach(function(B){return B.forEach(function(X){typeof X=="string"&&d.push(X)})});var m={},h=[],g=vr.read(a.numbers,{type:"base64"});g.FileIndex.map(function(B,X){return[B,g.FullPaths[X]]}).forEach(function(B){var X=B[0],K=B[1];if(X.type==2&&X.name.match(/\.iwa/)){var we=X.content,be=Oi(we),ke=Ai(be);ke.forEach(function(Me){h.push(Me.id),m[Me.id]={deps:[],location:K,type:Fd(Me.messages[0].meta[1][0].data)}})}}),h.sort(function(B,X){return B-X});var p=h.filter(function(B){return B>1}).map(function(B){return[B,dr(B)]});g.FileIndex.map(function(B,X){return[B,g.FullPaths[X]]}).forEach(function(B){var X=B[0];if(B[1],!!X.name.match(/\.iwa/)){var K=Ai(Oi(X.content));K.forEach(function(we){we.messages.forEach(function(be){p.forEach(function(ke){we.messages.some(function(Me){return Fd(Me.meta[1][0].data)!=11006&&p9(Me.data,ke[1])})&&m[ke[0]].deps.push(we.id)})})})}});for(var b=vr.find(g,m[1].location),j=Ai(Oi(b.content)),_,N=0;N<j.length;++N){var k=j[N];k.id==1&&(_=k)}var C=Sl(bs(_.messages[0].data)[1][0].data);for(b=vr.find(g,m[C].location),j=Ai(Oi(b.content)),N=0;N<j.length;++N)k=j[N],k.id==C&&(_=k);for(C=Sl(bs(_.messages[0].data)[2][0].data),b=vr.find(g,m[C].location),j=Ai(Oi(b.content)),N=0;N<j.length;++N)k=j[N],k.id==C&&(_=k);for(C=Sl(bs(_.messages[0].data)[2][0].data),b=vr.find(g,m[C].location),j=Ai(Oi(b.content)),N=0;N<j.length;++N)k=j[N],k.id==C&&(_=k);var D=bs(_.messages[0].data);{D[6][0].data=dr(s.e.r+1),D[7][0].data=dr(s.e.c+1);var T=Sl(D[46][0].data),E=vr.find(g,m[T].location),O=Ai(Oi(E.content));{for(var R=0;R<O.length&&O[R].id!=T;++R);if(O[R].id!=T)throw"Bad ColumnRowUIDMapArchive";var Y=bs(O[R].messages[0].data);Y[1]=[],Y[2]=[],Y[3]=[];for(var P=0;P<=s.e.c;++P){var U=[];U[1]=U[2]=[{type:0,data:dr(P+420690)}],Y[1].push({type:2,data:Ws(U)}),Y[2].push({type:0,data:dr(P)}),Y[3].push({type:0,data:dr(P)})}Y[4]=[],Y[5]=[],Y[6]=[];for(var J=0;J<=s.e.r;++J)U=[],U[1]=U[2]=[{type:0,data:dr(J+726270)}],Y[4].push({type:2,data:Ws(U)}),Y[5].push({type:0,data:dr(J)}),Y[6].push({type:0,data:dr(J)});O[R].messages[0].data=Ws(Y)}E.content=jd(kd(O)),E.size=E.content.length,delete D[46];var ne=bs(D[4][0].data);{ne[7][0].data=dr(s.e.r+1);var ye=bs(ne[1][0].data),he=Sl(ye[2][0].data);E=vr.find(g,m[he].location),O=Ai(Oi(E.content));{if(O[0].id!=he)throw"Bad HeaderStorageBucket";var ce=bs(O[0].messages[0].data);for(J=0;J<c.length;++J){var se=bs(ce[2][0].data);se[1][0].data=dr(J),se[4][0].data=dr(c[J].length),ce[2][J]={type:ce[2][0].type,data:Ws(se)}}O[0].messages[0].data=Ws(ce)}E.content=jd(kd(O)),E.size=E.content.length;var ee=Sl(ne[2][0].data);E=vr.find(g,m[ee].location),O=Ai(Oi(E.content));{if(O[0].id!=ee)throw"Bad HeaderStorageBucket";for(ce=bs(O[0].messages[0].data),P=0;P<=s.e.c;++P)se=bs(ce[2][0].data),se[1][0].data=dr(P),se[4][0].data=dr(s.e.r+1),ce[2][P]={type:ce[2][0].type,data:Ws(se)};O[0].messages[0].data=Ws(ce)}E.content=jd(kd(O)),E.size=E.content.length;var te=Sl(ne[4][0].data);(function(){for(var B=vr.find(g,m[te].location),X=Ai(Oi(B.content)),K,we=0;we<X.length;++we){var be=X[we];be.id==te&&(K=be)}var ke=bs(K.messages[0].data);{ke[3]=[];var Me=[];d.forEach(function(Xe,gt){Me[1]=[{type:0,data:dr(gt)}],Me[2]=[{type:0,data:dr(1)}],Me[3]=[{type:2,data:x9(Xe)}],ke[3].push({type:2,data:Ws(Me)})})}K.messages[0].data=Ws(ke);var z=kd(X),Ne=jd(z);B.content=Ne,B.size=B.content.length})();var W=bs(ne[3][0].data);{var I=W[1][0];delete W[2];var oe=bs(I.data);{var ae=Sl(oe[2][0].data);(function(){for(var B=vr.find(g,m[ae].location),X=Ai(Oi(B.content)),K,we=0;we<X.length;++we){var be=X[we];be.id==ae&&(K=be)}var ke=bs(K.messages[0].data);{delete ke[6],delete W[7];var Me=new Uint8Array(ke[5][0].data);ke[5]=[];for(var z=0,Ne=0;Ne<=s.e.r;++Ne){var Xe=bs(Me);z+=v9(Xe,c[Ne],d),Xe[1][0].data=dr(Ne),ke[5].push({data:Ws(Xe),type:2})}ke[1]=[{type:0,data:dr(s.e.c+1)}],ke[2]=[{type:0,data:dr(s.e.r+1)}],ke[3]=[{type:0,data:dr(z)}],ke[4]=[{type:0,data:dr(s.e.r+1)}]}K.messages[0].data=Ws(ke);var gt=kd(X),St=jd(gt);B.content=St,B.size=B.content.length})()}I.data=Ws(oe)}ne[3][0].data=Ws(W)}D[4][0].data=Ws(ne)}_.messages[0].data=Ws(D);var F=kd(j),M=jd(F);return b.content=M,b.size=b.content.length,g}function w9(t){return function(r){for(var s=0;s!=t.length;++s){var i=t[s];r[i[0]]===void 0&&(r[i[0]]=i[1]),i[2]==="n"&&(r[i[0]]=Number(r[i[0]]))}}}function yp(t){w9([["cellDates",!1],["bookSST",!1],["bookType","xlsx"],["compression",!1],["WTF",!1]])(t)}function k9(t,a){return a.bookType=="ods"?nk(t,a):a.bookType=="numbers"?_9(t,a):a.bookType=="xlsb"?j9(t,a):N9(t,a)}function j9(t,a){Ad=1024,t&&!t.SSF&&(t.SSF=In(Vr)),t&&t.SSF&&(zh(),Ih(t.SSF),a.revssf=Bh(t.SSF),a.revssf[t.SSF[65535]]=0,a.ssf=t.SSF),a.rels={},a.wbrels={},a.Strings=[],a.Strings.Count=0,a.Strings.Unique=0,lu?a.revStrings=new Map:(a.revStrings={},a.revStrings.foo=[],delete a.revStrings.foo);var r=a.bookType=="xlsb"?"bin":"xml",s=Uw.indexOf(a.bookType)>-1,i=xw();yp(a=a||{});var c=ap(),d="",m=0;if(a.cellXfs=[],Ml(a.cellXfs,{},{revssf:{General:0}}),t.Props||(t.Props={}),d="docProps/core.xml",Ma(c,d,vw(t.Props,a)),i.coreprops.push(d),ur(a.rels,2,d,tr.CORE_PROPS),d="docProps/app.xml",!(t.Props&&t.Props.SheetNames))if(!t.Workbook||!t.Workbook.Sheets)t.Props.SheetNames=t.SheetNames;else{for(var h=[],g=0;g<t.SheetNames.length;++g)(t.Workbook.Sheets[g]||{}).Hidden!=2&&h.push(t.SheetNames[g]);t.Props.SheetNames=h}for(t.Props.Worksheets=t.Props.SheetNames.length,Ma(c,d,ww(t.Props)),i.extprops.push(d),ur(a.rels,3,d,tr.EXT_PROPS),t.Custprops!==t.Props&&Xs(t.Custprops||{}).length>0&&(d="docProps/custom.xml",Ma(c,d,kw(t.Custprops)),i.custprops.push(d),ur(a.rels,4,d,tr.CUST_PROPS)),m=1;m<=t.SheetNames.length;++m){var p={"!id":{}},b=t.Sheets[t.SheetNames[m-1]],j=(b||{})["!type"]||"sheet";switch(j){case"chart":default:d="xl/worksheets/sheet"+m+"."+r,Ma(c,d,CA(m-1,d,a,t,p)),i.sheets.push(d),ur(a.wbrels,-1,"worksheets/sheet"+m+"."+r,tr.WS[0])}if(b){var _=b["!comments"],N=!1,k="";_&&_.length>0&&(k="xl/comments"+m+"."+r,Ma(c,k,AA(_,k)),i.comments.push(k),ur(p,-1,"../comments"+m+"."+r,tr.CMNT),N=!0),b["!legacy"]&&N&&Ma(c,"xl/drawings/vmlDrawing"+m+".vml",zw(m,b["!comments"])),delete b["!comments"],delete b["!legacy"]}p["!id"].rId1&&Ma(c,yw(d),Rd(p))}return a.Strings!=null&&a.Strings.length>0&&(d="xl/sharedStrings."+r,Ma(c,d,EA(a.Strings,d,a)),i.strs.push(d),ur(a.wbrels,-1,"sharedStrings."+r,tr.SST)),d="xl/workbook."+r,Ma(c,d,SA(t,d)),i.workbooks.push(d),ur(a.rels,1,d,tr.WB),d="xl/theme/theme1.xml",Ma(c,d,Fw(t.Themes,a)),i.themes.push(d),ur(a.wbrels,-1,"theme/theme1.xml",tr.THEME),d="xl/styles."+r,Ma(c,d,TA(t,d,a)),i.styles.push(d),ur(a.wbrels,-1,"styles."+r,tr.STY),t.vbaraw&&s&&(d="xl/vbaProject.bin",Ma(c,d,t.vbaraw),i.vba.push(d),ur(a.wbrels,-1,"vbaProject.bin",tr.VBA)),d="xl/metadata."+r,Ma(c,d,OA(d)),i.metadata.push(d),ur(a.wbrels,-1,"metadata."+r,tr.XLMETA),Ma(c,"[Content_Types].xml",pw(i,a)),Ma(c,"_rels/.rels",Rd(a.rels)),Ma(c,"xl/_rels/workbook."+r+".rels",Rd(a.wbrels)),delete a.revssf,delete a.ssf,c}function N9(t,a){Ad=1024,t&&!t.SSF&&(t.SSF=In(Vr)),t&&t.SSF&&(zh(),Ih(t.SSF),a.revssf=Bh(t.SSF),a.revssf[t.SSF[65535]]=0,a.ssf=t.SSF),a.rels={},a.wbrels={},a.Strings=[],a.Strings.Count=0,a.Strings.Unique=0,lu?a.revStrings=new Map:(a.revStrings={},a.revStrings.foo=[],delete a.revStrings.foo);var r="xml",s=Uw.indexOf(a.bookType)>-1,i=xw();yp(a=a||{});var c=ap(),d="",m=0;if(a.cellXfs=[],Ml(a.cellXfs,{},{revssf:{General:0}}),t.Props||(t.Props={}),d="docProps/core.xml",Ma(c,d,vw(t.Props,a)),i.coreprops.push(d),ur(a.rels,2,d,tr.CORE_PROPS),d="docProps/app.xml",!(t.Props&&t.Props.SheetNames))if(!t.Workbook||!t.Workbook.Sheets)t.Props.SheetNames=t.SheetNames;else{for(var h=[],g=0;g<t.SheetNames.length;++g)(t.Workbook.Sheets[g]||{}).Hidden!=2&&h.push(t.SheetNames[g]);t.Props.SheetNames=h}t.Props.Worksheets=t.Props.SheetNames.length,Ma(c,d,ww(t.Props)),i.extprops.push(d),ur(a.rels,3,d,tr.EXT_PROPS),t.Custprops!==t.Props&&Xs(t.Custprops||{}).length>0&&(d="docProps/custom.xml",Ma(c,d,kw(t.Custprops)),i.custprops.push(d),ur(a.rels,4,d,tr.CUST_PROPS));var p=["SheetJ5"];for(a.tcid=0,m=1;m<=t.SheetNames.length;++m){var b={"!id":{}},j=t.Sheets[t.SheetNames[m-1]],_=(j||{})["!type"]||"sheet";switch(_){case"chart":default:d="xl/worksheets/sheet"+m+"."+r,Ma(c,d,Jw(m-1,a,t,b)),i.sheets.push(d),ur(a.wbrels,-1,"worksheets/sheet"+m+"."+r,tr.WS[0])}if(j){var N=j["!comments"],k=!1,C="";if(N&&N.length>0){var D=!1;N.forEach(function(T){T[1].forEach(function(E){E.T==!0&&(D=!0)})}),D&&(C="xl/threadedComments/threadedComment"+m+"."+r,Ma(c,C,aE(N,p,a)),i.threadedcomments.push(C),ur(b,-1,"../threadedComments/threadedComment"+m+"."+r,tr.TCMNT)),C="xl/comments"+m+"."+r,Ma(c,C,Bw(N)),i.comments.push(C),ur(b,-1,"../comments"+m+"."+r,tr.CMNT),k=!0}j["!legacy"]&&k&&Ma(c,"xl/drawings/vmlDrawing"+m+".vml",zw(m,j["!comments"])),delete j["!comments"],delete j["!legacy"]}b["!id"].rId1&&Ma(c,yw(d),Rd(b))}return a.Strings!=null&&a.Strings.length>0&&(d="xl/sharedStrings."+r,Ma(c,d,Ow(a.Strings,a)),i.strs.push(d),ur(a.wbrels,-1,"sharedStrings."+r,tr.SST)),d="xl/workbook."+r,Ma(c,d,Qw(t)),i.workbooks.push(d),ur(a.rels,1,d,tr.WB),d="xl/theme/theme1.xml",Ma(c,d,Fw(t.Themes,a)),i.themes.push(d),ur(a.wbrels,-1,"theme/theme1.xml",tr.THEME),d="xl/styles."+r,Ma(c,d,Rw(t,a)),i.styles.push(d),ur(a.wbrels,-1,"styles."+r,tr.STY),t.vbaraw&&s&&(d="xl/vbaProject.bin",Ma(c,d,t.vbaraw),i.vba.push(d),ur(a.wbrels,-1,"vbaProject.bin",tr.VBA)),d="xl/metadata."+r,Ma(c,d,Iw()),i.metadata.push(d),ur(a.wbrels,-1,"metadata."+r,tr.XLMETA),p.length>1&&(d="xl/persons/person.xml",Ma(c,d,rE(p)),i.people.push(d),ur(a.wbrels,-1,"persons/person.xml",tr.PEOPLE)),Ma(c,"[Content_Types].xml",pw(i,a)),Ma(c,"_rels/.rels",Rd(a.rels)),Ma(c,"xl/_rels/workbook."+r+".rels",Rd(a.wbrels)),delete a.revssf,delete a.ssf,c}function S9(t,a){var r="";switch((a||{}).type||"base64"){case"buffer":return[t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7]];case"base64":r=Jo(t.slice(0,12));break;case"binary":r=t;break;case"array":return[t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7]];default:throw new Error("Unrecognized type "+(a&&a.type||"undefined"))}return[r.charCodeAt(0),r.charCodeAt(1),r.charCodeAt(2),r.charCodeAt(3),r.charCodeAt(4),r.charCodeAt(5),r.charCodeAt(6),r.charCodeAt(7)]}function ik(t,a){switch(a.type){case"base64":case"binary":break;case"buffer":case"array":a.type="";break;case"file":return Cu(a.file,vr.write(t,{type:ir?"buffer":""}));case"string":throw new Error("'string' output type invalid for '"+a.bookType+"' files");default:throw new Error("Unrecognized type "+a.type)}return vr.write(t,a)}function C9(t,a){var r=In(a||{}),s=k9(t,r);return T9(s,r)}function T9(t,a){var r={},s=ir?"nodebuffer":typeof Uint8Array!="undefined"?"array":"string";if(a.compression&&(r.compression="DEFLATE"),a.password)r.type=s;else switch(a.type){case"base64":r.type="base64";break;case"binary":r.type="string";break;case"string":throw new Error("'string' output type invalid for '"+a.bookType+"' files");case"buffer":case"file":r.type=s;break;default:throw new Error("Unrecognized type "+a.type)}var i=t.FullPaths?vr.write(t,{fileType:"zip",type:{nodebuffer:"buffer",string:"binary"}[r.type]||r.type,compression:!!a.compression}):t.generate(r);if(typeof Deno!="undefined"&&typeof i=="string"){if(a.type=="binary"||a.type=="base64")return i;i=new Uint8Array(Fh(i))}return a.password&&typeof encrypt_agile!="undefined"?ik(encrypt_agile(i,a.password),a):a.type==="file"?Cu(a.file,i):a.type=="string"?su(i):i}function E9(t,a){var r=a||{},s=VA(t,r);return ik(s,r)}function mo(t,a,r){r||(r="");var s=r+t;switch(a.type){case"base64":return fu(pu(s));case"binary":return pu(s);case"string":return t;case"file":return Cu(a.file,s,"utf8");case"buffer":return ir?Qo(s,"utf8"):typeof TextEncoder!="undefined"?new TextEncoder().encode(s):mo(s,{type:"binary"}).split("").map(function(i){return i.charCodeAt(0)})}throw new Error("Unrecognized type "+a.type)}function A9(t,a){switch(a.type){case"base64":return fu(t);case"binary":return t;case"string":return t;case"file":return Cu(a.file,t,"binary");case"buffer":return ir?Qo(t,"binary"):t.split("").map(function(r){return r.charCodeAt(0)})}throw new Error("Unrecognized type "+a.type)}function Vm(t,a){switch(a.type){case"string":case"base64":case"binary":for(var r="",s=0;s<t.length;++s)r+=String.fromCharCode(t[s]);return a.type=="base64"?fu(r):a.type=="string"?su(r):r;case"file":return Cu(a.file,t);case"buffer":return t;default:throw new Error("Unrecognized type "+a.type)}}function ok(t,a){s6(),fA(t);var r=In(a||{});if(r.cellStyles&&(r.cellNF=!0,r.sheetStubs=!0),r.type=="array"){r.type="binary";var s=ok(t,r);return r.type="array",Fh(s)}var i=0;if(r.sheet&&(typeof r.sheet=="number"?i=r.sheet:i=t.SheetNames.indexOf(r.sheet),!t.SheetNames[i]))throw new Error("Sheet not found: "+r.sheet+" : "+typeof r.sheet);switch(r.bookType||"xlsb"){case"xml":case"xlml":return mo(HA(t,r),r);case"slk":case"sylk":return mo(mT.from_sheet(t.Sheets[t.SheetNames[i]],r),r);case"htm":case"html":return mo(ak(t.Sheets[t.SheetNames[i]],r),r);case"txt":return A9(lk(t.Sheets[t.SheetNames[i]],r),r);case"csv":return mo(bp(t.Sheets[t.SheetNames[i]],r),r,"\uFEFF");case"dif":return mo(hT.from_sheet(t.Sheets[t.SheetNames[i]],r),r);case"dbf":return Vm(uT.from_sheet(t.Sheets[t.SheetNames[i]],r),r);case"prn":return mo(gT.from_sheet(t.Sheets[t.SheetNames[i]],r),r);case"rtf":return mo(_T.from_sheet(t.Sheets[t.SheetNames[i]],r),r);case"eth":return mo(Aw.from_sheet(t.Sheets[t.SheetNames[i]],r),r);case"fods":return mo(nk(t,r),r);case"wk1":return Vm(a_.sheet_to_wk1(t.Sheets[t.SheetNames[i]],r),r);case"wk3":return Vm(a_.book_to_wk3(t,r),r);case"biff2":r.biff||(r.biff=2);case"biff3":r.biff||(r.biff=3);case"biff4":return r.biff||(r.biff=4),Vm(tk(t,r),r);case"biff5":r.biff||(r.biff=5);case"biff8":case"xla":case"xls":return r.biff||(r.biff=8),E9(t,r);case"xlsx":case"xlsm":case"xlam":case"xlsb":case"numbers":case"ods":return C9(t,r);default:throw new Error("Unrecognized bookType |"+r.bookType+"|")}}function O9(t){if(!t.bookType){var a={xls:"biff8",htm:"html",slk:"sylk",socialcalc:"eth",Sh33tJS:"WTF"},r=t.file.slice(t.file.lastIndexOf(".")).toLowerCase();r.match(/^\.[a-z]+$/)&&(t.bookType=r.slice(1)),t.bookType=a[t.bookType]||t.bookType}}function $i(t,a,r){var s={};return s.type="file",s.file=a,O9(s),ok(t,s)}function D9(t,a,r,s,i,c,d,m){var h=Ys(r),g=m.defval,p=m.raw||!Object.prototype.hasOwnProperty.call(m,"raw"),b=!0,j=i===1?[]:{};if(i!==1)if(Object.defineProperty)try{Object.defineProperty(j,"__rowNum__",{value:r,enumerable:!1})}catch(C){j.__rowNum__=r}else j.__rowNum__=r;if(!d||t[r])for(var _=a.s.c;_<=a.e.c;++_){var N=d?t[r][_]:t[s[_]+h];if(N===void 0||N.t===void 0){if(g===void 0)continue;c[_]!=null&&(j[c[_]]=g);continue}var k=N.v;switch(N.t){case"z":if(k==null)break;continue;case"e":k=k==0?null:void 0;break;case"s":case"d":case"b":case"n":break;default:throw new Error("unrecognized type "+N.t)}if(c[_]!=null){if(k==null)if(N.t=="e"&&k===null)j[c[_]]=null;else if(g!==void 0)j[c[_]]=g;else if(p&&k===null)j[c[_]]=null;else continue;else j[c[_]]=p&&(N.t!=="n"||N.t==="n"&&m.rawNumbers!==!1)?k:Xo(N,k,m);k!=null&&(b=!1)}}return{row:j,isempty:b}}function Eh(t,a){if(t==null||t["!ref"]==null)return[];var r={t:"n",v:0},s=0,i=1,c=[],d=0,m="",h={s:{r:0,c:0},e:{r:0,c:0}},g=a||{},p=g.range!=null?g.range:t["!ref"];switch(g.header===1?s=1:g.header==="A"?s=2:Array.isArray(g.header)?s=3:g.header==null&&(s=0),typeof p){case"string":h=Dr(p);break;case"number":h=Dr(t["!ref"]),h.s.r=p;break;default:h=p}s>0&&(i=0);var b=Ys(h.s.r),j=[],_=[],N=0,k=0,C=Array.isArray(t),D=h.s.r,T=0,E={};C&&!t[D]&&(t[D]=[]);var O=g.skipHidden&&t["!cols"]||[],R=g.skipHidden&&t["!rows"]||[];for(T=h.s.c;T<=h.e.c;++T)if(!(O[T]||{}).hidden)switch(j[T]=on(T),r=C?t[D][T]:t[j[T]+b],s){case 1:c[T]=T-h.s.c;break;case 2:c[T]=j[T];break;case 3:c[T]=g.header[T-h.s.c];break;default:if(r==null&&(r={w:"__EMPTY",t:"s"}),m=d=Xo(r,null,g),k=E[d]||0,!k)E[d]=1;else{do m=d+"_"+k++;while(E[m]);E[d]=k,E[m]=1}c[T]=m}for(D=h.s.r+i;D<=h.e.r;++D)if(!(R[D]||{}).hidden){var Y=D9(t,h,D,j,s,c,C,g);(Y.isempty===!1||(s===1?g.blankrows!==!1:g.blankrows))&&(_[N++]=Y.row)}return _.length=N,_}var d_=/"/g;function M9(t,a,r,s,i,c,d,m){for(var h=!0,g=[],p="",b=Ys(r),j=a.s.c;j<=a.e.c;++j)if(s[j]){var _=m.dense?(t[r]||[])[j]:t[s[j]+b];if(_==null)p="";else if(_.v!=null){h=!1,p=""+(m.rawNumbers&&_.t=="n"?_.v:Xo(_,null,m));for(var N=0,k=0;N!==p.length;++N)if((k=p.charCodeAt(N))===i||k===c||k===34||m.forceQuotes){p='"'+p.replace(d_,'""')+'"';break}p=="ID"&&(p='"ID"')}else _.f!=null&&!_.F?(h=!1,p="="+_.f,p.indexOf(",")>=0&&(p='"'+p.replace(d_,'""')+'"')):p="";g.push(p)}return m.blankrows===!1&&h?null:g.join(d)}function bp(t,a){var r=[],s=a==null?{}:a;if(t==null||t["!ref"]==null)return"";var i=Dr(t["!ref"]),c=s.FS!==void 0?s.FS:",",d=c.charCodeAt(0),m=s.RS!==void 0?s.RS:`
`,h=m.charCodeAt(0),g=new RegExp((c=="|"?"\\|":c)+"+$"),p="",b=[];s.dense=Array.isArray(t);for(var j=s.skipHidden&&t["!cols"]||[],_=s.skipHidden&&t["!rows"]||[],N=i.s.c;N<=i.e.c;++N)(j[N]||{}).hidden||(b[N]=on(N));for(var k=0,C=i.s.r;C<=i.e.r;++C)(_[C]||{}).hidden||(p=M9(t,i,C,b,d,h,c,s),p!=null&&(s.strip&&(p=p.replace(g,"")),(p||s.blankrows!==!1)&&r.push((k++?m:"")+p)));return delete s.dense,r.join("")}function lk(t,a){a||(a={}),a.FS=" ",a.RS=`
`;var r=bp(t,a);return r}function L9(t){var a="",r,s="";if(t==null||t["!ref"]==null)return[];var i=Dr(t["!ref"]),c="",d=[],m,h=[],g=Array.isArray(t);for(m=i.s.c;m<=i.e.c;++m)d[m]=on(m);for(var p=i.s.r;p<=i.e.r;++p)for(c=Ys(p),m=i.s.c;m<=i.e.c;++m)if(a=d[m]+c,r=g?(t[p]||[])[m]:t[a],s="",r!==void 0){if(r.F!=null){if(a=r.F,!r.f)continue;s=r.f,a.indexOf(":")==-1&&(a=a+":"+a)}if(r.f!=null)s=r.f;else{if(r.t=="z")continue;if(r.t=="n"&&r.v!=null)s=""+r.v;else if(r.t=="b")s=r.v?"TRUE":"FALSE";else if(r.w!==void 0)s="'"+r.w;else{if(r.v===void 0)continue;r.t=="s"?s="'"+r.v:s=""+r.v}}h[h.length]=a+"="+s}return h}function ck(t,a,r){var s=r||{},i=+!s.skipHeader,c=t||{},d=0,m=0;if(c&&s.origin!=null)if(typeof s.origin=="number")d=s.origin;else{var h=typeof s.origin=="string"?Ss(s.origin):s.origin;d=h.r,m=h.c}var g,p={s:{c:0,r:0},e:{c:m,r:d+a.length-1+i}};if(c["!ref"]){var b=Dr(c["!ref"]);p.e.c=Math.max(p.e.c,b.e.c),p.e.r=Math.max(p.e.r,b.e.r),d==-1&&(d=b.e.r+1,p.e.r=d+a.length-1+i)}else d==-1&&(d=0,p.e.r=a.length-1+i);var j=s.header||[],_=0;a.forEach(function(k,C){Xs(k).forEach(function(D){(_=j.indexOf(D))==-1&&(j[_=j.length]=D);var T=k[D],E="z",O="",R=hr({c:m+_,r:d+C+i});g=vu(c,R),T&&typeof T=="object"&&!(T instanceof Date)?c[R]=T:(typeof T=="number"?E="n":typeof T=="boolean"?E="b":typeof T=="string"?E="s":T instanceof Date?(E="d",s.cellDates||(E="n",T=Fn(T)),O=s.dateNF||Vr[14]):T===null&&s.nullError&&(E="e",T=0),g?(g.t=E,g.v=T,delete g.w,delete g.R,O&&(g.z=O)):c[R]=g={t:E,v:T},O&&(g.z=O))})}),p.e.c=Math.max(p.e.c,m+j.length-1);var N=Ys(d);if(i)for(_=0;_<j.length;++_)c[on(_+m)+N]={t:"s",v:j[_]};return c["!ref"]=ls(p),c}function R9(t,a){return ck(null,t,a)}function vu(t,a,r){if(typeof a=="string"){if(Array.isArray(t)){var s=Ss(a);return t[s.r]||(t[s.r]=[]),t[s.r][s.c]||(t[s.r][s.c]={t:"z"})}return t[a]||(t[a]={t:"z"})}return typeof a!="number"?vu(t,hr(a)):vu(t,hr({r:a,c:r||0}))}function P9(t,a){if(typeof a=="number"){if(a>=0&&t.SheetNames.length>a)return a;throw new Error("Cannot find sheet # "+a)}else if(typeof a=="string"){var r=t.SheetNames.indexOf(a);if(r>-1)return r;throw new Error("Cannot find sheet name |"+a+"|")}else throw new Error("Cannot find sheet |"+a+"|")}function F9(){return{SheetNames:[],Sheets:{}}}function I9(t,a,r,s){var i=1;if(!r)for(;i<=65535&&t.SheetNames.indexOf(r="Sheet"+i)!=-1;++i,r=void 0);if(!r||t.SheetNames.length>=65535)throw new Error("Too many worksheets");if(s&&t.SheetNames.indexOf(r)>=0){var c=r.match(/(^.*?)(\d+)$/);i=c&&+c[2]||0;var d=c&&c[1]||r;for(++i;i<=65535&&t.SheetNames.indexOf(r=d+i)!=-1;++i);}if(Kw(r),t.SheetNames.indexOf(r)>=0)throw new Error("Worksheet with name |"+r+"| already exists!");return t.SheetNames.push(r),t.Sheets[r]=a,r}function z9(t,a,r){t.Workbook||(t.Workbook={}),t.Workbook.Sheets||(t.Workbook.Sheets=[]);var s=P9(t,a);switch(t.Workbook.Sheets[s]||(t.Workbook.Sheets[s]={}),r){case 0:case 1:case 2:break;default:throw new Error("Bad sheet visibility setting "+r)}t.Workbook.Sheets[s].Hidden=r}function B9(t,a){return t.z=a,t}function dk(t,a,r){return a?(t.l={Target:a},r&&(t.l.Tooltip=r)):delete t.l,t}function U9(t,a,r){return dk(t,"#"+a,r)}function $9(t,a,r){t.c||(t.c=[]),t.c.push({t:a,a:r||"SheetJS"})}function H9(t,a,r,s){for(var i=typeof a!="string"?a:Dr(a),c=typeof a=="string"?a:ls(a),d=i.s.r;d<=i.e.r;++d)for(var m=i.s.c;m<=i.e.c;++m){var h=vu(t,d,m);h.t="n",h.F=c,delete h.v,d==i.s.r&&m==i.s.c&&(h.f=r,s&&(h.D=!0))}return t}var Ja={encode_col:on,encode_row:Ys,encode_cell:hr,encode_range:ls,decode_col:lp,decode_row:op,split_cell:sC,decode_cell:Ss,decode_range:ni,format_cell:Xo,sheet_add_aoa:dw,sheet_add_json:ck,sheet_add_dom:rk,aoa_to_sheet:qd,json_to_sheet:R9,table_to_sheet:sk,table_to_book:h9,sheet_to_csv:bp,sheet_to_txt:lk,sheet_to_json:Eh,sheet_to_html:ak,sheet_to_formulae:L9,sheet_to_row_object_array:Eh,sheet_get_cell:vu,book_new:F9,book_append_sheet:I9,book_set_sheet_visibility:z9,cell_set_number_format:B9,cell_set_hyperlink:dk,cell_set_internal_link:U9,cell_add_comment:$9,sheet_set_array_formula:H9,consts:{SHEET_VISIBLE:0,SHEET_HIDDEN:1,SHEET_VERY_HIDDEN:2}};const W9=({isOpen:t,onClose:a,permittedIssueTypes:r=[],isAdmin:s=!0,defaultWorkOrderType:i=""})=>{const{t:c}=ca(),[d,m]=y.useState(!1),[h,g]=y.useState(null),[p,b]=y.useState([]),[j,_]=y.useState([]),[N,k]=y.useState(!0),[C,D]=y.useState(""),[T,E]=y.useState(""),[O,R]=y.useState(""),[Y,P]=y.useState(!1),[U,J]=y.useState([]);y.useEffect(()=>{if(!s)return;Q(null,null,function*(){try{const B=yield(yield fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})).json();B.data&&J(B.data.map(X=>X.name))}catch(M){console.error("Error fetching issue types:",M)}})},[s]),y.useEffect(()=>{!s&&r.length===1?R(r[0]):R(i||"")},[r,s,i]);const ne="Technicians working Hours",ye=y.useCallback(()=>Q(null,null,function*(){m(!0),g(null);try{const F={};C&&(F.from_date=C),T&&(F.to_date=T),O?F.work_order_type=O:!s&&r.length>0&&r.length===1&&(F.work_order_type=r[0]);const B=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:ne,filters:F,ignore_prepared_report:1})})).json();if(B.exc)throw new Error(B.exc);if(B.message)if(B.message.columns&&B.message.columns.length>0&&_(B.message.columns),B.message.result){let X=B.message.result;!s&&r.length>1&&!O&&(X=X.filter(K=>r.includes(K.work_order_type))),b(X)}else b([])}catch(F){console.error("Error fetching report:",F),g(F instanceof Error?F.message:"Failed to fetch report data"),b([])}finally{m(!1)}}),[C,T,O,s,r]);y.useEffect(()=>{t&&ye()},[t,ye]),y.useEffect(()=>{const F=M=>{M.key==="Escape"&&t&&a()};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[t,a]),y.useEffect(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[t]);const he=()=>{D(""),E(""),s&&R("")},ce=()=>{const F=p.length,M=p.reduce((X,K)=>X+(parseFloat(K.total_hours)||0),0),B=F>0?M/F:0;return{totalTechnicians:F,totalHours:M,avgHours:B}},se=()=>{if(p.length!==0){P(!0);try{const M=[j.map(we=>we.label).join(","),...p.map(we=>j.map(be=>{let ke=we[be.fieldname]||"";return typeof ke=="string"&&(ke.includes(",")||ke.includes('"')||ke.includes(`
`))&&(ke=`"${ke.replace(/"/g,'""')}"`),ke}).join(","))].join(`
`),B=new Blob(["\uFEFF"+M],{type:"text/csv;charset=utf-8;"}),X=URL.createObjectURL(B),K=document.createElement("a");K.href=X,K.download=`technician_working_hours_${new Date().toISOString().split("T")[0]}.csv`,K.click(),URL.revokeObjectURL(X)}finally{P(!1)}}},ee=()=>{if(p.length!==0){P(!0);try{const M=[j.map(we=>we.label),...p.map(we=>j.map(be=>we[be.fieldname]||""))],B=Ja.aoa_to_sheet(M),X=j.map(we=>({wch:we.width?Math.floor(we.width/7):20}));B["!cols"]=X;const K=Ja.book_new();Ja.book_append_sheet(K,B,"Technician Hours"),$i(K,`technician_working_hours_${new Date().toISOString().split("T")[0]}.xlsx`)}finally{P(!1)}}},te=()=>{const F=ce(),M=window.open("","_blank");if(!M){alert("Please allow popups for this site to print the report.");return}const B=`
<!DOCTYPE html>
<html>
<head>
<title>Technicians Working Hours Report</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
h1 { text-align: center; color: #333; margin-bottom: 20px; }
.meta { text-align: center; color: #666; margin-bottom: 20px; font-size: 12px; }
.summary { display: flex; justify-content: center; gap: 30px; margin-bottom: 20px; padding: 15px; background: #f8f9fa; border-radius: 8px; }
.summary-item { text-align: center; }
.summary-label { font-size: 11px; color: #666; }
.summary-value { font-size: 20px; font-weight: bold; color: #333; }
.summary-value.hours { color: #0891B2; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { background-color: #0891B2; color: white; padding: 10px 8px; text-align: left; font-weight: 600; }
td { padding: 10px 8px; border-bottom: 1px solid #ddd; }
tr:nth-child(even) { background-color: #f9f9f9; }
tr:hover { background-color: #f5f5f5; }
.hours-cell { font-weight: 600; color: #0891B2; }
@media print {
body { margin: 0; }
table { page-break-inside: auto; }
tr { page-break-inside: avoid; page-break-after: auto; }
}
</style>
</head>
<body>
<h1>Technicians Working Hours Report</h1>
<div class="meta">
Generated on: ${new Date().toLocaleString()}
${C?` | From: ${C}`:""}
${T?` | To: ${T}`:""}
</div>
<div class="summary">
<div class="summary-item">
<div class="summary-label">Total Technicians</div>
<div class="summary-value">${F.totalTechnicians}</div>
</div>
<div class="summary-item">
<div class="summary-label">Total Hours</div>
<div class="summary-value hours">${F.totalHours.toFixed(2)}</div>
</div>
<div class="summary-item">
<div class="summary-label">Average Hours</div>
<div class="summary-value hours">${F.avgHours.toFixed(2)}</div>
</div>
</div>
<table>
<thead>
<tr>
<th>#</th>
${j.map(X=>`<th>${X.label}</th>`).join("")}
</tr>
</thead>
<tbody>
${p.map((X,K)=>`
<tr>
<td>${K+1}</td>
${j.map(we=>{let be=X[we.fieldname]||"-",ke="";return we.fieldname==="total_hours"&&(ke="hours-cell",be=typeof be=="number"?be.toFixed(2):be),`<td class="${ke}">${be}</td>`}).join("")}
</tr>
`).join("")}
</tbody>
</table>
<script>
window.onload = function() { window.print(); }
<\/script>
</body>
</html>
`;M.document.write(B),M.document.close()},W=()=>{te()},I=(F,M)=>{if(F==null||F==="")return"-";switch(M.fieldtype){case"Float":return typeof F=="number"?F.toFixed(2):F;case"Date":return new Date(F).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});case"Datetime":return new Date(F).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});default:return String(F)}};if(!t)return null;const oe=ce(),ae=C||T||O;return e.jsxs("div",{className:"fixed inset-0 z-[80] bg-gray-50 dark:bg-gray-900 flex flex-col",children:[e.jsx("div",{className:"bg-gradient-to-r from-cyan-600 to-blue-600 px-6 py-4 flex-shrink-0 shadow-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:a,className:"p-2 text-white/80 hover:text-white hover:bg-white/20 rounded-lg transition-colors",title:"Go Back",children:e.jsx(en,{size:18})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(or,{className:"text-white text-xl"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-white",children:"Technicians Working Hours"}),e.jsxs("p",{className:"text-white/70 text-sm",children:[p.length," technician",p.length!==1?"s":""," found"]})]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{onClick:a,className:"p-2 text-white/80 hover:text-white hover:bg-white/20 rounded-lg transition-colors",title:"Close (Esc)",children:e.jsx(wt,{size:20})})})]})}),!d&&p.length>0&&e.jsx("div",{className:"bg-white dark:bg-gray-800 px-6 py-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fc,{className:"text-blue-500 text-2xl"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 font-medium",children:"Total Technicians"}),e.jsx("p",{className:"text-2xl font-bold text-blue-700 dark:text-blue-300",children:oe.totalTechnicians})]})]})}),e.jsx("div",{className:"bg-cyan-50 dark:bg-cyan-900/20 rounded-lg p-4 border border-cyan-200 dark:border-cyan-800",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(or,{className:"text-cyan-500 text-2xl"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-cyan-600 dark:text-cyan-400 font-medium",children:"Total Hours Worked"}),e.jsx("p",{className:"text-2xl font-bold text-cyan-700 dark:text-cyan-300",children:oe.totalHours.toFixed(2)})]})]})}),e.jsx("div",{className:"bg-purple-50 dark:bg-purple-900/20 rounded-lg p-4 border border-purple-200 dark:border-purple-800",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(j1,{className:"text-purple-500 text-2xl"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-purple-600 dark:text-purple-400 font-medium",children:"Average Hours/Technician"}),e.jsx("p",{className:"text-2xl font-bold text-purple-700 dark:text-purple-300",children:oe.avgHours.toFixed(2)})]})]})})]})}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 px-6 py-3 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("button",{onClick:()=>k(!N),className:"flex items-center gap-2 px-4 py-2 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:[e.jsx(ds,{size:12}),"Filters",ae&&e.jsx("span",{className:"bg-cyan-100 dark:bg-cyan-900/50 text-cyan-600 dark:text-cyan-400 px-2 py-0.5 rounded-full text-xs font-bold",children:[C,T,O].filter(Boolean).length}),N?e.jsx(As,{size:10}):e.jsx(cs,{size:10})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:ye,disabled:d,className:"p-2.5 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors disabled:opacity-50",title:"Refresh",children:e.jsx(vn,{className:d?"animate-spin":"",size:14})}),e.jsxs("div",{className:"flex items-center gap-1 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:se,disabled:p.length===0||Y,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as CSV",children:[e.jsx(Bi,{className:"text-green-600",size:14}),e.jsx("span",{children:"CSV"})]}),e.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),e.jsxs("button",{onClick:ee,disabled:p.length===0||Y,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as Excel",children:[e.jsx(Ui,{className:"text-green-700",size:14}),e.jsx("span",{children:"Excel"})]}),e.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),e.jsxs("button",{onClick:W,disabled:p.length===0,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as PDF",children:[e.jsx(Ph,{className:"text-red-600",size:14}),e.jsx("span",{children:"PDF"})]}),e.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),e.jsxs("button",{onClick:te,disabled:p.length===0,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Print",children:[e.jsx(Fi,{className:"text-purple-600",size:14}),e.jsx("span",{children:"Print"})]})]})]})]}),N&&e.jsx("div",{className:"mt-4 p-4 bg-gray-50 dark:bg-gray-900/50 rounded-lg border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"From Date"}),e.jsx("input",{type:"date",value:C,onChange:F=>D(F.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-cyan-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"To Date"}),e.jsx("input",{type:"date",value:T,onChange:F=>E(F.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-cyan-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Technical Department"}),!s&&r.length===1?e.jsxs("div",{className:"w-full px-3 py-2 text-sm border border-gray-200 dark:border-gray-600 rounded-lg bg-gray-50 dark:bg-gray-600 text-gray-700 dark:text-gray-300 flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-indigo-400 flex-shrink-0"}),O,e.jsx("span",{className:"ml-auto text-[10px] text-gray-400 dark:text-gray-500 uppercase",children:"Restricted"})]}):e.jsxs("select",{value:O,onChange:F=>R(F.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-cyan-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:"All Departments"}),(s?U:r).map(F=>e.jsx("option",{value:F,children:F},F))]})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs("button",{onClick:he,disabled:!ae,className:"px-4 py-2 text-sm font-medium text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[e.jsx(wt,{size:12}),"Clear Filters"]})})]})})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[d&&e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ya,{className:"animate-spin text-cyan-500 text-5xl mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-lg",children:"Loading report data..."})]})}),h&&!d&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-8 text-center max-w-lg mx-auto",children:[e.jsx("p",{className:"text-red-600 dark:text-red-400 mb-4 text-lg",children:h}),e.jsx("button",{onClick:ye,className:"px-6 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-sm font-medium transition-colors",children:"Try Again"})]}),!d&&!h&&p.length===0&&e.jsxs("div",{className:"text-center py-20",children:[e.jsx(Js,{className:"text-gray-300 dark:text-gray-600 text-6xl mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-xl",children:"No data found"}),e.jsx("p",{className:"text-gray-400 dark:text-gray-500 text-sm mt-2",children:"Try adjusting your date range filters"})]}),!d&&!h&&p.length>0&&e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden shadow-sm",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 sticky top-0",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider w-16",children:"#"}),j.map((F,M)=>e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider whitespace-nowrap",style:{minWidth:F.width||150},children:F.label},M))]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:p.map((F,M)=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400 font-medium",children:M+1}),j.map((B,X)=>{const K=F[B.fieldname],we=I(K,B);return B.fieldname==="total_hours"?e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-3 py-1 rounded-full text-sm font-semibold bg-cyan-100 dark:bg-cyan-900/30 text-cyan-700 dark:text-cyan-300",children:[e.jsx(or,{size:12}),we," hrs"]})},X):B.fieldname==="engineer"&&K?e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx("a",{href:`/app/user/${K}`,target:"_blank",rel:"noopener noreferrer",className:"text-cyan-600 dark:text-cyan-400 hover:underline font-medium text-sm",children:we})},X):B.fieldname==="technician_name"?e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-200 dark:bg-gray-600 flex items-center justify-center",children:e.jsx(j1,{className:"text-gray-500 dark:text-gray-400",size:14})}),e.jsx("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:we})]})},X):e.jsx("td",{className:"px-4 py-3 text-sm text-gray-700 dark:text-gray-300",title:typeof K=="string"&&K.length>50?K:void 0,children:e.jsx("div",{className:"max-w-xs truncate",children:we})},X)})]},M))})]})})})]}),e.jsx("div",{className:"bg-white dark:bg-gray-800 px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex-shrink-0 shadow-inner",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Showing ",p.length," technician",p.length!==1?"s":"",ae&&" (filtered)",oe.totalHours>0&&e.jsxs("span",{className:"ml-2 text-cyan-600 dark:text-cyan-400",children:["• Total: ",oe.totalHours.toFixed(2)," hours"]})]}),e.jsx("button",{onClick:a,className:"px-6 py-2 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium transition-colors",children:"Close"})]})})]})},V9=({isOpen:t,onClose:a,permittedIssueTypes:r=[],isAdmin:s=!0,defaultWorkOrderType:i=""})=>{const{t:c}=ca(),[d,m]=y.useState(!1),[h,g]=y.useState(null),[p,b]=y.useState([]),[j,_]=y.useState([]),[N,k]=y.useState(!1),[C,D]=y.useState(!1),[T,E]=y.useState([]);y.useEffect(()=>{if(!s)return;Q(null,null,function*(){try{const I=yield(yield fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})).json();I.data&&E(I.data.map(oe=>oe.name))}catch(W){console.error("Error fetching issue types:",W)}})},[s]);const[O,R]=y.useState("");y.useEffect(()=>{!s&&r.length===1?R(r[0]):R(i||"")},[r,s,i]);const Y="Technician Work Order Summary",P=y.useCallback(()=>Q(null,null,function*(){m(!0),g(null);try{const te={};O?te.work_order_type=O:!s&&r.length===1&&(te.work_order_type=r[0]);const I=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:Y,filters:te,ignore_prepared_report:1})})).json();if(I.exc)throw new Error(I.exc);if(I.message)if(I.message.columns&&I.message.columns.length>0&&_(I.message.columns),I.message.result){let oe=I.message.result;!s&&r.length>1&&!O&&(oe=oe.filter(ae=>r.includes(ae.work_order_type))),b(oe)}else b([])}catch(te){console.error("Error fetching report:",te),g(te instanceof Error?te.message:"Failed to fetch report data"),b([])}finally{m(!1)}}),[O,s,r]);y.useEffect(()=>{t&&P()},[t,P]),y.useEffect(()=>{const te=W=>{W.key==="Escape"&&t&&a()};return document.addEventListener("keydown",te),()=>document.removeEventListener("keydown",te)},[t,a]),y.useEffect(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[t]);const U=()=>{const te=p.length,W=p.reduce((M,B)=>M+(parseInt(B.total)||0),0),I=p.reduce((M,B)=>M+(parseInt(B.completed)||0),0),oe=p.reduce((M,B)=>M+(parseInt(B.in_progress)||0),0),ae=p.reduce((M,B)=>M+(parseInt(B.open)||0),0),F=W>0?(I/W*100).toFixed(1):"0";return{totalTechnicians:te,totalWorkOrders:W,totalCompleted:I,totalInProgress:oe,totalOpen:ae,completionRate:F}},J=()=>{if(p.length!==0){D(!0);try{const W=[j.map(F=>F.label).join(","),...p.map(F=>j.map(M=>{let B=F[M.fieldname]||"";return typeof B=="string"&&(B.includes(",")||B.includes('"')||B.includes(`
`))&&(B=`"${B.replace(/"/g,'""')}"`),B}).join(","))].join(`
`),I=new Blob(["\uFEFF"+W],{type:"text/csv;charset=utf-8;"}),oe=URL.createObjectURL(I),ae=document.createElement("a");ae.href=oe,ae.download=`technician_work_order_summary_${new Date().toISOString().split("T")[0]}.csv`,ae.click(),URL.revokeObjectURL(oe)}finally{D(!1)}}},ne=()=>{if(p.length!==0){D(!0);try{const W=[j.map(F=>F.label),...p.map(F=>j.map(M=>F[M.fieldname]||""))],I=Ja.aoa_to_sheet(W),oe=j.map(F=>({wch:F.width?Math.floor(F.width/7):20}));I["!cols"]=oe;const ae=Ja.book_new();Ja.book_append_sheet(ae,I,"Work Order Summary"),$i(ae,`technician_work_order_summary_${new Date().toISOString().split("T")[0]}.xlsx`)}finally{D(!1)}}},ye=()=>{const te=U(),W=window.open("","_blank");if(!W){alert("Please allow popups for this site to print the report.");return}const I=`
<!DOCTYPE html>
<html>
<head>
<title>Technician Work Order Summary Report</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
h1 { text-align: center; color: #333; margin-bottom: 20px; }
.meta { text-align: center; color: #666; margin-bottom: 20px; font-size: 12px; }
.summary { display: flex; justify-content: center; gap: 20px; margin-bottom: 20px; padding: 15px; background: #f8f9fa; border-radius: 8px; flex-wrap: wrap; }
.summary-item { text-align: center; min-width: 100px; }
.summary-label { font-size: 11px; color: #666; }
.summary-value { font-size: 20px; font-weight: bold; color: #333; }
.summary-value.completed { color: #10B981; }
.summary-value.in-progress { color: #3B82F6; }
.summary-value.open { color: #F59E0B; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { background-color: #8B5CF6; color: white; padding: 10px 8px; text-align: left; font-weight: 600; }
td { padding: 10px 8px; border-bottom: 1px solid #ddd; }
tr:nth-child(even) { background-color: #f9f9f9; }
tr:hover { background-color: #f5f5f5; }
.count-cell { font-weight: 600; text-align: center; }
.completed { color: #10B981; }
.in-progress { color: #3B82F6; }
.open { color: #F59E0B; }
@media print {
body { margin: 0; }
table { page-break-inside: auto; }
tr { page-break-inside: avoid; page-break-after: auto; }
}
</style>
</head>
<body>
<h1>Technician Work Order Summary Report</h1>
<div class="meta">
Generated on: ${new Date().toLocaleString()}
${O?` | Department: ${O}`:""}
</div>
<div class="summary">
<div class="summary-item">
<div class="summary-label">Total Technicians</div>
<div class="summary-value">${te.totalTechnicians}</div>
</div>
<div class="summary-item">
<div class="summary-label">Total Work Orders</div>
<div class="summary-value">${te.totalWorkOrders}</div>
</div>
<div class="summary-item">
<div class="summary-label">Completed</div>
<div class="summary-value completed">${te.totalCompleted}</div>
</div>
<div class="summary-item">
<div class="summary-label">In Progress</div>
<div class="summary-value in-progress">${te.totalInProgress}</div>
</div>
<div class="summary-item">
<div class="summary-label">Open</div>
<div class="summary-value open">${te.totalOpen}</div>
</div>
<div class="summary-item">
<div class="summary-label">Completion Rate</div>
<div class="summary-value completed">${te.completionRate}%</div>
</div>
</div>
<table>
<thead>
<tr>
<th>#</th>
${j.map(oe=>`<th>${oe.label}</th>`).join("")}
</tr>
</thead>
<tbody>
${p.map((oe,ae)=>`
<tr>
<td>${ae+1}</td>
${j.map(F=>{let M=oe[F.fieldname]||"-",B="";return F.fieldname==="completed"?B="count-cell completed":F.fieldname==="in_progress"?B="count-cell in-progress":F.fieldname==="open"?B="count-cell open":F.fieldname==="total"&&(B="count-cell"),`<td class="${B}">${M}</td>`}).join("")}
</tr>
`).join("")}
</tbody>
</table>
<script>
window.onload = function() { window.print(); }
<\/script>
</body>
</html>
`;W.document.write(I),W.document.close()},he=()=>{ye()},ce=(te,W)=>{if(te==null||te==="")return"-";switch(W.fieldtype){case"Int":return parseInt(te)||0;case"Float":return typeof te=="number"?te.toFixed(2):te;default:return String(te)}};if(!t)return null;const se=U(),ee=!!O;return e.jsxs("div",{className:"fixed inset-0 z-[80] bg-gray-50 dark:bg-gray-900 flex flex-col",children:[e.jsx("div",{className:"bg-gradient-to-r from-purple-600 to-indigo-600 px-6 py-4 flex-shrink-0 shadow-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:a,className:"p-2 text-white/80 hover:text-white hover:bg-white/20 rounded-lg transition-colors",title:"Go Back",children:e.jsx(en,{size:18})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(hh,{className:"text-white text-xl"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-white",children:"Technician Work Order Summary"}),e.jsxs("p",{className:"text-white/70 text-sm",children:[p.length," technician",p.length!==1?"s":""," found",O&&e.jsx("span",{className:"ml-2 bg-white/20 px-2 py-0.5 rounded-full text-xs",children:O})]})]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{onClick:a,className:"p-2 text-white/80 hover:text-white hover:bg-white/20 rounded-lg transition-colors",title:"Close (Esc)",children:e.jsx(wt,{size:20})})})]})}),!d&&p.length>0&&e.jsx("div",{className:"bg-white dark:bg-gray-800 px-6 py-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4",children:e.jsx("div",{className:"bg-indigo-50 dark:bg-indigo-900/20 rounded-lg p-4 border border-indigo-200 dark:border-indigo-800",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fc,{className:"text-indigo-500 text-xl"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-indigo-600 dark:text-indigo-400 font-medium",children:"Technicians"}),e.jsx("p",{className:"text-xl font-bold text-indigo-700 dark:text-indigo-300",children:se.totalTechnicians})]})]})})})}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 px-6 py-3 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("button",{onClick:()=>k(!N),className:"flex items-center gap-2 px-4 py-2 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:[e.jsx(ds,{size:12}),"Filters",ee&&e.jsx("span",{className:"bg-purple-100 dark:bg-purple-900/50 text-purple-600 dark:text-purple-400 px-2 py-0.5 rounded-full text-xs font-bold",children:"1"}),N?e.jsx(As,{size:10}):e.jsx(cs,{size:10})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:P,disabled:d,className:"p-2.5 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors disabled:opacity-50",title:"Refresh",children:e.jsx(vn,{className:d?"animate-spin":"",size:14})}),e.jsxs("div",{className:"flex items-center gap-1 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:J,disabled:p.length===0||C,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as CSV",children:[e.jsx(Bi,{className:"text-green-600",size:14}),e.jsx("span",{children:"CSV"})]}),e.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),e.jsxs("button",{onClick:ne,disabled:p.length===0||C,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as Excel",children:[e.jsx(Ui,{className:"text-green-700",size:14}),e.jsx("span",{children:"Excel"})]}),e.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),e.jsxs("button",{onClick:he,disabled:p.length===0,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as PDF",children:[e.jsx(Ph,{className:"text-red-600",size:14}),e.jsx("span",{children:"PDF"})]}),e.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),e.jsxs("button",{onClick:ye,disabled:p.length===0,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Print",children:[e.jsx(Fi,{className:"text-purple-600",size:14}),e.jsx("span",{children:"Print"})]})]})]})]}),N&&e.jsx("div",{className:"mt-4 p-4 bg-gray-50 dark:bg-gray-900/50 rounded-lg border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Technical Department"}),!s&&r.length===1?e.jsxs("div",{className:"w-full px-3 py-2 text-sm border border-gray-200 dark:border-gray-600 rounded-lg bg-gray-50 dark:bg-gray-600 text-gray-700 dark:text-gray-300 flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-purple-400 flex-shrink-0"}),O,e.jsx("span",{className:"ml-auto text-[10px] text-gray-400 dark:text-gray-500 uppercase tracking-wide",children:"Restricted"})]}):e.jsxs("select",{value:O,onChange:te=>R(te.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:s?"All Departments":"Select Department"}),(s?T:r).map(te=>e.jsx("option",{value:te,children:te},te))]})]}),e.jsx("div",{}),e.jsx("div",{}),e.jsx("div",{className:"flex items-end",children:s&&e.jsxs("button",{onClick:()=>R(""),disabled:!ee,className:"px-4 py-2 text-sm font-medium text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[e.jsx(wt,{size:12}),"Clear Filters"]})})]})})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[d&&e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ya,{className:"animate-spin text-purple-500 text-5xl mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-lg",children:"Loading report data..."})]})}),h&&!d&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-8 text-center max-w-lg mx-auto",children:[e.jsx("p",{className:"text-red-600 dark:text-red-400 mb-4 text-lg",children:h}),e.jsx("button",{onClick:P,className:"px-6 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-sm font-medium transition-colors",children:"Try Again"})]}),!d&&!h&&p.length===0&&e.jsxs("div",{className:"text-center py-20",children:[e.jsx(Js,{className:"text-gray-300 dark:text-gray-600 text-6xl mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-xl",children:"No data found"}),e.jsx("p",{className:"text-gray-400 dark:text-gray-500 text-sm mt-2",children:"No technicians have been assigned to work orders yet."})]}),!d&&!h&&p.length>0&&e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden shadow-sm",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 sticky top-0",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider w-16",children:"#"}),j.map((te,W)=>e.jsx("th",{className:`px-4 py-3 text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider whitespace-nowrap ${te.fieldtype==="Int"?"text-center":"text-left"}`,style:{minWidth:te.width||120},children:te.label},W))]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:p.map((te,W)=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400 font-medium",children:W+1}),j.map((I,oe)=>{const ae=te[I.fieldname],F=ce(ae,I);return I.fieldname==="assigned_technician"?e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-purple-100 dark:bg-purple-900/30 flex items-center justify-center",children:e.jsx(hh,{className:"text-purple-500 dark:text-purple-400",size:14})}),e.jsx("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:F})]})},oe):I.fieldname==="total"?e.jsx("td",{className:"px-4 py-3 text-center whitespace-nowrap",children:e.jsx("span",{className:"inline-flex items-center justify-center min-w-[40px] px-3 py-1 rounded-full text-sm font-bold bg-indigo-100 dark:bg-indigo-900/30 text-indigo-700 dark:text-indigo-300",children:F})},oe):I.fieldname==="completed"?e.jsx("td",{className:"px-4 py-3 text-center whitespace-nowrap",children:e.jsx("span",{className:"inline-flex items-center justify-center min-w-[40px] px-3 py-1 rounded-full text-sm font-bold bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300",children:F})},oe):I.fieldname==="in_progress"?e.jsx("td",{className:"px-4 py-3 text-center whitespace-nowrap",children:e.jsx("span",{className:"inline-flex items-center justify-center min-w-[40px] px-3 py-1 rounded-full text-sm font-bold bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300",children:F})},oe):I.fieldname==="open"?e.jsx("td",{className:"px-4 py-3 text-center whitespace-nowrap",children:e.jsx("span",{className:"inline-flex items-center justify-center min-w-[40px] px-3 py-1 rounded-full text-sm font-bold bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300",children:F})},oe):e.jsx("td",{className:"px-4 py-3 text-sm text-gray-700 dark:text-gray-300",children:F},oe)})]},W))})]})})})]}),e.jsx("div",{className:"bg-white dark:bg-gray-800 px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex-shrink-0 shadow-inner",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Showing ",p.length," technician",p.length!==1?"s":"",O&&e.jsxs("span",{className:"ml-2 text-purple-600 dark:text-purple-400",children:["· ",O]}),se.totalWorkOrders>0&&e.jsxs("span",{className:"ml-2 text-purple-600 dark:text-purple-400",children:["• Total: ",se.totalWorkOrders," work orders • ",e.jsxs("span",{className:"text-green-600",children:[se.totalCompleted," completed"]}),"• ",e.jsxs("span",{className:"text-blue-600",children:[se.totalInProgress," in progress"]}),"• ",e.jsxs("span",{className:"text-amber-600",children:[se.totalOpen," open"]})]})]}),e.jsx("button",{onClick:a,className:"px-6 py-2 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium transition-colors",children:"Close"})]})})]})},vp=(t="Asset")=>{const[a,r]=y.useState({isAdmin:!1,restrictions:{},permissionFilters:{},targetDoctype:t,loading:!0,error:null}),s=y.useCallback(g=>Q(null,null,function*(){const p=g||t;try{r(j=>Se(ue({},j),{loading:!0,error:null,targetDoctype:p}));const b=yield mt.getPermissionFilters(p);return r({isAdmin:b.is_admin,restrictions:b.restrictions||{},permissionFilters:b.filters||{},targetDoctype:p,loading:!1,error:null}),b}catch(b){return console.error(`Error fetching permissions for ${p}:`,b),r(j=>Se(ue({},j),{loading:!1,error:b instanceof Error?b.message:"Failed to fetch permissions"})),null}}),[t]);y.useEffect(()=>{s()},[s]);const i=y.useCallback(g=>{var p;return((p=a.restrictions[g])==null?void 0:p.values)||[]},[a.restrictions]),c=y.useCallback(g=>a.isAdmin?!1:!!a.restrictions[g],[a.isAdmin,a.restrictions]),d=y.useMemo(()=>!a.isAdmin&&Object.keys(a.restrictions).length>0,[a.isAdmin,a.restrictions]),m=y.useCallback(g=>{if(a.isAdmin)return g;const p=ue({},g);for(const[b,j]of Object.entries(a.permissionFilters))if(!p[b])p[b]=j;else if(Array.isArray(j)&&j[0]==="in"){const _=j[1];typeof p[b]=="string"&&!_.includes(p[b])&&(p[b]=["in",[]])}return p},[a.isAdmin,a.permissionFilters]),h=y.useMemo(()=>Object.entries(a.restrictions).map(([g,p])=>({type:g,field:p.field,values:p.values,count:p.count})),[a.restrictions]);return Se(ue({},a),{refetch:s,switchDoctype:s,getAllowedValues:i,hasRestriction:c,hasAnyRestrictions:d,mergeFilters:m,restrictionsList:h})},Wo=t=>{if(t==null)return!0;const a=String(t).trim().toLowerCase();return a===""||a==="null"||a==="unknown"||a==="undefined"||a==="none"},q9=()=>{var lt,aa,Ie,Nt,ve,Oe,ht;const{t}=ca(),{data:a,loading:r}=Zx(),{workOrders:s}=y2({},0,0),i=pa.useMemo(()=>(s||[]).filter(et=>et.custom_delete_status!=="Deleted"),[s]),{logs:c}=Rh({},0,0),{assets:d}=_2({},0,0),[m,h]=y.useState(null),[g,p]=y.useState(null),[b,j]=y.useState(null),[_,N]=y.useState(null),[k,C]=y.useState(null),[D,T]=y.useState(null),[E,O]=y.useState(null),[R,Y]=y.useState(null),[P,U]=y.useState({open:0,inProgress:0,completed:0,pendingReview:0,rejected:0,total:0,wfCompleted:0,wfInProgress:0,wfRejected:0}),[J,ne]=y.useState({assetsDown:0,avgResponseTime:0,maintenanceEfficiency:0,overdueTasks:0,plannedMaintenance:0});lc("Up & Down Time Chart");const{data:ye}=lc("Work Order Status Chart");lc("Maintenance - Asset wise Count");const{data:he}=lc("Asset Maintenance Assignees Status Count");lc("Asset Maintenance Frequency Chart");const{restrictions:ce,isAdmin:se}=vp("Work_Order"),ee=pa.useMemo(()=>{var et;return((et=ce["Issue Type"])==null?void 0:et.values)||[]},[JSON.stringify((lt=ce["Issue Type"])==null?void 0:lt.values)]),[te,W]=y.useState([]);y.useEffect(()=>{Q(null,null,function*(){var Be;try{const kt=yield fetch('/api/method/frappe.client.get_value?doctype=User&fieldname=["roles"]&filters={"name":"__user__"}'.replace("__user__",""),{credentials:"include"}),Dt=(yield(yield fetch("/api/method/frappe.auth.get_logged_user",{credentials:"include"})).json()).message;if(Dt){const De=(((Be=(yield(yield fetch(`/api/resource/User/${encodeURIComponent(Dt)}?fields=["roles"]`,{headers:{Accept:"application/json"},credentials:"include"})).json()).data)==null?void 0:Be.roles)||[]).map(Qe=>Qe.role);W(De)}}catch(kt){console.error("Error fetching user roles:",kt)}})},[]);const I=se||te.includes("System Manager")||te.includes("Quality Supervisor"),oe=se||te.includes("System Manager")||te.includes("Cluster Manager"),[ae,F]=y.useState(null),[M,B]=y.useState(null),[X,K]=y.useState(!1),[we,be]=y.useState(!1),[ke,Me]=y.useState(null),[z,Ne]=y.useState(null),[Xe,gt]=y.useState(!1),[St,Ht]=y.useState(!1),[Mt,Te]=y.useState(null),[Qt,zt]=y.useState(!1),[Wt,Vt]=y.useState(null),[va,ta]=y.useState(!1),[sa,ra]=y.useState([]),[Ye,ft]=y.useState("");y.useEffect(()=>{Q(null,null,function*(){try{const kt=yield(yield fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})).json();kt.data&&ra(kt.data.map(it=>it.name))}catch(Be){console.error("Error fetching issue types:",Be)}})},[]);const $t=pa.useMemo(()=>i?!se&&ee.length>0||!Ye?i:i.filter(et=>et.work_order_type===Ye):[],[i,se,ee,Ye]);y.useEffect(()=>{Q(null,null,function*(){var Be;try{const kt={};!se&&ee.length>0?kt.work_order_type=ee.length===1?ee[0]:["in",ee]:Ye&&(kt.work_order_type=Ye);const xt=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"Technicians working Hours",filters:kt,ignore_prepared_report:1})})).json();if((Be=xt.message)!=null&&Be.result){const Dt=xt.message.result.filter(De=>De&&typeof De=="object"&&!De.is_total_row),Ot=Dt.map(De=>De.technician_name||"Unknown"),Rt=Dt.map(De=>parseFloat(De.total_hours)||0);F({labels:Ot,datasets:[{name:"Total Hours",values:Rt,colors:["#6366F1"]}],type:"Bar"})}}catch(kt){console.error("Error fetching technician hours:",kt)}})},[ee,se,Ye]),y.useEffect(()=>{Q(null,null,function*(){var Be;try{const kt={};!se&&ee.length>0?kt.work_order_type=ee.length===1?ee[0]:["in",ee]:Ye&&(kt.work_order_type=Ye);const xt=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"Technician Work Order Summary",filters:kt,ignore_prepared_report:1})})).json();if((Be=xt.message)!=null&&Be.result){const Dt=xt.message.result.filter(De=>De&&typeof De=="object"&&!De.is_total_row),Ot=Dt.map(De=>De.assigned_technician||"Unknown"),Rt=[{name:"completed",values:Dt.map(De=>parseFloat(De.completed)||0),color:"#10B981"},{name:"in_progress",values:Dt.map(De=>parseFloat(De.in_progress)||0),color:"#3B82F6"},{name:"open",values:Dt.map(De=>parseFloat(De.open)||0),color:"#F59E0B"}].filter(De=>De.values.some(Qe=>Qe>0));B({labels:Ot,datasets:Rt,type:"Bar"})}}catch(kt){console.error("Error fetching technician worked:",kt)}})},[ee,se,Ye]);const na=(et,Be)=>{var xt,Dt;const kt=et.find(Ot=>(Ot==null?void 0:Ot.fieldname)&&(Ot.fieldname.toLowerCase().includes("work_order_type")||Ot.fieldname.toLowerCase().includes("wo_type")||Ot.fieldname.toLowerCase()==="type"));if(kt)return kt.fieldname;const it=et.find(Ot=>(Ot==null?void 0:Ot.label)&&(Ot.label.toLowerCase().includes("wo type")||Ot.label.toLowerCase().includes("work order type")||Ot.label.toLowerCase()==="type"));return it?it.fieldname:(xt=et[1])!=null&&xt.fieldname?et[1].fieldname:((Dt=et[0])==null?void 0:Dt.fieldname)||Object.keys(Be[0]||{})[0]||"name"},Ze=(et,Be,kt)=>{var Ot;const it=Rt=>typeof Rt=="number"&&!isNaN(Rt)||typeof Rt=="string"&&Rt!==""&&!isNaN(parseFloat(Rt)),xt=et.filter(Rt=>(Rt==null?void 0:Rt.fieldname)&&Rt.fieldname!==kt&&Be.some(De=>it(De[Rt.fieldname]))),Dt=xt.find(Rt=>{const De=((Rt.label||"")+(Rt.fieldname||"")).toLowerCase();return De.includes("count")||De.includes("linked")||De.includes("inspection")||De.includes("rejection")||De.includes("total")||De.includes("wo")});return Dt?Dt.fieldname:((Ot=xt[0])==null?void 0:Ot.fieldname)||null};return y.useEffect(()=>{if(!I)return;Q(null,null,function*(){var Be,kt;try{const it={};!se&&ee.length>0?it.work_order_type=ee.length===1?ee[0]:ee:Ye&&(it.work_order_type=Ye);const Dt=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"Inspection Linked Work Orders Summary",filters:it,ignore_prepared_report:1})})).json();if((Be=Dt.message)!=null&&Be.result){const Ot=Dt.message.result.filter(ct=>ct&&typeof ct=="object"&&!ct.is_total_row),Rt=((kt=Dt.message)==null?void 0:kt.columns)||[],De=na(Rt,Ot),Qe=Ze(Rt,Ot,De),fe={};Ot.forEach(ct=>{const It=ct[De]!==null&&ct[De]!==void 0&&ct[De]!==""?String(ct[De]):"(No Type)",st=Qe&&parseFloat(ct[Qe])||0;fe[It]=(fe[It]||0)+st});const re=Object.keys(fe),Ee=Object.values(fe),Ge=Rt.find(ct=>(ct==null?void 0:ct.fieldname)===Qe);Me({labels:re,datasets:[{name:(Ge==null?void 0:Ge.label)||"Count",values:Ee}],rawRows:Ot,columns:Rt,type:"Bar"})}}catch(it){console.error("Error fetching inspection summary:",it)}})},[I,ee,se,Ye]),y.useEffect(()=>{if(!I)return;Q(null,null,function*(){var Be,kt;try{const it={};!se&&ee.length>0?it.work_order_type=ee.length===1?ee[0]:ee:Ye&&(it.work_order_type=Ye);const Dt=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"WO Rejection Summary",filters:it,ignore_prepared_report:1})})).json();if((Be=Dt.message)!=null&&Be.result){const Ot=Dt.message.result.filter(V=>V&&typeof V=="object"&&!V.is_total_row),Rt=((kt=Dt.message)==null?void 0:kt.columns)||[],De=na(Rt,Ot),Qe=V=>typeof V=="number"&&!isNaN(V)||typeof V=="string"&&V!==""&&!isNaN(parseFloat(V)),fe=V=>{if(!(V!=null&&V.fieldname)||V.fieldname===De||!Ot.length)return!1;if(V.fieldtype&&["Int","Float","Currency","Percent"].includes(V.fieldtype))return!0;const me=Ot.find(de=>de[V.fieldname]!=null&&de[V.fieldname]!=="");return me?Qe(me[V.fieldname]):!1},re=Rt.filter(fe),Ee=re.length>0?re:Rt.filter(V=>{if(!(V!=null&&V.fieldname)||V.fieldname===De||!Ot.length)return!1;const me=Ot.find(de=>de[V.fieldname]!=null&&de[V.fieldname]!=="");return me?!isNaN(parseFloat(String(me[V.fieldname]))):!1}),Ge={};Ot.forEach(V=>{const me=V[De]!==null&&V[De]!==void 0&&V[De]!==""?String(V[De]):"(No Type)";Ge[me]||(Ge[me]={}),Ee.forEach(de=>{Ge[me][de.fieldname]=(Ge[me][de.fieldname]||0)+(parseFloat(V[de.fieldname])||0)})});const ct=(()=>{var me;const V=Ee.find(de=>{const ie=((de.label||"")+(de.fieldname||"")).toLowerCase();return ie.includes("total_rejected")||ie.includes("total rejected")||ie.includes("rejected")});return(V==null?void 0:V.fieldname)||((me=Ee[Ee.length-1])==null?void 0:me.fieldname)||null})(),It=Object.keys(Ge),st=It.map(V=>ct&&Ge[V][ct]||0),rt=st.reduce((V,me)=>V+me,0);Ne({labels:It,datasets:[{name:"Total Rejected",values:st}],totalRejected:rt,rawRows:Ot,columns:Rt,type:"Bar"})}}catch(it){console.error("Error fetching rejection summary:",it)}})},[I,ee,se,Ye]),y.useEffect(()=>{if(d&&d.length>0){let et=0,Be=0;d.forEach(xt=>{const Dt=xt.custom_up_time||0,Ot=xt.custom_down_time||0;et+=typeof Dt=="number"?Dt:0,Be+=typeof Ot=="number"?Ot:0});const kt=[],it=[];if(et>0&&(kt.push(t("dashboard.upTime")),it.push(et)),Be>0&&(kt.push(t("dashboard.downTime")),it.push(Be)),kt.length>0){const xt=[];et>0&&xt.push("#6366F1"),Be>0&&xt.push("#8B5CF6"),N({labels:kt,datasets:[{name:"Time",values:it,colors:xt}],type:"Pie"})}else N(null)}else N(null)},[d]),y.useEffect(()=>{if(d&&d.length>0){const et=d.filter(Be=>(Be.custom_device_status||"").trim().toLowerCase()==="down").length;ne(Be=>Se(ue({},Be),{assetsDown:et}))}},[d]),y.useEffect(()=>{if(d&&d.length>0){const et={};d.forEach(Ot=>{const Rt=(Ot.custom_device_status||"Unknown").trim();et[Rt]=(et[Rt]||0)+1});const Be=Object.entries(et).sort(([,Ot],[,Rt])=>Rt-Ot),kt=Be.map(([Ot])=>Ot),it=Be.map(([,Ot])=>Ot),xt={Up:"#10B981",up:"#10B981",Down:"#EF4444",down:"#EF4444","Under Maintenance":"#F59E0B","under maintenance":"#F59E0B",Decommissioned:"#6B7280"},Dt=kt.map((Ot,Rt)=>xt[Ot]||xt[Ot.toLowerCase()]||Pi(kt.length)[Rt]);C({labels:kt,datasets:[{name:"Assets",values:it,colors:Dt}],type:"Pie",total:d.length})}else C(null)},[d]),y.useEffect(()=>{if($t&&$t.length>0){const et={};let Be=0,kt=0,it=0,xt=0,Dt=0;$t.forEach(Ue=>{const Pe=Ue.repair_status||"Unknown";et[Pe]=(et[Pe]||0)+1;const Re=Pe.toLowerCase();Re==="open"&&Be++,Re==="work in progress"&&kt++,Re==="closed"&&it++,Re==="pending review"&&xt++,Re==="rejected"&&Dt++});let Ot=0,Rt=0,De=0;$t.forEach(Ue=>{const Pe=(Ue.workflow_state||"").toLowerCase();Pe==="closed"||Pe==="sent to supervisor"?Ot++:Pe==="rejected"?De++:Rt++});const Qe=["Open","Work In Progress","Pending Review","Closed","Rejected","Cancelled","Unknown"],fe=Object.entries(et).sort(([Ue],[Pe])=>{const Re=Qe.indexOf(Ue),We=Qe.indexOf(Pe);return Re===-1&&We===-1?Ue.localeCompare(Pe):Re===-1?1:We===-1?-1:Re-We}),re=fe.map(([Ue])=>Ue),Ee=fe.map(([,Ue])=>Ue),Ge={Open:"#F59E0B","Work In Progress":"#3B82F6","Pending Review":"#E11D48",Pending:"#8B5CF6",Completed:"#10B981",Closed:"#10B981",Rejected:"#EF4444",Cancelled:"#EC4899",Unknown:"#6B7280"},ct=re.map(Ue=>Ge[Ue]||"#6366F1");h({labels:re,datasets:[{name:"Work Orders",values:Ee,colors:ct}],type:"bar"}),U({open:Be,inProgress:kt,completed:it,pendingReview:xt,rejected:Dt,total:$t.length,wfCompleted:Ot,wfInProgress:Rt,wfRejected:De});const It=Ue=>{const Pe=Ue.toLowerCase().trim();return Pe.includes("open")?"Open":Pe.includes("work in progress")||Pe.includes("in progress")||Pe.includes("wip")?"Work In Progress":Pe.includes("pending review")||Pe.includes("pending")?"Pending Review":Pe.includes("completed")||Pe.includes("complete")?"Completed":Pe.includes("closed")?"Closed":Pe.includes("rejected")?"Rejected":Ue},st={},rt=new Set;$t.forEach(Ue=>{const Pe=Ue.work_order_type;if(Wo(Pe))return;const Re=String(Pe),We=It(Ue.repair_status||"Unknown");rt.add(We),st[Re]||(st[Re]={}),st[Re][We]=(st[Re][We]||0)+1});const V=Object.keys(st),me=["Open","Work In Progress","Pending Review","Completed","Closed","Rejected"],ie=Array.from(rt).sort((Ue,Pe)=>{const Re=me.indexOf(Ue),We=me.indexOf(Pe);return Re!==-1&&We!==-1?Re-We:Re!==-1?-1:We!==-1?1:Ue.localeCompare(Pe)}).map(Ue=>({name:Ue,values:V.map(Pe=>st[Pe][Ue]||0)}));p({labels:V,datasets:ie,type:"Bar"});const xe={};$t.forEach(Ue=>{const Pe=Ue.work_order_type;if(Wo(Pe))return;const Re=String(Pe);xe[Re]||(xe[Re]={total:0,wfCompleted:0,wfInProgress:0,wfRejected:0,closed:0,pendingReview:0,open:0,inProgress:0,rejected:0}),xe[Re].total++;const We=(Ue.workflow_state||"").toLowerCase();We==="closed"||We==="sent to supervisor"?xe[Re].wfCompleted++:We==="rejected"?xe[Re].wfRejected++:xe[Re].wfInProgress++;const _t=(Ue.repair_status||"").toLowerCase();_t==="closed"&&xe[Re].closed++,_t==="pending review"&&xe[Re].pendingReview++,_t==="open"&&xe[Re].open++,_t==="work in progress"&&xe[Re].inProgress++,_t==="rejected"&&xe[Re].rejected++});const _e=Object.keys(xe),He=_e.map(Ue=>{const Pe=xe[Ue];return Se(ue({type:Ue},Pe),{rate:Pe.total>0?Pe.wfCompleted/Pe.total*100:0})});Y({labels:_e,rates:He})}else p(null),Y(null)},[$t]),y.useEffect(()=>{if(c&&c.length>0){const et={};let Be=0,kt=0,it=0;const xt=new Date;c.forEach(st=>{var V,me;const rt=st.asset_name||"Unknown";et[rt]=(et[rt]||0)+1,((V=st.maintenance_status)==null?void 0:V.toLowerCase())==="completed"&&Be++,((me=st.maintenance_status)==null?void 0:me.toLowerCase())==="planned"&&kt++,st.due_date&&new Date(st.due_date)<xt&&st.maintenance_status!=="Completed"&&it++});const Dt=Object.entries(et).sort(([,st],[,rt])=>rt-st).slice(0,10);j({labels:Dt.map(([st])=>st),datasets:[{name:"Maintenance Count",values:Dt.map(([,st])=>st),colors:Pi(Dt.length)}],type:"bar"});const Ot=c.length>0?Be/c.length*100:0;ne(st=>Se(ue({},st),{maintenanceEfficiency:Ot,overdueTasks:it,plannedMaintenance:kt}));const Rt={},De=new Set,Qe=(st,rt)=>{const V=st.toLowerCase().trim(),me=new Date,de=rt.due_date?new Date(rt.due_date):null;return de&&de<me&&V!=="completed"&&V!=="cancelled"?"Overdue":V.includes("completed on time")||V==="completed on time"?"Completed On Time":V.includes("completed within")||V.includes("within sla")||V==="completed"?"Completed Within SLA":V.includes("delay")||V.includes("late")?"Delay In Completion":V.includes("pending")||V==="planned"?"Pending":V.includes("overdue")?"Overdue":V.includes("cancelled")||V==="cancelled"?"Cancelled":st};c.forEach(st=>{const rt=st.assign_to_name||"null",V=Qe(st.maintenance_status||"Unknown",st);De.add(V),Rt[rt]||(Rt[rt]={}),Rt[rt][V]=(Rt[rt][V]||0)+1});const fe=Object.keys(Rt),re=["Completed On Time","Completed Within SLA","Delay In Completion","Pending","Overdue","Cancelled"],Ge=Array.from(De).sort((st,rt)=>{const V=re.indexOf(st),me=re.indexOf(rt);return V!==-1&&me!==-1?V-me:V!==-1?-1:me!==-1?1:st.localeCompare(rt)}).map(st=>({name:st,values:fe.map(rt=>Rt[rt][st]||0)}));T({labels:fe,datasets:Ge,type:"Bar"});const ct={};c.forEach(st=>{const rt=st.periodicity||st.maintenance_type||"Other";ct[rt]=(ct[rt]||0)+1});const It=Object.entries(ct).sort(([,st],[,rt])=>rt-st);O({labels:It.map(([st])=>st),datasets:[{name:"Frequency",values:It.map(([,st])=>st),colors:Pi(It.length)}],type:"bar"})}else T(null),O(null)},[c]),y.useEffect(()=>{if(i&&i.length>0){let et=0,Be=0;i.forEach(it=>{if(it.creation&&it.first_responded_on){const xt=new Date(it.creation),Ot=(new Date(it.first_responded_on).getTime()-xt.getTime())/(1e3*60*60);Ot>=0&&(et+=Ot,Be++)}});const kt=Be>0?et/Be:0;ne(it=>Se(ue({},it),{avgResponseTime:kt}))}},[i]),y.useEffect(()=>{if(!oe)return;Q(null,null,function*(){var Be,kt,it;try{const xt={};!se&&ee.length>0?xt.work_order_type=ee.length===1?ee[0]:ee:Ye&&(xt.work_order_type=Ye);const Ot=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"Time to Repair",filters:xt,ignore_prepared_report:1})})).json();if((Be=Ot.message)!=null&&Be.result){const Rt=Ot.message.result.filter(V=>V&&typeof V=="object"&&!V.is_total_row),De=((kt=Ot.message)==null?void 0:kt.columns)||[],Qe=De.find(V=>{const me=((V.label||"")+(V.fieldname||"")).toLowerCase();return me.includes("wo_type")||me.includes("wo type")||me.includes("work_order_type")||me.includes("work order type")})||De[1],fe=De.find(V=>{const me=((V.label||"")+(V.fieldname||"")).toLowerCase();return me.includes("time_to_repair")||me.includes("time to repair")||me.includes("repair_time")||me.includes("hours")})||De[De.length-1],re={};Rt.forEach(V=>{const me=Qe?V[Qe.fieldname]:null;if(Wo(me))return;const de=String(me),ie=fe&&parseFloat(V[fe.fieldname])||0;re[de]||(re[de]={total:0,count:0}),re[de].total+=ie,re[de].count+=1});const Ee=Object.keys(re),Ge=Ee.map(V=>parseFloat((re[V].total/re[V].count).toFixed(3))),ct=Rt.filter(V=>!Wo(Qe?V[Qe.fieldname]:null)),It=ct.length>0?parseFloat((ct.reduce((V,me)=>V+(fe&&parseFloat(me[fe.fieldname])||0),0)/ct.length).toFixed(3)):0,st=((it=Ot.message)==null?void 0:it.report_summary)||[],rt=st.find(V=>{var me,de;return((me=V.label)==null?void 0:me.toLowerCase().includes("avg"))||((de=V.label)==null?void 0:de.toLowerCase().includes("overall"))});Te({labels:Ee,datasets:[{name:"Avg Time to Repair (hrs)",values:Ge}],overallAvg:rt&&parseFloat(rt.value)||It,rawRows:Rt,columns:De,reportSummary:st,type:"Bar"})}}catch(xt){console.error("Error fetching time to repair:",xt)}})},[oe,ee,se,Ye]),r?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-600 mx-auto mb-4"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:t("dashboard.loading")})]})}):e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[e.jsxs("div",{className:"max-w-[1600px] mx-auto",children:[(se||ee.length===0)&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 px-5 py-3 mb-5 flex items-center gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("div",{className:"w-7 h-7 bg-indigo-50 dark:bg-indigo-900/30 rounded-lg flex items-center justify-center",children:e.jsx(ds,{className:"text-indigo-500 text-xs"})}),e.jsx("span",{className:"font-semibold text-gray-700 dark:text-gray-300",children:t("dashboard.dashboardFilter","Dashboard Filter")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Technical Department"}),e.jsxs("select",{value:Ye,onChange:et=>ft(et.target.value),className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white min-w-[200px]",children:[e.jsx("option",{value:"",children:t("dashboard.allDepartments","All Departments")}),sa.map(et=>e.jsx("option",{value:et,children:et},et))]})]}),Ye&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>ft(""),className:"text-xs text-red-500 hover:text-red-700 dark:text-red-400 flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:[e.jsx(wt,{size:10})," ",t("dashboard.clearFilter","Clear")]}),e.jsx("span",{className:"text-xs text-indigo-600 dark:text-indigo-400 bg-indigo-50 dark:bg-indigo-900/30 px-3 py-1 rounded-full font-medium",children:Ye})]})]}),e.jsxs("div",{className:"grid grid-cols-12 gap-4 mb-5",style:{gridTemplateRows:"auto 1fr 1fr"},children:[e.jsx("div",{className:"col-span-12 lg:col-span-7",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"grid grid-cols-4 lg:grid-cols-7 divide-x divide-gray-200 dark:divide-gray-700",children:[e.jsx(ic,{icon:e.jsx(Sx,{className:"text-indigo-600"}),value:(Ie=(aa=d==null?void 0:d.length)!=null?aa:a==null?void 0:a.total_assets)!=null?Ie:0,label:t("dashboard.totalAssets"),bgColor:"bg-indigo-50 dark:bg-indigo-900/20",iconColor:"text-indigo-600",href:"/asm_app/assets"}),e.jsx(ic,{icon:e.jsx(Z5,{className:"text-amber-500"}),value:P.open||((Nt=a==null?void 0:a.work_orders_open)!=null?Nt:0),label:t("dashboard.openWorkOrders"),bgColor:"bg-amber-50 dark:bg-amber-900/20",iconColor:"text-amber-500",href:"/asm_app/work-orders?status=Open"}),e.jsx(ic,{icon:e.jsx(or,{className:"text-blue-600"}),value:P.inProgress||((ve=a==null?void 0:a.work_orders_in_progress)!=null?ve:0),label:t("dashboard.workOrdersInProgress"),bgColor:"bg-blue-50 dark:bg-blue-900/20",iconColor:"text-blue-600",href:"/asm_app/work-orders?status=In+Progress"}),e.jsx(ic,{icon:e.jsx(fa,{className:"text-orange-500"}),value:P.pendingReview,label:t("dashboard.pendingReviewWorkOrders","Pending Review"),bgColor:"bg-orange-50 dark:bg-orange-900/20",iconColor:"text-orange-500",href:"/asm_app/work-orders?status=Pending+Review"}),e.jsx(ic,{icon:e.jsx(ea,{className:"text-emerald-600"}),value:P.completed||((Oe=a==null?void 0:a.work_orders_completed)!=null?Oe:0),label:t("dashboard.closedWorkOrders"),bgColor:"bg-emerald-50 dark:bg-emerald-900/20",iconColor:"text-emerald-600",href:"/asm_app/work-orders?status=Closed"}),e.jsx(ic,{icon:e.jsx(ei,{className:"text-red-500"}),value:P.rejected,label:t("dashboard.rejectedWorkOrders","Rejected WOs"),bgColor:"bg-red-50 dark:bg-red-900/20",iconColor:"text-red-500",href:"/asm_app/work-orders?status=Rejected"}),e.jsx(ic,{icon:e.jsx(N2,{className:"text-purple-600"}),value:P.total,label:t("dashboard.totalWorkOrders"),bgColor:"bg-purple-50 dark:bg-purple-900/20",iconColor:"text-purple-600",href:"/asm_app/work-orders"})]})})}),e.jsx("div",{className:"col-span-12 lg:col-span-5 lg:row-span-2 flex",children:e.jsx(K9,{className:"flex-1 w-full",data:m||ye,totalWorkOrders:P.total,completedWorkOrders:P.completed,onOpenReport:()=>Vt({title:"Work Order Status Distribution",data:m||ye,redirectContext:"wo_status"})})}),e.jsx("div",{className:"col-span-12 lg:col-span-7 flex",children:e.jsx(G9,{className:"flex-1 w-full",totalWorkOrders:P.total,completedWorkOrders:P.wfCompleted,inProgressWorkOrders:P.wfInProgress,rejectedWorkOrders:P.wfRejected,byTypeChartData:R,onOpenReport:()=>{const et=(R==null?void 0:R.rates)||[];Vt({title:t("dashboard.completionRate","Completion Rate by Department"),data:{labels:et.map(Be=>Be.type),datasets:[{name:"Completion Rate (%)",values:et.map(Be=>parseFloat(Be.rate.toFixed(2)))},{name:"WF Completed",values:et.map(Be=>Be.wfCompleted)},{name:"In Progress",values:et.map(Be=>Be.wfInProgress)},{name:"Rejected (WF)",values:et.map(Be=>Be.wfRejected)},{name:"Closed WOs",values:et.map(Be=>Be.closed)},{name:"Pending Review",values:et.map(Be=>Be.pendingReview)},{name:"Open",values:et.map(Be=>Be.open)},{name:"Total",values:et.map(Be=>Be.total)}],hideFooterTotal:!0}})}})}),e.jsx("div",{className:"col-span-12 lg:col-span-7 flex",children:e.jsx(Z9,{className:"flex-1 w-full",totalWorkOrders:P.total,closedWorkOrders:P.completed,inProgressWorkOrders:P.inProgress,rejectedWorkOrders:P.rejected,byTypeChartData:R,onOpenReport:()=>{const et=(R==null?void 0:R.rates)||[];Vt({title:"Overall Completion Rate by Department",data:{labels:et.map(Be=>Be.type),datasets:[{name:"Completion Rate (%)",values:et.map(Be=>parseFloat((Be.closed/(Be.total||1)*100).toFixed(2)))},{name:"Closed WOs",values:et.map(Be=>Be.closed)},{name:"In Progress",values:et.map(Be=>Be.inProgress)},{name:"Rejected",values:et.map(Be=>Be.rejected)},{name:"Total WOs",values:et.map(Be=>Be.total)}],hideFooterTotal:!0}})}})}),e.jsx("div",{className:"col-span-12 lg:col-span-5 flex",children:e.jsx(Q9,{className:"flex-1 w-full",data:k,totalAssets:(ht=d==null?void 0:d.length)!=null?ht:0,onOpenReport:()=>ta(!0)})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-5",children:[e.jsx(qm,{icon:e.jsx(fa,{className:"text-red-500"}),title:t("dashboard.assetsDown","Assets Down"),value:J.assetsDown,trend:J.assetsDown===0?"All Operational":J.assetsDown<=3?"Low":"High Priority",trendUp:J.assetsDown===0,bgColor:"bg-red-50 dark:bg-red-900/20"}),e.jsx(qm,{icon:e.jsx(or,{className:"text-blue-500"}),title:t("dashboard.avgResponseTime"),value:J.avgResponseTime>0?`${J.avgResponseTime.toFixed(1)} hrs`:"N/A",trend:J.avgResponseTime>0&&J.avgResponseTime<4?"Fast Response":"Monitor",trendUp:J.avgResponseTime>0&&J.avgResponseTime<4,bgColor:"bg-blue-50 dark:bg-blue-900/20"}),e.jsx(qm,{icon:e.jsx(A2,{className:"text-orange-500"}),title:t("dashboard.maintenanceEfficiency"),value:`${J.maintenanceEfficiency.toFixed(1)}%`,trend:J.maintenanceEfficiency>=70?"On Track":"Needs Attention",trendUp:J.maintenanceEfficiency>=70,bgColor:"bg-orange-50 dark:bg-orange-900/20"}),e.jsx(qm,{icon:e.jsx(fa,{className:"text-rose-500"}),title:t("dashboard.overdueMaintenance"),value:J.overdueTasks,trend:J.overdueTasks===0?"All Clear":J.overdueTasks<=3?"Low":"High Priority",trendUp:J.overdueTasks<=3,bgColor:"bg-rose-50 dark:bg-rose-900/20"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-5",children:[e.jsx(u_,{title:t("dashboard.workOrderStatus"),data:g||ye,onOpenReport:()=>Vt({title:t("dashboard.workOrderStatus"),data:g||ye,redirectContext:"wo_type"})}),e.jsx(u_,{title:t("dashboard.assigneesStatus"),data:D||he,onOpenReport:()=>Vt({title:t("dashboard.assigneesStatus"),data:D||he}),showSummary:!0})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-5",children:[e.jsx(rO,{title:t("dashboard.technicianWorkingHours","Technicians Working Hours"),data:ae,onOpenReport:()=>K(!0)}),e.jsx(sO,{title:t("dashboard.techniciansWorked","Technicians Work Summary"),data:M,onOpenReport:()=>be(!0)})]}),I&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-5",children:[e.jsx(oO,{title:t("dashboard.inspectionLinkedWOSummary","Inspection Linked Work Orders Summary"),data:ke,onOpenReport:()=>gt(!0)}),e.jsx(lO,{title:t("dashboard.woRejectionSummary","WO Rejection Summary"),data:z,onOpenReport:()=>Ht(!0)})]}),oe&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-5",children:[e.jsx(uO,{data:Mt,onOpenReport:()=>zt(!0)}),e.jsx(X9,{insights:J,maintenanceLogs:c||[]})]})]}),e.jsx(W9,{isOpen:X,onClose:()=>K(!1),permittedIssueTypes:ee,isAdmin:se,defaultWorkOrderType:Ye}),e.jsx(V9,{isOpen:we,onClose:()=>be(!1),permittedIssueTypes:ee,isAdmin:se,defaultWorkOrderType:Ye}),I&&e.jsx(cO,{isOpen:Xe,onClose:()=>gt(!1),permittedIssueTypes:ee,isAdmin:se,defaultWorkOrderType:Ye}),I&&e.jsx(dO,{isOpen:St,onClose:()=>Ht(!1),permittedIssueTypes:ee,isAdmin:se,defaultWorkOrderType:Ye}),oe&&e.jsx(mO,{isOpen:Qt,onClose:()=>zt(!1),permittedIssueTypes:ee,isAdmin:se,defaultWorkOrderType:Ye}),e.jsx(eO,{isOpen:va,onClose:()=>ta(!1),assets:d||[],chartData:k}),e.jsx(iO,{isOpen:!!Wt,onClose:()=>Vt(null),title:(Wt==null?void 0:Wt.title)||"",data:Wt==null?void 0:Wt.data,redirectContext:Wt==null?void 0:Wt.redirectContext})]})},ic=({icon:t,value:a,label:r,bgColor:s,href:i})=>{const c=()=>{i&&(window.location.href=i)};return e.jsxs("div",{className:`text-center py-3 px-2 last:border-r-0 ${i?"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors rounded-lg group":""}`,onClick:i?c:void 0,title:i?`View ${r}`:void 0,children:[e.jsx("div",{className:`w-10 h-10 ${s} rounded-xl flex items-center justify-center text-base mx-auto mb-2 ${i?"group-hover:scale-105 transition-transform":""}`,children:t}),e.jsx("div",{className:"text-xl font-bold text-gray-900 dark:text-white leading-none mb-1",children:a}),e.jsx("div",{className:"text-[9px] font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide leading-tight px-1",children:r}),i&&e.jsx("div",{className:"text-[8px] text-indigo-400 dark:text-indigo-500 opacity-0 group-hover:opacity-100 transition-opacity mt-0.5",children:"View →"})]})},qm=({icon:t,title:a,value:r,trend:s,trendUp:i,bgColor:c})=>e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all p-4 border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsx("div",{className:`w-10 h-10 ${c} rounded-xl flex items-center justify-center text-lg`,children:t}),e.jsxs("div",{className:`flex items-center gap-1 text-xs font-semibold px-2 py-1 rounded-full ${i?"text-emerald-700 bg-emerald-50 dark:text-emerald-400 dark:bg-emerald-900/20":"text-red-700 bg-red-50 dark:text-red-400 dark:bg-red-900/20"}`,children:[i?e.jsx(B5,{className:"text-[9px]"}):e.jsx(z5,{className:"text-[9px]"}),s]})]}),e.jsx("div",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-1",children:r}),e.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:a})]}),G9=({totalWorkOrders:t,completedWorkOrders:a,inProgressWorkOrders:r,rejectedWorkOrders:s,byTypeChartData:i,onOpenReport:c,className:d=""})=>{var g;const{t:m}=ca(),h=t>0?(a/t*100).toFixed(2):"0.00";return e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all px-5 py-4 border border-gray-200 dark:border-gray-700 flex flex-col h-full ${d}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-indigo-50 dark:bg-indigo-900/20 rounded-xl flex items-center justify-center",children:e.jsx(N2,{className:"text-indigo-600 text-base"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:[h,"%"]}),e.jsx("div",{className:"text-xs font-semibold text-indigo-600 dark:text-indigo-400 uppercase tracking-wide",children:m("dashboard.completionRate","Workflow Completion Rate")})]})]}),c&&e.jsx("button",{onClick:c,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"View Detail",children:e.jsx(vs,{className:"text-gray-400 text-xs"})})]}),i&&((g=i.rates)==null?void 0:g.length)>0?e.jsx(Y9,{data:i}):e.jsx("div",{className:"h-28 flex items-center justify-center text-gray-400 text-xs",children:m("dashboard.noDataAvailable","No data available")}),e.jsxs("div",{className:"grid grid-cols-4 gap-3 mt-3 pt-3 border-t border-gray-100 dark:border-gray-700",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg font-bold text-indigo-600 dark:text-indigo-400",children:t}),e.jsx("div",{className:"text-[9px] font-semibold text-gray-400 uppercase tracking-wide",children:"Total"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg font-bold text-blue-600 dark:text-blue-400",children:r}),e.jsx("div",{className:"text-[9px] font-semibold text-gray-400 uppercase tracking-wide",children:"In Progress"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg font-bold text-red-600 dark:text-red-400",children:s}),e.jsx("div",{className:"text-[9px] font-semibold text-gray-400 uppercase tracking-wide",children:"Rejected"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg font-bold text-emerald-600 dark:text-emerald-400",children:a}),e.jsx("div",{className:"text-[9px] font-semibold text-gray-400 uppercase tracking-wide",children:"Completed"})]})]})]})},Y9=({data:t})=>{const{t:a}=ca(),[r,s]=pa.useState(null),i=pa.useRef(null),[c,d]=pa.useState(null),m=((t==null?void 0:t.rates)||[]).filter(Y=>!Wo(Y.type));if(!m.length)return e.jsx("div",{className:"h-28 flex items-center justify-center text-gray-400 text-xs",children:a("dashboard.noDataAvailable","No data available")});const h=Pi(m.length),g=110,p=32,b=12,j=10,N=g-j-28,k=m.length,C=Math.max(260,k*72+p+b),T=(C-p-b)/k,E=Math.min(44,T*.55),O=[0,.25,.5,.75,1],R=(Y,P)=>{if(s(Y),i.current){const U=i.current.getBoundingClientRect(),ne=P.currentTarget.ownerSVGElement.getBoundingClientRect(),ye=ne.width/C,he=ne.left-U.left+(p+Y*T+T/2)*ye;d({x:he,y:0})}};return e.jsxs("div",{className:"w-full relative",ref:i,children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("svg",{width:"100%",height:g,viewBox:`0 0 ${C} ${g}`,preserveAspectRatio:"xMidYMid meet",className:"w-full",onMouseLeave:()=>{s(null),d(null)},children:[O.map((Y,P)=>{const U=j+N-Y*N;return e.jsxs("g",{children:[e.jsx("line",{x1:p,y1:U,x2:C-b,y2:U,stroke:"#E5E7EB",strokeWidth:"1"}),e.jsxs("text",{x:p-3,y:U+3,textAnchor:"end",fontSize:"7",fill:"#9CA3AF",children:[Math.round(Y*100),"%"]})]},P)}),e.jsx("line",{x1:p,y1:j+N,x2:C-b,y2:j+N,stroke:"#D1D5DB",strokeWidth:"1"}),m.map((Y,P)=>{const U=Math.max(0,Y.rate/100*N),J=p+P*T+T/2,ne=J-E/2,ye=j+N-U,he=h[P],ce=r===P;return e.jsxs("g",{onMouseEnter:se=>R(P,se),style:{cursor:"pointer"},children:[e.jsx("rect",{x:p+P*T,y:j,width:T,height:N,fill:"transparent"}),e.jsx("rect",{x:ne,y:U>0?ye:j+N-1,width:E,height:U>0?U:1,fill:he,rx:"4",ry:"4",opacity:ce?1:.8,style:{transition:"opacity 0.15s, filter 0.15s",filter:ce?"brightness(1.15)":"none"}}),U>14&&e.jsxs("text",{x:J,y:ye-3,textAnchor:"middle",fontSize:"7.5",fontWeight:"700",fill:he,children:[Y.rate.toFixed(1),"%"]}),e.jsx("text",{x:J,y:j+N+12,textAnchor:"middle",fontSize:"6.5",fill:ce?he:"#6B7280",fontWeight:ce?"700":"400",children:(Y.type||"").length>11?(Y.type||"").substring(0,9)+"…":Y.type||""})]},P)})]})}),r!==null&&c&&m[r]&&(()=>{const Y=m[r],P=h[r];return e.jsxs("div",{className:"absolute pointer-events-none z-30",style:{left:c.x,top:4,transform:"translateX(-50%)",minWidth:160},children:[e.jsxs("div",{className:"bg-gray-900 dark:bg-gray-700 text-white text-xs rounded-xl shadow-2xl px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1 pb-1 border-b border-white/20",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{backgroundColor:P}}),e.jsx("span",{className:"font-semibold text-[11px] truncate max-w-[120px]",children:Y.type})]}),e.jsxs("div",{className:"text-green-400 font-bold text-sm text-center mb-0.5",children:["WF: ",Y.rate.toFixed(2),"%"]}),e.jsxs("div",{className:"text-gray-300 text-[10px] text-center",children:[Y.wfCompleted," done · ",Y.wfInProgress," prog · ",Y.wfRejected," rej"]})]}),e.jsx("div",{className:"w-2.5 h-2.5 bg-gray-900 dark:bg-gray-700 rotate-45 mx-auto -mt-1.5"})]})})(),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-2 pt-2 border-t border-gray-100 dark:border-gray-700",children:m.map((Y,P)=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{backgroundColor:h[P]}}),e.jsx("span",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:(Y.type||"").length>22?(Y.type||"").substring(0,20)+"…":Y.type||""})]},P))})]})},Z9=({totalWorkOrders:t,closedWorkOrders:a,inProgressWorkOrders:r,rejectedWorkOrders:s,byTypeChartData:i,onOpenReport:c,className:d=""})=>{var g;const{t:m}=ca(),h=t>0?(a/t*100).toFixed(2):"0.00";return e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all px-5 py-4 border border-gray-200 dark:border-gray-700 flex flex-col h-full ${d}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-emerald-50 dark:bg-emerald-900/20 rounded-xl flex items-center justify-center",children:e.jsx(ea,{className:"text-emerald-600 text-base"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:[h,"%"]}),e.jsx("div",{className:"text-xs font-semibold text-emerald-600 dark:text-emerald-400 uppercase tracking-wide",children:"Overall Completion Rate"})]})]}),c&&e.jsx("button",{onClick:c,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"View Detail",children:e.jsx(vs,{className:"text-gray-400 text-xs"})})]}),i&&((g=i.rates)==null?void 0:g.length)>0?e.jsx(J9,{data:i}):e.jsx("div",{className:"h-28 flex items-center justify-center text-gray-400 text-xs",children:m("dashboard.noDataAvailable","No data available")}),e.jsxs("div",{className:"grid grid-cols-4 gap-3 mt-3 pt-3 border-t border-gray-100 dark:border-gray-700",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg font-bold text-indigo-600 dark:text-indigo-400",children:t}),e.jsx("div",{className:"text-[9px] font-semibold text-gray-400 uppercase tracking-wide",children:"Total"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg font-bold text-blue-600 dark:text-blue-400",children:r}),e.jsx("div",{className:"text-[9px] font-semibold text-gray-400 uppercase tracking-wide",children:"In Progress"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg font-bold text-red-600 dark:text-red-400",children:s}),e.jsx("div",{className:"text-[9px] font-semibold text-gray-400 uppercase tracking-wide",children:"Rejected"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-lg font-bold text-emerald-600 dark:text-emerald-400",children:a}),e.jsx("div",{className:"text-[9px] font-semibold text-gray-400 uppercase tracking-wide",children:"Completed"})]})]})]})},J9=({data:t})=>{const{t:a}=ca(),[r,s]=pa.useState(null),i=pa.useRef(null),[c,d]=pa.useState(null),m=((t==null?void 0:t.rates)||[]).filter(P=>!Wo(P.type));if(!m.length)return e.jsx("div",{className:"h-28 flex items-center justify-center text-gray-400 text-xs",children:a("dashboard.noDataAvailable","No data available")});const h=m.map(P=>({type:P.type,total:P.total,closed:P.closed,inProgress:P.inProgress,rejected:P.rejected,rate:P.total>0?P.closed/P.total*100:0})),g=Pi(h.length),p=110,b=32,j=12,_=10,k=p-_-28,C=h.length,D=Math.max(260,C*72+b+j),E=(D-b-j)/C,O=Math.min(44,E*.55),R=[0,.25,.5,.75,1],Y=(P,U)=>{if(s(P),i.current){const J=i.current.getBoundingClientRect(),ye=U.currentTarget.ownerSVGElement.getBoundingClientRect(),he=ye.width/D,ce=ye.left-J.left+(b+P*E+E/2)*he;d({x:ce,y:0})}};return e.jsxs("div",{className:"w-full relative",ref:i,children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("svg",{width:"100%",height:p,viewBox:`0 0 ${D} ${p}`,preserveAspectRatio:"xMidYMid meet",className:"w-full",onMouseLeave:()=>{s(null),d(null)},children:[R.map((P,U)=>{const J=_+k-P*k;return e.jsxs("g",{children:[e.jsx("line",{x1:b,y1:J,x2:D-j,y2:J,stroke:"#E5E7EB",strokeWidth:"1"}),e.jsxs("text",{x:b-3,y:J+3,textAnchor:"end",fontSize:"7",fill:"#9CA3AF",children:[Math.round(P*100),"%"]})]},U)}),e.jsx("line",{x1:b,y1:_+k,x2:D-j,y2:_+k,stroke:"#D1D5DB",strokeWidth:"1"}),h.map((P,U)=>{const J=Math.max(0,P.rate/100*k),ne=b+U*E+E/2,ye=ne-O/2,he=_+k-J,ce=g[U],se=r===U;return e.jsxs("g",{onMouseEnter:ee=>Y(U,ee),style:{cursor:"pointer"},children:[e.jsx("rect",{x:b+U*E,y:_,width:E,height:k,fill:"transparent"}),e.jsx("rect",{x:ye,y:J>0?he:_+k-1,width:O,height:J>0?J:1,fill:ce,rx:"4",ry:"4",opacity:se?1:.8,style:{transition:"opacity 0.15s, filter 0.15s",filter:se?"brightness(1.15)":"none"}}),J>14&&e.jsxs("text",{x:ne,y:he-3,textAnchor:"middle",fontSize:"7.5",fontWeight:"700",fill:ce,children:[P.rate.toFixed(1),"%"]}),e.jsx("text",{x:ne,y:_+k+12,textAnchor:"middle",fontSize:"6.5",fill:se?ce:"#6B7280",fontWeight:se?"700":"400",children:(P.type||"").length>11?(P.type||"").substring(0,9)+"…":P.type||""})]},U)})]})}),r!==null&&c&&h[r]&&(()=>{const P=h[r],U=g[r];return e.jsxs("div",{className:"absolute pointer-events-none z-30",style:{left:c.x,top:4,transform:"translateX(-50%)",minWidth:160},children:[e.jsxs("div",{className:"bg-gray-900 dark:bg-gray-700 text-white text-xs rounded-xl shadow-2xl px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1 pb-1 border-b border-white/20",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{backgroundColor:U}}),e.jsx("span",{className:"font-semibold text-[11px] truncate max-w-[120px]",children:P.type})]}),e.jsxs("div",{className:"text-green-400 font-bold text-sm text-center mb-0.5",children:[P.rate.toFixed(2),"% Closed"]}),e.jsxs("div",{className:"text-gray-300 text-[10px] text-center",children:[P.closed," closed · ",P.inProgress," prog · ",P.rejected," rej"]}),e.jsxs("div",{className:"text-gray-400 text-[10px] text-center",children:[P.total," total"]})]}),e.jsx("div",{className:"w-2.5 h-2.5 bg-gray-900 dark:bg-gray-700 rotate-45 mx-auto -mt-1.5"})]})})(),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-2 pt-2 border-t border-gray-100 dark:border-gray-700",children:h.map((P,U)=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{backgroundColor:g[U]}}),e.jsx("span",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:(P.type||"").length>22?(P.type||"").substring(0,20)+"…":P.type||""})]},U))})]})},X9=({insights:t,maintenanceLogs:a})=>{const r=pa.useMemo(()=>a.filter(m=>{var h;return((h=m.maintenance_status)==null?void 0:h.toLowerCase())==="completed"}).length,[a]),s=a.length,i=[{label:"Total Logs",value:s,color:"bg-indigo-50 dark:bg-indigo-900/20",textColor:"text-indigo-600 dark:text-indigo-400"},{label:"Planned",value:t.plannedMaintenance,color:"bg-blue-50 dark:bg-blue-900/20",textColor:"text-blue-600 dark:text-blue-400"},{label:"Completed",value:r,color:"bg-emerald-50 dark:bg-emerald-900/20",textColor:"text-emerald-600 dark:text-emerald-400"},{label:"Overdue",value:t.overdueTasks,color:"bg-red-50 dark:bg-red-900/20",textColor:"text-red-600 dark:text-red-400"}],c=Math.min(t.maintenanceEfficiency,100),d=c>=70?"#10B981":c>=40?"#F59E0B":"#EF4444";return e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all p-5 border border-gray-200 dark:border-gray-700 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-orange-50 dark:bg-orange-900/20 rounded-xl flex items-center justify-center",children:e.jsx(Xx,{className:"text-orange-500 text-base"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Maintenance Overview"}),e.jsxs("p",{className:"text-xs text-gray-400",children:[s," total maintenance logs"]})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:i.map((m,h)=>e.jsxs("div",{className:`${m.color} rounded-xl p-3 text-center`,children:[e.jsx("div",{className:`text-2xl font-bold ${m.textColor}`,children:m.value}),e.jsx("div",{className:"text-[10px] font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide mt-0.5",children:m.label})]},h))}),e.jsxs("div",{className:"mt-auto space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center text-xs mb-1",children:[e.jsx("span",{className:"font-semibold text-gray-600 dark:text-gray-300",children:"Maintenance Efficiency"}),e.jsxs("span",{className:"font-bold",style:{color:d},children:[t.maintenanceEfficiency.toFixed(1),"%"]})]}),e.jsx("div",{className:"h-3 bg-gray-100 dark:bg-gray-700 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-700",style:{width:`${c}%`,backgroundColor:d}})}),e.jsxs("div",{className:"flex justify-between text-[10px] text-gray-400 mt-1",children:[e.jsx("span",{children:"0%"}),e.jsx("span",{className:c>=70?"text-emerald-500":"text-amber-500",children:c>=70?"✓ On Track":"Needs Attention"}),e.jsx("span",{children:"100%"})]})]}),e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-100 dark:border-gray-700 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx(or,{className:"text-blue-400"}),e.jsx("span",{children:"Avg Response Time"})]}),e.jsx("span",{className:"text-sm font-bold text-blue-600 dark:text-blue-400",children:t.avgResponseTime>0?`${t.avgResponseTime.toFixed(1)} hrs`:"N/A"})]})]})},K9=({data:t,totalWorkOrders:a,completedWorkOrders:r,onOpenReport:s,className:i=""})=>{var d,m,h,g;const{t:c}=ca();return e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all px-5 py-5 border border-gray-200 dark:border-gray-700 flex flex-col h-full ${i}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 flex-shrink-0",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Work Order Status Distribution"}),e.jsxs("div",{className:"text-2xl font-bold text-gray-900 dark:text-white mt-1",children:[a," ",e.jsx("span",{className:"text-sm font-medium text-gray-500",children:"Total"})]})]}),e.jsx("button",{onClick:s,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:c("dashboard.viewFullReport"),children:e.jsx(vs,{className:"w-4 h-4 text-gray-400"})})]}),e.jsx("div",{className:"flex-1",children:t&&((d=t==null?void 0:t.labels)!=null&&d.length||(g=(h=(m=t==null?void 0:t.datasets)==null?void 0:m[0])==null?void 0:h.values)!=null&&g.length)?e.jsx(mk,{data:t}):e.jsx("div",{className:"h-48 flex items-center justify-center text-gray-400 text-sm",children:c("dashboard.noDataAvailable")})})]})},Q9=({data:t,totalAssets:a,onOpenReport:r,className:s=""})=>{var i;return e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all px-5 py-5 border border-gray-200 dark:border-gray-700 flex flex-col h-full ${s}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 flex-shrink-0",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Asset UP & Down"}),e.jsxs("div",{className:"text-2xl font-bold text-gray-900 dark:text-white mt-1",children:[a," ",e.jsx("span",{className:"text-sm font-medium text-gray-500",children:"Total"})]})]}),r&&e.jsx("button",{onClick:r,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"View Asset Status Report",children:e.jsx(vs,{className:"w-4 h-4 text-gray-400"})})]}),e.jsx("div",{className:"flex-1",children:t&&((i=t==null?void 0:t.labels)!=null&&i.length)?e.jsx(mk,{data:t}):e.jsx("div",{className:"h-48 flex items-center justify-center text-gray-400 text-sm",children:"No asset status data"})})]})},eO=({isOpen:t,onClose:a,assets:r,chartData:s})=>{var b,j,_,N,k,C;if(!t)return null;const i=(s==null?void 0:s.labels)||[],c=((j=(b=s==null?void 0:s.datasets)==null?void 0:b[0])==null?void 0:j.values)||[],d=((N=(_=s==null?void 0:s.datasets)==null?void 0:_[0])==null?void 0:N.colors)||Pi(i.length),m=(C=(k=s==null?void 0:s.total)!=null?k:r==null?void 0:r.length)!=null?C:c.reduce((D,T)=>D+T,0),h=D=>{const T=D.toLowerCase();return T==="up"?{border:"border-emerald-200 dark:border-emerald-700",bg:"bg-emerald-50 dark:bg-emerald-900/20",text:"text-emerald-700 dark:text-emerald-300",badge:"bg-emerald-100 dark:bg-emerald-800 text-emerald-700 dark:text-emerald-200"}:T==="down"?{border:"border-red-200 dark:border-red-700",bg:"bg-red-50 dark:bg-red-900/20",text:"text-red-700 dark:text-red-300",badge:"bg-red-100 dark:bg-red-800 text-red-700 dark:text-red-200"}:T.includes("maintenance")?{border:"border-amber-200 dark:border-amber-700",bg:"bg-amber-50 dark:bg-amber-900/20",text:"text-amber-700 dark:text-amber-300",badge:"bg-amber-100 dark:bg-amber-800 text-amber-700 dark:text-amber-200"}:T.includes("decommission")?{border:"border-gray-200 dark:border-gray-600",bg:"bg-gray-50 dark:bg-gray-700/30",text:"text-gray-600 dark:text-gray-400",badge:"bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300"}:{border:"border-indigo-200 dark:border-indigo-700",bg:"bg-indigo-50 dark:bg-indigo-900/20",text:"text-indigo-700 dark:text-indigo-300",badge:"bg-indigo-100 dark:bg-indigo-800 text-indigo-700 dark:text-indigo-200"}},g=D=>{const T=`/asm_app/assets?device_status=${encodeURIComponent(D)}`;window.location.href=T},p=()=>{window.location.href="/asm_app/assets"};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-lg overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"bg-gradient-to-r from-teal-500 to-emerald-600 px-6 py-4 flex items-center justify-between flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Sx,{className:"text-white text-xl"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-white leading-tight",children:"Asset Status Overview"}),e.jsx("p",{className:"text-teal-100 text-xs mt-0.5",children:"Click a card to view filtered assets"})]})]}),e.jsx("button",{onClick:a,className:"text-white/80 hover:text-white p-1.5 rounded-lg hover:bg-white/20 transition-colors",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("button",{onClick:p,className:"w-full flex items-center justify-between bg-indigo-50 dark:bg-indigo-900/20 border border-indigo-200 dark:border-indigo-700 rounded-xl px-5 py-4 hover:bg-indigo-100 dark:hover:bg-indigo-900/40 transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-indigo-100 dark:bg-indigo-800 rounded-xl flex items-center justify-center",children:e.jsx(Sx,{className:"text-indigo-600 dark:text-indigo-300 text-base"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"text-xs font-semibold text-indigo-500 dark:text-indigo-400 uppercase tracking-wide",children:"Total Assets"}),e.jsx("div",{className:"text-3xl font-bold text-indigo-700 dark:text-indigo-200 leading-tight",children:m})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-semibold text-indigo-500 dark:text-indigo-400 group-hover:text-indigo-700 dark:group-hover:text-indigo-200 transition-colors",children:["View all ",e.jsx(vs,{size:10})]})]}),i.length===0?e.jsx("div",{className:"text-center text-gray-400 py-8 text-sm",children:"No status data available"}):e.jsx("div",{className:"grid grid-cols-2 gap-3",children:i.map((D,T)=>{var P;const E=(P=c[T])!=null?P:0,O=m>0?(E/m*100).toFixed(1):"0.0",R=h(D),Y=d[T]||"#6366F1";return e.jsxs("button",{onClick:()=>g(D),className:`flex flex-col items-start text-left ${R.bg} border ${R.border} rounded-xl px-4 py-4 hover:opacity-80 hover:shadow-md transition-all group`,children:[e.jsxs("div",{className:"flex items-start justify-between w-full mb-2",children:[e.jsx("div",{className:`text-4xl font-bold ${R.text} leading-none`,children:E}),e.jsxs("div",{className:`flex items-center gap-1 text-[10px] font-semibold ${R.text} opacity-60 group-hover:opacity-100 transition-opacity mt-1`,children:["View ",e.jsx(vs,{size:8})]})]}),e.jsx("div",{className:`text-xs font-semibold ${R.text} uppercase tracking-wide mb-3`,children:D}),e.jsx("div",{className:"w-full h-1.5 bg-white/60 dark:bg-black/20 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-700",style:{width:`${O}%`,backgroundColor:Y}})}),e.jsxs("div",{className:`text-[11px] font-semibold ${R.text} mt-1.5 opacity-70`,children:[O,"% of total"]})]},D)})})]})]})})},tO=({data:t})=>{const{t:a}=ca(),r=(t==null?void 0:t.labels)||[],s=(t==null?void 0:t.datasets)||[];if(!s.length)return e.jsx("div",{className:"text-center text-gray-400 py-4 text-sm",children:a("dashboard.noDataAvailable")});const i=s.flatMap(N=>N.values||[]),c=Math.max(...i,1),d=240,m=Math.max(800,r.length*100),h=Math.min(120,(m-100)/r.length),g=4,p=s.length,b=Math.max(12,(h-g*(p+1))/p),j={"Completed On Time":"#6366F1","Completed Within SLA":"#3B82F6","Delay In Completion":"#8B5CF6",Pending:"#A855F7",Overdue:"#EC4899",Cancelled:"#0EA5E9",Open:"#F59E0B","Work In Progress":"#3B82F6","Pending Review":"#E11D48",Completed:"#10B981",Closed:"#10B981",Rejected:"#EF4444"},_=(N,k)=>{for(const[C,D]of Object.entries(j))if(N.toLowerCase().includes(C.toLowerCase()))return D;return Pi(p)[k]};return e.jsxs("div",{className:"relative w-full overflow-x-auto",children:[e.jsxs("svg",{width:"100%",height:d+40,viewBox:`0 0 ${m} ${d+40}`,className:"w-full",preserveAspectRatio:"xMidYMid meet",children:[e.jsx("defs",{children:s.map((N,k)=>{const C=_(N.name||"",k);return e.jsxs("linearGradient",{id:`groupedBarGradient${k}`,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[e.jsx("stop",{offset:"0%",style:{stopColor:C,stopOpacity:.9}}),e.jsx("stop",{offset:"100%",style:{stopColor:C,stopOpacity:.7}})]},k)})}),[0,.25,.5,.75,1].map((N,k)=>e.jsx("line",{x1:"60",y1:d-N*d,x2:m-20,y2:d-N*d,stroke:"#E5E7EB",strokeWidth:"1"},k)),[0,.25,.5,.75,1].map((N,k)=>e.jsx("text",{x:"45",y:d-N*d+4,textAnchor:"end",className:"text-xs fill-gray-400",children:(c*N).toFixed(N===0?0:c<5?1:0)},k)),r.map((N,k)=>{const C=80+k*h;return e.jsxs("g",{children:[s.map((D,T)=>{var U;const E=((U=D.values)==null?void 0:U[k])||0,O=E/c*d,R=C+g+T*(b+g),Y=d-O,P=_(D.name||"",T);return e.jsx("g",{children:e.jsx("rect",{x:R,y:Y,width:b,height:O,fill:P,rx:"3",ry:"3",className:"hover:opacity-80 cursor-pointer transition-opacity",children:e.jsx("title",{children:`${N||"Unknown"} — ${D.name||"Series"}: ${E}`})})},T)}),e.jsx("text",{x:C+h/2,y:d+15,textAnchor:"middle",className:"text-xs fill-gray-600 dark:fill-gray-400",children:N&&N.length>12?N.substring(0,10)+"...":N||"null"})]},k)})]}),e.jsx("div",{className:"flex flex-wrap items-center justify-center gap-2 mt-2 pt-2 border-t border-gray-200 dark:border-gray-700",children:s.map((N,k)=>{const C=_(N.name||"",k);return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded",style:{backgroundColor:C}}),e.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:N.name&&N.name.length>20?N.name.substring(0,18)+"...":N.name||`Series ${k+1}`})]},k)})})]})},aO=({data:t})=>{const{t:a}=ca(),r=(t==null?void 0:t.labels)||[],s=(t==null?void 0:t.datasets)||[];if(!s.length)return e.jsx("div",{className:"text-center text-gray-400 py-4 text-sm",children:a("dashboard.noDataAvailable")});const c=Array.isArray(t==null?void 0:t.totals)&&t.totals.length===r.length?t.totals:r.map((g,p)=>s.reduce((b,j)=>{var _;return b+(((_=j.values)==null?void 0:_[p])||0)},0)),d=Math.max(...c,1),m={total:"#6366F1",completed:"#10B981",in_progress:"#3B82F6",open:"#F59E0B"},h=(g,p)=>{for(const[b,j]of Object.entries(m))if(g.toLowerCase().includes(b))return j;return Pi(s.length)[p]};return e.jsxs("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:[r.map((g,p)=>{const b=c[p],j=s.map(_=>{var k;const N=((k=_.values)==null?void 0:k[p])||0;return N>0?`${(_.name||"").replace(/_/g," ")}: ${N}`:null}).filter(Boolean).join(" • ");return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-32 text-xs text-gray-700 dark:text-gray-200 truncate",title:g,children:g}),e.jsx("div",{className:"flex-1 h-4 bg-gray-100 dark:bg-gray-700 rounded-full overflow-hidden flex cursor-default",title:`${j} • Total: ${b}`,children:s.map((_,N)=>{var C;const k=((C=_.values)==null?void 0:C[p])||0;return k?e.jsx("div",{className:"h-full",style:{width:`${k/d*100}%`,backgroundColor:h(_.name||"",N)}},_.name):null})}),e.jsx("div",{className:"w-10 text-xs text-right text-gray-500 dark:text-gray-400",children:b})]},p)}),e.jsx("div",{className:"flex flex-wrap items-center gap-3 pt-2 border-t border-gray-200 dark:border-gray-700 mt-2",children:s.map((g,p)=>e.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-gray-600 dark:text-gray-300",children:[e.jsx("span",{className:"inline-block w-3 h-3 rounded-sm",style:{backgroundColor:h(g.name||"",p)}}),e.jsx("span",{children:(g.name||`Series ${p+1}`).replace(/_/g," ")})]},g.name||p))})]})},rO=({title:t,data:a,onOpenReport:r})=>{var m;const{t:s}=ca(),[i,c]=y.useState(!1),d=pa.useMemo(()=>{var h,g;return(g=(h=a==null?void 0:a.datasets)==null?void 0:h[0])!=null&&g.values?a.datasets[0].values.reduce((p,b)=>p+b,0):0},[a]);return y.useEffect(()=>{const h=()=>c(!1);if(i)return document.addEventListener("click",h),()=>document.removeEventListener("click",h)},[i]),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all p-5 border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:r,className:"w-10 h-10 bg-indigo-50 dark:bg-indigo-900/20 rounded-xl flex items-center justify-center hover:bg-indigo-100 transition-colors group",children:e.jsx(k1,{className:"text-indigo-600 text-lg group-hover:scale-110 transition-transform"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:t}),e.jsxs("p",{className:"text-xs text-gray-400",children:["Total: ",e.jsxs("span",{className:"font-semibold text-indigo-600",children:[d.toFixed(1)," hrs"]})]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:h=>{h.stopPropagation(),c(!i)},className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",children:e.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z"})})}),i&&e.jsx("div",{className:"absolute right-0 top-full mt-1 w-48 bg-white dark:bg-gray-800 rounded-xl shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50",children:e.jsxs("button",{onClick:h=>{h.stopPropagation(),c(!1),r==null||r()},className:"w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[e.jsx(vs,{className:"text-gray-400",size:12}),s("dashboard.viewFullReport")]})})]})]}),!a||!((m=a.datasets)!=null&&m.length)?e.jsx("div",{className:"h-64 flex items-center justify-center text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(k1,{className:"text-4xl mx-auto mb-2 opacity-30"}),e.jsx("div",{className:"text-sm",children:"Loading..."})]})}):e.jsx(uk,{data:a,valueLabel:"hrs"})]})},sO=({title:t,data:a,onOpenReport:r})=>{var m;const{t:s}=ca(),[i,c]=y.useState(!1),d=pa.useMemo(()=>{if(!(a!=null&&a.datasets))return{completed:0,inProgress:0,open:0};const h={completed:0,inProgress:0,open:0};return a.datasets.forEach(g=>{var b;const p=((b=g.values)==null?void 0:b.reduce((j,_)=>j+_,0))||0;g.name==="completed"?h.completed=p:g.name==="in_progress"?h.inProgress=p:g.name==="open"&&(h.open=p)}),h},[a]);return y.useEffect(()=>{const h=()=>c(!1);if(i)return document.addEventListener("click",h),()=>document.removeEventListener("click",h)},[i]),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all p-5 border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:r,className:"w-10 h-10 bg-purple-50 dark:bg-purple-900/20 rounded-xl flex items-center justify-center hover:bg-purple-100 transition-colors group",children:e.jsx(hh,{className:"text-purple-600 text-lg group-hover:scale-110 transition-transform"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:t}),e.jsxs("div",{className:"flex items-center gap-2 text-xs mt-0.5",children:[e.jsxs("span",{className:"text-emerald-600 font-semibold",children:[d.completed," done"]}),e.jsx("span",{className:"text-gray-300",children:"•"}),e.jsxs("span",{className:"text-blue-600 font-semibold",children:[d.inProgress," wip"]}),e.jsx("span",{className:"text-gray-300",children:"•"}),e.jsxs("span",{className:"text-amber-600 font-semibold",children:[d.open," open"]})]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:h=>{h.stopPropagation(),c(!i)},className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",children:e.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z"})})}),i&&e.jsx("div",{className:"absolute right-0 top-full mt-1 w-48 bg-white dark:bg-gray-800 rounded-xl shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50",children:e.jsxs("button",{onClick:h=>{h.stopPropagation(),c(!1),r==null||r()},className:"w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[e.jsx(vs,{className:"text-gray-400",size:12}),s("dashboard.viewFullReport")]})})]})]}),!a||!((m=a.datasets)!=null&&m.length)?e.jsx("div",{className:"h-64 flex items-center justify-center text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(hh,{className:"text-4xl mx-auto mb-2 opacity-30"}),e.jsx("div",{className:"text-sm",children:"Loading..."})]})}):e.jsx(aO,{data:a})]})},uk=({data:t,valueLabel:a=""})=>{var d,m;const{t:r}=ca(),s=(t==null?void 0:t.labels)||[],i=((m=(d=t==null?void 0:t.datasets)==null?void 0:d[0])==null?void 0:m.values)||[];if(!i.length)return e.jsx("div",{className:"text-center text-gray-400 py-4 text-sm",children:r("dashboard.noDataAvailable")});const c=Math.max(...i,1);return e.jsx("div",{className:"space-y-3",children:s.map((h,g)=>{const p=i[g]||0,b=p/c*100;return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-28 text-xs text-gray-600 dark:text-gray-400 truncate text-right",title:h||"(No Type)",children:h||"(No Type)"}),e.jsx("div",{className:"flex-1 h-6 bg-gray-100 dark:bg-gray-700 rounded-lg overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-indigo-500 to-purple-500 rounded-lg transition-all duration-500",style:{width:`${b}%`}})}),e.jsxs("div",{className:"w-12 text-xs font-semibold text-gray-800 dark:text-gray-200 text-right",children:[typeof p=="number"?Number.isInteger(p)?p:p.toFixed(1):p,a?` ${a}`:""]})]},g)})})},nO=({data:t})=>{var c,d;const{t:a}=ca(),r=(t==null?void 0:t.labels)||[],s=((d=(c=t==null?void 0:t.datasets)==null?void 0:c[0])==null?void 0:d.values)||[];if(!s.length)return e.jsx("div",{className:"text-center text-gray-400 py-4 text-sm",children:a("dashboard.noDataAvailable")});const i=Math.max(...s,1);return e.jsx("div",{className:"space-y-3",children:r.map((m,h)=>{const g=s[h]||0,p=g/i*100;return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-32 text-xs text-gray-600 dark:text-gray-400 truncate text-right",title:m||"(No Type)",children:m||"(No Type)"}),e.jsx("div",{className:"flex-1 h-6 bg-gray-100 dark:bg-gray-700 rounded-lg overflow-hidden",children:e.jsx("div",{className:"h-full rounded-lg transition-all duration-500",style:{width:`${p}%`,background:"linear-gradient(to right, #EF4444, #F87171)"}})}),e.jsx("div",{className:"w-10 text-xs font-semibold text-red-600 dark:text-red-400 text-right",children:typeof g=="number"?Number.isInteger(g)?g:g.toFixed(1):g})]},h)})})},mk=({data:t})=>{var b,j,_,N;const a=(t==null?void 0:t.labels)||[],r=((j=(b=t==null?void 0:t.datasets)==null?void 0:b[0])==null?void 0:j.values)||[],s=a.some(k=>k.toLowerCase().includes("up time")||k.toLowerCase().includes("down time")||k.toLowerCase().includes("uptime")||k.toLowerCase().includes("downtime"));let i=[];if(s)i=a.map(k=>{const C=k.toLowerCase();return C.includes("up time")||C.includes("uptime")?"#6366F1":"#8B5CF6"});else{const k=(N=(_=t==null?void 0:t.datasets)==null?void 0:_[0])==null?void 0:N.colors;i=k&&k.length===r.length?k:Pi(r.length)}const c=r.reduce((k,C)=>k+C,0),d=100,m=d+10,h=d+10;let g=0;const p=r.map((k,C)=>{const D=g/c*2*Math.PI-Math.PI/2;g+=k;const T=g/c*2*Math.PI-Math.PI/2,E=T-D>Math.PI?1:0,O=m+d*Math.cos(D),R=h+d*Math.sin(D),Y=m+d*Math.cos(T),P=h+d*Math.sin(T);return{path:`M ${m} ${h} L ${O} ${R} A ${d} ${d} 0 ${E} 1 ${Y} ${P} Z`,color:i[C],label:a[C],value:k,percentage:(k/c*100).toFixed(1)}});return e.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-around",children:[e.jsx("svg",{width:m*2,height:h*2,viewBox:`0 0 ${m*2} ${h*2}`,className:"max-w-xs",children:p.map((k,C)=>e.jsx("path",{d:k.path,fill:k.color,className:"hover:opacity-80 transition-opacity cursor-pointer drop-shadow-sm",children:e.jsx("title",{children:`${k.label}: ${k.value} (${k.percentage}%)`})},C))}),e.jsx("div",{className:"flex flex-col gap-2.5 mt-4 md:mt-0",children:p.map((k,C)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:k.color}}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:k.label}),e.jsx("span",{className:"text-sm font-bold text-gray-900 dark:text-white ml-auto pl-4",children:k.value})]},C))})]})},u_=({title:t,data:a,onOpenReport:r,showSummary:s})=>{const{t:i}=ca(),c=(a==null?void 0:a.labels)||[],d=(a==null?void 0:a.datasets)||[],m=c.length,h=d.reduce((g,p)=>g+(p.values||[]).reduce((b,j)=>b+j,0),0);return e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all p-4 border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-white",children:t}),e.jsx("button",{onClick:r,className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:i("dashboard.viewFullReport"),children:e.jsx(vs,{className:"w-3.5 h-3.5 text-gray-400"})})]}),!a||!d.length?e.jsx("div",{className:"h-48 flex items-center justify-center text-gray-400",children:e.jsx("div",{className:"text-xs",children:"No chart data available"})}):e.jsxs(e.Fragment,{children:[e.jsx(tO,{data:a}),s&&m>0&&e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-3 pt-3 border-t border-gray-100 dark:border-gray-700",children:[e.jsxs("div",{className:"bg-indigo-50 dark:bg-indigo-900/20 rounded-xl px-3 py-2 text-center",children:[e.jsx("div",{className:"text-lg font-bold text-indigo-600 dark:text-indigo-400",children:m}),e.jsx("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 uppercase tracking-wide font-semibold",children:"Assignees"})]}),e.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 rounded-xl px-3 py-2 text-center",children:[e.jsx("div",{className:"text-lg font-bold text-purple-600 dark:text-purple-400",children:h}),e.jsx("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 uppercase tracking-wide font-semibold",children:"Tasks"})]})]})]})]})},iO=({isOpen:t,onClose:a,title:r,data:s,redirectContext:i})=>{const{t:c}=ca();if(!t)return null;const d=(s==null?void 0:s.labels)||[],m=(s==null?void 0:s.datasets)||[],h=(s==null?void 0:s.hideFooterTotal)===!0,g=_=>{window.location.href=_},p=_=>i?i==="wo_status"?`/asm_app/work-orders?status=${encodeURIComponent(_)}`:i==="wo_type"?`/asm_app/work-orders?work_order_type=${encodeURIComponent(_)}&page=1`:null:null,b=(_,N)=>i?i==="wo_status"?`/asm_app/work-orders?status=${encodeURIComponent(_)}`:i==="wo_type"?`/asm_app/work-orders?work_order_type=${encodeURIComponent(_)}&page=1&status=${encodeURIComponent(N)}`:null:null,j=!!i;return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl max-w-4xl w-full max-h-[90vh] overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-indigo-500 to-purple-600 px-6 py-4 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:r}),j&&e.jsx("p",{className:"text-indigo-200 text-xs mt-0.5",children:"Click a row or value to view filtered work orders"})]}),e.jsx("button",{onClick:a,className:"text-white/80 hover:text-white transition-colors p-1 rounded-lg hover:bg-white/20",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"p-6 overflow-auto max-h-[calc(90vh-120px)]",children:d.length===0||m.length===0?e.jsx("div",{className:"text-center text-gray-400 py-8",children:c("dashboard.noDataAvailable")}):e.jsxs("table",{className:"w-full text-sm border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:[e.jsx("th",{className:"text-left py-3 px-4 font-semibold text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-900/50 rounded-tl-lg",children:i==="wo_type"?"WO Type":i==="wo_status"?"Status":"Label"}),m.map((_,N)=>e.jsx("th",{className:"text-right py-3 px-4 font-semibold text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-900/50 last:rounded-tr-lg",children:(_.name||`Series ${N+1}`).replace(/_/g," ")},N))]})}),e.jsx("tbody",{children:d.map((_,N)=>{const k=p(_);return e.jsxs("tr",{className:`border-b border-gray-100 dark:border-gray-700/50 transition-colors ${j?"hover:bg-indigo-50 dark:hover:bg-indigo-900/20":"hover:bg-gray-50 dark:hover:bg-gray-700/30"}`,children:[e.jsx("td",{className:`py-2.5 px-4 text-gray-800 dark:text-gray-200 font-medium ${k?"cursor-pointer text-indigo-700 dark:text-indigo-300 hover:underline":""}`,onClick:k?()=>g(k):void 0,title:k?`View work orders for ${_}`:void 0,children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[_||"Unknown",k&&e.jsx(vs,{size:9,className:"opacity-50 flex-shrink-0"})]})}),m.map((C,D)=>{var O,R;const T=(R=(O=C.values)==null?void 0:O[N])!=null?R:0,E=b(_,C.name||"");return e.jsx("td",{className:`py-2.5 px-4 text-right tabular-nums ${E?"cursor-pointer text-indigo-600 dark:text-indigo-400 font-semibold hover:text-indigo-800 dark:hover:text-indigo-200 hover:underline":"text-gray-600 dark:text-gray-300"}`,onClick:E?()=>g(E):void 0,title:E?`View ${C.name} work orders for ${_}`:void 0,children:T},D)})]},N)})}),!h&&e.jsx("tfoot",{children:e.jsxs("tr",{className:"border-t-2 border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-900/50",children:[e.jsx("td",{className:"py-3 px-4 font-bold text-gray-800 dark:text-gray-200",children:"Total"}),m.map((_,N)=>{const k=(_.values||[]).reduce((C,D)=>C+D,0);return e.jsx("td",{className:"py-3 px-4 text-right font-bold text-gray-800 dark:text-gray-200 tabular-nums",children:typeof k=="number"&&k%1!==0?k.toFixed(1):k},N)})]})})]})})]})})},oO=({title:t,data:a,onOpenReport:r})=>{var m;const{t:s}=ca(),[i,c]=y.useState(!1),d=pa.useMemo(()=>{var h,g,p,b;return(b=(p=(g=(h=a==null?void 0:a.datasets)==null?void 0:h[0])==null?void 0:g.values)==null?void 0:p.reduce((j,_)=>j+_,0))!=null?b:0},[a]);return y.useEffect(()=>{const h=()=>c(!1);if(i)return document.addEventListener("click",h),()=>document.removeEventListener("click",h)},[i]),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all p-5 border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:r,className:"w-10 h-10 bg-emerald-50 dark:bg-emerald-900/20 rounded-xl flex items-center justify-center hover:bg-emerald-100 transition-colors group",children:e.jsx(ea,{className:"text-emerald-600 text-lg group-hover:scale-110 transition-transform"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:t}),e.jsxs("p",{className:"text-xs text-gray-400",children:["Total: ",e.jsx("span",{className:"font-semibold text-emerald-600",children:d})]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:h=>{h.stopPropagation(),c(!i)},className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",children:e.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z"})})}),i&&e.jsx("div",{className:"absolute right-0 top-full mt-1 w-48 bg-white dark:bg-gray-800 rounded-xl shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50",children:e.jsxs("button",{onClick:h=>{h.stopPropagation(),c(!1),r==null||r()},className:"w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[e.jsx(vs,{className:"text-gray-400",size:12}),s("dashboard.viewFullReport","View Full Report")]})})]})]}),a===null?e.jsx("div",{className:"h-64 flex items-center justify-center text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ea,{className:"text-4xl mx-auto mb-2 opacity-20"}),e.jsx("div",{className:"text-sm",children:"Loading..."})]})}):(m=a.datasets)!=null&&m.length?e.jsx(uk,{data:a,valueLabel:""}):e.jsx("div",{className:"h-64 flex items-center justify-center text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ea,{className:"text-4xl mx-auto mb-2 opacity-10"}),e.jsx("div",{className:"text-sm",children:"No inspection data"})]})})]})},lO=({title:t,data:a,onOpenReport:r})=>{var m;const{t:s}=ca(),[i,c]=y.useState(!1),d=pa.useMemo(()=>{var h,g,p;return(g=(h=a==null?void 0:a.datasets)==null?void 0:h[0])!=null&&g.values?a.datasets[0].values.reduce((b,j)=>b+j,0):(p=a==null?void 0:a.totalRejected)!=null?p:0},[a]);return y.useEffect(()=>{const h=()=>c(!1);if(i)return document.addEventListener("click",h),()=>document.removeEventListener("click",h)},[i]),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all p-5 border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:r,className:"w-10 h-10 bg-red-50 dark:bg-red-900/20 rounded-xl flex items-center justify-center hover:bg-red-100 transition-colors group",children:e.jsx(fa,{className:"text-red-500 text-lg group-hover:scale-110 transition-transform"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:t}),e.jsxs("p",{className:"text-xs text-gray-400",children:["Total: ",e.jsx("span",{className:"font-semibold text-red-600",children:d})]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:h=>{h.stopPropagation(),c(!i)},className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",children:e.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z"})})}),i&&e.jsx("div",{className:"absolute right-0 top-full mt-1 w-48 bg-white dark:bg-gray-800 rounded-xl shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50",children:e.jsxs("button",{onClick:h=>{h.stopPropagation(),c(!1),r==null||r()},className:"w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[e.jsx(vs,{className:"text-gray-400",size:12}),s("dashboard.viewFullReport","View Full Report")]})})]})]}),a===null?e.jsx("div",{className:"h-64 flex items-center justify-center text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(fa,{className:"text-4xl mx-auto mb-2 opacity-20"}),e.jsx("div",{className:"text-sm",children:"Loading..."})]})}):(m=a.datasets)!=null&&m.length?e.jsx(nO,{data:a}):e.jsx("div",{className:"h-64 flex items-center justify-center text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(fa,{className:"text-4xl mx-auto mb-2 opacity-10"}),e.jsx("div",{className:"text-sm",children:"No rejection data"})]})})]})},cO=({isOpen:t,onClose:a,permittedIssueTypes:r,isAdmin:s,defaultWorkOrderType:i})=>{var ee,te;const{t:c}=ca(),[d,m]=y.useState(null),[h,g]=y.useState(!1),[p,b]=y.useState(""),[j,_]=y.useState(i||""),[N,k]=y.useState(""),[C,D]=y.useState(""),[T,E]=y.useState([]),[O,R]=y.useState([]);y.useEffect(()=>{_(i||"")},[i]),y.useEffect(()=>{if(!t)return;Q(null,null,function*(){try{const[I,oe]=yield Promise.all([fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"}),fetch('/api/resource/Department?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})]),ae=yield I.json(),F=yield oe.json();ae.data&&E(ae.data.map(M=>M.name)),F.data&&R(F.data.map(M=>M.name))}catch(I){console.error(I)}})},[t]);const Y=s?T:r;if(y.useEffect(()=>{if(!t)return;Q(null,null,function*(){g(!0);try{const I={};!s&&r.length>0?I.work_order_type=r.length===1?r[0]:r:j&&(I.work_order_type=j),p&&(I.department=p),N&&(I.from_date=N),C&&(I.to_date=C);const ae=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"Inspection Linked Work Orders Summary",filters:I,ignore_prepared_report:1})})).json();m(ae.message||null)}catch(I){console.error(I)}finally{g(!1)}})},[t,j,p,N,C,r,s]),!t)return null;const P=(d==null?void 0:d.columns)||[],U=((d==null?void 0:d.result)||[]).filter(W=>W&&typeof W=="object"),J=U.filter(W=>!W.is_total_row),ne=(d==null?void 0:d.report_summary)||[],ye=(te=(ee=ne.find(W=>{var I;return(I=W.label)==null?void 0:I.toLowerCase().includes("total inspection")}))==null?void 0:ee.value)!=null?te:J.reduce((W,I)=>{const oe=P.find(ae=>{var F,M;return((F=ae.label)==null?void 0:F.toLowerCase().includes("total inspection"))||((M=ae.fieldname)==null?void 0:M.toLowerCase().includes("total_inspection"))});return W+(oe&&parseFloat(I[oe.fieldname])||0)},0),he=ne.length>0?ne.map(W=>({label:W.label,value:W.value,color:W.color||"blue"})):[{label:"Total Inspections",value:ye,color:"blue"}],ce={blue:"text-blue-600 dark:text-blue-400",teal:"text-teal-600 dark:text-teal-400",green:"text-emerald-600 dark:text-emerald-400",red:"text-red-600 dark:text-red-400",orange:"text-orange-600 dark:text-orange-400",purple:"text-purple-600 dark:text-purple-400"},se=p||N||C||j&&(s||r.length===0);return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl max-w-5xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"bg-gradient-to-r from-emerald-500 to-teal-600 px-6 py-4 flex items-center justify-between flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ea,{className:"text-white text-xl"}),e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Inspection Linked Work Orders Summary"})]}),e.jsx("button",{onClick:a,className:"text-white/80 hover:text-white p-1 rounded-lg hover:bg-white/20 transition-colors",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"px-6 py-3 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/30 flex-shrink-0 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"WO Type"}),e.jsxs("select",{value:j,onChange:W=>_(W.target.value),disabled:!s&&r.length>0,className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white min-w-[200px] disabled:opacity-60",children:[e.jsx("option",{value:"",children:"All Types"}),Y.map(W=>e.jsx("option",{value:W,children:W},W))]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"From Date"}),e.jsx("input",{type:"date",value:N,onChange:W=>k(W.target.value),className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"To Date"}),e.jsx("input",{type:"date",value:C,onChange:W=>D(W.target.value),className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"Department"}),e.jsxs("select",{value:p,onChange:W=>b(W.target.value),className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white min-w-[300px]",children:[e.jsx("option",{value:"",children:"All Departments"}),O.map(W=>e.jsx("option",{value:W,children:W},W))]})]}),se&&e.jsxs("button",{onClick:()=>{b(""),k(""),D(""),(s||r.length===0)&&_("")},className:"text-xs text-red-500 hover:text-red-700 flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-red-50 transition-colors",children:[e.jsx(wt,{size:10})," Clear"]})]})]}),!h&&he.length>0&&e.jsx("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40 flex-shrink-0",children:e.jsx("div",{className:`grid gap-6 ${he.length===1?"grid-cols-1":he.length===2?"grid-cols-2":"grid-cols-3"}`,children:he.map((W,I)=>e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1",children:W.label}),e.jsx("div",{className:`text-2xl font-bold ${ce[W.color]||"text-blue-600"}`,children:W.value})]},I))})}),e.jsx("div",{className:"p-6 overflow-auto flex-1",children:h?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-emerald-600"})}):U.length===0?e.jsx("div",{className:"text-center text-gray-400 py-16",children:"No data available"}):e.jsxs("table",{className:"w-full text-sm border-collapse",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:P.map((W,I)=>e.jsx("th",{className:`py-3 px-4 font-semibold text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-900/50 ${I===0?"text-left":"text-right"}`,children:W.label||W.fieldname},I))})}),e.jsx("tbody",{children:U.map((W,I)=>e.jsx("tr",{className:"border-b border-gray-100 dark:border-gray-700/50 hover:bg-gray-50 dark:hover:bg-gray-700/30 transition-colors",children:P.map((oe,ae)=>{var F;return e.jsx("td",{className:`py-2.5 px-4 ${ae===0?"text-gray-800 dark:text-gray-200 font-medium":"text-right text-gray-600 dark:text-gray-300 tabular-nums"}`,children:(F=W[oe.fieldname])!=null?F:"—"},ae)})},I))})]})})]})})},dO=({isOpen:t,onClose:a,permittedIssueTypes:r,isAdmin:s,defaultWorkOrderType:i})=>{const[c,d]=y.useState(null),[m,h]=y.useState(!1),[g,p]=y.useState(""),[b,j]=y.useState(""),[_,N]=y.useState(i||""),[k,C]=y.useState(""),[D,T]=y.useState([]),[E,O]=y.useState([]);y.useEffect(()=>{N(i||"")},[i]),y.useEffect(()=>{if(!t)return;Q(null,null,function*(){try{const[oe,ae]=yield Promise.all([fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"}),fetch('/api/resource/Department?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})]),F=yield oe.json(),M=yield ae.json();F.data&&T(F.data.map(B=>B.name)),M.data&&O(M.data.map(B=>B.name))}catch(oe){console.error(oe)}})},[t]);const R=s?D:r;if(y.useEffect(()=>{if(!t)return;Q(null,null,function*(){h(!0);try{const oe={};!s&&r.length>0?oe.work_order_type=r.length===1?r[0]:r:_&&(oe.work_order_type=_),k&&(oe.department=k),g&&(oe.from_date=g),b&&(oe.to_date=b);const F=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"WO Rejection Summary",filters:oe,ignore_prepared_report:1})})).json();d(F.message||null)}catch(oe){console.error(oe)}finally{h(!1)}})},[t,_,k,g,b,r,s]),!t)return null;const Y=(c==null?void 0:c.columns)||[],P=((c==null?void 0:c.result)||[]).filter(I=>I&&typeof I=="object"&&I.custom_delete_status!=="Deleted"),U=P.filter(I=>!I.is_total_row),J=(c==null?void 0:c.report_summary)||[];((I,oe)=>{var F,M;const ae=I.find(B=>(B==null?void 0:B.fieldname)&&(B.fieldname.toLowerCase().includes("work_order_type")||B.fieldname.toLowerCase().includes("wo_type")||B.fieldname.toLowerCase()==="type"));return ae?ae.fieldname:(F=I[1])!=null&&F.fieldname?I[1].fieldname:((M=I[0])==null?void 0:M.fieldname)||""})(Y);const ye=Y.find(I=>{const oe=((I.label||"")+(I.fieldname||"")).toLowerCase();return oe.includes("total_work")||oe.includes("total work")}),he=Y.find(I=>{const oe=((I.label||"")+(I.fieldname||"")).toLowerCase();return oe.includes("total_rejected")||oe.includes("total rejected")||oe.includes("rejected")&&!oe.includes("%")}),ce=ye?U.reduce((I,oe)=>I+(parseFloat(oe[ye.fieldname])||0),0):null,se=he?U.reduce((I,oe)=>I+(parseFloat(oe[he.fieldname])||0),0):null,ee=ce&&se&&ce>0?(se/ce*100).toFixed(2)+"%":null,te=J.length>0?J.map(I=>({label:I.label,value:I.value,color:I.color||"blue"})):[...ce!==null?[{label:"Total Work Orders",value:ce,color:"blue"}]:[],...se!==null?[{label:"Total Rejected",value:se,color:"red"}]:[],...ee!==null?[{label:"Rejected %",value:ee,color:"orange"}]:[]],W={blue:"text-blue-600 dark:text-blue-400",red:"text-red-600 dark:text-red-400",orange:"text-orange-600 dark:text-orange-400",green:"text-emerald-600 dark:text-emerald-400",purple:"text-purple-600 dark:text-purple-400"};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl max-w-5xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"bg-gradient-to-r from-red-500 to-rose-600 px-6 py-4 flex items-center justify-between flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fa,{className:"text-white text-xl"}),e.jsx("h3",{className:"text-lg font-semibold text-white",children:"WO Rejection Summary"})]}),e.jsx("button",{onClick:a,className:"text-white/80 hover:text-white p-1 rounded-lg hover:bg-white/20 transition-colors",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"px-6 py-3 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/30 flex-shrink-0 flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"From Date"}),e.jsx("input",{type:"date",value:g,onChange:I=>p(I.target.value),className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-red-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"To Date"}),e.jsx("input",{type:"date",value:b,onChange:I=>j(I.target.value),className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-red-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"WO Type"}),e.jsxs("select",{value:_,onChange:I=>N(I.target.value),disabled:!s&&r.length>0,className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-red-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white min-w-[160px] disabled:opacity-60",children:[e.jsx("option",{value:"",children:"All Types"}),R.map(I=>e.jsx("option",{value:I,children:I},I))]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"Department"}),e.jsxs("select",{value:k,onChange:I=>C(I.target.value),className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-red-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white min-w-[160px]",children:[e.jsx("option",{value:"",children:"All Departments"}),E.map(I=>e.jsx("option",{value:I,children:I},I))]})]}),(g||b||_||k)&&e.jsxs("button",{onClick:()=>{p(""),j(""),N(""),C("")},className:"text-xs text-red-500 hover:text-red-700 flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-red-50 transition-colors",children:[e.jsx(wt,{size:10})," Clear"]})]}),!m&&te.length>0&&e.jsx("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40 flex-shrink-0",children:e.jsx("div",{className:`grid gap-6 ${te.length===1?"grid-cols-1":te.length===2?"grid-cols-2":"grid-cols-3"}`,children:te.map((I,oe)=>e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1",children:I.label}),e.jsx("div",{className:`text-2xl font-bold ${W[I.color]||"text-blue-600"}`,children:I.value})]},oe))})}),e.jsx("div",{className:"p-6 overflow-auto flex-1",children:m?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-red-600"})}):P.length===0?e.jsx("div",{className:"text-center text-gray-400 py-16",children:"No data available"}):(()=>{const I=Y.find(M=>{const B=((M.label||"")+(M.fieldname||"")).toLowerCase();return B.includes("work_order_type")||B.includes("wo_type")||B.includes("type")}),oe=Y.find(M=>{const B=((M.label||"")+(M.fieldname||"")).toLowerCase();return B.includes("department")||B.includes("dept")}),ae=Y.find(M=>{const B=((M.label||"")+(M.fieldname||"")).toLowerCase();return B.includes("total_rejected")||B.includes("total rejected")||B.includes("rejected")&&!B.includes("%")}),F=M=>{const B=new URLSearchParams,X=I&&M[I.fieldname]||"",K=oe&&M[oe.fieldname]||"";return X&&B.set("work_order_type",X),B.set("page","1"),K&&B.set("department",K),B.set("status","Rejected"),`/asm_app/work-orders?${B.toString()}`};return e.jsxs("table",{className:"w-full text-sm border-collapse",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Y.map((M,B)=>e.jsxs("th",{className:`py-3 px-4 font-semibold text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-900/50 ${B===0?"text-left rounded-tl-lg":"text-right"} ${B===Y.length-1?"rounded-tr-lg":""}`,children:[M.label||M.fieldname,ae&&M.fieldname===ae.fieldname&&e.jsx("span",{className:"ml-1 text-[9px] text-red-400 font-normal normal-case",children:"(click to view)"})]},B))})}),e.jsx("tbody",{children:P.map((M,B)=>e.jsx("tr",{className:"border-b border-gray-100 dark:border-gray-700/50 hover:bg-red-50/40 dark:hover:bg-red-900/10 transition-colors",children:Y.map((X,K)=>{var Ne;const we=ae&&X.fieldname===ae.fieldname,be=(Ne=M[X.fieldname])!=null?Ne:"—",ke=we&&parseFloat(M[X.fieldname])||0,Me=we&&ke>0,z=Me?F(M):null;return e.jsx("td",{className:`py-2.5 px-4 ${K===0?"text-gray-800 dark:text-gray-200 font-medium text-left":"text-right tabular-nums"} ${Me?"cursor-pointer text-red-600 dark:text-red-400 font-bold hover:text-red-800 dark:hover:text-red-200 hover:underline":"text-gray-600 dark:text-gray-300"}`,onClick:Me?()=>{window.location.href=z}:void 0,title:Me?"View rejected work orders":void 0,children:Me?e.jsxs("span",{className:"flex items-center justify-end gap-1.5",children:[be,e.jsx(vs,{size:9,className:"opacity-60 flex-shrink-0"})]}):be},K)})},B))})]})})()})]})})},uO=({data:t,onOpenReport:a})=>{var j,_,N;const[r,s]=y.useState(!1);y.useEffect(()=>{const k=()=>s(!1);if(r)return document.addEventListener("click",k),()=>document.removeEventListener("click",k)},[r]);const i=(t==null?void 0:t.labels)||[],c=((_=(j=t==null?void 0:t.datasets)==null?void 0:j[0])==null?void 0:_.values)||[],d=i.reduce((k,C,D)=>{var T;return Wo(C)||(k.labels.push(C),k.values.push((T=c[D])!=null?T:0)),k},{labels:[],values:[]}),m=d.labels,h=d.values,g=(N=t==null?void 0:t.overallAvg)!=null?N:0,p=Pi(m.length),b=Math.max(...h,.001);return e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm hover:shadow-md transition-all p-5 border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:a,className:"w-10 h-10 bg-pink-50 dark:bg-pink-900/20 rounded-xl flex items-center justify-center hover:bg-pink-100 transition-colors group",children:e.jsx(wc,{className:"text-pink-600 text-base group-hover:scale-110 transition-transform"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Time to Repair"}),e.jsxs("p",{className:"text-xs text-gray-400",children:["Overall Avg: ",e.jsxs("span",{className:"font-bold text-pink-600 dark:text-pink-400",children:[g.toFixed(3)," hrs"]})]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:k=>{k.stopPropagation(),s(!r)},className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",children:e.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z"})})}),r&&e.jsx("div",{className:"absolute right-0 top-full mt-1 w-48 bg-white dark:bg-gray-800 rounded-xl shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50",children:e.jsxs("button",{onClick:k=>{k.stopPropagation(),s(!1),a==null||a()},className:"w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[e.jsx(vs,{className:"text-gray-400",size:12})," View Full Report"]})})]})]}),e.jsxs("div",{className:"bg-gradient-to-r from-pink-50 to-rose-50 dark:from-pink-900/20 dark:to-rose-900/20 rounded-xl px-4 py-3 mb-4 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-semibold text-pink-700 dark:text-pink-300",children:"Overall Avg Time to Repair"}),e.jsxs("span",{className:"text-2xl font-bold text-pink-600 dark:text-pink-400",children:[g.toFixed(3)," ",e.jsx("span",{className:"text-sm font-normal",children:"hrs"})]})]}),!t||!m.length?e.jsx("div",{className:"h-40 flex items-center justify-center text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(wc,{className:"text-3xl mx-auto mb-1 opacity-20"}),e.jsx("div",{className:"text-xs",children:"Loading..."})]})}):e.jsx("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:m.map((k,C)=>{const D=h[C]||0,T=b>0?D/b*100:0,E=p[C],O=Math.max(T,D>0?3:1);return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 h-7 bg-gray-100 dark:bg-gray-700 rounded-lg overflow-hidden relative",children:[e.jsx("div",{className:"h-full rounded-lg transition-all duration-500 flex items-center justify-end pr-2",style:{width:`${O}%`,backgroundColor:E,opacity:.88},children:T>28&&e.jsxs("span",{className:"text-[9px] font-bold text-white whitespace-nowrap",children:[D.toFixed(2)," hrs"]})}),T<=28&&e.jsxs("span",{className:"absolute left-[calc(max(3%,6px)+6px)] top-1/2 -translate-y-1/2 text-[9px] font-bold text-gray-600 dark:text-gray-300 whitespace-nowrap",children:[D.toFixed(2)," hrs"]})]}),e.jsx("div",{className:"w-36 text-[11px] text-gray-700 dark:text-gray-200 font-medium truncate flex-shrink-0",title:k,children:k})]},C)})}),m.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-3 pt-2 border-t border-gray-100 dark:border-gray-700",children:m.map((k,C)=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-sm flex-shrink-0",style:{backgroundColor:p[C]}}),e.jsx("span",{className:"text-[9px] text-gray-400 truncate max-w-[90px]",children:k.length>14?k.substring(0,12)+"…":k})]},C))})]})},mO=({isOpen:t,onClose:a,permittedIssueTypes:r,isAdmin:s,defaultWorkOrderType:i})=>{const[c,d]=y.useState(null),[m,h]=y.useState(!1),[g,p]=y.useState(""),[b,j]=y.useState(i||""),[_,N]=y.useState([]),[k,C]=y.useState([]);y.useEffect(()=>{j(i||"")},[i]),y.useEffect(()=>{if(!t)return;Q(null,null,function*(){try{const[I,oe]=yield Promise.all([fetch('/api/resource/Department?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"}),fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})]),ae=yield I.json(),F=yield oe.json();ae.data&&N(ae.data.map(M=>M.name)),F.data&&C(F.data.map(M=>M.name))}catch(I){console.error(I)}})},[t]);const D=s?k:r;if(y.useEffect(()=>{if(!t)return;Q(null,null,function*(){h(!0);try{const I={};!s&&r.length>0?I.work_order_type=r.length===1?r[0]:r:b&&(I.work_order_type=b),g&&(I.department=g);const ae=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:"Time to Repair",filters:I,ignore_prepared_report:1})})).json();d(ae.message||null)}catch(I){console.error(I)}finally{h(!1)}})},[t,g,b,r,s]),!t)return null;const T=(c==null?void 0:c.columns)||[],E=((c==null?void 0:c.result)||[]).filter(W=>W&&typeof W=="object"),O=E.filter(W=>!W.is_total_row),R=(c==null?void 0:c.report_summary)||[],Y=T.find(W=>{const I=((W.label||"")+(W.fieldname||"")).toLowerCase();return I.includes("time_to_repair")||I.includes("time to repair")||I.includes("hours")})||T[T.length-1],P=T.find(W=>{const I=((W.label||"")+(W.fieldname||"")).toLowerCase();return I.includes("wo_type")||I.includes("wo type")||I.includes("work_order_type")})||T[1],U=R.find(W=>{var I,oe;return((I=W.label)==null?void 0:I.toLowerCase().includes("avg"))||((oe=W.label)==null?void 0:oe.toLowerCase().includes("overall"))}),J=O.filter(W=>!Wo(P?W[P.fieldname]:null)),ne=U?parseFloat(U.value)||0:J.length>0&&Y?J.reduce((W,I)=>W+(parseFloat(I[Y.fieldname])||0),0)/J.length:0,ye={};O.forEach(W=>{const I=P?W[P.fieldname]:null;if(Wo(I))return;const oe=String(I),ae=Y&&parseFloat(W[Y.fieldname])||0;ye[oe]||(ye[oe]={total:0,count:0}),ye[oe].total+=ae,ye[oe].count+=1});const he=Object.keys(ye),ce=he.map(W=>parseFloat((ye[W].total/ye[W].count).toFixed(3))),se=Math.max(...ce,.001),ee=Pi(he.length),te=g||b&&(s||r.length===0);return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl max-w-5xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"bg-gradient-to-r from-pink-500 to-rose-600 px-6 py-4 flex items-center justify-between flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(wc,{className:"text-white text-xl"}),e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Time to Repair"})]}),e.jsx("button",{onClick:a,className:"text-white/80 hover:text-white p-1 rounded-lg hover:bg-white/20 transition-colors",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"px-6 py-3 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/30 flex-shrink-0 flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"Department"}),e.jsxs("select",{value:g,onChange:W=>p(W.target.value),className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-pink-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white min-w-[180px]",children:[e.jsx("option",{value:"",children:"All Departments"}),_.map(W=>e.jsx("option",{value:W,children:W},W))]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs font-medium text-gray-500 whitespace-nowrap",children:"WO Type"}),e.jsxs("select",{value:b,onChange:W=>j(W.target.value),disabled:!s&&r.length>0,className:"px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-pink-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white min-w-[180px] disabled:opacity-60",children:[e.jsx("option",{value:"",children:"All Types"}),D.map(W=>e.jsx("option",{value:W,children:W},W))]})]}),te&&e.jsxs("button",{onClick:()=>{p(""),j("")},className:"text-xs text-red-500 hover:text-red-700 flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-red-50 transition-colors",children:[e.jsx(wt,{size:10})," Clear"]})]}),!m&&e.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40 flex-shrink-0 text-center",children:[e.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1",children:"Overall Avg Time to Repair (Hours)"}),e.jsx("div",{className:"text-3xl font-bold text-pink-600 dark:text-pink-400",children:ne.toFixed(3)})]}),e.jsx("div",{className:"p-6 overflow-auto flex-1 flex flex-col gap-6",children:m?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-pink-600"})}):E.length===0?e.jsx("div",{className:"text-center text-gray-400 py-16",children:"No data available"}):e.jsxs(e.Fragment,{children:[he.length>0&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/30 rounded-xl p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-4",children:"Avg Time to Repair by WO Type (Hours)"}),e.jsx("div",{className:"space-y-3",children:he.map((W,I)=>{const oe=ce[I],ae=se>0?oe/se*100:0,F=ee[I],M=Math.max(ae,oe>0?2:1);return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1 h-8 bg-white dark:bg-gray-700 rounded-lg overflow-hidden relative border border-gray-200 dark:border-gray-600",children:[e.jsx("div",{className:"h-full rounded-lg transition-all duration-500 flex items-center justify-end pr-2",style:{width:`${M}%`,backgroundColor:F,opacity:.85},children:ae>20&&e.jsx("span",{className:"text-[11px] font-semibold text-white",children:oe.toFixed(3)})}),ae<=20&&e.jsx("span",{className:"absolute left-[calc(max(2%,4px)+8px)] top-1/2 -translate-y-1/2 text-[11px] font-semibold text-gray-700 dark:text-gray-200",children:oe.toFixed(3)})]}),e.jsx("div",{className:"w-52 text-xs text-gray-700 dark:text-gray-200 font-medium truncate flex-shrink-0",title:W,children:W})]},I)})})]}),e.jsxs("table",{className:"w-full text-sm border-collapse",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:T.map((W,I)=>e.jsx("th",{className:`py-3 px-4 font-semibold text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-900/50 ${I===0?"text-left":"text-right"}`,children:W.label||W.fieldname},I))})}),e.jsx("tbody",{children:E.map((W,I)=>e.jsx("tr",{className:`border-b border-gray-100 dark:border-gray-700/50 hover:bg-pink-50/40 dark:hover:bg-pink-900/10 transition-colors ${W.is_total_row?"font-bold bg-gray-50 dark:bg-gray-900/40 border-t-2 border-gray-300 dark:border-gray-600":""}`,children:T.map((oe,ae)=>{var be;const F=(oe.fieldname||"").toLowerCase(),M=(oe.label||"").toLowerCase(),B=!W.is_total_row&&(F==="name"||F==="work_order"||F==="work_order_id"||M==="work order"||M==="work order id"||M==="wo"),X=(be=W[oe.fieldname])!=null?be:"—",K=B?String(X):"",we=B&&K&&K!=="—";return e.jsx("td",{className:`py-2.5 px-4 ${ae===0?"text-left font-medium":"text-right tabular-nums"} ${we?"cursor-pointer text-pink-600 dark:text-pink-400 font-semibold hover:text-pink-800 dark:hover:text-pink-200 hover:underline":"text-gray-800 dark:text-gray-200"}`,onClick:we?()=>{window.location.href=`/asm_app/work-orders?work_order_id=${encodeURIComponent(K)}`}:void 0,title:we?`Open Work Order ${K}`:void 0,children:we?e.jsxs("span",{className:"flex items-center gap-1.5",children:[X,e.jsx(vs,{size:9,className:"opacity-50 flex-shrink-0"})]}):X},ae)})},I))})]})]})})]})})};function Pi(t){const a=["#8B5CF6","#6366F1","#3B82F6","#06B6D4","#14B8A6","#EC4899","#A855F7","#0EA5E9","#10B981","#F472B6","#7C3AED","#2DD4BF"];return Array.from({length:t},(r,s)=>a[s%a.length])}function hk(t,a){return function(){return t.apply(a,arguments)}}const{toString:hO}=Object.prototype,{getPrototypeOf:_p}=Object,{iterator:Vh,toStringTag:gk}=Symbol,qh=(t=>a=>{const r=hO.call(a);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Hi=t=>(t=t.toLowerCase(),a=>qh(a)===t),Gh=t=>a=>typeof a===t,{isArray:Zd}=Array,Bd=Gh("undefined");function Du(t){return t!==null&&!Bd(t)&&t.constructor!==null&&!Bd(t.constructor)&&Rn(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const fk=Hi("ArrayBuffer");function gO(t){let a;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?a=ArrayBuffer.isView(t):a=t&&t.buffer&&fk(t.buffer),a}const fO=Gh("string"),Rn=Gh("function"),xk=Gh("number"),Mu=t=>t!==null&&typeof t=="object",xO=t=>t===!0||t===!1,th=t=>{if(qh(t)!=="object")return!1;const a=_p(t);return(a===null||a===Object.prototype||Object.getPrototypeOf(a)===null)&&!(gk in t)&&!(Vh in t)},pO=t=>{if(!Mu(t)||Du(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch(a){return!1}},yO=Hi("Date"),bO=Hi("File"),vO=Hi("Blob"),_O=Hi("FileList"),wO=t=>Mu(t)&&Rn(t.pipe),kO=t=>{let a;return t&&(typeof FormData=="function"&&t instanceof FormData||Rn(t.append)&&((a=qh(t))==="formdata"||a==="object"&&Rn(t.toString)&&t.toString()==="[object FormData]"))},jO=Hi("URLSearchParams"),[NO,SO,CO,TO]=["ReadableStream","Request","Response","Headers"].map(Hi),EO=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Lu(t,a,{allOwnKeys:r=!1}={}){if(t===null||typeof t=="undefined")return;let s,i;if(typeof t!="object"&&(t=[t]),Zd(t))for(s=0,i=t.length;s<i;s++)a.call(null,t[s],s,t);else{if(Du(t))return;const c=r?Object.getOwnPropertyNames(t):Object.keys(t),d=c.length;let m;for(s=0;s<d;s++)m=c[s],a.call(null,t[m],m,t)}}function pk(t,a){if(Du(t))return null;a=a.toLowerCase();const r=Object.keys(t);let s=r.length,i;for(;s-- >0;)if(i=r[s],a===i.toLowerCase())return i;return null}const hc=typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:global,yk=t=>!Bd(t)&&t!==hc;function Dx(){const{caseless:t,skipUndefined:a}=yk(this)&&this||{},r={},s=(i,c)=>{const d=t&&pk(r,c)||c;th(r[d])&&th(i)?r[d]=Dx(r[d],i):th(i)?r[d]=Dx({},i):Zd(i)?r[d]=i.slice():(!a||!Bd(i))&&(r[d]=i)};for(let i=0,c=arguments.length;i<c;i++)arguments[i]&&Lu(arguments[i],s);return r}const AO=(t,a,r,{allOwnKeys:s}={})=>(Lu(a,(i,c)=>{r&&Rn(i)?t[c]=hk(i,r):t[c]=i},{allOwnKeys:s}),t),OO=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),DO=(t,a,r,s)=>{t.prototype=Object.create(a.prototype,s),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:a.prototype}),r&&Object.assign(t.prototype,r)},MO=(t,a,r,s)=>{let i,c,d;const m={};if(a=a||{},t==null)return a;do{for(i=Object.getOwnPropertyNames(t),c=i.length;c-- >0;)d=i[c],(!s||s(d,t,a))&&!m[d]&&(a[d]=t[d],m[d]=!0);t=r!==!1&&_p(t)}while(t&&(!r||r(t,a))&&t!==Object.prototype);return a},LO=(t,a,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=a.length;const s=t.indexOf(a,r);return s!==-1&&s===r},RO=t=>{if(!t)return null;if(Zd(t))return t;let a=t.length;if(!xk(a))return null;const r=new Array(a);for(;a-- >0;)r[a]=t[a];return r},PO=(t=>a=>t&&a instanceof t)(typeof Uint8Array!="undefined"&&_p(Uint8Array)),FO=(t,a)=>{const s=(t&&t[Vh]).call(t);let i;for(;(i=s.next())&&!i.done;){const c=i.value;a.call(t,c[0],c[1])}},IO=(t,a)=>{let r;const s=[];for(;(r=t.exec(a))!==null;)s.push(r);return s},zO=Hi("HTMLFormElement"),BO=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,s,i){return s.toUpperCase()+i}),m_=(({hasOwnProperty:t})=>(a,r)=>t.call(a,r))(Object.prototype),UO=Hi("RegExp"),bk=(t,a)=>{const r=Object.getOwnPropertyDescriptors(t),s={};Lu(r,(i,c)=>{let d;(d=a(i,c,t))!==!1&&(s[c]=d||i)}),Object.defineProperties(t,s)},$O=t=>{bk(t,(a,r)=>{if(Rn(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const s=t[r];if(Rn(s)){if(a.enumerable=!1,"writable"in a){a.writable=!1;return}a.set||(a.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},HO=(t,a)=>{const r={},s=i=>{i.forEach(c=>{r[c]=!0})};return Zd(t)?s(t):s(String(t).split(a)),r},WO=()=>{},VO=(t,a)=>t!=null&&Number.isFinite(t=+t)?t:a;function qO(t){return!!(t&&Rn(t.append)&&t[gk]==="FormData"&&t[Vh])}const GO=t=>{const a=new Array(10),r=(s,i)=>{if(Mu(s)){if(a.indexOf(s)>=0)return;if(Du(s))return s;if(!("toJSON"in s)){a[i]=s;const c=Zd(s)?[]:{};return Lu(s,(d,m)=>{const h=r(d,i+1);!Bd(h)&&(c[m]=h)}),a[i]=void 0,c}}return s};return r(t,0)},YO=Hi("AsyncFunction"),ZO=t=>t&&(Mu(t)||Rn(t))&&Rn(t.then)&&Rn(t.catch),vk=((t,a)=>t?setImmediate:a?((r,s)=>(hc.addEventListener("message",({source:i,data:c})=>{i===hc&&c===r&&s.length&&s.shift()()},!1),i=>{s.push(i),hc.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Rn(hc.postMessage)),JO=typeof queueMicrotask!="undefined"?queueMicrotask.bind(hc):typeof process!="undefined"&&process.nextTick||vk,XO=t=>t!=null&&Rn(t[Vh]),ot={isArray:Zd,isArrayBuffer:fk,isBuffer:Du,isFormData:kO,isArrayBufferView:gO,isString:fO,isNumber:xk,isBoolean:xO,isObject:Mu,isPlainObject:th,isEmptyObject:pO,isReadableStream:NO,isRequest:SO,isResponse:CO,isHeaders:TO,isUndefined:Bd,isDate:yO,isFile:bO,isBlob:vO,isRegExp:UO,isFunction:Rn,isStream:wO,isURLSearchParams:jO,isTypedArray:PO,isFileList:_O,forEach:Lu,merge:Dx,extend:AO,trim:EO,stripBOM:OO,inherits:DO,toFlatObject:MO,kindOf:qh,kindOfTest:Hi,endsWith:LO,toArray:RO,forEachEntry:FO,matchAll:IO,isHTMLForm:zO,hasOwnProperty:m_,hasOwnProp:m_,reduceDescriptors:bk,freezeMethods:$O,toObjectSet:HO,toCamelCase:BO,noop:WO,toFiniteNumber:VO,findKey:pk,global:hc,isContextDefined:yk,isSpecCompliantForm:qO,toJSONObject:GO,isAsyncFn:YO,isThenable:ZO,setImmediate:vk,asap:JO,isIterable:XO};function Ea(t,a,r,s,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",a&&(this.code=a),r&&(this.config=r),s&&(this.request=s),i&&(this.response=i,this.status=i.status?i.status:null)}ot.inherits(Ea,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ot.toJSONObject(this.config),code:this.code,status:this.status}}});const _k=Ea.prototype,wk={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{wk[t]={value:t}});Object.defineProperties(Ea,wk);Object.defineProperty(_k,"isAxiosError",{value:!0});Ea.from=(t,a,r,s,i,c)=>{const d=Object.create(_k);ot.toFlatObject(t,d,function(p){return p!==Error.prototype},g=>g!=="isAxiosError");const m=t&&t.message?t.message:"Error",h=a==null&&t?t.code:a;return Ea.call(d,m,h,r,s,i),t&&d.cause==null&&Object.defineProperty(d,"cause",{value:t,configurable:!0}),d.name=t&&t.name||"Error",c&&Object.assign(d,c),d};const KO=null;function Mx(t){return ot.isPlainObject(t)||ot.isArray(t)}function kk(t){return ot.endsWith(t,"[]")?t.slice(0,-2):t}function h_(t,a,r){return t?t.concat(a).map(function(i,c){return i=kk(i),!r&&c?"["+i+"]":i}).join(r?".":""):a}function QO(t){return ot.isArray(t)&&!t.some(Mx)}const eD=ot.toFlatObject(ot,{},null,function(a){return/^is[A-Z]/.test(a)});function Yh(t,a,r){if(!ot.isObject(t))throw new TypeError("target must be an object");a=a||new FormData,r=ot.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(k,C){return!ot.isUndefined(C[k])});const s=r.metaTokens,i=r.visitor||p,c=r.dots,d=r.indexes,h=(r.Blob||typeof Blob!="undefined"&&Blob)&&ot.isSpecCompliantForm(a);if(!ot.isFunction(i))throw new TypeError("visitor must be a function");function g(N){if(N===null)return"";if(ot.isDate(N))return N.toISOString();if(ot.isBoolean(N))return N.toString();if(!h&&ot.isBlob(N))throw new Ea("Blob is not supported. Use a Buffer instead.");return ot.isArrayBuffer(N)||ot.isTypedArray(N)?h&&typeof Blob=="function"?new Blob([N]):Buffer.from(N):N}function p(N,k,C){let D=N;if(N&&!C&&typeof N=="object"){if(ot.endsWith(k,"{}"))k=s?k:k.slice(0,-2),N=JSON.stringify(N);else if(ot.isArray(N)&&QO(N)||(ot.isFileList(N)||ot.endsWith(k,"[]"))&&(D=ot.toArray(N)))return k=kk(k),D.forEach(function(E,O){!(ot.isUndefined(E)||E===null)&&a.append(d===!0?h_([k],O,c):d===null?k:k+"[]",g(E))}),!1}return Mx(N)?!0:(a.append(h_(C,k,c),g(N)),!1)}const b=[],j=Object.assign(eD,{defaultVisitor:p,convertValue:g,isVisitable:Mx});function _(N,k){if(!ot.isUndefined(N)){if(b.indexOf(N)!==-1)throw Error("Circular reference detected in "+k.join("."));b.push(N),ot.forEach(N,function(D,T){(!(ot.isUndefined(D)||D===null)&&i.call(a,D,ot.isString(T)?T.trim():T,k,j))===!0&&_(D,k?k.concat(T):[T])}),b.pop()}}if(!ot.isObject(t))throw new TypeError("data must be an object");return _(t),a}function g_(t){const a={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(s){return a[s]})}function wp(t,a){this._pairs=[],t&&Yh(t,this,a)}const jk=wp.prototype;jk.append=function(a,r){this._pairs.push([a,r])};jk.toString=function(a){const r=a?function(s){return a.call(this,s,g_)}:g_;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};function tD(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Nk(t,a,r){if(!a)return t;const s=r&&r.encode||tD;ot.isFunction(r)&&(r={serialize:r});const i=r&&r.serialize;let c;if(i?c=i(a,r):c=ot.isURLSearchParams(a)?a.toString():new wp(a,r).toString(s),c){const d=t.indexOf("#");d!==-1&&(t=t.slice(0,d)),t+=(t.indexOf("?")===-1?"?":"&")+c}return t}class f_{constructor(){this.handlers=[]}use(a,r,s){return this.handlers.push({fulfilled:a,rejected:r,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(a){this.handlers[a]&&(this.handlers[a]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(a){ot.forEach(this.handlers,function(s){s!==null&&a(s)})}}const Sk={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},aD=typeof URLSearchParams!="undefined"?URLSearchParams:wp,rD=typeof FormData!="undefined"?FormData:null,sD=typeof Blob!="undefined"?Blob:null,nD={isBrowser:!0,classes:{URLSearchParams:aD,FormData:rD,Blob:sD},protocols:["http","https","file","blob","url","data"]},kp=typeof window!="undefined"&&typeof document!="undefined",Lx=typeof navigator=="object"&&navigator||void 0,iD=kp&&(!Lx||["ReactNative","NativeScript","NS"].indexOf(Lx.product)<0),oD=typeof WorkerGlobalScope!="undefined"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",lD=kp&&window.location.href||"http://localhost",cD=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:kp,hasStandardBrowserEnv:iD,hasStandardBrowserWebWorkerEnv:oD,navigator:Lx,origin:lD},Symbol.toStringTag,{value:"Module"})),nn=ue(ue({},cD),nD);function dD(t,a){return Yh(t,new nn.classes.URLSearchParams,ue({visitor:function(r,s,i,c){return nn.isNode&&ot.isBuffer(r)?(this.append(s,r.toString("base64")),!1):c.defaultVisitor.apply(this,arguments)}},a))}function uD(t){return ot.matchAll(/\w+|\[(\w*)]/g,t).map(a=>a[0]==="[]"?"":a[1]||a[0])}function mD(t){const a={},r=Object.keys(t);let s;const i=r.length;let c;for(s=0;s<i;s++)c=r[s],a[c]=t[c];return a}function Ck(t){function a(r,s,i,c){let d=r[c++];if(d==="__proto__")return!0;const m=Number.isFinite(+d),h=c>=r.length;return d=!d&&ot.isArray(i)?i.length:d,h?(ot.hasOwnProp(i,d)?i[d]=[i[d],s]:i[d]=s,!m):((!i[d]||!ot.isObject(i[d]))&&(i[d]=[]),a(r,s,i[d],c)&&ot.isArray(i[d])&&(i[d]=mD(i[d])),!m)}if(ot.isFormData(t)&&ot.isFunction(t.entries)){const r={};return ot.forEachEntry(t,(s,i)=>{a(uD(s),i,r,0)}),r}return null}function hD(t,a,r){if(ot.isString(t))try{return(a||JSON.parse)(t),ot.trim(t)}catch(s){if(s.name!=="SyntaxError")throw s}return(r||JSON.stringify)(t)}const Ru={transitional:Sk,adapter:["xhr","http","fetch"],transformRequest:[function(a,r){const s=r.getContentType()||"",i=s.indexOf("application/json")>-1,c=ot.isObject(a);if(c&&ot.isHTMLForm(a)&&(a=new FormData(a)),ot.isFormData(a))return i?JSON.stringify(Ck(a)):a;if(ot.isArrayBuffer(a)||ot.isBuffer(a)||ot.isStream(a)||ot.isFile(a)||ot.isBlob(a)||ot.isReadableStream(a))return a;if(ot.isArrayBufferView(a))return a.buffer;if(ot.isURLSearchParams(a))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),a.toString();let m;if(c){if(s.indexOf("application/x-www-form-urlencoded")>-1)return dD(a,this.formSerializer).toString();if((m=ot.isFileList(a))||s.indexOf("multipart/form-data")>-1){const h=this.env&&this.env.FormData;return Yh(m?{"files[]":a}:a,h&&new h,this.formSerializer)}}return c||i?(r.setContentType("application/json",!1),hD(a)):a}],transformResponse:[function(a){const r=this.transitional||Ru.transitional,s=r&&r.forcedJSONParsing,i=this.responseType==="json";if(ot.isResponse(a)||ot.isReadableStream(a))return a;if(a&&ot.isString(a)&&(s&&!this.responseType||i)){const d=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(a,this.parseReviver)}catch(m){if(d)throw m.name==="SyntaxError"?Ea.from(m,Ea.ERR_BAD_RESPONSE,this,null,this.response):m}}return a}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:nn.classes.FormData,Blob:nn.classes.Blob},validateStatus:function(a){return a>=200&&a<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ot.forEach(["delete","get","head","post","put","patch"],t=>{Ru.headers[t]={}});const gD=ot.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),fD=t=>{const a={};let r,s,i;return t&&t.split(`
`).forEach(function(d){i=d.indexOf(":"),r=d.substring(0,i).trim().toLowerCase(),s=d.substring(i+1).trim(),!(!r||a[r]&&gD[r])&&(r==="set-cookie"?a[r]?a[r].push(s):a[r]=[s]:a[r]=a[r]?a[r]+", "+s:s)}),a},x_=Symbol("internals");function q0(t){return t&&String(t).trim().toLowerCase()}function ah(t){return t===!1||t==null?t:ot.isArray(t)?t.map(ah):String(t)}function xD(t){const a=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=r.exec(t);)a[s[1]]=s[2];return a}const pD=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function dx(t,a,r,s,i){if(ot.isFunction(s))return s.call(this,a,r);if(i&&(a=r),!!ot.isString(a)){if(ot.isString(s))return a.indexOf(s)!==-1;if(ot.isRegExp(s))return s.test(a)}}function yD(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(a,r,s)=>r.toUpperCase()+s)}function bD(t,a){const r=ot.toCamelCase(" "+a);["get","set","has"].forEach(s=>{Object.defineProperty(t,s+r,{value:function(i,c,d){return this[s].call(this,a,i,c,d)},configurable:!0})})}let Pn=class{constructor(a){a&&this.set(a)}set(a,r,s){const i=this;function c(m,h,g){const p=q0(h);if(!p)throw new Error("header name must be a non-empty string");const b=ot.findKey(i,p);(!b||i[b]===void 0||g===!0||g===void 0&&i[b]!==!1)&&(i[b||h]=ah(m))}const d=(m,h)=>ot.forEach(m,(g,p)=>c(g,p,h));if(ot.isPlainObject(a)||a instanceof this.constructor)d(a,r);else if(ot.isString(a)&&(a=a.trim())&&!pD(a))d(fD(a),r);else if(ot.isObject(a)&&ot.isIterable(a)){let m={},h,g;for(const p of a){if(!ot.isArray(p))throw TypeError("Object iterator must return a key-value pair");m[g=p[0]]=(h=m[g])?ot.isArray(h)?[...h,p[1]]:[h,p[1]]:p[1]}d(m,r)}else a!=null&&c(r,a,s);return this}get(a,r){if(a=q0(a),a){const s=ot.findKey(this,a);if(s){const i=this[s];if(!r)return i;if(r===!0)return xD(i);if(ot.isFunction(r))return r.call(this,i,s);if(ot.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(a,r){if(a=q0(a),a){const s=ot.findKey(this,a);return!!(s&&this[s]!==void 0&&(!r||dx(this,this[s],s,r)))}return!1}delete(a,r){const s=this;let i=!1;function c(d){if(d=q0(d),d){const m=ot.findKey(s,d);m&&(!r||dx(s,s[m],m,r))&&(delete s[m],i=!0)}}return ot.isArray(a)?a.forEach(c):c(a),i}clear(a){const r=Object.keys(this);let s=r.length,i=!1;for(;s--;){const c=r[s];(!a||dx(this,this[c],c,a,!0))&&(delete this[c],i=!0)}return i}normalize(a){const r=this,s={};return ot.forEach(this,(i,c)=>{const d=ot.findKey(s,c);if(d){r[d]=ah(i),delete r[c];return}const m=a?yD(c):String(c).trim();m!==c&&delete r[c],r[m]=ah(i),s[m]=!0}),this}concat(...a){return this.constructor.concat(this,...a)}toJSON(a){const r=Object.create(null);return ot.forEach(this,(s,i)=>{s!=null&&s!==!1&&(r[i]=a&&ot.isArray(s)?s.join(", "):s)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([a,r])=>a+": "+r).join(`
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(a){return a instanceof this?a:new this(a)}static concat(a,...r){const s=new this(a);return r.forEach(i=>s.set(i)),s}static accessor(a){const s=(this[x_]=this[x_]={accessors:{}}).accessors,i=this.prototype;function c(d){const m=q0(d);s[m]||(bD(i,d),s[m]=!0)}return ot.isArray(a)?a.forEach(c):c(a),this}};Pn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ot.reduceDescriptors(Pn.prototype,({value:t},a)=>{let r=a[0].toUpperCase()+a.slice(1);return{get:()=>t,set(s){this[r]=s}}});ot.freezeMethods(Pn);function ux(t,a){const r=this||Ru,s=a||r,i=Pn.from(s.headers);let c=s.data;return ot.forEach(t,function(m){c=m.call(r,c,i.normalize(),a?a.status:void 0)}),i.normalize(),c}function Tk(t){return!!(t&&t.__CANCEL__)}function Jd(t,a,r){Ea.call(this,t==null?"canceled":t,Ea.ERR_CANCELED,a,r),this.name="CanceledError"}ot.inherits(Jd,Ea,{__CANCEL__:!0});function Ek(t,a,r){const s=r.config.validateStatus;!r.status||!s||s(r.status)?t(r):a(new Ea("Request failed with status code "+r.status,[Ea.ERR_BAD_REQUEST,Ea.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function vD(t){const a=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return a&&a[1]||""}function _D(t,a){t=t||10;const r=new Array(t),s=new Array(t);let i=0,c=0,d;return a=a!==void 0?a:1e3,function(h){const g=Date.now(),p=s[c];d||(d=g),r[i]=h,s[i]=g;let b=c,j=0;for(;b!==i;)j+=r[b++],b=b%t;if(i=(i+1)%t,i===c&&(c=(c+1)%t),g-d<a)return;const _=p&&g-p;return _?Math.round(j*1e3/_):void 0}}function wD(t,a){let r=0,s=1e3/a,i,c;const d=(g,p=Date.now())=>{r=p,i=null,c&&(clearTimeout(c),c=null),t(...g)};return[(...g)=>{const p=Date.now(),b=p-r;b>=s?d(g,p):(i=g,c||(c=setTimeout(()=>{c=null,d(i)},s-b)))},()=>i&&d(i)]}const Ah=(t,a,r=3)=>{let s=0;const i=_D(50,250);return wD(c=>{const d=c.loaded,m=c.lengthComputable?c.total:void 0,h=d-s,g=i(h),p=d<=m;s=d;const b={loaded:d,total:m,progress:m?d/m:void 0,bytes:h,rate:g||void 0,estimated:g&&m&&p?(m-d)/g:void 0,event:c,lengthComputable:m!=null,[a?"download":"upload"]:!0};t(b)},r)},p_=(t,a)=>{const r=t!=null;return[s=>a[0]({lengthComputable:r,total:t,loaded:s}),a[1]]},y_=t=>(...a)=>ot.asap(()=>t(...a)),kD=nn.hasStandardBrowserEnv?((t,a)=>r=>(r=new URL(r,nn.origin),t.protocol===r.protocol&&t.host===r.host&&(a||t.port===r.port)))(new URL(nn.origin),nn.navigator&&/(msie|trident)/i.test(nn.navigator.userAgent)):()=>!0,jD=nn.hasStandardBrowserEnv?{write(t,a,r,s,i,c,d){if(typeof document=="undefined")return;const m=[`${t}=${encodeURIComponent(a)}`];ot.isNumber(r)&&m.push(`expires=${new Date(r).toUTCString()}`),ot.isString(s)&&m.push(`path=${s}`),ot.isString(i)&&m.push(`domain=${i}`),c===!0&&m.push("secure"),ot.isString(d)&&m.push(`SameSite=${d}`),document.cookie=m.join("; ")},read(t){if(typeof document=="undefined")return null;const a=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return a?decodeURIComponent(a[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function ND(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function SD(t,a){return a?t.replace(/\/?\/$/,"")+"/"+a.replace(/^\/+/,""):t}function Ak(t,a,r){let s=!ND(a);return t&&(s||r==!1)?SD(t,a):a}const b_=t=>t instanceof Pn?ue({},t):t;function Sc(t,a){a=a||{};const r={};function s(g,p,b,j){return ot.isPlainObject(g)&&ot.isPlainObject(p)?ot.merge.call({caseless:j},g,p):ot.isPlainObject(p)?ot.merge({},p):ot.isArray(p)?p.slice():p}function i(g,p,b,j){if(ot.isUndefined(p)){if(!ot.isUndefined(g))return s(void 0,g,b,j)}else return s(g,p,b,j)}function c(g,p){if(!ot.isUndefined(p))return s(void 0,p)}function d(g,p){if(ot.isUndefined(p)){if(!ot.isUndefined(g))return s(void 0,g)}else return s(void 0,p)}function m(g,p,b){if(b in a)return s(g,p);if(b in t)return s(void 0,g)}const h={url:c,method:c,data:c,baseURL:d,transformRequest:d,transformResponse:d,paramsSerializer:d,timeout:d,timeoutMessage:d,withCredentials:d,withXSRFToken:d,adapter:d,responseType:d,xsrfCookieName:d,xsrfHeaderName:d,onUploadProgress:d,onDownloadProgress:d,decompress:d,maxContentLength:d,maxBodyLength:d,beforeRedirect:d,transport:d,httpAgent:d,httpsAgent:d,cancelToken:d,socketPath:d,responseEncoding:d,validateStatus:m,headers:(g,p,b)=>i(b_(g),b_(p),b,!0)};return ot.forEach(Object.keys(ue(ue({},t),a)),function(p){const b=h[p]||i,j=b(t[p],a[p],p);ot.isUndefined(j)&&b!==m||(r[p]=j)}),r}const Ok=t=>{const a=Sc({},t);let{data:r,withXSRFToken:s,xsrfHeaderName:i,xsrfCookieName:c,headers:d,auth:m}=a;if(a.headers=d=Pn.from(d),a.url=Nk(Ak(a.baseURL,a.url,a.allowAbsoluteUrls),t.params,t.paramsSerializer),m&&d.set("Authorization","Basic "+btoa((m.username||"")+":"+(m.password?unescape(encodeURIComponent(m.password)):""))),ot.isFormData(r)){if(nn.hasStandardBrowserEnv||nn.hasStandardBrowserWebWorkerEnv)d.setContentType(void 0);else if(ot.isFunction(r.getHeaders)){const h=r.getHeaders(),g=["content-type","content-length"];Object.entries(h).forEach(([p,b])=>{g.includes(p.toLowerCase())&&d.set(p,b)})}}if(nn.hasStandardBrowserEnv&&(s&&ot.isFunction(s)&&(s=s(a)),s||s!==!1&&kD(a.url))){const h=i&&c&&jD.read(c);h&&d.set(i,h)}return a},CD=typeof XMLHttpRequest!="undefined",TD=CD&&function(t){return new Promise(function(r,s){const i=Ok(t);let c=i.data;const d=Pn.from(i.headers).normalize();let{responseType:m,onUploadProgress:h,onDownloadProgress:g}=i,p,b,j,_,N;function k(){_&&_(),N&&N(),i.cancelToken&&i.cancelToken.unsubscribe(p),i.signal&&i.signal.removeEventListener("abort",p)}let C=new XMLHttpRequest;C.open(i.method.toUpperCase(),i.url,!0),C.timeout=i.timeout;function D(){if(!C)return;const E=Pn.from("getAllResponseHeaders"in C&&C.getAllResponseHeaders()),R={data:!m||m==="text"||m==="json"?C.responseText:C.response,status:C.status,statusText:C.statusText,headers:E,config:t,request:C};Ek(function(P){r(P),k()},function(P){s(P),k()},R),C=null}"onloadend"in C?C.onloadend=D:C.onreadystatechange=function(){!C||C.readyState!==4||C.status===0&&!(C.responseURL&&C.responseURL.indexOf("file:")===0)||setTimeout(D)},C.onabort=function(){C&&(s(new Ea("Request aborted",Ea.ECONNABORTED,t,C)),C=null)},C.onerror=function(O){const R=O&&O.message?O.message:"Network Error",Y=new Ea(R,Ea.ERR_NETWORK,t,C);Y.event=O||null,s(Y),C=null},C.ontimeout=function(){let O=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const R=i.transitional||Sk;i.timeoutErrorMessage&&(O=i.timeoutErrorMessage),s(new Ea(O,R.clarifyTimeoutError?Ea.ETIMEDOUT:Ea.ECONNABORTED,t,C)),C=null},c===void 0&&d.setContentType(null),"setRequestHeader"in C&&ot.forEach(d.toJSON(),function(O,R){C.setRequestHeader(R,O)}),ot.isUndefined(i.withCredentials)||(C.withCredentials=!!i.withCredentials),m&&m!=="json"&&(C.responseType=i.responseType),g&&([j,N]=Ah(g,!0),C.addEventListener("progress",j)),h&&C.upload&&([b,_]=Ah(h),C.upload.addEventListener("progress",b),C.upload.addEventListener("loadend",_)),(i.cancelToken||i.signal)&&(p=E=>{C&&(s(!E||E.type?new Jd(null,t,C):E),C.abort(),C=null)},i.cancelToken&&i.cancelToken.subscribe(p),i.signal&&(i.signal.aborted?p():i.signal.addEventListener("abort",p)));const T=vD(i.url);if(T&&nn.protocols.indexOf(T)===-1){s(new Ea("Unsupported protocol "+T+":",Ea.ERR_BAD_REQUEST,t));return}C.send(c||null)})},ED=(t,a)=>{const{length:r}=t=t?t.filter(Boolean):[];if(a||r){let s=new AbortController,i;const c=function(g){if(!i){i=!0,m();const p=g instanceof Error?g:this.reason;s.abort(p instanceof Ea?p:new Jd(p instanceof Error?p.message:p))}};let d=a&&setTimeout(()=>{d=null,c(new Ea(`timeout ${a} of ms exceeded`,Ea.ETIMEDOUT))},a);const m=()=>{t&&(d&&clearTimeout(d),d=null,t.forEach(g=>{g.unsubscribe?g.unsubscribe(c):g.removeEventListener("abort",c)}),t=null)};t.forEach(g=>g.addEventListener("abort",c));const{signal:h}=s;return h.unsubscribe=()=>ot.asap(m),h}},AD=function*(t,a){let r=t.byteLength;if(r<a){yield t;return}let s=0,i;for(;s<r;)i=s+a,yield t.slice(s,i),s=i},OD=function(t,a){return If(this,null,function*(){try{for(var r=Av(DD(t)),s,i,c;s=!(i=yield new nc(r.next())).done;s=!1){const d=i.value;yield*zf(AD(d,a))}}catch(i){c=[i]}finally{try{s&&(i=r.return)&&(yield new nc(i.call(r)))}finally{if(c)throw c[0]}}})},DD=function(t){return If(this,null,function*(){if(t[Symbol.asyncIterator]){yield*zf(t);return}const a=t.getReader();try{for(;;){const{done:r,value:s}=yield new nc(a.read());if(r)break;yield s}}finally{yield new nc(a.cancel())}})},v_=(t,a,r,s)=>{const i=OD(t,a);let c=0,d,m=g=>{d||(d=!0,s&&s(g))};return new ReadableStream({pull(g){return Q(this,null,function*(){try{const{done:p,value:b}=yield i.next();if(p){m(),g.close();return}let j=b.byteLength;if(r){let _=c+=j;r(_)}g.enqueue(new Uint8Array(b))}catch(p){throw m(p),p}})},cancel(g){return m(g),i.return()}},{highWaterMark:2})},__=64*1024,{isFunction:Gm}=ot,MD=(({Request:t,Response:a})=>({Request:t,Response:a}))(ot.global),{ReadableStream:w_,TextEncoder:k_}=ot.global,j_=(t,...a)=>{try{return!!t(...a)}catch(r){return!1}},LD=t=>{t=ot.merge.call({skipUndefined:!0},MD,t);const{fetch:a,Request:r,Response:s}=t,i=a?Gm(a):typeof fetch=="function",c=Gm(r),d=Gm(s);if(!i)return!1;const m=i&&Gm(w_),h=i&&(typeof k_=="function"?(N=>k=>N.encode(k))(new k_):N=>Q(null,null,function*(){return new Uint8Array(yield new r(N).arrayBuffer())})),g=c&&m&&j_(()=>{let N=!1;const k=new r(nn.origin,{body:new w_,method:"POST",get duplex(){return N=!0,"half"}}).headers.has("Content-Type");return N&&!k}),p=d&&m&&j_(()=>ot.isReadableStream(new s("").body)),b={stream:p&&(N=>N.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(N=>{!b[N]&&(b[N]=(k,C)=>{let D=k&&k[N];if(D)return D.call(k);throw new Ea(`Response type '${N}' is not supported`,Ea.ERR_NOT_SUPPORT,C)})});const j=N=>Q(null,null,function*(){if(N==null)return 0;if(ot.isBlob(N))return N.size;if(ot.isSpecCompliantForm(N))return(yield new r(nn.origin,{method:"POST",body:N}).arrayBuffer()).byteLength;if(ot.isArrayBufferView(N)||ot.isArrayBuffer(N))return N.byteLength;if(ot.isURLSearchParams(N)&&(N=N+""),ot.isString(N))return(yield h(N)).byteLength}),_=(N,k)=>Q(null,null,function*(){const C=ot.toFiniteNumber(N.getContentLength());return C==null?j(k):C});return N=>Q(null,null,function*(){let{url:k,method:C,data:D,signal:T,cancelToken:E,timeout:O,onDownloadProgress:R,onUploadProgress:Y,responseType:P,headers:U,withCredentials:J="same-origin",fetchOptions:ne}=Ok(N),ye=a||fetch;P=P?(P+"").toLowerCase():"text";let he=ED([T,E&&E.toAbortSignal()],O),ce=null;const se=he&&he.unsubscribe&&(()=>{he.unsubscribe()});let ee;try{if(Y&&g&&C!=="get"&&C!=="head"&&(ee=yield _(U,D))!==0){let F=new r(k,{method:"POST",body:D,duplex:"half"}),M;if(ot.isFormData(D)&&(M=F.headers.get("content-type"))&&U.setContentType(M),F.body){const[B,X]=p_(ee,Ah(y_(Y)));D=v_(F.body,__,B,X)}}ot.isString(J)||(J=J?"include":"omit");const te=c&&"credentials"in r.prototype,W=Se(ue({},ne),{signal:he,method:C.toUpperCase(),headers:U.normalize().toJSON(),body:D,duplex:"half",credentials:te?J:void 0});ce=c&&new r(k,W);let I=yield c?ye(ce,ne):ye(k,W);const oe=p&&(P==="stream"||P==="response");if(p&&(R||oe&&se)){const F={};["status","statusText","headers"].forEach(K=>{F[K]=I[K]});const M=ot.toFiniteNumber(I.headers.get("content-length")),[B,X]=R&&p_(M,Ah(y_(R),!0))||[];I=new s(v_(I.body,__,B,()=>{X&&X(),se&&se()}),F)}P=P||"text";let ae=yield b[ot.findKey(b,P)||"text"](I,N);return!oe&&se&&se(),yield new Promise((F,M)=>{Ek(F,M,{data:ae,headers:Pn.from(I.headers),status:I.status,statusText:I.statusText,config:N,request:ce})})}catch(te){throw se&&se(),te&&te.name==="TypeError"&&/Load failed|fetch/i.test(te.message)?Object.assign(new Ea("Network Error",Ea.ERR_NETWORK,N,ce),{cause:te.cause||te}):Ea.from(te,te&&te.code,N,ce)}})},RD=new Map,Dk=t=>{let a=t&&t.env||{};const{fetch:r,Request:s,Response:i}=a,c=[s,i,r];let d=c.length,m=d,h,g,p=RD;for(;m--;)h=c[m],g=p.get(h),g===void 0&&p.set(h,g=m?new Map:LD(a)),p=g;return g};Dk();const jp={http:KO,xhr:TD,fetch:{get:Dk}};ot.forEach(jp,(t,a)=>{if(t){try{Object.defineProperty(t,"name",{value:a})}catch(r){}Object.defineProperty(t,"adapterName",{value:a})}});const N_=t=>`- ${t}`,PD=t=>ot.isFunction(t)||t===null||t===!1;function FD(t,a){t=ot.isArray(t)?t:[t];const{length:r}=t;let s,i;const c={};for(let d=0;d<r;d++){s=t[d];let m;if(i=s,!PD(s)&&(i=jp[(m=String(s)).toLowerCase()],i===void 0))throw new Ea(`Unknown adapter '${m}'`);if(i&&(ot.isFunction(i)||(i=i.get(a))))break;c[m||"#"+d]=i}if(!i){const d=Object.entries(c).map(([h,g])=>`adapter ${h} `+(g===!1?"is not supported by the environment":"is not available in the build"));let m=r?d.length>1?`since :
`+d.map(N_).join(`
`):" "+N_(d[0]):"as no adapter specified";throw new Ea("There is no suitable adapter to dispatch the request "+m,"ERR_NOT_SUPPORT")}return i}const Mk={getAdapter:FD,adapters:jp};function mx(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Jd(null,t)}function S_(t){return mx(t),t.headers=Pn.from(t.headers),t.data=ux.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Mk.getAdapter(t.adapter||Ru.adapter,t)(t).then(function(s){return mx(t),s.data=ux.call(t,t.transformResponse,s),s.headers=Pn.from(s.headers),s},function(s){return Tk(s)||(mx(t),s&&s.response&&(s.response.data=ux.call(t,t.transformResponse,s.response),s.response.headers=Pn.from(s.response.headers))),Promise.reject(s)})}const Lk="1.13.2",Zh={};["object","boolean","number","function","string","symbol"].forEach((t,a)=>{Zh[t]=function(s){return typeof s===t||"a"+(a<1?"n ":" ")+t}});const C_={};Zh.transitional=function(a,r,s){function i(c,d){return"[Axios v"+Lk+"] Transitional option '"+c+"'"+d+(s?". "+s:"")}return(c,d,m)=>{if(a===!1)throw new Ea(i(d," has been removed"+(r?" in "+r:"")),Ea.ERR_DEPRECATED);return r&&!C_[d]&&(C_[d]=!0,console.warn(i(d," has been deprecated since v"+r+" and will be removed in the near future"))),a?a(c,d,m):!0}};Zh.spelling=function(a){return(r,s)=>(console.warn(`${s} is likely a misspelling of ${a}`),!0)};function ID(t,a,r){if(typeof t!="object")throw new Ea("options must be an object",Ea.ERR_BAD_OPTION_VALUE);const s=Object.keys(t);let i=s.length;for(;i-- >0;){const c=s[i],d=a[c];if(d){const m=t[c],h=m===void 0||d(m,c,t);if(h!==!0)throw new Ea("option "+c+" must be "+h,Ea.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new Ea("Unknown option "+c,Ea.ERR_BAD_OPTION)}}const rh={assertOptions:ID,validators:Zh},lo=rh.validators;let pc=class{constructor(a){this.defaults=a||{},this.interceptors={request:new f_,response:new f_}}request(a,r){return Q(this,null,function*(){try{return yield this._request(a,r)}catch(s){if(s instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const c=i.stack?i.stack.replace(/^.+\n/,""):"";try{s.stack?c&&!String(s.stack).endsWith(c.replace(/^.+\n.+\n/,""))&&(s.stack+=`
`+c):s.stack=c}catch(d){}}throw s}})}_request(a,r){typeof a=="string"?(r=r||{},r.url=a):r=a||{},r=Sc(this.defaults,r);const{transitional:s,paramsSerializer:i,headers:c}=r;s!==void 0&&rh.assertOptions(s,{silentJSONParsing:lo.transitional(lo.boolean),forcedJSONParsing:lo.transitional(lo.boolean),clarifyTimeoutError:lo.transitional(lo.boolean)},!1),i!=null&&(ot.isFunction(i)?r.paramsSerializer={serialize:i}:rh.assertOptions(i,{encode:lo.function,serialize:lo.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),rh.assertOptions(r,{baseUrl:lo.spelling("baseURL"),withXsrfToken:lo.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let d=c&&ot.merge(c.common,c[r.method]);c&&ot.forEach(["delete","get","head","post","put","patch","common"],N=>{delete c[N]}),r.headers=Pn.concat(d,c);const m=[];let h=!0;this.interceptors.request.forEach(function(k){typeof k.runWhen=="function"&&k.runWhen(r)===!1||(h=h&&k.synchronous,m.unshift(k.fulfilled,k.rejected))});const g=[];this.interceptors.response.forEach(function(k){g.push(k.fulfilled,k.rejected)});let p,b=0,j;if(!h){const N=[S_.bind(this),void 0];for(N.unshift(...m),N.push(...g),j=N.length,p=Promise.resolve(r);b<j;)p=p.then(N[b++],N[b++]);return p}j=m.length;let _=r;for(;b<j;){const N=m[b++],k=m[b++];try{_=N(_)}catch(C){k.call(this,C);break}}try{p=S_.call(this,_)}catch(N){return Promise.reject(N)}for(b=0,j=g.length;b<j;)p=p.then(g[b++],g[b++]);return p}getUri(a){a=Sc(this.defaults,a);const r=Ak(a.baseURL,a.url,a.allowAbsoluteUrls);return Nk(r,a.params,a.paramsSerializer)}};ot.forEach(["delete","get","head","options"],function(a){pc.prototype[a]=function(r,s){return this.request(Sc(s||{},{method:a,url:r,data:(s||{}).data}))}});ot.forEach(["post","put","patch"],function(a){function r(s){return function(c,d,m){return this.request(Sc(m||{},{method:a,headers:s?{"Content-Type":"multipart/form-data"}:{},url:c,data:d}))}}pc.prototype[a]=r(),pc.prototype[a+"Form"]=r(!0)});let zD=class Rk{constructor(a){if(typeof a!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(c){r=c});const s=this;this.promise.then(i=>{if(!s._listeners)return;let c=s._listeners.length;for(;c-- >0;)s._listeners[c](i);s._listeners=null}),this.promise.then=i=>{let c;const d=new Promise(m=>{s.subscribe(m),c=m}).then(i);return d.cancel=function(){s.unsubscribe(c)},d},a(function(c,d,m){s.reason||(s.reason=new Jd(c,d,m),r(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(a){if(this.reason){a(this.reason);return}this._listeners?this._listeners.push(a):this._listeners=[a]}unsubscribe(a){if(!this._listeners)return;const r=this._listeners.indexOf(a);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const a=new AbortController,r=s=>{a.abort(s)};return this.subscribe(r),a.signal.unsubscribe=()=>this.unsubscribe(r),a.signal}static source(){let a;return{token:new Rk(function(i){a=i}),cancel:a}}};function BD(t){return function(r){return t.apply(null,r)}}function UD(t){return ot.isObject(t)&&t.isAxiosError===!0}const Rx={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Rx).forEach(([t,a])=>{Rx[a]=t});function Pk(t){const a=new pc(t),r=hk(pc.prototype.request,a);return ot.extend(r,pc.prototype,a,{allOwnKeys:!0}),ot.extend(r,a,null,{allOwnKeys:!0}),r.create=function(i){return Pk(Sc(t,i))},r}const Kr=Pk(Ru);Kr.Axios=pc;Kr.CanceledError=Jd;Kr.CancelToken=zD;Kr.isCancel=Tk;Kr.VERSION=Lk;Kr.toFormData=Yh;Kr.AxiosError=Ea;Kr.Cancel=Kr.CanceledError;Kr.all=function(a){return Promise.all(a)};Kr.spread=BD;Kr.isAxiosError=UD;Kr.mergeConfig=Sc;Kr.AxiosHeaders=Pn;Kr.formToJSON=t=>Ck(ot.isHTMLForm(t)?new FormData(t):t);Kr.getAdapter=Mk.getAdapter;Kr.HttpStatusCode=Rx;Kr.default=Kr;const{Axios:iF,AxiosError:oF,CanceledError:lF,isCancel:cF,CancelToken:dF,VERSION:uF,all:mF,Cancel:hF,isAxiosError:gF,spread:fF,toFormData:xF,AxiosHeaders:pF,HttpStatusCode:yF,formToJSON:bF,getAdapter:vF,mergeConfig:_F}=Kr;class $D{constructor(){Mn(this,"client");Mn(this,"baseURL");Mn(this,"siteName");this.baseURL="http://localhost:8000",this.siteName="seeraasm-med.seeraarabia.com",this.client=Kr.create({baseURL:this.baseURL,timeout:parseInt("10000"),withCredentials:!0,headers:{"Content-Type":"application/json",Accept:"application/json"}}),this.client.interceptors.request.use(a=>{var r;return(r=a.url)!=null&&r.includes("/api/")&&(a.url=`/${this.siteName}${a.url}`),a}),this.client.interceptors.response.use(a=>a,a=>{var r;return((r=a.response)==null?void 0:r.status)===401&&(window.location.href="/login"),Promise.reject(a)})}login(a){return Q(this,null,function*(){return(yield this.client.post("/api/method/login",a)).data})}logout(){return Q(this,null,function*(){return(yield this.client.post("/api/method/logout")).data})}getCurrentUser(){return Q(this,null,function*(){return(yield this.client.get("/api/method/frappe.auth.get_logged_user")).data})}callMethod(s){return Q(this,arguments,function*(a,r={}){return(yield this.client.post(`/api/method/${a}`,r)).data})}frappeGet(s){return Q(this,arguments,function*(a,r={}){return this.callMethod(a,r)})}getDocTypeRecords(i){return Q(this,arguments,function*(a,r={},s=[]){const c=new URLSearchParams;return Object.keys(r).length>0&&c.append("filters",JSON.stringify(r)),s.length>0&&c.append("fields",JSON.stringify(s)),(yield this.client.get(`/api/resource/${a}?${c.toString()}`)).data})}getDocTypeRecord(a,r){return Q(this,null,function*(){return(yield this.client.get(`/api/resource/${a}/${r}`)).data})}createDocTypeRecord(a,r){return Q(this,null,function*(){return(yield this.client.post(`/api/resource/${a}`,r)).data})}updateDocTypeRecord(a,r,s){return Q(this,null,function*(){return(yield this.client.put(`/api/resource/${a}/${r}`,s)).data})}deleteDocTypeRecord(a,r){return Q(this,null,function*(){return(yield this.client.delete(`/api/resource/${a}/${r}`)).data})}uploadFile(a,r="Home"){return Q(this,null,function*(){const s=new FormData;return s.append("file",a),s.append("folder",r),s.append("is_private","0"),(yield this.client.post("/api/method/upload_file",s,{headers:{"Content-Type":"multipart/form-data"}})).data})}}const Fk=new $D,HD=()=>{const{t}=ca(),[a,r]=y.useState([]),[s,i]=y.useState(!0),[c,d]=y.useState(null),[m,h]=y.useState(""),g=qa();y.useEffect(()=>{p()},[]);const p=()=>Q(null,null,function*(){var _,N;try{i(!0);const k=yield Fk.getDocTypeRecords("User",{},["name","full_name","email","enabled","creation","modified"]);r(k.message||[])}catch(k){d(((N=(_=k.response)==null?void 0:_.data)==null?void 0:N.message)||"Failed to load users")}finally{i(!1)}}),b=a.filter(_=>{var N,k,C;return((N=_.full_name)==null?void 0:N.toLowerCase().includes(m.toLowerCase()))||((k=_.email)==null?void 0:k.toLowerCase().includes(m.toLowerCase()))||((C=_.name)==null?void 0:C.toLowerCase().includes(m.toLowerCase()))}),j=_=>{g(`/users/${_.name}`)};return s?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900",children:e.jsx("div",{className:"animate-spin rounded-full h-32 w-32 border-b-2 border-indigo-600"})}):e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900",children:[e.jsx("header",{className:"bg-white dark:bg-gray-800 shadow",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"flex justify-between items-center py-6",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("button",{onClick:()=>g("/dashboard"),className:"mr-4 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300",children:e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),e.jsx("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white",children:t("users.title")})]}),e.jsx("div",{className:"flex items-center space-x-4",children:e.jsx("button",{onClick:()=>g("/dashboard"),className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-md text-sm font-medium",children:t("users.backToDashboard")})})]})})}),e.jsxs("main",{className:"max-w-7xl mx-auto py-6 sm:px-6 lg:px-8",children:[c&&e.jsx("div",{className:"mb-6 rounded-md bg-red-50 dark:bg-red-900/20 p-4",children:e.jsx("div",{className:"text-sm text-red-700 dark:text-red-400",children:c})}),e.jsxs("div",{className:"mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:e.jsx("svg",{className:"h-5 w-5 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),e.jsx("input",{type:"text",placeholder:t("users.searchUsers"),value:m,onChange:_=>h(_.target.value),className:"block w-full pl-10 pr-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md leading-5 bg-white dark:bg-gray-700 placeholder-gray-500 dark:placeholder-gray-400 text-gray-900 dark:text-white focus:outline-none focus:placeholder-gray-400 focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"})]})}),e.jsx("div",{className:"mt-4 sm:mt-0 sm:ml-4",children:e.jsxs("button",{onClick:p,className:"inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",children:[e.jsx("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),t("users.refresh")]})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow overflow-hidden sm:rounded-md",children:[e.jsxs("div",{className:"px-4 py-5 sm:px-6",children:[e.jsxs("h3",{className:"text-lg leading-6 font-medium text-gray-900 dark:text-white",children:[t("users.title")," (",b.length,")"]}),e.jsx("p",{className:"mt-1 max-w-2xl text-sm text-gray-500 dark:text-gray-400",children:t("users.manageUsers")})]}),b.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197m13.5-9a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0z"})}),e.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900 dark:text-white",children:t("users.noUsersFound")}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:t(m?"users.tryAdjustingSearch":"users.noUsersAvailable")})]}):e.jsx("ul",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:b.map(_=>{var N;return e.jsx("li",{children:e.jsxs("div",{className:"px-4 py-4 flex items-center justify-between hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer",onClick:()=>j(_),children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"flex-shrink-0 h-10 w-10",children:e.jsx("div",{className:"h-10 w-10 rounded-full bg-indigo-100 dark:bg-indigo-900 flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-medium text-indigo-600 dark:text-indigo-300",children:((N=_.full_name)==null?void 0:N.charAt(0))||_.name.charAt(0)})})}),e.jsxs("div",{className:"ml-4",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:_.full_name||_.name}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:_.email||t("users.noEmail")})]})]}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`w-2 h-2 rounded-full mr-2 ${_.enabled?"bg-green-400":"bg-red-400"}`}),_.enabled?t("users.active"):t("users.inactive")]})}),e.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t("users.created"),": ",new Date(_.creation).toLocaleDateString()]}),e.jsx("svg",{className:"w-5 h-5 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})]})},_.name)})})]})]})]})},WD=()=>{const{t}=ca(),[a,r]=y.useState([]),[s,i]=y.useState(!0),[c,d]=y.useState(null);y.useEffect(()=>{m()},[]);const m=()=>Q(null,null,function*(){try{i(!0);const b=yield Fk.frappeGet("frappe.desk.doctype.event.event.get_events");r(b.message||[])}catch(b){console.log("API call failed, using demo events:",b);const j=[{name:"EVT001",subject:"Team Meeting - Asset Management Review",starts_on:new Date().toISOString(),ends_on:new Date(Date.now()+36e5).toISOString(),status:"Open",event_type:"Meeting",description:"Monthly review of asset management processes"},{name:"EVT002",subject:"System Maintenance Window",starts_on:new Date(Date.now()+864e5).toISOString(),ends_on:new Date(Date.now()+864e5+72e5).toISOString(),status:"Scheduled",event_type:"Maintenance",description:"Scheduled maintenance for Seera Arabia AMS"},{name:"EVT003",subject:"User Training Session",starts_on:new Date(Date.now()+1728e5).toISOString(),ends_on:new Date(Date.now()+1728e5+108e5).toISOString(),status:"Open",event_type:"Training",description:"Training session for new users on AMS features"}];r(j),d(null)}finally{i(!1)}}),h=b=>new Date(b).toLocaleString(),g=b=>{switch(b.toLowerCase()){case"open":return"bg-green-100 text-green-800";case"scheduled":return"bg-blue-100 text-blue-800";case"completed":return"bg-gray-100 text-gray-800";case"cancelled":return"bg-red-100 text-red-800";default:return"bg-gray-100 text-gray-800"}},p=b=>{switch(b.toLowerCase()){case"meeting":return"bg-purple-100 text-purple-800";case"training":return"bg-yellow-100 text-yellow-800";case"maintenance":return"bg-orange-100 text-orange-800";default:return"bg-gray-100 text-gray-800"}};return s?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900",children:e.jsx("div",{className:"animate-spin rounded-full h-32 w-32 border-b-2 border-indigo-600"})}):e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900",children:[e.jsx("header",{className:"bg-white dark:bg-gray-800 shadow",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"flex justify-between items-center py-6",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white",children:t("events.title")})}),e.jsx("div",{className:"flex items-center space-x-4",children:e.jsx("button",{onClick:m,className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-md text-sm font-medium",children:t("events.refreshEvents")})})]})})}),e.jsxs("main",{className:"max-w-7xl mx-auto py-6 sm:px-6 lg:px-8",children:[c&&e.jsx("div",{className:"mb-6 rounded-md bg-red-50 dark:bg-red-900/20 p-4",children:e.jsx("div",{className:"text-sm text-red-700 dark:text-red-400",children:c})}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow overflow-hidden sm:rounded-md",children:[e.jsxs("div",{className:"px-4 py-5 sm:px-6",children:[e.jsxs("h3",{className:"text-lg leading-6 font-medium text-gray-900 dark:text-white",children:[t("events.upcomingEvents")," (",a.length,")"]}),e.jsx("p",{className:"mt-1 max-w-2xl text-sm text-gray-500 dark:text-gray-400",children:t("events.eventsFromFrappe")})]}),a.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),e.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900 dark:text-white",children:t("events.noEventsFound")}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:t("events.noEventsScheduled")})]}):e.jsx("ul",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:a.map(b=>e.jsx("li",{children:e.jsx("div",{className:"px-4 py-4 hover:bg-gray-50 dark:hover:bg-gray-700",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-lg font-medium text-gray-900 dark:text-white",children:b.subject}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${g(b.status)}`,children:b.status}),e.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${p(b.event_type)}`,children:b.event_type})]})]}),b.description&&e.jsx("p",{className:"mt-1 text-sm text-gray-600 dark:text-gray-400",children:b.description}),e.jsxs("div",{className:"mt-2 flex items-center text-sm text-gray-500 dark:text-gray-400",children:[e.jsx("svg",{className:"flex-shrink-0 mr-1.5 h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("span",{children:[h(b.starts_on)," - ",h(b.ends_on)]})]})]})})})},b.name))})]}),e.jsx("div",{className:"mt-8 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-md p-4",children:e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-blue-400",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"ml-3",children:[e.jsx("h3",{className:"text-sm font-medium text-blue-800 dark:text-blue-300",children:"API Endpoint Information"}),e.jsxs("div",{className:"mt-2 text-sm text-blue-700 dark:text-blue-400",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Endpoint:"})," ",e.jsx("code",{children:"frappe.desk.doctype.event.event.get_events"})]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Full URL:"})," ",e.jsx("code",{children:"https://seeraasm-med.seeraarabia.com/api/method/frappe.desk.doctype.event.event.get_events"})]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Method:"})," POST (Frappe API standard)"]})]})]})]})})]})]})},Ik={Location:{doctype:"Location",title:"Create New Location",titleField:"location_name",fields:[{fieldname:"location_name",label:"Location Name",fieldtype:"Data",required:!0,placeholder:"Enter location name"},{fieldname:"parent_location",label:"Parent Location",fieldtype:"Link",linkDoctype:"Location",placeholder:"Select parent location (optional)"},{fieldname:"is_group",label:"Is Group",fieldtype:"Check",defaultValue:0,description:"Check if this location contains sub-locations"},{fieldname:"latitude",label:"Latitude",fieldtype:"Float",placeholder:"e.g., 24.7136"},{fieldname:"longitude",label:"Longitude",fieldtype:"Float",placeholder:"e.g., 46.6753"}]},Room:{doctype:"Room",title:"Create New Room",titleField:"name",fields:[{fieldname:"room",label:"Room Name/Number",fieldtype:"Data",required:!0,placeholder:"Enter room name or number"},{fieldname:"building",label:"Building",fieldtype:"Link",linkDoctype:"Building",placeholder:"Select building"},{fieldname:"location_name",label:"Location Name",fieldtype:"Link",linkDoctype:"Location",placeholder:"Select Location"},{fieldname:"department",label:"Department",fieldtype:"Link",linkDoctype:"Department",placeholder:"Select department"}]},Building:{doctype:"Building",title:"Create New Building",titleField:"name",fields:[{fieldname:"building",label:"Building Name",fieldtype:"Data",required:!0,placeholder:"Enter building name"}]},"Extension Directory":{doctype:"Extension Directory",title:"Create New Extension",titleField:"name",fields:[{fieldname:"extension_number",label:"Extension Number",fieldtype:"Data",required:!0,placeholder:"Enter extension number"}]},Department:{doctype:"Department",title:"Create New Department",titleField:"department_name",fields:[{fieldname:"department_name",label:"Department Name",fieldtype:"Data",required:!0,placeholder:"Enter department name"},{fieldname:"company",label:"Company",fieldtype:"Link",linkDoctype:"Company",required:!0,placeholder:"Select company"},{fieldname:"parent_department",label:"Parent Department",fieldtype:"Link",linkDoctype:"Department",placeholder:"Select parent department"},{fieldname:"is_group",label:"Is Group",fieldtype:"Check",defaultValue:0}]},"Issue Type":{doctype:"Issue Type",title:"Create New Issue Type",titleField:"name",fields:[{fieldname:"__newname",label:"Issue Type Name",fieldtype:"Data",required:!0,placeholder:"Enter issue type name"},{fieldname:"description",label:"Description",fieldtype:"Text",placeholder:"Enter description"}]},Manufacturer:{doctype:"Manufacturer",title:"Create New Manufacturer",titleField:"name",fields:[{fieldname:"short_name",label:"Manufacturer Name",fieldtype:"Data",required:!0,placeholder:"Enter manufacturer name"},{fieldname:"full_name",label:"Full Name",fieldtype:"Data",placeholder:"Enter full company name"},{fieldname:"website",label:"Website",fieldtype:"Data",placeholder:"https://example.com"},{fieldname:"country",label:"Country",fieldtype:"Link",linkDoctype:"Country",placeholder:"Select country"}]},Supplier:{doctype:"Supplier",title:"Create New Supplier",titleField:"supplier_name",fields:[{fieldname:"supplier_name",label:"Supplier Name",fieldtype:"Data",required:!0,placeholder:"Enter supplier name"},{fieldname:"supplier_group",label:"Supplier Group",fieldtype:"Link",linkDoctype:"Supplier Group",placeholder:"Select supplier group"},{fieldname:"supplier_type",label:"Supplier Type",fieldtype:"Select",options:["Company","Individual"],defaultValue:"Company"},{fieldname:"country",label:"Country",fieldtype:"Link",linkDoctype:"Country",placeholder:"Select country"}]},Warehouse:{doctype:"Warehouse",title:"Create New Warehouse",titleField:"warehouse_name",fields:[{fieldname:"warehouse_name",label:"Warehouse Name",fieldtype:"Data",required:!0,placeholder:"Enter warehouse name"},{fieldname:"company",label:"Company",fieldtype:"Link",linkDoctype:"Company",required:!0,placeholder:"Select company"},{fieldname:"parent_warehouse",label:"Parent Warehouse",fieldtype:"Link",linkDoctype:"Warehouse",placeholder:"Select parent warehouse"},{fieldname:"is_group",label:"Is Group",fieldtype:"Check",defaultValue:0}]},Item:{doctype:"Item",title:"Create New Item",titleField:"item_name",fields:[{fieldname:"item_code",label:"Item Code",fieldtype:"Data",required:!0,placeholder:"Enter item code"},{fieldname:"item_name",label:"Item Name",fieldtype:"Data",required:!0,placeholder:"Enter item name"},{fieldname:"item_group",label:"Item Group",fieldtype:"Link",linkDoctype:"Item Group",required:!0,placeholder:"Select item group"},{fieldname:"stock_uom",label:"Default Unit of Measure",fieldtype:"Link",linkDoctype:"UOM",required:!0,defaultValue:"Nos",placeholder:"Select UOM"},{fieldname:"is_stock_item",label:"Maintain Stock",fieldtype:"Check",defaultValue:1},{fieldname:"description",label:"Description",fieldtype:"Text",placeholder:"Enter item description"}]},Asset:{doctype:"Asset",title:"Create New Asset",titleField:"asset_name",fields:[{fieldname:"asset_name",label:"Asset Name",fieldtype:"Data",required:!0,placeholder:"Enter asset name"},{fieldname:"item_code",label:"Item Code",fieldtype:"Link",linkDoctype:"Item",required:!0,linkFilters:{is_fixed_asset:1},placeholder:"Select item"},{fieldname:"company",label:"Company",fieldtype:"Link",linkDoctype:"Company",required:!0,placeholder:"Select company"},{fieldname:"location",label:"Location",fieldtype:"Link",linkDoctype:"Location",placeholder:"Select location"},{fieldname:"custodian",label:"Custodian",fieldtype:"Link",linkDoctype:"Employee",placeholder:"Select custodian"}]},"Technical Department":{doctype:"Technical Department",title:"Create New Technical Department",titleField:"name",fields:[{fieldname:"department",label:"Department Name",fieldtype:"Data",required:!0,placeholder:"Enter technical department name"}]}},VD=t=>Ik[t]||null,qD=t=>t in Ik,G0=new Map,GD=t=>Q(null,null,function*(){var a;try{return((a=(yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({roles:t.join(",")})})).json()).message)==null?void 0:a.has_role)===!0}catch(r){return console.error("[PermissionService] Error checking roles:",r),!1}}),YD=t=>Q(null,null,function*(){var r,s,i,c;const a=`create_${t}`;if(G0.has(a)){const d=G0.get(a);return console.log(`[PermissionService] ${t} (cached): ${d}`),d}console.log(`[PermissionService] Checking create permission for: ${t}`);try{const m=yield(yield fetch("/api/method/asset_lite.api.user_roles.has_create_permission",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:t})})).json();console.log(`[PermissionService] has_create_permission response for ${t}:`,m);const h=((r=m.message)==null?void 0:r.has_permission)===!0;return console.log(h?`[PermissionService] ${t}: Permission GRANTED via ${(s=m.message)==null?void 0:s.reason} (role: ${(i=m.message)==null?void 0:i.role})`:`[PermissionService] ${t}: Permission DENIED - ${(c=m.message)==null?void 0:c.reason}`),G0.set(a,h),h}catch(d){console.error(`[PermissionService] Error checking permission for ${t}:`,d);try{if(yield GD(["System Manager","Administrator"]))return console.log("[PermissionService] Fallback: User is admin, granting permission"),G0.set(a,!0),!0}catch(m){console.error("[PermissionService] Fallback check failed:",m)}return G0.set(a,!1),!1}});function zk(t){var a,r,s="";if(typeof t=="string"||typeof t=="number")s+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(a=0;a<i;a++)t[a]&&(r=zk(t[a]))&&(s&&(s+=" "),s+=r)}else for(r in t)t[r]&&(s&&(s+=" "),s+=r);return s}function yc(){for(var t,a,r=0,s="",i=arguments.length;r<i;r++)(t=arguments[r])&&(a=zk(t))&&(s&&(s+=" "),s+=a);return s}function ZD(t){if(typeof document=="undefined")return;let a=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",a.firstChild?a.insertBefore(r,a.firstChild):a.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}ZD(`:root{--toastify-color-light: #fff;--toastify-color-dark: #121212;--toastify-color-info: #3498db;--toastify-color-success: #07bc0c;--toastify-color-warning: #f1c40f;--toastify-color-error: hsl(6, 78%, 57%);--toastify-color-transparent: rgba(255, 255, 255, .7);--toastify-icon-color-info: var(--toastify-color-info);--toastify-icon-color-success: var(--toastify-color-success);--toastify-icon-color-warning: var(--toastify-color-warning);--toastify-icon-color-error: var(--toastify-color-error);--toastify-container-width: fit-content;--toastify-toast-width: 320px;--toastify-toast-offset: 16px;--toastify-toast-top: max(var(--toastify-toast-offset), env(safe-area-inset-top));--toastify-toast-right: max(var(--toastify-toast-offset), env(safe-area-inset-right));--toastify-toast-left: max(var(--toastify-toast-offset), env(safe-area-inset-left));--toastify-toast-bottom: max(var(--toastify-toast-offset), env(safe-area-inset-bottom));--toastify-toast-background: #fff;--toastify-toast-padding: 14px;--toastify-toast-min-height: 64px;--toastify-toast-max-height: 800px;--toastify-toast-bd-radius: 6px;--toastify-toast-shadow: 0px 4px 12px rgba(0, 0, 0, .1);--toastify-font-family: sans-serif;--toastify-z-index: 9999;--toastify-text-color-light: #757575;--toastify-text-color-dark: #fff;--toastify-text-color-info: #fff;--toastify-text-color-success: #fff;--toastify-text-color-warning: #fff;--toastify-text-color-error: #fff;--toastify-spinner-color: #616161;--toastify-spinner-color-empty-area: #e0e0e0;--toastify-color-progress-light: linear-gradient(to right, #4cd964, #5ac8fa, #007aff, #34aadc, #5856d6, #ff2d55);--toastify-color-progress-dark: #bb86fc;--toastify-color-progress-info: var(--toastify-color-info);--toastify-color-progress-success: var(--toastify-color-success);--toastify-color-progress-warning: var(--toastify-color-warning);--toastify-color-progress-error: var(--toastify-color-error);--toastify-color-progress-bgo: .2}.Toastify__toast-container{z-index:var(--toastify-z-index);-webkit-transform:translate3d(0,0,var(--toastify-z-index));position:fixed;width:var(--toastify-container-width);box-sizing:border-box;color:#fff;display:flex;flex-direction:column}.Toastify__toast-container--top-left{top:var(--toastify-toast-top);left:var(--toastify-toast-left)}.Toastify__toast-container--top-center{top:var(--toastify-toast-top);left:50%;transform:translate(-50%);align-items:center}.Toastify__toast-container--top-right{top:var(--toastify-toast-top);right:var(--toastify-toast-right);align-items:end}.Toastify__toast-container--bottom-left{bottom:var(--toastify-toast-bottom);left:var(--toastify-toast-left)}.Toastify__toast-container--bottom-center{bottom:var(--toastify-toast-bottom);left:50%;transform:translate(-50%);align-items:center}.Toastify__toast-container--bottom-right{bottom:var(--toastify-toast-bottom);right:var(--toastify-toast-right);align-items:end}.Toastify__toast{--y: 0;position:relative;touch-action:none;width:var(--toastify-toast-width);min-height:var(--toastify-toast-min-height);box-sizing:border-box;margin-bottom:1rem;padding:var(--toastify-toast-padding);border-radius:var(--toastify-toast-bd-radius);box-shadow:var(--toastify-toast-shadow);max-height:var(--toastify-toast-max-height);font-family:var(--toastify-font-family);z-index:0;display:flex;flex:1 auto;align-items:center;word-break:break-word}@media only screen and (max-width: 480px){.Toastify__toast-container{width:100vw;left:env(safe-area-inset-left);margin:0}.Toastify__toast-container--top-left,.Toastify__toast-container--top-center,.Toastify__toast-container--top-right{top:env(safe-area-inset-top);transform:translate(0)}.Toastify__toast-container--bottom-left,.Toastify__toast-container--bottom-center,.Toastify__toast-container--bottom-right{bottom:env(safe-area-inset-bottom);transform:translate(0)}.Toastify__toast-container--rtl{right:env(safe-area-inset-right);left:initial}.Toastify__toast{--toastify-toast-width: 100%;margin-bottom:0;border-radius:0}}.Toastify__toast-container[data-stacked=true]{width:var(--toastify-toast-width)}.Toastify__toast--stacked{position:absolute;width:100%;transform:translate3d(0,var(--y),0) scale(var(--s));transition:transform .3s}.Toastify__toast--stacked[data-collapsed] .Toastify__toast-body,.Toastify__toast--stacked[data-collapsed] .Toastify__close-button{transition:opacity .1s}.Toastify__toast--stacked[data-collapsed=false]{overflow:visible}.Toastify__toast--stacked[data-collapsed=true]:not(:last-child)>*{opacity:0}.Toastify__toast--stacked:after{content:"";position:absolute;left:0;right:0;height:calc(var(--g) * 1px);bottom:100%}.Toastify__toast--stacked[data-pos=top]{top:0}.Toastify__toast--stacked[data-pos=bot]{bottom:0}.Toastify__toast--stacked[data-pos=bot].Toastify__toast--stacked:before{transform-origin:top}.Toastify__toast--stacked[data-pos=top].Toastify__toast--stacked:before{transform-origin:bottom}.Toastify__toast--stacked:before{content:"";position:absolute;left:0;right:0;bottom:0;height:100%;transform:scaleY(3);z-index:-1}.Toastify__toast--rtl{direction:rtl}.Toastify__toast--close-on-click{cursor:pointer}.Toastify__toast-icon{margin-inline-end:10px;width:22px;flex-shrink:0;display:flex}.Toastify--animate{animation-fill-mode:both;animation-duration:.5s}.Toastify--animate-icon{animation-fill-mode:both;animation-duration:.3s}.Toastify__toast-theme--dark{background:var(--toastify-color-dark);color:var(--toastify-text-color-dark)}.Toastify__toast-theme--light,.Toastify__toast-theme--colored.Toastify__toast--default{background:var(--toastify-color-light);color:var(--toastify-text-color-light)}.Toastify__toast-theme--colored.Toastify__toast--info{color:var(--toastify-text-color-info);background:var(--toastify-color-info)}.Toastify__toast-theme--colored.Toastify__toast--success{color:var(--toastify-text-color-success);background:var(--toastify-color-success)}.Toastify__toast-theme--colored.Toastify__toast--warning{color:var(--toastify-text-color-warning);background:var(--toastify-color-warning)}.Toastify__toast-theme--colored.Toastify__toast--error{color:var(--toastify-text-color-error);background:var(--toastify-color-error)}.Toastify__progress-bar-theme--light{background:var(--toastify-color-progress-light)}.Toastify__progress-bar-theme--dark{background:var(--toastify-color-progress-dark)}.Toastify__progress-bar--info{background:var(--toastify-color-progress-info)}.Toastify__progress-bar--success{background:var(--toastify-color-progress-success)}.Toastify__progress-bar--warning{background:var(--toastify-color-progress-warning)}.Toastify__progress-bar--error{background:var(--toastify-color-progress-error)}.Toastify__progress-bar-theme--colored.Toastify__progress-bar--info,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--success,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--warning,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--error{background:var(--toastify-color-transparent)}.Toastify__close-button{color:#fff;position:absolute;top:6px;right:6px;background:transparent;outline:none;border:none;padding:0;cursor:pointer;opacity:.7;transition:.3s ease;z-index:1}.Toastify__toast--rtl .Toastify__close-button{left:6px;right:unset}.Toastify__close-button--light{color:#000;opacity:.3}.Toastify__close-button>svg{fill:currentColor;height:16px;width:14px}.Toastify__close-button:hover,.Toastify__close-button:focus{opacity:1}@keyframes Toastify__trackProgress{0%{transform:scaleX(1)}to{transform:scaleX(0)}}.Toastify__progress-bar{position:absolute;bottom:0;left:0;width:100%;height:100%;z-index:1;opacity:.7;transform-origin:left}.Toastify__progress-bar--animated{animation:Toastify__trackProgress linear 1 forwards}.Toastify__progress-bar--controlled{transition:transform .2s}.Toastify__progress-bar--rtl{right:0;left:initial;transform-origin:right;border-bottom-left-radius:initial}.Toastify__progress-bar--wrp{position:absolute;overflow:hidden;bottom:0;left:0;width:100%;height:5px;border-bottom-left-radius:var(--toastify-toast-bd-radius);border-bottom-right-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp[data-hidden=true]{opacity:0}.Toastify__progress-bar--bg{opacity:var(--toastify-color-progress-bgo);width:100%;height:100%}.Toastify__spinner{width:20px;height:20px;box-sizing:border-box;border:2px solid;border-radius:100%;border-color:var(--toastify-spinner-color-empty-area);border-right-color:var(--toastify-spinner-color);animation:Toastify__spin .65s linear infinite}@keyframes Toastify__bounceInRight{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(3000px,0,0)}60%{opacity:1;transform:translate3d(-25px,0,0)}75%{transform:translate3d(10px,0,0)}90%{transform:translate3d(-5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutRight{20%{opacity:1;transform:translate3d(-20px,var(--y),0)}to{opacity:0;transform:translate3d(2000px,var(--y),0)}}@keyframes Toastify__bounceInLeft{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(-3000px,0,0)}60%{opacity:1;transform:translate3d(25px,0,0)}75%{transform:translate3d(-10px,0,0)}90%{transform:translate3d(5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutLeft{20%{opacity:1;transform:translate3d(20px,var(--y),0)}to{opacity:0;transform:translate3d(-2000px,var(--y),0)}}@keyframes Toastify__bounceInUp{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,3000px,0)}60%{opacity:1;transform:translate3d(0,-20px,0)}75%{transform:translate3d(0,10px,0)}90%{transform:translate3d(0,-5px,0)}to{transform:translateZ(0)}}@keyframes Toastify__bounceOutUp{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,-2000px,0)}}@keyframes Toastify__bounceInDown{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,-3000px,0)}60%{opacity:1;transform:translate3d(0,25px,0)}75%{transform:translate3d(0,-10px,0)}90%{transform:translate3d(0,5px,0)}to{transform:none}}@keyframes Toastify__bounceOutDown{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,2000px,0)}}.Toastify__bounce-enter--top-left,.Toastify__bounce-enter--bottom-left{animation-name:Toastify__bounceInLeft}.Toastify__bounce-enter--top-right,.Toastify__bounce-enter--bottom-right{animation-name:Toastify__bounceInRight}.Toastify__bounce-enter--top-center{animation-name:Toastify__bounceInDown}.Toastify__bounce-enter--bottom-center{animation-name:Toastify__bounceInUp}.Toastify__bounce-exit--top-left,.Toastify__bounce-exit--bottom-left{animation-name:Toastify__bounceOutLeft}.Toastify__bounce-exit--top-right,.Toastify__bounce-exit--bottom-right{animation-name:Toastify__bounceOutRight}.Toastify__bounce-exit--top-center{animation-name:Toastify__bounceOutUp}.Toastify__bounce-exit--bottom-center{animation-name:Toastify__bounceOutDown}@keyframes Toastify__zoomIn{0%{opacity:0;transform:scale3d(.3,.3,.3)}50%{opacity:1}}@keyframes Toastify__zoomOut{0%{opacity:1}50%{opacity:0;transform:translate3d(0,var(--y),0) scale3d(.3,.3,.3)}to{opacity:0}}.Toastify__zoom-enter{animation-name:Toastify__zoomIn}.Toastify__zoom-exit{animation-name:Toastify__zoomOut}@keyframes Toastify__flipIn{0%{transform:perspective(400px) rotateX(90deg);animation-timing-function:ease-in;opacity:0}40%{transform:perspective(400px) rotateX(-20deg);animation-timing-function:ease-in}60%{transform:perspective(400px) rotateX(10deg);opacity:1}80%{transform:perspective(400px) rotateX(-5deg)}to{transform:perspective(400px)}}@keyframes Toastify__flipOut{0%{transform:translate3d(0,var(--y),0) perspective(400px)}30%{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(-20deg);opacity:1}to{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(90deg);opacity:0}}.Toastify__flip-enter{animation-name:Toastify__flipIn}.Toastify__flip-exit{animation-name:Toastify__flipOut}@keyframes Toastify__slideInRight{0%{transform:translate3d(110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInLeft{0%{transform:translate3d(-110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInUp{0%{transform:translate3d(0,110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInDown{0%{transform:translate3d(0,-110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideOutRight{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(110%,var(--y),0)}}@keyframes Toastify__slideOutLeft{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(-110%,var(--y),0)}}@keyframes Toastify__slideOutDown{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,500px,0)}}@keyframes Toastify__slideOutUp{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,-500px,0)}}.Toastify__slide-enter--top-left,.Toastify__slide-enter--bottom-left{animation-name:Toastify__slideInLeft}.Toastify__slide-enter--top-right,.Toastify__slide-enter--bottom-right{animation-name:Toastify__slideInRight}.Toastify__slide-enter--top-center{animation-name:Toastify__slideInDown}.Toastify__slide-enter--bottom-center{animation-name:Toastify__slideInUp}.Toastify__slide-exit--top-left,.Toastify__slide-exit--bottom-left{animation-name:Toastify__slideOutLeft;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--top-right,.Toastify__slide-exit--bottom-right{animation-name:Toastify__slideOutRight;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--top-center{animation-name:Toastify__slideOutUp;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-center{animation-name:Toastify__slideOutDown;animation-timing-function:ease-in;animation-duration:.3s}@keyframes Toastify__spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
`);var Pu=t=>typeof t=="number"&&!isNaN(t),Cc=t=>typeof t=="string",Ko=t=>typeof t=="function",JD=t=>Cc(t)||Pu(t),Px=t=>Cc(t)||Ko(t)?t:null,XD=(t,a)=>t===!1||Pu(t)&&t>0?t:a,Fx=t=>y.isValidElement(t)||Cc(t)||Ko(t)||Pu(t);function KD(t,a,r=300){let{scrollHeight:s,style:i}=t;requestAnimationFrame(()=>{i.minHeight="initial",i.height=s+"px",i.transition=`all ${r}ms`,requestAnimationFrame(()=>{i.height="0",i.padding="0",i.margin="0",setTimeout(a,r)})})}function QD({enter:t,exit:a,appendPosition:r=!1,collapse:s=!0,collapseDuration:i=300}){return function({children:c,position:d,preventExitTransition:m,done:h,nodeRef:g,isIn:p,playToast:b}){let j=r?`${t}--${d}`:t,_=r?`${a}--${d}`:a,N=y.useRef(0);return y.useLayoutEffect(()=>{let k=g.current,C=j.split(" "),D=T=>{T.target===g.current&&(b(),k.removeEventListener("animationend",D),k.removeEventListener("animationcancel",D),N.current===0&&T.type!=="animationcancel"&&k.classList.remove(...C))};k.classList.add(...C),k.addEventListener("animationend",D),k.addEventListener("animationcancel",D)},[]),y.useEffect(()=>{let k=g.current,C=()=>{k.removeEventListener("animationend",C),s?KD(k,h,i):h()};p||(m?C():(N.current=1,k.className+=` ${_}`,k.addEventListener("animationend",C)))},[p]),pa.createElement(pa.Fragment,null,c)}}function T_(t,a){return{content:Bk(t.content,t.props),containerId:t.props.containerId,id:t.props.toastId,theme:t.props.theme,type:t.props.type,data:t.props.data||{},isLoading:t.props.isLoading,icon:t.props.icon,reason:t.removalReason,status:a}}function Bk(t,a,r=!1){return y.isValidElement(t)&&!Cc(t.type)?y.cloneElement(t,{closeToast:a.closeToast,toastProps:a,data:a.data,isPaused:r}):Ko(t)?t({closeToast:a.closeToast,toastProps:a,data:a.data,isPaused:r}):t}function eM({closeToast:t,theme:a,ariaLabel:r="close"}){return pa.createElement("button",{className:`Toastify__close-button Toastify__close-button--${a}`,type:"button",onClick:s=>{s.stopPropagation(),t(!0)},"aria-label":r},pa.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},pa.createElement("path",{fillRule:"evenodd",d:"M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"})))}function tM({delay:t,isRunning:a,closeToast:r,type:s="default",hide:i,className:c,controlledProgress:d,progress:m,rtl:h,isIn:g,theme:p}){let b=i||d&&m===0,j={animationDuration:`${t}ms`,animationPlayState:a?"running":"paused"};d&&(j.transform=`scaleX(${m})`);let _=yc("Toastify__progress-bar",d?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated",`Toastify__progress-bar-theme--${p}`,`Toastify__progress-bar--${s}`,{"Toastify__progress-bar--rtl":h}),N=Ko(c)?c({rtl:h,type:s,defaultClassName:_}):yc(_,c),k={[d&&m>=1?"onTransitionEnd":"onAnimationEnd"]:d&&m<1?null:()=>{g&&r()}};return pa.createElement("div",{className:"Toastify__progress-bar--wrp","data-hidden":b},pa.createElement("div",{className:`Toastify__progress-bar--bg Toastify__progress-bar-theme--${p} Toastify__progress-bar--${s}`}),pa.createElement("div",ue({role:"progressbar","aria-hidden":b?"true":"false","aria-label":"notification timer",className:N,style:j},k)))}var aM=1,Uk=()=>`${aM++}`;function rM(t,a,r){let s=1,i=0,c=[],d=[],m=a,h=new Map,g=new Set,p=T=>(g.add(T),()=>g.delete(T)),b=()=>{d=Array.from(h.values()),g.forEach(T=>T())},j=({containerId:T,toastId:E,updateId:O})=>{let R=T?T!==t:t!==1,Y=h.has(E)&&O==null;return R||Y},_=(T,E)=>{h.forEach(O=>{var R;(E==null||E===O.props.toastId)&&((R=O.toggle)==null||R.call(O,T))})},N=T=>{var E,O;(O=(E=T.props)==null?void 0:E.onClose)==null||O.call(E,T.removalReason),T.isActive=!1},k=T=>{if(T==null)h.forEach(N);else{let E=h.get(T);E&&N(E)}b()},C=()=>{i-=c.length,c=[]},D=T=>{var E,O;let{toastId:R,updateId:Y}=T.props,P=Y==null;T.staleId&&h.delete(T.staleId),T.isActive=!0,h.set(R,T),b(),r(T_(T,P?"added":"updated")),P&&((O=(E=T.props).onOpen)==null||O.call(E))};return{id:t,props:m,observe:p,toggle:_,removeToast:k,toasts:h,clearQueue:C,buildToast:(T,E)=>{if(j(E))return;let{toastId:O,updateId:R,data:Y,staleId:P,delay:U}=E,J=R==null;J&&i++;let ne=Se(ue(Se(ue({},m),{style:m.toastStyle,key:s++}),Object.fromEntries(Object.entries(E).filter(([he,ce])=>ce!=null))),{toastId:O,updateId:R,data:Y,isIn:!1,className:Px(E.className||m.toastClassName),progressClassName:Px(E.progressClassName||m.progressClassName),autoClose:E.isLoading?!1:XD(E.autoClose,m.autoClose),closeToast(he){h.get(O).removalReason=he,k(O)},deleteToast(){let he=h.get(O);if(he!=null){if(r(T_(he,"removed")),h.delete(O),i--,i<0&&(i=0),c.length>0){D(c.shift());return}b()}}});ne.closeButton=m.closeButton,E.closeButton===!1||Fx(E.closeButton)?ne.closeButton=E.closeButton:E.closeButton===!0&&(ne.closeButton=Fx(m.closeButton)?m.closeButton:!0);let ye={content:T,props:ne,staleId:P};m.limit&&m.limit>0&&i>m.limit&&J?c.push(ye):Pu(U)?setTimeout(()=>{D(ye)},U):D(ye)},setProps(T){m=T},setToggle:(T,E)=>{let O=h.get(T);O&&(O.toggle=E)},isToastActive:T=>{var E;return(E=h.get(T))==null?void 0:E.isActive},getSnapshot:()=>d}}var yn=new Map,_u=[],Ix=new Set,sM=t=>Ix.forEach(a=>a(t)),$k=()=>yn.size>0;function nM(){_u.forEach(t=>Wk(t.content,t.options)),_u=[]}var iM=(t,{containerId:a})=>{var r;return(r=yn.get(a||1))==null?void 0:r.toasts.get(t)};function Hk(t,a){var r;if(a)return!!((r=yn.get(a))!=null&&r.isToastActive(t));let s=!1;return yn.forEach(i=>{i.isToastActive(t)&&(s=!0)}),s}function oM(t){if(!$k()){_u=_u.filter(a=>t!=null&&a.options.toastId!==t);return}if(t==null||JD(t))yn.forEach(a=>{a.removeToast(t)});else if(t&&("containerId"in t||"id"in t)){let a=yn.get(t.containerId);a?a.removeToast(t.id):yn.forEach(r=>{r.removeToast(t.id)})}}var lM=(t={})=>{yn.forEach(a=>{a.props.limit&&(!t.containerId||a.id===t.containerId)&&a.clearQueue()})};function Wk(t,a){Fx(t)&&($k()||_u.push({content:t,options:a}),yn.forEach(r=>{r.buildToast(t,a)}))}function cM(t){var a;(a=yn.get(t.containerId||1))==null||a.setToggle(t.id,t.fn)}function Vk(t,a){yn.forEach(r=>{(a==null||!(a!=null&&a.containerId)||(a==null?void 0:a.containerId)===r.id)&&r.toggle(t,a==null?void 0:a.id)})}function dM(t){let a=t.containerId||1;return{subscribe(r){let s=rM(a,t,sM);yn.set(a,s);let i=s.observe(r);return nM(),()=>{i(),yn.delete(a)}},setProps(r){var s;(s=yn.get(a))==null||s.setProps(r)},getSnapshot(){var r;return(r=yn.get(a))==null?void 0:r.getSnapshot()}}}function uM(t){return Ix.add(t),()=>{Ix.delete(t)}}function mM(t){return t&&(Cc(t.toastId)||Pu(t.toastId))?t.toastId:Uk()}function Fu(t,a){return Wk(t,a),a.toastId}function Jh(t,a){return Se(ue({},a),{type:a&&a.type||t,toastId:mM(a)})}function Xh(t){return(a,r)=>Fu(a,Jh(t,r))}function nt(t,a){return Fu(t,Jh("default",a))}nt.loading=(t,a)=>Fu(t,Jh("default",ue({isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1},a)));function hM(t,{pending:a,error:r,success:s},i){let c;a&&(c=Cc(a)?nt.loading(a,i):nt.loading(a.render,ue(ue({},i),a)));let d={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},m=(g,p,b)=>{if(p==null){nt.dismiss(c);return}let j=Se(ue(ue({type:g},d),i),{data:b}),_=Cc(p)?{render:p}:p;return c?nt.update(c,ue(ue({},j),_)):nt(_.render,ue(ue({},j),_)),b},h=Ko(t)?t():t;return h.then(g=>m("success",s,g)).catch(g=>m("error",r,g)),h}nt.promise=hM;nt.success=Xh("success");nt.info=Xh("info");nt.error=Xh("error");nt.warning=Xh("warning");nt.warn=nt.warning;nt.dark=(t,a)=>Fu(t,Jh("default",ue({theme:"dark"},a)));function gM(t){oM(t)}nt.dismiss=gM;nt.clearWaitingQueue=lM;nt.isActive=Hk;nt.update=(t,a={})=>{let r=iM(t,a);if(r){let{props:s,content:i}=r,c=Se(ue(ue({delay:100},s),a),{toastId:a.toastId||t,updateId:Uk()});c.toastId!==t&&(c.staleId=t);let d=c.render||i;delete c.render,Fu(d,c)}};nt.done=t=>{nt.update(t,{progress:1})};nt.onChange=uM;nt.play=t=>Vk(!0,t);nt.pause=t=>Vk(!1,t);function fM(t){var a;let{subscribe:r,getSnapshot:s,setProps:i}=y.useRef(dM(t)).current;i(t);let c=(a=y.useSyncExternalStore(r,s,s))==null?void 0:a.slice();function d(m){if(!c)return[];let h=new Map;return t.newestOnTop&&c.reverse(),c.forEach(g=>{let{position:p}=g.props;h.has(p)||h.set(p,[]),h.get(p).push(g)}),Array.from(h,g=>m(g[0],g[1]))}return{getToastToRender:d,isToastActive:Hk,count:c==null?void 0:c.length}}function xM(t){let[a,r]=y.useState(!1),[s,i]=y.useState(!1),c=y.useRef(null),d=y.useRef({start:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,didMove:!1}).current,{autoClose:m,pauseOnHover:h,closeToast:g,onClick:p,closeOnClick:b}=t;cM({id:t.toastId,containerId:t.containerId,fn:r}),y.useEffect(()=>{if(t.pauseOnFocusLoss)return j(),()=>{_()}},[t.pauseOnFocusLoss]);function j(){document.hasFocus()||D(),window.addEventListener("focus",C),window.addEventListener("blur",D)}function _(){window.removeEventListener("focus",C),window.removeEventListener("blur",D)}function N(P){if(t.draggable===!0||t.draggable===P.pointerType){T();let U=c.current;d.canCloseOnClick=!0,d.canDrag=!0,U.style.transition="none",t.draggableDirection==="x"?(d.start=P.clientX,d.removalDistance=U.offsetWidth*(t.draggablePercent/100)):(d.start=P.clientY,d.removalDistance=U.offsetHeight*(t.draggablePercent===80?t.draggablePercent*1.5:t.draggablePercent)/100)}}function k(P){let{top:U,bottom:J,left:ne,right:ye}=c.current.getBoundingClientRect();P.nativeEvent.type!=="touchend"&&t.pauseOnHover&&P.clientX>=ne&&P.clientX<=ye&&P.clientY>=U&&P.clientY<=J?D():C()}function C(){r(!0)}function D(){r(!1)}function T(){d.didMove=!1,document.addEventListener("pointermove",O),document.addEventListener("pointerup",R)}function E(){document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",R)}function O(P){let U=c.current;if(d.canDrag&&U){d.didMove=!0,a&&D(),t.draggableDirection==="x"?d.delta=P.clientX-d.start:d.delta=P.clientY-d.start,d.start!==P.clientX&&(d.canCloseOnClick=!1);let J=t.draggableDirection==="x"?`${d.delta}px, var(--y)`:`0, calc(${d.delta}px + var(--y))`;U.style.transform=`translate3d(${J},0)`,U.style.opacity=`${1-Math.abs(d.delta/d.removalDistance)}`}}function R(){E();let P=c.current;if(d.canDrag&&d.didMove&&P){if(d.canDrag=!1,Math.abs(d.delta)>d.removalDistance){i(!0),t.closeToast(!0),t.collapseAll();return}P.style.transition="transform 0.2s, opacity 0.2s",P.style.removeProperty("transform"),P.style.removeProperty("opacity")}}let Y={onPointerDown:N,onPointerUp:k};return m&&h&&(Y.onMouseEnter=D,t.stacked||(Y.onMouseLeave=C)),b&&(Y.onClick=P=>{p&&p(P),d.canCloseOnClick&&g(!0)}),{playToast:C,pauseToast:D,isRunning:a,preventExitTransition:s,toastRef:c,eventHandlers:Y}}var pM=typeof window!="undefined"?y.useLayoutEffect:y.useEffect,Kh=i=>{var c=i,{theme:t,type:a,isLoading:r}=c,s=Dn(c,["theme","type","isLoading"]);return pa.createElement("svg",ue({viewBox:"0 0 24 24",width:"100%",height:"100%",fill:t==="colored"?"currentColor":`var(--toastify-icon-color-${a})`},s))};function yM(t){return pa.createElement(Kh,ue({},t),pa.createElement("path",{d:"M23.32 17.191L15.438 2.184C14.728.833 13.416 0 11.996 0c-1.42 0-2.733.833-3.443 2.184L.533 17.448a4.744 4.744 0 000 4.368C1.243 23.167 2.555 24 3.975 24h16.05C22.22 24 24 22.044 24 19.632c0-.904-.251-1.746-.68-2.44zm-9.622 1.46c0 1.033-.724 1.823-1.698 1.823s-1.698-.79-1.698-1.822v-.043c0-1.028.724-1.822 1.698-1.822s1.698.79 1.698 1.822v.043zm.039-12.285l-.84 8.06c-.057.581-.408.943-.897.943-.49 0-.84-.367-.896-.942l-.84-8.065c-.057-.624.25-1.095.779-1.095h1.91c.528.005.84.476.784 1.1z"}))}function bM(t){return pa.createElement(Kh,ue({},t),pa.createElement("path",{d:"M12 0a12 12 0 1012 12A12.013 12.013 0 0012 0zm.25 5a1.5 1.5 0 11-1.5 1.5 1.5 1.5 0 011.5-1.5zm2.25 13.5h-4a1 1 0 010-2h.75a.25.25 0 00.25-.25v-4.5a.25.25 0 00-.25-.25h-.75a1 1 0 010-2h1a2 2 0 012 2v4.75a.25.25 0 00.25.25h.75a1 1 0 110 2z"}))}function vM(t){return pa.createElement(Kh,ue({},t),pa.createElement("path",{d:"M12 0a12 12 0 1012 12A12.014 12.014 0 0012 0zm6.927 8.2l-6.845 9.289a1.011 1.011 0 01-1.43.188l-4.888-3.908a1 1 0 111.25-1.562l4.076 3.261 6.227-8.451a1 1 0 111.61 1.183z"}))}function _M(t){return pa.createElement(Kh,ue({},t),pa.createElement("path",{d:"M11.983 0a12.206 12.206 0 00-8.51 3.653A11.8 11.8 0 000 12.207 11.779 11.779 0 0011.8 24h.214A12.111 12.111 0 0024 11.791 11.766 11.766 0 0011.983 0zM10.5 16.542a1.476 1.476 0 011.449-1.53h.027a1.527 1.527 0 011.523 1.47 1.475 1.475 0 01-1.449 1.53h-.027a1.529 1.529 0 01-1.523-1.47zM11 12.5v-6a1 1 0 012 0v6a1 1 0 11-2 0z"}))}function wM(){return pa.createElement("div",{className:"Toastify__spinner"})}var zx={info:bM,warning:yM,success:vM,error:_M,spinner:wM},kM=t=>t in zx;function jM({theme:t,type:a,isLoading:r,icon:s}){let i=null,c={theme:t,type:a};return s===!1||(Ko(s)?i=s(Se(ue({},c),{isLoading:r})):y.isValidElement(s)?i=y.cloneElement(s,c):r?i=zx.spinner():kM(a)&&(i=zx[a](c))),i}var NM=t=>{let{isRunning:a,preventExitTransition:r,toastRef:s,eventHandlers:i,playToast:c}=xM(t),{closeButton:d,children:m,autoClose:h,onClick:g,type:p,hideProgressBar:b,closeToast:j,transition:_,position:N,className:k,style:C,progressClassName:D,updateId:T,role:E,progress:O,rtl:R,toastId:Y,deleteToast:P,isIn:U,isLoading:J,closeOnClick:ne,theme:ye,ariaLabel:he}=t,ce=yc("Toastify__toast",`Toastify__toast-theme--${ye}`,`Toastify__toast--${p}`,{"Toastify__toast--rtl":R},{"Toastify__toast--close-on-click":ne}),se=Ko(k)?k({rtl:R,position:N,type:p,defaultClassName:ce}):yc(ce,k),ee=jM(t),te=!!O||!h,W={closeToast:j,type:p,theme:ye},I=null;return d===!1||(Ko(d)?I=d(W):y.isValidElement(d)?I=y.cloneElement(d,W):I=eM(W)),pa.createElement(_,{isIn:U,done:P,position:N,preventExitTransition:r,nodeRef:s,playToast:c},pa.createElement("div",ue(Se(ue({id:Y,tabIndex:0,onClick:g,"data-in":U,className:se},i),{style:C,ref:s}),U&&{role:E,"aria-label":he}),ee!=null&&pa.createElement("div",{className:yc("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!J})},ee),Bk(m,t,!a),I,!t.customProgressBar&&pa.createElement(tM,Se(ue({},T&&!te?{key:`p-${T}`}:{}),{rtl:R,theme:ye,delay:h,isRunning:a,isIn:U,closeToast:j,hide:b,type:p,className:D,controlledProgress:te,progress:O||0}))))},SM=(t,a=!1)=>({enter:`Toastify--animate Toastify__${t}-enter`,exit:`Toastify--animate Toastify__${t}-exit`,appendPosition:a}),Lc=QD(SM("bounce",!0)),CM={position:"top-right",transition:Lc,autoClose:5e3,closeButton:!0,pauseOnHover:!0,pauseOnFocusLoss:!0,draggable:"touch",draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light","aria-label":"Notifications Alt+T",hotKeys:t=>t.altKey&&t.code==="KeyT"};function Xd(t){let a=ue(ue({},CM),t),r=t.stacked,[s,i]=y.useState(!0),c=y.useRef(null),{getToastToRender:d,isToastActive:m,count:h}=fM(a),{className:g,style:p,rtl:b,containerId:j,hotKeys:_}=a;function N(C){let D=yc("Toastify__toast-container",`Toastify__toast-container--${C}`,{"Toastify__toast-container--rtl":b});return Ko(g)?g({position:C,rtl:b,defaultClassName:D}):yc(D,Px(g))}function k(){r&&(i(!0),nt.play())}return pM(()=>{var C;if(r){let D=c.current.querySelectorAll('[data-in="true"]'),T=12,E=(C=a.position)==null?void 0:C.includes("top"),O=0,R=0;Array.from(D).reverse().forEach((Y,P)=>{let U=Y;U.classList.add("Toastify__toast--stacked"),P>0&&(U.dataset.collapsed=`${s}`),U.dataset.pos||(U.dataset.pos=E?"top":"bot");let J=O*(s?.2:1)+(s?0:T*P);U.style.setProperty("--y",`${E?J:J*-1}px`),U.style.setProperty("--g",`${T}`),U.style.setProperty("--s",`${1-(s?R:0)}`),O+=U.offsetHeight,R+=.025})}},[s,h,r]),y.useEffect(()=>{function C(D){var T;let E=c.current;_(D)&&((T=E.querySelector('[tabIndex="0"]'))==null||T.focus(),i(!1),nt.pause()),D.key==="Escape"&&(document.activeElement===E||E!=null&&E.contains(document.activeElement))&&(i(!0),nt.play())}return document.addEventListener("keydown",C),()=>{document.removeEventListener("keydown",C)}},[_]),pa.createElement("section",{ref:c,className:"Toastify",id:j,onMouseEnter:()=>{r&&(i(!1),nt.pause())},onMouseLeave:k,"aria-live":"polite","aria-atomic":"false","aria-relevant":"additions text","aria-label":a["aria-label"]},d((C,D)=>{let T=D.length?ue({},p):Se(ue({},p),{pointerEvents:"none"});return pa.createElement("div",{tabIndex:-1,className:N(C),"data-stacked":r,style:T,key:`c-${C}`},D.map(({content:E,props:O})=>pa.createElement(NM,Se(ue({},O),{stacked:r,collapseAll:k,isIn:m(O.toastId,O.containerId),key:`t-${O.key}`}),E)))}))}const TM=({doctype:t,value:a,onChange:r,disabled:s=!1,placeholder:i="Search...",filters:c={}})=>{const[d,m]=y.useState(""),[h,g]=y.useState([]),[p,b]=y.useState(!1),[j,_]=y.useState(!1),N=y.useRef(null),k=y.useRef(null),C=y.useCallback((E="")=>Q(null,null,function*(){if(t){_(!0);try{const O=new URLSearchParams({doctype:t,txt:E,page_length:"20"});c&&Object.keys(c).length>0&&O.append("filters",JSON.stringify(c));const R=yield mt.apiCall(`/api/method/frappe.desk.search.search_link?${O.toString()}`);g(R||[])}catch(O){console.error(`Error fetching ${t} links:`,O),g([])}finally{_(!1)}}}),[t,c]);y.useEffect(()=>{if(p)return k.current&&clearTimeout(k.current),k.current=setTimeout(()=>C(d),300),()=>{k.current&&clearTimeout(k.current)}},[d,p,C]),y.useEffect(()=>{p&&C(d)},[p]),y.useEffect(()=>{const E=O=>{N.current&&!N.current.contains(O.target)&&(b(!1),m(""))};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const D=E=>{r(E),m(""),b(!1)},T=()=>{r(""),m("")};return e.jsxs("div",{ref:N,className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Js,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400",size:12}),e.jsx("input",{type:"text",value:p?d:a,placeholder:i,disabled:s,className:`w-full pl-9 pr-8 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md
focus:outline-none focus:ring-2 focus:ring-blue-500
disabled:bg-gray-100 dark:disabled:bg-gray-700
bg-white dark:bg-gray-700 text-gray-900 dark:text-white`,onFocus:()=>!s&&b(!0),onChange:E=>{m(E.target.value),b(!0)}}),a&&!s&&!p&&e.jsx("button",{type:"button",onClick:T,className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:e.jsx(wt,{size:12})})]}),p&&!s&&e.jsx("div",{className:"absolute z-50 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-md shadow-lg max-h-40 overflow-auto",children:j?e.jsxs("div",{className:"p-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:[e.jsx(ya,{className:"animate-spin inline mr-2",size:12}),"Loading..."]}):h.length>0?e.jsx("ul",{children:h.map((E,O)=>e.jsxs("li",{onClick:()=>D(E.value),className:`px-3 py-2 cursor-pointer text-sm hover:bg-blue-500 hover:text-white
${a===E.value?"bg-blue-50 dark:bg-blue-900/30":""}`,children:[E.value,E.description&&e.jsx("span",{className:"text-xs text-gray-500 ml-2",children:E.description})]},O))}):e.jsx("div",{className:"p-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:"No results found"})})]})},EM=({doctype:t,isOpen:a,onClose:r,onSuccess:s,initialValues:i={},parentFilters:c={},customConfig:d})=>{const[m,h]=y.useState({}),[g,p]=y.useState({}),[b,j]=y.useState(!1),[_,N]=y.useState(null);y.useEffect(()=>{const E=d||VD(t);if(N(E),E){const O={};E.fields.forEach(R=>{R.defaultValue!==void 0?O[R.fieldname]=R.defaultValue:R.fieldtype==="Check"?O[R.fieldname]=0:O[R.fieldname]=""}),h(ue(ue({},O),i))}},[t,d,i]),y.useEffect(()=>{if(a&&_){const E={};_.fields.forEach(O=>{O.defaultValue!==void 0?E[O.fieldname]=O.defaultValue:O.fieldtype==="Check"?E[O.fieldname]=0:E[O.fieldname]=""}),h(ue(ue({},E),i)),p({})}},[a,_,i]);const k=y.useCallback((E,O)=>{h(R=>Se(ue({},R),{[E]:O})),p(R=>{const Y=ue({},R);return delete Y[E],Y})},[]),C=y.useCallback(()=>{if(!_)return!1;const E={};if(_.fields.forEach(O=>{if(O.required&&!O.hidden){const R=m[O.fieldname];(R==null||R==="")&&(E[O.fieldname]=`${O.label} is required`)}}),_.validateBeforeCreate){const O=_.validateBeforeCreate(m);if(O)return nt.error(O,{position:"top-right",autoClose:4e3,icon:e.jsx(fa,{})}),!1}return p(E),Object.keys(E).length===0},[_,m]),D=E=>Q(null,null,function*(){if(E.preventDefault(),!(!C()||!_)){j(!0);try{const O={};Object.entries(m).forEach(([Y,P])=>{P!==""&&P!==null&&P!==void 0&&(O[Y]=P)});const R=yield mt.apiCall(`/api/resource/${_.doctype}`,{method:"POST",body:JSON.stringify(O)});if(R!=null&&R.data){const Y=R.data;nt.success(`${_.title.replace("Create New ","")} created successfully!`,{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),_.afterCreate&&_.afterCreate(Y),s(Y),r()}else throw new Error("Failed to create record")}catch(O){console.error("Error creating record:",O);const R=O instanceof Error?O.message:"Unknown error occurred";R.includes("Duplicate")||R.includes("already exists")?nt.error("A record with this name already exists. Please use a different name.",{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})}):nt.error(`Failed to create: ${R}`,{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})})}finally{j(!1)}}}),T=E=>{if(E.hidden)return null;const O=m[E.fieldname],R=g[E.fieldname],Y=E.readOnly||b;if(E.dependsOn&&!m[E.dependsOn])return null;const P=`w-full px-3 py-2 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500
${R?"border-red-500":"border-gray-300 dark:border-gray-600"}
${Y?"bg-gray-100 dark:bg-gray-700 cursor-not-allowed":"bg-white dark:bg-gray-700"}
text-gray-900 dark:text-white`;switch(E.fieldtype){case"Data":return e.jsx("input",{type:"text",value:O||"",onChange:U=>k(E.fieldname,U.target.value),placeholder:E.placeholder,disabled:Y,className:P});case"Text":return e.jsx("textarea",{value:O||"",onChange:U=>k(E.fieldname,U.target.value),placeholder:E.placeholder,disabled:Y,rows:3,className:`${P} resize-none`});case"Select":return e.jsxs("select",{value:O||"",onChange:U=>k(E.fieldname,U.target.value),disabled:Y,className:P,children:[e.jsxs("option",{value:"",children:["Select ",E.label]}),(E.options||[]).map(U=>{const J=typeof U=="string"?U:U.value,ne=typeof U=="string"?U:U.label;return e.jsx("option",{value:J,children:ne},J)})]});case"Link":return e.jsx(TM,{doctype:E.linkDoctype||"",value:O||"",onChange:U=>k(E.fieldname,U),disabled:Y,placeholder:E.placeholder,filters:E.linkFilters||{}});case"Check":return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:O===1||O===!0,onChange:U=>k(E.fieldname,U.target.checked?1:0),disabled:Y,className:`w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500
dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2
dark:bg-gray-700 dark:border-gray-600`}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:E.description||E.label})]});case"Int":return e.jsx("input",{type:"number",value:O||"",onChange:U=>k(E.fieldname,parseInt(U.target.value)||""),placeholder:E.placeholder,disabled:Y,step:"1",className:P});case"Float":return e.jsx("input",{type:"number",value:O||"",onChange:U=>k(E.fieldname,parseFloat(U.target.value)||""),placeholder:E.placeholder,disabled:Y,step:"0.01",className:P});case"Date":return e.jsx("input",{type:"date",value:O||"",onChange:U=>k(E.fieldname,U.target.value),disabled:Y,className:P});case"Datetime":return e.jsx("input",{type:"datetime-local",value:O||"",onChange:U=>k(E.fieldname,U.target.value),disabled:Y,className:P});default:return e.jsx("input",{type:"text",value:O||"",onChange:U=>k(E.fieldname,U.target.value),placeholder:E.placeholder,disabled:Y,className:P})}};return!a||!_?null:e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[9999]",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white flex items-center gap-2",children:[e.jsx(Zs,{className:"text-blue-500",size:16}),_.title]}),e.jsx("button",{type:"button",onClick:r,disabled:b,className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded transition-colors disabled:opacity-50",children:e.jsx(wt,{size:18})})]}),e.jsx("form",{onSubmit:D,className:"flex-1 overflow-y-auto p-4",children:e.jsx("div",{className:"space-y-4",children:_.fields.map(E=>E.hidden||E.dependsOn&&!m[E.dependsOn]?null:e.jsxs("div",{children:[E.fieldtype!=="Check"&&e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:[E.label,E.required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),T(E),E.description&&E.fieldtype!=="Check"&&e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:E.description}),g[E.fieldname]&&e.jsxs("p",{className:"mt-1 text-xs text-red-500 flex items-center gap-1",children:[e.jsx(fa,{size:10}),g[E.fieldname]]})]},E.fieldname))})}),e.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("button",{type:"button",onClick:r,disabled:b,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 hover:bg-gray-300 rounded-lg transition-colors disabled:opacity-50",children:"Cancel"}),e.jsx("button",{type:"submit",onClick:D,disabled:b,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-lg transition-colors disabled:opacity-50 flex items-center gap-2",children:b?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin",size:14}),"Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Zs,{size:14}),"Create"]})})]})]})})},AM={},Ut=({label:t,doctype:a,value:r,onChange:s,placeholder:i,disabled:c=!1,filters:d,compact:m=!1,usePortal:h=!1,allowQuickCreate:g=!1,onQuickCreateSuccess:p,quickCreateInitialValues:b={},query:j})=>{const{t:_}=ca(),[N,k]=y.useState([]),[C,D]=y.useState(""),[T,E]=y.useState(!1),[O,R]=y.useState(!1),[Y,P]=y.useState({top:0,left:0,width:0}),[U,J]=y.useState(!1),[ne,ye]=y.useState(null),he=y.useRef(null),ce=y.useRef(null),se=y.useRef(null),ee=y.useRef(null),te=y.useRef(""),W=y.useRef(!1),I=d||AM,oe=y.useMemo(()=>JSON.stringify(I),[I]),ae=y.useMemo(()=>{const z=qD(a);return console.log(`[LinkField] ${a} hasQuickCreateConfig: ${z}`),z},[a]);y.useEffect(()=>{ye(null),g&&ae?(console.log(`[LinkField] Checking permission for ${a}...`),YD(a).then(z=>{console.log(`[LinkField] Permission for ${a}: ${z}`),ye(z)}).catch(z=>{console.error(`[LinkField] Permission check failed for ${a}:`,z),ye(!1)})):(ye(!1),g&&!ae&&console.warn(`[LinkField] ${a}: allowQuickCreate=true but no config in QuickCreateConfig.ts`))},[g,a,ae]);const F=y.useMemo(()=>{const z=g&&ae&&ne===!0;return console.log(`[LinkField] canQuickCreate for ${a}: ${z}`,{allowQuickCreate:g,hasQuickCreateConfig:ae,hasPermission:ne}),z},[g,ae,ne,a]),M=y.useCallback((z="",Ne=!1)=>Q(null,null,function*(){const Xe=`${z}-${oe}-${j||""}`;if(!(!Ne&&te.current===Xe)){te.current=Xe,R(!0);try{let gt=null;if(j){const St=new URLSearchParams({txt:z,doctype:a,searchfield:"name",start:"0",page_len:"50"});I&&Object.keys(I).length>0&&St.append("filters",JSON.stringify(I));const Ht=yield mt.apiCall(`/api/method/${j}?${St.toString()}`);Array.isArray(Ht)?gt=Ht.map(Mt=>Array.isArray(Mt)?{value:Mt[0],description:Mt[1]||void 0}:{value:Mt.value||Mt.name||Mt,description:Mt.description}):gt=[]}else{const St=new URLSearchParams({doctype:a,txt:z,page_length:"50"});I&&Object.keys(I).length>0&&St.append("filters",JSON.stringify(I)),gt=yield mt.apiCall(`/api/method/frappe.desk.search.search_link?${St.toString()}`)}k(gt||[])}catch(gt){console.error(`Error fetching ${a} links:`,gt),k([])}finally{R(!1)}}}),[a,oe,I,j]),B=y.useCallback(z=>{ee.current&&clearTimeout(ee.current),ee.current=setTimeout(()=>{M(z)},300)},[M]);y.useEffect(()=>{T&&!W.current&&(W.current=!0,M(C||"",!0)),T||(W.current=!1,te.current="")},[T]),y.useEffect(()=>()=>{ee.current&&clearTimeout(ee.current)},[]);const X=y.useCallback(()=>{if(h&&ce.current){const z=ce.current.getBoundingClientRect();P({top:z.bottom+window.scrollY,left:z.left+window.scrollX,width:z.width})}},[h]);y.useEffect(()=>{if(T&&h){X();const z=()=>X();return window.addEventListener("scroll",z,!0),window.addEventListener("resize",z),()=>{window.removeEventListener("scroll",z,!0),window.removeEventListener("resize",z)}}},[T,h,X]),y.useEffect(()=>{const z=Ne=>{const Xe=Ne.target,gt=he.current&&!he.current.contains(Xe),St=h&&se.current&&!se.current.contains(Xe);h?gt&&St&&(E(!1),D("")):gt&&(E(!1),D(""))};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[h]);const K=z=>{s(z),D(""),E(!1)},we=()=>{s(""),D(""),E(!1)},be=()=>{E(!1),D(""),J(!0)},ke=z=>{const Ne=z.name||z[Object.keys(z)[0]];K(Ne),p&&p(z)},Me=()=>{const z=`bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600
rounded-md w-full shadow-lg ${m?"mt-0.5":"mt-1"}`,Ne=h?{position:"fixed",top:`${Y.top}px`,left:`${Y.left}px`,width:`${Y.width}px`,zIndex:1050,marginTop:m?"2px":"4px"}:{};if(!T||c)return null;const Xe=e.jsxs("div",{ref:se,children:[O&&e.jsxs("div",{className:`${h?"":"absolute z-[1050]"} ${z} text-center text-gray-500 dark:text-gray-400
${m?"p-1.5 text-[10px]":"p-3 text-sm"}`,style:Ne,children:[e.jsx("span",{className:"inline-block animate-spin mr-2",children:"⏳"}),_("linkField.loading")]}),!O&&e.jsxs("div",{className:`${h?"":"absolute z-[1050]"} ${z} overflow-hidden`,style:Ne,children:[N.length>0?e.jsx("ul",{className:`overflow-auto ${m?"max-h-36":"max-h-48"}`,children:N.map((gt,St)=>e.jsxs("li",{onClick:()=>K(gt.value),className:`cursor-pointer text-gray-900 dark:text-gray-100
hover:bg-blue-500 dark:hover:bg-blue-600 hover:text-white
${m?"px-2 py-1 text-xs":"px-3 py-2 text-sm"}
${r===gt.value?"bg-blue-50 dark:bg-blue-700 font-semibold":""}`,children:[gt.value,gt.description&&e.jsx("span",{className:`text-gray-600 dark:text-gray-300 ml-2
${m?"text-[9px] ml-1":"text-xs ml-2"}`,children:gt.description})]},St))}):e.jsx("div",{className:`text-center text-gray-500 dark:text-gray-400
${m?"p-1.5 text-[10px]":"p-3 text-sm"}`,children:_("linkField.noResultsFound")}),F&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700"}),e.jsxs("div",{onClick:be,className:`cursor-pointer flex items-center gap-2
text-green-600 dark:text-green-400
hover:bg-green-50 dark:hover:bg-green-900/20
hover:text-green-700 dark:hover:text-green-300
transition-colors
${m?"px-2 py-1.5 text-xs":"px-3 py-2.5 text-sm"}`,children:[e.jsx(Zs,{size:m?10:12}),e.jsx("span",{className:"font-medium",children:_("linkField.createNewDoctype",{doctype:a.replace(/_/g," ")})})]})]})]})]});return h?h2.createPortal(Xe,document.body):Xe};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:he,className:`relative w-full ${m?"mb-2":"mb-4"}`,children:[e.jsx("label",{className:`block font-medium text-gray-700 dark:text-gray-300 ${m?"text-[10px] mb-0.5":"text-sm mb-1"}`,children:t}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:ce,type:"text",value:T?C:r,placeholder:i||_("linkField.selectLabel",{label:t}),disabled:c,className:`w-full border border-gray-300 dark:border-gray-600 rounded-md
focus:outline-none disabled:bg-gray-100 dark:disabled:bg-gray-700
bg-white dark:bg-gray-700 text-gray-900 dark:text-white
${m?"px-2 py-1 text-xs focus:ring-1 focus:ring-blue-500 rounded":"px-3 py-2 text-sm focus:ring-2 focus:ring-blue-500"}
${r?m?"pr-5":"pr-8":""}`,onFocus:()=>{c||(E(!0),D(""),h&&X())},onChange:z=>{const Ne=z.target.value;D(Ne),B(Ne)}}),r&&!c&&!T&&e.jsx("button",{type:"button",onClick:we,className:`absolute top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300
${m?"right-1 text-xs":"right-2 text-sm"}`,children:"✕"})]}),Me()]}),e.jsx(EM,{doctype:a,isOpen:U,onClose:()=>J(!1),onSuccess:ke,initialValues:b,parentFilters:I})]})},Rc=({currentPage:t,totalCount:a=0,pageSize:r,hasMore:s=!1,itemLabel:i,onPageChange:c,className:d=""})=>{const{t:m}=ca(),h=i!=null?i:m("listPages.results"),g=a>0?Math.max(1,Math.ceil(a/r)):0,p=a>0,b=(t-1)*r+1,j=p?Math.min(t*r,a):t*r,[_,N]=y.useState(""),k=T=>{T.preventDefault();const E=parseInt(_.trim(),10);if(!Number.isNaN(E)&&E>=1){const O=p?Math.min(E,g):E;c(O),N("")}},C=()=>{if(g<=7)return Array.from({length:g},(E,O)=>O+1);const T=[];T.push(1),t>3&&T.push("ellipsis");for(let E=Math.max(2,t-1);E<=Math.min(g-1,t+1);E++)T.includes(E)||T.push(E);return t<g-2&&T.push("ellipsis"),g>1&&T.push(g),T};return s||t>1||p&&g>1?e.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 px-6 py-4 border-t border-gray-200 dark:border-gray-700 ${d}`,children:[e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:p?m("pagination.showingToOf",{start:b,end:j,total:a,label:h}):m("pagination.showingTo",{start:b,end:j,label:h})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>c(t-1),disabled:t<=1,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed",children:m("pagination.previous")}),p&&g>1&&e.jsx("div",{className:"flex items-center gap-1",children:C().map((T,E)=>T==="ellipsis"?e.jsx("span",{className:"px-2 text-gray-500 dark:text-gray-400",children:"…"},`e-${E}`):e.jsx("button",{type:"button",onClick:()=>c(T),className:`min-w-[2rem] px-2 py-1 text-sm font-medium rounded-lg transition-colors ${T===t?"bg-blue-600 text-white border border-blue-600":"text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600"}`,children:T},T))}),e.jsx("button",{type:"button",onClick:()=>c(t+1),disabled:p?t>=g:!s,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed",children:m("pagination.next")}),e.jsxs("form",{onSubmit:k,className:"flex items-center gap-1 ml-2",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400 whitespace-nowrap",children:m("pagination.goTo")}),e.jsx("input",{type:"number",min:1,max:p?g:void 0,value:_,onChange:T=>N(T.target.value),placeholder:p?`1-${g}`:m("pagination.page"),className:"w-14 px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),e.jsx("button",{type:"submit",className:"px-2 py-1 text-sm font-medium text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700",children:m("pagination.go")})]})]})]}):null};function Ks(t){if(!t||typeof t!="object")return[];const a=[];for(const[r,s]of Object.entries(t))if(!(s==null||s===""))if(r==="creation_from")a.push(["creation",">=",s]);else if(r==="creation_to"){const i=new Date(s);if(!isNaN(i.getTime())){i.setDate(i.getDate()+1);const c=i.toISOString().slice(0,10);a.push(["creation","<",c])}}else if(r==="modified_from")a.push(["modified",">=",s]);else if(r==="modified_to"){const i=new Date(s);if(!isNaN(i.getTime())){i.setDate(i.getDate()+1);const c=i.toISOString().slice(0,10);a.push(["modified","<",c])}}else Array.isArray(s)&&s.length>=2?a.push([r,s[0],s[1]]):a.push([r,"=",s]);return a}function el(t,a,r){if(!t||!a&&!r)return{};const s={};return t==="creation"?(a&&(s.creation_from=a),r&&(s.creation_to=r)):(a&&(s.modified_from=a),r&&(s.modified_to=r)),s}const Np=Object.freeze(Object.defineProperty({__proto__:null,buildDateRangeFilters:el,toFrappeFilterArray:Ks},Symbol.toStringTag,{value:"Module"}));function OM(t,a,r){return Q(this,null,function*(){var s,i;try{const d=yield(yield fetch(`/api/resource/${t}/${encodeURIComponent(a)}`,{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({custom_delete_status:r})})).json();return d.data||d.message?{success:!0}:{success:!1,error:d.exc_type==="ValidationError"?d.exception||"Validation error":d._server_messages?((i=(s=JSON.parse(d._server_messages))==null?void 0:s[0])==null?void 0:i.message)||"Unknown error":"Failed to update delete status"}}catch(c){return{success:!1,error:c instanceof Error?c.message:"Network error"}}})}function DM(t,a){return console.log("[DeleteRequest] userRoles:",t,"| isSystemManager:",a),a||t.includes("System Manager")?"System Manager":t.includes("Cluster Manager")?"Cluster Manager":t.includes("Contractor Supervisor")||t.includes("DR Approver")?"Contractor Supervisor":t.includes("End user")?"End user":"Other"}function MM(t,a){const r={showRaiseRequest:!1,showApproveAsSupervisor:!1,showApproveAsCM:!1,showDirectDelete:!1};return a==="Deleted"?r:!a||a===""?t==="End user"?r:t==="System Manager"||t==="Cluster Manager"?Se(ue({},r),{showDirectDelete:!0}):t==="Contractor Supervisor"?Se(ue({},r),{showRaiseRequest:!0}):Se(ue({},r),{showRaiseRequest:!0}):a==="Delete Request With Supervisor"?t==="Contractor Supervisor"?Se(ue({},r),{showApproveAsSupervisor:!0}):t==="System Manager"||t==="Cluster Manager"?Se(ue({},r),{showApproveAsCM:!0}):r:a==="Delete Request With CM"&&(t==="System Manager"||t==="Cluster Manager")?Se(ue({},r),{showApproveAsCM:!0}):r}function LM(t,a){return t==="reject"?"":t==="direct"||t==="cm_approve"?"Deleted":t==="supervisor_approve"||a==="Contractor Supervisor"?"Delete Request With CM":"Delete Request With Supervisor"}function RM({doctype:t,docname:a,currentDeleteStatus:r,userRoles:s,isSystemManager:i,onSuccess:c}){const[d,m]=y.useState(!1),[h,g]=y.useState(null),[p,b]=y.useState(r),j=p!==r?p:r,_=y.useMemo(()=>DM(s,i),[s,i]),N=y.useMemo(()=>MM(_,j),[_,j]),k=y.useCallback(C=>Q(null,null,function*(){if(!a)return;m(!0),g(null);const D=LM(C,_),T=yield OM(t,a,D);m(!1),T.success?(b(D),c==null||c(D)):g(T.error||"Failed to update delete status")}),[t,a,_,c]);return Se(ue({},N),{deleteStatus:j,loading:d,error:h,highestRole:_,raiseRequest:()=>k("raise"),approveAsSupervisor:()=>k("supervisor_approve"),approveAsCM:()=>k("cm_approve"),directDelete:()=>k("direct"),rejectRequest:()=>k("reject")})}const E_=({title:t,message:a,confirmLabel:r,confirmClass:s,icon:i,loading:c,onConfirm:d,onCancel:m})=>e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[9999]",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl p-6 max-w-md w-full mx-4 shadow-2xl",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx("span",{className:"mt-0.5 flex-shrink-0 text-xl",children:i}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-800 dark:text-white",children:t}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:a})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:m,disabled:c,className:"px-4 py-2 bg-gray-200 hover:bg-gray-300 dark:bg-gray-600 dark:hover:bg-gray-500 text-gray-700 dark:text-gray-200 rounded-lg text-sm font-medium disabled:opacity-50",children:"Cancel"}),e.jsxs("button",{onClick:d,disabled:c,className:`px-4 py-2 text-white rounded-lg text-sm font-medium flex items-center gap-2 disabled:opacity-50 ${s}`,children:[c?e.jsx(ya,{className:"animate-spin",size:13}):null,r]})]})]})}),A_=({primaryLabel:t,primaryClass:a,primaryIcon:r,onPrimary:s,secondaryLabel:i,secondaryClass:c,secondaryIcon:d,onSecondary:m,disabled:h=!1,loading:g=!1})=>{const[p,b]=y.useState(!1),j=y.useRef(null);return y.useEffect(()=>{const _=N=>{j.current&&!j.current.contains(N.target)&&b(!1)};return p&&document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[p]),e.jsxs("div",{ref:j,className:"relative inline-flex rounded-lg overflow-visible",children:[e.jsxs("button",{type:"button",disabled:h,onClick:s,className:`px-4 py-2 text-white text-sm font-medium flex items-center gap-2 disabled:opacity-50 transition-colors rounded-l-lg ${a}`,children:[g?e.jsx(ya,{className:"animate-spin",size:13}):r,t]}),e.jsx("span",{className:"w-px bg-white/30"}),e.jsx("button",{type:"button",disabled:h,onClick:()=>b(_=>!_),className:`px-2 py-2 text-white text-sm font-medium flex items-center disabled:opacity-50 transition-colors rounded-r-lg ${a}`,"aria-label":"More options",children:e.jsx(cs,{size:11,className:`transition-transform ${p?"rotate-180":""}`})}),p&&e.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg min-w-[160px] overflow-hidden",children:e.jsxs("button",{type:"button",disabled:h,onClick:()=>{b(!1),m()},className:`w-full px-4 py-2.5 text-sm font-medium flex items-center gap-2 transition-colors ${c}`,children:[d,i]})})]})},O_=({status:t})=>{if(!t)return null;const r={"Delete Request With Supervisor":{bg:"bg-orange-100 dark:bg-orange-900/30",text:"text-orange-700 dark:text-orange-300",label:"⏳ Delete Request Pending Supervisor"},"Delete Request With CM":{bg:"bg-yellow-100 dark:bg-yellow-900/30",text:"text-yellow-700 dark:text-yellow-300",label:"⏳ Delete Request Pending CM"},Deleted:{bg:"bg-red-100 dark:bg-red-900/30",text:"text-red-700 dark:text-red-300",label:"🗑 Marked for Deletion"}}[t];return r?e.jsx("span",{className:`inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium ${r.bg} ${r.text}`,children:r.label}):null},Ll=({doctype:t,docname:a,currentDeleteStatus:r,userRoles:s,isSystemManager:i,onStatusChange:c,className:d="",inline:m=!1,redirectOnDelete:h,triggerMode:g=!1})=>{const p=qa(),[b,j]=y.useState(null),[_,N]=y.useState(!1),k=y.useRef(null),{showRaiseRequest:C,showApproveAsSupervisor:D,showApproveAsCM:T,showDirectDelete:E,deleteStatus:O,loading:R,error:Y,raiseRequest:P,approveAsSupervisor:U,approveAsCM:J,directDelete:ne,rejectRequest:ye}=RM({doctype:t,docname:a,currentDeleteStatus:r,userRoles:s,isSystemManager:i,onSuccess:te=>{c==null||c(te),te==="Deleted"&&h&&p(h)}});y.useEffect(()=>{if(!_)return;const te=W=>{k.current&&!k.current.contains(W.target)&&N(!1)};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[_]);const he=()=>Q(null,null,function*(){if(!b)return;yield{raise:P,supervisor_approve:U,supervisor_reject:ye,cm_approve:J,cm_reject:ye,direct:ne}[b](),j(null)}),ce={raise:{title:"Request Deletion",message:"This will raise a deletion request to the Supervisor for review.",confirmLabel:"Raise Request",confirmClass:"bg-orange-600 hover:bg-orange-700",icon:e.jsx(fa,{className:"text-orange-500"})},supervisor_approve:{title:"Approve Deletion Request",message:"This will forward the deletion request to the Cluster Manager for final approval.",confirmLabel:"Approve & Forward",confirmClass:"bg-yellow-600 hover:bg-yellow-700",icon:e.jsx(ea,{className:"text-yellow-500"})},supervisor_reject:{title:"Reject Deletion Request",message:"This will reject the deletion request and clear the status. The record will remain active.",confirmLabel:"Reject Request",confirmClass:"bg-gray-600 hover:bg-gray-700",icon:e.jsx(ei,{className:"text-gray-500"})},cm_approve:{title:"Approve & Mark as Deleted",message:"This will mark the record as Deleted.",confirmLabel:"Approve & Delete",confirmClass:"bg-red-600 hover:bg-red-700",icon:e.jsx(Na,{className:"text-red-500"})},cm_reject:{title:"Reject Deletion Request",message:"This will reject the deletion request and clear the status. The record will remain active.",confirmLabel:"Reject Request",confirmClass:"bg-gray-600 hover:bg-gray-700",icon:e.jsx(ei,{className:"text-gray-500"})},direct:{title:"Mark as Deleted",message:"This will immediately Delete The Record.",confirmLabel:"Delete",confirmClass:"bg-red-600 hover:bg-red-700",icon:e.jsx(Na,{className:"text-red-500"})}},se={"Delete Request With Supervisor":"Delete Request Pending Supervisor","Delete Request With CM":"Delete Request Pending Cluster Manager",Deleted:"Marked for Deletion"};if(g){const W=!!O?"text-orange-500 dark:text-orange-400 hover:bg-orange-50 dark:hover:bg-orange-900/20":"text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20";return!C&&!D&&!T&&!E&&!O?null:e.jsxs(e.Fragment,{children:[b&&e.jsx(E_,Se(ue({},ce[b]),{loading:R,onConfirm:he,onCancel:()=>j(null)})),e.jsxs("div",{className:"relative",ref:k,children:[e.jsx("button",{type:"button",onClick:()=>N(oe=>!oe),title:O?se[O]:"Request Deletion",className:`p-2 rounded transition-colors ${W}`,disabled:R||!a,children:R?e.jsx(ya,{className:"animate-spin",size:14}):e.jsx(Na,{size:14})}),_&&e.jsxs("div",{className:"absolute right-0 mt-1 z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-xl p-3 min-w-[230px]",children:[O&&e.jsx("div",{className:"mb-3",children:e.jsx(O_,{status:O})}),Y&&e.jsxs("p",{className:"text-xs text-red-500 mb-2 flex items-center gap-1",children:[e.jsx(fa,{size:10})," ",Y]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[C&&e.jsxs("button",{type:"button",disabled:R||!a,onClick:()=>{N(!1),j("raise")},className:"w-full px-3 py-2 bg-orange-600 hover:bg-orange-700 text-white rounded-lg text-xs font-medium flex items-center gap-2 disabled:opacity-50",children:[e.jsx(Na,{size:11})," Request Deletion"]}),D&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:R||!a,onClick:()=>{N(!1),j("supervisor_approve")},className:"w-full px-3 py-2 bg-yellow-600 hover:bg-yellow-700 text-white rounded-lg text-xs font-medium flex items-center gap-2 disabled:opacity-50",children:[e.jsx(ea,{size:11})," Approve & Forward to CM"]}),e.jsxs("button",{type:"button",disabled:R||!a,onClick:()=>{N(!1),j("supervisor_reject")},className:"w-full px-3 py-2 bg-gray-200 hover:bg-gray-300 dark:bg-gray-600 dark:hover:bg-gray-500 text-gray-700 dark:text-gray-200 rounded-lg text-xs font-medium flex items-center gap-2 disabled:opacity-50",children:[e.jsx(ei,{size:11})," Reject Request"]})]}),T&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:R||!a,onClick:()=>{N(!1),j("cm_approve")},className:"w-full px-3 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs font-medium flex items-center gap-2 disabled:opacity-50",children:[e.jsx(ea,{size:11})," Approve & Delete"]}),e.jsxs("button",{type:"button",disabled:R||!a,onClick:()=>{N(!1),j("cm_reject")},className:"w-full px-3 py-2 bg-gray-200 hover:bg-gray-300 dark:bg-gray-600 dark:hover:bg-gray-500 text-gray-700 dark:text-gray-200 rounded-lg text-xs font-medium flex items-center gap-2 disabled:opacity-50",children:[e.jsx(ei,{size:11})," Reject Request"]})]}),E&&e.jsxs("button",{type:"button",disabled:R||!a,onClick:()=>{N(!1),j("direct")},className:"w-full px-3 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs font-medium flex items-center gap-2 disabled:opacity-50",children:[e.jsx(Na,{size:11})," Delete"]})]})]})]})]})}const ee=m?"flex flex-row flex-wrap items-center gap-2":"flex flex-col gap-2";return e.jsxs(e.Fragment,{children:[b&&e.jsx(E_,Se(ue({},ce[b]),{loading:R,onConfirm:he,onCancel:()=>j(null)})),e.jsxs("div",{className:`${ee} ${d}`,children:[O&&e.jsx(O_,{status:O}),Y&&e.jsxs("p",{className:"text-xs text-red-500 dark:text-red-400 flex items-center gap-1",children:[e.jsx(fa,{size:11})," ",Y]}),C&&e.jsxs("button",{type:"button",disabled:R||!a,onClick:()=>j("raise"),className:"px-4 py-2 bg-orange-600 hover:bg-orange-700 text-white rounded-lg text-sm font-medium flex items-center gap-2 disabled:opacity-50 transition-colors",children:[R?e.jsx(ya,{className:"animate-spin",size:13}):e.jsx(Na,{size:13}),"Request Deletion"]}),D&&e.jsx(A_,{disabled:R||!a,loading:R,primaryLabel:"Approve Request",primaryClass:"bg-yellow-600 hover:bg-yellow-700",primaryIcon:e.jsx(ea,{size:13}),onPrimary:()=>j("supervisor_approve"),secondaryLabel:"Reject Request",secondaryClass:"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700",secondaryIcon:e.jsx(ei,{size:13,className:"text-gray-500"}),onSecondary:()=>j("supervisor_reject")}),T&&e.jsx(A_,{disabled:R||!a,loading:R,primaryLabel:"Approve & Delete",primaryClass:"bg-red-600 hover:bg-red-700",primaryIcon:e.jsx(ea,{size:13}),onPrimary:()=>j("cm_approve"),secondaryLabel:"Reject Request",secondaryClass:"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700",secondaryIcon:e.jsx(ei,{size:13,className:"text-gray-500"}),onSecondary:()=>j("cm_reject")}),E&&e.jsxs("button",{type:"button",disabled:R||!a,onClick:()=>j("direct"),className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-sm font-medium flex items-center gap-2 disabled:opacity-50 transition-colors",children:[R?e.jsx(ya,{className:"animate-spin",size:13}):e.jsx(Na,{size:13}),"Delete"]})]})]})},PM={Work_Order:new Set(["name","asset","asset_name","work_order_type","company","department","repair_status","workflow_state","custom_priority_","creation","modified"]),Asset:new Set(["name","asset_name","custom_serial_number","company","location","custom_device_status","modified"])},Ym=new Map;function FM(t){const[a,r]=y.useState([]),[s,i]=y.useState(!1),[c,d]=y.useState(null),m=y.useRef(!1);return y.useEffect(()=>{if(!t)return;let g=!1;return Q(null,null,function*(){if(!m.current){if(m.current=!0,Ym.has(t)){g||r(Ym.get(t)),m.current=!1;return}g||(i(!0),d(null));try{const b=yield fetch("/api/method/asset_lite.api.doctype_fields.get_export_fields",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:t})});if(!b.ok)throw new Error(`Server returned ${b.status}`);const j=yield b.json();if(j.exc)throw new Error(j.exc);const _=j.message||[],N=PM[t],k=_.map((C,D)=>({key:C.fieldname,label:C.label||C.fieldname,fieldtype:C.fieldtype||"Data",default:N?N.has(C.fieldname):D<8}));console.log(`[useDoctypeFields] ✅ "${t}": ${k.length} fields from server`),Ym.set(t,k),g||r(k)}catch(b){console.error("[useDoctypeFields] ❌",b),g||(d(b instanceof Error?b.message:"Failed to fetch fields"),r([{key:"name",label:"ID",fieldtype:"Data",default:!0},{key:"creation",label:"Created On",fieldtype:"Datetime",default:!1},{key:"modified",label:"Modified On",fieldtype:"Datetime",default:!0}]))}finally{m.current=!1,g||i(!1)}}}),()=>{g=!0}},[t]),{fields:a,loading:s,error:c,refetchFields:()=>{Ym.delete(t),m.current=!1,r([]),d(null)}}}function qk(t){return t==null?"":typeof t=="boolean"?t?"Yes":"No":String(t)}function IM(t,a,r){const s=a.map(g=>g.label),i=t.map(g=>a.map(p=>{const b=qk(g[p.key]);return b.includes(",")||b.includes('"')||b.includes(`
`)?`"${b.replace(/"/g,'""')}"`:b}).join(",")),c=[s.join(","),...i].join(`
`),d=new Blob(["\uFEFF"+c],{type:"text/csv;charset=utf-8;"}),m=URL.createObjectURL(d),h=document.createElement("a");h.href=m,h.download=r,h.click(),URL.revokeObjectURL(m)}function zM(t,a,r){const s=[a.map(d=>d.label),...t.map(d=>a.map(m=>qk(d[m.key])))],i=Ja.aoa_to_sheet(s),c=Ja.book_new();Ja.book_append_sheet(c,i,"Export"),$i(c,r)}const Gk=({isOpen:t,onClose:a,doctype:r,selectedCount:s,pageCount:i,totalCount:c,onExport:d,onFetchAll:m,pageData:h,selectedRows:g,rowKey:p="name",extraColumns:b=[],hiddenColumns:j=[],defaultColumns:_,fileNamePrefix:N})=>{const{t:k}=ca(),{fields:C,loading:D}=FM(r),T=pa.useMemo(()=>{const ae=new Set(j),F=[...C.filter(M=>!ae.has(M.key)),...b.filter(M=>!ae.has(M.key))];if(_){const M=new Set(_);return F.map(B=>Se(ue({},B),{default:M.has(B.key)}))}return F},[C,b,j,_]),[E,O]=y.useState(s>0?"selected":"all_with_filters"),[R,Y]=y.useState("csv"),[P,U]=y.useState(new Set),[J,ne]=y.useState(""),[ye,he]=y.useState(!1),ce=pa.useRef(!1);if(y.useEffect(()=>{O(s>0?"selected":"all_with_filters")},[s]),y.useEffect(()=>{T.length!==0&&(ce.current||(ce.current=!0,U(new Set(T.filter(ae=>ae.default).map(ae=>ae.key)))))},[T]),y.useEffect(()=>{t||(ce.current=!1,U(new Set))},[t]),!t)return null;const se=J.trim()?T.filter(ae=>ae.label.toLowerCase().includes(J.toLowerCase())||ae.key.toLowerCase().includes(J.toLowerCase())):T,ee=ae=>{U(F=>{const M=new Set(F);return M.has(ae)?M.delete(ae):M.add(ae),M})},te=()=>U(new Set(T.map(ae=>ae.key))),W=()=>U(new Set(T.filter(ae=>ae.default).map(ae=>ae.key))),I=()=>U(new Set),oe=()=>Q(null,null,function*(){if(P.size!==0){he(!0);try{if(d){yield d(E,R,[...P]),a();return}let ae=[];if(E==="selected"){const K=g!=null?g:new Set;ae=h.filter(we=>K.has(we[p]))}else if(E==="all_on_page")ae=h;else{if(!m){alert("onFetchAll not provided for all_with_filters scope");return}ae=yield m()}if(ae.length===0){alert("No data to export.");return}const F=T.filter(K=>P.has(K.key)),M=N!=null?N:r.toLowerCase().replace(/\s+/g,"_"),B=new Date().toISOString().split("T")[0],X=`${M}_export_${B}.${R==="csv"?"csv":"xlsx"}`;R==="csv"?IM(ae,F,X):zM(ae,F,X),a()}catch(ae){console.error("Export failed:",ae),alert(`Export failed: ${ae instanceof Error?ae.message:"Unknown error"}`)}finally{he(!1)}}});return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-2xl max-h-[92vh] flex flex-col animate-scale-in",children:[e.jsx("div",{className:"bg-gradient-to-r from-green-500 to-green-600 px-6 py-4 rounded-t-lg flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Os,{className:"text-white text-xl"}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Export ",r.replace(/_/g," ")]}),e.jsxs("p",{className:"text-green-100 text-xs mt-0.5",children:[T.length," fields available · ",P.size," selected"]})]})]}),e.jsx("button",{onClick:a,className:"text-white/80 hover:text-white transition-colors",disabled:ye,children:e.jsx(wt,{size:20})})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"What to export"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(hx,{value:"selected",current:E,onChange:O,disabled:s===0,badge:s,badgeColor:"green",label:"Selected rows",sub:`${s} row${s!==1?"s":""} selected`}),e.jsx(hx,{value:"all_on_page",current:E,onChange:O,badge:i,badgeColor:"blue",label:"Current page",sub:`${i} rows on this page`}),e.jsx(hx,{value:"all_with_filters",current:E,onChange:O,badge:c,badgeColor:"purple",label:"All records (current filters)",sub:`${c} total matching records`})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"File format"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(D_,{value:"csv",current:R,onChange:Y,icon:e.jsx(Bi,{className:"text-green-600 text-xl"}),label:"CSV",sub:"Universal, works everywhere"}),e.jsx(D_,{value:"excel",current:R,onChange:Y,icon:e.jsx(Ui,{className:"text-green-700 text-xl"}),label:"Excel (.xlsx)",sub:"Native Excel workbook"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:["Columns to export",D&&e.jsx(ya,{className:"inline ml-2 animate-spin text-gray-400",size:12})]}),e.jsxs("div",{className:"flex gap-3 text-xs text-blue-600 dark:text-blue-400",children:[e.jsx("button",{onClick:te,className:"hover:underline",children:"All"}),e.jsx("button",{onClick:W,className:"hover:underline",children:"Default"}),e.jsx("button",{onClick:I,className:"hover:underline",children:"None"})]})]}),e.jsxs("div",{className:"relative mb-2",children:[e.jsx(Js,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400",size:12}),e.jsx("input",{type:"text",value:J,onChange:ae=>ne(ae.target.value),placeholder:"Search fields…",className:"w-full pl-8 pr-3 py-1.5 text-xs border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),J&&e.jsx("button",{onClick:()=>ne(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:e.jsx(wt,{size:10})})]}),D?e.jsxs("div",{className:"flex items-center justify-center h-24 text-gray-400 text-sm gap-2",children:[e.jsx(ya,{className:"animate-spin"})," Loading fields…"]}):e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-1.5 max-h-52 overflow-y-auto p-2 bg-gray-50 dark:bg-gray-900/50 rounded-lg border border-gray-200 dark:border-gray-700",children:[se.map(ae=>{const F=P.has(ae.key);return e.jsxs("div",{onClick:()=>ee(ae.key),className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-all text-xs select-none ${F?"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-600 dark:text-gray-400"}`,children:[e.jsx("span",{className:"flex-shrink-0",children:F?e.jsx(Es,{size:13,className:"text-green-600"}):e.jsx(Ar,{size:13,className:"text-gray-300 dark:text-gray-600"})}),e.jsx("span",{className:"truncate",title:`${ae.label} (${ae.key})`,children:ae.label})]},ae.key)}),se.length===0&&e.jsxs("p",{className:"col-span-3 text-center text-gray-400 text-xs py-4",children:['No fields match "',J,'"']})]}),e.jsxs("p",{className:"text-xs text-gray-400 mt-1.5",children:[P.size," of ",T.length," fields selected",J&&` · showing ${se.length} matching`]})]})]}),e.jsxs("div",{className:"flex-shrink-0 px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 rounded-b-lg flex justify-between items-center",children:[e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[E==="selected"&&`Exporting ${s} selected row${s!==1?"s":""}`,E==="all_on_page"&&`Exporting ${i} rows from current page`,E==="all_with_filters"&&`Exporting up to ${c} records`]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:a,disabled:ye,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:"Cancel"}),e.jsx("button",{onClick:oe,disabled:P.size===0||ye,className:"px-4 py-2 text-sm font-medium text-white bg-green-600 hover:bg-green-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:ye?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin",size:14})," Exporting…"]}):e.jsxs(e.Fragment,{children:[e.jsx(po,{size:14})," Export"]})})]})]})]})})},BM={green:"bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300",blue:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300",purple:"bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300"},hx=({value:t,current:a,onChange:r,disabled:s,label:i,sub:c,badge:d,badgeColor:m})=>e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${a===t?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"} ${s?"opacity-50 cursor-not-allowed":""}`,children:[e.jsx("input",{type:"radio",name:"export_scope",value:t,checked:a===t,onChange:()=>!s&&r(t),disabled:s,className:"text-green-600 focus:ring-green-500"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm text-gray-900 dark:text-white",children:i}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c})]}),e.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-semibold flex-shrink-0 ${BM[m]}`,children:d.toLocaleString()})]}),D_=({value:t,current:a,onChange:r,icon:s,label:i,sub:c})=>e.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${a===t?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"export_format",value:t,checked:a===t,onChange:()=>r(t),className:"text-green-600 focus:ring-green-500"}),s,e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm text-gray-900 dark:text-white",children:i}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c})]})]}),UM=({isOpen:t,onClose:a,selectedCount:r,totalCount:s,pageCount:i,onPrint:c,isPrinting:d})=>{const{t:m}=ca(),[h,g]=y.useState(r>0?"selected":"all_with_filters");return y.useEffect(()=>{r>0?g("selected"):g("all_with_filters")},[r]),t?e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-lg w-full animate-scale-in",children:[e.jsx("div",{className:"bg-gradient-to-r from-purple-500 to-purple-600 px-6 py-4 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Cl,{className:"text-white text-xl"}),e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Print QR Codes"})]}),e.jsx("button",{onClick:a,className:"text-white/80 hover:text-white transition-colors",disabled:d,children:e.jsx(wt,{size:20})})]})}),e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"mb-5 p-3 bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-700 rounded-lg",children:[e.jsxs("p",{className:"text-sm text-purple-700 dark:text-purple-300 flex items-center gap-2",children:[e.jsx(Cl,{}),e.jsxs("span",{children:["Layout: ",e.jsx("strong",{children:"2 columns × 5 rows = 10 QR codes per A4 page"})]})]}),e.jsx("p",{className:"text-xs text-purple-500 dark:text-purple-400 mt-1 ml-6",children:"Each QR includes Asset Name and Asset ID"})]}),e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"Select Records"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${h==="selected"?"border-purple-500 bg-purple-50 dark:bg-purple-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"} ${r===0?"opacity-50 cursor-not-allowed":""}`,children:[e.jsx("input",{type:"radio",name:"qr_scope",value:"selected",checked:h==="selected",onChange:()=>g("selected"),disabled:r===0,className:"text-purple-600 focus:ring-purple-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Selected Rows"}),e.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:[r," asset(s) selected"]})]}),r>0&&e.jsx("span",{className:"bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300 px-2 py-1 rounded text-xs font-medium",children:r})]}),e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${h==="all_on_page"?"border-purple-500 bg-purple-50 dark:bg-purple-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"qr_scope",value:"all_on_page",checked:h==="all_on_page",onChange:()=>g("all_on_page"),className:"text-purple-600 focus:ring-purple-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Current Page"}),e.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:[i," assets on this page"]})]}),e.jsx("span",{className:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 px-2 py-1 rounded text-xs font-medium",children:i})]}),e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${h==="all_with_filters"?"border-purple-500 bg-purple-50 dark:bg-purple-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"qr_scope",value:"all_with_filters",checked:h==="all_with_filters",onChange:()=>g("all_with_filters"),className:"text-purple-600 focus:ring-purple-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"All Records (with filters)"}),e.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["All ",s," matching assets"]})]}),e.jsx("span",{className:"bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300 px-2 py-1 rounded text-xs font-medium",children:s})]})]})]}),e.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-end gap-3 rounded-b-lg",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",disabled:d,children:"Cancel"}),e.jsx("button",{onClick:()=>c(h),disabled:d,className:"px-4 py-2 text-sm font-medium text-white bg-purple-600 hover:bg-purple-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:d?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Fetching QR Codes..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Cl,{}),"Print QRs"]})})]})]})}):null},$M=()=>{const{t}=ca(),a=qa(),[r,s]=Qs(),i=y.useMemo(()=>{const G=parseInt(r.get("page")||"1",10);return Math.max(0,Number.isNaN(G)?0:G-1)},[r]),c=y.useCallback(G=>{s($e=>{const Bt=new URLSearchParams($e);return Bt.set("page",String(G+1)),Bt})},[s]),[d,m]=y.useState(()=>r.get("search")||""),[h,g]=y.useState(null),[p,b]=y.useState(null),j=y.useRef(null),_=20,[N,k]=y.useState(!1),[C,D]=y.useState(new Set),[T,E]=y.useState(!1),[O,R]=y.useState(!1),[Y,P]=y.useState(!1),[U,J]=y.useState(!1),[ne,ye]=y.useState(!1),[he,ce]=y.useState([]),[se,ee]=y.useState(!1),{permissionFilters:te,loading:W,error:I}=vp("Asset"),[oe,ae]=y.useState(!1),F=["Maintenance Manager","Maintenance User","System Manager","Technician","Contractor Engineer","Work Control"],M=["Contractor Supervisor"];y.useEffect(()=>{Q(null,null,function*(){try{console.log("🔍 [Role Check] Starting role check...");const Bt=yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({roles:F.join(",")})})).json();if(console.log("🔍 [Role Check] API Response:",Bt),Bt.message){console.log("🔍 [Role Check] User roles:",Bt.message.user_roles),console.log("🔍 [Role Check] Matching roles:",Bt.message.matching_roles),console.log("✅ [Role Check] Has allowed role:",Bt.message.has_role);const Aa=Bt.message.user_roles||[],Ds=Aa.includes("System Manager");M.some(wa=>Aa.includes(wa))&&!Ds?(console.log("🚫 [Role Check] Blocked: Contractor Supervisor without System Manager"),ae(!1)):ae(Bt.message.has_role)}else console.error("❌ [Role Check] Invalid response:",Bt),ae(!1);const _a=yield(yield fetch("/api/method/asset_lite.api.user_roles.get_user_roles",{credentials:"include"})).json(),zr=Array.isArray(_a.message)?_a.message:[];ce(zr),ee(zr.includes("System Manager"))}catch($e){console.error("❌ [Role Check] Error:",$e),ae(!1)}})},[]);const[B,X]=y.useState(()=>r.get("date_filter_by")||""),[K,we]=y.useState(()=>r.get("date_start")||""),[be,ke]=y.useState(()=>r.get("date_end")||""),[Me,z]=y.useState(()=>r.get("asset_id")||""),[Ne,Xe]=y.useState(()=>r.get("company")||""),[gt,St]=y.useState(()=>r.get("manufacturer")||""),[Ht,Mt]=y.useState(()=>r.get("supplier")||""),[Te,Qt]=y.useState(()=>r.get("location")||""),[zt,Wt]=y.useState(()=>r.get("department")||""),[Vt,va]=y.useState(()=>r.get("modality")||""),[ta,sa]=y.useState(()=>r.get("device_status")||""),[ra,Ye]=y.useState(()=>r.get("asset_name")||""),[ft,$t]=y.useState(()=>r.get("serial_number")||""),na=["creation desc","creation asc","modified desc","modified asc","asset_name asc","asset_name desc","name asc","name desc"],[Ze,lt]=y.useState(()=>r.get("sort_by")||"creation desc"),[aa,Ie]=y.useState(!0),[Nt,ve]=y.useState(0),[Oe,ht]=y.useState([]),[et,Be]=y.useState(!1),[kt,it]=y.useState(""),[xt,Dt]=y.useState(()=>r.get("asset_name")||""),[Ot,Rt]=y.useState(()=>r.get("serial_number")||""),De=y.useRef(null),Qe=y.useRef(null);y.useEffect(()=>{const G=localStorage.getItem("assetFilterPresets");G&&ht(JSON.parse(G))},[]);const fe=B&&(K||be);y.useEffect(()=>{const G=[Me,Ne,Te,zt,Vt,gt,Ht,ta,ra,ft,d].filter(Boolean).length+(fe?1:0);ve(G)},[fe,B,K,be,Me,Ne,Te,zt,Vt,gt,Ht,ta,ra,ft,d]);const re={};Me&&(re.name=Me),Ne&&(re.company=Ne),gt&&(re.custom_manufacturer=gt),Ht&&(re.supplier=Ht),Te&&(re.location=Te),zt&&(re.department=zt),Vt&&(re.custom_modality=Vt),ta&&(re.custom_device_status=ta),ra&&(re.asset_name=["like",`%${ra}%`]),ft&&(re.custom_serial_number=["like",`%${ft}%`]),d&&(re.asset_name=["like",`%${d}%`]),Object.assign(re,el(B,K,be)),re.custom_delete_status=["!=","Deleted"];const Ee=na.includes(Ze)?Ze:"creation desc",{assets:Ge,totalCount:ct,hasMore:It,loading:st,error:rt,refetch:V}=_2(re,_,i*_,Ee,te),{deleteAsset:me,loading:de}=w2();y.useEffect(()=>{!st&&!N&&!W&&k(!0)},[st,N,W]);const ie=y.useRef(!1);y.useEffect(()=>{if(!ie.current){ie.current=!0;return}s(G=>{const $e=new URLSearchParams(G);return B?$e.set("date_filter_by",B):$e.delete("date_filter_by"),K?$e.set("date_start",K):$e.delete("date_start"),be?$e.set("date_end",be):$e.delete("date_end"),Me?$e.set("asset_id",Me):$e.delete("asset_id"),Ne?$e.set("company",Ne):$e.delete("company"),gt?$e.set("manufacturer",gt):$e.delete("manufacturer"),Ht?$e.set("supplier",Ht):$e.delete("supplier"),Te?$e.set("location",Te):$e.delete("location"),zt?$e.set("department",zt):$e.delete("department"),Vt?$e.set("modality",Vt):$e.delete("modality"),ta?$e.set("device_status",ta):$e.delete("device_status"),ra?$e.set("asset_name",ra):$e.delete("asset_name"),ft?$e.set("serial_number",ft):$e.delete("serial_number"),d?$e.set("search",d):$e.delete("search"),Ze&&Ze!=="creation desc"?$e.set("sort_by",Ze):$e.delete("sort_by"),$e.set("page","1"),$e})},[B,K,be,Me,Ne,gt,Ht,Te,zt,Vt,ta,ra,ft,d,Ze]),y.useEffect(()=>{D(new Set)},[B,K,be,Me,Ne,gt,Ht,Te,zt,Vt,ta,ra,ft,d,i]);const xe=G=>{Dt(G),De.current&&clearTimeout(De.current),De.current=window.setTimeout(()=>{Ye(G)},800)},_e=G=>{Rt(G),Qe.current&&clearTimeout(Qe.current),Qe.current=window.setTimeout(()=>{$t(G)},800)},He=(G,$e)=>{G.key==="Enter"&&(G.preventDefault(),$e==="assetName"?(De.current&&clearTimeout(De.current),Ye(xt)):$e==="serialNumber"&&(Qe.current&&clearTimeout(Qe.current),$t(Ot)))},Ue=()=>{if(!kt.trim()){alert("Please enter a filter name");return}const G={id:Date.now(),name:kt,filters:{dateFilterBy:B,dateStart:K,dateEnd:be,sortBy:Ze,filterAssetId:Me,filterCompany:Ne,filterLocation:Te,filterDepartment:zt,filterModality:Vt,filterManufacturer:gt,filterSupplier:Ht,filterDeviceStatus:ta,filterAssetName:ra,filterSerialNumber:ft,searchTerm:d}},$e=[...Oe,G];ht($e),it(""),Be(!1),localStorage.setItem("assetFilterPresets",JSON.stringify($e))},Pe=G=>{const $e=G.filters;X($e.dateFilterBy||""),we($e.dateStart||""),ke($e.dateEnd||""),lt($e.sortBy||"creation desc"),z($e.filterAssetId||""),Xe($e.filterCompany||""),Qt($e.filterLocation||""),Wt($e.filterDepartment||""),va($e.filterModality||""),St($e.filterManufacturer||""),Mt($e.filterSupplier||""),sa($e.filterDeviceStatus||""),Ye($e.filterAssetName||""),Dt($e.filterAssetName||""),$t($e.filterSerialNumber||""),Rt($e.filterSerialNumber||""),m($e.searchTerm||"")},Re=G=>{const $e=Oe.filter(Bt=>Bt.id!==G);ht($e),localStorage.setItem("assetFilterPresets",JSON.stringify($e))};y.useEffect(()=>()=>{De.current&&clearTimeout(De.current),Qe.current&&clearTimeout(Qe.current)},[]);const We=G=>{switch(G){case"Delete Request With Supervisor":return"bg-orange-50 dark:bg-orange-900/10";case"Delete Request With CM":return"bg-yellow-50 dark:bg-yellow-900/10";case"Deleted":return"bg-red-50 dark:bg-red-900/10";default:return""}},_t=G=>G?new Date(G).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"-";y.useEffect(()=>{const G=$e=>{j.current&&!j.current.contains($e.target)&&b(null)};return p&&document.addEventListener("mousedown",G),()=>{document.removeEventListener("mousedown",G)}},[p]);const Ft=G=>{D($e=>{const Bt=new Set($e);return Bt.has(G)?Bt.delete(G):Bt.add(G),Bt})},dt=()=>{C.size===Ge.length?D(new Set):D(new Set(Ge.map(G=>G.name)))},pt=Ge.length>0&&C.size===Ge.length,At=C.size>0&&C.size<Ge.length,Zt=y.useCallback(()=>Q(null,null,function*(){const G=[];let $e=0;const Bt=100;let Kt=!0;const _a=ue(ue({},re),te),zr=Ks(_a);for(;Kt;)try{const xr=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Asset",filters:zr.length>0?zr:{},fields:["*"],limit_start:$e*Bt,limit_page_length:Bt,order_by:"creation desc"})})).json()).message||[];G.push(...xr),xr.length<Bt?Kt=!1:$e++,$e>100&&(console.warn("Export safety limit reached"),Kt=!1)}catch(Aa){throw console.error("Error fetching assets for export:",Aa),Aa}return G}),[re,te]),Fa=()=>a("/assets/new"),La=G=>a(`/assets/${G}`),Ya=G=>a(`/assets/${G}`),gr=G=>a(`/assets/new?duplicate=${G}`),ar=G=>Q(null,null,function*(){try{console.log("Fetching full asset details for:",G.name);const Kt=(yield(yield fetch(`/api/resource/Asset/${encodeURIComponent(G.name)}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).data||G;console.log("Full asset data:",Kt),console.log("Building:",Kt.custom_building),console.log("Room Number:",Kt.custom_room_number);const _a=new URLSearchParams;Kt.name&&_a.append("asset",Kt.name),Kt.asset_name&&_a.append("asset_name",Kt.asset_name),Kt.custom_asset_type&&_a.append("asset_type",Kt.custom_asset_type),Kt.custom_manufacturer&&_a.append("manufacturer",Kt.custom_manufacturer),Kt.custom_serial_number&&_a.append("serial_number",Kt.custom_serial_number),Kt.department&&_a.append("department",Kt.department),Kt.custom_site_contractor&&_a.append("site_contractor",Kt.custom_site_contractor),Kt.custom_subcontractor&&_a.append("subcontractor",Kt.custom_subcontractor),Kt.company&&_a.append("company",Kt.company),Kt.custom_service_agreement&&_a.append("custom_service_agreement",Kt.custom_service_agreement),Kt.custom_service_coverage&&_a.append("custom_service_coverage",Kt.custom_service_coverage),Kt.custom_site&&_a.append("site_name",Kt.custom_site),Kt.supplier&&_a.append("supplier",Kt.supplier),Kt.custom_building&&_a.append("building",Kt.custom_building),Kt.custom_room_number&&_a.append("room_no",Kt.custom_room_number),Kt.location&&_a.append("location",Kt.location),a(`/work-orders/new?${_a.toString()}`)}catch($e){console.error("Error fetching asset details:",$e);const Bt=new URLSearchParams;G.name&&Bt.append("asset",G.name),a(`/work-orders/new?${Bt.toString()}`)}}),Ir=G=>{a(`/work-orders?asset=${encodeURIComponent(G)}`)},kr=G=>Q(null,null,function*(){try{yield me(G),g(null),V(),alert("Asset deleted successfully!")}catch($e){alert(`Failed to delete asset: ${$e instanceof Error?$e.message:"Unknown error"}`)}}),hs=G=>Q(null,null,function*(){ye(!0);try{let $e=[];if(G==="selected"?$e=Ge.filter(wa=>C.has(wa.name)):G==="all_on_page"?$e=Ge:$e=yield Zt(),$e.length===0){alert("No assets to print.");return}const Bt=$e.map(wa=>wa.name),Kt=100,_a=[];for(let wa=0;wa<Bt.length;wa+=Kt){const Za=Bt.slice(wa,wa+Kt),_s=yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:"File",filters:[["File","attached_to_doctype","=","Asset"],["File","attached_to_field","=","custom_attach_image"],["File","attached_to_name","in",Za]],fields:["attached_to_name","file_url"],limit_page_length:Kt})})).json(),Gr=(_s==null?void 0:_s.message)||[];_a.push(...Gr)}const zr={};_a.forEach(wa=>{wa.attached_to_name&&wa.file_url&&(zr[wa.attached_to_name]=wa.file_url)});const Ds=$e.map(wa=>({name:wa.name,asset_name:wa.asset_name||wa.name,qrUrl:zr[wa.name]||null,technical_department:wa.custom_technical_department||""})).map(wa=>`
<div class="qr-cell">
<div class="qr-image-wrapper">
${wa.qrUrl?`<img src="${wa.qrUrl}" alt="QR" class="qr-img" />`:'<div class="qr-placeholder">No QR</div>'}
</div>
<div class="qr-info">
<div class="qr-asset-name" title="${wa.asset_name}">${wa.asset_name}</div>
<div class="qr-asset-id">${wa.name}</div>
${wa.technical_department?`<div class="qr-dept">${wa.technical_department}</div>`:""}
</div>
</div>
`).join(""),xr=window.open("","_blank");if(!xr){alert("Pop-up blocked. Please allow pop-ups for this site.");return}xr.document.write(`
<!DOCTYPE html>
<html>
<head>
<title>QR Codes - ${$e.length} Assets</title>
<style>
@page {
size: A4;
margin: 4mm;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: Arial, sans-serif;
background: white;
}
.no-print {
padding: 12px 20px;
background: #6d28d9;
color: white;
display: flex;
align-items: center;
gap: 12px;
}
.no-print button {
background: white;
color: #6d28d9;
border: none;
padding: 6px 16px;
border-radius: 4px;
font-weight: 600;
cursor: pointer;
font-size: 13px;
}
.no-print span { font-size: 14px; }
@media print {
.no-print { display: none !important; }
}
/* Grid: 2 columns, 5 rows per page = 10 per page */
.qr-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1mm;
padding: 0;
}
.qr-cell {
display: flex;
flex-direction: column;
align-items: center;
border: 1px solid #d1d5db;
border-radius: 6px;
padding: 2mm 3mm 2mm;
height: 54mm;
page-break-inside: avoid;
overflow: hidden;
}
.qr-image-wrapper {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
}
.qr-img {
max-width: 100%;
max-height: 38mm;
object-fit: contain;
}
.qr-placeholder {
width: 32mm;
height: 32mm;
background: #f3f4f6;
border: 2px dashed #d1d5db;
display: flex;
align-items: center;
justify-content: center;
color: #9ca3af;
font-size: 10px;
border-radius: 4px;
}
.qr-info {
text-align: center;
margin-top: 1mm;
width: 100%;
line-height: 1.3;
}
.qr-asset-name {
font-size: 8pt;
font-weight: 600;
color: #111827;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100%;
}
.qr-asset-id {
font-size: 7pt;
color: #6b7280;
margin-top: 1mm;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.qr-dept {
font-size: 7pt;
color: #2563eb;
margin-top: 0.5mm;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-weight: 500;
}
</style>
</head>
<body>
<div class="no-print">
<span>📄 ${$e.length} QR code(s)</span>
<button onclick="window.print()">🖨️ Print / Save PDF</button>
<button onclick="window.close()" style="background:#e5e7eb;color:#374151;margin-left:4px;">✕ Close</button>
</div>
<div class="qr-grid">
${Ds}
</div>
</body>
</html>
`),xr.document.close(),J(!1)}catch($e){console.error("QR print error:",$e),alert(`Failed to print QR codes: ${$e instanceof Error?$e.message:"Unknown error"}`)}finally{ye(!1)}}),ha=G=>{const $e=JSON.stringify(G,null,2),Bt=new Blob([$e],{type:"application/json"}),Kt=URL.createObjectURL(Bt),_a=document.createElement("a");_a.href=Kt,_a.download=`asset_${G.name}.json`,_a.click(),URL.revokeObjectURL(Kt)},Ia=G=>Q(null,null,function*(){var zr;const $e=`/files/${G}-qr.png`;let Bt=null;try{if((yield fetch($e,{method:"HEAD",credentials:"include"})).ok)Bt=$e;else{const xr=yield(yield fetch(`/api/resource/File?filters=[["File","attached_to_name","=","${G}"]]`,{credentials:"include"})).json();((zr=xr==null?void 0:xr.data)==null?void 0:zr.length)>0&&(Bt=xr.data[0].file_url)}}catch(Aa){console.error("Error fetching QR code:",Aa)}const Kt=Ge.find(Aa=>Aa.name===G),_a=window.open("","_blank");_a&&(_a.document.write(`
<!DOCTYPE html>
<html>
<head>
<title>Print QR Code - ${G}</title>
<style>
@page { margin: 0.5in; size: auto; }
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: Arial, sans-serif;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
.qr-container {
text-align: center;
border: 2px solid #333;
padding: 20px;
border-radius: 8px;
background: white;
max-width: 400px;
}
.qr-image { width: 300px; height: 300px; margin: 15px auto; display: block; }
h1 { font-size: 20px; margin-bottom: 10px; }
.asset-info { margin: 10px 0; font-size: 14px; line-height: 1.5; }
.no-qr { width: 300px; height: 300px; margin: 15px auto; display: flex; align-items: center; justify-content: center; background: #f5f5f5; border: 2px dashed #ccc; border-radius: 8px; color: #999; font-size: 14px; }
</style>
</head>
<body>
<div class="qr-container">
<h1>Asset QR Code</h1>
<div class="asset-info">
<strong>Asset ID:</strong> ${G}<br/>
<strong>Asset Name:</strong> ${(Kt==null?void 0:Kt.asset_name)||"N/A"}
</div>
${Bt?`<img src="${Bt}" alt="QR Code" class="qr-image" onload="window.print();" />`:'<div class="no-qr">No QR Code Available</div><script>setTimeout(() => window.print(), 500);<\/script>'}
</div>
</body>
</html>
`),_a.document.close())}),qr=()=>{X(""),we(""),ke(""),lt("creation desc"),z(""),Xe(""),St(""),Mt(""),Qt(""),Wt(""),va(""),sa(""),Ye(""),$t(""),Dt(""),Rt(""),m(""),De.current&&clearTimeout(De.current),Qe.current&&clearTimeout(Qe.current),s(G=>{const $e=new URLSearchParams(G);return $e.delete("date_filter_by"),$e.delete("date_start"),$e.delete("date_end"),$e.delete("sort_by"),$e.delete("asset_id"),$e.delete("company"),$e.delete("manufacturer"),$e.delete("supplier"),$e.delete("location"),$e.delete("department"),$e.delete("modality"),$e.delete("device_status"),$e.delete("asset_name"),$e.delete("serial_number"),$e.delete("search"),$e.set("page","1"),$e})},fr=fe||Me||Ne||gt||Ht||Te||zt||Vt||ta||ra||ft||d;return W&&!N?e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("assets.loadingPermissions")})]})}):I?e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:"⚠️ Permission Error"}),e.jsxs("div",{className:"text-red-700 dark:text-red-400 space-y-3",children:[e.jsx("p",{children:e.jsx("strong",{children:"Unable to load user permissions."})}),e.jsx("p",{children:I}),e.jsx("button",{onClick:()=>window.location.reload(),className:"mt-2 bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded",children:"Retry"})]})]})}):st&&!N?e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("listPages.loading")})]})}):rt?e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-6",children:[e.jsxs("h2",{className:"text-xl font-bold text-yellow-800 dark:text-yellow-300 mb-4",children:["⚠️ ",t("assets.apiNotAvailable")]}),e.jsxs("div",{className:"text-yellow-700 dark:text-yellow-400 space-y-3",children:[e.jsx("p",{children:e.jsx("strong",{children:t("assets.apiNotDeployed")})}),e.jsx("button",{onClick:()=>a("/assets/new"),className:"mt-2 bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:t("assets.tryCreatingNew")}),e.jsx("button",{onClick:V,className:"mt-2 ml-2 bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded",children:t("common.tryAgain")})]})]})}):e.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-800 dark:text-white",children:t("assets.title")}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:[t("assets.listTotal")," ",ct," asset",ct!==1?"s":"",C.size>0&&e.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",C.size," ",t("common.selected")]}),st&&N&&e.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[e.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-blue-500"}),t("common.updating")]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:()=>J(!0),className:"bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",disabled:ct===0,children:[e.jsx(Cl,{}),e.jsx("span",{className:"font-medium",children:"Print QRs"}),C.size>0&&e.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:C.size})]}),e.jsxs("button",{onClick:()=>E(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",disabled:ct===0,children:[e.jsx(Os,{}),e.jsx("span",{className:"font-medium",children:t("listPages.export")}),C.size>0&&e.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:C.size})]}),oe&&e.jsxs("button",{onClick:Fa,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow-lg transition-all hover:shadow-xl",children:[e.jsx(Zs,{}),e.jsx("span",{className:"font-medium",children:t("assets.addAsset")})]})]})]}),e.jsxs("div",{className:"isolate bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[e.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 dark:from-blue-600 dark:to-blue-700 px-4 py-3 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[e.jsx("button",{onClick:()=>Ie(!aa),className:"text-white hover:bg-white/20 p-2 rounded-lg transition-all",children:aa?e.jsx(As,{size:14}):e.jsx(cs,{size:14})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ds,{className:"text-white",size:16}),e.jsx("h3",{className:"text-white font-semibold text-sm",children:t("listPages.filters")})]}),Nt>0&&e.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:Nt})]}),fr&&e.jsx("div",{className:"flex-1 overflow-x-auto scrollbar-hide mx-2",children:e.jsxs("div",{className:"flex items-center gap-2 py-1",children:[fe&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("filters.filterBy"),":"]})," ",t(B==="creation"?"filters.createdDate":"filters.latestModifiedDate")," ",K&&` ${K}`," ",be&&` - ${be}`,e.jsx("button",{onClick:G=>{G.stopPropagation(),X(""),we(""),ke("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),Me&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-blue-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("commonFields.assetId"),":"]})," ",Me,e.jsx("button",{onClick:G=>{G.stopPropagation(),z("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),Ne&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-green-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("assets.selectHospital"),":"]})," ",Ne,e.jsx("button",{onClick:G=>{G.stopPropagation(),Xe("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),ra&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-cyan-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("commonFields.assetName"),":"]})," ",ra,e.jsx("button",{onClick:G=>{G.stopPropagation(),Ye(""),Dt("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),ft&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-lime-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("commonFields.serialNumber"),":"]})," ",ft,e.jsx("button",{onClick:G=>{G.stopPropagation(),$t(""),Rt("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),ta&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-orange-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("assets.table.status"),":"]})," ",ta,e.jsx("button",{onClick:G=>{G.stopPropagation(),sa("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),Te&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-purple-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("filters.location"),":"]})," ",Te,e.jsx("button",{onClick:G=>{G.stopPropagation(),Qt("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),zt&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-yellow-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("filters.dept"),":"]})," ",zt,e.jsx("button",{onClick:G=>{G.stopPropagation(),Wt("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),Vt&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-pink-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("filters.modality"),":"]})," ",Vt,e.jsx("button",{onClick:G=>{G.stopPropagation(),va("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),gt&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("filters.mfr"),":"]})," ",gt,e.jsx("button",{onClick:G=>{G.stopPropagation(),St("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),Ht&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-teal-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("filters.supplier"),":"]})," ",Ht,e.jsx("button",{onClick:G=>{G.stopPropagation(),Mt("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]})]})}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Nt>0&&e.jsxs("button",{onClick:()=>Be(!0),className:"px-3 py-1.5 bg-white text-blue-600 hover:bg-blue-50 rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[e.jsx(Or,{size:12}),e.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),fr&&e.jsxs("button",{onClick:qr,className:"px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[e.jsx(wt,{size:12}),e.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]})]})}),aa&&e.jsxs("div",{className:"p-4",children:[Oe.length>0&&e.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[e.jsx(Tc,{className:"text-yellow-500",size:12}),"Saved Filters"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Oe.map(G=>e.jsxs("div",{className:"group relative inline-flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-purple-100 to-blue-100 dark:from-purple-900/30 dark:to-blue-900/30 border border-purple-200 dark:border-purple-700 rounded-lg hover:shadow-md transition-all",children:[e.jsx("button",{onClick:()=>Pe(G),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:G.name}),e.jsx("button",{onClick:()=>Re(G.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:e.jsx(Na,{size:10})})]},G.id))})]}),e.jsx("div",{className:"space-y-5",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.sortBy")}),e.jsxs("select",{value:Ze,onChange:G=>lt(G.target.value),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"creation desc",children:t("filters.sortCreationNewest")}),e.jsx("option",{value:"creation asc",children:t("filters.sortCreationOldest")}),e.jsx("option",{value:"modified desc",children:t("filters.sortModifiedNewest")}),e.jsx("option",{value:"modified asc",children:t("filters.sortModifiedOldest")}),e.jsx("option",{value:"asset_name asc",children:t("filters.sortAssetNameAsc")}),e.jsx("option",{value:"asset_name desc",children:t("filters.sortAssetNameDesc")}),e.jsx("option",{value:"name asc",children:t("filters.sortNameAsc")}),e.jsx("option",{value:"name desc",children:t("filters.sortNameDesc")})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.filterBy")}),e.jsxs("select",{value:B,onChange:G=>{const $e=G.target.value;X($e)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("filters.filterBy")}),e.jsx("option",{value:"creation",children:t("filters.createdDate")}),e.jsx("option",{value:"modified",children:t("filters.latestModifiedDate")})]})]}),B&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.startDate")}),e.jsx("input",{type:"date",value:K,onChange:G=>{const $e=G.target.value;we($e),be&&$e>be&&ke($e)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.endDate")}),e.jsx("input",{type:"date",value:be,onChange:G=>ke(G.target.value),min:K||void 0,className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),e.jsxs("div",{className:"relative z-[60]",children:[e.jsx(Ut,{label:t("commonFields.assetId"),doctype:"Asset",value:Me,onChange:G=>z(G),placeholder:t("assets.selectAssetId"),disabled:!1,compact:!0,filters:{custom_delete_status:["!=","Deleted"]}}),Me&&e.jsx("button",{onClick:()=>z(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("commonFields.assetName")}),e.jsx("input",{type:"text",value:xt,onChange:G=>xe(G.target.value),onKeyDown:G=>He(G,"assetName"),placeholder:t("common.typeToSearch"),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),xt&&xt!==ra&&e.jsx("span",{className:"absolute right-2 top-6 text-[9px] text-blue-500 animate-pulse",children:t("common.typing")}),ra&&e.jsx("button",{onClick:()=>{Ye(""),Dt("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("commonFields.serialNumber")}),e.jsx("input",{type:"text",value:Ot,onChange:G=>_e(G.target.value),onKeyDown:G=>He(G,"serialNumber"),placeholder:t("common.typeToSearch"),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),Ot&&Ot!==ft&&e.jsx("span",{className:"absolute right-2 top-6 text-[9px] text-blue-500 animate-pulse",children:t("common.typing")}),ft&&e.jsx("button",{onClick:()=>{$t(""),Rt("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[59]",children:[e.jsx(Ut,{label:t("assets.selectHospital"),doctype:"Company",value:Ne,onChange:G=>Xe(G),placeholder:t("linkField.selectLabel",{label:t("assets.selectHospital")}),disabled:!1,compact:!0,filters:{domain:"Healthcare"}}),Ne&&e.jsx("button",{onClick:()=>Xe(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("assets.deviceStatus")}),e.jsxs("select",{value:ta,onChange:G=>sa(G.target.value),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("filters.allStatuses")}),e.jsxs("option",{value:"Up",children:["✓ ",t("assets.status.up")]}),e.jsxs("option",{value:"Down",children:["⚠ ",t("assets.status.down")]})]}),ta&&e.jsx("button",{onClick:()=>sa(""),className:"absolute right-8 top-6 text-gray-400 hover:text-red-500 transition-colors",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[58]",children:[e.jsx(Ut,{label:t("filters.location"),doctype:"Location",value:Te,onChange:G=>Qt(G),placeholder:t("linkField.selectLabel",{label:t("filters.location")}),disabled:!1,compact:!0}),Te&&e.jsx("button",{onClick:()=>Qt(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[57]",children:[e.jsx(Ut,{label:t("filters.dept"),doctype:"Department",value:zt,onChange:G=>Wt(G),placeholder:t("linkField.selectLabel",{label:t("filters.dept")}),disabled:!1,compact:!0}),zt&&e.jsx("button",{onClick:()=>Wt(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[56]",children:[e.jsx(Ut,{label:t("filters.modality"),doctype:"Modality",value:Vt,onChange:G=>va(G),placeholder:t("linkField.selectLabel",{label:t("filters.modality")}),disabled:!1,compact:!0}),Vt&&e.jsx("button",{onClick:()=>va(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[55]",children:[e.jsx(Ut,{label:t("filters.mfr"),doctype:"Manufacturer",value:gt,onChange:G=>St(G),placeholder:t("linkField.selectLabel",{label:t("filters.mfr")}),disabled:!1,compact:!0}),gt&&e.jsx("button",{onClick:()=>St(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[54]",children:[e.jsx(Ut,{label:t("filters.supplier"),doctype:"Supplier",value:Ht,onChange:G=>Mt(G),placeholder:t("linkField.selectLabel",{label:t("filters.supplier")}),disabled:!1,compact:!0}),Ht&&e.jsx("button",{onClick:()=>Mt(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]})]})})})]})]}),et&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:t("common.saveFilterPreset")}),e.jsx("input",{type:"text",value:kt,onChange:G=>it(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),Ue())},placeholder:t("common.enterFilterNameExample"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white mb-4",autoFocus:!0}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>{Be(!1),it("")},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",children:t("common.cancel")}),e.jsxs("button",{onClick:Ue,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors flex items-center gap-2",children:[e.jsx(Or,{size:12}),t("common.saveFilter")]})]})]})}),e.jsx(UM,{isOpen:U,onClose:()=>J(!1),selectedCount:C.size,totalCount:ct,pageCount:Ge.length,onPrint:hs,isPrinting:ne}),e.jsx(Gk,{isOpen:T,onClose:()=>E(!1),doctype:"Asset",selectedCount:C.size,pageCount:Ge.length,totalCount:ct,pageData:Ge,selectedRows:C,rowKey:"name",onFetchAll:Zt,fileNamePrefix:"assets",defaultColumns:["name","asset_name","custom_serial_number","company","location","custom_device_status","modified"],hiddenColumns:["docstatus","idx","amended_from","naming_series"]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden relative",children:[st&&N&&e.jsx("div",{className:"absolute inset-0 bg-white/60 dark:bg-gray-800/60 flex items-center justify-center z-10 backdrop-blur-[1px]",children:e.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[e.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-blue-500"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:t("common.filtering")})]})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left",children:e.jsx("button",{onClick:dt,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:t(pt?"common.deselectAllTitle":"common.selectAllTitle"),children:pt?e.jsx(Es,{className:"text-blue-600 dark:text-blue-400",size:18}):At?e.jsxs("div",{className:"relative",children:[e.jsx(Ar,{size:18}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):e.jsx(Ar,{size:18})})}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("assets.table.assetName")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("assets.table.serialNo")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("assets.table.company")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("assets.table.location")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("assets.table.status")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("assets.table.updatedOn")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("assets.table.actions")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:Ge.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(Js,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),e.jsx("p",{children:t("assets.noAssetsFound")}),fr?e.jsx("button",{onClick:qr,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:t("listPages.clearFilters")}):oe?e.jsx("button",{onClick:Fa,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:t("assets.createFirstAsset")}):null]})})}):Ge.map(G=>{var $e;return e.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${C.has(G.name)?"bg-blue-50 dark:bg-blue-900/20":We(G.custom_delete_status)}`,title:G.custom_delete_status?`Delete Status: ${G.custom_delete_status}`:void 0,onClick:()=>La(G.name),children:[e.jsx("td",{className:"px-4 py-4",onClick:Bt=>Bt.stopPropagation(),children:e.jsx("button",{onClick:()=>Ft(G.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:C.has(G.name)?e.jsx(Es,{className:"text-blue-600 dark:text-blue-400",size:18}):e.jsx(Ar,{size:18})})}),e.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:G.asset_name}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:G.name})]}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:G.custom_serial_number||"-"}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:G.company||"-"}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:G.location||"-"}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:G.custom_device_status||"-"}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:_t(G.modified)}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:e.jsxs("div",{className:"flex items-center gap-1",onClick:Bt=>Bt.stopPropagation(),children:[e.jsx("button",{onClick:()=>La(G.name),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:t("assets.viewDetails"),children:e.jsx(ri,{})}),e.jsx("button",{onClick:()=>Ya(G.name),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:t("assets.editAsset"),children:e.jsx(Fr,{})}),e.jsx("button",{onClick:()=>gr(G.name),className:"text-purple-600 dark:text-purple-400 hover:text-purple-900 dark:hover:text-purple-300 p-2 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded transition-colors",title:t("assets.duplicateAsset"),children:e.jsx(Wd,{})}),e.jsx("button",{onClick:()=>ar(G),className:"text-orange-600 dark:text-orange-400 hover:text-orange-900 dark:hover:text-orange-300 p-2 hover:bg-orange-50 dark:hover:bg-orange-900/30 rounded transition-colors",title:t("assets.createWorkOrder"),children:e.jsx(wc,{})}),e.jsx("button",{onClick:()=>Ir(G.name),className:"text-cyan-600 dark:text-cyan-400 hover:text-cyan-900 dark:hover:text-cyan-300 p-2 hover:bg-cyan-50 dark:hover:bg-cyan-900/30 rounded transition-colors",title:t("assets.viewLinkedWOs"),children:e.jsx(_1,{})}),e.jsx("div",{onClick:Bt=>Bt.stopPropagation(),children:e.jsx(Ll,{doctype:"Asset",docname:G.name,currentDeleteStatus:($e=G.custom_delete_status)!=null?$e:null,userRoles:he,isSystemManager:se,triggerMode:!0,redirectOnDelete:"/assets",onStatusChange:()=>V()})}),e.jsxs("div",{className:"relative",ref:p===G.name?j:null,children:[e.jsx("button",{onClick:()=>b(p===G.name?null:G.name),className:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 p-2 hover:bg-gray-50 dark:hover:bg-gray-700 rounded transition-colors",title:t("assets.moreActions"),children:e.jsx(Nu,{})}),p===G.name&&e.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 z-10",children:[e.jsxs("button",{onClick:()=>{ar(G),b(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2 rounded-t-lg",children:[e.jsx(wc,{className:"text-orange-500"}),t("assets.createWorkOrder")]}),e.jsxs("button",{onClick:()=>{Ir(G.name),b(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[e.jsx(_1,{className:"text-cyan-500"}),t("assets.viewLinkedWOs")]}),e.jsxs("button",{onClick:()=>{ha(G),b(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[e.jsx(po,{className:"text-blue-500"}),t("assets.exportAsJson")]}),e.jsxs("button",{onClick:()=>{Ia(G.name),b(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2 rounded-b-lg",children:[e.jsx(Fi,{className:"text-purple-500"}),t("assets.printAsset")]})]})]})]})})]},G.name)})})]})}),e.jsx(Rc,{currentPage:i+1,totalCount:ct,pageSize:_,hasMore:It,itemLabel:t("pagination.assets"),onPageChange:G=>c(Math.max(0,G-1))})]}),h&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:e.jsx(Na,{className:"text-red-600 dark:text-red-400 text-xl"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:t("assets.deleteConfirmTitle")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:t("assets.deleteConfirmMessage")}),e.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-md p-3 mb-4",children:e.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[e.jsxs("strong",{children:[t("commonFields.assetId"),":"]})," ",h]})}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>g(null),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-lg transition-colors",disabled:de,children:t("common.cancel")}),e.jsx("button",{onClick:()=>kr(h),className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50",disabled:de,children:de?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),t("common.deleting")]}):e.jsxs(e.Fragment,{children:[e.jsx(Na,{}),t("assets.deleteConfirmTitle")]})})]})]})]})})}),e.jsx("style",{children:`
@keyframes scale-in {
from {
transform: scale(0.95);
opacity: 0;
}
to {
transform: scale(1);
opacity: 1;
}
}
.animate-scale-in {
animation: scale-in 0.2s ease-out;
}
.scrollbar-hide {
-ms-overflow-style: none;
scrollbar-width: none;
}
.scrollbar-hide::-webkit-scrollbar {
display: none;
}
`})]})},HM=t=>{const[a,r]=y.useState([]),[s,i]=y.useState(new Set),[c,d]=y.useState(!0),[m,h]=y.useState(null);return y.useEffect(()=>{Q(null,null,function*(){try{d(!0);const b=yield mt.apiCall(`/api/resource/DocType/${t}`),_=(b.data||b).fields||[],N=new Set;_.forEach(k=>{k.allow_on_submit===1&&N.add(k.fieldname)}),r(_),i(N),h(null)}catch(b){console.error(`[DocTypeMeta] Error fetching DocType meta for ${t}:`,b),h(b instanceof Error?b.message:"Unknown error"),r([]),i(new Set)}finally{d(!1)}})},[t]),{fields:a,allowOnSubmitFields:s,isAllowedOnSubmit:p=>s.has(p),loading:c,error:m}};function gx(t,a){if(!t||(t=t.trim(),!t))return!1;if(!t.startsWith("eval:"))return!!a[t];const r=t.substring(5).trim();try{return new Function("doc",`
try {
return Boolean(${r});
} catch (e) {
console.warn('Expression evaluation error:', e);
return false;
}
`)(a)}catch(s){return console.warn(`Failed to evaluate expression: ${t}`,s),!1}}function WM(t){if(!t)return null;const a=t.split(".");return a.length!==2?null:{linkField:a[0],targetField:a[1]}}const fx={};function Yk(t,a){const[r,s]=y.useState([]),[i,c]=y.useState(!0),[d,m]=y.useState(null);y.useEffect(()=>{if(!t){c(!1);return}if(fx[t]){s(fx[t]),c(!1);return}Q(null,null,function*(){var T;c(!0);try{const E=yield mt.apiCall(`/api/method/frappe.client.get_doc?doctype=DocType&name=${encodeURIComponent(t)}`,{credentials:"include"});if((T=E==null?void 0:E.message)!=null&&T.fields){const O=E.message.fields.map(R=>({fieldname:R.fieldname,label:R.label,fieldtype:R.fieldtype,options:R.options,reqd:R.reqd,hidden:R.hidden,read_only:R.read_only,depends_on:R.depends_on,mandatory_depends_on:R.mandatory_depends_on,read_only_depends_on:R.read_only_depends_on,fetch_from:R.fetch_from,fetch_if_empty:R.fetch_if_empty,default:R.default,description:R.description,in_list_view:R.in_list_view,permlevel:R.permlevel,allow_on_submit:R.allow_on_submit}));fx[t]=O,s(O)}}catch(E){console.warn(`Could not fetch DocType meta for ${t}:`,E.message),m(E.message)}finally{c(!1)}})},[t]);const h=y.useMemo(()=>{const D={};return r.forEach(T=>{D[T.fieldname]=T}),D},[r]),g=y.useCallback(D=>{const T=h[D];if(!T)return{isVisible:!0,isReadOnly:!1,isMandatory:!1};let E=!(T.hidden===1||T.hidden===!0);T.depends_on&&E&&(E=gx(T.depends_on,a));let O=T.read_only===1||T.read_only===!0;T.read_only_depends_on&&(O=O||gx(T.read_only_depends_on,a));let R=T.reqd===1||T.reqd===!0;return T.mandatory_depends_on&&(R=R||gx(T.mandatory_depends_on,a)),{isVisible:E,isReadOnly:O,isMandatory:R}},[h,a]),p=y.useCallback(D=>g(D).isVisible,[g]),b=y.useCallback(D=>{const T=g(D);return T.isVisible&&T.isMandatory},[g]),j=y.useCallback(D=>g(D).isReadOnly,[g]),_=y.useCallback(D=>{const T=h[D];return(T==null?void 0:T.label)||D},[h]),N=y.useCallback(D=>{const T=h[D];return T!=null&&T.options?T.fieldtype==="Select"?T.options.split(`
`).filter(E=>E.trim()!==""):[]:[]},[h]),k=y.useCallback((D,T)=>{const E=h[D];if(!(E!=null&&E.fetch_from)||!T)return;const O=WM(E.fetch_from);if(O)return T[O.targetField]},[h]),C=y.useCallback(()=>{const D={};return r.forEach(T=>{const E=g(T.fieldname);if(E.isVisible&&E.isMandatory){const O=a[T.fieldname];(O==null||O==="")&&(D[T.fieldname]=`${T.label||T.fieldname} is required`)}}),{valid:Object.keys(D).length===0,errors:D}},[r,a,g]);return{loading:i,error:d,fields:r,getFieldState:g,shouldShowField:p,isMandatory:b,isReadOnly:j,getFieldLabel:_,getFieldOptions:N,getFetchFromValue:k,validateMandatory:C}}let Od=null,Dd=null;const VM=(t,a)=>{Od=t,a&&(Dd=a),console.log("[Workflow] User set manually:",t,"Roles:",a)},qM=()=>{Od=null,Dd=null},Sp=()=>Q(null,null,function*(){try{if(Od&&Dd)return console.log("[Workflow] Using cached user:",Od,"roles:",Dd),{user:Od,roles:Dd};const t=yield mt.getUserDetails();if(t&&t.email){const a=t.email||t.user_id,r=t.roles||[];return Od=a,Dd=r,console.log("[Workflow] User from getUserDetails():",a),console.log("[Workflow] Roles from getUserDetails():",r),{user:a,roles:r}}return console.warn("[Workflow] getUserDetails() returned no user"),{user:"",roles:[]}}catch(t){return console.error("[Workflow] Error getting user details:",t),{user:"",roles:[]}}}),GM=()=>Q(null,null,function*(){const{user:t}=yield Sp();return t}),Qh=()=>Q(null,null,function*(){const{roles:t}=yield Sp();return t}),eg=()=>Q(null,null,function*(){try{const t=yield Qh(),a=t.includes("System Manager");return console.log("[Workflow] Is System Manager:",a,"Roles:",t),a}catch(t){return console.error("[Workflow] Error checking System Manager role:",t),!1}}),Cp=(t,a)=>{if(!t||t.trim()==="")return!0;try{console.log("[Workflow] Evaluating condition:",t),console.log("[Workflow] Document data for condition:",{asset_type:a.asset_type,site_name:a.site_name,need_procurement:a.need_procurement,custom_assign_to_contractor:a.custom_assign_to_contractor,docstatus:a.docstatus});let r=t;r=r.replace(/\band\b/g,"&&"),r=r.replace(/\bor\b/g,"||"),r=r.replace(/\bnot\s+/g,"!"),r=r.replace(/\bTrue\b/g,"true"),r=r.replace(/\bFalse\b/g,"false"),r=r.replace(/\bNone\b/g,"null"),r=r.replace(/doc\.(\w+)/g,(i,c)=>{const d=a[c];return d==null||d===""?"false":typeof d=="string"?`"${d.replace(/"/g,'\\"')}"`:typeof d=="boolean"?d?"true":"false":typeof d=="number"?String(d):JSON.stringify(d)}),r=r.replace(/== 1/g,"=== 1"),r=r.replace(/== 0/g,"=== 0"),r=r.replace(/!= 1/g,"!== 1"),r=r.replace(/!= 0/g,"!== 0"),console.log("[Workflow] Transformed condition:",r);const s=new Function(`return (${r})`)();return console.log("[Workflow] Condition result:",s),!!s}catch(r){return console.error("[Workflow] Error evaluating condition:",t,r),!1}},tg=t=>Q(null,null,function*(){var a,r,s,i;try{console.log("[Workflow] Getting workflow info for doctype:",t);const c=yield mt.apiCall(`/api/resource/Workflow?filters=[["document_type","=","${t}"],["is_active","=",1]]&fields=["name","workflow_state_field"]&limit=1`);if(console.log("[Workflow] Workflow response:",c),!(c!=null&&c.data)||c.data.length===0)return console.warn("[Workflow] No active workflow found for doctype:",t),null;const d=c.data[0].name;console.log("[Workflow] Found workflow:",d);const m=yield mt.apiCall(`/api/resource/Workflow/${encodeURIComponent(d)}`);return console.log("[Workflow] Full workflow data:",m==null?void 0:m.data),console.log("[Workflow] Transitions count:",(r=(a=m==null?void 0:m.data)==null?void 0:a.transitions)==null?void 0:r.length),console.log("[Workflow] States count:",(i=(s=m==null?void 0:m.data)==null?void 0:s.states)==null?void 0:i.length),{workflow_name:m.data.name,workflow_state:"",workflow_state_field:m.data.workflow_state_field,transitions:m.data.transitions||[],states:m.data.states||[]}}catch(c){return console.error("[Workflow] Error fetching workflow info:",c),null}}),Zk=(t,a,r)=>Q(null,null,function*(){try{console.log("[Workflow] Getting all transitions for state:",a);const s=yield tg(t);if(!s)return console.warn("[Workflow] No workflow info found"),[];console.log("[Workflow] All transitions from workflow:",s.transitions.length);let i=s.transitions.filter(m=>m.state===a);console.log("[Workflow] Transitions for state",a,":",i.length),r&&(i=i.filter(m=>{const h=Cp(m.condition,r);return console.log(`[Workflow] Transition "${m.action}" (allowed: ${m.allowed}) condition "${m.condition||"none"}" = ${h}`),h}),console.log("[Workflow] Transitions after condition evaluation:",i.length));const c=new Set,d=[];for(const m of i){const h=`${m.action}::${m.next_state}`;c.has(h)?console.log(`[Workflow] Skipping duplicate: ${m.action} → ${m.next_state} (allowed: ${m.allowed})`):(c.add(h),d.push(m))}return console.log("[Workflow] Unique transitions after deduplication:",d.length),d}catch(s){return console.error("[Workflow] Error fetching all transitions:",s),[]}}),YM=(t,a,r,s)=>Q(null,null,function*(){var i;try{console.log("[Workflow] getWorkflowTransitions called with:",{doctype:t,docname:a,currentState:r});const c=yield eg(),d=yield Qh();if(console.log("[Workflow] User is System Manager:",c),console.log("[Workflow] User roles:",d),c&&r){console.log("[Workflow] System Manager detected, getting all transitions for state:",r);const g=yield Zk(t,r,s);return console.log("[Workflow] Final transitions for System Manager:",g.map(p=>`${p.action} → ${p.next_state}`)),g}console.log("[Workflow] Non-System Manager, using Frappe API");const m=yield mt.apiCall("/api/method/frappe.model.workflow.get_transitions",{method:"POST",body:JSON.stringify({doc:JSON.stringify({doctype:t,name:a})})});console.log("[Workflow] Frappe transitions raw response:",m);let h=[];if(Array.isArray(m)?h=m:m!=null&&m.message&&Array.isArray(m.message)?h=m.message:m!=null&&m.data&&Array.isArray(m.data)?h=m.data:(i=m==null?void 0:m.data)!=null&&i.message&&Array.isArray(m.data.message)&&(h=m.data.message),console.log("[Workflow] Parsed transitions:",h),console.log("[Workflow] Transitions count:",h.length),h.length===0&&r&&s){console.log("[Workflow] Frappe API returned no transitions, trying local filtering");const g=yield tg(t);if(g){const p=g.transitions.filter(_=>!(_.state!==r||!d.includes(_.allowed)||!Cp(_.condition,s))),b=new Set,j=[];for(const _ of p){const N=`${_.action}::${_.next_state}`;b.has(N)||(b.add(N),j.push(_))}return console.log("[Workflow] Local filtered transitions:",j),j}}return h}catch(c){return console.error("[Workflow] Error fetching workflow transitions:",c),[]}}),ZM=(t,a,r,s)=>Q(null,null,function*(){try{if(console.log("[Workflow] Applying action:",{doctype:t,docname:a,action:r,nextState:s}),(yield eg())&&s)try{const d=yield mt.apiCall("/api/method/frappe.model.workflow.apply_workflow",{method:"POST",body:JSON.stringify({doc:JSON.stringify({doctype:t,name:a}),action:r})});return console.log("[Workflow] Action applied successfully via workflow API"),d==null?void 0:d.message}catch(d){console.log("[Workflow] Normal workflow failed, System Manager forcing state change...");const m=yield mt.apiCall(`/api/resource/${t}/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify({workflow_state:s})});return console.log("[Workflow] Force update response:",m),m==null?void 0:m.data}const c=yield mt.apiCall("/api/method/frappe.model.workflow.apply_workflow",{method:"POST",body:JSON.stringify({doc:JSON.stringify({doctype:t,name:a}),action:r})});return console.log("[Workflow] Action applied successfully"),c==null?void 0:c.message}catch(i){throw console.error("[Workflow] Error applying workflow action:",i),i}}),JM=(t,a,r)=>Q(null,null,function*(){try{if(yield eg())return console.log("[Workflow] System Manager can always edit"),!0;const i=yield tg(t);if(!i)return!0;const c=yield Qh(),d=i.states.filter(h=>h.state===r);if(d.length===0)return!0;const m=d.some(h=>c.includes(h.allow_edit));return console.log("[Workflow] Can user edit:",m,"User roles:",c,"Allowed roles:",d.map(h=>h.allow_edit)),m}catch(s){return console.error("[Workflow] Error checking edit permission:",s),!1}}),Jk=t=>{const a={Draft:{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-800 dark:text-gray-200",border:"border-gray-300 dark:border-gray-600"},"Sent To Maintenance manger":{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-200",border:"border-blue-300 dark:border-blue-600"},"Sent to Supervisor":{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-200",border:"border-blue-300 dark:border-blue-600"},"Sent to Engineer":{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-200",border:"border-blue-300 dark:border-blue-600"},"Sent to Work Control":{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-200",border:"border-blue-300 dark:border-blue-600"},"Sent to technician":{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-200",border:"border-blue-300 dark:border-blue-600"},"Sent to General WOA":{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-200",border:"border-blue-300 dark:border-blue-600"},"Repair InProgress":{bg:"bg-yellow-100 dark:bg-yellow-900/30",text:"text-yellow-800 dark:text-yellow-200",border:"border-yellow-300 dark:border-yellow-600"},"Pending Purchase":{bg:"bg-orange-100 dark:bg-orange-900/30",text:"text-orange-800 dark:text-orange-200",border:"border-orange-300 dark:border-orange-600"},"Pending Approval":{bg:"bg-purple-100 dark:bg-purple-900/30",text:"text-purple-800 dark:text-purple-200",border:"border-purple-300 dark:border-purple-600"},Completed:{bg:"bg-green-100 dark:bg-green-900/30",text:"text-green-800 dark:text-green-200",border:"border-green-300 dark:border-green-600"},Approved:{bg:"bg-green-100 dark:bg-green-900/30",text:"text-green-800 dark:text-green-200",border:"border-green-300 dark:border-green-600"},Rejected:{bg:"bg-red-100 dark:bg-red-900/30",text:"text-red-800 dark:text-red-200",border:"border-red-300 dark:border-red-600"},Cancelled:{bg:"bg-red-100 dark:bg-red-900/30",text:"text-red-800 dark:text-red-200",border:"border-red-300 dark:border-red-600"},Closed:{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-800 dark:text-gray-200",border:"border-gray-300 dark:border-gray-600"},Applied:{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-200",border:"border-blue-300 dark:border-blue-600"}};return a[t]||a.Draft},Xk=t=>({Apply:"bg-blue-600 hover:bg-blue-700 text-white","Assign Technician":"bg-blue-600 hover:bg-blue-700 text-white","Back To Controller":"bg-gray-600 hover:bg-gray-700 text-white","Send For Repair":"bg-yellow-600 hover:bg-yellow-700 text-white","Send For Approval":"bg-purple-600 hover:bg-purple-700 text-white","Send to Supervisor":"bg-purple-600 hover:bg-purple-700 text-white","Material Request":"bg-orange-600 hover:bg-orange-700 text-white",Accept:"bg-green-600 hover:bg-green-700 text-white",Reject:"bg-red-600 hover:bg-red-700 text-white",Close:"bg-gray-600 hover:bg-gray-700 text-white","Re-Open":"bg-blue-600 hover:bg-blue-700 text-white",Cancel:"bg-red-600 hover:bg-red-700 text-white",Approve:"bg-green-600 hover:bg-green-700 text-white"})[t]||"bg-blue-600 hover:bg-blue-700 text-white",Kk=t=>({Apply:"📤","Send For Repair":"🔧","Send For Approval":"📋","Material Request":"📦",Accept:"✅",Reject:"❌",Close:"🔒","Re-Open":"🔓",Cancel:"🚫",Approve:"✅"})[t]||"▶️",oc={getWorkflowTransitions:YM,applyWorkflowAction:ZM,getWorkflowInfo:tg,getCurrentUserRoles:Qh,getCurrentUser:GM,getCurrentUserAndRoles:Sp,setCurrentUser:VM,clearCurrentUser:qM,canUserEditDocument:JM,getWorkflowStateStyle:Jk,getActionButtonStyle:Xk,getActionIcon:Kk,isSystemManager:eg,getAllTransitionsForState:Zk,evaluateCondition:Cp},ag=({doctype:t,docname:a,workflowState:r,enabled:s=!0,docData:i})=>{const[c,d]=y.useState([]),[m,h]=y.useState(null),[g,p]=y.useState([]),[b,j]=y.useState(""),[_,N]=y.useState(!1),[k,C]=y.useState(!1),[D,T]=y.useState(!1),[E,O]=y.useState(null),[R,Y]=y.useState(!0);y.useEffect(()=>{if(!s)return;Q(null,null,function*(){try{const ne=yield oc.getWorkflowInfo(t);h(ne)}catch(ne){console.error("Error fetching workflow info:",ne)}})},[t,s]),y.useEffect(()=>{if(!s)return;Q(null,null,function*(){try{const[ne,ye,he]=yield Promise.all([oc.getCurrentUserRoles(),oc.getCurrentUser(),oc.isSystemManager()]);p(ne),j(ye),N(he),he&&Y(!0)}catch(ne){console.error("Error fetching user info:",ne)}})},[s]);const P=y.useCallback(()=>Q(null,null,function*(){if(!a||!s){d([]);return}C(!0),O(null);try{const J=yield oc.getWorkflowTransitions(t,a,r,i);if(console.log("[useWorkflow] Available transitions:",J),d(J),r){const ne=yield oc.canUserEditDocument(t,a,r);Y(ne)}}catch(J){console.error("Error fetching transitions:",J),O("Failed to load workflow actions"),d([])}finally{C(!1)}}),[t,a,r,s,i]);y.useEffect(()=>{P()},[P]);const U=y.useCallback((J,ne)=>Q(null,null,function*(){if(!a)return O("Document not saved yet"),!1;T(!0),O(null);try{return yield oc.applyWorkflowAction(t,a,J,ne),yield P(),!0}catch(ye){console.error("Error applying workflow action:",ye);let he="Failed to apply action";if(ye.message)he=ye.message;else if(ye._server_messages)try{he=JSON.parse(ye._server_messages).map(se=>{try{return JSON.parse(se).message}catch(ee){return se}}).join(`
`)}catch(ce){he=ye._server_messages}return O(he),!1}finally{T(!1)}}),[t,a,P]);return{transitions:c,workflowInfo:m,userRoles:g,currentUser:b,isSystemManager:_,loading:k,actionLoading:D,error:E,canEdit:R,applyAction:U,refreshTransitions:P,getStateStyle:Jk,getButtonStyle:Xk,getIcon:Kk}},Tp=({doctype:t,docname:a,workflowState:r,onActionComplete:s,onStateChange:i,showStateInfo:c=!0,className:d=""})=>{const{transitions:m,loading:h,actionLoading:g,error:p,applyAction:b,getStateStyle:j,getButtonStyle:_,getIcon:N}=ag({doctype:t,docname:a,workflowState:r,enabled:!!a}),[k,C]=y.useState(null),D=["Reject","Cancel","Close"],T=R=>Q(null,null,function*(){if(D.includes(R)&&k!==R){C(R);return}C(null);const Y=yield b(R);s&&s(R,Y),Y&&i&&i()}),E=()=>{C(null)};if(!a)return null;const O=j(r||"Draft");return e.jsxs("div",{className:`space-y-4 ${d}`,children:[c&&r&&e.jsx("div",{className:`p-4 rounded-lg border ${O.bg} ${O.border}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Workflow State"}),e.jsx("p",{className:`text-lg font-semibold ${O.text}`,children:r})]}),e.jsx("div",{className:`w-3 h-3 rounded-full ${O.bg.replace("100","500").replace("900/30","500")}`})]})}),h&&e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(ya,{className:"animate-spin"}),e.jsx("span",{className:"text-sm",children:"Loading workflow actions..."})]}),p&&e.jsx("div",{className:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(fa,{className:"text-red-500 mt-0.5"}),e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:p})]})}),k&&e.jsxs("div",{className:"p-4 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:[e.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[e.jsx(fa,{className:"text-yellow-500 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-yellow-800 dark:text-yellow-200",children:"Confirm Action"}),e.jsxs("p",{className:"text-xs text-yellow-600 dark:text-yellow-400 mt-1",children:["Are you sure you want to ",e.jsx("strong",{children:k})," this work order?"]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>T(k),disabled:g,className:"px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white text-sm rounded-md disabled:opacity-50",children:g?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ya,{className:"animate-spin",size:12}),"Processing..."]}):`Yes, ${k}`}),e.jsx("button",{onClick:E,disabled:g,className:"px-3 py-1.5 bg-gray-300 hover:bg-gray-400 text-gray-700 text-sm rounded-md disabled:opacity-50",children:"Cancel"})]})]}),!h&&m.length>0&&!k&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 flex items-center gap-1",children:[e.jsx(Di,{size:12}),"Available Actions"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:m.map((R,Y)=>e.jsxs("button",{onClick:()=>T(R.action),disabled:g,className:`px-4 py-2 rounded-lg text-sm font-medium transition-colors disabled:opacity-50 flex items-center gap-2 ${_(R.action)}`,title:`Move to: ${R.next_state}`,children:[g?e.jsx(ya,{className:"animate-spin",size:14}):e.jsx("span",{children:N(R.action)}),R.action]},`${R.action}-${Y}`))}),e.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:m.map((R,Y)=>e.jsxs("span",{className:"inline-block mr-3",children:[R.action," → ",e.jsx("span",{className:"font-medium",children:R.next_state})]},Y))})]}),!h&&m.length===0&&a&&e.jsx("div",{className:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center",children:"No workflow actions available for your role"})})]})},Y0={getComments(t,a){return Q(this,null,function*(){var c;const r=JSON.stringify([["reference_doctype","=",t],["reference_name","=",a],["comment_type","in",["Comment","Info","Edit","Attachment","Like"]]]),s=JSON.stringify(["name","owner","creation","modified","modified_by","comment_type","comment_email","comment_by","content","reference_doctype","reference_name","published","seen"]),i=yield mt.apiCall(`/api/resource/Comment?filters=${encodeURIComponent(r)}&fields=${encodeURIComponent(s)}&order_by=creation asc&limit_page_length=100`);return(c=i==null?void 0:i.data)!=null?c:[]})},postComment(t,a,r){return Q(this,null,function*(){const s=ia.BASE_URL,i=yield fetch(`${s}/api/resource/Comment`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({comment_type:"Comment",reference_doctype:t,reference_name:a,content:r})});if(!i.ok){const d=yield i.json().catch(()=>({}));throw new Error((d==null?void 0:d.exc)||(d==null?void 0:d._server_messages)||"Failed to post comment")}return(yield i.json()).data})},deleteComment(t){return Q(this,null,function*(){const a=ia.BASE_URL,r=yield fetch(`${a}/api/resource/Comment/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"include"});if(!r.ok){const s=yield r.json().catch(()=>({}));throw new Error((s==null?void 0:s.exc)||"Failed to delete comment")}})},searchUsers(t){return Q(this,null,function*(){var d;const a=ia.BASE_URL,r=JSON.stringify(t?[["enabled","=",1],["user_type","=","System User"],["name","like",`%${t}%`]]:[["enabled","=",1],["user_type","=","System User"]]),s=JSON.stringify(["name","full_name","user_image"]),i=yield fetch(`${a}/api/resource/User?filters=${encodeURIComponent(r)}&fields=${encodeURIComponent(s)}&limit_page_length=20&order_by=full_name asc`,{credentials:"include"});return i.ok?((d=(yield i.json()).data)!=null?d:[]).filter(m=>m.name!=="Administrator"&&m.name!=="Guest"):[]})},getCurrentUser(){return Q(this,null,function*(){const t=ia.BASE_URL;return(yield(yield fetch(`${t}/api/method/frappe.auth.get_logged_user`,{credentials:"include"})).json()).message||""})}};function XM({referenceDoctype:t,referenceName:a,pollInterval:r=3e4}){const[s,i]=y.useState([]),[c,d]=y.useState(!0),[m,h]=y.useState(!1),[g,p]=y.useState(null),[b,j]=y.useState(""),[_,N]=y.useState([]),[k,C]=y.useState(!1),D=y.useRef(null);y.useEffect(()=>{Y0.getCurrentUser().then(j).catch(()=>{})},[]);const T=y.useCallback(()=>Q(null,null,function*(){if(!a){i([]),d(!1);return}try{const Y=yield Y0.getComments(t,a);i(Y),p(null)}catch(Y){console.error("Error fetching comments:",Y),p(Y.message||"Failed to load comments")}finally{d(!1)}}),[t,a]);y.useEffect(()=>{d(!0),T()},[T]),y.useEffect(()=>{if(!r||!a)return;const Y=setInterval(T,r);return()=>clearInterval(Y)},[r,T,a]);const E=y.useCallback(Y=>Q(null,null,function*(){if(a){h(!0);try{yield Y0.postComment(t,a,Y),yield T()}catch(P){throw P}finally{h(!1)}}}),[t,a,T]),O=y.useCallback(Y=>Q(null,null,function*(){try{yield Y0.deleteComment(Y),i(P=>P.filter(U=>U.name!==Y))}catch(P){throw P}}),[]),R=y.useCallback(Y=>Q(null,null,function*(){D.current&&clearTimeout(D.current),C(!0),D.current=setTimeout(()=>Q(null,null,function*(){try{const P=yield Y0.searchUsers(Y);N(P)}catch(P){N([])}finally{C(!1)}}),250)}),[]);return{comments:s,loading:c,posting:m,error:g,currentUser:b,refetch:T,postComment:E,deleteComment:O,mentionUsers:_,mentionLoading:k,searchMentionUsers:R}}const KM=({value:t,onChange:a,onSubmit:r,placeholder:s="Type a comment… Use @ to mention someone",disabled:i=!1,mentionUsers:c,mentionLoading:d,onMentionSearch:m,posting:h=!1})=>{const g=y.useRef(null),p=y.useRef(null),[b,j]=y.useState(!1),[_,N]=y.useState(""),[k,C]=y.useState(null),[D,T]=y.useState(0),[E,O]=y.useState([]),[R,Y]=y.useState({top:0,left:0}),P=y.useCallback(()=>{var te,W;const se=g.current;if(!se)return;const ee=se.getBoundingClientRect();(W=(te=se.offsetParent)==null?void 0:te.getBoundingClientRect())!=null,Y({top:se.offsetTop-4,left:se.offsetLeft})},[]),U=se=>{var oe;const ee=se.target.value,te=(oe=se.target.selectionStart)!=null?oe:0;a(ee);const W=ee.substring(0,te),I=W.lastIndexOf("@");if(I!==-1){const ae=I>0?ee[I-1]:" ";if(ae===" "||ae===`
`||I===0){const F=W.substring(I+1);if(!F.includes(" ")||F.length<=30){j(!0),N(F),C(I),T(0),m(F),P();return}}}j(!1),C(null)},J=y.useCallback(se=>{var F;if(k===null)return;const ee=g.current,te=t.substring(0,k),W=(F=ee==null?void 0:ee.selectionStart)!=null?F:k+_.length+1,I=t.substring(W),oe=se.full_name||se.name,ae=`${te}@${oe} ${I}`;O(M=>[...M,{startIndex:k,displayText:oe,userId:se.name,fullName:se.full_name||se.name}]),a(ae),j(!1),C(null),N(""),setTimeout(()=>{if(ee){ee.focus();const M=te.length+oe.length+2;ee.selectionStart=M,ee.selectionEnd=M}},0)},[k,_,t,a]),ne=se=>{if(b&&c.length>0)switch(se.key){case"ArrowDown":se.preventDefault(),T(ee=>Math.min(ee+1,c.length-1));return;case"ArrowUp":se.preventDefault(),T(ee=>Math.max(ee-1,0));return;case"Enter":se.preventDefault(),J(c[D]);return;case"Escape":se.preventDefault(),j(!1);return}se.key==="Enter"&&(se.ctrlKey||se.metaKey)&&(se.preventDefault(),he())},ye=y.useCallback(se=>{let ee=se;const te=ia.BASE_URL,W=[...E].sort((I,oe)=>oe.startIndex-I.startIndex);for(const I of W){const oe=`@${I.displayText}`,ae=ee.indexOf(oe);if(ae===-1)continue;const F=`${te}/app/user-profile/${encodeURIComponent(I.userId)}`,M=`<span class="mention" data-id="${I.userId}" data-value="&lt;a href=&quot;${F}&quot; target=&quot;_blank&quot;&gt;${I.fullName}" data-denotation-char="@" data-is-group="false" data-link="${F}">\uFEFF<span contenteditable="false"><span class="ql-mention-denotation-char">@</span><a href="${F}" target="_blank">${I.fullName}</a></span>\uFEFF</span>`;ee=ee.substring(0,ae)+M+ee.substring(ae+oe.length)}return ee=ee.replace(/\n/g,"<br>"),`<div class="ql-editor read-mode"><p>${ee}</p></div>`},[E]),he=()=>{const se=t.trim();if(!se||h)return;const ee=ye(se);r(ee),O([])};y.useEffect(()=>{const se=ee=>{p.current&&!p.current.contains(ee.target)&&g.current&&!g.current.contains(ee.target)&&j(!1)};return document.addEventListener("mousedown",se),()=>document.removeEventListener("mousedown",se)},[]),y.useEffect(()=>{if(!p.current)return;const se=p.current.querySelector(`[data-idx="${D}"]`);se==null||se.scrollIntoView({block:"nearest"})},[D]);const ce=ia.BASE_URL;return e.jsxs("div",{className:"relative",children:[b&&e.jsx("div",{ref:p,className:`absolute z-50 bottom-full mb-1 w-72 max-h-52 overflow-y-auto
bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-600
rounded-lg shadow-lg`,style:{left:0},children:d&&c.length===0?e.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-sm text-gray-500 dark:text-gray-400",children:[e.jsx(ya,{className:"animate-spin",size:12}),"Searching users…"]}):c.length===0?e.jsx("div",{className:"px-3 py-4 text-sm text-gray-500 dark:text-gray-400",children:"No users found"}):c.map((se,ee)=>e.jsxs("button",{"data-idx":ee,type:"button",className:`w-full flex items-center gap-2.5 px-3 py-2 text-left transition-colors
${ee===D?"bg-teal-50 dark:bg-teal-900/30 text-teal-800 dark:text-teal-200":"text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700"}`,onMouseEnter:()=>T(ee),onMouseDown:te=>{te.preventDefault(),J(se)},children:[se.user_image?e.jsx("img",{src:`${ce}${se.user_image}`,alt:"",className:"w-7 h-7 rounded-full object-cover flex-shrink-0"}):e.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-200 dark:bg-gray-600 flex items-center justify-center flex-shrink-0",children:e.jsx(js,{className:"text-gray-500 dark:text-gray-400",size:10})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:se.full_name||se.name}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:se.name})]})]},se.name))}),e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsx("textarea",{ref:g,value:t,onChange:U,onKeyDown:ne,placeholder:s,disabled:i||h,rows:3,className:`flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg
bg-white dark:bg-gray-700 text-gray-900 dark:text-white text-sm
disabled:bg-gray-100 dark:disabled:bg-gray-800
focus:outline-none focus:ring-2 focus:ring-teal-500 resize-none
placeholder:text-gray-400 dark:placeholder:text-gray-500`}),e.jsx("button",{type:"button",onClick:he,disabled:i||h||!t.trim(),className:`px-4 py-2 bg-teal-600 hover:bg-teal-700 disabled:bg-teal-600/50
text-white text-sm font-medium rounded-lg transition-colors
disabled:cursor-not-allowed flex items-center gap-1.5 h-10 flex-shrink-0`,children:h?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin",size:12}),e.jsx("span",{children:"Posting…"})]}):e.jsx("span",{children:"Comment"})})]}),e.jsxs("p",{className:"mt-1 text-[10px] text-gray-400 dark:text-gray-500",children:[e.jsx("kbd",{className:"px-1 py-0.5 bg-gray-100 dark:bg-gray-700 rounded text-[9px]",children:"@"})," to mention  · ",e.jsx("kbd",{className:"px-1 py-0.5 bg-gray-100 dark:bg-gray-700 rounded text-[9px]",children:"Ctrl+Enter"})," to post"]})]})},M_={Comment:{icon:e.jsx(eh,{size:10}),color:"text-blue-600 dark:text-blue-400",label:"Comment"},Info:{icon:e.jsx(Di,{size:10}),color:"text-gray-500 dark:text-gray-400",label:"Info"},Edit:{icon:e.jsx(Fr,{size:10}),color:"text-orange-500 dark:text-orange-400",label:"Edit"},Attachment:{icon:e.jsx(Y5,{size:10}),color:"text-purple-500 dark:text-purple-400",label:"Attachment"},Like:{icon:e.jsx(X0,{size:10}),color:"text-pink-500 dark:text-pink-400",label:"Like"}},QM=t=>{if(!t)return"";const a=new Date(t),r=new Date,s=r.getTime()-a.getTime(),i=Math.floor(s/6e4),c=Math.floor(s/36e5),d=Math.floor(s/864e5);return i<1?"Just now":i<60?`${i}m ago`:c<24?`${c}h ago`:d<7?`${d}d ago`:a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:a.getFullYear()!==r.getFullYear()?"numeric":void 0})},eL=t=>{if(!t)return"Unknown";const a=t.indexOf("@");return a===-1?t:t.substring(0,a).replace(/[._-]/g," ").replace(/\b\w/g,r=>r.toUpperCase())},tL=({html:t})=>{const a=t.replace(/<div class="ql-editor[^"]*">/g,"").replace(/<\/div>$/g,"");return e.jsx("div",{className:`comment-content text-sm text-gray-800 dark:text-gray-200 leading-relaxed
[&_a]:text-teal-600 [&_a]:dark:text-teal-400 [&_a]:underline [&_a]:font-medium
[&_.mention]:text-teal-700 [&_.mention]:dark:text-teal-300 [&_.mention]:font-semibold
[&_.mention]:bg-teal-50 [&_.mention]:dark:bg-teal-900/30 [&_.mention]:px-1 [&_.mention]:py-0.5
[&_.mention]:rounded [&_.mention]:pointer-events-none [&_.mention]:cursor-default
[&_.mention_a]:no-underline [&_.mention_a]:text-inherit
[&_p]:my-0`,dangerouslySetInnerHTML:{__html:a}})},Pc=({referenceDoctype:t,referenceName:a,title:r="Comments & Discussion",pollInterval:s=3e4,initialLimit:i=5,collapsible:c=!0,startCollapsed:d=!1})=>{const{comments:m,loading:h,posting:g,error:p,currentUser:b,refetch:j,postComment:_,deleteComment:N,mentionUsers:k,mentionLoading:C,searchMentionUsers:D}=XM({referenceDoctype:t,referenceName:a,pollInterval:s}),[T,E]=y.useState(!d),[O,R]=y.useState(!1),[Y,P]=y.useState(""),[U,J]=y.useState(null),ne=y.useMemo(()=>m.filter(se=>se.comment_type==="Comment"),[m]),ye=y.useMemo(()=>O?m:m.slice(-i),[m,O,i]),he=se=>Q(null,null,function*(){try{yield _(se),P(""),nt.success("Comment posted!",{position:"top-right",autoClose:2e3,icon:e.jsx(ea,{})})}catch(ee){nt.error(`Failed to post comment: ${ee.message||"Unknown error"}`,{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})})}}),ce=se=>Q(null,null,function*(){J(se);try{yield N(se),nt.success("Comment deleted",{position:"top-right",autoClose:2e3,icon:e.jsx(ea,{})})}catch(ee){nt.error(`Failed to delete: ${ee.message||"Unknown error"}`,{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})})}finally{J(null)}});return a?e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsxs("div",{className:`flex items-center justify-between px-5 py-3 border-b border-gray-200 dark:border-gray-700 ${c?"cursor-pointer select-none":""}`,onClick:()=>c&&E(se=>!se),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(eh,{className:"text-teal-500",size:16}),e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white",children:r}),ne.length>0&&e.jsx("span",{className:"px-2 py-0.5 bg-teal-100 dark:bg-teal-900/30 text-teal-700 dark:text-teal-300 rounded-full text-xs font-medium",children:ne.length})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),j()},disabled:h,className:"p-1.5 text-gray-400 hover:text-teal-500 hover:bg-teal-50 dark:hover:bg-teal-900/20 rounded transition-colors disabled:opacity-50",title:"Refresh comments",children:e.jsx(vn,{className:h?"animate-spin":"",size:11})}),c&&e.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:T?e.jsx(As,{size:12}):e.jsx(cs,{size:12})})]})]}),T&&e.jsxs("div",{className:"p-5 space-y-5",children:[p&&e.jsxs("div",{className:"flex items-center gap-2 text-red-600 dark:text-red-400 text-sm bg-red-50 dark:bg-red-900/20 rounded-lg p-3",children:[e.jsx(fa,{size:12}),p]}),h&&m.length===0&&e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(ya,{className:"animate-spin text-teal-500 mr-2",size:16}),e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Loading comments…"})]}),m.length>0&&e.jsxs(e.Fragment,{children:[!O&&m.length>i&&e.jsxs("button",{type:"button",onClick:()=>R(!0),className:`w-full text-center py-2 text-xs text-teal-600 dark:text-teal-400
hover:bg-teal-50 dark:hover:bg-teal-900/20 rounded-lg transition-colors font-medium`,children:["Show ",m.length-i," older comment",m.length-i!==1?"s":""]}),e.jsx("div",{className:"space-y-3",children:ye.map(se=>{const ee=M_[se.comment_type]||M_.Comment,te=se.comment_email===b||se.owner===b,W=U===se.name;return e.jsx("div",{className:`group relative rounded-lg border transition-colors ${se.comment_type==="Comment"?"bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600":"bg-gray-50 dark:bg-gray-800/50 border-gray-100 dark:border-gray-700/50"}`,children:e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-full bg-teal-100 dark:bg-teal-900/40 flex items-center justify-center flex-shrink-0",children:e.jsx(js,{className:"text-teal-600 dark:text-teal-400",size:10})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:se.comment_by||eL(se.comment_email||se.owner)}),se.comment_type!=="Comment"&&e.jsxs("span",{className:`ml-2 inline-flex items-center gap-1 text-[10px] font-medium ${ee.color}`,children:[ee.icon,ee.label]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-[11px] text-gray-400 dark:text-gray-500 flex items-center gap-1",title:new Date(se.creation).toLocaleString(),children:[e.jsx(or,{size:9}),QM(se.creation)]}),te&&se.comment_type==="Comment"&&e.jsx("button",{type:"button",onClick:()=>ce(se.name),disabled:W,className:`opacity-0 group-hover:opacity-100 p-1 text-gray-400 hover:text-red-500
hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-all disabled:opacity-50`,title:"Delete comment",children:W?e.jsx(ya,{className:"animate-spin",size:10}):e.jsx(Na,{size:10})})]})]}),e.jsx("div",{className:"ml-9",children:e.jsx(tL,{html:se.content})})]})},se.name)})}),O&&m.length>i&&e.jsx("button",{type:"button",onClick:()=>R(!1),className:`w-full text-center py-2 text-xs text-teal-600 dark:text-teal-400
hover:bg-teal-50 dark:hover:bg-teal-900/20 rounded-lg transition-colors font-medium`,children:"Show fewer comments"})]}),!h&&m.length===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx(eh,{className:"mx-auto text-gray-300 dark:text-gray-600 mb-2",size:28}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No comments yet. Start the discussion!"})]}),e.jsx("div",{className:"pt-3 border-t border-gray-200 dark:border-gray-700",children:e.jsx(KM,{value:Y,onChange:P,onSubmit:he,disabled:!a,posting:g,mentionUsers:k,mentionLoading:C,onMentionSearch:D})})]})]}):e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(eh,{className:"text-gray-400"}),e.jsx("span",{className:"text-sm",children:"Save the document first to enable comments."})]})})},aL=({doctype:t,docname:a,limit:r=50,enabled:s=!0})=>{const[i,c]=y.useState([]),[d,m]=y.useState(!1),[h,g]=y.useState(null),p=y.useCallback(()=>Q(null,null,function*(){if(!(!s||!t||!a)){m(!0),g(null);try{const b=yield mt.apiCall(`/api/resource/Version?filters=[["ref_doctype","=","${encodeURIComponent(t)}"],["docname","=","${encodeURIComponent(a)}"]]&fields=["name","owner","creation","data"]&order_by=creation desc&limit=${r}`);if(b!=null&&b.data&&b.data.length>0){const j=b.data.map(_=>{let N={added:[],changed:[],removed:[],row_changed:[]};try{N=JSON.parse(_.data||"{}")}catch(C){console.error("Error parsing version data:",C)}const k=(N.changed||[]).map(C=>({field:C[0]||"",oldValue:C[1],newValue:C[2]}));return{name:_.name,owner:_.owner,creation:_.creation,changes:k,added:N.added||[],removed:N.removed||[],rowChanged:N.row_changed||[]}});c(j)}else c([])}catch(b){console.error(`Error fetching audit logs for ${t}/${a}:`,b),g(b instanceof Error?b.message:"Failed to load activity log"),c([])}finally{m(!1)}}}),[t,a,r,s]);return y.useEffect(()=>{p()},[p]),{auditLogs:i,loading:d,error:h,refetch:p}},rL=t=>t?t.replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase()):"",L_=t=>t==null||t===""?"(empty)":t===0?"0":t===1?"1":typeof t=="boolean"?t?"Yes":"No":typeof t=="object"?JSON.stringify(t):String(t),Qk=t=>{if(!t)return"";const a=new Date(t),r=new Date,s=r.getTime()-a.getTime(),i=Math.floor(s/6e4),c=Math.floor(s/36e5),d=Math.floor(s/864e5);return i<1?"Just now":i<60?`${i} min${i>1?"s":""} ago`:c<24?`${c} hour${c>1?"s":""} ago`:d<7?`${d} day${d>1?"s":""} ago`:a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:a.getFullYear()!==r.getFullYear()?"numeric":void 0,hour:"2-digit",minute:"2-digit"})},ej=t=>{if(!t)return"Unknown";const a=t.indexOf("@");return a===-1?t:t.substring(0,a)},sL=t=>{const a=t.toLowerCase();return a.includes("status")||a.includes("state")||a.includes("workflow")?"text-purple-600 dark:text-purple-400":a.includes("date")?"text-blue-600 dark:text-blue-400":a.includes("technician")||a.includes("supervisor")||a.includes("assigned")||a.includes("location")||a.includes("department")||a.includes("building")||a.includes("room")?"text-green-600 dark:text-green-400":"text-gray-600 dark:text-gray-400"},nL=({log:t,isLatest:a,compact:r})=>{const s=r?"w-2.5 h-2.5":"w-3 h-3",i=r?"w-5 h-5":"w-6 h-6",c=r?8:10,d=r?"text-[10px]":"text-xs",m=r?"text-[9px]":"text-[10px]";return e.jsxs("div",{className:`relative ${r?"pl-6":"pl-8"}`,children:[e.jsx("div",{className:`absolute ${r?"left-1":"left-1.5"} top-1.5 ${s} rounded-full border-2 border-white dark:border-gray-800 ${a?"bg-blue-500":"bg-gray-300 dark:bg-gray-600"}`}),e.jsxs("div",{className:`${r?"p-2":"p-3"} rounded-lg ${a?"bg-blue-50 dark:bg-blue-900/20 border border-blue-100 dark:border-blue-800/50":"bg-gray-50 dark:bg-gray-700/50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:`${i} rounded-full bg-gray-200 dark:bg-gray-600 flex items-center justify-center`,children:e.jsx(js,{className:"text-gray-500 dark:text-gray-400",size:c})}),e.jsx("span",{className:`${d} font-medium text-gray-700 dark:text-gray-300`,children:ej(t.owner)})]}),e.jsxs("div",{className:`flex items-center gap-1 ${d} text-gray-500 dark:text-gray-400`,children:[e.jsx(or,{size:c}),e.jsx("span",{title:new Date(t.creation).toLocaleString(),children:Qk(t.creation)})]})]}),e.jsxs("div",{className:"space-y-1",children:[t.changes.length>0?t.changes.map((h,g)=>e.jsxs("div",{className:d,children:[e.jsx("span",{className:`font-medium ${sL(h.field)}`,children:rL(h.field)}),e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:" changed from "}),e.jsx("span",{className:`px-1 py-0.5 bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400 rounded ${m} font-mono`,children:L_(h.oldValue)}),e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:" → "}),e.jsx("span",{className:`px-1 py-0.5 bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400 rounded ${m} font-mono`,children:L_(h.newValue)})]},g)):e.jsx("p",{className:`${d} text-gray-500 dark:text-gray-400 italic`,children:"Document updated"}),t.added&&t.added.length>0&&e.jsxs("div",{className:`${d} text-green-600 dark:text-green-400`,children:[e.jsx("span",{className:"font-medium",children:"Added:"})," ",t.added.length," item(s)"]}),t.removed&&t.removed.length>0&&e.jsxs("div",{className:`${d} text-red-600 dark:text-red-400`,children:[e.jsx("span",{className:"font-medium",children:"Removed:"})," ",t.removed.length," item(s)"]}),t.rowChanged&&t.rowChanged.length>0&&e.jsxs("div",{className:`${d} text-orange-600 dark:text-orange-400`,children:[e.jsx("span",{className:"font-medium",children:"Modified:"})," ",t.rowChanged.length," row(s)"]})]})]})]})},R_=({creationDate:t,createdBy:a,doctype:r,compact:s})=>{const i=s?"w-2.5 h-2.5":"w-3 h-3",c=s?"w-5 h-5":"w-6 h-6",d=s?8:10,m=s?"text-[10px]":"text-xs",h=r.replace(/_/g," ");return e.jsxs("div",{className:`relative ${s?"pl-6":"pl-8"}`,children:[e.jsx("div",{className:`absolute ${s?"left-1":"left-1.5"} top-1.5 ${i} rounded-full border-2 border-white dark:border-gray-800 bg-green-500`}),e.jsxs("div",{className:`${s?"p-2":"p-3"} rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-100 dark:border-green-800/50`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:`${c} rounded-full bg-green-200 dark:bg-green-800 flex items-center justify-center`,children:e.jsx(js,{className:"text-green-600 dark:text-green-400",size:d})}),e.jsx("span",{className:`${m} font-medium text-gray-700 dark:text-gray-300`,children:ej(a)})]}),e.jsxs("div",{className:`flex items-center gap-1 ${m} text-gray-500 dark:text-gray-400`,children:[e.jsx(or,{size:d}),e.jsx("span",{title:new Date(t).toLocaleString(),children:Qk(t)})]})]}),e.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 bg-green-100 dark:bg-green-800/50 text-green-700 dark:text-green-300 rounded ${m} font-medium`,children:[e.jsx(ea,{size:d}),"Created this ",h]})]})]})},tj=({doctype:t,docname:a,creationDate:r,createdBy:s,title:i="Activity Log",limit:c=50,initialVisible:d=5,collapsible:m=!0,startCollapsed:h=!1,compact:g=!1,className:p="",onRefresh:b})=>{const[j,_]=y.useState(!h),[N,k]=y.useState(!1),{auditLogs:C,loading:D,refetch:T}=aL({doctype:t,docname:a,limit:c,enabled:!!a}),E=()=>{T(),b==null||b()};if(!a)return null;const O=g?14:16,R=g?"text-sm":"text-base",Y=g?"left-2":"left-3",P=g?"text-[10px]":"text-xs",U=g?8:10,J=N?C:C.slice(0,d);return e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 overflow-hidden ${p}`,children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:`flex items-center gap-2 flex-1 ${m?"cursor-pointer":""}`,onClick:()=>m&&_(!j),children:[e.jsx(_c,{className:"text-blue-500",size:O}),e.jsx("h2",{className:`${R} font-semibold text-gray-800 dark:text-white`,children:i}),C.length>0&&e.jsx("span",{className:"px-1.5 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 rounded-full text-[10px] font-medium",children:C.length})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:ne=>{ne.stopPropagation(),E()},disabled:D,className:"p-1 text-gray-400 hover:text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded transition-colors disabled:opacity-50",title:"Refresh activity log",children:e.jsx(vn,{className:D?"animate-spin":"",size:g?10:12})}),m&&e.jsx("button",{type:"button",onClick:()=>_(!j),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors p-1",children:j?e.jsx(As,{size:g?12:14}):e.jsx(cs,{size:g?12:14})})]})]}),j&&e.jsxs("div",{className:"p-3",children:[D&&e.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsx(ya,{className:"animate-spin text-blue-500 mr-2",size:14}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Loading..."})]}),!D&&C.length===0&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:`absolute ${Y} top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700`}),e.jsxs("div",{className:`relative ${g?"pl-6":"pl-8"} mb-3`,children:[e.jsx("div",{className:`absolute ${g?"left-1":"left-1.5"} top-1 ${g?"w-2.5 h-2.5":"w-3 h-3"} rounded-full border-2 border-white dark:border-gray-800 bg-gray-300 dark:bg-gray-600`}),e.jsx("div",{className:`${g?"p-2":"p-3"} rounded-lg bg-gray-50 dark:bg-gray-700/50`,children:e.jsx("p",{className:`${g?"text-[10px]":"text-xs"} text-gray-500 dark:text-gray-400 italic`,children:"No changes recorded yet"})})]}),r&&s&&e.jsx(R_,{creationDate:r,createdBy:s,doctype:t,compact:g})]}),!D&&C.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:`absolute ${Y} top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700`}),e.jsx("div",{className:"space-y-3",children:J.map((ne,ye)=>e.jsx(nL,{log:ne,isLatest:ye===0,compact:g},ne.name))}),C.length>d&&e.jsx("div",{className:"mt-3 text-center",children:e.jsx("button",{type:"button",onClick:()=>k(!N),className:`inline-flex items-center gap-1 px-2 py-1 ${P} font-medium text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-md transition-colors`,children:N?e.jsxs(e.Fragment,{children:[e.jsx(As,{size:U})," Show Less"]}):e.jsxs(e.Fragment,{children:[e.jsx(cs,{size:U})," Show All (",C.length,")"]})})}),r&&s&&e.jsx("div",{className:"mt-3",children:e.jsx(R_,{creationDate:r,createdBy:s,doctype:t,compact:g})})]})]})]})},iL=()=>{var De,Qe;const{t}=ca(),{assetName:a}=xo(),r=qa(),[s]=Qs(),i=s.get("duplicate"),c=a==="new",d=c&&!!i,{isAllowedOnSubmit:m}=HM("Asset"),[h,g]=y.useState({asset_name:"",company:"",custom_serial_number:"",custom_technical_department:"",location:"",custom_manufacturer:"",department:"",custom_asset_type:"Non Biomedical",custom_category:"General",custom_manufacturing_year:"",custom_model:"",custom_class:"",custom_device_status:"",custom_down_time:0,asset_owner_company:"",custom_up_time:0,custom_total_hours:0,custom_modality:"",custom_attach_image:"",custom_site_contractor:"",custom_site:"",custom_total_amount:0,calculate_depreciation:!1,available_for_use_date:void 0,finance_books:[],custom_service_agreement:"",custom_service_coverage:"",custom_start_date:"",custom_end_date:"",custom_warranty:!1,custom_extended_warranty:!1,custom__service_contract:!1,custom_covering_spare_parts:!1,custom_spare_parts_labour:!1,custom_covering_labour:!1,custom_ppm_only:!1,custom_support_plan:"",custom_spare_parts:[],custom_total_spare_parts_amount:0,custom_building:"",custom_room_number:"",is_existing_asset:!0,__islocal:!1}),{shouldShowField:p,isMandatory:b,isReadOnly:j}=Yk("Asset",h),{asset:_,loading:N,error:k,refetch:C}=O5(d?i:c?null:a||null),{createAsset:D,updateAsset:T,submitAsset:E,loading:O}=w2(),R=(_==null?void 0:_.workflow_state)||"Draft",{transitions:Y,workflowInfo:P,userRoles:U,isSystemManager:J,error:ne,canEdit:ye,getStateStyle:he}=ag({doctype:"Asset",docname:c?null:a||null,workflowState:R,enabled:!c&&!!a,docData:h}),[ce,se]=y.useState(c),ee=(De=_==null?void 0:_.docstatus)!=null?De:0,te=ee===1,W=ee===2,I=ee===0,oe=!!(_!=null&&_.custom_delete_status),ae=y.useMemo(()=>{const fe=["System Manager","Contractor Supervisor","Contractor Manager"];return J||U.some(re=>fe.includes(re))},[J,U]);y.useMemo(()=>ae&&(P!=null&&P.transitions)?P.transitions.filter(re=>re.state===R).map(re=>({action:re.action,next_state:re.next_state,allowed:re.allowed,condition:re.condition})):Y,[ae,P,R,Y]);const F=y.useMemo(()=>c||ae?!0:W?!1:P&&R?ye:I||Y.length>0,[c,ae,W,P,R,ye,I,Y.length]),M=y.useMemo(()=>J?!0:!(U.includes("Contractor Supervisor")||U.includes("End user")&&U.filter(re=>!["End user","All","Guest","Desk User"].includes(re)).length===0),[J,U]),B=y.useMemo(()=>U.includes("Cluster Manager")||J,[J,U]),[X,K]=y.useState(!1),we=y.useRef(null);y.useEffect(()=>{const fe=re=>{we.current&&!we.current.contains(re.target)&&K(!1)};return document.addEventListener("mousedown",fe),()=>document.removeEventListener("mousedown",fe)},[]),y.useEffect(()=>{},[_,ee,I,te,W,ce]);const be=y.useCallback(fe=>!ce||W||oe||j(fe)?!0:te?!m(fe):!I,[ce,W,te,I,m,j,oe]),ke=y.useCallback(fe=>p(fe),[p]);y.useCallback(fe=>b(fe),[b]);const Me=y.useCallback(()=>!!(h.custom_building||h.department),[h.custom_building,h.department]),z=y.useCallback(()=>!!(h.department||h.custom_room_number),[h.department,h.custom_room_number]),Ne=y.useCallback(()=>!!(h.custom_room_number||h.location),[h.custom_room_number,h.location]),[Xe,gt]=y.useState(""),[St,Ht]=y.useState({}),[Mt,Te]=y.useState([]),[Qt,zt]=y.useState([]),[Wt,Vt]=y.useState(!1),[va,ta]=y.useState(!1);y.useEffect(()=>{c&&!h.available_for_use_date&&g(fe=>Se(ue({},fe),{available_for_use_date:new Date().toISOString().split("T")[0],__islocal:!0}))},[c]),y.useEffect(()=>{function fe(){return Q(this,null,function*(){try{const re=yield mt.getUserDetails();gt(re.custom_site_name||""),g(Ee=>{const Ge={};if(c||!Ee.company){const ct=re.custom_site_name||"King Fahad Specialist Hospital - Dammam";Ge.company=ct,Ge.asset_owner_company=ct}return!Ee.custom_site&&re.custom_phcc_site_name&&(Ge.custom_site=re.custom_phcc_site_name),ue(ue({},Ee),Ge)})}catch(re){console.error("Error loading user details",re)}})}fe()},[c]);const sa=()=>{const re={finance_book:"Depreciation Entries",depreciation_method:"Straight Line",total_number_of_depreciations:10,frequency_of_depreciation:12,depreciation_start_date:new Date().toISOString().split("T")[0]};g(Ee=>Se(ue({},Ee),{finance_books:[...Ee.finance_books||[],re]}))},ra=fe=>{g(re=>{const Ee=[...re.finance_books||[]];return Ee.splice(fe,1),Se(ue({},re),{finance_books:Ee})})},Ye=(fe,re)=>{g(Ee=>{const Ge=[...Ee.finance_books||[]];return Ge[fe]=ue(ue({},Ge[fe]||{}),re),Se(ue({},Ee),{finance_books:Ge})})};y.useEffect(()=>{if(h.calculate_depreciation&&(!h.finance_books||h.finance_books.length===0)){const re={finance_book:"Depreciation Entries",depreciation_method:"Straight Line",total_number_of_depreciations:10,frequency_of_depreciation:12,depreciation_start_date:new Date().toISOString().split("T")[0]};g(Ee=>Se(ue({},Ee),{finance_books:[re]}))}},[h.calculate_depreciation]);const ft=(fe,re,Ee)=>{g(Ge=>{const ct=[...Ge.custom_spare_parts||[]],It=ue({},ct[fe]);re==="qty"||re==="rate"?(It[re]=Ee,It.amount=(It.qty||0)*(It.rate||0)):It[re]=Ee,ct[fe]=It;const st=ct.reduce((rt,V)=>rt+(V.amount||0),0);return Se(ue({},Ge),{custom_spare_parts:ct,custom_total_spare_parts_amount:st})})},$t=()=>{g(fe=>Se(ue({},fe),{custom_spare_parts:[...fe.custom_spare_parts||[],{qty:0,rate:0,amount:0}]}))},na=fe=>{g(re=>{const Ee=[...re.custom_spare_parts||[]];Ee.splice(fe,1);const Ge=Ee.reduce((ct,It)=>ct+(It.amount||0),0);return Se(ue({},re),{custom_spare_parts:Ee,custom_total_spare_parts_amount:Ge})})};y.useEffect(()=>{if(h.available_for_use_date){const fe=new Date(h.available_for_use_date),Ee=new Date().getTime()-fe.getTime(),ct=Math.floor(Ee/(1e3*60*60*24))*24,It=ct-(h.custom_down_time||0);g(st=>Se(ue({},st),{custom_total_hours:ct,custom_up_time:It}))}},[h.available_for_use_date,h.custom_down_time]);const Ze=y.useRef("");y.useEffect(()=>{if(!ce){Ze.current=h.custom_asset_type||"";return}const fe=(h.custom_asset_type||"").toString().trim().toLowerCase(),re=(Ze.current||"").toString().trim().toLowerCase();fe!==re&&(Ze.current=h.custom_asset_type||"",fe==="biomedical"?h.custom_site_contractor!=="SAMAMA"&&g(Ee=>Se(ue({},Ee),{custom_site_contractor:"SAMAMA"})):re==="biomedical"&&h.custom_site_contractor==="SAMAMA"&&g(Ee=>Se(ue({},Ee),{custom_site_contractor:""})))},[h.custom_asset_type,ce]),y.useEffect(()=>{const fe={};h.company&&(fe.company=h.company);const re=Xe&&Xe.startsWith("Mobile")||h.company&&h.company.startsWith("Mobile");(Xe||h.company)&&(re?fe.department_name=["not like","Non Bio%"]:fe.department_name=["not like","Non Bio%"]),Ht(fe)},[h.company,Xe]);const lt=y.useCallback((fe,re)=>Q(null,null,function*(){if(!fe){Te([]);return}ta(!0);try{const Ee=new URLSearchParams;Ee.append("building",fe),re&&Ee.append("company",re);const It=(yield(yield fetch(`/api/method/asset_lite.api.room_filter.get_department_count?${Ee.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).message||0;Te(new Array(It).fill("")),console.log("Department count for Asset:",{building:fe,company:re,count:It})}catch(Ee){console.error("Error fetching department count:",Ee),Te([])}finally{ta(!1)}}),[]),aa=y.useCallback((fe,re)=>Q(null,null,function*(){if(!fe&&!re){zt([]);return}Vt(!0);try{const Ee=new URLSearchParams;fe&&Ee.append("building",fe),re&&Ee.append("department",re);const It=(yield(yield fetch(`/api/method/asset_lite.api.room_filter.get_room_count?${Ee.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).message||0;zt(new Array(It).fill("")),console.log("Room count for Asset:",{building:fe,department:re,count:It})}catch(Ee){console.error("Error fetching room count:",Ee),zt([])}finally{Vt(!1)}}),[]);y.useEffect(()=>{const fe=h.custom_building||void 0,re=h.company||void 0;fe?lt(fe,re):Te([])},[h.custom_building,h.company,lt]),y.useEffect(()=>{const fe=h.custom_building||void 0,re=h.department||void 0;fe||re?aa(fe,re):zt([])},[h.custom_building,h.department,aa]);const Ie=y.useCallback(fe=>Q(null,null,function*(){if(g(re=>Se(ue({},re),{custom_room_number:fe})),!fe){g(re=>Se(ue({},re),{location:""}));return}try{const re=h.custom_building||"",Ee=h.department||"",Ge=[["room_no","=",fe]];re&&Ge.push(["building","=",re]),Ee&&Ge.push(["department","=",Ee]);const ct=JSON.stringify(Ge),It=yield mt.apiCall(`/api/resource/Infrastructure Location?filters=${encodeURIComponent(ct)}&fields=["location"]&limit=1`);It!=null&&It.data&&It.data.length>0&&It.data[0].location&&(g(st=>Se(ue({},st),{location:It.data[0].location})),console.log("Auto-set location:",It.data[0].location))}catch(re){console.error("Error fetching location for room:",re)}}),[h.custom_building,h.department]);y.useEffect(()=>{_&&(Ze.current=_.custom_asset_type||"",g({asset_name:d?`${_.asset_name} (Copy)`:_.asset_name||"",company:_.company||"",custom_serial_number:d?"":_.custom_serial_number||"",custom_technical_department:_.custom_technical_department||"",location:_.location||"",custom_manufacturer:_.custom_manufacturer||"",department:_.department||"",custom_asset_type:_.custom_asset_type||"Non Biomedical",custom_category:_.custom_category||"General",custom_manufacturing_year:_.custom_manufacturing_year||"",custom_model:_.custom_model||"",custom_class:_.custom_class||"",custom_device_status:_.custom_device_status||"",custom_down_time:_.custom_down_time||0,asset_owner_company:_.asset_owner_company||"",custom_up_time:_.custom_up_time||0,custom_total_hours:_.custom_total_hours||0,custom_modality:_.custom_modality||"",custom_attach_image:_.custom_attach_image||"",custom_site_contractor:_.custom_site_contractor||"",custom_site:_.custom_site||"",custom_total_amount:_.custom_total_amount||0,gross_purchase_amount:_.gross_purchase_amount||0,available_for_use_date:_.available_for_use_date||"",calculate_depreciation:_.calculate_depreciation||!1,finance_books:_.finance_books||[],custom_service_agreement:_.custom_service_agreement||"",custom_service_coverage:_.custom_service_coverage||"",custom_start_date:_.custom_start_date?_.custom_start_date.split(" ")[0]:"",custom_end_date:_.custom_end_date?_.custom_end_date.split(" ")[0]:"",custom_building:_.custom_building||"",custom_room_number:_.custom_room_number||"",custom_warranty:_.custom_warranty||!1,custom_extended_warranty:_.custom_extended_warranty||!1,custom__service_contract:_.custom__service_contract||!1,custom_covering_spare_parts:_.custom_covering_spare_parts||!1,custom_spare_parts_labour:_.custom_spare_parts_labour||!1,custom_covering_labour:_.custom_covering_labour||!1,custom_ppm_only:_.custom_ppm_only||!1,custom_support_plan:_.custom_support_plan||"",custom_spare_parts:_.custom_spare_parts||[],custom_total_spare_parts_amount:_.custom_total_spare_parts_amount||0}))},[_,d]);const[Nt,ve]=y.useState(null);y.useEffect(()=>{if(!a||a==="new")return;Q(null,null,function*(){var re;try{const Ee=`/files/${a}-qr.png`;if((yield fetch(Ee,{method:"HEAD"})).ok){ve(Ee);return}const ct=yield mt.apiCall(`/api/resource/File?filters=[["File","attached_to_name","=","${a}"]]`);((re=ct==null?void 0:ct.data)==null?void 0:re.length)>0&&ve(ct.data[0].file_url)}catch(Ee){console.error("Error loading QR code:",Ee)}})},[a,_]);const Oe=fe=>{const{name:re,value:Ee}=fe.target;g(Ge=>Se(ue({},Ge),{[re]:Ee}))},ht=fe=>Q(null,null,function*(){if(fe.preventDefault(),!h.asset_name){alert(t("assets.pleaseEnterAssetName"));return}if(!h.custom_asset_type){alert(t("assets.pleaseSelectCategory"));return}console.log("Submitting asset data:",h);try{if(c||d){const re=yield D(h);if(re.name){const Ge=`/files/${re.name}-qr.png`;ve(Ge)}const Ee=t(d?"assets.detail.assetDuplicatedSuccess":"assets.detail.assetCreatedSuccess");alert(Ee),r(`/assets/${re.name}`)}else a&&(yield T(a,h),alert(t("assets.detail.assetUpdatedSuccess")),se(!1),C())}catch(re){console.error("Asset save error:",re);const Ee=re instanceof Error?re.message:"Unknown error";Ee.includes("404")||Ee.includes("not found")||Ee.includes("has no attribute")||Ee.includes("417")?alert(`⚠️ Asset API Not Deployed
The Asset API endpoint (asset_api.py) is not deployed on your Frappe server yet.
To fix this:
1. SSH into your Frappe server
2. Navigate to: frappe-bench/apps/asset_lite/asset_lite/api/
3. Create the file: asset_api.py
4. Copy the content from frappe_asset_api.py in this project
5. Restart Frappe: bench restart
Error: `+Ee):alert(t("assets.detail.failedToSave")+`:
`+Ee)}}),et=()=>{C()},Be=()=>Q(null,null,function*(){if(!a||c){alert(t("assets.detail.cannotSubmitNotSaved"));return}if(window.confirm(t("assets.detail.confirmSubmit")))try{yield E(a),alert(t("assets.detail.assetSubmittedSuccess")),C(),se(!1)}catch(fe){console.error("Asset submit error:",fe);const re=fe instanceof Error?fe.message:"Unknown error";alert(t("assets.detail.failedToSubmit")+`:
`+re)}});if(N)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("assets.loadingAssetDetails")})]})});if(k&&!c&&!d)return e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[e.jsxs("p",{className:"text-red-600 dark:text-red-400",children:[t("common.error"),": ",k]}),e.jsx("button",{onClick:()=>r(-1),className:"mt-2 text-red-700 dark:text-red-400 underline hover:text-red-800 dark:hover:text-red-300",children:t("assets.backToList")})]})});if(k&&d)return e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-yellow-800 dark:text-yellow-300 mb-2",children:t("assets.sourceAssetNotFound")}),e.jsx("p",{className:"text-yellow-700 dark:text-yellow-400",children:t("assets.assetNotFoundMessage")}),e.jsxs("div",{className:"mt-4 flex gap-3",children:[e.jsx("button",{onClick:()=>r("/assets/new"),className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors",children:t("assets.createNewAsset")}),e.jsx("button",{onClick:()=>r(-1),className:"px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg transition-colors",children:t("assets.backToAssetsList")})]})]})});const kt=()=>{if(!Nt||!_)return;const fe=window.open("","_blank");fe&&(fe.document.write(`
<!DOCTYPE html>
<html>
<head>
<title>Print QR Code - ${_.name}</title>
<style>
@page {
margin: 0.5in;
size: auto;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
padding: 0;
}
.qr-container {
text-align: center;
border: 2px solid #333;
padding: 20px;
border-radius: 8px;
background: white;
max-width: 400px;
}
.qr-image {
width: 300px;
height: 300px;
margin: 15px 0;
display: block;
margin-left: auto;
margin-right: auto;
}
h1 {
font-size: 20px;
margin-bottom: 10px;
}
.asset-info {
margin: 10px 0;
font-size: 14px;
line-height: 1.5;
}
</style>
</head>
<body>
<div class="qr-container">
<h1>Asset QR Code</h1>
<div class="asset-info">
<strong>Asset ID:</strong> ${_.name}<br/>
<strong>Asset Name:</strong> ${_.asset_name||"N/A"}
</div>
<img src="${Nt}" alt="QR Code" class="qr-image" onload="window.print();" />
</div>
</body>
</html>
`),fe.document.close())},it=()=>{const fe=window.open("","_blank");fe&&(fe.document.write(`
<!DOCTYPE html>
<html>
<head>
<title>Stay Plugged</title>
<style>
@page {
margin: 0.5in;
size: auto;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
padding: 0;
}
.image-container {
text-align: center;
padding: 40px;
max-width: 100%;
}
.stay-plugged-image {
max-width: 100%;
height: auto;
display: block;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="image-container">
<img src="/files/Stay Plugged.jpg" alt="Stay Plugged" class="stay-plugged-image" onload="window.print();" />
</div>
</body>
</html>
`),fe.document.close())},xt=()=>Q(null,null,function*(){if(!a||c){alert(t("assets.detail.pleaseSaveFirstForPPM"));return}try{const fe=yield mt.apiCall(`/api/resource/Asset Maintenance Log?filters=[["asset_name","=","${a}"],["maintenance_status","=","Planned"]]&fields=["name","due_date","periodicity","custom_asset_names","asset_name","maintenance_type","assign_to_name"]`),re=(fe==null?void 0:fe.data)||[],Ee=(ie,xe)=>{const _e=new Date(ie);return _e.setDate(_e.getDate()+xe),_e},Ge=(ie,xe)=>{const _e=new Date(ie);return _e.setMonth(_e.getMonth()+xe),_e},ct=(ie,xe)=>{const _e=new Date(ie);return _e.setFullYear(_e.getFullYear()+xe),_e},It=(ie,xe)=>{switch(xe){case"Daily":return Ee(ie,1);case"Weekly":return Ee(ie,7);case"Monthly":return Ge(ie,1);case"Quarterly":return Ge(ie,3);case"Half-yearly":return Ge(ie,6);case"Yearly":return ct(ie,1);case"2 Yearly":return ct(ie,2);case"3 Yearly":return ct(ie,3);default:return Ge(ie,1)}},st=ie=>ie.toISOString().split("T")[0],rt=ct(new Date,5),V=[];for(const ie of re){let xe=new Date(ie.due_date);const _e=ie.periodicity||"Monthly";for(let He=0;He<60&&(V.push({asset_name:ie.asset_name||"",custom_asset_names:ie.custom_asset_names||"",serial_number:h.custom_serial_number||"N/A",due_date:st(xe),periodicity:_e,maintenance_type:ie.maintenance_type||"",assign_to_name:ie.assign_to_name||"",status:"Planned"}),xe=It(xe,_e),!(xe>rt));He++);}V.sort((ie,xe)=>new Date(ie.due_date).getTime()-new Date(xe.due_date).getTime());const me=window.open("","_blank");if(!me)return;const de=V.length>0?V.map((ie,xe)=>`
<tr class="${xe%2===0?"bg-white":"bg-gray-50"}">
<td class="border px-3 py-2">${ie.asset_name}</td>
<td class="border px-3 py-2">${ie.custom_asset_names}</td>
<td class="border px-3 py-2">${ie.serial_number}</td>
<td class="border px-3 py-2">${ie.due_date}</td>
<td class="border px-3 py-2">${ie.periodicity}</td>
<td class="border px-3 py-2">${ie.maintenance_type}</td>
<td class="border px-3 py-2">${ie.assign_to_name}</td>
<td class="border px-3 py-2">
<span class="px-2 py-1 bg-yellow-100 text-yellow-800 rounded text-xs">${ie.status}</span>
</td>
</tr>
`).join(""):'<tr><td colspan="8" class="border px-3 py-4 text-center text-gray-500">No planned maintenance found for this asset</td></tr>';me.document.write(`
<!DOCTYPE html>
<html>
<head>
<title>PPM Plan - ${a}</title>
<style>
@page {
margin: 0.5in;
size: landscape;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
padding: 20px;
background: #f5f5f5;
}
.container {
max-width: 1400px;
margin: 0 auto;
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
padding-bottom: 15px;
border-bottom: 2px solid #3b82f6;
}
h1 {
font-size: 24px;
color: #1f2937;
}
.asset-info {
font-size: 14px;
color: #6b7280;
}
.btn {
padding: 10px 20px;
font-size: 14px;
border: none;
border-radius: 5px;
cursor: pointer;
margin-left: 10px;
}
.btn-print {
background: #3b82f6;
color: white;
}
.btn-print:hover {
background: #2563eb;
}
.btn-close {
background: #6b7280;
color: white;
}
.btn-close:hover {
background: #4b5563;
}
.table-container {
overflow-x: auto;
margin-top: 20px;
}
table {
width: 100%;
border-collapse: collapse;
font-size: 13px;
}
th {
background: #3b82f6;
color: white;
padding: 12px 8px;
text-align: left;
border: 1px solid #2563eb;
font-weight: 600;
}
td {
border: 1px solid #e5e7eb;
padding: 8px;
}
.bg-white { background: white; }
.bg-gray-50 { background: #f9fafb; }
.summary {
margin-top: 20px;
padding: 15px;
background: #f0f9ff;
border-radius: 5px;
font-size: 14px;
color: #1e40af;
}
@media print {
.no-print { display: none; }
body { background: white; padding: 0; }
.container { box-shadow: none; padding: 0; }
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<div>
<h1>PPM Planner Report</h1>
<div class="asset-info">
<strong>Asset ID:</strong> ${a} |
<strong>Asset Name:</strong> ${h.asset_name||"N/A"} |
<strong>Generated:</strong> ${new Date().toLocaleDateString()}
</div>
</div>
<div class="no-print">
<button class="btn btn-print" onclick="window.print()">Print / Save PDF</button>
<button class="btn btn-close" onclick="window.close()">Close</button>
</div>
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th>Asset ID</th>
<th>Asset Name</th>
<th>Serial Number</th>
<th>Due Date</th>
<th>Periodicity</th>
<th>Maintenance Type</th>
<th>Assigned To</th>
<th>Status</th>
</tr>
</thead>
<tbody>
${de}
</tbody>
</table>
</div>
<div class="summary">
<strong>Summary:</strong> ${V.length} planned maintenance entries for the next 5 years
</div>
</div>
</body>
</html>
`),me.document.close()}catch(fe){console.error("Error fetching PPM Plan:",fe),alert(t("assets.detail.failedToLoadPPMPlan"))}}),Dt=()=>Q(null,null,function*(){if(!a||c){alert(t("assets.detail.pleaseSaveFirstForHistory"));return}try{const fe=yield mt.apiCall(`/api/resource/Asset/${a}`),re=(fe==null?void 0:fe.data)||{},Ee=yield mt.apiCall(`/api/resource/Work_Order?filters=[["asset","=","${a}"]]&fields=["name","work_order_type","repair_status","creation","total_repair_cost"]`),Ge=(Ee==null?void 0:Ee.data)||[],ct=yield mt.apiCall(`/api/resource/Asset Maintenance?filters=[["asset_name","=","${a}"]]&fields=["name","maintenance_team","custom_type_of_maintenance"]`),It=(ct==null?void 0:ct.data)||[];let st=[],rt=[];for(const dt of It){const pt=yield mt.apiCall(`/api/resource/Asset Maintenance/${dt.name}`),At=(pt==null?void 0:pt.data)||{};At.asset_maintenance_tasks&&(rt=[...rt,...At.asset_maintenance_tasks.map(Fa=>Se(ue({},Fa),{maintenance_id:dt.name}))]);const Zt=yield mt.apiCall(`/api/resource/Asset Maintenance Log?filters=[["asset_maintenance","=","${dt.name}"]]&fields=["name","maintenance_status","assign_to_name","maintenance_type","due_date","completion_date","periodicity","actions_performed"]&order_by=completion_date desc`);st=[...st,...(Zt==null?void 0:Zt.data)||[]]}const V=st.filter(dt=>dt.maintenance_status==="Completed"),me=st.filter(dt=>dt.maintenance_status!=="Completed"),de={};st.forEach(dt=>{de[dt.maintenance_status]=(de[dt.maintenance_status]||0)+1});const ie=re.custom_spare_parts||[],xe={};ie.forEach(dt=>{const pt=dt.work_order||"Unassigned";xe[pt]||(xe[pt]=[]),xe[pt].push(dt)});const _e=window.open("","_blank");if(!_e)return;const He=Ge.length>0?Ge.map((dt,pt)=>{const At=dt.repair_status==="Completed"?"bg-green-100 text-green-800":dt.repair_status==="Work In Progress"?"bg-yellow-100 text-yellow-800":"bg-gray-100 text-gray-800";return`
<tr class="${pt%2===0?"bg-white":"bg-gray-50"}">
<td class="px-4 py-3 font-medium text-blue-600">${dt.name}</td>
<td class="px-4 py-3">${dt.work_order_type||"-"}</td>
<td class="px-4 py-3"><span class="px-2 py-1 rounded-full text-xs font-medium ${At}">${dt.repair_status||"-"}</span></td>
<td class="px-4 py-3 font-semibold">${parseFloat(dt.total_repair_cost||0).toFixed(2)} ر.س</td>
<td class="px-4 py-3 text-gray-500">${dt.creation?new Date(dt.creation).toLocaleDateString():"-"}</td>
</tr>
`}).join(""):'<tr><td colspan="5" class="px-4 py-8 text-center text-gray-500">No Work Orders Found</td></tr>';let Ue="";Object.keys(xe).length>0?Object.keys(xe).forEach(dt=>{Ue+=`
<div class="mb-4">
<div class="bg-amber-50 border-l-4 border-amber-400 px-4 py-2 mb-2">
<span class="font-medium">Work Order: </span>
<span class="text-blue-600 font-medium">${dt}</span>
</div>
<table class="w-full">
<thead>
<tr class="bg-gray-100">
<th class="px-4 py-2 text-left text-xs font-semibold text-gray-600">Item Name</th>
<th class="px-4 py-2 text-left text-xs font-semibold text-gray-600">Quantity</th>
<th class="px-4 py-2 text-left text-xs font-semibold text-gray-600">Cost</th>
<th class="px-4 py-2 text-left text-xs font-semibold text-gray-600">Amount</th>
</tr>
</thead>
<tbody>
${xe[dt].map((pt,At)=>`
<tr class="${At%2===0?"bg-white":"bg-gray-50"}">
<td class="px-4 py-2">${pt.item_code||"-"}</td>
<td class="px-4 py-2">${pt.qty||0}</td>
<td class="px-4 py-2">${pt.rate||0} ر.س</td>
<td class="px-4 py-2 font-medium">${pt.amount||0} ر.س</td>
</tr>
`).join("")}
</tbody>
</table>
</div>
`}):Ue='<p class="text-gray-500 text-center py-8">No Spare Parts Used</p>';const Pe=It.length>0?It.map(dt=>`
<div class="bg-white border rounded-lg p-4 mb-3 shadow-sm">
<div class="flex justify-between items-start">
<div>
<p class="text-sm text-gray-500">Maintenance ID</p>
<p class="font-medium text-blue-600">${dt.name}</p>
</div>
<div class="text-right">
<p class="text-sm text-gray-500">Type</p>
<p class="font-medium">${dt.custom_type_of_maintenance||"-"}</p>
</div>
</div>
<div class="mt-2">
<p class="text-sm text-gray-500">Maintenance Team</p>
<p class="font-medium">${dt.maintenance_team||"-"}</p>
</div>
</div>
`).join(""):'<p class="text-gray-500 text-center py-8">No Maintenance Records Found</p>',Re=rt.length>0?rt.map((dt,pt)=>`
<tr class="${pt%2===0?"bg-white":"bg-gray-50"}">
<td class="px-4 py-3">${dt.assign_to_name||"-"}</td>
<td class="px-4 py-3">${dt.periodicity||"-"}</td>
<td class="px-4 py-3">${dt.next_due_date||"-"}</td>
<td class="px-4 py-3 text-blue-600 text-sm">${dt.maintenance_id||"-"}</td>
</tr>
`).join(""):'<tr><td colspan="4" class="px-4 py-8 text-center text-gray-500">No Maintenance Tasks Found</td></tr>',We=Object.keys(de).length>0?Object.entries(de).map(([dt,pt])=>`
<div class="flex items-center justify-between p-3 rounded-lg border ${dt==="Completed"?"bg-green-100 text-green-800 border-green-200":dt==="Planned"?"bg-blue-100 text-blue-800 border-blue-200":"bg-yellow-100 text-yellow-800 border-yellow-200"}">
<span class="font-medium">${dt}</span>
<span class="text-2xl font-bold">${pt}</span>
</div>
`).join(""):'<p class="text-gray-500 text-center">No Data</p>',_t=V.length>0?V.map((dt,pt)=>`
<tr class="${pt%2===0?"bg-white":"bg-gray-50"}">
<td class="px-3 py-2 text-blue-600 font-medium">${dt.name}</td>
<td class="px-3 py-2">${dt.assign_to_name||"-"}</td>
<td class="px-3 py-2">${dt.maintenance_type||"-"}</td>
<td class="px-3 py-2">${dt.due_date||"-"}</td>
<td class="px-3 py-2 text-green-600 font-medium">${dt.completion_date||"-"}</td>
<td class="px-3 py-2">${dt.periodicity||"-"}</td>
<td class="px-3 py-2 text-sm text-gray-600">${dt.actions_performed||"-"}</td>
</tr>
`).join(""):'<tr><td colspan="7" class="px-4 py-8 text-center text-gray-500">No Completed Maintenance Logs</td></tr>',Ft=me.length>0?me.map((dt,pt)=>{const At=dt.maintenance_status==="Planned"?"bg-blue-100 text-blue-800":"bg-yellow-100 text-yellow-800";return`
<tr class="${pt%2===0?"bg-white":"bg-gray-50"}">
<td class="px-3 py-2 text-blue-600 font-medium">${dt.name}</td>
<td class="px-3 py-2">${dt.assign_to_name||"-"}</td>
<td class="px-3 py-2">${dt.maintenance_type||"-"}</td>
<td class="px-3 py-2">${dt.due_date||"-"}</td>
<td class="px-3 py-2">${dt.periodicity||"-"}</td>
<td class="px-3 py-2"><span class="px-2 py-1 rounded-full text-xs font-medium ${At}">${dt.maintenance_status||"-"}</span></td>
<td class="px-3 py-2 text-sm text-gray-600">${dt.actions_performed||"-"}</td>
</tr>
`}).join(""):'<tr><td colspan="7" class="px-4 py-8 text-center text-gray-500">No Pending/Planned Maintenance Logs</td></tr>';_e.document.write(`
<!DOCTYPE html>
<html>
<head>
<title>Asset History - ${a}</title>
<script src="https://cdn.tailwindcss.com"><\/script>
<style>
@page { margin: 0.5in; size: landscape; }
@media print {
.no-print { display: none !important; }
.page-break { page-break-before: always; }
}
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
.section-card {
background: white;
border-radius: 12px;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
margin-bottom: 24px;
overflow: hidden;
}
.section-header {
padding: 16px 20px;
font-weight: 600;
font-size: 16px;
display: flex;
align-items: center;
gap: 10px;
}
.section-content {
padding: 16px 20px;
}
table {
width: 100%;
border-collapse: collapse;
}
th {
text-align: left;
padding: 12px 16px;
font-size: 12px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.5px;
}
td {
border-top: 1px solid #e5e7eb;
}
</style>
</head>
<body class="bg-gray-100 min-h-screen">
<!-- Header -->
<div class="bg-gradient-to-r from-blue-600 to-blue-800 text-white py-6 px-8 no-print">
<div class="max-w-7xl mx-auto flex justify-between items-center">
<div>
<h1 class="text-2xl font-bold">Asset History</h1>
<p class="text-blue-200 mt-1">Complete history and maintenance records</p>
</div>
<div class="flex gap-3">
<button onclick="window.print()" class="bg-white text-blue-600 px-4 py-2 rounded-lg font-medium hover:bg-blue-50 transition">
🖨️ Print / Save PDF
</button>
<button onclick="window.close()" class="bg-blue-700 text-white px-4 py-2 rounded-lg font-medium hover:bg-blue-600 transition">
✕ Close
</button>
</div>
</div>
</div>
<div class="max-w-7xl mx-auto py-6 px-8">
<!-- Asset Details Card -->
<div class="section-card">
<div class="section-header bg-gradient-to-r from-blue-500 to-blue-600 text-white">
<span>🔍</span> Asset Details
</div>
<div class="section-content">
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4">
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-xs text-gray-500 uppercase tracking-wide">Asset ID</p>
<p class="font-semibold text-blue-600 mt-1">${a}</p>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-xs text-gray-500 uppercase tracking-wide">Asset Name</p>
<p class="font-semibold mt-1">${re.asset_name||"-"}</p>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-xs text-gray-500 uppercase tracking-wide">🏥 Hospital</p>
<p class="font-semibold mt-1">${re.company||"-"}</p>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-xs text-gray-500 uppercase tracking-wide">📍 Location</p>
<p class="font-semibold mt-1">${re.location||"-"}</p>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-xs text-gray-500 uppercase tracking-wide">🚛 Supplier</p>
<p class="font-semibold mt-1">${re.supplier||"-"}</p>
</div>
<div class="bg-amber-50 rounded-lg p-4 border border-amber-200">
<p class="text-xs text-amber-600 uppercase tracking-wide">💰 Total Repair Cost</p>
<p class="font-bold text-amber-700 mt-1 text-lg">${re.custom_total_spare_parts_amount||0} ر.س</p>
</div>
</div>
</div>
</div>
<!-- Two Column Layout -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<!-- Work Orders -->
<div class="section-card">
<div class="section-header bg-gradient-to-r from-indigo-500 to-indigo-600 text-white">
<span>🔗</span> Linked Work Orders
</div>
<div class="overflow-x-auto">
<table>
<thead class="bg-gray-50">
<tr>
<th class="text-gray-600">Work Order No</th>
<th class="text-gray-600">Type</th>
<th class="text-gray-600">Status</th>
<th class="text-gray-600">Repair Cost</th>
<th class="text-gray-600">Created</th>
</tr>
</thead>
<tbody>
${He}
</tbody>
</table>
</div>
</div>
<!-- Spare Parts -->
<div class="section-card">
<div class="section-header bg-gradient-to-r from-orange-500 to-orange-600 text-white">
<span>🛠️</span> Items Used for Repair
</div>
<div class="section-content max-h-96 overflow-y-auto">
${Ue}
</div>
</div>
</div>
<!-- Maintenance Section -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mt-6">
<!-- Maintenance Records -->
<div class="section-card">
<div class="section-header bg-gradient-to-r from-teal-500 to-teal-600 text-white">
<span>🛠️</span> Maintenance Records
</div>
<div class="section-content max-h-80 overflow-y-auto">
${Pe}
</div>
</div>
<!-- Maintenance Tasks -->
<div class="section-card lg:col-span-2">
<div class="section-header bg-gradient-to-r from-purple-500 to-purple-600 text-white">
<span>📋</span> Maintenance Tasks
</div>
<div class="overflow-x-auto">
<table>
<thead class="bg-gray-50">
<tr>
<th class="text-gray-600">Assigned To</th>
<th class="text-gray-600">Periodicity</th>
<th class="text-gray-600">Next Due Date</th>
<th class="text-gray-600">Maintenance ID</th>
</tr>
</thead>
<tbody>
${Re}
</tbody>
</table>
</div>
</div>
</div>
<!-- Periodic Maintenance Summary -->
<div class="section-card mt-6">
<div class="section-header bg-gradient-to-r from-cyan-500 to-cyan-600 text-white">
<span>📜</span> Periodic Maintenance Summary
</div>
<div class="section-content">
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
${We}
</div>
</div>
</div>
<!-- Completed Maintenance Logs -->
<div class="section-card mt-6">
<div class="section-header bg-gradient-to-r from-green-500 to-green-600 text-white">
<span>✅</span> Completed Maintenance Logs
</div>
<div class="overflow-x-auto">
<table>
<thead class="bg-gray-50">
<tr>
<th class="text-gray-600">Log ID</th>
<th class="text-gray-600">Assigned To</th>
<th class="text-gray-600">Type</th>
<th class="text-gray-600">Due Date</th>
<th class="text-gray-600">Completed</th>
<th class="text-gray-600">Periodicity</th>
<th class="text-gray-600">Actions</th>
</tr>
</thead>
<tbody>
${_t}
</tbody>
</table>
</div>
</div>
<!-- Pending/Planned Maintenance Logs -->
<div class="section-card mt-6">
<div class="section-header bg-gradient-to-r from-amber-500 to-amber-600 text-white">
<span>⏳</span> Pending/Planned Maintenance Logs
</div>
<div class="overflow-x-auto">
<table>
<thead class="bg-gray-50">
<tr>
<th class="text-gray-600">Log ID</th>
<th class="text-gray-600">Assigned To</th>
<th class="text-gray-600">Type</th>
<th class="text-gray-600">Due Date</th>
<th class="text-gray-600">Periodicity</th>
<th class="text-gray-600">Status</th>
<th class="text-gray-600">Actions</th>
</tr>
</thead>
<tbody>
${Ft}
</tbody>
</table>
</div>
</div>
<!-- Footer -->
<div class="text-center text-gray-500 text-sm mt-8 pb-8">
Generated on ${new Date().toLocaleString()} | Asset: ${a}
</div>
</div>
</body>
</html>
`),_e.document.close()}catch(fe){console.error("Error fetching Asset History:",fe),alert("Failed to load Asset History. Please try again.")}}),Ot=()=>{if(!a||c){alert("Please save the asset first to view Installation Report");return}const fe=window.open("","_blank");if(!fe)return;const re=new Date,Ee=st=>{const rt=String(st.getDate()).padStart(2,"0"),V=String(st.getMonth()+1).padStart(2,"0"),me=st.getFullYear();return`${rt}/${V}/${me}`},Ge=(_==null?void 0:_.custom_spare_parts)||[];let ct="";const It=3;if(Ge.length>0){Ge.forEach((st,rt)=>{ct+=`
<tr>
<td>${rt+1}</td>
<td>${st.item_name||""}</td>
<td>${st.item_code||""}</td>
<td>${st.uom||""}</td>
<td>${st.qty||""}</td>
</tr>
`});for(let st=Ge.length;st<It;st++)ct+=`
<tr>
<td>${st+1}</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
`}else for(let st=0;st<It;st++)ct+=`
<tr>
<td>${st+1}</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
`;fe.document.write(`
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Installation Report - ${a}</title>
<style>
@page {
margin: 0.5in;
size: A4;
}
body {
font-family: 'Times New Roman', serif;
margin: 0;
padding: 20px;
font-size: 12px;
line-height: 1.3;
direction: rtl;
text-align: right;
}
.header-line {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 5px;
}
.header-right {
font-weight: bold;
}
.header-center {
font-weight: bold;
text-align: center;
flex-grow: 1;
}
.header-left {
font-weight: bold;
}
.dotted-line {
border-bottom: 1px dotted #000;
display: inline-block;
min-width: 100px;
}
.main-content {
margin: 15px 0;
text-align: justify;
}
.equipment-section {
margin: 15px 0;
}
.equipment-line {
display: flex;
justify-content: space-between;
margin: 8px 0;
font-weight: bold;
}
.equipment-item {
display: flex;
align-items: center;
direction: ltr;
text-align: left;
width: 48%;
}
.arabic-label {
direction: rtl;
text-align: right;
margin-left: 10px;
}
.colon {
margin: 0 5px;
}
.field-value {
border-bottom: 1px solid #000;
min-width: 120px;
display: inline-block;
height: 18px;
}
.location-line {
margin: 10px 0;
font-weight: bold;
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
}
.location-arabic {
direction: rtl;
text-align: right;
}
.location-english {
direction: ltr;
text-align: left;
}
.parts-table {
width: 100%;
border-collapse: collapse;
margin: 15px 0;
border: 2px solid #000;
}
.parts-table th,
.parts-table td {
border: 1px solid #000;
padding: 6px;
text-align: center;
font-weight: bold;
vertical-align: middle;
}
.parts-table th {
background-color: #f8f8f8;
font-size: 11px;
}
.parts-table .row-number {
width: 8%;
}
.parts-table .description {
width: 35%;
}
.parts-table .part-number {
width: 25%;
}
.parts-table .unit {
width: 16%;
}
.parts-table .quantity {
width: 16%;
}
.footer-text {
margin: 20px 0;
text-align: justify;
}
.signatures-section {
margin-top: 40px;
}
.signature-row {
display: flex;
justify-content: space-between;
margin: 30px 0;
}
.signature-block-right {
text-align: left;
width: 45%;
float: right;
}
.signature-block-left {
text-align: left;
width: 45%;
float: left;
}
.signature-title {
font-weight: bold;
margin-bottom: 3px;
font-size: 11px;
}
.signature-line {
border-bottom: 1px solid #000;
height: 25px;
margin: 8px 0;
display: inline-block;
width: 120px;
margin-left: 10px;
}
.signature-label {
font-size: 10px;
font-weight: bold;
}
.seal-section {
text-align: center;
margin-top: 30px;
font-weight: bold;
font-size: 12px;
}
</style>
</head>
<body>
<!-- Header Section -->
<div class="header-line">
<div class="header-right">المملكة العربية السعودية</div>
<div class="header-center"></div>
<div class="header-left">الرقم: <span class="dotted-line">${a||""}</span></div>
</div>
<div class="header-line">
<div class="header-right">تجمع الجوف الصحي</div>
<div class="header-center">محضر تركيب</div>
<div class="header-left">التاريخ: <span class="dotted-line">${Ee(re)}</span> هـ</div>
</div>
<div class="header-line">
<div class="header-right">الصيانة الطبية</div>
<div class="header-center">INSTALLATION REPORT</div>
<div class="header-left">الموافق: <span class="dotted-line">${Ee(re)}</span> م</div>
</div>
<div style="margin: 15px 0; font-weight: bold;">
مستشفى <span class="dotted-line" style="min-width: 200px;">${h.company||""}</span>
</div>
<!-- Main Content -->
<div class="main-content">
تشهد مستشفى <span class="dotted-line" style="min-width: 180px;">${h.company||""}</span> بأن <span class="dotted-line" style="min-width: 180px;">${h.supplier||""}</span> قامت بتركيب و توريد قطع الغيار الخاصة التالية والتابعة:
</div>
<!-- Equipment Information -->
<div class="equipment-section">
<div class="equipment-line">
<div class="equipment-item">
<span>EQUIPMENT NAME</span>
<span class="colon">:</span>
<span class="field-value">${h.asset_name||""}</span>
<span class="arabic-label">اسم الجهاز:</span>
</div>
<div class="equipment-item">
<span>MFR</span>
<span class="colon">:</span>
<span class="field-value">${h.custom_manufacturer||""}</span>
<span class="arabic-label">صناعة:</span>
</div>
</div>
<div class="equipment-line">
<div class="equipment-item">
<span>SERIAL NO</span>
<span class="colon">:</span>
<span class="field-value">${h.custom_serial_number||""}</span>
<span class="arabic-label">مسلسل:</span>
</div>
<div class="equipment-item">
<span>MODEL</span>
<span class="colon">:</span>
<span class="field-value">${h.custom_model||""}</span>
<span class="arabic-label">موديل:</span>
</div>
</div>
</div>
<div class="location-line">
<span class="location-arabic">
التابع لقسم:
</span>
<span class="field-value" style="min-width: 300px; flex-grow: 1; margin: 0 10px; text-align: left;">${h.location||""}</span>
<span class="location-english">
LOCATION:
</span>
</div>
<!-- Parts Table -->
<table class="parts-table">
<thead>
<tr>
<th class="row-number">م</th>
<th class="description">وصف القطعة<br>DESCRIPTION</th>
<th class="part-number">رقم القطعة<br>PART NO.</th>
<th class="unit">الوحدة<br>UNIT</th>
<th class="quantity">الكمية<br>QTY.</th>
</tr>
</thead>
<tbody>
${ct}
</tbody>
</table>
<!-- Footer Text -->
<div class="footer-text">
وذلك طبقا لعقد صيانة وإصلاح الأجهزة الطبية بمستشفى <span class="dotted-line" style="min-width: 150px;">${h.company||""}</span> والجهاز يعمل بحالة جيدة.
<br><br>
وﷲ الموفق .....
</div>
<!-- Signatures Section -->
<div class="signatures-section">
<!-- First Row -->
<div class="signature-row">
<div class="signature-block-right">
<div class="signature-title">المسئول في القسم &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dept. Responsible</div>
<div><span class="signature-line"></span><span class="signature-label">Name</span></div>
<div><span class="signature-line"></span><span class="signature-label">Sign</span></div>
</div>
<div class="signature-block-left">
<div class="signature-title">مدير شركة سمامة &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Site Manager</div>
<div><span class="signature-line"></span><span class="signature-label">Name</span></div>
<div><span class="signature-line"></span><span class="signature-label">Sign</span></div>
</div>
</div>
<!-- Installation Engineer - Right aligned -->
<div style="text-align: left; margin: 25px 0; width: 45%; float: right; clear: both;">
<div class="signature-title">مهندس/ فني التركيب &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Installation Eng</div>
<div><span class="signature-line"></span><span class="signature-label">Name</span></div>
<div><span class="signature-line"></span><span class="signature-label">Sign</span></div>
</div>
<div style="clear: both;"></div>
<!-- Second Row -->
<div class="signature-row">
<div class="signature-block-right">
<div class="signature-title">مشرف الوزارة بالمستشفى &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hospital Supervisor</div>
<div><span class="signature-line"></span><span class="signature-label">Name</span></div>
<div><span class="signature-line"></span><span class="signature-label">Sign</span></div>
</div>
<div class="signature-block-left">
<div class="signature-title">مدير المستشفى/ المركز &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hospital Manager</div>
<div><span class="signature-line"></span><span class="signature-label">Name</span></div>
<div><span class="signature-line"></span><span class="signature-label">Sign</span></div>
</div>
</div>
</div>
<!-- Official Seal -->
<div class="seal-section">
الختم الرسمي
</div>
<script>
window.onload = function() {
window.print();
};
<\/script>
</body>
</html>
`),fe.document.close()},Rt=()=>{if(!a||c){alert("Please save the asset first to view Dismantling Report");return}const fe=window.open("","_blank");if(!fe)return;const re=new Date,Ee=It=>{const st=String(It.getDate()).padStart(2,"0"),rt=String(It.getMonth()+1).padStart(2,"0"),V=It.getFullYear();return`${st}/${rt}/${V}`},Ge=_!=null&&_.creation?new Date(_.creation):null;let ct="";if(Ge){const It=Math.floor((re.getTime()-Ge.getTime())/31536e6),st=Math.floor((re.getTime()-Ge.getTime())%(1e3*60*60*24*365)/(1e3*60*60*24*30));ct=`${It} سنة و ${st} شهر`}fe.document.write(`
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dismantling Report - ${a}</title>
<style>
@page {
margin: 0.5in;
size: A4;
}
body {
font-family: 'Times New Roman', serif;
margin: 0;
padding: 20px;
font-size: 12px;
line-height: 1.4;
direction: rtl;
text-align: right;
}
.header {
text-align: left;
margin-bottom: 30px;
}
.title {
text-align: center;
font-size: 14px;
font-weight: bold;
margin: 20px 0;
}
.department-line {
margin: 15px 0;
font-weight: bold;
}
.section-title {
font-weight: bold;
margin: 20px 0 10px 0;
}
.reasons-section {
margin: 20px 0;
}
.reasons-table {
width: 60%;
border-collapse: collapse;
margin: 10px 0;
}
.reasons-table td {
border: 2px solid #000;
padding: 8px;
text-align: center;
font-weight: bold;
width: 16.66%;
height: 30px;
}
.reason-text {
margin: 8px 0;
text-align: right;
font-size: 11px;
direction: rtl;
word-wrap: break-word;
overflow-wrap: break-word;
}
.committee-opinion {
margin: 20px 0;
padding: 10px;
border: 1px solid #ccc;
text-align: justify;
}
.signatures-table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
}
.signatures-table td {
padding: 8px;
text-align: right;
vertical-align: top;
font-weight: bold;
direction: rtl;
word-wrap: break-word;
overflow-wrap: break-word;
}
.signature-title {
font-size: 11px;
height: 30px;
font-weight: bold;
}
.signature-field {
height: 25px;
font-size: 10px;
}
.hospital-manager {
text-align: right;
margin: 20px 0;
}
.hospital-manager-table {
width: 100%;
margin: 0;
border-collapse: collapse;
float: right;
}
.hospital-manager-table td {
padding: 8px;
text-align: right;
font-weight: bold;
direction: rtl;
word-wrap: break-word;
overflow-wrap: break-word;
}
.seal-section {
text-align: center;
margin: 30px 0;
font-weight: bold;
}
.footer {
margin-top: 40px;
text-align: right;
}
.footer-title {
font-weight: bold;
margin-bottom: 5px;
color: #0066cc;
}
.footer-name {
font-size: 11px;
color: #0066cc;
}
.logo {
width: 100px;
height: 60px;
margin: 0;
display: inline-flex;
align-items: center;
justify-content: center;
}
.logo img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
}
.equipment-table {
width: 100%;
border: 1px solid black;
border-collapse: collapse;
}
.equipment-table td {
width: 25%;
border: 1px solid black;
padding: 8px;
}
</style>
</head>
<body>
<!-- Header Section -->
<div class="header">
<div class="logo"><img src='/files/SEMH!.png' onerror="this.style.display='none'"></div>
</div>
<!-- Title -->
<div class="title">
محضر تكهين / إبعاد عن الخدمة
</div>
<!-- Department -->
<div class="department-line">
القسم : <span style="border-bottom: 1px solid #000; min-width: 200px; display: inline-block;">${h.department||""}</span>
</div>
<!-- Equipment Data Section -->
<div class="section-title">0-1 بيانات الجهاز المطلوب تكهينه :</div>
<table class="equipment-table">
<tr>
<td>اسم الجهاز</td>
<td>${h.asset_name||""}</td>
<td>الرقم التسلسلي</td>
<td>${h.custom_serial_number||""}</td>
</tr>
<tr>
<td>الشركة الصانعة</td>
<td>${h.custom_manufacturer||""}</td>
<td>تاريخ التوريد</td>
<td>${Ge?Ee(Ge):""}</td>
</tr>
<tr>
<td>الطراز/الموديل</td>
<td>${h.custom_model||""}</td>
<td>مدة استخدام الجهاز</td>
<td>${ct}</td>
</tr>
</table>
<!-- Reasons Section -->
<div class="section-title">2- أسباب طلب التكهين / إبعاد عن الخدمة :</div>
<table class="reasons-table">
<tr>
<td>أ</td>
<td>ب</td>
<td>ج</td>
<td>د</td>
<td>هـ</td>
<td>و</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<div class="reason-text">
أ) تكاليف قطع الغيار المطلوبة للإصلاح أكثر من نصف قيمة الجهاز (مرفق عرض أسعار قطع الغيار اللازمة للإصلاح).
</div>
<div class="reason-text">
ب) توقف انتاج الجهاز وقطع الغيار من الشركة الصانعة حسب تقرير المورد.
</div>
<div class="reason-text">
ج) جهاز قديم وتم استخدامه أكثر من عشر سنوات.
</div>
<div class="reason-text">
د) ليس للجهاز وكيل معروف بالمملكة في الوقت الحالي ولا يمكن توفير قطع غيار للجهاز.
</div>
<div class="reason-text">
ه) تكرار أعطال الجهاز وإصلاحه على فترات متقاربة.
</div>
<div class="reason-text">
و) أخرى : <span style="border-bottom: 1px solid #000; min-width: 300px; display: inline-block;"></span>
</div>
<!-- Committee Opinion -->
<div class="section-title">3- مرئيات اللجنة:</div>
<div class="reason-text">
بناءاً على الفقرة أ. ج. و. يتم تكهين الجهاز وادراجه ضمن بنود الإحلال المطلوبة للمستشفى.
</div>
<!-- Signatures Section -->
<div class="section-title">توقيع اللجنة :</div>
<table class="signatures-table">
<tr>
<td class="signature-title">المقاول</td>
<td class="signature-title">رئيس القسم</td>
<td class="signature-title">مدير الصيانة الطبية</td>
<td class="signature-title">مدير مراقبة المخزون</td>
</tr>
<tr>
<td class="signature-field">الإسم :</td>
<td class="signature-field">الإسم :</td>
<td class="signature-field">الإسم :</td>
<td class="signature-field">الإسم :</td>
</tr>
<tr>
<td class="signature-field">التوقيع :</td>
<td class="signature-field">التوقيع :</td>
<td class="signature-field">التوقيع :</td>
<td class="signature-field">التوقيع :</td>
</tr>
<tr>
<td class="signature-field">التاريخ :</td>
<td class="signature-field">التاريخ :</td>
<td class="signature-field">التاريخ :</td>
<td class="signature-field">التاريخ :</td>
</tr>
</table>
<!-- Hospital Manager Section -->
<div class="hospital-manager">
<table class="hospital-manager-table">
<tr>
<td class="signature-title">مدير مستشفى</td>
</tr>
<tr>
<td class="signature-field">الإسم :</td>
</tr>
<tr>
<td class="signature-field">التوقيع :</td>
</tr>
<tr>
<td class="signature-field">التاريخ :</td>
</tr>
<tr>
<td class="signature-field">الختم :</td>
</tr>
</table>
</div>
<!-- Arabic text after last table -->
<div style="clear: both; text-align: left; margin: 20px 0;">
<div style="font-weight: bold; margin-bottom: 5px;">الصيانة الطبية بتجمع الجوف الصحي</div>
<div>المهندس/عبد العزيز زايد الخمعلي</div>
</div>
<!-- Footer -->
<div class="footer">
<div style="color: #0066cc; font-weight: bold;">تجمع الجوف الصحي</div>
<div style="color: #0066cc;">Aljouf Health Cluster</div>
</div>
<script>
window.onload = function() {
window.print();
};
<\/script>
</body>
</html>
`),fe.document.close()};return e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("button",{onClick:()=>r(-1),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[e.jsx(en,{}),e.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:d?"Duplicate Asset":c?"New Asset Details":"Asset Details"})]}),_&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${he(R).bg} ${he(R).text} ${he(R).border} border`,children:R})})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[!c&&!ce&&!W&&F&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",ref:we,children:[e.jsxs("button",{onClick:()=>K(!X),className:"bg-blue-600 hover:bg-blue-700 text-white px-2 py-1 rounded-lg flex items-center gap-2",children:["Actions",e.jsx(cs,{size:12,className:`transition-transform ${X?"rotate-180":""}`})]}),X&&e.jsx("div",{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-gray-800 rounded-md shadow-lg z-50 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"py-1",children:[Nt&&e.jsxs("button",{onClick:()=>{kt(),K(!1)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[e.jsx(Cl,{size:14}),"Print QR"]}),e.jsxs("button",{onClick:()=>{it(),K(!1)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[e.jsx(Cl,{size:14}),"Stay Plugged"]}),e.jsxs("button",{onClick:()=>{xt(),K(!1)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[e.jsx(go,{size:14}),"PPM Plan"]}),e.jsxs("button",{onClick:()=>{Dt(),K(!1)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[e.jsx(_c,{size:14}),"Asset History"]}),e.jsxs("button",{onClick:()=>{Ot(),K(!1)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[e.jsx(W5,{size:14}),"Installation Report"]}),(_==null?void 0:_.status)==="Scrapped"&&e.jsxs("button",{onClick:()=>{Rt(),K(!1)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-red-50 dark:hover:bg-red-900/20 flex items-center gap-2 text-red-600 dark:text-red-400 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(K5,{size:14}),"Dismantling Report"]})]})})]}),M&&!oe&&e.jsxs("button",{onClick:()=>se(!0),className:"bg-blue-600 hover:bg-blue-700 text-white px-2 py-1 rounded-lg flex items-center gap-2",children:[e.jsx(Fr,{}),"Edit"]}),I&&B&&e.jsxs("button",{onClick:Be,disabled:O,className:"bg-purple-600 hover:bg-purple-700 text-white px-2 py-1 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[e.jsx(dc,{}),O?"Submitting...":"Submit"]})]}),W&&e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 italic",children:"Cancelled documents cannot be edited"}),ce&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{c?r(-1):se(!1)},className:"bg-gray-300 hover:bg-gray-400 text-gray-700 dark:text-gray-800 px-2 py-1 rounded-lg",disabled:O,children:"Cancel"}),e.jsxs("button",{onClick:ht,disabled:O,className:"bg-green-600 hover:bg-green-700 text-white px-2 py-1 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[e.jsx(Or,{}),O?"Saving...":"Save Changes"]})]})]})]}),e.jsxs("form",{onSubmit:ht,children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:t("assets.detail.assetInformation")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t("assets.detail.assetName")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",name:"asset_name",value:h.asset_name,onChange:Oe,placeholder:t("assets.detail.placeholderAssetName"),required:!0,disabled:be("asset_name"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsx("input",{type:"hidden",name:"custom_asset_type",value:"Non Biomedical"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Category"}),e.jsx("select",{name:"custom_category",value:h.custom_category||"General",onChange:Oe,disabled:be("custom_category"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:e.jsx("option",{value:"General",children:"General"})})]}),e.jsx(Ut,{label:t("assets.detail.modality"),doctype:"Modality",value:h.custom_modality||"",onChange:fe=>g(Se(ue({},h),{custom_modality:fe})),disabled:be("custom_modality")}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.class")}),e.jsxs("select",{name:"custom_class",value:h.custom_class,onChange:Oe,disabled:be("custom_class"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("assets.detail.selectClass")}),e.jsx("option",{value:"Class A",children:t("assets.detail.classA")}),e.jsx("option",{value:"Class B",children:t("assets.detail.classB")}),e.jsx("option",{value:"Class C",children:t("assets.detail.classC")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.assetId")}),e.jsx("input",{type:"text",value:c||d?t("assets.detail.autoGenerated"):_==null?void 0:_.name,disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400"}),d&&e.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:["💡 ",t("assets.detail.duplicatingFrom")," ",i]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t("assets.detail.deviceStatus")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("select",{name:"custom_device_status",value:h.custom_device_status,onChange:Oe,disabled:!ce,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"Up",children:t("assets.status.up")}),e.jsx("option",{value:"Down",children:t("assets.status.down")})]})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:t("assets.detail.technicalSpecs")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.serialCode")}),e.jsx("input",{type:"text",name:"custom_serial_number",value:h.custom_serial_number,onChange:Oe,placeholder:t("assets.detail.placeholderSerialCode"),disabled:be("custom_serial_number"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsx(Ut,{label:t("assets.detail.technicalDepartment"),doctype:"Issue Type",value:h.custom_technical_department||"",onChange:fe=>g(Se(ue({},h),{custom_technical_department:fe})),disabled:be("custom_technical_department")}),e.jsx(Ut,{label:t("assets.detail.manufacturer"),doctype:"Manufacturer",value:h.custom_manufacturer||"",onChange:fe=>g(Se(ue({},h),{custom_manufacturer:fe})),disabled:be("custom_manufacturer"),allowQuickCreate:!0}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.model")}),e.jsx("input",{type:"text",name:"custom_model",value:h.custom_model,onChange:Oe,placeholder:t("assets.detail.placeholderModelNumber"),disabled:be("custom_model"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.totalHours")}),e.jsx("input",{type:"number",name:"custom_total_hours",value:h.custom_total_hours||0,disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:t("assets.detail.calculatedFromAvailableDate")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.downTimeHours")}),e.jsx("input",{type:"number",name:"custom_down_time",value:h.custom_down_time||0,onChange:Oe,placeholder:t("assets.detail.placeholderZero"),disabled:be("custom_down_time"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.upTimeHours")}),e.jsx("input",{type:"number",name:"custom_up_time",value:h.custom_up_time||0,disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:t("assets.detail.calculatedTotalMinusDown")})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:t("assets.detail.location")}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ut,{label:t("assets.detail.hospital"),doctype:"Company",value:h.company||"",onChange:fe=>{g(Se(ue({},h),{company:fe,asset_owner_company:fe,department:""}))},disabled:be("company"),filters:{domain:"Healthcare"}}),ke("custom_site")&&e.jsx("div",{children:e.jsx(Ut,{label:t("assets.detail.siteName"),doctype:"Mobile Team Site",value:h.custom_site||"",onChange:fe=>g(Se(ue({},h),{custom_site:fe})),disabled:be("custom_site"),placeholder:t("assets.detail.selectSite")})}),e.jsxs("div",{children:[e.jsx(Ut,{label:t("assets.detail.building"),doctype:"Building",value:h.custom_building||"",onChange:fe=>{g(re=>Se(ue({},re),{custom_building:fe,department:"",custom_room_number:"",location:""}))},disabled:be("custom_building"),allowQuickCreate:!0}),!h.custom_building&&ce&&e.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:t("assets.detail.selectBuildingFirst")})]}),Me()&&e.jsxs("div",{children:[e.jsx(Ut,{label:t("assets.detail.department"),doctype:"Department",value:h.department||"",onChange:fe=>{g(re=>Se(ue({},re),{department:fe,custom_room_number:"",location:""}))},disabled:be("department"),query:h.custom_building?"asset_lite.api.room_filter.get_filtered_departments":void 0,filters:(()=>{const fe={};return h.custom_building&&(fe.building=h.custom_building),h.company&&(fe.company=h.company),Xe&&Xe.startsWith("Mobile")||h.company&&h.company.startsWith("Mobile")||(fe.department_name=["not like","Non Bio%"]),fe})(),allowQuickCreate:!0}),va&&e.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400 flex items-center gap-1",children:[e.jsx(ya,{className:"animate-spin",size:10}),t("common.loading")]}),!va&&h.custom_building&&Mt.length===0&&e.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:t("assets.detail.noDepartmentsMapped")}),!va&&h.custom_building&&Mt.length>0&&e.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:t("assets.detail.departmentsAvailable",{count:Mt.length})}),!h.department&&h.custom_building&&ce&&e.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:t("assets.detail.selectDepartmentForRoom")})]}),z()&&e.jsxs("div",{children:[e.jsx(Ut,{label:t("assets.detail.roomNumber"),doctype:"Room",value:h.custom_room_number||"",onChange:Ie,disabled:be("custom_room_number"),query:"asset_lite.api.room_filter.get_filtered_rooms",filters:(()=>{const fe={};return h.custom_building&&(fe.building=h.custom_building),h.department&&(fe.department=h.department),fe})(),allowQuickCreate:!0}),Wt&&e.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400 flex items-center gap-1",children:[e.jsx(ya,{className:"animate-spin",size:10}),t("common.loading")]}),!Wt&&(h.custom_building||h.department)&&Qt.length===0&&e.jsxs("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:["No rooms mapped to ",h.custom_building&&h.department?"this building + department":h.custom_building?"this building":"this department"]}),!Wt&&(h.custom_building||h.department)&&Qt.length>0&&e.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:[Qt.length," room(s) available",h.custom_building&&!h.department&&" (filtered by building)",!h.custom_building&&h.department&&" (filtered by department)",h.custom_building&&h.department&&" (filtered by building + department)"]}),!h.custom_room_number&&h.department&&ce&&e.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:t("assets.detail.selectRoomFirst")})]}),Ne()&&e.jsxs("div",{children:[e.jsx(Ut,{label:t("assets.detail.location"),doctype:"Location",value:h.location||"",onChange:fe=>g(Se(ue({},h),{location:fe})),disabled:be("location"),allowQuickCreate:!0}),h.custom_room_number&&h.location&&e.jsxs("p",{className:"mt-1 text-xs text-green-600 dark:text-green-400",children:["✓ ",t("assets.detail.autoSetFromRoom")]})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:t("assets.detail.moreDetails")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col items-center my-4",children:[e.jsx("div",{className:"border-2 border-gray-300 dark:border-gray-600 p-3 rounded-lg bg-white dark:bg-gray-700",children:Nt?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:Nt,alt:`QR Code for ${(_==null?void 0:_.name)||"Asset"}`,className:"w-[120px] h-[120px] object-contain",onError:fe=>{const re=fe.target;re.style.display="none";const Ee=re.nextElementSibling;Ee&&(Ee.style.display="flex")}}),e.jsx("div",{className:"w-[120px] h-[120px] hidden items-center justify-center bg-gray-100 dark:bg-gray-700 rounded",children:e.jsx(Cl,{size:80,className:"text-gray-400 dark:text-gray-500"})})]}):e.jsx("div",{className:"w-[120px] h-[120px] flex items-center justify-center bg-gray-100 dark:bg-gray-700 rounded",children:e.jsx(Cl,{size:80,className:"text-gray-400 dark:text-gray-500"})})}),(_==null?void 0:_.name)&&e.jsxs("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400 text-center",children:["Asset ID: ",_.name]})]}),!c&&_&&!d&&e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx("span",{children:"📋"})," Workflow Actions"]}),e.jsx(Tp,{doctype:"Asset",docname:a||null,workflowState:R,onActionComplete:(fe,re)=>{re&&C()},onStateChange:et,showStateInfo:!0,className:""}),ne&&e.jsx("div",{className:"mt-3 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:ne})}),!1]})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Description"}),e.jsx("textarea",{rows:4,placeholder:t("assets.detail.placeholderDescription"),disabled:!ce,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 mt-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:t("assets.detail.coverage")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.siteContractor")}),e.jsx("input",{type:"text",name:"custom_site_contractor",value:h.custom_site_contractor,onChange:Oe,disabled:be("custom_site_contractor"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.contractNumber")}),e.jsx("input",{type:"text",disabled:!ce,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.serviceAgreement")}),e.jsxs("select",{name:"custom_service_agreement",value:h.custom_service_agreement||"",onChange:Oe,disabled:be("custom_service_agreement"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("assets.detail.selectServiceAgreement")}),e.jsx("option",{value:"Warranty",children:t("assets.detail.warranty")}),e.jsx("option",{value:"Contract",children:t("assets.detail.contract")}),e.jsx("option",{value:"Frame Work",children:t("assets.detail.frameWork")}),e.jsx("option",{value:"Main Contractor",children:t("assets.detail.mainContractor")}),e.jsx("option",{value:"Out of warranty",children:t("assets.detail.outOfWarranty")}),e.jsx("option",{value:"Under Dismantle",children:t("assets.detail.underDismantle")}),e.jsx("option",{value:"Under Installation",children:t("assets.detail.underInstallation")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.serviceCoverage")}),e.jsxs("select",{name:"custom_service_coverage",value:h.custom_service_coverage||"",onChange:Oe,disabled:be("custom_service_coverage"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("assets.detail.selectServiceCoverage")}),e.jsx("option",{value:"PM Only",children:t("assets.detail.pmOnly")}),e.jsx("option",{value:"Labour",children:t("assets.detail.labour")}),e.jsx("option",{value:"Labour & Parts",children:t("assets.detail.labourAndParts")}),e.jsx("option",{value:"Comprehensive",children:t("assets.detail.comprehensive")})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.startDate")}),e.jsx("input",{type:"date",name:"custom_start_date",value:h.custom_start_date||"",onChange:Oe,disabled:be("custom_start_date"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.endDate")}),e.jsx("input",{type:"date",name:"custom_end_date",value:h.custom_end_date||"",onChange:Oe,disabled:be("custom_end_date"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.totalAmount")}),e.jsx("input",{type:"number",name:"custom_total_amount",value:h.custom_total_amount,onChange:Oe,disabled:be("custom_total_amount"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Comments"}),e.jsx("textarea",{rows:2,disabled:!ce,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Acquisition Details"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.purchaseOrderNumber")}),e.jsx("input",{type:"text",placeholder:t("assets.detail.placeholderPONumber"),disabled:!ce,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsx(Ut,{label:t("assets.detail.supplierVendor"),doctype:"Supplier",value:h.supplier||"",onChange:fe=>g(Se(ue({},h),{supplier:fe})),disabled:be("supplier")}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.grossPurchaseAmount")}),e.jsx("input",{type:"number",name:"gross_purchase_amount",value:h.gross_purchase_amount||0,onChange:Oe,disabled:be("gross_purchase_amount"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.purchaseDate")}),e.jsx("input",{type:"date",disabled:!ce,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.installationDate")}),e.jsx("input",{type:"date",disabled:!ce,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.availableForUseDate")}),e.jsx("input",{type:"date",name:"available_for_use_date",value:h.available_for_use_date||"",onChange:fe=>g(re=>Se(ue({},re),{available_for_use_date:fe.target.value})),disabled:be("available_for_use_date"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]})]}),e.jsx("div",{className:"mt-6",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:t("assets.detail.financialDetails")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:t("assets.detail.depreciationMethodNote")}),e.jsxs("div",{className:"flex items-center mb-6",children:[e.jsx("input",{id:"calculate_depreciation",type:"checkbox",checked:h.calculate_depreciation,onChange:fe=>g(Se(ue({},h),{calculate_depreciation:fe.target.checked})),disabled:!ce,className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700"}),e.jsx("label",{htmlFor:"calculate_depreciation",className:"ml-2 text-sm font-medium text-gray-700 dark:text-gray-300",children:t("assets.detail.calculateDepreciation")})]}),h.calculate_depreciation&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("h3",{className:"text-md font-semibold text-gray-800 dark:text-white",children:t("assets.detail.assetFinanceBooks")}),ce&&e.jsxs("button",{type:"button",onClick:sa,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 flex items-center gap-2",children:[e.jsx("span",{children:"+"})," ",t("assets.detail.addRow")]})]}),(!h.finance_books||h.finance_books.length===0)&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400 bg-gray-50 dark:bg-gray-900 rounded-lg",children:t("assets.detail.noFinanceBooksYet")}),h.finance_books&&h.finance_books.length>0&&e.jsx("div",{className:"overflow-visible",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-300 dark:border-gray-600",children:[e.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[200px]",children:t("assets.detail.financeBook")}),e.jsxs("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[200px]",children:[t("assets.detail.depreciationMethod"),"*"]}),e.jsxs("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[180px]",children:[t("assets.detail.totalDepreciations"),"*"]}),e.jsxs("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[180px]",children:[t("assets.detail.frequencyMonths"),"*"]}),e.jsxs("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[200px]",children:[t("assets.detail.depreciationPostingDate"),"*"]}),ce&&e.jsx("th",{className:"text-center px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[120px]",children:t("common.actions")})]})}),e.jsx("tbody",{children:h.finance_books.map((fe,re)=>{var Ee,Ge;return e.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-750",children:[e.jsx("td",{className:"px-4 py-3 relative",style:{overflow:"visible"},children:e.jsx("div",{className:"relative z-20",children:e.jsx(Ut,{label:"",doctype:"Finance Book",value:fe.finance_book||"",onChange:ct=>Ye(re,{finance_book:ct}),disabled:!ce})})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("select",{value:fe.depreciation_method||"",onChange:ct=>Ye(re,{depreciation_method:ct.target.value}),disabled:!ce,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("assets.detail.selectMethod")}),e.jsx("option",{value:"Straight Line",children:t("assets.detail.straightLine")}),e.jsx("option",{value:"Double Declining Balance",children:t("assets.detail.doubleDecliningBalance")}),e.jsx("option",{value:"Written Down Value",children:t("assets.detail.writtenDownValue")}),e.jsx("option",{value:"Manual",children:t("assets.detail.manual")})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("input",{type:"number",value:(Ee=fe.total_number_of_depreciations)!=null?Ee:"",onChange:ct=>Ye(re,{total_number_of_depreciations:Number(ct.target.value)}),disabled:!ce,placeholder:t("assets.detail.placeholderZero"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("input",{type:"number",value:(Ge=fe.frequency_of_depreciation)!=null?Ge:"",onChange:ct=>Ye(re,{frequency_of_depreciation:Number(ct.target.value)}),disabled:!ce,placeholder:"0",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("input",{type:"date",value:fe.depreciation_start_date||"",onChange:ct=>Ye(re,{depreciation_start_date:ct.target.value}),disabled:!ce,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),ce&&e.jsx("td",{className:"px-4 py-3 text-center",children:e.jsx("button",{type:"button",onClick:()=>ra(re),className:"px-3 py-2 bg-red-600 text-white rounded-md hover:bg-red-700 transition-colors",children:"Remove"})})]},re)})})]})})})]})]})}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6 mt-6",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"End-of-Life Details"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Expected End-of-Life Date"}),e.jsx("input",{type:"date",disabled:!ce,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Disposal Method"}),e.jsxs("select",{disabled:!ce,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:"Recycling"}),e.jsx("option",{value:"Donation",children:"Donation"}),e.jsx("option",{value:"Sale",children:"Sale"})]})]})]})]})}),e.jsxs("div",{className:"mt-6 bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white",children:"Spare Parts"}),ce&&e.jsxs("button",{type:"button",onClick:$t,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 flex items-center gap-2 text-sm",children:[e.jsx("span",{children:"+"})," ",t("assets.detail.addRow")]})]}),(!h.custom_spare_parts||h.custom_spare_parts.length===0)&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400 bg-gray-50 dark:bg-gray-900 rounded-lg",children:t("assets.detail.noSparePartsYet")}),h.custom_spare_parts&&h.custom_spare_parts.length>0&&e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-300 dark:border-gray-600",children:[e.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Item Code"}),e.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Item Name"}),e.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Qty"}),e.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Rate"}),e.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Amount"}),e.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"UOM"}),ce&&e.jsx("th",{className:"text-center px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Action"})]})}),e.jsx("tbody",{children:h.custom_spare_parts.map((fe,re)=>e.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-750",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsx("input",{type:"text",value:fe.item_code||"",onChange:Ee=>ft(re,"item_code",Ee.target.value),disabled:!ce,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("input",{type:"text",value:fe.item_name||"",onChange:Ee=>ft(re,"item_name",Ee.target.value),disabled:!ce,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("input",{type:"number",value:fe.qty||0,onChange:Ee=>ft(re,"qty",Number(Ee.target.value)),disabled:!ce,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("input",{type:"number",value:fe.rate||0,onChange:Ee=>ft(re,"rate",Number(Ee.target.value)),disabled:!ce,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("input",{type:"number",value:fe.amount||0,disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("input",{type:"text",value:fe.uom||"",onChange:Ee=>ft(re,"uom",Ee.target.value),disabled:!ce,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),ce&&e.jsx("td",{className:"px-4 py-3 text-center",children:e.jsx("button",{type:"button",onClick:()=>na(re),className:"px-3 py-2 bg-red-600 text-white rounded-md hover:bg-red-700 transition-colors text-sm",children:"Remove"})})]},re))}),e.jsx("tfoot",{children:e.jsxs("tr",{className:"bg-gray-100 dark:bg-gray-700 font-semibold",children:[e.jsx("td",{colSpan:4,className:"px-4 py-3 text-right text-sm text-gray-700 dark:text-gray-300",children:"Total Amount:"}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-900 dark:text-white",children:h.custom_total_spare_parts_amount||0}),e.jsx("td",{colSpan:ce?2:1})]})})]})})]})]}),!c&&e.jsx(Pc,{referenceDoctype:"Asset",referenceName:a||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5,collapsible:!0,startCollapsed:!1}),!c&&!d&&e.jsx("div",{className:"mt-6",children:e.jsx(tj,{doctype:"Asset",docname:a||null,creationDate:_==null?void 0:_.creation,createdBy:_==null?void 0:_.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})}),!c&&((_==null?void 0:_.docstatus)===0||(_==null?void 0:_.docstatus)===1||(_==null?void 0:_.docstatus)===2)&&e.jsxs("div",{className:"mt-6 bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Delete Request"}),e.jsx(Ll,{doctype:"Asset",docname:a,currentDeleteStatus:(Qe=_==null?void 0:_.custom_delete_status)!=null?Qe:null,userRoles:U,isSystemManager:J,redirectOnDelete:"/assets",onStatusChange:()=>{C()}})]})]})},oL=["System Manager","Administrator","Contractor Supervisor","Contractor Manager","Work Control","End user"];function lL(){const[t,a]=y.useState(""),[r,s]=y.useState(!1),[i,c]=y.useState(!0),[d,m]=y.useState(null);y.useEffect(()=>{Q(null,null,function*(){try{c(!0);const p=yield fetch("/api/method/asset_lite.api.user_roles.get_user_info_with_roles",{method:"GET",headers:{"Content-Type":"application/json"}});if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);const b=yield p.json();if(b.message){const{user:j,roles:_}=b.message;if(a(j||""),!j||j==="Guest"){s(!1);return}const N=_.includes("Technician"),k=_.some(D=>oL.includes(D)),C=N&&!k;console.log("[useTechnicianFilter] User:",j),console.log("[useTechnicianFilter] Roles:",_),console.log("[useTechnicianFilter] Has Technician:",N),console.log("[useTechnicianFilter] Has Full Access:",k),console.log("[useTechnicianFilter] Is Technician Only:",C),s(C)}m(null)}catch(p){console.error("[useTechnicianFilter] Error checking technician role:",p),m(p instanceof Error?p.message:"Failed to check user roles"),s(!1)}finally{c(!1)}})},[]);const h=y.useMemo(()=>{if(!(!r||!t))return console.log("[useTechnicianFilter] Building OR filters for user:",t),[["owner","=",t],["assigned_technician","=",t],["custom_add_technicians","like",`%${t}%`]]},[r,t]);return{currentUser:t,isTechnicianOnly:r,technicianOrFilters:h,loading:i,error:d}}const cL=({isOpen:t,onClose:a})=>{const{t:r}=ca(),[s,i]=y.useState(!1),[c,d]=y.useState(null),[m,h]=y.useState([]),[g,p]=y.useState([]),[b,j]=y.useState(!0),[_,N]=y.useState(""),[k,C]=y.useState(""),[D,T]=y.useState(!1),E="Work Order Data",O=y.useCallback(()=>Q(null,null,function*(){i(!0),d(null);try{const ce={};_&&(ce.work_order_type=_),k&&(ce.repair_status=k);const ee=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:E,filters:ce,ignore_prepared_report:1})})).json();if(ee.exc)throw new Error(ee.exc);ee.message&&(ee.message.columns&&ee.message.columns.length>0&&p(ee.message.columns),ee.message.result?h(ee.message.result):h([]))}catch(ce){console.error("Error fetching report:",ce),d(ce instanceof Error?ce.message:"Failed to fetch report data"),h([])}finally{i(!1)}}),[_,k]);y.useEffect(()=>{t&&O()},[t,O]),y.useEffect(()=>{const ce=se=>{se.key==="Escape"&&t&&a()};return document.addEventListener("keydown",ce),()=>document.removeEventListener("keydown",ce)},[t,a]),y.useEffect(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[t]);const R=()=>{N(""),C("")},Y=()=>{if(m.length!==0){T(!0);try{const se=[g.map(I=>I.label).join(","),...m.map(I=>g.map(oe=>{let ae=I[oe.fieldname]||"";return typeof ae=="string"&&(ae.includes(",")||ae.includes('"')||ae.includes(`
`))&&(ae=`"${ae.replace(/"/g,'""')}"`),ae}).join(","))].join(`
`),ee=new Blob(["\uFEFF"+se],{type:"text/csv;charset=utf-8;"}),te=URL.createObjectURL(ee),W=document.createElement("a");W.href=te,W.download=`work_order_report_${new Date().toISOString().split("T")[0]}.csv`,W.click(),URL.revokeObjectURL(te)}finally{T(!1)}}},P=()=>{if(m.length!==0){T(!0);try{const se=[g.map(I=>I.label),...m.map(I=>g.map(oe=>I[oe.fieldname]||""))],ee=Ja.aoa_to_sheet(se),te=g.map(I=>({wch:I.width?Math.floor(I.width/7):15}));ee["!cols"]=te;const W=Ja.book_new();Ja.book_append_sheet(W,ee,"Work Order Report"),$i(W,`work_order_report_${new Date().toISOString().split("T")[0]}.xlsx`)}finally{T(!1)}}},U=()=>{const ce=window.open("","_blank");if(!ce){alert("Please allow popups for this site to print the report.");return}const se=`
<!DOCTYPE html>
<html>
<head>
<title>Work Order Report</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
h1 { text-align: center; color: #333; margin-bottom: 20px; }
.meta { text-align: center; color: #666; margin-bottom: 20px; font-size: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { background-color: #4A90D9; color: white; padding: 10px 8px; text-align: left; font-weight: 600; }
td { padding: 8px; border-bottom: 1px solid #ddd; }
tr:nth-child(even) { background-color: #f9f9f9; }
tr:hover { background-color: #f5f5f5; }
.status-open { color: #D97706; font-weight: 500; }
.status-completed { color: #059669; font-weight: 500; }
.status-inprogress { color: #2563EB; font-weight: 500; }
.priority-urgent { color: #DC2626; font-weight: 600; }
.priority-normal { color: #6B7280; }
@media print {
body { margin: 0; }
table { page-break-inside: auto; }
tr { page-break-inside: avoid; page-break-after: auto; }
}
</style>
</head>
<body>
<h1>Work Order Report</h1>
<div class="meta">
Generated on: ${new Date().toLocaleString()} | Total Records: ${m.length}
${_?` | Type: ${_}`:""}
${k?` | Status: ${k}`:""}
</div>
<table>
<thead>
<tr>
${g.map(ee=>`<th>${ee.label}</th>`).join("")}
</tr>
</thead>
<tbody>
${m.map(ee=>`
<tr>
${g.map(te=>{let W=ee[te.fieldname]||"-",I="";return te.fieldname==="repair_status"&&(W.toLowerCase().includes("open")?I="status-open":W.toLowerCase().includes("completed")?I="status-completed":W.toLowerCase().includes("progress")&&(I="status-inprogress")),te.fieldname==="custom_priority_"&&(W.toLowerCase()==="urgent"?I="priority-urgent":I="priority-normal"),`<td class="${I}">${W}</td>`}).join("")}
</tr>
`).join("")}
</tbody>
</table>
<script>
window.onload = function() { window.print(); }
<\/script>
</body>
</html>
`;ce.document.write(se),ce.document.close()},J=()=>{U()},ne=ce=>{switch(ce==null?void 0:ce.toLowerCase()){case"completed":case"closed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300";case"work in progress":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300";case"open":case"pending review":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-300";case"cancelled":return"bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300";default:return"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300"}},ye=ce=>{switch(ce==null?void 0:ce.toLowerCase()){case"urgent":return"bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300";case"medium":return"bg-orange-100 dark:bg-orange-900/30 text-orange-800 dark:text-orange-300";default:return"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300"}},he=(ce,se)=>{if(ce==null||ce==="")return"-";switch(se.fieldtype){case"Date":return new Date(ce).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});case"Datetime":return new Date(ce).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});case"Currency":return new Intl.NumberFormat("en-US",{style:"currency",currency:"SAR"}).format(ce);case"Link":return ce;default:return String(ce)}};return t?e.jsxs("div",{className:"fixed inset-0 z-[80] bg-gray-50 dark:bg-gray-900 flex flex-col",children:[e.jsx("div",{className:"bg-gradient-to-r from-indigo-600 to-purple-600 px-6 py-4 flex-shrink-0 shadow-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:a,className:"p-2 text-white/80 hover:text-white hover:bg-white/20 rounded-lg transition-colors",title:"Go Back",children:e.jsx(en,{size:18})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(E2,{className:"text-white text-xl"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-white",children:"Work Order Report"}),e.jsxs("p",{className:"text-white/70 text-sm",children:[m.length," record",m.length!==1?"s":""," found"]})]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{onClick:a,className:"p-2 text-white/80 hover:text-white hover:bg-white/20 rounded-lg transition-colors",title:"Close (Esc)",children:e.jsx(wt,{size:20})})})]})}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 px-6 py-3 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("button",{onClick:()=>j(!b),className:"flex items-center gap-2 px-4 py-2 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:[e.jsx(ds,{size:12}),"Filters",(_||k)&&e.jsx("span",{className:"bg-indigo-100 dark:bg-indigo-900/50 text-indigo-600 dark:text-indigo-400 px-2 py-0.5 rounded-full text-xs font-bold",children:[_,k].filter(Boolean).length}),b?e.jsx(As,{size:10}):e.jsx(cs,{size:10})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:O,disabled:s,className:"p-2.5 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors disabled:opacity-50",title:"Refresh",children:e.jsx(vn,{className:s?"animate-spin":"",size:14})}),e.jsxs("div",{className:"flex items-center gap-1 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:Y,disabled:m.length===0||D,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as CSV",children:[e.jsx(Bi,{className:"text-green-600",size:14}),e.jsx("span",{children:"CSV"})]}),e.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),e.jsxs("button",{onClick:P,disabled:m.length===0||D,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as Excel",children:[e.jsx(Ui,{className:"text-green-700",size:14}),e.jsx("span",{children:"Excel"})]}),e.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),e.jsxs("button",{onClick:J,disabled:m.length===0,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as PDF",children:[e.jsx(Ph,{className:"text-red-600",size:14}),e.jsx("span",{children:"PDF"})]}),e.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),e.jsxs("button",{onClick:U,disabled:m.length===0,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Print",children:[e.jsx(Fi,{className:"text-purple-600",size:14}),e.jsx("span",{children:"Print"})]})]})]})]}),b&&e.jsx("div",{className:"mt-4 p-4 bg-gray-50 dark:bg-gray-900/50 rounded-lg border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx("div",{className:"relative z-[70]",children:e.jsx(Ut,{label:"Work Order Type",doctype:"Issue Type",value:_,onChange:ce=>N(ce),placeholder:"All Types",disabled:!1,compact:!1})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Work Order Status"}),e.jsxs("select",{value:k,onChange:ce=>C(ce.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:"All Status"}),e.jsx("option",{value:"Open",children:"Open"}),e.jsx("option",{value:"Work In Progress",children:"Work In Progress"}),e.jsx("option",{value:"Pending Review",children:"Pending Review"}),e.jsx("option",{value:"Completed",children:"Completed"}),e.jsx("option",{value:"Executed",children:"Executed"}),e.jsx("option",{value:"Cancelled",children:"Cancelled"}),e.jsx("option",{value:"Closed",children:"Closed"})]})]}),e.jsx("div",{}),e.jsx("div",{className:"flex items-end",children:e.jsxs("button",{onClick:R,disabled:!_&&!k,className:"px-4 py-2 text-sm font-medium text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[e.jsx(wt,{size:12}),"Clear Filters"]})})]})})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[s&&e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ya,{className:"animate-spin text-indigo-500 text-5xl mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-lg",children:"Loading report data..."})]})}),c&&!s&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-8 text-center max-w-lg mx-auto",children:[e.jsx("p",{className:"text-red-600 dark:text-red-400 mb-4 text-lg",children:c}),e.jsx("button",{onClick:O,className:"px-6 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-sm font-medium transition-colors",children:"Try Again"})]}),!s&&!c&&m.length===0&&e.jsxs("div",{className:"text-center py-20",children:[e.jsx(Js,{className:"text-gray-300 dark:text-gray-600 text-6xl mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-xl",children:"No data found"}),e.jsx("p",{className:"text-gray-400 dark:text-gray-500 text-sm mt-2",children:"Try adjusting your filters"})]}),!s&&!c&&m.length>0&&e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden shadow-sm",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 sticky top-0",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider w-16",children:"#"}),g.map((ce,se)=>e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider whitespace-nowrap",style:{minWidth:ce.width||120},children:ce.label},se))]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:m.map((ce,se)=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400 font-medium",children:se+1}),g.map((ee,te)=>{const W=ce[ee.fieldname],I=he(W,ee);return ee.fieldname==="repair_status"?e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${ne(W)}`,children:I})},te):ee.fieldname==="custom_priority_"?e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${ye(W)}`,children:I})},te):ee.fieldtype==="Link"&&ee.fieldname==="name"?e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx("a",{href:`/asm_app/work-orders/${W}`,target:"_blank",rel:"noopener noreferrer",className:"text-indigo-600 dark:text-indigo-400 hover:underline font-medium text-sm",children:I})},te):e.jsx("td",{className:"px-4 py-3 text-sm text-gray-700 dark:text-gray-300",title:typeof W=="string"&&W.length>50?W:void 0,children:e.jsx("div",{className:"max-w-xs truncate",children:I})},te)})]},se))})]})})})]}),e.jsx("div",{className:"bg-white dark:bg-gray-800 px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex-shrink-0 shadow-inner",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Showing ",m.length," record",m.length!==1?"s":"",(_||k)&&" (filtered)"]}),e.jsx("button",{onClick:a,className:"px-6 py-2 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium transition-colors",children:"Close"})]})})]}):null},dL=["CARPENTARY","MASONRY","PAINTING","PLUMPING"],uL="Civil works-الأعمال المدنية",mL=({isOpen:t,onClose:a,selectedWorkOrders:r,onConfirmClose:s,isClosing:i})=>{const{t:c}=ca();if(!t)return null;const d=g=>{switch(g==null?void 0:g.toLowerCase()){case"closed":return"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300";case"completed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300";case"in progress":case"work in progress":case"repair inprogress":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300";case"pending":case"pending approval":case"pending review":case"open":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-300";case"cancelled":return"bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300";default:return"bg-purple-100 dark:bg-purple-900/30 text-purple-800 dark:text-purple-300"}},m=r.filter(g=>{var p;return((p=g.workflow_state)==null?void 0:p.toLowerCase())==="closed"}).length,h=r.length-m;return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] overflow-hidden animate-scale-in",children:[e.jsx("div",{className:"bg-gradient-to-r from-orange-500 to-orange-600 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Cx,{className:"text-white text-xl"}),e.jsx("h3",{className:"text-lg font-semibold text-white",children:c("workOrders.closeModal.title")})]}),e.jsx("button",{onClick:a,className:"text-white/80 hover:text-white transition-colors",disabled:i,children:e.jsx(wt,{size:20})})]})}),e.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[e.jsx("div",{className:"mb-4 p-4 bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(fa,{className:"text-orange-500 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-orange-800 dark:text-orange-200",children:c("workOrders.closeModal.confirmBulkClose")}),e.jsx("p",{className:"text-xs text-orange-600 dark:text-orange-400 mt-1",children:c("workOrders.closeModal.aboutToClose",{count:h})}),m>0&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:c("workOrders.closeModal.alreadyClosedNote",{count:m})})]})]})}),e.jsxs("div",{className:"mb-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:c("workOrders.closeModal.selectedWorkOrders",{count:r.length})}),e.jsx("div",{className:"max-h-64 overflow-y-auto border border-gray-200 dark:border-gray-700 rounded-lg",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700 sticky top-0",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:c("workOrders.closeModal.workOrderId")}),e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:c("workOrders.closeModal.currentStatus")}),e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:c("workOrders.closeModal.workflowState")})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:r.map(g=>{var b;const p=((b=g.workflow_state)==null?void 0:b.toLowerCase())==="closed";return e.jsxs("tr",{className:`${p?"bg-gray-50 dark:bg-gray-700/50 opacity-60":"bg-white dark:bg-gray-800"}`,children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:g.name}),p&&e.jsx("span",{className:"ml-2 text-xs text-gray-500",children:c("workOrders.closeModal.alreadyClosed")})]}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${d(g.repair_status)}`,children:g.repair_status||"Open"})})]},g.name)})})]})})]})]}),e.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:h>0?e.jsx("span",{children:c("workOrders.closeModal.willClose",{count:h})}):e.jsx("span",{className:"text-orange-600 dark:text-orange-400",children:c("workOrders.closeModal.allAlreadyClosed")})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",disabled:i,children:c("workOrders.closeModal.cancel")}),e.jsx("button",{onClick:s,disabled:h===0||i,className:"px-4 py-2 text-sm font-medium text-white bg-orange-600 hover:bg-orange-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:i?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin",size:14}),c("workOrders.closeModal.closing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Cx,{size:14}),c("workOrders.closeModal.close")," ",h>0?`(${h})`:""]})})]})]})]})})},hL=()=>{const{t}=ca(),a=qa(),[r,s]=Qs(),i=y.useMemo(()=>{const ze=parseInt(r.get("page")||"1",10);return Math.max(0,Number.isNaN(ze)?0:ze-1)},[r]),c=y.useCallback(ze=>{s(yt=>{const Sa=new URLSearchParams(yt);return Sa.set("page",String(ze+1)),Sa})},[s]),[d,m]=y.useState(null),[h,g]=y.useState(null),p=y.useRef(null),b=20;r.get("asset"),r.get("work_order_type");const[j,_]=y.useState(!1),[N,k]=y.useState(new Set),[C,D]=y.useState(!1),[T,E]=y.useState(!1),[O,R]=y.useState(!1),[Y,P]=y.useState(!1),[U,J]=y.useState([]),[ne,ye]=y.useState(!1),[he,ce]=y.useState(!1),[se,ee]=y.useState(""),[te,W]=y.useState([]),[I,oe]=y.useState(!1),{permissionFilters:ae,loading:F,error:M}=vp("Work_Order"),{technicianOrFilters:B,isTechnicianOnly:X,loading:K,error:we}=lL(),be=["System Manager","Cluster Manager","Contractor Supervisor","Contractor Manager","Work Control"],ke=["System Manager","Cluster Manager","Work Control","End user"],Me=["System Manager","Maintenance Manager","Work Control","Technician","Contractor Supervisor","Contractor Manager","Contractor Engineer"],z=["Cluster Manager"],[Ne,Xe]=y.useState(!1),[gt,St]=y.useState(!1),[Ht,Mt]=y.useState(!1);y.useEffect(()=>{Q(null,null,function*(){try{const[yt,Sa,_r,Sr,Yr]=yield Promise.all([fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:be.join(",")})}),fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:ke.join(",")})}),fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:Me.join(",")})}),fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:z.join(",")})}),fetch("/api/method/frappe.auth.get_logged_user",{credentials:"include"})]),[oa,Zr,za,_n,wn]=yield Promise.all([yt.json(),Sa.json(),_r.json(),Sr.json(),Yr.json()]);oa.message&&Xe(oa.message.has_role),Zr.message&&St(Zr.message.has_role),za.message&&Mt(za.message.has_role),_n.message&&ye(_n.message.has_role);const ws=wn.message||"";ee(ws);const gs=yield(yield fetch("/api/method/asset_lite.api.user_roles.get_user_roles",{credentials:"include"})).json(),Ls=Array.isArray(gs.message)?gs.message:[];W(Ls);const zn=Ls.includes("System Manager");oe(zn);const Un=yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:["System Manager","Cluster Manager","Maintenance Manager","Work Control","Technician","Contractor Supervisor","Contractor Manager","Contractor Engineer"].join(",")})})).json();Un.message&&ce(!Un.message.has_role)}catch(yt){console.error("Error checking permissions:",yt),Xe(!1),St(!1),Mt(!1),ye(!1),ce(!1)}})},[]);const[Te,Qt]=y.useState(()=>r.get("date_filter_by")||""),[zt,Wt]=y.useState(()=>r.get("date_start")||""),[Vt,va]=y.useState(()=>r.get("date_end")||""),[ta,sa]=y.useState(()=>r.get("work_order_id")||""),[ra,Ye]=y.useState(()=>r.get("asset")||""),[ft,$t]=y.useState(()=>r.get("work_order_type")||""),[na,Ze]=y.useState(()=>r.get("civil_work_category")||""),[lt,aa]=y.useState(()=>r.get("company")||""),[Ie,Nt]=y.useState(()=>r.get("status")||""),[ve,Oe]=y.useState(()=>r.get("serial_number")||""),[ht,et]=y.useState(()=>r.get("manufacturer")||""),[Be,kt]=y.useState(()=>r.get("supplier")||""),[it,xt]=y.useState(()=>r.get("department")||""),[Dt,Ot]=y.useState(()=>r.get("priority")||""),[Rt,De]=y.useState(()=>r.get("workflow_state")||""),Qe=ft===uL,fe=["creation desc","creation asc","modified desc","modified asc","name asc","name desc"],[re,Ee]=y.useState(()=>r.get("sort_by")||"modified desc"),[Ge,ct]=y.useState(!0),[It,st]=y.useState(0),[rt,V]=y.useState([]),[me,de]=y.useState(!1),[ie,xe]=y.useState(""),[_e,He]=y.useState(()=>r.get("serial_number")||""),Ue=y.useRef(null);y.useEffect(()=>{const ze=localStorage.getItem("workOrderFilterPresets");ze&&V(JSON.parse(ze))},[]);const Pe=Te&&(zt||Vt);y.useEffect(()=>{const ze=[ta,ra,ft,Qe?na:"",lt,Ie,ve,ht,Be,it,Dt,Rt].filter(Boolean).length+(Pe?1:0);st(ze)},[Pe,ta,ra,ft,Qe,na,lt,Ie,ve,ht,Be,it,Dt,Rt]);const Re={};ta&&(Re.name=ta),ra&&(Re.asset=ra),ft&&(Re.work_order_type=ft),Qe&&na&&(Re.custom_civil_work_category=na),lt&&(Re.company=lt),Ie&&(Re.repair_status=Ie),ve&&(Re.custom_serial_number=["like",`%${ve}%`]),ht&&(Re.custom_manufacturer=ht),Be&&(Re.supplier=Be),it&&(Re.department=it),Dt&&(Re.custom_priority_=Dt),Rt&&(Re.workflow_state=Rt),Object.assign(Re,el(Te,zt,Vt)),Re.custom_delete_status=["!=","Deleted"],he&&se&&(Re.owner=se);const We=fe.includes(re)?re:"modified desc",{workOrders:_t,totalCount:Ft,hasMore:dt,loading:pt,error:At,refetch:Zt}=y2(Re,b,i*b,We,ae,B),{deleteWorkOrder:Fa,loading:La}=b2(),Ya=y.useRef(!1);y.useEffect(()=>{!pt&&!F&&!K&&(At||(Ya.current=!0),j||_(!0))},[pt,j,F,K,At]);const gr=y.useRef(!1);y.useEffect(()=>{if(!gr.current){gr.current=!0;return}s(ze=>{const yt=new URLSearchParams(ze);return Te?yt.set("date_filter_by",Te):yt.delete("date_filter_by"),zt?yt.set("date_start",zt):yt.delete("date_start"),Vt?yt.set("date_end",Vt):yt.delete("date_end"),ta?yt.set("work_order_id",ta):yt.delete("work_order_id"),ra?yt.set("asset",ra):yt.delete("asset"),ft?yt.set("work_order_type",ft):yt.delete("work_order_type"),Qe&&na?yt.set("civil_work_category",na):yt.delete("civil_work_category"),lt?yt.set("company",lt):yt.delete("company"),Ie?yt.set("status",Ie):yt.delete("status"),ve?yt.set("serial_number",ve):yt.delete("serial_number"),ht?yt.set("manufacturer",ht):yt.delete("manufacturer"),Be?yt.set("supplier",Be):yt.delete("supplier"),it?yt.set("department",it):yt.delete("department"),Dt?yt.set("priority",Dt):yt.delete("priority"),Rt?yt.set("workflow_state",Rt):yt.delete("workflow_state"),re&&re!=="modified desc"?yt.set("sort_by",re):yt.delete("sort_by"),yt.set("page","1"),yt})},[Te,zt,Vt,ta,ra,ft,Qe,na,lt,Ie,ve,ht,Be,it,Dt,Rt,re]),y.useEffect(()=>{Qe||Ze("")},[Qe]),y.useEffect(()=>{k(new Set)},[Te,zt,Vt,ta,ra,ft,na,lt,Ie,ve,ht,Be,it,Dt,Rt,i]);const ar=ze=>{He(ze),Ue.current&&clearTimeout(Ue.current),Ue.current=window.setTimeout(()=>Oe(ze),800)},Ir=ze=>{ze.key==="Enter"&&(ze.preventDefault(),Ue.current&&clearTimeout(Ue.current),Oe(_e))},kr=()=>{if(!ie.trim()){alert("Please enter a filter name");return}const ze={id:Date.now(),name:ie,filters:{dateFilterBy:Te,dateStart:zt,dateEnd:Vt,sortBy:re,filterWorkOrderId:ta,filterAsset:ra,filterType:ft,filterCivilWorkCategory:na,filterCompany:lt,filterStatus:Ie,filterSerialNumber:ve,filterManufacturer:ht,filterSupplier:Be,filterDepartment:it,filterPriority:Dt,filterWorkflowState:Rt}},yt=[...rt,ze];V(yt),xe(""),de(!1),localStorage.setItem("workOrderFilterPresets",JSON.stringify(yt))},hs=ze=>{const yt=ze.filters;Qt(yt.dateFilterBy||""),Wt(yt.dateStart||""),va(yt.dateEnd||""),Ee(yt.sortBy||"modified desc"),sa(yt.filterWorkOrderId||""),Ye(yt.filterAsset||""),$t(yt.filterType||""),Ze(yt.filterCivilWorkCategory||""),aa(yt.filterCompany||""),Nt(yt.filterStatus||""),Oe(yt.filterSerialNumber||""),He(yt.filterSerialNumber||""),et(yt.filterManufacturer||""),kt(yt.filterSupplier||""),xt(yt.filterDepartment||""),Ot(yt.filterPriority||""),De(yt.filterWorkflowState||"")},ha=ze=>{const yt=rt.filter(Sa=>Sa.id!==ze);V(yt),localStorage.setItem("workOrderFilterPresets",JSON.stringify(yt))};y.useEffect(()=>()=>{Ue.current&&clearTimeout(Ue.current)},[]),y.useEffect(()=>{const ze=yt=>{p.current&&!p.current.contains(yt.target)&&g(null)};return h&&document.addEventListener("mousedown",ze),()=>document.removeEventListener("mousedown",ze)},[h]);const Ia=ze=>{k(yt=>{const Sa=new Set(yt);return Sa.has(ze)?Sa.delete(ze):Sa.add(ze),Sa})},qr=()=>{N.size===_t.length?k(new Set):k(new Set(_t.map(ze=>ze.name)))},fr=_t.length>0&&N.size===_t.length,G=N.size>0&&N.size<_t.length,$e=y.useCallback(()=>Q(null,null,function*(){const ze=[];let yt=0;const Sa=100;let _r=!0;const Sr=ue(ue({},Re),ae),Yr=Ks(Sr);for(;_r;)try{const oa={doctype:"Work_Order",filters:Yr.length>0?Yr:{},fields:["*"],limit_start:yt*Sa,limit_page_length:Sa,order_by:"creation desc"};B&&B.length>0&&(oa.or_filters=B);const _n=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(oa)})).json()).message||[];ze.push(..._n),_n.length<Sa?_r=!1:yt++,yt>100&&(console.warn("Export safety limit reached"),_r=!1)}catch(oa){throw console.error("Error fetching work orders for export:",oa),oa}return ze}),[Re,ae,B]),Bt=()=>{const ze=_t.filter(yt=>N.has(yt.name)).map(yt=>({name:yt.name,workflow_state:yt.workflow_state||"Draft",repair_status:yt.repair_status||"Open"}));J(ze),R(!0)},Kt=()=>Q(null,null,function*(){P(!0);const ze=U.filter(Sr=>{var Yr;return((Yr=Sr.workflow_state)==null?void 0:Yr.toLowerCase())!=="closed"});let yt=0,Sa=0;const _r=[];for(const Sr of ze)try{const oa=yield(yield fetch("/api/method/frappe.model.workflow.apply_workflow",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doc:{doctype:"Work_Order",name:Sr.name},action:"Close"})})).json();if(oa.exc||oa.exception)throw new Error(oa.exc||oa.exception);yt++}catch(Yr){console.error(`Failed to close ${Sr.name}:`,Yr),Sa++,_r.push(Sr.name)}P(!1),R(!1),k(new Set),Zt(),yt>0&&Sa===0?alert(`Successfully closed ${yt} work order${yt!==1?"s":""}.`):yt>0&&Sa>0?alert(`Closed ${yt} work order${yt!==1?"s":""}. Failed to close ${Sa}: ${_r.join(", ")}`):Sa>0&&alert(`Failed to close work orders: ${_r.join(", ")}`)}),_a=()=>a("/work-orders/new"),zr=ze=>a(`/work-orders/${ze}`),Aa=ze=>a(`/work-orders/${ze}`),Ds=ze=>a(`/work-orders/new?duplicate=${ze}`),xr=ze=>Q(null,null,function*(){try{yield Fa(ze),m(null),Zt(),alert("Work order deleted successfully!")}catch(yt){alert(`Failed to delete work order: ${yt instanceof Error?yt.message:"Unknown error"}`)}}),wa=ze=>{const yt=JSON.stringify(ze,null,2),Sa=new Blob([yt],{type:"application/json"}),_r=URL.createObjectURL(Sa),Sr=document.createElement("a");Sr.href=_r,Sr.download=`work_order_${ze.name}.json`,Sr.click(),URL.revokeObjectURL(_r)},Za="Service_Report",cn=ze=>{const Sa=`${ia.BASE_URL}/printview?doctype=Work_Order&name=${encodeURIComponent(ze)}&format=${encodeURIComponent(Za)}&trigger_print=1`;window.open(Sa,"_blank")},_s=()=>{Qt(""),Wt(""),va(""),Ee("modified desc"),sa(""),Ye(""),$t(""),Ze(""),aa(""),Nt(""),Oe(""),He(""),et(""),kt(""),xt(""),Ot(""),De(""),s(ze=>{const yt=new URLSearchParams(ze);return yt.delete("date_filter_by"),yt.delete("date_start"),yt.delete("date_end"),yt.delete("work_order_id"),yt.delete("asset"),yt.delete("work_order_type"),yt.delete("civil_work_category"),yt.delete("company"),yt.delete("status"),yt.delete("serial_number"),yt.delete("manufacturer"),yt.delete("supplier"),yt.delete("department"),yt.delete("priority"),yt.delete("workflow_state"),yt.set("page","1"),yt}),Ue.current&&clearTimeout(Ue.current)},Gr=Pe||ta||ra||ft||Qe&&na||lt||Ie||ve||ht||Be||it||Dt||Rt,yo=ze=>ze?new Date(ze).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"-",ii=ze=>{switch(ze){case"Delete Request With Supervisor":return"bg-orange-50 dark:bg-orange-900/10";case"Delete Request With CM":return"bg-yellow-50 dark:bg-yellow-900/10";case"Deleted":return"bg-red-50 dark:bg-red-900/10";default:return""}},Ms=ze=>{switch(ze==null?void 0:ze.toLowerCase()){case"completed":return e.jsx(ea,{className:"text-green-500"});case"in progress":return e.jsx(or,{className:"text-blue-500"});case"pending":return e.jsx(fa,{className:"text-yellow-500"});default:return e.jsx(or,{className:"text-gray-400"})}},oi=ze=>{switch(ze==null?void 0:ze.toLowerCase()){case"completed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300";case"in progress":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300";case"pending":case"open":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-300";case"cancelled":return"bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300";default:return"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300"}},wi=ze=>{switch(ze==null?void 0:ze.toLowerCase()){case"high":case"urgent":return"bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300";case"medium":return"bg-orange-100 dark:bg-orange-900/30 text-orange-800 dark:text-orange-300";case"low":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300";default:return"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300"}};return(F||K)&&!j?e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("assets.loadingPermissions")})]})}):M||we?e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:"⚠️ Permission Error"}),e.jsxs("div",{className:"text-red-700 dark:text-red-400 space-y-3",children:[e.jsx("p",{children:e.jsx("strong",{children:"Unable to load user permissions."})}),e.jsx("p",{children:M||we}),e.jsx("button",{onClick:()=>window.location.reload(),className:"mt-2 bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded",children:"Retry"})]})]})}):pt&&!j?e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("workOrders.loadingWorkOrders")})]})}):At&&j&&!Ya.current?e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-yellow-800 dark:text-yellow-300 mb-4",children:"⚠️ Work Order API Not Available"}),e.jsxs("div",{className:"text-yellow-700 dark:text-yellow-400 space-y-3",children:[e.jsx("p",{children:e.jsx("strong",{children:"The Work Order API endpoint is not deployed yet."})}),e.jsx("button",{onClick:()=>a("/work-orders/new"),className:"mt-2 bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:"Try Creating a New Work Order (Demo)"}),e.jsx("button",{onClick:Zt,className:"mt-2 ml-2 bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded",children:"Try Again"})]})]})}):e.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-800 dark:text-white",children:t("workOrders.title")}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:["Total: ",Ft," work order",Ft!==1?"s":"",N.size>0&&e.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",N.size," selected"]}),X&&e.jsx("span",{className:"ml-2 text-amber-600 dark:text-amber-400",children:"• Showing your assigned work orders"}),pt&&j&&e.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[e.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-blue-500"}),"Updating..."]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[Ht&&e.jsxs("button",{onClick:()=>E(!0),className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",children:[e.jsx(E2,{}),e.jsx("span",{className:"font-medium",children:"WO Report"})]}),ne&&N.size>0&&e.jsxs("button",{onClick:Bt,className:"bg-orange-600 hover:bg-orange-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",children:[e.jsx(Cx,{}),e.jsx("span",{className:"font-medium",children:"Close"}),e.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:N.size})]}),e.jsxs("button",{onClick:()=>D(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",disabled:Ft===0,children:[e.jsx(Os,{}),e.jsx("span",{className:"font-medium",children:t("listPages.export")}),N.size>0&&e.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:N.size})]}),gt&&e.jsxs("button",{onClick:_a,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow-lg transition-all hover:shadow-xl",children:[e.jsx(Zs,{}),e.jsx("span",{className:"font-medium",children:t("workOrders.addWorkOrder")})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[e.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 dark:from-blue-600 dark:to-blue-700 px-4 py-3 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[e.jsx("button",{onClick:()=>ct(!Ge),className:"text-white hover:bg-white/20 p-2 rounded-lg transition-all",children:Ge?e.jsx(As,{size:14}):e.jsx(cs,{size:14})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ds,{className:"text-white",size:16}),e.jsx("h3",{className:"text-white font-semibold text-sm",children:"Filters"})]}),It>0&&e.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:It})]}),Gr&&e.jsx("div",{className:"flex-1 overflow-x-auto scrollbar-hide mx-2",children:e.jsxs("div",{className:"flex items-center gap-2 py-1",children:[Pe&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("filters.filterBy"),":"]})," ",t(Te==="creation"?"filters.createdDate":"filters.latestModifiedDate")," ",zt&&` ${zt}`," ",Vt&&` - ${Vt}`,e.jsx("button",{onClick:ze=>{ze.stopPropagation(),Qt(""),Wt(""),va("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),ta&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-blue-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsx("span",{className:"font-semibold",children:"WO ID:"})," ",ta,e.jsx("button",{onClick:ze=>{ze.stopPropagation(),sa("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),ra&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-cyan-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsx("span",{className:"font-semibold",children:"Asset:"})," ",ra,e.jsx("button",{onClick:ze=>{ze.stopPropagation(),Ye(""),r.delete("asset"),s(r)},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),ft&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-purple-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsx("span",{className:"font-semibold",children:"Type:"})," ",ft,e.jsx("button",{onClick:ze=>{ze.stopPropagation(),$t(""),r.delete("work_order_type"),s(r)},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),Qe&&na&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-emerald-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsx("span",{className:"font-semibold",children:"Civil Category:"})," ",na,e.jsx("button",{onClick:ze=>{ze.stopPropagation(),Ze(""),r.delete("civil_work_category"),s(r)},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),lt&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-green-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsx("span",{className:"font-semibold",children:"Hospital:"})," ",lt,e.jsx("button",{onClick:ze=>{ze.stopPropagation(),aa("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),Ie&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-orange-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsx("span",{className:"font-semibold",children:"Status:"})," ",Ie,e.jsx("button",{onClick:ze=>{ze.stopPropagation(),Nt("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),Rt&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-violet-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsx("span",{className:"font-semibold",children:"Workflow:"})," ",Rt,e.jsx("button",{onClick:ze=>{ze.stopPropagation(),De(""),r.delete("workflow_state"),s(r)},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),ve&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-lime-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsx("span",{className:"font-semibold",children:"Serial:"})," ",ve,e.jsx("button",{onClick:ze=>{ze.stopPropagation(),Oe(""),He("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),ht&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsx("span",{className:"font-semibold",children:"Mfr:"})," ",ht,e.jsx("button",{onClick:ze=>{ze.stopPropagation(),et("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),Be&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-teal-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsx("span",{className:"font-semibold",children:"Supplier:"})," ",Be,e.jsx("button",{onClick:ze=>{ze.stopPropagation(),kt("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),it&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-yellow-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsx("span",{className:"font-semibold",children:"Dept:"})," ",it,e.jsx("button",{onClick:ze=>{ze.stopPropagation(),xt("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),Dt&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-red-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsx("span",{className:"font-semibold",children:"Priority:"})," ",Dt,e.jsx("button",{onClick:ze=>{ze.stopPropagation(),Ot("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]})]})}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[It>0&&e.jsxs("button",{onClick:()=>de(!0),className:"px-3 py-1.5 bg-white text-blue-600 hover:bg-blue-50 rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[e.jsx(Or,{size:12}),e.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),Gr&&e.jsxs("button",{onClick:_s,className:"px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[e.jsx(wt,{size:12}),e.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]})]})}),Ge&&e.jsxs("div",{className:"p-4",children:[rt.length>0&&e.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[e.jsx(Tc,{className:"text-yellow-500",size:12}),"Saved Filters"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:rt.map(ze=>e.jsxs("div",{className:"group relative inline-flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-purple-100 to-blue-100 dark:from-purple-900/30 dark:to-blue-900/30 border border-purple-200 dark:border-purple-700 rounded-lg hover:shadow-md transition-all",children:[e.jsx("button",{onClick:()=>hs(ze),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:ze.name}),e.jsx("button",{onClick:()=>ha(ze.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:e.jsx(Na,{size:10})})]},ze.id))})]}),e.jsx("div",{className:"space-y-5",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.sortBy")}),e.jsxs("select",{value:re,onChange:ze=>Ee(ze.target.value),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"creation desc",children:t("filters.sortCreationNewest")}),e.jsx("option",{value:"creation asc",children:t("filters.sortCreationOldest")}),e.jsx("option",{value:"modified desc",children:t("filters.sortModifiedNewest")}),e.jsx("option",{value:"modified asc",children:t("filters.sortModifiedOldest")}),e.jsx("option",{value:"name asc",children:t("filters.sortNameAsc")}),e.jsx("option",{value:"name desc",children:t("filters.sortNameDesc")})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.filterBy")}),e.jsxs("select",{value:Te,onChange:ze=>{const yt=ze.target.value;Qt(yt)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("filters.filterBy")}),e.jsx("option",{value:"creation",children:t("filters.createdDate")}),e.jsx("option",{value:"modified",children:t("filters.latestModifiedDate")})]})]}),Te&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.startDate")}),e.jsx("input",{type:"date",value:zt,onChange:ze=>{const yt=ze.target.value;Wt(yt),Vt&&yt>Vt&&va(yt)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.endDate")}),e.jsx("input",{type:"date",value:Vt,onChange:ze=>va(ze.target.value),min:zt||void 0,className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),e.jsxs("div",{className:"relative z-[60]",children:[e.jsx(Ut,{label:t("filters.workOrderId"),doctype:"Work_Order",value:ta,onChange:ze=>sa(ze),placeholder:t("linkField.selectLabel",{label:t("filters.workOrderId")}),disabled:!1,compact:!0,filters:{custom_delete_status:["!=","Deleted"]}}),ta&&e.jsx("button",{onClick:()=>sa(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[59]",children:[e.jsx(Ut,{label:t("filters.asset"),doctype:"Asset",value:ra,onChange:ze=>Ye(ze),placeholder:t("linkField.selectLabel",{label:t("filters.asset")}),disabled:!1,compact:!0,filters:{custom_delete_status:["!=","Deleted"]}}),ra&&e.jsx("button",{onClick:()=>{Ye(""),r.delete("asset"),s(r)},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[58]",children:[e.jsx(Ut,{label:t("filters.type"),doctype:"Issue Type",value:ft,onChange:ze=>{$t(ze),r.has("work_order_type")&&(r.delete("work_order_type"),s(r))},placeholder:t("linkField.selectLabel",{label:t("filters.type")}),disabled:!1,compact:!0}),ft&&e.jsx("button",{onClick:()=>{$t(""),r.delete("work_order_type"),s(r)},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),Qe&&e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Civil Work Category"}),e.jsxs("select",{value:na,onChange:ze=>Ze(ze.target.value),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:"All Civil Categories"}),dL.map(ze=>e.jsx("option",{value:ze,children:ze},ze))]}),na&&e.jsx("button",{onClick:()=>Ze(""),className:"absolute right-8 top-6 text-gray-400 hover:text-red-500 transition-colors",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[57]",children:[e.jsx(Ut,{label:t("filters.hospital"),doctype:"Company",value:lt,onChange:ze=>aa(ze),placeholder:t("linkField.selectLabel",{label:t("filters.hospital")}),disabled:!1,compact:!0,filters:{domain:"Healthcare"}}),lt&&e.jsx("button",{onClick:()=>aa(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.status")}),e.jsxs("select",{value:Ie,onChange:ze=>Nt(ze.target.value),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("filters.allStatuses")}),e.jsx("option",{value:"Open",children:t("workOrders.status.open")}),e.jsx("option",{value:"Work In Progress",children:t("workOrders.status.work_in_progress")}),e.jsx("option",{value:"Pending Review",children:t("workOrders.status.pending_review")}),e.jsx("option",{value:"Closed",children:t("workOrders.status.closed")})]}),Ie&&e.jsx("button",{onClick:()=>Nt(""),className:"absolute right-8 top-6 text-gray-400 hover:text-red-500 transition-colors",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[56]",children:[e.jsx(Ut,{label:t("filters.workflowState","Workflow State"),doctype:"Workflow State",value:Rt,onChange:ze=>De(ze),placeholder:t("linkField.selectLabel",{label:t("filters.workflowState","Workflow State")}),disabled:!1,compact:!0}),Rt&&e.jsx("button",{onClick:()=>{De(""),r.delete("workflow_state"),s(r)},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("commonFields.serialNumber")}),e.jsx("input",{type:"text",value:_e,onChange:ze=>ar(ze.target.value),onKeyDown:Ir,placeholder:t("common.typeToSearch"),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),_e&&_e!==ve&&e.jsx("span",{className:"absolute right-2 top-6 text-[9px] text-blue-500 animate-pulse",children:t("common.typing")}),ve&&e.jsx("button",{onClick:()=>{Oe(""),He("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[55]",children:[e.jsx(Ut,{label:t("filters.mfr"),doctype:"Manufacturer",value:ht,onChange:ze=>et(ze),placeholder:t("linkField.selectLabel",{label:t("filters.mfr")}),disabled:!1,compact:!0}),ht&&e.jsx("button",{onClick:()=>et(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[54]",children:[e.jsx(Ut,{label:t("filters.supplier"),doctype:"Supplier",value:Be,onChange:ze=>kt(ze),placeholder:t("linkField.selectLabel",{label:t("filters.supplier")}),disabled:!1,compact:!0}),Be&&e.jsx("button",{onClick:()=>kt(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[53]",children:[e.jsx(Ut,{label:t("filters.dept"),doctype:"Department",value:it,onChange:ze=>xt(ze),placeholder:t("linkField.selectLabel",{label:t("filters.dept")}),disabled:!1,compact:!0}),it&&e.jsx("button",{onClick:()=>xt(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.priority")}),e.jsxs("select",{value:Dt,onChange:ze=>Ot(ze.target.value),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("filters.allPriorities")}),e.jsx("option",{value:"Normal",children:t("workOrders.priorityNormal")}),e.jsx("option",{value:"Urgent",children:t("workOrders.priorityUrgent")})]}),Dt&&e.jsx("button",{onClick:()=>Ot(""),className:"absolute right-8 top-6 text-gray-400 hover:text-red-500 transition-colors",children:e.jsx(wt,{size:10})})]})]})})})]})]}),me&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:"Save Filter Preset"}),e.jsx("input",{type:"text",value:ie,onChange:ze=>xe(ze.target.value),onKeyDown:ze=>{ze.key==="Enter"&&(ze.preventDefault(),kr())},placeholder:"Enter filter name (e.g., 'Pending High Priority')",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white mb-4",autoFocus:!0}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>{de(!1),xe("")},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:kr,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors flex items-center gap-2",children:[e.jsx(Or,{size:12}),"Save Filter"]})]})]})}),e.jsx(Gk,{isOpen:C,onClose:()=>D(!1),doctype:"Work_Order",selectedCount:N.size,pageCount:_t.length,totalCount:Ft,pageData:_t,selectedRows:N,rowKey:"name",onFetchAll:$e,fileNamePrefix:"work_orders",defaultColumns:["name","asset","asset_name","work_order_type","company","department","repair_status","workflow_state","custom_priority_","creation"],hiddenColumns:["docstatus","idx","amended_from","naming_series"]}),e.jsx(mL,{isOpen:O,onClose:()=>R(!1),selectedWorkOrders:U,onConfirmClose:Kt,isClosing:Y}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden relative",children:[pt&&j&&e.jsx("div",{className:"absolute inset-0 bg-white/60 dark:bg-gray-800/60 flex items-center justify-center z-10 backdrop-blur-[1px]",children:e.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[e.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-blue-500"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Filtering..."})]})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left",children:e.jsx("button",{onClick:qr,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:fr?"Deselect all":"Select all",children:fr?e.jsx(Es,{className:"text-blue-600 dark:text-blue-400",size:18}):G?e.jsxs("div",{className:"relative",children:[e.jsx(Ar,{size:18}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):e.jsx(Ar,{size:18})})}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("workOrders.table.workOrderId")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("workOrders.table.asset")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("workOrders.table.type")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("workOrders.table.technicalReport")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("workOrders.table.department")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("commonFields.status")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("workOrders.table.priority")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("common.actions")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:_t.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:10,className:"px-6 py-12 text-center text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(Js,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),e.jsx("p",{children:t("workOrders.table.noWorkOrdersFound")}),Gr?e.jsx("button",{onClick:_s,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:t("common.clearFilters")}):gt?e.jsx("button",{onClick:_a,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:t("workOrders.table.createFirstWorkOrder")}):null]})})}):_t.map(ze=>{var yt,Sa;return e.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${N.has(ze.name)?"bg-blue-50 dark:bg-blue-900/20":ii((yt=ze.custom_delete_status)!=null?yt:void 0)}`,title:ze.custom_delete_status?`Delete Status: ${ze.custom_delete_status}`:void 0,onClick:()=>zr(ze.name),children:[e.jsx("td",{className:"px-4 py-4",onClick:_r=>_r.stopPropagation(),children:e.jsx("button",{onClick:()=>Ia(ze.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:N.has(ze.name)?e.jsx(Es,{className:"text-blue-600 dark:text-blue-400",size:18}):e.jsx(Ar,{size:18})})}),e.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:ze.name}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:yo(ze.modified)})]}),e.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[e.jsx("div",{className:"text-sm text-gray-900 dark:text-white",children:ze.asset_name||"-"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:ze.asset||""})]}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:ze.work_order_type||"-"}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 max-w-xs truncate",title:ze.actions_performed||"",children:ze.actions_performed||"-"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:ze.department||"-"}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Ms(ze.repair_status||""),e.jsx("span",{className:`px-3 py-1 inline-flex text-xs leading-5 font-semibold rounded-full ${oi(ze.repair_status||"")}`,children:ze.repair_status||"Unknown"})]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:`px-3 py-1 inline-flex text-xs leading-5 font-semibold rounded-full ${wi(ze.custom_priority_||"")}`,children:ze.custom_priority_?t(`workOrders.priority.${ze.custom_priority_.toLowerCase()}`,ze.custom_priority_):t("workOrders.priority.normal","Normal")})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:e.jsxs("div",{className:"flex items-center gap-1",onClick:_r=>_r.stopPropagation(),children:[e.jsx("button",{onClick:()=>zr(ze.name),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:"View Details",children:e.jsx(ri,{})}),e.jsx("button",{onClick:()=>Aa(ze.name),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:"Edit Work Order",children:e.jsx(Fr,{})}),e.jsx("button",{onClick:()=>Ds(ze.name),className:"text-purple-600 dark:text-purple-400 hover:text-purple-900 dark:hover:text-purple-300 p-2 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded transition-colors",title:"Duplicate Work Order",children:e.jsx(Wd,{})}),e.jsx("div",{onClick:_r=>_r.stopPropagation(),children:e.jsx(Ll,{doctype:"Work_Order",docname:ze.name,currentDeleteStatus:(Sa=ze.custom_delete_status)!=null?Sa:null,userRoles:te,isSystemManager:I,triggerMode:!0,redirectOnDelete:"/work-orders",onStatusChange:()=>Zt()})}),e.jsxs("div",{className:"relative",ref:h===ze.name?p:null,children:[e.jsx("button",{onClick:()=>g(h===ze.name?null:ze.name),className:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 p-2 hover:bg-gray-50 dark:hover:bg-gray-700 rounded transition-colors",title:"More Actions",children:e.jsx(Nu,{})}),h===ze.name&&e.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 z-10",children:[e.jsxs("button",{onClick:()=>{wa(ze),g(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2 rounded-t-lg",children:[e.jsx(po,{className:"text-blue-500"}),"Export as JSON"]}),e.jsxs("button",{onClick:()=>{cn(ze.name),g(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2 rounded-b-lg",children:[e.jsx(Fi,{className:"text-purple-500"}),"Print Work Order"]})]})]})]})})]},ze.name)})})]})}),e.jsx(Rc,{currentPage:i+1,totalCount:Ft,pageSize:b,hasMore:dt,itemLabel:t("pagination.workOrders"),onPageChange:ze=>c(Math.max(0,ze-1))})]}),d&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:e.jsx(Na,{className:"text-red-600 dark:text-red-400 text-xl"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:t("workOrders.deleteWorkOrder")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:t("workOrders.deleteConfirmMessage")}),e.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-md p-3 mb-4",children:e.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[e.jsxs("strong",{children:[t("commonFields.workOrderId"),":"]})," ",d]})}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>m(null),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-lg transition-colors",disabled:La,children:t("common.cancel")}),e.jsx("button",{onClick:()=>xr(d),className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50",disabled:La,children:La?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),t("common.deleting")]}):e.jsxs(e.Fragment,{children:[e.jsx(Na,{}),t("workOrders.deleteWorkOrder")]})})]})]})]})})}),e.jsx(cL,{isOpen:T,onClose:()=>E(!1)}),e.jsx("style",{children:`
@keyframes scale-in { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.animate-scale-in { animation: scale-in 0.2s ease-out; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
.scrollbar-hide::-webkit-scrollbar { display: none; }
`})]})},gL="Service_Report",Z0=()=>{const t=new Date,a=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),i=String(t.getHours()).padStart(2,"0"),c=String(t.getMinutes()).padStart(2,"0");return`${a}-${r}-${s}T${i}:${c}`},xx=()=>{const t=new Date,a=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),i=String(t.getHours()).padStart(2,"0"),c=String(t.getMinutes()).padStart(2,"0"),d=String(t.getSeconds()).padStart(2,"0");return`${a}-${r}-${s} ${i}:${c}:${d}`},Nd=t=>{if(!t)return"";if(t.length===10)return`${t}T00:00`;if(t.includes(" ")){const[a,r]=t.split(" "),s=r.substring(0,5);return`${a}T${s}`}return t.includes("T")?t.substring(0,16):t},Sd=t=>t?t.includes("T")?t.replace("T"," ")+":00":t:"",co=t=>{if(!t)return"-";try{return new Date(t.replace(" ","T")).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})}catch(a){return t}},fL=(t,a)=>{if(!t)return"";const r=t.split("T")[0].split(" ")[0],s=new Date(r);return s.setDate(s.getDate()+a),s.toISOString().split("T")[0]},xL=()=>{var Co,Vn,To;const{t}=ca(),{workOrderName:a}=xo(),r=qa(),[s]=Qs(),i=s.get("duplicate"),c=s.get("asset"),d=!!c,m=a==="new",h=m&&!!i,g=()=>{if(!a||m)return;const pe=`${ia.BASE_URL}/printview?doctype=Work_Order&name=${encodeURIComponent(a)}&format=${encodeURIComponent(gL)}&trigger_print=1`;window.open(pe,"_blank")||nt.warning(t("workOrders.detail.pleaseAllowPopupsServiceReport"),{position:"top-right",autoClose:5e3,icon:e.jsx(fa,{})})},[p,b]=y.useState(!1),[j,_]=y.useState([]),[N,k]=y.useState(!1),[C,D]=y.useState(""),[T,E]=y.useState(!1),[O,R]=y.useState([]),[Y,P]=y.useState([]),[U,J]=y.useState(""),[ne,ye]=y.useState(!1),[he,ce]=y.useState(!1),[se,ee]=y.useState(null),[te,W]=y.useState([]),[I,oe]=y.useState(!1),[ae,F]=y.useState([]),[M,B]=y.useState("room"),[X,K]=y.useState(!1),[we,be]=y.useState(!1),[ke,Me]=y.useState(0),{workOrder:z,loading:Ne,error:Xe,refetch:gt}=S5(h?i:m?null:a||null),{createWorkOrder:St,updateWorkOrder:Ht,loading:Mt}=b2(),[Te,Qt]=y.useState(m),[zt,Wt]=y.useState(!1),[Vt,va]=y.useState(null),ta=["System Manager","Work Control","Contractor Supervisor","Contractor Manager","Maintenance Manager","Cluster Manager","Contractor Engineer","Quality Supervisor","Technician"],[sa,ra]=y.useState(!1),[Ye,ft]=y.useState(null),$t=pa.useRef(!1),[na,Ze]=y.useState(!1),[lt,aa]=y.useState(!1),[Ie,Nt]=y.useState(!1),[ve,Oe]=y.useState([]),[ht,et]=y.useState([]),[Be,kt]=y.useState([]),[it,xt]=y.useState(!1),[Dt,Ot]=y.useState(""),[Rt,De]=y.useState(""),[Qe,fe]=y.useState(""),[re,Ee]=y.useState(""),[Ge,ct]=y.useState([]),[It,st]=y.useState([]),[rt,V]=y.useState(!1),[me,de]=y.useState(!1),[ie,xe]=y.useState(""),[_e,He]=y.useState(!1),[Ue,Pe]=y.useState([]),[Re,We]=y.useState(!1),[_t,Ft]=y.useState(!1),[dt,pt]=y.useState(!1),[At,Zt]=y.useState(null),[Fa,La]=y.useState(!1),[Ya,gr]=y.useState(!1),[ar,Ir]=y.useState("give"),[kr,hs]=y.useState([{parameter:"Quality of Service",rating:0,feedback:""},{parameter:"Timeliness",rating:0,feedback:""},{parameter:"Professionalism",rating:0,feedback:""},{parameter:"Communication",rating:0,feedback:""}]),[ha,Ia]=y.useState(!1),[qr,fr]=y.useState(""),[G,$e]=y.useState({company:"King Fahad Specialist Hospital - Dammam",work_order_type:"",custom_type:"Corrective",custom_civil_work_category:"",asset:"",asset_name:"",description:"",repair_status:"Open",workflow_state:"Draft",department:"",custom_priority_:"Normal",asset_type:"Non Biomedical",manufacturer:"",supplier:"",serial_number:"",model:"",custom_site_contractor:"",custom_subcontractor:"",failure_date:m?Z0():"",custom_deadline_date:"",completion_date:"",first_responded_on:"",actions_performed:"",stock_consumption:0,stock_items:[],site_name:"",need_procurement:0,custom_assign_to_contractor:"",assigned_technician:"",custom_assigned_engineer:"",docstatus:0,custom_assigned_supervisor:"",total_hours_spent:0,custom_pending_reason:"",total_repair_cost:0,custom_travel_hour:"",custom_service_agreement:"",custom_service_coverage:"",custom_start_date:"",custom_end_date:"",custom_total_amount:0,custom_location:"",custom_extension_no:"",custom_attachment:"",custom_attachment_on_close:"",custom_add_technicians:"",inspection:"",custom_department_no:"",custom_reason:"",custom_technical_department:"",custom_room_no:"",custom_building:"",__islocal:!1}),Bt=G.asset_type==="Non Biomedical",_a=y.useCallback(()=>{const Z=(z==null?void 0:z.workflow_state)||G.workflow_state||"Draft";return Z==="Cancelled"?2:Z==="Closed"?1:(z==null?void 0:z.docstatus)||G.docstatus||0},[z==null?void 0:z.workflow_state,G.workflow_state,z==null?void 0:z.docstatus,G.docstatus])(),Ds=_a===1||_a===2,xr=!!Ye,wa=!!(C&&(z!=null&&z.owner)&&C===z.owner),Za=Z=>{const pe=new Date;return pe.setDate(pe.getDate()-(Z-1)),pe.toISOString().split("T")[0]},cn=()=>Q(null,null,function*(){var Z;try{const pe=yield mt.apiCall("/api/resource/Work Order Settings/Work Order Settings");return(Z=pe==null?void 0:pe.data)!=null&&Z.custom_days&&parseInt(pe.data.custom_days)||1}catch(pe){return console.error("Error fetching days config:",pe),1}}),_s=y.useCallback((Z,pe)=>Q(null,null,function*(){if(!(!Z||!pe||!m)){K(!0);try{const je=yield cn(),Ct=Za(je),Jt=[["work_order_type","=",Z],["custom_room_no","=",pe],["workflow_state","not in",["Approved","Closed","Cancelled"]],["creation",">=",`${Ct} 00:00:00`]],Pt=yield mt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify(Jt))}&fields=["name","workflow_state","creation"]&limit=10`);Pt!=null&&Pt.data&&Pt.data.length>0&&(F(Pt.data),B("room"),oe(!0))}catch(je){console.error("Error checking duplicates by Room No:",je)}finally{K(!1)}}}),[m]),Gr=y.useCallback(Z=>Q(null,null,function*(){if(!(!Z||!m)){K(!0);try{const pe=[["asset","=",Z],["workflow_state","not in",["Approved","Closed","Cancelled"]]],je=yield mt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify(pe))}&fields=["name","workflow_state","creation"]&limit=10`);je!=null&&je.data&&je.data.length>0&&(F(je.data),B("asset"),oe(!0))}catch(pe){console.error("Error checking duplicates by Asset:",pe)}finally{K(!1)}}}),[m]),yo=()=>{oe(!1),F([])},ii=()=>{oe(!1),F([]),$e(M==="asset"?Z=>Se(ue({},Z),{asset:"",asset_name:""}):Z=>Se(ue({},Z),{work_order_type:"",custom_room_no:""}))};y.useEffect(()=>{const Z=G.work_order_type,pe=G.custom_room_no;if(m&&!G.asset&&Z&&pe){const je=setTimeout(()=>{_s(Z,pe)},500);return()=>clearTimeout(je)}},[m,G.asset,G.work_order_type,G.custom_room_no,_s]),y.useEffect(()=>{const Z=G.asset;if(m&&Z){const pe=setTimeout(()=>{Gr(Z)},500);return()=>clearTimeout(pe)}},[m,G.asset,Gr]),y.useEffect(()=>{const pe=setTimeout(()=>Q(null,null,function*(){var Ct,Jt;if(G.asset){be(!1),Me(0);return}if(!(G.custom_building||G.department||G.custom_room_no)){be(!1),Me(0);return}try{const Pt=[["docstatus","=","1"]];G.company&&Pt.push(["company","=",G.company]),G.custom_building&&Pt.push(["custom_building","=",G.custom_building]),G.department&&Pt.push(["department","=",G.department]),G.custom_room_no&&Pt.push(["custom_room_number","=",G.custom_room_no]);const ma=yield mt.apiCall(`/api/resource/Asset?filters=${encodeURIComponent(JSON.stringify(Pt))}&fields=["name"]&limit=1000`),xa=((Ct=ma==null?void 0:ma.data)==null?void 0:Ct.length)||0;Me(xa),be(xa>=1);const Tr=!!(G.custom_building&&G.department&&G.custom_room_no);xa===1&&((Jt=ma.data[0])!=null&&Jt.name)&&!G.asset&&Tr&&(di(ma.data[0].name),nt.info(`Asset auto-selected: ${ma.data[0].name}`,{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}))}catch(Pt){console.error("Error checking asset count:",Pt),be(!1),Me(0)}}),500);return()=>clearTimeout(pe)},[G.asset,G.company,G.custom_building,G.department,G.custom_room_no]),y.useEffect(()=>{const Z=j.includes("Technician");!m&&(z==null?void 0:z.workflow_state)==="Repair InProgress"&&!xr&&Z&&Qt(!0)},[m,z==null?void 0:z.workflow_state,xr,j]),y.useEffect(()=>{Q(null,null,function*(){if(!m&&a&&(z==null?void 0:z.workflow_state)==="Repair InProgress"&&(!(z!=null&&z.first_responded_on)||z.first_responded_on==="")){const pe=xx();try{yield Ht(a,{first_responded_on:pe}),$e(je=>Se(ue({},je),{first_responded_on:Nd(pe)})),nt.info(t("workOrders.detail.firstRespondedOnSetTo",{datetime:co(pe)}),{position:"top-right",autoClose:3e3,icon:e.jsx(or,{})}),gt(),setTimeout(()=>{Ms()},500),console.log("Auto-set first_responded_on to:",pe)}catch(je){console.error("Error auto-setting first_responded_on:",je)}}})},[m,a,z==null?void 0:z.workflow_state,z==null?void 0:z.first_responded_on]),y.useEffect(()=>{Q(null,null,function*(){if(!m&&a&&(z==null?void 0:z.workflow_state)==="Closed"&&(!(z!=null&&z.completion_date)||z.completion_date==="")){const pe=xx();try{yield Ht(a,{completion_date:pe}),$e(je=>Se(ue({},je),{completion_date:Nd(pe)})),nt.info(t("workOrders.detail.completionDateSetTo",{datetime:co(pe)}),{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),gt(),setTimeout(()=>{Ms()},500),console.log("Auto-set completion_date to:",pe)}catch(je){console.error("Error auto-setting completion_date:",je)}}})},[m,a,z==null?void 0:z.workflow_state,z==null?void 0:z.completion_date]),y.useEffect(()=>{if(!C)return;k(!1),_([]),Q(null,null,function*(){try{const je=yield(yield fetch(`/api/method/asset_lite.api.user_roles.get_user_roles?_=${Date.now()}`,{method:"GET",headers:{"Content-Type":"application/json","Cache-Control":"no-cache, no-store, must-revalidate",Pragma:"no-cache"},credentials:"include"})).json();je.message&&Array.isArray(je.message)&&(_(je.message),console.log("User roles fetched for:",C,je.message))}catch(pe){console.error("Error fetching user roles:",pe),_([])}finally{k(!0)}})},[C]),y.useEffect(()=>{Q(null,null,function*(){try{const je=yield(yield fetch("/api/method/frappe.auth.get_logged_user",{method:"GET",headers:{"Content-Type":"application/json","Cache-Control":"no-cache, no-store, must-revalidate",Pragma:"no-cache"},credentials:"include"})).json();je.message&&(D(je.message),console.log("Current user:",je.message))}catch(pe){console.error("Error fetching current user:",pe),D("")}})},[]),y.useEffect(()=>{Q(null,null,function*(){try{const je=yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({roles:ta.join(",")})})).json();je.message&&(ra(je.message.has_role),console.log("Can delete/cancel:",je.message.has_role))}catch(pe){console.error("Error checking delete permissions:",pe),ra(!1)}})},[]);const Ms=y.useCallback(()=>Q(null,null,function*(){if(!(m||!a)){We(!0);try{const Z=yield mt.apiCall(`/api/resource/Version?filters=[["ref_doctype","=","Work_Order"],["docname","=","${encodeURIComponent(a)}"]]&fields=["name","owner","creation","data"]&order_by=creation desc&limit=50`);if(Z!=null&&Z.data&&Z.data.length>0){const pe=Z.data.map(je=>{let Ct={added:[],changed:[],removed:[],row_changed:[]};try{Ct=JSON.parse(je.data||"{}")}catch(Pt){console.error("Error parsing version data:",Pt)}const Jt=(Ct.changed||[]).map(Pt=>({field:Pt[0]||"",oldValue:Pt[1],newValue:Pt[2]}));return{name:je.name,owner:je.owner,creation:je.creation,changes:Jt,added:Ct.added||[],removed:Ct.removed||[],rowChanged:Ct.row_changed||[]}});Pe(pe),console.log("Audit logs fetched:",pe.length)}else Pe([])}catch(Z){console.error("Error fetching audit logs:",Z),Pe([])}finally{We(!1)}}}),[m,a]);y.useEffect(()=>{Ms()},[Ms]);const oi=y.useCallback(()=>Q(null,null,function*(){var Z;try{const je=yield(yield fetch("/api/method/frappe.client.get_value",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:"User",filters:{name:C},fieldname:"full_name"})})).json();(Z=je.message)!=null&&Z.full_name&&fr(je.message.full_name)}catch(pe){console.error("Error fetching user full name:",pe)}}),[C]),wi=y.useCallback(()=>Q(null,null,function*(){if(!(m||!a||!(z!=null&&z.owner))){La(!0);try{const Z=JSON.stringify([["work_order","=",a],["feedback_by","=",(z==null?void 0:z.owner)||C]]),pe=yield mt.apiCall(`/api/resource/Feedback?filters=${encodeURIComponent(Z)}&fields=["name"]&limit=1`);if(pe!=null&&pe.data&&pe.data.length>0){const je=yield mt.apiCall(`/api/resource/Feedback/${pe.data[0].name}`);je!=null&&je.data&&Zt(je.data)}else Zt(null)}catch(Z){console.error("Error fetching feedback:",Z),Zt(null)}finally{La(!1)}}}),[m,a,C]);y.useEffect(()=>{const Z=(z==null?void 0:z.workflow_state)||G.workflow_state||"";["Approved","Closed"].includes(Z)&&(C||z!=null&&z.owner)&&(wi(),C&&oi())},[z==null?void 0:z.workflow_state,G.workflow_state,C,z==null?void 0:z.owner,wi,oi]);const ze=()=>{hs([{parameter:"Quality of Service",rating:0,feedback:""},{parameter:"Timeliness",rating:0,feedback:""},{parameter:"Professionalism",rating:0,feedback:""},{parameter:"Communication",rating:0,feedback:""}]),Ir("give"),gr(!0)},yt=()=>{At!=null&&At.parameters&&hs(At.parameters.map(Z=>({parameter:Z.parameter,rating:Z.rating||0,feedback:Z.feedback||""}))),Ir("view"),gr(!0)},Sa=()=>{Ir("edit")},_r=(Z,pe)=>{hs(je=>{const Ct=[...je];return Ct[Z]=Se(ue({},Ct[Z]),{rating:pe}),Ct})},Sr=Z=>{const pe=Z.filter(Ct=>Ct.rating>0);if(pe.length===0)return 0;const je=pe.reduce((Ct,Jt)=>Ct+Jt.rating,0);return parseFloat((je/pe.length).toFixed(2))},Yr=()=>Q(null,null,function*(){if(!kr.some(pe=>pe.rating>0)){nt.warning(t("workOrders.detail.pleaseProvideAtLeastOneRating"),{position:"top-right",autoClose:3e3,icon:e.jsx(fa,{})});return}Ia(!0);try{const pe=Sr(kr),je={doctype:"Feedback",work_order:a,feedback_by:C,overall:pe,parameters:kr.map((Pt,ma)=>({parameter:Pt.parameter,rating:Pt.rating,feedback:Pt.feedback||null,idx:ma+1}))},Jt=yield(yield fetch("/api/resource/Feedback",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(je)})).json();if(Jt.data)Zt(Jt.data),gr(!1),nt.success(t("workOrders.detail.feedbackSubmittedSuccessfully"),{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})});else throw new Error(Jt.exc||"Failed to submit feedback")}catch(pe){console.error("Error submitting feedback:",pe);const je=pe instanceof Error?pe.message:"Unknown error";nt.error(`${t("workOrders.detail.failedToSubmitFeedback")}: ${je}`,{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})})}finally{Ia(!1)}}),oa=()=>Q(null,null,function*(){if(At!=null&&At.name){Ia(!0);try{const Z=Sr(kr),pe=kr.map((Jt,Pt)=>{var xa;const ma=(xa=At.parameters)==null?void 0:xa[Pt];return Se(ue({},ma!=null&&ma.name?{name:ma.name}:{}),{parameter:Jt.parameter,rating:Jt.rating,feedback:Jt.feedback||null,idx:Pt+1})}),Ct=yield(yield fetch(`/api/resource/Feedback/${At.name}`,{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({overall:Z,parameters:pe})})).json();if(Ct.data)Zt(Ct.data),Ir("view"),nt.success(t("workOrders.detail.feedbackUpdatedSuccessfully"),{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})});else throw new Error(Ct.exc||"Failed to update feedback")}catch(Z){console.error("Error updating feedback:",Z);const pe=Z instanceof Error?Z.message:"Unknown error";nt.error(`${t("workOrders.detail.failedToUpdateFeedback")}: ${pe}`,{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})})}finally{Ia(!1)}}}),Zr=Z=>({"Medical Gas الغازات الطبية":"Mechanical Maintenance-الصيانة الميكانيكية"})[Z]||Z,za=y.useCallback(Z=>Q(null,null,function*(){if(!Z){Oe([]);return}const pe=Zr(Z);try{const je=yield mt.apiCall(`/api/resource/Asset Maintenance Team?filters=[["custom_expertise","=","${encodeURIComponent(pe)}"]]&fields=["maintenance_manager"]&limit=100`);if(je!=null&&je.data&&je.data.length>0){const Ct=je.data.map(Pt=>Pt.maintenance_manager).filter(Pt=>Pt),Jt=[...new Set(Ct)];console.log("Filtered Managers based on expertise:",Jt),Oe(Jt)}else Oe([])}catch(je){console.error("Error fetching managers based on expertise:",je),Oe([])}}),[]),_n=y.useCallback(Z=>Q(null,null,function*(){if(!Z){et([]);return}const pe=Zr(Z);try{console.log("Filtering technicians for work order type:",Z,"→ expertise:",pe);const je=yield mt.apiCall(`/api/resource/Asset Maintenance Team?filters=[["custom_expertise","=","${encodeURIComponent(pe)}"]]&fields=["name"]&limit=100`);if(je!=null&&je.data&&je.data.length>0){const Ct=new Set,Jt=je.data.map(ma=>Q(null,null,function*(){try{const xa=yield mt.apiCall(`/api/resource/Asset Maintenance Team/${encodeURIComponent(ma.name)}`);xa!=null&&xa.data&&(xa.data.maintenance_team_members||[]).forEach(Ba=>{Ba.team_member&&Ct.add(Ba.team_member)})}catch(xa){console.error("Error fetching team:",ma.name,xa)}}));yield Promise.all(Jt);const Pt=Array.from(Ct);console.log("Filtered Technicians:",Pt),et(Pt)}else et([])}catch(je){console.error("Error fetching technicians:",je),et([])}}),[]),wn=y.useCallback(Z=>Q(null,null,function*(){if(!Z){kt([]);return}const pe=Zr(Z);try{console.log("Filtering engineers for work order type:",Z,"→ expertise:",pe);const je=yield mt.apiCall(`/api/resource/Asset Maintenance Team?filters=[["custom_expertise","=","${encodeURIComponent(pe)}"]]&fields=["name"]&limit=100`);if(je!=null&&je.data&&je.data.length>0){const Ct=new Set,Jt=je.data.map(ma=>Q(null,null,function*(){try{const xa=yield mt.apiCall(`/api/resource/Asset Maintenance Team/${encodeURIComponent(ma.name)}`);xa!=null&&xa.data&&(xa.data.maintenance_team_members||[]).forEach(Ba=>{Ba.team_member&&Ba.maintenance_role==="Contractor Engineer"&&Ct.add(Ba.team_member)})}catch(xa){console.error("Error fetching team for engineers:",ma.name,xa)}}));yield Promise.all(Jt);const Pt=Array.from(Ct);console.log("Filtered Engineers (Contractor Engineer role):",Pt),kt(Pt)}else kt([])}catch(je){console.error("Error fetching engineers:",je),kt([])}}),[]),ws=y.useCallback(Z=>Q(null,null,function*(){if(!Z){ct([]);return}V(!0);try{const pe=JSON.stringify([["building","=",Z]]),je=yield mt.apiCall(`/api/resource/Infrastructure Location?filters=${encodeURIComponent(pe)}&fields=["department"]&limit=9999`);if(je!=null&&je.data&&je.data.length>0){const Ct=je.data.map(Pt=>Pt.department).filter(Pt=>Pt),Jt=[...new Set(Ct)];console.log("Filtered Departments for building:",Z,Jt),ct(Jt)}else ct([])}catch(pe){console.error("Error fetching departments for building:",pe),ct([])}finally{V(!1)}}),[]),ki=y.useCallback((Z,pe)=>Q(null,null,function*(){if(!Z&&!pe){st([]);return}V(!0);try{const je=new URLSearchParams;Z&&je.append("building",Z),pe&&je.append("department",pe);const Pt=(yield(yield fetch(`/api/method/asset_lite.api.room_filter.get_room_count?${je.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).message||0;st(new Array(Pt).fill("")),console.log("Room count:",{building:Z,department:pe,count:Pt})}catch(je){console.error("Error fetching room count:",je),st([])}finally{V(!1)}}),[]),gs=y.useCallback((Z,pe,je)=>Q(null,null,function*(){if(je&&!(!Z&&!pe)){V(!0);try{const Ct=[["room_no","=",je]];Z&&Ct.push(["building","=",Z]),pe&&Ct.push(["department","=",pe]);const Jt=JSON.stringify(Ct),Pt=yield mt.apiCall(`/api/resource/Infrastructure Location?filters=${encodeURIComponent(Jt)}&fields=["location"]&limit=1`);if(Pt!=null&&Pt.data&&Pt.data.length>0&&Pt.data[0].location){const ma=Pt.data[0].location;console.log("Auto-setting location:",ma,{building:Z,department:pe,roomNo:je}),$e(xa=>xa.custom_location===ma?xa:(nt.info(t("workOrders.detail.locationAutoSetTo",{location:ma}),{position:"top-right",autoClose:2e3,icon:e.jsx(ea,{})}),Se(ue({},xa),{custom_location:ma})))}}catch(Ct){console.error("Error fetching location:",Ct)}finally{V(!1)}}}),[]);y.useCallback(()=>Q(null,null,function*(){ye(!0);try{const pe=yield(yield fetch("/api/method/asset_lite.api.user_roles.get_users_with_role",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({role:"Technician"})})).json();if(pe.message&&Array.isArray(pe.message)){const je=pe.message.map(Ct=>({name:Ct.name,full_name:Ct.full_name||Ct.name}));P(je),console.log("Fetched technicians:",je.length)}else P([]),console.log("No technicians found")}catch(Z){console.error("Error fetching technicians:",Z),P([])}finally{ye(!1)}}),[]);const Ls=Z=>{R(pe=>pe.includes(Z)?pe.filter(je=>je!==Z):[...pe,Z])},zn=()=>{if(O.length===0){nt.warning(t("workOrders.detail.noTechniciansSelected"),{position:"top-right",autoClose:3e3,icon:e.jsx(fa,{})});return}W(O),ce(!0)},Cr=()=>{const Z=te.join(",");$e(pe=>Se(ue({},pe),{custom_add_technicians:Z})),ce(!1),E(!1),W([]),nt.success(t("workOrders.detail.techniciansAssignedSuccessfully",{count:te.length}),{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})})},Bn=()=>{ce(!1),W([])},Un=y.useMemo(()=>{if(!U)return Y;const Z=U.toLowerCase();return Y.filter(pe=>pe.name.toLowerCase().includes(Z)||pe.full_name&&pe.full_name.toLowerCase().includes(Z))},[Y,U]);y.useEffect(()=>{G.work_order_type?za(G.work_order_type):Oe([])},[G.work_order_type,za]),y.useEffect(()=>{G.work_order_type?_n(G.work_order_type):et([])},[G.work_order_type,_n]),y.useEffect(()=>{G.work_order_type?wn(G.work_order_type):kt([])},[G.work_order_type,wn]),y.useEffect(()=>{G.custom_building?ws(G.custom_building):ct([])},[G.custom_building,ws]),y.useEffect(()=>{const Z=G.custom_building||void 0,pe=G.department||void 0;Z||pe?ki(Z,pe):st([])},[G.custom_building,G.department,ki]),y.useEffect(()=>{const Z=G.custom_building||void 0,pe=G.department||void 0,je=G.custom_room_no||void 0;je&&(Z||pe)&&gs(Z,pe,je)},[G.custom_building,G.department,G.custom_room_no,gs]);const Wi=y.useCallback((Z,pe,je)=>{if(!Z)return"";let Ct=0;const Jt=je===1;return pe==="Normal"?Ct=Jt?30:5:pe==="Medium"?Ct=Jt?30:3:pe==="Urgent"&&(Ct=Jt?30:1),fL(Z,Ct)},[]);y.useEffect(()=>{if(!Te)return;const Z=Wi(G.failure_date,G.custom_priority_||"Normal",G.need_procurement||0);Z&&Z!==G.custom_deadline_date&&$e(pe=>Se(ue({},pe),{custom_deadline_date:Z}))},[G.failure_date,G.custom_priority_,G.need_procurement,Te,Wi]),y.useEffect(()=>{Bt&&Te&&$e(Z=>Se(ue({},Z),{asset:"",asset_name:"",serial_number:"",manufacturer:"",supplier:"",model:""}))},[Bt,Te]);const{shouldShowField:Rl,isMandatory:Qr,isReadOnly:kn}=Yk("Work_Order",G);y.useCallback(Z=>Rl(Z),[Rl]),y.useCallback(Z=>Qr(Z),[Qr]);const bo=y.useCallback(Z=>kn(Z),[kn]),Vi=y.useCallback(()=>!!(G.custom_building||G.department),[G.custom_building,G.department]),Ra=y.useCallback(()=>!!(G.department||G.custom_room_no),[G.department,G.custom_room_no]),Pl=y.useCallback(()=>!!(G.custom_room_no||G.custom_location),[G.custom_room_no,G.custom_location]);y.useCallback(Z=>Ds||xr||!Te?!0:bo(Z),[Te,bo,Ds,xr]),y.useMemo(()=>{if(!ie)return It.slice(0,30);const Z=ie.toLowerCase();return It.filter(pe=>pe.toLowerCase().includes(Z)).slice(0,50)},[It,ie]);const Rs=y.useMemo(()=>{if(!m)return{asset_type:(z==null?void 0:z.asset_type)||G.asset_type||"",site_name:(z==null?void 0:z.site_name)||G.site_name||"",need_procurement:(z==null?void 0:z.need_procurement)||G.need_procurement||0,custom_assign_to_contractor:(z==null?void 0:z.custom_assign_to_contractor)||G.custom_assign_to_contractor||"",assigned_technician:(z==null?void 0:z.assigned_technician)||G.assigned_technician||"",custom_assigned_engineer:(z==null?void 0:z.custom_assigned_engineer)||G.custom_assigned_engineer||"",docstatus:(z==null?void 0:z.docstatus)||G.docstatus||0,company:(z==null?void 0:z.company)||G.company||"",department:(z==null?void 0:z.department)||G.department||"",repair_status:(z==null?void 0:z.repair_status)||G.repair_status||"",first_responded_on:(z==null?void 0:z.first_responded_on)||G.first_responded_on||""}},[m,z==null?void 0:z.asset_type,z==null?void 0:z.site_name,z==null?void 0:z.need_procurement,z==null?void 0:z.custom_assign_to_contractor,z==null?void 0:z.docstatus,z==null?void 0:z.company,z==null?void 0:z.department,z==null?void 0:z.repair_status,z==null?void 0:z.first_responded_on,G.first_responded_on,G.asset_type,G.site_name,G.need_procurement,G.custom_assign_to_contractor,G.docstatus,G.company,G.department,G.repair_status]),{transitions:es,loading:dn,actionLoading:qi,error:vo,isSystemManager:li,applyAction:Fc,getStateStyle:Fl,getButtonStyle:Qd,getIcon:Il}=ag({doctype:"Work_Order",docname:m?null:a||null,workflowState:z==null?void 0:z.workflow_state,enabled:!m,docData:Rs}),ci=y.useMemo(()=>{if(!es||es.length===0)return ee(null),[];const Z=j.includes("Work Control"),pe=j.includes("System Manager")||li,je=(z==null?void 0:z.workflow_state)||G.workflow_state||"Draft",Ct=G.assigned_technician||(z==null?void 0:z.assigned_technician)||"",Jt=G.custom_assigned_supervisor||(z==null?void 0:z.custom_assigned_supervisor)||"",Pt=G.custom_assigned_engineer||(z==null?void 0:z.custom_assigned_engineer)||"",ma=(z==null?void 0:z.work_order_type)||"",xa=Dt!==""&&ma!==""&&ma!==Dt;if(je==="Sent to Engineer"){if(xa){setTimeout(()=>ee('WO Type has been changed. Use "Back To Controller" to send for reassignment, or revert the change.'),0);const Nr=es.find(xs=>xs.action==="Back To Controller"&&xs.state==="Sent to Engineer");return Nr?[Nr]:[]}const as=(G.actions_performed||(z==null?void 0:z.actions_performed)||"").trim().length>0,Is=!!Ct,Pa=es.filter(Nr=>Nr.state==="Sent to Engineer"),qn=Pa.find(Nr=>Nr.action==="Send to Supervisor"),Rr=Pa.find(Nr=>Nr.action==="Back To Controller"),zs=Pa.filter(Nr=>Nr.action!=="Send to Supervisor"&&Nr.action!=="Back To Controller"),Bs=[];return Is&&as?(setTimeout(()=>ee(null),0),Bs.push(...zs),qn&&Bs.push(qn),Rr&&Bs.push(Rr)):Is&&!as?(setTimeout(()=>ee('Technician assigned. Fill "Technical Report" to also enable "Send to Supervisor" option.'),0),Bs.push(...zs),Rr&&Bs.push(Rr)):!Is&&as?(setTimeout(()=>ee('Technical Report filled. You can "Send to Supervisor" directly, OR assign a Technician for more workflow options.'),0),qn&&Bs.push(qn),Rr&&Bs.push(Rr)):(setTimeout(()=>ee(null),0),Rr&&Bs.push(Rr)),Bs}if(je==="Repair InProgress"){if(xa){setTimeout(()=>ee('WO Type has been changed. Use "Back To Controller" to send for reassignment, or revert the change.'),0);const Pa=es.find(qn=>qn.action==="Back To Controller"&&qn.state==="Repair InProgress");return Pa?[Pa]:[]}const as=(G.actions_performed||(z==null?void 0:z.actions_performed)||"").trim().length>0,Is=es.filter(Pa=>Pa.state==="Repair InProgress");return as?(setTimeout(()=>ee(null),0),Is):(setTimeout(()=>ee('Please fill the "Technical Report" field to enable "Send For Approval" action.'),0),Is.filter(Pa=>Pa.action!=="Send For Approval"))}const Tr={};es.forEach(an=>{Tr[an.action]||(Tr[an.action]=[]),Tr[an.action].push(an)});const Ba=[];let Br=null;return Object.entries(Tr).forEach(([an,as])=>{if(as.length===1){const Is=as[0];if(an==="Apply"&&Is.allowed==="Work Control"&&(Z||pe)){const Pa=[];if(Jt||Pa.push("Assigned Supervisor"),Pt||Pa.push("Assigned Engineer"),Pa.length>0){Br=`Please assign ${Pa.join(" and ")} before applying`,console.log(`Apply hidden for Work Control: ${Br}`);return}}Ba.push(Is)}else{const Is=as.find(Pa=>Pa.allowed==="Work Control");if(as.find(Pa=>Pa.allowed==="End user"),Z||pe)if(Is){if(an==="Apply"){const Pa=[];if(Jt||Pa.push("Assigned Supervisor"),Pt||Pa.push("Assigned Engineer"),Pa.length>0){Br=`Please assign ${Pa.join(" and ")} before applying`,console.log(`Apply hidden for Work Control: ${Br}`);return}}Ba.push(Is)}else as.forEach(Pa=>Ba.push(Pa));else as.forEach(Pa=>Ba.push(Pa))}}),setTimeout(()=>ee(Br),0),Ba.filter(an=>an.action==="Send For Approval"&&je==="Repair InProgress"?pe?!0:C?!!(C===Ct||(G.custom_add_technicians||(z==null?void 0:z.custom_add_technicians)||"").split(",").map(Rr=>Rr.trim()).filter(Rr=>Rr).includes(C)):!1:!0)},[es,j,li,C,G.assigned_technician,G.custom_assigned_supervisor,G.custom_assigned_engineer,G.workflow_state,G.custom_add_technicians,G.actions_performed,z==null?void 0:z.assigned_technician,z==null?void 0:z.custom_assigned_supervisor,z==null?void 0:z.custom_assigned_engineer,z==null?void 0:z.workflow_state,z==null?void 0:z.custom_add_technicians,z==null?void 0:z.work_order_type,z==null?void 0:z.actions_performed,Dt]);y.useMemo(()=>j.includes("Work Control")||li,[j,li]);const fs="Stores - KFSH-D",[tl,_o]=y.useState({}),$n=(Z,pe)=>Q(null,null,function*(){if(!Z||!pe)return 0;try{const je=yield mt.apiCall(`/api/resource/Bin?filters=[["item_code","=","${Z}"],["warehouse","=","${pe}"]]&fields=["actual_qty"]&limit=1`);return je!=null&&je.data&&je.data.length>0&&je.data[0].actual_qty||0}catch(je){return console.error("Error fetching available stock:",je),0}}),Ic=Z=>Q(null,null,function*(){var pe;if(!Z)return 0;try{const je=yield mt.apiCall(`/api/resource/Item/${Z}?fields=["valuation_rate"]`);return((pe=je==null?void 0:je.data)==null?void 0:pe.valuation_rate)||0}catch(je){return console.error("Error fetching valuation rate:",je),0}}),zc=Z=>Q(null,null,function*(){var pe;if(!Z)return fs;try{const je=yield mt.apiCall(`/api/resource/Item/${Z}?fields=["item_defaults"]`),Ct=((pe=je==null?void 0:je.data)==null?void 0:pe.item_defaults)||[];return Ct.length>0&&Ct[0].default_warehouse?Ct[0].default_warehouse:fs}catch(je){return console.error("Error fetching item default warehouse:",je),fs}}),zl=(Z,pe)=>Q(null,null,function*(){const je=[...G.stock_items||[]];if(pe){const Ct=je.findIndex((Jt,Pt)=>Pt!==Z&&Jt.item_code===pe);if(Ct!==-1){nt.warning(t("workOrders.detail.itemAlreadyAdded",{itemCode:pe,row:Ct+1}),{position:"top-right",autoClose:4e3,icon:e.jsx(fa,{}),toastId:`duplicate-item-${Z}`}),je[Z]=Se(ue({},je[Z]),{item_code:"",item_name:"",valuation_rate:0,custom_available_stock:0,total_value:0}),$e(Se(ue({},G),{stock_items:je}));return}}if(je[Z]=Se(ue({},je[Z]),{item_code:pe}),pe){const[Ct,Jt]=yield Promise.all([Ic(pe),zc(pe)]);je[Z].valuation_rate=Ct,je[Z].total_value=Ct*(je[Z].consumed_quantity||1),je[Z].warehouse=Jt;const Pt=yield $n(pe,Jt);je[Z].custom_available_stock=Pt,al(Z,je[Z].consumed_quantity,Pt,pe,Jt)}$e(Se(ue({},G),{stock_items:je}))}),Bl=Z=>{$e(pe=>Se(ue({},pe),{custom_building:Z,department:"",custom_room_no:"",custom_location:""}))},Bc=Z=>{$e(pe=>Se(ue({},pe),{department:Z,custom_room_no:"",custom_location:""}))},Uc=Z=>{$e(pe=>Se(ue({},pe),{custom_room_no:Z,custom_location:""}))},e0=(Z,pe)=>Q(null,null,function*(){const je=[...G.stock_items||[]];if(je[Z]=Se(ue({},je[Z]),{warehouse:pe}),pe&&je[Z].item_code){const Ct=yield $n(je[Z].item_code,pe);je[Z].custom_available_stock=Ct,al(Z,je[Z].consumed_quantity,Ct,je[Z].item_code,pe)}$e(Se(ue({},G),{stock_items:je}))}),al=(Z,pe,je,Ct,Jt)=>{pe>je?(_o(Pt=>Se(ue({},Pt),{[Z]:`Insufficient stock for ${Ct} in ${Jt}. Available: ${je}, Required: ${pe}`})),nt.warning(t("workOrders.detail.insufficientStock",{itemCode:Ct,available:je,required:pe}),{position:"top-right",autoClose:5e3,icon:e.jsx(fa,{}),toastId:`stock-warning-${Z}`})):_o(Pt=>{const ma=ue({},Pt);return delete ma[Z],ma})},Ul=(Z,pe)=>{const je=[...G.stock_items||[]],Ct=je[Z].valuation_rate||0,Jt=je[Z].custom_available_stock||0;je[Z]=Se(ue({},je[Z]),{consumed_quantity:pe,total_value:Ct*pe}),je[Z].item_code&&je[Z].warehouse&&al(Z,pe,Jt,je[Z].item_code,je[Z].warehouse),$e(Se(ue({},G),{stock_items:je}))},[t0,$c]=y.useState({});y.useEffect(()=>{const Z={};G.company&&(Z.company=G.company),$c(Z)},[G.company]);const Hc=Z=>Q(null,null,function*(){if(!Z)return null;try{Wt(!0);const pe=yield mt.apiCall(`/api/resource/Asset/${Z}`);return(pe==null?void 0:pe.data)||null}catch(pe){return console.error("Error fetching asset details:",pe),null}finally{Wt(!1)}}),wo=Z=>Q(null,null,function*(){if(!Z)return null;try{Wt(!0);const pe=yield mt.apiCall(`/api/resource/Asset?filters=[["custom_serial_number","=","${Z}"]]&fields=["name","asset_name","company","department","custom_serial_number","custom_asset_type","custom_manufacturer","supplier","custom_site_contractor","custom_subcontractor","custom_model","custom_service_agreement","custom_service_coverage","custom_start_date","custom_end_date","custom_total_amount","custom_site","location","custom_building","custom_room_number"]&limit=1`);return pe!=null&&pe.data&&pe.data.length>0?pe.data[0]:null}catch(pe){return console.error("Error fetching asset by serial number:",pe),null}finally{Wt(!1)}}),un=Z=>Z?Z.split(" ")[0]:"",$l=Z=>{Z&&$e(pe=>Se(ue({},pe),{asset:Z.name||pe.asset,asset_name:Z.asset_name||"",company:Z.company||"",department:Z.department||"",serial_number:Z.custom_serial_number||"",asset_type:Z.custom_asset_type||"",manufacturer:Z.custom_manufacturer||"",supplier:Z.supplier||"",custom_site_contractor:Z.custom_site_contractor||"",custom_subcontractor:Z.custom_subcontractor||"",model:Z.custom_model||"",site_name:Z.custom_site||"",custom_service_agreement:Z.custom_service_agreement||"",custom_service_coverage:Z.custom_service_coverage||"",custom_start_date:un(Z.custom_start_date)||"",custom_end_date:un(Z.custom_end_date)||"",custom_total_amount:Z.custom_total_amount||0,custom_location:Z.location||Z.custom_location||"",custom_building:Z.custom_building||"",custom_room_no:Z.custom_room_number||""}))},di=Z=>Q(null,null,function*(){if($e(pe=>Se(ue({},pe),{asset:Z})),Z){const pe=yield Hc(Z);pe&&$l(pe)}else $e(pe=>Se(ue({},pe),{asset:"",asset_name:"",serial_number:"",asset_type:"Non Biomedical",manufacturer:"",supplier:"",custom_site_contractor:"",custom_subcontractor:"",model:"",site_name:"",custom_service_agreement:"",custom_service_coverage:"",custom_start_date:"",custom_end_date:"",custom_total_amount:0,custom_building:"",custom_room_no:"",custom_location:""}))}),tn=()=>Q(null,null,function*(){if(!G.serial_number){nt.warning(t("workOrders.detail.pleaseEnterSerialNumberToSearch"),{position:"top-right",autoClose:3e3,icon:e.jsx(fa,{})});return}const Z=yield wo(G.serial_number);Z?($l(Z),nt.success(t("workOrders.detail.assetFound",{name:Z.asset_name||Z.name}),{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})})):nt.error(t("workOrders.detail.noAssetFoundWithSerialNumber"),{position:"top-right",autoClose:4e3,icon:e.jsx(ka,{})})}),rl=()=>Q(null,null,function*(){if(G.serial_number&&!G.asset){const Z=yield wo(G.serial_number);Z&&$l(Z)}}),Gi=Z=>Q(null,null,function*(){var Ct,Jt;const pe=(Ct=Z.target.files)==null?void 0:Ct[0];if(!pe)return;const je=10*1024*1024;if(pe.size>je){nt.error(t("workOrders.detail.fileSizeExceeds"),{position:"top-right",autoClose:4e3,icon:e.jsx(ka,{})});return}de(!0);try{const Pt=new FormData;Pt.append("file",pe),Pt.append("is_private","0"),Pt.append("folder","Home/Attachments"),!m&&a&&(Pt.append("doctype","Work_Order"),Pt.append("docname",a));const ma=ia.BASE_URL||"",Tr=yield(yield fetch(`${ma}/api/method/upload_file`,{method:"POST",credentials:"include",body:Pt})).json();if((Jt=Tr.message)!=null&&Jt.file_url)$e(Ba=>Se(ue({},Ba),{custom_attachment:Tr.message.file_url})),nt.success(t("workOrders.detail.fileUploadedSuccessfully"),{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})});else throw new Error("Upload failed")}catch(Pt){console.error("File upload error:",Pt),nt.error(t("workOrders.detail.failedToUploadFile"),{position:"top-right",autoClose:4e3,icon:e.jsx(ka,{})})}finally{de(!1),Z.target.value=""}}),a0=()=>{$e(Z=>Se(ue({},Z),{custom_attachment:""})),nt.info(t("workOrders.detail.attachmentRemoved"),{position:"top-right",autoClose:2e3})},ko=Z=>{if(!Z)return"";const pe=Z.split("/");return pe[pe.length-1]||Z};y.useEffect(()=>{if(m&&d&&!h){const Z={asset:s.get("asset")||"",asset_name:s.get("asset_name")||"",asset_type:s.get("asset_type")||"Non Biomedical",manufacturer:s.get("manufacturer")||"",supplier:s.get("supplier")||"",serial_number:s.get("serial_number")||"",department:s.get("department")||"",custom_site_contractor:s.get("site_contractor")||"",custom_subcontractor:s.get("subcontractor")||"",company:s.get("company")||"",site_name:s.get("site_name")||"",custom_building:s.get("building")||"",custom_room_no:s.get("room_no")||"",custom_location:s.get("location")||""};$e(pe=>Se(ue(ue({},pe),Z),{repair_status:"Open",workflow_state:"Draft",custom_priority_:"Normal",failure_date:Z0()}))}},[m,d,h,s]),y.useEffect(()=>{z&&!it&&!m&&!h&&(Ot(z.work_order_type||""),De(z.custom_assigned_supervisor||""),fe(z.custom_assigned_engineer||""),Ee(z.assigned_technician||""),xt(!0),console.log("Initial values stored:",{workOrderType:z.work_order_type,supervisor:z.custom_assigned_supervisor,engineer:z.custom_assigned_engineer,technician:z.assigned_technician}))},[z,it,m,h]),y.useEffect(()=>{var Z;z&&($t.current||ft((Z=z.custom_delete_status)!=null?Z:null),$t.current=!1,$e({company:z.company||"",work_order_type:z.work_order_type||"",asset:z.asset||"",asset_name:h?`${z.asset_name} (Copy)`:z.asset_name||"",description:z.description||"",repair_status:h?"Open":z.repair_status||"Open",workflow_state:h?"Draft":z.workflow_state||"Draft",department:z.department||"",custom_priority_:z.custom_priority_||"Normal",asset_type:z.asset_type||"Non Biomedical",custom_type:z.custom_type||"Corrective",manufacturer:z.manufacturer||"",supplier:z.supplier||"",serial_number:z.serial_number||"",model:z.model||"",custom_site_contractor:z.custom_site_contractor||"",custom_subcontractor:z.custom_subcontractor||"",failure_date:Nd(z.failure_date)||"",custom_deadline_date:un(z.custom_deadline_date)||"",first_responded_on:Nd(z.first_responded_on)||"",completion_date:Nd(z.completion_date)||"",actions_performed:z.actions_performed||"",stock_consumption:z.stock_consumption||0,stock_items:z.stock_items||[],site_name:z.site_name||"",need_procurement:z.need_procurement||0,custom_assign_to_contractor:z.custom_assign_to_contractor||"",assigned_technician:z.assigned_technician||"",custom_assigned_engineer:z.custom_assigned_engineer||"",custom_add_technicians:z.custom_add_technicians||"",docstatus:z.docstatus||0,custom_assigned_supervisor:z.custom_assigned_supervisor||"",total_hours_spent:z.total_hours_spent||0,custom_pending_reason:z.custom_pending_reason||"",total_repair_cost:z.total_repair_cost||0,custom_travel_hour:z.custom_travel_hour||"",custom_service_agreement:z.custom_service_agreement||"",custom_service_coverage:z.custom_service_coverage||"",custom_start_date:un(z.custom_start_date)||"",custom_end_date:un(z.custom_end_date)||"",custom_total_amount:z.custom_total_amount||0,custom_location:z.custom_location||"",custom_extension_no:z.custom_extension_no||"",custom_attachment:z.custom_attachment||"",custom_attachment_on_close:z.custom_attachment_on_close||"",inspection:z.inspection||"",custom_department_no:z.custom_department_no||"",custom_reason:z.custom_reason||"",custom_technical_department:z.custom_technical_department||"",custom_room_no:z.custom_room_no||"",custom_building:z.custom_building||"",custom_civil_work_category:z.custom_civil_work_category||""}))},[z,h]);const jr=Z=>{const{name:pe,value:je}=Z.target;$e(Ct=>Se(ue({},Ct),{[pe]:je}))},Hl=Z=>{const pe=Z.target.value;$e(je=>Se(ue({},je),{custom_priority_:pe}))},Wc=Z=>{const pe=Z.target.value;$e(je=>Se(ue({},je),{failure_date:pe}))},Wl=Z=>{const pe=Z.target.value;$e(je=>Se(ue({},je),{first_responded_on:pe}))},Yi=Z=>{const pe=Z.target.value;$e(je=>Se(ue({},je),{completion_date:pe}))},mn=()=>{const Z=Z0();$e(pe=>Se(ue({},pe),{failure_date:Z})),nt.info(t("workOrders.detail.failureDateSetToCurrentTime"),{position:"top-right",autoClose:2e3,icon:e.jsx(or,{})})},Zi=()=>{const Z=Z0();$e(pe=>Se(ue({},pe),{first_responded_on:Z})),nt.info(t("workOrders.detail.firstRespondedOnSetToCurrentTime"),{position:"top-right",autoClose:2e3,icon:e.jsx(or,{})})},r0=()=>{const Z=Z0();$e(pe=>Se(ue({},pe),{completion_date:Z})),nt.info(t("workOrders.detail.completionDateSetToCurrentTime"),{position:"top-right",autoClose:2e3,icon:e.jsx(or,{})})},jn=Z=>{Z===Dt&&Dt!==""?($e(pe=>Se(ue({},pe),{work_order_type:Z,custom_assigned_supervisor:Rt,custom_assigned_engineer:Qe,assigned_technician:re,custom_civil_work_category:Z==="Civil works-الأعمال المدنية"?pe.custom_civil_work_category:""})),console.log("Reverted to original work_order_type, restored values:",{supervisor:Rt,engineer:Qe,technician:re})):$e(pe=>Se(ue({},pe),{work_order_type:Z,custom_assigned_supervisor:"",custom_assigned_engineer:"",custom_assign_to_contractor:"",assigned_technician:"",custom_civil_work_category:Z==="Civil works-الأعمال المدنية"?pe.custom_civil_work_category:""}))},Vc=Z=>{$e(pe=>Se(ue({},pe),{custom_assigned_supervisor:Z}))},Ps=y.useMemo(()=>j.includes("Work Control")||j.includes("System Manager"),[j]),jo=()=>{if(Ps&&!m){if(!G.custom_assigned_supervisor)return nt.error(t("workOrders.detail.assignedSupervisorMandatory"),{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})}),!1;if(!G.custom_assigned_engineer)return nt.error(t("workOrders.detail.assignedEngineerMandatory"),{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})}),!1;if(Fs==="Sent to Engineer"&&!G.assigned_technician)return nt.error(t("workOrders.detail.assignedTechnicianMandatory"),{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})}),!1}return!0},No=()=>Q(null,null,function*(){if(a){aa(!0);try{yield Ht(a,{workflow_state:"Cancelled",docstatus:2,repair_status:"Cancelled"}),nt.success(t("workOrders.detail.workOrderCancelledSuccessfully"),{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),Ze(!1),gt(),setTimeout(()=>{Ms()},500)}catch(Z){const pe=Z instanceof Error?Z.message:"Unknown error";nt.error(t("workOrders.detail.failedToCancel",{error:pe}),{position:"top-right",autoClose:6e3,icon:e.jsx(ka,{})})}finally{aa(!1)}}}),So=()=>Q(null,null,function*(){if(a)try{yield mt.apiCall(`/api/resource/Work_Order/${a}`,{method:"DELETE"}),nt.success(t("workOrders.detail.workOrderDeletedSuccessfully"),{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),r(-1)}catch(Z){const pe=Z instanceof Error?Z.message:"Unknown error";nt.error(t("workOrders.detail.failedToDelete",{error:pe}),{position:"top-right",autoClose:6e3,icon:e.jsx(ka,{})})}}),Ji=Z=>Q(null,null,function*(){if(Z.preventDefault(),!G.work_order_type){nt.error(t("workOrders.detail.pleaseSelectWorkOrderType"),{position:"top-right",autoClose:4e3,icon:e.jsx(ka,{})});return}if(we&&!G.asset){nt.error("Asset is required based on your location selection. Please select an Asset.",{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})});return}if(!jo())return;const pe=Se(ue({},G),{failure_date:Sd(G.failure_date),first_responded_on:Sd(G.first_responded_on),completion_date:Sd(G.completion_date)});try{if(m||h){const je=yield St(pe),Ct=t(h?"workOrders.detail.workOrderDuplicatedSuccessfully":d?"workOrders.detail.workOrderCreatedFromAssetSuccessfully":"workOrders.detail.workOrderCreatedSuccessfully");nt.success(Ct,{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),r(`/work-orders/${je.name}`)}else a&&(yield Ht(a,pe),nt.success(t("workOrders.detail.workOrderUpdatedSuccessfully"),{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),Qt(!1),gt(),setTimeout(()=>{Ms()},500))}catch(je){console.error("Work order save error:",je);const Ct=je instanceof Error?je.message:"Unknown error",Jt=JSON.stringify(je);Ct.includes("TimestampMismatchError")||Ct.includes("Document has been modified")||Ct.includes("Please refresh")||Jt.includes("TimestampMismatchError")?(nt.error(t("workOrders.detail.documentModifiedByAnotherUser"),{position:"top-right",autoClose:4e3,icon:e.jsx(fa,{})}),yield gt(),nt.info(t("workOrders.detail.pleaseReviewLatestChanges"),{position:"top-right",autoClose:5e3,icon:e.jsx(Di,{})})):nt.error(t("workOrders.detail.failedToSaveWorkOrder",{error:Ct}),{position:"top-right",autoClose:6e3,icon:e.jsx(ka,{})})}});y.useEffect(()=>{m||fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({roles:"Maintenance Manager"})}).then(Z=>Z.json()).then(Z=>{var pe;(pe=Z.message)!=null&&pe.has_role&&b(!0)}).catch(Z=>console.error("Role check error:",Z))},[m]);const qc=Z=>Q(null,null,function*(){if(!a||m||!["Apply","Send For Repair"].includes(Z))return null;try{const je=yield mt.apiCall("/api/method/assign_supervisor_or_technician",{method:"POST",body:JSON.stringify({work_order:a,action:Z,asset_type:G.asset_type||(z==null?void 0:z.asset_type)||""})});return(je==null?void 0:je.message)||null}catch(je){return console.error("Error in before_workflow_action:",je),null}}),hn=(Z,pe)=>Q(null,null,function*(){if(["Reject","Cancel","Close"].includes(Z)&&(Vt==null?void 0:Vt.action)!==Z){va({action:Z,nextState:pe||""});return}if(va(null),Z==="Cancel"&&a){const Ba=xx();try{yield Ht(a,{completion_date:Ba}),$e(Br=>Se(ue({},Br),{completion_date:Nd(Ba)})),console.log("Auto-set completion_date on Cancel:",Ba)}catch(Br){console.error("Error setting completion_date on Cancel:",Br)}}const Ct=(z==null?void 0:z.workflow_state)||G.workflow_state||"Draft";if(Z==="Send to Supervisor"&&Ct==="Sent to Engineer"&&!(G.actions_performed||"").trim()){nt.dismiss(),setTimeout(()=>{nt.error(t("workOrders.detail.technicalReportMandatoryForSupervisor"),{position:"top-right",autoClose:8e3,hideProgressBar:!1,closeOnClick:!0,pauseOnHover:!0,draggable:!0,toastId:"technical-report-required",icon:e.jsx(fa,{})})},100);return}const Jt=nt.loading(t("workOrders.detail.applyingAction",{action:Z}),{position:"top-right"});yield gt();const Pt=yield qc(Z);Pt!=null&&Pt.assigned_to&&(nt.info(t("workOrders.detail.assignedTo",{name:Pt.assigned_to}),{position:"top-right",autoClose:4e3,icon:e.jsx(ea,{})}),yield gt());let ma=!1,xa=0;const Tr=3;for(;!ma&&xa<Tr;)try{ma=yield Fc(Z,pe);break}catch(Ba){const Br=(Ba==null?void 0:Ba.message)||String(Ba);if((Br.includes("TimestampMismatchError")||Br.includes("Document has been modified")||Br.includes("Please refresh"))&&xa<Tr-1)xa++,console.log(`Timestamp mismatch, retrying... (attempt ${xa})`),yield gt(),yield new Promise(as=>setTimeout(as,500));else throw Ba}if(nt.dismiss(Jt),ma)nt.success(t("workOrders.detail.actionCompletedSuccessfully",{action:Z}),{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),gt(),setTimeout(()=>Ms(),500);else{const Ba=vo||"Please try again.";Ba.includes("TimestampMismatchError")||Ba.includes("Document has been modified")||Ba.includes("Please refresh")?(nt.error(t("workOrders.detail.documentModifiedRefreshing"),{position:"top-right",autoClose:4e3,icon:e.jsx(fa,{})}),yield gt(),nt.info(t("workOrders.detail.tryActionAgainAfterReview"),{position:"top-right",autoClose:5e3,icon:e.jsx(Di,{})})):nt.error(t("workOrders.detail.failedToApplyAction",{action:Z,error:Ba}),{position:"top-right",autoClose:6e3,icon:e.jsx(ka,{})})}});if(Ne)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("workOrders.loadingDetails")})]})});if(Xe&&!m&&!h)return e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[e.jsxs("p",{className:"text-red-600 dark:text-red-400",children:[t("workOrders.detail.errorLabel"),": ",Xe]}),e.jsx("button",{onClick:()=>r(-1),className:"mt-2 text-red-700 dark:text-red-400 underline hover:text-red-800 dark:hover:text-red-300",children:t("workOrders.detail.backToList")})]})});const Xi=()=>t(h?"workOrders.detail.duplicateWorkOrder":d?"workOrders.detail.createFromAsset":m?"workOrders.detail.newWorkOrder":"workOrders.detail.workOrderDetails"),Nn=(z==null?void 0:z.workflow_state)||G.workflow_state||"Draft",Hn=Fl(Nn),sl=(Vn=(Co=z==null?void 0:z.docstatus)!=null?Co:G.docstatus)!=null?Vn:0,Fs=(z==null?void 0:z.workflow_state)||G.workflow_state||"Draft",s0=j.includes("Work Control"),Ki=j.includes("Contractor Engineer"),Wn=j.includes("Contractor Supervisor")&&!li,ts=m||li&&sl===0||p&&Fs==="Sent to Team Leader"||s0&&(Fs==="Draft"||Fs==="Sent to Work Control")&&sl===0||Ki&&Fs==="Sent to Engineer"&&sl===0||!dn&&ci.length>0,Qi=()=>{const Z=G.custom_priority_||"Normal";if(G.need_procurement===1)return`${Z} priority + Procurement: +30 days`;switch(Z){case"Urgent":return"Urgent priority: +1 day";case"Medium":return"Medium priority: +3 days";case"Normal":default:return"Normal priority: +5 days"}},nl=Z=>Z?Z.replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,pe=>pe.toUpperCase()):"",eo=Z=>Z==null||Z===""?"(empty)":Z===0?"0":Z===1?"1":typeof Z=="boolean"?Z?"Yes":"No":typeof Z=="object"?JSON.stringify(Z):String(Z),to=Z=>{if(!Z)return"";const pe=new Date(Z),je=new Date,Ct=je.getTime()-pe.getTime(),Jt=Math.floor(Ct/6e4),Pt=Math.floor(Ct/36e5),ma=Math.floor(Ct/864e5);return Jt<1?"Just now":Jt<60?`${Jt} min${Jt>1?"s":""} ago`:Pt<24?`${Pt} hour${Pt>1?"s":""} ago`:ma<7?`${ma} day${ma>1?"s":""} ago`:pe.toLocaleDateString("en-US",{month:"short",day:"numeric",year:pe.getFullYear()!==je.getFullYear()?"numeric":void 0,hour:"2-digit",minute:"2-digit"})},ji=Z=>{if(!Z)return"Unknown";const pe=Z.indexOf("@");return pe===-1?Z:Z.substring(0,pe)},ui=Z=>{const pe=Z.toLowerCase();return pe.includes("status")||pe.includes("state")?"text-purple-600 dark:text-purple-400":pe.includes("date")?"text-blue-600 dark:text-blue-400":pe.includes("technician")||pe.includes("supervisor")||pe.includes("assigned")?"text-green-600 dark:text-green-400":"text-gray-600 dark:text-gray-400"};return e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[e.jsx(Xd,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Lc}),I&&ae.length>0&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[9999]",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-lg w-full mx-4 shadow-xl",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(fa,{className:"text-orange-500 text-2xl mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:t("workOrders.detail.existingWorkOrderFound")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1 text-sm",children:t(M==="asset"?"workOrders.detail.workOrderExistsForAsset":"workOrders.detail.workOrderExistsForTypeAndRoom")})]})]}),e.jsxs("div",{className:"mb-4 max-h-48 overflow-y-auto",children:[e.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 mb-2",children:t("workOrders.detail.existingWorkOrders")}),e.jsx("div",{className:"space-y-2",children:ae.map(Z=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600",children:[e.jsxs("div",{children:[e.jsxs("a",{href:`/asm_app/work-orders/${Z.name}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 font-medium hover:underline flex items-center gap-1",children:[Z.name," ",e.jsx(vs,{size:10})]}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:[t("workOrders.detail.created"),": ",co(Z.creation)]})]}),e.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${Z.workflow_state==="Draft"?"bg-gray-100 text-gray-700":Z.workflow_state==="Repair InProgress"?"bg-blue-100 text-blue-700":"bg-purple-100 text-purple-700"}`,children:Z.workflow_state})]},Z.name))})]}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:t("workOrders.detail.proceedWithNewWO")}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:ii,className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg text-sm font-medium",children:t("common.cancel")}),e.jsxs("button",{onClick:yo,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-medium flex items-center gap-2",children:[e.jsx(ea,{size:14})," ",t("workOrders.detail.proceedAnyway")]})]})]})}),na&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(ei,{className:"text-orange-500 text-xl mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:t("workOrders.cancelWorkOrder")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:t("workOrders.cancelConfirmMessage")})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>Ze(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",disabled:lt,children:t("workOrders.detail.noGoBack")}),e.jsx("button",{onClick:No,disabled:lt,className:"px-4 py-2 bg-orange-600 hover:bg-orange-700 text-white rounded-lg disabled:opacity-50 flex items-center gap-2",children:lt?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin"}),t("workOrders.detail.cancelling")]}):e.jsxs(e.Fragment,{children:[e.jsx(ei,{}),t("workOrders.detail.yesCancel")]})})]})]})}),Ie&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(fa,{className:"text-red-500 text-xl mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:t("workOrders.deleteWorkOrder")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:t("workOrders.deleteConfirmMessage")})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>Nt(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:t("common.cancel")}),e.jsx("button",{onClick:So,disabled:Mt,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg disabled:opacity-50 flex items-center gap-2",children:Mt?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin"}),t("workOrders.detail.deleting")]}):e.jsxs(e.Fragment,{children:[e.jsx(Na,{}),t("common.delete")]})})]})]})}),T&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-lg w-full mx-4 shadow-xl max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white flex items-center gap-2",children:[e.jsx(js,{className:"text-blue-500"}),t("workOrders.detail.selectAdditionalTechnicians")]}),e.jsx("button",{onClick:()=>E(!1),className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded",children:e.jsx(wt,{size:18})})]}),e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(Js,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400",size:14}),e.jsx("input",{type:"text",placeholder:t("workOrders.detail.searchTechnicians"),value:U,onChange:Z=>J(Z.target.value),className:"w-full pl-10 pr-4 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})}),e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:t("workOrders.detail.techniciansSelected",{count:O.length})}),O.length>0&&e.jsx("button",{onClick:()=>R([]),className:"text-xs text-red-500 hover:text-red-700",children:t("workOrders.detail.clearAll")})]}),e.jsx("div",{className:"flex-1 overflow-y-auto border border-gray-200 dark:border-gray-700 rounded-lg",children:ne?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(ya,{className:"animate-spin text-blue-500 mr-2"}),e.jsx("span",{className:"text-sm text-gray-500",children:t("workOrders.detail.loadingTechnicians")})]}):Un.length===0?e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:e.jsx("p",{className:"text-sm",children:t(U?"workOrders.detail.noTechniciansMatchSearch":"workOrders.detail.noTechniciansFound")})}):e.jsx("div",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:Un.map(Z=>{const pe=O.includes(Z.name),je=G.assigned_technician===Z.name;return e.jsxs("label",{className:`flex items-center gap-3 p-3 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors ${pe?"bg-blue-50 dark:bg-blue-900/20":""} ${je?"opacity-50 cursor-not-allowed":""}`,children:[e.jsx("input",{type:"checkbox",checked:pe,onChange:()=>!je&&Ls(Z.name),disabled:je,className:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:bg-gray-700 dark:border-gray-600"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:Z.full_name||Z.name}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:Z.name})]}),je&&e.jsx("span",{className:"px-2 py-0.5 bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400 text-xs rounded",children:"Primary"}),pe&&!je&&e.jsx(ea,{className:"text-blue-500",size:16})]},Z.name)})})}),e.jsxs("div",{className:"flex justify-end gap-3 mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("button",{onClick:()=>E(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg text-sm",children:"Cancel"}),e.jsxs("button",{onClick:zn,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm flex items-center gap-2",children:[e.jsx(ea,{size:14}),t("workOrders.detail.saveSelection")," (",O.length,")"]})]})]})}),he&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[60]",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(js,{className:"text-blue-500 text-xl mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Confirm Technician Assignment"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1 text-sm",children:"Are you sure you want to assign this work order to the following technician(s)?"})]})]}),e.jsxs("div",{className:"mb-4 max-h-48 overflow-y-auto",children:[e.jsxs("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 mb-2",children:["Selected Technicians (",te.length,"):"]}),e.jsx("div",{className:"space-y-2",children:te.map(Z=>{const pe=Y.find(Jt=>Jt.name===Z),je=(pe==null?void 0:pe.full_name)||Z,Ct=Z;return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-200 dark:border-blue-800",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-200 dark:bg-blue-800 flex items-center justify-center flex-shrink-0",children:e.jsx(js,{className:"text-blue-600 dark:text-blue-400",size:12})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:je}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:Ct})]})]},Z)})})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("button",{onClick:Bn,className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg text-sm font-medium",children:t("common.cancel")}),e.jsxs("button",{onClick:Cr,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-medium flex items-center gap-2",children:[e.jsx(ea,{size:14}),t("workOrders.detail.confirmAssignment")]})]})]})}),Ya&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[9999]",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl p-6 max-w-lg w-full mx-4 shadow-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-gray-800 dark:text-white",children:ar==="give"?`⭐ ${t("workOrders.detail.giveFeedback")}`:ar==="edit"?`✏️ ${t("workOrders.detail.editFeedback")}`:`⭐ ${t("workOrders.detail.feedbackDetails")}`}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[t("workOrders.detail.workOrder")," ",e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:a})]})]}),e.jsx("button",{onClick:()=>gr(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:e.jsx(wt,{size:16})})]}),e.jsxs("div",{className:"mb-5 p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:t("workOrders.detail.feedbackBy")}),e.jsx("p",{className:"text-sm font-medium text-gray-800 dark:text-white",children:qr||C})]}),e.jsx("div",{className:"space-y-5 mb-6",children:kr.map((Z,pe)=>e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700/30 rounded-lg border border-gray-200 dark:border-gray-600",children:[e.jsx("label",{className:"block text-sm font-semibold text-gray-700 dark:text-gray-200 mb-2",children:Z.parameter}),e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[[1,2,3,4,5].map(je=>{const Ct=je*.2,Jt=Z.rating>=Ct,Pt=!Jt&&Z.rating>=Ct-.1,ma=ar==="view";return e.jsx("button",{type:"button",disabled:ma,onClick:()=>{ma||_r(pe,Ct)},className:`text-2xl transition-all duration-150 ${ma?"cursor-default":"cursor-pointer hover:scale-110"} ${Jt?"text-yellow-400":Pt?"text-yellow-300":"text-gray-300 dark:text-gray-500"}`,title:`${je} star${je>1?"s":""}`,children:"★"},je)}),e.jsx("span",{className:"ml-2 text-xs text-gray-500 dark:text-gray-400 font-medium",children:Z.rating>0?`${(Z.rating*5).toFixed(1)} / 5`:t("workOrders.detail.notRated")})]})]},Z.parameter))}),(ar==="view"||ar==="edit")&&(At==null?void 0:At.overall)>0&&e.jsxs("div",{className:"mb-5 p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg text-center",children:[e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mb-1 font-medium",children:t("workOrders.detail.overallSatisfaction")}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx("div",{className:"flex",children:[1,2,3,4,5].map(Z=>e.jsx("span",{className:`text-xl ${At.overall>=Z*.2?"text-yellow-400":"text-gray-300 dark:text-gray-500"}`,children:"★"},Z))}),e.jsxs("span",{className:"text-lg font-bold text-blue-700 dark:text-blue-300",children:[(At.overall*5).toFixed(1)," / 5"]})]})]}),(ar==="give"||ar==="edit")&&(()=>{const Z=Sr(kr);return Z<=0?null:e.jsxs("div",{className:"mb-5 p-4 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg text-center",children:[e.jsx("p",{className:"text-xs text-green-600 dark:text-green-400 mb-1 font-medium",children:t("workOrders.detail.overallRatingPreview")}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx("div",{className:"flex",children:[1,2,3,4,5].map(pe=>e.jsx("span",{className:`text-xl ${Z>=pe*.2?"text-yellow-400":"text-gray-300 dark:text-gray-500"}`,children:"★"},pe))}),e.jsxs("span",{className:"text-lg font-bold text-green-700 dark:text-green-300",children:[(Z*5).toFixed(1)," / 5"]})]})]})})(),e.jsx("div",{className:"flex justify-end gap-3 pt-4 border-t border-gray-200 dark:border-gray-700",children:ar==="view"?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>gr(!1),className:"px-4 py-2 bg-gray-200 hover:bg-gray-300 dark:bg-gray-600 dark:hover:bg-gray-500 text-gray-700 dark:text-gray-200 rounded-lg text-sm font-medium",children:t("listPages.close")}),wa&&e.jsxs("button",{onClick:Sa,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-medium flex items-center gap-2",children:[e.jsx(Fr,{size:12}),t("workOrders.detail.editRating")]})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{ar==="edit"?Ir("view"):gr(!1)},className:"px-4 py-2 bg-gray-200 hover:bg-gray-300 dark:bg-gray-600 dark:hover:bg-gray-500 text-gray-700 dark:text-gray-200 rounded-lg text-sm font-medium",disabled:ha,children:t("common.cancel")}),e.jsx("button",{onClick:ar==="edit"?oa:Yr,disabled:ha,className:"px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg text-sm font-medium flex items-center gap-2 disabled:opacity-50",children:ha?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin",size:12}),t(ar==="edit"?"workOrders.detail.updating":"workOrders.detail.submitting")]}):e.jsxs(e.Fragment,{children:[e.jsx(ea,{size:12}),t(ar==="edit"?"workOrders.detail.updateFeedback":"workOrders.detail.submitFeedback")]})})]})})]})}),e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("button",{onClick:()=>r(-1),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[e.jsx(en,{}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:Xi()})]}),!m&&e.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${Hn.bg} ${Hn.text} ${Hn.border} border`,children:(z==null?void 0:z.repair_status)||G.repair_status||"Open"}),d&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 bg-orange-100 dark:bg-orange-900/30 text-orange-700 dark:text-orange-300 rounded-full text-xs font-medium",children:[e.jsx(tx,{size:10}),t("workOrders.detail.linkedFromAsset")," ",c]}),zt&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded-full text-xs font-medium",children:[e.jsx(ya,{className:"animate-spin",size:12}),t("workOrders.detail.loadingAssetDetails")]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[!m&&e.jsxs("button",{onClick:g,className:"bg-purple-600 hover:bg-purple-700 text-white px-6 py-2 rounded-lg flex items-center gap-2",title:t("workOrders.detail.printServiceReport"),children:[e.jsx(Fi,{}),t("workOrders.detail.serviceReport")]}),!m&&!Te&&!Ds&&!xr&&ts&&!Wn&&N&&e.jsxs("button",{onClick:()=>{Qt(!0),nt.info(t("workOrders.detail.editModeEnabled"),{position:"top-right",autoClose:2e3,icon:e.jsx(Fr,{})})},className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg flex items-center gap-2",children:[e.jsx(Fr,{}),t("common.edit")]}),!m&&!Te&&(z==null?void 0:z.docstatus)===1&&sa&&e.jsxs("button",{onClick:()=>Ze(!0),className:"bg-orange-600 hover:bg-orange-700 text-white px-6 py-2 rounded-lg flex items-center gap-2",children:[e.jsx(ei,{}),t("common.cancel")]}),Te&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{m?r(-1):(Qt(!1),nt.info(t("workOrders.detail.editCancelledChangesDiscarded"),{position:"top-right",autoClose:2e3,icon:e.jsx(ka,{})}))},className:"bg-gray-300 hover:bg-gray-400 text-gray-700 px-6 py-2 rounded-lg",disabled:Mt,children:t("common.cancel")}),e.jsxs("button",{onClick:Ji,disabled:Mt||zt,className:"bg-green-600 hover:bg-green-700 text-white px-6 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[e.jsx(Or,{}),t(Mt?"common.saving":"common.saveChanges")]})]})]})]}),d&&m&&e.jsx("div",{className:"mb-6 bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(tx,{className:"text-orange-500 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-orange-800 dark:text-orange-300",children:t("workOrders.createFromAsset")}),e.jsxs("p",{className:"text-xs text-orange-700 dark:text-orange-400 mt-1",children:[t("workOrders.detail.assetInfoPrefilled")," ",e.jsx("strong",{children:G.asset_name||c}),".",t("assets.pleaseSelectWorkOrderType")]})]})]})}),e.jsx("form",{onSubmit:Ji,className:"space-y-6",style:{overflow:"visible"},children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6",style:{overflow:"visible"},children:[e.jsxs("div",{className:"lg:col-span-3 space-y-6",style:{overflow:"visible"},children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white",children:"Asset Information"}),d&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400 rounded text-[10px] font-medium",children:[e.jsx(tx,{size:8}),t("workOrders.detail.fromAsset")]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsx("div",{children:e.jsx(Ut,{label:t("workOrders.detail.hospital"),doctype:"Company",value:G.company||"",onChange:Z=>$e(Se(ue({},G),{company:Z,department:""})),disabled:!Te,filters:{domain:"Healthcare"}})}),e.jsxs("div",{className:"relative z-[50]",children:[e.jsx(Ut,{label:t("workOrders.detail.technicalDepartment"),doctype:"Issue Type",value:G.work_order_type||"",onChange:jn,disabled:!Te}),ve.length>0&&e.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:t("workOrders.detail.supervisorsAvailableForType",{count:ve.length})})]}),G.work_order_type==="Civil works-الأعمال المدنية"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t("workOrders.detail.civilWorkCategory")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("select",{name:"custom_civil_work_category",value:G.custom_civil_work_category||"",onChange:jr,disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("workOrders.detail.selectCivilWorkCategory")}),e.jsx("option",{value:"CARPENTARY",children:"CARPENTARY"}),e.jsx("option",{value:"MASONRY",children:"MASONRY"}),e.jsx("option",{value:"PAINTING",children:"PAINTING"}),e.jsx("option",{value:"PLUMPING",children:"PLUMPING"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("workOrders.detail.woType")}),e.jsx("select",{name:"custom_type",value:G.custom_type,onChange:Hl,disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:e.jsx("option",{value:"Corrective",children:"Corrective"})})]}),e.jsx("div",{className:"relative z-[40]",children:(()=>{const Z={docstatus:1};return G.company&&(Z.company=G.company),G.custom_building&&(Z.custom_building=G.custom_building),G.department&&(Z.department=G.department),G.custom_room_no&&(Z.custom_room_number=G.custom_room_no),e.jsxs(e.Fragment,{children:[e.jsx(Ut,{label:t("workOrders.detail.assetId"),doctype:"Asset",value:G.asset||"",onChange:di,disabled:!Te||zt||!!G.asset,filters:Z}),G.asset&&e.jsxs("div",{className:"flex items-center justify-between mt-1",children:[e.jsx("p",{className:"text-xs text-green-600 dark:text-green-400",children:"✓ Asset details auto-populated"}),Te&&e.jsx("button",{type:"button",onClick:()=>di(""),className:"text-xs text-red-500 hover:text-red-700 underline",children:"Clear Asset"})]}),we&&!G.asset&&e.jsxs("p",{className:"mt-1 text-xs text-red-500 flex items-center gap-1",children:[e.jsx(fa,{size:10}),"Asset is required based on your location selection"]}),!G.asset&&(G.custom_building||G.department||G.custom_room_no)&&!we&&ke>0&&e.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:[ke," asset(s) available for selected location"]})]})})()}),G.asset&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("workOrders.detail.assetName")}),e.jsx("input",{type:"text",name:"asset_name",value:G.asset_name,onChange:jr,disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsx("div",{children:e.jsx(Ut,{label:t("workOrders.detail.extensionNo"),doctype:"Extension Directory",value:G.custom_extension_no||"",onChange:Z=>$e(Se(ue({},G),{custom_extension_no:Z})),disabled:!Te,allowQuickCreate:!0})}),e.jsxs("div",{children:[e.jsx(Ut,{label:t("workOrders.detail.building"),doctype:"Building",value:G.custom_building||"",onChange:Bl,disabled:!Te,allowQuickCreate:!0}),!G.custom_building&&Te&&e.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:t("workOrders.detail.selectBuildingFirst")})]}),Vi()&&e.jsxs("div",{children:[e.jsx(Ut,{label:t("workOrders.detail.departmentName"),doctype:"Department",value:G.department||"",onChange:Bc,disabled:!Te,filters:Ge.length>0?{name:["in",Ge]}:t0,allowQuickCreate:!0}),G.custom_building&&Ge.length===0&&!rt&&e.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:"No departments mapped to this building"}),G.custom_building&&Ge.length>0&&e.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:[Ge.length," department(s) available for this building"]}),!G.department&&G.custom_building&&Te&&e.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:"Select Department to enable Room No"})]}),Ra()&&e.jsxs("div",{children:[e.jsx(Ut,{label:t("workOrders.detail.roomNo"),doctype:"Room",value:G.custom_room_no||"",onChange:Uc,disabled:!Te,query:"asset_lite.api.room_filter.get_filtered_rooms",filters:(()=>{const Z={};return G.custom_building&&(Z.building=G.custom_building),G.department&&(Z.department=G.department),Z})(),allowQuickCreate:!0}),rt&&e.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400 flex items-center gap-1",children:[e.jsx(ya,{className:"animate-spin",size:10}),"Loading..."]}),!rt&&(G.custom_building||G.department)&&It.length===0&&e.jsxs("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:["No rooms mapped to ",G.custom_building&&G.department?"this building + department":G.custom_building?"this building":"this department"]}),!rt&&(G.custom_building||G.department)&&It.length>0&&e.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:[It.length," room(s) available",G.custom_building&&!G.department&&" (filtered by building)",!G.custom_building&&G.department&&" (filtered by department)",G.custom_building&&G.department&&" (filtered by building + department)"]}),!G.custom_room_no&&G.department&&Te&&e.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:"Select Room No to enable Location"})]}),Pl()&&e.jsxs("div",{children:[e.jsx(Ut,{label:t("workOrders.detail.location"),doctype:"Location",value:G.custom_location||"",onChange:Z=>$e(Se(ue({},G),{custom_location:Z})),disabled:!Te,allowQuickCreate:!0}),rt&&e.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400 flex items-center gap-1",children:[e.jsx(ya,{className:"animate-spin",size:10}),"Loading location data..."]}),(G.custom_building||G.department)&&G.custom_room_no&&G.custom_location&&e.jsx("p",{className:"mt-1 text-xs text-green-600 dark:text-green-400",children:"✓ Location auto-set from Infrastructure mapping"})]}),G.inspection&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Inspection"}),e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-gray-100 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600",children:[e.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:G.inspection}),e.jsxs("button",{type:"button",onClick:()=>r(`/inspections/${G.inspection}`),className:"text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 flex items-center gap-1 text-sm",children:["View ",e.jsx(vs,{size:12})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Opening Attachment"}),G.custom_attachment?e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600",children:[e.jsx(mh,{className:"text-blue-500 flex-shrink-0",size:16}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("a",{href:`${ia.BASE_URL}${G.custom_attachment}`,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline truncate block",children:ko(G.custom_attachment)})}),Te&&e.jsx("button",{type:"button",onClick:a0,className:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors flex-shrink-0",title:t("workOrders.detail.removeAttachment"),children:e.jsx(wt,{size:12})})]}):Te?e.jsxs("label",{className:"flex items-center gap-2 px-3 py-2 bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 rounded-lg cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-900/30 transition-colors border border-blue-200 dark:border-blue-800 w-fit",children:[me?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin",size:14}),e.jsx("span",{className:"text-sm",children:t("workOrders.detail.uploading")})]}):e.jsxs(e.Fragment,{children:[e.jsx(gh,{size:14}),e.jsx("span",{className:"text-sm",children:t("workOrders.detail.uploadOpeningFile")})]}),e.jsx("input",{type:"file",onChange:Gi,disabled:me,className:"hidden",accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.txt"})]}):e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 italic",children:t("workOrders.detail.noAttachment")})]}),["Pending Approval","Approved","Rejected","Closed"].includes(Nn)&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("workOrders.detail.closingAttachment")}),G.custom_attachment_on_close?e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600",children:[e.jsx(mh,{className:"text-green-500 flex-shrink-0",size:16}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("a",{href:`${ia.BASE_URL}${G.custom_attachment_on_close}`,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline truncate block",children:ko(G.custom_attachment_on_close)})}),Te&&e.jsx("button",{type:"button",onClick:()=>{$e(Z=>Se(ue({},Z),{custom_attachment_on_close:""})),nt.info(t("workOrders.detail.closingAttachmentRemoved"),{position:"top-right",autoClose:2e3})},className:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors flex-shrink-0",title:t("workOrders.detail.removeClosingAttachment"),children:e.jsx(wt,{size:12})})]}):Te?e.jsxs("label",{className:"flex items-center gap-2 px-3 py-2 bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400 rounded-lg cursor-pointer hover:bg-green-100 dark:hover:bg-green-900/30 transition-colors border border-green-200 dark:border-green-800 w-fit",children:[me?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin",size:14}),e.jsx("span",{className:"text-sm",children:t("workOrders.detail.uploading")})]}):e.jsxs(e.Fragment,{children:[e.jsx(gh,{size:14}),e.jsx("span",{className:"text-sm",children:t("workOrders.detail.uploadClosingFile")})]}),e.jsx("input",{type:"file",onChange:Z=>Q(null,null,function*(){var Ct,Jt;const pe=(Ct=Z.target.files)==null?void 0:Ct[0];if(!pe)return;const je=10*1024*1024;if(pe.size>je){nt.error(t("workOrders.detail.fileSizeExceeds"),{position:"top-right",autoClose:4e3,icon:e.jsx(ka,{})});return}de(!0);try{const Pt=new FormData;Pt.append("file",pe),Pt.append("is_private","0"),Pt.append("folder","Home/Attachments"),!m&&a&&(Pt.append("doctype","Work_Order"),Pt.append("docname",a));const ma=ia.BASE_URL||"",Tr=yield(yield fetch(`${ma}/api/method/upload_file`,{method:"POST",credentials:"include",body:Pt})).json();if((Jt=Tr.message)!=null&&Jt.file_url)$e(Ba=>Se(ue({},Ba),{custom_attachment_on_close:Tr.message.file_url})),nt.success(t("workOrders.detail.closingAttachmentUploadedSuccessfully"),{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})});else throw new Error("Upload failed")}catch(Pt){console.error("File upload error:",Pt),nt.error(t("workOrders.detail.failedToUploadClosingAttachment"),{position:"top-right",autoClose:4e3,icon:e.jsx(ka,{})})}finally{de(!1),Z.target.value=""}}),disabled:me,className:"hidden",accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.txt"})]}):e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 italic",children:t("workOrders.detail.noClosingAttachment")})]}),!Bt&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative z-[40]",children:[e.jsx(Ut,{label:t("workOrders.detail.assetId"),doctype:"Asset",value:G.asset||"",onChange:di,disabled:!Te||zt,filters:G.company?{company:G.company}:{}}),G.asset&&e.jsx("p",{className:"mt-1 text-xs text-green-600 dark:text-green-400",children:"✓ Asset details auto-populated"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Serial Number"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",name:"serial_number",value:G.serial_number,onChange:jr,onBlur:rl,disabled:!Te||zt,placeholder:t("workOrders.detail.enterSerialNumber"),className:"flex-1 px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),Te&&e.jsx("button",{type:"button",onClick:tn,disabled:zt||!G.serial_number,className:"px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md disabled:opacity-50 disabled:cursor-not-allowed",title:t("workOrders.detail.searchAssetBySerial"),children:e.jsx(Js,{size:14})})]})]}),G.asset&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("workOrders.detail.assetName")}),e.jsx("input",{type:"text",name:"asset_name",value:G.asset_name,onChange:jr,disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsx("div",{children:e.jsx(Ut,{label:t("workOrders.detail.manufacturer"),doctype:"Manufacturer",value:G.manufacturer||"",onChange:Z=>$e(Se(ue({},G),{manufacturer:Z})),disabled:!Te})}),e.jsx("div",{children:e.jsx(Ut,{label:t("workOrders.detail.supplier"),doctype:"Supplier",value:G.supplier||"",onChange:Z=>$e(Se(ue({},G),{supplier:Z})),disabled:!Te})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("workOrders.detail.model")}),e.jsx("input",{type:"text",name:"model",value:G.model,onChange:jr,disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:t("workOrders.detail.workOrderInformation")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("workOrders.detail.workOrderId")}),e.jsx("input",{type:"text",value:m||h?t("workOrders.detail.autoGenerated"):z==null?void 0:z.name,disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("workOrders.detail.priority")}),e.jsxs("select",{name:"custom_priority_",value:G.custom_priority_,onChange:Hl,disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"Normal",children:"Normal"}),e.jsx("option",{value:"Medium",children:"Medium"}),e.jsx("option",{value:"Urgent",children:"Urgent"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("commonFields.status")}),e.jsx("input",{type:"text",value:G.repair_status,disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("workOrders.detail.pendingReason")}),e.jsxs("select",{name:"custom_pending_reason",value:G.custom_pending_reason||"",onChange:Z=>{const pe=Z.target.value;$e(je=>Se(ue({},je),{custom_pending_reason:pe,custom_reason:pe==="Other"?je.custom_reason:""}))},disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("workOrders.detail.selectPendingReason")}),e.jsx("option",{value:"Need Part",children:"Need Part"}),e.jsx("option",{value:"Waiting For Quotation",children:"Waiting For Quotation"}),e.jsx("option",{value:"Waiting For PO",children:"Waiting For PO"}),e.jsx("option",{value:"Waiting For Part Delivery",children:"Waiting For Part Delivery"}),e.jsx("option",{value:"Other",children:"Other"})]})]}),G.custom_pending_reason==="Other"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t("workOrders.detail.otherReason")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",name:"custom_reason",value:G.custom_reason||"",onChange:jr,disabled:!Te,placeholder:t("workOrders.detail.pleaseSpecifyReason"),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]}),!Bt&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:t("workOrders.detail.serviceAgreementDetails")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("workOrders.detail.siteContractor")}),e.jsx("input",{type:"text",name:"custom_site_contractor",value:G.custom_site_contractor,onChange:jr,disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("workOrders.detail.subcontractor")}),e.jsx("input",{type:"text",name:"custom_subcontractor",value:G.custom_subcontractor,onChange:jr,disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Service Agreement"}),e.jsxs("select",{name:"custom_service_agreement",value:G.custom_service_agreement||"",onChange:jr,disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("workOrders.detail.selectServiceAgreement")}),e.jsx("option",{value:"Warranty",children:"Warranty"}),e.jsx("option",{value:"Contract",children:"Contract"}),e.jsx("option",{value:"Frame Work",children:"Frame Work"}),e.jsx("option",{value:"Main Contractor",children:"Main Contractor"}),e.jsx("option",{value:"Out of warranty",children:"Out of warranty"}),e.jsx("option",{value:"Under Dismantle",children:"Under Dismantle"}),e.jsx("option",{value:"Under Installation",children:"Under Installation"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Service Coverage"}),e.jsxs("select",{name:"custom_service_coverage",value:G.custom_service_coverage||"",onChange:jr,disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("workOrders.detail.selectServiceCoverage")}),e.jsx("option",{value:"PM Only",children:"PM Only"}),e.jsx("option",{value:"Labour",children:"Labour"}),e.jsx("option",{value:"Labour & Parts",children:"Labour & Parts"}),e.jsx("option",{value:"Comprehensive",children:"Comprehensive"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("filters.startDate")}),e.jsx("input",{type:"date",name:"custom_start_date",value:G.custom_start_date||"",onChange:jr,disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("filters.endDate")}),e.jsx("input",{type:"date",name:"custom_end_date",value:G.custom_end_date||"",onChange:jr,disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("assets.detail.totalAmount")}),e.jsx("input",{type:"number",name:"custom_total_amount",min:"0",step:"0.01",value:G.custom_total_amount||0,onChange:jr,disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:t("workOrders.detail.description")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("workOrders.detail.natureOfComplaint")}),e.jsx("textarea",{name:"description",value:G.description,onChange:jr,disabled:!Te||!m&&!(Nn==="Draft"&&C===(z==null?void 0:z.owner)),placeholder:t("workOrders.detail.describeComplaint"),rows:4,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("workOrders.detail.technicalReport")}),e.jsx("textarea",{name:"actions_performed",value:G.actions_performed,onChange:jr,disabled:!Te,placeholder:t("workOrders.detail.describeWorkPerformed"),rows:4,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white resize-none"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:t("workOrders.detail.assignments")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(Ut,{label:t("workOrders.detail.assignedSupervisor"),doctype:"User",value:G.custom_assigned_supervisor||"",onChange:Vc,disabled:!Te,filters:ve.length>0?{name:["in",ve]}:{}}),!G.work_order_type&&Te&&e.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:t("workOrders.detail.selectWoTypeFirstForSupervisors")}),G.work_order_type&&ve.length===0&&Te&&e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:t("workOrders.detail.noSupervisorsFound")}),!m&&Ps&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:t("workOrders.detail.requiredForExistingWO")})]}),e.jsxs("div",{children:[e.jsx(Ut,{label:t("workOrders.detail.assignedEngineer"),doctype:"User",value:G.custom_assigned_engineer||"",onChange:Z=>$e(Se(ue({},G),{custom_assigned_engineer:Z})),disabled:!Te,filters:Be.length>0?{name:["in",Be]}:{}}),!G.work_order_type&&Te&&e.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:t("workOrders.detail.selectWoTypeFirstForEngineers")}),G.work_order_type&&Be.length===0&&Te&&e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:t("workOrders.detail.noEngineersFound")}),Be.length>0&&e.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:t("workOrders.detail.engineersAvailable",{count:Be.length})}),!m&&Ps&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:t("workOrders.detail.requiredForExistingWO")})]}),e.jsxs("div",{children:[e.jsx(Ut,{label:t("workOrders.detail.assignedTechnician"),doctype:"User",value:G.assigned_technician||"",onChange:Z=>$e(Se(ue({},G),{assigned_technician:Z})),disabled:!Te,filters:ht.length>0?{name:["in",ht]}:{}}),!G.work_order_type&&Te&&e.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:t("workOrders.detail.selectWoTypeFirstForTechnicians")}),G.work_order_type&&ht.length===0&&Te&&e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:t("workOrders.detail.noTechniciansFoundForType")}),ht.length>0&&e.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:t("workOrders.detail.techniciansAvailable",{count:ht.length})}),!m&&Ps&&Nn==="Sent to Engineer"&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:t("workOrders.detail.requiredForSentToEngineer")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Failure Date & Time"}),e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.jsx("input",{type:"datetime-local",name:"failure_date",value:G.failure_date,onChange:Wc,disabled:!Te,className:"flex-1 min-w-0 px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),Te&&e.jsxs("button",{type:"button",onClick:mn,className:"flex-shrink-0 px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-xs flex items-center gap-1",title:"Set to current date & time",children:[e.jsx(or,{size:12}),"Now"]})]}),G.failure_date&&e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:co(Sd(G.failure_date))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Deadline Date",e.jsx("span",{className:"ml-1 text-xs text-gray-400",children:t("workOrders.detail.autoCalculated")})]}),e.jsx("input",{type:"date",name:"custom_deadline_date",value:G.custom_deadline_date,onChange:jr,disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),Te&&G.failure_date&&e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:Qi()})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Total Hours Spent"}),e.jsx("input",{type:"number",name:"total_hours_spent",min:"0",step:"0.5",value:G.total_hours_spent||0,onChange:jr,disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["First Responded On",e.jsx("span",{className:"ml-1 text-xs text-gray-400",children:t("workOrders.detail.autoSetOnRepairStart")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.jsx("input",{type:"datetime-local",name:"first_responded_on",value:G.first_responded_on,onChange:Wl,disabled:!Te,className:"flex-1 min-w-0 px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),Te&&e.jsxs("button",{type:"button",onClick:Zi,className:"flex-shrink-0 px-3 py-2 bg-green-600 hover:bg-green-700 text-white rounded-md text-xs flex items-center gap-1",title:"Set to current date & time",children:[e.jsx(or,{size:12}),"Now"]})]}),G.first_responded_on&&e.jsxs("p",{className:"mt-1 text-xs text-green-600 dark:text-green-400",children:["✓ ",co(Sd(G.first_responded_on))]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Completion Date & Time",e.jsx("span",{className:"ml-1 text-xs text-gray-400",children:t("workOrders.detail.autoSetOnClose")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.jsx("input",{type:"datetime-local",name:"completion_date",value:G.completion_date,onChange:Yi,disabled:!Te,className:"flex-1 min-w-0 px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),Te&&e.jsxs("button",{type:"button",onClick:r0,className:"flex-shrink-0 px-3 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-md text-xs flex items-center gap-1",title:"Set to current date & time",children:[e.jsx(or,{size:12}),"Now"]})]}),G.completion_date&&e.jsxs("p",{className:"mt-1 text-xs text-purple-600 dark:text-purple-400",children:["✓ ",co(Sd(G.completion_date))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Total Travel Hours"}),e.jsx("input",{type:"text",name:"custom_travel_hour",value:G.custom_travel_hour,onChange:jr,disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700 relative z-20",style:{overflow:"visible"},children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Stock Consumption Details"}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:G.stock_consumption===1,onChange:Z=>{var pe;$e(Se(ue({},G),{stock_consumption:Z.target.checked?1:0,stock_items:Z.target.checked?(pe=G.stock_items)!=null&&pe.length?G.stock_items:[{item_code:"",warehouse:fs,consumed_quantity:1,valuation_rate:0,custom_available_stock:0,total_value:0}]:[]}))},disabled:!Te,className:"w-5 h-5 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600 disabled:opacity-50"}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Parts Consumed"})]}),e.jsx("p",{className:"mt-1 ml-8 text-xs text-gray-500 dark:text-gray-400",children:"Check this if spare parts or items were used during the repair"})]}),G.stock_consumption===1&&e.jsxs("div",{className:"mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Stock Items"}),Te&&e.jsxs("button",{type:"button",onClick:()=>{$e(Se(ue({},G),{stock_items:[...G.stock_items||[],{item_code:"",warehouse:fs,consumed_quantity:1,valuation_rate:0,custom_available_stock:0,total_value:0}]})),nt.info(t("workOrders.detail.newStockItemRowAdded"),{position:"top-right",autoClose:2e3,icon:e.jsx(Zs,{})})},className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-white bg-green-600 hover:bg-green-700 rounded-md transition-colors",children:[e.jsx(Zs,{size:10}),t("workOrders.detail.addItem")]})]}),e.jsx("div",{className:"stock-items-table-wrapper",children:e.jsx("div",{className:"stock-items-scroll-container",children:e.jsxs("table",{className:"w-full text-sm border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-10",children:"#"}),e.jsxs("th",{className:"px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider min-w-[180px]",children:[t("workOrders.detail.item")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("th",{className:"px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-28",children:t("workOrders.detail.valuationRate")}),e.jsxs("th",{className:"px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider min-w-[180px]",children:[t("workOrders.detail.warehouse")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("th",{className:"px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-24",children:t("workOrders.detail.consumedQty")}),e.jsx("th",{className:"px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-28",children:t("workOrders.detail.availableStock")}),e.jsx("th",{className:"px-3 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-28",children:t("workOrders.detail.totalValue")}),Te&&e.jsx("th",{className:"px-3 py-3 text-center text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-16",children:t("workOrders.detail.action")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:(G.stock_items||[]).length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:Te?8:7,className:"px-4 py-8 text-center text-gray-500 dark:text-gray-400",children:[e.jsx("p",{children:t("workOrders.detail.noItemsAddedYet")}),Te&&e.jsx("button",{type:"button",onClick:()=>{$e(Se(ue({},G),{stock_items:[{item_code:"",warehouse:fs,consumed_quantity:1,valuation_rate:0,custom_available_stock:0,total_value:0}]}))},className:"mt-2 text-blue-600 dark:text-blue-400 hover:underline text-sm",children:t("workOrders.detail.addFirstItem")})]})}):(G.stock_items||[]).map((Z,pe)=>e.jsxs(pa.Fragment,{children:[e.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 ${tl[pe]?"bg-red-50 dark:bg-red-900/20":""}`,children:[e.jsx("td",{className:"px-3 py-3 text-gray-500 dark:text-gray-400",children:pe+1}),e.jsx("td",{className:"px-3 py-3 relative",style:{zIndex:50-pe},children:e.jsx("div",{className:"relative",children:e.jsx(Ut,{label:"",doctype:"Item",value:Z.item_code,onChange:je=>zl(pe,je),disabled:!Te,placeholder:t("workOrders.detail.selectItem"),compact:!0,usePortal:!0,filters:ue(ue({is_stock_item:1},G.company?{custom_hospital_name:G.company}:{}),G.work_order_type?{custom_technical_department:G.work_order_type}:{})})})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("input",{type:"number",min:"0",step:"0.01",value:Z.valuation_rate||0,onChange:je=>{const Ct=[...G.stock_items||[]],Jt=parseFloat(je.target.value)||0,Pt=Ct[pe].consumed_quantity||0;Ct[pe]=Se(ue({},Ct[pe]),{valuation_rate:Jt,total_value:Jt*Pt}),$e(Se(ue({},G),{stock_items:Ct}))},disabled:!Te,className:"w-full px-2 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})}),e.jsx("td",{className:"px-3 py-3 relative",style:{zIndex:50-pe},children:e.jsx("div",{className:"relative",children:e.jsx(Ut,{label:"",doctype:"Warehouse",value:Z.warehouse,onChange:je=>e0(pe,je),disabled:!Te,placeholder:t("workOrders.detail.selectWarehouse"),compact:!0,usePortal:!0})})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("input",{type:"number",min:"1",value:Z.consumed_quantity||1,onChange:je=>Ul(pe,parseInt(je.target.value)||1),disabled:!Te,className:`w-full px-2 py-1.5 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white ${tl[pe]?"border-red-500 dark:border-red-500":"border-gray-300 dark:border-gray-600"}`})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("input",{type:"number",min:"0",value:Z.custom_available_stock||0,disabled:!0,className:"w-full px-2 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300",title:t("workOrders.detail.autoPopulatedFromStock")})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("input",{type:"number",min:"0",step:"0.01",value:Z.total_value||0,disabled:!0,className:"w-full px-2 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300"})}),Te&&e.jsx("td",{className:"px-3 py-3 text-center",children:e.jsx("button",{type:"button",onClick:()=>{var Jt;const je=(Jt=G.stock_items)==null?void 0:Jt[pe],Ct=(G.stock_items||[]).filter((Pt,ma)=>ma!==pe);$e(Se(ue({},G),{stock_items:Ct})),_o(Pt=>{const ma=ue({},Pt);return delete ma[pe],ma}),nt.warning(t("workOrders.detail.stockItemRemoved",{item:(je==null?void 0:je.item_code)||"row"}),{position:"top-right",autoClose:2e3,icon:e.jsx(Na,{})})},className:"p-1.5 text-red-500 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors",title:t("workOrders.detail.removeItem"),children:e.jsx(Na,{size:14})})})]}),tl[pe]&&e.jsx("tr",{className:"bg-red-50 dark:bg-red-900/30",children:e.jsx("td",{colSpan:Te?8:7,className:"px-4 py-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-red-600 dark:text-red-400 text-xs",children:[e.jsx(fa,{}),e.jsx("span",{children:tl[pe]})]})})})]},pe))})]})})}),(G.stock_items||[]).length>0&&e.jsxs("div",{className:"mt-3 flex flex-wrap justify-between items-center gap-4 text-sm bg-gray-50 dark:bg-gray-700/50 p-3 rounded-lg",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[t("workOrders.detail.totalItems")," ",e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:(G.stock_items||[]).length})]}),e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["Total Qty: ",e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:(G.stock_items||[]).reduce((Z,pe)=>Z+(Number(pe.consumed_quantity)||0),0)})]}),e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["Total Value: ",e.jsx("span",{className:"font-semibold text-green-600 dark:text-green-400",children:(G.stock_items||[]).reduce((Z,pe)=>Z+(Number(pe.total_value)||0),0).toFixed(2)})]})]})]}),e.jsx("div",{className:"mt-6 pt-4 border-t border-gray-200 dark:border-gray-700",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Total Repair Cost"}),e.jsx("input",{type:"number",name:"total_repair_cost",min:"0",step:"0.01",value:G.total_repair_cost||0,onChange:jr,disabled:!Te,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})})})]}),!m&&e.jsx(Pc,{referenceDoctype:"Work_Order",referenceName:a||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5,collapsible:!0,startCollapsed:!1})]}),e.jsxs("div",{className:"space-y-6",children:[!m&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"flex items-center justify-between mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white",children:"Workflow Actions"})}),e.jsxs("div",{className:`p-4 rounded-lg border mb-4 ${Hn.bg} ${Hn.border}`,children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:t("workOrders.detail.currentState")}),e.jsx("p",{className:`text-lg font-semibold ${Hn.text}`,children:Nn})]}),dn&&e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400 mb-4",children:[e.jsx(ya,{className:"animate-spin"}),e.jsx("span",{className:"text-sm",children:t("workOrders.detail.loadingActions")})]}),vo&&e.jsx("div",{className:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg mb-4",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(fa,{className:"text-red-500 mt-0.5"}),e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:vo})]})}),Vt&&e.jsxs("div",{className:"p-4 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg mb-4",children:[e.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[e.jsx(fa,{className:"text-yellow-500 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-yellow-800 dark:text-yellow-200",children:t("workOrders.detail.confirmAction")}),e.jsx("p",{className:"text-xs text-yellow-600 dark:text-yellow-400 mt-1",children:t("workOrders.detail.confirmActionMessage",{action:Vt.action})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>hn(Vt.action,Vt.nextState),disabled:qi,className:"px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white text-sm rounded-md disabled:opacity-50",children:qi?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ya,{className:"animate-spin",size:12}),t("workOrders.detail.processing")]}):t("workOrders.detail.yesAction",{action:Vt.action})}),e.jsx("button",{onClick:()=>va(null),disabled:qi,className:"px-3 py-1.5 bg-gray-300 hover:bg-gray-400 text-gray-700 text-sm rounded-md disabled:opacity-50",children:t("common.cancel")})]})]}),!dn&&ci.length>0&&!Vt&&e.jsxs("div",{className:"space-y-3",children:[li&&e.jsx("div",{className:"p-2 bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg mb-2",children:e.jsx("p",{className:"text-xs text-purple-700 dark:text-purple-300",children:t("workOrders.detail.systemManagerNote")})}),Te&&ci.some(Z=>Z.action!=="Apply")&&e.jsx("div",{className:"p-2 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg mb-2",children:e.jsxs("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:[e.jsx(Di,{className:"inline mr-1",size:10}),t("workOrders.detail.saveToSeeActions")]})}),(()=>{const Z=Te?ci.filter(pe=>pe.action==="Apply"):ci;return Z.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 flex items-center gap-1",children:[e.jsx(Di,{size:12}),t("workOrders.detail.availableActions")," (",Z.length,")"]}),e.jsx("div",{className:"flex flex-col gap-2",children:Z.map((pe,je)=>e.jsxs("button",{onClick:()=>hn(pe.action,pe.next_state),disabled:qi,className:`w-full px-4 py-2.5 rounded-lg text-sm font-medium transition-colors disabled:opacity-50 flex items-center justify-center gap-2 ${Qd(pe.action)}`,children:[qi?e.jsx(ya,{className:"animate-spin",size:14}):e.jsx("span",{children:Il(pe.action)}),pe.action]},`${pe.action}-${pe.next_state}-${je}`))})]})})(),(()=>{const Z=Te?ci.filter(pe=>pe.action==="Apply"):ci;return Z.length===0?null:e.jsxs("div",{className:"mt-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:t("workOrders.detail.actionResults")}),Z.map((pe,je)=>e.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-300",children:[pe.action," → ",e.jsx("span",{className:"font-medium",children:pe.next_state})]},je))]})})()]}),!m&&!dn&&Nn==="Sent to Engineer"&&(()=>{const Z=!!(G.assigned_technician||z!=null&&z.assigned_technician),pe=!!(G.actions_performed||(z==null?void 0:z.actions_performed)||"").trim();return Z&&pe?e.jsx("div",{className:"p-4 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg mb-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ea,{className:"text-green-500 mt-0.5 flex-shrink-0",size:18}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-green-800 dark:text-green-200 mb-1",children:t("workOrders.detail.allOptionsAvailable")}),e.jsx("p",{className:"text-xs text-green-600 dark:text-green-400",children:t("workOrders.detail.bothFilledMessage")})]})]})}):Z&&!pe?e.jsx("div",{className:"p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg mb-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Di,{className:"text-blue-500 mt-0.5 flex-shrink-0",size:18}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-blue-800 dark:text-blue-200 mb-2",children:t("workOrders.detail.technicianAssigned")}),e.jsx("div",{className:"mb-3 p-2 bg-green-100 dark:bg-green-900/30 rounded border border-green-200 dark:border-green-700",children:e.jsxs("p",{className:"text-xs text-green-700 dark:text-green-300 flex items-start gap-1",children:[e.jsx(ea,{size:10,className:"mt-0.5 flex-shrink-0"}),e.jsxs("span",{className:"min-w-0",children:[t("workOrders.detail.assignedTechnicianLabel")," ",e.jsx("strong",{className:"break-all",children:G.assigned_technician||(z==null?void 0:z.assigned_technician)})]})]})}),e.jsxs("div",{className:"p-2 bg-white dark:bg-gray-800 rounded border border-blue-100 dark:border-blue-700",children:[e.jsx("p",{className:"text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("workOrders.detail.wantToEnableSendToSupervisor")}),e.jsxs("p",{className:"text-xs text-orange-600 dark:text-orange-400 flex items-start gap-1",children:[e.jsx(fa,{size:10,className:"mt-0.5 flex-shrink-0"}),e.jsx("span",{children:t("workOrders.detail.fillTechnicalReportToUnlock")})]})]})]})]})}):!Z&&pe?e.jsx("div",{className:"p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg mb-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Di,{className:"text-blue-500 mt-0.5 flex-shrink-0",size:18}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-blue-800 dark:text-blue-200 mb-2",children:t("workOrders.detail.technicalReportFilled")}),e.jsx("div",{className:"mb-3 p-2 bg-green-100 dark:bg-green-900/30 rounded border border-green-200 dark:border-green-700",children:e.jsxs("p",{className:"text-xs text-green-700 dark:text-green-300 flex items-center gap-1",children:[e.jsx(ea,{size:10}),'"Send to Supervisor" button is now available above']})}),e.jsxs("div",{className:"p-2 bg-white dark:bg-gray-800 rounded border border-blue-100 dark:border-blue-700",children:[e.jsx("p",{className:"text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Want more workflow options?"}),e.jsxs("p",{className:"text-xs text-orange-600 dark:text-orange-400 flex items-center gap-1",children:[e.jsx(fa,{size:10}),'Assign a "Technician" to enable technician workflow actions']})]})]})]})}):e.jsx("div",{className:"p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg mb-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Di,{className:"text-blue-500 mt-0.5 flex-shrink-0",size:18}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-blue-800 dark:text-blue-200 mb-2",children:"Choose Your Path"}),e.jsxs("div",{className:"mb-3 p-2 bg-white dark:bg-gray-800 rounded border border-blue-100 dark:border-blue-700",children:[e.jsx("p",{className:"text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Option 1: Assign to Technician"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:'Edit the form → Fill "Assigned Technician" → Save → Proceed with technician workflow'})]}),e.jsxs("div",{className:"p-2 bg-white dark:bg-gray-800 rounded border border-blue-100 dark:border-blue-700",children:[e.jsx("p",{className:"text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Option 2: Send Directly to Supervisor"}),e.jsxs("p",{className:"text-xs text-orange-600 dark:text-orange-400 flex items-center gap-1",children:[e.jsx(fa,{size:10}),'Fill "Technical Report" field to enable "Send to Supervisor" button']})]})]})]})})})(),!m&&!dn&&Nn==="Repair InProgress"&&(j.includes("Technician")||j.includes("Contractor Engineer"))&&((G.actions_performed||(z==null?void 0:z.actions_performed)||"").trim()?e.jsx("div",{className:"p-4 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg mb-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ea,{className:"text-green-500 mt-0.5 flex-shrink-0",size:18}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-green-800 dark:text-green-200 mb-1",children:"Ready for Approval"}),e.jsx("p",{className:"text-xs text-green-600 dark:text-green-400",children:'Technical Report is filled. You can now use "Send For Approval" action.'})]})]})}):e.jsx("div",{className:"p-4 bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg mb-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(fa,{className:"text-orange-500 mt-0.5 flex-shrink-0",size:18}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-orange-800 dark:text-orange-200 mb-2",children:"Action Required"}),e.jsxs("div",{className:"p-2 bg-white dark:bg-gray-800 rounded border border-orange-100 dark:border-orange-700",children:[e.jsx("p",{className:"text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Technical Report Required"}),e.jsxs("p",{className:"text-xs text-orange-600 dark:text-orange-400 flex items-center gap-1",children:[e.jsx(fa,{size:10}),'Please fill the "Technical Report" field to enable "Send For Approval" button']})]})]})]})})),!dn&&se&&e.jsx("div",{className:"p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg mb-4",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Di,{className:"text-blue-500 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:se.includes("WO Type has been changed")?"Technical Dept Changed":Nn==="Sent to Engineer"?"Choose Your Path":Nn==="Repair InProgress"?"Action Required":"Apply Action Unavailable"}),e.jsx("p",{className:"text-xs text-orange-600 dark:text-orange-400 mt-1",children:se}),!se.includes("Technical Dept has been changed")&&e.jsx("p",{className:"text-xs text-orange-500 dark:text-orange-500 mt-2",children:"→ Edit the form to assign the required fields, then save to enable the action."})]})]})}),!dn&&ci.length===0&&e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center",children:"No workflow actions available"}),e.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 text-center mt-1",children:"(Conditions may not be met for available transitions)"})]})]}),!m&&["Approved","Closed"].includes((z==null?void 0:z.workflow_state)||G.workflow_state||"")&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Feedback"}),Fa?e.jsxs("div",{className:"flex items-center justify-center py-4",children:[e.jsx(ya,{className:"animate-spin text-blue-500 mr-2",size:14}),e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("workOrders.detail.checkingFeedback")})]}):At?e.jsxs("div",{children:[e.jsxs("div",{className:"p-4 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg mb-4 text-center",children:[e.jsx("p",{className:"text-xs text-green-600 dark:text-green-400 mb-2 font-medium",children:wa?"Your Rating":"Owner Rating"}),e.jsx("div",{className:"flex items-center justify-center gap-1 mb-1",children:[1,2,3,4,5].map(Z=>e.jsx("span",{className:`text-xl ${(At.overall||0)>=Z*.2?"text-yellow-400":"text-gray-300 dark:text-gray-500"}`,children:"★"},Z))}),e.jsxs("p",{className:"text-lg font-bold text-green-700 dark:text-green-300",children:[((At.overall||0)*5).toFixed(1)," / 5"]})]}),e.jsx("button",{onClick:yt,className:"w-full px-4 py-2.5 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-medium flex items-center justify-center gap-2 transition-colors",children:"⭐ See Rating"})]}):wa?e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-4 text-center",children:t("workOrders.detail.howWasService")}),e.jsxs("button",{onClick:ze,className:"w-full px-4 py-2.5 bg-yellow-500 hover:bg-yellow-600 text-white rounded-lg text-sm font-medium flex items-center justify-center gap-2 transition-colors",children:["⭐ ",t("workOrders.detail.giveFeedback")]})]}):e.jsx("div",{className:"text-center py-4",children:e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 italic",children:t("workOrders.detail.noFeedbackYet")})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:t("workOrders.detail.statusSummary")}),!m&&z&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:t("workOrders.detail.priority")}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:z.custom_priority_||"Normal"})]}),e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:t("workOrders.detail.created")}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:z.creation?co(z.creation):"-"})]}),e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:t("workOrders.detail.lastModified")}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:z.modified?co(z.modified):"-"})]})]}),m&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Di,{className:"text-4xl text-gray-400 dark:text-gray-500 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("workOrders.detail.statusInfoAfterCreation")})]})]}),!m&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-2 cursor-pointer flex-1",onClick:()=>Ft(!_t),children:[e.jsx(_c,{className:"text-blue-500",size:16}),e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white",children:t("workOrders.detail.activityLog")}),Ue.length>0&&e.jsx("span",{className:"px-2 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 rounded-full text-xs font-medium",children:Ue.length})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:Z=>{Z.stopPropagation(),Ms(),nt.info(t("workOrders.detail.activityLogRefreshed"),{position:"top-right",autoClose:1500,icon:e.jsx(vn,{})})},disabled:Re,className:"p-1.5 text-gray-400 hover:text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded transition-colors disabled:opacity-50",title:t("workOrders.detail.refreshActivityLogTitle"),children:e.jsx(vn,{className:`${Re?"animate-spin":""}`,size:12})}),e.jsx("button",{type:"button",onClick:()=>Ft(!_t),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:_t?e.jsx(As,{size:14}):e.jsx(cs,{size:14})})]})]}),_t&&e.jsxs("div",{className:"p-4",children:[Re&&e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(ya,{className:"animate-spin text-blue-500 mr-2",size:16}),e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("workOrders.detail.loadingActivity")})]}),!Re&&Ue.length===0&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-3 top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700"}),e.jsxs("div",{className:"relative pl-8 mb-4",children:[e.jsx("div",{className:"absolute left-1.5 top-1 w-3 h-3 rounded-full border-2 border-white dark:border-gray-800 bg-gray-300 dark:bg-gray-600"}),e.jsx("div",{className:"p-3 rounded-lg bg-gray-50 dark:bg-gray-700/50",children:e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 italic",children:t("workOrders.detail.noChangesRecorded")})})]}),(z==null?void 0:z.creation)&&(z==null?void 0:z.owner)&&e.jsxs("div",{className:"relative pl-8",children:[e.jsx("div",{className:"absolute left-1.5 top-1 w-3 h-3 rounded-full border-2 border-white dark:border-gray-800 bg-green-500"}),e.jsxs("div",{className:"p-3 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-100 dark:border-green-800/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-green-200 dark:bg-green-800 flex items-center justify-center",children:e.jsx(js,{className:"text-green-600 dark:text-green-400",size:10})}),e.jsx("span",{className:"text-xs font-medium text-gray-700 dark:text-gray-300",children:ji(z.owner)})]}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx(or,{size:10}),e.jsx("span",{title:co(z.creation),children:to(z.creation)})]})]}),e.jsx("div",{className:"text-xs",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 bg-green-100 dark:bg-green-800/50 text-green-700 dark:text-green-300 rounded font-medium",children:[e.jsx(ea,{size:10}),"Created this Work Order"]})})]})]})]}),!Re&&Ue.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-3 top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700"}),e.jsx("div",{className:"space-y-4",children:(dt?Ue:Ue.slice(0,5)).map((Z,pe)=>e.jsxs("div",{className:"relative pl-8",children:[e.jsx("div",{className:`absolute left-1.5 top-1 w-3 h-3 rounded-full border-2 border-white dark:border-gray-800 ${pe===0?"bg-blue-500":"bg-gray-300 dark:bg-gray-600"}`}),e.jsxs("div",{className:`p-3 rounded-lg ${pe===0?"bg-blue-50 dark:bg-blue-900/20 border border-blue-100 dark:border-blue-800/50":"bg-gray-50 dark:bg-gray-700/50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-gray-200 dark:bg-gray-600 flex items-center justify-center",children:e.jsx(js,{className:"text-gray-500 dark:text-gray-400",size:10})}),e.jsx("span",{className:"text-xs font-medium text-gray-700 dark:text-gray-300",children:ji(Z.owner)})]}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx(or,{size:10}),e.jsx("span",{title:co(Z.creation),children:to(Z.creation)})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[Z.changes.length>0?Z.changes.map((je,Ct)=>e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:`font-medium ${ui(je.field)}`,children:nl(je.field)}),e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[" ",t("workOrders.detail.changedFrom")," "]}),e.jsx("span",{className:"px-1.5 py-0.5 bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400 rounded text-[10px] font-mono",children:eo(je.oldValue)}),e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:" → "}),e.jsx("span",{className:"px-1.5 py-0.5 bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400 rounded text-[10px] font-mono",children:eo(je.newValue)})]},Ct)):e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 italic",children:t("workOrders.detail.documentUpdated")}),Z.added&&Z.added.length>0&&e.jsxs("div",{className:"text-xs text-green-600 dark:text-green-400",children:[e.jsx("span",{className:"font-medium",children:t("workOrders.detail.added")})," ",Z.added.length," ",t("workOrders.detail.items")]}),Z.removed&&Z.removed.length>0&&e.jsxs("div",{className:"text-xs text-red-600 dark:text-red-400",children:[e.jsx("span",{className:"font-medium",children:t("workOrders.detail.removed")})," ",Z.removed.length," ",t("workOrders.detail.items")]}),Z.rowChanged&&Z.rowChanged.length>0&&e.jsxs("div",{className:"text-xs text-orange-600 dark:text-orange-400",children:[e.jsx("span",{className:"font-medium",children:t("workOrders.detail.modified")})," ",Z.rowChanged.length," ",t("workOrders.detail.rows")]})]})]})]},Z.name))}),Ue.length>5&&e.jsx("div",{className:"mt-4 text-center",children:e.jsx("button",{type:"button",onClick:()=>pt(!dt),className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-md transition-colors",children:dt?e.jsxs(e.Fragment,{children:[e.jsx(As,{size:10}),t("workOrders.detail.showLess")]}):e.jsxs(e.Fragment,{children:[e.jsx(cs,{size:10}),t("workOrders.detail.showAll")," (",Ue.length," ",t("workOrders.detail.entries"),")"]})})}),(z==null?void 0:z.creation)&&(z==null?void 0:z.owner)&&e.jsxs("div",{className:"relative pl-8 mt-4",children:[e.jsx("div",{className:"absolute left-1.5 top-1 w-3 h-3 rounded-full border-2 border-white dark:border-gray-800 bg-green-500"}),e.jsxs("div",{className:"p-3 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-100 dark:border-green-800/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-green-200 dark:bg-green-800 flex items-center justify-center",children:e.jsx(js,{className:"text-green-600 dark:text-green-400",size:10})}),e.jsx("span",{className:"text-xs font-medium text-gray-700 dark:text-gray-300",children:ji(z.owner)})]}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx(or,{size:10}),e.jsx("span",{title:new Date(z.creation).toLocaleString(),children:to(z.creation)})]})]}),e.jsx("div",{className:"text-xs",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 bg-green-100 dark:bg-green-800/50 text-green-700 dark:text-green-300 rounded font-medium",children:[e.jsx(ea,{size:10}),"Created this Work Order"]})})]})]})]})]})]}),!m&&((z==null?void 0:z.docstatus)===0||(z==null?void 0:z.docstatus)===2)&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Delete Request"}),e.jsx(Ll,{doctype:"Work_Order",docname:a,currentDeleteStatus:(To=z==null?void 0:z.custom_delete_status)!=null?To:null,userRoles:j,isSystemManager:li,redirectOnDelete:"/work-orders",onStatusChange:Z=>{gt()}})]})]})]})}),e.jsx("style",{children:`
/* Wrapper for table - allow natural flow */
.stock-items-table-wrapper {
width: 100%;
position: relative;
}
/* Scroll container handles horizontal scrolling only */
.stock-items-scroll-container {
width: 100%;
overflow-x: auto;
overflow-y: visible;
-webkit-overflow-scrolling: touch;
}
/* Table styling */
.stock-items-scroll-container table {
border-collapse: separate;
border-spacing: 0;
min-width: 100%;
}
.stock-items-scroll-container tbody tr td {
position: relative;
}
`})]})},pL=()=>{const{t}=ca(),a=qa(),[r,s]=y.useState(0),[i,c]=y.useState(""),[d,m]=y.useState(""),[h,g]=y.useState(null),[p,b]=y.useState(null),j=y.useRef(null),_=20,N=d?{maintenance_status:d}:{},{logs:k,totalCount:C,hasMore:D,loading:T,error:E,refetch:O}=Rh(N,_,r*_,"due_date asc"),{deleteLog:R,loading:Y}=v2();y.useEffect(()=>{const oe=ae=>{j.current&&!j.current.contains(ae.target)&&b(null)};return p&&document.addEventListener("mousedown",oe),()=>{document.removeEventListener("mousedown",oe)}},[p]);const P=()=>{a("/maintenance/new")},U=oe=>{a(`/maintenance/${oe}`)},J=oe=>{a(`/maintenance/${oe}`)},ne=oe=>Q(null,null,function*(){try{yield R(oe),g(null),O(),alert(t("maintenance.deletedSuccessfully"))}catch(ae){alert(`Failed to delete: ${ae instanceof Error?ae.message:"Unknown error"}`)}}),ye=oe=>{a(`/maintenance/new?duplicate=${oe}`)},he=oe=>{const ae=JSON.stringify(oe,null,2),F=new Blob([ae],{type:"application/json"}),M=URL.createObjectURL(F),B=document.createElement("a");B.href=M,B.download=`maintenance_${oe.name}.json`,B.click(),URL.revokeObjectURL(M)},ce=oe=>{window.open(`/maintenance/${oe}?print=true`,"_blank")},se=()=>{const ae=[["Log ID","Asset","Type","Status","Due Date","Assigned To"].join(","),...k.map(X=>[X.name,X.asset_name||"",X.maintenance_type||"",X.maintenance_status||"",X.due_date||"",X.assign_to_name||""].join(","))].join(`
`),F=new Blob([ae],{type:"text/csv"}),M=URL.createObjectURL(F),B=document.createElement("a");B.href=M,B.download=`maintenance_logs_${new Date().toISOString().split("T")[0]}.csv`,B.click(),URL.revokeObjectURL(M)},ee=oe=>{switch(oe==null?void 0:oe.toLowerCase()){case"completed":return e.jsx(ea,{className:"text-green-500"});case"planned":return e.jsx(Xx,{className:"text-blue-500"});case"overdue":return e.jsx(fa,{className:"text-red-500"});default:return e.jsx(or,{className:"text-gray-400"})}},te=oe=>{switch(oe==null?void 0:oe.toLowerCase()){case"completed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300";case"planned":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300";case"overdue":return"bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300";case"cancelled":return"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300";default:return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-300"}},W=(oe,ae)=>!oe||(ae==null?void 0:ae.toLowerCase())==="completed"?!1:new Date(oe)<new Date;if(T&&r===0)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("listPages.loading")})]})});if(E)return e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-6",children:[e.jsxs("h2",{className:"text-xl font-bold text-yellow-800 dark:text-yellow-300 mb-4",children:["⚠️ ",t("maintenance.apiNotAvailable")]}),e.jsxs("div",{className:"text-yellow-700 dark:text-yellow-400 space-y-3",children:[e.jsx("p",{children:e.jsx("strong",{children:t("maintenance.apiNotDeployed")})}),e.jsxs("div",{className:"mt-4 flex gap-3",children:[e.jsx("button",{onClick:()=>a("/maintenance/new"),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:t("maintenance.tryCreatingNew")}),e.jsx("button",{onClick:O,className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded",children:t("common.tryAgain")})]})]}),e.jsx("div",{className:"mt-4 p-4 bg-white dark:bg-gray-800 rounded border border-yellow-300 dark:border-yellow-700",children:e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("strong",{children:"Technical Error:"})," ",E]})})]})});const I=k.filter(oe=>{var ae,F,M;return((ae=oe.name)==null?void 0:ae.toLowerCase().includes(i.toLowerCase()))||((F=oe.asset_name)==null?void 0:F.toLowerCase().includes(i.toLowerCase()))||((M=oe.task_name)==null?void 0:M.toLowerCase().includes(i.toLowerCase()))});return e.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-800 dark:text-white",children:t("maintenance.title")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:t("maintenance.listTotal",{count:C})})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:se,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-3 rounded-lg flex items-center gap-2 shadow transition-all",disabled:k.length===0,children:[e.jsx(Os,{}),e.jsx("span",{className:"font-medium",children:t("listPages.exportAllOnPage")})]}),e.jsxs("button",{onClick:P,className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-lg flex items-center gap-2 shadow-lg transition-all hover:shadow-xl",children:[e.jsx(Zs,{}),e.jsx("span",{className:"font-medium",children:t("maintenance.addMaintenance")})]})]})]}),e.jsxs("div",{className:"mb-6 grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:e.jsxs("div",{className:"flex items-center gap-2 border border-gray-300 dark:border-gray-600 rounded-lg px-4 py-2 bg-white dark:bg-gray-700",children:[e.jsx(Js,{className:"text-gray-400 dark:text-gray-500"}),e.jsx("input",{type:"text",placeholder:t("listPages.searchPlaceholder"),value:i,onChange:oe=>c(oe.target.value),className:"flex-1 outline-none text-gray-700 dark:text-gray-200 bg-transparent"})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:e.jsxs("select",{value:d,onChange:oe=>{m(oe.target.value),s(0)},className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:t("listPages.allStatuses")}),e.jsx("option",{value:"Planned",children:t("maintenance.status.planned")}),e.jsx("option",{value:"Completed",children:t("maintenance.status.completed")}),e.jsx("option",{value:"Overdue",children:t("maintenance.status.overdue")}),e.jsx("option",{value:"Cancelled",children:t("maintenance.status.cancelled")})]})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden",children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("maintenance.logId")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("commonFields.assetShort")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("commonFields.typeShort")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("ppm.dueDate")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("commonFields.status")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("listPages.actions")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:I.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(Js,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),e.jsx("p",{children:t("listPages.noMaintenanceLogsFound")}),e.jsx("button",{onClick:P,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:t("listPages.createFirstMaintenanceLog")})]})})}):I.map(oe=>{const ae=W(oe.due_date||"",oe.maintenance_status||"");return e.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${ae?"bg-red-50 dark:bg-red-900/10":""}`,onClick:()=>U(oe.name),children:[e.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:oe.name}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:oe.creation?new Date(oe.creation).toLocaleDateString():""})]}),e.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[e.jsx("div",{className:"text-sm text-gray-900 dark:text-white",children:oe.asset_name||"-"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:oe.custom_asset_type||""})]}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:oe.maintenance_type||"-"}),e.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[e.jsx("div",{className:"text-sm text-gray-900 dark:text-white",children:oe.due_date?new Date(oe.due_date).toLocaleDateString():"-"}),ae&&e.jsx("div",{className:"text-xs text-red-600 dark:text-red-400 font-semibold",children:"Overdue"})]}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ee(oe.maintenance_status||""),e.jsx("span",{className:`px-3 py-1 inline-flex text-xs leading-5 font-semibold rounded-full ${te(oe.maintenance_status||"")}`,children:oe.maintenance_status||"Unknown"})]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:e.jsxs("div",{className:"flex items-center gap-1",onClick:F=>F.stopPropagation(),children:[e.jsx("button",{onClick:()=>U(oe.name),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:"View Details",children:e.jsx(ri,{})}),e.jsx("button",{onClick:()=>J(oe.name),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:"Edit Log",children:e.jsx(Fr,{})}),e.jsx("button",{onClick:()=>ye(oe.name),className:"text-purple-600 dark:text-purple-400 hover:text-purple-900 dark:hover:text-purple-300 p-2 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded transition-colors",title:"Duplicate",children:e.jsx(Wd,{})}),e.jsx("button",{onClick:()=>g(oe.name),className:"text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300 p-2 hover:bg-red-50 dark:hover:bg-red-900/30 rounded transition-colors",title:"Delete",disabled:Y,children:e.jsx(Na,{})}),e.jsxs("div",{className:"relative",ref:p===oe.name?j:null,children:[e.jsx("button",{onClick:()=>b(p===oe.name?null:oe.name),className:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 p-2 hover:bg-gray-50 dark:hover:bg-gray-700 rounded transition-colors",title:"More Actions",children:e.jsx(Nu,{})}),p===oe.name&&e.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 z-10",children:[e.jsxs("button",{onClick:()=>{he(oe),b(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2 rounded-t-lg",children:[e.jsx(po,{className:"text-blue-500"}),"Export as JSON"]}),e.jsxs("button",{onClick:()=>{ce(oe.name),b(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2 rounded-b-lg",children:[e.jsx(Fi,{className:"text-purple-500"}),"Print Log"]})]})]})]})})]},oe.name)})})]})}),I.length>0&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 px-6 py-4 flex items-center justify-between border-t border-gray-200 dark:border-gray-600",children:[e.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Showing ",e.jsx("span",{className:"font-medium",children:r*_+1})," to"," ",e.jsx("span",{className:"font-medium",children:Math.min((r+1)*_,C)})," ","of ",e.jsx("span",{className:"font-medium",children:C})," results"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{disabled:r===0,onClick:()=>s(r-1),className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Previous"}),e.jsx("button",{disabled:!D,onClick:()=>s(r+1),className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Next"})]})]})]}),h&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:e.jsx(Na,{className:"text-red-600 dark:text-red-400 text-xl"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Delete Maintenance Log"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:"Are you sure you want to delete this maintenance log? This action cannot be undone."}),e.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-md p-3 mb-4",children:e.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[e.jsx("strong",{children:"Log ID:"})," ",h]})}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>g(null),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-lg transition-colors",disabled:Y,children:"Cancel"}),e.jsx("button",{onClick:()=>ne(h),className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50",disabled:Y,children:Y?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Na,{}),"Delete Log"]})})]})]})]})})})]})},yL=mt,bL=({message:t,type:a,onClose:r})=>{y.useEffect(()=>{const i=setTimeout(r,1e4);return()=>clearTimeout(i)},[r]);const s=a==="warning"?"bg-yellow-500":a==="success"?"bg-green-500":"bg-red-500";return e.jsx("div",{className:`fixed top-4 right-4 ${s} text-white px-6 py-4 rounded-lg shadow-lg z-50 max-w-md`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(fa,{className:"mt-0.5 flex-shrink-0"}),e.jsx("p",{className:"text-sm",children:t}),e.jsx("button",{onClick:r,className:"ml-2 text-white hover:text-gray-200",children:e.jsx(wt,{})})]})})},vL=()=>{const{t}=ca(),{logName:a}=xo(),r=qa(),[s]=Qs(),i=s.get("duplicate"),c=a==="new",d=c&&!!i,{log:m,loading:h,error:g}=T5(d?i:c?null:a||null),{createLog:p,updateLog:b,loading:j}=v2(),_=(m==null?void 0:m.workflow_state)==="Approved",[N,k]=y.useState(c),[C,D]=y.useState([]),[T,E]=y.useState(null),[O,R]=y.useState(!1),[Y,P]=y.useState({asset_name:"",custom_asset_type:"",item_code:"",item_name:"",custom_asset_names:"",custom_hospital_name:"",task:"",task_name:"",maintenance_type:"Preventive Maintenance",periodicity:"",has_certificate:0,custom_early_completion:"",maintenance_status:"Planned",custom_accepted_by_moh:0,assign_to_name:"",due_date:"",completion_date:"",custom_early_completion_reason:"",custom_accepted_by_moh_:0,custom_template:"",custom_table:[],description:""}),U=y.useCallback((ae,F,M)=>{if(M!=="Completed"){P(we=>Se(ue({},we),{custom_early_completion:""}));return}if(!ae||!F)return;const B=new Date(ae),X=new Date(F),K=new Date(B.getFullYear(),B.getMonth(),1);if(X<K){P(ke=>Se(ue({},ke),{custom_early_completion:"Yes"}));const we=X.toLocaleDateString(),be=B.toLocaleDateString();E({message:`⚠️ Warning: Completion Date (${we}) is before the Due Date Month (${be}). Please verify.`,type:"warning"})}},[]),J=y.useCallback(ae=>Q(null,null,function*(){var F;if(ae){R(!0);try{const M=yield yL.apiCall(`/api/resource/PPM Templates/${encodeURIComponent(ae)}`,"GET");if((F=M==null?void 0:M.data)!=null&&F.ppm_template_table&&Array.isArray(M.data.ppm_template_table)){const B=M.data.ppm_template_table.map((X,K)=>({idx:K+1,maintenance_name:X.maintenance_name||"",working:0,defect_found:0,not_working:0}));D(B)}}catch(M){console.error("Error loading PPM template:",M),E({message:"Failed to load PPM template. Please add items manually.",type:"error"})}finally{R(!1)}}}),[]);y.useEffect(()=>{m&&(m.workflow_state==="Approved"&&k(!1),P({asset_name:m.asset_name||"",custom_asset_type:m.custom_asset_type||"",item_code:m.item_code||"",item_name:m.item_name||"",custom_asset_names:m.custom_asset_names||"",custom_hospital_name:m.custom_hospital_name||"",task:m.task||"",task_name:m.task_name||"",maintenance_type:m.maintenance_type||"Preventive Maintenance",periodicity:m.periodicity||"",has_certificate:m.has_certificate||0,custom_early_completion:d?"":m.custom_early_completion||"",maintenance_status:d?"Planned":m.maintenance_status||"Planned",custom_accepted_by_moh:m.custom_accepted_by_moh||0,assign_to_name:m.assign_to_name||"",due_date:m.due_date||"",completion_date:d?"":m.completion_date||"",custom_early_completion_reason:d?"":m.custom_early_completion_reason||"",custom_accepted_by_moh_:m.custom_accepted_by_moh_||0,custom_template:m.custom_template||"",custom_table:m.custom_table||[],description:m.description||""}),m.custom_table&&Array.isArray(m.custom_table)&&m.custom_table.length>0?D(m.custom_table.map((ae,F)=>({name:ae.name,idx:ae.idx||F+1,maintenance_name:ae.maintenance_name||"",working:ae.working||0,defect_found:ae.defect_found||0,not_working:ae.not_working||0}))):m.custom_template&&(!m.custom_table||m.custom_table.length===0)&&J(m.custom_template))},[m,d,J]),y.useEffect(()=>{Y.completion_date&&Y.due_date&&U(Y.due_date,Y.completion_date,Y.maintenance_status)},[Y.completion_date,Y.due_date,Y.maintenance_status,U]);const ne=ae=>{const{name:F,value:M,type:B}=ae.target,X=ae.target.checked;P(K=>Se(ue({},K),{[F]:B==="checkbox"?X?1:0:M}))},ye=ae=>{const F=ae.target.value;P(M=>Se(ue({},M),{maintenance_status:F})),F==="Completed"?U(Y.due_date||"",Y.completion_date||"",F):P(M=>Se(ue({},M),{custom_early_completion:""}))},he=ae=>{const F=ae.target.value;P(M=>Se(ue({},M),{completion_date:F})),Y.maintenance_status==="Completed"&&U(Y.due_date||"",F,Y.maintenance_status)},ce=ae=>Q(null,null,function*(){const F=ae.target.value;P(M=>Se(ue({},M),{custom_template:F})),(F&&C.length===0||F&&C.length>0&&window.confirm("Loading a template will replace existing checklist items. Continue?"))&&J(F)}),se=()=>{const ae={idx:C.length+1,maintenance_name:"",working:0,defect_found:0,not_working:0};D([...C,ae])},ee=ae=>{const F=C.filter((M,B)=>B!==ae).map((M,B)=>Se(ue({},M),{idx:B+1}));D(F)},te=(ae,F,M)=>{const B=[...C];B[ae]=Se(ue({},B[ae]),{[F]:M}),D(B)},W=ae=>Q(null,null,function*(){if(ae.preventDefault(),!Y.asset_name){alert("Please enter Asset Name");return}if(!Y.maintenance_type){alert("Please select Maintenance Type");return}const F=C.map((B,X)=>{const K={idx:B.idx||X+1,maintenance_name:B.maintenance_name||"",working:B.working?1:0,defect_found:B.defect_found?1:0,not_working:B.not_working?1:0};return B.name&&typeof B.name=="string"&&B.name.trim()!==""&&(K.name=B.name),K}),M=Se(ue({},Y),{custom_table:F});console.log("Submitting maintenance log data:",M);try{if(c||d){const B=yield p(M);alert(d?"Maintenance log duplicated successfully!":"Maintenance log created successfully!"),r(`/maintenance/${B.name}`)}else a&&(yield b(a,M),alert("Maintenance log updated successfully!"),k(!1))}catch(B){console.error("Maintenance log save error:",B),alert("Failed to save: "+(B instanceof Error?B.message:"Unknown error"))}}),I=ae=>({Draft:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",Applied:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",Pending:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",Approved:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",Rejected:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",Completed:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200"})[ae]||"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",oe=ae=>({Planned:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",Completed:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",Overdue:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",Cancelled:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"})[ae]||"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300";return h?e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading maintenance log..."})]})}):g&&!c&&!d?e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[e.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["Error: ",g]}),e.jsx("button",{onClick:()=>r(-1),className:"mt-2 text-red-700 dark:text-red-400 underline hover:text-red-800 dark:hover:text-red-300",children:"Back to maintenance logs"})]})}):e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[T&&e.jsx(bL,{message:T.message,type:T.type,onClose:()=>E(null)}),e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("button",{onClick:()=>r(-1),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[e.jsx(en,{}),e.jsx("span",{className:"text-gray-900 dark:text-white font-semibold",children:d?"Duplicate Maintenance Log":c?"New Maintenance Log":"Maintenance Log Details"})]}),!c&&(m==null?void 0:m.workflow_state)&&e.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium ${I(m.workflow_state)}`,children:m.workflow_state})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[!c&&!N&&!_&&e.jsxs("button",{onClick:()=>k(!0),className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg flex items-center gap-2",children:[e.jsx(Fr,{}),"Edit"]}),N&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{c?r(-1):k(!1)},className:"bg-gray-300 hover:bg-gray-400 text-gray-700 px-6 py-2 rounded-lg",disabled:j,children:"Cancel"}),e.jsxs("button",{onClick:W,disabled:j,className:"bg-green-600 hover:bg-green-700 text-white px-6 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[e.jsx(Or,{}),j?"Saving...":"Save Changes"]})]})]})]}),e.jsx("form",{onSubmit:W,className:"space-y-6",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Basic Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Log ID"}),e.jsx("input",{type:"text",value:c||d?"Auto-generated":(m==null?void 0:m.name)||"",disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-900 dark:text-white"}),d&&e.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:["💡 Duplicating from: ",i]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Hospital"}),e.jsx("input",{type:"text",name:"custom_hospital_name",value:Y.custom_hospital_name||"",onChange:ne,disabled:!N,placeholder:"Hospital name",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Asset Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",name:"asset_name",value:Y.asset_name,onChange:ne,required:!0,disabled:!N,placeholder:"Asset ID",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Asset Display Name"}),e.jsx("input",{type:"text",name:"custom_asset_names",value:Y.custom_asset_names||"",onChange:ne,disabled:!N,placeholder:"Display name",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Asset Type"}),e.jsx("input",{type:"text",name:"custom_asset_type",value:Y.custom_asset_type||"",onChange:ne,disabled:!N,placeholder:"e.g., Bio Medical",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Maintenance Details"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Maintenance Type ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("select",{name:"maintenance_type",value:Y.maintenance_type,onChange:ne,required:!0,disabled:!N,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"Preventive Maintenance",children:"Preventive Maintenance"}),e.jsx("option",{value:"Corrective Maintenance",children:"Corrective Maintenance"}),e.jsx("option",{value:"Calibration",children:"Calibration"}),e.jsx("option",{value:"Inspection",children:"Inspection"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Periodicity"}),e.jsxs("select",{name:"periodicity",value:Y.periodicity||"",onChange:ne,disabled:!N,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:"Select periodicity"}),e.jsx("option",{value:"Daily",children:"Daily"}),e.jsx("option",{value:"Weekly",children:"Weekly"}),e.jsx("option",{value:"Monthly",children:"Monthly"}),e.jsx("option",{value:"Quarterly",children:"Quarterly"}),e.jsx("option",{value:"Half Yearly",children:"Half Yearly"}),e.jsx("option",{value:"Yearly",children:"Yearly"}),e.jsx("option",{value:"2 Yearly",children:"2 Yearly"}),e.jsx("option",{value:"3 Yearly",children:"3 Yearly"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Template",O&&e.jsx("span",{className:"ml-2 text-blue-500",children:"(Loading...)"})]}),e.jsx("input",{type:"text",name:"custom_template",value:Y.custom_template||"",onChange:ce,disabled:!N,placeholder:"PPM Template name",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Enter template name to auto-load checklist items"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Status"}),e.jsxs("select",{name:"maintenance_status",value:Y.maintenance_status,onChange:ye,disabled:!N,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"Planned",children:"Planned"}),e.jsx("option",{value:"Completed",children:"Completed"}),e.jsx("option",{value:"Overdue",children:"Overdue"}),e.jsx("option",{value:"Cancelled",children:"Cancelled"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Assigned To"}),e.jsx("input",{type:"text",name:"assign_to_name",value:Y.assign_to_name||"",onChange:ne,disabled:!N,placeholder:"Technician name",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Due Date"}),e.jsx("input",{type:"date",name:"due_date",value:Y.due_date||"",onChange:ne,disabled:!N,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Completion Date"}),e.jsx("input",{type:"date",name:"completion_date",value:Y.completion_date||"",onChange:he,disabled:!N,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Completion & Approval"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Early Completion",Y.custom_early_completion==="Yes"&&e.jsx("span",{className:"ml-2 text-yellow-500",children:"⚠️ Auto-detected"})]}),e.jsx("input",{type:"text",value:Y.custom_early_completion||"No",disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-700 text-gray-900 dark:text-white"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Auto-set based on completion date vs due date"})]}),Y.custom_early_completion==="Yes"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Early Completion Reason ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",name:"custom_early_completion_reason",value:Y.custom_early_completion_reason||"",onChange:ne,disabled:!N,required:!0,placeholder:"Required when early completion",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",name:"custom_accepted_by_moh",checked:!!Y.custom_accepted_by_moh,onChange:ne,disabled:!N,className:"w-4 h-4 text-blue-600 rounded focus:ring-2 focus:ring-blue-500"}),e.jsx("label",{className:"text-xs font-medium text-gray-700 dark:text-gray-300",children:"Accepted by MOH"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-800 dark:text-white flex items-center gap-2",children:[e.jsx(q5,{}),"PPM Checklist Table",O&&e.jsx("span",{className:"text-sm text-blue-500 font-normal",children:"(Loading template...)"})]}),N&&e.jsxs("button",{type:"button",onClick:se,className:"flex items-center gap-1 px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white text-sm rounded-md",children:[e.jsx(Zs,{className:"text-xs"}),"Add Row"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-50 dark:bg-gray-700",children:[e.jsx("th",{className:"text-left py-3 px-3 text-xs font-medium text-gray-700 dark:text-gray-300 w-12",children:"#"}),e.jsx("th",{className:"text-left py-3 px-3 text-xs font-medium text-gray-700 dark:text-gray-300",children:"Maintenance Task"}),e.jsx("th",{className:"text-center py-3 px-3 text-xs font-medium text-green-600 dark:text-green-400 w-24",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(dc,{})," Working"]})}),e.jsx("th",{className:"text-center py-3 px-3 text-xs font-medium text-yellow-600 dark:text-yellow-400 w-28",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(fa,{})," Defect"]})}),e.jsx("th",{className:"text-center py-3 px-3 text-xs font-medium text-red-600 dark:text-red-400 w-28",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(wt,{})," Not Working"]})}),N&&e.jsx("th",{className:"text-center py-3 px-3 text-xs font-medium text-gray-700 dark:text-gray-300 w-16",children:"Action"})]})}),e.jsx("tbody",{children:C.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:N?6:5,className:"text-center py-8 text-gray-500 dark:text-gray-400",children:["No checklist items. ",N&&'Enter a template name above or click "Add Row" to add items.']})}):C.map((ae,F)=>e.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50",children:[e.jsx("td",{className:"py-3 px-3 text-sm text-gray-600 dark:text-gray-400",children:ae.idx||F+1}),e.jsx("td",{className:"py-3 px-3",children:N?e.jsx("input",{type:"text",value:ae.maintenance_name,onChange:M=>te(F,"maintenance_name",M.target.value),placeholder:"Enter maintenance task",className:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-1 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):e.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:ae.maintenance_name})}),e.jsx("td",{className:"py-3 px-3 text-center",children:e.jsx("input",{type:"checkbox",checked:!!ae.working,onChange:M=>te(F,"working",M.target.checked?1:0),disabled:!N,className:"w-5 h-5 text-green-600 rounded focus:ring-2 focus:ring-green-500 cursor-pointer disabled:cursor-default"})}),e.jsx("td",{className:"py-3 px-3 text-center",children:e.jsx("input",{type:"checkbox",checked:!!ae.defect_found,onChange:M=>te(F,"defect_found",M.target.checked?1:0),disabled:!N,className:"w-5 h-5 text-yellow-600 rounded focus:ring-2 focus:ring-yellow-500 cursor-pointer disabled:cursor-default"})}),e.jsx("td",{className:"py-3 px-3 text-center",children:e.jsx("input",{type:"checkbox",checked:!!ae.not_working,onChange:M=>te(F,"not_working",M.target.checked?1:0),disabled:!N,className:"w-5 h-5 text-red-600 rounded focus:ring-2 focus:ring-red-500 cursor-pointer disabled:cursor-default"})}),N&&e.jsx("td",{className:"py-3 px-3 text-center",children:e.jsx("button",{type:"button",onClick:()=>ee(F),className:"text-red-500 hover:text-red-700 p-1",title:"Remove row",children:e.jsx(Na,{})})})]},ae.name||F))})]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[!c&&m&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Workflow Actions"}),e.jsx(Tp,{doctype:"Asset Maintenance Log",docname:m.name||null,workflowState:m.workflow_state,showStateInfo:!1,onActionComplete:(ae,F)=>{F&&console.log(`Action "${ae}" completed successfully`)},onStateChange:()=>{window.location.reload()}})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Status Summary"}),!c&&m?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Current Status"}),e.jsx("span",{className:`inline-block px-3 py-1 rounded-full text-sm font-medium ${oe(Y.maintenance_status)}`,children:Y.maintenance_status||"Planned"})]}),e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Workflow State"}),e.jsx("span",{className:`inline-block px-3 py-1 rounded-full text-sm font-medium ${I(m.workflow_state||"Draft")}`,children:m.workflow_state||"Draft"})]}),Y.custom_early_completion==="Yes"&&e.jsxs("div",{className:"p-4 bg-yellow-50 dark:bg-yellow-900/20 rounded-lg border border-yellow-200 dark:border-yellow-800",children:[e.jsx("p",{className:"text-xs text-yellow-600 dark:text-yellow-400 mb-1",children:"⚠️ Early Completion"}),e.jsx("p",{className:"text-sm text-yellow-700 dark:text-yellow-300 font-medium",children:"Completion date is before the due month"})]}),e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Due Date"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:Y.due_date?new Date(Y.due_date).toLocaleDateString():"Not set"}),Y.due_date&&new Date(Y.due_date)<new Date&&Y.maintenance_status!=="Completed"&&e.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 font-semibold mt-1",children:"⚠️ Overdue"})]}),e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Completion Date"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:Y.completion_date?new Date(Y.completion_date).toLocaleDateString():"Not completed"})]}),e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Assigned To"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:Y.assign_to_name||"Unassigned"})]}),e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"PPM Checklist"}),e.jsxs("p",{className:"text-sm text-gray-900 dark:text-white",children:[C.length," item(s)"]}),C.length>0&&e.jsxs("div",{className:"mt-2 text-xs space-y-1",children:[e.jsxs("p",{className:"text-green-600 dark:text-green-400",children:["✓ Working: ",C.filter(ae=>ae.working).length]}),e.jsxs("p",{className:"text-yellow-600 dark:text-yellow-400",children:["⚠ Defects: ",C.filter(ae=>ae.defect_found).length]}),e.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["✗ Not Working: ",C.filter(ae=>ae.not_working).length]})]})]})]}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(or,{className:"text-4xl text-gray-400 dark:text-gray-500 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Status information will appear after creation"})]})]}),!c&&m&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Audit Information"}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Created By"}),e.jsx("p",{className:"text-gray-900 dark:text-white",children:m.owner||"-"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Created On"}),e.jsx("p",{className:"text-gray-900 dark:text-white",children:m.creation?new Date(m.creation).toLocaleString():"-"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Modified By"}),e.jsx("p",{className:"text-gray-900 dark:text-white",children:m.modified_by||"-"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Modified On"}),e.jsx("p",{className:"text-gray-900 dark:text-white",children:m.modified?new Date(m.modified).toLocaleString():"-"})]})]})]})]})]})})]})};class _L{getAssetMaintenances(a,r,s=20,i=0,c){return Q(this,null,function*(){const d=new URLSearchParams;a&&d.append("filters",JSON.stringify(a)),r&&r.length>0&&d.append("fields",JSON.stringify(r)),d.append("limit",s.toString()),d.append("offset",i.toString()),c&&d.append("order_by",c);const m=`${ia.ENDPOINTS.GET_ASSET_MAINTENANCES}?${d.toString()}`;return mt.apiCall(m)})}getAssetMaintenanceDetails(a){return Q(this,null,function*(){const r=new URLSearchParams;r.append("maintenance_name",a);const s=`${ia.ENDPOINTS.GET_ASSET_MAINTENANCE_DETAILS}?${r.toString()}`;return mt.apiCall(s)})}createAssetMaintenance(a){return Q(this,null,function*(){const r=`${ia.ENDPOINTS.CREATE_ASSET_MAINTENANCE}`;return mt.apiCall(r,{method:"POST",body:JSON.stringify({maintenance_data:JSON.stringify(a)})})})}updateAssetMaintenance(a,r){return Q(this,null,function*(){const s=`${ia.ENDPOINTS.UPDATE_ASSET_MAINTENANCE}`;return mt.apiCall(s,{method:"POST",body:JSON.stringify({maintenance_name:a,maintenance_data:JSON.stringify(r)})})})}deleteAssetMaintenance(a){return Q(this,null,function*(){const r=`${ia.ENDPOINTS.DELETE_ASSET_MAINTENANCE}`;return mt.apiCall(r,{method:"POST",body:JSON.stringify({maintenance_name:a})})})}getMaintenanceTasks(a){return Q(this,null,function*(){const r=new URLSearchParams;r.append("maintenance_name",a);const s=`${ia.ENDPOINTS.GET_MAINTENANCE_TASKS}?${r.toString()}`;return mt.apiCall(s)})}getServiceCoverage(a){return Q(this,null,function*(){const r=new URLSearchParams;r.append("maintenance_name",a);const s=`${ia.ENDPOINTS.GET_SERVICE_COVERAGE}?${r.toString()}`;return mt.apiCall(s)})}getMaintenancesByAsset(a,r,s=20,i=0){return Q(this,null,function*(){const c=new URLSearchParams;c.append("asset_name",a),r&&c.append("filters",JSON.stringify(r)),c.append("limit",s.toString()),c.append("offset",i.toString());const d=`${ia.ENDPOINTS.GET_MAINTENANCES_BY_ASSET}?${c.toString()}`;return mt.apiCall(d)})}getActiveServiceContracts(a,r=20,s=0){return Q(this,null,function*(){const i=new URLSearchParams;a&&i.append("filters",JSON.stringify(a)),i.append("limit",r.toString()),i.append("offset",s.toString());const c=`${ia.ENDPOINTS.GET_ACTIVE_SERVICE_CONTRACTS}?${i.toString()}`;return mt.apiCall(c)})}}const cu=new _L;function wL(t,a=20,r=0,s){const[i,c]=y.useState([]),[d,m]=y.useState(0),[h,g]=y.useState(!1),[p,b]=y.useState(!0),[j,_]=y.useState(null),[N,k]=y.useState(0),C=y.useRef(!1),D=JSON.stringify(t);y.useEffect(()=>{if(C.current&&j)return;let E=!1;return C.current=!0,Q(null,null,function*(){try{b(!0);const R=yield cu.getAssetMaintenances(t,void 0,a,r,s);E||(c(R.asset_maintenances),m(R.total_count),g(R.has_more),_(null))}catch(R){if(!E){const Y=R instanceof Error?R.message:"Failed to fetch PPM schedules";Y.includes("417")||Y.includes("Expectation Failed")||Y.includes("has no attribute")?_("API endpoint not deployed. Please deploy ppm_api.py to your Frappe server."):_(Y),c([]),m(0),g(!1)}}finally{E||b(!1)}}),()=>{E=!0}},[D,a,r,s,N]);const T=y.useCallback(()=>{C.current=!1,k(E=>E+1)},[]);return{ppms:i,totalCount:d,hasMore:h,loading:p,error:j,refetch:T}}function kL(t){const[a,r]=y.useState(null),[s,i]=y.useState(!0),[c,d]=y.useState(null),m=y.useCallback(()=>Q(null,null,function*(){if(!t){r(null),i(!1);return}try{i(!0),d(null);const g=yield cu.getAssetMaintenanceDetails(t);r(g)}catch(g){d(g instanceof Error?g.message:"Failed to fetch PPM details")}finally{i(!1)}}),[t]);y.useEffect(()=>{m()},[m]);const h=y.useCallback(()=>{m()},[m]);return{ppm:a,loading:s,error:c,refetch:h}}function aj(){const[t,a]=y.useState(!1),[r,s]=y.useState(null),i=y.useCallback(m=>Q(null,null,function*(){try{return a(!0),s(null),yield cu.createAssetMaintenance(m)}catch(h){const g=h instanceof Error?h.message:"Failed to create PPM schedule";throw s(g),h}finally{a(!1)}}),[]),c=y.useCallback((m,h)=>Q(null,null,function*(){try{return a(!0),s(null),yield cu.updateAssetMaintenance(m,h)}catch(g){const p=g instanceof Error?g.message:"Failed to update PPM schedule";throw s(p),g}finally{a(!1)}}),[]),d=y.useCallback(m=>Q(null,null,function*(){try{return a(!0),s(null),yield cu.deleteAssetMaintenance(m)}catch(h){const g=h instanceof Error?h.message:"Failed to delete PPM schedule";throw s(g),h}finally{a(!1)}}),[]);return{createPPM:i,updatePPM:c,deletePPM:d,loading:t,error:r}}const jL=()=>{const{t}=ca(),a=qa(),[r,s]=y.useState(0),[i,c]=y.useState(""),[d,m]=y.useState(""),[h,g]=y.useState(null),[p,b]=y.useState(null),j=y.useRef(null),_=20,N=d?{company:d}:{},{ppms:k,totalCount:C,hasMore:D,loading:T,error:E,refetch:O}=wL(N,_,r*_,"creation desc"),{deletePPM:R,loading:Y}=aj();y.useEffect(()=>{const ee=te=>{j.current&&!j.current.contains(te.target)&&b(null)};return p&&document.addEventListener("mousedown",ee),()=>{document.removeEventListener("mousedown",ee)}},[p]);const P=()=>{a("/ppm/new")},U=ee=>{a(`/ppm/${ee}`)},J=ee=>{a(`/ppm/${ee}`)},ne=ee=>Q(null,null,function*(){try{yield R(ee),g(null),O(),alert(t("ppm.deletedSuccessfully"))}catch(te){alert(`Failed to delete: ${te instanceof Error?te.message:"Unknown error"}`)}}),ye=ee=>{a(`/ppm/new?duplicate=${ee}`)},he=ee=>{const te=JSON.stringify(ee,null,2),W=new Blob([te],{type:"application/json"}),I=URL.createObjectURL(W),oe=document.createElement("a");oe.href=I,oe.download=`ppm_${ee.name}.json`,oe.click(),URL.revokeObjectURL(I)},ce=()=>{const te=[["PPM ID","Company","Asset","Asset Type","Frequency","No. of PMs","Total Amount"].join(","),...k.map(ae=>[ae.name,ae.company||"",ae.asset_name||"",ae.custom_asset_type||"",ae.custom_frequency||"",ae.custom_no_of_pms||"",ae.custom_total_amount||""].join(","))].join(`
`),W=new Blob([te],{type:"text/csv"}),I=URL.createObjectURL(W),oe=document.createElement("a");oe.href=I,oe.download=`ppm_schedules_${new Date().toISOString().split("T")[0]}.csv`,oe.click(),URL.revokeObjectURL(I)};if(T&&r===0)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("listPages.loading")})]})});if(E)return e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-6",children:[e.jsxs("h2",{className:"text-xl font-bold text-yellow-800 dark:text-yellow-300 mb-4",children:["⚠️ ",t("ppm.apiNotAvailable")]}),e.jsxs("div",{className:"text-yellow-700 dark:text-yellow-400 space-y-3",children:[e.jsx("p",{children:e.jsx("strong",{children:t("ppm.apiNotDeployed")})}),e.jsxs("div",{className:"mt-4 flex gap-3",children:[e.jsx("button",{onClick:()=>a("/ppm/new"),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:t("ppm.tryCreatingNew")}),e.jsx("button",{onClick:O,className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded",children:t("common.tryAgain")})]})]}),e.jsx("div",{className:"mt-4 p-4 bg-white dark:bg-gray-800 rounded border border-yellow-300 dark:border-yellow-700",children:e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("strong",{children:"Technical Error:"})," ",E]})})]})});const se=k.filter(ee=>{var te,W,I,oe;return((te=ee.name)==null?void 0:te.toLowerCase().includes(i.toLowerCase()))||((W=ee.asset_name)==null?void 0:W.toLowerCase().includes(i.toLowerCase()))||((I=ee.company)==null?void 0:I.toLowerCase().includes(i.toLowerCase()))||((oe=ee.custom_asset_type)==null?void 0:oe.toLowerCase().includes(i.toLowerCase()))});return e.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-800 dark:text-white",children:t("ppm.title")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:t("ppm.listTotal",{count:C})})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:ce,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-3 rounded-lg flex items-center gap-2 shadow transition-all",disabled:k.length===0,children:[e.jsx(Os,{}),e.jsx("span",{className:"font-medium",children:t("listPages.export")})]}),e.jsxs("button",{onClick:P,className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-lg flex items-center gap-2 shadow-lg transition-all hover:shadow-xl",children:[e.jsx(Zs,{}),e.jsx("span",{className:"font-medium",children:t("ppm.addPPM")})]})]})]}),e.jsxs("div",{className:"mb-6 grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:e.jsxs("div",{className:"flex items-center gap-2 border border-gray-300 dark:border-gray-600 rounded-lg px-4 py-2 bg-white dark:bg-gray-700",children:[e.jsx(Js,{className:"text-gray-400 dark:text-gray-500"}),e.jsx("input",{type:"text",placeholder:t("ppm.searchPlaceholder"),value:i,onChange:ee=>c(ee.target.value),className:"flex-1 outline-none text-gray-700 dark:text-gray-200 bg-transparent"})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:e.jsx("input",{type:"text",placeholder:t("ppm.filterByCompany"),value:d,onChange:ee=>{m(ee.target.value),s(0)},className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500"})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden",children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("ppm.pmId")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("ppm.company")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("ppm.asset")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("ppm.assetType")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("ppm.frequency")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("ppm.noOfPMs")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("ppm.totalAmount")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("listPages.actions")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:se.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(Js,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),e.jsx("p",{children:t("ppm.noSchedulesFound")}),e.jsx("button",{onClick:P,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:t("ppm.createFirstSchedule")})]})})}):se.map(ee=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors cursor-pointer",onClick:()=>U(ee.name),children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:ee.name})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Jx,{className:"text-gray-400"}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:ee.company||"-"})]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:ee.asset_name||"-"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:ee.custom_asset_type||"-"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xx,{className:"text-blue-500"}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:ee.custom_frequency||"-"})]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:ee.custom_no_of_pms||"-"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:ee.custom_total_amount?`$${ee.custom_total_amount.toLocaleString()}`:"-"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:e.jsxs("div",{className:"relative",onClick:te=>te.stopPropagation(),children:[e.jsx("button",{onClick:()=>b(p===ee.name?null:ee.name),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(Nu,{})}),p===ee.name&&e.jsxs("div",{ref:j,className:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 rounded-lg shadow-lg z-10 border border-gray-200 dark:border-gray-700",children:[e.jsxs("button",{onClick:()=>{U(ee.name),b(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[e.jsx(ri,{}),t("listPages.view")]}),e.jsxs("button",{onClick:()=>{J(ee.name),b(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[e.jsx(Fr,{}),t("listPages.edit")]}),e.jsxs("button",{onClick:()=>{ye(ee.name),b(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[e.jsx(Wd,{}),t("listPages.duplicate")]}),e.jsxs("button",{onClick:()=>{he(ee),b(null)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[e.jsx(Os,{}),t("listPages.export")]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700"}),e.jsxs("button",{onClick:()=>{g(ee.name),b(null)},className:"w-full text-left px-4 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 flex items-center gap-2",children:[e.jsx(Na,{}),t("listPages.delete")]})]})]})})]},ee.name))})]})}),(D||r>0)&&e.jsxs("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:t("pagination.showingToOf",{start:r*_+1,end:Math.min((r+1)*_,C),total:C,label:t("listPages.results")})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>s(Math.max(0,r-1)),disabled:r===0,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed",children:t("pagination.previous")}),e.jsx("button",{onClick:()=>s(r+1),disabled:!D,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed",children:t("pagination.next")})]})]})]}),h&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 dark:text-white mb-4",children:t("ppm.confirmDelete")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:t("ppm.deleteConfirmMessage")}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>g(null),className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-gray-200 dark:bg-gray-700 rounded-lg hover:bg-gray-300 dark:hover:bg-gray-600",children:t("common.cancel")}),e.jsx("button",{onClick:()=>ne(h),disabled:Y,className:"px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 disabled:opacity-50",children:t(Y?"common.deleting":"common.delete")})]})]})})]})},NL=()=>{const{t}=ca(),{ppmName:a}=xo(),r=qa(),[s]=Qs(),i=s.get("duplicate"),c=a==="new",d=c&&!!i,{ppm:m,loading:h,error:g,refetch:p}=kL(d?i:c?null:a||null),{createPPM:b,updatePPM:j,loading:_}=aj(),[N,k]=y.useState(c),[C,D]=y.useState({company:"",asset_name:"",custom_asset_type:"",maintenance_team:"",custom_frequency:"",custom_total_amount:0,custom_no_of_pms:0,custom_price_per_pm:0});y.useEffect(()=>{m&&D({company:m.company||"",asset_name:m.asset_name||"",custom_asset_type:m.custom_asset_type||"",maintenance_team:m.maintenance_team||"",custom_frequency:m.custom_frequency||"",custom_total_amount:m.custom_total_amount||0,custom_no_of_pms:m.custom_no_of_pms||0,custom_price_per_pm:m.custom_price_per_pm||0})},[m,d]);const T=O=>{const{name:R,value:Y}=O.target;D(P=>Se(ue({},P),{[R]:R.includes("amount")||R.includes("pms")||R.includes("price")?parseFloat(Y)||0:Y}))},E=O=>Q(null,null,function*(){var R;if(O.preventDefault(),!C.asset_name){alert(t("ppm.detail.pleaseEnterAssetName"));return}try{if(c||d){const Y=yield b(C),P=t(d?"ppm.detail.duplicatedSuccessfully":"ppm.detail.createdSuccessfully");alert(P),(R=Y.asset_maintenance)!=null&&R.name?r(`/ppm/${Y.asset_maintenance.name}`):(p(),r(-1))}else a&&(yield j(a,C),alert(t("ppm.detail.updatedSuccessfully")),k(!1),p())}catch(Y){console.error("PPM save error:",Y),alert(t("ppm.detail.failedToSave")+": "+(Y instanceof Error?Y.message:"Unknown error"))}});return h?e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("ppm.detail.loadingSchedule")})]})}):g&&!c&&!d?e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[e.jsxs("p",{className:"text-red-600 dark:text-red-400",children:[t("ppm.detail.errorLoading"),": ",g]}),e.jsx("button",{onClick:()=>r(-1),className:"mt-2 text-red-700 dark:text-red-400 underline hover:text-red-800 dark:hover:text-red-300",children:t("ppm.detail.backToSchedules")})]})}):e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("button",{onClick:()=>r(-1),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[e.jsx(en,{}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:t(d?"ppm.detail.duplicateSchedule":c?"ppm.detail.newSchedule":"ppm.detail.scheduleDetails")})]})}),e.jsx("div",{className:"flex items-center gap-3",children:!c&&!N&&e.jsxs("button",{onClick:()=>k(!0),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[e.jsx(Fr,{}),t("common.edit")]})})]}),e.jsxs("form",{onSubmit:E,children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white mb-4",children:t("ppm.detail.basicInformation")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[t("ppm.company")," *"]}),N?e.jsx("input",{type:"text",name:"company",value:C.company,onChange:T,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}):e.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e.jsx("p",{className:"text-gray-900 dark:text-white",children:(m==null?void 0:m.company)||"-"})})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[t("ppm.detail.assetName")," *"]}),N?e.jsx("input",{type:"text",name:"asset_name",value:C.asset_name,onChange:T,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}):e.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e.jsx("p",{className:"text-gray-900 dark:text-white",children:(m==null?void 0:m.asset_name)||"-"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:t("ppm.assetType")}),N?e.jsx("input",{type:"text",name:"custom_asset_type",value:C.custom_asset_type,onChange:T,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}):e.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e.jsx("p",{className:"text-gray-900 dark:text-white",children:(m==null?void 0:m.custom_asset_type)||"-"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:t("ppm.detail.maintenanceTeam")}),N?e.jsx("input",{type:"text",name:"maintenance_team",value:C.maintenance_team,onChange:T,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}):e.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e.jsx("p",{className:"text-gray-900 dark:text-white",children:(m==null?void 0:m.maintenance_team)||"-"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:t("ppm.frequency")}),N?e.jsx("input",{type:"text",name:"custom_frequency",value:C.custom_frequency,onChange:T,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:t("ppm.detail.frequencyPlaceholder")}):e.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e.jsx("p",{className:"text-gray-900 dark:text-white",children:(m==null?void 0:m.custom_frequency)||"-"})})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white mb-4",children:t("ppm.detail.financialInformation")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:t("ppm.detail.numberOfPMs")}),N?e.jsx("input",{type:"number",name:"custom_no_of_pms",value:C.custom_no_of_pms,onChange:T,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500",min:"0"}):e.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e.jsx("p",{className:"text-gray-900 dark:text-white",children:(m==null?void 0:m.custom_no_of_pms)||"-"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:t("ppm.detail.pricePerPM")}),N?e.jsx("input",{type:"number",name:"custom_price_per_pm",value:C.custom_price_per_pm,onChange:T,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500",min:"0",step:"0.01"}):e.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e.jsx("p",{className:"text-gray-900 dark:text-white",children:m!=null&&m.custom_price_per_pm?`$${m.custom_price_per_pm.toLocaleString()}`:"-"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:t("ppm.totalAmount")}),N?e.jsx("input",{type:"number",name:"custom_total_amount",value:C.custom_total_amount,onChange:T,className:"w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500",min:"0",step:"0.01"}):e.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e.jsx("p",{className:"text-gray-900 dark:text-white font-semibold",children:m!=null&&m.custom_total_amount?`$${m.custom_total_amount.toLocaleString()}`:"-"})})]})]})]})]}),e.jsx("div",{className:"lg:col-span-1",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:t("ppm.detail.scheduleInformation")}),!c&&m&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:t("ppm.pmId")}),e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:m.name})]}),e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:t("users.created")}),e.jsx("p",{className:"text-xs text-gray-900 dark:text-white",children:m.creation?new Date(m.creation).toLocaleString():"-"})]})]}),c&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx(A2,{className:"text-4xl text-gray-400 dark:text-gray-500 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("ppm.detail.scheduleInfoAfterCreation")})]})]})})]}),N&&e.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>{c?r(-1):(k(!1),m&&D({company:m.company||"",asset_name:m.asset_name||"",custom_asset_type:m.custom_asset_type||"",maintenance_team:m.maintenance_team||"",custom_frequency:m.custom_frequency||"",custom_total_amount:m.custom_total_amount||0,custom_no_of_pms:m.custom_no_of_pms||0,custom_price_per_pm:m.custom_price_per_pm||0}))},className:"px-6 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700",children:t("common.cancel")}),e.jsxs("button",{type:"submit",disabled:_,className:"px-6 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg flex items-center gap-2 disabled:opacity-50",children:[e.jsx(Or,{}),t(_?"common.saving":c?"common.create":"ppm.detail.saveChanges")]})]})]})]})};class SL{submitDocument(a,r){return Q(this,null,function*(){try{const s=yield this.fetchWithTimeout(`${ia.BASE_URL}/api/resource/PM Schedule Generator/${encodeURIComponent(a)}`,{method:"GET",headers:{Accept:"application/json"},credentials:"include"},3e4);if(!s.ok){const m=yield s.text();console.warn("Failed to fetch document for submit:",m);return}const c=(yield s.json()).data;if(!c){console.warn("No document data received");return}const d=yield this.fetchWithTimeout(`${ia.BASE_URL}/api/method/frappe.client.submit`,{method:"POST",headers:r,credentials:"include",body:JSON.stringify({doc:c})},6e4);if(d.ok)console.log("✅ Document submitted successfully");else{const m=yield d.text();console.warn("Failed to submit document:",m)}}catch(s){console.warn("Error submitting document:",s.message)}})}fetchWithTimeout(a,r,s=12e4){return Q(this,null,function*(){var d,m;const i=new AbortController,c=setTimeout(()=>i.abort(),s);try{const h=yield fetch(a,Se(ue({},r),{signal:i.signal}));return clearTimeout(c),h}catch(h){throw clearTimeout(c),h.name==="AbortError"?new Error(`Request timeout after ${s}ms. The server may be slow or the request is too large.`):(d=h.message)!=null&&d.includes("Failed to fetch")||(m=h.message)!=null&&m.includes("ERR_CONNECTION_TIMED_OUT")?new Error(`Connection timeout. Please check:
1. Your internet connection
2. Server is accessible
3. Try with fewer assets`):h}})}getFilteredAssets(a){return Q(this,null,function*(){const r=[];a.modality&&r.push(["custom_modality","=",a.modality]),a.asset_type&&r.push(["custom_asset_type","=",a.asset_type]),a.department&&r.push(["department","=",a.department]),a.location&&r.push(["location","=",a.location]),a.manufacturer&&r.push(["custom_manufacturer","=",a.manufacturer]),a.model&&r.push(["custom_model","=",a.model]);const s=JSON.stringify(r),i=JSON.stringify(["name","asset_name","custom_asset_type","department","location","custom_manufacturer","custom_model","custom_modality","company"]),c=yield mt.apiCall(`/api/resource/Asset?filters=${encodeURIComponent(s)}&fields=${encodeURIComponent(i)}&limit_page_length=1000`);return(c==null?void 0:c.data)||[]})}createBulkMaintenanceSchedules(a){return Q(this,null,function*(){var c,m,h,g,p,b;if(!a.hospital)throw new Error("Hospital/Company is required to create PM Schedule Generator");if(!a.periodicity)throw new Error("Periodicity is required");if(a.assets.length===0)throw new Error("At least one asset must be selected");a.assets.length>50&&console.warn(`Creating schedules for ${a.assets.length} assets. This may take a while...`);const r={doctype:"PM Schedule Generator",hospital:a.hospital,start_date:a.start_date,end_date:a.end_date,periodicity:a.periodicity,pm_for:a.pm_for||null,no_of_pms:a.no_of_pms||null,maintenance_team:a.maintenance_team||null,maintenance_manager:a.maintenance_manager||null,assign_to:a.assign_to||null,modality:a.modality||null,manufacturer:a.manufacturer||null,model:a.model||null,department:a.department||null,maintenance_entries:a.assets.map(j=>({doctype:"PM Entry Line",asset:j.name,start_date:a.start_date,end_date:a.end_date,manufacturer:j.custom_manufacturer||null,model:j.custom_model||null}))};console.log("Creating PM Schedule Generator with document:",JSON.stringify(r,null,2));const s=yield mt.getCSRFToken(),i={"Content-Type":"application/json",Accept:"application/json"};s&&(i["X-Frappe-CSRF-Token"]=s);try{const j=yield this.fetchWithTimeout(`${ia.BASE_URL}/api/method/frappe.client.insert`,{method:"POST",headers:i,credentials:"include",body:JSON.stringify({doc:r})},12e4),_=yield j.text();if(console.log("frappe.client.insert response:",_),!j.ok)throw new Error(`HTTP ${j.status}: ${_}`);const N=JSON.parse(_),k=(c=N==null?void 0:N.message)==null?void 0:c.name;if(k)return console.log("✅ PM Schedule Generator created successfully:",k),yield this.submitDocument(k,i),{success:!0,created:a.assets.length,document:k,message:`PM Schedule Generator "${k}" created and submitted with ${a.assets.length} assets`};throw new Error("No document name in response")}catch(j){console.warn("Method 1 (frappe.client.insert) failed:",j.message);try{const d=r,{doctype:_,maintenance_entries:N}=d,k=Dn(d,["doctype","maintenance_entries"]),C=Se(ue({},k),{maintenance_entries:N.map(P=>{var U=P,{doctype:R}=U,Y=Dn(U,["doctype"]);return Y})});console.log("Trying Resource API with:",JSON.stringify(C,null,2));const D=yield this.fetchWithTimeout(`${ia.BASE_URL}/api/resource/PM%20Schedule%20Generator`,{method:"POST",headers:i,credentials:"include",body:JSON.stringify(C)},12e4),T=yield D.text();if(console.log("Resource API response:",T),!D.ok)throw new Error(`HTTP ${D.status}: ${T}`);const E=JSON.parse(T),O=(m=E==null?void 0:E.data)==null?void 0:m.name;if(O)return console.log("✅ PM Schedule Generator created via Resource API:",O),yield this.submitDocument(O,i),{success:!0,created:a.assets.length,document:O,message:`PM Schedule Generator "${O}" created and submitted with ${a.assets.length} assets`};throw new Error("No document name in response")}catch(_){console.warn("Method 2 (Resource API) failed:",_.message);const N=[];throw(((h=j==null?void 0:j.message)==null?void 0:h.includes("timeout"))||((g=j==null?void 0:j.message)==null?void 0:g.includes("Failed to fetch")))&&(((p=_==null?void 0:_.message)==null?void 0:p.includes("timeout"))||((b=_==null?void 0:_.message)==null?void 0:b.includes("Failed to fetch")))?N.push(`⚠️ Connection timeout detected. This usually means:
• The server is taking too long to process ${a.assets.length} assets
• Network connection is slow or unstable
• Server may be overloaded
💡 Suggestions:
• Try with fewer assets (10-20 at a time)
• Check your internet connection
• Try again later if server is busy`):(N.push("Failed to create PM Schedule Generator. Errors:"),j!=null&&j.message&&N.push(`• frappe.client.insert: ${j.message.substring(0,150)}`),_!=null&&_.message&&N.push(`• Resource API: ${_.message.substring(0,150)}`),N.push(`
Please ensure:
1. Hospital (${a.hospital}) is valid
2. You have permission to create PM Schedule Generator
3. All required fields are filled (including PM Name and Assign To)`)),new Error(`Failed to create PM Schedule Generator.
${N.join(`
`)}`)}}})}getFilterOptions(){return Q(this,null,function*(){try{const a=yield mt.apiCall(`/api/resource/Asset?fields=${encodeURIComponent(JSON.stringify(["custom_modality","custom_asset_type","department","location","custom_manufacturer","custom_model"]))}&limit_page_length=1000`),r=(a==null?void 0:a.data)||[];return{modalities:[...new Set(r.map(i=>i.custom_modality).filter(Boolean))],assetTypes:[...new Set(r.map(i=>i.custom_asset_type).filter(Boolean))],departments:[...new Set(r.map(i=>i.department).filter(Boolean))],locations:[...new Set(r.map(i=>i.location).filter(Boolean))],manufacturers:[...new Set(r.map(i=>i.custom_manufacturer).filter(Boolean))],models:[...new Set(r.map(i=>i.custom_model).filter(Boolean))],company:[...new Set(r.map(i=>i.company).filter(Boolean))]}}catch(a){return console.error("Error fetching filter options:",a),{modalities:[],assetTypes:[],departments:[],locations:[],manufacturers:[],models:[],company:[]}}})}getMaintenanceTeams(){return Q(this,null,function*(){try{const a=yield mt.apiCall(`/api/resource/Asset Maintenance Team?fields=${encodeURIComponent(JSON.stringify(["name"]))}&limit_page_length=1000`);return a!=null&&a.data&&a.data.length>0?a.data.map(r=>({name:r.name,maintenance_team_name:r.name})):[]}catch(a){return console.warn("Could not fetch maintenance teams:",(a==null?void 0:a.message)||"Unknown error"),[]}})}getMaintenanceTeamDetails(a){return Q(this,null,function*(){try{const r=yield mt.apiCall(`/api/resource/Asset Maintenance Team/${encodeURIComponent(a)}`);if(r!=null&&r.data){const s=r.data,i=[];return s.maintenance_team_members&&Array.isArray(s.maintenance_team_members)&&s.maintenance_team_members.forEach(c=>{c.team_member&&i.push(c.team_member)}),{name:s.name,maintenance_manager:s.maintenance_manager||void 0,team_members:i.length>0?i:void 0}}return null}catch(r){return console.warn("Could not fetch maintenance team details:",(r==null?void 0:r.message)||"Unknown error"),null}})}}const Zm=new SL,CL=()=>{const{t}=ca(),a=qa(),[r,s]=y.useState({}),[i,c]=y.useState([]),[d,m]=y.useState({start_date:"",end_date:"",maintenance_team:"",assign_to:"",pm_for:"",maintenance_manager:"",periodicity:"Monthly",maintenance_type:"Preventive",no_of_pms:"",department:""}),[h,g]=y.useState(!1),[p,b]=y.useState(!1),[j,_]=y.useState([]),[N,k]=y.useState({modalities:[],assetTypes:[],departments:[],locations:[],manufacturers:[],models:[],company:[]}),[C,D]=y.useState([]),[T,E]=y.useState(""),[O,R]=y.useState(null);y.useEffect(()=>{P(),U()},[]);const Y=(W,I,oe)=>{if(!W||!I||!oe)return null;const ae=parseInt(oe,10);if(isNaN(ae)||ae<1)return null;const F=ae-1;if(F<0)return null;const M=new Date(W),B=new Date(M);switch(I){case"Daily":B.setDate(B.getDate()+F);break;case"Weekly":B.setDate(B.getDate()+F*7);break;case"Monthly":B.setMonth(B.getMonth()+F);break;case"Quarterly":B.setMonth(B.getMonth()+F*3);break;case"Half-yearly":B.setMonth(B.getMonth()+F*6);break;case"Yearly":B.setFullYear(B.getFullYear()+F);break;case"2 Yearly":B.setFullYear(B.getFullYear()+F*2);break;case"3 Yearly":B.setFullYear(B.getFullYear()+F*3);break;default:return null}const X=B.getFullYear(),K=String(B.getMonth()+1).padStart(2,"0"),we=String(B.getDate()).padStart(2,"0");return`${X}-${K}-${we}`};y.useEffect(()=>{Q(null,null,function*(){if(d.maintenance_team){const I=yield Zm.getMaintenanceTeamDetails(d.maintenance_team);I&&m(oe=>Se(ue({},oe),{maintenance_manager:I.maintenance_manager||"",assign_to:I.team_members&&I.team_members.length===1?I.team_members[0]:oe.assign_to}))}else m(I=>Se(ue({},I),{maintenance_manager:"",assign_to:""}))})},[d.maintenance_team]),y.useEffect(()=>{if(d.start_date&&d.periodicity&&d.no_of_pms){const W=Y(d.start_date,d.periodicity,d.no_of_pms);W&&m(I=>Se(ue({},I),{end_date:W}))}},[d.start_date,d.periodicity,d.no_of_pms]);const P=()=>Q(null,null,function*(){const W=yield Zm.getFilterOptions();k(W)}),U=()=>Q(null,null,function*(){const W=yield Zm.getMaintenanceTeams();D(W)}),J=()=>Q(null,null,function*(){b(!0);try{const W=new URLSearchParams;r.company&&W.append("company",r.company),r.custom_modality&&W.append("custom_modality",r.custom_modality),r.custom_manufacturer&&W.append("custom_manufacturer",r.custom_manufacturer),r.custom_device_status&&W.append("custom_device_status",r.custom_device_status),r.custom_model&&W.append("custom_model",r.custom_model),r.department&&W.append("department",r.department);const I=yield fetch(`/api/method/get_assets?${W.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!I.ok)throw new Error(`HTTP error! status: ${I.status}`);const ae=(yield I.json()).message||[];_(ae),c([])}catch(W){console.error("Error fetching assets:",W),alert("Failed to fetch assets: "+(W instanceof Error?W.message:"Unknown error"))}finally{b(!1)}}),ne=(W,I)=>{s(oe=>Se(ue({},oe),{[W]:I||void 0}))},ye=W=>{c(I=>I.includes(W)?I.filter(oe=>oe!==W):[...I,W])},he=()=>{const W=ce();i.length===W.length&&W.length>0?c([]):c(W.map(I=>I.name))},ce=()=>{if(!T)return j;const W=T.toLowerCase();return j.filter(I=>{var oe,ae,F,M,B,X;return((oe=I.asset_name)==null?void 0:oe.toLowerCase().includes(W))||((ae=I.custom_modality)==null?void 0:ae.toLowerCase().includes(W))||((F=I.company)==null?void 0:F.toLowerCase().includes(W))||((M=I.custom_manufacturer)==null?void 0:M.toLowerCase().includes(W))||((B=I.custom_model)==null?void 0:B.toLowerCase().includes(W))||((X=I.custom_device_status)==null?void 0:X.toLowerCase().includes(W))})},se=()=>Q(null,null,function*(){if(i.length===0){alert("Please select at least one asset");return}if(!r.company){alert("Please select a Hospital/Company in the filters first");return}if(!d.pm_for){alert("Please enter a PM Name");return}if(!d.start_date||!d.end_date){alert("Please select start and end dates");return}if(new Date(d.start_date)>new Date(d.end_date)){alert("Start date must be before end date");return}if(!d.assign_to){alert("Please assign the task to a team member. This is required for Asset Maintenance creation.");return}if(window.confirm(`Are you sure you want to create maintenance schedules for ${i.length} asset(s)?`)){g(!0);try{const I=j.filter(F=>i.includes(F.name)).map(F=>({name:F.name,custom_manufacturer:F.custom_manufacturer,custom_model:F.custom_model})),oe={assets:I,start_date:d.start_date,end_date:d.end_date,maintenance_team:d.maintenance_team||void 0,assign_to:d.assign_to||void 0,maintenance_manager:d.maintenance_manager||void 0,periodicity:d.periodicity,maintenance_type:d.maintenance_type,no_of_pms:d.no_of_pms||void 0,pm_for:d.pm_for||void 0,hospital:r.company,modality:r.custom_modality,manufacturer:r.custom_manufacturer,model:r.custom_model,department:d.department||r.department||void 0};console.log("=== DEBUG: Selected Asset Details ===",I),console.log("=== DEBUG: bulkData ===",oe);const ae=yield Zm.createBulkMaintenanceSchedules(oe);R({show:!0,document:ae.document,count:ae.created||i.length,type:"pm_schedule"}),c([]),m({start_date:"",end_date:"",maintenance_team:"",assign_to:"",pm_for:"",maintenance_manager:"",periodicity:"Monthly",maintenance_type:"Preventive",no_of_pms:"",department:""})}catch(I){console.error("Error creating schedules:",I);const oe=I instanceof Error?I.message:"Unknown error";alert(`Failed to create maintenance schedules:
${oe}`)}finally{g(!1)}}}),ee=ce(),te=Object.values(r).some(W=>W);return e.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[e.jsxs("div",{className:"mb-6 flex items-center gap-4",children:[e.jsxs("button",{onClick:()=>a("/ppm-planner"),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[e.jsx(en,{}),e.jsx("span",{children:"Back to PPM Planner"})]}),e.jsx("h1",{className:"text-3xl font-bold text-gray-800 dark:text-white",children:"PPM Planner - Bulk Schedule Generator"})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6 mb-6",children:[e.jsxs("h2",{className:"text-xl font-semibold mb-4 flex items-center gap-2 text-gray-800 dark:text-white",children:[e.jsx(ds,{})," Filter Assets"]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[e.jsx("div",{children:e.jsx(Ut,{label:"Hospital/Company *",doctype:"Company",value:r.company||"",onChange:W=>ne("company",W),placeholder:"Select a hospital/company"})}),e.jsx("div",{children:e.jsx(Ut,{label:"Modality",doctype:"Modality",value:r.custom_modality||"",onChange:W=>ne("custom_modality",W),placeholder:"Leave empty for all modalities"})}),e.jsx("div",{children:e.jsx(Ut,{label:"Manufacturer",doctype:"Manufacturer",value:r.custom_manufacturer||"",onChange:W=>ne("custom_manufacturer",W),placeholder:"Leave empty for all manufacturers"})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Device Status"}),e.jsxs("select",{value:r.custom_device_status||"",onChange:W=>ne("custom_device_status",W.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:"All Statuses"}),e.jsx("option",{value:"Active",children:"Active"}),e.jsx("option",{value:"Inactive",children:"Inactive"}),e.jsx("option",{value:"Under Maintenance",children:"Under Maintenance"}),e.jsx("option",{value:"Decommissioned",children:"Decommissioned"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Model"}),e.jsxs("select",{value:r.custom_model||"",onChange:W=>ne("custom_model",W.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:"Select Model (optional)"}),N.models.map(W=>e.jsx("option",{value:W,children:W},W))]})]}),e.jsx("div",{children:e.jsx(Ut,{label:"Department",doctype:"Department",value:r.department||"",onChange:W=>ne("department",W),placeholder:"Select department (optional)"})})]}),e.jsxs("div",{className:"mt-4 flex gap-3",children:[e.jsx("button",{onClick:J,disabled:p,className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:p?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin"}),"Loading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Js,{}),"Fetch Assets"]})}),te&&e.jsx("button",{onClick:()=>{s({}),_([]),c([])},className:"bg-gray-600 hover:bg-gray-700 text-white px-6 py-2 rounded-lg",children:"Clear Filters"})]})]}),j.length>0&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6 mb-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsxs("h2",{className:"text-xl font-semibold text-gray-800 dark:text-white",children:["Select Assets (",i.length," of ",j.length," selected)"]}),e.jsxs("div",{className:"flex gap-3 items-center",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Js,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",placeholder:"Search assets...",value:T,onChange:W=>E(W.target.value),className:"pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsx("button",{onClick:he,className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 px-4 py-2 border border-blue-600 dark:border-blue-400 rounded-lg",children:i.length===ee.length&&ee.length>0?"Deselect All":"Select All"})]})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto border border-gray-200 dark:border-gray-700 rounded-lg",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 sticky top-0",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:e.jsx("input",{type:"checkbox",checked:i.length===ee.length&&ee.length>0,onChange:he,className:"rounded"})}),e.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Asset Name"}),e.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Modality"}),e.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Manufacturer"}),e.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Model"}),e.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Status"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:ee.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"p-6 text-center text-gray-500 dark:text-gray-400",children:"No assets match your search criteria"})}):ee.map(W=>e.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors ${i.includes(W.name)?"bg-blue-50 dark:bg-blue-900/20":""}`,children:[e.jsx("td",{className:"p-3",children:e.jsx("input",{type:"checkbox",checked:i.includes(W.name),onChange:()=>ye(W.name),className:"rounded"})}),e.jsx("td",{className:"p-3 text-sm text-gray-900 dark:text-white font-medium",children:W.asset_name}),e.jsx("td",{className:"p-3 text-sm text-gray-700 dark:text-gray-300",children:W.custom_modality||"-"}),e.jsx("td",{className:"p-3 text-sm text-gray-700 dark:text-gray-300",children:W.custom_manufacturer||"-"}),e.jsx("td",{className:"p-3 text-sm text-gray-700 dark:text-gray-300",children:W.custom_model||"-"}),e.jsx("td",{className:"p-3 text-sm",children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${W.custom_device_status==="Active"?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":W.custom_device_status==="Inactive"?"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400":"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}`,children:W.custom_device_status||"-"})})]},W.name))})]})})]}),i.length>0&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6 mb-6",children:[e.jsxs("h2",{className:"text-xl font-semibold mb-4 flex items-center gap-2 text-gray-800 dark:text-white",children:[e.jsx(Qm,{})," Schedule Configuration"]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"PPM Name *"}),e.jsx("input",{type:"text",value:d.pm_for,onChange:W=>m(I=>Se(ue({},I),{pm_for:W.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Enter PM Name",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"First PPM Date *"}),e.jsx("input",{type:"date",value:d.start_date,onChange:W=>m(I=>Se(ue({},I),{start_date:W.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Periodicity *"}),e.jsxs("select",{value:d.periodicity,onChange:W=>m(I=>Se(ue({},I),{periodicity:W.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"Daily",children:"Daily"}),e.jsx("option",{value:"Weekly",children:"Weekly"}),e.jsx("option",{value:"Monthly",children:"Monthly"}),e.jsx("option",{value:"Quarterly",children:"Quarterly"}),e.jsx("option",{value:"Half-yearly",children:"Half-yearly"}),e.jsx("option",{value:"Yearly",children:"Yearly"}),e.jsx("option",{value:"2 Yearly",children:"2 Yearly"}),e.jsx("option",{value:"3 Yearly",children:"3 Yearly"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Maintenance Type"}),e.jsxs("select",{value:d.maintenance_type,onChange:W=>m(I=>Se(ue({},I),{maintenance_type:W.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"Preventive",children:"Preventive"}),e.jsx("option",{value:"Corrective",children:"Corrective"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"No. of PMs"}),e.jsx("input",{type:"number",value:d.no_of_pms,onChange:W=>m(I=>Se(ue({},I),{no_of_pms:W.target.value})),min:"1",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Enter number of PMs"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"End date will be auto-calculated"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Last PPM Date *"}),e.jsx("input",{type:"date",value:d.end_date,onChange:W=>m(I=>Se(ue({},I),{end_date:W.target.value})),min:d.start_date,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0})]}),e.jsxs("div",{children:[e.jsx(Ut,{label:"Maintenance Team",doctype:"Asset Maintenance Team",value:d.maintenance_team,onChange:W=>m(I=>Se(ue({},I),{maintenance_team:W}))}),d.maintenance_manager&&e.jsxs("div",{className:"mt-2 p-2 bg-blue-50 dark:bg-blue-900/20 rounded text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("span",{className:"font-medium",children:"Maintenance Manager:"})," ",d.maintenance_manager]})]}),e.jsxs("div",{children:[e.jsx(Ut,{label:"Assign To *",doctype:"User",value:d.assign_to,onChange:W=>m(I=>Se(ue({},I),{assign_to:W})),placeholder:d.maintenance_team?"Select user (auto-selected if only one team member)":"Select user to assign tasks"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"Required for Asset Maintenance creation"}),d.assign_to&&e.jsxs("div",{className:"mt-1 p-2 bg-green-50 dark:bg-green-900/20 rounded text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("span",{className:"font-medium",children:"Assigned To:"})," ",d.assign_to]})]}),e.jsx("div",{children:e.jsx(Ut,{label:"Department",doctype:"Department",value:d.department,onChange:W=>m(I=>Se(ue({},I),{department:W})),placeholder:"Select department (optional)"})})]}),e.jsx("button",{onClick:se,disabled:h||!d.start_date||!d.end_date||!d.pm_for||!d.assign_to,className:"mt-6 bg-green-600 hover:bg-green-700 text-white px-6 py-3 rounded-lg flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed font-medium",children:h?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin"}),"Creating Schedules..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ea,{}),"Generate Maintenance Schedules (",i.length," asset",i.length!==1?"s":"",")"]})})]}),j.length===0&&!p&&!(O!=null&&O.show)&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-12 text-center",children:[e.jsx(ds,{className:"mx-auto text-4xl text-gray-400 dark:text-gray-600 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-700 dark:text-gray-300 mb-2",children:"No Assets Loaded"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:'Use the filters above to search for assets, then click "Fetch Assets" to load them.'}),e.jsx("p",{className:"text-sm text-blue-600 dark:text-blue-400",children:"Note: Only submitted assets without existing maintenance schedules will be shown."})]}),(O==null?void 0:O.show)&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl max-w-lg w-full p-6",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(ea,{className:"text-green-600 dark:text-green-400 text-3xl"})}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:"Schedules Created Successfully!"}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400",children:[O.count," maintenance schedule",O.count!==1?"s":""," have been created."]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"What was created:"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Document:"}),e.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-400",children:O.document})]}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["A PM Schedule Generator document has been created with ",O.count," asset(s). Frappe will automatically create Asset Maintenance Logs when the document is submitted. You can view and manage it in the PPM Planner section."]})]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[O.document&&e.jsxs("button",{onClick:()=>{a(`/ppm-planner/${O.document}`),R(null)},className:"w-full bg-blue-600 hover:bg-blue-700 text-white px-4 py-3 rounded-lg font-medium text-center flex items-center justify-center gap-2",children:[e.jsx(Qm,{}),"View PPM Planner"]}),e.jsxs("button",{onClick:()=>a("/maintenance-calendar"),className:"w-full bg-purple-600 hover:bg-purple-700 text-white px-4 py-3 rounded-lg font-medium flex items-center justify-center gap-2",children:[e.jsx(Qm,{}),"View Calendar"]}),e.jsx("button",{onClick:()=>R(null),className:"w-full bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 px-4 py-3 rounded-lg font-medium",children:"Create More Schedules"})]})]})})]})};function Ep(t={},a=20,r=0,s="creation desc",i={}){const[c,d]=y.useState([]),[m,h]=y.useState(0),[g,p]=y.useState(!1),[b,j]=y.useState(!0),[_,N]=y.useState(null),[k,C]=y.useState(0),D=JSON.stringify(t),T=JSON.stringify(i);y.useEffect(()=>{let O=!1;const R=D,Y=T,P=a,U=r,J=s;return Q(null,null,function*(){try{j(!0),N(null);let ye={},he={};try{ye=R?JSON.parse(R):{}}catch(ee){ye={}}try{he=Y?JSON.parse(Y):{}}catch(ee){he={}}const ce=ue(ue({},ye),he),se=yield mt.apiCall("/api/method/asset_lite.api.ppm_generator_api.get_pm_schedules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filters:JSON.stringify(ce),limit:P,offset:U,order_by:J,include_child_tables:!0,fields:JSON.stringify(["name","pm_for","hospital","modality","periodicity","start_date","end_date","due_date"])})});if(!O){const ee=(se==null?void 0:se.message)||se;if(ee&&ee.pm_schedules){const te=ee.pm_schedules||[];if(console.log("[usePMSchedules] Loaded",te.length,"PM Schedules"),te.length>0){const W=te[0];console.log("[usePMSchedules] 🔍 FIRST SCHEDULE FIELDS:",{name:W.name,pm_for:W.pm_for,"pm_for (bracket)":W.pm_for,allKeys:Object.keys(W),allKeysList:Object.keys(W).join(", "),fullObject:W})}d(te),h(ee.total_count||0),p(ee.has_more||!1)}else console.warn("[usePMSchedules] No pm_schedules in response:",se),d([]),h(0),p(!1)}}catch(ye){O||(console.error("Error fetching PM Schedules:",ye),N(ye instanceof Error?ye.message:"Failed to fetch PM Schedules"),d([]),h(0))}finally{O||j(!1)}}),()=>{O=!0}},[D,T,a,r,s,k]);const E=y.useCallback(()=>{C(O=>O+1)},[]);return{pmSchedules:c,totalCount:m,hasMore:g,loading:b,error:_,refetch:E}}function TL(t){const[a,r]=y.useState(null),[s,i]=y.useState(!0),[c,d]=y.useState(null),m=y.useCallback(()=>Q(null,null,function*(){if(!t){r(null),i(!1);return}i(!0),d(null);try{const h=yield mt.apiCall("/api/method/asset_lite.api.ppm_generator_api.get_pm_schedule_details",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_name:t})});if(console.log("[usePMScheduleDetails] API Response:",h),h&&h.name&&!h.error)console.log("[usePMScheduleDetails] Setting PM Schedule:",h),r(h);else{const g=(h==null?void 0:h.error)||"PM Schedule not found";console.warn("[usePMScheduleDetails] Error or not found:",g),d(g),r(null)}}catch(h){console.error("Error fetching PM Schedule details:",h),d(h instanceof Error?h.message:"Failed to fetch PM Schedule"),r(null)}finally{i(!1)}}),[t]);return y.useEffect(()=>{m()},[m]),{pmSchedule:a,loading:s,error:c,refetch:m}}function rj(){const[t,a]=y.useState(!1);return{createPMSchedule:p=>Q(null,null,function*(){a(!0);try{const b=yield mt.apiCall("/api/method/asset_lite.api.ppm_generator_api.create_pm_schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_data:JSON.stringify(p)})});if(b!=null&&b.success)return b.pm_schedule;throw new Error((b==null?void 0:b.error)||"Failed to create PM Schedule")}finally{a(!1)}}),updatePMSchedule:(p,b)=>Q(null,null,function*(){a(!0);try{const j=yield mt.apiCall("/api/method/asset_lite.api.ppm_generator_api.update_pm_schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_name:p,pm_schedule_data:JSON.stringify(b)})});if(j!=null&&j.success)return j.pm_schedule;throw new Error((j==null?void 0:j.error)||"Failed to update PM Schedule")}finally{a(!1)}}),deletePMSchedule:p=>Q(null,null,function*(){a(!0);try{const b=yield mt.apiCall("/api/method/asset_lite.api.ppm_generator_api.delete_pm_schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_name:p})});if(!(b!=null&&b.success))throw new Error((b==null?void 0:b.error)||"Failed to delete PM Schedule")}finally{a(!1)}}),submitPMSchedule:p=>Q(null,null,function*(){a(!0);try{const b=yield mt.apiCall("/api/method/asset_lite.api.ppm_generator_api.submit_pm_schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_name:p})});if(b!=null&&b.success)return b.pm_schedule;throw new Error((b==null?void 0:b.error)||"Failed to submit PM Schedule")}finally{a(!1)}}),cancelPMSchedule:p=>Q(null,null,function*(){a(!0);try{const b=yield mt.apiCall("/api/method/asset_lite.api.ppm_generator_api.cancel_pm_schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_name:p})});if(b!=null&&b.success)return b.pm_schedule;throw new Error((b==null?void 0:b.error)||"Failed to cancel PM Schedule")}finally{a(!1)}}),addMaintenanceEntry:(p,b)=>Q(null,null,function*(){a(!0);try{const j=yield mt.apiCall("/api/method/asset_lite.api.ppm_generator_api.add_maintenance_entry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_name:p,entry_data:JSON.stringify(b)})});if(j!=null&&j.success)return j.maintenance_entries;throw new Error((j==null?void 0:j.error)||"Failed to add maintenance entry")}finally{a(!1)}}),removeMaintenanceEntry:(p,b)=>Q(null,null,function*(){a(!0);try{const j=yield mt.apiCall("/api/method/asset_lite.api.ppm_generator_api.remove_maintenance_entry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_name:p,entry_name:b})});if(j!=null&&j.success)return j.maintenance_entries;throw new Error((j==null?void 0:j.error)||"Failed to remove maintenance entry")}finally{a(!1)}}),updateMaintenanceEntry:(p,b,j)=>Q(null,null,function*(){a(!0);try{const _=yield mt.apiCall("/api/method/asset_lite.api.ppm_generator_api.update_maintenance_entry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pm_schedule_name:p,entry_name:b,entry_data:JSON.stringify(j)})});if(_!=null&&_.success)return _.maintenance_entries;throw new Error((_==null?void 0:_.error)||"Failed to update maintenance entry")}finally{a(!1)}}),loading:t}}const EL=({isOpen:t,onClose:a,selectedCount:r,totalCount:s,pageCount:i,onExport:c,isExporting:d,exportColumns:m})=>{const{t:h}=ca(),[g,p]=y.useState(r>0?"selected":"all_with_filters"),[b,j]=y.useState("csv"),[_,N]=y.useState(m.filter(T=>T.default).map(T=>T.key));y.useEffect(()=>{r>0?p("selected"):p("all_with_filters")},[r]);const k=T=>{N(E=>E.includes(T)?E.filter(O=>O!==T):[...E,T])},C=()=>{N(m.map(T=>T.key))},D=()=>{N(m.filter(T=>T.default).map(T=>T.key))};return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] overflow-hidden animate-scale-in",children:[e.jsx("div",{className:"bg-gradient-to-r from-green-500 to-green-600 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Os,{className:"text-white text-xl"}),e.jsx("h3",{className:"text-lg font-semibold text-white",children:h("ppmPlanner.export.title")})]}),e.jsx("button",{onClick:a,className:"text-white/80 hover:text-white transition-colors",disabled:d,children:e.jsx(wt,{size:20})})]})}),e.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:h("ppmPlanner.export.selectData")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="selected"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"} ${r===0?"opacity-50 cursor-not-allowed":""}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"selected",checked:g==="selected",onChange:()=>p("selected"),disabled:r===0,className:"text-green-600 focus:ring-green-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("ppmPlanner.export.selectedRows")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("ppmPlanner.export.selectedCount",{count:r})})]}),r>0&&e.jsxs("span",{className:"bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300 px-2 py-1 rounded text-xs font-medium",children:[r," ",h("common.selected")]})]}),e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="all_on_page"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:g==="all_on_page",onChange:()=>p("all_on_page"),className:"text-green-600 focus:ring-green-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("ppmPlanner.export.currentPage")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("ppmPlanner.export.currentPageCount",{count:i})})]}),e.jsxs("span",{className:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 px-2 py-1 rounded text-xs font-medium",children:[i," ",h("common.rows")]})]}),e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="all_with_filters"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:g==="all_with_filters",onChange:()=>p("all_with_filters"),className:"text-green-600 focus:ring-green-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("ppmPlanner.export.allWithFilters")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("ppmPlanner.export.allWithFiltersCount",{count:s})})]}),e.jsxs("span",{className:"bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300 px-2 py-1 rounded text-xs font-medium",children:[s," ",h("common.total")]})]})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:h("listPages.exportFormat")}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${b==="csv"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"format",value:"csv",checked:b==="csv",onChange:()=>j("csv"),className:"text-green-600 focus:ring-green-500"}),e.jsx(Bi,{className:"text-green-600 text-xl"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("listPages.csv")}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("ppmPlanner.export.csvDesc")})]})]}),e.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${b==="excel"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"format",value:"excel",checked:b==="excel",onChange:()=>j("excel"),className:"text-green-600 focus:ring-green-500"}),e.jsx(Ui,{className:"text-green-700 text-xl"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("listPages.excel")}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("ppmPlanner.export.excelDesc")})]})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:h("ppmPlanner.export.columnsToExport")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:C,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("ppmPlanner.export.selectAll")}),e.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),e.jsx("button",{onClick:D,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("ppmPlanner.export.resetToDefault")})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2 max-h-48 overflow-y-auto p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg",children:m.map(T=>e.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${_.includes(T.key)?"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-400"}`,children:[e.jsx("input",{type:"checkbox",checked:_.includes(T.key),onChange:()=>k(T.key),className:"rounded text-green-600 focus:ring-green-500"}),e.jsx("span",{className:"text-sm truncate",children:T.label})]},T.key))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:h("ppmPlanner.export.columnsSelected",{count:_.length})})]})]}),e.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[g==="selected"&&h("ppmPlanner.export.exportingSelected",{count:r}),g==="all_on_page"&&h("ppmPlanner.export.exportingPage",{count:i}),g==="all_with_filters"&&h("ppmPlanner.export.exportingAll",{count:s})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",disabled:d,children:h("common.cancel")}),e.jsx("button",{onClick:()=>c(g,b,_),disabled:_.length===0||d,className:"px-4 py-2 text-sm font-medium text-white bg-green-600 hover:bg-green-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:d?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),h("ppmPlanner.export.exporting")]}):e.jsxs(e.Fragment,{children:[e.jsx(po,{}),h("ppmPlanner.export.exportButton")]})})]})]})]})}):null},AL=({isOpen:t,onClose:a,selectedItems:r,onPrint:s,isPrinting:i})=>{const{t:c}=ca(),[d,m]=y.useState(""),[h,g]=y.useState(!0),[p,b]=y.useState(""),[j,_]=y.useState("A4"),[N,k]=y.useState([]),[C,D]=y.useState([]),[T,E]=y.useState(!1);y.useEffect(()=>{t&&(O(),R())},[t]);const O=()=>Q(null,null,function*(){E(!0);try{const J=((yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Print Format",filters:{doc_type:"PM Schedule Generator",disabled:0},fields:["name"],limit_page_length:0})})).json()).message||[]).map(ne=>ne.name);k(J),J.length>0&&!d&&m(J[0])}catch(P){console.error("Error fetching print formats:",P)}finally{E(!1)}}),R=()=>Q(null,null,function*(){try{const J=((yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Letter Head",filters:{disabled:0},fields:["name"],limit_page_length:0})})).json()).message||[]).map(ne=>ne.name);D(J),J.length>0&&!p&&b(J[0])}catch(P){console.error("Error fetching letterheads:",P)}}),Y=()=>{if(!d){alert("Please select a print format");return}s(d,p,!h,j)};return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-lg w-full max-h-[90vh] overflow-hidden animate-scale-in",children:[e.jsx("div",{className:"bg-gradient-to-r from-purple-500 to-purple-600 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Fi,{className:"text-white text-xl"}),e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Print PM Schedules"})]}),e.jsx("button",{onClick:a,className:"text-white/80 hover:text-white transition-colors",disabled:i,children:e.jsx(wt,{size:20})})]})}),e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"mb-6 p-4 bg-purple-50 dark:bg-purple-900/20 rounded-lg border border-purple-200 dark:border-purple-700",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Es,{className:"text-purple-600 dark:text-purple-400"}),e.jsxs("span",{className:"font-medium text-purple-800 dark:text-purple-300",children:[r.length," schedule",r.length!==1?"s":""," selected for printing"]})]}),e.jsxs("div",{className:"mt-2 text-sm text-purple-600 dark:text-purple-400 max-h-20 overflow-y-auto",children:[r.slice(0,5).join(", "),r.length>5&&` and ${r.length-5} more...`]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Print Format ",e.jsx("span",{className:"text-red-500",children:"*"})]}),T?e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-purple-500"}),"Loading formats..."]}):N.length===0?e.jsx("div",{className:"text-amber-600 dark:text-amber-400 text-sm p-3 bg-amber-50 dark:bg-amber-900/20 rounded-lg",children:"No print formats found for PM Schedule Generator. Please create one in ERPNext."}):e.jsxs("select",{value:d,onChange:P=>m(P.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:"Select Print Format"}),N.map(P=>e.jsx("option",{value:P,children:P},P))]})]}),e.jsx("div",{className:"mb-4",children:e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:h,onChange:P=>g(P.target.checked),className:"rounded text-purple-600 focus:ring-purple-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Use Letterhead"})]})}),h&&e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Letterhead"}),e.jsxs("select",{value:p,onChange:P=>b(P.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:"Default Letterhead"}),C.map(P=>e.jsx("option",{value:P,children:P},P))]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Page Size"}),e.jsxs("select",{value:j,onChange:P=>_(P.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"A4",children:"A4"}),e.jsx("option",{value:"Letter",children:"Letter"}),e.jsx("option",{value:"A3",children:"A3"}),e.jsx("option",{value:"A5",children:"A5"}),e.jsx("option",{value:"Legal",children:"Legal"})]})]})]}),e.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-end gap-3",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",disabled:i,children:"Cancel"}),e.jsx("button",{onClick:Y,disabled:!d||i||r.length===0,className:"px-4 py-2 text-sm font-medium text-white bg-purple-600 hover:bg-purple-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:i?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Preparing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Fi,{}),"Print ",r.length," Schedule",r.length!==1?"s":""]})})]})]})}):null},OL=()=>{const{t}=ca(),a=qa(),[r]=Qs(),[s,i]=y.useState(0),[c,d]=y.useState(""),[m,h]=y.useState(null),[g,p]=y.useState(null),b=y.useRef(null),[j,_]=y.useState(!1),[N,k]=y.useState(()=>r.get("date_filter_by")||""),[C,D]=y.useState(()=>r.get("date_start")||""),[T,E]=y.useState(()=>r.get("date_end")||""),[O,R]=y.useState(""),[Y,P]=y.useState(""),[U,J]=y.useState(""),[ne,ye]=y.useState(""),he=["creation desc","creation asc","modified desc","modified asc","name asc","name desc","pm_for asc","pm_for desc"],[ce,se]=y.useState(()=>r.get("sort_by")||"creation desc"),[ee,te]=y.useState(new Set),[W,I]=y.useState(!1),[oe,ae]=y.useState(!1),[F,M]=y.useState(!1),[B,X]=y.useState(!1),K=20,we=[{key:"name",label:t("commonFields.pmId"),default:!0},{key:"pm_for",label:t("commonFields.name"),default:!0},{key:"hospital",label:t("commonFields.hospital"),default:!0},{key:"modality",label:t("commonFields.modality"),default:!0},{key:"manufacturer",label:t("commonFields.manufacturer"),default:!0},{key:"periodicity",label:t("ppm.periodicity"),default:!0},{key:"maintenance_team",label:"Maintenance Team",default:!1},{key:"docstatus",label:t("commonFields.status"),default:!0},{key:"creation",label:t("commonFields.createdOn"),default:!1},{key:"modified",label:t("commonFields.modifiedOn"),default:!1},{key:"owner",label:t("commonFields.createdBy"),default:!1},{key:"modified_by",label:t("commonFields.modifiedBy"),default:!1}],be=y.useMemo(()=>{const ve={};return O&&(ve.hospital=O),Y&&(ve.modality=Y),U&&(ve.manufacturer=U),ne&&(ve.periodicity=ne),Object.assign(ve,el(N,C,T)),ve},[O,Y,U,ne,N,C,T]),ke=he.includes(ce)?ce:"creation desc",{pmSchedules:Me,totalCount:z,hasMore:Ne,loading:Xe,error:gt,refetch:St}=Ep(be,K,s*K,ke),{deletePMSchedule:Ht,loading:Mt}=rj();y.useEffect(()=>{const ve=Oe=>{b.current&&!b.current.contains(Oe.target)&&p(null)};return g&&document.addEventListener("mousedown",ve),()=>{document.removeEventListener("mousedown",ve)}},[g]),y.useEffect(()=>{te(new Set)},[O,Y,U,ne,N,C,T,c,s]);const Te=Me.filter(ve=>{var ht,et,Be,kt,it,xt;if(!c)return!0;const Oe=c.toLowerCase();return((ht=ve.name)==null?void 0:ht.toLowerCase().includes(Oe))||((et=ve.pm_for)==null?void 0:et.toLowerCase().includes(Oe))||((Be=ve.hospital)==null?void 0:Be.toLowerCase().includes(Oe))||((kt=ve.modality)==null?void 0:kt.toLowerCase().includes(Oe))||((it=ve.manufacturer)==null?void 0:it.toLowerCase().includes(Oe))||((xt=ve.maintenance_team)==null?void 0:xt.toLowerCase().includes(Oe))}),Qt=()=>{ee.size===Te.length?te(new Set):te(new Set(Te.map(ve=>ve.name)))},zt=Te.length>0&&ee.size===Te.length,Wt=ee.size>0&&ee.size<Te.length,Vt=ve=>{te(Oe=>{const ht=new Set(Oe);return ht.has(ve)?ht.delete(ve):ht.add(ve),ht})},va=y.useCallback(()=>Q(null,null,function*(){const ve=[];let Oe=0;const ht=100;let et=!0;const Be=Ks(be);for(;et;)try{const xt=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"PM Schedule Generator",filters:Be.length>0?Be:{},fields:["*"],limit_start:Oe*ht,limit_page_length:ht,order_by:"creation desc"})})).json()).message||[];ve.push(...xt),xt.length<ht?et=!1:Oe++,Oe>100&&(console.warn("Export safety limit reached"),et=!1)}catch(kt){throw console.error("Error fetching schedules for export:",kt),kt}return ve}),[be]),ta=(ve,Oe,ht)=>Q(null,null,function*(){ae(!0);try{let et=[];switch(ve){case"selected":et=Te.filter(it=>ee.has(it.name));break;case"all_on_page":et=Te;break;case"all_with_filters":et=yield va();break}if(et.length===0){alert("No data to export");return}const Be=et.map(it=>{const xt=ue({},it);if(ht.includes("docstatus")){const Dt=Ze(it);xt.docstatus=Dt===1?"Submitted":Dt===2?"Cancelled":"Draft"}return xt}),kt=ht.map(it=>{const xt=we.find(Dt=>Dt.key===it);return(xt==null?void 0:xt.label)||it});if(Oe==="csv"){const it=[kt.join(","),...Be.map(Rt=>ht.map(De=>{let Qe=Rt[De]||"";return typeof Qe=="string"&&(Qe.includes(",")||Qe.includes('"')||Qe.includes(`
`))&&(Qe=`"${Qe.replace(/"/g,'""')}"`),Qe}).join(","))].join(`
`),xt=new Blob(["\uFEFF"+it],{type:"text/csv;charset=utf-8;"}),Dt=URL.createObjectURL(xt),Ot=document.createElement("a");Ot.href=Dt,Ot.download=`ppm_schedules_export_${new Date().toISOString().split("T")[0]}.csv`,Ot.click(),URL.revokeObjectURL(Dt)}else if(Oe==="excel"){const it=[kt,...Be.map(Ot=>ht.map(Rt=>Ot[Rt]||""))],xt=Ja.aoa_to_sheet(it),Dt=Ja.book_new();Ja.book_append_sheet(Dt,xt,"PPM Schedules"),$i(Dt,`ppm_schedules_export_${new Date().toISOString().split("T")[0]}.xlsx`)}I(!1),te(new Set)}catch(et){console.error("Export failed:",et),alert(`Export failed: ${et instanceof Error?et.message:"Unknown error"}`)}finally{ae(!1)}}),sa=(ve,Oe,ht,et)=>{X(!0);try{const Be=Array.from(ee);if(Be.length===0){alert("No schedules selected for printing");return}const kt=window.location.origin,it=new URLSearchParams;it.append("doctype","PM Schedule Generator"),it.append("name",JSON.stringify(Be)),it.append("format",ve),it.append("no_letterhead",ht?"1":"0"),Oe&&!ht&&it.append("letterhead",Oe),it.append("options",JSON.stringify({"page-size":et}));const xt=`${kt}/api/method/frappe.utils.print_format.download_multi_pdf?${it.toString()}`;window.open(xt,"_blank"),M(!1)}catch(Be){console.error("Print failed:",Be),alert(`Print failed: ${Be instanceof Error?Be.message:"Unknown error"}`)}finally{X(!1)}},ra=()=>{a("/ppm-planner/new")},Ye=ve=>{a(`/ppm-planner/${ve}`)},ft=ve=>{a(`/ppm-planner/${ve}`)},$t=ve=>Q(null,null,function*(){try{yield Ht(ve),St(),h(null)}catch(Oe){console.error("Error deleting PM Schedule:",Oe),alert("Failed to delete PM Schedule")}}),na=()=>{k(""),D(""),E(""),R(""),P(""),J(""),ye(""),se("creation desc"),i(0)},Ze=ve=>{var Oe;return ve.docstatus!==void 0?Number(ve.docstatus):((Oe=ve.maintenance_entries)==null?void 0:Oe.length)>0?Number(ve.maintenance_entries[0].docstatus):0},lt=N&&(C||T),aa=lt||O||Y||U||ne,Ie=[lt?"date":"",O,Y,U,ne].filter(Boolean).length,Nt=Math.ceil(z/K);return e.jsxs("div",{className:"flex flex-col h-screen bg-gray-50 dark:bg-gray-900",children:[e.jsxs("div",{className:"flex-shrink-0 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 px-4 py-3 lg:px-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(go,{className:"text-blue-600 dark:text-blue-400",size:24}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-gray-800 dark:text-white",children:t("sidebar.ppmPlanner")}),e.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:[t("ppm.manageSchedules"),ee.size>0&&e.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",ee.size," selected"]})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>I(!0),className:"px-3 py-1.5 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors flex items-center gap-2 text-sm",disabled:z===0,children:[e.jsx(Os,{}),e.jsx("span",{children:t("listPages.export")}),ee.size>0&&e.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:ee.size})]}),e.jsxs("button",{onClick:()=>M(!0),className:"px-3 py-1.5 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors flex items-center gap-2 text-sm disabled:opacity-50 disabled:cursor-not-allowed",disabled:ee.size===0,title:ee.size===0?"Select schedules to print":`Print ${ee.size} selected`,children:[e.jsx(Fi,{}),e.jsx("span",{children:"Print"}),ee.size>0&&e.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:ee.size})]}),e.jsxs("button",{onClick:ra,className:"px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors flex items-center gap-2 text-sm",children:[e.jsx(Zs,{}),e.jsx("span",{children:t("ppm.addPPM")})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Js,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400",size:14}),e.jsx("input",{type:"text",placeholder:t("listPages.searchPlaceholder"),value:c,onChange:ve=>d(ve.target.value),className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("button",{onClick:()=>_(!j),className:`px-3 py-1.5 border rounded-lg transition-colors flex items-center gap-2 text-sm ${aa?"border-blue-500 bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400":"border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:[e.jsx(ds,{}),e.jsx("span",{children:t("listPages.filters")}),Ie>0&&e.jsx("span",{className:"bg-blue-600 text-white rounded-full w-5 h-5 flex items-center justify-center text-xs",children:Ie}),j?e.jsx(As,{}):e.jsx(cs,{})]})]}),j&&e.jsxs("div",{className:"mt-3 p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg border border-gray-200 dark:border-gray-600",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:t("filters.sortBy")}),e.jsxs("select",{value:ce,onChange:ve=>{se(ve.target.value),i(0)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"creation desc",children:t("filters.sortCreationNewest")}),e.jsx("option",{value:"creation asc",children:t("filters.sortCreationOldest")}),e.jsx("option",{value:"modified desc",children:t("filters.sortModifiedNewest")}),e.jsx("option",{value:"modified asc",children:t("filters.sortModifiedOldest")}),e.jsx("option",{value:"name asc",children:t("filters.sortNameAsc")}),e.jsx("option",{value:"name desc",children:t("filters.sortNameDesc")}),e.jsx("option",{value:"pm_for asc",children:t("filters.sortNameAsc")}),e.jsx("option",{value:"pm_for desc",children:t("filters.sortNameDesc")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:t("filters.filterBy")}),e.jsxs("select",{value:N,onChange:ve=>{const Oe=ve.target.value;k(Oe),i(0)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("filters.filterBy")}),e.jsx("option",{value:"creation",children:t("filters.createdDate")}),e.jsx("option",{value:"modified",children:t("filters.latestModifiedDate")})]})]}),N&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:t("filters.startDate")}),e.jsx("input",{type:"date",value:C,onChange:ve=>{const Oe=ve.target.value;D(Oe),T&&Oe>T&&E(Oe),i(0)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:t("filters.endDate")}),e.jsx("input",{type:"date",value:T,onChange:ve=>{E(ve.target.value),i(0)},min:C||void 0,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),e.jsx("div",{children:e.jsx(Ut,{label:t("commonFields.hospital"),doctype:"Company",value:O,onChange:R,placeholder:t("filters.allHospitals"),filters:{domain:"Healthcare"}})}),e.jsx("div",{children:e.jsx(Ut,{label:t("commonFields.modality"),doctype:"Modality",value:Y,onChange:P,placeholder:t("filters.allModalities"),filters:{}})}),e.jsx("div",{children:e.jsx(Ut,{label:t("commonFields.manufacturer"),doctype:"Manufacturer",value:U,onChange:J,placeholder:t("filters.allManufacturers"),filters:{}})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:t("ppm.periodicity")}),e.jsxs("select",{value:ne,onChange:ve=>ye(ve.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("listPages.all")}),e.jsx("option",{value:"Daily",children:"Daily"}),e.jsx("option",{value:"Weekly",children:"Weekly"}),e.jsx("option",{value:"Monthly",children:"Monthly"}),e.jsx("option",{value:"Quarterly",children:"Quarterly"}),e.jsx("option",{value:"Half-yearly",children:"Half-yearly"}),e.jsx("option",{value:"Yearly",children:"Yearly"})]})]})]}),aa&&e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsxs("button",{onClick:na,className:"px-4 py-2 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 flex items-center gap-2",children:[e.jsx(wt,{}),t("listPages.clearFilters")]})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto p-4 lg:p-5",children:Xe&&s===0?e.jsxs("div",{className:"flex items-center justify-center h-full",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"}),e.jsx("span",{className:"ml-3 text-gray-600 dark:text-gray-400",children:t("listPages.loading")})]}):gt?e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:e.jsx("p",{className:"text-red-600 dark:text-red-400",children:gt})}):Te.length===0?e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-8 text-center",children:[e.jsx(go,{className:"mx-auto text-gray-400 mb-4",size:48}),e.jsx("h3",{className:"text-lg font-semibold text-gray-700 dark:text-gray-300 mb-2",children:t("listPages.noResults")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:t(c||aa?"listPages.tryAdjustingFilters":"listPages.getStartedCreateFirst")}),!c&&!aa&&e.jsx("button",{onClick:ra,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors",children:t("ppm.addPPM")})]}):e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden",children:[e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left",children:e.jsx("button",{onClick:Qt,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:zt?"Deselect all":"Select all",children:zt?e.jsx(Es,{className:"text-blue-600 dark:text-blue-400",size:18}):Wt?e.jsxs("div",{className:"relative",children:[e.jsx(Ar,{size:18}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):e.jsx(Ar,{size:18})})}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:t("commonFields.pmId")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:t("commonFields.name")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:t("commonFields.hospital")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:t("commonFields.modality")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:t("commonFields.manufacturer")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:t("ppm.periodicity")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:t("commonFields.status")}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:t("listPages.actions")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:Te.map(ve=>e.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors ${ee.has(ve.name)?"bg-blue-50 dark:bg-blue-900/20":""}`,children:[e.jsx("td",{className:"px-4 py-4",children:e.jsx("button",{onClick:()=>Vt(ve.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:ee.has(ve.name)?e.jsx(Es,{className:"text-blue-600 dark:text-blue-400",size:18}):e.jsx(Ar,{size:18})})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("button",{onClick:()=>Ye(ve.name),className:"text-blue-600 dark:text-blue-400 hover:underline font-medium",children:ve.name})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:ve.pm_for||"-"}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:ve.hospital||"-"}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:ve.modality||"-"}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:ve.manufacturer||"-"}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:ve.periodicity||"-"}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:(()=>{const Oe=Ze(ve);return e.jsx("span",{className:`px-2 py-1 text-xs font-semibold rounded-full ${Oe===1?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":Oe===0?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400":"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-400"}`,children:Oe===1?"Submitted":Oe===2?"Cancelled":"Draft"})})()}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:e.jsxs("div",{className:"relative inline-block",ref:g===ve.name?b:null,children:[e.jsx("button",{onClick:()=>p(g===ve.name?null:ve.name),className:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 p-2",children:e.jsx(Nu,{})}),g===ve.name&&e.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-white dark:bg-gray-700 rounded-lg shadow-lg border border-gray-200 dark:border-gray-600 z-10",children:[e.jsxs("button",{onClick:()=>{Ye(ve.name),p(null)},className:"w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-600 flex items-center gap-2",children:[e.jsx(ri,{})," ",t("listPages.view")]}),e.jsxs("button",{onClick:()=>{ft(ve.name),p(null)},className:"w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-600 flex items-center gap-2",children:[e.jsx(Fr,{})," ",t("listPages.edit")]}),e.jsxs("button",{onClick:()=>{h(ve.name),p(null)},className:"w-full px-4 py-2 text-left text-sm text-red-600 dark:text-red-400 hover:bg-gray-100 dark:hover:bg-gray-600 flex items-center gap-2",children:[e.jsx(Na,{})," ",t("listPages.delete")]})]})]})})]},ve.name))})]}),Nt>1&&e.jsxs("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[t("listPages.showing")," ",s*K+1," ",t("listPages.to")," ",Math.min((s+1)*K,z)," ",t("listPages.of")," ",z," ",t("listPages.results")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>i(Math.max(0,s-1)),disabled:s===0,className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-700 dark:text-gray-300",children:"Previous"}),e.jsx("button",{onClick:()=>i(s+1),disabled:!Ne,className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-700 dark:text-gray-300",children:"Next"})]})]})]})}),e.jsx(EL,{isOpen:W,onClose:()=>I(!1),selectedCount:ee.size,totalCount:z,pageCount:Te.length,onExport:ta,isExporting:oe,exportColumns:we}),e.jsx(AL,{isOpen:F,onClose:()=>M(!1),selectedItems:Array.from(ee),onPrint:sa,isPrinting:B}),m&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 max-w-md",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:t("confirmations.confirmDelete")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:t("confirmations.cannotUndo")}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>h(null),className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",disabled:Mt,children:t("common.cancel")}),e.jsx("button",{onClick:()=>$t(m),className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors",disabled:Mt,children:t(Mt?"common.deleting":"common.delete")})]})]})}),e.jsx("style",{children:`
@keyframes scale-in {
from {
transform: scale(0.95);
opacity: 0;
}
to {
transform: scale(1);
opacity: 1;
}
}
.animate-scale-in {
animation: scale-in 0.2s ease-out;
}
`})]})},DL=()=>{const{t}=ca(),{scheduleName:a}=xo(),r=qa(),{pmSchedule:s,loading:i,error:c,refetch:d}=TL(a||null),{updatePMSchedule:m,deletePMSchedule:h,submitPMSchedule:g,cancelPMSchedule:p,loading:b}=rj(),{logs:j,refetch:_}=Rh({},1e4,0),[N,k]=y.useState(!1),[C,D]=y.useState(!1),[T,E]=y.useState(!1),[O,R]=y.useState(""),[Y,P]=y.useState(""),[U,J]=y.useState(!1),[ne,ye]=y.useState(!1),[he,ce]=y.useState(new Set),[se,ee]=y.useState(!1),[te,W]=y.useState(!1),[I,oe]=y.useState(new Set),[ae,F]=y.useState([]),[M,B]=y.useState([]),[X,K]=y.useState([]),[we,be]=y.useState(""),[ke,Me]=y.useState({hospital:"",modality:"",device_status:"",start_date:"",end_date:"",maintenance_team:"",maintenance_manager:"",periodicity:"Monthly",assign_to:"",due_date:"",next_pm_date:"",manufacturer:"",model:"",pm_for:"",asset_name:"",no_of_pms:""});y.useEffect(()=>{Q(null,null,function*(){try{const ve=yield(yield fetch("/api/method/frappe.auth.get_logged_user",{method:"GET",credentials:"include"})).json();ve.message&&be(ve.message)}catch(Nt){console.error("Error fetching current user:",Nt)}})},[]),y.useEffect(()=>{if(a){const Ie=localStorage.getItem(`ppm_activity_${a}`);Ie&&K(JSON.parse(Ie))}},[a]),y.useEffect(()=>{if(s!=null&&s.maintenance_entries&&j.length>0){const Ie=[],Nt=[];s.maintenance_entries.forEach(ve=>{j.filter(ht=>ht.asset_name===ve.asset).forEach(ht=>{ht.workflow_state==="Applied"?Nt.push(Se(ue({},ht),{asset_display_name:ve.asset_name||ve.asset})):ht.maintenance_status==="Planned"&&(!ht.workflow_state||ht.workflow_state==="Draft")&&Ie.push(Se(ue({},ht),{asset_display_name:ve.asset_name||ve.asset}))})}),F(Ie),B(Nt)}},[s,j]),y.useEffect(()=>{if(j.length>0&&(s!=null&&s.maintenance_entries)){const Ie=[];if(s.maintenance_entries.forEach(Nt=>{j.filter(Oe=>Oe.asset_name===Nt.asset).forEach(Oe=>{const ht=Oe.maintenance_status==="Planned"&&(!Oe.workflow_state||Oe.workflow_state==="Draft"),et=Oe.workflow_state==="Applied";(ht||et)&&Oe.due_date&&Ie.push(Oe.due_date)})}),Ie.length>0){const Nt=Ie.sort((ve,Oe)=>new Date(ve).getTime()-new Date(Oe).getTime())[0];console.log("📅 Pending due dates:",Ie),console.log("📅 Earliest (Next PM Date):",Nt),Me(ve=>ve.next_pm_date!==Nt?Se(ue({},ve),{next_pm_date:Nt}):ve)}else console.log("📅 No pending entries found - all completed"),Me(Nt=>Se(ue({},Nt),{next_pm_date:""}))}},[s,j]),y.useEffect(()=>{s&&Me({hospital:s.hospital||"",modality:s.modality||"",device_status:s.device_status||"",start_date:s.start_date||"",end_date:s.end_date||"",maintenance_team:s.maintenance_team||"",maintenance_manager:s.maintenance_manager||"",periodicity:s.periodicity||"Monthly",assign_to:s.assign_to||"",due_date:s.due_date||"",next_pm_date:s.next_pm_date||"",manufacturer:s.manufacturer||"",model:s.model||"",pm_for:s.pm_for||"",asset_name:s.asset_name||"",no_of_pms:s.no_of_pms||""})},[s]),y.useEffect(()=>{if(O&&ke.next_pm_date){const Ie=new Date(O),Nt=new Date(ke.next_pm_date);J(Ie<Nt)}else J(!1)},[O,ke.next_pm_date]);const z=(Ie,Nt,ve)=>{if(!Ie||!Nt||!ve)return null;const Oe=parseInt(ve,10);if(isNaN(Oe)||Oe<1)return null;const ht=Oe-1;if(ht<0)return null;const et=new Date(Ie),Be=new Date(et);switch(Nt){case"Daily":Be.setDate(Be.getDate()+ht);break;case"Weekly":Be.setDate(Be.getDate()+ht*7);break;case"Monthly":Be.setMonth(Be.getMonth()+ht);break;case"Quarterly":Be.setMonth(Be.getMonth()+ht*3);break;case"Half-yearly":Be.setMonth(Be.getMonth()+ht*6);break;case"Yearly":Be.setFullYear(Be.getFullYear()+ht);break;case"2 Yearly":Be.setFullYear(Be.getFullYear()+ht*2);break;case"3 Yearly":Be.setFullYear(Be.getFullYear()+ht*3);break;default:return null}const kt=Be.getFullYear(),it=String(Be.getMonth()+1).padStart(2,"0"),xt=String(Be.getDate()).padStart(2,"0");return`${kt}-${it}-${xt}`},Ne=Ie=>{const{name:Nt,value:ve}=Ie.target;Me(Oe=>{const ht=Se(ue({},Oe),{[Nt]:ve});if(Nt==="start_date"||Nt==="periodicity"||Nt==="no_of_pms"){const et=z(Nt==="start_date"?ve:Oe.start_date,Nt==="periodicity"?ve:Oe.periodicity,Nt==="no_of_pms"?ve:Oe.no_of_pms);et&&(ht.end_date=et)}return ht})},Xe=()=>Q(null,null,function*(){if(a)try{yield m(a,ke),k(!1),d(),alert("PPM Planner updated successfully")}catch(Ie){console.error("Error updating PPM Planner:",Ie),alert("Failed to update PPM Planner")}}),gt=()=>Q(null,null,function*(){if(a)try{yield h(a),r(-1)}catch(Ie){console.error("Error deleting PPM Planner:",Ie),alert("Failed to delete PPM Planner")}}),St=()=>Q(null,null,function*(){if(a)try{yield g(a),d(),alert("PPM Planner submitted successfully")}catch(Ie){console.error("Error submitting PPM Planner:",Ie),alert("Failed to submit PPM Planner")}}),Ht=()=>Q(null,null,function*(){if(a)try{yield p(a),d(),alert("PPM Planner cancelled successfully")}catch(Ie){console.error("Error cancelling PPM Planner:",Ie),alert("Failed to cancel PPM Planner")}}),Mt=()=>{if(ae.length===0){alert("No planned maintenance entries found to apply.");return}const Ie=new Date().toISOString().split("T")[0];R(Ie),P(""),ce(new Set(ae.map(Nt=>Nt.name))),E(!0)},Te=Ie=>{ce(Nt=>{const ve=new Set(Nt);return ve.has(Ie)?ve.delete(Ie):ve.add(Ie),ve})},Qt=()=>{ce(new Set(ae.map(Ie=>Ie.name)))},zt=()=>{ce(new Set)},Wt=()=>Q(null,null,function*(){if(!O){alert("Please enter a completion date.");return}if(U&&!Y.trim()){alert("Please provide a reason for early completion.");return}if(he.size===0){alert("Please select at least one entry to complete.");return}ye(!0);try{let Ie=0,Nt=0;const ve=[],Oe=ae.filter(Be=>he.has(Be.name));for(const Be of Oe)try{const kt={maintenance_status:"Completed",workflow_state:"Applied",completion_date:O};U&&Y&&(kt.custom_early_completion_reason=Y,kt.custom_early_completion="Yes");const xt=yield(yield fetch("/api/method/frappe.client.set_value",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:"Asset Maintenance Log",name:Be.name,fieldname:kt})})).json();xt.message?(Ie++,ve.push(Be.name)):(Nt++,console.error(`Failed to apply ${Be.name}:`,xt))}catch(kt){Nt++,console.error(`Error applying ${Be.name}:`,kt)}const et=[{id:Date.now().toString(),user:we||"Unknown User",timestamp:new Date().toISOString(),action:"Applied",entriesCount:Ie,completionDate:O,earlyReason:U?Y:void 0,entries:ve},...X];K(et),a&&localStorage.setItem(`ppm_activity_${a}`,JSON.stringify(et)),E(!1),R(""),P(""),ce(new Set),_(),d(),alert(Nt===0?`Successfully applied ${Ie} maintenance entries. They are now pending approval.`:`Applied ${Ie} entries. Failed to apply ${Nt} entries.`)}catch(Ie){console.error("Error applying entries:",Ie),alert("Failed to apply entries.")}finally{ye(!1)}}),Vt=()=>{if(M.length===0){alert("No entries pending approval.");return}oe(new Set(M.map(Ie=>Ie.name))),ee(!0)},va=Ie=>{oe(Nt=>{const ve=new Set(Nt);return ve.has(Ie)?ve.delete(Ie):ve.add(Ie),ve})},ta=()=>{oe(new Set(M.map(Ie=>Ie.name)))},sa=()=>{oe(new Set)},ra=()=>Q(null,null,function*(){if(I.size===0){alert("Please select at least one entry to approve.");return}W(!0);try{let Ie=0,Nt=0;const ve=[],Oe=M.filter(Be=>I.has(Be.name));for(const Be of Oe)try{const it=yield(yield fetch(`/api/resource/Asset Maintenance Log/${encodeURIComponent(Be.name)}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json();if(!it.data){console.error(`Failed to get document ${Be.name}`),Nt++;continue}const xt=Se(ue({},it.data),{workflow_state:"Approved",docstatus:1}),Ot=yield(yield fetch(`/api/resource/Asset Maintenance Log/${encodeURIComponent(Be.name)}`,{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(xt)})).json();if(Ot.data&&Ot.data.docstatus===1)Ie++,ve.push(Be.name),console.log(`✅ Successfully approved and submitted: ${Be.name}`);else{console.log(`Trying alternative submit method for ${Be.name}...`);const Rt=yield fetch("/api/method/frappe.desk.form.utils.get_next",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:"Asset Maintenance Log",name:Be.name,workflow_action:"Approve"})}),Qe=yield(yield fetch("/api/method/run_doc_method",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({dt:"Asset Maintenance Log",dn:Be.name,method:"submit"})})).json();Qe.message||!Qe.exc?(Ie++,ve.push(Be.name),console.log(`✅ Successfully submitted via run_doc_method: ${Be.name}`)):(Nt++,console.error(`Failed to submit ${Be.name}:`,Qe))}}catch(kt){Nt++,console.error(`Error approving ${Be.name}:`,kt)}const et=[{id:Date.now().toString(),user:we||"Unknown User",timestamp:new Date().toISOString(),action:"Approved",entriesCount:Ie,entries:ve},...X];K(et),a&&localStorage.setItem(`ppm_activity_${a}`,JSON.stringify(et)),ee(!1),oe(new Set),setTimeout(()=>{_(),d()},1e3),alert(Nt===0?`Successfully approved and submitted ${Ie} maintenance entries. New planned entries should be created automatically.`:`Approved ${Ie} entries. Failed to approve ${Nt} entries.`)}catch(Ie){console.error("Error approving entries:",Ie),alert("Failed to approve entries.")}finally{W(!1)}}),Ye=Ie=>{switch(Ie){case"Planned":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400";case"Applied":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400";case"Approved":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},ft=Ie=>j.filter(ve=>ve.asset_name===Ie).filter(ve=>{const Oe=ve.maintenance_status==="Planned"&&(!ve.workflow_state||ve.workflow_state==="Draft"),ht=ve.workflow_state==="Applied";return Oe||ht}),$t=Ie=>ft(Ie).length>0,na=()=>s!=null&&s.maintenance_entries?s.maintenance_entries.filter(Ie=>$t(Ie.asset)):[];if(i)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ya,{className:"animate-spin text-blue-600",size:24}),e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Loading PPM Planner..."})]})});if(c)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[e.jsx("p",{className:"text-red-600 dark:text-red-400",children:c}),e.jsx("button",{onClick:()=>r(-1),className:"mt-4 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors",children:"Back to List"})]})});if(!s)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:[e.jsx("p",{className:"text-yellow-600 dark:text-yellow-400",children:"PPM Planner not found"}),e.jsx("button",{onClick:()=>r(-1),className:"mt-4 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors",children:"Back to List"})]})});const Ze=s.docstatus===0,lt=s.docstatus===1;s.docstatus;const aa=na();return e.jsxs("div",{className:"flex flex-col h-screen bg-gray-50 dark:bg-gray-900",children:[e.jsxs("div",{className:"flex-shrink-0 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 px-6 py-4",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>r(-1),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:e.jsx(en,{className:"text-gray-600 dark:text-gray-400"})}),e.jsx(go,{className:"text-blue-600 dark:text-blue-400",size:28}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:s.name}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"PPM Planner Details"})]}),e.jsx("span",{className:`ml-4 px-3 py-1 text-sm font-semibold rounded-full ${lt?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":Ze?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400":"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-400"}`,children:lt?"Submitted":Ze?"Draft":"Cancelled"})]}),e.jsxs("div",{className:"flex gap-2",children:[lt&&e.jsxs("div",{className:"flex gap-2 mr-4 pr-4 border-r border-gray-300 dark:border-gray-600",children:[ae.length>0&&e.jsxs("button",{onClick:Mt,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors flex items-center gap-2",children:[e.jsx(bi,{}),"Bulk Complete(",ae.length,")"]}),M.length>0&&e.jsxs("button",{onClick:Vt,className:"px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors flex items-center gap-2",children:[e.jsx(X0,{}),"Approve (",M.length,")"]})]}),Ze&&!N&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>k(!0),className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors flex items-center gap-2",children:[e.jsx(Fr,{}),"Edit"]}),e.jsxs("button",{onClick:St,disabled:b,className:"px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50",children:[e.jsx(ea,{}),"Submit"]}),e.jsxs("button",{onClick:()=>D(!0),disabled:b,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50",children:[e.jsx(Na,{}),"Delete"]})]}),N&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:Xe,disabled:b,className:"px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50",children:[b?e.jsx(ya,{className:"animate-spin"}):e.jsx(Or,{}),"Save"]}),e.jsx("button",{onClick:()=>{k(!1),Me({hospital:s.hospital||"",modality:s.modality||"",device_status:s.device_status||"",start_date:s.start_date||"",end_date:s.end_date||"",maintenance_team:s.maintenance_team||"",maintenance_manager:s.maintenance_manager||"",periodicity:s.periodicity||"Monthly",assign_to:s.assign_to||"",due_date:s.due_date||"",next_pm_date:s.next_pm_date||"",manufacturer:s.manufacturer||"",model:s.model||"",pm_for:s.pm_for||"",asset_name:s.asset_name||"",no_of_pms:s.no_of_pms||""})},disabled:b,className:"px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg transition-colors disabled:opacity-50",children:"Cancel"})]}),lt&&e.jsx("button",{onClick:Ht,disabled:b,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50",children:"Cancel Document"})]})]}),lt&&e.jsxs("div",{className:"flex items-center gap-4 mt-2 pt-3 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Workflow Status:"}),ae.length>0&&e.jsxs("span",{className:"px-3 py-1 text-sm font-medium rounded-full bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400",children:[ae.length," Planned"]}),M.length>0&&e.jsxs("span",{className:"px-3 py-1 text-sm font-medium rounded-full bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400",children:[M.length," Pending Approval"]}),ae.length===0&&M.length===0&&e.jsx("span",{className:"px-3 py-1 text-sm font-medium rounded-full bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:"All Approved ✓"})]})]}),e.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[e.jsx("div",{className:"flex-1 overflow-auto p-6",children:e.jsx("div",{className:"max-w-4xl mx-auto bg-white dark:bg-gray-800 rounded-lg shadow",children:e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:"Basic Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx("div",{children:N?e.jsx(Ut,{label:"Hospital *",doctype:"Company",value:ke.hospital,onChange:Ie=>Me(Nt=>Se(ue({},Nt),{hospital:Ie})),placeholder:"Select Hospital",filters:{}}):e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Hospital"}),e.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.hospital||"-"})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Modality"}),N?e.jsx("input",{type:"text",name:"modality",value:ke.modality,onChange:Ne,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):e.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.modality||"-"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Device Status"}),N?e.jsx("input",{type:"text",name:"device_status",value:ke.device_status,onChange:Ne,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):e.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.device_status||"-"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Periodicity *"}),N?e.jsxs("select",{name:"periodicity",value:ke.periodicity,onChange:Ne,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"Daily",children:"Daily"}),e.jsx("option",{value:"Weekly",children:"Weekly"}),e.jsx("option",{value:"Monthly",children:"Monthly"}),e.jsx("option",{value:"Quarterly",children:"Quarterly"}),e.jsx("option",{value:"Half-yearly",children:"Half-yearly"}),e.jsx("option",{value:"Yearly",children:"Yearly"})]}):e.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.periodicity||"-"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Manufacturer"}),N?e.jsx("input",{type:"text",name:"manufacturer",value:ke.manufacturer,onChange:Ne,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):e.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.manufacturer||"-"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Model"}),N?e.jsx("input",{type:"text",name:"model",value:ke.model,onChange:Ne,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):e.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.model||"-"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"PM Name"}),N?e.jsx("input",{type:"text",name:"pm_for",value:ke.pm_for,onChange:Ne,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):e.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.pm_for||"-"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Asset Name"}),N?e.jsx("input",{type:"text",name:"asset_name",value:ke.asset_name,onChange:Ne,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):e.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.asset_name||"-"})]})]})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:"Schedule Dates"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Start Date *"}),N?e.jsx("input",{type:"date",name:"start_date",value:ke.start_date,onChange:Ne,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):e.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.start_date?new Date(s.start_date).toLocaleDateString():"-"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"End Date *"}),N?e.jsx("input",{type:"date",name:"end_date",value:ke.end_date,onChange:Ne,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):e.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.end_date?new Date(s.end_date).toLocaleDateString():"-"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"First PM Date"}),N?e.jsx("input",{type:"date",name:"due_date",value:ke.due_date,onChange:Ne,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):e.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.due_date?new Date(s.due_date).toLocaleDateString():"-"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Next PM Date"}),N?e.jsx("input",{type:"date",name:"next_pm_date",value:ke.next_pm_date,onChange:Ne,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):e.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:ke.next_pm_date?new Date(ke.next_pm_date).toLocaleDateString():s.next_pm_date?new Date(s.next_pm_date).toLocaleDateString():"-"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"No. of PMs"}),N?e.jsx("input",{type:"number",name:"no_of_pms",value:ke.no_of_pms,onChange:Ne,min:"1",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",placeholder:"Enter number of PMs"}):e.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.no_of_pms||"-"})]})]})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:"Assignment"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Maintenance Team"}),N?e.jsx("input",{type:"text",name:"maintenance_team",value:ke.maintenance_team,onChange:Ne,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):e.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.maintenance_team||"-"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Maintenance Manager"}),N?e.jsx("input",{type:"text",name:"maintenance_manager",value:ke.maintenance_manager,onChange:Ne,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):e.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.maintenance_manager||"-"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Assign To"}),N?e.jsx("input",{type:"text",name:"assign_to",value:ke.assign_to,onChange:Ne,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}):e.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:s.assign_to||"-"})]})]})]}),aa.length>0&&e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:["Pending Maintenance Entries",e.jsx("span",{className:"ml-2 text-sm font-normal text-gray-500 dark:text-gray-400",children:"(Showing Planned & Applied only)"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse border border-gray-300 dark:border-gray-600",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-100 dark:bg-gray-700",children:[e.jsx("th",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-left text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Asset"}),e.jsx("th",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-left text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Asset Name"}),e.jsx("th",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-left text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Manufacturer"}),e.jsx("th",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-left text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Maintenance Log"}),e.jsx("th",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-left text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Status"}),e.jsx("th",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-left text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Next PM Date"})]})}),e.jsx("tbody",{children:aa.map((Ie,Nt)=>{const ve=ft(Ie.asset);return ve.map((Oe,ht)=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50",children:[ht===0&&e.jsxs(e.Fragment,{children:[e.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm text-gray-900 dark:text-white",rowSpan:ve.length,children:Ie.asset?e.jsx("button",{onClick:()=>r(`/assets/${Ie.asset}`),className:"text-blue-600 dark:text-blue-400 hover:underline",children:Ie.asset}):"-"}),e.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm text-gray-900 dark:text-white",rowSpan:ve.length,children:Ie.asset_name||"-"}),e.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm text-gray-900 dark:text-white",rowSpan:ve.length,children:Ie.manufacturer||"-"})]}),e.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm text-gray-900 dark:text-white",children:e.jsx("button",{onClick:()=>r(`/maintenance/${Oe.name}`),className:"text-blue-600 dark:text-blue-400 hover:underline",children:Oe.name})}),e.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm",children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${Oe.workflow_state==="Applied"?Ye("Applied"):Ye("Planned")}`,children:Oe.workflow_state==="Applied"?"Applied (Pending Approval)":"Planned"})}),e.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm text-gray-900 dark:text-white",children:Oe.due_date?new Date(Oe.due_date).toLocaleDateString():"-"})]},`${Ie.name}-${Oe.name}`))})})]})})]}),lt&&aa.length===0&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-6 text-center",children:[e.jsx(ea,{className:"mx-auto text-green-600 dark:text-green-400 text-3xl mb-2"}),e.jsx("h3",{className:"text-lg font-semibold text-green-800 dark:text-green-300 mb-1",children:"All Maintenance Entries Completed"}),e.jsx("p",{className:"text-sm text-green-600 dark:text-green-400",children:"All maintenance entries have been approved. New planned entries will appear when generated."})]}),e.jsxs("div",{className:"pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-600 dark:text-gray-400 mb-3",children:"Metadata"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-500",children:"Created:"}),e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:s.creation?new Date(s.creation).toLocaleString():"-"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-500",children:"Created By:"}),e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:s.owner||"-"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-500",children:"Modified:"}),e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:s.modified?new Date(s.modified).toLocaleString():"-"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-500",children:"Modified By:"}),e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:s.modified_by||"-"})]})]})]})]})})}),e.jsx("div",{className:"w-80 flex-shrink-0 bg-white dark:bg-gray-800 border-l border-gray-200 dark:border-gray-700 overflow-auto",children:e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(_c,{className:"text-blue-600 dark:text-blue-400"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Activity Log"})]}),X.length===0?e.jsxs("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:[e.jsx(_c,{className:"mx-auto text-3xl mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No activity recorded yet"})]}):e.jsx("div",{className:"space-y-3",children:X.map(Ie=>e.jsx("div",{className:`rounded-lg p-3 border ${Ie.action==="Approved"?"bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800":Ie.action==="Applied"?"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800":"bg-gray-50 dark:bg-gray-700 border-gray-200 dark:border-gray-600"}`,children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center ${Ie.action==="Approved"?"bg-green-100 dark:bg-green-900/30":Ie.action==="Applied"?"bg-blue-100 dark:bg-blue-900/30":"bg-gray-100 dark:bg-gray-600"}`,children:Ie.action==="Approved"?e.jsx(X0,{className:"text-green-600 dark:text-green-400 text-sm"}):e.jsx(bi,{className:"text-blue-600 dark:text-blue-400 text-sm"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`text-sm font-medium ${Ie.action==="Approved"?"text-green-800 dark:text-green-300":Ie.action==="Applied"?"text-blue-800 dark:text-blue-300":"text-gray-900 dark:text-white"}`,children:Ie.action}),e.jsxs("div",{className:"flex items-center gap-1 mt-1 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx(js,{className:"text-[10px]"}),e.jsx("span",{className:"truncate",children:Ie.user})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx(or,{className:"text-[10px]"}),e.jsx("span",{children:new Date(Ie.timestamp).toLocaleString()})]}),e.jsx("div",{className:"mt-2 pt-2 border-t border-gray-200 dark:border-gray-600",children:e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Entries:"}),e.jsx("span",{className:`font-medium ${Ie.action==="Approved"?"text-green-600 dark:text-green-400":"text-blue-600 dark:text-blue-400"}`,children:Ie.entriesCount})]}),Ie.completionDate&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Completion Date:"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:new Date(Ie.completionDate).toLocaleDateString()})]})]})})]})]})},Ie.id))})]})})]}),T&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 max-w-lg w-full mx-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center",children:e.jsx(bi,{className:"text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Apply for Approval"}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[he.size," of ",ae.length," ",ae.length===1?"entry":"entries"," selected"]})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400",children:"Select Entries to Complete:"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:Qt,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Select All"}),e.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),e.jsx("button",{type:"button",onClick:zt,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Deselect All"})]})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto bg-gray-50 dark:bg-gray-700 rounded-lg p-3 space-y-2",children:ae.map((Ie,Nt)=>e.jsxs("label",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-all ${he.has(Ie.name)?"bg-blue-50 dark:bg-blue-900/30 border border-blue-200 dark:border-blue-700":"bg-white dark:bg-gray-600 border border-gray-200 dark:border-gray-500 hover:bg-gray-50 dark:hover:bg-gray-550"}`,children:[e.jsx("input",{type:"checkbox",checked:he.has(Ie.name),onChange:()=>Te(Ie.name),className:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-5 h-5 bg-yellow-100 dark:bg-yellow-900/30 rounded-full flex items-center justify-center text-[10px] font-medium text-yellow-700 dark:text-yellow-400 flex-shrink-0",children:Nt+1}),e.jsxs("div",{className:"truncate",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:Ie.asset_display_name||Ie.asset_name||"Unknown Asset"}),e.jsx("span",{className:"text-gray-400 dark:text-gray-500 mx-1",children:"-"}),e.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:Ie.name})]})]}),Ie.due_date&&e.jsxs("div",{className:"ml-7 text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:["Due: ",new Date(Ie.due_date).toLocaleDateString()]})]})]},Ie.name))}),e.jsxs("div",{className:"mt-2 flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[he.size," selected"]}),he.size===0&&e.jsx("span",{className:"text-red-500 dark:text-red-400",children:"Please select at least one entry"})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Completion Date *"}),e.jsx("input",{type:"date",value:O,onChange:Ie=>R(Ie.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),ke.next_pm_date&&e.jsx("div",{className:"mb-4 p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(go,{className:"text-blue-600 dark:text-blue-400"}),e.jsxs("span",{className:"text-gray-700 dark:text-gray-300",children:["Next PM Date: ",e.jsx("strong",{className:"text-blue-600 dark:text-blue-400",children:new Date(ke.next_pm_date).toLocaleDateString()})]})]})}),U&&e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"p-3 bg-amber-50 dark:bg-amber-900/20 rounded-lg border border-amber-200 dark:border-amber-800 mb-3",children:e.jsxs("p",{className:"text-sm text-amber-700 dark:text-amber-400 flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:"⚠️"}),"Completion date is before the Next PM Date. Please provide a reason."]})}),e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Early Completion Reason *"}),e.jsx("textarea",{value:Y,onChange:Ie=>P(Ie.target.value),rows:3,placeholder:"Enter reason for early completion...",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-amber-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white resize-none"})]}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>{E(!1),R(""),P(""),ce(new Set)},className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300 transition-colors",disabled:ne,children:"Cancel"}),e.jsx("button",{onClick:Wt,disabled:ne||!O||he.size===0||U&&!Y.trim(),className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:ne?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin"}),"Applying..."]}):e.jsxs(e.Fragment,{children:[e.jsx(bi,{}),"Complete (",he.size,")"]})})]})]})}),se&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 max-w-lg w-full mx-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center",children:e.jsx(X0,{className:"text-green-600 dark:text-green-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Approve Entries"}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[I.size," of ",M.length," ",M.length===1?"entry":"entries"," selected"]})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400",children:"Select Entries to Approve:"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:ta,className:"text-xs text-green-600 dark:text-green-400 hover:underline",children:"Select All"}),e.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),e.jsx("button",{type:"button",onClick:sa,className:"text-xs text-green-600 dark:text-green-400 hover:underline",children:"Deselect All"})]})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto bg-gray-50 dark:bg-gray-700 rounded-lg p-3 space-y-2",children:M.map((Ie,Nt)=>e.jsxs("label",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-all ${I.has(Ie.name)?"bg-green-50 dark:bg-green-900/30 border border-green-200 dark:border-green-700":"bg-white dark:bg-gray-600 border border-gray-200 dark:border-gray-500 hover:bg-gray-50 dark:hover:bg-gray-550"}`,children:[e.jsx("input",{type:"checkbox",checked:I.has(Ie.name),onChange:()=>va(Ie.name),className:"w-4 h-4 text-green-600 bg-gray-100 border-gray-300 rounded focus:ring-green-500 dark:focus:ring-green-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-5 h-5 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center text-[10px] font-medium text-blue-700 dark:text-blue-400 flex-shrink-0",children:Nt+1}),e.jsxs("div",{className:"truncate",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:Ie.asset_display_name||Ie.asset_name||"Unknown Asset"}),e.jsx("span",{className:"text-gray-400 dark:text-gray-500 mx-1",children:"-"}),e.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:Ie.name})]})]}),Ie.completion_date&&e.jsxs("div",{className:"ml-7 text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:["Completed: ",new Date(Ie.completion_date).toLocaleDateString()]})]})]},Ie.name))}),e.jsxs("div",{className:"mt-2 flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[I.size," selected"]}),I.size===0&&e.jsx("span",{className:"text-red-500 dark:text-red-400",children:"Please select at least one entry"})]})]}),e.jsx("div",{className:"mb-4 p-3 bg-green-50 dark:bg-green-900/20 rounded-lg border border-green-200 dark:border-green-800",children:e.jsxs("p",{className:"text-sm text-green-700 dark:text-green-400",children:["✓ Approving will ",e.jsx("strong",{children:"submit"})," the documents (docstatus = 1) and trigger auto-creation of next planned entries."]})}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>{ee(!1),oe(new Set)},className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300 transition-colors",disabled:te,children:"Cancel"}),e.jsx("button",{onClick:ra,disabled:te||I.size===0,className:"px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:te?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin"}),"Approving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(X0,{}),"Approve (",I.size,")"]})})]})]})}),C&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 max-w-md",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:"Confirm Delete"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:"Are you sure you want to delete this PPM Planner? This action cannot be undone."}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>D(!1),className:"px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",disabled:b,children:"Cancel"}),e.jsx("button",{onClick:gt,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors",disabled:b,children:b?"Deleting...":"Delete"})]})]})})]})},ML=({month:t,year:a,filters:r={},viewType:s="maintenance-log",timeView:i="day-month"})=>{const{t:c}=ca(),d=qa(),m=new Date,[h,g]=y.useState(t!=null?t:m.getMonth()),[p,b]=y.useState(a!=null?a:m.getFullYear()),j=new Date(p,h,1).toISOString().split("T")[0],_=new Date(p,h+1,0).toISOString().split("T")[0],N=JSON.stringify(r),k=y.useMemo(()=>r,[N]),C=y.useMemo(()=>ue({due_date:["between",[j,_]]},k),[j,_,k]),D=y.useMemo(()=>({}),[]),T=y.useMemo(()=>({}),[]),{logs:E,loading:O}=Rh(s==="maintenance-log"?C:D,s==="maintenance-log"?1e3:0,0,"due_date asc"),{pmSchedules:R,loading:Y}=Ep(s==="ppm-planner"?k:D,1e3,0,"creation desc",T),P=s==="maintenance-log"?O:Y,U=y.useMemo(()=>s==="maintenance-log"?E.filter(I=>{if(!I.due_date)return!1;const oe=new Date(I.due_date);return oe.getMonth()===h&&oe.getFullYear()===p}):R.filter(oe=>{const ae=oe.due_date||oe.start_date;if(!ae)return!1;const[F,M,B]=ae.split("-").map(Number),X=new Date(F,M-1,B);return X.getMonth()===h&&X.getFullYear()===p}),[E,R,h,p,s]);y.useEffect(()=>{s==="ppm-planner"&&!Y&&(console.log("=== PPM PLANNER DEBUG ==="),console.log("[MaintenanceCalendar] Viewing Month:",h+1,"Year:",p),console.log("[MaintenanceCalendar] Total PM Schedules fetched:",R.length),console.log("[MaintenanceCalendar] Filtered for current month:",U.length),U.length>0?(console.log("[MaintenanceCalendar] Schedules showing in this month:"),U.forEach(I=>{console.log(` - ${I.name}: due_date=${I.due_date}, start_date=${I.start_date}`)})):(console.log("[MaintenanceCalendar] No schedules match this month."),console.log("[MaintenanceCalendar] Due dates in fetched data:"),R.slice(0,5).forEach(I=>{const oe=I.due_date||I.start_date;console.log(` - ${I.name}: due_date=${I.due_date}, start_date=${I.start_date}, will show in: ${oe?(()=>{const[ae,F]=oe.split("-").map(Number);return`${F}/${ae}`})():"unknown"}`)}),console.log("[MaintenanceCalendar] TIP: Navigate to the month where due_dates match to see schedules.")),console.log("========================="))},[s,R,Y,U.length,h,p]);const J=(I,oe)=>{const ae=new Date(oe)<new Date&&I!=="Completed";switch(I){case"Completed":return"bg-green-500 text-white border-green-600";case"Planned":return ae?"bg-red-500 text-white border-red-600":"bg-yellow-500 text-white border-yellow-600";case"Overdue":return"bg-red-600 text-white border-red-700";default:return"bg-gray-500 text-white border-gray-600"}},ne=new Date(p,h,1).getDay(),ye=new Date(p,h+1,0).getDate(),he=Array.from({length:ye},(I,oe)=>oe+1),ce=I=>{I>0?h===11?(g(0),b(p+1)):g(h+1):h===0?(g(11),b(p-1)):g(h-1)},se=I=>s==="maintenance-log"?U.filter(oe=>oe.due_date?new Date(oe.due_date).getDate()===I:!1):U.filter(ae=>{const F=ae.due_date||ae.start_date;if(!F)return!1;const[M,B,X]=F.split("-").map(Number),K=new Date(M,B-1,X);return K.getDate()===I&&K.getMonth()===h&&K.getFullYear()===p}),ee=()=>{g(m.getMonth()),b(m.getFullYear())},te=[c("maintenanceCalendarPage.months.january"),c("maintenanceCalendarPage.months.february"),c("maintenanceCalendarPage.months.march"),c("maintenanceCalendarPage.months.april"),c("maintenanceCalendarPage.months.may"),c("maintenanceCalendarPage.months.june"),c("maintenanceCalendarPage.months.july"),c("maintenanceCalendarPage.months.august"),c("maintenanceCalendarPage.months.september"),c("maintenanceCalendarPage.months.october"),c("maintenanceCalendarPage.months.november"),c("maintenanceCalendarPage.months.december")],W=[c("maintenanceCalendarPage.days.sun"),c("maintenanceCalendarPage.days.mon"),c("maintenanceCalendarPage.days.tue"),c("maintenanceCalendarPage.days.wed"),c("maintenanceCalendarPage.days.thu"),c("maintenanceCalendarPage.days.fri"),c("maintenanceCalendarPage.days.sat")];return e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow h-full flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center p-4 lg:p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-2 lg:gap-3",children:[e.jsx(go,{className:"text-blue-600 dark:text-blue-400",size:20}),e.jsxs("h2",{className:"text-xl lg:text-2xl font-bold text-gray-800 dark:text-white",children:[te[h]," ",p]})]}),e.jsxs("div",{className:"flex gap-1 lg:gap-2",children:[e.jsx("button",{onClick:()=>ce(-1),className:"px-2 py-2 lg:px-4 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 rounded-lg text-gray-700 dark:text-gray-300 transition-colors",title:c("maintenanceCalendarPage.previousMonth"),children:e.jsx(S2,{})}),e.jsx("button",{onClick:ee,className:"px-2 py-2 lg:px-4 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors text-xs lg:text-sm font-medium",children:c("maintenanceCalendarPage.today")}),e.jsx("button",{onClick:()=>ce(1),className:"px-2 py-2 lg:px-4 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 rounded-lg text-gray-700 dark:text-gray-300 transition-colors",title:c("maintenanceCalendarPage.nextMonth"),children:e.jsx(C2,{})})]})]}),P?e.jsxs("div",{className:"flex items-center justify-center flex-1",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"}),e.jsx("span",{className:"ml-3 text-gray-600 dark:text-gray-400",children:c(s==="maintenance-log"?"maintenanceCalendarPage.loadingLogs":"maintenanceCalendarPage.loadingPpm")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 overflow-auto p-4 lg:p-6",children:[e.jsx("div",{className:"grid grid-cols-7 gap-1 lg:gap-2 mb-2",children:W.map(I=>e.jsx("div",{className:"text-center font-semibold p-1 lg:p-2 text-gray-700 dark:text-gray-300 text-xs lg:text-sm",children:I},I))}),e.jsxs("div",{className:"grid grid-cols-7 gap-1 lg:gap-2 auto-rows-fr",children:[Array.from({length:ne}).map((I,oe)=>e.jsx("div",{className:"p-1 lg:p-2"},`empty-${oe}`)),he.map(I=>{const oe=se(I),ae=I===m.getDate()&&h===m.getMonth()&&p===m.getFullYear();return e.jsxs("div",{className:`border rounded-lg p-1 lg:p-2 min-h-16 lg:min-h-20 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors flex flex-col ${ae?"border-blue-500 border-2 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700"}`,children:[e.jsx("div",{className:`font-semibold mb-1 text-xs lg:text-sm flex-shrink-0 ${ae?"text-blue-700 dark:text-blue-300":"text-gray-700 dark:text-gray-300"}`,children:I}),e.jsxs("div",{className:"space-y-1 flex-1 overflow-hidden",children:[oe.slice(0,2).map(F=>{if(s==="maintenance-log"){const M=F,B=new Date(M.due_date||"")<new Date&&M.maintenance_status!=="Completed";return e.jsx("div",{onClick:()=>d(`/maintenance/${M.name}`),className:`text-xs p-1 rounded border ${J(M.maintenance_status||"Planned",M.due_date||"")} truncate cursor-pointer hover:opacity-80 transition-opacity`,title:`${M.asset_name||M.name} - ${M.maintenance_status||"Planned"}${B?` ${c("maintenanceCalendarPage.overdueInTooltip")}`:""} - ${c("maintenanceCalendarPage.clickToViewDetails")}`,children:e.jsx("div",{className:"truncate font-medium text-xs",children:M.asset_name||M.name})},M.name)}else{const M=F,X=M.pm_for||M.pm_for||M["PM Name"]||null||M.name||c("maintenanceCalendarPage.ppmPlannerDefault"),K=M.name?`${M.name}${M.modality?` - ${M.modality}`:""}${M.hospital?` - ${M.hospital}`:""} - ${c("maintenanceCalendarPage.clickToViewPpmPlanner")}`:c("maintenanceCalendarPage.clickToViewPpmPlanner");return e.jsx("div",{onClick:()=>d(`/ppm-planner/${M.name}`),className:"text-xs p-1 rounded border bg-purple-500 text-white border-purple-600 truncate cursor-pointer hover:opacity-80 transition-opacity",title:K,children:e.jsx("div",{className:"truncate font-medium text-xs",children:X})},M.name)}}),oe.length>2&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-medium",children:["+",oe.length-2]})]})]},I)})]})]}),e.jsx("div",{className:"flex-shrink-0 border-t border-gray-200 dark:border-gray-700 p-3 lg:p-4 bg-gray-50 dark:bg-gray-900/30",children:e.jsxs("div",{className:"flex flex-col lg:flex-row justify-between items-center gap-3 lg:gap-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-3 lg:gap-4 items-center justify-center lg:justify-start",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 bg-green-500 rounded border border-green-600"}),e.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:c("maintenanceCalendarPage.legendCompleted")})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 bg-yellow-500 rounded border border-yellow-600"}),e.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:c("maintenanceCalendarPage.legendPlanned")})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 bg-red-500 rounded border border-red-600"}),e.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:c("maintenanceCalendarPage.legendOverdue")})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 border-2 border-blue-500 rounded bg-blue-50 dark:bg-blue-900/20"}),e.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:c("maintenanceCalendarPage.legendToday")})]})]}),e.jsx("div",{className:"flex gap-4 lg:gap-6 text-center",children:s==="maintenance-log"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg lg:text-xl font-bold text-green-600 dark:text-green-400",children:U.filter(I=>I.maintenance_status==="Completed").length}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:c("maintenanceCalendarPage.legendCompleted")})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg lg:text-xl font-bold text-yellow-600 dark:text-yellow-400",children:U.filter(I=>I.maintenance_status==="Planned"&&new Date(I.due_date||"")>=new Date).length}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:c("maintenanceCalendarPage.legendPlanned")})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg lg:text-xl font-bold text-red-600 dark:text-red-400",children:U.filter(I=>new Date(I.due_date||"")<new Date&&I.maintenance_status!=="Completed").length}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:c("maintenanceCalendarPage.legendOverdue")})]})]}):e.jsxs("div",{children:[e.jsx("div",{className:"text-lg lg:text-xl font-bold text-purple-600 dark:text-purple-400",children:U.length}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:c("maintenanceCalendarPage.summaryPpmPlanners")})]})})]})})]})]})},LL=()=>{const{t}=ca(),a=qa(),[r]=Qs(),[s,i]=y.useState(""),[c,d]=y.useState(""),[m,h]=y.useState(""),[g,p]=y.useState("");y.useEffect(()=>{const O=r.get("hospital"),R=r.get("status");O&&i(O),R&&h(R)},[r]);const[b,j]=y.useState("maintenance-log"),[_,N]=y.useState(!1),[k,C]=y.useState(0);y.useEffect(()=>{const O=[s,c,m,g].filter(Boolean).length;C(O)},[s,c,m,g]);const D=()=>{i(""),d(""),h(""),p("")},T=s||c||m||g,E=y.useMemo(()=>{const O={};return s&&(O.company=s),c&&(O.department=c),m&&(O.maintenance_status=m),g&&(O.assign_to_name=g),O},[s,c,m,g]);return e.jsxs("div",{className:"flex flex-col h-screen bg-gray-50 dark:bg-gray-900 overflow-hidden",children:[e.jsxs("div",{className:"flex-shrink-0 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 px-4 py-2.5 lg:px-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-3 md:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx(go,{className:"text-blue-600 dark:text-blue-400 flex-shrink-0",size:22}),e.jsx("div",{className:"min-w-0",children:e.jsx("h1",{className:"text-lg md:text-xl font-bold text-gray-800 dark:text-white whitespace-nowrap",children:t("maintenanceCalendarPage.title")})})]}),e.jsxs("div",{className:"flex items-end gap-2 md:gap-3 flex-wrap md:flex-nowrap",children:[e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("maintenanceCalendarPage.viewType")}),e.jsxs("select",{value:b,onChange:O=>j(O.target.value),className:"px-2.5 md:px-3 py-1.5 text-xs md:text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"maintenance-log",children:t("maintenanceCalendarPage.maintenanceLog")}),e.jsx("option",{value:"ppm-planner",children:t("maintenanceCalendarPage.ppmPlanner")})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1 invisible",children:t("maintenanceCalendarPage.filters")}),e.jsxs("button",{onClick:()=>N(!_),className:`px-3 md:px-4 py-1.5 md:py-2 border rounded-lg transition-colors flex items-center gap-1.5 md:gap-2 text-xs md:text-sm ${T?"border-blue-500 bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400":"border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:[e.jsx(ds,{size:14}),e.jsx("span",{className:"hidden sm:inline",children:t("maintenanceCalendarPage.filters")}),k>0&&e.jsx("span",{className:"bg-blue-600 text-white rounded-full w-4 h-4 md:w-5 md:h-5 flex items-center justify-center text-[10px] md:text-xs",children:k}),_?e.jsx(As,{size:12}):e.jsx(cs,{size:12})]})]}),b==="ppm-planner"&&e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1 invisible",children:t("maintenanceCalendarPage.yearlyMap")}),e.jsxs("button",{onClick:()=>a("/yearly-ppm-planner"),className:"px-3 md:px-4 py-1.5 md:py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors flex items-center gap-1.5 md:gap-2 text-xs md:text-sm font-medium whitespace-nowrap",title:t("maintenanceCalendarPage.yearlyMapTitle"),children:[e.jsx(G5,{size:14}),e.jsx("span",{className:"hidden sm:inline",children:t("maintenanceCalendarPage.yearlyMap")}),e.jsx("span",{className:"sm:hidden",children:t("maintenanceCalendarPage.mapShort")})]})]})]})]}),_&&e.jsxs("div",{className:"mt-2.5 md:mt-3 p-3 md:p-4 bg-gray-50 dark:bg-gray-700/50 rounded-lg border border-gray-200 dark:border-gray-600",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"relative z-[60]",children:[e.jsx(Ut,{label:t("maintenanceCalendarPage.hospital"),doctype:"Company",value:s,onChange:O=>i(O),placeholder:t("maintenanceCalendarPage.selectHospital"),compact:!0}),s&&e.jsx("button",{onClick:()=>i(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[55]",children:[e.jsx(Ut,{label:t("maintenanceCalendarPage.department"),doctype:"Department",value:c,onChange:O=>d(O),placeholder:t("maintenanceCalendarPage.allDepartments"),compact:!0}),c&&e.jsx("button",{onClick:()=>d(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("maintenanceCalendarPage.status")}),e.jsxs("select",{value:m,onChange:O=>h(O.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("maintenanceCalendarPage.allStatuses")}),e.jsx("option",{value:"Planned",children:t("maintenanceCalendarPage.planned")}),e.jsx("option",{value:"Completed",children:t("maintenanceCalendarPage.completed")}),e.jsx("option",{value:"Overdue",children:t("maintenanceCalendarPage.overdue")}),e.jsx("option",{value:"Cancelled",children:t("maintenanceCalendarPage.cancelled")})]}),m&&e.jsx("button",{onClick:()=>h(""),className:"absolute right-8 top-7 text-gray-400 hover:text-red-500 transition-colors",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[50]",children:[e.jsx(Ut,{label:t("maintenanceCalendarPage.assignedTo"),doctype:"User",value:g,onChange:O=>p(O),placeholder:t("maintenanceCalendarPage.allTechnicians"),compact:!0}),g&&e.jsx("button",{onClick:()=>p(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]})]}),T&&e.jsx("div",{className:"mt-3 flex justify-end",children:e.jsxs("button",{onClick:D,className:"px-3 py-1.5 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 flex items-center gap-2",children:[e.jsx(wt,{}),t("maintenanceCalendarPage.clearFilters")]})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden px-3 pb-3 lg:px-4 lg:pb-4",children:e.jsx(ML,{filters:E,viewType:b,timeView:"day-month"})})]})},P_=()=>{const t=qa(),[a,r]=y.useState(2025),[s,i]=y.useState(2030),c=y.useMemo(()=>({}),[]),d=y.useMemo(()=>({}),[]),{pmSchedules:m,loading:h,error:g}=Ep(c,1e3,0,"creation desc",d),p=(k,C,D,T,E)=>{const O=k.toLowerCase().trim(),R=C.getFullYear(),Y=C.getMonth(),P=new Date(T,E,1),U=new Date(T,E+1,0,23,59,59,999);if(P>D||U<C)return!1;const J=(T-R)*12+(E-Y);switch(O){case"daily":return P<=D&&U>=C;case"weekly":return P<=D&&U>=C;case"monthly":return J>=0&&P<=D;case"quarterly":return J>=0&&J%3===0&&P<=D;case"half-yearly":case"half yearly":return J>=0&&J%6===0&&P<=D;case"yearly":case"annually":return E===Y&&P<=D&&P>=C;case"2 yearly":case"2-yearly":return J>=0&&J%24===0&&P<=D;case"3 yearly":case"3-yearly":return J>=0&&J%36===0&&P<=D;default:return P<=D&&U>=C}},b=y.useMemo(()=>{const k={};for(let C=a;C<=s;C++){k[C]={};for(let D=0;D<12;D++)k[C][D]=[]}return m.forEach(C=>{let D=null,T=null;if(C.start_date){const[R,Y,P]=C.start_date.split("-").map(Number)}if(C.end_date){const[R,Y,P]=C.end_date.split("-").map(Number);D=new Date(R,Y-1,P)}if(C.due_date){const[R,Y,P]=C.due_date.split("-").map(Number);T=new Date(R,Y-1,P)}if(!T)return;const E=D||T,O=C.periodicity||"monthly";for(let R=a;R<=s;R++)for(let Y=0;Y<12;Y++)p(O,T,E,R,Y)&&(k[R][Y].some(U=>U.name===C.name)||k[R][Y].push(C))}),k},[m,a,s]);y.useEffect(()=>{h||(console.log("[YearlyPPMPlannerPage] PM Schedules count:",m.length),console.log("[YearlyPPMPlannerPage] Matrix years:",a,"to",s))},[m,h,a,s]);const j=k=>{r(C=>C+k),i(C=>C+k)},_=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],N=Array.from({length:s-a+1},(k,C)=>a+C);return e.jsxs("div",{className:"flex flex-col h-screen bg-gray-50 dark:bg-gray-900 overflow-hidden",children:[e.jsx("div",{className:"flex-shrink-0 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 px-4 py-3 lg:px-6",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>t("/maintenance-calendar/month-view"),className:"p-1.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"Back to Month View",children:e.jsx(en,{className:"text-gray-600 dark:text-gray-400",size:18})}),e.jsx(go,{className:"text-blue-600 dark:text-blue-400",size:24}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-gray-800 dark:text-white",children:"Site or Cluster PPM Calendar"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"View PM Schedule Generators across multiple years"})]})]}),e.jsxs("button",{onClick:()=>t("/maintenance-calendar/month-view"),className:"px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors flex items-center gap-2 text-sm font-medium",title:"Go to Month View",children:[e.jsx(Qm,{size:14}),"Month"]})]})}),e.jsx("div",{className:"flex-shrink-0 px-3 lg:px-4 py-2",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700 p-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("button",{onClick:()=>j(-1),className:"px-3 py-1.5 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 rounded-lg text-gray-700 dark:text-gray-300 transition-colors",children:e.jsx(S2,{})}),e.jsxs("h2",{className:"text-lg font-bold text-gray-800 dark:text-white",children:[a," - ",s]}),e.jsx("button",{onClick:()=>j(1),className:"px-3 py-1.5 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 rounded-lg text-gray-700 dark:text-gray-300 transition-colors",children:e.jsx(C2,{})})]})})}),e.jsx("div",{className:"flex-1 overflow-auto px-3 pb-3 lg:px-4 lg:pb-4",children:h?e.jsxs("div",{className:"flex items-center justify-center h-full",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"}),e.jsx("span",{className:"ml-3 text-gray-600 dark:text-gray-400",children:"Loading PPM Planners..."})]}):g?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:e.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["Error loading PPM Planners: ",g]})})}):e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 sticky top-0 z-10",children:e.jsxs("tr",{children:[e.jsx("th",{className:"border border-gray-300 dark:border-gray-600 px-4 py-3 text-left font-bold text-gray-800 dark:text-white bg-gray-200 dark:bg-gray-800",children:"Year/Month"}),_.map((k,C)=>e.jsx("th",{className:"border border-gray-300 dark:border-gray-600 px-2 py-3 text-center font-semibold text-gray-800 dark:text-white min-w-[140px]",children:k},C))]})}),e.jsx("tbody",{children:N.map(k=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-3 font-bold text-gray-800 dark:text-white bg-gray-50 dark:bg-gray-800/50",children:k}),_.map((C,D)=>{var E;const T=((E=b[k])==null?void 0:E[D])||[];return e.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-2 py-2 align-top min-h-[60px]",children:T.length>0?e.jsx("div",{className:"space-y-1",children:T.map(O=>{const R=O.pm_for||O.pm_for||O["PM Name"]||null;T.indexOf(O)===0&&console.log("[YearlyCalendar] 🔍 SCHEDULE IN CELL:",{name:O.name,pm_for:O.pm_for,"pm_for (bracket)":O.pm_for,allKeys:Object.keys(O),pmName:R});const Y=R||O.name||"PPM Planner",P=[];O.name&&P.push(O.name),O.modality&&P.push(O.modality),O.hospital&&P.push(O.hospital);const U=P.length>0?`${P.join(" - ")} - Click to view details`:"Click to view details";return e.jsx("div",{onClick:()=>t(`/ppm-planner/${O.name}`),className:"text-[10px] p-1 bg-blue-50 dark:bg-blue-900/30 border border-blue-200 dark:border-blue-700 rounded cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-900/50 transition-colors group",title:U,children:e.jsx("div",{className:"font-medium text-blue-900 dark:text-blue-300 leading-tight group-hover:underline break-words",children:Y})},O.name)})}):e.jsx("div",{className:"text-xs text-gray-300 dark:text-gray-700 text-center py-1",children:"-"})},D)})]},k))})]})})})})]})};function sj(t,a){const r=y.useRef(a);y.useEffect(function(){a!==r.current&&t.attributionControl!=null&&(r.current!=null&&t.attributionControl.removeAttribution(r.current),a!=null&&t.attributionControl.addAttribution(a)),r.current=a},[t,a])}const RL=1;function PL(t){return Object.freeze({__version:RL,map:t})}function FL(t,a){return Object.freeze(ue(ue({},t),a))}const Ap=y.createContext(null);function Op(){const t=y.use(Ap);if(t==null)throw new Error("No context provided: useLeafletContext() can only be used in a descendant of <MapContainer>");return t}function IL(t){function a(r,s){const{instance:i,context:c}=t(r).current;y.useImperativeHandle(s,()=>i);const{children:d}=r;return d==null?null:pa.createElement(Ap,{value:c},d)}return y.forwardRef(a)}function zL(t){function a(r,s){const[i,c]=y.useState(!1),{instance:d}=t(r,c).current;y.useImperativeHandle(s,()=>d),y.useEffect(function(){i&&d.update()},[d,i,r.children]);const m=d._contentNode;return m?h2.createPortal(r.children,m):null}return y.forwardRef(a)}function BL(t){function a(r,s){const{instance:i}=t(r).current;return y.useImperativeHandle(s,()=>i),null}return y.forwardRef(a)}function nj(t,a){const r=y.useRef(void 0);y.useEffect(function(){return a!=null&&t.instance.on(a),r.current=a,function(){r.current!=null&&t.instance.off(r.current),r.current=null}},[t,a])}function Dp(t,a){var s;const r=(s=t.pane)!=null?s:a.pane;return r?Se(ue({},t),{pane:r}):t}function UL(t,a){return function(s,i){const c=Op(),d=t(Dp(s,c),c);return sj(c.map,s.attribution),nj(d.current,s.eventHandlers),a(d.current,c,s,i),d}}var Q0={exports:{}};var $L=Q0.exports,F_;function HL(){return F_||(F_=1,(function(t,a){(function(r,s){s(a)})($L,(function(r){var s="1.9.4";function i(l){var f,v,A,H;for(v=1,A=arguments.length;v<A;v++){H=arguments[v];for(f in H)l[f]=H[f]}return l}var c=Object.create||(function(){function l(){}return function(f){return l.prototype=f,new l}})();function d(l,f){var v=Array.prototype.slice;if(l.bind)return l.bind.apply(l,v.call(arguments,1));var A=v.call(arguments,2);return function(){return l.apply(f,A.length?A.concat(v.call(arguments)):arguments)}}var m=0;function h(l){return"_leaflet_id"in l||(l._leaflet_id=++m),l._leaflet_id}function g(l,f,v){var A,H,le,Ce;return Ce=function(){A=!1,H&&(le.apply(v,H),H=!1)},le=function(){A?H=arguments:(l.apply(v,arguments),setTimeout(Ce,f),A=!0)},le}function p(l,f,v){var A=f[1],H=f[0],le=A-H;return l===A&&v?l:((l-H)%le+le)%le+H}function b(){return!1}function j(l,f){if(f===!1)return l;var v=Math.pow(10,f===void 0?6:f);return Math.round(l*v)/v}function _(l){return l.trim?l.trim():l.replace(/^\s+|\s+$/g,"")}function N(l){return _(l).split(/\s+/)}function k(l,f){Object.prototype.hasOwnProperty.call(l,"options")||(l.options=l.options?c(l.options):{});for(var v in f)l.options[v]=f[v];return l.options}function C(l,f,v){var A=[];for(var H in l)A.push(encodeURIComponent(v?H.toUpperCase():H)+"="+encodeURIComponent(l[H]));return(!f||f.indexOf("?")===-1?"?":"&")+A.join("&")}var D=/\{ *([\w_ -]+) *\}/g;function T(l,f){return l.replace(D,function(v,A){var H=f[A];if(H===void 0)throw new Error("No value provided for variable "+v);return typeof H=="function"&&(H=H(f)),H})}var E=Array.isArray||function(l){return Object.prototype.toString.call(l)==="[object Array]"};function O(l,f){for(var v=0;v<l.length;v++)if(l[v]===f)return v;return-1}var R="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function Y(l){return window["webkit"+l]||window["moz"+l]||window["ms"+l]}var P=0;function U(l){var f=+new Date,v=Math.max(0,16-(f-P));return P=f+v,window.setTimeout(l,v)}var J=window.requestAnimationFrame||Y("RequestAnimationFrame")||U,ne=window.cancelAnimationFrame||Y("CancelAnimationFrame")||Y("CancelRequestAnimationFrame")||function(l){window.clearTimeout(l)};function ye(l,f,v){if(v&&J===U)l.call(f);else return J.call(window,d(l,f))}function he(l){l&&ne.call(window,l)}var ce={__proto__:null,extend:i,create:c,bind:d,get lastId(){return m},stamp:h,throttle:g,wrapNum:p,falseFn:b,formatNum:j,trim:_,splitWords:N,setOptions:k,getParamString:C,template:T,isArray:E,indexOf:O,emptyImageUrl:R,requestFn:J,cancelFn:ne,requestAnimFrame:ye,cancelAnimFrame:he};function se(){}se.extend=function(l){var f=function(){k(this),this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()},v=f.__super__=this.prototype,A=c(v);A.constructor=f,f.prototype=A;for(var H in this)Object.prototype.hasOwnProperty.call(this,H)&&H!=="prototype"&&H!=="__super__"&&(f[H]=this[H]);return l.statics&&i(f,l.statics),l.includes&&(ee(l.includes),i.apply(null,[A].concat(l.includes))),i(A,l),delete A.statics,delete A.includes,A.options&&(A.options=v.options?c(v.options):{},i(A.options,l.options)),A._initHooks=[],A.callInitHooks=function(){if(!this._initHooksCalled){v.callInitHooks&&v.callInitHooks.call(this),this._initHooksCalled=!0;for(var le=0,Ce=A._initHooks.length;le<Ce;le++)A._initHooks[le].call(this)}},f},se.include=function(l){var f=this.prototype.options;return i(this.prototype,l),l.options&&(this.prototype.options=f,this.mergeOptions(l.options)),this},se.mergeOptions=function(l){return i(this.prototype.options,l),this},se.addInitHook=function(l){var f=Array.prototype.slice.call(arguments,1),v=typeof l=="function"?l:function(){this[l].apply(this,f)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(v),this};function ee(l){if(!(typeof L=="undefined"||!L||!L.Mixin)){l=E(l)?l:[l];for(var f=0;f<l.length;f++)l[f]===L.Mixin.Events&&console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.",new Error().stack)}}var te={on:function(l,f,v){if(typeof l=="object")for(var A in l)this._on(A,l[A],f);else{l=N(l);for(var H=0,le=l.length;H<le;H++)this._on(l[H],f,v)}return this},off:function(l,f,v){if(!arguments.length)delete this._events;else if(typeof l=="object")for(var A in l)this._off(A,l[A],f);else{l=N(l);for(var H=arguments.length===1,le=0,Ce=l.length;le<Ce;le++)H?this._off(l[le]):this._off(l[le],f,v)}return this},_on:function(l,f,v,A){if(typeof f!="function"){console.warn("wrong listener type: "+typeof f);return}if(this._listens(l,f,v)===!1){v===this&&(v=void 0);var H={fn:f,ctx:v};A&&(H.once=!0),this._events=this._events||{},this._events[l]=this._events[l]||[],this._events[l].push(H)}},_off:function(l,f,v){var A,H,le;if(this._events&&(A=this._events[l],!!A)){if(arguments.length===1){if(this._firingCount)for(H=0,le=A.length;H<le;H++)A[H].fn=b;delete this._events[l];return}if(typeof f!="function"){console.warn("wrong listener type: "+typeof f);return}var Ce=this._listens(l,f,v);if(Ce!==!1){var qe=A[Ce];this._firingCount&&(qe.fn=b,this._events[l]=A=A.slice()),A.splice(Ce,1)}}},fire:function(l,f,v){if(!this.listens(l,v))return this;var A=i({},f,{type:l,target:this,sourceTarget:f&&f.sourceTarget||this});if(this._events){var H=this._events[l];if(H){this._firingCount=this._firingCount+1||1;for(var le=0,Ce=H.length;le<Ce;le++){var qe=H[le],tt=qe.fn;qe.once&&this.off(l,tt,qe.ctx),tt.call(qe.ctx||this,A)}this._firingCount--}}return v&&this._propagateEvent(A),this},listens:function(l,f,v,A){typeof l!="string"&&console.warn('"string" type argument expected');var H=f;typeof f!="function"&&(A=!!f,H=void 0,v=void 0);var le=this._events&&this._events[l];if(le&&le.length&&this._listens(l,H,v)!==!1)return!0;if(A){for(var Ce in this._eventParents)if(this._eventParents[Ce].listens(l,f,v,A))return!0}return!1},_listens:function(l,f,v){if(!this._events)return!1;var A=this._events[l]||[];if(!f)return!!A.length;v===this&&(v=void 0);for(var H=0,le=A.length;H<le;H++)if(A[H].fn===f&&A[H].ctx===v)return H;return!1},once:function(l,f,v){if(typeof l=="object")for(var A in l)this._on(A,l[A],f,!0);else{l=N(l);for(var H=0,le=l.length;H<le;H++)this._on(l[H],f,v,!0)}return this},addEventParent:function(l){return this._eventParents=this._eventParents||{},this._eventParents[h(l)]=l,this},removeEventParent:function(l){return this._eventParents&&delete this._eventParents[h(l)],this},_propagateEvent:function(l){for(var f in this._eventParents)this._eventParents[f].fire(l.type,i({layer:l.target,propagatedFrom:l.target},l),!0)}};te.addEventListener=te.on,te.removeEventListener=te.clearAllEventListeners=te.off,te.addOneTimeEventListener=te.once,te.fireEvent=te.fire,te.hasEventListeners=te.listens;var W=se.extend(te);function I(l,f,v){this.x=v?Math.round(l):l,this.y=v?Math.round(f):f}var oe=Math.trunc||function(l){return l>0?Math.floor(l):Math.ceil(l)};I.prototype={clone:function(){return new I(this.x,this.y)},add:function(l){return this.clone()._add(ae(l))},_add:function(l){return this.x+=l.x,this.y+=l.y,this},subtract:function(l){return this.clone()._subtract(ae(l))},_subtract:function(l){return this.x-=l.x,this.y-=l.y,this},divideBy:function(l){return this.clone()._divideBy(l)},_divideBy:function(l){return this.x/=l,this.y/=l,this},multiplyBy:function(l){return this.clone()._multiplyBy(l)},_multiplyBy:function(l){return this.x*=l,this.y*=l,this},scaleBy:function(l){return new I(this.x*l.x,this.y*l.y)},unscaleBy:function(l){return new I(this.x/l.x,this.y/l.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=oe(this.x),this.y=oe(this.y),this},distanceTo:function(l){l=ae(l);var f=l.x-this.x,v=l.y-this.y;return Math.sqrt(f*f+v*v)},equals:function(l){return l=ae(l),l.x===this.x&&l.y===this.y},contains:function(l){return l=ae(l),Math.abs(l.x)<=Math.abs(this.x)&&Math.abs(l.y)<=Math.abs(this.y)},toString:function(){return"Point("+j(this.x)+", "+j(this.y)+")"}};function ae(l,f,v){return l instanceof I?l:E(l)?new I(l[0],l[1]):l==null?l:typeof l=="object"&&"x"in l&&"y"in l?new I(l.x,l.y):new I(l,f,v)}function F(l,f){if(l)for(var v=f?[l,f]:l,A=0,H=v.length;A<H;A++)this.extend(v[A])}F.prototype={extend:function(l){var f,v;if(!l)return this;if(l instanceof I||typeof l[0]=="number"||"x"in l)f=v=ae(l);else if(l=M(l),f=l.min,v=l.max,!f||!v)return this;return!this.min&&!this.max?(this.min=f.clone(),this.max=v.clone()):(this.min.x=Math.min(f.x,this.min.x),this.max.x=Math.max(v.x,this.max.x),this.min.y=Math.min(f.y,this.min.y),this.max.y=Math.max(v.y,this.max.y)),this},getCenter:function(l){return ae((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,l)},getBottomLeft:function(){return ae(this.min.x,this.max.y)},getTopRight:function(){return ae(this.max.x,this.min.y)},getTopLeft:function(){return this.min},getBottomRight:function(){return this.max},getSize:function(){return this.max.subtract(this.min)},contains:function(l){var f,v;return typeof l[0]=="number"||l instanceof I?l=ae(l):l=M(l),l instanceof F?(f=l.min,v=l.max):f=v=l,f.x>=this.min.x&&v.x<=this.max.x&&f.y>=this.min.y&&v.y<=this.max.y},intersects:function(l){l=M(l);var f=this.min,v=this.max,A=l.min,H=l.max,le=H.x>=f.x&&A.x<=v.x,Ce=H.y>=f.y&&A.y<=v.y;return le&&Ce},overlaps:function(l){l=M(l);var f=this.min,v=this.max,A=l.min,H=l.max,le=H.x>f.x&&A.x<v.x,Ce=H.y>f.y&&A.y<v.y;return le&&Ce},isValid:function(){return!!(this.min&&this.max)},pad:function(l){var f=this.min,v=this.max,A=Math.abs(f.x-v.x)*l,H=Math.abs(f.y-v.y)*l;return M(ae(f.x-A,f.y-H),ae(v.x+A,v.y+H))},equals:function(l){return l?(l=M(l),this.min.equals(l.getTopLeft())&&this.max.equals(l.getBottomRight())):!1}};function M(l,f){return!l||l instanceof F?l:new F(l,f)}function B(l,f){if(l)for(var v=f?[l,f]:l,A=0,H=v.length;A<H;A++)this.extend(v[A])}B.prototype={extend:function(l){var f=this._southWest,v=this._northEast,A,H;if(l instanceof K)A=l,H=l;else if(l instanceof B){if(A=l._southWest,H=l._northEast,!A||!H)return this}else return l?this.extend(we(l)||X(l)):this;return!f&&!v?(this._southWest=new K(A.lat,A.lng),this._northEast=new K(H.lat,H.lng)):(f.lat=Math.min(A.lat,f.lat),f.lng=Math.min(A.lng,f.lng),v.lat=Math.max(H.lat,v.lat),v.lng=Math.max(H.lng,v.lng)),this},pad:function(l){var f=this._southWest,v=this._northEast,A=Math.abs(f.lat-v.lat)*l,H=Math.abs(f.lng-v.lng)*l;return new B(new K(f.lat-A,f.lng-H),new K(v.lat+A,v.lng+H))},getCenter:function(){return new K((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new K(this.getNorth(),this.getWest())},getSouthEast:function(){return new K(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(l){typeof l[0]=="number"||l instanceof K||"lat"in l?l=we(l):l=X(l);var f=this._southWest,v=this._northEast,A,H;return l instanceof B?(A=l.getSouthWest(),H=l.getNorthEast()):A=H=l,A.lat>=f.lat&&H.lat<=v.lat&&A.lng>=f.lng&&H.lng<=v.lng},intersects:function(l){l=X(l);var f=this._southWest,v=this._northEast,A=l.getSouthWest(),H=l.getNorthEast(),le=H.lat>=f.lat&&A.lat<=v.lat,Ce=H.lng>=f.lng&&A.lng<=v.lng;return le&&Ce},overlaps:function(l){l=X(l);var f=this._southWest,v=this._northEast,A=l.getSouthWest(),H=l.getNorthEast(),le=H.lat>f.lat&&A.lat<v.lat,Ce=H.lng>f.lng&&A.lng<v.lng;return le&&Ce},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(l,f){return l?(l=X(l),this._southWest.equals(l.getSouthWest(),f)&&this._northEast.equals(l.getNorthEast(),f)):!1},isValid:function(){return!!(this._southWest&&this._northEast)}};function X(l,f){return l instanceof B?l:new B(l,f)}function K(l,f,v){if(isNaN(l)||isNaN(f))throw new Error("Invalid LatLng object: ("+l+", "+f+")");this.lat=+l,this.lng=+f,v!==void 0&&(this.alt=+v)}K.prototype={equals:function(l,f){if(!l)return!1;l=we(l);var v=Math.max(Math.abs(this.lat-l.lat),Math.abs(this.lng-l.lng));return v<=(f===void 0?1e-9:f)},toString:function(l){return"LatLng("+j(this.lat,l)+", "+j(this.lng,l)+")"},distanceTo:function(l){return ke.distance(this,we(l))},wrap:function(){return ke.wrapLatLng(this)},toBounds:function(l){var f=180*l/40075017,v=f/Math.cos(Math.PI/180*this.lat);return X([this.lat-f,this.lng-v],[this.lat+f,this.lng+v])},clone:function(){return new K(this.lat,this.lng,this.alt)}};function we(l,f,v){return l instanceof K?l:E(l)&&typeof l[0]!="object"?l.length===3?new K(l[0],l[1],l[2]):l.length===2?new K(l[0],l[1]):null:l==null?l:typeof l=="object"&&"lat"in l?new K(l.lat,"lng"in l?l.lng:l.lon,l.alt):f===void 0?null:new K(l,f,v)}var be={latLngToPoint:function(l,f){var v=this.projection.project(l),A=this.scale(f);return this.transformation._transform(v,A)},pointToLatLng:function(l,f){var v=this.scale(f),A=this.transformation.untransform(l,v);return this.projection.unproject(A)},project:function(l){return this.projection.project(l)},unproject:function(l){return this.projection.unproject(l)},scale:function(l){return 256*Math.pow(2,l)},zoom:function(l){return Math.log(l/256)/Math.LN2},getProjectedBounds:function(l){if(this.infinite)return null;var f=this.projection.bounds,v=this.scale(l),A=this.transformation.transform(f.min,v),H=this.transformation.transform(f.max,v);return new F(A,H)},infinite:!1,wrapLatLng:function(l){var f=this.wrapLng?p(l.lng,this.wrapLng,!0):l.lng,v=this.wrapLat?p(l.lat,this.wrapLat,!0):l.lat,A=l.alt;return new K(v,f,A)},wrapLatLngBounds:function(l){var f=l.getCenter(),v=this.wrapLatLng(f),A=f.lat-v.lat,H=f.lng-v.lng;if(A===0&&H===0)return l;var le=l.getSouthWest(),Ce=l.getNorthEast(),qe=new K(le.lat-A,le.lng-H),tt=new K(Ce.lat-A,Ce.lng-H);return new B(qe,tt)}},ke=i({},be,{wrapLng:[-180,180],R:6371e3,distance:function(l,f){var v=Math.PI/180,A=l.lat*v,H=f.lat*v,le=Math.sin((f.lat-l.lat)*v/2),Ce=Math.sin((f.lng-l.lng)*v/2),qe=le*le+Math.cos(A)*Math.cos(H)*Ce*Ce,tt=2*Math.atan2(Math.sqrt(qe),Math.sqrt(1-qe));return this.R*tt}}),Me=6378137,z={R:Me,MAX_LATITUDE:85.0511287798,project:function(l){var f=Math.PI/180,v=this.MAX_LATITUDE,A=Math.max(Math.min(v,l.lat),-v),H=Math.sin(A*f);return new I(this.R*l.lng*f,this.R*Math.log((1+H)/(1-H))/2)},unproject:function(l){var f=180/Math.PI;return new K((2*Math.atan(Math.exp(l.y/this.R))-Math.PI/2)*f,l.x*f/this.R)},bounds:(function(){var l=Me*Math.PI;return new F([-l,-l],[l,l])})()};function Ne(l,f,v,A){if(E(l)){this._a=l[0],this._b=l[1],this._c=l[2],this._d=l[3];return}this._a=l,this._b=f,this._c=v,this._d=A}Ne.prototype={transform:function(l,f){return this._transform(l.clone(),f)},_transform:function(l,f){return f=f||1,l.x=f*(this._a*l.x+this._b),l.y=f*(this._c*l.y+this._d),l},untransform:function(l,f){return f=f||1,new I((l.x/f-this._b)/this._a,(l.y/f-this._d)/this._c)}};function Xe(l,f,v,A){return new Ne(l,f,v,A)}var gt=i({},ke,{code:"EPSG:3857",projection:z,transformation:(function(){var l=.5/(Math.PI*z.R);return Xe(l,.5,-l,.5)})()}),St=i({},gt,{code:"EPSG:900913"});function Ht(l){return document.createElementNS("http://www.w3.org/2000/svg",l)}function Mt(l,f){var v="",A,H,le,Ce,qe,tt;for(A=0,le=l.length;A<le;A++){for(qe=l[A],H=0,Ce=qe.length;H<Ce;H++)tt=qe[H],v+=(H?"L":"M")+tt.x+" "+tt.y;v+=f?rt.svg?"z":"x":""}return v||"M0 0"}var Te=document.documentElement.style,Qt="ActiveXObject"in window,zt=Qt&&!document.addEventListener,Wt="msLaunchUri"in navigator&&!("documentMode"in document),Vt=st("webkit"),va=st("android"),ta=st("android 2")||st("android 3"),sa=parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1],10),ra=va&&st("Google")&&sa<537&&!("AudioNode"in window),Ye=!!window.opera,ft=!Wt&&st("chrome"),$t=st("gecko")&&!Vt&&!Ye&&!Qt,na=!ft&&st("safari"),Ze=st("phantom"),lt="OTransition"in Te,aa=navigator.platform.indexOf("Win")===0,Ie=Qt&&"transition"in Te,Nt="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!ta,ve="MozPerspective"in Te,Oe=!window.L_DISABLE_3D&&(Ie||Nt||ve)&&!lt&&!Ze,ht=typeof orientation!="undefined"||st("mobile"),et=ht&&Vt,Be=ht&&Nt,kt=!window.PointerEvent&&window.MSPointerEvent,it=!!(window.PointerEvent||kt),xt="ontouchstart"in window||!!window.TouchEvent,Dt=!window.L_NO_TOUCH&&(xt||it),Ot=ht&&Ye,Rt=ht&&$t,De=(window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI)>1,Qe=(function(){var l=!1;try{var f=Object.defineProperty({},"passive",{get:function(){l=!0}});window.addEventListener("testPassiveEventSupport",b,f),window.removeEventListener("testPassiveEventSupport",b,f)}catch(v){}return l})(),fe=(function(){return!!document.createElement("canvas").getContext})(),re=!!(document.createElementNS&&Ht("svg").createSVGRect),Ee=!!re&&(function(){var l=document.createElement("div");return l.innerHTML="<svg/>",(l.firstChild&&l.firstChild.namespaceURI)==="http://www.w3.org/2000/svg"})(),Ge=!re&&(function(){try{var l=document.createElement("div");l.innerHTML='<v:shape adj="1"/>';var f=l.firstChild;return f.style.behavior="url(#default#VML)",f&&typeof f.adj=="object"}catch(v){return!1}})(),ct=navigator.platform.indexOf("Mac")===0,It=navigator.platform.indexOf("Linux")===0;function st(l){return navigator.userAgent.toLowerCase().indexOf(l)>=0}var rt={ie:Qt,ielt9:zt,edge:Wt,webkit:Vt,android:va,android23:ta,androidStock:ra,opera:Ye,chrome:ft,gecko:$t,safari:na,phantom:Ze,opera12:lt,win:aa,ie3d:Ie,webkit3d:Nt,gecko3d:ve,any3d:Oe,mobile:ht,mobileWebkit:et,mobileWebkit3d:Be,msPointer:kt,pointer:it,touch:Dt,touchNative:xt,mobileOpera:Ot,mobileGecko:Rt,retina:De,passiveEvents:Qe,canvas:fe,svg:re,vml:Ge,inlineSvg:Ee,mac:ct,linux:It},V=rt.msPointer?"MSPointerDown":"pointerdown",me=rt.msPointer?"MSPointerMove":"pointermove",de=rt.msPointer?"MSPointerUp":"pointerup",ie=rt.msPointer?"MSPointerCancel":"pointercancel",xe={touchstart:V,touchmove:me,touchend:de,touchcancel:ie},_e={touchstart:At,touchmove:pt,touchend:pt,touchcancel:pt},He={},Ue=!1;function Pe(l,f,v){return f==="touchstart"&&dt(),_e[f]?(v=_e[f].bind(this,v),l.addEventListener(xe[f],v,!1),v):(console.warn("wrong event specified:",f),b)}function Re(l,f,v){if(!xe[f]){console.warn("wrong event specified:",f);return}l.removeEventListener(xe[f],v,!1)}function We(l){He[l.pointerId]=l}function _t(l){He[l.pointerId]&&(He[l.pointerId]=l)}function Ft(l){delete He[l.pointerId]}function dt(){Ue||(document.addEventListener(V,We,!0),document.addEventListener(me,_t,!0),document.addEventListener(de,Ft,!0),document.addEventListener(ie,Ft,!0),Ue=!0)}function pt(l,f){if(f.pointerType!==(f.MSPOINTER_TYPE_MOUSE||"mouse")){f.touches=[];for(var v in He)f.touches.push(He[v]);f.changedTouches=[f],l(f)}}function At(l,f){f.MSPOINTER_TYPE_TOUCH&&f.pointerType===f.MSPOINTER_TYPE_TOUCH&&Cr(f),pt(l,f)}function Zt(l){var f={},v,A;for(A in l)v=l[A],f[A]=v&&v.bind?v.bind(l):v;return l=f,f.type="dblclick",f.detail=2,f.isTrusted=!1,f._simulated=!0,f}var Fa=200;function La(l,f){l.addEventListener("dblclick",f);var v=0,A;function H(le){if(le.detail!==1){A=le.detail;return}if(!(le.pointerType==="mouse"||le.sourceCapabilities&&!le.sourceCapabilities.firesTouchEvents)){var Ce=Un(le);if(!(Ce.some(function(tt){return tt instanceof HTMLLabelElement&&tt.attributes.for})&&!Ce.some(function(tt){return tt instanceof HTMLInputElement||tt instanceof HTMLSelectElement}))){var qe=Date.now();qe-v<=Fa?(A++,A===2&&f(Zt(le))):A=1,v=qe}}}return l.addEventListener("click",H),{dblclick:f,simDblclick:H}}function Ya(l,f){l.removeEventListener("dblclick",f.dblclick),l.removeEventListener("click",f.simDblclick)}var gr=xr(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),ar=xr(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),Ir=ar==="webkitTransition"||ar==="OTransition"?ar+"End":"transitionend";function kr(l){return typeof l=="string"?document.getElementById(l):l}function hs(l,f){var v=l.style[f]||l.currentStyle&&l.currentStyle[f];if((!v||v==="auto")&&document.defaultView){var A=document.defaultView.getComputedStyle(l,null);v=A?A[f]:null}return v==="auto"?null:v}function ha(l,f,v){var A=document.createElement(l);return A.className=f||"",v&&v.appendChild(A),A}function Ia(l){var f=l.parentNode;f&&f.removeChild(l)}function qr(l){for(;l.firstChild;)l.removeChild(l.firstChild)}function fr(l){var f=l.parentNode;f&&f.lastChild!==l&&f.appendChild(l)}function G(l){var f=l.parentNode;f&&f.firstChild!==l&&f.insertBefore(l,f.firstChild)}function $e(l,f){if(l.classList!==void 0)return l.classList.contains(f);var v=zr(l);return v.length>0&&new RegExp("(^|\\s)"+f+"(\\s|$)").test(v)}function Bt(l,f){if(l.classList!==void 0)for(var v=N(f),A=0,H=v.length;A<H;A++)l.classList.add(v[A]);else if(!$e(l,f)){var le=zr(l);_a(l,(le?le+" ":"")+f)}}function Kt(l,f){l.classList!==void 0?l.classList.remove(f):_a(l,_((" "+zr(l)+" ").replace(" "+f+" "," ")))}function _a(l,f){l.className.baseVal===void 0?l.className=f:l.className.baseVal=f}function zr(l){return l.correspondingElement&&(l=l.correspondingElement),l.className.baseVal===void 0?l.className:l.className.baseVal}function Aa(l,f){"opacity"in l.style?l.style.opacity=f:"filter"in l.style&&Ds(l,f)}function Ds(l,f){var v=!1,A="DXImageTransform.Microsoft.Alpha";try{v=l.filters.item(A)}catch(H){if(f===1)return}f=Math.round(f*100),v?(v.Enabled=f!==100,v.Opacity=f):l.style.filter+=" progid:"+A+"(opacity="+f+")"}function xr(l){for(var f=document.documentElement.style,v=0;v<l.length;v++)if(l[v]in f)return l[v];return!1}function wa(l,f,v){var A=f||new I(0,0);l.style[gr]=(rt.ie3d?"translate("+A.x+"px,"+A.y+"px)":"translate3d("+A.x+"px,"+A.y+"px,0)")+(v?" scale("+v+")":"")}function Za(l,f){l._leaflet_pos=f,rt.any3d?wa(l,f):(l.style.left=f.x+"px",l.style.top=f.y+"px")}function cn(l){return l._leaflet_pos||new I(0,0)}var _s,Gr,yo;if("onselectstart"in document)_s=function(){oa(window,"selectstart",Cr)},Gr=function(){za(window,"selectstart",Cr)};else{var ii=xr(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]);_s=function(){if(ii){var l=document.documentElement.style;yo=l[ii],l[ii]="none"}},Gr=function(){ii&&(document.documentElement.style[ii]=yo,yo=void 0)}}function Ms(){oa(window,"dragstart",Cr)}function oi(){za(window,"dragstart",Cr)}var wi,ze;function yt(l){for(;l.tabIndex===-1;)l=l.parentNode;l.style&&(Sa(),wi=l,ze=l.style.outlineStyle,l.style.outlineStyle="none",oa(window,"keydown",Sa))}function Sa(){wi&&(wi.style.outlineStyle=ze,wi=void 0,ze=void 0,za(window,"keydown",Sa))}function _r(l){do l=l.parentNode;while((!l.offsetWidth||!l.offsetHeight)&&l!==document.body);return l}function Sr(l){var f=l.getBoundingClientRect();return{x:f.width/l.offsetWidth||1,y:f.height/l.offsetHeight||1,boundingClientRect:f}}var Yr={__proto__:null,TRANSFORM:gr,TRANSITION:ar,TRANSITION_END:Ir,get:kr,getStyle:hs,create:ha,remove:Ia,empty:qr,toFront:fr,toBack:G,hasClass:$e,addClass:Bt,removeClass:Kt,setClass:_a,getClass:zr,setOpacity:Aa,testProp:xr,setTransform:wa,setPosition:Za,getPosition:cn,get disableTextSelection(){return _s},get enableTextSelection(){return Gr},disableImageDrag:Ms,enableImageDrag:oi,preventOutline:yt,restoreOutline:Sa,getSizedParentNode:_r,getScale:Sr};function oa(l,f,v,A){if(f&&typeof f=="object")for(var H in f)ws(l,H,f[H],v);else{f=N(f);for(var le=0,Ce=f.length;le<Ce;le++)ws(l,f[le],v,A)}return this}var Zr="_leaflet_events";function za(l,f,v,A){if(arguments.length===1)_n(l),delete l[Zr];else if(f&&typeof f=="object")for(var H in f)ki(l,H,f[H],v);else if(f=N(f),arguments.length===2)_n(l,function(qe){return O(f,qe)!==-1});else for(var le=0,Ce=f.length;le<Ce;le++)ki(l,f[le],v,A);return this}function _n(l,f){for(var v in l[Zr]){var A=v.split(/\d/)[0];(!f||f(A))&&ki(l,A,null,null,v)}}var wn={mouseenter:"mouseover",mouseleave:"mouseout",wheel:!("onwheel"in window)&&"mousewheel"};function ws(l,f,v,A){var H=f+h(v)+(A?"_"+h(A):"");if(l[Zr]&&l[Zr][H])return this;var le=function(qe){return v.call(A||l,qe||window.event)},Ce=le;!rt.touchNative&&rt.pointer&&f.indexOf("touch")===0?le=Pe(l,f,le):rt.touch&&f==="dblclick"?le=La(l,le):"addEventListener"in l?f==="touchstart"||f==="touchmove"||f==="wheel"||f==="mousewheel"?l.addEventListener(wn[f]||f,le,rt.passiveEvents?{passive:!1}:!1):f==="mouseenter"||f==="mouseleave"?(le=function(qe){qe=qe||window.event,kn(l,qe)&&Ce(qe)},l.addEventListener(wn[f],le,!1)):l.addEventListener(f,Ce,!1):l.attachEvent("on"+f,le),l[Zr]=l[Zr]||{},l[Zr][H]=le}function ki(l,f,v,A,H){H=H||f+h(v)+(A?"_"+h(A):"");var le=l[Zr]&&l[Zr][H];if(!le)return this;!rt.touchNative&&rt.pointer&&f.indexOf("touch")===0?Re(l,f,le):rt.touch&&f==="dblclick"?Ya(l,le):"removeEventListener"in l?l.removeEventListener(wn[f]||f,le,!1):l.detachEvent("on"+f,le),l[Zr][H]=null}function gs(l){return l.stopPropagation?l.stopPropagation():l.originalEvent?l.originalEvent._stopped=!0:l.cancelBubble=!0,this}function Ls(l){return ws(l,"wheel",gs),this}function zn(l){return oa(l,"mousedown touchstart dblclick contextmenu",gs),l._leaflet_disable_click=!0,this}function Cr(l){return l.preventDefault?l.preventDefault():l.returnValue=!1,this}function Bn(l){return Cr(l),gs(l),this}function Un(l){if(l.composedPath)return l.composedPath();for(var f=[],v=l.target;v;)f.push(v),v=v.parentNode;return f}function Wi(l,f){if(!f)return new I(l.clientX,l.clientY);var v=Sr(f),A=v.boundingClientRect;return new I((l.clientX-A.left)/v.x-f.clientLeft,(l.clientY-A.top)/v.y-f.clientTop)}var Rl=rt.linux&&rt.chrome?window.devicePixelRatio:rt.mac?window.devicePixelRatio*3:window.devicePixelRatio>0?2*window.devicePixelRatio:1;function Qr(l){return rt.edge?l.wheelDeltaY/2:l.deltaY&&l.deltaMode===0?-l.deltaY/Rl:l.deltaY&&l.deltaMode===1?-l.deltaY*20:l.deltaY&&l.deltaMode===2?-l.deltaY*60:l.deltaX||l.deltaZ?0:l.wheelDelta?(l.wheelDeltaY||l.wheelDelta)/2:l.detail&&Math.abs(l.detail)<32765?-l.detail*20:l.detail?l.detail/-32765*60:0}function kn(l,f){var v=f.relatedTarget;if(!v)return!0;try{for(;v&&v!==l;)v=v.parentNode}catch(A){return!1}return v!==l}var bo={__proto__:null,on:oa,off:za,stopPropagation:gs,disableScrollPropagation:Ls,disableClickPropagation:zn,preventDefault:Cr,stop:Bn,getPropagationPath:Un,getMousePosition:Wi,getWheelDelta:Qr,isExternalTarget:kn,addListener:oa,removeListener:za},Vi=W.extend({run:function(l,f,v,A){this.stop(),this._el=l,this._inProgress=!0,this._duration=v||.25,this._easeOutPower=1/Math.max(A||.5,.2),this._startPos=cn(l),this._offset=f.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=ye(this._animate,this),this._step()},_step:function(l){var f=+new Date-this._startTime,v=this._duration*1e3;f<v?this._runFrame(this._easeOut(f/v),l):(this._runFrame(1),this._complete())},_runFrame:function(l,f){var v=this._startPos.add(this._offset.multiplyBy(l));f&&v._round(),Za(this._el,v),this.fire("step")},_complete:function(){he(this._animId),this._inProgress=!1,this.fire("end")},_easeOut:function(l){return 1-Math.pow(1-l,this._easeOutPower)}}),Ra=W.extend({options:{crs:gt,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],maxBounds:void 0,renderer:void 0,zoomAnimation:!0,zoomAnimationThreshold:4,fadeAnimation:!0,markerZoomAnimation:!0,transform3DLimit:8388608,zoomSnap:1,zoomDelta:1,trackResize:!0},initialize:function(l,f){f=k(this,f),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(l),this._initLayout(),this._onResize=d(this._onResize,this),this._initEvents(),f.maxBounds&&this.setMaxBounds(f.maxBounds),f.zoom!==void 0&&(this._zoom=this._limitZoom(f.zoom)),f.center&&f.zoom!==void 0&&this.setView(we(f.center),f.zoom,{reset:!0}),this.callInitHooks(),this._zoomAnimated=ar&&rt.any3d&&!rt.mobileOpera&&this.options.zoomAnimation,this._zoomAnimated&&(this._createAnimProxy(),oa(this._proxy,Ir,this._catchTransitionEnd,this)),this._addLayers(this.options.layers)},setView:function(l,f,v){if(f=f===void 0?this._zoom:this._limitZoom(f),l=this._limitCenter(we(l),f,this.options.maxBounds),v=v||{},this._stop(),this._loaded&&!v.reset&&v!==!0){v.animate!==void 0&&(v.zoom=i({animate:v.animate},v.zoom),v.pan=i({animate:v.animate,duration:v.duration},v.pan));var A=this._zoom!==f?this._tryAnimatedZoom&&this._tryAnimatedZoom(l,f,v.zoom):this._tryAnimatedPan(l,v.pan);if(A)return clearTimeout(this._sizeTimer),this}return this._resetView(l,f,v.pan&&v.pan.noMoveStart),this},setZoom:function(l,f){return this._loaded?this.setView(this.getCenter(),l,{zoom:f}):(this._zoom=l,this)},zoomIn:function(l,f){return l=l||(rt.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom+l,f)},zoomOut:function(l,f){return l=l||(rt.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom-l,f)},setZoomAround:function(l,f,v){var A=this.getZoomScale(f),H=this.getSize().divideBy(2),le=l instanceof I?l:this.latLngToContainerPoint(l),Ce=le.subtract(H).multiplyBy(1-1/A),qe=this.containerPointToLatLng(H.add(Ce));return this.setView(qe,f,{zoom:v})},_getBoundsCenterZoom:function(l,f){f=f||{},l=l.getBounds?l.getBounds():X(l);var v=ae(f.paddingTopLeft||f.padding||[0,0]),A=ae(f.paddingBottomRight||f.padding||[0,0]),H=this.getBoundsZoom(l,!1,v.add(A));if(H=typeof f.maxZoom=="number"?Math.min(f.maxZoom,H):H,H===1/0)return{center:l.getCenter(),zoom:H};var le=A.subtract(v).divideBy(2),Ce=this.project(l.getSouthWest(),H),qe=this.project(l.getNorthEast(),H),tt=this.unproject(Ce.add(qe).divideBy(2).add(le),H);return{center:tt,zoom:H}},fitBounds:function(l,f){if(l=X(l),!l.isValid())throw new Error("Bounds are not valid.");var v=this._getBoundsCenterZoom(l,f);return this.setView(v.center,v.zoom,f)},fitWorld:function(l){return this.fitBounds([[-90,-180],[90,180]],l)},panTo:function(l,f){return this.setView(l,this._zoom,{pan:f})},panBy:function(l,f){if(l=ae(l).round(),f=f||{},!l.x&&!l.y)return this.fire("moveend");if(f.animate!==!0&&!this.getSize().contains(l))return this._resetView(this.unproject(this.project(this.getCenter()).add(l)),this.getZoom()),this;if(this._panAnim||(this._panAnim=new Vi,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),f.noMoveStart||this.fire("movestart"),f.animate!==!1){Bt(this._mapPane,"leaflet-pan-anim");var v=this._getMapPanePos().subtract(l).round();this._panAnim.run(this._mapPane,v,f.duration||.25,f.easeLinearity)}else this._rawPanBy(l),this.fire("move").fire("moveend");return this},flyTo:function(l,f,v){if(v=v||{},v.animate===!1||!rt.any3d)return this.setView(l,f,v);this._stop();var A=this.project(this.getCenter()),H=this.project(l),le=this.getSize(),Ce=this._zoom;l=we(l),f=f===void 0?Ce:f;var qe=Math.max(le.x,le.y),tt=qe*this.getZoomScale(Ce,f),Tt=H.distanceTo(A)||1,Xt=1.42,ua=Xt*Xt;function Oa(Pr){var Ni=Pr?-1:1,Oo=Pr?tt:qe,d0=tt*tt-qe*qe+Ni*ua*ua*Tt*Tt,Yl=2*Oo*ua*Tt,Zl=d0/Yl,no=Math.sqrt(Zl*Zl+1)-Zl,Si=no<1e-9?-18:Math.log(no);return Si}function ps(Pr){return(Math.exp(Pr)-Math.exp(-Pr))/2}function Ur(Pr){return(Math.exp(Pr)+Math.exp(-Pr))/2}function gn(Pr){return ps(Pr)/Ur(Pr)}var Xa=Oa(0);function Ka(Pr){return qe*(Ur(Xa)/Ur(Xa+Xt*Pr))}function Ua(Pr){return qe*(Ur(Xa)*gn(Xa+Xt*Pr)-ps(Xa))/ua}function ro(Pr){return 1-Math.pow(1-Pr,1.5)}var Sn=Date.now(),Jc=(Oa(1)-Xa)/Xt,so=v.duration?1e3*v.duration:1e3*Jc*.8;function c0(){var Pr=(Date.now()-Sn)/so,Ni=ro(Pr)*Jc;Pr<=1?(this._flyToFrame=ye(c0,this),this._move(this.unproject(A.add(H.subtract(A).multiplyBy(Ua(Ni)/Tt)),Ce),this.getScaleZoom(qe/Ka(Ni),Ce),{flyTo:!0})):this._move(l,f)._moveEnd(!0)}return this._moveStart(!0,v.noMoveStart),c0.call(this),this},flyToBounds:function(l,f){var v=this._getBoundsCenterZoom(l,f);return this.flyTo(v.center,v.zoom,f)},setMaxBounds:function(l){return l=X(l),this.listens("moveend",this._panInsideMaxBounds)&&this.off("moveend",this._panInsideMaxBounds),l.isValid()?(this.options.maxBounds=l,this._loaded&&this._panInsideMaxBounds(),this.on("moveend",this._panInsideMaxBounds)):(this.options.maxBounds=null,this)},setMinZoom:function(l){var f=this.options.minZoom;return this.options.minZoom=l,this._loaded&&f!==l&&(this.fire("zoomlevelschange"),this.getZoom()<this.options.minZoom)?this.setZoom(l):this},setMaxZoom:function(l){var f=this.options.maxZoom;return this.options.maxZoom=l,this._loaded&&f!==l&&(this.fire("zoomlevelschange"),this.getZoom()>this.options.maxZoom)?this.setZoom(l):this},panInsideBounds:function(l,f){this._enforcingBounds=!0;var v=this.getCenter(),A=this._limitCenter(v,this._zoom,X(l));return v.equals(A)||this.panTo(A,f),this._enforcingBounds=!1,this},panInside:function(l,f){f=f||{};var v=ae(f.paddingTopLeft||f.padding||[0,0]),A=ae(f.paddingBottomRight||f.padding||[0,0]),H=this.project(this.getCenter()),le=this.project(l),Ce=this.getPixelBounds(),qe=M([Ce.min.add(v),Ce.max.subtract(A)]),tt=qe.getSize();if(!qe.contains(le)){this._enforcingBounds=!0;var Tt=le.subtract(qe.getCenter()),Xt=qe.extend(le).getSize().subtract(tt);H.x+=Tt.x<0?-Xt.x:Xt.x,H.y+=Tt.y<0?-Xt.y:Xt.y,this.panTo(this.unproject(H),f),this._enforcingBounds=!1}return this},invalidateSize:function(l){if(!this._loaded)return this;l=i({animate:!1,pan:!0},l===!0?{animate:!0}:l);var f=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var v=this.getSize(),A=f.divideBy(2).round(),H=v.divideBy(2).round(),le=A.subtract(H);return!le.x&&!le.y?this:(l.animate&&l.pan?this.panBy(le):(l.pan&&this._rawPanBy(le),this.fire("move"),l.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(d(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:f,newSize:v}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(l){if(l=this._locateOptions=i({timeout:1e4,watch:!1},l),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var f=d(this._handleGeolocationResponse,this),v=d(this._handleGeolocationError,this);return l.watch?this._locationWatchId=navigator.geolocation.watchPosition(f,v,l):navigator.geolocation.getCurrentPosition(f,v,l),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(l){if(this._container._leaflet_id){var f=l.code,v=l.message||(f===1?"permission denied":f===2?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:f,message:"Geolocation error: "+v+"."})}},_handleGeolocationResponse:function(l){if(this._container._leaflet_id){var f=l.coords.latitude,v=l.coords.longitude,A=new K(f,v),H=A.toBounds(l.coords.accuracy*2),le=this._locateOptions;if(le.setView){var Ce=this.getBoundsZoom(H);this.setView(A,le.maxZoom?Math.min(Ce,le.maxZoom):Ce)}var qe={latlng:A,bounds:H,timestamp:l.timestamp};for(var tt in l.coords)typeof l.coords[tt]=="number"&&(qe[tt]=l.coords[tt]);this.fire("locationfound",qe)}},addHandler:function(l,f){if(!f)return this;var v=this[l]=new f(this);return this._handlers.push(v),this.options[l]&&v.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch(f){this._container._leaflet_id=void 0,this._containerId=void 0}this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),Ia(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(he(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload");var l;for(l in this._layers)this._layers[l].remove();for(l in this._panes)Ia(this._panes[l]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(l,f){var v="leaflet-pane"+(l?" leaflet-"+l.replace("Pane","")+"-pane":""),A=ha("div",v,f||this._mapPane);return l&&(this._panes[l]=A),A},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var l=this.getPixelBounds(),f=this.unproject(l.getBottomLeft()),v=this.unproject(l.getTopRight());return new B(f,v)},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(l,f,v){l=X(l),v=ae(v||[0,0]);var A=this.getZoom()||0,H=this.getMinZoom(),le=this.getMaxZoom(),Ce=l.getNorthWest(),qe=l.getSouthEast(),tt=this.getSize().subtract(v),Tt=M(this.project(qe,A),this.project(Ce,A)).getSize(),Xt=rt.any3d?this.options.zoomSnap:1,ua=tt.x/Tt.x,Oa=tt.y/Tt.y,ps=f?Math.max(ua,Oa):Math.min(ua,Oa);return A=this.getScaleZoom(ps,A),Xt&&(A=Math.round(A/(Xt/100))*(Xt/100),A=f?Math.ceil(A/Xt)*Xt:Math.floor(A/Xt)*Xt),Math.max(H,Math.min(le,A))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new I(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(l,f){var v=this._getTopLeftPoint(l,f);return new F(v,v.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(l){return this.options.crs.getProjectedBounds(l===void 0?this.getZoom():l)},getPane:function(l){return typeof l=="string"?this._panes[l]:l},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(l,f){var v=this.options.crs;return f=f===void 0?this._zoom:f,v.scale(l)/v.scale(f)},getScaleZoom:function(l,f){var v=this.options.crs;f=f===void 0?this._zoom:f;var A=v.zoom(l*v.scale(f));return isNaN(A)?1/0:A},project:function(l,f){return f=f===void 0?this._zoom:f,this.options.crs.latLngToPoint(we(l),f)},unproject:function(l,f){return f=f===void 0?this._zoom:f,this.options.crs.pointToLatLng(ae(l),f)},layerPointToLatLng:function(l){var f=ae(l).add(this.getPixelOrigin());return this.unproject(f)},latLngToLayerPoint:function(l){var f=this.project(we(l))._round();return f._subtract(this.getPixelOrigin())},wrapLatLng:function(l){return this.options.crs.wrapLatLng(we(l))},wrapLatLngBounds:function(l){return this.options.crs.wrapLatLngBounds(X(l))},distance:function(l,f){return this.options.crs.distance(we(l),we(f))},containerPointToLayerPoint:function(l){return ae(l).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(l){return ae(l).add(this._getMapPanePos())},containerPointToLatLng:function(l){var f=this.containerPointToLayerPoint(ae(l));return this.layerPointToLatLng(f)},latLngToContainerPoint:function(l){return this.layerPointToContainerPoint(this.latLngToLayerPoint(we(l)))},mouseEventToContainerPoint:function(l){return Wi(l,this._container)},mouseEventToLayerPoint:function(l){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(l))},mouseEventToLatLng:function(l){return this.layerPointToLatLng(this.mouseEventToLayerPoint(l))},_initContainer:function(l){var f=this._container=kr(l);if(f){if(f._leaflet_id)throw new Error("Map container is already initialized.")}else throw new Error("Map container not found.");oa(f,"scroll",this._onScroll,this),this._containerId=h(f)},_initLayout:function(){var l=this._container;this._fadeAnimated=this.options.fadeAnimation&&rt.any3d,Bt(l,"leaflet-container"+(rt.touch?" leaflet-touch":"")+(rt.retina?" leaflet-retina":"")+(rt.ielt9?" leaflet-oldie":"")+(rt.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var f=hs(l,"position");f!=="absolute"&&f!=="relative"&&f!=="fixed"&&f!=="sticky"&&(l.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var l=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),Za(this._mapPane,new I(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(Bt(l.markerPane,"leaflet-zoom-hide"),Bt(l.shadowPane,"leaflet-zoom-hide"))},_resetView:function(l,f,v){Za(this._mapPane,new I(0,0));var A=!this._loaded;this._loaded=!0,f=this._limitZoom(f),this.fire("viewprereset");var H=this._zoom!==f;this._moveStart(H,v)._move(l,f)._moveEnd(H),this.fire("viewreset"),A&&this.fire("load")},_moveStart:function(l,f){return l&&this.fire("zoomstart"),f||this.fire("movestart"),this},_move:function(l,f,v,A){f===void 0&&(f=this._zoom);var H=this._zoom!==f;return this._zoom=f,this._lastCenter=l,this._pixelOrigin=this._getNewPixelOrigin(l),A?v&&v.pinch&&this.fire("zoom",v):((H||v&&v.pinch)&&this.fire("zoom",v),this.fire("move",v)),this},_moveEnd:function(l){return l&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return he(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(l){Za(this._mapPane,this._getMapPanePos().subtract(l))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(l){this._targets={},this._targets[h(this._container)]=this;var f=l?za:oa;f(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&f(window,"resize",this._onResize,this),rt.any3d&&this.options.transform3DLimit&&(l?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){he(this._resizeRequest),this._resizeRequest=ye(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var l=this._getMapPanePos();Math.max(Math.abs(l.x),Math.abs(l.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(l,f){for(var v=[],A,H=f==="mouseout"||f==="mouseover",le=l.target||l.srcElement,Ce=!1;le;){if(A=this._targets[h(le)],A&&(f==="click"||f==="preclick")&&this._draggableMoved(A)){Ce=!0;break}if(A&&A.listens(f,!0)&&(H&&!kn(le,l)||(v.push(A),H))||le===this._container)break;le=le.parentNode}return!v.length&&!Ce&&!H&&this.listens(f,!0)&&(v=[this]),v},_isClickDisabled:function(l){for(;l&&l!==this._container;){if(l._leaflet_disable_click)return!0;l=l.parentNode}},_handleDOMEvent:function(l){var f=l.target||l.srcElement;if(!(!this._loaded||f._leaflet_disable_events||l.type==="click"&&this._isClickDisabled(f))){var v=l.type;v==="mousedown"&&yt(f),this._fireDOMEvent(l,v)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(l,f,v){if(l.type==="click"){var A=i({},l);A.type="preclick",this._fireDOMEvent(A,A.type,v)}var H=this._findEventTargets(l,f);if(v){for(var le=[],Ce=0;Ce<v.length;Ce++)v[Ce].listens(f,!0)&&le.push(v[Ce]);H=le.concat(H)}if(H.length){f==="contextmenu"&&Cr(l);var qe=H[0],tt={originalEvent:l};if(l.type!=="keypress"&&l.type!=="keydown"&&l.type!=="keyup"){var Tt=qe.getLatLng&&(!qe._radius||qe._radius<=10);tt.containerPoint=Tt?this.latLngToContainerPoint(qe.getLatLng()):this.mouseEventToContainerPoint(l),tt.layerPoint=this.containerPointToLayerPoint(tt.containerPoint),tt.latlng=Tt?qe.getLatLng():this.layerPointToLatLng(tt.layerPoint)}for(Ce=0;Ce<H.length;Ce++)if(H[Ce].fire(f,tt,!0),tt.originalEvent._stopped||H[Ce].options.bubblingMouseEvents===!1&&O(this._mouseEvents,f)!==-1)return}},_draggableMoved:function(l){return l=l.dragging&&l.dragging.enabled()?l:this,l.dragging&&l.dragging.moved()||this.boxZoom&&this.boxZoom.moved()},_clearHandlers:function(){for(var l=0,f=this._handlers.length;l<f;l++)this._handlers[l].disable()},whenReady:function(l,f){return this._loaded?l.call(f||this,{target:this}):this.on("load",l,f),this},_getMapPanePos:function(){return cn(this._mapPane)||new I(0,0)},_moved:function(){var l=this._getMapPanePos();return l&&!l.equals([0,0])},_getTopLeftPoint:function(l,f){var v=l&&f!==void 0?this._getNewPixelOrigin(l,f):this.getPixelOrigin();return v.subtract(this._getMapPanePos())},_getNewPixelOrigin:function(l,f){var v=this.getSize()._divideBy(2);return this.project(l,f)._subtract(v)._add(this._getMapPanePos())._round()},_latLngToNewLayerPoint:function(l,f,v){var A=this._getNewPixelOrigin(v,f);return this.project(l,f)._subtract(A)},_latLngBoundsToNewLayerBounds:function(l,f,v){var A=this._getNewPixelOrigin(v,f);return M([this.project(l.getSouthWest(),f)._subtract(A),this.project(l.getNorthWest(),f)._subtract(A),this.project(l.getSouthEast(),f)._subtract(A),this.project(l.getNorthEast(),f)._subtract(A)])},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(l){return this.latLngToLayerPoint(l).subtract(this._getCenterLayerPoint())},_limitCenter:function(l,f,v){if(!v)return l;var A=this.project(l,f),H=this.getSize().divideBy(2),le=new F(A.subtract(H),A.add(H)),Ce=this._getBoundsOffset(le,v,f);return Math.abs(Ce.x)<=1&&Math.abs(Ce.y)<=1?l:this.unproject(A.add(Ce),f)},_limitOffset:function(l,f){if(!f)return l;var v=this.getPixelBounds(),A=new F(v.min.add(l),v.max.add(l));return l.add(this._getBoundsOffset(A,f))},_getBoundsOffset:function(l,f,v){var A=M(this.project(f.getNorthEast(),v),this.project(f.getSouthWest(),v)),H=A.min.subtract(l.min),le=A.max.subtract(l.max),Ce=this._rebound(H.x,-le.x),qe=this._rebound(H.y,-le.y);return new I(Ce,qe)},_rebound:function(l,f){return l+f>0?Math.round(l-f)/2:Math.max(0,Math.ceil(l))-Math.max(0,Math.floor(f))},_limitZoom:function(l){var f=this.getMinZoom(),v=this.getMaxZoom(),A=rt.any3d?this.options.zoomSnap:1;return A&&(l=Math.round(l/A)*A),Math.max(f,Math.min(v,l))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){Kt(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(l,f){var v=this._getCenterOffset(l)._trunc();return(f&&f.animate)!==!0&&!this.getSize().contains(v)?!1:(this.panBy(v,f),!0)},_createAnimProxy:function(){var l=this._proxy=ha("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(l),this.on("zoomanim",function(f){var v=gr,A=this._proxy.style[v];wa(this._proxy,this.project(f.center,f.zoom),this.getZoomScale(f.zoom,1)),A===this._proxy.style[v]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){Ia(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var l=this.getCenter(),f=this.getZoom();wa(this._proxy,this.project(l,f),this.getZoomScale(f,1))},_catchTransitionEnd:function(l){this._animatingZoom&&l.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(l,f,v){if(this._animatingZoom)return!0;if(v=v||{},!this._zoomAnimated||v.animate===!1||this._nothingToAnimate()||Math.abs(f-this._zoom)>this.options.zoomAnimationThreshold)return!1;var A=this.getZoomScale(f),H=this._getCenterOffset(l)._divideBy(1-1/A);return v.animate!==!0&&!this.getSize().contains(H)?!1:(ye(function(){this._moveStart(!0,v.noMoveStart||!1)._animateZoom(l,f,!0)},this),!0)},_animateZoom:function(l,f,v,A){this._mapPane&&(v&&(this._animatingZoom=!0,this._animateToCenter=l,this._animateToZoom=f,Bt(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:l,zoom:f,noUpdate:A}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(d(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&Kt(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function Pl(l,f){return new Ra(l,f)}var Rs=se.extend({options:{position:"topright"},initialize:function(l){k(this,l)},getPosition:function(){return this.options.position},setPosition:function(l){var f=this._map;return f&&f.removeControl(this),this.options.position=l,f&&f.addControl(this),this},getContainer:function(){return this._container},addTo:function(l){this.remove(),this._map=l;var f=this._container=this.onAdd(l),v=this.getPosition(),A=l._controlCorners[v];return Bt(f,"leaflet-control"),v.indexOf("bottom")!==-1?A.insertBefore(f,A.firstChild):A.appendChild(f),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(Ia(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(l){this._map&&l&&l.screenX>0&&l.screenY>0&&this._map.getContainer().focus()}}),es=function(l){return new Rs(l)};Ra.include({addControl:function(l){return l.addTo(this),this},removeControl:function(l){return l.remove(),this},_initControlPos:function(){var l=this._controlCorners={},f="leaflet-",v=this._controlContainer=ha("div",f+"control-container",this._container);function A(H,le){var Ce=f+H+" "+f+le;l[H+le]=ha("div",Ce,v)}A("top","left"),A("top","right"),A("bottom","left"),A("bottom","right")},_clearControlPos:function(){for(var l in this._controlCorners)Ia(this._controlCorners[l]);Ia(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var dn=Rs.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(l,f,v,A){return v<A?-1:A<v?1:0}},initialize:function(l,f,v){k(this,v),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._preventClick=!1;for(var A in l)this._addLayer(l[A],A);for(A in f)this._addLayer(f[A],A,!0)},onAdd:function(l){this._initLayout(),this._update(),this._map=l,l.on("zoomend",this._checkDisabledLayers,this);for(var f=0;f<this._layers.length;f++)this._layers[f].layer.on("add remove",this._onLayerChange,this);return this._container},addTo:function(l){return Rs.prototype.addTo.call(this,l),this._expandIfNotCollapsed()},onRemove:function(){this._map.off("zoomend",this._checkDisabledLayers,this);for(var l=0;l<this._layers.length;l++)this._layers[l].layer.off("add remove",this._onLayerChange,this)},addBaseLayer:function(l,f){return this._addLayer(l,f),this._map?this._update():this},addOverlay:function(l,f){return this._addLayer(l,f,!0),this._map?this._update():this},removeLayer:function(l){l.off("add remove",this._onLayerChange,this);var f=this._getLayer(h(l));return f&&this._layers.splice(this._layers.indexOf(f),1),this._map?this._update():this},expand:function(){Bt(this._container,"leaflet-control-layers-expanded"),this._section.style.height=null;var l=this._map.getSize().y-(this._container.offsetTop+50);return l<this._section.clientHeight?(Bt(this._section,"leaflet-control-layers-scrollbar"),this._section.style.height=l+"px"):Kt(this._section,"leaflet-control-layers-scrollbar"),this._checkDisabledLayers(),this},collapse:function(){return Kt(this._container,"leaflet-control-layers-expanded"),this},_initLayout:function(){var l="leaflet-control-layers",f=this._container=ha("div",l),v=this.options.collapsed;f.setAttribute("aria-haspopup",!0),zn(f),Ls(f);var A=this._section=ha("section",l+"-list");v&&(this._map.on("click",this.collapse,this),oa(f,{mouseenter:this._expandSafely,mouseleave:this.collapse},this));var H=this._layersLink=ha("a",l+"-toggle",f);H.href="#",H.title="Layers",H.setAttribute("role","button"),oa(H,{keydown:function(le){le.keyCode===13&&this._expandSafely()},click:function(le){Cr(le),this._expandSafely()}},this),v||this.expand(),this._baseLayersList=ha("div",l+"-base",A),this._separator=ha("div",l+"-separator",A),this._overlaysList=ha("div",l+"-overlays",A),f.appendChild(A)},_getLayer:function(l){for(var f=0;f<this._layers.length;f++)if(this._layers[f]&&h(this._layers[f].layer)===l)return this._layers[f]},_addLayer:function(l,f,v){this._map&&l.on("add remove",this._onLayerChange,this),this._layers.push({layer:l,name:f,overlay:v}),this.options.sortLayers&&this._layers.sort(d(function(A,H){return this.options.sortFunction(A.layer,H.layer,A.name,H.name)},this)),this.options.autoZIndex&&l.setZIndex&&(this._lastZIndex++,l.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()},_update:function(){if(!this._container)return this;qr(this._baseLayersList),qr(this._overlaysList),this._layerControlInputs=[];var l,f,v,A,H=0;for(v=0;v<this._layers.length;v++)A=this._layers[v],this._addItem(A),f=f||A.overlay,l=l||!A.overlay,H+=A.overlay?0:1;return this.options.hideSingleBase&&(l=l&&H>1,this._baseLayersList.style.display=l?"":"none"),this._separator.style.display=f&&l?"":"none",this},_onLayerChange:function(l){this._handlingClick||this._update();var f=this._getLayer(h(l.target)),v=f.overlay?l.type==="add"?"overlayadd":"overlayremove":l.type==="add"?"baselayerchange":null;v&&this._map.fire(v,f)},_createRadioElement:function(l,f){var v='<input type="radio" class="leaflet-control-layers-selector" name="'+l+'"'+(f?' checked="checked"':"")+"/>",A=document.createElement("div");return A.innerHTML=v,A.firstChild},_addItem:function(l){var f=document.createElement("label"),v=this._map.hasLayer(l.layer),A;l.overlay?(A=document.createElement("input"),A.type="checkbox",A.className="leaflet-control-layers-selector",A.defaultChecked=v):A=this._createRadioElement("leaflet-base-layers_"+h(this),v),this._layerControlInputs.push(A),A.layerId=h(l.layer),oa(A,"click",this._onInputClick,this);var H=document.createElement("span");H.innerHTML=" "+l.name;var le=document.createElement("span");f.appendChild(le),le.appendChild(A),le.appendChild(H);var Ce=l.overlay?this._overlaysList:this._baseLayersList;return Ce.appendChild(f),this._checkDisabledLayers(),f},_onInputClick:function(){if(!this._preventClick){var l=this._layerControlInputs,f,v,A=[],H=[];this._handlingClick=!0;for(var le=l.length-1;le>=0;le--)f=l[le],v=this._getLayer(f.layerId).layer,f.checked?A.push(v):f.checked||H.push(v);for(le=0;le<H.length;le++)this._map.hasLayer(H[le])&&this._map.removeLayer(H[le]);for(le=0;le<A.length;le++)this._map.hasLayer(A[le])||this._map.addLayer(A[le]);this._handlingClick=!1,this._refocusOnMap()}},_checkDisabledLayers:function(){for(var l=this._layerControlInputs,f,v,A=this._map.getZoom(),H=l.length-1;H>=0;H--)f=l[H],v=this._getLayer(f.layerId).layer,f.disabled=v.options.minZoom!==void 0&&A<v.options.minZoom||v.options.maxZoom!==void 0&&A>v.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var l=this._section;this._preventClick=!0,oa(l,"click",Cr),this.expand();var f=this;setTimeout(function(){za(l,"click",Cr),f._preventClick=!1})}}),qi=function(l,f,v){return new dn(l,f,v)},vo=Rs.extend({options:{position:"topleft",zoomInText:'<span aria-hidden="true">+</span>',zoomInTitle:"Zoom in",zoomOutText:'<span aria-hidden="true">&#x2212;</span>',zoomOutTitle:"Zoom out"},onAdd:function(l){var f="leaflet-control-zoom",v=ha("div",f+" leaflet-bar"),A=this.options;return this._zoomInButton=this._createButton(A.zoomInText,A.zoomInTitle,f+"-in",v,this._zoomIn),this._zoomOutButton=this._createButton(A.zoomOutText,A.zoomOutTitle,f+"-out",v,this._zoomOut),this._updateDisabled(),l.on("zoomend zoomlevelschange",this._updateDisabled,this),v},onRemove:function(l){l.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(l){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&this._map.zoomIn(this._map.options.zoomDelta*(l.shiftKey?3:1))},_zoomOut:function(l){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(l.shiftKey?3:1))},_createButton:function(l,f,v,A,H){var le=ha("a",v,A);return le.innerHTML=l,le.href="#",le.title=f,le.setAttribute("role","button"),le.setAttribute("aria-label",f),zn(le),oa(le,"click",Bn),oa(le,"click",H,this),oa(le,"click",this._refocusOnMap,this),le},_updateDisabled:function(){var l=this._map,f="leaflet-disabled";Kt(this._zoomInButton,f),Kt(this._zoomOutButton,f),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||l._zoom===l.getMinZoom())&&(Bt(this._zoomOutButton,f),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||l._zoom===l.getMaxZoom())&&(Bt(this._zoomInButton,f),this._zoomInButton.setAttribute("aria-disabled","true"))}});Ra.mergeOptions({zoomControl:!0}),Ra.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new vo,this.addControl(this.zoomControl))});var li=function(l){return new vo(l)},Fc=Rs.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(l){var f="leaflet-control-scale",v=ha("div",f),A=this.options;return this._addScales(A,f+"-line",v),l.on(A.updateWhenIdle?"moveend":"move",this._update,this),l.whenReady(this._update,this),v},onRemove:function(l){l.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(l,f,v){l.metric&&(this._mScale=ha("div",f,v)),l.imperial&&(this._iScale=ha("div",f,v))},_update:function(){var l=this._map,f=l.getSize().y/2,v=l.distance(l.containerPointToLatLng([0,f]),l.containerPointToLatLng([this.options.maxWidth,f]));this._updateScales(v)},_updateScales:function(l){this.options.metric&&l&&this._updateMetric(l),this.options.imperial&&l&&this._updateImperial(l)},_updateMetric:function(l){var f=this._getRoundNum(l),v=f<1e3?f+" m":f/1e3+" km";this._updateScale(this._mScale,v,f/l)},_updateImperial:function(l){var f=l*3.2808399,v,A,H;f>5280?(v=f/5280,A=this._getRoundNum(v),this._updateScale(this._iScale,A+" mi",A/v)):(H=this._getRoundNum(f),this._updateScale(this._iScale,H+" ft",H/f))},_updateScale:function(l,f,v){l.style.width=Math.round(this.options.maxWidth*v)+"px",l.innerHTML=f},_getRoundNum:function(l){var f=Math.pow(10,(Math.floor(l)+"").length-1),v=l/f;return v=v>=10?10:v>=5?5:v>=3?3:v>=2?2:1,f*v}}),Fl=function(l){return new Fc(l)},Qd='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8" class="leaflet-attribution-flag"><path fill="#4C7BE1" d="M0 0h12v4H0z"/><path fill="#FFD500" d="M0 4h12v3H0z"/><path fill="#E0BC00" d="M0 7h12v1H0z"/></svg>',Il=Rs.extend({options:{position:"bottomright",prefix:'<a href="https://leafletjs.com" title="A JavaScript library for interactive maps">'+(rt.inlineSvg?Qd+" ":"")+"Leaflet</a>"},initialize:function(l){k(this,l),this._attributions={}},onAdd:function(l){l.attributionControl=this,this._container=ha("div","leaflet-control-attribution"),zn(this._container);for(var f in l._layers)l._layers[f].getAttribution&&this.addAttribution(l._layers[f].getAttribution());return this._update(),l.on("layeradd",this._addAttribution,this),this._container},onRemove:function(l){l.off("layeradd",this._addAttribution,this)},_addAttribution:function(l){l.layer.getAttribution&&(this.addAttribution(l.layer.getAttribution()),l.layer.once("remove",function(){this.removeAttribution(l.layer.getAttribution())},this))},setPrefix:function(l){return this.options.prefix=l,this._update(),this},addAttribution:function(l){return l?(this._attributions[l]||(this._attributions[l]=0),this._attributions[l]++,this._update(),this):this},removeAttribution:function(l){return l?(this._attributions[l]&&(this._attributions[l]--,this._update()),this):this},_update:function(){if(this._map){var l=[];for(var f in this._attributions)this._attributions[f]&&l.push(f);var v=[];this.options.prefix&&v.push(this.options.prefix),l.length&&v.push(l.join(", ")),this._container.innerHTML=v.join(' <span aria-hidden="true">|</span> ')}}});Ra.mergeOptions({attributionControl:!0}),Ra.addInitHook(function(){this.options.attributionControl&&new Il().addTo(this)});var ci=function(l){return new Il(l)};Rs.Layers=dn,Rs.Zoom=vo,Rs.Scale=Fc,Rs.Attribution=Il,es.layers=qi,es.zoom=li,es.scale=Fl,es.attribution=ci;var fs=se.extend({initialize:function(l){this._map=l},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});fs.addTo=function(l,f){return l.addHandler(f,this),this};var tl={Events:te},_o=rt.touch?"touchstart mousedown":"mousedown",$n=W.extend({options:{clickTolerance:3},initialize:function(l,f,v,A){k(this,A),this._element=l,this._dragStartTarget=f||l,this._preventOutline=v},enable:function(){this._enabled||(oa(this._dragStartTarget,_o,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&($n._dragging===this&&this.finishDrag(!0),za(this._dragStartTarget,_o,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(l){if(this._enabled&&(this._moved=!1,!$e(this._element,"leaflet-zoom-anim"))){if(l.touches&&l.touches.length!==1){$n._dragging===this&&this.finishDrag();return}if(!($n._dragging||l.shiftKey||l.which!==1&&l.button!==1&&!l.touches)&&($n._dragging=this,this._preventOutline&&yt(this._element),Ms(),_s(),!this._moving)){this.fire("down");var f=l.touches?l.touches[0]:l,v=_r(this._element);this._startPoint=new I(f.clientX,f.clientY),this._startPos=cn(this._element),this._parentScale=Sr(v);var A=l.type==="mousedown";oa(document,A?"mousemove":"touchmove",this._onMove,this),oa(document,A?"mouseup":"touchend touchcancel",this._onUp,this)}}},_onMove:function(l){if(this._enabled){if(l.touches&&l.touches.length>1){this._moved=!0;return}var f=l.touches&&l.touches.length===1?l.touches[0]:l,v=new I(f.clientX,f.clientY)._subtract(this._startPoint);!v.x&&!v.y||Math.abs(v.x)+Math.abs(v.y)<this.options.clickTolerance||(v.x/=this._parentScale.x,v.y/=this._parentScale.y,Cr(l),this._moved||(this.fire("dragstart"),this._moved=!0,Bt(document.body,"leaflet-dragging"),this._lastTarget=l.target||l.srcElement,window.SVGElementInstance&&this._lastTarget instanceof window.SVGElementInstance&&(this._lastTarget=this._lastTarget.correspondingUseElement),Bt(this._lastTarget,"leaflet-drag-target")),this._newPos=this._startPos.add(v),this._moving=!0,this._lastEvent=l,this._updatePosition())}},_updatePosition:function(){var l={originalEvent:this._lastEvent};this.fire("predrag",l),Za(this._element,this._newPos),this.fire("drag",l)},_onUp:function(){this._enabled&&this.finishDrag()},finishDrag:function(l){Kt(document.body,"leaflet-dragging"),this._lastTarget&&(Kt(this._lastTarget,"leaflet-drag-target"),this._lastTarget=null),za(document,"mousemove touchmove",this._onMove,this),za(document,"mouseup touchend touchcancel",this._onUp,this),oi(),Gr();var f=this._moved&&this._moving;this._moving=!1,$n._dragging=!1,f&&this.fire("dragend",{noInertia:l,distance:this._newPos.distanceTo(this._startPos)})}});function Ic(l,f,v){var A,H=[1,4,2,8],le,Ce,qe,tt,Tt,Xt,ua,Oa;for(le=0,Xt=l.length;le<Xt;le++)l[le]._code=un(l[le],f);for(qe=0;qe<4;qe++){for(ua=H[qe],A=[],le=0,Xt=l.length,Ce=Xt-1;le<Xt;Ce=le++)tt=l[le],Tt=l[Ce],tt._code&ua?Tt._code&ua||(Oa=wo(Tt,tt,ua,f,v),Oa._code=un(Oa,f),A.push(Oa)):(Tt._code&ua&&(Oa=wo(Tt,tt,ua,f,v),Oa._code=un(Oa,f),A.push(Oa)),A.push(tt));l=A}return l}function zc(l,f){var v,A,H,le,Ce,qe,tt,Tt,Xt;if(!l||l.length===0)throw new Error("latlngs not passed");tn(l)||(console.warn("latlngs are not flat! Only the first ring will be used"),l=l[0]);var ua=we([0,0]),Oa=X(l),ps=Oa.getNorthWest().distanceTo(Oa.getSouthWest())*Oa.getNorthEast().distanceTo(Oa.getNorthWest());ps<1700&&(ua=zl(l));var Ur=l.length,gn=[];for(v=0;v<Ur;v++){var Xa=we(l[v]);gn.push(f.project(we([Xa.lat-ua.lat,Xa.lng-ua.lng])))}for(qe=tt=Tt=0,v=0,A=Ur-1;v<Ur;A=v++)H=gn[v],le=gn[A],Ce=H.y*le.x-le.y*H.x,tt+=(H.x+le.x)*Ce,Tt+=(H.y+le.y)*Ce,qe+=Ce*3;qe===0?Xt=gn[0]:Xt=[tt/qe,Tt/qe];var Ka=f.unproject(ae(Xt));return we([Ka.lat+ua.lat,Ka.lng+ua.lng])}function zl(l){for(var f=0,v=0,A=0,H=0;H<l.length;H++){var le=we(l[H]);f+=le.lat,v+=le.lng,A++}return we([f/A,v/A])}var Bl={__proto__:null,clipPolygon:Ic,polygonCenter:zc,centroid:zl};function Bc(l,f){if(!f||!l.length)return l.slice();var v=f*f;return l=t0(l,v),l=al(l,v),l}function Uc(l,f,v){return Math.sqrt(di(l,f,v,!0))}function e0(l,f,v){return di(l,f,v)}function al(l,f){var v=l.length,A=typeof Uint8Array!="undefined"?Uint8Array:Array,H=new A(v);H[0]=H[v-1]=1,Ul(l,H,f,0,v-1);var le,Ce=[];for(le=0;le<v;le++)H[le]&&Ce.push(l[le]);return Ce}function Ul(l,f,v,A,H){var le=0,Ce,qe,tt;for(qe=A+1;qe<=H-1;qe++)tt=di(l[qe],l[A],l[H],!0),tt>le&&(Ce=qe,le=tt);le>v&&(f[Ce]=1,Ul(l,f,v,A,Ce),Ul(l,f,v,Ce,H))}function t0(l,f){for(var v=[l[0]],A=1,H=0,le=l.length;A<le;A++)$l(l[A],l[H])>f&&(v.push(l[A]),H=A);return H<le-1&&v.push(l[le-1]),v}var $c;function Hc(l,f,v,A,H){var le=A?$c:un(l,v),Ce=un(f,v),qe,tt,Tt;for($c=Ce;;){if(!(le|Ce))return[l,f];if(le&Ce)return!1;qe=le||Ce,tt=wo(l,f,qe,v,H),Tt=un(tt,v),qe===le?(l=tt,le=Tt):(f=tt,Ce=Tt)}}function wo(l,f,v,A,H){var le=f.x-l.x,Ce=f.y-l.y,qe=A.min,tt=A.max,Tt,Xt;return v&8?(Tt=l.x+le*(tt.y-l.y)/Ce,Xt=tt.y):v&4?(Tt=l.x+le*(qe.y-l.y)/Ce,Xt=qe.y):v&2?(Tt=tt.x,Xt=l.y+Ce*(tt.x-l.x)/le):v&1&&(Tt=qe.x,Xt=l.y+Ce*(qe.x-l.x)/le),new I(Tt,Xt,H)}function un(l,f){var v=0;return l.x<f.min.x?v|=1:l.x>f.max.x&&(v|=2),l.y<f.min.y?v|=4:l.y>f.max.y&&(v|=8),v}function $l(l,f){var v=f.x-l.x,A=f.y-l.y;return v*v+A*A}function di(l,f,v,A){var H=f.x,le=f.y,Ce=v.x-H,qe=v.y-le,tt=Ce*Ce+qe*qe,Tt;return tt>0&&(Tt=((l.x-H)*Ce+(l.y-le)*qe)/tt,Tt>1?(H=v.x,le=v.y):Tt>0&&(H+=Ce*Tt,le+=qe*Tt)),Ce=l.x-H,qe=l.y-le,A?Ce*Ce+qe*qe:new I(H,le)}function tn(l){return!E(l[0])||typeof l[0][0]!="object"&&typeof l[0][0]!="undefined"}function rl(l){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),tn(l)}function Gi(l,f){var v,A,H,le,Ce,qe,tt,Tt;if(!l||l.length===0)throw new Error("latlngs not passed");tn(l)||(console.warn("latlngs are not flat! Only the first ring will be used"),l=l[0]);var Xt=we([0,0]),ua=X(l),Oa=ua.getNorthWest().distanceTo(ua.getSouthWest())*ua.getNorthEast().distanceTo(ua.getNorthWest());Oa<1700&&(Xt=zl(l));var ps=l.length,Ur=[];for(v=0;v<ps;v++){var gn=we(l[v]);Ur.push(f.project(we([gn.lat-Xt.lat,gn.lng-Xt.lng])))}for(v=0,A=0;v<ps-1;v++)A+=Ur[v].distanceTo(Ur[v+1])/2;if(A===0)Tt=Ur[0];else for(v=0,le=0;v<ps-1;v++)if(Ce=Ur[v],qe=Ur[v+1],H=Ce.distanceTo(qe),le+=H,le>A){tt=(le-A)/H,Tt=[qe.x-tt*(qe.x-Ce.x),qe.y-tt*(qe.y-Ce.y)];break}var Xa=f.unproject(ae(Tt));return we([Xa.lat+Xt.lat,Xa.lng+Xt.lng])}var a0={__proto__:null,simplify:Bc,pointToSegmentDistance:Uc,closestPointOnSegment:e0,clipSegment:Hc,_getEdgeIntersection:wo,_getBitCode:un,_sqClosestPointOnSegment:di,isFlat:tn,_flat:rl,polylineCenter:Gi},ko={project:function(l){return new I(l.lng,l.lat)},unproject:function(l){return new K(l.y,l.x)},bounds:new F([-180,-90],[180,90])},jr={R:6378137,R_MINOR:6356752314245179e-9,bounds:new F([-2003750834279e-5,-1549657073972e-5],[2003750834279e-5,1876465623138e-5]),project:function(l){var f=Math.PI/180,v=this.R,A=l.lat*f,H=this.R_MINOR/v,le=Math.sqrt(1-H*H),Ce=le*Math.sin(A),qe=Math.tan(Math.PI/4-A/2)/Math.pow((1-Ce)/(1+Ce),le/2);return A=-v*Math.log(Math.max(qe,1e-10)),new I(l.lng*f*v,A)},unproject:function(l){for(var f=180/Math.PI,v=this.R,A=this.R_MINOR/v,H=Math.sqrt(1-A*A),le=Math.exp(-l.y/v),Ce=Math.PI/2-2*Math.atan(le),qe=0,tt=.1,Tt;qe<15&&Math.abs(tt)>1e-7;qe++)Tt=H*Math.sin(Ce),Tt=Math.pow((1-Tt)/(1+Tt),H/2),tt=Math.PI/2-2*Math.atan(le*Tt)-Ce,Ce+=tt;return new K(Ce*f,l.x*f/v)}},Hl={__proto__:null,LonLat:ko,Mercator:jr,SphericalMercator:z},Wc=i({},ke,{code:"EPSG:3395",projection:jr,transformation:(function(){var l=.5/(Math.PI*jr.R);return Xe(l,.5,-l,.5)})()}),Wl=i({},ke,{code:"EPSG:4326",projection:ko,transformation:Xe(1/180,1,-1/180,.5)}),Yi=i({},be,{projection:ko,transformation:Xe(1,0,-1,0),scale:function(l){return Math.pow(2,l)},zoom:function(l){return Math.log(l)/Math.LN2},distance:function(l,f){var v=f.lng-l.lng,A=f.lat-l.lat;return Math.sqrt(v*v+A*A)},infinite:!0});be.Earth=ke,be.EPSG3395=Wc,be.EPSG3857=gt,be.EPSG900913=St,be.EPSG4326=Wl,be.Simple=Yi;var mn=W.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(l){return l.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(l){return l&&l.removeLayer(this),this},getPane:function(l){return this._map.getPane(l?this.options[l]||l:this.options.pane)},addInteractiveTarget:function(l){return this._map._targets[h(l)]=this,this},removeInteractiveTarget:function(l){return delete this._map._targets[h(l)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(l){var f=l.target;if(f.hasLayer(this)){if(this._map=f,this._zoomAnimated=f._zoomAnimated,this.getEvents){var v=this.getEvents();f.on(v,this),this.once("remove",function(){f.off(v,this)},this)}this.onAdd(f),this.fire("add"),f.fire("layeradd",{layer:this})}}});Ra.include({addLayer:function(l){if(!l._layerAdd)throw new Error("The provided object is not a Layer.");var f=h(l);return this._layers[f]?this:(this._layers[f]=l,l._mapToAdd=this,l.beforeAdd&&l.beforeAdd(this),this.whenReady(l._layerAdd,l),this)},removeLayer:function(l){var f=h(l);return this._layers[f]?(this._loaded&&l.onRemove(this),delete this._layers[f],this._loaded&&(this.fire("layerremove",{layer:l}),l.fire("remove")),l._map=l._mapToAdd=null,this):this},hasLayer:function(l){return h(l)in this._layers},eachLayer:function(l,f){for(var v in this._layers)l.call(f,this._layers[v]);return this},_addLayers:function(l){l=l?E(l)?l:[l]:[];for(var f=0,v=l.length;f<v;f++)this.addLayer(l[f])},_addZoomLimit:function(l){(!isNaN(l.options.maxZoom)||!isNaN(l.options.minZoom))&&(this._zoomBoundLayers[h(l)]=l,this._updateZoomLevels())},_removeZoomLimit:function(l){var f=h(l);this._zoomBoundLayers[f]&&(delete this._zoomBoundLayers[f],this._updateZoomLevels())},_updateZoomLevels:function(){var l=1/0,f=-1/0,v=this._getZoomSpan();for(var A in this._zoomBoundLayers){var H=this._zoomBoundLayers[A].options;l=H.minZoom===void 0?l:Math.min(l,H.minZoom),f=H.maxZoom===void 0?f:Math.max(f,H.maxZoom)}this._layersMaxZoom=f===-1/0?void 0:f,this._layersMinZoom=l===1/0?void 0:l,v!==this._getZoomSpan()&&this.fire("zoomlevelschange"),this.options.maxZoom===void 0&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom&&this.setZoom(this._layersMinZoom)}});var Zi=mn.extend({initialize:function(l,f){k(this,f),this._layers={};var v,A;if(l)for(v=0,A=l.length;v<A;v++)this.addLayer(l[v])},addLayer:function(l){var f=this.getLayerId(l);return this._layers[f]=l,this._map&&this._map.addLayer(l),this},removeLayer:function(l){var f=l in this._layers?l:this.getLayerId(l);return this._map&&this._layers[f]&&this._map.removeLayer(this._layers[f]),delete this._layers[f],this},hasLayer:function(l){var f=typeof l=="number"?l:this.getLayerId(l);return f in this._layers},clearLayers:function(){return this.eachLayer(this.removeLayer,this)},invoke:function(l){var f=Array.prototype.slice.call(arguments,1),v,A;for(v in this._layers)A=this._layers[v],A[l]&&A[l].apply(A,f);return this},onAdd:function(l){this.eachLayer(l.addLayer,l)},onRemove:function(l){this.eachLayer(l.removeLayer,l)},eachLayer:function(l,f){for(var v in this._layers)l.call(f,this._layers[v]);return this},getLayer:function(l){return this._layers[l]},getLayers:function(){var l=[];return this.eachLayer(l.push,l),l},setZIndex:function(l){return this.invoke("setZIndex",l)},getLayerId:function(l){return h(l)}}),r0=function(l,f){return new Zi(l,f)},jn=Zi.extend({addLayer:function(l){return this.hasLayer(l)?this:(l.addEventParent(this),Zi.prototype.addLayer.call(this,l),this.fire("layeradd",{layer:l}))},removeLayer:function(l){return this.hasLayer(l)?(l in this._layers&&(l=this._layers[l]),l.removeEventParent(this),Zi.prototype.removeLayer.call(this,l),this.fire("layerremove",{layer:l})):this},setStyle:function(l){return this.invoke("setStyle",l)},bringToFront:function(){return this.invoke("bringToFront")},bringToBack:function(){return this.invoke("bringToBack")},getBounds:function(){var l=new B;for(var f in this._layers){var v=this._layers[f];l.extend(v.getBounds?v.getBounds():v.getLatLng())}return l}}),Vc=function(l,f){return new jn(l,f)},Ps=se.extend({options:{popupAnchor:[0,0],tooltipAnchor:[0,0],crossOrigin:!1},initialize:function(l){k(this,l)},createIcon:function(l){return this._createIcon("icon",l)},createShadow:function(l){return this._createIcon("shadow",l)},_createIcon:function(l,f){var v=this._getIconUrl(l);if(!v){if(l==="icon")throw new Error("iconUrl not set in Icon options (see the docs).");return null}var A=this._createImg(v,f&&f.tagName==="IMG"?f:null);return this._setIconStyles(A,l),(this.options.crossOrigin||this.options.crossOrigin==="")&&(A.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),A},_setIconStyles:function(l,f){var v=this.options,A=v[f+"Size"];typeof A=="number"&&(A=[A,A]);var H=ae(A),le=ae(f==="shadow"&&v.shadowAnchor||v.iconAnchor||H&&H.divideBy(2,!0));l.className="leaflet-marker-"+f+" "+(v.className||""),le&&(l.style.marginLeft=-le.x+"px",l.style.marginTop=-le.y+"px"),H&&(l.style.width=H.x+"px",l.style.height=H.y+"px")},_createImg:function(l,f){return f=f||document.createElement("img"),f.src=l,f},_getIconUrl:function(l){return rt.retina&&this.options[l+"RetinaUrl"]||this.options[l+"Url"]}});function jo(l){return new Ps(l)}var No=Ps.extend({options:{iconUrl:"marker-icon.png",iconRetinaUrl:"marker-icon-2x.png",shadowUrl:"marker-shadow.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]},_getIconUrl:function(l){return typeof No.imagePath!="string"&&(No.imagePath=this._detectIconPath()),(this.options.imagePath||No.imagePath)+Ps.prototype._getIconUrl.call(this,l)},_stripUrl:function(l){var f=function(v,A,H){var le=A.exec(v);return le&&le[H]};return l=f(l,/^url\((['"])?(.+)\1\)$/,2),l&&f(l,/^(.*)marker-icon\.png$/,1)},_detectIconPath:function(){var l=ha("div","leaflet-default-icon-path",document.body),f=hs(l,"background-image")||hs(l,"backgroundImage");if(document.body.removeChild(l),f=this._stripUrl(f),f)return f;var v=document.querySelector('link[href$="leaflet.css"]');return v?v.href.substring(0,v.href.length-11-1):""}}),So=fs.extend({initialize:function(l){this._marker=l},addHooks:function(){var l=this._marker._icon;this._draggable||(this._draggable=new $n(l,l,!0)),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),Bt(l,"leaflet-marker-draggable")},removeHooks:function(){this._draggable.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon&&Kt(this._marker._icon,"leaflet-marker-draggable")},moved:function(){return this._draggable&&this._draggable._moved},_adjustPan:function(l){var f=this._marker,v=f._map,A=this._marker.options.autoPanSpeed,H=this._marker.options.autoPanPadding,le=cn(f._icon),Ce=v.getPixelBounds(),qe=v.getPixelOrigin(),tt=M(Ce.min._subtract(qe).add(H),Ce.max._subtract(qe).subtract(H));if(!tt.contains(le)){var Tt=ae((Math.max(tt.max.x,le.x)-tt.max.x)/(Ce.max.x-tt.max.x)-(Math.min(tt.min.x,le.x)-tt.min.x)/(Ce.min.x-tt.min.x),(Math.max(tt.max.y,le.y)-tt.max.y)/(Ce.max.y-tt.max.y)-(Math.min(tt.min.y,le.y)-tt.min.y)/(Ce.min.y-tt.min.y)).multiplyBy(A);v.panBy(Tt,{animate:!1}),this._draggable._newPos._add(Tt),this._draggable._startPos._add(Tt),Za(f._icon,this._draggable._newPos),this._onDrag(l),this._panRequest=ye(this._adjustPan.bind(this,l))}},_onDragStart:function(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup&&this._marker.closePopup(),this._marker.fire("movestart").fire("dragstart")},_onPreDrag:function(l){this._marker.options.autoPan&&(he(this._panRequest),this._panRequest=ye(this._adjustPan.bind(this,l)))},_onDrag:function(l){var f=this._marker,v=f._shadow,A=cn(f._icon),H=f._map.layerPointToLatLng(A);v&&Za(v,A),f._latlng=H,l.latlng=H,l.oldLatLng=this._oldLatLng,f.fire("move",l).fire("drag",l)},_onDragEnd:function(l){he(this._panRequest),delete this._oldLatLng,this._marker.fire("moveend").fire("dragend",l)}}),Ji=mn.extend({options:{icon:new No,interactive:!0,keyboard:!0,title:"",alt:"Marker",zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:"markerPane",shadowPane:"shadowPane",bubblingMouseEvents:!1,autoPanOnFocus:!0,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10},initialize:function(l,f){k(this,f),this._latlng=we(l)},onAdd:function(l){this._zoomAnimated=this._zoomAnimated&&l.options.markerZoomAnimation,this._zoomAnimated&&l.on("zoomanim",this._animateZoom,this),this._initIcon(),this.update()},onRemove:function(l){this.dragging&&this.dragging.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&l.off("zoomanim",this._animateZoom,this),this._removeIcon(),this._removeShadow()},getEvents:function(){return{zoom:this.update,viewreset:this.update}},getLatLng:function(){return this._latlng},setLatLng:function(l){var f=this._latlng;return this._latlng=we(l),this.update(),this.fire("move",{oldLatLng:f,latlng:this._latlng})},setZIndexOffset:function(l){return this.options.zIndexOffset=l,this.update()},getIcon:function(){return this.options.icon},setIcon:function(l){return this.options.icon=l,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup,this._popup.options),this},getElement:function(){return this._icon},update:function(){if(this._icon&&this._map){var l=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(l)}return this},_initIcon:function(){var l=this.options,f="leaflet-zoom-"+(this._zoomAnimated?"animated":"hide"),v=l.icon.createIcon(this._icon),A=!1;v!==this._icon&&(this._icon&&this._removeIcon(),A=!0,l.title&&(v.title=l.title),v.tagName==="IMG"&&(v.alt=l.alt||"")),Bt(v,f),l.keyboard&&(v.tabIndex="0",v.setAttribute("role","button")),this._icon=v,l.riseOnHover&&this.on({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&oa(v,"focus",this._panOnFocus,this);var H=l.icon.createShadow(this._shadow),le=!1;H!==this._shadow&&(this._removeShadow(),le=!0),H&&(Bt(H,f),H.alt=""),this._shadow=H,l.opacity<1&&this._updateOpacity(),A&&this.getPane().appendChild(this._icon),this._initInteraction(),H&&le&&this.getPane(l.shadowPane).appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&za(this._icon,"focus",this._panOnFocus,this),Ia(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&Ia(this._shadow),this._shadow=null},_setPos:function(l){this._icon&&Za(this._icon,l),this._shadow&&Za(this._shadow,l),this._zIndex=l.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(l){this._icon&&(this._icon.style.zIndex=this._zIndex+l)},_animateZoom:function(l){var f=this._map._latLngToNewLayerPoint(this._latlng,l.zoom,l.center).round();this._setPos(f)},_initInteraction:function(){if(this.options.interactive&&(Bt(this._icon,"leaflet-interactive"),this.addInteractiveTarget(this._icon),So)){var l=this.options.draggable;this.dragging&&(l=this.dragging.enabled(),this.dragging.disable()),this.dragging=new So(this),l&&this.dragging.enable()}},setOpacity:function(l){return this.options.opacity=l,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var l=this.options.opacity;this._icon&&Aa(this._icon,l),this._shadow&&Aa(this._shadow,l)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_panOnFocus:function(){var l=this._map;if(l){var f=this.options.icon.options,v=f.iconSize?ae(f.iconSize):ae(0,0),A=f.iconAnchor?ae(f.iconAnchor):ae(0,0);l.panInside(this._latlng,{paddingTopLeft:A,paddingBottomRight:v.subtract(A)})}},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor}});function qc(l,f){return new Ji(l,f)}var hn=mn.extend({options:{stroke:!0,color:"#3388ff",weight:3,opacity:1,lineCap:"round",lineJoin:"round",dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:"evenodd",interactive:!0,bubblingMouseEvents:!0},beforeAdd:function(l){this._renderer=l.getRenderer(this)},onAdd:function(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)},onRemove:function(){this._renderer._removePath(this)},redraw:function(){return this._map&&this._renderer._updatePath(this),this},setStyle:function(l){return k(this,l),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&l&&Object.prototype.hasOwnProperty.call(l,"weight")&&this._updateBounds()),this},bringToFront:function(){return this._renderer&&this._renderer._bringToFront(this),this},bringToBack:function(){return this._renderer&&this._renderer._bringToBack(this),this},getElement:function(){return this._path},_reset:function(){this._project(),this._update()},_clickTolerance:function(){return(this.options.stroke?this.options.weight/2:0)+(this._renderer.options.tolerance||0)}}),Xi=hn.extend({options:{fill:!0,radius:10},initialize:function(l,f){k(this,f),this._latlng=we(l),this._radius=this.options.radius},setLatLng:function(l){var f=this._latlng;return this._latlng=we(l),this.redraw(),this.fire("move",{oldLatLng:f,latlng:this._latlng})},getLatLng:function(){return this._latlng},setRadius:function(l){return this.options.radius=this._radius=l,this.redraw()},getRadius:function(){return this._radius},setStyle:function(l){var f=l&&l.radius||this._radius;return hn.prototype.setStyle.call(this,l),this.setRadius(f),this},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng),this._updateBounds()},_updateBounds:function(){var l=this._radius,f=this._radiusY||l,v=this._clickTolerance(),A=[l+v,f+v];this._pxBounds=new F(this._point.subtract(A),this._point.add(A))},_update:function(){this._map&&this._updatePath()},_updatePath:function(){this._renderer._updateCircle(this)},_empty:function(){return this._radius&&!this._renderer._bounds.intersects(this._pxBounds)},_containsPoint:function(l){return l.distanceTo(this._point)<=this._radius+this._clickTolerance()}});function Nn(l,f){return new Xi(l,f)}var Hn=Xi.extend({initialize:function(l,f,v){if(typeof f=="number"&&(f=i({},v,{radius:f})),k(this,f),this._latlng=we(l),isNaN(this.options.radius))throw new Error("Circle radius cannot be NaN");this._mRadius=this.options.radius},setRadius:function(l){return this._mRadius=l,this.redraw()},getRadius:function(){return this._mRadius},getBounds:function(){var l=[this._radius,this._radiusY||this._radius];return new B(this._map.layerPointToLatLng(this._point.subtract(l)),this._map.layerPointToLatLng(this._point.add(l)))},setStyle:hn.prototype.setStyle,_project:function(){var l=this._latlng.lng,f=this._latlng.lat,v=this._map,A=v.options.crs;if(A.distance===ke.distance){var H=Math.PI/180,le=this._mRadius/ke.R/H,Ce=v.project([f+le,l]),qe=v.project([f-le,l]),tt=Ce.add(qe).divideBy(2),Tt=v.unproject(tt).lat,Xt=Math.acos((Math.cos(le*H)-Math.sin(f*H)*Math.sin(Tt*H))/(Math.cos(f*H)*Math.cos(Tt*H)))/H;(isNaN(Xt)||Xt===0)&&(Xt=le/Math.cos(Math.PI/180*f)),this._point=tt.subtract(v.getPixelOrigin()),this._radius=isNaN(Xt)?0:tt.x-v.project([Tt,l-Xt]).x,this._radiusY=tt.y-Ce.y}else{var ua=A.unproject(A.project(this._latlng).subtract([this._mRadius,0]));this._point=v.latLngToLayerPoint(this._latlng),this._radius=this._point.x-v.latLngToLayerPoint(ua).x}this._updateBounds()}});function sl(l,f,v){return new Hn(l,f,v)}var Fs=hn.extend({options:{smoothFactor:1,noClip:!1},initialize:function(l,f){k(this,f),this._setLatLngs(l)},getLatLngs:function(){return this._latlngs},setLatLngs:function(l){return this._setLatLngs(l),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(l){for(var f=1/0,v=null,A=di,H,le,Ce=0,qe=this._parts.length;Ce<qe;Ce++)for(var tt=this._parts[Ce],Tt=1,Xt=tt.length;Tt<Xt;Tt++){H=tt[Tt-1],le=tt[Tt];var ua=A(l,H,le,!0);ua<f&&(f=ua,v=A(l,H,le))}return v&&(v.distance=Math.sqrt(f)),v},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");return Gi(this._defaultShape(),this._map.options.crs)},getBounds:function(){return this._bounds},addLatLng:function(l,f){return f=f||this._defaultShape(),l=we(l),f.push(l),this._bounds.extend(l),this.redraw()},_setLatLngs:function(l){this._bounds=new B,this._latlngs=this._convertLatLngs(l)},_defaultShape:function(){return tn(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(l){for(var f=[],v=tn(l),A=0,H=l.length;A<H;A++)v?(f[A]=we(l[A]),this._bounds.extend(f[A])):f[A]=this._convertLatLngs(l[A]);return f},_project:function(){var l=new F;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,l),this._bounds.isValid()&&l.isValid()&&(this._rawPxBounds=l,this._updateBounds())},_updateBounds:function(){var l=this._clickTolerance(),f=new I(l,l);this._rawPxBounds&&(this._pxBounds=new F([this._rawPxBounds.min.subtract(f),this._rawPxBounds.max.add(f)]))},_projectLatlngs:function(l,f,v){var A=l[0]instanceof K,H=l.length,le,Ce;if(A){for(Ce=[],le=0;le<H;le++)Ce[le]=this._map.latLngToLayerPoint(l[le]),v.extend(Ce[le]);f.push(Ce)}else for(le=0;le<H;le++)this._projectLatlngs(l[le],f,v)},_clipPoints:function(){var l=this._renderer._bounds;if(this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(l))){if(this.options.noClip){this._parts=this._rings;return}var f=this._parts,v,A,H,le,Ce,qe,tt;for(v=0,H=0,le=this._rings.length;v<le;v++)for(tt=this._rings[v],A=0,Ce=tt.length;A<Ce-1;A++)qe=Hc(tt[A],tt[A+1],l,A,!0),qe&&(f[H]=f[H]||[],f[H].push(qe[0]),(qe[1]!==tt[A+1]||A===Ce-2)&&(f[H].push(qe[1]),H++))}},_simplifyPoints:function(){for(var l=this._parts,f=this.options.smoothFactor,v=0,A=l.length;v<A;v++)l[v]=Bc(l[v],f)},_update:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())},_updatePath:function(){this._renderer._updatePoly(this)},_containsPoint:function(l,f){var v,A,H,le,Ce,qe,tt=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(l))return!1;for(v=0,le=this._parts.length;v<le;v++)for(qe=this._parts[v],A=0,Ce=qe.length,H=Ce-1;A<Ce;H=A++)if(!(!f&&A===0)&&Uc(l,qe[H],qe[A])<=tt)return!0;return!1}});function s0(l,f){return new Fs(l,f)}Fs._flat=rl;var Ki=Fs.extend({options:{fill:!0},isEmpty:function(){return!this._latlngs.length||!this._latlngs[0].length},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");return zc(this._defaultShape(),this._map.options.crs)},_convertLatLngs:function(l){var f=Fs.prototype._convertLatLngs.call(this,l),v=f.length;return v>=2&&f[0]instanceof K&&f[0].equals(f[v-1])&&f.pop(),f},_setLatLngs:function(l){Fs.prototype._setLatLngs.call(this,l),tn(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return tn(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var l=this._renderer._bounds,f=this.options.weight,v=new I(f,f);if(l=new F(l.min.subtract(v),l.max.add(v)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(l))){if(this.options.noClip){this._parts=this._rings;return}for(var A=0,H=this._rings.length,le;A<H;A++)le=Ic(this._rings[A],l,!0),le.length&&this._parts.push(le)}},_updatePath:function(){this._renderer._updatePoly(this,!0)},_containsPoint:function(l){var f=!1,v,A,H,le,Ce,qe,tt,Tt;if(!this._pxBounds||!this._pxBounds.contains(l))return!1;for(le=0,tt=this._parts.length;le<tt;le++)for(v=this._parts[le],Ce=0,Tt=v.length,qe=Tt-1;Ce<Tt;qe=Ce++)A=v[Ce],H=v[qe],A.y>l.y!=H.y>l.y&&l.x<(H.x-A.x)*(l.y-A.y)/(H.y-A.y)+A.x&&(f=!f);return f||Fs.prototype._containsPoint.call(this,l,!0)}});function Iu(l,f){return new Ki(l,f)}var Wn=jn.extend({initialize:function(l,f){k(this,f),this._layers={},l&&this.addData(l)},addData:function(l){var f=E(l)?l:l.features,v,A,H;if(f){for(v=0,A=f.length;v<A;v++)H=f[v],(H.geometries||H.geometry||H.features||H.coordinates)&&this.addData(H);return this}var le=this.options;if(le.filter&&!le.filter(l))return this;var Ce=ts(l,le);return Ce?(Ce.feature=Co(l),Ce.defaultOptions=Ce.options,this.resetStyle(Ce),le.onEachFeature&&le.onEachFeature(l,Ce),this.addLayer(Ce)):this},resetStyle:function(l){return l===void 0?this.eachLayer(this.resetStyle,this):(l.options=i({},l.defaultOptions),this._setLayerStyle(l,this.options.style),this)},setStyle:function(l){return this.eachLayer(function(f){this._setLayerStyle(f,l)},this)},_setLayerStyle:function(l,f){l.setStyle&&(typeof f=="function"&&(f=f(l.feature)),l.setStyle(f))}});function ts(l,f){var v=l.type==="Feature"?l.geometry:l,A=v?v.coordinates:null,H=[],le=f&&f.pointToLayer,Ce=f&&f.coordsToLatLng||nl,qe,tt,Tt,Xt;if(!A&&!v)return null;switch(v.type){case"Point":return qe=Ce(A),Qi(le,l,qe,f);case"MultiPoint":for(Tt=0,Xt=A.length;Tt<Xt;Tt++)qe=Ce(A[Tt]),H.push(Qi(le,l,qe,f));return new jn(H);case"LineString":case"MultiLineString":return tt=eo(A,v.type==="LineString"?0:1,Ce),new Fs(tt,f);case"Polygon":case"MultiPolygon":return tt=eo(A,v.type==="Polygon"?1:2,Ce),new Ki(tt,f);case"GeometryCollection":for(Tt=0,Xt=v.geometries.length;Tt<Xt;Tt++){var ua=ts({geometry:v.geometries[Tt],type:"Feature",properties:l.properties},f);ua&&H.push(ua)}return new jn(H);case"FeatureCollection":for(Tt=0,Xt=v.features.length;Tt<Xt;Tt++){var Oa=ts(v.features[Tt],f);Oa&&H.push(Oa)}return new jn(H);default:throw new Error("Invalid GeoJSON object.")}}function Qi(l,f,v,A){return l?l(f,v):new Ji(v,A&&A.markersInheritOptions&&A)}function nl(l){return new K(l[1],l[0],l[2])}function eo(l,f,v){for(var A=[],H=0,le=l.length,Ce;H<le;H++)Ce=f?eo(l[H],f-1,v):(v||nl)(l[H]),A.push(Ce);return A}function to(l,f){return l=we(l),l.alt!==void 0?[j(l.lng,f),j(l.lat,f),j(l.alt,f)]:[j(l.lng,f),j(l.lat,f)]}function ji(l,f,v,A){for(var H=[],le=0,Ce=l.length;le<Ce;le++)H.push(f?ji(l[le],tn(l[le])?0:f-1,v,A):to(l[le],A));return!f&&v&&H.length>0&&H.push(H[0].slice()),H}function ui(l,f){return l.feature?i({},l.feature,{geometry:f}):Co(f)}function Co(l){return l.type==="Feature"||l.type==="FeatureCollection"?l:{type:"Feature",properties:{},geometry:l}}var Vn={toGeoJSON:function(l){return ui(this,{type:"Point",coordinates:to(this.getLatLng(),l)})}};Ji.include(Vn),Hn.include(Vn),Xi.include(Vn),Fs.include({toGeoJSON:function(l){var f=!tn(this._latlngs),v=ji(this._latlngs,f?1:0,!1,l);return ui(this,{type:(f?"Multi":"")+"LineString",coordinates:v})}}),Ki.include({toGeoJSON:function(l){var f=!tn(this._latlngs),v=f&&!tn(this._latlngs[0]),A=ji(this._latlngs,v?2:f?1:0,!0,l);return f||(A=[A]),ui(this,{type:(v?"Multi":"")+"Polygon",coordinates:A})}}),Zi.include({toMultiPoint:function(l){var f=[];return this.eachLayer(function(v){f.push(v.toGeoJSON(l).geometry.coordinates)}),ui(this,{type:"MultiPoint",coordinates:f})},toGeoJSON:function(l){var f=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(f==="MultiPoint")return this.toMultiPoint(l);var v=f==="GeometryCollection",A=[];return this.eachLayer(function(H){if(H.toGeoJSON){var le=H.toGeoJSON(l);if(v)A.push(le.geometry);else{var Ce=Co(le);Ce.type==="FeatureCollection"?A.push.apply(A,Ce.features):A.push(Ce)}}}),v?ui(this,{geometries:A,type:"GeometryCollection"}):{type:"FeatureCollection",features:A}}});function To(l,f){return new Wn(l,f)}var Z=To,pe=mn.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(l,f,v){this._url=l,this._bounds=X(f),k(this,v)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(Bt(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){Ia(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(l){return this.options.opacity=l,this._image&&this._updateOpacity(),this},setStyle:function(l){return l.opacity&&this.setOpacity(l.opacity),this},bringToFront:function(){return this._map&&fr(this._image),this},bringToBack:function(){return this._map&&G(this._image),this},setUrl:function(l){return this._url=l,this._image&&(this._image.src=l),this},setBounds:function(l){return this._bounds=X(l),this._map&&this._reset(),this},getEvents:function(){var l={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(l.zoomanim=this._animateZoom),l},setZIndex:function(l){return this.options.zIndex=l,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var l=this._url.tagName==="IMG",f=this._image=l?this._url:ha("img");if(Bt(f,"leaflet-image-layer"),this._zoomAnimated&&Bt(f,"leaflet-zoom-animated"),this.options.className&&Bt(f,this.options.className),f.onselectstart=b,f.onmousemove=b,f.onload=d(this.fire,this,"load"),f.onerror=d(this._overlayOnError,this,"error"),(this.options.crossOrigin||this.options.crossOrigin==="")&&(f.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),l){this._url=f.src;return}f.src=this._url,f.alt=this.options.alt},_animateZoom:function(l){var f=this._map.getZoomScale(l.zoom),v=this._map._latLngBoundsToNewLayerBounds(this._bounds,l.zoom,l.center).min;wa(this._image,v,f)},_reset:function(){var l=this._image,f=new F(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),v=f.getSize();Za(l,f.min),l.style.width=v.x+"px",l.style.height=v.y+"px"},_updateOpacity:function(){Aa(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var l=this.options.errorOverlayUrl;l&&this._url!==l&&(this._url=l,this._image.src=l)},getCenter:function(){return this._bounds.getCenter()}}),je=function(l,f,v){return new pe(l,f,v)},Ct=pe.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var l=this._url.tagName==="VIDEO",f=this._image=l?this._url:ha("video");if(Bt(f,"leaflet-image-layer"),this._zoomAnimated&&Bt(f,"leaflet-zoom-animated"),this.options.className&&Bt(f,this.options.className),f.onselectstart=b,f.onmousemove=b,f.onloadeddata=d(this.fire,this,"load"),l){for(var v=f.getElementsByTagName("source"),A=[],H=0;H<v.length;H++)A.push(v[H].src);this._url=v.length>0?A:[f.src];return}E(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(f.style,"objectFit")&&(f.style.objectFit="fill"),f.autoplay=!!this.options.autoplay,f.loop=!!this.options.loop,f.muted=!!this.options.muted,f.playsInline=!!this.options.playsInline;for(var le=0;le<this._url.length;le++){var Ce=ha("source");Ce.src=this._url[le],f.appendChild(Ce)}}});function Jt(l,f,v){return new Ct(l,f,v)}var Pt=pe.extend({_initImage:function(){var l=this._image=this._url;Bt(l,"leaflet-image-layer"),this._zoomAnimated&&Bt(l,"leaflet-zoom-animated"),this.options.className&&Bt(l,this.options.className),l.onselectstart=b,l.onmousemove=b}});function ma(l,f,v){return new Pt(l,f,v)}var xa=mn.extend({options:{interactive:!1,offset:[0,0],className:"",pane:void 0,content:""},initialize:function(l,f){l&&(l instanceof K||E(l))?(this._latlng=we(l),k(this,f)):(k(this,l),this._source=f),this.options.content&&(this._content=this.options.content)},openOn:function(l){return l=arguments.length?l:this._source._map,l.hasLayer(this)||l.addLayer(this),this},close:function(){return this._map&&this._map.removeLayer(this),this},toggle:function(l){return this._map?this.close():(arguments.length?this._source=l:l=this._source,this._prepareOpen(),this.openOn(l._map)),this},onAdd:function(l){this._zoomAnimated=l._zoomAnimated,this._container||this._initLayout(),l._fadeAnimated&&Aa(this._container,0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),l._fadeAnimated&&Aa(this._container,1),this.bringToFront(),this.options.interactive&&(Bt(this._container,"leaflet-interactive"),this.addInteractiveTarget(this._container))},onRemove:function(l){l._fadeAnimated?(Aa(this._container,0),this._removeTimeout=setTimeout(d(Ia,void 0,this._container),200)):Ia(this._container),this.options.interactive&&(Kt(this._container,"leaflet-interactive"),this.removeInteractiveTarget(this._container))},getLatLng:function(){return this._latlng},setLatLng:function(l){return this._latlng=we(l),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(l){return this._content=l,this.update(),this},getElement:function(){return this._container},update:function(){this._map&&(this._container.style.visibility="hidden",this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility="",this._adjustPan())},getEvents:function(){var l={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(l.zoomanim=this._animateZoom),l},isOpen:function(){return!!this._map&&this._map.hasLayer(this)},bringToFront:function(){return this._map&&fr(this._container),this},bringToBack:function(){return this._map&&G(this._container),this},_prepareOpen:function(l){var f=this._source;if(!f._map)return!1;if(f instanceof jn){f=null;var v=this._source._layers;for(var A in v)if(v[A]._map){f=v[A];break}if(!f)return!1;this._source=f}if(!l)if(f.getCenter)l=f.getCenter();else if(f.getLatLng)l=f.getLatLng();else if(f.getBounds)l=f.getBounds().getCenter();else throw new Error("Unable to get source layer LatLng.");return this.setLatLng(l),this._map&&this.update(),!0},_updateContent:function(){if(this._content){var l=this._contentNode,f=typeof this._content=="function"?this._content(this._source||this):this._content;if(typeof f=="string")l.innerHTML=f;else{for(;l.hasChildNodes();)l.removeChild(l.firstChild);l.appendChild(f)}this.fire("contentupdate")}},_updatePosition:function(){if(this._map){var l=this._map.latLngToLayerPoint(this._latlng),f=ae(this.options.offset),v=this._getAnchor();this._zoomAnimated?Za(this._container,l.add(v)):f=f.add(l).add(v);var A=this._containerBottom=-f.y,H=this._containerLeft=-Math.round(this._containerWidth/2)+f.x;this._container.style.bottom=A+"px",this._container.style.left=H+"px"}},_getAnchor:function(){return[0,0]}});Ra.include({_initOverlay:function(l,f,v,A){var H=f;return H instanceof l||(H=new l(A).setContent(f)),v&&H.setLatLng(v),H}}),mn.include({_initOverlay:function(l,f,v,A){var H=v;return H instanceof l?(k(H,A),H._source=this):(H=f&&!A?f:new l(A,this),H.setContent(v)),H}});var Tr=xa.extend({options:{pane:"popupPane",offset:[0,7],maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,closeOnEscapeKey:!0,className:""},openOn:function(l){return l=arguments.length?l:this._source._map,!l.hasLayer(this)&&l._popup&&l._popup.options.autoClose&&l.removeLayer(l._popup),l._popup=this,xa.prototype.openOn.call(this,l)},onAdd:function(l){xa.prototype.onAdd.call(this,l),l.fire("popupopen",{popup:this}),this._source&&(this._source.fire("popupopen",{popup:this},!0),this._source instanceof hn||this._source.on("preclick",gs))},onRemove:function(l){xa.prototype.onRemove.call(this,l),l.fire("popupclose",{popup:this}),this._source&&(this._source.fire("popupclose",{popup:this},!0),this._source instanceof hn||this._source.off("preclick",gs))},getEvents:function(){var l=xa.prototype.getEvents.call(this);return(this.options.closeOnClick!==void 0?this.options.closeOnClick:this._map.options.closePopupOnClick)&&(l.preclick=this.close),this.options.keepInView&&(l.moveend=this._adjustPan),l},_initLayout:function(){var l="leaflet-popup",f=this._container=ha("div",l+" "+(this.options.className||"")+" leaflet-zoom-animated"),v=this._wrapper=ha("div",l+"-content-wrapper",f);if(this._contentNode=ha("div",l+"-content",v),zn(f),Ls(this._contentNode),oa(f,"contextmenu",gs),this._tipContainer=ha("div",l+"-tip-container",f),this._tip=ha("div",l+"-tip",this._tipContainer),this.options.closeButton){var A=this._closeButton=ha("a",l+"-close-button",f);A.setAttribute("role","button"),A.setAttribute("aria-label","Close popup"),A.href="#close",A.innerHTML='<span aria-hidden="true">&#215;</span>',oa(A,"click",function(H){Cr(H),this.close()},this)}},_updateLayout:function(){var l=this._contentNode,f=l.style;f.width="",f.whiteSpace="nowrap";var v=l.offsetWidth;v=Math.min(v,this.options.maxWidth),v=Math.max(v,this.options.minWidth),f.width=v+1+"px",f.whiteSpace="",f.height="";var A=l.offsetHeight,H=this.options.maxHeight,le="leaflet-popup-scrolled";H&&A>H?(f.height=H+"px",Bt(l,le)):Kt(l,le),this._containerWidth=this._container.offsetWidth},_animateZoom:function(l){var f=this._map._latLngToNewLayerPoint(this._latlng,l.zoom,l.center),v=this._getAnchor();Za(this._container,f.add(v))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning){this._autopanning=!1;return}var l=this._map,f=parseInt(hs(this._container,"marginBottom"),10)||0,v=this._container.offsetHeight+f,A=this._containerWidth,H=new I(this._containerLeft,-v-this._containerBottom);H._add(cn(this._container));var le=l.layerPointToContainerPoint(H),Ce=ae(this.options.autoPanPadding),qe=ae(this.options.autoPanPaddingTopLeft||Ce),tt=ae(this.options.autoPanPaddingBottomRight||Ce),Tt=l.getSize(),Xt=0,ua=0;le.x+A+tt.x>Tt.x&&(Xt=le.x+A-Tt.x+tt.x),le.x-Xt-qe.x<0&&(Xt=le.x-qe.x),le.y+v+tt.y>Tt.y&&(ua=le.y+v-Tt.y+tt.y),le.y-ua-qe.y<0&&(ua=le.y-qe.y),(Xt||ua)&&(this.options.keepInView&&(this._autopanning=!0),l.fire("autopanstart").panBy([Xt,ua]))}},_getAnchor:function(){return ae(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),Ba=function(l,f){return new Tr(l,f)};Ra.mergeOptions({closePopupOnClick:!0}),Ra.include({openPopup:function(l,f,v){return this._initOverlay(Tr,l,f,v).openOn(this),this},closePopup:function(l){return l=arguments.length?l:this._popup,l&&l.close(),this}}),mn.include({bindPopup:function(l,f){return this._popup=this._initOverlay(Tr,this._popup,l,f),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(l){return this._popup&&(this instanceof jn||(this._popup._source=this),this._popup._prepareOpen(l||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1},setPopupContent:function(l){return this._popup&&this._popup.setContent(l),this},getPopup:function(){return this._popup},_openPopup:function(l){if(!(!this._popup||!this._map)){Bn(l);var f=l.layer||l.target;if(this._popup._source===f&&!(f instanceof hn)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(l.latlng);return}this._popup._source=f,this.openPopup(l.latlng)}},_movePopup:function(l){this._popup.setLatLng(l.latlng)},_onKeyPress:function(l){l.originalEvent.keyCode===13&&this._openPopup(l)}});var Br=xa.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(l){xa.prototype.onAdd.call(this,l),this.setOpacity(this.options.opacity),l.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(l){xa.prototype.onRemove.call(this,l),l.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var l=xa.prototype.getEvents.call(this);return this.options.permanent||(l.preclick=this.close),l},_initLayout:function(){var l="leaflet-tooltip",f=l+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=ha("div",f),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+h(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(l){var f,v,A=this._map,H=this._container,le=A.latLngToContainerPoint(A.getCenter()),Ce=A.layerPointToContainerPoint(l),qe=this.options.direction,tt=H.offsetWidth,Tt=H.offsetHeight,Xt=ae(this.options.offset),ua=this._getAnchor();qe==="top"?(f=tt/2,v=Tt):qe==="bottom"?(f=tt/2,v=0):qe==="center"?(f=tt/2,v=Tt/2):qe==="right"?(f=0,v=Tt/2):qe==="left"?(f=tt,v=Tt/2):Ce.x<le.x?(qe="right",f=0,v=Tt/2):(qe="left",f=tt+(Xt.x+ua.x)*2,v=Tt/2),l=l.subtract(ae(f,v,!0)).add(Xt).add(ua),Kt(H,"leaflet-tooltip-right"),Kt(H,"leaflet-tooltip-left"),Kt(H,"leaflet-tooltip-top"),Kt(H,"leaflet-tooltip-bottom"),Bt(H,"leaflet-tooltip-"+qe),Za(H,l)},_updatePosition:function(){var l=this._map.latLngToLayerPoint(this._latlng);this._setPosition(l)},setOpacity:function(l){this.options.opacity=l,this._container&&Aa(this._container,l)},_animateZoom:function(l){var f=this._map._latLngToNewLayerPoint(this._latlng,l.zoom,l.center);this._setPosition(f)},_getAnchor:function(){return ae(this._source&&this._source._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}}),an=function(l,f){return new Br(l,f)};Ra.include({openTooltip:function(l,f,v){return this._initOverlay(Br,l,f,v).openOn(this),this},closeTooltip:function(l){return l.close(),this}}),mn.include({bindTooltip:function(l,f){return this._tooltip&&this.isTooltipOpen()&&this.unbindTooltip(),this._tooltip=this._initOverlay(Br,this._tooltip,l,f),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this)&&this.openTooltip(),this},unbindTooltip:function(){return this._tooltip&&(this._initTooltipInteractions(!0),this.closeTooltip(),this._tooltip=null),this},_initTooltipInteractions:function(l){if(!(!l&&this._tooltipHandlersAdded)){var f=l?"off":"on",v={remove:this.closeTooltip,move:this._moveTooltip};this._tooltip.options.permanent?v.add=this._openTooltip:(v.mouseover=this._openTooltip,v.mouseout=this.closeTooltip,v.click=this._openTooltip,this._map?this._addFocusListeners():v.add=this._addFocusListeners),this._tooltip.options.sticky&&(v.mousemove=this._moveTooltip),this[f](v),this._tooltipHandlersAdded=!l}},openTooltip:function(l){return this._tooltip&&(this instanceof jn||(this._tooltip._source=this),this._tooltip._prepareOpen(l)&&(this._tooltip.openOn(this._map),this.getElement?this._setAriaDescribedByOnLayer(this):this.eachLayer&&this.eachLayer(this._setAriaDescribedByOnLayer,this))),this},closeTooltip:function(){if(this._tooltip)return this._tooltip.close()},toggleTooltip:function(){return this._tooltip&&this._tooltip.toggle(this),this},isTooltipOpen:function(){return this._tooltip.isOpen()},setTooltipContent:function(l){return this._tooltip&&this._tooltip.setContent(l),this},getTooltip:function(){return this._tooltip},_addFocusListeners:function(){this.getElement?this._addFocusListenersOnLayer(this):this.eachLayer&&this.eachLayer(this._addFocusListenersOnLayer,this)},_addFocusListenersOnLayer:function(l){var f=typeof l.getElement=="function"&&l.getElement();f&&(oa(f,"focus",function(){this._tooltip._source=l,this.openTooltip()},this),oa(f,"blur",this.closeTooltip,this))},_setAriaDescribedByOnLayer:function(l){var f=typeof l.getElement=="function"&&l.getElement();f&&f.setAttribute("aria-describedby",this._tooltip._container.id)},_openTooltip:function(l){if(!(!this._tooltip||!this._map)){if(this._map.dragging&&this._map.dragging.moving()&&!this._openOnceFlag){this._openOnceFlag=!0;var f=this;this._map.once("moveend",function(){f._openOnceFlag=!1,f._openTooltip(l)});return}this._tooltip._source=l.layer||l.target,this.openTooltip(this._tooltip.options.sticky?l.latlng:void 0)}},_moveTooltip:function(l){var f=l.latlng,v,A;this._tooltip.options.sticky&&l.originalEvent&&(v=this._map.mouseEventToContainerPoint(l.originalEvent),A=this._map.containerPointToLayerPoint(v),f=this._map.layerPointToLatLng(A)),this._tooltip.setLatLng(f)}});var as=Ps.extend({options:{iconSize:[12,12],html:!1,bgPos:null,className:"leaflet-div-icon"},createIcon:function(l){var f=l&&l.tagName==="DIV"?l:document.createElement("div"),v=this.options;if(v.html instanceof Element?(qr(f),f.appendChild(v.html)):f.innerHTML=v.html!==!1?v.html:"",v.bgPos){var A=ae(v.bgPos);f.style.backgroundPosition=-A.x+"px "+-A.y+"px"}return this._setIconStyles(f,"icon"),f},createShadow:function(){return null}});function Is(l){return new as(l)}Ps.Default=No;var Pa=mn.extend({options:{tileSize:256,opacity:1,updateWhenIdle:rt.mobile,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:"tilePane",className:"",keepBuffer:2},initialize:function(l){k(this,l)},onAdd:function(){this._initContainer(),this._levels={},this._tiles={},this._resetView()},beforeAdd:function(l){l._addZoomLimit(this)},onRemove:function(l){this._removeAllTiles(),Ia(this._container),l._removeZoomLimit(this),this._container=null,this._tileZoom=void 0},bringToFront:function(){return this._map&&(fr(this._container),this._setAutoZIndex(Math.max)),this},bringToBack:function(){return this._map&&(G(this._container),this._setAutoZIndex(Math.min)),this},getContainer:function(){return this._container},setOpacity:function(l){return this.options.opacity=l,this._updateOpacity(),this},setZIndex:function(l){return this.options.zIndex=l,this._updateZIndex(),this},isLoading:function(){return this._loading},redraw:function(){if(this._map){this._removeAllTiles();var l=this._clampZoom(this._map.getZoom());l!==this._tileZoom&&(this._tileZoom=l,this._updateLevels()),this._update()}return this},getEvents:function(){var l={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||(this._onMove=g(this._onMoveEnd,this.options.updateInterval,this)),l.move=this._onMove),this._zoomAnimated&&(l.zoomanim=this._animateZoom),l},createTile:function(){return document.createElement("div")},getTileSize:function(){var l=this.options.tileSize;return l instanceof I?l:new I(l,l)},_updateZIndex:function(){this._container&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(l){for(var f=this.getPane().children,v=-l(-1/0,1/0),A=0,H=f.length,le;A<H;A++)le=f[A].style.zIndex,f[A]!==this._container&&le&&(v=l(v,+le));isFinite(v)&&(this.options.zIndex=v+l(-1,1),this._updateZIndex())},_updateOpacity:function(){if(this._map&&!rt.ielt9){Aa(this._container,this.options.opacity);var l=+new Date,f=!1,v=!1;for(var A in this._tiles){var H=this._tiles[A];if(!(!H.current||!H.loaded)){var le=Math.min(1,(l-H.loaded)/200);Aa(H.el,le),le<1?f=!0:(H.active?v=!0:this._onOpaqueTile(H),H.active=!0)}}v&&!this._noPrune&&this._pruneTiles(),f&&(he(this._fadeFrame),this._fadeFrame=ye(this._updateOpacity,this))}},_onOpaqueTile:b,_initContainer:function(){this._container||(this._container=ha("div","leaflet-layer "+(this.options.className||"")),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))},_updateLevels:function(){var l=this._tileZoom,f=this.options.maxZoom;if(l!==void 0){for(var v in this._levels)v=Number(v),this._levels[v].el.children.length||v===l?(this._levels[v].el.style.zIndex=f-Math.abs(l-v),this._onUpdateLevel(v)):(Ia(this._levels[v].el),this._removeTilesAtZoom(v),this._onRemoveLevel(v),delete this._levels[v]);var A=this._levels[l],H=this._map;return A||(A=this._levels[l]={},A.el=ha("div","leaflet-tile-container leaflet-zoom-animated",this._container),A.el.style.zIndex=f,A.origin=H.project(H.unproject(H.getPixelOrigin()),l).round(),A.zoom=l,this._setZoomTransform(A,H.getCenter(),H.getZoom()),b(A.el.offsetWidth),this._onCreateLevel(A)),this._level=A,A}},_onUpdateLevel:b,_onRemoveLevel:b,_onCreateLevel:b,_pruneTiles:function(){if(this._map){var l,f,v=this._map.getZoom();if(v>this.options.maxZoom||v<this.options.minZoom){this._removeAllTiles();return}for(l in this._tiles)f=this._tiles[l],f.retain=f.current;for(l in this._tiles)if(f=this._tiles[l],f.current&&!f.active){var A=f.coords;this._retainParent(A.x,A.y,A.z,A.z-5)||this._retainChildren(A.x,A.y,A.z,A.z+2)}for(l in this._tiles)this._tiles[l].retain||this._removeTile(l)}},_removeTilesAtZoom:function(l){for(var f in this._tiles)this._tiles[f].coords.z===l&&this._removeTile(f)},_removeAllTiles:function(){for(var l in this._tiles)this._removeTile(l)},_invalidateAll:function(){for(var l in this._levels)Ia(this._levels[l].el),this._onRemoveLevel(Number(l)),delete this._levels[l];this._removeAllTiles(),this._tileZoom=void 0},_retainParent:function(l,f,v,A){var H=Math.floor(l/2),le=Math.floor(f/2),Ce=v-1,qe=new I(+H,+le);qe.z=+Ce;var tt=this._tileCoordsToKey(qe),Tt=this._tiles[tt];return Tt&&Tt.active?(Tt.retain=!0,!0):(Tt&&Tt.loaded&&(Tt.retain=!0),Ce>A?this._retainParent(H,le,Ce,A):!1)},_retainChildren:function(l,f,v,A){for(var H=2*l;H<2*l+2;H++)for(var le=2*f;le<2*f+2;le++){var Ce=new I(H,le);Ce.z=v+1;var qe=this._tileCoordsToKey(Ce),tt=this._tiles[qe];if(tt&&tt.active){tt.retain=!0;continue}else tt&&tt.loaded&&(tt.retain=!0);v+1<A&&this._retainChildren(H,le,v+1,A)}},_resetView:function(l){var f=l&&(l.pinch||l.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),f,f)},_animateZoom:function(l){this._setView(l.center,l.zoom,!0,l.noUpdate)},_clampZoom:function(l){var f=this.options;return f.minNativeZoom!==void 0&&l<f.minNativeZoom?f.minNativeZoom:f.maxNativeZoom!==void 0&&f.maxNativeZoom<l?f.maxNativeZoom:l},_setView:function(l,f,v,A){var H=Math.round(f);this.options.maxZoom!==void 0&&H>this.options.maxZoom||this.options.minZoom!==void 0&&H<this.options.minZoom?H=void 0:H=this._clampZoom(H);var le=this.options.updateWhenZooming&&H!==this._tileZoom;(!A||le)&&(this._tileZoom=H,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),H!==void 0&&this._update(l),v||this._pruneTiles(),this._noPrune=!!v),this._setZoomTransforms(l,f)},_setZoomTransforms:function(l,f){for(var v in this._levels)this._setZoomTransform(this._levels[v],l,f)},_setZoomTransform:function(l,f,v){var A=this._map.getZoomScale(v,l.zoom),H=l.origin.multiplyBy(A).subtract(this._map._getNewPixelOrigin(f,v)).round();rt.any3d?wa(l.el,H,A):Za(l.el,H)},_resetGrid:function(){var l=this._map,f=l.options.crs,v=this._tileSize=this.getTileSize(),A=this._tileZoom,H=this._map.getPixelWorldBounds(this._tileZoom);H&&(this._globalTileRange=this._pxBoundsToTileRange(H)),this._wrapX=f.wrapLng&&!this.options.noWrap&&[Math.floor(l.project([0,f.wrapLng[0]],A).x/v.x),Math.ceil(l.project([0,f.wrapLng[1]],A).x/v.y)],this._wrapY=f.wrapLat&&!this.options.noWrap&&[Math.floor(l.project([f.wrapLat[0],0],A).y/v.x),Math.ceil(l.project([f.wrapLat[1],0],A).y/v.y)]},_onMoveEnd:function(){!this._map||this._map._animatingZoom||this._update()},_getTiledPixelBounds:function(l){var f=this._map,v=f._animatingZoom?Math.max(f._animateToZoom,f.getZoom()):f.getZoom(),A=f.getZoomScale(v,this._tileZoom),H=f.project(l,this._tileZoom).floor(),le=f.getSize().divideBy(A*2);return new F(H.subtract(le),H.add(le))},_update:function(l){var f=this._map;if(f){var v=this._clampZoom(f.getZoom());if(l===void 0&&(l=f.getCenter()),this._tileZoom!==void 0){var A=this._getTiledPixelBounds(l),H=this._pxBoundsToTileRange(A),le=H.getCenter(),Ce=[],qe=this.options.keepBuffer,tt=new F(H.getBottomLeft().subtract([qe,-qe]),H.getTopRight().add([qe,-qe]));if(!(isFinite(H.min.x)&&isFinite(H.min.y)&&isFinite(H.max.x)&&isFinite(H.max.y)))throw new Error("Attempted to load an infinite number of tiles");for(var Tt in this._tiles){var Xt=this._tiles[Tt].coords;(Xt.z!==this._tileZoom||!tt.contains(new I(Xt.x,Xt.y)))&&(this._tiles[Tt].current=!1)}if(Math.abs(v-this._tileZoom)>1){this._setView(l,v);return}for(var ua=H.min.y;ua<=H.max.y;ua++)for(var Oa=H.min.x;Oa<=H.max.x;Oa++){var ps=new I(Oa,ua);if(ps.z=this._tileZoom,!!this._isValidTile(ps)){var Ur=this._tiles[this._tileCoordsToKey(ps)];Ur?Ur.current=!0:Ce.push(ps)}}if(Ce.sort(function(Xa,Ka){return Xa.distanceTo(le)-Ka.distanceTo(le)}),Ce.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var gn=document.createDocumentFragment();for(Oa=0;Oa<Ce.length;Oa++)this._addTile(Ce[Oa],gn);this._level.el.appendChild(gn)}}}},_isValidTile:function(l){var f=this._map.options.crs;if(!f.infinite){var v=this._globalTileRange;if(!f.wrapLng&&(l.x<v.min.x||l.x>v.max.x)||!f.wrapLat&&(l.y<v.min.y||l.y>v.max.y))return!1}if(!this.options.bounds)return!0;var A=this._tileCoordsToBounds(l);return X(this.options.bounds).overlaps(A)},_keyToBounds:function(l){return this._tileCoordsToBounds(this._keyToTileCoords(l))},_tileCoordsToNwSe:function(l){var f=this._map,v=this.getTileSize(),A=l.scaleBy(v),H=A.add(v),le=f.unproject(A,l.z),Ce=f.unproject(H,l.z);return[le,Ce]},_tileCoordsToBounds:function(l){var f=this._tileCoordsToNwSe(l),v=new B(f[0],f[1]);return this.options.noWrap||(v=this._map.wrapLatLngBounds(v)),v},_tileCoordsToKey:function(l){return l.x+":"+l.y+":"+l.z},_keyToTileCoords:function(l){var f=l.split(":"),v=new I(+f[0],+f[1]);return v.z=+f[2],v},_removeTile:function(l){var f=this._tiles[l];f&&(Ia(f.el),delete this._tiles[l],this.fire("tileunload",{tile:f.el,coords:this._keyToTileCoords(l)}))},_initTile:function(l){Bt(l,"leaflet-tile");var f=this.getTileSize();l.style.width=f.x+"px",l.style.height=f.y+"px",l.onselectstart=b,l.onmousemove=b,rt.ielt9&&this.options.opacity<1&&Aa(l,this.options.opacity)},_addTile:function(l,f){var v=this._getTilePos(l),A=this._tileCoordsToKey(l),H=this.createTile(this._wrapCoords(l),d(this._tileReady,this,l));this._initTile(H),this.createTile.length<2&&ye(d(this._tileReady,this,l,null,H)),Za(H,v),this._tiles[A]={el:H,coords:l,current:!0},f.appendChild(H),this.fire("tileloadstart",{tile:H,coords:l})},_tileReady:function(l,f,v){f&&this.fire("tileerror",{error:f,tile:v,coords:l});var A=this._tileCoordsToKey(l);v=this._tiles[A],v&&(v.loaded=+new Date,this._map._fadeAnimated?(Aa(v.el,0),he(this._fadeFrame),this._fadeFrame=ye(this._updateOpacity,this)):(v.active=!0,this._pruneTiles()),f||(Bt(v.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:v.el,coords:l})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),rt.ielt9||!this._map._fadeAnimated?ye(this._pruneTiles,this):setTimeout(d(this._pruneTiles,this),250)))},_getTilePos:function(l){return l.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(l){var f=new I(this._wrapX?p(l.x,this._wrapX):l.x,this._wrapY?p(l.y,this._wrapY):l.y);return f.z=l.z,f},_pxBoundsToTileRange:function(l){var f=this.getTileSize();return new F(l.min.unscaleBy(f).floor(),l.max.unscaleBy(f).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var l in this._tiles)if(!this._tiles[l].loaded)return!1;return!0}});function qn(l){return new Pa(l)}var Rr=Pa.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(l,f){this._url=l,f=k(this,f),f.detectRetina&&rt.retina&&f.maxZoom>0?(f.tileSize=Math.floor(f.tileSize/2),f.zoomReverse?(f.zoomOffset--,f.minZoom=Math.min(f.maxZoom,f.minZoom+1)):(f.zoomOffset++,f.maxZoom=Math.max(f.minZoom,f.maxZoom-1)),f.minZoom=Math.max(0,f.minZoom)):f.zoomReverse?f.minZoom=Math.min(f.maxZoom,f.minZoom):f.maxZoom=Math.max(f.minZoom,f.maxZoom),typeof f.subdomains=="string"&&(f.subdomains=f.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(l,f){return this._url===l&&f===void 0&&(f=!0),this._url=l,f||this.redraw(),this},createTile:function(l,f){var v=document.createElement("img");return oa(v,"load",d(this._tileOnLoad,this,f,v)),oa(v,"error",d(this._tileOnError,this,f,v)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(v.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),typeof this.options.referrerPolicy=="string"&&(v.referrerPolicy=this.options.referrerPolicy),v.alt="",v.src=this.getTileUrl(l),v},getTileUrl:function(l){var f={r:rt.retina?"@2x":"",s:this._getSubdomain(l),x:l.x,y:l.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var v=this._globalTileRange.max.y-l.y;this.options.tms&&(f.y=v),f["-y"]=v}return T(this._url,i(f,this.options))},_tileOnLoad:function(l,f){rt.ielt9?setTimeout(d(l,this,null,f),0):l(null,f)},_tileOnError:function(l,f,v){var A=this.options.errorTileUrl;A&&f.getAttribute("src")!==A&&(f.src=A),l(v,f)},_onTileRemove:function(l){l.tile.onload=null},_getZoomForUrl:function(){var l=this._tileZoom,f=this.options.maxZoom,v=this.options.zoomReverse,A=this.options.zoomOffset;return v&&(l=f-l),l+A},_getSubdomain:function(l){var f=Math.abs(l.x+l.y)%this.options.subdomains.length;return this.options.subdomains[f]},_abortLoading:function(){var l,f;for(l in this._tiles)if(this._tiles[l].coords.z!==this._tileZoom&&(f=this._tiles[l].el,f.onload=b,f.onerror=b,!f.complete)){f.src=R;var v=this._tiles[l].coords;Ia(f),delete this._tiles[l],this.fire("tileabort",{tile:f,coords:v})}},_removeTile:function(l){var f=this._tiles[l];if(f)return f.el.setAttribute("src",R),Pa.prototype._removeTile.call(this,l)},_tileReady:function(l,f,v){if(!(!this._map||v&&v.getAttribute("src")===R))return Pa.prototype._tileReady.call(this,l,f,v)}});function zs(l,f){return new Rr(l,f)}var Bs=Rr.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(l,f){this._url=l;var v=i({},this.defaultWmsParams);for(var A in f)A in this.options||(v[A]=f[A]);f=k(this,f);var H=f.detectRetina&&rt.retina?2:1,le=this.getTileSize();v.width=le.x*H,v.height=le.y*H,this.wmsParams=v},onAdd:function(l){this._crs=this.options.crs||l.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var f=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[f]=this._crs.code,Rr.prototype.onAdd.call(this,l)},getTileUrl:function(l){var f=this._tileCoordsToNwSe(l),v=this._crs,A=M(v.project(f[0]),v.project(f[1])),H=A.min,le=A.max,Ce=(this._wmsVersion>=1.3&&this._crs===Wl?[H.y,H.x,le.y,le.x]:[H.x,H.y,le.x,le.y]).join(","),qe=Rr.prototype.getTileUrl.call(this,l);return qe+C(this.wmsParams,qe,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+Ce},setParams:function(l,f){return i(this.wmsParams,l),f||this.redraw(),this}});function Nr(l,f){return new Bs(l,f)}Rr.WMS=Bs,zs.wms=Nr;var xs=mn.extend({options:{padding:.1},initialize:function(l){k(this,l),h(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),Bt(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var l={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(l.zoomanim=this._onAnimZoom),l},_onAnimZoom:function(l){this._updateTransform(l.center,l.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(l,f){var v=this._map.getZoomScale(f,this._zoom),A=this._map.getSize().multiplyBy(.5+this.options.padding),H=this._map.project(this._center,f),le=A.multiplyBy(-v).add(H).subtract(this._map._getNewPixelOrigin(l,f));rt.any3d?wa(this._container,le,v):Za(this._container,le)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var l in this._layers)this._layers[l]._reset()},_onZoomEnd:function(){for(var l in this._layers)this._layers[l]._project()},_updatePaths:function(){for(var l in this._layers)this._layers[l]._update()},_update:function(){var l=this.options.padding,f=this._map.getSize(),v=this._map.containerPointToLayerPoint(f.multiplyBy(-l)).round();this._bounds=new F(v,v.add(f.multiplyBy(1+l*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),Gc=xs.extend({options:{tolerance:0},getEvents:function(){var l=xs.prototype.getEvents.call(this);return l.viewprereset=this._onViewPreReset,l},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){xs.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var l=this._container=document.createElement("canvas");oa(l,"mousemove",this._onMouseMove,this),oa(l,"click dblclick mousedown mouseup contextmenu",this._onClick,this),oa(l,"mouseout",this._handleMouseOut,this),l._leaflet_disable_events=!0,this._ctx=l.getContext("2d")},_destroyContainer:function(){he(this._redrawRequest),delete this._ctx,Ia(this._container),za(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var l;this._redrawBounds=null;for(var f in this._layers)l=this._layers[f],l._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){xs.prototype._update.call(this);var l=this._bounds,f=this._container,v=l.getSize(),A=rt.retina?2:1;Za(f,l.min),f.width=A*v.x,f.height=A*v.y,f.style.width=v.x+"px",f.style.height=v.y+"px",rt.retina&&this._ctx.scale(2,2),this._ctx.translate(-l.min.x,-l.min.y),this.fire("update")}},_reset:function(){xs.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(l){this._updateDashArray(l),this._layers[h(l)]=l;var f=l._order={layer:l,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=f),this._drawLast=f,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(l){this._requestRedraw(l)},_removePath:function(l){var f=l._order,v=f.next,A=f.prev;v?v.prev=A:this._drawLast=A,A?A.next=v:this._drawFirst=v,delete l._order,delete this._layers[h(l)],this._requestRedraw(l)},_updatePath:function(l){this._extendRedrawBounds(l),l._project(),l._update(),this._requestRedraw(l)},_updateStyle:function(l){this._updateDashArray(l),this._requestRedraw(l)},_updateDashArray:function(l){if(typeof l.options.dashArray=="string"){var f=l.options.dashArray.split(/[, ]+/),v=[],A,H;for(H=0;H<f.length;H++){if(A=Number(f[H]),isNaN(A))return;v.push(A)}l.options._dashArray=v}else l.options._dashArray=l.options.dashArray},_requestRedraw:function(l){this._map&&(this._extendRedrawBounds(l),this._redrawRequest=this._redrawRequest||ye(this._redraw,this))},_extendRedrawBounds:function(l){if(l._pxBounds){var f=(l.options.weight||0)+1;this._redrawBounds=this._redrawBounds||new F,this._redrawBounds.extend(l._pxBounds.min.subtract([f,f])),this._redrawBounds.extend(l._pxBounds.max.add([f,f]))}},_redraw:function(){this._redrawRequest=null,this._redrawBounds&&(this._redrawBounds.min._floor(),this._redrawBounds.max._ceil()),this._clear(),this._draw(),this._redrawBounds=null},_clear:function(){var l=this._redrawBounds;if(l){var f=l.getSize();this._ctx.clearRect(l.min.x,l.min.y,f.x,f.y)}else this._ctx.save(),this._ctx.setTransform(1,0,0,1,0,0),this._ctx.clearRect(0,0,this._container.width,this._container.height),this._ctx.restore()},_draw:function(){var l,f=this._redrawBounds;if(this._ctx.save(),f){var v=f.getSize();this._ctx.beginPath(),this._ctx.rect(f.min.x,f.min.y,v.x,v.y),this._ctx.clip()}this._drawing=!0;for(var A=this._drawFirst;A;A=A.next)l=A.layer,(!f||l._pxBounds&&l._pxBounds.intersects(f))&&l._updatePath();this._drawing=!1,this._ctx.restore()},_updatePoly:function(l,f){if(this._drawing){var v,A,H,le,Ce=l._parts,qe=Ce.length,tt=this._ctx;if(qe){for(tt.beginPath(),v=0;v<qe;v++){for(A=0,H=Ce[v].length;A<H;A++)le=Ce[v][A],tt[A?"lineTo":"moveTo"](le.x,le.y);f&&tt.closePath()}this._fillStroke(tt,l)}}},_updateCircle:function(l){if(!(!this._drawing||l._empty())){var f=l._point,v=this._ctx,A=Math.max(Math.round(l._radius),1),H=(Math.max(Math.round(l._radiusY),1)||A)/A;H!==1&&(v.save(),v.scale(1,H)),v.beginPath(),v.arc(f.x,f.y/H,A,0,Math.PI*2,!1),H!==1&&v.restore(),this._fillStroke(v,l)}},_fillStroke:function(l,f){var v=f.options;v.fill&&(l.globalAlpha=v.fillOpacity,l.fillStyle=v.fillColor||v.color,l.fill(v.fillRule||"evenodd")),v.stroke&&v.weight!==0&&(l.setLineDash&&l.setLineDash(f.options&&f.options._dashArray||[]),l.globalAlpha=v.opacity,l.lineWidth=v.weight,l.strokeStyle=v.color,l.lineCap=v.lineCap,l.lineJoin=v.lineJoin,l.stroke())},_onClick:function(l){for(var f=this._map.mouseEventToLayerPoint(l),v,A,H=this._drawFirst;H;H=H.next)v=H.layer,v.options.interactive&&v._containsPoint(f)&&(!(l.type==="click"||l.type==="preclick")||!this._map._draggableMoved(v))&&(A=v);this._fireEvent(A?[A]:!1,l)},_onMouseMove:function(l){if(!(!this._map||this._map.dragging.moving()||this._map._animatingZoom)){var f=this._map.mouseEventToLayerPoint(l);this._handleMouseHover(l,f)}},_handleMouseOut:function(l){var f=this._hoveredLayer;f&&(Kt(this._container,"leaflet-interactive"),this._fireEvent([f],l,"mouseout"),this._hoveredLayer=null,this._mouseHoverThrottled=!1)},_handleMouseHover:function(l,f){if(!this._mouseHoverThrottled){for(var v,A,H=this._drawFirst;H;H=H.next)v=H.layer,v.options.interactive&&v._containsPoint(f)&&(A=v);A!==this._hoveredLayer&&(this._handleMouseOut(l),A&&(Bt(this._container,"leaflet-interactive"),this._fireEvent([A],l,"mouseover"),this._hoveredLayer=A)),this._fireEvent(this._hoveredLayer?[this._hoveredLayer]:!1,l),this._mouseHoverThrottled=!0,setTimeout(d(function(){this._mouseHoverThrottled=!1},this),32)}},_fireEvent:function(l,f,v){this._map._fireDOMEvent(f,v||f.type,l)},_bringToFront:function(l){var f=l._order;if(f){var v=f.next,A=f.prev;if(v)v.prev=A;else return;A?A.next=v:v&&(this._drawFirst=v),f.prev=this._drawLast,this._drawLast.next=f,f.next=null,this._drawLast=f,this._requestRedraw(l)}},_bringToBack:function(l){var f=l._order;if(f){var v=f.next,A=f.prev;if(A)A.next=v;else return;v?v.prev=A:A&&(this._drawLast=A),f.prev=null,f.next=this._drawFirst,this._drawFirst.prev=f,this._drawFirst=f,this._requestRedraw(l)}}});function Vl(l){return rt.canvas?new Gc(l):null}var ao=(function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(l){return document.createElement("<lvml:"+l+' class="lvml">')}}catch(l){}return function(l){return document.createElement("<"+l+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}})(),n0={_initContainer:function(){this._container=ha("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(xs.prototype._update.call(this),this.fire("update"))},_initPath:function(l){var f=l._container=ao("shape");Bt(f,"leaflet-vml-shape "+(this.options.className||"")),f.coordsize="1 1",l._path=ao("path"),f.appendChild(l._path),this._updateStyle(l),this._layers[h(l)]=l},_addPath:function(l){var f=l._container;this._container.appendChild(f),l.options.interactive&&l.addInteractiveTarget(f)},_removePath:function(l){var f=l._container;Ia(f),l.removeInteractiveTarget(f),delete this._layers[h(l)]},_updateStyle:function(l){var f=l._stroke,v=l._fill,A=l.options,H=l._container;H.stroked=!!A.stroke,H.filled=!!A.fill,A.stroke?(f||(f=l._stroke=ao("stroke")),H.appendChild(f),f.weight=A.weight+"px",f.color=A.color,f.opacity=A.opacity,A.dashArray?f.dashStyle=E(A.dashArray)?A.dashArray.join(" "):A.dashArray.replace(/( *, *)/g," "):f.dashStyle="",f.endcap=A.lineCap.replace("butt","flat"),f.joinstyle=A.lineJoin):f&&(H.removeChild(f),l._stroke=null),A.fill?(v||(v=l._fill=ao("fill")),H.appendChild(v),v.color=A.fillColor||A.color,v.opacity=A.fillOpacity):v&&(H.removeChild(v),l._fill=null)},_updateCircle:function(l){var f=l._point.round(),v=Math.round(l._radius),A=Math.round(l._radiusY||v);this._setPath(l,l._empty()?"M0 0":"AL "+f.x+","+f.y+" "+v+","+A+" 0,"+65535*360)},_setPath:function(l,f){l._path.v=f},_bringToFront:function(l){fr(l._container)},_bringToBack:function(l){G(l._container)}},mi=rt.vml?ao:Ht,il=xs.extend({_initContainer:function(){this._container=mi("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=mi("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){Ia(this._container),za(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){xs.prototype._update.call(this);var l=this._bounds,f=l.getSize(),v=this._container;(!this._svgSize||!this._svgSize.equals(f))&&(this._svgSize=f,v.setAttribute("width",f.x),v.setAttribute("height",f.y)),Za(v,l.min),v.setAttribute("viewBox",[l.min.x,l.min.y,f.x,f.y].join(" ")),this.fire("update")}},_initPath:function(l){var f=l._path=mi("path");l.options.className&&Bt(f,l.options.className),l.options.interactive&&Bt(f,"leaflet-interactive"),this._updateStyle(l),this._layers[h(l)]=l},_addPath:function(l){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(l._path),l.addInteractiveTarget(l._path)},_removePath:function(l){Ia(l._path),l.removeInteractiveTarget(l._path),delete this._layers[h(l)]},_updatePath:function(l){l._project(),l._update()},_updateStyle:function(l){var f=l._path,v=l.options;f&&(v.stroke?(f.setAttribute("stroke",v.color),f.setAttribute("stroke-opacity",v.opacity),f.setAttribute("stroke-width",v.weight),f.setAttribute("stroke-linecap",v.lineCap),f.setAttribute("stroke-linejoin",v.lineJoin),v.dashArray?f.setAttribute("stroke-dasharray",v.dashArray):f.removeAttribute("stroke-dasharray"),v.dashOffset?f.setAttribute("stroke-dashoffset",v.dashOffset):f.removeAttribute("stroke-dashoffset")):f.setAttribute("stroke","none"),v.fill?(f.setAttribute("fill",v.fillColor||v.color),f.setAttribute("fill-opacity",v.fillOpacity),f.setAttribute("fill-rule",v.fillRule||"evenodd")):f.setAttribute("fill","none"))},_updatePoly:function(l,f){this._setPath(l,Mt(l._parts,f))},_updateCircle:function(l){var f=l._point,v=Math.max(Math.round(l._radius),1),A=Math.max(Math.round(l._radiusY),1)||v,H="a"+v+","+A+" 0 1,0 ",le=l._empty()?"M0 0":"M"+(f.x-v)+","+f.y+H+v*2+",0 "+H+-v*2+",0 ";this._setPath(l,le)},_setPath:function(l,f){l._path.setAttribute("d",f)},_bringToFront:function(l){fr(l._path)},_bringToBack:function(l){G(l._path)}});rt.vml&&il.include(n0);function ql(l){return rt.svg||rt.vml?new il(l):null}Ra.include({getRenderer:function(l){var f=l.options.renderer||this._getPaneRenderer(l.options.pane)||this.options.renderer||this._renderer;return f||(f=this._renderer=this._createRenderer()),this.hasLayer(f)||this.addLayer(f),f},_getPaneRenderer:function(l){if(l==="overlayPane"||l===void 0)return!1;var f=this._paneRenderers[l];return f===void 0&&(f=this._createRenderer({pane:l}),this._paneRenderers[l]=f),f},_createRenderer:function(l){return this.options.preferCanvas&&Vl(l)||ql(l)}});var Eo=Ki.extend({initialize:function(l,f){Ki.prototype.initialize.call(this,this._boundsToLatLngs(l),f)},setBounds:function(l){return this.setLatLngs(this._boundsToLatLngs(l))},_boundsToLatLngs:function(l){return l=X(l),[l.getSouthWest(),l.getNorthWest(),l.getNorthEast(),l.getSouthEast()]}});function ng(l,f){return new Eo(l,f)}il.create=mi,il.pointsToPath=Mt,Wn.geometryToLayer=ts,Wn.coordsToLatLng=nl,Wn.coordsToLatLngs=eo,Wn.latLngToCoords=to,Wn.latLngsToCoords=ji,Wn.getFeature=ui,Wn.asFeature=Co,Ra.mergeOptions({boxZoom:!0});var rn=fs.extend({initialize:function(l){this._map=l,this._container=l._container,this._pane=l._panes.overlayPane,this._resetStateTimeout=0,l.on("unload",this._destroy,this)},addHooks:function(){oa(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){za(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){Ia(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(l){if(!l.shiftKey||l.which!==1&&l.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),_s(),Ms(),this._startPoint=this._map.mouseEventToContainerPoint(l),oa(document,{contextmenu:Bn,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(l){this._moved||(this._moved=!0,this._box=ha("div","leaflet-zoom-box",this._container),Bt(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(l);var f=new F(this._point,this._startPoint),v=f.getSize();Za(this._box,f.min),this._box.style.width=v.x+"px",this._box.style.height=v.y+"px"},_finish:function(){this._moved&&(Ia(this._box),Kt(this._container,"leaflet-crosshair")),Gr(),oi(),za(document,{contextmenu:Bn,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(l){if(!(l.which!==1&&l.button!==1)&&(this._finish(),!!this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(d(this._resetState,this),0);var f=new B(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(f).fire("boxzoomend",{boxZoomBounds:f})}},_onKeyDown:function(l){l.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});Ra.addInitHook("addHandler","boxZoom",rn),Ra.mergeOptions({doubleClickZoom:!0});var Yc=fs.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(l){var f=this._map,v=f.getZoom(),A=f.options.zoomDelta,H=l.originalEvent.shiftKey?v-A:v+A;f.options.doubleClickZoom==="center"?f.setZoom(H):f.setZoomAround(l.containerPoint,H)}});Ra.addInitHook("addHandler","doubleClickZoom",Yc),Ra.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var hi=fs.extend({addHooks:function(){if(!this._draggable){var l=this._map;this._draggable=new $n(l._mapPane,l._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),l.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),l.on("zoomend",this._onZoomEnd,this),l.whenReady(this._onZoomEnd,this))}Bt(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){Kt(this._map._container,"leaflet-grab"),Kt(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var l=this._map;if(l._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var f=X(this._map.options.maxBounds);this._offsetLimit=M(this._map.latLngToContainerPoint(f.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(f.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;l.fire("movestart").fire("dragstart"),l.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(l){if(this._map.options.inertia){var f=this._lastTime=+new Date,v=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(v),this._times.push(f),this._prunePositions(f)}this._map.fire("move",l).fire("drag",l)},_prunePositions:function(l){for(;this._positions.length>1&&l-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var l=this._map.getSize().divideBy(2),f=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=f.subtract(l).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(l,f){return l-(l-f)*this._viscosity},_onPreDragLimit:function(){if(!(!this._viscosity||!this._offsetLimit)){var l=this._draggable._newPos.subtract(this._draggable._startPos),f=this._offsetLimit;l.x<f.min.x&&(l.x=this._viscousLimit(l.x,f.min.x)),l.y<f.min.y&&(l.y=this._viscousLimit(l.y,f.min.y)),l.x>f.max.x&&(l.x=this._viscousLimit(l.x,f.max.x)),l.y>f.max.y&&(l.y=this._viscousLimit(l.y,f.max.y)),this._draggable._newPos=this._draggable._startPos.add(l)}},_onPreDragWrap:function(){var l=this._worldWidth,f=Math.round(l/2),v=this._initialWorldOffset,A=this._draggable._newPos.x,H=(A-f+v)%l+f-v,le=(A+f+v)%l-f-v,Ce=Math.abs(H+v)<Math.abs(le+v)?H:le;this._draggable._absPos=this._draggable._newPos.clone(),this._draggable._newPos.x=Ce},_onDragEnd:function(l){var f=this._map,v=f.options,A=!v.inertia||l.noInertia||this._times.length<2;if(f.fire("dragend",l),A)f.fire("moveend");else{this._prunePositions(+new Date);var H=this._lastPos.subtract(this._positions[0]),le=(this._lastTime-this._times[0])/1e3,Ce=v.easeLinearity,qe=H.multiplyBy(Ce/le),tt=qe.distanceTo([0,0]),Tt=Math.min(v.inertiaMaxSpeed,tt),Xt=qe.multiplyBy(Tt/tt),ua=Tt/(v.inertiaDeceleration*Ce),Oa=Xt.multiplyBy(-ua/2).round();!Oa.x&&!Oa.y?f.fire("moveend"):(Oa=f._limitOffset(Oa,f.options.maxBounds),ye(function(){f.panBy(Oa,{duration:ua,easeLinearity:Ce,noMoveStart:!0,animate:!0})}))}}});Ra.addInitHook("addHandler","dragging",hi),Ra.mergeOptions({keyboard:!0,keyboardPanDelta:80});var i0=fs.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(l){this._map=l,this._setPanDelta(l.options.keyboardPanDelta),this._setZoomDelta(l.options.zoomDelta)},addHooks:function(){var l=this._map._container;l.tabIndex<=0&&(l.tabIndex="0"),oa(l,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),za(this._map._container,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)},_onMouseDown:function(){if(!this._focused){var l=document.body,f=document.documentElement,v=l.scrollTop||f.scrollTop,A=l.scrollLeft||f.scrollLeft;this._map._container.focus(),window.scrollTo(A,v)}},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanDelta:function(l){var f=this._panKeys={},v=this.keyCodes,A,H;for(A=0,H=v.left.length;A<H;A++)f[v.left[A]]=[-1*l,0];for(A=0,H=v.right.length;A<H;A++)f[v.right[A]]=[l,0];for(A=0,H=v.down.length;A<H;A++)f[v.down[A]]=[0,l];for(A=0,H=v.up.length;A<H;A++)f[v.up[A]]=[0,-1*l]},_setZoomDelta:function(l){var f=this._zoomKeys={},v=this.keyCodes,A,H;for(A=0,H=v.zoomIn.length;A<H;A++)f[v.zoomIn[A]]=l;for(A=0,H=v.zoomOut.length;A<H;A++)f[v.zoomOut[A]]=-l},_addHooks:function(){oa(document,"keydown",this._onKeyDown,this)},_removeHooks:function(){za(document,"keydown",this._onKeyDown,this)},_onKeyDown:function(l){if(!(l.altKey||l.ctrlKey||l.metaKey)){var f=l.keyCode,v=this._map,A;if(f in this._panKeys){if(!v._panAnim||!v._panAnim._inProgress)if(A=this._panKeys[f],l.shiftKey&&(A=ae(A).multiplyBy(3)),v.options.maxBounds&&(A=v._limitOffset(ae(A),v.options.maxBounds)),v.options.worldCopyJump){var H=v.wrapLatLng(v.unproject(v.project(v.getCenter()).add(A)));v.panTo(H)}else v.panBy(A)}else if(f in this._zoomKeys)v.setZoom(v.getZoom()+(l.shiftKey?3:1)*this._zoomKeys[f]);else if(f===27&&v._popup&&v._popup.options.closeOnEscapeKey)v.closePopup();else return;Bn(l)}}});Ra.addInitHook("addHandler","keyboard",i0),Ra.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60});var Gl=fs.extend({addHooks:function(){oa(this._map._container,"wheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){za(this._map._container,"wheel",this._onWheelScroll,this)},_onWheelScroll:function(l){var f=Qr(l),v=this._map.options.wheelDebounceTime;this._delta+=f,this._lastMousePos=this._map.mouseEventToContainerPoint(l),this._startTime||(this._startTime=+new Date);var A=Math.max(v-(+new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(d(this._performZoom,this),A),Bn(l)},_performZoom:function(){var l=this._map,f=l.getZoom(),v=this._map.options.zoomSnap||0;l._stop();var A=this._delta/(this._map.options.wheelPxPerZoomLevel*4),H=4*Math.log(2/(1+Math.exp(-Math.abs(A))))/Math.LN2,le=v?Math.ceil(H/v)*v:H,Ce=l._limitZoom(f+(this._delta>0?le:-le))-f;this._delta=0,this._startTime=null,Ce&&(l.options.scrollWheelZoom==="center"?l.setZoom(f+Ce):l.setZoomAround(this._lastMousePos,f+Ce))}});Ra.addInitHook("addHandler","scrollWheelZoom",Gl);var Ao=600;Ra.mergeOptions({tapHold:rt.touchNative&&rt.safari&&rt.mobile,tapTolerance:15});var Zc=fs.extend({addHooks:function(){oa(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){za(this._map._container,"touchstart",this._onDown,this)},_onDown:function(l){if(clearTimeout(this._holdTimeout),l.touches.length===1){var f=l.touches[0];this._startPos=this._newPos=new I(f.clientX,f.clientY),this._holdTimeout=setTimeout(d(function(){this._cancel(),this._isTapValid()&&(oa(document,"touchend",Cr),oa(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",f))},this),Ao),oa(document,"touchend touchcancel contextmenu",this._cancel,this),oa(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function l(){za(document,"touchend",Cr),za(document,"touchend touchcancel",l)},_cancel:function(){clearTimeout(this._holdTimeout),za(document,"touchend touchcancel contextmenu",this._cancel,this),za(document,"touchmove",this._onMove,this)},_onMove:function(l){var f=l.touches[0];this._newPos=new I(f.clientX,f.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(l,f){var v=new MouseEvent(l,{bubbles:!0,cancelable:!0,view:window,screenX:f.screenX,screenY:f.screenY,clientX:f.clientX,clientY:f.clientY});v._simulated=!0,f.target.dispatchEvent(v)}});Ra.addInitHook("addHandler","tapHold",Zc),Ra.mergeOptions({touchZoom:rt.touch,bounceAtZoomLimits:!0});var o0=fs.extend({addHooks:function(){Bt(this._map._container,"leaflet-touch-zoom"),oa(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){Kt(this._map._container,"leaflet-touch-zoom"),za(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(l){var f=this._map;if(!(!l.touches||l.touches.length!==2||f._animatingZoom||this._zooming)){var v=f.mouseEventToContainerPoint(l.touches[0]),A=f.mouseEventToContainerPoint(l.touches[1]);this._centerPoint=f.getSize()._divideBy(2),this._startLatLng=f.containerPointToLatLng(this._centerPoint),f.options.touchZoom!=="center"&&(this._pinchStartLatLng=f.containerPointToLatLng(v.add(A)._divideBy(2))),this._startDist=v.distanceTo(A),this._startZoom=f.getZoom(),this._moved=!1,this._zooming=!0,f._stop(),oa(document,"touchmove",this._onTouchMove,this),oa(document,"touchend touchcancel",this._onTouchEnd,this),Cr(l)}},_onTouchMove:function(l){if(!(!l.touches||l.touches.length!==2||!this._zooming)){var f=this._map,v=f.mouseEventToContainerPoint(l.touches[0]),A=f.mouseEventToContainerPoint(l.touches[1]),H=v.distanceTo(A)/this._startDist;if(this._zoom=f.getScaleZoom(H,this._startZoom),!f.options.bounceAtZoomLimits&&(this._zoom<f.getMinZoom()&&H<1||this._zoom>f.getMaxZoom()&&H>1)&&(this._zoom=f._limitZoom(this._zoom)),f.options.touchZoom==="center"){if(this._center=this._startLatLng,H===1)return}else{var le=v._add(A)._divideBy(2)._subtract(this._centerPoint);if(H===1&&le.x===0&&le.y===0)return;this._center=f.unproject(f.project(this._pinchStartLatLng,this._zoom).subtract(le),this._zoom)}this._moved||(f._moveStart(!0,!1),this._moved=!0),he(this._animRequest);var Ce=d(f._move,f,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=ye(Ce,this,!0),Cr(l)}},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,he(this._animRequest),za(document,"touchmove",this._onTouchMove,this),za(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))}});Ra.addInitHook("addHandler","touchZoom",o0),Ra.BoxZoom=rn,Ra.DoubleClickZoom=Yc,Ra.Drag=hi,Ra.Keyboard=i0,Ra.ScrollWheelZoom=Gl,Ra.TapHold=Zc,Ra.TouchZoom=o0,r.Bounds=F,r.Browser=rt,r.CRS=be,r.Canvas=Gc,r.Circle=Hn,r.CircleMarker=Xi,r.Class=se,r.Control=Rs,r.DivIcon=as,r.DivOverlay=xa,r.DomEvent=bo,r.DomUtil=Yr,r.Draggable=$n,r.Evented=W,r.FeatureGroup=jn,r.GeoJSON=Wn,r.GridLayer=Pa,r.Handler=fs,r.Icon=Ps,r.ImageOverlay=pe,r.LatLng=K,r.LatLngBounds=B,r.Layer=mn,r.LayerGroup=Zi,r.LineUtil=a0,r.Map=Ra,r.Marker=Ji,r.Mixin=tl,r.Path=hn,r.Point=I,r.PolyUtil=Bl,r.Polygon=Ki,r.Polyline=Fs,r.Popup=Tr,r.PosAnimation=Vi,r.Projection=Hl,r.Rectangle=Eo,r.Renderer=xs,r.SVG=il,r.SVGOverlay=Pt,r.TileLayer=Rr,r.Tooltip=Br,r.Transformation=Ne,r.Util=ce,r.VideoOverlay=Ct,r.bind=d,r.bounds=M,r.canvas=Vl,r.circle=sl,r.circleMarker=Nn,r.control=es,r.divIcon=Is,r.extend=i,r.featureGroup=Vc,r.geoJSON=To,r.geoJson=Z,r.gridLayer=qn,r.icon=jo,r.imageOverlay=je,r.latLng=we,r.latLngBounds=X,r.layerGroup=r0,r.map=Pl,r.marker=qc,r.point=ae,r.polygon=Iu,r.polyline=s0,r.popup=Ba,r.rectangle=ng,r.setOptions=k,r.stamp=h,r.svg=ql,r.svgOverlay=ma,r.tileLayer=zs,r.tooltip=an,r.transformation=Xe,r.version=s,r.videoOverlay=Jt;var l0=window.L;r.noConflict=function(){return window.L=l0,this},window.L=r}))})(Q0,Q0.exports)),Q0.exports}var Kd=HL();const rg=$_(Kd);function sg(t,a,r){return Object.freeze({instance:t,context:a,container:r})}function Mp(t,a){return a==null?function(s,i){const c=y.useRef(void 0);return c.current||(c.current=t(s,i)),c}:function(s,i){const c=y.useRef(void 0);c.current||(c.current=t(s,i));const d=y.useRef(s),{instance:m}=c.current;return y.useEffect(function(){d.current!==s&&(a(m,s,d.current),d.current=s)},[m,s,a]),c}}function WL(t,a){y.useEffect(function(){var i;return((i=a.layerContainer)!=null?i:a.map).addLayer(t.instance),function(){var d;(d=a.layerContainer)==null||d.removeLayer(t.instance),a.map.removeLayer(t.instance)}},[a,t])}function ij(t){return function(r){const s=Op(),i=t(Dp(r,s),s);return sj(s.map,r.attribution),nj(i.current,r.eventHandlers),WL(i.current,s),i}}function VL(t,a){const r=Mp(t,a),s=ij(r);return IL(s)}function oj(t,a){const r=Mp(t),s=UL(r,a);return zL(s)}function qL(t,a){const r=Mp(t,a),s=ij(r);return BL(s)}function GL(t,a,r){const{opacity:s,zIndex:i}=a;s!=null&&s!==r.opacity&&t.setOpacity(s),i!=null&&i!==r.zIndex&&t.setZIndex(i)}function YL(){return Op().map}function ZL(j,b){var _=j,{bounds:t,boundsOptions:a,center:r,children:s,className:i,id:c,placeholder:d,style:m,whenReady:h,zoom:g}=_,p=Dn(_,["bounds","boundsOptions","center","children","className","id","placeholder","style","whenReady","zoom"]);const[N]=y.useState({className:i,id:c,style:m}),[k,C]=y.useState(null),D=y.useRef(void 0);y.useImperativeHandle(b,()=>{var O;return(O=k==null?void 0:k.map)!=null?O:null},[k]);const T=y.useCallback(O=>{if(O!==null&&!D.current){const R=new Kd.Map(O,p);D.current=R,r!=null&&g!=null?R.setView(r,g):t!=null&&R.fitBounds(t,a),h!=null&&R.whenReady(h),C(PL(R))}},[]);y.useEffect(()=>()=>{k==null||k.map.remove()},[k]);const E=k?pa.createElement(Ap,{value:k},s):d!=null?d:null;return pa.createElement("div",Se(ue({},N),{ref:T}),E)}const JL=y.forwardRef(ZL),XL=VL(function(i,s){var c=i,{position:a}=c,r=Dn(c,["position"]);const d=new Kd.Marker(a,r);return sg(d,FL(s,{overlayContainer:d}))},function(a,r,s){r.position!==s.position&&a.setLatLng(r.position),r.icon!=null&&r.icon!==s.icon&&a.setIcon(r.icon),r.zIndexOffset!=null&&r.zIndexOffset!==s.zIndexOffset&&a.setZIndexOffset(r.zIndexOffset),r.opacity!=null&&r.opacity!==s.opacity&&a.setOpacity(r.opacity),a.dragging!=null&&r.draggable!==s.draggable&&(r.draggable===!0?a.dragging.enable():a.dragging.disable())}),KL=oj(function(a,r){const s=new Kd.Popup(a,r.overlayContainer);return sg(s,r)},function(a,r,{position:s},i){y.useEffect(function(){const{instance:d}=a;function m(g){g.popup===d&&(d.update(),i(!0))}function h(g){g.popup===d&&i(!1)}return r.map.on({popupopen:m,popupclose:h}),r.overlayContainer==null?(s!=null&&d.setLatLng(s),d.openOn(r.map)):r.overlayContainer.bindPopup(d),function(){var p;r.map.off({popupopen:m,popupclose:h}),(p=r.overlayContainer)==null||p.unbindPopup(),r.map.removeLayer(d)}},[a,r,i,s])}),QL=qL(function(i,s){var c=i,{url:a}=c,r=Dn(c,["url"]);const d=new Kd.TileLayer(a,Dp(r,s));return sg(d,s)},function(a,r,s){GL(a,r,s);const{url:i}=r;i!=null&&i!==s.url&&a.setUrl(i)}),eR=oj(function(a,r){const s=new Kd.Tooltip(a,r.overlayContainer);return sg(s,r)},function(a,r,{position:s},i){y.useEffect(function(){const d=r.overlayContainer;if(d==null)return;const{instance:m}=a,h=p=>{p.tooltip===m&&(s!=null&&m.setLatLng(s),m.update(),i(!0))},g=p=>{p.tooltip===m&&i(!1)};return d.on({tooltipopen:h,tooltipclose:g}),d.bindTooltip(m),function(){d.off({tooltipopen:h,tooltipclose:g}),d._map!=null&&d.unbindTooltip()}},[a,r,i,s])}),lj="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=",cj="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC",dj=rg.icon({iconUrl:lj,shadowUrl:cj,iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]});rg.Marker.prototype.options.icon=dj;const tR=rg.icon({iconUrl:lj,shadowUrl:cj,iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41],className:"department-marker-icon"}),aR=({locations:t})=>{const a=YL();return y.useEffect(()=>{if(t.length>0&&t.some(r=>r.latitude&&r.longitude)){const r=rg.latLngBounds(t.filter(s=>s.latitude&&s.longitude).map(s=>[s.latitude,s.longitude]));a.fitBounds(r,{padding:[30,30],maxZoom:8})}else a.setView([24.8,45.5],6)},[t,a]),null},rR=()=>{const{t}=ca(),a=qa(),[r,s]=y.useState(""),[i,c]=y.useState(""),[d,m]=y.useState([]),[h,g]=y.useState(!0),p=y.useRef({}),[b,j]=y.useState(null),[_,N]=y.useState(!1);y.useEffect(()=>{Q(null,null,function*(){try{const ne=yield(yield fetch("/api/method/frappe.auth.get_logged_user")).json(),ye=ne==null?void 0:ne.message;if(!ye){console.warn("[ActiveMap] Could not determine logged-in user, response:",ne),j(null),N(!0);return}console.log("[ActiveMap] Logged-in user:",ye);const ce=yield(yield fetch(`/api/resource/User Permission?filters=${encodeURIComponent(JSON.stringify({user:ye,allow:"Issue Type"}))}&fields=["for_value"]&limit_page_length=0`)).json(),se=(ce==null?void 0:ce.data)||[];if(se.length>0){const ee=se.map(te=>te.for_value).filter(Boolean);console.log("[ActiveMap] Allowed departments:",ee),j(ee)}else console.log("[ActiveMap] No Issue Type permissions → showing all departments"),j(null)}catch(J){console.error("[ActiveMap] Error fetching User Permissions:",J),j(null)}finally{N(!0)}})},[]);const k=()=>Q(null,null,function*(){if(_){g(!0);try{const U=[];if(!i){const J={latitude:["!=",""],longitude:["!=",""],custom_is_hospital:1};r&&(J.name=r);const ne=yield mt.apiCall(`/api/resource/Location?filters=${encodeURIComponent(JSON.stringify(J))}&fields=["name","latitude","longitude"]&limit_page_length=0`),he=((ne==null?void 0:ne.data)||[]).map(se=>Q(null,null,function*(){var te,W,I,oe,ae,F,M,B,X,K,we;const ee={assets:0,normal_work_orders:0,urgent_work_orders:0,planned_maintenance:0,completed_maintenance:0,overdue_maintenance:0,wo_open:0,wo_progress:0,wo_review:0,wo_completed:0,wo_closed:0,locationType:"hospital"};try{const be=yield mt.apiCall(`/api/resource/Asset?filters=${encodeURIComponent(JSON.stringify({company:se.name}))}&fields=["name"]&limit_page_length=0`);ee.assets=((te=be==null?void 0:be.data)==null?void 0:te.length)||0;const ke=yield mt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:se.name,custom_priority_:"Normal",repair_status:["in",["Open","Work In Progress","Closed"]]}))}&fields=["name"]&limit_page_length=0`);ee.normal_work_orders=((W=ke==null?void 0:ke.data)==null?void 0:W.length)||0;const Me=yield mt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:se.name,custom_priority_:"Urgent",repair_status:["in",["Open","Work In Progress","Closed"]]}))}&fields=["name"]&limit_page_length=0`);ee.urgent_work_orders=((I=Me==null?void 0:Me.data)==null?void 0:I.length)||0;const[z,Ne,Xe,gt,St,Ht,Mt,Te]=yield Promise.all([mt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:se.name,repair_status:"Open"}))}&fields=["name"]&limit_page_length=0`),mt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:se.name,repair_status:"Work In Progress"}))}&fields=["name"]&limit_page_length=0`),mt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:se.name,repair_status:"Pending Review"}))}&fields=["name"]&limit_page_length=0`),mt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:se.name,repair_status:"Completed"}))}&fields=["name"]&limit_page_length=0`),mt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({company:se.name,repair_status:"Closed"}))}&fields=["name"]&limit_page_length=0`),mt.apiCall(`/api/resource/Asset Maintenance Log?filters=${encodeURIComponent(JSON.stringify({custom_hospital_name:se.name,maintenance_status:"Planned"}))}&fields=["name"]&limit_page_length=0`),mt.apiCall(`/api/resource/Asset Maintenance Log?filters=${encodeURIComponent(JSON.stringify({custom_hospital_name:se.name,maintenance_status:"Completed"}))}&fields=["name"]&limit_page_length=0`),mt.apiCall(`/api/resource/Asset Maintenance Log?filters=${encodeURIComponent(JSON.stringify({custom_hospital_name:se.name,maintenance_status:"Overdue"}))}&fields=["name"]&limit_page_length=0`)]);ee.wo_open=((oe=z==null?void 0:z.data)==null?void 0:oe.length)||0,ee.wo_progress=((ae=Ne==null?void 0:Ne.data)==null?void 0:ae.length)||0,ee.wo_review=((F=Xe==null?void 0:Xe.data)==null?void 0:F.length)||0,ee.wo_completed=((M=gt==null?void 0:gt.data)==null?void 0:M.length)||0,ee.wo_closed=((B=St==null?void 0:St.data)==null?void 0:B.length)||0,ee.planned_maintenance=((X=Ht==null?void 0:Ht.data)==null?void 0:X.length)||0,ee.completed_maintenance=((K=Mt==null?void 0:Mt.data)==null?void 0:K.length)||0,ee.overdue_maintenance=((we=Te==null?void 0:Te.data)==null?void 0:we.length)||0}catch(be){console.error(`Error fetching counts for hospital ${se.name}:`,be)}return ue({name:se.name,latitude:parseFloat(se.latitude),longitude:parseFloat(se.longitude)},ee)})),ce=yield Promise.all(he);U.push(...ce.filter(se=>!isNaN(se.latitude)&&!isNaN(se.longitude)))}if(!r){const J={latitude:["!=",""],longitude:["!=",""],custom_is_wo_type:1};if(i&&(J.name=i),b!==null&&b.length>0&&!i)J.name=["in",b];else if(b!==null&&b.length===0){console.log("[ActiveMap] User has Issue Type permissions but no matching values — skipping departments"),m(U),g(!1);return}console.log("[ActiveMap] Department filters:",J);const ne=yield mt.apiCall(`/api/resource/Location?filters=${encodeURIComponent(JSON.stringify(J))}&fields=["name","latitude","longitude"]&limit_page_length=0`),ye=(ne==null?void 0:ne.data)||[];console.log("[ActiveMap] Departments to show on map:",ye.map(se=>se.name));const he=ye.map(se=>Q(null,null,function*(){var te,W,I,oe,ae,F,M;const ee={assets:0,normal_work_orders:0,urgent_work_orders:0,planned_maintenance:0,completed_maintenance:0,overdue_maintenance:0,wo_open:0,wo_progress:0,wo_review:0,wo_completed:0,wo_closed:0,locationType:"department"};try{const B=yield mt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:se.name,custom_priority_:"Normal",repair_status:["in",["Open","Work In Progress","Closed"]]}))}&fields=["name"]&limit_page_length=0`);ee.normal_work_orders=((te=B==null?void 0:B.data)==null?void 0:te.length)||0;const X=yield mt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:se.name,custom_priority_:"Urgent",repair_status:["in",["Open","Work In Progress","Closed"]]}))}&fields=["name"]&limit_page_length=0`);ee.urgent_work_orders=((W=X==null?void 0:X.data)==null?void 0:W.length)||0;const[K,we,be,ke,Me]=yield Promise.all([mt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:se.name,repair_status:"Open"}))}&fields=["name"]&limit_page_length=0`),mt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:se.name,repair_status:"Work In Progress"}))}&fields=["name"]&limit_page_length=0`),mt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:se.name,repair_status:"Pending Review"}))}&fields=["name"]&limit_page_length=0`),mt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:se.name,repair_status:"Completed"}))}&fields=["name"]&limit_page_length=0`),mt.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify({work_order_type:se.name,repair_status:"Closed"}))}&fields=["name"]&limit_page_length=0`)]);ee.wo_open=((I=K==null?void 0:K.data)==null?void 0:I.length)||0,ee.wo_progress=((oe=we==null?void 0:we.data)==null?void 0:oe.length)||0,ee.wo_review=((ae=be==null?void 0:be.data)==null?void 0:ae.length)||0,ee.wo_completed=((F=ke==null?void 0:ke.data)==null?void 0:F.length)||0,ee.wo_closed=((M=Me==null?void 0:Me.data)==null?void 0:M.length)||0}catch(B){console.error(`Error fetching counts for department ${se.name}:`,B)}return ue({name:se.name,latitude:parseFloat(se.latitude),longitude:parseFloat(se.longitude)},ee)})),ce=yield Promise.all(he);U.push(...ce.filter(se=>!isNaN(se.latitude)&&!isNaN(se.longitude)))}m(U)}catch(U){console.error("Error fetching map data:",U)}finally{g(!1)}}});y.useEffect(()=>{k()},[r,i,_]);const C=U=>{s(U),U&&c("")},D=U=>{c(U),U&&s("")},T=(U,J,ne,ye)=>{const he=new URLSearchParams;J==="hospital"?U&&he.set("company",U):U&&he.set("work_order_type",U),ne&&he.set("priority",ne),ye&&he.set("status",ye),a(`/work-orders?${he.toString()}`)},E=U=>{const J=new URLSearchParams;U&&J.set("company",U),a(`/assets?${J.toString()}`)},O=(U,J)=>{const ne=new URLSearchParams;U&&ne.set("hospital",U),J&&ne.set("status",J),a(`/maintenance-calendar?${ne.toString()}`)},R=U=>e.jsxs("div",{className:"p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg min-w-[280px] max-w-[320px]",children:[e.jsxs("div",{className:"mb-4 pb-3 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"px-2 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded text-xs font-medium",children:t("activeMap.hospital")})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900 dark:text-white mt-1",children:U.name}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:[t("activeMap.totalAssets"),": ",e.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:U.assets})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200 mb-2",children:t("activeMap.workOrderStatus")}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsxs("button",{onClick:()=>T(U.name,"hospital","Normal"),className:"px-3 py-1.5 bg-blue-100 dark:bg-blue-900/30 hover:bg-blue-200 dark:hover:bg-blue-900/50 text-blue-700 dark:text-blue-300 rounded-lg text-xs font-semibold transition-colors cursor-pointer",children:[t("activeMap.normal"),": ",U.normal_work_orders]}),e.jsxs("button",{onClick:()=>T(U.name,"hospital","Urgent"),className:"px-3 py-1.5 bg-red-100 dark:bg-red-900/30 hover:bg-red-200 dark:hover:bg-red-900/50 text-red-700 dark:text-red-300 rounded-lg text-xs font-semibold transition-colors cursor-pointer",children:[t("activeMap.urgent"),": ",U.urgent_work_orders]})]}),e.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-200 dark:border-gray-700",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 text-left font-semibold text-gray-700 dark:text-gray-300",children:t("activeMap.status")}),e.jsx("th",{className:"px-3 py-2 text-left font-semibold text-gray-700 dark:text-gray-300",children:t("activeMap.count")})]})}),e.jsxs("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsxs("tr",{className:"bg-red-50 dark:bg-red-900/20 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors",children:[e.jsx("td",{className:"px-3 py-2 text-red-800 dark:text-red-300 font-medium",children:t("activeMap.open")}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("button",{onClick:()=>T(U.name,"hospital",void 0,"Open"),className:"text-red-700 dark:text-red-400 font-bold hover:underline cursor-pointer",children:U.wo_open})})]}),e.jsxs("tr",{className:"bg-yellow-50 dark:bg-yellow-900/20 hover:bg-yellow-100 dark:hover:bg-yellow-900/30 transition-colors",children:[e.jsx("td",{className:"px-3 py-2 text-yellow-800 dark:text-yellow-300 font-medium",children:t("activeMap.workInProgress")}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("button",{onClick:()=>T(U.name,"hospital",void 0,"Work In Progress"),className:"text-yellow-700 dark:text-yellow-400 font-bold hover:underline cursor-pointer",children:U.wo_progress})})]}),e.jsxs("tr",{className:"bg-blue-50 dark:bg-blue-900/20 hover:bg-blue-100 dark:hover:bg-blue-900/30 transition-colors",children:[e.jsx("td",{className:"px-3 py-2 text-blue-800 dark:text-blue-300 font-medium",children:t("activeMap.pendingReview")}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("button",{onClick:()=>T(U.name,"hospital",void 0,"Pending Review"),className:"text-blue-700 dark:text-blue-400 font-bold hover:underline cursor-pointer",children:U.wo_review})})]}),e.jsxs("tr",{className:"bg-green-50 dark:bg-green-900/20 hover:bg-green-100 dark:hover:bg-green-900/30 transition-colors",children:[e.jsx("td",{className:"px-3 py-2 text-green-800 dark:text-green-300 font-medium",children:t("activeMap.completed")}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("button",{onClick:()=>T(U.name,"hospital",void 0,"Completed"),className:"text-green-700 dark:text-green-400 font-bold hover:underline cursor-pointer",children:U.wo_completed})})]}),e.jsxs("tr",{className:"bg-gray-50 dark:bg-gray-900/20 hover:bg-gray-100 dark:hover:bg-gray-900/30 transition-colors",children:[e.jsx("td",{className:"px-3 py-2 text-gray-800 dark:text-gray-300 font-medium",children:t("activeMap.closed")}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("button",{onClick:()=>T(U.name,"hospital",void 0,"Closed"),className:"text-gray-700 dark:text-gray-400 font-bold hover:underline cursor-pointer",children:U.wo_closed})})]})]})]})})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200 mb-2",children:t("activeMap.preventiveMaintenance")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{onClick:()=>O(U.name,"Planned"),className:"px-3 py-1.5 bg-orange-100 dark:bg-orange-900/30 hover:bg-orange-200 dark:hover:bg-orange-900/50 text-orange-700 dark:text-orange-300 rounded-lg text-xs font-semibold transition-colors cursor-pointer",children:[t("activeMap.planned"),": ",U.planned_maintenance]}),e.jsxs("button",{onClick:()=>O(U.name,"Completed"),className:"px-3 py-1.5 bg-green-100 dark:bg-green-900/30 hover:bg-green-200 dark:hover:bg-green-900/50 text-green-700 dark:text-green-300 rounded-lg text-xs font-semibold transition-colors cursor-pointer",children:[t("activeMap.completed"),": ",U.completed_maintenance]}),e.jsxs("button",{onClick:()=>O(U.name,"Overdue"),className:"px-3 py-1.5 bg-red-100 dark:bg-red-900/30 hover:bg-red-200 dark:hover:bg-red-900/50 text-red-700 dark:text-red-300 rounded-lg text-xs font-semibold transition-colors cursor-pointer",children:[t("activeMap.overdue"),": ",U.overdue_maintenance]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-3 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("button",{onClick:()=>E(U.name),className:"flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 dark:bg-blue-700 dark:hover:bg-blue-600 text-white rounded-lg text-sm font-medium transition-colors cursor-pointer",children:t("activeMap.viewAssets")}),e.jsx("button",{onClick:()=>T(U.name,"hospital"),className:"flex-1 px-4 py-2 bg-purple-600 hover:bg-purple-700 dark:bg-purple-700 dark:hover:bg-purple-600 text-white rounded-lg text-sm font-medium transition-colors cursor-pointer",children:t("activeMap.viewWorkOrders")})]})]}),Y=U=>e.jsxs("div",{className:"p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg min-w-[280px] max-w-[320px]",children:[e.jsxs("div",{className:"mb-4 pb-3 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"px-2 py-0.5 bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 rounded text-xs font-medium",children:t("activeMap.deptWoType")})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900 dark:text-white mt-1",children:U.name}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1 italic",children:t("activeMap.showingWorkOrdersByType")})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200 mb-2",children:t("activeMap.workOrderStatus")}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsxs("button",{onClick:()=>T(U.name,"department","Normal"),className:"px-3 py-1.5 bg-blue-100 dark:bg-blue-900/30 hover:bg-blue-200 dark:hover:bg-blue-900/50 text-blue-700 dark:text-blue-300 rounded-lg text-xs font-semibold transition-colors cursor-pointer",children:[t("activeMap.normal"),": ",U.normal_work_orders]}),e.jsxs("button",{onClick:()=>T(U.name,"department","Urgent"),className:"px-3 py-1.5 bg-red-100 dark:bg-red-900/30 hover:bg-red-200 dark:hover:bg-red-900/50 text-red-700 dark:text-red-300 rounded-lg text-xs font-semibold transition-colors cursor-pointer",children:[t("activeMap.urgent"),": ",U.urgent_work_orders]})]}),e.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-200 dark:border-gray-700",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 text-left font-semibold text-gray-700 dark:text-gray-300",children:t("activeMap.status")}),e.jsx("th",{className:"px-3 py-2 text-left font-semibold text-gray-700 dark:text-gray-300",children:t("activeMap.count")})]})}),e.jsxs("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsxs("tr",{className:"bg-red-50 dark:bg-red-900/20 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors",children:[e.jsx("td",{className:"px-3 py-2 text-red-800 dark:text-red-300 font-medium",children:t("activeMap.open")}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("button",{onClick:()=>T(U.name,"department",void 0,"Open"),className:"text-red-700 dark:text-red-400 font-bold hover:underline cursor-pointer",children:U.wo_open})})]}),e.jsxs("tr",{className:"bg-yellow-50 dark:bg-yellow-900/20 hover:bg-yellow-100 dark:hover:bg-yellow-900/30 transition-colors",children:[e.jsx("td",{className:"px-3 py-2 text-yellow-800 dark:text-yellow-300 font-medium",children:t("activeMap.workInProgress")}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("button",{onClick:()=>T(U.name,"department",void 0,"Work In Progress"),className:"text-yellow-700 dark:text-yellow-400 font-bold hover:underline cursor-pointer",children:U.wo_progress})})]}),e.jsxs("tr",{className:"bg-blue-50 dark:bg-blue-900/20 hover:bg-blue-100 dark:hover:bg-blue-900/30 transition-colors",children:[e.jsx("td",{className:"px-3 py-2 text-blue-800 dark:text-blue-300 font-medium",children:t("activeMap.pendingReview")}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("button",{onClick:()=>T(U.name,"department",void 0,"Pending Review"),className:"text-blue-700 dark:text-blue-400 font-bold hover:underline cursor-pointer",children:U.wo_review})})]}),e.jsxs("tr",{className:"bg-green-50 dark:bg-green-900/20 hover:bg-green-100 dark:hover:bg-green-900/30 transition-colors",children:[e.jsx("td",{className:"px-3 py-2 text-green-800 dark:text-green-300 font-medium",children:t("activeMap.completed")}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("button",{onClick:()=>T(U.name,"department",void 0,"Completed"),className:"text-green-700 dark:text-green-400 font-bold hover:underline cursor-pointer",children:U.wo_completed})})]}),e.jsxs("tr",{className:"bg-gray-50 dark:bg-gray-900/20 hover:bg-gray-100 dark:hover:bg-gray-900/30 transition-colors",children:[e.jsx("td",{className:"px-3 py-2 text-gray-800 dark:text-gray-300 font-medium",children:t("activeMap.closed")}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("button",{onClick:()=>T(U.name,"department",void 0,"Closed"),className:"text-gray-700 dark:text-gray-400 font-bold hover:underline cursor-pointer",children:U.wo_closed})})]})]})]})})]}),e.jsx("div",{className:"pt-3 border-t border-gray-200 dark:border-gray-700",children:e.jsx("button",{onClick:()=>T(U.name,"department"),className:"w-full px-4 py-2 bg-purple-600 hover:bg-purple-700 dark:bg-purple-700 dark:hover:bg-purple-600 text-white rounded-lg text-sm font-medium transition-colors cursor-pointer",children:t("activeMap.viewAllWorkOrders")})})]}),P=U=>{const J=U.urgent_work_orders>0?`🚨 ${t("activeMap.tooltipUrgent")}`:"",ne=U.locationType==="department"?`📋 ${t("activeMap.tooltipDept")}`:`🏥 ${t("activeMap.tooltipHospital")}`;return e.jsxs("div",{className:"p-2 bg-white dark:bg-gray-800 rounded-lg shadow-lg min-w-[200px]",children:[e.jsxs("div",{className:"mb-2 pb-2 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"flex items-center gap-1 mb-1",children:e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${U.locationType==="department"?"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300":"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300"}`,children:ne})}),e.jsxs("h4",{className:"text-sm font-bold text-gray-900 dark:text-white",children:[J,U.name]}),U.locationType==="hospital"&&e.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5",children:[t("activeMap.assets"),": ",e.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:U.assets})]})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:t("activeMap.normalWos")}),e.jsx("span",{className:"font-semibold text-blue-700 dark:text-blue-300",children:U.normal_work_orders})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:t("activeMap.urgentWos")}),e.jsx("span",{className:"font-semibold text-red-700 dark:text-red-300",children:U.urgent_work_orders})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:t("activeMap.closedWos")}),e.jsx("span",{className:"font-semibold text-gray-700 dark:text-gray-300",children:U.wo_closed})]}),U.locationType==="hospital"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:t("activeMap.plannedPms")}),e.jsx("span",{className:"font-semibold text-orange-700 dark:text-orange-300",children:U.planned_maintenance})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:t("activeMap.completedPms")}),e.jsx("span",{className:"font-semibold text-green-700 dark:text-green-300",children:U.completed_maintenance})]})]})]})]})};return e.jsxs("div",{className:"h-screen flex flex-col bg-gray-50 dark:bg-gray-900",children:[e.jsx("div",{className:"flex-shrink-0 bg-white dark:bg-gray-800 shadow-sm border-b border-gray-200 dark:border-gray-700 px-4 py-3",children:e.jsx("h1",{className:"text-xl font-semibold text-gray-800 dark:text-white",children:t("activeMap.title")})}),e.jsxs("div",{className:"flex-shrink-0 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 px-4 py-3 relative z-[1000]",children:[e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs("div",{className:"w-64 relative z-[1000]",children:[e.jsx(Ut,{label:t("activeMap.hospital"),doctype:"Location",value:r,onChange:C,filters:{custom_is_hospital:1},placeholder:t("activeMap.selectHospital"),disabled:!!i}),i&&e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:t("activeMap.clearDepartmentHint")})]}),e.jsxs("div",{className:"w-64 relative z-[1000]",children:[e.jsx(Ut,{label:t("activeMap.departmentWoType"),doctype:"Location",value:i,onChange:D,filters:b!==null&&b.length>0?{custom_is_wo_type:1,name:["in",b]}:{custom_is_wo_type:1},placeholder:t("activeMap.selectDepartment"),disabled:!!r}),r&&e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:t("activeMap.clearHospitalHint")})]}),(r||i)&&e.jsx("div",{className:"flex items-end",children:e.jsx("button",{onClick:()=>{s(""),c("")},className:"px-4 py-2 bg-gray-200 hover:bg-gray-300 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium transition-colors",children:t("activeMap.clearFilters")})})]}),e.jsxs("div",{className:"flex gap-4 mt-3 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-3 h-3 bg-blue-500 rounded-full"}),e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:t("activeMap.legendHospital")})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-3 h-3 bg-green-500 rounded-full"}),e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:t("activeMap.legendDepartment")})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-3 h-3 bg-red-500 rounded-full animate-pulse"}),e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:t("activeMap.legendHasUrgent")})]})]})]}),e.jsxs("div",{className:"flex-1 relative",style:{zIndex:1},children:[h&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-white bg-opacity-75 z-[1000]",children:e.jsx("div",{className:"text-gray-600 dark:text-gray-300",children:t("activeMap.loading")})}),e.jsxs(JL,{center:[24.8,45.5],zoom:6,style:{height:"100%",width:"100%"},zoomControl:!0,children:[e.jsx(QL,{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),e.jsx(aR,{locations:d}),d.map(U=>{const J=`${U.locationType}-${U.latitude}-${U.longitude}`,ne=U.locationType==="department";return e.jsxs(XL,{position:[U.latitude,U.longitude],icon:ne?tR:dj,ref:ye=>{ye&&(p.current[J]=ye,setTimeout(()=>{const he=ye.getElement();he&&(U.urgent_work_orders>0&&he.classList.add("urgent-marker"),ne&&he.classList.add("department-marker"))},100))},children:[e.jsx(eR,{permanent:!1,direction:"right",className:"hospital-tooltip-modern",children:P(U)}),e.jsx(KL,{className:"hospital-popup-container",maxWidth:300,maxHeight:450,autoPan:!0,keepInView:!0,closeButton:!0,autoClose:!1,children:ne?Y(U):R(U)})]},J)})]})]}),e.jsx("style",{children:`
/* Ensure filter container and dropdowns stay above map */
.leaflet-container {
z-index: 1 !important;
}
/* LinkField dropdown z-index - ensure it's above everything */
[data-linkfield-dropdown],
.linkfield-dropdown,
.react-select__menu,
.react-select__menu-portal,
.select2-container,
.select2-dropdown {
z-index: 1050 !important;
}
/* Any dropdown menu from LinkField */
div[role="listbox"],
ul[role="listbox"],
.dropdown-menu,
.autocomplete-dropdown {
z-index: 1050 !important;
}
.hospital-tooltip-modern {
background: transparent !important;
border: none !important;
box-shadow: none !important;
}
.hospital-tooltip-modern .leaflet-tooltip-content-wrapper {
background: transparent !important;
border: none !important;
box-shadow: none !important;
padding: 0 !important;
}
.hospital-tooltip-modern .leaflet-tooltip-content {
margin: 0 !important;
}
.hospital-popup-container .leaflet-popup-content-wrapper {
padding: 0;
border-radius: 8px;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}
.hospital-popup-container .leaflet-popup-content {
margin: 0;
width: auto !important;
}
.urgent-marker {
animation: urgent-flash 2s infinite;
}
@keyframes urgent-flash {
0%, 50% {
filter: hue-rotate(0deg) brightness(1) saturate(1);
}
25%, 75% {
filter: hue-rotate(0deg) brightness(1.5) saturate(2) drop-shadow(0 0 10px red);
}
}
/* Department marker - purple tint */
.department-marker {
filter: hue-rotate(270deg) saturate(1.5) brightness(1);
}
/* When department marker has urgent */
.department-marker.urgent-marker {
animation: department-urgent-flash 2s infinite;
}
@keyframes department-urgent-flash {
0%, 50% {
filter: hue-rotate(270deg) saturate(1.5) brightness(1);
}
25%, 75% {
filter: hue-rotate(270deg) brightness(1.5) saturate(2) drop-shadow(0 0 10px red);
}
}
.leaflet-popup {
z-index: 2000 !important;
}
.leaflet-tooltip {
z-index: 2000 !important;
}
`})]})};class sR{getItems(a,r,s=20,i=0,c){return Q(this,null,function*(){try{const{toFrappeFilterArray:d}=yield hu(()=>Q(null,null,function*(){const{toFrappeFilterArray:g}=yield Promise.resolve().then(()=>Np);return{toFrappeFilterArray:g}}),void 0);let m=[];a&&Object.keys(a).length>0&&(m=d(a));const h=yield mt.apiCall("/api/method/asset_lite.api.item_api.get_items",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filters:m.length>0?m:[],fields:r||[],limit:s,offset:i,order_by:c||"creation desc"})});return{data:h.data||[],total:h.total||0}}catch(d){throw console.error("Error fetching items:",d),d}})}getItem(a){return Q(this,null,function*(){try{return(yield mt.apiCall(`/api/resource/Item/${encodeURIComponent(a)}`)).data}catch(r){throw console.error("Error fetching item:",r),r}})}createItem(a){return Q(this,null,function*(){try{return(yield mt.apiCall("/api/resource/Item",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).data}catch(r){throw console.error("Error creating item:",r),r}})}updateItem(a,r){return Q(this,null,function*(){try{return(yield mt.apiCall(`/api/resource/Item/${encodeURIComponent(a)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).data}catch(s){throw console.error("Error updating item:",s),s}})}deleteItem(a){return Q(this,null,function*(){try{yield mt.apiCall(`/api/resource/Item/${encodeURIComponent(a)}`,{method:"DELETE"})}catch(r){throw console.error("Error deleting item:",r),r}})}submitItem(a){return Q(this,null,function*(){try{return(yield mt.apiCall(`/api/resource/Item/${encodeURIComponent(a)}/submit`,{method:"POST"})).data}catch(r){throw console.error("Error submitting item:",r),r}})}cancelItem(a){return Q(this,null,function*(){try{return(yield mt.apiCall(`/api/resource/Item/${a}/cancel`,{method:"POST"})).data}catch(r){throw console.error("Error cancelling item:",r),r}})}}const Md=new sR;function nR(t,a=20,r=0,s){const[i,c]=y.useState([]),[d,m]=y.useState(0),[h,g]=y.useState(!1),[p,b]=y.useState(!0),[j,_]=y.useState(null),[N,k]=y.useState(0);y.useRef(!1);const C=JSON.stringify(t);y.useEffect(()=>{let T=!1;return Q(null,null,function*(){try{b(!0);const O=["name","item_code","item_name","item_group","stock_uom","disabled","is_stock_item","is_fixed_asset","custom_hospital_name","opening_stock","valuation_rate","standard_rate","creation","modified","owner","docstatus","custom_serial_no","custom_date_in","custom_code","custom_type","custom_volts","custom_w","custom_delete_status"],R=yield Md.getItems(t,O,a,r,s);T||(c(R.data),m(R.total),g(R.data.length===a),_(null))}catch(O){if(!T){const R=O instanceof Error?O.message:"Failed to fetch items";_(R),c([]),m(0),g(!1)}}finally{T||b(!1)}}),()=>{T=!0}},[C,a,r,s,N]);const D=y.useCallback(()=>{k(T=>T+1)},[]);return{items:i,totalCount:d,hasMore:h,loading:p,error:j,refetch:D}}function iR(t){const[a,r]=y.useState(null),[s,i]=y.useState(!0),[c,d]=y.useState(null),m=y.useCallback(()=>Q(null,null,function*(){if(!t){r(null),i(!1);return}try{i(!0),d(null);const g=yield Md.getItem(t);r(g)}catch(g){d(g instanceof Error?g.message:"Failed to fetch item details")}finally{i(!1)}}),[t]);y.useEffect(()=>{m()},[m]);const h=y.useCallback(()=>{m()},[m]);return{item:a,loading:s,error:c,refetch:h}}function uj(){const[t,a]=y.useState(!1),[r,s]=y.useState(null),i=y.useCallback(h=>Q(null,null,function*(){try{return a(!0),s(null),yield Md.createItem(h)}catch(g){const p=g instanceof Error?g.message:"Failed to create item";throw s(p),g}finally{a(!1)}}),[]),c=y.useCallback((h,g)=>Q(null,null,function*(){try{return a(!0),s(null),yield Md.updateItem(h,g)}catch(p){const b=p instanceof Error?p.message:"Failed to update item";throw s(b),p}finally{a(!1)}}),[]),d=y.useCallback(h=>Q(null,null,function*(){try{a(!0),s(null),yield Md.deleteItem(h)}catch(g){const p=g instanceof Error?g.message:"Failed to delete item";throw s(p),g}finally{a(!1)}}),[]),m=y.useCallback(h=>Q(null,null,function*(){try{return a(!0),s(null),yield Md.submitItem(h)}catch(g){const p=g instanceof Error?g.message:"Failed to submit item";throw s(p),g}finally{a(!1)}}),[]);return{createItem:i,updateItem:c,deleteItem:d,submitItem:m,loading:t,error:r}}const oR=({isOpen:t,onClose:a,selectedCount:r,totalCount:s,pageCount:i,onExport:c,isExporting:d,exportColumns:m})=>{const{t:h}=ca(),[g,p]=y.useState(r>0?"selected":"all_with_filters"),[b,j]=y.useState("csv"),[_,N]=y.useState(m.filter(T=>T.default).map(T=>T.key));y.useEffect(()=>{r>0?p("selected"):p("all_with_filters")},[r]);const k=T=>{N(E=>E.includes(T)?E.filter(O=>O!==T):[...E,T])},C=()=>{N(m.map(T=>T.key))},D=()=>{N(m.filter(T=>T.default).map(T=>T.key))};return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] overflow-hidden animate-scale-in",children:[e.jsx("div",{className:"bg-gradient-to-r from-green-500 to-green-600 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Os,{className:"text-white text-xl"}),e.jsx("h3",{className:"text-lg font-semibold text-white",children:h("items.export.title")})]}),e.jsx("button",{onClick:a,className:"text-white/80 hover:text-white transition-colors",disabled:d,children:e.jsx(wt,{size:20})})]})}),e.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:h("items.export.selectData")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="selected"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"} ${r===0?"opacity-50 cursor-not-allowed":""}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"selected",checked:g==="selected",onChange:()=>p("selected"),disabled:r===0,className:"text-green-600 focus:ring-green-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("items.export.selectedRows")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("items.export.selectedCount",{count:r})})]}),r>0&&e.jsxs("span",{className:"bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300 px-2 py-1 rounded text-xs font-medium",children:[r," ",h("common.selected")]})]}),e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="all_on_page"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:g==="all_on_page",onChange:()=>p("all_on_page"),className:"text-green-600 focus:ring-green-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("items.export.currentPage")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("items.export.currentPageCount",{count:i})})]}),e.jsxs("span",{className:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 px-2 py-1 rounded text-xs font-medium",children:[i," ",h("common.rows")]})]}),e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="all_with_filters"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:g==="all_with_filters",onChange:()=>p("all_with_filters"),className:"text-green-600 focus:ring-green-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("items.export.allWithFilters")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("items.export.allWithFiltersCount",{count:s})})]}),e.jsxs("span",{className:"bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300 px-2 py-1 rounded text-xs font-medium",children:[s," ",h("common.total")]})]})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:h("listPages.exportFormat")}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${b==="csv"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"format",value:"csv",checked:b==="csv",onChange:()=>j("csv"),className:"text-green-600 focus:ring-green-500"}),e.jsx(Bi,{className:"text-green-600 text-xl"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("listPages.csv")}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("items.export.csvDesc")})]})]}),e.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${b==="excel"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"format",value:"excel",checked:b==="excel",onChange:()=>j("excel"),className:"text-green-600 focus:ring-green-500"}),e.jsx(Ui,{className:"text-green-700 text-xl"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("listPages.excel")}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("items.export.excelDesc")})]})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:h("items.export.columnsToExport")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:C,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("items.export.selectAll")}),e.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),e.jsx("button",{onClick:D,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("items.export.resetToDefault")})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2 max-h-48 overflow-y-auto p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg",children:m.map(T=>e.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${_.includes(T.key)?"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-400"}`,children:[e.jsx("input",{type:"checkbox",checked:_.includes(T.key),onChange:()=>k(T.key),className:"rounded text-green-600 focus:ring-green-500"}),e.jsx("span",{className:"text-sm truncate",children:T.label})]},T.key))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:h("items.export.columnsSelected",{count:_.length})})]})]}),e.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[g==="selected"&&h("items.export.exportingSelected",{count:r}),g==="all_on_page"&&h("items.export.exportingPage",{count:i}),g==="all_with_filters"&&h("items.export.exportingAll",{count:s})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",disabled:d,children:h("common.cancel")}),e.jsx("button",{onClick:()=>c(g,b,_),disabled:_.length===0||d,className:"px-4 py-2 text-sm font-medium text-white bg-green-600 hover:bg-green-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:d?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),h("items.export.exporting")]}):e.jsxs(e.Fragment,{children:[e.jsx(po,{}),h("items.export.exportButton")]})})]})]})]})}):null},lR=()=>{const{t}=ca(),a=qa(),[r,s]=Qs(),c=y.useMemo(()=>{const re=parseInt(r.get("page")||"1",10);return Math.max(0,Number.isNaN(re)?0:re-1)},[r]),d=y.useCallback(re=>{s(Ee=>{const Ge=new URLSearchParams(Ee);return Ge.set("page",String(re+1)),Ge})},[s]),[m,h]=y.useState(null),g=20,p=[{key:"name",label:"Item ID",default:!0},{key:"item_code",label:"Item Code",default:!0},{key:"item_name",label:"Item Name",default:!0},{key:"item_group",label:"Item Group",default:!0},{key:"custom_hospital_name",label:"Hospital",default:!0},{key:"custom_serial_no",label:"Serial No",default:!0},{key:"custom_technical_department",label:"Technical Department",default:!0},{key:"custom_date_in",label:"Date In",default:!0},{key:"custom_w",label:"Watts",default:!0},{key:"custom_volts",label:"Volts",default:!0},{key:"custom_type",label:"Type",default:!0},{key:"custom_code",label:"Code",default:!0},{key:"stock_uom",label:"Stock UOM",default:!1},{key:"custom_part_description",label:"Part Description",default:!1},{key:"brand",label:"Brand",default:!1},{key:"valuation_rate",label:"Valuation Rate",default:!1},{key:"opening_stock",label:"Opening Stock",default:!1},{key:"custom_last_calibration_date",label:"Last Calibration Date",default:!1},{key:"custom_next_due_calibration_date",label:"Next Calibration Date",default:!1},{key:"description",label:"Description",default:!1},{key:"creation",label:"Created On",default:!1},{key:"modified",label:"Modified On",default:!0},{key:"owner",label:"Created By",default:!1},{key:"modified_by",label:"Modified By",default:!1}],[b,j]=y.useState(!1),[_,N]=y.useState(new Set),[k,C]=y.useState(!1),[D,T]=y.useState(!1),[E,O]=y.useState([]),[R,Y]=y.useState(!1);y.useEffect(()=>{Q(null,null,function*(){try{const Ge=yield(yield fetch("/api/method/asset_lite.api.user_roles.get_user_roles",{credentials:"include"})).json(),ct=Array.isArray(Ge.message)?Ge.message:[];O(ct),Y(ct.includes("System Manager"))}catch(Ee){console.error("Failed to fetch user roles:",Ee)}})},[]);const[P,U]=y.useState(()=>r.get("date_filter_by")||""),[J,ne]=y.useState(()=>r.get("date_start")||""),[ye,he]=y.useState(()=>r.get("date_end")||""),[ce,se]=y.useState(()=>r.get("item_id")||""),[ee,te]=y.useState(()=>r.get("item_group")||""),[W,I]=y.useState(()=>r.get("company")||""),[oe,ae]=y.useState(()=>r.get("item_name")||""),F=["creation desc","creation asc","modified desc","modified asc","item_name asc","item_name desc","name asc","name desc"],[M,B]=y.useState(()=>r.get("sort_by")||"creation desc"),[X,K]=y.useState(!0),[we,be]=y.useState(0),[ke,Me]=y.useState([]),[z,Ne]=y.useState(!1),[Xe,gt]=y.useState(""),[St,Ht]=y.useState(()=>r.get("item_name")||""),Mt=y.useRef(null);y.useEffect(()=>{const re=localStorage.getItem("itemFilterPresets");re&&Me(JSON.parse(re))},[]);const Te=P&&(J||ye);y.useEffect(()=>{const re=[ce,ee,W,oe].filter(Boolean).length+(Te?1:0);be(re)},[ce,ee,W,oe,Te]);const Qt={};ce&&(Qt.name=ce),ee&&(Qt.item_group=ee),W&&(Qt.custom_hospital_name=W),oe&&(Qt.item_name=["like",`%${oe}%`]),Object.assign(Qt,el(P,J,ye)),Qt.custom_delete_status=["!=","Deleted"];const zt=F.includes(M)?M:"creation desc",{items:Wt,totalCount:Vt,hasMore:va,loading:ta,error:sa,refetch:ra}=nR(Object.keys(Qt).length>0?Qt:void 0,g,c*g,zt),{deleteItem:Ye,loading:ft}=uj();y.useEffect(()=>{!ta&&!b&&j(!0)},[ta,b]);const $t=y.useRef(!1);y.useEffect(()=>{if(!$t.current){$t.current=!0;return}s(re=>{const Ee=new URLSearchParams(re);return P?Ee.set("date_filter_by",P):Ee.delete("date_filter_by"),J?Ee.set("date_start",J):Ee.delete("date_start"),ye?Ee.set("date_end",ye):Ee.delete("date_end"),ce?Ee.set("item_id",ce):Ee.delete("item_id"),ee?Ee.set("item_group",ee):Ee.delete("item_group"),W?Ee.set("company",W):Ee.delete("company"),oe?Ee.set("item_name",oe):Ee.delete("item_name"),M&&M!=="creation desc"?Ee.set("sort_by",M):Ee.delete("sort_by"),Ee.set("page","1"),Ee})},[P,J,ye,ce,ee,W,oe,M]),y.useEffect(()=>{N(new Set)},[P,J,ye,ce,ee,W,oe,c]);const na=re=>{Ht(re),Mt.current&&clearTimeout(Mt.current),Mt.current=window.setTimeout(()=>{ae(re)},800)},Ze=re=>{re.key==="Enter"&&(re.preventDefault(),Mt.current&&clearTimeout(Mt.current),ae(St))},lt=()=>{if(!Xe.trim()){alert("Please enter a filter name");return}const re={id:Date.now(),name:Xe,filters:{dateFilterBy:P,dateStart:J,dateEnd:ye,sortBy:M,filterItemId:ce,filterItemGroup:ee,filterCompany:W,filterItemName:oe}},Ee=[...ke,re];Me(Ee),gt(""),Ne(!1),localStorage.setItem("itemFilterPresets",JSON.stringify(Ee))},aa=re=>{const Ee=re.filters;U(Ee.dateFilterBy||""),ne(Ee.dateStart||""),he(Ee.dateEnd||""),B(Ee.sortBy||"creation desc"),se(Ee.filterItemId||""),te(Ee.filterItemGroup||""),I(Ee.filterCompany||""),ae(Ee.filterItemName||""),Ht(Ee.filterItemName||"")},Ie=re=>{const Ee=ke.filter(Ge=>Ge.id!==re);Me(Ee),localStorage.setItem("itemFilterPresets",JSON.stringify(Ee))};y.useEffect(()=>()=>{Mt.current&&clearTimeout(Mt.current)},[]);const Nt=()=>{U(""),ne(""),he(""),B("creation desc"),se(""),te(""),I(""),ae(""),Ht(""),Mt.current&&clearTimeout(Mt.current),s(re=>{const Ee=new URLSearchParams(re);return Ee.delete("date_filter_by"),Ee.delete("date_start"),Ee.delete("date_end"),Ee.delete("sort_by"),Ee.delete("item_id"),Ee.delete("item_group"),Ee.delete("company"),Ee.delete("item_name"),Ee.set("page","1"),Ee})},ve=Te||ce||ee||W||oe,Oe=re=>{switch(re){case"Delete Request With Supervisor":return"bg-orange-50 dark:bg-orange-900/10";case"Delete Request With CM":return"bg-yellow-50 dark:bg-yellow-900/10";case"Deleted":return"bg-red-50 dark:bg-red-900/10";default:return""}},ht=re=>re?new Date(re).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"-",et=re=>{N(Ee=>{const Ge=new Set(Ee);return Ge.has(re)?Ge.delete(re):Ge.add(re),Ge})},Be=()=>{_.size===Wt.length?N(new Set):N(new Set(Wt.map(re=>re.name)))},kt=Wt.length>0&&_.size===Wt.length,it=_.size>0&&_.size<Wt.length,xt=y.useCallback(()=>Q(null,null,function*(){const re=[];let Ee=0;const Ge=100;let ct=!0;const It=Ks(Qt);for(;ct;)try{const V=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Item",filters:It.length>0?It:{},fields:["*"],limit_start:Ee*Ge,limit_page_length:Ge,order_by:"creation desc"})})).json()).message||[];re.push(...V),V.length<Ge?ct=!1:Ee++,Ee>100&&(console.warn("Export safety limit reached"),ct=!1)}catch(st){throw console.error("Error fetching items for export:",st),st}return re}),[Qt]),Dt=(re,Ee,Ge)=>Q(null,null,function*(){T(!0);try{let ct=[];switch(re){case"selected":ct=Wt.filter(st=>_.has(st.name));break;case"all_on_page":ct=Wt;break;case"all_with_filters":ct=yield xt();break}if(ct.length===0){alert(t("assets.noDataToExport"));return}const It=Ge.map(st=>{const rt=p.find(V=>V.key===st);return(rt==null?void 0:rt.label)||st});if(Ee==="csv"){const st=[It.join(","),...ct.map(de=>Ge.map(ie=>{let xe=de[ie]||"";return typeof xe=="string"&&(xe.includes(",")||xe.includes('"')||xe.includes(`
`))&&(xe=`"${xe.replace(/"/g,'""')}"`),xe}).join(","))].join(`
`),rt=new Blob(["\uFEFF"+st],{type:"text/csv;charset=utf-8;"}),V=URL.createObjectURL(rt),me=document.createElement("a");me.href=V,me.download=`items_export_${new Date().toISOString().split("T")[0]}.csv`,me.click(),URL.revokeObjectURL(V)}else if(Ee==="excel"){const st=[It,...ct.map(me=>Ge.map(de=>me[de]||""))],rt=Ja.aoa_to_sheet(st),V=Ja.book_new();Ja.book_append_sheet(V,rt,"Items"),$i(V,`items_export_${new Date().toISOString().split("T")[0]}.xlsx`)}C(!1),N(new Set)}catch(ct){console.error("Export failed:",ct),alert(`Export failed: ${ct instanceof Error?ct.message:"Unknown error"}`)}finally{T(!1)}}),Ot=()=>{a("/inventory/new")},Rt=re=>{a(`/inventory/${encodeURIComponent(re)}`)},De=re=>{a(`/inventory/${encodeURIComponent(re)}`)},Qe=re=>Q(null,null,function*(){try{yield Ye(re),h(null),ra(),alert("Item deleted successfully!")}catch(Ee){alert(`Failed to delete: ${Ee instanceof Error?Ee.message:"Unknown error"}`)}}),fe=re=>{a(`/inventory/new?duplicate=${encodeURIComponent(re)}`)};return ta&&!b?e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("items.loadingItems")})]})}):sa?e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:t("items.errorLoadingItems")}),e.jsxs("div",{className:"text-red-700 dark:text-red-400 space-y-3",children:[e.jsx("p",{children:e.jsx("strong",{children:t("items.failedToLoadItems")})}),e.jsxs("div",{className:"mt-4 flex gap-3",children:[e.jsx("button",{onClick:()=>a("/inventory/new"),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:t("items.addItem")}),e.jsx("button",{onClick:ra,className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded",children:t("common.tryAgain")})]})]}),e.jsx("div",{className:"mt-4 p-4 bg-white dark:bg-gray-800 rounded border border-red-300 dark:border-red-700",children:e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("strong",{children:"Technical Error:"})," ",sa]})})]})}):e.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-800 dark:text-white",children:t("items.listTitle")}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:[t("items.listTotal",{count:Vt}),_.size>0&&e.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",_.size," ",t("common.selected")]}),ta&&b&&e.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[e.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-blue-500"}),t("common.updating")]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:()=>C(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",disabled:Vt===0,children:[e.jsx(Os,{}),e.jsx("span",{className:"font-medium",children:t("listPages.export")}),_.size>0&&e.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:_.size})]}),e.jsxs("button",{onClick:Ot,className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg flex items-center gap-2 shadow-lg transition-all hover:shadow-xl",children:[e.jsx(Zs,{}),e.jsx("span",{className:"font-medium",children:t("items.listAddItem")})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[e.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 dark:from-blue-600 dark:to-blue-700 px-4 py-3 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[e.jsx("button",{onClick:()=>K(!X),className:"text-white hover:bg-white/20 p-2 rounded-lg transition-all",children:X?e.jsx(As,{size:14}):e.jsx(cs,{size:14})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ds,{className:"text-white",size:16}),e.jsx("h3",{className:"text-white font-semibold text-sm",children:t("listPages.filters")})]}),we>0&&e.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:we})]}),ve&&e.jsx("div",{className:"flex-1 overflow-x-auto scrollbar-hide mx-2",children:e.jsxs("div",{className:"flex items-center gap-2 py-1",children:[Te&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("filters.filterBy"),":"]})," ",t(P==="creation"?"filters.createdDate":"filters.latestModifiedDate")," ",J&&` ${J}`," ",ye&&` - ${ye}`,e.jsx("button",{onClick:re=>{re.stopPropagation(),U(""),ne(""),he("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),ce&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-blue-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsx("span",{className:"font-semibold",children:"Item ID:"})," ",ce,e.jsx("button",{onClick:re=>{re.stopPropagation(),se("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),oe&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-cyan-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsx("span",{className:"font-semibold",children:"Name:"})," ",oe,e.jsx("button",{onClick:re=>{re.stopPropagation(),ae(""),Ht("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),W&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-green-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsx("span",{className:"font-semibold",children:"Hospital:"})," ",W,e.jsx("button",{onClick:re=>{re.stopPropagation(),I("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]}),ee&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-purple-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsx("span",{className:"font-semibold",children:"Item Group:"})," ",ee,e.jsx("button",{onClick:re=>{re.stopPropagation(),te("")},className:"hover:text-red-500 transition-colors",children:e.jsx(wt,{className:"text-[9px]"})})]})]})}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[we>0&&e.jsxs("button",{onClick:()=>Ne(!0),className:"px-3 py-1.5 bg-white text-blue-600 hover:bg-blue-50 rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[e.jsx(Or,{size:12}),e.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),ve&&e.jsxs("button",{onClick:Nt,className:"px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[e.jsx(wt,{size:12}),e.jsx("span",{className:"hidden sm:inline",children:t("listPages.clear")})]})]})]})}),X&&e.jsxs("div",{className:"p-4",children:[ke.length>0&&e.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[e.jsx(Tc,{className:"text-yellow-500",size:12}),t("listPages.savedFilters")]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ke.map(re=>e.jsxs("div",{className:"group relative inline-flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-purple-100 to-blue-100 dark:from-purple-900/30 dark:to-blue-900/30 border border-purple-200 dark:border-purple-700 rounded-lg hover:shadow-md transition-all",children:[e.jsx("button",{onClick:()=>aa(re),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:re.name}),e.jsx("button",{onClick:()=>Ie(re.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:e.jsx(Na,{size:10})})]},re.id))})]}),e.jsx("div",{className:"space-y-5",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.sortBy")}),e.jsxs("select",{value:M,onChange:re=>B(re.target.value),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"creation desc",children:t("filters.sortCreationNewest")}),e.jsx("option",{value:"creation asc",children:t("filters.sortCreationOldest")}),e.jsx("option",{value:"modified desc",children:t("filters.sortModifiedNewest")}),e.jsx("option",{value:"modified asc",children:t("filters.sortModifiedOldest")}),e.jsx("option",{value:"item_name asc",children:t("filters.sortItemNameAsc")}),e.jsx("option",{value:"item_name desc",children:t("filters.sortItemNameDesc")}),e.jsx("option",{value:"name asc",children:t("filters.sortNameAsc")}),e.jsx("option",{value:"name desc",children:t("filters.sortNameDesc")})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.filterBy")}),e.jsxs("select",{value:P,onChange:re=>{const Ee=re.target.value;U(Ee)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("filters.filterBy")}),e.jsx("option",{value:"creation",children:t("filters.createdDate")}),e.jsx("option",{value:"modified",children:t("filters.latestModifiedDate")})]})]}),P&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.startDate")}),e.jsx("input",{type:"date",value:J,onChange:re=>{const Ee=re.target.value;ne(Ee),ye&&Ee>ye&&he(Ee)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.endDate")}),e.jsx("input",{type:"date",value:ye,onChange:re=>he(re.target.value),min:J||void 0,className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),e.jsxs("div",{className:"relative z-[60]",children:[e.jsx(Ut,{label:t("items.itemId"),doctype:"Item",value:ce,onChange:re=>se(re),placeholder:t("linkField.selectLabel",{label:t("items.itemId")}),disabled:!1,compact:!0,filters:{custom_delete_status:["!=","Deleted"]}}),ce&&e.jsx("button",{onClick:()=>se(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("items.itemName")}),e.jsx("input",{type:"text",value:St,onChange:re=>na(re.target.value),onKeyDown:Ze,placeholder:t("common.typeToSearch"),className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),St&&St!==oe&&e.jsx("span",{className:"absolute right-2 top-6 text-[9px] text-blue-500 animate-pulse",children:t("common.typing")}),oe&&e.jsx("button",{onClick:()=>{ae(""),Ht("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[59]",children:[e.jsx(Ut,{label:t("items.selectHospital"),doctype:"Company",value:W,onChange:re=>I(re),placeholder:t("linkField.selectLabel",{label:t("items.selectHospital")}),disabled:!1,compact:!0,filters:{domain:"Healthcare"}}),W&&e.jsx("button",{onClick:()=>I(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[58]",children:[e.jsx(Ut,{label:t("items.itemGroup"),doctype:"Item Group",value:ee,onChange:re=>te(re),placeholder:t("linkField.selectLabel",{label:t("items.itemGroup")}),disabled:!1,compact:!0}),ee&&e.jsx("button",{onClick:()=>te(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]})]})})})]})]}),z&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:t("common.saveFilterPreset")}),e.jsx("input",{type:"text",value:Xe,onChange:re=>gt(re.target.value),onKeyDown:re=>{re.key==="Enter"&&(re.preventDefault(),lt())},placeholder:t("common.enterFilterNameExample"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white mb-4",autoFocus:!0}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>{Ne(!1),gt("")},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",children:t("common.cancel")}),e.jsxs("button",{onClick:lt,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors flex items-center gap-2",children:[e.jsx(Or,{size:12}),t("common.saveFilter")]})]})]})}),e.jsx(oR,{isOpen:k,onClose:()=>C(!1),selectedCount:_.size,totalCount:Vt,pageCount:Wt.length,onExport:Dt,isExporting:D,exportColumns:p}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden relative",children:[ta&&b&&e.jsx("div",{className:"absolute inset-0 bg-white/60 dark:bg-gray-800/60 flex items-center justify-center z-10 backdrop-blur-[1px]",children:e.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[e.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-blue-500"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:t("common.filtering")})]})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left",children:e.jsx("button",{onClick:Be,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:kt?"Deselect all":"Select all",children:kt?e.jsx(Es,{className:"text-blue-600 dark:text-blue-400",size:18}):it?e.jsxs("div",{className:"relative",children:[e.jsx(Ar,{size:18}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):e.jsx(Ar,{size:18})})}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("items.itemCode")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("items.itemName")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("items.itemGroup")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("items.selectHospital")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("items.serialNo")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("items.dateIn")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("commonFields.modifiedOn")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("listPages.actions")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:Wt.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:13,className:"px-6 py-12 text-center text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(U5,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),e.jsx("p",{children:t("items.noItemsFound")}),ve?e.jsx("button",{onClick:Nt,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:t("common.clearFilters")}):e.jsx("button",{onClick:Ot,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:t("items.createFirstItem")})]})})}):Wt.map(re=>{var Ee;return e.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors cursor-pointer ${_.has(re.name)?"bg-blue-50 dark:bg-blue-900/20":Oe(re.custom_delete_status)}`,title:re.custom_delete_status?`Delete Status: ${re.custom_delete_status}`:void 0,onClick:()=>Rt(re.name),children:[e.jsx("td",{className:"px-4 py-4",onClick:Ge=>Ge.stopPropagation(),children:e.jsx("button",{onClick:()=>et(re.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:_.has(re.name)?e.jsx(Es,{className:"text-blue-600 dark:text-blue-400",size:18}):e.jsx(Ar,{size:18})})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:re.item_code||re.name})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:re.item_name||"-"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:re.item_group||"-"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:re.custom_hospital_name||"-"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:re.custom_serial_no||"-"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:re.custom_date_in?ht(re.custom_date_in):"-"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:ht(re.modified)})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:e.jsxs("div",{className:"flex items-center gap-1",onClick:Ge=>Ge.stopPropagation(),children:[e.jsx("button",{onClick:()=>Rt(re.name),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:"View Details",children:e.jsx(ri,{})}),e.jsx("button",{onClick:()=>De(re.name),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:"Edit Item",children:e.jsx(Fr,{})}),e.jsx("button",{onClick:()=>fe(re.name),className:"text-purple-600 dark:text-purple-400 hover:text-purple-900 dark:hover:text-purple-300 p-2 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded transition-colors",title:"Duplicate Item",children:e.jsx(Wd,{})}),e.jsx("div",{onClick:Ge=>Ge.stopPropagation(),children:e.jsx(Ll,{doctype:"Item",docname:re.name,currentDeleteStatus:(Ee=re.custom_delete_status)!=null?Ee:null,userRoles:E,isSystemManager:R,triggerMode:!0,redirectOnDelete:"/inventory",onStatusChange:()=>ra()})})]})})]},re.name)})})]})}),e.jsx(Rc,{currentPage:c+1,totalCount:Vt,pageSize:g,hasMore:va,itemLabel:t("pagination.items"),onPageChange:re=>d(Math.max(0,re-1))})]}),m&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:e.jsx(Na,{className:"text-red-600 dark:text-red-400 text-xl"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:t("items.deleteItem")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:t("items.deleteConfirmMessage")}),e.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-md p-3 mb-4",children:e.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[e.jsxs("strong",{children:[t("items.itemId"),":"]})," ",m]})}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>h(null),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-lg transition-colors",disabled:ft,children:t("common.cancel")}),e.jsx("button",{onClick:()=>Qe(m),className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50",disabled:ft,children:ft?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),t("common.deleting")]}):e.jsxs(e.Fragment,{children:[e.jsx(Na,{}),t("items.deleteItem")]})})]})]})]})})}),e.jsx("style",{children:`
@keyframes scale-in {
from {
transform: scale(0.95);
opacity: 0;
}
to {
transform: scale(1);
opacity: 1;
}
}
.animate-scale-in {
animation: scale-in 0.2s ease-out;
}
.scrollbar-hide {
-ms-overflow-style: none;
scrollbar-width: none;
}
.scrollbar-hide::-webkit-scrollbar {
display: none;
}
`})]})},cR=()=>{var be,ke,Me,z;const{t}=ca(),{itemName:a}=xo(),r=qa(),s=zi(),[i]=Qs(),c=i.get("duplicate"),d=y.useMemo(()=>{if(a==="new")return"new";const Ne="/inventory/",Xe=window.location.pathname,gt=Xe.indexOf(Ne);if(gt!==-1){const St=Xe.slice(gt+Ne.length);try{return decodeURIComponent(St)}catch(Ht){return St}}return a||""},[a,s.pathname]),m=d==="new",h=m&&!!c,[g,p]=y.useState(0),[b,j]=y.useState(!1),[_,N]=y.useState([]),[k,C]=y.useState(!1),[D,T]=y.useState(!1);y.useEffect(()=>{Q(null,null,function*(){try{const Xe=yield mt.apiCall("/api/method/asset_lite.api.user_roles.get_user_roles"),gt=Array.isArray(Xe)?Xe:(Xe==null?void 0:Xe.message)||[];N(gt),C(gt.includes("System Manager"))}catch(Xe){console.error("Error fetching roles:",Xe)}finally{T(!0)}})},[]);const[E,O]=y.useState({item_code:"",item_name:"",item_group:"",custom_technical_department:"",custom_hospital_name:"",custom_part_description:"",stock_uom:"Nos",custom_item_cost_per_unit:0,disabled:0,is_stock_item:1,is_fixed_asset:0,opening_stock:0,valuation_rate:0,standard_rate:0,custom_last_calibration_date:"",custom_next_due_calibration_date:"",description:"",brand:"",custom_warranty_in_months:"",valuation_method:"",has_batch_no:0,has_serial_no:0,custom_serial_no:"",custom_date_in:"",custom_code:"",custom_type:"",custom_volts:void 0,custom_w:void 0,is_purchase_item:1,is_sales_item:1,country_of_origin:"Saudi Arabia"}),{item:R,loading:Y,error:P,refetch:U}=iR(h?c:m?null:d||null),{createItem:J,updateItem:ne,loading:ye}=uj(),[he,ce]=y.useState(m),se=(be=R==null?void 0:R.docstatus)!=null?be:0,ee=se===1,te=se===2,W=se===0,I=!!(R!=null&&R.custom_delete_status),oe=E.item_group==="Tools",ae=y.useCallback(Ne=>Q(null,null,function*(){var Xe;if(Ne){j(!0);try{let gt=null;typeof window!="undefined"&&window.csrf_token&&(gt=window.csrf_token);const St=JSON.stringify([["item_code","=",Ne]]),Ht=JSON.stringify(["actual_qty","warehouse"]),Mt=`${ia.BASE_URL}/api/resource/Bin?filters=${encodeURIComponent(St)}&fields=${encodeURIComponent(Ht)}&limit_page_length=0`,Te={Accept:"application/json","Content-Type":"application/json"};gt&&(Te["X-Frappe-CSRF-Token"]=gt);const Qt=yield fetch(Mt,{method:"GET",headers:Te,credentials:"include"});if(!Qt.ok)throw new Error(`HTTP error! status: ${Qt.status}`);const Wt=((Xe=(yield Qt.json()).data)==null?void 0:Xe.reduce((Vt,va)=>Vt+(va.actual_qty||0),0))||0;p(Wt)}catch(gt){console.error("Failed to fetch balance qty:",gt),p(0)}finally{j(!1)}}}),[]);y.useEffect(()=>{!m&&(R!=null&&R.item_code)&&ae(R.item_code)},[m,R==null?void 0:R.item_code,ae]),y.useEffect(()=>{var Ne,Xe,gt,St,Ht,Mt,Te,Qt,zt,Wt;R&&!h?(O({item_code:R.item_code||"",item_name:R.item_name||"",item_group:R.item_group||"",custom_technical_department:R.custom_technical_department||"",custom_hospital_name:R.custom_hospital_name||"",custom_part_description:R.custom_part_description||"",stock_uom:R.stock_uom||"Nos",custom_item_cost_per_unit:R.custom_item_cost_per_unit||0,disabled:R.disabled||0,is_stock_item:(Ne=R.is_stock_item)!=null?Ne:1,is_fixed_asset:(Xe=R.is_fixed_asset)!=null?Xe:0,opening_stock:R.opening_stock||0,valuation_rate:(gt=R.valuation_rate)!=null?gt:0,standard_rate:R.standard_rate||0,custom_last_calibration_date:R.custom_last_calibration_date||"",custom_next_due_calibration_date:R.custom_next_due_calibration_date||"",description:R.description||"",brand:R.brand||"",custom_warranty_in_months:R.custom_warranty_in_months||"",valuation_method:R.valuation_method||"",has_batch_no:R.has_batch_no||0,has_serial_no:R.has_serial_no||0,is_purchase_item:(St=R.is_purchase_item)!=null?St:1,is_sales_item:(Ht=R.is_sales_item)!=null?Ht:1,country_of_origin:R.country_of_origin||"Saudi Arabia",uoms:R.uoms||[],item_defaults:R.item_defaults||[],custom_serial_no:R.custom_serial_no||"",custom_date_in:R.custom_date_in||"",custom_code:R.custom_code||"",custom_type:R.custom_type||"",custom_volts:R.custom_volts,custom_w:R.custom_w}),ce(!1)):h&&R&&O({item_code:"",item_name:R.item_name||"",item_group:R.item_group||"",custom_technical_department:R.custom_technical_department||"",custom_hospital_name:R.custom_hospital_name||"",custom_part_description:R.custom_part_description||"",stock_uom:R.stock_uom||"Nos",custom_item_cost_per_unit:R.custom_item_cost_per_unit||0,disabled:0,is_stock_item:(Mt=R.is_stock_item)!=null?Mt:1,is_fixed_asset:(Te=R.is_fixed_asset)!=null?Te:0,opening_stock:R.opening_stock||0,valuation_rate:(Qt=R.valuation_rate)!=null?Qt:0,standard_rate:R.standard_rate||0,custom_last_calibration_date:R.custom_last_calibration_date||"",custom_next_due_calibration_date:R.custom_next_due_calibration_date||"",description:R.description||"",brand:R.brand||"",custom_warranty_in_months:R.custom_warranty_in_months||"",valuation_method:R.valuation_method||"",has_batch_no:R.has_batch_no||0,has_serial_no:R.has_serial_no||0,is_purchase_item:(zt=R.is_purchase_item)!=null?zt:1,is_sales_item:(Wt=R.is_sales_item)!=null?Wt:1,country_of_origin:R.country_of_origin||"Saudi Arabia",uoms:R.uoms||[],item_defaults:R.item_defaults||[],custom_serial_no:R.custom_serial_no||"",custom_date_in:R.custom_date_in||"",custom_code:R.custom_code||"",custom_type:R.custom_type||"",custom_volts:R.custom_volts,custom_w:R.custom_w})},[R,h]);const F=()=>Q(null,null,function*(){try{if(m){const Ne=yield J(E);r(`/inventory/${Ne.name}`)}else yield ne(d,E),yield U(),E.item_code&&ae(E.item_code),ce(!1),alert(t("items.itemUpdatedSuccessfully"))}catch(Ne){alert(`${t("items.failedToSave")}: ${Ne instanceof Error?Ne.message:"Unknown error"}`)}}),M=y.useCallback(Ne=>!!(!he||te||I||ee),[he,te,ee,I]);if(Y)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("items.loadingItem")})]})});if(P&&!m)return e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:t("items.errorLoadingItem")}),e.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:P}),e.jsx("button",{onClick:()=>r(-1),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:t("items.backToInventory")})]})});const B="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 dark:disabled:bg-gray-700 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",X="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",K="text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",we="bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700";return e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("button",{onClick:()=>r(-1),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[e.jsx(en,{}),e.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:m?t("items.newItem"):(R==null?void 0:R.item_name)||(R==null?void 0:R.item_code)||t("items.title")})]}),!m&&e.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300",children:(R==null?void 0:R.item_code)||d})]}),e.jsxs("div",{className:"flex gap-3",children:[!m&&!he&&W&&!I&&e.jsxs("button",{onClick:()=>ce(!0),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[e.jsx(Fr,{}),t("common.edit")]}),he&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>{m?r(-1):(ce(!1),U())},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg",children:t("common.cancel")}),e.jsxs("button",{type:"button",onClick:F,disabled:ye,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[e.jsx(Or,{}),t(ye?"common.saving":"common.save")]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:we,children:[e.jsx("h2",{className:K,children:t("items.basicInformation")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:X,children:[t("items.itemCode")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:E.item_code,onChange:Ne=>O(Se(ue({},E),{item_code:Ne.target.value})),disabled:M("item_code")||!m,className:B,required:!0})]}),e.jsx(Ut,{label:t("commonFields.hospital"),doctype:"Company",value:E.custom_hospital_name||"",onChange:Ne=>O(Se(ue({},E),{custom_hospital_name:Ne})),disabled:M("custom_hospital_name"),placeholder:t("items.selectHospital"),filters:{domain:"Healthcare"}}),e.jsx(Ut,{label:t("items.itemGroup"),doctype:"Item Group",value:E.item_group||"",onChange:Ne=>O(Se(ue({},E),{item_group:Ne})),disabled:M("item_group"),placeholder:t("items.selectItemGroup")}),e.jsx(Ut,{label:t("items.technicalDepartment"),doctype:"Issue Type",value:E.custom_technical_department||"",onChange:Ne=>O(Se(ue({},E),{custom_technical_department:Ne})),disabled:M("custom_technical_department"),placeholder:t("items.selectTechnicalDepartment")}),e.jsxs("div",{children:[e.jsx("label",{className:X,children:t("items.stockUOM")}),e.jsx("input",{type:"text",value:E.stock_uom,onChange:Ne=>O(Se(ue({},E),{stock_uom:Ne.target.value})),disabled:M("stock_uom"),className:B})]}),e.jsxs("div",{children:[e.jsx("label",{className:X,children:t("items.partDescription")}),e.jsx("input",{type:"text",value:E.custom_part_description,onChange:Ne=>O(Se(ue({},E),{custom_part_description:Ne.target.value})),disabled:M("custom_part_description"),className:B})]})]})]}),e.jsxs("div",{className:we,children:[e.jsx("h2",{className:K,children:t("items.inventoryDetails")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:X,children:t("items.serialNo")}),e.jsx("input",{type:"text",value:E.custom_serial_no,onChange:Ne=>O(Se(ue({},E),{custom_serial_no:Ne.target.value})),disabled:M("custom_serial_no"),className:B})]}),e.jsxs("div",{children:[e.jsx("label",{className:X,children:t("items.dateIn")}),e.jsx("input",{type:"date",value:E.custom_date_in,onChange:Ne=>O(Se(ue({},E),{custom_date_in:Ne.target.value})),disabled:M("custom_date_in"),className:B})]}),e.jsxs("div",{children:[e.jsx("label",{className:X,children:t("items.watts")}),e.jsx("input",{type:"number",step:"0.01",value:(ke=E.custom_w)!=null?ke:"",onChange:Ne=>{const Xe=parseFloat(Ne.target.value);O(Se(ue({},E),{custom_w:Ne.target.value===""||isNaN(Xe)?void 0:Xe}))},disabled:M("custom_w"),className:B})]}),e.jsxs("div",{children:[e.jsx("label",{className:X,children:t("items.volts")}),e.jsx("input",{type:"number",step:"0.01",value:(Me=E.custom_volts)!=null?Me:"",onChange:Ne=>{const Xe=parseFloat(Ne.target.value);O(Se(ue({},E),{custom_volts:Ne.target.value===""||isNaN(Xe)?void 0:Xe}))},disabled:M("custom_volts"),className:B})]}),e.jsxs("div",{children:[e.jsx("label",{className:X,children:t("items.type")}),e.jsx("input",{type:"text",value:E.custom_type,onChange:Ne=>O(Se(ue({},E),{custom_type:Ne.target.value})),disabled:M("custom_type"),className:B})]}),e.jsxs("div",{children:[e.jsx("label",{className:X,children:t("items.code")}),e.jsx("input",{type:"text",value:E.custom_code,onChange:Ne=>O(Se(ue({},E),{custom_code:Ne.target.value})),disabled:M("custom_code"),className:B})]})]})]}),e.jsxs("div",{className:we,children:[e.jsx("h2",{className:K,children:t("items.stockInformation")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"is_stock_item",checked:E.is_stock_item===1,onChange:Ne=>O(Se(ue({},E),{is_stock_item:Ne.target.checked?1:0})),disabled:M("is_stock_item"),className:"w-4 h-4"}),e.jsx("label",{htmlFor:"is_stock_item",className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:t("items.isStockItem")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"is_fixed_asset",checked:E.is_fixed_asset===1,onChange:Ne=>O(Se(ue({},E),{is_fixed_asset:Ne.target.checked?1:0})),disabled:M("is_fixed_asset"),className:"w-4 h-4"}),e.jsx("label",{htmlFor:"is_fixed_asset",className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:t("items.isFixedAsset")})]}),m&&E.is_stock_item===1&&e.jsxs("div",{children:[e.jsx("label",{className:X,children:t("items.openingStock")}),e.jsx("input",{type:"number",value:E.opening_stock,onChange:Ne=>O(Se(ue({},E),{opening_stock:parseFloat(Ne.target.value)||0})),disabled:M("opening_stock"),className:B})]}),E.is_stock_item===1&&e.jsxs("div",{children:[e.jsx("label",{className:X,children:t("items.valuationRate")}),e.jsx("input",{type:"number",step:"0.01",value:E.valuation_rate,onChange:Ne=>O(Se(ue({},E),{valuation_rate:parseFloat(Ne.target.value)||0})),disabled:M("valuation_rate"),className:B})]}),!m&&E.is_stock_item===1&&e.jsxs("div",{children:[e.jsx("label",{className:X,children:t("items.balanceQty")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",value:g,readOnly:!0,className:`${B} bg-gray-100 dark:bg-gray-800 cursor-not-allowed`}),e.jsx("button",{type:"button",onClick:()=>E.item_code&&ae(E.item_code),disabled:b,className:"p-2 text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 disabled:opacity-50",title:t("items.refreshBalanceQty"),children:e.jsx(vn,{className:b?"animate-spin":""})})]})]})]}),oe&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:`${K} mt-6`,children:t("items.calibrationInformation")}),e.jsxs("div",{className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:X,children:t("items.lastCalibrationDate")}),e.jsx("input",{type:"date",value:E.custom_last_calibration_date,onChange:Ne=>O(Se(ue({},E),{custom_last_calibration_date:Ne.target.value})),disabled:M("custom_last_calibration_date"),className:B})]}),e.jsxs("div",{children:[e.jsx("label",{className:X,children:t("items.nextCalibrationDate")}),e.jsx("input",{type:"date",value:E.custom_next_due_calibration_date,onChange:Ne=>O(Se(ue({},E),{custom_next_due_calibration_date:Ne.target.value})),disabled:M("custom_next_due_calibration_date"),className:B})]})]})]}),e.jsx("h2",{className:`${K} mt-6`,children:t("items.additionalInformation")}),e.jsxs("div",{className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:X,children:t("commonFields.description")}),e.jsx("textarea",{value:E.description,onChange:Ne=>O(Se(ue({},E),{description:Ne.target.value})),disabled:M("description"),rows:3,className:B})]}),e.jsxs("div",{children:[e.jsx("label",{className:X,children:t("items.warrantyMonths")}),e.jsx("input",{type:"text",value:E.custom_warranty_in_months,onChange:Ne=>O(Se(ue({},E),{custom_warranty_in_months:Ne.target.value})),disabled:M("custom_warranty_in_months"),className:B})]})]})]})," ",!m&&e.jsx("div",{className:"mt-6",children:e.jsx(Pc,{referenceDoctype:"Item",referenceName:d||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5,collapsible:!0,startCollapsed:!1})}),!m&&!h&&e.jsx("div",{className:"mt-6",children:e.jsx(tj,{doctype:"Item",docname:d||null,creationDate:R==null?void 0:R.creation,createdBy:R==null?void 0:R.owner,compact:!1,initialVisible:5,collapsible:!0,startCollapsed:!0})}),!m&&D&&e.jsx("div",{className:"mt-6 max-w-sm",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Delete Request"}),e.jsx(Ll,{doctype:"Item",docname:d,currentDeleteStatus:(z=R==null?void 0:R.custom_delete_status)!=null?z:null,userRoles:_,isSystemManager:k,redirectOnDelete:"/inventory",onStatusChange:()=>U()})]})})]})," "]})};const dR=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),uR=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,r,s)=>s?s.toUpperCase():r.toLowerCase()),I_=t=>{const a=uR(t);return a.charAt(0).toUpperCase()+a.slice(1)},mj=(...t)=>t.filter((a,r,s)=>!!a&&a.trim()!==""&&s.indexOf(a)===r).join(" ").trim(),mR=t=>{for(const a in t)if(a.startsWith("aria-")||a==="role"||a==="title")return!0};var hR={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const gR=y.forwardRef((g,h)=>{var p=g,{color:t="currentColor",size:a=24,strokeWidth:r=2,absoluteStrokeWidth:s,className:i="",children:c,iconNode:d}=p,m=Dn(p,["color","size","strokeWidth","absoluteStrokeWidth","className","children","iconNode"]);return y.createElement("svg",ue(ue(Se(ue({ref:h},hR),{width:a,height:a,stroke:t,strokeWidth:s?Number(r)*24/Number(a):r,className:mj("lucide",i)}),!c&&!mR(m)&&{"aria-hidden":"true"}),m),[...d.map(([b,j])=>y.createElement(b,j)),...Array.isArray(c)?c:[c]])});const ms=(t,a)=>{const r=y.forwardRef((d,c)=>{var m=d,{className:s}=m,i=Dn(m,["className"]);return y.createElement(gR,ue({ref:c,iconNode:a,className:mj(`lucide-${dR(I_(t))}`,`lucide-${t}`,s)},i))});return r.displayName=I_(t),r};const fR=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],xR=ms("bell",fR);const pR=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],yR=ms("box",pR);const bR=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m9 16 2 2 4-4",key:"19s6y9"}]],vR=ms("calendar-check",bR);const _R=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],wR=ms("calendar",_R);const kR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],jR=ms("circle-question-mark",kR);const NR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]],z_=ms("circle-user",NR);const SR=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]],CR=ms("clipboard-list",SR);const TR=[["rect",{x:"2",y:"6",width:"20",height:"8",rx:"1",key:"1estib"}],["path",{d:"M17 14v7",key:"7m2elx"}],["path",{d:"M7 14v7",key:"1cm7wv"}],["path",{d:"M17 3v3",key:"1v4jwn"}],["path",{d:"M7 3v3",key:"7o6guu"}],["path",{d:"M10 14 2.3 6.3",key:"1023jk"}],["path",{d:"m14 6 7.7 7.7",key:"1s8pl2"}],["path",{d:"m8 6 8 8",key:"hl96qh"}]],ER=ms("construction",TR);const AR=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],OR=ms("file-text",AR);const DR=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],MR=ms("languages",DR);const LR=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],RR=ms("layout-dashboard",LR);const PR=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],FR=ms("log-out",PR);const IR=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],zR=ms("map",IR);const BR=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],UR=ms("menu",BR);const $R=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],HR=ms("moon",$R);const WR=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],VR=ms("package",WR);const qR=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],GR=ms("shopping-cart",qR);const YR=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],ZR=ms("sun",YR);const JR=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],XR=ms("users",JR);const KR=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],QR=ms("x",KR),eP=({title:t="Coming Soon"})=>e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-gray-50 dark:bg-gray-900 p-4",children:e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx("div",{className:"mb-6 flex justify-center",children:e.jsx("div",{className:"bg-blue-100 dark:bg-blue-900/30 p-6 rounded-full",children:e.jsx(ER,{size:64,className:"text-blue-600 dark:text-blue-400"})})}),e.jsx("h1",{className:"text-4xl font-bold text-gray-900 dark:text-white mb-4",children:t}),e.jsx("p",{className:"text-lg text-gray-600 dark:text-gray-400 mb-8",children:"Access Currently Denied"})]})}),tP=["System Manager","Contractor Supervisor","Contractor Manager","Work Control","Contractor Engineer"],aP="Technician",rP="End User",sP=({userEmail:t})=>{const[a,r]=y.useState(!1),s=zi(),i=qa(),{isRTL:c}=Yx(),{t:d}=ca(),[m,h]=y.useState({isAdmin:!1,isTechnician:!1,isEndUser:!1,isLoading:!0}),[g,p]=y.useState(""),b="/assets/asm_ui_app/asm_app/",j="?v=1774269853",_="?v=1774269853",N=b.endsWith("/")?`${b}sidebar-background.jpg${j}`:`${b}/sidebar-background.jpg${j}`;y.useEffect(()=>{Q(null,null,function*(){var R,Y,P;try{const ne=((R=(yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:tP.join(",")})})).json()).message)==null?void 0:R.has_role)||!1,ce=((Y=(yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:aP})})).json()).message)==null?void 0:Y.has_role)||!1,te=((P=(yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:rP})})).json()).message)==null?void 0:P.has_role)||!1;h({isAdmin:ne,isTechnician:ce,isEndUser:te,isLoading:!1}),console.log("User roles:",{isAdmin:ne,isTechnician:ce,isEndUser:te})}catch(U){console.error("Error fetching user roles:",U),h({isAdmin:!1,isTechnician:!1,isEndUser:!0,isLoading:!1})}})},[]),y.useEffect(()=>{Q(null,null,function*(){var R;try{const U=(yield(yield fetch("/api/method/frappe.auth.get_logged_user",{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).message;if(U){const ne=yield(yield fetch(`/api/resource/User/${encodeURIComponent(U)}?fields=["full_name"]`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json();(R=ne.data)!=null&&R.full_name?p(ne.data.full_name):p(U)}}catch(Y){console.error("Error fetching user full name:",Y),t&&p(t)}})},[t]);const k=O=>{const{isAdmin:R,isTechnician:Y,isEndUser:P,isLoading:U}=m;if(U)return!1;if(R)return!0;const J=["work-orders","support","assets","inventory"],ne=["work-orders","inspections","procurement","support","active-map","assets","inventory"];let ye=!1;return P&&J.includes(O)&&(ye=!0),Y&&ne.includes(O)&&(ye=!0),!R&&!Y&&!P&&(ye=J.includes(O)),ye},D=[{id:"dashboard",title:d("common.dashboard"),icon:e.jsx(RR,{size:20}),path:"/dashboard",visible:m.isAdmin},{id:"assets",title:d("common.assets"),icon:e.jsx(VR,{size:20}),path:"/assets",visible:k("assets")},{id:"inventory",title:d("sidebar.inventory"),icon:e.jsx(yR,{size:20}),path:"/inventory",visible:k("inventory")},{id:"work-orders",title:d("common.workOrders"),icon:e.jsx(CR,{size:20}),path:"/work-orders",visible:k("work-orders")},{id:"inspections",title:d("sidebar.inspection"),icon:e.jsx(bi,{size:20}),path:"/inspections",visible:k("inspections")},{id:"ppm-planner",title:d("sidebar.ppmPlanner"),icon:e.jsx(vR,{size:20}),path:"/ppm-planner",visible:m.isAdmin},{id:"maintenance-calendar",title:d("sidebar.maintenanceCalendar"),icon:e.jsx(wR,{size:20}),path:"/maintenance-calendar",visible:m.isAdmin},{id:"active-map",title:d("sidebar.activeMap"),icon:e.jsx(zR,{size:20}),path:"/active-map",visible:k("active-map")},{id:"maintenance-teams",title:d("sidebar.maintenanceTeam"),icon:e.jsx(XR,{size:20}),path:"/maintenance-teams",visible:m.isAdmin},{id:"procurement",title:d("sidebar.procurement"),icon:e.jsx(GR,{size:20}),path:"/procurement",visible:k("procurement")},{id:"sla",title:d("sidebar.sla"),icon:e.jsx(OR,{size:20}),path:"/sla",visible:m.isAdmin},{id:"support",title:d("sidebar.support"),icon:e.jsx(jR,{size:20}),path:"/support",visible:k("support")}].filter(O=>O.visible),T=O=>s.pathname===O,E=()=>{i("/user-profile")};return m.isLoading?e.jsxs("div",{className:`
relative
h-screen
w-64
flex
flex-col
items-center
justify-center
shadow-xl
border-r border-gray-200 dark:border-gray-700
`,style:{backgroundImage:`url(${N})`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat"},children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 dark:bg-black/70 z-0"}),e.jsxs("div",{className:"relative z-10 text-white",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-white mx-auto"}),e.jsx("p",{className:"mt-2 text-sm",children:d("common.loading")})]})]}):e.jsxs("div",{className:`
relative
h-screen
transition-all
duration-300
ease-in-out
flex
flex-col
shadow-xl
border-r border-gray-200 dark:border-gray-700
${a?"w-16":"w-64"}
`,style:{backgroundImage:`url(${N})`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat"},children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 dark:bg-black/70 z-0"}),e.jsxs("div",{className:"relative z-10 flex flex-col h-full bg-white/0 dark:bg-white/0",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200/30 dark:border-gray-700/30",children:[!a&&e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsxs("div",{className:"w-10 h-10 flex items-center justify-center bg-white/20 dark:bg-white/20 rounded-lg p-1 backdrop-blur-sm",children:[e.jsx("img",{src:`${b}${b.endsWith("/")?"":"/"}seera-logo.png${_}`,alt:"SEERA-ASM",className:"w-full h-full object-contain",onError:O=>{var R;O.currentTarget.style.display="none",(R=O.currentTarget.nextElementSibling)==null||R.classList.remove("hidden")}}),e.jsxs("svg",{className:"w-6 h-6 hidden",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"#6366F1",fillOpacity:"0.9"}),e.jsx("path",{d:"M2 17L12 22L22 17V12L12 17L2 12V17Z",fill:"#8B5CF6",fillOpacity:"0.7"}),e.jsx("path",{d:"M12 12V17",stroke:"#A855F7",strokeWidth:"2",strokeLinecap:"round"})]})]}),e.jsx("h1",{className:"text-white dark:text-white text-lg font-semibold drop-shadow-lg",children:d("sidebar.title")})]}),a&&e.jsxs("div",{className:"w-8 h-8 flex items-center justify-center bg-white dark:bg-gray-700 rounded-lg p-1",children:[e.jsx("img",{src:`${b}${b.endsWith("/")?"":"/"}seera-logo.png?v=1765198405${_}`,alt:"SEERA-ASM",className:"w-full h-full object-contain",onError:O=>{var R;O.currentTarget.style.display="none",(R=O.currentTarget.nextElementSibling)==null||R.classList.remove("hidden")}}),e.jsxs("svg",{className:"w-5 h-5 hidden",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"#6366F1",fillOpacity:"0.9"}),e.jsx("path",{d:"M2 17L12 22L22 17V12L12 17L2 12V17Z",fill:"#8B5CF6",fillOpacity:"0.7"}),e.jsx("path",{d:"M12 12V17",stroke:"#A855F7",strokeWidth:"2",strokeLinecap:"round"})]})]}),e.jsx("button",{onClick:()=>r(!a),className:"text-white dark:text-white hover:bg-white/20 dark:hover:bg-white/20 p-2 rounded-lg transition-colors",children:a?e.jsx(UR,{size:20}):e.jsx(QR,{size:20})})]}),e.jsx("nav",{className:"flex-1 overflow-y-auto py-4",children:D.map(O=>e.jsxs(Gx,{to:O.path,className:`
flex
items-center
px-4
py-3
text-white dark:text-white
hover:bg-white/20 dark:hover:bg-white/20
hover:text-white dark:hover:text-white
transition-all
duration-200
${T(O.path)?"bg-white/30 dark:bg-white/30 text-white dark:text-white border-l-4 border-white":""}
${a?"justify-center":""}
`,title:a?O.title:"",children:[e.jsx("span",{children:O.icon}),!a&&e.jsx("span",{className:`${c?"mr-4":"ml-4"} font-medium`,children:O.title})]},O.id))}),e.jsxs("div",{className:`${a?"p-2":"p-4"} border-t border-white/10 backdrop-blur-sm bg-white/5 space-y-3 relative z-10`,children:[!a&&(g||t)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-white/80 dark:text-white/80 text-xs truncate",children:d("sidebar.loggedInAs")}),e.jsx("div",{className:"text-white dark:text-white text-sm font-medium truncate",children:g||t}),e.jsxs("button",{onClick:E,className:`
mt-3 w-full flex items-center justify-center gap-2
px-3 py-2
bg-white/20 hover:bg-white/30
text-white
rounded-lg
transition-all duration-200
text-sm font-medium
${T("/user-profile")?"bg-white/40 border border-white/50":""}
`,children:[e.jsx(z_,{size:18}),e.jsx("span",{children:d("sidebar.userProfile")})]})]}),a&&e.jsx("button",{onClick:E,className:`
w-full flex items-center justify-center
p-2
bg-white/20 hover:bg-white/30
text-white
rounded-lg
transition-all duration-200
${T("/user-profile")?"bg-white/40 border border-white/50":""}
`,title:d("sidebar.userProfile"),children:e.jsx(z_,{size:20})}),!a&&e.jsx("div",{className:"text-xs text-white/70 dark:text-white/70 text-center",children:d("sidebar.version")})]})]})]})},hj=y.createContext(void 0),nP=({children:t})=>{const[a,r]=y.useState(()=>localStorage.getItem("theme")||"light");y.useEffect(()=>{const i=document.documentElement;localStorage.setItem("theme",a),a==="dark"?i.classList.add("dark"):i.classList.remove("dark")},[a]);const s=()=>{r(i=>i==="light"?"dark":"light")};return e.jsx(hj.Provider,{value:{theme:a,toggleTheme:s},children:t})},iP=()=>{const t=y.useContext(hj);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t};class oP{getNotifications(a=50,r=0){return Q(this,null,function*(){var c,d,m,h;const s=localStorage.getItem("user"),i=s?JSON.parse(s).email:"";if(!i)return[];try{const g=JSON.stringify([["for_user","=",i]]),p=JSON.stringify(["name","subject","email_content","document_type","document_name","read","creation","from_user","type"]),b=yield mt.apiCall(`/api/resource/Notification Log?filters=${encodeURIComponent(g)}&fields=${encodeURIComponent(p)}&order_by=creation desc&limit=${a}&offset=${r}`);return console.log("[NotificationService] Fetched notifications:",b==null?void 0:b.data),((c=b==null?void 0:b.data)==null?void 0:c.length)>0&&console.log("[NotificationService] First notification sample:",b.data[0]),(b==null?void 0:b.data)||[]}catch(g){return(d=g==null?void 0:g.message)!=null&&d.includes("417")||(m=g==null?void 0:g.message)!=null&&m.includes("EXPECTATION FAILED")?[]:((h=g==null?void 0:g.message)!=null&&h.includes("417")||console.warn("Notifications API not available:",(g==null?void 0:g.message)||"Unknown error"),[])}})}markAsRead(a){return Q(this,null,function*(){var r,s,i,c;try{return yield mt.apiCall(`/api/resource/Notification Log/${a}`,{method:"PUT",body:JSON.stringify({read:1})})}catch(d){if((r=d==null?void 0:d.message)!=null&&r.includes("417")||(s=d==null?void 0:d.message)!=null&&s.includes("EXPECTATION FAILED")||(i=d==null?void 0:d.message)!=null&&i.includes("PermissionError")||(c=d==null?void 0:d.message)!=null&&c.includes("Insufficient Permission"))return console.warn("[NotificationService] Cannot mark as read (permissions)"),{success:!1,reason:"permission_denied"};throw console.warn("Error marking notification as read:",(d==null?void 0:d.message)||"Unknown error"),d}})}markAllAsRead(){return Q(this,null,function*(){try{const r=(yield this.getNotifications(1e3)).filter(i=>!i.read);let s=0;for(const i of r)try{const c=yield this.markAsRead(i.name);(c==null?void 0:c.success)!==!1&&s++}catch(c){console.error(`Error marking notification ${i.name} as read:`,c)}return{success:!0,marked:s,total:r.length}}catch(a){return console.error("Error marking all notifications as read:",a),{success:!1,marked:0,total:0}}})}getUnreadCount(){return Q(this,null,function*(){try{return(yield this.getNotifications(1e3)).filter(r=>!r.read).length}catch(a){return console.error("Error getting unread count:",a),0}})}}const px=new oP;function lP(){const[t,a]=y.useState([]),[r,s]=y.useState(0),[i,c]=y.useState(!0),[d,m]=y.useState(null),h=y.useCallback(()=>Q(null,null,function*(){var b,j;try{c(!0),m(null);const N=(yield px.getNotifications()).filter(k=>{var C;return!((C=k.subject)!=null&&C.startsWith("Failed to send email"))});a(N),s(N.filter(k=>!k.read).length)}catch(_){if((b=_==null?void 0:_.message)!=null&&b.includes("417")||(j=_==null?void 0:_.message)!=null&&j.includes("EXPECTATION FAILED"))a([]),s(0),m(null);else{const N=_ instanceof Error?_.message:"Failed to fetch notifications";m(N),console.warn("Error fetching notifications:",_)}}finally{c(!1)}}),[]);y.useEffect(()=>{h();const b=setInterval(h,3e4);return()=>clearInterval(b)},[h]);const g=y.useCallback(b=>Q(null,null,function*(){const j=t,_=r;a(N=>N.map(k=>k.name===b?Se(ue({},k),{read:1}):k)),s(N=>Math.max(0,N-1));try{yield px.markAsRead(b)}catch(N){throw console.error("Error marking notification as read:",N),a(j),s(_),N}}),[t,r]),p=y.useCallback(()=>Q(null,null,function*(){const b=t,j=r;a(_=>_.map(N=>Se(ue({},N),{read:1}))),s(0);try{yield px.markAllAsRead()}catch(_){throw console.error("Error marking all notifications as read:",_),a(b),s(j),_}}),[t,r]);return{notifications:t,unreadCount:r,loading:i,error:d,markAsRead:g,markAllAsRead:p,refetch:h}}const Jm=t=>t?(new DOMParser().parseFromString(t,"text/html").body.textContent||"").replace(/\uFEFF/g,"").replace(/\s+/g," ").trim():"",cP=()=>{const{notifications:t,unreadCount:a,markAsRead:r,markAllAsRead:s}=lP(),[i,c]=y.useState(!1),[d,m]=y.useState(!1),h=y.useRef(null),g=qa();y.useEffect(()=>{const k=C=>{h.current&&!h.current.contains(C.target)&&c(!1)};return i&&document.addEventListener("mousedown",k),()=>{document.removeEventListener("mousedown",k)}},[i]);const p=()=>Q(null,null,function*(){m(!0);try{yield s()}catch(k){console.warn("[NotificationBell] Could not mark all as read:",k)}finally{m(!1)}}),b=k=>Q(null,null,function*(){if(console.log("[NotificationBell] Clicked notification:",k),console.log("[NotificationBell] document_type:",k.document_type),console.log("[NotificationBell] document_name:",k.document_name),!k.read)try{yield r(k.name)}catch(C){console.warn("[NotificationBell] Could not mark as read (permission issue):",C)}if(k.document_type&&k.document_name){const C=k.document_type,D=k.document_name,T=C.replace(/_/g," ").trim();if(console.log("[NotificationBell] Normalized type:",T),console.log("[NotificationBell] Document name:",D),T==="Asset Maintenance Log"||T==="Asset Maintenance")console.log("[NotificationBell] Navigating to maintenance:",`/maintenance/${D}`),g(`/maintenance/${D}`);else if(T==="Work Order"||T==="Asset Repair")console.log("[NotificationBell] Navigating to work order:",`/work-orders/${D}`),g(`/work-orders/${D}`);else if(T==="Asset")console.log("[NotificationBell] Navigating to asset:",`/assets/${D}`),g(`/assets/${D}`);else if(T==="PM Schedule Generator"||T==="PM Schedule")console.log("[NotificationBell] Navigating to PPM planner:",`/ppm-planner/${D}`),g(`/ppm-planner/${D}`);else if(T==="PPM")console.log("[NotificationBell] Navigating to PPM:",`/ppm/${D}`),g(`/ppm/${D}`);else if(T==="Item")console.log("[NotificationBell] Navigating to inventory:",`/inventory/${D}`),g(`/inventory/${D}`);else if(T==="Inspection")console.log("[NotificationBell] Navigating to inspection:",`/inspections/${D}`),g(`/inspections/${D}`);else{console.warn(`[NotificationBell] Unknown document type: ${C}, opening in Frappe`);const E=C.toLowerCase().replace(/\s+/g,"-").replace(/_/g,"-");window.open(`/app/${E}/${D}`,"_blank")}}else console.warn("[NotificationBell] No document_type or document_name found:",{document_type:k.document_type,document_name:k.document_name,notification:k});c(!1)}),j=k=>{const C=new Date(k),T=new Date().getTime()-C.getTime(),E=Math.floor(T/6e4),O=Math.floor(T/36e5),R=Math.floor(T/864e5);return E<1?"Just now":E<60?`${E}m ago`:O<24?`${O}h ago`:R<7?`${R}d ago`:C.toLocaleDateString()},_=t.filter(k=>!k.read),N=t.filter(k=>k.read).slice(0,10);return e.jsxs("div",{className:"relative",ref:h,children:[e.jsxs("button",{onClick:()=>c(!i),className:"relative p-2 text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"Notifications",children:[e.jsx(xR,{size:20}),a>0&&e.jsx("span",{className:"absolute top-0 right-0 flex items-center justify-center w-5 h-5 text-xs font-bold text-white bg-red-500 rounded-full",children:a>9?"9+":a})]}),i&&e.jsxs("div",{className:"absolute right-0 mt-2 w-80 bg-white dark:bg-gray-800 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 z-[9999] max-h-96 overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[e.jsxs("h3",{className:"font-semibold text-gray-800 dark:text-white flex items-center gap-2",children:[e.jsx(v1,{}),"Notifications",a>0&&e.jsxs("span",{className:"text-xs bg-red-500 text-white px-2 py-0.5 rounded-full",children:[a," new"]})]}),a>0&&e.jsx("button",{onClick:p,disabled:d,className:`text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:underline ${d?"opacity-50 cursor-not-allowed":""}`,children:d?"Marking...":"Mark all read"})]}),e.jsx("div",{className:"overflow-y-auto flex-1",children:t.length===0?e.jsxs("div",{className:"p-8 text-center text-gray-500 dark:text-gray-400",children:[e.jsx(v1,{className:"mx-auto text-3xl mb-2 opacity-50"}),e.jsx("p",{children:"No notifications"})]}):e.jsxs(e.Fragment,{children:[_.length>0&&e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 px-2 mb-1",children:"NEW"}),_.map(k=>e.jsx("div",{onClick:()=>b(k),className:"p-3 hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer border-l-4 border-blue-500 bg-blue-50 dark:bg-blue-900/20",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:Jm(k.subject||"")||k.document_type||"Notification"}),k.email_content&&e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-1 line-clamp-2",children:Jm(k.email_content||"")}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-500 mt-1",children:j(k.creation)})]}),e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full flex-shrink-0 mt-1"})]})},k.name))]}),N.length>0&&e.jsxs("div",{className:"p-2 border-t border-gray-200 dark:border-gray-700",children:[_.length>0&&e.jsx("div",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 px-2 mb-1",children:"EARLIER"}),N.map(k=>e.jsx("div",{onClick:()=>b(k),className:"p-3 hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer",children:e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 truncate",children:Jm(k.subject||"")||k.document_type||"Notification"}),k.email_content&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1 line-clamp-2",children:Jm(k.email_content||"")}),e.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:j(k.creation)})]})})},k.name))]})]})})]})]})},dP=({userEmail:t})=>{qa();const{theme:a,toggleTheme:r}=iP(),{language:s,changeLanguage:i}=Yx(),{t:c}=ca(),d=()=>Q(null,null,function*(){var m;localStorage.removeItem("user"),localStorage.removeItem("sid");try{const h=((m=document.cookie.split("; ").find(g=>g.startsWith("X-Frappe-CSRF-Token=")))==null?void 0:m.split("=")[1])||"";yield fetch("/api/method/frappe.auth.logout",{method:"POST",headers:{"Content-Type":"application/json","X-Frappe-CSRF-Token":h},credentials:"include"}),yield fetch("/?cmd=web_logout",{credentials:"include"})}catch(h){console.error("Logout error:",h)}finally{window.location.href="/asm_app/login"}});return e.jsxs("header",{className:"h-14 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 px-4 flex items-center justify-end gap-2 flex-shrink-0",children:[e.jsx("div",{className:"relative",children:e.jsx(cP,{})}),e.jsx("button",{onClick:()=>i(s==="en"?"ar":"en"),className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors text-gray-700 dark:text-gray-300",title:c("common.language"),children:e.jsx(MR,{size:20})}),e.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors text-gray-700 dark:text-gray-300",title:c(a==="light"?"common.darkMode":"common.lightMode"),children:a==="light"?e.jsx(HR,{size:20}):e.jsx(ZR,{size:20})}),e.jsx("button",{onClick:d,className:"p-2 rounded-lg hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors text-red-600 dark:text-red-400",title:c("common.logout"),children:e.jsx(FR,{size:20})})]})};class uP{constructor(){Mn(this,"baseURL");this.baseURL=ia.BASE_URL}getCSRFToken(){return Q(this,null,function*(){try{return typeof window!="undefined"&&window.csrf_token?window.csrf_token:null}catch(a){return null}})}getHeaders(){return Q(this,null,function*(){const a={Accept:"application/json","Content-Type":"application/json"},r=yield this.getCSRFToken();return r&&(a["X-Frappe-CSRF-Token"]=r),a})}getIssues(){return Q(this,arguments,function*(a={}){const{filters:r={},fields:s=["name","subject","raised_by","status","priority","issue_type","opening_date","company","contact","creation","modified","first_responded_on","sla_resolution_date","sla_resolution_by"],limit_start:i=0,limit_page_length:c=20,order_by:d="creation desc"}=a,m=new URLSearchParams;if(m.append("fields",JSON.stringify(s)),m.append("limit_start",i.toString()),m.append("limit_page_length",c.toString()),m.append("order_by",d),Object.keys(r).length>0){const p=Ks(r);p.length>0&&m.append("filters",JSON.stringify(p))}const h=yield fetch(`${this.baseURL}/api/resource/Issue?${m.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);return{data:(yield h.json()).data||[]}})}getIssue(a){return Q(this,null,function*(){const r=yield fetch(`${this.baseURL}/api/resource/Issue/${encodeURIComponent(a)}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return(yield r.json()).data})}createIssue(a){return Q(this,null,function*(){const r=yield fetch(`${this.baseURL}/api/resource/Issue`,{method:"POST",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(a)});if(!r.ok){const i=yield r.json().catch(()=>({}));throw new Error(i.message||`HTTP error! status: ${r.status}`)}return(yield r.json()).data})}updateIssue(a,r){return Q(this,null,function*(){const s=yield fetch(`${this.baseURL}/api/resource/Issue/${encodeURIComponent(a)}`,{method:"PUT",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(r)});if(!s.ok){const c=yield s.json().catch(()=>({}));throw new Error(c.message||`HTTP error! status: ${s.status}`)}return(yield s.json()).data})}deleteIssue(a){return Q(this,null,function*(){const r=yield fetch(`${this.baseURL}/api/resource/Issue/${encodeURIComponent(a)}`,{method:"DELETE",headers:yield this.getHeaders(),credentials:"include"});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`)})}getIssueCount(){return Q(this,arguments,function*(a={}){var c,d;const r=new URLSearchParams;if(r.append("fields",JSON.stringify(["count(name) as count"])),Object.keys(a).length>0){const m=Ks(a);m.length>0&&r.append("filters",JSON.stringify(m))}const s=yield fetch(`${this.baseURL}/api/resource/Issue?${r.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return((d=(c=(yield s.json()).data)==null?void 0:c[0])==null?void 0:d.count)||0})}}const Id=new uP,mP=(t={})=>{const[a,r]=y.useState([]),[s,i]=y.useState(!0),[c,d]=y.useState(null),[m,h]=y.useState(0),g=y.useCallback(()=>Q(null,null,function*(){try{i(!0),d(null);const p=yield Id.getIssues(t);r(p.data);const b=yield Id.getIssueCount(t.filters);h(b)}catch(p){d(p instanceof Error?p.message:"Failed to fetch issues")}finally{i(!1)}}),[JSON.stringify(t)]);return y.useEffect(()=>{g()},[g]),{issues:a,loading:s,error:c,totalCount:m,refetch:g}},hP=t=>{const[a,r]=y.useState(null),[s,i]=y.useState(!1),[c,d]=y.useState(null),m=y.useCallback(()=>Q(null,null,function*(){if(!t){r(null);return}try{i(!0),d(null);const h=yield Id.getIssue(t);r(h)}catch(h){d(h instanceof Error?h.message:"Failed to fetch issue details")}finally{i(!1)}}),[t]);return y.useEffect(()=>{m()},[m]),{issue:a,loading:s,error:c,refetch:m}},gP=()=>{const[t,a]=y.useState(!1),[r,s]=y.useState(null);return{createIssue:m=>Q(null,null,function*(){try{return a(!0),s(null),yield Id.createIssue(m)}catch(h){const g=h instanceof Error?h.message:"Failed to create issue";throw s(g),h}finally{a(!1)}}),updateIssue:(m,h)=>Q(null,null,function*(){try{return a(!0),s(null),yield Id.updateIssue(m,h)}catch(g){const p=g instanceof Error?g.message:"Failed to update issue";throw s(p),g}finally{a(!1)}}),deleteIssue:m=>Q(null,null,function*(){try{a(!0),s(null),yield Id.deleteIssue(m)}catch(h){const g=h instanceof Error?h.message:"Failed to delete issue";throw s(g),h}finally{a(!1)}}),loading:t,error:r}},fP=({isOpen:t,onClose:a,selectedCount:r,totalCount:s,pageCount:i,onExport:c,isExporting:d,exportColumns:m})=>{const{t:h}=ca(),[g,p]=y.useState(r>0?"selected":"all_with_filters"),[b,j]=y.useState("csv"),[_,N]=y.useState(m.filter(T=>T.default).map(T=>T.key));y.useEffect(()=>{r>0?p("selected"):p("all_with_filters")},[r]);const k=T=>{N(E=>E.includes(T)?E.filter(O=>O!==T):[...E,T])},C=()=>N(m.map(T=>T.key)),D=()=>N(m.filter(T=>T.default).map(T=>T.key));return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] overflow-hidden animate-scale-in",children:[e.jsx("div",{className:"bg-gradient-to-r from-green-500 to-green-600 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Os,{className:"text-white text-xl"}),e.jsx("h3",{className:"text-lg font-semibold text-white",children:h("issues.export.title")})]}),e.jsx("button",{onClick:a,className:"text-white/80 hover:text-white transition-colors",disabled:d,children:e.jsx(wt,{size:20})})]})}),e.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:h("issues.export.selectData")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="selected"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"} ${r===0?"opacity-50 cursor-not-allowed":""}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"selected",checked:g==="selected",onChange:()=>p("selected"),disabled:r===0,className:"text-green-600 focus:ring-green-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("issues.export.selectedRows")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("issues.export.selectedCount",{count:r})})]}),r>0&&e.jsxs("span",{className:"bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300 px-2 py-1 rounded text-xs font-medium",children:[r," selected"]})]}),e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="all_on_page"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:g==="all_on_page",onChange:()=>p("all_on_page"),className:"text-green-600 focus:ring-green-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("issues.export.currentPage")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("issues.export.currentPageCount",{count:i})})]}),e.jsxs("span",{className:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 px-2 py-1 rounded text-xs font-medium",children:[i," rows"]})]}),e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="all_with_filters"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:g==="all_with_filters",onChange:()=>p("all_with_filters"),className:"text-green-600 focus:ring-green-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("issues.export.allWithFilters")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("issues.export.allWithFiltersCount",{count:s})})]}),e.jsxs("span",{className:"bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300 px-2 py-1 rounded text-xs font-medium",children:[s," total"]})]})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:h("issues.export.exportFormat")}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${b==="csv"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"format",value:"csv",checked:b==="csv",onChange:()=>j("csv"),className:"text-green-600 focus:ring-green-500"}),e.jsx(Bi,{className:"text-green-600 text-xl"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("issues.export.csv")}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("issues.export.csvDesc")})]})]}),e.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${b==="excel"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"format",value:"excel",checked:b==="excel",onChange:()=>j("excel"),className:"text-green-600 focus:ring-green-500"}),e.jsx(Ui,{className:"text-green-700 text-xl"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("issues.export.excel")}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("issues.export.excelDesc")})]})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:h("issues.export.columnsToExport")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:C,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("issues.export.selectAll")}),e.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),e.jsx("button",{onClick:D,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("issues.export.resetToDefault")})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2 max-h-48 overflow-y-auto p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg",children:m.map(T=>e.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${_.includes(T.key)?"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-400"}`,children:[e.jsx("input",{type:"checkbox",checked:_.includes(T.key),onChange:()=>k(T.key),className:"rounded text-green-600 focus:ring-green-500"}),e.jsx("span",{className:"text-sm truncate",children:T.label})]},T.key))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:h("issues.export.columnsSelected",{count:_.length})})]})]}),e.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[g==="selected"&&h("issues.export.exportingSelected",{count:r}),g==="all_on_page"&&h("issues.export.exportingPage",{count:i}),g==="all_with_filters"&&h("issues.export.exportingAll",{count:s})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",disabled:d,children:h("common.cancel")}),e.jsx("button",{onClick:()=>c(g,b,_),disabled:_.length===0||d,className:"px-4 py-2 text-sm font-medium text-white bg-green-600 hover:bg-green-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:d?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),h("issues.export.exporting")]}):e.jsxs(e.Fragment,{children:[e.jsx(po,{}),h("issues.export.exportButton")]})})]})]})]})}):null},xP=t=>{switch(t==null?void 0:t.toLowerCase()){case"open":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";case"replied":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";case"on hold":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300";case"resolved":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";case"closed":return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},pP=t=>{switch(t==null?void 0:t.toLowerCase()){case"high":return"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300";case"medium":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300";case"low":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},yP=()=>{const{t}=ca(),a=qa(),[r,s]=Qs(),i=y.useMemo(()=>{const Ze=parseInt(r.get("page")||"1",10);return Number.isNaN(Ze)||Ze<1?1:Ze},[r]),c=y.useCallback(Ze=>{const lt=typeof Ze=="function"?Ze(i):Ze;s(aa=>{const Ie=new URLSearchParams(aa);return Ie.set("page",String(lt)),Ie})},[i,s]),d=[{key:"name",label:t("issues.issueId"),default:!0},{key:"subject",label:t("issues.subject"),default:!0},{key:"status",label:t("commonFields.status"),default:!0},{key:"priority",label:t("commonFields.priority"),default:!0},{key:"raised_by",label:t("issues.raisedBy"),default:!0},{key:"company",label:t("commonFields.company"),default:!0},{key:"contact",label:t("issues.contact"),default:!1},{key:"issue_type",label:t("issues.issueType"),default:!1},{key:"opening_date",label:t("issues.openingDate"),default:!0},{key:"sla_resolution_date",label:t("issues.resolutionDate"),default:!1},{key:"sla_resolution_by",label:t("issues.resolvedBy"),default:!1},{key:"first_responded_on",label:t("issues.firstRespondedOn"),default:!1},{key:"description",label:t("commonFields.description"),default:!1},{key:"resolution_details",label:t("issues.resolutionDetails"),default:!1},{key:"creation",label:t("commonFields.createdOn"),default:!1},{key:"modified",label:t("commonFields.modifiedOn"),default:!1},{key:"owner",label:t("commonFields.createdBy"),default:!1}],[m]=y.useState(20),[h,g]=y.useState(!1),[p,b]=y.useState(new Set),[j,_]=y.useState(!1),[N,k]=y.useState(!1),[C,D]=y.useState(null),[T,E]=y.useState(()=>r.get("date_filter_by")||""),[O,R]=y.useState(()=>r.get("date_start")||""),[Y,P]=y.useState(()=>r.get("date_end")||""),[U,J]=y.useState(()=>r.get("status")||""),[ne,ye]=y.useState(()=>r.get("priority")||""),[he,ce]=y.useState(()=>r.get("company")||""),[se,ee]=y.useState(()=>r.get("issue_id")||""),[te,W]=y.useState(()=>r.get("sort_by")||"creation desc"),[I,oe]=y.useState(!1),[ae,F]=y.useState(0),[M,B]=y.useState([]),[X,K]=y.useState(!1),[we,be]=y.useState("");y.useEffect(()=>{const Ze=localStorage.getItem("issueFilterPresets");Ze&&B(JSON.parse(Ze))},[]);const ke=T&&(O||Y);y.useEffect(()=>{const Ze=[U,ne,he,se].filter(Boolean).length+(ke?1:0);F(Ze)},[U,ne,he,se,ke]);const Me=y.useMemo(()=>{const Ze={};return U&&(Ze.status=U),ne&&(Ze.priority=ne),he&&(Ze.company=he),se&&(Ze.name=se),Object.assign(Ze,el(T,O,Y)),Ze},[U,ne,he,se,T,O,Y]),z=["creation desc","creation asc","modified desc","modified asc","name asc","name desc"].includes(te)?te:"creation desc",{issues:Ne,loading:Xe,error:gt,totalCount:St,refetch:Ht}=mP({filters:Me,limit_start:(i-1)*m,limit_page_length:m,order_by:z});y.useEffect(()=>{!Xe&&!h&&g(!0)},[Xe,h]);const Mt=y.useRef(!1);y.useEffect(()=>{if(!Mt.current){Mt.current=!0;return}s(Ze=>{const lt=new URLSearchParams(Ze);return T?lt.set("date_filter_by",T):lt.delete("date_filter_by"),O?lt.set("date_start",O):lt.delete("date_start"),Y?lt.set("date_end",Y):lt.delete("date_end"),U?lt.set("status",U):lt.delete("status"),ne?lt.set("priority",ne):lt.delete("priority"),he?lt.set("company",he):lt.delete("company"),se?lt.set("issue_id",se):lt.delete("issue_id"),te&&te!=="creation desc"?lt.set("sort_by",te):lt.delete("sort_by"),lt.set("page","1"),lt})},[T,O,Y,U,ne,he,se,te]),y.useEffect(()=>{b(new Set)},[T,O,Y,U,ne,he,se,i]);const Te=Ze=>Ze?new Date(Ze).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",Qt=()=>{E(""),R(""),P(""),W("creation desc"),J(""),ye(""),ce(""),ee(""),s(Ze=>{const lt=new URLSearchParams(Ze);return lt.delete("date_filter_by"),lt.delete("date_start"),lt.delete("date_end"),lt.delete("sort_by"),lt.delete("status"),lt.delete("priority"),lt.delete("company"),lt.delete("issue_id"),lt.set("page","1"),lt})},zt=ke||!!U||!!ne||!!he||!!se,Wt=()=>{if(!we.trim()){alert("Please enter a filter name");return}const Ze={id:Date.now(),name:we,filters:{dateFilterBy:T,dateStart:O,dateEnd:Y,sortBy:te,statusFilter:U,priorityFilter:ne,companyFilter:he,issueIdFilter:se}},lt=[...M,Ze];B(lt),be(""),K(!1),localStorage.setItem("issueFilterPresets",JSON.stringify(lt))},Vt=Ze=>{const lt=Ze.filters;E(lt.dateFilterBy||""),R(lt.dateStart||""),P(lt.dateEnd||""),W(lt.sortBy||"creation desc"),J(lt.statusFilter||""),ye(lt.priorityFilter||""),ce(lt.companyFilter||""),ee(lt.issueIdFilter||"")},va=Ze=>{const lt=M.filter(aa=>aa.id!==Ze);B(lt),localStorage.setItem("issueFilterPresets",JSON.stringify(lt))},ta=Ze=>{b(lt=>{const aa=new Set(lt);return aa.has(Ze)?aa.delete(Ze):aa.add(Ze),aa})},sa=()=>{p.size===Ne.length?b(new Set):b(new Set(Ne.map(Ze=>Ze.name)))},ra=Ne.length>0&&p.size===Ne.length,Ye=p.size>0&&p.size<Ne.length,ft=y.useCallback(()=>Q(null,null,function*(){const Ze=[];let lt=0;const aa=100;let Ie=!0;const Nt=Ks(Me);for(;Ie;)try{const ht=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Issue",filters:Nt.length>0?Nt:{},fields:["*"],limit_start:lt*aa,limit_page_length:aa,order_by:z})})).json()).message||[];Ze.push(...ht),ht.length<aa?Ie=!1:lt++,lt>100&&(console.warn("Export safety limit reached"),Ie=!1)}catch(ve){throw console.error("Error fetching issues for export:",ve),ve}return Ze}),[Me,z]),$t=(Ze,lt,aa)=>Q(null,null,function*(){k(!0);try{let Ie=[];switch(Ze){case"selected":Ie=Ne.filter(ve=>p.has(ve.name));break;case"all_on_page":Ie=Ne;break;case"all_with_filters":Ie=yield ft();break}if(Ie.length===0){alert(t("assets.noDataToExport"));return}const Nt=aa.map(ve=>{var Oe;return((Oe=d.find(ht=>ht.key===ve))==null?void 0:Oe.label)||ve});if(lt==="csv"){const ve=[Nt.join(","),...Ie.map(Be=>aa.map(kt=>{let it=Be[kt]||"";return typeof it=="string"&&(it.includes(",")||it.includes('"')||it.includes(`
`))&&(it=`"${it.replace(/"/g,'""')}"`),it}).join(","))].join(`
`),Oe=new Blob(["\uFEFF"+ve],{type:"text/csv;charset=utf-8;"}),ht=URL.createObjectURL(Oe),et=document.createElement("a");et.href=ht,et.download=`issues_export_${new Date().toISOString().split("T")[0]}.csv`,et.click(),URL.revokeObjectURL(ht)}else if(lt==="excel"){const ve=[Nt,...Ie.map(et=>aa.map(Be=>et[Be]||""))],Oe=Ja.aoa_to_sheet(ve),ht=Ja.book_new();Ja.book_append_sheet(ht,Oe,"Issues"),$i(ht,`issues_export_${new Date().toISOString().split("T")[0]}.xlsx`)}_(!1),b(new Set)}catch(Ie){console.error("Export failed:",Ie),alert(`Export failed: ${Ie instanceof Error?Ie.message:"Unknown error"}`)}finally{k(!1)}}),na=Ze=>Q(null,null,function*(){try{if(!(yield fetch(`/api/resource/Issue/${Ze}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to delete");D(null),Ht(),alert(t("issues.deletedSuccessfully"))}catch(lt){alert(`Failed to delete: ${lt instanceof Error?lt.message:"Unknown error"}`)}});return Xe&&!h?e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("issues.loadingIssues")})]})}):gt?e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:t("issues.errorLoadingIssues")}),e.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:gt}),e.jsx("button",{onClick:Ht,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:t("common.tryAgain")})]})}):e.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(w1,{className:"text-3xl text-blue-600 dark:text-blue-400"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:t("issues.listTitle")}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t("issues.listTotal"),": ",St,p.size>0&&e.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",p.size," ",t("issues.listSelected")]}),Xe&&h&&e.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[e.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-blue-500"}),t("common.filtering")]})]})]})]})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:()=>oe(!I),className:`px-4 py-2 rounded-lg flex items-center gap-2 transition-colors ${I||zt?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300":"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600"}`,children:[e.jsx(ds,{}),t("listPages.filters"),ae>0&&e.jsx("span",{className:"bg-blue-600 text-white text-xs px-1.5 py-0.5 rounded-full",children:ae})]}),e.jsxs("button",{onClick:Ht,disabled:Xe,className:"px-4 py-2 rounded-lg bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 flex items-center gap-2 disabled:opacity-50",children:[e.jsx(vn,{className:Xe?"animate-spin":""}),t("listPages.refresh")]}),e.jsxs("button",{onClick:()=>_(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",disabled:St===0,children:[e.jsx(Os,{}),e.jsx("span",{className:"font-medium",children:t("listPages.export")}),p.size>0&&e.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:p.size})]}),e.jsxs("button",{onClick:()=>a("/support/new"),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow-lg transition-all hover:shadow-xl",children:[e.jsx(Zs,{}),e.jsx("span",{className:"font-medium",children:t("issues.newIssue")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-4",children:[e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("issues.statsTotalIssues")}),e.jsx("p",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:St})]}),e.jsx(H5,{className:"text-3xl text-blue-500"})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("issues.statsOpen")}),e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:Ne.filter(Ze=>Ze.status==="Open").length})]}),e.jsx(or,{className:"text-3xl text-blue-500"})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("issues.statsResolved")}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:Ne.filter(Ze=>Ze.status==="Resolved").length})]}),e.jsx(ea,{className:"text-3xl text-green-500"})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("issues.statsClosed")}),e.jsx("p",{className:"text-2xl font-bold text-gray-600 dark:text-gray-300",children:Ne.filter(Ze=>Ze.status==="Closed").length})]}),e.jsx(ka,{className:"text-3xl text-gray-500"})]})})]}),I&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[e.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 dark:from-blue-600 dark:to-blue-700 px-4 py-3 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ds,{className:"text-white",size:16}),e.jsx("h3",{className:"text-white font-semibold text-sm",children:t("listPages.filters")}),ae>0&&e.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:ae})]}),zt&&e.jsx("div",{className:"flex-1 overflow-x-auto scrollbar-hide mx-2",children:e.jsxs("div",{className:"flex items-center gap-2 py-1",children:[se&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-blue-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("issues.issueId"),":"]})," ",se,e.jsx("button",{onClick:()=>ee(""),className:"hover:text-red-500",children:e.jsx(wt,{className:"text-[9px]"})})]}),U&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-green-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("filters.status"),":"]})," ",U,e.jsx("button",{onClick:()=>J(""),className:"hover:text-red-500",children:e.jsx(wt,{className:"text-[9px]"})})]}),ne&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-orange-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("filters.priority"),":"]})," ",ne,e.jsx("button",{onClick:()=>ye(""),className:"hover:text-red-500",children:e.jsx(wt,{className:"text-[9px]"})})]}),he&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-purple-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("filters.filterByCompany"),":"]})," ",he,e.jsx("button",{onClick:()=>ce(""),className:"hover:text-red-500",children:e.jsx(wt,{className:"text-[9px]"})})]}),ke&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("filters.filterBy"),":"]})," ",t(T==="creation"?"filters.createdDate":"filters.latestModifiedDate")," ",O&&` ${O}`," ",Y&&` - ${Y}`,e.jsx("button",{onClick:()=>{E(""),R(""),P("")},className:"hover:text-red-500",children:e.jsx(wt,{className:"text-[9px]"})})]})]})}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[ae>0&&e.jsxs("button",{onClick:()=>K(!0),className:"px-3 py-1.5 bg-white text-blue-600 hover:bg-blue-50 rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[e.jsx(Or,{size:12}),e.jsx("span",{className:"hidden sm:inline",children:t("listPages.saveFilterPreset")})]}),zt&&e.jsxs("button",{onClick:Qt,className:"px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[e.jsx(wt,{size:12}),e.jsx("span",{className:"hidden sm:inline",children:t("listPages.clearFilters")})]})]})]})}),e.jsxs("div",{className:"p-4",children:[M.length>0&&e.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[e.jsx(Tc,{className:"text-yellow-500",size:12}),t("inspections.savedFilters")]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:M.map(Ze=>e.jsxs("div",{className:"group relative inline-flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-purple-100 to-blue-100 dark:from-purple-900/30 dark:to-blue-900/30 border border-purple-200 dark:border-purple-700 rounded-lg hover:shadow-md transition-all",children:[e.jsx("button",{onClick:()=>Vt(Ze),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:Ze.name}),e.jsx("button",{onClick:()=>va(Ze.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:e.jsx(Na,{size:10})})]},Ze.id))})]}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.sortBy")}),e.jsxs("select",{value:te,onChange:Ze=>{W(Ze.target.value),c(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"creation desc",children:t("filters.sortCreationNewest")}),e.jsx("option",{value:"creation asc",children:t("filters.sortCreationOldest")}),e.jsx("option",{value:"modified desc",children:t("filters.sortModifiedNewest")}),e.jsx("option",{value:"modified asc",children:t("filters.sortModifiedOldest")}),e.jsx("option",{value:"name asc",children:t("filters.sortNameAsc")}),e.jsx("option",{value:"name desc",children:t("filters.sortNameDesc")})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.filterBy")}),e.jsxs("select",{value:T,onChange:Ze=>{const lt=Ze.target.value;E(lt),c(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("filters.filterBy")}),e.jsx("option",{value:"creation",children:t("filters.createdDate")}),e.jsx("option",{value:"modified",children:t("filters.latestModifiedDate")})]})]}),T&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.startDate")}),e.jsx("input",{type:"date",value:O,onChange:Ze=>{const lt=Ze.target.value;R(lt),Y&&lt>Y&&P(lt),c(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.endDate")}),e.jsx("input",{type:"date",value:Y,onChange:Ze=>{P(Ze.target.value),c(1)},min:O||void 0,className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),e.jsxs("div",{className:"relative z-[60]",children:[e.jsx(Ut,{label:t("issues.issueId"),doctype:"Issue",value:se,onChange:Ze=>{ee(Ze),c(1)},placeholder:t("linkField.selectLabel",{label:t("issues.issueId")}),disabled:!1,compact:!0}),se&&e.jsx("button",{onClick:()=>ee(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.status")}),e.jsxs("select",{value:U,onChange:Ze=>{J(Ze.target.value),c(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("filters.allStatuses")}),e.jsx("option",{value:"Open",children:t("issues.status.open")}),e.jsx("option",{value:"Replied",children:t("issues.status.replied")}),e.jsx("option",{value:"On Hold",children:t("issues.status.on_hold")}),e.jsx("option",{value:"Resolved",children:t("issues.status.resolved")}),e.jsx("option",{value:"Closed",children:t("issues.status.closed")})]})]}),e.jsxs("div",{className:"relative z-[59]",children:[e.jsx(Ut,{label:t("commonFields.priority"),doctype:"Issue Priority",value:ne,onChange:Ze=>{ye(Ze),c(1)},placeholder:t("issues.allPriorities"),disabled:!1,compact:!0}),ne&&e.jsx("button",{onClick:()=>ye(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[58]",children:[e.jsx(Ut,{label:t("commonFields.company"),doctype:"Company",value:he,onChange:Ze=>{ce(Ze),c(1)},placeholder:t("issues.allCompanies"),disabled:!1,compact:!0}),he&&e.jsx("button",{onClick:()=>ce(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]})]})})]})]}),X&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:"Save Filter Preset"}),e.jsx("input",{type:"text",value:we,onChange:Ze=>be(Ze.target.value),onKeyDown:Ze=>{Ze.key==="Enter"&&(Ze.preventDefault(),Wt())},placeholder:"Enter filter name (e.g., 'Open High Priority')",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white mb-4",autoFocus:!0}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>{K(!1),be("")},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:Wt,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors flex items-center gap-2",children:[e.jsx(Or,{size:12}),"Save Filter"]})]})]})}),e.jsx(fP,{isOpen:j,onClose:()=>_(!1),selectedCount:p.size,totalCount:St,pageCount:Ne.length,onExport:$t,isExporting:N,exportColumns:d}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700 overflow-hidden relative",children:[Xe&&h&&e.jsx("div",{className:"absolute inset-0 bg-white/60 dark:bg-gray-800/60 flex items-center justify-center z-10 backdrop-blur-[1px]",children:e.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[e.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-blue-500"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:t("common.filtering")})]})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left",children:e.jsx("button",{onClick:sa,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:t(ra?"listPages.deselectAllTitle":"listPages.selectAllTitle"),children:ra?e.jsx(Es,{className:"text-blue-600 dark:text-blue-400",size:18}):Ye?e.jsxs("div",{className:"relative",children:[e.jsx(Ar,{size:18}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):e.jsx(Ar,{size:18})})}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("issues.issueId")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("issues.subject")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("commonFields.status")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("commonFields.priority")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("commonFields.company")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("issues.openingDate")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("listPages.actions")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:Ne.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:"px-4 py-12 text-center text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(w1,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),e.jsx("p",{children:t("issues.noIssuesFound")}),zt?e.jsx("button",{onClick:Qt,className:"mt-4 text-blue-600 dark:text-blue-400 hover:underline",children:t("common.clearFilters")}):e.jsx("button",{onClick:()=>a("/support/new"),className:"mt-4 text-blue-600 dark:text-blue-400 hover:underline",children:t("issues.createFirstIssue")})]})})}):Ne.map(Ze=>e.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer transition-colors ${p.has(Ze.name)?"bg-blue-50 dark:bg-blue-900/20":""}`,onClick:()=>a(`/support/${Ze.name}`),children:[e.jsx("td",{className:"px-4 py-3",onClick:lt=>lt.stopPropagation(),children:e.jsx("button",{onClick:()=>ta(Ze.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:p.has(Ze.name)?e.jsx(Es,{className:"text-blue-600 dark:text-blue-400",size:18}):e.jsx(Ar,{size:18})})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-400",children:Ze.name})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm text-gray-900 dark:text-white line-clamp-1",children:Ze.subject||"-"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${xP(Ze.status)}`,children:Ze.status?t(`issues.status.${Ze.status.toLowerCase().replace(/\\s+/g,"_")}`,Ze.status):"-"})}),e.jsx("td",{className:"px-4 py-3",children:Ze.priority?e.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${pP(Ze.priority)}`,children:t(`issues.priority.${Ze.priority.toLowerCase()}`,Ze.priority)}):e.jsx("span",{className:"text-gray-400",children:"-"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300 line-clamp-1",children:Ze.company||"-"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:Te(Ze.opening_date)})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1",onClick:lt=>lt.stopPropagation(),children:[e.jsx("button",{onClick:()=>a(`/support/${Ze.name}`),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:t("issues.viewDetails"),children:e.jsx(ri,{})}),e.jsx("button",{onClick:()=>a(`/support/${Ze.name}`),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:t("issues.editIssue"),children:e.jsx(Fr,{})}),e.jsx("button",{onClick:()=>D(Ze.name),className:"text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300 p-2 hover:bg-red-50 dark:hover:bg-red-900/30 rounded transition-colors",title:t("issues.deleteIssue"),children:e.jsx(Na,{})})]})})]},Ze.name))})]})}),e.jsx(Rc,{currentPage:i,totalCount:St,pageSize:m,itemLabel:t("pagination.issues"),onPageChange:Ze=>c(Ze)})]}),C&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:e.jsx(Na,{className:"text-red-600 dark:text-red-400 text-xl"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:t("issues.deleteIssue")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:t("issues.deleteConfirmMessage")}),e.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-md p-3 mb-4",children:e.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[e.jsxs("strong",{children:[t("issues.issueId"),":"]})," ",C]})}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>D(null),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-lg transition-colors",children:t("common.cancel")}),e.jsxs("button",{onClick:()=>na(C),className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors flex items-center gap-2",children:[e.jsx(Na,{}),t("issues.deleteIssue")]})]})]})]})})}),e.jsx("style",{children:`
@keyframes scale-in { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.animate-scale-in { animation: scale-in 0.2s ease-out; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
.scrollbar-hide::-webkit-scrollbar { display: none; }
`})]})},bP=()=>new Date().toISOString().split("T")[0],vP=()=>new Date().toTimeString().split(" ")[0],_P=t=>{switch(t==null?void 0:t.toLowerCase()){case"open":return{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-300",border:"border-blue-200 dark:border-blue-800"};case"replied":return{bg:"bg-purple-100 dark:bg-purple-900/30",text:"text-purple-800 dark:text-purple-300",border:"border-purple-200 dark:border-purple-800"};case"on hold":return{bg:"bg-yellow-100 dark:bg-yellow-900/30",text:"text-yellow-800 dark:text-yellow-300",border:"border-yellow-200 dark:border-yellow-800"};case"resolved":return{bg:"bg-green-100 dark:bg-green-900/30",text:"text-green-800 dark:text-green-300",border:"border-green-200 dark:border-green-800"};case"closed":return{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-800 dark:text-gray-300",border:"border-gray-200 dark:border-gray-600"};default:return{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-800 dark:text-gray-300",border:"border-gray-200 dark:border-gray-600"}}},wP=()=>{const{t}=ca(),{issueName:a}=xo(),r=qa(),s=a==="new",[i,c]=y.useState({subject:"",raised_by:"",status:"Open",priority:"",issue_type:"",description:"",contact:"",company:"",customer:"",project:"",resolution_details:"",opening_date:s?bP():"",opening_time:s?vP():"",first_responded_on:"",sla_resolution_date:"",sla_resolution_by:""}),{issue:d,loading:m,error:h,refetch:g}=hP(s?null:a||null),{createIssue:p,updateIssue:b,deleteIssue:j,loading:_}=gP(),[N,k]=y.useState(s),[C,D]=y.useState(!1);y.useEffect(()=>{d&&!s&&(c({subject:d.subject||"",raised_by:d.raised_by||"",status:d.status||"Open",priority:d.priority||"",issue_type:d.issue_type||"",description:d.description||"",contact:d.contact||"",company:d.company||"",customer:d.customer||"",project:d.project||"",resolution_details:d.resolution_details||"",opening_date:d.opening_date||"",opening_time:d.opening_time||"",first_responded_on:d.first_responded_on?d.first_responded_on.split(" ")[0]:"",sla_resolution_date:d.sla_resolution_date?d.sla_resolution_date.split(" ")[0]:"",sla_resolution_by:d.sla_resolution_by||""}),k(!1))},[d,s]);const T=J=>{const{name:ne,value:ye}=J.target;c(he=>Se(ue({},he),{[ne]:ye}))},E=()=>Q(null,null,function*(){if(!i.subject){nt.error("Please enter a subject",{position:"top-right",autoClose:4e3,icon:e.jsx(ka,{})});return}try{if(s){const J=yield p(i);nt.success("Issue created successfully!",{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),r(`/support/${J.name}`)}else yield b(a,i),nt.success("Issue updated successfully!",{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),k(!1),g()}catch(J){const ne=J instanceof Error?J.message:"Unknown error";nt.error(`Failed to save: ${ne}`,{position:"top-right",autoClose:6e3,icon:e.jsx(ka,{})})}}),O=()=>Q(null,null,function*(){try{yield j(a),nt.success("Issue deleted successfully!",{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),r(-1)}catch(J){const ne=J instanceof Error?J.message:"Unknown error";nt.error(`Failed to delete: ${ne}`,{position:"top-right",autoClose:6e3,icon:e.jsx(ka,{})})}}),R=y.useCallback(J=>!!(!N||["opening_date","opening_time"].includes(J)&&!s),[N,s]),Y=J=>J?new Date(J).toLocaleString():"-";if(m)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading issue details..."})]})});if(h&&!s)return e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:"Error Loading Issue"}),e.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:h}),e.jsx("button",{onClick:()=>r(-1),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:"Back to Issues"})]})});const P=(d==null?void 0:d.status)||i.status||"Open",U=_P(P);return e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[e.jsx(Xd,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Lc}),e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>r(-1),className:"text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200",children:e.jsx(en,{size:20})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white flex items-center gap-3",children:[s?t("issues.newIssue"):(d==null?void 0:d.name)||t("issues.issueDetails"),!s&&e.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium ${U.bg} ${U.text} ${U.border} border`,children:P})]}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:s?t("issues.createNewIssue"):i.subject})]})]}),e.jsxs("div",{className:"flex gap-3",children:[!s&&!N&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>k(!0),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[e.jsx(Fr,{}),t("common.edit")]}),e.jsxs("button",{onClick:()=>D(!0),className:"bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[e.jsx(Na,{}),t("common.delete")]})]}),N&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{s?r(-1):(k(!1),g())},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg",children:t("common.cancel")}),e.jsxs("button",{onClick:E,disabled:_,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[e.jsx(Or,{}),t(_?"common.saving":"common.save")]})]})]})]}),C&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(fa,{className:"text-red-500 text-xl mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Delete Issue"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Are you sure you want to delete this issue? This action cannot be undone."})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>D(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:"Cancel"}),e.jsx("button",{onClick:O,disabled:_,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg disabled:opacity-50",children:_?"Deleting...":"Delete"})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx($5,{className:"text-blue-500"}),t("issues.issueDetails")]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t("issues.subject")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",name:"subject",value:i.subject,onChange:T,disabled:R("subject"),placeholder:t("issues.enterSubject"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("commonFields.status")}),e.jsxs("select",{name:"status",value:i.status,onChange:T,disabled:R("status"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"Open",children:"Open"}),e.jsx("option",{value:"Replied",children:"Replied"}),e.jsx("option",{value:"On Hold",children:"On Hold"}),e.jsx("option",{value:"Resolved",children:"Resolved"}),e.jsx("option",{value:"Closed",children:"Closed"})]})]}),e.jsx("div",{children:e.jsx(Ut,{label:t("commonFields.priority"),doctype:"Issue Priority",value:i.priority||"",onChange:J=>c(Se(ue({},i),{priority:J})),disabled:R("priority"),placeholder:t("issues.selectPriority")})})]}),e.jsx("div",{children:e.jsx(Ut,{label:t("issues.issueType"),doctype:"Issue Type",value:i.issue_type||"",onChange:J=>c(Se(ue({},i),{issue_type:J})),disabled:R("issue_type"),placeholder:t("issues.selectIssueType")})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("commonFields.description")}),e.jsx("textarea",{name:"description",value:i.description,onChange:T,disabled:R("description"),placeholder:t("issues.describeIssue"),rows:5,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(js,{className:"text-green-500"}),t("issues.contactInformation")]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("issues.raisedBy")}),e.jsxs("div",{className:"relative",children:[e.jsx(T2,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"email",name:"raised_by",value:i.raised_by,onChange:T,disabled:R("raised_by"),placeholder:t("common.email"),className:"w-full pl-10 pr-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]}),e.jsx("div",{children:e.jsx(Ut,{label:t("commonFields.company"),doctype:"Company",value:i.company||"",onChange:J=>c(Se(ue({},i),{company:J})),disabled:R("company"),placeholder:t("issues.selectCompany")})})]})]}),!s&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(ea,{className:"text-purple-500"}),t("issues.resolution")]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("issues.firstRespondedOn")}),e.jsx("input",{type:"date",name:"first_responded_on",value:i.first_responded_on||"",onChange:T,disabled:R("first_responded_on"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("issues.resolutionDate")}),e.jsx("input",{type:"date",name:"sla_resolution_date",value:i.sla_resolution_date||"",onChange:T,disabled:R("sla_resolution_date"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]}),e.jsx("div",{children:e.jsx(Ut,{label:t("issues.resolvedBy"),doctype:"User",value:i.sla_resolution_by||"",onChange:J=>c(Se(ue({},i),{sla_resolution_by:J})),disabled:R("sla_resolution_by"),placeholder:t("maintenance.selectUser")})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("issues.resolutionDetails")}),e.jsx("textarea",{name:"resolution_details",value:i.resolution_details,onChange:T,disabled:R("resolution_details"),placeholder:t("issues.describeResolution"),rows:4,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none"})]})]})]}),!s&&e.jsx(Pc,{referenceDoctype:"Issue",referenceName:a||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5,collapsible:!0,startCollapsed:!1})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(X5,{className:"text-orange-500"}),t("issues.statusInformation")]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:`p-4 rounded-lg border ${U.bg} ${U.border}`,children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:t("issues.currentStatus")}),e.jsx("p",{className:`text-xl font-semibold ${U.text}`,children:P})]}),i.priority&&e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:t("commonFields.priority")}),e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:i.priority})]}),i.issue_type&&e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:t("issues.issueType")}),e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:i.issue_type})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(go,{className:"text-teal-500"}),t("issues.timeline")]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:t("issues.openingDate")}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:i.opening_date||"-"})]}),e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Opening Time"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:i.opening_time||"-"})]}),!s&&d&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Created"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:Y(d.creation)})]}),e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Last Modified"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:Y(d.modified)})]}),e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Modified By"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:d.modified_by||"-"})]})]})]})]}),i.company&&!s&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(Jx,{className:"text-indigo-500"}),"Company"]}),e.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:i.company})})]})]})]})]})};class kP{constructor(){Mn(this,"baseURL");this.baseURL=ia.BASE_URL}getCSRFToken(){return Q(this,null,function*(){try{return typeof window!="undefined"&&window.csrf_token?window.csrf_token:null}catch(a){return null}})}getHeaders(){return Q(this,null,function*(){const a={Accept:"application/json","Content-Type":"application/json"},r=yield this.getCSRFToken();return r&&(a["X-Frappe-CSRF-Token"]=r),a})}getMaintenanceTeams(){return Q(this,arguments,function*(a={}){const{filters:r={},fields:s=["name","maintenance_team_name","maintenance_manager","maintenance_manager_name","company","custom_expertise","creation","modified"],limit_start:i=0,limit_page_length:c=20,order_by:d="creation desc"}=a,m=new URLSearchParams;if(m.append("fields",JSON.stringify(s)),m.append("limit_start",i.toString()),m.append("limit_page_length",c.toString()),m.append("order_by",d),Object.keys(r).length>0){const p=Ks(r);p.length>0&&m.append("filters",JSON.stringify(p))}const h=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team?${m.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);return{data:(yield h.json()).data||[]}})}getMaintenanceTeam(a){return Q(this,null,function*(){const r=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team/${encodeURIComponent(a)}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return(yield r.json()).data})}createMaintenanceTeam(a){return Q(this,null,function*(){const r=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team`,{method:"POST",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(a)});if(!r.ok){const i=yield r.json().catch(()=>({}));throw new Error(i.message||`HTTP error! status: ${r.status}`)}return(yield r.json()).data})}updateMaintenanceTeam(a,r){return Q(this,null,function*(){const s=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team/${encodeURIComponent(a)}`,{method:"PUT",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(r)});if(!s.ok){const c=yield s.json().catch(()=>({}));throw new Error(c.message||`HTTP error! status: ${s.status}`)}return(yield s.json()).data})}deleteMaintenanceTeam(a){return Q(this,null,function*(){const r=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team/${encodeURIComponent(a)}`,{method:"DELETE",headers:yield this.getHeaders(),credentials:"include"});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`)})}getMaintenanceTeamCount(){return Q(this,arguments,function*(a={}){var c,d;const r=new URLSearchParams;if(r.append("fields",JSON.stringify(["count(name) as count"])),Object.keys(a).length>0){const m=Ks(a);m.length>0&&r.append("filters",JSON.stringify(m))}const s=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team?${r.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return((d=(c=(yield s.json()).data)==null?void 0:c[0])==null?void 0:d.count)||0})}getUserFullName(a){return Q(this,null,function*(){var r;try{const s=yield fetch(`${this.baseURL}/api/resource/User/${encodeURIComponent(a)}?fields=["full_name"]`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});return s.ok&&((r=(yield s.json()).data)==null?void 0:r.full_name)||""}catch(s){return""}})}}const gc=new kP,jP=(t={})=>{const[a,r]=y.useState([]),[s,i]=y.useState(!0),[c,d]=y.useState(null),[m,h]=y.useState(0),g=y.useCallback(()=>Q(null,null,function*(){try{i(!0),d(null);const p=yield gc.getMaintenanceTeams(t);r(p.data);const b=yield gc.getMaintenanceTeamCount(t.filters);h(b)}catch(p){d(p instanceof Error?p.message:"Failed to fetch maintenance teams")}finally{i(!1)}}),[JSON.stringify(t)]);return y.useEffect(()=>{g()},[g]),{teams:a,loading:s,error:c,totalCount:m,refetch:g}},NP=t=>{const[a,r]=y.useState(null),[s,i]=y.useState(!1),[c,d]=y.useState(null),m=y.useCallback(()=>Q(null,null,function*(){if(!t){r(null);return}try{i(!0),d(null);const h=yield gc.getMaintenanceTeam(t);r(h)}catch(h){d(h instanceof Error?h.message:"Failed to fetch maintenance team details")}finally{i(!1)}}),[t]);return y.useEffect(()=>{m()},[m]),{team:a,loading:s,error:c,refetch:m}},SP=()=>{const[t,a]=y.useState(!1),[r,s]=y.useState(null);return{createTeam:h=>Q(null,null,function*(){try{return a(!0),s(null),yield gc.createMaintenanceTeam(h)}catch(g){const p=g instanceof Error?g.message:"Failed to create maintenance team";throw s(p),g}finally{a(!1)}}),updateTeam:(h,g)=>Q(null,null,function*(){try{return a(!0),s(null),yield gc.updateMaintenanceTeam(h,g)}catch(p){const b=p instanceof Error?p.message:"Failed to update maintenance team";throw s(b),p}finally{a(!1)}}),deleteTeam:h=>Q(null,null,function*(){try{a(!0),s(null),yield gc.deleteMaintenanceTeam(h)}catch(g){const p=g instanceof Error?g.message:"Failed to delete maintenance team";throw s(p),g}finally{a(!1)}}),getUserFullName:h=>Q(null,null,function*(){return yield gc.getUserFullName(h)}),loading:t,error:r}},CP=({isOpen:t,onClose:a,selectedCount:r,totalCount:s,pageCount:i,onExport:c,isExporting:d,exportColumns:m})=>{const{t:h}=ca(),[g,p]=y.useState(r>0?"selected":"all_with_filters"),[b,j]=y.useState("csv"),[_,N]=y.useState(m.filter(T=>T.default).map(T=>T.key));y.useEffect(()=>{p(r>0?"selected":"all_with_filters")},[r]);const k=T=>N(E=>E.includes(T)?E.filter(O=>O!==T):[...E,T]),C=()=>N(m.map(T=>T.key)),D=()=>N(m.filter(T=>T.default).map(T=>T.key));return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] overflow-hidden animate-scale-in",children:[e.jsx("div",{className:"bg-gradient-to-r from-green-500 to-green-600 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Os,{className:"text-white text-xl"}),e.jsx("h3",{className:"text-lg font-semibold text-white",children:h("maintenance.export.title")})]}),e.jsx("button",{onClick:a,className:"text-white/80 hover:text-white transition-colors",disabled:d,children:e.jsx(wt,{size:20})})]})}),e.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:h("maintenance.export.selectData")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="selected"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"} ${r===0?"opacity-50 cursor-not-allowed":""}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"selected",checked:g==="selected",onChange:()=>p("selected"),disabled:r===0,className:"text-green-600 focus:ring-green-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("maintenance.export.selectedRows")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("maintenance.export.selectedCount",{count:r})})]}),r>0&&e.jsxs("span",{className:"bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300 px-2 py-1 rounded text-xs font-medium",children:[r," selected"]})]}),e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="all_on_page"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:g==="all_on_page",onChange:()=>p("all_on_page"),className:"text-green-600 focus:ring-green-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("maintenance.export.currentPage")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("maintenance.export.currentPageCount",{count:i})})]}),e.jsxs("span",{className:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 px-2 py-1 rounded text-xs font-medium",children:[i," rows"]})]}),e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="all_with_filters"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:g==="all_with_filters",onChange:()=>p("all_with_filters"),className:"text-green-600 focus:ring-green-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("maintenance.export.allWithFilters")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("maintenance.export.allWithFiltersCount",{count:s})})]}),e.jsxs("span",{className:"bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300 px-2 py-1 rounded text-xs font-medium",children:[s," total"]})]})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:h("maintenance.export.exportFormat")}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${b==="csv"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"format",value:"csv",checked:b==="csv",onChange:()=>j("csv"),className:"text-green-600 focus:ring-green-500"}),e.jsx(Bi,{className:"text-green-600 text-xl"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("maintenance.export.csv")}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("maintenance.export.csvDesc")})]})]}),e.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${b==="excel"?"border-green-500 bg-green-50 dark:bg-green-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"format",value:"excel",checked:b==="excel",onChange:()=>j("excel"),className:"text-green-600 focus:ring-green-500"}),e.jsx(Ui,{className:"text-green-700 text-xl"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("maintenance.export.excel")}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("maintenance.export.excelDesc")})]})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:h("maintenance.export.columnsToExport")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:C,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("maintenance.export.selectAll")}),e.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),e.jsx("button",{onClick:D,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("maintenance.export.resetToDefault")})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2 max-h-48 overflow-y-auto p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg",children:m.map(T=>e.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${_.includes(T.key)?"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-400"}`,children:[e.jsx("input",{type:"checkbox",checked:_.includes(T.key),onChange:()=>k(T.key),className:"rounded text-green-600 focus:ring-green-500"}),e.jsx("span",{className:"text-sm truncate",children:T.label})]},T.key))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:h("maintenance.export.columnsSelected",{count:_.length})})]})]}),e.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[g==="selected"&&h("maintenance.export.exportingSelected",{count:r}),g==="all_on_page"&&h("maintenance.export.exportingPage",{count:i}),g==="all_with_filters"&&h("maintenance.export.exportingAll",{count:s})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",disabled:d,children:h("common.cancel")}),e.jsx("button",{onClick:()=>c(g,b,_),disabled:_.length===0||d,className:"px-4 py-2 text-sm font-medium text-white bg-green-600 hover:bg-green-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:d?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),h("maintenance.export.exporting")]}):e.jsxs(e.Fragment,{children:[e.jsx(po,{}),h("maintenance.export.exportButton")]})})]})]})]})}):null},TP=()=>{const{t}=ca(),a=qa(),r=[{key:"name",label:t("maintenance.teamId"),default:!0},{key:"maintenance_team_name",label:t("maintenance.teamName"),default:!0},{key:"maintenance_manager",label:t("maintenance.managerEmail"),default:!0},{key:"maintenance_manager_name",label:t("maintenance.managerName"),default:!0},{key:"company",label:t("commonFields.hospital"),default:!0},{key:"custom_expertise",label:t("maintenance.expertise"),default:!0},{key:"creation",label:t("commonFields.createdOn"),default:!1},{key:"modified",label:t("commonFields.modifiedOn"),default:!1}],[s,i]=Qs(),c=y.useMemo(()=>{const Ye=parseInt(s.get("page")||"1",10);return Number.isNaN(Ye)||Ye<1?1:Ye},[s]),d=y.useCallback(Ye=>{const ft=typeof Ye=="function"?Ye(c):Ye;i($t=>{const na=new URLSearchParams($t);return na.set("page",String(ft)),na})},[c,i]),[m]=y.useState(20),[h,g]=y.useState(!1),[p,b]=y.useState(new Set),[j,_]=y.useState(!1),[N,k]=y.useState(!1),[C,D]=y.useState(null),[T,E]=y.useState(()=>s.get("date_filter_by")||""),[O,R]=y.useState(()=>s.get("date_start")||""),[Y,P]=y.useState(()=>s.get("date_end")||""),[U,J]=y.useState(()=>s.get("company")||""),[ne,ye]=y.useState(()=>s.get("team_name")||""),[he,ce]=y.useState(()=>s.get("sort_by")||"creation desc"),[se,ee]=y.useState(!1),[te,W]=y.useState(0),[I,oe]=y.useState([]),[ae,F]=y.useState(!1),[M,B]=y.useState("");y.useEffect(()=>{const Ye=localStorage.getItem("maintenanceTeamFilterPresets");Ye&&oe(JSON.parse(Ye))},[]);const X=T&&(O||Y);y.useEffect(()=>{const Ye=[U,ne].filter(Boolean).length+(X?1:0);W(Ye)},[U,ne,X]);const K=y.useMemo(()=>{const Ye={};return U&&(Ye.company=U),ne&&(Ye.name=ne),Object.assign(Ye,el(T,O,Y)),Ye},[U,ne,T,O,Y]),we=["creation desc","creation asc","modified desc","modified asc","name asc","name desc","maintenance_team_name asc","maintenance_team_name desc"].includes(he)?he:"creation desc",{teams:be,loading:ke,error:Me,totalCount:z,refetch:Ne}=jP({filters:K,limit_start:(c-1)*m,limit_page_length:m,order_by:we});y.useEffect(()=>{!ke&&!h&&g(!0)},[ke,h]);const Xe=y.useRef(!1);y.useEffect(()=>{if(!Xe.current){Xe.current=!0;return}i(Ye=>{const ft=new URLSearchParams(Ye);return T?ft.set("date_filter_by",T):ft.delete("date_filter_by"),O?ft.set("date_start",O):ft.delete("date_start"),Y?ft.set("date_end",Y):ft.delete("date_end"),U?ft.set("company",U):ft.delete("company"),ne?ft.set("team_name",ne):ft.delete("team_name"),he&&he!=="creation desc"?ft.set("sort_by",he):ft.delete("sort_by"),ft.set("page","1"),ft})},[T,O,Y,U,ne,he]),y.useEffect(()=>{b(new Set)},[T,O,Y,U,ne,c]);const gt=Ye=>Ye?new Date(Ye).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",St=()=>{E(""),R(""),P(""),ce("creation desc"),J(""),ye(""),i(Ye=>{const ft=new URLSearchParams(Ye);return ft.delete("date_filter_by"),ft.delete("date_start"),ft.delete("date_end"),ft.delete("sort_by"),ft.delete("company"),ft.delete("team_name"),ft.set("page","1"),ft})},Ht=X||!!U||!!ne,Mt=()=>{if(!M.trim()){alert("Please enter a filter name");return}const Ye={id:Date.now(),name:M,filters:{dateFilterBy:T,dateStart:O,dateEnd:Y,sortBy:he,companyFilter:U,teamNameFilter:ne}},ft=[...I,Ye];oe(ft),B(""),F(!1),localStorage.setItem("maintenanceTeamFilterPresets",JSON.stringify(ft))},Te=Ye=>{const ft=Ye.filters;E(ft.dateFilterBy||""),R(ft.dateStart||""),P(ft.dateEnd||""),ce(ft.sortBy||"creation desc"),J(ft.companyFilter||""),ye(ft.teamNameFilter||"")},Qt=Ye=>{const ft=I.filter($t=>$t.id!==Ye);oe(ft),localStorage.setItem("maintenanceTeamFilterPresets",JSON.stringify(ft))},zt=Ye=>{b(ft=>{const $t=new Set(ft);return $t.has(Ye)?$t.delete(Ye):$t.add(Ye),$t})},Wt=()=>{p.size===be.length?b(new Set):b(new Set(be.map(Ye=>Ye.name)))},Vt=be.length>0&&p.size===be.length,va=p.size>0&&p.size<be.length,ta=y.useCallback(()=>Q(null,null,function*(){const Ye=[];let ft=0;const $t=100;let na=!0;const Ze=Ks(K);for(;na;)try{const Ie=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Asset Maintenance Team",filters:Ze.length>0?Ze:{},fields:["*"],limit_start:ft*$t,limit_page_length:$t,order_by:we})})).json()).message||[];Ye.push(...Ie),Ie.length<$t?na=!1:ft++,ft>100&&(console.warn("Export safety limit reached"),na=!1)}catch(lt){throw console.error("Error fetching teams for export:",lt),lt}return Ye}),[K]),sa=(Ye,ft,$t)=>Q(null,null,function*(){k(!0);try{let na=[];switch(Ye){case"selected":na=be.filter(lt=>p.has(lt.name));break;case"all_on_page":na=be;break;case"all_with_filters":na=yield ta();break}if(na.length===0){alert(t("assets.noDataToExport"));return}const Ze=$t.map(lt=>{var aa;return((aa=r.find(Ie=>Ie.key===lt))==null?void 0:aa.label)||lt});if(ft==="csv"){const lt=[Ze.join(","),...na.map(ve=>$t.map(Oe=>{let ht=ve[Oe]||"";return typeof ht=="string"&&(ht.includes(",")||ht.includes('"')||ht.includes(`
`))&&(ht=`"${ht.replace(/"/g,'""')}"`),ht}).join(","))].join(`
`),aa=new Blob(["\uFEFF"+lt],{type:"text/csv;charset=utf-8;"}),Ie=URL.createObjectURL(aa),Nt=document.createElement("a");Nt.href=Ie,Nt.download=`maintenance_teams_export_${new Date().toISOString().split("T")[0]}.csv`,Nt.click(),URL.revokeObjectURL(Ie)}else if(ft==="excel"){const lt=[Ze,...na.map(Nt=>$t.map(ve=>Nt[ve]||""))],aa=Ja.aoa_to_sheet(lt),Ie=Ja.book_new();Ja.book_append_sheet(Ie,aa,"Maintenance Teams"),$i(Ie,`maintenance_teams_export_${new Date().toISOString().split("T")[0]}.xlsx`)}_(!1),b(new Set)}catch(na){console.error("Export failed:",na),alert(`Export failed: ${na instanceof Error?na.message:"Unknown error"}`)}finally{k(!1)}}),ra=Ye=>Q(null,null,function*(){try{if(!(yield fetch(`/api/resource/Asset Maintenance Team/${encodeURIComponent(Ye)}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to delete");D(null),Ne(),alert(t("maintenance.deletedSuccessfully"))}catch(ft){alert(`Failed to delete: ${ft instanceof Error?ft.message:"Unknown error"}`)}});return ke&&!h?e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("maintenance.loadingTeams")})]})}):Me?e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:t("maintenance.errorLoadingTeams")}),e.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:Me}),e.jsx("button",{onClick:Ne,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:t("common.tryAgain")})]})}):e.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fc,{className:"text-3xl text-indigo-600 dark:text-indigo-400"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:t("maintenance.listTitle")}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t("issues.listTotal"),": ",z,p.size>0&&e.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",p.size," ",t("issues.listSelected")]}),ke&&h&&e.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[e.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-blue-500"}),t("common.filtering")]})]})]})]})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:()=>ee(!se),className:`px-4 py-2 rounded-lg flex items-center gap-2 transition-colors ${se||Ht?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300":"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600"}`,children:[e.jsx(ds,{}),t("listPages.filters"),te>0&&e.jsx("span",{className:"bg-blue-600 text-white text-xs px-1.5 py-0.5 rounded-full",children:te})]}),e.jsxs("button",{onClick:Ne,disabled:ke,className:"px-4 py-2 rounded-lg bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 flex items-center gap-2 disabled:opacity-50",children:[e.jsx(vn,{className:ke?"animate-spin":""}),t("listPages.refresh")]}),e.jsxs("button",{onClick:()=>_(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",disabled:z===0,children:[e.jsx(Os,{}),e.jsx("span",{className:"font-medium",children:t("listPages.export")}),p.size>0&&e.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:p.size})]}),e.jsxs("button",{onClick:()=>a("/maintenance-teams/new"),className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow-lg transition-all hover:shadow-xl",children:[e.jsx(Zs,{}),e.jsx("span",{className:"font-medium",children:t("maintenance.newMaintenanceTeam")})]})]})]}),se&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[e.jsx("div",{className:"bg-gradient-to-r from-indigo-500 to-indigo-600 dark:from-indigo-600 dark:to-indigo-700 px-4 py-3 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ds,{className:"text-white",size:16}),e.jsx("h3",{className:"text-white font-semibold text-sm",children:t("listPages.filters")}),te>0&&e.jsx("span",{className:"bg-white text-indigo-600 px-2 py-0.5 rounded-full text-xs font-bold",children:te})]}),Ht&&e.jsx("div",{className:"flex-1 overflow-x-auto scrollbar-hide mx-2",children:e.jsxs("div",{className:"flex items-center gap-2 py-1",children:[X&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-amber-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t(T==="creation"?"filters.createdDate":"filters.latestModifiedDate"),":"]})," ",[O,Y].filter(Boolean).join(" "),e.jsx("button",{onClick:()=>{E(""),R(""),P("")},className:"hover:text-red-500",children:e.jsx(wt,{className:"text-[9px]"})})]}),U&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-green-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("filters.hospital"),":"]})," ",U,e.jsx("button",{onClick:()=>J(""),className:"hover:text-red-500",children:e.jsx(wt,{className:"text-[9px]"})})]}),ne&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("maintenance.teamName"),":"]})," ",ne,e.jsx("button",{onClick:()=>ye(""),className:"hover:text-red-500",children:e.jsx(wt,{className:"text-[9px]"})})]})]})}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[te>0&&e.jsxs("button",{onClick:()=>F(!0),className:"px-3 py-1.5 bg-white text-indigo-600 hover:bg-indigo-50 rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[e.jsx(Or,{size:12}),e.jsx("span",{className:"hidden sm:inline",children:t("listPages.saveFilterPreset")})]}),Ht&&e.jsxs("button",{onClick:St,className:"px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[e.jsx(wt,{size:12}),e.jsx("span",{className:"hidden sm:inline",children:t("listPages.clearFilters")})]})]})]})}),e.jsxs("div",{className:"p-4",children:[I.length>0&&e.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[e.jsx(Tc,{className:"text-yellow-500",size:12}),t("inspections.savedFilters")]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:I.map(Ye=>e.jsxs("div",{className:"group relative inline-flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-purple-100 to-indigo-100 dark:from-purple-900/30 dark:to-indigo-900/30 border border-purple-200 dark:border-purple-700 rounded-lg hover:shadow-md transition-all",children:[e.jsx("button",{onClick:()=>Te(Ye),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:Ye.name}),e.jsx("button",{onClick:()=>Qt(Ye.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:e.jsx(Na,{size:10})})]},Ye.id))})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3 mb-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.sortBy")}),e.jsxs("select",{value:he,onChange:Ye=>{ce(Ye.target.value),d(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"creation desc",children:t("filters.sortCreationNewest")}),e.jsx("option",{value:"creation asc",children:t("filters.sortCreationOldest")}),e.jsx("option",{value:"modified desc",children:t("filters.sortModifiedNewest")}),e.jsx("option",{value:"modified asc",children:t("filters.sortModifiedOldest")}),e.jsx("option",{value:"name asc",children:t("filters.sortNameAsc")}),e.jsx("option",{value:"name desc",children:t("filters.sortNameDesc")}),e.jsx("option",{value:"maintenance_team_name asc",children:t("filters.sortTeamNameAsc")}),e.jsx("option",{value:"maintenance_team_name desc",children:t("filters.sortTeamNameDesc")})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.filterBy")}),e.jsxs("select",{value:T,onChange:Ye=>{const ft=Ye.target.value;E(ft),d(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("filters.filterBy")}),e.jsx("option",{value:"creation",children:t("filters.createdDate")}),e.jsx("option",{value:"modified",children:t("filters.latestModifiedDate")})]})]}),T&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.startDate")}),e.jsx("input",{type:"date",value:O,onChange:Ye=>{const ft=Ye.target.value;R(ft),Y&&ft>Y&&P(ft),d(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.endDate")}),e.jsx("input",{type:"date",value:Y,onChange:Ye=>{P(Ye.target.value),d(1)},min:O||void 0,className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"relative z-[60]",children:[e.jsx(Ut,{label:"Hospital",doctype:"Company",value:U,onChange:Ye=>{J(Ye),d(1)},placeholder:"Select Hospital",disabled:!1,compact:!0}),U&&e.jsx("button",{onClick:()=>J(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[59]",children:[e.jsx(Ut,{label:t("maintenance.teamName"),doctype:"Asset Maintenance Team",value:ne,onChange:Ye=>{ye(Ye),d(1)},placeholder:t("maintenance.selectTeam"),disabled:!1,compact:!0}),ne&&e.jsx("button",{onClick:()=>ye(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]})]})]})]})]}),ae&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:t("listPages.saveFilterPreset")}),e.jsx("input",{type:"text",value:M,onChange:Ye=>B(Ye.target.value),onKeyDown:Ye=>{Ye.key==="Enter"&&(Ye.preventDefault(),Mt())},placeholder:t("listPages.enterFilterName"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white mb-4",autoFocus:!0}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>{F(!1),B("")},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",children:t("common.cancel")}),e.jsxs("button",{onClick:Mt,className:"px-4 py-2 text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 rounded-md transition-colors flex items-center gap-2",children:[e.jsx(Or,{size:12}),t("listPages.saveFilter")]})]})]})}),e.jsx(CP,{isOpen:j,onClose:()=>_(!1),selectedCount:p.size,totalCount:z,pageCount:be.length,onExport:sa,isExporting:N,exportColumns:r}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700 overflow-hidden relative",children:[ke&&h&&e.jsx("div",{className:"absolute inset-0 bg-white/60 dark:bg-gray-800/60 flex items-center justify-center z-10 backdrop-blur-[1px]",children:e.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[e.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-indigo-500"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:t("listPages.filtering")})]})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left",children:e.jsx("button",{onClick:Wt,className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors",title:t(Vt?"listPages.deselectAllTitle":"listPages.selectAllTitle"),children:Vt?e.jsx(Es,{className:"text-indigo-600 dark:text-indigo-400",size:18}):va?e.jsxs("div",{className:"relative",children:[e.jsx(Ar,{size:18}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):e.jsx(Ar,{size:18})})}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("maintenance.teamName")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("maintenance.managerName")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("commonFields.hospital")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("maintenance.expertise")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("commonFields.createdOn")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("listPages.actions")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:be.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-12 text-center text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(fc,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),e.jsx("p",{children:t("listPages.noMaintenanceTeamsFound")}),Ht?e.jsx("button",{onClick:St,className:"mt-4 text-indigo-600 dark:text-indigo-400 hover:underline",children:t("common.clearFilters")}):e.jsx("button",{onClick:()=>a("/maintenance-teams/new"),className:"mt-4 text-indigo-600 dark:text-indigo-400 hover:underline",children:t("listPages.createFirstTeam")})]})})}):be.map(Ye=>e.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer transition-colors ${p.has(Ye.name)?"bg-indigo-50 dark:bg-indigo-900/20":""}`,onClick:()=>a(`/maintenance-teams/${Ye.name}`),children:[e.jsx("td",{className:"px-4 py-3",onClick:ft=>ft.stopPropagation(),children:e.jsx("button",{onClick:()=>zt(Ye.name),className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors",children:p.has(Ye.name)?e.jsx(Es,{className:"text-indigo-600 dark:text-indigo-400",size:18}):e.jsx(Ar,{size:18})})}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:Ye.maintenance_team_name}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:Ye.name})]}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"text-sm text-gray-900 dark:text-white",children:Ye.maintenance_manager_name||"-"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:Ye.maintenance_manager||"-"})]}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:Ye.company||"-"})}),e.jsx("td",{className:"px-4 py-3",children:Ye.custom_expertise?e.jsx("span",{className:"inline-flex px-2 py-1 text-xs font-medium rounded-full bg-indigo-100 text-indigo-800 dark:bg-indigo-900/30 dark:text-indigo-300",children:Ye.custom_expertise}):e.jsx("span",{className:"text-gray-400",children:"-"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:gt(Ye.creation)})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1",onClick:ft=>ft.stopPropagation(),children:[e.jsx("button",{onClick:()=>a(`/maintenance-teams/${Ye.name}`),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:t("maintenance.viewDetails"),children:e.jsx(ri,{})}),e.jsx("button",{onClick:()=>a(`/maintenance-teams/${Ye.name}`),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:t("maintenance.editTeam"),children:e.jsx(Fr,{})}),e.jsx("button",{onClick:()=>a(`/maintenance-teams/new?duplicate=${Ye.name}`),className:"text-purple-600 dark:text-purple-400 hover:text-purple-900 dark:hover:text-purple-300 p-2 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded transition-colors",title:t("maintenance.duplicateTeam"),children:e.jsx(Wd,{})}),e.jsx("button",{onClick:()=>D(Ye.name),className:"text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300 p-2 hover:bg-red-50 dark:hover:bg-red-900/30 rounded transition-colors",title:t("maintenance.deleteTeam"),children:e.jsx(Na,{})})]})})]},Ye.name))})]})}),e.jsx(Rc,{currentPage:c,totalCount:z,pageSize:m,itemLabel:t("pagination.teams"),onPageChange:Ye=>d(Ye)})]}),C&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:e.jsx(Na,{className:"text-red-600 dark:text-red-400 text-xl"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:t("maintenance.deleteTeam")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:t("maintenance.deleteConfirmMessage")}),e.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-md p-3 mb-4",children:e.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[e.jsxs("strong",{children:[t("maintenance.team"),":"]})," ",C]})}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>D(null),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-lg transition-colors",children:t("common.cancel")}),e.jsxs("button",{onClick:()=>ra(C),className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors flex items-center gap-2",children:[e.jsx(Na,{}),t("maintenance.deleteTeamButton")]})]})]})]})})}),e.jsx("style",{children:`
@keyframes scale-in { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.animate-scale-in { animation: scale-in 0.2s ease-out; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
.scrollbar-hide::-webkit-scrollbar { display: none; }
`})]})},EP=()=>{var ae;const{t}=ca(),{teamName:a}=xo(),[r]=Qs(),s=qa(),i=a==="new",c=r.get("duplicate"),[d,m]=y.useState({maintenance_team_name:"",maintenance_manager:"",maintenance_manager_name:"",company:"",custom_expertise:"",maintenance_team_members:[]}),{team:h,loading:g,error:p,refetch:b}=NP(i?c||null:a||null),{createTeam:j,updateTeam:_,deleteTeam:N,getUserFullName:k,loading:C}=SP(),[D,T]=y.useState(i),[E,O]=y.useState(!1),[R,Y]=y.useState(null),[P,U]=y.useState(null),J=F=>Q(null,null,function*(){if(!F)return{exists:!1};try{const M=yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},credentials:"include",body:JSON.stringify({doctype:"Asset Maintenance Team",filters:{},fields:["name","maintenance_team_name","maintenance_team_members.team_member"],limit_page_length:0})});if(!M.ok)return yield ne(F);const X=(yield M.json()).message||[];for(const K of X)if(!(K.name===a||K.name===(h==null?void 0:h.name))&&K["maintenance_team_members.team_member"]===F)return{exists:!0,teamName:K.maintenance_team_name||K.name};return yield ne(F)}catch(M){return console.error("Error checking member in other teams:",M),yield ne(F)}}),ne=F=>Q(null,null,function*(){var M,B;try{const X=yield fetch('/api/resource/Asset Maintenance Team?fields=["name","maintenance_team_name"]&limit_page_length=0',{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!X.ok)return{exists:!1};const we=(yield X.json()).data||[];for(const be of we){if(be.name===a||be.name===(h==null?void 0:h.name))continue;const ke=yield fetch(`/api/resource/Asset Maintenance Team/${encodeURIComponent(be.name)}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!ke.ok)continue;const Me=yield ke.json();if((((M=Me.data)==null?void 0:M.maintenance_team_members)||[]).some(Xe=>Xe.team_member===F))return{exists:!0,teamName:((B=Me.data)==null?void 0:B.maintenance_team_name)||be.name}}return{exists:!1}}catch(X){return console.error("Fallback check failed:",X),{exists:!1}}});y.useEffect(()=>{var F;h&&(m({maintenance_team_name:i&&c?`${h.maintenance_team_name} (Copy)`:h.maintenance_team_name||"",maintenance_manager:h.maintenance_manager||"",maintenance_manager_name:h.maintenance_manager_name||"",company:h.company||"",custom_expertise:h.custom_expertise||"",maintenance_team_members:((F=h.maintenance_team_members)==null?void 0:F.map((M,B)=>Se(ue({},M),{idx:B+1,name:i?void 0:M.name})))||[]}),i||T(!1))},[h,i,c]);const ye=F=>{const{name:M,value:B}=F.target;m(X=>Se(ue({},X),{[M]:B}))},he=F=>Q(null,null,function*(){if(m(M=>Se(ue({},M),{maintenance_manager:F})),F){const M=yield k(F);m(B=>Se(ue({},B),{maintenance_manager_name:M}))}else m(M=>Se(ue({},M),{maintenance_manager_name:""}))}),ce=(F,M,B)=>Q(null,null,function*(){var X;if(M==="team_member"&&B){if((X=d.maintenance_team_members)==null?void 0:X.some((z,Ne)=>Ne!==F&&z.team_member===B)){nt.error("This member is already added to this team!",{position:"top-right",autoClose:4e3,icon:e.jsx(ka,{})});return}U(F),nt.info("Checking member availability...",{position:"top-right",autoClose:2e3,icon:()=>e.jsx("span",{children:"🔍"})});const{exists:we,teamName:be}=yield J(B);if(U(null),we){nt.error(e.jsxs("div",{children:[e.jsx("strong",{children:"Cannot add member!"}),e.jsx("br",{}),e.jsxs("span",{className:"text-sm",children:["This member is already assigned to: ",e.jsx("b",{children:be})]})]}),{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})});return}const ke=yield k(B),Me=[...d.maintenance_team_members||[]];Me[F]=Se(ue({},Me[F]),{team_member:B,full_name:ke}),m(z=>Se(ue({},z),{maintenance_team_members:Me})),nt.success("Member added successfully!",{position:"top-right",autoClose:2e3,icon:e.jsx(ea,{})})}else{const K=[...d.maintenance_team_members||[]];K[F]=Se(ue({},K[F]),{[M]:B}),m(we=>Se(ue({},we),{maintenance_team_members:K}))}}),se=()=>{var M;const F={team_member:"",full_name:"",maintenance_role:"",idx:(((M=d.maintenance_team_members)==null?void 0:M.length)||0)+1};m(B=>Se(ue({},B),{maintenance_team_members:[...B.maintenance_team_members||[],F]}))},ee=F=>{var B;const M=((B=d.maintenance_team_members)==null?void 0:B.filter((X,K)=>K!==F))||[];M.forEach((X,K)=>{X.idx=K+1}),m(X=>Se(ue({},X),{maintenance_team_members:M})),Y(null)},te=()=>Q(null,null,function*(){var F;if(!d.maintenance_team_name){nt.error("Please enter a team name",{position:"top-right",autoClose:4e3,icon:e.jsx(ka,{})});return}try{const M=Se(ue({},d),{maintenance_team_members:(F=d.maintenance_team_members)==null?void 0:F.map(B=>({team_member:B.team_member,full_name:B.full_name,maintenance_role:B.maintenance_role})).filter(B=>B.team_member)});if(i){const B=yield j(M);nt.success("Maintenance Team created successfully!",{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),s(`/maintenance-teams/${B.name}`)}else yield _(a,M),nt.success("Maintenance Team updated successfully!",{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),T(!1),b()}catch(M){const B=M instanceof Error?M.message:"Unknown error";nt.error(`Failed to save: ${B}`,{position:"top-right",autoClose:6e3,icon:e.jsx(ka,{})})}}),W=()=>Q(null,null,function*(){try{yield N(a),nt.success("Maintenance Team deleted successfully!",{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),s(-1)}catch(F){const M=F instanceof Error?F.message:"Unknown error";nt.error(`Failed to delete: ${M}`,{position:"top-right",autoClose:6e3,icon:e.jsx(ka,{})})}}),I=y.useCallback(F=>!D,[D]),oe=F=>F?new Date(F).toLocaleString():"-";return g?e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading maintenance team..."})]})}):p&&!i?e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:t("maintenance.errorLoadingTeam")}),e.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:p}),e.jsx("button",{onClick:()=>s(-1),className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded",children:t("maintenance.backToTeams")})]})}):e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[e.jsx(Xd,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Lc}),e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>s(-1),className:"text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200",children:e.jsx(en,{size:20})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white flex items-center gap-3",children:[e.jsx(fc,{className:"text-indigo-500"}),i?"New Maintenance Team":(h==null?void 0:h.maintenance_team_name)||"Maintenance Team"]}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:i?"Create a new maintenance team":h==null?void 0:h.name})]})]}),e.jsxs("div",{className:"flex gap-3",children:[!i&&!D&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>T(!0),className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[e.jsx(Fr,{}),t("common.edit")]}),e.jsxs("button",{onClick:()=>O(!0),className:"bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[e.jsx(Na,{}),t("common.delete")]})]}),D&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{i?s(-1):(T(!1),b())},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg",children:t("common.cancel")}),e.jsxs("button",{onClick:te,disabled:C,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[e.jsx(Or,{}),t(C?"common.saving":"common.save")]})]})]})]}),E&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(fa,{className:"text-red-500 text-xl mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:t("maintenance.deleteTeam")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:t("confirmations.cannotUndo")})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>O(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:t("common.cancel")}),e.jsx("button",{onClick:W,disabled:C,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg disabled:opacity-50",children:t(C?"common.deleting":"common.delete")})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(fc,{className:"text-indigo-500"}),t("maintenance.teamInformation")]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t("maintenance.teamName")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",name:"maintenance_team_name",value:d.maintenance_team_name,onChange:ye,disabled:I("maintenance_team_name"),placeholder:t("maintenance.enterTeamName"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),e.jsx("div",{children:e.jsx(Ut,{label:t("commonFields.hospital"),doctype:"Company",value:d.company||"",onChange:F=>m(Se(ue({},d),{company:F})),disabled:I("company"),placeholder:t("maintenance.selectHospital")})}),e.jsx("div",{children:e.jsx(Ut,{label:t("maintenance.expertise"),doctype:"Issue Type",value:d.custom_expertise||"",onChange:F=>m(Se(ue({},d),{custom_expertise:F})),disabled:I("custom_expertise"),placeholder:t("maintenance.selectExpertise"),allowQuickCreate:!0})}),e.jsx("div",{children:e.jsx(Ut,{label:t("maintenance.manager"),doctype:"User",value:d.maintenance_manager||"",onChange:he,disabled:I("maintenance_manager"),placeholder:t("maintenance.selectManager")})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("maintenance.managerName")}),e.jsx("input",{type:"text",value:d.maintenance_manager_name||"",disabled:!0,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white flex items-center gap-2",children:[e.jsx(Q5,{className:"text-green-500"}),"Team Members"]}),D&&e.jsxs("button",{onClick:se,disabled:P!==null,className:"bg-green-600 hover:bg-green-700 text-white px-3 py-1.5 rounded-lg flex items-center gap-2 text-sm disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(Zs,{size:12}),"Add Member"]})]}),d.maintenance_team_members&&d.maintenance_team_members.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"#"}),e.jsxs("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:["Team Member",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"Full Name"}),e.jsxs("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:["Role",e.jsx("span",{className:"text-red-500",children:"*"})]}),D&&e.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"Action"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:d.maintenance_team_members.map((F,M)=>e.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 ${P===M?"opacity-70":""}`,children:[e.jsx("td",{className:"px-3 py-2 text-sm text-gray-600 dark:text-gray-400",children:M+1}),e.jsx("td",{className:"px-3 py-2",children:D?e.jsxs("div",{className:"relative",children:[e.jsx(Ut,{label:"",doctype:"User",value:F.team_member||"",onChange:B=>ce(M,"team_member",B),disabled:P!==null,placeholder:t("maintenance.selectUser"),compact:!0}),P===M&&e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2",children:e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-indigo-500"})})]}):e.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:F.team_member||"-"})}),e.jsx("td",{className:"px-3 py-2 text-sm text-gray-600 dark:text-gray-300",children:F.full_name||"-"}),e.jsx("td",{className:"px-3 py-2",children:D?e.jsx(Ut,{label:"",doctype:"Role",value:F.maintenance_role||"",onChange:B=>ce(M,"maintenance_role",B),disabled:P!==null,placeholder:t("maintenance.selectRole"),compact:!0}):e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:F.maintenance_role||"-"})}),D&&e.jsx("td",{className:"px-3 py-2 text-center",children:e.jsx("button",{onClick:()=>Y(M),className:"text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 p-1.5 hover:bg-red-50 dark:hover:bg-red-900/30 rounded transition-colors",title:t("maintenance.removeMember"),children:e.jsx(Na,{size:14})})})]},M))})]})}):e.jsxs("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:[e.jsx(fc,{className:"text-4xl mx-auto mb-2 text-gray-300 dark:text-gray-600"}),e.jsx("p",{children:t("maintenance.noTeamMembersYet")}),D&&e.jsxs("button",{onClick:se,className:"mt-3 text-indigo-600 dark:text-indigo-400 hover:underline",children:["+ ",t("maintenance.addFirstMember")]})]})]}),!i&&e.jsx(Pc,{referenceDoctype:"Asset Maintenance Team",referenceName:a||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5,collapsible:!0,startCollapsed:!1})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(t6,{className:"text-blue-500"}),t("maintenance.teamSummary")]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 bg-indigo-50 dark:bg-indigo-900/30 rounded-lg border border-indigo-200 dark:border-indigo-800",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:t("maintenance.totalMembers")}),e.jsx("p",{className:"text-2xl font-bold text-indigo-600 dark:text-indigo-300",children:((ae=d.maintenance_team_members)==null?void 0:ae.filter(F=>F.team_member).length)||0})]}),d.maintenance_manager_name&&e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:t("maintenance.manager")}),e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:d.maintenance_manager_name})]}),d.company&&e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Hospital"}),e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:d.company})]}),d.custom_expertise&&e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Expertise"}),e.jsx("span",{className:"inline-flex px-2 py-1 text-xs font-medium rounded-full bg-indigo-100 text-indigo-800 dark:bg-indigo-900/30 dark:text-indigo-300",children:d.custom_expertise})]})]})]}),!i&&h&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(Jx,{className:"text-teal-500"}),"Details"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Created"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:oe(h.creation)})]}),e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Last Modified"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:oe(h.modified)})]}),e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Modified By"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:h.modified_by||"-"})]})]})]})]})]}),R!==null&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-sm w-full mx-4 shadow-xl",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(fa,{className:"text-orange-500 text-xl mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Remove Team Member"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Are you sure you want to remove this team member?"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>Y(null),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:"Cancel"}),e.jsx("button",{onClick:()=>ee(R),className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg",children:"Remove"})]})]})})]})};class AP{constructor(){Mn(this,"baseURL");this.baseURL=ia.BASE_URL}getCSRFToken(){return Q(this,null,function*(){try{return typeof window!="undefined"&&window.csrf_token?window.csrf_token:null}catch(a){return null}})}getHeaders(){return Q(this,null,function*(){const a={Accept:"application/json","Content-Type":"application/json"},r=yield this.getCSRFToken();return r&&(a["X-Frappe-CSRF-Token"]=r),a})}getInspections(){return Q(this,arguments,function*(a={}){const{filters:r={},fields:s=["name","workflow_state","inspection_type","status","inspection_date","target_closure_date","requested_by","technician_department","linked_corrective_wo_no","observation_note","technical_response","creation","modified","owner","modified_by","custom_delete_status"],limit_start:i=0,limit_page_length:c=20,order_by:d="creation desc"}=a,m=new URLSearchParams;if(m.append("fields",JSON.stringify(s)),m.append("limit_start",i.toString()),m.append("limit_page_length",c.toString()),m.append("order_by",d),Object.keys(r).length>0){const p=Ks(r);p.length>0&&m.append("filters",JSON.stringify(p))}const h=yield fetch(`${this.baseURL}/api/resource/Inspection?${m.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);return{data:(yield h.json()).data||[]}})}getInspection(a){return Q(this,null,function*(){const r=yield fetch(`${this.baseURL}/api/resource/Inspection/${encodeURIComponent(a)}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return(yield r.json()).data})}createInspection(a){return Q(this,null,function*(){const r=yield fetch(`${this.baseURL}/api/resource/Inspection`,{method:"POST",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(a)});if(!r.ok){const i=yield r.json().catch(()=>({}));throw new Error(i.message||`HTTP error! status: ${r.status}`)}return(yield r.json()).data})}updateInspection(a,r){return Q(this,null,function*(){const s=yield fetch(`${this.baseURL}/api/resource/Inspection/${encodeURIComponent(a)}`,{method:"PUT",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(r)});if(!s.ok){const c=yield s.json().catch(()=>({}));throw new Error(c.message||`HTTP error! status: ${s.status}`)}return(yield s.json()).data})}deleteInspection(a){return Q(this,null,function*(){const r=yield fetch(`${this.baseURL}/api/resource/Inspection/${encodeURIComponent(a)}`,{method:"DELETE",headers:yield this.getHeaders(),credentials:"include"});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`)})}getInspectionCount(){return Q(this,arguments,function*(a={}){var c,d;const r=new URLSearchParams;if(r.append("fields",JSON.stringify(["count(name) as count"])),Object.keys(a).length>0){const m=Ks(a);m.length>0&&r.append("filters",JSON.stringify(m))}const s=yield fetch(`${this.baseURL}/api/resource/Inspection?${r.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return((d=(c=(yield s.json()).data)==null?void 0:c[0])==null?void 0:d.count)||0})}getCurrentUser(){return Q(this,null,function*(){try{const a=yield fetch(`${this.baseURL}/api/method/frappe.auth.get_logged_user`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return(yield a.json()).message||""}catch(a){return console.error("Error getting current user:",a),""}})}}const bc=new AP;function OP(t={}){const[a,r]=y.useState([]),[s,i]=y.useState(!0),[c,d]=y.useState(null),[m,h]=y.useState(0),g=y.useCallback(()=>Q(null,null,function*(){try{i(!0),d(null);const[p,b]=yield Promise.all([bc.getInspections(t),bc.getInspectionCount(t.filters||{})]);r(p.data),h(b)}catch(p){const b=p instanceof Error?p.message:"Failed to fetch inspections";d(b),console.error("Error fetching inspections:",p)}finally{i(!1)}}),[JSON.stringify(t)]);return y.useEffect(()=>{g()},[g]),{inspections:a,loading:s,error:c,totalCount:m,refetch:g}}function DP(t){const[a,r]=y.useState(null),[s,i]=y.useState(!0),[c,d]=y.useState(null),m=y.useCallback(()=>Q(null,null,function*(){if(!t){i(!1);return}try{i(!0),d(null);const h=yield bc.getInspection(t);r(h)}catch(h){const g=h instanceof Error?h.message:"Failed to fetch inspection";d(g),console.error("Error fetching inspection:",h)}finally{i(!1)}}),[t]);return y.useEffect(()=>{m()},[m]),{inspection:a,loading:s,error:c,refetch:m}}function MP(){const[t,a]=y.useState(!1),[r,s]=y.useState(null);return{createInspection:m=>Q(null,null,function*(){try{return a(!0),s(null),yield bc.createInspection(m)}catch(h){const g=h instanceof Error?h.message:"Failed to create inspection";throw s(g),h}finally{a(!1)}}),updateInspection:(m,h)=>Q(null,null,function*(){try{return a(!0),s(null),yield bc.updateInspection(m,h)}catch(g){const p=g instanceof Error?g.message:"Failed to update inspection";throw s(p),g}finally{a(!1)}}),deleteInspection:m=>Q(null,null,function*(){try{a(!0),s(null),yield bc.deleteInspection(m)}catch(h){const g=h instanceof Error?h.message:"Failed to delete inspection";throw s(g),h}finally{a(!1)}}),loading:t,error:r}}const LP=({isOpen:t,onClose:a,permittedIssueTypes:r=[],isAdmin:s=!0})=>{const{t:i}=ca(),[c,d]=y.useState(!1),[m,h]=y.useState(null),[g,p]=y.useState([]),[b,j]=y.useState([]),[_,N]=y.useState(!0),[k,C]=y.useState(!1),[D,T]=y.useState([]),[E,O]=y.useState(""),[R,Y]=y.useState(""),[P,U]=y.useState(""),J="Inspection";y.useEffect(()=>{if(!s)return;Q(null,null,function*(){try{const Me=yield(yield fetch('/api/resource/Issue Type?fields=["name"]&limit_page_length=0&order_by=name asc',{headers:{Accept:"application/json"},credentials:"include"})).json();Me.data&&T(Me.data.map(z=>z.name))}catch(ke){console.error(ke)}})},[s]),y.useEffect(()=>{!s&&r.length===1?U(r[0]):U("")},[r,s]);const ne=y.useCallback(()=>Q(null,null,function*(){var be;d(!0),h(null);try{const ke={};E&&(ke.status=E),R&&(ke.only_late=R),P?ke.work_order_type=P:!s&&r.length===1&&(ke.work_order_type=r[0]);const z=yield(yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({report_name:J,filters:ke,ignore_prepared_report:1})})).json();if(z.exc)throw new Error(z.exc);if(z.message)if(((be=z.message.columns)==null?void 0:be.length)>0&&j(z.message.columns),z.message.result){let Ne=z.message.result;!s&&r.length>1&&!P&&(Ne=Ne.filter(Xe=>r.includes(Xe.work_order_type))),p(Ne)}else p([])}catch(ke){console.error("Error fetching report:",ke),h(ke instanceof Error?ke.message:"Failed to fetch report data"),p([])}finally{d(!1)}}),[E,R,P,s,r]);y.useEffect(()=>{t&&ne()},[t,ne]),y.useEffect(()=>{const be=ke=>{ke.key==="Escape"&&t&&a()};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[t,a]),y.useEffect(()=>(document.body.style.overflow=t?"hidden":"unset",()=>{document.body.style.overflow="unset"}),[t]);const ye=()=>{O(""),Y(""),(s||r.length!==1)&&U("")},he=()=>g.filter(be=>be.status!=="TOTAL"),ce=()=>g.find(be=>be.status==="TOTAL"),se=be=>{switch(be==null?void 0:be.toLowerCase()){case"closed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300";case"in progress":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-300";case"open":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300";default:return"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300"}},ee=be=>be==="Yes"?"bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300":"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300",te=(be,ke)=>{if(be==null||be==="")return"-";switch(ke.fieldtype){case"Date":return new Date(be).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});case"Datetime":return new Date(be).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});default:return String(be)}},W=()=>{const be=he();if(be.length){C(!0);try{const ke=[b.map(Xe=>Xe.label).join(","),...be.map(Xe=>b.map(gt=>{let St=Xe[gt.fieldname]||"";return typeof St=="string"&&(St.includes(",")||St.includes('"')||St.includes(`
`))&&(St=`"${St.replace(/"/g,'""')}"`),St}).join(","))].join(`
`),Me=new Blob(["\uFEFF"+ke],{type:"text/csv;charset=utf-8;"}),z=URL.createObjectURL(Me),Ne=document.createElement("a");Ne.href=z,Ne.download=`inspection_report_${new Date().toISOString().split("T")[0]}.csv`,Ne.click(),URL.revokeObjectURL(z)}finally{C(!1)}}},I=()=>{const be=he();if(be.length){C(!0);try{const ke=Ja.aoa_to_sheet([b.map(z=>z.label),...be.map(z=>b.map(Ne=>z[Ne.fieldname]||""))]);ke["!cols"]=b.map(z=>({wch:z.width?Math.floor(z.width/7):15}));const Me=Ja.book_new();Ja.book_append_sheet(Me,ke,"Inspection Report"),$i(Me,`inspection_report_${new Date().toISOString().split("T")[0]}.xlsx`)}finally{C(!1)}}},oe=()=>{const be=he(),ke=ce(),Me=window.open("","_blank");if(!Me){alert("Please allow popups to print.");return}Me.document.write(`<!DOCTYPE html><html><head><title>Inspection Report</title>
<style>
body{font-family:Arial,sans-serif;margin:20px}
h1{text-align:center;color:#333;margin-bottom:20px}
.meta{text-align:center;color:#666;margin-bottom:20px;font-size:12px}
.summary{display:flex;justify-content:center;gap:30px;margin-bottom:20px;padding:15px;background:#f8f9fa;border-radius:8px}
.summary-item{text-align:center}.summary-label{font-size:11px;color:#666}
.summary-value{font-size:20px;font-weight:bold;color:#333}.summary-value.late{color:#DC2626}
table{width:100%;border-collapse:collapse;font-size:11px}
th{background-color:#0D9488;color:white;padding:10px 8px;text-align:left;font-weight:600}
td{padding:8px;border-bottom:1px solid #ddd}
tr:nth-child(even){background:#f9f9f9}
.status-open{color:#2563EB;font-weight:500}
.status-closed{color:#059669;font-weight:500}
.status-inprogress{color:#D97706;font-weight:500}
.late-yes{color:#DC2626;font-weight:600}.late-no{color:#059669}
@media print{body{margin:0}tr{page-break-inside:avoid}}
</style></head><body>
<h1>Inspection Report</h1>
<div class="meta">
Generated on: ${new Date().toLocaleString()} | Records: ${be.length}
${E?` | Status: ${E}`:""}
${P?` | Dept: ${P}`:""}
${R==="Yes"?" | Only Late":""}
</div>
${ke?`
<div class="summary">
<div class="summary-item"><div class="summary-label">Total Inspections</div><div class="summary-value">${ke.inspection||0}</div></div>
<div class="summary-item"><div class="summary-label">WO Created</div><div class="summary-value">${ke.wo_created||0}</div></div>
<div class="summary-item"><div class="summary-label">Not Closed On Time</div><div class="summary-value late">${ke.not_closed_on_time||0}</div></div>
</div>`:""}
<table>
<thead><tr><th>#</th>${b.map(z=>`<th>${z.label}</th>`).join("")}</tr></thead>
<tbody>
${be.map((z,Ne)=>`
<tr><td>${Ne+1}</td>${b.map(Xe=>{let gt=z[Xe.fieldname]||"-",St="";return Xe.fieldname==="status"&&(String(gt).toLowerCase()==="open"?St="status-open":String(gt).toLowerCase()==="closed"?St="status-closed":String(gt).toLowerCase().includes("progress")&&(St="status-inprogress")),Xe.fieldname==="not_closed_on_time"&&(St=gt==="Yes"?"late-yes":"late-no"),`<td class="${St}">${gt}</td>`}).join("")}</tr>
`).join("")}
</tbody>
</table>
<script>window.onload=function(){window.print()}<\/script>
</body></html>`),Me.document.close()},ae=()=>oe();if(!t)return null;const F=he(),M=ce(),B=!!(E||R||P),X=[E,R,P].filter(Boolean).length,K=s?D:r,we=s||r.length>=1;return e.jsxs("div",{className:"fixed inset-0 z-[80] bg-gray-50 dark:bg-gray-900 flex flex-col",children:[e.jsx("div",{className:"bg-gradient-to-r from-teal-600 to-cyan-600 px-6 py-4 flex-shrink-0 shadow-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:a,className:"p-2 text-white/80 hover:text-white hover:bg-white/20 rounded-lg transition-colors",title:"Go Back",children:e.jsx(en,{size:18})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(bi,{className:"text-white text-xl"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-white",children:"Inspection Report"}),e.jsxs("p",{className:"text-white/70 text-sm",children:[F.length," record",F.length!==1?"s":""," found",P&&e.jsx("span",{className:"ml-2 bg-white/20 px-2 py-0.5 rounded-full text-xs",children:P})]})]})]})]}),e.jsx("button",{onClick:a,className:"p-2 text-white/80 hover:text-white hover:bg-white/20 rounded-lg transition-colors",title:"Close (Esc)",children:e.jsx(wt,{size:20})})]})}),M&&!c&&e.jsx("div",{className:"bg-white dark:bg-gray-800 px-6 py-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-teal-50 dark:bg-teal-900/20 rounded-lg p-4 border border-teal-200 dark:border-teal-800",children:[e.jsx("p",{className:"text-xs text-teal-600 dark:text-teal-400 font-medium",children:"Total Inspections"}),e.jsx("p",{className:"text-2xl font-bold text-teal-700 dark:text-teal-300",children:M.inspection||0})]}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:[e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 font-medium",children:"Work Orders Created"}),e.jsx("p",{className:"text-2xl font-bold text-blue-700 dark:text-blue-300",children:M.wo_created||0})]}),e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 rounded-lg p-4 border border-red-200 dark:border-red-800",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fa,{className:"text-red-500"}),e.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 font-medium",children:"Not Closed On Time"})]}),e.jsx("p",{className:"text-2xl font-bold text-red-700 dark:text-red-300",children:M.not_closed_on_time||0})]})]})}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 px-6 py-3 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("button",{onClick:()=>N(!_),className:"flex items-center gap-2 px-4 py-2 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:[e.jsx(ds,{size:12}),"Filters",B&&e.jsx("span",{className:"bg-teal-100 dark:bg-teal-900/50 text-teal-600 dark:text-teal-400 px-2 py-0.5 rounded-full text-xs font-bold",children:X}),_?e.jsx(As,{size:10}):e.jsx(cs,{size:10})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:ne,disabled:c,className:"p-2.5 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors disabled:opacity-50",title:"Refresh",children:e.jsx(vn,{className:c?"animate-spin":"",size:14})}),e.jsxs("div",{className:"flex items-center gap-1 bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:W,disabled:!F.length||k,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as CSV",children:[e.jsx(Bi,{className:"text-green-600",size:14}),e.jsx("span",{children:"CSV"})]}),e.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),e.jsxs("button",{onClick:I,disabled:!F.length||k,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as Excel",children:[e.jsx(Ui,{className:"text-green-700",size:14}),e.jsx("span",{children:"Excel"})]}),e.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),e.jsxs("button",{onClick:ae,disabled:!F.length,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Export as PDF",children:[e.jsx(Ph,{className:"text-red-600",size:14}),e.jsx("span",{children:"PDF"})]}),e.jsx("div",{className:"w-px h-6 bg-gray-300 dark:bg-gray-600"}),e.jsxs("button",{onClick:oe,disabled:!F.length,className:"px-4 py-2.5 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors flex items-center gap-2 disabled:opacity-50",title:"Print",children:[e.jsx(Fi,{className:"text-purple-600",size:14}),e.jsx("span",{children:"Print"})]})]})]})]}),_&&e.jsxs("div",{className:"mt-4 p-4 bg-gray-50 dark:bg-gray-900/50 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Status"}),e.jsxs("select",{value:E,onChange:be=>O(be.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:"All Status"}),e.jsx("option",{value:"Open",children:"Open"}),e.jsx("option",{value:"In Progress",children:"In Progress"}),e.jsx("option",{value:"Closed",children:"Closed"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Show Only Late"}),e.jsxs("select",{value:R,onChange:be=>Y(be.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:"All Inspections"}),e.jsx("option",{value:"Yes",children:"Only Late (Not Closed On Time)"})]})]}),we&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Technical Department"}),!s&&r.length===1?e.jsxs("div",{className:"w-full px-3 py-2 text-sm border border-gray-200 dark:border-gray-600 rounded-lg bg-gray-50 dark:bg-gray-600 text-gray-700 dark:text-gray-300 flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-teal-400 flex-shrink-0"}),P,e.jsx("span",{className:"ml-auto text-[10px] text-gray-400 dark:text-gray-500 uppercase tracking-wide",children:"Restricted"})]}):e.jsxs("select",{value:P,onChange:be=>U(be.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:s?"All Departments":"Select Department"}),K.map(be=>e.jsx("option",{value:be,children:be},be))]})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs("button",{onClick:ye,disabled:!B,className:"px-4 py-2 text-sm font-medium text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[e.jsx(wt,{size:12}),"Clear Filters"]})})]}),B&&e.jsxs("div",{className:"flex flex-wrap gap-2 mt-3",children:[E&&e.jsxs("span",{className:"text-xs bg-teal-50 dark:bg-teal-900/30 text-teal-700 dark:text-teal-300 border border-teal-200 dark:border-teal-700 px-2 py-1 rounded-full",children:["Status: ",E]}),R&&e.jsx("span",{className:"text-xs bg-red-50 dark:bg-red-900/30 text-red-700 dark:text-red-300 border border-red-200 dark:border-red-700 px-2 py-1 rounded-full",children:"Only Late"}),P&&e.jsxs("span",{className:"text-xs bg-indigo-50 dark:bg-indigo-900/30 text-indigo-700 dark:text-indigo-300 border border-indigo-200 dark:border-indigo-700 px-2 py-1 rounded-full",children:["Dept: ",P]})]})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[c&&e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ya,{className:"animate-spin text-teal-500 text-5xl mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-lg",children:"Loading report data..."})]})}),m&&!c&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-8 text-center max-w-lg mx-auto",children:[e.jsx("p",{className:"text-red-600 dark:text-red-400 mb-4 text-lg",children:m}),e.jsx("button",{onClick:ne,className:"px-6 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-sm font-medium transition-colors",children:"Try Again"})]}),!c&&!m&&F.length===0&&e.jsxs("div",{className:"text-center py-20",children:[e.jsx(Js,{className:"text-gray-300 dark:text-gray-600 text-6xl mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-xl",children:"No data found"}),e.jsx("p",{className:"text-gray-400 dark:text-gray-500 text-sm mt-2",children:"Try adjusting your filters"})]}),!c&&!m&&F.length>0&&e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden shadow-sm",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 sticky top-0",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider w-16",children:"#"}),b.map((be,ke)=>e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider whitespace-nowrap",style:{minWidth:be.width||120},children:be.label},ke))]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:F.map((be,ke)=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400 font-medium",children:ke+1}),b.map((Me,z)=>{const Ne=be[Me.fieldname],Xe=te(Ne,Me);return Me.fieldname==="status"?e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${se(Ne)}`,children:Xe})},z):Me.fieldname==="wo_created"?e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${Ne==="Yes"?"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300":"bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400"}`,children:Xe})},z):Me.fieldname==="not_closed_on_time"?e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${ee(Ne)}`,children:Xe})},z):Me.fieldname==="inspection"?e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx("a",{href:`/asm_app/inspections/${Ne}`,target:"_blank",rel:"noopener noreferrer",className:"text-teal-600 dark:text-teal-400 hover:underline font-medium text-sm",children:Xe})},z):e.jsx("td",{className:"px-4 py-3 text-sm text-gray-700 dark:text-gray-300",title:typeof Ne=="string"&&Ne.length>50?Ne:void 0,children:e.jsx("div",{className:"max-w-xs truncate",children:Xe})},z)})]},ke))})]})})})]}),e.jsx("div",{className:"bg-white dark:bg-gray-800 px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex-shrink-0 shadow-inner",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Showing ",F.length," record",F.length!==1?"s":"",B&&" (filtered)",P&&e.jsxs("span",{className:"ml-2 text-teal-600 dark:text-teal-400",children:["· ",P]})]}),e.jsx("button",{onClick:a,className:"px-6 py-2 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium transition-colors",children:"Close"})]})})]})},RP=({isOpen:t,onClose:a,selectedCount:r,totalCount:s,pageCount:i,onExport:c,isExporting:d,exportColumns:m})=>{const{t:h}=ca(),[g,p]=y.useState(r>0?"selected":"all_with_filters"),[b,j]=y.useState("csv"),[_,N]=y.useState(m.filter(T=>T.default).map(T=>T.key));y.useEffect(()=>{r>0?p("selected"):p("all_with_filters")},[r]);const k=T=>{N(E=>E.includes(T)?E.filter(O=>O!==T):[...E,T])},C=()=>N(m.map(T=>T.key)),D=()=>N(m.filter(T=>T.default).map(T=>T.key));return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] overflow-hidden animate-scale-in",children:[e.jsx("div",{className:"bg-gradient-to-r from-teal-500 to-teal-600 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Os,{className:"text-white text-xl"}),e.jsx("h3",{className:"text-lg font-semibold text-white",children:h("inspections.export.title")})]}),e.jsx("button",{onClick:a,className:"text-white/80 hover:text-white transition-colors",disabled:d,children:e.jsx(wt,{size:20})})]})}),e.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:h("inspections.export.selectData")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="selected"?"border-teal-500 bg-teal-50 dark:bg-teal-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"} ${r===0?"opacity-50 cursor-not-allowed":""}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"selected",checked:g==="selected",onChange:()=>p("selected"),disabled:r===0,className:"text-teal-600 focus:ring-teal-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("inspections.export.selectedRows")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("inspections.export.selectedCount",{count:r})})]}),r>0&&e.jsxs("span",{className:"bg-teal-100 dark:bg-teal-900/40 text-teal-700 dark:text-teal-300 px-2 py-1 rounded text-xs font-medium",children:[r," selected"]})]}),e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="all_on_page"?"border-teal-500 bg-teal-50 dark:bg-teal-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:g==="all_on_page",onChange:()=>p("all_on_page"),className:"text-teal-600 focus:ring-teal-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("inspections.export.currentPage")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("inspections.export.currentPageCount",{count:i})})]}),e.jsxs("span",{className:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 px-2 py-1 rounded text-xs font-medium",children:[i," rows"]})]}),e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="all_with_filters"?"border-teal-500 bg-teal-50 dark:bg-teal-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:g==="all_with_filters",onChange:()=>p("all_with_filters"),className:"text-teal-600 focus:ring-teal-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("inspections.export.allWithFilters")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("inspections.export.allWithFiltersCount",{count:s})})]}),e.jsxs("span",{className:"bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300 px-2 py-1 rounded text-xs font-medium",children:[s," total"]})]})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:h("inspections.export.exportFormat")}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${b==="csv"?"border-teal-500 bg-teal-50 dark:bg-teal-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"format",value:"csv",checked:b==="csv",onChange:()=>j("csv"),className:"text-teal-600 focus:ring-teal-500"}),e.jsx(Bi,{className:"text-teal-600 text-xl"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("inspections.export.csv")}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("inspections.export.csvDesc")})]})]}),e.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${b==="excel"?"border-teal-500 bg-teal-50 dark:bg-teal-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"format",value:"excel",checked:b==="excel",onChange:()=>j("excel"),className:"text-teal-600 focus:ring-teal-500"}),e.jsx(Ui,{className:"text-green-700 text-xl"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("inspections.export.excel")}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("inspections.export.excelDesc")})]})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:h("inspections.export.columnsToExport")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:C,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("inspections.export.selectAll")}),e.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),e.jsx("button",{onClick:D,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("inspections.export.resetToDefault")})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2 max-h-48 overflow-y-auto p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg",children:m.map(T=>e.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${_.includes(T.key)?"bg-teal-100 dark:bg-teal-900/30 text-teal-800 dark:text-teal-300":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-400"}`,children:[e.jsx("input",{type:"checkbox",checked:_.includes(T.key),onChange:()=>k(T.key),className:"rounded text-teal-600 focus:ring-teal-500"}),e.jsx("span",{className:"text-sm truncate",children:h(T.labelKey)})]},T.key))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:h("inspections.export.columnsSelected",{count:_.length})})]})]}),e.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[g==="selected"&&h("inspections.export.exportingSelected",{count:r}),g==="all_on_page"&&h("inspections.export.exportingPage",{count:i}),g==="all_with_filters"&&h("inspections.export.exportingAll",{count:s})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",disabled:d,children:h("common.cancel")}),e.jsx("button",{onClick:()=>c(g,b,_),disabled:_.length===0||d,className:"px-4 py-2 text-sm font-medium text-white bg-teal-600 hover:bg-teal-700 rounded-lg transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:d?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),h("inspections.export.exporting")]}):e.jsxs(e.Fragment,{children:[e.jsx(po,{}),h("inspections.export.exportButton")]})})]})]})]})}):null},PP=t=>{switch(t==null?void 0:t.toLowerCase()){case"open":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";case"in progress":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300";case"closed":return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300";case"pending review":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},FP=t=>{switch(t==null?void 0:t.toLowerCase()){case"draft":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300";case"sent to supervisor":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";case"closed":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},IP=t=>{switch(t==null?void 0:t.toLowerCase()){case"inspection":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";case"safety inspection":return"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},zP=()=>{const{t}=ca(),a=qa(),[r,s]=Qs(),[i,c]=y.useState([]),[d,m]=y.useState(!0),h=y.useMemo(()=>{const fe=parseInt(r.get("page")||"1",10);return Number.isNaN(fe)||fe<1?1:fe},[r]),g=y.useCallback(fe=>{const re=typeof fe=="function"?fe(h):fe;s(Ee=>{const Ge=new URLSearchParams(Ee);return Ge.set("page",String(re)),Ge})},[h,s]),p=[{key:"name",labelKey:"inspections.export.inspectionId",default:!0},{key:"inspection_type",labelKey:"inspections.export.inspectionType",default:!0},{key:"status",labelKey:"inspections.export.status",default:!0},{key:"workflow_state",labelKey:"inspections.export.workflowState",default:!0},{key:"inspection_date",labelKey:"inspections.export.inspectionDate",default:!0},{key:"target_closure_date",labelKey:"inspections.export.targetClosureDate",default:!0},{key:"requested_by",labelKey:"inspections.export.requestedBy",default:!0},{key:"work_order_type",labelKey:"inspections.export.technicalDepartment",default:!1},{key:"extension_no",labelKey:"inspections.export.extensionNo",default:!1},{key:"department",labelKey:"inspections.export.department",default:!1},{key:"location",labelKey:"inspections.export.location",default:!1},{key:"assigned_technician",labelKey:"inspections.export.assignedTechnician",default:!1},{key:"linked_corrective_wo_no",labelKey:"inspections.export.linkedWorkOrder",default:!0},{key:"observation_note",labelKey:"inspections.export.observationNote",default:!1},{key:"technical_response",labelKey:"inspections.export.technicalResponse",default:!1},{key:"creation",labelKey:"inspections.export.createdOn",default:!1},{key:"modified",labelKey:"inspections.export.modifiedOn",default:!1},{key:"owner",labelKey:"inspections.export.createdBy",default:!1}],[b]=y.useState(20),[j,_]=y.useState(!1),[N,k]=y.useState(new Set),[C,D]=y.useState(!1),[T,E]=y.useState(!1),[O,R]=y.useState(null),[Y,P]=y.useState(!1),U=["System Manager","Contractor Supervisor","Contractor Manager","Work Control"],[J,ne]=y.useState(!1),[ye,he]=y.useState(!1),[ce,se]=y.useState([]),[ee,te]=y.useState(!1);y.useEffect(()=>{Q(null,null,function*(){var re,Ee,Ge;try{const It=yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:U.join(",")})})).json();if(It.message){const me=It.message.has_role;ne(me),he(me)}const rt=yield(yield fetch("/api/method/asset_lite.api.user_roles.get_user_roles",{credentials:"include"})).json(),V=Array.isArray(rt.message)?rt.message:[];se(V),te(V.includes("System Manager"));try{const ie=(yield(yield fetch("/api/method/asset_lite.api.userperm_api.get_permission_filters?target_doctype=Work_Order",{credentials:"include"})).json()).message||{};m((re=ie.is_admin)!=null?re:!0),c(((Ge=(Ee=ie.restrictions)==null?void 0:Ee["Issue Type"])==null?void 0:Ge.values)||[])}catch(me){console.error("Error fetching issue type permissions:",me),m(!0),c([])}}catch(ct){console.error("Error checking permissions:",ct),ne(!1),he(!1)}})},[]);const[W,I]=y.useState(()=>r.get("date_filter_by")||""),[oe,ae]=y.useState(()=>r.get("date_start")||""),[F,M]=y.useState(()=>r.get("date_end")||""),[B,X]=y.useState(()=>r.get("status")||""),[K,we]=y.useState(()=>r.get("workflow_state")||""),[be,ke]=y.useState(()=>r.get("inspection_type")||""),[Me,z]=y.useState(()=>r.get("work_order")||""),[Ne,Xe]=y.useState(()=>r.get("department")||""),[gt,St]=y.useState(()=>r.get("sort_by")||"creation desc"),[Ht,Mt]=y.useState(!1),[Te,Qt]=y.useState(0),[zt,Wt]=y.useState([]),[Vt,va]=y.useState(!1),[ta,sa]=y.useState("");y.useEffect(()=>{const fe=localStorage.getItem("inspectionFilterPresets");fe&&Wt(JSON.parse(fe))},[]);const ra=W&&(oe||F);y.useEffect(()=>{const fe=[B,K,be,Me,Ne].filter(Boolean).length+(ra?1:0);Qt(fe)},[B,K,be,Me,Ne,ra]);const Ye=y.useMemo(()=>{const fe={};return B&&(fe.status=B),K&&(fe.workflow_state=K),be&&(fe.inspection_type=be),Me&&(fe.linked_corrective_wo_no=Me),Ne&&(fe.work_order_type=Ne),Object.assign(fe,el(W,oe,F)),fe.custom_delete_status=["!=","Deleted"],fe},[B,K,be,Me,Ne,W,oe,F]),ft=["creation desc","creation asc","modified desc","modified asc","name asc","name desc"].includes(gt)?gt:"creation desc",{inspections:$t,loading:na,error:Ze,totalCount:lt,refetch:aa}=OP({filters:Ye,limit_start:(h-1)*b,limit_page_length:b,order_by:ft});y.useEffect(()=>{!na&&!j&&_(!0)},[na,j]);const Ie=y.useRef(!1);y.useEffect(()=>{if(!Ie.current){Ie.current=!0;return}s(fe=>{const re=new URLSearchParams(fe);return W?re.set("date_filter_by",W):re.delete("date_filter_by"),oe?re.set("date_start",oe):re.delete("date_start"),F?re.set("date_end",F):re.delete("date_end"),B?re.set("status",B):re.delete("status"),K?re.set("workflow_state",K):re.delete("workflow_state"),be?re.set("inspection_type",be):re.delete("inspection_type"),Me?re.set("work_order",Me):re.delete("work_order"),Ne?re.set("department",Ne):re.delete("department"),gt&&gt!=="creation desc"?re.set("sort_by",gt):re.delete("sort_by"),re.set("page","1"),re})},[W,oe,F,B,K,be,Me,Ne,gt]),y.useEffect(()=>{k(new Set)},[W,oe,F,B,K,be,Me,Ne,h]);const Nt=fe=>{switch(fe){case"Delete Request With Supervisor":return"bg-orange-50 dark:bg-orange-900/10";case"Delete Request With CM":return"bg-yellow-50 dark:bg-yellow-900/10";case"Deleted":return"bg-red-50 dark:bg-red-900/10";default:return""}},ve=fe=>fe?new Date(fe).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",Oe=()=>{I(""),ae(""),M(""),St("creation desc"),X(""),we(""),ke(""),z(""),Xe(""),s(fe=>{const re=new URLSearchParams(fe);return re.delete("date_filter_by"),re.delete("date_start"),re.delete("date_end"),re.delete("sort_by"),re.delete("status"),re.delete("workflow_state"),re.delete("inspection_type"),re.delete("work_order"),re.delete("department"),re.set("page","1"),re})},ht=ra||!!B||!!K||!!be||!!Me||!!Ne,et=()=>{if(!ta.trim()){alert(t("common.enterFilterName"));return}const fe={id:Date.now(),name:ta,filters:{dateFilterBy:W,dateStart:oe,dateEnd:F,sortBy:gt,statusFilter:B,workflowStateFilter:K,inspectionTypeFilter:be,workOrderFilter:Me,departmentFilter:Ne}},re=[...zt,fe];Wt(re),sa(""),va(!1),localStorage.setItem("inspectionFilterPresets",JSON.stringify(re))},Be=fe=>{const re=fe.filters;I(re.dateFilterBy||""),ae(re.dateStart||""),M(re.dateEnd||""),St(re.sortBy||"creation desc"),X(re.statusFilter||""),we(re.workflowStateFilter||""),ke(re.inspectionTypeFilter||""),z(re.workOrderFilter||""),Xe(re.departmentFilter||"")},kt=fe=>{const re=zt.filter(Ee=>Ee.id!==fe);Wt(re),localStorage.setItem("inspectionFilterPresets",JSON.stringify(re))},it=fe=>{k(re=>{const Ee=new Set(re);return Ee.has(fe)?Ee.delete(fe):Ee.add(fe),Ee})},xt=()=>{N.size===$t.length?k(new Set):k(new Set($t.map(fe=>fe.name)))},Dt=$t.length>0&&N.size===$t.length,Ot=N.size>0&&N.size<$t.length,Rt=y.useCallback(()=>Q(null,null,function*(){const fe=[];let re=0;const Ee=100;let Ge=!0;const ct=Ks(Ye);for(;Ge;)try{const rt=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Inspection",filters:ct.length>0?ct:{},fields:["*"],limit_start:re*Ee,limit_page_length:Ee,order_by:ft})})).json()).message||[];fe.push(...rt),rt.length<Ee?Ge=!1:re++,re>100&&(console.warn("Export safety limit reached"),Ge=!1)}catch(It){throw console.error("Error fetching inspections for export:",It),It}return fe}),[Ye,ft]),De=(fe,re,Ee)=>Q(null,null,function*(){E(!0);try{let Ge=[];switch(fe){case"selected":Ge=$t.filter(It=>N.has(It.name));break;case"all_on_page":Ge=$t;break;case"all_with_filters":Ge=yield Rt();break}if(Ge.length===0){alert(t("assets.noDataToExport"));return}const ct=Ee.map(It=>{var st;return t(((st=p.find(rt=>rt.key===It))==null?void 0:st.labelKey)||It)});if(re==="csv"){const It=[ct.join(","),...Ge.map(me=>Ee.map(de=>{let ie=me[de]||"";return typeof ie=="string"&&(ie.includes(",")||ie.includes('"')||ie.includes(`
`))&&(ie=`"${ie.replace(/"/g,'""')}"`),ie}).join(","))].join(`
`),st=new Blob(["\uFEFF"+It],{type:"text/csv;charset=utf-8;"}),rt=URL.createObjectURL(st),V=document.createElement("a");V.href=rt,V.download=`inspections_export_${new Date().toISOString().split("T")[0]}.csv`,V.click(),URL.revokeObjectURL(rt)}else if(re==="excel"){const It=[ct,...Ge.map(V=>Ee.map(me=>V[me]||""))],st=Ja.aoa_to_sheet(It),rt=Ja.book_new();Ja.book_append_sheet(rt,st,"Inspections"),$i(rt,`inspections_export_${new Date().toISOString().split("T")[0]}.xlsx`)}D(!1),k(new Set)}catch(Ge){console.error("Export failed:",Ge),alert(`Export failed: ${Ge instanceof Error?Ge.message:"Unknown error"}`)}finally{E(!1)}}),Qe=fe=>Q(null,null,function*(){try{if(!(yield fetch(`/api/resource/Inspection/${fe}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to delete");R(null),aa(),alert(t("inspections.deletedSuccessfully"))}catch(re){alert(`Failed to delete: ${re instanceof Error?re.message:"Unknown error"}`)}});return na&&!j?e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-teal-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("inspections.loadingInspections")})]})}):Ze?e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:t("inspections.errorLoadingInspections")}),e.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:Ze}),e.jsx("button",{onClick:aa,className:"bg-teal-600 hover:bg-teal-700 text-white px-4 py-2 rounded",children:t("common.tryAgain")})]})}):e.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(bi,{className:"text-3xl text-teal-600 dark:text-teal-400"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:t("inspections.title")}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t("common.total"),": ",lt,N.size>0&&e.jsxs("span",{className:"ml-2 text-teal-600 dark:text-teal-400",children:["• ",N.size," selected"]}),na&&j&&e.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-teal-600 dark:text-teal-400",children:[e.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-teal-500"}),"Updating..."]})]})]})]})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:()=>Mt(!Ht),className:`px-4 py-2 rounded-lg flex items-center gap-2 transition-colors ${Ht||ht?"bg-teal-100 text-teal-700 dark:bg-teal-900/30 dark:text-teal-300":"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600"}`,children:[e.jsx(ds,{}),t("listPages.filters"),Te>0&&e.jsx("span",{className:"bg-teal-600 text-white text-xs px-1.5 py-0.5 rounded-full",children:Te})]}),e.jsxs("button",{onClick:aa,disabled:na,className:"px-4 py-2 rounded-lg bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 flex items-center gap-2 disabled:opacity-50",children:[e.jsx(vn,{className:na?"animate-spin":""}),t("listPages.refresh")]}),e.jsxs("button",{onClick:()=>P(!0),className:"bg-cyan-600 hover:bg-cyan-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",children:[e.jsx(bi,{}),e.jsx("span",{className:"font-medium",children:t("inspections.inspectionReport")})]}),e.jsxs("button",{onClick:()=>D(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow transition-all",disabled:lt===0,children:[e.jsx(Os,{}),e.jsx("span",{className:"font-medium",children:t("common.export")}),N.size>0&&e.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:N.size})]}),ye&&e.jsxs("button",{onClick:()=>a("/inspections/new"),className:"bg-teal-600 hover:bg-teal-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow-lg transition-all hover:shadow-xl",children:[e.jsx(Zs,{}),e.jsx("span",{className:"font-medium",children:t("inspections.newInspection")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-4",children:[e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("common.total")}),e.jsx("p",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:lt})]}),e.jsx(bi,{className:"text-3xl text-teal-500"})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("inspections.stats.draft")}),e.jsx("p",{className:"text-2xl font-bold text-orange-600",children:$t.filter(fe=>fe.workflow_state==="Draft").length})]}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-orange-100 dark:bg-orange-900/30 flex items-center justify-center",children:e.jsx("span",{className:"text-orange-600 font-bold",children:"D"})})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("inspections.stats.pendingApproval")}),e.jsx("p",{className:"text-2xl font-bold text-purple-600",children:$t.filter(fe=>fe.workflow_state==="Sent to Supervisor").length})]}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-purple-100 dark:bg-purple-900/30 flex items-center justify-center",children:e.jsx("span",{className:"text-purple-600 font-bold",children:"P"})})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("inspections.stats.closed")}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:$t.filter(fe=>fe.workflow_state==="Closed").length})]}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:e.jsx("span",{className:"text-green-600 font-bold",children:"C"})})]})})]}),Ht&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[e.jsx("div",{className:"bg-gradient-to-r from-teal-500 to-teal-600 dark:from-teal-600 dark:to-teal-700 px-4 py-3 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ds,{className:"text-white",size:16}),e.jsx("h3",{className:"text-white font-semibold text-sm",children:t("listPages.filters")}),Te>0&&e.jsx("span",{className:"bg-white text-teal-600 px-2 py-0.5 rounded-full text-xs font-bold",children:Te})]}),ht&&e.jsx("div",{className:"flex-1 overflow-x-auto scrollbar-hide mx-2",children:e.jsxs("div",{className:"flex items-center gap-2 py-1",children:[B&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-blue-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("inspections.filterStatus"),":"]})," ",t(`inspections.status.${(B||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:B}),e.jsx("button",{onClick:()=>X(""),className:"hover:text-red-500",children:e.jsx(wt,{className:"text-[9px]"})})]}),K&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-purple-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("inspections.filterWorkflow"),":"]})," ",t(`inspections.workflowState.${(K||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:K}),e.jsx("button",{onClick:()=>we(""),className:"hover:text-red-500",children:e.jsx(wt,{className:"text-[9px]"})})]}),be&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-teal-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("inspections.filterType"),":"]})," ",t(`inspections.typeMap.${(be||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:be}),e.jsx("button",{onClick:()=>ke(""),className:"hover:text-red-500",children:e.jsx(wt,{className:"text-[9px]"})})]}),Me&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-orange-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("inspections.filterWorkOrder"),":"]})," ",Me,e.jsx("button",{onClick:()=>z(""),className:"hover:text-red-500",children:e.jsx(wt,{className:"text-[9px]"})})]}),Ne&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-green-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("inspections.filterDepartment"),":"]})," ",Ne,e.jsx("button",{onClick:()=>Xe(""),className:"hover:text-red-500",children:e.jsx(wt,{className:"text-[9px]"})})]}),ra&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-white/90 text-indigo-700 rounded-full text-[10px] font-medium whitespace-nowrap shadow-sm",children:[e.jsxs("span",{className:"font-semibold",children:[t("filters.filterBy"),":"]})," ",t(W==="creation"?"filters.createdDate":"filters.latestModifiedDate")," ",oe&&` ${oe}`," ",F&&` - ${F}`,e.jsx("button",{onClick:()=>{I(""),ae(""),M("")},className:"hover:text-red-500",children:e.jsx(wt,{className:"text-[9px]"})})]})]})}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Te>0&&e.jsxs("button",{onClick:()=>va(!0),className:"px-3 py-1.5 bg-white text-teal-600 hover:bg-teal-50 rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[e.jsx(Or,{size:12}),e.jsx("span",{className:"hidden sm:inline",children:t("common.save")})]}),ht&&e.jsxs("button",{onClick:Oe,className:"px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white rounded-md text-xs font-medium transition-all flex items-center gap-1.5",children:[e.jsx(wt,{size:12}),e.jsx("span",{className:"hidden sm:inline",children:t("common.clearFilters")})]})]})]})}),e.jsxs("div",{className:"p-4",children:[zt.length>0&&e.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[e.jsx(Tc,{className:"text-yellow-500",size:12}),t("inspections.savedFilters")]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:zt.map(fe=>e.jsxs("div",{className:"group relative inline-flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-teal-100 to-blue-100 dark:from-teal-900/30 dark:to-blue-900/30 border border-teal-200 dark:border-teal-700 rounded-lg hover:shadow-md transition-all",children:[e.jsx("button",{onClick:()=>Be(fe),className:"text-xs font-medium text-teal-700 dark:text-teal-300",children:fe.name}),e.jsx("button",{onClick:()=>kt(fe.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:e.jsx(Na,{size:10})})]},fe.id))})]}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.sortBy")}),e.jsxs("select",{value:gt,onChange:fe=>{St(fe.target.value),g(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"creation desc",children:t("filters.sortCreationNewest")}),e.jsx("option",{value:"creation asc",children:t("filters.sortCreationOldest")}),e.jsx("option",{value:"modified desc",children:t("filters.sortModifiedNewest")}),e.jsx("option",{value:"modified asc",children:t("filters.sortModifiedOldest")}),e.jsx("option",{value:"name asc",children:t("filters.sortNameAsc")}),e.jsx("option",{value:"name desc",children:t("filters.sortNameDesc")})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.filterBy")}),e.jsxs("select",{value:W,onChange:fe=>{const re=fe.target.value;I(re),g(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("filters.filterBy")}),e.jsx("option",{value:"creation",children:t("filters.createdDate")}),e.jsx("option",{value:"modified",children:t("filters.latestModifiedDate")})]})]}),W&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.startDate")}),e.jsx("input",{type:"date",value:oe,onChange:fe=>{const re=fe.target.value;ae(re),F&&re>F&&M(re),g(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.endDate")}),e.jsx("input",{type:"date",value:F,onChange:fe=>{M(fe.target.value),g(1)},min:oe||void 0,className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.status")}),e.jsxs("select",{value:B,onChange:fe=>{X(fe.target.value),g(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("filters.allStatuses")}),e.jsx("option",{value:"Open",children:t("inspections.status.open")}),e.jsx("option",{value:"In Progress",children:t("inspections.status.in_progress")}),e.jsx("option",{value:"Pending Review",children:t("inspections.status.pending_review")}),e.jsx("option",{value:"Closed",children:t("inspections.status.closed")})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.workflowState")}),e.jsxs("select",{value:K,onChange:fe=>{we(fe.target.value),g(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("filters.allStates")}),e.jsx("option",{value:"Draft",children:t("inspections.workflowState.draft")}),e.jsx("option",{value:"Sent to Work Control",children:t("inspections.workflowState.sent_to_work_control")}),e.jsx("option",{value:"Sent to technician",children:t("inspections.workflowState.sent_to_technician")}),e.jsx("option",{value:"Sent to Supervisor",children:t("inspections.workflowState.sent_to_supervisor")}),e.jsx("option",{value:"Closed",children:t("inspections.workflowState.closed")})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("inspections.type")}),e.jsxs("select",{value:be,onChange:fe=>{ke(fe.target.value),g(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("filters.allTypes")}),e.jsx("option",{value:"Inspection",children:t("inspections.typeMap.inspection")}),e.jsx("option",{value:"Safety Inspection",children:t("inspections.typeMap.safety_inspection")})]})]}),e.jsxs("div",{className:"relative z-[60]",children:[e.jsx(Ut,{label:t("inspections.filterWorkOrder"),doctype:"Work_Order",value:Me,onChange:fe=>{z(fe),g(1)},placeholder:t("inspections.selectWorkOrder"),disabled:!1,compact:!0,filters:{custom_delete_status:["!=","Deleted"]}}),Me&&e.jsx("button",{onClick:()=>z(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[59]",children:[e.jsx(Ut,{label:t("inspections.technicalDepartment"),doctype:"Issue Type",value:Ne,onChange:fe=>{Xe(fe),g(1)},placeholder:t("inspections.selectDepartment"),disabled:!1,compact:!0}),Ne&&e.jsx("button",{onClick:()=>Xe(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:e.jsx(wt,{size:10})})]})]})})]})]}),Vt&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:t("common.saveFilterPreset")}),e.jsx("input",{type:"text",value:ta,onChange:fe=>sa(fe.target.value),onKeyDown:fe=>{fe.key==="Enter"&&(fe.preventDefault(),et())},placeholder:t("common.enterFilterName"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white mb-4",autoFocus:!0}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>{va(!1),sa("")},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",children:t("common.cancel")}),e.jsxs("button",{onClick:et,className:"px-4 py-2 text-sm font-medium text-white bg-teal-600 hover:bg-teal-700 rounded-md transition-colors flex items-center gap-2",children:[e.jsx(Or,{size:12}),t("common.saveFilter")]})]})]})}),e.jsx(RP,{isOpen:C,onClose:()=>D(!1),selectedCount:N.size,totalCount:lt,pageCount:$t.length,onExport:De,isExporting:T,exportColumns:p}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700 overflow-hidden relative",children:[na&&j&&e.jsx("div",{className:"absolute inset-0 bg-white/60 dark:bg-gray-800/60 flex items-center justify-center z-10 backdrop-blur-[1px]",children:e.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[e.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-teal-500"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:t("common.filtering")})]})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left",children:e.jsx("button",{onClick:xt,className:"text-gray-500 dark:text-gray-400 hover:text-teal-600 dark:hover:text-teal-400 transition-colors",title:t(Dt?"common.deselectAllTitle":"common.selectAllTitle"),children:Dt?e.jsx(Es,{className:"text-teal-600 dark:text-teal-400",size:18}):Ot?e.jsxs("div",{className:"relative",children:[e.jsx(Ar,{size:18}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):e.jsx(Ar,{size:18})})}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("inspections.inspectionId")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("inspections.type")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("filters.status")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("inspections.workflowStateHeader")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("inspections.targetDate")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("inspections.requestedBy")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("inspections.linkedWorkOrder")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("listPages.actions")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:$t.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:9,className:"px-4 py-12 text-center text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(bi,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),e.jsx("p",{children:t("inspections.noInspectionsFound")}),ht?e.jsx("button",{onClick:Oe,className:"mt-4 text-teal-600 dark:text-teal-400 hover:underline",children:t("common.clearFilters")}):ye?e.jsx("button",{onClick:()=>a("/inspections/new"),className:"mt-4 text-teal-600 dark:text-teal-400 hover:underline",children:t("inspections.createFirstInspection")}):null]})})}):$t.map(fe=>{var re;return e.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer transition-colors ${N.has(fe.name)?"bg-teal-50 dark:bg-teal-900/20":Nt(fe.custom_delete_status)}`,title:fe.custom_delete_status?`Delete Status: ${fe.custom_delete_status}`:void 0,onClick:()=>a(`/inspections/${fe.name}`),children:[e.jsx("td",{className:"px-4 py-3",onClick:Ee=>Ee.stopPropagation(),children:e.jsx("button",{onClick:()=>it(fe.name),className:"text-gray-500 dark:text-gray-400 hover:text-teal-600 dark:hover:text-teal-400 transition-colors",children:N.has(fe.name)?e.jsx(Es,{className:"text-teal-600 dark:text-teal-400",size:18}):e.jsx(Ar,{size:18})})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm font-medium text-teal-600 dark:text-teal-400",children:fe.name})}),e.jsx("td",{className:"px-4 py-3",children:fe.inspection_type?e.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${IP(fe.inspection_type)}`,children:t(`inspections.typeMap.${(fe.inspection_type||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:fe.inspection_type})}):e.jsx("span",{className:"text-gray-400",children:"-"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${PP(fe.status)}`,children:fe.status?t(`inspections.status.${(fe.status||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:fe.status}):"-"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${FP(fe.workflow_state)}`,children:fe.workflow_state?t(`inspections.workflowState.${(fe.workflow_state||"").toLowerCase().replace(/\s+/g,"_")}`,{defaultValue:fe.workflow_state}):"-"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:ve(fe.target_closure_date||"")})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300 line-clamp-1",children:fe.requested_by||"-"})}),e.jsx("td",{className:"px-4 py-3",onClick:Ee=>Ee.stopPropagation(),children:fe.linked_corrective_wo_no?e.jsxs("button",{onClick:()=>a(`/work-orders/${fe.linked_corrective_wo_no}`),className:"text-sm text-blue-600 dark:text-blue-400 hover:underline flex items-center gap-1",children:[fe.linked_corrective_wo_no,e.jsx(vs,{size:10})]}):e.jsx("span",{className:"text-gray-400",children:"-"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1",onClick:Ee=>Ee.stopPropagation(),children:[e.jsx("button",{onClick:()=>a(`/inspections/${fe.name}`),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded transition-colors",title:t("inspections.viewDetails"),children:e.jsx(ri,{})}),e.jsx("button",{onClick:()=>a(`/inspections/${fe.name}?edit=true`),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded transition-colors",title:t("inspections.editInspection"),children:e.jsx(Fr,{})}),e.jsx("div",{onClick:Ee=>Ee.stopPropagation(),children:e.jsx(Ll,{doctype:"Inspection",docname:fe.name,currentDeleteStatus:(re=fe.custom_delete_status)!=null?re:null,userRoles:ce,isSystemManager:ee,triggerMode:!0,redirectOnDelete:"/inspections",onStatusChange:()=>aa()})})]})})]},fe.name)})})]})}),e.jsx(Rc,{currentPage:h,totalCount:lt,pageSize:b,itemLabel:t("pagination.inspections"),onPageChange:fe=>g(fe)})]}),O&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:e.jsx(Na,{className:"text-red-600 dark:text-red-400 text-xl"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:t("inspections.deleteInspection")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:t("inspections.deleteConfirmMessage")}),e.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-md p-3 mb-4",children:e.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[e.jsxs("strong",{children:[t("inspections.inspectionId"),":"]})," ",O]})}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>R(null),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-lg transition-colors",children:t("common.cancel")}),e.jsxs("button",{onClick:()=>Qe(O),className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors flex items-center gap-2",children:[e.jsx(Na,{}),t("common.delete")]})]})]})]})})}),e.jsx(LP,{isOpen:Y,onClose:()=>P(!1),permittedIssueTypes:i,isAdmin:d}),e.jsx("style",{children:`
@keyframes scale-in { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.animate-scale-in { animation: scale-in 0.2s ease-out; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
.scrollbar-hide::-webkit-scrollbar { display: none; }
`})]})},J0=()=>new Date().toISOString().split("T")[0],BP=t=>{switch(t==null?void 0:t.toLowerCase()){case"open":return{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-300",border:"border-blue-200 dark:border-blue-800"};case"in progress":return{bg:"bg-yellow-100 dark:bg-yellow-900/30",text:"text-yellow-800 dark:text-yellow-300",border:"border-yellow-200 dark:border-yellow-800"};case"closed":return{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-800 dark:text-gray-300",border:"border-gray-200 dark:border-gray-600"};default:return{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-800 dark:text-gray-300",border:"border-gray-200 dark:border-gray-600"}}},UP=()=>{var Rt;const{t}=ca(),{inspectionName:a}=xo(),[r]=Qs(),s=qa(),i=a==="new",c=r.get("edit")==="true",d=["System Manager","Contractor Supervisor","Contractor Manager"],[m,h]=y.useState(!1);y.useEffect(()=>{Q(null,null,function*(){try{const fe=yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:d.join(",")})})).json();fe.message&&h(fe.message.has_role)}catch(Qe){console.error("Error checking permissions:",Qe),h(!1)}})},[]);const[g,p]=y.useState([]),[b,j]=y.useState(!1);y.useEffect(()=>{Q(null,null,function*(){try{const Qe=yield mt.apiCall("/api/method/asset_lite.api.user_roles.get_user_roles");Array.isArray(Qe)?p(Qe):Qe!=null&&Qe.message&&p(Qe.message)}catch(Qe){console.error("Error fetching roles:",Qe)}finally{j(!0)}})},[]);const[_,N]=y.useState(!1),[k,C]=y.useState(!1);y.useEffect(()=>{Q(null,null,function*(){try{const fe=yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:d.join(",")})})).json();fe.message&&h(fe.message.has_role)}catch(Qe){console.error("Error checking permissions:",Qe),h(!1)}})},[]);const[D,T]=y.useState({inspection_type:"",status:"Open",inspection_date:i?J0():"",target_closure_date:"",requested_by:"",technician_department:"",linked_corrective_wo_no:"",observation_note:"",technical_response:"",workflow_state:"Draft",work_order_type:"",department:"",location:"",assigned_technician:"",attachment:"",attachment_on_close:"",extension_no:"",docstatus:0}),[E,O]=y.useState(i),[R,Y]=y.useState([]),[P,U]=y.useState(!1),[J,ne]=y.useState([]),[ye,he]=y.useState(!1),[ce,se]=y.useState(!1),[ee,te]=y.useState(!1),{inspection:W,loading:I,error:oe,refetch:ae}=DP(i?null:a||null),{createInspection:F,updateInspection:M,deleteInspection:B,loading:X}=MP(),{isSystemManager:K,canEdit:we,getStateStyle:be}=ag({doctype:"Inspection",docname:i?null:a||null,workflowState:D.workflow_state,enabled:!i,docData:D}),Me=g.includes("Work Control")&&!D.assigned_technician,[z,Ne]=y.useState(i||c),[Xe,gt]=y.useState(!1),Ht=y.useCallback(()=>{const De=D.workflow_state||"Draft";return De==="Cancelled"?2:De==="Closed"?1:D.docstatus||0},[D.workflow_state,D.docstatus])(),Mt=Ht===1,Te=Ht===2,Qt=!!(W!=null&&W.custom_delete_status),zt=Mt||Te||Qt,Wt=y.useCallback(()=>Q(null,null,function*(){if(!(i||!a)){he(!0);try{const De=yield mt.apiCall(`/api/resource/Version?filters=[["ref_doctype","=","Inspection"],["docname","=","${encodeURIComponent(a)}"]]&fields=["name","owner","creation","data"]&order_by=creation desc&limit=50`);if(De!=null&&De.data&&De.data.length>0){const Qe=De.data.map(fe=>{let re={added:[],changed:[],removed:[],row_changed:[]};try{re=JSON.parse(fe.data||"{}")}catch(Ge){console.error("Error parsing version data:",Ge)}const Ee=(re.changed||[]).map(Ge=>({field:Ge[0]||"",oldValue:Ge[1],newValue:Ge[2]}));return{name:fe.name,owner:fe.owner,creation:fe.creation,changes:Ee,added:re.added||[],removed:re.removed||[],rowChanged:re.row_changed||[]}});ne(Qe),console.log("Audit logs fetched:",Qe.length)}else ne([])}catch(De){console.error("Error fetching audit logs:",De),ne([])}finally{he(!1)}}}),[i,a]);y.useEffect(()=>{Wt()},[Wt]);const Vt=De=>De?De.replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,Qe=>Qe.toUpperCase()):"",va=De=>De==null||De===""?"(empty)":De===0?"0":De===1?"1":typeof De=="boolean"?De?"Yes":"No":typeof De=="object"?JSON.stringify(De):String(De),ta=De=>{if(!De)return"";const Qe=new Date(De),fe=new Date,re=fe.getTime()-Qe.getTime(),Ee=Math.floor(re/6e4),Ge=Math.floor(re/36e5),ct=Math.floor(re/864e5);return Ee<1?"Just now":Ee<60?`${Ee} min${Ee>1?"s":""} ago`:Ge<24?`${Ge} hour${Ge>1?"s":""} ago`:ct<7?`${ct} day${ct>1?"s":""} ago`:Qe.toLocaleDateString("en-US",{month:"short",day:"numeric",year:Qe.getFullYear()!==fe.getFullYear()?"numeric":void 0,hour:"2-digit",minute:"2-digit"})},sa=De=>{if(!De)return"Unknown";const Qe=De.indexOf("@");return Qe===-1?De:De.substring(0,Qe)},ra=De=>{const Qe=De.toLowerCase();return Qe.includes("status")||Qe.includes("state")?"text-purple-600 dark:text-purple-400":Qe.includes("date")?"text-blue-600 dark:text-blue-400":Qe.includes("technician")||Qe.includes("supervisor")||Qe.includes("assigned")?"text-green-600 dark:text-green-400":"text-gray-600 dark:text-gray-400"},Ye=y.useCallback(De=>Q(null,null,function*(){if(!De){Y([]);return}try{console.log("Filtering technicians for work order type:",De);const Qe=yield mt.apiCall(`/api/resource/Asset Maintenance Team?filters=[["custom_expertise","=","${encodeURIComponent(De)}"]]&fields=["name"]&limit=100`);if(Qe!=null&&Qe.data&&Qe.data.length>0){const fe=new Set,re=Qe.data.map(Ge=>Q(null,null,function*(){try{const ct=yield mt.apiCall(`/api/resource/Asset Maintenance Team/${encodeURIComponent(Ge.name)}`);ct!=null&&ct.data&&(ct.data.maintenance_team_members||[]).forEach(st=>{st.team_member&&fe.add(st.team_member)})}catch(ct){console.error("Error fetching team:",Ge.name,ct)}}));yield Promise.all(re);const Ee=Array.from(fe);console.log("Filtered Technicians:",Ee),Y(Ee)}else Y([])}catch(Qe){console.error("Error fetching technicians:",Qe),Y([])}}),[]);y.useEffect(()=>{D.work_order_type?Ye(D.work_order_type):Y([])},[D.work_order_type,Ye]);const ft=De=>{if(!De)return!0;const Qe=J0();return De<Qe?(nt.error(t("inspections.detail.inspectionDateInPast"),{position:"top-right",autoClose:5e3,icon:e.jsx(fa,{})}),!1):!0},$t=(De,Qe)=>{if(!De)return!0;const fe=J0();return Qe&&De<Qe?(nt.error(t("inspections.detail.targetClosureEarlier"),{position:"top-right",autoClose:5e3,icon:e.jsx(fa,{})}),!1):De<fe?(nt.error(t("inspections.detail.targetClosureInPast"),{position:"top-right",autoClose:5e3,icon:e.jsx(fa,{})}),!1):!0},na=De=>{const Qe=De.target.value;ft(Qe)&&(T(fe=>Se(ue({},fe),{inspection_date:Qe})),D.target_closure_date&&$t(D.target_closure_date,Qe))},Ze=De=>{const Qe=De.target.value;$t(Qe,D.inspection_date||"")&&T(fe=>Se(ue({},fe),{target_closure_date:Qe}))},lt=De=>{T(Qe=>Se(ue({},Qe),{work_order_type:De,assigned_technician:""}))},aa=De=>Q(null,null,function*(){var re,Ee;const Qe=(re=De.target.files)==null?void 0:re[0];if(!Qe)return;const fe=10*1024*1024;if(Qe.size>fe){nt.error(t("inspections.detail.fileSizeExceeds"),{position:"top-right",autoClose:4e3,icon:e.jsx(ka,{})});return}U(!0);try{const Ge=new FormData;Ge.append("file",Qe),Ge.append("is_private","0"),Ge.append("folder","Home/Attachments"),!i&&a&&(Ge.append("doctype","Inspection"),Ge.append("docname",a));const ct=ia.BASE_URL||"",st=yield(yield fetch(`${ct}/api/method/upload_file`,{method:"POST",credentials:"include",body:Ge})).json();if((Ee=st.message)!=null&&Ee.file_url)T(rt=>Se(ue({},rt),{attachment:st.message.file_url})),nt.success(t("inspections.detail.fileUploadedSuccess"),{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})});else throw new Error("Upload failed")}catch(Ge){console.error("File upload error:",Ge),nt.error(t("inspections.detail.failedToUpload"),{position:"top-right",autoClose:4e3,icon:e.jsx(ka,{})})}finally{U(!1),De.target.value=""}}),Ie=()=>{T(De=>Se(ue({},De),{attachment:""})),nt.info(t("inspections.detail.attachmentRemoved"),{position:"top-right",autoClose:2e3})},Nt=De=>{if(!De)return"";const Qe=De.split("/");return Qe[Qe.length-1]||De},ve=()=>Q(null,null,function*(){C(!0);try{yield M(a,Se(ue({},D),{workflow_state:"Cancelled",docstatus:2,status:"Cancelled"})),nt.success(t("inspections.detail.cancelledSuccessfully"),{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),N(!1),ae(),setTimeout(()=>{Wt()},500)}catch(De){const Qe=De instanceof Error?De.message:"Unknown error";nt.error(t("inspections.detail.failedToCancel",{error:Qe}),{position:"top-right",autoClose:6e3,icon:e.jsx(ka,{})})}finally{C(!1)}});y.useEffect(()=>{Q(null,null,function*(){if(i&&!D.requested_by)try{const Qe=yield bc.getCurrentUser();Qe&&T(fe=>Se(ue({},fe),{requested_by:Qe}))}catch(Qe){console.error("Error fetching current user:",Qe)}finally{O(!1)}else O(!1)})},[i]),y.useEffect(()=>{W&&!i&&(T({inspection_type:W.inspection_type||"",status:W.status||"Open",inspection_date:W.inspection_date||"",target_closure_date:W.target_closure_date||"",requested_by:W.requested_by||"",technician_department:W.technician_department||"",linked_corrective_wo_no:W.linked_corrective_wo_no||"",observation_note:W.observation_note||"",technical_response:W.technical_response||"",workflow_state:W.workflow_state||"Draft",work_order_type:W.work_order_type||"",department:W.department||"",location:W.location||"",assigned_technician:W.assigned_technician||"",attachment:W.attachment||"",attachment_on_close:W.attachment_on_close||"",extension_no:W.extension_no||"",docstatus:W.docstatus||0}),W.workflow_state==="Closed"||W.workflow_state==="Cancelled"||W.docstatus>=1?Ne(!1):c||Ne(!1))},[W,i,c]);const Oe=De=>{const{name:Qe,value:fe}=De.target;T(re=>Se(ue({},re),{[Qe]:fe}))},ht=()=>Q(null,null,function*(){if(!D.target_closure_date){nt.error(t("inspections.detail.targetClosureMandatory"),{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})});return}if(!D.attachment){nt.error(t("inspections.detail.attachmentMandatory"),{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})});return}if(!D.extension_no){nt.error(t("inspections.detail.extensionMandatory"),{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})});return}if(ft(D.inspection_date||"")&&$t(D.target_closure_date||"",D.inspection_date||""))try{if(i){const De=yield F(D);nt.success(t("inspections.detail.createdSuccessfully"),{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),s(`/inspections/${De.name}`)}else yield M(a,D),nt.success(t("inspections.detail.updatedSuccessfully"),{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),Ne(!1),ae(),setTimeout(()=>{Wt()},500)}catch(De){const Qe=De instanceof Error?De.message:"Unknown error";nt.error(t("inspections.detail.failedToSave",{error:Qe}),{position:"top-right",autoClose:6e3,icon:e.jsx(ka,{})})}}),et=()=>Q(null,null,function*(){try{yield B(a),nt.success(t("inspections.detail.deletedSuccessfully"),{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),s(-1)}catch(De){const Qe=De instanceof Error?De.message:"Unknown error";nt.error(t("inspections.detail.failedToDelete",{error:Qe}),{position:"top-right",autoClose:6e3,icon:e.jsx(ka,{})})}}),Be=(De,Qe)=>{Qe&&(nt.success(`Action "${De}" applied successfully!`,{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),setTimeout(()=>{Wt()},500))},kt=()=>{ae()},it=y.useCallback(De=>!!(zt||!z||De==="linked_corrective_wo_no"||!i&&!we&&!K),[z,i,we,K,zt]);if(I||E)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-teal-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("inspections.detail.loadingDetails")})]})});if(oe&&!i)return e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:t("inspections.detail.errorLoading")}),e.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:oe}),e.jsx("button",{onClick:()=>s(-1),className:"bg-teal-600 hover:bg-teal-700 text-white px-4 py-2 rounded",children:t("inspections.detail.backToList")})]})});const xt=(W==null?void 0:W.workflow_state)||D.workflow_state||"Draft",Dt=be(xt),Ot=BP(D.status||"Open");return e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[e.jsx(Xd,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Lc}),e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>s(-1),className:"text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200",children:e.jsx(en,{size:20})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white flex items-center gap-3",children:[i?t("inspections.detail.newInspection"):(W==null?void 0:W.name)||t("inspections.detail.inspectionDetails"),!i&&e.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium ${Ot.bg} ${Ot.text} ${Ot.border} border`,children:D.status||"Open"}),Te&&e.jsx("span",{className:"px-3 py-1 rounded-full text-sm font-medium bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300 border border-red-200 dark:border-red-800",children:t("inspections.detail.cancelled")}),K&&!i&&e.jsx("span",{className:"px-2 py-0.5 bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 text-xs rounded-full",children:"System Manager"})]}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:i?t("inspections.detail.createNewRecord"):`${D.inspection_type||t("inspections.typeMap.inspection")}`})]})]}),e.jsxs("div",{className:"flex gap-3",children:[!i&&!z&&e.jsxs(e.Fragment,{children:[!zt&&e.jsxs("button",{onClick:()=>Ne(!0),className:"bg-teal-600 hover:bg-teal-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[e.jsx(Fr,{}),t("common.edit")]}),Mt&&m&&e.jsxs("button",{onClick:()=>N(!0),className:"bg-orange-600 hover:bg-orange-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[e.jsx(ei,{}),t("common.cancel")]})]}),z&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{i?s(-1):(Ne(!1),ae())},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg",children:t("common.cancel")}),e.jsxs("button",{onClick:ht,disabled:X,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[e.jsx(Or,{}),t(X?"common.saving":"common.save")]})]})]})]}),_&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(ei,{className:"text-orange-500 text-xl mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:t("inspections.detail.cancelInspection")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:t("inspections.detail.cancelConfirmMessage")})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>N(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",disabled:k,children:t("inspections.detail.noGoBack")}),e.jsx("button",{onClick:ve,disabled:k,className:"px-4 py-2 bg-orange-600 hover:bg-orange-700 text-white rounded-lg disabled:opacity-50 flex items-center gap-2",children:k?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin"}),t("inspections.detail.cancelling")]}):e.jsxs(e.Fragment,{children:[e.jsx(ei,{}),t("inspections.detail.yesCancel")]})})]})]})}),Xe&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(fa,{className:"text-red-500 text-xl mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:t("inspections.deleteInspection")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:t("inspections.deleteConfirmMessage")})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>gt(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:t("common.cancel")}),e.jsx("button",{onClick:et,disabled:X,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg disabled:opacity-50",children:t(X?"common.deleting":"common.delete")})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(bi,{className:"text-teal-500"}),t("inspections.detail.inspectionDetails")]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("inspections.detail.inspectionType")}),e.jsxs("select",{name:"inspection_type",value:D.inspection_type,onChange:Oe,disabled:it("inspection_type"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-teal-500",children:[e.jsx("option",{value:"",children:t("inspections.detail.selectType")}),e.jsx("option",{value:"Inspection",children:t("inspections.typeMap.inspection")}),e.jsx("option",{value:"Safety Inspection",children:t("inspections.typeMap.safety_inspection")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("inspections.detail.status")}),e.jsxs("select",{name:"status",value:D.status,onChange:Oe,disabled:it("status"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-teal-500",children:[e.jsx("option",{value:"Open",children:t("inspections.status.open")}),e.jsx("option",{value:"In Progress",children:t("inspections.status.in_progress")}),e.jsx("option",{value:"Pending Review",children:t("inspections.status.pending_review")}),e.jsx("option",{value:"Closed",children:t("inspections.status.closed")}),e.jsx("option",{value:"Cancelled",children:t("inspections.detail.cancelled")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(Ut,{label:t("inspections.detail.workOrderType"),doctype:"Issue Type",value:D.work_order_type||"",onChange:lt,disabled:it("work_order_type"),placeholder:t("inspections.detail.selectWorkOrderType")}),R.length>0&&e.jsx("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:t("inspections.detail.techniciansAvailable",{count:R.length})})]}),e.jsx("div",{children:e.jsx(Ut,{label:t("inspections.detail.department"),doctype:"Department",value:D.department||"",onChange:De=>T(Se(ue({},D),{department:De})),disabled:it("department"),placeholder:t("inspections.detail.selectDepartment"),allowQuickCreate:!0})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx("div",{children:e.jsx(Ut,{label:t("inspections.detail.location"),doctype:"Location",value:D.location||"",onChange:De=>T(Se(ue({},D),{location:De})),disabled:it("location"),placeholder:t("inspections.detail.selectLocation"),allowQuickCreate:!0})}),e.jsx("div",{children:e.jsx(Ut,{label:t("inspections.detail.extensionNo"),doctype:"Extension Directory",value:D.extension_no||"",onChange:De=>T(Se(ue({},D),{extension_no:De})),disabled:it("extension_no"),placeholder:t("inspections.detail.selectExtension"),allowQuickCreate:!0})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("inspections.detail.inspectionDate")}),e.jsx("input",{type:"date",name:"inspection_date",value:D.inspection_date||"",onChange:na,min:J0(),disabled:it("inspection_date"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-teal-500"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:t("inspections.detail.cannotBeInPast")})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t("inspections.detail.targetClosureDate")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"date",name:"target_closure_date",value:D.target_closure_date||"",onChange:Ze,min:D.inspection_date||J0(),disabled:it("target_closure_date"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-teal-500"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:t("inspections.detail.cannotBeEarlier")})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("inspections.detail.openingAttachment")}),D.attachment?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600",children:[e.jsx(mh,{className:"text-blue-500 flex-shrink-0",size:18}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("a",{href:`${ia.BASE_URL}${D.attachment}`,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline truncate block",children:Nt(D.attachment)})}),z&&!zt&&e.jsx("button",{type:"button",onClick:Ie,className:"p-1.5 text-red-500 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors flex-shrink-0",title:t("inspections.detail.removeAttachment"),children:e.jsx(wt,{size:14})})]}):z&&!zt?e.jsxs("label",{className:"flex items-center gap-2 px-4 py-2.5 bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 rounded-lg cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-900/30 transition-colors border border-blue-200 dark:border-blue-800 w-fit",children:[P?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin",size:14}),e.jsx("span",{className:"text-sm",children:t("inspections.detail.uploading")})]}):e.jsxs(e.Fragment,{children:[e.jsx(gh,{size:14}),e.jsx("span",{className:"text-sm",children:t("inspections.detail.uploadFile")})]}),e.jsx("input",{type:"file",onChange:aa,disabled:P||it("attachment"),className:"hidden",accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.txt"})]}):e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 italic p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t("inspections.detail.noAttachment")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("inspections.detail.closingAttachment")}),D.attachment_on_close?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600",children:[e.jsx(mh,{className:"text-green-500 flex-shrink-0",size:18}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("a",{href:`${ia.BASE_URL}${D.attachment_on_close}`,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline truncate block",children:Nt(D.attachment_on_close)})}),z&&!zt&&e.jsx("button",{type:"button",onClick:()=>{T(De=>Se(ue({},De),{attachment_on_close:""})),nt.info(t("inspections.detail.closingAttachmentRemoved"),{position:"top-right",autoClose:2e3})},className:"p-1.5 text-red-500 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors flex-shrink-0",title:t("inspections.detail.removeClosingAttachment"),children:e.jsx(wt,{size:14})})]}):z&&!zt?e.jsxs("label",{className:"flex items-center gap-2 px-4 py-2.5 bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400 rounded-lg cursor-pointer hover:bg-green-100 dark:hover:bg-green-900/30 transition-colors border border-green-200 dark:border-green-800 w-fit",children:[P?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin",size:14}),e.jsx("span",{className:"text-sm",children:t("inspections.detail.uploading")})]}):e.jsxs(e.Fragment,{children:[e.jsx(gh,{size:14}),e.jsx("span",{className:"text-sm",children:t("inspections.detail.uploadClosingFile")})]}),e.jsx("input",{type:"file",onChange:De=>Q(null,null,function*(){var re,Ee;const Qe=(re=De.target.files)==null?void 0:re[0];if(!Qe)return;const fe=10*1024*1024;if(Qe.size>fe){nt.error(t("inspections.detail.fileSizeExceeds"),{position:"top-right",autoClose:4e3,icon:e.jsx(ka,{})});return}U(!0);try{const Ge=new FormData;Ge.append("file",Qe),Ge.append("is_private","0"),Ge.append("folder","Home/Attachments"),!i&&a&&(Ge.append("doctype","Inspection"),Ge.append("docname",a));const ct=ia.BASE_URL||"",st=yield(yield fetch(`${ct}/api/method/upload_file`,{method:"POST",credentials:"include",body:Ge})).json();if((Ee=st.message)!=null&&Ee.file_url)T(rt=>Se(ue({},rt),{attachment_on_close:st.message.file_url})),nt.success(t("inspections.detail.closingAttachmentUploadedSuccess"),{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})});else throw new Error("Upload failed")}catch(Ge){console.error("File upload error:",Ge),nt.error(t("inspections.detail.failedToUploadClosing"),{position:"top-right",autoClose:4e3,icon:e.jsx(ka,{})})}finally{U(!1),De.target.value=""}}),disabled:P||it("attachment_on_close"),className:"hidden",accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx,.txt"})]}):e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 italic p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t("inspections.detail.noClosingAttachment")})]})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(js,{className:"text-blue-500"}),t("inspections.detail.assignmentInformation")]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx("div",{children:e.jsx(Ut,{label:t("inspections.detail.requestedBy"),doctype:"User",value:D.requested_by||"",onChange:De=>T(Se(ue({},D),{requested_by:De})),disabled:it("requested_by"),placeholder:t("inspections.detail.selectUser")})}),e.jsx("div",{children:e.jsx(Ut,{label:t("inspections.detail.technicalDepartment"),doctype:"Technical Department",value:D.technician_department||"",onChange:De=>T(Se(ue({},D),{technician_department:De})),disabled:it("technician_department"),placeholder:t("inspections.detail.selectDepartment"),allowQuickCreate:!0})}),e.jsxs("div",{children:[e.jsx(Ut,{label:t("inspections.detail.assignedTechnician"),doctype:"User",value:D.assigned_technician||"",onChange:De=>T(Se(ue({},D),{assigned_technician:De})),disabled:it("assigned_technician"),placeholder:t("inspections.detail.selectTechnician"),filters:R.length>0?{name:["in",R]}:{}}),!D.work_order_type&&z&&!zt&&e.jsx("p",{className:"mt-1 text-xs text-orange-500 dark:text-orange-400",children:t("inspections.detail.selectWOTypeFirst")}),D.work_order_type&&R.length===0&&z&&!zt&&e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:t("inspections.detail.noTechniciansForType")})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(J5,{className:"text-green-500"}),t("inspections.detail.notesAndResponse")]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("inspections.detail.observationNote")}),e.jsx("textarea",{name:"observation_note",value:D.observation_note,onChange:Oe,disabled:it("observation_note"),placeholder:t("inspections.detail.placeholderObservation"),rows:4,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-teal-500 resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t("inspections.detail.technicalResponse")}),e.jsx("textarea",{name:"technical_response",value:D.technical_response,onChange:Oe,disabled:it("technical_response"),placeholder:t("inspections.detail.placeholderTechnicalResponse"),rows:4,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-teal-500 resize-none"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(uh,{className:"text-orange-500"}),t("inspections.detail.linkedWorkOrder")]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t("inspections.detail.linkedCorrectiveWO")," ",e.jsxs("span",{className:"text-xs text-gray-500",children:["(",t("inspections.detail.readOnly"),")"]})]}),D.linked_corrective_wo_no?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600",children:[e.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:D.linked_corrective_wo_no}),e.jsxs("button",{onClick:()=>s(`/work-orders/${D.linked_corrective_wo_no}`),className:"text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 flex items-center gap-1 text-sm",children:[t("inspections.detail.viewWorkOrder")," ",e.jsx(vs,{size:12})]})]}):e.jsx("div",{className:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600",children:e.jsx("span",{className:"text-gray-500 dark:text-gray-400 italic",children:t("inspections.detail.noLinkedWorkOrder")})})]})]}),!i&&e.jsx(Pc,{referenceDoctype:"Inspection",referenceName:a||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5,collapsible:!0,startCollapsed:!1})]}),e.jsxs("div",{className:"space-y-4",children:[!i&&!z&&!zt&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-4 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-sm font-semibold text-gray-800 dark:text-white mb-3 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(uh,{className:"text-purple-500",size:14}),t("inspections.detail.workflowActions")]}),Me&&e.jsxs("div",{className:"mb-3 flex items-start gap-2 p-3 bg-amber-50 dark:bg-amber-900/20 border border-amber-300 dark:border-amber-700 rounded-lg",children:[e.jsx(fa,{className:"text-amber-500 flex-shrink-0 mt-0.5",size:14}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-amber-800 dark:text-amber-300",children:"Technician Required"}),e.jsx("p",{className:"text-[11px] text-amber-700 dark:text-amber-400 mt-0.5",children:"Please assign a technician to this inspection before proceeding with workflow actions."})]})]}),!Me&&e.jsx(Tp,{doctype:"Inspection",docname:a||null,workflowState:xt,onActionComplete:Be,onStateChange:kt,showStateInfo:!1}),e.jsxs("div",{className:"mt-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400 mb-2",children:t("inspections.detail.workflowProgress")}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:`flex flex-col items-center ${xt==="Draft"?"text-orange-600":"text-green-600"}`,children:[e.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center text-[10px] ${xt==="Draft"?"bg-orange-100 dark:bg-orange-900/30":"bg-green-100 dark:bg-green-900/30"}`,children:xt==="Draft"?"1":e.jsx(dc,{size:8})}),e.jsx("span",{className:"text-[8px] mt-0.5",children:t("inspections.detail.draftStep")})]}),e.jsx("div",{className:`flex-1 h-0.5 mx-0.5 ${xt!=="Draft"?"bg-green-500":"bg-gray-300 dark:bg-gray-600"}`}),e.jsxs("div",{className:`flex flex-col items-center ${xt==="Sent to Work Control"?"text-blue-600":["Sent to technician","Sent to Supervisor","Closed"].includes(xt)?"text-green-600":"text-gray-400"}`,children:[e.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center text-[10px] ${xt==="Sent to Work Control"?"bg-blue-100 dark:bg-blue-900/30":["Sent to technician","Sent to Supervisor","Closed"].includes(xt)?"bg-green-100 dark:bg-green-900/30":"bg-gray-100 dark:bg-gray-700"}`,children:["Sent to technician","Sent to Supervisor","Closed"].includes(xt)?e.jsx(dc,{size:8}):"2"}),e.jsx("span",{className:"text-[8px] mt-0.5 text-center leading-tight",children:(()=>{const De=t("inspections.detail.workControl").split(" ");return De.length>=2?e.jsxs(e.Fragment,{children:[De[0],e.jsx("br",{}),De[1]]}):t("inspections.detail.workControl")})()})]}),e.jsx("div",{className:`flex-1 h-0.5 mx-0.5 ${["Sent to technician","Sent to Supervisor","Closed"].includes(xt)?"bg-green-500":"bg-gray-300 dark:bg-gray-600"}`}),e.jsxs("div",{className:`flex flex-col items-center ${xt==="Sent to technician"?"text-purple-600":["Sent to Supervisor","Closed"].includes(xt)?"text-green-600":"text-gray-400"}`,children:[e.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center text-[10px] ${xt==="Sent to technician"?"bg-purple-100 dark:bg-purple-900/30":["Sent to Supervisor","Closed"].includes(xt)?"bg-green-100 dark:bg-green-900/30":"bg-gray-100 dark:bg-gray-700"}`,children:["Sent to Supervisor","Closed"].includes(xt)?e.jsx(dc,{size:8}):"3"}),e.jsx("span",{className:"text-[8px] mt-0.5",children:t("inspections.detail.technicianStep")})]}),e.jsx("div",{className:`flex-1 h-0.5 mx-0.5 ${["Sent to Supervisor","Closed"].includes(xt)?"bg-green-500":"bg-gray-300 dark:bg-gray-600"}`}),e.jsxs("div",{className:`flex flex-col items-center ${xt==="Sent to Supervisor"?"text-indigo-600":xt==="Closed"?"text-green-600":"text-gray-400"}`,children:[e.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center text-[10px] ${xt==="Sent to Supervisor"?"bg-indigo-100 dark:bg-indigo-900/30":xt==="Closed"?"bg-green-100 dark:bg-green-900/30":"bg-gray-100 dark:bg-gray-700"}`,children:xt==="Closed"?e.jsx(dc,{size:8}):"4"}),e.jsx("span",{className:"text-[8px] mt-0.5",children:t("inspections.detail.supervisorStep")})]}),e.jsx("div",{className:`flex-1 h-0.5 mx-0.5 ${xt==="Closed"?"bg-green-500":"bg-gray-300 dark:bg-gray-600"}`}),e.jsxs("div",{className:`flex flex-col items-center ${xt==="Closed"?"text-green-600":"text-gray-400"}`,children:[e.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center text-[10px] ${xt==="Closed"?"bg-green-100 dark:bg-green-900/30":"bg-gray-100 dark:bg-gray-700"}`,children:xt==="Closed"?e.jsx(dc,{size:8}):"5"}),e.jsx("span",{className:"text-[8px] mt-0.5",children:t("inspections.detail.closedStep")})]})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-4 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-sm font-semibold text-gray-800 dark:text-white mb-3 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(bi,{className:"text-teal-500",size:14}),t("inspections.detail.statusInfo")]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:`p-2 rounded-lg border ${Dt.bg} ${Dt.border}`,children:[e.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:t("inspections.detail.workflow")}),e.jsx("p",{className:`text-sm font-semibold ${Dt.text}`,children:xt})]}),e.jsxs("div",{className:`p-2 rounded-lg border ${Ot.bg} ${Ot.border}`,children:[e.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:t("inspections.detail.status")}),e.jsx("p",{className:`text-sm font-semibold ${Ot.text}`,children:D.status||"Open"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[D.inspection_type&&e.jsxs("div",{className:"p-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:t("inspections.detail.inspectionType")}),e.jsx("p",{className:"text-xs font-medium text-gray-900 dark:text-white truncate",children:D.inspection_type})]}),D.work_order_type&&e.jsxs("div",{className:"p-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:t("inspections.detail.woType")}),e.jsx("p",{className:"text-xs font-medium text-gray-900 dark:text-white truncate",children:D.work_order_type})]})]}),D.assigned_technician&&e.jsxs("div",{className:"p-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:t("inspections.detail.assignedTo")}),e.jsx("p",{className:"text-xs font-medium text-gray-900 dark:text-white truncate",children:D.assigned_technician})]})]})]}),!i&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-2 cursor-pointer flex-1",onClick:()=>se(!ce),children:[e.jsx(_c,{className:"text-blue-500",size:14}),e.jsx("h2",{className:"text-sm font-semibold text-gray-800 dark:text-white",children:t("inspections.detail.activityLog")}),J.length>0&&e.jsx("span",{className:"px-1.5 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 rounded-full text-[10px] font-medium",children:J.length})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:De=>{De.stopPropagation(),Wt(),nt.info(t("inspections.detail.activityLogRefreshed"),{position:"top-right",autoClose:1500,icon:e.jsx(vn,{})})},disabled:ye,className:"p-1 text-gray-400 hover:text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded transition-colors disabled:opacity-50",title:t("inspections.detail.refreshActivityLog"),children:e.jsx(vn,{className:`${ye?"animate-spin":""}`,size:10})}),e.jsx("button",{type:"button",onClick:()=>se(!ce),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors p-1",children:ce?e.jsx(As,{size:12}):e.jsx(cs,{size:12})})]})]}),ce&&e.jsxs("div",{className:"p-3",children:[ye&&e.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsx(ya,{className:"animate-spin text-blue-500 mr-2",size:14}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:t("common.loading")})]}),!ye&&J.length===0&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-2 top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700"}),e.jsxs("div",{className:"relative pl-6 mb-3",children:[e.jsx("div",{className:"absolute left-1 top-1 w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 bg-gray-300 dark:bg-gray-600"}),e.jsx("div",{className:"p-2 rounded-lg bg-gray-50 dark:bg-gray-700/50",children:e.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400 italic",children:t("inspections.detail.noChangesRecorded")})})]}),(W==null?void 0:W.creation)&&(W==null?void 0:W.owner)&&e.jsxs("div",{className:"relative pl-6",children:[e.jsx("div",{className:"absolute left-1 top-1 w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 bg-green-500"}),e.jsxs("div",{className:"p-2 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-100 dark:border-green-800/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-5 h-5 rounded-full bg-green-200 dark:bg-green-800 flex items-center justify-center",children:e.jsx(js,{className:"text-green-600 dark:text-green-400",size:8})}),e.jsx("span",{className:"text-[10px] font-medium text-gray-700 dark:text-gray-300",children:sa(W.owner)})]}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-500 dark:text-gray-400",children:[e.jsx(or,{size:8}),e.jsx("span",{title:new Date(W.creation).toLocaleString(),children:ta(W.creation)})]})]}),e.jsx("div",{className:"text-[10px]",children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 bg-green-100 dark:bg-green-800/50 text-green-700 dark:text-green-300 rounded font-medium",children:[e.jsx(ea,{size:8}),t("inspections.detail.createdThisInspection")]})})]})]})]}),!ye&&J.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-2 top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700"}),e.jsx("div",{className:"space-y-3",children:(ee?J:J.slice(0,5)).map((De,Qe)=>e.jsxs("div",{className:"relative pl-6",children:[e.jsx("div",{className:`absolute left-1 top-1 w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 ${Qe===0?"bg-blue-500":"bg-gray-300 dark:bg-gray-600"}`}),e.jsxs("div",{className:`p-2 rounded-lg ${Qe===0?"bg-blue-50 dark:bg-blue-900/20 border border-blue-100 dark:border-blue-800/50":"bg-gray-50 dark:bg-gray-700/50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-600 flex items-center justify-center",children:e.jsx(js,{className:"text-gray-500 dark:text-gray-400",size:8})}),e.jsx("span",{className:"text-[10px] font-medium text-gray-700 dark:text-gray-300",children:sa(De.owner)})]}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-500 dark:text-gray-400",children:[e.jsx(or,{size:8}),e.jsx("span",{title:new Date(De.creation).toLocaleString(),children:ta(De.creation)})]})]}),e.jsxs("div",{className:"space-y-1",children:[De.changes.length>0?De.changes.map((fe,re)=>e.jsxs("div",{className:"text-[10px]",children:[e.jsx("span",{className:`font-medium ${ra(fe.field)}`,children:Vt(fe.field)}),e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[" ",t("inspections.detail.changedFrom")," "]}),e.jsx("span",{className:"px-1 py-0.5 bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400 rounded text-[9px] font-mono",children:va(fe.oldValue)}),e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:" → "}),e.jsx("span",{className:"px-1 py-0.5 bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400 rounded text-[9px] font-mono",children:va(fe.newValue)})]},re)):e.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400 italic",children:t("inspections.detail.documentUpdated")}),De.added&&De.added.length>0&&e.jsxs("div",{className:"text-[10px] text-green-600 dark:text-green-400",children:[e.jsx("span",{className:"font-medium",children:t("inspections.detail.added")})," ",De.added.length," ",t("inspections.detail.items")]}),De.removed&&De.removed.length>0&&e.jsxs("div",{className:"text-[10px] text-red-600 dark:text-red-400",children:[e.jsx("span",{className:"font-medium",children:t("inspections.detail.removed")})," ",De.removed.length," ",t("inspections.detail.items")]}),De.rowChanged&&De.rowChanged.length>0&&e.jsxs("div",{className:"text-[10px] text-orange-600 dark:text-orange-400",children:[e.jsx("span",{className:"font-medium",children:t("inspections.detail.modified")})," ",De.rowChanged.length," ",t("inspections.detail.rows")]})]})]})]},De.name))}),J.length>5&&e.jsx("div",{className:"mt-3 text-center",children:e.jsx("button",{type:"button",onClick:()=>te(!ee),className:"inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-md transition-colors",children:ee?e.jsxs(e.Fragment,{children:[e.jsx(As,{size:8}),t("inspections.detail.showLess")]}):e.jsxs(e.Fragment,{children:[e.jsx(cs,{size:8}),t("inspections.detail.showAll")," (",J.length,")"]})})}),(W==null?void 0:W.creation)&&(W==null?void 0:W.owner)&&e.jsxs("div",{className:"relative pl-6 mt-3",children:[e.jsx("div",{className:"absolute left-1 top-1 w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 bg-green-500"}),e.jsxs("div",{className:"p-2 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-100 dark:border-green-800/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-5 h-5 rounded-full bg-green-200 dark:bg-green-800 flex items-center justify-center",children:e.jsx(js,{className:"text-green-600 dark:text-green-400",size:8})}),e.jsx("span",{className:"text-[10px] font-medium text-gray-700 dark:text-gray-300",children:sa(W.owner)})]}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-500 dark:text-gray-400",children:[e.jsx(or,{size:8}),e.jsx("span",{title:new Date(W.creation).toLocaleString(),children:ta(W.creation)})]})]}),e.jsx("div",{className:"text-[10px]",children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 bg-green-100 dark:bg-green-800/50 text-green-700 dark:text-green-300 rounded font-medium",children:[e.jsx(ea,{size:8}),t("inspections.detail.createdThisInspection")]})})]})]})]})]})]}),!i&&b&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-4 border border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-800 dark:text-white mb-3 pb-2 border-b border-gray-200 dark:border-gray-700",children:"Delete Request"}),e.jsx(Ll,{doctype:"Inspection",docname:a,currentDeleteStatus:(Rt=W==null?void 0:W.custom_delete_status)!=null?Rt:null,userRoles:g,isSystemManager:K,redirectOnDelete:"/inspections",onStatusChange:()=>ae()})]})]})]})]})};class $P{constructor(){Mn(this,"baseURL");this.baseURL=ia.BASE_URL}getCSRFToken(){return Q(this,null,function*(){try{return typeof window!="undefined"&&window.csrf_token?window.csrf_token:null}catch(a){return null}})}getHeaders(){return Q(this,null,function*(){const a={Accept:"application/json","Content-Type":"application/json"},r=yield this.getCSRFToken();return r&&(a["X-Frappe-CSRF-Token"]=r),a})}getSupportPlans(){return Q(this,arguments,function*(a={}){const{filters:r={},fields:s=["name","support_plan","frequency","max_downtime_hrs","asset","starting_date","penalty_factor","custom_contractwarranty","custom_contract_value","warranty","warranty_start_date","warranty_end_date","war_status","extended_warranty","service_contract","spare_parts","spare_parts_labour","labour","ppm_only","start_date","end_date","service_contract_status","vendor","creation","modified","owner","modified_by","docstatus"],limit_start:i=0,limit_page_length:c=20,order_by:d="creation desc"}=a,m=new URLSearchParams;if(m.append("fields",JSON.stringify(s)),m.append("limit_start",i.toString()),m.append("limit_page_length",c.toString()),m.append("order_by",d),Object.keys(r).length>0){const p=Ks(r);p.length>0&&m.append("filters",JSON.stringify(p))}const h=yield fetch(`${this.baseURL}/api/resource/Support Plans?${m.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);return{data:(yield h.json()).data||[]}})}getSupportPlan(a){return Q(this,null,function*(){const r=yield fetch(`${this.baseURL}/api/resource/Support Plans/${encodeURIComponent(a)}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return(yield r.json()).data})}createSupportPlan(a){return Q(this,null,function*(){const r=yield fetch(`${this.baseURL}/api/resource/Support Plans`,{method:"POST",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(a)});if(!r.ok){const i=yield r.json().catch(()=>({}));throw new Error(i.message||`HTTP error! status: ${r.status}`)}return(yield r.json()).data})}updateSupportPlan(a,r){return Q(this,null,function*(){const s=yield fetch(`${this.baseURL}/api/resource/Support Plans/${encodeURIComponent(a)}`,{method:"PUT",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(r)});if(!s.ok){const c=yield s.json().catch(()=>({}));throw new Error(c.message||`HTTP error! status: ${s.status}`)}return(yield s.json()).data})}deleteSupportPlan(a){return Q(this,null,function*(){const r=yield fetch(`${this.baseURL}/api/resource/Support Plans/${encodeURIComponent(a)}`,{method:"DELETE",headers:yield this.getHeaders(),credentials:"include"});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`)})}getSupportPlanCount(){return Q(this,arguments,function*(a={}){var c,d;const r=new URLSearchParams;if(r.append("fields",JSON.stringify(["count(name) as count"])),Object.keys(a).length>0){const m=Ks(a);m.length>0&&r.append("filters",JSON.stringify(m))}const s=yield fetch(`${this.baseURL}/api/resource/Support Plans?${r.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return((d=(c=(yield s.json()).data)==null?void 0:c[0])==null?void 0:d.count)||0})}getCurrentUser(){return Q(this,null,function*(){try{const a=yield fetch(`${this.baseURL}/api/method/frappe.auth.get_logged_user`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return(yield a.json()).message||""}catch(a){return console.error("Error getting current user:",a),""}})}}const du=new $P,HP=(t={})=>{const[a,r]=y.useState([]),[s,i]=y.useState(!0),[c,d]=y.useState(null),[m,h]=y.useState(0),g=y.useCallback(()=>Q(null,null,function*(){try{i(!0),d(null);const p=yield du.getSupportPlans(t);r(p.data);const j=yield(yield fetch("/api/method/frappe.client.get_count",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Support Plans",filters:t.filters||{}})})).json();h(j.message||p.data.length)}catch(p){d(p instanceof Error?p.message:"Failed to fetch support plans"),r([])}finally{i(!1)}}),[t.filters,t.limit_start,t.limit_page_length,t.order_by]);return y.useEffect(()=>{g()},[g]),{supportPlans:a,loading:s,error:c,totalCount:m,refetch:g}},WP=t=>{const[a,r]=y.useState(null),[s,i]=y.useState(!0),[c,d]=y.useState(null),m=y.useCallback(()=>Q(null,null,function*(){if(!t){i(!1);return}try{i(!0),d(null);const h=yield du.getSupportPlan(t);r(h)}catch(h){d(h instanceof Error?h.message:"Failed to fetch support plan"),r(null)}finally{i(!1)}}),[t]);return y.useEffect(()=>{m()},[m]),{supportPlan:a,loading:s,error:c,refetch:m}},VP=()=>{const[t,a]=y.useState(!1),[r,s]=y.useState(null),i=y.useCallback(m=>Q(null,null,function*(){try{return a(!0),s(null),yield du.createSupportPlan(m)}catch(h){const g=h instanceof Error?h.message:"Failed to create support plan";throw s(g),h}finally{a(!1)}}),[]),c=y.useCallback((m,h)=>Q(null,null,function*(){try{return a(!0),s(null),yield du.updateSupportPlan(m,h)}catch(g){const p=g instanceof Error?g.message:"Failed to update support plan";throw s(p),g}finally{a(!1)}}),[]),d=y.useCallback(m=>Q(null,null,function*(){try{a(!0),s(null),yield du.deleteSupportPlan(m)}catch(h){const g=h instanceof Error?h.message:"Failed to delete support plan";throw s(g),h}finally{a(!1)}}),[]);return{createSupportPlan:i,updateSupportPlan:c,deleteSupportPlan:d,loading:t,error:r}},qP=({isOpen:t,onClose:a,selectedCount:r,totalCount:s,pageCount:i,onExport:c,isExporting:d,exportColumns:m})=>{const{t:h}=ca(),[g,p]=y.useState(r>0?"selected":"all_with_filters"),[b,j]=y.useState("csv"),[_,N]=y.useState(m.filter(T=>T.default).map(T=>T.key));y.useEffect(()=>{p(r>0?"selected":"all_with_filters")},[r]);const k=T=>N(E=>E.includes(T)?E.filter(O=>O!==T):[...E,T]),C=()=>N(m.map(T=>T.key)),D=()=>N(m.filter(T=>T.default).map(T=>T.key));return t?e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] overflow-hidden animate-scale-in",children:[e.jsx("div",{className:"bg-gradient-to-r from-indigo-500 to-indigo-600 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Os,{className:"text-white text-xl"}),e.jsx("h3",{className:"text-lg font-semibold text-white",children:h("supportPlans.export.title")})]}),e.jsx("button",{onClick:a,className:"text-white/80 hover:text-white transition-colors",disabled:d,children:e.jsx(wt,{size:20})})]})}),e.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:h("supportPlans.export.selectData")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="selected"?"border-indigo-500 bg-indigo-50 dark:bg-indigo-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"} ${r===0?"opacity-50 cursor-not-allowed":""}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"selected",checked:g==="selected",onChange:()=>p("selected"),disabled:r===0,className:"text-indigo-600"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("supportPlans.export.selectedRows")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("supportPlans.export.selectedCount",{count:r})})]}),r>0&&e.jsxs("span",{className:"bg-indigo-100 dark:bg-indigo-900/40 text-indigo-700 dark:text-indigo-300 px-2 py-1 rounded text-xs font-medium",children:[r," selected"]})]}),e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="all_on_page"?"border-indigo-500 bg-indigo-50 dark:bg-indigo-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:g==="all_on_page",onChange:()=>p("all_on_page"),className:"text-indigo-600"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("supportPlans.export.currentPage")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("supportPlans.export.currentPageCount",{count:i})})]}),e.jsxs("span",{className:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 px-2 py-1 rounded text-xs font-medium",children:[i," rows"]})]}),e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${g==="all_with_filters"?"border-indigo-500 bg-indigo-50 dark:bg-indigo-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:g==="all_with_filters",onChange:()=>p("all_with_filters"),className:"text-indigo-600"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("supportPlans.export.allWithFilters")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:h("supportPlans.export.allWithFiltersCount",{count:s})})]}),e.jsxs("span",{className:"bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300 px-2 py-1 rounded text-xs font-medium",children:[s," total"]})]})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:h("supportPlans.export.exportFormat")}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${b==="csv"?"border-indigo-500 bg-indigo-50 dark:bg-indigo-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"format",value:"csv",checked:b==="csv",onChange:()=>j("csv"),className:"text-indigo-600"}),e.jsx(Bi,{className:"text-indigo-600 text-xl"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("supportPlans.export.csv")}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("supportPlans.export.csvDesc")})]})]}),e.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${b==="excel"?"border-indigo-500 bg-indigo-50 dark:bg-indigo-900/20":"border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[e.jsx("input",{type:"radio",name:"format",value:"excel",checked:b==="excel",onChange:()=>j("excel"),className:"text-indigo-600"}),e.jsx(Ui,{className:"text-green-700 text-xl"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h("supportPlans.export.excel")}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h("supportPlans.export.excelDesc")})]})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:h("supportPlans.export.columnsToExport")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:C,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("supportPlans.export.selectAll")}),e.jsx("span",{className:"text-gray-300",children:"|"}),e.jsx("button",{onClick:D,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:h("supportPlans.export.resetToDefault")})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2 max-h-48 overflow-y-auto p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg",children:m.map(T=>e.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${_.includes(T.key)?"bg-indigo-100 dark:bg-indigo-900/30 text-indigo-800 dark:text-indigo-300":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-400"}`,children:[e.jsx("input",{type:"checkbox",checked:_.includes(T.key),onChange:()=>k(T.key),className:"rounded text-indigo-600"}),e.jsx("span",{className:"text-sm truncate",children:T.label})]},T.key))}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:h("supportPlans.export.columnsSelected",{count:_.length})})]})]}),e.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-900/50 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[g==="selected"&&h("supportPlans.export.exportingSelected",{count:r}),g==="all_on_page"&&h("supportPlans.export.exportingPage",{count:i}),g==="all_with_filters"&&h("supportPlans.export.exportingAll",{count:s})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",disabled:d,children:h("common.cancel")}),e.jsx("button",{onClick:()=>c(g,b,_),disabled:_.length===0||d,className:"px-4 py-2 text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 rounded-lg flex items-center gap-2 disabled:opacity-50",children:d?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),h("supportPlans.export.exporting")]}):e.jsxs(e.Fragment,{children:[e.jsx(po,{}),h("supportPlans.export.exportButton")]})})]})]})]})}):null},GP=t=>{switch(t==null?void 0:t.toLowerCase()){case"contract":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300";case"warranty":return"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},B_=t=>{switch(t==null?void 0:t.toLowerCase()){case"active":return"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300";case"inactive":return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300";case"expired":return"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},YP=t=>{switch(t==null?void 0:t.toLowerCase()){case"monthly":return"bg-cyan-100 text-cyan-800 dark:bg-cyan-900/30 dark:text-cyan-300";case"quarterly":return"bg-indigo-100 text-indigo-800 dark:bg-indigo-900/30 dark:text-indigo-300";case"half-yearly":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300";case"yearly":return"bg-pink-100 text-pink-800 dark:bg-pink-900/30 dark:text-pink-300";default:return"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300"}},ZP=()=>{const{t}=ca(),a=qa(),r=[{key:"name",label:t("supportPlans.planId"),default:!0},{key:"support_plan",label:t("supportPlans.table.planName"),default:!0},{key:"frequency",label:t("supportPlans.table.frequency"),default:!0},{key:"custom_contractwarranty",label:t("supportPlans.table.type"),default:!0},{key:"custom_contract_value",label:t("supportPlans.table.contractValue"),default:!0},{key:"war_status",label:t("supportPlans.table.warrantyStatus"),default:!0},{key:"service_contract_status",label:t("supportPlans.table.contractStatus"),default:!0},{key:"max_downtime_hrs",label:"Max Downtime (hrs)",default:!1},{key:"penalty_factor",label:"Penalty Factor",default:!1},{key:"asset",label:t("filters.asset"),default:!1},{key:"vendor",label:t("commonFields.supplier"),default:!0},{key:"warranty_start_date",label:t("assets.warrantyStartDate"),default:!1},{key:"warranty_end_date",label:t("assets.warrantyEndDate"),default:!1},{key:"start_date",label:t("assets.serviceStartDate"),default:!1},{key:"end_date",label:t("assets.serviceEndDate"),default:!1},{key:"creation",label:t("commonFields.createdOn"),default:!1},{key:"owner",label:t("commonFields.createdBy"),default:!1}],[s,i]=Qs(),c=y.useMemo(()=>{const ve=parseInt(s.get("page")||"1",10);return Number.isNaN(ve)||ve<1?1:ve},[s]),d=y.useCallback(ve=>{const Oe=typeof ve=="function"?ve(c):ve;i(ht=>{const et=new URLSearchParams(ht);return et.set("page",String(Oe)),et})},[c,i]),[m]=y.useState(20),[h,g]=y.useState(!1),[p,b]=y.useState(new Set),[j,_]=y.useState(!1),[N,k]=y.useState(!1),[C,D]=y.useState(null),[T,E]=y.useState(!0),[O,R]=y.useState(!0),[Y,P]=y.useState(()=>s.get("date_filter_by")||""),[U,J]=y.useState(()=>s.get("date_start")||""),[ne,ye]=y.useState(()=>s.get("date_end")||""),[he,ce]=y.useState(()=>s.get("contract_warranty")||""),[se,ee]=y.useState(()=>s.get("frequency")||""),[te,W]=y.useState(()=>s.get("war_status")||""),[I,oe]=y.useState(()=>s.get("service_contract_status")||""),[ae,F]=y.useState(()=>s.get("vendor")||""),[M,B]=y.useState(()=>s.get("asset")||""),[X,K]=y.useState(!1),[we,be]=y.useState(0),[ke,Me]=y.useState([]),[z,Ne]=y.useState(!1),[Xe,gt]=y.useState("");y.useEffect(()=>{const ve=localStorage.getItem("supportPlanFilterPresets");ve&&Me(JSON.parse(ve))},[]);const St=Y&&(U||ne);y.useEffect(()=>{const ve=[he,se,te,I,ae,M].filter(Boolean).length+(St?1:0);be(ve)},[he,se,te,I,ae,M,St]);const Ht=y.useMemo(()=>{const ve={};return he&&(ve.custom_contractwarranty=he),se&&(ve.frequency=se),te&&(ve.war_status=te),I&&(ve.service_contract_status=I),ae&&(ve.vendor=ae),M&&(ve.asset=M),Object.assign(ve,el(Y,U,ne)),ve},[he,se,te,I,ae,M,Y,U,ne]),{supportPlans:Mt,loading:Te,error:Qt,totalCount:zt,refetch:Wt}=HP({filters:Ht,limit_start:(c-1)*m,limit_page_length:m,order_by:"creation desc"});y.useEffect(()=>{!Te&&!h&&g(!0)},[Te,h]);const Vt=y.useRef(!1);y.useEffect(()=>{if(!Vt.current){Vt.current=!0;return}i(ve=>{const Oe=new URLSearchParams(ve);return Y?Oe.set("date_filter_by",Y):Oe.delete("date_filter_by"),U?Oe.set("date_start",U):Oe.delete("date_start"),ne?Oe.set("date_end",ne):Oe.delete("date_end"),he?Oe.set("contract_warranty",he):Oe.delete("contract_warranty"),se?Oe.set("frequency",se):Oe.delete("frequency"),te?Oe.set("war_status",te):Oe.delete("war_status"),I?Oe.set("service_contract_status",I):Oe.delete("service_contract_status"),ae?Oe.set("vendor",ae):Oe.delete("vendor"),M?Oe.set("asset",M):Oe.delete("asset"),Oe.set("page","1"),Oe})},[Y,U,ne,he,se,te,I,ae,M]),y.useEffect(()=>{b(new Set)},[Y,U,ne,he,se,te,I,ae,M,c]);const va=ve=>{if(!ve)return"-";const Oe=typeof ve=="string"?parseFloat(ve):ve;return new Intl.NumberFormat("en-US",{style:"currency",currency:"SAR"}).format(Oe)},ta=()=>{P(""),J(""),ye(""),ce(""),ee(""),W(""),oe(""),F(""),B(""),i(ve=>{const Oe=new URLSearchParams(ve);return Oe.delete("date_filter_by"),Oe.delete("date_start"),Oe.delete("date_end"),Oe.delete("contract_warranty"),Oe.delete("frequency"),Oe.delete("war_status"),Oe.delete("service_contract_status"),Oe.delete("vendor"),Oe.delete("asset"),Oe.set("page","1"),Oe})},sa=St||!!he||!!se||!!te||!!I||!!ae||!!M,ra=()=>{if(!Xe.trim()){alert("Please enter a filter name");return}const ve={id:Date.now(),name:Xe,filters:{dateFilterBy:Y,dateStart:U,dateEnd:ne,contractWarrantyFilter:he,frequencyFilter:se,warStatusFilter:te,serviceContractStatusFilter:I,vendorFilter:ae,assetFilter:M}},Oe=[...ke,ve];Me(Oe),gt(""),Ne(!1),localStorage.setItem("supportPlanFilterPresets",JSON.stringify(Oe))},Ye=ve=>{const Oe=ve.filters;P(Oe.dateFilterBy||""),J(Oe.dateStart||""),ye(Oe.dateEnd||""),ce(Oe.contractWarrantyFilter||""),ee(Oe.frequencyFilter||""),W(Oe.warStatusFilter||""),oe(Oe.serviceContractStatusFilter||""),F(Oe.vendorFilter||""),B(Oe.assetFilter||"")},ft=ve=>{const Oe=ke.filter(ht=>ht.id!==ve);Me(Oe),localStorage.setItem("supportPlanFilterPresets",JSON.stringify(Oe))},$t=ve=>b(Oe=>{const ht=new Set(Oe);return ht.has(ve)?ht.delete(ve):ht.add(ve),ht}),na=()=>p.size===Mt.length?b(new Set):b(new Set(Mt.map(ve=>ve.name))),Ze=Mt.length>0&&p.size===Mt.length,lt=p.size>0&&p.size<Mt.length,aa=y.useCallback(()=>Q(null,null,function*(){const ve=[];let Oe=0;const ht=100;let et=!0;const Be=Ks(Ht);for(;et;)try{const xt=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Support Plans",filters:Be.length>0?Be:{},fields:["*"],limit_start:Oe*ht,limit_page_length:ht,order_by:"creation desc"})})).json()).message||[];ve.push(...xt),xt.length<ht?et=!1:Oe++,Oe>100&&(console.warn("Export safety limit reached"),et=!1)}catch(kt){throw console.error("Error fetching support plans for export:",kt),kt}return ve}),[Ht]),Ie=(ve,Oe,ht)=>Q(null,null,function*(){k(!0);try{let et=[];switch(ve){case"selected":et=Mt.filter(kt=>p.has(kt.name));break;case"all_on_page":et=Mt;break;case"all_with_filters":et=yield aa();break}if(et.length===0){alert(t("assets.noDataToExport"));return}const Be=ht.map(kt=>{var it;return((it=r.find(xt=>xt.key===kt))==null?void 0:it.label)||kt});if(Oe==="csv"){const kt=[Be.join(","),...et.map(Ot=>ht.map(Rt=>{var Qe;let De=(Qe=Ot[Rt])!=null?Qe:"";return typeof De=="string"&&(De.includes(",")||De.includes('"')||De.includes(`
`))&&(De=`"${De.replace(/"/g,'""')}"`),De}).join(","))].join(`
`),it=new Blob(["\uFEFF"+kt],{type:"text/csv;charset=utf-8;"}),xt=URL.createObjectURL(it),Dt=document.createElement("a");Dt.href=xt,Dt.download=`support_plans_export_${new Date().toISOString().split("T")[0]}.csv`,Dt.click(),URL.revokeObjectURL(xt)}else if(Oe==="excel"){const kt=[Be,...et.map(Dt=>ht.map(Ot=>{var Rt;return(Rt=Dt[Ot])!=null?Rt:""}))],it=Ja.aoa_to_sheet(kt),xt=Ja.book_new();Ja.book_append_sheet(xt,it,"Support Plans"),$i(xt,`support_plans_export_${new Date().toISOString().split("T")[0]}.xlsx`)}_(!1),b(new Set)}catch(et){console.error("Export failed:",et),alert(`Export failed: ${et instanceof Error?et.message:"Unknown error"}`)}finally{k(!1)}}),Nt=ve=>Q(null,null,function*(){try{if(!(yield fetch(`/api/resource/Support Plans/${encodeURIComponent(ve)}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to delete");D(null),Wt(),alert(t("supportPlans.deletedSuccessfully"))}catch(Oe){alert(`Failed to delete: ${Oe instanceof Error?Oe.message:"Unknown error"}`)}});return Te&&!h?e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("supportPlans.loadingSupportPlans")})]})}):Qt?e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:t("supportPlans.errorLoadingSupportPlans")}),e.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:Qt}),e.jsx("button",{onClick:Wt,className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded",children:"Try Again"})]})}):e.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(au,{className:"text-3xl text-indigo-600 dark:text-indigo-400"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:t("supportPlans.listTitle")}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t("issues.listTotal"),": ",zt,p.size>0&&e.jsxs("span",{className:"ml-2 text-indigo-600 dark:text-indigo-400",children:["• ",p.size," selected"]}),Te&&h&&e.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-indigo-600 dark:text-indigo-400",children:[e.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-indigo-500"}),"Updating..."]})]})]})]})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:()=>K(!X),className:`px-4 py-2 rounded-lg flex items-center gap-2 transition-colors ${X||sa?"bg-indigo-100 text-indigo-700 dark:bg-indigo-900/30 dark:text-indigo-300":"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600"}`,children:[e.jsx(ds,{}),"Filters",we>0&&e.jsx("span",{className:"bg-indigo-600 text-white text-xs px-1.5 py-0.5 rounded-full",children:we})]}),e.jsxs("button",{onClick:Wt,disabled:Te,className:"px-4 py-2 rounded-lg bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 flex items-center gap-2 disabled:opacity-50",children:[e.jsx(vn,{className:Te?"animate-spin":""}),"Refresh"]}),e.jsxs("button",{onClick:()=>_(!0),className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow",disabled:zt===0,children:[e.jsx(Os,{}),e.jsx("span",{className:"font-medium",children:t("listPages.export")}),p.size>0&&e.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:p.size})]}),O&&e.jsxs("button",{onClick:()=>a("/sla/new"),className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 shadow-lg",children:[e.jsx(Zs,{}),e.jsx("span",{className:"font-medium",children:t("supportPlans.createFirstSupportPlan")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-4",children:[e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("supportPlans.statsTotalPlans")}),e.jsx("p",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:zt})]}),e.jsx(au,{className:"text-3xl text-indigo-500"})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("supportPlans.statsContracts")}),e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:Mt.filter(ve=>ve.custom_contractwarranty==="Contract").length})]}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center",children:e.jsx(uh,{className:"text-blue-600"})})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("supportPlans.statsWarranties")}),e.jsx("p",{className:"text-2xl font-bold text-purple-600",children:Mt.filter(ve=>ve.custom_contractwarranty==="Warranty").length})]}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-purple-100 dark:bg-purple-900/30 flex items-center justify-center",children:e.jsx(Kx,{className:"text-purple-600"})})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("supportPlans.statsActive")}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:Mt.filter(ve=>ve.service_contract_status==="Active"||ve.war_status==="Active").length})]}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:e.jsx("span",{className:"text-green-600 font-bold",children:"✓"})})]})})]}),X&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[e.jsx("div",{className:"bg-gradient-to-r from-indigo-500 to-indigo-600 px-4 py-3 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ds,{className:"text-white",size:16}),e.jsx("h3",{className:"text-white font-semibold text-sm",children:"Filters"}),we>0&&e.jsx("span",{className:"bg-white text-indigo-600 px-2 py-0.5 rounded-full text-xs font-bold",children:we})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[we>0&&e.jsxs("button",{onClick:()=>Ne(!0),className:"px-3 py-1.5 bg-white text-indigo-600 hover:bg-indigo-50 rounded-md text-xs font-medium flex items-center gap-1.5",children:[e.jsx(Or,{size:12}),"Save"]}),sa&&e.jsxs("button",{onClick:ta,className:"px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white rounded-md text-xs font-medium flex items-center gap-1.5",children:[e.jsx(wt,{size:12}),"Clear"]})]})]})}),e.jsxs("div",{className:"p-4",children:[ke.length>0&&e.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[e.jsx(Tc,{className:"text-yellow-500",size:12}),"Saved Filters"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ke.map(ve=>e.jsxs("div",{className:"group relative inline-flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-indigo-100 to-blue-100 dark:from-indigo-900/30 dark:to-blue-900/30 border border-indigo-200 dark:border-indigo-700 rounded-lg hover:shadow-md",children:[e.jsx("button",{onClick:()=>Ye(ve),className:"text-xs font-medium text-indigo-700 dark:text-indigo-300",children:ve.name}),e.jsx("button",{onClick:()=>ft(ve.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700",children:e.jsx(Na,{size:10})})]},ve.id))})]}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-6 gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.filterBy")}),e.jsxs("select",{value:Y,onChange:ve=>{const Oe=ve.target.value;P(Oe),d(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:t("filters.filterBy")}),e.jsx("option",{value:"creation",children:t("filters.createdDate")}),e.jsx("option",{value:"modified",children:t("filters.latestModifiedDate")})]})]}),Y&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.startDate")}),e.jsx("input",{type:"date",value:U,onChange:ve=>{const Oe=ve.target.value;J(Oe),ne&&Oe>ne&&ye(Oe),d(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:t("filters.endDate")}),e.jsx("input",{type:"date",value:ne,onChange:ve=>{ye(ve.target.value),d(1)},min:U||void 0,className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Contract/Warranty"}),e.jsxs("select",{value:he,onChange:ve=>{ce(ve.target.value),d(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:"All Types"}),e.jsx("option",{value:"Contract",children:"Contract"}),e.jsx("option",{value:"Warranty",children:"Warranty"})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Frequency"}),e.jsxs("select",{value:se,onChange:ve=>{ee(ve.target.value),d(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:"All Frequencies"}),e.jsx("option",{value:"Monthly",children:"Monthly"}),e.jsx("option",{value:"Quarterly",children:"Quarterly"}),e.jsx("option",{value:"Half-Yearly",children:"Half-Yearly"}),e.jsx("option",{value:"Yearly",children:"Yearly"})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Warranty Status"}),e.jsxs("select",{value:te,onChange:ve=>{W(ve.target.value),d(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:"All Statuses"}),e.jsx("option",{value:"Active",children:"Active"}),e.jsx("option",{value:"Inactive",children:"Inactive"}),e.jsx("option",{value:"Expired",children:"Expired"})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Contract Status"}),e.jsxs("select",{value:I,onChange:ve=>{oe(ve.target.value),d(1)},className:"w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white",children:[e.jsx("option",{value:"",children:"All Statuses"}),e.jsx("option",{value:"Active",children:"Active"}),e.jsx("option",{value:"Inactive",children:"Inactive"}),e.jsx("option",{value:"Expired",children:"Expired"})]})]}),e.jsxs("div",{className:"relative z-[60]",children:[e.jsx(Ut,{label:"Vendor",doctype:"Supplier",value:ae,onChange:ve=>{F(ve),d(1)},placeholder:"Select Vendor",disabled:!1,compact:!0}),ae&&e.jsx("button",{onClick:()=>F(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 z-10",children:e.jsx(wt,{size:10})})]}),e.jsxs("div",{className:"relative z-[59]",children:[e.jsx(Ut,{label:"Asset",doctype:"Asset",value:M,onChange:ve=>{B(ve),d(1)},placeholder:"Select Asset",disabled:!1,compact:!0}),M&&e.jsx("button",{onClick:()=>B(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 z-10",children:e.jsx(wt,{size:10})})]})]})})]})]}),z&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:t("common.saveFilterPreset")}),e.jsx("input",{type:"text",value:Xe,onChange:ve=>gt(ve.target.value),onKeyDown:ve=>{ve.key==="Enter"&&ra()},placeholder:t("common.enterFilterName"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white mb-4",autoFocus:!0}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>{Ne(!1),gt("")},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md",children:t("common.cancel")}),e.jsxs("button",{onClick:ra,className:"px-4 py-2 text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 rounded-md flex items-center gap-2",children:[e.jsx(Or,{size:12}),t("common.saveFilter")]})]})]})}),e.jsx(qP,{isOpen:j,onClose:()=>_(!1),selectedCount:p.size,totalCount:zt,pageCount:Mt.length,onExport:Ie,isExporting:N,exportColumns:r}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700 overflow-hidden relative",children:[Te&&h&&e.jsx("div",{className:"absolute inset-0 bg-white/60 dark:bg-gray-800/60 flex items-center justify-center z-10 backdrop-blur-[1px]",children:e.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[e.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-indigo-500"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:t("common.filtering")})]})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left",children:e.jsx("button",{onClick:na,className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400",title:Ze?"Deselect all":"Select all",children:Ze?e.jsx(Es,{className:"text-indigo-600 dark:text-indigo-400",size:18}):lt?e.jsxs("div",{className:"relative",children:[e.jsx(Ar,{size:18}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):e.jsx(Ar,{size:18})})}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("supportPlans.table.planName","Plan Name")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("supportPlans.table.type","Type")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("supportPlans.table.frequency","Frequency")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("supportPlans.table.contractValue","Contract Value")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("commonFields.status")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("commonFields.supplier")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("listPages.actions")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:Mt.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:"px-4 py-12 text-center text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(au,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),e.jsx("p",{children:t("supportPlans.noSupportPlansFound","No support plans found")}),sa?e.jsx("button",{onClick:ta,className:"mt-4 text-indigo-600 dark:text-indigo-400 hover:underline",children:t("common.clearFilters")}):O?e.jsx("button",{onClick:()=>a("/sla/new"),className:"mt-4 text-indigo-600 dark:text-indigo-400 hover:underline",children:t("supportPlans.createFirstSupportPlan","Create your first support plan")}):null]})})}):Mt.map(ve=>e.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer transition-colors ${p.has(ve.name)?"bg-indigo-50 dark:bg-indigo-900/20":""}`,onClick:()=>a(`/sla/${ve.name}`),children:[e.jsx("td",{className:"px-4 py-3",onClick:Oe=>Oe.stopPropagation(),children:e.jsx("button",{onClick:()=>$t(ve.name),className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400",children:p.has(ve.name)?e.jsx(Es,{className:"text-indigo-600 dark:text-indigo-400",size:18}):e.jsx(Ar,{size:18})})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-indigo-600 dark:text-indigo-400",children:ve.support_plan||ve.name}),ve.asset&&e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 flex items-center gap-1",children:[e.jsx(wc,{size:10})," ",ve.asset]})]})}),e.jsx("td",{className:"px-4 py-3",children:ve.custom_contractwarranty?e.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${GP(ve.custom_contractwarranty)}`,children:ve.custom_contractwarranty}):e.jsx("span",{className:"text-gray-400",children:"-"})}),e.jsx("td",{className:"px-4 py-3",children:ve.frequency?e.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${YP(ve.frequency)}`,children:ve.frequency}):e.jsx("span",{className:"text-gray-400",children:"-"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:va(ve.custom_contract_value)})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[ve.custom_contractwarranty==="Warranty"&&ve.war_status&&e.jsxs("span",{className:`inline-flex px-2 py-0.5 text-[10px] font-medium rounded-full ${B_(ve.war_status)}`,children:[t("supportPlans.statusLabel.warrantyPrefix","W:")," ",t(`supportPlans.status.${ve.war_status.toLowerCase().replace(/\\s+/g,"_")}`,ve.war_status)]}),ve.custom_contractwarranty==="Contract"&&ve.service_contract_status&&e.jsxs("span",{className:`inline-flex px-2 py-0.5 text-[10px] font-medium rounded-full ${B_(ve.service_contract_status)}`,children:[t("supportPlans.statusLabel.contractPrefix","C:")," ",t(`supportPlans.status.${ve.service_contract_status.toLowerCase().replace(/\\s+/g,"_")}`,ve.service_contract_status)]}),!ve.war_status&&!ve.service_contract_status&&e.jsx("span",{className:"text-gray-400",children:"-"})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300 line-clamp-1",children:ve.vendor||"-"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1",onClick:Oe=>Oe.stopPropagation(),children:[e.jsx("button",{onClick:()=>a(`/sla/${ve.name}`),className:"text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 p-2 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded",title:t("supportPlans.viewDetails","View"),children:e.jsx(ri,{})}),e.jsx("button",{onClick:()=>a(`/sla/${ve.name}?edit=true`),className:"text-green-600 dark:text-green-400 hover:text-green-900 dark:hover:text-green-300 p-2 hover:bg-green-50 dark:hover:bg-green-900/30 rounded",title:t("supportPlans.editSupportPlan","Edit"),children:e.jsx(Fr,{})}),T&&e.jsx("button",{onClick:()=>D(ve.name),className:"text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300 p-2 hover:bg-red-50 dark:hover:bg-red-900/30 rounded",title:t("common.delete"),children:e.jsx(Na,{})})]})})]},ve.name))})]})}),e.jsx(Rc,{currentPage:c,totalCount:zt,pageSize:m,itemLabel:t("pagination.plans"),onPageChange:ve=>d(ve)})]}),C&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:e.jsx(Na,{className:"text-red-600 dark:text-red-400 text-xl"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:t("supportPlans.deleteSupportPlan")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:t("supportPlans.deleteConfirmMessage")}),e.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-md p-3 mb-4",children:e.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[e.jsxs("strong",{children:[t("supportPlans.planId"),":"]})," ",C]})}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>D(null),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-lg",children:t("common.cancel")}),e.jsxs("button",{onClick:()=>Nt(C),className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg flex items-center gap-2",children:[e.jsx(Na,{}),t("common.delete")]})]})]})]})})}),e.jsx("style",{children:`
@keyframes scale-in { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.animate-scale-in { animation: scale-in 0.2s ease-out; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
.scrollbar-hide::-webkit-scrollbar { display: none; }
`})]})},U_=t=>{switch(t==null?void 0:t.toLowerCase()){case"active":return{bg:"bg-green-100 dark:bg-green-900/30",text:"text-green-800 dark:text-green-300",border:"border-green-200 dark:border-green-800"};case"inactive":return{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-800 dark:text-gray-300",border:"border-gray-200 dark:border-gray-600"};case"expired":return{bg:"bg-red-100 dark:bg-red-900/30",text:"text-red-800 dark:text-red-300",border:"border-red-200 dark:border-red-800"};default:return{bg:"bg-gray-100 dark:bg-gray-700",text:"text-gray-800 dark:text-gray-300",border:"border-gray-200 dark:border-gray-600"}}},JP=()=>{var K,we;const{t}=ca(),{slaName:a}=xo(),[r]=Qs(),s=qa(),i=a==="new",c=r.get("edit")==="true",[d,m]=y.useState(!0),[h,g]=y.useState(!1),[p,b]=y.useState([]),[j,_]=y.useState(!1),[N,k]=y.useState(!1),[C,D]=y.useState(!1),[T,E]=y.useState({support_plan:"",frequency:"Quarterly",max_downtime_hrs:0,asset:null,starting_date:null,penalty_factor:5,custom_contractwarranty:"Contract",custom_contract_value:"",warranty:0,warranty_start_date:null,warranty_end_date:null,war_status:"Active",extended_warranty:0,start:null,end:null,service_contract:1,spare_parts:1,spare_parts_labour:0,labour:0,ppm_only:0,no:0,start_date:null,end_date:null,service_contract_status:"Active",vendor:null,asset_list:[]}),{supportPlan:O,loading:R,error:Y,refetch:P}=WP(i?null:a||null),{createSupportPlan:U,updateSupportPlan:J,deleteSupportPlan:ne,loading:ye}=VP(),[he,ce]=y.useState(i||c),se=y.useCallback(()=>Q(null,null,function*(){if(!(i||!a)){_(!0);try{const ke=yield(yield fetch(`/api/resource/Version?filters=[["ref_doctype","=","Support Plans"],["docname","=","${encodeURIComponent(a)}"]]&fields=["name","owner","creation","data"]&order_by=creation desc&limit=50`)).json();if(ke!=null&&ke.data&&ke.data.length>0){const Me=ke.data.map(z=>{let Ne={changed:[]};try{Ne=JSON.parse(z.data||"{}")}catch(Xe){}return{name:z.name,owner:z.owner,creation:z.creation,changes:(Ne.changed||[]).map(Xe=>({field:Xe[0]||"",oldValue:Xe[1],newValue:Xe[2]}))}});b(Me)}else b([])}catch(be){console.error("Error fetching audit logs:",be),b([])}finally{_(!1)}}}),[i,a]);y.useEffect(()=>{se()},[se]),y.useEffect(()=>{O&&!i&&(E({support_plan:O.support_plan||"",frequency:O.frequency||"Quarterly",max_downtime_hrs:O.max_downtime_hrs||0,asset:O.asset||null,starting_date:O.starting_date||null,penalty_factor:O.penalty_factor||5,custom_contractwarranty:O.custom_contractwarranty||"Contract",custom_contract_value:O.custom_contract_value||"",warranty:O.warranty||0,warranty_start_date:O.warranty_start_date||null,warranty_end_date:O.warranty_end_date||null,war_status:O.war_status||"Active",extended_warranty:O.extended_warranty||0,start:O.start||null,end:O.end||null,service_contract:O.service_contract||0,spare_parts:O.spare_parts||0,spare_parts_labour:O.spare_parts_labour||0,labour:O.labour||0,ppm_only:O.ppm_only||0,no:O.no||0,start_date:O.start_date||null,end_date:O.end_date||null,service_contract_status:O.service_contract_status||"Active",vendor:O.vendor||null,asset_list:O.asset_list||[]}),c||ce(!1))},[O,i,c]);const ee=be=>{const{name:ke,value:Me,type:z}=be.target;E(z==="checkbox"?Ne=>Se(ue({},Ne),{[ke]:be.target.checked?1:0}):z==="number"?Ne=>Se(ue({},Ne),{[ke]:parseFloat(Me)||0}):Ne=>Se(ue({},Ne),{[ke]:Me}))},te=()=>Q(null,null,function*(){var be;if(!((be=T.support_plan)!=null&&be.trim())){nt.error("Support Plan Name is required",{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})});return}try{if(i){const ke=yield U(T);nt.success("Support Plan created successfully!",{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),s(`/sla/${ke.name}`)}else yield J(a,T),nt.success("Support Plan updated successfully!",{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),ce(!1),P(),setTimeout(()=>se(),500)}catch(ke){const Me=ke instanceof Error?ke.message:"Unknown error";nt.error(`Failed to save: ${Me}`,{position:"top-right",autoClose:6e3,icon:e.jsx(ka,{})})}}),W=()=>Q(null,null,function*(){try{yield ne(a),nt.success("Support Plan deleted successfully!",{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),s(-1)}catch(be){const ke=be instanceof Error?be.message:"Unknown error";nt.error(`Failed to delete: ${ke}`,{position:"top-right",autoClose:6e3,icon:e.jsx(ka,{})})}}),I=y.useCallback(be=>!he,[he]),oe=be=>be.replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,ke=>ke.toUpperCase()),ae=be=>be==null||be===""?"(empty)":String(be),F=be=>{if(!be)return"";const ke=new Date(be),Me=new Date,z=Me.getTime()-ke.getTime(),Ne=Math.floor(z/6e4),Xe=Math.floor(z/36e5),gt=Math.floor(z/864e5);return Ne<1?"Just now":Ne<60?`${Ne} min${Ne>1?"s":""} ago`:Xe<24?`${Xe} hour${Xe>1?"s":""} ago`:gt<7?`${gt} day${gt>1?"s":""} ago`:ke.toLocaleDateString("en-US",{month:"short",day:"numeric",year:ke.getFullYear()!==Me.getFullYear()?"numeric":void 0,hour:"2-digit",minute:"2-digit"})},M=be=>be?be.split("@")[0]:"Unknown";if(R)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading support plan..."})]})});if(Y&&!i)return e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:"Error Loading Support Plan"}),e.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:Y}),e.jsx("button",{onClick:()=>s(-1),className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded",children:"Back to Support Plans"})]})});const B=U_(T.war_status||""),X=U_(T.service_contract_status||"");return e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[e.jsx(Xd,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Lc}),e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>s(-1),className:"text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200",children:e.jsx(en,{size:20})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white flex items-center gap-3",children:[i?"New Support Plan":T.support_plan||(O==null?void 0:O.name)||"Support Plan Details",!i&&T.custom_contractwarranty&&e.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium ${T.custom_contractwarranty==="Contract"?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300"}`,children:T.custom_contractwarranty})]}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:i?"Create a new support plan":`ID: ${a}`})]})]}),e.jsxs("div",{className:"flex gap-3",children:[!i&&!he&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>ce(!0),className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[e.jsx(Fr,{}),"Edit"]}),d&&e.jsxs("button",{onClick:()=>g(!0),className:"bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[e.jsx(Na,{}),"Delete"]})]}),he&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{i?s(-1):(ce(!1),P())},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg",children:"Cancel"}),e.jsxs("button",{onClick:te,disabled:ye,className:"bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[e.jsx(Or,{}),ye?"Saving...":"Save"]})]})]})]}),h&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(fa,{className:"text-red-500 text-xl mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Delete Support Plan"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Are you sure you want to delete this support plan? This action cannot be undone."})]})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>g(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:"Cancel"}),e.jsx("button",{onClick:W,disabled:ye,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg disabled:opacity-50",children:ye?"Deleting...":"Delete"})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(au,{className:"text-indigo-500"}),"Basic Information"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Support Plan Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",name:"support_plan",value:T.support_plan||"",onChange:ee,disabled:I("support_plan"),placeholder:"Enter plan name",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Contract/Warranty Type"}),e.jsxs("select",{name:"custom_contractwarranty",value:T.custom_contractwarranty||"",onChange:ee,disabled:I("custom_contractwarranty"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500",children:[e.jsx("option",{value:"Contract",children:"Contract"}),e.jsx("option",{value:"Warranty",children:"Warranty"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Frequency"}),e.jsxs("select",{name:"frequency",value:T.frequency||"",onChange:ee,disabled:I("frequency"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500",children:[e.jsx("option",{value:"Monthly",children:"Monthly"}),e.jsx("option",{value:"Quarterly",children:"Quarterly"}),e.jsx("option",{value:"Half-Yearly",children:"Half-Yearly"}),e.jsx("option",{value:"Yearly",children:"Yearly"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Contract Value"}),e.jsx("input",{type:"text",name:"custom_contract_value",value:T.custom_contract_value||"",onChange:ee,disabled:I("custom_contract_value"),placeholder:"e.g., 10000",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),e.jsx("div",{children:e.jsx(Ut,{label:"Asset",doctype:"Asset",value:T.asset||"",onChange:be=>E(Se(ue({},T),{asset:be||null})),disabled:I("asset"),placeholder:"Select Asset"})}),e.jsx("div",{children:e.jsx(Ut,{label:"Vendor",doctype:"Supplier",value:T.vendor||"",onChange:be=>E(Se(ue({},T),{vendor:be||null})),disabled:I("vendor"),placeholder:"Select Vendor"})})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(uh,{className:"text-orange-500"}),"Performance Settings"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Max Downtime (hrs)"}),e.jsx("input",{type:"number",name:"max_downtime_hrs",value:T.max_downtime_hrs||0,onChange:ee,disabled:I("max_downtime_hrs"),min:"0",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Penalty Factor (%)"}),e.jsx("input",{type:"number",name:"penalty_factor",value:T.penalty_factor||0,onChange:ee,disabled:I("penalty_factor"),min:"0",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Starting Date"}),e.jsx("input",{type:"date",name:"starting_date",value:T.starting_date||"",onChange:ee,disabled:I("starting_date"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(Kx,{className:"text-purple-500"}),"Warranty Information"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",name:"warranty",checked:!!T.warranty,onChange:ee,disabled:I("warranty"),className:"h-4 w-4 text-indigo-600 rounded"}),e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Has Warranty"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",name:"extended_warranty",checked:!!T.extended_warranty,onChange:ee,disabled:I("extended_warranty"),className:"h-4 w-4 text-indigo-600 rounded"}),e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Extended Warranty"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Warranty Status"}),e.jsxs("select",{name:"war_status",value:T.war_status||"",onChange:ee,disabled:I("war_status"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500",children:[e.jsx("option",{value:"Active",children:"Active"}),e.jsx("option",{value:"Inactive",children:"Inactive"}),e.jsx("option",{value:"Expired",children:"Expired"})]})]}),e.jsx("div",{}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Warranty Start Date"}),e.jsx("input",{type:"date",name:"warranty_start_date",value:T.warranty_start_date||"",onChange:ee,disabled:I("warranty_start_date"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Warranty End Date"}),e.jsx("input",{type:"date",name:"warranty_end_date",value:T.warranty_end_date||"",onChange:ee,disabled:I("warranty_end_date"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(wc,{className:"text-blue-500"}),"Service Contract"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",name:"service_contract",checked:!!T.service_contract,onChange:ee,disabled:I("service_contract"),className:"h-4 w-4 text-indigo-600 rounded"}),e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Has Service Contract"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Service Contract Status"}),e.jsxs("select",{name:"service_contract_status",value:T.service_contract_status||"",onChange:ee,disabled:I("service_contract_status"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500",children:[e.jsx("option",{value:"Active",children:"Active"}),e.jsx("option",{value:"Inactive",children:"Inactive"}),e.jsx("option",{value:"Expired",children:"Expired"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Start Date"}),e.jsx("input",{type:"date",name:"start_date",value:T.start_date||"",onChange:ee,disabled:I("start_date"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"End Date"}),e.jsx("input",{type:"date",name:"end_date",value:T.end_date||"",onChange:ee,disabled:I("end_date"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white disabled:bg-gray-100 dark:disabled:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:"Inclusions"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",name:"spare_parts",checked:!!T.spare_parts,onChange:ee,disabled:I("spare_parts"),className:"h-4 w-4 text-indigo-600 rounded"}),e.jsx("label",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Spare Parts"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",name:"spare_parts_labour",checked:!!T.spare_parts_labour,onChange:ee,disabled:I("spare_parts_labour"),className:"h-4 w-4 text-indigo-600 rounded"}),e.jsx("label",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Spare Parts + Labour"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",name:"labour",checked:!!T.labour,onChange:ee,disabled:I("labour"),className:"h-4 w-4 text-indigo-600 rounded"}),e.jsx("label",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Labour Only"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",name:"ppm_only",checked:!!T.ppm_only,onChange:ee,disabled:I("ppm_only"),className:"h-4 w-4 text-indigo-600 rounded"}),e.jsx("label",{className:"text-sm text-gray-600 dark:text-gray-400",children:"PPM Only"})]})]})]})]}),!i&&e.jsx(Pc,{referenceDoctype:"Support Plans",referenceName:a||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5,collapsible:!0,startCollapsed:!1})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-4 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-sm font-semibold text-gray-800 dark:text-white mb-3 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(au,{className:"text-indigo-500",size:14}),"Status Overview"]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`p-3 rounded-lg border ${T.custom_contractwarranty==="Contract"?"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800":"bg-purple-50 dark:bg-purple-900/20 border-purple-200 dark:border-purple-800"}`,children:[e.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:"Type"}),e.jsx("p",{className:`text-sm font-semibold ${T.custom_contractwarranty==="Contract"?"text-blue-700 dark:text-blue-300":"text-purple-700 dark:text-purple-300"}`,children:T.custom_contractwarranty||"Not Set"})]}),T.custom_contractwarranty==="Warranty"&&e.jsxs("div",{className:`p-3 rounded-lg border ${B.bg} ${B.border}`,children:[e.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:"Warranty Status"}),e.jsx("p",{className:`text-sm font-semibold ${B.text}`,children:T.war_status||"Not Set"})]}),T.custom_contractwarranty==="Contract"&&e.jsxs("div",{className:`p-3 rounded-lg border ${X.bg} ${X.border}`,children:[e.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:"Contract Status"}),e.jsx("p",{className:`text-sm font-semibold ${X.text}`,children:T.service_contract_status||"Not Set"})]}),T.frequency&&e.jsxs("div",{className:"p-3 bg-indigo-50 dark:bg-indigo-900/20 rounded-lg border border-indigo-200 dark:border-indigo-800",children:[e.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:"Frequency"}),e.jsx("p",{className:"text-sm font-semibold text-indigo-700 dark:text-indigo-300",children:T.frequency})]}),T.custom_contract_value&&e.jsxs("div",{className:"p-3 bg-green-50 dark:bg-green-900/20 rounded-lg border border-green-200 dark:border-green-800",children:[e.jsx("p",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:"Contract Value"}),e.jsx("p",{className:"text-sm font-semibold text-green-700 dark:text-green-300",children:new Intl.NumberFormat("en-US",{style:"currency",currency:"SAR"}).format(parseFloat(T.custom_contract_value)||0)})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-4 border border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-sm font-semibold text-gray-800 dark:text-white mb-3 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(go,{className:"text-orange-500",size:14}),"Quick Info"]}),e.jsxs("div",{className:"space-y-2 text-sm",children:[T.asset&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Asset:"}),e.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:T.asset})]}),T.vendor&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Vendor:"}),e.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:T.vendor})]}),((K=T.max_downtime_hrs)!=null?K:0)>0&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Max Downtime:"}),e.jsxs("span",{className:"text-gray-900 dark:text-white font-medium",children:[T.max_downtime_hrs," hrs"]})]}),((we=T.penalty_factor)!=null?we:0)>0&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Penalty Factor:"}),e.jsxs("span",{className:"text-gray-900 dark:text-white font-medium",children:[T.penalty_factor,"%"]})]})]})]}),!i&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-2 cursor-pointer flex-1",onClick:()=>k(!N),children:[e.jsx(_c,{className:"text-blue-500",size:14}),e.jsx("h2",{className:"text-sm font-semibold text-gray-800 dark:text-white",children:"Activity Log"}),p.length>0&&e.jsx("span",{className:"px-1.5 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 rounded-full text-[10px] font-medium",children:p.length})]}),e.jsx("button",{onClick:()=>k(!N),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-1",children:N?e.jsx(As,{size:12}):e.jsx(cs,{size:12})})]}),N&&e.jsx("div",{className:"p-3",children:j?e.jsxs("div",{className:"flex items-center justify-center py-4",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-500 mr-2"}),e.jsx("span",{className:"text-xs text-gray-500",children:"Loading..."})]}):p.length===0?e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 text-center py-4",children:"No changes recorded yet"}):e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-2 top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700"}),e.jsx("div",{className:"space-y-3",children:(C?p:p.slice(0,5)).map((be,ke)=>e.jsxs("div",{className:"relative pl-6",children:[e.jsx("div",{className:`absolute left-1 top-1 w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 ${ke===0?"bg-blue-500":"bg-gray-300 dark:bg-gray-600"}`}),e.jsxs("div",{className:`p-2 rounded-lg ${ke===0?"bg-blue-50 dark:bg-blue-900/20":"bg-gray-50 dark:bg-gray-700/50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-700 dark:text-gray-300",children:M(be.owner)}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-500",children:[e.jsx(or,{size:8}),F(be.creation)]})]}),be.changes.length>0?be.changes.map((Me,z)=>e.jsxs("div",{className:"text-[10px]",children:[e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:oe(Me.field)}),e.jsx("span",{className:"text-gray-500",children:" changed from "}),e.jsx("span",{className:"px-1 py-0.5 bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400 rounded text-[9px]",children:ae(Me.oldValue)}),e.jsx("span",{className:"text-gray-500",children:" → "}),e.jsx("span",{className:"px-1 py-0.5 bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400 rounded text-[9px]",children:ae(Me.newValue)})]},z)):e.jsx("p",{className:"text-[10px] text-gray-500 italic",children:"Document updated"})]})]},be.name))}),p.length>5&&e.jsx("div",{className:"mt-3 text-center",children:e.jsx("button",{onClick:()=>D(!C),className:"inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-md",children:C?e.jsxs(e.Fragment,{children:[e.jsx(As,{size:8}),"Show Less"]}):e.jsxs(e.Fragment,{children:[e.jsx(cs,{size:8}),"Show All (",p.length,")"]})})}),(O==null?void 0:O.creation)&&(O==null?void 0:O.owner)&&e.jsxs("div",{className:"relative pl-6 mt-3",children:[e.jsx("div",{className:"absolute left-1 top-1 w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 bg-green-500"}),e.jsxs("div",{className:"p-2 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-100 dark:border-green-800/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-700 dark:text-gray-300",children:M(O.owner)}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-500",children:[e.jsx(or,{size:8}),F(O.creation)]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 bg-green-100 dark:bg-green-800/50 text-green-700 dark:text-green-300 rounded text-[10px] font-medium",children:[e.jsx(ea,{size:8}),"Created this Support Plan"]})]})]})]})})]})]})]})]})},XP=()=>Q(null,null,function*(){var t;try{const s=(yield(yield fetch("/api/method/frappe.auth.get_logged_user",{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).message;if(!s)throw new Error("No user logged in");const c=yield(yield fetch("/api/method/frappe.client.get",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({doctype:"User",name:s})})).json();if(console.log("frappe.client.get response:",c),console.log("role_profile_name:",(t=c.message)==null?void 0:t.role_profile_name),c.message){const d=c.message;return d.roles||(d.roles=[]),d}throw new Error("Failed to fetch user profile")}catch(a){throw console.error("Error fetching user profile:",a),a}}),KP=(t,a)=>Q(null,null,function*(){try{const r=yield fetch(`/api/resource/User/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(a)}),s=yield r.json();if(!r.ok)throw new Error(s.exc||s.message||"Failed to update profile");return s.data}catch(r){throw console.error("Error updating user profile:",r),r}}),QP=(t,a)=>Q(null,null,function*(){try{const r=yield fetch("/api/method/frappe.core.doctype.user.user.update_password",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({new_password:t,old_password:a})}),s=yield r.json();if(!r.ok){let i="Failed to change password";if(s.exc){if(s.exc.includes("Incorrect Old Password"))i="Incorrect old password";else if(s.exc.includes("Password cannot be same"))i="New password cannot be the same as old password";else if(s._server_messages)try{const c=JSON.parse(s._server_messages);i=JSON.parse(c[0]).message||i}catch(c){}}throw new Error(i)}return{message:"Password changed successfully"}}catch(r){throw console.error("Error changing password:",r),r}}),eF=()=>{const t=qa(),[a,r]=y.useState(!0),[s,i]=y.useState(!1),[c,d]=y.useState(!1),[m,h]=y.useState(!1),[g,p]=y.useState(null),[b,j]=y.useState(null),[_,N]=y.useState({first_name:"",middle_name:"",last_name:"",role_profile_name:"",custom_user_id:""}),[k,C]=y.useState(!1),[D,T]=y.useState({old_password:"",new_password:"",confirm_password:""}),[E,O]=y.useState(!1),[R,Y]=y.useState(!1),[P,U]=y.useState(!1);y.useEffect(()=>{Q(null,null,function*(){var se;try{r(!0);const W=((se=(yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({roles:"System Manager"})})).json()).message)==null?void 0:se.has_role)||!1;d(W),console.log("Is System Manager:",W);const I=yield XP();console.log("Full profile data:",JSON.stringify(I,null,2)),console.log("role_profile_name:",I.role_profile_name),console.log("All keys:",Object.keys(I)),p(I),N({first_name:I.first_name||"",middle_name:I.middle_name||"",last_name:I.last_name||"",role_profile_name:I.role_profile_name||"",custom_user_id:I.custom_user_id||""}),console.log("FormData role_profile_name:",I.role_profile_name||"")}catch(ee){const te=ee instanceof Error?ee.message:"Failed to load profile";j(te),nt.error(te,{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})})}finally{r(!1)}})},[]);const J=ce=>{const{name:se,value:ee}=ce.target;N(te=>Se(ue({},te),{[se]:ee}))},ne=ce=>{const{name:se,value:ee}=ce.target;T(te=>Se(ue({},te),{[se]:ee}))},ye=()=>Q(null,null,function*(){if(g!=null&&g.email)try{i(!0);const ce={first_name:_.first_name,middle_name:_.middle_name,last_name:_.last_name,role_profile_name:_.role_profile_name},se=yield KP(g.email,ce);p(ee=>ee?ue(ue({},ee),se):se),nt.success("Profile updated successfully!",{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})})}catch(ce){const se=ce instanceof Error?ce.message:"Failed to update profile";nt.error(se,{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})})}finally{i(!1)}}),he=()=>Q(null,null,function*(){if(!D.old_password){nt.error("Please enter your current password",{position:"top-right",autoClose:3e3,icon:e.jsx(fa,{})});return}if(!D.new_password){nt.error("Please enter a new password",{position:"top-right",autoClose:3e3,icon:e.jsx(fa,{})});return}if(D.new_password.length<8){nt.error("Password must be at least 8 characters long",{position:"top-right",autoClose:3e3,icon:e.jsx(fa,{})});return}if(D.new_password!==D.confirm_password){nt.error("New passwords do not match",{position:"top-right",autoClose:3e3,icon:e.jsx(fa,{})});return}try{h(!0),yield QP(D.new_password,D.old_password),nt.success("Password changed successfully!",{position:"top-right",autoClose:3e3,icon:e.jsx(ea,{})}),T({old_password:"",new_password:"",confirm_password:""}),C(!1)}catch(ce){const se=ce instanceof Error?ce.message:"Failed to change password";nt.error(se,{position:"top-right",autoClose:5e3,icon:e.jsx(ka,{})})}finally{h(!1)}});return a?e.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ya,{className:"animate-spin text-blue-500 text-4xl mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading profile..."})]})}):b&&!g?e.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[e.jsxs("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:[e.jsx(ka,{className:"inline mr-2"}),"Error Loading Profile"]}),e.jsx("p",{className:"text-red-700 dark:text-red-400",children:b}),e.jsx("button",{onClick:()=>t(-1),className:"mt-4 bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded",children:"Go Back"})]})}):e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[e.jsx(Xd,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Lc}),e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("button",{onClick:()=>t(-1),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[e.jsx(en,{}),e.jsx("span",{className:"text-gray-900 dark:text-white text-xl font-semibold",children:"User Profile"})]})}),e.jsx("button",{onClick:ye,disabled:s,className:"bg-green-600 hover:bg-green-700 text-white px-6 py-2 rounded-lg flex items-center gap-2 disabled:opacity-50 shadow-lg transition-all",children:s?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Or,{}),"Save Changes"]})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx("div",{className:"lg:col-span-1",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 p-6 text-center",children:[e.jsx("div",{className:"w-24 h-24 bg-white/20 rounded-full mx-auto flex items-center justify-center mb-4",children:g!=null&&g.user_image?e.jsx("img",{src:g.user_image,alt:"Profile",className:"w-20 h-20 rounded-full object-cover"}):e.jsx(js,{className:"text-white text-4xl"})}),e.jsx("h2",{className:"text-xl font-bold text-white",children:(g==null?void 0:g.full_name)||"User"}),e.jsx("p",{className:"text-white/80 text-sm mt-1",children:g==null?void 0:g.email})]}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx(V5,{className:"text-blue-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Username"}),e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:(g==null?void 0:g.username)||"-"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx(e6,{className:"text-green-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Role Profile"}),e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:(g==null?void 0:g.role_profile_name)||"-"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsx(Kx,{className:"text-purple-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Status"}),e.jsx("p",{className:`text-sm font-medium ${g!=null&&g.enabled?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:g!=null&&g.enabled?"Active":"Inactive"})]})]})]})]})}),e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2",children:[e.jsx(js,{className:"text-blue-500"}),"Basic Information"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Email",e.jsx("span",{className:"ml-1 text-gray-400",children:"(Read-only)"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(T2,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400",size:14}),e.jsx("input",{type:"email",value:(g==null?void 0:g.email)||"",disabled:!0,className:"w-full pl-10 pr-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400 cursor-not-allowed"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Full Name",e.jsx("span",{className:"ml-1 text-gray-400",children:"(Auto-generated)"})]}),e.jsx("input",{type:"text",value:(g==null?void 0:g.full_name)||"",disabled:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400 cursor-not-allowed"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["First Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",name:"first_name",value:_.first_name,onChange:J,placeholder:"Enter first name",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Middle Name"}),e.jsx("input",{type:"text",name:"middle_name",value:_.middle_name,onChange:J,placeholder:"Enter middle name",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Last Name"}),e.jsx("input",{type:"text",name:"last_name",value:_.last_name,onChange:J,placeholder:"Enter last name",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"User ID No"}),e.jsx("input",{type:"text",name:"custom_user_id",value:_.custom_user_id,onChange:J,placeholder:"Enter User No",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"})]}),e.jsx("div",{children:e.jsx(Ut,{label:"Role Profile",doctype:"Role Profile",value:_.role_profile_name,onChange:ce=>N(se=>Se(ue({},se),{role_profile_name:ce})),placeholder:"Select Role Profile",disabled:!c})})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white flex items-center gap-2",children:[e.jsx(ex,{className:"text-orange-500"}),"Change Password"]}),e.jsx("button",{onClick:()=>C(!k),className:"text-sm text-blue-600 dark:text-blue-400 hover:underline",children:k?"Cancel":"Change Password"})]}),k?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Current Password ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:E?"text":"password",name:"old_password",value:D.old_password,onChange:ne,placeholder:"Enter current password",className:"w-full px-3 py-2 pr-10 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),e.jsx("button",{type:"button",onClick:()=>O(!E),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:E?e.jsx(Qf,{size:14}):e.jsx(ri,{size:14})})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["New Password ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:R?"text":"password",name:"new_password",value:D.new_password,onChange:ne,placeholder:"Enter new password (min 8 characters)",className:"w-full px-3 py-2 pr-10 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),e.jsx("button",{type:"button",onClick:()=>Y(!R),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:R?e.jsx(Qf,{size:14}):e.jsx(ri,{size:14})})]}),D.new_password&&D.new_password.length<8&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:"Password must be at least 8 characters"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Confirm New Password ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:P?"text":"password",name:"confirm_password",value:D.confirm_password,onChange:ne,placeholder:"Confirm new password",className:"w-full px-3 py-2 pr-10 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700 text-gray-900 dark:text-white"}),e.jsx("button",{type:"button",onClick:()=>U(!P),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:P?e.jsx(Qf,{size:14}):e.jsx(ri,{size:14})})]}),D.confirm_password&&D.new_password!==D.confirm_password&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:"Passwords do not match"}),D.confirm_password&&D.new_password===D.confirm_password&&D.new_password.length>=8&&e.jsxs("p",{className:"mt-1 text-xs text-green-500 flex items-center gap-1",children:[e.jsx(ea,{size:10})," Passwords match"]})]}),e.jsx("div",{className:"pt-2",children:e.jsx("button",{onClick:he,disabled:m,className:"w-full bg-orange-600 hover:bg-orange-700 text-white px-4 py-2.5 rounded-lg flex items-center justify-center gap-2 disabled:opacity-50 transition-colors",children:m?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"animate-spin"}),"Changing Password..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ex,{}),"Change Password"]})})})]}):e.jsxs("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:[e.jsx(ex,{className:"mx-auto text-3xl mb-2 text-gray-300 dark:text-gray-600"}),e.jsx("p",{className:"text-sm",children:'Click "Change Password" to update your password'})]})]})]})]})]})},sr=({children:t})=>{const a=localStorage.getItem("user"),r=a?JSON.parse(a).email:"";return e.jsxs("div",{className:"flex h-screen overflow-hidden bg-gray-50 dark:bg-gray-900",children:[e.jsx(sP,{userEmail:r}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(dP,{userEmail:r}),e.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 dark:bg-gray-900",children:t})]})]})},nr=({children:t})=>localStorage.getItem("user")?e.jsx(e.Fragment,{children:t}):e.jsx(kx,{to:"/login",replace:!0}),tF=()=>e.jsx(r5,{basename:"/asm_app",children:e.jsxs(MS,{children:[e.jsx(Ga,{path:"/login",element:e.jsx(x5,{})}),e.jsx(Ga,{path:"/dashboard",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(q9,{})})})}),e.jsx(Ga,{path:"/assets",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx($M,{})})})}),e.jsx(Ga,{path:"/assets/:assetName",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(iL,{})})})}),e.jsx(Ga,{path:"/work-orders",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(hL,{})})})}),e.jsx(Ga,{path:"/work-orders/:workOrderName",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(xL,{})})})}),e.jsx(Ga,{path:"/maintenance",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(pL,{})})})}),e.jsx(Ga,{path:"/maintenance/:logName",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(vL,{})})})}),e.jsx(Ga,{path:"/ppm",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(jL,{})})})}),e.jsx(Ga,{path:"/ppm/:ppmName",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(NL,{})})})}),e.jsx(Ga,{path:"/ppm-planner",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(OL,{})})})}),e.jsx(Ga,{path:"/ppm-planner/new",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(CL,{})})})}),e.jsx(Ga,{path:"/ppm-planner/:scheduleName",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(DL,{})})})}),e.jsx(Ga,{path:"/maintenance-calendar",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(P_,{})})})}),e.jsx(Ga,{path:"/maintenance-calendar/month-view",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(LL,{})})})}),e.jsx(Ga,{path:"/yearly-ppm-planner",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(P_,{})})})}),e.jsx(Ga,{path:"/active-map",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(rR,{})})})}),e.jsx(Ga,{path:"/inventory",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(lR,{})})})}),e.jsx(Ga,{path:"/inventory/:itemName",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(cR,{})})})}),e.jsx(Ga,{path:"/users",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(HD,{})})})}),e.jsx(Ga,{path:"/events",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(WD,{})})})}),e.jsx(Ga,{path:"/old-dashboard",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(w5,{})})})}),e.jsx(Ga,{path:"/maintenance-teams",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(TP,{})})})}),e.jsx(Ga,{path:"/maintenance-teams/:teamName",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(EP,{})})})}),e.jsx(Ga,{path:"/inspections",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(zP,{})})})}),e.jsx(Ga,{path:"/inspections/:inspectionName",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(UP,{})})})}),e.jsx(Ga,{path:"/procurement",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(eP,{title:"Procurement"})})})}),e.jsx(Ga,{path:"/sla",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(ZP,{})})})}),e.jsx(Ga,{path:"/sla/:slaName",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(JP,{})})})}),e.jsx(Ga,{path:"/support",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(yP,{})})})}),e.jsx(Ga,{path:"/support/:issueName",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(wP,{})})})}),e.jsx(Ga,{path:"/user-profile",element:e.jsx(nr,{children:e.jsx(sr,{children:e.jsx(eF,{})})})}),e.jsx(Ga,{path:"/",element:e.jsx(kx,{to:"/login",replace:!0})}),e.jsx(Ga,{path:"*",element:e.jsx(kx,{to:"/login",replace:!0})})]})});HN.createRoot(document.getElementById("root")).render(e.jsx(y.StrictMode,{children:e.jsx(f5,{children:e.jsx(nP,{children:e.jsx(tF,{})})})}))});export default aF();