1864 lines
2.1 MiB
1864 lines
2.1 MiB
var n6=Object.defineProperty,s6=Object.defineProperties;var i6=Object.getOwnPropertyDescriptors;var zh=Object.getOwnPropertySymbols;var l2=Object.prototype.hasOwnProperty,c2=Object.prototype.propertyIsEnumerable;var xd=(e,r)=>(r=Symbol[e])?r:Symbol.for("Symbol."+e),o6=e=>{throw TypeError(e)};var nx=(e,r,a)=>r in e?n6(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a,_e=(e,r)=>{for(var a in r||(r={}))l2.call(r,a)&&nx(e,a,r[a]);if(zh)for(var a of zh(r))c2.call(r,a)&&nx(e,a,r[a]);return e},$e=(e,r)=>s6(e,i6(r));var Gs=(e,r)=>{var a={};for(var n in e)l2.call(e,n)&&r.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&zh)for(var n of zh(e))r.indexOf(n)<0&&c2.call(e,n)&&(a[n]=e[n]);return a};var l6=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var Ti=(e,r,a)=>nx(e,typeof r!="symbol"?r+"":r,a);var xe=(e,r,a)=>new Promise((n,i)=>{var c=y=>{try{g(a.next(y))}catch(x){i(x)}},u=y=>{try{g(a.throw(y))}catch(x){i(x)}},g=y=>y.done?n(y.value):Promise.resolve(y.value).then(c,u);g((a=a.apply(e,r)).next())}),yc=function(e,r){this[0]=e,this[1]=r},sx=(e,r,a)=>{var n=(u,g,y,x)=>{try{var k=a[u](g),N=(g=k.value)instanceof yc,C=k.done;Promise.resolve(N?g[0]:g).then(O=>N?n(u==="return"?u:"next",g[1]?{done:O.done,value:O.value}:O,y,x):y({value:O,done:C})).catch(O=>n("throw",O,y,x))}catch(O){x(O)}},i=u=>c[u]=g=>new Promise((y,x)=>n(u,g,y,x)),c={};return a=a.apply(e,r),c[xd("asyncIterator")]=()=>c,i("next"),i("throw"),i("return"),c},ix=e=>{var r=e[xd("asyncIterator")],a=!1,n,i={};return r==null?(r=e[xd("iterator")](),n=c=>i[c]=u=>r[c](u)):(r=r.call(e),n=c=>i[c]=u=>{if(a){if(a=!1,c==="throw")throw u;return u}return a=!0,{done:!1,value:new yc(new Promise(g=>{var y=r[c](u);y instanceof Object||o6("Object expected"),g(y)}),1)}}),i[xd("iterator")]=()=>i,n("next"),"throw"in r?n("throw"):i.throw=c=>{throw c},"return"in r&&n("return"),i},d2=(e,r,a)=>(r=e[xd("asyncIterator")])?r.call(e):(e=e[xd("iterator")](),r={},a=(n,i)=>(i=e[n])&&(r[n]=c=>new Promise((u,g,y)=>(c=i.call(e,c),y=c.done,Promise.resolve(c.value).then(x=>u({value:x,done:y}),g)))),a("next"),a("return"),r);var cB=l6(ht=>{function c6(e,r){for(var a=0;a<r.length;a++){const n=r[a];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const c=Object.getOwnPropertyDescriptor(n,i);c&&Object.defineProperty(e,i,c.get?c:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const c of i)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&n(u)}).observe(document,{childList:!0,subtree:!0});function a(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 n(i){if(i.ep)return;i.ep=!0;const c=a(i);fetch(i.href,c)}})();var Hh=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function gp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ox={exports:{}},H0={};var u2;function d6(){if(u2)return H0;u2=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function a(n,i,c){var u=null;if(c!==void 0&&(u=""+c),i.key!==void 0&&(u=""+i.key),"key"in i){c={};for(var g in i)g!=="key"&&(c[g]=i[g])}else c=i;return i=c.ref,{$$typeof:e,type:n,key:u,ref:i!==void 0?i:null,props:c}}return H0.Fragment=r,H0.jsx=a,H0.jsxs=a,H0}var h2;function u6(){return h2||(h2=1,ox.exports=d6()),ox.exports}var t=u6(),lx={exports:{}},Vr={};var f2;function h6(){if(f2)return Vr;f2=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),u=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),x=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),C=Symbol.iterator;function O(J){return J===null||typeof J!="object"?null:(J=C&&J[C]||J["@@iterator"],typeof J=="function"?J:null)}var D={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},A=Object.assign,I={};function z(J,G,ie){this.props=J,this.context=G,this.refs=I,this.updater=ie||D}z.prototype.isReactComponent={},z.prototype.setState=function(J,G){if(typeof J!="object"&&typeof J!="function"&&J!=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,J,G,"setState")},z.prototype.forceUpdate=function(J){this.updater.enqueueForceUpdate(this,J,"forceUpdate")};function U(){}U.prototype=z.prototype;function B(J,G,ie){this.props=J,this.context=G,this.refs=I,this.updater=ie||D}var V=B.prototype=new U;V.constructor=B,A(V,z.prototype),V.isPureReactComponent=!0;var Z=Array.isArray;function W(){}var H={H:null,A:null,T:null,S:null},le=Object.prototype.hasOwnProperty;function Q(J,G,ie){var re=ie.ref;return{$$typeof:e,type:J,key:G,ref:re!==void 0?re:null,props:ie}}function Ne(J,G){return Q(J.type,G,J.props)}function oe(J){return typeof J=="object"&&J!==null&&J.$$typeof===e}function se(J){var G={"=":"=0",":":"=2"};return"$"+J.replace(/[=:]/g,function(ie){return G[ie]})}var ce=/\/+/g;function Ce(J,G){return typeof J=="object"&&J!==null&&J.key!=null?se(""+J.key):G.toString(36)}function ae(J){switch(J.status){case"fulfilled":return J.value;case"rejected":throw J.reason;default:switch(typeof J.status=="string"?J.then(W,W):(J.status="pending",J.then(function(G){J.status==="pending"&&(J.status="fulfilled",J.value=G)},function(G){J.status==="pending"&&(J.status="rejected",J.reason=G)})),J.status){case"fulfilled":return J.value;case"rejected":throw J.reason}}throw J}function me(J,G,ie,re,ne){var ve=typeof J;(ve==="undefined"||ve==="boolean")&&(J=null);var Ve=!1;if(J===null)Ve=!0;else switch(ve){case"bigint":case"string":case"number":Ve=!0;break;case"object":switch(J.$$typeof){case e:case r:Ve=!0;break;case k:return Ve=J._init,me(Ve(J._payload),G,ie,re,ne)}}if(Ve)return ne=ne(J),Ve=re===""?"."+Ce(J,0):re,Z(ne)?(ie="",Ve!=null&&(ie=Ve.replace(ce,"$&/")+"/"),me(ne,G,ie,"",function(Re){return Re})):ne!=null&&(oe(ne)&&(ne=Ne(ne,ie+(ne.key==null||J&&J.key===ne.key?"":(""+ne.key).replace(ce,"$&/")+"/")+Ve)),G.push(ne)),1;Ve=0;var Ae=re===""?".":re+":";if(Z(J))for(var ze=0;ze<J.length;ze++)re=J[ze],ve=Ae+Ce(re,ze),Ve+=me(re,G,ie,ve,ne);else if(ze=O(J),typeof ze=="function")for(J=ze.call(J),ze=0;!(re=J.next()).done;)re=re.value,ve=Ae+Ce(re,ze++),Ve+=me(re,G,ie,ve,ne);else if(ve==="object"){if(typeof J.then=="function")return me(ae(J),G,ie,re,ne);throw G=String(J),Error("Objects are not valid as a React child (found: "+(G==="[object Object]"?"object with keys {"+Object.keys(J).join(", ")+"}":G)+"). If you meant to render a collection of children, use an array instead.")}return Ve}function K(J,G,ie){if(J==null)return J;var re=[],ne=0;return me(J,re,"","",function(ve){return G.call(ie,ve,ne++)}),re}function fe(J){if(J._status===-1){var G=J._result;G=G(),G.then(function(ie){(J._status===0||J._status===-1)&&(J._status=1,J._result=ie)},function(ie){(J._status===0||J._status===-1)&&(J._status=2,J._result=ie)}),J._status===-1&&(J._status=0,J._result=G)}if(J._status===1)return J._result.default;throw J._result}var Oe=typeof reportError=="function"?reportError:function(J){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var G=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof J=="object"&&J!==null&&typeof J.message=="string"?String(J.message):String(J),error:J});if(!window.dispatchEvent(G))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",J);return}console.error(J)},ye={map:K,forEach:function(J,G,ie){K(J,function(){G.apply(this,arguments)},ie)},count:function(J){var G=0;return K(J,function(){G++}),G},toArray:function(J){return K(J,function(G){return G})||[]},only:function(J){if(!oe(J))throw Error("React.Children.only expected to receive a single React element child.");return J}};return Vr.Activity=N,Vr.Children=ye,Vr.Component=z,Vr.Fragment=a,Vr.Profiler=i,Vr.PureComponent=B,Vr.StrictMode=n,Vr.Suspense=y,Vr.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=H,Vr.__COMPILER_RUNTIME={__proto__:null,c:function(J){return H.H.useMemoCache(J)}},Vr.cache=function(J){return function(){return J.apply(null,arguments)}},Vr.cacheSignal=function(){return null},Vr.cloneElement=function(J,G,ie){if(J==null)throw Error("The argument must be a React element, but you passed "+J+".");var re=A({},J.props),ne=J.key;if(G!=null)for(ve in G.key!==void 0&&(ne=""+G.key),G)!le.call(G,ve)||ve==="key"||ve==="__self"||ve==="__source"||ve==="ref"&&G.ref===void 0||(re[ve]=G[ve]);var ve=arguments.length-2;if(ve===1)re.children=ie;else if(1<ve){for(var Ve=Array(ve),Ae=0;Ae<ve;Ae++)Ve[Ae]=arguments[Ae+2];re.children=Ve}return Q(J.type,ne,re)},Vr.createContext=function(J){return J={$$typeof:u,_currentValue:J,_currentValue2:J,_threadCount:0,Provider:null,Consumer:null},J.Provider=J,J.Consumer={$$typeof:c,_context:J},J},Vr.createElement=function(J,G,ie){var re,ne={},ve=null;if(G!=null)for(re in G.key!==void 0&&(ve=""+G.key),G)le.call(G,re)&&re!=="key"&&re!=="__self"&&re!=="__source"&&(ne[re]=G[re]);var Ve=arguments.length-2;if(Ve===1)ne.children=ie;else if(1<Ve){for(var Ae=Array(Ve),ze=0;ze<Ve;ze++)Ae[ze]=arguments[ze+2];ne.children=Ae}if(J&&J.defaultProps)for(re in Ve=J.defaultProps,Ve)ne[re]===void 0&&(ne[re]=Ve[re]);return Q(J,ve,ne)},Vr.createRef=function(){return{current:null}},Vr.forwardRef=function(J){return{$$typeof:g,render:J}},Vr.isValidElement=oe,Vr.lazy=function(J){return{$$typeof:k,_payload:{_status:-1,_result:J},_init:fe}},Vr.memo=function(J,G){return{$$typeof:x,type:J,compare:G===void 0?null:G}},Vr.startTransition=function(J){var G=H.T,ie={};H.T=ie;try{var re=J(),ne=H.S;ne!==null&&ne(ie,re),typeof re=="object"&&re!==null&&typeof re.then=="function"&&re.then(W,Oe)}catch(ve){Oe(ve)}finally{G!==null&&ie.types!==null&&(G.types=ie.types),H.T=G}},Vr.unstable_useCacheRefresh=function(){return H.H.useCacheRefresh()},Vr.use=function(J){return H.H.use(J)},Vr.useActionState=function(J,G,ie){return H.H.useActionState(J,G,ie)},Vr.useCallback=function(J,G){return H.H.useCallback(J,G)},Vr.useContext=function(J){return H.H.useContext(J)},Vr.useDebugValue=function(){},Vr.useDeferredValue=function(J,G){return H.H.useDeferredValue(J,G)},Vr.useEffect=function(J,G){return H.H.useEffect(J,G)},Vr.useEffectEvent=function(J){return H.H.useEffectEvent(J)},Vr.useId=function(){return H.H.useId()},Vr.useImperativeHandle=function(J,G,ie){return H.H.useImperativeHandle(J,G,ie)},Vr.useInsertionEffect=function(J,G){return H.H.useInsertionEffect(J,G)},Vr.useLayoutEffect=function(J,G){return H.H.useLayoutEffect(J,G)},Vr.useMemo=function(J,G){return H.H.useMemo(J,G)},Vr.useOptimistic=function(J,G){return H.H.useOptimistic(J,G)},Vr.useReducer=function(J,G,ie){return H.H.useReducer(J,G,ie)},Vr.useRef=function(J){return H.H.useRef(J)},Vr.useState=function(J){return H.H.useState(J)},Vr.useSyncExternalStore=function(J,G,ie){return H.H.useSyncExternalStore(J,G,ie)},Vr.useTransition=function(){return H.H.useTransition()},Vr.version="19.2.1",Vr}var m2;function Xf(){return m2||(m2=1,lx.exports=h6()),lx.exports}var E=Xf();const ea=gp(E);var cx={exports:{}},V0={},dx={exports:{}},ux={};var g2;function f6(){return g2||(g2=1,(function(e){function r(me,K){var fe=me.length;me.push(K);e:for(;0<fe;){var Oe=fe-1>>>1,ye=me[Oe];if(0<i(ye,K))me[Oe]=K,me[fe]=ye,fe=Oe;else break e}}function a(me){return me.length===0?null:me[0]}function n(me){if(me.length===0)return null;var K=me[0],fe=me.pop();if(fe!==K){me[0]=fe;e:for(var Oe=0,ye=me.length,J=ye>>>1;Oe<J;){var G=2*(Oe+1)-1,ie=me[G],re=G+1,ne=me[re];if(0>i(ie,fe))re<ye&&0>i(ne,ie)?(me[Oe]=ne,me[re]=fe,Oe=re):(me[Oe]=ie,me[G]=fe,Oe=G);else if(re<ye&&0>i(ne,fe))me[Oe]=ne,me[re]=fe,Oe=re;else break e}}return K}function i(me,K){var fe=me.sortIndex-K.sortIndex;return fe!==0?fe:me.id-K.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var u=Date,g=u.now();e.unstable_now=function(){return u.now()-g}}var y=[],x=[],k=1,N=null,C=3,O=!1,D=!1,A=!1,I=!1,z=typeof setTimeout=="function"?setTimeout:null,U=typeof clearTimeout=="function"?clearTimeout:null,B=typeof setImmediate!="undefined"?setImmediate:null;function V(me){for(var K=a(x);K!==null;){if(K.callback===null)n(x);else if(K.startTime<=me)n(x),K.sortIndex=K.expirationTime,r(y,K);else break;K=a(x)}}function Z(me){if(A=!1,V(me),!D)if(a(y)!==null)D=!0,W||(W=!0,se());else{var K=a(x);K!==null&&ae(Z,K.startTime-me)}}var W=!1,H=-1,le=5,Q=-1;function Ne(){return I?!0:!(e.unstable_now()-Q<le)}function oe(){if(I=!1,W){var me=e.unstable_now();Q=me;var K=!0;try{e:{D=!1,A&&(A=!1,U(H),H=-1),O=!0;var fe=C;try{t:{for(V(me),N=a(y);N!==null&&!(N.expirationTime>me&&Ne());){var Oe=N.callback;if(typeof Oe=="function"){N.callback=null,C=N.priorityLevel;var ye=Oe(N.expirationTime<=me);if(me=e.unstable_now(),typeof ye=="function"){N.callback=ye,V(me),K=!0;break t}N===a(y)&&n(y),V(me)}else n(y);N=a(y)}if(N!==null)K=!0;else{var J=a(x);J!==null&&ae(Z,J.startTime-me),K=!1}}break e}finally{N=null,C=fe,O=!1}K=void 0}}finally{K?se():W=!1}}}var se;if(typeof B=="function")se=function(){B(oe)};else if(typeof MessageChannel!="undefined"){var ce=new MessageChannel,Ce=ce.port2;ce.port1.onmessage=oe,se=function(){Ce.postMessage(null)}}else se=function(){z(oe,0)};function ae(me,K){H=z(function(){me(e.unstable_now())},K)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(me){me.callback=null},e.unstable_forceFrameRate=function(me){0>me||125<me?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):le=0<me?Math.floor(1e3/me):5},e.unstable_getCurrentPriorityLevel=function(){return C},e.unstable_next=function(me){switch(C){case 1:case 2:case 3:var K=3;break;default:K=C}var fe=C;C=K;try{return me()}finally{C=fe}},e.unstable_requestPaint=function(){I=!0},e.unstable_runWithPriority=function(me,K){switch(me){case 1:case 2:case 3:case 4:case 5:break;default:me=3}var fe=C;C=me;try{return K()}finally{C=fe}},e.unstable_scheduleCallback=function(me,K,fe){var Oe=e.unstable_now();switch(typeof fe=="object"&&fe!==null?(fe=fe.delay,fe=typeof fe=="number"&&0<fe?Oe+fe:Oe):fe=Oe,me){case 1:var ye=-1;break;case 2:ye=250;break;case 5:ye=1073741823;break;case 4:ye=1e4;break;default:ye=5e3}return ye=fe+ye,me={id:k++,callback:K,priorityLevel:me,startTime:fe,expirationTime:ye,sortIndex:-1},fe>Oe?(me.sortIndex=fe,r(x,me),a(y)===null&&me===a(x)&&(A?(U(H),H=-1):A=!0,ae(Z,fe-Oe))):(me.sortIndex=ye,r(y,me),D||O||(D=!0,W||(W=!0,se()))),me},e.unstable_shouldYield=Ne,e.unstable_wrapCallback=function(me){var K=C;return function(){var fe=C;C=K;try{return me.apply(this,arguments)}finally{C=fe}}}})(ux)),ux}var x2;function m6(){return x2||(x2=1,dx.exports=f6()),dx.exports}var hx={exports:{}},xs={};var p2;function g6(){if(p2)return xs;p2=1;var e=Xf();function r(y){var x="https://react.dev/errors/"+y;if(1<arguments.length){x+="?args[]="+encodeURIComponent(arguments[1]);for(var k=2;k<arguments.length;k++)x+="&args[]="+encodeURIComponent(arguments[k])}return"Minified React error #"+y+"; visit "+x+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(){}var n={d:{f:a,r:function(){throw Error(r(522))},D:a,C:a,L:a,m:a,X:a,S:a,M:a},p:0,findDOMNode:null},i=Symbol.for("react.portal");function c(y,x,k){var N=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:N==null?null:""+N,children:y,containerInfo:x,implementation:k}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function g(y,x){if(y==="font")return"";if(typeof x=="string")return x==="use-credentials"?x:""}return xs.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=n,xs.createPortal=function(y,x){var k=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!x||x.nodeType!==1&&x.nodeType!==9&&x.nodeType!==11)throw Error(r(299));return c(y,x,null,k)},xs.flushSync=function(y){var x=u.T,k=n.p;try{if(u.T=null,n.p=2,y)return y()}finally{u.T=x,n.p=k,n.d.f()}},xs.preconnect=function(y,x){typeof y=="string"&&(x?(x=x.crossOrigin,x=typeof x=="string"?x==="use-credentials"?x:"":void 0):x=null,n.d.C(y,x))},xs.prefetchDNS=function(y){typeof y=="string"&&n.d.D(y)},xs.preinit=function(y,x){if(typeof y=="string"&&x&&typeof x.as=="string"){var k=x.as,N=g(k,x.crossOrigin),C=typeof x.integrity=="string"?x.integrity:void 0,O=typeof x.fetchPriority=="string"?x.fetchPriority:void 0;k==="style"?n.d.S(y,typeof x.precedence=="string"?x.precedence:void 0,{crossOrigin:N,integrity:C,fetchPriority:O}):k==="script"&&n.d.X(y,{crossOrigin:N,integrity:C,fetchPriority:O,nonce:typeof x.nonce=="string"?x.nonce:void 0})}},xs.preinitModule=function(y,x){if(typeof y=="string")if(typeof x=="object"&&x!==null){if(x.as==null||x.as==="script"){var k=g(x.as,x.crossOrigin);n.d.M(y,{crossOrigin:k,integrity:typeof x.integrity=="string"?x.integrity:void 0,nonce:typeof x.nonce=="string"?x.nonce:void 0})}}else x==null&&n.d.M(y)},xs.preload=function(y,x){if(typeof y=="string"&&typeof x=="object"&&x!==null&&typeof x.as=="string"){var k=x.as,N=g(k,x.crossOrigin);n.d.L(y,k,{crossOrigin:N,integrity:typeof x.integrity=="string"?x.integrity:void 0,nonce:typeof x.nonce=="string"?x.nonce:void 0,type:typeof x.type=="string"?x.type:void 0,fetchPriority:typeof x.fetchPriority=="string"?x.fetchPriority:void 0,referrerPolicy:typeof x.referrerPolicy=="string"?x.referrerPolicy:void 0,imageSrcSet:typeof x.imageSrcSet=="string"?x.imageSrcSet:void 0,imageSizes:typeof x.imageSizes=="string"?x.imageSizes:void 0,media:typeof x.media=="string"?x.media:void 0})}},xs.preloadModule=function(y,x){if(typeof y=="string")if(x){var k=g(x.as,x.crossOrigin);n.d.m(y,{as:typeof x.as=="string"&&x.as!=="script"?x.as:void 0,crossOrigin:k,integrity:typeof x.integrity=="string"?x.integrity:void 0})}else n.d.m(y)},xs.requestFormReset=function(y){n.d.r(y)},xs.unstable_batchedUpdates=function(y,x){return y(x)},xs.useFormState=function(y,x,k){return u.H.useFormState(y,x,k)},xs.useFormStatus=function(){return u.H.useHostTransitionStatus()},xs.version="19.2.1",xs}var y2;function V_(){if(y2)return hx.exports;y2=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__=="undefined"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),hx.exports=g6(),hx.exports}var b2;function x6(){if(b2)return V0;b2=1;var e=m6(),r=Xf(),a=V_();function n(s){var l="https://react.dev/errors/"+s;if(1<arguments.length){l+="?args[]="+encodeURIComponent(arguments[1]);for(var m=2;m<arguments.length;m++)l+="&args[]="+encodeURIComponent(arguments[m])}return"Minified React error #"+s+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function c(s){var l=s,m=s;if(s.alternate)for(;l.return;)l=l.return;else{s=l;do l=s,(l.flags&4098)!==0&&(m=l.return),s=l.return;while(s)}return l.tag===3?m:null}function u(s){if(s.tag===13){var l=s.memoizedState;if(l===null&&(s=s.alternate,s!==null&&(l=s.memoizedState)),l!==null)return l.dehydrated}return null}function g(s){if(s.tag===31){var l=s.memoizedState;if(l===null&&(s=s.alternate,s!==null&&(l=s.memoizedState)),l!==null)return l.dehydrated}return null}function y(s){if(c(s)!==s)throw Error(n(188))}function x(s){var l=s.alternate;if(!l){if(l=c(s),l===null)throw Error(n(188));return l!==s?null:s}for(var m=s,_=l;;){var T=m.return;if(T===null)break;var M=T.alternate;if(M===null){if(_=T.return,_!==null){m=_;continue}break}if(T.child===M.child){for(M=T.child;M;){if(M===m)return y(T),s;if(M===_)return y(T),l;M=M.sibling}throw Error(n(188))}if(m.return!==_.return)m=T,_=M;else{for(var q=!1,pe=T.child;pe;){if(pe===m){q=!0,m=T,_=M;break}if(pe===_){q=!0,_=T,m=M;break}pe=pe.sibling}if(!q){for(pe=M.child;pe;){if(pe===m){q=!0,m=M,_=T;break}if(pe===_){q=!0,_=M,m=T;break}pe=pe.sibling}if(!q)throw Error(n(189))}}if(m.alternate!==_)throw Error(n(190))}if(m.tag!==3)throw Error(n(188));return m.stateNode.current===m?s:l}function k(s){var l=s.tag;if(l===5||l===26||l===27||l===6)return s;for(s=s.child;s!==null;){if(l=k(s),l!==null)return l;s=s.sibling}return null}var N=Object.assign,C=Symbol.for("react.element"),O=Symbol.for("react.transitional.element"),D=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),U=Symbol.for("react.consumer"),B=Symbol.for("react.context"),V=Symbol.for("react.forward_ref"),Z=Symbol.for("react.suspense"),W=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),le=Symbol.for("react.lazy"),Q=Symbol.for("react.activity"),Ne=Symbol.for("react.memo_cache_sentinel"),oe=Symbol.iterator;function se(s){return s===null||typeof s!="object"?null:(s=oe&&s[oe]||s["@@iterator"],typeof s=="function"?s:null)}var ce=Symbol.for("react.client.reference");function Ce(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===ce?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case A:return"Fragment";case z:return"Profiler";case I:return"StrictMode";case Z:return"Suspense";case W:return"SuspenseList";case Q:return"Activity"}if(typeof s=="object")switch(s.$$typeof){case D:return"Portal";case B:return s.displayName||"Context";case U:return(s._context.displayName||"Context")+".Consumer";case V:var l=s.render;return s=s.displayName,s||(s=l.displayName||l.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case H:return l=s.displayName||null,l!==null?l:Ce(s.type)||"Memo";case le:l=s._payload,s=s._init;try{return Ce(s(l))}catch(m){}}return null}var ae=Array.isArray,me=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,fe={pending:!1,data:null,method:null,action:null},Oe=[],ye=-1;function J(s){return{current:s}}function G(s){0>ye||(s.current=Oe[ye],Oe[ye]=null,ye--)}function ie(s,l){ye++,Oe[ye]=s.current,s.current=l}var re=J(null),ne=J(null),ve=J(null),Ve=J(null);function Ae(s,l){switch(ie(ve,l),ie(ne,s),ie(re,null),l.nodeType){case 9:case 11:s=(s=l.documentElement)&&(s=s.namespaceURI)?Ob(s):0;break;default:if(s=l.tagName,l=l.namespaceURI)l=Ob(l),s=Rb(l,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}G(re),ie(re,s)}function ze(){G(re),G(ne),G(ve)}function Re(s){s.memoizedState!==null&&ie(Ve,s);var l=re.current,m=Rb(l,s.type);l!==m&&(ie(ne,s),ie(re,m))}function Ze(s){ne.current===s&&(G(re),G(ne)),Ve.current===s&&(G(Ve),F0._currentValue=fe)}var Lt,mt;function Zt(s){if(Lt===void 0)try{throw Error()}catch(m){var l=m.stack.trim().match(/\n( *(at )?)/);Lt=l&&l[1]||"",mt=-1<m.stack.indexOf(`
|
||
at`)?" (<anonymous>)":-1<m.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||
`+Lt+s+mt}var ar=!1;function or(s,l){if(!s||ar)return"";ar=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var _={DetermineComponentFrameRoot:function(){try{if(l){var Mt=function(){throw Error()};if(Object.defineProperty(Mt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Mt,[])}catch(xt){var dt=xt}Reflect.construct(s,[],Mt)}else{try{Mt.call()}catch(xt){dt=xt}s.call(Mt.prototype)}}else{try{throw Error()}catch(xt){dt=xt}(Mt=s())&&typeof Mt.catch=="function"&&Mt.catch(function(){})}}catch(xt){if(xt&&dt&&typeof xt.stack=="string")return[xt.stack,dt.stack]}return[null,null]}};_.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var T=Object.getOwnPropertyDescriptor(_.DetermineComponentFrameRoot,"name");T&&T.configurable&&Object.defineProperty(_.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var M=_.DetermineComponentFrameRoot(),q=M[0],pe=M[1];if(q&&pe){var Ie=q.split(`
|
||
`),ot=pe.split(`
|
||
`);for(T=_=0;_<Ie.length&&!Ie[_].includes("DetermineComponentFrameRoot");)_++;for(;T<ot.length&&!ot[T].includes("DetermineComponentFrameRoot");)T++;if(_===Ie.length||T===ot.length)for(_=Ie.length-1,T=ot.length-1;1<=_&&0<=T&&Ie[_]!==ot[T];)T--;for(;1<=_&&0<=T;_--,T--)if(Ie[_]!==ot[T]){if(_!==1||T!==1)do if(_--,T--,0>T||Ie[_]!==ot[T]){var Et=`
|
||
`+Ie[_].replace(" at new "," at ");return s.displayName&&Et.includes("<anonymous>")&&(Et=Et.replace("<anonymous>",s.displayName)),Et}while(1<=_&&0<=T);break}}}finally{ar=!1,Error.prepareStackTrace=m}return(m=s?s.displayName||s.name:"")?Zt(m):""}function yt(s,l){switch(s.tag){case 26:case 27:case 5:return Zt(s.type);case 16:return Zt("Lazy");case 13:return s.child!==l&&l!==null?Zt("Suspense Fallback"):Zt("Suspense");case 19:return Zt("SuspenseList");case 0:case 15:return or(s.type,!1);case 11:return or(s.type.render,!1);case 1:return or(s.type,!0);case 31:return Zt("Activity");default:return""}}function nr(s){try{var l="",m=null;do l+=yt(s,m),m=s,s=s.return;while(s);return l}catch(_){return`
|
||
Error generating stack: `+_.message+`
|
||
`+_.stack}}var $t=Object.prototype.hasOwnProperty,Er=e.unstable_scheduleCallback,St=e.unstable_cancelCallback,Br=e.unstable_shouldYield,Pt=e.unstable_requestPaint,it=e.unstable_now,De=e.unstable_getCurrentPriorityLevel,Je=e.unstable_ImmediatePriority,Be=e.unstable_UserBlockingPriority,vt=e.unstable_NormalPriority,jt=e.unstable_LowPriority,Ct=e.unstable_IdlePriority,Wt=e.log,pr=e.unstable_setDisableYieldValue,Ge=null,We=null;function At(s){if(typeof Wt=="function"&&pr(s),We&&typeof We.setStrictMode=="function")try{We.setStrictMode(Ge,s)}catch(l){}}var lt=Math.clz32?Math.clz32:tr,Dt=Math.log,mr=Math.LN2;function tr(s){return s>>>=0,s===0?32:31-(Dt(s)/mr|0)|0}var pt=256,Jt=262144,vr=4194304;function Ir(s){var l=s&42;if(l!==0)return l;switch(s&-s){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 s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function Le(s,l,m){var _=s.pendingLanes;if(_===0)return 0;var T=0,M=s.suspendedLanes,q=s.pingedLanes;s=s.warmLanes;var pe=_&134217727;return pe!==0?(_=pe&~M,_!==0?T=Ir(_):(q&=pe,q!==0?T=Ir(q):m||(m=pe&~s,m!==0&&(T=Ir(m))))):(pe=_&~M,pe!==0?T=Ir(pe):q!==0?T=Ir(q):m||(m=_&~s,m!==0&&(T=Ir(m)))),T===0?0:l!==0&&l!==T&&(l&M)===0&&(M=T&-T,m=l&-l,M>=m||M===32&&(m&4194048)!==0)?l:T}function qe(s,l){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&l)===0}function Ke(s,l){switch(s){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Yt(){var s=vr;return vr<<=1,(vr&62914560)===0&&(vr=4194304),s}function gr(s){for(var l=[],m=0;31>m;m++)l.push(s);return l}function jr(s,l){s.pendingLanes|=l,l!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function Zr(s,l,m,_,T,M){var q=s.pendingLanes;s.pendingLanes=m,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=m,s.entangledLanes&=m,s.errorRecoveryDisabledLanes&=m,s.shellSuspendCounter=0;var pe=s.entanglements,Ie=s.expirationTimes,ot=s.hiddenUpdates;for(m=q&~m;0<m;){var Et=31-lt(m),Mt=1<<Et;pe[Et]=0,Ie[Et]=-1;var dt=ot[Et];if(dt!==null)for(ot[Et]=null,Et=0;Et<dt.length;Et++){var xt=dt[Et];xt!==null&&(xt.lane&=-536870913)}m&=~Mt}_!==0&&en(s,_,0),M!==0&&T===0&&s.tag!==0&&(s.suspendedLanes|=M&~(q&~l))}function en(s,l,m){s.pendingLanes|=l,s.suspendedLanes&=~l;var _=31-lt(l);s.entangledLanes|=l,s.entanglements[_]=s.entanglements[_]|1073741824|m&261930}function Qt(s,l){var m=s.entangledLanes|=l;for(s=s.entanglements;m;){var _=31-lt(m),T=1<<_;T&l|s[_]&l&&(s[_]|=l),m&=~T}}function wr(s,l){var m=l&-l;return m=(m&42)!==0?1:Vt(m),(m&(s.suspendedLanes|l))!==0?0:m}function Vt(s){switch(s){case 2:s=1;break;case 8:s=4;break;case 32:s=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:s=128;break;case 268435456:s=134217728;break;default:s=0}return s}function Ut(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function de(){var s=K.p;return s!==0?s:(s=window.event,s===void 0?32:t2(s.type))}function ge(s,l){var m=K.p;try{return K.p=s,l()}finally{K.p=m}}var be=Math.random().toString(36).slice(2),we="__reactFiber$"+be,ke="__reactProps$"+be,Te="__reactContainer$"+be,Qe="__reactEvents$"+be,bt="__reactListeners$"+be,et="__reactHandles$"+be,at="__reactResources$"+be,nt="__reactMarker$"+be;function Ot(s){delete s[we],delete s[ke],delete s[Qe],delete s[bt],delete s[et]}function It(s){var l=s[we];if(l)return l;for(var m=s.parentNode;m;){if(l=m[Te]||m[we]){if(m=l.alternate,l.child!==null||m!==null&&m.child!==null)for(s=Bb(s);s!==null;){if(m=s[we])return m;s=Bb(s)}return l}s=m,m=s.parentNode}return null}function Ht(s){if(s=s[we]||s[Te]){var l=s.tag;if(l===5||l===6||l===13||l===31||l===26||l===27||l===3)return s}return null}function zt(s){var l=s.tag;if(l===5||l===26||l===27||l===6)return s.stateNode;throw Error(n(33))}function Kt(s){var l=s[at];return l||(l=s[at]={hoistableStyles:new Map,hoistableScripts:new Map}),l}function fr(s){s[nt]=!0}var Ee=new Set,wt={};function xr(s,l){qr(s,l),qr(s+"Capture",l)}function qr(s,l){for(wt[s]=l,s=0;s<l.length;s++)Ee.add(l[s])}var Za=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]*$"),Tr={},Ar={};function Pe(s){return $t.call(Ar,s)?!0:$t.call(Tr,s)?!1:Za.test(s)?Ar[s]=!0:(Tr[s]=!0,!1)}function kt(s,l,m){if(Pe(l))if(m===null)s.removeAttribute(l);else{switch(typeof m){case"undefined":case"function":case"symbol":s.removeAttribute(l);return;case"boolean":var _=l.toLowerCase().slice(0,5);if(_!=="data-"&&_!=="aria-"){s.removeAttribute(l);return}}s.setAttribute(l,""+m)}}function Sr(s,l,m){if(m===null)s.removeAttribute(l);else{switch(typeof m){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(l);return}s.setAttribute(l,""+m)}}function la(s,l,m,_){if(_===null)s.removeAttribute(m);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(m);return}s.setAttributeNS(l,m,""+_)}}function Dr(s){switch(typeof s){case"bigint":case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function Da(s){var l=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function Un(s,l,m){var _=Object.getOwnPropertyDescriptor(s.constructor.prototype,l);if(!s.hasOwnProperty(l)&&typeof _!="undefined"&&typeof _.get=="function"&&typeof _.set=="function"){var T=_.get,M=_.set;return Object.defineProperty(s,l,{configurable:!0,get:function(){return T.call(this)},set:function(q){m=""+q,M.call(this,q)}}),Object.defineProperty(s,l,{enumerable:_.enumerable}),{getValue:function(){return m},setValue:function(q){m=""+q},stopTracking:function(){s._valueTracker=null,delete s[l]}}}}function hr(s){if(!s._valueTracker){var l=Da(s)?"checked":"value";s._valueTracker=Un(s,l,""+s[l])}}function Jr(s){if(!s)return!1;var l=s._valueTracker;if(!l)return!0;var m=l.getValue(),_="";return s&&(_=Da(s)?s.checked?"true":"false":s.value),s=_,s!==m?(l.setValue(s),!0):!1}function Rs(s){if(s=s||(typeof document!="undefined"?document:void 0),typeof s=="undefined")return null;try{return s.activeElement||s.body}catch(l){return s.body}}var _s=/[\n"\\]/g;function kr(s){return s.replace(_s,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function sn(s,l,m,_,T,M,q,pe){s.name="",q!=null&&typeof q!="function"&&typeof q!="symbol"&&typeof q!="boolean"?s.type=q:s.removeAttribute("type"),l!=null?q==="number"?(l===0&&s.value===""||s.value!=l)&&(s.value=""+Dr(l)):s.value!==""+Dr(l)&&(s.value=""+Dr(l)):q!=="submit"&&q!=="reset"||s.removeAttribute("value"),l!=null?Se(s,q,Dr(l)):m!=null?Se(s,q,Dr(m)):_!=null&&s.removeAttribute("value"),T==null&&M!=null&&(s.defaultChecked=!!M),T!=null&&(s.checked=T&&typeof T!="function"&&typeof T!="symbol"),pe!=null&&typeof pe!="function"&&typeof pe!="symbol"&&typeof pe!="boolean"?s.name=""+Dr(pe):s.removeAttribute("name")}function rt(s,l,m,_,T,M,q,pe){if(M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"&&(s.type=M),l!=null||m!=null){if(!(M!=="submit"&&M!=="reset"||l!=null)){hr(s);return}m=m!=null?""+Dr(m):"",l=l!=null?""+Dr(l):m,pe||l===s.value||(s.value=l),s.defaultValue=l}_=_!=null?_:T,_=typeof _!="function"&&typeof _!="symbol"&&!!_,s.checked=pe?s.checked:!!_,s.defaultChecked=!!_,q!=null&&typeof q!="function"&&typeof q!="symbol"&&typeof q!="boolean"&&(s.name=q),hr(s)}function Se(s,l,m){l==="number"&&Rs(s.ownerDocument)===s||s.defaultValue===""+m||(s.defaultValue=""+m)}function sr(s,l,m,_){if(s=s.options,l){l={};for(var T=0;T<m.length;T++)l["$"+m[T]]=!0;for(m=0;m<s.length;m++)T=l.hasOwnProperty("$"+s[m].value),s[m].selected!==T&&(s[m].selected=T),T&&_&&(s[m].defaultSelected=!0)}else{for(m=""+Dr(m),l=null,T=0;T<s.length;T++){if(s[T].value===m){s[T].selected=!0,_&&(s[T].defaultSelected=!0);return}l!==null||s[T].disabled||(l=s[T])}l!==null&&(l.selected=!0)}}function Ea(s,l,m){if(l!=null&&(l=""+Dr(l),l!==s.value&&(s.value=l),m==null)){s.defaultValue!==l&&(s.defaultValue=l);return}s.defaultValue=m!=null?""+Dr(m):""}function gn(s,l,m,_){if(l==null){if(_!=null){if(m!=null)throw Error(n(92));if(ae(_)){if(1<_.length)throw Error(n(93));_=_[0]}m=_}m==null&&(m=""),l=m}m=Dr(l),s.defaultValue=m,_=s.textContent,_===m&&_!==""&&_!==null&&(s.value=_),hr(s)}function Ms(s,l){if(l){var m=s.firstChild;if(m&&m===s.lastChild&&m.nodeType===3){m.nodeValue=l;return}}s.textContent=l}var jo=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 xn(s,l,m){var _=l.indexOf("--")===0;m==null||typeof m=="boolean"||m===""?_?s.setProperty(l,""):l==="float"?s.cssFloat="":s[l]="":_?s.setProperty(l,m):typeof m!="number"||m===0||jo.has(l)?l==="float"?s.cssFloat=m:s[l]=(""+m).trim():s[l]=m+"px"}function Nr(s,l,m){if(l!=null&&typeof l!="object")throw Error(n(62));if(s=s.style,m!=null){for(var _ in m)!m.hasOwnProperty(_)||l!=null&&l.hasOwnProperty(_)||(_.indexOf("--")===0?s.setProperty(_,""):_==="float"?s.cssFloat="":s[_]="");for(var T in l)_=l[T],l.hasOwnProperty(T)&&m[T]!==_&&xn(s,T,_)}else for(var M in l)l.hasOwnProperty(M)&&xn(s,M,l[M])}function _a(s){if(s.indexOf("-")===-1)return!1;switch(s){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 To=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"]]),Jl=/^[\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 vi(s){return Jl.test(""+s)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":s}function On(){}var so=null;function Ao(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var za=null,Rr=null;function on(s){var l=Ht(s);if(l&&(s=l.stateNode)){var m=s[ke]||null;e:switch(s=l.stateNode,l.type){case"input":if(sn(s,m.value,m.defaultValue,m.defaultValue,m.checked,m.defaultChecked,m.type,m.name),l=m.name,m.type==="radio"&&l!=null){for(m=s;m.parentNode;)m=m.parentNode;for(m=m.querySelectorAll('input[name="'+kr(""+l)+'"][type="radio"]'),l=0;l<m.length;l++){var _=m[l];if(_!==s&&_.form===s.form){var T=_[ke]||null;if(!T)throw Error(n(90));sn(_,T.value,T.defaultValue,T.defaultValue,T.checked,T.defaultChecked,T.type,T.name)}}for(l=0;l<m.length;l++)_=m[l],_.form===s.form&&Jr(_)}break e;case"textarea":Ea(s,m.value,m.defaultValue);break e;case"select":l=m.value,l!=null&&sr(s,!!m.multiple,l,!1)}}}var cr=!1;function Ql(s,l,m){if(cr)return s(l,m);cr=!0;try{var _=s(l);return _}finally{if(cr=!1,(za!==null||Rr!==null)&&(bh(),za&&(l=za,s=Rr,Rr=za=null,on(l),s)))for(l=0;l<s.length;l++)on(s[l])}}function Fr(s,l){var m=s.stateNode;if(m===null)return null;var _=m[ke]||null;if(_===null)return null;m=_[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(_=!_.disabled)||(s=s.type,_=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!_;break e;default:s=!1}if(s)return null;if(m&&typeof m!="function")throw Error(n(231,l,typeof m));return m}var wa=!(typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"),Oo=!1;if(wa)try{var Zn={};Object.defineProperty(Zn,"passive",{get:function(){Oo=!0}}),window.addEventListener("test",Zn,Zn),window.removeEventListener("test",Zn,Zn)}catch(s){Oo=!1}var ws=null,qn=null,qa=null;function us(){if(qa)return qa;var s,l=qn,m=l.length,_,T="value"in ws?ws.value:ws.textContent,M=T.length;for(s=0;s<m&&l[s]===T[s];s++);var q=m-s;for(_=1;_<=q&&l[m-_]===T[M-_];_++);return qa=T.slice(s,1<_?1-_:void 0)}function Qs(s){var l=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&l===13&&(s=13)):s=l,s===10&&(s=13),32<=s||s===13?s:0}function ei(){return!0}function ec(){return!1}function tn(s){function l(m,_,T,M,q){this._reactName=m,this._targetInst=T,this.type=_,this.nativeEvent=M,this.target=q,this.currentTarget=null;for(var pe in s)s.hasOwnProperty(pe)&&(m=s[pe],this[pe]=m?m(M):M[pe]);return this.isDefaultPrevented=(M.defaultPrevented!=null?M.defaultPrevented:M.returnValue===!1)?ei:ec,this.isPropagationStopped=ec,this}return N(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var m=this.nativeEvent;m&&(m.preventDefault?m.preventDefault():typeof m.returnValue!="unknown"&&(m.returnValue=!1),this.isDefaultPrevented=ei)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=ei)},persist:function(){},isPersistent:ei}),l}var Kn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},pn=tn(Kn),Pi=N({},Kn,{view:0,detail:0}),Qr=tn(Pi),fl,Jn,ti,Ro=N({},Pi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Mo,button:0,buttons:0,relatedTarget:function(s){return s.relatedTarget===void 0?s.fromElement===s.srcElement?s.toElement:s.fromElement:s.relatedTarget},movementX:function(s){return"movementX"in s?s.movementX:(s!==ti&&(ti&&s.type==="mousemove"?(fl=s.screenX-ti.screenX,Jn=s.screenY-ti.screenY):Jn=fl=0,ti=s),fl)},movementY:function(s){return"movementY"in s?s.movementY:Jn}}),ha=tn(Ro),ml=N({},Ro,{dataTransfer:0}),gl=tn(ml),ri=N({},Pi,{relatedTarget:0}),tc=tn(ri),ft=N({},Kn,{animationName:0,elapsedTime:0,pseudoElement:0}),Hr=tn(ft),yn=N({},Kn,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),Qn=tn(yn),Bc=N({},Kn,{data:0}),rc=tn(Bc),_i={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Uc={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"},xl={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ga(s){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(s):(s=xl[s])?!!l[s]:!1}function Mo(){return Ga}var Ha=N({},Pi,{key:function(s){if(s.key){var l=_i[s.key]||s.key;if(l!=="Unidentified")return l}return s.type==="keypress"?(s=Qs(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?Uc[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Mo,charCode:function(s){return s.type==="keypress"?Qs(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?Qs(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),Do=tn(Ha),Fi=N({},Ro,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ga=tn(Fi),Or=N({},Pi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Mo}),s0=tn(Or),Sa=N({},Kn,{propertyName:0,elapsedTime:0,pseudoElement:0}),wi=tn(Sa),ai=N({},Ro,{deltaX:function(s){return"deltaX"in s?s.deltaX:"wheelDeltaX"in s?-s.wheelDeltaX:0},deltaY:function(s){return"deltaY"in s?s.deltaY:"wheelDeltaY"in s?-s.wheelDeltaY:"wheelDelta"in s?-s.wheelDelta:0},deltaZ:0,deltaMode:0}),Bi=tn(ai),Ds=N({},Kn,{newState:0,oldState:0}),Ui=tn(Ds),es=[9,13,27,32],io=wa&&"CompositionEvent"in window,zi=null;wa&&"documentMode"in document&&(zi=document.documentMode);var zc=wa&&"TextEvent"in window&&!zi,pl=wa&&(!io||zi&&8<zi&&11>=zi),ni=" ",yl=!1;function Hc(s,l){switch(s){case"keyup":return es.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Hi(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var oo=!1;function ln(s,l){switch(s){case"compositionend":return Hi(l);case"keypress":return l.which!==32?null:(yl=!0,ni);case"textInput":return s=l.data,s===ni&&yl?null:s;default:return null}}function si(s,l){if(oo)return s==="compositionend"||!io&&Hc(s,l)?(s=us(),qa=qn=ws=null,oo=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return pl&&l.locale!=="ko"?null:l.data;default:return null}}var hs={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 ks(s){var l=s&&s.nodeName&&s.nodeName.toLowerCase();return l==="input"?!!hs[s.type]:l==="textarea"}function Ns(s,l,m,_){za?Rr?Rr.push(_):Rr=[_]:za=_,l=Ch(l,"onChange"),0<l.length&&(m=new pn("onChange","change",null,m,_),s.push({event:m,listeners:l}))}var Ls=null,Vi=null;function Lo(s){Sb(s,0)}function lo(s){var l=zt(s);if(Jr(l))return s}function zn(s,l){if(s==="change")return l}var Vc=!1;if(wa){var fs;if(wa){var Is="oninput"in document;if(!Is){var ta=document.createElement("div");ta.setAttribute("oninput","return;"),Is=typeof ta.oninput=="function"}fs=Is}else fs=!1;Vc=fs&&(!document.documentMode||9<document.documentMode)}function Wi(){Ls&&(Ls.detachEvent("onpropertychange",ee),Vi=Ls=null)}function ee(s){if(s.propertyName==="value"&&lo(Vi)){var l=[];Ns(l,Vi,s,Ao(s)),Ql(Lo,l)}}function o(s,l,m){s==="focusin"?(Wi(),Ls=l,Vi=m,Ls.attachEvent("onpropertychange",ee)):s==="focusout"&&Wi()}function d(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return lo(Vi)}function f(s,l){if(s==="click")return lo(l)}function p(s,l){if(s==="input"||s==="change")return lo(l)}function b(s,l){return s===l&&(s!==0||1/s===1/l)||s!==s&&l!==l}var w=typeof Object.is=="function"?Object.is:b;function S(s,l){if(w(s,l))return!0;if(typeof s!="object"||s===null||typeof l!="object"||l===null)return!1;var m=Object.keys(s),_=Object.keys(l);if(m.length!==_.length)return!1;for(_=0;_<m.length;_++){var T=m[_];if(!$t.call(l,T)||!w(s[T],l[T]))return!1}return!0}function R(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function P(s,l){var m=R(s);s=0;for(var _;m;){if(m.nodeType===3){if(_=s+m.textContent.length,s<=l&&_>=l)return{node:m,offset:l-s};s=_}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=R(m)}}function X(s,l){return s&&l?s===l?!0:s&&s.nodeType===3?!1:l&&l.nodeType===3?X(s,l.parentNode):"contains"in s?s.contains(l):s.compareDocumentPosition?!!(s.compareDocumentPosition(l)&16):!1:!1}function te(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var l=Rs(s.document);l instanceof s.HTMLIFrameElement;){try{var m=typeof l.contentWindow.location.href=="string"}catch(_){m=!1}if(m)s=l.contentWindow;else break;l=Rs(s.document)}return l}function ue(s){var l=s&&s.nodeName&&s.nodeName.toLowerCase();return l&&(l==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||l==="textarea"||s.contentEditable==="true")}var je=wa&&"documentMode"in document&&11>=document.documentMode,Fe=null,Ue=null,tt=null,ut=!1;function Xt(s,l,m){var _=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;ut||Fe==null||Fe!==Rs(_)||(_=Fe,"selectionStart"in _&&ue(_)?_={start:_.selectionStart,end:_.selectionEnd}:(_=(_.ownerDocument&&_.ownerDocument.defaultView||window).getSelection(),_={anchorNode:_.anchorNode,anchorOffset:_.anchorOffset,focusNode:_.focusNode,focusOffset:_.focusOffset}),tt&&S(tt,_)||(tt=_,_=Ch(Ue,"onSelect"),0<_.length&&(l=new pn("onSelect","select",null,l,m),s.push({event:l,listeners:_}),l.target=Fe)))}function Gt(s,l){var m={};return m[s.toLowerCase()]=l.toLowerCase(),m["Webkit"+s]="webkit"+l,m["Moz"+s]="moz"+l,m}var Ft={animationend:Gt("Animation","AnimationEnd"),animationiteration:Gt("Animation","AnimationIteration"),animationstart:Gt("Animation","AnimationStart"),transitionrun:Gt("Transition","TransitionRun"),transitionstart:Gt("Transition","TransitionStart"),transitioncancel:Gt("Transition","TransitionCancel"),transitionend:Gt("Transition","TransitionEnd")},Wr={},Ur={};wa&&(Ur=document.createElement("div").style,"AnimationEvent"in window||(delete Ft.animationend.animation,delete Ft.animationiteration.animation,delete Ft.animationstart.animation),"TransitionEvent"in window||delete Ft.transitionend.transition);function fa(s){if(Wr[s])return Wr[s];if(!Ft[s])return s;var l=Ft[s],m;for(m in l)if(l.hasOwnProperty(m)&&m in Ur)return Wr[s]=l[m];return s}var Rn=fa("animationend"),Mn=fa("animationiteration"),ca=fa("animationstart"),bn=fa("transitionrun"),Hn=fa("transitionstart"),co=fa("transitioncancel"),Ss=fa("transitionend"),Wc=new Map,ki="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(" ");ki.push("scrollEnd");function Ps(s,l){Wc.set(s,l),xr(l,[s])}var ac=typeof reportError=="function"?reportError:function(s){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var l=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof s=="object"&&s!==null&&typeof s.message=="string"?String(s.message):String(s),error:s});if(!window.dispatchEvent(l))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",s);return}console.error(s)},Fs=[],ms=0,Gc=0;function nc(){for(var s=ms,l=Gc=ms=0;l<s;){var m=Fs[l];Fs[l++]=null;var _=Fs[l];Fs[l++]=null;var T=Fs[l];Fs[l++]=null;var M=Fs[l];if(Fs[l++]=null,_!==null&&T!==null){var q=_.pending;q===null?T.next=T:(T.next=q.next,q.next=T),_.pending=T}M!==0&&bl(m,T,M)}}function uo(s,l,m,_){Fs[ms++]=s,Fs[ms++]=l,Fs[ms++]=m,Fs[ms++]=_,Gc|=_,s.lanes|=_,s=s.alternate,s!==null&&(s.lanes|=_)}function i0(s,l,m,_){return uo(s,l,m,_),sc(s)}function Ni(s,l){return uo(s,null,null,l),sc(s)}function bl(s,l,m){s.lanes|=m;var _=s.alternate;_!==null&&(_.lanes|=m);for(var T=!1,M=s.return;M!==null;)M.childLanes|=m,_=M.alternate,_!==null&&(_.childLanes|=m),M.tag===22&&(s=M.stateNode,s===null||s._visibility&1||(T=!0)),s=M,M=M.return;return s.tag===3?(M=s.stateNode,T&&l!==null&&(T=31-lt(m),s=M.hiddenUpdates,_=s[T],_===null?s[T]=[l]:_.push(l),l.lane=m|536870912),M):null}function sc(s){if(50<O0)throw O0=0,jg=null,Error(n(185));for(var l=s.return;l!==null;)s=l,l=s.return;return s.tag===3?s.stateNode:null}var Io={};function Em(s,l,m,_){this.tag=s,this.key=m,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=_,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function gs(s,l,m,_){return new Em(s,l,m,_)}function $c(s){return s=s.prototype,!(!s||!s.isReactComponent)}function Si(s,l){var m=s.alternate;return m===null?(m=gs(s.tag,l,s.key,s.mode),m.elementType=s.elementType,m.type=s.type,m.stateNode=s.stateNode,m.alternate=s,s.alternate=m):(m.pendingProps=l,m.type=s.type,m.flags=0,m.subtreeFlags=0,m.deletions=null),m.flags=s.flags&65011712,m.childLanes=s.childLanes,m.lanes=s.lanes,m.child=s.child,m.memoizedProps=s.memoizedProps,m.memoizedState=s.memoizedState,m.updateQueue=s.updateQueue,l=s.dependencies,m.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},m.sibling=s.sibling,m.index=s.index,m.ref=s.ref,m.refCleanup=s.refCleanup,m}function o0(s,l){s.flags&=65011714;var m=s.alternate;return m===null?(s.childLanes=0,s.lanes=l,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=m.childLanes,s.lanes=m.lanes,s.child=m.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=m.memoizedProps,s.memoizedState=m.memoizedState,s.updateQueue=m.updateQueue,s.type=m.type,l=m.dependencies,s.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),s}function ic(s,l,m,_,T,M){var q=0;if(_=s,typeof s=="function")$c(s)&&(q=1);else if(typeof s=="string")q=$N(s,m,re.current)?26:s==="html"||s==="head"||s==="body"?27:5;else e:switch(s){case Q:return s=gs(31,m,l,T),s.elementType=Q,s.lanes=M,s;case A:return Po(m.children,T,M,l);case I:q=8,T|=24;break;case z:return s=gs(12,m,l,T|2),s.elementType=z,s.lanes=M,s;case Z:return s=gs(13,m,l,T),s.elementType=Z,s.lanes=M,s;case W:return s=gs(19,m,l,T),s.elementType=W,s.lanes=M,s;default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case B:q=10;break e;case U:q=9;break e;case V:q=11;break e;case H:q=14;break e;case le:q=16,_=null;break e}q=29,m=Error(n(130,s===null?"null":typeof s,"")),_=null}return l=gs(q,m,l,T),l.elementType=s,l.type=_,l.lanes=M,l}function Po(s,l,m,_){return s=gs(7,s,_,l),s.lanes=m,s}function Xc(s,l,m){return s=gs(6,s,null,l),s.lanes=m,s}function l0(s){var l=gs(18,null,null,0);return l.stateNode=s,l}function c0(s,l,m){return l=gs(4,s.children!==null?s.children:[],s.key,l),l.lanes=m,l.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},l}var h=new WeakMap;function v(s,l){if(typeof s=="object"&&s!==null){var m=h.get(s);return m!==void 0?m:(l={value:s,source:l,stack:nr(l)},h.set(s,l),l)}return{value:s,source:l,stack:nr(l)}}var j=[],F=0,Y=null,he=0,Me=[],Ye=0,ct=null,Rt=1,lr="";function Cr(s,l){j[F++]=he,j[F++]=Y,Y=s,he=l}function Xr(s,l,m){Me[Ye++]=Rt,Me[Ye++]=lr,Me[Ye++]=ct,ct=s;var _=Rt;s=lr;var T=32-lt(_)-1;_&=~(1<<T),m+=1;var M=32-lt(l)+T;if(30<M){var q=T-T%5;M=(_&(1<<q)-1).toString(32),_>>=q,T-=q,Rt=1<<32-lt(l)+T|m<<T|_,lr=M+s}else Rt=1<<M|m<<T|_,lr=s}function Dn(s){s.return!==null&&(Cr(s,1),Xr(s,1,0))}function cn(s){for(;s===Y;)Y=j[--F],j[F]=null,he=j[--F],j[F]=null;for(;s===ct;)ct=Me[--Ye],Me[Ye]=null,lr=Me[--Ye],Me[Ye]=null,Rt=Me[--Ye],Me[Ye]=null}function Cs(s,l){Me[Ye++]=Rt,Me[Ye++]=lr,Me[Ye++]=ct,Rt=l.id,lr=l.overflow,ct=s}var xa=null,pa=null,ra=!1,ho=null,Bs=!1,Yc=Error(n(519));function fo(s){var l=Error(n(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw oc(v(l,s)),Yc}function d0(s){var l=s.stateNode,m=s.type,_=s.memoizedProps;switch(l[we]=s,l[ke]=_,m){case"dialog":na("cancel",l),na("close",l);break;case"iframe":case"object":case"embed":na("load",l);break;case"video":case"audio":for(m=0;m<M0.length;m++)na(M0[m],l);break;case"source":na("error",l);break;case"img":case"image":case"link":na("error",l),na("load",l);break;case"details":na("toggle",l);break;case"input":na("invalid",l),rt(l,_.value,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name,!0);break;case"select":na("invalid",l);break;case"textarea":na("invalid",l),gn(l,_.value,_.defaultValue,_.children)}m=_.children,typeof m!="string"&&typeof m!="number"&&typeof m!="bigint"||l.textContent===""+m||_.suppressHydrationWarning===!0||Tb(l.textContent,m)?(_.popover!=null&&(na("beforetoggle",l),na("toggle",l)),_.onScroll!=null&&na("scroll",l),_.onScrollEnd!=null&&na("scrollend",l),_.onClick!=null&&(l.onclick=On),l=!0):l=!1,l||fo(s,!0)}function rn(s){for(xa=s.return;xa;)switch(xa.tag){case 5:case 31:case 13:Bs=!1;return;case 27:case 3:Bs=!0;return;default:xa=xa.return}}function Gi(s){if(s!==xa)return!1;if(!ra)return rn(s),ra=!0,!1;var l=s.tag,m;if((m=l!==3&&l!==27)&&((m=l===5)&&(m=s.type,m=!(m!=="form"&&m!=="button")||Vg(s.type,s.memoizedProps)),m=!m),m&&pa&&fo(s),rn(s),l===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(n(317));pa=Fb(s)}else if(l===31){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(n(317));pa=Fb(s)}else l===27?(l=pa,Ml(s.type)?(s=Yg,Yg=null,pa=s):pa=l):pa=xa?Ei(s.stateNode.nextSibling):null;return!0}function Fo(){pa=xa=null,ra=!1}function u0(){var s=ho;return s!==null&&(Vs===null?Vs=s:Vs.push.apply(Vs,s),ho=null),s}function oc(s){ho===null?ho=[s]:ho.push(s)}var lc=J(null),mo=null,$i=null;function vl(s,l,m){ie(lc,l._currentValue),l._currentValue=m}function Bo(s){s._currentValue=lc.current,G(lc)}function jm(s,l,m){for(;s!==null;){var _=s.alternate;if((s.childLanes&l)!==l?(s.childLanes|=l,_!==null&&(_.childLanes|=l)):_!==null&&(_.childLanes&l)!==l&&(_.childLanes|=l),s===m)break;s=s.return}}function Tm(s,l,m,_){var T=s.child;for(T!==null&&(T.return=s);T!==null;){var M=T.dependencies;if(M!==null){var q=T.child;M=M.firstContext;e:for(;M!==null;){var pe=M;M=T;for(var Ie=0;Ie<l.length;Ie++)if(pe.context===l[Ie]){M.lanes|=m,pe=M.alternate,pe!==null&&(pe.lanes|=m),jm(M.return,m,s),_||(q=null);break e}M=pe.next}}else if(T.tag===18){if(q=T.return,q===null)throw Error(n(341));q.lanes|=m,M=q.alternate,M!==null&&(M.lanes|=m),jm(q,m,s),q=null}else q=T.child;if(q!==null)q.return=T;else for(q=T;q!==null;){if(q===s){q=null;break}if(T=q.sibling,T!==null){T.return=q.return,q=T;break}q=q.return}T=q}}function Zc(s,l,m,_){s=null;for(var T=l,M=!1;T!==null;){if(!M){if((T.flags&524288)!==0)M=!0;else if((T.flags&262144)!==0)break}if(T.tag===10){var q=T.alternate;if(q===null)throw Error(n(387));if(q=q.memoizedProps,q!==null){var pe=T.type;w(T.pendingProps.value,q.value)||(s!==null?s.push(pe):s=[pe])}}else if(T===Ve.current){if(q=T.alternate,q===null)throw Error(n(387));q.memoizedState.memoizedState!==T.memoizedState.memoizedState&&(s!==null?s.push(F0):s=[F0])}T=T.return}s!==null&&Tm(l,s,m,_),l.flags|=262144}function Gu(s){for(s=s.firstContext;s!==null;){if(!w(s.context._currentValue,s.memoizedValue))return!0;s=s.next}return!1}function cc(s){mo=s,$i=null,s=s.dependencies,s!==null&&(s.firstContext=null)}function ts(s){return m1(mo,s)}function $u(s,l){return mo===null&&cc(s),m1(s,l)}function m1(s,l){var m=l._currentValue;if(l={context:l,memoizedValue:m,next:null},$i===null){if(s===null)throw Error(n(308));$i=l,s.dependencies={lanes:0,firstContext:l},s.flags|=524288}else $i=$i.next=l;return m}var Hk=typeof AbortController!="undefined"?AbortController:function(){var s=[],l=this.signal={aborted:!1,addEventListener:function(m,_){s.push(_)}};this.abort=function(){l.aborted=!0,s.forEach(function(m){return m()})}},Vk=e.unstable_scheduleCallback,Wk=e.unstable_NormalPriority,kn={$$typeof:B,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Am(){return{controller:new Hk,data:new Map,refCount:0}}function h0(s){s.refCount--,s.refCount===0&&Vk(Wk,function(){s.controller.abort()})}var f0=null,Om=0,qc=0,Kc=null;function Gk(s,l){if(f0===null){var m=f0=[];Om=0,qc=Dg(),Kc={status:"pending",value:void 0,then:function(_){m.push(_)}}}return Om++,l.then(g1,g1),l}function g1(){if(--Om===0&&f0!==null){Kc!==null&&(Kc.status="fulfilled");var s=f0;f0=null,qc=0,Kc=null;for(var l=0;l<s.length;l++)(0,s[l])()}}function $k(s,l){var m=[],_={status:"pending",value:null,reason:null,then:function(T){m.push(T)}};return s.then(function(){_.status="fulfilled",_.value=l;for(var T=0;T<m.length;T++)(0,m[T])(l)},function(T){for(_.status="rejected",_.reason=T,T=0;T<m.length;T++)(0,m[T])(void 0)}),_}var x1=me.S;me.S=function(s,l){Qy=it(),typeof l=="object"&&l!==null&&typeof l.then=="function"&&Gk(s,l),x1!==null&&x1(s,l)};var dc=J(null);function Rm(){var s=dc.current;return s!==null?s:Va.pooledCache}function Xu(s,l){l===null?ie(dc,dc.current):ie(dc,l.pool)}function p1(){var s=Rm();return s===null?null:{parent:kn._currentValue,pool:s}}var Jc=Error(n(460)),Mm=Error(n(474)),Yu=Error(n(542)),Zu={then:function(){}};function y1(s){return s=s.status,s==="fulfilled"||s==="rejected"}function b1(s,l,m){switch(m=s[m],m===void 0?s.push(l):m!==l&&(l.then(On,On),l=m),l.status){case"fulfilled":return l.value;case"rejected":throw s=l.reason,_1(s),s;default:if(typeof l.status=="string")l.then(On,On);else{if(s=Va,s!==null&&100<s.shellSuspendCounter)throw Error(n(482));s=l,s.status="pending",s.then(function(_){if(l.status==="pending"){var T=l;T.status="fulfilled",T.value=_}},function(_){if(l.status==="pending"){var T=l;T.status="rejected",T.reason=_}})}switch(l.status){case"fulfilled":return l.value;case"rejected":throw s=l.reason,_1(s),s}throw hc=l,Jc}}function uc(s){try{var l=s._init;return l(s._payload)}catch(m){throw m!==null&&typeof m=="object"&&typeof m.then=="function"?(hc=m,Jc):m}}var hc=null;function v1(){if(hc===null)throw Error(n(459));var s=hc;return hc=null,s}function _1(s){if(s===Jc||s===Yu)throw Error(n(483))}var Qc=null,m0=0;function qu(s){var l=m0;return m0+=1,Qc===null&&(Qc=[]),b1(Qc,s,l)}function g0(s,l){l=l.props.ref,s.ref=l!==void 0?l:null}function Ku(s,l){throw l.$$typeof===C?Error(n(525)):(s=Object.prototype.toString.call(l),Error(n(31,s==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":s)))}function w1(s){function l(Xe,He){if(s){var st=Xe.deletions;st===null?(Xe.deletions=[He],Xe.flags|=16):st.push(He)}}function m(Xe,He){if(!s)return null;for(;He!==null;)l(Xe,He),He=He.sibling;return null}function _(Xe){for(var He=new Map;Xe!==null;)Xe.key!==null?He.set(Xe.key,Xe):He.set(Xe.index,Xe),Xe=Xe.sibling;return He}function T(Xe,He){return Xe=Si(Xe,He),Xe.index=0,Xe.sibling=null,Xe}function M(Xe,He,st){return Xe.index=st,s?(st=Xe.alternate,st!==null?(st=st.index,st<He?(Xe.flags|=67108866,He):st):(Xe.flags|=67108866,He)):(Xe.flags|=1048576,He)}function q(Xe){return s&&Xe.alternate===null&&(Xe.flags|=67108866),Xe}function pe(Xe,He,st,Tt){return He===null||He.tag!==6?(He=Xc(st,Xe.mode,Tt),He.return=Xe,He):(He=T(He,st),He.return=Xe,He)}function Ie(Xe,He,st,Tt){var Mr=st.type;return Mr===A?Et(Xe,He,st.props.children,Tt,st.key):He!==null&&(He.elementType===Mr||typeof Mr=="object"&&Mr!==null&&Mr.$$typeof===le&&uc(Mr)===He.type)?(He=T(He,st.props),g0(He,st),He.return=Xe,He):(He=ic(st.type,st.key,st.props,null,Xe.mode,Tt),g0(He,st),He.return=Xe,He)}function ot(Xe,He,st,Tt){return He===null||He.tag!==4||He.stateNode.containerInfo!==st.containerInfo||He.stateNode.implementation!==st.implementation?(He=c0(st,Xe.mode,Tt),He.return=Xe,He):(He=T(He,st.children||[]),He.return=Xe,He)}function Et(Xe,He,st,Tt,Mr){return He===null||He.tag!==7?(He=Po(st,Xe.mode,Tt,Mr),He.return=Xe,He):(He=T(He,st),He.return=Xe,He)}function Mt(Xe,He,st){if(typeof He=="string"&&He!==""||typeof He=="number"||typeof He=="bigint")return He=Xc(""+He,Xe.mode,st),He.return=Xe,He;if(typeof He=="object"&&He!==null){switch(He.$$typeof){case O:return st=ic(He.type,He.key,He.props,null,Xe.mode,st),g0(st,He),st.return=Xe,st;case D:return He=c0(He,Xe.mode,st),He.return=Xe,He;case le:return He=uc(He),Mt(Xe,He,st)}if(ae(He)||se(He))return He=Po(He,Xe.mode,st,null),He.return=Xe,He;if(typeof He.then=="function")return Mt(Xe,qu(He),st);if(He.$$typeof===B)return Mt(Xe,$u(Xe,He),st);Ku(Xe,He)}return null}function dt(Xe,He,st,Tt){var Mr=He!==null?He.key:null;if(typeof st=="string"&&st!==""||typeof st=="number"||typeof st=="bigint")return Mr!==null?null:pe(Xe,He,""+st,Tt);if(typeof st=="object"&&st!==null){switch(st.$$typeof){case O:return st.key===Mr?Ie(Xe,He,st,Tt):null;case D:return st.key===Mr?ot(Xe,He,st,Tt):null;case le:return st=uc(st),dt(Xe,He,st,Tt)}if(ae(st)||se(st))return Mr!==null?null:Et(Xe,He,st,Tt,null);if(typeof st.then=="function")return dt(Xe,He,qu(st),Tt);if(st.$$typeof===B)return dt(Xe,He,$u(Xe,st),Tt);Ku(Xe,st)}return null}function xt(Xe,He,st,Tt,Mr){if(typeof Tt=="string"&&Tt!==""||typeof Tt=="number"||typeof Tt=="bigint")return Xe=Xe.get(st)||null,pe(He,Xe,""+Tt,Mr);if(typeof Tt=="object"&&Tt!==null){switch(Tt.$$typeof){case O:return Xe=Xe.get(Tt.key===null?st:Tt.key)||null,Ie(He,Xe,Tt,Mr);case D:return Xe=Xe.get(Tt.key===null?st:Tt.key)||null,ot(He,Xe,Tt,Mr);case le:return Tt=uc(Tt),xt(Xe,He,st,Tt,Mr)}if(ae(Tt)||se(Tt))return Xe=Xe.get(st)||null,Et(He,Xe,Tt,Mr,null);if(typeof Tt.then=="function")return xt(Xe,He,st,qu(Tt),Mr);if(Tt.$$typeof===B)return xt(Xe,He,st,$u(He,Tt),Mr);Ku(He,Tt)}return null}function br(Xe,He,st,Tt){for(var Mr=null,ya=null,_r=He,Yr=He=0,ia=null;_r!==null&&Yr<st.length;Yr++){_r.index>Yr?(ia=_r,_r=null):ia=_r.sibling;var ba=dt(Xe,_r,st[Yr],Tt);if(ba===null){_r===null&&(_r=ia);break}s&&_r&&ba.alternate===null&&l(Xe,_r),He=M(ba,He,Yr),ya===null?Mr=ba:ya.sibling=ba,ya=ba,_r=ia}if(Yr===st.length)return m(Xe,_r),ra&&Cr(Xe,Yr),Mr;if(_r===null){for(;Yr<st.length;Yr++)_r=Mt(Xe,st[Yr],Tt),_r!==null&&(He=M(_r,He,Yr),ya===null?Mr=_r:ya.sibling=_r,ya=_r);return ra&&Cr(Xe,Yr),Mr}for(_r=_(_r);Yr<st.length;Yr++)ia=xt(_r,Xe,Yr,st[Yr],Tt),ia!==null&&(s&&ia.alternate!==null&&_r.delete(ia.key===null?Yr:ia.key),He=M(ia,He,Yr),ya===null?Mr=ia:ya.sibling=ia,ya=ia);return s&&_r.forEach(function(Fl){return l(Xe,Fl)}),ra&&Cr(Xe,Yr),Mr}function Pr(Xe,He,st,Tt){if(st==null)throw Error(n(151));for(var Mr=null,ya=null,_r=He,Yr=He=0,ia=null,ba=st.next();_r!==null&&!ba.done;Yr++,ba=st.next()){_r.index>Yr?(ia=_r,_r=null):ia=_r.sibling;var Fl=dt(Xe,_r,ba.value,Tt);if(Fl===null){_r===null&&(_r=ia);break}s&&_r&&Fl.alternate===null&&l(Xe,_r),He=M(Fl,He,Yr),ya===null?Mr=Fl:ya.sibling=Fl,ya=Fl,_r=ia}if(ba.done)return m(Xe,_r),ra&&Cr(Xe,Yr),Mr;if(_r===null){for(;!ba.done;Yr++,ba=st.next())ba=Mt(Xe,ba.value,Tt),ba!==null&&(He=M(ba,He,Yr),ya===null?Mr=ba:ya.sibling=ba,ya=ba);return ra&&Cr(Xe,Yr),Mr}for(_r=_(_r);!ba.done;Yr++,ba=st.next())ba=xt(_r,Xe,Yr,ba.value,Tt),ba!==null&&(s&&ba.alternate!==null&&_r.delete(ba.key===null?Yr:ba.key),He=M(ba,He,Yr),ya===null?Mr=ba:ya.sibling=ba,ya=ba);return s&&_r.forEach(function(a6){return l(Xe,a6)}),ra&&Cr(Xe,Yr),Mr}function Pa(Xe,He,st,Tt){if(typeof st=="object"&&st!==null&&st.type===A&&st.key===null&&(st=st.props.children),typeof st=="object"&&st!==null){switch(st.$$typeof){case O:e:{for(var Mr=st.key;He!==null;){if(He.key===Mr){if(Mr=st.type,Mr===A){if(He.tag===7){m(Xe,He.sibling),Tt=T(He,st.props.children),Tt.return=Xe,Xe=Tt;break e}}else if(He.elementType===Mr||typeof Mr=="object"&&Mr!==null&&Mr.$$typeof===le&&uc(Mr)===He.type){m(Xe,He.sibling),Tt=T(He,st.props),g0(Tt,st),Tt.return=Xe,Xe=Tt;break e}m(Xe,He);break}else l(Xe,He);He=He.sibling}st.type===A?(Tt=Po(st.props.children,Xe.mode,Tt,st.key),Tt.return=Xe,Xe=Tt):(Tt=ic(st.type,st.key,st.props,null,Xe.mode,Tt),g0(Tt,st),Tt.return=Xe,Xe=Tt)}return q(Xe);case D:e:{for(Mr=st.key;He!==null;){if(He.key===Mr)if(He.tag===4&&He.stateNode.containerInfo===st.containerInfo&&He.stateNode.implementation===st.implementation){m(Xe,He.sibling),Tt=T(He,st.children||[]),Tt.return=Xe,Xe=Tt;break e}else{m(Xe,He);break}else l(Xe,He);He=He.sibling}Tt=c0(st,Xe.mode,Tt),Tt.return=Xe,Xe=Tt}return q(Xe);case le:return st=uc(st),Pa(Xe,He,st,Tt)}if(ae(st))return br(Xe,He,st,Tt);if(se(st)){if(Mr=se(st),typeof Mr!="function")throw Error(n(150));return st=Mr.call(st),Pr(Xe,He,st,Tt)}if(typeof st.then=="function")return Pa(Xe,He,qu(st),Tt);if(st.$$typeof===B)return Pa(Xe,He,$u(Xe,st),Tt);Ku(Xe,st)}return typeof st=="string"&&st!==""||typeof st=="number"||typeof st=="bigint"?(st=""+st,He!==null&&He.tag===6?(m(Xe,He.sibling),Tt=T(He,st),Tt.return=Xe,Xe=Tt):(m(Xe,He),Tt=Xc(st,Xe.mode,Tt),Tt.return=Xe,Xe=Tt),q(Xe)):m(Xe,He)}return function(Xe,He,st,Tt){try{m0=0;var Mr=Pa(Xe,He,st,Tt);return Qc=null,Mr}catch(_r){if(_r===Jc||_r===Yu)throw _r;var ya=gs(29,_r,null,Xe.mode);return ya.lanes=Tt,ya.return=Xe,ya}finally{}}}var fc=w1(!0),k1=w1(!1),_l=!1;function Dm(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Lm(s,l){s=s.updateQueue,l.updateQueue===s&&(l.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function wl(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function kl(s,l,m){var _=s.updateQueue;if(_===null)return null;if(_=_.shared,(ka&2)!==0){var T=_.pending;return T===null?l.next=l:(l.next=T.next,T.next=l),_.pending=l,l=sc(s),bl(s,null,m),l}return uo(s,_,l,m),sc(s)}function x0(s,l,m){if(l=l.updateQueue,l!==null&&(l=l.shared,(m&4194048)!==0)){var _=l.lanes;_&=s.pendingLanes,m|=_,l.lanes=m,Qt(s,m)}}function Im(s,l){var m=s.updateQueue,_=s.alternate;if(_!==null&&(_=_.updateQueue,m===_)){var T=null,M=null;if(m=m.firstBaseUpdate,m!==null){do{var q={lane:m.lane,tag:m.tag,payload:m.payload,callback:null,next:null};M===null?T=M=q:M=M.next=q,m=m.next}while(m!==null);M===null?T=M=l:M=M.next=l}else T=M=l;m={baseState:_.baseState,firstBaseUpdate:T,lastBaseUpdate:M,shared:_.shared,callbacks:_.callbacks},s.updateQueue=m;return}s=m.lastBaseUpdate,s===null?m.firstBaseUpdate=l:s.next=l,m.lastBaseUpdate=l}var Pm=!1;function p0(){if(Pm){var s=Kc;if(s!==null)throw s}}function y0(s,l,m,_){Pm=!1;var T=s.updateQueue;_l=!1;var M=T.firstBaseUpdate,q=T.lastBaseUpdate,pe=T.shared.pending;if(pe!==null){T.shared.pending=null;var Ie=pe,ot=Ie.next;Ie.next=null,q===null?M=ot:q.next=ot,q=Ie;var Et=s.alternate;Et!==null&&(Et=Et.updateQueue,pe=Et.lastBaseUpdate,pe!==q&&(pe===null?Et.firstBaseUpdate=ot:pe.next=ot,Et.lastBaseUpdate=Ie))}if(M!==null){var Mt=T.baseState;q=0,Et=ot=Ie=null,pe=M;do{var dt=pe.lane&-536870913,xt=dt!==pe.lane;if(xt?(sa&dt)===dt:(_&dt)===dt){dt!==0&&dt===qc&&(Pm=!0),Et!==null&&(Et=Et.next={lane:0,tag:pe.tag,payload:pe.payload,callback:null,next:null});e:{var br=s,Pr=pe;dt=l;var Pa=m;switch(Pr.tag){case 1:if(br=Pr.payload,typeof br=="function"){Mt=br.call(Pa,Mt,dt);break e}Mt=br;break e;case 3:br.flags=br.flags&-65537|128;case 0:if(br=Pr.payload,dt=typeof br=="function"?br.call(Pa,Mt,dt):br,dt==null)break e;Mt=N({},Mt,dt);break e;case 2:_l=!0}}dt=pe.callback,dt!==null&&(s.flags|=64,xt&&(s.flags|=8192),xt=T.callbacks,xt===null?T.callbacks=[dt]:xt.push(dt))}else xt={lane:dt,tag:pe.tag,payload:pe.payload,callback:pe.callback,next:null},Et===null?(ot=Et=xt,Ie=Mt):Et=Et.next=xt,q|=dt;if(pe=pe.next,pe===null){if(pe=T.shared.pending,pe===null)break;xt=pe,pe=xt.next,xt.next=null,T.lastBaseUpdate=xt,T.shared.pending=null}}while(!0);Et===null&&(Ie=Mt),T.baseState=Ie,T.firstBaseUpdate=ot,T.lastBaseUpdate=Et,M===null&&(T.shared.lanes=0),jl|=q,s.lanes=q,s.memoizedState=Mt}}function N1(s,l){if(typeof s!="function")throw Error(n(191,s));s.call(l)}function S1(s,l){var m=s.callbacks;if(m!==null)for(s.callbacks=null,s=0;s<m.length;s++)N1(m[s],l)}var ed=J(null),Ju=J(0);function C1(s,l){s=Yo,ie(Ju,s),ie(ed,l),Yo=s|l.baseLanes}function Fm(){ie(Ju,Yo),ie(ed,ed.current)}function Bm(){Yo=Ju.current,G(ed),G(Ju)}var ii=J(null),Ci=null;function Nl(s){var l=s.alternate;ie(vn,vn.current&1),ie(ii,s),Ci===null&&(l===null||ed.current!==null||l.memoizedState!==null)&&(Ci=s)}function Um(s){ie(vn,vn.current),ie(ii,s),Ci===null&&(Ci=s)}function E1(s){s.tag===22?(ie(vn,vn.current),ie(ii,s),Ci===null&&(Ci=s)):Sl()}function Sl(){ie(vn,vn.current),ie(ii,ii.current)}function oi(s){G(ii),Ci===s&&(Ci=null),G(vn)}var vn=J(0);function Qu(s){for(var l=s;l!==null;){if(l.tag===13){var m=l.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||$g(m)||Xg(m)))return l}else if(l.tag===19&&(l.memoizedProps.revealOrder==="forwards"||l.memoizedProps.revealOrder==="backwards"||l.memoizedProps.revealOrder==="unstable_legacy-backwards"||l.memoizedProps.revealOrder==="together")){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===s)break;for(;l.sibling===null;){if(l.return===null||l.return===s)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var Uo=0,Gr=null,La=null,Nn=null,eh=!1,td=!1,mc=!1,th=0,b0=0,rd=null,Xk=0;function dn(){throw Error(n(321))}function zm(s,l){if(l===null)return!1;for(var m=0;m<l.length&&m<s.length;m++)if(!w(s[m],l[m]))return!1;return!0}function Hm(s,l,m,_,T,M){return Uo=M,Gr=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,me.H=s===null||s.memoizedState===null?dy:ag,mc=!1,M=m(_,T),mc=!1,td&&(M=T1(l,m,_,T)),j1(s),M}function j1(s){me.H=w0;var l=La!==null&&La.next!==null;if(Uo=0,Nn=La=Gr=null,eh=!1,b0=0,rd=null,l)throw Error(n(300));s===null||Sn||(s=s.dependencies,s!==null&&Gu(s)&&(Sn=!0))}function T1(s,l,m,_){Gr=s;var T=0;do{if(td&&(rd=null),b0=0,td=!1,25<=T)throw Error(n(301));if(T+=1,Nn=La=null,s.updateQueue!=null){var M=s.updateQueue;M.lastEffect=null,M.events=null,M.stores=null,M.memoCache!=null&&(M.memoCache.index=0)}me.H=uy,M=l(m,_)}while(td);return M}function Yk(){var s=me.H,l=s.useState()[0];return l=typeof l.then=="function"?v0(l):l,s=s.useState()[0],(La!==null?La.memoizedState:null)!==s&&(Gr.flags|=1024),l}function Vm(){var s=th!==0;return th=0,s}function Wm(s,l,m){l.updateQueue=s.updateQueue,l.flags&=-2053,s.lanes&=~m}function Gm(s){if(eh){for(s=s.memoizedState;s!==null;){var l=s.queue;l!==null&&(l.pending=null),s=s.next}eh=!1}Uo=0,Nn=La=Gr=null,td=!1,b0=th=0,rd=null}function Es(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Nn===null?Gr.memoizedState=Nn=s:Nn=Nn.next=s,Nn}function _n(){if(La===null){var s=Gr.alternate;s=s!==null?s.memoizedState:null}else s=La.next;var l=Nn===null?Gr.memoizedState:Nn.next;if(l!==null)Nn=l,La=s;else{if(s===null)throw Gr.alternate===null?Error(n(467)):Error(n(310));La=s,s={memoizedState:La.memoizedState,baseState:La.baseState,baseQueue:La.baseQueue,queue:La.queue,next:null},Nn===null?Gr.memoizedState=Nn=s:Nn=Nn.next=s}return Nn}function rh(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function v0(s){var l=b0;return b0+=1,rd===null&&(rd=[]),s=b1(rd,s,l),l=Gr,(Nn===null?l.memoizedState:Nn.next)===null&&(l=l.alternate,me.H=l===null||l.memoizedState===null?dy:ag),s}function ah(s){if(s!==null&&typeof s=="object"){if(typeof s.then=="function")return v0(s);if(s.$$typeof===B)return ts(s)}throw Error(n(438,String(s)))}function $m(s){var l=null,m=Gr.updateQueue;if(m!==null&&(l=m.memoCache),l==null){var _=Gr.alternate;_!==null&&(_=_.updateQueue,_!==null&&(_=_.memoCache,_!=null&&(l={data:_.data.map(function(T){return T.slice()}),index:0})))}if(l==null&&(l={data:[],index:0}),m===null&&(m=rh(),Gr.updateQueue=m),m.memoCache=l,m=l.data[l.index],m===void 0)for(m=l.data[l.index]=Array(s),_=0;_<s;_++)m[_]=Ne;return l.index++,m}function zo(s,l){return typeof l=="function"?l(s):l}function nh(s){var l=_n();return Xm(l,La,s)}function Xm(s,l,m){var _=s.queue;if(_===null)throw Error(n(311));_.lastRenderedReducer=m;var T=s.baseQueue,M=_.pending;if(M!==null){if(T!==null){var q=T.next;T.next=M.next,M.next=q}l.baseQueue=T=M,_.pending=null}if(M=s.baseState,T===null)s.memoizedState=M;else{l=T.next;var pe=q=null,Ie=null,ot=l,Et=!1;do{var Mt=ot.lane&-536870913;if(Mt!==ot.lane?(sa&Mt)===Mt:(Uo&Mt)===Mt){var dt=ot.revertLane;if(dt===0)Ie!==null&&(Ie=Ie.next={lane:0,revertLane:0,gesture:null,action:ot.action,hasEagerState:ot.hasEagerState,eagerState:ot.eagerState,next:null}),Mt===qc&&(Et=!0);else if((Uo&dt)===dt){ot=ot.next,dt===qc&&(Et=!0);continue}else Mt={lane:0,revertLane:ot.revertLane,gesture:null,action:ot.action,hasEagerState:ot.hasEagerState,eagerState:ot.eagerState,next:null},Ie===null?(pe=Ie=Mt,q=M):Ie=Ie.next=Mt,Gr.lanes|=dt,jl|=dt;Mt=ot.action,mc&&m(M,Mt),M=ot.hasEagerState?ot.eagerState:m(M,Mt)}else dt={lane:Mt,revertLane:ot.revertLane,gesture:ot.gesture,action:ot.action,hasEagerState:ot.hasEagerState,eagerState:ot.eagerState,next:null},Ie===null?(pe=Ie=dt,q=M):Ie=Ie.next=dt,Gr.lanes|=Mt,jl|=Mt;ot=ot.next}while(ot!==null&&ot!==l);if(Ie===null?q=M:Ie.next=pe,!w(M,s.memoizedState)&&(Sn=!0,Et&&(m=Kc,m!==null)))throw m;s.memoizedState=M,s.baseState=q,s.baseQueue=Ie,_.lastRenderedState=M}return T===null&&(_.lanes=0),[s.memoizedState,_.dispatch]}function Ym(s){var l=_n(),m=l.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=s;var _=m.dispatch,T=m.pending,M=l.memoizedState;if(T!==null){m.pending=null;var q=T=T.next;do M=s(M,q.action),q=q.next;while(q!==T);w(M,l.memoizedState)||(Sn=!0),l.memoizedState=M,l.baseQueue===null&&(l.baseState=M),m.lastRenderedState=M}return[M,_]}function A1(s,l,m){var _=Gr,T=_n(),M=ra;if(M){if(m===void 0)throw Error(n(407));m=m()}else m=l();var q=!w((La||T).memoizedState,m);if(q&&(T.memoizedState=m,Sn=!0),T=T.queue,Km(M1.bind(null,_,T,s),[s]),T.getSnapshot!==l||q||Nn!==null&&Nn.memoizedState.tag&1){if(_.flags|=2048,ad(9,{destroy:void 0},R1.bind(null,_,T,m,l),null),Va===null)throw Error(n(349));M||(Uo&127)!==0||O1(_,l,m)}return m}function O1(s,l,m){s.flags|=16384,s={getSnapshot:l,value:m},l=Gr.updateQueue,l===null?(l=rh(),Gr.updateQueue=l,l.stores=[s]):(m=l.stores,m===null?l.stores=[s]:m.push(s))}function R1(s,l,m,_){l.value=m,l.getSnapshot=_,D1(l)&&L1(s)}function M1(s,l,m){return m(function(){D1(l)&&L1(s)})}function D1(s){var l=s.getSnapshot;s=s.value;try{var m=l();return!w(s,m)}catch(_){return!0}}function L1(s){var l=Ni(s,2);l!==null&&Ws(l,s,2)}function Zm(s){var l=Es();if(typeof s=="function"){var m=s;if(s=m(),mc){At(!0);try{m()}finally{At(!1)}}}return l.memoizedState=l.baseState=s,l.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:zo,lastRenderedState:s},l}function I1(s,l,m,_){return s.baseState=m,Xm(s,La,typeof _=="function"?_:zo)}function Zk(s,l,m,_,T){if(oh(s))throw Error(n(485));if(s=l.action,s!==null){var M={payload:T,action:s,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(q){M.listeners.push(q)}};me.T!==null?m(!0):M.isTransition=!1,_(M),m=l.pending,m===null?(M.next=l.pending=M,P1(l,M)):(M.next=m.next,l.pending=m.next=M)}}function P1(s,l){var m=l.action,_=l.payload,T=s.state;if(l.isTransition){var M=me.T,q={};me.T=q;try{var pe=m(T,_),Ie=me.S;Ie!==null&&Ie(q,pe),F1(s,l,pe)}catch(ot){qm(s,l,ot)}finally{M!==null&&q.types!==null&&(M.types=q.types),me.T=M}}else try{M=m(T,_),F1(s,l,M)}catch(ot){qm(s,l,ot)}}function F1(s,l,m){m!==null&&typeof m=="object"&&typeof m.then=="function"?m.then(function(_){B1(s,l,_)},function(_){return qm(s,l,_)}):B1(s,l,m)}function B1(s,l,m){l.status="fulfilled",l.value=m,U1(l),s.state=m,l=s.pending,l!==null&&(m=l.next,m===l?s.pending=null:(m=m.next,l.next=m,P1(s,m)))}function qm(s,l,m){var _=s.pending;if(s.pending=null,_!==null){_=_.next;do l.status="rejected",l.reason=m,U1(l),l=l.next;while(l!==_)}s.action=null}function U1(s){s=s.listeners;for(var l=0;l<s.length;l++)(0,s[l])()}function z1(s,l){return l}function H1(s,l){if(ra){var m=Va.formState;if(m!==null){e:{var _=Gr;if(ra){if(pa){t:{for(var T=pa,M=Bs;T.nodeType!==8;){if(!M){T=null;break t}if(T=Ei(T.nextSibling),T===null){T=null;break t}}M=T.data,T=M==="F!"||M==="F"?T:null}if(T){pa=Ei(T.nextSibling),_=T.data==="F!";break e}}fo(_)}_=!1}_&&(l=m[0])}}return m=Es(),m.memoizedState=m.baseState=l,_={pending:null,lanes:0,dispatch:null,lastRenderedReducer:z1,lastRenderedState:l},m.queue=_,m=oy.bind(null,Gr,_),_.dispatch=m,_=Zm(!1),M=rg.bind(null,Gr,!1,_.queue),_=Es(),T={state:l,dispatch:null,action:s,pending:null},_.queue=T,m=Zk.bind(null,Gr,T,M,m),T.dispatch=m,_.memoizedState=s,[l,m,!1]}function V1(s){var l=_n();return W1(l,La,s)}function W1(s,l,m){if(l=Xm(s,l,z1)[0],s=nh(zo)[0],typeof l=="object"&&l!==null&&typeof l.then=="function")try{var _=v0(l)}catch(q){throw q===Jc?Yu:q}else _=l;l=_n();var T=l.queue,M=T.dispatch;return m!==l.memoizedState&&(Gr.flags|=2048,ad(9,{destroy:void 0},qk.bind(null,T,m),null)),[_,M,s]}function qk(s,l){s.action=l}function G1(s){var l=_n(),m=La;if(m!==null)return W1(l,m,s);_n(),l=l.memoizedState,m=_n();var _=m.queue.dispatch;return m.memoizedState=s,[l,_,!1]}function ad(s,l,m,_){return s={tag:s,create:m,deps:_,inst:l,next:null},l=Gr.updateQueue,l===null&&(l=rh(),Gr.updateQueue=l),m=l.lastEffect,m===null?l.lastEffect=s.next=s:(_=m.next,m.next=s,s.next=_,l.lastEffect=s),s}function $1(){return _n().memoizedState}function sh(s,l,m,_){var T=Es();Gr.flags|=s,T.memoizedState=ad(1|l,{destroy:void 0},m,_===void 0?null:_)}function ih(s,l,m,_){var T=_n();_=_===void 0?null:_;var M=T.memoizedState.inst;La!==null&&_!==null&&zm(_,La.memoizedState.deps)?T.memoizedState=ad(l,M,m,_):(Gr.flags|=s,T.memoizedState=ad(1|l,M,m,_))}function X1(s,l){sh(8390656,8,s,l)}function Km(s,l){ih(2048,8,s,l)}function Kk(s){Gr.flags|=4;var l=Gr.updateQueue;if(l===null)l=rh(),Gr.updateQueue=l,l.events=[s];else{var m=l.events;m===null?l.events=[s]:m.push(s)}}function Y1(s){var l=_n().memoizedState;return Kk({ref:l,nextImpl:s}),function(){if((ka&2)!==0)throw Error(n(440));return l.impl.apply(void 0,arguments)}}function Z1(s,l){return ih(4,2,s,l)}function q1(s,l){return ih(4,4,s,l)}function K1(s,l){if(typeof l=="function"){s=s();var m=l(s);return function(){typeof m=="function"?m():l(null)}}if(l!=null)return s=s(),l.current=s,function(){l.current=null}}function J1(s,l,m){m=m!=null?m.concat([s]):null,ih(4,4,K1.bind(null,l,s),m)}function Jm(){}function Q1(s,l){var m=_n();l=l===void 0?null:l;var _=m.memoizedState;return l!==null&&zm(l,_[1])?_[0]:(m.memoizedState=[s,l],s)}function ey(s,l){var m=_n();l=l===void 0?null:l;var _=m.memoizedState;if(l!==null&&zm(l,_[1]))return _[0];if(_=s(),mc){At(!0);try{s()}finally{At(!1)}}return m.memoizedState=[_,l],_}function Qm(s,l,m){return m===void 0||(Uo&1073741824)!==0&&(sa&261930)===0?s.memoizedState=l:(s.memoizedState=m,s=tb(),Gr.lanes|=s,jl|=s,m)}function ty(s,l,m,_){return w(m,l)?m:ed.current!==null?(s=Qm(s,m,_),w(s,l)||(Sn=!0),s):(Uo&42)===0||(Uo&1073741824)!==0&&(sa&261930)===0?(Sn=!0,s.memoizedState=m):(s=tb(),Gr.lanes|=s,jl|=s,l)}function ry(s,l,m,_,T){var M=K.p;K.p=M!==0&&8>M?M:8;var q=me.T,pe={};me.T=pe,rg(s,!1,l,m);try{var Ie=T(),ot=me.S;if(ot!==null&&ot(pe,Ie),Ie!==null&&typeof Ie=="object"&&typeof Ie.then=="function"){var Et=$k(Ie,_);_0(s,l,Et,di(s))}else _0(s,l,_,di(s))}catch(Mt){_0(s,l,{then:function(){},status:"rejected",reason:Mt},di())}finally{K.p=M,q!==null&&pe.types!==null&&(q.types=pe.types),me.T=q}}function Jk(){}function eg(s,l,m,_){if(s.tag!==5)throw Error(n(476));var T=ay(s).queue;ry(s,T,l,fe,m===null?Jk:function(){return ny(s),m(_)})}function ay(s){var l=s.memoizedState;if(l!==null)return l;l={memoizedState:fe,baseState:fe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:zo,lastRenderedState:fe},next:null};var m={};return l.next={memoizedState:m,baseState:m,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:zo,lastRenderedState:m},next:null},s.memoizedState=l,s=s.alternate,s!==null&&(s.memoizedState=l),l}function ny(s){var l=ay(s);l.next===null&&(l=s.alternate.memoizedState),_0(s,l.next.queue,{},di())}function tg(){return ts(F0)}function sy(){return _n().memoizedState}function iy(){return _n().memoizedState}function Qk(s){for(var l=s.return;l!==null;){switch(l.tag){case 24:case 3:var m=di();s=wl(m);var _=kl(l,s,m);_!==null&&(Ws(_,l,m),x0(_,l,m)),l={cache:Am()},s.payload=l;return}l=l.return}}function eN(s,l,m){var _=di();m={lane:_,revertLane:0,gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null},oh(s)?ly(l,m):(m=i0(s,l,m,_),m!==null&&(Ws(m,s,_),cy(m,l,_)))}function oy(s,l,m){var _=di();_0(s,l,m,_)}function _0(s,l,m,_){var T={lane:_,revertLane:0,gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null};if(oh(s))ly(l,T);else{var M=s.alternate;if(s.lanes===0&&(M===null||M.lanes===0)&&(M=l.lastRenderedReducer,M!==null))try{var q=l.lastRenderedState,pe=M(q,m);if(T.hasEagerState=!0,T.eagerState=pe,w(pe,q))return uo(s,l,T,0),Va===null&&nc(),!1}catch(Ie){}finally{}if(m=i0(s,l,T,_),m!==null)return Ws(m,s,_),cy(m,l,_),!0}return!1}function rg(s,l,m,_){if(_={lane:2,revertLane:Dg(),gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},oh(s)){if(l)throw Error(n(479))}else l=i0(s,m,_,2),l!==null&&Ws(l,s,2)}function oh(s){var l=s.alternate;return s===Gr||l!==null&&l===Gr}function ly(s,l){td=eh=!0;var m=s.pending;m===null?l.next=l:(l.next=m.next,m.next=l),s.pending=l}function cy(s,l,m){if((m&4194048)!==0){var _=l.lanes;_&=s.pendingLanes,m|=_,l.lanes=m,Qt(s,m)}}var w0={readContext:ts,use:ah,useCallback:dn,useContext:dn,useEffect:dn,useImperativeHandle:dn,useLayoutEffect:dn,useInsertionEffect:dn,useMemo:dn,useReducer:dn,useRef:dn,useState:dn,useDebugValue:dn,useDeferredValue:dn,useTransition:dn,useSyncExternalStore:dn,useId:dn,useHostTransitionStatus:dn,useFormState:dn,useActionState:dn,useOptimistic:dn,useMemoCache:dn,useCacheRefresh:dn};w0.useEffectEvent=dn;var dy={readContext:ts,use:ah,useCallback:function(s,l){return Es().memoizedState=[s,l===void 0?null:l],s},useContext:ts,useEffect:X1,useImperativeHandle:function(s,l,m){m=m!=null?m.concat([s]):null,sh(4194308,4,K1.bind(null,l,s),m)},useLayoutEffect:function(s,l){return sh(4194308,4,s,l)},useInsertionEffect:function(s,l){sh(4,2,s,l)},useMemo:function(s,l){var m=Es();l=l===void 0?null:l;var _=s();if(mc){At(!0);try{s()}finally{At(!1)}}return m.memoizedState=[_,l],_},useReducer:function(s,l,m){var _=Es();if(m!==void 0){var T=m(l);if(mc){At(!0);try{m(l)}finally{At(!1)}}}else T=l;return _.memoizedState=_.baseState=T,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:T},_.queue=s,s=s.dispatch=eN.bind(null,Gr,s),[_.memoizedState,s]},useRef:function(s){var l=Es();return s={current:s},l.memoizedState=s},useState:function(s){s=Zm(s);var l=s.queue,m=oy.bind(null,Gr,l);return l.dispatch=m,[s.memoizedState,m]},useDebugValue:Jm,useDeferredValue:function(s,l){var m=Es();return Qm(m,s,l)},useTransition:function(){var s=Zm(!1);return s=ry.bind(null,Gr,s.queue,!0,!1),Es().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,l,m){var _=Gr,T=Es();if(ra){if(m===void 0)throw Error(n(407));m=m()}else{if(m=l(),Va===null)throw Error(n(349));(sa&127)!==0||O1(_,l,m)}T.memoizedState=m;var M={value:m,getSnapshot:l};return T.queue=M,X1(M1.bind(null,_,M,s),[s]),_.flags|=2048,ad(9,{destroy:void 0},R1.bind(null,_,M,m,l),null),m},useId:function(){var s=Es(),l=Va.identifierPrefix;if(ra){var m=lr,_=Rt;m=(_&~(1<<32-lt(_)-1)).toString(32)+m,l="_"+l+"R_"+m,m=th++,0<m&&(l+="H"+m.toString(32)),l+="_"}else m=Xk++,l="_"+l+"r_"+m.toString(32)+"_";return s.memoizedState=l},useHostTransitionStatus:tg,useFormState:H1,useActionState:H1,useOptimistic:function(s){var l=Es();l.memoizedState=l.baseState=s;var m={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return l.queue=m,l=rg.bind(null,Gr,!0,m),m.dispatch=l,[s,l]},useMemoCache:$m,useCacheRefresh:function(){return Es().memoizedState=Qk.bind(null,Gr)},useEffectEvent:function(s){var l=Es(),m={impl:s};return l.memoizedState=m,function(){if((ka&2)!==0)throw Error(n(440));return m.impl.apply(void 0,arguments)}}},ag={readContext:ts,use:ah,useCallback:Q1,useContext:ts,useEffect:Km,useImperativeHandle:J1,useInsertionEffect:Z1,useLayoutEffect:q1,useMemo:ey,useReducer:nh,useRef:$1,useState:function(){return nh(zo)},useDebugValue:Jm,useDeferredValue:function(s,l){var m=_n();return ty(m,La.memoizedState,s,l)},useTransition:function(){var s=nh(zo)[0],l=_n().memoizedState;return[typeof s=="boolean"?s:v0(s),l]},useSyncExternalStore:A1,useId:sy,useHostTransitionStatus:tg,useFormState:V1,useActionState:V1,useOptimistic:function(s,l){var m=_n();return I1(m,La,s,l)},useMemoCache:$m,useCacheRefresh:iy};ag.useEffectEvent=Y1;var uy={readContext:ts,use:ah,useCallback:Q1,useContext:ts,useEffect:Km,useImperativeHandle:J1,useInsertionEffect:Z1,useLayoutEffect:q1,useMemo:ey,useReducer:Ym,useRef:$1,useState:function(){return Ym(zo)},useDebugValue:Jm,useDeferredValue:function(s,l){var m=_n();return La===null?Qm(m,s,l):ty(m,La.memoizedState,s,l)},useTransition:function(){var s=Ym(zo)[0],l=_n().memoizedState;return[typeof s=="boolean"?s:v0(s),l]},useSyncExternalStore:A1,useId:sy,useHostTransitionStatus:tg,useFormState:G1,useActionState:G1,useOptimistic:function(s,l){var m=_n();return La!==null?I1(m,La,s,l):(m.baseState=s,[s,m.queue.dispatch])},useMemoCache:$m,useCacheRefresh:iy};uy.useEffectEvent=Y1;function ng(s,l,m,_){l=s.memoizedState,m=m(_,l),m=m==null?l:N({},l,m),s.memoizedState=m,s.lanes===0&&(s.updateQueue.baseState=m)}var sg={enqueueSetState:function(s,l,m){s=s._reactInternals;var _=di(),T=wl(_);T.payload=l,m!=null&&(T.callback=m),l=kl(s,T,_),l!==null&&(Ws(l,s,_),x0(l,s,_))},enqueueReplaceState:function(s,l,m){s=s._reactInternals;var _=di(),T=wl(_);T.tag=1,T.payload=l,m!=null&&(T.callback=m),l=kl(s,T,_),l!==null&&(Ws(l,s,_),x0(l,s,_))},enqueueForceUpdate:function(s,l){s=s._reactInternals;var m=di(),_=wl(m);_.tag=2,l!=null&&(_.callback=l),l=kl(s,_,m),l!==null&&(Ws(l,s,m),x0(l,s,m))}};function hy(s,l,m,_,T,M,q){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(_,M,q):l.prototype&&l.prototype.isPureReactComponent?!S(m,_)||!S(T,M):!0}function fy(s,l,m,_){s=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(m,_),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(m,_),l.state!==s&&sg.enqueueReplaceState(l,l.state,null)}function gc(s,l){var m=l;if("ref"in l){m={};for(var _ in l)_!=="ref"&&(m[_]=l[_])}if(s=s.defaultProps){m===l&&(m=N({},m));for(var T in s)m[T]===void 0&&(m[T]=s[T])}return m}function my(s){ac(s)}function gy(s){console.error(s)}function xy(s){ac(s)}function lh(s,l){try{var m=s.onUncaughtError;m(l.value,{componentStack:l.stack})}catch(_){setTimeout(function(){throw _})}}function py(s,l,m){try{var _=s.onCaughtError;_(m.value,{componentStack:m.stack,errorBoundary:l.tag===1?l.stateNode:null})}catch(T){setTimeout(function(){throw T})}}function ig(s,l,m){return m=wl(m),m.tag=3,m.payload={element:null},m.callback=function(){lh(s,l)},m}function yy(s){return s=wl(s),s.tag=3,s}function by(s,l,m,_){var T=m.type.getDerivedStateFromError;if(typeof T=="function"){var M=_.value;s.payload=function(){return T(M)},s.callback=function(){py(l,m,_)}}var q=m.stateNode;q!==null&&typeof q.componentDidCatch=="function"&&(s.callback=function(){py(l,m,_),typeof T!="function"&&(Tl===null?Tl=new Set([this]):Tl.add(this));var pe=_.stack;this.componentDidCatch(_.value,{componentStack:pe!==null?pe:""})})}function tN(s,l,m,_,T){if(m.flags|=32768,_!==null&&typeof _=="object"&&typeof _.then=="function"){if(l=m.alternate,l!==null&&Zc(l,m,T,!0),m=ii.current,m!==null){switch(m.tag){case 31:case 13:return Ci===null?vh():m.alternate===null&&un===0&&(un=3),m.flags&=-257,m.flags|=65536,m.lanes=T,_===Zu?m.flags|=16384:(l=m.updateQueue,l===null?m.updateQueue=new Set([_]):l.add(_),Og(s,_,T)),!1;case 22:return m.flags|=65536,_===Zu?m.flags|=16384:(l=m.updateQueue,l===null?(l={transitions:null,markerInstances:null,retryQueue:new Set([_])},m.updateQueue=l):(m=l.retryQueue,m===null?l.retryQueue=new Set([_]):m.add(_)),Og(s,_,T)),!1}throw Error(n(435,m.tag))}return Og(s,_,T),vh(),!1}if(ra)return l=ii.current,l!==null?((l.flags&65536)===0&&(l.flags|=256),l.flags|=65536,l.lanes=T,_!==Yc&&(s=Error(n(422),{cause:_}),oc(v(s,m)))):(_!==Yc&&(l=Error(n(423),{cause:_}),oc(v(l,m))),s=s.current.alternate,s.flags|=65536,T&=-T,s.lanes|=T,_=v(_,m),T=ig(s.stateNode,_,T),Im(s,T),un!==4&&(un=2)),!1;var M=Error(n(520),{cause:_});if(M=v(M,m),A0===null?A0=[M]:A0.push(M),un!==4&&(un=2),l===null)return!0;_=v(_,m),m=l;do{switch(m.tag){case 3:return m.flags|=65536,s=T&-T,m.lanes|=s,s=ig(m.stateNode,_,s),Im(m,s),!1;case 1:if(l=m.type,M=m.stateNode,(m.flags&128)===0&&(typeof l.getDerivedStateFromError=="function"||M!==null&&typeof M.componentDidCatch=="function"&&(Tl===null||!Tl.has(M))))return m.flags|=65536,T&=-T,m.lanes|=T,T=yy(T),by(T,s,m,_),Im(m,T),!1}m=m.return}while(m!==null);return!1}var og=Error(n(461)),Sn=!1;function rs(s,l,m,_){l.child=s===null?k1(l,null,m,_):fc(l,s.child,m,_)}function vy(s,l,m,_,T){m=m.render;var M=l.ref;if("ref"in _){var q={};for(var pe in _)pe!=="ref"&&(q[pe]=_[pe])}else q=_;return cc(l),_=Hm(s,l,m,q,M,T),pe=Vm(),s!==null&&!Sn?(Wm(s,l,T),Ho(s,l,T)):(ra&&pe&&Dn(l),l.flags|=1,rs(s,l,_,T),l.child)}function _y(s,l,m,_,T){if(s===null){var M=m.type;return typeof M=="function"&&!$c(M)&&M.defaultProps===void 0&&m.compare===null?(l.tag=15,l.type=M,wy(s,l,M,_,T)):(s=ic(m.type,null,_,l,l.mode,T),s.ref=l.ref,s.return=l,l.child=s)}if(M=s.child,!gg(s,T)){var q=M.memoizedProps;if(m=m.compare,m=m!==null?m:S,m(q,_)&&s.ref===l.ref)return Ho(s,l,T)}return l.flags|=1,s=Si(M,_),s.ref=l.ref,s.return=l,l.child=s}function wy(s,l,m,_,T){if(s!==null){var M=s.memoizedProps;if(S(M,_)&&s.ref===l.ref)if(Sn=!1,l.pendingProps=_=M,gg(s,T))(s.flags&131072)!==0&&(Sn=!0);else return l.lanes=s.lanes,Ho(s,l,T)}return lg(s,l,m,_,T)}function ky(s,l,m,_){var T=_.children,M=s!==null?s.memoizedState:null;if(s===null&&l.stateNode===null&&(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),_.mode==="hidden"){if((l.flags&128)!==0){if(M=M!==null?M.baseLanes|m:m,s!==null){for(_=l.child=s.child,T=0;_!==null;)T=T|_.lanes|_.childLanes,_=_.sibling;_=T&~M}else _=0,l.child=null;return Ny(s,l,M,m,_)}if((m&536870912)!==0)l.memoizedState={baseLanes:0,cachePool:null},s!==null&&Xu(l,M!==null?M.cachePool:null),M!==null?C1(l,M):Fm(),E1(l);else return _=l.lanes=536870912,Ny(s,l,M!==null?M.baseLanes|m:m,m,_)}else M!==null?(Xu(l,M.cachePool),C1(l,M),Sl(),l.memoizedState=null):(s!==null&&Xu(l,null),Fm(),Sl());return rs(s,l,T,m),l.child}function k0(s,l){return s!==null&&s.tag===22||l.stateNode!==null||(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.sibling}function Ny(s,l,m,_,T){var M=Rm();return M=M===null?null:{parent:kn._currentValue,pool:M},l.memoizedState={baseLanes:m,cachePool:M},s!==null&&Xu(l,null),Fm(),E1(l),s!==null&&Zc(s,l,_,!0),l.childLanes=T,null}function ch(s,l){return l=uh({mode:l.mode,children:l.children},s.mode),l.ref=s.ref,s.child=l,l.return=s,l}function Sy(s,l,m){return fc(l,s.child,null,m),s=ch(l,l.pendingProps),s.flags|=2,oi(l),l.memoizedState=null,s}function rN(s,l,m){var _=l.pendingProps,T=(l.flags&128)!==0;if(l.flags&=-129,s===null){if(ra){if(_.mode==="hidden")return s=ch(l,_),l.lanes=536870912,k0(null,s);if(Um(l),(s=pa)?(s=Pb(s,Bs),s=s!==null&&s.data==="&"?s:null,s!==null&&(l.memoizedState={dehydrated:s,treeContext:ct!==null?{id:Rt,overflow:lr}:null,retryLane:536870912,hydrationErrors:null},m=l0(s),m.return=l,l.child=m,xa=l,pa=null)):s=null,s===null)throw fo(l);return l.lanes=536870912,null}return ch(l,_)}var M=s.memoizedState;if(M!==null){var q=M.dehydrated;if(Um(l),T)if(l.flags&256)l.flags&=-257,l=Sy(s,l,m);else if(l.memoizedState!==null)l.child=s.child,l.flags|=128,l=null;else throw Error(n(558));else if(Sn||Zc(s,l,m,!1),T=(m&s.childLanes)!==0,Sn||T){if(_=Va,_!==null&&(q=wr(_,m),q!==0&&q!==M.retryLane))throw M.retryLane=q,Ni(s,q),Ws(_,s,q),og;vh(),l=Sy(s,l,m)}else s=M.treeContext,pa=Ei(q.nextSibling),xa=l,ra=!0,ho=null,Bs=!1,s!==null&&Cs(l,s),l=ch(l,_),l.flags|=4096;return l}return s=Si(s.child,{mode:_.mode,children:_.children}),s.ref=l.ref,l.child=s,s.return=l,s}function dh(s,l){var m=l.ref;if(m===null)s!==null&&s.ref!==null&&(l.flags|=4194816);else{if(typeof m!="function"&&typeof m!="object")throw Error(n(284));(s===null||s.ref!==m)&&(l.flags|=4194816)}}function lg(s,l,m,_,T){return cc(l),m=Hm(s,l,m,_,void 0,T),_=Vm(),s!==null&&!Sn?(Wm(s,l,T),Ho(s,l,T)):(ra&&_&&Dn(l),l.flags|=1,rs(s,l,m,T),l.child)}function Cy(s,l,m,_,T,M){return cc(l),l.updateQueue=null,m=T1(l,_,m,T),j1(s),_=Vm(),s!==null&&!Sn?(Wm(s,l,M),Ho(s,l,M)):(ra&&_&&Dn(l),l.flags|=1,rs(s,l,m,M),l.child)}function Ey(s,l,m,_,T){if(cc(l),l.stateNode===null){var M=Io,q=m.contextType;typeof q=="object"&&q!==null&&(M=ts(q)),M=new m(_,M),l.memoizedState=M.state!==null&&M.state!==void 0?M.state:null,M.updater=sg,l.stateNode=M,M._reactInternals=l,M=l.stateNode,M.props=_,M.state=l.memoizedState,M.refs={},Dm(l),q=m.contextType,M.context=typeof q=="object"&&q!==null?ts(q):Io,M.state=l.memoizedState,q=m.getDerivedStateFromProps,typeof q=="function"&&(ng(l,m,q,_),M.state=l.memoizedState),typeof m.getDerivedStateFromProps=="function"||typeof M.getSnapshotBeforeUpdate=="function"||typeof M.UNSAFE_componentWillMount!="function"&&typeof M.componentWillMount!="function"||(q=M.state,typeof M.componentWillMount=="function"&&M.componentWillMount(),typeof M.UNSAFE_componentWillMount=="function"&&M.UNSAFE_componentWillMount(),q!==M.state&&sg.enqueueReplaceState(M,M.state,null),y0(l,_,M,T),p0(),M.state=l.memoizedState),typeof M.componentDidMount=="function"&&(l.flags|=4194308),_=!0}else if(s===null){M=l.stateNode;var pe=l.memoizedProps,Ie=gc(m,pe);M.props=Ie;var ot=M.context,Et=m.contextType;q=Io,typeof Et=="object"&&Et!==null&&(q=ts(Et));var Mt=m.getDerivedStateFromProps;Et=typeof Mt=="function"||typeof M.getSnapshotBeforeUpdate=="function",pe=l.pendingProps!==pe,Et||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(pe||ot!==q)&&fy(l,M,_,q),_l=!1;var dt=l.memoizedState;M.state=dt,y0(l,_,M,T),p0(),ot=l.memoizedState,pe||dt!==ot||_l?(typeof Mt=="function"&&(ng(l,m,Mt,_),ot=l.memoizedState),(Ie=_l||hy(l,m,Ie,_,dt,ot,q))?(Et||typeof M.UNSAFE_componentWillMount!="function"&&typeof M.componentWillMount!="function"||(typeof M.componentWillMount=="function"&&M.componentWillMount(),typeof M.UNSAFE_componentWillMount=="function"&&M.UNSAFE_componentWillMount()),typeof M.componentDidMount=="function"&&(l.flags|=4194308)):(typeof M.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=_,l.memoizedState=ot),M.props=_,M.state=ot,M.context=q,_=Ie):(typeof M.componentDidMount=="function"&&(l.flags|=4194308),_=!1)}else{M=l.stateNode,Lm(s,l),q=l.memoizedProps,Et=gc(m,q),M.props=Et,Mt=l.pendingProps,dt=M.context,ot=m.contextType,Ie=Io,typeof ot=="object"&&ot!==null&&(Ie=ts(ot)),pe=m.getDerivedStateFromProps,(ot=typeof pe=="function"||typeof M.getSnapshotBeforeUpdate=="function")||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(q!==Mt||dt!==Ie)&&fy(l,M,_,Ie),_l=!1,dt=l.memoizedState,M.state=dt,y0(l,_,M,T),p0();var xt=l.memoizedState;q!==Mt||dt!==xt||_l||s!==null&&s.dependencies!==null&&Gu(s.dependencies)?(typeof pe=="function"&&(ng(l,m,pe,_),xt=l.memoizedState),(Et=_l||hy(l,m,Et,_,dt,xt,Ie)||s!==null&&s.dependencies!==null&&Gu(s.dependencies))?(ot||typeof M.UNSAFE_componentWillUpdate!="function"&&typeof M.componentWillUpdate!="function"||(typeof M.componentWillUpdate=="function"&&M.componentWillUpdate(_,xt,Ie),typeof M.UNSAFE_componentWillUpdate=="function"&&M.UNSAFE_componentWillUpdate(_,xt,Ie)),typeof M.componentDidUpdate=="function"&&(l.flags|=4),typeof M.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof M.componentDidUpdate!="function"||q===s.memoizedProps&&dt===s.memoizedState||(l.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||q===s.memoizedProps&&dt===s.memoizedState||(l.flags|=1024),l.memoizedProps=_,l.memoizedState=xt),M.props=_,M.state=xt,M.context=Ie,_=Et):(typeof M.componentDidUpdate!="function"||q===s.memoizedProps&&dt===s.memoizedState||(l.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||q===s.memoizedProps&&dt===s.memoizedState||(l.flags|=1024),_=!1)}return M=_,dh(s,l),_=(l.flags&128)!==0,M||_?(M=l.stateNode,m=_&&typeof m.getDerivedStateFromError!="function"?null:M.render(),l.flags|=1,s!==null&&_?(l.child=fc(l,s.child,null,T),l.child=fc(l,null,m,T)):rs(s,l,m,T),l.memoizedState=M.state,s=l.child):s=Ho(s,l,T),s}function jy(s,l,m,_){return Fo(),l.flags|=256,rs(s,l,m,_),l.child}var cg={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function dg(s){return{baseLanes:s,cachePool:p1()}}function ug(s,l,m){return s=s!==null?s.childLanes&~m:0,l&&(s|=ci),s}function Ty(s,l,m){var _=l.pendingProps,T=!1,M=(l.flags&128)!==0,q;if((q=M)||(q=s!==null&&s.memoizedState===null?!1:(vn.current&2)!==0),q&&(T=!0,l.flags&=-129),q=(l.flags&32)!==0,l.flags&=-33,s===null){if(ra){if(T?Nl(l):Sl(),(s=pa)?(s=Pb(s,Bs),s=s!==null&&s.data!=="&"?s:null,s!==null&&(l.memoizedState={dehydrated:s,treeContext:ct!==null?{id:Rt,overflow:lr}:null,retryLane:536870912,hydrationErrors:null},m=l0(s),m.return=l,l.child=m,xa=l,pa=null)):s=null,s===null)throw fo(l);return Xg(s)?l.lanes=32:l.lanes=536870912,null}var pe=_.children;return _=_.fallback,T?(Sl(),T=l.mode,pe=uh({mode:"hidden",children:pe},T),_=Po(_,T,m,null),pe.return=l,_.return=l,pe.sibling=_,l.child=pe,_=l.child,_.memoizedState=dg(m),_.childLanes=ug(s,q,m),l.memoizedState=cg,k0(null,_)):(Nl(l),hg(l,pe))}var Ie=s.memoizedState;if(Ie!==null&&(pe=Ie.dehydrated,pe!==null)){if(M)l.flags&256?(Nl(l),l.flags&=-257,l=fg(s,l,m)):l.memoizedState!==null?(Sl(),l.child=s.child,l.flags|=128,l=null):(Sl(),pe=_.fallback,T=l.mode,_=uh({mode:"visible",children:_.children},T),pe=Po(pe,T,m,null),pe.flags|=2,_.return=l,pe.return=l,_.sibling=pe,l.child=_,fc(l,s.child,null,m),_=l.child,_.memoizedState=dg(m),_.childLanes=ug(s,q,m),l.memoizedState=cg,l=k0(null,_));else if(Nl(l),Xg(pe)){if(q=pe.nextSibling&&pe.nextSibling.dataset,q)var ot=q.dgst;q=ot,_=Error(n(419)),_.stack="",_.digest=q,oc({value:_,source:null,stack:null}),l=fg(s,l,m)}else if(Sn||Zc(s,l,m,!1),q=(m&s.childLanes)!==0,Sn||q){if(q=Va,q!==null&&(_=wr(q,m),_!==0&&_!==Ie.retryLane))throw Ie.retryLane=_,Ni(s,_),Ws(q,s,_),og;$g(pe)||vh(),l=fg(s,l,m)}else $g(pe)?(l.flags|=192,l.child=s.child,l=null):(s=Ie.treeContext,pa=Ei(pe.nextSibling),xa=l,ra=!0,ho=null,Bs=!1,s!==null&&Cs(l,s),l=hg(l,_.children),l.flags|=4096);return l}return T?(Sl(),pe=_.fallback,T=l.mode,Ie=s.child,ot=Ie.sibling,_=Si(Ie,{mode:"hidden",children:_.children}),_.subtreeFlags=Ie.subtreeFlags&65011712,ot!==null?pe=Si(ot,pe):(pe=Po(pe,T,m,null),pe.flags|=2),pe.return=l,_.return=l,_.sibling=pe,l.child=_,k0(null,_),_=l.child,pe=s.child.memoizedState,pe===null?pe=dg(m):(T=pe.cachePool,T!==null?(Ie=kn._currentValue,T=T.parent!==Ie?{parent:Ie,pool:Ie}:T):T=p1(),pe={baseLanes:pe.baseLanes|m,cachePool:T}),_.memoizedState=pe,_.childLanes=ug(s,q,m),l.memoizedState=cg,k0(s.child,_)):(Nl(l),m=s.child,s=m.sibling,m=Si(m,{mode:"visible",children:_.children}),m.return=l,m.sibling=null,s!==null&&(q=l.deletions,q===null?(l.deletions=[s],l.flags|=16):q.push(s)),l.child=m,l.memoizedState=null,m)}function hg(s,l){return l=uh({mode:"visible",children:l},s.mode),l.return=s,s.child=l}function uh(s,l){return s=gs(22,s,null,l),s.lanes=0,s}function fg(s,l,m){return fc(l,s.child,null,m),s=hg(l,l.pendingProps.children),s.flags|=2,l.memoizedState=null,s}function Ay(s,l,m){s.lanes|=l;var _=s.alternate;_!==null&&(_.lanes|=l),jm(s.return,l,m)}function mg(s,l,m,_,T,M){var q=s.memoizedState;q===null?s.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:_,tail:m,tailMode:T,treeForkCount:M}:(q.isBackwards=l,q.rendering=null,q.renderingStartTime=0,q.last=_,q.tail=m,q.tailMode=T,q.treeForkCount=M)}function Oy(s,l,m){var _=l.pendingProps,T=_.revealOrder,M=_.tail;_=_.children;var q=vn.current,pe=(q&2)!==0;if(pe?(q=q&1|2,l.flags|=128):q&=1,ie(vn,q),rs(s,l,_,m),_=ra?he:0,!pe&&s!==null&&(s.flags&128)!==0)e:for(s=l.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&Ay(s,m,l);else if(s.tag===19)Ay(s,m,l);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===l)break e;for(;s.sibling===null;){if(s.return===null||s.return===l)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}switch(T){case"forwards":for(m=l.child,T=null;m!==null;)s=m.alternate,s!==null&&Qu(s)===null&&(T=m),m=m.sibling;m=T,m===null?(T=l.child,l.child=null):(T=m.sibling,m.sibling=null),mg(l,!1,T,m,M,_);break;case"backwards":case"unstable_legacy-backwards":for(m=null,T=l.child,l.child=null;T!==null;){if(s=T.alternate,s!==null&&Qu(s)===null){l.child=T;break}s=T.sibling,T.sibling=m,m=T,T=s}mg(l,!0,m,null,M,_);break;case"together":mg(l,!1,null,null,void 0,_);break;default:l.memoizedState=null}return l.child}function Ho(s,l,m){if(s!==null&&(l.dependencies=s.dependencies),jl|=l.lanes,(m&l.childLanes)===0)if(s!==null){if(Zc(s,l,m,!1),(m&l.childLanes)===0)return null}else return null;if(s!==null&&l.child!==s.child)throw Error(n(153));if(l.child!==null){for(s=l.child,m=Si(s,s.pendingProps),l.child=m,m.return=l;s.sibling!==null;)s=s.sibling,m=m.sibling=Si(s,s.pendingProps),m.return=l;m.sibling=null}return l.child}function gg(s,l){return(s.lanes&l)!==0?!0:(s=s.dependencies,!!(s!==null&&Gu(s)))}function aN(s,l,m){switch(l.tag){case 3:Ae(l,l.stateNode.containerInfo),vl(l,kn,s.memoizedState.cache),Fo();break;case 27:case 5:Re(l);break;case 4:Ae(l,l.stateNode.containerInfo);break;case 10:vl(l,l.type,l.memoizedProps.value);break;case 31:if(l.memoizedState!==null)return l.flags|=128,Um(l),null;break;case 13:var _=l.memoizedState;if(_!==null)return _.dehydrated!==null?(Nl(l),l.flags|=128,null):(m&l.child.childLanes)!==0?Ty(s,l,m):(Nl(l),s=Ho(s,l,m),s!==null?s.sibling:null);Nl(l);break;case 19:var T=(s.flags&128)!==0;if(_=(m&l.childLanes)!==0,_||(Zc(s,l,m,!1),_=(m&l.childLanes)!==0),T){if(_)return Oy(s,l,m);l.flags|=128}if(T=l.memoizedState,T!==null&&(T.rendering=null,T.tail=null,T.lastEffect=null),ie(vn,vn.current),_)break;return null;case 22:return l.lanes=0,ky(s,l,m,l.pendingProps);case 24:vl(l,kn,s.memoizedState.cache)}return Ho(s,l,m)}function Ry(s,l,m){if(s!==null)if(s.memoizedProps!==l.pendingProps)Sn=!0;else{if(!gg(s,m)&&(l.flags&128)===0)return Sn=!1,aN(s,l,m);Sn=(s.flags&131072)!==0}else Sn=!1,ra&&(l.flags&1048576)!==0&&Xr(l,he,l.index);switch(l.lanes=0,l.tag){case 16:e:{var _=l.pendingProps;if(s=uc(l.elementType),l.type=s,typeof s=="function")$c(s)?(_=gc(s,_),l.tag=1,l=Ey(null,l,s,_,m)):(l.tag=0,l=lg(null,l,s,_,m));else{if(s!=null){var T=s.$$typeof;if(T===V){l.tag=11,l=vy(null,l,s,_,m);break e}else if(T===H){l.tag=14,l=_y(null,l,s,_,m);break e}}throw l=Ce(s)||s,Error(n(306,l,""))}}return l;case 0:return lg(s,l,l.type,l.pendingProps,m);case 1:return _=l.type,T=gc(_,l.pendingProps),Ey(s,l,_,T,m);case 3:e:{if(Ae(l,l.stateNode.containerInfo),s===null)throw Error(n(387));_=l.pendingProps;var M=l.memoizedState;T=M.element,Lm(s,l),y0(l,_,null,m);var q=l.memoizedState;if(_=q.cache,vl(l,kn,_),_!==M.cache&&Tm(l,[kn],m,!0),p0(),_=q.element,M.isDehydrated)if(M={element:_,isDehydrated:!1,cache:q.cache},l.updateQueue.baseState=M,l.memoizedState=M,l.flags&256){l=jy(s,l,_,m);break e}else if(_!==T){T=v(Error(n(424)),l),oc(T),l=jy(s,l,_,m);break e}else{switch(s=l.stateNode.containerInfo,s.nodeType){case 9:s=s.body;break;default:s=s.nodeName==="HTML"?s.ownerDocument.body:s}for(pa=Ei(s.firstChild),xa=l,ra=!0,ho=null,Bs=!0,m=k1(l,null,_,m),l.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling}else{if(Fo(),_===T){l=Ho(s,l,m);break e}rs(s,l,_,m)}l=l.child}return l;case 26:return dh(s,l),s===null?(m=Vb(l.type,null,l.pendingProps,null))?l.memoizedState=m:ra||(m=l.type,s=l.pendingProps,_=Eh(ve.current).createElement(m),_[we]=l,_[ke]=s,as(_,m,s),fr(_),l.stateNode=_):l.memoizedState=Vb(l.type,s.memoizedProps,l.pendingProps,s.memoizedState),null;case 27:return Re(l),s===null&&ra&&(_=l.stateNode=Ub(l.type,l.pendingProps,ve.current),xa=l,Bs=!0,T=pa,Ml(l.type)?(Yg=T,pa=Ei(_.firstChild)):pa=T),rs(s,l,l.pendingProps.children,m),dh(s,l),s===null&&(l.flags|=4194304),l.child;case 5:return s===null&&ra&&((T=_=pa)&&(_=MN(_,l.type,l.pendingProps,Bs),_!==null?(l.stateNode=_,xa=l,pa=Ei(_.firstChild),Bs=!1,T=!0):T=!1),T||fo(l)),Re(l),T=l.type,M=l.pendingProps,q=s!==null?s.memoizedProps:null,_=M.children,Vg(T,M)?_=null:q!==null&&Vg(T,q)&&(l.flags|=32),l.memoizedState!==null&&(T=Hm(s,l,Yk,null,null,m),F0._currentValue=T),dh(s,l),rs(s,l,_,m),l.child;case 6:return s===null&&ra&&((s=m=pa)&&(m=DN(m,l.pendingProps,Bs),m!==null?(l.stateNode=m,xa=l,pa=null,s=!0):s=!1),s||fo(l)),null;case 13:return Ty(s,l,m);case 4:return Ae(l,l.stateNode.containerInfo),_=l.pendingProps,s===null?l.child=fc(l,null,_,m):rs(s,l,_,m),l.child;case 11:return vy(s,l,l.type,l.pendingProps,m);case 7:return rs(s,l,l.pendingProps,m),l.child;case 8:return rs(s,l,l.pendingProps.children,m),l.child;case 12:return rs(s,l,l.pendingProps.children,m),l.child;case 10:return _=l.pendingProps,vl(l,l.type,_.value),rs(s,l,_.children,m),l.child;case 9:return T=l.type._context,_=l.pendingProps.children,cc(l),T=ts(T),_=_(T),l.flags|=1,rs(s,l,_,m),l.child;case 14:return _y(s,l,l.type,l.pendingProps,m);case 15:return wy(s,l,l.type,l.pendingProps,m);case 19:return Oy(s,l,m);case 31:return rN(s,l,m);case 22:return ky(s,l,m,l.pendingProps);case 24:return cc(l),_=ts(kn),s===null?(T=Rm(),T===null&&(T=Va,M=Am(),T.pooledCache=M,M.refCount++,M!==null&&(T.pooledCacheLanes|=m),T=M),l.memoizedState={parent:_,cache:T},Dm(l),vl(l,kn,T)):((s.lanes&m)!==0&&(Lm(s,l),y0(l,null,null,m),p0()),T=s.memoizedState,M=l.memoizedState,T.parent!==_?(T={parent:_,cache:_},l.memoizedState=T,l.lanes===0&&(l.memoizedState=l.updateQueue.baseState=T),vl(l,kn,_)):(_=M.cache,vl(l,kn,_),_!==T.cache&&Tm(l,[kn],m,!0))),rs(s,l,l.pendingProps.children,m),l.child;case 29:throw l.pendingProps}throw Error(n(156,l.tag))}function Vo(s){s.flags|=4}function xg(s,l,m,_,T){if((l=(s.mode&32)!==0)&&(l=!1),l){if(s.flags|=16777216,(T&335544128)===T)if(s.stateNode.complete)s.flags|=8192;else if(sb())s.flags|=8192;else throw hc=Zu,Mm}else s.flags&=-16777217}function My(s,l){if(l.type!=="stylesheet"||(l.state.loading&4)!==0)s.flags&=-16777217;else if(s.flags|=16777216,!Yb(l))if(sb())s.flags|=8192;else throw hc=Zu,Mm}function hh(s,l){l!==null&&(s.flags|=4),s.flags&16384&&(l=s.tag!==22?Yt():536870912,s.lanes|=l,od|=l)}function N0(s,l){if(!ra)switch(s.tailMode){case"hidden":l=s.tail;for(var m=null;l!==null;)l.alternate!==null&&(m=l),l=l.sibling;m===null?s.tail=null:m.sibling=null;break;case"collapsed":m=s.tail;for(var _=null;m!==null;)m.alternate!==null&&(_=m),m=m.sibling;_===null?l||s.tail===null?s.tail=null:s.tail.sibling=null:_.sibling=null}}function $a(s){var l=s.alternate!==null&&s.alternate.child===s.child,m=0,_=0;if(l)for(var T=s.child;T!==null;)m|=T.lanes|T.childLanes,_|=T.subtreeFlags&65011712,_|=T.flags&65011712,T.return=s,T=T.sibling;else for(T=s.child;T!==null;)m|=T.lanes|T.childLanes,_|=T.subtreeFlags,_|=T.flags,T.return=s,T=T.sibling;return s.subtreeFlags|=_,s.childLanes=m,l}function nN(s,l,m){var _=l.pendingProps;switch(cn(l),l.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return $a(l),null;case 1:return $a(l),null;case 3:return m=l.stateNode,_=null,s!==null&&(_=s.memoizedState.cache),l.memoizedState.cache!==_&&(l.flags|=2048),Bo(kn),ze(),m.pendingContext&&(m.context=m.pendingContext,m.pendingContext=null),(s===null||s.child===null)&&(Gi(l)?Vo(l):s===null||s.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,u0())),$a(l),null;case 26:var T=l.type,M=l.memoizedState;return s===null?(Vo(l),M!==null?($a(l),My(l,M)):($a(l),xg(l,T,null,_,m))):M?M!==s.memoizedState?(Vo(l),$a(l),My(l,M)):($a(l),l.flags&=-16777217):(s=s.memoizedProps,s!==_&&Vo(l),$a(l),xg(l,T,s,_,m)),null;case 27:if(Ze(l),m=ve.current,T=l.type,s!==null&&l.stateNode!=null)s.memoizedProps!==_&&Vo(l);else{if(!_){if(l.stateNode===null)throw Error(n(166));return $a(l),null}s=re.current,Gi(l)?d0(l):(s=Ub(T,_,m),l.stateNode=s,Vo(l))}return $a(l),null;case 5:if(Ze(l),T=l.type,s!==null&&l.stateNode!=null)s.memoizedProps!==_&&Vo(l);else{if(!_){if(l.stateNode===null)throw Error(n(166));return $a(l),null}if(M=re.current,Gi(l))d0(l);else{var q=Eh(ve.current);switch(M){case 1:M=q.createElementNS("http://www.w3.org/2000/svg",T);break;case 2:M=q.createElementNS("http://www.w3.org/1998/Math/MathML",T);break;default:switch(T){case"svg":M=q.createElementNS("http://www.w3.org/2000/svg",T);break;case"math":M=q.createElementNS("http://www.w3.org/1998/Math/MathML",T);break;case"script":M=q.createElement("div"),M.innerHTML="<script><\/script>",M=M.removeChild(M.firstChild);break;case"select":M=typeof _.is=="string"?q.createElement("select",{is:_.is}):q.createElement("select"),_.multiple?M.multiple=!0:_.size&&(M.size=_.size);break;default:M=typeof _.is=="string"?q.createElement(T,{is:_.is}):q.createElement(T)}}M[we]=l,M[ke]=_;e:for(q=l.child;q!==null;){if(q.tag===5||q.tag===6)M.appendChild(q.stateNode);else if(q.tag!==4&&q.tag!==27&&q.child!==null){q.child.return=q,q=q.child;continue}if(q===l)break e;for(;q.sibling===null;){if(q.return===null||q.return===l)break e;q=q.return}q.sibling.return=q.return,q=q.sibling}l.stateNode=M;e:switch(as(M,T,_),T){case"button":case"input":case"select":case"textarea":_=!!_.autoFocus;break e;case"img":_=!0;break e;default:_=!1}_&&Vo(l)}}return $a(l),xg(l,l.type,s===null?null:s.memoizedProps,l.pendingProps,m),null;case 6:if(s&&l.stateNode!=null)s.memoizedProps!==_&&Vo(l);else{if(typeof _!="string"&&l.stateNode===null)throw Error(n(166));if(s=ve.current,Gi(l)){if(s=l.stateNode,m=l.memoizedProps,_=null,T=xa,T!==null)switch(T.tag){case 27:case 5:_=T.memoizedProps}s[we]=l,s=!!(s.nodeValue===m||_!==null&&_.suppressHydrationWarning===!0||Tb(s.nodeValue,m)),s||fo(l,!0)}else s=Eh(s).createTextNode(_),s[we]=l,l.stateNode=s}return $a(l),null;case 31:if(m=l.memoizedState,s===null||s.memoizedState!==null){if(_=Gi(l),m!==null){if(s===null){if(!_)throw Error(n(318));if(s=l.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(n(557));s[we]=l}else Fo(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;$a(l),s=!1}else m=u0(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=m),s=!0;if(!s)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(n(558))}return $a(l),null;case 13:if(_=l.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(T=Gi(l),_!==null&&_.dehydrated!==null){if(s===null){if(!T)throw Error(n(318));if(T=l.memoizedState,T=T!==null?T.dehydrated:null,!T)throw Error(n(317));T[we]=l}else Fo(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;$a(l),T=!1}else T=u0(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=T),T=!0;if(!T)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=m,l):(m=_!==null,s=s!==null&&s.memoizedState!==null,m&&(_=l.child,T=null,_.alternate!==null&&_.alternate.memoizedState!==null&&_.alternate.memoizedState.cachePool!==null&&(T=_.alternate.memoizedState.cachePool.pool),M=null,_.memoizedState!==null&&_.memoizedState.cachePool!==null&&(M=_.memoizedState.cachePool.pool),M!==T&&(_.flags|=2048)),m!==s&&m&&(l.child.flags|=8192),hh(l,l.updateQueue),$a(l),null);case 4:return ze(),s===null&&Fg(l.stateNode.containerInfo),$a(l),null;case 10:return Bo(l.type),$a(l),null;case 19:if(G(vn),_=l.memoizedState,_===null)return $a(l),null;if(T=(l.flags&128)!==0,M=_.rendering,M===null)if(T)N0(_,!1);else{if(un!==0||s!==null&&(s.flags&128)!==0)for(s=l.child;s!==null;){if(M=Qu(s),M!==null){for(l.flags|=128,N0(_,!1),s=M.updateQueue,l.updateQueue=s,hh(l,s),l.subtreeFlags=0,s=m,m=l.child;m!==null;)o0(m,s),m=m.sibling;return ie(vn,vn.current&1|2),ra&&Cr(l,_.treeForkCount),l.child}s=s.sibling}_.tail!==null&&it()>ph&&(l.flags|=128,T=!0,N0(_,!1),l.lanes=4194304)}else{if(!T)if(s=Qu(M),s!==null){if(l.flags|=128,T=!0,s=s.updateQueue,l.updateQueue=s,hh(l,s),N0(_,!0),_.tail===null&&_.tailMode==="hidden"&&!M.alternate&&!ra)return $a(l),null}else 2*it()-_.renderingStartTime>ph&&m!==536870912&&(l.flags|=128,T=!0,N0(_,!1),l.lanes=4194304);_.isBackwards?(M.sibling=l.child,l.child=M):(s=_.last,s!==null?s.sibling=M:l.child=M,_.last=M)}return _.tail!==null?(s=_.tail,_.rendering=s,_.tail=s.sibling,_.renderingStartTime=it(),s.sibling=null,m=vn.current,ie(vn,T?m&1|2:m&1),ra&&Cr(l,_.treeForkCount),s):($a(l),null);case 22:case 23:return oi(l),Bm(),_=l.memoizedState!==null,s!==null?s.memoizedState!==null!==_&&(l.flags|=8192):_&&(l.flags|=8192),_?(m&536870912)!==0&&(l.flags&128)===0&&($a(l),l.subtreeFlags&6&&(l.flags|=8192)):$a(l),m=l.updateQueue,m!==null&&hh(l,m.retryQueue),m=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(m=s.memoizedState.cachePool.pool),_=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(_=l.memoizedState.cachePool.pool),_!==m&&(l.flags|=2048),s!==null&&G(dc),null;case 24:return m=null,s!==null&&(m=s.memoizedState.cache),l.memoizedState.cache!==m&&(l.flags|=2048),Bo(kn),$a(l),null;case 25:return null;case 30:return null}throw Error(n(156,l.tag))}function sN(s,l){switch(cn(l),l.tag){case 1:return s=l.flags,s&65536?(l.flags=s&-65537|128,l):null;case 3:return Bo(kn),ze(),s=l.flags,(s&65536)!==0&&(s&128)===0?(l.flags=s&-65537|128,l):null;case 26:case 27:case 5:return Ze(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(n(340));Fo()}return s=l.flags,s&65536?(l.flags=s&-65537|128,l):null;case 13:if(oi(l),s=l.memoizedState,s!==null&&s.dehydrated!==null){if(l.alternate===null)throw Error(n(340));Fo()}return s=l.flags,s&65536?(l.flags=s&-65537|128,l):null;case 19:return G(vn),null;case 4:return ze(),null;case 10:return Bo(l.type),null;case 22:case 23:return oi(l),Bm(),s!==null&&G(dc),s=l.flags,s&65536?(l.flags=s&-65537|128,l):null;case 24:return Bo(kn),null;case 25:return null;default:return null}}function Dy(s,l){switch(cn(l),l.tag){case 3:Bo(kn),ze();break;case 26:case 27:case 5:Ze(l);break;case 4:ze();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:G(vn);break;case 10:Bo(l.type);break;case 22:case 23:oi(l),Bm(),s!==null&&G(dc);break;case 24:Bo(kn)}}function S0(s,l){try{var m=l.updateQueue,_=m!==null?m.lastEffect:null;if(_!==null){var T=_.next;m=T;do{if((m.tag&s)===s){_=void 0;var M=m.create,q=m.inst;_=M(),q.destroy=_}m=m.next}while(m!==T)}}catch(pe){Ta(l,l.return,pe)}}function Cl(s,l,m){try{var _=l.updateQueue,T=_!==null?_.lastEffect:null;if(T!==null){var M=T.next;_=M;do{if((_.tag&s)===s){var q=_.inst,pe=q.destroy;if(pe!==void 0){q.destroy=void 0,T=l;var Ie=m,ot=pe;try{ot()}catch(Et){Ta(T,Ie,Et)}}}_=_.next}while(_!==M)}}catch(Et){Ta(l,l.return,Et)}}function Ly(s){var l=s.updateQueue;if(l!==null){var m=s.stateNode;try{S1(l,m)}catch(_){Ta(s,s.return,_)}}}function Iy(s,l,m){m.props=gc(s.type,s.memoizedProps),m.state=s.memoizedState;try{m.componentWillUnmount()}catch(_){Ta(s,l,_)}}function C0(s,l){try{var m=s.ref;if(m!==null){switch(s.tag){case 26:case 27:case 5:var _=s.stateNode;break;case 30:_=s.stateNode;break;default:_=s.stateNode}typeof m=="function"?s.refCleanup=m(_):m.current=_}}catch(T){Ta(s,l,T)}}function go(s,l){var m=s.ref,_=s.refCleanup;if(m!==null)if(typeof _=="function")try{_()}catch(T){Ta(s,l,T)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof m=="function")try{m(null)}catch(T){Ta(s,l,T)}else m.current=null}function Py(s){var l=s.type,m=s.memoizedProps,_=s.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":m.autoFocus&&_.focus();break e;case"img":m.src?_.src=m.src:m.srcSet&&(_.srcset=m.srcSet)}}catch(T){Ta(s,s.return,T)}}function pg(s,l,m){try{var _=s.stateNode;EN(_,s.type,m,l),_[ke]=l}catch(T){Ta(s,s.return,T)}}function Fy(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&Ml(s.type)||s.tag===4}function yg(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||Fy(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.tag===27&&Ml(s.type)||s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function bg(s,l,m){var _=s.tag;if(_===5||_===6)s=s.stateNode,l?(m.nodeType===9?m.body:m.nodeName==="HTML"?m.ownerDocument.body:m).insertBefore(s,l):(l=m.nodeType===9?m.body:m.nodeName==="HTML"?m.ownerDocument.body:m,l.appendChild(s),m=m._reactRootContainer,m!=null||l.onclick!==null||(l.onclick=On));else if(_!==4&&(_===27&&Ml(s.type)&&(m=s.stateNode,l=null),s=s.child,s!==null))for(bg(s,l,m),s=s.sibling;s!==null;)bg(s,l,m),s=s.sibling}function fh(s,l,m){var _=s.tag;if(_===5||_===6)s=s.stateNode,l?m.insertBefore(s,l):m.appendChild(s);else if(_!==4&&(_===27&&Ml(s.type)&&(m=s.stateNode),s=s.child,s!==null))for(fh(s,l,m),s=s.sibling;s!==null;)fh(s,l,m),s=s.sibling}function By(s){var l=s.stateNode,m=s.memoizedProps;try{for(var _=s.type,T=l.attributes;T.length;)l.removeAttributeNode(T[0]);as(l,_,m),l[we]=s,l[ke]=m}catch(M){Ta(s,s.return,M)}}var Wo=!1,Cn=!1,vg=!1,Uy=typeof WeakSet=="function"?WeakSet:Set,Vn=null;function iN(s,l){if(s=s.containerInfo,zg=Dh,s=te(s),ue(s)){if("selectionStart"in s)var m={start:s.selectionStart,end:s.selectionEnd};else e:{m=(m=s.ownerDocument)&&m.defaultView||window;var _=m.getSelection&&m.getSelection();if(_&&_.rangeCount!==0){m=_.anchorNode;var T=_.anchorOffset,M=_.focusNode;_=_.focusOffset;try{m.nodeType,M.nodeType}catch(Pr){m=null;break e}var q=0,pe=-1,Ie=-1,ot=0,Et=0,Mt=s,dt=null;t:for(;;){for(var xt;Mt!==m||T!==0&&Mt.nodeType!==3||(pe=q+T),Mt!==M||_!==0&&Mt.nodeType!==3||(Ie=q+_),Mt.nodeType===3&&(q+=Mt.nodeValue.length),(xt=Mt.firstChild)!==null;)dt=Mt,Mt=xt;for(;;){if(Mt===s)break t;if(dt===m&&++ot===T&&(pe=q),dt===M&&++Et===_&&(Ie=q),(xt=Mt.nextSibling)!==null)break;Mt=dt,dt=Mt.parentNode}Mt=xt}m=pe===-1||Ie===-1?null:{start:pe,end:Ie}}else m=null}m=m||{start:0,end:0}}else m=null;for(Hg={focusedElem:s,selectionRange:m},Dh=!1,Vn=l;Vn!==null;)if(l=Vn,s=l.child,(l.subtreeFlags&1028)!==0&&s!==null)s.return=l,Vn=s;else for(;Vn!==null;){switch(l=Vn,M=l.alternate,s=l.flags,l.tag){case 0:if((s&4)!==0&&(s=l.updateQueue,s=s!==null?s.events:null,s!==null))for(m=0;m<s.length;m++)T=s[m],T.ref.impl=T.nextImpl;break;case 11:case 15:break;case 1:if((s&1024)!==0&&M!==null){s=void 0,m=l,T=M.memoizedProps,M=M.memoizedState,_=m.stateNode;try{var br=gc(m.type,T);s=_.getSnapshotBeforeUpdate(br,M),_.__reactInternalSnapshotBeforeUpdate=s}catch(Pr){Ta(m,m.return,Pr)}}break;case 3:if((s&1024)!==0){if(s=l.stateNode.containerInfo,m=s.nodeType,m===9)Gg(s);else if(m===1)switch(s.nodeName){case"HEAD":case"HTML":case"BODY":Gg(s);break;default:s.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((s&1024)!==0)throw Error(n(163))}if(s=l.sibling,s!==null){s.return=l.return,Vn=s;break}Vn=l.return}}function zy(s,l,m){var _=m.flags;switch(m.tag){case 0:case 11:case 15:$o(s,m),_&4&&S0(5,m);break;case 1:if($o(s,m),_&4)if(s=m.stateNode,l===null)try{s.componentDidMount()}catch(q){Ta(m,m.return,q)}else{var T=gc(m.type,l.memoizedProps);l=l.memoizedState;try{s.componentDidUpdate(T,l,s.__reactInternalSnapshotBeforeUpdate)}catch(q){Ta(m,m.return,q)}}_&64&&Ly(m),_&512&&C0(m,m.return);break;case 3:if($o(s,m),_&64&&(s=m.updateQueue,s!==null)){if(l=null,m.child!==null)switch(m.child.tag){case 27:case 5:l=m.child.stateNode;break;case 1:l=m.child.stateNode}try{S1(s,l)}catch(q){Ta(m,m.return,q)}}break;case 27:l===null&&_&4&&By(m);case 26:case 5:$o(s,m),l===null&&_&4&&Py(m),_&512&&C0(m,m.return);break;case 12:$o(s,m);break;case 31:$o(s,m),_&4&&Wy(s,m);break;case 13:$o(s,m),_&4&&Gy(s,m),_&64&&(s=m.memoizedState,s!==null&&(s=s.dehydrated,s!==null&&(m=gN.bind(null,m),LN(s,m))));break;case 22:if(_=m.memoizedState!==null||Wo,!_){l=l!==null&&l.memoizedState!==null||Cn,T=Wo;var M=Cn;Wo=_,(Cn=l)&&!M?Xo(s,m,(m.subtreeFlags&8772)!==0):$o(s,m),Wo=T,Cn=M}break;case 30:break;default:$o(s,m)}}function Hy(s){var l=s.alternate;l!==null&&(s.alternate=null,Hy(l)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(l=s.stateNode,l!==null&&Ot(l)),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}var Ka=null,Us=!1;function Go(s,l,m){for(m=m.child;m!==null;)Vy(s,l,m),m=m.sibling}function Vy(s,l,m){if(We&&typeof We.onCommitFiberUnmount=="function")try{We.onCommitFiberUnmount(Ge,m)}catch(M){}switch(m.tag){case 26:Cn||go(m,l),Go(s,l,m),m.memoizedState?m.memoizedState.count--:m.stateNode&&(m=m.stateNode,m.parentNode.removeChild(m));break;case 27:Cn||go(m,l);var _=Ka,T=Us;Ml(m.type)&&(Ka=m.stateNode,Us=!1),Go(s,l,m),L0(m.stateNode),Ka=_,Us=T;break;case 5:Cn||go(m,l);case 6:if(_=Ka,T=Us,Ka=null,Go(s,l,m),Ka=_,Us=T,Ka!==null)if(Us)try{(Ka.nodeType===9?Ka.body:Ka.nodeName==="HTML"?Ka.ownerDocument.body:Ka).removeChild(m.stateNode)}catch(M){Ta(m,l,M)}else try{Ka.removeChild(m.stateNode)}catch(M){Ta(m,l,M)}break;case 18:Ka!==null&&(Us?(s=Ka,Lb(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,m.stateNode),gd(s)):Lb(Ka,m.stateNode));break;case 4:_=Ka,T=Us,Ka=m.stateNode.containerInfo,Us=!0,Go(s,l,m),Ka=_,Us=T;break;case 0:case 11:case 14:case 15:Cl(2,m,l),Cn||Cl(4,m,l),Go(s,l,m);break;case 1:Cn||(go(m,l),_=m.stateNode,typeof _.componentWillUnmount=="function"&&Iy(m,l,_)),Go(s,l,m);break;case 21:Go(s,l,m);break;case 22:Cn=(_=Cn)||m.memoizedState!==null,Go(s,l,m),Cn=_;break;default:Go(s,l,m)}}function Wy(s,l){if(l.memoizedState===null&&(s=l.alternate,s!==null&&(s=s.memoizedState,s!==null))){s=s.dehydrated;try{gd(s)}catch(m){Ta(l,l.return,m)}}}function Gy(s,l){if(l.memoizedState===null&&(s=l.alternate,s!==null&&(s=s.memoizedState,s!==null&&(s=s.dehydrated,s!==null))))try{gd(s)}catch(m){Ta(l,l.return,m)}}function oN(s){switch(s.tag){case 31:case 13:case 19:var l=s.stateNode;return l===null&&(l=s.stateNode=new Uy),l;case 22:return s=s.stateNode,l=s._retryCache,l===null&&(l=s._retryCache=new Uy),l;default:throw Error(n(435,s.tag))}}function mh(s,l){var m=oN(s);l.forEach(function(_){if(!m.has(_)){m.add(_);var T=xN.bind(null,s,_);_.then(T,T)}})}function zs(s,l){var m=l.deletions;if(m!==null)for(var _=0;_<m.length;_++){var T=m[_],M=s,q=l,pe=q;e:for(;pe!==null;){switch(pe.tag){case 27:if(Ml(pe.type)){Ka=pe.stateNode,Us=!1;break e}break;case 5:Ka=pe.stateNode,Us=!1;break e;case 3:case 4:Ka=pe.stateNode.containerInfo,Us=!0;break e}pe=pe.return}if(Ka===null)throw Error(n(160));Vy(M,q,T),Ka=null,Us=!1,M=T.alternate,M!==null&&(M.return=null),T.return=null}if(l.subtreeFlags&13886)for(l=l.child;l!==null;)$y(l,s),l=l.sibling}var Xi=null;function $y(s,l){var m=s.alternate,_=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:zs(l,s),Hs(s),_&4&&(Cl(3,s,s.return),S0(3,s),Cl(5,s,s.return));break;case 1:zs(l,s),Hs(s),_&512&&(Cn||m===null||go(m,m.return)),_&64&&Wo&&(s=s.updateQueue,s!==null&&(_=s.callbacks,_!==null&&(m=s.shared.hiddenCallbacks,s.shared.hiddenCallbacks=m===null?_:m.concat(_))));break;case 26:var T=Xi;if(zs(l,s),Hs(s),_&512&&(Cn||m===null||go(m,m.return)),_&4){var M=m!==null?m.memoizedState:null;if(_=s.memoizedState,m===null)if(_===null)if(s.stateNode===null){e:{_=s.type,m=s.memoizedProps,T=T.ownerDocument||T;t:switch(_){case"title":M=T.getElementsByTagName("title")[0],(!M||M[nt]||M[we]||M.namespaceURI==="http://www.w3.org/2000/svg"||M.hasAttribute("itemprop"))&&(M=T.createElement(_),T.head.insertBefore(M,T.querySelector("head > title"))),as(M,_,m),M[we]=s,fr(M),_=M;break e;case"link":var q=$b("link","href",T).get(_+(m.href||""));if(q){for(var pe=0;pe<q.length;pe++)if(M=q[pe],M.getAttribute("href")===(m.href==null||m.href===""?null:m.href)&&M.getAttribute("rel")===(m.rel==null?null:m.rel)&&M.getAttribute("title")===(m.title==null?null:m.title)&&M.getAttribute("crossorigin")===(m.crossOrigin==null?null:m.crossOrigin)){q.splice(pe,1);break t}}M=T.createElement(_),as(M,_,m),T.head.appendChild(M);break;case"meta":if(q=$b("meta","content",T).get(_+(m.content||""))){for(pe=0;pe<q.length;pe++)if(M=q[pe],M.getAttribute("content")===(m.content==null?null:""+m.content)&&M.getAttribute("name")===(m.name==null?null:m.name)&&M.getAttribute("property")===(m.property==null?null:m.property)&&M.getAttribute("http-equiv")===(m.httpEquiv==null?null:m.httpEquiv)&&M.getAttribute("charset")===(m.charSet==null?null:m.charSet)){q.splice(pe,1);break t}}M=T.createElement(_),as(M,_,m),T.head.appendChild(M);break;default:throw Error(n(468,_))}M[we]=s,fr(M),_=M}s.stateNode=_}else Xb(T,s.type,s.stateNode);else s.stateNode=Gb(T,_,s.memoizedProps);else M!==_?(M===null?m.stateNode!==null&&(m=m.stateNode,m.parentNode.removeChild(m)):M.count--,_===null?Xb(T,s.type,s.stateNode):Gb(T,_,s.memoizedProps)):_===null&&s.stateNode!==null&&pg(s,s.memoizedProps,m.memoizedProps)}break;case 27:zs(l,s),Hs(s),_&512&&(Cn||m===null||go(m,m.return)),m!==null&&_&4&&pg(s,s.memoizedProps,m.memoizedProps);break;case 5:if(zs(l,s),Hs(s),_&512&&(Cn||m===null||go(m,m.return)),s.flags&32){T=s.stateNode;try{Ms(T,"")}catch(br){Ta(s,s.return,br)}}_&4&&s.stateNode!=null&&(T=s.memoizedProps,pg(s,T,m!==null?m.memoizedProps:T)),_&1024&&(vg=!0);break;case 6:if(zs(l,s),Hs(s),_&4){if(s.stateNode===null)throw Error(n(162));_=s.memoizedProps,m=s.stateNode;try{m.nodeValue=_}catch(br){Ta(s,s.return,br)}}break;case 3:if(Ah=null,T=Xi,Xi=jh(l.containerInfo),zs(l,s),Xi=T,Hs(s),_&4&&m!==null&&m.memoizedState.isDehydrated)try{gd(l.containerInfo)}catch(br){Ta(s,s.return,br)}vg&&(vg=!1,Xy(s));break;case 4:_=Xi,Xi=jh(s.stateNode.containerInfo),zs(l,s),Hs(s),Xi=_;break;case 12:zs(l,s),Hs(s);break;case 31:zs(l,s),Hs(s),_&4&&(_=s.updateQueue,_!==null&&(s.updateQueue=null,mh(s,_)));break;case 13:zs(l,s),Hs(s),s.child.flags&8192&&s.memoizedState!==null!=(m!==null&&m.memoizedState!==null)&&(xh=it()),_&4&&(_=s.updateQueue,_!==null&&(s.updateQueue=null,mh(s,_)));break;case 22:T=s.memoizedState!==null;var Ie=m!==null&&m.memoizedState!==null,ot=Wo,Et=Cn;if(Wo=ot||T,Cn=Et||Ie,zs(l,s),Cn=Et,Wo=ot,Hs(s),_&8192)e:for(l=s.stateNode,l._visibility=T?l._visibility&-2:l._visibility|1,T&&(m===null||Ie||Wo||Cn||xc(s)),m=null,l=s;;){if(l.tag===5||l.tag===26){if(m===null){Ie=m=l;try{if(M=Ie.stateNode,T)q=M.style,typeof q.setProperty=="function"?q.setProperty("display","none","important"):q.display="none";else{pe=Ie.stateNode;var Mt=Ie.memoizedProps.style,dt=Mt!=null&&Mt.hasOwnProperty("display")?Mt.display:null;pe.style.display=dt==null||typeof dt=="boolean"?"":(""+dt).trim()}}catch(br){Ta(Ie,Ie.return,br)}}}else if(l.tag===6){if(m===null){Ie=l;try{Ie.stateNode.nodeValue=T?"":Ie.memoizedProps}catch(br){Ta(Ie,Ie.return,br)}}}else if(l.tag===18){if(m===null){Ie=l;try{var xt=Ie.stateNode;T?Ib(xt,!0):Ib(Ie.stateNode,!1)}catch(br){Ta(Ie,Ie.return,br)}}}else if((l.tag!==22&&l.tag!==23||l.memoizedState===null||l===s)&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===s)break e;for(;l.sibling===null;){if(l.return===null||l.return===s)break e;m===l&&(m=null),l=l.return}m===l&&(m=null),l.sibling.return=l.return,l=l.sibling}_&4&&(_=s.updateQueue,_!==null&&(m=_.retryQueue,m!==null&&(_.retryQueue=null,mh(s,m))));break;case 19:zs(l,s),Hs(s),_&4&&(_=s.updateQueue,_!==null&&(s.updateQueue=null,mh(s,_)));break;case 30:break;case 21:break;default:zs(l,s),Hs(s)}}function Hs(s){var l=s.flags;if(l&2){try{for(var m,_=s.return;_!==null;){if(Fy(_)){m=_;break}_=_.return}if(m==null)throw Error(n(160));switch(m.tag){case 27:var T=m.stateNode,M=yg(s);fh(s,M,T);break;case 5:var q=m.stateNode;m.flags&32&&(Ms(q,""),m.flags&=-33);var pe=yg(s);fh(s,pe,q);break;case 3:case 4:var Ie=m.stateNode.containerInfo,ot=yg(s);bg(s,ot,Ie);break;default:throw Error(n(161))}}catch(Et){Ta(s,s.return,Et)}s.flags&=-3}l&4096&&(s.flags&=-4097)}function Xy(s){if(s.subtreeFlags&1024)for(s=s.child;s!==null;){var l=s;Xy(l),l.tag===5&&l.flags&1024&&l.stateNode.reset(),s=s.sibling}}function $o(s,l){if(l.subtreeFlags&8772)for(l=l.child;l!==null;)zy(s,l.alternate,l),l=l.sibling}function xc(s){for(s=s.child;s!==null;){var l=s;switch(l.tag){case 0:case 11:case 14:case 15:Cl(4,l,l.return),xc(l);break;case 1:go(l,l.return);var m=l.stateNode;typeof m.componentWillUnmount=="function"&&Iy(l,l.return,m),xc(l);break;case 27:L0(l.stateNode);case 26:case 5:go(l,l.return),xc(l);break;case 22:l.memoizedState===null&&xc(l);break;case 30:xc(l);break;default:xc(l)}s=s.sibling}}function Xo(s,l,m){for(m=m&&(l.subtreeFlags&8772)!==0,l=l.child;l!==null;){var _=l.alternate,T=s,M=l,q=M.flags;switch(M.tag){case 0:case 11:case 15:Xo(T,M,m),S0(4,M);break;case 1:if(Xo(T,M,m),_=M,T=_.stateNode,typeof T.componentDidMount=="function")try{T.componentDidMount()}catch(ot){Ta(_,_.return,ot)}if(_=M,T=_.updateQueue,T!==null){var pe=_.stateNode;try{var Ie=T.shared.hiddenCallbacks;if(Ie!==null)for(T.shared.hiddenCallbacks=null,T=0;T<Ie.length;T++)N1(Ie[T],pe)}catch(ot){Ta(_,_.return,ot)}}m&&q&64&&Ly(M),C0(M,M.return);break;case 27:By(M);case 26:case 5:Xo(T,M,m),m&&_===null&&q&4&&Py(M),C0(M,M.return);break;case 12:Xo(T,M,m);break;case 31:Xo(T,M,m),m&&q&4&&Wy(T,M);break;case 13:Xo(T,M,m),m&&q&4&&Gy(T,M);break;case 22:M.memoizedState===null&&Xo(T,M,m),C0(M,M.return);break;case 30:break;default:Xo(T,M,m)}l=l.sibling}}function _g(s,l){var m=null;s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(m=s.memoizedState.cachePool.pool),s=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(s=l.memoizedState.cachePool.pool),s!==m&&(s!=null&&s.refCount++,m!=null&&h0(m))}function wg(s,l){s=null,l.alternate!==null&&(s=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==s&&(l.refCount++,s!=null&&h0(s))}function Yi(s,l,m,_){if(l.subtreeFlags&10256)for(l=l.child;l!==null;)Yy(s,l,m,_),l=l.sibling}function Yy(s,l,m,_){var T=l.flags;switch(l.tag){case 0:case 11:case 15:Yi(s,l,m,_),T&2048&&S0(9,l);break;case 1:Yi(s,l,m,_);break;case 3:Yi(s,l,m,_),T&2048&&(s=null,l.alternate!==null&&(s=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==s&&(l.refCount++,s!=null&&h0(s)));break;case 12:if(T&2048){Yi(s,l,m,_),s=l.stateNode;try{var M=l.memoizedProps,q=M.id,pe=M.onPostCommit;typeof pe=="function"&&pe(q,l.alternate===null?"mount":"update",s.passiveEffectDuration,-0)}catch(Ie){Ta(l,l.return,Ie)}}else Yi(s,l,m,_);break;case 31:Yi(s,l,m,_);break;case 13:Yi(s,l,m,_);break;case 23:break;case 22:M=l.stateNode,q=l.alternate,l.memoizedState!==null?M._visibility&2?Yi(s,l,m,_):E0(s,l):M._visibility&2?Yi(s,l,m,_):(M._visibility|=2,nd(s,l,m,_,(l.subtreeFlags&10256)!==0||!1)),T&2048&&_g(q,l);break;case 24:Yi(s,l,m,_),T&2048&&wg(l.alternate,l);break;default:Yi(s,l,m,_)}}function nd(s,l,m,_,T){for(T=T&&((l.subtreeFlags&10256)!==0||!1),l=l.child;l!==null;){var M=s,q=l,pe=m,Ie=_,ot=q.flags;switch(q.tag){case 0:case 11:case 15:nd(M,q,pe,Ie,T),S0(8,q);break;case 23:break;case 22:var Et=q.stateNode;q.memoizedState!==null?Et._visibility&2?nd(M,q,pe,Ie,T):E0(M,q):(Et._visibility|=2,nd(M,q,pe,Ie,T)),T&&ot&2048&&_g(q.alternate,q);break;case 24:nd(M,q,pe,Ie,T),T&&ot&2048&&wg(q.alternate,q);break;default:nd(M,q,pe,Ie,T)}l=l.sibling}}function E0(s,l){if(l.subtreeFlags&10256)for(l=l.child;l!==null;){var m=s,_=l,T=_.flags;switch(_.tag){case 22:E0(m,_),T&2048&&_g(_.alternate,_);break;case 24:E0(m,_),T&2048&&wg(_.alternate,_);break;default:E0(m,_)}l=l.sibling}}var j0=8192;function sd(s,l,m){if(s.subtreeFlags&j0)for(s=s.child;s!==null;)Zy(s,l,m),s=s.sibling}function Zy(s,l,m){switch(s.tag){case 26:sd(s,l,m),s.flags&j0&&s.memoizedState!==null&&XN(m,Xi,s.memoizedState,s.memoizedProps);break;case 5:sd(s,l,m);break;case 3:case 4:var _=Xi;Xi=jh(s.stateNode.containerInfo),sd(s,l,m),Xi=_;break;case 22:s.memoizedState===null&&(_=s.alternate,_!==null&&_.memoizedState!==null?(_=j0,j0=16777216,sd(s,l,m),j0=_):sd(s,l,m));break;default:sd(s,l,m)}}function qy(s){var l=s.alternate;if(l!==null&&(s=l.child,s!==null)){l.child=null;do l=s.sibling,s.sibling=null,s=l;while(s!==null)}}function T0(s){var l=s.deletions;if((s.flags&16)!==0){if(l!==null)for(var m=0;m<l.length;m++){var _=l[m];Vn=_,Jy(_,s)}qy(s)}if(s.subtreeFlags&10256)for(s=s.child;s!==null;)Ky(s),s=s.sibling}function Ky(s){switch(s.tag){case 0:case 11:case 15:T0(s),s.flags&2048&&Cl(9,s,s.return);break;case 3:T0(s);break;case 12:T0(s);break;case 22:var l=s.stateNode;s.memoizedState!==null&&l._visibility&2&&(s.return===null||s.return.tag!==13)?(l._visibility&=-3,gh(s)):T0(s);break;default:T0(s)}}function gh(s){var l=s.deletions;if((s.flags&16)!==0){if(l!==null)for(var m=0;m<l.length;m++){var _=l[m];Vn=_,Jy(_,s)}qy(s)}for(s=s.child;s!==null;){switch(l=s,l.tag){case 0:case 11:case 15:Cl(8,l,l.return),gh(l);break;case 22:m=l.stateNode,m._visibility&2&&(m._visibility&=-3,gh(l));break;default:gh(l)}s=s.sibling}}function Jy(s,l){for(;Vn!==null;){var m=Vn;switch(m.tag){case 0:case 11:case 15:Cl(8,m,l);break;case 23:case 22:if(m.memoizedState!==null&&m.memoizedState.cachePool!==null){var _=m.memoizedState.cachePool.pool;_!=null&&_.refCount++}break;case 24:h0(m.memoizedState.cache)}if(_=m.child,_!==null)_.return=m,Vn=_;else e:for(m=s;Vn!==null;){_=Vn;var T=_.sibling,M=_.return;if(Hy(_),_===m){Vn=null;break e}if(T!==null){T.return=M,Vn=T;break e}Vn=M}}}var lN={getCacheForType:function(s){var l=ts(kn),m=l.data.get(s);return m===void 0&&(m=s(),l.data.set(s,m)),m},cacheSignal:function(){return ts(kn).controller.signal}},cN=typeof WeakMap=="function"?WeakMap:Map,ka=0,Va=null,aa=null,sa=0,ja=0,li=null,El=!1,id=!1,kg=!1,Yo=0,un=0,jl=0,pc=0,Ng=0,ci=0,od=0,A0=null,Vs=null,Sg=!1,xh=0,Qy=0,ph=1/0,yh=null,Tl=null,Ln=0,Al=null,ld=null,Zo=0,Cg=0,Eg=null,eb=null,O0=0,jg=null;function di(){return(ka&2)!==0&&sa!==0?sa&-sa:me.T!==null?Dg():de()}function tb(){if(ci===0)if((sa&536870912)===0||ra){var s=Jt;Jt<<=1,(Jt&3932160)===0&&(Jt=262144),ci=s}else ci=536870912;return s=ii.current,s!==null&&(s.flags|=32),ci}function Ws(s,l,m){(s===Va&&(ja===2||ja===9)||s.cancelPendingCommit!==null)&&(cd(s,0),Ol(s,sa,ci,!1)),jr(s,m),((ka&2)===0||s!==Va)&&(s===Va&&((ka&2)===0&&(pc|=m),un===4&&Ol(s,sa,ci,!1)),xo(s))}function rb(s,l,m){if((ka&6)!==0)throw Error(n(327));var _=!m&&(l&127)===0&&(l&s.expiredLanes)===0||qe(s,l),T=_?hN(s,l):Ag(s,l,!0),M=_;do{if(T===0){id&&!_&&Ol(s,l,0,!1);break}else{if(m=s.current.alternate,M&&!dN(m)){T=Ag(s,l,!1),M=!1;continue}if(T===2){if(M=l,s.errorRecoveryDisabledLanes&M)var q=0;else q=s.pendingLanes&-536870913,q=q!==0?q:q&536870912?536870912:0;if(q!==0){l=q;e:{var pe=s;T=A0;var Ie=pe.current.memoizedState.isDehydrated;if(Ie&&(cd(pe,q).flags|=256),q=Ag(pe,q,!1),q!==2){if(kg&&!Ie){pe.errorRecoveryDisabledLanes|=M,pc|=M,T=4;break e}M=Vs,Vs=T,M!==null&&(Vs===null?Vs=M:Vs.push.apply(Vs,M))}T=q}if(M=!1,T!==2)continue}}if(T===1){cd(s,0),Ol(s,l,0,!0);break}e:{switch(_=s,M=T,M){case 0:case 1:throw Error(n(345));case 4:if((l&4194048)!==l)break;case 6:Ol(_,l,ci,!El);break e;case 2:Vs=null;break;case 3:case 5:break;default:throw Error(n(329))}if((l&62914560)===l&&(T=xh+300-it(),10<T)){if(Ol(_,l,ci,!El),Le(_,0,!0)!==0)break e;Zo=l,_.timeoutHandle=Mb(ab.bind(null,_,m,Vs,yh,Sg,l,ci,pc,od,El,M,"Throttled",-0,0),T);break e}ab(_,m,Vs,yh,Sg,l,ci,pc,od,El,M,null,-0,0)}}break}while(!0);xo(s)}function ab(s,l,m,_,T,M,q,pe,Ie,ot,Et,Mt,dt,xt){if(s.timeoutHandle=-1,Mt=l.subtreeFlags,Mt&8192||(Mt&16785408)===16785408){Mt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:On},Zy(l,M,Mt);var br=(M&62914560)===M?xh-it():(M&4194048)===M?Qy-it():0;if(br=YN(Mt,br),br!==null){Zo=M,s.cancelPendingCommit=br(ub.bind(null,s,l,M,m,_,T,q,pe,Ie,Et,Mt,null,dt,xt)),Ol(s,M,q,!ot);return}}ub(s,l,M,m,_,T,q,pe,Ie)}function dN(s){for(var l=s;;){var m=l.tag;if((m===0||m===11||m===15)&&l.flags&16384&&(m=l.updateQueue,m!==null&&(m=m.stores,m!==null)))for(var _=0;_<m.length;_++){var T=m[_],M=T.getSnapshot;T=T.value;try{if(!w(M(),T))return!1}catch(q){return!1}}if(m=l.child,l.subtreeFlags&16384&&m!==null)m.return=l,l=m;else{if(l===s)break;for(;l.sibling===null;){if(l.return===null||l.return===s)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function Ol(s,l,m,_){l&=~Ng,l&=~pc,s.suspendedLanes|=l,s.pingedLanes&=~l,_&&(s.warmLanes|=l),_=s.expirationTimes;for(var T=l;0<T;){var M=31-lt(T),q=1<<M;_[M]=-1,T&=~q}m!==0&&en(s,m,l)}function bh(){return(ka&6)===0?(R0(0),!1):!0}function Tg(){if(aa!==null){if(ja===0)var s=aa.return;else s=aa,$i=mo=null,Gm(s),Qc=null,m0=0,s=aa;for(;s!==null;)Dy(s.alternate,s),s=s.return;aa=null}}function cd(s,l){var m=s.timeoutHandle;m!==-1&&(s.timeoutHandle=-1,AN(m)),m=s.cancelPendingCommit,m!==null&&(s.cancelPendingCommit=null,m()),Zo=0,Tg(),Va=s,aa=m=Si(s.current,null),sa=l,ja=0,li=null,El=!1,id=qe(s,l),kg=!1,od=ci=Ng=pc=jl=un=0,Vs=A0=null,Sg=!1,(l&8)!==0&&(l|=l&32);var _=s.entangledLanes;if(_!==0)for(s=s.entanglements,_&=l;0<_;){var T=31-lt(_),M=1<<T;l|=s[T],_&=~M}return Yo=l,nc(),m}function nb(s,l){Gr=null,me.H=w0,l===Jc||l===Yu?(l=v1(),ja=3):l===Mm?(l=v1(),ja=4):ja=l===og?8:l!==null&&typeof l=="object"&&typeof l.then=="function"?6:1,li=l,aa===null&&(un=1,lh(s,v(l,s.current)))}function sb(){var s=ii.current;return s===null?!0:(sa&4194048)===sa?Ci===null:(sa&62914560)===sa||(sa&536870912)!==0?s===Ci:!1}function ib(){var s=me.H;return me.H=w0,s===null?w0:s}function ob(){var s=me.A;return me.A=lN,s}function vh(){un=4,El||(sa&4194048)!==sa&&ii.current!==null||(id=!0),(jl&134217727)===0&&(pc&134217727)===0||Va===null||Ol(Va,sa,ci,!1)}function Ag(s,l,m){var _=ka;ka|=2;var T=ib(),M=ob();(Va!==s||sa!==l)&&(yh=null,cd(s,l)),l=!1;var q=un;e:do try{if(ja!==0&&aa!==null){var pe=aa,Ie=li;switch(ja){case 8:Tg(),q=6;break e;case 3:case 2:case 9:case 6:ii.current===null&&(l=!0);var ot=ja;if(ja=0,li=null,dd(s,pe,Ie,ot),m&&id){q=0;break e}break;default:ot=ja,ja=0,li=null,dd(s,pe,Ie,ot)}}uN(),q=un;break}catch(Et){nb(s,Et)}while(!0);return l&&s.shellSuspendCounter++,$i=mo=null,ka=_,me.H=T,me.A=M,aa===null&&(Va=null,sa=0,nc()),q}function uN(){for(;aa!==null;)lb(aa)}function hN(s,l){var m=ka;ka|=2;var _=ib(),T=ob();Va!==s||sa!==l?(yh=null,ph=it()+500,cd(s,l)):id=qe(s,l);e:do try{if(ja!==0&&aa!==null){l=aa;var M=li;t:switch(ja){case 1:ja=0,li=null,dd(s,l,M,1);break;case 2:case 9:if(y1(M)){ja=0,li=null,cb(l);break}l=function(){ja!==2&&ja!==9||Va!==s||(ja=7),xo(s)},M.then(l,l);break e;case 3:ja=7;break e;case 4:ja=5;break e;case 7:y1(M)?(ja=0,li=null,cb(l)):(ja=0,li=null,dd(s,l,M,7));break;case 5:var q=null;switch(aa.tag){case 26:q=aa.memoizedState;case 5:case 27:var pe=aa;if(q?Yb(q):pe.stateNode.complete){ja=0,li=null;var Ie=pe.sibling;if(Ie!==null)aa=Ie;else{var ot=pe.return;ot!==null?(aa=ot,_h(ot)):aa=null}break t}}ja=0,li=null,dd(s,l,M,5);break;case 6:ja=0,li=null,dd(s,l,M,6);break;case 8:Tg(),un=6;break e;default:throw Error(n(462))}}fN();break}catch(Et){nb(s,Et)}while(!0);return $i=mo=null,me.H=_,me.A=T,ka=m,aa!==null?0:(Va=null,sa=0,nc(),un)}function fN(){for(;aa!==null&&!Br();)lb(aa)}function lb(s){var l=Ry(s.alternate,s,Yo);s.memoizedProps=s.pendingProps,l===null?_h(s):aa=l}function cb(s){var l=s,m=l.alternate;switch(l.tag){case 15:case 0:l=Cy(m,l,l.pendingProps,l.type,void 0,sa);break;case 11:l=Cy(m,l,l.pendingProps,l.type.render,l.ref,sa);break;case 5:Gm(l);default:Dy(m,l),l=aa=o0(l,Yo),l=Ry(m,l,Yo)}s.memoizedProps=s.pendingProps,l===null?_h(s):aa=l}function dd(s,l,m,_){$i=mo=null,Gm(l),Qc=null,m0=0;var T=l.return;try{if(tN(s,T,l,m,sa)){un=1,lh(s,v(m,s.current)),aa=null;return}}catch(M){if(T!==null)throw aa=T,M;un=1,lh(s,v(m,s.current)),aa=null;return}l.flags&32768?(ra||_===1?s=!0:id||(sa&536870912)!==0?s=!1:(El=s=!0,(_===2||_===9||_===3||_===6)&&(_=ii.current,_!==null&&_.tag===13&&(_.flags|=16384))),db(l,s)):_h(l)}function _h(s){var l=s;do{if((l.flags&32768)!==0){db(l,El);return}s=l.return;var m=nN(l.alternate,l,Yo);if(m!==null){aa=m;return}if(l=l.sibling,l!==null){aa=l;return}aa=l=s}while(l!==null);un===0&&(un=5)}function db(s,l){do{var m=sN(s.alternate,s);if(m!==null){m.flags&=32767,aa=m;return}if(m=s.return,m!==null&&(m.flags|=32768,m.subtreeFlags=0,m.deletions=null),!l&&(s=s.sibling,s!==null)){aa=s;return}aa=s=m}while(s!==null);un=6,aa=null}function ub(s,l,m,_,T,M,q,pe,Ie){s.cancelPendingCommit=null;do wh();while(Ln!==0);if((ka&6)!==0)throw Error(n(327));if(l!==null){if(l===s.current)throw Error(n(177));if(M=l.lanes|l.childLanes,M|=Gc,Zr(s,m,M,q,pe,Ie),s===Va&&(aa=Va=null,sa=0),ld=l,Al=s,Zo=m,Cg=M,Eg=T,eb=_,(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?(s.callbackNode=null,s.callbackPriority=0,pN(vt,function(){return xb(),null})):(s.callbackNode=null,s.callbackPriority=0),_=(l.flags&13878)!==0,(l.subtreeFlags&13878)!==0||_){_=me.T,me.T=null,T=K.p,K.p=2,q=ka,ka|=4;try{iN(s,l,m)}finally{ka=q,K.p=T,me.T=_}}Ln=1,hb(),fb(),mb()}}function hb(){if(Ln===1){Ln=0;var s=Al,l=ld,m=(l.flags&13878)!==0;if((l.subtreeFlags&13878)!==0||m){m=me.T,me.T=null;var _=K.p;K.p=2;var T=ka;ka|=4;try{$y(l,s);var M=Hg,q=te(s.containerInfo),pe=M.focusedElem,Ie=M.selectionRange;if(q!==pe&&pe&&pe.ownerDocument&&X(pe.ownerDocument.documentElement,pe)){if(Ie!==null&&ue(pe)){var ot=Ie.start,Et=Ie.end;if(Et===void 0&&(Et=ot),"selectionStart"in pe)pe.selectionStart=ot,pe.selectionEnd=Math.min(Et,pe.value.length);else{var Mt=pe.ownerDocument||document,dt=Mt&&Mt.defaultView||window;if(dt.getSelection){var xt=dt.getSelection(),br=pe.textContent.length,Pr=Math.min(Ie.start,br),Pa=Ie.end===void 0?Pr:Math.min(Ie.end,br);!xt.extend&&Pr>Pa&&(q=Pa,Pa=Pr,Pr=q);var Xe=P(pe,Pr),He=P(pe,Pa);if(Xe&&He&&(xt.rangeCount!==1||xt.anchorNode!==Xe.node||xt.anchorOffset!==Xe.offset||xt.focusNode!==He.node||xt.focusOffset!==He.offset)){var st=Mt.createRange();st.setStart(Xe.node,Xe.offset),xt.removeAllRanges(),Pr>Pa?(xt.addRange(st),xt.extend(He.node,He.offset)):(st.setEnd(He.node,He.offset),xt.addRange(st))}}}}for(Mt=[],xt=pe;xt=xt.parentNode;)xt.nodeType===1&&Mt.push({element:xt,left:xt.scrollLeft,top:xt.scrollTop});for(typeof pe.focus=="function"&&pe.focus(),pe=0;pe<Mt.length;pe++){var Tt=Mt[pe];Tt.element.scrollLeft=Tt.left,Tt.element.scrollTop=Tt.top}}Dh=!!zg,Hg=zg=null}finally{ka=T,K.p=_,me.T=m}}s.current=l,Ln=2}}function fb(){if(Ln===2){Ln=0;var s=Al,l=ld,m=(l.flags&8772)!==0;if((l.subtreeFlags&8772)!==0||m){m=me.T,me.T=null;var _=K.p;K.p=2;var T=ka;ka|=4;try{zy(s,l.alternate,l)}finally{ka=T,K.p=_,me.T=m}}Ln=3}}function mb(){if(Ln===4||Ln===3){Ln=0,Pt();var s=Al,l=ld,m=Zo,_=eb;(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?Ln=5:(Ln=0,ld=Al=null,gb(s,s.pendingLanes));var T=s.pendingLanes;if(T===0&&(Tl=null),Ut(m),l=l.stateNode,We&&typeof We.onCommitFiberRoot=="function")try{We.onCommitFiberRoot(Ge,l,void 0,(l.current.flags&128)===128)}catch(Ie){}if(_!==null){l=me.T,T=K.p,K.p=2,me.T=null;try{for(var M=s.onRecoverableError,q=0;q<_.length;q++){var pe=_[q];M(pe.value,{componentStack:pe.stack})}}finally{me.T=l,K.p=T}}(Zo&3)!==0&&wh(),xo(s),T=s.pendingLanes,(m&261930)!==0&&(T&42)!==0?s===jg?O0++:(O0=0,jg=s):O0=0,R0(0)}}function gb(s,l){(s.pooledCacheLanes&=l)===0&&(l=s.pooledCache,l!=null&&(s.pooledCache=null,h0(l)))}function wh(){return hb(),fb(),mb(),xb()}function xb(){if(Ln!==5)return!1;var s=Al,l=Cg;Cg=0;var m=Ut(Zo),_=me.T,T=K.p;try{K.p=32>m?32:m,me.T=null,m=Eg,Eg=null;var M=Al,q=Zo;if(Ln=0,ld=Al=null,Zo=0,(ka&6)!==0)throw Error(n(331));var pe=ka;if(ka|=4,Ky(M.current),Yy(M,M.current,q,m),ka=pe,R0(0,!1),We&&typeof We.onPostCommitFiberRoot=="function")try{We.onPostCommitFiberRoot(Ge,M)}catch(Ie){}return!0}finally{K.p=T,me.T=_,gb(s,l)}}function pb(s,l,m){l=v(m,l),l=ig(s.stateNode,l,2),s=kl(s,l,2),s!==null&&(jr(s,2),xo(s))}function Ta(s,l,m){if(s.tag===3)pb(s,s,m);else for(;l!==null;){if(l.tag===3){pb(l,s,m);break}else if(l.tag===1){var _=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof _.componentDidCatch=="function"&&(Tl===null||!Tl.has(_))){s=v(m,s),m=yy(2),_=kl(l,m,2),_!==null&&(by(m,_,l,s),jr(_,2),xo(_));break}}l=l.return}}function Og(s,l,m){var _=s.pingCache;if(_===null){_=s.pingCache=new cN;var T=new Set;_.set(l,T)}else T=_.get(l),T===void 0&&(T=new Set,_.set(l,T));T.has(m)||(kg=!0,T.add(m),s=mN.bind(null,s,l,m),l.then(s,s))}function mN(s,l,m){var _=s.pingCache;_!==null&&_.delete(l),s.pingedLanes|=s.suspendedLanes&m,s.warmLanes&=~m,Va===s&&(sa&m)===m&&(un===4||un===3&&(sa&62914560)===sa&&300>it()-xh?(ka&2)===0&&cd(s,0):Ng|=m,od===sa&&(od=0)),xo(s)}function yb(s,l){l===0&&(l=Yt()),s=Ni(s,l),s!==null&&(jr(s,l),xo(s))}function gN(s){var l=s.memoizedState,m=0;l!==null&&(m=l.retryLane),yb(s,m)}function xN(s,l){var m=0;switch(s.tag){case 31:case 13:var _=s.stateNode,T=s.memoizedState;T!==null&&(m=T.retryLane);break;case 19:_=s.stateNode;break;case 22:_=s.stateNode._retryCache;break;default:throw Error(n(314))}_!==null&&_.delete(l),yb(s,m)}function pN(s,l){return Er(s,l)}var kh=null,ud=null,Rg=!1,Nh=!1,Mg=!1,Rl=0;function xo(s){s!==ud&&s.next===null&&(ud===null?kh=ud=s:ud=ud.next=s),Nh=!0,Rg||(Rg=!0,bN())}function R0(s,l){if(!Mg&&Nh){Mg=!0;do for(var m=!1,_=kh;_!==null;){if(s!==0){var T=_.pendingLanes;if(T===0)var M=0;else{var q=_.suspendedLanes,pe=_.pingedLanes;M=(1<<31-lt(42|s)+1)-1,M&=T&~(q&~pe),M=M&201326741?M&201326741|1:M?M|2:0}M!==0&&(m=!0,wb(_,M))}else M=sa,M=Le(_,_===Va?M:0,_.cancelPendingCommit!==null||_.timeoutHandle!==-1),(M&3)===0||qe(_,M)||(m=!0,wb(_,M));_=_.next}while(m);Mg=!1}}function yN(){bb()}function bb(){Nh=Rg=!1;var s=0;Rl!==0&&TN()&&(s=Rl);for(var l=it(),m=null,_=kh;_!==null;){var T=_.next,M=vb(_,l);M===0?(_.next=null,m===null?kh=T:m.next=T,T===null&&(ud=m)):(m=_,(s!==0||(M&3)!==0)&&(Nh=!0)),_=T}Ln!==0&&Ln!==5||R0(s),Rl!==0&&(Rl=0)}function vb(s,l){for(var m=s.suspendedLanes,_=s.pingedLanes,T=s.expirationTimes,M=s.pendingLanes&-62914561;0<M;){var q=31-lt(M),pe=1<<q,Ie=T[q];Ie===-1?((pe&m)===0||(pe&_)!==0)&&(T[q]=Ke(pe,l)):Ie<=l&&(s.expiredLanes|=pe),M&=~pe}if(l=Va,m=sa,m=Le(s,s===l?m:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),_=s.callbackNode,m===0||s===l&&(ja===2||ja===9)||s.cancelPendingCommit!==null)return _!==null&&_!==null&&St(_),s.callbackNode=null,s.callbackPriority=0;if((m&3)===0||qe(s,m)){if(l=m&-m,l===s.callbackPriority)return l;switch(_!==null&&St(_),Ut(m)){case 2:case 8:m=Be;break;case 32:m=vt;break;case 268435456:m=Ct;break;default:m=vt}return _=_b.bind(null,s),m=Er(m,_),s.callbackPriority=l,s.callbackNode=m,l}return _!==null&&_!==null&&St(_),s.callbackPriority=2,s.callbackNode=null,2}function _b(s,l){if(Ln!==0&&Ln!==5)return s.callbackNode=null,s.callbackPriority=0,null;var m=s.callbackNode;if(wh()&&s.callbackNode!==m)return null;var _=sa;return _=Le(s,s===Va?_:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),_===0?null:(rb(s,_,l),vb(s,it()),s.callbackNode!=null&&s.callbackNode===m?_b.bind(null,s):null)}function wb(s,l){if(wh())return null;rb(s,l,!0)}function bN(){ON(function(){(ka&6)!==0?Er(Je,yN):bb()})}function Dg(){if(Rl===0){var s=qc;s===0&&(s=pt,pt<<=1,(pt&261888)===0&&(pt=256)),Rl=s}return Rl}function kb(s){return s==null||typeof s=="symbol"||typeof s=="boolean"?null:typeof s=="function"?s:vi(""+s)}function Nb(s,l){var m=l.ownerDocument.createElement("input");return m.name=l.name,m.value=l.value,s.id&&m.setAttribute("form",s.id),l.parentNode.insertBefore(m,l),s=new FormData(s),m.parentNode.removeChild(m),s}function vN(s,l,m,_,T){if(l==="submit"&&m&&m.stateNode===T){var M=kb((T[ke]||null).action),q=_.submitter;q&&(l=(l=q[ke]||null)?kb(l.formAction):q.getAttribute("formAction"),l!==null&&(M=l,q=null));var pe=new pn("action","action",null,_,T);s.push({event:pe,listeners:[{instance:null,listener:function(){if(_.defaultPrevented){if(Rl!==0){var Ie=q?Nb(T,q):new FormData(T);eg(m,{pending:!0,data:Ie,method:T.method,action:M},null,Ie)}}else typeof M=="function"&&(pe.preventDefault(),Ie=q?Nb(T,q):new FormData(T),eg(m,{pending:!0,data:Ie,method:T.method,action:M},M,Ie))},currentTarget:T}]})}}for(var Lg=0;Lg<ki.length;Lg++){var Ig=ki[Lg],_N=Ig.toLowerCase(),wN=Ig[0].toUpperCase()+Ig.slice(1);Ps(_N,"on"+wN)}Ps(Rn,"onAnimationEnd"),Ps(Mn,"onAnimationIteration"),Ps(ca,"onAnimationStart"),Ps("dblclick","onDoubleClick"),Ps("focusin","onFocus"),Ps("focusout","onBlur"),Ps(bn,"onTransitionRun"),Ps(Hn,"onTransitionStart"),Ps(co,"onTransitionCancel"),Ps(Ss,"onTransitionEnd"),qr("onMouseEnter",["mouseout","mouseover"]),qr("onMouseLeave",["mouseout","mouseover"]),qr("onPointerEnter",["pointerout","pointerover"]),qr("onPointerLeave",["pointerout","pointerover"]),xr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),xr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),xr("onBeforeInput",["compositionend","keypress","textInput","paste"]),xr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),xr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),xr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var M0="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(" "),kN=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(M0));function Sb(s,l){l=(l&4)!==0;for(var m=0;m<s.length;m++){var _=s[m],T=_.event;_=_.listeners;e:{var M=void 0;if(l)for(var q=_.length-1;0<=q;q--){var pe=_[q],Ie=pe.instance,ot=pe.currentTarget;if(pe=pe.listener,Ie!==M&&T.isPropagationStopped())break e;M=pe,T.currentTarget=ot;try{M(T)}catch(Et){ac(Et)}T.currentTarget=null,M=Ie}else for(q=0;q<_.length;q++){if(pe=_[q],Ie=pe.instance,ot=pe.currentTarget,pe=pe.listener,Ie!==M&&T.isPropagationStopped())break e;M=pe,T.currentTarget=ot;try{M(T)}catch(Et){ac(Et)}T.currentTarget=null,M=Ie}}}}function na(s,l){var m=l[Qe];m===void 0&&(m=l[Qe]=new Set);var _=s+"__bubble";m.has(_)||(Cb(l,s,2,!1),m.add(_))}function Pg(s,l,m){var _=0;l&&(_|=4),Cb(m,s,_,l)}var Sh="_reactListening"+Math.random().toString(36).slice(2);function Fg(s){if(!s[Sh]){s[Sh]=!0,Ee.forEach(function(m){m!=="selectionchange"&&(kN.has(m)||Pg(m,!1,s),Pg(m,!0,s))});var l=s.nodeType===9?s:s.ownerDocument;l===null||l[Sh]||(l[Sh]=!0,Pg("selectionchange",!1,l))}}function Cb(s,l,m,_){switch(t2(l)){case 2:var T=KN;break;case 8:T=JN;break;default:T=Qg}m=T.bind(null,l,m,s),T=void 0,!Oo||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(T=!0),_?T!==void 0?s.addEventListener(l,m,{capture:!0,passive:T}):s.addEventListener(l,m,!0):T!==void 0?s.addEventListener(l,m,{passive:T}):s.addEventListener(l,m,!1)}function Bg(s,l,m,_,T){var M=_;if((l&1)===0&&(l&2)===0&&_!==null)e:for(;;){if(_===null)return;var q=_.tag;if(q===3||q===4){var pe=_.stateNode.containerInfo;if(pe===T)break;if(q===4)for(q=_.return;q!==null;){var Ie=q.tag;if((Ie===3||Ie===4)&&q.stateNode.containerInfo===T)return;q=q.return}for(;pe!==null;){if(q=It(pe),q===null)return;if(Ie=q.tag,Ie===5||Ie===6||Ie===26||Ie===27){_=M=q;continue e}pe=pe.parentNode}}_=_.return}Ql(function(){var ot=M,Et=Ao(m),Mt=[];e:{var dt=Wc.get(s);if(dt!==void 0){var xt=pn,br=s;switch(s){case"keypress":if(Qs(m)===0)break e;case"keydown":case"keyup":xt=Do;break;case"focusin":br="focus",xt=tc;break;case"focusout":br="blur",xt=tc;break;case"beforeblur":case"afterblur":xt=tc;break;case"click":if(m.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":xt=ha;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":xt=gl;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":xt=s0;break;case Rn:case Mn:case ca:xt=Hr;break;case Ss:xt=wi;break;case"scroll":case"scrollend":xt=Qr;break;case"wheel":xt=Bi;break;case"copy":case"cut":case"paste":xt=Qn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":xt=ga;break;case"toggle":case"beforetoggle":xt=Ui}var Pr=(l&4)!==0,Pa=!Pr&&(s==="scroll"||s==="scrollend"),Xe=Pr?dt!==null?dt+"Capture":null:dt;Pr=[];for(var He=ot,st;He!==null;){var Tt=He;if(st=Tt.stateNode,Tt=Tt.tag,Tt!==5&&Tt!==26&&Tt!==27||st===null||Xe===null||(Tt=Fr(He,Xe),Tt!=null&&Pr.push(D0(He,Tt,st))),Pa)break;He=He.return}0<Pr.length&&(dt=new xt(dt,br,null,m,Et),Mt.push({event:dt,listeners:Pr}))}}if((l&7)===0){e:{if(dt=s==="mouseover"||s==="pointerover",xt=s==="mouseout"||s==="pointerout",dt&&m!==so&&(br=m.relatedTarget||m.fromElement)&&(It(br)||br[Te]))break e;if((xt||dt)&&(dt=Et.window===Et?Et:(dt=Et.ownerDocument)?dt.defaultView||dt.parentWindow:window,xt?(br=m.relatedTarget||m.toElement,xt=ot,br=br?It(br):null,br!==null&&(Pa=c(br),Pr=br.tag,br!==Pa||Pr!==5&&Pr!==27&&Pr!==6)&&(br=null)):(xt=null,br=ot),xt!==br)){if(Pr=ha,Tt="onMouseLeave",Xe="onMouseEnter",He="mouse",(s==="pointerout"||s==="pointerover")&&(Pr=ga,Tt="onPointerLeave",Xe="onPointerEnter",He="pointer"),Pa=xt==null?dt:zt(xt),st=br==null?dt:zt(br),dt=new Pr(Tt,He+"leave",xt,m,Et),dt.target=Pa,dt.relatedTarget=st,Tt=null,It(Et)===ot&&(Pr=new Pr(Xe,He+"enter",br,m,Et),Pr.target=st,Pr.relatedTarget=Pa,Tt=Pr),Pa=Tt,xt&&br)t:{for(Pr=NN,Xe=xt,He=br,st=0,Tt=Xe;Tt;Tt=Pr(Tt))st++;Tt=0;for(var Mr=He;Mr;Mr=Pr(Mr))Tt++;for(;0<st-Tt;)Xe=Pr(Xe),st--;for(;0<Tt-st;)He=Pr(He),Tt--;for(;st--;){if(Xe===He||He!==null&&Xe===He.alternate){Pr=Xe;break t}Xe=Pr(Xe),He=Pr(He)}Pr=null}else Pr=null;xt!==null&&Eb(Mt,dt,xt,Pr,!1),br!==null&&Pa!==null&&Eb(Mt,Pa,br,Pr,!0)}}e:{if(dt=ot?zt(ot):window,xt=dt.nodeName&&dt.nodeName.toLowerCase(),xt==="select"||xt==="input"&&dt.type==="file")var ya=zn;else if(ks(dt))if(Vc)ya=p;else{ya=d;var _r=o}else xt=dt.nodeName,!xt||xt.toLowerCase()!=="input"||dt.type!=="checkbox"&&dt.type!=="radio"?ot&&_a(ot.elementType)&&(ya=zn):ya=f;if(ya&&(ya=ya(s,ot))){Ns(Mt,ya,m,Et);break e}_r&&_r(s,dt,ot),s==="focusout"&&ot&&dt.type==="number"&&ot.memoizedProps.value!=null&&Se(dt,"number",dt.value)}switch(_r=ot?zt(ot):window,s){case"focusin":(ks(_r)||_r.contentEditable==="true")&&(Fe=_r,Ue=ot,tt=null);break;case"focusout":tt=Ue=Fe=null;break;case"mousedown":ut=!0;break;case"contextmenu":case"mouseup":case"dragend":ut=!1,Xt(Mt,m,Et);break;case"selectionchange":if(je)break;case"keydown":case"keyup":Xt(Mt,m,Et)}var Yr;if(io)e:{switch(s){case"compositionstart":var ia="onCompositionStart";break e;case"compositionend":ia="onCompositionEnd";break e;case"compositionupdate":ia="onCompositionUpdate";break e}ia=void 0}else oo?Hc(s,m)&&(ia="onCompositionEnd"):s==="keydown"&&m.keyCode===229&&(ia="onCompositionStart");ia&&(pl&&m.locale!=="ko"&&(oo||ia!=="onCompositionStart"?ia==="onCompositionEnd"&&oo&&(Yr=us()):(ws=Et,qn="value"in ws?ws.value:ws.textContent,oo=!0)),_r=Ch(ot,ia),0<_r.length&&(ia=new rc(ia,s,null,m,Et),Mt.push({event:ia,listeners:_r}),Yr?ia.data=Yr:(Yr=Hi(m),Yr!==null&&(ia.data=Yr)))),(Yr=zc?ln(s,m):si(s,m))&&(ia=Ch(ot,"onBeforeInput"),0<ia.length&&(_r=new rc("onBeforeInput","beforeinput",null,m,Et),Mt.push({event:_r,listeners:ia}),_r.data=Yr)),vN(Mt,s,ot,m,Et)}Sb(Mt,l)})}function D0(s,l,m){return{instance:s,listener:l,currentTarget:m}}function Ch(s,l){for(var m=l+"Capture",_=[];s!==null;){var T=s,M=T.stateNode;if(T=T.tag,T!==5&&T!==26&&T!==27||M===null||(T=Fr(s,m),T!=null&&_.unshift(D0(s,T,M)),T=Fr(s,l),T!=null&&_.push(D0(s,T,M))),s.tag===3)return _;s=s.return}return[]}function NN(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5&&s.tag!==27);return s||null}function Eb(s,l,m,_,T){for(var M=l._reactName,q=[];m!==null&&m!==_;){var pe=m,Ie=pe.alternate,ot=pe.stateNode;if(pe=pe.tag,Ie!==null&&Ie===_)break;pe!==5&&pe!==26&&pe!==27||ot===null||(Ie=ot,T?(ot=Fr(m,M),ot!=null&&q.unshift(D0(m,ot,Ie))):T||(ot=Fr(m,M),ot!=null&&q.push(D0(m,ot,Ie)))),m=m.return}q.length!==0&&s.push({event:l,listeners:q})}var SN=/\r\n?/g,CN=/\u0000|\uFFFD/g;function jb(s){return(typeof s=="string"?s:""+s).replace(SN,`
|
||
`).replace(CN,"")}function Tb(s,l){return l=jb(l),jb(s)===l}function Ia(s,l,m,_,T,M){switch(m){case"children":typeof _=="string"?l==="body"||l==="textarea"&&_===""||Ms(s,_):(typeof _=="number"||typeof _=="bigint")&&l!=="body"&&Ms(s,""+_);break;case"className":Sr(s,"class",_);break;case"tabIndex":Sr(s,"tabindex",_);break;case"dir":case"role":case"viewBox":case"width":case"height":Sr(s,m,_);break;case"style":Nr(s,_,M);break;case"data":if(l!=="object"){Sr(s,"data",_);break}case"src":case"href":if(_===""&&(l!=="a"||m!=="href")){s.removeAttribute(m);break}if(_==null||typeof _=="function"||typeof _=="symbol"||typeof _=="boolean"){s.removeAttribute(m);break}_=vi(""+_),s.setAttribute(m,_);break;case"action":case"formAction":if(typeof _=="function"){s.setAttribute(m,"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 M=="function"&&(m==="formAction"?(l!=="input"&&Ia(s,l,"name",T.name,T,null),Ia(s,l,"formEncType",T.formEncType,T,null),Ia(s,l,"formMethod",T.formMethod,T,null),Ia(s,l,"formTarget",T.formTarget,T,null)):(Ia(s,l,"encType",T.encType,T,null),Ia(s,l,"method",T.method,T,null),Ia(s,l,"target",T.target,T,null)));if(_==null||typeof _=="symbol"||typeof _=="boolean"){s.removeAttribute(m);break}_=vi(""+_),s.setAttribute(m,_);break;case"onClick":_!=null&&(s.onclick=On);break;case"onScroll":_!=null&&na("scroll",s);break;case"onScrollEnd":_!=null&&na("scrollend",s);break;case"dangerouslySetInnerHTML":if(_!=null){if(typeof _!="object"||!("__html"in _))throw Error(n(61));if(m=_.__html,m!=null){if(T.children!=null)throw Error(n(60));s.innerHTML=m}}break;case"multiple":s.multiple=_&&typeof _!="function"&&typeof _!="symbol";break;case"muted":s.muted=_&&typeof _!="function"&&typeof _!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(_==null||typeof _=="function"||typeof _=="boolean"||typeof _=="symbol"){s.removeAttribute("xlink:href");break}m=vi(""+_),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",m);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":_!=null&&typeof _!="function"&&typeof _!="symbol"?s.setAttribute(m,""+_):s.removeAttribute(m);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":_&&typeof _!="function"&&typeof _!="symbol"?s.setAttribute(m,""):s.removeAttribute(m);break;case"capture":case"download":_===!0?s.setAttribute(m,""):_!==!1&&_!=null&&typeof _!="function"&&typeof _!="symbol"?s.setAttribute(m,_):s.removeAttribute(m);break;case"cols":case"rows":case"size":case"span":_!=null&&typeof _!="function"&&typeof _!="symbol"&&!isNaN(_)&&1<=_?s.setAttribute(m,_):s.removeAttribute(m);break;case"rowSpan":case"start":_==null||typeof _=="function"||typeof _=="symbol"||isNaN(_)?s.removeAttribute(m):s.setAttribute(m,_);break;case"popover":na("beforetoggle",s),na("toggle",s),kt(s,"popover",_);break;case"xlinkActuate":la(s,"http://www.w3.org/1999/xlink","xlink:actuate",_);break;case"xlinkArcrole":la(s,"http://www.w3.org/1999/xlink","xlink:arcrole",_);break;case"xlinkRole":la(s,"http://www.w3.org/1999/xlink","xlink:role",_);break;case"xlinkShow":la(s,"http://www.w3.org/1999/xlink","xlink:show",_);break;case"xlinkTitle":la(s,"http://www.w3.org/1999/xlink","xlink:title",_);break;case"xlinkType":la(s,"http://www.w3.org/1999/xlink","xlink:type",_);break;case"xmlBase":la(s,"http://www.w3.org/XML/1998/namespace","xml:base",_);break;case"xmlLang":la(s,"http://www.w3.org/XML/1998/namespace","xml:lang",_);break;case"xmlSpace":la(s,"http://www.w3.org/XML/1998/namespace","xml:space",_);break;case"is":kt(s,"is",_);break;case"innerText":case"textContent":break;default:(!(2<m.length)||m[0]!=="o"&&m[0]!=="O"||m[1]!=="n"&&m[1]!=="N")&&(m=To.get(m)||m,kt(s,m,_))}}function Ug(s,l,m,_,T,M){switch(m){case"style":Nr(s,_,M);break;case"dangerouslySetInnerHTML":if(_!=null){if(typeof _!="object"||!("__html"in _))throw Error(n(61));if(m=_.__html,m!=null){if(T.children!=null)throw Error(n(60));s.innerHTML=m}}break;case"children":typeof _=="string"?Ms(s,_):(typeof _=="number"||typeof _=="bigint")&&Ms(s,""+_);break;case"onScroll":_!=null&&na("scroll",s);break;case"onScrollEnd":_!=null&&na("scrollend",s);break;case"onClick":_!=null&&(s.onclick=On);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!wt.hasOwnProperty(m))e:{if(m[0]==="o"&&m[1]==="n"&&(T=m.endsWith("Capture"),l=m.slice(2,T?m.length-7:void 0),M=s[ke]||null,M=M!=null?M[m]:null,typeof M=="function"&&s.removeEventListener(l,M,T),typeof _=="function")){typeof M!="function"&&M!==null&&(m in s?s[m]=null:s.hasAttribute(m)&&s.removeAttribute(m)),s.addEventListener(l,_,T);break e}m in s?s[m]=_:_===!0?s.setAttribute(m,""):kt(s,m,_)}}}function as(s,l,m){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":na("error",s),na("load",s);var _=!1,T=!1,M;for(M in m)if(m.hasOwnProperty(M)){var q=m[M];if(q!=null)switch(M){case"src":_=!0;break;case"srcSet":T=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(n(137,l));default:Ia(s,l,M,q,m,null)}}T&&Ia(s,l,"srcSet",m.srcSet,m,null),_&&Ia(s,l,"src",m.src,m,null);return;case"input":na("invalid",s);var pe=M=q=T=null,Ie=null,ot=null;for(_ in m)if(m.hasOwnProperty(_)){var Et=m[_];if(Et!=null)switch(_){case"name":T=Et;break;case"type":q=Et;break;case"checked":Ie=Et;break;case"defaultChecked":ot=Et;break;case"value":M=Et;break;case"defaultValue":pe=Et;break;case"children":case"dangerouslySetInnerHTML":if(Et!=null)throw Error(n(137,l));break;default:Ia(s,l,_,Et,m,null)}}rt(s,M,pe,Ie,ot,q,T,!1);return;case"select":na("invalid",s),_=q=M=null;for(T in m)if(m.hasOwnProperty(T)&&(pe=m[T],pe!=null))switch(T){case"value":M=pe;break;case"defaultValue":q=pe;break;case"multiple":_=pe;default:Ia(s,l,T,pe,m,null)}l=M,m=q,s.multiple=!!_,l!=null?sr(s,!!_,l,!1):m!=null&&sr(s,!!_,m,!0);return;case"textarea":na("invalid",s),M=T=_=null;for(q in m)if(m.hasOwnProperty(q)&&(pe=m[q],pe!=null))switch(q){case"value":_=pe;break;case"defaultValue":T=pe;break;case"children":M=pe;break;case"dangerouslySetInnerHTML":if(pe!=null)throw Error(n(91));break;default:Ia(s,l,q,pe,m,null)}gn(s,_,T,M);return;case"option":for(Ie in m)if(m.hasOwnProperty(Ie)&&(_=m[Ie],_!=null))switch(Ie){case"selected":s.selected=_&&typeof _!="function"&&typeof _!="symbol";break;default:Ia(s,l,Ie,_,m,null)}return;case"dialog":na("beforetoggle",s),na("toggle",s),na("cancel",s),na("close",s);break;case"iframe":case"object":na("load",s);break;case"video":case"audio":for(_=0;_<M0.length;_++)na(M0[_],s);break;case"image":na("error",s),na("load",s);break;case"details":na("toggle",s);break;case"embed":case"source":case"link":na("error",s),na("load",s);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ot in m)if(m.hasOwnProperty(ot)&&(_=m[ot],_!=null))switch(ot){case"children":case"dangerouslySetInnerHTML":throw Error(n(137,l));default:Ia(s,l,ot,_,m,null)}return;default:if(_a(l)){for(Et in m)m.hasOwnProperty(Et)&&(_=m[Et],_!==void 0&&Ug(s,l,Et,_,m,void 0));return}}for(pe in m)m.hasOwnProperty(pe)&&(_=m[pe],_!=null&&Ia(s,l,pe,_,m,null))}function EN(s,l,m,_){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var T=null,M=null,q=null,pe=null,Ie=null,ot=null,Et=null;for(xt in m){var Mt=m[xt];if(m.hasOwnProperty(xt)&&Mt!=null)switch(xt){case"checked":break;case"value":break;case"defaultValue":Ie=Mt;default:_.hasOwnProperty(xt)||Ia(s,l,xt,null,_,Mt)}}for(var dt in _){var xt=_[dt];if(Mt=m[dt],_.hasOwnProperty(dt)&&(xt!=null||Mt!=null))switch(dt){case"type":M=xt;break;case"name":T=xt;break;case"checked":ot=xt;break;case"defaultChecked":Et=xt;break;case"value":q=xt;break;case"defaultValue":pe=xt;break;case"children":case"dangerouslySetInnerHTML":if(xt!=null)throw Error(n(137,l));break;default:xt!==Mt&&Ia(s,l,dt,xt,_,Mt)}}sn(s,q,pe,Ie,ot,Et,M,T);return;case"select":xt=q=pe=dt=null;for(M in m)if(Ie=m[M],m.hasOwnProperty(M)&&Ie!=null)switch(M){case"value":break;case"multiple":xt=Ie;default:_.hasOwnProperty(M)||Ia(s,l,M,null,_,Ie)}for(T in _)if(M=_[T],Ie=m[T],_.hasOwnProperty(T)&&(M!=null||Ie!=null))switch(T){case"value":dt=M;break;case"defaultValue":pe=M;break;case"multiple":q=M;default:M!==Ie&&Ia(s,l,T,M,_,Ie)}l=pe,m=q,_=xt,dt!=null?sr(s,!!m,dt,!1):!!_!=!!m&&(l!=null?sr(s,!!m,l,!0):sr(s,!!m,m?[]:"",!1));return;case"textarea":xt=dt=null;for(pe in m)if(T=m[pe],m.hasOwnProperty(pe)&&T!=null&&!_.hasOwnProperty(pe))switch(pe){case"value":break;case"children":break;default:Ia(s,l,pe,null,_,T)}for(q in _)if(T=_[q],M=m[q],_.hasOwnProperty(q)&&(T!=null||M!=null))switch(q){case"value":dt=T;break;case"defaultValue":xt=T;break;case"children":break;case"dangerouslySetInnerHTML":if(T!=null)throw Error(n(91));break;default:T!==M&&Ia(s,l,q,T,_,M)}Ea(s,dt,xt);return;case"option":for(var br in m)if(dt=m[br],m.hasOwnProperty(br)&&dt!=null&&!_.hasOwnProperty(br))switch(br){case"selected":s.selected=!1;break;default:Ia(s,l,br,null,_,dt)}for(Ie in _)if(dt=_[Ie],xt=m[Ie],_.hasOwnProperty(Ie)&&dt!==xt&&(dt!=null||xt!=null))switch(Ie){case"selected":s.selected=dt&&typeof dt!="function"&&typeof dt!="symbol";break;default:Ia(s,l,Ie,dt,_,xt)}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 Pr in m)dt=m[Pr],m.hasOwnProperty(Pr)&&dt!=null&&!_.hasOwnProperty(Pr)&&Ia(s,l,Pr,null,_,dt);for(ot in _)if(dt=_[ot],xt=m[ot],_.hasOwnProperty(ot)&&dt!==xt&&(dt!=null||xt!=null))switch(ot){case"children":case"dangerouslySetInnerHTML":if(dt!=null)throw Error(n(137,l));break;default:Ia(s,l,ot,dt,_,xt)}return;default:if(_a(l)){for(var Pa in m)dt=m[Pa],m.hasOwnProperty(Pa)&&dt!==void 0&&!_.hasOwnProperty(Pa)&&Ug(s,l,Pa,void 0,_,dt);for(Et in _)dt=_[Et],xt=m[Et],!_.hasOwnProperty(Et)||dt===xt||dt===void 0&&xt===void 0||Ug(s,l,Et,dt,_,xt);return}}for(var Xe in m)dt=m[Xe],m.hasOwnProperty(Xe)&&dt!=null&&!_.hasOwnProperty(Xe)&&Ia(s,l,Xe,null,_,dt);for(Mt in _)dt=_[Mt],xt=m[Mt],!_.hasOwnProperty(Mt)||dt===xt||dt==null&&xt==null||Ia(s,l,Mt,dt,_,xt)}function Ab(s){switch(s){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function jN(){if(typeof performance.getEntriesByType=="function"){for(var s=0,l=0,m=performance.getEntriesByType("resource"),_=0;_<m.length;_++){var T=m[_],M=T.transferSize,q=T.initiatorType,pe=T.duration;if(M&&pe&&Ab(q)){for(q=0,pe=T.responseEnd,_+=1;_<m.length;_++){var Ie=m[_],ot=Ie.startTime;if(ot>pe)break;var Et=Ie.transferSize,Mt=Ie.initiatorType;Et&&Ab(Mt)&&(Ie=Ie.responseEnd,q+=Et*(Ie<pe?1:(pe-ot)/(Ie-ot)))}if(--_,l+=8*(M+q)/(T.duration/1e3),s++,10<s)break}}if(0<s)return l/s/1e6}return navigator.connection&&(s=navigator.connection.downlink,typeof s=="number")?s:5}var zg=null,Hg=null;function Eh(s){return s.nodeType===9?s:s.ownerDocument}function Ob(s){switch(s){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Rb(s,l){if(s===0)switch(l){case"svg":return 1;case"math":return 2;default:return 0}return s===1&&l==="foreignObject"?0:s}function Vg(s,l){return s==="textarea"||s==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.children=="bigint"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var Wg=null;function TN(){var s=window.event;return s&&s.type==="popstate"?s===Wg?!1:(Wg=s,!0):(Wg=null,!1)}var Mb=typeof setTimeout=="function"?setTimeout:void 0,AN=typeof clearTimeout=="function"?clearTimeout:void 0,Db=typeof Promise=="function"?Promise:void 0,ON=typeof queueMicrotask=="function"?queueMicrotask:typeof Db!="undefined"?function(s){return Db.resolve(null).then(s).catch(RN)}:Mb;function RN(s){setTimeout(function(){throw s})}function Ml(s){return s==="head"}function Lb(s,l){var m=l,_=0;do{var T=m.nextSibling;if(s.removeChild(m),T&&T.nodeType===8)if(m=T.data,m==="/$"||m==="/&"){if(_===0){s.removeChild(T),gd(l);return}_--}else if(m==="$"||m==="$?"||m==="$~"||m==="$!"||m==="&")_++;else if(m==="html")L0(s.ownerDocument.documentElement);else if(m==="head"){m=s.ownerDocument.head,L0(m);for(var M=m.firstChild;M;){var q=M.nextSibling,pe=M.nodeName;M[nt]||pe==="SCRIPT"||pe==="STYLE"||pe==="LINK"&&M.rel.toLowerCase()==="stylesheet"||m.removeChild(M),M=q}}else m==="body"&&L0(s.ownerDocument.body);m=T}while(m);gd(l)}function Ib(s,l){var m=s;s=0;do{var _=m.nextSibling;if(m.nodeType===1?l?(m._stashedDisplay=m.style.display,m.style.display="none"):(m.style.display=m._stashedDisplay||"",m.getAttribute("style")===""&&m.removeAttribute("style")):m.nodeType===3&&(l?(m._stashedText=m.nodeValue,m.nodeValue=""):m.nodeValue=m._stashedText||""),_&&_.nodeType===8)if(m=_.data,m==="/$"){if(s===0)break;s--}else m!=="$"&&m!=="$?"&&m!=="$~"&&m!=="$!"||s++;m=_}while(m)}function Gg(s){var l=s.firstChild;for(l&&l.nodeType===10&&(l=l.nextSibling);l;){var m=l;switch(l=l.nextSibling,m.nodeName){case"HTML":case"HEAD":case"BODY":Gg(m),Ot(m);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(m.rel.toLowerCase()==="stylesheet")continue}s.removeChild(m)}}function MN(s,l,m,_){for(;s.nodeType===1;){var T=m;if(s.nodeName.toLowerCase()!==l.toLowerCase()){if(!_&&(s.nodeName!=="INPUT"||s.type!=="hidden"))break}else if(_){if(!s[nt])switch(l){case"meta":if(!s.hasAttribute("itemprop"))break;return s;case"link":if(M=s.getAttribute("rel"),M==="stylesheet"&&s.hasAttribute("data-precedence"))break;if(M!==T.rel||s.getAttribute("href")!==(T.href==null||T.href===""?null:T.href)||s.getAttribute("crossorigin")!==(T.crossOrigin==null?null:T.crossOrigin)||s.getAttribute("title")!==(T.title==null?null:T.title))break;return s;case"style":if(s.hasAttribute("data-precedence"))break;return s;case"script":if(M=s.getAttribute("src"),(M!==(T.src==null?null:T.src)||s.getAttribute("type")!==(T.type==null?null:T.type)||s.getAttribute("crossorigin")!==(T.crossOrigin==null?null:T.crossOrigin))&&M&&s.hasAttribute("async")&&!s.hasAttribute("itemprop"))break;return s;default:return s}}else if(l==="input"&&s.type==="hidden"){var M=T.name==null?null:""+T.name;if(T.type==="hidden"&&s.getAttribute("name")===M)return s}else return s;if(s=Ei(s.nextSibling),s===null)break}return null}function DN(s,l,m){if(l==="")return null;for(;s.nodeType!==3;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!m||(s=Ei(s.nextSibling),s===null))return null;return s}function Pb(s,l){for(;s.nodeType!==8;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!l||(s=Ei(s.nextSibling),s===null))return null;return s}function $g(s){return s.data==="$?"||s.data==="$~"}function Xg(s){return s.data==="$!"||s.data==="$?"&&s.ownerDocument.readyState!=="loading"}function LN(s,l){var m=s.ownerDocument;if(s.data==="$~")s._reactRetry=l;else if(s.data!=="$?"||m.readyState!=="loading")l();else{var _=function(){l(),m.removeEventListener("DOMContentLoaded",_)};m.addEventListener("DOMContentLoaded",_),s._reactRetry=_}}function Ei(s){for(;s!=null;s=s.nextSibling){var l=s.nodeType;if(l===1||l===3)break;if(l===8){if(l=s.data,l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"||l==="F!"||l==="F")break;if(l==="/$"||l==="/&")return null}}return s}var Yg=null;function Fb(s){s=s.nextSibling;for(var l=0;s;){if(s.nodeType===8){var m=s.data;if(m==="/$"||m==="/&"){if(l===0)return Ei(s.nextSibling);l--}else m!=="$"&&m!=="$!"&&m!=="$?"&&m!=="$~"&&m!=="&"||l++}s=s.nextSibling}return null}function Bb(s){s=s.previousSibling;for(var l=0;s;){if(s.nodeType===8){var m=s.data;if(m==="$"||m==="$!"||m==="$?"||m==="$~"||m==="&"){if(l===0)return s;l--}else m!=="/$"&&m!=="/&"||l++}s=s.previousSibling}return null}function Ub(s,l,m){switch(l=Eh(m),s){case"html":if(s=l.documentElement,!s)throw Error(n(452));return s;case"head":if(s=l.head,!s)throw Error(n(453));return s;case"body":if(s=l.body,!s)throw Error(n(454));return s;default:throw Error(n(451))}}function L0(s){for(var l=s.attributes;l.length;)s.removeAttributeNode(l[0]);Ot(s)}var ji=new Map,zb=new Set;function jh(s){return typeof s.getRootNode=="function"?s.getRootNode():s.nodeType===9?s:s.ownerDocument}var qo=K.d;K.d={f:IN,r:PN,D:FN,C:BN,L:UN,m:zN,X:VN,S:HN,M:WN};function IN(){var s=qo.f(),l=bh();return s||l}function PN(s){var l=Ht(s);l!==null&&l.tag===5&&l.type==="form"?ny(l):qo.r(s)}var hd=typeof document=="undefined"?null:document;function Hb(s,l,m){var _=hd;if(_&&typeof l=="string"&&l){var T=kr(l);T='link[rel="'+s+'"][href="'+T+'"]',typeof m=="string"&&(T+='[crossorigin="'+m+'"]'),zb.has(T)||(zb.add(T),s={rel:s,crossOrigin:m,href:l},_.querySelector(T)===null&&(l=_.createElement("link"),as(l,"link",s),fr(l),_.head.appendChild(l)))}}function FN(s){qo.D(s),Hb("dns-prefetch",s,null)}function BN(s,l){qo.C(s,l),Hb("preconnect",s,l)}function UN(s,l,m){qo.L(s,l,m);var _=hd;if(_&&s&&l){var T='link[rel="preload"][as="'+kr(l)+'"]';l==="image"&&m&&m.imageSrcSet?(T+='[imagesrcset="'+kr(m.imageSrcSet)+'"]',typeof m.imageSizes=="string"&&(T+='[imagesizes="'+kr(m.imageSizes)+'"]')):T+='[href="'+kr(s)+'"]';var M=T;switch(l){case"style":M=fd(s);break;case"script":M=md(s)}ji.has(M)||(s=N({rel:"preload",href:l==="image"&&m&&m.imageSrcSet?void 0:s,as:l},m),ji.set(M,s),_.querySelector(T)!==null||l==="style"&&_.querySelector(I0(M))||l==="script"&&_.querySelector(P0(M))||(l=_.createElement("link"),as(l,"link",s),fr(l),_.head.appendChild(l)))}}function zN(s,l){qo.m(s,l);var m=hd;if(m&&s){var _=l&&typeof l.as=="string"?l.as:"script",T='link[rel="modulepreload"][as="'+kr(_)+'"][href="'+kr(s)+'"]',M=T;switch(_){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":M=md(s)}if(!ji.has(M)&&(s=N({rel:"modulepreload",href:s},l),ji.set(M,s),m.querySelector(T)===null)){switch(_){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(m.querySelector(P0(M)))return}_=m.createElement("link"),as(_,"link",s),fr(_),m.head.appendChild(_)}}}function HN(s,l,m){qo.S(s,l,m);var _=hd;if(_&&s){var T=Kt(_).hoistableStyles,M=fd(s);l=l||"default";var q=T.get(M);if(!q){var pe={loading:0,preload:null};if(q=_.querySelector(I0(M)))pe.loading=5;else{s=N({rel:"stylesheet",href:s,"data-precedence":l},m),(m=ji.get(M))&&Zg(s,m);var Ie=q=_.createElement("link");fr(Ie),as(Ie,"link",s),Ie._p=new Promise(function(ot,Et){Ie.onload=ot,Ie.onerror=Et}),Ie.addEventListener("load",function(){pe.loading|=1}),Ie.addEventListener("error",function(){pe.loading|=2}),pe.loading|=4,Th(q,l,_)}q={type:"stylesheet",instance:q,count:1,state:pe},T.set(M,q)}}}function VN(s,l){qo.X(s,l);var m=hd;if(m&&s){var _=Kt(m).hoistableScripts,T=md(s),M=_.get(T);M||(M=m.querySelector(P0(T)),M||(s=N({src:s,async:!0},l),(l=ji.get(T))&&qg(s,l),M=m.createElement("script"),fr(M),as(M,"link",s),m.head.appendChild(M)),M={type:"script",instance:M,count:1,state:null},_.set(T,M))}}function WN(s,l){qo.M(s,l);var m=hd;if(m&&s){var _=Kt(m).hoistableScripts,T=md(s),M=_.get(T);M||(M=m.querySelector(P0(T)),M||(s=N({src:s,async:!0,type:"module"},l),(l=ji.get(T))&&qg(s,l),M=m.createElement("script"),fr(M),as(M,"link",s),m.head.appendChild(M)),M={type:"script",instance:M,count:1,state:null},_.set(T,M))}}function Vb(s,l,m,_){var T=(T=ve.current)?jh(T):null;if(!T)throw Error(n(446));switch(s){case"meta":case"title":return null;case"style":return typeof m.precedence=="string"&&typeof m.href=="string"?(l=fd(m.href),m=Kt(T).hoistableStyles,_=m.get(l),_||(_={type:"style",instance:null,count:0,state:null},m.set(l,_)),_):{type:"void",instance:null,count:0,state:null};case"link":if(m.rel==="stylesheet"&&typeof m.href=="string"&&typeof m.precedence=="string"){s=fd(m.href);var M=Kt(T).hoistableStyles,q=M.get(s);if(q||(T=T.ownerDocument||T,q={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},M.set(s,q),(M=T.querySelector(I0(s)))&&!M._p&&(q.instance=M,q.state.loading=5),ji.has(s)||(m={rel:"preload",as:"style",href:m.href,crossOrigin:m.crossOrigin,integrity:m.integrity,media:m.media,hrefLang:m.hrefLang,referrerPolicy:m.referrerPolicy},ji.set(s,m),M||GN(T,s,m,q.state))),l&&_===null)throw Error(n(528,""));return q}if(l&&_!==null)throw Error(n(529,""));return null;case"script":return l=m.async,m=m.src,typeof m=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=md(m),m=Kt(T).hoistableScripts,_=m.get(l),_||(_={type:"script",instance:null,count:0,state:null},m.set(l,_)),_):{type:"void",instance:null,count:0,state:null};default:throw Error(n(444,s))}}function fd(s){return'href="'+kr(s)+'"'}function I0(s){return'link[rel="stylesheet"]['+s+"]"}function Wb(s){return N({},s,{"data-precedence":s.precedence,precedence:null})}function GN(s,l,m,_){s.querySelector('link[rel="preload"][as="style"]['+l+"]")?_.loading=1:(l=s.createElement("link"),_.preload=l,l.addEventListener("load",function(){return _.loading|=1}),l.addEventListener("error",function(){return _.loading|=2}),as(l,"link",m),fr(l),s.head.appendChild(l))}function md(s){return'[src="'+kr(s)+'"]'}function P0(s){return"script[async]"+s}function Gb(s,l,m){if(l.count++,l.instance===null)switch(l.type){case"style":var _=s.querySelector('style[data-href~="'+kr(m.href)+'"]');if(_)return l.instance=_,fr(_),_;var T=N({},m,{"data-href":m.href,"data-precedence":m.precedence,href:null,precedence:null});return _=(s.ownerDocument||s).createElement("style"),fr(_),as(_,"style",T),Th(_,m.precedence,s),l.instance=_;case"stylesheet":T=fd(m.href);var M=s.querySelector(I0(T));if(M)return l.state.loading|=4,l.instance=M,fr(M),M;_=Wb(m),(T=ji.get(T))&&Zg(_,T),M=(s.ownerDocument||s).createElement("link"),fr(M);var q=M;return q._p=new Promise(function(pe,Ie){q.onload=pe,q.onerror=Ie}),as(M,"link",_),l.state.loading|=4,Th(M,m.precedence,s),l.instance=M;case"script":return M=md(m.src),(T=s.querySelector(P0(M)))?(l.instance=T,fr(T),T):(_=m,(T=ji.get(M))&&(_=N({},m),qg(_,T)),s=s.ownerDocument||s,T=s.createElement("script"),fr(T),as(T,"link",_),s.head.appendChild(T),l.instance=T);case"void":return null;default:throw Error(n(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(_=l.instance,l.state.loading|=4,Th(_,m.precedence,s));return l.instance}function Th(s,l,m){for(var _=m.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),T=_.length?_[_.length-1]:null,M=T,q=0;q<_.length;q++){var pe=_[q];if(pe.dataset.precedence===l)M=pe;else if(M!==T)break}M?M.parentNode.insertBefore(s,M.nextSibling):(l=m.nodeType===9?m.head:m,l.insertBefore(s,l.firstChild))}function Zg(s,l){s.crossOrigin==null&&(s.crossOrigin=l.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=l.referrerPolicy),s.title==null&&(s.title=l.title)}function qg(s,l){s.crossOrigin==null&&(s.crossOrigin=l.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=l.referrerPolicy),s.integrity==null&&(s.integrity=l.integrity)}var Ah=null;function $b(s,l,m){if(Ah===null){var _=new Map,T=Ah=new Map;T.set(m,_)}else T=Ah,_=T.get(m),_||(_=new Map,T.set(m,_));if(_.has(s))return _;for(_.set(s,null),m=m.getElementsByTagName(s),T=0;T<m.length;T++){var M=m[T];if(!(M[nt]||M[we]||s==="link"&&M.getAttribute("rel")==="stylesheet")&&M.namespaceURI!=="http://www.w3.org/2000/svg"){var q=M.getAttribute(l)||"";q=s+q;var pe=_.get(q);pe?pe.push(M):_.set(q,[M])}}return _}function Xb(s,l,m){s=s.ownerDocument||s,s.head.insertBefore(m,l==="title"?s.querySelector("head > title"):null)}function $N(s,l,m){if(m===1||l.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;switch(l.rel){case"stylesheet":return s=l.disabled,typeof l.precedence=="string"&&s==null;default:return!0}case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function Yb(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function XN(s,l,m,_){if(m.type==="stylesheet"&&(typeof _.media!="string"||matchMedia(_.media).matches!==!1)&&(m.state.loading&4)===0){if(m.instance===null){var T=fd(_.href),M=l.querySelector(I0(T));if(M){l=M._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(s.count++,s=Oh.bind(s),l.then(s,s)),m.state.loading|=4,m.instance=M,fr(M);return}M=l.ownerDocument||l,_=Wb(_),(T=ji.get(T))&&Zg(_,T),M=M.createElement("link"),fr(M);var q=M;q._p=new Promise(function(pe,Ie){q.onload=pe,q.onerror=Ie}),as(M,"link",_),m.instance=M}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(m,l),(l=m.state.preload)&&(m.state.loading&3)===0&&(s.count++,m=Oh.bind(s),l.addEventListener("load",m),l.addEventListener("error",m))}}var Kg=0;function YN(s,l){return s.stylesheets&&s.count===0&&Mh(s,s.stylesheets),0<s.count||0<s.imgCount?function(m){var _=setTimeout(function(){if(s.stylesheets&&Mh(s,s.stylesheets),s.unsuspend){var M=s.unsuspend;s.unsuspend=null,M()}},6e4+l);0<s.imgBytes&&Kg===0&&(Kg=62500*jN());var T=setTimeout(function(){if(s.waitingForImages=!1,s.count===0&&(s.stylesheets&&Mh(s,s.stylesheets),s.unsuspend)){var M=s.unsuspend;s.unsuspend=null,M()}},(s.imgBytes>Kg?50:800)+l);return s.unsuspend=m,function(){s.unsuspend=null,clearTimeout(_),clearTimeout(T)}}:null}function Oh(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Mh(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var Rh=null;function Mh(s,l){s.stylesheets=null,s.unsuspend!==null&&(s.count++,Rh=new Map,l.forEach(ZN,s),Rh=null,Oh.call(s))}function ZN(s,l){if(!(l.state.loading&4)){var m=Rh.get(s);if(m)var _=m.get(null);else{m=new Map,Rh.set(s,m);for(var T=s.querySelectorAll("link[data-precedence],style[data-precedence]"),M=0;M<T.length;M++){var q=T[M];(q.nodeName==="LINK"||q.getAttribute("media")!=="not all")&&(m.set(q.dataset.precedence,q),_=q)}_&&m.set(null,_)}T=l.instance,q=T.getAttribute("data-precedence"),M=m.get(q)||_,M===_&&m.set(null,T),m.set(q,T),this.count++,_=Oh.bind(this),T.addEventListener("load",_),T.addEventListener("error",_),M?M.parentNode.insertBefore(T,M.nextSibling):(s=s.nodeType===9?s.head:s,s.insertBefore(T,s.firstChild)),l.state.loading|=4}}var F0={$$typeof:B,Provider:null,Consumer:null,_currentValue:fe,_currentValue2:fe,_threadCount:0};function qN(s,l,m,_,T,M,q,pe,Ie){this.tag=1,this.containerInfo=s,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=gr(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=gr(0),this.hiddenUpdates=gr(null),this.identifierPrefix=_,this.onUncaughtError=T,this.onCaughtError=M,this.onRecoverableError=q,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Ie,this.incompleteTransitions=new Map}function Zb(s,l,m,_,T,M,q,pe,Ie,ot,Et,Mt){return s=new qN(s,l,m,q,Ie,ot,Et,Mt,pe),l=1,M===!0&&(l|=24),M=gs(3,null,null,l),s.current=M,M.stateNode=s,l=Am(),l.refCount++,s.pooledCache=l,l.refCount++,M.memoizedState={element:_,isDehydrated:m,cache:l},Dm(M),s}function qb(s){return s?(s=Io,s):Io}function Kb(s,l,m,_,T,M){T=qb(T),_.context===null?_.context=T:_.pendingContext=T,_=wl(l),_.payload={element:m},M=M===void 0?null:M,M!==null&&(_.callback=M),m=kl(s,_,l),m!==null&&(Ws(m,s,l),x0(m,s,l))}function Jb(s,l){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var m=s.retryLane;s.retryLane=m!==0&&m<l?m:l}}function Jg(s,l){Jb(s,l),(s=s.alternate)&&Jb(s,l)}function Qb(s){if(s.tag===13||s.tag===31){var l=Ni(s,67108864);l!==null&&Ws(l,s,67108864),Jg(s,67108864)}}function e2(s){if(s.tag===13||s.tag===31){var l=di();l=Vt(l);var m=Ni(s,l);m!==null&&Ws(m,s,l),Jg(s,l)}}var Dh=!0;function KN(s,l,m,_){var T=me.T;me.T=null;var M=K.p;try{K.p=2,Qg(s,l,m,_)}finally{K.p=M,me.T=T}}function JN(s,l,m,_){var T=me.T;me.T=null;var M=K.p;try{K.p=8,Qg(s,l,m,_)}finally{K.p=M,me.T=T}}function Qg(s,l,m,_){if(Dh){var T=ex(_);if(T===null)Bg(s,l,_,Lh,m),r2(s,_);else if(e6(T,s,l,m,_))_.stopPropagation();else if(r2(s,_),l&4&&-1<QN.indexOf(s)){for(;T!==null;){var M=Ht(T);if(M!==null)switch(M.tag){case 3:if(M=M.stateNode,M.current.memoizedState.isDehydrated){var q=Ir(M.pendingLanes);if(q!==0){var pe=M;for(pe.pendingLanes|=2,pe.entangledLanes|=2;q;){var Ie=1<<31-lt(q);pe.entanglements[1]|=Ie,q&=~Ie}xo(M),(ka&6)===0&&(ph=it()+500,R0(0))}}break;case 31:case 13:pe=Ni(M,2),pe!==null&&Ws(pe,M,2),bh(),Jg(M,2)}if(M=ex(_),M===null&&Bg(s,l,_,Lh,m),M===T)break;T=M}T!==null&&_.stopPropagation()}else Bg(s,l,_,null,m)}}function ex(s){return s=Ao(s),tx(s)}var Lh=null;function tx(s){if(Lh=null,s=It(s),s!==null){var l=c(s);if(l===null)s=null;else{var m=l.tag;if(m===13){if(s=u(l),s!==null)return s;s=null}else if(m===31){if(s=g(l),s!==null)return s;s=null}else if(m===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;s=null}else l!==s&&(s=null)}}return Lh=s,null}function t2(s){switch(s){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(De()){case Je:return 2;case Be:return 8;case vt:case jt:return 32;case Ct:return 268435456;default:return 32}default:return 32}}var rx=!1,Dl=null,Ll=null,Il=null,B0=new Map,U0=new Map,Pl=[],QN="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 r2(s,l){switch(s){case"focusin":case"focusout":Dl=null;break;case"dragenter":case"dragleave":Ll=null;break;case"mouseover":case"mouseout":Il=null;break;case"pointerover":case"pointerout":B0.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":U0.delete(l.pointerId)}}function z0(s,l,m,_,T,M){return s===null||s.nativeEvent!==M?(s={blockedOn:l,domEventName:m,eventSystemFlags:_,nativeEvent:M,targetContainers:[T]},l!==null&&(l=Ht(l),l!==null&&Qb(l)),s):(s.eventSystemFlags|=_,l=s.targetContainers,T!==null&&l.indexOf(T)===-1&&l.push(T),s)}function e6(s,l,m,_,T){switch(l){case"focusin":return Dl=z0(Dl,s,l,m,_,T),!0;case"dragenter":return Ll=z0(Ll,s,l,m,_,T),!0;case"mouseover":return Il=z0(Il,s,l,m,_,T),!0;case"pointerover":var M=T.pointerId;return B0.set(M,z0(B0.get(M)||null,s,l,m,_,T)),!0;case"gotpointercapture":return M=T.pointerId,U0.set(M,z0(U0.get(M)||null,s,l,m,_,T)),!0}return!1}function a2(s){var l=It(s.target);if(l!==null){var m=c(l);if(m!==null){if(l=m.tag,l===13){if(l=u(m),l!==null){s.blockedOn=l,ge(s.priority,function(){e2(m)});return}}else if(l===31){if(l=g(m),l!==null){s.blockedOn=l,ge(s.priority,function(){e2(m)});return}}else if(l===3&&m.stateNode.current.memoizedState.isDehydrated){s.blockedOn=m.tag===3?m.stateNode.containerInfo:null;return}}}s.blockedOn=null}function Ih(s){if(s.blockedOn!==null)return!1;for(var l=s.targetContainers;0<l.length;){var m=ex(s.nativeEvent);if(m===null){m=s.nativeEvent;var _=new m.constructor(m.type,m);so=_,m.target.dispatchEvent(_),so=null}else return l=Ht(m),l!==null&&Qb(l),s.blockedOn=m,!1;l.shift()}return!0}function n2(s,l,m){Ih(s)&&m.delete(l)}function t6(){rx=!1,Dl!==null&&Ih(Dl)&&(Dl=null),Ll!==null&&Ih(Ll)&&(Ll=null),Il!==null&&Ih(Il)&&(Il=null),B0.forEach(n2),U0.forEach(n2)}function Ph(s,l){s.blockedOn===l&&(s.blockedOn=null,rx||(rx=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,t6)))}var Fh=null;function s2(s){Fh!==s&&(Fh=s,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Fh===s&&(Fh=null);for(var l=0;l<s.length;l+=3){var m=s[l],_=s[l+1],T=s[l+2];if(typeof _!="function"){if(tx(_||m)===null)continue;break}var M=Ht(m);M!==null&&(s.splice(l,3),l-=3,eg(M,{pending:!0,data:T,method:m.method,action:_},_,T))}}))}function gd(s){function l(Ie){return Ph(Ie,s)}Dl!==null&&Ph(Dl,s),Ll!==null&&Ph(Ll,s),Il!==null&&Ph(Il,s),B0.forEach(l),U0.forEach(l);for(var m=0;m<Pl.length;m++){var _=Pl[m];_.blockedOn===s&&(_.blockedOn=null)}for(;0<Pl.length&&(m=Pl[0],m.blockedOn===null);)a2(m),m.blockedOn===null&&Pl.shift();if(m=(s.ownerDocument||s).$$reactFormReplay,m!=null)for(_=0;_<m.length;_+=3){var T=m[_],M=m[_+1],q=T[ke]||null;if(typeof M=="function")q||s2(m);else if(q){var pe=null;if(M&&M.hasAttribute("formAction")){if(T=M,q=M[ke]||null)pe=q.formAction;else if(tx(T)!==null)continue}else pe=q.action;typeof pe=="function"?m[_+1]=pe:(m.splice(_,3),_-=3),s2(m)}}}function i2(){function s(M){M.canIntercept&&M.info==="react-transition"&&M.intercept({handler:function(){return new Promise(function(q){return T=q})},focusReset:"manual",scroll:"manual"})}function l(){T!==null&&(T(),T=null),_||setTimeout(m,20)}function m(){if(!_&&!navigation.transition){var M=navigation.currentEntry;M&&M.url!=null&&navigation.navigate(M.url,{state:M.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var _=!1,T=null;return navigation.addEventListener("navigate",s),navigation.addEventListener("navigatesuccess",l),navigation.addEventListener("navigateerror",l),setTimeout(m,100),function(){_=!0,navigation.removeEventListener("navigate",s),navigation.removeEventListener("navigatesuccess",l),navigation.removeEventListener("navigateerror",l),T!==null&&(T(),T=null)}}}function ax(s){this._internalRoot=s}Bh.prototype.render=ax.prototype.render=function(s){var l=this._internalRoot;if(l===null)throw Error(n(409));var m=l.current,_=di();Kb(m,_,s,l,null,null)},Bh.prototype.unmount=ax.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var l=s.containerInfo;Kb(s.current,2,null,s,null,null),bh(),l[Te]=null}};function Bh(s){this._internalRoot=s}Bh.prototype.unstable_scheduleHydration=function(s){if(s){var l=de();s={blockedOn:null,target:s,priority:l};for(var m=0;m<Pl.length&&l!==0&&l<Pl[m].priority;m++);Pl.splice(m,0,s),m===0&&a2(s)}};var o2=r.version;if(o2!=="19.2.1")throw Error(n(527,o2,"19.2.1"));K.findDOMNode=function(s){var l=s._reactInternals;if(l===void 0)throw typeof s.render=="function"?Error(n(188)):(s=Object.keys(s).join(","),Error(n(268,s)));return s=x(l),s=s!==null?k(s):null,s=s===null?null:s.stateNode,s};var r6={bundleType:0,version:"19.2.1",rendererPackageName:"react-dom",currentDispatcherRef:me,reconcilerVersion:"19.2.1"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"){var Uh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Uh.isDisabled&&Uh.supportsFiber)try{Ge=Uh.inject(r6),We=Uh}catch(s){}}return V0.createRoot=function(s,l){if(!i(s))throw Error(n(299));var m=!1,_="",T=my,M=gy,q=xy;return l!=null&&(l.unstable_strictMode===!0&&(m=!0),l.identifierPrefix!==void 0&&(_=l.identifierPrefix),l.onUncaughtError!==void 0&&(T=l.onUncaughtError),l.onCaughtError!==void 0&&(M=l.onCaughtError),l.onRecoverableError!==void 0&&(q=l.onRecoverableError)),l=Zb(s,1,!1,null,null,m,_,null,T,M,q,i2),s[Te]=l.current,Fg(s),new ax(l)},V0.hydrateRoot=function(s,l,m){if(!i(s))throw Error(n(299));var _=!1,T="",M=my,q=gy,pe=xy,Ie=null;return m!=null&&(m.unstable_strictMode===!0&&(_=!0),m.identifierPrefix!==void 0&&(T=m.identifierPrefix),m.onUncaughtError!==void 0&&(M=m.onUncaughtError),m.onCaughtError!==void 0&&(q=m.onCaughtError),m.onRecoverableError!==void 0&&(pe=m.onRecoverableError),m.formState!==void 0&&(Ie=m.formState)),l=Zb(s,1,!0,l,m!=null?m:null,_,T,Ie,M,q,pe,i2),l.context=qb(null),m=l.current,_=di(),_=Vt(_),T=wl(_),T.callback=null,kl(m,T,_),m=_,l.current.lanes=m,jr(l,m),xo(l),s[Te]=l.current,Fg(s),new Bh(l)},V0.version="19.2.1",V0}var v2;function p6(){if(v2)return cx.exports;v2=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__=="undefined"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),cx.exports=x6(),cx.exports}var y6=p6();const zr=e=>typeof e=="string",W0=()=>{let e,r;const a=new Promise((n,i)=>{e=n,r=i});return a.resolve=e,a.reject=r,a},_2=e=>e==null?"":""+e,b6=(e,r,a)=>{e.forEach(n=>{r[n]&&(a[n]=r[n])})},v6=/###/g,w2=e=>e&&e.indexOf("###")>-1?e.replace(v6,"."):e,k2=e=>!e||zr(e),ru=(e,r,a)=>{const n=zr(r)?r.split("."):r;let i=0;for(;i<n.length-1;){if(k2(e))return{};const c=w2(n[i]);!e[c]&&a&&(e[c]=new a),Object.prototype.hasOwnProperty.call(e,c)?e=e[c]:e={},++i}return k2(e)?{}:{obj:e,k:w2(n[i])}},N2=(e,r,a)=>{const{obj:n,k:i}=ru(e,r,Object);if(n!==void 0||r.length===1){n[i]=a;return}let c=r[r.length-1],u=r.slice(0,r.length-1),g=ru(e,u,Object);for(;g.obj===void 0&&u.length;)c=`${u[u.length-1]}.${c}`,u=u.slice(0,u.length-1),g=ru(e,u,Object),g!=null&&g.obj&&typeof g.obj[`${g.k}.${c}`]!="undefined"&&(g.obj=void 0);g.obj[`${g.k}.${c}`]=a},_6=(e,r,a,n)=>{const{obj:i,k:c}=ru(e,r,Object);i[c]=i[c]||[],i[c].push(a)},pf=(e,r)=>{const{obj:a,k:n}=ru(e,r);if(a&&Object.prototype.hasOwnProperty.call(a,n))return a[n]},w6=(e,r,a)=>{const n=pf(e,a);return n!==void 0?n:pf(r,a)},W_=(e,r,a)=>{for(const n in r)n!=="__proto__"&&n!=="constructor"&&(n in e?zr(e[n])||e[n]instanceof String||zr(r[n])||r[n]instanceof String?a&&(e[n]=r[n]):W_(e[n],r[n],a):e[n]=r[n]);return e},pd=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var k6={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const N6=e=>zr(e)?e.replace(/[&<>"'\/]/g,r=>k6[r]):e;class S6{constructor(r){this.capacity=r,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(r){const a=this.regExpMap.get(r);if(a!==void 0)return a;const n=new RegExp(r);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(r,n),this.regExpQueue.push(r),n}}const C6=[" ",",","?","!",";"],E6=new S6(20),j6=(e,r,a)=>{r=r||"",a=a||"";const n=C6.filter(u=>r.indexOf(u)<0&&a.indexOf(u)<0);if(n.length===0)return!0;const i=E6.getRegExp(`(${n.map(u=>u==="?"?"\\?":u).join("|")})`);let c=!i.test(e);if(!c){const u=e.indexOf(a);u>0&&!i.test(e.substring(0,u))&&(c=!0)}return c},Vx=(e,r,a=".")=>{if(!e)return;if(e[r])return Object.prototype.hasOwnProperty.call(e,r)?e[r]:void 0;const n=r.split(a);let i=e;for(let c=0;c<n.length;){if(!i||typeof i!="object")return;let u,g="";for(let y=c;y<n.length;++y)if(y!==c&&(g+=a),g+=n[y],u=i[g],u!==void 0){if(["string","number","boolean"].indexOf(typeof u)>-1&&y<n.length-1)continue;c+=y-c+1;break}i=u}return i},uu=e=>e==null?void 0:e.replace("_","-"),T6={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,r){var a,n;(n=(a=console==null?void 0:console[e])==null?void 0:a.apply)==null||n.call(a,console,r)}};class yf{constructor(r,a={}){this.init(r,a)}init(r,a={}){this.prefix=a.prefix||"i18next:",this.logger=r||T6,this.options=a,this.debug=a.debug}log(...r){return this.forward(r,"log","",!0)}warn(...r){return this.forward(r,"warn","",!0)}error(...r){return this.forward(r,"error","")}deprecate(...r){return this.forward(r,"warn","WARNING DEPRECATED: ",!0)}forward(r,a,n,i){return i&&!this.debug?null:(zr(r[0])&&(r[0]=`${n}${this.prefix} ${r[0]}`),this.logger[a](r))}create(r){return new yf(this.logger,_e({prefix:`${this.prefix}:${r}:`},this.options))}clone(r){return r=r||this.options,r.prefix=r.prefix||this.prefix,new yf(this.logger,r)}}var vo=new yf;class Yf{constructor(){this.observers={}}on(r,a){return r.split(" ").forEach(n=>{this.observers[n]||(this.observers[n]=new Map);const i=this.observers[n].get(a)||0;this.observers[n].set(a,i+1)}),this}off(r,a){if(this.observers[r]){if(!a){delete this.observers[r];return}this.observers[r].delete(a)}}emit(r,...a){this.observers[r]&&Array.from(this.observers[r].entries()).forEach(([i,c])=>{for(let u=0;u<c;u++)i(...a)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,c])=>{for(let u=0;u<c;u++)i.apply(i,[r,...a])})}}class S2 extends Yf{constructor(r,a={ns:["translation"],defaultNS:"translation"}){super(),this.data=r||{},this.options=a,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(r){this.options.ns.indexOf(r)<0&&this.options.ns.push(r)}removeNamespaces(r){const a=this.options.ns.indexOf(r);a>-1&&this.options.ns.splice(a,1)}getResource(r,a,n,i={}){var x,k;const c=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,u=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let g;r.indexOf(".")>-1?g=r.split("."):(g=[r,a],n&&(Array.isArray(n)?g.push(...n):zr(n)&&c?g.push(...n.split(c)):g.push(n)));const y=pf(this.data,g);return!y&&!a&&!n&&r.indexOf(".")>-1&&(r=g[0],a=g[1],n=g.slice(2).join(".")),y||!u||!zr(n)?y:Vx((k=(x=this.data)==null?void 0:x[r])==null?void 0:k[a],n,c)}addResource(r,a,n,i,c={silent:!1}){const u=c.keySeparator!==void 0?c.keySeparator:this.options.keySeparator;let g=[r,a];n&&(g=g.concat(u?n.split(u):n)),r.indexOf(".")>-1&&(g=r.split("."),i=a,a=g[1]),this.addNamespaces(a),N2(this.data,g,i),c.silent||this.emit("added",r,a,n,i)}addResources(r,a,n,i={silent:!1}){for(const c in n)(zr(n[c])||Array.isArray(n[c]))&&this.addResource(r,a,c,n[c],{silent:!0});i.silent||this.emit("added",r,a,n)}addResourceBundle(r,a,n,i,c,u={silent:!1,skipCopy:!1}){let g=[r,a];r.indexOf(".")>-1&&(g=r.split("."),i=n,n=a,a=g[1]),this.addNamespaces(a);let y=pf(this.data,g)||{};u.skipCopy||(n=JSON.parse(JSON.stringify(n))),i?W_(y,n,c):y=_e(_e({},y),n),N2(this.data,g,y),u.silent||this.emit("added",r,a,n)}removeResourceBundle(r,a){this.hasResourceBundle(r,a)&&delete this.data[r][a],this.removeNamespaces(a),this.emit("removed",r,a)}hasResourceBundle(r,a){return this.getResource(r,a)!==void 0}getResourceBundle(r,a){return a||(a=this.options.defaultNS),this.getResource(r,a)}getDataByLanguage(r){return this.data[r]}hasLanguageSomeTranslations(r){const a=this.getDataByLanguage(r);return!!(a&&Object.keys(a)||[]).find(i=>a[i]&&Object.keys(a[i]).length>0)}toJSON(){return this.data}}var G_={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,r,a,n,i){return e.forEach(c=>{var u,g;r=(g=(u=this.processors[c])==null?void 0:u.process(r,a,n,i))!=null?g:r}),r}};const $_=Symbol("i18next/PATH_KEY");function A6(){const e=[],r=Object.create(null);let a;return r.get=(n,i)=>{var c;return(c=a==null?void 0:a.revoke)==null||c.call(a),i===$_?e:(e.push(i),a=Proxy.revocable(n,r),a.proxy)},Proxy.revocable(Object.create(null),r).proxy}function Wx(e,r){var n;const{[$_]:a}=e(A6());return a.join((n=r==null?void 0:r.keySeparator)!=null?n:".")}const C2={},fx=e=>!zr(e)&&typeof e!="boolean"&&typeof e!="number";class bf extends Yf{constructor(r,a={}){super(),b6(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],r,this),this.options=a,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=vo.create("translator")}changeLanguage(r){r&&(this.language=r)}exists(r,a={interpolation:{}}){const n=_e({},a);if(r==null)return!1;const i=this.resolve(r,n);if((i==null?void 0:i.res)===void 0)return!1;const c=fx(i.res);return!(n.returnObjects===!1&&c)}extractFromKey(r,a){let n=a.nsSeparator!==void 0?a.nsSeparator:this.options.nsSeparator;n===void 0&&(n=":");const i=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let c=a.ns||this.options.defaultNS||[];const u=n&&r.indexOf(n)>-1,g=!this.options.userDefinedKeySeparator&&!a.keySeparator&&!this.options.userDefinedNsSeparator&&!a.nsSeparator&&!j6(r,n,i);if(u&&!g){const y=r.match(this.interpolator.nestingRegexp);if(y&&y.length>0)return{key:r,namespaces:zr(c)?[c]:c};const x=r.split(n);(n!==i||n===i&&this.options.ns.indexOf(x[0])>-1)&&(c=x.shift()),r=x.join(i)}return{key:r,namespaces:zr(c)?[c]:c}}translate(r,a,n){let i=typeof a=="object"?_e({},a):a;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i=_e({},i)),i||(i={}),r==null)return"";typeof r=="function"&&(r=Wx(r,_e(_e({},this.options),i))),Array.isArray(r)||(r=[String(r)]);const c=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,u=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:g,namespaces:y}=this.extractFromKey(r[r.length-1],i),x=y[y.length-1];let k=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;k===void 0&&(k=":");const N=i.lng||this.language,C=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((N==null?void 0:N.toLowerCase())==="cimode")return C?c?{res:`${x}${k}${g}`,usedKey:g,exactUsedKey:g,usedLng:N,usedNS:x,usedParams:this.getUsedParamsDetails(i)}:`${x}${k}${g}`:c?{res:g,usedKey:g,exactUsedKey:g,usedLng:N,usedNS:x,usedParams:this.getUsedParamsDetails(i)}:g;const O=this.resolve(r,i);let D=O==null?void 0:O.res;const A=(O==null?void 0:O.usedKey)||g,I=(O==null?void 0:O.exactUsedKey)||g,z=["[object Number]","[object Function]","[object RegExp]"],U=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,B=!this.i18nFormat||this.i18nFormat.handleAsObject,V=i.count!==void 0&&!zr(i.count),Z=bf.hasDefaultValue(i),W=V?this.pluralResolver.getSuffix(N,i.count,i):"",H=i.ordinal&&V?this.pluralResolver.getSuffix(N,i.count,{ordinal:!1}):"",le=V&&!i.ordinal&&i.count===0,Q=le&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${W}`]||i[`defaultValue${H}`]||i.defaultValue;let Ne=D;B&&!D&&Z&&(Ne=Q);const oe=fx(Ne),se=Object.prototype.toString.apply(Ne);if(B&&Ne&&oe&&z.indexOf(se)<0&&!(zr(U)&&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(A,Ne,$e(_e({},i),{ns:y})):`key '${g} (${this.language})' returned an object instead of string.`;return c?(O.res=ce,O.usedParams=this.getUsedParamsDetails(i),O):ce}if(u){const ce=Array.isArray(Ne),Ce=ce?[]:{},ae=ce?I:A;for(const me in Ne)if(Object.prototype.hasOwnProperty.call(Ne,me)){const K=`${ae}${u}${me}`;Z&&!D?Ce[me]=this.translate(K,$e(_e({},i),{defaultValue:fx(Q)?Q[me]:void 0,joinArrays:!1,ns:y})):Ce[me]=this.translate(K,$e(_e({},i),{joinArrays:!1,ns:y})),Ce[me]===K&&(Ce[me]=Ne[me])}D=Ce}}else if(B&&zr(U)&&Array.isArray(D))D=D.join(U),D&&(D=this.extendTranslation(D,r,i,n));else{let ce=!1,Ce=!1;!this.isValidLookup(D)&&Z&&(ce=!0,D=Q),this.isValidLookup(D)||(Ce=!0,D=g);const me=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&Ce?void 0:D,K=Z&&Q!==D&&this.options.updateMissing;if(Ce||ce||K){if(this.logger.log(K?"updateKey":"missingKey",N,x,g,K?Q:D),u){const J=this.resolve(g,$e(_e({},i),{keySeparator:!1}));J&&J.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 fe=[];const Oe=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Oe&&Oe[0])for(let J=0;J<Oe.length;J++)fe.push(Oe[J]);else this.options.saveMissingTo==="all"?fe=this.languageUtils.toResolveHierarchy(i.lng||this.language):fe.push(i.lng||this.language);const ye=(J,G,ie)=>{var ne;const re=Z&&ie!==D?ie:me;this.options.missingKeyHandler?this.options.missingKeyHandler(J,x,G,re,K,i):(ne=this.backendConnector)!=null&&ne.saveMissing&&this.backendConnector.saveMissing(J,x,G,re,K,i),this.emit("missingKey",J,x,G,D)};this.options.saveMissing&&(this.options.saveMissingPlurals&&V?fe.forEach(J=>{const G=this.pluralResolver.getSuffixes(J,i);le&&i[`defaultValue${this.options.pluralSeparator}zero`]&&G.indexOf(`${this.options.pluralSeparator}zero`)<0&&G.push(`${this.options.pluralSeparator}zero`),G.forEach(ie=>{ye([J],g+ie,i[`defaultValue${ie}`]||Q)})}):ye(fe,g,Q))}D=this.extendTranslation(D,r,i,O,n),Ce&&D===g&&this.options.appendNamespaceToMissingKey&&(D=`${x}${k}${g}`),(Ce||ce)&&this.options.parseMissingKeyHandler&&(D=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${x}${k}${g}`:g,ce?D:void 0,i))}return c?(O.res=D,O.usedParams=this.getUsedParamsDetails(i),O):D}extendTranslation(r,a,n,i,c){var y,x;if((y=this.i18nFormat)!=null&&y.parse)r=this.i18nFormat.parse(r,_e(_e({},this.options.interpolation.defaultVariables),n),n.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init($e(_e({},n),{interpolation:_e(_e({},this.options.interpolation),n.interpolation)}));const k=zr(r)&&(((x=n==null?void 0:n.interpolation)==null?void 0:x.skipOnVariables)!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let N;if(k){const O=r.match(this.interpolator.nestingRegexp);N=O&&O.length}let C=n.replace&&!zr(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(C=_e(_e({},this.options.interpolation.defaultVariables),C)),r=this.interpolator.interpolate(r,C,n.lng||this.language||i.usedLng,n),k){const O=r.match(this.interpolator.nestingRegexp),D=O&&O.length;N<D&&(n.nest=!1)}!n.lng&&i&&i.res&&(n.lng=this.language||i.usedLng),n.nest!==!1&&(r=this.interpolator.nest(r,(...O)=>(c==null?void 0:c[0])===O[0]&&!n.context?(this.logger.warn(`It seems you are nesting recursively key: ${O[0]} in key: ${a[0]}`),null):this.translate(...O,a),n)),n.interpolation&&this.interpolator.reset()}const u=n.postProcess||this.options.postProcess,g=zr(u)?[u]:u;return r!=null&&(g!=null&&g.length)&&n.applyPostProcessor!==!1&&(r=G_.handle(g,r,a,this.options&&this.options.postProcessPassResolved?_e({i18nResolved:$e(_e({},i),{usedParams:this.getUsedParamsDetails(n)})},n):n,this)),r}resolve(r,a={}){let n,i,c,u,g;return zr(r)&&(r=[r]),r.forEach(y=>{if(this.isValidLookup(n))return;const x=this.extractFromKey(y,a),k=x.key;i=k;let N=x.namespaces;this.options.fallbackNS&&(N=N.concat(this.options.fallbackNS));const C=a.count!==void 0&&!zr(a.count),O=C&&!a.ordinal&&a.count===0,D=a.context!==void 0&&(zr(a.context)||typeof a.context=="number")&&a.context!=="",A=a.lngs?a.lngs:this.languageUtils.toResolveHierarchy(a.lng||this.language,a.fallbackLng);N.forEach(I=>{var z,U;this.isValidLookup(n)||(g=I,!C2[`${A[0]}-${I}`]&&((z=this.utils)!=null&&z.hasLoadedNamespace)&&!((U=this.utils)!=null&&U.hasLoadedNamespace(g))&&(C2[`${A[0]}-${I}`]=!0,this.logger.warn(`key "${i}" for languages "${A.join(", ")}" won't get resolved as namespace "${g}" 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!!!")),A.forEach(B=>{var W;if(this.isValidLookup(n))return;u=B;const V=[k];if((W=this.i18nFormat)!=null&&W.addLookupKeys)this.i18nFormat.addLookupKeys(V,k,B,I,a);else{let H;C&&(H=this.pluralResolver.getSuffix(B,a.count,a));const le=`${this.options.pluralSeparator}zero`,Q=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(C&&(a.ordinal&&H.indexOf(Q)===0&&V.push(k+H.replace(Q,this.options.pluralSeparator)),V.push(k+H),O&&V.push(k+le)),D){const Ne=`${k}${this.options.contextSeparator||"_"}${a.context}`;V.push(Ne),C&&(a.ordinal&&H.indexOf(Q)===0&&V.push(Ne+H.replace(Q,this.options.pluralSeparator)),V.push(Ne+H),O&&V.push(Ne+le))}}let Z;for(;Z=V.pop();)this.isValidLookup(n)||(c=Z,n=this.getResource(B,I,Z,a))}))})}),{res:n,usedKey:i,exactUsedKey:c,usedLng:u,usedNS:g}}isValidLookup(r){return r!==void 0&&!(!this.options.returnNull&&r===null)&&!(!this.options.returnEmptyString&&r==="")}getResource(r,a,n,i={}){var c;return(c=this.i18nFormat)!=null&&c.getResource?this.i18nFormat.getResource(r,a,n,i):this.resourceStore.getResource(r,a,n,i)}getUsedParamsDetails(r={}){const a=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],n=r.replace&&!zr(r.replace);let i=n?r.replace:r;if(n&&typeof r.count!="undefined"&&(i.count=r.count),this.options.interpolation.defaultVariables&&(i=_e(_e({},this.options.interpolation.defaultVariables),i)),!n){i=_e({},i);for(const c of a)delete i[c]}return i}static hasDefaultValue(r){const a="defaultValue";for(const n in r)if(Object.prototype.hasOwnProperty.call(r,n)&&a===n.substring(0,a.length)&&r[n]!==void 0)return!0;return!1}}class E2{constructor(r){this.options=r,this.supportedLngs=this.options.supportedLngs||!1,this.logger=vo.create("languageUtils")}getScriptPartFromCode(r){if(r=uu(r),!r||r.indexOf("-")<0)return null;const a=r.split("-");return a.length===2||(a.pop(),a[a.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(a.join("-"))}getLanguagePartFromCode(r){if(r=uu(r),!r||r.indexOf("-")<0)return r;const a=r.split("-");return this.formatLanguageCode(a[0])}formatLanguageCode(r){if(zr(r)&&r.indexOf("-")>-1){let a;try{a=Intl.getCanonicalLocales(r)[0]}catch(n){}return a&&this.options.lowerCaseLng&&(a=a.toLowerCase()),a||(this.options.lowerCaseLng?r.toLowerCase():r)}return this.options.cleanCode||this.options.lowerCaseLng?r.toLowerCase():r}isSupportedCode(r){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(r=this.getLanguagePartFromCode(r)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(r)>-1}getBestMatchFromCodes(r){if(!r)return null;let a;return r.forEach(n=>{if(a)return;const i=this.formatLanguageCode(n);(!this.options.supportedLngs||this.isSupportedCode(i))&&(a=i)}),!a&&this.options.supportedLngs&&r.forEach(n=>{if(a)return;const i=this.getScriptPartFromCode(n);if(this.isSupportedCode(i))return a=i;const c=this.getLanguagePartFromCode(n);if(this.isSupportedCode(c))return a=c;a=this.options.supportedLngs.find(u=>{if(u===c)return u;if(!(u.indexOf("-")<0&&c.indexOf("-")<0)&&(u.indexOf("-")>0&&c.indexOf("-")<0&&u.substring(0,u.indexOf("-"))===c||u.indexOf(c)===0&&c.length>1))return u})}),a||(a=this.getFallbackCodes(this.options.fallbackLng)[0]),a}getFallbackCodes(r,a){if(!r)return[];if(typeof r=="function"&&(r=r(a)),zr(r)&&(r=[r]),Array.isArray(r))return r;if(!a)return r.default||[];let n=r[a];return n||(n=r[this.getScriptPartFromCode(a)]),n||(n=r[this.formatLanguageCode(a)]),n||(n=r[this.getLanguagePartFromCode(a)]),n||(n=r.default),n||[]}toResolveHierarchy(r,a){const n=this.getFallbackCodes((a===!1?[]:a)||this.options.fallbackLng||[],r),i=[],c=u=>{u&&(this.isSupportedCode(u)?i.push(u):this.logger.warn(`rejecting language code not found in supportedLngs: ${u}`))};return zr(r)&&(r.indexOf("-")>-1||r.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&c(this.formatLanguageCode(r)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&c(this.getScriptPartFromCode(r)),this.options.load!=="currentOnly"&&c(this.getLanguagePartFromCode(r))):zr(r)&&c(this.formatLanguageCode(r)),n.forEach(u=>{i.indexOf(u)<0&&c(this.formatLanguageCode(u))}),i}}const j2={zero:0,one:1,two:2,few:3,many:4,other:5},T2={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class O6{constructor(r,a={}){this.languageUtils=r,this.options=a,this.logger=vo.create("pluralResolver"),this.pluralRulesCache={}}addRule(r,a){this.rules[r]=a}clearCache(){this.pluralRulesCache={}}getRule(r,a={}){const n=uu(r==="dev"?"en":r),i=a.ordinal?"ordinal":"cardinal",c=JSON.stringify({cleanedCode:n,type:i});if(c in this.pluralRulesCache)return this.pluralRulesCache[c];let u;try{u=new Intl.PluralRules(n,{type:i})}catch(g){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),T2;if(!r.match(/-|_/))return T2;const y=this.languageUtils.getLanguagePartFromCode(r);u=this.getRule(y,a)}return this.pluralRulesCache[c]=u,u}needsPlural(r,a={}){let n=this.getRule(r,a);return n||(n=this.getRule("dev",a)),(n==null?void 0:n.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(r,a,n={}){return this.getSuffixes(r,n).map(i=>`${a}${i}`)}getSuffixes(r,a={}){let n=this.getRule(r,a);return n||(n=this.getRule("dev",a)),n?n.resolvedOptions().pluralCategories.sort((i,c)=>j2[i]-j2[c]).map(i=>`${this.options.prepend}${a.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(r,a,n={}){const i=this.getRule(r,n);return i?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i.select(a)}`:(this.logger.warn(`no plural rule found for: ${r}`),this.getSuffix("dev",a,n))}}const A2=(e,r,a,n=".",i=!0)=>{let c=w6(e,r,a);return!c&&i&&zr(a)&&(c=Vx(e,a,n),c===void 0&&(c=Vx(r,a,n))),c},mx=e=>e.replace(/\$/g,"$$$$");class O2{constructor(r={}){var a;this.logger=vo.create("interpolator"),this.options=r,this.format=((a=r==null?void 0:r.interpolation)==null?void 0:a.format)||(n=>n),this.init(r)}init(r={}){r.interpolation||(r.interpolation={escapeValue:!0});const{escape:a,escapeValue:n,useRawValueToEscape:i,prefix:c,prefixEscaped:u,suffix:g,suffixEscaped:y,formatSeparator:x,unescapeSuffix:k,unescapePrefix:N,nestingPrefix:C,nestingPrefixEscaped:O,nestingSuffix:D,nestingSuffixEscaped:A,nestingOptionsSeparator:I,maxReplaces:z,alwaysFormat:U}=r.interpolation;this.escape=a!==void 0?a:N6,this.escapeValue=n!==void 0?n:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=c?pd(c):u||"{{",this.suffix=g?pd(g):y||"}}",this.formatSeparator=x||",",this.unescapePrefix=k?"":N||"-",this.unescapeSuffix=this.unescapePrefix?"":k||"",this.nestingPrefix=C?pd(C):O||pd("$t("),this.nestingSuffix=D?pd(D):A||pd(")"),this.nestingOptionsSeparator=I||",",this.maxReplaces=z||1e3,this.alwaysFormat=U!==void 0?U:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const r=(a,n)=>(a==null?void 0:a.source)===n?(a.lastIndex=0,a):new RegExp(n,"g");this.regexp=r(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=r(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=r(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(r,a,n,i){var O;let c,u,g;const y=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},x=D=>{if(D.indexOf(this.formatSeparator)<0){const U=A2(a,y,D,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(U,void 0,n,$e(_e(_e({},i),a),{interpolationkey:D})):U}const A=D.split(this.formatSeparator),I=A.shift().trim(),z=A.join(this.formatSeparator).trim();return this.format(A2(a,y,I,this.options.keySeparator,this.options.ignoreJSONStructure),z,n,$e(_e(_e({},i),a),{interpolationkey:I}))};this.resetRegExp();const k=(i==null?void 0:i.missingInterpolationHandler)||this.options.missingInterpolationHandler,N=((O=i==null?void 0:i.interpolation)==null?void 0:O.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:D=>mx(D)},{regex:this.regexp,safeValue:D=>this.escapeValue?mx(this.escape(D)):mx(D)}].forEach(D=>{for(g=0;c=D.regex.exec(r);){const A=c[1].trim();if(u=x(A),u===void 0)if(typeof k=="function"){const z=k(r,c,i);u=zr(z)?z:""}else if(i&&Object.prototype.hasOwnProperty.call(i,A))u="";else if(N){u=c[0];continue}else this.logger.warn(`missed to pass in variable ${A} for interpolating ${r}`),u="";else!zr(u)&&!this.useRawValueToEscape&&(u=_2(u));const I=D.safeValue(u);if(r=r.replace(c[0],I),N?(D.regex.lastIndex+=u.length,D.regex.lastIndex-=c[0].length):D.regex.lastIndex=0,g++,g>=this.maxReplaces)break}}),r}nest(r,a,n={}){let i,c,u;const g=(y,x)=>{var A;const k=this.nestingOptionsSeparator;if(y.indexOf(k)<0)return y;const N=y.split(new RegExp(`${k}[ ]*{`));let C=`{${N[1]}`;y=N[0],C=this.interpolate(C,u);const O=C.match(/'/g),D=C.match(/"/g);(((A=O==null?void 0:O.length)!=null?A:0)%2===0&&!D||D.length%2!==0)&&(C=C.replace(/'/g,'"'));try{u=JSON.parse(C),x&&(u=_e(_e({},x),u))}catch(I){return this.logger.warn(`failed parsing options string in nesting for key ${y}`,I),`${y}${k}${C}`}return u.defaultValue&&u.defaultValue.indexOf(this.prefix)>-1&&delete u.defaultValue,y};for(;i=this.nestingRegexp.exec(r);){let y=[];u=_e({},n),u=u.replace&&!zr(u.replace)?u.replace:u,u.applyPostProcessor=!1,delete u.defaultValue;const x=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(x!==-1&&(y=i[1].slice(x).split(this.formatSeparator).map(k=>k.trim()).filter(Boolean),i[1]=i[1].slice(0,x)),c=a(g.call(this,i[1].trim(),u),u),c&&i[0]===r&&!zr(c))return c;zr(c)||(c=_2(c)),c||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${r}`),c=""),y.length&&(c=y.reduce((k,N)=>this.format(k,N,n.lng,$e(_e({},n),{interpolationkey:i[1].trim()})),c.trim())),r=r.replace(i[0],c),this.regexp.lastIndex=0}return r}}const R6=e=>{let r=e.toLowerCase().trim();const a={};if(e.indexOf("(")>-1){const n=e.split("(");r=n[0].toLowerCase().trim();const i=n[1].substring(0,n[1].length-1);r==="currency"&&i.indexOf(":")<0?a.currency||(a.currency=i.trim()):r==="relativetime"&&i.indexOf(":")<0?a.range||(a.range=i.trim()):i.split(";").forEach(u=>{if(u){const[g,...y]=u.split(":"),x=y.join(":").trim().replace(/^'+|'+$/g,""),k=g.trim();a[k]||(a[k]=x),x==="false"&&(a[k]=!1),x==="true"&&(a[k]=!0),isNaN(x)||(a[k]=parseInt(x,10))}})}return{formatName:r,formatOptions:a}},R2=e=>{const r={};return(a,n,i)=>{let c=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(c=$e(_e({},c),{[i.interpolationkey]:void 0}));const u=n+JSON.stringify(c);let g=r[u];return g||(g=e(uu(n),i),r[u]=g),g(a)}},M6=e=>(r,a,n)=>e(uu(a),n)(r);class D6{constructor(r={}){this.logger=vo.create("formatter"),this.options=r,this.init(r)}init(r,a={interpolation:{}}){this.formatSeparator=a.interpolation.formatSeparator||",";const n=a.cacheInBuiltFormats?R2:M6;this.formats={number:n((i,c)=>{const u=new Intl.NumberFormat(i,_e({},c));return g=>u.format(g)}),currency:n((i,c)=>{const u=new Intl.NumberFormat(i,$e(_e({},c),{style:"currency"}));return g=>u.format(g)}),datetime:n((i,c)=>{const u=new Intl.DateTimeFormat(i,_e({},c));return g=>u.format(g)}),relativetime:n((i,c)=>{const u=new Intl.RelativeTimeFormat(i,_e({},c));return g=>u.format(g,c.range||"day")}),list:n((i,c)=>{const u=new Intl.ListFormat(i,_e({},c));return g=>u.format(g)})}}add(r,a){this.formats[r.toLowerCase().trim()]=a}addCached(r,a){this.formats[r.toLowerCase().trim()]=R2(a)}format(r,a,n,i={}){const c=a.split(this.formatSeparator);if(c.length>1&&c[0].indexOf("(")>1&&c[0].indexOf(")")<0&&c.find(g=>g.indexOf(")")>-1)){const g=c.findIndex(y=>y.indexOf(")")>-1);c[0]=[c[0],...c.splice(1,g)].join(this.formatSeparator)}return c.reduce((g,y)=>{var N;const{formatName:x,formatOptions:k}=R6(y);if(this.formats[x]){let C=g;try{const O=((N=i==null?void 0:i.formatParams)==null?void 0:N[i.interpolationkey])||{},D=O.locale||O.lng||i.locale||i.lng||n;C=this.formats[x](g,D,_e(_e(_e({},k),i),O))}catch(O){this.logger.warn(O)}return C}else this.logger.warn(`there was no format function for ${x}`);return g},r)}}const L6=(e,r)=>{e.pending[r]!==void 0&&(delete e.pending[r],e.pendingCount--)};class I6 extends Yf{constructor(r,a,n,i={}){var c,u;super(),this.backend=r,this.store=a,this.services=n,this.languageUtils=n.languageUtils,this.options=i,this.logger=vo.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=[],(u=(c=this.backend)==null?void 0:c.init)==null||u.call(c,n,i.backend,i)}queueLoad(r,a,n,i){const c={},u={},g={},y={};return r.forEach(x=>{let k=!0;a.forEach(N=>{const C=`${x}|${N}`;!n.reload&&this.store.hasResourceBundle(x,N)?this.state[C]=2:this.state[C]<0||(this.state[C]===1?u[C]===void 0&&(u[C]=!0):(this.state[C]=1,k=!1,u[C]===void 0&&(u[C]=!0),c[C]===void 0&&(c[C]=!0),y[N]===void 0&&(y[N]=!0)))}),k||(g[x]=!0)}),(Object.keys(c).length||Object.keys(u).length)&&this.queue.push({pending:u,pendingCount:Object.keys(u).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(c),pending:Object.keys(u),toLoadLanguages:Object.keys(g),toLoadNamespaces:Object.keys(y)}}loaded(r,a,n){const i=r.split("|"),c=i[0],u=i[1];a&&this.emit("failedLoading",c,u,a),!a&&n&&this.store.addResourceBundle(c,u,n,void 0,void 0,{skipCopy:!0}),this.state[r]=a?-1:2,a&&n&&(this.state[r]=0);const g={};this.queue.forEach(y=>{_6(y.loaded,[c],u),L6(y,r),a&&y.errors.push(a),y.pendingCount===0&&!y.done&&(Object.keys(y.loaded).forEach(x=>{g[x]||(g[x]={});const k=y.loaded[x];k.length&&k.forEach(N=>{g[x][N]===void 0&&(g[x][N]=!0)})}),y.done=!0,y.errors.length?y.callback(y.errors):y.callback())}),this.emit("loaded",g),this.queue=this.queue.filter(y=>!y.done)}read(r,a,n,i=0,c=this.retryTimeout,u){if(!r.length)return u(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:r,ns:a,fcName:n,tried:i,wait:c,callback:u});return}this.readingCalls++;const g=(x,k)=>{if(this.readingCalls--,this.waitingReads.length>0){const N=this.waitingReads.shift();this.read(N.lng,N.ns,N.fcName,N.tried,N.wait,N.callback)}if(x&&k&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,r,a,n,i+1,c*2,u)},c);return}u(x,k)},y=this.backend[n].bind(this.backend);if(y.length===2){try{const x=y(r,a);x&&typeof x.then=="function"?x.then(k=>g(null,k)).catch(g):g(null,x)}catch(x){g(x)}return}return y(r,a,g)}prepareLoading(r,a,n={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();zr(r)&&(r=this.languageUtils.toResolveHierarchy(r)),zr(a)&&(a=[a]);const c=this.queueLoad(r,a,n,i);if(!c.toLoad.length)return c.pending.length||i(),null;c.toLoad.forEach(u=>{this.loadOne(u)})}load(r,a,n){this.prepareLoading(r,a,{},n)}reload(r,a,n){this.prepareLoading(r,a,{reload:!0},n)}loadOne(r,a=""){const n=r.split("|"),i=n[0],c=n[1];this.read(i,c,"read",void 0,void 0,(u,g)=>{u&&this.logger.warn(`${a}loading namespace ${c} for language ${i} failed`,u),!u&&g&&this.logger.log(`${a}loaded namespace ${c} for language ${i}`,g),this.loaded(r,u,g)})}saveMissing(r,a,n,i,c,u={},g=()=>{}){var y,x,k,N,C;if((x=(y=this.services)==null?void 0:y.utils)!=null&&x.hasLoadedNamespace&&!((N=(k=this.services)==null?void 0:k.utils)!=null&&N.hasLoadedNamespace(a))){this.logger.warn(`did not save key "${n}" as the namespace "${a}" 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(!(n==null||n==="")){if((C=this.backend)!=null&&C.create){const O=$e(_e({},u),{isUpdate:c}),D=this.backend.create.bind(this.backend);if(D.length<6)try{let A;D.length===5?A=D(r,a,n,i,O):A=D(r,a,n,i),A&&typeof A.then=="function"?A.then(I=>g(null,I)).catch(g):g(null,A)}catch(A){g(A)}else D(r,a,n,i,g,O)}!r||!r[0]||this.store.addResource(r[0],a,n,i)}}}const M2=()=>({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:e=>{let r={};if(typeof e[1]=="object"&&(r=e[1]),zr(e[1])&&(r.defaultValue=e[1]),zr(e[2])&&(r.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const a=e[3]||e[2];Object.keys(a).forEach(n=>{r[n]=a[n]})}return r},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),D2=e=>{var r,a;return zr(e.ns)&&(e.ns=[e.ns]),zr(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),zr(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),((a=(r=e.supportedLngs)==null?void 0:r.indexOf)==null?void 0:a.call(r,"cimode"))<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),typeof e.initImmediate=="boolean"&&(e.initAsync=e.initImmediate),e},Vh=()=>{},P6=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(a=>{typeof e[a]=="function"&&(e[a]=e[a].bind(e))})};class au extends Yf{constructor(r={},a){if(super(),this.options=D2(r),this.services={},this.logger=vo,this.modules={external:[]},P6(this),a&&!this.isInitialized&&!r.isClone){if(!this.options.initAsync)return this.init(r,a),this;setTimeout(()=>{this.init(r,a)},0)}}init(r={},a){this.isInitializing=!0,typeof r=="function"&&(a=r,r={}),r.defaultNS==null&&r.ns&&(zr(r.ns)?r.defaultNS=r.ns:r.ns.indexOf("translation")<0&&(r.defaultNS=r.ns[0]));const n=M2();this.options=_e(_e(_e({},n),this.options),D2(r)),this.options.interpolation=_e(_e({},n.interpolation),this.options.interpolation),r.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=r.keySeparator),r.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=r.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=n.overloadTranslationOptionHandler);const i=x=>x?typeof x=="function"?new x:x:null;if(!this.options.isClone){this.modules.logger?vo.init(i(this.modules.logger),this.options):vo.init(null,this.options);let x;this.modules.formatter?x=this.modules.formatter:x=D6;const k=new E2(this.options);this.store=new S2(this.options.resources,this.options);const N=this.services;N.logger=vo,N.resourceStore=this.store,N.languageUtils=k,N.pluralResolver=new O6(k,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==n.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"),x&&(!this.options.interpolation.format||this.options.interpolation.format===n.interpolation.format)&&(N.formatter=i(x),N.formatter.init&&N.formatter.init(N,this.options),this.options.interpolation.format=N.formatter.format.bind(N.formatter)),N.interpolator=new O2(this.options),N.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},N.backendConnector=new I6(i(this.modules.backend),N.resourceStore,N,this.options),N.backendConnector.on("*",(O,...D)=>{this.emit(O,...D)}),this.modules.languageDetector&&(N.languageDetector=i(this.modules.languageDetector),N.languageDetector.init&&N.languageDetector.init(N,this.options.detection,this.options)),this.modules.i18nFormat&&(N.i18nFormat=i(this.modules.i18nFormat),N.i18nFormat.init&&N.i18nFormat.init(this)),this.translator=new bf(this.services,this.options),this.translator.on("*",(O,...D)=>{this.emit(O,...D)}),this.modules.external.forEach(O=>{O.init&&O.init(this)})}if(this.format=this.options.interpolation.format,a||(a=Vh),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const x=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);x.length>0&&x[0]!=="dev"&&(this.options.lng=x[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(x=>{this[x]=(...k)=>this.store[x](...k)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(x=>{this[x]=(...k)=>(this.store[x](...k),this)});const g=W0(),y=()=>{const x=(k,N)=>{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),g.resolve(N),a(k,N)};if(this.languages&&!this.isInitialized)return x(null,this.t.bind(this));this.changeLanguage(this.options.lng,x)};return this.options.resources||!this.options.initAsync?y():setTimeout(y,0),g}loadResources(r,a=Vh){var c,u;let n=a;const i=zr(r)?r:this.language;if(typeof r=="function"&&(n=r),!this.options.resources||this.options.partialBundledLanguages){if((i==null?void 0:i.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return n();const g=[],y=x=>{if(!x||x==="cimode")return;this.services.languageUtils.toResolveHierarchy(x).forEach(N=>{N!=="cimode"&&g.indexOf(N)<0&&g.push(N)})};i?y(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(k=>y(k)),(u=(c=this.options.preload)==null?void 0:c.forEach)==null||u.call(c,x=>y(x)),this.services.backendConnector.load(g,this.options.ns,x=>{!x&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),n(x)})}else n(null)}reloadResources(r,a,n){const i=W0();return typeof r=="function"&&(n=r,r=void 0),typeof a=="function"&&(n=a,a=void 0),r||(r=this.languages),a||(a=this.options.ns),n||(n=Vh),this.services.backendConnector.reload(r,a,c=>{i.resolve(),n(c)}),i}use(r){if(!r)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!r.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return r.type==="backend"&&(this.modules.backend=r),(r.type==="logger"||r.log&&r.warn&&r.error)&&(this.modules.logger=r),r.type==="languageDetector"&&(this.modules.languageDetector=r),r.type==="i18nFormat"&&(this.modules.i18nFormat=r),r.type==="postProcessor"&&G_.addPostProcessor(r),r.type==="formatter"&&(this.modules.formatter=r),r.type==="3rdParty"&&this.modules.external.push(r),this}setResolvedLanguage(r){if(!(!r||!this.languages)&&!(["cimode","dev"].indexOf(r)>-1)){for(let a=0;a<this.languages.length;a++){const n=this.languages[a];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}!this.resolvedLanguage&&this.languages.indexOf(r)<0&&this.store.hasLanguageSomeTranslations(r)&&(this.resolvedLanguage=r,this.languages.unshift(r))}}changeLanguage(r,a){this.isLanguageChangingTo=r;const n=W0();this.emit("languageChanging",r);const i=g=>{this.language=g,this.languages=this.services.languageUtils.toResolveHierarchy(g),this.resolvedLanguage=void 0,this.setResolvedLanguage(g)},c=(g,y)=>{y?this.isLanguageChangingTo===r&&(i(y),this.translator.changeLanguage(y),this.isLanguageChangingTo=void 0,this.emit("languageChanged",y),this.logger.log("languageChanged",y)):this.isLanguageChangingTo=void 0,n.resolve((...x)=>this.t(...x)),a&&a(g,(...x)=>this.t(...x))},u=g=>{var k,N;!r&&!g&&this.services.languageDetector&&(g=[]);const y=zr(g)?g:g&&g[0],x=this.store.hasLanguageSomeTranslations(y)?y:this.services.languageUtils.getBestMatchFromCodes(zr(g)?[g]:g);x&&(this.language||i(x),this.translator.language||this.translator.changeLanguage(x),(N=(k=this.services.languageDetector)==null?void 0:k.cacheUserLanguage)==null||N.call(k,x)),this.loadResources(x,C=>{c(C,x)})};return!r&&this.services.languageDetector&&!this.services.languageDetector.async?u(this.services.languageDetector.detect()):!r&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(u):this.services.languageDetector.detect(u):u(r),n}getFixedT(r,a,n){const i=(c,u,...g)=>{let y;typeof u!="object"?y=this.options.overloadTranslationOptionHandler([c,u].concat(g)):y=_e({},u),y.lng=y.lng||i.lng,y.lngs=y.lngs||i.lngs,y.ns=y.ns||i.ns,y.keyPrefix!==""&&(y.keyPrefix=y.keyPrefix||n||i.keyPrefix);const x=this.options.keySeparator||".";let k;return y.keyPrefix&&Array.isArray(c)?k=c.map(N=>(typeof N=="function"&&(N=Wx(N,_e(_e({},this.options),u))),`${y.keyPrefix}${x}${N}`)):(typeof c=="function"&&(c=Wx(c,_e(_e({},this.options),u))),k=y.keyPrefix?`${y.keyPrefix}${x}${c}`:c),this.t(k,y)};return zr(r)?i.lng=r:i.lngs=r,i.ns=a,i.keyPrefix=n,i}t(...r){var a;return(a=this.translator)==null?void 0:a.translate(...r)}exists(...r){var a;return(a=this.translator)==null?void 0:a.exists(...r)}setDefaultNamespace(r){this.options.defaultNS=r}hasLoadedNamespace(r,a={}){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 n=a.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,c=this.languages[this.languages.length-1];if(n.toLowerCase()==="cimode")return!0;const u=(g,y)=>{const x=this.services.backendConnector.state[`${g}|${y}`];return x===-1||x===0||x===2};if(a.precheck){const g=a.precheck(this,u);if(g!==void 0)return g}return!!(this.hasResourceBundle(n,r)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||u(n,r)&&(!i||u(c,r)))}loadNamespaces(r,a){const n=W0();return this.options.ns?(zr(r)&&(r=[r]),r.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{n.resolve(),a&&a(i)}),n):(a&&a(),Promise.resolve())}loadLanguages(r,a){const n=W0();zr(r)&&(r=[r]);const i=this.options.preload||[],c=r.filter(u=>i.indexOf(u)<0&&this.services.languageUtils.isSupportedCode(u));return c.length?(this.options.preload=i.concat(c),this.loadResources(u=>{n.resolve(),a&&a(u)}),n):(a&&a(),Promise.resolve())}dir(r){var i,c;if(r||(r=this.resolvedLanguage||(((i=this.languages)==null?void 0:i.length)>0?this.languages[0]:this.language)),!r)return"rtl";try{const u=new Intl.Locale(r);if(u&&u.getTextInfo){const g=u.getTextInfo();if(g&&g.direction)return g.direction}}catch(u){}const a=["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"],n=((c=this.services)==null?void 0:c.languageUtils)||new E2(M2());return r.toLowerCase().indexOf("-latn")>1?"ltr":a.indexOf(n.getLanguagePartFromCode(r))>-1||r.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(r={},a){const n=new au(r,a);return n.createInstance=au.createInstance,n}cloneInstance(r={},a=Vh){const n=r.forkResourceStore;n&&delete r.forkResourceStore;const i=$e(_e(_e({},this.options),r),{isClone:!0}),c=new au(i);if((r.debug!==void 0||r.prefix!==void 0)&&(c.logger=c.logger.clone(r)),["store","services","language"].forEach(g=>{c[g]=this[g]}),c.services=_e({},this.services),c.services.utils={hasLoadedNamespace:c.hasLoadedNamespace.bind(c)},n){const g=Object.keys(this.store.data).reduce((y,x)=>(y[x]=_e({},this.store.data[x]),y[x]=Object.keys(y[x]).reduce((k,N)=>(k[N]=_e({},y[x][N]),k),y[x]),y),{});c.store=new S2(g,i),c.services.resourceStore=c.store}return r.interpolation&&(c.services.interpolator=new O2(i)),c.translator=new bf(c.services,i),c.translator.on("*",(g,...y)=>{c.emit(g,...y)}),c.init(i,a),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 Xn=au.createInstance();Xn.createInstance;Xn.dir;Xn.init;Xn.loadResources;Xn.reloadResources;Xn.use;Xn.changeLanguage;Xn.getFixedT;Xn.t;Xn.exists;Xn.setDefaultNamespace;Xn.hasLoadedNamespace;Xn.loadNamespaces;Xn.loadLanguages;const F6=(e,r,a,n)=>{var c,u,g,y;const i=[a,_e({code:r},n||{})];if((u=(c=e==null?void 0:e.services)==null?void 0:c.logger)!=null&&u.forward)return e.services.logger.forward(i,"warn","react-i18next::",!0);jc(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),(y=(g=e==null?void 0:e.services)==null?void 0:g.logger)!=null&&y.warn?e.services.logger.warn(...i):console!=null&&console.warn&&console.warn(...i)},L2={},X_=(e,r,a,n)=>{jc(a)&&L2[a]||(jc(a)&&(L2[a]=new Date),F6(e,r,a,n))},Y_=(e,r)=>()=>{if(e.isInitialized)r();else{const a=()=>{setTimeout(()=>{e.off("initialized",a)},0),r()};e.on("initialized",a)}},Gx=(e,r,a)=>{e.loadNamespaces(r,Y_(e,a))},I2=(e,r,a,n)=>{if(jc(a)&&(a=[a]),e.options.preload&&e.options.preload.indexOf(r)>-1)return Gx(e,a,n);a.forEach(i=>{e.options.ns.indexOf(i)<0&&e.options.ns.push(i)}),e.loadLanguages(r,Y_(e,n))},B6=(e,r,a={})=>!r.languages||!r.languages.length?(X_(r,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:r.languages}),!0):r.hasLoadedNamespace(e,{lng:a.lng,precheck:(n,i)=>{if(a.bindI18n&&a.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!i(n.isLanguageChangingTo,e))return!1}}),jc=e=>typeof e=="string",U6=e=>typeof e=="object"&&e!==null,z6=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,H6={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},V6=e=>H6[e],W6=e=>e.replace(z6,V6);let $x={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:W6};const G6=(e={})=>{$x=_e(_e({},$x),e)},$6=()=>$x;let Z_;const X6=e=>{Z_=e},Y6=()=>Z_,Z6={type:"3rdParty",init(e){G6(e.options.react),X6(e)}},q6=E.createContext();class K6{constructor(){this.usedNamespaces={}}addUsedNamespaces(r){r.forEach(a=>{this.usedNamespaces[a]||(this.usedNamespaces[a]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var gx={exports:{}},xx={};var P2;function J6(){if(P2)return xx;P2=1;var e=Xf();function r(N,C){return N===C&&(N!==0||1/N===1/C)||N!==N&&C!==C}var a=typeof Object.is=="function"?Object.is:r,n=e.useState,i=e.useEffect,c=e.useLayoutEffect,u=e.useDebugValue;function g(N,C){var O=C(),D=n({inst:{value:O,getSnapshot:C}}),A=D[0].inst,I=D[1];return c(function(){A.value=O,A.getSnapshot=C,y(A)&&I({inst:A})},[N,O,C]),i(function(){return y(A)&&I({inst:A}),N(function(){y(A)&&I({inst:A})})},[N]),u(O),O}function y(N){var C=N.getSnapshot;N=N.value;try{var O=C();return!a(N,O)}catch(D){return!0}}function x(N,C){return C()}var k=typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"?x:g;return xx.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:k,xx}var F2;function Q6(){return F2||(F2=1,gx.exports=J6()),gx.exports}var eS=Q6();const tS=(e,r)=>jc(r)?r:U6(r)&&jc(r.defaultValue)?r.defaultValue:Array.isArray(e)?e[e.length-1]:e,rS={t:tS,ready:!1},aS=()=>()=>{},oa=(e,r={})=>{var Q,Ne,oe;const{i18n:a}=r,{i18n:n,defaultNS:i}=E.useContext(q6)||{},c=a||n||Y6();c&&!c.reportNamespaces&&(c.reportNamespaces=new K6),c||X_(c,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const u=E.useMemo(()=>{var se;return _e(_e(_e({},$6()),(se=c==null?void 0:c.options)==null?void 0:se.react),r)},[c,r]),{useSuspense:g,keyPrefix:y}=u,x=i||((Q=c==null?void 0:c.options)==null?void 0:Q.defaultNS),k=jc(x)?[x]:x||["translation"],N=E.useMemo(()=>k,k);(oe=(Ne=c==null?void 0:c.reportNamespaces)==null?void 0:Ne.addUsedNamespaces)==null||oe.call(Ne,N);const C=E.useRef(0),O=E.useCallback(se=>{if(!c)return aS;const{bindI18n:ce,bindI18nStore:Ce}=u,ae=()=>{C.current+=1,se()};return ce&&c.on(ce,ae),Ce&&c.store.on(Ce,ae),()=>{ce&&ce.split(" ").forEach(me=>c.off(me,ae)),Ce&&Ce.split(" ").forEach(me=>c.store.off(me,ae))}},[c,u]),D=E.useRef(),A=E.useCallback(()=>{if(!c)return rS;const se=!!(c.isInitialized||c.initializedStoreOnce)&&N.every(fe=>B6(fe,c,u)),ce=r.lng||c.language,Ce=C.current,ae=D.current;if(ae&&ae.ready===se&&ae.lng===ce&&ae.keyPrefix===y&&ae.revision===Ce)return ae;const K={t:c.getFixedT(ce,u.nsMode==="fallback"?N:N[0],y),ready:se,lng:ce,keyPrefix:y,revision:Ce};return D.current=K,K},[c,N,y,u,r.lng]),[I,z]=E.useState(0),{t:U,ready:B}=eS.useSyncExternalStore(O,A,A);E.useEffect(()=>{if(c&&!B&&!g){const se=()=>z(ce=>ce+1);r.lng?I2(c,r.lng,N,se):Gx(c,N,se)}},[c,r.lng,N,B,g,I]);const V=c||{},Z=E.useRef(null),W=E.useRef(),H=se=>{const ce=Object.getOwnPropertyDescriptors(se);ce.__original&&delete ce.__original;const Ce=Object.create(Object.getPrototypeOf(se),ce);if(!Object.prototype.hasOwnProperty.call(Ce,"__original"))try{Object.defineProperty(Ce,"__original",{value:se,writable:!1,enumerable:!1,configurable:!1})}catch(ae){}return Ce},le=E.useMemo(()=>{const se=V,ce=se==null?void 0:se.language;let Ce=se;se&&(Z.current&&Z.current.__original===se?W.current!==ce?(Ce=H(se),Z.current=Ce,W.current=ce):Ce=Z.current:(Ce=H(se),Z.current=Ce,W.current=ce));const ae=[U,Ce,B];return ae.t=U,ae.i18n=Ce,ae.ready=B,ae},[U,V,B,V.resolvedLanguage,V.language,V.languages]);if(c&&g&&!B)throw new Promise(se=>{const ce=()=>se();r.lng?I2(c,r.lng,N,ce):Gx(c,N,ce)});return le},{slice:nS,forEach:sS}=[];function iS(e){return sS.call(nS.call(arguments,1),r=>{if(r)for(const a in r)e[a]===void 0&&(e[a]=r[a])}),e}function oS(e){return typeof e!="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(a=>a.test(e))}const B2=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,lS=function(e,r){const n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(r);let c=`${e}=${i}`;if(n.maxAge>0){const u=n.maxAge-0;if(Number.isNaN(u))throw new Error("maxAge should be a Number");c+=`; Max-Age=${Math.floor(u)}`}if(n.domain){if(!B2.test(n.domain))throw new TypeError("option domain is invalid");c+=`; Domain=${n.domain}`}if(n.path){if(!B2.test(n.path))throw new TypeError("option path is invalid");c+=`; Path=${n.path}`}if(n.expires){if(typeof n.expires.toUTCString!="function")throw new TypeError("option expires is invalid");c+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(c+="; HttpOnly"),n.secure&&(c+="; Secure"),n.sameSite)switch(typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.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 n.partitioned&&(c+="; Partitioned"),c},U2={create(e,r,a,n){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};a&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+a*60*1e3)),n&&(i.domain=n),document.cookie=lS(e,r,i)},read(e){const r=`${e}=`,a=document.cookie.split(";");for(let n=0;n<a.length;n++){let i=a[n];for(;i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(r)===0)return i.substring(r.length,i.length)}return null},remove(e,r){this.create(e,"",-1,r)}};var cS={name:"cookie",lookup(e){let{lookupCookie:r}=e;if(r&&typeof document!="undefined")return U2.read(r)||void 0},cacheUserLanguage(e,r){let{lookupCookie:a,cookieMinutes:n,cookieDomain:i,cookieOptions:c}=r;a&&typeof document!="undefined"&&U2.create(a,e,n,i,c)}},dS={name:"querystring",lookup(e){var n;let{lookupQuerystring:r}=e,a;if(typeof window!="undefined"){let{search:i}=window.location;!window.location.search&&((n=window.location.hash)==null?void 0:n.indexOf("?"))>-1&&(i=window.location.hash.substring(window.location.hash.indexOf("?")));const u=i.substring(1).split("&");for(let g=0;g<u.length;g++){const y=u[g].indexOf("=");y>0&&u[g].substring(0,y)===r&&(a=u[g].substring(y+1))}}return a}},uS={name:"hash",lookup(e){var i;let{lookupHash:r,lookupFromHashIndex:a}=e,n;if(typeof window!="undefined"){const{hash:c}=window.location;if(c&&c.length>2){const u=c.substring(1);if(r){const g=u.split("&");for(let y=0;y<g.length;y++){const x=g[y].indexOf("=");x>0&&g[y].substring(0,x)===r&&(n=g[y].substring(x+1))}}if(n)return n;if(!n&&a>-1){const g=c.match(/\/([a-zA-Z-]*)/g);return Array.isArray(g)?(i=g[typeof a=="number"?a:0])==null?void 0:i.replace("/",""):void 0}}}return n}};let yd=null;const z2=()=>{if(yd!==null)return yd;try{if(yd=typeof window!="undefined"&&window.localStorage!==null,!yd)return!1;const e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e)}catch(e){yd=!1}return yd};var hS={name:"localStorage",lookup(e){let{lookupLocalStorage:r}=e;if(r&&z2())return window.localStorage.getItem(r)||void 0},cacheUserLanguage(e,r){let{lookupLocalStorage:a}=r;a&&z2()&&window.localStorage.setItem(a,e)}};let bd=null;const H2=()=>{if(bd!==null)return bd;try{if(bd=typeof window!="undefined"&&window.sessionStorage!==null,!bd)return!1;const e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e)}catch(e){bd=!1}return bd};var fS={name:"sessionStorage",lookup(e){let{lookupSessionStorage:r}=e;if(r&&H2())return window.sessionStorage.getItem(r)||void 0},cacheUserLanguage(e,r){let{lookupSessionStorage:a}=r;a&&H2()&&window.sessionStorage.setItem(a,e)}},mS={name:"navigator",lookup(e){const r=[];if(typeof navigator!="undefined"){const{languages:a,userLanguage:n,language:i}=navigator;if(a)for(let c=0;c<a.length;c++)r.push(a[c]);n&&r.push(n),i&&r.push(i)}return r.length>0?r:void 0}},gS={name:"htmlTag",lookup(e){let{htmlTag:r}=e,a;const n=r||(typeof document!="undefined"?document.documentElement:null);return n&&typeof n.getAttribute=="function"&&(a=n.getAttribute("lang")),a}},xS={name:"path",lookup(e){var i;let{lookupFromPathIndex:r}=e;if(typeof window=="undefined")return;const a=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(a)?(i=a[typeof r=="number"?r:0])==null?void 0:i.replace("/",""):void 0}},pS={name:"subdomain",lookup(e){var i,c;let{lookupFromSubdomainIndex:r}=e;const a=typeof r=="number"?r+1:1,n=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(n)return n[a]}};let q_=!1;try{document.cookie,q_=!0}catch(e){}const K_=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];q_||K_.splice(1,1);const yS=()=>({order:K_,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:e=>e});class J_{constructor(r){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(r,a)}init(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=r,this.options=iS(a,this.options||{},yS()),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=n,this.addDetector(cS),this.addDetector(dS),this.addDetector(hS),this.addDetector(fS),this.addDetector(mS),this.addDetector(gS),this.addDetector(xS),this.addDetector(pS),this.addDetector(uS)}addDetector(r){return this.detectors[r.name]=r,this}detect(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,a=[];return r.forEach(n=>{if(this.detectors[n]){let i=this.detectors[n].lookup(this.options);i&&typeof i=="string"&&(i=[i]),i&&(a=a.concat(i))}}),a=a.filter(n=>n!=null&&!oS(n)).map(n=>this.options.convertDetectedLanguage(n)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?a:a.length>0?a[0]:null}cacheUserLanguage(r){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;a&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(r)>-1||a.forEach(n=>{this.detectors[n]&&this.detectors[n].cacheUserLanguage(r,this.options)}))}}J_.type="languageDetector";const bS={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",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"},vS={title:"Seera-ASM",loggedInAs:"Logged in as:",version:"Seera-ASM v2.26",inventory:"Inventory",ppmPlanner:"PPM Planner",maintenanceCalendar:"Maintenance Calendar",activeMap:"Active Map",maintenanceTeam:"Maintenance Team",procurement:"Procurement",sla:"Service Level Agreement (SLA)",support:"Support"},_S={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",forgotPassword:"Forgot password?",forgotPasswordTitle:"Reset your password",forgotPasswordHint:"Enter your email address or username. We will send you a link to reset your password.",forgotPasswordUserRequired:"Please enter your email or username.",forgotPasswordUserPlaceholder:"Email or username",forgotPasswordSubmit:"Send reset link",forgotPasswordClose:"Close",forgotPasswordSentSuccess:"If an account exists for that user, password reset instructions have been sent by email.",forgotPasswordNotFound:"No account was found with that email or username.",forgotPasswordTimeout:"The request timed out. Please try again.",forgotPasswordCannotReset:"Password reset is not available for this account.",forgotPasswordFailed:"Could not send the reset link. Please try again later.",finishingSignOut:"Finishing sign-out…",afterPasswordResetSignIn:"Your password was updated. Please sign in with your new password."},wS={title:"Dashboard",loading:"Loading dashboard...",totalAssets:"Total Assets",openWorkOrders:"OPEN WORK ORDERS",workOrdersInProgress:"WORK ORDERS IN PROGRESS",completedWorkOrders:"COMPLETED WORK ORDERS",closedWorkOrders:"CLOSED WORK ORDERS",totalWorkOrders:"TOTAL WORK ORDERS",overdueWorkOrders:"OVERDUE WORK ORDERS",upTime:"Up Time",downTime:"Down Time",workOrderStatus:"Work Order Status",workOrderTypeStatusHint:"Type vs status counts — click a number to view filtered work orders",workOrderByType:"Work Order by Type",maintenanceByAsset:"Maintenance by Asset",assigneesStatus:"Asset Maintenance Assignees Status Count",assignedTo:"Assigned To",plannedTasks:"Planned",completedTasks:"Completed",cancelledTasks:"Cancelled",overdueTasks:"Overdue",totalTasks:"Total",maintenanceFrequency:"Maintenance Frequency",maintenanceLogs:"MAINTENANCE LOGS",assetUptime:"Asset Uptime",avgResponseTime:"Avg Response Time",maintenanceEfficiency:"Maintenance Efficiency",overdueMaintenance:"Overdue Maintenance",upDownTimeChart:"Up & Down Time Chart",assetUpDown:"Asset UP & Down",assetStatusOverview:"Asset Status Overview",clickStatusCardHint:"Click a card to view filtered assets",totalAssetsLabel:"Total",noAssetStatusData:"No asset status data",viewAssetStatusOverview:"View asset status overview",viewAll:"View all",viewFiltered:"View ↗",ofTotal:"of total",ppmStatus:"PPM Status",techniciansWorked:"Technicians Work Summary",workOrderStatusDistribution:"Work Order Status Distribution",workOrders:"Work Orders",activeDateRange:"Date range: {{from}} to {{to}}",allDates:"Showing all dates",applyFilters:"Apply",clearDates:"Clear dates",techniciansWorkedSubtitle:"{{completed}} done • {{inProgress}} wip • {{open}} open",techniciansWorkedEmpty:"No technician data",techniciansWorkedReportHint:"Work orders grouped by assigned contractor",technicianWorkingHours:"Technicians Working Hours",technicianHoursSubtitle:"Total: {{total}} hrs",technicianHoursEmpty:"No technician hours data",loadingTechnicianHours:"Loading technician hours…",technicianHoursFound:"{{count}} technicians found",totalTechnicians:"Total Technicians",totalHoursWorked:"Total Hours Worked",avgHoursPerTechnician:"Average Hours/Technician",technicianName:"Technician Name",engineer:"Engineer",totalHoursSpent:"Total Hours Spent",technicianHoursFooter:"Showing {{count}} technicians (filtered) • {{total}} total hours",filters:"Filters",clearFilters:"Clear Filters",viewFullReport:"View Full Report",noChartData:"No chart data available",fromDate:"From Date",toDate:"To Date",technicalDepartment:"Technical Department",allDepartments:"All Departments",refreshReport:"Refresh",allHospitals:"All Hospitals",allSites:"All Sites",overallCompletionRate:"Overall Completion Rate",overallCompletionByDepartment:"Overall Completion Rate by Department",viewCompletionDetails:"View completion details",clickRowToFilter:"Click a row or value to view filtered work orders",woType:"WO Type",woFeedbackReport:"WO Feedback Report",woFeedbackTotalResponses:"Total responses: {{total}}"},kS={assetId:"Asset ID",assetName:"Asset Name",serialNumber:"Serial Number",company:"Company/Hospital",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"},NS={filterBy:"Filter By",sortBy:"Sort By",createdDate:"Created Date",latestModifiedDate:"Latest Modified Date",startDate:"Start Date",endDate:"End Date",sortCreationNewest:"Created (Newest)",sortCreationOldest:"Created (Oldest)",sortModifiedNewest:"Modified (Newest)",sortModifiedOldest:"Modified (Oldest)",sortNameAsc:"Name (A-Z)",sortNameDesc:"Name (Z-A)"},SS={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",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"},CS={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",newAssetDetails:"New Asset Details",noAssetsFound:"No assets found",createFirstAsset:"Create your first asset"},ES={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"},jS={title:"Asset Maintenance",maintenanceLogs:"Maintenance Logs",maintenanceDetails:"Maintenance Details",addMaintenance:"Add New Maintenance",maintenanceTeam:"Maintenance Team",newMaintenanceTeam:"New Maintenance Team",teamId:"Team ID",teamName:"Team Name",managerEmail:"Manager Email",managerName:"Manager 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:"Maintenance Manager"},TS={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"},AS={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"},OS={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",viewDetails:"View Details",editItem:"Edit Item",duplicateItem:"Duplicate Item",deleteItem:"Delete Item",basicInformation:"Basic Information",stockInformation:"Stock Information",isStockItem:"Is Stock Item",balanceQty:"Balance Qty",calibrationInformation:"Calibration Information",additionalInformation:"Additional Information",refreshBalanceQty:"Refresh Balance Qty",warrantyMonths:"Warranty (Months)"},RS={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"},MS={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"},DS={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"},LS={showingToOf:"Showing {{start}} to {{end}} of {{total}} {{label}}",showingTo:"Showing {{start}} to {{end}} {{label}}",previous:"Previous",next:"Next",goTo:"Go to",go:"Go",page:"Page",assets:"assets",workOrders:"work orders",items:"items",issues:"issues",maintenanceTeams:"maintenance teams"},IS={common:bS,sidebar:vS,login:_S,dashboard:wS,commonFields:kS,filters:NS,listPages:SS,assets:CS,workOrders:ES,maintenance:jS,ppm:TS,exportModal:AS,items:OS,issues:RS,users:MS,events:DS,pagination:LS},PS={dashboard:"لوحة التحكم",assets:"الأصول",workOrders:"أوامر العمل",maintenance:"صيانة الأصول",ppm:"الصيانة الوقائية",logout:"تسجيل الخروج",login:"تسجيل الدخول",email:"البريد الإلكتروني",password:"كلمة المرور",submit:"إرسال",cancel:"إلغاء",save:"حفظ",delete:"حذف",edit:"تعديل",create:"إنشاء",search:"بحث",filter:"تصفية",export:"تصدير",import:"استيراد",loading:"جاري التحميل...",noData:"لا توجد بيانات",error:"خطأ",success:"نجح",darkMode:"الوضع الداكن",lightMode:"الوضع الفاتح",language:"اللغة",english:"الإنجليزية",arabic:"العربية"},FS={title:"أصول سيرا",loggedInAs:"تم تسجيل الدخول كـ:",version:"أصول سيرا نظام إدارة الأصول الإصدار 2.26"},BS={title:"أصول سيرا",subtitle:"نظام إدارة الأصول",signIn:"قم بتسجيل الدخول للمتابعة",emailPlaceholder:"أدخل بريدك الإلكتروني",passwordPlaceholder:"أدخل كلمة المرور",loginFailed:"فشل تسجيل الدخول. يرجى التحقق من بيانات الاعتماد الخاصة بك.",demoLogin:"تسجيل دخول تجريبي",forgotPassword:"نسيت كلمة المرور؟",forgotPasswordTitle:"إعادة تعيين كلمة المرور",forgotPasswordHint:"أدخل بريدك الإلكتروني أو اسم المستخدم. سنرسل لك رابطًا لإعادة تعيين كلمة المرور.",forgotPasswordUserRequired:"يرجى إدخال بريدك الإلكتروني أو اسم المستخدم.",forgotPasswordUserPlaceholder:"البريد الإلكتروني أو اسم المستخدم",forgotPasswordSubmit:"إرسال رابط إعادة التعيين",forgotPasswordClose:"إغلاق",forgotPasswordSentSuccess:"إذا كان هناك حساب لهذا المستخدم، فقد أُرسلت تعليمات إعادة تعيين كلمة المرور بالبريد الإلكتروني.",forgotPasswordNotFound:"لم يتم العثور على حساب بهذا البريد الإلكتروني أو اسم المستخدم.",forgotPasswordTimeout:"انتهت مهلة الطلب. يرجى المحاولة مرة أخرى.",forgotPasswordCannotReset:"إعادة تعيين كلمة المرور غير متاحة لهذا الحساب.",forgotPasswordFailed:"تعذر إرسال رابط إعادة التعيين. يرجى المحاولة لاحقًا.",finishingSignOut:"جاري إنهاء تسجيل الخروج…",afterPasswordResetSignIn:"تم تحديث كلمة المرور. يرجى تسجيل الدخول بكلمة المرور الجديدة."},US={title:"لوحة التحكم",loading:"جاري تحميل لوحة التحكم...",totalAssets:"إجمالي الأصول",openWorkOrders:"أوامر العمل المفتوحة",workOrdersInProgress:"أوامر العمل قيد التنفيذ",completedWorkOrders:"أوامر العمل المكتملة",closedWorkOrders:"أوامر العمل المغلقة",totalWorkOrders:"إجمالي أوامر العمل",overdueWorkOrders:"أوامر العمل المتأخرة",upTime:"وقت التشغيل",downTime:"وقت التوقف",workOrderStatus:"حالة أمر العمل",workOrderTypeStatusHint:"عدد الحالات حسب النوع — انقر على الرقم لعرض أوامر العمل المفلترة",workOrderByType:"أمر العمل حسب النوع",maintenanceByAsset:"الصيانة حسب الأصل",assigneesStatus:"عدد حالة مكلفي صيانة الأصول",assignedTo:"المكلف",plannedTasks:"مخطط",completedTasks:"مكتمل",cancelledTasks:"ملغى",overdueTasks:"متأخر",totalTasks:"الإجمالي",maintenanceFrequency:"تكرار الصيانة",maintenanceLogs:"سجلات الصيانة",assetUptime:"وقت تشغيل الأصل",avgResponseTime:"متوسط وقت الاستجابة",maintenanceEfficiency:"كفاءة الصيانة",overdueMaintenance:"صيانة متأخرة",upDownTimeChart:"مخطط وقت التشغيل والتوقف",assetUpDown:"حالة الأصول (تشغيل / توقف)",assetStatusOverview:"نظرة عامة على حالة الأصول",clickStatusCardHint:"انقر على بطاقة لعرض الأصول المفلترة",totalAssetsLabel:"الإجمالي",noAssetStatusData:"لا توجد بيانات لحالة الأصول",viewAssetStatusOverview:"عرض نظرة عامة على حالة الأصول",viewAll:"عرض الكل",viewFiltered:"عرض ↗",ofTotal:"من الإجمالي",ppmStatus:"حالة الصيانة الوقائية",techniciansWorked:"ملخص عمل الفنيين",workOrderStatusDistribution:"توزيع حالة أمر العمل",workOrders:"أوامر العمل",activeDateRange:"نطاق التاريخ: {{from}} إلى {{to}}",allDates:"عرض جميع التواريخ",applyFilters:"تطبيق",clearDates:"مسح التواريخ",techniciansWorkedSubtitle:"{{completed}} منجز • {{inProgress}} قيد التنفيذ • {{open}} مفتوح",techniciansWorkedEmpty:"لا توجد بيانات للفنيين",techniciansWorkedReportHint:"أوامر العمل مجمعة حسب المقاول المعين",technicianWorkingHours:"ساعات عمل الفنيين",technicianHoursSubtitle:"الإجمالي: {{total}} ساعة",technicianHoursEmpty:"لا توجد بيانات لساعات الفنيين",loadingTechnicianHours:"جاري تحميل ساعات الفنيين…",technicianHoursFound:"تم العثور على {{count}} فني",totalTechnicians:"إجمالي الفنيين",totalHoursWorked:"إجمالي ساعات العمل",avgHoursPerTechnician:"متوسط الساعات/فني",technicianName:"اسم الفني",engineer:"المهندس",totalHoursSpent:"إجمالي الساعات",technicianHoursFooter:"عرض {{count}} فني (مفلتر) • {{total}} إجمالي الساعات",filters:"الفلاتر",clearFilters:"مسح الفلاتر",viewFullReport:"عرض التقرير الكامل",noChartData:"لا توجد بيانات للمخطط",fromDate:"من تاريخ",toDate:"إلى تاريخ",technicalDepartment:"القسم الفني",allDepartments:"جميع الأقسام",refreshReport:"تحديث",allHospitals:"جميع المستشفيات",allSites:"جميع المواقع",overallCompletionRate:"معدل الإنجاز الإجمالي",overallCompletionByDepartment:"معدل الإنجاز الإجمالي حسب القسم",viewCompletionDetails:"عرض تفاصيل الإنجاز",clickRowToFilter:"انقر على صف أو قيمة لعرض أوامر العمل المفلترة",woType:"نوع أمر العمل",woFeedbackReport:"تقرير ملاحظات أمر العمل",woFeedbackTotalResponses:"إجمالي الردود: {{total}}"},zS={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:"تاريخ الإكمال"},HS={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:"تحديث"},VS={title:"الأصول",addAsset:"إضافة أصل جديد",assetDetails:"تفاصيل الأصل"},WS={title:"أوامر العمل",addWorkOrder:"إضافة أمر عمل جديد",workOrderDetails:"تفاصيل أمر العمل",newWorkOrder:"أمر عمل جديد",duplicateWorkOrder:"نسخ أمر العمل",createFromAsset:"إنشاء أمر عمل من الأصل"},GS={title:"صيانة الأصول",maintenanceLogs:"سجلات الصيانة",maintenanceDetails:"تفاصيل الصيانة",addMaintenance:"إضافة صيانة جديدة"},$S={title:"الصيانة الوقائية",ppmDetails:"تفاصيل الصيانة الوقائية",addPPM:"إضافة صيانة وقائية جديدة"},XS={title:"تصدير",whatToExport:"ما الذي سيتم تصديره",selectedRows:"الصفوف المحددة",currentPage:"الصفحة الحالية",allWithFilters:"الكل مع المرشحات",exportSelected:"تصدير {count} محدد",exportPage:"تصدير {count} في الصفحة الحالية",exportAll:"تصدير الكل {count}",columnsToExport:"الأعمدة للتصدير",selectAll:"تحديد الكل",selectDefault:"تحديد الافتراضي",exporting:"جاري التصدير...",exportingSelected:"جاري تصدير {count} صف(وف) محدد(ة)",exportingPage:"جاري تصدير {count} صف(وف) من الصفحة الحالية",exportingAll:"جاري تصدير جميع {count} صف(وف)",selected:"محدد",rows:"صفوف"},YS={filterBy:"تصفية حسب",sortBy:"ترتيب حسب",createdDate:"تاريخ الإنشاء",latestModifiedDate:"تاريخ آخر تعديل",startDate:"تاريخ البداية",endDate:"تاريخ النهاية",sortCreationNewest:"الإنشاء (الأحدث)",sortCreationOldest:"الإنشاء (الأقدم)",sortModifiedNewest:"التعديل (الأحدث)",sortModifiedOldest:"التعديل (الأقدم)",sortNameAsc:"الاسم (أ-ي)",sortNameDesc:"الاسم (ي-أ)"},ZS={showingToOf:"عرض {{start}} إلى {{end}} من {{total}} {{label}}",showingTo:"عرض {{start}} إلى {{end}} {{label}}",previous:"السابق",next:"التالي",goTo:"انتقل إلى",go:"انتقل",page:"صفحة",assets:"أصول",workOrders:"أوامر عمل",items:"عناصر",issues:"مشكلات",maintenanceTeams:"فرق صيانة"},qS={common:PS,sidebar:FS,login:BS,dashboard:US,commonFields:zS,listPages:HS,assets:VS,workOrders:WS,maintenance:GS,ppm:$S,exportModal:XS,filters:YS,pagination:ZS},Lr={BASE_URL:"",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_WORK_ORDER_METRICS:"/api/method/asset_lite.api.dashboard_api.get_dashboard_work_order_metrics",DASHBOARD_ASSET_DEVICE_STATUS:"/api/method/asset_lite.api.dashboard_api.get_asset_device_status_summary",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",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/asset_lite.api.custom_api.get_user_details",RESET_PASSWORD:"/api/method/frappe.core.doctype.user.user.reset_password",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 KS{constructor(){Ti(this,"baseURL");Ti(this,"endpoints");Ti(this,"defaultHeaders");Ti(this,"timeout");this.baseURL=Lr.BASE_URL,this.endpoints=Lr.ENDPOINTS,this.defaultHeaders=Lr.DEFAULT_HEADERS,this.timeout=Lr.TIMEOUT}getCSRFTokenForGuest(){return xe(this,null,function*(){if(typeof window!="undefined"){const r=window.csrf_token;if(r&&r!=="None")return r}try{const r=yield fetch(`${this.baseURL}${this.endpoints.CSRF_TOKEN}`,{method:"GET",headers:{Accept:"application/json"},credentials:"include"});if(r.ok)return(yield r.json()).message||null}catch(r){}return null})}requestPasswordReset(r,a){return xe(this,null,function*(){var x;const n=r.trim();if(!n)throw new ps("User required",void 0,"USER_REQUIRED");const i=yield this.getCSRFTokenForGuest(),c={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"};i&&(c["X-Frappe-CSRF-Token"]=i);const u=new AbortController,g=setTimeout(()=>u.abort(),45e3),y=()=>u.abort();if(a){if(a.aborted)throw clearTimeout(g),new ps("Aborted",void 0,"TIMEOUT");a.addEventListener("abort",y)}try{const k=yield fetch(`${this.baseURL}${this.endpoints.RESET_PASSWORD}`,{method:"POST",headers:c,body:`user=${encodeURIComponent(n)}`,credentials:"include",signal:u.signal}),N=yield k.json().catch(()=>({})),C=typeof N.message=="string"?N.message:typeof N.message=="object"&&N.message!==null?String((x=N.message.message)!=null?x:""):"";if(k.status===404||C==="not found"||/not found/i.test(C))throw new ps("not found",404,"NOT_FOUND");if(k.status===403)throw new ps("forbidden",403,"FORBIDDEN");if(C==="disabled"||C==="not allowed")throw new ps(C,200,"CANNOT_RESET");if(!k.ok)throw new ps(N.error||`HTTP error! status: ${k.status}`,k.status)}catch(k){throw k instanceof ps?k:k instanceof DOMException&&k.name==="AbortError"?new ps("timeout",void 0,"TIMEOUT"):k instanceof Error&&k.name==="AbortError"?new ps("timeout",void 0,"TIMEOUT"):k}finally{clearTimeout(g),a&&a.removeEventListener("abort",y)}})}getCSRFToken(){return xe(this,null,function*(){var r;try{if(typeof window!="undefined"){const u=window.csrf_token;if(u&&u!=="None")return u}if(!localStorage.getItem("user"))return null;const n=yield fetch(`${this.baseURL}${this.endpoints.CSRF_TOKEN}`,{method:"GET",headers:{Accept:"application/json"},credentials:"include"});if(!n.ok)return null;const c=((r=(yield n.json()).message)==null?void 0:r.csrf_token)||null;return c&&typeof window!="undefined"&&(window.csrf_token=c),c}catch(a){return null}})}refreshCSRFToken(){return xe(this,null,function*(){return typeof window!="undefined"&&(window.csrf_token=null),this.getCSRFToken()})}apiCall(n){return xe(this,arguments,function*(r,a={}){const i=`${this.baseURL}${r}`,c=_e({method:"GET",headers:_e(_e({},this.defaultHeaders),a.headers)},a),u=(c.method||"GET").toUpperCase();if(u!=="GET"&&u!=="HEAD"){const g=yield this.getCSRFToken();g&&(c.headers["X-Frappe-CSRF-Token"]=g)}try{const g=new AbortController,y=setTimeout(()=>g.abort(),this.timeout),x=yield fetch(i,$e(_e({},c),{signal:g.signal}));if(clearTimeout(y),!x.ok){const N=yield x.json().catch(()=>({}));throw new ps(N.error||`HTTP error! status: ${x.status}`,x.status)}const k=yield x.json();return k.message!==void 0?k.message:k}catch(g){throw g instanceof Error?(console.error("API call failed:",g),new ps(g.message)):g}})}login(r){return xe(this,null,function*(){const a=new FormData;a.append("usr",r.email),a.append("pwd",r.password);const n=`${this.baseURL}${this.endpoints.LOGIN}`;try{const i=new AbortController,c=setTimeout(()=>i.abort(),this.timeout),u=yield fetch(n,{method:"POST",headers:{Accept:"application/json"},body:a,credentials:"include",signal:i.signal});if(clearTimeout(c),!u.ok){const y=yield u.json().catch(()=>({})),x="Invalid credentials. Please try again.";throw new ps(x,u.status)}const g=yield u.json();return yield this.refreshCSRFToken(),typeof g.message=="string"&&g.message==="Logged In"?{message:{full_name:g.full_name,user_id:g.user||g.email,home_page:g.home_page,sid:g.sid}}:g.message&&typeof g.message=="object"?{message:g.message}:g.full_name||g.user?{message:g}:{message:g}}catch(i){throw i instanceof Error?new ps("Login failed. Please try again."):i}})}logout(){return xe(this,null,function*(){yield this.apiCall(this.endpoints.LOGOUT,{method:"POST"})})}getUserDetails(r){return xe(this,null,function*(){const a=r?`?user_id=${r}`:"";return this.apiCall(`${this.endpoints.USER_DETAILS}${a}`)})}getDoctypeRecords(r,a,n,i=20,c=0){return xe(this,null,function*(){const u=new URLSearchParams({doctype:r,limit:i.toString(),offset:c.toString()});return a&&u.append("filters",JSON.stringify(a)),n&&u.append("fields",JSON.stringify(n)),this.apiCall(`${this.endpoints.DOCTYPE_RECORDS}?${u}`)})}getDashboardStats(){return xe(this,null,function*(){return this.apiCall(this.endpoints.DASHBOARD_STATS)})}getNumberCards(r){return xe(this,null,function*(){const a=new URLSearchParams;r!=null&&r.company&&a.append("company",r.company),r!=null&&r.site_name&&a.append("site_name",r.site_name);const n=a.toString(),i=n?`${this.endpoints.DASHBOARD_NUMBER_CARDS}?${n}`:this.endpoints.DASHBOARD_NUMBER_CARDS;return this.apiCall(i)})}getDashboardWorkOrderMetrics(r){return xe(this,null,function*(){const a=new URLSearchParams;r!=null&&r.company&&a.append("company",r.company),r!=null&&r.site_name&&a.append("site_name",r.site_name),r!=null&&r.work_order_type&&a.append("work_order_type",r.work_order_type),r!=null&&r.from_date&&a.append("from_date",r.from_date),r!=null&&r.to_date&&a.append("to_date",r.to_date);const n=a.toString(),i=n?`${this.endpoints.DASHBOARD_WORK_ORDER_METRICS}?${n}`:this.endpoints.DASHBOARD_WORK_ORDER_METRICS;return this.apiCall(i)})}getAssetDeviceStatusSummary(r){return xe(this,null,function*(){const a=new URLSearchParams;r!=null&&r.company&&a.append("company",r.company),r!=null&&r.site_name&&a.append("site_name",r.site_name),r!=null&&r.from_date&&a.append("from_date",r.from_date),r!=null&&r.to_date&&a.append("to_date",r.to_date);const n=a.toString(),i=n?`${this.endpoints.DASHBOARD_ASSET_DEVICE_STATUS}?${n}`:this.endpoints.DASHBOARD_ASSET_DEVICE_STATUS;return this.apiCall(i)})}listDashboardCharts(r=!0){return xe(this,null,function*(){const a=new URLSearchParams({public_only:r?"1":"0"});return this.apiCall(`${this.endpoints.DASHBOARD_LIST_CHARTS}?${a}`)})}getDashboardChartData(r,a){return xe(this,null,function*(){const n=new URLSearchParams({chart_name:r});return a&&n.append("report_filters",JSON.stringify(a)),this.apiCall(`${this.endpoints.DASHBOARD_CHART_DATA}?${n}`)})}getKycDetails(){return xe(this,null,function*(){return this.apiCall(this.endpoints.KYC_DETAILS)})}uploadFile(r){return xe(this,null,function*(){const a=new FormData;return a.append("file",r.file),a.append("doctype",r.doctype),a.append("docname",r.docname),a.append("fieldname",r.fieldname),this.apiCall(this.endpoints.UPLOAD_FILE,{method:"POST",headers:{},body:a})})}getUserPermissions(r){return xe(this,null,function*(){const a=r?`?user=${encodeURIComponent(r)}`:"";return this.apiCall(`${this.endpoints.GET_USER_PERMISSIONS}${a}`)})}getPermissionFilters(r,a){return xe(this,null,function*(){const n=new URLSearchParams({target_doctype:r});return a&&n.append("user",a),this.apiCall(`${this.endpoints.GET_PERMISSION_FILTERS}?${n}`)})}getAllowedValues(r,a){return xe(this,null,function*(){const n=new URLSearchParams({allow_doctype:r});return a&&n.append("user",a),this.apiCall(`${this.endpoints.GET_ALLOWED_VALUES}?${n}`)})}checkDocumentAccess(r,a,n){return xe(this,null,function*(){const i=new URLSearchParams({doctype:r,docname:a});return n&&i.append("user",n),this.apiCall(`${this.endpoints.CHECK_DOCUMENT_ACCESS}?${i}`)})}getConfiguredDoctypes(){return xe(this,null,function*(){return this.apiCall(this.endpoints.GET_CONFIGURED_DOCTYPES)})}getUserDefaults(r){return xe(this,null,function*(){const a=r?`?user=${encodeURIComponent(r)}`:"";return this.apiCall(`${this.endpoints.GET_USER_DEFAULTS}${a}`)})}isAuthenticated(){return!!localStorage.getItem("frappe_session_id")}getSessionId(){return localStorage.getItem("frappe_session_id")}setSessionId(r){localStorage.setItem("frappe_session_id",r)}}class ps extends Error{constructor(a,n,i){super(a);Ti(this,"status");Ti(this,"code");this.name="ApiError",this.status=n,this.code=i}}const _t=new KS;function JS(e){return xe(this,null,function*(){try{const r=yield _t.getDoctypeRecords("Translation",{language:e},["source_text","translated_text","context"],1e4,0),a={};return r.records&&r.records.length>0&&r.records.forEach(n=>{const i=n.source_text,c=n.translated_text||i;if(n.context){const u=`${n.context}.${i}`;a[u]=c}else i.includes("."),a[i]=c}),a}catch(r){return console.error("Error fetching translations from Frappe:",r),{}}})}function QS(e){const r={};return Object.keys(e).forEach(a=>{if(a.includes(".")){const n=a.split(".");let i=r;for(let c=0;c<n.length-1;c++){const u=n[c];i[u]||(i[u]={}),i=i[u]}i[n[n.length-1]]=e[a]}else r[a]=e[a]}),r}function V2(e){return xe(this,null,function*(){const r=yield JS(e);return QS(r)})}Xn.use(J_).use(Z6).init({resources:{en:{translation:IS},ar:{translation:qS}},fallbackLng:"en",defaultNS:"translation",interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator"],caches:["localStorage"]}});function jd(){return xe(this,null,function*(){try{if(!localStorage.getItem("user"))return;const r=yield V2("en");Object.keys(r).length>0&&Xn.addResourceBundle("en","translation",r,!0,!0);const a=yield V2("ar");Object.keys(a).length>0&&Xn.addResourceBundle("ar","translation",a,!0,!0),console.log("✓ Translations loaded from Frappe")}catch(e){console.warn("⚠ Could not load translations from Frappe, using static translations:",e)}})}Xn.on("initialized",()=>{jd()});var W2="popstate";function e5(e={}){function r(n,i){let{pathname:c,search:u,hash:g}=n.location;return Xx("",{pathname:c,search:u,hash:g},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function a(n,i){return typeof i=="string"?i:hu(i)}return r5(r,a,null,e)}function Qa(e,r){if(e===!1||e===null||typeof e=="undefined")throw new Error(r)}function xi(e,r){if(!e){typeof console!="undefined"&&console.warn(r);try{throw new Error(r)}catch(a){}}}function t5(){return Math.random().toString(36).substring(2,10)}function G2(e,r){return{usr:e.state,key:e.key,idx:r}}function Xx(e,r,a=null,n){return $e(_e({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof r=="string"?$d(r):r),{state:a,key:r&&r.key||n||t5()})}function hu({pathname:e="/",search:r="",hash:a=""}){return r&&r!=="?"&&(e+=r.charAt(0)==="?"?r:"?"+r),a&&a!=="#"&&(e+=a.charAt(0)==="#"?a:"#"+a),e}function $d(e){let r={};if(e){let a=e.indexOf("#");a>=0&&(r.hash=e.substring(a),e=e.substring(0,a));let n=e.indexOf("?");n>=0&&(r.search=e.substring(n),e=e.substring(0,n)),e&&(r.pathname=e)}return r}function r5(e,r,a,n={}){let{window:i=document.defaultView,v5Compat:c=!1}=n,u=i.history,g="POP",y=null,x=k();x==null&&(x=0,u.replaceState($e(_e({},u.state),{idx:x}),""));function k(){return(u.state||{idx:null}).idx}function N(){g="POP";let I=k(),z=I==null?null:I-x;x=I,y&&y({action:g,location:A.location,delta:z})}function C(I,z){g="PUSH";let U=Xx(A.location,I,z);x=k()+1;let B=G2(U,x),V=A.createHref(U);try{u.pushState(B,"",V)}catch(Z){if(Z instanceof DOMException&&Z.name==="DataCloneError")throw Z;i.location.assign(V)}c&&y&&y({action:g,location:A.location,delta:1})}function O(I,z){g="REPLACE";let U=Xx(A.location,I,z);x=k();let B=G2(U,x),V=A.createHref(U);u.replaceState(B,"",V),c&&y&&y({action:g,location:A.location,delta:0})}function D(I){return a5(I)}let A={get action(){return g},get location(){return e(i,u)},listen(I){if(y)throw new Error("A history only accepts one active listener");return i.addEventListener(W2,N),y=I,()=>{i.removeEventListener(W2,N),y=null}},createHref(I){return r(i,I)},createURL:D,encodeLocation(I){let z=D(I);return{pathname:z.pathname,search:z.search,hash:z.hash}},push:C,replace:O,go(I){return u.go(I)}};return A}function a5(e,r=!1){let a="http://localhost";typeof window!="undefined"&&(a=window.location.origin!=="null"?window.location.origin:window.location.href),Qa(a,"No window.location.(origin|href) available to create URL");let n=typeof e=="string"?e:hu(e);return n=n.replace(/ $/,"%20"),!r&&n.startsWith("//")&&(n=a+n),new URL(n,a)}function Q_(e,r,a="/"){return n5(e,r,a,!1)}function n5(e,r,a,n){let i=typeof r=="string"?$d(r):r,c=rl(i.pathname||"/",a);if(c==null)return null;let u=ew(e);s5(u);let g=null;for(let y=0;g==null&&y<u.length;++y){let x=x5(c);g=m5(u[y],x,n)}return g}function ew(e,r=[],a=[],n="",i=!1){let c=(u,g,y=i,x)=>{let k={relativePath:x===void 0?u.path||"":x,caseSensitive:u.caseSensitive===!0,childrenIndex:g,route:u};if(k.relativePath.startsWith("/")){if(!k.relativePath.startsWith(n)&&y)return;Qa(k.relativePath.startsWith(n),`Absolute route path "${k.relativePath}" nested under path "${n}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),k.relativePath=k.relativePath.slice(n.length)}let N=Jo([n,k.relativePath]),C=a.concat(k);u.children&&u.children.length>0&&(Qa(u.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${N}".`),ew(u.children,r,C,N,y)),!(u.path==null&&!u.index)&&r.push({path:N,score:h5(N,u.index),routesMeta:C})};return e.forEach((u,g)=>{var y;if(u.path===""||!((y=u.path)!=null&&y.includes("?")))c(u,g);else for(let x of tw(u.path))c(u,g,!0,x)}),r}function tw(e){let r=e.split("/");if(r.length===0)return[];let[a,...n]=r,i=a.endsWith("?"),c=a.replace(/\?$/,"");if(n.length===0)return i?[c,""]:[c];let u=tw(n.join("/")),g=[];return g.push(...u.map(y=>y===""?c:[c,y].join("/"))),i&&g.push(...u),g.map(y=>e.startsWith("/")&&y===""?"/":y)}function s5(e){e.sort((r,a)=>r.score!==a.score?a.score-r.score:f5(r.routesMeta.map(n=>n.childrenIndex),a.routesMeta.map(n=>n.childrenIndex)))}var i5=/^:[\w-]+$/,o5=3,l5=2,c5=1,d5=10,u5=-2,$2=e=>e==="*";function h5(e,r){let a=e.split("/"),n=a.length;return a.some($2)&&(n+=u5),r&&(n+=l5),a.filter(i=>!$2(i)).reduce((i,c)=>i+(i5.test(c)?o5:c===""?c5:d5),n)}function f5(e,r){return e.length===r.length&&e.slice(0,-1).every((n,i)=>n===r[i])?e[e.length-1]-r[r.length-1]:0}function m5(e,r,a=!1){let{routesMeta:n}=e,i={},c="/",u=[];for(let g=0;g<n.length;++g){let y=n[g],x=g===n.length-1,k=c==="/"?r:r.slice(c.length)||"/",N=vf({path:y.relativePath,caseSensitive:y.caseSensitive,end:x},k),C=y.route;if(!N&&x&&a&&!n[n.length-1].route.index&&(N=vf({path:y.relativePath,caseSensitive:y.caseSensitive,end:!1},k)),!N)return null;Object.assign(i,N.params),u.push({params:i,pathname:Jo([c,N.pathname]),pathnameBase:_5(Jo([c,N.pathnameBase])),route:C}),N.pathnameBase!=="/"&&(c=Jo([c,N.pathnameBase]))}return u}function vf(e,r){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[a,n]=g5(e.path,e.caseSensitive,e.end),i=r.match(a);if(!i)return null;let c=i[0],u=c.replace(/(.)\/+$/,"$1"),g=i.slice(1);return{params:n.reduce((x,{paramName:k,isOptional:N},C)=>{if(k==="*"){let D=g[C]||"";u=c.slice(0,c.length-D.length).replace(/(.)\/+$/,"$1")}const O=g[C];return N&&!O?x[k]=void 0:x[k]=(O||"").replace(/%2F/g,"/"),x},{}),pathname:c,pathnameBase:u,pattern:e}}function g5(e,r=!1,a=!0){xi(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let n=[],i="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(u,g,y)=>(n.push({paramName:g,isOptional:y!=null}),y?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(n.push({paramName:"*"}),i+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?i+="\\/*$":e!==""&&e!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,r?void 0:"i"),n]}function x5(e){try{return e.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return xi(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${r}).`),e}}function rl(e,r){if(r==="/")return e;if(!e.toLowerCase().startsWith(r.toLowerCase()))return null;let a=r.endsWith("/")?r.length-1:r.length,n=e.charAt(a);return n&&n!=="/"?null:e.slice(a)||"/"}var p5=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,y5=e=>p5.test(e);function b5(e,r="/"){let{pathname:a,search:n="",hash:i=""}=typeof e=="string"?$d(e):e,c;if(a)if(y5(a))c=a;else{if(a.includes("//")){let u=a;a=a.replace(/\/\/+/g,"/"),xi(!1,`Pathnames cannot have embedded double slashes - normalizing ${u} -> ${a}`)}a.startsWith("/")?c=X2(a.substring(1),"/"):c=X2(a,r)}else c=r;return{pathname:c,search:w5(n),hash:k5(i)}}function X2(e,r){let a=r.replace(/\/+$/,"").split("/");return e.split("/").forEach(i=>{i===".."?a.length>1&&a.pop():i!=="."&&a.push(i)}),a.length>1?a.join("/"):"/"}function px(e,r,a,n){return`Cannot include a '${e}' character in a manually specified \`to.${r}\` field [${JSON.stringify(n)}]. Please separate it out to the \`to.${a}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function v5(e){return e.filter((r,a)=>a===0||r.route.path&&r.route.path.length>0)}function xp(e){let r=v5(e);return r.map((a,n)=>n===r.length-1?a.pathname:a.pathnameBase)}function pp(e,r,a,n=!1){let i;typeof e=="string"?i=$d(e):(i=_e({},e),Qa(!i.pathname||!i.pathname.includes("?"),px("?","pathname","search",i)),Qa(!i.pathname||!i.pathname.includes("#"),px("#","pathname","hash",i)),Qa(!i.search||!i.search.includes("#"),px("#","search","hash",i)));let c=e===""||i.pathname==="",u=c?"/":i.pathname,g;if(u==null)g=a;else{let N=r.length-1;if(!n&&u.startsWith("..")){let C=u.split("/");for(;C[0]==="..";)C.shift(),N-=1;i.pathname=C.join("/")}g=N>=0?r[N]:"/"}let y=b5(i,g),x=u&&u!=="/"&&u.endsWith("/"),k=(c||u===".")&&a.endsWith("/");return!y.pathname.endsWith("/")&&(x||k)&&(y.pathname+="/"),y}var Jo=e=>e.join("/").replace(/\/\/+/g,"/"),_5=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),w5=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,k5=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function N5(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function S5(e){return e.map(r=>r.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var rw=["POST","PUT","PATCH","DELETE"];new Set(rw);var C5=["GET",...rw];new Set(C5);var Xd=E.createContext(null);Xd.displayName="DataRouter";var Zf=E.createContext(null);Zf.displayName="DataRouterState";E.createContext(!1);var aw=E.createContext({isTransitioning:!1});aw.displayName="ViewTransition";var E5=E.createContext(new Map);E5.displayName="Fetchers";var j5=E.createContext(null);j5.displayName="Await";var Di=E.createContext(null);Di.displayName="Navigation";var ku=E.createContext(null);ku.displayName="Location";var ao=E.createContext({outlet:null,matches:[],isDataRoute:!1});ao.displayName="Route";var yp=E.createContext(null);yp.displayName="RouteError";function T5(e,{relative:r}={}){Qa(Yd(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:n}=E.useContext(Di),{hash:i,pathname:c,search:u}=Nu(e,{relative:r}),g=c;return a!=="/"&&(g=c==="/"?a:Jo([a,c])),n.createHref({pathname:g,search:u,hash:i})}function Yd(){return E.useContext(ku)!=null}function yi(){return Qa(Yd(),"useLocation() may be used only in the context of a <Router> component."),E.useContext(ku).location}var nw="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function sw(e){E.useContext(Di).static||E.useLayoutEffect(e)}function ua(){let{isDataRoute:e}=E.useContext(ao);return e?H5():A5()}function A5(){Qa(Yd(),"useNavigate() may be used only in the context of a <Router> component.");let e=E.useContext(Xd),{basename:r,navigator:a}=E.useContext(Di),{matches:n}=E.useContext(ao),{pathname:i}=yi(),c=JSON.stringify(xp(n)),u=E.useRef(!1);return sw(()=>{u.current=!0}),E.useCallback((y,x={})=>{if(xi(u.current,nw),!u.current)return;if(typeof y=="number"){a.go(y);return}let k=pp(y,JSON.parse(c),i,x.relative==="path");e==null&&r!=="/"&&(k.pathname=k.pathname==="/"?r:Jo([r,k.pathname])),(x.replace?a.replace:a.push)(k,x.state,x)},[r,a,c,i,e])}E.createContext(null);function Yl(){let{matches:e}=E.useContext(ao),r=e[e.length-1];return r?r.params:{}}function Nu(e,{relative:r}={}){let{matches:a}=E.useContext(ao),{pathname:n}=yi(),i=JSON.stringify(xp(a));return E.useMemo(()=>pp(e,JSON.parse(i),n,r==="path"),[e,i,n,r])}function O5(e,r){return iw(e,r)}function iw(e,r,a,n,i){var U;Qa(Yd(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:c}=E.useContext(Di),{matches:u}=E.useContext(ao),g=u[u.length-1],y=g?g.params:{},x=g?g.pathname:"/",k=g?g.pathnameBase:"/",N=g&&g.route;{let B=N&&N.path||"";ow(x,!N||B.endsWith("*")||B.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${x}" (under <Route path="${B}">) 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="${B}"> to <Route path="${B==="/"?"*":`${B}/*`}">.`)}let C=yi(),O;if(r){let B=typeof r=="string"?$d(r):r;Qa(k==="/"||((U=B.pathname)==null?void 0:U.startsWith(k)),`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 "${k}" but pathname "${B.pathname}" was given in the \`location\` prop.`),O=B}else O=C;let D=O.pathname||"/",A=D;if(k!=="/"){let B=k.replace(/^\//,"").split("/");A="/"+D.replace(/^\//,"").split("/").slice(B.length).join("/")}let I=Q_(e,{pathname:A});xi(N||I!=null,`No routes matched location "${O.pathname}${O.search}${O.hash}" `),xi(I==null||I[I.length-1].route.element!==void 0||I[I.length-1].route.Component!==void 0||I[I.length-1].route.lazy!==void 0,`Matched leaf route at location "${O.pathname}${O.search}${O.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 z=I5(I&&I.map(B=>Object.assign({},B,{params:Object.assign({},y,B.params),pathname:Jo([k,c.encodeLocation?c.encodeLocation(B.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:B.pathname]),pathnameBase:B.pathnameBase==="/"?k:Jo([k,c.encodeLocation?c.encodeLocation(B.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:B.pathnameBase])})),u,a,n,i);return r&&z?E.createElement(ku.Provider,{value:{location:_e({pathname:"/",search:"",hash:"",state:null,key:"default"},O),navigationType:"POP"}},z):z}function R5(){let e=z5(),r=N5(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),a=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:n},c={padding:"2px 4px",backgroundColor:n},u=null;return console.error("Error handled by React Router default ErrorBoundary:",e),u=E.createElement(E.Fragment,null,E.createElement("p",null,"💿 Hey developer 👋"),E.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",E.createElement("code",{style:c},"ErrorBoundary")," or"," ",E.createElement("code",{style:c},"errorElement")," prop on your route.")),E.createElement(E.Fragment,null,E.createElement("h2",null,"Unexpected Application Error!"),E.createElement("h3",{style:{fontStyle:"italic"}},r),a?E.createElement("pre",{style:i},a):null,u)}var M5=E.createElement(R5,null),D5=class extends E.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,r){return r.location!==e.location||r.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:r.error,location:r.location,revalidation:e.revalidation||r.revalidation}}componentDidCatch(e,r){this.props.onError?this.props.onError(e,r):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?E.createElement(ao.Provider,{value:this.props.routeContext},E.createElement(yp.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function L5({routeContext:e,match:r,children:a}){let n=E.useContext(Xd);return n&&n.static&&n.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(n.staticContext._deepestRenderedBoundaryId=r.route.id),E.createElement(ao.Provider,{value:e},a)}function I5(e,r=[],a=null,n=null,i=null){if(e==null){if(!a)return null;if(a.errors)e=a.matches;else if(r.length===0&&!a.initialized&&a.matches.length>0)e=a.matches;else return null}let c=e,u=a==null?void 0:a.errors;if(u!=null){let k=c.findIndex(N=>N.route.id&&(u==null?void 0:u[N.route.id])!==void 0);Qa(k>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),c=c.slice(0,Math.min(c.length,k+1))}let g=!1,y=-1;if(a)for(let k=0;k<c.length;k++){let N=c[k];if((N.route.HydrateFallback||N.route.hydrateFallbackElement)&&(y=k),N.route.id){let{loaderData:C,errors:O}=a,D=N.route.loader&&!C.hasOwnProperty(N.route.id)&&(!O||O[N.route.id]===void 0);if(N.route.lazy||D){g=!0,y>=0?c=c.slice(0,y+1):c=[c[0]];break}}}let x=a&&n?(k,N)=>{var C,O,D;n(k,{location:a.location,params:(D=(O=(C=a.matches)==null?void 0:C[0])==null?void 0:O.params)!=null?D:{},unstable_pattern:S5(a.matches),errorInfo:N})}:void 0;return c.reduceRight((k,N,C)=>{let O,D=!1,A=null,I=null;a&&(O=u&&N.route.id?u[N.route.id]:void 0,A=N.route.errorElement||M5,g&&(y<0&&C===0?(ow("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),D=!0,I=null):y===C&&(D=!0,I=N.route.hydrateFallbackElement||null)));let z=r.concat(c.slice(0,C+1)),U=()=>{let B;return O?B=A:D?B=I:N.route.Component?B=E.createElement(N.route.Component,null):N.route.element?B=N.route.element:B=k,E.createElement(L5,{match:N,routeContext:{outlet:k,matches:z,isDataRoute:a!=null},children:B})};return a&&(N.route.ErrorBoundary||N.route.errorElement||C===0)?E.createElement(D5,{location:a.location,revalidation:a.revalidation,component:A,error:O,children:U(),routeContext:{outlet:null,matches:z,isDataRoute:!0},onError:x}):U()},null)}function bp(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function P5(e){let r=E.useContext(Xd);return Qa(r,bp(e)),r}function F5(e){let r=E.useContext(Zf);return Qa(r,bp(e)),r}function B5(e){let r=E.useContext(ao);return Qa(r,bp(e)),r}function vp(e){let r=B5(e),a=r.matches[r.matches.length-1];return Qa(a.route.id,`${e} can only be used on routes that contain a unique "id"`),a.route.id}function U5(){return vp("useRouteId")}function z5(){var n;let e=E.useContext(yp),r=F5("useRouteError"),a=vp("useRouteError");return e!==void 0?e:(n=r.errors)==null?void 0:n[a]}function H5(){let{router:e}=P5("useNavigate"),r=vp("useNavigate"),a=E.useRef(!1);return sw(()=>{a.current=!0}),E.useCallback((u,...g)=>xe(null,[u,...g],function*(i,c={}){xi(a.current,nw),a.current&&(typeof i=="number"?yield e.navigate(i):yield e.navigate(i,_e({fromRouteId:r},c)))}),[e,r])}var Y2={};function ow(e,r,a){!r&&!Y2[e]&&(Y2[e]=!0,xi(!1,a))}E.memo(V5);function V5({routes:e,future:r,state:a,unstable_onError:n}){return iw(e,void 0,a,n,r)}function fu({to:e,replace:r,state:a,relative:n}){Qa(Yd(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=E.useContext(Di);xi(!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}=E.useContext(ao),{pathname:u}=yi(),g=ua(),y=pp(e,xp(c),u,n==="path"),x=JSON.stringify(y);return E.useEffect(()=>{g(JSON.parse(x),{replace:r,state:a,relative:n})},[g,x,n,r,a]),null}function da(e){Qa(!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 W5({basename:e="/",children:r=null,location:a,navigationType:n="POP",navigator:i,static:c=!1,unstable_useTransitions:u}){Qa(!Yd(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let g=e.replace(/^\/*/,"/"),y=E.useMemo(()=>({basename:g,navigator:i,static:c,unstable_useTransitions:u,future:{}}),[g,i,c,u]);typeof a=="string"&&(a=$d(a));let{pathname:x="/",search:k="",hash:N="",state:C=null,key:O="default"}=a,D=E.useMemo(()=>{let A=rl(x,g);return A==null?null:{location:{pathname:A,search:k,hash:N,state:C,key:O},navigationType:n}},[g,x,k,N,C,O,n]);return xi(D!=null,`<Router basename="${g}"> is not able to match the URL "${x}${k}${N}" because it does not start with the basename, so the <Router> won't render anything.`),D==null?null:E.createElement(Di.Provider,{value:y},E.createElement(ku.Provider,{children:r,value:D}))}function G5({children:e,location:r}){return O5(Yx(e),r)}function Yx(e,r=[]){let a=[];return E.Children.forEach(e,(n,i)=>{if(!E.isValidElement(n))return;let c=[...r,i];if(n.type===E.Fragment){a.push.apply(a,Yx(n.props.children,c));return}Qa(n.type===da,`[${typeof n.type=="string"?n.type:n.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Qa(!n.props.index||!n.props.children,"An index route cannot have child routes.");let u={id:n.props.id||c.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,middleware:n.props.middleware,loader:n.props.loader,action:n.props.action,hydrateFallbackElement:n.props.hydrateFallbackElement,HydrateFallback:n.props.HydrateFallback,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.hasErrorBoundary===!0||n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(u.children=Yx(n.props.children,c)),a.push(u)}),a}var lf="get",cf="application/x-www-form-urlencoded";function qf(e){return typeof HTMLElement!="undefined"&&e instanceof HTMLElement}function $5(e){return qf(e)&&e.tagName.toLowerCase()==="button"}function X5(e){return qf(e)&&e.tagName.toLowerCase()==="form"}function Y5(e){return qf(e)&&e.tagName.toLowerCase()==="input"}function Z5(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function q5(e,r){return e.button===0&&(!r||r==="_self")&&!Z5(e)}function Zx(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((r,a)=>{let n=e[a];return r.concat(Array.isArray(n)?n.map(i=>[a,i]):[[a,n]])},[]))}function K5(e,r){let a=Zx(e);return r&&r.forEach((n,i)=>{a.has(i)||r.getAll(i).forEach(c=>{a.append(i,c)})}),a}var Wh=null;function J5(){if(Wh===null)try{new FormData(document.createElement("form"),0),Wh=!1}catch(e){Wh=!0}return Wh}var Q5=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function yx(e){return e!=null&&!Q5.has(e)?(xi(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${cf}"`),null):e}function e8(e,r){let a,n,i,c,u;if(X5(e)){let g=e.getAttribute("action");n=g?rl(g,r):null,a=e.getAttribute("method")||lf,i=yx(e.getAttribute("enctype"))||cf,c=new FormData(e)}else if($5(e)||Y5(e)&&(e.type==="submit"||e.type==="image")){let g=e.form;if(g==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let y=e.getAttribute("formaction")||g.getAttribute("action");if(n=y?rl(y,r):null,a=e.getAttribute("formmethod")||g.getAttribute("method")||lf,i=yx(e.getAttribute("formenctype"))||yx(g.getAttribute("enctype"))||cf,c=new FormData(g,e),!J5()){let{name:x,type:k,value:N}=e;if(k==="image"){let C=x?`${x}.`:"";c.append(`${C}x`,"0"),c.append(`${C}y`,"0")}else x&&c.append(x,N)}}else{if(qf(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a=lf,n=null,i=cf,u=e}return c&&i==="text/plain"&&(u=c,c=void 0),{action:n,method:a.toLowerCase(),encType:i,formData:c,body:u}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function _p(e,r){if(e===!1||e===null||typeof e=="undefined")throw new Error(r)}function t8(e,r,a){let n=typeof e=="string"?new URL(e,typeof window=="undefined"?"server://singlefetch/":window.location.origin):e;return n.pathname==="/"?n.pathname=`_root.${a}`:r&&rl(n.pathname,r)==="/"?n.pathname=`${r.replace(/\/$/,"")}/_root.${a}`:n.pathname=`${n.pathname.replace(/\/$/,"")}.${a}`,n}function r8(e,r){return xe(this,null,function*(){if(e.id in r)return r[e.id];try{let a=yield import(e.module);return r[e.id]=a,a}catch(a){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(a),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}})}function a8(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}function n8(e,r,a){return xe(this,null,function*(){let n=yield Promise.all(e.map(i=>xe(null,null,function*(){let c=r.routes[i.route.id];if(c){let u=yield r8(c,a);return u.links?u.links():[]}return[]})));return l8(n.flat(1).filter(a8).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?$e(_e({},i),{rel:"prefetch",as:"style"}):$e(_e({},i),{rel:"prefetch"})))})}function Z2(e,r,a,n,i,c){let u=(y,x)=>a[x]?y.route.id!==a[x].route.id:!0,g=(y,x)=>{var k;return a[x].pathname!==y.pathname||((k=a[x].route.path)==null?void 0:k.endsWith("*"))&&a[x].params["*"]!==y.params["*"]};return c==="assets"?r.filter((y,x)=>u(y,x)||g(y,x)):c==="data"?r.filter((y,x)=>{var N;let k=n.routes[y.route.id];if(!k||!k.hasLoader)return!1;if(u(y,x)||g(y,x))return!0;if(y.route.shouldRevalidate){let C=y.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:((N=a[0])==null?void 0:N.params)||{},nextUrl:new URL(e,window.origin),nextParams:y.params,defaultShouldRevalidate:!0});if(typeof C=="boolean")return C}return!0}):[]}function s8(e,r,{includeHydrateFallback:a}={}){return i8(e.map(n=>{let i=r.routes[n.route.id];if(!i)return[];let c=[i.module];return i.clientActionModule&&(c=c.concat(i.clientActionModule)),i.clientLoaderModule&&(c=c.concat(i.clientLoaderModule)),a&&i.hydrateFallbackModule&&(c=c.concat(i.hydrateFallbackModule)),i.imports&&(c=c.concat(i.imports)),c}).flat(1))}function i8(e){return[...new Set(e)]}function o8(e){let r={},a=Object.keys(e).sort();for(let n of a)r[n]=e[n];return r}function l8(e,r){let a=new Set;return new Set(r),e.reduce((n,i)=>{let c=JSON.stringify(o8(i));return a.has(c)||(a.add(c),n.push({key:c,link:i})),n},[])}function lw(){let e=E.useContext(Xd);return _p(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function c8(){let e=E.useContext(Zf);return _p(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var wp=E.createContext(void 0);wp.displayName="FrameworkContext";function cw(){let e=E.useContext(wp);return _p(e,"You must render this element inside a <HydratedRouter> element"),e}function d8(e,r){let a=E.useContext(wp),[n,i]=E.useState(!1),[c,u]=E.useState(!1),{onFocus:g,onBlur:y,onMouseEnter:x,onMouseLeave:k,onTouchStart:N}=r,C=E.useRef(null);E.useEffect(()=>{if(e==="render"&&u(!0),e==="viewport"){let A=z=>{z.forEach(U=>{u(U.isIntersecting)})},I=new IntersectionObserver(A,{threshold:.5});return C.current&&I.observe(C.current),()=>{I.disconnect()}}},[e]),E.useEffect(()=>{if(n){let A=setTimeout(()=>{u(!0)},100);return()=>{clearTimeout(A)}}},[n]);let O=()=>{i(!0)},D=()=>{i(!1),u(!1)};return a?e!=="intent"?[c,C,{}]:[c,C,{onFocus:G0(g,O),onBlur:G0(y,D),onMouseEnter:G0(x,O),onMouseLeave:G0(k,D),onTouchStart:G0(N,O)}]:[!1,C,{}]}function G0(e,r){return a=>{e&&e(a),a.defaultPrevented||r(a)}}function u8(a){var n=a,{page:e}=n,r=Gs(n,["page"]);let{router:i}=lw(),c=E.useMemo(()=>Q_(i.routes,e,i.basename),[i.routes,e,i.basename]);return c?E.createElement(f8,_e({page:e,matches:c},r)):null}function h8(e){let{manifest:r,routeModules:a}=cw(),[n,i]=E.useState([]);return E.useEffect(()=>{let c=!1;return n8(e,r,a).then(u=>{c||i(u)}),()=>{c=!0}},[e,r,a]),n}function f8(n){var i=n,{page:e,matches:r}=i,a=Gs(i,["page","matches"]);let c=yi(),{manifest:u,routeModules:g}=cw(),{basename:y}=lw(),{loaderData:x,matches:k}=c8(),N=E.useMemo(()=>Z2(e,r,k,u,c,"data"),[e,r,k,u,c]),C=E.useMemo(()=>Z2(e,r,k,u,c,"assets"),[e,r,k,u,c]),O=E.useMemo(()=>{if(e===c.pathname+c.search+c.hash)return[];let I=new Set,z=!1;if(r.forEach(B=>{var Z;let V=u.routes[B.route.id];!V||!V.hasLoader||(!N.some(W=>W.route.id===B.route.id)&&B.route.id in x&&((Z=g[B.route.id])!=null&&Z.shouldRevalidate)||V.hasClientLoader?z=!0:I.add(B.route.id))}),I.size===0)return[];let U=t8(e,y,"data");return z&&I.size>0&&U.searchParams.set("_routes",r.filter(B=>I.has(B.route.id)).map(B=>B.route.id).join(",")),[U.pathname+U.search]},[y,x,c,u,N,r,e,g]),D=E.useMemo(()=>s8(C,u),[C,u]),A=h8(C);return E.createElement(E.Fragment,null,O.map(I=>E.createElement("link",_e({key:I,rel:"prefetch",as:"fetch",href:I},a))),D.map(I=>E.createElement("link",_e({key:I,rel:"modulepreload",href:I},a))),A.map(({key:I,link:z})=>E.createElement("link",_e({key:I,nonce:a.nonce},z))))}function m8(...e){return r=>{e.forEach(a=>{typeof a=="function"?a(r):a!=null&&(a.current=r)})}}var dw=typeof window!="undefined"&&typeof window.document!="undefined"&&typeof window.document.createElement!="undefined";try{dw&&(window.__reactRouterVersion="7.10.0")}catch(e){}function g8({basename:e,children:r,unstable_useTransitions:a,window:n}){let i=E.useRef();i.current==null&&(i.current=e5({window:n,v5Compat:!0}));let c=i.current,[u,g]=E.useState({action:c.action,location:c.location}),y=E.useCallback(x=>{a===!1?g(x):E.startTransition(()=>g(x))},[a]);return E.useLayoutEffect(()=>c.listen(y),[c,y]),E.createElement(W5,{basename:e,children:r,location:u.location,navigationType:u.action,navigator:c,unstable_useTransitions:a===!0})}var uw=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,kp=E.forwardRef(function(D,O){var A=D,{onClick:r,discover:a="render",prefetch:n="none",relative:i,reloadDocument:c,replace:u,state:g,target:y,to:x,preventScrollReset:k,viewTransition:N}=A,C=Gs(A,["onClick","discover","prefetch","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"]);let{basename:I,unstable_useTransitions:z}=E.useContext(Di),U=typeof x=="string"&&uw.test(x),B,V=!1;if(typeof x=="string"&&U&&(B=x,dw))try{let se=new URL(window.location.href),ce=x.startsWith("//")?new URL(se.protocol+x):new URL(x),Ce=rl(ce.pathname,I);ce.origin===se.origin&&Ce!=null?x=Ce+ce.search+ce.hash:V=!0}catch(se){xi(!1,`<Link to="${x}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let Z=T5(x,{relative:i}),[W,H,le]=d8(n,C),Q=b8(x,{replace:u,state:g,target:y,preventScrollReset:k,relative:i,viewTransition:N,unstable_useTransitions:z});function Ne(se){r&&r(se),se.defaultPrevented||Q(se)}let oe=E.createElement("a",$e(_e(_e({},C),le),{href:B||Z,onClick:V||c?r:Ne,ref:m8(O,H),target:y,"data-discover":!U&&a==="render"?"true":void 0}));return W&&!U?E.createElement(E.Fragment,null,oe,E.createElement(u8,{page:Z})):oe});kp.displayName="Link";var x8=E.forwardRef(function(N,k){var C=N,{"aria-current":r="page",caseSensitive:a=!1,className:n="",end:i=!1,style:c,to:u,viewTransition:g,children:y}=C,x=Gs(C,["aria-current","caseSensitive","className","end","style","to","viewTransition","children"]);let O=Nu(u,{relative:x.relative}),D=yi(),A=E.useContext(Zf),{navigator:I,basename:z}=E.useContext(Di),U=A!=null&&N8(O)&&g===!0,B=I.encodeLocation?I.encodeLocation(O).pathname:O.pathname,V=D.pathname,Z=A&&A.navigation&&A.navigation.location?A.navigation.location.pathname:null;a||(V=V.toLowerCase(),Z=Z?Z.toLowerCase():null,B=B.toLowerCase()),Z&&z&&(Z=rl(Z,z)||Z);const W=B!=="/"&&B.endsWith("/")?B.length-1:B.length;let H=V===B||!i&&V.startsWith(B)&&V.charAt(W)==="/",le=Z!=null&&(Z===B||!i&&Z.startsWith(B)&&Z.charAt(B.length)==="/"),Q={isActive:H,isPending:le,isTransitioning:U},Ne=H?r:void 0,oe;typeof n=="function"?oe=n(Q):oe=[n,H?"active":null,le?"pending":null,U?"transitioning":null].filter(Boolean).join(" ");let se=typeof c=="function"?c(Q):c;return E.createElement(kp,$e(_e({},x),{"aria-current":Ne,className:oe,ref:k,style:se,to:u,viewTransition:g}),typeof y=="function"?y(Q):y)});x8.displayName="NavLink";var p8=E.forwardRef((D,O)=>{var A=D,{discover:e="render",fetcherKey:r,navigate:a,reloadDocument:n,replace:i,state:c,method:u=lf,action:g,onSubmit:y,relative:x,preventScrollReset:k,viewTransition:N}=A,C=Gs(A,["discover","fetcherKey","navigate","reloadDocument","replace","state","method","action","onSubmit","relative","preventScrollReset","viewTransition"]);let{unstable_useTransitions:I}=E.useContext(Di),z=w8(),U=k8(g,{relative:x}),B=u.toLowerCase()==="get"?"get":"post",V=typeof g=="string"&&uw.test(g),Z=W=>{if(y&&y(W),W.defaultPrevented)return;W.preventDefault();let H=W.nativeEvent.submitter,le=(H==null?void 0:H.getAttribute("formmethod"))||u,Q=()=>z(H||W.currentTarget,{fetcherKey:r,method:le,navigate:a,replace:i,state:c,relative:x,preventScrollReset:k,viewTransition:N});I&&a!==!1?E.startTransition(()=>Q()):Q()};return E.createElement("form",$e(_e({ref:O,method:B,action:U,onSubmit:n?y:Z},C),{"data-discover":!V&&e==="render"?"true":void 0}))});p8.displayName="Form";function y8(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function hw(e){let r=E.useContext(Xd);return Qa(r,y8(e)),r}function b8(e,{target:r,replace:a,state:n,preventScrollReset:i,relative:c,viewTransition:u,unstable_useTransitions:g}={}){let y=ua(),x=yi(),k=Nu(e,{relative:c});return E.useCallback(N=>{if(q5(N,r)){N.preventDefault();let C=a!==void 0?a:hu(x)===hu(k),O=()=>y(e,{replace:C,state:n,preventScrollReset:i,relative:c,viewTransition:u});g?E.startTransition(()=>O()):O()}},[x,y,k,a,n,r,e,i,c,u,g])}function Li(e){xi(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 r=E.useRef(Zx(e)),a=E.useRef(!1),n=yi(),i=E.useMemo(()=>K5(n.search,a.current?null:r.current),[n.search]),c=ua(),u=E.useCallback((g,y)=>{const x=Zx(typeof g=="function"?g(new URLSearchParams(i)):g);a.current=!0,c("?"+x,y)},[c,i]);return[i,u]}var v8=0,_8=()=>`__${String(++v8)}__`;function w8(){let{router:e}=hw("useSubmit"),{basename:r}=E.useContext(Di),a=U5(),n=e.fetch,i=e.navigate;return E.useCallback((g,...y)=>xe(null,[g,...y],function*(c,u={}){let{action:x,method:k,encType:N,formData:C,body:O}=e8(c,r);if(u.navigate===!1){let D=u.fetcherKey||_8();yield n(D,a,u.action||x,{preventScrollReset:u.preventScrollReset,formData:C,body:O,formMethod:u.method||k,formEncType:u.encType||N,flushSync:u.flushSync})}else yield i(u.action||x,{preventScrollReset:u.preventScrollReset,formData:C,body:O,formMethod:u.method||k,formEncType:u.encType||N,replace:u.replace,state:u.state,fromRouteId:a,flushSync:u.flushSync,viewTransition:u.viewTransition})}),[n,i,r,a])}function k8(e,{relative:r}={}){let{basename:a}=E.useContext(Di),n=E.useContext(ao);Qa(n,"useFormAction must be used inside a RouteContext");let[i]=n.matches.slice(-1),c=_e({},Nu(e||".",{relative:r})),u=yi();if(e==null){c.search=u.search;let g=new URLSearchParams(c.search),y=g.getAll("index");if(y.some(k=>k==="")){g.delete("index"),y.filter(N=>N).forEach(N=>g.append("index",N));let k=g.toString();c.search=k?`?${k}`:""}}return(!e||e===".")&&i.route.index&&(c.search=c.search?c.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(c.pathname=c.pathname==="/"?a:Jo([a,c.pathname])),hu(c)}function N8(e,{relative:r}={}){let a=E.useContext(aw);Qa(a!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:n}=hw("useViewTransitionState"),i=Nu(e,{relative:r});if(!a.isTransitioning)return!1;let c=rl(a.currentLocation.pathname,n)||a.currentLocation.pathname,u=rl(a.nextLocation.pathname,n)||a.nextLocation.pathname;return vf(i.pathname,u)!=null||vf(i.pathname,c)!=null}var Su=V_();const S8=e=>{e&&e!=="None"&&typeof window!="undefined"&&(window.csrf_token=e)},Kf=()=>xe(null,null,function*(){try{const e=yield _t.apiCall("/api/method/asset_lite.api.custom_api.get_user_details");if(!(e!=null&&e.user_id)&&!(e!=null&&e.email))throw new Error("No user logged in");return S8(e.csrf_token),$e(_e({},e),{name:e.user_id||e.email,email:e.email||e.user_id||"",roles:e.roles||[]})}catch(e){throw console.error("Error fetching user profile:",e),e}}),C8=(e,r)=>xe(null,null,function*(){try{const a=yield _t.getCSRFToken(),n={"Content-Type":"application/json",Accept:"application/json"};a&&(n["X-Frappe-CSRF-Token"]=a);const i=yield fetch(`/api/resource/User/${encodeURIComponent(e)}`,{method:"PUT",headers:n,credentials:"include",body:JSON.stringify(r)}),c=yield i.json();if(!i.ok)throw new Error(c.exc||c.message||"Failed to update profile");return c.data}catch(a){throw console.error("Error updating user profile:",a),a}}),E8=(e,r)=>xe(null,null,function*(){try{if(!r)throw new Error("Current password is required");const a=yield _t.getCSRFToken(),n={"Content-Type":"application/json",Accept:"application/json"};a&&(n["X-Frappe-CSRF-Token"]=a);const i=yield fetch("/api/method/frappe.core.doctype.user.user.update_password",{method:"POST",headers:n,credentials:"include",body:JSON.stringify({new_password:e,old_password:r})}),c=yield i.json();if(!i.ok){let u="Failed to change password";if(c.exc){if(c.exc.includes("Incorrect Old Password"))u="Incorrect old password";else if(c.exc.includes("Password cannot be same"))u="New password cannot be the same as old password";else if(c._server_messages)try{const g=JSON.parse(c._server_messages);u=JSON.parse(g[0]).message||u}catch(g){}}throw new Error(u)}return{message:"Password changed successfully"}}catch(a){throw console.error("Error changing password:",a),a}}),qx={END_USER:"End User",PHCC_END_USER:"PHCC End User",TECHNICIAN:"Technician"},j8=["assets","work-orders","support"],T8=["dashboard","assets","inventory","work-orders","maintenance-calendar","active-map","procurement","support"];function Cu(e){return e===qx.END_USER||e===qx.PHCC_END_USER}function Np(e){return e===qx.TECHNICIAN}function fw(e){return Cu(e)?"/work-orders":"/dashboard"}function Zi(e,r){return Cu(r)?j8.includes(e):Np(r)?T8.includes(e):!0}function bx(){try{const e=localStorage.getItem("user");if(!e)return"";const r=JSON.parse(e);return r.email||r.user_id||r.name||""}catch(e){return""}}function vc(){try{const e=localStorage.getItem("user");return e&&JSON.parse(e).role_profile_name||""}catch(e){return""}}function A8(e,r){return r?Cu(e)?{filters:{owner:r}}:Np(e)?{or_filters:[["owner","=",r],["custom_assign_to_contractor","=",r],["assigned_technician","=",r]]}:null:null}function O8(e,r,a,n){const i=_e({},e);for(const[u,g]of Object.entries(r))i[u]||(i[u]=g);const c=A8(a,n||"");return c?_e({filters:_e(_e({},i),c.filters||{})},c.or_filters?{or_filters:c.or_filters}:{}):{filters:i}}function mw(){return xe(this,null,function*(){try{const e=yield Kf(),r=localStorage.getItem("user");if(r){const a=JSON.parse(r);localStorage.setItem("user",JSON.stringify($e(_e({},a),{email:e.email||e.name||a.email,full_name:e.full_name||a.full_name,role_profile_name:e.role_profile_name||"",custom_site_name:e.custom_site_name||"",custom_phcc_site_name:e.custom_phcc_site_name||""})))}return fw(e.role_profile_name)}catch(e){return console.warn("[AppRouting] Could not load role profile, using default route:",e),"/dashboard"}})}function gw(){return xe(this,null,function*(){var r;if(!localStorage.getItem("user"))return null;try{const a=yield fetch("/api/method/asset_lite.api.custom_api.get_user_details",{method:"GET",headers:{Accept:"application/json"},credentials:"include"});return!a.ok||!((r=(yield a.json()).message)!=null&&r.user_id)?(localStorage.removeItem("user"),null):mw()}catch(a){return localStorage.removeItem("user"),null}})}const vx="asm_show_after_password_reset",R8=()=>{const[e,r]=E.useState({email:"",password:""}),[a,n]=E.useState(!1),[i,c]=E.useState(null),[u,g]=E.useState(!1),[y,x]=E.useState(""),[k,N]=E.useState(!1),[C,O]=E.useState(null),[D,A]=E.useState(null),[I,z]=E.useState(!1),[U,B]=E.useState(!1),V=E.useRef(!1),Z=E.useRef(null),W=ua(),H=yi(),{t:le}=oa(),Q="/assets/asm_ui_app/asm_app/",Ne="?v=1765198405",oe=E.useCallback(()=>{var K;(K=Z.current)==null||K.abort(),Z.current=null,g(!1),x(""),O(null),A(null),N(!1)},[]),se=()=>{g(!0),O(null),A(null)};E.useEffect(()=>{if(!u)return;const K=fe=>{fe.key==="Escape"&&oe()};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[u,oe]),E.useEffect(()=>{if(new URLSearchParams(H.search).get("manual_login")!=="1"||V.current)return;V.current=!0,xe(null,null,function*(){z(!0);try{localStorage.removeItem("user"),localStorage.removeItem("frappe_session_id");const Oe=yield _t.getCSRFTokenForGuest(),ye={Accept:"application/json"};Oe&&(ye["X-Frappe-CSRF-Token"]=Oe),yield fetch("/api/method/logout",{method:"POST",headers:ye,credentials:"include"}).catch(()=>{}),sessionStorage.setItem(vx,"1"),W("/login",{replace:!0})}finally{z(!1)}})},[H.pathname,H.search,W]),E.useEffect(()=>{sessionStorage.getItem(vx)==="1"&&(sessionStorage.removeItem(vx),B(!0))},[H.pathname,H.search]),E.useEffect(()=>{if(I||new URLSearchParams(H.search).get("manual_login")==="1")return;if(!localStorage.getItem("user")){jd().catch(()=>{});return}let Oe=!1;return xe(null,null,function*(){const J=yield gw();if(!Oe){if(J){W(J,{replace:!0});return}jd().catch(()=>{})}}),()=>{Oe=!0}},[H.pathname,H.search,W,I]);const ce=K=>{const{name:fe,value:Oe}=K.target;r(ye=>$e(_e({},ye),{[fe]:Oe})),c(null)},Ce=K=>xe(null,null,function*(){K.preventDefault(),n(!0),c(null);try{const fe=yield _t.login(e);if(fe&&fe.message){const Oe=$e(_e({},fe.message),{email:e.email});localStorage.setItem("user",JSON.stringify(Oe)),fe.message.sid&&_t.setSessionId(fe.message.sid);try{yield jd()}catch(J){console.warn("Could not load translations after login:",J)}const ye=yield mw();W(ye)}else c(le("login.loginFailed"))}catch(fe){console.error("Login error:",fe);const Oe=fe instanceof Error?fe.message:le("login.loginFailed");c(Oe||le("login.loginFailed"))}finally{n(!1)}}),ae=()=>xe(null,null,function*(){const K={full_name:"Demo User",email:"demo@seeraarabia.com",user_image:"",roles:["System Manager","Administrator"]};localStorage.setItem("user",JSON.stringify(K));try{yield jd()}catch(fe){console.warn("Could not load translations after demo login:",fe)}W("/dashboard")}),me=K=>xe(null,null,function*(){var ye;K.preventDefault();const fe=y.trim();if(!fe){O(le("login.forgotPasswordUserRequired")),A(null);return}(ye=Z.current)==null||ye.abort();const Oe=new AbortController;Z.current=Oe,N(!0),O(null),A(null);try{yield _t.requestPasswordReset(fe,Oe.signal),A(le("login.forgotPasswordSentSuccess"))}catch(J){J instanceof ps?J.code==="NOT_FOUND"?O(le("login.forgotPasswordNotFound")):J.code==="CANNOT_RESET"?O(le("login.forgotPasswordCannotReset")):J.code==="FORBIDDEN"?O(le("login.forgotPasswordFailed")):J.code==="TIMEOUT"?O(le("login.forgotPasswordTimeout")):O(le("login.forgotPasswordFailed")):O(le("login.forgotPasswordFailed"))}finally{N(!1),Z.current===Oe&&(Z.current=null)}});return I?t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"flex items-center text-gray-700 dark:text-gray-300",children:[t.jsxs("svg",{className:"animate-spin -ml-1 mr-3 h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.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"})]}),le("login.finishingSignOut")]})}):t.jsxs("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:[t.jsxs("div",{className:"max-w-md w-full space-y-8",children:[t.jsxs("div",{children:[t.jsx("div",{className:"flex justify-center mb-6",children:t.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:[t.jsx("img",{src:`${Q}${Q.endsWith("/")?"":"/"}seera-logo.png${Ne}`,alt:"Seera Arabia",className:"w-full h-full object-contain",onError:K=>{const fe=K.currentTarget.parentElement;fe&&fe.classList.add("bg-gradient-to-br","from-indigo-600","to-purple-600"),K.currentTarget.style.display="none";const Oe=K.currentTarget.nextElementSibling;Oe&&Oe.classList.remove("hidden")}}),t.jsxs("svg",{className:"w-20 h-20 hidden",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"white",fillOpacity:"0.9"}),t.jsx("path",{d:"M2 17L12 22L22 17V12L12 17L2 12V17Z",fill:"white",fillOpacity:"0.7"}),t.jsx("path",{d:"M12 12V17",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]})]})}),t.jsx("h2",{className:"text-center text-3xl font-semibold text-gray-900 dark:text-white",children:le("login.title")}),t.jsx("p",{className:"mt-2 text-center text-sm font-medium text-indigo-600 dark:text-indigo-400",children:le("login.subtitle")}),t.jsx("p",{className:"mt-1 text-center text-xs text-gray-600 dark:text-gray-400",children:le("login.signIn")})]}),t.jsxs("form",{className:"mt-8 space-y-6",onSubmit:Ce,children:[U&&t.jsx("div",{className:"rounded-md bg-green-50 dark:bg-green-900/20 p-4 border border-green-200 dark:border-green-800",children:t.jsx("p",{className:"text-sm text-green-800 dark:text-green-300 text-center",children:le("login.afterPasswordResetSignIn")})}),t.jsxs("div",{className:"rounded-md shadow-sm -space-y-px",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"email",className:"sr-only",children:le("common.email")}),t.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:le("login.emailPlaceholder"),value:e.email,onChange:ce})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"password",className:"sr-only",children:le("common.password")}),t.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:le("login.passwordPlaceholder"),value:e.password,onChange:ce})]})]}),i&&t.jsx("div",{className:"rounded-md bg-red-50 dark:bg-red-900/20 p-4",children:t.jsx("div",{className:"text-sm text-red-700 dark:text-red-400",children:i})}),t.jsx("button",{type:"submit",disabled:a,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:a?t.jsxs("div",{className:"flex items-center",children:[t.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:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.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"})]}),le("common.loading")]}):le("common.login")}),t.jsx("p",{className:"text-center -mt-2",children:t.jsx("button",{type:"button",onClick:se,className:"text-sm font-medium text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-300",children:le("login.forgotPassword")})}),t.jsxs("div",{className:"hidden relative pt-2","aria-hidden":"true",children:[t.jsx("div",{className:"absolute inset-0 flex items-center",children:t.jsx("div",{className:"w-full border-t border-gray-300 dark:border-gray-600"})}),t.jsx("div",{className:"relative flex justify-center text-sm",children:t.jsx("span",{className:"px-2 bg-gray-50 dark:bg-gray-900 text-gray-500 dark:text-gray-400",children:"or"})})]}),t.jsxs("button",{type:"button",onClick:ae,className:"hidden 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","aria-hidden":"true",tabIndex:-1,children:["🚀 ",le("login.demoLogin")]})]})]}),u&&t.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center p-4 bg-black/40 backdrop-blur-sm",onClick:oe,role:"presentation",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-lg p-6",onClick:K=>K.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"forgot-password-title",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[t.jsx("h3",{id:"forgot-password-title",className:"text-xl font-semibold text-gray-900 dark:text-white",children:le("login.forgotPassword")}),t.jsx("button",{type:"button",onClick:oe,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 text-2xl leading-none shrink-0","aria-label":le("login.forgotPasswordClose"),children:"×"})]}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:le("login.forgotPasswordHint")}),t.jsxs("form",{onSubmit:me,children:[t.jsx("input",{type:"text",autoComplete:"username",className:"appearance-none 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-700 rounded-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm",placeholder:le("login.forgotPasswordUserPlaceholder"),value:y,onChange:K=>{x(K.target.value),O(null),A(null)},disabled:k}),C&&t.jsx("div",{className:"mt-4 rounded-md bg-red-50 dark:bg-red-900/20 p-3",children:t.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:C})}),D&&t.jsx("div",{className:"mt-4 rounded-md bg-green-50 dark:bg-green-900/20 p-3",children:t.jsx("p",{className:"text-sm text-green-700 dark:text-green-400",children:D})}),t.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[t.jsx("button",{type:"button",onClick:oe,disabled:k,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-md hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50",children:le("common.cancel")}),t.jsx("button",{type:"submit",disabled:k,className:"px-4 py-2 text-sm font-medium text-white bg-indigo-600 rounded-md hover:bg-indigo-700 disabled:opacity-50 disabled:cursor-not-allowed",children:le(k?"common.loading":"login.forgotPasswordSubmit")})]})]})]})})]})};function Jf(e,r=[]){const[a,n]=E.useState(null),[i,c]=E.useState(!0),[u,g]=E.useState(null),y=E.useCallback(()=>xe(null,null,function*(){try{c(!0),g(null);const k=yield e();n(k)}catch(k){k instanceof ps?g(k.message):g(k instanceof Error?k.message:"Unknown error")}finally{c(!1)}}),r);E.useEffect(()=>{y()},[y]);const x=E.useCallback(()=>{y()},[y]);return{data:a,loading:i,error:u,refetch:x}}function M8(e){return Jf(()=>_t.getUserDetails(e),[e])}function D8(){return Jf(()=>_t.getDashboardStats())}function xw(e){return Jf(()=>_t.getNumberCards(e),[JSON.stringify(e||{})])}function pw(e,r){return Jf(()=>_t.getDashboardChartData(e,r),[e,JSON.stringify(r||{})])}function L8(){const[e,r]=E.useState(_t.isAuthenticated());return{isAuthenticated:e,login:i=>xe(null,null,function*(){try{const c=yield _t.login(i);if(c&&c.message)return c.message.sid&&_t.setSessionId(c.message.sid),r(!0),c;throw new Error("Login failed")}catch(c){throw r(!1),c}}),logout:()=>xe(null,null,function*(){try{yield _t.logout()}finally{_t.setSessionId(""),r(!1)}})}}const I8=()=>{const[e,r]=E.useState({}),[a,n]=E.useState(!1),i=()=>xe(null,null,function*(){n(!0);const c={};try{console.log("Testing basic connectivity...");try{const u=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)});u.ok?c.csrfToken="✅ Basic Connectivity: SUCCESS":c.csrfToken=`❌ Basic Connectivity: HTTP ${u.status}`}catch(u){c.csrfToken=`❌ Basic Connectivity: ${u instanceof Error?u.message:"Unknown error"}`}console.log("Testing Frappe system endpoint...");try{yield _t.apiCall("/api/method/frappe.auth.get_logged_user",{method:"GET",headers:{"Content-Type":"application/json"}}),c.dashboardStats="✅ Frappe System API: SUCCESS"}catch(u){const g=u instanceof Error?u.message:"Unknown";g.includes("403")||g.includes("401")?c.dashboardStats="✅ Frappe System API: SUCCESS (auth required)":c.dashboardStats=`❌ Frappe System API: ${g}`}console.log("Testing Custom User Details...");try{const u=yield _t.getUserDetails();c.userDetails=u?"✅ Custom API: SUCCESS":"❌ Custom API: Failed"}catch(u){c.userDetails=`❌ Custom API (Expected): ${u instanceof Error?u.message:"Unknown"}`}console.log("Testing Custom Dashboard Stats...");try{const u=yield _t.getDashboardStats();c.doctypeRecords=u?"✅ Custom Stats: SUCCESS":"❌ Custom Stats: Failed"}catch(u){c.doctypeRecords=`❌ Custom Stats (Expected): ${u instanceof Error?u.message:"Unknown"}`}}catch(u){console.error("API Test Error:",u),u instanceof ps?c.error=`${u.message} (Status: ${u.status})`:c.error=u instanceof Error?u.message:"Unknown error"}r(c),n(!1)});return t.jsxs("div",{style:{padding:"20px",border:"1px solid #ccc",margin:"20px"},children:[t.jsx("h2",{children:"API Connection Test"}),t.jsx("button",{onClick:i,disabled:a,style:{padding:"10px 20px",marginBottom:"20px",backgroundColor:a?"#ccc":"#007bff",color:"white",border:"none",borderRadius:"4px",cursor:a?"not-allowed":"pointer"},children:a?"Testing...":"Test API Connection"}),t.jsxs("div",{children:[t.jsx("h3",{children:"Test Results:"}),t.jsxs("div",{style:{background:"#f5f5f5",padding:"15px",borderRadius:"5px",fontSize:"14px"},children:[t.jsxs("div",{children:[t.jsx("strong",{children:"1. Basic Connectivity:"})," ",e.csrfToken||"Not tested"]}),t.jsxs("div",{children:[t.jsx("strong",{children:"2. Frappe System API:"})," ",e.dashboardStats||"Not tested"]}),t.jsxs("div",{children:[t.jsx("strong",{children:"3. Custom User API:"})," ",e.userDetails||"Not tested"]}),t.jsxs("div",{children:[t.jsx("strong",{children:"4. Custom Stats API:"})," ",e.doctypeRecords||"Not tested"]}),e.error&&t.jsxs("div",{style:{color:"red"},children:[t.jsx("strong",{children:"Error:"})," ",e.error]})]}),t.jsxs("div",{style:{marginTop:"10px",fontSize:"12px",color:"#666"},children:[t.jsx("p",{children:t.jsx("strong",{children:"Expected Results:"})}),t.jsxs("ul",{children:[t.jsx("li",{children:"✅ Basic Connectivity should succeed (tests proxy connection)"}),t.jsx("li",{children:"✅ Frappe System API should succeed (tests Frappe API)"}),t.jsx("li",{children:"❌ Custom APIs will fail until you deploy the API file to your server"})]}),t.jsxs("p",{children:[t.jsx("strong",{children:"If Basic Connectivity fails:"})," Check your Frappe server is running and accessible"]})]})]})]})},_x=e=>Number.isFinite(e)?Math.max(0,e):0;function P8({type:e,labels:r,datasets:a,height:n=220}){if(!(r!=null&&r.length)||!(a!=null&&a.length))return t.jsx("div",{className:"text-sm text-gray-500",children:"No data"});if(e.toLowerCase()==="pie"){const x=a[0].values.map(_x),k=x.reduce((I,z)=>I+z,0)||1,N=Math.min(100,n/2-10),C=N+10,O=N+10;let D=0;const A=a[0].values.map((I,z)=>a[0].color||q2(z));return t.jsx("svg",{width:C*2,height:O*2,viewBox:`0 0 ${C*2} ${O*2}`,children:x.map((I,z)=>{const U=D/k*2*Math.PI;D+=I;const B=D/k*2*Math.PI,V=B-U>Math.PI?1:0,Z=C+N*Math.cos(U),W=O+N*Math.sin(U),H=C+N*Math.cos(B),le=O+N*Math.sin(B),Q=`M ${C} ${O} L ${Z} ${W} A ${N} ${N} 0 ${V} 1 ${H} ${le} Z`;return t.jsx("path",{d:Q,fill:A[z]},z)})})}const i=a,c=Math.max(...i.flatMap(x=>x.values.map(_x)),1),u=Math.max(r.length*60,300),g=n-40,y=Math.max(20,(u-40)/r.length-10);return t.jsxs("svg",{width:u,height:n,viewBox:`0 0 ${u} ${n}`,children:[t.jsx("line",{x1:30,y1:10,x2:30,y2:g,stroke:"#e5e7eb"}),t.jsx("line",{x1:30,y1:g,x2:u-10,y2:g,stroke:"#e5e7eb"}),r.map((x,k)=>{const N=40+k*(y+10);let C=0;return t.jsxs("g",{children:[i.map((O,D)=>{const I=_x(O.values[k]||0)/c*(g-20),z=g-I-C,U=O.color||q2(D);return C+=I,t.jsx("rect",{x:N,y:z,width:y,height:I,fill:U,rx:2},D)}),t.jsx("text",{x:N+y/2,y:n-5,textAnchor:"middle",fontSize:"10",fill:"#6b7280",children:F8(x,8)})]},k)})]})}function q2(e){const r=["#4F46E5","#10B981","#F59E0B","#EF4444","#6366F1","#22C55E","#E11D48"];return r[e%r.length]}function F8(e,r){return e.length>r?e.slice(0,r-1)+"…":e}const B8=({chartName:e,filters:r})=>{const{data:a,loading:n,error:i}=pw(e,r);return t.jsxs("div",{className:"bg-white rounded-lg shadow p-4 overflow-auto",children:[t.jsx("div",{className:"flex items-center justify-between mb-3",children:t.jsx("h4",{className:"text-sm font-semibold text-gray-800",children:e})}),n&&t.jsx("div",{className:"text-sm text-gray-500",children:"Loading…"}),i&&t.jsx("div",{className:"text-sm text-red-600",children:i}),!n&&!i&&a&&t.jsx(P8,{type:a.type,labels:a.labels,datasets:a.datasets})]})},U8=()=>{var O,D,A,I;const[e,r]=E.useState(null),[a,n]=E.useState([]),i=ua(),{logout:c}=L8(),{loading:u,error:g}=D8(),{data:y}=xw(),{data:x,loading:k,error:N}=M8();E.useEffect(()=>{const z=localStorage.getItem("user");z?r(JSON.parse(z)):x&&r(x);const U=[{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}];n(U)},[x]);const C=()=>xe(null,null,function*(){try{yield c(),localStorage.removeItem("user"),i("/login")}catch(z){console.error("Logout error:",z),localStorage.removeItem("user"),i("/login")}});return u||k?t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900",children:t.jsx("div",{className:"animate-spin rounded-full h-32 w-32 border-b-2 border-indigo-600"})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900",children:[t.jsx("header",{className:"bg-white dark:bg-gray-800 shadow",children:t.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex justify-between items-center py-6",children:[t.jsx("div",{className:"flex items-center",children:t.jsx("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white",children:"Dashboard"})}),t.jsxs("div",{className:"flex items-center space-x-4",children:[t.jsxs("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Welcome, ",(e==null?void 0:e.full_name)||"User"]}),t.jsx("button",{onClick:C,className:"bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-md text-sm font-medium",children:"Logout"})]})]})})}),t.jsxs("main",{className:"max-w-7xl mx-auto py-6 sm:px-6 lg:px-8",children:[(g||N)&&t.jsx("div",{className:"mb-6 rounded-md bg-red-50 dark:bg-red-900/20 p-4",children:t.jsx("div",{className:"text-sm text-red-700 dark:text-red-400",children:g||N||"Failed to load dashboard data"})}),t.jsxs("div",{className:"grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-4 mb-8",children:[t.jsx("div",{className:"bg-white dark:bg-gray-800 overflow-hidden shadow rounded-lg",children:t.jsx("div",{className:"p-5",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-8 h-8 bg-indigo-500 rounded-md flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),t.jsx("div",{className:"ml-5 w-0 flex-1",children:t.jsxs("dl",{children:[t.jsx("dt",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 truncate",children:"Total Assets"}),t.jsx("dd",{className:"text-lg font-medium text-gray-900 dark:text-white",children:(O=y==null?void 0:y.total_assets)!=null?O:"-"})]})})]})})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 overflow-hidden shadow rounded-lg",children:t.jsx("div",{className:"p-5",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-8 h-8 bg-green-500 rounded-md flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})})})}),t.jsx("div",{className:"ml-5 w-0 flex-1",children:t.jsxs("dl",{children:[t.jsx("dt",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 truncate",children:"Open Work Orders"}),t.jsx("dd",{className:"text-lg font-medium text-gray-900 dark:text-white",children:(D=y==null?void 0:y.work_orders_open)!=null?D:"-"})]})})]})})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 overflow-hidden shadow rounded-lg",children:t.jsx("div",{className:"p-5",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-8 h-8 bg-yellow-500 rounded-md flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})})})}),t.jsx("div",{className:"ml-5 w-0 flex-1",children:t.jsxs("dl",{children:[t.jsx("dt",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 truncate",children:"In Progress"}),t.jsx("dd",{className:"text-lg font-medium text-gray-900 dark:text-white",children:(A=y==null?void 0:y.work_orders_in_progress)!=null?A:"-"})]})})]})})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 overflow-hidden shadow rounded-lg",children:t.jsx("div",{className:"p-5",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-8 h-8 bg-purple-500 rounded-md flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})})})}),t.jsx("div",{className:"ml-5 w-0 flex-1",children:t.jsxs("dl",{children:[t.jsx("dt",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 truncate",children:"Completed Work Orders"}),t.jsx("dd",{className:"text-lg font-medium text-gray-900 dark:text-white",children:(I=y==null?void 0:y.work_orders_completed)!=null?I:"-"})]})})]})})})]}),t.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(z=>t.jsx(B8,{chartName:z},z))}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow overflow-hidden sm:rounded-md",children:[t.jsxs("div",{className:"px-4 py-5 sm:px-6",children:[t.jsx("h3",{className:"text-lg leading-6 font-medium text-gray-900 dark:text-white",children:"Recent Records"}),t.jsx("p",{className:"mt-1 max-w-2xl text-sm text-gray-500 dark:text-gray-400",children:"Latest entries from your Frappe backend"})]}),t.jsx("ul",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:a.map(z=>{var U;return t.jsx("li",{children:t.jsxs("div",{className:"px-4 py-4 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0 h-10 w-10",children:t.jsx("div",{className:"h-10 w-10 rounded-full bg-indigo-100 flex items-center justify-center",children:t.jsx("span",{className:"text-sm font-medium text-indigo-600",children:((U=z.full_name)==null?void 0:U.charAt(0))||z.name.charAt(0)})})}),t.jsxs("div",{className:"ml-4",children:[t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:z.full_name||z.name}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:z.email||"No email"})]})]}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(z.creation).toLocaleDateString()})]})},z.name)})})]}),t.jsxs("div",{className:"mt-8",children:[t.jsx("h3",{className:"text-lg leading-6 font-medium text-gray-900 dark:text-white mb-4",children:"Quick Actions"}),t.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[t.jsx("button",{onClick:()=>i("/users"),className:"bg-white dark:bg-gray-800 p-6 rounded-lg shadow hover:shadow-md transition-shadow",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-8 h-8 bg-blue-500 rounded-md flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})})})}),t.jsxs("div",{className:"ml-4",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"View Users"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Manage user accounts"})]})]})}),t.jsx("button",{onClick:()=>i("/settings"),className:"bg-white dark:bg-gray-800 p-6 rounded-lg shadow hover:shadow-md transition-shadow",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-8 h-8 bg-gray-500 rounded-md flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})})})}),t.jsxs("div",{className:"ml-4",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Settings"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Configure your preferences"})]})]})}),t.jsx("button",{onClick:()=>i("/events"),className:"bg-white dark:bg-gray-800 p-6 rounded-lg shadow hover:shadow-md transition-shadow",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-8 h-8 bg-purple-500 rounded-md flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})})}),t.jsxs("div",{className:"ml-4",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Events"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"View calendar events"})]})]})}),t.jsx("button",{onClick:()=>i("/reports"),className:"bg-white dark:bg-gray-800 p-6 rounded-lg shadow hover:shadow-md transition-shadow",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"w-8 h-8 bg-green-500 rounded-md flex items-center justify-center",children:t.jsx("svg",{className:"w-5 h-5 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})})})}),t.jsxs("div",{className:"ml-4",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Reports"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"View analytics and reports"})]})]})})]})]}),t.jsx("div",{className:"mt-8",children:t.jsx(I8,{})})]})]})};class z8{getWorkOrders(r,a,n=20,i=0,c){return xe(this,null,function*(){var y;const u=new URLSearchParams;if(r)if(Array.isArray(r))u.append("filters",JSON.stringify(r));else if("or_filters"in r||"filters"in r&&!Array.isArray(r)&&typeof r=="object"&&r.filters!==void 0){const x=r;x.filters!==void 0&&u.append("filters",JSON.stringify(x.filters)),(y=x.or_filters)!=null&&y.length&&u.append("or_filters",JSON.stringify(x.or_filters))}else u.append("filters",JSON.stringify(r));a&&a.length>0&&u.append("fields",JSON.stringify(a)),u.append("limit",n.toString()),u.append("offset",i.toString()),c&&u.append("order_by",c);const g=`${Lr.ENDPOINTS.GET_WORK_ORDERS}?${u.toString()}`;return _t.apiCall(g)})}getWorkOrderDetails(r){return xe(this,null,function*(){const a=`${Lr.ENDPOINTS.GET_WORK_ORDER_DETAILS}?work_order_name=${encodeURIComponent(r)}`;return _t.apiCall(a)})}createWorkOrder(r){return xe(this,null,function*(){return _t.apiCall(Lr.ENDPOINTS.CREATE_WORK_ORDER,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({work_order_data:r})})})}updateWorkOrder(r,a){return xe(this,null,function*(){return _t.apiCall(Lr.ENDPOINTS.UPDATE_WORK_ORDER,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({work_order_name:r,work_order_data:a})})})}deleteWorkOrder(r){return xe(this,null,function*(){return _t.apiCall(Lr.ENDPOINTS.DELETE_WORK_ORDER,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({work_order_name:r})})})}updateWorkOrderStatus(r,a,n){return xe(this,null,function*(){return _t.apiCall(Lr.ENDPOINTS.UPDATE_WORK_ORDER_STATUS,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({work_order_name:r,repair_status:a,workflow_state:n})})})}getWorkOrderFilters(){return xe(this,null,function*(){return _t.apiCall(Lr.ENDPOINTS.GET_WORK_ORDER_FILTERS)})}getWorkOrderStats(){return xe(this,null,function*(){return _t.apiCall(Lr.ENDPOINTS.GET_WORK_ORDER_STATS)})}searchWorkOrders(r,a=10){return xe(this,null,function*(){const n=`${Lr.ENDPOINTS.SEARCH_WORK_ORDERS}?search_term=${encodeURIComponent(r)}&limit=${a}`;return _t.apiCall(n)})}submitWorkOrder(r){return xe(this,null,function*(){return _t.apiCall("/api/method/frappe.client.submit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doc:{doctype:"Asset Repair",name:r}})})})}cancelWorkOrder(r){return xe(this,null,function*(){return _t.apiCall("/api/method/frappe.client.cancel",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doc:{doctype:"Asset Repair",name:r}})})})}getWorkOrdersByAsset(r,a=50){return xe(this,null,function*(){const n={asset:r};return(yield this.getWorkOrders(n,void 0,a,0,"creation desc")).work_orders})}getOpenWorkOrders(r=50){return xe(this,null,function*(){const a={repair_status:["not in",["Completed","Cancelled"]]};return(yield this.getWorkOrders(a,void 0,r,0,"creation desc")).work_orders})}getWorkOrdersByPriority(r,a=50){return xe(this,null,function*(){const n={custom_priority_:r};return(yield this.getWorkOrders(n,void 0,a,0,"creation desc")).work_orders})}}const Ul=new z8,H8=(e,r)=>{if(Array.isArray(e))return e;const a=e&&"or_filters"in e?_e({},e.filters):_e({},e||{}),n=_e({},a),i=e&&"or_filters"in e?e.or_filters:void 0;for(const[c,u]of Object.entries(r))if(!n[c])n[c]=u;else if(Array.isArray(u)&&u[0]==="in"){const g=u[1],y=n[c];if(typeof y=="string")g.includes(y)||(n[c]=["in",[]]);else if(Array.isArray(y)&&y[0]==="in"){const k=y[1].filter(N=>g.includes(N));n[c]=["in",k]}else n[c]=u}return i!=null&&i.length?{filters:n,or_filters:i}:n};function yw(e,r=20,a=0,n,i={}){const[c,u]=E.useState([]),[g,y]=E.useState(0),[x,k]=E.useState(!1),[N,C]=E.useState(!0),[O,D]=E.useState(null),[A,I]=E.useState(0),z=E.useRef(!1),U=JSON.stringify(e),B=JSON.stringify(i);E.useEffect(()=>{if(z.current&&O)return;let Z=!1;return z.current=!0,xe(null,null,function*(){try{C(!0);const H=Array.isArray(e)?e:H8(e,i);console.log("[useWorkOrders] User filters:",e),console.log("[useWorkOrders] Permission filters:",i),console.log("[useWorkOrders] Merged filters:",H);const le=yield Ul.getWorkOrders(H,void 0,r,a,n);Z||(u(le.work_orders),y(le.total_count),k(le.has_more),D(null))}catch(H){if(!Z){const le=H instanceof Error?H.message:"Failed to fetch work orders";le.includes("417")||le.includes("Expectation Failed")||le.includes("has no attribute")?D("API endpoint not deployed or misconfigured. Please check FIX_417_ERROR.md for solutions."):D(le),u([]),y(0),k(!1)}}finally{Z||C(!1)}}),()=>{Z=!0}},[U,B,r,a,n,A]);const V=E.useCallback(()=>{z.current=!1,I(Z=>Z+1)},[]);return{workOrders:c,totalCount:g,hasMore:x,loading:N,error:O,refetch:V}}function V8(e){const[r,a]=E.useState(null),[n,i]=E.useState(!0),[c,u]=E.useState(null),g=E.useCallback(()=>xe(null,null,function*(){if(!e){a(null),i(!1);return}try{i(!0),u(null);const x=yield Ul.getWorkOrderDetails(e);a(x)}catch(x){u(x instanceof Error?x.message:"Failed to fetch work order details")}finally{i(!1)}}),[e]);E.useEffect(()=>{g()},[g]);const y=E.useCallback(()=>{g()},[g]);return{workOrder:r,loading:n,error:c,refetch:y}}function bw(){const[e,r]=E.useState(!1),[a,n]=E.useState(null);return{createWorkOrder:x=>xe(null,null,function*(){try{r(!0),n(null),console.log("[useWorkOrderMutations] Creating work order with data:",x);const k=yield Ul.createWorkOrder(x);if(console.log("[useWorkOrderMutations] Create work order response:",k),k.success)return k.work_order;{const N=k.error||"Failed to create work order";throw new Error(N)}}catch(k){console.error("[useWorkOrderMutations] Create work order error:",k);const N=k instanceof Error?k.message:"Failed to create work order";throw n(N),k}finally{r(!1)}}),updateWorkOrder:(x,k)=>xe(null,null,function*(){try{r(!0),n(null),console.log("[useWorkOrderMutations] Updating work order:",x,"with data:",k);const N=yield Ul.updateWorkOrder(x,k);if(console.log("[useWorkOrderMutations] Update work order response:",N),N.success)return N.work_order;{const C=N.error||"Failed to update work order";throw new Error(C)}}catch(N){console.error("[useWorkOrderMutations] Update work order error:",N);const C=N instanceof Error?N.message:"Failed to update work order";throw n(C),N}finally{r(!1)}}),deleteWorkOrder:x=>xe(null,null,function*(){try{r(!0),n(null);const k=yield Ul.deleteWorkOrder(x);if(!k.success)throw new Error("Failed to delete work order");return k}catch(k){const N=k instanceof Error?k.message:"Failed to delete work order";throw n(N),k}finally{r(!1)}}),submitWorkOrder:x=>xe(null,null,function*(){try{r(!0),n(null),console.log("[useWorkOrderMutations] Submitting work order:",x);const k=yield Ul.submitWorkOrder(x);return console.log("[useWorkOrderMutations] Submit work order response:",k),k}catch(k){console.error("[useWorkOrderMutations] Submit work order error:",k);const N=k instanceof Error?k.message:"Failed to submit work order";throw n(N),k}finally{r(!1)}}),updateStatus:(x,k,N)=>xe(null,null,function*(){try{r(!0),n(null);const C=yield Ul.updateWorkOrderStatus(x,k,N);if(C.success)return C.work_order;throw new Error("Failed to update work order status")}catch(C){const O=C instanceof Error?C.message:"Failed to update status";throw n(O),C}finally{r(!1)}}),loading:e,error:a}}const qi=_t;class W8{getMaintenanceLogs(r,a,n=20,i=0,c){return xe(this,null,function*(){const u=new URLSearchParams;r&&u.append("filters",JSON.stringify(r)),a&&a.length>0&&u.append("fields",JSON.stringify(a)),u.append("limit",n.toString()),u.append("offset",i.toString()),c&&u.append("order_by",c),u.append("include_child_tables","true");const g=`${Lr.ENDPOINTS.GET_ASSET_MAINTENANCE_LOGS}?${u.toString()}`;return qi.apiCall(g)})}getMaintenanceLogDetails(r){return xe(this,null,function*(){const a=new URLSearchParams;a.append("log_name",r),a.append("include_child_tables","true");const n=`${Lr.ENDPOINTS.GET_ASSET_MAINTENANCE_LOG_DETAILS}?${a.toString()}`;return qi.apiCall(n)})}createMaintenanceLog(r){return xe(this,null,function*(){const a=this.prepareLogData(r);return qi.apiCall(Lr.ENDPOINTS.CREATE_ASSET_MAINTENANCE_LOG,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_data:a})})})}updateMaintenanceLog(r,a){return xe(this,null,function*(){const n=this.prepareLogData(a);return qi.apiCall(Lr.ENDPOINTS.UPDATE_ASSET_MAINTENANCE_LOG,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_name:r,log_data:n})})})}deleteMaintenanceLog(r){return xe(this,null,function*(){return qi.apiCall(Lr.ENDPOINTS.DELETE_ASSET_MAINTENANCE_LOG,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_name:r})})})}updateMaintenanceStatus(r,a,n){return xe(this,null,function*(){return qi.apiCall(Lr.ENDPOINTS.UPDATE_MAINTENANCE_STATUS,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({log_name:r,maintenance_status:a,workflow_state:n})})})}getMaintenanceLogsByAsset(r,a,n=20,i=0){return xe(this,null,function*(){const c=new URLSearchParams;c.append("asset_name",r),a&&c.append("filters",JSON.stringify(a)),c.append("limit",n.toString()),c.append("offset",i.toString()),c.append("include_child_tables","true");const u=`${Lr.ENDPOINTS.GET_MAINTENANCE_LOGS_BY_ASSET}?${c.toString()}`;return qi.apiCall(u)})}getOverdueMaintenanceLogs(r,a=20,n=0){return xe(this,null,function*(){const i=new URLSearchParams;r&&i.append("filters",JSON.stringify(r)),i.append("limit",a.toString()),i.append("offset",n.toString()),i.append("include_child_tables","true");const c=`${Lr.ENDPOINTS.GET_OVERDUE_MAINTENANCE_LOGS}?${i.toString()}`;return qi.apiCall(c)})}addPPMTableRow(r,a){return xe(this,null,function*(){return qi.apiCall(Lr.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:r,row_data:this.cleanPPMRow(a)})})})}removePPMTableRow(r,a){return xe(this,null,function*(){return qi.apiCall(Lr.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:r,row_name:a})})})}updatePPMTableRow(r,a,n){return xe(this,null,function*(){return qi.apiCall(Lr.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:r,row_name:a,row_data:this.cleanPPMRow(n)})})})}cleanPPMRow(r){return $e(_e({},r.name&&!r.name.startsWith("new-")?{name:r.name}:{}),{maintenance_name:r.maintenance_name||"",working:typeof r.working=="boolean"?r.working?1:0:r.working||0,defect_found:typeof r.defect_found=="boolean"?r.defect_found?1:0:r.defect_found||0,not_working:typeof r.not_working=="boolean"?r.not_working?1:0:r.not_working||0})}prepareLogData(r){const a={},n=["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 n)r[i]!==void 0&&r[i]!==null&&r[i]!==""&&(a[i]=r[i]);return typeof a.has_certificate=="boolean"&&(a.has_certificate=a.has_certificate?1:0),typeof a.custom_accepted_by_moh=="boolean"&&(a.custom_accepted_by_moh=a.custom_accepted_by_moh?1:0),typeof a.custom_accepted_by_moh_=="boolean"&&(a.custom_accepted_by_moh_=a.custom_accepted_by_moh_?1:0),a.custom_table&&Array.isArray(a.custom_table)&&(a.custom_table=a.custom_table.map(i=>this.cleanPPMRow(i))),a}}const Td=new W8;function Qf(e,r=20,a=0,n){const[i,c]=E.useState([]),[u,g]=E.useState(0),[y,x]=E.useState(!1),[k,N]=E.useState(!0),[C,O]=E.useState(null),[D,A]=E.useState(0),I=E.useRef(!1),z=JSON.stringify(e);E.useEffect(()=>{if(I.current&&C)return;let B=!1;return I.current=!0,xe(null,null,function*(){try{N(!0);const Z=yield Td.getMaintenanceLogs(e,void 0,r,a,n);B||(c(Z.asset_maintenance_logs),g(Z.total_count),x(Z.has_more),O(null))}catch(Z){if(!B){const W=Z instanceof Error?Z.message:"Failed to fetch maintenance logs";W.includes("417")||W.includes("Expectation Failed")||W.includes("has no attribute")?O("API endpoint not deployed. Please deploy asset_maintenance_api.py to your Frappe server."):O(W),c([]),g(0),x(!1)}}finally{B||N(!1)}}),()=>{B=!0}},[z,r,a,n,D]);const U=E.useCallback(()=>{I.current=!1,A(B=>B+1)},[]);return{logs:i,totalCount:u,hasMore:y,loading:k,error:C,refetch:U}}function G8(e){const[r,a]=E.useState(null),[n,i]=E.useState(!0),[c,u]=E.useState(null),g=E.useCallback(()=>xe(null,null,function*(){if(!e){a(null),i(!1);return}try{i(!0),u(null);const x=yield Td.getMaintenanceLogDetails(e);a(x)}catch(x){u(x instanceof Error?x.message:"Failed to fetch maintenance log details")}finally{i(!1)}}),[e]);E.useEffect(()=>{g()},[g]);const y=E.useCallback(()=>{g()},[g]);return{log:r,loading:n,error:c,refetch:y}}function vw(){const[e,r]=E.useState(!1),[a,n]=E.useState(null);return{createLog:y=>xe(null,null,function*(){try{r(!0),n(null),console.log("[useMaintenanceMutations] Creating maintenance log:",y);const x=yield Td.createMaintenanceLog(y);if(console.log("[useMaintenanceMutations] Create response:",x),x.success)return x.asset_maintenance_log;{const k=x.error||"Failed to create maintenance log";throw new Error(k)}}catch(x){console.error("[useMaintenanceMutations] Create error:",x);const k=x instanceof Error?x.message:"Failed to create maintenance log";throw n(k),x}finally{r(!1)}}),updateLog:(y,x)=>xe(null,null,function*(){try{r(!0),n(null),console.log("[useMaintenanceMutations] Updating maintenance log:",y,x);const k=yield Td.updateMaintenanceLog(y,x);if(console.log("[useMaintenanceMutations] Update response:",k),k.success)return k.asset_maintenance_log;{const N=k.error||"Failed to update maintenance log";throw new Error(N)}}catch(k){console.error("[useMaintenanceMutations] Update error:",k);const N=k instanceof Error?k.message:"Failed to update maintenance log";throw n(N),k}finally{r(!1)}}),deleteLog:y=>xe(null,null,function*(){try{r(!0),n(null);const x=yield Td.deleteMaintenanceLog(y);if(!x.success)throw new Error("Failed to delete maintenance log");return x}catch(x){const k=x instanceof Error?x.message:"Failed to delete maintenance log";throw n(k),x}finally{r(!1)}}),updateStatus:(y,x,k)=>xe(null,null,function*(){try{r(!0),n(null);const N=yield Td.updateMaintenanceStatus(y,x,k);if(N.success)return N.asset_maintenance_log;throw new Error("Failed to update maintenance status")}catch(N){const C=N instanceof Error?N.message:"Failed to update status";throw n(C),N}finally{r(!1)}}),loading:e,error:a}}var _w={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},K2=ea.createContext&&ea.createContext(_w),$8=["attr","size","title"];function X8(e,r){if(e==null)return{};var a=Y8(e,r),n,i;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(i=0;i<c.length;i++)n=c[i],!(r.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function Y8(e,r){if(e==null)return{};var a={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(r.indexOf(n)>=0)continue;a[n]=e[n]}return a}function _f(){return _f=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},_f.apply(this,arguments)}function J2(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),a.push.apply(a,n)}return a}function wf(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?J2(Object(a),!0).forEach(function(n){Z8(e,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):J2(Object(a)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(a,n))})}return e}function Z8(e,r,a){return r=q8(r),r in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function q8(e){var r=K8(e,"string");return typeof r=="symbol"?r:r+""}function K8(e,r){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var n=a.call(e,r);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function ww(e){return e&&e.map((r,a)=>ea.createElement(r.tag,wf({key:a},r.attr),ww(r.child)))}function ur(e){return r=>ea.createElement(J8,_f({attr:wf({},e.attr)},r),ww(e.child))}function J8(e){var r=a=>{var{attr:n,size:i,title:c}=e,u=X8(e,$8),g=i||a.size||"1em",y;return a.className&&(y=a.className),e.className&&(y=(y?y+" ":"")+e.className),ea.createElement("svg",_f({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,u,{className:y,style:wf(wf({color:e.color||a.color},a.style),e.style),height:g,width:g,xmlns:"http://www.w3.org/2000/svg"}),c&&ea.createElement("title",null,c),e.children)};return K2!==void 0?ea.createElement(K2.Consumer,null,a=>r(a)):r(_w)}function Q8(e){return ur({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M32 448c0 17.7 14.3 32 32 32h384c17.7 0 32-14.3 32-32V160H32v288zm160-212c0-6.6 5.4-12 12-12h104c6.6 0 12 5.4 12 12v8c0 6.6-5.4 12-12 12H204c-6.6 0-12-5.4-12-12v-8zM480 32H32C14.3 32 0 46.3 0 64v48c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16V64c0-17.7-14.3-32-32-32z"},child:[]}]})(e)}function eC(e){return ur({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:[]}]})(e)}function bi(e){return ur({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:[]}]})(e)}function tC(e){return ur({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:[]}]})(e)}function Q2(e){return ur({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:[]}]})(e)}function rC(e){return ur({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:[]}]})(e)}function kw(e){return ur({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:[]}]})(e)}function kf(e){return ur({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:[]}]})(e)}function al(e){return ur({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:[]}]})(e)}function Nw(e){return ur({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:[]}]})(e)}function df(e){return ur({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:[]}]})(e)}function Sw(e){return ur({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M512 144v288c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V144c0-26.5 21.5-48 48-48h88l12.3-32.9c7-18.7 24.9-31.1 44.9-31.1h125.5c20 0 37.9 12.4 44.9 31.1L376 96h88c26.5 0 48 21.5 48 48zM376 288c0-66.2-53.8-120-120-120s-120 53.8-120 120 53.8 120 120 120 120-53.8 120-120zm-32 0c0 48.5-39.5 88-88 88s-88-39.5-88-88 39.5-88 88-88 88 39.5 88 88z"},child:[]}]})(e)}function aC(e){return ur({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:[]}]})(e)}function Ca(e){return ur({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:[]}]})(e)}function qs(e){return ur({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:[]}]})(e)}function Cw(e){return ur({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:[]}]})(e)}function nl(e){return ur({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:[]}]})(e)}function Ew(e){return ur({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:[]}]})(e)}function jw(e){return ur({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:[]}]})(e)}function Vl(e){return ur({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:[]}]})(e)}function Gh(e){return ur({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:[]}]})(e)}function Kx(e){return ur({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:[]}]})(e)}function $s(e){return ur({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:[]}]})(e)}function nC(e){return ur({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:[]}]})(e)}function uf(e){return ur({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:[]}]})(e)}function Zd(e){return ur({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:[]}]})(e)}function Co(e){return ur({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:[]}]})(e)}function Yn(e){return ur({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:[]}]})(e)}function Eu(e){return ur({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:[]}]})(e)}function Tw(e){return ur({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:[]}]})(e)}function sC(e){return ur({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:[]}]})(e)}function an(e){return ur({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:[]}]})(e)}function qd(e){return ur({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:[]}]})(e)}function wx(e){return ur({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:[]}]})(e)}function to(e){return ur({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:[]}]})(e)}function iC(e){return ur({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:[]}]})(e)}function Kd(e){return ur({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:[]}]})(e)}function cl(e){return ur({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:[]}]})(e)}function cs(e){return ur({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:[]}]})(e)}function oC(e){return ur({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:[]}]})(e)}function Ri(e){return ur({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:[]}]})(e)}function lC(e){return ur({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:[]}]})(e)}function ev(e){return ur({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:[]}]})(e)}function Nf(e){return ur({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:[]}]})(e)}function cC(e){return ur({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:[]}]})(e)}function Ad(e){return ur({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:[]}]})(e)}function kx(e){return ur({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:[]}]})(e)}function Nx(e){return ur({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:[]}]})(e)}function dC(e){return ur({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:[]}]})(e)}function uC(e){return ur({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:[]}]})(e)}function hC(e){return ur({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:[]}]})(e)}function Mi(e){return ur({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:[]}]})(e)}function sl(e){return ur({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:[]}]})(e)}function $h(e){return ur({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:[]}]})(e)}function Fn(e){return ur({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:[]}]})(e)}function _o(e){return ur({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:[]}]})(e)}function fC(e){return ur({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:[]}]})(e)}function mC(e){return ur({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:[]}]})(e)}function Ja(e){return ur({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:[]}]})(e)}function Pn(e){return ur({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:[]}]})(e)}function Zl(e){return ur({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:[]}]})(e)}function Eo(e){return ur({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:[]}]})(e)}function gC(e){return ur({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:[]}]})(e)}function q0(e){return ur({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:[]}]})(e)}function jn(e){return ur({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:[]}]})(e)}function qt(e){return ur({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:[]}]})(e)}function Aw(e){return ur({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:[]}]})(e)}function xC(e){return ur({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:[]}]})(e)}function ma(e){return ur({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:[]}]})(e)}function pC(e){return ur({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:[]}]})(e)}function tv(e){return ur({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:[]}]})(e)}function yC(e){return ur({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:[]}]})(e)}function bC(e){return ur({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:[]}]})(e)}function vC(e){return ur({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:[]}]})(e)}function Wl(e){return ur({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:[]}]})(e)}function Pd(e){return ur({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:[]}]})(e)}function rv(e){return ur({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:[]}]})(e)}const _C={},er=({label:e,doctype:r,value:a,onChange:n,placeholder:i,disabled:c=!1,filters:u,query:g,compact:y=!1,usePortal:x=!1})=>{const[k,N]=E.useState([]),[C,O]=E.useState(""),[D,A]=E.useState(!1),[I,z]=E.useState(!1),[U,B]=E.useState({top:0,left:0,width:0}),V=E.useRef(null),Z=E.useRef(null),W=E.useRef(null),H=E.useRef(null),le=E.useRef(""),Q=E.useRef(!1),Ne=u||_C,oe=E.useMemo(()=>JSON.stringify(Ne),[Ne]),se=g||"",ce=E.useCallback((Oe="",ye=!1)=>xe(null,null,function*(){const J=`${Oe}-${oe}-${se}`;if(!(!ye&&le.current===J)){le.current=J,z(!0);try{const G=new URLSearchParams({doctype:r,txt:Oe});Ne&&Object.keys(Ne).length>0&&G.append("filters",JSON.stringify(Ne)),g&&G.append("query",g);const ie=yield _t.apiCall(`/api/method/frappe.desk.search.search_link?${G.toString()}`);N(ie||[])}catch(G){console.error(`Error fetching ${r} links:`,G),N([])}finally{z(!1)}}}),[r,oe,se,Ne,g]),Ce=E.useCallback(Oe=>{H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{ce(Oe)},300)},[ce]);E.useEffect(()=>{D&&!Q.current&&(Q.current=!0,ce(C||"",!0)),D||(Q.current=!1,le.current="")},[D]),E.useEffect(()=>()=>{H.current&&clearTimeout(H.current)},[]);const ae=E.useCallback(()=>{if(x&&Z.current){const Oe=Z.current.getBoundingClientRect();B({top:Oe.bottom+window.scrollY,left:Oe.left+window.scrollX,width:Oe.width})}},[x]);E.useEffect(()=>{if(D&&x){ae();const Oe=()=>ae();return window.addEventListener("scroll",Oe,!0),window.addEventListener("resize",Oe),()=>{window.removeEventListener("scroll",Oe,!0),window.removeEventListener("resize",Oe)}}},[D,x,ae]),E.useEffect(()=>{const Oe=ye=>{const J=ye.target,G=V.current&&!V.current.contains(J),ie=x&&W.current&&!W.current.contains(J);x?G&&ie&&(A(!1),O("")):G&&(A(!1),O(""))};return document.addEventListener("mousedown",Oe),()=>document.removeEventListener("mousedown",Oe)},[x]);const me=Oe=>{n(Oe),O(""),A(!1)},K=()=>{n(""),O(""),A(!1)},fe=()=>{const Oe=`bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600
|
||
rounded-md w-full shadow-lg ${y?"mt-0.5":"mt-1"}`,ye=x?{position:"fixed",top:`${U.top}px`,left:`${U.left}px`,width:`${U.width}px`,zIndex:1050,marginTop:y?"2px":"4px"}:{};if(!D||c)return null;const J=t.jsxs("div",{ref:W,children:[I&&t.jsxs("div",{className:`${x?"":"absolute z-[1050]"} ${Oe} text-center text-gray-500 dark:text-gray-400
|
||
${y?"p-1.5 text-[10px]":"p-3 text-sm"}`,style:ye,children:[t.jsx("span",{className:"inline-block animate-spin mr-2",children:"⏳"}),"Loading..."]}),!I&&k.length>0&&t.jsx("ul",{className:`${x?"":"absolute z-[1050]"} ${Oe} overflow-auto
|
||
${y?"max-h-36":"max-h-48"}`,style:ye,children:k.map((G,ie)=>t.jsxs("li",{onClick:()=>me(G.value),className:`cursor-pointer text-gray-900 dark:text-gray-100
|
||
hover:bg-blue-500 dark:hover:bg-blue-600 hover:text-white
|
||
${y?"px-2 py-1 text-xs":"px-3 py-2 text-sm"}
|
||
${a===G.value?"bg-blue-50 dark:bg-blue-700 font-semibold":""}`,children:[G.value,G.description&&t.jsx("span",{className:`text-gray-600 dark:text-gray-300 ml-2
|
||
${y?"text-[9px] ml-1":"text-xs ml-2"}`,children:G.description})]},ie))}),!I&&k.length===0&&t.jsx("div",{className:`${x?"":"absolute z-[1050]"} ${Oe} text-center text-gray-500 dark:text-gray-400
|
||
${y?"p-1.5 text-[10px]":"p-3 text-sm"}`,style:ye,children:"No results found"})]});return x?Su.createPortal(J,document.body):J};return t.jsxs("div",{ref:V,className:`relative w-full ${y?"mb-2":"mb-4"}`,children:[t.jsx("label",{className:`block font-medium text-gray-700 dark:text-gray-300 ${y?"text-[10px] mb-0.5":"text-sm mb-1"}`,children:e}),t.jsxs("div",{className:"relative",children:[t.jsx("input",{ref:Z,type:"text",value:D?C:a,placeholder:i||`Select ${e}`,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
|
||
${y?"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"}
|
||
${a?y?"pr-5":"pr-8":""}`,onFocus:()=>{c||(A(!0),O(""),x&&ae())},onChange:Oe=>{const ye=Oe.target.value;O(ye),Ce(ye)}}),a&&!c&&!D&&t.jsx("button",{type:"button",onClick:K,className:`absolute top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300
|
||
${y?"right-1 text-xs":"right-2 text-sm"}`,children:"✕"})]}),fe()]})},wC="Asset Maintenance Assignees Status Count",kC=[{label:"Planned",color:"#6366F1",fields:["pending","Pending"]},{label:"Completed",color:"#10B981",fields:["completed_on_time","completed_within_time","delay_in_completion"]},{label:"Cancelled",color:"#F59E0B",fields:["cancelled","Cancelled"]},{label:"Overdue",color:"#EF4444",fields:["overdue","Overdue"]}],Nc=(e,...r)=>{for(const a of r){const n=e[a];if(n==null||n==="")continue;const i=Number(n);if(Number.isFinite(i))return i}return 0},NC=e=>{const r=e["Assigned To"]||e.assign_to_name||e.assigned_to||e.assign_to||"Unknown";return String(r).trim()||"Unknown"},Ow=e=>Nc(e,"pending","Pending"),Rw=e=>Nc(e,"completed_on_time")+Nc(e,"completed_within_time")+Nc(e,"delay_in_completion"),Mw=e=>Nc(e,"cancelled","Cancelled"),Dw=e=>Nc(e,"overdue","Overdue"),SC=e=>Ow(e)+Rw(e)+Mw(e)+Dw(e),Lw=e=>{const r=e.filter(n=>n&&!n.is_total_row);if(!r.length)return null;const a=kC.map(({label:n,color:i,fields:c})=>({label:n,color:i,total:r.reduce((u,g)=>u+c.reduce((y,x)=>y+Nc(g,x),0),0)}));return{labels:a.map(n=>n.label),datasets:[{name:"Tasks",values:a.map(n=>n.total),colors:a.map(n=>n.color)}],type:"Bar",rawRows:r}},Iw=e=>xe(null,null,function*(){var g,y,x;const r=typeof window!="undefined"&&window.csrf_token&&window.csrf_token!=="None"?window.csrf_token:null,a={"Content-Type":"application/json",Accept:"application/json"};r&&(a["X-Frappe-CSRF-Token"]=r);const n={};Object.entries(e).forEach(([k,N])=>{N&&(n[k]=N)});const i=yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:a,credentials:"include",body:JSON.stringify({report_name:wC,filters:n,ignore_prepared_report:1})}),c=yield i.json();if(!i.ok)throw new Error((c==null?void 0:c.message)||(c==null?void 0:c.exc)||"Failed to load assignees status report");const u=((g=c==null?void 0:c.message)==null?void 0:g.result)||((x=(y=c==null?void 0:c.message)==null?void 0:y.message)==null?void 0:x.result)||[];return Array.isArray(u)?u.filter(k=>k&&!k.is_total_row):[]}),CC=e=>xe(null,null,function*(){const r=yield Iw(e);return Lw(r)});function EC(e,r,a,n){const i=new URLSearchParams;e.assignee&&i.set("assignee",e.assignee),e.status&&i.set("status",e.status),(e.company||n!=null&&n.company)&&i.set("company",e.company||(n==null?void 0:n.company)||""),(e.site_name||n!=null&&n.site_name)&&i.set("site_name",e.site_name||(n==null?void 0:n.site_name)||""),r&&i.set("date_start",r),a&&i.set("date_end",a);const c=i.toString();return`/maintenance${c?`?${c}`:""}`}function Sf(e,r,a,n){const i=new URLSearchParams;e.status&&i.set("status",e.status),e.work_order_type&&i.set("work_order_type",e.work_order_type),(e.company||n!=null&&n.company)&&i.set("company",e.company||(n==null?void 0:n.company)||""),(e.site_name||n!=null&&n.site_name)&&i.set("site_name",e.site_name||(n==null?void 0:n.site_name)||""),(r||a)&&(i.set("date_filter_by","creation"),r&&i.set("date_start",r),a&&i.set("date_end",a));const c=i.toString();return`/work-orders${c?`?${c}`:""}`}function jC(e){const r=(e||"").trim().toLowerCase();return r===""||r==="null"||r==="unknown"||r==="none"||r==="undefined"}const Xh=["#8B5CF6","#6366F1","#3B82F6","#06B6D4","#14B8A6","#EC4899","#A855F7","#0EA5E9","#10B981","#F472B6","#7C3AED","#2DD4BF"];function av(e,r){return(e||0)+(r||0)}function Sp(e){var n;const r=e.total||0;if(r<=0)return 0;const a=(n=e.completedCombined)!=null?n:(e.completed||0)+(e.closed||0);return Math.round(a/r*1e4)/100}const nv="/asm_app",TC=({isOpen:e,onClose:r,title:a,initialData:n=null,redirectContext:i=null,defaultFromDate:c="",defaultToDate:u="",locationFilters:g,workOrderType:y=""})=>{var ie,re;const{t:x}=oa(),k=ua(),[N,C]=E.useState(c),[O,D]=E.useState(u),[A,I]=E.useState(n),[z,U]=E.useState(!1),[B,V]=E.useState(null),Z=E.useCallback((ne,ve)=>{const Ve={};return ne&&(Ve.from_date=ne),ve&&(Ve.to_date=ve),g!=null&&g.company&&(Ve.company=g.company),g!=null&&g.site_name&&(Ve.site_name=g.site_name),y&&(Ve.work_order_type=y),Ve},[g,y]),W=E.useCallback((ne,ve)=>xe(null,null,function*(){var Ve;if(i==="wo_status"){U(!0),V(null);try{const Ae=yield _t.getDashboardWorkOrderMetrics(Z(ne,ve));I(Ae.work_order_chart)}catch(Ae){I(null),V(Ae instanceof Error?Ae.message:"Failed to load report data")}finally{U(!1)}return}if(i==="wo_type"){U(!0),V(null);try{const ze=((Ve=(yield _t.getDashboardWorkOrderMetrics(Z(ne,ve))).completion_by_type)==null?void 0:Ve.rates)||[];I({labels:ze.map(Re=>Re.type),datasets:[{name:"Completion Rate (%)",values:ze.map(Re=>Sp(Re))},{name:"Completed WOs",values:ze.map(Re=>{var Ze;return(Ze=Re.completedCombined)!=null?Ze:(Re.completed||0)+(Re.closed||0)})},{name:"In Progress",values:ze.map(Re=>Re.inProgress||0)},{name:"Rejected",values:ze.map(Re=>Re.rejected||0)},{name:"Total WOs",values:ze.map(Re=>Re.total||0)}],hideFooterTotal:!0})}catch(Ae){I(null),V(Ae instanceof Error?Ae.message:"Failed to load report data")}finally{U(!1)}return}if(i==="assignees_status"){U(!0),V(null);try{const Ae=yield Iw(Z(ne,ve));I(Lw(Ae))}catch(Ae){I(null),V(Ae instanceof Error?Ae.message:"Failed to load report data")}finally{U(!1)}return}I(n)}),[i,n,Z]);E.useEffect(()=>{e&&(C(c),D(u),W(c,u))},[e,c,u,W]),E.useEffect(()=>{if(!e)return;const ne=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=ne}},[e]),E.useEffect(()=>{if(!e)return;const ne=ve=>{ve.key==="Escape"&&r()};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[e,r]);const H=E.useMemo(()=>{var Ae,ze,Re,Ze;const ne=(A==null?void 0:A.labels)||[],ve=((ze=(Ae=A==null?void 0:A.datasets)==null?void 0:Ae[0])==null?void 0:ze.values)||[],Ve=((Ze=(Re=A==null?void 0:A.datasets)==null?void 0:Re[0])==null?void 0:Ze.colors)||[];return ne.map((Lt,mt)=>({label:Lt,value:Number(ve[mt])||0,color:Ve[mt]||"#6366F1"}))},[A]),le=E.useMemo(()=>{const ne=(A==null?void 0:A.labels)||[],ve=(A==null?void 0:A.datasets)||[];return ne.map((Ve,Ae)=>({label:Ve,cells:ve.map(ze=>{var Re;return Number((Re=ze.values)==null?void 0:Re[Ae])||0})}))},[A]),Q=((ie=A==null?void 0:A.datasets)==null?void 0:ie.map(ne=>ne.name||""))||[],Ne=E.useMemo(()=>H.reduce((ne,ve)=>ne+ve.value,0),[H]),oe=E.useMemo(()=>((A==null?void 0:A.rawRows)||[]).map(ve=>({assignee:NC(ve),planned:Ow(ve),completed:Rw(ve),cancelled:Mw(ve),overdue:Dw(ve),total:SC(ve)})),[A==null?void 0:A.rawRows]),se=E.useMemo(()=>oe.reduce((ne,ve)=>(ne.planned+=ve.planned,ne.completed+=ve.completed,ne.cancelled+=ve.cancelled,ne.overdue+=ve.overdue,ne.total+=ve.total,ne),{planned:0,completed:0,cancelled:0,overdue:0,total:0}),[oe]),ce=()=>{W(N,O)},Ce=()=>{C(""),D(""),W("","")},ae=ne=>{const ve=Sf({work_order_type:ne.work_order_type,status:ne.status,company:g==null?void 0:g.company,site_name:g==null?void 0:g.site_name},N||void 0,O||void 0,g);r(),window.location.href=`${nv}${ve}`},me=(ne,ve)=>{const Ve=EC({assignee:ne,status:ve},N||void 0,O||void 0,g);r(),window.location.href=`${nv}${Ve}`},K=(ne,ve,Ve)=>{i!=="assignees_status"||Ve<=0||me(ne,ve)},fe=ne=>{i==="wo_status"&&(r(),k(Sf({status:ne},N||void 0,O||void 0,g)))},Oe=(ne,ve)=>{if(i==="wo_type"){if(ve==="Rejected"){ae({work_order_type:ne,status:"Rejected"});return}if(ve==="In Progress"){ae({work_order_type:ne,status:"Work In Progress"});return}if(ve==="Completed WOs"||ve==="Completion Rate (%)"){ae({work_order_type:ne,status:"Completed,Closed"});return}ae({work_order_type:ne})}},ye=N||O?x("dashboard.activeDateRange",{defaultValue:"Date range: {{from}} to {{to}}",from:N||"—",to:O||"—"}):x("dashboard.allDates",{defaultValue:"Showing all dates"});if(!e)return null;const J=i==="wo_type",G=i==="assignees_status"||!!((re=A==null?void 0:A.rawRows)!=null&&re.length);return t.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:t.jsxs("div",{className:"w-full max-w-4xl max-h-[90vh] overflow-hidden rounded-xl bg-white dark:bg-gray-900 shadow-2xl border border-gray-200 dark:border-gray-700 flex flex-col",children:[t.jsx("div",{className:`px-5 py-4 border-b border-gray-200 dark:border-gray-700 ${J||G?"bg-gradient-to-r from-indigo-600 to-purple-600 text-white":""}`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("h3",{className:`text-lg font-semibold ${J||G?"text-white":"text-gray-900 dark:text-white"}`,children:a}),t.jsx("p",{className:`text-xs mt-1 ${J||G?"text-white/85":"text-indigo-600 dark:text-indigo-300"}`,children:J?x("dashboard.clickRowToFilter",{defaultValue:"Click a row or value to view filtered work orders"}):ye})]}),t.jsx("button",{type:"button",onClick:r,className:`p-2 rounded-lg ${J||G?"hover:bg-white/10 text-white":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-500"}`,"aria-label":"Close",children:t.jsx(qt,{})})]})}),t.jsxs("div",{className:"px-5 py-3 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:[t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3 items-end",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-300 mb-1",children:x("dashboard.fromDate",{defaultValue:"From Date"})}),t.jsx("input",{type:"date",value:N,onChange:ne=>C(ne.target.value),className:"w-full rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-900 px-3 py-2 text-sm"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-300 mb-1",children:x("dashboard.toDate",{defaultValue:"To Date"})}),t.jsx("input",{type:"date",value:O,onChange:ne=>D(ne.target.value),className:"w-full rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-900 px-3 py-2 text-sm"})]}),t.jsxs("div",{className:"flex flex-wrap gap-2 lg:col-span-2",children:[t.jsxs("button",{type:"button",onClick:ce,disabled:z,className:"inline-flex items-center gap-2 px-3 py-2 rounded-md bg-indigo-600 hover:bg-indigo-700 text-white text-sm disabled:opacity-60",children:[t.jsx(Eo,{className:z?"animate-spin":""}),x("dashboard.applyFilters",{defaultValue:"Apply"})]}),t.jsx("button",{type:"button",onClick:Ce,disabled:z,className:"px-3 py-2 rounded-md border border-gray-300 dark:border-gray-600 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-60",children:x("dashboard.clearDates",{defaultValue:"Clear dates"})})]})]}),J&&t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:ye})]}),t.jsxs("div",{className:"overflow-y-auto flex-1",children:[B&&t.jsx("div",{className:"mx-5 mt-4 rounded-md border border-red-200 bg-red-50 text-red-700 px-4 py-3 text-sm",children:B}),J?t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800/80 sticky top-0",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left font-semibold text-gray-700 dark:text-gray-200",children:x("dashboard.woType",{defaultValue:"WO Type"})}),Q.map(ne=>t.jsx("th",{className:"px-4 py-3 text-right font-semibold text-gray-700 dark:text-gray-200 whitespace-nowrap",children:ne},ne))]})}),t.jsx("tbody",{children:z?t.jsx("tr",{children:t.jsx("td",{colSpan:Q.length+1,className:"px-5 py-10 text-center text-gray-500",children:x("common.loading",{defaultValue:"Loading..."})})}):le.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:Q.length+1,className:"px-5 py-10 text-center text-gray-500",children:x("common.noData",{defaultValue:"No data"})})}):le.map(ne=>t.jsxs("tr",{className:"border-t border-gray-100 dark:border-gray-800",children:[t.jsx("td",{className:"px-4 py-3",children:t.jsx("button",{type:"button",onClick:()=>Oe(ne.label,"Total WOs"),className:"text-left font-medium text-indigo-700 dark:text-indigo-300 hover:underline",children:ne.label})}),ne.cells.map((ve,Ve)=>t.jsx("td",{className:"px-4 py-3 text-right",children:t.jsx("button",{type:"button",onClick:()=>Oe(ne.label,Q[Ve]),className:"font-semibold text-gray-900 dark:text-white hover:text-indigo-600 dark:hover:text-indigo-300",children:Q[Ve]==="Completion Rate (%)"?`${ve.toFixed(2)}%`:ve})},`${ne.label}-${Q[Ve]}`))]},ne.label))})]}):G?t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800/80 sticky top-0",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left font-semibold text-gray-700 dark:text-gray-200",children:x("dashboard.assignedTo",{defaultValue:"Assigned To"})}),t.jsx("th",{className:"px-4 py-3 text-right font-semibold text-indigo-600 dark:text-indigo-300",children:x("dashboard.plannedTasks",{defaultValue:"Planned"})}),t.jsx("th",{className:"px-4 py-3 text-right font-semibold text-green-600 dark:text-green-400",children:x("dashboard.completedTasks",{defaultValue:"Completed"})}),t.jsx("th",{className:"px-4 py-3 text-right font-semibold text-amber-600 dark:text-amber-400",children:x("dashboard.cancelledTasks",{defaultValue:"Cancelled"})}),t.jsx("th",{className:"px-4 py-3 text-right font-semibold text-red-600 dark:text-red-400",children:x("dashboard.overdueTasks",{defaultValue:"Overdue"})}),t.jsx("th",{className:"px-4 py-3 text-right font-semibold text-gray-700 dark:text-gray-200",children:x("dashboard.totalTasks",{defaultValue:"Total"})})]})}),t.jsx("tbody",{children:z?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"px-5 py-10 text-center text-gray-500",children:x("common.loading",{defaultValue:"Loading..."})})}):oe.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"px-5 py-10 text-center text-gray-500",children:x("common.noData",{defaultValue:"No data"})})}):oe.map(ne=>t.jsxs("tr",{className:"border-t border-gray-100 dark:border-gray-800",children:[t.jsx("td",{className:"px-4 py-3 text-gray-800 dark:text-gray-100",children:ne.assignee}),t.jsx("td",{className:"px-4 py-3 text-right",children:t.jsx(Yh,{value:ne.planned,onClick:()=>K(ne.assignee,"Planned",ne.planned)})}),t.jsx("td",{className:"px-4 py-3 text-right",children:t.jsx(Yh,{value:ne.completed,onClick:()=>K(ne.assignee,"Completed",ne.completed)})}),t.jsx("td",{className:"px-4 py-3 text-right",children:t.jsx(Yh,{value:ne.cancelled,onClick:()=>K(ne.assignee,"Cancelled",ne.cancelled)})}),t.jsx("td",{className:"px-4 py-3 text-right",children:t.jsx(Yh,{value:ne.overdue,onClick:()=>K(ne.assignee,"Overdue",ne.overdue)})}),t.jsx("td",{className:"px-4 py-3 text-right font-semibold text-gray-900 dark:text-white",children:ne.total})]},ne.assignee))}),!z&&oe.length>0&&t.jsx("tfoot",{children:t.jsxs("tr",{className:"border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/80",children:[t.jsx("td",{className:"px-4 py-3 font-semibold text-gray-800 dark:text-gray-100",children:x("dashboard.totalTasks",{defaultValue:"Total"})}),t.jsx("td",{className:"px-4 py-3 text-right font-semibold text-indigo-600 dark:text-indigo-300",children:se.planned}),t.jsx("td",{className:"px-4 py-3 text-right font-semibold text-green-600 dark:text-green-400",children:se.completed}),t.jsx("td",{className:"px-4 py-3 text-right font-semibold text-amber-600 dark:text-amber-400",children:se.cancelled}),t.jsx("td",{className:"px-4 py-3 text-right font-semibold text-red-600 dark:text-red-400",children:se.overdue}),t.jsx("td",{className:"px-4 py-3 text-right font-semibold text-gray-900 dark:text-white",children:se.total})]})})]}):t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800/80 sticky top-0",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-5 py-3 text-left font-semibold text-gray-700 dark:text-gray-200",children:x("commonFields.status",{defaultValue:"Status"})}),t.jsx("th",{className:"px-5 py-3 text-right font-semibold text-gray-700 dark:text-gray-200",children:x("dashboard.workOrders",{defaultValue:"Work Orders"})})]})}),t.jsx("tbody",{children:z?t.jsx("tr",{children:t.jsx("td",{colSpan:2,className:"px-5 py-10 text-center text-gray-500",children:x("common.loading",{defaultValue:"Loading..."})})}):H.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:2,className:"px-5 py-10 text-center text-gray-500",children:x("common.noData",{defaultValue:"No data"})})}):H.map(ne=>t.jsxs("tr",{className:`border-t border-gray-100 dark:border-gray-800 ${i==="wo_status"?"cursor-pointer hover:bg-indigo-50 dark:hover:bg-indigo-900/20":""}`,onClick:()=>fe(ne.label),children:[t.jsx("td",{className:"px-5 py-3",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:ne.color}}),t.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:ne.label})]})}),t.jsx("td",{className:"px-5 py-3 text-right font-semibold text-gray-900 dark:text-white",children:ne.value})]},ne.label))}),!z&&H.length>0&&!(A!=null&&A.hideFooterTotal)&&t.jsx("tfoot",{children:t.jsxs("tr",{className:"border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/80",children:[t.jsx("td",{className:"px-5 py-3 font-semibold text-gray-800 dark:text-gray-100",children:x("dashboard.totalWorkOrders",{defaultValue:"Total Work Orders"})}),t.jsx("td",{className:"px-5 py-3 text-right font-semibold text-gray-900 dark:text-white",children:Ne})]})})]})]})]})})},Yh=({value:e,onClick:r})=>e<=0?t.jsx("span",{className:"text-gray-400",children:"0"}):t.jsx("button",{type:"button",onClick:r,className:"font-semibold text-gray-900 dark:text-white hover:text-indigo-600 dark:hover:text-indigo-300",children:e}),sv=["#6366F1","#8B5CF6","#06B6D4","#EC4899","#F59E0B","#10B981","#EF4444","#3B82F6"],AC=e=>{const r=Number(e);return Number.isFinite(r)&&r>=0?r:0},Jx=(e,r,a)=>a!=null&&a>0?`${e}: ${r} (${(r/a*100).toFixed(1)}%)`:`${e}: ${r}`,OC=()=>{const[e,r]=E.useState(null),a=E.useCallback((i,c,u,g,y)=>{r({x:i,y:c,text:Jx(u,g,y)})},[]),n=E.useCallback(()=>r(null),[]);return{tooltip:e,show:a,hide:n}},RC=({tooltip:e})=>e?t.jsx("div",{className:"fixed z-[9999] pointer-events-none px-2.5 py-1.5 rounded text-xs font-medium text-white bg-gray-900 shadow-lg whitespace-nowrap",style:{left:e.x,top:e.y-8,transform:"translate(-50%, -100%)"},role:"tooltip",children:e.text}):null,MC=({data:e,emptyMessage:r="No data available"})=>{var I,z,U,B,V;const{tooltip:a,show:n,hide:i}=OC(),c=(e==null?void 0:e.labels)||[],u=(((z=(I=e==null?void 0:e.datasets)==null?void 0:I[0])==null?void 0:z.values)||[]).map(AC),g=(B=(U=e==null?void 0:e.datasets)==null?void 0:U[0])==null?void 0:B.colors,y=g&&g.length===u.length?g:u.map((Z,W)=>sv[W%sv.length]),x=(V=e==null?void 0:e.total)!=null?V:u.reduce((Z,W)=>Z+W,0);if(x<=0||c.length===0)return t.jsx("div",{className:"h-48 flex items-center justify-center text-gray-400 text-sm",children:r});const k=100,N=k+10,C=k+10;let O=0;const D=u.map((Z,W)=>{const H=O/x*2*Math.PI-Math.PI/2;O+=Z;const le=O/x*2*Math.PI-Math.PI/2,Q=le-H>Math.PI?1:0,Ne=N+k*Math.cos(H),oe=C+k*Math.sin(H),se=N+k*Math.cos(le),ce=C+k*Math.sin(le);return{path:`M ${N} ${C} L ${Ne} ${oe} A ${k} ${k} 0 ${Q} 1 ${se} ${ce} Z`,color:y[W],label:c[W],value:Z,percentage:(Z/x*100).toFixed(1)}}),A=D.length===1;return t.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-around gap-4",onMouseLeave:i,children:[t.jsx(RC,{tooltip:a}),t.jsx("svg",{width:N*2,height:C*2,viewBox:`0 0 ${N*2} ${C*2}`,className:"max-w-xs shrink-0",children:A?t.jsx("circle",{cx:N,cy:C,r:k,fill:D[0].color,className:"hover:opacity-90 transition-opacity drop-shadow-lg",onMouseEnter:Z=>n(Z.clientX,Z.clientY,D[0].label,D[0].value,x),onMouseMove:Z=>n(Z.clientX,Z.clientY,D[0].label,D[0].value,x),onMouseLeave:i,children:t.jsx("title",{children:Jx(D[0].label,D[0].value,x)})}):D.map((Z,W)=>t.jsx("path",{d:Z.path,fill:Z.color,className:"hover:opacity-80 transition-opacity drop-shadow-md",onMouseEnter:H=>n(H.clientX,H.clientY,Z.label,Z.value,x),onMouseMove:H=>n(H.clientX,H.clientY,Z.label,Z.value,x),onMouseLeave:i,children:t.jsx("title",{children:Jx(Z.label,Z.value,x)})},W))}),t.jsx("div",{className:"flex flex-col gap-2 min-w-[140px]",children:D.map((Z,W)=>t.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-300",children:[t.jsx("span",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:Z.color}}),t.jsx("span",{className:"truncate flex-1",children:Z.label}),t.jsx("span",{className:"font-semibold text-gray-800 dark:text-white",children:Z.value})]},W))})]})},DC=({title:e,data:r,loading:a=!1,totalAssets:n,onOpenReport:i})=>{var u;const{t:c}=oa();return t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow hover:shadow-md transition-all px-5 py-5 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-white",children:e}),t.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:[n.toLocaleString()," ",c("dashboard.totalAssetsLabel",{defaultValue:"Total"})]})]}),t.jsx("button",{type:"button",onClick:i,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg text-teal-600 dark:text-teal-300",title:c("dashboard.viewAssetStatusOverview",{defaultValue:"View asset status overview"}),children:t.jsx(qd,{className:"w-4 h-4"})})]}),a?t.jsx("div",{className:"h-64 flex items-center justify-center",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-teal-600"})}):(u=r==null?void 0:r.labels)!=null&&u.length?t.jsx(MC,{data:r,emptyMessage:c("dashboard.noAssetStatusData",{defaultValue:"No asset status data"})}):t.jsx("div",{className:"h-64 flex items-center justify-center text-gray-400 text-sm",children:c("dashboard.noAssetStatusData",{defaultValue:"No asset status data"})})]})};function Pw(e,r,a,n){const i=new URLSearchParams;e.device_status&&i.set("device_status",e.device_status),(e.company||n!=null&&n.company)&&i.set("company",e.company||(n==null?void 0:n.company)||""),(e.site_name||n!=null&&n.site_name)&&i.set("site_name",e.site_name||(n==null?void 0:n.site_name)||""),(r||a)&&(i.set("date_filter_by","creation"),r&&i.set("date_start",r),a&&i.set("date_end",a));const c=i.toString();return`/assets${c?`?${c}`:""}`}const wo="block font-medium text-gray-700 dark:text-gray-300 text-[10px] mb-0.5",ko="w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-emerald-500 disabled:bg-gray-100 dark:disabled:bg-gray-700",No="relative w-full mb-2",Fw="inline-flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium disabled:opacity-50 disabled:cursor-not-allowed",em=(e="cyan")=>`${Fw} ${{cyan:"bg-cyan-600 hover:bg-cyan-700 text-white",purple:"bg-purple-600 hover:bg-purple-700 text-white",emerald:"bg-emerald-600 hover:bg-emerald-700 text-white"}[e]} disabled:opacity-60`,Fd=`${Fw} border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-800`,Cp="rounded-lg border px-3 py-2",Ep="text-[10px] text-gray-500 dark:text-gray-400",jp="text-lg font-semibold text-gray-900 dark:text-white",LC=(e,r)=>{const a=(e||"").trim().toLowerCase();return a==="up"?{bg:"bg-emerald-50 dark:bg-emerald-900/20",border:"border-emerald-200 dark:border-emerald-800",text:"text-emerald-700 dark:text-emerald-300",bar:"#10B981"}:a==="down"?{bg:"bg-red-50 dark:bg-red-900/20",border:"border-red-200 dark:border-red-800",text:"text-red-700 dark:text-red-300",bar:"#EF4444"}:a.includes("maintenance")?{bg:"bg-amber-50 dark:bg-amber-900/20",border:"border-amber-200 dark:border-amber-800",text:"text-amber-700 dark:text-amber-300",bar:"#F59E0B"}:a.includes("decommission")?{bg:"bg-gray-50 dark:bg-gray-800",border:"border-gray-200 dark:border-gray-700",text:"text-gray-600 dark:text-gray-300",bar:"#6B7280"}:{bg:"bg-indigo-50 dark:bg-indigo-900/20",border:"border-indigo-200 dark:border-indigo-800",text:"text-indigo-700 dark:text-indigo-300",bar:r||"#6366F1"}},IC="/asm_app",PC=({isOpen:e,onClose:r,chartData:a,defaultFromDate:n="",defaultToDate:i="",locationFilters:c,onRefresh:u})=>{var Z;const{t:g}=oa(),[y,x]=E.useState(!1),[k,N]=E.useState(n),[C,O]=E.useState(i),[D,A]=E.useState(a);E.useEffect(()=>{e&&(N(n),O(i),A(a))},[e,n,i,a]);const I=E.useCallback(()=>{const W={};return c!=null&&c.company&&(W.company=c.company),c!=null&&c.site_name&&(W.site_name=c.site_name),k&&(W.from_date=k),C&&(W.to_date=C),W},[k,C,c]),z=E.useCallback(()=>xe(null,null,function*(){if(u){x(!0);try{const W=yield u(I());A(W.chart)}catch(W){console.error("Failed to load asset status overview:",W),A(null)}finally{x(!1)}}}),[u,I]);E.useEffect(()=>{!e||!u||z()},[e,u]);const U=(Z=D==null?void 0:D.total)!=null?Z:0,B=E.useMemo(()=>{var Q,Ne,oe,se;const W=(D==null?void 0:D.labels)||[],H=((Ne=(Q=D==null?void 0:D.datasets)==null?void 0:Q[0])==null?void 0:Ne.values)||[],le=((se=(oe=D==null?void 0:D.datasets)==null?void 0:oe[0])==null?void 0:se.colors)||[];return W.map((ce,Ce)=>({label:ce,count:Number(H[Ce])||0,color:le[Ce],percentage:U>0?(Number(H[Ce])||0)/U*100:0}))},[D,U]),V=E.useCallback(W=>{const H=Pw(_e({device_status:W},c),k,C,c);window.location.href=`${IC}${H}`},[k,C,c]);return e?t.jsxs("div",{className:"fixed inset-0 z-[80] flex items-center justify-center p-4",children:[t.jsx("button",{type:"button",className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:r,"aria-label":"Close"}),t.jsxs("div",{className:"relative w-full max-w-2xl max-h-[90vh] overflow-hidden rounded-xl bg-white dark:bg-gray-900 shadow-2xl flex flex-col",children:[t.jsx("div",{className:"bg-gradient-to-r from-teal-500 to-emerald-600 text-white px-4 py-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("div",{className:"p-1.5 rounded-lg bg-white/15",children:t.jsx(kw,{className:"w-4 h-4"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold",children:g("dashboard.assetStatusOverview",{defaultValue:"Asset Status Overview"})}),t.jsx("p",{className:"text-xs text-white/85 mt-0.5",children:g("dashboard.clickStatusCardHint",{defaultValue:"Click a card to view filtered assets"})})]})]}),t.jsx("button",{type:"button",onClick:r,className:"p-1.5 rounded-lg hover:bg-white/10",children:t.jsx(qt,{className:"text-sm"})})]})}),t.jsx("div",{className:"px-3 py-2 bg-teal-50 dark:bg-teal-900/20 border-b border-teal-100 dark:border-teal-900/40",children:t.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[t.jsxs("div",{className:`${No} mb-0 w-[8.5rem]`,children:[t.jsx("label",{className:wo,children:g("dashboard.fromDate",{defaultValue:"From Date"})}),t.jsx("input",{type:"date",value:k,onChange:W=>N(W.target.value),className:ko})]}),t.jsxs("div",{className:`${No} mb-0 w-[8.5rem]`,children:[t.jsx("label",{className:wo,children:g("dashboard.toDate",{defaultValue:"To Date"})}),t.jsx("input",{type:"date",value:C,onChange:W=>O(W.target.value),className:ko})]}),t.jsxs("button",{type:"button",onClick:z,disabled:y||!u,className:`${em("emerald")} mb-0.5`,children:[t.jsx(Eo,{className:`text-[10px] ${y?"animate-spin":""}`}),g("dashboard.refreshReport",{defaultValue:"Refresh"})]}),((c==null?void 0:c.company)||(c==null?void 0:c.site_name))&&t.jsxs("div",{className:"flex flex-wrap gap-1.5 ml-auto pb-0.5",children:[(c==null?void 0:c.company)&&t.jsx("span",{className:"px-2 py-0.5 rounded-full bg-white dark:bg-gray-800 border border-teal-200 dark:border-teal-800 text-teal-800 dark:text-teal-200 text-[10px]",children:c.company}),(c==null?void 0:c.site_name)&&t.jsx("span",{className:"px-2 py-0.5 rounded-full bg-white dark:bg-gray-800 border border-teal-200 dark:border-teal-800 text-teal-800 dark:text-teal-200 text-[10px]",children:c.site_name})]})]})}),t.jsxs("div",{className:"p-3 overflow-y-auto flex-1 space-y-3",children:[t.jsx("button",{type:"button",onClick:()=>V(),className:"w-full text-left rounded-lg border border-indigo-200 dark:border-indigo-800 bg-indigo-50 dark:bg-indigo-900/20 p-3 hover:shadow-md transition-all group",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-xl font-bold text-indigo-700 dark:text-indigo-300",children:U.toLocaleString()}),t.jsx("div",{className:"text-xs font-medium text-indigo-600 dark:text-indigo-300 mt-0.5",children:g("dashboard.totalAssets",{defaultValue:"Total Assets"})})]}),t.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-semibold text-indigo-600 dark:text-indigo-300 group-hover:underline",children:[g("dashboard.viewAll",{defaultValue:"View all"}),t.jsx(qd,{className:"w-2.5 h-2.5"})]})]})}),y?t.jsx("div",{className:"py-8 flex justify-center",children:t.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-teal-600"})}):t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:B.map(W=>{const H=LC(W.label,W.color);return t.jsxs("button",{type:"button",onClick:()=>V(W.label),className:`text-left rounded-lg border p-3 transition-all hover:shadow-md group ${H.bg} ${H.border}`,children:[t.jsx("div",{className:`text-lg font-bold ${H.text}`,children:W.count.toLocaleString()}),t.jsx("div",{className:`text-[10px] font-semibold uppercase tracking-wide mt-0.5 ${H.text}`,children:W.label}),t.jsx("div",{className:"mt-2 h-1.5 rounded-full bg-white/70 dark:bg-gray-900/30 overflow-hidden",children:t.jsx("div",{className:"h-full rounded-full",style:{width:`${W.percentage}%`,backgroundColor:H.bar}})}),t.jsxs("div",{className:"mt-1.5 flex items-center justify-between text-[10px] text-gray-600 dark:text-gray-400",children:[t.jsxs("span",{children:[W.percentage.toFixed(1),"% ",g("dashboard.ofTotal",{defaultValue:"of total"})]}),t.jsx("span",{className:"opacity-0 group-hover:opacity-100 transition-opacity font-medium",children:g("dashboard.viewFiltered",{defaultValue:"View ↗"})})]})]},W.label)})})]})]})]}):null},FC="/asm_app",BC={Open:"text-amber-700 dark:text-amber-300","Work In Progress":"text-blue-700 dark:text-blue-300","Pending Review":"text-rose-700 dark:text-rose-300",Completed:"text-green-700 dark:text-green-400",Closed:"text-purple-700 dark:text-purple-300",Rejected:"text-red-700 dark:text-red-400",Cancelled:"text-gray-600 dark:text-gray-300"},UC=({isOpen:e,onClose:r,initialChartData:a=null,defaultFromDate:n="",defaultToDate:i="",locationFilters:c,workOrderType:u="",onRefresh:g})=>{var me;const{t:y}=oa(),[x,k]=E.useState(n),[N,C]=E.useState(i),[O,D]=E.useState(a),[A,I]=E.useState(0),[z,U]=E.useState(!1),[B,V]=E.useState(null);E.useEffect(()=>{e&&(k(n),C(i),D(a),V(null))},[e,n,i,a]),E.useEffect(()=>{if(!e)return;const K=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=K}},[e]),E.useEffect(()=>{if(!e)return;const K=fe=>{fe.key==="Escape"&&r()};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[e,r]);const Z=E.useCallback(()=>{const K={};return c!=null&&c.company&&(K.company=c.company),c!=null&&c.site_name&&(K.site_name=c.site_name),x&&(K.from_date=x),N&&(K.to_date=N),u&&(K.work_order_type=u),K},[x,N,c,u]),W=E.useCallback(()=>xe(null,null,function*(){if(g){U(!0),V(null);try{const K=yield g(Z());D(K.chart),I(K.total)}catch(K){D(null),I(0),V(K instanceof Error?K.message:"Failed to load report data")}finally{U(!1)}}}),[g,Z]);E.useEffect(()=>{!e||!g||W()},[e,g]);const H=E.useMemo(()=>{const K=(O==null?void 0:O.labels)||[],fe=(O==null?void 0:O.datasets)||[];return K.map((Oe,ye)=>({label:Oe,cells:fe.map(J=>{var G;return Number((G=J.values)==null?void 0:G[ye])||0}),rowTotal:fe.reduce((J,G)=>{var ie;return J+(Number((ie=G.values)==null?void 0:ie[ye])||0)},0)}))},[O]),le=((me=O==null?void 0:O.datasets)==null?void 0:me.map(K=>K.name||""))||[],Q=E.useMemo(()=>le.map((K,fe)=>H.reduce((Oe,ye)=>Oe+(ye.cells[fe]||0),0)),[le,H]),Ne=E.useMemo(()=>H.reduce((K,fe)=>K+fe.rowTotal,0),[H]),oe=A||Ne,se=K=>{const fe=Sf({work_order_type:K.work_order_type||u||void 0,status:K.status,company:c==null?void 0:c.company,site_name:c==null?void 0:c.site_name},x||void 0,N||void 0,c);r(),window.location.href=`${FC}${fe}`},ce=K=>{se({work_order_type:K})},Ce=(K,fe,Oe)=>{Oe<=0||se({work_order_type:K,status:fe})},ae=(K,fe)=>{fe<=0||se({status:K})};return e?t.jsxs("div",{className:"fixed inset-0 z-[80] flex items-center justify-center p-4",children:[t.jsx("button",{type:"button",className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:r,"aria-label":"Close"}),t.jsxs("div",{className:"relative w-full max-w-5xl max-h-[90vh] overflow-hidden rounded-xl bg-white dark:bg-gray-900 shadow-2xl flex flex-col",children:[t.jsx("div",{className:"bg-gradient-to-r from-indigo-600 to-purple-600 text-white px-4 py-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("div",{className:"p-1.5 rounded-lg bg-white/15 shrink-0",children:t.jsx(Kx,{className:"w-4 h-4"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-base font-semibold truncate",children:y("dashboard.workOrderStatus",{defaultValue:"Work Order Status"})}),t.jsx("p",{className:"text-xs text-white/85 mt-0.5",children:y("dashboard.workOrderTypeStatusHint",{defaultValue:"Type vs status counts — click a number to view filtered work orders"})})]})]}),t.jsx("button",{type:"button",onClick:r,className:"p-1.5 rounded-lg hover:bg-white/10",children:t.jsx(qt,{className:"text-sm"})})]})}),t.jsx("div",{className:"px-3 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:t.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[t.jsxs("div",{className:`${No} mb-0 w-[8.5rem]`,children:[t.jsx("label",{className:wo,children:y("dashboard.fromDate",{defaultValue:"From Date"})}),t.jsx("input",{type:"date",value:x,onChange:K=>k(K.target.value),className:ko})]}),t.jsxs("div",{className:`${No} mb-0 w-[8.5rem]`,children:[t.jsx("label",{className:wo,children:y("dashboard.toDate",{defaultValue:"To Date"})}),t.jsx("input",{type:"date",value:N,onChange:K=>C(K.target.value),className:ko})]}),t.jsxs("button",{type:"button",onClick:W,disabled:z||!g,className:`${em("purple")} mb-0.5`,children:[t.jsx(Eo,{className:`text-[10px] ${z?"animate-spin":""}`}),y("dashboard.refreshReport",{defaultValue:"Refresh"})]}),((c==null?void 0:c.company)||(c==null?void 0:c.site_name))&&t.jsxs("div",{className:"flex flex-wrap gap-1.5 ml-auto pb-0.5",children:[(c==null?void 0:c.company)&&t.jsx("span",{className:"px-2 py-0.5 rounded-full bg-white dark:bg-gray-800 border border-indigo-200 dark:border-indigo-800 text-indigo-800 dark:text-indigo-200 text-[10px]",children:c.company}),(c==null?void 0:c.site_name)&&t.jsx("span",{className:"px-2 py-0.5 rounded-full bg-white dark:bg-gray-800 border border-indigo-200 dark:border-indigo-800 text-indigo-800 dark:text-indigo-200 text-[10px]",children:c.site_name})]})]})}),t.jsx("div",{className:"px-3 py-2 border-b border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:`${Cp} border-indigo-200 dark:border-indigo-800 bg-indigo-50 dark:bg-indigo-900/20 inline-block min-w-[8rem]`,children:[t.jsx("div",{className:Ep,children:y("dashboard.totalWorkOrders",{defaultValue:"Total Work Orders"})}),t.jsx("div",{className:`${jp} text-indigo-700 dark:text-indigo-300`,children:oe.toLocaleString()})]})}),t.jsxs("div",{className:"overflow-y-auto flex-1",children:[B&&t.jsx("div",{className:"mx-3 mt-3 rounded-md border border-red-200 bg-red-50 text-red-700 px-3 py-2 text-xs",children:B}),t.jsxs("table",{className:"min-w-full text-xs",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800/80 sticky top-0",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-semibold text-gray-700 dark:text-gray-200",children:y("dashboard.woType",{defaultValue:"WO Type"})}),le.map(K=>t.jsx("th",{className:`px-3 py-2 text-right font-semibold whitespace-nowrap ${BC[K]||"text-gray-700 dark:text-gray-200"}`,children:K},K)),t.jsx("th",{className:"px-3 py-2 text-right font-semibold text-gray-700 dark:text-gray-200",children:y("dashboard.totalWorkOrders",{defaultValue:"Total"})})]})}),t.jsx("tbody",{children:z?t.jsx("tr",{children:t.jsx("td",{colSpan:le.length+2,className:"px-3 py-8 text-center text-gray-500",children:y("common.loading",{defaultValue:"Loading..."})})}):H.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:le.length+2,className:"px-3 py-8 text-center text-gray-500",children:y("common.noData",{defaultValue:"No data"})})}):H.map(K=>t.jsxs("tr",{className:"border-t border-gray-100 dark:border-gray-800",children:[t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{type:"button",onClick:()=>ce(K.label),className:"text-left font-medium text-indigo-700 dark:text-indigo-300 hover:underline",children:K.label})}),K.cells.map((fe,Oe)=>t.jsx("td",{className:"px-3 py-2 text-right",children:t.jsx(iv,{value:fe,onClick:()=>Ce(K.label,le[Oe],fe)})},`${K.label}-${le[Oe]}`)),t.jsx("td",{className:"px-3 py-2 text-right font-semibold text-gray-900 dark:text-white",children:K.rowTotal})]},K.label))}),!z&&H.length>0&&t.jsx("tfoot",{children:t.jsxs("tr",{className:"border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/80",children:[t.jsx("td",{className:"px-3 py-2 font-semibold text-gray-800 dark:text-gray-100",children:y("dashboard.totalWorkOrders",{defaultValue:"Total"})}),Q.map((K,fe)=>t.jsx("td",{className:"px-3 py-2 text-right",children:t.jsx(iv,{value:K,onClick:()=>ae(le[fe],K),bold:!0})},`total-${le[fe]}`)),t.jsx("td",{className:"px-3 py-2 text-right font-semibold text-gray-900 dark:text-white",children:Ne})]})})]})]})]})]}):null},iv=({value:e,onClick:r,bold:a=!1})=>e<=0?t.jsx("span",{className:"text-gray-400",children:"0"}):t.jsx("button",{type:"button",onClick:r,className:`${a?"font-semibold":"font-medium"} text-gray-900 dark:text-white hover:text-indigo-600 dark:hover:text-indigo-300 hover:underline`,children:e.toLocaleString()}),zC=({data:e})=>{var C;const[r,a]=E.useState(null),n=E.useMemo(()=>((e==null?void 0:e.rates)||[]).filter(O=>!jC(O.type)),[e]),i=E.useCallback(()=>a(null),[]);if(!n.length)return t.jsx("div",{className:"h-44 flex items-center justify-center text-gray-400 text-sm",children:"No completion data available"});const c=160,u=44,g=18,y=36,x=16,k=y+n.length*(u+g)+x,N=[0,25,50,75,100];return t.jsxs("div",{className:"relative w-full overflow-x-auto",onMouseLeave:i,children:[r&&t.jsxs("div",{className:"fixed z-[9999] pointer-events-none rounded-lg bg-gray-900 text-white px-3 py-2 text-xs shadow-lg max-w-[220px]",style:{left:r.x,top:r.y-8,transform:"translate(-50%, -100%)"},children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded-sm shrink-0",style:{backgroundColor:r.color}}),t.jsx("span",{className:"font-semibold truncate",children:r.rate.type})]}),t.jsxs("div",{className:"text-emerald-300 font-semibold",children:[r.percentage.toFixed(1),"% Completed"]}),t.jsxs("div",{className:"text-gray-300 mt-1",children:[(C=r.rate.completedCombined)!=null?C:(r.rate.completed||0)+(r.rate.closed||0)," completed ·"," ",r.rate.inProgress||0," prog · ",r.rate.rejected||0," rej"]}),t.jsxs("div",{className:"text-gray-400",children:[r.rate.total||0," total"]})]}),t.jsxs("svg",{width:k,height:c+56,className:"min-w-full",children:[N.map(O=>{const D=c-O/100*c+8;return t.jsxs("g",{children:[t.jsx("line",{x1:y,y1:D,x2:k-x,y2:D,stroke:"#E5E7EB",strokeWidth:"1"}),t.jsxs("text",{x:y-8,y:D+4,textAnchor:"end",className:"fill-gray-400 text-[10px]",children:[O,"%"]})]},O)}),n.map((O,D)=>{const A=Sp(O),I=Math.max(2,A/100*c),z=y+D*(u+g),U=c-I+8,B=Xh[D%Xh.length],V=O.type.length>12?`${O.type.slice(0,10)}…`:O.type;return t.jsxs("g",{children:[t.jsx("rect",{x:z,y:U,width:u,height:I,rx:4,fill:B,className:"hover:opacity-85 transition-opacity cursor-default",onMouseEnter:Z=>a({x:Z.clientX,y:Z.clientY,rate:O,color:B,percentage:A}),onMouseMove:Z=>a({x:Z.clientX,y:Z.clientY,rate:O,color:B,percentage:A}),onMouseLeave:i}),t.jsx("text",{x:z+u/2,y:c+24,textAnchor:"middle",className:"fill-gray-500 text-[10px]",children:V})]},O.type)})]}),t.jsx("div",{className:"flex flex-wrap gap-3 mt-1 px-1",children:n.slice(0,6).map((O,D)=>t.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-gray-500",children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded-sm shrink-0",style:{backgroundColor:Xh[D%Xh.length]}}),t.jsx("span",{className:"truncate max-w-[100px]",children:O.type})]},O.type))})]})},HC=({loading:e=!1,totalWorkOrders:r,completedWorkOrders:a,inProgressWorkOrders:n,rejectedWorkOrders:i,byTypeChartData:c,onOpenReport:u})=>{const{t:g}=oa(),y=E.useMemo(()=>r<=0?"0.00":(a/r*100).toFixed(2),[a,r]);return t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow hover:shadow-md transition-all px-5 py-4 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[t.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[t.jsx("div",{className:"w-11 h-11 rounded-full bg-emerald-50 dark:bg-emerald-900/30 flex items-center justify-center shrink-0",children:t.jsx(Ca,{className:"text-emerald-600 dark:text-emerald-300 text-lg"})}),t.jsxs("div",{children:[t.jsxs("div",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:[y,"%"]}),t.jsx("div",{className:"text-sm font-medium text-emerald-700 dark:text-emerald-300",children:g("dashboard.overallCompletionRate",{defaultValue:"Overall Completion Rate"})})]})]}),t.jsx("button",{type:"button",onClick:u,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg text-emerald-600 dark:text-emerald-300 shrink-0",title:g("dashboard.viewCompletionDetails",{defaultValue:"View completion details"}),children:t.jsx(qd,{className:"w-4 h-4"})})]}),e?t.jsx("div",{className:"h-44 flex items-center justify-center",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-emerald-600"})}):t.jsx(zC,{data:c}),t.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 mt-3 pt-3 border-t border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"rounded-lg bg-indigo-50 dark:bg-indigo-900/20 px-3 py-2 text-center",children:[t.jsx("div",{className:"text-lg font-semibold text-indigo-700 dark:text-indigo-300",children:r}),t.jsx("div",{className:"text-[10px] uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Total"})]}),t.jsxs("div",{className:"rounded-lg bg-blue-50 dark:bg-blue-900/20 px-3 py-2 text-center",children:[t.jsx("div",{className:"text-lg font-semibold text-blue-700 dark:text-blue-300",children:n}),t.jsx("div",{className:"text-[10px] uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"In Progress"})]}),t.jsxs("div",{className:"rounded-lg bg-red-50 dark:bg-red-900/20 px-3 py-2 text-center",children:[t.jsx("div",{className:"text-lg font-semibold text-red-700 dark:text-red-300",children:i}),t.jsx("div",{className:"text-[10px] uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Rejected"})]}),t.jsxs("div",{className:"rounded-lg bg-emerald-50 dark:bg-emerald-900/20 px-3 py-2 text-center",children:[t.jsx("div",{className:"text-lg font-semibold text-emerald-700 dark:text-emerald-300",children:a}),t.jsx("div",{className:"text-[10px] uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Completed"})]})]})]})},VC=({labels:e,datasets:r})=>{const[a,n]=E.useState(null),i=E.useMemo(()=>e.map((u,g)=>r.reduce((y,x)=>y+(Number(x.values[g])||0),0)),[e,r]),c=E.useMemo(()=>Math.max(...i,1),[i]);return!e.length||!r.length?t.jsx("div",{className:"h-48 flex items-center justify-center text-gray-400 text-xs",children:"No chart data available"}):t.jsxs("div",{className:"relative",onMouseLeave:()=>n(null),children:[a&&t.jsx("div",{className:"fixed z-[90] pointer-events-none rounded-md bg-gray-900 text-white text-xs px-2 py-1 shadow-lg",style:{left:a.x+12,top:a.y+12},children:a.text}),t.jsx("div",{className:"max-h-72 overflow-y-auto pr-1 space-y-2",children:e.map((u,g)=>{const y=i[g]||0;return t.jsxs("div",{className:"grid grid-cols-[120px_1fr_36px] gap-2 items-center",children:[t.jsx("div",{className:"text-xs text-gray-700 dark:text-gray-300 truncate",title:u,children:u}),t.jsx("div",{className:"h-7 bg-gray-100 dark:bg-gray-700/60 rounded-md overflow-hidden flex",children:r.map(x=>{const k=Number(x.values[g])||0;if(k<=0)return null;const N=k/c*100;return t.jsx("div",{className:"h-full transition-opacity hover:opacity-85 cursor-pointer",style:{width:`${N}%`,backgroundColor:x.color,minWidth:k>0?"4px":0},onMouseEnter:C=>n({x:C.clientX,y:C.clientY,text:`${u}: ${x.name.replace("_"," ")} = ${k}`}),onMouseMove:C=>n({x:C.clientX,y:C.clientY,text:`${u}: ${x.name.replace("_"," ")} = ${k}`})},`${x.name}-${g}`)})}),t.jsx("div",{className:"text-xs font-semibold text-gray-700 dark:text-gray-200 text-right",children:y})]},`${u}-${g}`)})}),t.jsx("div",{className:"flex flex-wrap items-center gap-3 mt-3 pt-2 border-t border-gray-200 dark:border-gray-700",children:r.map(u=>t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded-sm",style:{backgroundColor:u.color}}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400 capitalize",children:u.name.replace("_"," ")})]},u.name))})]})},WC=({title:e,data:r,loading:a=!1,onOpenReport:n})=>{const{t:i}=oa(),[c,u]=E.useState(!1),g=E.useRef(null);E.useEffect(()=>{const x=k=>{g.current&&!g.current.contains(k.target)&&u(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[]);const y=r?i("dashboard.techniciansWorkedSubtitle",{completed:r.totals.completed,inProgress:r.totals.in_progress,open:r.totals.open,defaultValue:`${r.totals.completed} done • ${r.totals.in_progress} wip • ${r.totals.open} open`}):i("dashboard.techniciansWorkedEmpty",{defaultValue:"No technician data"});return t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow hover:shadow-md transition-all p-3 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-white truncate",children:e}),t.jsx("button",{type:"button",onClick:n,className:"p-1.5 rounded-lg bg-purple-50 dark:bg-purple-900/30 text-purple-600 dark:text-purple-300 hover:bg-purple-100 dark:hover:bg-purple-900/50 transition-colors",title:i("dashboard.viewFullReport",{defaultValue:"View Full Report"}),children:t.jsx(lC,{className:"w-3.5 h-3.5"})})]}),t.jsx("p",{className:"text-[11px] text-gray-500 dark:text-gray-400 mt-0.5",children:y})]}),t.jsxs("div",{className:"relative",ref:g,children:[t.jsx("button",{type:"button",onClick:()=>u(x=>!x),className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg","aria-label":"Chart menu",children:t.jsx("svg",{className:"w-4 h-4 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})})}),c&&t.jsx("div",{className:"absolute right-0 mt-1 w-44 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-20 py-1",children:t.jsx("button",{type:"button",className:"w-full text-left px-3 py-2 text-xs text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700",onClick:()=>{u(!1),n()},children:i("dashboard.viewFullReport",{defaultValue:"View Full Report"})})})]})]}),a?t.jsx("div",{className:"h-48 flex items-center justify-center",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-purple-600"})}):!r||!r.datasets.length?t.jsx("div",{className:"h-48 flex items-center justify-center text-gray-400 text-xs",children:i("dashboard.noChartData",{defaultValue:"No chart data available"})}):t.jsx(VC,{labels:r.labels,datasets:r.datasets})]})},GC=({labels:e,datasets:r,valueLabel:a=""})=>{const n=r[0],i=(n==null?void 0:n.values)||[],c=E.useMemo(()=>Math.max(...i.map(g=>Number(g)||0),1),[i]);if(!e.length||!n)return t.jsx("div",{className:"h-48 flex items-center justify-center text-gray-400 text-xs",children:"No chart data available"});const u=g=>{const y=Math.round(g*100)/100;return a?`${y} ${a}`:String(y)};return t.jsx("div",{className:"max-h-72 overflow-y-auto pr-1 space-y-2",children:e.map((g,y)=>{const x=Number(i[y])||0,k=x/c*100;return t.jsxs("div",{className:"grid grid-cols-[7rem_1fr_auto] gap-2 items-center",children:[t.jsx("div",{className:"text-xs text-gray-700 dark:text-gray-300 truncate text-right",title:g,children:g}),t.jsx("div",{className:"h-7 bg-gray-100 dark:bg-gray-700/60 rounded-md overflow-hidden",children:t.jsx("div",{className:"h-full rounded-md bg-gradient-to-r from-indigo-500 to-purple-500 transition-opacity",style:{width:`${k}%`,minWidth:x>0?"4px":0}})}),t.jsx("div",{className:"text-xs font-semibold text-gray-700 dark:text-gray-200 whitespace-nowrap",children:u(x)})]},`${g}-${y}`)})})},$C=({title:e,data:r,loading:a=!1,onOpenReport:n})=>{var k;const{t:i}=oa(),[c,u]=E.useState(!1),g=E.useRef(null);E.useEffect(()=>{const N=C=>{g.current&&!g.current.contains(C.target)&&u(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const y=(k=r==null?void 0:r.totalHours)!=null?k:0,x=r?i("dashboard.technicianHoursSubtitle",{total:Math.round(y*100)/100,defaultValue:`Total: ${Math.round(y*100)/100} hrs`}):i("dashboard.technicianHoursEmpty",{defaultValue:"No technician hours data"});return t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow hover:shadow-md transition-all p-3 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[t.jsx("div",{className:"min-w-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:n,className:"p-1.5 rounded-full bg-indigo-50 dark:bg-indigo-900/30 text-indigo-600 dark:text-indigo-300 hover:bg-indigo-100 dark:hover:bg-indigo-900/50 transition-colors shrink-0",title:i("dashboard.viewFullReport",{defaultValue:"View Full Report"}),children:t.jsx(pC,{className:"w-3.5 h-3.5"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-white truncate",children:e}),t.jsx("p",{className:"text-[11px] text-indigo-600 dark:text-indigo-300 mt-0.5",children:x})]})]})}),t.jsxs("div",{className:"relative",ref:g,children:[t.jsx("button",{type:"button",onClick:()=>u(N=>!N),className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg","aria-label":"Chart menu",children:t.jsx("svg",{className:"w-4 h-4 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})})}),c&&t.jsx("div",{className:"absolute right-0 mt-1 w-44 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-20 py-1",children:t.jsx("button",{type:"button",className:"w-full text-left px-3 py-2 text-xs text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700",onClick:()=>{u(!1),n()},children:i("dashboard.viewFullReport",{defaultValue:"View Full Report"})})})]})]}),a?t.jsxs("div",{className:"h-48 flex flex-col items-center justify-center gap-2",children:[t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-600"}),t.jsx("span",{className:"text-xs text-gray-500",children:i("dashboard.loadingTechnicianHours",{defaultValue:"Loading technician hours…"})})]}):!r||!r.datasets.length?t.jsx("div",{className:"h-48 flex items-center justify-center text-gray-400 text-xs",children:i("dashboard.noChartData",{defaultValue:"No chart data available"})}):t.jsx(GC,{labels:r.labels,datasets:r.datasets,valueLabel:"hrs"})]})};var Cf={};Cf.version="0.18.5";var Bw=1252,XC=[874,932,936,949,950,1250,1251,1252,1253,1254,1255,1256,1257,1258,1e4],Uw=function(e){XC.indexOf(e)!=-1&&(Bw=e)};function YC(){Uw(1252)}var mu=function(e){Uw(e)};function ZC(){mu(1200),YC()}var Zh=function(r){return String.fromCharCode(r)},ov=function(r){return String.fromCharCode(r)},Ef,zl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function gu(e){for(var r="",a=0,n=0,i=0,c=0,u=0,g=0,y=0,x=0;x<e.length;)a=e.charCodeAt(x++),c=a>>2,n=e.charCodeAt(x++),u=(a&3)<<4|n>>4,i=e.charCodeAt(x++),g=(n&15)<<2|i>>6,y=i&63,isNaN(n)?g=y=64:isNaN(i)&&(y=64),r+=zl.charAt(c)+zl.charAt(u)+zl.charAt(g)+zl.charAt(y);return r}function il(e){var r="",a=0,n=0,i=0,c=0,u=0,g=0,y=0;e=e.replace(/[^\w\+\/\=]/g,"");for(var x=0;x<e.length;)c=zl.indexOf(e.charAt(x++)),u=zl.indexOf(e.charAt(x++)),a=c<<2|u>>4,r+=String.fromCharCode(a),g=zl.indexOf(e.charAt(x++)),n=(u&15)<<4|g>>2,g!==64&&(r+=String.fromCharCode(n)),y=zl.indexOf(e.charAt(x++)),i=(g&3)<<6|y,y!==64&&(r+=String.fromCharCode(i));return r}var Na=(function(){return typeof Buffer!="undefined"&&typeof process!="undefined"&&typeof process.versions!="undefined"&&!!process.versions.node})(),dl=(function(){if(typeof Buffer!="undefined"){var e=!Buffer.from;if(!e)try{Buffer.from("foo","utf8")}catch(r){e=!0}return e?function(r,a){return a?new Buffer(r,a):new Buffer(r)}:Buffer.from.bind(Buffer)}return function(){}})();function Tc(e){return Na?Buffer.alloc?Buffer.alloc(e):new Buffer(e):typeof Uint8Array!="undefined"?new Uint8Array(e):new Array(e)}function lv(e){return Na?Buffer.allocUnsafe?Buffer.allocUnsafe(e):new Buffer(e):typeof Uint8Array!="undefined"?new Uint8Array(e):new Array(e)}var Qi=function(r){return Na?dl(r,"binary"):r.split("").map(function(a){return a.charCodeAt(0)&255})};function tm(e){if(typeof ArrayBuffer=="undefined")return Qi(e);for(var r=new ArrayBuffer(e.length),a=new Uint8Array(r),n=0;n!=e.length;++n)a[n]=e.charCodeAt(n)&255;return r}function ju(e){if(Array.isArray(e))return e.map(function(n){return String.fromCharCode(n)}).join("");for(var r=[],a=0;a<e.length;++a)r[a]=String.fromCharCode(e[a]);return r.join("")}function qC(e){if(typeof Uint8Array=="undefined")throw new Error("Unsupported");return new Uint8Array(e)}var is=Na?function(e){return Buffer.concat(e.map(function(r){return Buffer.isBuffer(r)?r:dl(r)}))}:function(e){if(typeof Uint8Array!="undefined"){var r=0,a=0;for(r=0;r<e.length;++r)a+=e[r].length;var n=new Uint8Array(a),i=0;for(r=0,a=0;r<e.length;a+=i,++r)if(i=e[r].length,e[r]instanceof Uint8Array)n.set(e[r],a);else{if(typeof e[r]=="string")throw"wtf";n.set(new Uint8Array(e[r]),a)}return n}return[].concat.apply([],e.map(function(c){return Array.isArray(c)?c:[].slice.call(c)}))};function KC(e){for(var r=[],a=0,n=e.length+250,i=Tc(e.length+255),c=0;c<e.length;++c){var u=e.charCodeAt(c);if(u<128)i[a++]=u;else if(u<2048)i[a++]=192|u>>6&31,i[a++]=128|u&63;else if(u>=55296&&u<57344){u=(u&1023)+64;var g=e.charCodeAt(++c)&1023;i[a++]=240|u>>8&7,i[a++]=128|u>>2&63,i[a++]=128|g>>6&15|(u&3)<<4,i[a++]=128|g&63}else i[a++]=224|u>>12&15,i[a++]=128|u>>6&63,i[a++]=128|u&63;a>n&&(r.push(i.slice(0,a)),a=0,i=Tc(65535),n=65530)}return r.push(i.slice(0,a)),is(r)}var nu=/\u0000/g,qh=/[\u0001-\u0006]/g;function Bd(e){for(var r="",a=e.length-1;a>=0;)r+=e.charAt(a--);return r}function eo(e,r){var a=""+e;return a.length>=r?a:fn("0",r-a.length)+a}function Tp(e,r){var a=""+e;return a.length>=r?a:fn(" ",r-a.length)+a}function jf(e,r){var a=""+e;return a.length>=r?a:a+fn(" ",r-a.length)}function JC(e,r){var a=""+Math.round(e);return a.length>=r?a:fn("0",r-a.length)+a}function QC(e,r){var a=""+e;return a.length>=r?a:fn("0",r-a.length)+a}var cv=Math.pow(2,32);function vd(e,r){if(e>cv||e<-cv)return JC(e,r);var a=Math.round(e);return QC(a,r)}function Tf(e,r){return r=r||0,e.length>=7+r&&(e.charCodeAt(r)|32)===103&&(e.charCodeAt(r+1)|32)===101&&(e.charCodeAt(r+2)|32)===110&&(e.charCodeAt(r+3)|32)===101&&(e.charCodeAt(r+4)|32)===114&&(e.charCodeAt(r+5)|32)===97&&(e.charCodeAt(r+6)|32)===108}var dv=[["Sun","Sunday"],["Mon","Monday"],["Tue","Tuesday"],["Wed","Wednesday"],["Thu","Thursday"],["Fri","Friday"],["Sat","Saturday"]],Sx=[["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 eE(e){return e||(e={}),e[0]="General",e[1]="0",e[2]="0.00",e[3]="#,##0",e[4]="#,##0.00",e[9]="0%",e[10]="0.00%",e[11]="0.00E+00",e[12]="# ?/?",e[13]="# ??/??",e[14]="m/d/yy",e[15]="d-mmm-yy",e[16]="d-mmm",e[17]="mmm-yy",e[18]="h:mm AM/PM",e[19]="h:mm:ss AM/PM",e[20]="h:mm",e[21]="h:mm:ss",e[22]="m/d/yy h:mm",e[37]="#,##0 ;(#,##0)",e[38]="#,##0 ;[Red](#,##0)",e[39]="#,##0.00;(#,##0.00)",e[40]="#,##0.00;[Red](#,##0.00)",e[45]="mm:ss",e[46]="[h]:mm:ss",e[47]="mmss.0",e[48]="##0.0E+0",e[49]="@",e[56]='"上午/下午 "hh"時"mm"分"ss"秒 "',e}var mn={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"秒 "'},uv={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},tE={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 Af(e,r,a){for(var n=e<0?-1:1,i=e*n,c=0,u=1,g=0,y=1,x=0,k=0,N=Math.floor(i);x<r&&(N=Math.floor(i),g=N*u+c,k=N*x+y,!(i-N<5e-8));)i=1/(i-N),c=u,u=g,y=x,x=k;if(k>r&&(x>r?(k=y,g=c):(k=x,g=u)),!a)return[0,n*g,k];var C=Math.floor(n*g/k);return[C,n*g-C*k,k]}function Kh(e,r,a){if(e>2958465||e<0)return null;var n=e|0,i=Math.floor(86400*(e-n)),c=0,u=[],g={D:n,T:i,u:86400*(e-n)-i,y:0,m:0,d:0,H:0,M:0,S:0,q:0};if(Math.abs(g.u)<1e-6&&(g.u=0),r&&r.date1904&&(n+=1462),g.u>.9999&&(g.u=0,++i==86400&&(g.T=i=0,++n,++g.D)),n===60)u=a?[1317,10,29]:[1900,2,29],c=3;else if(n===0)u=a?[1317,8,29]:[1900,1,0],c=6;else{n>60&&--n;var y=new Date(1900,0,1);y.setDate(y.getDate()+n-1),u=[y.getFullYear(),y.getMonth()+1,y.getDate()],c=y.getDay(),n<60&&(c=(c+6)%7),a&&(c=lE(y,u))}return g.y=u[0],g.m=u[1],g.d=u[2],g.S=i%60,i=Math.floor(i/60),g.M=i%60,i=Math.floor(i/60),g.H=i,g.q=c,g}var zw=new Date(1899,11,31,0,0,0),rE=zw.getTime(),aE=new Date(1900,2,1,0,0,0);function Hw(e,r){var a=e.getTime();return r?a-=1461*24*60*60*1e3:e>=aE&&(a+=1440*60*1e3),(a-(rE+(e.getTimezoneOffset()-zw.getTimezoneOffset())*6e4))/(1440*60*1e3)}function Ap(e){return e.indexOf(".")==-1?e:e.replace(/(?:\.0*|(\.\d*[1-9])0+)$/,"$1")}function nE(e){return e.indexOf("E")==-1?e:e.replace(/(?:\.0*|(\.\d*[1-9])0+)[Ee]/,"$1E").replace(/(E[+-])(\d)$/,"$10$2")}function sE(e){var r=e<0?12:11,a=Ap(e.toFixed(12));return a.length<=r||(a=e.toPrecision(10),a.length<=r)?a:e.toExponential(5)}function iE(e){var r=Ap(e.toFixed(11));return r.length>(e<0?12:11)||r==="0"||r==="-0"?e.toPrecision(6):r}function oE(e){var r=Math.floor(Math.log(Math.abs(e))*Math.LOG10E),a;return r>=-4&&r<=-1?a=e.toPrecision(10+r):Math.abs(r)<=9?a=sE(e):r===10?a=e.toFixed(10).substr(0,12):a=iE(e),Ap(nE(a.toUpperCase()))}function Qx(e,r){switch(typeof e){case"string":return e;case"boolean":return e?"TRUE":"FALSE";case"number":return(e|0)===e?e.toString(10):oE(e);case"undefined":return"";case"object":if(e==null)return"";if(e instanceof Date)return Gl(14,Hw(e,r&&r.date1904),r)}throw new Error("unsupported value in General format: "+e)}function lE(e,r){r[0]-=581;var a=e.getDay();return e<60&&(a=(a+6)%7),a}function cE(e,r,a,n){var i="",c=0,u=0,g=a.y,y,x=0;switch(e){case 98:g=a.y+543;case 121:switch(r.length){case 1:case 2:y=g%100,x=2;break;default:y=g%1e4,x=4;break}break;case 109:switch(r.length){case 1:case 2:y=a.m,x=r.length;break;case 3:return Sx[a.m-1][1];case 5:return Sx[a.m-1][0];default:return Sx[a.m-1][2]}break;case 100:switch(r.length){case 1:case 2:y=a.d,x=r.length;break;case 3:return dv[a.q][0];default:return dv[a.q][1]}break;case 104:switch(r.length){case 1:case 2:y=1+(a.H+11)%12,x=r.length;break;default:throw"bad hour format: "+r}break;case 72:switch(r.length){case 1:case 2:y=a.H,x=r.length;break;default:throw"bad hour format: "+r}break;case 77:switch(r.length){case 1:case 2:y=a.M,x=r.length;break;default:throw"bad minute format: "+r}break;case 115:if(r!="s"&&r!="ss"&&r!=".0"&&r!=".00"&&r!=".000")throw"bad second format: "+r;return a.u===0&&(r=="s"||r=="ss")?eo(a.S,r.length):(n>=2?u=n===3?1e3:100:u=n===1?10:1,c=Math.round(u*(a.S+a.u)),c>=60*u&&(c=0),r==="s"?c===0?"0":""+c/u:(i=eo(c,2+n),r==="ss"?i.substr(0,2):"."+i.substr(2,r.length-1)));case 90:switch(r){case"[h]":case"[hh]":y=a.D*24+a.H;break;case"[m]":case"[mm]":y=(a.D*24+a.H)*60+a.M;break;case"[s]":case"[ss]":y=((a.D*24+a.H)*60+a.M)*60+Math.round(a.S+a.u);break;default:throw"bad abstime format: "+r}x=r.length===3?1:2;break;case 101:y=g,x=1;break}var k=x>0?eo(y,x):"";return k}function Hl(e){var r=3;if(e.length<=r)return e;for(var a=e.length%r,n=e.substr(0,a);a!=e.length;a+=r)n+=(n.length>0?",":"")+e.substr(a,r);return n}var Vw=/%/g;function dE(e,r,a){var n=r.replace(Vw,""),i=r.length-n.length;return Qo(e,n,a*Math.pow(10,2*i))+fn("%",i)}function uE(e,r,a){for(var n=r.length-1;r.charCodeAt(n-1)===44;)--n;return Qo(e,r.substr(0,n),a/Math.pow(10,3*(r.length-n)))}function Ww(e,r){var a,n=e.indexOf("E")-e.indexOf(".")-1;if(e.match(/^#+0.0E\+0$/)){if(r==0)return"0.0E+0";if(r<0)return"-"+Ww(e,-r);var i=e.indexOf(".");i===-1&&(i=e.indexOf("E"));var c=Math.floor(Math.log(r)*Math.LOG10E)%i;if(c<0&&(c+=i),a=(r/Math.pow(10,c)).toPrecision(n+1+(i+c)%i),a.indexOf("e")===-1){var u=Math.floor(Math.log(r)*Math.LOG10E);for(a.indexOf(".")===-1?a=a.charAt(0)+"."+a.substr(1)+"E+"+(u-a.length+c):a+="E+"+(u-c);a.substr(0,2)==="0.";)a=a.charAt(0)+a.substr(2,i)+"."+a.substr(2+i),a=a.replace(/^0+([1-9])/,"$1").replace(/^0+\./,"0.");a=a.replace(/\+-/,"-")}a=a.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/,function(g,y,x,k){return y+x+k.substr(0,(i+c)%i)+"."+k.substr(c)+"E"})}else a=r.toExponential(n);return e.match(/E\+00$/)&&a.match(/e[+-]\d$/)&&(a=a.substr(0,a.length-1)+"0"+a.charAt(a.length-1)),e.match(/E\-/)&&a.match(/e\+/)&&(a=a.replace(/e\+/,"e")),a.replace("e","E")}var Gw=/# (\?+)( ?)\/( ?)(\d+)/;function hE(e,r,a){var n=parseInt(e[4],10),i=Math.round(r*n),c=Math.floor(i/n),u=i-c*n,g=n;return a+(c===0?"":""+c)+" "+(u===0?fn(" ",e[1].length+1+e[4].length):Tp(u,e[1].length)+e[2]+"/"+e[3]+eo(g,e[4].length))}function fE(e,r,a){return a+(r===0?"":""+r)+fn(" ",e[1].length+2+e[4].length)}var $w=/^#*0*\.([0#]+)/,Xw=/\).*[0#]/,Yw=/\(###\) ###\\?-####/;function js(e){for(var r="",a,n=0;n!=e.length;++n)switch(a=e.charCodeAt(n)){case 35:break;case 63:r+=" ";break;case 48:r+="0";break;default:r+=String.fromCharCode(a)}return r}function hv(e,r){var a=Math.pow(10,r);return""+Math.round(e*a)/a}function fv(e,r){var a=e-Math.floor(e),n=Math.pow(10,r);return r<(""+Math.round(a*n)).length?0:Math.round(a*n)}function mE(e,r){return r<(""+Math.round((e-Math.floor(e))*Math.pow(10,r))).length?1:0}function gE(e){return e<2147483647&&e>-2147483648?""+(e>=0?e|0:e-1|0):""+Math.floor(e)}function Ai(e,r,a){if(e.charCodeAt(0)===40&&!r.match(Xw)){var n=r.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");return a>=0?Ai("n",n,a):"("+Ai("n",n,-a)+")"}if(r.charCodeAt(r.length-1)===44)return uE(e,r,a);if(r.indexOf("%")!==-1)return dE(e,r,a);if(r.indexOf("E")!==-1)return Ww(r,a);if(r.charCodeAt(0)===36)return"$"+Ai(e,r.substr(r.charAt(1)==" "?2:1),a);var i,c,u,g,y=Math.abs(a),x=a<0?"-":"";if(r.match(/^00+$/))return x+vd(y,r.length);if(r.match(/^[#?]+$/))return i=vd(a,0),i==="0"&&(i=""),i.length>r.length?i:js(r.substr(0,r.length-i.length))+i;if(c=r.match(Gw))return hE(c,y,x);if(r.match(/^#+0+$/))return x+vd(y,r.length-r.indexOf("0"));if(c=r.match($w))return i=hv(a,c[1].length).replace(/^([^\.]+)$/,"$1."+js(c[1])).replace(/\.$/,"."+js(c[1])).replace(/\.(\d*)$/,function(D,A){return"."+A+fn("0",js(c[1]).length-A.length)}),r.indexOf("0.")!==-1?i:i.replace(/^0\./,".");if(r=r.replace(/^#+([0.])/,"$1"),c=r.match(/^(0*)\.(#*)$/))return x+hv(y,c[2].length).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,c[1].length?"0.":".");if(c=r.match(/^#{1,3},##0(\.?)$/))return x+Hl(vd(y,0));if(c=r.match(/^#,##0\.([#0]*0)$/))return a<0?"-"+Ai(e,r,-a):Hl(""+(Math.floor(a)+mE(a,c[1].length)))+"."+eo(fv(a,c[1].length),c[1].length);if(c=r.match(/^#,#*,#0/))return Ai(e,r.replace(/^#,#*,/,""),a);if(c=r.match(/^([0#]+)(\\?-([0#]+))+$/))return i=Bd(Ai(e,r.replace(/[\\-]/g,""),a)),u=0,Bd(Bd(r.replace(/\\/g,"")).replace(/[0#]/g,function(D){return u<i.length?i.charAt(u++):D==="0"?"0":""}));if(r.match(Yw))return i=Ai(e,"##########",a),"("+i.substr(0,3)+") "+i.substr(3,3)+"-"+i.substr(6);var k="";if(c=r.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))return u=Math.min(c[4].length,7),g=Af(y,Math.pow(10,u)-1,!1),i=""+x,k=Qo("n",c[1],g[1]),k.charAt(k.length-1)==" "&&(k=k.substr(0,k.length-1)+"0"),i+=k+c[2]+"/"+c[3],k=jf(g[2],u),k.length<c[4].length&&(k=js(c[4].substr(c[4].length-k.length))+k),i+=k,i;if(c=r.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))return u=Math.min(Math.max(c[1].length,c[4].length),7),g=Af(y,Math.pow(10,u)-1,!0),x+(g[0]||(g[1]?"":"0"))+" "+(g[1]?Tp(g[1],u)+c[2]+"/"+c[3]+jf(g[2],u):fn(" ",2*u+1+c[2].length+c[3].length));if(c=r.match(/^[#0?]+$/))return i=vd(a,0),r.length<=i.length?i:js(r.substr(0,r.length-i.length))+i;if(c=r.match(/^([#0?]+)\.([#0]+)$/)){i=""+a.toFixed(Math.min(c[2].length,10)).replace(/([^0])0+$/,"$1"),u=i.indexOf(".");var N=r.indexOf(".")-u,C=r.length-i.length-N;return js(r.substr(0,N)+i+r.substr(r.length-C))}if(c=r.match(/^00,000\.([#0]*0)$/))return u=fv(a,c[1].length),a<0?"-"+Ai(e,r,-a):Hl(gE(a)).replace(/^\d,\d{3}$/,"0$&").replace(/^\d*$/,function(D){return"00,"+(D.length<3?eo(0,3-D.length):"")+D})+"."+eo(u,c[1].length);switch(r){case"###,##0.00":return Ai(e,"#,##0.00",a);case"###,###":case"##,###":case"#,###":var O=Hl(vd(y,0));return O!=="0"?x+O:"";case"###,###.00":return Ai(e,"###,##0.00",a).replace(/^0\./,".");case"#,###.00":return Ai(e,"#,##0.00",a).replace(/^0\./,".")}throw new Error("unsupported format |"+r+"|")}function xE(e,r,a){for(var n=r.length-1;r.charCodeAt(n-1)===44;)--n;return Qo(e,r.substr(0,n),a/Math.pow(10,3*(r.length-n)))}function pE(e,r,a){var n=r.replace(Vw,""),i=r.length-n.length;return Qo(e,n,a*Math.pow(10,2*i))+fn("%",i)}function Zw(e,r){var a,n=e.indexOf("E")-e.indexOf(".")-1;if(e.match(/^#+0.0E\+0$/)){if(r==0)return"0.0E+0";if(r<0)return"-"+Zw(e,-r);var i=e.indexOf(".");i===-1&&(i=e.indexOf("E"));var c=Math.floor(Math.log(r)*Math.LOG10E)%i;if(c<0&&(c+=i),a=(r/Math.pow(10,c)).toPrecision(n+1+(i+c)%i),!a.match(/[Ee]/)){var u=Math.floor(Math.log(r)*Math.LOG10E);a.indexOf(".")===-1?a=a.charAt(0)+"."+a.substr(1)+"E+"+(u-a.length+c):a+="E+"+(u-c),a=a.replace(/\+-/,"-")}a=a.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/,function(g,y,x,k){return y+x+k.substr(0,(i+c)%i)+"."+k.substr(c)+"E"})}else a=r.toExponential(n);return e.match(/E\+00$/)&&a.match(/e[+-]\d$/)&&(a=a.substr(0,a.length-1)+"0"+a.charAt(a.length-1)),e.match(/E\-/)&&a.match(/e\+/)&&(a=a.replace(/e\+/,"e")),a.replace("e","E")}function yo(e,r,a){if(e.charCodeAt(0)===40&&!r.match(Xw)){var n=r.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");return a>=0?yo("n",n,a):"("+yo("n",n,-a)+")"}if(r.charCodeAt(r.length-1)===44)return xE(e,r,a);if(r.indexOf("%")!==-1)return pE(e,r,a);if(r.indexOf("E")!==-1)return Zw(r,a);if(r.charCodeAt(0)===36)return"$"+yo(e,r.substr(r.charAt(1)==" "?2:1),a);var i,c,u,g,y=Math.abs(a),x=a<0?"-":"";if(r.match(/^00+$/))return x+eo(y,r.length);if(r.match(/^[#?]+$/))return i=""+a,a===0&&(i=""),i.length>r.length?i:js(r.substr(0,r.length-i.length))+i;if(c=r.match(Gw))return fE(c,y,x);if(r.match(/^#+0+$/))return x+eo(y,r.length-r.indexOf("0"));if(c=r.match($w))return i=(""+a).replace(/^([^\.]+)$/,"$1."+js(c[1])).replace(/\.$/,"."+js(c[1])),i=i.replace(/\.(\d*)$/,function(D,A){return"."+A+fn("0",js(c[1]).length-A.length)}),r.indexOf("0.")!==-1?i:i.replace(/^0\./,".");if(r=r.replace(/^#+([0.])/,"$1"),c=r.match(/^(0*)\.(#*)$/))return x+(""+y).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,c[1].length?"0.":".");if(c=r.match(/^#{1,3},##0(\.?)$/))return x+Hl(""+y);if(c=r.match(/^#,##0\.([#0]*0)$/))return a<0?"-"+yo(e,r,-a):Hl(""+a)+"."+fn("0",c[1].length);if(c=r.match(/^#,#*,#0/))return yo(e,r.replace(/^#,#*,/,""),a);if(c=r.match(/^([0#]+)(\\?-([0#]+))+$/))return i=Bd(yo(e,r.replace(/[\\-]/g,""),a)),u=0,Bd(Bd(r.replace(/\\/g,"")).replace(/[0#]/g,function(D){return u<i.length?i.charAt(u++):D==="0"?"0":""}));if(r.match(Yw))return i=yo(e,"##########",a),"("+i.substr(0,3)+") "+i.substr(3,3)+"-"+i.substr(6);var k="";if(c=r.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))return u=Math.min(c[4].length,7),g=Af(y,Math.pow(10,u)-1,!1),i=""+x,k=Qo("n",c[1],g[1]),k.charAt(k.length-1)==" "&&(k=k.substr(0,k.length-1)+"0"),i+=k+c[2]+"/"+c[3],k=jf(g[2],u),k.length<c[4].length&&(k=js(c[4].substr(c[4].length-k.length))+k),i+=k,i;if(c=r.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))return u=Math.min(Math.max(c[1].length,c[4].length),7),g=Af(y,Math.pow(10,u)-1,!0),x+(g[0]||(g[1]?"":"0"))+" "+(g[1]?Tp(g[1],u)+c[2]+"/"+c[3]+jf(g[2],u):fn(" ",2*u+1+c[2].length+c[3].length));if(c=r.match(/^[#0?]+$/))return i=""+a,r.length<=i.length?i:js(r.substr(0,r.length-i.length))+i;if(c=r.match(/^([#0]+)\.([#0]+)$/)){i=""+a.toFixed(Math.min(c[2].length,10)).replace(/([^0])0+$/,"$1"),u=i.indexOf(".");var N=r.indexOf(".")-u,C=r.length-i.length-N;return js(r.substr(0,N)+i+r.substr(r.length-C))}if(c=r.match(/^00,000\.([#0]*0)$/))return a<0?"-"+yo(e,r,-a):Hl(""+a).replace(/^\d,\d{3}$/,"0$&").replace(/^\d*$/,function(D){return"00,"+(D.length<3?eo(0,3-D.length):"")+D})+"."+eo(0,c[1].length);switch(r){case"###,###":case"##,###":case"#,###":var O=Hl(""+y);return O!=="0"?x+O:"";default:if(r.match(/\.[0#?]*$/))return yo(e,r.slice(0,r.lastIndexOf(".")),a)+js(r.slice(r.lastIndexOf(".")))}throw new Error("unsupported format |"+r+"|")}function Qo(e,r,a){return(a|0)===a?yo(e,r,a):Ai(e,r,a)}function yE(e){for(var r=[],a=!1,n=0,i=0;n<e.length;++n)switch(e.charCodeAt(n)){case 34:a=!a;break;case 95:case 42:case 92:++n;break;case 59:r[r.length]=e.substr(i,n-i),i=n+1}if(r[r.length]=e.substr(i),a===!0)throw new Error("Format |"+e+"| unterminated string ");return r}var qw=/\[[HhMmSs\u0E0A\u0E19\u0E17]*\]/;function Kw(e){for(var r=0,a="",n="";r<e.length;)switch(a=e.charAt(r)){case"G":Tf(e,r)&&(r+=6),r++;break;case'"':for(;e.charCodeAt(++r)!==34&&r<e.length;);++r;break;case"\\":r+=2;break;case"_":r+=2;break;case"@":++r;break;case"B":case"b":if(e.charAt(r+1)==="1"||e.charAt(r+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(e.substr(r,3).toUpperCase()==="A/P"||e.substr(r,5).toUpperCase()==="AM/PM"||e.substr(r,5).toUpperCase()==="上午/下午")return!0;++r;break;case"[":for(n=a;e.charAt(r++)!=="]"&&r<e.length;)n+=e.charAt(r);if(n.match(qw))return!0;break;case".":case"0":case"#":for(;r<e.length&&("0#?.,E+-%".indexOf(a=e.charAt(++r))>-1||a=="\\"&&e.charAt(r+1)=="-"&&"0#".indexOf(e.charAt(r+2))>-1););break;case"?":for(;e.charAt(++r)===a;);break;case"*":++r,(e.charAt(r)==" "||e.charAt(r)=="*")&&++r;break;case"(":case")":++r;break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(;r<e.length&&"0123456789".indexOf(e.charAt(++r))>-1;);break;case" ":++r;break;default:++r;break}return!1}function bE(e,r,a,n){for(var i=[],c="",u=0,g="",y="t",x,k,N,C="H";u<e.length;)switch(g=e.charAt(u)){case"G":if(!Tf(e,u))throw new Error("unrecognized character "+g+" in "+e);i[i.length]={t:"G",v:"General"},u+=7;break;case'"':for(c="";(N=e.charCodeAt(++u))!==34&&u<e.length;)c+=String.fromCharCode(N);i[i.length]={t:"t",v:c},++u;break;case"\\":var O=e.charAt(++u),D=O==="("||O===")"?O:"t";i[i.length]={t:D,v:O},++u;break;case"_":i[i.length]={t:"t",v:" "},u+=2;break;case"@":i[i.length]={t:"T",v:r},++u;break;case"B":case"b":if(e.charAt(u+1)==="1"||e.charAt(u+1)==="2"){if(x==null&&(x=Kh(r,a,e.charAt(u+1)==="2"),x==null))return"";i[i.length]={t:"X",v:e.substr(u,2)},y=g,u+=2;break}case"M":case"D":case"Y":case"H":case"S":case"E":g=g.toLowerCase();case"m":case"d":case"y":case"h":case"s":case"e":case"g":if(r<0||x==null&&(x=Kh(r,a),x==null))return"";for(c=g;++u<e.length&&e.charAt(u).toLowerCase()===g;)c+=g;g==="m"&&y.toLowerCase()==="h"&&(g="M"),g==="h"&&(g=C),i[i.length]={t:g,v:c},y=g;break;case"A":case"a":case"上":var A={t:g,v:g};if(x==null&&(x=Kh(r,a)),e.substr(u,3).toUpperCase()==="A/P"?(x!=null&&(A.v=x.H>=12?"P":"A"),A.t="T",C="h",u+=3):e.substr(u,5).toUpperCase()==="AM/PM"?(x!=null&&(A.v=x.H>=12?"PM":"AM"),A.t="T",u+=5,C="h"):e.substr(u,5).toUpperCase()==="上午/下午"?(x!=null&&(A.v=x.H>=12?"下午":"上午"),A.t="T",u+=5,C="h"):(A.t="t",++u),x==null&&A.t==="T")return"";i[i.length]=A,y=g;break;case"[":for(c=g;e.charAt(u++)!=="]"&&u<e.length;)c+=e.charAt(u);if(c.slice(-1)!=="]")throw'unterminated "[" block: |'+c+"|";if(c.match(qw)){if(x==null&&(x=Kh(r,a),x==null))return"";i[i.length]={t:"Z",v:c.toLowerCase()},y=c.charAt(1)}else c.indexOf("$")>-1&&(c=(c.match(/\$([^-\[\]]*)/)||[])[1]||"$",Kw(e)||(i[i.length]={t:"t",v:c}));break;case".":if(x!=null){for(c=g;++u<e.length&&(g=e.charAt(u))==="0";)c+=g;i[i.length]={t:"s",v:c};break}case"0":case"#":for(c=g;++u<e.length&&"0#?.,E+-%".indexOf(g=e.charAt(u))>-1;)c+=g;i[i.length]={t:"n",v:c};break;case"?":for(c=g;e.charAt(++u)===g;)c+=g;i[i.length]={t:g,v:c},y=g;break;case"*":++u,(e.charAt(u)==" "||e.charAt(u)=="*")&&++u;break;case"(":case")":i[i.length]={t:n===1?"t":g,v:g},++u;break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(c=g;u<e.length&&"0123456789".indexOf(e.charAt(++u))>-1;)c+=e.charAt(u);i[i.length]={t:"D",v:c};break;case" ":i[i.length]={t:g,v:g},++u;break;case"$":i[i.length]={t:"t",v:"$"},++u;break;default:if(",$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP".indexOf(g)===-1)throw new Error("unrecognized character "+g+" in "+e);i[i.length]={t:"t",v:g},++u;break}var I=0,z=0,U;for(u=i.length-1,y="t";u>=0;--u)switch(i[u].t){case"h":case"H":i[u].t=C,y="h",I<1&&(I=1);break;case"s":(U=i[u].v.match(/\.0+$/))&&(z=Math.max(z,U[0].length-1)),I<3&&(I=3);case"d":case"y":case"M":case"e":y=i[u].t;break;case"m":y==="s"&&(i[u].t="M",I<2&&(I=2));break;case"X":break;case"Z":I<1&&i[u].v.match(/[Hh]/)&&(I=1),I<2&&i[u].v.match(/[Mm]/)&&(I=2),I<3&&i[u].v.match(/[Ss]/)&&(I=3)}switch(I){case 0:break;case 1:x.u>=.5&&(x.u=0,++x.S),x.S>=60&&(x.S=0,++x.M),x.M>=60&&(x.M=0,++x.H);break;case 2:x.u>=.5&&(x.u=0,++x.S),x.S>=60&&(x.S=0,++x.M);break}var B="",V;for(u=0;u<i.length;++u)switch(i[u].t){case"t":case"T":case" ":case"D":break;case"X":i[u].v="",i[u].t=";";break;case"d":case"m":case"y":case"h":case"H":case"M":case"s":case"e":case"b":case"Z":i[u].v=cE(i[u].t.charCodeAt(0),i[u].v,x,z),i[u].t="t";break;case"n":case"?":for(V=u+1;i[V]!=null&&((g=i[V].t)==="?"||g==="D"||(g===" "||g==="t")&&i[V+1]!=null&&(i[V+1].t==="?"||i[V+1].t==="t"&&i[V+1].v==="/")||i[u].t==="("&&(g===" "||g==="n"||g===")")||g==="t"&&(i[V].v==="/"||i[V].v===" "&&i[V+1]!=null&&i[V+1].t=="?"));)i[u].v+=i[V].v,i[V]={v:"",t:";"},++V;B+=i[u].v,u=V-1;break;case"G":i[u].t="t",i[u].v=Qx(r,a);break}var Z="",W,H;if(B.length>0){B.charCodeAt(0)==40?(W=r<0&&B.charCodeAt(0)===45?-r:r,H=Qo("n",B,W)):(W=r<0&&n>1?-r:r,H=Qo("n",B,W),W<0&&i[0]&&i[0].t=="t"&&(H=H.substr(1),i[0].v="-"+i[0].v)),V=H.length-1;var le=i.length;for(u=0;u<i.length;++u)if(i[u]!=null&&i[u].t!="t"&&i[u].v.indexOf(".")>-1){le=u;break}var Q=i.length;if(le===i.length&&H.indexOf("E")===-1){for(u=i.length-1;u>=0;--u)i[u]==null||"n?".indexOf(i[u].t)===-1||(V>=i[u].v.length-1?(V-=i[u].v.length,i[u].v=H.substr(V+1,i[u].v.length)):V<0?i[u].v="":(i[u].v=H.substr(0,V+1),V=-1),i[u].t="t",Q=u);V>=0&&Q<i.length&&(i[Q].v=H.substr(0,V+1)+i[Q].v)}else if(le!==i.length&&H.indexOf("E")===-1){for(V=H.indexOf(".")-1,u=le;u>=0;--u)if(!(i[u]==null||"n?".indexOf(i[u].t)===-1)){for(k=i[u].v.indexOf(".")>-1&&u===le?i[u].v.indexOf(".")-1:i[u].v.length-1,Z=i[u].v.substr(k+1);k>=0;--k)V>=0&&(i[u].v.charAt(k)==="0"||i[u].v.charAt(k)==="#")&&(Z=H.charAt(V--)+Z);i[u].v=Z,i[u].t="t",Q=u}for(V>=0&&Q<i.length&&(i[Q].v=H.substr(0,V+1)+i[Q].v),V=H.indexOf(".")+1,u=le;u<i.length;++u)if(!(i[u]==null||"n?(".indexOf(i[u].t)===-1&&u!==le)){for(k=i[u].v.indexOf(".")>-1&&u===le?i[u].v.indexOf(".")+1:0,Z=i[u].v.substr(0,k);k<i[u].v.length;++k)V<H.length&&(Z+=H.charAt(V++));i[u].v=Z,i[u].t="t",Q=u}}}for(u=0;u<i.length;++u)i[u]!=null&&"n?".indexOf(i[u].t)>-1&&(W=n>1&&r<0&&u>0&&i[u-1].v==="-"?-r:r,i[u].v=Qo(i[u].t,i[u].v,W),i[u].t="t");var Ne="";for(u=0;u!==i.length;++u)i[u]!=null&&(Ne+=i[u].v);return Ne}var mv=/\[(=|>[=]?|<[>=]?)(-?\d+(?:\.\d*)?)\]/;function gv(e,r){if(r==null)return!1;var a=parseFloat(r[2]);switch(r[1]){case"=":if(e==a)return!0;break;case">":if(e>a)return!0;break;case"<":if(e<a)return!0;break;case"<>":if(e!=a)return!0;break;case">=":if(e>=a)return!0;break;case"<=":if(e<=a)return!0;break}return!1}function vE(e,r){var a=yE(e),n=a.length,i=a[n-1].indexOf("@");if(n<4&&i>-1&&--n,a.length>4)throw new Error("cannot find right format for |"+a.join("|")+"|");if(typeof r!="number")return[4,a.length===4||i>-1?a[a.length-1]:"@"];switch(a.length){case 1:a=i>-1?["General","General","General",a[0]]:[a[0],a[0],a[0],"@"];break;case 2:a=i>-1?[a[0],a[0],a[0],a[1]]:[a[0],a[1],a[0],"@"];break;case 3:a=i>-1?[a[0],a[1],a[0],a[2]]:[a[0],a[1],a[2],"@"];break}var c=r>0?a[0]:r<0?a[1]:a[2];if(a[0].indexOf("[")===-1&&a[1].indexOf("[")===-1)return[n,c];if(a[0].match(/\[[=<>]/)!=null||a[1].match(/\[[=<>]/)!=null){var u=a[0].match(mv),g=a[1].match(mv);return gv(r,u)?[n,a[0]]:gv(r,g)?[n,a[1]]:[n,a[u!=null&&g!=null?2:1]]}return[n,c]}function Gl(e,r,a){a==null&&(a={});var n="";switch(typeof e){case"string":e=="m/d/yy"&&a.dateNF?n=a.dateNF:n=e;break;case"number":e==14&&a.dateNF?n=a.dateNF:n=(a.table!=null?a.table:mn)[e],n==null&&(n=a.table&&a.table[uv[e]]||mn[uv[e]]),n==null&&(n=tE[e]||"General");break}if(Tf(n,0))return Qx(r,a);r instanceof Date&&(r=Hw(r,a.date1904));var i=vE(n,r);if(Tf(i[1]))return Qx(r,a);if(r===!0)r="TRUE";else if(r===!1)r="FALSE";else if(r===""||r==null)return"";return bE(i[1],r,a,i[0])}function Jw(e,r){if(typeof r!="number"){r=+r||-1;for(var a=0;a<392;++a){if(mn[a]==null){r<0&&(r=a);continue}if(mn[a]==e){r=a;break}}r<0&&(r=391)}return mn[r]=e,r}function rm(e){for(var r=0;r!=392;++r)e[r]!==void 0&&Jw(e[r],r)}function am(){mn=eE()}var Qw=/[dD]+|[mM]+|[yYeE]+|[Hh]+|[Ss]+/g;function _E(e){var r=typeof e=="number"?mn[e]:e;return r=r.replace(Qw,"(\\d+)"),new RegExp("^"+r+"$")}function wE(e,r,a){var n=-1,i=-1,c=-1,u=-1,g=-1,y=-1;(r.match(Qw)||[]).forEach(function(N,C){var O=parseInt(a[C+1],10);switch(N.toLowerCase().charAt(0)){case"y":n=O;break;case"d":c=O;break;case"h":u=O;break;case"s":y=O;break;case"m":u>=0?g=O:i=O;break}}),y>=0&&g==-1&&i>=0&&(g=i,i=-1);var x=(""+(n>=0?n:new Date().getFullYear())).slice(-4)+"-"+("00"+(i>=1?i:1)).slice(-2)+"-"+("00"+(c>=1?c:1)).slice(-2);x.length==7&&(x="0"+x),x.length==8&&(x="20"+x);var k=("00"+(u>=0?u:0)).slice(-2)+":"+("00"+(g>=0?g:0)).slice(-2)+":"+("00"+(y>=0?y:0)).slice(-2);return u==-1&&g==-1&&y==-1?x:n==-1&&i==-1&&c==-1?k:x+"T"+k}var kE=(function(){var e={};e.version="1.2.0";function r(){for(var H=0,le=new Array(256),Q=0;Q!=256;++Q)H=Q,H=H&1?-306674912^H>>>1:H>>>1,H=H&1?-306674912^H>>>1:H>>>1,H=H&1?-306674912^H>>>1:H>>>1,H=H&1?-306674912^H>>>1:H>>>1,H=H&1?-306674912^H>>>1:H>>>1,H=H&1?-306674912^H>>>1:H>>>1,H=H&1?-306674912^H>>>1:H>>>1,H=H&1?-306674912^H>>>1:H>>>1,le[Q]=H;return typeof Int32Array!="undefined"?new Int32Array(le):le}var a=r();function n(H){var le=0,Q=0,Ne=0,oe=typeof Int32Array!="undefined"?new Int32Array(4096):new Array(4096);for(Ne=0;Ne!=256;++Ne)oe[Ne]=H[Ne];for(Ne=0;Ne!=256;++Ne)for(Q=H[Ne],le=256+Ne;le<4096;le+=256)Q=oe[le]=Q>>>8^H[Q&255];var se=[];for(Ne=1;Ne!=16;++Ne)se[Ne-1]=typeof Int32Array!="undefined"?oe.subarray(Ne*256,Ne*256+256):oe.slice(Ne*256,Ne*256+256);return se}var i=n(a),c=i[0],u=i[1],g=i[2],y=i[3],x=i[4],k=i[5],N=i[6],C=i[7],O=i[8],D=i[9],A=i[10],I=i[11],z=i[12],U=i[13],B=i[14];function V(H,le){for(var Q=le^-1,Ne=0,oe=H.length;Ne<oe;)Q=Q>>>8^a[(Q^H.charCodeAt(Ne++))&255];return~Q}function Z(H,le){for(var Q=le^-1,Ne=H.length-15,oe=0;oe<Ne;)Q=B[H[oe++]^Q&255]^U[H[oe++]^Q>>8&255]^z[H[oe++]^Q>>16&255]^I[H[oe++]^Q>>>24]^A[H[oe++]]^D[H[oe++]]^O[H[oe++]]^C[H[oe++]]^N[H[oe++]]^k[H[oe++]]^x[H[oe++]]^y[H[oe++]]^g[H[oe++]]^u[H[oe++]]^c[H[oe++]]^a[H[oe++]];for(Ne+=15;oe<Ne;)Q=Q>>>8^a[(Q^H[oe++])&255];return~Q}function W(H,le){for(var Q=le^-1,Ne=0,oe=H.length,se=0,ce=0;Ne<oe;)se=H.charCodeAt(Ne++),se<128?Q=Q>>>8^a[(Q^se)&255]:se<2048?(Q=Q>>>8^a[(Q^(192|se>>6&31))&255],Q=Q>>>8^a[(Q^(128|se&63))&255]):se>=55296&&se<57344?(se=(se&1023)+64,ce=H.charCodeAt(Ne++)&1023,Q=Q>>>8^a[(Q^(240|se>>8&7))&255],Q=Q>>>8^a[(Q^(128|se>>2&63))&255],Q=Q>>>8^a[(Q^(128|ce>>6&15|(se&3)<<4))&255],Q=Q>>>8^a[(Q^(128|ce&63))&255]):(Q=Q>>>8^a[(Q^(224|se>>12&15))&255],Q=Q>>>8^a[(Q^(128|se>>6&63))&255],Q=Q>>>8^a[(Q^(128|se&63))&255]);return~Q}return e.table=a,e.bstr=V,e.buf=Z,e.str=W,e})(),Ua=(function(){var r={};r.version="1.2.1";function a(de,ge){for(var be=de.split("/"),we=ge.split("/"),ke=0,Te=0,Qe=Math.min(be.length,we.length);ke<Qe;++ke){if(Te=be[ke].length-we[ke].length)return Te;if(be[ke]!=we[ke])return be[ke]<we[ke]?-1:1}return be.length-we.length}function n(de){if(de.charAt(de.length-1)=="/")return de.slice(0,-1).indexOf("/")===-1?de:n(de.slice(0,-1));var ge=de.lastIndexOf("/");return ge===-1?de:de.slice(0,ge+1)}function i(de){if(de.charAt(de.length-1)=="/")return i(de.slice(0,-1));var ge=de.lastIndexOf("/");return ge===-1?de:de.slice(ge+1)}function c(de,ge){typeof ge=="string"&&(ge=new Date(ge));var be=ge.getHours();be=be<<6|ge.getMinutes(),be=be<<5|ge.getSeconds()>>>1,de.write_shift(2,be);var we=ge.getFullYear()-1980;we=we<<4|ge.getMonth()+1,we=we<<5|ge.getDate(),de.write_shift(2,we)}function u(de){var ge=de.read_shift(2)&65535,be=de.read_shift(2)&65535,we=new Date,ke=be&31;be>>>=5;var Te=be&15;be>>>=4,we.setMilliseconds(0),we.setFullYear(be+1980),we.setMonth(Te-1),we.setDate(ke);var Qe=ge&31;ge>>>=5;var bt=ge&63;return ge>>>=6,we.setHours(ge),we.setMinutes(bt),we.setSeconds(Qe<<1),we}function g(de){fi(de,0);for(var ge={},be=0;de.l<=de.length-4;){var we=de.read_shift(2),ke=de.read_shift(2),Te=de.l+ke,Qe={};switch(we){case 21589:be=de.read_shift(1),be&1&&(Qe.mtime=de.read_shift(4)),ke>5&&(be&2&&(Qe.atime=de.read_shift(4)),be&4&&(Qe.ctime=de.read_shift(4))),Qe.mtime&&(Qe.mt=new Date(Qe.mtime*1e3));break}de.l=Te,ge[we]=Qe}return ge}var y;function x(){return y||(y={})}function k(de,ge){if(de[0]==80&&de[1]==75)return pt(de,ge);if((de[0]|32)==109&&(de[1]|32)==105)return jr(de,ge);if(de.length<512)throw new Error("CFB file size "+de.length+" < 512");var be=3,we=512,ke=0,Te=0,Qe=0,bt=0,et=0,at=[],nt=de.slice(0,512);fi(nt,0);var Ot=N(nt);switch(be=Ot[0],be){case 3:we=512;break;case 4:we=4096;break;case 0:if(Ot[1]==0)return pt(de,ge);default:throw new Error("Major Version: Expected 3 or 4 saw "+be)}we!==512&&(nt=de.slice(0,we),fi(nt,28));var It=de.slice(0,we);C(nt,be);var Ht=nt.read_shift(4,"i");if(be===3&&Ht!==0)throw new Error("# Directory Sectors: Expected 0 saw "+Ht);nt.l+=4,Qe=nt.read_shift(4,"i"),nt.l+=4,nt.chk("00100000","Mini Stream Cutoff Size: "),bt=nt.read_shift(4,"i"),ke=nt.read_shift(4,"i"),et=nt.read_shift(4,"i"),Te=nt.read_shift(4,"i");for(var zt=-1,Kt=0;Kt<109&&(zt=nt.read_shift(4,"i"),!(zt<0));++Kt)at[Kt]=zt;var fr=O(de,we);I(et,Te,fr,we,at);var Ee=U(fr,Qe,at,we);Ee[Qe].name="!Directory",ke>0&&bt!==ce&&(Ee[bt].name="!MiniFAT"),Ee[at[0]].name="!FAT",Ee.fat_addrs=at,Ee.ssz=we;var wt={},xr=[],qr=[],Za=[];B(Qe,Ee,fr,xr,ke,wt,qr,bt),D(qr,Za,xr),xr.shift();var Tr={FileIndex:qr,FullPaths:Za};return ge&&ge.raw&&(Tr.raw={header:It,sectors:fr}),Tr}function N(de){if(de[de.l]==80&&de[de.l+1]==75)return[0,0];de.chk(Ce,"Header Signature: "),de.l+=16;var ge=de.read_shift(2,"u");return[de.read_shift(2,"u"),ge]}function C(de,ge){var be=9;switch(de.l+=2,be=de.read_shift(2)){case 9:if(ge!=3)throw new Error("Sector Shift: Expected 9 saw "+be);break;case 12:if(ge!=4)throw new Error("Sector Shift: Expected 12 saw "+be);break;default:throw new Error("Sector Shift: Expected 9 or 12 saw "+be)}de.chk("0600","Mini Sector Shift: "),de.chk("000000000000","Reserved: ")}function O(de,ge){for(var be=Math.ceil(de.length/ge)-1,we=[],ke=1;ke<be;++ke)we[ke-1]=de.slice(ke*ge,(ke+1)*ge);return we[be-1]=de.slice(be*ge),we}function D(de,ge,be){for(var we=0,ke=0,Te=0,Qe=0,bt=0,et=be.length,at=[],nt=[];we<et;++we)at[we]=nt[we]=we,ge[we]=be[we];for(;bt<nt.length;++bt)we=nt[bt],ke=de[we].L,Te=de[we].R,Qe=de[we].C,at[we]===we&&(ke!==-1&&at[ke]!==ke&&(at[we]=at[ke]),Te!==-1&&at[Te]!==Te&&(at[we]=at[Te])),Qe!==-1&&(at[Qe]=we),ke!==-1&&we!=at[we]&&(at[ke]=at[we],nt.lastIndexOf(ke)<bt&&nt.push(ke)),Te!==-1&&we!=at[we]&&(at[Te]=at[we],nt.lastIndexOf(Te)<bt&&nt.push(Te));for(we=1;we<et;++we)at[we]===we&&(Te!==-1&&at[Te]!==Te?at[we]=at[Te]:ke!==-1&&at[ke]!==ke&&(at[we]=at[ke]));for(we=1;we<et;++we)if(de[we].type!==0){if(bt=we,bt!=at[bt])do bt=at[bt],ge[we]=ge[bt]+"/"+ge[we];while(bt!==0&&at[bt]!==-1&&bt!=at[bt]);at[we]=-1}for(ge[0]+="/",we=1;we<et;++we)de[we].type!==2&&(ge[we]+="/")}function A(de,ge,be){for(var we=de.start,ke=de.size,Te=[],Qe=we;be&&ke>0&&Qe>=0;)Te.push(ge.slice(Qe*se,Qe*se+se)),ke-=se,Qe=_c(be,Qe*4);return Te.length===0?Nt(0):is(Te).slice(0,de.size)}function I(de,ge,be,we,ke){var Te=ce;if(de===ce){if(ge!==0)throw new Error("DIFAT chain shorter than expected")}else if(de!==-1){var Qe=be[de],bt=(we>>>2)-1;if(!Qe)return;for(var et=0;et<bt&&(Te=_c(Qe,et*4))!==ce;++et)ke.push(Te);I(_c(Qe,we-4),ge-1,be,we,ke)}}function z(de,ge,be,we,ke){var Te=[],Qe=[];ke||(ke=[]);var bt=we-1,et=0,at=0;for(et=ge;et>=0;){ke[et]=!0,Te[Te.length]=et,Qe.push(de[et]);var nt=be[Math.floor(et*4/we)];if(at=et*4&bt,we<4+at)throw new Error("FAT boundary crossed: "+et+" 4 "+we);if(!de[nt])break;et=_c(de[nt],at)}return{nodes:Te,data:kv([Qe])}}function U(de,ge,be,we){var ke=de.length,Te=[],Qe=[],bt=[],et=[],at=we-1,nt=0,Ot=0,It=0,Ht=0;for(nt=0;nt<ke;++nt)if(bt=[],It=nt+ge,It>=ke&&(It-=ke),!Qe[It]){et=[];var zt=[];for(Ot=It;Ot>=0;){zt[Ot]=!0,Qe[Ot]=!0,bt[bt.length]=Ot,et.push(de[Ot]);var Kt=be[Math.floor(Ot*4/we)];if(Ht=Ot*4&at,we<4+Ht)throw new Error("FAT boundary crossed: "+Ot+" 4 "+we);if(!de[Kt]||(Ot=_c(de[Kt],Ht),zt[Ot]))break}Te[It]={nodes:bt,data:kv([et])}}return Te}function B(de,ge,be,we,ke,Te,Qe,bt){for(var et=0,at=we.length?2:0,nt=ge[de].data,Ot=0,It=0,Ht;Ot<nt.length;Ot+=128){var zt=nt.slice(Ot,Ot+128);fi(zt,64),It=zt.read_shift(2),Ht=Lp(zt,0,It-at),we.push(Ht);var Kt={name:Ht,type:zt.read_shift(1),color:zt.read_shift(1),L:zt.read_shift(4,"i"),R:zt.read_shift(4,"i"),C:zt.read_shift(4,"i"),clsid:zt.read_shift(16),state:zt.read_shift(4,"i"),start:0,size:0},fr=zt.read_shift(2)+zt.read_shift(2)+zt.read_shift(2)+zt.read_shift(2);fr!==0&&(Kt.ct=V(zt,zt.l-8));var Ee=zt.read_shift(2)+zt.read_shift(2)+zt.read_shift(2)+zt.read_shift(2);Ee!==0&&(Kt.mt=V(zt,zt.l-8)),Kt.start=zt.read_shift(4,"i"),Kt.size=zt.read_shift(4,"i"),Kt.size<0&&Kt.start<0&&(Kt.size=Kt.type=0,Kt.start=ce,Kt.name=""),Kt.type===5?(et=Kt.start,ke>0&&et!==ce&&(ge[et].name="!StreamData")):Kt.size>=4096?(Kt.storage="fat",ge[Kt.start]===void 0&&(ge[Kt.start]=z(be,Kt.start,ge.fat_addrs,ge.ssz)),ge[Kt.start].name=Kt.name,Kt.content=ge[Kt.start].data.slice(0,Kt.size)):(Kt.storage="minifat",Kt.size<0?Kt.size=0:et!==ce&&Kt.start!==ce&&ge[et]&&(Kt.content=A(Kt,ge[et].data,(ge[bt]||{}).data))),Kt.content&&fi(Kt.content,0),Te[Ht]=Kt,Qe.push(Kt)}}function V(de,ge){return new Date((gi(de,ge+4)/1e7*Math.pow(2,32)+gi(de,ge)/1e7-11644473600)*1e3)}function Z(de,ge){return x(),k(y.readFileSync(de),ge)}function W(de,ge){var be=ge&&ge.type;switch(be||Na&&Buffer.isBuffer(de)&&(be="buffer"),be||"base64"){case"file":return Z(de,ge);case"base64":return k(Qi(il(de)),ge);case"binary":return k(Qi(de),ge)}return k(de,ge)}function H(de,ge){var be=ge||{},we=be.root||"Root Entry";if(de.FullPaths||(de.FullPaths=[]),de.FileIndex||(de.FileIndex=[]),de.FullPaths.length!==de.FileIndex.length)throw new Error("inconsistent CFB structure");de.FullPaths.length===0&&(de.FullPaths[0]=we+"/",de.FileIndex[0]={name:we,type:5}),be.CLSID&&(de.FileIndex[0].clsid=be.CLSID),le(de)}function le(de){var ge="Sh33tJ5";if(!Ua.find(de,"/"+ge)){var be=Nt(4);be[0]=55,be[1]=be[3]=50,be[2]=54,de.FileIndex.push({name:ge,type:2,content:be,size:4,L:69,R:69,C:69}),de.FullPaths.push(de.FullPaths[0]+ge),Q(de)}}function Q(de,ge){H(de);for(var be=!1,we=!1,ke=de.FullPaths.length-1;ke>=0;--ke){var Te=de.FileIndex[ke];switch(Te.type){case 0:we?be=!0:(de.FileIndex.pop(),de.FullPaths.pop());break;case 1:case 2:case 5:we=!0,isNaN(Te.R*Te.L*Te.C)&&(be=!0),Te.R>-1&&Te.L>-1&&Te.R==Te.L&&(be=!0);break;default:be=!0;break}}if(!(!be&&!ge)){var Qe=new Date(1987,1,19),bt=0,et=Object.create?Object.create(null):{},at=[];for(ke=0;ke<de.FullPaths.length;++ke)et[de.FullPaths[ke]]=!0,de.FileIndex[ke].type!==0&&at.push([de.FullPaths[ke],de.FileIndex[ke]]);for(ke=0;ke<at.length;++ke){var nt=n(at[ke][0]);we=et[nt],we||(at.push([nt,{name:i(nt).replace("/",""),type:1,clsid:me,ct:Qe,mt:Qe,content:null}]),et[nt]=!0)}for(at.sort(function(Ht,zt){return a(Ht[0],zt[0])}),de.FullPaths=[],de.FileIndex=[],ke=0;ke<at.length;++ke)de.FullPaths[ke]=at[ke][0],de.FileIndex[ke]=at[ke][1];for(ke=0;ke<at.length;++ke){var Ot=de.FileIndex[ke],It=de.FullPaths[ke];if(Ot.name=i(It).replace("/",""),Ot.L=Ot.R=Ot.C=-(Ot.color=1),Ot.size=Ot.content?Ot.content.length:0,Ot.start=0,Ot.clsid=Ot.clsid||me,ke===0)Ot.C=at.length>1?1:-1,Ot.size=0,Ot.type=5;else if(It.slice(-1)=="/"){for(bt=ke+1;bt<at.length&&n(de.FullPaths[bt])!=It;++bt);for(Ot.C=bt>=at.length?-1:bt,bt=ke+1;bt<at.length&&n(de.FullPaths[bt])!=n(It);++bt);Ot.R=bt>=at.length?-1:bt,Ot.type=1}else n(de.FullPaths[ke+1]||"")==n(It)&&(Ot.R=ke+1),Ot.type=2}}}function Ne(de,ge){var be=ge||{};if(be.fileType=="mad")return Zr(de,be);switch(Q(de),be.fileType){case"zip":return vr(de,be)}var we=(function(Ht){for(var zt=0,Kt=0,fr=0;fr<Ht.FileIndex.length;++fr){var Ee=Ht.FileIndex[fr];if(Ee.content){var wt=Ee.content.length;wt>0&&(wt<4096?zt+=wt+63>>6:Kt+=wt+511>>9)}}for(var xr=Ht.FullPaths.length+3>>2,qr=zt+7>>3,Za=zt+127>>7,Tr=qr+Kt+xr+Za,Ar=Tr+127>>7,Pe=Ar<=109?0:Math.ceil((Ar-109)/127);Tr+Ar+Pe+127>>7>Ar;)Pe=++Ar<=109?0:Math.ceil((Ar-109)/127);var kt=[1,Pe,Ar,Za,xr,Kt,zt,0];return Ht.FileIndex[0].size=zt<<6,kt[7]=(Ht.FileIndex[0].start=kt[0]+kt[1]+kt[2]+kt[3]+kt[4]+kt[5])+(kt[6]+7>>3),kt})(de),ke=Nt(we[7]<<9),Te=0,Qe=0;{for(Te=0;Te<8;++Te)ke.write_shift(1,ae[Te]);for(Te=0;Te<8;++Te)ke.write_shift(2,0);for(ke.write_shift(2,62),ke.write_shift(2,3),ke.write_shift(2,65534),ke.write_shift(2,9),ke.write_shift(2,6),Te=0;Te<3;++Te)ke.write_shift(2,0);for(ke.write_shift(4,0),ke.write_shift(4,we[2]),ke.write_shift(4,we[0]+we[1]+we[2]+we[3]-1),ke.write_shift(4,0),ke.write_shift(4,4096),ke.write_shift(4,we[3]?we[0]+we[1]+we[2]-1:ce),ke.write_shift(4,we[3]),ke.write_shift(-4,we[1]?we[0]-1:ce),ke.write_shift(4,we[1]),Te=0;Te<109;++Te)ke.write_shift(-4,Te<we[2]?we[1]+Te:-1)}if(we[1])for(Qe=0;Qe<we[1];++Qe){for(;Te<236+Qe*127;++Te)ke.write_shift(-4,Te<we[2]?we[1]+Te:-1);ke.write_shift(-4,Qe===we[1]-1?ce:Qe+1)}var bt=function(Ht){for(Qe+=Ht;Te<Qe-1;++Te)ke.write_shift(-4,Te+1);Ht&&(++Te,ke.write_shift(-4,ce))};for(Qe=Te=0,Qe+=we[1];Te<Qe;++Te)ke.write_shift(-4,K.DIFSECT);for(Qe+=we[2];Te<Qe;++Te)ke.write_shift(-4,K.FATSECT);bt(we[3]),bt(we[4]);for(var et=0,at=0,nt=de.FileIndex[0];et<de.FileIndex.length;++et)nt=de.FileIndex[et],nt.content&&(at=nt.content.length,!(at<4096)&&(nt.start=Qe,bt(at+511>>9)));for(bt(we[6]+7>>3);ke.l&511;)ke.write_shift(-4,K.ENDOFCHAIN);for(Qe=Te=0,et=0;et<de.FileIndex.length;++et)nt=de.FileIndex[et],nt.content&&(at=nt.content.length,!(!at||at>=4096)&&(nt.start=Qe,bt(at+63>>6)));for(;ke.l&511;)ke.write_shift(-4,K.ENDOFCHAIN);for(Te=0;Te<we[4]<<2;++Te){var Ot=de.FullPaths[Te];if(!Ot||Ot.length===0){for(et=0;et<17;++et)ke.write_shift(4,0);for(et=0;et<3;++et)ke.write_shift(4,-1);for(et=0;et<12;++et)ke.write_shift(4,0);continue}nt=de.FileIndex[Te],Te===0&&(nt.start=nt.size?nt.start-1:ce);var It=Te===0&&be.root||nt.name;if(at=2*(It.length+1),ke.write_shift(64,It,"utf16le"),ke.write_shift(2,at),ke.write_shift(1,nt.type),ke.write_shift(1,nt.color),ke.write_shift(-4,nt.L),ke.write_shift(-4,nt.R),ke.write_shift(-4,nt.C),nt.clsid)ke.write_shift(16,nt.clsid,"hex");else for(et=0;et<4;++et)ke.write_shift(4,0);ke.write_shift(4,nt.state||0),ke.write_shift(4,0),ke.write_shift(4,0),ke.write_shift(4,0),ke.write_shift(4,0),ke.write_shift(4,nt.start),ke.write_shift(4,nt.size),ke.write_shift(4,0)}for(Te=1;Te<de.FileIndex.length;++Te)if(nt=de.FileIndex[Te],nt.size>=4096)if(ke.l=nt.start+1<<9,Na&&Buffer.isBuffer(nt.content))nt.content.copy(ke,ke.l,0,nt.size),ke.l+=nt.size+511&-512;else{for(et=0;et<nt.size;++et)ke.write_shift(1,nt.content[et]);for(;et&511;++et)ke.write_shift(1,0)}for(Te=1;Te<de.FileIndex.length;++Te)if(nt=de.FileIndex[Te],nt.size>0&&nt.size<4096)if(Na&&Buffer.isBuffer(nt.content))nt.content.copy(ke,ke.l,0,nt.size),ke.l+=nt.size+63&-64;else{for(et=0;et<nt.size;++et)ke.write_shift(1,nt.content[et]);for(;et&63;++et)ke.write_shift(1,0)}if(Na)ke.l=ke.length;else for(;ke.l<ke.length;)ke.write_shift(1,0);return ke}function oe(de,ge){var be=de.FullPaths.map(function(et){return et.toUpperCase()}),we=be.map(function(et){var at=et.split("/");return at[at.length-(et.slice(-1)=="/"?2:1)]}),ke=!1;ge.charCodeAt(0)===47?(ke=!0,ge=be[0].slice(0,-1)+ge):ke=ge.indexOf("/")!==-1;var Te=ge.toUpperCase(),Qe=ke===!0?be.indexOf(Te):we.indexOf(Te);if(Qe!==-1)return de.FileIndex[Qe];var bt=!Te.match(qh);for(Te=Te.replace(nu,""),bt&&(Te=Te.replace(qh,"!")),Qe=0;Qe<be.length;++Qe)if((bt?be[Qe].replace(qh,"!"):be[Qe]).replace(nu,"")==Te||(bt?we[Qe].replace(qh,"!"):we[Qe]).replace(nu,"")==Te)return de.FileIndex[Qe];return null}var se=64,ce=-2,Ce="d0cf11e0a1b11ae1",ae=[208,207,17,224,161,177,26,225],me="00000000000000000000000000000000",K={MAXREGSECT:-6,DIFSECT:-4,FATSECT:-3,ENDOFCHAIN:ce,FREESECT:-1,HEADER_SIGNATURE:Ce,HEADER_MINOR_VERSION:"3e00",MAXREGSID:-6,NOSTREAM:-1,HEADER_CLSID:me,EntryTypes:["unknown","storage","stream","lockbytes","property","root"]};function fe(de,ge,be){x();var we=Ne(de,be);y.writeFileSync(ge,we)}function Oe(de){for(var ge=new Array(de.length),be=0;be<de.length;++be)ge[be]=String.fromCharCode(de[be]);return ge.join("")}function ye(de,ge){var be=Ne(de,ge);switch(ge&&ge.type||"buffer"){case"file":return x(),y.writeFileSync(ge.filename,be),be;case"binary":return typeof be=="string"?be:Oe(be);case"base64":return gu(typeof be=="string"?be:Oe(be));case"buffer":if(Na)return Buffer.isBuffer(be)?be:dl(be);case"array":return typeof be=="string"?Qi(be):be}return be}var J;function G(de){try{var ge=de.InflateRaw,be=new ge;if(be._processChunk(new Uint8Array([3,0]),be._finishFlushFlag),be.bytesRead)J=de;else throw new Error("zlib does not expose bytesRead")}catch(we){console.error("cannot use native zlib: "+(we.message||we))}}function ie(de,ge){if(!J)return mr(de,ge);var be=J.InflateRaw,we=new be,ke=we._processChunk(de.slice(de.l),we._finishFlushFlag);return de.l+=we.bytesRead,ke}function re(de){return J?J.deflateRawSync(de):Ct(de)}var ne=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],ve=[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],Ve=[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 Ae(de){var ge=(de<<1|de<<11)&139536|(de<<5|de<<15)&558144;return(ge>>16|ge>>8|ge)&255}for(var ze=typeof Uint8Array!="undefined",Re=ze?new Uint8Array(256):[],Ze=0;Ze<256;++Ze)Re[Ze]=Ae(Ze);function Lt(de,ge){var be=Re[de&255];return ge<=8?be>>>8-ge:(be=be<<8|Re[de>>8&255],ge<=16?be>>>16-ge:(be=be<<8|Re[de>>16&255],be>>>24-ge))}function mt(de,ge){var be=ge&7,we=ge>>>3;return(de[we]|(be<=6?0:de[we+1]<<8))>>>be&3}function Zt(de,ge){var be=ge&7,we=ge>>>3;return(de[we]|(be<=5?0:de[we+1]<<8))>>>be&7}function ar(de,ge){var be=ge&7,we=ge>>>3;return(de[we]|(be<=4?0:de[we+1]<<8))>>>be&15}function or(de,ge){var be=ge&7,we=ge>>>3;return(de[we]|(be<=3?0:de[we+1]<<8))>>>be&31}function yt(de,ge){var be=ge&7,we=ge>>>3;return(de[we]|(be<=1?0:de[we+1]<<8))>>>be&127}function nr(de,ge,be){var we=ge&7,ke=ge>>>3,Te=(1<<be)-1,Qe=de[ke]>>>we;return be<8-we||(Qe|=de[ke+1]<<8-we,be<16-we)||(Qe|=de[ke+2]<<16-we,be<24-we)||(Qe|=de[ke+3]<<24-we),Qe&Te}function $t(de,ge,be){var we=ge&7,ke=ge>>>3;return we<=5?de[ke]|=(be&7)<<we:(de[ke]|=be<<we&255,de[ke+1]=(be&7)>>8-we),ge+3}function Er(de,ge,be){var we=ge&7,ke=ge>>>3;return be=(be&1)<<we,de[ke]|=be,ge+1}function St(de,ge,be){var we=ge&7,ke=ge>>>3;return be<<=we,de[ke]|=be&255,be>>>=8,de[ke+1]=be,ge+8}function Br(de,ge,be){var we=ge&7,ke=ge>>>3;return be<<=we,de[ke]|=be&255,be>>>=8,de[ke+1]=be&255,de[ke+2]=be>>>8,ge+16}function Pt(de,ge){var be=de.length,we=2*be>ge?2*be:ge+5,ke=0;if(be>=ge)return de;if(Na){var Te=lv(we);if(de.copy)de.copy(Te);else for(;ke<de.length;++ke)Te[ke]=de[ke];return Te}else if(ze){var Qe=new Uint8Array(we);if(Qe.set)Qe.set(de);else for(;ke<be;++ke)Qe[ke]=de[ke];return Qe}return de.length=we,de}function it(de){for(var ge=new Array(de),be=0;be<de;++be)ge[be]=0;return ge}function De(de,ge,be){var we=1,ke=0,Te=0,Qe=0,bt=0,et=de.length,at=ze?new Uint16Array(32):it(32);for(Te=0;Te<32;++Te)at[Te]=0;for(Te=et;Te<be;++Te)de[Te]=0;et=de.length;var nt=ze?new Uint16Array(et):it(et);for(Te=0;Te<et;++Te)at[ke=de[Te]]++,we<ke&&(we=ke),nt[Te]=0;for(at[0]=0,Te=1;Te<=we;++Te)at[Te+16]=bt=bt+at[Te-1]<<1;for(Te=0;Te<et;++Te)bt=de[Te],bt!=0&&(nt[Te]=at[bt+16]++);var Ot=0;for(Te=0;Te<et;++Te)if(Ot=de[Te],Ot!=0)for(bt=Lt(nt[Te],we)>>we-Ot,Qe=(1<<we+4-Ot)-1;Qe>=0;--Qe)ge[bt|Qe<<Ot]=Ot&15|Te<<4;return we}var Je=ze?new Uint16Array(512):it(512),Be=ze?new Uint16Array(32):it(32);if(!ze){for(var vt=0;vt<512;++vt)Je[vt]=0;for(vt=0;vt<32;++vt)Be[vt]=0}(function(){for(var de=[],ge=0;ge<32;ge++)de.push(5);De(de,Be,32);var be=[];for(ge=0;ge<=143;ge++)be.push(8);for(;ge<=255;ge++)be.push(9);for(;ge<=279;ge++)be.push(7);for(;ge<=287;ge++)be.push(8);De(be,Je,288)})();var jt=(function(){for(var ge=ze?new Uint8Array(32768):[],be=0,we=0;be<Ve.length-1;++be)for(;we<Ve[be+1];++we)ge[we]=be;for(;we<32768;++we)ge[we]=29;var ke=ze?new Uint8Array(259):[];for(be=0,we=0;be<ve.length-1;++be)for(;we<ve[be+1];++we)ke[we]=be;function Te(bt,et){for(var at=0;at<bt.length;){var nt=Math.min(65535,bt.length-at),Ot=at+nt==bt.length;for(et.write_shift(1,+Ot),et.write_shift(2,nt),et.write_shift(2,~nt&65535);nt-- >0;)et[et.l++]=bt[at++]}return et.l}function Qe(bt,et){for(var at=0,nt=0,Ot=ze?new Uint16Array(32768):[];nt<bt.length;){var It=Math.min(65535,bt.length-nt);if(It<10){for(at=$t(et,at,+(nt+It==bt.length)),at&7&&(at+=8-(at&7)),et.l=at/8|0,et.write_shift(2,It),et.write_shift(2,~It&65535);It-- >0;)et[et.l++]=bt[nt++];at=et.l*8;continue}at=$t(et,at,+(nt+It==bt.length)+2);for(var Ht=0;It-- >0;){var zt=bt[nt];Ht=(Ht<<5^zt)&32767;var Kt=-1,fr=0;if((Kt=Ot[Ht])&&(Kt|=nt&-32768,Kt>nt&&(Kt-=32768),Kt<nt))for(;bt[Kt+fr]==bt[nt+fr]&&fr<250;)++fr;if(fr>2){zt=ke[fr],zt<=22?at=St(et,at,Re[zt+1]>>1)-1:(St(et,at,3),at+=5,St(et,at,Re[zt-23]>>5),at+=3);var Ee=zt<8?0:zt-4>>2;Ee>0&&(Br(et,at,fr-ve[zt]),at+=Ee),zt=ge[nt-Kt],at=St(et,at,Re[zt]>>3),at-=3;var wt=zt<4?0:zt-2>>1;wt>0&&(Br(et,at,nt-Kt-Ve[zt]),at+=wt);for(var xr=0;xr<fr;++xr)Ot[Ht]=nt&32767,Ht=(Ht<<5^bt[nt])&32767,++nt;It-=fr-1}else zt<=143?zt=zt+48:at=Er(et,at,1),at=St(et,at,Re[zt]),Ot[Ht]=nt&32767,++nt}at=St(et,at,0)-1}return et.l=(at+7)/8|0,et.l}return function(et,at){return et.length<8?Te(et,at):Qe(et,at)}})();function Ct(de){var ge=Nt(50+Math.floor(de.length*1.1)),be=jt(de,ge);return ge.slice(0,be)}var Wt=ze?new Uint16Array(32768):it(32768),pr=ze?new Uint16Array(32768):it(32768),Ge=ze?new Uint16Array(128):it(128),We=1,At=1;function lt(de,ge){var be=or(de,ge)+257;ge+=5;var we=or(de,ge)+1;ge+=5;var ke=ar(de,ge)+4;ge+=4;for(var Te=0,Qe=ze?new Uint8Array(19):it(19),bt=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],et=1,at=ze?new Uint8Array(8):it(8),nt=ze?new Uint8Array(8):it(8),Ot=Qe.length,It=0;It<ke;++It)Qe[ne[It]]=Te=Zt(de,ge),et<Te&&(et=Te),at[Te]++,ge+=3;var Ht=0;for(at[0]=0,It=1;It<=et;++It)nt[It]=Ht=Ht+at[It-1]<<1;for(It=0;It<Ot;++It)(Ht=Qe[It])!=0&&(bt[It]=nt[Ht]++);var zt=0;for(It=0;It<Ot;++It)if(zt=Qe[It],zt!=0){Ht=Re[bt[It]]>>8-zt;for(var Kt=(1<<7-zt)-1;Kt>=0;--Kt)Ge[Ht|Kt<<zt]=zt&7|It<<3}var fr=[];for(et=1;fr.length<be+we;)switch(Ht=Ge[yt(de,ge)],ge+=Ht&7,Ht>>>=3){case 16:for(Te=3+mt(de,ge),ge+=2,Ht=fr[fr.length-1];Te-- >0;)fr.push(Ht);break;case 17:for(Te=3+Zt(de,ge),ge+=3;Te-- >0;)fr.push(0);break;case 18:for(Te=11+yt(de,ge),ge+=7;Te-- >0;)fr.push(0);break;default:fr.push(Ht),et<Ht&&(et=Ht);break}var Ee=fr.slice(0,be),wt=fr.slice(be);for(It=be;It<286;++It)Ee[It]=0;for(It=we;It<30;++It)wt[It]=0;return We=De(Ee,Wt,286),At=De(wt,pr,30),ge}function Dt(de,ge){if(de[0]==3&&!(de[1]&3))return[Tc(ge),2];for(var be=0,we=0,ke=lv(ge||1<<18),Te=0,Qe=ke.length>>>0,bt=0,et=0;(we&1)==0;){if(we=Zt(de,be),be+=3,we>>>1)we>>1==1?(bt=9,et=5):(be=lt(de,be),bt=We,et=At);else{be&7&&(be+=8-(be&7));var at=de[be>>>3]|de[(be>>>3)+1]<<8;if(be+=32,at>0)for(!ge&&Qe<Te+at&&(ke=Pt(ke,Te+at),Qe=ke.length);at-- >0;)ke[Te++]=de[be>>>3],be+=8;continue}for(;;){!ge&&Qe<Te+32767&&(ke=Pt(ke,Te+32767),Qe=ke.length);var nt=nr(de,be,bt),Ot=we>>>1==1?Je[nt]:Wt[nt];if(be+=Ot&15,Ot>>>=4,(Ot>>>8&255)===0)ke[Te++]=Ot;else{if(Ot==256)break;Ot-=257;var It=Ot<8?0:Ot-4>>2;It>5&&(It=0);var Ht=Te+ve[Ot];It>0&&(Ht+=nr(de,be,It),be+=It),nt=nr(de,be,et),Ot=we>>>1==1?Be[nt]:pr[nt],be+=Ot&15,Ot>>>=4;var zt=Ot<4?0:Ot-2>>1,Kt=Ve[Ot];for(zt>0&&(Kt+=nr(de,be,zt),be+=zt),!ge&&Qe<Ht&&(ke=Pt(ke,Ht+100),Qe=ke.length);Te<Ht;)ke[Te]=ke[Te-Kt],++Te}}}return ge?[ke,be+7>>>3]:[ke.slice(0,Te),be+7>>>3]}function mr(de,ge){var be=de.slice(de.l||0),we=Dt(be,ge);return de.l+=we[1],we[0]}function tr(de,ge){if(de)typeof console!="undefined"&&console.error(ge);else throw new Error(ge)}function pt(de,ge){var be=de;fi(be,0);var we=[],ke=[],Te={FileIndex:we,FullPaths:ke};H(Te,{root:ge.root});for(var Qe=be.length-4;(be[Qe]!=80||be[Qe+1]!=75||be[Qe+2]!=5||be[Qe+3]!=6)&&Qe>=0;)--Qe;be.l=Qe+4,be.l+=4;var bt=be.read_shift(2);be.l+=6;var et=be.read_shift(4);for(be.l=et,Qe=0;Qe<bt;++Qe){be.l+=20;var at=be.read_shift(4),nt=be.read_shift(4),Ot=be.read_shift(2),It=be.read_shift(2),Ht=be.read_shift(2);be.l+=8;var zt=be.read_shift(4),Kt=g(be.slice(be.l+Ot,be.l+Ot+It));be.l+=Ot+It+Ht;var fr=be.l;be.l=zt+4,Jt(be,at,nt,Te,Kt),be.l=fr}return Te}function Jt(de,ge,be,we,ke){de.l+=2;var Te=de.read_shift(2),Qe=de.read_shift(2),bt=u(de);if(Te&8257)throw new Error("Unsupported ZIP encryption");for(var et=de.read_shift(4),at=de.read_shift(4),nt=de.read_shift(4),Ot=de.read_shift(2),It=de.read_shift(2),Ht="",zt=0;zt<Ot;++zt)Ht+=String.fromCharCode(de[de.l++]);if(It){var Kt=g(de.slice(de.l,de.l+It));(Kt[21589]||{}).mt&&(bt=Kt[21589].mt),((ke||{})[21589]||{}).mt&&(bt=ke[21589].mt)}de.l+=It;var fr=de.slice(de.l,de.l+at);switch(Qe){case 8:fr=ie(de,nt);break;case 0:break;default:throw new Error("Unsupported ZIP Compression method "+Qe)}var Ee=!1;Te&8&&(et=de.read_shift(4),et==134695760&&(et=de.read_shift(4),Ee=!0),at=de.read_shift(4),nt=de.read_shift(4)),at!=ge&&tr(Ee,"Bad compressed size: "+ge+" != "+at),nt!=be&&tr(Ee,"Bad uncompressed size: "+be+" != "+nt),Qt(we,Ht,fr,{unsafe:!0,mt:bt})}function vr(de,ge){var be=ge||{},we=[],ke=[],Te=Nt(1),Qe=be.compression?8:0,bt=0,et=0,at=0,nt=0,Ot=0,It=de.FullPaths[0],Ht=It,zt=de.FileIndex[0],Kt=[],fr=0;for(et=1;et<de.FullPaths.length;++et)if(Ht=de.FullPaths[et].slice(It.length),zt=de.FileIndex[et],!(!zt.size||!zt.content||Ht=="Sh33tJ5")){var Ee=nt,wt=Nt(Ht.length);for(at=0;at<Ht.length;++at)wt.write_shift(1,Ht.charCodeAt(at)&127);wt=wt.slice(0,wt.l),Kt[Ot]=kE.buf(zt.content,0);var xr=zt.content;Qe==8&&(xr=re(xr)),Te=Nt(30),Te.write_shift(4,67324752),Te.write_shift(2,20),Te.write_shift(2,bt),Te.write_shift(2,Qe),zt.mt?c(Te,zt.mt):Te.write_shift(4,0),Te.write_shift(-4,Kt[Ot]),Te.write_shift(4,xr.length),Te.write_shift(4,zt.content.length),Te.write_shift(2,wt.length),Te.write_shift(2,0),nt+=Te.length,we.push(Te),nt+=wt.length,we.push(wt),nt+=xr.length,we.push(xr),Te=Nt(46),Te.write_shift(4,33639248),Te.write_shift(2,0),Te.write_shift(2,20),Te.write_shift(2,bt),Te.write_shift(2,Qe),Te.write_shift(4,0),Te.write_shift(-4,Kt[Ot]),Te.write_shift(4,xr.length),Te.write_shift(4,zt.content.length),Te.write_shift(2,wt.length),Te.write_shift(2,0),Te.write_shift(2,0),Te.write_shift(2,0),Te.write_shift(2,0),Te.write_shift(4,0),Te.write_shift(4,Ee),fr+=Te.l,ke.push(Te),fr+=wt.length,ke.push(wt),++Ot}return Te=Nt(22),Te.write_shift(4,101010256),Te.write_shift(2,0),Te.write_shift(2,0),Te.write_shift(2,Ot),Te.write_shift(2,Ot),Te.write_shift(4,fr),Te.write_shift(4,nt),Te.write_shift(2,0),is([is(we),is(ke),Te])}var Ir={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 Le(de,ge){if(de.ctype)return de.ctype;var be=de.name||"",we=be.match(/\.([^\.]+)$/);return we&&Ir[we[1]]||ge&&(we=(be=ge).match(/[\.\\]([^\.\\])+$/),we&&Ir[we[1]])?Ir[we[1]]:"application/octet-stream"}function qe(de){for(var ge=gu(de),be=[],we=0;we<ge.length;we+=76)be.push(ge.slice(we,we+76));return be.join(`\r
|
||
`)+`\r
|
||
`}function Ke(de){var ge=de.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7E-\xFF=]/g,function(at){var nt=at.charCodeAt(0).toString(16).toUpperCase();return"="+(nt.length==1?"0"+nt:nt)});ge=ge.replace(/ $/mg,"=20").replace(/\t$/mg,"=09"),ge.charAt(0)==`
|
||
`&&(ge="=0D"+ge.slice(1)),ge=ge.replace(/\r(?!\n)/mg,"=0D").replace(/\n\n/mg,`
|
||
=0A`).replace(/([^\r\n])\n/mg,"$1=0A");for(var be=[],we=ge.split(`\r
|
||
`),ke=0;ke<we.length;++ke){var Te=we[ke];if(Te.length==0){be.push("");continue}for(var Qe=0;Qe<Te.length;){var bt=76,et=Te.slice(Qe,Qe+bt);et.charAt(bt-1)=="="?bt--:et.charAt(bt-2)=="="?bt-=2:et.charAt(bt-3)=="="&&(bt-=3),et=Te.slice(Qe,Qe+bt),Qe+=bt,Qe<Te.length&&(et+="="),be.push(et)}}return be.join(`\r
|
||
`)}function Yt(de){for(var ge=[],be=0;be<de.length;++be){for(var we=de[be];be<=de.length&&we.charAt(we.length-1)=="=";)we=we.slice(0,we.length-1)+de[++be];ge.push(we)}for(var ke=0;ke<ge.length;++ke)ge[ke]=ge[ke].replace(/[=][0-9A-Fa-f]{2}/g,function(Te){return String.fromCharCode(parseInt(Te.slice(1),16))});return Qi(ge.join(`\r
|
||
`))}function gr(de,ge,be){for(var we="",ke="",Te="",Qe,bt=0;bt<10;++bt){var et=ge[bt];if(!et||et.match(/^\s*$/))break;var at=et.match(/^(.*?):\s*([^\s].*)$/);if(at)switch(at[1].toLowerCase()){case"content-location":we=at[2].trim();break;case"content-type":Te=at[2].trim();break;case"content-transfer-encoding":ke=at[2].trim();break}}switch(++bt,ke.toLowerCase()){case"base64":Qe=Qi(il(ge.slice(bt).join("")));break;case"quoted-printable":Qe=Yt(ge.slice(bt));break;default:throw new Error("Unsupported Content-Transfer-Encoding "+ke)}var nt=Qt(de,we.slice(be.length),Qe,{unsafe:!0});Te&&(nt.ctype=Te)}function jr(de,ge){if(Oe(de.slice(0,13)).toLowerCase()!="mime-version:")throw new Error("Unsupported MAD header");var be=ge&&ge.root||"",we=(Na&&Buffer.isBuffer(de)?de.toString("binary"):Oe(de)).split(`\r
|
||
`),ke=0,Te="";for(ke=0;ke<we.length;++ke)if(Te=we[ke],!!/^Content-Location:/i.test(Te)&&(Te=Te.slice(Te.indexOf("file")),be||(be=Te.slice(0,Te.lastIndexOf("/")+1)),Te.slice(0,be.length)!=be))for(;be.length>0&&(be=be.slice(0,be.length-1),be=be.slice(0,be.lastIndexOf("/")+1),Te.slice(0,be.length)!=be););var Qe=(we[1]||"").match(/boundary="(.*?)"/);if(!Qe)throw new Error("MAD cannot find boundary");var bt="--"+(Qe[1]||""),et=[],at=[],nt={FileIndex:et,FullPaths:at};H(nt);var Ot,It=0;for(ke=0;ke<we.length;++ke){var Ht=we[ke];Ht!==bt&&Ht!==bt+"--"||(It++&&gr(nt,we.slice(Ot,ke),be),Ot=ke)}return nt}function Zr(de,ge){var be=ge||{},we=be.boundary||"SheetJS";we="------="+we;for(var ke=["MIME-Version: 1.0",'Content-Type: multipart/related; boundary="'+we.slice(2)+'"',"","",""],Te=de.FullPaths[0],Qe=Te,bt=de.FileIndex[0],et=1;et<de.FullPaths.length;++et)if(Qe=de.FullPaths[et].slice(Te.length),bt=de.FileIndex[et],!(!bt.size||!bt.content||Qe=="Sh33tJ5")){Qe=Qe.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7E-\xFF]/g,function(fr){return"_x"+fr.charCodeAt(0).toString(16)+"_"}).replace(/[\u0080-\uFFFF]/g,function(fr){return"_u"+fr.charCodeAt(0).toString(16)+"_"});for(var at=bt.content,nt=Na&&Buffer.isBuffer(at)?at.toString("binary"):Oe(at),Ot=0,It=Math.min(1024,nt.length),Ht=0,zt=0;zt<=It;++zt)(Ht=nt.charCodeAt(zt))>=32&&Ht<128&&++Ot;var Kt=Ot>=It*4/5;ke.push(we),ke.push("Content-Location: "+(be.root||"file:///C:/SheetJS/")+Qe),ke.push("Content-Transfer-Encoding: "+(Kt?"quoted-printable":"base64")),ke.push("Content-Type: "+Le(bt,Qe)),ke.push(""),ke.push(Kt?Ke(nt):qe(nt))}return ke.push(we+`--\r
|
||
`),ke.join(`\r
|
||
`)}function en(de){var ge={};return H(ge,de),ge}function Qt(de,ge,be,we){var ke=we&&we.unsafe;ke||H(de);var Te=!ke&&Ua.find(de,ge);if(!Te){var Qe=de.FullPaths[0];ge.slice(0,Qe.length)==Qe?Qe=ge:(Qe.slice(-1)!="/"&&(Qe+="/"),Qe=(Qe+ge).replace("//","/")),Te={name:i(ge),type:2},de.FileIndex.push(Te),de.FullPaths.push(Qe),ke||Ua.utils.cfb_gc(de)}return Te.content=be,Te.size=be?be.length:0,we&&(we.CLSID&&(Te.clsid=we.CLSID),we.mt&&(Te.mt=we.mt),we.ct&&(Te.ct=we.ct)),Te}function wr(de,ge){H(de);var be=Ua.find(de,ge);if(be){for(var we=0;we<de.FileIndex.length;++we)if(de.FileIndex[we]==be)return de.FileIndex.splice(we,1),de.FullPaths.splice(we,1),!0}return!1}function Vt(de,ge,be){H(de);var we=Ua.find(de,ge);if(we){for(var ke=0;ke<de.FileIndex.length;++ke)if(de.FileIndex[ke]==we)return de.FileIndex[ke].name=i(be),de.FullPaths[ke]=be,!0}return!1}function Ut(de){Q(de,!0)}return r.find=oe,r.read=W,r.parse=k,r.write=ye,r.writeFile=fe,r.utils={cfb_new:en,cfb_add:Qt,cfb_del:wr,cfb_mov:Vt,cfb_gc:Ut,ReadShift:iu,CheckField:p4,prep_blob:fi,bconcat:is,use_zlib:G,_deflateRaw:Ct,_inflateRaw:mr,consts:K},r})();function NE(e){return typeof e=="string"?tm(e):Array.isArray(e)?qC(e):e}function Tu(e,r,a){if(typeof Deno!="undefined"){if(a&&typeof r=="string")switch(a){case"utf8":r=new TextEncoder(a).encode(r);break;case"binary":r=tm(r);break;default:throw new Error("Unsupported encoding "+a)}return Deno.writeFileSync(e,r)}var n=a=="utf8"?pu(r):r;if(typeof IE_SaveFile!="undefined")return IE_SaveFile(n,e);if(typeof Blob!="undefined"){var i=new Blob([NE(n)],{type:"application/octet-stream"});if(typeof navigator!="undefined"&&navigator.msSaveBlob)return navigator.msSaveBlob(i,e);if(typeof saveAs!="undefined")return saveAs(i,e);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:e,saveAs:!0});var u=document.createElement("a");if(u.download!=null)return u.download=e,u.href=c,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL&&typeof setTimeout!="undefined"&&setTimeout(function(){URL.revokeObjectURL(c)},6e4),c}}if(typeof $!="undefined"&&typeof File!="undefined"&&typeof Folder!="undefined")try{var g=File(e);return g.open("w"),g.encoding="binary",Array.isArray(r)&&(r=ju(r)),g.write(r),g.close(),r}catch(y){if(!y.message||!y.message.match(/onstruct/))throw y}throw new Error("cannot save file "+e)}function ds(e){for(var r=Object.keys(e),a=[],n=0;n<r.length;++n)Object.prototype.hasOwnProperty.call(e,r[n])&&a.push(r[n]);return a}function xv(e,r){for(var a=[],n=ds(e),i=0;i!==n.length;++i)a[e[n[i]][r]]==null&&(a[e[n[i]][r]]=n[i]);return a}function Op(e){for(var r=[],a=ds(e),n=0;n!==a.length;++n)r[e[a[n]]]=a[n];return r}function nm(e){for(var r=[],a=ds(e),n=0;n!==a.length;++n)r[e[a[n]]]=parseInt(a[n],10);return r}function SE(e){for(var r=[],a=ds(e),n=0;n!==a.length;++n)r[e[a[n]]]==null&&(r[e[a[n]]]=[]),r[e[a[n]]].push(a[n]);return r}var Of=new Date(1899,11,30,0,0,0);function Ks(e,r){var a=e.getTime(),n=Of.getTime()+(e.getTimezoneOffset()-Of.getTimezoneOffset())*6e4;return(a-n)/(1440*60*1e3)}var e4=new Date,CE=Of.getTime()+(e4.getTimezoneOffset()-Of.getTimezoneOffset())*6e4,pv=e4.getTimezoneOffset();function t4(e){var r=new Date;return r.setTime(e*24*60*60*1e3+CE),r.getTimezoneOffset()!==pv&&r.setTime(r.getTime()+(r.getTimezoneOffset()-pv)*6e4),r}var yv=new Date("2017-02-19T19:06:09.000Z"),r4=isNaN(yv.getFullYear())?new Date("2/19/17"):yv,EE=r4.getFullYear()==2017;function Os(e,r){var a=new Date(e);if(EE)return r>0?a.setTime(a.getTime()+a.getTimezoneOffset()*60*1e3):r<0&&a.setTime(a.getTime()-a.getTimezoneOffset()*60*1e3),a;if(e instanceof Date)return e;if(r4.getFullYear()==1917&&!isNaN(a.getFullYear())){var n=a.getFullYear();return e.indexOf(""+n)>-1||a.setFullYear(a.getFullYear()+100),a}var i=e.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 e.indexOf("Z")>-1&&(c=new Date(c.getTime()-c.getTimezoneOffset()*60*1e3)),c}function sm(e,r){if(Na&&Buffer.isBuffer(e))return e.toString("binary");if(typeof TextDecoder!="undefined")try{var a={"€":"","‚":"",ƒ:"","„":"","…":"
","†":"","‡":"","ˆ":"","‰":"",Š:"","‹":"",Œ:"",Ž:"","‘":"","’":"","“":"","”":"","•":"","–":"","—":"","˜":"","™":"",š:"","›":"",œ:"",ž:"",Ÿ:""};return Array.isArray(e)&&(e=new Uint8Array(e)),new TextDecoder("latin1").decode(e).replace(/[€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ]/g,function(c){return a[c]||c})}catch(c){}for(var n=[],i=0;i!=e.length;++i)n.push(String.fromCharCode(e[i]));return n.join("")}function Js(e){if(typeof JSON!="undefined"&&!Array.isArray(e))return JSON.parse(JSON.stringify(e));if(typeof e!="object"||e==null)return e;if(e instanceof Date)return new Date(e.getTime());var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=Js(e[a]));return r}function fn(e,r){for(var a="";a.length<r;)a+=e;return a}function el(e){var r=Number(e);if(!isNaN(r))return isFinite(r)?r:NaN;if(!/\d/.test(e))return r;var a=1,n=e.replace(/([\d]),([\d])/g,"$1$2").replace(/[$]/g,"").replace(/[%]/g,function(){return a*=100,""});return!isNaN(r=Number(n))||(n=n.replace(/[(](.*)[)]/,function(i,c){return a=-a,c}),!isNaN(r=Number(n)))?r/a:r}var jE=["january","february","march","april","may","june","july","august","september","october","november","december"];function xu(e){var r=new Date(e),a=new Date(NaN),n=r.getYear(),i=r.getMonth(),c=r.getDate();if(isNaN(c))return a;var u=e.toLowerCase();if(u.match(/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/)){if(u=u.replace(/[^a-z]/g,"").replace(/([^a-z]|^)[ap]m?([^a-z]|$)/,""),u.length>3&&jE.indexOf(u)==-1)return a}else if(u.match(/[a-z]/))return a;return n<0||n>8099?a:(i>0||c>1)&&n!=101?r:e.match(/[^-0-9:,\/\\]/)?a:r}function Kr(e,r,a){if(e.FullPaths){if(typeof a=="string"){var n;return Na?n=dl(a):n=KC(a),Ua.utils.cfb_add(e,r,n)}Ua.utils.cfb_add(e,r,a)}else e.file(r,a)}function Rp(){return Ua.utils.cfb_new()}var An=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
|
||
`,TE={""":'"',"'":"'",">":">","<":"<","&":"&"},Mp=Op(TE),Dp=/[&<>'"]/g,AE=/[\u0000-\u0008\u000b-\u001f]/g;function Ra(e){var r=e+"";return r.replace(Dp,function(a){return Mp[a]}).replace(AE,function(a){return"_x"+("000"+a.charCodeAt(0).toString(16)).slice(-4)+"_"})}function bv(e){return Ra(e).replace(/ /g,"_x0020_")}var a4=/[\u0000-\u001f]/g;function OE(e){var r=e+"";return r.replace(Dp,function(a){return Mp[a]}).replace(/\n/g,"<br/>").replace(a4,function(a){return"&#x"+("000"+a.charCodeAt(0).toString(16)).slice(-4)+";"})}function RE(e){var r=e+"";return r.replace(Dp,function(a){return Mp[a]}).replace(a4,function(a){return"&#x"+a.charCodeAt(0).toString(16).toUpperCase()+";"})}function ME(e){return e.replace(/(\r\n|[\r\n])/g," ")}function DE(e){switch(e){case 1:case!0:case"1":case"true":case"TRUE":return!0;default:return!1}}function Cx(e){for(var r="",a=0,n=0,i=0,c=0,u=0,g=0;a<e.length;){if(n=e.charCodeAt(a++),n<128){r+=String.fromCharCode(n);continue}if(i=e.charCodeAt(a++),n>191&&n<224){u=(n&31)<<6,u|=i&63,r+=String.fromCharCode(u);continue}if(c=e.charCodeAt(a++),n<240){r+=String.fromCharCode((n&15)<<12|(i&63)<<6|c&63);continue}u=e.charCodeAt(a++),g=((n&7)<<18|(i&63)<<12|(c&63)<<6|u&63)-65536,r+=String.fromCharCode(55296+(g>>>10&1023)),r+=String.fromCharCode(56320+(g&1023))}return r}function vv(e){var r=Tc(2*e.length),a,n,i=1,c=0,u=0,g;for(n=0;n<e.length;n+=i)i=1,(g=e.charCodeAt(n))<128?a=g:g<224?(a=(g&31)*64+(e.charCodeAt(n+1)&63),i=2):g<240?(a=(g&15)*4096+(e.charCodeAt(n+1)&63)*64+(e.charCodeAt(n+2)&63),i=3):(i=4,a=(g&7)*262144+(e.charCodeAt(n+1)&63)*4096+(e.charCodeAt(n+2)&63)*64+(e.charCodeAt(n+3)&63),a-=65536,u=55296+(a>>>10&1023),a=56320+(a&1023)),u!==0&&(r[c++]=u&255,r[c++]=u>>>8,u=0),r[c++]=a%256,r[c++]=a>>>8;return r.slice(0,c).toString("ucs2")}function _v(e){return dl(e,"binary").toString("utf8")}var Jh="foo bar bazâð£",su=Na&&(_v(Jh)==Cx(Jh)&&_v||vv(Jh)==Cx(Jh)&&vv)||Cx,pu=Na?function(e){return dl(e,"utf8").toString("binary")}:function(e){for(var r=[],a=0,n=0,i=0;a<e.length;)switch(n=e.charCodeAt(a++),!0){case n<128:r.push(String.fromCharCode(n));break;case n<2048:r.push(String.fromCharCode(192+(n>>6))),r.push(String.fromCharCode(128+(n&63)));break;case(n>=55296&&n<57344):n-=55296,i=e.charCodeAt(a++)-56320+(n<<10),r.push(String.fromCharCode(240+(i>>18&7))),r.push(String.fromCharCode(144+(i>>12&63))),r.push(String.fromCharCode(128+(i>>6&63))),r.push(String.fromCharCode(128+(i&63)));break;default:r.push(String.fromCharCode(224+(n>>12))),r.push(String.fromCharCode(128+(n>>6&63))),r.push(String.fromCharCode(128+(n&63)))}return r.join("")},LE=(function(){var e=[["nbsp"," "],["middot","·"],["quot",'"'],["apos","'"],["gt",">"],["lt","<"],["amp","&"]].map(function(r){return[new RegExp("&"+r[0]+";","ig"),r[1]]});return function(a){for(var n=a.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<e.length;++i)n=n.replace(e[i][0],e[i][1]);return n}})(),n4=/(^\s|\s$|\n)/;function os(e,r){return"<"+e+(r.match(n4)?' xml:space="preserve"':"")+">"+r+"</"+e+">"}function yu(e){return ds(e).map(function(r){return" "+r+'="'+e[r]+'"'}).join("")}function rr(e,r,a){return"<"+e+(a!=null?yu(a):"")+(r!=null?(r.match(n4)?' xml:space="preserve"':"")+">"+r+"</"+e:"/")+">"}function ep(e,r){try{return e.toISOString().replace(/\.\d*/,"")}catch(a){if(r)throw a}return""}function IE(e,r){switch(typeof e){case"string":var a=rr("vt:lpwstr",Ra(e));return a=a.replace(/"/g,"_x0022_"),a;case"number":return rr((e|0)==e?"vt:i4":"vt:r8",Ra(String(e)));case"boolean":return rr("vt:bool",e?"true":"false")}if(e instanceof Date)return rr("vt:filetime",ep(e));throw new Error("Unable to serialize "+e)}var Wn={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"},Jd=["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"],mi={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 PE(e,r){for(var a=1-2*(e[r+7]>>>7),n=((e[r+7]&127)<<4)+(e[r+6]>>>4&15),i=e[r+6]&15,c=5;c>=0;--c)i=i*256+e[r+c];return n==2047?i==0?a*(1/0):NaN:(n==0?n=-1022:(n-=1023,i+=Math.pow(2,52)),a*Math.pow(2,n-52)*i)}function FE(e,r,a){var n=(r<0||1/r==-1/0?1:0)<<7,i=0,c=0,u=n?-r:r;isFinite(u)?u==0?i=c=0:(i=Math.floor(Math.log(u)/Math.LN2),c=u*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(r)?26985:0);for(var g=0;g<=5;++g,c/=256)e[a+g]=c&255;e[a+6]=(i&15)<<4|c&15,e[a+7]=i>>4|n}var wv=function(e){for(var r=[],a=10240,n=0;n<e[0].length;++n)if(e[0][n])for(var i=0,c=e[0][n].length;i<c;i+=a)r.push.apply(r,e[0][n].slice(i,i+a));return r},kv=Na?function(e){return e[0].length>0&&Buffer.isBuffer(e[0][0])?Buffer.concat(e[0].map(function(r){return Buffer.isBuffer(r)?r:dl(r)})):wv(e)}:wv,Nv=function(e,r,a){for(var n=[],i=r;i<a;i+=2)n.push(String.fromCharCode(K0(e,i)));return n.join("").replace(nu,"")},Lp=Na?function(e,r,a){return Buffer.isBuffer(e)?e.toString("utf16le",r,a).replace(nu,""):Nv(e,r,a)}:Nv,Sv=function(e,r,a){for(var n=[],i=r;i<r+a;++i)n.push(("0"+e[i].toString(16)).slice(-2));return n.join("")},s4=Na?function(e,r,a){return Buffer.isBuffer(e)?e.toString("hex",r,r+a):Sv(e,r,a)}:Sv,Cv=function(e,r,a){for(var n=[],i=r;i<a;i++)n.push(String.fromCharCode(Ed(e,i)));return n.join("")},Au=Na?function(r,a,n){return Buffer.isBuffer(r)?r.toString("utf8",a,n):Cv(r,a,n)}:Cv,i4=function(e,r){var a=gi(e,r);return a>0?Au(e,r+4,r+4+a-1):""},o4=i4,l4=function(e,r){var a=gi(e,r);return a>0?Au(e,r+4,r+4+a-1):""},c4=l4,d4=function(e,r){var a=2*gi(e,r);return a>0?Au(e,r+4,r+4+a-1):""},u4=d4,h4=function(r,a){var n=gi(r,a);return n>0?Lp(r,a+4,a+4+n):""},f4=h4,m4=function(e,r){var a=gi(e,r);return a>0?Au(e,r+4,r+4+a):""},g4=m4,x4=function(e,r){return PE(e,r)},Rf=x4,Ip=function(r){return Array.isArray(r)||typeof Uint8Array!="undefined"&&r instanceof Uint8Array};Na&&(o4=function(r,a){if(!Buffer.isBuffer(r))return i4(r,a);var n=r.readUInt32LE(a);return n>0?r.toString("utf8",a+4,a+4+n-1):""},c4=function(r,a){if(!Buffer.isBuffer(r))return l4(r,a);var n=r.readUInt32LE(a);return n>0?r.toString("utf8",a+4,a+4+n-1):""},u4=function(r,a){if(!Buffer.isBuffer(r))return d4(r,a);var n=2*r.readUInt32LE(a);return r.toString("utf16le",a+4,a+4+n-1)},f4=function(r,a){if(!Buffer.isBuffer(r))return h4(r,a);var n=r.readUInt32LE(a);return r.toString("utf16le",a+4,a+4+n)},g4=function(r,a){if(!Buffer.isBuffer(r))return m4(r,a);var n=r.readUInt32LE(a);return r.toString("utf8",a+4,a+4+n)},Rf=function(r,a){return Buffer.isBuffer(r)?r.readDoubleLE(a):x4(r,a)},Ip=function(r){return Buffer.isBuffer(r)||Array.isArray(r)||typeof Uint8Array!="undefined"&&r instanceof Uint8Array});var Ed=function(e,r){return e[r]},K0=function(e,r){return e[r+1]*256+e[r]},BE=function(e,r){var a=e[r+1]*256+e[r];return a<32768?a:(65535-a+1)*-1},gi=function(e,r){return e[r+3]*(1<<24)+(e[r+2]<<16)+(e[r+1]<<8)+e[r]},_c=function(e,r){return e[r+3]<<24|e[r+2]<<16|e[r+1]<<8|e[r]},UE=function(e,r){return e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3]};function iu(e,r){var a="",n,i,c=[],u,g,y,x;switch(r){case"dbcs":if(x=this.l,Na&&Buffer.isBuffer(this))a=this.slice(this.l,this.l+2*e).toString("utf16le");else for(y=0;y<e;++y)a+=String.fromCharCode(K0(this,x)),x+=2;e*=2;break;case"utf8":a=Au(this,this.l,this.l+e);break;case"utf16le":e*=2,a=Lp(this,this.l,this.l+e);break;case"wstr":return iu.call(this,e,"dbcs");case"lpstr-ansi":a=o4(this,this.l),e=4+gi(this,this.l);break;case"lpstr-cp":a=c4(this,this.l),e=4+gi(this,this.l);break;case"lpwstr":a=u4(this,this.l),e=4+2*gi(this,this.l);break;case"lpp4":e=4+gi(this,this.l),a=f4(this,this.l),e&2&&(e+=2);break;case"8lpp4":e=4+gi(this,this.l),a=g4(this,this.l),e&3&&(e+=4-(e&3));break;case"cstr":for(e=0,a="";(u=Ed(this,this.l+e++))!==0;)c.push(Zh(u));a=c.join("");break;case"_wstr":for(e=0,a="";(u=K0(this,this.l+e))!==0;)c.push(Zh(u)),e+=2;e+=2,a=c.join("");break;case"dbcs-cont":for(a="",x=this.l,y=0;y<e;++y){if(this.lens&&this.lens.indexOf(x)!==-1)return u=Ed(this,x),this.l=x+1,g=iu.call(this,e-y,u?"dbcs-cont":"sbcs-cont"),c.join("")+g;c.push(Zh(K0(this,x))),x+=2}a=c.join(""),e*=2;break;case"cpstr":case"sbcs-cont":for(a="",x=this.l,y=0;y!=e;++y){if(this.lens&&this.lens.indexOf(x)!==-1)return u=Ed(this,x),this.l=x+1,g=iu.call(this,e-y,u?"dbcs-cont":"sbcs-cont"),c.join("")+g;c.push(Zh(Ed(this,x))),x+=1}a=c.join("");break;default:switch(e){case 1:return n=Ed(this,this.l),this.l++,n;case 2:return n=(r==="i"?BE:K0)(this,this.l),this.l+=2,n;case 4:case-4:return r==="i"||(this[this.l+3]&128)===0?(n=(e>0?_c:UE)(this,this.l),this.l+=4,n):(i=gi(this,this.l),this.l+=4,i);case 8:case-8:if(r==="f")return e==8?i=Rf(this,this.l):i=Rf([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;e=8;case 16:a=s4(this,this.l,e);break}}return this.l+=e,a}var zE=function(e,r,a){e[a]=r&255,e[a+1]=r>>>8&255,e[a+2]=r>>>16&255,e[a+3]=r>>>24&255},HE=function(e,r,a){e[a]=r&255,e[a+1]=r>>8&255,e[a+2]=r>>16&255,e[a+3]=r>>24&255},VE=function(e,r,a){e[a]=r&255,e[a+1]=r>>>8&255};function WE(e,r,a){var n=0,i=0;if(a==="dbcs"){for(i=0;i!=r.length;++i)VE(this,r.charCodeAt(i),this.l+2*i);n=2*r.length}else if(a==="sbcs"){for(r=r.replace(/[^\x00-\x7F]/g,"_"),i=0;i!=r.length;++i)this[this.l+i]=r.charCodeAt(i)&255;n=r.length}else if(a==="hex"){for(;i<e;++i)this[this.l++]=parseInt(r.slice(2*i,2*i+2),16)||0;return this}else if(a==="utf16le"){var c=Math.min(this.l+e,this.length);for(i=0;i<Math.min(r.length,e);++i){var u=r.charCodeAt(i);this[this.l++]=u&255,this[this.l++]=u>>8}for(;this.l<c;)this[this.l++]=0;return this}else switch(e){case 1:n=1,this[this.l]=r&255;break;case 2:n=2,this[this.l]=r&255,r>>>=8,this[this.l+1]=r&255;break;case 3:n=3,this[this.l]=r&255,r>>>=8,this[this.l+1]=r&255,r>>>=8,this[this.l+2]=r&255;break;case 4:n=4,zE(this,r,this.l);break;case 8:if(n=8,a==="f"){FE(this,r,this.l);break}case 16:break;case-4:n=4,HE(this,r,this.l);break}return this.l+=n,this}function p4(e,r){var a=s4(this,this.l,e.length>>1);if(a!==e)throw new Error(r+"Expected "+e+" saw "+a);this.l+=e.length>>1}function fi(e,r){e.l=r,e.read_shift=iu,e.chk=p4,e.write_shift=WE}function So(e,r){e.l+=r}function Nt(e){var r=Tc(e);return fi(r,0),r}function Xs(){var e=[],r=Na?256:2048,a=function(x){var k=Nt(x);return fi(k,0),k},n=a(r),i=function(){n&&(n.length>n.l&&(n=n.slice(0,n.l),n.l=n.length),n.length>0&&e.push(n),n=null)},c=function(x){return n&&x<n.length-n.l?n:(i(),n=a(Math.max(x+1,r)))},u=function(){return i(),is(e)},g=function(x){i(),n=x,n.l==null&&(n.l=n.length),c(r)};return{next:c,push:g,end:u,_bufs:e}}function Bt(e,r,a,n){var i=+r,c;if(!isNaN(i)){n||(n=PO[i].p||(a||[]).length||0),c=1+(i>=128?1:0)+1,n>=128&&++c,n>=16384&&++c,n>=2097152&&++c;var u=e.next(c);i<=127?u.write_shift(1,i):(u.write_shift(1,(i&127)+128),u.write_shift(1,i>>7));for(var g=0;g!=4;++g)if(n>=128)u.write_shift(1,(n&127)+128),n>>=7;else{u.write_shift(1,n);break}n>0&&Ip(a)&&e.push(a)}}function ou(e,r,a){var n=Js(e);if(r.s?(n.cRel&&(n.c+=r.s.c),n.rRel&&(n.r+=r.s.r)):(n.cRel&&(n.c+=r.c),n.rRel&&(n.r+=r.r)),!a||a.biff<12){for(;n.c>=256;)n.c-=256;for(;n.r>=65536;)n.r-=65536}return n}function Ev(e,r,a){var n=Js(e);return n.s=ou(n.s,r.s,a),n.e=ou(n.e,r.s,a),n}function lu(e,r){if(e.cRel&&e.c<0)for(e=Js(e);e.c<0;)e.c+=r>8?16384:256;if(e.rRel&&e.r<0)for(e=Js(e);e.r<0;)e.r+=r>8?1048576:r>5?65536:16384;var a=Ma(e);return!e.cRel&&e.cRel!=null&&(a=XE(a)),!e.rRel&&e.rRel!=null&&(a=GE(a)),a}function Ex(e,r){return e.s.r==0&&!e.s.rRel&&e.e.r==(r.biff>=12?1048575:r.biff>=8?65536:16384)&&!e.e.rRel?(e.s.cRel?"":"$")+bs(e.s.c)+":"+(e.e.cRel?"":"$")+bs(e.e.c):e.s.c==0&&!e.s.cRel&&e.e.c==(r.biff>=12?16383:255)&&!e.e.cRel?(e.s.rRel?"":"$")+ls(e.s.r)+":"+(e.e.rRel?"":"$")+ls(e.e.r):lu(e.s,r.biff)+":"+lu(e.e,r.biff)}function Pp(e){return parseInt($E(e),10)-1}function ls(e){return""+(e+1)}function GE(e){return e.replace(/([A-Z]|^)(\d+)$/,"$1$$$2")}function $E(e){return e.replace(/\$(\d+)$/,"$1")}function Fp(e){for(var r=YE(e),a=0,n=0;n!==r.length;++n)a=26*a+r.charCodeAt(n)-64;return a-1}function bs(e){if(e<0)throw new Error("invalid column "+e);var r="";for(++e;e;e=Math.floor((e-1)/26))r=String.fromCharCode((e-1)%26+65)+r;return r}function XE(e){return e.replace(/^([A-Z])/,"$$$1")}function YE(e){return e.replace(/^\$([A-Z])/,"$1")}function ZE(e){return e.replace(/(\$?[A-Z]*)(\$?\d*)/,"$1,$2").split(",")}function Gn(e){for(var r=0,a=0,n=0;n<e.length;++n){var i=e.charCodeAt(n);i>=48&&i<=57?r=10*r+(i-48):i>=65&&i<=90&&(a=26*a+(i-64))}return{c:a-1,r:r-1}}function Ma(e){for(var r=e.c+1,a="";r;r=(r-1)/26|0)a=String.fromCharCode((r-1)%26+65)+a;return a+(e.r+1)}function pi(e){var r=e.indexOf(":");return r==-1?{s:Gn(e),e:Gn(e)}:{s:Gn(e.slice(0,r)),e:Gn(e.slice(r+1))}}function Tn(e,r){return typeof r=="undefined"||typeof r=="number"?Tn(e.s,e.e):(typeof e!="string"&&(e=Ma(e)),typeof r!="string"&&(r=Ma(r)),e==r?e:e+":"+r)}function Ya(e){var r={s:{c:0,r:0},e:{c:0,r:0}},a=0,n=0,i=0,c=e.length;for(a=0;n<c&&!((i=e.charCodeAt(n)-64)<1||i>26);++n)a=26*a+i;for(r.s.c=--a,a=0;n<c&&!((i=e.charCodeAt(n)-48)<0||i>9);++n)a=10*a+i;if(r.s.r=--a,n===c||i!=10)return r.e.c=r.s.c,r.e.r=r.s.r,r;for(++n,a=0;n!=c&&!((i=e.charCodeAt(n)-64)<1||i>26);++n)a=26*a+i;for(r.e.c=--a,a=0;n!=c&&!((i=e.charCodeAt(n)-48)<0||i>9);++n)a=10*a+i;return r.e.r=--a,r}function jv(e,r){var a=e.t=="d"&&r instanceof Date;if(e.z!=null)try{return e.w=Gl(e.z,a?Ks(r):r)}catch(n){}try{return e.w=Gl((e.XF||{}).numFmtId||(a?14:0),a?Ks(r):r)}catch(n){return""+r}}function ol(e,r,a){return e==null||e.t==null||e.t=="z"?"":e.w!==void 0?e.w:(e.t=="d"&&!e.z&&a&&a.dateNF&&(e.z=a.dateNF),e.t=="e"?Ou[e.v]||e.v:r==null?jv(e,e.v):jv(e,r))}function Dc(e,r){var a=r&&r.sheet?r.sheet:"Sheet1",n={};return n[a]=e,{SheetNames:[a],Sheets:n}}function y4(e,r,a){var n=a||{},i=e?Array.isArray(e):n.dense,c=e||(i?[]:{}),u=0,g=0;if(c&&n.origin!=null){if(typeof n.origin=="number")u=n.origin;else{var y=typeof n.origin=="string"?Gn(n.origin):n.origin;u=y.r,g=y.c}c["!ref"]||(c["!ref"]="A1:A1")}var x={s:{c:1e7,r:1e7},e:{c:0,r:0}};if(c["!ref"]){var k=Ya(c["!ref"]);x.s.c=k.s.c,x.s.r=k.s.r,x.e.c=Math.max(x.e.c,k.e.c),x.e.r=Math.max(x.e.r,k.e.r),u==-1&&(x.e.r=u=k.e.r+1)}for(var N=0;N!=r.length;++N)if(r[N]){if(!Array.isArray(r[N]))throw new Error("aoa_to_sheet expects an array of arrays");for(var C=0;C!=r[N].length;++C)if(typeof r[N][C]!="undefined"){var O={v:r[N][C]},D=u+N,A=g+C;if(x.s.r>D&&(x.s.r=D),x.s.c>A&&(x.s.c=A),x.e.r<D&&(x.e.r=D),x.e.c<A&&(x.e.c=A),r[N][C]&&typeof r[N][C]=="object"&&!Array.isArray(r[N][C])&&!(r[N][C]instanceof Date))O=r[N][C];else if(Array.isArray(O.v)&&(O.f=r[N][C][1],O.v=O.v[0]),O.v===null)if(O.f)O.t="n";else if(n.nullError)O.t="e",O.v=0;else if(n.sheetStubs)O.t="z";else continue;else typeof O.v=="number"?O.t="n":typeof O.v=="boolean"?O.t="b":O.v instanceof Date?(O.z=n.dateNF||mn[14],n.cellDates?(O.t="d",O.w=Gl(O.z,Ks(O.v))):(O.t="n",O.v=Ks(O.v),O.w=Gl(O.z,O.v))):O.t="s";if(i)c[D]||(c[D]=[]),c[D][A]&&c[D][A].z&&(O.z=c[D][A].z),c[D][A]=O;else{var I=Ma({c:A,r:D});c[I]&&c[I].z&&(O.z=c[I].z),c[I]=O}}}return x.s.c<1e7&&(c["!ref"]=Tn(x)),c}function Qd(e,r){return y4(null,e,r)}function qE(e){return e.read_shift(4,"i")}function ro(e,r){return r||(r=Nt(4)),r.write_shift(4,e),r}function vs(e){var r=e.read_shift(4);return r===0?"":e.read_shift(r,"dbcs")}function $n(e,r){var a=!1;return r==null&&(a=!0,r=Nt(4+2*e.length)),r.write_shift(4,e.length),e.length>0&&r.write_shift(0,e,"dbcs"),a?r.slice(0,r.l):r}function KE(e){return{ich:e.read_shift(2),ifnt:e.read_shift(2)}}function JE(e,r){return r||(r=Nt(4)),r.write_shift(2,0),r.write_shift(2,0),r}function Bp(e,r){var a=e.l,n=e.read_shift(1),i=vs(e),c=[],u={t:i,h:i};if((n&1)!==0){for(var g=e.read_shift(4),y=0;y!=g;++y)c.push(KE(e));u.r=c}else u.r=[{ich:0,ifnt:0}];return e.l=a+r,u}function QE(e,r){var a=!1;return r==null&&(a=!0,r=Nt(15+4*e.t.length)),r.write_shift(1,0),$n(e.t,r),a?r.slice(0,r.l):r}var ej=Bp;function tj(e,r){var a=!1;return r==null&&(a=!0,r=Nt(23+4*e.t.length)),r.write_shift(1,1),$n(e.t,r),r.write_shift(4,1),JE({},r),a?r.slice(0,r.l):r}function Ii(e){var r=e.read_shift(4),a=e.read_shift(2);return a+=e.read_shift(1)<<16,e.l++,{c:r,iStyleRef:a}}function Lc(e,r){return r==null&&(r=Nt(8)),r.write_shift(-4,e.c),r.write_shift(3,e.iStyleRef||e.s),r.write_shift(1,0),r}function Ic(e){var r=e.read_shift(2);return r+=e.read_shift(1)<<16,e.l++,{c:-1,iStyleRef:r}}function Pc(e,r){return r==null&&(r=Nt(4)),r.write_shift(3,e.iStyleRef||e.s),r.write_shift(1,0),r}var rj=vs,b4=$n;function Up(e){var r=e.read_shift(4);return r===0||r===4294967295?"":e.read_shift(r,"dbcs")}function Mf(e,r){var a=!1;return r==null&&(a=!0,r=Nt(127)),r.write_shift(4,e.length>0?e.length:4294967295),e.length>0&&r.write_shift(0,e,"dbcs"),a?r.slice(0,r.l):r}var aj=vs,tp=Up,zp=Mf;function v4(e){var r=e.slice(e.l,e.l+4),a=r[0]&1,n=r[0]&2;e.l+=4;var i=n===0?Rf([0,0,0,0,r[0]&252,r[1],r[2],r[3]],0):_c(r,0)>>2;return a?i/100:i}function _4(e,r){r==null&&(r=Nt(4));var a=0,n=0,i=e*100;if(e==(e|0)&&e>=-536870912&&e<1<<29?n=1:i==(i|0)&&i>=-536870912&&i<1<<29&&(n=1,a=1),n)r.write_shift(-4,((a?i:e)<<2)+(a+2));else throw new Error("unsupported RkNumber "+e)}function w4(e){var r={s:{},e:{}};return r.s.r=e.read_shift(4),r.e.r=e.read_shift(4),r.s.c=e.read_shift(4),r.e.c=e.read_shift(4),r}function nj(e,r){return r||(r=Nt(16)),r.write_shift(4,e.s.r),r.write_shift(4,e.e.r),r.write_shift(4,e.s.c),r.write_shift(4,e.e.c),r}var Fc=w4,e0=nj;function t0(e){if(e.length-e.l<8)throw"XLS Xnum Buffer underflow";return e.read_shift(8,"f")}function Ac(e,r){return(r||Nt(8)).write_shift(8,e,"f")}function sj(e){var r={},a=e.read_shift(1),n=a>>>1,i=e.read_shift(1),c=e.read_shift(2,"i"),u=e.read_shift(1),g=e.read_shift(1),y=e.read_shift(1);switch(e.l++,n){case 0:r.auto=1;break;case 1:r.index=i;var x=mj[i];x&&(r.rgb=Bv(x));break;case 2:r.rgb=Bv([u,g,y]);break;case 3:r.theme=i;break}return c!=0&&(r.tint=c>0?c/32767:c/32768),r}function Df(e,r){if(r||(r=Nt(8)),!e||e.auto)return r.write_shift(4,0),r.write_shift(4,0),r;e.index!=null?(r.write_shift(1,2),r.write_shift(1,e.index)):e.theme!=null?(r.write_shift(1,6),r.write_shift(1,e.theme)):(r.write_shift(1,5),r.write_shift(1,0));var a=e.tint||0;if(a>0?a*=32767:a<0&&(a*=32768),r.write_shift(2,a),!e.rgb||e.theme!=null)r.write_shift(2,0),r.write_shift(1,0),r.write_shift(1,0);else{var n=e.rgb||"FFFFFF";typeof n=="number"&&(n=("000000"+n.toString(16)).slice(-6)),r.write_shift(1,parseInt(n.slice(0,2),16)),r.write_shift(1,parseInt(n.slice(2,4),16)),r.write_shift(1,parseInt(n.slice(4,6),16)),r.write_shift(1,255)}return r}function ij(e){var r=e.read_shift(1);e.l++;var a={fBold:r&1,fItalic:r&2,fUnderline:r&4,fStrikeout:r&8,fOutline:r&16,fShadow:r&32,fCondense:r&64,fExtend:r&128};return a}function oj(e,r){r||(r=Nt(2));var a=(e.italic?2:0)|(e.strike?8:0)|(e.outline?16:0)|(e.shadow?32:0)|(e.condense?64:0)|(e.extend?128:0);return r.write_shift(1,a),r.write_shift(1,0),r}var k4=2,hi=3,Qh=11,Lf=19,ef=64,lj=65,cj=71,dj=4108,uj=4126,ss=80,Tv={1:{n:"CodePage",t:k4},2:{n:"Category",t:ss},3:{n:"PresentationFormat",t:ss},4:{n:"ByteCount",t:hi},5:{n:"LineCount",t:hi},6:{n:"ParagraphCount",t:hi},7:{n:"SlideCount",t:hi},8:{n:"NoteCount",t:hi},9:{n:"HiddenCount",t:hi},10:{n:"MultimediaClipCount",t:hi},11:{n:"ScaleCrop",t:Qh},12:{n:"HeadingPairs",t:dj},13:{n:"TitlesOfParts",t:uj},14:{n:"Manager",t:ss},15:{n:"Company",t:ss},16:{n:"LinksUpToDate",t:Qh},17:{n:"CharacterCount",t:hi},19:{n:"SharedDoc",t:Qh},22:{n:"HyperlinksChanged",t:Qh},23:{n:"AppVersion",t:hi,p:"version"},24:{n:"DigSig",t:lj},26:{n:"ContentType",t:ss},27:{n:"ContentStatus",t:ss},28:{n:"Language",t:ss},29:{n:"Version",t:ss},255:{},2147483648:{n:"Locale",t:Lf},2147483651:{n:"Behavior",t:Lf},1919054434:{}},Av={1:{n:"CodePage",t:k4},2:{n:"Title",t:ss},3:{n:"Subject",t:ss},4:{n:"Author",t:ss},5:{n:"Keywords",t:ss},6:{n:"Comments",t:ss},7:{n:"Template",t:ss},8:{n:"LastAuthor",t:ss},9:{n:"RevNumber",t:ss},10:{n:"EditTime",t:ef},11:{n:"LastPrinted",t:ef},12:{n:"CreatedDate",t:ef},13:{n:"ModifiedDate",t:ef},14:{n:"PageCount",t:hi},15:{n:"WordCount",t:hi},16:{n:"CharCount",t:hi},17:{n:"Thumbnail",t:cj},18:{n:"Application",t:ss},19:{n:"DocSecurity",t:hi},255:{},2147483648:{n:"Locale",t:Lf},2147483651:{n:"Behavior",t:Lf},1919054434:{}};function hj(e){return e.map(function(r){return[r>>16&255,r>>8&255,r&255]})}var fj=hj([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]),mj=Js(fj),Ou={0:"#NULL!",7:"#DIV/0!",15:"#VALUE!",23:"#REF!",29:"#NAME?",36:"#NUM!",42:"#N/A",43:"#GETTING_DATA",255:"#WTF?"},gj={"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"},tf={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 N4(){return{workbooks:[],sheets:[],charts:[],dialogs:[],macros:[],rels:[],strs:[],comments:[],threadedcomments:[],links:[],coreprops:[],extprops:[],custprops:[],themes:[],styles:[],calcchains:[],vba:[],drawings:[],metadata:[],people:[],TODO:[],xmlns:""}}function S4(e,r){var a=SE(gj),n=[],i;n[n.length]=An,n[n.length]=rr("Types",null,{xmlns:Wn.CT,"xmlns:xsd":Wn.xsd,"xmlns:xsi":Wn.xsi}),n=n.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(y){return rr("Default",null,{Extension:y[0],ContentType:y[1]})}));var c=function(y){e[y]&&e[y].length>0&&(i=e[y][0],n[n.length]=rr("Override",null,{PartName:(i[0]=="/"?"":"/")+i,ContentType:tf[y][r.bookType]||tf[y].xlsx}))},u=function(y){(e[y]||[]).forEach(function(x){n[n.length]=rr("Override",null,{PartName:(x[0]=="/"?"":"/")+x,ContentType:tf[y][r.bookType]||tf[y].xlsx})})},g=function(y){(e[y]||[]).forEach(function(x){n[n.length]=rr("Override",null,{PartName:(x[0]=="/"?"":"/")+x,ContentType:a[y][0]})})};return c("workbooks"),u("sheets"),u("charts"),g("themes"),["strs","styles"].forEach(c),["coreprops","extprops","custprops"].forEach(g),g("vba"),g("comments"),g("threadedcomments"),g("drawings"),u("metadata"),g("people"),n.length>2&&(n[n.length]="</Types>",n[1]=n[1].replace("/>",">")),n.join("")}var va={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 C4(e){var r=e.lastIndexOf("/");return e.slice(0,r+1)+"_rels/"+e.slice(r+1)+".rels"}function Ud(e){var r=[An,rr("Relationships",null,{xmlns:Wn.RELS})];return ds(e["!id"]).forEach(function(a){r[r.length]=rr("Relationship",null,e["!id"][a])}),r.length>2&&(r[r.length]="</Relationships>",r[1]=r[1].replace("/>",">")),r.join("")}function Oa(e,r,a,n,i,c){if(i||(i={}),e["!id"]||(e["!id"]={}),e["!idx"]||(e["!idx"]=1),r<0)for(r=e["!idx"];e["!id"]["rId"+r];++r);if(e["!idx"]=r+1,i.Id="rId"+r,i.Type=n,i.Target=a,[va.HLINK,va.XPATH,va.XMISS].indexOf(i.Type)>-1&&(i.TargetMode="External"),e["!id"][i.Id])throw new Error("Cannot rewrite rId "+r);return e["!id"][i.Id]=i,e[("/"+i.Target).replace("//","/")]=i,r}function xj(e){var r=[An];r.push(`<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.2">
|
||
`),r.push(` <manifest:file-entry manifest:full-path="/" manifest:version="1.2" manifest:media-type="application/vnd.oasis.opendocument.spreadsheet"/>
|
||
`);for(var a=0;a<e.length;++a)r.push(' <manifest:file-entry manifest:full-path="'+e[a][0]+'" manifest:media-type="'+e[a][1]+`"/>
|
||
`);return r.push("</manifest:manifest>"),r.join("")}function Ov(e,r,a){return[' <rdf:Description rdf:about="'+e+`">
|
||
`,' <rdf:type rdf:resource="http://docs.oasis-open.org/ns/office/1.2/meta/'+(a||"odf")+"#"+r+`"/>
|
||
`,` </rdf:Description>
|
||
`].join("")}function pj(e,r){return[' <rdf:Description rdf:about="'+e+`">
|
||
`,' <ns0:hasPart xmlns:ns0="http://docs.oasis-open.org/ns/office/1.2/meta/pkg#" rdf:resource="'+r+`"/>
|
||
`,` </rdf:Description>
|
||
`].join("")}function yj(e){var r=[An];r.push(`<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||
`);for(var a=0;a!=e.length;++a)r.push(Ov(e[a][0],e[a][1])),r.push(pj("",e[a][0]));return r.push(Ov("","Document","pkg")),r.push("</rdf:RDF>"),r.join("")}function E4(){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 '+Cf.version+"</meta:generator></office:meta></office:document-meta>"}var Sc=[["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 jx(e,r,a,n,i){i[e]!=null||r==null||r===""||(i[e]=r,r=Ra(r),n[n.length]=a?rr(e,r,a):os(e,r))}function j4(e,r){var a=r||{},n=[An,rr("cp:coreProperties",null,{"xmlns:cp":Wn.CORE_PROPS,"xmlns:dc":Wn.dc,"xmlns:dcterms":Wn.dcterms,"xmlns:dcmitype":Wn.dcmitype,"xmlns:xsi":Wn.xsi})],i={};if(!e&&!a.Props)return n.join("");e&&(e.CreatedDate!=null&&jx("dcterms:created",typeof e.CreatedDate=="string"?e.CreatedDate:ep(e.CreatedDate,a.WTF),{"xsi:type":"dcterms:W3CDTF"},n,i),e.ModifiedDate!=null&&jx("dcterms:modified",typeof e.ModifiedDate=="string"?e.ModifiedDate:ep(e.ModifiedDate,a.WTF),{"xsi:type":"dcterms:W3CDTF"},n,i));for(var c=0;c!=Sc.length;++c){var u=Sc[c],g=a.Props&&a.Props[u[1]]!=null?a.Props[u[1]]:e?e[u[1]]:null;g===!0?g="1":g===!1?g="0":typeof g=="number"&&(g=String(g)),g!=null&&jx(u[0],g,null,n,i)}return n.length>2&&(n[n.length]="</cp:coreProperties>",n[1]=n[1].replace("/>",">")),n.join("")}var zd=[["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"]],T4=["Worksheets","SheetNames","NamedRanges","DefinedNames","Chartsheets","ChartNames"];function A4(e){var r=[],a=rr;return e||(e={}),e.Application="SheetJS",r[r.length]=An,r[r.length]=rr("Properties",null,{xmlns:Wn.EXT_PROPS,"xmlns:vt":Wn.vt}),zd.forEach(function(n){if(e[n[1]]!==void 0){var i;switch(n[2]){case"string":i=Ra(String(e[n[1]]));break;case"bool":i=e[n[1]]?"true":"false";break}i!==void 0&&(r[r.length]=a(n[0],i))}}),r[r.length]=a("HeadingPairs",a("vt:vector",a("vt:variant","<vt:lpstr>Worksheets</vt:lpstr>")+a("vt:variant",a("vt:i4",String(e.Worksheets))),{size:2,baseType:"variant"})),r[r.length]=a("TitlesOfParts",a("vt:vector",e.SheetNames.map(function(n){return"<vt:lpstr>"+Ra(n)+"</vt:lpstr>"}).join(""),{size:e.Worksheets,baseType:"lpstr"})),r.length>2&&(r[r.length]="</Properties>",r[1]=r[1].replace("/>",">")),r.join("")}function O4(e){var r=[An,rr("Properties",null,{xmlns:Wn.CUST_PROPS,"xmlns:vt":Wn.vt})];if(!e)return r.join("");var a=1;return ds(e).forEach(function(i){++a,r[r.length]=rr("property",IE(e[i]),{fmtid:"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",pid:a,name:Ra(i)})}),r.length>2&&(r[r.length]="</Properties>",r[1]=r[1].replace("/>",">")),r.join("")}var Rv={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 bj(e,r){var a=[];return ds(Rv).map(function(n){for(var i=0;i<Sc.length;++i)if(Sc[i][1]==n)return Sc[i];for(i=0;i<zd.length;++i)if(zd[i][1]==n)return zd[i];throw n}).forEach(function(n){if(e[n[1]]!=null){var i=r&&r.Props&&r.Props[n[1]]!=null?r.Props[n[1]]:e[n[1]];switch(n[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/,"")),a.push(os(Rv[n[1]]||n[1],i))}}),rr("DocumentProperties",a.join(""),{xmlns:mi.o})}function vj(e,r){var a=["Worksheets","SheetNames"],n="CustomDocumentProperties",i=[];return e&&ds(e).forEach(function(c){if(Object.prototype.hasOwnProperty.call(e,c)){for(var u=0;u<Sc.length;++u)if(c==Sc[u][1])return;for(u=0;u<zd.length;++u)if(c==zd[u][1])return;for(u=0;u<a.length;++u)if(c==a[u])return;var g=e[c],y="string";typeof g=="number"?(y="float",g=String(g)):g===!0||g===!1?(y="boolean",g=g?"1":"0"):g=String(g),i.push(rr(bv(c),g,{"dt:dt":y}))}}),r&&ds(r).forEach(function(c){if(Object.prototype.hasOwnProperty.call(r,c)&&!(e&&Object.prototype.hasOwnProperty.call(e,c))){var u=r[c],g="string";typeof u=="number"?(g="float",u=String(u)):u===!0||u===!1?(g="boolean",u=u?"1":"0"):u instanceof Date?(g="dateTime.tz",u=u.toISOString()):u=String(u),i.push(rr(bv(c),u,{"dt:dt":g}))}}),"<"+n+' xmlns="'+mi.o+'">'+i.join("")+"</"+n+">"}function _j(e){var r=typeof e=="string"?new Date(Date.parse(e)):e,a=r.getTime()/1e3+11644473600,n=a%Math.pow(2,32),i=(a-n)/Math.pow(2,32);n*=1e7,i*=1e7;var c=n/Math.pow(2,32)|0;c>0&&(n=n%Math.pow(2,32),i+=c);var u=Nt(8);return u.write_shift(4,n),u.write_shift(4,i),u}function Mv(e,r){var a=Nt(4),n=Nt(4);switch(a.write_shift(4,e==80?31:e),e){case 3:n.write_shift(-4,r);break;case 5:n=Nt(8),n.write_shift(8,r,"f");break;case 11:n.write_shift(4,r?1:0);break;case 64:n=_j(r);break;case 31:case 80:for(n=Nt(4+2*(r.length+1)+(r.length%2?0:2)),n.write_shift(4,r.length+1),n.write_shift(0,r,"dbcs");n.l!=n.length;)n.write_shift(1,0);break;default:throw new Error("TypedPropertyValue unrecognized type "+e+" "+r)}return is([a,n])}var R4=["CodePage","Thumbnail","_PID_LINKBASE","_PID_HLINKS","SystemIdentifier","FMTID"];function wj(e){switch(typeof e){case"boolean":return 11;case"number":return(e|0)==e?3:5;case"string":return 31;case"object":if(e instanceof Date)return 64;break}return-1}function Dv(e,r,a){var n=Nt(8),i=[],c=[],u=8,g=0,y=Nt(8),x=Nt(8);if(y.write_shift(4,2),y.write_shift(4,1200),x.write_shift(4,1),c.push(y),i.push(x),u+=8+y.length,!r){x=Nt(8),x.write_shift(4,0),i.unshift(x);var k=[Nt(4)];for(k[0].write_shift(4,e.length),g=0;g<e.length;++g){var N=e[g][0];for(y=Nt(8+2*(N.length+1)+(N.length%2?0:2)),y.write_shift(4,g+2),y.write_shift(4,N.length+1),y.write_shift(0,N,"dbcs");y.l!=y.length;)y.write_shift(1,0);k.push(y)}y=is(k),c.unshift(y),u+=8+y.length}for(g=0;g<e.length;++g)if(!(r&&!r[e[g][0]])&&!(R4.indexOf(e[g][0])>-1||T4.indexOf(e[g][0])>-1)&&e[g][1]!=null){var C=e[g][1],O=0;if(r){O=+r[e[g][0]];var D=a[O];if(D.p=="version"&&typeof C=="string"){var A=C.split(".");C=(+A[0]<<16)+(+A[1]||0)}y=Mv(D.t,C)}else{var I=wj(C);I==-1&&(I=31,C=String(C)),y=Mv(I,C)}c.push(y),x=Nt(8),x.write_shift(4,r?O:2+g),i.push(x),u+=8+y.length}var z=8*(c.length+1);for(g=0;g<c.length;++g)i[g].write_shift(4,z),z+=c[g].length;return n.write_shift(4,u),n.write_shift(4,c.length),is([n].concat(i).concat(c))}function Lv(e,r,a,n,i,c){var u=Nt(i?68:48),g=[u];u.write_shift(2,65534),u.write_shift(2,0),u.write_shift(4,842412599),u.write_shift(16,Ua.utils.consts.HEADER_CLSID,"hex"),u.write_shift(4,i?2:1),u.write_shift(16,r,"hex"),u.write_shift(4,i?68:48);var y=Dv(e,a,n);if(g.push(y),i){var x=Dv(i,null,null);u.write_shift(16,c,"hex"),u.write_shift(4,68+y.length),g.push(x)}return is(g)}function kj(e,r){r||(r=Nt(e));for(var a=0;a<e;++a)r.write_shift(1,0);return r}function Nj(e,r){return e.read_shift(r)===1}function Ts(e,r){return r||(r=Nt(2)),r.write_shift(2,+!!e),r}function M4(e){return e.read_shift(2,"u")}function Oi(e,r){return r||(r=Nt(2)),r.write_shift(2,e),r}function D4(e,r,a){return a||(a=Nt(2)),a.write_shift(1,r=="e"?+e:+!!e),a.write_shift(1,r=="e"?1:0),a}function L4(e,r,a){var n=e.read_shift(a&&a.biff>=12?2:1),i="sbcs-cont";if(a&&a.biff>=8,!a||a.biff==8){var c=e.read_shift(1);c&&(i="dbcs-cont")}else a.biff==12&&(i="wstr");a.biff>=2&&a.biff<=5&&(i="cpstr");var u=n?e.read_shift(n,i):"";return u}function Sj(e){var r=e.t||"",a=Nt(3);a.write_shift(2,r.length),a.write_shift(1,1);var n=Nt(2*r.length);n.write_shift(2*r.length,r,"utf16le");var i=[a,n];return is(i)}function Cj(e,r,a){var n;if(a){if(a.biff>=2&&a.biff<=5)return e.read_shift(r,"cpstr");if(a.biff>=12)return e.read_shift(r,"dbcs-cont")}var i=e.read_shift(1);return i===0?n=e.read_shift(r,"sbcs-cont"):n=e.read_shift(r,"dbcs-cont"),n}function Ej(e,r,a){var n=e.read_shift(a&&a.biff==2?1:2);return n===0?(e.l++,""):Cj(e,n,a)}function jj(e,r,a){if(a.biff>5)return Ej(e,r,a);var n=e.read_shift(1);return n===0?(e.l++,""):e.read_shift(n,a.biff<=4||!e.lens?"cpstr":"sbcs-cont")}function I4(e,r,a){return a||(a=Nt(3+2*e.length)),a.write_shift(2,e.length),a.write_shift(1,1),a.write_shift(31,e,"utf16le"),a}function Iv(e,r){r||(r=Nt(6+e.length*2)),r.write_shift(4,1+e.length);for(var a=0;a<e.length;++a)r.write_shift(2,e.charCodeAt(a));return r.write_shift(2,0),r}function Tj(e){var r=Nt(512),a=0,n=e.Target;n.slice(0,7)=="file://"&&(n=n.slice(7));var i=n.indexOf("#"),c=i>-1?31:23;switch(n.charAt(0)){case"#":c=28;break;case".":c&=-3;break}r.write_shift(4,2),r.write_shift(4,c);var u=[8,6815827,6619237,4849780,83];for(a=0;a<u.length;++a)r.write_shift(4,u[a]);if(c==28)n=n.slice(1),Iv(n,r);else if(c&2){for(u="e0 c9 ea 79 f9 ba ce 11 8c 82 00 aa 00 4b a9 0b".split(" "),a=0;a<u.length;++a)r.write_shift(1,parseInt(u[a],16));var g=i>-1?n.slice(0,i):n;for(r.write_shift(4,2*(g.length+1)),a=0;a<g.length;++a)r.write_shift(2,g.charCodeAt(a));r.write_shift(2,0),c&8&&Iv(i>-1?n.slice(i+1):"",r)}else{for(u="03 03 00 00 00 00 00 00 c0 00 00 00 00 00 00 46".split(" "),a=0;a<u.length;++a)r.write_shift(1,parseInt(u[a],16));for(var y=0;n.slice(y*3,y*3+3)=="../"||n.slice(y*3,y*3+3)=="..\\";)++y;for(r.write_shift(2,y),r.write_shift(4,n.length-3*y+1),a=0;a<n.length-3*y;++a)r.write_shift(1,n.charCodeAt(a+3*y)&255);for(r.write_shift(1,0),r.write_shift(2,65535),r.write_shift(2,57005),a=0;a<6;++a)r.write_shift(4,0)}return r.slice(0,r.l)}function Oc(e,r,a,n){return n||(n=Nt(6)),n.write_shift(2,e),n.write_shift(2,r),n.write_shift(2,a||0),n}function Aj(e,r,a){var n=a.biff>8?4:2,i=e.read_shift(n),c=e.read_shift(n,"i"),u=e.read_shift(n,"i");return[i,c,u]}function Oj(e){var r=e.read_shift(2),a=e.read_shift(2),n=e.read_shift(2),i=e.read_shift(2);return{s:{c:n,r},e:{c:i,r:a}}}function P4(e,r){return r||(r=Nt(8)),r.write_shift(2,e.s.r),r.write_shift(2,e.e.r),r.write_shift(2,e.s.c),r.write_shift(2,e.e.c),r}function Hp(e,r,a){var n=1536,i=16;switch(a.bookType){case"biff8":break;case"biff5":n=1280,i=8;break;case"biff4":n=4,i=6;break;case"biff3":n=3,i=6;break;case"biff2":n=2,i=4;break;case"xla":break;default:throw new Error("unsupported BIFF version")}var c=Nt(i);return c.write_shift(2,n),c.write_shift(2,r),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 Rj(e,r){var a=!r||r.biff==8,n=Nt(a?112:54);for(n.write_shift(r.biff==8?2:1,7),a&&n.write_shift(1,0),n.write_shift(4,859007059),n.write_shift(4,5458548|(a?0:536870912));n.l<n.length;)n.write_shift(1,a?0:32);return n}function Mj(e,r){var a=!r||r.biff>=8?2:1,n=Nt(8+a*e.name.length);n.write_shift(4,e.pos),n.write_shift(1,e.hs||0),n.write_shift(1,e.dt),n.write_shift(1,e.name.length),r.biff>=8&&n.write_shift(1,1),n.write_shift(a*e.name.length,e.name,r.biff<8?"sbcs":"utf16le");var i=n.slice(0,n.l);return i.l=n.l,i}function Dj(e,r){var a=Nt(8);a.write_shift(4,e.Count),a.write_shift(4,e.Unique);for(var n=[],i=0;i<e.length;++i)n[i]=Sj(e[i]);var c=is([a].concat(n));return c.parts=[a.length].concat(n.map(function(u){return u.length})),c}function Lj(){var e=Nt(18);return e.write_shift(2,0),e.write_shift(2,0),e.write_shift(2,29280),e.write_shift(2,17600),e.write_shift(2,56),e.write_shift(2,0),e.write_shift(2,0),e.write_shift(2,1),e.write_shift(2,500),e}function Ij(e){var r=Nt(18),a=1718;return e&&e.RTL&&(a|=64),r.write_shift(2,a),r.write_shift(4,0),r.write_shift(4,64),r.write_shift(4,0),r.write_shift(4,0),r}function Pj(e,r){var a=e.name||"Arial",n=r&&r.biff==5,i=n?15+a.length:16+2*a.length,c=Nt(i);return c.write_shift(2,e.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,a.length),n||c.write_shift(1,1),c.write_shift((n?1:2)*a.length,a,n?"sbcs":"utf16le"),c}function Fj(e,r,a,n){var i=Nt(10);return Oc(e,r,n,i),i.write_shift(4,a),i}function Bj(e,r,a,n,i){var c=!i||i.biff==8,u=Nt(8+ +c+(1+c)*a.length);return Oc(e,r,n,u),u.write_shift(2,a.length),c&&u.write_shift(1,1),u.write_shift((1+c)*a.length,a,c?"utf16le":"sbcs"),u}function Uj(e,r,a,n){var i=a&&a.biff==5;n||(n=Nt(i?3+r.length:5+2*r.length)),n.write_shift(2,e),n.write_shift(i?1:2,r.length),i||n.write_shift(1,1),n.write_shift((i?1:2)*r.length,r,i?"sbcs":"utf16le");var c=n.length>n.l?n.slice(0,n.l):n;return c.l==null&&(c.l=c.length),c}function zj(e,r){var a=r.biff==8||!r.biff?4:2,n=Nt(2*a+6);return n.write_shift(a,e.s.r),n.write_shift(a,e.e.r+1),n.write_shift(2,e.s.c),n.write_shift(2,e.e.c+1),n.write_shift(2,0),n}function Pv(e,r,a,n){var i=a&&a.biff==5;n||(n=Nt(i?16:20)),n.write_shift(2,0),e.style?(n.write_shift(2,e.numFmtId||0),n.write_shift(2,65524)):(n.write_shift(2,e.numFmtId||0),n.write_shift(2,r<<4));var c=0;return e.numFmtId>0&&i&&(c|=1024),n.write_shift(4,c),n.write_shift(4,0),i||n.write_shift(4,0),n.write_shift(2,0),n}function Hj(e){var r=Nt(8);return r.write_shift(4,0),r.write_shift(2,0),r.write_shift(2,0),r}function Vj(e,r,a,n,i,c){var u=Nt(8);return Oc(e,r,n,u),D4(a,c,u),u}function Wj(e,r,a,n){var i=Nt(14);return Oc(e,r,n,i),Ac(a,i),i}function Gj(e,r,a){if(a.biff<8)return $j(e,r,a);for(var n=[],i=e.l+r,c=e.read_shift(a.biff>8?4:2);c--!==0;)n.push(Aj(e,a.biff>8?12:6,a));if(e.l!=i)throw new Error("Bad ExternSheet: "+e.l+" != "+i);return n}function $j(e,r,a){e[e.l+1]==3&&e[e.l]++;var n=L4(e,r,a);return n.charCodeAt(0)==3?n.slice(1):n}function Xj(e){var r=Nt(2+e.length*8);r.write_shift(2,e.length);for(var a=0;a<e.length;++a)P4(e[a],r);return r}function Yj(e){var r=Nt(24),a=Gn(e[0]);r.write_shift(2,a.r),r.write_shift(2,a.r),r.write_shift(2,a.c),r.write_shift(2,a.c);for(var n="d0 c9 ea 79 f9 ba ce 11 8c 82 00 aa 00 4b a9 0b".split(" "),i=0;i<16;++i)r.write_shift(1,parseInt(n[i],16));return is([r,Tj(e[1])])}function Zj(e){var r=e[1].Tooltip,a=Nt(10+2*(r.length+1));a.write_shift(2,2048);var n=Gn(e[0]);a.write_shift(2,n.r),a.write_shift(2,n.r),a.write_shift(2,n.c),a.write_shift(2,n.c);for(var i=0;i<r.length;++i)a.write_shift(2,r.charCodeAt(i));return a.write_shift(2,0),a}function qj(e){return e||(e=Nt(4)),e.write_shift(2,1),e.write_shift(2,1),e}function Kj(e,r,a){if(!a.cellStyles)return So(e,r);var n=a&&a.biff>=12?4:2,i=e.read_shift(n),c=e.read_shift(n),u=e.read_shift(n),g=e.read_shift(n),y=e.read_shift(2);n==2&&(e.l+=2);var x={s:i,e:c,w:u,ixfe:g,flags:y};return(a.biff>=5||!a.biff)&&(x.level=y>>8&7),x}function Jj(e,r){var a=Nt(12);a.write_shift(2,r),a.write_shift(2,r),a.write_shift(2,e.width*256),a.write_shift(2,0);var n=0;return e.hidden&&(n|=1),a.write_shift(1,n),n=e.level||0,a.write_shift(1,n),a.write_shift(2,0),a}function Qj(e){for(var r=Nt(2*e),a=0;a<e;++a)r.write_shift(2,a+1);return r}function eT(e,r,a){var n=Nt(15);return Mu(n,e,r),n.write_shift(8,a,"f"),n}function tT(e,r,a){var n=Nt(9);return Mu(n,e,r),n.write_shift(2,a),n}var rT=(function(){var e={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},r=Op({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 a(g,y){var x=[],k=Tc(1);switch(y.type){case"base64":k=Qi(il(g));break;case"binary":k=Qi(g);break;case"buffer":case"array":k=g;break}fi(k,0);var N=k.read_shift(1),C=!!(N&136),O=!1,D=!1;switch(N){case 2:break;case 3:break;case 48:O=!0,C=!0;break;case 49:O=!0,C=!0;break;case 131:break;case 139:break;case 140:D=!0;break;case 245:break;default:throw new Error("DBF Unsupported Version: "+N.toString(16))}var A=0,I=521;N==2&&(A=k.read_shift(2)),k.l+=3,N!=2&&(A=k.read_shift(4)),A>1048576&&(A=1e6),N!=2&&(I=k.read_shift(2));var z=k.read_shift(2),U=y.codepage||1252;N!=2&&(k.l+=16,k.read_shift(1),k[k.l]!==0&&(U=e[k[k.l]]),k.l+=1,k.l+=2),D&&(k.l+=36);for(var B=[],V={},Z=Math.min(k.length,N==2?521:I-10-(O?264:0)),W=D?32:11;k.l<Z&&k[k.l]!=13;)switch(V={},V.name=Ef.utils.decode(U,k.slice(k.l,k.l+W)).replace(/[\u0000\r\n].*$/g,""),k.l+=W,V.type=String.fromCharCode(k.read_shift(1)),N!=2&&!D&&(V.offset=k.read_shift(4)),V.len=k.read_shift(1),N==2&&(V.offset=k.read_shift(2)),V.dec=k.read_shift(1),V.name.length&&B.push(V),N!=2&&(k.l+=D?13:14),V.type){case"B":(!O||V.len!=8)&&y.WTF&&console.log("Skipping "+V.name+":"+V.type);break;case"G":case"P":y.WTF&&console.log("Skipping "+V.name+":"+V.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: "+V.type)}if(k[k.l]!==13&&(k.l=I-1),k.read_shift(1)!==13)throw new Error("DBF Terminator not found "+k.l+" "+k[k.l]);k.l=I;var H=0,le=0;for(x[0]=[],le=0;le!=B.length;++le)x[0][le]=B[le].name;for(;A-- >0;){if(k[k.l]===42){k.l+=z;continue}for(++k.l,x[++H]=[],le=0,le=0;le!=B.length;++le){var Q=k.slice(k.l,k.l+B[le].len);k.l+=B[le].len,fi(Q,0);var Ne=Ef.utils.decode(U,Q);switch(B[le].type){case"C":Ne.trim().length&&(x[H][le]=Ne.replace(/\s+$/,""));break;case"D":Ne.length===8?x[H][le]=new Date(+Ne.slice(0,4),+Ne.slice(4,6)-1,+Ne.slice(6,8)):x[H][le]=Ne;break;case"F":x[H][le]=parseFloat(Ne.trim());break;case"+":case"I":x[H][le]=D?Q.read_shift(-4,"i")^2147483648:Q.read_shift(4,"i");break;case"L":switch(Ne.trim().toUpperCase()){case"Y":case"T":x[H][le]=!0;break;case"N":case"F":x[H][le]=!1;break;case"":case"?":break;default:throw new Error("DBF Unrecognized L:|"+Ne+"|")}break;case"M":if(!C)throw new Error("DBF Unexpected MEMO for type "+N.toString(16));x[H][le]="##MEMO##"+(D?parseInt(Ne.trim(),10):Q.read_shift(4));break;case"N":Ne=Ne.replace(/\u0000/g,"").trim(),Ne&&Ne!="."&&(x[H][le]=+Ne||0);break;case"@":x[H][le]=new Date(Q.read_shift(-8,"f")-621356832e5);break;case"T":x[H][le]=new Date((Q.read_shift(4)-2440588)*864e5+Q.read_shift(4));break;case"Y":x[H][le]=Q.read_shift(4,"i")/1e4+Q.read_shift(4,"i")/1e4*Math.pow(2,32);break;case"O":x[H][le]=-Q.read_shift(-8,"f");break;case"B":if(O&&B[le].len==8){x[H][le]=Q.read_shift(8,"f");break}case"G":case"P":Q.l+=B[le].len;break;case"0":if(B[le].name==="_NullFlags")break;default:throw new Error("DBF Unsupported data type "+B[le].type)}}}if(N!=2&&k.l<k.length&&k[k.l++]!=26)throw new Error("DBF EOF Marker missing "+(k.l-1)+" of "+k.length+" "+k[k.l-1].toString(16));return y&&y.sheetRows&&(x=x.slice(0,y.sheetRows)),y.DBF=B,x}function n(g,y){var x=y||{};x.dateNF||(x.dateNF="yyyymmdd");var k=Qd(a(g,x),x);return k["!cols"]=x.DBF.map(function(N){return{wch:N.len,DBF:N}}),delete x.DBF,k}function i(g,y){try{return Dc(n(g,y),y)}catch(x){if(y&&y.WTF)throw x}return{SheetNames:[],Sheets:{}}}var c={B:8,C:250,L:1,D:8,"?":0,"":0};function u(g,y){var x=y||{};if(+x.codepage>=0&&mu(+x.codepage),x.type=="string")throw new Error("Cannot write DBF to JS string");var k=Xs(),N=Uf(g,{header:1,raw:!0,cellDates:!0}),C=N[0],O=N.slice(1),D=g["!cols"]||[],A=0,I=0,z=0,U=1;for(A=0;A<C.length;++A){if(((D[A]||{}).DBF||{}).name){C[A]=D[A].DBF.name,++z;continue}if(C[A]!=null){if(++z,typeof C[A]=="number"&&(C[A]=C[A].toString(10)),typeof C[A]!="string")throw new Error("DBF Invalid column name "+C[A]+" |"+typeof C[A]+"|");if(C.indexOf(C[A])!==A){for(I=0;I<1024;++I)if(C.indexOf(C[A]+"_"+I)==-1){C[A]+="_"+I;break}}}}var B=Ya(g["!ref"]),V=[],Z=[],W=[];for(A=0;A<=B.e.c-B.s.c;++A){var H="",le="",Q=0,Ne=[];for(I=0;I<O.length;++I)O[I][A]!=null&&Ne.push(O[I][A]);if(Ne.length==0||C[A]==null){V[A]="?";continue}for(I=0;I<Ne.length;++I){switch(typeof Ne[I]){case"number":le="B";break;case"string":le="C";break;case"boolean":le="L";break;case"object":le=Ne[I]instanceof Date?"D":"C";break;default:le="C"}Q=Math.max(Q,String(Ne[I]).length),H=H&&H!=le?"C":le}Q>250&&(Q=250),le=((D[A]||{}).DBF||{}).type,le=="C"&&D[A].DBF.len>Q&&(Q=D[A].DBF.len),H=="B"&&le=="N"&&(H="N",W[A]=D[A].DBF.dec,Q=D[A].DBF.len),Z[A]=H=="C"||le=="N"?Q:c[H]||0,U+=Z[A],V[A]=H}var oe=k.next(32);for(oe.write_shift(4,318902576),oe.write_shift(4,O.length),oe.write_shift(2,296+32*z),oe.write_shift(2,U),A=0;A<4;++A)oe.write_shift(4,0);for(oe.write_shift(4,0|(+r[Bw]||3)<<8),A=0,I=0;A<C.length;++A)if(C[A]!=null){var se=k.next(32),ce=(C[A].slice(-10)+"\0\0\0\0\0\0\0\0\0\0\0").slice(0,11);se.write_shift(1,ce,"sbcs"),se.write_shift(1,V[A]=="?"?"C":V[A],"sbcs"),se.write_shift(4,I),se.write_shift(1,Z[A]||c[V[A]]||0),se.write_shift(1,W[A]||0),se.write_shift(1,2),se.write_shift(4,0),se.write_shift(1,0),se.write_shift(4,0),se.write_shift(4,0),I+=Z[A]||c[V[A]]||0}var Ce=k.next(264);for(Ce.write_shift(4,13),A=0;A<65;++A)Ce.write_shift(4,0);for(A=0;A<O.length;++A){var ae=k.next(U);for(ae.write_shift(1,0),I=0;I<C.length;++I)if(C[I]!=null)switch(V[I]){case"L":ae.write_shift(1,O[A][I]==null?63:O[A][I]?84:70);break;case"B":ae.write_shift(8,O[A][I]||0,"f");break;case"N":var me="0";for(typeof O[A][I]=="number"&&(me=O[A][I].toFixed(W[I]||0)),z=0;z<Z[I]-me.length;++z)ae.write_shift(1,32);ae.write_shift(1,me,"sbcs");break;case"D":O[A][I]?(ae.write_shift(4,("0000"+O[A][I].getFullYear()).slice(-4),"sbcs"),ae.write_shift(2,("00"+(O[A][I].getMonth()+1)).slice(-2),"sbcs"),ae.write_shift(2,("00"+O[A][I].getDate()).slice(-2),"sbcs")):ae.write_shift(8,"00000000","sbcs");break;case"C":var K=String(O[A][I]!=null?O[A][I]:"").slice(0,Z[I]);for(ae.write_shift(1,K,"sbcs"),z=0;z<Z[I]-K.length;++z)ae.write_shift(1,32);break}}return k.next(1).write_shift(1,26),k.end()}return{to_workbook:i,to_sheet:n,from_sheet:u}})(),aT=(function(){var e={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},r=new RegExp("\x1BN("+ds(e).join("|").replace(/\|\|\|/,"|\\||").replace(/([?()+])/g,"\\$1")+"|\\|)","gm"),a=function(C,O){var D=e[O];return typeof D=="number"?ov(D):D},n=function(C,O,D){var A=O.charCodeAt(0)-32<<4|D.charCodeAt(0)-48;return A==59?C:ov(A)};e["|"]=254;function i(C,O){switch(O.type){case"base64":return c(il(C),O);case"binary":return c(C,O);case"buffer":return c(Na&&Buffer.isBuffer(C)?C.toString("binary"):ju(C),O);case"array":return c(sm(C),O)}throw new Error("Unrecognized type "+O.type)}function c(C,O){var D=C.split(/[\n\r]+/),A=-1,I=-1,z=0,U=0,B=[],V=[],Z=null,W={},H=[],le=[],Q=[],Ne=0,oe;for(+O.codepage>=0&&mu(+O.codepage);z!==D.length;++z){Ne=0;var se=D[z].trim().replace(/\x1B([\x20-\x2F])([\x30-\x3F])/g,n).replace(r,a),ce=se.replace(/;;/g,"\0").split(";").map(function(ne){return ne.replace(/\u0000/g,";")}),Ce=ce[0],ae;if(se.length>0)switch(Ce){case"ID":break;case"E":break;case"B":break;case"O":break;case"W":break;case"P":ce[1].charAt(0)=="P"&&V.push(se.slice(3).replace(/;;/g,";"));break;case"C":var me=!1,K=!1,fe=!1,Oe=!1,ye=-1,J=-1;for(U=1;U<ce.length;++U)switch(ce[U].charAt(0)){case"A":break;case"X":I=parseInt(ce[U].slice(1))-1,K=!0;break;case"Y":for(A=parseInt(ce[U].slice(1))-1,K||(I=0),oe=B.length;oe<=A;++oe)B[oe]=[];break;case"K":ae=ce[U].slice(1),ae.charAt(0)==='"'?ae=ae.slice(1,ae.length-1):ae==="TRUE"?ae=!0:ae==="FALSE"?ae=!1:isNaN(el(ae))?isNaN(xu(ae).getDate())||(ae=Os(ae)):(ae=el(ae),Z!==null&&Kw(Z)&&(ae=t4(ae))),me=!0;break;case"E":Oe=!0;var G=tA(ce[U].slice(1),{r:A,c:I});B[A][I]=[B[A][I],G];break;case"S":fe=!0,B[A][I]=[B[A][I],"S5S"];break;case"G":break;case"R":ye=parseInt(ce[U].slice(1))-1;break;case"C":J=parseInt(ce[U].slice(1))-1;break;default:if(O&&O.WTF)throw new Error("SYLK bad record "+se)}if(me&&(B[A][I]&&B[A][I].length==2?B[A][I][0]=ae:B[A][I]=ae,Z=null),fe){if(Oe)throw new Error("SYLK shared formula cannot have own formula");var ie=ye>-1&&B[ye][J];if(!ie||!ie[1])throw new Error("SYLK shared formula cannot find base");B[A][I][1]=rA(ie[1],{r:A-ye,c:I-J})}break;case"F":var re=0;for(U=1;U<ce.length;++U)switch(ce[U].charAt(0)){case"X":I=parseInt(ce[U].slice(1))-1,++re;break;case"Y":for(A=parseInt(ce[U].slice(1))-1,oe=B.length;oe<=A;++oe)B[oe]=[];break;case"M":Ne=parseInt(ce[U].slice(1))/20;break;case"F":break;case"G":break;case"P":Z=V[parseInt(ce[U].slice(1))];break;case"S":break;case"D":break;case"N":break;case"W":for(Q=ce[U].slice(1).split(" "),oe=parseInt(Q[0],10);oe<=parseInt(Q[1],10);++oe)Ne=parseInt(Q[2],10),le[oe-1]=Ne===0?{hidden:!0}:{wch:Ne},Vp(le[oe-1]);break;case"C":I=parseInt(ce[U].slice(1))-1,le[I]||(le[I]={});break;case"R":A=parseInt(ce[U].slice(1))-1,H[A]||(H[A]={}),Ne>0?(H[A].hpt=Ne,H[A].hpx=H4(Ne)):Ne===0&&(H[A].hidden=!0);break;default:if(O&&O.WTF)throw new Error("SYLK bad record "+se)}re<1&&(Z=null);break;default:if(O&&O.WTF)throw new Error("SYLK bad record "+se)}}return H.length>0&&(W["!rows"]=H),le.length>0&&(W["!cols"]=le),O&&O.sheetRows&&(B=B.slice(0,O.sheetRows)),[B,W]}function u(C,O){var D=i(C,O),A=D[0],I=D[1],z=Qd(A,O);return ds(I).forEach(function(U){z[U]=I[U]}),z}function g(C,O){return Dc(u(C,O),O)}function y(C,O,D,A){var I="C;Y"+(D+1)+";X"+(A+1)+";K";switch(C.t){case"n":I+=C.v||0,C.f&&!C.F&&(I+=";E"+Gp(C.f,{r:D,c:A}));break;case"b":I+=C.v?"TRUE":"FALSE";break;case"e":I+=C.w||C.v;break;case"d":I+='"'+(C.w||C.v)+'"';break;case"s":I+='"'+C.v.replace(/"/g,"").replace(/;/g,";;")+'"';break}return I}function x(C,O){O.forEach(function(D,A){var I="F;W"+(A+1)+" "+(A+1)+" ";D.hidden?I+="0":(typeof D.width=="number"&&!D.wpx&&(D.wpx=If(D.width)),typeof D.wpx=="number"&&!D.wch&&(D.wch=Pf(D.wpx)),typeof D.wch=="number"&&(I+=Math.round(D.wch))),I.charAt(I.length-1)!=" "&&C.push(I)})}function k(C,O){O.forEach(function(D,A){var I="F;";D.hidden?I+="M0;":D.hpt?I+="M"+20*D.hpt+";":D.hpx&&(I+="M"+20*Ff(D.hpx)+";"),I.length>2&&C.push(I+"R"+(A+1))})}function N(C,O){var D=["ID;PWXL;N;E"],A=[],I=Ya(C["!ref"]),z,U=Array.isArray(C),B=`\r
|
||
`;D.push("P;PGeneral"),D.push("F;P0;DG0G8;M255"),C["!cols"]&&x(D,C["!cols"]),C["!rows"]&&k(D,C["!rows"]),D.push("B;Y"+(I.e.r-I.s.r+1)+";X"+(I.e.c-I.s.c+1)+";D"+[I.s.c,I.s.r,I.e.c,I.e.r].join(" "));for(var V=I.s.r;V<=I.e.r;++V)for(var Z=I.s.c;Z<=I.e.c;++Z){var W=Ma({r:V,c:Z});z=U?(C[V]||[])[Z]:C[W],!(!z||z.v==null&&(!z.f||z.F))&&A.push(y(z,C,V,Z))}return D.join(B)+B+A.join(B)+B+"E"+B}return{to_workbook:g,to_sheet:u,from_sheet:N}})(),nT=(function(){function e(c,u){switch(u.type){case"base64":return r(il(c),u);case"binary":return r(c,u);case"buffer":return r(Na&&Buffer.isBuffer(c)?c.toString("binary"):ju(c),u);case"array":return r(sm(c),u)}throw new Error("Unrecognized type "+u.type)}function r(c,u){for(var g=c.split(`
|
||
`),y=-1,x=-1,k=0,N=[];k!==g.length;++k){if(g[k].trim()==="BOT"){N[++y]=[],x=0;continue}if(!(y<0)){var C=g[k].trim().split(","),O=C[0],D=C[1];++k;for(var A=g[k]||"";(A.match(/["]/g)||[]).length&1&&k<g.length-1;)A+=`
|
||
`+g[++k];switch(A=A.trim(),+O){case-1:if(A==="BOT"){N[++y]=[],x=0;continue}else if(A!=="EOD")throw new Error("Unrecognized DIF special command "+A);break;case 0:A==="TRUE"?N[y][x]=!0:A==="FALSE"?N[y][x]=!1:isNaN(el(D))?isNaN(xu(D).getDate())?N[y][x]=D:N[y][x]=Os(D):N[y][x]=el(D),++x;break;case 1:A=A.slice(1,A.length-1),A=A.replace(/""/g,'"'),A&&A.match(/^=".*"$/)&&(A=A.slice(2,-1)),N[y][x++]=A!==""?A:null;break}if(A==="EOD")break}}return u&&u.sheetRows&&(N=N.slice(0,u.sheetRows)),N}function a(c,u){return Qd(e(c,u),u)}function n(c,u){return Dc(a(c,u),u)}var i=(function(){var c=function(y,x,k,N,C){y.push(x),y.push(k+","+N),y.push('"'+C.replace(/"/g,'""')+'"')},u=function(y,x,k,N){y.push(x+","+k),y.push(x==1?'"'+N.replace(/"/g,'""')+'"':N)};return function(y){var x=[],k=Ya(y["!ref"]),N,C=Array.isArray(y);c(x,"TABLE",0,1,"sheetjs"),c(x,"VECTORS",0,k.e.r-k.s.r+1,""),c(x,"TUPLES",0,k.e.c-k.s.c+1,""),c(x,"DATA",0,0,"");for(var O=k.s.r;O<=k.e.r;++O){u(x,-1,0,"BOT");for(var D=k.s.c;D<=k.e.c;++D){var A=Ma({r:O,c:D});if(N=C?(y[O]||[])[D]:y[A],!N){u(x,1,0,"");continue}switch(N.t){case"n":var I=N.w;!I&&N.v!=null&&(I=N.v),I==null?N.f&&!N.F?u(x,1,0,"="+N.f):u(x,1,0,""):u(x,0,I,"V");break;case"b":u(x,0,N.v?1:0,N.v?"TRUE":"FALSE");break;case"s":u(x,1,0,isNaN(N.v)?N.v:'="'+N.v+'"');break;case"d":N.w||(N.w=Gl(N.z||mn[14],Ks(Os(N.v)))),u(x,0,N.w,"V");break;default:u(x,1,0,"")}}}u(x,-1,0,"EOD");var z=`\r
|
||
`,U=x.join(z);return U}})();return{to_workbook:n,to_sheet:a,from_sheet:i}})(),F4=(function(){function e(N){return N.replace(/\\b/g,"\\").replace(/\\c/g,":").replace(/\\n/g,`
|
||
`)}function r(N){return N.replace(/\\/g,"\\b").replace(/:/g,"\\c").replace(/\n/g,"\\n")}function a(N,C){for(var O=N.split(`
|
||
`),D=-1,A=-1,I=0,z=[];I!==O.length;++I){var U=O[I].trim().split(":");if(U[0]==="cell"){var B=Gn(U[1]);if(z.length<=B.r)for(D=z.length;D<=B.r;++D)z[D]||(z[D]=[]);switch(D=B.r,A=B.c,U[2]){case"t":z[D][A]=e(U[3]);break;case"v":z[D][A]=+U[3];break;case"vtf":var V=U[U.length-1];case"vtc":switch(U[3]){case"nl":z[D][A]=!!+U[4];break;default:z[D][A]=+U[4];break}U[2]=="vtf"&&(z[D][A]=[z[D][A],V])}}}return C&&C.sheetRows&&(z=z.slice(0,C.sheetRows)),z}function n(N,C){return Qd(a(N,C),C)}function i(N,C){return Dc(n(N,C),C)}var c=["socialcalc:version:1.5","MIME-Version: 1.0","Content-Type: multipart/mixed; boundary=SocialCalcSpreadsheetControlSave"].join(`
|
||
`),u=["--SocialCalcSpreadsheetControlSave","Content-type: text/plain; charset=UTF-8"].join(`
|
||
`)+`
|
||
`,g=["# SocialCalc Spreadsheet Control Save","part:sheet"].join(`
|
||
`),y="--SocialCalcSpreadsheetControlSave--";function x(N){if(!N||!N["!ref"])return"";for(var C=[],O=[],D,A="",I=pi(N["!ref"]),z=Array.isArray(N),U=I.s.r;U<=I.e.r;++U)for(var B=I.s.c;B<=I.e.c;++B)if(A=Ma({r:U,c:B}),D=z?(N[U]||[])[B]:N[A],!(!D||D.v==null||D.t==="z")){switch(O=["cell",A,"t"],D.t){case"s":case"str":O.push(r(D.v));break;case"n":D.f?(O[2]="vtf",O[3]="n",O[4]=D.v,O[5]=r(D.f)):(O[2]="v",O[3]=D.v);break;case"b":O[2]="vt"+(D.f?"f":"c"),O[3]="nl",O[4]=D.v?"1":"0",O[5]=r(D.f||(D.v?"TRUE":"FALSE"));break;case"d":var V=Ks(Os(D.v));O[2]="vtc",O[3]="nd",O[4]=""+V,O[5]=D.w||Gl(D.z||mn[14],V);break;case"e":continue}C.push(O.join(":"))}return C.push("sheet:c:"+(I.e.c-I.s.c+1)+":r:"+(I.e.r-I.s.r+1)+":tvf:1"),C.push("valueformat:1:text-wiki"),C.join(`
|
||
`)}function k(N){return[c,u,g,u,x(N),y].join(`
|
||
`)}return{to_workbook:i,to_sheet:n,from_sheet:k}})(),sT=(function(){function e(k,N,C,O,D){D.raw?N[C][O]=k:k===""||(k==="TRUE"?N[C][O]=!0:k==="FALSE"?N[C][O]=!1:isNaN(el(k))?isNaN(xu(k).getDate())?N[C][O]=k:N[C][O]=Os(k):N[C][O]=el(k))}function r(k,N){var C=N||{},O=[];if(!k||k.length===0)return O;for(var D=k.split(/[\r\n]/),A=D.length-1;A>=0&&D[A].length===0;)--A;for(var I=10,z=0,U=0;U<=A;++U)z=D[U].indexOf(" "),z==-1?z=D[U].length:z++,I=Math.max(I,z);for(U=0;U<=A;++U){O[U]=[];var B=0;for(e(D[U].slice(0,I).trim(),O,U,B,C),B=1;B<=(D[U].length-I)/10+1;++B)e(D[U].slice(I+(B-1)*10,I+B*10).trim(),O,U,B,C)}return C.sheetRows&&(O=O.slice(0,C.sheetRows)),O}var a={44:",",9:" ",59:";",124:"|"},n={44:3,9:2,59:1,124:0};function i(k){for(var N={},C=!1,O=0,D=0;O<k.length;++O)(D=k.charCodeAt(O))==34?C=!C:!C&&D in a&&(N[D]=(N[D]||0)+1);D=[];for(O in N)Object.prototype.hasOwnProperty.call(N,O)&&D.push([N[O],O]);if(!D.length){N=n;for(O in N)Object.prototype.hasOwnProperty.call(N,O)&&D.push([N[O],O])}return D.sort(function(A,I){return A[0]-I[0]||n[A[1]]-n[I[1]]}),a[D.pop()[1]]||44}function c(k,N){var C=N||{},O="",D=C.dense?[]:{},A={s:{c:0,r:0},e:{c:0,r:0}};k.slice(0,4)=="sep="?k.charCodeAt(5)==13&&k.charCodeAt(6)==10?(O=k.charAt(4),k=k.slice(7)):k.charCodeAt(5)==13||k.charCodeAt(5)==10?(O=k.charAt(4),k=k.slice(6)):O=i(k.slice(0,1024)):C&&C.FS?O=C.FS:O=i(k.slice(0,1024));var I=0,z=0,U=0,B=0,V=0,Z=O.charCodeAt(0),W=!1,H=0,le=k.charCodeAt(0);k=k.replace(/\r\n/mg,`
|
||
`);var Q=C.dateNF!=null?_E(C.dateNF):null;function Ne(){var oe=k.slice(B,V),se={};if(oe.charAt(0)=='"'&&oe.charAt(oe.length-1)=='"'&&(oe=oe.slice(1,-1).replace(/""/g,'"')),oe.length===0)se.t="z";else if(C.raw)se.t="s",se.v=oe;else if(oe.trim().length===0)se.t="s",se.v=oe;else if(oe.charCodeAt(0)==61)oe.charCodeAt(1)==34&&oe.charCodeAt(oe.length-1)==34?(se.t="s",se.v=oe.slice(2,-1).replace(/""/g,'"')):aA(oe)?(se.t="n",se.f=oe.slice(1)):(se.t="s",se.v=oe);else if(oe=="TRUE")se.t="b",se.v=!0;else if(oe=="FALSE")se.t="b",se.v=!1;else if(!isNaN(U=el(oe)))se.t="n",C.cellText!==!1&&(se.w=oe),se.v=U;else if(!isNaN(xu(oe).getDate())||Q&&oe.match(Q)){se.z=C.dateNF||mn[14];var ce=0;Q&&oe.match(Q)&&(oe=wE(oe,C.dateNF,oe.match(Q)||[]),ce=1),C.cellDates?(se.t="d",se.v=Os(oe,ce)):(se.t="n",se.v=Ks(Os(oe,ce))),C.cellText!==!1&&(se.w=Gl(se.z,se.v instanceof Date?Ks(se.v):se.v)),C.cellNF||delete se.z}else se.t="s",se.v=oe;if(se.t=="z"||(C.dense?(D[I]||(D[I]=[]),D[I][z]=se):D[Ma({c:z,r:I})]=se),B=V+1,le=k.charCodeAt(B),A.e.c<z&&(A.e.c=z),A.e.r<I&&(A.e.r=I),H==Z)++z;else if(z=0,++I,C.sheetRows&&C.sheetRows<=I)return!0}e:for(;V<k.length;++V)switch(H=k.charCodeAt(V)){case 34:le===34&&(W=!W);break;case Z:case 10:case 13:if(!W&&Ne())break e;break}return V-B>0&&Ne(),D["!ref"]=Tn(A),D}function u(k,N){return!(N&&N.PRN)||N.FS||k.slice(0,4)=="sep="||k.indexOf(" ")>=0||k.indexOf(",")>=0||k.indexOf(";")>=0?c(k,N):Qd(r(k,N),N)}function g(k,N){var C="",O=N.type=="string"?[0,0,0,0]:pR(k,N);switch(N.type){case"base64":C=il(k);break;case"binary":C=k;break;case"buffer":N.codepage==65001?C=k.toString("utf8"):N.codepage&&typeof Ef!="undefined"||(C=Na&&Buffer.isBuffer(k)?k.toString("binary"):ju(k));break;case"array":C=sm(k);break;case"string":C=k;break;default:throw new Error("Unrecognized type "+N.type)}return O[0]==239&&O[1]==187&&O[2]==191?C=su(C.slice(3)):N.type!="string"&&N.type!="buffer"&&N.codepage==65001?C=su(C):N.type=="binary",C.slice(0,19)=="socialcalc:version:"?F4.to_sheet(N.type=="string"?C:su(C),N):u(C,N)}function y(k,N){return Dc(g(k,N),N)}function x(k){for(var N=[],C=Ya(k["!ref"]),O,D=Array.isArray(k),A=C.s.r;A<=C.e.r;++A){for(var I=[],z=C.s.c;z<=C.e.c;++z){var U=Ma({r:A,c:z});if(O=D?(k[A]||[])[z]:k[U],!O||O.v==null){I.push(" ");continue}for(var B=(O.w||(ol(O),O.w)||"").slice(0,10);B.length<10;)B+=" ";I.push(B+(z===0?" ":""))}N.push(I.join(""))}return N.join(`
|
||
`)}return{to_workbook:y,to_sheet:g,from_sheet:x}})(),Fv=(function(){function e(G,ie,re){if(G){fi(G,G.l||0);for(var ne=re.Enum||ye;G.l<G.length;){var ve=G.read_shift(2),Ve=ne[ve]||ne[65535],Ae=G.read_shift(2),ze=G.l+Ae,Re=Ve.f&&Ve.f(G,Ae,re);if(G.l=ze,ie(Re,Ve,ve))return}}}function r(G,ie){switch(ie.type){case"base64":return a(Qi(il(G)),ie);case"binary":return a(Qi(G),ie);case"buffer":case"array":return a(G,ie)}throw"Unsupported type "+ie.type}function a(G,ie){if(!G)return G;var re=ie||{},ne=re.dense?[]:{},ve="Sheet1",Ve="",Ae=0,ze={},Re=[],Ze=[],Lt={s:{r:0,c:0},e:{r:0,c:0}},mt=re.sheetRows||0;if(G[2]==0&&(G[3]==8||G[3]==9)&&G.length>=16&&G[14]==5&&G[15]===108)throw new Error("Unsupported Works 3 for Mac file");if(G[2]==2)re.Enum=ye,e(G,function(yt,nr,$t){switch($t){case 0:re.vers=yt,yt>=4096&&(re.qpro=!0);break;case 6:Lt=yt;break;case 204:yt&&(Ve=yt);break;case 222:Ve=yt;break;case 15:case 51:re.qpro||(yt[1].v=yt[1].v.slice(1));case 13:case 14:case 16:$t==14&&(yt[2]&112)==112&&(yt[2]&15)>1&&(yt[2]&15)<15&&(yt[1].z=re.dateNF||mn[14],re.cellDates&&(yt[1].t="d",yt[1].v=t4(yt[1].v))),re.qpro&&yt[3]>Ae&&(ne["!ref"]=Tn(Lt),ze[ve]=ne,Re.push(ve),ne=re.dense?[]:{},Lt={s:{r:0,c:0},e:{r:0,c:0}},Ae=yt[3],ve=Ve||"Sheet"+(Ae+1),Ve="");var Er=re.dense?(ne[yt[0].r]||[])[yt[0].c]:ne[Ma(yt[0])];if(Er){Er.t=yt[1].t,Er.v=yt[1].v,yt[1].z!=null&&(Er.z=yt[1].z),yt[1].f!=null&&(Er.f=yt[1].f);break}re.dense?(ne[yt[0].r]||(ne[yt[0].r]=[]),ne[yt[0].r][yt[0].c]=yt[1]):ne[Ma(yt[0])]=yt[1];break}},re);else if(G[2]==26||G[2]==14)re.Enum=J,G[2]==14&&(re.qpro=!0,G.l=0),e(G,function(yt,nr,$t){switch($t){case 204:ve=yt;break;case 22:yt[1].v=yt[1].v.slice(1);case 23:case 24:case 25:case 37:case 39:case 40:if(yt[3]>Ae&&(ne["!ref"]=Tn(Lt),ze[ve]=ne,Re.push(ve),ne=re.dense?[]:{},Lt={s:{r:0,c:0},e:{r:0,c:0}},Ae=yt[3],ve="Sheet"+(Ae+1)),mt>0&&yt[0].r>=mt)break;re.dense?(ne[yt[0].r]||(ne[yt[0].r]=[]),ne[yt[0].r][yt[0].c]=yt[1]):ne[Ma(yt[0])]=yt[1],Lt.e.c<yt[0].c&&(Lt.e.c=yt[0].c),Lt.e.r<yt[0].r&&(Lt.e.r=yt[0].r);break;case 27:yt[14e3]&&(Ze[yt[14e3][0]]=yt[14e3][1]);break;case 1537:Ze[yt[0]]=yt[1],yt[0]==Ae&&(ve=yt[1]);break}},re);else throw new Error("Unrecognized LOTUS BOF "+G[2]);if(ne["!ref"]=Tn(Lt),ze[Ve||ve]=ne,Re.push(Ve||ve),!Ze.length)return{SheetNames:Re,Sheets:ze};for(var Zt={},ar=[],or=0;or<Ze.length;++or)ze[Re[or]]?(ar.push(Ze[or]||Re[or]),Zt[Ze[or]]=ze[Ze[or]]||ze[Re[or]]):(ar.push(Ze[or]),Zt[Ze[or]]={"!ref":"A1"});return{SheetNames:ar,Sheets:Zt}}function n(G,ie){var re=ie||{};if(+re.codepage>=0&&mu(+re.codepage),re.type=="string")throw new Error("Cannot write WK1 to JS string");var ne=Xs(),ve=Ya(G["!ref"]),Ve=Array.isArray(G),Ae=[];ir(ne,0,c(1030)),ir(ne,6,y(ve));for(var ze=Math.min(ve.e.r,8191),Re=ve.s.r;Re<=ze;++Re)for(var Ze=ls(Re),Lt=ve.s.c;Lt<=ve.e.c;++Lt){Re===ve.s.r&&(Ae[Lt]=bs(Lt));var mt=Ae[Lt]+Ze,Zt=Ve?(G[Re]||[])[Lt]:G[mt];if(!(!Zt||Zt.t=="z"))if(Zt.t=="n")(Zt.v|0)==Zt.v&&Zt.v>=-32768&&Zt.v<=32767?ir(ne,13,O(Re,Lt,Zt.v)):ir(ne,14,A(Re,Lt,Zt.v));else{var ar=ol(Zt);ir(ne,15,N(Re,Lt,ar.slice(0,239)))}}return ir(ne,1),ne.end()}function i(G,ie){var re=ie||{};if(+re.codepage>=0&&mu(+re.codepage),re.type=="string")throw new Error("Cannot write WK3 to JS string");var ne=Xs();ir(ne,0,u(G));for(var ve=0,Ve=0;ve<G.SheetNames.length;++ve)(G.Sheets[G.SheetNames[ve]]||{})["!ref"]&&ir(ne,27,Oe(G.SheetNames[ve],Ve++));var Ae=0;for(ve=0;ve<G.SheetNames.length;++ve){var ze=G.Sheets[G.SheetNames[ve]];if(!(!ze||!ze["!ref"])){for(var Re=Ya(ze["!ref"]),Ze=Array.isArray(ze),Lt=[],mt=Math.min(Re.e.r,8191),Zt=Re.s.r;Zt<=mt;++Zt)for(var ar=ls(Zt),or=Re.s.c;or<=Re.e.c;++or){Zt===Re.s.r&&(Lt[or]=bs(or));var yt=Lt[or]+ar,nr=Ze?(ze[Zt]||[])[or]:ze[yt];if(!(!nr||nr.t=="z"))if(nr.t=="n")ir(ne,23,Ne(Zt,or,Ae,nr.v));else{var $t=ol(nr);ir(ne,22,H(Zt,or,Ae,$t.slice(0,239)))}}++Ae}}return ir(ne,1),ne.end()}function c(G){var ie=Nt(2);return ie.write_shift(2,G),ie}function u(G){var ie=Nt(26);ie.write_shift(2,4096),ie.write_shift(2,4),ie.write_shift(4,0);for(var re=0,ne=0,ve=0,Ve=0;Ve<G.SheetNames.length;++Ve){var Ae=G.SheetNames[Ve],ze=G.Sheets[Ae];if(!(!ze||!ze["!ref"])){++ve;var Re=pi(ze["!ref"]);re<Re.e.r&&(re=Re.e.r),ne<Re.e.c&&(ne=Re.e.c)}}return re>8191&&(re=8191),ie.write_shift(2,re),ie.write_shift(1,ve),ie.write_shift(1,ne),ie.write_shift(2,0),ie.write_shift(2,0),ie.write_shift(1,1),ie.write_shift(1,2),ie.write_shift(4,0),ie.write_shift(4,0),ie}function g(G,ie,re){var ne={s:{c:0,r:0},e:{c:0,r:0}};return ie==8&&re.qpro?(ne.s.c=G.read_shift(1),G.l++,ne.s.r=G.read_shift(2),ne.e.c=G.read_shift(1),G.l++,ne.e.r=G.read_shift(2),ne):(ne.s.c=G.read_shift(2),ne.s.r=G.read_shift(2),ie==12&&re.qpro&&(G.l+=2),ne.e.c=G.read_shift(2),ne.e.r=G.read_shift(2),ie==12&&re.qpro&&(G.l+=2),ne.s.c==65535&&(ne.s.c=ne.e.c=ne.s.r=ne.e.r=0),ne)}function y(G){var ie=Nt(8);return ie.write_shift(2,G.s.c),ie.write_shift(2,G.s.r),ie.write_shift(2,G.e.c),ie.write_shift(2,G.e.r),ie}function x(G,ie,re){var ne=[{c:0,r:0},{t:"n",v:0},0,0];return re.qpro&&re.vers!=20768?(ne[0].c=G.read_shift(1),ne[3]=G.read_shift(1),ne[0].r=G.read_shift(2),G.l+=2):(ne[2]=G.read_shift(1),ne[0].c=G.read_shift(2),ne[0].r=G.read_shift(2)),ne}function k(G,ie,re){var ne=G.l+ie,ve=x(G,ie,re);if(ve[1].t="s",re.vers==20768){G.l++;var Ve=G.read_shift(1);return ve[1].v=G.read_shift(Ve,"utf8"),ve}return re.qpro&&G.l++,ve[1].v=G.read_shift(ne-G.l,"cstr"),ve}function N(G,ie,re){var ne=Nt(7+re.length);ne.write_shift(1,255),ne.write_shift(2,ie),ne.write_shift(2,G),ne.write_shift(1,39);for(var ve=0;ve<ne.length;++ve){var Ve=re.charCodeAt(ve);ne.write_shift(1,Ve>=128?95:Ve)}return ne.write_shift(1,0),ne}function C(G,ie,re){var ne=x(G,ie,re);return ne[1].v=G.read_shift(2,"i"),ne}function O(G,ie,re){var ne=Nt(7);return ne.write_shift(1,255),ne.write_shift(2,ie),ne.write_shift(2,G),ne.write_shift(2,re,"i"),ne}function D(G,ie,re){var ne=x(G,ie,re);return ne[1].v=G.read_shift(8,"f"),ne}function A(G,ie,re){var ne=Nt(13);return ne.write_shift(1,255),ne.write_shift(2,ie),ne.write_shift(2,G),ne.write_shift(8,re,"f"),ne}function I(G,ie,re){var ne=G.l+ie,ve=x(G,ie,re);if(ve[1].v=G.read_shift(8,"f"),re.qpro)G.l=ne;else{var Ve=G.read_shift(2);V(G.slice(G.l,G.l+Ve),ve),G.l+=Ve}return ve}function z(G,ie,re){var ne=ie&32768;return ie&=-32769,ie=(ne?G:0)+(ie>=8192?ie-16384:ie),(ne?"":"$")+(re?bs(ie):ls(ie))}var U={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]},B=["","","","","","","","","","+","-","*","/","^","=","<>","<=",">=","<",">","","","","","&","","","","","","",""];function V(G,ie){fi(G,0);for(var re=[],ne=0,ve="",Ve="",Ae="",ze="";G.l<G.length;){var Re=G[G.l++];switch(Re){case 0:re.push(G.read_shift(8,"f"));break;case 1:Ve=z(ie[0].c,G.read_shift(2),!0),ve=z(ie[0].r,G.read_shift(2),!1),re.push(Ve+ve);break;case 2:{var Ze=z(ie[0].c,G.read_shift(2),!0),Lt=z(ie[0].r,G.read_shift(2),!1);Ve=z(ie[0].c,G.read_shift(2),!0),ve=z(ie[0].r,G.read_shift(2),!1),re.push(Ze+Lt+":"+Ve+ve)}break;case 3:if(G.l<G.length){console.error("WK1 premature formula end");return}break;case 4:re.push("("+re.pop()+")");break;case 5:re.push(G.read_shift(2));break;case 6:{for(var mt="";Re=G[G.l++];)mt+=String.fromCharCode(Re);re.push('"'+mt.replace(/"/g,'""')+'"')}break;case 8:re.push("-"+re.pop());break;case 23:re.push("+"+re.pop());break;case 22:re.push("NOT("+re.pop()+")");break;case 20:case 21:ze=re.pop(),Ae=re.pop(),re.push(["AND","OR"][Re-20]+"("+Ae+","+ze+")");break;default:if(Re<32&&B[Re])ze=re.pop(),Ae=re.pop(),re.push(Ae+B[Re]+ze);else if(U[Re]){if(ne=U[Re][1],ne==69&&(ne=G[G.l++]),ne>re.length){console.error("WK1 bad formula parse 0x"+Re.toString(16)+":|"+re.join("|")+"|");return}var Zt=re.slice(-ne);re.length-=ne,re.push(U[Re][0]+"("+Zt.join(",")+")")}else return Re<=7?console.error("WK1 invalid opcode "+Re.toString(16)):Re<=24?console.error("WK1 unsupported op "+Re.toString(16)):Re<=30?console.error("WK1 invalid opcode "+Re.toString(16)):Re<=115?console.error("WK1 unsupported function opcode "+Re.toString(16)):console.error("WK1 unrecognized opcode "+Re.toString(16))}}re.length==1?ie[1].f=""+re[0]:console.error("WK1 bad formula parse |"+re.join("|")+"|")}function Z(G){var ie=[{c:0,r:0},{t:"n",v:0},0];return ie[0].r=G.read_shift(2),ie[3]=G[G.l++],ie[0].c=G[G.l++],ie}function W(G,ie){var re=Z(G);return re[1].t="s",re[1].v=G.read_shift(ie-4,"cstr"),re}function H(G,ie,re,ne){var ve=Nt(6+ne.length);ve.write_shift(2,G),ve.write_shift(1,re),ve.write_shift(1,ie),ve.write_shift(1,39);for(var Ve=0;Ve<ne.length;++Ve){var Ae=ne.charCodeAt(Ve);ve.write_shift(1,Ae>=128?95:Ae)}return ve.write_shift(1,0),ve}function le(G,ie){var re=Z(G);re[1].v=G.read_shift(2);var ne=re[1].v>>1;if(re[1].v&1)switch(ne&7){case 0:ne=(ne>>3)*5e3;break;case 1:ne=(ne>>3)*500;break;case 2:ne=(ne>>3)/20;break;case 3:ne=(ne>>3)/200;break;case 4:ne=(ne>>3)/2e3;break;case 5:ne=(ne>>3)/2e4;break;case 6:ne=(ne>>3)/16;break;case 7:ne=(ne>>3)/64;break}return re[1].v=ne,re}function Q(G,ie){var re=Z(G),ne=G.read_shift(4),ve=G.read_shift(4),Ve=G.read_shift(2);if(Ve==65535)return ne===0&&ve===3221225472?(re[1].t="e",re[1].v=15):ne===0&&ve===3489660928?(re[1].t="e",re[1].v=42):re[1].v=0,re;var Ae=Ve&32768;return Ve=(Ve&32767)-16446,re[1].v=(1-Ae*2)*(ve*Math.pow(2,Ve+32)+ne*Math.pow(2,Ve)),re}function Ne(G,ie,re,ne){var ve=Nt(14);if(ve.write_shift(2,G),ve.write_shift(1,re),ve.write_shift(1,ie),ne==0)return ve.write_shift(4,0),ve.write_shift(4,0),ve.write_shift(2,65535),ve;var Ve=0,Ae=0,ze=0,Re=0;return ne<0&&(Ve=1,ne=-ne),Ae=Math.log2(ne)|0,ne/=Math.pow(2,Ae-31),Re=ne>>>0,(Re&2147483648)==0&&(ne/=2,++Ae,Re=ne>>>0),ne-=Re,Re|=2147483648,Re>>>=0,ne*=Math.pow(2,32),ze=ne>>>0,ve.write_shift(4,ze),ve.write_shift(4,Re),Ae+=16383+(Ve?32768:0),ve.write_shift(2,Ae),ve}function oe(G,ie){var re=Q(G);return G.l+=ie-14,re}function se(G,ie){var re=Z(G),ne=G.read_shift(4);return re[1].v=ne>>6,re}function ce(G,ie){var re=Z(G),ne=G.read_shift(8,"f");return re[1].v=ne,re}function Ce(G,ie){var re=ce(G);return G.l+=ie-10,re}function ae(G,ie){return G[G.l+ie-1]==0?G.read_shift(ie,"cstr"):""}function me(G,ie){var re=G[G.l++];re>ie-1&&(re=ie-1);for(var ne="";ne.length<re;)ne+=String.fromCharCode(G[G.l++]);return ne}function K(G,ie,re){if(!(!re.qpro||ie<21)){var ne=G.read_shift(1);G.l+=17,G.l+=1,G.l+=2;var ve=G.read_shift(ie-21,"cstr");return[ne,ve]}}function fe(G,ie){for(var re={},ne=G.l+ie;G.l<ne;){var ve=G.read_shift(2);if(ve==14e3){for(re[ve]=[0,""],re[ve][0]=G.read_shift(2);G[G.l];)re[ve][1]+=String.fromCharCode(G[G.l]),G.l++;G.l++}}return re}function Oe(G,ie){var re=Nt(5+G.length);re.write_shift(2,14e3),re.write_shift(2,ie);for(var ne=0;ne<G.length;++ne){var ve=G.charCodeAt(ne);re[re.l++]=ve>127?95:ve}return re[re.l++]=0,re}var ye={0:{n:"BOF",f:M4},1:{n:"EOF"},2:{n:"CALCMODE"},3:{n:"CALCORDER"},4:{n:"SPLIT"},5:{n:"SYNC"},6:{n:"RANGE",f:g},7:{n:"WINDOW1"},8:{n:"COLW1"},9:{n:"WINTWO"},10:{n:"COLW2"},11:{n:"NAME"},12:{n:"BLANK"},13:{n:"INTEGER",f:C},14:{n:"NUMBER",f:D},15:{n:"LABEL",f:k},16:{n:"FORMULA",f:I},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:k},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:ae},222:{n:"SHEETNAMELP",f:me},65535:{n:""}},J={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:W},23:{n:"NUMBER17",f:Q},24:{n:"NUMBER18",f:le},25:{n:"FORMULA19",f:oe},26:{n:"FORMULA1A"},27:{n:"XFORMAT",f:fe},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:se},38:{n:"??"},39:{n:"NUMBER27",f:ce},40:{n:"FORMULA28",f:Ce},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:ae},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:K},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:n,book_to_wk3:i,to_workbook:r}})(),iT=/^\s|\s$|[\t\n\r]/;function B4(e,r){if(!r.bookSST)return"";var a=[An];a[a.length]=rr("sst",null,{xmlns:Jd[0],count:e.Count,uniqueCount:e.Unique});for(var n=0;n!=e.length;++n)if(e[n]!=null){var i=e[n],c="<si>";i.r?c+=i.r:(c+="<t",i.t||(i.t=""),i.t.match(iT)&&(c+=' xml:space="preserve"'),c+=">"+Ra(i.t)+"</t>"),c+="</si>",a[a.length]=c}return a.length>2&&(a[a.length]="</sst>",a[1]=a[1].replace("/>",">")),a.join("")}function oT(e){return[e.read_shift(4),e.read_shift(4)]}function lT(e,r){return r||(r=Nt(8)),r.write_shift(4,e.Count),r.write_shift(4,e.Unique),r}var cT=QE;function dT(e){var r=Xs();Bt(r,159,lT(e));for(var a=0;a<e.length;++a)Bt(r,19,cT(e[a]));return Bt(r,160),r.end()}function uT(e){for(var r=[],a=e.split(""),n=0;n<a.length;++n)r[n]=a[n].charCodeAt(0);return r}function U4(e){var r=0,a,n=uT(e),i=n.length+1,c,u,g,y,x;for(a=Tc(i),a[0]=n.length,c=1;c!=i;++c)a[c]=n[c-1];for(c=i-1;c>=0;--c)u=a[c],g=(r&16384)===0?0:1,y=r<<1&32767,x=g|y,r=x^u;return r^52811}var hT=(function(){function e(i,c){switch(c.type){case"base64":return r(il(i),c);case"binary":return r(i,c);case"buffer":return r(Na&&Buffer.isBuffer(i)?i.toString("binary"):ju(i),c);case"array":return r(sm(i),c)}throw new Error("Unrecognized type "+c.type)}function r(i,c){var u=c||{},g=u.dense?[]:{},y=i.match(/\\trowd.*?\\row\b/g);if(!y.length)throw new Error("RTF missing table");var x={s:{c:0,r:0},e:{c:0,r:y.length-1}};return y.forEach(function(k,N){Array.isArray(g)&&(g[N]=[]);for(var C=/\\\w+\b/g,O=0,D,A=-1;D=C.exec(k);){switch(D[0]){case"\\cell":var I=k.slice(O,C.lastIndex-D[0].length);if(I[0]==" "&&(I=I.slice(1)),++A,I.length){var z={v:I,t:"s"};Array.isArray(g)?g[N][A]=z:g[Ma({r:N,c:A})]=z}break}O=C.lastIndex}A>x.e.c&&(x.e.c=A)}),g["!ref"]=Tn(x),g}function a(i,c){return Dc(e(i,c),c)}function n(i){for(var c=["{\\rtf1\\ansi"],u=Ya(i["!ref"]),g,y=Array.isArray(i),x=u.s.r;x<=u.e.r;++x){c.push("\\trowd\\trautofit1");for(var k=u.s.c;k<=u.e.c;++k)c.push("\\cellx"+(k+1));for(c.push("\\pard\\intbl"),k=u.s.c;k<=u.e.c;++k){var N=Ma({r:x,c:k});g=y?(i[x]||[])[k]:i[N],!(!g||g.v==null&&(!g.f||g.F))&&(c.push(" "+(g.w||(ol(g),g.w))),c.push("\\cell"))}c.push("\\pard\\intbl\\row")}return c.join("")+"}"}return{to_workbook:a,to_sheet:e,from_sheet:n}})();function Bv(e){for(var r=0,a=1;r!=3;++r)a=a*256+(e[r]>255?255:e[r]<0?0:e[r]);return a.toString(16).toUpperCase().slice(1)}var fT=6,tl=fT;function If(e){return Math.floor((e+Math.round(128/tl)/256)*tl)}function Pf(e){return Math.floor((e-5)/tl*100+.5)/100}function rp(e){return Math.round((e*tl+5)/tl*256)/256}function Vp(e){e.width?(e.wpx=If(e.width),e.wch=Pf(e.wpx),e.MDW=tl):e.wpx?(e.wch=Pf(e.wpx),e.width=rp(e.wch),e.MDW=tl):typeof e.wch=="number"&&(e.width=rp(e.wch),e.wpx=If(e.width),e.MDW=tl),e.customWidth&&delete e.customWidth}var mT=96,z4=mT;function Ff(e){return e*96/z4}function H4(e){return e*z4/96}function gT(e){var r=["<numFmts>"];return[[5,8],[23,26],[41,44],[50,392]].forEach(function(a){for(var n=a[0];n<=a[1];++n)e[n]!=null&&(r[r.length]=rr("numFmt",null,{numFmtId:n,formatCode:Ra(e[n])}))}),r.length===1?"":(r[r.length]="</numFmts>",r[0]=rr("numFmts",null,{count:r.length-2}).replace("/>",">"),r.join(""))}function xT(e){var r=[];return r[r.length]=rr("cellXfs",null),e.forEach(function(a){r[r.length]=rr("xf",null,a)}),r[r.length]="</cellXfs>",r.length===2?"":(r[0]=rr("cellXfs",null,{count:r.length-2}).replace("/>",">"),r.join(""))}function V4(e,r){var a=[An,rr("styleSheet",null,{xmlns:Jd[0],"xmlns:vt":Wn.vt})],n;return e.SSF&&(n=gT(e.SSF))!=null&&(a[a.length]=n),a[a.length]='<fonts count="1"><font><sz val="12"/><color theme="1"/><name val="Calibri"/><family val="2"/><scheme val="minor"/></font></fonts>',a[a.length]='<fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills>',a[a.length]='<borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders>',a[a.length]='<cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs>',(n=xT(r.cellXfs))&&(a[a.length]=n),a[a.length]='<cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>',a[a.length]='<dxfs count="0"/>',a[a.length]='<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleMedium4"/>',a.length>2&&(a[a.length]="</styleSheet>",a[1]=a[1].replace("/>",">")),a.join("")}function pT(e,r){var a=e.read_shift(2),n=vs(e);return[a,n]}function yT(e,r,a){a||(a=Nt(6+4*r.length)),a.write_shift(2,e),$n(r,a);var n=a.length>a.l?a.slice(0,a.l):a;return a.l==null&&(a.l=a.length),n}function bT(e,r,a){var n={};n.sz=e.read_shift(2)/20;var i=ij(e);i.fItalic&&(n.italic=1),i.fCondense&&(n.condense=1),i.fExtend&&(n.extend=1),i.fShadow&&(n.shadow=1),i.fOutline&&(n.outline=1),i.fStrikeout&&(n.strike=1);var c=e.read_shift(2);switch(c===700&&(n.bold=1),e.read_shift(2)){case 1:n.vertAlign="superscript";break;case 2:n.vertAlign="subscript";break}var u=e.read_shift(1);u!=0&&(n.underline=u);var g=e.read_shift(1);g>0&&(n.family=g);var y=e.read_shift(1);switch(y>0&&(n.charset=y),e.l++,n.color=sj(e),e.read_shift(1)){case 1:n.scheme="major";break;case 2:n.scheme="minor";break}return n.name=vs(e),n}function vT(e,r){r||(r=Nt(153)),r.write_shift(2,e.sz*20),oj(e,r),r.write_shift(2,e.bold?700:400);var a=0;e.vertAlign=="superscript"?a=1:e.vertAlign=="subscript"&&(a=2),r.write_shift(2,a),r.write_shift(1,e.underline||0),r.write_shift(1,e.family||0),r.write_shift(1,e.charset||0),r.write_shift(1,0),Df(e.color,r);var n=0;return n=2,r.write_shift(1,n),$n(e.name,r),r.length>r.l?r.slice(0,r.l):r}var _T=["none","solid","mediumGray","darkGray","lightGray","darkHorizontal","darkVertical","darkDown","darkUp","darkGrid","darkTrellis","lightHorizontal","lightVertical","lightDown","lightUp","lightGrid","lightTrellis","gray125","gray0625"],Tx,wT=So;function Uv(e,r){r||(r=Nt(84)),Tx||(Tx=Op(_T));var a=Tx[e.patternType];a==null&&(a=40),r.write_shift(4,a);var n=0;if(a!=40)for(Df({auto:1},r),Df({auto:1},r);n<12;++n)r.write_shift(4,0);else{for(;n<4;++n)r.write_shift(4,0);for(;n<12;++n)r.write_shift(4,0)}return r.length>r.l?r.slice(0,r.l):r}function kT(e,r){var a=e.l+r,n=e.read_shift(2),i=e.read_shift(2);return e.l=a,{ixfe:n,numFmtId:i}}function W4(e,r,a){a||(a=Nt(16)),a.write_shift(2,r||0),a.write_shift(2,e.numFmtId||0),a.write_shift(2,0),a.write_shift(2,0),a.write_shift(2,0),a.write_shift(1,0),a.write_shift(1,0);var n=0;return a.write_shift(1,n),a.write_shift(1,0),a.write_shift(1,0),a.write_shift(1,0),a}function $0(e,r){return r||(r=Nt(10)),r.write_shift(1,0),r.write_shift(1,0),r.write_shift(4,0),r.write_shift(4,0),r}var NT=So;function ST(e,r){return r||(r=Nt(51)),r.write_shift(1,0),$0(null,r),$0(null,r),$0(null,r),$0(null,r),$0(null,r),r.length>r.l?r.slice(0,r.l):r}function CT(e,r){return r||(r=Nt(52)),r.write_shift(4,e.xfId),r.write_shift(2,1),r.write_shift(1,0),r.write_shift(1,0),Mf(e.name||"",r),r.length>r.l?r.slice(0,r.l):r}function ET(e,r,a){var n=Nt(2052);return n.write_shift(4,e),Mf(r,n),Mf(a,n),n.length>n.l?n.slice(0,n.l):n}function jT(e,r){if(r){var a=0;[[5,8],[23,26],[41,44],[50,392]].forEach(function(n){for(var i=n[0];i<=n[1];++i)r[i]!=null&&++a}),a!=0&&(Bt(e,615,ro(a)),[[5,8],[23,26],[41,44],[50,392]].forEach(function(n){for(var i=n[0];i<=n[1];++i)r[i]!=null&&Bt(e,44,yT(i,r[i]))}),Bt(e,616))}}function TT(e){var r=1;Bt(e,611,ro(r)),Bt(e,43,vT({sz:12,color:{theme:1},name:"Calibri",family:2})),Bt(e,612)}function AT(e){var r=2;Bt(e,603,ro(r)),Bt(e,45,Uv({patternType:"none"})),Bt(e,45,Uv({patternType:"gray125"})),Bt(e,604)}function OT(e){var r=1;Bt(e,613,ro(r)),Bt(e,46,ST()),Bt(e,614)}function RT(e){var r=1;Bt(e,626,ro(r)),Bt(e,47,W4({numFmtId:0},65535)),Bt(e,627)}function MT(e,r){Bt(e,617,ro(r.length)),r.forEach(function(a){Bt(e,47,W4(a,0))}),Bt(e,618)}function DT(e){var r=1;Bt(e,619,ro(r)),Bt(e,48,CT({xfId:0,name:"Normal"})),Bt(e,620)}function LT(e){var r=0;Bt(e,505,ro(r)),Bt(e,506)}function IT(e){var r=0;Bt(e,508,ET(r,"TableStyleMedium9","PivotStyleMedium4")),Bt(e,509)}function PT(e,r){var a=Xs();return Bt(a,278),jT(a,e.SSF),TT(a),AT(a),OT(a),RT(a),MT(a,r.cellXfs),DT(a),LT(a),IT(a),Bt(a,279),a.end()}function G4(e,r){if(r&&r.themeXLSX)return r.themeXLSX;if(e&&typeof e.raw=="string")return e.raw;var a=[An];return a[a.length]='<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme">',a[a.length]="<a:themeElements>",a[a.length]='<a:clrScheme name="Office">',a[a.length]='<a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1>',a[a.length]='<a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1>',a[a.length]='<a:dk2><a:srgbClr val="1F497D"/></a:dk2>',a[a.length]='<a:lt2><a:srgbClr val="EEECE1"/></a:lt2>',a[a.length]='<a:accent1><a:srgbClr val="4F81BD"/></a:accent1>',a[a.length]='<a:accent2><a:srgbClr val="C0504D"/></a:accent2>',a[a.length]='<a:accent3><a:srgbClr val="9BBB59"/></a:accent3>',a[a.length]='<a:accent4><a:srgbClr val="8064A2"/></a:accent4>',a[a.length]='<a:accent5><a:srgbClr val="4BACC6"/></a:accent5>',a[a.length]='<a:accent6><a:srgbClr val="F79646"/></a:accent6>',a[a.length]='<a:hlink><a:srgbClr val="0000FF"/></a:hlink>',a[a.length]='<a:folHlink><a:srgbClr val="800080"/></a:folHlink>',a[a.length]="</a:clrScheme>",a[a.length]='<a:fontScheme name="Office">',a[a.length]="<a:majorFont>",a[a.length]='<a:latin typeface="Cambria"/>',a[a.length]='<a:ea typeface=""/>',a[a.length]='<a:cs typeface=""/>',a[a.length]='<a:font script="Jpan" typeface="MS Pゴシック"/>',a[a.length]='<a:font script="Hang" typeface="맑은 고딕"/>',a[a.length]='<a:font script="Hans" typeface="宋体"/>',a[a.length]='<a:font script="Hant" typeface="新細明體"/>',a[a.length]='<a:font script="Arab" typeface="Times New Roman"/>',a[a.length]='<a:font script="Hebr" typeface="Times New Roman"/>',a[a.length]='<a:font script="Thai" typeface="Tahoma"/>',a[a.length]='<a:font script="Ethi" typeface="Nyala"/>',a[a.length]='<a:font script="Beng" typeface="Vrinda"/>',a[a.length]='<a:font script="Gujr" typeface="Shruti"/>',a[a.length]='<a:font script="Khmr" typeface="MoolBoran"/>',a[a.length]='<a:font script="Knda" typeface="Tunga"/>',a[a.length]='<a:font script="Guru" typeface="Raavi"/>',a[a.length]='<a:font script="Cans" typeface="Euphemia"/>',a[a.length]='<a:font script="Cher" typeface="Plantagenet Cherokee"/>',a[a.length]='<a:font script="Yiii" typeface="Microsoft Yi Baiti"/>',a[a.length]='<a:font script="Tibt" typeface="Microsoft Himalaya"/>',a[a.length]='<a:font script="Thaa" typeface="MV Boli"/>',a[a.length]='<a:font script="Deva" typeface="Mangal"/>',a[a.length]='<a:font script="Telu" typeface="Gautami"/>',a[a.length]='<a:font script="Taml" typeface="Latha"/>',a[a.length]='<a:font script="Syrc" typeface="Estrangelo Edessa"/>',a[a.length]='<a:font script="Orya" typeface="Kalinga"/>',a[a.length]='<a:font script="Mlym" typeface="Kartika"/>',a[a.length]='<a:font script="Laoo" typeface="DokChampa"/>',a[a.length]='<a:font script="Sinh" typeface="Iskoola Pota"/>',a[a.length]='<a:font script="Mong" typeface="Mongolian Baiti"/>',a[a.length]='<a:font script="Viet" typeface="Times New Roman"/>',a[a.length]='<a:font script="Uigh" typeface="Microsoft Uighur"/>',a[a.length]='<a:font script="Geor" typeface="Sylfaen"/>',a[a.length]="</a:majorFont>",a[a.length]="<a:minorFont>",a[a.length]='<a:latin typeface="Calibri"/>',a[a.length]='<a:ea typeface=""/>',a[a.length]='<a:cs typeface=""/>',a[a.length]='<a:font script="Jpan" typeface="MS Pゴシック"/>',a[a.length]='<a:font script="Hang" typeface="맑은 고딕"/>',a[a.length]='<a:font script="Hans" typeface="宋体"/>',a[a.length]='<a:font script="Hant" typeface="新細明體"/>',a[a.length]='<a:font script="Arab" typeface="Arial"/>',a[a.length]='<a:font script="Hebr" typeface="Arial"/>',a[a.length]='<a:font script="Thai" typeface="Tahoma"/>',a[a.length]='<a:font script="Ethi" typeface="Nyala"/>',a[a.length]='<a:font script="Beng" typeface="Vrinda"/>',a[a.length]='<a:font script="Gujr" typeface="Shruti"/>',a[a.length]='<a:font script="Khmr" typeface="DaunPenh"/>',a[a.length]='<a:font script="Knda" typeface="Tunga"/>',a[a.length]='<a:font script="Guru" typeface="Raavi"/>',a[a.length]='<a:font script="Cans" typeface="Euphemia"/>',a[a.length]='<a:font script="Cher" typeface="Plantagenet Cherokee"/>',a[a.length]='<a:font script="Yiii" typeface="Microsoft Yi Baiti"/>',a[a.length]='<a:font script="Tibt" typeface="Microsoft Himalaya"/>',a[a.length]='<a:font script="Thaa" typeface="MV Boli"/>',a[a.length]='<a:font script="Deva" typeface="Mangal"/>',a[a.length]='<a:font script="Telu" typeface="Gautami"/>',a[a.length]='<a:font script="Taml" typeface="Latha"/>',a[a.length]='<a:font script="Syrc" typeface="Estrangelo Edessa"/>',a[a.length]='<a:font script="Orya" typeface="Kalinga"/>',a[a.length]='<a:font script="Mlym" typeface="Kartika"/>',a[a.length]='<a:font script="Laoo" typeface="DokChampa"/>',a[a.length]='<a:font script="Sinh" typeface="Iskoola Pota"/>',a[a.length]='<a:font script="Mong" typeface="Mongolian Baiti"/>',a[a.length]='<a:font script="Viet" typeface="Arial"/>',a[a.length]='<a:font script="Uigh" typeface="Microsoft Uighur"/>',a[a.length]='<a:font script="Geor" typeface="Sylfaen"/>',a[a.length]="</a:minorFont>",a[a.length]="</a:fontScheme>",a[a.length]='<a:fmtScheme name="Office">',a[a.length]="<a:fillStyleLst>",a[a.length]='<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>',a[a.length]='<a:gradFill rotWithShape="1">',a[a.length]="<a:gsLst>",a[a.length]='<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs>',a[a.length]='<a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod val="300000"/></a:schemeClr></a:gs>',a[a.length]='<a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs>',a[a.length]="</a:gsLst>",a[a.length]='<a:lin ang="16200000" scaled="1"/>',a[a.length]="</a:gradFill>",a[a.length]='<a:gradFill rotWithShape="1">',a[a.length]="<a:gsLst>",a[a.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>',a[a.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>',a[a.length]="</a:gsLst>",a[a.length]='<a:lin ang="16200000" scaled="0"/>',a[a.length]="</a:gradFill>",a[a.length]="</a:fillStyleLst>",a[a.length]="<a:lnStyleLst>",a[a.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>',a[a.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>',a[a.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>',a[a.length]="</a:lnStyleLst>",a[a.length]="<a:effectStyleLst>",a[a.length]="<a:effectStyle>",a[a.length]="<a:effectLst>",a[a.length]='<a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw>',a[a.length]="</a:effectLst>",a[a.length]="</a:effectStyle>",a[a.length]="<a:effectStyle>",a[a.length]="<a:effectLst>",a[a.length]='<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw>',a[a.length]="</a:effectLst>",a[a.length]="</a:effectStyle>",a[a.length]="<a:effectStyle>",a[a.length]="<a:effectLst>",a[a.length]='<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw>',a[a.length]="</a:effectLst>",a[a.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>',a[a.length]='<a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d>',a[a.length]="</a:effectStyle>",a[a.length]="</a:effectStyleLst>",a[a.length]="<a:bgFillStyleLst>",a[a.length]='<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>',a[a.length]='<a:gradFill rotWithShape="1">',a[a.length]="<a:gsLst>",a[a.length]='<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs>',a[a.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>',a[a.length]='<a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs>',a[a.length]="</a:gsLst>",a[a.length]='<a:path path="circle"><a:fillToRect l="50000" t="-80000" r="50000" b="180000"/></a:path>',a[a.length]="</a:gradFill>",a[a.length]='<a:gradFill rotWithShape="1">',a[a.length]="<a:gsLst>",a[a.length]='<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs>',a[a.length]='<a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs>',a[a.length]="</a:gsLst>",a[a.length]='<a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path>',a[a.length]="</a:gradFill>",a[a.length]="</a:bgFillStyleLst>",a[a.length]="</a:fmtScheme>",a[a.length]="</a:themeElements>",a[a.length]="<a:objectDefaults>",a[a.length]="<a:spDef>",a[a.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>',a[a.length]="</a:spDef>",a[a.length]="<a:lnDef>",a[a.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>',a[a.length]="</a:lnDef>",a[a.length]="</a:objectDefaults>",a[a.length]="<a:extraClrSchemeLst/>",a[a.length]="</a:theme>",a.join("")}function FT(e,r){return{flags:e.read_shift(4),version:e.read_shift(4),name:vs(e)}}function BT(e){var r=Nt(12+2*e.name.length);return r.write_shift(4,e.flags),r.write_shift(4,e.version),$n(e.name,r),r.slice(0,r.l)}function UT(e){for(var r=[],a=e.read_shift(4);a-- >0;)r.push([e.read_shift(4),e.read_shift(4)]);return r}function zT(e){var r=Nt(4+8*e.length);r.write_shift(4,e.length);for(var a=0;a<e.length;++a)r.write_shift(4,e[a][0]),r.write_shift(4,e[a][1]);return r}function HT(e,r){var a=Nt(8+2*r.length);return a.write_shift(4,e),$n(r,a),a.slice(0,a.l)}function VT(e){return e.l+=4,e.read_shift(4)!=0}function WT(e,r){var a=Nt(8);return a.write_shift(4,e),a.write_shift(4,1),a}function GT(){var e=Xs();return Bt(e,332),Bt(e,334,ro(1)),Bt(e,335,BT({name:"XLDAPR",version:12e4,flags:3496657072})),Bt(e,336),Bt(e,339,HT(1,"XLDAPR")),Bt(e,52),Bt(e,35,ro(514)),Bt(e,4096,ro(0)),Bt(e,4097,Oi(1)),Bt(e,36),Bt(e,53),Bt(e,340),Bt(e,337,WT(1)),Bt(e,51,zT([[1,0]])),Bt(e,338),Bt(e,333),e.end()}function $4(){var e=[An];return e.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>`),e.join("")}function $T(e){var r={};r.i=e.read_shift(4);var a={};a.r=e.read_shift(4),a.c=e.read_shift(4),r.r=Ma(a);var n=e.read_shift(1);return n&2&&(r.l="1"),n&8&&(r.a="1"),r}var Od=1024;function X4(e,r){for(var a=[21600,21600],n=["m0,0l0",a[1],a[0],a[1],a[0],"0xe"].join(","),i=[rr("xml",null,{"xmlns:v":mi.v,"xmlns:o":mi.o,"xmlns:x":mi.x,"xmlns:mv":mi.mv}).replace(/\/>/,">"),rr("o:shapelayout",rr("o:idmap",null,{"v:ext":"edit",data:e}),{"v:ext":"edit"}),rr("v:shapetype",[rr("v:stroke",null,{joinstyle:"miter"}),rr("v:path",null,{gradientshapeok:"t","o:connecttype":"rect"})].join(""),{id:"_x0000_t202","o:spt":202,coordsize:a.join(","),path:n})];Od<e*1e3;)Od+=1e3;return r.forEach(function(c){var u=Gn(c[0]),g={color2:"#BEFF82",type:"gradient"};g.type=="gradient"&&(g.angle="-180");var y=g.type=="gradient"?rr("o:fill",null,{type:"gradientUnscaled","v:ext":"view"}):null,x=rr("v:fill",y,g),k={on:"t",obscured:"t"};++Od,i=i.concat(["<v:shape"+yu({id:"_x0000_s"+Od,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"})+">",x,rr("v:shadow",null,k),rr("v:path",null,{"o:connecttype":"none"}),'<v:textbox><div style="text-align:left"></div></v:textbox>','<x:ClientData ObjectType="Note">',"<x:MoveWithCells/>","<x:SizeWithCells/>",os("x:Anchor",[u.c+1,0,u.r+1,0,u.c+3,20,u.r+5,20].join(",")),os("x:AutoFill","False"),os("x:Row",String(u.r)),os("x:Column",String(u.c)),c[1].hidden?"":"<x:Visible/>","</x:ClientData>","</v:shape>"])}),i.push("</xml>"),i.join("")}function Y4(e){var r=[An,rr("comments",null,{xmlns:Jd[0]})],a=[];return r.push("<authors>"),e.forEach(function(n){n[1].forEach(function(i){var c=Ra(i.a);a.indexOf(c)==-1&&(a.push(c),r.push("<author>"+c+"</author>")),i.T&&i.ID&&a.indexOf("tc="+i.ID)==-1&&(a.push("tc="+i.ID),r.push("<author>tc="+i.ID+"</author>"))})}),a.length==0&&(a.push("SheetJ5"),r.push("<author>SheetJ5</author>")),r.push("</authors>"),r.push("<commentList>"),e.forEach(function(n){var i=0,c=[];if(n[1][0]&&n[1][0].T&&n[1][0].ID?i=a.indexOf("tc="+n[1][0].ID):n[1].forEach(function(y){y.a&&(i=a.indexOf(Ra(y.a))),c.push(y.t||"")}),r.push('<comment ref="'+n[0]+'" authorId="'+i+'"><text>'),c.length<=1)r.push(os("t",Ra(c[0]||"")));else{for(var u=`Comment:
|
||
`+c[0]+`
|
||
`,g=1;g<c.length;++g)u+=`Reply:
|
||
`+c[g]+`
|
||
`;r.push(os("t",Ra(u)))}r.push("</text></comment>")}),r.push("</commentList>"),r.length>2&&(r[r.length]="</comments>",r[1]=r[1].replace("/>",">")),r.join("")}function XT(e,r,a){var n=[An,rr("ThreadedComments",null,{xmlns:Wn.TCMNT}).replace(/[\/]>/,">")];return e.forEach(function(i){var c="";(i[1]||[]).forEach(function(u,g){if(!u.T){delete u.ID;return}u.a&&r.indexOf(u.a)==-1&&r.push(u.a);var y={ref:i[0],id:"{54EE7951-7262-4200-6969-"+("000000000000"+a.tcid++).slice(-12)+"}"};g==0?c=y.id:y.parentId=c,u.ID=y.id,u.a&&(y.personId="{54EE7950-7262-4200-6969-"+("000000000000"+r.indexOf(u.a)).slice(-12)+"}"),n.push(rr("threadedComment",os("text",u.t||""),y))})}),n.push("</ThreadedComments>"),n.join("")}function YT(e){var r=[An,rr("personList",null,{xmlns:Wn.TCMNT,"xmlns:x":Jd[0]}).replace(/[\/]>/,">")];return e.forEach(function(a,n){r.push(rr("person",null,{displayName:a,id:"{54EE7950-7262-4200-6969-"+("000000000000"+n).slice(-12)+"}",userId:a,providerId:"None"}))}),r.push("</personList>"),r.join("")}function ZT(e){var r={};r.iauthor=e.read_shift(4);var a=Fc(e);return r.rfx=a.s,r.ref=Ma(a.s),e.l+=16,r}function qT(e,r){return r==null&&(r=Nt(36)),r.write_shift(4,e[1].iauthor),e0(e[0],r),r.write_shift(4,0),r.write_shift(4,0),r.write_shift(4,0),r.write_shift(4,0),r}var KT=vs;function JT(e){return $n(e.slice(0,54))}function QT(e){var r=Xs(),a=[];return Bt(r,628),Bt(r,630),e.forEach(function(n){n[1].forEach(function(i){a.indexOf(i.a)>-1||(a.push(i.a.slice(0,54)),Bt(r,632,JT(i.a)))})}),Bt(r,631),Bt(r,633),e.forEach(function(n){n[1].forEach(function(i){i.iauthor=a.indexOf(i.a);var c={s:Gn(n[0]),e:Gn(n[0])};Bt(r,635,qT([c,i])),i.t&&i.t.length>0&&Bt(r,637,tj(i)),Bt(r,636),delete i.iauthor})}),Bt(r,634),Bt(r,629),r.end()}function eA(e,r){r.FullPaths.forEach(function(a,n){if(n!=0){var i=a.replace(/[^\/]*[\/]/,"/_VBA_PROJECT_CUR/");i.slice(-1)!=="/"&&Ua.utils.cfb_add(e,i,r.FileIndex[n].content)}})}var Z4=["xlsb","xlsm","xlam","biff8","xla"],tA=(function(){var e=/(^|[^A-Za-z_])R(\[?-?\d+\]|[1-9]\d*|)C(\[?-?\d+\]|[1-9]\d*|)(?![A-Za-z0-9_])/g,r={r:0,c:0};function a(n,i,c,u){var g=!1,y=!1;c.length==0?y=!0:c.charAt(0)=="["&&(y=!0,c=c.slice(1,-1)),u.length==0?g=!0:u.charAt(0)=="["&&(g=!0,u=u.slice(1,-1));var x=c.length>0?parseInt(c,10)|0:0,k=u.length>0?parseInt(u,10)|0:0;return g?k+=r.c:--k,y?x+=r.r:--x,i+(g?"":"$")+bs(k)+(y?"":"$")+ls(x)}return function(i,c){return r=c,i.replace(e,a)}})(),Wp=/(^|[^._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,Gp=(function(){return function(r,a){return r.replace(Wp,function(n,i,c,u,g,y){var x=Fp(u)-(c?0:a.c),k=Pp(y)-(g?0:a.r),N=k==0?"":g?k+1:"["+k+"]",C=x==0?"":c?x+1:"["+x+"]";return i+"R"+N+"C"+C})}})();function rA(e,r){return e.replace(Wp,function(a,n,i,c,u,g){return n+(i=="$"?i+c:bs(Fp(c)+r.c))+(u=="$"?u+g:ls(Pp(g)+r.r))})}function aA(e){return e.length!=1}function En(e){e.l+=1}function $l(e,r){var a=e.read_shift(2);return[a&16383,a>>14&1,a>>15&1]}function q4(e,r,a){var n=2;if(a){if(a.biff>=2&&a.biff<=5)return K4(e);a.biff==12&&(n=4)}var i=e.read_shift(n),c=e.read_shift(n),u=$l(e),g=$l(e);return{s:{r:i,c:u[0],cRel:u[1],rRel:u[2]},e:{r:c,c:g[0],cRel:g[1],rRel:g[2]}}}function K4(e){var r=$l(e),a=$l(e),n=e.read_shift(1),i=e.read_shift(1);return{s:{r:r[0],c:n,cRel:r[1],rRel:r[2]},e:{r:a[0],c:i,cRel:a[1],rRel:a[2]}}}function nA(e,r,a){if(a.biff<8)return K4(e);var n=e.read_shift(a.biff==12?4:2),i=e.read_shift(a.biff==12?4:2),c=$l(e),u=$l(e);return{s:{r:n,c:c[0],cRel:c[1],rRel:c[2]},e:{r:i,c:u[0],cRel:u[1],rRel:u[2]}}}function J4(e,r,a){if(a&&a.biff>=2&&a.biff<=5)return sA(e);var n=e.read_shift(a&&a.biff==12?4:2),i=$l(e);return{r:n,c:i[0],cRel:i[1],rRel:i[2]}}function sA(e){var r=$l(e),a=e.read_shift(1);return{r:r[0],c:a,cRel:r[1],rRel:r[2]}}function iA(e){var r=e.read_shift(2),a=e.read_shift(2);return{r,c:a&255,fQuoted:!!(a&16384),cRel:a>>15,rRel:a>>15}}function oA(e,r,a){var n=a&&a.biff?a.biff:8;if(n>=2&&n<=5)return lA(e);var i=e.read_shift(n>=12?4:2),c=e.read_shift(2),u=(c&16384)>>14,g=(c&32768)>>15;if(c&=16383,g==1)for(;i>524287;)i-=1048576;if(u==1)for(;c>8191;)c=c-16384;return{r:i,c,cRel:u,rRel:g}}function lA(e){var r=e.read_shift(2),a=e.read_shift(1),n=(r&32768)>>15,i=(r&16384)>>14;return r&=16383,n==1&&r>=8192&&(r=r-16384),i==1&&a>=128&&(a=a-256),{r,c:a,cRel:i,rRel:n}}function cA(e,r,a){var n=(e[e.l++]&96)>>5,i=q4(e,a.biff>=2&&a.biff<=5?6:8,a);return[n,i]}function dA(e,r,a){var n=(e[e.l++]&96)>>5,i=e.read_shift(2,"i"),c=8;if(a)switch(a.biff){case 5:e.l+=12,c=6;break;case 12:c=12;break}var u=q4(e,c,a);return[n,i,u]}function uA(e,r,a){var n=(e[e.l++]&96)>>5;return e.l+=a&&a.biff>8?12:a.biff<8?6:8,[n]}function hA(e,r,a){var n=(e[e.l++]&96)>>5,i=e.read_shift(2),c=8;if(a)switch(a.biff){case 5:e.l+=12,c=6;break;case 12:c=12;break}return e.l+=c,[n,i]}function fA(e,r,a){var n=(e[e.l++]&96)>>5,i=nA(e,r-1,a);return[n,i]}function mA(e,r,a){var n=(e[e.l++]&96)>>5;return e.l+=a.biff==2?6:a.biff==12?14:7,[n]}function zv(e){var r=e[e.l+1]&1,a=1;return e.l+=4,[r,a]}function gA(e,r,a){e.l+=2;for(var n=e.read_shift(a&&a.biff==2?1:2),i=[],c=0;c<=n;++c)i.push(e.read_shift(a&&a.biff==2?1:2));return i}function xA(e,r,a){var n=e[e.l+1]&255?1:0;return e.l+=2,[n,e.read_shift(a&&a.biff==2?1:2)]}function pA(e,r,a){var n=e[e.l+1]&255?1:0;return e.l+=2,[n,e.read_shift(a&&a.biff==2?1:2)]}function yA(e){var r=e[e.l+1]&255?1:0;return e.l+=2,[r,e.read_shift(2)]}function bA(e,r,a){var n=e[e.l+1]&255?1:0;return e.l+=a&&a.biff==2?3:4,[n]}function Q4(e){var r=e.read_shift(1),a=e.read_shift(1);return[r,a]}function vA(e){return e.read_shift(2),Q4(e)}function _A(e){return e.read_shift(2),Q4(e)}function wA(e,r,a){var n=(e[e.l]&96)>>5;e.l+=1;var i=J4(e,0,a);return[n,i]}function kA(e,r,a){var n=(e[e.l]&96)>>5;e.l+=1;var i=oA(e,0,a);return[n,i]}function NA(e,r,a){var n=(e[e.l]&96)>>5;e.l+=1;var i=e.read_shift(2);a&&a.biff==5&&(e.l+=12);var c=J4(e,0,a);return[n,i,c]}function SA(e,r,a){var n=(e[e.l]&96)>>5;e.l+=1;var i=e.read_shift(a&&a.biff<=3?1:2);return[S7[i],r3[i],n]}function CA(e,r,a){var n=e[e.l++],i=e.read_shift(1),c=a&&a.biff<=3?[n==88?-1:0,e.read_shift(1)]:EA(e);return[i,(c[0]===0?r3:N7)[c[1]]]}function EA(e){return[e[e.l+1]>>7,e.read_shift(2)&32767]}function jA(e,r,a){e.l+=a&&a.biff==2?3:4}function TA(e,r,a){if(e.l++,a&&a.biff==12)return[e.read_shift(4,"i"),0];var n=e.read_shift(2),i=e.read_shift(a&&a.biff==2?1:2);return[n,i]}function AA(e){return e.l++,Ou[e.read_shift(1)]}function OA(e){return e.l++,e.read_shift(2)}function RA(e){return e.l++,e.read_shift(1)!==0}function MA(e){return e.l++,t0(e)}function DA(e,r,a){return e.l++,L4(e,r-1,a)}function LA(e,r){var a=[e.read_shift(1)];if(r==12)switch(a[0]){case 2:a[0]=4;break;case 4:a[0]=16;break;case 0:a[0]=1;break;case 1:a[0]=2;break}switch(a[0]){case 4:a[1]=Nj(e,1)?"TRUE":"FALSE",r!=12&&(e.l+=7);break;case 37:case 16:a[1]=Ou[e[e.l]],e.l+=r==12?4:8;break;case 0:e.l+=8;break;case 1:a[1]=t0(e);break;case 2:a[1]=jj(e,0,{biff:r>0&&r<8?2:r});break;default:throw new Error("Bad SerAr: "+a[0])}return a}function IA(e,r,a){for(var n=e.read_shift(a.biff==12?4:2),i=[],c=0;c!=n;++c)i.push((a.biff==12?Fc:Oj)(e));return i}function PA(e,r,a){var n=0,i=0;a.biff==12?(n=e.read_shift(4),i=e.read_shift(4)):(i=1+e.read_shift(1),n=1+e.read_shift(2)),a.biff>=2&&a.biff<8&&(--n,--i==0&&(i=256));for(var c=0,u=[];c!=n&&(u[c]=[]);++c)for(var g=0;g!=i;++g)u[c][g]=LA(e,a.biff);return u}function FA(e,r,a){var n=e.read_shift(1)>>>5&3,i=!a||a.biff>=8?4:2,c=e.read_shift(i);switch(a.biff){case 2:e.l+=5;break;case 3:case 4:e.l+=8;break;case 5:e.l+=12;break}return[n,0,c]}function BA(e,r,a){if(a.biff==5)return UA(e);var n=e.read_shift(1)>>>5&3,i=e.read_shift(2),c=e.read_shift(4);return[n,i,c]}function UA(e){var r=e.read_shift(1)>>>5&3,a=e.read_shift(2,"i");e.l+=8;var n=e.read_shift(2);return e.l+=12,[r,a,n]}function zA(e,r,a){var n=e.read_shift(1)>>>5&3;e.l+=a&&a.biff==2?3:4;var i=e.read_shift(a&&a.biff==2?1:2);return[n,i]}function HA(e,r,a){var n=e.read_shift(1)>>>5&3,i=e.read_shift(a&&a.biff==2?1:2);return[n,i]}function VA(e,r,a){var n=e.read_shift(1)>>>5&3;return e.l+=4,a.biff<8&&e.l--,a.biff==12&&(e.l+=2),[n]}function WA(e,r,a){var n=(e[e.l++]&96)>>5,i=e.read_shift(2),c=4;if(a)switch(a.biff){case 5:c=15;break;case 12:c=6;break}return e.l+=c,[n,i]}var GA=So,$A=So,XA=So;function Ru(e,r,a){return e.l+=2,[iA(e)]}function $p(e){return e.l+=6,[]}var YA=Ru,ZA=$p,qA=$p,KA=Ru;function e3(e){return e.l+=2,[M4(e),e.read_shift(2)&1]}var JA=Ru,QA=e3,e7=$p,t7=Ru,r7=Ru,a7=["Data","All","Headers","??","?Data2","??","?DataHeaders","??","Totals","??","??","??","?DataTotals","??","??","??","?Current"];function n7(e){e.l+=2;var r=e.read_shift(2),a=e.read_shift(2),n=e.read_shift(4),i=e.read_shift(2),c=e.read_shift(2),u=a7[a>>2&31];return{ixti:r,coltype:a&3,rt:u,idx:n,c:i,C:c}}function s7(e){return e.l+=2,[e.read_shift(4)]}function i7(e,r,a){return e.l+=5,e.l+=2,e.l+=a.biff==2?1:4,["PTGSHEET"]}function o7(e,r,a){return e.l+=a.biff==2?4:5,["PTGENDSHEET"]}function l7(e){var r=e.read_shift(1)>>>5&3,a=e.read_shift(2);return[r,a]}function c7(e){var r=e.read_shift(1)>>>5&3,a=e.read_shift(2);return[r,a]}function d7(e){return e.l+=4,[0,0]}var Hv={1:{n:"PtgExp",f:TA},2:{n:"PtgTbl",f:XA},3:{n:"PtgAdd",f:En},4:{n:"PtgSub",f:En},5:{n:"PtgMul",f:En},6:{n:"PtgDiv",f:En},7:{n:"PtgPower",f:En},8:{n:"PtgConcat",f:En},9:{n:"PtgLt",f:En},10:{n:"PtgLe",f:En},11:{n:"PtgEq",f:En},12:{n:"PtgGe",f:En},13:{n:"PtgGt",f:En},14:{n:"PtgNe",f:En},15:{n:"PtgIsect",f:En},16:{n:"PtgUnion",f:En},17:{n:"PtgRange",f:En},18:{n:"PtgUplus",f:En},19:{n:"PtgUminus",f:En},20:{n:"PtgPercent",f:En},21:{n:"PtgParen",f:En},22:{n:"PtgMissArg",f:En},23:{n:"PtgStr",f:DA},26:{n:"PtgSheet",f:i7},27:{n:"PtgEndSheet",f:o7},28:{n:"PtgErr",f:AA},29:{n:"PtgBool",f:RA},30:{n:"PtgInt",f:OA},31:{n:"PtgNum",f:MA},32:{n:"PtgArray",f:mA},33:{n:"PtgFunc",f:SA},34:{n:"PtgFuncVar",f:CA},35:{n:"PtgName",f:FA},36:{n:"PtgRef",f:wA},37:{n:"PtgArea",f:cA},38:{n:"PtgMemArea",f:zA},39:{n:"PtgMemErr",f:GA},40:{n:"PtgMemNoMem",f:$A},41:{n:"PtgMemFunc",f:HA},42:{n:"PtgRefErr",f:VA},43:{n:"PtgAreaErr",f:uA},44:{n:"PtgRefN",f:kA},45:{n:"PtgAreaN",f:fA},46:{n:"PtgMemAreaN",f:l7},47:{n:"PtgMemNoMemN",f:c7},57:{n:"PtgNameX",f:BA},58:{n:"PtgRef3d",f:NA},59:{n:"PtgArea3d",f:dA},60:{n:"PtgRefErr3d",f:WA},61:{n:"PtgAreaErr3d",f:hA},255:{}},u7={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},h7={1:{n:"PtgElfLel",f:e3},2:{n:"PtgElfRw",f:t7},3:{n:"PtgElfCol",f:YA},6:{n:"PtgElfRwV",f:r7},7:{n:"PtgElfColV",f:KA},10:{n:"PtgElfRadical",f:JA},11:{n:"PtgElfRadicalS",f:e7},13:{n:"PtgElfColS",f:ZA},15:{n:"PtgElfColSV",f:qA},16:{n:"PtgElfRadicalLel",f:QA},25:{n:"PtgList",f:n7},29:{n:"PtgSxName",f:s7},255:{}},f7={0:{n:"PtgAttrNoop",f:d7},1:{n:"PtgAttrSemi",f:bA},2:{n:"PtgAttrIf",f:pA},4:{n:"PtgAttrChoose",f:gA},8:{n:"PtgAttrGoto",f:xA},16:{n:"PtgAttrSum",f:jA},32:{n:"PtgAttrBaxcel",f:zv},33:{n:"PtgAttrBaxcel",f:zv},64:{n:"PtgAttrSpace",f:vA},65:{n:"PtgAttrSpaceSemi",f:_A},128:{n:"PtgAttrIfError",f:yA},255:{}};function m7(e,r,a,n){if(n.biff<8)return So(e,r);for(var i=e.l+r,c=[],u=0;u!==a.length;++u)switch(a[u][0]){case"PtgArray":a[u][1]=PA(e,0,n),c.push(a[u][1]);break;case"PtgMemArea":a[u][2]=IA(e,a[u][1],n),c.push(a[u][2]);break;case"PtgExp":n&&n.biff==12&&(a[u][1][1]=e.read_shift(4),c.push(a[u][1]));break;case"PtgList":case"PtgElfRadicalS":case"PtgElfColS":case"PtgElfColSV":throw"Unsupported "+a[u][0]}return r=i-e.l,r!==0&&c.push(So(e,r)),c}function g7(e,r,a){for(var n=e.l+r,i,c,u=[];n!=e.l;)r=n-e.l,c=e[e.l],i=Hv[c]||Hv[u7[c]],(c===24||c===25)&&(i=(c===24?h7:f7)[e[e.l+1]]),!i||!i.f?So(e,r):u.push([i.n,i.f(e,r,a)]);return u}function x7(e){for(var r=[],a=0;a<e.length;++a){for(var n=e[a],i=[],c=0;c<n.length;++c){var u=n[c];if(u)switch(u[0]){case 2:i.push('"'+u[1].replace(/"/g,'""')+'"');break;default:i.push(u[1])}else i.push("")}r.push(i.join(","))}return r.join(";")}var p7={PtgAdd:"+",PtgConcat:"&",PtgDiv:"/",PtgEq:"=",PtgGe:">=",PtgGt:">",PtgLe:"<=",PtgLt:"<",PtgMul:"*",PtgNe:"<>",PtgPower:"^",PtgSub:"-"};function y7(e,r){if(!e&&!(r&&r.biff<=5&&r.biff>=2))throw new Error("empty sheet name");return/[^\w\u4E00-\u9FFF\u3040-\u30FF]/.test(e)?"'"+e+"'":e}function t3(e,r,a){if(!e)return"SH33TJSERR0";if(a.biff>8&&(!e.XTI||!e.XTI[r]))return e.SheetNames[r];if(!e.XTI)return"SH33TJSERR6";var n=e.XTI[r];if(a.biff<8)return r>1e4&&(r-=65536),r<0&&(r=-r),r==0?"":e.XTI[r-1];if(!n)return"SH33TJSERR1";var i="";if(a.biff>8)switch(e[n[0]][0]){case 357:return i=n[1]==-1?"#REF":e.SheetNames[n[1]],n[1]==n[2]?i:i+":"+e.SheetNames[n[2]];case 358:return a.SID!=null?e.SheetNames[a.SID]:"SH33TJSSAME"+e[n[0]][0];case 355:default:return"SH33TJSSRC"+e[n[0]][0]}switch(e[n[0]][0][0]){case 1025:return i=n[1]==-1?"#REF":e.SheetNames[n[1]]||"SH33TJSERR3",n[1]==n[2]?i:i+":"+e.SheetNames[n[2]];case 14849:return e[n[0]].slice(1).map(function(c){return c.Name}).join(";;");default:return e[n[0]][0][3]?(i=n[1]==-1?"#REF":e[n[0]][0][3][n[1]]||"SH33TJSERR4",n[1]==n[2]?i:i+":"+e[n[0]][0][3][n[2]]):"SH33TJSERR2"}}function Vv(e,r,a){var n=t3(e,r,a);return n=="#REF"?n:y7(n,a)}function Wd(e,r,a,n,i){var c=i&&i.biff||8,u={s:{c:0,r:0}},g=[],y,x,k,N=0,C=0,O,D="";if(!e[0]||!e[0][0])return"";for(var A=-1,I="",z=0,U=e[0].length;z<U;++z){var B=e[0][z];switch(B[0]){case"PtgUminus":g.push("-"+g.pop());break;case"PtgUplus":g.push("+"+g.pop());break;case"PtgPercent":g.push(g.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(y=g.pop(),x=g.pop(),A>=0){switch(e[0][A][1][0]){case 0:I=fn(" ",e[0][A][1][1]);break;case 1:I=fn("\r",e[0][A][1][1]);break;default:if(I="",i.WTF)throw new Error("Unexpected PtgAttrSpaceType "+e[0][A][1][0])}x=x+I,A=-1}g.push(x+p7[B[0]]+y);break;case"PtgIsect":y=g.pop(),x=g.pop(),g.push(x+" "+y);break;case"PtgUnion":y=g.pop(),x=g.pop(),g.push(x+","+y);break;case"PtgRange":y=g.pop(),x=g.pop(),g.push(x+":"+y);break;case"PtgAttrChoose":break;case"PtgAttrGoto":break;case"PtgAttrIf":break;case"PtgAttrIfError":break;case"PtgRef":k=ou(B[1][1],u,i),g.push(lu(k,c));break;case"PtgRefN":k=a?ou(B[1][1],a,i):B[1][1],g.push(lu(k,c));break;case"PtgRef3d":N=B[1][1],k=ou(B[1][2],u,i),D=Vv(n,N,i),g.push(D+"!"+lu(k,c));break;case"PtgFunc":case"PtgFuncVar":var V=B[1][0],Z=B[1][1];V||(V=0),V&=127;var W=V==0?[]:g.slice(-V);g.length-=V,Z==="User"&&(Z=W.shift()),g.push(Z+"("+W.join(",")+")");break;case"PtgBool":g.push(B[1]?"TRUE":"FALSE");break;case"PtgInt":g.push(B[1]);break;case"PtgNum":g.push(String(B[1]));break;case"PtgStr":g.push('"'+B[1].replace(/"/g,'""')+'"');break;case"PtgErr":g.push(B[1]);break;case"PtgAreaN":O=Ev(B[1][1],a?{s:a}:u,i),g.push(Ex(O,i));break;case"PtgArea":O=Ev(B[1][1],u,i),g.push(Ex(O,i));break;case"PtgArea3d":N=B[1][1],O=B[1][2],D=Vv(n,N,i),g.push(D+"!"+Ex(O,i));break;case"PtgAttrSum":g.push("SUM("+g.pop()+")");break;case"PtgAttrBaxcel":case"PtgAttrSemi":break;case"PtgName":C=B[1][2];var H=(n.names||[])[C-1]||(n[0]||[])[C],le=H?H.Name:"SH33TJSNAME"+String(C);le&&le.slice(0,6)=="_xlfn."&&!i.xlfn&&(le=le.slice(6)),g.push(le);break;case"PtgNameX":var Q=B[1][1];C=B[1][2];var Ne;if(i.biff<=5)Q<0&&(Q=-Q),n[Q]&&(Ne=n[Q][C]);else{var oe="";if(((n[Q]||[])[0]||[])[0]==14849||(((n[Q]||[])[0]||[])[0]==1025?n[Q][C]&&n[Q][C].itab>0&&(oe=n.SheetNames[n[Q][C].itab-1]+"!"):oe=n.SheetNames[C-1]+"!"),n[Q]&&n[Q][C])oe+=n[Q][C].Name;else if(n[0]&&n[0][C])oe+=n[0][C].Name;else{var se=(t3(n,Q,i)||"").split(";;");se[C-1]?oe=se[C-1]:oe+="SH33TJSERRX"}g.push(oe);break}Ne||(Ne={Name:"SH33TJSERRY"}),g.push(Ne.Name);break;case"PtgParen":var ce="(",Ce=")";if(A>=0){switch(I="",e[0][A][1][0]){case 2:ce=fn(" ",e[0][A][1][1])+ce;break;case 3:ce=fn("\r",e[0][A][1][1])+ce;break;case 4:Ce=fn(" ",e[0][A][1][1])+Ce;break;case 5:Ce=fn("\r",e[0][A][1][1])+Ce;break;default:if(i.WTF)throw new Error("Unexpected PtgAttrSpaceType "+e[0][A][1][0])}A=-1}g.push(ce+g.pop()+Ce);break;case"PtgRefErr":g.push("#REF!");break;case"PtgRefErr3d":g.push("#REF!");break;case"PtgExp":k={c:B[1][1],r:B[1][0]};var ae={c:a.c,r:a.r};if(n.sharedf[Ma(k)]){var me=n.sharedf[Ma(k)];g.push(Wd(me,u,ae,n,i))}else{var K=!1;for(y=0;y!=n.arrayf.length;++y)if(x=n.arrayf[y],!(k.c<x[0].s.c||k.c>x[0].e.c)&&!(k.r<x[0].s.r||k.r>x[0].e.r)){g.push(Wd(x[1],u,ae,n,i)),K=!0;break}K||g.push(B[1])}break;case"PtgArray":g.push("{"+x7(B[1])+"}");break;case"PtgMemArea":break;case"PtgAttrSpace":case"PtgAttrSpaceSemi":A=z;break;case"PtgTbl":break;case"PtgMemErr":break;case"PtgMissArg":g.push("");break;case"PtgAreaErr":g.push("#REF!");break;case"PtgAreaErr3d":g.push("#REF!");break;case"PtgList":g.push("Table"+B[1].idx+"[#"+B[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(B));default:throw new Error("Unrecognized Formula Token: "+String(B))}var fe=["PtgAttrSpace","PtgAttrSpaceSemi","PtgAttrGoto"];if(i.biff!=3&&A>=0&&fe.indexOf(e[0][z][0])==-1){B=e[0][A];var Oe=!0;switch(B[1][0]){case 4:Oe=!1;case 0:I=fn(" ",B[1][1]);break;case 5:Oe=!1;case 1:I=fn("\r",B[1][1]);break;default:if(I="",i.WTF)throw new Error("Unexpected PtgAttrSpaceType "+B[1][0])}g.push((Oe?I:"")+g.pop()+(Oe?"":I)),A=-1}}if(g.length>1&&i.WTF)throw new Error("bad formula stack");return g[0]}function b7(e){if(e==null){var r=Nt(8);return r.write_shift(1,3),r.write_shift(1,0),r.write_shift(2,0),r.write_shift(2,0),r.write_shift(2,65535),r}else if(typeof e=="number")return Ac(e);return Ac(0)}function v7(e,r,a,n,i){var c=Oc(r,a,i),u=b7(e.v),g=Nt(6),y=33;g.write_shift(2,y),g.write_shift(4,0);for(var x=Nt(e.bf.length),k=0;k<e.bf.length;++k)x[k]=e.bf[k];var N=is([c,u,g,x]);return N}function im(e,r,a){var n=e.read_shift(4),i=g7(e,n,a),c=e.read_shift(4),u=c>0?m7(e,c,i,a):null;return[i,u]}var _7=im,om=im,w7=im,k7=im,N7={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"},r3={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"},S7={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 C7(e){var r="of:="+e.replace(Wp,"$1[.$2$3$4$5]").replace(/\]:\[/g,":");return r.replace(/;/g,"|").replace(/,/g,";")}function E7(e){return e.replace(/\./,"!")}var cu=typeof Map!="undefined";function Xp(e,r,a){var n=0,i=e.length;if(a){if(cu?a.has(r):Object.prototype.hasOwnProperty.call(a,r)){for(var c=cu?a.get(r):a[r];n<c.length;++n)if(e[c[n]].t===r)return e.Count++,c[n]}}else for(;n<i;++n)if(e[n].t===r)return e.Count++,n;return e[i]={t:r},e.Count++,e.Unique++,a&&(cu?(a.has(r)||a.set(r,[]),a.get(r).push(i)):(Object.prototype.hasOwnProperty.call(a,r)||(a[r]=[]),a[r].push(i))),i}function lm(e,r){var a={min:e+1,max:e+1},n=-1;return r.MDW&&(tl=r.MDW),r.width!=null?a.customWidth=1:r.wpx!=null?n=Pf(r.wpx):r.wch!=null&&(n=r.wch),n>-1?(a.width=rp(n),a.customWidth=1):r.width!=null&&(a.width=r.width),r.hidden&&(a.hidden=!0),r.level!=null&&(a.outlineLevel=a.level=r.level),a}function a3(e,r){if(e){var a=[.7,.7,.75,.75,.3,.3];e.left==null&&(e.left=a[0]),e.right==null&&(e.right=a[1]),e.top==null&&(e.top=a[2]),e.bottom==null&&(e.bottom=a[3]),e.header==null&&(e.header=a[4]),e.footer==null&&(e.footer=a[5])}}function ql(e,r,a){var n=a.revssf[r.z!=null?r.z:"General"],i=60,c=e.length;if(n==null&&a.ssf){for(;i<392;++i)if(a.ssf[i]==null){Jw(r.z,i),a.ssf[i]=r.z,a.revssf[r.z]=n=i;break}}for(i=0;i!=c;++i)if(e[i].numFmtId===n)return i;return e[c]={numFmtId:n,fontId:0,fillId:0,borderId:0,xfId:0,applyNumberFormat:1},c}function j7(e,r,a){if(e&&e["!ref"]){var n=Ya(e["!ref"]);if(n.e.c<n.s.c||n.e.r<n.s.r)throw new Error("Bad range ("+a+"): "+e["!ref"])}}function T7(e){if(e.length===0)return"";for(var r='<mergeCells count="'+e.length+'">',a=0;a!=e.length;++a)r+='<mergeCell ref="'+Tn(e[a])+'"/>';return r+"</mergeCells>"}function A7(e,r,a,n,i){var c=!1,u={},g=null;if(n.bookType!=="xlsx"&&r.vbaraw){var y=r.SheetNames[a];try{r.Workbook&&(y=r.Workbook.Sheets[a].CodeName||y)}catch(k){}c=!0,u.codeName=pu(Ra(y))}if(e&&e["!outline"]){var x={summaryBelow:1,summaryRight:1};e["!outline"].above&&(x.summaryBelow=0),e["!outline"].left&&(x.summaryRight=0),g=(g||"")+rr("outlinePr",null,x)}!c&&!g||(i[i.length]=rr("sheetPr",g,u))}var O7=["objects","scenarios","selectLockedCells","selectUnlockedCells"],R7=["formatColumns","formatRows","formatCells","insertColumns","insertRows","insertHyperlinks","deleteColumns","deleteRows","sort","autoFilter","pivotTables"];function M7(e){var r={sheet:1};return O7.forEach(function(a){e[a]!=null&&e[a]&&(r[a]="1")}),R7.forEach(function(a){e[a]!=null&&!e[a]&&(r[a]="0")}),e.password&&(r.password=U4(e.password).toString(16).toUpperCase()),rr("sheetProtection",null,r)}function D7(e){return a3(e),rr("pageMargins",null,e)}function L7(e,r){for(var a=["<cols>"],n,i=0;i!=r.length;++i)(n=r[i])&&(a[a.length]=rr("col",null,lm(i,n)));return a[a.length]="</cols>",a.join("")}function I7(e,r,a,n){var i=typeof e.ref=="string"?e.ref:Tn(e.ref);a.Workbook||(a.Workbook={Sheets:[]}),a.Workbook.Names||(a.Workbook.Names=[]);var c=a.Workbook.Names,u=pi(i);u.s.r==u.e.r&&(u.e.r=pi(r["!ref"]).e.r,i=Tn(u));for(var g=0;g<c.length;++g){var y=c[g];if(y.Name=="_xlnm._FilterDatabase"&&y.Sheet==n){y.Ref="'"+a.SheetNames[n]+"'!"+i;break}}return g==c.length&&c.push({Name:"_xlnm._FilterDatabase",Sheet:n,Ref:"'"+a.SheetNames[n]+"'!"+i}),rr("autoFilter",null,{ref:i})}function P7(e,r,a,n){var i={workbookViewId:"0"};return(((n||{}).Workbook||{}).Views||[])[0]&&(i.rightToLeft=n.Workbook.Views[0].RTL?"1":"0"),rr("sheetViews",rr("sheetView",null,i),{})}function F7(e,r,a,n){if(e.c&&a["!comments"].push([r,e.c]),e.v===void 0&&typeof e.f!="string"||e.t==="z"&&!e.f)return"";var i="",c=e.t,u=e.v;if(e.t!=="z")switch(e.t){case"b":i=e.v?"1":"0";break;case"n":i=""+e.v;break;case"e":i=Ou[e.v];break;case"d":n&&n.cellDates?i=Os(e.v,-1).toISOString():(e=Js(e),e.t="n",i=""+(e.v=Ks(Os(e.v)))),typeof e.z=="undefined"&&(e.z=mn[14]);break;default:i=e.v;break}var g=os("v",Ra(i)),y={r},x=ql(n.cellXfs,e,n);switch(x!==0&&(y.s=x),e.t){case"n":break;case"d":y.t="d";break;case"b":y.t="b";break;case"e":y.t="e";break;case"z":break;default:if(e.v==null){delete e.t;break}if(e.v.length>32767)throw new Error("Text length must not exceed 32767 characters");if(n&&n.bookSST){g=os("v",""+Xp(n.Strings,e.v,n.revStrings)),y.t="s";break}y.t="str";break}if(e.t!=c&&(e.t=c,e.v=u),typeof e.f=="string"&&e.f){var k=e.F&&e.F.slice(0,r.length)==r?{t:"array",ref:e.F}:null;g=rr("f",Ra(e.f),k)+(e.v!=null?g:"")}return e.l&&a["!links"].push([r,e.l]),e.D&&(y.cm=1),rr("c",g,y)}function B7(e,r,a,n){var i=[],c=[],u=Ya(e["!ref"]),g="",y,x="",k=[],N=0,C=0,O=e["!rows"],D=Array.isArray(e),A={r:x},I,z=-1;for(C=u.s.c;C<=u.e.c;++C)k[C]=bs(C);for(N=u.s.r;N<=u.e.r;++N){for(c=[],x=ls(N),C=u.s.c;C<=u.e.c;++C){y=k[C]+x;var U=D?(e[N]||[])[C]:e[y];U!==void 0&&(g=F7(U,y,e,r))!=null&&c.push(g)}(c.length>0||O&&O[N])&&(A={r:x},O&&O[N]&&(I=O[N],I.hidden&&(A.hidden=1),z=-1,I.hpx?z=Ff(I.hpx):I.hpt&&(z=I.hpt),z>-1&&(A.ht=z,A.customHeight=1),I.level&&(A.outlineLevel=I.level)),i[i.length]=rr("row",c.join(""),A))}if(O)for(;N<O.length;++N)O&&O[N]&&(A={r:N+1},I=O[N],I.hidden&&(A.hidden=1),z=-1,I.hpx?z=Ff(I.hpx):I.hpt&&(z=I.hpt),z>-1&&(A.ht=z,A.customHeight=1),I.level&&(A.outlineLevel=I.level),i[i.length]=rr("row","",A));return i.join("")}function n3(e,r,a,n){var i=[An,rr("worksheet",null,{xmlns:Jd[0],"xmlns:r":Wn.r})],c=a.SheetNames[e],u=0,g="",y=a.Sheets[c];y==null&&(y={});var x=y["!ref"]||"A1",k=Ya(x);if(k.e.c>16383||k.e.r>1048575){if(r.WTF)throw new Error("Range "+x+" exceeds format limit A1:XFD1048576");k.e.c=Math.min(k.e.c,16383),k.e.r=Math.min(k.e.c,1048575),x=Tn(k)}n||(n={}),y["!comments"]=[];var N=[];A7(y,a,e,r,i),i[i.length]=rr("dimension",null,{ref:x}),i[i.length]=P7(y,r,e,a),r.sheetFormat&&(i[i.length]=rr("sheetFormatPr",null,{defaultRowHeight:r.sheetFormat.defaultRowHeight||"16",baseColWidth:r.sheetFormat.baseColWidth||"10",outlineLevelRow:r.sheetFormat.outlineLevelRow||"7"})),y["!cols"]!=null&&y["!cols"].length>0&&(i[i.length]=L7(y,y["!cols"])),i[u=i.length]="<sheetData/>",y["!links"]=[],y["!ref"]!=null&&(g=B7(y,r),g.length>0&&(i[i.length]=g)),i.length>u+1&&(i[i.length]="</sheetData>",i[u]=i[u].replace("/>",">")),y["!protect"]&&(i[i.length]=M7(y["!protect"])),y["!autofilter"]!=null&&(i[i.length]=I7(y["!autofilter"],y,a,e)),y["!merges"]!=null&&y["!merges"].length>0&&(i[i.length]=T7(y["!merges"]));var C=-1,O,D=-1;return y["!links"].length>0&&(i[i.length]="<hyperlinks>",y["!links"].forEach(function(A){A[1].Target&&(O={ref:A[0]},A[1].Target.charAt(0)!="#"&&(D=Oa(n,-1,Ra(A[1].Target).replace(/#.*$/,""),va.HLINK),O["r:id"]="rId"+D),(C=A[1].Target.indexOf("#"))>-1&&(O.location=Ra(A[1].Target.slice(C+1))),A[1].Tooltip&&(O.tooltip=Ra(A[1].Tooltip)),i[i.length]=rr("hyperlink",null,O))}),i[i.length]="</hyperlinks>"),delete y["!links"],y["!margins"]!=null&&(i[i.length]=D7(y["!margins"])),(!r||r.ignoreEC||r.ignoreEC==null)&&(i[i.length]=os("ignoredErrors",rr("ignoredError",null,{numberStoredAsText:1,sqref:x}))),N.length>0&&(D=Oa(n,-1,"../drawings/drawing"+(e+1)+".xml",va.DRAW),i[i.length]=rr("drawing",null,{"r:id":"rId"+D}),y["!drawing"]=N),y["!comments"].length>0&&(D=Oa(n,-1,"../drawings/vmlDrawing"+(e+1)+".vml",va.VML),i[i.length]=rr("legacyDrawing",null,{"r:id":"rId"+D}),y["!legacy"]=D),i.length>1&&(i[i.length]="</worksheet>",i[1]=i[1].replace("/>",">")),i.join("")}function U7(e,r){var a={},n=e.l+r;a.r=e.read_shift(4),e.l+=4;var i=e.read_shift(2);e.l+=1;var c=e.read_shift(1);return e.l=n,c&7&&(a.level=c&7),c&16&&(a.hidden=!0),c&32&&(a.hpt=i/20),a}function z7(e,r,a){var n=Nt(145),i=(a["!rows"]||[])[e]||{};n.write_shift(4,e),n.write_shift(4,0);var c=320;i.hpx?c=Ff(i.hpx)*20:i.hpt&&(c=i.hpt*20),n.write_shift(2,c),n.write_shift(1,0);var u=0;i.level&&(u|=i.level),i.hidden&&(u|=16),(i.hpx||i.hpt)&&(u|=32),n.write_shift(1,u),n.write_shift(1,0);var g=0,y=n.l;n.l+=4;for(var x={r:e,c:0},k=0;k<16;++k)if(!(r.s.c>k+1<<10||r.e.c<k<<10)){for(var N=-1,C=-1,O=k<<10;O<k+1<<10;++O){x.c=O;var D=Array.isArray(a)?(a[x.r]||[])[x.c]:a[Ma(x)];D&&(N<0&&(N=O),C=O)}N<0||(++g,n.write_shift(4,N),n.write_shift(4,C))}var A=n.l;return n.l=y,n.write_shift(4,g),n.l=A,n.length>n.l?n.slice(0,n.l):n}function H7(e,r,a,n){var i=z7(n,a,r);(i.length>17||(r["!rows"]||[])[n])&&Bt(e,0,i)}var V7=Fc,W7=e0;function G7(){}function $7(e,r){var a={},n=e[e.l];return++e.l,a.above=!(n&64),a.left=!(n&128),e.l+=18,a.name=rj(e),a}function X7(e,r,a){a==null&&(a=Nt(84+4*e.length));var n=192;r&&(r.above&&(n&=-65),r.left&&(n&=-129)),a.write_shift(1,n);for(var i=1;i<3;++i)a.write_shift(1,0);return Df({auto:1},a),a.write_shift(-4,-1),a.write_shift(-4,-1),b4(e,a),a.slice(0,a.l)}function Y7(e){var r=Ii(e);return[r]}function Z7(e,r,a){return a==null&&(a=Nt(8)),Lc(r,a)}function q7(e){var r=Ic(e);return[r]}function K7(e,r,a){return a==null&&(a=Nt(4)),Pc(r,a)}function J7(e){var r=Ii(e),a=e.read_shift(1);return[r,a,"b"]}function Q7(e,r,a){return a==null&&(a=Nt(9)),Lc(r,a),a.write_shift(1,e.v?1:0),a}function e9(e){var r=Ic(e),a=e.read_shift(1);return[r,a,"b"]}function t9(e,r,a){return a==null&&(a=Nt(5)),Pc(r,a),a.write_shift(1,e.v?1:0),a}function r9(e){var r=Ii(e),a=e.read_shift(1);return[r,a,"e"]}function a9(e,r,a){return a==null&&(a=Nt(9)),Lc(r,a),a.write_shift(1,e.v),a}function n9(e){var r=Ic(e),a=e.read_shift(1);return[r,a,"e"]}function s9(e,r,a){return a==null&&(a=Nt(8)),Pc(r,a),a.write_shift(1,e.v),a.write_shift(2,0),a.write_shift(1,0),a}function i9(e){var r=Ii(e),a=e.read_shift(4);return[r,a,"s"]}function o9(e,r,a){return a==null&&(a=Nt(12)),Lc(r,a),a.write_shift(4,r.v),a}function l9(e){var r=Ic(e),a=e.read_shift(4);return[r,a,"s"]}function c9(e,r,a){return a==null&&(a=Nt(8)),Pc(r,a),a.write_shift(4,r.v),a}function d9(e){var r=Ii(e),a=t0(e);return[r,a,"n"]}function u9(e,r,a){return a==null&&(a=Nt(16)),Lc(r,a),Ac(e.v,a),a}function h9(e){var r=Ic(e),a=t0(e);return[r,a,"n"]}function f9(e,r,a){return a==null&&(a=Nt(12)),Pc(r,a),Ac(e.v,a),a}function m9(e){var r=Ii(e),a=v4(e);return[r,a,"n"]}function g9(e,r,a){return a==null&&(a=Nt(12)),Lc(r,a),_4(e.v,a),a}function x9(e){var r=Ic(e),a=v4(e);return[r,a,"n"]}function p9(e,r,a){return a==null&&(a=Nt(8)),Pc(r,a),_4(e.v,a),a}function y9(e){var r=Ii(e),a=Bp(e);return[r,a,"is"]}function b9(e){var r=Ii(e),a=vs(e);return[r,a,"str"]}function v9(e,r,a){return a==null&&(a=Nt(12+4*e.v.length)),Lc(r,a),$n(e.v,a),a.length>a.l?a.slice(0,a.l):a}function _9(e){var r=Ic(e),a=vs(e);return[r,a,"str"]}function w9(e,r,a){return a==null&&(a=Nt(8+4*e.v.length)),Pc(r,a),$n(e.v,a),a.length>a.l?a.slice(0,a.l):a}function k9(e,r,a){var n=e.l+r,i=Ii(e);i.r=a["!row"];var c=e.read_shift(1),u=[i,c,"b"];if(a.cellFormula){e.l+=2;var g=om(e,n-e.l,a);u[3]=Wd(g,null,i,a.supbooks,a)}else e.l=n;return u}function N9(e,r,a){var n=e.l+r,i=Ii(e);i.r=a["!row"];var c=e.read_shift(1),u=[i,c,"e"];if(a.cellFormula){e.l+=2;var g=om(e,n-e.l,a);u[3]=Wd(g,null,i,a.supbooks,a)}else e.l=n;return u}function S9(e,r,a){var n=e.l+r,i=Ii(e);i.r=a["!row"];var c=t0(e),u=[i,c,"n"];if(a.cellFormula){e.l+=2;var g=om(e,n-e.l,a);u[3]=Wd(g,null,i,a.supbooks,a)}else e.l=n;return u}function C9(e,r,a){var n=e.l+r,i=Ii(e);i.r=a["!row"];var c=vs(e),u=[i,c,"str"];if(a.cellFormula){e.l+=2;var g=om(e,n-e.l,a);u[3]=Wd(g,null,i,a.supbooks,a)}else e.l=n;return u}var E9=Fc,j9=e0;function T9(e,r){return r==null&&(r=Nt(4)),r.write_shift(4,e),r}function A9(e,r){var a=e.l+r,n=Fc(e),i=Up(e),c=vs(e),u=vs(e),g=vs(e);e.l=a;var y={rfx:n,relId:i,loc:c,display:g};return u&&(y.Tooltip=u),y}function O9(e,r){var a=Nt(50+4*(e[1].Target.length+(e[1].Tooltip||"").length));e0({s:Gn(e[0]),e:Gn(e[0])},a),zp("rId"+r,a);var n=e[1].Target.indexOf("#"),i=n==-1?"":e[1].Target.slice(n+1);return $n(i||"",a),$n(e[1].Tooltip||"",a),$n("",a),a.slice(0,a.l)}function R9(){}function M9(e,r,a){var n=e.l+r,i=w4(e),c=e.read_shift(1),u=[i];if(u[2]=c,a.cellFormula){var g=_7(e,n-e.l,a);u[1]=g}else e.l=n;return u}function D9(e,r,a){var n=e.l+r,i=Fc(e),c=[i];if(a.cellFormula){var u=k7(e,n-e.l,a);c[1]=u,e.l=n}else e.l=n;return c}function L9(e,r,a){a==null&&(a=Nt(18));var n=lm(e,r);a.write_shift(-4,e),a.write_shift(-4,e),a.write_shift(4,(n.width||10)*256),a.write_shift(4,0);var i=0;return r.hidden&&(i|=1),typeof n.width=="number"&&(i|=2),r.level&&(i|=r.level<<8),a.write_shift(2,i),a}var s3=["left","right","top","bottom","header","footer"];function I9(e){var r={};return s3.forEach(function(a){r[a]=t0(e)}),r}function P9(e,r){return r==null&&(r=Nt(48)),a3(e),s3.forEach(function(a){Ac(e[a],r)}),r}function F9(e){var r=e.read_shift(2);return e.l+=28,{RTL:r&32}}function B9(e,r,a){a==null&&(a=Nt(30));var n=924;return(((r||{}).Views||[])[0]||{}).RTL&&(n|=32),a.write_shift(2,n),a.write_shift(4,0),a.write_shift(4,0),a.write_shift(4,0),a.write_shift(1,0),a.write_shift(1,0),a.write_shift(2,0),a.write_shift(2,100),a.write_shift(2,0),a.write_shift(2,0),a.write_shift(2,0),a.write_shift(4,0),a}function U9(e){var r=Nt(24);return r.write_shift(4,4),r.write_shift(4,1),e0(e,r),r}function z9(e,r){return r==null&&(r=Nt(66)),r.write_shift(2,e.password?U4(e.password):0),r.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(a){a[1]?r.write_shift(4,e[a[0]]!=null&&!e[a[0]]?1:0):r.write_shift(4,e[a[0]]!=null&&e[a[0]]?0:1)}),r}function H9(){}function V9(){}function W9(e,r,a,n,i,c,u){if(r.v===void 0)return!1;var g="";switch(r.t){case"b":g=r.v?"1":"0";break;case"d":r=Js(r),r.z=r.z||mn[14],r.v=Ks(Os(r.v)),r.t="n";break;case"n":case"e":g=""+r.v;break;default:g=r.v;break}var y={r:a,c:n};switch(y.s=ql(i.cellXfs,r,i),r.l&&c["!links"].push([Ma(y),r.l]),r.c&&c["!comments"].push([Ma(y),r.c]),r.t){case"s":case"str":return i.bookSST?(g=Xp(i.Strings,r.v,i.revStrings),y.t="s",y.v=g,u?Bt(e,18,c9(r,y)):Bt(e,7,o9(r,y))):(y.t="str",u?Bt(e,17,w9(r,y)):Bt(e,6,v9(r,y))),!0;case"n":return r.v==(r.v|0)&&r.v>-1e3&&r.v<1e3?u?Bt(e,13,p9(r,y)):Bt(e,2,g9(r,y)):u?Bt(e,16,f9(r,y)):Bt(e,5,u9(r,y)),!0;case"b":return y.t="b",u?Bt(e,15,t9(r,y)):Bt(e,4,Q7(r,y)),!0;case"e":return y.t="e",u?Bt(e,14,s9(r,y)):Bt(e,3,a9(r,y)),!0}return u?Bt(e,12,K7(r,y)):Bt(e,1,Z7(r,y)),!0}function G9(e,r,a,n){var i=Ya(r["!ref"]||"A1"),c,u="",g=[];Bt(e,145);var y=Array.isArray(r),x=i.e.r;r["!rows"]&&(x=Math.max(i.e.r,r["!rows"].length-1));for(var k=i.s.r;k<=x;++k){u=ls(k),H7(e,r,i,k);var N=!1;if(k<=i.e.r)for(var C=i.s.c;C<=i.e.c;++C){k===i.s.r&&(g[C]=bs(C)),c=g[C]+u;var O=y?(r[k]||[])[C]:r[c];if(!O){N=!1;continue}N=W9(e,O,k,C,n,r,N)}}Bt(e,146)}function $9(e,r){!r||!r["!merges"]||(Bt(e,177,T9(r["!merges"].length)),r["!merges"].forEach(function(a){Bt(e,176,j9(a))}),Bt(e,178))}function X9(e,r){!r||!r["!cols"]||(Bt(e,390),r["!cols"].forEach(function(a,n){a&&Bt(e,60,L9(n,a))}),Bt(e,391))}function Y9(e,r){!r||!r["!ref"]||(Bt(e,648),Bt(e,649,U9(Ya(r["!ref"]))),Bt(e,650))}function Z9(e,r,a){r["!links"].forEach(function(n){if(n[1].Target){var i=Oa(a,-1,n[1].Target.replace(/#.*$/,""),va.HLINK);Bt(e,494,O9(n,i))}}),delete r["!links"]}function q9(e,r,a,n){if(r["!comments"].length>0){var i=Oa(n,-1,"../drawings/vmlDrawing"+(a+1)+".vml",va.VML);Bt(e,551,zp("rId"+i)),r["!legacy"]=i}}function K9(e,r,a,n){if(r["!autofilter"]){var i=r["!autofilter"],c=typeof i.ref=="string"?i.ref:Tn(i.ref);a.Workbook||(a.Workbook={Sheets:[]}),a.Workbook.Names||(a.Workbook.Names=[]);var u=a.Workbook.Names,g=pi(c);g.s.r==g.e.r&&(g.e.r=pi(r["!ref"]).e.r,c=Tn(g));for(var y=0;y<u.length;++y){var x=u[y];if(x.Name=="_xlnm._FilterDatabase"&&x.Sheet==n){x.Ref="'"+a.SheetNames[n]+"'!"+c;break}}y==u.length&&u.push({Name:"_xlnm._FilterDatabase",Sheet:n,Ref:"'"+a.SheetNames[n]+"'!"+c}),Bt(e,161,e0(Ya(c))),Bt(e,162)}}function J9(e,r,a){Bt(e,133),Bt(e,137,B9(r,a)),Bt(e,138),Bt(e,134)}function Q9(e,r){r["!protect"]&&Bt(e,535,z9(r["!protect"]))}function eO(e,r,a,n){var i=Xs(),c=a.SheetNames[e],u=a.Sheets[c]||{},g=c;try{a&&a.Workbook&&(g=a.Workbook.Sheets[e].CodeName||g)}catch(x){}var y=Ya(u["!ref"]||"A1");if(y.e.c>16383||y.e.r>1048575){if(r.WTF)throw new Error("Range "+(u["!ref"]||"A1")+" exceeds format limit A1:XFD1048576");y.e.c=Math.min(y.e.c,16383),y.e.r=Math.min(y.e.c,1048575)}return u["!links"]=[],u["!comments"]=[],Bt(i,129),(a.vbaraw||u["!outline"])&&Bt(i,147,X7(g,u["!outline"])),Bt(i,148,W7(y)),J9(i,u,a.Workbook),X9(i,u),G9(i,u,e,r),Q9(i,u),K9(i,u,a,e),$9(i,u),Z9(i,u,n),u["!margins"]&&Bt(i,476,P9(u["!margins"])),(!r||r.ignoreEC||r.ignoreEC==null)&&Y9(i,u),q9(i,u,e,n),Bt(i,130),i.end()}function tO(e,r){e.l+=10;var a=vs(e);return{name:a}}var rO=[["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 aO(e){return!e.Workbook||!e.Workbook.WBProps?"false":DE(e.Workbook.WBProps.date1904)?"true":"false"}var nO="][*?/\\".split("");function i3(e,r){if(e.length>31)throw new Error("Sheet names cannot exceed 31 chars");var a=!0;return nO.forEach(function(n){if(e.indexOf(n)!=-1)throw new Error("Sheet name cannot contain : \\ / ? * [ ]")}),a}function sO(e,r,a){e.forEach(function(n,i){i3(n);for(var c=0;c<i;++c)if(n==e[c])throw new Error("Duplicate Sheet Name: "+n);if(a){var u=r&&r[i]&&r[i].CodeName||n;if(u.charCodeAt(0)==95&&u.length>22)throw new Error("Bad Code Name: Worksheet"+u)}})}function iO(e){if(!e||!e.SheetNames||!e.Sheets)throw new Error("Invalid Workbook");if(!e.SheetNames.length)throw new Error("Workbook is empty");var r=e.Workbook&&e.Workbook.Sheets||[];sO(e.SheetNames,r,!!e.vbaraw);for(var a=0;a<e.SheetNames.length;++a)j7(e.Sheets[e.SheetNames[a]],e.SheetNames[a],a)}function o3(e){var r=[An];r[r.length]=rr("workbook",null,{xmlns:Jd[0],"xmlns:r":Wn.r});var a=e.Workbook&&(e.Workbook.Names||[]).length>0,n={codeName:"ThisWorkbook"};e.Workbook&&e.Workbook.WBProps&&(rO.forEach(function(g){e.Workbook.WBProps[g[0]]!=null&&e.Workbook.WBProps[g[0]]!=g[1]&&(n[g[0]]=e.Workbook.WBProps[g[0]])}),e.Workbook.WBProps.CodeName&&(n.codeName=e.Workbook.WBProps.CodeName,delete n.CodeName)),r[r.length]=rr("workbookPr",null,n);var i=e.Workbook&&e.Workbook.Sheets||[],c=0;if(i&&i[0]&&i[0].Hidden){for(r[r.length]="<bookViews>",c=0;c!=e.SheetNames.length&&!(!i[c]||!i[c].Hidden);++c);c==e.SheetNames.length&&(c=0),r[r.length]='<workbookView firstSheet="'+c+'" activeTab="'+c+'"/>',r[r.length]="</bookViews>"}for(r[r.length]="<sheets>",c=0;c!=e.SheetNames.length;++c){var u={name:Ra(e.SheetNames[c].slice(0,31))};if(u.sheetId=""+(c+1),u["r:id"]="rId"+(c+1),i[c])switch(i[c].Hidden){case 1:u.state="hidden";break;case 2:u.state="veryHidden";break}r[r.length]=rr("sheet",null,u)}return r[r.length]="</sheets>",a&&(r[r.length]="<definedNames>",e.Workbook&&e.Workbook.Names&&e.Workbook.Names.forEach(function(g){var y={name:g.Name};g.Comment&&(y.comment=g.Comment),g.Sheet!=null&&(y.localSheetId=""+g.Sheet),g.Hidden&&(y.hidden="1"),g.Ref&&(r[r.length]=rr("definedName",Ra(g.Ref),y))}),r[r.length]="</definedNames>"),r.length>2&&(r[r.length]="</workbook>",r[1]=r[1].replace("/>",">")),r.join("")}function oO(e,r){var a={};return a.Hidden=e.read_shift(4),a.iTabID=e.read_shift(4),a.strRelID=tp(e),a.name=vs(e),a}function lO(e,r){return r||(r=Nt(127)),r.write_shift(4,e.Hidden),r.write_shift(4,e.iTabID),zp(e.strRelID,r),$n(e.name.slice(0,31),r),r.length>r.l?r.slice(0,r.l):r}function cO(e,r){var a={},n=e.read_shift(4);a.defaultThemeVersion=e.read_shift(4);var i=r>8?vs(e):"";return i.length>0&&(a.CodeName=i),a.autoCompressPictures=!!(n&65536),a.backupFile=!!(n&64),a.checkCompatibility=!!(n&4096),a.date1904=!!(n&1),a.filterPrivacy=!!(n&8),a.hidePivotFieldList=!!(n&1024),a.promptedSolutions=!!(n&16),a.publishItems=!!(n&2048),a.refreshAllConnections=!!(n&262144),a.saveExternalLinkValues=!!(n&128),a.showBorderUnselectedTables=!!(n&4),a.showInkAnnotation=!!(n&32),a.showObjects=["all","placeholders","none"][n>>13&3],a.showPivotChartFilter=!!(n&32768),a.updateLinks=["userSet","never","always"][n>>8&3],a}function dO(e,r){r||(r=Nt(72));var a=0;return e&&e.filterPrivacy&&(a|=8),r.write_shift(4,a),r.write_shift(4,0),b4(e&&e.CodeName||"ThisWorkbook",r),r.slice(0,r.l)}function uO(e,r,a){var n=e.l+r;e.l+=4,e.l+=1;var i=e.read_shift(4),c=aj(e),u=w7(e,0,a),g=Up(e);e.l=n;var y={Name:c,Ptg:u};return i<268435455&&(y.Sheet=i),g&&(y.Comment=g),y}function hO(e,r){Bt(e,143);for(var a=0;a!=r.SheetNames.length;++a){var n=r.Workbook&&r.Workbook.Sheets&&r.Workbook.Sheets[a]&&r.Workbook.Sheets[a].Hidden||0,i={Hidden:n,iTabID:a+1,strRelID:"rId"+(a+1),name:r.SheetNames[a]};Bt(e,156,lO(i))}Bt(e,144)}function fO(e,r){r||(r=Nt(127));for(var a=0;a!=4;++a)r.write_shift(4,0);return $n("SheetJS",r),$n(Cf.version,r),$n(Cf.version,r),$n("7262",r),r.length>r.l?r.slice(0,r.l):r}function mO(e,r){r||(r=Nt(29)),r.write_shift(-4,0),r.write_shift(-4,460),r.write_shift(4,28800),r.write_shift(4,17600),r.write_shift(4,500),r.write_shift(4,e),r.write_shift(4,e);var a=120;return r.write_shift(1,a),r.length>r.l?r.slice(0,r.l):r}function gO(e,r){if(!(!r.Workbook||!r.Workbook.Sheets)){for(var a=r.Workbook.Sheets,n=0,i=-1,c=-1;n<a.length;++n)!a[n]||!a[n].Hidden&&i==-1?i=n:a[n].Hidden==1&&c==-1&&(c=n);c>i||(Bt(e,135),Bt(e,158,mO(i)),Bt(e,136))}}function xO(e,r){var a=Xs();return Bt(a,131),Bt(a,128,fO()),Bt(a,153,dO(e.Workbook&&e.Workbook.WBProps||null)),gO(a,e),hO(a,e),Bt(a,132),a.end()}function pO(e,r,a){return(r.slice(-4)===".bin"?xO:o3)(e)}function yO(e,r,a,n,i){return(r.slice(-4)===".bin"?eO:n3)(e,a,n,i)}function bO(e,r,a){return(r.slice(-4)===".bin"?PT:V4)(e,a)}function vO(e,r,a){return(r.slice(-4)===".bin"?dT:B4)(e,a)}function _O(e,r,a){return(r.slice(-4)===".bin"?QT:Y4)(e)}function wO(e){return(e.slice(-4)===".bin"?GT:$4)()}function kO(e,r){var a=[];return e.Props&&a.push(bj(e.Props,r)),e.Custprops&&a.push(vj(e.Props,e.Custprops)),a.join("")}function NO(){return""}function SO(e,r){var a=['<Style ss:ID="Default" ss:Name="Normal"><NumberFormat/></Style>'];return r.cellXfs.forEach(function(n,i){var c=[];c.push(rr("NumberFormat",null,{"ss:Format":Ra(mn[n.numFmtId])}));var u={"ss:ID":"s"+(21+i)};a.push(rr("Style",c.join(""),u))}),rr("Styles",a.join(""))}function l3(e){return rr("NamedRange",null,{"ss:Name":e.Name,"ss:RefersTo":"="+Gp(e.Ref,{r:0,c:0})})}function CO(e){if(!((e||{}).Workbook||{}).Names)return"";for(var r=e.Workbook.Names,a=[],n=0;n<r.length;++n){var i=r[n];i.Sheet==null&&(i.Name.match(/^_xlfn\./)||a.push(l3(i)))}return rr("Names",a.join(""))}function EO(e,r,a,n){if(!e||!((n||{}).Workbook||{}).Names)return"";for(var i=n.Workbook.Names,c=[],u=0;u<i.length;++u){var g=i[u];g.Sheet==a&&(g.Name.match(/^_xlfn\./)||c.push(l3(g)))}return c.join("")}function jO(e,r,a,n){if(!e)return"";var i=[];if(e["!margins"]&&(i.push("<PageSetup>"),e["!margins"].header&&i.push(rr("Header",null,{"x:Margin":e["!margins"].header})),e["!margins"].footer&&i.push(rr("Footer",null,{"x:Margin":e["!margins"].footer})),i.push(rr("PageMargins",null,{"x:Bottom":e["!margins"].bottom||"0.75","x:Left":e["!margins"].left||"0.7","x:Right":e["!margins"].right||"0.7","x:Top":e["!margins"].top||"0.75"})),i.push("</PageSetup>")),n&&n.Workbook&&n.Workbook.Sheets&&n.Workbook.Sheets[a])if(n.Workbook.Sheets[a].Hidden)i.push(rr("Visible",n.Workbook.Sheets[a].Hidden==1?"SheetHidden":"SheetVeryHidden",{}));else{for(var c=0;c<a&&!(n.Workbook.Sheets[c]&&!n.Workbook.Sheets[c].Hidden);++c);c==a&&i.push("<Selected/>")}return((((n||{}).Workbook||{}).Views||[])[0]||{}).RTL&&i.push("<DisplayRightToLeft/>"),e["!protect"]&&(i.push(os("ProtectContents","True")),e["!protect"].objects&&i.push(os("ProtectObjects","True")),e["!protect"].scenarios&&i.push(os("ProtectScenarios","True")),e["!protect"].selectLockedCells!=null&&!e["!protect"].selectLockedCells?i.push(os("EnableSelection","NoSelection")):e["!protect"].selectUnlockedCells!=null&&!e["!protect"].selectUnlockedCells&&i.push(os("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(u){e["!protect"][u[0]]&&i.push("<"+u[1]+"/>")})),i.length==0?"":rr("WorksheetOptions",i.join(""),{xmlns:mi.x})}function TO(e){return e.map(function(r){var a=ME(r.t||""),n=rr("ss:Data",a,{xmlns:"http://www.w3.org/TR/REC-html40"});return rr("Comment",n,{"ss:Author":r.a})}).join("")}function AO(e,r,a,n,i,c,u){if(!e||e.v==null&&e.f==null)return"";var g={};if(e.f&&(g["ss:Formula"]="="+Ra(Gp(e.f,u))),e.F&&e.F.slice(0,r.length)==r){var y=Gn(e.F.slice(r.length+1));g["ss:ArrayRange"]="RC:R"+(y.r==u.r?"":"["+(y.r-u.r)+"]")+"C"+(y.c==u.c?"":"["+(y.c-u.c)+"]")}if(e.l&&e.l.Target&&(g["ss:HRef"]=Ra(e.l.Target),e.l.Tooltip&&(g["x:HRefScreenTip"]=Ra(e.l.Tooltip))),a["!merges"])for(var x=a["!merges"],k=0;k!=x.length;++k)x[k].s.c!=u.c||x[k].s.r!=u.r||(x[k].e.c>x[k].s.c&&(g["ss:MergeAcross"]=x[k].e.c-x[k].s.c),x[k].e.r>x[k].s.r&&(g["ss:MergeDown"]=x[k].e.r-x[k].s.r));var N="",C="";switch(e.t){case"z":if(!n.sheetStubs)return"";break;case"n":N="Number",C=String(e.v);break;case"b":N="Boolean",C=e.v?"1":"0";break;case"e":N="Error",C=Ou[e.v];break;case"d":N="DateTime",C=new Date(e.v).toISOString(),e.z==null&&(e.z=e.z||mn[14]);break;case"s":N="String",C=RE(e.v||"");break}var O=ql(n.cellXfs,e,n);g["ss:StyleID"]="s"+(21+O),g["ss:Index"]=u.c+1;var D=e.v!=null?C:"",A=e.t=="z"?"":'<Data ss:Type="'+N+'">'+D+"</Data>";return(e.c||[]).length>0&&(A+=TO(e.c)),rr("Cell",A,g)}function OO(e,r){var a='<Row ss:Index="'+(e+1)+'"';return r&&(r.hpt&&!r.hpx&&(r.hpx=H4(r.hpt)),r.hpx&&(a+=' ss:AutoFitHeight="0" ss:Height="'+r.hpx+'"'),r.hidden&&(a+=' ss:Hidden="1"')),a+">"}function RO(e,r,a,n){if(!e["!ref"])return"";var i=Ya(e["!ref"]),c=e["!merges"]||[],u=0,g=[];e["!cols"]&&e["!cols"].forEach(function(I,z){Vp(I);var U=!!I.width,B=lm(z,I),V={"ss:Index":z+1};U&&(V["ss:Width"]=If(B.width)),I.hidden&&(V["ss:Hidden"]="1"),g.push(rr("Column",null,V))});for(var y=Array.isArray(e),x=i.s.r;x<=i.e.r;++x){for(var k=[OO(x,(e["!rows"]||[])[x])],N=i.s.c;N<=i.e.c;++N){var C=!1;for(u=0;u!=c.length;++u)if(!(c[u].s.c>N)&&!(c[u].s.r>x)&&!(c[u].e.c<N)&&!(c[u].e.r<x)){(c[u].s.c!=N||c[u].s.r!=x)&&(C=!0);break}if(!C){var O={r:x,c:N},D=Ma(O),A=y?(e[x]||[])[N]:e[D];k.push(AO(A,D,e,r,a,n,O))}}k.push("</Row>"),k.length>2&&g.push(k.join(""))}return g.join("")}function MO(e,r,a){var n=[],i=a.SheetNames[e],c=a.Sheets[i],u=c?EO(c,r,e,a):"";return u.length>0&&n.push("<Names>"+u+"</Names>"),u=c?RO(c,r,e,a):"",u.length>0&&n.push("<Table>"+u+"</Table>"),n.push(jO(c,r,e,a)),n.join("")}function DO(e,r){r||(r={}),e.SSF||(e.SSF=Js(mn)),e.SSF&&(am(),rm(e.SSF),r.revssf=nm(e.SSF),r.revssf[e.SSF[65535]]=0,r.ssf=e.SSF,r.cellXfs=[],ql(r.cellXfs,{},{revssf:{General:0}}));var a=[];a.push(kO(e,r)),a.push(NO()),a.push(""),a.push("");for(var n=0;n<e.SheetNames.length;++n)a.push(rr("Worksheet",MO(n,r,e),{"ss:Name":Ra(e.SheetNames[n])}));return a[2]=SO(e,r),a[3]=CO(e),An+rr("Workbook",a.join(""),{xmlns:mi.ss,"xmlns:o":mi.o,"xmlns:x":mi.x,"xmlns:ss":mi.ss,"xmlns:dt":mi.dt,"xmlns:html":mi.html})}var Ax={SI:"e0859ff2f94f6810ab9108002b27b3d9",DSI:"02d5cdd59c2e1b10939708002b2cf9ae",UDI:"05d5cdd59c2e1b10939708002b2cf9ae"};function LO(e,r){var a=[],n=[],i=[],c=0,u,g=xv(Tv,"n"),y=xv(Av,"n");if(e.Props)for(u=ds(e.Props),c=0;c<u.length;++c)(Object.prototype.hasOwnProperty.call(g,u[c])?a:Object.prototype.hasOwnProperty.call(y,u[c])?n:i).push([u[c],e.Props[u[c]]]);if(e.Custprops)for(u=ds(e.Custprops),c=0;c<u.length;++c)Object.prototype.hasOwnProperty.call(e.Props||{},u[c])||(Object.prototype.hasOwnProperty.call(g,u[c])?a:Object.prototype.hasOwnProperty.call(y,u[c])?n:i).push([u[c],e.Custprops[u[c]]]);var x=[];for(c=0;c<i.length;++c)R4.indexOf(i[c][0])>-1||T4.indexOf(i[c][0])>-1||i[c][1]!=null&&x.push(i[c]);n.length&&Ua.utils.cfb_add(r,"/SummaryInformation",Lv(n,Ax.SI,y,Av)),(a.length||x.length)&&Ua.utils.cfb_add(r,"/DocumentSummaryInformation",Lv(a,Ax.DSI,g,Tv,x.length?x:null,Ax.UDI))}function IO(e,r){var a=r||{},n=Ua.utils.cfb_new({root:"R"}),i="/Workbook";switch(a.bookType||"xls"){case"xls":a.bookType="biff8";case"xla":a.bookType||(a.bookType="xla");case"biff8":i="/Workbook",a.biff=8;break;case"biff5":i="/Book",a.biff=5;break;default:throw new Error("invalid type "+a.bookType+" for XLS CFB")}return Ua.utils.cfb_add(n,i,c3(e,a)),a.biff==8&&(e.Props||e.Custprops)&&LO(e,n),a.biff==8&&e.vbaraw&&eA(n,Ua.read(e.vbaraw,{type:typeof e.vbaraw=="string"?"binary":"buffer"})),n}var PO={0:{f:U7},1:{f:Y7},2:{f:m9},3:{f:r9},4:{f:J7},5:{f:d9},6:{f:b9},7:{f:i9},8:{f:C9},9:{f:S9},10:{f:k9},11:{f:N9},12:{f:q7},13:{f:x9},14:{f:n9},15:{f:e9},16:{f:h9},17:{f:_9},18:{f:l9},19:{f:Bp},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:uO},40:{},42:{},43:{f:bT},44:{f:pT},45:{f:wT},46:{f:NT},47:{f:kT},48:{},49:{f:qE},50:{},51:{f:UT},52:{T:1},53:{T:-1},54:{T:1},55:{T:-1},56:{T:1},57:{T:-1},58:{},59:{},60:{f:Kj},62:{f:y9},63:{f:$T},64:{f:H9},65:{},66:{},67:{},68:{},69:{},70:{},128:{},129:{T:1},130:{T:-1},131:{T:1,f:So,p:0},132:{T:-1},133:{T:1},134:{T:-1},135:{T:1},136:{T:-1},137:{T:1,f:F9},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:$7},148:{f:V7,p:16},151:{f:R9},152:{},153:{f:cO},154:{},155:{},156:{f:oO},157:{},158:{},159:{T:1,f:oT},160:{T:-1},161:{T:1,f:Fc},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:E9},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:FT},336:{T:-1},337:{f:VT,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:tp},357:{},358:{},359:{},360:{T:1},361:{},362:{f:Gj},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:M9},427:{f:D9},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:I9},477:{},478:{},479:{T:1},480:{T:-1},481:{T:1},482:{T:-1},483:{T:1},484:{T:-1},485:{f:G7},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:A9},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:tp},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:KT},633:{T:1},634:{T:-1},635:{T:1,f:ZT},636:{T:-1},637:{f:ej},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:tO},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:V9},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 ir(e,r,a,n){var i=r;if(!isNaN(i)){var c=n||(a||[]).length||0,u=e.next(4);u.write_shift(2,i),u.write_shift(2,c),c>0&&Ip(a)&&e.push(a)}}function FO(e,r,a,n){var i=(a||[]).length||0;if(i<=8224)return ir(e,r,a,i);var c=r;if(!isNaN(c)){for(var u=a.parts||[],g=0,y=0,x=0;x+(u[g]||8224)<=8224;)x+=u[g]||8224,g++;var k=e.next(4);for(k.write_shift(2,c),k.write_shift(2,x),e.push(a.slice(y,y+x)),y+=x;y<i;){for(k=e.next(4),k.write_shift(2,60),x=0;x+(u[g]||8224)<=8224;)x+=u[g]||8224,g++;k.write_shift(2,x),e.push(a.slice(y,y+x)),y+=x}}}function Mu(e,r,a){return e||(e=Nt(7)),e.write_shift(2,r),e.write_shift(2,a),e.write_shift(2,0),e.write_shift(1,0),e}function BO(e,r,a,n){var i=Nt(9);return Mu(i,e,r),D4(a,n||"b",i),i}function UO(e,r,a){var n=Nt(8+2*a.length);return Mu(n,e,r),n.write_shift(1,a.length),n.write_shift(a.length,a,"sbcs"),n.l<n.length?n.slice(0,n.l):n}function zO(e,r,a,n){if(r.v!=null)switch(r.t){case"d":case"n":var i=r.t=="d"?Ks(Os(r.v)):r.v;i==(i|0)&&i>=0&&i<65536?ir(e,2,tT(a,n,i)):ir(e,3,eT(a,n,i));return;case"b":case"e":ir(e,5,BO(a,n,r.v,r.t));return;case"s":case"str":ir(e,4,UO(a,n,(r.v||"").slice(0,255)));return}ir(e,1,Mu(null,a,n))}function HO(e,r,a,n){var i=Array.isArray(r),c=Ya(r["!ref"]||"A1"),u,g="",y=[];if(c.e.c>255||c.e.r>16383){if(n.WTF)throw new Error("Range "+(r["!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),u=Tn(c)}for(var x=c.s.r;x<=c.e.r;++x){g=ls(x);for(var k=c.s.c;k<=c.e.c;++k){x===c.s.r&&(y[k]=bs(k)),u=y[k]+g;var N=i?(r[x]||[])[k]:r[u];N&&zO(e,N,x,k)}}}function VO(e,r){for(var a=r||{},n=Xs(),i=0,c=0;c<e.SheetNames.length;++c)e.SheetNames[c]==a.sheet&&(i=c);if(i==0&&a.sheet&&e.SheetNames[0]!=a.sheet)throw new Error("Sheet not found: "+a.sheet);return ir(n,a.biff==4?1033:a.biff==3?521:9,Hp(e,16,a)),HO(n,e.Sheets[e.SheetNames[i]],i,a),ir(n,10),n.end()}function WO(e,r,a){ir(e,49,Pj({sz:12,name:"Arial"},a))}function GO(e,r,a){r&&[[5,8],[23,26],[41,44],[50,392]].forEach(function(n){for(var i=n[0];i<=n[1];++i)r[i]!=null&&ir(e,1054,Uj(i,r[i],a))})}function $O(e,r){var a=Nt(19);a.write_shift(4,2151),a.write_shift(4,0),a.write_shift(4,0),a.write_shift(2,3),a.write_shift(1,1),a.write_shift(4,0),ir(e,2151,a),a=Nt(39),a.write_shift(4,2152),a.write_shift(4,0),a.write_shift(4,0),a.write_shift(2,3),a.write_shift(1,0),a.write_shift(4,0),a.write_shift(2,1),a.write_shift(4,4),a.write_shift(2,0),P4(Ya(r["!ref"]||"A1"),a),a.write_shift(4,4),ir(e,2152,a)}function XO(e,r){for(var a=0;a<16;++a)ir(e,224,Pv({numFmtId:0,style:!0},0,r));r.cellXfs.forEach(function(n){ir(e,224,Pv(n,0,r))})}function YO(e,r){for(var a=0;a<r["!links"].length;++a){var n=r["!links"][a];ir(e,440,Yj(n)),n[1].Tooltip&&ir(e,2048,Zj(n))}delete r["!links"]}function ZO(e,r){if(r){var a=0;r.forEach(function(n,i){++a<=256&&n&&ir(e,125,Jj(lm(i,n),i))})}}function qO(e,r,a,n,i){var c=16+ql(i.cellXfs,r,i);if(r.v==null&&!r.bf){ir(e,513,Oc(a,n,c));return}if(r.bf)ir(e,6,v7(r,a,n,i,c));else switch(r.t){case"d":case"n":var u=r.t=="d"?Ks(Os(r.v)):r.v;ir(e,515,Wj(a,n,u,c));break;case"b":case"e":ir(e,517,Vj(a,n,r.v,c,i,r.t));break;case"s":case"str":if(i.bookSST){var g=Xp(i.Strings,r.v,i.revStrings);ir(e,253,Fj(a,n,g,c))}else ir(e,516,Bj(a,n,(r.v||"").slice(0,255),c,i));break;default:ir(e,513,Oc(a,n,c))}}function KO(e,r,a){var n=Xs(),i=a.SheetNames[e],c=a.Sheets[i]||{},u=(a||{}).Workbook||{},g=(u.Sheets||[])[e]||{},y=Array.isArray(c),x=r.biff==8,k,N="",C=[],O=Ya(c["!ref"]||"A1"),D=x?65536:16384;if(O.e.c>255||O.e.r>=D){if(r.WTF)throw new Error("Range "+(c["!ref"]||"A1")+" exceeds format limit A1:IV16384");O.e.c=Math.min(O.e.c,255),O.e.r=Math.min(O.e.c,D-1)}ir(n,2057,Hp(a,16,r)),ir(n,13,Oi(1)),ir(n,12,Oi(100)),ir(n,15,Ts(!0)),ir(n,17,Ts(!1)),ir(n,16,Ac(.001)),ir(n,95,Ts(!0)),ir(n,42,Ts(!1)),ir(n,43,Ts(!1)),ir(n,130,Oi(1)),ir(n,128,Hj()),ir(n,131,Ts(!1)),ir(n,132,Ts(!1)),x&&ZO(n,c["!cols"]),ir(n,512,zj(O,r)),x&&(c["!links"]=[]);for(var A=O.s.r;A<=O.e.r;++A){N=ls(A);for(var I=O.s.c;I<=O.e.c;++I){A===O.s.r&&(C[I]=bs(I)),k=C[I]+N;var z=y?(c[A]||[])[I]:c[k];z&&(qO(n,z,A,I,r),x&&z.l&&c["!links"].push([k,z.l]))}}var U=g.CodeName||g.name||i;return x&&ir(n,574,Ij((u.Views||[])[0])),x&&(c["!merges"]||[]).length&&ir(n,229,Xj(c["!merges"])),x&&YO(n,c),ir(n,442,I4(U)),x&&$O(n,c),ir(n,10),n.end()}function JO(e,r,a){var n=Xs(),i=(e||{}).Workbook||{},c=i.Sheets||[],u=i.WBProps||{},g=a.biff==8,y=a.biff==5;if(ir(n,2057,Hp(e,5,a)),a.bookType=="xla"&&ir(n,135),ir(n,225,g?Oi(1200):null),ir(n,193,kj(2)),y&&ir(n,191),y&&ir(n,192),ir(n,226),ir(n,92,Rj("SheetJS",a)),ir(n,66,Oi(g?1200:1252)),g&&ir(n,353,Oi(0)),g&&ir(n,448),ir(n,317,Qj(e.SheetNames.length)),g&&e.vbaraw&&ir(n,211),g&&e.vbaraw){var x=u.CodeName||"ThisWorkbook";ir(n,442,I4(x))}ir(n,156,Oi(17)),ir(n,25,Ts(!1)),ir(n,18,Ts(!1)),ir(n,19,Oi(0)),g&&ir(n,431,Ts(!1)),g&&ir(n,444,Oi(0)),ir(n,61,Lj()),ir(n,64,Ts(!1)),ir(n,141,Oi(0)),ir(n,34,Ts(aO(e)=="true")),ir(n,14,Ts(!0)),g&&ir(n,439,Ts(!1)),ir(n,218,Oi(0)),WO(n,e,a),GO(n,e.SSF,a),XO(n,a),g&&ir(n,352,Ts(!1));var k=n.end(),N=Xs();g&&ir(N,140,qj()),g&&a.Strings&&FO(N,252,Dj(a.Strings)),ir(N,10);var C=N.end(),O=Xs(),D=0,A=0;for(A=0;A<e.SheetNames.length;++A)D+=(g?12:11)+(g?2:1)*e.SheetNames[A].length;var I=k.length+D+C.length;for(A=0;A<e.SheetNames.length;++A){var z=c[A]||{};ir(O,133,Mj({pos:I,hs:z.Hidden||0,dt:0,name:e.SheetNames[A]},a)),I+=r[A].length}var U=O.end();if(D!=U.length)throw new Error("BS8 "+D+" != "+U.length);var B=[];return k.length&&B.push(k),U.length&&B.push(U),C.length&&B.push(C),is(B)}function QO(e,r){var a=r||{},n=[];e&&!e.SSF&&(e.SSF=Js(mn)),e&&e.SSF&&(am(),rm(e.SSF),a.revssf=nm(e.SSF),a.revssf[e.SSF[65535]]=0,a.ssf=e.SSF),a.Strings=[],a.Strings.Count=0,a.Strings.Unique=0,Yp(a),a.cellXfs=[],ql(a.cellXfs,{},{revssf:{General:0}}),e.Props||(e.Props={});for(var i=0;i<e.SheetNames.length;++i)n[n.length]=KO(i,a,e);return n.unshift(JO(e,n,a)),is(n)}function c3(e,r){for(var a=0;a<=e.SheetNames.length;++a){var n=e.Sheets[e.SheetNames[a]];if(!(!n||!n["!ref"])){var i=pi(n["!ref"]);i.e.c>255&&typeof console!="undefined"&&console.error&&console.error("Worksheet '"+e.SheetNames[a]+"' extends beyond column IV (255). Data may be lost.")}}var c=r||{};switch(c.biff||2){case 8:case 5:return QO(e,r);case 4:case 3:case 2:return VO(e,r)}throw new Error("invalid type "+c.bookType+" for BIFF")}function eR(e,r,a,n){for(var i=e["!merges"]||[],c=[],u=r.s.c;u<=r.e.c;++u){for(var g=0,y=0,x=0;x<i.length;++x)if(!(i[x].s.r>a||i[x].s.c>u)&&!(i[x].e.r<a||i[x].e.c<u)){if(i[x].s.r<a||i[x].s.c<u){g=-1;break}g=i[x].e.r-i[x].s.r+1,y=i[x].e.c-i[x].s.c+1;break}if(!(g<0)){var k=Ma({r:a,c:u}),N=n.dense?(e[a]||[])[u]:e[k],C=N&&N.v!=null&&(N.h||OE(N.w||(ol(N),N.w)||""))||"",O={};g>1&&(O.rowspan=g),y>1&&(O.colspan=y),n.editable?C='<span contenteditable="true">'+C+"</span>":N&&(O["data-t"]=N&&N.t||"z",N.v!=null&&(O["data-v"]=N.v),N.z!=null&&(O["data-z"]=N.z),N.l&&(N.l.Target||"#").charAt(0)!="#"&&(C='<a href="'+N.l.Target+'">'+C+"</a>")),O.id=(n.id||"sjs")+"-"+k,c.push(rr("td",C,O))}}var D="<tr>";return D+c.join("")+"</tr>"}var tR='<html><head><meta charset="utf-8"/><title>SheetJS Table Export</title></head><body>',rR="</body></html>";function aR(e,r,a){var n=[];return n.join("")+"<table"+(a&&a.id?' id="'+a.id+'"':"")+">"}function d3(e,r){var a=r||{},n=a.header!=null?a.header:tR,i=a.footer!=null?a.footer:rR,c=[n],u=pi(e["!ref"]);a.dense=Array.isArray(e),c.push(aR(e,u,a));for(var g=u.s.r;g<=u.e.r;++g)c.push(eR(e,u,g,a));return c.push("</table>"+i),c.join("")}function u3(e,r,a){var n=a||{},i=0,c=0;if(n.origin!=null)if(typeof n.origin=="number")i=n.origin;else{var u=typeof n.origin=="string"?Gn(n.origin):n.origin;i=u.r,c=u.c}var g=r.getElementsByTagName("tr"),y=Math.min(n.sheetRows||1e7,g.length),x={s:{r:0,c:0},e:{r:i,c}};if(e["!ref"]){var k=pi(e["!ref"]);x.s.r=Math.min(x.s.r,k.s.r),x.s.c=Math.min(x.s.c,k.s.c),x.e.r=Math.max(x.e.r,k.e.r),x.e.c=Math.max(x.e.c,k.e.c),i==-1&&(x.e.r=i=k.e.r+1)}var N=[],C=0,O=e["!rows"]||(e["!rows"]=[]),D=0,A=0,I=0,z=0,U=0,B=0;for(e["!cols"]||(e["!cols"]=[]);D<g.length&&A<y;++D){var V=g[D];if(Wv(V)){if(n.display)continue;O[A]={hidden:!0}}var Z=V.children;for(I=z=0;I<Z.length;++I){var W=Z[I];if(!(n.display&&Wv(W))){var H=W.hasAttribute("data-v")?W.getAttribute("data-v"):W.hasAttribute("v")?W.getAttribute("v"):LE(W.innerHTML),le=W.getAttribute("data-z")||W.getAttribute("z");for(C=0;C<N.length;++C){var Q=N[C];Q.s.c==z+c&&Q.s.r<A+i&&A+i<=Q.e.r&&(z=Q.e.c+1-c,C=-1)}B=+W.getAttribute("colspan")||1,((U=+W.getAttribute("rowspan")||1)>1||B>1)&&N.push({s:{r:A+i,c:z+c},e:{r:A+i+(U||1)-1,c:z+c+(B||1)-1}});var Ne={t:"s",v:H},oe=W.getAttribute("data-t")||W.getAttribute("t")||"";H!=null&&(H.length==0?Ne.t=oe||"z":n.raw||H.trim().length==0||oe=="s"||(H==="TRUE"?Ne={t:"b",v:!0}:H==="FALSE"?Ne={t:"b",v:!1}:isNaN(el(H))?isNaN(xu(H).getDate())||(Ne={t:"d",v:Os(H)},n.cellDates||(Ne={t:"n",v:Ks(Ne.v)}),Ne.z=n.dateNF||mn[14]):Ne={t:"n",v:el(H)})),Ne.z===void 0&&le!=null&&(Ne.z=le);var se="",ce=W.getElementsByTagName("A");if(ce&&ce.length)for(var Ce=0;Ce<ce.length&&!(ce[Ce].hasAttribute("href")&&(se=ce[Ce].getAttribute("href"),se.charAt(0)!="#"));++Ce);se&&se.charAt(0)!="#"&&(Ne.l={Target:se}),n.dense?(e[A+i]||(e[A+i]=[]),e[A+i][z+c]=Ne):e[Ma({c:z+c,r:A+i})]=Ne,x.e.c<z+c&&(x.e.c=z+c),z+=B}}++A}return N.length&&(e["!merges"]=(e["!merges"]||[]).concat(N)),x.e.r=Math.max(x.e.r,A-1+i),e["!ref"]=Tn(x),A>=y&&(e["!fullref"]=Tn((x.e.r=g.length-D+A-1+i,x))),e}function h3(e,r){var a=r||{},n=a.dense?[]:{};return u3(n,e,r)}function nR(e,r){return Dc(h3(e,r),r)}function Wv(e){var r="",a=sR(e);return a&&(r=a(e).getPropertyValue("display")),r||(r=e.style&&e.style.display),r==="none"}function sR(e){return e.ownerDocument.defaultView&&typeof e.ownerDocument.defaultView.getComputedStyle=="function"?e.ownerDocument.defaultView.getComputedStyle:typeof getComputedStyle=="function"?getComputedStyle:null}var iR=(function(){var e=["<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(""),r="<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"})+">"+e+"</office:document-styles>";return function(){return An+r}})(),Gv=(function(){var e=function(c){return Ra(c).replace(/ +/g,function(u){return'<text:s text:c="'+u.length+'"/>'}).replace(/\t/g,"<text:tab/>").replace(/\n/g,"</text:p><text:p>").replace(/^ /,"<text:s/>").replace(/ $/,"<text:s/>")},r=` <table:table-cell />
|
||
`,a=` <table:covered-table-cell/>
|
||
`,n=function(c,u,g){var y=[];y.push(' <table:table table:name="'+Ra(u.SheetNames[g])+`" table:style-name="ta1">
|
||
`);var x=0,k=0,N=pi(c["!ref"]||"A1"),C=c["!merges"]||[],O=0,D=Array.isArray(c);if(c["!cols"])for(k=0;k<=N.e.c;++k)y.push(" <table:table-column"+(c["!cols"][k]?' table:style-name="co'+c["!cols"][k].ods+'"':"")+`></table:table-column>
|
||
`);var A="",I=c["!rows"]||[];for(x=0;x<N.s.r;++x)A=I[x]?' table:style-name="ro'+I[x].ods+'"':"",y.push(" <table:table-row"+A+`></table:table-row>
|
||
`);for(;x<=N.e.r;++x){for(A=I[x]?' table:style-name="ro'+I[x].ods+'"':"",y.push(" <table:table-row"+A+`>
|
||
`),k=0;k<N.s.c;++k)y.push(r);for(;k<=N.e.c;++k){var z=!1,U={},B="";for(O=0;O!=C.length;++O)if(!(C[O].s.c>k)&&!(C[O].s.r>x)&&!(C[O].e.c<k)&&!(C[O].e.r<x)){(C[O].s.c!=k||C[O].s.r!=x)&&(z=!0),U["table:number-columns-spanned"]=C[O].e.c-C[O].s.c+1,U["table:number-rows-spanned"]=C[O].e.r-C[O].s.r+1;break}if(z){y.push(a);continue}var V=Ma({r:x,c:k}),Z=D?(c[x]||[])[k]:c[V];if(Z&&Z.f&&(U["table:formula"]=Ra(C7(Z.f)),Z.F&&Z.F.slice(0,V.length)==V)){var W=pi(Z.F);U["table:number-matrix-columns-spanned"]=W.e.c-W.s.c+1,U["table:number-matrix-rows-spanned"]=W.e.r-W.s.r+1}if(!Z){y.push(r);continue}switch(Z.t){case"b":B=Z.v?"TRUE":"FALSE",U["office:value-type"]="boolean",U["office:boolean-value"]=Z.v?"true":"false";break;case"n":B=Z.w||String(Z.v||0),U["office:value-type"]="float",U["office:value"]=Z.v||0;break;case"s":case"str":B=Z.v==null?"":Z.v,U["office:value-type"]="string";break;case"d":B=Z.w||Os(Z.v).toISOString(),U["office:value-type"]="date",U["office:date-value"]=Os(Z.v).toISOString(),U["table:style-name"]="ce1";break;default:y.push(r);continue}var H=e(B);if(Z.l&&Z.l.Target){var le=Z.l.Target;le=le.charAt(0)=="#"?"#"+E7(le.slice(1)):le,le.charAt(0)!="#"&&!le.match(/^\w+:/)&&(le="../"+le),H=rr("text:a",H,{"xlink:href":le.replace(/&/g,"&")})}y.push(" "+rr("table:table-cell",rr("text:p",H,{}),U)+`
|
||
`)}y.push(` </table:table-row>
|
||
`)}return y.push(` </table:table>
|
||
`),y.join("")},i=function(c,u){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 g=0;u.SheetNames.map(function(x){return u.Sheets[x]}).forEach(function(x){if(x&&x["!cols"]){for(var k=0;k<x["!cols"].length;++k)if(x["!cols"][k]){var N=x["!cols"][k];if(N.width==null&&N.wpx==null&&N.wch==null)continue;Vp(N),N.ods=g;var C=x["!cols"][k].wpx+"px";c.push(' <style:style style:name="co'+g+`" style:family="table-column">
|
||
`),c.push(' <style:table-column-properties fo:break-before="auto" style:column-width="'+C+`"/>
|
||
`),c.push(` </style:style>
|
||
`),++g}}});var y=0;u.SheetNames.map(function(x){return u.Sheets[x]}).forEach(function(x){if(x&&x["!rows"]){for(var k=0;k<x["!rows"].length;++k)if(x["!rows"][k]){x["!rows"][k].ods=y;var N=x["!rows"][k].hpx+"px";c.push(' <style:style style:name="ro'+y+`" style:family="table-row">
|
||
`),c.push(' <style:table-row-properties fo:break-before="auto" style:row-height="'+N+`"/>
|
||
`),c.push(` </style:style>
|
||
`),++y}}}),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(u,g){var y=[An],x=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"}),k=yu({"xmlns:config":"urn:oasis:names:tc:opendocument:xmlns:config:1.0","office:mimetype":"application/vnd.oasis.opendocument.spreadsheet"});g.bookType=="fods"?(y.push("<office:document"+x+k+`>
|
||
`),y.push(E4().replace(/office:document-meta/g,"office:meta"))):y.push("<office:document-content"+x+`>
|
||
`),i(y,u),y.push(` <office:body>
|
||
`),y.push(` <office:spreadsheet>
|
||
`);for(var N=0;N!=u.SheetNames.length;++N)y.push(n(u.Sheets[u.SheetNames[N]],u,N));return y.push(` </office:spreadsheet>
|
||
`),y.push(` </office:body>
|
||
`),g.bookType=="fods"?y.push("</office:document>"):y.push("</office:document-content>"),y.join("")}})();function f3(e,r){if(r.bookType=="fods")return Gv(e,r);var a=Rp(),n="",i=[],c=[];return n="mimetype",Kr(a,n,"application/vnd.oasis.opendocument.spreadsheet"),n="content.xml",Kr(a,n,Gv(e,r)),i.push([n,"text/xml"]),c.push([n,"ContentFile"]),n="styles.xml",Kr(a,n,iR(e,r)),i.push([n,"text/xml"]),c.push([n,"StylesFile"]),n="meta.xml",Kr(a,n,An+E4()),i.push([n,"text/xml"]),c.push([n,"MetadataFile"]),n="manifest.rdf",Kr(a,n,yj(c)),i.push([n,"application/rdf+xml"]),n="META-INF/manifest.xml",Kr(a,n,xj(i)),a}function Bf(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function oR(e){return typeof TextEncoder!="undefined"?new TextEncoder().encode(e):Qi(pu(e))}function lR(e,r){e:for(var a=0;a<=e.length-r.length;++a){for(var n=0;n<r.length;++n)if(e[a+n]!=r[n])continue e;return!0}return!1}function Xl(e){var r=e.reduce(function(i,c){return i+c.length},0),a=new Uint8Array(r),n=0;return e.forEach(function(i){a.set(i,n),n+=i.length}),a}function cR(e,r,a){var n=Math.floor(a==0?0:Math.LOG10E*Math.log(Math.abs(a)))+6176-20,i=a/Math.pow(10,n-6176);e[r+15]|=n>>7,e[r+14]|=(n&127)<<1;for(var c=0;i>=1;++c,i/=256)e[r+c]=i&255;e[r+15]|=a>=0?0:128}function bu(e,r){var a=r?r[0]:0,n=e[a]&127;e:if(e[a++]>=128&&(n|=(e[a]&127)<<7,e[a++]<128||(n|=(e[a]&127)<<14,e[a++]<128)||(n|=(e[a]&127)<<21,e[a++]<128)||(n+=(e[a]&127)*Math.pow(2,28),++a,e[a++]<128)||(n+=(e[a]&127)*Math.pow(2,35),++a,e[a++]<128)||(n+=(e[a]&127)*Math.pow(2,42),++a,e[a++]<128)))break e;return r&&(r[0]=a),n}function Aa(e){var r=new Uint8Array(7);r[0]=e&127;var a=1;e:if(e>127){if(r[a-1]|=128,r[a]=e>>7&127,++a,e<=16383||(r[a-1]|=128,r[a]=e>>14&127,++a,e<=2097151)||(r[a-1]|=128,r[a]=e>>21&127,++a,e<=268435455)||(r[a-1]|=128,r[a]=e/256>>>21&127,++a,e<=34359738367)||(r[a-1]|=128,r[a]=e/65536>>>21&127,++a,e<=4398046511103))break e;r[a-1]|=128,r[a]=e/16777216>>>21&127,++a}return r.slice(0,a)}function Hd(e){var r=0,a=e[r]&127;e:if(e[r++]>=128){if(a|=(e[r]&127)<<7,e[r++]<128||(a|=(e[r]&127)<<14,e[r++]<128)||(a|=(e[r]&127)<<21,e[r++]<128))break e;a|=(e[r]&127)<<28}return a}function In(e){for(var r=[],a=[0];a[0]<e.length;){var n=a[0],i=bu(e,a),c=i&7;i=Math.floor(i/8);var u=0,g;if(i==0)break;switch(c){case 0:{for(var y=a[0];e[a[0]++]>=128;);g=e.slice(y,a[0])}break;case 5:u=4,g=e.slice(a[0],a[0]+u),a[0]+=u;break;case 1:u=8,g=e.slice(a[0],a[0]+u),a[0]+=u;break;case 2:u=bu(e,a),g=e.slice(a[0],a[0]+u),a[0]+=u;break;case 3:case 4:default:throw new Error("PB Type ".concat(c," for Field ").concat(i," at offset ").concat(n))}var x={data:g,type:c};r[i]==null?r[i]=[x]:r[i].push(x)}return r}function ns(e){var r=[];return e.forEach(function(a,n){a.forEach(function(i){i.data&&(r.push(Aa(n*8+i.type)),i.type==2&&r.push(Aa(i.data.length)),r.push(i.data))})}),Xl(r)}function Ki(e){for(var r,a=[],n=[0];n[0]<e.length;){var i=bu(e,n),c=In(e.slice(n[0],n[0]+i));n[0]+=i;var u={id:Hd(c[1][0].data),messages:[]};c[2].forEach(function(g){var y=In(g.data),x=Hd(y[3][0].data);u.messages.push({meta:y,data:e.slice(n[0],n[0]+x)}),n[0]+=x}),(r=c[3])!=null&&r[0]&&(u.merge=Hd(c[3][0].data)>>>0>0),a.push(u)}return a}function _d(e){var r=[];return e.forEach(function(a){var n=[];n[1]=[{data:Aa(a.id),type:0}],n[2]=[],a.merge!=null&&(n[3]=[{data:Aa(+!!a.merge),type:0}]);var i=[];a.messages.forEach(function(u){i.push(u.data),u.meta[3]=[{type:0,data:Aa(u.data.length)}],n[2].push({data:ns(u.meta),type:2})});var c=ns(n);r.push(Aa(c.length)),r.push(c),i.forEach(function(u){return r.push(u)})}),Xl(r)}function dR(e,r){if(e!=0)throw new Error("Unexpected Snappy chunk type ".concat(e));for(var a=[0],n=bu(r,a),i=[];a[0]<r.length;){var c=r[a[0]]&3;if(c==0){var u=r[a[0]++]>>2;if(u<60)++u;else{var g=u-59;u=r[a[0]],g>1&&(u|=r[a[0]+1]<<8),g>2&&(u|=r[a[0]+2]<<16),g>3&&(u|=r[a[0]+3]<<24),u>>>=0,u++,a[0]+=g}i.push(r.slice(a[0],a[0]+u)),a[0]+=u;continue}else{var y=0,x=0;if(c==1?(x=(r[a[0]]>>2&7)+4,y=(r[a[0]++]&224)<<3,y|=r[a[0]++]):(x=(r[a[0]++]>>2)+1,c==2?(y=r[a[0]]|r[a[0]+1]<<8,a[0]+=2):(y=(r[a[0]]|r[a[0]+1]<<8|r[a[0]+2]<<16|r[a[0]+3]<<24)>>>0,a[0]+=4)),i=[Xl(i)],y==0)throw new Error("Invalid offset 0");if(y>i[0].length)throw new Error("Invalid offset beyond length");if(x>=y)for(i.push(i[0].slice(-y)),x-=y;x>=i[i.length-1].length;)i.push(i[i.length-1]),x-=i[i.length-1].length;i.push(i[0].slice(-y,-y+x))}}var k=Xl(i);if(k.length!=n)throw new Error("Unexpected length: ".concat(k.length," != ").concat(n));return k}function Ji(e){for(var r=[],a=0;a<e.length;){var n=e[a++],i=e[a]|e[a+1]<<8|e[a+2]<<16;a+=3,r.push(dR(n,e.slice(a,a+i))),a+=i}if(a!==e.length)throw new Error("data is not a valid framed stream!");return Xl(r)}function wd(e){for(var r=[],a=0;a<e.length;){var n=Math.min(e.length-a,268435455),i=new Uint8Array(4);r.push(i);var c=Aa(n),u=c.length;r.push(c),n<=60?(u++,r.push(new Uint8Array([n-1<<2]))):n<=256?(u+=2,r.push(new Uint8Array([240,n-1&255]))):n<=65536?(u+=3,r.push(new Uint8Array([244,n-1&255,n-1>>8&255]))):n<=16777216?(u+=4,r.push(new Uint8Array([248,n-1&255,n-1>>8&255,n-1>>16&255]))):n<=4294967296&&(u+=5,r.push(new Uint8Array([252,n-1&255,n-1>>8&255,n-1>>16&255,n-1>>>24&255]))),r.push(e.slice(a,a+n)),u+=n,i[0]=0,i[1]=u&255,i[2]=u>>8&255,i[3]=u>>16&255,a+=n}return Xl(r)}function Ox(e,r){var a=new Uint8Array(32),n=Bf(a),i=12,c=0;switch(a[0]=5,e.t){case"n":a[1]=2,cR(a,i,e.v),c|=1,i+=16;break;case"b":a[1]=6,n.setFloat64(i,e.v?1:0,!0),c|=2,i+=8;break;case"s":if(r.indexOf(e.v)==-1)throw new Error("Value ".concat(e.v," missing from SST!"));a[1]=3,n.setUint32(i,r.indexOf(e.v),!0),c|=8,i+=4;break;default:throw"unsupported cell type "+e.t}return n.setUint32(8,c,!0),a.slice(0,i)}function Rx(e,r){var a=new Uint8Array(32),n=Bf(a),i=12,c=0;switch(a[0]=3,e.t){case"n":a[2]=2,n.setFloat64(i,e.v,!0),c|=32,i+=8;break;case"b":a[2]=6,n.setFloat64(i,e.v?1:0,!0),c|=32,i+=8;break;case"s":if(r.indexOf(e.v)==-1)throw new Error("Value ".concat(e.v," missing from SST!"));a[2]=3,n.setUint32(i,r.indexOf(e.v),!0),c|=16,i+=4;break;default:throw"unsupported cell type "+e.t}return n.setUint32(4,c,!0),a.slice(0,i)}function Bl(e){var r=In(e);return bu(r[1][0].data)}function uR(e,r,a){var n,i,c,u;if(!((n=e[6])!=null&&n[0])||!((i=e[7])!=null&&i[0]))throw"Mutation only works on post-BNC storages!";var g=((u=(c=e[8])==null?void 0:c[0])==null?void 0:u.data)&&Hd(e[8][0].data)>0||!1;if(g)throw"Math only works with normal offsets";for(var y=0,x=Bf(e[7][0].data),k=0,N=[],C=Bf(e[4][0].data),O=0,D=[],A=0;A<r.length;++A){if(r[A]==null){x.setUint16(A*2,65535,!0),C.setUint16(A*2,65535);continue}x.setUint16(A*2,k,!0),C.setUint16(A*2,O,!0);var I,z;switch(typeof r[A]){case"string":I=Ox({t:"s",v:r[A]},a),z=Rx({t:"s",v:r[A]},a);break;case"number":I=Ox({t:"n",v:r[A]},a),z=Rx({t:"n",v:r[A]},a);break;case"boolean":I=Ox({t:"b",v:r[A]},a),z=Rx({t:"b",v:r[A]},a);break;default:throw new Error("Unsupported value "+r[A])}N.push(I),k+=I.length,D.push(z),O+=z.length,++y}for(e[2][0].data=Aa(y);A<e[7][0].data.length/2;++A)x.setUint16(A*2,65535,!0),C.setUint16(A*2,65535,!0);return e[6][0].data=Xl(N),e[3][0].data=Xl(D),y}function hR(e,r){if(!r||!r.numbers)throw new Error("Must pass a `numbers` option -- check the README");var a=e.Sheets[e.SheetNames[0]];e.SheetNames.length>1&&console.error("The Numbers writer currently writes only the first table");var n=pi(a["!ref"]);n.s.r=n.s.c=0;var i=!1;n.e.c>9&&(i=!0,n.e.c=9),n.e.r>49&&(i=!0,n.e.r=49),i&&console.error("The Numbers writer is currently limited to ".concat(Tn(n)));var c=Uf(a,{range:n,header:1}),u=["~Sh33tJ5~"];c.forEach(function(ie){return ie.forEach(function(re){typeof re=="string"&&u.push(re)})});var g={},y=[],x=Ua.read(r.numbers,{type:"base64"});x.FileIndex.map(function(ie,re){return[ie,x.FullPaths[re]]}).forEach(function(ie){var re=ie[0],ne=ie[1];if(re.type==2&&re.name.match(/\.iwa/)){var ve=re.content,Ve=Ji(ve),Ae=Ki(Ve);Ae.forEach(function(ze){y.push(ze.id),g[ze.id]={deps:[],location:ne,type:Hd(ze.messages[0].meta[1][0].data)}})}}),y.sort(function(ie,re){return ie-re});var k=y.filter(function(ie){return ie>1}).map(function(ie){return[ie,Aa(ie)]});x.FileIndex.map(function(ie,re){return[ie,x.FullPaths[re]]}).forEach(function(ie){var re=ie[0];if(ie[1],!!re.name.match(/\.iwa/)){var ne=Ki(Ji(re.content));ne.forEach(function(ve){ve.messages.forEach(function(Ve){k.forEach(function(Ae){ve.messages.some(function(ze){return Hd(ze.meta[1][0].data)!=11006&&lR(ze.data,Ae[1])})&&g[Ae[0]].deps.push(ve.id)})})})}});for(var N=Ua.find(x,g[1].location),C=Ki(Ji(N.content)),O,D=0;D<C.length;++D){var A=C[D];A.id==1&&(O=A)}var I=Bl(In(O.messages[0].data)[1][0].data);for(N=Ua.find(x,g[I].location),C=Ki(Ji(N.content)),D=0;D<C.length;++D)A=C[D],A.id==I&&(O=A);for(I=Bl(In(O.messages[0].data)[2][0].data),N=Ua.find(x,g[I].location),C=Ki(Ji(N.content)),D=0;D<C.length;++D)A=C[D],A.id==I&&(O=A);for(I=Bl(In(O.messages[0].data)[2][0].data),N=Ua.find(x,g[I].location),C=Ki(Ji(N.content)),D=0;D<C.length;++D)A=C[D],A.id==I&&(O=A);var z=In(O.messages[0].data);{z[6][0].data=Aa(n.e.r+1),z[7][0].data=Aa(n.e.c+1);var U=Bl(z[46][0].data),B=Ua.find(x,g[U].location),V=Ki(Ji(B.content));{for(var Z=0;Z<V.length&&V[Z].id!=U;++Z);if(V[Z].id!=U)throw"Bad ColumnRowUIDMapArchive";var W=In(V[Z].messages[0].data);W[1]=[],W[2]=[],W[3]=[];for(var H=0;H<=n.e.c;++H){var le=[];le[1]=le[2]=[{type:0,data:Aa(H+420690)}],W[1].push({type:2,data:ns(le)}),W[2].push({type:0,data:Aa(H)}),W[3].push({type:0,data:Aa(H)})}W[4]=[],W[5]=[],W[6]=[];for(var Q=0;Q<=n.e.r;++Q)le=[],le[1]=le[2]=[{type:0,data:Aa(Q+726270)}],W[4].push({type:2,data:ns(le)}),W[5].push({type:0,data:Aa(Q)}),W[6].push({type:0,data:Aa(Q)});V[Z].messages[0].data=ns(W)}B.content=wd(_d(V)),B.size=B.content.length,delete z[46];var Ne=In(z[4][0].data);{Ne[7][0].data=Aa(n.e.r+1);var oe=In(Ne[1][0].data),se=Bl(oe[2][0].data);B=Ua.find(x,g[se].location),V=Ki(Ji(B.content));{if(V[0].id!=se)throw"Bad HeaderStorageBucket";var ce=In(V[0].messages[0].data);for(Q=0;Q<c.length;++Q){var Ce=In(ce[2][0].data);Ce[1][0].data=Aa(Q),Ce[4][0].data=Aa(c[Q].length),ce[2][Q]={type:ce[2][0].type,data:ns(Ce)}}V[0].messages[0].data=ns(ce)}B.content=wd(_d(V)),B.size=B.content.length;var ae=Bl(Ne[2][0].data);B=Ua.find(x,g[ae].location),V=Ki(Ji(B.content));{if(V[0].id!=ae)throw"Bad HeaderStorageBucket";for(ce=In(V[0].messages[0].data),H=0;H<=n.e.c;++H)Ce=In(ce[2][0].data),Ce[1][0].data=Aa(H),Ce[4][0].data=Aa(n.e.r+1),ce[2][H]={type:ce[2][0].type,data:ns(Ce)};V[0].messages[0].data=ns(ce)}B.content=wd(_d(V)),B.size=B.content.length;var me=Bl(Ne[4][0].data);(function(){for(var ie=Ua.find(x,g[me].location),re=Ki(Ji(ie.content)),ne,ve=0;ve<re.length;++ve){var Ve=re[ve];Ve.id==me&&(ne=Ve)}var Ae=In(ne.messages[0].data);{Ae[3]=[];var ze=[];u.forEach(function(Lt,mt){ze[1]=[{type:0,data:Aa(mt)}],ze[2]=[{type:0,data:Aa(1)}],ze[3]=[{type:2,data:oR(Lt)}],Ae[3].push({type:2,data:ns(ze)})})}ne.messages[0].data=ns(Ae);var Re=_d(re),Ze=wd(Re);ie.content=Ze,ie.size=ie.content.length})();var K=In(Ne[3][0].data);{var fe=K[1][0];delete K[2];var Oe=In(fe.data);{var ye=Bl(Oe[2][0].data);(function(){for(var ie=Ua.find(x,g[ye].location),re=Ki(Ji(ie.content)),ne,ve=0;ve<re.length;++ve){var Ve=re[ve];Ve.id==ye&&(ne=Ve)}var Ae=In(ne.messages[0].data);{delete Ae[6],delete K[7];var ze=new Uint8Array(Ae[5][0].data);Ae[5]=[];for(var Re=0,Ze=0;Ze<=n.e.r;++Ze){var Lt=In(ze);Re+=uR(Lt,c[Ze],u),Lt[1][0].data=Aa(Ze),Ae[5].push({data:ns(Lt),type:2})}Ae[1]=[{type:0,data:Aa(n.e.c+1)}],Ae[2]=[{type:0,data:Aa(n.e.r+1)}],Ae[3]=[{type:0,data:Aa(Re)}],Ae[4]=[{type:0,data:Aa(n.e.r+1)}]}ne.messages[0].data=ns(Ae);var mt=_d(re),Zt=wd(mt);ie.content=Zt,ie.size=ie.content.length})()}fe.data=ns(Oe)}Ne[3][0].data=ns(K)}z[4][0].data=ns(Ne)}O.messages[0].data=ns(z);var J=_d(C),G=wd(J);return N.content=G,N.size=N.content.length,x}function fR(e){return function(a){for(var n=0;n!=e.length;++n){var i=e[n];a[i[0]]===void 0&&(a[i[0]]=i[1]),i[2]==="n"&&(a[i[0]]=Number(a[i[0]]))}}}function Yp(e){fR([["cellDates",!1],["bookSST",!1],["bookType","xlsx"],["compression",!1],["WTF",!1]])(e)}function mR(e,r){return r.bookType=="ods"?f3(e,r):r.bookType=="numbers"?hR(e,r):r.bookType=="xlsb"?gR(e,r):xR(e,r)}function gR(e,r){Od=1024,e&&!e.SSF&&(e.SSF=Js(mn)),e&&e.SSF&&(am(),rm(e.SSF),r.revssf=nm(e.SSF),r.revssf[e.SSF[65535]]=0,r.ssf=e.SSF),r.rels={},r.wbrels={},r.Strings=[],r.Strings.Count=0,r.Strings.Unique=0,cu?r.revStrings=new Map:(r.revStrings={},r.revStrings.foo=[],delete r.revStrings.foo);var a=r.bookType=="xlsb"?"bin":"xml",n=Z4.indexOf(r.bookType)>-1,i=N4();Yp(r=r||{});var c=Rp(),u="",g=0;if(r.cellXfs=[],ql(r.cellXfs,{},{revssf:{General:0}}),e.Props||(e.Props={}),u="docProps/core.xml",Kr(c,u,j4(e.Props,r)),i.coreprops.push(u),Oa(r.rels,2,u,va.CORE_PROPS),u="docProps/app.xml",!(e.Props&&e.Props.SheetNames))if(!e.Workbook||!e.Workbook.Sheets)e.Props.SheetNames=e.SheetNames;else{for(var y=[],x=0;x<e.SheetNames.length;++x)(e.Workbook.Sheets[x]||{}).Hidden!=2&&y.push(e.SheetNames[x]);e.Props.SheetNames=y}for(e.Props.Worksheets=e.Props.SheetNames.length,Kr(c,u,A4(e.Props)),i.extprops.push(u),Oa(r.rels,3,u,va.EXT_PROPS),e.Custprops!==e.Props&&ds(e.Custprops||{}).length>0&&(u="docProps/custom.xml",Kr(c,u,O4(e.Custprops)),i.custprops.push(u),Oa(r.rels,4,u,va.CUST_PROPS)),g=1;g<=e.SheetNames.length;++g){var k={"!id":{}},N=e.Sheets[e.SheetNames[g-1]],C=(N||{})["!type"]||"sheet";switch(C){case"chart":default:u="xl/worksheets/sheet"+g+"."+a,Kr(c,u,yO(g-1,u,r,e,k)),i.sheets.push(u),Oa(r.wbrels,-1,"worksheets/sheet"+g+"."+a,va.WS[0])}if(N){var O=N["!comments"],D=!1,A="";O&&O.length>0&&(A="xl/comments"+g+"."+a,Kr(c,A,_O(O,A)),i.comments.push(A),Oa(k,-1,"../comments"+g+"."+a,va.CMNT),D=!0),N["!legacy"]&&D&&Kr(c,"xl/drawings/vmlDrawing"+g+".vml",X4(g,N["!comments"])),delete N["!comments"],delete N["!legacy"]}k["!id"].rId1&&Kr(c,C4(u),Ud(k))}return r.Strings!=null&&r.Strings.length>0&&(u="xl/sharedStrings."+a,Kr(c,u,vO(r.Strings,u,r)),i.strs.push(u),Oa(r.wbrels,-1,"sharedStrings."+a,va.SST)),u="xl/workbook."+a,Kr(c,u,pO(e,u)),i.workbooks.push(u),Oa(r.rels,1,u,va.WB),u="xl/theme/theme1.xml",Kr(c,u,G4(e.Themes,r)),i.themes.push(u),Oa(r.wbrels,-1,"theme/theme1.xml",va.THEME),u="xl/styles."+a,Kr(c,u,bO(e,u,r)),i.styles.push(u),Oa(r.wbrels,-1,"styles."+a,va.STY),e.vbaraw&&n&&(u="xl/vbaProject.bin",Kr(c,u,e.vbaraw),i.vba.push(u),Oa(r.wbrels,-1,"vbaProject.bin",va.VBA)),u="xl/metadata."+a,Kr(c,u,wO(u)),i.metadata.push(u),Oa(r.wbrels,-1,"metadata."+a,va.XLMETA),Kr(c,"[Content_Types].xml",S4(i,r)),Kr(c,"_rels/.rels",Ud(r.rels)),Kr(c,"xl/_rels/workbook."+a+".rels",Ud(r.wbrels)),delete r.revssf,delete r.ssf,c}function xR(e,r){Od=1024,e&&!e.SSF&&(e.SSF=Js(mn)),e&&e.SSF&&(am(),rm(e.SSF),r.revssf=nm(e.SSF),r.revssf[e.SSF[65535]]=0,r.ssf=e.SSF),r.rels={},r.wbrels={},r.Strings=[],r.Strings.Count=0,r.Strings.Unique=0,cu?r.revStrings=new Map:(r.revStrings={},r.revStrings.foo=[],delete r.revStrings.foo);var a="xml",n=Z4.indexOf(r.bookType)>-1,i=N4();Yp(r=r||{});var c=Rp(),u="",g=0;if(r.cellXfs=[],ql(r.cellXfs,{},{revssf:{General:0}}),e.Props||(e.Props={}),u="docProps/core.xml",Kr(c,u,j4(e.Props,r)),i.coreprops.push(u),Oa(r.rels,2,u,va.CORE_PROPS),u="docProps/app.xml",!(e.Props&&e.Props.SheetNames))if(!e.Workbook||!e.Workbook.Sheets)e.Props.SheetNames=e.SheetNames;else{for(var y=[],x=0;x<e.SheetNames.length;++x)(e.Workbook.Sheets[x]||{}).Hidden!=2&&y.push(e.SheetNames[x]);e.Props.SheetNames=y}e.Props.Worksheets=e.Props.SheetNames.length,Kr(c,u,A4(e.Props)),i.extprops.push(u),Oa(r.rels,3,u,va.EXT_PROPS),e.Custprops!==e.Props&&ds(e.Custprops||{}).length>0&&(u="docProps/custom.xml",Kr(c,u,O4(e.Custprops)),i.custprops.push(u),Oa(r.rels,4,u,va.CUST_PROPS));var k=["SheetJ5"];for(r.tcid=0,g=1;g<=e.SheetNames.length;++g){var N={"!id":{}},C=e.Sheets[e.SheetNames[g-1]],O=(C||{})["!type"]||"sheet";switch(O){case"chart":default:u="xl/worksheets/sheet"+g+"."+a,Kr(c,u,n3(g-1,r,e,N)),i.sheets.push(u),Oa(r.wbrels,-1,"worksheets/sheet"+g+"."+a,va.WS[0])}if(C){var D=C["!comments"],A=!1,I="";if(D&&D.length>0){var z=!1;D.forEach(function(U){U[1].forEach(function(B){B.T==!0&&(z=!0)})}),z&&(I="xl/threadedComments/threadedComment"+g+"."+a,Kr(c,I,XT(D,k,r)),i.threadedcomments.push(I),Oa(N,-1,"../threadedComments/threadedComment"+g+"."+a,va.TCMNT)),I="xl/comments"+g+"."+a,Kr(c,I,Y4(D)),i.comments.push(I),Oa(N,-1,"../comments"+g+"."+a,va.CMNT),A=!0}C["!legacy"]&&A&&Kr(c,"xl/drawings/vmlDrawing"+g+".vml",X4(g,C["!comments"])),delete C["!comments"],delete C["!legacy"]}N["!id"].rId1&&Kr(c,C4(u),Ud(N))}return r.Strings!=null&&r.Strings.length>0&&(u="xl/sharedStrings."+a,Kr(c,u,B4(r.Strings,r)),i.strs.push(u),Oa(r.wbrels,-1,"sharedStrings."+a,va.SST)),u="xl/workbook."+a,Kr(c,u,o3(e)),i.workbooks.push(u),Oa(r.rels,1,u,va.WB),u="xl/theme/theme1.xml",Kr(c,u,G4(e.Themes,r)),i.themes.push(u),Oa(r.wbrels,-1,"theme/theme1.xml",va.THEME),u="xl/styles."+a,Kr(c,u,V4(e,r)),i.styles.push(u),Oa(r.wbrels,-1,"styles."+a,va.STY),e.vbaraw&&n&&(u="xl/vbaProject.bin",Kr(c,u,e.vbaraw),i.vba.push(u),Oa(r.wbrels,-1,"vbaProject.bin",va.VBA)),u="xl/metadata."+a,Kr(c,u,$4()),i.metadata.push(u),Oa(r.wbrels,-1,"metadata."+a,va.XLMETA),k.length>1&&(u="xl/persons/person.xml",Kr(c,u,YT(k)),i.people.push(u),Oa(r.wbrels,-1,"persons/person.xml",va.PEOPLE)),Kr(c,"[Content_Types].xml",S4(i,r)),Kr(c,"_rels/.rels",Ud(r.rels)),Kr(c,"xl/_rels/workbook."+a+".rels",Ud(r.wbrels)),delete r.revssf,delete r.ssf,c}function pR(e,r){var a="";switch((r||{}).type||"base64"){case"buffer":return[e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7]];case"base64":a=il(e.slice(0,12));break;case"binary":a=e;break;case"array":return[e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7]];default:throw new Error("Unrecognized type "+(r&&r.type||"undefined"))}return[a.charCodeAt(0),a.charCodeAt(1),a.charCodeAt(2),a.charCodeAt(3),a.charCodeAt(4),a.charCodeAt(5),a.charCodeAt(6),a.charCodeAt(7)]}function m3(e,r){switch(r.type){case"base64":case"binary":break;case"buffer":case"array":r.type="";break;case"file":return Tu(r.file,Ua.write(e,{type:Na?"buffer":""}));case"string":throw new Error("'string' output type invalid for '"+r.bookType+"' files");default:throw new Error("Unrecognized type "+r.type)}return Ua.write(e,r)}function yR(e,r){var a=Js(r||{}),n=mR(e,a);return bR(n,a)}function bR(e,r){var a={},n=Na?"nodebuffer":typeof Uint8Array!="undefined"?"array":"string";if(r.compression&&(a.compression="DEFLATE"),r.password)a.type=n;else switch(r.type){case"base64":a.type="base64";break;case"binary":a.type="string";break;case"string":throw new Error("'string' output type invalid for '"+r.bookType+"' files");case"buffer":case"file":a.type=n;break;default:throw new Error("Unrecognized type "+r.type)}var i=e.FullPaths?Ua.write(e,{fileType:"zip",type:{nodebuffer:"buffer",string:"binary"}[a.type]||a.type,compression:!!r.compression}):e.generate(a);if(typeof Deno!="undefined"&&typeof i=="string"){if(r.type=="binary"||r.type=="base64")return i;i=new Uint8Array(tm(i))}return r.password&&typeof encrypt_agile!="undefined"?m3(encrypt_agile(i,r.password),r):r.type==="file"?Tu(r.file,i):r.type=="string"?su(i):i}function vR(e,r){var a=r||{},n=IO(e,a);return m3(n,a)}function bo(e,r,a){a||(a="");var n=a+e;switch(r.type){case"base64":return gu(pu(n));case"binary":return pu(n);case"string":return e;case"file":return Tu(r.file,n,"utf8");case"buffer":return Na?dl(n,"utf8"):typeof TextEncoder!="undefined"?new TextEncoder().encode(n):bo(n,{type:"binary"}).split("").map(function(i){return i.charCodeAt(0)})}throw new Error("Unrecognized type "+r.type)}function _R(e,r){switch(r.type){case"base64":return gu(e);case"binary":return e;case"string":return e;case"file":return Tu(r.file,e,"binary");case"buffer":return Na?dl(e,"binary"):e.split("").map(function(a){return a.charCodeAt(0)})}throw new Error("Unrecognized type "+r.type)}function rf(e,r){switch(r.type){case"string":case"base64":case"binary":for(var a="",n=0;n<e.length;++n)a+=String.fromCharCode(e[n]);return r.type=="base64"?gu(a):r.type=="string"?su(a):a;case"file":return Tu(r.file,e);case"buffer":return e;default:throw new Error("Unrecognized type "+r.type)}}function g3(e,r){ZC(),iO(e);var a=Js(r||{});if(a.cellStyles&&(a.cellNF=!0,a.sheetStubs=!0),a.type=="array"){a.type="binary";var n=g3(e,a);return a.type="array",tm(n)}var i=0;if(a.sheet&&(typeof a.sheet=="number"?i=a.sheet:i=e.SheetNames.indexOf(a.sheet),!e.SheetNames[i]))throw new Error("Sheet not found: "+a.sheet+" : "+typeof a.sheet);switch(a.bookType||"xlsb"){case"xml":case"xlml":return bo(DO(e,a),a);case"slk":case"sylk":return bo(aT.from_sheet(e.Sheets[e.SheetNames[i]],a),a);case"htm":case"html":return bo(d3(e.Sheets[e.SheetNames[i]],a),a);case"txt":return _R(x3(e.Sheets[e.SheetNames[i]],a),a);case"csv":return bo(Zp(e.Sheets[e.SheetNames[i]],a),a,"\uFEFF");case"dif":return bo(nT.from_sheet(e.Sheets[e.SheetNames[i]],a),a);case"dbf":return rf(rT.from_sheet(e.Sheets[e.SheetNames[i]],a),a);case"prn":return bo(sT.from_sheet(e.Sheets[e.SheetNames[i]],a),a);case"rtf":return bo(hT.from_sheet(e.Sheets[e.SheetNames[i]],a),a);case"eth":return bo(F4.from_sheet(e.Sheets[e.SheetNames[i]],a),a);case"fods":return bo(f3(e,a),a);case"wk1":return rf(Fv.sheet_to_wk1(e.Sheets[e.SheetNames[i]],a),a);case"wk3":return rf(Fv.book_to_wk3(e,a),a);case"biff2":a.biff||(a.biff=2);case"biff3":a.biff||(a.biff=3);case"biff4":return a.biff||(a.biff=4),rf(c3(e,a),a);case"biff5":a.biff||(a.biff=5);case"biff8":case"xla":case"xls":return a.biff||(a.biff=8),vR(e,a);case"xlsx":case"xlsm":case"xlam":case"xlsb":case"numbers":case"ods":return yR(e,a);default:throw new Error("Unrecognized bookType |"+a.bookType+"|")}}function wR(e){if(!e.bookType){var r={xls:"biff8",htm:"html",slk:"sylk",socialcalc:"eth",Sh33tJS:"WTF"},a=e.file.slice(e.file.lastIndexOf(".")).toLowerCase();a.match(/^\.[a-z]+$/)&&(e.bookType=a.slice(1)),e.bookType=r[e.bookType]||e.bookType}}function ul(e,r,a){var n={};return n.type="file",n.file=r,wR(n),g3(e,n)}function kR(e,r,a,n,i,c,u,g){var y=ls(a),x=g.defval,k=g.raw||!Object.prototype.hasOwnProperty.call(g,"raw"),N=!0,C=i===1?[]:{};if(i!==1)if(Object.defineProperty)try{Object.defineProperty(C,"__rowNum__",{value:a,enumerable:!1})}catch(I){C.__rowNum__=a}else C.__rowNum__=a;if(!u||e[a])for(var O=r.s.c;O<=r.e.c;++O){var D=u?e[a][O]:e[n[O]+y];if(D===void 0||D.t===void 0){if(x===void 0)continue;c[O]!=null&&(C[c[O]]=x);continue}var A=D.v;switch(D.t){case"z":if(A==null)break;continue;case"e":A=A==0?null:void 0;break;case"s":case"d":case"b":case"n":break;default:throw new Error("unrecognized type "+D.t)}if(c[O]!=null){if(A==null)if(D.t=="e"&&A===null)C[c[O]]=null;else if(x!==void 0)C[c[O]]=x;else if(k&&A===null)C[c[O]]=null;else continue;else C[c[O]]=k&&(D.t!=="n"||D.t==="n"&&g.rawNumbers!==!1)?A:ol(D,A,g);A!=null&&(N=!1)}}return{row:C,isempty:N}}function Uf(e,r){if(e==null||e["!ref"]==null)return[];var a={t:"n",v:0},n=0,i=1,c=[],u=0,g="",y={s:{r:0,c:0},e:{r:0,c:0}},x=r||{},k=x.range!=null?x.range:e["!ref"];switch(x.header===1?n=1:x.header==="A"?n=2:Array.isArray(x.header)?n=3:x.header==null&&(n=0),typeof k){case"string":y=Ya(k);break;case"number":y=Ya(e["!ref"]),y.s.r=k;break;default:y=k}n>0&&(i=0);var N=ls(y.s.r),C=[],O=[],D=0,A=0,I=Array.isArray(e),z=y.s.r,U=0,B={};I&&!e[z]&&(e[z]=[]);var V=x.skipHidden&&e["!cols"]||[],Z=x.skipHidden&&e["!rows"]||[];for(U=y.s.c;U<=y.e.c;++U)if(!(V[U]||{}).hidden)switch(C[U]=bs(U),a=I?e[z][U]:e[C[U]+N],n){case 1:c[U]=U-y.s.c;break;case 2:c[U]=C[U];break;case 3:c[U]=x.header[U-y.s.c];break;default:if(a==null&&(a={w:"__EMPTY",t:"s"}),g=u=ol(a,null,x),A=B[u]||0,!A)B[u]=1;else{do g=u+"_"+A++;while(B[g]);B[u]=A,B[g]=1}c[U]=g}for(z=y.s.r+i;z<=y.e.r;++z)if(!(Z[z]||{}).hidden){var W=kR(e,y,z,C,n,c,I,x);(W.isempty===!1||(n===1?x.blankrows!==!1:x.blankrows))&&(O[D++]=W.row)}return O.length=D,O}var $v=/"/g;function NR(e,r,a,n,i,c,u,g){for(var y=!0,x=[],k="",N=ls(a),C=r.s.c;C<=r.e.c;++C)if(n[C]){var O=g.dense?(e[a]||[])[C]:e[n[C]+N];if(O==null)k="";else if(O.v!=null){y=!1,k=""+(g.rawNumbers&&O.t=="n"?O.v:ol(O,null,g));for(var D=0,A=0;D!==k.length;++D)if((A=k.charCodeAt(D))===i||A===c||A===34||g.forceQuotes){k='"'+k.replace($v,'""')+'"';break}k=="ID"&&(k='"ID"')}else O.f!=null&&!O.F?(y=!1,k="="+O.f,k.indexOf(",")>=0&&(k='"'+k.replace($v,'""')+'"')):k="";x.push(k)}return g.blankrows===!1&&y?null:x.join(u)}function Zp(e,r){var a=[],n=r==null?{}:r;if(e==null||e["!ref"]==null)return"";var i=Ya(e["!ref"]),c=n.FS!==void 0?n.FS:",",u=c.charCodeAt(0),g=n.RS!==void 0?n.RS:`
|
||
`,y=g.charCodeAt(0),x=new RegExp((c=="|"?"\\|":c)+"+$"),k="",N=[];n.dense=Array.isArray(e);for(var C=n.skipHidden&&e["!cols"]||[],O=n.skipHidden&&e["!rows"]||[],D=i.s.c;D<=i.e.c;++D)(C[D]||{}).hidden||(N[D]=bs(D));for(var A=0,I=i.s.r;I<=i.e.r;++I)(O[I]||{}).hidden||(k=NR(e,i,I,N,u,y,c,n),k!=null&&(n.strip&&(k=k.replace(x,"")),(k||n.blankrows!==!1)&&a.push((A++?g:"")+k)));return delete n.dense,a.join("")}function x3(e,r){r||(r={}),r.FS=" ",r.RS=`
|
||
`;var a=Zp(e,r);return a}function SR(e){var r="",a,n="";if(e==null||e["!ref"]==null)return[];var i=Ya(e["!ref"]),c="",u=[],g,y=[],x=Array.isArray(e);for(g=i.s.c;g<=i.e.c;++g)u[g]=bs(g);for(var k=i.s.r;k<=i.e.r;++k)for(c=ls(k),g=i.s.c;g<=i.e.c;++g)if(r=u[g]+c,a=x?(e[k]||[])[g]:e[r],n="",a!==void 0){if(a.F!=null){if(r=a.F,!a.f)continue;n=a.f,r.indexOf(":")==-1&&(r=r+":"+r)}if(a.f!=null)n=a.f;else{if(a.t=="z")continue;if(a.t=="n"&&a.v!=null)n=""+a.v;else if(a.t=="b")n=a.v?"TRUE":"FALSE";else if(a.w!==void 0)n="'"+a.w;else{if(a.v===void 0)continue;a.t=="s"?n="'"+a.v:n=""+a.v}}y[y.length]=r+"="+n}return y}function p3(e,r,a){var n=a||{},i=+!n.skipHeader,c=e||{},u=0,g=0;if(c&&n.origin!=null)if(typeof n.origin=="number")u=n.origin;else{var y=typeof n.origin=="string"?Gn(n.origin):n.origin;u=y.r,g=y.c}var x,k={s:{c:0,r:0},e:{c:g,r:u+r.length-1+i}};if(c["!ref"]){var N=Ya(c["!ref"]);k.e.c=Math.max(k.e.c,N.e.c),k.e.r=Math.max(k.e.r,N.e.r),u==-1&&(u=N.e.r+1,k.e.r=u+r.length-1+i)}else u==-1&&(u=0,k.e.r=r.length-1+i);var C=n.header||[],O=0;r.forEach(function(A,I){ds(A).forEach(function(z){(O=C.indexOf(z))==-1&&(C[O=C.length]=z);var U=A[z],B="z",V="",Z=Ma({c:g+O,r:u+I+i});x=vu(c,Z),U&&typeof U=="object"&&!(U instanceof Date)?c[Z]=U:(typeof U=="number"?B="n":typeof U=="boolean"?B="b":typeof U=="string"?B="s":U instanceof Date?(B="d",n.cellDates||(B="n",U=Ks(U)),V=n.dateNF||mn[14]):U===null&&n.nullError&&(B="e",U=0),x?(x.t=B,x.v=U,delete x.w,delete x.R,V&&(x.z=V)):c[Z]=x={t:B,v:U},V&&(x.z=V))})}),k.e.c=Math.max(k.e.c,g+C.length-1);var D=ls(u);if(i)for(O=0;O<C.length;++O)c[bs(O+g)+D]={t:"s",v:C[O]};return c["!ref"]=Tn(k),c}function CR(e,r){return p3(null,e,r)}function vu(e,r,a){if(typeof r=="string"){if(Array.isArray(e)){var n=Gn(r);return e[n.r]||(e[n.r]=[]),e[n.r][n.c]||(e[n.r][n.c]={t:"z"})}return e[r]||(e[r]={t:"z"})}return typeof r!="number"?vu(e,Ma(r)):vu(e,Ma({r,c:a||0}))}function ER(e,r){if(typeof r=="number"){if(r>=0&&e.SheetNames.length>r)return r;throw new Error("Cannot find sheet # "+r)}else if(typeof r=="string"){var a=e.SheetNames.indexOf(r);if(a>-1)return a;throw new Error("Cannot find sheet name |"+r+"|")}else throw new Error("Cannot find sheet |"+r+"|")}function jR(){return{SheetNames:[],Sheets:{}}}function TR(e,r,a,n){var i=1;if(!a)for(;i<=65535&&e.SheetNames.indexOf(a="Sheet"+i)!=-1;++i,a=void 0);if(!a||e.SheetNames.length>=65535)throw new Error("Too many worksheets");if(n&&e.SheetNames.indexOf(a)>=0){var c=a.match(/(^.*?)(\d+)$/);i=c&&+c[2]||0;var u=c&&c[1]||a;for(++i;i<=65535&&e.SheetNames.indexOf(a=u+i)!=-1;++i);}if(i3(a),e.SheetNames.indexOf(a)>=0)throw new Error("Worksheet with name |"+a+"| already exists!");return e.SheetNames.push(a),e.Sheets[a]=r,a}function AR(e,r,a){e.Workbook||(e.Workbook={}),e.Workbook.Sheets||(e.Workbook.Sheets=[]);var n=ER(e,r);switch(e.Workbook.Sheets[n]||(e.Workbook.Sheets[n]={}),a){case 0:case 1:case 2:break;default:throw new Error("Bad sheet visibility setting "+a)}e.Workbook.Sheets[n].Hidden=a}function OR(e,r){return e.z=r,e}function y3(e,r,a){return r?(e.l={Target:r},a&&(e.l.Tooltip=a)):delete e.l,e}function RR(e,r,a){return y3(e,"#"+r,a)}function MR(e,r,a){e.c||(e.c=[]),e.c.push({t:r,a:a||"SheetJS"})}function DR(e,r,a,n){for(var i=typeof r!="string"?r:Ya(r),c=typeof r=="string"?r:Tn(r),u=i.s.r;u<=i.e.r;++u)for(var g=i.s.c;g<=i.e.c;++g){var y=vu(e,u,g);y.t="n",y.F=c,delete y.v,u==i.s.r&&g==i.s.c&&(y.f=a,n&&(y.D=!0))}return e}var Wa={encode_col:bs,encode_row:ls,encode_cell:Ma,encode_range:Tn,decode_col:Fp,decode_row:Pp,split_cell:ZE,decode_cell:Gn,decode_range:pi,format_cell:ol,sheet_add_aoa:y4,sheet_add_json:p3,sheet_add_dom:u3,aoa_to_sheet:Qd,json_to_sheet:CR,table_to_sheet:h3,table_to_book:nR,sheet_to_csv:Zp,sheet_to_txt:x3,sheet_to_json:Uf,sheet_to_html:d3,sheet_to_formulae:SR,sheet_to_row_object_array:Uf,sheet_get_cell:vu,book_new:jR,book_append_sheet:TR,book_set_sheet_visibility:AR,cell_set_number_format:OR,cell_set_hyperlink:y3,cell_set_internal_link:RR,cell_add_comment:MR,sheet_set_array_formula:DR,consts:{SHEET_VISIBLE:0,SHEET_HIDDEN:1,SHEET_VERY_HIDDEN:2}};const LR="Technician Work Order Summary",Mx={completed:"#10B981",in_progress:"#3B82F6",open:"#F59E0B"},hf=e=>(e.custom_assign_to_contractor||e.assigned_technician||"Unknown").trim()||"Unknown",b3=e=>{if(!e.length)return null;const r=e.map(hf),a=[{name:"completed",values:e.map(i=>Number(i.completed)||0),color:Mx.completed},{name:"in_progress",values:e.map(i=>Number(i.in_progress)||0),color:Mx.in_progress},{name:"open",values:e.map(i=>Number(i.open)||0),color:Mx.open}].filter(i=>i.values.some(c=>c>0)),n=e.reduce((i,c)=>(i.completed+=Number(c.completed)||0,i.in_progress+=Number(c.in_progress)||0,i.open+=Number(c.open)||0,i.total+=Number(c.total)||0,i),{completed:0,in_progress:0,open:0,total:0});return{labels:r,datasets:a,totals:n,rows:e}},v3=e=>xe(null,null,function*(){var g,y,x;const r=typeof window!="undefined"&&window.csrf_token&&window.csrf_token!=="None"?window.csrf_token:null,a={"Content-Type":"application/json",Accept:"application/json"};r&&(a["X-Frappe-CSRF-Token"]=r);const n={};Object.entries(e).forEach(([k,N])=>{N&&(n[k]=N)});const i=yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:a,credentials:"include",body:JSON.stringify({report_name:LR,filters:n,ignore_prepared_report:1})}),c=yield i.json();if(!i.ok)throw new Error((c==null?void 0:c.message)||(c==null?void 0:c.exc)||"Failed to load technician work summary");const u=((g=c==null?void 0:c.message)==null?void 0:g.result)||((x=(y=c==null?void 0:c.message)==null?void 0:y.message)==null?void 0:x.result)||[];return Array.isArray(u)?u:[]}),IR=e=>xe(null,null,function*(){const r=yield v3(e);return b3(r)});function nn(e){return e?e.startsWith("Mobile")||e.startsWith("Dental"):!1}function PR(e,r,a,n){const i={};return e&&(i.company=e),r&&nn(e)&&(i.site_name=r),a&&(i.from_date=a),n&&(i.to_date=n),i}function FR(e,r){const a={};return e&&(a.company=e),r&&nn(e)&&(a.site_name=r),a}function BR(e,r){const a={};return e&&(a.custom_hospital_name=e),r&&nn(e)&&(a.site_name=r),a}function hl(e,r){const a={};return e&&nn(e)&&(a.mobile_team=e),r&&(a.name=r),a}function _3(e){const r={domain:"Healthcare"};return e!=null&&e.length&&(r.name=["in",e]),r}const UR=({isOpen:e,onClose:r,permittedIssueTypes:a=[],isAdmin:n=!1,defaultWorkOrderType:i="",defaultFromDate:c="",defaultToDate:u="",defaultCompany:g="",defaultSiteName:y="",companyLocked:x=!1,siteLocked:k=!1,hospitalLinkFilters:N})=>{const{t:C}=oa(),[O,D]=E.useState(c),[A,I]=E.useState(u),[z,U]=E.useState(i),[B,V]=E.useState(g),[Z,W]=E.useState(y),[H,le]=E.useState([]),[Q,Ne]=E.useState(!1),[oe,se]=E.useState(null),ce=!n&&a.length===1?a[0]:"",Ce=!!ce,ae=nn(B),me=E.useMemo(()=>hl(B,k?Z:void 0),[B,Z,k]);E.useEffect(()=>{e&&(D(c),I(u),U(ce||i),V(g),W(y))},[e,c,u,i,g,y,ce]),E.useEffect(()=>{if(!e)return;const re=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=re}},[e]),E.useEffect(()=>{if(!e)return;const re=ne=>{ne.key==="Escape"&&r()};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},[e,r]);const K=E.useCallback(()=>{const re={};return O&&(re.from_date=O),A&&(re.to_date=A),z&&(re.work_order_type=z),B&&(re.company=B),Z&&ae&&(re.site_name=Z),re},[O,A,z,B,Z,ae]),fe=E.useCallback(()=>xe(null,null,function*(){Ne(!0),se(null);try{let re=yield v3(K());le(re)}catch(re){le([]),se(re instanceof Error?re.message:"Failed to load report")}finally{Ne(!1)}}),[K]);E.useEffect(()=>{e&&fe()},[e,fe]);const Oe=E.useMemo(()=>{const re=b3(H);return(re==null?void 0:re.totals)||{completed:0,in_progress:0,open:0,total:0}},[H]),ye=E.useMemo(()=>H.map(re=>({Technician:hf(re),Total:Number(re.total)||0,Completed:Number(re.completed)||0,"In Progress":Number(re.in_progress)||0,Open:Number(re.open)||0})),[H]),J=()=>{if(!ye.length)return;const re=Object.keys(ye[0]),ne=[re.join(","),...ye.map(ze=>re.map(Re=>`"${String(ze[Re]).replace(/"/g,'""')}"`).join(","))].join(`
|
||
`),ve=new Blob([ne],{type:"text/csv;charset=utf-8;"}),Ve=URL.createObjectURL(ve),Ae=document.createElement("a");Ae.href=Ve,Ae.download="technician-work-order-summary.csv",Ae.click(),URL.revokeObjectURL(Ve)},G=()=>{if(!ye.length)return;const re=Wa.json_to_sheet(ye),ne=Wa.book_new();Wa.book_append_sheet(ne,re,"Technicians"),ul(ne,"technician-work-order-summary.xlsx")},ie=()=>{window.print()};return e?t.jsx("div",{className:"fixed inset-0 z-[80] bg-black/50 backdrop-blur-sm",children:t.jsxs("div",{className:"fixed inset-0 bg-white dark:bg-gray-900 flex flex-col print:static print:inset-auto",children:[t.jsx("div",{className:"bg-gradient-to-r from-purple-700 via-indigo-700 to-purple-800 text-white px-4 sm:px-5 py-3 print:bg-white print:text-black",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("button",{type:"button",onClick:r,className:"p-1.5 rounded-lg hover:bg-white/10 print:hidden","aria-label":"Close",children:t.jsx(bi,{className:"text-sm"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-base sm:text-lg font-semibold truncate",children:C("dashboard.techniciansWorked",{defaultValue:"Technicians Work Summary"})}),t.jsx("p",{className:"text-xs sm:text-sm text-purple-100 print:text-gray-600",children:C("dashboard.techniciansWorkedReportHint",{defaultValue:"Work orders grouped by assigned contractor"})})]})]}),t.jsx("button",{type:"button",onClick:r,className:"p-2 rounded-lg hover:bg-white/10 print:hidden","aria-label":"Close",children:t.jsx(qt,{})})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-3 sm:p-4 space-y-3",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-3 print:hidden",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-5 gap-2",children:[t.jsxs("div",{className:No,children:[t.jsx("label",{className:wo,children:C("dashboard.fromDate",{defaultValue:"From Date"})}),t.jsx("input",{type:"date",value:O,onChange:re=>D(re.target.value),className:ko})]}),t.jsxs("div",{className:No,children:[t.jsx("label",{className:wo,children:C("dashboard.toDate",{defaultValue:"To Date"})}),t.jsx("input",{type:"date",value:A,onChange:re=>I(re.target.value),className:ko})]}),t.jsx(er,{label:C("dashboard.technicalDepartment",{defaultValue:"Technical Department"}),doctype:"Issue Type",value:z,onChange:U,placeholder:C("dashboard.allDepartments",{defaultValue:"All Departments"}),disabled:Ce,compact:!0}),t.jsx(er,{label:C("commonFields.hospital",{defaultValue:"Hospital"}),doctype:"Company",value:B,onChange:re=>{V(re),nn(re)||W("")},placeholder:C("dashboard.allHospitals",{defaultValue:"All Hospitals"}),disabled:x,compact:!0,filters:N}),ae&&t.jsx(er,{label:C("commonFields.siteName",{defaultValue:"PHCC Site"}),doctype:"Mobile Team Site",value:Z,onChange:W,placeholder:C("dashboard.allSites",{defaultValue:"All Sites"}),disabled:k,compact:!0,filters:me})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-2",children:[t.jsxs("button",{type:"button",onClick:fe,disabled:Q,className:em("purple"),children:[t.jsx(Eo,{className:`text-[10px] ${Q?"animate-spin":""}`}),C("dashboard.refreshReport",{defaultValue:"Refresh"})]}),t.jsxs("button",{type:"button",onClick:J,disabled:!ye.length,className:Fd,children:[t.jsx(Co,{className:"text-[10px]"}),"CSV"]}),t.jsxs("button",{type:"button",onClick:G,disabled:!ye.length,className:Fd,children:[t.jsx(cl,{className:"text-[10px]"}),"Excel"]}),t.jsxs("button",{type:"button",onClick:ie,disabled:!ye.length,className:Fd,children:[t.jsx(sl,{className:"text-[10px]"}),C("listPages.print",{defaultValue:"Print"})]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-2",children:[t.jsx(af,{label:C("dashboard.totalWorkOrders",{defaultValue:"Total"}),value:Oe.total}),t.jsx(af,{label:C("dashboard.completedWorkOrders",{defaultValue:"Completed"}),value:Oe.completed,color:"text-green-600"}),t.jsx(af,{label:C("dashboard.workOrdersInProgress",{defaultValue:"In Progress"}),value:Oe.in_progress,color:"text-blue-600"}),t.jsx(af,{label:C("dashboard.openWorkOrders",{defaultValue:"Open"}),value:Oe.open,color:"text-amber-600"})]}),oe&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 text-red-700 px-4 py-3 text-sm",children:oe}),t.jsx("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/60",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left font-semibold text-gray-700 dark:text-gray-200",children:C("commonFields.assignedContractor",{defaultValue:"Assigned Contractor"})}),t.jsx("th",{className:"px-4 py-3 text-right font-semibold text-gray-700 dark:text-gray-200",children:"Total"}),t.jsx("th",{className:"px-4 py-3 text-right font-semibold text-green-700 dark:text-green-400",children:"Completed"}),t.jsx("th",{className:"px-4 py-3 text-right font-semibold text-blue-700 dark:text-blue-400",children:"In Progress"}),t.jsx("th",{className:"px-4 py-3 text-right font-semibold text-amber-700 dark:text-amber-400",children:"Open"})]})}),t.jsx("tbody",{children:Q?t.jsx("tr",{children:t.jsx("td",{colSpan:5,className:"px-4 py-10 text-center text-gray-500",children:C("common.loading",{defaultValue:"Loading..."})})}):H.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:5,className:"px-4 py-10 text-center text-gray-500",children:C("common.noData",{defaultValue:"No data"})})}):H.map((re,ne)=>t.jsxs("tr",{className:"border-t border-gray-100 dark:border-gray-700",children:[t.jsx("td",{className:"px-4 py-3 text-gray-800 dark:text-gray-100",children:hf(re)}),t.jsx("td",{className:"px-4 py-3 text-right font-medium",children:Number(re.total)||0}),t.jsx("td",{className:"px-4 py-3 text-right text-green-700 dark:text-green-400",children:Number(re.completed)||0}),t.jsx("td",{className:"px-4 py-3 text-right text-blue-700 dark:text-blue-400",children:Number(re.in_progress)||0}),t.jsx("td",{className:"px-4 py-3 text-right text-amber-700 dark:text-amber-400",children:Number(re.open)||0})]},`${hf(re)}-${ne}`))})]})})})]})]})}):null},af=({label:e,value:r,color:a="text-gray-900 dark:text-white"})=>t.jsxs("div",{className:`${Cp} border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800`,children:[t.jsx("div",{className:Ep,children:e}),t.jsx("div",{className:`${jp} mt-0.5 ${a}`,children:r})]}),zR="Technicians working Hours",J0=e=>(e.technician_name||e.engineer||"Unknown").trim()||"Unknown",Q0=e=>{if(e==null||e==="")return 0;const r=Number(e);return Number.isFinite(r)&&r>=0?r:0},HR=e=>{const r=e.filter(c=>c&&!c.is_total_row);if(!r.length)return null;const a=r.map(J0),n=r.map(c=>Q0(c.total_hours)),i=n.reduce((c,u)=>c+u,0);return{labels:a,datasets:[{name:"Total Hours",values:n,colors:["#6366F1"]}],totalHours:i,rows:r}},w3=e=>xe(null,null,function*(){var g,y,x;const r=typeof window!="undefined"&&window.csrf_token&&window.csrf_token!=="None"?window.csrf_token:null,a={"Content-Type":"application/json",Accept:"application/json"};r&&(a["X-Frappe-CSRF-Token"]=r);const n={};Object.entries(e).forEach(([k,N])=>{N&&(n[k]=N)});const i=yield fetch("/api/method/frappe.desk.query_report.run",{method:"POST",headers:a,credentials:"include",body:JSON.stringify({report_name:zR,filters:n,ignore_prepared_report:1})}),c=yield i.json();if(!i.ok)throw new Error((c==null?void 0:c.message)||(c==null?void 0:c.exc)||"Failed to load technician working hours");const u=((g=c==null?void 0:c.message)==null?void 0:g.result)||((x=(y=c==null?void 0:c.message)==null?void 0:y.message)==null?void 0:x.result)||[];return Array.isArray(u)?u.filter(k=>k&&!k.is_total_row):[]}),VR=e=>xe(null,null,function*(){const r=yield w3(e);return HR(r)}),WR=({isOpen:e,onClose:r,permittedIssueTypes:a=[],isAdmin:n=!1,defaultWorkOrderType:i="",defaultFromDate:c="",defaultToDate:u="",defaultCompany:g="",defaultSiteName:y="",companyLocked:x=!1,siteLocked:k=!1,hospitalLinkFilters:N})=>{const{t:C}=oa(),[O,D]=E.useState(c),[A,I]=E.useState(u),[z,U]=E.useState(i),[B,V]=E.useState(g),[Z,W]=E.useState(y),[H,le]=E.useState([]),[Q,Ne]=E.useState(!1),[oe,se]=E.useState(null),[ce,Ce]=E.useState(!0),ae=!n&&a.length===1?a[0]:"",me=!!ae,K=nn(B),fe=E.useMemo(()=>hl(B,k?Z:void 0),[B,Z,k]);E.useEffect(()=>{e&&(D(c),I(u),U(ae||i),V(g),W(y),Ce(!0))},[e,c,u,i,g,y,ae]),E.useEffect(()=>{if(!e)return;const Ae=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=Ae}},[e]),E.useEffect(()=>{if(!e)return;const Ae=ze=>{ze.key==="Escape"&&r()};return window.addEventListener("keydown",Ae),()=>window.removeEventListener("keydown",Ae)},[e,r]);const Oe=E.useMemo(()=>{let Ae=0;return O&&(Ae+=1),A&&(Ae+=1),z&&(Ae+=1),B&&(Ae+=1),Z&&K&&(Ae+=1),Ae},[O,A,z,B,Z,K]),ye=E.useCallback(()=>{const Ae={};return O&&(Ae.from_date=O),A&&(Ae.to_date=A),z&&(Ae.work_order_type=z),B&&(Ae.company=B),Z&&K&&(Ae.site_name=Z),Ae},[O,A,z,B,Z,K]),J=E.useCallback(()=>xe(null,null,function*(){Ne(!0),se(null);try{const Ae=yield w3(ye());le(Ae)}catch(Ae){le([]),se(Ae instanceof Error?Ae.message:"Failed to load report")}finally{Ne(!1)}}),[ye]);E.useEffect(()=>{e&&J()},[e,J]);const G=E.useMemo(()=>{const Ae=H.length,ze=H.reduce((Ze,Lt)=>Ze+Q0(Lt.total_hours),0),Re=Ae>0?ze/Ae:0;return{totalTechnicians:Ae,totalHours:Math.round(ze*100)/100,avgHours:Math.round(Re*100)/100}},[H]),ie=E.useMemo(()=>H.map(Ae=>({Engineer:Ae.engineer||"","Technician Name":J0(Ae),"Total Hours":Q0(Ae.total_hours)})),[H]),re=()=>{D(c),I(u),U(ae||i),V(g),W(y)},ne=()=>{if(!ie.length)return;const Ae=Object.keys(ie[0]),ze=[Ae.join(","),...ie.map(mt=>Ae.map(Zt=>`"${String(mt[Zt]).replace(/"/g,'""')}"`).join(","))].join(`
|
||
`),Re=new Blob([ze],{type:"text/csv;charset=utf-8;"}),Ze=URL.createObjectURL(Re),Lt=document.createElement("a");Lt.href=Ze,Lt.download="technicians-working-hours.csv",Lt.click(),URL.revokeObjectURL(Ze)},ve=()=>{if(!ie.length)return;const Ae=Wa.json_to_sheet(ie),ze=Wa.book_new();Wa.book_append_sheet(ze,Ae,"Technicians"),ul(ze,"technicians-working-hours.xlsx")},Ve=()=>{if(!ie.length)return;const Ae=H.map((Re,Ze)=>`
|
||
<tr>
|
||
<td>${Ze+1}</td>
|
||
<td>${J0(Re)}</td>
|
||
<td>${Re.engineer||""}</td>
|
||
<td class="hours">${Q0(Re.total_hours)} hrs</td>
|
||
</tr>
|
||
`).join(""),ze=window.open("","_blank");ze&&(ze.document.write(`
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>Technicians Working Hours</title>
|
||
<style>
|
||
body { font-family: Arial, sans-serif; padding: 24px; color: #111827; }
|
||
h1 { color: #0891B2; margin-bottom: 8px; }
|
||
p { color: #6B7280; margin-top: 0; }
|
||
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
|
||
th { background: #0891B2; color: white; text-align: left; padding: 10px 12px; }
|
||
td { border-bottom: 1px solid #E5E7EB; padding: 10px 12px; }
|
||
.hours { color: #0891B2; font-weight: 700; }
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<h1>Technicians Working Hours</h1>
|
||
<p>${H.length} technicians • ${G.totalHours} total hours</p>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>#</th>
|
||
<th>Technician Name</th>
|
||
<th>Engineer</th>
|
||
<th>Total Hours</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>${Ae}</tbody>
|
||
</table>
|
||
</body>
|
||
</html>
|
||
`),ze.document.close(),ze.focus(),ze.print())};return e?t.jsx("div",{className:"fixed inset-0 z-[80] bg-black/50 backdrop-blur-sm",children:t.jsxs("div",{className:"fixed inset-0 bg-white dark:bg-gray-900 flex flex-col",children:[t.jsx("div",{className:"bg-gradient-to-r from-cyan-600 to-blue-600 text-white px-4 sm:px-5 py-3",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("button",{type:"button",onClick:r,className:"p-1.5 rounded-lg hover:bg-white/10","aria-label":"Back",children:t.jsx(bi,{className:"text-sm"})}),t.jsx("div",{className:"w-8 h-8 rounded-full bg-white/15 flex items-center justify-center shrink-0",children:t.jsx($s,{className:"text-sm"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-base sm:text-lg font-semibold truncate",children:C("dashboard.technicianWorkingHours",{defaultValue:"Technicians Working Hours"})}),t.jsx("p",{className:"text-xs sm:text-sm text-cyan-100",children:C("dashboard.technicianHoursFound",{count:G.totalTechnicians,defaultValue:`${G.totalTechnicians} technicians found`})})]})]}),t.jsx("button",{type:"button",onClick:r,className:"p-2 rounded-lg hover:bg-white/10","aria-label":"Close",children:t.jsx(qt,{})})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-3 sm:p-4 space-y-3",children:[!Q&&H.length>0&&t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[t.jsx(Dx,{icon:t.jsx(Pd,{className:"text-blue-500"}),label:C("dashboard.totalTechnicians",{defaultValue:"Total Technicians"}),value:String(G.totalTechnicians),theme:"blue"}),t.jsx(Dx,{icon:t.jsx($s,{className:"text-cyan-500"}),label:C("dashboard.totalHoursWorked",{defaultValue:"Total Hours Worked"}),value:`${G.totalHours} hrs`,theme:"cyan"}),t.jsx(Dx,{icon:t.jsx(tv,{className:"text-purple-500"}),label:C("dashboard.avgHoursPerTechnician",{defaultValue:"Average Hours/Technician"}),value:`${G.avgHours} hrs`,theme:"purple"})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("button",{type:"button",onClick:()=>Ce(Ae=>!Ae),className:"inline-flex items-center gap-1.5 text-xs font-medium text-gray-700 dark:text-gray-200",children:[t.jsx(Ri,{className:"text-cyan-600 text-xs"}),C("dashboard.filters",{defaultValue:"Filters"}),Oe>0&&t.jsx("span",{className:"inline-flex items-center justify-center min-w-[1rem] h-4 px-1 rounded-full bg-cyan-100 text-cyan-700 text-[10px] font-semibold",children:Oe})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:J,disabled:Q,className:em("cyan"),children:[t.jsx(Eo,{className:`text-[10px] ${Q?"animate-spin":""}`}),C("dashboard.refreshReport",{defaultValue:"Refresh"})]}),t.jsxs("button",{type:"button",onClick:ne,disabled:!ie.length,className:Fd,children:[t.jsx(Co,{className:"text-[10px]"}),"CSV"]}),t.jsxs("button",{type:"button",onClick:ve,disabled:!ie.length,className:Fd,children:[t.jsx(cl,{className:"text-[10px]"}),"Excel"]}),t.jsxs("button",{type:"button",onClick:Ve,disabled:!ie.length,className:Fd,children:[t.jsx(sl,{className:"text-[10px]"}),"PDF/Print"]})]})]}),ce&&t.jsxs("div",{className:"p-3 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-5 gap-2",children:[t.jsxs("div",{className:No,children:[t.jsx("label",{className:wo,children:C("dashboard.fromDate",{defaultValue:"From Date"})}),t.jsx("input",{type:"date",value:O,onChange:Ae=>D(Ae.target.value),className:ko})]}),t.jsxs("div",{className:No,children:[t.jsx("label",{className:wo,children:C("dashboard.toDate",{defaultValue:"To Date"})}),t.jsx("input",{type:"date",value:A,onChange:Ae=>I(Ae.target.value),className:ko})]}),t.jsx(er,{label:C("dashboard.technicalDepartment",{defaultValue:"Technical Department"}),doctype:"Issue Type",value:z,onChange:U,placeholder:C("dashboard.allDepartments",{defaultValue:"All Departments"}),disabled:me,compact:!0}),t.jsx(er,{label:C("commonFields.hospital",{defaultValue:"Hospital"}),doctype:"Company",value:B,onChange:Ae=>{V(Ae),nn(Ae)||W("")},placeholder:C("dashboard.allHospitals",{defaultValue:"All Hospitals"}),disabled:x,compact:!0,filters:N}),K&&t.jsx(er,{label:C("commonFields.siteName",{defaultValue:"PHCC Site"}),doctype:"Mobile Team Site",value:Z,onChange:W,placeholder:C("dashboard.allSites",{defaultValue:"All Sites"}),disabled:k,compact:!0,filters:fe})]}),t.jsx("div",{className:"mt-2",children:t.jsx("button",{type:"button",onClick:re,className:"text-[11px] text-cyan-700 dark:text-cyan-300 hover:underline",children:C("dashboard.clearFilters",{defaultValue:"Clear Filters"})})})]})]}),oe&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 text-red-700 px-4 py-3 text-sm",children:oe}),t.jsx("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-full text-sm",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/60 sticky top-0 z-10",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left font-semibold text-gray-700 dark:text-gray-200 w-12",children:"#"}),t.jsx("th",{className:"px-4 py-3 text-left font-semibold text-gray-700 dark:text-gray-200",children:C("dashboard.technicianName",{defaultValue:"Technician Name"})}),t.jsx("th",{className:"px-4 py-3 text-left font-semibold text-gray-700 dark:text-gray-200",children:C("dashboard.engineer",{defaultValue:"Engineer"})}),t.jsx("th",{className:"px-4 py-3 text-right font-semibold text-gray-700 dark:text-gray-200",children:C("dashboard.totalHoursSpent",{defaultValue:"Total Hours Spent"})})]})}),t.jsx("tbody",{children:Q?t.jsx("tr",{children:t.jsx("td",{colSpan:4,className:"px-4 py-10 text-center text-gray-500",children:C("dashboard.loadingTechnicianHours",{defaultValue:"Loading technician hours…"})})}):H.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:4,className:"px-4 py-10 text-center text-gray-500",children:C("common.noData",{defaultValue:"No data"})})}):H.map((Ae,ze)=>t.jsxs("tr",{className:"border-t border-gray-100 dark:border-gray-700",children:[t.jsx("td",{className:"px-4 py-3 text-gray-500",children:ze+1}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-cyan-50 dark:bg-cyan-900/20 flex items-center justify-center shrink-0",children:t.jsx(tv,{className:"text-cyan-600 dark:text-cyan-300 text-sm"})}),t.jsx("span",{className:"truncate text-gray-800 dark:text-gray-100",children:J0(Ae)})]})}),t.jsx("td",{className:"px-4 py-3",children:Ae.engineer?t.jsx("a",{href:`/app/user/${encodeURIComponent(Ae.engineer)}`,target:"_blank",rel:"noopener noreferrer",className:"text-cyan-700 dark:text-cyan-300 hover:underline truncate inline-block max-w-[220px]",children:Ae.engineer}):t.jsx("span",{className:"text-gray-400",children:"—"})}),t.jsx("td",{className:"px-4 py-3 text-right",children:t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-cyan-50 dark:bg-cyan-900/20 px-3 py-1 text-cyan-700 dark:text-cyan-300 font-semibold",children:[t.jsx($s,{className:"text-xs"}),Q0(Ae.total_hours)," hrs"]})})]},`${Ae.engineer||J0(Ae)}-${ze}`))})]})})})]}),t.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 px-3 sm:px-4 py-2 flex flex-wrap items-center justify-between gap-2",children:[t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300",children:C("dashboard.technicianHoursFooter",{count:H.length,total:G.totalHours,defaultValue:`Showing ${H.length} technicians (filtered) • ${G.totalHours} total hours`})}),t.jsx("button",{type:"button",onClick:r,className:"px-3 py-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-xs hover:bg-gray-50 dark:hover:bg-gray-800",children:C("common.close",{defaultValue:"Close"})})]})]})}):null},Dx=({icon:e,label:r,value:a,theme:n})=>{const i={blue:"bg-blue-50 dark:bg-blue-900/20 border-blue-100 dark:border-blue-800",cyan:"bg-cyan-50 dark:bg-cyan-900/20 border-cyan-100 dark:border-cyan-800",purple:"bg-purple-50 dark:bg-purple-900/20 border-purple-100 dark:border-purple-800"}[n];return t.jsxs("div",{className:`${Cp} ${i}`,children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e,t.jsx("div",{className:Ep,children:r})]}),t.jsx("div",{className:jp,children:a})]})};function k3(e){return e==null||e===""?"":String(e)}function GR(e,r,a){const n=[r.map(u=>u.label||u.fieldname),...e.map(u=>r.map(g=>k3(u[g.fieldname])))],i=Wa.aoa_to_sheet(n),c=Wa.book_new();Wa.book_append_sheet(c,i,"Export"),ul(c,a)}function $R(e,r,a){const n=window.open("","_blank");if(!n){window.alert("Please allow popups for this site to export PDF.");return}const i=`
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>${a}</title>
|
||
<style>
|
||
body { font-family: Arial, sans-serif; margin: 20px; }
|
||
h1 { text-align: center; color: #333; margin-bottom: 8px; font-size: 18px; }
|
||
.meta { text-align: center; color: #666; margin-bottom: 20px; font-size: 11px; }
|
||
table { width: 100%; border-collapse: collapse; font-size: 10px; }
|
||
th, td { border: 1px solid #ccc; padding: 6px 8px; text-align: left; vertical-align: top; }
|
||
th { background: #047857; color: white; }
|
||
tr:nth-child(even) { background: #f9fafb; }
|
||
@media print { body { margin: 0; } }
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<h1>${a}</h1>
|
||
<div class="meta">
|
||
Generated on: ${new Date().toLocaleString()} | Total Records: ${e.length}
|
||
</div>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
${r.map(c=>`<th>${c.label||c.fieldname}</th>`).join("")}
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
${e.map(c=>`
|
||
<tr>
|
||
${r.map(u=>`<td>${k3(c[u.fieldname])||"—"}</td>`).join("")}
|
||
</tr>
|
||
`).join("")}
|
||
</tbody>
|
||
</table>
|
||
<script>window.onload = function() { window.print(); }<\/script>
|
||
</body>
|
||
</html>
|
||
`;n.document.write(i),n.document.close()}const XR=({isOpen:e,onClose:r,title:a="Export Report",columns:n,rows:i,fileNamePrefix:c="report"})=>{const[u,g]=E.useState("excel"),[y,x]=E.useState(new Set),[k,N]=E.useState(!1),C=E.useMemo(()=>n.filter(B=>B.fieldname),[n]);if(E.useEffect(()=>{e&&(g("excel"),x(new Set(C.map(B=>B.fieldname))))},[e,C]),!e)return null;const O=C.filter(B=>y.has(B.fieldname)),D=i.length>0&&O.length>0,A=B=>{x(V=>{const Z=new Set(V);return Z.has(B)?Z.delete(B):Z.add(B),Z})},I=()=>x(new Set(C.map(B=>B.fieldname))),z=()=>x(new Set),U=()=>xe(null,null,function*(){if(D){N(!0);try{const B=new Date().toISOString().split("T")[0];u==="excel"?GR(i,O,`${c}_${B}.xlsx`):$R(i,O,a),r()}catch(B){console.error("Export failed:",B),window.alert(`Export failed: ${B instanceof Error?B.message:"Unknown error"}`)}finally{N(!1)}}});return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[80] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-lg max-h-[90vh] flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"bg-gradient-to-r from-emerald-600 to-teal-600 px-5 py-4 flex items-center justify-between shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(cs,{className:"text-white"}),t.jsx("h3",{className:"text-base font-semibold text-white",children:a})]}),t.jsx("button",{type:"button",onClick:r,disabled:k,className:"text-white/80 hover:text-white p-1 rounded-lg hover:bg-white/20",children:t.jsx(qt,{})})]}),t.jsxs("div",{className:"p-5 space-y-5 overflow-y-auto flex-1",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2",children:"File format"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("label",{className:`flex-1 flex items-center gap-2 p-3 rounded-lg border cursor-pointer ${u==="excel"?"border-emerald-500 bg-emerald-50 dark:bg-emerald-900/20":"border-gray-200 dark:border-gray-700"}`,children:[t.jsx("input",{type:"radio",name:"wo_feedback_export_format",checked:u==="excel",onChange:()=>g("excel"),className:"text-emerald-600"}),t.jsx(cl,{className:"text-green-700"}),t.jsx("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:"Excel (.xlsx)"})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-2 p-3 rounded-lg border cursor-pointer ${u==="pdf"?"border-emerald-500 bg-emerald-50 dark:bg-emerald-900/20":"border-gray-200 dark:border-gray-700"}`,children:[t.jsx("input",{type:"radio",name:"wo_feedback_export_format",checked:u==="pdf",onChange:()=>g("pdf"),className:"text-emerald-600"}),t.jsx(oC,{className:"text-red-600"}),t.jsx("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:"PDF"})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Columns to export"}),t.jsxs("div",{className:"flex gap-3 text-xs text-emerald-600 dark:text-emerald-400",children:[t.jsx("button",{type:"button",onClick:I,className:"hover:underline",children:"All"}),t.jsx("button",{type:"button",onClick:z,className:"hover:underline",children:"None"})]})]}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 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:C.map(B=>{const V=y.has(B.fieldname);return t.jsxs("button",{type:"button",onClick:()=>A(B.fieldname),className:`flex items-center gap-2 px-2 py-1.5 rounded text-left text-xs transition-colors ${V?"bg-emerald-100 dark:bg-emerald-900/30 text-emerald-800 dark:text-emerald-200":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-600 dark:text-gray-400"}`,children:[V?t.jsx(qs,{size:13,className:"text-emerald-600 shrink-0"}):t.jsx(Pn,{size:13,className:"text-gray-300 shrink-0"}),t.jsx("span",{className:"truncate",title:B.label||B.fieldname,children:B.label||B.fieldname})]},B.fieldname)})}),t.jsxs("p",{className:"text-xs text-gray-400 mt-1.5",children:[y.size," of ",C.length," columns selected · ",i.length," row",i.length!==1?"s":""]})]})]}),t.jsxs("div",{className:"px-5 py-4 border-t border-gray-200 dark:border-gray-700 flex justify-end gap-3 shrink-0",children:[t.jsx("button",{type:"button",onClick:r,disabled:k,className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg",children:"Cancel"}),t.jsx("button",{type:"button",onClick:U,disabled:!D||k,className:"px-4 py-2 text-sm font-medium text-white bg-emerald-600 hover:bg-emerald-700 rounded-lg flex items-center gap-2 disabled:opacity-50",children:k?t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"animate-spin",size:14})," Exporting…"]}):t.jsxs(t.Fragment,{children:[t.jsx(Co,{size:14})," Export"]})})]})]})})};function kd(e){if(!e||typeof e!="string")return"";let r=e.replace(/<br\s*\/?>/gi,`
|
||
`).replace(/<\/(p|div|li|tr)>/gi,`
|
||
`).replace(/<a[^>]*>([\s\S]*?)<\/a>/gi,(a,n)=>n.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim()).replace(/<[^>]+>/g," ");return r=r.replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,'"'),r.replace(/[ \t]+\n/g,`
|
||
`).replace(/\n{3,}/g,`
|
||
|
||
`).replace(/ +/g," ").trim()}function qp(e){if(e==null)return"Something went wrong";if(e instanceof Error)return kd(e.message)||e.message;if(typeof e=="string")return kd(e);const r=e;let a=typeof r.message=="string"?r.message:"";if(r._server_messages)try{const n=r._server_messages,i=typeof n=="string"?JSON.parse(n):n;if(Array.isArray(i)){const c=[];for(const u of i)try{const g=typeof u=="string"?JSON.parse(u):u;g&&typeof g.message=="string"?c.push(kd(g.message)):typeof u=="string"&&c.push(kd(u))}catch(g){typeof u=="string"&&c.push(kd(u))}c.length&&(a=c.join(`
|
||
`))}}catch(n){}return!a&&typeof r.exc=="string"&&r.exc.length<800&&(a=r.exc),a?kd(a):"Request failed. Check stock, warehouses, and linked documents."}function N3(a){return xe(this,arguments,function*(e,r={}){const n=(yield _t.getCSRFToken())||(yield _t.getCSRFTokenForGuest()),i={Accept:"application/json","Content-Type":"application/json"};n&&(i["X-Frappe-CSRF-Token"]=n);const c=yield fetch(`${Lr.BASE_URL}/api/method/${e}`,{method:"POST",credentials:"include",headers:i,body:JSON.stringify(r)}),u=yield c.json().catch(()=>({}));if(!c.ok||u.exc)throw new Error(qp(u)||(u==null?void 0:u.message)||`HTTP ${c.status}`);return u.message})}function S3(e){const r={};return Object.entries(e).forEach(([a,n])=>{n&&(r[a]=n)}),r}function YR(){return xe(this,arguments,function*(e={}){return N3("asset_lite.api.wo_feedback_api.run_wo_feedback_report",{filters:S3(e)})})}function C3(){return xe(this,arguments,function*(e={}){return N3("asset_lite.api.wo_feedback_api.get_wo_feedback_summary",{filters:S3(e)})})}const ZR={runWoFeedbackReport:YR,fetchWoFeedbackSummary:C3},ap=["Excellent / ممتاز","Good / جيد","Average / متوسط","Poor / ضعيف"];function E3(e){const r=e.toLowerCase();return r.includes("excellent")||r.includes("ممتاز")?0:r.includes("good")||r.includes("جيد")?1:r.includes("average")||r.includes("متوسط")?2:r.includes("poor")||r.includes("ضعيف")?3:-1}function np(e){const r=E3(e);return r===0?"#10B981":r===1?"#3B82F6":r===2?"#F59E0B":r===3?"#EF4444":"#6B7280"}function qR(e){var u,g,y;const r=(e==null?void 0:e.labels)||[],a=((g=(u=e==null?void 0:e.datasets)==null?void 0:u[0])==null?void 0:g.values)||[],n=new Map;r.forEach((x,k)=>{const N=E3(x);if(N<0)return;const C=Number(a[k])||0,O=n.get(N);O?O.value+=C:n.set(N,{label:x,value:C})});const i=ap.map((x,k)=>{var N,C;return(C=(N=n.get(k))==null?void 0:N.label)!=null?C:x}),c=ap.map((x,k)=>{var N,C;return(C=(N=n.get(k))==null?void 0:N.value)!=null?C:0});return $e(_e({},e||{}),{labels:i,datasets:[$e(_e({},((y=e==null?void 0:e.datasets)==null?void 0:y[0])||{name:"Work Orders"}),{values:c})]})}function KR(e){var n,i,c;const r=qR(e),a=r.labels.map(u=>np(u));return $e(_e({},r),{type:"Pie",datasets:[$e(_e({},((n=r.datasets)==null?void 0:n[0])||{name:"Work Orders",values:[]}),{colors:a,values:((c=(i=r.datasets)==null?void 0:i[0])==null?void 0:c.values)||[]})]})}const Xv={work_order:"",requester_name:"",rating:"",company:"",site_name:""},Yv="block font-medium text-gray-700 dark:text-gray-300 text-[10px] mb-0.5",Zv="w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-emerald-500 disabled:bg-gray-100 dark:disabled:bg-gray-700",JR=({isOpen:e,onClose:r,defaultCompany:a="",defaultSiteName:n="",companyLocked:i=!1,siteLocked:c=!1,hospitalLinkFilters:u})=>{const{t:g}=oa(),[y,x]=E.useState(null),[k,N]=E.useState(!1),[C,O]=E.useState(!1),[D,A]=E.useState(""),[I,z]=E.useState(""),[U,B]=E.useState(""),[V,Z]=E.useState(a),[W,H]=E.useState(n),[le,Q]=E.useState(Xv),[Ne,oe]=E.useState(!1),se=E.useRef(!1),ce=E.useRef(null),Ce=nn(V),ae=E.useMemo(()=>hl(V,c?W:void 0),[V,W,c]);E.useEffect(()=>{e||(A(""),z(""),B(""),Z(a),H(n),Q(Xv),x(null),N(!1),O(!1),se.current=!1,oe(!1),ce.current&&clearTimeout(ce.current))},[e,a,n]),E.useEffect(()=>{e&&(Z(a),H(n))},[e,a,n]),E.useEffect(()=>{if(e)return ce.current&&clearTimeout(ce.current),ce.current=setTimeout(()=>{Q({work_order:D.trim(),requester_name:I.trim(),rating:U,company:V.trim(),site_name:Ce?W.trim():""})},450),()=>{ce.current&&clearTimeout(ce.current)}},[e,D,I,U,V,W,Ce]);const me=E.useCallback(G=>xe(null,null,function*(){const ie=se.current;ie?O(!0):N(!0);try{const re=yield ZR.runWoFeedbackReport(G);x(re||null),se.current=!0}catch(re){console.error("WO feedback report error:",re),ie||x(null)}finally{N(!1),O(!1)}}),[]);if(E.useEffect(()=>{e&&me(le)},[e,le,me]),!e)return null;const K=(y==null?void 0:y.columns)||[],fe=((y==null?void 0:y.result)||[]).filter(G=>G&&typeof G=="object"&&!G.is_total_row),Oe=!!(D.trim()||I.trim()||U||V.trim()||Ce&&W.trim()),ye=k&&!se.current,J=!ye&&fe.length===0;return t.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:[t.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:[t.jsxs("div",{className:"bg-gradient-to-r from-emerald-600 to-teal-600 px-6 py-4 flex items-center justify-between shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Zl,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:g("dashboard.woFeedbackReport",{defaultValue:"WO Feedback Report"})})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>oe(!0),disabled:ye||fe.length===0,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-emerald-700 bg-white hover:bg-emerald-50 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[t.jsx(cs,{size:12})," Export"]}),t.jsx("button",{type:"button",onClick:r,className:"text-white/80 hover:text-white p-1 rounded-lg hover:bg-white/20 transition-colors",children:t.jsx(qt,{className:"w-5 h-5"})})]})]}),t.jsxs("div",{className:"px-6 py-3 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/30 shrink-0",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-5 gap-3",children:[t.jsx(er,{label:g("commonFields.hospital",{defaultValue:"Hospital"}),doctype:"Company",value:V,onChange:G=>{Z(G),nn(G)||H("")},placeholder:g("dashboard.allHospitals",{defaultValue:"All Hospitals"}),disabled:i,compact:!0,filters:u}),Ce&&t.jsx(er,{label:g("commonFields.siteName",{defaultValue:"PHCC Site"}),doctype:"Mobile Team Site",value:W,onChange:H,placeholder:g("dashboard.allSites",{defaultValue:"All Sites"}),disabled:c,compact:!0,filters:ae}),t.jsx(er,{label:g("commonFields.workOrder",{defaultValue:"Work Order"}),doctype:"Work_Order",value:D,onChange:A,placeholder:"Filter by work order…",compact:!0}),t.jsxs("div",{className:"relative w-full mb-2",children:[t.jsx("label",{className:Yv,children:"Requester Name"}),t.jsx("input",{type:"text",value:I,onChange:G=>z(G.target.value),placeholder:"Filter by requester…",className:Zv})]}),t.jsxs("div",{className:"relative w-full mb-2",children:[t.jsx("label",{className:Yv,children:"Rating"}),t.jsxs("select",{value:U,onChange:G=>B(G.target.value),className:Zv,children:[t.jsx("option",{value:"",children:"All ratings"}),ap.map(G=>t.jsx("option",{value:G,children:G},G))]})]})]}),Oe&&t.jsxs("button",{type:"button",onClick:()=>{A(""),z(""),B(""),Z(a),H(n)},className:"mt-3 text-xs text-red-500 hover:text-red-700 flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:[t.jsx(qt,{size:10})," ",g("dashboard.clearFilters",{defaultValue:"Clear filters"})]})]}),t.jsx("div",{className:"p-6 overflow-auto flex-1 relative min-h-[240px]",children:ye?t.jsx("div",{className:"flex items-center justify-center py-16",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-emerald-600"})}):J?t.jsx("div",{className:"text-center text-gray-400 py-16",children:"No feedback records found"}):t.jsxs("div",{className:`overflow-x-auto transition-opacity duration-200 ${C?"opacity-60":"opacity-100"}`,children:[C&&t.jsx("div",{className:"absolute top-6 right-6 z-10",children:t.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-2 border-emerald-600 border-t-transparent"})}),t.jsxs("table",{className:"w-full text-sm border-collapse",children:[t.jsx("thead",{children:t.jsx("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:K.map((G,ie)=>t.jsx("th",{className:"py-3 px-4 font-semibold text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-900/50 text-left",children:G.label||G.fieldname},ie))})}),t.jsx("tbody",{children:fe.map((G,ie)=>t.jsx("tr",{className:"border-b border-gray-100 dark:border-gray-700/50 hover:bg-emerald-50/40 dark:hover:bg-emerald-900/10 transition-colors",children:K.map((re,ne)=>{var Ze;const Ve=(re.fieldname||"").toLowerCase()==="work_order",Ae=(Ze=G[re.fieldname])!=null?Ze:"—",ze=Ve?String(Ae):"",Re=Ve&&ze&&ze!=="—";return t.jsx("td",{className:`py-2.5 px-4 align-top ${Re?"cursor-pointer text-emerald-600 dark:text-emerald-400 font-semibold hover:underline":"text-gray-800 dark:text-gray-200"}`,onClick:Re?()=>{window.location.href=`/asm_app/work-orders/${encodeURIComponent(ze)}`}:void 0,title:Re?`Open Work Order ${ze}`:void 0,children:Re?t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[Ae,t.jsx(qd,{size:9,className:"opacity-50 shrink-0"})]}):Ae},ne)})},ie))})]})]})})]}),t.jsx(XR,{isOpen:Ne,onClose:()=>oe(!1),title:g("dashboard.woFeedbackReport",{defaultValue:"WO Feedback Report"}),columns:K,rows:fe,fileNamePrefix:"wo_feedback_report"})]})};let QR=null,eM=null,X0=null;function tM(){return xe(this,null,function*(){try{const[e,r]=yield Promise.all([_t.getAllowedValues("Company"),_t.getAllowedValues("Hospital")]);if(e.is_admin||r.is_admin)return[];const a=new Set;return e.has_restriction&&e.allowed_values.forEach(n=>a.add(n)),r.has_restriction&&r.allowed_values.forEach(n=>a.add(n)),Array.from(a).sort()}catch(e){return console.error("[userHospital] Failed to load allowed hospitals:",e),[]}})}function rM(e,r,a){return r.length===1?r[0]:e&&(!r.length||r.includes(e))?e:a&&r.includes(a)?a:""}function aM(e,r){return e.length===1?!0:e.length>1?!1:!!r}function Kp(){try{const e=localStorage.getItem("user");return e&&JSON.parse(e).custom_site_name||""}catch(e){return""}}function _u(){try{const e=localStorage.getItem("user");return e&&JSON.parse(e).custom_phcc_site_name||""}catch(e){return""}}function nM(e,r){try{const a=localStorage.getItem("user");if(!a)return;const n=JSON.parse(a);localStorage.setItem("user",JSON.stringify(_e($e(_e({},n),{custom_site_name:e}),r!==void 0?{custom_phcc_site_name:r}:{})))}catch(a){console.warn("[userHospital] Failed to persist hospital to localStorage:",a)}}function sM(){return xe(this,null,function*(){return(yield cm()).hospital})}function cm(){return xe(this,null,function*(){return X0||(X0=xe(null,null,function*(){try{const[e,r,a]=yield Promise.all([Kf().catch(()=>null),tM(),_t.getAllowedValues("Company").catch(()=>null)]);let n=(e==null?void 0:e.custom_site_name)||"",i=(e==null?void 0:e.custom_phcc_site_name)||"";if(!n){const g=yield _t.getUserDetails();n=g.custom_site_name||"",i=i||g.custom_phcc_site_name||""}const c=rM(n,r,a==null?void 0:a.default_value),u=aM(r,n);return c&&(QR=c,eM=i,nM(c,i)),{hospital:c,siteName:i,isLocked:u,allowedHospitals:r}}catch(e){return console.error("[userHospital] Failed to load user location filters:",e),{hospital:Kp(),siteName:_u(),isLocked:!1,allowedHospitals:[]}}finally{X0=null}}),X0)})}function j3(){const[e,r]=E.useState(()=>Kp()),[a,n]=E.useState(()=>_u()),[i,c]=E.useState(!1),[u,g]=E.useState(()=>!!_u()),[y,x]=E.useState([]),[k,N]=E.useState(!0);E.useEffect(()=>{let A=!1;return cm().then(({hospital:I,siteName:z,isLocked:U,allowedHospitals:B})=>{A||(x(B),c(U),I&&r(I),z&&(n(z),g(!0)))}).finally(()=>{A||N(!1)}),()=>{A=!0}},[]);const C=E.useCallback(A=>{i||(r(A),nn(A)||n(""))},[i]),O=E.useCallback(A=>{u||n(A)},[u]),D=E.useMemo(()=>_3(y),[y]);return{filterHospital:e,filterSiteName:a,hospitalLocked:i,siteLocked:u,allowedHospitals:y,hospitalLinkFilters:D,filtersLocked:i,loading:k,handleHospitalChange:C,handleSiteChange:O,setFilterSiteName:O}}const dm=(e="Asset")=>{const[r,a]=E.useState({isAdmin:!1,restrictions:{},permissionFilters:{},targetDoctype:e,loading:!0,error:null}),n=E.useCallback(x=>xe(null,null,function*(){const k=x||e;try{a(C=>$e(_e({},C),{loading:!0,error:null,targetDoctype:k}));const N=yield _t.getPermissionFilters(k);return a({isAdmin:N.is_admin,restrictions:N.restrictions||{},permissionFilters:N.filters||{},targetDoctype:k,loading:!1,error:null}),N}catch(N){return console.error(`Error fetching permissions for ${k}:`,N),a(C=>$e(_e({},C),{loading:!1,error:N instanceof Error?N.message:"Failed to fetch permissions"})),null}}),[e]);E.useEffect(()=>{n()},[n]);const i=E.useCallback(x=>{var k;return((k=r.restrictions[x])==null?void 0:k.values)||[]},[r.restrictions]),c=E.useCallback(x=>r.isAdmin?!1:!!r.restrictions[x],[r.isAdmin,r.restrictions]),u=E.useMemo(()=>!r.isAdmin&&Object.keys(r.restrictions).length>0,[r.isAdmin,r.restrictions]),g=E.useCallback(x=>{if(r.isAdmin)return x;const k=_e({},x);for(const[N,C]of Object.entries(r.permissionFilters))if(!k[N])k[N]=C;else if(Array.isArray(C)&&C[0]==="in"){const O=C[1];typeof k[N]=="string"&&!O.includes(k[N])&&(k[N]=["in",[]])}return k},[r.isAdmin,r.permissionFilters]),y=E.useMemo(()=>Object.entries(r.restrictions).map(([x,k])=>({type:x,field:k.field,values:k.values,count:k.count})),[r.restrictions]);return $e(_e({},r),{refetch:n,switchDoctype:n,getAllowedValues:i,hasRestriction:c,hasAnyRestrictions:u,mergeFilters:g,restrictionsList:y})};function iM(e){return xe(this,null,function*(){const r=typeof window!="undefined"&&window.csrf_token&&window.csrf_token!=="None"?window.csrf_token:null,a={"Content-Type":"application/json",Accept:"application/json"};r&&(a["X-Frappe-CSRF-Token"]=r);const n=[];e.company&&n.push(["company","=",e.company]),e.site_name&&n.push(["custom_site","=",e.site_name]),e.from_date&&e.to_date?n.push(["creation","between",[`${e.from_date} 00:00:00`,`${e.to_date} 23:59:59`]]):e.from_date?n.push(["creation",">=",`${e.from_date} 00:00:00`]):e.to_date&&n.push(["creation","<=",`${e.to_date} 23:59:59`]);const i=yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:a,credentials:"include",body:JSON.stringify({doctype:"Asset",fields:["name","asset_name","custom_device_status","location","department","company","custom_site"],filters:n,limit_page_length:500,order_by:"modified desc"})}),c=yield i.json();if(!i.ok)throw new Error((c==null?void 0:c.message)||(c==null?void 0:c.exc)||"Failed to load assets");const u=(c==null?void 0:c.message)||[];return Array.isArray(u)?u:[]})}const qv="#22C55E",Kv="#EF4444",zf=e=>{if(e==null||e==="")return 0;if(typeof e=="number")return Number.isFinite(e)&&e>=0?e:0;if(typeof e=="string"){if(e.includes(":")){const a=e.split(":").map(n=>Number(n)||0);if(a.length===3)return a[0]+a[1]/60+a[2]/3600;if(a.length===2)return a[0]+a[1]/60}const r=Number(e);return Number.isFinite(r)&&r>=0?r:0}return 0},oM=e=>{var n,i;if(!e||typeof e!="object"||"error"in e)return!1;const a=(i=(n=e.datasets)==null?void 0:n[0])==null?void 0:i.values;return!Array.isArray(a)||a.length===0?!1:a.some(c=>zf(c)>0)},lM=()=>{var Yt,gr,jr,Zr,en;const{t:e}=oa(),r=ua(),[a,n]=E.useState(""),[i,c]=E.useState(""),{filterHospital:u,filterSiteName:g,hospitalLocked:y,siteLocked:x,handleHospitalChange:k,handleSiteChange:N,hospitalLinkFilters:C}=j3(),{isAdmin:O,restrictions:D,permissionFilters:A}=dm("Work_Order"),I=E.useMemo(()=>{var Vt,Ut;const Qt=((Vt=D["Issue Type"])==null?void 0:Vt.values)||((Ut=D.work_order_type)==null?void 0:Ut.values)||[];if(Qt.length)return Qt;const wr=A.work_order_type;return Array.isArray(wr)&&wr[0]==="in"&&Array.isArray(wr[1])?wr[1]:typeof wr=="string"&&wr?[wr]:[]},[D,A]),z=E.useMemo(()=>!O&&I.length===1?I[0]:"",[O,I]),U=E.useMemo(()=>hl(u,x?g:void 0),[u,g,x]),B=E.useMemo(()=>PR(u,g,a,i),[u,g,a,i]),V=E.useMemo(()=>FR(u,g),[u,g]),Z=E.useMemo(()=>BR(u,g),[u,g]),W=nn(u),{data:H,loading:le}=xw(B),{workOrders:Q}=yw(V,1e3,0),{logs:Ne}=Qf(Z,1e3,0),[oe,se]=E.useState(null),[ce,Ce]=E.useState(null),[ae,me]=E.useState(null),[K,fe]=E.useState(null),[Oe,ye]=E.useState(!1),[J,G]=E.useState(null),[ie,re]=E.useState(!1),[ne,ve]=E.useState(null),[Ve,Ae]=E.useState(!1),[ze,Re]=E.useState(!1),[Ze,Lt]=E.useState(null),[mt,Zt]=E.useState(!1),[ar,or]=E.useState(!1),[yt,nr]=E.useState(!1),[$t,Er]=E.useState(null),[St,Br]=E.useState(!1),[Pt,it]=E.useState(null),[De,Je]=E.useState(0),[Be,vt]=E.useState(!1),[jt,Ct]=E.useState(!1),[Wt,pr]=E.useState(null),[Ge,We]=E.useState(!1),At=E.useCallback(()=>{r(Pw({},B.from_date,B.to_date,B))},[r,B]),lt=E.useCallback(Qt=>{r(Sf({status:Qt,work_order_type:z||void 0},B.from_date,B.to_date,B))},[r,B,z]),[Dt,mr]=E.useState({open:0,inProgress:0,completed:0,completedCombined:0,pendingReview:0,rejected:0,closed:0,total:0}),tr=E.useMemo(()=>{const Qt=Dt.completed||(H==null?void 0:H.work_orders_completed)||0,wr=Dt.closed||(H==null?void 0:H.work_orders_closed)||0;return av(Qt,wr)},[Dt,H]),[pt,Jt]=E.useState({assetUptime:0,avgResponseTime:0,maintenanceEfficiency:0,overdueTasks:0,plannedMaintenance:0}),{data:vr}=pw("Work Order Status Chart",B);E.useEffect(()=>{if(Q&&Q.length>0){const Qt={},wr=new Set;Q.forEach(be=>{const we=be.work_order_type||"null",ke=be.repair_status||"Unknown";wr.add(ke),Qt[we]||(Qt[we]={}),Qt[we][ke]||(Qt[we][ke]=0),Qt[we][ke]++});const Vt=Object.keys(Qt),Ut=["Open","Work In Progress","Pending Review","Completed","Closed","Cancelled"],ge=Array.from(wr).sort((be,we)=>{const ke=Ut.indexOf(be),Te=Ut.indexOf(we);return ke!==-1&&Te!==-1?ke-Te:ke!==-1?-1:Te!==-1?1:be.localeCompare(we)}).map(be=>{const we=Vt.map(ke=>Qt[ke][be]||0);return{name:be,values:we}});me({labels:Vt,datasets:ge,type:"Bar"})}else me(null)},[Q]),E.useEffect(()=>{let Qt=!1;return xe(null,null,function*(){We(!0);try{const Vt={};u&&(Vt.company=u),g&&nn(u)&&(Vt.site_name=g),z&&(Vt.work_order_type=z),a&&(Vt.from_date=a),i&&(Vt.to_date=i);const Ut=yield _t.getDashboardWorkOrderMetrics(Vt);if(Qt)return;se(Ut.work_order_chart),fe(Ut.type_status_chart||null),Ce(Ut.completion_by_type||null),mr({open:Ut.counts.open||0,inProgress:Ut.counts.inProgress||0,completed:Ut.counts.completed||0,completedCombined:av(Ut.counts.completed,Ut.counts.closed),pendingReview:Ut.counts.pendingReview||0,rejected:Ut.counts.rejected||0,closed:Ut.counts.closed||0,total:Ut.counts.total||0})}catch(Vt){console.error("Failed to load work order metrics:",Vt),Qt||(se(null),fe(null),Ce(null),mr({open:0,inProgress:0,completed:0,completedCombined:0,pendingReview:0,rejected:0,closed:0,total:0}))}finally{Qt||We(!1)}}),()=>{Qt=!0}},[u,g,z,a,i]),E.useEffect(()=>{let Qt=!1;return xe(null,null,function*(){Ae(!0);try{const Vt={};a&&(Vt.from_date=a),i&&(Vt.to_date=i),u&&(Vt.company=u),g&&nn(u)&&(Vt.site_name=g),z&&(Vt.work_order_type=z);const Ut=yield IR(Vt);Qt||ve(Ut)}catch(Vt){console.error("Failed to load technician work summary:",Vt),Qt||ve(null)}finally{Qt||Ae(!1)}}),()=>{Qt=!0}},[u,g,a,i,z]),E.useEffect(()=>{let Qt=!1;return xe(null,null,function*(){Zt(!0);try{const Vt={};a&&(Vt.from_date=a),i&&(Vt.to_date=i),u&&(Vt.company=u),g&&nn(u)&&(Vt.site_name=g),z&&(Vt.work_order_type=z);const Ut=yield VR(Vt);Qt||Lt(Ut)}catch(Vt){console.error("Failed to load technician working hours:",Vt),Qt||Lt(null)}finally{Qt||Zt(!1)}}),()=>{Qt=!0}},[u,g,a,i,z]),E.useEffect(()=>{let Qt=!1;return xe(null,null,function*(){Ct(!0);try{const Vt={};u&&(Vt.company=u),g&&(Vt.site_name=g),a&&(Vt.from_date=a),i&&(Vt.to_date=i);const Ut=yield _t.getAssetDeviceStatusSummary(Vt);if(Qt)return;it(Ut.chart||null),Je(Ut.total_assets||0)}catch(Vt){console.error("Failed to load asset device status summary:",Vt),Qt||(it(null),Je(0))}finally{Qt||Ct(!1)}}),()=>{Qt=!0}},[u,g,a,i]),E.useEffect(()=>{if(z){Er(null);return}let Qt=!1;return xe(null,null,function*(){Br(!0);try{const Vt=yield C3(B);Qt||Er(KR(Vt!=null?Vt:{}))}catch(Vt){console.error("Failed to load WO feedback summary:",Vt),Qt||Er(null)}finally{Qt||Br(!1)}}),()=>{Qt=!0}},[z,B]);const Ir=E.useCallback(Qt=>xe(null,null,function*(){const[wr,Vt]=yield Promise.all([_t.getAssetDeviceStatusSummary(Qt),iM(Qt)]);return{chart:wr.chart||null,total_assets:wr.total_assets||0,assets:Vt}}),[]),Le=E.useCallback(Qt=>xe(null,null,function*(){var Vt;const wr=yield _t.getDashboardWorkOrderMetrics(Qt);return{chart:wr.type_status_chart||null,total:((Vt=wr.counts)==null?void 0:Vt.total)||0}}),[]);E.useEffect(()=>{if(Ne&&Ne.length>0){let Qt=0,wr=0,Vt=0;const Ut=new Date;Ne.forEach(ge=>{var be,we;((be=ge.maintenance_status)==null?void 0:be.toLowerCase())==="completed"&&Qt++,((we=ge.maintenance_status)==null?void 0:we.toLowerCase())==="planned"&&wr++,ge.due_date&&new Date(ge.due_date)<Ut&&ge.maintenance_status!=="Completed"&&Vt++});const de=Ne.length>0?Qt/Ne.length*100:0;Jt(ge=>$e(_e({},ge),{maintenanceEfficiency:de,overdueTasks:Vt,plannedMaintenance:wr}))}},[Ne]),E.useEffect(()=>{let Qt=!1;return xe(null,null,function*(){re(!0);try{const Vt={};a&&(Vt.from_date=a),i&&(Vt.to_date=i),u&&(Vt.company=u),g&&nn(u)&&(Vt.site_name=g);const Ut=yield CC(Vt);Qt||G(Ut)}catch(Vt){console.error("Failed to load assignees status chart:",Vt),Qt||G(null)}finally{Qt||re(!1)}}),()=>{Qt=!0}},[u,g,a,i]),E.useEffect(()=>{if(Q&&Q.length>0){let Qt=0,wr=0;Q.forEach(ge=>{if(ge.creation&&ge.first_responded_on){const be=new Date(ge.creation),ke=(new Date(ge.first_responded_on).getTime()-be.getTime())/(1e3*60*60);ke>=0&&(Qt+=ke,wr++)}});const Vt=wr>0?Qt/wr:0,Ut=Q.filter(ge=>{var be;return((be=ge.repair_status)==null?void 0:be.toLowerCase())==="completed"}).length,de=Q.length>0?Ut/Q.length*100:0;Jt(ge=>$e(_e({},ge),{assetUptime:de,avgResponseTime:Vt}))}},[Q]);const qe=E.useMemo(()=>oe,[oe]),Ke=E.useMemo(()=>K||ae||vr,[K,ae,vr]);return le?t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-600 mx-auto mb-4"}),t.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:e("dashboard.loading")})]})}):t.jsxs("div",{className:"min-h-screen w-full min-w-0 overflow-x-hidden bg-gray-50 dark:bg-gray-900 p-3 sm:p-6",children:[t.jsxs("div",{className:"max-w-[1600px] mx-auto",children:[t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700 px-4 py-3 mb-4",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3 items-end w-full min-w-0",children:[t.jsxs("div",{className:"relative z-[60]",children:[t.jsx(er,{label:e("commonFields.hospital",{defaultValue:"Hospital"}),doctype:"Company",value:u,onChange:k,placeholder:e("dashboard.allHospitals",{defaultValue:"All Hospitals"}),disabled:y,compact:!0,filters:C}),u&&!y&&t.jsx("button",{type:"button",onClick:()=>k(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),W&&t.jsxs("div",{className:"relative z-[55]",children:[t.jsx(er,{label:e("commonFields.siteName",{defaultValue:"Site Name"}),doctype:"Mobile Team Site",value:g,onChange:N,placeholder:e("dashboard.allSites",{defaultValue:"All Sites"}),disabled:x,compact:!0,filters:U}),g&&!x&&t.jsx("button",{type:"button",onClick:()=>N(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:No,children:[t.jsx("label",{className:wo,children:e("dashboard.fromDate",{defaultValue:"From Date"})}),t.jsx("input",{type:"date",value:a,onChange:Qt=>n(Qt.target.value),className:ko})]}),t.jsxs("div",{className:No,children:[t.jsx("label",{className:wo,children:e("dashboard.toDate",{defaultValue:"To Date"})}),t.jsx("input",{type:"date",value:i,onChange:Qt=>c(Qt.target.value),className:ko})]})]})}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-3 mb-6",children:[t.jsxs("div",{className:"lg:col-span-7 col-span-12 space-y-2",children:[t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700 px-4 py-4",children:t.jsxs("div",{className:"grid grid-cols-12 gap-0 w-full",children:[t.jsx("div",{className:"col-span-2",children:t.jsx(Nd,{icon:t.jsx(kw,{className:"text-indigo-600"}),value:(Yt=H==null?void 0:H.total_assets)!=null?Yt:0,label:e("dashboard.totalAssets"),bgColor:"bg-indigo-50 dark:bg-indigo-900/20",onClick:At})}),t.jsx("div",{className:"col-span-2",children:t.jsx(Nd,{icon:t.jsx(mC,{className:"text-purple-600"}),value:Dt.open||((gr=H==null?void 0:H.work_orders_open)!=null?gr:0),label:e("dashboard.openWorkOrders"),bgColor:"bg-purple-50 dark:bg-purple-900/20",onClick:()=>lt("Open")})}),t.jsx("div",{className:"col-span-2",children:t.jsx(Nd,{icon:t.jsx($s,{className:"text-blue-600"}),value:Dt.inProgress||((jr=H==null?void 0:H.work_orders_in_progress)!=null?jr:0),label:e("dashboard.workOrdersInProgress"),bgColor:"bg-blue-50 dark:bg-blue-900/20",onClick:()=>lt("Work In Progress")})}),t.jsx("div",{className:"col-span-2",children:t.jsx(Nd,{icon:t.jsx(Ca,{className:"text-pink-600"}),value:Dt.completed||((Zr=H==null?void 0:H.work_orders_completed)!=null?Zr:0),label:e("dashboard.completedWorkOrders"),bgColor:"bg-pink-50 dark:bg-pink-900/20",onClick:()=>lt("Completed")})}),t.jsx("div",{className:"col-span-2",children:t.jsx(Nd,{icon:t.jsx(Q8,{className:"text-cyan-600"}),value:Dt.closed||((en=H==null?void 0:H.work_orders_closed)!=null?en:0),label:e("dashboard.closedWorkOrders"),bgColor:"bg-cyan-50 dark:bg-cyan-900/20",onClick:()=>lt("Closed")})}),t.jsx("div",{className:"col-span-2",children:t.jsx(Nd,{icon:t.jsx(aC,{className:"text-purple-600"}),value:Dt.total,label:e("dashboard.totalWorkOrders"),bgColor:"bg-purple-50 dark:bg-purple-900/20",onClick:()=>lt()})})]})}),t.jsx(HC,{loading:Ge,totalWorkOrders:Dt.total,completedWorkOrders:tr,inProgressWorkOrders:Dt.inProgress,rejectedWorkOrders:Dt.rejected,byTypeChartData:ce,onOpenReport:()=>{const Qt=(ce==null?void 0:ce.rates)||[];pr({title:e("dashboard.overallCompletionByDepartment",{defaultValue:"Overall Completion Rate by Department"}),redirectContext:"wo_type",data:{labels:Qt.map(wr=>wr.type),datasets:[{name:"Completion Rate (%)",values:Qt.map(wr=>Sp(wr))},{name:"Completed WOs",values:Qt.map(wr=>{var Vt;return(Vt=wr.completedCombined)!=null?Vt:(wr.completed||0)+(wr.closed||0)})},{name:"In Progress",values:Qt.map(wr=>wr.inProgress||0)},{name:"Rejected",values:Qt.map(wr=>wr.rejected||0)},{name:"Total WOs",values:Qt.map(wr=>wr.total||0)}],hideFooterTotal:!0}})}})]}),t.jsx("div",{className:"lg:col-span-5 col-span-12",children:t.jsx(Jv,{title:e("dashboard.assigneesStatus",{defaultValue:"Asset Maintenance Assignees Status Count"}),data:J,loading:ie,onOpenReport:()=>pr({title:e("dashboard.assigneesStatus",{defaultValue:"Asset Maintenance Assignees Status Count"}),data:J,redirectContext:"assignees_status"})})})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-6",children:[t.jsx(nf,{icon:t.jsx(Ca,{className:"text-green-500"}),title:e("dashboard.assetUptime"),value:`${pt.assetUptime.toFixed(1)}%`,trend:pt.assetUptime>=90?"Excellent":pt.assetUptime>=75?"Good":"Needs Attention",trendUp:pt.assetUptime>=75,bgColor:"bg-green-50 dark:bg-green-900/20"}),t.jsx(nf,{icon:t.jsx($s,{className:"text-blue-500"}),title:e("dashboard.avgResponseTime"),value:pt.avgResponseTime>0?`${pt.avgResponseTime.toFixed(1)} hrs`:"N/A",trend:pt.avgResponseTime>0&&pt.avgResponseTime<4?"Fast Response":"Monitor",trendUp:pt.avgResponseTime>0&&pt.avgResponseTime<4,bgColor:"bg-blue-50 dark:bg-blue-900/20"}),t.jsx(nf,{icon:t.jsx(Aw,{className:"text-orange-500"}),title:e("dashboard.maintenanceEfficiency"),value:`${pt.maintenanceEfficiency.toFixed(1)}%`,trend:pt.maintenanceEfficiency>=70?"On Track":"Needs Attention",trendUp:pt.maintenanceEfficiency>=70,bgColor:"bg-orange-50 dark:bg-orange-900/20"}),t.jsx(nf,{icon:t.jsx(an,{className:"text-red-500"}),title:e("dashboard.overdueMaintenance"),value:pt.overdueTasks,trend:pt.overdueTasks===0?"All Clear":pt.overdueTasks<=3?"Low":"High Priority",trendUp:pt.overdueTasks<=3,bgColor:"bg-red-50 dark:bg-red-900/20"})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-6",children:[t.jsx(DC,{title:e("dashboard.assetUpDown",{defaultValue:"Asset UP & Down"}),data:Pt,loading:jt,totalAssets:De,onOpenReport:()=>vt(!0)}),t.jsx(cM,{title:e("dashboard.workOrderStatusDistribution",{defaultValue:"Work Order Status Distribution"}),data:qe,totalWorkOrders:Dt.total,completedWorkOrders:Dt.completed,loading:Ge,onOpenReport:()=>pr({title:e("dashboard.workOrderStatusDistribution",{defaultValue:"Work Order Status Distribution"}),data:qe,redirectContext:"wo_status"})})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 ",children:[t.jsx(Jv,{title:e("dashboard.workOrderStatus"),data:Ke,loading:Ge,onOpenReport:()=>ye(!0)}),t.jsx(WC,{title:e("dashboard.techniciansWorked",{defaultValue:"Technicians Work Summary"}),data:ne,loading:Ve,onOpenReport:()=>Re(!0)}),t.jsx($C,{title:e("dashboard.technicianWorkingHours",{defaultValue:"Technicians Working Hours"}),data:Ze,loading:mt,onOpenReport:()=>or(!0)}),!z&&t.jsx(fM,{title:e("dashboard.woFeedbackReport",{defaultValue:"WO Feedback Report"}),data:$t,loading:St,onOpenReport:()=>nr(!0)})]})]}),t.jsx(UC,{isOpen:Oe,onClose:()=>ye(!1),initialChartData:K||Ke,defaultFromDate:a,defaultToDate:i,locationFilters:B,workOrderType:z,onRefresh:Le}),t.jsx(PC,{isOpen:Be,onClose:()=>vt(!1),chartData:Pt,defaultFromDate:a,defaultToDate:i,locationFilters:B,onRefresh:Ir}),t.jsx(UR,{isOpen:ze,onClose:()=>Re(!1),permittedIssueTypes:I,isAdmin:O,defaultWorkOrderType:z,defaultFromDate:a,defaultToDate:i,defaultCompany:u,defaultSiteName:g,companyLocked:y,siteLocked:x,hospitalLinkFilters:C}),t.jsx(WR,{isOpen:ar,onClose:()=>or(!1),permittedIssueTypes:I,isAdmin:O,defaultWorkOrderType:z,defaultFromDate:a,defaultToDate:i,defaultCompany:u,defaultSiteName:g,companyLocked:y,siteLocked:x,hospitalLinkFilters:C}),t.jsx(JR,{isOpen:yt,onClose:()=>nr(!1),defaultCompany:u,defaultSiteName:g,companyLocked:y,siteLocked:x,hospitalLinkFilters:C}),t.jsx(TC,{isOpen:!!Wt,onClose:()=>pr(null),title:(Wt==null?void 0:Wt.title)||"",initialData:Wt==null?void 0:Wt.data,redirectContext:Wt==null?void 0:Wt.redirectContext,defaultFromDate:a,defaultToDate:i,locationFilters:B,workOrderType:z})]})},Nd=({icon:e,value:r,label:a,bgColor:n,onClick:i})=>t.jsxs("button",{type:"button",onClick:i,title:i?`View ${a}`:void 0,className:`w-full text-center py-2 px-1 border-r border-gray-200 dark:border-gray-700 last:border-r-0 transition-all ${i?"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/40 hover:shadow-sm rounded-lg group":"cursor-default"}`,children:[t.jsx("div",{className:`w-10 h-10 ${n} rounded-lg flex items-center justify-center text-base mx-auto mb-1.5 transition-transform ${i?"group-hover:scale-105":""}`,children:e}),t.jsx("div",{className:"text-lg font-semibold text-gray-900 dark:text-white leading-none mb-1",children:r}),t.jsx("div",{className:"text-[9px] font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide leading-tight px-1",children:a})]}),nf=({icon:e,title:r,value:a,trend:n,trendUp:i,bgColor:c})=>t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow hover:shadow-md transition-all p-4 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-start justify-between mb-3",children:[t.jsx("div",{className:`w-10 h-10 ${c} rounded-lg flex items-center justify-center text-lg`,children:e}),t.jsxs("div",{className:`flex items-center gap-1 text-xs font-medium ${i?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[i?t.jsx(tC,{className:"text-[10px]"}):t.jsx(eC,{className:"text-[10px]"}),n]})]}),t.jsx("div",{className:"text-2xl font-semibold text-gray-900 dark:text-white mb-1",children:a}),t.jsx("div",{className:"text-xs font-medium text-gray-600 dark:text-gray-400",children:r})]}),cM=({title:e,data:r,totalWorkOrders:a,completedWorkOrders:n,loading:i=!1,onOpenReport:c})=>t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow hover:shadow-md transition-all px-5 py-5 border border-gray-200 dark:border-gray-700 flex flex-col",style:{minHeight:"100%"},children:[t.jsxs("div",{className:"flex items-center justify-between mb-4 flex-shrink-0",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-white",children:e}),t.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[t.jsxs("div",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:[a," Total"]}),t.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:[t.jsxs("span",{className:"font-medium",children:[n," Completed"]}),t.jsxs("span",{className:"ml-1",children:["(",a>0?(n/a*100).toFixed(1):0,"%)"]})]})]})]}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("button",{type:"button",onClick:c,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg text-indigo-600 dark:text-indigo-300",title:"View details",children:t.jsx(qd,{className:"w-4 h-4"})})})]}),t.jsx("div",{className:"flex-1",children:i?t.jsx("div",{className:"h-64 flex items-center justify-center",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-600"})}):oM(r)?t.jsx(hM,{data:r}):t.jsx("div",{className:"h-64 flex items-center justify-center text-gray-400 text-sm",children:"No chart data available"})})]}),dM=(e,r,a)=>{if(a!=null&&a>0){const n=(r/a*100).toFixed(1);return`${e}: ${r} (${n}%)`}return`${e}: ${r}`},T3=()=>{const[e,r]=E.useState(null),a=E.useCallback((i,c,u,g,y)=>{r({x:i,y:c,text:dM(u,g,y)})},[]),n=E.useCallback(()=>r(null),[]);return{tooltip:e,show:a,hide:n}},A3=({tooltip:e})=>e?t.jsx("div",{className:"fixed z-[9999] pointer-events-none px-2.5 py-1.5 rounded text-xs font-medium text-white bg-gray-900 shadow-lg whitespace-nowrap",style:{left:e.x,top:e.y-8,transform:"translate(-50%, -100%)"},role:"tooltip",children:e.text}):null,uM=({data:e})=>{const{tooltip:r,show:a,hide:n}=T3(),i=(e==null?void 0:e.labels)||[],c=(e==null?void 0:e.datasets)||[];if(!c.length)return t.jsx("div",{className:"text-center text-gray-400 py-4 text-sm",children:"No data available"});const u=c.flatMap(z=>z.values||[]),g=Math.max(...u,1),y=240,x=Math.max(800,i.length*100),k=Math.min(120,(x-100)/i.length),N=4,C=c.length,O=Math.max(12,(k-N*(C+1))/C),D={"Completed On Time":"#6366F1","Completed Within SLA":"#3B82F6","Delay In Completion":"#8B5CF6",Pending:"#A855F7",Overdue:"#EC4899",Cancelled:"#0EA5E9",Open:"#6366F1","Work In Progress":"#3B82F6","Pending Review":"#8B5CF6",Completed:"#6366F1",Closed:"#A855F7"},A=(z,U)=>{for(const[B,V]of Object.entries(D))if(z.toLowerCase().includes(B.toLowerCase()))return V;return O3(C)[U]},I=i.map((z,U)=>c.reduce((B,V)=>{var Z;return B+zf((Z=V.values)==null?void 0:Z[U])},0));return t.jsxs("div",{className:"relative w-full overflow-x-auto",onMouseLeave:n,children:[t.jsx(A3,{tooltip:r}),t.jsxs("svg",{width:"100%",height:y+40,viewBox:`0 0 ${x} ${y+40}`,className:"w-full",preserveAspectRatio:"xMidYMid meet",children:[t.jsx("defs",{children:c.map((z,U)=>{const B=A(z.name||"",U);return t.jsxs("linearGradient",{id:`groupedBarGradient${U}`,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[t.jsx("stop",{offset:"0%",style:{stopColor:B,stopOpacity:.9}}),t.jsx("stop",{offset:"100%",style:{stopColor:B,stopOpacity:.7}})]},U)})}),[0,.25,.5,.75,1].map((z,U)=>t.jsx("line",{x1:"60",y1:y-z*y,x2:x-20,y2:y-z*y,stroke:"#E5E7EB",strokeWidth:"1",className:"dark:stroke-gray-700"},U)),[0,.25,.5,.75,1].map((z,U)=>t.jsx("text",{x:"45",y:y-z*y+4,textAnchor:"end",className:"text-xs fill-gray-400 dark:fill-gray-500",children:(g*z).toFixed(z===0?0:g<5?1:0)},U)),t.jsx("text",{x:"15",y:y/2,textAnchor:"middle",transform:`rotate(-90, 15, ${y/2})`,className:"text-xs fill-gray-600 dark:fill-gray-400 font-medium",children:"Count"}),i.map((z,U)=>{const B=80+U*k;return t.jsxs("g",{children:[c.map((V,Z)=>{var Ce;const W=zf((Ce=V.values)==null?void 0:Ce[U]),H=W/g*y,le=B+N+Z*(O+N),Q=y-H,Ne=V.colors||[],oe=C===1&&Ne[U]?Ne[U]:A(V.name||"",Z),se=i[U]||z,ce=C===1?`${se} — Tasks: ${W}`:`${se} — ${V.name||`Series ${Z+1}`}: ${W}`;return t.jsx("g",{children:t.jsx("rect",{x:le,y:Q,width:O,height:H,fill:oe,rx:"4",ry:"4",className:"hover:opacity-80 transition-opacity",onMouseEnter:ae=>a(ae.clientX,ae.clientY,ce,W,I[U]),onMouseMove:ae=>a(ae.clientX,ae.clientY,ce,W,I[U]),onMouseLeave:n})},Z)}),t.jsx("text",{x:B+k/2,y:y+15,textAnchor:"middle",className:"text-xs fill-gray-600 dark:fill-gray-400",children:z&&z.length>12?z.substring(0,10)+"...":z||"null"})]},U)})]}),t.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:c.map((z,U)=>{const B=A(z.name||"",U);return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded",style:{backgroundColor:B}}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:z.name&&z.name.length>20?z.name.substring(0,18)+"...":z.name||`Series ${U+1}`})]},U)})})]})},hM=({data:e})=>{var I,z,U,B;const{tooltip:r,show:a,hide:n}=T3(),i=(e==null?void 0:e.labels)||[],c=(((z=(I=e==null?void 0:e.datasets)==null?void 0:I[0])==null?void 0:z.values)||[]).map(V=>zf(V)),u=V=>{const Z=V.toLowerCase();return Z.includes("up")||Z.includes("down")||Z.includes("تشغيل")||Z.includes("توقف")},g=i.some(u);let y=[];if(g&&i.length>=1)y=i.map(V=>{const Z=V.toLowerCase();return Z.includes("down")||V.includes("توقف")?Kv:Z.includes("up")||V.includes("تشغيل")||i.indexOf(V)===0?qv:Kv});else{const V=(B=(U=e==null?void 0:e.datasets)==null?void 0:U[0])==null?void 0:B.colors;y=V&&V.length===c.length?V:O3(c.length)}const x=c.reduce((V,Z)=>V+Z,0);if(x<=0||i.length===0)return t.jsx("div",{className:"h-48 flex items-center justify-center text-gray-400 text-sm",children:"No data available"});const k=100,N=k+10,C=k+10;let O=0;const D=c.map((V,Z)=>{const W=O/x*2*Math.PI-Math.PI/2;O+=V;const H=O/x*2*Math.PI-Math.PI/2,le=H-W>Math.PI?1:0,Q=N+k*Math.cos(W),Ne=C+k*Math.sin(W),oe=N+k*Math.cos(H),se=C+k*Math.sin(H);return{path:`M ${N} ${C} L ${Q} ${Ne} A ${k} ${k} 0 ${le} 1 ${oe} ${se} Z`,color:y[Z],label:i[Z],value:V,percentage:(V/x*100).toFixed(1)}}),A=D.length===1;return t.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-around",onMouseLeave:n,children:[t.jsx(A3,{tooltip:r}),t.jsx("svg",{width:N*2,height:C*2,viewBox:`0 0 ${N*2} ${C*2}`,className:"max-w-xs",children:A?t.jsx("circle",{cx:N,cy:C,r:k,fill:D[0].color,className:"hover:opacity-90 transition-opacity cursor-pointer drop-shadow-lg",onMouseEnter:V=>a(V.clientX,V.clientY,D[0].label,D[0].value,x),onMouseMove:V=>a(V.clientX,V.clientY,D[0].label,D[0].value,x),onMouseLeave:n}):D.map((V,Z)=>t.jsx("path",{d:V.path,fill:V.color,className:"hover:opacity-90 transition-opacity cursor-pointer drop-shadow-lg",onMouseEnter:W=>a(W.clientX,W.clientY,V.label,V.value,x),onMouseMove:W=>a(W.clientX,W.clientY,V.label,V.value,x),onMouseLeave:n},Z))}),t.jsx("div",{className:"flex flex-col gap-3 mt-4 md:mt-0",children:D.map((V,Z)=>t.jsxs("div",{className:"flex items-center gap-3 cursor-pointer rounded px-1 py-0.5 hover:bg-gray-100 dark:hover:bg-gray-700/50",onMouseEnter:W=>a(W.clientX,W.clientY,V.label,V.value,x),onMouseMove:W=>a(W.clientX,W.clientY,V.label,V.value,x),onMouseLeave:n,children:[t.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:V.color}}),t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:V.label}),t.jsx("span",{className:"text-sm font-bold text-gray-900 dark:text-white",children:V.value})]},Z))})]})},Jv=({title:e,data:r,loading:a=!1,onOpenReport:n})=>t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow hover:shadow-md transition-all p-3 border border-gray-200 dark:border-gray-700 h-full",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-white",children:e}),n&&t.jsx("button",{type:"button",onClick:n,className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg text-indigo-600 dark:text-indigo-300",title:"View details",children:t.jsx(qd,{className:"w-3.5 h-3.5"})})]}),a?t.jsx("div",{className:"h-48 flex items-center justify-center",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-600"})}):!r||!r.datasets||!r.datasets.length?t.jsx("div",{className:"h-48 flex items-center justify-center text-gray-400",children:t.jsx("div",{className:"text-center",children:t.jsx("div",{className:"text-xs",children:"No chart data available"})})}):t.jsx(uM,{data:r})]}),fM=({title:e,data:r,loading:a=!1,onOpenReport:n})=>{var O,D,A,I;const{t:i}=oa(),[c,u]=ea.useState(!1),g=ea.useRef(null);ea.useEffect(()=>{const z=U=>{g.current&&!g.current.contains(U.target)&&u(!1)};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]);const y=(r==null?void 0:r.labels)||[],x=((D=(O=r==null?void 0:r.datasets)==null?void 0:O[0])==null?void 0:D.values)||[],k=((I=(A=r==null?void 0:r.datasets)==null?void 0:A[0])==null?void 0:I.colors)||y.map(z=>np(z)),N=x.reduce((z,U)=>z+(Number(U)||0),0),C=Math.max(...x.map(z=>Number(z)||0),1);return t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow hover:shadow-md transition-all p-3 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[t.jsx("div",{className:"min-w-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:n,className:"p-1.5 rounded-full bg-emerald-50 dark:bg-emerald-900/30 text-emerald-600 dark:text-emerald-300 hover:bg-emerald-100 dark:hover:bg-emerald-900/50 transition-colors shrink-0",title:i("dashboard.viewFullReport",{defaultValue:"View Full Report"}),children:t.jsx(Zl,{className:"w-3.5 h-3.5"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-white truncate",children:e}),t.jsx("p",{className:"text-[11px] text-emerald-600 dark:text-emerald-300 mt-0.5",children:i("dashboard.woFeedbackTotalResponses",{total:N,defaultValue:`Total responses: ${N}`})})]})]})}),t.jsxs("div",{className:"relative",ref:g,children:[t.jsx("button",{type:"button",onClick:()=>u(z=>!z),className:"p-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg","aria-label":"Chart menu",children:t.jsx("svg",{className:"w-4 h-4 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})})}),c&&t.jsx("div",{className:"absolute right-0 mt-1 w-44 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-20 py-1",children:t.jsx("button",{type:"button",className:"w-full text-left px-3 py-2 text-xs text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700",onClick:()=>{u(!1),n()},children:i("dashboard.viewFullReport",{defaultValue:"View Full Report"})})})]})]}),a?t.jsx("div",{className:"h-48 flex items-center justify-center",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-emerald-600"})}):y.length?t.jsx("div",{className:"max-h-72 overflow-y-auto pr-1 space-y-2",children:y.map((z,U)=>{const B=Number(x[U])||0,V=B/C*100,Z=k[U]||np(z);return t.jsxs("div",{className:"grid grid-cols-[7rem_1fr_auto] gap-2 items-center",children:[t.jsx("div",{className:"text-xs text-gray-700 dark:text-gray-300 truncate text-right",title:z,children:z}),t.jsx("div",{className:"h-7 bg-gray-100 dark:bg-gray-700/60 rounded-md overflow-hidden",children:t.jsx("div",{className:"h-full rounded-md transition-opacity",style:{width:`${V}%`,minWidth:B>0?"4px":0,backgroundColor:Z}})}),t.jsx("div",{className:"text-xs font-semibold text-gray-700 dark:text-gray-200 whitespace-nowrap",children:B})]},`${z}-${U}`)})}):t.jsx("div",{className:"h-48 flex items-center justify-center text-gray-400 text-xs",children:i("dashboard.noChartData",{defaultValue:"No chart data available"})})]})};function O3(e){const r=["#8B5CF6","#6366F1","#3B82F6","#06B6D4","#14B8A6","#EC4899","#A855F7","#0EA5E9","#10B981","#F472B6","#7C3AED","#2DD4BF"];return Array.from({length:e},(a,n)=>r[n%r.length])}const R3="wo-feedback",M3="WO Feedback";function mM(){return xe(this,null,function*(){const e=yield _t.getCSRFToken();return e||_t.getCSRFTokenForGuest()})}function D3(a){return xe(this,arguments,function*(e,r={}){const n=yield mM(),i={Accept:"application/json","Content-Type":"application/json"};n&&(i["X-Frappe-CSRF-Token"]=n);const c=yield fetch(`${Lr.BASE_URL}/api/method/${e}`,{method:"POST",credentials:"include",headers:i,body:JSON.stringify(r)}),u=yield c.json().catch(()=>({}));if(!c.ok||u.exc)throw new Error(qp(u)||(u==null?void 0:u.message)||`HTTP ${c.status}`);return Object.prototype.hasOwnProperty.call(u,"message")?u.message:null})}function gM(e){return e?e.split(`
|
||
`).map(r=>r.trim()).filter(Boolean):[]}function xM(e){return e?typeof document=="undefined"?e.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim():(new DOMParser().parseFromString(e,"text/html").body.textContent||"").replace(/\s+/g," ").trim():""}function L3(e){const r=(e==null?void 0:e.web_form)||{},n=(r.web_form_fields||[]).find(i=>i.fieldname==="rating");return{title:String(r.title||"WO Feedback"),introductionHtml:String(r.introduction_text||""),introductionText:xM(String(r.introduction_text||"")),buttonLabel:String(r.button_label||"Save"),successTitle:String(r.success_title||"Feedback Submitted"),successMessage:String(r.success_message||"Your feedback was submitted successfully."),ratingOptions:gM(n==null?void 0:n.options)}}function pM(){return xe(this,null,function*(){const e=new URLSearchParams({doctype:M3,web_form_name:R3}),r=yield fetch(`${Lr.BASE_URL}/api/method/frappe.website.doctype.web_form.web_form.get_form_data?${e}`,{credentials:"include",headers:{Accept:"application/json"}}),a=yield r.json().catch(()=>({}));if(!r.ok||a.exc)throw new Error(qp(a)||"Failed to load web form");return L3(a.message||a)})}function yM(e){return xe(this,null,function*(){const r=yield D3("asset_lite.api.wo_feedback_api.get_wo_feedback_for_work_order",{work_order:e});return r!=null&&r.name?r:null})}function bM(e){return xe(this,null,function*(){const r=JSON.stringify({work_order:e.work_order,requester_name:e.requester_name,rating:e.rating,comments:e.comments||"",doctype:M3});return D3("frappe.website.doctype.web_form.web_form.accept",{web_form:R3,data:r})})}const ff={getWebFormConfig:pM,getFeedbackForWorkOrder:yM,submitFeedback:bM,parseWebFormConfig:L3},Lx="w-full px-3 py-2 text-sm 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-indigo-400",vM=({workOrder:e,defaultRequesterName:r="",compact:a=!1,onSuccess:n})=>{const[i,c]=E.useState("loading"),[u,g]=E.useState(null),[y,x]=E.useState(null),[k,N]=E.useState(r),[C,O]=E.useState(""),[D,A]=E.useState(""),[I,z]=E.useState(!1),[U,B]=E.useState("");E.useEffect(()=>{N(r)},[r]),E.useEffect(()=>{if(!e){c("error"),B("Work Order is required.");return}let W=!1;return xe(null,null,function*(){c("loading"),B("");try{const[H,le]=yield Promise.all([ff.getWebFormConfig(),ff.getFeedbackForWorkOrder(e)]);if(W)return;g(H),le?(x(le),c("existing")):c("form")}catch(H){if(W)return;B(H instanceof Error?H.message:"Failed to load feedback form"),c("error")}}),()=>{W=!0}},[e]);const V=W=>xe(null,null,function*(){if(W.preventDefault(),!k.trim()){B("Requester Name is required.");return}if(!C){B("Please select a rating.");return}z(!0),B("");try{const H=yield ff.submitFeedback({work_order:e,requester_name:k.trim(),rating:C,comments:D.trim()});x(H),c("success"),n==null||n(H)}catch(H){B(H instanceof Error?H.message:"Failed to submit feedback")}finally{z(!1)}});if(i==="loading")return t.jsxs("div",{className:`flex items-center justify-center gap-2 text-gray-500 ${a?"py-4":"py-10"}`,children:[t.jsx(Ja,{className:"animate-spin text-indigo-500"}),t.jsx("span",{className:"text-sm",children:"Loading feedback form…"})]});if(i==="error"&&!u)return t.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 dark:bg-red-900/20 dark:border-red-800 px-4 py-3 text-sm text-red-700 dark:text-red-300",children:U||"Unable to load feedback form."});const Z=(u==null?void 0:u.title)||"WO Feedback";return i==="existing"&&y?t.jsxs("div",{className:a?"space-y-3":"space-y-4",children:[!a&&(u==null?void 0:u.introductionText)&&t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:u.introductionText}),t.jsxs("div",{className:"rounded-lg border border-green-200 dark:border-green-800 bg-green-50 dark:bg-green-900/20 p-4 text-center",children:[t.jsx(Ca,{className:"mx-auto text-green-600 mb-2"}),t.jsx("p",{className:"text-sm font-semibold text-green-800 dark:text-green-300",children:"Feedback already submitted"}),t.jsxs("p",{className:"text-xs text-green-700 dark:text-green-400 mt-2",children:[t.jsx("span",{className:"font-medium",children:"Requester:"})," ",y.requester_name||"—"]}),t.jsx("p",{className:"text-sm font-bold text-green-800 dark:text-green-200 mt-1",children:y.rating||"—"}),y.comments&&t.jsxs("p",{className:"text-xs text-green-700 dark:text-green-400 mt-2 text-left",children:[t.jsx("span",{className:"font-medium",children:"Comments:"})," ",y.comments]})]})]}):i==="success"&&y?t.jsxs("div",{className:`rounded-lg border border-green-200 dark:border-green-800 bg-green-50 dark:bg-green-900/20 p-4 text-center ${a?"":"py-8"}`,children:[t.jsx(Ca,{className:"mx-auto text-green-600 text-2xl mb-3"}),t.jsx("h3",{className:"text-base font-bold text-green-800 dark:text-green-200",children:(u==null?void 0:u.successTitle)||"Feedback Submitted"}),t.jsx("p",{className:"text-sm text-green-700 dark:text-green-300 mt-1",children:(u==null?void 0:u.successMessage)||"Your feedback was submitted successfully."}),t.jsx("p",{className:"text-xs text-green-600 dark:text-green-400 mt-3",children:y.rating}),y.comments&&t.jsx("p",{className:"text-xs text-green-600 dark:text-green-400 mt-2",children:y.comments})]}):t.jsxs("form",{onSubmit:V,className:a?"space-y-3":"space-y-4",children:[!a&&t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-white",children:Z}),(u==null?void 0:u.introductionText)&&t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:u.introductionText})]}),a&&(u==null?void 0:u.introductionText)&&t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:u.introductionText}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase mb-1",children:"Work Order"}),t.jsx("div",{className:"px-3 py-2 text-sm bg-gray-100 dark:bg-gray-900/40 border border-gray-200 dark:border-gray-700 rounded-lg text-gray-800 dark:text-gray-200",children:e})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase mb-1",children:["Requester Name ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",value:k,onChange:W=>N(W.target.value),className:Lx,placeholder:"Your name",required:!0})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase mb-1",children:["Rating ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("select",{value:C,onChange:W=>O(W.target.value),className:Lx,required:!0,children:[t.jsx("option",{value:"",children:"Select rating…"}),((u==null?void 0:u.ratingOptions)||[]).map(W=>t.jsx("option",{value:W,children:W},W))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase mb-1",children:"Comments"}),t.jsx("textarea",{value:D,onChange:W=>A(W.target.value),className:`${Lx} min-h-[88px] resize-y`,placeholder:"Optional comments…",rows:3})]}),U&&t.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:U}),t.jsx("button",{type:"submit",disabled:I,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg text-sm font-medium disabled:opacity-50",children:I?t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"animate-spin",size:14}),"Submitting…"]}):(u==null?void 0:u.buttonLabel)||"Save"})]})},_M=()=>{const[e]=Li(),r=(e.get("work_order")||"").trim(),a="/assets/asm_ui_app/asm_app/",n=`${a}${a.endsWith("/")?"":"/"}seera-logo.png`;return t.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-white to-indigo-50 dark:from-gray-900 dark:via-gray-900 dark:to-indigo-950 flex flex-col items-center justify-center p-4",children:t.jsxs("div",{className:"w-full max-w-md",children:[t.jsx("div",{className:"flex justify-center mb-6",children:t.jsx("img",{src:n,alt:"Logo",className:"h-10 object-contain",onError:i=>{i.target.style.display="none"}})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-2xl shadow-xl border border-gray-200 dark:border-gray-700 p-6 md:p-8",children:r?t.jsxs(t.Fragment,{children:[t.jsx("h1",{className:"text-lg font-bold text-gray-900 dark:text-white mb-1 text-center",children:"Work Order Feedback"}),t.jsx(vM,{workOrder:r})]}):t.jsxs("div",{className:"text-center py-6",children:[t.jsx("h1",{className:"text-lg font-bold text-gray-900 dark:text-white mb-2",children:"Work Order Feedback"}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"A work order link is required. Please use the link shared with you, for example:"}),t.jsx("p",{className:"mt-3 text-xs font-mono text-indigo-600 dark:text-indigo-400 break-all",children:"/asm_app/wo-feedback?work_order=WO-00001"})]})})]})})};function I3(e,r){return function(){return e.apply(r,arguments)}}const{toString:wM}=Object.prototype,{getPrototypeOf:Jp}=Object,{iterator:um,toStringTag:P3}=Symbol,hm=(e=>r=>{const a=wM.call(r);return e[a]||(e[a]=a.slice(8,-1).toLowerCase())})(Object.create(null)),no=e=>(e=e.toLowerCase(),r=>hm(r)===e),fm=e=>r=>typeof r===e,{isArray:r0}=Array,Gd=fm("undefined");function Du(e){return e!==null&&!Gd(e)&&e.constructor!==null&&!Gd(e.constructor)&&Ys(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const F3=no("ArrayBuffer");function kM(e){let r;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?r=ArrayBuffer.isView(e):r=e&&e.buffer&&F3(e.buffer),r}const NM=fm("string"),Ys=fm("function"),B3=fm("number"),Lu=e=>e!==null&&typeof e=="object",SM=e=>e===!0||e===!1,mf=e=>{if(hm(e)!=="object")return!1;const r=Jp(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(P3 in e)&&!(um in e)},CM=e=>{if(!Lu(e)||Du(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch(r){return!1}},EM=no("Date"),jM=no("File"),TM=no("Blob"),AM=no("FileList"),OM=e=>Lu(e)&&Ys(e.pipe),RM=e=>{let r;return e&&(typeof FormData=="function"&&e instanceof FormData||Ys(e.append)&&((r=hm(e))==="formdata"||r==="object"&&Ys(e.toString)&&e.toString()==="[object FormData]"))},MM=no("URLSearchParams"),[DM,LM,IM,PM]=["ReadableStream","Request","Response","Headers"].map(no),FM=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Iu(e,r,{allOwnKeys:a=!1}={}){if(e===null||typeof e=="undefined")return;let n,i;if(typeof e!="object"&&(e=[e]),r0(e))for(n=0,i=e.length;n<i;n++)r.call(null,e[n],n,e);else{if(Du(e))return;const c=a?Object.getOwnPropertyNames(e):Object.keys(e),u=c.length;let g;for(n=0;n<u;n++)g=c[n],r.call(null,e[g],g,e)}}function U3(e,r){if(Du(e))return null;r=r.toLowerCase();const a=Object.keys(e);let n=a.length,i;for(;n-- >0;)if(i=a[n],r===i.toLowerCase())return i;return null}const wc=typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:global,z3=e=>!Gd(e)&&e!==wc;function sp(){const{caseless:e,skipUndefined:r}=z3(this)&&this||{},a={},n=(i,c)=>{const u=e&&U3(a,c)||c;mf(a[u])&&mf(i)?a[u]=sp(a[u],i):mf(i)?a[u]=sp({},i):r0(i)?a[u]=i.slice():(!r||!Gd(i))&&(a[u]=i)};for(let i=0,c=arguments.length;i<c;i++)arguments[i]&&Iu(arguments[i],n);return a}const BM=(e,r,a,{allOwnKeys:n}={})=>(Iu(r,(i,c)=>{a&&Ys(i)?e[c]=I3(i,a):e[c]=i},{allOwnKeys:n}),e),UM=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),zM=(e,r,a,n)=>{e.prototype=Object.create(r.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:r.prototype}),a&&Object.assign(e.prototype,a)},HM=(e,r,a,n)=>{let i,c,u;const g={};if(r=r||{},e==null)return r;do{for(i=Object.getOwnPropertyNames(e),c=i.length;c-- >0;)u=i[c],(!n||n(u,e,r))&&!g[u]&&(r[u]=e[u],g[u]=!0);e=a!==!1&&Jp(e)}while(e&&(!a||a(e,r))&&e!==Object.prototype);return r},VM=(e,r,a)=>{e=String(e),(a===void 0||a>e.length)&&(a=e.length),a-=r.length;const n=e.indexOf(r,a);return n!==-1&&n===a},WM=e=>{if(!e)return null;if(r0(e))return e;let r=e.length;if(!B3(r))return null;const a=new Array(r);for(;r-- >0;)a[r]=e[r];return a},GM=(e=>r=>e&&r instanceof e)(typeof Uint8Array!="undefined"&&Jp(Uint8Array)),$M=(e,r)=>{const n=(e&&e[um]).call(e);let i;for(;(i=n.next())&&!i.done;){const c=i.value;r.call(e,c[0],c[1])}},XM=(e,r)=>{let a;const n=[];for(;(a=e.exec(r))!==null;)n.push(a);return n},YM=no("HTMLFormElement"),ZM=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(a,n,i){return n.toUpperCase()+i}),Qv=(({hasOwnProperty:e})=>(r,a)=>e.call(r,a))(Object.prototype),qM=no("RegExp"),H3=(e,r)=>{const a=Object.getOwnPropertyDescriptors(e),n={};Iu(a,(i,c)=>{let u;(u=r(i,c,e))!==!1&&(n[c]=u||i)}),Object.defineProperties(e,n)},KM=e=>{H3(e,(r,a)=>{if(Ys(e)&&["arguments","caller","callee"].indexOf(a)!==-1)return!1;const n=e[a];if(Ys(n)){if(r.enumerable=!1,"writable"in r){r.writable=!1;return}r.set||(r.set=()=>{throw Error("Can not rewrite read-only method '"+a+"'")})}})},JM=(e,r)=>{const a={},n=i=>{i.forEach(c=>{a[c]=!0})};return r0(e)?n(e):n(String(e).split(r)),a},QM=()=>{},eD=(e,r)=>e!=null&&Number.isFinite(e=+e)?e:r;function tD(e){return!!(e&&Ys(e.append)&&e[P3]==="FormData"&&e[um])}const rD=e=>{const r=new Array(10),a=(n,i)=>{if(Lu(n)){if(r.indexOf(n)>=0)return;if(Du(n))return n;if(!("toJSON"in n)){r[i]=n;const c=r0(n)?[]:{};return Iu(n,(u,g)=>{const y=a(u,i+1);!Gd(y)&&(c[g]=y)}),r[i]=void 0,c}}return n};return a(e,0)},aD=no("AsyncFunction"),nD=e=>e&&(Lu(e)||Ys(e))&&Ys(e.then)&&Ys(e.catch),V3=((e,r)=>e?setImmediate:r?((a,n)=>(wc.addEventListener("message",({source:i,data:c})=>{i===wc&&c===a&&n.length&&n.shift()()},!1),i=>{n.push(i),wc.postMessage(a,"*")}))(`axios@${Math.random()}`,[]):a=>setTimeout(a))(typeof setImmediate=="function",Ys(wc.postMessage)),sD=typeof queueMicrotask!="undefined"?queueMicrotask.bind(wc):typeof process!="undefined"&&process.nextTick||V3,iD=e=>e!=null&&Ys(e[um]),gt={isArray:r0,isArrayBuffer:F3,isBuffer:Du,isFormData:RM,isArrayBufferView:kM,isString:NM,isNumber:B3,isBoolean:SM,isObject:Lu,isPlainObject:mf,isEmptyObject:CM,isReadableStream:DM,isRequest:LM,isResponse:IM,isHeaders:PM,isUndefined:Gd,isDate:EM,isFile:jM,isBlob:TM,isRegExp:qM,isFunction:Ys,isStream:OM,isURLSearchParams:MM,isTypedArray:GM,isFileList:AM,forEach:Iu,merge:sp,extend:BM,trim:FM,stripBOM:UM,inherits:zM,toFlatObject:HM,kindOf:hm,kindOfTest:no,endsWith:VM,toArray:WM,forEachEntry:$M,matchAll:XM,isHTMLForm:YM,hasOwnProperty:Qv,hasOwnProp:Qv,reduceDescriptors:H3,freezeMethods:KM,toObjectSet:JM,toCamelCase:ZM,noop:QM,toFiniteNumber:eD,findKey:U3,global:wc,isContextDefined:z3,isSpecCompliantForm:tD,toJSONObject:rD,isAsyncFn:aD,isThenable:nD,setImmediate:V3,asap:sD,isIterable:iD};function $r(e,r,a,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",r&&(this.code=r),a&&(this.config=a),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}gt.inherits($r,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:gt.toJSONObject(this.config),code:this.code,status:this.status}}});const W3=$r.prototype,G3={};["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(e=>{G3[e]={value:e}});Object.defineProperties($r,G3);Object.defineProperty(W3,"isAxiosError",{value:!0});$r.from=(e,r,a,n,i,c)=>{const u=Object.create(W3);gt.toFlatObject(e,u,function(k){return k!==Error.prototype},x=>x!=="isAxiosError");const g=e&&e.message?e.message:"Error",y=r==null&&e?e.code:r;return $r.call(u,g,y,a,n,i),e&&u.cause==null&&Object.defineProperty(u,"cause",{value:e,configurable:!0}),u.name=e&&e.name||"Error",c&&Object.assign(u,c),u};const oD=null;function ip(e){return gt.isPlainObject(e)||gt.isArray(e)}function $3(e){return gt.endsWith(e,"[]")?e.slice(0,-2):e}function e_(e,r,a){return e?e.concat(r).map(function(i,c){return i=$3(i),!a&&c?"["+i+"]":i}).join(a?".":""):r}function lD(e){return gt.isArray(e)&&!e.some(ip)}const cD=gt.toFlatObject(gt,{},null,function(r){return/^is[A-Z]/.test(r)});function mm(e,r,a){if(!gt.isObject(e))throw new TypeError("target must be an object");r=r||new FormData,a=gt.toFlatObject(a,{metaTokens:!0,dots:!1,indexes:!1},!1,function(A,I){return!gt.isUndefined(I[A])});const n=a.metaTokens,i=a.visitor||k,c=a.dots,u=a.indexes,y=(a.Blob||typeof Blob!="undefined"&&Blob)&>.isSpecCompliantForm(r);if(!gt.isFunction(i))throw new TypeError("visitor must be a function");function x(D){if(D===null)return"";if(gt.isDate(D))return D.toISOString();if(gt.isBoolean(D))return D.toString();if(!y&>.isBlob(D))throw new $r("Blob is not supported. Use a Buffer instead.");return gt.isArrayBuffer(D)||gt.isTypedArray(D)?y&&typeof Blob=="function"?new Blob([D]):Buffer.from(D):D}function k(D,A,I){let z=D;if(D&&!I&&typeof D=="object"){if(gt.endsWith(A,"{}"))A=n?A:A.slice(0,-2),D=JSON.stringify(D);else if(gt.isArray(D)&&lD(D)||(gt.isFileList(D)||gt.endsWith(A,"[]"))&&(z=gt.toArray(D)))return A=$3(A),z.forEach(function(B,V){!(gt.isUndefined(B)||B===null)&&r.append(u===!0?e_([A],V,c):u===null?A:A+"[]",x(B))}),!1}return ip(D)?!0:(r.append(e_(I,A,c),x(D)),!1)}const N=[],C=Object.assign(cD,{defaultVisitor:k,convertValue:x,isVisitable:ip});function O(D,A){if(!gt.isUndefined(D)){if(N.indexOf(D)!==-1)throw Error("Circular reference detected in "+A.join("."));N.push(D),gt.forEach(D,function(z,U){(!(gt.isUndefined(z)||z===null)&&i.call(r,z,gt.isString(U)?U.trim():U,A,C))===!0&&O(z,A?A.concat(U):[U])}),N.pop()}}if(!gt.isObject(e))throw new TypeError("data must be an object");return O(e),r}function t_(e){const r={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return r[n]})}function Qp(e,r){this._pairs=[],e&&mm(e,this,r)}const X3=Qp.prototype;X3.append=function(r,a){this._pairs.push([r,a])};X3.toString=function(r){const a=r?function(n){return r.call(this,n,t_)}:t_;return this._pairs.map(function(i){return a(i[0])+"="+a(i[1])},"").join("&")};function dD(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Y3(e,r,a){if(!r)return e;const n=a&&a.encode||dD;gt.isFunction(a)&&(a={serialize:a});const i=a&&a.serialize;let c;if(i?c=i(r,a):c=gt.isURLSearchParams(r)?r.toString():new Qp(r,a).toString(n),c){const u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+c}return e}class r_{constructor(){this.handlers=[]}use(r,a,n){return this.handlers.push({fulfilled:r,rejected:a,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(r){this.handlers[r]&&(this.handlers[r]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(r){gt.forEach(this.handlers,function(n){n!==null&&r(n)})}}const Z3={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},uD=typeof URLSearchParams!="undefined"?URLSearchParams:Qp,hD=typeof FormData!="undefined"?FormData:null,fD=typeof Blob!="undefined"?Blob:null,mD={isBrowser:!0,classes:{URLSearchParams:uD,FormData:hD,Blob:fD},protocols:["http","https","file","blob","url","data"]},e1=typeof window!="undefined"&&typeof document!="undefined",op=typeof navigator=="object"&&navigator||void 0,gD=e1&&(!op||["ReactNative","NativeScript","NS"].indexOf(op.product)<0),xD=typeof WorkerGlobalScope!="undefined"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",pD=e1&&window.location.href||"http://localhost",yD=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:e1,hasStandardBrowserEnv:gD,hasStandardBrowserWebWorkerEnv:xD,navigator:op,origin:pD},Symbol.toStringTag,{value:"Module"})),ys=_e(_e({},yD),mD);function bD(e,r){return mm(e,new ys.classes.URLSearchParams,_e({visitor:function(a,n,i,c){return ys.isNode&>.isBuffer(a)?(this.append(n,a.toString("base64")),!1):c.defaultVisitor.apply(this,arguments)}},r))}function vD(e){return gt.matchAll(/\w+|\[(\w*)]/g,e).map(r=>r[0]==="[]"?"":r[1]||r[0])}function _D(e){const r={},a=Object.keys(e);let n;const i=a.length;let c;for(n=0;n<i;n++)c=a[n],r[c]=e[c];return r}function q3(e){function r(a,n,i,c){let u=a[c++];if(u==="__proto__")return!0;const g=Number.isFinite(+u),y=c>=a.length;return u=!u&>.isArray(i)?i.length:u,y?(gt.hasOwnProp(i,u)?i[u]=[i[u],n]:i[u]=n,!g):((!i[u]||!gt.isObject(i[u]))&&(i[u]=[]),r(a,n,i[u],c)&>.isArray(i[u])&&(i[u]=_D(i[u])),!g)}if(gt.isFormData(e)&>.isFunction(e.entries)){const a={};return gt.forEachEntry(e,(n,i)=>{r(vD(n),i,a,0)}),a}return null}function wD(e,r,a){if(gt.isString(e))try{return(r||JSON.parse)(e),gt.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(a||JSON.stringify)(e)}const Pu={transitional:Z3,adapter:["xhr","http","fetch"],transformRequest:[function(r,a){const n=a.getContentType()||"",i=n.indexOf("application/json")>-1,c=gt.isObject(r);if(c&>.isHTMLForm(r)&&(r=new FormData(r)),gt.isFormData(r))return i?JSON.stringify(q3(r)):r;if(gt.isArrayBuffer(r)||gt.isBuffer(r)||gt.isStream(r)||gt.isFile(r)||gt.isBlob(r)||gt.isReadableStream(r))return r;if(gt.isArrayBufferView(r))return r.buffer;if(gt.isURLSearchParams(r))return a.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),r.toString();let g;if(c){if(n.indexOf("application/x-www-form-urlencoded")>-1)return bD(r,this.formSerializer).toString();if((g=gt.isFileList(r))||n.indexOf("multipart/form-data")>-1){const y=this.env&&this.env.FormData;return mm(g?{"files[]":r}:r,y&&new y,this.formSerializer)}}return c||i?(a.setContentType("application/json",!1),wD(r)):r}],transformResponse:[function(r){const a=this.transitional||Pu.transitional,n=a&&a.forcedJSONParsing,i=this.responseType==="json";if(gt.isResponse(r)||gt.isReadableStream(r))return r;if(r&>.isString(r)&&(n&&!this.responseType||i)){const u=!(a&&a.silentJSONParsing)&&i;try{return JSON.parse(r,this.parseReviver)}catch(g){if(u)throw g.name==="SyntaxError"?$r.from(g,$r.ERR_BAD_RESPONSE,this,null,this.response):g}}return r}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ys.classes.FormData,Blob:ys.classes.Blob},validateStatus:function(r){return r>=200&&r<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};gt.forEach(["delete","get","head","post","put","patch"],e=>{Pu.headers[e]={}});const kD=gt.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"]),ND=e=>{const r={};let a,n,i;return e&&e.split(`
|
||
`).forEach(function(u){i=u.indexOf(":"),a=u.substring(0,i).trim().toLowerCase(),n=u.substring(i+1).trim(),!(!a||r[a]&&kD[a])&&(a==="set-cookie"?r[a]?r[a].push(n):r[a]=[n]:r[a]=r[a]?r[a]+", "+n:n)}),r},a_=Symbol("internals");function Y0(e){return e&&String(e).trim().toLowerCase()}function gf(e){return e===!1||e==null?e:gt.isArray(e)?e.map(gf):String(e)}function SD(e){const r=Object.create(null),a=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=a.exec(e);)r[n[1]]=n[2];return r}const CD=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ix(e,r,a,n,i){if(gt.isFunction(n))return n.call(this,r,a);if(i&&(r=a),!!gt.isString(r)){if(gt.isString(n))return r.indexOf(n)!==-1;if(gt.isRegExp(n))return n.test(r)}}function ED(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(r,a,n)=>a.toUpperCase()+n)}function jD(e,r){const a=gt.toCamelCase(" "+r);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+a,{value:function(i,c,u){return this[n].call(this,r,i,c,u)},configurable:!0})})}let Zs=class{constructor(r){r&&this.set(r)}set(r,a,n){const i=this;function c(g,y,x){const k=Y0(y);if(!k)throw new Error("header name must be a non-empty string");const N=gt.findKey(i,k);(!N||i[N]===void 0||x===!0||x===void 0&&i[N]!==!1)&&(i[N||y]=gf(g))}const u=(g,y)=>gt.forEach(g,(x,k)=>c(x,k,y));if(gt.isPlainObject(r)||r instanceof this.constructor)u(r,a);else if(gt.isString(r)&&(r=r.trim())&&!CD(r))u(ND(r),a);else if(gt.isObject(r)&>.isIterable(r)){let g={},y,x;for(const k of r){if(!gt.isArray(k))throw TypeError("Object iterator must return a key-value pair");g[x=k[0]]=(y=g[x])?gt.isArray(y)?[...y,k[1]]:[y,k[1]]:k[1]}u(g,a)}else r!=null&&c(a,r,n);return this}get(r,a){if(r=Y0(r),r){const n=gt.findKey(this,r);if(n){const i=this[n];if(!a)return i;if(a===!0)return SD(i);if(gt.isFunction(a))return a.call(this,i,n);if(gt.isRegExp(a))return a.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(r,a){if(r=Y0(r),r){const n=gt.findKey(this,r);return!!(n&&this[n]!==void 0&&(!a||Ix(this,this[n],n,a)))}return!1}delete(r,a){const n=this;let i=!1;function c(u){if(u=Y0(u),u){const g=gt.findKey(n,u);g&&(!a||Ix(n,n[g],g,a))&&(delete n[g],i=!0)}}return gt.isArray(r)?r.forEach(c):c(r),i}clear(r){const a=Object.keys(this);let n=a.length,i=!1;for(;n--;){const c=a[n];(!r||Ix(this,this[c],c,r,!0))&&(delete this[c],i=!0)}return i}normalize(r){const a=this,n={};return gt.forEach(this,(i,c)=>{const u=gt.findKey(n,c);if(u){a[u]=gf(i),delete a[c];return}const g=r?ED(c):String(c).trim();g!==c&&delete a[c],a[g]=gf(i),n[g]=!0}),this}concat(...r){return this.constructor.concat(this,...r)}toJSON(r){const a=Object.create(null);return gt.forEach(this,(n,i)=>{n!=null&&n!==!1&&(a[i]=r&>.isArray(n)?n.join(", "):n)}),a}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([r,a])=>r+": "+a).join(`
|
||
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(r){return r instanceof this?r:new this(r)}static concat(r,...a){const n=new this(r);return a.forEach(i=>n.set(i)),n}static accessor(r){const n=(this[a_]=this[a_]={accessors:{}}).accessors,i=this.prototype;function c(u){const g=Y0(u);n[g]||(jD(i,u),n[g]=!0)}return gt.isArray(r)?r.forEach(c):c(r),this}};Zs.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);gt.reduceDescriptors(Zs.prototype,({value:e},r)=>{let a=r[0].toUpperCase()+r.slice(1);return{get:()=>e,set(n){this[a]=n}}});gt.freezeMethods(Zs);function Px(e,r){const a=this||Pu,n=r||a,i=Zs.from(n.headers);let c=n.data;return gt.forEach(e,function(g){c=g.call(a,c,i.normalize(),r?r.status:void 0)}),i.normalize(),c}function K3(e){return!!(e&&e.__CANCEL__)}function a0(e,r,a){$r.call(this,e==null?"canceled":e,$r.ERR_CANCELED,r,a),this.name="CanceledError"}gt.inherits(a0,$r,{__CANCEL__:!0});function J3(e,r,a){const n=a.config.validateStatus;!a.status||!n||n(a.status)?e(a):r(new $r("Request failed with status code "+a.status,[$r.ERR_BAD_REQUEST,$r.ERR_BAD_RESPONSE][Math.floor(a.status/100)-4],a.config,a.request,a))}function TD(e){const r=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return r&&r[1]||""}function AD(e,r){e=e||10;const a=new Array(e),n=new Array(e);let i=0,c=0,u;return r=r!==void 0?r:1e3,function(y){const x=Date.now(),k=n[c];u||(u=x),a[i]=y,n[i]=x;let N=c,C=0;for(;N!==i;)C+=a[N++],N=N%e;if(i=(i+1)%e,i===c&&(c=(c+1)%e),x-u<r)return;const O=k&&x-k;return O?Math.round(C*1e3/O):void 0}}function OD(e,r){let a=0,n=1e3/r,i,c;const u=(x,k=Date.now())=>{a=k,i=null,c&&(clearTimeout(c),c=null),e(...x)};return[(...x)=>{const k=Date.now(),N=k-a;N>=n?u(x,k):(i=x,c||(c=setTimeout(()=>{c=null,u(i)},n-N)))},()=>i&&u(i)]}const Hf=(e,r,a=3)=>{let n=0;const i=AD(50,250);return OD(c=>{const u=c.loaded,g=c.lengthComputable?c.total:void 0,y=u-n,x=i(y),k=u<=g;n=u;const N={loaded:u,total:g,progress:g?u/g:void 0,bytes:y,rate:x||void 0,estimated:x&&g&&k?(g-u)/x:void 0,event:c,lengthComputable:g!=null,[r?"download":"upload"]:!0};e(N)},a)},n_=(e,r)=>{const a=e!=null;return[n=>r[0]({lengthComputable:a,total:e,loaded:n}),r[1]]},s_=e=>(...r)=>gt.asap(()=>e(...r)),RD=ys.hasStandardBrowserEnv?((e,r)=>a=>(a=new URL(a,ys.origin),e.protocol===a.protocol&&e.host===a.host&&(r||e.port===a.port)))(new URL(ys.origin),ys.navigator&&/(msie|trident)/i.test(ys.navigator.userAgent)):()=>!0,MD=ys.hasStandardBrowserEnv?{write(e,r,a,n,i,c,u){if(typeof document=="undefined")return;const g=[`${e}=${encodeURIComponent(r)}`];gt.isNumber(a)&&g.push(`expires=${new Date(a).toUTCString()}`),gt.isString(n)&&g.push(`path=${n}`),gt.isString(i)&&g.push(`domain=${i}`),c===!0&&g.push("secure"),gt.isString(u)&&g.push(`SameSite=${u}`),document.cookie=g.join("; ")},read(e){if(typeof document=="undefined")return null;const r=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return r?decodeURIComponent(r[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function DD(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function LD(e,r){return r?e.replace(/\/?\/$/,"")+"/"+r.replace(/^\/+/,""):e}function Q3(e,r,a){let n=!DD(r);return e&&(n||a==!1)?LD(e,r):r}const i_=e=>e instanceof Zs?_e({},e):e;function Rc(e,r){r=r||{};const a={};function n(x,k,N,C){return gt.isPlainObject(x)&>.isPlainObject(k)?gt.merge.call({caseless:C},x,k):gt.isPlainObject(k)?gt.merge({},k):gt.isArray(k)?k.slice():k}function i(x,k,N,C){if(gt.isUndefined(k)){if(!gt.isUndefined(x))return n(void 0,x,N,C)}else return n(x,k,N,C)}function c(x,k){if(!gt.isUndefined(k))return n(void 0,k)}function u(x,k){if(gt.isUndefined(k)){if(!gt.isUndefined(x))return n(void 0,x)}else return n(void 0,k)}function g(x,k,N){if(N in r)return n(x,k);if(N in e)return n(void 0,x)}const y={url:c,method:c,data:c,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:g,headers:(x,k,N)=>i(i_(x),i_(k),N,!0)};return gt.forEach(Object.keys(_e(_e({},e),r)),function(k){const N=y[k]||i,C=N(e[k],r[k],k);gt.isUndefined(C)&&N!==g||(a[k]=C)}),a}const ek=e=>{const r=Rc({},e);let{data:a,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:c,headers:u,auth:g}=r;if(r.headers=u=Zs.from(u),r.url=Y3(Q3(r.baseURL,r.url,r.allowAbsoluteUrls),e.params,e.paramsSerializer),g&&u.set("Authorization","Basic "+btoa((g.username||"")+":"+(g.password?unescape(encodeURIComponent(g.password)):""))),gt.isFormData(a)){if(ys.hasStandardBrowserEnv||ys.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if(gt.isFunction(a.getHeaders)){const y=a.getHeaders(),x=["content-type","content-length"];Object.entries(y).forEach(([k,N])=>{x.includes(k.toLowerCase())&&u.set(k,N)})}}if(ys.hasStandardBrowserEnv&&(n&>.isFunction(n)&&(n=n(r)),n||n!==!1&&RD(r.url))){const y=i&&c&&MD.read(c);y&&u.set(i,y)}return r},ID=typeof XMLHttpRequest!="undefined",PD=ID&&function(e){return new Promise(function(a,n){const i=ek(e);let c=i.data;const u=Zs.from(i.headers).normalize();let{responseType:g,onUploadProgress:y,onDownloadProgress:x}=i,k,N,C,O,D;function A(){O&&O(),D&&D(),i.cancelToken&&i.cancelToken.unsubscribe(k),i.signal&&i.signal.removeEventListener("abort",k)}let I=new XMLHttpRequest;I.open(i.method.toUpperCase(),i.url,!0),I.timeout=i.timeout;function z(){if(!I)return;const B=Zs.from("getAllResponseHeaders"in I&&I.getAllResponseHeaders()),Z={data:!g||g==="text"||g==="json"?I.responseText:I.response,status:I.status,statusText:I.statusText,headers:B,config:e,request:I};J3(function(H){a(H),A()},function(H){n(H),A()},Z),I=null}"onloadend"in I?I.onloadend=z:I.onreadystatechange=function(){!I||I.readyState!==4||I.status===0&&!(I.responseURL&&I.responseURL.indexOf("file:")===0)||setTimeout(z)},I.onabort=function(){I&&(n(new $r("Request aborted",$r.ECONNABORTED,e,I)),I=null)},I.onerror=function(V){const Z=V&&V.message?V.message:"Network Error",W=new $r(Z,$r.ERR_NETWORK,e,I);W.event=V||null,n(W),I=null},I.ontimeout=function(){let V=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const Z=i.transitional||Z3;i.timeoutErrorMessage&&(V=i.timeoutErrorMessage),n(new $r(V,Z.clarifyTimeoutError?$r.ETIMEDOUT:$r.ECONNABORTED,e,I)),I=null},c===void 0&&u.setContentType(null),"setRequestHeader"in I&>.forEach(u.toJSON(),function(V,Z){I.setRequestHeader(Z,V)}),gt.isUndefined(i.withCredentials)||(I.withCredentials=!!i.withCredentials),g&&g!=="json"&&(I.responseType=i.responseType),x&&([C,D]=Hf(x,!0),I.addEventListener("progress",C)),y&&I.upload&&([N,O]=Hf(y),I.upload.addEventListener("progress",N),I.upload.addEventListener("loadend",O)),(i.cancelToken||i.signal)&&(k=B=>{I&&(n(!B||B.type?new a0(null,e,I):B),I.abort(),I=null)},i.cancelToken&&i.cancelToken.subscribe(k),i.signal&&(i.signal.aborted?k():i.signal.addEventListener("abort",k)));const U=TD(i.url);if(U&&ys.protocols.indexOf(U)===-1){n(new $r("Unsupported protocol "+U+":",$r.ERR_BAD_REQUEST,e));return}I.send(c||null)})},FD=(e,r)=>{const{length:a}=e=e?e.filter(Boolean):[];if(r||a){let n=new AbortController,i;const c=function(x){if(!i){i=!0,g();const k=x instanceof Error?x:this.reason;n.abort(k instanceof $r?k:new a0(k instanceof Error?k.message:k))}};let u=r&&setTimeout(()=>{u=null,c(new $r(`timeout ${r} of ms exceeded`,$r.ETIMEDOUT))},r);const g=()=>{e&&(u&&clearTimeout(u),u=null,e.forEach(x=>{x.unsubscribe?x.unsubscribe(c):x.removeEventListener("abort",c)}),e=null)};e.forEach(x=>x.addEventListener("abort",c));const{signal:y}=n;return y.unsubscribe=()=>gt.asap(g),y}},BD=function*(e,r){let a=e.byteLength;if(a<r){yield e;return}let n=0,i;for(;n<a;)i=n+r,yield e.slice(n,i),n=i},UD=function(e,r){return sx(this,null,function*(){try{for(var a=d2(zD(e)),n,i,c;n=!(i=yield new yc(a.next())).done;n=!1){const u=i.value;yield*ix(BD(u,r))}}catch(i){c=[i]}finally{try{n&&(i=a.return)&&(yield new yc(i.call(a)))}finally{if(c)throw c[0]}}})},zD=function(e){return sx(this,null,function*(){if(e[Symbol.asyncIterator]){yield*ix(e);return}const r=e.getReader();try{for(;;){const{done:a,value:n}=yield new yc(r.read());if(a)break;yield n}}finally{yield new yc(r.cancel())}})},o_=(e,r,a,n)=>{const i=UD(e,r);let c=0,u,g=x=>{u||(u=!0,n&&n(x))};return new ReadableStream({pull(x){return xe(this,null,function*(){try{const{done:k,value:N}=yield i.next();if(k){g(),x.close();return}let C=N.byteLength;if(a){let O=c+=C;a(O)}x.enqueue(new Uint8Array(N))}catch(k){throw g(k),k}})},cancel(x){return g(x),i.return()}},{highWaterMark:2})},l_=64*1024,{isFunction:sf}=gt,HD=(({Request:e,Response:r})=>({Request:e,Response:r}))(gt.global),{ReadableStream:c_,TextEncoder:d_}=gt.global,u_=(e,...r)=>{try{return!!e(...r)}catch(a){return!1}},VD=e=>{e=gt.merge.call({skipUndefined:!0},HD,e);const{fetch:r,Request:a,Response:n}=e,i=r?sf(r):typeof fetch=="function",c=sf(a),u=sf(n);if(!i)return!1;const g=i&&sf(c_),y=i&&(typeof d_=="function"?(D=>A=>D.encode(A))(new d_):D=>xe(null,null,function*(){return new Uint8Array(yield new a(D).arrayBuffer())})),x=c&&g&&u_(()=>{let D=!1;const A=new a(ys.origin,{body:new c_,method:"POST",get duplex(){return D=!0,"half"}}).headers.has("Content-Type");return D&&!A}),k=u&&g&&u_(()=>gt.isReadableStream(new n("").body)),N={stream:k&&(D=>D.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(D=>{!N[D]&&(N[D]=(A,I)=>{let z=A&&A[D];if(z)return z.call(A);throw new $r(`Response type '${D}' is not supported`,$r.ERR_NOT_SUPPORT,I)})});const C=D=>xe(null,null,function*(){if(D==null)return 0;if(gt.isBlob(D))return D.size;if(gt.isSpecCompliantForm(D))return(yield new a(ys.origin,{method:"POST",body:D}).arrayBuffer()).byteLength;if(gt.isArrayBufferView(D)||gt.isArrayBuffer(D))return D.byteLength;if(gt.isURLSearchParams(D)&&(D=D+""),gt.isString(D))return(yield y(D)).byteLength}),O=(D,A)=>xe(null,null,function*(){const I=gt.toFiniteNumber(D.getContentLength());return I==null?C(A):I});return D=>xe(null,null,function*(){let{url:A,method:I,data:z,signal:U,cancelToken:B,timeout:V,onDownloadProgress:Z,onUploadProgress:W,responseType:H,headers:le,withCredentials:Q="same-origin",fetchOptions:Ne}=ek(D),oe=r||fetch;H=H?(H+"").toLowerCase():"text";let se=FD([U,B&&B.toAbortSignal()],V),ce=null;const Ce=se&&se.unsubscribe&&(()=>{se.unsubscribe()});let ae;try{if(W&&x&&I!=="get"&&I!=="head"&&(ae=yield O(le,z))!==0){let J=new a(A,{method:"POST",body:z,duplex:"half"}),G;if(gt.isFormData(z)&&(G=J.headers.get("content-type"))&&le.setContentType(G),J.body){const[ie,re]=n_(ae,Hf(s_(W)));z=o_(J.body,l_,ie,re)}}gt.isString(Q)||(Q=Q?"include":"omit");const me=c&&"credentials"in a.prototype,K=$e(_e({},Ne),{signal:se,method:I.toUpperCase(),headers:le.normalize().toJSON(),body:z,duplex:"half",credentials:me?Q:void 0});ce=c&&new a(A,K);let fe=yield c?oe(ce,Ne):oe(A,K);const Oe=k&&(H==="stream"||H==="response");if(k&&(Z||Oe&&Ce)){const J={};["status","statusText","headers"].forEach(ne=>{J[ne]=fe[ne]});const G=gt.toFiniteNumber(fe.headers.get("content-length")),[ie,re]=Z&&n_(G,Hf(s_(Z),!0))||[];fe=new n(o_(fe.body,l_,ie,()=>{re&&re(),Ce&&Ce()}),J)}H=H||"text";let ye=yield N[gt.findKey(N,H)||"text"](fe,D);return!Oe&&Ce&&Ce(),yield new Promise((J,G)=>{J3(J,G,{data:ye,headers:Zs.from(fe.headers),status:fe.status,statusText:fe.statusText,config:D,request:ce})})}catch(me){throw Ce&&Ce(),me&&me.name==="TypeError"&&/Load failed|fetch/i.test(me.message)?Object.assign(new $r("Network Error",$r.ERR_NETWORK,D,ce),{cause:me.cause||me}):$r.from(me,me&&me.code,D,ce)}})},WD=new Map,tk=e=>{let r=e&&e.env||{};const{fetch:a,Request:n,Response:i}=r,c=[n,i,a];let u=c.length,g=u,y,x,k=WD;for(;g--;)y=c[g],x=k.get(y),x===void 0&&k.set(y,x=g?new Map:VD(r)),k=x;return x};tk();const t1={http:oD,xhr:PD,fetch:{get:tk}};gt.forEach(t1,(e,r)=>{if(e){try{Object.defineProperty(e,"name",{value:r})}catch(a){}Object.defineProperty(e,"adapterName",{value:r})}});const h_=e=>`- ${e}`,GD=e=>gt.isFunction(e)||e===null||e===!1;function $D(e,r){e=gt.isArray(e)?e:[e];const{length:a}=e;let n,i;const c={};for(let u=0;u<a;u++){n=e[u];let g;if(i=n,!GD(n)&&(i=t1[(g=String(n)).toLowerCase()],i===void 0))throw new $r(`Unknown adapter '${g}'`);if(i&&(gt.isFunction(i)||(i=i.get(r))))break;c[g||"#"+u]=i}if(!i){const u=Object.entries(c).map(([y,x])=>`adapter ${y} `+(x===!1?"is not supported by the environment":"is not available in the build"));let g=a?u.length>1?`since :
|
||
`+u.map(h_).join(`
|
||
`):" "+h_(u[0]):"as no adapter specified";throw new $r("There is no suitable adapter to dispatch the request "+g,"ERR_NOT_SUPPORT")}return i}const rk={getAdapter:$D,adapters:t1};function Fx(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new a0(null,e)}function f_(e){return Fx(e),e.headers=Zs.from(e.headers),e.data=Px.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),rk.getAdapter(e.adapter||Pu.adapter,e)(e).then(function(n){return Fx(e),n.data=Px.call(e,e.transformResponse,n),n.headers=Zs.from(n.headers),n},function(n){return K3(n)||(Fx(e),n&&n.response&&(n.response.data=Px.call(e,e.transformResponse,n.response),n.response.headers=Zs.from(n.response.headers))),Promise.reject(n)})}const ak="1.13.2",gm={};["object","boolean","number","function","string","symbol"].forEach((e,r)=>{gm[e]=function(n){return typeof n===e||"a"+(r<1?"n ":" ")+e}});const m_={};gm.transitional=function(r,a,n){function i(c,u){return"[Axios v"+ak+"] Transitional option '"+c+"'"+u+(n?". "+n:"")}return(c,u,g)=>{if(r===!1)throw new $r(i(u," has been removed"+(a?" in "+a:"")),$r.ERR_DEPRECATED);return a&&!m_[u]&&(m_[u]=!0,console.warn(i(u," has been deprecated since v"+a+" and will be removed in the near future"))),r?r(c,u,g):!0}};gm.spelling=function(r){return(a,n)=>(console.warn(`${n} is likely a misspelling of ${r}`),!0)};function XD(e,r,a){if(typeof e!="object")throw new $r("options must be an object",$r.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const c=n[i],u=r[c];if(u){const g=e[c],y=g===void 0||u(g,c,e);if(y!==!0)throw new $r("option "+c+" must be "+y,$r.ERR_BAD_OPTION_VALUE);continue}if(a!==!0)throw new $r("Unknown option "+c,$r.ERR_BAD_OPTION)}}const xf={assertOptions:XD,validators:gm},po=xf.validators;let Cc=class{constructor(r){this.defaults=r||{},this.interceptors={request:new r_,response:new r_}}request(r,a){return xe(this,null,function*(){try{return yield this._request(r,a)}catch(n){if(n instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const c=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?c&&!String(n.stack).endsWith(c.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
||
`+c):n.stack=c}catch(u){}}throw n}})}_request(r,a){typeof r=="string"?(a=a||{},a.url=r):a=r||{},a=Rc(this.defaults,a);const{transitional:n,paramsSerializer:i,headers:c}=a;n!==void 0&&xf.assertOptions(n,{silentJSONParsing:po.transitional(po.boolean),forcedJSONParsing:po.transitional(po.boolean),clarifyTimeoutError:po.transitional(po.boolean)},!1),i!=null&&(gt.isFunction(i)?a.paramsSerializer={serialize:i}:xf.assertOptions(i,{encode:po.function,serialize:po.function},!0)),a.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?a.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:a.allowAbsoluteUrls=!0),xf.assertOptions(a,{baseUrl:po.spelling("baseURL"),withXsrfToken:po.spelling("withXSRFToken")},!0),a.method=(a.method||this.defaults.method||"get").toLowerCase();let u=c&>.merge(c.common,c[a.method]);c&>.forEach(["delete","get","head","post","put","patch","common"],D=>{delete c[D]}),a.headers=Zs.concat(u,c);const g=[];let y=!0;this.interceptors.request.forEach(function(A){typeof A.runWhen=="function"&&A.runWhen(a)===!1||(y=y&&A.synchronous,g.unshift(A.fulfilled,A.rejected))});const x=[];this.interceptors.response.forEach(function(A){x.push(A.fulfilled,A.rejected)});let k,N=0,C;if(!y){const D=[f_.bind(this),void 0];for(D.unshift(...g),D.push(...x),C=D.length,k=Promise.resolve(a);N<C;)k=k.then(D[N++],D[N++]);return k}C=g.length;let O=a;for(;N<C;){const D=g[N++],A=g[N++];try{O=D(O)}catch(I){A.call(this,I);break}}try{k=f_.call(this,O)}catch(D){return Promise.reject(D)}for(N=0,C=x.length;N<C;)k=k.then(x[N++],x[N++]);return k}getUri(r){r=Rc(this.defaults,r);const a=Q3(r.baseURL,r.url,r.allowAbsoluteUrls);return Y3(a,r.params,r.paramsSerializer)}};gt.forEach(["delete","get","head","options"],function(r){Cc.prototype[r]=function(a,n){return this.request(Rc(n||{},{method:r,url:a,data:(n||{}).data}))}});gt.forEach(["post","put","patch"],function(r){function a(n){return function(c,u,g){return this.request(Rc(g||{},{method:r,headers:n?{"Content-Type":"multipart/form-data"}:{},url:c,data:u}))}}Cc.prototype[r]=a(),Cc.prototype[r+"Form"]=a(!0)});let YD=class nk{constructor(r){if(typeof r!="function")throw new TypeError("executor must be a function.");let a;this.promise=new Promise(function(c){a=c});const n=this;this.promise.then(i=>{if(!n._listeners)return;let c=n._listeners.length;for(;c-- >0;)n._listeners[c](i);n._listeners=null}),this.promise.then=i=>{let c;const u=new Promise(g=>{n.subscribe(g),c=g}).then(i);return u.cancel=function(){n.unsubscribe(c)},u},r(function(c,u,g){n.reason||(n.reason=new a0(c,u,g),a(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(r){if(this.reason){r(this.reason);return}this._listeners?this._listeners.push(r):this._listeners=[r]}unsubscribe(r){if(!this._listeners)return;const a=this._listeners.indexOf(r);a!==-1&&this._listeners.splice(a,1)}toAbortSignal(){const r=new AbortController,a=n=>{r.abort(n)};return this.subscribe(a),r.signal.unsubscribe=()=>this.unsubscribe(a),r.signal}static source(){let r;return{token:new nk(function(i){r=i}),cancel:r}}};function ZD(e){return function(a){return e.apply(null,a)}}function qD(e){return gt.isObject(e)&&e.isAxiosError===!0}const lp={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(lp).forEach(([e,r])=>{lp[r]=e});function sk(e){const r=new Cc(e),a=I3(Cc.prototype.request,r);return gt.extend(a,Cc.prototype,r,{allOwnKeys:!0}),gt.extend(a,r,null,{allOwnKeys:!0}),a.create=function(i){return sk(Rc(e,i))},a}const wn=sk(Pu);wn.Axios=Cc;wn.CanceledError=a0;wn.CancelToken=YD;wn.isCancel=K3;wn.VERSION=ak;wn.toFormData=mm;wn.AxiosError=$r;wn.Cancel=wn.CanceledError;wn.all=function(r){return Promise.all(r)};wn.spread=ZD;wn.isAxiosError=qD;wn.mergeConfig=Rc;wn.AxiosHeaders=Zs;wn.formToJSON=e=>q3(gt.isHTMLForm(e)?new FormData(e):e);wn.getAdapter=rk.getAdapter;wn.HttpStatusCode=lp;wn.default=wn;const{Axios:fB,AxiosError:mB,CanceledError:gB,isCancel:xB,CancelToken:pB,VERSION:yB,all:bB,Cancel:vB,isAxiosError:_B,spread:wB,toFormData:kB,AxiosHeaders:NB,HttpStatusCode:SB,formToJSON:CB,getAdapter:EB,mergeConfig:jB}=wn;class KD{constructor(){Ti(this,"client");Ti(this,"baseURL");Ti(this,"siteName");this.baseURL="http://localhost:8000",this.siteName="seeraasm-med.seeraarabia.com",this.client=wn.create({baseURL:this.baseURL,timeout:parseInt("10000"),withCredentials:!0,headers:{"Content-Type":"application/json",Accept:"application/json"}}),this.client.interceptors.request.use(r=>{var a;return(a=r.url)!=null&&a.includes("/api/")&&(r.url=`/${this.siteName}${r.url}`),r}),this.client.interceptors.response.use(r=>r,r=>{var a;return((a=r.response)==null?void 0:a.status)===401&&(window.location.href="/login"),Promise.reject(r)})}login(r){return xe(this,null,function*(){return(yield this.client.post("/api/method/login",r)).data})}logout(){return xe(this,null,function*(){return(yield this.client.post("/api/method/logout")).data})}getCurrentUser(){return xe(this,null,function*(){return(yield this.client.get("/api/method/frappe.auth.get_logged_user")).data})}callMethod(n){return xe(this,arguments,function*(r,a={}){return(yield this.client.post(`/api/method/${r}`,a)).data})}frappeGet(n){return xe(this,arguments,function*(r,a={}){return this.callMethod(r,a)})}getDocTypeRecords(i){return xe(this,arguments,function*(r,a={},n=[]){const c=new URLSearchParams;return Object.keys(a).length>0&&c.append("filters",JSON.stringify(a)),n.length>0&&c.append("fields",JSON.stringify(n)),(yield this.client.get(`/api/resource/${r}?${c.toString()}`)).data})}getDocTypeRecord(r,a){return xe(this,null,function*(){return(yield this.client.get(`/api/resource/${r}/${a}`)).data})}createDocTypeRecord(r,a){return xe(this,null,function*(){return(yield this.client.post(`/api/resource/${r}`,a)).data})}updateDocTypeRecord(r,a,n){return xe(this,null,function*(){return(yield this.client.put(`/api/resource/${r}/${a}`,n)).data})}deleteDocTypeRecord(r,a){return xe(this,null,function*(){return(yield this.client.delete(`/api/resource/${r}/${a}`)).data})}uploadFile(r,a="Home"){return xe(this,null,function*(){const n=new FormData;return n.append("file",r),n.append("folder",a),n.append("is_private","0"),(yield this.client.post("/api/method/upload_file",n,{headers:{"Content-Type":"multipart/form-data"}})).data})}}const ik=new KD,JD=()=>{const[e,r]=E.useState([]),[a,n]=E.useState(!0),[i,c]=E.useState(null),[u,g]=E.useState(""),y=ua();E.useEffect(()=>{x()},[]);const x=()=>xe(null,null,function*(){var C,O;try{n(!0);const D=yield ik.getDocTypeRecords("User",{},["name","full_name","email","enabled","creation","modified"]);r(D.message||[])}catch(D){c(((O=(C=D.response)==null?void 0:C.data)==null?void 0:O.message)||"Failed to load users")}finally{n(!1)}}),k=e.filter(C=>{var O,D,A;return((O=C.full_name)==null?void 0:O.toLowerCase().includes(u.toLowerCase()))||((D=C.email)==null?void 0:D.toLowerCase().includes(u.toLowerCase()))||((A=C.name)==null?void 0:A.toLowerCase().includes(u.toLowerCase()))}),N=C=>{y(`/users/${C.name}`)};return a?t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900",children:t.jsx("div",{className:"animate-spin rounded-full h-32 w-32 border-b-2 border-indigo-600"})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900",children:[t.jsx("header",{className:"bg-white dark:bg-gray-800 shadow",children:t.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex justify-between items-center py-6",children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx("button",{onClick:()=>y("/dashboard"),className:"mr-4 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300",children:t.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),t.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-gray-900 dark:text-white break-words",children:"Users"})]}),t.jsx("div",{className:"flex items-center space-x-4",children:t.jsx("button",{onClick:()=>y("/dashboard"),className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-md text-sm font-medium",children:"Back to Dashboard"})})]})})}),t.jsxs("main",{className:"max-w-7xl mx-auto py-6 sm:px-6 lg:px-8",children:[i&&t.jsx("div",{className:"mb-6 rounded-md bg-red-50 dark:bg-red-900/20 p-4",children:t.jsx("div",{className:"text-sm text-red-700 dark:text-red-400",children:i})}),t.jsxs("div",{className:"mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between",children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:t.jsx("svg",{className:"h-5 w-5 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),t.jsx("input",{type:"text",placeholder:"Search users...",value:u,onChange:C=>g(C.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"})]})}),t.jsx("div",{className:"mt-4 sm:mt-0 sm:ml-4",children:t.jsxs("button",{onClick:x,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:[t.jsx("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})}),"Refresh"]})})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow overflow-hidden sm:rounded-md",children:[t.jsxs("div",{className:"px-4 py-5 sm:px-6",children:[t.jsxs("h3",{className:"text-lg leading-6 font-medium text-gray-900 dark:text-white",children:["Users (",k.length,")"]}),t.jsx("p",{className:"mt-1 max-w-2xl text-sm text-gray-500 dark:text-gray-400",children:"Manage user accounts and permissions"})]}),k.length===0?t.jsxs("div",{className:"text-center py-12",children:[t.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:t.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"})}),t.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900 dark:text-white",children:"No users found"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:u?"Try adjusting your search terms.":"No users available."})]}):t.jsx("ul",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:k.map(C=>{var O;return t.jsx("li",{children:t.jsxs("div",{className:"px-4 py-4 flex items-center justify-between hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer",onClick:()=>N(C),children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0 h-10 w-10",children:t.jsx("div",{className:"h-10 w-10 rounded-full bg-indigo-100 dark:bg-indigo-900 flex items-center justify-center",children:t.jsx("span",{className:"text-sm font-medium text-indigo-600 dark:text-indigo-300",children:((O=C.full_name)==null?void 0:O.charAt(0))||C.name.charAt(0)})})}),t.jsxs("div",{className:"ml-4",children:[t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:C.full_name||C.name}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:C.email||"No email"})]})]}),t.jsxs("div",{className:"flex items-center space-x-4",children:[t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:`w-2 h-2 rounded-full mr-2 ${C.enabled?"bg-green-400":"bg-red-400"}`}),C.enabled?"Active":"Inactive"]})}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Created: ",new Date(C.creation).toLocaleDateString()]}),t.jsx("svg",{className:"w-5 h-5 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})]})},C.name)})})]})]})]})},QD=()=>{const[e,r]=E.useState([]),[a,n]=E.useState(!0),[i,c]=E.useState(null);E.useEffect(()=>{u()},[]);const u=()=>xe(null,null,function*(){try{n(!0);const k=yield ik.frappeGet("frappe.desk.doctype.event.event.get_events");r(k.message||[])}catch(k){console.log("API call failed, using demo events:",k);const N=[{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(N),c(null)}finally{n(!1)}}),g=k=>new Date(k).toLocaleString(),y=k=>{switch(k.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"}},x=k=>{switch(k.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 a?t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900",children:t.jsx("div",{className:"animate-spin rounded-full h-32 w-32 border-b-2 border-indigo-600"})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900",children:[t.jsx("header",{className:"bg-white dark:bg-gray-800 shadow",children:t.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex justify-between items-center py-6",children:[t.jsx("div",{className:"flex items-center",children:t.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-gray-900 dark:text-white break-words",children:"Events"})}),t.jsx("div",{className:"flex items-center space-x-4",children:t.jsx("button",{onClick:u,className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-md text-sm font-medium",children:"Refresh Events"})})]})})}),t.jsxs("main",{className:"max-w-7xl mx-auto py-6 sm:px-6 lg:px-8",children:[i&&t.jsx("div",{className:"mb-6 rounded-md bg-red-50 dark:bg-red-900/20 p-4",children:t.jsx("div",{className:"text-sm text-red-700 dark:text-red-400",children:i})}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow overflow-hidden sm:rounded-md",children:[t.jsxs("div",{className:"px-4 py-5 sm:px-6",children:[t.jsxs("h3",{className:"text-lg leading-6 font-medium text-gray-900 dark:text-white",children:["Upcoming Events (",e.length,")"]}),t.jsx("p",{className:"mt-1 max-w-2xl text-sm text-gray-500 dark:text-gray-400",children:"Events from your Frappe backend"})]}),e.length===0?t.jsxs("div",{className:"text-center py-12",children:[t.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:t.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"})}),t.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900 dark:text-white",children:"No events found"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"No events are currently scheduled."})]}):t.jsx("ul",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:e.map(k=>t.jsx("li",{children:t.jsx("div",{className:"px-4 py-4 hover:bg-gray-50 dark:hover:bg-gray-700",children:t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h4",{className:"text-lg font-medium text-gray-900 dark:text-white",children:k.subject}),t.jsxs("div",{className:"flex space-x-2",children:[t.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${y(k.status)}`,children:k.status}),t.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${x(k.event_type)}`,children:k.event_type})]})]}),k.description&&t.jsx("p",{className:"mt-1 text-sm text-gray-600 dark:text-gray-400",children:k.description}),t.jsxs("div",{className:"mt-2 flex items-center text-sm text-gray-500 dark:text-gray-400",children:[t.jsx("svg",{className:"flex-shrink-0 mr-1.5 h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),t.jsxs("span",{children:[g(k.starts_on)," - ",g(k.ends_on)]})]})]})})})},k.name))})]}),t.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:t.jsxs("div",{className:"flex",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("svg",{className:"h-5 w-5 text-blue-400",fill:"currentColor",viewBox:"0 0 20 20",children:t.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"})})}),t.jsxs("div",{className:"ml-3",children:[t.jsx("h3",{className:"text-sm font-medium text-blue-800 dark:text-blue-300",children:"API Endpoint Information"}),t.jsxs("div",{className:"mt-2 text-sm text-blue-700 dark:text-blue-400",children:[t.jsxs("p",{children:[t.jsx("strong",{children:"Endpoint:"})," ",t.jsx("code",{children:"frappe.desk.doctype.event.event.get_events"})]}),t.jsxs("p",{children:[t.jsx("strong",{children:"Full URL:"})," ",t.jsx("code",{children:"https://seeraasm-med.seeraarabia.com/api/method/frappe.desk.doctype.event.event.get_events"})]}),t.jsxs("p",{children:[t.jsx("strong",{children:"Method:"})," POST (Frappe API standard)"]})]})]})]})})]})]})};class eL{getAssets(r,a,n=20,i=0,c){return xe(this,null,function*(){const u=new URLSearchParams;r&&u.append("filters",JSON.stringify(r)),a&&a.length>0&&u.append("fields",JSON.stringify(a)),u.append("limit",n.toString()),u.append("offset",i.toString()),c&&u.append("order_by",c);const g=`${Lr.ENDPOINTS.GET_ASSETS}?${u.toString()}`;return _t.apiCall(g)})}getAssetDetails(r){return xe(this,null,function*(){const a=`${Lr.ENDPOINTS.GET_ASSET_DETAILS}?asset_name=${encodeURIComponent(r)}`;return _t.apiCall(a)})}createAsset(r){return xe(this,null,function*(){return _t.apiCall(Lr.ENDPOINTS.CREATE_ASSET,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({asset_data:r})})})}updateAsset(r,a){return xe(this,null,function*(){return _t.apiCall(Lr.ENDPOINTS.UPDATE_ASSET,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({asset_name:r,asset_data:a})})})}deleteAsset(r){return xe(this,null,function*(){return _t.apiCall(Lr.ENDPOINTS.DELETE_ASSET,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({asset_name:r})})})}getAssetFilters(){return xe(this,null,function*(){return _t.apiCall(Lr.ENDPOINTS.GET_ASSET_FILTERS)})}getAssetStats(){return xe(this,null,function*(){return _t.apiCall(Lr.ENDPOINTS.GET_ASSET_STATS)})}searchAssets(r,a=10){return xe(this,null,function*(){const n=`${Lr.ENDPOINTS.SEARCH_ASSETS}?search_term=${encodeURIComponent(r)}&limit=${a}`;return _t.apiCall(n)})}submitAsset(r){return xe(this,null,function*(){return _t.apiCall(Lr.ENDPOINTS.SUBMIT_ASSET||"/api/method/asset_lite.api.asset_api.submit_asset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({asset_name:r})})})}}const Rd=new eL,tL=(e,r)=>{const a=_e({},e||{});for(const[n,i]of Object.entries(r))if(!a[n])a[n]=i;else if(Array.isArray(i)&&i[0]==="in"){const c=i[1],u=a[n];if(typeof u=="string")c.includes(u)||(a[n]=["in",[]]);else if(Array.isArray(u)&&u[0]==="in"){const y=u[1].filter(x=>c.includes(x));a[n]=["in",y]}else a[n]=i}return a};function rL(e,r=20,a=0,n,i={}){const[c,u]=E.useState([]),[g,y]=E.useState(0),[x,k]=E.useState(!1),[N,C]=E.useState(!0),[O,D]=E.useState(null),[A,I]=E.useState(0),z=E.useRef(!1),U=JSON.stringify(e),B=JSON.stringify(i);E.useEffect(()=>{if(z.current&&O)return;let Z=!1;return z.current=!0,xe(null,null,function*(){try{C(!0);const H=tL(e,i);console.log("[useAssets] User filters:",e),console.log("[useAssets] Permission filters:",i),console.log("[useAssets] Merged filters:",H);const le=yield Rd.getAssets(H,void 0,r,a,n);Z||(u(le.assets),y(le.total_count),k(le.has_more),D(null))}catch(H){if(!Z){const le=H instanceof Error?H.message:"Failed to fetch assets";le.includes("417")||le.includes("Expectation Failed")||le.includes("has no attribute")?D("API endpoint not deployed or misconfigured. Please check FIX_417_ERROR.md for solutions."):D(le),u([]),y(0),k(!1)}}finally{Z||C(!1)}}),()=>{Z=!0}},[U,B,r,a,n,A]);const V=E.useCallback(()=>{z.current=!1,I(Z=>Z+1)},[]);return{assets:c,totalCount:g,hasMore:x,loading:N,error:O,refetch:V}}function aL(e){const[r,a]=E.useState(null),[n,i]=E.useState(!0),[c,u]=E.useState(null),g=E.useCallback(()=>xe(null,null,function*(){if(!e){a(null),i(!1);return}try{i(!0),u(null);const x=yield Rd.getAssetDetails(e);a(x)}catch(x){u(x instanceof Error?x.message:"Failed to fetch asset details")}finally{i(!1)}}),[e]);E.useEffect(()=>{g()},[g]);const y=E.useCallback(()=>{g()},[g]);return{asset:r,loading:n,error:c,refetch:y}}function ok(){const[e,r]=E.useState(!1),[a,n]=E.useState(null);return{createAsset:y=>xe(null,null,function*(){try{r(!0),n(null),console.log("[useAssetMutations] Creating asset with data:",y);const x=yield Rd.createAsset(y);if(console.log("[useAssetMutations] Create asset response:",x),x.success)return x.asset;{const k=x.error||"Failed to create asset";throw new Error(k)}}catch(x){console.error("[useAssetMutations] Create asset error:",x);const k=x instanceof Error?x.message:"Failed to create asset";throw n(k),x}finally{r(!1)}}),updateAsset:(y,x)=>xe(null,null,function*(){try{r(!0),n(null),console.log("[useAssetMutations] Updating asset:",y,"with data:",x);const k=yield Rd.updateAsset(y,x);if(console.log("[useAssetMutations] Update asset response:",k),k.success)return k.asset;{const N=k.error||"Failed to update asset";throw new Error(N)}}catch(k){console.error("[useAssetMutations] Update asset error:",k);const N=k instanceof Error?k.message:"Failed to update asset";throw n(N),k}finally{r(!1)}}),deleteAsset:y=>xe(null,null,function*(){try{r(!0),n(null);const x=yield Rd.deleteAsset(y);if(!x.success)throw new Error("Failed to delete asset");return x}catch(x){const k=x instanceof Error?x.message:"Failed to delete asset";throw n(k),x}finally{r(!1)}}),submitAsset:y=>xe(null,null,function*(){try{r(!0),n(null),console.log("[useAssetMutations] Submitting asset:",y);const x=yield Rd.submitAsset(y);return console.log("[useAssetMutations] Submit asset response:",x),x}catch(x){console.error("[useAssetMutations] Submit asset error:",x);const k=x instanceof Error?x.message:"Failed to submit asset";throw n(k),x}finally{r(!1)}}),loading:e,error:a}}var yr;(function(e){e[e.QR_CODE=0]="QR_CODE",e[e.AZTEC=1]="AZTEC",e[e.CODABAR=2]="CODABAR",e[e.CODE_39=3]="CODE_39",e[e.CODE_93=4]="CODE_93",e[e.CODE_128=5]="CODE_128",e[e.DATA_MATRIX=6]="DATA_MATRIX",e[e.MAXICODE=7]="MAXICODE",e[e.ITF=8]="ITF",e[e.EAN_13=9]="EAN_13",e[e.EAN_8=10]="EAN_8",e[e.PDF_417=11]="PDF_417",e[e.RSS_14=12]="RSS_14",e[e.RSS_EXPANDED=13]="RSS_EXPANDED",e[e.UPC_A=14]="UPC_A",e[e.UPC_E=15]="UPC_E",e[e.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(yr||(yr={}));var g_=new Map([[yr.QR_CODE,"QR_CODE"],[yr.AZTEC,"AZTEC"],[yr.CODABAR,"CODABAR"],[yr.CODE_39,"CODE_39"],[yr.CODE_93,"CODE_93"],[yr.CODE_128,"CODE_128"],[yr.DATA_MATRIX,"DATA_MATRIX"],[yr.MAXICODE,"MAXICODE"],[yr.ITF,"ITF"],[yr.EAN_13,"EAN_13"],[yr.EAN_8,"EAN_8"],[yr.PDF_417,"PDF_417"],[yr.RSS_14,"RSS_14"],[yr.RSS_EXPANDED,"RSS_EXPANDED"],[yr.UPC_A,"UPC_A"],[yr.UPC_E,"UPC_E"],[yr.UPC_EAN_EXTENSION,"UPC_EAN_EXTENSION"]]),x_;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.URL=1]="URL"})(x_||(x_={}));function nL(e){return Object.values(yr).includes(e)}var Vf;(function(e){e[e.SCAN_TYPE_CAMERA=0]="SCAN_TYPE_CAMERA",e[e.SCAN_TYPE_FILE=1]="SCAN_TYPE_FILE"})(Vf||(Vf={}));var sL=(function(){function e(){}return e.GITHUB_PROJECT_URL="https://github.com/mebjas/html5-qrcode",e.SCAN_DEFAULT_FPS=2,e.DEFAULT_DISABLE_FLIP=!1,e.DEFAULT_REMEMBER_LAST_CAMERA_USED=!0,e.DEFAULT_SUPPORTED_SCAN_TYPE=[Vf.SCAN_TYPE_CAMERA,Vf.SCAN_TYPE_FILE],e})(),lk=(function(){function e(r,a){this.format=r,this.formatName=a}return e.prototype.toString=function(){return this.formatName},e.create=function(r){if(!g_.has(r))throw"".concat(r," not in html5QrcodeSupportedFormatsTextMap");return new e(r,g_.get(r))},e})(),p_=(function(){function e(){}return e.createFromText=function(r){var a={text:r};return{decodedText:r,result:a}},e.createFromQrcodeResult=function(r){return{decodedText:r.text,result:r}},e})(),cp;(function(e){e[e.UNKWOWN_ERROR=0]="UNKWOWN_ERROR",e[e.IMPLEMENTATION_ERROR=1]="IMPLEMENTATION_ERROR",e[e.NO_CODE_FOUND_ERROR=2]="NO_CODE_FOUND_ERROR"})(cp||(cp={}));var iL=(function(){function e(){}return e.createFrom=function(r){return{errorMessage:r,type:cp.UNKWOWN_ERROR}},e})(),oL=(function(){function e(r){this.verbose=r}return e.prototype.log=function(r){this.verbose&&console.log(r)},e.prototype.warn=function(r){this.verbose&&console.warn(r)},e.prototype.logError=function(r,a){(this.verbose||a===!0)&&console.error(r)},e.prototype.logErrors=function(r){if(r.length===0)throw"Logger#logError called without arguments";this.verbose&&console.error(r)},e})();function Ko(e){return typeof e=="undefined"||e===null}var Md=(function(){function e(){}return e.codeParseError=function(r){return"QR code parse error, error = ".concat(r)},e.errorGettingUserMedia=function(r){return"Error getting userMedia, error = ".concat(r)},e.onlyDeviceSupportedError=function(){return"The device doesn't support navigator.mediaDevices , only supported cameraIdOrConfig in this case is deviceId parameter (string)."},e.cameraStreamingNotSupported=function(){return"Camera streaming not supported by the browser."},e.unableToQuerySupportedDevices=function(){return"Unable to query supported devices, unknown error."},e.insecureContextCameraQueryError=function(){return"Camera access is only supported in secure context like https or localhost."},e.scannerPaused=function(){return"Scanner paused"},e})(),ck=(function(){function e(){}return e.isMediaStreamConstraintsValid=function(r,a){if(typeof r!="object"){var n=typeof r;return a.logError("videoConstraints should be of type object, the "+"object passed is of type ".concat(n,"."),!0),!1}for(var i=["autoGainControl","channelCount","echoCancellation","latency","noiseSuppression","sampleRate","sampleSize","volume"],c=new Set(i),u=Object.keys(r),g=0,y=u;g<y.length;g++){var x=y[g];if(c.has(x))return a.logError("".concat(x," is not supported videoConstaints."),!0),!1}return!0},e})(),eu={exports:{}},lL=eu.exports,y_;function cL(){return y_||(y_=1,(function(e,r){(function(a,n){n(r)})(lL,(function(a){function n(ee){return ee==null}var i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(ee,o){ee.__proto__=o}||function(ee,o){for(var d in o)o.hasOwnProperty(d)&&(ee[d]=o[d])};function c(ee,o){i(ee,o);function d(){this.constructor=ee}ee.prototype=o===null?Object.create(o):(d.prototype=o.prototype,new d)}function u(ee,o){var d=Object.setPrototypeOf;d?d(ee,o):ee.__proto__=o}function g(ee,o){o===void 0&&(o=ee.constructor);var d=Error.captureStackTrace;d&&d(ee,o)}var y=(function(ee){c(o,ee);function o(d){var f=this.constructor,p=ee.call(this,d)||this;return Object.defineProperty(p,"name",{value:f.name,enumerable:!1}),u(p,f.prototype),g(p),p}return o})(Error);class x extends y{constructor(o=void 0){super(o),this.message=o}getKind(){return this.constructor.kind}}x.kind="Exception";class k extends x{}k.kind="ArgumentException";class N extends x{}N.kind="IllegalArgumentException";class C{constructor(o){if(this.binarizer=o,o===null)throw new N("Binarizer must be non-null.")}getWidth(){return this.binarizer.getWidth()}getHeight(){return this.binarizer.getHeight()}getBlackRow(o,d){return this.binarizer.getBlackRow(o,d)}getBlackMatrix(){return(this.matrix===null||this.matrix===void 0)&&(this.matrix=this.binarizer.getBlackMatrix()),this.matrix}isCropSupported(){return this.binarizer.getLuminanceSource().isCropSupported()}crop(o,d,f,p){const b=this.binarizer.getLuminanceSource().crop(o,d,f,p);return new C(this.binarizer.createBinarizer(b))}isRotateSupported(){return this.binarizer.getLuminanceSource().isRotateSupported()}rotateCounterClockwise(){const o=this.binarizer.getLuminanceSource().rotateCounterClockwise();return new C(this.binarizer.createBinarizer(o))}rotateCounterClockwise45(){const o=this.binarizer.getLuminanceSource().rotateCounterClockwise45();return new C(this.binarizer.createBinarizer(o))}toString(){try{return this.getBlackMatrix().toString()}catch(o){return""}}}class O extends x{static getChecksumInstance(){return new O}}O.kind="ChecksumException";class D{constructor(o){this.source=o}getLuminanceSource(){return this.source}getWidth(){return this.source.getWidth()}getHeight(){return this.source.getHeight()}}class A{static arraycopy(o,d,f,p,b){for(;b--;)f[p++]=o[d++]}static currentTimeMillis(){return Date.now()}}class I extends x{}I.kind="IndexOutOfBoundsException";class z extends I{constructor(o=void 0,d=void 0){super(d),this.index=o,this.message=d}}z.kind="ArrayIndexOutOfBoundsException";class U{static fill(o,d){for(let f=0,p=o.length;f<p;f++)o[f]=d}static fillWithin(o,d,f,p){U.rangeCheck(o.length,d,f);for(let b=d;b<f;b++)o[b]=p}static rangeCheck(o,d,f){if(d>f)throw new N("fromIndex("+d+") > toIndex("+f+")");if(d<0)throw new z(d);if(f>o)throw new z(f)}static asList(...o){return o}static create(o,d,f){return Array.from({length:o}).map(b=>Array.from({length:d}).fill(f))}static createInt32Array(o,d,f){return Array.from({length:o}).map(b=>Int32Array.from({length:d}).fill(f))}static equals(o,d){if(!o||!d||!o.length||!d.length||o.length!==d.length)return!1;for(let f=0,p=o.length;f<p;f++)if(o[f]!==d[f])return!1;return!0}static hashCode(o){if(o===null)return 0;let d=1;for(const f of o)d=31*d+f;return d}static fillUint8Array(o,d){for(let f=0;f!==o.length;f++)o[f]=d}static copyOf(o,d){return o.slice(0,d)}static copyOfUint8Array(o,d){if(o.length<=d){const f=new Uint8Array(d);return f.set(o),f}return o.slice(0,d)}static copyOfRange(o,d,f){const p=f-d,b=new Int32Array(p);return A.arraycopy(o,d,b,0,p),b}static binarySearch(o,d,f){f===void 0&&(f=U.numberComparator);let p=0,b=o.length-1;for(;p<=b;){const w=b+p>>1,S=f(d,o[w]);if(S>0)p=w+1;else if(S<0)b=w-1;else return w}return-p-1}static numberComparator(o,d){return o-d}}class B{static numberOfTrailingZeros(o){let d;if(o===0)return 32;let f=31;return d=o<<16,d!==0&&(f-=16,o=d),d=o<<8,d!==0&&(f-=8,o=d),d=o<<4,d!==0&&(f-=4,o=d),d=o<<2,d!==0&&(f-=2,o=d),f-(o<<1>>>31)}static numberOfLeadingZeros(o){if(o===0)return 32;let d=1;return o>>>16||(d+=16,o<<=16),o>>>24||(d+=8,o<<=8),o>>>28||(d+=4,o<<=4),o>>>30||(d+=2,o<<=2),d-=o>>>31,d}static toHexString(o){return o.toString(16)}static toBinaryString(o){return String(parseInt(String(o),2))}static bitCount(o){return o=o-(o>>>1&1431655765),o=(o&858993459)+(o>>>2&858993459),o=o+(o>>>4)&252645135,o=o+(o>>>8),o=o+(o>>>16),o&63}static truncDivision(o,d){return Math.trunc(o/d)}static parseInt(o,d=void 0){return parseInt(o,d)}}B.MIN_VALUE_32_BITS=-2147483648,B.MAX_VALUE=Number.MAX_SAFE_INTEGER;class V{constructor(o,d){o===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=o,d==null?this.bits=V.makeArray(o):this.bits=d)}getSize(){return this.size}getSizeInBytes(){return Math.floor((this.size+7)/8)}ensureCapacity(o){if(o>this.bits.length*32){const d=V.makeArray(o);A.arraycopy(this.bits,0,d,0,this.bits.length),this.bits=d}}get(o){return(this.bits[Math.floor(o/32)]&1<<(o&31))!==0}set(o){this.bits[Math.floor(o/32)]|=1<<(o&31)}flip(o){this.bits[Math.floor(o/32)]^=1<<(o&31)}getNextSet(o){const d=this.size;if(o>=d)return d;const f=this.bits;let p=Math.floor(o/32),b=f[p];b&=~((1<<(o&31))-1);const w=f.length;for(;b===0;){if(++p===w)return d;b=f[p]}const S=p*32+B.numberOfTrailingZeros(b);return S>d?d:S}getNextUnset(o){const d=this.size;if(o>=d)return d;const f=this.bits;let p=Math.floor(o/32),b=~f[p];b&=~((1<<(o&31))-1);const w=f.length;for(;b===0;){if(++p===w)return d;b=~f[p]}const S=p*32+B.numberOfTrailingZeros(b);return S>d?d:S}setBulk(o,d){this.bits[Math.floor(o/32)]=d}setRange(o,d){if(d<o||o<0||d>this.size)throw new N;if(d===o)return;d--;const f=Math.floor(o/32),p=Math.floor(d/32),b=this.bits;for(let w=f;w<=p;w++){const S=w>f?0:o&31,P=(2<<(w<p?31:d&31))-(1<<S);b[w]|=P}}clear(){const o=this.bits.length,d=this.bits;for(let f=0;f<o;f++)d[f]=0}isRange(o,d,f){if(d<o||o<0||d>this.size)throw new N;if(d===o)return!0;d--;const p=Math.floor(o/32),b=Math.floor(d/32),w=this.bits;for(let S=p;S<=b;S++){const R=S>p?0:o&31,X=(2<<(S<b?31:d&31))-(1<<R)&4294967295;if((w[S]&X)!==(f?X:0))return!1}return!0}appendBit(o){this.ensureCapacity(this.size+1),o&&(this.bits[Math.floor(this.size/32)]|=1<<(this.size&31)),this.size++}appendBits(o,d){if(d<0||d>32)throw new N("Num bits must be between 0 and 32");this.ensureCapacity(this.size+d);for(let f=d;f>0;f--)this.appendBit((o>>f-1&1)===1)}appendBitArray(o){const d=o.size;this.ensureCapacity(this.size+d);for(let f=0;f<d;f++)this.appendBit(o.get(f))}xor(o){if(this.size!==o.size)throw new N("Sizes don't match");const d=this.bits;for(let f=0,p=d.length;f<p;f++)d[f]^=o.bits[f]}toBytes(o,d,f,p){for(let b=0;b<p;b++){let w=0;for(let S=0;S<8;S++)this.get(o)&&(w|=1<<7-S),o++;d[f+b]=w}}getBitArray(){return this.bits}reverse(){const o=new Int32Array(this.bits.length),d=Math.floor((this.size-1)/32),f=d+1,p=this.bits;for(let b=0;b<f;b++){let w=p[b];w=w>>1&1431655765|(w&1431655765)<<1,w=w>>2&858993459|(w&858993459)<<2,w=w>>4&252645135|(w&252645135)<<4,w=w>>8&16711935|(w&16711935)<<8,w=w>>16&65535|(w&65535)<<16,o[d-b]=w}if(this.size!==f*32){const b=f*32-this.size;let w=o[0]>>>b;for(let S=1;S<f;S++){const R=o[S];w|=R<<32-b,o[S-1]=w,w=R>>>b}o[f-1]=w}this.bits=o}static makeArray(o){return new Int32Array(Math.floor((o+31)/32))}equals(o){if(!(o instanceof V))return!1;const d=o;return this.size===d.size&&U.equals(this.bits,d.bits)}hashCode(){return 31*this.size+U.hashCode(this.bits)}toString(){let o="";for(let d=0,f=this.size;d<f;d++)(d&7)===0&&(o+=" "),o+=this.get(d)?"X":".";return o}clone(){return new V(this.size,this.bits.slice())}}var Z;(function(ee){ee[ee.OTHER=0]="OTHER",ee[ee.PURE_BARCODE=1]="PURE_BARCODE",ee[ee.POSSIBLE_FORMATS=2]="POSSIBLE_FORMATS",ee[ee.TRY_HARDER=3]="TRY_HARDER",ee[ee.CHARACTER_SET=4]="CHARACTER_SET",ee[ee.ALLOWED_LENGTHS=5]="ALLOWED_LENGTHS",ee[ee.ASSUME_CODE_39_CHECK_DIGIT=6]="ASSUME_CODE_39_CHECK_DIGIT",ee[ee.ASSUME_GS1=7]="ASSUME_GS1",ee[ee.RETURN_CODABAR_START_END=8]="RETURN_CODABAR_START_END",ee[ee.NEED_RESULT_POINT_CALLBACK=9]="NEED_RESULT_POINT_CALLBACK",ee[ee.ALLOWED_EAN_EXTENSIONS=10]="ALLOWED_EAN_EXTENSIONS"})(Z||(Z={}));var W=Z;class H extends x{static getFormatInstance(){return new H}}H.kind="FormatException";var le;(function(ee){ee[ee.Cp437=0]="Cp437",ee[ee.ISO8859_1=1]="ISO8859_1",ee[ee.ISO8859_2=2]="ISO8859_2",ee[ee.ISO8859_3=3]="ISO8859_3",ee[ee.ISO8859_4=4]="ISO8859_4",ee[ee.ISO8859_5=5]="ISO8859_5",ee[ee.ISO8859_6=6]="ISO8859_6",ee[ee.ISO8859_7=7]="ISO8859_7",ee[ee.ISO8859_8=8]="ISO8859_8",ee[ee.ISO8859_9=9]="ISO8859_9",ee[ee.ISO8859_10=10]="ISO8859_10",ee[ee.ISO8859_11=11]="ISO8859_11",ee[ee.ISO8859_13=12]="ISO8859_13",ee[ee.ISO8859_14=13]="ISO8859_14",ee[ee.ISO8859_15=14]="ISO8859_15",ee[ee.ISO8859_16=15]="ISO8859_16",ee[ee.SJIS=16]="SJIS",ee[ee.Cp1250=17]="Cp1250",ee[ee.Cp1251=18]="Cp1251",ee[ee.Cp1252=19]="Cp1252",ee[ee.Cp1256=20]="Cp1256",ee[ee.UnicodeBigUnmarked=21]="UnicodeBigUnmarked",ee[ee.UTF8=22]="UTF8",ee[ee.ASCII=23]="ASCII",ee[ee.Big5=24]="Big5",ee[ee.GB18030=25]="GB18030",ee[ee.EUC_KR=26]="EUC_KR"})(le||(le={}));class Q{constructor(o,d,f,...p){this.valueIdentifier=o,this.name=f,typeof d=="number"?this.values=Int32Array.from([d]):this.values=d,this.otherEncodingNames=p,Q.VALUE_IDENTIFIER_TO_ECI.set(o,this),Q.NAME_TO_ECI.set(f,this);const b=this.values;for(let w=0,S=b.length;w!==S;w++){const R=b[w];Q.VALUES_TO_ECI.set(R,this)}for(const w of p)Q.NAME_TO_ECI.set(w,this)}getValueIdentifier(){return this.valueIdentifier}getName(){return this.name}getValue(){return this.values[0]}static getCharacterSetECIByValue(o){if(o<0||o>=900)throw new H("incorect value");const d=Q.VALUES_TO_ECI.get(o);if(d===void 0)throw new H("incorect value");return d}static getCharacterSetECIByName(o){const d=Q.NAME_TO_ECI.get(o);if(d===void 0)throw new H("incorect value");return d}equals(o){if(!(o instanceof Q))return!1;const d=o;return this.getName()===d.getName()}}Q.VALUE_IDENTIFIER_TO_ECI=new Map,Q.VALUES_TO_ECI=new Map,Q.NAME_TO_ECI=new Map,Q.Cp437=new Q(le.Cp437,Int32Array.from([0,2]),"Cp437"),Q.ISO8859_1=new Q(le.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),Q.ISO8859_2=new Q(le.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),Q.ISO8859_3=new Q(le.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),Q.ISO8859_4=new Q(le.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),Q.ISO8859_5=new Q(le.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),Q.ISO8859_6=new Q(le.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),Q.ISO8859_7=new Q(le.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),Q.ISO8859_8=new Q(le.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),Q.ISO8859_9=new Q(le.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),Q.ISO8859_10=new Q(le.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),Q.ISO8859_11=new Q(le.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),Q.ISO8859_13=new Q(le.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),Q.ISO8859_14=new Q(le.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),Q.ISO8859_15=new Q(le.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),Q.ISO8859_16=new Q(le.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),Q.SJIS=new Q(le.SJIS,20,"SJIS","Shift_JIS"),Q.Cp1250=new Q(le.Cp1250,21,"Cp1250","windows-1250"),Q.Cp1251=new Q(le.Cp1251,22,"Cp1251","windows-1251"),Q.Cp1252=new Q(le.Cp1252,23,"Cp1252","windows-1252"),Q.Cp1256=new Q(le.Cp1256,24,"Cp1256","windows-1256"),Q.UnicodeBigUnmarked=new Q(le.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),Q.UTF8=new Q(le.UTF8,26,"UTF8","UTF-8"),Q.ASCII=new Q(le.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),Q.Big5=new Q(le.Big5,28,"Big5"),Q.GB18030=new Q(le.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),Q.EUC_KR=new Q(le.EUC_KR,30,"EUC_KR","EUC-KR");class Ne extends x{}Ne.kind="UnsupportedOperationException";class oe{static decode(o,d){const f=this.encodingName(d);return this.customDecoder?this.customDecoder(o,f):typeof TextDecoder=="undefined"||this.shouldDecodeOnFallback(f)?this.decodeFallback(o,f):new TextDecoder(f).decode(o)}static shouldDecodeOnFallback(o){return!oe.isBrowser()&&o==="ISO-8859-1"}static encode(o,d){const f=this.encodingName(d);return this.customEncoder?this.customEncoder(o,f):typeof TextEncoder=="undefined"?this.encodeFallback(o):new TextEncoder().encode(o)}static isBrowser(){return typeof window!="undefined"&&{}.toString.call(window)==="[object Window]"}static encodingName(o){return typeof o=="string"?o:o.getName()}static encodingCharacterSet(o){return o instanceof Q?o:Q.getCharacterSetECIByName(o)}static decodeFallback(o,d){const f=this.encodingCharacterSet(d);if(oe.isDecodeFallbackSupported(f)){let p="";for(let b=0,w=o.length;b<w;b++){let S=o[b].toString(16);S.length<2&&(S="0"+S),p+="%"+S}return decodeURIComponent(p)}if(f.equals(Q.UnicodeBigUnmarked))return String.fromCharCode.apply(null,new Uint16Array(o.buffer));throw new Ne(`Encoding ${this.encodingName(d)} not supported by fallback.`)}static isDecodeFallbackSupported(o){return o.equals(Q.UTF8)||o.equals(Q.ISO8859_1)||o.equals(Q.ASCII)}static encodeFallback(o){const f=btoa(unescape(encodeURIComponent(o))).split(""),p=[];for(let b=0;b<f.length;b++)p.push(f[b].charCodeAt(0));return new Uint8Array(p)}}class se{static castAsNonUtf8Char(o,d=null){const f=d?d.getName():this.ISO88591;return oe.decode(new Uint8Array([o]),f)}static guessEncoding(o,d){if(d!=null&&d.get(W.CHARACTER_SET)!==void 0)return d.get(W.CHARACTER_SET).toString();const f=o.length;let p=!0,b=!0,w=!0,S=0,R=0,P=0,X=0,te=0,ue=0,je=0,Fe=0,Ue=0,tt=0,ut=0;const Xt=o.length>3&&o[0]===239&&o[1]===187&&o[2]===191;for(let Gt=0;Gt<f&&(p||b||w);Gt++){const Ft=o[Gt]&255;w&&(S>0?(Ft&128)===0?w=!1:S--:(Ft&128)!==0&&((Ft&64)===0?w=!1:(S++,(Ft&32)===0?R++:(S++,(Ft&16)===0?P++:(S++,(Ft&8)===0?X++:w=!1))))),p&&(Ft>127&&Ft<160?p=!1:Ft>159&&(Ft<192||Ft===215||Ft===247)&&ut++),b&&(te>0?Ft<64||Ft===127||Ft>252?b=!1:te--:Ft===128||Ft===160||Ft>239?b=!1:Ft>160&&Ft<224?(ue++,Fe=0,je++,je>Ue&&(Ue=je)):Ft>127?(te++,je=0,Fe++,Fe>tt&&(tt=Fe)):(je=0,Fe=0))}return w&&S>0&&(w=!1),b&&te>0&&(b=!1),w&&(Xt||R+P+X>0)?se.UTF8:b&&(se.ASSUME_SHIFT_JIS||Ue>=3||tt>=3)?se.SHIFT_JIS:p&&b?Ue===2&&ue===2||ut*10>=f?se.SHIFT_JIS:se.ISO88591:p?se.ISO88591:b?se.SHIFT_JIS:w?se.UTF8:se.PLATFORM_DEFAULT_ENCODING}static format(o,...d){let f=-1;function p(w,S,R,P,X,te){if(w==="%%")return"%";if(d[++f]===void 0)return;w=P?parseInt(P.substr(1)):void 0;let ue=X?parseInt(X.substr(1)):void 0,je;switch(te){case"s":je=d[f];break;case"c":je=d[f][0];break;case"f":je=parseFloat(d[f]).toFixed(w);break;case"p":je=parseFloat(d[f]).toPrecision(w);break;case"e":je=parseFloat(d[f]).toExponential(w);break;case"x":je=parseInt(d[f]).toString(ue||16);break;case"d":je=parseFloat(parseInt(d[f],ue||10).toPrecision(w)).toFixed(0);break}je=typeof je=="object"?JSON.stringify(je):(+je).toString(ue);let Fe=parseInt(R),Ue=R&&R[0]+""=="0"?"0":" ";for(;je.length<Fe;)je=S!==void 0?je+Ue:Ue+je;return je}let b=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return o.replace(b,p)}static getBytes(o,d){return oe.encode(o,d)}static getCharCode(o,d=0){return o.charCodeAt(d)}static getCharAt(o){return String.fromCharCode(o)}}se.SHIFT_JIS=Q.SJIS.getName(),se.GB2312="GB2312",se.ISO88591=Q.ISO8859_1.getName(),se.EUC_JP="EUC_JP",se.UTF8=Q.UTF8.getName(),se.PLATFORM_DEFAULT_ENCODING=se.UTF8,se.ASSUME_SHIFT_JIS=!1;class ce{constructor(o=""){this.value=o}enableDecoding(o){return this.encoding=o,this}append(o){return typeof o=="string"?this.value+=o.toString():this.encoding?this.value+=se.castAsNonUtf8Char(o,this.encoding):this.value+=String.fromCharCode(o),this}appendChars(o,d,f){for(let p=d;d<d+f;p++)this.append(o[p]);return this}length(){return this.value.length}charAt(o){return this.value.charAt(o)}deleteCharAt(o){this.value=this.value.substr(0,o)+this.value.substring(o+1)}setCharAt(o,d){this.value=this.value.substr(0,o)+d+this.value.substr(o+1)}substring(o,d){return this.value.substring(o,d)}setLengthToZero(){this.value=""}toString(){return this.value}insert(o,d){this.value=this.value.substr(0,o)+d+this.value.substr(o+d.length)}}class Ce{constructor(o,d,f,p){if(this.width=o,this.height=d,this.rowSize=f,this.bits=p,d==null&&(d=o),this.height=d,o<1||d<1)throw new N("Both dimensions must be greater than 0");f==null&&(f=Math.floor((o+31)/32)),this.rowSize=f,p==null&&(this.bits=new Int32Array(this.rowSize*this.height))}static parseFromBooleanArray(o){const d=o.length,f=o[0].length,p=new Ce(f,d);for(let b=0;b<d;b++){const w=o[b];for(let S=0;S<f;S++)w[S]&&p.set(S,b)}return p}static parseFromString(o,d,f){if(o===null)throw new N("stringRepresentation cannot be null");const p=new Array(o.length);let b=0,w=0,S=-1,R=0,P=0;for(;P<o.length;)if(o.charAt(P)===`
|
||
`||o.charAt(P)==="\r"){if(b>w){if(S===-1)S=b-w;else if(b-w!==S)throw new N("row lengths do not match");w=b,R++}P++}else if(o.substring(P,P+d.length)===d)P+=d.length,p[b]=!0,b++;else if(o.substring(P,P+f.length)===f)P+=f.length,p[b]=!1,b++;else throw new N("illegal character encountered: "+o.substring(P));if(b>w){if(S===-1)S=b-w;else if(b-w!==S)throw new N("row lengths do not match");R++}const X=new Ce(S,R);for(let te=0;te<b;te++)p[te]&&X.set(Math.floor(te%S),Math.floor(te/S));return X}get(o,d){const f=d*this.rowSize+Math.floor(o/32);return(this.bits[f]>>>(o&31)&1)!==0}set(o,d){const f=d*this.rowSize+Math.floor(o/32);this.bits[f]|=1<<(o&31)&4294967295}unset(o,d){const f=d*this.rowSize+Math.floor(o/32);this.bits[f]&=~(1<<(o&31)&4294967295)}flip(o,d){const f=d*this.rowSize+Math.floor(o/32);this.bits[f]^=1<<(o&31)&4294967295}xor(o){if(this.width!==o.getWidth()||this.height!==o.getHeight()||this.rowSize!==o.getRowSize())throw new N("input matrix dimensions do not match");const d=new V(Math.floor(this.width/32)+1),f=this.rowSize,p=this.bits;for(let b=0,w=this.height;b<w;b++){const S=b*f,R=o.getRow(b,d).getBitArray();for(let P=0;P<f;P++)p[S+P]^=R[P]}}clear(){const o=this.bits,d=o.length;for(let f=0;f<d;f++)o[f]=0}setRegion(o,d,f,p){if(d<0||o<0)throw new N("Left and top must be nonnegative");if(p<1||f<1)throw new N("Height and width must be at least 1");const b=o+f,w=d+p;if(w>this.height||b>this.width)throw new N("The region must fit inside the matrix");const S=this.rowSize,R=this.bits;for(let P=d;P<w;P++){const X=P*S;for(let te=o;te<b;te++)R[X+Math.floor(te/32)]|=1<<(te&31)&4294967295}}getRow(o,d){d==null||d.getSize()<this.width?d=new V(this.width):d.clear();const f=this.rowSize,p=this.bits,b=o*f;for(let w=0;w<f;w++)d.setBulk(w*32,p[b+w]);return d}setRow(o,d){A.arraycopy(d.getBitArray(),0,this.bits,o*this.rowSize,this.rowSize)}rotate180(){const o=this.getWidth(),d=this.getHeight();let f=new V(o),p=new V(o);for(let b=0,w=Math.floor((d+1)/2);b<w;b++)f=this.getRow(b,f),p=this.getRow(d-1-b,p),f.reverse(),p.reverse(),this.setRow(b,p),this.setRow(d-1-b,f)}getEnclosingRectangle(){const o=this.width,d=this.height,f=this.rowSize,p=this.bits;let b=o,w=d,S=-1,R=-1;for(let P=0;P<d;P++)for(let X=0;X<f;X++){const te=p[P*f+X];if(te!==0){if(P<w&&(w=P),P>R&&(R=P),X*32<b){let ue=0;for(;(te<<31-ue&4294967295)===0;)ue++;X*32+ue<b&&(b=X*32+ue)}if(X*32+31>S){let ue=31;for(;!(te>>>ue);)ue--;X*32+ue>S&&(S=X*32+ue)}}}return S<b||R<w?null:Int32Array.from([b,w,S-b+1,R-w+1])}getTopLeftOnBit(){const o=this.rowSize,d=this.bits;let f=0;for(;f<d.length&&d[f]===0;)f++;if(f===d.length)return null;const p=f/o;let b=f%o*32;const w=d[f];let S=0;for(;(w<<31-S&4294967295)===0;)S++;return b+=S,Int32Array.from([b,p])}getBottomRightOnBit(){const o=this.rowSize,d=this.bits;let f=d.length-1;for(;f>=0&&d[f]===0;)f--;if(f<0)return null;const p=Math.floor(f/o);let b=Math.floor(f%o)*32;const w=d[f];let S=31;for(;!(w>>>S);)S--;return b+=S,Int32Array.from([b,p])}getWidth(){return this.width}getHeight(){return this.height}getRowSize(){return this.rowSize}equals(o){if(!(o instanceof Ce))return!1;const d=o;return this.width===d.width&&this.height===d.height&&this.rowSize===d.rowSize&&U.equals(this.bits,d.bits)}hashCode(){let o=this.width;return o=31*o+this.width,o=31*o+this.height,o=31*o+this.rowSize,o=31*o+U.hashCode(this.bits),o}toString(o="X ",d=" ",f=`
|
||
`){return this.buildToString(o,d,f)}buildToString(o,d,f){let p=new ce;for(let b=0,w=this.height;b<w;b++){for(let S=0,R=this.width;S<R;S++)p.append(this.get(S,b)?o:d);p.append(f)}return p.toString()}clone(){return new Ce(this.width,this.height,this.rowSize,this.bits.slice())}}class ae extends x{static getNotFoundInstance(){return new ae}}ae.kind="NotFoundException";class me extends D{constructor(o){super(o),this.luminances=me.EMPTY,this.buckets=new Int32Array(me.LUMINANCE_BUCKETS)}getBlackRow(o,d){const f=this.getLuminanceSource(),p=f.getWidth();d==null||d.getSize()<p?d=new V(p):d.clear(),this.initArrays(p);const b=f.getRow(o,this.luminances),w=this.buckets;for(let R=0;R<p;R++)w[(b[R]&255)>>me.LUMINANCE_SHIFT]++;const S=me.estimateBlackPoint(w);if(p<3)for(let R=0;R<p;R++)(b[R]&255)<S&&d.set(R);else{let R=b[0]&255,P=b[1]&255;for(let X=1;X<p-1;X++){const te=b[X+1]&255;(P*4-R-te)/2<S&&d.set(X),R=P,P=te}}return d}getBlackMatrix(){const o=this.getLuminanceSource(),d=o.getWidth(),f=o.getHeight(),p=new Ce(d,f);this.initArrays(d);const b=this.buckets;for(let R=1;R<5;R++){const P=Math.floor(f*R/5),X=o.getRow(P,this.luminances),te=Math.floor(d*4/5);for(let ue=Math.floor(d/5);ue<te;ue++){const je=X[ue]&255;b[je>>me.LUMINANCE_SHIFT]++}}const w=me.estimateBlackPoint(b),S=o.getMatrix();for(let R=0;R<f;R++){const P=R*d;for(let X=0;X<d;X++)(S[P+X]&255)<w&&p.set(X,R)}return p}createBinarizer(o){return new me(o)}initArrays(o){this.luminances.length<o&&(this.luminances=new Uint8ClampedArray(o));const d=this.buckets;for(let f=0;f<me.LUMINANCE_BUCKETS;f++)d[f]=0}static estimateBlackPoint(o){const d=o.length;let f=0,p=0,b=0;for(let X=0;X<d;X++)o[X]>b&&(p=X,b=o[X]),o[X]>f&&(f=o[X]);let w=0,S=0;for(let X=0;X<d;X++){const te=X-p,ue=o[X]*te*te;ue>S&&(w=X,S=ue)}if(p>w){const X=p;p=w,w=X}if(w-p<=d/16)throw new ae;let R=w-1,P=-1;for(let X=w-1;X>p;X--){const te=X-p,ue=te*te*(w-X)*(f-o[X]);ue>P&&(R=X,P=ue)}return R<<me.LUMINANCE_SHIFT}}me.LUMINANCE_BITS=5,me.LUMINANCE_SHIFT=8-me.LUMINANCE_BITS,me.LUMINANCE_BUCKETS=1<<me.LUMINANCE_BITS,me.EMPTY=Uint8ClampedArray.from([0]);class K extends me{constructor(o){super(o),this.matrix=null}getBlackMatrix(){if(this.matrix!==null)return this.matrix;const o=this.getLuminanceSource(),d=o.getWidth(),f=o.getHeight();if(d>=K.MINIMUM_DIMENSION&&f>=K.MINIMUM_DIMENSION){const p=o.getMatrix();let b=d>>K.BLOCK_SIZE_POWER;(d&K.BLOCK_SIZE_MASK)!==0&&b++;let w=f>>K.BLOCK_SIZE_POWER;(f&K.BLOCK_SIZE_MASK)!==0&&w++;const S=K.calculateBlackPoints(p,b,w,d,f),R=new Ce(d,f);K.calculateThresholdForBlock(p,b,w,d,f,S,R),this.matrix=R}else this.matrix=super.getBlackMatrix();return this.matrix}createBinarizer(o){return new K(o)}static calculateThresholdForBlock(o,d,f,p,b,w,S){const R=b-K.BLOCK_SIZE,P=p-K.BLOCK_SIZE;for(let X=0;X<f;X++){let te=X<<K.BLOCK_SIZE_POWER;te>R&&(te=R);const ue=K.cap(X,2,f-3);for(let je=0;je<d;je++){let Fe=je<<K.BLOCK_SIZE_POWER;Fe>P&&(Fe=P);const Ue=K.cap(je,2,d-3);let tt=0;for(let Xt=-2;Xt<=2;Xt++){const Gt=w[ue+Xt];tt+=Gt[Ue-2]+Gt[Ue-1]+Gt[Ue]+Gt[Ue+1]+Gt[Ue+2]}const ut=tt/25;K.thresholdBlock(o,Fe,te,ut,p,S)}}}static cap(o,d,f){return o<d?d:o>f?f:o}static thresholdBlock(o,d,f,p,b,w){for(let S=0,R=f*b+d;S<K.BLOCK_SIZE;S++,R+=b)for(let P=0;P<K.BLOCK_SIZE;P++)(o[R+P]&255)<=p&&w.set(d+P,f+S)}static calculateBlackPoints(o,d,f,p,b){const w=b-K.BLOCK_SIZE,S=p-K.BLOCK_SIZE,R=new Array(f);for(let P=0;P<f;P++){R[P]=new Int32Array(d);let X=P<<K.BLOCK_SIZE_POWER;X>w&&(X=w);for(let te=0;te<d;te++){let ue=te<<K.BLOCK_SIZE_POWER;ue>S&&(ue=S);let je=0,Fe=255,Ue=0;for(let ut=0,Xt=X*p+ue;ut<K.BLOCK_SIZE;ut++,Xt+=p){for(let Gt=0;Gt<K.BLOCK_SIZE;Gt++){const Ft=o[Xt+Gt]&255;je+=Ft,Ft<Fe&&(Fe=Ft),Ft>Ue&&(Ue=Ft)}if(Ue-Fe>K.MIN_DYNAMIC_RANGE)for(ut++,Xt+=p;ut<K.BLOCK_SIZE;ut++,Xt+=p)for(let Gt=0;Gt<K.BLOCK_SIZE;Gt++)je+=o[Xt+Gt]&255}let tt=je>>K.BLOCK_SIZE_POWER*2;if(Ue-Fe<=K.MIN_DYNAMIC_RANGE&&(tt=Fe/2,P>0&&te>0)){const ut=(R[P-1][te]+2*R[P][te-1]+R[P-1][te-1])/4;Fe<ut&&(tt=ut)}R[P][te]=tt}}return R}}K.BLOCK_SIZE_POWER=3,K.BLOCK_SIZE=1<<K.BLOCK_SIZE_POWER,K.BLOCK_SIZE_MASK=K.BLOCK_SIZE-1,K.MINIMUM_DIMENSION=K.BLOCK_SIZE*5,K.MIN_DYNAMIC_RANGE=24;class fe{constructor(o,d){this.width=o,this.height=d}getWidth(){return this.width}getHeight(){return this.height}isCropSupported(){return!1}crop(o,d,f,p){throw new Ne("This luminance source does not support cropping.")}isRotateSupported(){return!1}rotateCounterClockwise(){throw new Ne("This luminance source does not support rotation by 90 degrees.")}rotateCounterClockwise45(){throw new Ne("This luminance source does not support rotation by 45 degrees.")}toString(){const o=new Uint8ClampedArray(this.width);let d=new ce;for(let f=0;f<this.height;f++){const p=this.getRow(f,o);for(let b=0;b<this.width;b++){const w=p[b]&255;let S;w<64?S="#":w<128?S="+":w<192?S=".":S=" ",d.append(S)}d.append(`
|
||
`)}return d.toString()}}class Oe extends fe{constructor(o){super(o.getWidth(),o.getHeight()),this.delegate=o}getRow(o,d){const f=this.delegate.getRow(o,d),p=this.getWidth();for(let b=0;b<p;b++)f[b]=255-(f[b]&255);return f}getMatrix(){const o=this.delegate.getMatrix(),d=this.getWidth()*this.getHeight(),f=new Uint8ClampedArray(d);for(let p=0;p<d;p++)f[p]=255-(o[p]&255);return f}isCropSupported(){return this.delegate.isCropSupported()}crop(o,d,f,p){return new Oe(this.delegate.crop(o,d,f,p))}isRotateSupported(){return this.delegate.isRotateSupported()}invert(){return this.delegate}rotateCounterClockwise(){return new Oe(this.delegate.rotateCounterClockwise())}rotateCounterClockwise45(){return new Oe(this.delegate.rotateCounterClockwise45())}}class ye extends fe{constructor(o){super(o.width,o.height),this.canvas=o,this.tempCanvasElement=null,this.buffer=ye.makeBufferFromCanvasImageData(o)}static makeBufferFromCanvasImageData(o){const d=o.getContext("2d").getImageData(0,0,o.width,o.height);return ye.toGrayscaleBuffer(d.data,o.width,o.height)}static toGrayscaleBuffer(o,d,f){const p=new Uint8ClampedArray(d*f);for(let b=0,w=0,S=o.length;b<S;b+=4,w++){let R;if(o[b+3]===0)R=255;else{const X=o[b],te=o[b+1],ue=o[b+2];R=306*X+601*te+117*ue+512>>10}p[w]=R}return p}getRow(o,d){if(o<0||o>=this.getHeight())throw new N("Requested row is outside the image: "+o);const f=this.getWidth(),p=o*f;return d===null?d=this.buffer.slice(p,p+f):(d.length<f&&(d=new Uint8ClampedArray(f)),d.set(this.buffer.slice(p,p+f))),d}getMatrix(){return this.buffer}isCropSupported(){return!0}crop(o,d,f,p){return super.crop(o,d,f,p),this}isRotateSupported(){return!0}rotateCounterClockwise(){return this.rotate(-90),this}rotateCounterClockwise45(){return this.rotate(-45),this}getTempCanvasElement(){if(this.tempCanvasElement===null){const o=this.canvas.ownerDocument.createElement("canvas");o.width=this.canvas.width,o.height=this.canvas.height,this.tempCanvasElement=o}return this.tempCanvasElement}rotate(o){const d=this.getTempCanvasElement(),f=d.getContext("2d"),p=o*ye.DEGREE_TO_RADIANS,b=this.canvas.width,w=this.canvas.height,S=Math.ceil(Math.abs(Math.cos(p))*b+Math.abs(Math.sin(p))*w),R=Math.ceil(Math.abs(Math.sin(p))*b+Math.abs(Math.cos(p))*w);return d.width=S,d.height=R,f.translate(S/2,R/2),f.rotate(p),f.drawImage(this.canvas,b/-2,w/-2),this.buffer=ye.makeBufferFromCanvasImageData(d),this}invert(){return new Oe(this)}}ye.DEGREE_TO_RADIANS=Math.PI/180;class J{constructor(o,d,f){this.deviceId=o,this.label=d,this.kind="videoinput",this.groupId=f||void 0}toJSON(){return{kind:this.kind,groupId:this.groupId,deviceId:this.deviceId,label:this.label}}}var G=(globalThis||Hh||self||window||void 0)&&(globalThis||Hh||self||window||void 0).__awaiter||function(ee,o,d,f){function p(b){return b instanceof d?b:new d(function(w){w(b)})}return new(d||(d=Promise))(function(b,w){function S(X){try{P(f.next(X))}catch(te){w(te)}}function R(X){try{P(f.throw(X))}catch(te){w(te)}}function P(X){X.done?b(X.value):p(X.value).then(S,R)}P((f=f.apply(ee,o||[])).next())})};class ie{constructor(o,d=500,f){this.reader=o,this.timeBetweenScansMillis=d,this._hints=f,this._stopContinuousDecode=!1,this._stopAsyncDecode=!1,this._timeBetweenDecodingAttempts=0}get hasNavigator(){return typeof navigator!="undefined"}get isMediaDevicesSuported(){return this.hasNavigator&&!!navigator.mediaDevices}get canEnumerateDevices(){return!!(this.isMediaDevicesSuported&&navigator.mediaDevices.enumerateDevices)}get timeBetweenDecodingAttempts(){return this._timeBetweenDecodingAttempts}set timeBetweenDecodingAttempts(o){this._timeBetweenDecodingAttempts=o<0?0:o}set hints(o){this._hints=o||null}get hints(){return this._hints}listVideoInputDevices(){return G(this,void 0,void 0,function*(){if(!this.hasNavigator)throw new Error("Can't enumerate devices, navigator is not present.");if(!this.canEnumerateDevices)throw new Error("Can't enumerate devices, method not supported.");const o=yield navigator.mediaDevices.enumerateDevices(),d=[];for(const f of o){const p=f.kind==="video"?"videoinput":f.kind;if(p!=="videoinput")continue;const b=f.deviceId||f.id,w=f.label||`Video device ${d.length+1}`,S=f.groupId,R={deviceId:b,label:w,kind:p,groupId:S};d.push(R)}return d})}getVideoInputDevices(){return G(this,void 0,void 0,function*(){return(yield this.listVideoInputDevices()).map(d=>new J(d.deviceId,d.label))})}findDeviceById(o){return G(this,void 0,void 0,function*(){const d=yield this.listVideoInputDevices();return d?d.find(f=>f.deviceId===o):null})}decodeFromInputVideoDevice(o,d){return G(this,void 0,void 0,function*(){return yield this.decodeOnceFromVideoDevice(o,d)})}decodeOnceFromVideoDevice(o,d){return G(this,void 0,void 0,function*(){this.reset();let f;o?f={deviceId:{exact:o}}:f={facingMode:"environment"};const p={video:f};return yield this.decodeOnceFromConstraints(p,d)})}decodeOnceFromConstraints(o,d){return G(this,void 0,void 0,function*(){const f=yield navigator.mediaDevices.getUserMedia(o);return yield this.decodeOnceFromStream(f,d)})}decodeOnceFromStream(o,d){return G(this,void 0,void 0,function*(){this.reset();const f=yield this.attachStreamToVideo(o,d);return yield this.decodeOnce(f)})}decodeFromInputVideoDeviceContinuously(o,d,f){return G(this,void 0,void 0,function*(){return yield this.decodeFromVideoDevice(o,d,f)})}decodeFromVideoDevice(o,d,f){return G(this,void 0,void 0,function*(){let p;o?p={deviceId:{exact:o}}:p={facingMode:"environment"};const b={video:p};return yield this.decodeFromConstraints(b,d,f)})}decodeFromConstraints(o,d,f){return G(this,void 0,void 0,function*(){const p=yield navigator.mediaDevices.getUserMedia(o);return yield this.decodeFromStream(p,d,f)})}decodeFromStream(o,d,f){return G(this,void 0,void 0,function*(){this.reset();const p=yield this.attachStreamToVideo(o,d);return yield this.decodeContinuously(p,f)})}stopAsyncDecode(){this._stopAsyncDecode=!0}stopContinuousDecode(){this._stopContinuousDecode=!0}attachStreamToVideo(o,d){return G(this,void 0,void 0,function*(){const f=this.prepareVideoElement(d);return this.addVideoSource(f,o),this.videoElement=f,this.stream=o,yield this.playVideoOnLoadAsync(f),f})}playVideoOnLoadAsync(o){return new Promise((d,f)=>this.playVideoOnLoad(o,()=>d()))}playVideoOnLoad(o,d){this.videoEndedListener=()=>this.stopStreams(),this.videoCanPlayListener=()=>this.tryPlayVideo(o),o.addEventListener("ended",this.videoEndedListener),o.addEventListener("canplay",this.videoCanPlayListener),o.addEventListener("playing",d),this.tryPlayVideo(o)}isVideoPlaying(o){return o.currentTime>0&&!o.paused&&!o.ended&&o.readyState>2}tryPlayVideo(o){return G(this,void 0,void 0,function*(){if(this.isVideoPlaying(o)){console.warn("Trying to play video that is already playing.");return}try{yield o.play()}catch(d){console.warn("It was not possible to play the video.")}})}getMediaElement(o,d){const f=document.getElementById(o);if(!f)throw new k(`element with id '${o}' not found`);if(f.nodeName.toLowerCase()!==d.toLowerCase())throw new k(`element with id '${o}' must be an ${d} element`);return f}decodeFromImage(o,d){if(!o&&!d)throw new k("either imageElement with a src set or an url must be provided");return d&&!o?this.decodeFromImageUrl(d):this.decodeFromImageElement(o)}decodeFromVideo(o,d){if(!o&&!d)throw new k("Either an element with a src set or an URL must be provided");return d&&!o?this.decodeFromVideoUrl(d):this.decodeFromVideoElement(o)}decodeFromVideoContinuously(o,d,f){if(o===void 0&&d===void 0)throw new k("Either an element with a src set or an URL must be provided");return d&&!o?this.decodeFromVideoUrlContinuously(d,f):this.decodeFromVideoElementContinuously(o,f)}decodeFromImageElement(o){if(!o)throw new k("An image element must be provided.");this.reset();const d=this.prepareImageElement(o);this.imageElement=d;let f;return this.isImageLoaded(d)?f=this.decodeOnce(d,!1,!0):f=this._decodeOnLoadImage(d),f}decodeFromVideoElement(o){const d=this._decodeFromVideoElementSetup(o);return this._decodeOnLoadVideo(d)}decodeFromVideoElementContinuously(o,d){const f=this._decodeFromVideoElementSetup(o);return this._decodeOnLoadVideoContinuously(f,d)}_decodeFromVideoElementSetup(o){if(!o)throw new k("A video element must be provided.");this.reset();const d=this.prepareVideoElement(o);return this.videoElement=d,d}decodeFromImageUrl(o){if(!o)throw new k("An URL must be provided.");this.reset();const d=this.prepareImageElement();this.imageElement=d;const f=this._decodeOnLoadImage(d);return d.src=o,f}decodeFromVideoUrl(o){if(!o)throw new k("An URL must be provided.");this.reset();const d=this.prepareVideoElement(),f=this.decodeFromVideoElement(d);return d.src=o,f}decodeFromVideoUrlContinuously(o,d){if(!o)throw new k("An URL must be provided.");this.reset();const f=this.prepareVideoElement(),p=this.decodeFromVideoElementContinuously(f,d);return f.src=o,p}_decodeOnLoadImage(o){return new Promise((d,f)=>{this.imageLoadedListener=()=>this.decodeOnce(o,!1,!0).then(d,f),o.addEventListener("load",this.imageLoadedListener)})}_decodeOnLoadVideo(o){return G(this,void 0,void 0,function*(){return yield this.playVideoOnLoadAsync(o),yield this.decodeOnce(o)})}_decodeOnLoadVideoContinuously(o,d){return G(this,void 0,void 0,function*(){yield this.playVideoOnLoadAsync(o),this.decodeContinuously(o,d)})}isImageLoaded(o){return!(!o.complete||o.naturalWidth===0)}prepareImageElement(o){let d;return typeof o=="undefined"&&(d=document.createElement("img"),d.width=200,d.height=200),typeof o=="string"&&(d=this.getMediaElement(o,"img")),o instanceof HTMLImageElement&&(d=o),d}prepareVideoElement(o){let d;return!o&&typeof document!="undefined"&&(d=document.createElement("video"),d.width=200,d.height=200),typeof o=="string"&&(d=this.getMediaElement(o,"video")),o instanceof HTMLVideoElement&&(d=o),d.setAttribute("autoplay","true"),d.setAttribute("muted","true"),d.setAttribute("playsinline","true"),d}decodeOnce(o,d=!0,f=!0){this._stopAsyncDecode=!1;const p=(b,w)=>{if(this._stopAsyncDecode){w(new ae("Video stream has ended before any code could be detected.")),this._stopAsyncDecode=void 0;return}try{const S=this.decode(o);b(S)}catch(S){const R=d&&S instanceof ae,X=(S instanceof O||S instanceof H)&&f;if(R||X)return setTimeout(p,this._timeBetweenDecodingAttempts,b,w);w(S)}};return new Promise((b,w)=>p(b,w))}decodeContinuously(o,d){this._stopContinuousDecode=!1;const f=()=>{if(this._stopContinuousDecode){this._stopContinuousDecode=void 0;return}try{const p=this.decode(o);d(p,null),setTimeout(f,this.timeBetweenScansMillis)}catch(p){d(null,p);const b=p instanceof O||p instanceof H,w=p instanceof ae;(b||w)&&setTimeout(f,this._timeBetweenDecodingAttempts)}};f()}decode(o){const d=this.createBinaryBitmap(o);return this.decodeBitmap(d)}_isHTMLVideoElement(o){return o.videoWidth!==0}drawFrameOnCanvas(o,d,f){d||(d={sx:0,sy:0,sWidth:o.videoWidth,sHeight:o.videoHeight,dx:0,dy:0,dWidth:o.videoWidth,dHeight:o.videoHeight}),f||(f=this.captureCanvasContext),f.drawImage(o,d.sx,d.sy,d.sWidth,d.sHeight,d.dx,d.dy,d.dWidth,d.dHeight)}drawImageOnCanvas(o,d,f=this.captureCanvasContext){d||(d={sx:0,sy:0,sWidth:o.naturalWidth,sHeight:o.naturalHeight,dx:0,dy:0,dWidth:o.naturalWidth,dHeight:o.naturalHeight}),f||(f=this.captureCanvasContext),f.drawImage(o,d.sx,d.sy,d.sWidth,d.sHeight,d.dx,d.dy,d.dWidth,d.dHeight)}createBinaryBitmap(o){this.getCaptureCanvasContext(o),this._isHTMLVideoElement(o)?this.drawFrameOnCanvas(o):this.drawImageOnCanvas(o);const d=this.getCaptureCanvas(o),f=new ye(d),p=new K(f);return new C(p)}getCaptureCanvasContext(o){if(!this.captureCanvasContext){const f=this.getCaptureCanvas(o).getContext("2d");this.captureCanvasContext=f}return this.captureCanvasContext}getCaptureCanvas(o){if(!this.captureCanvas){const d=this.createCaptureCanvas(o);this.captureCanvas=d}return this.captureCanvas}decodeBitmap(o){return this.reader.decode(o,this._hints)}createCaptureCanvas(o){if(typeof document=="undefined")return this._destroyCaptureCanvas(),null;const d=document.createElement("canvas");let f,p;return typeof o!="undefined"&&(o instanceof HTMLVideoElement?(f=o.videoWidth,p=o.videoHeight):o instanceof HTMLImageElement&&(f=o.naturalWidth||o.width,p=o.naturalHeight||o.height)),d.style.width=f+"px",d.style.height=p+"px",d.width=f,d.height=p,d}stopStreams(){this.stream&&(this.stream.getVideoTracks().forEach(o=>o.stop()),this.stream=void 0),this._stopAsyncDecode===!1&&this.stopAsyncDecode(),this._stopContinuousDecode===!1&&this.stopContinuousDecode()}reset(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()}_destroyVideoElement(){this.videoElement&&(typeof this.videoEndedListener!="undefined"&&this.videoElement.removeEventListener("ended",this.videoEndedListener),typeof this.videoPlayingEventListener!="undefined"&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),typeof this.videoCanPlayListener!="undefined"&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)}_destroyImageElement(){this.imageElement&&(this.imageLoadedListener!==void 0&&this.imageElement.removeEventListener("load",this.imageLoadedListener),this.imageElement.src=void 0,this.imageElement.removeAttribute("src"),this.imageElement=void 0)}_destroyCaptureCanvas(){this.captureCanvasContext=void 0,this.captureCanvas=void 0}addVideoSource(o,d){try{o.srcObject=d}catch(f){o.src=URL.createObjectURL(d)}}cleanVideoSource(o){try{o.srcObject=null}catch(d){o.src=""}this.videoElement.removeAttribute("src")}}class re{constructor(o,d,f=d==null?0:8*d.length,p,b,w=A.currentTimeMillis()){this.text=o,this.rawBytes=d,this.numBits=f,this.resultPoints=p,this.format=b,this.timestamp=w,this.text=o,this.rawBytes=d,f==null?this.numBits=d==null?0:8*d.length:this.numBits=f,this.resultPoints=p,this.format=b,this.resultMetadata=null,w==null?this.timestamp=A.currentTimeMillis():this.timestamp=w}getText(){return this.text}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}getResultPoints(){return this.resultPoints}getBarcodeFormat(){return this.format}getResultMetadata(){return this.resultMetadata}putMetadata(o,d){this.resultMetadata===null&&(this.resultMetadata=new Map),this.resultMetadata.set(o,d)}putAllMetadata(o){o!==null&&(this.resultMetadata===null?this.resultMetadata=o:this.resultMetadata=new Map(o))}addResultPoints(o){const d=this.resultPoints;if(d===null)this.resultPoints=o;else if(o!==null&&o.length>0){const f=new Array(d.length+o.length);A.arraycopy(d,0,f,0,d.length),A.arraycopy(o,0,f,d.length,o.length),this.resultPoints=f}}getTimestamp(){return this.timestamp}toString(){return this.text}}var ne;(function(ee){ee[ee.AZTEC=0]="AZTEC",ee[ee.CODABAR=1]="CODABAR",ee[ee.CODE_39=2]="CODE_39",ee[ee.CODE_93=3]="CODE_93",ee[ee.CODE_128=4]="CODE_128",ee[ee.DATA_MATRIX=5]="DATA_MATRIX",ee[ee.EAN_8=6]="EAN_8",ee[ee.EAN_13=7]="EAN_13",ee[ee.ITF=8]="ITF",ee[ee.MAXICODE=9]="MAXICODE",ee[ee.PDF_417=10]="PDF_417",ee[ee.QR_CODE=11]="QR_CODE",ee[ee.RSS_14=12]="RSS_14",ee[ee.RSS_EXPANDED=13]="RSS_EXPANDED",ee[ee.UPC_A=14]="UPC_A",ee[ee.UPC_E=15]="UPC_E",ee[ee.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(ne||(ne={}));var ve=ne,Ve;(function(ee){ee[ee.OTHER=0]="OTHER",ee[ee.ORIENTATION=1]="ORIENTATION",ee[ee.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",ee[ee.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",ee[ee.ISSUE_NUMBER=4]="ISSUE_NUMBER",ee[ee.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",ee[ee.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",ee[ee.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",ee[ee.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",ee[ee.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",ee[ee.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"})(Ve||(Ve={}));var Ae=Ve;class ze{constructor(o,d,f,p,b=-1,w=-1){this.rawBytes=o,this.text=d,this.byteSegments=f,this.ecLevel=p,this.structuredAppendSequenceNumber=b,this.structuredAppendParity=w,this.numBits=o==null?0:8*o.length}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}setNumBits(o){this.numBits=o}getText(){return this.text}getByteSegments(){return this.byteSegments}getECLevel(){return this.ecLevel}getErrorsCorrected(){return this.errorsCorrected}setErrorsCorrected(o){this.errorsCorrected=o}getErasures(){return this.erasures}setErasures(o){this.erasures=o}getOther(){return this.other}setOther(o){this.other=o}hasStructuredAppend(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0}getStructuredAppendParity(){return this.structuredAppendParity}getStructuredAppendSequenceNumber(){return this.structuredAppendSequenceNumber}}class Re{exp(o){return this.expTable[o]}log(o){if(o===0)throw new N;return this.logTable[o]}static addOrSubtract(o,d){return o^d}}class Ze{constructor(o,d){if(d.length===0)throw new N;this.field=o;const f=d.length;if(f>1&&d[0]===0){let p=1;for(;p<f&&d[p]===0;)p++;p===f?this.coefficients=Int32Array.from([0]):(this.coefficients=new Int32Array(f-p),A.arraycopy(d,p,this.coefficients,0,this.coefficients.length))}else this.coefficients=d}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(o){return this.coefficients[this.coefficients.length-1-o]}evaluateAt(o){if(o===0)return this.getCoefficient(0);const d=this.coefficients;let f;if(o===1){f=0;for(let w=0,S=d.length;w!==S;w++){const R=d[w];f=Re.addOrSubtract(f,R)}return f}f=d[0];const p=d.length,b=this.field;for(let w=1;w<p;w++)f=Re.addOrSubtract(b.multiply(o,f),d[w]);return f}addOrSubtract(o){if(!this.field.equals(o.field))throw new N("GenericGFPolys do not have same GenericGF field");if(this.isZero())return o;if(o.isZero())return this;let d=this.coefficients,f=o.coefficients;if(d.length>f.length){const w=d;d=f,f=w}let p=new Int32Array(f.length);const b=f.length-d.length;A.arraycopy(f,0,p,0,b);for(let w=b;w<f.length;w++)p[w]=Re.addOrSubtract(d[w-b],f[w]);return new Ze(this.field,p)}multiply(o){if(!this.field.equals(o.field))throw new N("GenericGFPolys do not have same GenericGF field");if(this.isZero()||o.isZero())return this.field.getZero();const d=this.coefficients,f=d.length,p=o.coefficients,b=p.length,w=new Int32Array(f+b-1),S=this.field;for(let R=0;R<f;R++){const P=d[R];for(let X=0;X<b;X++)w[R+X]=Re.addOrSubtract(w[R+X],S.multiply(P,p[X]))}return new Ze(S,w)}multiplyScalar(o){if(o===0)return this.field.getZero();if(o===1)return this;const d=this.coefficients.length,f=this.field,p=new Int32Array(d),b=this.coefficients;for(let w=0;w<d;w++)p[w]=f.multiply(b[w],o);return new Ze(f,p)}multiplyByMonomial(o,d){if(o<0)throw new N;if(d===0)return this.field.getZero();const f=this.coefficients,p=f.length,b=new Int32Array(p+o),w=this.field;for(let S=0;S<p;S++)b[S]=w.multiply(f[S],d);return new Ze(w,b)}divide(o){if(!this.field.equals(o.field))throw new N("GenericGFPolys do not have same GenericGF field");if(o.isZero())throw new N("Divide by 0");const d=this.field;let f=d.getZero(),p=this;const b=o.getCoefficient(o.getDegree()),w=d.inverse(b);for(;p.getDegree()>=o.getDegree()&&!p.isZero();){const S=p.getDegree()-o.getDegree(),R=d.multiply(p.getCoefficient(p.getDegree()),w),P=o.multiplyByMonomial(S,R),X=d.buildMonomial(S,R);f=f.addOrSubtract(X),p=p.addOrSubtract(P)}return[f,p]}toString(){let o="";for(let d=this.getDegree();d>=0;d--){let f=this.getCoefficient(d);if(f!==0){if(f<0?(o+=" - ",f=-f):o.length>0&&(o+=" + "),d===0||f!==1){const p=this.field.log(f);p===0?o+="1":p===1?o+="a":(o+="a^",o+=p)}d!==0&&(d===1?o+="x":(o+="x^",o+=d))}}return o}}class Lt extends x{}Lt.kind="ArithmeticException";class mt extends Re{constructor(o,d,f){super(),this.primitive=o,this.size=d,this.generatorBase=f;const p=new Int32Array(d);let b=1;for(let S=0;S<d;S++)p[S]=b,b*=2,b>=d&&(b^=o,b&=d-1);this.expTable=p;const w=new Int32Array(d);for(let S=0;S<d-1;S++)w[p[S]]=S;this.logTable=w,this.zero=new Ze(this,Int32Array.from([0])),this.one=new Ze(this,Int32Array.from([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(o,d){if(o<0)throw new N;if(d===0)return this.zero;const f=new Int32Array(o+1);return f[0]=d,new Ze(this,f)}inverse(o){if(o===0)throw new Lt;return this.expTable[this.size-this.logTable[o]-1]}multiply(o,d){return o===0||d===0?0:this.expTable[(this.logTable[o]+this.logTable[d])%(this.size-1)]}getSize(){return this.size}getGeneratorBase(){return this.generatorBase}toString(){return"GF(0x"+B.toHexString(this.primitive)+","+this.size+")"}equals(o){return o===this}}mt.AZTEC_DATA_12=new mt(4201,4096,1),mt.AZTEC_DATA_10=new mt(1033,1024,1),mt.AZTEC_DATA_6=new mt(67,64,1),mt.AZTEC_PARAM=new mt(19,16,1),mt.QR_CODE_FIELD_256=new mt(285,256,0),mt.DATA_MATRIX_FIELD_256=new mt(301,256,1),mt.AZTEC_DATA_8=mt.DATA_MATRIX_FIELD_256,mt.MAXICODE_FIELD_64=mt.AZTEC_DATA_6;class Zt extends x{}Zt.kind="ReedSolomonException";class ar extends x{}ar.kind="IllegalStateException";class or{constructor(o){this.field=o}decode(o,d){const f=this.field,p=new Ze(f,o),b=new Int32Array(d);let w=!0;for(let je=0;je<d;je++){const Fe=p.evaluateAt(f.exp(je+f.getGeneratorBase()));b[b.length-1-je]=Fe,Fe!==0&&(w=!1)}if(w)return;const S=new Ze(f,b),R=this.runEuclideanAlgorithm(f.buildMonomial(d,1),S,d),P=R[0],X=R[1],te=this.findErrorLocations(P),ue=this.findErrorMagnitudes(X,te);for(let je=0;je<te.length;je++){const Fe=o.length-1-f.log(te[je]);if(Fe<0)throw new Zt("Bad error location");o[Fe]=mt.addOrSubtract(o[Fe],ue[je])}}runEuclideanAlgorithm(o,d,f){if(o.getDegree()<d.getDegree()){const je=o;o=d,d=je}const p=this.field;let b=o,w=d,S=p.getZero(),R=p.getOne();for(;w.getDegree()>=(f/2|0);){let je=b,Fe=S;if(b=w,S=R,b.isZero())throw new Zt("r_{i-1} was zero");w=je;let Ue=p.getZero();const tt=b.getCoefficient(b.getDegree()),ut=p.inverse(tt);for(;w.getDegree()>=b.getDegree()&&!w.isZero();){const Xt=w.getDegree()-b.getDegree(),Gt=p.multiply(w.getCoefficient(w.getDegree()),ut);Ue=Ue.addOrSubtract(p.buildMonomial(Xt,Gt)),w=w.addOrSubtract(b.multiplyByMonomial(Xt,Gt))}if(R=Ue.multiply(S).addOrSubtract(Fe),w.getDegree()>=b.getDegree())throw new ar("Division algorithm failed to reduce polynomial?")}const P=R.getCoefficient(0);if(P===0)throw new Zt("sigmaTilde(0) was zero");const X=p.inverse(P),te=R.multiplyScalar(X),ue=w.multiplyScalar(X);return[te,ue]}findErrorLocations(o){const d=o.getDegree();if(d===1)return Int32Array.from([o.getCoefficient(1)]);const f=new Int32Array(d);let p=0;const b=this.field;for(let w=1;w<b.getSize()&&p<d;w++)o.evaluateAt(w)===0&&(f[p]=b.inverse(w),p++);if(p!==d)throw new Zt("Error locator degree does not match number of roots");return f}findErrorMagnitudes(o,d){const f=d.length,p=new Int32Array(f),b=this.field;for(let w=0;w<f;w++){const S=b.inverse(d[w]);let R=1;for(let P=0;P<f;P++)if(w!==P){const X=b.multiply(d[P],S),te=(X&1)===0?X|1:X&-2;R=b.multiply(R,te)}p[w]=b.multiply(o.evaluateAt(S),b.inverse(R)),b.getGeneratorBase()!==0&&(p[w]=b.multiply(p[w],S))}return p}}var yt;(function(ee){ee[ee.UPPER=0]="UPPER",ee[ee.LOWER=1]="LOWER",ee[ee.MIXED=2]="MIXED",ee[ee.DIGIT=3]="DIGIT",ee[ee.PUNCT=4]="PUNCT",ee[ee.BINARY=5]="BINARY"})(yt||(yt={}));class nr{decode(o){this.ddata=o;let d=o.getBits(),f=this.extractBits(d),p=this.correctBits(f),b=nr.convertBoolArrayToByteArray(p),w=nr.getEncodedData(p),S=new ze(b,w,null,null);return S.setNumBits(p.length),S}static highLevelDecode(o){return this.getEncodedData(o)}static getEncodedData(o){let d=o.length,f=yt.UPPER,p=yt.UPPER,b="",w=0;for(;w<d;)if(p===yt.BINARY){if(d-w<5)break;let S=nr.readCode(o,w,5);if(w+=5,S===0){if(d-w<11)break;S=nr.readCode(o,w,11)+31,w+=11}for(let R=0;R<S;R++){if(d-w<8){w=d;break}const P=nr.readCode(o,w,8);b+=se.castAsNonUtf8Char(P),w+=8}p=f}else{let S=p===yt.DIGIT?4:5;if(d-w<S)break;let R=nr.readCode(o,w,S);w+=S;let P=nr.getCharacter(p,R);P.startsWith("CTRL_")?(f=p,p=nr.getTable(P.charAt(5)),P.charAt(6)==="L"&&(f=p)):(b+=P,p=f)}return b}static getTable(o){switch(o){case"L":return yt.LOWER;case"P":return yt.PUNCT;case"M":return yt.MIXED;case"D":return yt.DIGIT;case"B":return yt.BINARY;case"U":default:return yt.UPPER}}static getCharacter(o,d){switch(o){case yt.UPPER:return nr.UPPER_TABLE[d];case yt.LOWER:return nr.LOWER_TABLE[d];case yt.MIXED:return nr.MIXED_TABLE[d];case yt.PUNCT:return nr.PUNCT_TABLE[d];case yt.DIGIT:return nr.DIGIT_TABLE[d];default:throw new ar("Bad table")}}correctBits(o){let d,f;this.ddata.getNbLayers()<=2?(f=6,d=mt.AZTEC_DATA_6):this.ddata.getNbLayers()<=8?(f=8,d=mt.AZTEC_DATA_8):this.ddata.getNbLayers()<=22?(f=10,d=mt.AZTEC_DATA_10):(f=12,d=mt.AZTEC_DATA_12);let p=this.ddata.getNbDatablocks(),b=o.length/f;if(b<p)throw new H;let w=o.length%f,S=new Int32Array(b);for(let ue=0;ue<b;ue++,w+=f)S[ue]=nr.readCode(o,w,f);try{new or(d).decode(S,b-p)}catch(ue){throw new H(ue)}let R=(1<<f)-1,P=0;for(let ue=0;ue<p;ue++){let je=S[ue];if(je===0||je===R)throw new H;(je===1||je===R-1)&&P++}let X=new Array(p*f-P),te=0;for(let ue=0;ue<p;ue++){let je=S[ue];if(je===1||je===R-1)X.fill(je>1,te,te+f-1),te+=f-1;else for(let Fe=f-1;Fe>=0;--Fe)X[te++]=(je&1<<Fe)!==0}return X}extractBits(o){let d=this.ddata.isCompact(),f=this.ddata.getNbLayers(),p=(d?11:14)+f*4,b=new Int32Array(p),w=new Array(this.totalBitsInLayer(f,d));if(d)for(let S=0;S<b.length;S++)b[S]=S;else{let S=p+1+2*B.truncDivision(B.truncDivision(p,2)-1,15),R=p/2,P=B.truncDivision(S,2);for(let X=0;X<R;X++){let te=X+B.truncDivision(X,15);b[R-X-1]=P-te-1,b[R+X]=P+te+1}}for(let S=0,R=0;S<f;S++){let P=(f-S)*4+(d?9:12),X=S*2,te=p-1-X;for(let ue=0;ue<P;ue++){let je=ue*2;for(let Fe=0;Fe<2;Fe++)w[R+je+Fe]=o.get(b[X+Fe],b[X+ue]),w[R+2*P+je+Fe]=o.get(b[X+ue],b[te-Fe]),w[R+4*P+je+Fe]=o.get(b[te-Fe],b[te-ue]),w[R+6*P+je+Fe]=o.get(b[te-ue],b[X+Fe])}R+=P*8}return w}static readCode(o,d,f){let p=0;for(let b=d;b<d+f;b++)p<<=1,o[b]&&(p|=1);return p}static readByte(o,d){let f=o.length-d;return f>=8?nr.readCode(o,d,8):nr.readCode(o,d,f)<<8-f}static convertBoolArrayToByteArray(o){let d=new Uint8Array((o.length+7)/8);for(let f=0;f<d.length;f++)d[f]=nr.readByte(o,8*f);return d}totalBitsInLayer(o,d){return((d?88:112)+16*o)*o}}nr.UPPER_TABLE=["CTRL_PS"," ","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","CTRL_LL","CTRL_ML","CTRL_DL","CTRL_BS"],nr.LOWER_TABLE=["CTRL_PS"," ","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","CTRL_US","CTRL_ML","CTRL_DL","CTRL_BS"],nr.MIXED_TABLE=["CTRL_PS"," ","\\1","\\2","\\3","\\4","\\5","\\6","\\7","\b"," ",`
|
||
`,"\\13","\f","\r","\\33","\\34","\\35","\\36","\\37","@","\\","^","_","`","|","~","\\177","CTRL_LL","CTRL_UL","CTRL_PL","CTRL_BS"],nr.PUNCT_TABLE=["","\r",`\r
|
||
`,". ",", ",": ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}","CTRL_UL"],nr.DIGIT_TABLE=["CTRL_PS"," ","0","1","2","3","4","5","6","7","8","9",",",".","CTRL_UL","CTRL_US"];class $t{constructor(){}static round(o){return o===NaN?0:o<=Number.MIN_SAFE_INTEGER?Number.MIN_SAFE_INTEGER:o>=Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:o+(o<0?-.5:.5)|0}static distance(o,d,f,p){const b=o-f,w=d-p;return Math.sqrt(b*b+w*w)}static sum(o){let d=0;for(let f=0,p=o.length;f!==p;f++){const b=o[f];d+=b}return d}}class Er{static floatToIntBits(o){return o}}Er.MAX_VALUE=Number.MAX_SAFE_INTEGER;class St{constructor(o,d){this.x=o,this.y=d}getX(){return this.x}getY(){return this.y}equals(o){if(o instanceof St){const d=o;return this.x===d.x&&this.y===d.y}return!1}hashCode(){return 31*Er.floatToIntBits(this.x)+Er.floatToIntBits(this.y)}toString(){return"("+this.x+","+this.y+")"}static orderBestPatterns(o){const d=this.distance(o[0],o[1]),f=this.distance(o[1],o[2]),p=this.distance(o[0],o[2]);let b,w,S;if(f>=d&&f>=p?(w=o[0],b=o[1],S=o[2]):p>=f&&p>=d?(w=o[1],b=o[0],S=o[2]):(w=o[2],b=o[0],S=o[1]),this.crossProductZ(b,w,S)<0){const R=b;b=S,S=R}o[0]=b,o[1]=w,o[2]=S}static distance(o,d){return $t.distance(o.x,o.y,d.x,d.y)}static crossProductZ(o,d,f){const p=d.x,b=d.y;return(f.x-p)*(o.y-b)-(f.y-b)*(o.x-p)}}class Br{constructor(o,d){this.bits=o,this.points=d}getBits(){return this.bits}getPoints(){return this.points}}class Pt extends Br{constructor(o,d,f,p,b){super(o,d),this.compact=f,this.nbDatablocks=p,this.nbLayers=b}getNbLayers(){return this.nbLayers}getNbDatablocks(){return this.nbDatablocks}isCompact(){return this.compact}}class it{constructor(o,d,f,p){this.image=o,this.height=o.getHeight(),this.width=o.getWidth(),d==null&&(d=it.INIT_SIZE),f==null&&(f=o.getWidth()/2|0),p==null&&(p=o.getHeight()/2|0);const b=d/2|0;if(this.leftInit=f-b,this.rightInit=f+b,this.upInit=p-b,this.downInit=p+b,this.upInit<0||this.leftInit<0||this.downInit>=this.height||this.rightInit>=this.width)throw new ae}detect(){let o=this.leftInit,d=this.rightInit,f=this.upInit,p=this.downInit,b=!1,w=!0,S=!1,R=!1,P=!1,X=!1,te=!1;const ue=this.width,je=this.height;for(;w;){w=!1;let Fe=!0;for(;(Fe||!R)&&d<ue;)Fe=this.containsBlackPoint(f,p,d,!1),Fe?(d++,w=!0,R=!0):R||d++;if(d>=ue){b=!0;break}let Ue=!0;for(;(Ue||!P)&&p<je;)Ue=this.containsBlackPoint(o,d,p,!0),Ue?(p++,w=!0,P=!0):P||p++;if(p>=je){b=!0;break}let tt=!0;for(;(tt||!X)&&o>=0;)tt=this.containsBlackPoint(f,p,o,!1),tt?(o--,w=!0,X=!0):X||o--;if(o<0){b=!0;break}let ut=!0;for(;(ut||!te)&&f>=0;)ut=this.containsBlackPoint(o,d,f,!0),ut?(f--,w=!0,te=!0):te||f--;if(f<0){b=!0;break}w&&(S=!0)}if(!b&&S){const Fe=d-o;let Ue=null;for(let Gt=1;Ue===null&&Gt<Fe;Gt++)Ue=this.getBlackPointOnSegment(o,p-Gt,o+Gt,p);if(Ue==null)throw new ae;let tt=null;for(let Gt=1;tt===null&&Gt<Fe;Gt++)tt=this.getBlackPointOnSegment(o,f+Gt,o+Gt,f);if(tt==null)throw new ae;let ut=null;for(let Gt=1;ut===null&&Gt<Fe;Gt++)ut=this.getBlackPointOnSegment(d,f+Gt,d-Gt,f);if(ut==null)throw new ae;let Xt=null;for(let Gt=1;Xt===null&&Gt<Fe;Gt++)Xt=this.getBlackPointOnSegment(d,p-Gt,d-Gt,p);if(Xt==null)throw new ae;return this.centerEdges(Xt,Ue,ut,tt)}else throw new ae}getBlackPointOnSegment(o,d,f,p){const b=$t.round($t.distance(o,d,f,p)),w=(f-o)/b,S=(p-d)/b,R=this.image;for(let P=0;P<b;P++){const X=$t.round(o+P*w),te=$t.round(d+P*S);if(R.get(X,te))return new St(X,te)}return null}centerEdges(o,d,f,p){const b=o.getX(),w=o.getY(),S=d.getX(),R=d.getY(),P=f.getX(),X=f.getY(),te=p.getX(),ue=p.getY(),je=it.CORR;return b<this.width/2?[new St(te-je,ue+je),new St(S+je,R+je),new St(P-je,X-je),new St(b+je,w-je)]:[new St(te+je,ue+je),new St(S+je,R-je),new St(P-je,X+je),new St(b-je,w-je)]}containsBlackPoint(o,d,f,p){const b=this.image;if(p){for(let w=o;w<=d;w++)if(b.get(w,f))return!0}else for(let w=o;w<=d;w++)if(b.get(f,w))return!0;return!1}}it.INIT_SIZE=10,it.CORR=1;class De{static checkAndNudgePoints(o,d){const f=o.getWidth(),p=o.getHeight();let b=!0;for(let w=0;w<d.length&&b;w+=2){const S=Math.floor(d[w]),R=Math.floor(d[w+1]);if(S<-1||S>f||R<-1||R>p)throw new ae;b=!1,S===-1?(d[w]=0,b=!0):S===f&&(d[w]=f-1,b=!0),R===-1?(d[w+1]=0,b=!0):R===p&&(d[w+1]=p-1,b=!0)}b=!0;for(let w=d.length-2;w>=0&&b;w-=2){const S=Math.floor(d[w]),R=Math.floor(d[w+1]);if(S<-1||S>f||R<-1||R>p)throw new ae;b=!1,S===-1?(d[w]=0,b=!0):S===f&&(d[w]=f-1,b=!0),R===-1?(d[w+1]=0,b=!0):R===p&&(d[w+1]=p-1,b=!0)}}}class Je{constructor(o,d,f,p,b,w,S,R,P){this.a11=o,this.a21=d,this.a31=f,this.a12=p,this.a22=b,this.a32=w,this.a13=S,this.a23=R,this.a33=P}static quadrilateralToQuadrilateral(o,d,f,p,b,w,S,R,P,X,te,ue,je,Fe,Ue,tt){const ut=Je.quadrilateralToSquare(o,d,f,p,b,w,S,R);return Je.squareToQuadrilateral(P,X,te,ue,je,Fe,Ue,tt).times(ut)}transformPoints(o){const d=o.length,f=this.a11,p=this.a12,b=this.a13,w=this.a21,S=this.a22,R=this.a23,P=this.a31,X=this.a32,te=this.a33;for(let ue=0;ue<d;ue+=2){const je=o[ue],Fe=o[ue+1],Ue=b*je+R*Fe+te;o[ue]=(f*je+w*Fe+P)/Ue,o[ue+1]=(p*je+S*Fe+X)/Ue}}transformPointsWithValues(o,d){const f=this.a11,p=this.a12,b=this.a13,w=this.a21,S=this.a22,R=this.a23,P=this.a31,X=this.a32,te=this.a33,ue=o.length;for(let je=0;je<ue;je++){const Fe=o[je],Ue=d[je],tt=b*Fe+R*Ue+te;o[je]=(f*Fe+w*Ue+P)/tt,d[je]=(p*Fe+S*Ue+X)/tt}}static squareToQuadrilateral(o,d,f,p,b,w,S,R){const P=o-f+b-S,X=d-p+w-R;if(P===0&&X===0)return new Je(f-o,b-f,o,p-d,w-p,d,0,0,1);{const te=f-b,ue=S-b,je=p-w,Fe=R-w,Ue=te*Fe-ue*je,tt=(P*Fe-ue*X)/Ue,ut=(te*X-P*je)/Ue;return new Je(f-o+tt*f,S-o+ut*S,o,p-d+tt*p,R-d+ut*R,d,tt,ut,1)}}static quadrilateralToSquare(o,d,f,p,b,w,S,R){return Je.squareToQuadrilateral(o,d,f,p,b,w,S,R).buildAdjoint()}buildAdjoint(){return new Je(this.a22*this.a33-this.a23*this.a32,this.a23*this.a31-this.a21*this.a33,this.a21*this.a32-this.a22*this.a31,this.a13*this.a32-this.a12*this.a33,this.a11*this.a33-this.a13*this.a31,this.a12*this.a31-this.a11*this.a32,this.a12*this.a23-this.a13*this.a22,this.a13*this.a21-this.a11*this.a23,this.a11*this.a22-this.a12*this.a21)}times(o){return new Je(this.a11*o.a11+this.a21*o.a12+this.a31*o.a13,this.a11*o.a21+this.a21*o.a22+this.a31*o.a23,this.a11*o.a31+this.a21*o.a32+this.a31*o.a33,this.a12*o.a11+this.a22*o.a12+this.a32*o.a13,this.a12*o.a21+this.a22*o.a22+this.a32*o.a23,this.a12*o.a31+this.a22*o.a32+this.a32*o.a33,this.a13*o.a11+this.a23*o.a12+this.a33*o.a13,this.a13*o.a21+this.a23*o.a22+this.a33*o.a23,this.a13*o.a31+this.a23*o.a32+this.a33*o.a33)}}class Be extends De{sampleGrid(o,d,f,p,b,w,S,R,P,X,te,ue,je,Fe,Ue,tt,ut,Xt,Gt){const Ft=Je.quadrilateralToQuadrilateral(p,b,w,S,R,P,X,te,ue,je,Fe,Ue,tt,ut,Xt,Gt);return this.sampleGridWithTransform(o,d,f,Ft)}sampleGridWithTransform(o,d,f,p){if(d<=0||f<=0)throw new ae;const b=new Ce(d,f),w=new Float32Array(2*d);for(let S=0;S<f;S++){const R=w.length,P=S+.5;for(let X=0;X<R;X+=2)w[X]=X/2+.5,w[X+1]=P;p.transformPoints(w),De.checkAndNudgePoints(o,w);try{for(let X=0;X<R;X+=2)o.get(Math.floor(w[X]),Math.floor(w[X+1]))&&b.set(X/2,S)}catch(X){throw new ae}}return b}}class vt{static setGridSampler(o){vt.gridSampler=o}static getInstance(){return vt.gridSampler}}vt.gridSampler=new Be;class jt{constructor(o,d){this.x=o,this.y=d}toResultPoint(){return new St(this.getX(),this.getY())}getX(){return this.x}getY(){return this.y}}class Ct{constructor(o){this.EXPECTED_CORNER_BITS=new Int32Array([3808,476,2107,1799]),this.image=o}detect(){return this.detectMirror(!1)}detectMirror(o){let d=this.getMatrixCenter(),f=this.getBullsEyeCorners(d);if(o){let w=f[0];f[0]=f[2],f[2]=w}this.extractParameters(f);let p=this.sampleGrid(this.image,f[this.shift%4],f[(this.shift+1)%4],f[(this.shift+2)%4],f[(this.shift+3)%4]),b=this.getMatrixCornerPoints(f);return new Pt(p,b,this.compact,this.nbDataBlocks,this.nbLayers)}extractParameters(o){if(!this.isValidPoint(o[0])||!this.isValidPoint(o[1])||!this.isValidPoint(o[2])||!this.isValidPoint(o[3]))throw new ae;let d=2*this.nbCenterLayers,f=new Int32Array([this.sampleLine(o[0],o[1],d),this.sampleLine(o[1],o[2],d),this.sampleLine(o[2],o[3],d),this.sampleLine(o[3],o[0],d)]);this.shift=this.getRotation(f,d);let p=0;for(let w=0;w<4;w++){let S=f[(this.shift+w)%4];this.compact?(p<<=7,p+=S>>1&127):(p<<=10,p+=(S>>2&992)+(S>>1&31))}let b=this.getCorrectedParameterData(p,this.compact);this.compact?(this.nbLayers=(b>>6)+1,this.nbDataBlocks=(b&63)+1):(this.nbLayers=(b>>11)+1,this.nbDataBlocks=(b&2047)+1)}getRotation(o,d){let f=0;o.forEach((p,b,w)=>{let S=(p>>d-2<<1)+(p&1);f=(f<<3)+S}),f=((f&1)<<11)+(f>>1);for(let p=0;p<4;p++)if(B.bitCount(f^this.EXPECTED_CORNER_BITS[p])<=2)return p;throw new ae}getCorrectedParameterData(o,d){let f,p;d?(f=7,p=2):(f=10,p=4);let b=f-p,w=new Int32Array(f);for(let R=f-1;R>=0;--R)w[R]=o&15,o>>=4;try{new or(mt.AZTEC_PARAM).decode(w,b)}catch(R){throw new ae}let S=0;for(let R=0;R<p;R++)S=(S<<4)+w[R];return S}getBullsEyeCorners(o){let d=o,f=o,p=o,b=o,w=!0;for(this.nbCenterLayers=1;this.nbCenterLayers<9;this.nbCenterLayers++){let te=this.getFirstDifferent(d,w,1,-1),ue=this.getFirstDifferent(f,w,1,1),je=this.getFirstDifferent(p,w,-1,1),Fe=this.getFirstDifferent(b,w,-1,-1);if(this.nbCenterLayers>2){let Ue=this.distancePoint(Fe,te)*this.nbCenterLayers/(this.distancePoint(b,d)*(this.nbCenterLayers+2));if(Ue<.75||Ue>1.25||!this.isWhiteOrBlackRectangle(te,ue,je,Fe))break}d=te,f=ue,p=je,b=Fe,w=!w}if(this.nbCenterLayers!==5&&this.nbCenterLayers!==7)throw new ae;this.compact=this.nbCenterLayers===5;let S=new St(d.getX()+.5,d.getY()-.5),R=new St(f.getX()+.5,f.getY()+.5),P=new St(p.getX()-.5,p.getY()+.5),X=new St(b.getX()-.5,b.getY()-.5);return this.expandSquare([S,R,P,X],2*this.nbCenterLayers-3,2*this.nbCenterLayers)}getMatrixCenter(){let o,d,f,p;try{let S=new it(this.image).detect();o=S[0],d=S[1],f=S[2],p=S[3]}catch(S){let R=this.image.getWidth()/2,P=this.image.getHeight()/2;o=this.getFirstDifferent(new jt(R+7,P-7),!1,1,-1).toResultPoint(),d=this.getFirstDifferent(new jt(R+7,P+7),!1,1,1).toResultPoint(),f=this.getFirstDifferent(new jt(R-7,P+7),!1,-1,1).toResultPoint(),p=this.getFirstDifferent(new jt(R-7,P-7),!1,-1,-1).toResultPoint()}let b=$t.round((o.getX()+p.getX()+d.getX()+f.getX())/4),w=$t.round((o.getY()+p.getY()+d.getY()+f.getY())/4);try{let S=new it(this.image,15,b,w).detect();o=S[0],d=S[1],f=S[2],p=S[3]}catch(S){o=this.getFirstDifferent(new jt(b+7,w-7),!1,1,-1).toResultPoint(),d=this.getFirstDifferent(new jt(b+7,w+7),!1,1,1).toResultPoint(),f=this.getFirstDifferent(new jt(b-7,w+7),!1,-1,1).toResultPoint(),p=this.getFirstDifferent(new jt(b-7,w-7),!1,-1,-1).toResultPoint()}return b=$t.round((o.getX()+p.getX()+d.getX()+f.getX())/4),w=$t.round((o.getY()+p.getY()+d.getY()+f.getY())/4),new jt(b,w)}getMatrixCornerPoints(o){return this.expandSquare(o,2*this.nbCenterLayers,this.getDimension())}sampleGrid(o,d,f,p,b){let w=vt.getInstance(),S=this.getDimension(),R=S/2-this.nbCenterLayers,P=S/2+this.nbCenterLayers;return w.sampleGrid(o,S,S,R,R,P,R,P,P,R,P,d.getX(),d.getY(),f.getX(),f.getY(),p.getX(),p.getY(),b.getX(),b.getY())}sampleLine(o,d,f){let p=0,b=this.distanceResultPoint(o,d),w=b/f,S=o.getX(),R=o.getY(),P=w*(d.getX()-o.getX())/b,X=w*(d.getY()-o.getY())/b;for(let te=0;te<f;te++)this.image.get($t.round(S+te*P),$t.round(R+te*X))&&(p|=1<<f-te-1);return p}isWhiteOrBlackRectangle(o,d,f,p){let b=3;o=new jt(o.getX()-b,o.getY()+b),d=new jt(d.getX()-b,d.getY()-b),f=new jt(f.getX()+b,f.getY()-b),p=new jt(p.getX()+b,p.getY()+b);let w=this.getColor(p,o);if(w===0)return!1;let S=this.getColor(o,d);return S!==w||(S=this.getColor(d,f),S!==w)?!1:(S=this.getColor(f,p),S===w)}getColor(o,d){let f=this.distancePoint(o,d),p=(d.getX()-o.getX())/f,b=(d.getY()-o.getY())/f,w=0,S=o.getX(),R=o.getY(),P=this.image.get(o.getX(),o.getY()),X=Math.ceil(f);for(let ue=0;ue<X;ue++)S+=p,R+=b,this.image.get($t.round(S),$t.round(R))!==P&&w++;let te=w/f;return te>.1&&te<.9?0:te<=.1===P?1:-1}getFirstDifferent(o,d,f,p){let b=o.getX()+f,w=o.getY()+p;for(;this.isValid(b,w)&&this.image.get(b,w)===d;)b+=f,w+=p;for(b-=f,w-=p;this.isValid(b,w)&&this.image.get(b,w)===d;)b+=f;for(b-=f;this.isValid(b,w)&&this.image.get(b,w)===d;)w+=p;return w-=p,new jt(b,w)}expandSquare(o,d,f){let p=f/(2*d),b=o[0].getX()-o[2].getX(),w=o[0].getY()-o[2].getY(),S=(o[0].getX()+o[2].getX())/2,R=(o[0].getY()+o[2].getY())/2,P=new St(S+p*b,R+p*w),X=new St(S-p*b,R-p*w);b=o[1].getX()-o[3].getX(),w=o[1].getY()-o[3].getY(),S=(o[1].getX()+o[3].getX())/2,R=(o[1].getY()+o[3].getY())/2;let te=new St(S+p*b,R+p*w),ue=new St(S-p*b,R-p*w);return[P,te,X,ue]}isValid(o,d){return o>=0&&o<this.image.getWidth()&&d>0&&d<this.image.getHeight()}isValidPoint(o){let d=$t.round(o.getX()),f=$t.round(o.getY());return this.isValid(d,f)}distancePoint(o,d){return $t.distance(o.getX(),o.getY(),d.getX(),d.getY())}distanceResultPoint(o,d){return $t.distance(o.getX(),o.getY(),d.getX(),d.getY())}getDimension(){return this.compact?4*this.nbLayers+11:this.nbLayers<=4?4*this.nbLayers+15:4*this.nbLayers+2*(B.truncDivision(this.nbLayers-4,8)+1)+15}}class Wt{decode(o,d=null){let f=null,p=new Ct(o.getBlackMatrix()),b=null,w=null;try{let X=p.detectMirror(!1);b=X.getPoints(),this.reportFoundResultPoints(d,b),w=new nr().decode(X)}catch(X){f=X}if(w==null)try{let X=p.detectMirror(!0);b=X.getPoints(),this.reportFoundResultPoints(d,b),w=new nr().decode(X)}catch(X){throw f!=null?f:X}let S=new re(w.getText(),w.getRawBytes(),w.getNumBits(),b,ve.AZTEC,A.currentTimeMillis()),R=w.getByteSegments();R!=null&&S.putMetadata(Ae.BYTE_SEGMENTS,R);let P=w.getECLevel();return P!=null&&S.putMetadata(Ae.ERROR_CORRECTION_LEVEL,P),S}reportFoundResultPoints(o,d){if(o!=null){let f=o.get(W.NEED_RESULT_POINT_CALLBACK);f!=null&&d.forEach((p,b,w)=>{f.foundPossibleResultPoint(p)})}}reset(){}}class pr extends ie{constructor(o=500){super(new Wt,o)}}class Ge{decode(o,d){try{return this.doDecode(o,d)}catch(f){if(d&&d.get(W.TRY_HARDER)===!0&&o.isRotateSupported()){const b=o.rotateCounterClockwise(),w=this.doDecode(b,d),S=w.getResultMetadata();let R=270;S!==null&&S.get(Ae.ORIENTATION)===!0&&(R=R+S.get(Ae.ORIENTATION)%360),w.putMetadata(Ae.ORIENTATION,R);const P=w.getResultPoints();if(P!==null){const X=b.getHeight();for(let te=0;te<P.length;te++)P[te]=new St(X-P[te].getY()-1,P[te].getX())}return w}else throw new ae}}reset(){}doDecode(o,d){const f=o.getWidth(),p=o.getHeight();let b=new V(f);const w=d&&d.get(W.TRY_HARDER)===!0,S=Math.max(1,p>>(w?8:5));let R;w?R=p:R=15;const P=Math.trunc(p/2);for(let X=0;X<R;X++){const te=Math.trunc((X+1)/2),ue=(X&1)===0,je=P+S*(ue?te:-te);if(je<0||je>=p)break;try{b=o.getBlackRow(je,b)}catch(Fe){continue}for(let Fe=0;Fe<2;Fe++){if(Fe===1&&(b.reverse(),d&&d.get(W.NEED_RESULT_POINT_CALLBACK)===!0)){const Ue=new Map;d.forEach((tt,ut)=>Ue.set(ut,tt)),Ue.delete(W.NEED_RESULT_POINT_CALLBACK),d=Ue}try{const Ue=this.decodeRow(je,b,d);if(Fe===1){Ue.putMetadata(Ae.ORIENTATION,180);const tt=Ue.getResultPoints();tt!==null&&(tt[0]=new St(f-tt[0].getX()-1,tt[0].getY()),tt[1]=new St(f-tt[1].getX()-1,tt[1].getY()))}return Ue}catch(Ue){}}}throw new ae}static recordPattern(o,d,f){const p=f.length;for(let P=0;P<p;P++)f[P]=0;const b=o.getSize();if(d>=b)throw new ae;let w=!o.get(d),S=0,R=d;for(;R<b;){if(o.get(R)!==w)f[S]++;else{if(++S===p)break;f[S]=1,w=!w}R++}if(!(S===p||S===p-1&&R===b))throw new ae}static recordPatternInReverse(o,d,f){let p=f.length,b=o.get(d);for(;d>0&&p>=0;)o.get(--d)!==b&&(p--,b=!b);if(p>=0)throw new ae;Ge.recordPattern(o,d+1,f)}static patternMatchVariance(o,d,f){const p=o.length;let b=0,w=0;for(let P=0;P<p;P++)b+=o[P],w+=d[P];if(b<w)return Number.POSITIVE_INFINITY;const S=b/w;f*=S;let R=0;for(let P=0;P<p;P++){const X=o[P],te=d[P]*S,ue=X>te?X-te:te-X;if(ue>f)return Number.POSITIVE_INFINITY;R+=ue}return R/b}}class We extends Ge{static findStartPattern(o){const d=o.getSize(),f=o.getNextSet(0);let p=0,b=Int32Array.from([0,0,0,0,0,0]),w=f,S=!1;const R=6;for(let P=f;P<d;P++)if(o.get(P)!==S)b[p]++;else{if(p===R-1){let X=We.MAX_AVG_VARIANCE,te=-1;for(let ue=We.CODE_START_A;ue<=We.CODE_START_C;ue++){const je=Ge.patternMatchVariance(b,We.CODE_PATTERNS[ue],We.MAX_INDIVIDUAL_VARIANCE);je<X&&(X=je,te=ue)}if(te>=0&&o.isRange(Math.max(0,w-(P-w)/2),w,!1))return Int32Array.from([w,P,te]);w+=b[0]+b[1],b=b.slice(2,b.length-1),b[p-1]=0,b[p]=0,p--}else p++;b[p]=1,S=!S}throw new ae}static decodeCode(o,d,f){Ge.recordPattern(o,f,d);let p=We.MAX_AVG_VARIANCE,b=-1;for(let w=0;w<We.CODE_PATTERNS.length;w++){const S=We.CODE_PATTERNS[w],R=this.patternMatchVariance(d,S,We.MAX_INDIVIDUAL_VARIANCE);R<p&&(p=R,b=w)}if(b>=0)return b;throw new ae}decodeRow(o,d,f){const p=f&&f.get(W.ASSUME_GS1)===!0,b=We.findStartPattern(d),w=b[2];let S=0;const R=new Uint8Array(20);R[S++]=w;let P;switch(w){case We.CODE_START_A:P=We.CODE_CODE_A;break;case We.CODE_START_B:P=We.CODE_CODE_B;break;case We.CODE_START_C:P=We.CODE_CODE_C;break;default:throw new H}let X=!1,te=!1,ue="",je=b[0],Fe=b[1];const Ue=Int32Array.from([0,0,0,0,0,0]);let tt=0,ut=0,Xt=w,Gt=0,Ft=!0,Wr=!1,Ur=!1;for(;!X;){const Ss=te;switch(te=!1,tt=ut,ut=We.decodeCode(d,Ue,Fe),R[S++]=ut,ut!==We.CODE_STOP&&(Ft=!0),ut!==We.CODE_STOP&&(Gt++,Xt+=Gt*ut),je=Fe,Fe+=Ue.reduce((Wc,ki)=>Wc+ki,0),ut){case We.CODE_START_A:case We.CODE_START_B:case We.CODE_START_C:throw new H}switch(P){case We.CODE_CODE_A:if(ut<64)Ur===Wr?ue+=String.fromCharCode(32+ut):ue+=String.fromCharCode(32+ut+128),Ur=!1;else if(ut<96)Ur===Wr?ue+=String.fromCharCode(ut-64):ue+=String.fromCharCode(ut+64),Ur=!1;else switch(ut!==We.CODE_STOP&&(Ft=!1),ut){case We.CODE_FNC_1:p&&(ue.length===0?ue+="]C1":ue+="");break;case We.CODE_FNC_2:case We.CODE_FNC_3:break;case We.CODE_FNC_4_A:!Wr&&Ur?(Wr=!0,Ur=!1):Wr&&Ur?(Wr=!1,Ur=!1):Ur=!0;break;case We.CODE_SHIFT:te=!0,P=We.CODE_CODE_B;break;case We.CODE_CODE_B:P=We.CODE_CODE_B;break;case We.CODE_CODE_C:P=We.CODE_CODE_C;break;case We.CODE_STOP:X=!0;break}break;case We.CODE_CODE_B:if(ut<96)Ur===Wr?ue+=String.fromCharCode(32+ut):ue+=String.fromCharCode(32+ut+128),Ur=!1;else switch(ut!==We.CODE_STOP&&(Ft=!1),ut){case We.CODE_FNC_1:p&&(ue.length===0?ue+="]C1":ue+="");break;case We.CODE_FNC_2:case We.CODE_FNC_3:break;case We.CODE_FNC_4_B:!Wr&&Ur?(Wr=!0,Ur=!1):Wr&&Ur?(Wr=!1,Ur=!1):Ur=!0;break;case We.CODE_SHIFT:te=!0,P=We.CODE_CODE_A;break;case We.CODE_CODE_A:P=We.CODE_CODE_A;break;case We.CODE_CODE_C:P=We.CODE_CODE_C;break;case We.CODE_STOP:X=!0;break}break;case We.CODE_CODE_C:if(ut<100)ut<10&&(ue+="0"),ue+=ut;else switch(ut!==We.CODE_STOP&&(Ft=!1),ut){case We.CODE_FNC_1:p&&(ue.length===0?ue+="]C1":ue+="");break;case We.CODE_CODE_A:P=We.CODE_CODE_A;break;case We.CODE_CODE_B:P=We.CODE_CODE_B;break;case We.CODE_STOP:X=!0;break}break}Ss&&(P=P===We.CODE_CODE_A?We.CODE_CODE_B:We.CODE_CODE_A)}const fa=Fe-je;if(Fe=d.getNextUnset(Fe),!d.isRange(Fe,Math.min(d.getSize(),Fe+(Fe-je)/2),!1))throw new ae;if(Xt-=Gt*tt,Xt%103!==tt)throw new O;const Rn=ue.length;if(Rn===0)throw new ae;Rn>0&&Ft&&(P===We.CODE_CODE_C?ue=ue.substring(0,Rn-2):ue=ue.substring(0,Rn-1));const Mn=(b[1]+b[0])/2,ca=je+fa/2,bn=R.length,Hn=new Uint8Array(bn);for(let Ss=0;Ss<bn;Ss++)Hn[Ss]=R[Ss];const co=[new St(Mn,o),new St(ca,o)];return new re(ue,Hn,0,co,ve.CODE_128,new Date().getTime())}}We.CODE_PATTERNS=[Int32Array.from([2,1,2,2,2,2]),Int32Array.from([2,2,2,1,2,2]),Int32Array.from([2,2,2,2,2,1]),Int32Array.from([1,2,1,2,2,3]),Int32Array.from([1,2,1,3,2,2]),Int32Array.from([1,3,1,2,2,2]),Int32Array.from([1,2,2,2,1,3]),Int32Array.from([1,2,2,3,1,2]),Int32Array.from([1,3,2,2,1,2]),Int32Array.from([2,2,1,2,1,3]),Int32Array.from([2,2,1,3,1,2]),Int32Array.from([2,3,1,2,1,2]),Int32Array.from([1,1,2,2,3,2]),Int32Array.from([1,2,2,1,3,2]),Int32Array.from([1,2,2,2,3,1]),Int32Array.from([1,1,3,2,2,2]),Int32Array.from([1,2,3,1,2,2]),Int32Array.from([1,2,3,2,2,1]),Int32Array.from([2,2,3,2,1,1]),Int32Array.from([2,2,1,1,3,2]),Int32Array.from([2,2,1,2,3,1]),Int32Array.from([2,1,3,2,1,2]),Int32Array.from([2,2,3,1,1,2]),Int32Array.from([3,1,2,1,3,1]),Int32Array.from([3,1,1,2,2,2]),Int32Array.from([3,2,1,1,2,2]),Int32Array.from([3,2,1,2,2,1]),Int32Array.from([3,1,2,2,1,2]),Int32Array.from([3,2,2,1,1,2]),Int32Array.from([3,2,2,2,1,1]),Int32Array.from([2,1,2,1,2,3]),Int32Array.from([2,1,2,3,2,1]),Int32Array.from([2,3,2,1,2,1]),Int32Array.from([1,1,1,3,2,3]),Int32Array.from([1,3,1,1,2,3]),Int32Array.from([1,3,1,3,2,1]),Int32Array.from([1,1,2,3,1,3]),Int32Array.from([1,3,2,1,1,3]),Int32Array.from([1,3,2,3,1,1]),Int32Array.from([2,1,1,3,1,3]),Int32Array.from([2,3,1,1,1,3]),Int32Array.from([2,3,1,3,1,1]),Int32Array.from([1,1,2,1,3,3]),Int32Array.from([1,1,2,3,3,1]),Int32Array.from([1,3,2,1,3,1]),Int32Array.from([1,1,3,1,2,3]),Int32Array.from([1,1,3,3,2,1]),Int32Array.from([1,3,3,1,2,1]),Int32Array.from([3,1,3,1,2,1]),Int32Array.from([2,1,1,3,3,1]),Int32Array.from([2,3,1,1,3,1]),Int32Array.from([2,1,3,1,1,3]),Int32Array.from([2,1,3,3,1,1]),Int32Array.from([2,1,3,1,3,1]),Int32Array.from([3,1,1,1,2,3]),Int32Array.from([3,1,1,3,2,1]),Int32Array.from([3,3,1,1,2,1]),Int32Array.from([3,1,2,1,1,3]),Int32Array.from([3,1,2,3,1,1]),Int32Array.from([3,3,2,1,1,1]),Int32Array.from([3,1,4,1,1,1]),Int32Array.from([2,2,1,4,1,1]),Int32Array.from([4,3,1,1,1,1]),Int32Array.from([1,1,1,2,2,4]),Int32Array.from([1,1,1,4,2,2]),Int32Array.from([1,2,1,1,2,4]),Int32Array.from([1,2,1,4,2,1]),Int32Array.from([1,4,1,1,2,2]),Int32Array.from([1,4,1,2,2,1]),Int32Array.from([1,1,2,2,1,4]),Int32Array.from([1,1,2,4,1,2]),Int32Array.from([1,2,2,1,1,4]),Int32Array.from([1,2,2,4,1,1]),Int32Array.from([1,4,2,1,1,2]),Int32Array.from([1,4,2,2,1,1]),Int32Array.from([2,4,1,2,1,1]),Int32Array.from([2,2,1,1,1,4]),Int32Array.from([4,1,3,1,1,1]),Int32Array.from([2,4,1,1,1,2]),Int32Array.from([1,3,4,1,1,1]),Int32Array.from([1,1,1,2,4,2]),Int32Array.from([1,2,1,1,4,2]),Int32Array.from([1,2,1,2,4,1]),Int32Array.from([1,1,4,2,1,2]),Int32Array.from([1,2,4,1,1,2]),Int32Array.from([1,2,4,2,1,1]),Int32Array.from([4,1,1,2,1,2]),Int32Array.from([4,2,1,1,1,2]),Int32Array.from([4,2,1,2,1,1]),Int32Array.from([2,1,2,1,4,1]),Int32Array.from([2,1,4,1,2,1]),Int32Array.from([4,1,2,1,2,1]),Int32Array.from([1,1,1,1,4,3]),Int32Array.from([1,1,1,3,4,1]),Int32Array.from([1,3,1,1,4,1]),Int32Array.from([1,1,4,1,1,3]),Int32Array.from([1,1,4,3,1,1]),Int32Array.from([4,1,1,1,1,3]),Int32Array.from([4,1,1,3,1,1]),Int32Array.from([1,1,3,1,4,1]),Int32Array.from([1,1,4,1,3,1]),Int32Array.from([3,1,1,1,4,1]),Int32Array.from([4,1,1,1,3,1]),Int32Array.from([2,1,1,4,1,2]),Int32Array.from([2,1,1,2,1,4]),Int32Array.from([2,1,1,2,3,2]),Int32Array.from([2,3,3,1,1,1,2])],We.MAX_AVG_VARIANCE=.25,We.MAX_INDIVIDUAL_VARIANCE=.7,We.CODE_SHIFT=98,We.CODE_CODE_C=99,We.CODE_CODE_B=100,We.CODE_CODE_A=101,We.CODE_FNC_1=102,We.CODE_FNC_2=97,We.CODE_FNC_3=96,We.CODE_FNC_4_A=101,We.CODE_FNC_4_B=100,We.CODE_START_A=103,We.CODE_START_B=104,We.CODE_START_C=105,We.CODE_STOP=106;class At extends Ge{constructor(o=!1,d=!1){super(),this.usingCheckDigit=o,this.extendedMode=d,this.decodeRowResult="",this.counters=new Int32Array(9)}decodeRow(o,d,f){let p=this.counters;p.fill(0),this.decodeRowResult="";let b=At.findAsteriskPattern(d,p),w=d.getNextSet(b[1]),S=d.getSize(),R,P;do{At.recordPattern(d,w,p);let Ue=At.toNarrowWidePattern(p);if(Ue<0)throw new ae;R=At.patternToChar(Ue),this.decodeRowResult+=R,P=w;for(let tt of p)w+=tt;w=d.getNextSet(w)}while(R!=="*");this.decodeRowResult=this.decodeRowResult.substring(0,this.decodeRowResult.length-1);let X=0;for(let Ue of p)X+=Ue;let te=w-P-X;if(w!==S&&te*2<X)throw new ae;if(this.usingCheckDigit){let Ue=this.decodeRowResult.length-1,tt=0;for(let ut=0;ut<Ue;ut++)tt+=At.ALPHABET_STRING.indexOf(this.decodeRowResult.charAt(ut));if(this.decodeRowResult.charAt(Ue)!==At.ALPHABET_STRING.charAt(tt%43))throw new O;this.decodeRowResult=this.decodeRowResult.substring(0,Ue)}if(this.decodeRowResult.length===0)throw new ae;let ue;this.extendedMode?ue=At.decodeExtended(this.decodeRowResult):ue=this.decodeRowResult;let je=(b[1]+b[0])/2,Fe=P+X/2;return new re(ue,null,0,[new St(je,o),new St(Fe,o)],ve.CODE_39,new Date().getTime())}static findAsteriskPattern(o,d){let f=o.getSize(),p=o.getNextSet(0),b=0,w=p,S=!1,R=d.length;for(let P=p;P<f;P++)if(o.get(P)!==S)d[b]++;else{if(b===R-1){if(this.toNarrowWidePattern(d)===At.ASTERISK_ENCODING&&o.isRange(Math.max(0,w-Math.floor((P-w)/2)),w,!1))return[w,P];w+=d[0]+d[1],d.copyWithin(0,2,2+b-1),d[b-1]=0,d[b]=0,b--}else b++;d[b]=1,S=!S}throw new ae}static toNarrowWidePattern(o){let d=o.length,f=0,p;do{let b=2147483647;for(let R of o)R<b&&R>f&&(b=R);f=b,p=0;let w=0,S=0;for(let R=0;R<d;R++){let P=o[R];P>f&&(S|=1<<d-1-R,p++,w+=P)}if(p===3){for(let R=0;R<d&&p>0;R++){let P=o[R];if(P>f&&(p--,P*2>=w))return-1}return S}}while(p>3);return-1}static patternToChar(o){for(let d=0;d<At.CHARACTER_ENCODINGS.length;d++)if(At.CHARACTER_ENCODINGS[d]===o)return At.ALPHABET_STRING.charAt(d);if(o===At.ASTERISK_ENCODING)return"*";throw new ae}static decodeExtended(o){let d=o.length,f="";for(let p=0;p<d;p++){let b=o.charAt(p);if(b==="+"||b==="$"||b==="%"||b==="/"){let w=o.charAt(p+1),S="\0";switch(b){case"+":if(w>="A"&&w<="Z")S=String.fromCharCode(w.charCodeAt(0)+32);else throw new H;break;case"$":if(w>="A"&&w<="Z")S=String.fromCharCode(w.charCodeAt(0)-64);else throw new H;break;case"%":if(w>="A"&&w<="E")S=String.fromCharCode(w.charCodeAt(0)-38);else if(w>="F"&&w<="J")S=String.fromCharCode(w.charCodeAt(0)-11);else if(w>="K"&&w<="O")S=String.fromCharCode(w.charCodeAt(0)+16);else if(w>="P"&&w<="T")S=String.fromCharCode(w.charCodeAt(0)+43);else if(w==="U")S="\0";else if(w==="V")S="@";else if(w==="W")S="`";else if(w==="X"||w==="Y"||w==="Z")S="";else throw new H;break;case"/":if(w>="A"&&w<="O")S=String.fromCharCode(w.charCodeAt(0)-32);else if(w==="Z")S=":";else throw new H;break}f+=S,p++}else f+=b}return f}}At.ALPHABET_STRING="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",At.CHARACTER_ENCODINGS=[52,289,97,352,49,304,112,37,292,100,265,73,328,25,280,88,13,268,76,28,259,67,322,19,274,82,7,262,70,22,385,193,448,145,400,208,133,388,196,168,162,138,42],At.ASTERISK_ENCODING=148;class lt extends Ge{constructor(){super(...arguments),this.narrowLineWidth=-1}decodeRow(o,d,f){let p=this.decodeStart(d),b=this.decodeEnd(d),w=new ce;lt.decodeMiddle(d,p[1],b[0],w);let S=w.toString(),R=null;f!=null&&(R=f.get(W.ALLOWED_LENGTHS)),R==null&&(R=lt.DEFAULT_ALLOWED_LENGTHS);let P=S.length,X=!1,te=0;for(let Fe of R){if(P===Fe){X=!0;break}Fe>te&&(te=Fe)}if(!X&&P>te&&(X=!0),!X)throw new H;const ue=[new St(p[1],o),new St(b[0],o)];return new re(S,null,0,ue,ve.ITF,new Date().getTime())}static decodeMiddle(o,d,f,p){let b=new Int32Array(10),w=new Int32Array(5),S=new Int32Array(5);for(b.fill(0),w.fill(0),S.fill(0);d<f;){Ge.recordPattern(o,d,b);for(let P=0;P<5;P++){let X=2*P;w[P]=b[X],S[P]=b[X+1]}let R=lt.decodeDigit(w);p.append(R.toString()),R=this.decodeDigit(S),p.append(R.toString()),b.forEach(function(P){d+=P})}}decodeStart(o){let d=lt.skipWhiteSpace(o),f=lt.findGuardPattern(o,d,lt.START_PATTERN);return this.narrowLineWidth=(f[1]-f[0])/4,this.validateQuietZone(o,f[0]),f}validateQuietZone(o,d){let f=this.narrowLineWidth*10;f=f<d?f:d;for(let p=d-1;f>0&&p>=0&&!o.get(p);p--)f--;if(f!==0)throw new ae}static skipWhiteSpace(o){const d=o.getSize(),f=o.getNextSet(0);if(f===d)throw new ae;return f}decodeEnd(o){o.reverse();try{let d=lt.skipWhiteSpace(o),f;try{f=lt.findGuardPattern(o,d,lt.END_PATTERN_REVERSED[0])}catch(b){b instanceof ae&&(f=lt.findGuardPattern(o,d,lt.END_PATTERN_REVERSED[1]))}this.validateQuietZone(o,f[0]);let p=f[0];return f[0]=o.getSize()-f[1],f[1]=o.getSize()-p,f}finally{o.reverse()}}static findGuardPattern(o,d,f){let p=f.length,b=new Int32Array(p),w=o.getSize(),S=!1,R=0,P=d;b.fill(0);for(let X=d;X<w;X++)if(o.get(X)!==S)b[R]++;else{if(R===p-1){if(Ge.patternMatchVariance(b,f,lt.MAX_INDIVIDUAL_VARIANCE)<lt.MAX_AVG_VARIANCE)return[P,X];P+=b[0]+b[1],A.arraycopy(b,2,b,0,R-1),b[R-1]=0,b[R]=0,R--}else R++;b[R]=1,S=!S}throw new ae}static decodeDigit(o){let d=lt.MAX_AVG_VARIANCE,f=-1,p=lt.PATTERNS.length;for(let b=0;b<p;b++){let w=lt.PATTERNS[b],S=Ge.patternMatchVariance(o,w,lt.MAX_INDIVIDUAL_VARIANCE);S<d?(d=S,f=b):S===d&&(f=-1)}if(f>=0)return f%10;throw new ae}}lt.PATTERNS=[Int32Array.from([1,1,2,2,1]),Int32Array.from([2,1,1,1,2]),Int32Array.from([1,2,1,1,2]),Int32Array.from([2,2,1,1,1]),Int32Array.from([1,1,2,1,2]),Int32Array.from([2,1,2,1,1]),Int32Array.from([1,2,2,1,1]),Int32Array.from([1,1,1,2,2]),Int32Array.from([2,1,1,2,1]),Int32Array.from([1,2,1,2,1]),Int32Array.from([1,1,3,3,1]),Int32Array.from([3,1,1,1,3]),Int32Array.from([1,3,1,1,3]),Int32Array.from([3,3,1,1,1]),Int32Array.from([1,1,3,1,3]),Int32Array.from([3,1,3,1,1]),Int32Array.from([1,3,3,1,1]),Int32Array.from([1,1,1,3,3]),Int32Array.from([3,1,1,3,1]),Int32Array.from([1,3,1,3,1])],lt.MAX_AVG_VARIANCE=.38,lt.MAX_INDIVIDUAL_VARIANCE=.5,lt.DEFAULT_ALLOWED_LENGTHS=[6,8,10,12,14],lt.START_PATTERN=Int32Array.from([1,1,1,1]),lt.END_PATTERN_REVERSED=[Int32Array.from([1,1,2]),Int32Array.from([1,1,3])];class Dt extends Ge{constructor(){super(...arguments),this.decodeRowStringBuffer=""}static findStartGuardPattern(o){let d=!1,f,p=0,b=Int32Array.from([0,0,0]);for(;!d;){b=Int32Array.from([0,0,0]),f=Dt.findGuardPattern(o,p,!1,this.START_END_PATTERN,b);let w=f[0];p=f[1];let S=w-(p-w);S>=0&&(d=o.isRange(S,w,!1))}return f}static checkChecksum(o){return Dt.checkStandardUPCEANChecksum(o)}static checkStandardUPCEANChecksum(o){let d=o.length;if(d===0)return!1;let f=parseInt(o.charAt(d-1),10);return Dt.getStandardUPCEANChecksum(o.substring(0,d-1))===f}static getStandardUPCEANChecksum(o){let d=o.length,f=0;for(let p=d-1;p>=0;p-=2){let b=o.charAt(p).charCodeAt(0)-48;if(b<0||b>9)throw new H;f+=b}f*=3;for(let p=d-2;p>=0;p-=2){let b=o.charAt(p).charCodeAt(0)-48;if(b<0||b>9)throw new H;f+=b}return(1e3-f)%10}static decodeEnd(o,d){return Dt.findGuardPattern(o,d,!1,Dt.START_END_PATTERN,new Int32Array(Dt.START_END_PATTERN.length).fill(0))}static findGuardPatternWithoutCounters(o,d,f,p){return this.findGuardPattern(o,d,f,p,new Int32Array(p.length))}static findGuardPattern(o,d,f,p,b){let w=o.getSize();d=f?o.getNextUnset(d):o.getNextSet(d);let S=0,R=d,P=p.length,X=f;for(let te=d;te<w;te++)if(o.get(te)!==X)b[S]++;else{if(S===P-1){if(Ge.patternMatchVariance(b,p,Dt.MAX_INDIVIDUAL_VARIANCE)<Dt.MAX_AVG_VARIANCE)return Int32Array.from([R,te]);R+=b[0]+b[1];let ue=b.slice(2,b.length-1);for(let je=0;je<S-1;je++)b[je]=ue[je];b[S-1]=0,b[S]=0,S--}else S++;b[S]=1,X=!X}throw new ae}static decodeDigit(o,d,f,p){this.recordPattern(o,f,d);let b=this.MAX_AVG_VARIANCE,w=-1,S=p.length;for(let R=0;R<S;R++){let P=p[R],X=Ge.patternMatchVariance(d,P,Dt.MAX_INDIVIDUAL_VARIANCE);X<b&&(b=X,w=R)}if(w>=0)return w;throw new ae}}Dt.MAX_AVG_VARIANCE=.48,Dt.MAX_INDIVIDUAL_VARIANCE=.7,Dt.START_END_PATTERN=Int32Array.from([1,1,1]),Dt.MIDDLE_PATTERN=Int32Array.from([1,1,1,1,1]),Dt.END_PATTERN=Int32Array.from([1,1,1,1,1,1]),Dt.L_PATTERNS=[Int32Array.from([3,2,1,1]),Int32Array.from([2,2,2,1]),Int32Array.from([2,1,2,2]),Int32Array.from([1,4,1,1]),Int32Array.from([1,1,3,2]),Int32Array.from([1,2,3,1]),Int32Array.from([1,1,1,4]),Int32Array.from([1,3,1,2]),Int32Array.from([1,2,1,3]),Int32Array.from([3,1,1,2])];class mr{constructor(){this.CHECK_DIGIT_ENCODINGS=[24,20,18,17,12,6,3,10,9,5],this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(o,d,f){let p=this.decodeRowStringBuffer,b=this.decodeMiddle(d,f,p),w=p.toString(),S=mr.parseExtensionString(w),R=[new St((f[0]+f[1])/2,o),new St(b,o)],P=new re(w,null,0,R,ve.UPC_EAN_EXTENSION,new Date().getTime());return S!=null&&P.putAllMetadata(S),P}decodeMiddle(o,d,f){let p=this.decodeMiddleCounters;p[0]=0,p[1]=0,p[2]=0,p[3]=0;let b=o.getSize(),w=d[1],S=0;for(let P=0;P<5&&w<b;P++){let X=Dt.decodeDigit(o,p,w,Dt.L_AND_G_PATTERNS);f+=String.fromCharCode(48+X%10);for(let te of p)w+=te;X>=10&&(S|=1<<4-P),P!==4&&(w=o.getNextSet(w),w=o.getNextUnset(w))}if(f.length!==5)throw new ae;let R=this.determineCheckDigit(S);if(mr.extensionChecksum(f.toString())!==R)throw new ae;return w}static extensionChecksum(o){let d=o.length,f=0;for(let p=d-2;p>=0;p-=2)f+=o.charAt(p).charCodeAt(0)-48;f*=3;for(let p=d-1;p>=0;p-=2)f+=o.charAt(p).charCodeAt(0)-48;return f*=3,f%10}determineCheckDigit(o){for(let d=0;d<10;d++)if(o===this.CHECK_DIGIT_ENCODINGS[d])return d;throw new ae}static parseExtensionString(o){if(o.length!==5)return null;let d=mr.parseExtension5String(o);return d==null?null:new Map([[Ae.SUGGESTED_PRICE,d]])}static parseExtension5String(o){let d;switch(o.charAt(0)){case"0":d="£";break;case"5":d="$";break;case"9":switch(o){case"90000":return null;case"99991":return"0.00";case"99990":return"Used"}d="";break;default:d="";break}let f=parseInt(o.substring(1)),p=(f/100).toString(),b=f%100,w=b<10?"0"+b:b.toString();return d+p+"."+w}}class tr{constructor(){this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(o,d,f){let p=this.decodeRowStringBuffer,b=this.decodeMiddle(d,f,p),w=p.toString(),S=tr.parseExtensionString(w),R=[new St((f[0]+f[1])/2,o),new St(b,o)],P=new re(w,null,0,R,ve.UPC_EAN_EXTENSION,new Date().getTime());return S!=null&&P.putAllMetadata(S),P}decodeMiddle(o,d,f){let p=this.decodeMiddleCounters;p[0]=0,p[1]=0,p[2]=0,p[3]=0;let b=o.getSize(),w=d[1],S=0;for(let R=0;R<2&&w<b;R++){let P=Dt.decodeDigit(o,p,w,Dt.L_AND_G_PATTERNS);f+=String.fromCharCode(48+P%10);for(let X of p)w+=X;P>=10&&(S|=1<<1-R),R!==1&&(w=o.getNextSet(w),w=o.getNextUnset(w))}if(f.length!==2)throw new ae;if(parseInt(f.toString())%4!==S)throw new ae;return w}static parseExtensionString(o){return o.length!==2?null:new Map([[Ae.ISSUE_NUMBER,parseInt(o)]])}}class pt{static decodeRow(o,d,f){let p=Dt.findGuardPattern(d,f,!1,this.EXTENSION_START_PATTERN,new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0));try{return new mr().decodeRow(o,d,p)}catch(b){return new tr().decodeRow(o,d,p)}}}pt.EXTENSION_START_PATTERN=Int32Array.from([1,1,2]);class Jt extends Dt{constructor(){super(),this.decodeRowStringBuffer="",Jt.L_AND_G_PATTERNS=Jt.L_PATTERNS.map(o=>Int32Array.from(o));for(let o=10;o<20;o++){let d=Jt.L_PATTERNS[o-10],f=new Int32Array(d.length);for(let p=0;p<d.length;p++)f[p]=d[d.length-p-1];Jt.L_AND_G_PATTERNS[o]=f}}decodeRow(o,d,f){let p=Jt.findStartGuardPattern(d),b=f==null?null:f.get(W.NEED_RESULT_POINT_CALLBACK);if(b!=null){const Ft=new St((p[0]+p[1])/2,o);b.foundPossibleResultPoint(Ft)}let w=this.decodeMiddle(d,p,this.decodeRowStringBuffer),S=w.rowOffset,R=w.resultString;if(b!=null){const Ft=new St(S,o);b.foundPossibleResultPoint(Ft)}let P=this.decodeEnd(d,S);if(b!=null){const Ft=new St((P[0]+P[1])/2,o);b.foundPossibleResultPoint(Ft)}let X=P[1],te=X+(X-P[0]);if(te>=d.getSize()||!d.isRange(X,te,!1))throw new ae;let ue=R.toString();if(ue.length<8)throw new H;if(!Jt.checkChecksum(ue))throw new O;let je=(p[1]+p[0])/2,Fe=(P[1]+P[0])/2,Ue=this.getBarcodeFormat(),tt=[new St(je,o),new St(Fe,o)],ut=new re(ue,null,0,tt,Ue,new Date().getTime()),Xt=0;try{let Ft=pt.decodeRow(o,d,P[1]);ut.putMetadata(Ae.UPC_EAN_EXTENSION,Ft.getText()),ut.putAllMetadata(Ft.getResultMetadata()),ut.addResultPoints(Ft.getResultPoints()),Xt=Ft.getText().length}catch(Ft){}let Gt=f==null?null:f.get(W.ALLOWED_EAN_EXTENSIONS);if(Gt!=null){let Ft=!1;for(let Wr in Gt)if(Xt.toString()===Wr){Ft=!0;break}if(!Ft)throw new ae}return ut}decodeEnd(o,d){return Jt.findGuardPattern(o,d,!1,Jt.START_END_PATTERN,new Int32Array(Jt.START_END_PATTERN.length).fill(0))}static checkChecksum(o){return Jt.checkStandardUPCEANChecksum(o)}static checkStandardUPCEANChecksum(o){let d=o.length;if(d===0)return!1;let f=parseInt(o.charAt(d-1),10);return Jt.getStandardUPCEANChecksum(o.substring(0,d-1))===f}static getStandardUPCEANChecksum(o){let d=o.length,f=0;for(let p=d-1;p>=0;p-=2){let b=o.charAt(p).charCodeAt(0)-48;if(b<0||b>9)throw new H;f+=b}f*=3;for(let p=d-2;p>=0;p-=2){let b=o.charAt(p).charCodeAt(0)-48;if(b<0||b>9)throw new H;f+=b}return(1e3-f)%10}}class vr extends Jt{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(o,d,f){let p=this.decodeMiddleCounters;p[0]=0,p[1]=0,p[2]=0,p[3]=0;let b=o.getSize(),w=d[1],S=0;for(let P=0;P<6&&w<b;P++){let X=Jt.decodeDigit(o,p,w,Jt.L_AND_G_PATTERNS);f+=String.fromCharCode(48+X%10);for(let te of p)w+=te;X>=10&&(S|=1<<5-P)}f=vr.determineFirstDigit(f,S),w=Jt.findGuardPattern(o,w,!0,Jt.MIDDLE_PATTERN,new Int32Array(Jt.MIDDLE_PATTERN.length).fill(0))[1];for(let P=0;P<6&&w<b;P++){let X=Jt.decodeDigit(o,p,w,Jt.L_PATTERNS);f+=String.fromCharCode(48+X);for(let te of p)w+=te}return{rowOffset:w,resultString:f}}getBarcodeFormat(){return ve.EAN_13}static determineFirstDigit(o,d){for(let f=0;f<10;f++)if(d===this.FIRST_DIGIT_ENCODINGS[f])return o=String.fromCharCode(48+f)+o,o;throw new ae}}vr.FIRST_DIGIT_ENCODINGS=[0,11,13,14,19,25,28,21,22,26];class Ir extends Jt{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(o,d,f){const p=this.decodeMiddleCounters;p[0]=0,p[1]=0,p[2]=0,p[3]=0;let b=o.getSize(),w=d[1];for(let R=0;R<4&&w<b;R++){let P=Jt.decodeDigit(o,p,w,Jt.L_PATTERNS);f+=String.fromCharCode(48+P);for(let X of p)w+=X}w=Jt.findGuardPattern(o,w,!0,Jt.MIDDLE_PATTERN,new Int32Array(Jt.MIDDLE_PATTERN.length).fill(0))[1];for(let R=0;R<4&&w<b;R++){let P=Jt.decodeDigit(o,p,w,Jt.L_PATTERNS);f+=String.fromCharCode(48+P);for(let X of p)w+=X}return{rowOffset:w,resultString:f}}getBarcodeFormat(){return ve.EAN_8}}class Le extends Jt{constructor(){super(...arguments),this.ean13Reader=new vr}getBarcodeFormat(){return ve.UPC_A}decode(o,d){return this.maybeReturnResult(this.ean13Reader.decode(o))}decodeRow(o,d,f){return this.maybeReturnResult(this.ean13Reader.decodeRow(o,d,f))}decodeMiddle(o,d,f){return this.ean13Reader.decodeMiddle(o,d,f)}maybeReturnResult(o){let d=o.getText();if(d.charAt(0)==="0"){let f=new re(d.substring(1),null,null,o.getResultPoints(),ve.UPC_A);return o.getResultMetadata()!=null&&f.putAllMetadata(o.getResultMetadata()),f}else throw new ae}reset(){this.ean13Reader.reset()}}class qe extends Jt{constructor(){super(),this.decodeMiddleCounters=new Int32Array(4)}decodeMiddle(o,d,f){const p=this.decodeMiddleCounters.map(P=>P);p[0]=0,p[1]=0,p[2]=0,p[3]=0;const b=o.getSize();let w=d[1],S=0;for(let P=0;P<6&&w<b;P++){const X=qe.decodeDigit(o,p,w,qe.L_AND_G_PATTERNS);f+=String.fromCharCode(48+X%10);for(let te of p)w+=te;X>=10&&(S|=1<<5-P)}let R=qe.determineNumSysAndCheckDigit(f,S);return{rowOffset:w,resultString:R}}decodeEnd(o,d){return qe.findGuardPatternWithoutCounters(o,d,!0,qe.MIDDLE_END_PATTERN)}checkChecksum(o){return Jt.checkChecksum(qe.convertUPCEtoUPCA(o))}static determineNumSysAndCheckDigit(o,d){for(let f=0;f<=1;f++)for(let p=0;p<10;p++)if(d===this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[f][p]){let b=String.fromCharCode(48+f),w=String.fromCharCode(48+p);return b+o+w}throw ae.getNotFoundInstance()}getBarcodeFormat(){return ve.UPC_E}static convertUPCEtoUPCA(o){const d=o.slice(1,7).split("").map(b=>b.charCodeAt(0)),f=new ce;f.append(o.charAt(0));let p=d[5];switch(p){case 0:case 1:case 2:f.appendChars(d,0,2),f.append(p),f.append("0000"),f.appendChars(d,2,3);break;case 3:f.appendChars(d,0,3),f.append("00000"),f.appendChars(d,3,2);break;case 4:f.appendChars(d,0,4),f.append("00000"),f.append(d[4]);break;default:f.appendChars(d,0,5),f.append("0000"),f.append(p);break}return o.length>=8&&f.append(o.charAt(7)),f.toString()}}qe.MIDDLE_END_PATTERN=Int32Array.from([1,1,1,1,1,1]),qe.NUMSYS_AND_CHECK_DIGIT_PATTERNS=[Int32Array.from([56,52,50,49,44,38,35,42,41,37]),Int32Array.from([7,11,13,14,19,25,28,21,22,26])];class Ke extends Ge{constructor(o){super();let d=o==null?null:o.get(W.POSSIBLE_FORMATS),f=[];n(d)?(f.push(new vr),f.push(new Le),f.push(new Ir),f.push(new qe)):(d.indexOf(ve.EAN_13)>-1&&f.push(new vr),d.indexOf(ve.UPC_A)>-1&&f.push(new Le),d.indexOf(ve.EAN_8)>-1&&f.push(new Ir),d.indexOf(ve.UPC_E)>-1&&f.push(new qe)),this.readers=f}decodeRow(o,d,f){for(let p of this.readers)try{const b=p.decodeRow(o,d,f),w=b.getBarcodeFormat()===ve.EAN_13&&b.getText().charAt(0)==="0",S=f==null?null:f.get(W.POSSIBLE_FORMATS),R=S==null||S.includes(ve.UPC_A);if(w&&R){const P=b.getRawBytes(),X=new re(b.getText().substring(1),P,P?P.length:null,b.getResultPoints(),ve.UPC_A);return X.putAllMetadata(b.getResultMetadata()),X}return b}catch(b){}throw new ae}reset(){for(let o of this.readers)o.reset()}}class Yt extends Ge{constructor(){super(),this.decodeFinderCounters=new Int32Array(4),this.dataCharacterCounters=new Int32Array(8),this.oddRoundingErrors=new Array(4),this.evenRoundingErrors=new Array(4),this.oddCounts=new Array(this.dataCharacterCounters.length/2),this.evenCounts=new Array(this.dataCharacterCounters.length/2)}getDecodeFinderCounters(){return this.decodeFinderCounters}getDataCharacterCounters(){return this.dataCharacterCounters}getOddRoundingErrors(){return this.oddRoundingErrors}getEvenRoundingErrors(){return this.evenRoundingErrors}getOddCounts(){return this.oddCounts}getEvenCounts(){return this.evenCounts}parseFinderValue(o,d){for(let f=0;f<d.length;f++)if(Ge.patternMatchVariance(o,d[f],Yt.MAX_INDIVIDUAL_VARIANCE)<Yt.MAX_AVG_VARIANCE)return f;throw new ae}static count(o){return $t.sum(new Int32Array(o))}static increment(o,d){let f=0,p=d[0];for(let b=1;b<o.length;b++)d[b]>p&&(p=d[b],f=b);o[f]++}static decrement(o,d){let f=0,p=d[0];for(let b=1;b<o.length;b++)d[b]<p&&(p=d[b],f=b);o[f]--}static isFinderPattern(o){let d=o[0]+o[1],f=d+o[2]+o[3],p=d/f;if(p>=Yt.MIN_FINDER_PATTERN_RATIO&&p<=Yt.MAX_FINDER_PATTERN_RATIO){let b=Number.MAX_SAFE_INTEGER,w=Number.MIN_SAFE_INTEGER;for(let S of o)S>w&&(w=S),S<b&&(b=S);return w<10*b}return!1}}Yt.MAX_AVG_VARIANCE=.2,Yt.MAX_INDIVIDUAL_VARIANCE=.45,Yt.MIN_FINDER_PATTERN_RATIO=9.5/12,Yt.MAX_FINDER_PATTERN_RATIO=12.5/14;class gr{constructor(o,d){this.value=o,this.checksumPortion=d}getValue(){return this.value}getChecksumPortion(){return this.checksumPortion}toString(){return this.value+"("+this.checksumPortion+")"}equals(o){if(!(o instanceof gr))return!1;const d=o;return this.value===d.value&&this.checksumPortion===d.checksumPortion}hashCode(){return this.value^this.checksumPortion}}class jr{constructor(o,d,f,p,b){this.value=o,this.startEnd=d,this.value=o,this.startEnd=d,this.resultPoints=new Array,this.resultPoints.push(new St(f,b)),this.resultPoints.push(new St(p,b))}getValue(){return this.value}getStartEnd(){return this.startEnd}getResultPoints(){return this.resultPoints}equals(o){if(!(o instanceof jr))return!1;const d=o;return this.value===d.value}hashCode(){return this.value}}class Zr{constructor(){}static getRSSvalue(o,d,f){let p=0;for(let R of o)p+=R;let b=0,w=0,S=o.length;for(let R=0;R<S-1;R++){let P;for(P=1,w|=1<<R;P<o[R];P++,w&=~(1<<R)){let X=Zr.combins(p-P-1,S-R-2);if(f&&w===0&&p-P-(S-R-1)>=S-R-1&&(X-=Zr.combins(p-P-(S-R),S-R-2)),S-R-1>1){let te=0;for(let ue=p-P-(S-R-2);ue>d;ue--)te+=Zr.combins(p-P-ue-1,S-R-3);X-=te*(S-1-R)}else p-P>d&&X--;b+=X}p-=P}return b}static combins(o,d){let f,p;o-d>d?(p=d,f=o-d):(p=o-d,f=d);let b=1,w=1;for(let S=o;S>f;S--)b*=S,w<=p&&(b/=w,w++);for(;w<=p;)b/=w,w++;return b}}class en{static buildBitArray(o){let d=o.length*2-1;o[o.length-1].getRightChar()==null&&(d-=1);let f=12*d,p=new V(f),b=0,S=o[0].getRightChar().getValue();for(let R=11;R>=0;--R)(S&1<<R)!=0&&p.set(b),b++;for(let R=1;R<o.length;++R){let P=o[R],X=P.getLeftChar().getValue();for(let te=11;te>=0;--te)(X&1<<te)!=0&&p.set(b),b++;if(P.getRightChar()!=null){let te=P.getRightChar().getValue();for(let ue=11;ue>=0;--ue)(te&1<<ue)!=0&&p.set(b),b++}}return p}}class Qt{constructor(o,d){d?this.decodedInformation=null:(this.finished=o,this.decodedInformation=d)}getDecodedInformation(){return this.decodedInformation}isFinished(){return this.finished}}class wr{constructor(o){this.newPosition=o}getNewPosition(){return this.newPosition}}class Vt extends wr{constructor(o,d){super(o),this.value=d}getValue(){return this.value}isFNC1(){return this.value===Vt.FNC1}}Vt.FNC1="$";class Ut extends wr{constructor(o,d,f){super(o),f?(this.remaining=!0,this.remainingValue=this.remainingValue):(this.remaining=!1,this.remainingValue=0),this.newString=d}getNewString(){return this.newString}isRemaining(){return this.remaining}getRemainingValue(){return this.remainingValue}}class de extends wr{constructor(o,d,f){if(super(o),d<0||d>10||f<0||f>10)throw new H;this.firstDigit=d,this.secondDigit=f}getFirstDigit(){return this.firstDigit}getSecondDigit(){return this.secondDigit}getValue(){return this.firstDigit*10+this.secondDigit}isFirstDigitFNC1(){return this.firstDigit===de.FNC1}isSecondDigitFNC1(){return this.secondDigit===de.FNC1}isAnyFNC1(){return this.firstDigit===de.FNC1||this.secondDigit===de.FNC1}}de.FNC1=10;class ge{constructor(){}static parseFieldsInGeneralPurpose(o){if(!o)return null;if(o.length<2)throw new ae;let d=o.substring(0,2);for(let b of ge.TWO_DIGIT_DATA_LENGTH)if(b[0]===d)return b[1]===ge.VARIABLE_LENGTH?ge.processVariableAI(2,b[2],o):ge.processFixedAI(2,b[1],o);if(o.length<3)throw new ae;let f=o.substring(0,3);for(let b of ge.THREE_DIGIT_DATA_LENGTH)if(b[0]===f)return b[1]===ge.VARIABLE_LENGTH?ge.processVariableAI(3,b[2],o):ge.processFixedAI(3,b[1],o);for(let b of ge.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH)if(b[0]===f)return b[1]===ge.VARIABLE_LENGTH?ge.processVariableAI(4,b[2],o):ge.processFixedAI(4,b[1],o);if(o.length<4)throw new ae;let p=o.substring(0,4);for(let b of ge.FOUR_DIGIT_DATA_LENGTH)if(b[0]===p)return b[1]===ge.VARIABLE_LENGTH?ge.processVariableAI(4,b[2],o):ge.processFixedAI(4,b[1],o);throw new ae}static processFixedAI(o,d,f){if(f.length<o)throw new ae;let p=f.substring(0,o);if(f.length<o+d)throw new ae;let b=f.substring(o,o+d),w=f.substring(o+d),S="("+p+")"+b,R=ge.parseFieldsInGeneralPurpose(w);return R==null?S:S+R}static processVariableAI(o,d,f){let p=f.substring(0,o),b;f.length<o+d?b=f.length:b=o+d;let w=f.substring(o,b),S=f.substring(b),R="("+p+")"+w,P=ge.parseFieldsInGeneralPurpose(S);return P==null?R:R+P}}ge.VARIABLE_LENGTH=[],ge.TWO_DIGIT_DATA_LENGTH=[["00",18],["01",14],["02",14],["10",ge.VARIABLE_LENGTH,20],["11",6],["12",6],["13",6],["15",6],["17",6],["20",2],["21",ge.VARIABLE_LENGTH,20],["22",ge.VARIABLE_LENGTH,29],["30",ge.VARIABLE_LENGTH,8],["37",ge.VARIABLE_LENGTH,8],["90",ge.VARIABLE_LENGTH,30],["91",ge.VARIABLE_LENGTH,30],["92",ge.VARIABLE_LENGTH,30],["93",ge.VARIABLE_LENGTH,30],["94",ge.VARIABLE_LENGTH,30],["95",ge.VARIABLE_LENGTH,30],["96",ge.VARIABLE_LENGTH,30],["97",ge.VARIABLE_LENGTH,3],["98",ge.VARIABLE_LENGTH,30],["99",ge.VARIABLE_LENGTH,30]],ge.THREE_DIGIT_DATA_LENGTH=[["240",ge.VARIABLE_LENGTH,30],["241",ge.VARIABLE_LENGTH,30],["242",ge.VARIABLE_LENGTH,6],["250",ge.VARIABLE_LENGTH,30],["251",ge.VARIABLE_LENGTH,30],["253",ge.VARIABLE_LENGTH,17],["254",ge.VARIABLE_LENGTH,20],["400",ge.VARIABLE_LENGTH,30],["401",ge.VARIABLE_LENGTH,30],["402",17],["403",ge.VARIABLE_LENGTH,30],["410",13],["411",13],["412",13],["413",13],["414",13],["420",ge.VARIABLE_LENGTH,20],["421",ge.VARIABLE_LENGTH,15],["422",3],["423",ge.VARIABLE_LENGTH,15],["424",3],["425",3],["426",3]],ge.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH=[["310",6],["311",6],["312",6],["313",6],["314",6],["315",6],["316",6],["320",6],["321",6],["322",6],["323",6],["324",6],["325",6],["326",6],["327",6],["328",6],["329",6],["330",6],["331",6],["332",6],["333",6],["334",6],["335",6],["336",6],["340",6],["341",6],["342",6],["343",6],["344",6],["345",6],["346",6],["347",6],["348",6],["349",6],["350",6],["351",6],["352",6],["353",6],["354",6],["355",6],["356",6],["357",6],["360",6],["361",6],["362",6],["363",6],["364",6],["365",6],["366",6],["367",6],["368",6],["369",6],["390",ge.VARIABLE_LENGTH,15],["391",ge.VARIABLE_LENGTH,18],["392",ge.VARIABLE_LENGTH,15],["393",ge.VARIABLE_LENGTH,18],["703",ge.VARIABLE_LENGTH,30]],ge.FOUR_DIGIT_DATA_LENGTH=[["7001",13],["7002",ge.VARIABLE_LENGTH,30],["7003",10],["8001",14],["8002",ge.VARIABLE_LENGTH,20],["8003",ge.VARIABLE_LENGTH,30],["8004",ge.VARIABLE_LENGTH,30],["8005",6],["8006",18],["8007",ge.VARIABLE_LENGTH,30],["8008",ge.VARIABLE_LENGTH,12],["8018",18],["8020",ge.VARIABLE_LENGTH,25],["8100",6],["8101",10],["8102",2],["8110",ge.VARIABLE_LENGTH,70],["8200",ge.VARIABLE_LENGTH,70]];class be{constructor(o){this.buffer=new ce,this.information=o}decodeAllCodes(o,d){let f=d,p=null;do{let b=this.decodeGeneralPurposeField(f,p),w=ge.parseFieldsInGeneralPurpose(b.getNewString());if(w!=null&&o.append(w),b.isRemaining()?p=""+b.getRemainingValue():p=null,f===b.getNewPosition())break;f=b.getNewPosition()}while(!0);return o.toString()}isStillNumeric(o){if(o+7>this.information.getSize())return o+4<=this.information.getSize();for(let d=o;d<o+3;++d)if(this.information.get(d))return!0;return this.information.get(o+3)}decodeNumeric(o){if(o+7>this.information.getSize()){let b=this.extractNumericValueFromBitArray(o,4);return b===0?new de(this.information.getSize(),de.FNC1,de.FNC1):new de(this.information.getSize(),b-1,de.FNC1)}let d=this.extractNumericValueFromBitArray(o,7),f=(d-8)/11,p=(d-8)%11;return new de(o+7,f,p)}extractNumericValueFromBitArray(o,d){return be.extractNumericValueFromBitArray(this.information,o,d)}static extractNumericValueFromBitArray(o,d,f){let p=0;for(let b=0;b<f;++b)o.get(d+b)&&(p|=1<<f-b-1);return p}decodeGeneralPurposeField(o,d){this.buffer.setLengthToZero(),d!=null&&this.buffer.append(d),this.current.setPosition(o);let f=this.parseBlocks();return f!=null&&f.isRemaining()?new Ut(this.current.getPosition(),this.buffer.toString(),f.getRemainingValue()):new Ut(this.current.getPosition(),this.buffer.toString())}parseBlocks(){let o,d;do{let f=this.current.getPosition();if(this.current.isAlpha()?(d=this.parseAlphaBlock(),o=d.isFinished()):this.current.isIsoIec646()?(d=this.parseIsoIec646Block(),o=d.isFinished()):(d=this.parseNumericBlock(),o=d.isFinished()),!(f!==this.current.getPosition())&&!o)break}while(!o);return d.getDecodedInformation()}parseNumericBlock(){for(;this.isStillNumeric(this.current.getPosition());){let o=this.decodeNumeric(this.current.getPosition());if(this.current.setPosition(o.getNewPosition()),o.isFirstDigitFNC1()){let d;return o.isSecondDigitFNC1()?d=new Ut(this.current.getPosition(),this.buffer.toString()):d=new Ut(this.current.getPosition(),this.buffer.toString(),o.getSecondDigit()),new Qt(!0,d)}if(this.buffer.append(o.getFirstDigit()),o.isSecondDigitFNC1()){let d=new Ut(this.current.getPosition(),this.buffer.toString());return new Qt(!0,d)}this.buffer.append(o.getSecondDigit())}return this.isNumericToAlphaNumericLatch(this.current.getPosition())&&(this.current.setAlpha(),this.current.incrementPosition(4)),new Qt(!1)}parseIsoIec646Block(){for(;this.isStillIsoIec646(this.current.getPosition());){let o=this.decodeIsoIec646(this.current.getPosition());if(this.current.setPosition(o.getNewPosition()),o.isFNC1()){let d=new Ut(this.current.getPosition(),this.buffer.toString());return new Qt(!0,d)}this.buffer.append(o.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setAlpha()),new Qt(!1)}parseAlphaBlock(){for(;this.isStillAlpha(this.current.getPosition());){let o=this.decodeAlphanumeric(this.current.getPosition());if(this.current.setPosition(o.getNewPosition()),o.isFNC1()){let d=new Ut(this.current.getPosition(),this.buffer.toString());return new Qt(!0,d)}this.buffer.append(o.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setIsoIec646()),new Qt(!1)}isStillIsoIec646(o){if(o+5>this.information.getSize())return!1;let d=this.extractNumericValueFromBitArray(o,5);if(d>=5&&d<16)return!0;if(o+7>this.information.getSize())return!1;let f=this.extractNumericValueFromBitArray(o,7);if(f>=64&&f<116)return!0;if(o+8>this.information.getSize())return!1;let p=this.extractNumericValueFromBitArray(o,8);return p>=232&&p<253}decodeIsoIec646(o){let d=this.extractNumericValueFromBitArray(o,5);if(d===15)return new Vt(o+5,Vt.FNC1);if(d>=5&&d<15)return new Vt(o+5,"0"+(d-5));let f=this.extractNumericValueFromBitArray(o,7);if(f>=64&&f<90)return new Vt(o+7,""+(f+1));if(f>=90&&f<116)return new Vt(o+7,""+(f+7));let p=this.extractNumericValueFromBitArray(o,8),b;switch(p){case 232:b="!";break;case 233:b='"';break;case 234:b="%";break;case 235:b="&";break;case 236:b="'";break;case 237:b="(";break;case 238:b=")";break;case 239:b="*";break;case 240:b="+";break;case 241:b=",";break;case 242:b="-";break;case 243:b=".";break;case 244:b="/";break;case 245:b=":";break;case 246:b=";";break;case 247:b="<";break;case 248:b="=";break;case 249:b=">";break;case 250:b="?";break;case 251:b="_";break;case 252:b=" ";break;default:throw new H}return new Vt(o+8,b)}isStillAlpha(o){if(o+5>this.information.getSize())return!1;let d=this.extractNumericValueFromBitArray(o,5);if(d>=5&&d<16)return!0;if(o+6>this.information.getSize())return!1;let f=this.extractNumericValueFromBitArray(o,6);return f>=16&&f<63}decodeAlphanumeric(o){let d=this.extractNumericValueFromBitArray(o,5);if(d===15)return new Vt(o+5,Vt.FNC1);if(d>=5&&d<15)return new Vt(o+5,"0"+(d-5));let f=this.extractNumericValueFromBitArray(o,6);if(f>=32&&f<58)return new Vt(o+6,""+(f+33));let p;switch(f){case 58:p="*";break;case 59:p=",";break;case 60:p="-";break;case 61:p=".";break;case 62:p="/";break;default:throw new ar("Decoding invalid alphanumeric value: "+f)}return new Vt(o+6,p)}isAlphaTo646ToAlphaLatch(o){if(o+1>this.information.getSize())return!1;for(let d=0;d<5&&d+o<this.information.getSize();++d)if(d===2){if(!this.information.get(o+2))return!1}else if(this.information.get(o+d))return!1;return!0}isAlphaOr646ToNumericLatch(o){if(o+3>this.information.getSize())return!1;for(let d=o;d<o+3;++d)if(this.information.get(d))return!1;return!0}isNumericToAlphaNumericLatch(o){if(o+1>this.information.getSize())return!1;for(let d=0;d<4&&d+o<this.information.getSize();++d)if(this.information.get(o+d))return!1;return!0}}class we{constructor(o){this.information=o,this.generalDecoder=new be(o)}getInformation(){return this.information}getGeneralDecoder(){return this.generalDecoder}}class ke extends we{constructor(o){super(o)}encodeCompressedGtin(o,d){o.append("(01)");let f=o.length();o.append("9"),this.encodeCompressedGtinWithoutAI(o,d,f)}encodeCompressedGtinWithoutAI(o,d,f){for(let p=0;p<4;++p){let b=this.getGeneralDecoder().extractNumericValueFromBitArray(d+10*p,10);b/100===0&&o.append("0"),b/10===0&&o.append("0"),o.append(b)}ke.appendCheckDigit(o,f)}static appendCheckDigit(o,d){let f=0;for(let p=0;p<13;p++){let b=o.charAt(p+d).charCodeAt(0)-48;f+=(p&1)===0?3*b:b}f=10-f%10,f===10&&(f=0),o.append(f)}}ke.GTIN_SIZE=40;class Te extends ke{constructor(o){super(o)}parseInformation(){let o=new ce;o.append("(01)");let d=o.length(),f=this.getGeneralDecoder().extractNumericValueFromBitArray(Te.HEADER_SIZE,4);return o.append(f),this.encodeCompressedGtinWithoutAI(o,Te.HEADER_SIZE+4,d),this.getGeneralDecoder().decodeAllCodes(o,Te.HEADER_SIZE+44)}}Te.HEADER_SIZE=4;class Qe extends we{constructor(o){super(o)}parseInformation(){let o=new ce;return this.getGeneralDecoder().decodeAllCodes(o,Qe.HEADER_SIZE)}}Qe.HEADER_SIZE=5;class bt extends ke{constructor(o){super(o)}encodeCompressedWeight(o,d,f){let p=this.getGeneralDecoder().extractNumericValueFromBitArray(d,f);this.addWeightCode(o,p);let b=this.checkWeight(p),w=1e5;for(let S=0;S<5;++S)b/w===0&&o.append("0"),w/=10;o.append(b)}}class et extends bt{constructor(o){super(o)}parseInformation(){if(this.getInformation().getSize()!=et.HEADER_SIZE+bt.GTIN_SIZE+et.WEIGHT_SIZE)throw new ae;let o=new ce;return this.encodeCompressedGtin(o,et.HEADER_SIZE),this.encodeCompressedWeight(o,et.HEADER_SIZE+bt.GTIN_SIZE,et.WEIGHT_SIZE),o.toString()}}et.HEADER_SIZE=5,et.WEIGHT_SIZE=15;class at extends et{constructor(o){super(o)}addWeightCode(o,d){o.append("(3103)")}checkWeight(o){return o}}class nt extends et{constructor(o){super(o)}addWeightCode(o,d){d<1e4?o.append("(3202)"):o.append("(3203)")}checkWeight(o){return o<1e4?o:o-1e4}}class Ot extends ke{constructor(o){super(o)}parseInformation(){if(this.getInformation().getSize()<Ot.HEADER_SIZE+ke.GTIN_SIZE)throw new ae;let o=new ce;this.encodeCompressedGtin(o,Ot.HEADER_SIZE);let d=this.getGeneralDecoder().extractNumericValueFromBitArray(Ot.HEADER_SIZE+ke.GTIN_SIZE,Ot.LAST_DIGIT_SIZE);o.append("(392"),o.append(d),o.append(")");let f=this.getGeneralDecoder().decodeGeneralPurposeField(Ot.HEADER_SIZE+ke.GTIN_SIZE+Ot.LAST_DIGIT_SIZE,null);return o.append(f.getNewString()),o.toString()}}Ot.HEADER_SIZE=8,Ot.LAST_DIGIT_SIZE=2;class It extends ke{constructor(o){super(o)}parseInformation(){if(this.getInformation().getSize()<It.HEADER_SIZE+ke.GTIN_SIZE)throw new ae;let o=new ce;this.encodeCompressedGtin(o,It.HEADER_SIZE);let d=this.getGeneralDecoder().extractNumericValueFromBitArray(It.HEADER_SIZE+ke.GTIN_SIZE,It.LAST_DIGIT_SIZE);o.append("(393"),o.append(d),o.append(")");let f=this.getGeneralDecoder().extractNumericValueFromBitArray(It.HEADER_SIZE+ke.GTIN_SIZE+It.LAST_DIGIT_SIZE,It.FIRST_THREE_DIGITS_SIZE);f/100==0&&o.append("0"),f/10==0&&o.append("0"),o.append(f);let p=this.getGeneralDecoder().decodeGeneralPurposeField(It.HEADER_SIZE+ke.GTIN_SIZE+It.LAST_DIGIT_SIZE+It.FIRST_THREE_DIGITS_SIZE,null);return o.append(p.getNewString()),o.toString()}}It.HEADER_SIZE=8,It.LAST_DIGIT_SIZE=2,It.FIRST_THREE_DIGITS_SIZE=10;class Ht extends bt{constructor(o,d,f){super(o),this.dateCode=f,this.firstAIdigits=d}parseInformation(){if(this.getInformation().getSize()!=Ht.HEADER_SIZE+Ht.GTIN_SIZE+Ht.WEIGHT_SIZE+Ht.DATE_SIZE)throw new ae;let o=new ce;return this.encodeCompressedGtin(o,Ht.HEADER_SIZE),this.encodeCompressedWeight(o,Ht.HEADER_SIZE+Ht.GTIN_SIZE,Ht.WEIGHT_SIZE),this.encodeCompressedDate(o,Ht.HEADER_SIZE+Ht.GTIN_SIZE+Ht.WEIGHT_SIZE),o.toString()}encodeCompressedDate(o,d){let f=this.getGeneralDecoder().extractNumericValueFromBitArray(d,Ht.DATE_SIZE);if(f==38400)return;o.append("("),o.append(this.dateCode),o.append(")");let p=f%32;f/=32;let b=f%12+1;f/=12;let w=f;w/10==0&&o.append("0"),o.append(w),b/10==0&&o.append("0"),o.append(b),p/10==0&&o.append("0"),o.append(p)}addWeightCode(o,d){o.append("("),o.append(this.firstAIdigits),o.append(d/1e5),o.append(")")}checkWeight(o){return o%1e5}}Ht.HEADER_SIZE=8,Ht.WEIGHT_SIZE=20,Ht.DATE_SIZE=16;function zt(ee){try{if(ee.get(1))return new Te(ee);if(!ee.get(2))return new Qe(ee);switch(be.extractNumericValueFromBitArray(ee,1,4)){case 4:return new at(ee);case 5:return new nt(ee)}switch(be.extractNumericValueFromBitArray(ee,1,5)){case 12:return new Ot(ee);case 13:return new It(ee)}switch(be.extractNumericValueFromBitArray(ee,1,7)){case 56:return new Ht(ee,"310","11");case 57:return new Ht(ee,"320","11");case 58:return new Ht(ee,"310","13");case 59:return new Ht(ee,"320","13");case 60:return new Ht(ee,"310","15");case 61:return new Ht(ee,"320","15");case 62:return new Ht(ee,"310","17");case 63:return new Ht(ee,"320","17")}}catch(o){throw console.log(o),new ar("unknown decoder: "+ee)}}class Kt{constructor(o,d,f,p){this.leftchar=o,this.rightchar=d,this.finderpattern=f,this.maybeLast=p}mayBeLast(){return this.maybeLast}getLeftChar(){return this.leftchar}getRightChar(){return this.rightchar}getFinderPattern(){return this.finderpattern}mustBeLast(){return this.rightchar==null}toString(){return"[ "+this.leftchar+", "+this.rightchar+" : "+(this.finderpattern==null?"null":this.finderpattern.getValue())+" ]"}static equals(o,d){return o instanceof Kt?Kt.equalsOrNull(o.leftchar,d.leftchar)&&Kt.equalsOrNull(o.rightchar,d.rightchar)&&Kt.equalsOrNull(o.finderpattern,d.finderpattern):!1}static equalsOrNull(o,d){return o===null?d===null:Kt.equals(o,d)}hashCode(){return this.leftchar.getValue()^this.rightchar.getValue()^this.finderpattern.getValue()}}class fr{constructor(o,d,f){this.pairs=o,this.rowNumber=d,this.wasReversed=f}getPairs(){return this.pairs}getRowNumber(){return this.rowNumber}isReversed(){return this.wasReversed}isEquivalent(o){return this.checkEqualitity(this,o)}toString(){return"{ "+this.pairs+" }"}equals(o,d){return o instanceof fr?this.checkEqualitity(o,d)&&o.wasReversed===d.wasReversed:!1}checkEqualitity(o,d){if(!o||!d)return;let f;return o.forEach((p,b)=>{d.forEach(w=>{p.getLeftChar().getValue()===w.getLeftChar().getValue()&&p.getRightChar().getValue()===w.getRightChar().getValue()&&p.getFinderPatter().getValue()===w.getFinderPatter().getValue()&&(f=!0)})}),f}}class Ee extends Yt{constructor(o){super(...arguments),this.pairs=new Array(Ee.MAX_PAIRS),this.rows=new Array,this.startEnd=[2],this.verbose=o===!0}decodeRow(o,d,f){this.pairs.length=0,this.startFromEven=!1;try{return Ee.constructResult(this.decodeRow2pairs(o,d))}catch(p){this.verbose&&console.log(p)}return this.pairs.length=0,this.startFromEven=!0,Ee.constructResult(this.decodeRow2pairs(o,d))}reset(){this.pairs.length=0,this.rows.length=0}decodeRow2pairs(o,d){let f=!1;for(;!f;)try{this.pairs.push(this.retrieveNextPair(d,this.pairs,o))}catch(b){if(b instanceof ae){if(!this.pairs.length)throw new ae;f=!0}}if(this.checkChecksum())return this.pairs;let p;if(this.rows.length?p=!0:p=!1,this.storeRow(o,!1),p){let b=this.checkRowsBoolean(!1);if(b!=null||(b=this.checkRowsBoolean(!0),b!=null))return b}throw new ae}checkRowsBoolean(o){if(this.rows.length>25)return this.rows.length=0,null;this.pairs.length=0,o&&(this.rows=this.rows.reverse());let d=null;try{d=this.checkRows(new Array,0)}catch(f){this.verbose&&console.log(f)}return o&&(this.rows=this.rows.reverse()),d}checkRows(o,d){for(let f=d;f<this.rows.length;f++){let p=this.rows[f];this.pairs.length=0;for(let w of o)this.pairs.push(w.getPairs());if(this.pairs.push(p.getPairs()),!Ee.isValidSequence(this.pairs))continue;if(this.checkChecksum())return this.pairs;let b=new Array(o);b.push(p);try{return this.checkRows(b,f+1)}catch(w){this.verbose&&console.log(w)}}throw new ae}static isValidSequence(o){for(let d of Ee.FINDER_PATTERN_SEQUENCES){if(o.length>d.length)continue;let f=!0;for(let p=0;p<o.length;p++)if(o[p].getFinderPattern().getValue()!=d[p]){f=!1;break}if(f)return!0}return!1}storeRow(o,d){let f=0,p=!1,b=!1;for(;f<this.rows.length;){let w=this.rows[f];if(w.getRowNumber()>o){b=w.isEquivalent(this.pairs);break}p=w.isEquivalent(this.pairs),f++}b||p||Ee.isPartialRow(this.pairs,this.rows)||(this.rows.push(f,new fr(this.pairs,o,d)),this.removePartialRows(this.pairs,this.rows))}removePartialRows(o,d){for(let f of d)if(f.getPairs().length!==o.length){for(let p of f.getPairs())for(let b of o)if(Kt.equals(p,b))break}}static isPartialRow(o,d){for(let f of d){let p=!0;for(let b of o){let w=!1;for(let S of f.getPairs())if(b.equals(S)){w=!0;break}if(!w){p=!1;break}}if(p)return!0}return!1}getRows(){return this.rows}static constructResult(o){let d=en.buildBitArray(o),p=zt(d).parseInformation(),b=o[0].getFinderPattern().getResultPoints(),w=o[o.length-1].getFinderPattern().getResultPoints(),S=[b[0],b[1],w[0],w[1]];return new re(p,null,null,S,ve.RSS_EXPANDED,null)}checkChecksum(){let o=this.pairs.get(0),d=o.getLeftChar(),f=o.getRightChar();if(f==null)return!1;let p=f.getChecksumPortion(),b=2;for(let S=1;S<this.pairs.size();++S){let R=this.pairs.get(S);p+=R.getLeftChar().getChecksumPortion(),b++;let P=R.getRightChar();P!=null&&(p+=P.getChecksumPortion(),b++)}return p%=211,211*(b-4)+p==d.getValue()}static getNextSecondBar(o,d){let f;return o.get(d)?(f=o.getNextUnset(d),f=o.getNextSet(f)):(f=o.getNextSet(d),f=o.getNextUnset(f)),f}retrieveNextPair(o,d,f){let p=d.length%2==0;this.startFromEven&&(p=!p);let b,w=!0,S=-1;do this.findNextPair(o,d,S),b=this.parseFoundFinderPattern(o,f,p),b==null?S=Ee.getNextSecondBar(o,this.startEnd[0]):w=!1;while(w);let R=this.decodeDataCharacter(o,b,p,!0);if(!this.isEmptyPair(d)&&d[d.length-1].mustBeLast())throw new ae;let P;try{P=this.decodeDataCharacter(o,b,p,!1)}catch(X){P=null,this.verbose&&console.log(X)}return new Kt(R,P,b,!0)}isEmptyPair(o){return o.length===0}findNextPair(o,d,f){let p=this.getDecodeFinderCounters();p[0]=0,p[1]=0,p[2]=0,p[3]=0;let b=o.getSize(),w;f>=0?w=f:this.isEmptyPair(d)?w=0:w=d[d.length-1].getFinderPattern().getStartEnd()[1];let S=d.length%2!=0;this.startFromEven&&(S=!S);let R=!1;for(;w<b&&(R=!o.get(w),!!R);)w++;let P=0,X=w;for(let te=w;te<b;te++)if(o.get(te)!=R)p[P]++;else{if(P==3){if(S&&Ee.reverseCounters(p),Ee.isFinderPattern(p)){this.startEnd[0]=X,this.startEnd[1]=te;return}S&&Ee.reverseCounters(p),X+=p[0]+p[1],p[0]=p[2],p[1]=p[3],p[2]=0,p[3]=0,P--}else P++;p[P]=1,R=!R}throw new ae}static reverseCounters(o){let d=o.length;for(let f=0;f<d/2;++f){let p=o[f];o[f]=o[d-f-1],o[d-f-1]=p}}parseFoundFinderPattern(o,d,f){let p,b,w;if(f){let P=this.startEnd[0]-1;for(;P>=0&&!o.get(P);)P--;P++,p=this.startEnd[0]-P,b=P,w=this.startEnd[1]}else b=this.startEnd[0],w=o.getNextUnset(this.startEnd[1]+1),p=w-this.startEnd[1];let S=this.getDecodeFinderCounters();A.arraycopy(S,0,S,1,S.length-1),S[0]=p;let R;try{R=this.parseFinderValue(S,Ee.FINDER_PATTERNS)}catch(P){return null}return new jr(R,[b,w],b,w,d)}decodeDataCharacter(o,d,f,p){let b=this.getDataCharacterCounters();for(let ca=0;ca<b.length;ca++)b[ca]=0;if(p)Ee.recordPatternInReverse(o,d.getStartEnd()[0],b);else{Ee.recordPattern(o,d.getStartEnd()[1],b);for(let ca=0,bn=b.length-1;ca<bn;ca++,bn--){let Hn=b[ca];b[ca]=b[bn],b[bn]=Hn}}let w=17,S=$t.sum(new Int32Array(b))/w,R=(d.getStartEnd()[1]-d.getStartEnd()[0])/15;if(Math.abs(S-R)/R>.3)throw new ae;let P=this.getOddCounts(),X=this.getEvenCounts(),te=this.getOddRoundingErrors(),ue=this.getEvenRoundingErrors();for(let ca=0;ca<b.length;ca++){let bn=1*b[ca]/S,Hn=bn+.5;if(Hn<1){if(bn<.3)throw new ae;Hn=1}else if(Hn>8){if(bn>8.7)throw new ae;Hn=8}let co=ca/2;(ca&1)==0?(P[co]=Hn,te[co]=bn-Hn):(X[co]=Hn,ue[co]=bn-Hn)}this.adjustOddEvenCounts(w);let je=4*d.getValue()+(f?0:2)+(p?0:1)-1,Fe=0,Ue=0;for(let ca=P.length-1;ca>=0;ca--){if(Ee.isNotA1left(d,f,p)){let bn=Ee.WEIGHTS[je][2*ca];Ue+=P[ca]*bn}Fe+=P[ca]}let tt=0;for(let ca=X.length-1;ca>=0;ca--)if(Ee.isNotA1left(d,f,p)){let bn=Ee.WEIGHTS[je][2*ca+1];tt+=X[ca]*bn}let ut=Ue+tt;if((Fe&1)!=0||Fe>13||Fe<4)throw new ae;let Xt=(13-Fe)/2,Gt=Ee.SYMBOL_WIDEST[Xt],Ft=9-Gt,Wr=Zr.getRSSvalue(P,Gt,!0),Ur=Zr.getRSSvalue(X,Ft,!1),fa=Ee.EVEN_TOTAL_SUBSET[Xt],Rn=Ee.GSUM[Xt],Mn=Wr*fa+Ur+Rn;return new gr(Mn,ut)}static isNotA1left(o,d,f){return!(o.getValue()==0&&d&&f)}adjustOddEvenCounts(o){let d=$t.sum(new Int32Array(this.getOddCounts())),f=$t.sum(new Int32Array(this.getEvenCounts())),p=!1,b=!1;d>13?b=!0:d<4&&(p=!0);let w=!1,S=!1;f>13?S=!0:f<4&&(w=!0);let R=d+f-o,P=(d&1)==1,X=(f&1)==0;if(R==1)if(P){if(X)throw new ae;b=!0}else{if(!X)throw new ae;S=!0}else if(R==-1)if(P){if(X)throw new ae;p=!0}else{if(!X)throw new ae;w=!0}else if(R==0){if(P){if(!X)throw new ae;d<f?(p=!0,S=!0):(b=!0,w=!0)}else if(X)throw new ae}else throw new ae;if(p){if(b)throw new ae;Ee.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(b&&Ee.decrement(this.getOddCounts(),this.getOddRoundingErrors()),w){if(S)throw new ae;Ee.increment(this.getEvenCounts(),this.getOddRoundingErrors())}S&&Ee.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}Ee.SYMBOL_WIDEST=[7,5,4,3,1],Ee.EVEN_TOTAL_SUBSET=[4,20,52,104,204],Ee.GSUM=[0,348,1388,2948,3988],Ee.FINDER_PATTERNS=[Int32Array.from([1,8,4,1]),Int32Array.from([3,6,4,1]),Int32Array.from([3,4,6,1]),Int32Array.from([3,2,8,1]),Int32Array.from([2,6,5,1]),Int32Array.from([2,2,9,1])],Ee.WEIGHTS=[[1,3,9,27,81,32,96,77],[20,60,180,118,143,7,21,63],[189,145,13,39,117,140,209,205],[193,157,49,147,19,57,171,91],[62,186,136,197,169,85,44,132],[185,133,188,142,4,12,36,108],[113,128,173,97,80,29,87,50],[150,28,84,41,123,158,52,156],[46,138,203,187,139,206,196,166],[76,17,51,153,37,111,122,155],[43,129,176,106,107,110,119,146],[16,48,144,10,30,90,59,177],[109,116,137,200,178,112,125,164],[70,210,208,202,184,130,179,115],[134,191,151,31,93,68,204,190],[148,22,66,198,172,94,71,2],[6,18,54,162,64,192,154,40],[120,149,25,75,14,42,126,167],[79,26,78,23,69,207,199,175],[103,98,83,38,114,131,182,124],[161,61,183,127,170,88,53,159],[55,165,73,8,24,72,5,15],[45,135,194,160,58,174,100,89]],Ee.FINDER_PAT_A=0,Ee.FINDER_PAT_B=1,Ee.FINDER_PAT_C=2,Ee.FINDER_PAT_D=3,Ee.FINDER_PAT_E=4,Ee.FINDER_PAT_F=5,Ee.FINDER_PATTERN_SEQUENCES=[[Ee.FINDER_PAT_A,Ee.FINDER_PAT_A],[Ee.FINDER_PAT_A,Ee.FINDER_PAT_B,Ee.FINDER_PAT_B],[Ee.FINDER_PAT_A,Ee.FINDER_PAT_C,Ee.FINDER_PAT_B,Ee.FINDER_PAT_D],[Ee.FINDER_PAT_A,Ee.FINDER_PAT_E,Ee.FINDER_PAT_B,Ee.FINDER_PAT_D,Ee.FINDER_PAT_C],[Ee.FINDER_PAT_A,Ee.FINDER_PAT_E,Ee.FINDER_PAT_B,Ee.FINDER_PAT_D,Ee.FINDER_PAT_D,Ee.FINDER_PAT_F],[Ee.FINDER_PAT_A,Ee.FINDER_PAT_E,Ee.FINDER_PAT_B,Ee.FINDER_PAT_D,Ee.FINDER_PAT_E,Ee.FINDER_PAT_F,Ee.FINDER_PAT_F],[Ee.FINDER_PAT_A,Ee.FINDER_PAT_A,Ee.FINDER_PAT_B,Ee.FINDER_PAT_B,Ee.FINDER_PAT_C,Ee.FINDER_PAT_C,Ee.FINDER_PAT_D,Ee.FINDER_PAT_D],[Ee.FINDER_PAT_A,Ee.FINDER_PAT_A,Ee.FINDER_PAT_B,Ee.FINDER_PAT_B,Ee.FINDER_PAT_C,Ee.FINDER_PAT_C,Ee.FINDER_PAT_D,Ee.FINDER_PAT_E,Ee.FINDER_PAT_E],[Ee.FINDER_PAT_A,Ee.FINDER_PAT_A,Ee.FINDER_PAT_B,Ee.FINDER_PAT_B,Ee.FINDER_PAT_C,Ee.FINDER_PAT_C,Ee.FINDER_PAT_D,Ee.FINDER_PAT_E,Ee.FINDER_PAT_F,Ee.FINDER_PAT_F],[Ee.FINDER_PAT_A,Ee.FINDER_PAT_A,Ee.FINDER_PAT_B,Ee.FINDER_PAT_B,Ee.FINDER_PAT_C,Ee.FINDER_PAT_D,Ee.FINDER_PAT_D,Ee.FINDER_PAT_E,Ee.FINDER_PAT_E,Ee.FINDER_PAT_F,Ee.FINDER_PAT_F]],Ee.MAX_PAIRS=11;class wt extends gr{constructor(o,d,f){super(o,d),this.count=0,this.finderPattern=f}getFinderPattern(){return this.finderPattern}getCount(){return this.count}incrementCount(){this.count++}}class xr extends Yt{constructor(){super(...arguments),this.possibleLeftPairs=[],this.possibleRightPairs=[]}decodeRow(o,d,f){const p=this.decodePair(d,!1,o,f);xr.addOrTally(this.possibleLeftPairs,p),d.reverse();let b=this.decodePair(d,!0,o,f);xr.addOrTally(this.possibleRightPairs,b),d.reverse();for(let w of this.possibleLeftPairs)if(w.getCount()>1){for(let S of this.possibleRightPairs)if(S.getCount()>1&&xr.checkChecksum(w,S))return xr.constructResult(w,S)}throw new ae}static addOrTally(o,d){if(d==null)return;let f=!1;for(let p of o)if(p.getValue()===d.getValue()){p.incrementCount(),f=!0;break}f||o.push(d)}reset(){this.possibleLeftPairs.length=0,this.possibleRightPairs.length=0}static constructResult(o,d){let f=4537077*o.getValue()+d.getValue(),p=new String(f).toString(),b=new ce;for(let P=13-p.length;P>0;P--)b.append("0");b.append(p);let w=0;for(let P=0;P<13;P++){let X=b.charAt(P).charCodeAt(0)-48;w+=(P&1)===0?3*X:X}w=10-w%10,w===10&&(w=0),b.append(w.toString());let S=o.getFinderPattern().getResultPoints(),R=d.getFinderPattern().getResultPoints();return new re(b.toString(),null,0,[S[0],S[1],R[0],R[1]],ve.RSS_14,new Date().getTime())}static checkChecksum(o,d){let f=(o.getChecksumPortion()+16*d.getChecksumPortion())%79,p=9*o.getFinderPattern().getValue()+d.getFinderPattern().getValue();return p>72&&p--,p>8&&p--,f===p}decodePair(o,d,f,p){try{let b=this.findFinderPattern(o,d),w=this.parseFoundFinderPattern(o,f,d,b),S=p==null?null:p.get(W.NEED_RESULT_POINT_CALLBACK);if(S!=null){let X=(b[0]+b[1])/2;d&&(X=o.getSize()-1-X),S.foundPossibleResultPoint(new St(X,f))}let R=this.decodeDataCharacter(o,w,!0),P=this.decodeDataCharacter(o,w,!1);return new wt(1597*R.getValue()+P.getValue(),R.getChecksumPortion()+4*P.getChecksumPortion(),w)}catch(b){return null}}decodeDataCharacter(o,d,f){let p=this.getDataCharacterCounters();for(let tt=0;tt<p.length;tt++)p[tt]=0;if(f)Ge.recordPatternInReverse(o,d.getStartEnd()[0],p);else{Ge.recordPattern(o,d.getStartEnd()[1]+1,p);for(let tt=0,ut=p.length-1;tt<ut;tt++,ut--){let Xt=p[tt];p[tt]=p[ut],p[ut]=Xt}}let b=f?16:15,w=$t.sum(new Int32Array(p))/b,S=this.getOddCounts(),R=this.getEvenCounts(),P=this.getOddRoundingErrors(),X=this.getEvenRoundingErrors();for(let tt=0;tt<p.length;tt++){let ut=p[tt]/w,Xt=Math.floor(ut+.5);Xt<1?Xt=1:Xt>8&&(Xt=8);let Gt=Math.floor(tt/2);(tt&1)===0?(S[Gt]=Xt,P[Gt]=ut-Xt):(R[Gt]=Xt,X[Gt]=ut-Xt)}this.adjustOddEvenCounts(f,b);let te=0,ue=0;for(let tt=S.length-1;tt>=0;tt--)ue*=9,ue+=S[tt],te+=S[tt];let je=0,Fe=0;for(let tt=R.length-1;tt>=0;tt--)je*=9,je+=R[tt],Fe+=R[tt];let Ue=ue+3*je;if(f){if((te&1)!==0||te>12||te<4)throw new ae;let tt=(12-te)/2,ut=xr.OUTSIDE_ODD_WIDEST[tt],Xt=9-ut,Gt=Zr.getRSSvalue(S,ut,!1),Ft=Zr.getRSSvalue(R,Xt,!0),Wr=xr.OUTSIDE_EVEN_TOTAL_SUBSET[tt],Ur=xr.OUTSIDE_GSUM[tt];return new gr(Gt*Wr+Ft+Ur,Ue)}else{if((Fe&1)!==0||Fe>10||Fe<4)throw new ae;let tt=(10-Fe)/2,ut=xr.INSIDE_ODD_WIDEST[tt],Xt=9-ut,Gt=Zr.getRSSvalue(S,ut,!0),Ft=Zr.getRSSvalue(R,Xt,!1),Wr=xr.INSIDE_ODD_TOTAL_SUBSET[tt],Ur=xr.INSIDE_GSUM[tt];return new gr(Ft*Wr+Gt+Ur,Ue)}}findFinderPattern(o,d){let f=this.getDecodeFinderCounters();f[0]=0,f[1]=0,f[2]=0,f[3]=0;let p=o.getSize(),b=!1,w=0;for(;w<p&&(b=!o.get(w),d!==b);)w++;let S=0,R=w;for(let P=w;P<p;P++)if(o.get(P)!==b)f[S]++;else{if(S===3){if(Yt.isFinderPattern(f))return[R,P];R+=f[0]+f[1],f[0]=f[2],f[1]=f[3],f[2]=0,f[3]=0,S--}else S++;f[S]=1,b=!b}throw new ae}parseFoundFinderPattern(o,d,f,p){let b=o.get(p[0]),w=p[0]-1;for(;w>=0&&b!==o.get(w);)w--;w++;const S=p[0]-w,R=this.getDecodeFinderCounters(),P=new Int32Array(R.length);A.arraycopy(R,0,P,1,R.length-1),P[0]=S;const X=this.parseFinderValue(P,xr.FINDER_PATTERNS);let te=w,ue=p[1];return f&&(te=o.getSize()-1-te,ue=o.getSize()-1-ue),new jr(X,[w,p[1]],te,ue,d)}adjustOddEvenCounts(o,d){let f=$t.sum(new Int32Array(this.getOddCounts())),p=$t.sum(new Int32Array(this.getEvenCounts())),b=!1,w=!1,S=!1,R=!1;o?(f>12?w=!0:f<4&&(b=!0),p>12?R=!0:p<4&&(S=!0)):(f>11?w=!0:f<5&&(b=!0),p>10?R=!0:p<4&&(S=!0));let P=f+p-d,X=(f&1)===(o?1:0),te=(p&1)===1;if(P===1)if(X){if(te)throw new ae;w=!0}else{if(!te)throw new ae;R=!0}else if(P===-1)if(X){if(te)throw new ae;b=!0}else{if(!te)throw new ae;S=!0}else if(P===0){if(X){if(!te)throw new ae;f<p?(b=!0,R=!0):(w=!0,S=!0)}else if(te)throw new ae}else throw new ae;if(b){if(w)throw new ae;Yt.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(w&&Yt.decrement(this.getOddCounts(),this.getOddRoundingErrors()),S){if(R)throw new ae;Yt.increment(this.getEvenCounts(),this.getOddRoundingErrors())}R&&Yt.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}xr.OUTSIDE_EVEN_TOTAL_SUBSET=[1,10,34,70,126],xr.INSIDE_ODD_TOTAL_SUBSET=[4,20,48,81],xr.OUTSIDE_GSUM=[0,161,961,2015,2715],xr.INSIDE_GSUM=[0,336,1036,1516],xr.OUTSIDE_ODD_WIDEST=[8,6,4,3,1],xr.INSIDE_ODD_WIDEST=[2,4,6,8],xr.FINDER_PATTERNS=[Int32Array.from([3,8,2,1]),Int32Array.from([3,5,5,1]),Int32Array.from([3,3,7,1]),Int32Array.from([3,1,9,1]),Int32Array.from([2,7,4,1]),Int32Array.from([2,5,6,1]),Int32Array.from([2,3,8,1]),Int32Array.from([1,5,7,1]),Int32Array.from([1,3,9,1])];class qr extends Ge{constructor(o,d){super(),this.readers=[],this.verbose=d===!0;const f=o?o.get(W.POSSIBLE_FORMATS):null,p=o&&o.get(W.ASSUME_CODE_39_CHECK_DIGIT)!==void 0;f?((f.includes(ve.EAN_13)||f.includes(ve.UPC_A)||f.includes(ve.EAN_8)||f.includes(ve.UPC_E))&&this.readers.push(new Ke(o)),f.includes(ve.CODE_39)&&this.readers.push(new At(p)),f.includes(ve.CODE_128)&&this.readers.push(new We),f.includes(ve.ITF)&&this.readers.push(new lt),f.includes(ve.RSS_14)&&this.readers.push(new xr),f.includes(ve.RSS_EXPANDED)&&this.readers.push(new Ee(this.verbose))):(this.readers.push(new Ke(o)),this.readers.push(new At),this.readers.push(new Ke(o)),this.readers.push(new We),this.readers.push(new lt),this.readers.push(new xr),this.readers.push(new Ee(this.verbose)))}decodeRow(o,d,f){for(let p=0;p<this.readers.length;p++)try{return this.readers[p].decodeRow(o,d,f)}catch(b){}throw new ae}reset(){this.readers.forEach(o=>o.reset())}}class Za extends ie{constructor(o=500,d){super(new qr(d),o,d)}}class Tr{constructor(o,d,f){this.ecCodewords=o,this.ecBlocks=[d],f&&this.ecBlocks.push(f)}getECCodewords(){return this.ecCodewords}getECBlocks(){return this.ecBlocks}}class Ar{constructor(o,d){this.count=o,this.dataCodewords=d}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class Pe{constructor(o,d,f,p,b,w){this.versionNumber=o,this.symbolSizeRows=d,this.symbolSizeColumns=f,this.dataRegionSizeRows=p,this.dataRegionSizeColumns=b,this.ecBlocks=w;let S=0;const R=w.getECCodewords(),P=w.getECBlocks();for(let X of P)S+=X.getCount()*(X.getDataCodewords()+R);this.totalCodewords=S}getVersionNumber(){return this.versionNumber}getSymbolSizeRows(){return this.symbolSizeRows}getSymbolSizeColumns(){return this.symbolSizeColumns}getDataRegionSizeRows(){return this.dataRegionSizeRows}getDataRegionSizeColumns(){return this.dataRegionSizeColumns}getTotalCodewords(){return this.totalCodewords}getECBlocks(){return this.ecBlocks}static getVersionForDimensions(o,d){if((o&1)!==0||(d&1)!==0)throw new H;for(let f of Pe.VERSIONS)if(f.symbolSizeRows===o&&f.symbolSizeColumns===d)return f;throw new H}toString(){return""+this.versionNumber}static buildVersions(){return[new Pe(1,10,10,8,8,new Tr(5,new Ar(1,3))),new Pe(2,12,12,10,10,new Tr(7,new Ar(1,5))),new Pe(3,14,14,12,12,new Tr(10,new Ar(1,8))),new Pe(4,16,16,14,14,new Tr(12,new Ar(1,12))),new Pe(5,18,18,16,16,new Tr(14,new Ar(1,18))),new Pe(6,20,20,18,18,new Tr(18,new Ar(1,22))),new Pe(7,22,22,20,20,new Tr(20,new Ar(1,30))),new Pe(8,24,24,22,22,new Tr(24,new Ar(1,36))),new Pe(9,26,26,24,24,new Tr(28,new Ar(1,44))),new Pe(10,32,32,14,14,new Tr(36,new Ar(1,62))),new Pe(11,36,36,16,16,new Tr(42,new Ar(1,86))),new Pe(12,40,40,18,18,new Tr(48,new Ar(1,114))),new Pe(13,44,44,20,20,new Tr(56,new Ar(1,144))),new Pe(14,48,48,22,22,new Tr(68,new Ar(1,174))),new Pe(15,52,52,24,24,new Tr(42,new Ar(2,102))),new Pe(16,64,64,14,14,new Tr(56,new Ar(2,140))),new Pe(17,72,72,16,16,new Tr(36,new Ar(4,92))),new Pe(18,80,80,18,18,new Tr(48,new Ar(4,114))),new Pe(19,88,88,20,20,new Tr(56,new Ar(4,144))),new Pe(20,96,96,22,22,new Tr(68,new Ar(4,174))),new Pe(21,104,104,24,24,new Tr(56,new Ar(6,136))),new Pe(22,120,120,18,18,new Tr(68,new Ar(6,175))),new Pe(23,132,132,20,20,new Tr(62,new Ar(8,163))),new Pe(24,144,144,22,22,new Tr(62,new Ar(8,156),new Ar(2,155))),new Pe(25,8,18,6,16,new Tr(7,new Ar(1,5))),new Pe(26,8,32,6,14,new Tr(11,new Ar(1,10))),new Pe(27,12,26,10,24,new Tr(14,new Ar(1,16))),new Pe(28,12,36,10,16,new Tr(18,new Ar(1,22))),new Pe(29,16,36,14,16,new Tr(24,new Ar(1,32))),new Pe(30,16,48,14,22,new Tr(28,new Ar(1,49)))]}}Pe.VERSIONS=Pe.buildVersions();class kt{constructor(o){const d=o.getHeight();if(d<8||d>144||(d&1)!==0)throw new H;this.version=kt.readVersion(o),this.mappingBitMatrix=this.extractDataRegion(o),this.readMappingMatrix=new Ce(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight())}getVersion(){return this.version}static readVersion(o){const d=o.getHeight(),f=o.getWidth();return Pe.getVersionForDimensions(d,f)}readCodewords(){const o=new Int8Array(this.version.getTotalCodewords());let d=0,f=4,p=0;const b=this.mappingBitMatrix.getHeight(),w=this.mappingBitMatrix.getWidth();let S=!1,R=!1,P=!1,X=!1;do if(f===b&&p===0&&!S)o[d++]=this.readCorner1(b,w)&255,f-=2,p+=2,S=!0;else if(f===b-2&&p===0&&(w&3)!==0&&!R)o[d++]=this.readCorner2(b,w)&255,f-=2,p+=2,R=!0;else if(f===b+4&&p===2&&(w&7)===0&&!P)o[d++]=this.readCorner3(b,w)&255,f-=2,p+=2,P=!0;else if(f===b-2&&p===0&&(w&7)===4&&!X)o[d++]=this.readCorner4(b,w)&255,f-=2,p+=2,X=!0;else{do f<b&&p>=0&&!this.readMappingMatrix.get(p,f)&&(o[d++]=this.readUtah(f,p,b,w)&255),f-=2,p+=2;while(f>=0&&p<w);f+=1,p+=3;do f>=0&&p<w&&!this.readMappingMatrix.get(p,f)&&(o[d++]=this.readUtah(f,p,b,w)&255),f+=2,p-=2;while(f<b&&p>=0);f+=3,p+=1}while(f<b||p<w);if(d!==this.version.getTotalCodewords())throw new H;return o}readModule(o,d,f,p){return o<0&&(o+=f,d+=4-(f+4&7)),d<0&&(d+=p,o+=4-(p+4&7)),this.readMappingMatrix.set(d,o),this.mappingBitMatrix.get(d,o)}readUtah(o,d,f,p){let b=0;return this.readModule(o-2,d-2,f,p)&&(b|=1),b<<=1,this.readModule(o-2,d-1,f,p)&&(b|=1),b<<=1,this.readModule(o-1,d-2,f,p)&&(b|=1),b<<=1,this.readModule(o-1,d-1,f,p)&&(b|=1),b<<=1,this.readModule(o-1,d,f,p)&&(b|=1),b<<=1,this.readModule(o,d-2,f,p)&&(b|=1),b<<=1,this.readModule(o,d-1,f,p)&&(b|=1),b<<=1,this.readModule(o,d,f,p)&&(b|=1),b}readCorner1(o,d){let f=0;return this.readModule(o-1,0,o,d)&&(f|=1),f<<=1,this.readModule(o-1,1,o,d)&&(f|=1),f<<=1,this.readModule(o-1,2,o,d)&&(f|=1),f<<=1,this.readModule(0,d-2,o,d)&&(f|=1),f<<=1,this.readModule(0,d-1,o,d)&&(f|=1),f<<=1,this.readModule(1,d-1,o,d)&&(f|=1),f<<=1,this.readModule(2,d-1,o,d)&&(f|=1),f<<=1,this.readModule(3,d-1,o,d)&&(f|=1),f}readCorner2(o,d){let f=0;return this.readModule(o-3,0,o,d)&&(f|=1),f<<=1,this.readModule(o-2,0,o,d)&&(f|=1),f<<=1,this.readModule(o-1,0,o,d)&&(f|=1),f<<=1,this.readModule(0,d-4,o,d)&&(f|=1),f<<=1,this.readModule(0,d-3,o,d)&&(f|=1),f<<=1,this.readModule(0,d-2,o,d)&&(f|=1),f<<=1,this.readModule(0,d-1,o,d)&&(f|=1),f<<=1,this.readModule(1,d-1,o,d)&&(f|=1),f}readCorner3(o,d){let f=0;return this.readModule(o-1,0,o,d)&&(f|=1),f<<=1,this.readModule(o-1,d-1,o,d)&&(f|=1),f<<=1,this.readModule(0,d-3,o,d)&&(f|=1),f<<=1,this.readModule(0,d-2,o,d)&&(f|=1),f<<=1,this.readModule(0,d-1,o,d)&&(f|=1),f<<=1,this.readModule(1,d-3,o,d)&&(f|=1),f<<=1,this.readModule(1,d-2,o,d)&&(f|=1),f<<=1,this.readModule(1,d-1,o,d)&&(f|=1),f}readCorner4(o,d){let f=0;return this.readModule(o-3,0,o,d)&&(f|=1),f<<=1,this.readModule(o-2,0,o,d)&&(f|=1),f<<=1,this.readModule(o-1,0,o,d)&&(f|=1),f<<=1,this.readModule(0,d-2,o,d)&&(f|=1),f<<=1,this.readModule(0,d-1,o,d)&&(f|=1),f<<=1,this.readModule(1,d-1,o,d)&&(f|=1),f<<=1,this.readModule(2,d-1,o,d)&&(f|=1),f<<=1,this.readModule(3,d-1,o,d)&&(f|=1),f}extractDataRegion(o){const d=this.version.getSymbolSizeRows(),f=this.version.getSymbolSizeColumns();if(o.getHeight()!==d)throw new N("Dimension of bitMatrix must match the version size");const p=this.version.getDataRegionSizeRows(),b=this.version.getDataRegionSizeColumns(),w=d/p|0,S=f/b|0,R=w*p,P=S*b,X=new Ce(P,R);for(let te=0;te<w;++te){const ue=te*p;for(let je=0;je<S;++je){const Fe=je*b;for(let Ue=0;Ue<p;++Ue){const tt=te*(p+2)+1+Ue,ut=ue+Ue;for(let Xt=0;Xt<b;++Xt){const Gt=je*(b+2)+1+Xt;if(o.get(Gt,tt)){const Ft=Fe+Xt;X.set(Ft,ut)}}}}}return X}}class Sr{constructor(o,d){this.numDataCodewords=o,this.codewords=d}static getDataBlocks(o,d){const f=d.getECBlocks();let p=0;const b=f.getECBlocks();for(let Ue of b)p+=Ue.getCount();const w=new Array(p);let S=0;for(let Ue of b)for(let tt=0;tt<Ue.getCount();tt++){const ut=Ue.getDataCodewords(),Xt=f.getECCodewords()+ut;w[S++]=new Sr(ut,new Uint8Array(Xt))}const P=w[0].codewords.length-f.getECCodewords(),X=P-1;let te=0;for(let Ue=0;Ue<X;Ue++)for(let tt=0;tt<S;tt++)w[tt].codewords[Ue]=o[te++];const ue=d.getVersionNumber()===24,je=ue?8:S;for(let Ue=0;Ue<je;Ue++)w[Ue].codewords[P-1]=o[te++];const Fe=w[0].codewords.length;for(let Ue=P;Ue<Fe;Ue++)for(let tt=0;tt<S;tt++){const ut=ue?(tt+8)%S:tt,Xt=ue&&ut>7?Ue-1:Ue;w[ut].codewords[Xt]=o[te++]}if(te!==o.length)throw new N;return w}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class la{constructor(o){this.bytes=o,this.byteOffset=0,this.bitOffset=0}getBitOffset(){return this.bitOffset}getByteOffset(){return this.byteOffset}readBits(o){if(o<1||o>32||o>this.available())throw new N(""+o);let d=0,f=this.bitOffset,p=this.byteOffset;const b=this.bytes;if(f>0){const w=8-f,S=o<w?o:w,R=w-S,P=255>>8-S<<R;d=(b[p]&P)>>R,o-=S,f+=S,f===8&&(f=0,p++)}if(o>0){for(;o>=8;)d=d<<8|b[p]&255,p++,o-=8;if(o>0){const w=8-o,S=255>>w<<w;d=d<<o|(b[p]&S)>>w,f+=o}}return this.bitOffset=f,this.byteOffset=p,d}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}var Dr;(function(ee){ee[ee.PAD_ENCODE=0]="PAD_ENCODE",ee[ee.ASCII_ENCODE=1]="ASCII_ENCODE",ee[ee.C40_ENCODE=2]="C40_ENCODE",ee[ee.TEXT_ENCODE=3]="TEXT_ENCODE",ee[ee.ANSIX12_ENCODE=4]="ANSIX12_ENCODE",ee[ee.EDIFACT_ENCODE=5]="EDIFACT_ENCODE",ee[ee.BASE256_ENCODE=6]="BASE256_ENCODE"})(Dr||(Dr={}));class Da{static decode(o){const d=new la(o),f=new ce,p=new ce,b=new Array;let w=Dr.ASCII_ENCODE;do if(w===Dr.ASCII_ENCODE)w=this.decodeAsciiSegment(d,f,p);else{switch(w){case Dr.C40_ENCODE:this.decodeC40Segment(d,f);break;case Dr.TEXT_ENCODE:this.decodeTextSegment(d,f);break;case Dr.ANSIX12_ENCODE:this.decodeAnsiX12Segment(d,f);break;case Dr.EDIFACT_ENCODE:this.decodeEdifactSegment(d,f);break;case Dr.BASE256_ENCODE:this.decodeBase256Segment(d,f,b);break;default:throw new H}w=Dr.ASCII_ENCODE}while(w!==Dr.PAD_ENCODE&&d.available()>0);return p.length()>0&&f.append(p.toString()),new ze(o,f.toString(),b.length===0?null:b,null)}static decodeAsciiSegment(o,d,f){let p=!1;do{let b=o.readBits(8);if(b===0)throw new H;if(b<=128)return p&&(b+=128),d.append(String.fromCharCode(b-1)),Dr.ASCII_ENCODE;if(b===129)return Dr.PAD_ENCODE;if(b<=229){const w=b-130;w<10&&d.append("0"),d.append(""+w)}else switch(b){case 230:return Dr.C40_ENCODE;case 231:return Dr.BASE256_ENCODE;case 232:d.append("");break;case 233:case 234:break;case 235:p=!0;break;case 236:d.append("[)>05"),f.insert(0,"");break;case 237:d.append("[)>06"),f.insert(0,"");break;case 238:return Dr.ANSIX12_ENCODE;case 239:return Dr.TEXT_ENCODE;case 240:return Dr.EDIFACT_ENCODE;case 241:break;default:if(b!==254||o.available()!==0)throw new H;break}}while(o.available()>0);return Dr.ASCII_ENCODE}static decodeC40Segment(o,d){let f=!1;const p=[];let b=0;do{if(o.available()===8)return;const w=o.readBits(8);if(w===254)return;this.parseTwoBytes(w,o.readBits(8),p);for(let S=0;S<3;S++){const R=p[S];switch(b){case 0:if(R<3)b=R+1;else if(R<this.C40_BASIC_SET_CHARS.length){const P=this.C40_BASIC_SET_CHARS[R];f?(d.append(String.fromCharCode(P.charCodeAt(0)+128)),f=!1):d.append(P)}else throw new H;break;case 1:f?(d.append(String.fromCharCode(R+128)),f=!1):d.append(String.fromCharCode(R)),b=0;break;case 2:if(R<this.C40_SHIFT2_SET_CHARS.length){const P=this.C40_SHIFT2_SET_CHARS[R];f?(d.append(String.fromCharCode(P.charCodeAt(0)+128)),f=!1):d.append(P)}else switch(R){case 27:d.append("");break;case 30:f=!0;break;default:throw new H}b=0;break;case 3:f?(d.append(String.fromCharCode(R+224)),f=!1):d.append(String.fromCharCode(R+96)),b=0;break;default:throw new H}}}while(o.available()>0)}static decodeTextSegment(o,d){let f=!1,p=[],b=0;do{if(o.available()===8)return;const w=o.readBits(8);if(w===254)return;this.parseTwoBytes(w,o.readBits(8),p);for(let S=0;S<3;S++){const R=p[S];switch(b){case 0:if(R<3)b=R+1;else if(R<this.TEXT_BASIC_SET_CHARS.length){const P=this.TEXT_BASIC_SET_CHARS[R];f?(d.append(String.fromCharCode(P.charCodeAt(0)+128)),f=!1):d.append(P)}else throw new H;break;case 1:f?(d.append(String.fromCharCode(R+128)),f=!1):d.append(String.fromCharCode(R)),b=0;break;case 2:if(R<this.TEXT_SHIFT2_SET_CHARS.length){const P=this.TEXT_SHIFT2_SET_CHARS[R];f?(d.append(String.fromCharCode(P.charCodeAt(0)+128)),f=!1):d.append(P)}else switch(R){case 27:d.append("");break;case 30:f=!0;break;default:throw new H}b=0;break;case 3:if(R<this.TEXT_SHIFT3_SET_CHARS.length){const P=this.TEXT_SHIFT3_SET_CHARS[R];f?(d.append(String.fromCharCode(P.charCodeAt(0)+128)),f=!1):d.append(P),b=0}else throw new H;break;default:throw new H}}}while(o.available()>0)}static decodeAnsiX12Segment(o,d){const f=[];do{if(o.available()===8)return;const p=o.readBits(8);if(p===254)return;this.parseTwoBytes(p,o.readBits(8),f);for(let b=0;b<3;b++){const w=f[b];switch(w){case 0:d.append("\r");break;case 1:d.append("*");break;case 2:d.append(">");break;case 3:d.append(" ");break;default:if(w<14)d.append(String.fromCharCode(w+44));else if(w<40)d.append(String.fromCharCode(w+51));else throw new H;break}}}while(o.available()>0)}static parseTwoBytes(o,d,f){let p=(o<<8)+d-1,b=Math.floor(p/1600);f[0]=b,p-=b*1600,b=Math.floor(p/40),f[1]=b,f[2]=p-b*40}static decodeEdifactSegment(o,d){do{if(o.available()<=16)return;for(let f=0;f<4;f++){let p=o.readBits(6);if(p===31){const b=8-o.getBitOffset();b!==8&&o.readBits(b);return}(p&32)===0&&(p|=64),d.append(String.fromCharCode(p))}}while(o.available()>0)}static decodeBase256Segment(o,d,f){let p=1+o.getByteOffset();const b=this.unrandomize255State(o.readBits(8),p++);let w;if(b===0?w=o.available()/8|0:b<250?w=b:w=250*(b-249)+this.unrandomize255State(o.readBits(8),p++),w<0)throw new H;const S=new Uint8Array(w);for(let R=0;R<w;R++){if(o.available()<8)throw new H;S[R]=this.unrandomize255State(o.readBits(8),p++)}f.push(S);try{d.append(oe.decode(S,se.ISO88591))}catch(R){throw new ar("Platform does not support required encoding: "+R.message)}}static unrandomize255State(o,d){const f=149*d%255+1,p=o-f;return p>=0?p:p+256}}Da.C40_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],Da.C40_SHIFT2_SET_CHARS=["!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_"],Da.TEXT_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],Da.TEXT_SHIFT2_SET_CHARS=Da.C40_SHIFT2_SET_CHARS,Da.TEXT_SHIFT3_SET_CHARS=["`","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","{","|","}","~",""];class Un{constructor(){this.rsDecoder=new or(mt.DATA_MATRIX_FIELD_256)}decode(o){const d=new kt(o),f=d.getVersion(),p=d.readCodewords(),b=Sr.getDataBlocks(p,f);let w=0;for(let P of b)w+=P.getNumDataCodewords();const S=new Uint8Array(w),R=b.length;for(let P=0;P<R;P++){const X=b[P],te=X.getCodewords(),ue=X.getNumDataCodewords();this.correctErrors(te,ue);for(let je=0;je<ue;je++)S[je*R+P]=te[je]}return Da.decode(S)}correctErrors(o,d){const f=new Int32Array(o);try{this.rsDecoder.decode(f,o.length-d)}catch(p){throw new O}for(let p=0;p<d;p++)o[p]=f[p]}}class hr{constructor(o){this.image=o,this.rectangleDetector=new it(this.image)}detect(){const o=this.rectangleDetector.detect();let d=this.detectSolid1(o);if(d=this.detectSolid2(d),d[3]=this.correctTopRight(d),!d[3])throw new ae;d=this.shiftToModuleCenter(d);const f=d[0],p=d[1],b=d[2],w=d[3];let S=this.transitionsBetween(f,w)+1,R=this.transitionsBetween(b,w)+1;(S&1)===1&&(S+=1),(R&1)===1&&(R+=1),4*S<7*R&&4*R<7*S&&(S=R=Math.max(S,R));let P=hr.sampleGrid(this.image,f,p,b,w,S,R);return new Br(P,[f,p,b,w])}static shiftPoint(o,d,f){let p=(d.getX()-o.getX())/(f+1),b=(d.getY()-o.getY())/(f+1);return new St(o.getX()+p,o.getY()+b)}static moveAway(o,d,f){let p=o.getX(),b=o.getY();return p<d?p-=1:p+=1,b<f?b-=1:b+=1,new St(p,b)}detectSolid1(o){let d=o[0],f=o[1],p=o[3],b=o[2],w=this.transitionsBetween(d,f),S=this.transitionsBetween(f,p),R=this.transitionsBetween(p,b),P=this.transitionsBetween(b,d),X=w,te=[b,d,f,p];return X>S&&(X=S,te[0]=d,te[1]=f,te[2]=p,te[3]=b),X>R&&(X=R,te[0]=f,te[1]=p,te[2]=b,te[3]=d),X>P&&(te[0]=p,te[1]=b,te[2]=d,te[3]=f),te}detectSolid2(o){let d=o[0],f=o[1],p=o[2],b=o[3],w=this.transitionsBetween(d,b),S=hr.shiftPoint(f,p,(w+1)*4),R=hr.shiftPoint(p,f,(w+1)*4),P=this.transitionsBetween(S,d),X=this.transitionsBetween(R,b);return P<X?(o[0]=d,o[1]=f,o[2]=p,o[3]=b):(o[0]=f,o[1]=p,o[2]=b,o[3]=d),o}correctTopRight(o){let d=o[0],f=o[1],p=o[2],b=o[3],w=this.transitionsBetween(d,b),S=this.transitionsBetween(f,b),R=hr.shiftPoint(d,f,(S+1)*4),P=hr.shiftPoint(p,f,(w+1)*4);w=this.transitionsBetween(R,b),S=this.transitionsBetween(P,b);let X=new St(b.getX()+(p.getX()-f.getX())/(w+1),b.getY()+(p.getY()-f.getY())/(w+1)),te=new St(b.getX()+(d.getX()-f.getX())/(S+1),b.getY()+(d.getY()-f.getY())/(S+1));if(!this.isValid(X))return this.isValid(te)?te:null;if(!this.isValid(te))return X;let ue=this.transitionsBetween(R,X)+this.transitionsBetween(P,X),je=this.transitionsBetween(R,te)+this.transitionsBetween(P,te);return ue>je?X:te}shiftToModuleCenter(o){let d=o[0],f=o[1],p=o[2],b=o[3],w=this.transitionsBetween(d,b)+1,S=this.transitionsBetween(p,b)+1,R=hr.shiftPoint(d,f,S*4),P=hr.shiftPoint(p,f,w*4);w=this.transitionsBetween(R,b)+1,S=this.transitionsBetween(P,b)+1,(w&1)===1&&(w+=1),(S&1)===1&&(S+=1);let X=(d.getX()+f.getX()+p.getX()+b.getX())/4,te=(d.getY()+f.getY()+p.getY()+b.getY())/4;d=hr.moveAway(d,X,te),f=hr.moveAway(f,X,te),p=hr.moveAway(p,X,te),b=hr.moveAway(b,X,te);let ue,je;return R=hr.shiftPoint(d,f,S*4),R=hr.shiftPoint(R,b,w*4),ue=hr.shiftPoint(f,d,S*4),ue=hr.shiftPoint(ue,p,w*4),P=hr.shiftPoint(p,b,S*4),P=hr.shiftPoint(P,f,w*4),je=hr.shiftPoint(b,p,S*4),je=hr.shiftPoint(je,d,w*4),[R,ue,P,je]}isValid(o){return o.getX()>=0&&o.getX()<this.image.getWidth()&&o.getY()>0&&o.getY()<this.image.getHeight()}static sampleGrid(o,d,f,p,b,w,S){return vt.getInstance().sampleGrid(o,w,S,.5,.5,w-.5,.5,w-.5,S-.5,.5,S-.5,d.getX(),d.getY(),b.getX(),b.getY(),p.getX(),p.getY(),f.getX(),f.getY())}transitionsBetween(o,d){let f=Math.trunc(o.getX()),p=Math.trunc(o.getY()),b=Math.trunc(d.getX()),w=Math.trunc(d.getY()),S=Math.abs(w-p)>Math.abs(b-f);if(S){let Ue=f;f=p,p=Ue,Ue=b,b=w,w=Ue}let R=Math.abs(b-f),P=Math.abs(w-p),X=-R/2,te=p<w?1:-1,ue=f<b?1:-1,je=0,Fe=this.image.get(S?p:f,S?f:p);for(let Ue=f,tt=p;Ue!==b;Ue+=ue){let ut=this.image.get(S?tt:Ue,S?Ue:tt);if(ut!==Fe&&(je++,Fe=ut),X+=P,X>0){if(tt===w)break;tt+=te,X-=R}}return je}}class Jr{constructor(){this.decoder=new Un}decode(o,d=null){let f,p;if(d!=null&&d.has(W.PURE_BARCODE)){const P=Jr.extractPureBits(o.getBlackMatrix());f=this.decoder.decode(P),p=Jr.NO_POINTS}else{const P=new hr(o.getBlackMatrix()).detect();f=this.decoder.decode(P.getBits()),p=P.getPoints()}const b=f.getRawBytes(),w=new re(f.getText(),b,8*b.length,p,ve.DATA_MATRIX,A.currentTimeMillis()),S=f.getByteSegments();S!=null&&w.putMetadata(Ae.BYTE_SEGMENTS,S);const R=f.getECLevel();return R!=null&&w.putMetadata(Ae.ERROR_CORRECTION_LEVEL,R),w}reset(){}static extractPureBits(o){const d=o.getTopLeftOnBit(),f=o.getBottomRightOnBit();if(d==null||f==null)throw new ae;const p=this.moduleSize(d,o);let b=d[1];const w=f[1];let S=d[0];const P=(f[0]-S+1)/p,X=(w-b+1)/p;if(P<=0||X<=0)throw new ae;const te=p/2;b+=te,S+=te;const ue=new Ce(P,X);for(let je=0;je<X;je++){const Fe=b+je*p;for(let Ue=0;Ue<P;Ue++)o.get(S+Ue*p,Fe)&&ue.set(Ue,je)}return ue}static moduleSize(o,d){const f=d.getWidth();let p=o[0];const b=o[1];for(;p<f&&d.get(p,b);)p++;if(p===f)throw new ae;const w=p-o[0];if(w===0)throw new ae;return w}}Jr.NO_POINTS=[];class Rs extends ie{constructor(o=500){super(new Jr,o)}}var _s;(function(ee){ee[ee.L=0]="L",ee[ee.M=1]="M",ee[ee.Q=2]="Q",ee[ee.H=3]="H"})(_s||(_s={}));class kr{constructor(o,d,f){this.value=o,this.stringValue=d,this.bits=f,kr.FOR_BITS.set(f,this),kr.FOR_VALUE.set(o,this)}getValue(){return this.value}getBits(){return this.bits}static fromString(o){switch(o){case"L":return kr.L;case"M":return kr.M;case"Q":return kr.Q;case"H":return kr.H;default:throw new k(o+"not available")}}toString(){return this.stringValue}equals(o){if(!(o instanceof kr))return!1;const d=o;return this.value===d.value}static forBits(o){if(o<0||o>=kr.FOR_BITS.size)throw new N;return kr.FOR_BITS.get(o)}}kr.FOR_BITS=new Map,kr.FOR_VALUE=new Map,kr.L=new kr(_s.L,"L",1),kr.M=new kr(_s.M,"M",0),kr.Q=new kr(_s.Q,"Q",3),kr.H=new kr(_s.H,"H",2);class sn{constructor(o){this.errorCorrectionLevel=kr.forBits(o>>3&3),this.dataMask=o&7}static numBitsDiffering(o,d){return B.bitCount(o^d)}static decodeFormatInformation(o,d){const f=sn.doDecodeFormatInformation(o,d);return f!==null?f:sn.doDecodeFormatInformation(o^sn.FORMAT_INFO_MASK_QR,d^sn.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(o,d){let f=Number.MAX_SAFE_INTEGER,p=0;for(const b of sn.FORMAT_INFO_DECODE_LOOKUP){const w=b[0];if(w===o||w===d)return new sn(b[1]);let S=sn.numBitsDiffering(o,w);S<f&&(p=b[1],f=S),o!==d&&(S=sn.numBitsDiffering(d,w),S<f&&(p=b[1],f=S))}return f<=3?new sn(p):null}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getDataMask(){return this.dataMask}hashCode(){return this.errorCorrectionLevel.getBits()<<3|this.dataMask}equals(o){if(!(o instanceof sn))return!1;const d=o;return this.errorCorrectionLevel===d.errorCorrectionLevel&&this.dataMask===d.dataMask}}sn.FORMAT_INFO_MASK_QR=21522,sn.FORMAT_INFO_DECODE_LOOKUP=[Int32Array.from([21522,0]),Int32Array.from([20773,1]),Int32Array.from([24188,2]),Int32Array.from([23371,3]),Int32Array.from([17913,4]),Int32Array.from([16590,5]),Int32Array.from([20375,6]),Int32Array.from([19104,7]),Int32Array.from([30660,8]),Int32Array.from([29427,9]),Int32Array.from([32170,10]),Int32Array.from([30877,11]),Int32Array.from([26159,12]),Int32Array.from([25368,13]),Int32Array.from([27713,14]),Int32Array.from([26998,15]),Int32Array.from([5769,16]),Int32Array.from([5054,17]),Int32Array.from([7399,18]),Int32Array.from([6608,19]),Int32Array.from([1890,20]),Int32Array.from([597,21]),Int32Array.from([3340,22]),Int32Array.from([2107,23]),Int32Array.from([13663,24]),Int32Array.from([12392,25]),Int32Array.from([16177,26]),Int32Array.from([14854,27]),Int32Array.from([9396,28]),Int32Array.from([8579,29]),Int32Array.from([11994,30]),Int32Array.from([11245,31])];class rt{constructor(o,...d){this.ecCodewordsPerBlock=o,this.ecBlocks=d}getECCodewordsPerBlock(){return this.ecCodewordsPerBlock}getNumBlocks(){let o=0;const d=this.ecBlocks;for(const f of d)o+=f.getCount();return o}getTotalECCodewords(){return this.ecCodewordsPerBlock*this.getNumBlocks()}getECBlocks(){return this.ecBlocks}}class Se{constructor(o,d){this.count=o,this.dataCodewords=d}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class sr{constructor(o,d,...f){this.versionNumber=o,this.alignmentPatternCenters=d,this.ecBlocks=f;let p=0;const b=f[0].getECCodewordsPerBlock(),w=f[0].getECBlocks();for(const S of w)p+=S.getCount()*(S.getDataCodewords()+b);this.totalCodewords=p}getVersionNumber(){return this.versionNumber}getAlignmentPatternCenters(){return this.alignmentPatternCenters}getTotalCodewords(){return this.totalCodewords}getDimensionForVersion(){return 17+4*this.versionNumber}getECBlocksForLevel(o){return this.ecBlocks[o.getValue()]}static getProvisionalVersionForDimension(o){if(o%4!==1)throw new H;try{return this.getVersionForNumber((o-17)/4)}catch(d){throw new H}}static getVersionForNumber(o){if(o<1||o>40)throw new N;return sr.VERSIONS[o-1]}static decodeVersionInformation(o){let d=Number.MAX_SAFE_INTEGER,f=0;for(let p=0;p<sr.VERSION_DECODE_INFO.length;p++){const b=sr.VERSION_DECODE_INFO[p];if(b===o)return sr.getVersionForNumber(p+7);const w=sn.numBitsDiffering(o,b);w<d&&(f=p+7,d=w)}return d<=3?sr.getVersionForNumber(f):null}buildFunctionPattern(){const o=this.getDimensionForVersion(),d=new Ce(o);d.setRegion(0,0,9,9),d.setRegion(o-8,0,8,9),d.setRegion(0,o-8,9,8);const f=this.alignmentPatternCenters.length;for(let p=0;p<f;p++){const b=this.alignmentPatternCenters[p]-2;for(let w=0;w<f;w++)p===0&&(w===0||w===f-1)||p===f-1&&w===0||d.setRegion(this.alignmentPatternCenters[w]-2,b,5,5)}return d.setRegion(6,9,1,o-17),d.setRegion(9,6,o-17,1),this.versionNumber>6&&(d.setRegion(o-11,0,3,6),d.setRegion(0,o-11,6,3)),d}toString(){return""+this.versionNumber}}sr.VERSION_DECODE_INFO=Int32Array.from([31892,34236,39577,42195,48118,51042,55367,58893,63784,68472,70749,76311,79154,84390,87683,92361,96236,102084,102881,110507,110734,117786,119615,126325,127568,133589,136944,141498,145311,150283,152622,158308,161089,167017]),sr.VERSIONS=[new sr(1,new Int32Array(0),new rt(7,new Se(1,19)),new rt(10,new Se(1,16)),new rt(13,new Se(1,13)),new rt(17,new Se(1,9))),new sr(2,Int32Array.from([6,18]),new rt(10,new Se(1,34)),new rt(16,new Se(1,28)),new rt(22,new Se(1,22)),new rt(28,new Se(1,16))),new sr(3,Int32Array.from([6,22]),new rt(15,new Se(1,55)),new rt(26,new Se(1,44)),new rt(18,new Se(2,17)),new rt(22,new Se(2,13))),new sr(4,Int32Array.from([6,26]),new rt(20,new Se(1,80)),new rt(18,new Se(2,32)),new rt(26,new Se(2,24)),new rt(16,new Se(4,9))),new sr(5,Int32Array.from([6,30]),new rt(26,new Se(1,108)),new rt(24,new Se(2,43)),new rt(18,new Se(2,15),new Se(2,16)),new rt(22,new Se(2,11),new Se(2,12))),new sr(6,Int32Array.from([6,34]),new rt(18,new Se(2,68)),new rt(16,new Se(4,27)),new rt(24,new Se(4,19)),new rt(28,new Se(4,15))),new sr(7,Int32Array.from([6,22,38]),new rt(20,new Se(2,78)),new rt(18,new Se(4,31)),new rt(18,new Se(2,14),new Se(4,15)),new rt(26,new Se(4,13),new Se(1,14))),new sr(8,Int32Array.from([6,24,42]),new rt(24,new Se(2,97)),new rt(22,new Se(2,38),new Se(2,39)),new rt(22,new Se(4,18),new Se(2,19)),new rt(26,new Se(4,14),new Se(2,15))),new sr(9,Int32Array.from([6,26,46]),new rt(30,new Se(2,116)),new rt(22,new Se(3,36),new Se(2,37)),new rt(20,new Se(4,16),new Se(4,17)),new rt(24,new Se(4,12),new Se(4,13))),new sr(10,Int32Array.from([6,28,50]),new rt(18,new Se(2,68),new Se(2,69)),new rt(26,new Se(4,43),new Se(1,44)),new rt(24,new Se(6,19),new Se(2,20)),new rt(28,new Se(6,15),new Se(2,16))),new sr(11,Int32Array.from([6,30,54]),new rt(20,new Se(4,81)),new rt(30,new Se(1,50),new Se(4,51)),new rt(28,new Se(4,22),new Se(4,23)),new rt(24,new Se(3,12),new Se(8,13))),new sr(12,Int32Array.from([6,32,58]),new rt(24,new Se(2,92),new Se(2,93)),new rt(22,new Se(6,36),new Se(2,37)),new rt(26,new Se(4,20),new Se(6,21)),new rt(28,new Se(7,14),new Se(4,15))),new sr(13,Int32Array.from([6,34,62]),new rt(26,new Se(4,107)),new rt(22,new Se(8,37),new Se(1,38)),new rt(24,new Se(8,20),new Se(4,21)),new rt(22,new Se(12,11),new Se(4,12))),new sr(14,Int32Array.from([6,26,46,66]),new rt(30,new Se(3,115),new Se(1,116)),new rt(24,new Se(4,40),new Se(5,41)),new rt(20,new Se(11,16),new Se(5,17)),new rt(24,new Se(11,12),new Se(5,13))),new sr(15,Int32Array.from([6,26,48,70]),new rt(22,new Se(5,87),new Se(1,88)),new rt(24,new Se(5,41),new Se(5,42)),new rt(30,new Se(5,24),new Se(7,25)),new rt(24,new Se(11,12),new Se(7,13))),new sr(16,Int32Array.from([6,26,50,74]),new rt(24,new Se(5,98),new Se(1,99)),new rt(28,new Se(7,45),new Se(3,46)),new rt(24,new Se(15,19),new Se(2,20)),new rt(30,new Se(3,15),new Se(13,16))),new sr(17,Int32Array.from([6,30,54,78]),new rt(28,new Se(1,107),new Se(5,108)),new rt(28,new Se(10,46),new Se(1,47)),new rt(28,new Se(1,22),new Se(15,23)),new rt(28,new Se(2,14),new Se(17,15))),new sr(18,Int32Array.from([6,30,56,82]),new rt(30,new Se(5,120),new Se(1,121)),new rt(26,new Se(9,43),new Se(4,44)),new rt(28,new Se(17,22),new Se(1,23)),new rt(28,new Se(2,14),new Se(19,15))),new sr(19,Int32Array.from([6,30,58,86]),new rt(28,new Se(3,113),new Se(4,114)),new rt(26,new Se(3,44),new Se(11,45)),new rt(26,new Se(17,21),new Se(4,22)),new rt(26,new Se(9,13),new Se(16,14))),new sr(20,Int32Array.from([6,34,62,90]),new rt(28,new Se(3,107),new Se(5,108)),new rt(26,new Se(3,41),new Se(13,42)),new rt(30,new Se(15,24),new Se(5,25)),new rt(28,new Se(15,15),new Se(10,16))),new sr(21,Int32Array.from([6,28,50,72,94]),new rt(28,new Se(4,116),new Se(4,117)),new rt(26,new Se(17,42)),new rt(28,new Se(17,22),new Se(6,23)),new rt(30,new Se(19,16),new Se(6,17))),new sr(22,Int32Array.from([6,26,50,74,98]),new rt(28,new Se(2,111),new Se(7,112)),new rt(28,new Se(17,46)),new rt(30,new Se(7,24),new Se(16,25)),new rt(24,new Se(34,13))),new sr(23,Int32Array.from([6,30,54,78,102]),new rt(30,new Se(4,121),new Se(5,122)),new rt(28,new Se(4,47),new Se(14,48)),new rt(30,new Se(11,24),new Se(14,25)),new rt(30,new Se(16,15),new Se(14,16))),new sr(24,Int32Array.from([6,28,54,80,106]),new rt(30,new Se(6,117),new Se(4,118)),new rt(28,new Se(6,45),new Se(14,46)),new rt(30,new Se(11,24),new Se(16,25)),new rt(30,new Se(30,16),new Se(2,17))),new sr(25,Int32Array.from([6,32,58,84,110]),new rt(26,new Se(8,106),new Se(4,107)),new rt(28,new Se(8,47),new Se(13,48)),new rt(30,new Se(7,24),new Se(22,25)),new rt(30,new Se(22,15),new Se(13,16))),new sr(26,Int32Array.from([6,30,58,86,114]),new rt(28,new Se(10,114),new Se(2,115)),new rt(28,new Se(19,46),new Se(4,47)),new rt(28,new Se(28,22),new Se(6,23)),new rt(30,new Se(33,16),new Se(4,17))),new sr(27,Int32Array.from([6,34,62,90,118]),new rt(30,new Se(8,122),new Se(4,123)),new rt(28,new Se(22,45),new Se(3,46)),new rt(30,new Se(8,23),new Se(26,24)),new rt(30,new Se(12,15),new Se(28,16))),new sr(28,Int32Array.from([6,26,50,74,98,122]),new rt(30,new Se(3,117),new Se(10,118)),new rt(28,new Se(3,45),new Se(23,46)),new rt(30,new Se(4,24),new Se(31,25)),new rt(30,new Se(11,15),new Se(31,16))),new sr(29,Int32Array.from([6,30,54,78,102,126]),new rt(30,new Se(7,116),new Se(7,117)),new rt(28,new Se(21,45),new Se(7,46)),new rt(30,new Se(1,23),new Se(37,24)),new rt(30,new Se(19,15),new Se(26,16))),new sr(30,Int32Array.from([6,26,52,78,104,130]),new rt(30,new Se(5,115),new Se(10,116)),new rt(28,new Se(19,47),new Se(10,48)),new rt(30,new Se(15,24),new Se(25,25)),new rt(30,new Se(23,15),new Se(25,16))),new sr(31,Int32Array.from([6,30,56,82,108,134]),new rt(30,new Se(13,115),new Se(3,116)),new rt(28,new Se(2,46),new Se(29,47)),new rt(30,new Se(42,24),new Se(1,25)),new rt(30,new Se(23,15),new Se(28,16))),new sr(32,Int32Array.from([6,34,60,86,112,138]),new rt(30,new Se(17,115)),new rt(28,new Se(10,46),new Se(23,47)),new rt(30,new Se(10,24),new Se(35,25)),new rt(30,new Se(19,15),new Se(35,16))),new sr(33,Int32Array.from([6,30,58,86,114,142]),new rt(30,new Se(17,115),new Se(1,116)),new rt(28,new Se(14,46),new Se(21,47)),new rt(30,new Se(29,24),new Se(19,25)),new rt(30,new Se(11,15),new Se(46,16))),new sr(34,Int32Array.from([6,34,62,90,118,146]),new rt(30,new Se(13,115),new Se(6,116)),new rt(28,new Se(14,46),new Se(23,47)),new rt(30,new Se(44,24),new Se(7,25)),new rt(30,new Se(59,16),new Se(1,17))),new sr(35,Int32Array.from([6,30,54,78,102,126,150]),new rt(30,new Se(12,121),new Se(7,122)),new rt(28,new Se(12,47),new Se(26,48)),new rt(30,new Se(39,24),new Se(14,25)),new rt(30,new Se(22,15),new Se(41,16))),new sr(36,Int32Array.from([6,24,50,76,102,128,154]),new rt(30,new Se(6,121),new Se(14,122)),new rt(28,new Se(6,47),new Se(34,48)),new rt(30,new Se(46,24),new Se(10,25)),new rt(30,new Se(2,15),new Se(64,16))),new sr(37,Int32Array.from([6,28,54,80,106,132,158]),new rt(30,new Se(17,122),new Se(4,123)),new rt(28,new Se(29,46),new Se(14,47)),new rt(30,new Se(49,24),new Se(10,25)),new rt(30,new Se(24,15),new Se(46,16))),new sr(38,Int32Array.from([6,32,58,84,110,136,162]),new rt(30,new Se(4,122),new Se(18,123)),new rt(28,new Se(13,46),new Se(32,47)),new rt(30,new Se(48,24),new Se(14,25)),new rt(30,new Se(42,15),new Se(32,16))),new sr(39,Int32Array.from([6,26,54,82,110,138,166]),new rt(30,new Se(20,117),new Se(4,118)),new rt(28,new Se(40,47),new Se(7,48)),new rt(30,new Se(43,24),new Se(22,25)),new rt(30,new Se(10,15),new Se(67,16))),new sr(40,Int32Array.from([6,30,58,86,114,142,170]),new rt(30,new Se(19,118),new Se(6,119)),new rt(28,new Se(18,47),new Se(31,48)),new rt(30,new Se(34,24),new Se(34,25)),new rt(30,new Se(20,15),new Se(61,16)))];var Ea;(function(ee){ee[ee.DATA_MASK_000=0]="DATA_MASK_000",ee[ee.DATA_MASK_001=1]="DATA_MASK_001",ee[ee.DATA_MASK_010=2]="DATA_MASK_010",ee[ee.DATA_MASK_011=3]="DATA_MASK_011",ee[ee.DATA_MASK_100=4]="DATA_MASK_100",ee[ee.DATA_MASK_101=5]="DATA_MASK_101",ee[ee.DATA_MASK_110=6]="DATA_MASK_110",ee[ee.DATA_MASK_111=7]="DATA_MASK_111"})(Ea||(Ea={}));class gn{constructor(o,d){this.value=o,this.isMasked=d}unmaskBitMatrix(o,d){for(let f=0;f<d;f++)for(let p=0;p<d;p++)this.isMasked(f,p)&&o.flip(p,f)}}gn.values=new Map([[Ea.DATA_MASK_000,new gn(Ea.DATA_MASK_000,(ee,o)=>(ee+o&1)===0)],[Ea.DATA_MASK_001,new gn(Ea.DATA_MASK_001,(ee,o)=>(ee&1)===0)],[Ea.DATA_MASK_010,new gn(Ea.DATA_MASK_010,(ee,o)=>o%3===0)],[Ea.DATA_MASK_011,new gn(Ea.DATA_MASK_011,(ee,o)=>(ee+o)%3===0)],[Ea.DATA_MASK_100,new gn(Ea.DATA_MASK_100,(ee,o)=>(Math.floor(ee/2)+Math.floor(o/3)&1)===0)],[Ea.DATA_MASK_101,new gn(Ea.DATA_MASK_101,(ee,o)=>ee*o%6===0)],[Ea.DATA_MASK_110,new gn(Ea.DATA_MASK_110,(ee,o)=>ee*o%6<3)],[Ea.DATA_MASK_111,new gn(Ea.DATA_MASK_111,(ee,o)=>(ee+o+ee*o%3&1)===0)]]);class Ms{constructor(o){const d=o.getHeight();if(d<21||(d&3)!==1)throw new H;this.bitMatrix=o}readFormatInformation(){if(this.parsedFormatInfo!==null&&this.parsedFormatInfo!==void 0)return this.parsedFormatInfo;let o=0;for(let b=0;b<6;b++)o=this.copyBit(b,8,o);o=this.copyBit(7,8,o),o=this.copyBit(8,8,o),o=this.copyBit(8,7,o);for(let b=5;b>=0;b--)o=this.copyBit(8,b,o);const d=this.bitMatrix.getHeight();let f=0;const p=d-7;for(let b=d-1;b>=p;b--)f=this.copyBit(8,b,f);for(let b=d-8;b<d;b++)f=this.copyBit(b,8,f);if(this.parsedFormatInfo=sn.decodeFormatInformation(o,f),this.parsedFormatInfo!==null)return this.parsedFormatInfo;throw new H}readVersion(){if(this.parsedVersion!==null&&this.parsedVersion!==void 0)return this.parsedVersion;const o=this.bitMatrix.getHeight(),d=Math.floor((o-17)/4);if(d<=6)return sr.getVersionForNumber(d);let f=0;const p=o-11;for(let w=5;w>=0;w--)for(let S=o-9;S>=p;S--)f=this.copyBit(S,w,f);let b=sr.decodeVersionInformation(f);if(b!==null&&b.getDimensionForVersion()===o)return this.parsedVersion=b,b;f=0;for(let w=5;w>=0;w--)for(let S=o-9;S>=p;S--)f=this.copyBit(w,S,f);if(b=sr.decodeVersionInformation(f),b!==null&&b.getDimensionForVersion()===o)return this.parsedVersion=b,b;throw new H}copyBit(o,d,f){return(this.isMirror?this.bitMatrix.get(d,o):this.bitMatrix.get(o,d))?f<<1|1:f<<1}readCodewords(){const o=this.readFormatInformation(),d=this.readVersion(),f=gn.values.get(o.getDataMask()),p=this.bitMatrix.getHeight();f.unmaskBitMatrix(this.bitMatrix,p);const b=d.buildFunctionPattern();let w=!0;const S=new Uint8Array(d.getTotalCodewords());let R=0,P=0,X=0;for(let te=p-1;te>0;te-=2){te===6&&te--;for(let ue=0;ue<p;ue++){const je=w?p-1-ue:ue;for(let Fe=0;Fe<2;Fe++)b.get(te-Fe,je)||(X++,P<<=1,this.bitMatrix.get(te-Fe,je)&&(P|=1),X===8&&(S[R++]=P,X=0,P=0))}w=!w}if(R!==d.getTotalCodewords())throw new H;return S}remask(){if(this.parsedFormatInfo===null)return;const o=gn.values[this.parsedFormatInfo.getDataMask()],d=this.bitMatrix.getHeight();o.unmaskBitMatrix(this.bitMatrix,d)}setMirror(o){this.parsedVersion=null,this.parsedFormatInfo=null,this.isMirror=o}mirror(){const o=this.bitMatrix;for(let d=0,f=o.getWidth();d<f;d++)for(let p=d+1,b=o.getHeight();p<b;p++)o.get(d,p)!==o.get(p,d)&&(o.flip(p,d),o.flip(d,p))}}class jo{constructor(o,d){this.numDataCodewords=o,this.codewords=d}static getDataBlocks(o,d,f){if(o.length!==d.getTotalCodewords())throw new N;const p=d.getECBlocksForLevel(f);let b=0;const w=p.getECBlocks();for(const Fe of w)b+=Fe.getCount();const S=new Array(b);let R=0;for(const Fe of w)for(let Ue=0;Ue<Fe.getCount();Ue++){const tt=Fe.getDataCodewords(),ut=p.getECCodewordsPerBlock()+tt;S[R++]=new jo(tt,new Uint8Array(ut))}const P=S[0].codewords.length;let X=S.length-1;for(;X>=0&&S[X].codewords.length!==P;)X--;X++;const te=P-p.getECCodewordsPerBlock();let ue=0;for(let Fe=0;Fe<te;Fe++)for(let Ue=0;Ue<R;Ue++)S[Ue].codewords[Fe]=o[ue++];for(let Fe=X;Fe<R;Fe++)S[Fe].codewords[te]=o[ue++];const je=S[0].codewords.length;for(let Fe=te;Fe<je;Fe++)for(let Ue=0;Ue<R;Ue++){const tt=Ue<X?Fe:Fe+1;S[Ue].codewords[tt]=o[ue++]}return S}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}var xn;(function(ee){ee[ee.TERMINATOR=0]="TERMINATOR",ee[ee.NUMERIC=1]="NUMERIC",ee[ee.ALPHANUMERIC=2]="ALPHANUMERIC",ee[ee.STRUCTURED_APPEND=3]="STRUCTURED_APPEND",ee[ee.BYTE=4]="BYTE",ee[ee.ECI=5]="ECI",ee[ee.KANJI=6]="KANJI",ee[ee.FNC1_FIRST_POSITION=7]="FNC1_FIRST_POSITION",ee[ee.FNC1_SECOND_POSITION=8]="FNC1_SECOND_POSITION",ee[ee.HANZI=9]="HANZI"})(xn||(xn={}));class Nr{constructor(o,d,f,p){this.value=o,this.stringValue=d,this.characterCountBitsForVersions=f,this.bits=p,Nr.FOR_BITS.set(p,this),Nr.FOR_VALUE.set(o,this)}static forBits(o){const d=Nr.FOR_BITS.get(o);if(d===void 0)throw new N;return d}getCharacterCountBits(o){const d=o.getVersionNumber();let f;return d<=9?f=0:d<=26?f=1:f=2,this.characterCountBitsForVersions[f]}getValue(){return this.value}getBits(){return this.bits}equals(o){if(!(o instanceof Nr))return!1;const d=o;return this.value===d.value}toString(){return this.stringValue}}Nr.FOR_BITS=new Map,Nr.FOR_VALUE=new Map,Nr.TERMINATOR=new Nr(xn.TERMINATOR,"TERMINATOR",Int32Array.from([0,0,0]),0),Nr.NUMERIC=new Nr(xn.NUMERIC,"NUMERIC",Int32Array.from([10,12,14]),1),Nr.ALPHANUMERIC=new Nr(xn.ALPHANUMERIC,"ALPHANUMERIC",Int32Array.from([9,11,13]),2),Nr.STRUCTURED_APPEND=new Nr(xn.STRUCTURED_APPEND,"STRUCTURED_APPEND",Int32Array.from([0,0,0]),3),Nr.BYTE=new Nr(xn.BYTE,"BYTE",Int32Array.from([8,16,16]),4),Nr.ECI=new Nr(xn.ECI,"ECI",Int32Array.from([0,0,0]),7),Nr.KANJI=new Nr(xn.KANJI,"KANJI",Int32Array.from([8,10,12]),8),Nr.FNC1_FIRST_POSITION=new Nr(xn.FNC1_FIRST_POSITION,"FNC1_FIRST_POSITION",Int32Array.from([0,0,0]),5),Nr.FNC1_SECOND_POSITION=new Nr(xn.FNC1_SECOND_POSITION,"FNC1_SECOND_POSITION",Int32Array.from([0,0,0]),9),Nr.HANZI=new Nr(xn.HANZI,"HANZI",Int32Array.from([8,10,12]),13);class _a{static decode(o,d,f,p){const b=new la(o);let w=new ce;const S=new Array;let R=-1,P=-1;try{let X=null,te=!1,ue;do{if(b.available()<4)ue=Nr.TERMINATOR;else{const je=b.readBits(4);ue=Nr.forBits(je)}switch(ue){case Nr.TERMINATOR:break;case Nr.FNC1_FIRST_POSITION:case Nr.FNC1_SECOND_POSITION:te=!0;break;case Nr.STRUCTURED_APPEND:if(b.available()<16)throw new H;R=b.readBits(8),P=b.readBits(8);break;case Nr.ECI:const je=_a.parseECIValue(b);if(X=Q.getCharacterSetECIByValue(je),X===null)throw new H;break;case Nr.HANZI:const Fe=b.readBits(4),Ue=b.readBits(ue.getCharacterCountBits(d));Fe===_a.GB2312_SUBSET&&_a.decodeHanziSegment(b,w,Ue);break;default:const tt=b.readBits(ue.getCharacterCountBits(d));switch(ue){case Nr.NUMERIC:_a.decodeNumericSegment(b,w,tt);break;case Nr.ALPHANUMERIC:_a.decodeAlphanumericSegment(b,w,tt,te);break;case Nr.BYTE:_a.decodeByteSegment(b,w,tt,X,S,p);break;case Nr.KANJI:_a.decodeKanjiSegment(b,w,tt);break;default:throw new H}break}}while(ue!==Nr.TERMINATOR)}catch(X){throw new H}return new ze(o,w.toString(),S.length===0?null:S,f===null?null:f.toString(),R,P)}static decodeHanziSegment(o,d,f){if(f*13>o.available())throw new H;const p=new Uint8Array(2*f);let b=0;for(;f>0;){const w=o.readBits(13);let S=w/96<<8&4294967295|w%96;S<959?S+=41377:S+=42657,p[b]=S>>8&255,p[b+1]=S&255,b+=2,f--}try{d.append(oe.decode(p,se.GB2312))}catch(w){throw new H(w)}}static decodeKanjiSegment(o,d,f){if(f*13>o.available())throw new H;const p=new Uint8Array(2*f);let b=0;for(;f>0;){const w=o.readBits(13);let S=w/192<<8&4294967295|w%192;S<7936?S+=33088:S+=49472,p[b]=S>>8,p[b+1]=S,b+=2,f--}try{d.append(oe.decode(p,se.SHIFT_JIS))}catch(w){throw new H(w)}}static decodeByteSegment(o,d,f,p,b,w){if(8*f>o.available())throw new H;const S=new Uint8Array(f);for(let P=0;P<f;P++)S[P]=o.readBits(8);let R;p===null?R=se.guessEncoding(S,w):R=p.getName();try{d.append(oe.decode(S,R))}catch(P){throw new H(P)}b.push(S)}static toAlphaNumericChar(o){if(o>=_a.ALPHANUMERIC_CHARS.length)throw new H;return _a.ALPHANUMERIC_CHARS[o]}static decodeAlphanumericSegment(o,d,f,p){const b=d.length();for(;f>1;){if(o.available()<11)throw new H;const w=o.readBits(11);d.append(_a.toAlphaNumericChar(Math.floor(w/45))),d.append(_a.toAlphaNumericChar(w%45)),f-=2}if(f===1){if(o.available()<6)throw new H;d.append(_a.toAlphaNumericChar(o.readBits(6)))}if(p)for(let w=b;w<d.length();w++)d.charAt(w)==="%"&&(w<d.length()-1&&d.charAt(w+1)==="%"?d.deleteCharAt(w+1):d.setCharAt(w,""))}static decodeNumericSegment(o,d,f){for(;f>=3;){if(o.available()<10)throw new H;const p=o.readBits(10);if(p>=1e3)throw new H;d.append(_a.toAlphaNumericChar(Math.floor(p/100))),d.append(_a.toAlphaNumericChar(Math.floor(p/10)%10)),d.append(_a.toAlphaNumericChar(p%10)),f-=3}if(f===2){if(o.available()<7)throw new H;const p=o.readBits(7);if(p>=100)throw new H;d.append(_a.toAlphaNumericChar(Math.floor(p/10))),d.append(_a.toAlphaNumericChar(p%10))}else if(f===1){if(o.available()<4)throw new H;const p=o.readBits(4);if(p>=10)throw new H;d.append(_a.toAlphaNumericChar(p))}}static parseECIValue(o){const d=o.readBits(8);if((d&128)===0)return d&127;if((d&192)===128){const f=o.readBits(8);return(d&63)<<8&4294967295|f}if((d&224)===192){const f=o.readBits(16);return(d&31)<<16&4294967295|f}throw new H}}_a.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",_a.GB2312_SUBSET=1;class To{constructor(o){this.mirrored=o}isMirrored(){return this.mirrored}applyMirroredCorrection(o){if(!this.mirrored||o===null||o.length<3)return;const d=o[0];o[0]=o[2],o[2]=d}}class Jl{constructor(){this.rsDecoder=new or(mt.QR_CODE_FIELD_256)}decodeBooleanArray(o,d){return this.decodeBitMatrix(Ce.parseFromBooleanArray(o),d)}decodeBitMatrix(o,d){const f=new Ms(o);let p=null;try{return this.decodeBitMatrixParser(f,d)}catch(b){p=b}try{f.remask(),f.setMirror(!0),f.readVersion(),f.readFormatInformation(),f.mirror();const b=this.decodeBitMatrixParser(f,d);return b.setOther(new To(!0)),b}catch(b){throw p!==null?p:b}}decodeBitMatrixParser(o,d){const f=o.readVersion(),p=o.readFormatInformation().getErrorCorrectionLevel(),b=o.readCodewords(),w=jo.getDataBlocks(b,f,p);let S=0;for(const X of w)S+=X.getNumDataCodewords();const R=new Uint8Array(S);let P=0;for(const X of w){const te=X.getCodewords(),ue=X.getNumDataCodewords();this.correctErrors(te,ue);for(let je=0;je<ue;je++)R[P++]=te[je]}return _a.decode(R,f,p,d)}correctErrors(o,d){const f=new Int32Array(o);try{this.rsDecoder.decode(f,o.length-d)}catch(p){throw new O}for(let p=0;p<d;p++)o[p]=f[p]}}class vi extends St{constructor(o,d,f){super(o,d),this.estimatedModuleSize=f}aboutEquals(o,d,f){if(Math.abs(d-this.getY())<=o&&Math.abs(f-this.getX())<=o){const p=Math.abs(o-this.estimatedModuleSize);return p<=1||p<=this.estimatedModuleSize}return!1}combineEstimate(o,d,f){const p=(this.getX()+d)/2,b=(this.getY()+o)/2,w=(this.estimatedModuleSize+f)/2;return new vi(p,b,w)}}class On{constructor(o,d,f,p,b,w,S){this.image=o,this.startX=d,this.startY=f,this.width=p,this.height=b,this.moduleSize=w,this.resultPointCallback=S,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(3)}find(){const o=this.startX,d=this.height,f=this.width,p=o+f,b=this.startY+d/2,w=new Int32Array(3),S=this.image;for(let R=0;R<d;R++){const P=b+((R&1)===0?Math.floor((R+1)/2):-Math.floor((R+1)/2));w[0]=0,w[1]=0,w[2]=0;let X=o;for(;X<p&&!S.get(X,P);)X++;let te=0;for(;X<p;){if(S.get(X,P))if(te===1)w[1]++;else if(te===2){if(this.foundPatternCross(w)){const ue=this.handlePossibleCenter(w,P,X);if(ue!==null)return ue}w[0]=w[2],w[1]=1,w[2]=0,te=1}else w[++te]++;else te===1&&te++,w[te]++;X++}if(this.foundPatternCross(w)){const ue=this.handlePossibleCenter(w,P,p);if(ue!==null)return ue}}if(this.possibleCenters.length!==0)return this.possibleCenters[0];throw new ae}static centerFromEnd(o,d){return d-o[2]-o[1]/2}foundPatternCross(o){const d=this.moduleSize,f=d/2;for(let p=0;p<3;p++)if(Math.abs(d-o[p])>=f)return!1;return!0}crossCheckVertical(o,d,f,p){const b=this.image,w=b.getHeight(),S=this.crossCheckStateCount;S[0]=0,S[1]=0,S[2]=0;let R=o;for(;R>=0&&b.get(d,R)&&S[1]<=f;)S[1]++,R--;if(R<0||S[1]>f)return NaN;for(;R>=0&&!b.get(d,R)&&S[0]<=f;)S[0]++,R--;if(S[0]>f)return NaN;for(R=o+1;R<w&&b.get(d,R)&&S[1]<=f;)S[1]++,R++;if(R===w||S[1]>f)return NaN;for(;R<w&&!b.get(d,R)&&S[2]<=f;)S[2]++,R++;if(S[2]>f)return NaN;const P=S[0]+S[1]+S[2];return 5*Math.abs(P-p)>=2*p?NaN:this.foundPatternCross(S)?On.centerFromEnd(S,R):NaN}handlePossibleCenter(o,d,f){const p=o[0]+o[1]+o[2],b=On.centerFromEnd(o,f),w=this.crossCheckVertical(d,b,2*o[1],p);if(!isNaN(w)){const S=(o[0]+o[1]+o[2])/3;for(const P of this.possibleCenters)if(P.aboutEquals(S,w,b))return P.combineEstimate(w,b,S);const R=new vi(b,w,S);this.possibleCenters.push(R),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(R)}return null}}class so extends St{constructor(o,d,f,p){super(o,d),this.estimatedModuleSize=f,this.count=p,p===void 0&&(this.count=1)}getEstimatedModuleSize(){return this.estimatedModuleSize}getCount(){return this.count}aboutEquals(o,d,f){if(Math.abs(d-this.getY())<=o&&Math.abs(f-this.getX())<=o){const p=Math.abs(o-this.estimatedModuleSize);return p<=1||p<=this.estimatedModuleSize}return!1}combineEstimate(o,d,f){const p=this.count+1,b=(this.count*this.getX()+d)/p,w=(this.count*this.getY()+o)/p,S=(this.count*this.estimatedModuleSize+f)/p;return new so(b,w,S,p)}}class Ao{constructor(o){this.bottomLeft=o[0],this.topLeft=o[1],this.topRight=o[2]}getBottomLeft(){return this.bottomLeft}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}}class za{constructor(o,d){this.image=o,this.resultPointCallback=d,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(5),this.resultPointCallback=d}getImage(){return this.image}getPossibleCenters(){return this.possibleCenters}find(o){const d=o!=null&&o.get(W.TRY_HARDER)!==void 0,f=o!=null&&o.get(W.PURE_BARCODE)!==void 0,p=this.image,b=p.getHeight(),w=p.getWidth();let S=Math.floor(3*b/(4*za.MAX_MODULES));(S<za.MIN_SKIP||d)&&(S=za.MIN_SKIP);let R=!1;const P=new Int32Array(5);for(let te=S-1;te<b&&!R;te+=S){P[0]=0,P[1]=0,P[2]=0,P[3]=0,P[4]=0;let ue=0;for(let je=0;je<w;je++)if(p.get(je,te))(ue&1)===1&&ue++,P[ue]++;else if((ue&1)===0)if(ue===4)if(za.foundPatternCross(P)){if(this.handlePossibleCenter(P,te,je,f)===!0)if(S=2,this.hasSkipped===!0)R=this.haveMultiplyConfirmedCenters();else{const Ue=this.findRowSkip();Ue>P[2]&&(te+=Ue-P[2]-S,je=w-1)}else{P[0]=P[2],P[1]=P[3],P[2]=P[4],P[3]=1,P[4]=0,ue=3;continue}ue=0,P[0]=0,P[1]=0,P[2]=0,P[3]=0,P[4]=0}else P[0]=P[2],P[1]=P[3],P[2]=P[4],P[3]=1,P[4]=0,ue=3;else P[++ue]++;else P[ue]++;za.foundPatternCross(P)&&this.handlePossibleCenter(P,te,w,f)===!0&&(S=P[0],this.hasSkipped&&(R=this.haveMultiplyConfirmedCenters()))}const X=this.selectBestPatterns();return St.orderBestPatterns(X),new Ao(X)}static centerFromEnd(o,d){return d-o[4]-o[3]-o[2]/2}static foundPatternCross(o){let d=0;for(let b=0;b<5;b++){const w=o[b];if(w===0)return!1;d+=w}if(d<7)return!1;const f=d/7,p=f/2;return Math.abs(f-o[0])<p&&Math.abs(f-o[1])<p&&Math.abs(3*f-o[2])<3*p&&Math.abs(f-o[3])<p&&Math.abs(f-o[4])<p}getCrossCheckStateCount(){const o=this.crossCheckStateCount;return o[0]=0,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o}crossCheckDiagonal(o,d,f,p){const b=this.getCrossCheckStateCount();let w=0;const S=this.image;for(;o>=w&&d>=w&&S.get(d-w,o-w);)b[2]++,w++;if(o<w||d<w)return!1;for(;o>=w&&d>=w&&!S.get(d-w,o-w)&&b[1]<=f;)b[1]++,w++;if(o<w||d<w||b[1]>f)return!1;for(;o>=w&&d>=w&&S.get(d-w,o-w)&&b[0]<=f;)b[0]++,w++;if(b[0]>f)return!1;const R=S.getHeight(),P=S.getWidth();for(w=1;o+w<R&&d+w<P&&S.get(d+w,o+w);)b[2]++,w++;if(o+w>=R||d+w>=P)return!1;for(;o+w<R&&d+w<P&&!S.get(d+w,o+w)&&b[3]<f;)b[3]++,w++;if(o+w>=R||d+w>=P||b[3]>=f)return!1;for(;o+w<R&&d+w<P&&S.get(d+w,o+w)&&b[4]<f;)b[4]++,w++;if(b[4]>=f)return!1;const X=b[0]+b[1]+b[2]+b[3]+b[4];return Math.abs(X-p)<2*p&&za.foundPatternCross(b)}crossCheckVertical(o,d,f,p){const b=this.image,w=b.getHeight(),S=this.getCrossCheckStateCount();let R=o;for(;R>=0&&b.get(d,R);)S[2]++,R--;if(R<0)return NaN;for(;R>=0&&!b.get(d,R)&&S[1]<=f;)S[1]++,R--;if(R<0||S[1]>f)return NaN;for(;R>=0&&b.get(d,R)&&S[0]<=f;)S[0]++,R--;if(S[0]>f)return NaN;for(R=o+1;R<w&&b.get(d,R);)S[2]++,R++;if(R===w)return NaN;for(;R<w&&!b.get(d,R)&&S[3]<f;)S[3]++,R++;if(R===w||S[3]>=f)return NaN;for(;R<w&&b.get(d,R)&&S[4]<f;)S[4]++,R++;if(S[4]>=f)return NaN;const P=S[0]+S[1]+S[2]+S[3]+S[4];return 5*Math.abs(P-p)>=2*p?NaN:za.foundPatternCross(S)?za.centerFromEnd(S,R):NaN}crossCheckHorizontal(o,d,f,p){const b=this.image,w=b.getWidth(),S=this.getCrossCheckStateCount();let R=o;for(;R>=0&&b.get(R,d);)S[2]++,R--;if(R<0)return NaN;for(;R>=0&&!b.get(R,d)&&S[1]<=f;)S[1]++,R--;if(R<0||S[1]>f)return NaN;for(;R>=0&&b.get(R,d)&&S[0]<=f;)S[0]++,R--;if(S[0]>f)return NaN;for(R=o+1;R<w&&b.get(R,d);)S[2]++,R++;if(R===w)return NaN;for(;R<w&&!b.get(R,d)&&S[3]<f;)S[3]++,R++;if(R===w||S[3]>=f)return NaN;for(;R<w&&b.get(R,d)&&S[4]<f;)S[4]++,R++;if(S[4]>=f)return NaN;const P=S[0]+S[1]+S[2]+S[3]+S[4];return 5*Math.abs(P-p)>=p?NaN:za.foundPatternCross(S)?za.centerFromEnd(S,R):NaN}handlePossibleCenter(o,d,f,p){const b=o[0]+o[1]+o[2]+o[3]+o[4];let w=za.centerFromEnd(o,f),S=this.crossCheckVertical(d,Math.floor(w),o[2],b);if(!isNaN(S)&&(w=this.crossCheckHorizontal(Math.floor(w),Math.floor(S),o[2],b),!isNaN(w)&&(!p||this.crossCheckDiagonal(Math.floor(S),Math.floor(w),o[2],b)))){const R=b/7;let P=!1;const X=this.possibleCenters;for(let te=0,ue=X.length;te<ue;te++){const je=X[te];if(je.aboutEquals(R,S,w)){X[te]=je.combineEstimate(S,w,R),P=!0;break}}if(!P){const te=new so(w,S,R);X.push(te),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(te)}return!0}return!1}findRowSkip(){if(this.possibleCenters.length<=1)return 0;let d=null;for(const f of this.possibleCenters)if(f.getCount()>=za.CENTER_QUORUM)if(d==null)d=f;else return this.hasSkipped=!0,Math.floor((Math.abs(d.getX()-f.getX())-Math.abs(d.getY()-f.getY()))/2);return 0}haveMultiplyConfirmedCenters(){let o=0,d=0;const f=this.possibleCenters.length;for(const w of this.possibleCenters)w.getCount()>=za.CENTER_QUORUM&&(o++,d+=w.getEstimatedModuleSize());if(o<3)return!1;const p=d/f;let b=0;for(const w of this.possibleCenters)b+=Math.abs(w.getEstimatedModuleSize()-p);return b<=.05*d}selectBestPatterns(){const o=this.possibleCenters.length;if(o<3)throw new ae;const d=this.possibleCenters;let f;if(o>3){let p=0,b=0;for(const R of this.possibleCenters){const P=R.getEstimatedModuleSize();p+=P,b+=P*P}f=p/o;let w=Math.sqrt(b/o-f*f);d.sort((R,P)=>{const X=Math.abs(P.getEstimatedModuleSize()-f),te=Math.abs(R.getEstimatedModuleSize()-f);return X<te?-1:X>te?1:0});const S=Math.max(.2*f,w);for(let R=0;R<d.length&&d.length>3;R++){const P=d[R];Math.abs(P.getEstimatedModuleSize()-f)>S&&(d.splice(R,1),R--)}}if(d.length>3){let p=0;for(const b of d)p+=b.getEstimatedModuleSize();f=p/d.length,d.sort((b,w)=>{if(w.getCount()===b.getCount()){const S=Math.abs(w.getEstimatedModuleSize()-f),R=Math.abs(b.getEstimatedModuleSize()-f);return S<R?1:S>R?-1:0}else return w.getCount()-b.getCount()}),d.splice(3)}return[d[0],d[1],d[2]]}}za.CENTER_QUORUM=2,za.MIN_SKIP=3,za.MAX_MODULES=57;class Rr{constructor(o){this.image=o}getImage(){return this.image}getResultPointCallback(){return this.resultPointCallback}detect(o){this.resultPointCallback=o==null?null:o.get(W.NEED_RESULT_POINT_CALLBACK);const f=new za(this.image,this.resultPointCallback).find(o);return this.processFinderPatternInfo(f)}processFinderPatternInfo(o){const d=o.getTopLeft(),f=o.getTopRight(),p=o.getBottomLeft(),b=this.calculateModuleSize(d,f,p);if(b<1)throw new ae("No pattern found in proccess finder.");const w=Rr.computeDimension(d,f,p,b),S=sr.getProvisionalVersionForDimension(w),R=S.getDimensionForVersion()-7;let P=null;if(S.getAlignmentPatternCenters().length>0){const je=f.getX()-d.getX()+p.getX(),Fe=f.getY()-d.getY()+p.getY(),Ue=1-3/R,tt=Math.floor(d.getX()+Ue*(je-d.getX())),ut=Math.floor(d.getY()+Ue*(Fe-d.getY()));for(let Xt=4;Xt<=16;Xt<<=1)try{P=this.findAlignmentInRegion(b,tt,ut,Xt);break}catch(Gt){if(!(Gt instanceof ae))throw Gt}}const X=Rr.createTransform(d,f,p,P,w),te=Rr.sampleGrid(this.image,X,w);let ue;return P===null?ue=[p,d,f]:ue=[p,d,f,P],new Br(te,ue)}static createTransform(o,d,f,p,b){const w=b-3.5;let S,R,P,X;return p!==null?(S=p.getX(),R=p.getY(),P=w-3,X=P):(S=d.getX()-o.getX()+f.getX(),R=d.getY()-o.getY()+f.getY(),P=w,X=w),Je.quadrilateralToQuadrilateral(3.5,3.5,w,3.5,P,X,3.5,w,o.getX(),o.getY(),d.getX(),d.getY(),S,R,f.getX(),f.getY())}static sampleGrid(o,d,f){return vt.getInstance().sampleGridWithTransform(o,f,f,d)}static computeDimension(o,d,f,p){const b=$t.round(St.distance(o,d)/p),w=$t.round(St.distance(o,f)/p);let S=Math.floor((b+w)/2)+7;switch(S&3){case 0:S++;break;case 2:S--;break;case 3:throw new ae("Dimensions could be not found.")}return S}calculateModuleSize(o,d,f){return(this.calculateModuleSizeOneWay(o,d)+this.calculateModuleSizeOneWay(o,f))/2}calculateModuleSizeOneWay(o,d){const f=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(o.getX()),Math.floor(o.getY()),Math.floor(d.getX()),Math.floor(d.getY())),p=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(d.getX()),Math.floor(d.getY()),Math.floor(o.getX()),Math.floor(o.getY()));return isNaN(f)?p/7:isNaN(p)?f/7:(f+p)/14}sizeOfBlackWhiteBlackRunBothWays(o,d,f,p){let b=this.sizeOfBlackWhiteBlackRun(o,d,f,p),w=1,S=o-(f-o);S<0?(w=o/(o-S),S=0):S>=this.image.getWidth()&&(w=(this.image.getWidth()-1-o)/(S-o),S=this.image.getWidth()-1);let R=Math.floor(d-(p-d)*w);return w=1,R<0?(w=d/(d-R),R=0):R>=this.image.getHeight()&&(w=(this.image.getHeight()-1-d)/(R-d),R=this.image.getHeight()-1),S=Math.floor(o+(S-o)*w),b+=this.sizeOfBlackWhiteBlackRun(o,d,S,R),b-1}sizeOfBlackWhiteBlackRun(o,d,f,p){const b=Math.abs(p-d)>Math.abs(f-o);if(b){let je=o;o=d,d=je,je=f,f=p,p=je}const w=Math.abs(f-o),S=Math.abs(p-d);let R=-w/2;const P=o<f?1:-1,X=d<p?1:-1;let te=0;const ue=f+P;for(let je=o,Fe=d;je!==ue;je+=P){const Ue=b?Fe:je,tt=b?je:Fe;if(te===1===this.image.get(Ue,tt)){if(te===2)return $t.distance(je,Fe,o,d);te++}if(R+=S,R>0){if(Fe===p)break;Fe+=X,R-=w}}return te===2?$t.distance(f+P,p,o,d):NaN}findAlignmentInRegion(o,d,f,p){const b=Math.floor(p*o),w=Math.max(0,d-b),S=Math.min(this.image.getWidth()-1,d+b);if(S-w<o*3)throw new ae("Alignment top exceeds estimated module size.");const R=Math.max(0,f-b),P=Math.min(this.image.getHeight()-1,f+b);if(P-R<o*3)throw new ae("Alignment bottom exceeds estimated module size.");return new On(this.image,w,R,S-w,P-R,o,this.resultPointCallback).find()}}class on{constructor(){this.decoder=new Jl}getDecoder(){return this.decoder}decode(o,d){let f,p;if(d!=null&&d.get(W.PURE_BARCODE)!==void 0){const R=on.extractPureBits(o.getBlackMatrix());f=this.decoder.decodeBitMatrix(R,d),p=on.NO_POINTS}else{const R=new Rr(o.getBlackMatrix()).detect(d);f=this.decoder.decodeBitMatrix(R.getBits(),d),p=R.getPoints()}f.getOther()instanceof To&&f.getOther().applyMirroredCorrection(p);const b=new re(f.getText(),f.getRawBytes(),void 0,p,ve.QR_CODE,void 0),w=f.getByteSegments();w!==null&&b.putMetadata(Ae.BYTE_SEGMENTS,w);const S=f.getECLevel();return S!==null&&b.putMetadata(Ae.ERROR_CORRECTION_LEVEL,S),f.hasStructuredAppend()&&(b.putMetadata(Ae.STRUCTURED_APPEND_SEQUENCE,f.getStructuredAppendSequenceNumber()),b.putMetadata(Ae.STRUCTURED_APPEND_PARITY,f.getStructuredAppendParity())),b}reset(){}static extractPureBits(o){const d=o.getTopLeftOnBit(),f=o.getBottomRightOnBit();if(d===null||f===null)throw new ae;const p=this.moduleSize(d,o);let b=d[1],w=f[1],S=d[0],R=f[0];if(S>=R||b>=w)throw new ae;if(w-b!==R-S&&(R=S+(w-b),R>=o.getWidth()))throw new ae;const P=Math.round((R-S+1)/p),X=Math.round((w-b+1)/p);if(P<=0||X<=0)throw new ae;if(X!==P)throw new ae;const te=Math.floor(p/2);b+=te,S+=te;const ue=S+Math.floor((P-1)*p)-R;if(ue>0){if(ue>te)throw new ae;S-=ue}const je=b+Math.floor((X-1)*p)-w;if(je>0){if(je>te)throw new ae;b-=je}const Fe=new Ce(P,X);for(let Ue=0;Ue<X;Ue++){const tt=b+Math.floor(Ue*p);for(let ut=0;ut<P;ut++)o.get(S+Math.floor(ut*p),tt)&&Fe.set(ut,Ue)}return Fe}static moduleSize(o,d){const f=d.getHeight(),p=d.getWidth();let b=o[0],w=o[1],S=!0,R=0;for(;b<p&&w<f;){if(S!==d.get(b,w)){if(++R===5)break;S=!S}b++,w++}if(b===p||w===f)throw new ae;return(b-o[0])/7}}on.NO_POINTS=new Array;class cr{PDF417Common(){}static getBitCountSum(o){return $t.sum(o)}static toIntArray(o){if(o==null||!o.length)return cr.EMPTY_INT_ARRAY;const d=new Int32Array(o.length);let f=0;for(const p of o)d[f++]=p;return d}static getCodeword(o){const d=U.binarySearch(cr.SYMBOL_TABLE,o&262143);return d<0?-1:(cr.CODEWORD_TABLE[d]-1)%cr.NUMBER_OF_CODEWORDS}}cr.NUMBER_OF_CODEWORDS=929,cr.MAX_CODEWORDS_IN_BARCODE=cr.NUMBER_OF_CODEWORDS-1,cr.MIN_ROWS_IN_BARCODE=3,cr.MAX_ROWS_IN_BARCODE=90,cr.MODULES_IN_CODEWORD=17,cr.MODULES_IN_STOP_PATTERN=18,cr.BARS_IN_MODULE=8,cr.EMPTY_INT_ARRAY=new Int32Array([]),cr.SYMBOL_TABLE=Int32Array.from([66142,66170,66206,66236,66290,66292,66350,66382,66396,66454,66470,66476,66594,66600,66614,66626,66628,66632,66640,66654,66662,66668,66682,66690,66718,66720,66748,66758,66776,66798,66802,66804,66820,66824,66832,66846,66848,66876,66880,66936,66950,66956,66968,66992,67006,67022,67036,67042,67044,67048,67062,67118,67150,67164,67214,67228,67256,67294,67322,67350,67366,67372,67398,67404,67416,67438,67474,67476,67490,67492,67496,67510,67618,67624,67650,67656,67664,67678,67686,67692,67706,67714,67716,67728,67742,67744,67772,67782,67788,67800,67822,67826,67828,67842,67848,67870,67872,67900,67904,67960,67974,67992,68016,68030,68046,68060,68066,68068,68072,68086,68104,68112,68126,68128,68156,68160,68216,68336,68358,68364,68376,68400,68414,68448,68476,68494,68508,68536,68546,68548,68552,68560,68574,68582,68588,68654,68686,68700,68706,68708,68712,68726,68750,68764,68792,68802,68804,68808,68816,68830,68838,68844,68858,68878,68892,68920,68976,68990,68994,68996,69e3,69008,69022,69024,69052,69062,69068,69080,69102,69106,69108,69142,69158,69164,69190,69208,69230,69254,69260,69272,69296,69310,69326,69340,69386,69394,69396,69410,69416,69430,69442,69444,69448,69456,69470,69478,69484,69554,69556,69666,69672,69698,69704,69712,69726,69754,69762,69764,69776,69790,69792,69820,69830,69836,69848,69870,69874,69876,69890,69918,69920,69948,69952,70008,70022,70040,70064,70078,70094,70108,70114,70116,70120,70134,70152,70174,70176,70264,70384,70412,70448,70462,70496,70524,70542,70556,70584,70594,70600,70608,70622,70630,70636,70664,70672,70686,70688,70716,70720,70776,70896,71136,71180,71192,71216,71230,71264,71292,71360,71416,71452,71480,71536,71550,71554,71556,71560,71568,71582,71584,71612,71622,71628,71640,71662,71726,71732,71758,71772,71778,71780,71784,71798,71822,71836,71864,71874,71880,71888,71902,71910,71916,71930,71950,71964,71992,72048,72062,72066,72068,72080,72094,72096,72124,72134,72140,72152,72174,72178,72180,72206,72220,72248,72304,72318,72416,72444,72456,72464,72478,72480,72508,72512,72568,72588,72600,72624,72638,72654,72668,72674,72676,72680,72694,72726,72742,72748,72774,72780,72792,72814,72838,72856,72880,72894,72910,72924,72930,72932,72936,72950,72966,72972,72984,73008,73022,73056,73084,73102,73116,73144,73156,73160,73168,73182,73190,73196,73210,73226,73234,73236,73250,73252,73256,73270,73282,73284,73296,73310,73318,73324,73346,73348,73352,73360,73374,73376,73404,73414,73420,73432,73454,73498,73518,73522,73524,73550,73564,73570,73572,73576,73590,73800,73822,73858,73860,73872,73886,73888,73916,73944,73970,73972,73992,74014,74016,74044,74048,74104,74118,74136,74160,74174,74210,74212,74216,74230,74244,74256,74270,74272,74360,74480,74502,74508,74544,74558,74592,74620,74638,74652,74680,74690,74696,74704,74726,74732,74782,74784,74812,74992,75232,75288,75326,75360,75388,75456,75512,75576,75632,75646,75650,75652,75664,75678,75680,75708,75718,75724,75736,75758,75808,75836,75840,75896,76016,76256,76736,76824,76848,76862,76896,76924,76992,77048,77296,77340,77368,77424,77438,77536,77564,77572,77576,77584,77600,77628,77632,77688,77702,77708,77720,77744,77758,77774,77788,77870,77902,77916,77922,77928,77966,77980,78008,78018,78024,78032,78046,78060,78074,78094,78136,78192,78206,78210,78212,78224,78238,78240,78268,78278,78284,78296,78322,78324,78350,78364,78448,78462,78560,78588,78600,78622,78624,78652,78656,78712,78726,78744,78768,78782,78798,78812,78818,78820,78824,78838,78862,78876,78904,78960,78974,79072,79100,79296,79352,79368,79376,79390,79392,79420,79424,79480,79600,79628,79640,79664,79678,79712,79740,79772,79800,79810,79812,79816,79824,79838,79846,79852,79894,79910,79916,79942,79948,79960,79982,79988,80006,80024,80048,80062,80078,80092,80098,80100,80104,80134,80140,80176,80190,80224,80252,80270,80284,80312,80328,80336,80350,80358,80364,80378,80390,80396,80408,80432,80446,80480,80508,80576,80632,80654,80668,80696,80752,80766,80776,80784,80798,80800,80828,80844,80856,80878,80882,80884,80914,80916,80930,80932,80936,80950,80962,80968,80976,80990,80998,81004,81026,81028,81040,81054,81056,81084,81094,81100,81112,81134,81154,81156,81160,81168,81182,81184,81212,81216,81272,81286,81292,81304,81328,81342,81358,81372,81380,81384,81398,81434,81454,81458,81460,81486,81500,81506,81508,81512,81526,81550,81564,81592,81602,81604,81608,81616,81630,81638,81644,81702,81708,81722,81734,81740,81752,81774,81778,81780,82050,82078,82080,82108,82180,82184,82192,82206,82208,82236,82240,82296,82316,82328,82352,82366,82402,82404,82408,82440,82448,82462,82464,82492,82496,82552,82672,82694,82700,82712,82736,82750,82784,82812,82830,82882,82884,82888,82896,82918,82924,82952,82960,82974,82976,83004,83008,83064,83184,83424,83468,83480,83504,83518,83552,83580,83648,83704,83740,83768,83824,83838,83842,83844,83848,83856,83872,83900,83910,83916,83928,83950,83984,84e3,84028,84032,84088,84208,84448,84928,85040,85054,85088,85116,85184,85240,85488,85560,85616,85630,85728,85756,85764,85768,85776,85790,85792,85820,85824,85880,85894,85900,85912,85936,85966,85980,86048,86080,86136,86256,86496,86976,88160,88188,88256,88312,88560,89056,89200,89214,89312,89340,89536,89592,89608,89616,89632,89664,89720,89840,89868,89880,89904,89952,89980,89998,90012,90040,90190,90204,90254,90268,90296,90306,90308,90312,90334,90382,90396,90424,90480,90494,90500,90504,90512,90526,90528,90556,90566,90572,90584,90610,90612,90638,90652,90680,90736,90750,90848,90876,90884,90888,90896,90910,90912,90940,90944,91e3,91014,91020,91032,91056,91070,91086,91100,91106,91108,91112,91126,91150,91164,91192,91248,91262,91360,91388,91584,91640,91664,91678,91680,91708,91712,91768,91888,91928,91952,91966,92e3,92028,92046,92060,92088,92098,92100,92104,92112,92126,92134,92140,92188,92216,92272,92384,92412,92608,92664,93168,93200,93214,93216,93244,93248,93304,93424,93664,93720,93744,93758,93792,93820,93888,93944,93980,94008,94064,94078,94084,94088,94096,94110,94112,94140,94150,94156,94168,94246,94252,94278,94284,94296,94318,94342,94348,94360,94384,94398,94414,94428,94440,94470,94476,94488,94512,94526,94560,94588,94606,94620,94648,94658,94660,94664,94672,94686,94694,94700,94714,94726,94732,94744,94768,94782,94816,94844,94912,94968,94990,95004,95032,95088,95102,95112,95120,95134,95136,95164,95180,95192,95214,95218,95220,95244,95256,95280,95294,95328,95356,95424,95480,95728,95758,95772,95800,95856,95870,95968,95996,96008,96016,96030,96032,96060,96064,96120,96152,96176,96190,96220,96226,96228,96232,96290,96292,96296,96310,96322,96324,96328,96336,96350,96358,96364,96386,96388,96392,96400,96414,96416,96444,96454,96460,96472,96494,96498,96500,96514,96516,96520,96528,96542,96544,96572,96576,96632,96646,96652,96664,96688,96702,96718,96732,96738,96740,96744,96758,96772,96776,96784,96798,96800,96828,96832,96888,97008,97030,97036,97048,97072,97086,97120,97148,97166,97180,97208,97220,97224,97232,97246,97254,97260,97326,97330,97332,97358,97372,97378,97380,97384,97398,97422,97436,97464,97474,97476,97480,97488,97502,97510,97516,97550,97564,97592,97648,97666,97668,97672,97680,97694,97696,97724,97734,97740,97752,97774,97830,97836,97850,97862,97868,97880,97902,97906,97908,97926,97932,97944,97968,97998,98012,98018,98020,98024,98038,98618,98674,98676,98838,98854,98874,98892,98904,98926,98930,98932,98968,99006,99042,99044,99048,99062,99166,99194,99246,99286,99350,99366,99372,99386,99398,99416,99438,99442,99444,99462,99504,99518,99534,99548,99554,99556,99560,99574,99590,99596,99608,99632,99646,99680,99708,99726,99740,99768,99778,99780,99784,99792,99806,99814,99820,99834,99858,99860,99874,99880,99894,99906,99920,99934,99962,99970,99972,99976,99984,99998,1e5,100028,100038,100044,100056,100078,100082,100084,100142,100174,100188,100246,100262,100268,100306,100308,100390,100396,100410,100422,100428,100440,100462,100466,100468,100486,100504,100528,100542,100558,100572,100578,100580,100584,100598,100620,100656,100670,100704,100732,100750,100792,100802,100808,100816,100830,100838,100844,100858,100888,100912,100926,100960,100988,101056,101112,101148,101176,101232,101246,101250,101252,101256,101264,101278,101280,101308,101318,101324,101336,101358,101362,101364,101410,101412,101416,101430,101442,101448,101456,101470,101478,101498,101506,101508,101520,101534,101536,101564,101580,101618,101620,101636,101640,101648,101662,101664,101692,101696,101752,101766,101784,101838,101858,101860,101864,101934,101938,101940,101966,101980,101986,101988,101992,102030,102044,102072,102082,102084,102088,102096,102138,102166,102182,102188,102214,102220,102232,102254,102282,102290,102292,102306,102308,102312,102326,102444,102458,102470,102476,102488,102514,102516,102534,102552,102576,102590,102606,102620,102626,102632,102646,102662,102668,102704,102718,102752,102780,102798,102812,102840,102850,102856,102864,102878,102886,102892,102906,102936,102974,103008,103036,103104,103160,103224,103280,103294,103298,103300,103312,103326,103328,103356,103366,103372,103384,103406,103410,103412,103472,103486,103520,103548,103616,103672,103920,103992,104048,104062,104160,104188,104194,104196,104200,104208,104224,104252,104256,104312,104326,104332,104344,104368,104382,104398,104412,104418,104420,104424,104482,104484,104514,104520,104528,104542,104550,104570,104578,104580,104592,104606,104608,104636,104652,104690,104692,104706,104712,104734,104736,104764,104768,104824,104838,104856,104910,104930,104932,104936,104968,104976,104990,104992,105020,105024,105080,105200,105240,105278,105312,105372,105410,105412,105416,105424,105446,105518,105524,105550,105564,105570,105572,105576,105614,105628,105656,105666,105672,105680,105702,105722,105742,105756,105784,105840,105854,105858,105860,105864,105872,105888,105932,105970,105972,106006,106022,106028,106054,106060,106072,106100,106118,106124,106136,106160,106174,106190,106210,106212,106216,106250,106258,106260,106274,106276,106280,106306,106308,106312,106320,106334,106348,106394,106414,106418,106420,106566,106572,106610,106612,106630,106636,106648,106672,106686,106722,106724,106728,106742,106758,106764,106776,106800,106814,106848,106876,106894,106908,106936,106946,106948,106952,106960,106974,106982,106988,107032,107056,107070,107104,107132,107200,107256,107292,107320,107376,107390,107394,107396,107400,107408,107422,107424,107452,107462,107468,107480,107502,107506,107508,107544,107568,107582,107616,107644,107712,107768,108016,108060,108088,108144,108158,108256,108284,108290,108292,108296,108304,108318,108320,108348,108352,108408,108422,108428,108440,108464,108478,108494,108508,108514,108516,108520,108592,108640,108668,108736,108792,109040,109536,109680,109694,109792,109820,110016,110072,110084,110088,110096,110112,110140,110144,110200,110320,110342,110348,110360,110384,110398,110432,110460,110478,110492,110520,110532,110536,110544,110558,110658,110686,110714,110722,110724,110728,110736,110750,110752,110780,110796,110834,110836,110850,110852,110856,110864,110878,110880,110908,110912,110968,110982,111e3,111054,111074,111076,111080,111108,111112,111120,111134,111136,111164,111168,111224,111344,111372,111422,111456,111516,111554,111556,111560,111568,111590,111632,111646,111648,111676,111680,111736,111856,112096,112152,112224,112252,112320,112440,112514,112516,112520,112528,112542,112544,112588,112686,112718,112732,112782,112796,112824,112834,112836,112840,112848,112870,112890,112910,112924,112952,113008,113022,113026,113028,113032,113040,113054,113056,113100,113138,113140,113166,113180,113208,113264,113278,113376,113404,113416,113424,113440,113468,113472,113560,113614,113634,113636,113640,113686,113702,113708,113734,113740,113752,113778,113780,113798,113804,113816,113840,113854,113870,113890,113892,113896,113926,113932,113944,113968,113982,114016,114044,114076,114114,114116,114120,114128,114150,114170,114194,114196,114210,114212,114216,114242,114244,114248,114256,114270,114278,114306,114308,114312,114320,114334,114336,114364,114380,114420,114458,114478,114482,114484,114510,114524,114530,114532,114536,114842,114866,114868,114970,114994,114996,115042,115044,115048,115062,115130,115226,115250,115252,115278,115292,115298,115300,115304,115318,115342,115394,115396,115400,115408,115422,115430,115436,115450,115478,115494,115514,115526,115532,115570,115572,115738,115758,115762,115764,115790,115804,115810,115812,115816,115830,115854,115868,115896,115906,115912,115920,115934,115942,115948,115962,115996,116024,116080,116094,116098,116100,116104,116112,116126,116128,116156,116166,116172,116184,116206,116210,116212,116246,116262,116268,116282,116294,116300,116312,116334,116338,116340,116358,116364,116376,116400,116414,116430,116444,116450,116452,116456,116498,116500,116514,116520,116534,116546,116548,116552,116560,116574,116582,116588,116602,116654,116694,116714,116762,116782,116786,116788,116814,116828,116834,116836,116840,116854,116878,116892,116920,116930,116936,116944,116958,116966,116972,116986,117006,117048,117104,117118,117122,117124,117136,117150,117152,117180,117190,117196,117208,117230,117234,117236,117304,117360,117374,117472,117500,117506,117508,117512,117520,117536,117564,117568,117624,117638,117644,117656,117680,117694,117710,117724,117730,117732,117736,117750,117782,117798,117804,117818,117830,117848,117874,117876,117894,117936,117950,117966,117986,117988,117992,118022,118028,118040,118064,118078,118112,118140,118172,118210,118212,118216,118224,118238,118246,118266,118306,118312,118338,118352,118366,118374,118394,118402,118404,118408,118416,118430,118432,118460,118476,118514,118516,118574,118578,118580,118606,118620,118626,118628,118632,118678,118694,118700,118730,118738,118740,118830,118834,118836,118862,118876,118882,118884,118888,118902,118926,118940,118968,118978,118980,118984,118992,119006,119014,119020,119034,119068,119096,119152,119166,119170,119172,119176,119184,119198,119200,119228,119238,119244,119256,119278,119282,119284,119324,119352,119408,119422,119520,119548,119554,119556,119560,119568,119582,119584,119612,119616,119672,119686,119692,119704,119728,119742,119758,119772,119778,119780,119784,119798,119920,119934,120032,120060,120256,120312,120324,120328,120336,120352,120384,120440,120560,120582,120588,120600,120624,120638,120672,120700,120718,120732,120760,120770,120772,120776,120784,120798,120806,120812,120870,120876,120890,120902,120908,120920,120946,120948,120966,120972,120984,121008,121022,121038,121058,121060,121064,121078,121100,121112,121136,121150,121184,121212,121244,121282,121284,121288,121296,121318,121338,121356,121368,121392,121406,121440,121468,121536,121592,121656,121730,121732,121736,121744,121758,121760,121804,121842,121844,121890,121922,121924,121928,121936,121950,121958,121978,121986,121988,121992,122e3,122014,122016,122044,122060,122098,122100,122116,122120,122128,122142,122144,122172,122176,122232,122246,122264,122318,122338,122340,122344,122414,122418,122420,122446,122460,122466,122468,122472,122510,122524,122552,122562,122564,122568,122576,122598,122618,122646,122662,122668,122694,122700,122712,122738,122740,122762,122770,122772,122786,122788,122792,123018,123026,123028,123042,123044,123048,123062,123098,123146,123154,123156,123170,123172,123176,123190,123202,123204,123208,123216,123238,123244,123258,123290,123314,123316,123402,123410,123412,123426,123428,123432,123446,123458,123464,123472,123486,123494,123500,123514,123522,123524,123528,123536,123552,123580,123590,123596,123608,123630,123634,123636,123674,123698,123700,123740,123746,123748,123752,123834,123914,123922,123924,123938,123944,123958,123970,123976,123984,123998,124006,124012,124026,124034,124036,124048,124062,124064,124092,124102,124108,124120,124142,124146,124148,124162,124164,124168,124176,124190,124192,124220,124224,124280,124294,124300,124312,124336,124350,124366,124380,124386,124388,124392,124406,124442,124462,124466,124468,124494,124508,124514,124520,124558,124572,124600,124610,124612,124616,124624,124646,124666,124694,124710,124716,124730,124742,124748,124760,124786,124788,124818,124820,124834,124836,124840,124854,124946,124948,124962,124964,124968,124982,124994,124996,125e3,125008,125022,125030,125036,125050,125058,125060,125064,125072,125086,125088,125116,125126,125132,125144,125166,125170,125172,125186,125188,125192,125200,125216,125244,125248,125304,125318,125324,125336,125360,125374,125390,125404,125410,125412,125416,125430,125444,125448,125456,125472,125504,125560,125680,125702,125708,125720,125744,125758,125792,125820,125838,125852,125880,125890,125892,125896,125904,125918,125926,125932,125978,125998,126002,126004,126030,126044,126050,126052,126056,126094,126108,126136,126146,126148,126152,126160,126182,126202,126222,126236,126264,126320,126334,126338,126340,126344,126352,126366,126368,126412,126450,126452,126486,126502,126508,126522,126534,126540,126552,126574,126578,126580,126598,126604,126616,126640,126654,126670,126684,126690,126692,126696,126738,126754,126756,126760,126774,126786,126788,126792,126800,126814,126822,126828,126842,126894,126898,126900,126934,127126,127142,127148,127162,127178,127186,127188,127254,127270,127276,127290,127302,127308,127320,127342,127346,127348,127370,127378,127380,127394,127396,127400,127450,127510,127526,127532,127546,127558,127576,127598,127602,127604,127622,127628,127640,127664,127678,127694,127708,127714,127716,127720,127734,127754,127762,127764,127778,127784,127810,127812,127816,127824,127838,127846,127866,127898,127918,127922,127924,128022,128038,128044,128058,128070,128076,128088,128110,128114,128116,128134,128140,128152,128176,128190,128206,128220,128226,128228,128232,128246,128262,128268,128280,128304,128318,128352,128380,128398,128412,128440,128450,128452,128456,128464,128478,128486,128492,128506,128522,128530,128532,128546,128548,128552,128566,128578,128580,128584,128592,128606,128614,128634,128642,128644,128648,128656,128670,128672,128700,128716,128754,128756,128794,128814,128818,128820,128846,128860,128866,128868,128872,128886,128918,128934,128940,128954,128978,128980,129178,129198,129202,129204,129238,129258,129306,129326,129330,129332,129358,129372,129378,129380,129384,129398,129430,129446,129452,129466,129482,129490,129492,129562,129582,129586,129588,129614,129628,129634,129636,129640,129654,129678,129692,129720,129730,129732,129736,129744,129758,129766,129772,129814,129830,129836,129850,129862,129868,129880,129902,129906,129908,129930,129938,129940,129954,129956,129960,129974,130010]),cr.CODEWORD_TABLE=Int32Array.from([2627,1819,2622,2621,1813,1812,2729,2724,2723,2779,2774,2773,902,896,908,868,865,861,859,2511,873,871,1780,835,2493,825,2491,842,837,844,1764,1762,811,810,809,2483,807,2482,806,2480,815,814,813,812,2484,817,816,1745,1744,1742,1746,2655,2637,2635,2626,2625,2623,2628,1820,2752,2739,2737,2728,2727,2725,2730,2785,2783,2778,2777,2775,2780,787,781,747,739,736,2413,754,752,1719,692,689,681,2371,678,2369,700,697,694,703,1688,1686,642,638,2343,631,2341,627,2338,651,646,643,2345,654,652,1652,1650,1647,1654,601,599,2322,596,2321,594,2319,2317,611,610,608,606,2324,603,2323,615,614,612,1617,1616,1614,1612,616,1619,1618,2575,2538,2536,905,901,898,909,2509,2507,2504,870,867,864,860,2512,875,872,1781,2490,2489,2487,2485,1748,836,834,832,830,2494,827,2492,843,841,839,845,1765,1763,2701,2676,2674,2653,2648,2656,2634,2633,2631,2629,1821,2638,2636,2770,2763,2761,2750,2745,2753,2736,2735,2733,2731,1848,2740,2738,2786,2784,591,588,576,569,566,2296,1590,537,534,526,2276,522,2274,545,542,539,548,1572,1570,481,2245,466,2242,462,2239,492,485,482,2249,496,494,1534,1531,1528,1538,413,2196,406,2191,2188,425,419,2202,415,2199,432,430,427,1472,1467,1464,433,1476,1474,368,367,2160,365,2159,362,2157,2155,2152,378,377,375,2166,372,2165,369,2162,383,381,379,2168,1419,1418,1416,1414,385,1411,384,1423,1422,1420,1424,2461,802,2441,2439,790,786,783,794,2409,2406,2403,750,742,738,2414,756,753,1720,2367,2365,2362,2359,1663,693,691,684,2373,680,2370,702,699,696,704,1690,1687,2337,2336,2334,2332,1624,2329,1622,640,637,2344,634,2342,630,2340,650,648,645,2346,655,653,1653,1651,1649,1655,2612,2597,2595,2571,2568,2565,2576,2534,2529,2526,1787,2540,2537,907,904,900,910,2503,2502,2500,2498,1768,2495,1767,2510,2508,2506,869,866,863,2513,876,874,1782,2720,2713,2711,2697,2694,2691,2702,2672,2670,2664,1828,2678,2675,2647,2646,2644,2642,1823,2639,1822,2654,2652,2650,2657,2771,1855,2765,2762,1850,1849,2751,2749,2747,2754,353,2148,344,342,336,2142,332,2140,345,1375,1373,306,2130,299,2128,295,2125,319,314,311,2132,1354,1352,1349,1356,262,257,2101,253,2096,2093,274,273,267,2107,263,2104,280,278,275,1316,1311,1308,1320,1318,2052,202,2050,2044,2040,219,2063,212,2060,208,2055,224,221,2066,1260,1258,1252,231,1248,229,1266,1264,1261,1268,155,1998,153,1996,1994,1991,1988,165,164,2007,162,2006,159,2003,2e3,172,171,169,2012,166,2010,1186,1184,1182,1179,175,1176,173,1192,1191,1189,1187,176,1194,1193,2313,2307,2305,592,589,2294,2292,2289,578,572,568,2297,580,1591,2272,2267,2264,1547,538,536,529,2278,525,2275,547,544,541,1574,1571,2237,2235,2229,1493,2225,1489,478,2247,470,2244,465,2241,493,488,484,2250,498,495,1536,1533,1530,1539,2187,2186,2184,2182,1432,2179,1430,2176,1427,414,412,2197,409,2195,405,2193,2190,426,424,421,2203,418,2201,431,429,1473,1471,1469,1466,434,1477,1475,2478,2472,2470,2459,2457,2454,2462,803,2437,2432,2429,1726,2443,2440,792,789,785,2401,2399,2393,1702,2389,1699,2411,2408,2405,745,741,2415,758,755,1721,2358,2357,2355,2353,1661,2350,1660,2347,1657,2368,2366,2364,2361,1666,690,687,2374,683,2372,701,698,705,1691,1689,2619,2617,2610,2608,2605,2613,2593,2588,2585,1803,2599,2596,2563,2561,2555,1797,2551,1795,2573,2570,2567,2577,2525,2524,2522,2520,1786,2517,1785,2514,1783,2535,2533,2531,2528,1788,2541,2539,906,903,911,2721,1844,2715,2712,1838,1836,2699,2696,2693,2703,1827,1826,1824,2673,2671,2669,2666,1829,2679,2677,1858,1857,2772,1854,1853,1851,1856,2766,2764,143,1987,139,1986,135,133,131,1984,128,1983,125,1981,138,137,136,1985,1133,1132,1130,112,110,1974,107,1973,104,1971,1969,122,121,119,117,1977,114,1976,124,1115,1114,1112,1110,1117,1116,84,83,1953,81,1952,78,1950,1948,1945,94,93,91,1959,88,1958,85,1955,99,97,95,1961,1086,1085,1083,1081,1078,100,1090,1089,1087,1091,49,47,1917,44,1915,1913,1910,1907,59,1926,56,1925,53,1922,1919,66,64,1931,61,1929,1042,1040,1038,71,1035,70,1032,68,1048,1047,1045,1043,1050,1049,12,10,1869,1867,1864,1861,21,1880,19,1877,1874,1871,28,1888,25,1886,22,1883,982,980,977,974,32,30,991,989,987,984,34,995,994,992,2151,2150,2147,2146,2144,356,355,354,2149,2139,2138,2136,2134,1359,343,341,338,2143,335,2141,348,347,346,1376,1374,2124,2123,2121,2119,1326,2116,1324,310,308,305,2131,302,2129,298,2127,320,318,316,313,2133,322,321,1355,1353,1351,1357,2092,2091,2089,2087,1276,2084,1274,2081,1271,259,2102,256,2100,252,2098,2095,272,269,2108,266,2106,281,279,277,1317,1315,1313,1310,282,1321,1319,2039,2037,2035,2032,1203,2029,1200,1197,207,2053,205,2051,201,2049,2046,2043,220,218,2064,215,2062,211,2059,228,226,223,2069,1259,1257,1254,232,1251,230,1267,1265,1263,2316,2315,2312,2311,2309,2314,2304,2303,2301,2299,1593,2308,2306,590,2288,2287,2285,2283,1578,2280,1577,2295,2293,2291,579,577,574,571,2298,582,581,1592,2263,2262,2260,2258,1545,2255,1544,2252,1541,2273,2271,2269,2266,1550,535,532,2279,528,2277,546,543,549,1575,1573,2224,2222,2220,1486,2217,1485,2214,1482,1479,2238,2236,2234,2231,1496,2228,1492,480,477,2248,473,2246,469,2243,490,487,2251,497,1537,1535,1532,2477,2476,2474,2479,2469,2468,2466,2464,1730,2473,2471,2453,2452,2450,2448,1729,2445,1728,2460,2458,2456,2463,805,804,2428,2427,2425,2423,1725,2420,1724,2417,1722,2438,2436,2434,2431,1727,2444,2442,793,791,788,795,2388,2386,2384,1697,2381,1696,2378,1694,1692,2402,2400,2398,2395,1703,2392,1701,2412,2410,2407,751,748,744,2416,759,757,1807,2620,2618,1806,1805,2611,2609,2607,2614,1802,1801,1799,2594,2592,2590,2587,1804,2600,2598,1794,1793,1791,1789,2564,2562,2560,2557,1798,2554,1796,2574,2572,2569,2578,1847,1846,2722,1843,1842,1840,1845,2716,2714,1835,1834,1832,1830,1839,1837,2700,2698,2695,2704,1817,1811,1810,897,862,1777,829,826,838,1760,1758,808,2481,1741,1740,1738,1743,2624,1818,2726,2776,782,740,737,1715,686,679,695,1682,1680,639,628,2339,647,644,1645,1643,1640,1648,602,600,597,595,2320,593,2318,609,607,604,1611,1610,1608,1606,613,1615,1613,2328,926,924,892,886,899,857,850,2505,1778,824,823,821,819,2488,818,2486,833,831,828,840,1761,1759,2649,2632,2630,2746,2734,2732,2782,2781,570,567,1587,531,527,523,540,1566,1564,476,467,463,2240,486,483,1524,1521,1518,1529,411,403,2192,399,2189,423,416,1462,1457,1454,428,1468,1465,2210,366,363,2158,360,2156,357,2153,376,373,370,2163,1410,1409,1407,1405,382,1402,380,1417,1415,1412,1421,2175,2174,777,774,771,784,732,725,722,2404,743,1716,676,674,668,2363,665,2360,685,1684,1681,626,624,622,2335,620,2333,617,2330,641,635,649,1646,1644,1642,2566,928,925,2530,2527,894,891,888,2501,2499,2496,858,856,854,851,1779,2692,2668,2665,2645,2643,2640,2651,2768,2759,2757,2744,2743,2741,2748,352,1382,340,337,333,1371,1369,307,300,296,2126,315,312,1347,1342,1350,261,258,250,2097,246,2094,271,268,264,1306,1301,1298,276,1312,1309,2115,203,2048,195,2045,191,2041,213,209,2056,1246,1244,1238,225,1234,222,1256,1253,1249,1262,2080,2079,154,1997,150,1995,147,1992,1989,163,160,2004,156,2001,1175,1174,1172,1170,1167,170,1164,167,1185,1183,1180,1177,174,1190,1188,2025,2024,2022,587,586,564,559,556,2290,573,1588,520,518,512,2268,508,2265,530,1568,1565,461,457,2233,450,2230,446,2226,479,471,489,1526,1523,1520,397,395,2185,392,2183,389,2180,2177,410,2194,402,422,1463,1461,1459,1456,1470,2455,799,2433,2430,779,776,773,2397,2394,2390,734,728,724,746,1717,2356,2354,2351,2348,1658,677,675,673,670,667,688,1685,1683,2606,2589,2586,2559,2556,2552,927,2523,2521,2518,2515,1784,2532,895,893,890,2718,2709,2707,2689,2687,2684,2663,2662,2660,2658,1825,2667,2769,1852,2760,2758,142,141,1139,1138,134,132,129,126,1982,1129,1128,1126,1131,113,111,108,105,1972,101,1970,120,118,115,1109,1108,1106,1104,123,1113,1111,82,79,1951,75,1949,72,1946,92,89,86,1956,1077,1076,1074,1072,98,1069,96,1084,1082,1079,1088,1968,1967,48,45,1916,42,1914,39,1911,1908,60,57,54,1923,50,1920,1031,1030,1028,1026,67,1023,65,1020,62,1041,1039,1036,1033,69,1046,1044,1944,1943,1941,11,9,1868,7,1865,1862,1859,20,1878,16,1875,13,1872,970,968,966,963,29,960,26,23,983,981,978,975,33,971,31,990,988,985,1906,1904,1902,993,351,2145,1383,331,330,328,326,2137,323,2135,339,1372,1370,294,293,291,289,2122,286,2120,283,2117,309,303,317,1348,1346,1344,245,244,242,2090,239,2088,236,2085,2082,260,2099,249,270,1307,1305,1303,1300,1314,189,2038,186,2036,183,2033,2030,2026,206,198,2047,194,216,1247,1245,1243,1240,227,1237,1255,2310,2302,2300,2286,2284,2281,565,563,561,558,575,1589,2261,2259,2256,2253,1542,521,519,517,514,2270,511,533,1569,1567,2223,2221,2218,2215,1483,2211,1480,459,456,453,2232,449,474,491,1527,1525,1522,2475,2467,2465,2451,2449,2446,801,800,2426,2424,2421,2418,1723,2435,780,778,775,2387,2385,2382,2379,1695,2375,1693,2396,735,733,730,727,749,1718,2616,2615,2604,2603,2601,2584,2583,2581,2579,1800,2591,2550,2549,2547,2545,1792,2542,1790,2558,929,2719,1841,2710,2708,1833,1831,2690,2688,2686,1815,1809,1808,1774,1756,1754,1737,1736,1734,1739,1816,1711,1676,1674,633,629,1638,1636,1633,1641,598,1605,1604,1602,1600,605,1609,1607,2327,887,853,1775,822,820,1757,1755,1584,524,1560,1558,468,464,1514,1511,1508,1519,408,404,400,1452,1447,1444,417,1458,1455,2208,364,361,358,2154,1401,1400,1398,1396,374,1393,371,1408,1406,1403,1413,2173,2172,772,726,723,1712,672,669,666,682,1678,1675,625,623,621,618,2331,636,632,1639,1637,1635,920,918,884,880,889,849,848,847,846,2497,855,852,1776,2641,2742,2787,1380,334,1367,1365,301,297,1340,1338,1335,1343,255,251,247,1296,1291,1288,265,1302,1299,2113,204,196,192,2042,1232,1230,1224,214,1220,210,1242,1239,1235,1250,2077,2075,151,148,1993,144,1990,1163,1162,1160,1158,1155,161,1152,157,1173,1171,1168,1165,168,1181,1178,2021,2020,2018,2023,585,560,557,1585,516,509,1562,1559,458,447,2227,472,1516,1513,1510,398,396,393,390,2181,386,2178,407,1453,1451,1449,1446,420,1460,2209,769,764,720,712,2391,729,1713,664,663,661,659,2352,656,2349,671,1679,1677,2553,922,919,2519,2516,885,883,881,2685,2661,2659,2767,2756,2755,140,1137,1136,130,127,1125,1124,1122,1127,109,106,102,1103,1102,1100,1098,116,1107,1105,1980,80,76,73,1947,1068,1067,1065,1063,90,1060,87,1075,1073,1070,1080,1966,1965,46,43,40,1912,36,1909,1019,1018,1016,1014,58,1011,55,1008,51,1029,1027,1024,1021,63,1037,1034,1940,1939,1937,1942,8,1866,4,1863,1,1860,956,954,952,949,946,17,14,969,967,964,961,27,957,24,979,976,972,1901,1900,1898,1896,986,1905,1903,350,349,1381,329,327,324,1368,1366,292,290,287,284,2118,304,1341,1339,1337,1345,243,240,237,2086,233,2083,254,1297,1295,1293,1290,1304,2114,190,187,184,2034,180,2031,177,2027,199,1233,1231,1229,1226,217,1223,1241,2078,2076,584,555,554,552,550,2282,562,1586,507,506,504,502,2257,499,2254,515,1563,1561,445,443,441,2219,438,2216,435,2212,460,454,475,1517,1515,1512,2447,798,797,2422,2419,770,768,766,2383,2380,2376,721,719,717,714,731,1714,2602,2582,2580,2548,2546,2543,923,921,2717,2706,2705,2683,2682,2680,1771,1752,1750,1733,1732,1731,1735,1814,1707,1670,1668,1631,1629,1626,1634,1599,1598,1596,1594,1603,1601,2326,1772,1753,1751,1581,1554,1552,1504,1501,1498,1509,1442,1437,1434,401,1448,1445,2206,1392,1391,1389,1387,1384,359,1399,1397,1394,1404,2171,2170,1708,1672,1669,619,1632,1630,1628,1773,1378,1363,1361,1333,1328,1336,1286,1281,1278,248,1292,1289,2111,1218,1216,1210,197,1206,193,1228,1225,1221,1236,2073,2071,1151,1150,1148,1146,152,1143,149,1140,145,1161,1159,1156,1153,158,1169,1166,2017,2016,2014,2019,1582,510,1556,1553,452,448,1506,1500,394,391,387,1443,1441,1439,1436,1450,2207,765,716,713,1709,662,660,657,1673,1671,916,914,879,878,877,882,1135,1134,1121,1120,1118,1123,1097,1096,1094,1092,103,1101,1099,1979,1059,1058,1056,1054,77,1051,74,1066,1064,1061,1071,1964,1963,1007,1006,1004,1002,999,41,996,37,1017,1015,1012,1009,52,1025,1022,1936,1935,1933,1938,942,940,938,935,932,5,2,955,953,950,947,18,943,15,965,962,958,1895,1894,1892,1890,973,1899,1897,1379,325,1364,1362,288,285,1334,1332,1330,241,238,234,1287,1285,1283,1280,1294,2112,188,185,181,178,2028,1219,1217,1215,1212,200,1209,1227,2074,2072,583,553,551,1583,505,503,500,513,1557,1555,444,442,439,436,2213,455,451,1507,1505,1502,796,763,762,760,767,711,710,708,706,2377,718,715,1710,2544,917,915,2681,1627,1597,1595,2325,1769,1749,1747,1499,1438,1435,2204,1390,1388,1385,1395,2169,2167,1704,1665,1662,1625,1623,1620,1770,1329,1282,1279,2109,1214,1207,1222,2068,2065,1149,1147,1144,1141,146,1157,1154,2013,2011,2008,2015,1579,1549,1546,1495,1487,1433,1431,1428,1425,388,1440,2205,1705,658,1667,1664,1119,1095,1093,1978,1057,1055,1052,1062,1962,1960,1005,1003,1e3,997,38,1013,1010,1932,1930,1927,1934,941,939,936,933,6,930,3,951,948,944,1889,1887,1884,1881,959,1893,1891,35,1377,1360,1358,1327,1325,1322,1331,1277,1275,1272,1269,235,1284,2110,1205,1204,1201,1198,182,1195,179,1213,2070,2067,1580,501,1551,1548,440,437,1497,1494,1490,1503,761,709,707,1706,913,912,2198,1386,2164,2161,1621,1766,2103,1208,2058,2054,1145,1142,2005,2002,1999,2009,1488,1429,1426,2200,1698,1659,1656,1975,1053,1957,1954,1001,998,1924,1921,1918,1928,937,934,931,1879,1876,1873,1870,945,1885,1882,1323,1273,1270,2105,1202,1199,1196,1211,2061,2057,1576,1543,1540,1484,1481,1478,1491,1700]);class Ql{constructor(o,d){this.bits=o,this.points=d}getBits(){return this.bits}getPoints(){return this.points}}class Fr{static detectMultiple(o,d,f){let p=o.getBlackMatrix(),b=Fr.detect(f,p);return b.length||(p=p.clone(),p.rotate180(),b=Fr.detect(f,p)),new Ql(p,b)}static detect(o,d){const f=new Array;let p=0,b=0,w=!1;for(;p<d.getHeight();){const S=Fr.findVertices(d,p,b);if(S[0]==null&&S[3]==null){if(!w)break;w=!1,b=0;for(const R of f)R[1]!=null&&(p=Math.trunc(Math.max(p,R[1].getY()))),R[3]!=null&&(p=Math.max(p,Math.trunc(R[3].getY())));p+=Fr.ROW_STEP;continue}if(w=!0,f.push(S),!o)break;S[2]!=null?(b=Math.trunc(S[2].getX()),p=Math.trunc(S[2].getY())):(b=Math.trunc(S[4].getX()),p=Math.trunc(S[4].getY()))}return f}static findVertices(o,d,f){const p=o.getHeight(),b=o.getWidth(),w=new Array(8);return Fr.copyToResult(w,Fr.findRowsWithPattern(o,p,b,d,f,Fr.START_PATTERN),Fr.INDEXES_START_PATTERN),w[4]!=null&&(f=Math.trunc(w[4].getX()),d=Math.trunc(w[4].getY())),Fr.copyToResult(w,Fr.findRowsWithPattern(o,p,b,d,f,Fr.STOP_PATTERN),Fr.INDEXES_STOP_PATTERN),w}static copyToResult(o,d,f){for(let p=0;p<f.length;p++)o[f[p]]=d[p]}static findRowsWithPattern(o,d,f,p,b,w){const S=new Array(4);let R=!1;const P=new Int32Array(w.length);for(;p<d;p+=Fr.ROW_STEP){let te=Fr.findGuardPattern(o,b,p,f,!1,w,P);if(te!=null){for(;p>0;){const ue=Fr.findGuardPattern(o,b,--p,f,!1,w,P);if(ue!=null)te=ue;else{p++;break}}S[0]=new St(te[0],p),S[1]=new St(te[1],p),R=!0;break}}let X=p+1;if(R){let te=0,ue=Int32Array.from([Math.trunc(S[0].getX()),Math.trunc(S[1].getX())]);for(;X<d;X++){const je=Fr.findGuardPattern(o,ue[0],X,f,!1,w,P);if(je!=null&&Math.abs(ue[0]-je[0])<Fr.MAX_PATTERN_DRIFT&&Math.abs(ue[1]-je[1])<Fr.MAX_PATTERN_DRIFT)ue=je,te=0;else{if(te>Fr.SKIPPED_ROW_COUNT_MAX)break;te++}}X-=te+1,S[2]=new St(ue[0],X),S[3]=new St(ue[1],X)}return X-p<Fr.BARCODE_MIN_HEIGHT&&U.fill(S,null),S}static findGuardPattern(o,d,f,p,b,w,S){U.fillWithin(S,0,S.length,0);let R=d,P=0;for(;o.get(R,f)&&R>0&&P++<Fr.MAX_PIXEL_DRIFT;)R--;let X=R,te=0,ue=w.length;for(let je=b;X<p;X++)if(o.get(X,f)!==je)S[te]++;else{if(te===ue-1){if(Fr.patternMatchVariance(S,w,Fr.MAX_INDIVIDUAL_VARIANCE)<Fr.MAX_AVG_VARIANCE)return new Int32Array([R,X]);R+=S[0]+S[1],A.arraycopy(S,2,S,0,te-1),S[te-1]=0,S[te]=0,te--}else te++;S[te]=1,je=!je}return te===ue-1&&Fr.patternMatchVariance(S,w,Fr.MAX_INDIVIDUAL_VARIANCE)<Fr.MAX_AVG_VARIANCE?new Int32Array([R,X-1]):null}static patternMatchVariance(o,d,f){let p=o.length,b=0,w=0;for(let P=0;P<p;P++)b+=o[P],w+=d[P];if(b<w)return 1/0;let S=b/w;f*=S;let R=0;for(let P=0;P<p;P++){let X=o[P],te=d[P]*S,ue=X>te?X-te:te-X;if(ue>f)return 1/0;R+=ue}return R/b}}Fr.INDEXES_START_PATTERN=Int32Array.from([0,4,1,5]),Fr.INDEXES_STOP_PATTERN=Int32Array.from([6,2,7,3]),Fr.MAX_AVG_VARIANCE=.42,Fr.MAX_INDIVIDUAL_VARIANCE=.8,Fr.START_PATTERN=Int32Array.from([8,1,1,1,1,1,1,3]),Fr.STOP_PATTERN=Int32Array.from([7,1,1,3,1,1,1,2,1]),Fr.MAX_PIXEL_DRIFT=3,Fr.MAX_PATTERN_DRIFT=5,Fr.SKIPPED_ROW_COUNT_MAX=25,Fr.ROW_STEP=5,Fr.BARCODE_MIN_HEIGHT=10;class wa{constructor(o,d){if(d.length===0)throw new N;this.field=o;let f=d.length;if(f>1&&d[0]===0){let p=1;for(;p<f&&d[p]===0;)p++;p===f?this.coefficients=new Int32Array([0]):(this.coefficients=new Int32Array(f-p),A.arraycopy(d,p,this.coefficients,0,this.coefficients.length))}else this.coefficients=d}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(o){return this.coefficients[this.coefficients.length-1-o]}evaluateAt(o){if(o===0)return this.getCoefficient(0);if(o===1){let p=0;for(let b of this.coefficients)p=this.field.add(p,b);return p}let d=this.coefficients[0],f=this.coefficients.length;for(let p=1;p<f;p++)d=this.field.add(this.field.multiply(o,d),this.coefficients[p]);return d}add(o){if(!this.field.equals(o.field))throw new N("ModulusPolys do not have same ModulusGF field");if(this.isZero())return o;if(o.isZero())return this;let d=this.coefficients,f=o.coefficients;if(d.length>f.length){let w=d;d=f,f=w}let p=new Int32Array(f.length),b=f.length-d.length;A.arraycopy(f,0,p,0,b);for(let w=b;w<f.length;w++)p[w]=this.field.add(d[w-b],f[w]);return new wa(this.field,p)}subtract(o){if(!this.field.equals(o.field))throw new N("ModulusPolys do not have same ModulusGF field");return o.isZero()?this:this.add(o.negative())}multiply(o){return o instanceof wa?this.multiplyOther(o):this.multiplyScalar(o)}multiplyOther(o){if(!this.field.equals(o.field))throw new N("ModulusPolys do not have same ModulusGF field");if(this.isZero()||o.isZero())return new wa(this.field,new Int32Array([0]));let d=this.coefficients,f=d.length,p=o.coefficients,b=p.length,w=new Int32Array(f+b-1);for(let S=0;S<f;S++){let R=d[S];for(let P=0;P<b;P++)w[S+P]=this.field.add(w[S+P],this.field.multiply(R,p[P]))}return new wa(this.field,w)}negative(){let o=this.coefficients.length,d=new Int32Array(o);for(let f=0;f<o;f++)d[f]=this.field.subtract(0,this.coefficients[f]);return new wa(this.field,d)}multiplyScalar(o){if(o===0)return new wa(this.field,new Int32Array([0]));if(o===1)return this;let d=this.coefficients.length,f=new Int32Array(d);for(let p=0;p<d;p++)f[p]=this.field.multiply(this.coefficients[p],o);return new wa(this.field,f)}multiplyByMonomial(o,d){if(o<0)throw new N;if(d===0)return new wa(this.field,new Int32Array([0]));let f=this.coefficients.length,p=new Int32Array(f+o);for(let b=0;b<f;b++)p[b]=this.field.multiply(this.coefficients[b],d);return new wa(this.field,p)}toString(){let o=new ce;for(let d=this.getDegree();d>=0;d--){let f=this.getCoefficient(d);f!==0&&(f<0?(o.append(" - "),f=-f):o.length()>0&&o.append(" + "),(d===0||f!==1)&&o.append(f),d!==0&&(d===1?o.append("x"):(o.append("x^"),o.append(d))))}return o.toString()}}class Oo{add(o,d){return(o+d)%this.modulus}subtract(o,d){return(this.modulus+o-d)%this.modulus}exp(o){return this.expTable[o]}log(o){if(o===0)throw new N;return this.logTable[o]}inverse(o){if(o===0)throw new Lt;return this.expTable[this.modulus-this.logTable[o]-1]}multiply(o,d){return o===0||d===0?0:this.expTable[(this.logTable[o]+this.logTable[d])%(this.modulus-1)]}getSize(){return this.modulus}equals(o){return o===this}}class Zn extends Oo{constructor(o,d){super(),this.modulus=o,this.expTable=new Int32Array(o),this.logTable=new Int32Array(o);let f=1;for(let p=0;p<o;p++)this.expTable[p]=f,f=f*d%o;for(let p=0;p<o-1;p++)this.logTable[this.expTable[p]]=p;this.zero=new wa(this,new Int32Array([0])),this.one=new wa(this,new Int32Array([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(o,d){if(o<0)throw new N;if(d===0)return this.zero;let f=new Int32Array(o+1);return f[0]=d,new wa(this,f)}}Zn.PDF417_GF=new Zn(cr.NUMBER_OF_CODEWORDS,3);class ws{constructor(){this.field=Zn.PDF417_GF}decode(o,d,f){let p=new wa(this.field,o),b=new Int32Array(d),w=!1;for(let Fe=d;Fe>0;Fe--){let Ue=p.evaluateAt(this.field.exp(Fe));b[d-Fe]=Ue,Ue!==0&&(w=!0)}if(!w)return 0;let S=this.field.getOne();if(f!=null)for(const Fe of f){let Ue=this.field.exp(o.length-1-Fe),tt=new wa(this.field,new Int32Array([this.field.subtract(0,Ue),1]));S=S.multiply(tt)}let R=new wa(this.field,b),P=this.runEuclideanAlgorithm(this.field.buildMonomial(d,1),R,d),X=P[0],te=P[1],ue=this.findErrorLocations(X),je=this.findErrorMagnitudes(te,X,ue);for(let Fe=0;Fe<ue.length;Fe++){let Ue=o.length-1-this.field.log(ue[Fe]);if(Ue<0)throw O.getChecksumInstance();o[Ue]=this.field.subtract(o[Ue],je[Fe])}return ue.length}runEuclideanAlgorithm(o,d,f){if(o.getDegree()<d.getDegree()){let ue=o;o=d,d=ue}let p=o,b=d,w=this.field.getZero(),S=this.field.getOne();for(;b.getDegree()>=Math.round(f/2);){let ue=p,je=w;if(p=b,w=S,p.isZero())throw O.getChecksumInstance();b=ue;let Fe=this.field.getZero(),Ue=p.getCoefficient(p.getDegree()),tt=this.field.inverse(Ue);for(;b.getDegree()>=p.getDegree()&&!b.isZero();){let ut=b.getDegree()-p.getDegree(),Xt=this.field.multiply(b.getCoefficient(b.getDegree()),tt);Fe=Fe.add(this.field.buildMonomial(ut,Xt)),b=b.subtract(p.multiplyByMonomial(ut,Xt))}S=Fe.multiply(w).subtract(je).negative()}let R=S.getCoefficient(0);if(R===0)throw O.getChecksumInstance();let P=this.field.inverse(R),X=S.multiply(P),te=b.multiply(P);return[X,te]}findErrorLocations(o){let d=o.getDegree(),f=new Int32Array(d),p=0;for(let b=1;b<this.field.getSize()&&p<d;b++)o.evaluateAt(b)===0&&(f[p]=this.field.inverse(b),p++);if(p!==d)throw O.getChecksumInstance();return f}findErrorMagnitudes(o,d,f){let p=d.getDegree(),b=new Int32Array(p);for(let P=1;P<=p;P++)b[p-P]=this.field.multiply(P,d.getCoefficient(P));let w=new wa(this.field,b),S=f.length,R=new Int32Array(S);for(let P=0;P<S;P++){let X=this.field.inverse(f[P]),te=this.field.subtract(0,o.evaluateAt(X)),ue=this.field.inverse(w.evaluateAt(X));R[P]=this.field.multiply(te,ue)}return R}}class qn{constructor(o,d,f,p,b){o instanceof qn?this.constructor_2(o):this.constructor_1(o,d,f,p,b)}constructor_1(o,d,f,p,b){const w=d==null||f==null,S=p==null||b==null;if(w&&S)throw new ae;w?(d=new St(0,p.getY()),f=new St(0,b.getY())):S&&(p=new St(o.getWidth()-1,d.getY()),b=new St(o.getWidth()-1,f.getY())),this.image=o,this.topLeft=d,this.bottomLeft=f,this.topRight=p,this.bottomRight=b,this.minX=Math.trunc(Math.min(d.getX(),f.getX())),this.maxX=Math.trunc(Math.max(p.getX(),b.getX())),this.minY=Math.trunc(Math.min(d.getY(),p.getY())),this.maxY=Math.trunc(Math.max(f.getY(),b.getY()))}constructor_2(o){this.image=o.image,this.topLeft=o.getTopLeft(),this.bottomLeft=o.getBottomLeft(),this.topRight=o.getTopRight(),this.bottomRight=o.getBottomRight(),this.minX=o.getMinX(),this.maxX=o.getMaxX(),this.minY=o.getMinY(),this.maxY=o.getMaxY()}static merge(o,d){return o==null?d:d==null?o:new qn(o.image,o.topLeft,o.bottomLeft,d.topRight,d.bottomRight)}addMissingRows(o,d,f){let p=this.topLeft,b=this.bottomLeft,w=this.topRight,S=this.bottomRight;if(o>0){let R=f?this.topLeft:this.topRight,P=Math.trunc(R.getY()-o);P<0&&(P=0);let X=new St(R.getX(),P);f?p=X:w=X}if(d>0){let R=f?this.bottomLeft:this.bottomRight,P=Math.trunc(R.getY()+d);P>=this.image.getHeight()&&(P=this.image.getHeight()-1);let X=new St(R.getX(),P);f?b=X:S=X}return new qn(this.image,p,b,w,S)}getMinX(){return this.minX}getMaxX(){return this.maxX}getMinY(){return this.minY}getMaxY(){return this.maxY}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}getBottomLeft(){return this.bottomLeft}getBottomRight(){return this.bottomRight}}class qa{constructor(o,d,f,p){this.columnCount=o,this.errorCorrectionLevel=p,this.rowCountUpperPart=d,this.rowCountLowerPart=f,this.rowCount=d+f}getColumnCount(){return this.columnCount}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getRowCount(){return this.rowCount}getRowCountUpperPart(){return this.rowCountUpperPart}getRowCountLowerPart(){return this.rowCountLowerPart}}class us{constructor(){this.buffer=""}static form(o,d){let f=-1;function p(w,S,R,P,X,te){if(w==="%%")return"%";if(d[++f]===void 0)return;w=P?parseInt(P.substr(1)):void 0;let ue=X?parseInt(X.substr(1)):void 0,je;switch(te){case"s":je=d[f];break;case"c":je=d[f][0];break;case"f":je=parseFloat(d[f]).toFixed(w);break;case"p":je=parseFloat(d[f]).toPrecision(w);break;case"e":je=parseFloat(d[f]).toExponential(w);break;case"x":je=parseInt(d[f]).toString(ue||16);break;case"d":je=parseFloat(parseInt(d[f],ue||10).toPrecision(w)).toFixed(0);break}je=typeof je=="object"?JSON.stringify(je):(+je).toString(ue);let Fe=parseInt(R),Ue=R&&R[0]+""=="0"?"0":" ";for(;je.length<Fe;)je=S!==void 0?je+Ue:Ue+je;return je}let b=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return o.replace(b,p)}format(o,...d){this.buffer+=us.form(o,d)}toString(){return this.buffer}}class Qs{constructor(o){this.boundingBox=new qn(o),this.codewords=new Array(o.getMaxY()-o.getMinY()+1)}getCodewordNearby(o){let d=this.getCodeword(o);if(d!=null)return d;for(let f=1;f<Qs.MAX_NEARBY_DISTANCE;f++){let p=this.imageRowToCodewordIndex(o)-f;if(p>=0&&(d=this.codewords[p],d!=null)||(p=this.imageRowToCodewordIndex(o)+f,p<this.codewords.length&&(d=this.codewords[p],d!=null)))return d}return null}imageRowToCodewordIndex(o){return o-this.boundingBox.getMinY()}setCodeword(o,d){this.codewords[this.imageRowToCodewordIndex(o)]=d}getCodeword(o){return this.codewords[this.imageRowToCodewordIndex(o)]}getBoundingBox(){return this.boundingBox}getCodewords(){return this.codewords}toString(){const o=new us;let d=0;for(const f of this.codewords){if(f==null){o.format("%3d: | %n",d++);continue}o.format("%3d: %3d|%3d%n",d++,f.getRowNumber(),f.getValue())}return o.toString()}}Qs.MAX_NEARBY_DISTANCE=5;class ei{constructor(){this.values=new Map}setValue(o){o=Math.trunc(o);let d=this.values.get(o);d==null&&(d=0),d++,this.values.set(o,d)}getValue(){let o=-1,d=new Array;for(const[f,p]of this.values.entries()){const b={getKey:()=>f,getValue:()=>p};b.getValue()>o?(o=b.getValue(),d=[],d.push(b.getKey())):b.getValue()===o&&d.push(b.getKey())}return cr.toIntArray(d)}getConfidence(o){return this.values.get(o)}}class ec extends Qs{constructor(o,d){super(o),this._isLeft=d}setRowNumbers(){for(let o of this.getCodewords())o!=null&&o.setRowNumberAsRowIndicatorColumn()}adjustCompleteIndicatorColumnRowNumbers(o){let d=this.getCodewords();this.setRowNumbers(),this.removeIncorrectCodewords(d,o);let f=this.getBoundingBox(),p=this._isLeft?f.getTopLeft():f.getTopRight(),b=this._isLeft?f.getBottomLeft():f.getBottomRight(),w=this.imageRowToCodewordIndex(Math.trunc(p.getY())),S=this.imageRowToCodewordIndex(Math.trunc(b.getY())),R=-1,P=1,X=0;for(let te=w;te<S;te++){if(d[te]==null)continue;let ue=d[te],je=ue.getRowNumber()-R;if(je===0)X++;else if(je===1)P=Math.max(P,X),X=1,R=ue.getRowNumber();else if(je<0||ue.getRowNumber()>=o.getRowCount()||je>te)d[te]=null;else{let Fe;P>2?Fe=(P-2)*je:Fe=je;let Ue=Fe>=te;for(let tt=1;tt<=Fe&&!Ue;tt++)Ue=d[te-tt]!=null;Ue?d[te]=null:(R=ue.getRowNumber(),X=1)}}}getRowHeights(){let o=this.getBarcodeMetadata();if(o==null)return null;this.adjustIncompleteIndicatorColumnRowNumbers(o);let d=new Int32Array(o.getRowCount());for(let f of this.getCodewords())if(f!=null){let p=f.getRowNumber();if(p>=d.length)continue;d[p]++}return d}adjustIncompleteIndicatorColumnRowNumbers(o){let d=this.getBoundingBox(),f=this._isLeft?d.getTopLeft():d.getTopRight(),p=this._isLeft?d.getBottomLeft():d.getBottomRight(),b=this.imageRowToCodewordIndex(Math.trunc(f.getY())),w=this.imageRowToCodewordIndex(Math.trunc(p.getY())),S=this.getCodewords(),R=-1;for(let P=b;P<w;P++){if(S[P]==null)continue;let X=S[P];X.setRowNumberAsRowIndicatorColumn();let te=X.getRowNumber()-R;te===0||(te===1?R=X.getRowNumber():X.getRowNumber()>=o.getRowCount()?S[P]=null:R=X.getRowNumber())}}getBarcodeMetadata(){let o=this.getCodewords(),d=new ei,f=new ei,p=new ei,b=new ei;for(let S of o){if(S==null)continue;S.setRowNumberAsRowIndicatorColumn();let R=S.getValue()%30,P=S.getRowNumber();switch(this._isLeft||(P+=2),P%3){case 0:f.setValue(R*3+1);break;case 1:b.setValue(R/3),p.setValue(R%3);break;case 2:d.setValue(R+1);break}}if(d.getValue().length===0||f.getValue().length===0||p.getValue().length===0||b.getValue().length===0||d.getValue()[0]<1||f.getValue()[0]+p.getValue()[0]<cr.MIN_ROWS_IN_BARCODE||f.getValue()[0]+p.getValue()[0]>cr.MAX_ROWS_IN_BARCODE)return null;let w=new qa(d.getValue()[0],f.getValue()[0],p.getValue()[0],b.getValue()[0]);return this.removeIncorrectCodewords(o,w),w}removeIncorrectCodewords(o,d){for(let f=0;f<o.length;f++){let p=o[f];if(o[f]==null)continue;let b=p.getValue()%30,w=p.getRowNumber();if(w>d.getRowCount()){o[f]=null;continue}switch(this._isLeft||(w+=2),w%3){case 0:b*3+1!==d.getRowCountUpperPart()&&(o[f]=null);break;case 1:(Math.trunc(b/3)!==d.getErrorCorrectionLevel()||b%3!==d.getRowCountLowerPart())&&(o[f]=null);break;case 2:b+1!==d.getColumnCount()&&(o[f]=null);break}}}isLeft(){return this._isLeft}toString(){return"IsLeft: "+this._isLeft+`
|
||
`+super.toString()}}class tn{constructor(o,d){this.ADJUST_ROW_NUMBER_SKIP=2,this.barcodeMetadata=o,this.barcodeColumnCount=o.getColumnCount(),this.boundingBox=d,this.detectionResultColumns=new Array(this.barcodeColumnCount+2)}getDetectionResultColumns(){this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]),this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount+1]);let o=cr.MAX_CODEWORDS_IN_BARCODE,d;do d=o,o=this.adjustRowNumbersAndGetCount();while(o>0&&o<d);return this.detectionResultColumns}adjustIndicatorColumnRowNumbers(o){o!=null&&o.adjustCompleteIndicatorColumnRowNumbers(this.barcodeMetadata)}adjustRowNumbersAndGetCount(){let o=this.adjustRowNumbersByRow();if(o===0)return 0;for(let d=1;d<this.barcodeColumnCount+1;d++){let f=this.detectionResultColumns[d].getCodewords();for(let p=0;p<f.length;p++)f[p]!=null&&(f[p].hasValidRowNumber()||this.adjustRowNumbers(d,p,f))}return o}adjustRowNumbersByRow(){return this.adjustRowNumbersFromBothRI(),this.adjustRowNumbersFromLRI()+this.adjustRowNumbersFromRRI()}adjustRowNumbersFromBothRI(){if(this.detectionResultColumns[0]==null||this.detectionResultColumns[this.barcodeColumnCount+1]==null)return;let o=this.detectionResultColumns[0].getCodewords(),d=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let f=0;f<o.length;f++)if(o[f]!=null&&d[f]!=null&&o[f].getRowNumber()===d[f].getRowNumber())for(let p=1;p<=this.barcodeColumnCount;p++){let b=this.detectionResultColumns[p].getCodewords()[f];b!=null&&(b.setRowNumber(o[f].getRowNumber()),b.hasValidRowNumber()||(this.detectionResultColumns[p].getCodewords()[f]=null))}}adjustRowNumbersFromRRI(){if(this.detectionResultColumns[this.barcodeColumnCount+1]==null)return 0;let o=0,d=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let f=0;f<d.length;f++){if(d[f]==null)continue;let p=d[f].getRowNumber(),b=0;for(let w=this.barcodeColumnCount+1;w>0&&b<this.ADJUST_ROW_NUMBER_SKIP;w--){let S=this.detectionResultColumns[w].getCodewords()[f];S!=null&&(b=tn.adjustRowNumberIfValid(p,b,S),S.hasValidRowNumber()||o++)}}return o}adjustRowNumbersFromLRI(){if(this.detectionResultColumns[0]==null)return 0;let o=0,d=this.detectionResultColumns[0].getCodewords();for(let f=0;f<d.length;f++){if(d[f]==null)continue;let p=d[f].getRowNumber(),b=0;for(let w=1;w<this.barcodeColumnCount+1&&b<this.ADJUST_ROW_NUMBER_SKIP;w++){let S=this.detectionResultColumns[w].getCodewords()[f];S!=null&&(b=tn.adjustRowNumberIfValid(p,b,S),S.hasValidRowNumber()||o++)}}return o}static adjustRowNumberIfValid(o,d,f){return f==null||f.hasValidRowNumber()||(f.isValidRowNumber(o)?(f.setRowNumber(o),d=0):++d),d}adjustRowNumbers(o,d,f){if(!this.detectionResultColumns[o-1])return;let p=f[d],b=this.detectionResultColumns[o-1].getCodewords(),w=b;this.detectionResultColumns[o+1]!=null&&(w=this.detectionResultColumns[o+1].getCodewords());let S=new Array(14);S[2]=b[d],S[3]=w[d],d>0&&(S[0]=f[d-1],S[4]=b[d-1],S[5]=w[d-1]),d>1&&(S[8]=f[d-2],S[10]=b[d-2],S[11]=w[d-2]),d<f.length-1&&(S[1]=f[d+1],S[6]=b[d+1],S[7]=w[d+1]),d<f.length-2&&(S[9]=f[d+2],S[12]=b[d+2],S[13]=w[d+2]);for(let R of S)if(tn.adjustRowNumber(p,R))return}static adjustRowNumber(o,d){return d==null?!1:d.hasValidRowNumber()&&d.getBucket()===o.getBucket()?(o.setRowNumber(d.getRowNumber()),!0):!1}getBarcodeColumnCount(){return this.barcodeColumnCount}getBarcodeRowCount(){return this.barcodeMetadata.getRowCount()}getBarcodeECLevel(){return this.barcodeMetadata.getErrorCorrectionLevel()}setBoundingBox(o){this.boundingBox=o}getBoundingBox(){return this.boundingBox}setDetectionResultColumn(o,d){this.detectionResultColumns[o]=d}getDetectionResultColumn(o){return this.detectionResultColumns[o]}toString(){let o=this.detectionResultColumns[0];o==null&&(o=this.detectionResultColumns[this.barcodeColumnCount+1]);let d=new us;for(let f=0;f<o.getCodewords().length;f++){d.format("CW %3d:",f);for(let p=0;p<this.barcodeColumnCount+2;p++){if(this.detectionResultColumns[p]==null){d.format(" | ");continue}let b=this.detectionResultColumns[p].getCodewords()[f];if(b==null){d.format(" | ");continue}d.format(" %3d|%3d",b.getRowNumber(),b.getValue())}d.format("%n")}return d.toString()}}class Kn{constructor(o,d,f,p){this.rowNumber=Kn.BARCODE_ROW_UNKNOWN,this.startX=Math.trunc(o),this.endX=Math.trunc(d),this.bucket=Math.trunc(f),this.value=Math.trunc(p)}hasValidRowNumber(){return this.isValidRowNumber(this.rowNumber)}isValidRowNumber(o){return o!==Kn.BARCODE_ROW_UNKNOWN&&this.bucket===o%3*3}setRowNumberAsRowIndicatorColumn(){this.rowNumber=Math.trunc(Math.trunc(this.value/30)*3+Math.trunc(this.bucket/3))}getWidth(){return this.endX-this.startX}getStartX(){return this.startX}getEndX(){return this.endX}getBucket(){return this.bucket}getValue(){return this.value}getRowNumber(){return this.rowNumber}setRowNumber(o){this.rowNumber=o}toString(){return this.rowNumber+"|"+this.value}}Kn.BARCODE_ROW_UNKNOWN=-1;class pn{static initialize(){for(let o=0;o<cr.SYMBOL_TABLE.length;o++){let d=cr.SYMBOL_TABLE[o],f=d&1;for(let p=0;p<cr.BARS_IN_MODULE;p++){let b=0;for(;(d&1)===f;)b+=1,d>>=1;f=d&1,pn.RATIOS_TABLE[o]||(pn.RATIOS_TABLE[o]=new Array(cr.BARS_IN_MODULE)),pn.RATIOS_TABLE[o][cr.BARS_IN_MODULE-p-1]=Math.fround(b/cr.MODULES_IN_CODEWORD)}}this.bSymbolTableReady=!0}static getDecodedValue(o){let d=pn.getDecodedCodewordValue(pn.sampleBitCounts(o));return d!==-1?d:pn.getClosestDecodedValue(o)}static sampleBitCounts(o){let d=$t.sum(o),f=new Int32Array(cr.BARS_IN_MODULE),p=0,b=0;for(let w=0;w<cr.MODULES_IN_CODEWORD;w++){let S=d/(2*cr.MODULES_IN_CODEWORD)+w*d/cr.MODULES_IN_CODEWORD;b+o[p]<=S&&(b+=o[p],p++),f[p]++}return f}static getDecodedCodewordValue(o){let d=pn.getBitValue(o);return cr.getCodeword(d)===-1?-1:d}static getBitValue(o){let d=0;for(let f=0;f<o.length;f++)for(let p=0;p<o[f];p++)d=d<<1|(f%2===0?1:0);return Math.trunc(d)}static getClosestDecodedValue(o){let d=$t.sum(o),f=new Array(cr.BARS_IN_MODULE);if(d>1)for(let w=0;w<f.length;w++)f[w]=Math.fround(o[w]/d);let p=Er.MAX_VALUE,b=-1;this.bSymbolTableReady||pn.initialize();for(let w=0;w<pn.RATIOS_TABLE.length;w++){let S=0,R=pn.RATIOS_TABLE[w];for(let P=0;P<cr.BARS_IN_MODULE;P++){let X=Math.fround(R[P]-f[P]);if(S+=Math.fround(X*X),S>=p)break}S<p&&(p=S,b=cr.SYMBOL_TABLE[w])}return b}}pn.bSymbolTableReady=!1,pn.RATIOS_TABLE=new Array(cr.SYMBOL_TABLE.length).map(ee=>new Array(cr.BARS_IN_MODULE));class Pi{constructor(){this.segmentCount=-1,this.fileSize=-1,this.timestamp=-1,this.checksum=-1}getSegmentIndex(){return this.segmentIndex}setSegmentIndex(o){this.segmentIndex=o}getFileId(){return this.fileId}setFileId(o){this.fileId=o}getOptionalData(){return this.optionalData}setOptionalData(o){this.optionalData=o}isLastSegment(){return this.lastSegment}setLastSegment(o){this.lastSegment=o}getSegmentCount(){return this.segmentCount}setSegmentCount(o){this.segmentCount=o}getSender(){return this.sender||null}setSender(o){this.sender=o}getAddressee(){return this.addressee||null}setAddressee(o){this.addressee=o}getFileName(){return this.fileName}setFileName(o){this.fileName=o}getFileSize(){return this.fileSize}setFileSize(o){this.fileSize=o}getChecksum(){return this.checksum}setChecksum(o){this.checksum=o}getTimestamp(){return this.timestamp}setTimestamp(o){this.timestamp=o}}class Qr{static parseLong(o,d=void 0){return parseInt(o,d)}}class fl extends x{}fl.kind="NullPointerException";class Jn{writeBytes(o){this.writeBytesOffset(o,0,o.length)}writeBytesOffset(o,d,f){if(o==null)throw new fl;if(d<0||d>o.length||f<0||d+f>o.length||d+f<0)throw new I;if(f===0)return;for(let p=0;p<f;p++)this.write(o[d+p])}flush(){}close(){}}class ti extends x{}class Ro extends Jn{constructor(o=32){if(super(),this.count=0,o<0)throw new N("Negative initial size: "+o);this.buf=new Uint8Array(o)}ensureCapacity(o){o-this.buf.length>0&&this.grow(o)}grow(o){let f=this.buf.length<<1;if(f-o<0&&(f=o),f<0){if(o<0)throw new ti;f=B.MAX_VALUE}this.buf=U.copyOfUint8Array(this.buf,f)}write(o){this.ensureCapacity(this.count+1),this.buf[this.count]=o,this.count+=1}writeBytesOffset(o,d,f){if(d<0||d>o.length||f<0||d+f-o.length>0)throw new I;this.ensureCapacity(this.count+f),A.arraycopy(o,d,this.buf,this.count,f),this.count+=f}writeTo(o){o.writeBytesOffset(this.buf,0,this.count)}reset(){this.count=0}toByteArray(){return U.copyOfUint8Array(this.buf,this.count)}size(){return this.count}toString(o){return o?typeof o=="string"?this.toString_string(o):this.toString_number(o):this.toString_void()}toString_void(){return new String(this.buf).toString()}toString_string(o){return new String(this.buf).toString()}toString_number(o){return new String(this.buf).toString()}close(){}}var ha;(function(ee){ee[ee.ALPHA=0]="ALPHA",ee[ee.LOWER=1]="LOWER",ee[ee.MIXED=2]="MIXED",ee[ee.PUNCT=3]="PUNCT",ee[ee.ALPHA_SHIFT=4]="ALPHA_SHIFT",ee[ee.PUNCT_SHIFT=5]="PUNCT_SHIFT"})(ha||(ha={}));function ml(){if(typeof window!="undefined")return window.BigInt||null;if(typeof Hh!="undefined")return Hh.BigInt||null;if(typeof self!="undefined")return self.BigInt||null;throw new Error("Can't search globals for BigInt!")}let gl;function ri(ee){if(typeof gl=="undefined"&&(gl=ml()),gl===null)throw new Error("BigInt is not supported!");return gl(ee)}function tc(){let ee=[];ee[0]=ri(1);let o=ri(900);ee[1]=o;for(let d=2;d<16;d++)ee[d]=ee[d-1]*o;return ee}class ft{static decode(o,d){let f=new ce(""),p=Q.ISO8859_1;f.enableDecoding(p);let b=1,w=o[b++],S=new Pi;for(;b<o[0];){switch(w){case ft.TEXT_COMPACTION_MODE_LATCH:b=ft.textCompaction(o,b,f);break;case ft.BYTE_COMPACTION_MODE_LATCH:case ft.BYTE_COMPACTION_MODE_LATCH_6:b=ft.byteCompaction(w,o,p,b,f);break;case ft.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:f.append(o[b++]);break;case ft.NUMERIC_COMPACTION_MODE_LATCH:b=ft.numericCompaction(o,b,f);break;case ft.ECI_CHARSET:Q.getCharacterSetECIByValue(o[b++]);break;case ft.ECI_GENERAL_PURPOSE:b+=2;break;case ft.ECI_USER_DEFINED:b++;break;case ft.BEGIN_MACRO_PDF417_CONTROL_BLOCK:b=ft.decodeMacroBlock(o,b,S);break;case ft.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case ft.MACRO_PDF417_TERMINATOR:throw new H;default:b--,b=ft.textCompaction(o,b,f);break}if(b<o.length)w=o[b++];else throw H.getFormatInstance()}if(f.length()===0)throw H.getFormatInstance();let R=new ze(null,f.toString(),null,d);return R.setOther(S),R}static decodeMacroBlock(o,d,f){if(d+ft.NUMBER_OF_SEQUENCE_CODEWORDS>o[0])throw H.getFormatInstance();let p=new Int32Array(ft.NUMBER_OF_SEQUENCE_CODEWORDS);for(let S=0;S<ft.NUMBER_OF_SEQUENCE_CODEWORDS;S++,d++)p[S]=o[d];f.setSegmentIndex(B.parseInt(ft.decodeBase900toBase10(p,ft.NUMBER_OF_SEQUENCE_CODEWORDS)));let b=new ce;d=ft.textCompaction(o,d,b),f.setFileId(b.toString());let w=-1;for(o[d]===ft.BEGIN_MACRO_PDF417_OPTIONAL_FIELD&&(w=d+1);d<o[0];)switch(o[d]){case ft.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:switch(d++,o[d]){case ft.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME:let S=new ce;d=ft.textCompaction(o,d+1,S),f.setFileName(S.toString());break;case ft.MACRO_PDF417_OPTIONAL_FIELD_SENDER:let R=new ce;d=ft.textCompaction(o,d+1,R),f.setSender(R.toString());break;case ft.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE:let P=new ce;d=ft.textCompaction(o,d+1,P),f.setAddressee(P.toString());break;case ft.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT:let X=new ce;d=ft.numericCompaction(o,d+1,X),f.setSegmentCount(B.parseInt(X.toString()));break;case ft.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP:let te=new ce;d=ft.numericCompaction(o,d+1,te),f.setTimestamp(Qr.parseLong(te.toString()));break;case ft.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM:let ue=new ce;d=ft.numericCompaction(o,d+1,ue),f.setChecksum(B.parseInt(ue.toString()));break;case ft.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE:let je=new ce;d=ft.numericCompaction(o,d+1,je),f.setFileSize(Qr.parseLong(je.toString()));break;default:throw H.getFormatInstance()}break;case ft.MACRO_PDF417_TERMINATOR:d++,f.setLastSegment(!0);break;default:throw H.getFormatInstance()}if(w!==-1){let S=d-w;f.isLastSegment()&&S--,f.setOptionalData(U.copyOfRange(o,w,w+S))}return d}static textCompaction(o,d,f){let p=new Int32Array((o[0]-d)*2),b=new Int32Array((o[0]-d)*2),w=0,S=!1;for(;d<o[0]&&!S;){let R=o[d++];if(R<ft.TEXT_COMPACTION_MODE_LATCH)p[w]=R/30,p[w+1]=R%30,w+=2;else switch(R){case ft.TEXT_COMPACTION_MODE_LATCH:p[w++]=ft.TEXT_COMPACTION_MODE_LATCH;break;case ft.BYTE_COMPACTION_MODE_LATCH:case ft.BYTE_COMPACTION_MODE_LATCH_6:case ft.NUMERIC_COMPACTION_MODE_LATCH:case ft.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case ft.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case ft.MACRO_PDF417_TERMINATOR:d--,S=!0;break;case ft.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:p[w]=ft.MODE_SHIFT_TO_BYTE_COMPACTION_MODE,R=o[d++],b[w]=R,w++;break}}return ft.decodeTextCompaction(p,b,w,f),d}static decodeTextCompaction(o,d,f,p){let b=ha.ALPHA,w=ha.ALPHA,S=0;for(;S<f;){let R=o[S],P="";switch(b){case ha.ALPHA:if(R<26)P=String.fromCharCode(65+R);else switch(R){case 26:P=" ";break;case ft.LL:b=ha.LOWER;break;case ft.ML:b=ha.MIXED;break;case ft.PS:w=b,b=ha.PUNCT_SHIFT;break;case ft.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:p.append(d[S]);break;case ft.TEXT_COMPACTION_MODE_LATCH:b=ha.ALPHA;break}break;case ha.LOWER:if(R<26)P=String.fromCharCode(97+R);else switch(R){case 26:P=" ";break;case ft.AS:w=b,b=ha.ALPHA_SHIFT;break;case ft.ML:b=ha.MIXED;break;case ft.PS:w=b,b=ha.PUNCT_SHIFT;break;case ft.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:p.append(d[S]);break;case ft.TEXT_COMPACTION_MODE_LATCH:b=ha.ALPHA;break}break;case ha.MIXED:if(R<ft.PL)P=ft.MIXED_CHARS[R];else switch(R){case ft.PL:b=ha.PUNCT;break;case 26:P=" ";break;case ft.LL:b=ha.LOWER;break;case ft.AL:b=ha.ALPHA;break;case ft.PS:w=b,b=ha.PUNCT_SHIFT;break;case ft.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:p.append(d[S]);break;case ft.TEXT_COMPACTION_MODE_LATCH:b=ha.ALPHA;break}break;case ha.PUNCT:if(R<ft.PAL)P=ft.PUNCT_CHARS[R];else switch(R){case ft.PAL:b=ha.ALPHA;break;case ft.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:p.append(d[S]);break;case ft.TEXT_COMPACTION_MODE_LATCH:b=ha.ALPHA;break}break;case ha.ALPHA_SHIFT:if(b=w,R<26)P=String.fromCharCode(65+R);else switch(R){case 26:P=" ";break;case ft.TEXT_COMPACTION_MODE_LATCH:b=ha.ALPHA;break}break;case ha.PUNCT_SHIFT:if(b=w,R<ft.PAL)P=ft.PUNCT_CHARS[R];else switch(R){case ft.PAL:b=ha.ALPHA;break;case ft.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:p.append(d[S]);break;case ft.TEXT_COMPACTION_MODE_LATCH:b=ha.ALPHA;break}break}P!==""&&p.append(P),S++}}static byteCompaction(o,d,f,p,b){let w=new Ro,S=0,R=0,P=!1;switch(o){case ft.BYTE_COMPACTION_MODE_LATCH:let X=new Int32Array(6),te=d[p++];for(;p<d[0]&&!P;)switch(X[S++]=te,R=900*R+te,te=d[p++],te){case ft.TEXT_COMPACTION_MODE_LATCH:case ft.BYTE_COMPACTION_MODE_LATCH:case ft.NUMERIC_COMPACTION_MODE_LATCH:case ft.BYTE_COMPACTION_MODE_LATCH_6:case ft.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case ft.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case ft.MACRO_PDF417_TERMINATOR:p--,P=!0;break;default:if(S%5===0&&S>0){for(let ue=0;ue<6;++ue)w.write(Number(ri(R)>>ri(8*(5-ue))));R=0,S=0}break}p===d[0]&&te<ft.TEXT_COMPACTION_MODE_LATCH&&(X[S++]=te);for(let ue=0;ue<S;ue++)w.write(X[ue]);break;case ft.BYTE_COMPACTION_MODE_LATCH_6:for(;p<d[0]&&!P;){let ue=d[p++];if(ue<ft.TEXT_COMPACTION_MODE_LATCH)S++,R=900*R+ue;else switch(ue){case ft.TEXT_COMPACTION_MODE_LATCH:case ft.BYTE_COMPACTION_MODE_LATCH:case ft.NUMERIC_COMPACTION_MODE_LATCH:case ft.BYTE_COMPACTION_MODE_LATCH_6:case ft.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case ft.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case ft.MACRO_PDF417_TERMINATOR:p--,P=!0;break}if(S%5===0&&S>0){for(let je=0;je<6;++je)w.write(Number(ri(R)>>ri(8*(5-je))));R=0,S=0}}break}return b.append(oe.decode(w.toByteArray(),f)),p}static numericCompaction(o,d,f){let p=0,b=!1,w=new Int32Array(ft.MAX_NUMERIC_CODEWORDS);for(;d<o[0]&&!b;){let S=o[d++];if(d===o[0]&&(b=!0),S<ft.TEXT_COMPACTION_MODE_LATCH)w[p]=S,p++;else switch(S){case ft.TEXT_COMPACTION_MODE_LATCH:case ft.BYTE_COMPACTION_MODE_LATCH:case ft.BYTE_COMPACTION_MODE_LATCH_6:case ft.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case ft.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case ft.MACRO_PDF417_TERMINATOR:d--,b=!0;break}(p%ft.MAX_NUMERIC_CODEWORDS===0||S===ft.NUMERIC_COMPACTION_MODE_LATCH||b)&&p>0&&(f.append(ft.decodeBase900toBase10(w,p)),p=0)}return d}static decodeBase900toBase10(o,d){let f=ri(0);for(let b=0;b<d;b++)f+=ft.EXP900[d-b-1]*ri(o[b]);let p=f.toString();if(p.charAt(0)!=="1")throw new H;return p.substring(1)}}ft.TEXT_COMPACTION_MODE_LATCH=900,ft.BYTE_COMPACTION_MODE_LATCH=901,ft.NUMERIC_COMPACTION_MODE_LATCH=902,ft.BYTE_COMPACTION_MODE_LATCH_6=924,ft.ECI_USER_DEFINED=925,ft.ECI_GENERAL_PURPOSE=926,ft.ECI_CHARSET=927,ft.BEGIN_MACRO_PDF417_CONTROL_BLOCK=928,ft.BEGIN_MACRO_PDF417_OPTIONAL_FIELD=923,ft.MACRO_PDF417_TERMINATOR=922,ft.MODE_SHIFT_TO_BYTE_COMPACTION_MODE=913,ft.MAX_NUMERIC_CODEWORDS=15,ft.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME=0,ft.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT=1,ft.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP=2,ft.MACRO_PDF417_OPTIONAL_FIELD_SENDER=3,ft.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE=4,ft.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE=5,ft.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM=6,ft.PL=25,ft.LL=27,ft.AS=27,ft.ML=28,ft.AL=28,ft.PS=29,ft.PAL=29,ft.PUNCT_CHARS=`;<>@[\\]_\`~!\r ,:
|
||
-.$/"|*()?{}'`,ft.MIXED_CHARS="0123456789&\r ,:#-.$/+%*=^",ft.EXP900=ml()?tc():[],ft.NUMBER_OF_SEQUENCE_CODEWORDS=2;class Hr{constructor(){}static decode(o,d,f,p,b,w,S){let R=new qn(o,d,f,p,b),P=null,X=null,te;for(let Fe=!0;;Fe=!1){if(d!=null&&(P=Hr.getRowIndicatorColumn(o,R,d,!0,w,S)),p!=null&&(X=Hr.getRowIndicatorColumn(o,R,p,!1,w,S)),te=Hr.merge(P,X),te==null)throw ae.getNotFoundInstance();let Ue=te.getBoundingBox();if(Fe&&Ue!=null&&(Ue.getMinY()<R.getMinY()||Ue.getMaxY()>R.getMaxY()))R=Ue;else break}te.setBoundingBox(R);let ue=te.getBarcodeColumnCount()+1;te.setDetectionResultColumn(0,P),te.setDetectionResultColumn(ue,X);let je=P!=null;for(let Fe=1;Fe<=ue;Fe++){let Ue=je?Fe:ue-Fe;if(te.getDetectionResultColumn(Ue)!==void 0)continue;let tt;Ue===0||Ue===ue?tt=new ec(R,Ue===0):tt=new Qs(R),te.setDetectionResultColumn(Ue,tt);let ut=-1,Xt=ut;for(let Gt=R.getMinY();Gt<=R.getMaxY();Gt++){if(ut=Hr.getStartColumn(te,Ue,Gt,je),ut<0||ut>R.getMaxX()){if(Xt===-1)continue;ut=Xt}let Ft=Hr.detectCodeword(o,R.getMinX(),R.getMaxX(),je,ut,Gt,w,S);Ft!=null&&(tt.setCodeword(Gt,Ft),Xt=ut,w=Math.min(w,Ft.getWidth()),S=Math.max(S,Ft.getWidth()))}}return Hr.createDecoderResult(te)}static merge(o,d){if(o==null&&d==null)return null;let f=Hr.getBarcodeMetadata(o,d);if(f==null)return null;let p=qn.merge(Hr.adjustBoundingBox(o),Hr.adjustBoundingBox(d));return new tn(f,p)}static adjustBoundingBox(o){if(o==null)return null;let d=o.getRowHeights();if(d==null)return null;let f=Hr.getMax(d),p=0;for(let S of d)if(p+=f-S,S>0)break;let b=o.getCodewords();for(let S=0;p>0&&b[S]==null;S++)p--;let w=0;for(let S=d.length-1;S>=0&&(w+=f-d[S],!(d[S]>0));S--);for(let S=b.length-1;w>0&&b[S]==null;S--)w--;return o.getBoundingBox().addMissingRows(p,w,o.isLeft())}static getMax(o){let d=-1;for(let f of o)d=Math.max(d,f);return d}static getBarcodeMetadata(o,d){let f;if(o==null||(f=o.getBarcodeMetadata())==null)return d==null?null:d.getBarcodeMetadata();let p;return d==null||(p=d.getBarcodeMetadata())==null?f:f.getColumnCount()!==p.getColumnCount()&&f.getErrorCorrectionLevel()!==p.getErrorCorrectionLevel()&&f.getRowCount()!==p.getRowCount()?null:f}static getRowIndicatorColumn(o,d,f,p,b,w){let S=new ec(d,p);for(let R=0;R<2;R++){let P=R===0?1:-1,X=Math.trunc(Math.trunc(f.getX()));for(let te=Math.trunc(Math.trunc(f.getY()));te<=d.getMaxY()&&te>=d.getMinY();te+=P){let ue=Hr.detectCodeword(o,0,o.getWidth(),p,X,te,b,w);ue!=null&&(S.setCodeword(te,ue),p?X=ue.getStartX():X=ue.getEndX())}}return S}static adjustCodewordCount(o,d){let f=d[0][1],p=f.getValue(),b=o.getBarcodeColumnCount()*o.getBarcodeRowCount()-Hr.getNumberOfECCodeWords(o.getBarcodeECLevel());if(p.length===0){if(b<1||b>cr.MAX_CODEWORDS_IN_BARCODE)throw ae.getNotFoundInstance();f.setValue(b)}else p[0]!==b&&f.setValue(b)}static createDecoderResult(o){let d=Hr.createBarcodeMatrix(o);Hr.adjustCodewordCount(o,d);let f=new Array,p=new Int32Array(o.getBarcodeRowCount()*o.getBarcodeColumnCount()),b=[],w=new Array;for(let R=0;R<o.getBarcodeRowCount();R++)for(let P=0;P<o.getBarcodeColumnCount();P++){let X=d[R][P+1].getValue(),te=R*o.getBarcodeColumnCount()+P;X.length===0?f.push(te):X.length===1?p[te]=X[0]:(w.push(te),b.push(X))}let S=new Array(b.length);for(let R=0;R<S.length;R++)S[R]=b[R];return Hr.createDecoderResultFromAmbiguousValues(o.getBarcodeECLevel(),p,cr.toIntArray(f),cr.toIntArray(w),S)}static createDecoderResultFromAmbiguousValues(o,d,f,p,b){let w=new Int32Array(p.length),S=100;for(;S-- >0;){for(let R=0;R<w.length;R++)d[p[R]]=b[R][w[R]];try{return Hr.decodeCodewords(d,o,f)}catch(R){if(!(R instanceof O))throw R}if(w.length===0)throw O.getChecksumInstance();for(let R=0;R<w.length;R++)if(w[R]<b[R].length-1){w[R]++;break}else if(w[R]=0,R===w.length-1)throw O.getChecksumInstance()}throw O.getChecksumInstance()}static createBarcodeMatrix(o){let d=Array.from({length:o.getBarcodeRowCount()},()=>new Array(o.getBarcodeColumnCount()+2));for(let p=0;p<d.length;p++)for(let b=0;b<d[p].length;b++)d[p][b]=new ei;let f=0;for(let p of o.getDetectionResultColumns()){if(p!=null){for(let b of p.getCodewords())if(b!=null){let w=b.getRowNumber();if(w>=0){if(w>=d.length)continue;d[w][f].setValue(b.getValue())}}}f++}return d}static isValidBarcodeColumn(o,d){return d>=0&&d<=o.getBarcodeColumnCount()+1}static getStartColumn(o,d,f,p){let b=p?1:-1,w=null;if(Hr.isValidBarcodeColumn(o,d-b)&&(w=o.getDetectionResultColumn(d-b).getCodeword(f)),w!=null)return p?w.getEndX():w.getStartX();if(w=o.getDetectionResultColumn(d).getCodewordNearby(f),w!=null)return p?w.getStartX():w.getEndX();if(Hr.isValidBarcodeColumn(o,d-b)&&(w=o.getDetectionResultColumn(d-b).getCodewordNearby(f)),w!=null)return p?w.getEndX():w.getStartX();let S=0;for(;Hr.isValidBarcodeColumn(o,d-b);){d-=b;for(let R of o.getDetectionResultColumn(d).getCodewords())if(R!=null)return(p?R.getEndX():R.getStartX())+b*S*(R.getEndX()-R.getStartX());S++}return p?o.getBoundingBox().getMinX():o.getBoundingBox().getMaxX()}static detectCodeword(o,d,f,p,b,w,S,R){b=Hr.adjustCodewordStartColumn(o,d,f,p,b,w);let P=Hr.getModuleBitCount(o,d,f,p,b,w);if(P==null)return null;let X,te=$t.sum(P);if(p)X=b+te;else{for(let Fe=0;Fe<P.length/2;Fe++){let Ue=P[Fe];P[Fe]=P[P.length-1-Fe],P[P.length-1-Fe]=Ue}X=b,b=X-te}if(!Hr.checkCodewordSkew(te,S,R))return null;let ue=pn.getDecodedValue(P),je=cr.getCodeword(ue);return je===-1?null:new Kn(b,X,Hr.getCodewordBucketNumber(ue),je)}static getModuleBitCount(o,d,f,p,b,w){let S=b,R=new Int32Array(8),P=0,X=p?1:-1,te=p;for(;(p?S<f:S>=d)&&P<R.length;)o.get(S,w)===te?(R[P]++,S+=X):(P++,te=!te);return P===R.length||S===(p?f:d)&&P===R.length-1?R:null}static getNumberOfECCodeWords(o){return 2<<o}static adjustCodewordStartColumn(o,d,f,p,b,w){let S=b,R=p?-1:1;for(let P=0;P<2;P++){for(;(p?S>=d:S<f)&&p===o.get(S,w);){if(Math.abs(b-S)>Hr.CODEWORD_SKEW_SIZE)return b;S+=R}R=-R,p=!p}return S}static checkCodewordSkew(o,d,f){return d-Hr.CODEWORD_SKEW_SIZE<=o&&o<=f+Hr.CODEWORD_SKEW_SIZE}static decodeCodewords(o,d,f){if(o.length===0)throw H.getFormatInstance();let p=1<<d+1,b=Hr.correctErrors(o,f,p);Hr.verifyCodewordCount(o,p);let w=ft.decode(o,""+d);return w.setErrorsCorrected(b),w.setErasures(f.length),w}static correctErrors(o,d,f){if(d!=null&&d.length>f/2+Hr.MAX_ERRORS||f<0||f>Hr.MAX_EC_CODEWORDS)throw O.getChecksumInstance();return Hr.errorCorrection.decode(o,f,d)}static verifyCodewordCount(o,d){if(o.length<4)throw H.getFormatInstance();let f=o[0];if(f>o.length)throw H.getFormatInstance();if(f===0)if(d<o.length)o[0]=o.length-d;else throw H.getFormatInstance()}static getBitCountForCodeword(o){let d=new Int32Array(8),f=0,p=d.length-1;for(;!((o&1)!==f&&(f=o&1,p--,p<0));)d[p]++,o>>=1;return d}static getCodewordBucketNumber(o){return o instanceof Int32Array?this.getCodewordBucketNumber_Int32Array(o):this.getCodewordBucketNumber_number(o)}static getCodewordBucketNumber_number(o){return Hr.getCodewordBucketNumber(Hr.getBitCountForCodeword(o))}static getCodewordBucketNumber_Int32Array(o){return(o[0]-o[2]+o[4]-o[6]+9)%9}static toString(o){let d=new us;for(let f=0;f<o.length;f++){d.format("Row %2d: ",f);for(let p=0;p<o[f].length;p++){let b=o[f][p];b.getValue().length===0?d.format(" ",null):d.format("%4d(%2d)",b.getValue()[0],b.getConfidence(b.getValue()[0]))}d.format("%n")}return d.toString()}}Hr.CODEWORD_SKEW_SIZE=2,Hr.MAX_ERRORS=3,Hr.MAX_EC_CODEWORDS=512,Hr.errorCorrection=new ws;class yn{decode(o,d=null){let f=yn.decode(o,d,!1);if(f==null||f.length===0||f[0]==null)throw ae.getNotFoundInstance();return f[0]}decodeMultiple(o,d=null){try{return yn.decode(o,d,!0)}catch(f){throw f instanceof H||f instanceof O?ae.getNotFoundInstance():f}}static decode(o,d,f){const p=new Array,b=Fr.detectMultiple(o,d,f);for(const w of b.getPoints()){const S=Hr.decode(b.getBits(),w[4],w[5],w[6],w[7],yn.getMinCodewordWidth(w),yn.getMaxCodewordWidth(w)),R=new re(S.getText(),S.getRawBytes(),void 0,w,ve.PDF_417);R.putMetadata(Ae.ERROR_CORRECTION_LEVEL,S.getECLevel());const P=S.getOther();P!=null&&R.putMetadata(Ae.PDF417_EXTRA_METADATA,P),p.push(R)}return p.map(w=>w)}static getMaxWidth(o,d){return o==null||d==null?0:Math.trunc(Math.abs(o.getX()-d.getX()))}static getMinWidth(o,d){return o==null||d==null?B.MAX_VALUE:Math.trunc(Math.abs(o.getX()-d.getX()))}static getMaxCodewordWidth(o){return Math.floor(Math.max(Math.max(yn.getMaxWidth(o[0],o[4]),yn.getMaxWidth(o[6],o[2])*cr.MODULES_IN_CODEWORD/cr.MODULES_IN_STOP_PATTERN),Math.max(yn.getMaxWidth(o[1],o[5]),yn.getMaxWidth(o[7],o[3])*cr.MODULES_IN_CODEWORD/cr.MODULES_IN_STOP_PATTERN)))}static getMinCodewordWidth(o){return Math.floor(Math.min(Math.min(yn.getMinWidth(o[0],o[4]),yn.getMinWidth(o[6],o[2])*cr.MODULES_IN_CODEWORD/cr.MODULES_IN_STOP_PATTERN),Math.min(yn.getMinWidth(o[1],o[5]),yn.getMinWidth(o[7],o[3])*cr.MODULES_IN_CODEWORD/cr.MODULES_IN_STOP_PATTERN)))}reset(){}}class Qn extends x{}Qn.kind="ReaderException";class Bc{constructor(o,d){this.verbose=o===!0,d&&this.setHints(d)}decode(o,d){return d&&this.setHints(d),this.decodeInternal(o)}decodeWithState(o){return(this.readers===null||this.readers===void 0)&&this.setHints(null),this.decodeInternal(o)}setHints(o){this.hints=o;const d=!n(o)&&o.get(W.TRY_HARDER)===!0,f=n(o)?null:o.get(W.POSSIBLE_FORMATS),p=new Array;if(!n(f)){const b=f.some(w=>w===ve.UPC_A||w===ve.UPC_E||w===ve.EAN_13||w===ve.EAN_8||w===ve.CODABAR||w===ve.CODE_39||w===ve.CODE_93||w===ve.CODE_128||w===ve.ITF||w===ve.RSS_14||w===ve.RSS_EXPANDED);b&&!d&&p.push(new qr(o,this.verbose)),f.includes(ve.QR_CODE)&&p.push(new on),f.includes(ve.DATA_MATRIX)&&p.push(new Jr),f.includes(ve.AZTEC)&&p.push(new Wt),f.includes(ve.PDF_417)&&p.push(new yn),b&&d&&p.push(new qr(o,this.verbose))}p.length===0&&(d||p.push(new qr(o,this.verbose)),p.push(new on),p.push(new Jr),p.push(new Wt),p.push(new yn),d&&p.push(new qr(o,this.verbose))),this.readers=p}reset(){if(this.readers!==null)for(const o of this.readers)o.reset()}decodeInternal(o){if(this.readers===null)throw new Qn("No readers where selected, nothing can be read.");for(const d of this.readers)try{return d.decode(o,this.hints)}catch(f){if(f instanceof Qn)continue}throw new ae("No MultiFormat Readers were able to detect the code.")}}class rc extends ie{constructor(o=null,d=500){const f=new Bc;f.setHints(o),super(f,d)}decodeBitmap(o){return this.reader.decodeWithState(o)}}class _i extends ie{constructor(o=500){super(new yn,o)}}class Uc extends ie{constructor(o=500){super(new on,o)}}var xl;(function(ee){ee[ee.ERROR_CORRECTION=0]="ERROR_CORRECTION",ee[ee.CHARACTER_SET=1]="CHARACTER_SET",ee[ee.DATA_MATRIX_SHAPE=2]="DATA_MATRIX_SHAPE",ee[ee.MIN_SIZE=3]="MIN_SIZE",ee[ee.MAX_SIZE=4]="MAX_SIZE",ee[ee.MARGIN=5]="MARGIN",ee[ee.PDF417_COMPACT=6]="PDF417_COMPACT",ee[ee.PDF417_COMPACTION=7]="PDF417_COMPACTION",ee[ee.PDF417_DIMENSIONS=8]="PDF417_DIMENSIONS",ee[ee.AZTEC_LAYERS=9]="AZTEC_LAYERS",ee[ee.QR_VERSION=10]="QR_VERSION"})(xl||(xl={}));var Ga=xl;class Mo{constructor(o){this.field=o,this.cachedGenerators=[],this.cachedGenerators.push(new Ze(o,Int32Array.from([1])))}buildGenerator(o){const d=this.cachedGenerators;if(o>=d.length){let f=d[d.length-1];const p=this.field;for(let b=d.length;b<=o;b++){const w=f.multiply(new Ze(p,Int32Array.from([1,p.exp(b-1+p.getGeneratorBase())])));d.push(w),f=w}}return d[o]}encode(o,d){if(d===0)throw new N("No error correction bytes");const f=o.length-d;if(f<=0)throw new N("No data bytes provided");const p=this.buildGenerator(d),b=new Int32Array(f);A.arraycopy(o,0,b,0,f);let w=new Ze(this.field,b);w=w.multiplyByMonomial(d,1);const R=w.divide(p)[1].getCoefficients(),P=d-R.length;for(let X=0;X<P;X++)o[f+X]=0;A.arraycopy(R,0,o,f+P,R.length)}}class Ha{constructor(){}static applyMaskPenaltyRule1(o){return Ha.applyMaskPenaltyRule1Internal(o,!0)+Ha.applyMaskPenaltyRule1Internal(o,!1)}static applyMaskPenaltyRule2(o){let d=0;const f=o.getArray(),p=o.getWidth(),b=o.getHeight();for(let w=0;w<b-1;w++){const S=f[w];for(let R=0;R<p-1;R++){const P=S[R];P===S[R+1]&&P===f[w+1][R]&&P===f[w+1][R+1]&&d++}}return Ha.N2*d}static applyMaskPenaltyRule3(o){let d=0;const f=o.getArray(),p=o.getWidth(),b=o.getHeight();for(let w=0;w<b;w++)for(let S=0;S<p;S++){const R=f[w];S+6<p&&R[S]===1&&R[S+1]===0&&R[S+2]===1&&R[S+3]===1&&R[S+4]===1&&R[S+5]===0&&R[S+6]===1&&(Ha.isWhiteHorizontal(R,S-4,S)||Ha.isWhiteHorizontal(R,S+7,S+11))&&d++,w+6<b&&f[w][S]===1&&f[w+1][S]===0&&f[w+2][S]===1&&f[w+3][S]===1&&f[w+4][S]===1&&f[w+5][S]===0&&f[w+6][S]===1&&(Ha.isWhiteVertical(f,S,w-4,w)||Ha.isWhiteVertical(f,S,w+7,w+11))&&d++}return d*Ha.N3}static isWhiteHorizontal(o,d,f){d=Math.max(d,0),f=Math.min(f,o.length);for(let p=d;p<f;p++)if(o[p]===1)return!1;return!0}static isWhiteVertical(o,d,f,p){f=Math.max(f,0),p=Math.min(p,o.length);for(let b=f;b<p;b++)if(o[b][d]===1)return!1;return!0}static applyMaskPenaltyRule4(o){let d=0;const f=o.getArray(),p=o.getWidth(),b=o.getHeight();for(let R=0;R<b;R++){const P=f[R];for(let X=0;X<p;X++)P[X]===1&&d++}const w=o.getHeight()*o.getWidth();return Math.floor(Math.abs(d*2-w)*10/w)*Ha.N4}static getDataMaskBit(o,d,f){let p,b;switch(o){case 0:p=f+d&1;break;case 1:p=f&1;break;case 2:p=d%3;break;case 3:p=(f+d)%3;break;case 4:p=Math.floor(f/2)+Math.floor(d/3)&1;break;case 5:b=f*d,p=(b&1)+b%3;break;case 6:b=f*d,p=(b&1)+b%3&1;break;case 7:b=f*d,p=b%3+(f+d&1)&1;break;default:throw new N("Invalid mask pattern: "+o)}return p===0}static applyMaskPenaltyRule1Internal(o,d){let f=0;const p=d?o.getHeight():o.getWidth(),b=d?o.getWidth():o.getHeight(),w=o.getArray();for(let S=0;S<p;S++){let R=0,P=-1;for(let X=0;X<b;X++){const te=d?w[S][X]:w[X][S];te===P?R++:(R>=5&&(f+=Ha.N1+(R-5)),R=1,P=te)}R>=5&&(f+=Ha.N1+(R-5))}return f}}Ha.N1=3,Ha.N2=3,Ha.N3=40,Ha.N4=10;class Do{constructor(o,d){this.width=o,this.height=d;const f=new Array(d);for(let p=0;p!==d;p++)f[p]=new Uint8Array(o);this.bytes=f}getHeight(){return this.height}getWidth(){return this.width}get(o,d){return this.bytes[d][o]}getArray(){return this.bytes}setNumber(o,d,f){this.bytes[d][o]=f}setBoolean(o,d,f){this.bytes[d][o]=f?1:0}clear(o){for(const d of this.bytes)U.fill(d,o)}equals(o){if(!(o instanceof Do))return!1;const d=o;if(this.width!==d.width||this.height!==d.height)return!1;for(let f=0,p=this.height;f<p;++f){const b=this.bytes[f],w=d.bytes[f];for(let S=0,R=this.width;S<R;++S)if(b[S]!==w[S])return!1}return!0}toString(){const o=new ce;for(let d=0,f=this.height;d<f;++d){const p=this.bytes[d];for(let b=0,w=this.width;b<w;++b)switch(p[b]){case 0:o.append(" 0");break;case 1:o.append(" 1");break;default:o.append(" ");break}o.append(`
|
||
`)}return o.toString()}}class Fi{constructor(){this.maskPattern=-1}getMode(){return this.mode}getECLevel(){return this.ecLevel}getVersion(){return this.version}getMaskPattern(){return this.maskPattern}getMatrix(){return this.matrix}toString(){const o=new ce;return o.append(`<<
|
||
`),o.append(" mode: "),o.append(this.mode?this.mode.toString():"null"),o.append(`
|
||
ecLevel: `),o.append(this.ecLevel?this.ecLevel.toString():"null"),o.append(`
|
||
version: `),o.append(this.version?this.version.toString():"null"),o.append(`
|
||
maskPattern: `),o.append(this.maskPattern.toString()),this.matrix?(o.append(`
|
||
matrix:
|
||
`),o.append(this.matrix.toString())):o.append(`
|
||
matrix: null
|
||
`),o.append(`>>
|
||
`),o.toString()}setMode(o){this.mode=o}setECLevel(o){this.ecLevel=o}setVersion(o){this.version=o}setMaskPattern(o){this.maskPattern=o}setMatrix(o){this.matrix=o}static isValidMaskPattern(o){return o>=0&&o<Fi.NUM_MASK_PATTERNS}}Fi.NUM_MASK_PATTERNS=8;class ga extends x{}ga.kind="WriterException";class Or{constructor(){}static clearMatrix(o){o.clear(255)}static buildMatrix(o,d,f,p,b){Or.clearMatrix(b),Or.embedBasicPatterns(f,b),Or.embedTypeInfo(d,p,b),Or.maybeEmbedVersionInfo(f,b),Or.embedDataBits(o,p,b)}static embedBasicPatterns(o,d){Or.embedPositionDetectionPatternsAndSeparators(d),Or.embedDarkDotAtLeftBottomCorner(d),Or.maybeEmbedPositionAdjustmentPatterns(o,d),Or.embedTimingPatterns(d)}static embedTypeInfo(o,d,f){const p=new V;Or.makeTypeInfoBits(o,d,p);for(let b=0,w=p.getSize();b<w;++b){const S=p.get(p.getSize()-1-b),R=Or.TYPE_INFO_COORDINATES[b],P=R[0],X=R[1];if(f.setBoolean(P,X,S),b<8){const te=f.getWidth()-b-1;f.setBoolean(te,8,S)}else{const ue=f.getHeight()-7+(b-8);f.setBoolean(8,ue,S)}}}static maybeEmbedVersionInfo(o,d){if(o.getVersionNumber()<7)return;const f=new V;Or.makeVersionInfoBits(o,f);let p=17;for(let b=0;b<6;++b)for(let w=0;w<3;++w){const S=f.get(p);p--,d.setBoolean(b,d.getHeight()-11+w,S),d.setBoolean(d.getHeight()-11+w,b,S)}}static embedDataBits(o,d,f){let p=0,b=-1,w=f.getWidth()-1,S=f.getHeight()-1;for(;w>0;){for(w===6&&(w-=1);S>=0&&S<f.getHeight();){for(let R=0;R<2;++R){const P=w-R;if(!Or.isEmpty(f.get(P,S)))continue;let X;p<o.getSize()?(X=o.get(p),++p):X=!1,d!==255&&Ha.getDataMaskBit(d,P,S)&&(X=!X),f.setBoolean(P,S,X)}S+=b}b=-b,S+=b,w-=2}if(p!==o.getSize())throw new ga("Not all bits consumed: "+p+"/"+o.getSize())}static findMSBSet(o){return 32-B.numberOfLeadingZeros(o)}static calculateBCHCode(o,d){if(d===0)throw new N("0 polynomial");const f=Or.findMSBSet(d);for(o<<=f-1;Or.findMSBSet(o)>=f;)o^=d<<Or.findMSBSet(o)-f;return o}static makeTypeInfoBits(o,d,f){if(!Fi.isValidMaskPattern(d))throw new ga("Invalid mask pattern");const p=o.getBits()<<3|d;f.appendBits(p,5);const b=Or.calculateBCHCode(p,Or.TYPE_INFO_POLY);f.appendBits(b,10);const w=new V;if(w.appendBits(Or.TYPE_INFO_MASK_PATTERN,15),f.xor(w),f.getSize()!==15)throw new ga("should not happen but we got: "+f.getSize())}static makeVersionInfoBits(o,d){d.appendBits(o.getVersionNumber(),6);const f=Or.calculateBCHCode(o.getVersionNumber(),Or.VERSION_INFO_POLY);if(d.appendBits(f,12),d.getSize()!==18)throw new ga("should not happen but we got: "+d.getSize())}static isEmpty(o){return o===255}static embedTimingPatterns(o){for(let d=8;d<o.getWidth()-8;++d){const f=(d+1)%2;Or.isEmpty(o.get(d,6))&&o.setNumber(d,6,f),Or.isEmpty(o.get(6,d))&&o.setNumber(6,d,f)}}static embedDarkDotAtLeftBottomCorner(o){if(o.get(8,o.getHeight()-8)===0)throw new ga;o.setNumber(8,o.getHeight()-8,1)}static embedHorizontalSeparationPattern(o,d,f){for(let p=0;p<8;++p){if(!Or.isEmpty(f.get(o+p,d)))throw new ga;f.setNumber(o+p,d,0)}}static embedVerticalSeparationPattern(o,d,f){for(let p=0;p<7;++p){if(!Or.isEmpty(f.get(o,d+p)))throw new ga;f.setNumber(o,d+p,0)}}static embedPositionAdjustmentPattern(o,d,f){for(let p=0;p<5;++p){const b=Or.POSITION_ADJUSTMENT_PATTERN[p];for(let w=0;w<5;++w)f.setNumber(o+w,d+p,b[w])}}static embedPositionDetectionPattern(o,d,f){for(let p=0;p<7;++p){const b=Or.POSITION_DETECTION_PATTERN[p];for(let w=0;w<7;++w)f.setNumber(o+w,d+p,b[w])}}static embedPositionDetectionPatternsAndSeparators(o){const d=Or.POSITION_DETECTION_PATTERN[0].length;Or.embedPositionDetectionPattern(0,0,o),Or.embedPositionDetectionPattern(o.getWidth()-d,0,o),Or.embedPositionDetectionPattern(0,o.getWidth()-d,o);const f=8;Or.embedHorizontalSeparationPattern(0,f-1,o),Or.embedHorizontalSeparationPattern(o.getWidth()-f,f-1,o),Or.embedHorizontalSeparationPattern(0,o.getWidth()-f,o);const p=7;Or.embedVerticalSeparationPattern(p,0,o),Or.embedVerticalSeparationPattern(o.getHeight()-p-1,0,o),Or.embedVerticalSeparationPattern(p,o.getHeight()-p,o)}static maybeEmbedPositionAdjustmentPatterns(o,d){if(o.getVersionNumber()<2)return;const f=o.getVersionNumber()-1,p=Or.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[f];for(let b=0,w=p.length;b!==w;b++){const S=p[b];if(S>=0)for(let R=0;R!==w;R++){const P=p[R];P>=0&&Or.isEmpty(d.get(P,S))&&Or.embedPositionAdjustmentPattern(P-2,S-2,d)}}}}Or.POSITION_DETECTION_PATTERN=Array.from([Int32Array.from([1,1,1,1,1,1,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,1,1,1,1,1,1])]),Or.POSITION_ADJUSTMENT_PATTERN=Array.from([Int32Array.from([1,1,1,1,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,0,1,0,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,1,1,1,1])]),Or.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE=Array.from([Int32Array.from([-1,-1,-1,-1,-1,-1,-1]),Int32Array.from([6,18,-1,-1,-1,-1,-1]),Int32Array.from([6,22,-1,-1,-1,-1,-1]),Int32Array.from([6,26,-1,-1,-1,-1,-1]),Int32Array.from([6,30,-1,-1,-1,-1,-1]),Int32Array.from([6,34,-1,-1,-1,-1,-1]),Int32Array.from([6,22,38,-1,-1,-1,-1]),Int32Array.from([6,24,42,-1,-1,-1,-1]),Int32Array.from([6,26,46,-1,-1,-1,-1]),Int32Array.from([6,28,50,-1,-1,-1,-1]),Int32Array.from([6,30,54,-1,-1,-1,-1]),Int32Array.from([6,32,58,-1,-1,-1,-1]),Int32Array.from([6,34,62,-1,-1,-1,-1]),Int32Array.from([6,26,46,66,-1,-1,-1]),Int32Array.from([6,26,48,70,-1,-1,-1]),Int32Array.from([6,26,50,74,-1,-1,-1]),Int32Array.from([6,30,54,78,-1,-1,-1]),Int32Array.from([6,30,56,82,-1,-1,-1]),Int32Array.from([6,30,58,86,-1,-1,-1]),Int32Array.from([6,34,62,90,-1,-1,-1]),Int32Array.from([6,28,50,72,94,-1,-1]),Int32Array.from([6,26,50,74,98,-1,-1]),Int32Array.from([6,30,54,78,102,-1,-1]),Int32Array.from([6,28,54,80,106,-1,-1]),Int32Array.from([6,32,58,84,110,-1,-1]),Int32Array.from([6,30,58,86,114,-1,-1]),Int32Array.from([6,34,62,90,118,-1,-1]),Int32Array.from([6,26,50,74,98,122,-1]),Int32Array.from([6,30,54,78,102,126,-1]),Int32Array.from([6,26,52,78,104,130,-1]),Int32Array.from([6,30,56,82,108,134,-1]),Int32Array.from([6,34,60,86,112,138,-1]),Int32Array.from([6,30,58,86,114,142,-1]),Int32Array.from([6,34,62,90,118,146,-1]),Int32Array.from([6,30,54,78,102,126,150]),Int32Array.from([6,24,50,76,102,128,154]),Int32Array.from([6,28,54,80,106,132,158]),Int32Array.from([6,32,58,84,110,136,162]),Int32Array.from([6,26,54,82,110,138,166]),Int32Array.from([6,30,58,86,114,142,170])]),Or.TYPE_INFO_COORDINATES=Array.from([Int32Array.from([8,0]),Int32Array.from([8,1]),Int32Array.from([8,2]),Int32Array.from([8,3]),Int32Array.from([8,4]),Int32Array.from([8,5]),Int32Array.from([8,7]),Int32Array.from([8,8]),Int32Array.from([7,8]),Int32Array.from([5,8]),Int32Array.from([4,8]),Int32Array.from([3,8]),Int32Array.from([2,8]),Int32Array.from([1,8]),Int32Array.from([0,8])]),Or.VERSION_INFO_POLY=7973,Or.TYPE_INFO_POLY=1335,Or.TYPE_INFO_MASK_PATTERN=21522;class s0{constructor(o,d){this.dataBytes=o,this.errorCorrectionBytes=d}getDataBytes(){return this.dataBytes}getErrorCorrectionBytes(){return this.errorCorrectionBytes}}class Sa{constructor(){}static calculateMaskPenalty(o){return Ha.applyMaskPenaltyRule1(o)+Ha.applyMaskPenaltyRule2(o)+Ha.applyMaskPenaltyRule3(o)+Ha.applyMaskPenaltyRule4(o)}static encode(o,d,f=null){let p=Sa.DEFAULT_BYTE_MODE_ENCODING;const b=f!==null&&f.get(Ga.CHARACTER_SET)!==void 0;b&&(p=f.get(Ga.CHARACTER_SET).toString());const w=this.chooseMode(o,p),S=new V;if(w===Nr.BYTE&&(b||Sa.DEFAULT_BYTE_MODE_ENCODING!==p)){const Gt=Q.getCharacterSetECIByName(p);Gt!==void 0&&this.appendECI(Gt,S)}this.appendModeInfo(w,S);const R=new V;this.appendBytes(o,w,R,p);let P;if(f!==null&&f.get(Ga.QR_VERSION)!==void 0){const Gt=Number.parseInt(f.get(Ga.QR_VERSION).toString(),10);P=sr.getVersionForNumber(Gt);const Ft=this.calculateBitsNeeded(w,S,R,P);if(!this.willFit(Ft,P,d))throw new ga("Data too big for requested version")}else P=this.recommendVersion(d,w,S,R);const X=new V;X.appendBitArray(S);const te=w===Nr.BYTE?R.getSizeInBytes():o.length;this.appendLengthInfo(te,P,w,X),X.appendBitArray(R);const ue=P.getECBlocksForLevel(d),je=P.getTotalCodewords()-ue.getTotalECCodewords();this.terminateBits(je,X);const Fe=this.interleaveWithECBytes(X,P.getTotalCodewords(),je,ue.getNumBlocks()),Ue=new Fi;Ue.setECLevel(d),Ue.setMode(w),Ue.setVersion(P);const tt=P.getDimensionForVersion(),ut=new Do(tt,tt),Xt=this.chooseMaskPattern(Fe,d,P,ut);return Ue.setMaskPattern(Xt),Or.buildMatrix(Fe,d,P,Xt,ut),Ue.setMatrix(ut),Ue}static recommendVersion(o,d,f,p){const b=this.calculateBitsNeeded(d,f,p,sr.getVersionForNumber(1)),w=this.chooseVersion(b,o),S=this.calculateBitsNeeded(d,f,p,w);return this.chooseVersion(S,o)}static calculateBitsNeeded(o,d,f,p){return d.getSize()+o.getCharacterCountBits(p)+f.getSize()}static getAlphanumericCode(o){return o<Sa.ALPHANUMERIC_TABLE.length?Sa.ALPHANUMERIC_TABLE[o]:-1}static chooseMode(o,d=null){if(Q.SJIS.getName()===d&&this.isOnlyDoubleByteKanji(o))return Nr.KANJI;let f=!1,p=!1;for(let b=0,w=o.length;b<w;++b){const S=o.charAt(b);if(Sa.isDigit(S))f=!0;else if(this.getAlphanumericCode(S.charCodeAt(0))!==-1)p=!0;else return Nr.BYTE}return p?Nr.ALPHANUMERIC:f?Nr.NUMERIC:Nr.BYTE}static isOnlyDoubleByteKanji(o){let d;try{d=oe.encode(o,Q.SJIS)}catch(p){return!1}const f=d.length;if(f%2!==0)return!1;for(let p=0;p<f;p+=2){const b=d[p]&255;if((b<129||b>159)&&(b<224||b>235))return!1}return!0}static chooseMaskPattern(o,d,f,p){let b=Number.MAX_SAFE_INTEGER,w=-1;for(let S=0;S<Fi.NUM_MASK_PATTERNS;S++){Or.buildMatrix(o,d,f,S,p);let R=this.calculateMaskPenalty(p);R<b&&(b=R,w=S)}return w}static chooseVersion(o,d){for(let f=1;f<=40;f++){const p=sr.getVersionForNumber(f);if(Sa.willFit(o,p,d))return p}throw new ga("Data too big")}static willFit(o,d,f){const p=d.getTotalCodewords(),w=d.getECBlocksForLevel(f).getTotalECCodewords(),S=p-w,R=(o+7)/8;return S>=R}static terminateBits(o,d){const f=o*8;if(d.getSize()>f)throw new ga("data bits cannot fit in the QR Code"+d.getSize()+" > "+f);for(let w=0;w<4&&d.getSize()<f;++w)d.appendBit(!1);const p=d.getSize()&7;if(p>0)for(let w=p;w<8;w++)d.appendBit(!1);const b=o-d.getSizeInBytes();for(let w=0;w<b;++w)d.appendBits((w&1)===0?236:17,8);if(d.getSize()!==f)throw new ga("Bits size does not equal capacity")}static getNumDataBytesAndNumECBytesForBlockID(o,d,f,p,b,w){if(p>=f)throw new ga("Block ID too large");const S=o%f,R=f-S,P=Math.floor(o/f),X=P+1,te=Math.floor(d/f),ue=te+1,je=P-te,Fe=X-ue;if(je!==Fe)throw new ga("EC bytes mismatch");if(f!==R+S)throw new ga("RS blocks mismatch");if(o!==(te+je)*R+(ue+Fe)*S)throw new ga("Total bytes mismatch");p<R?(b[0]=te,w[0]=je):(b[0]=ue,w[0]=Fe)}static interleaveWithECBytes(o,d,f,p){if(o.getSizeInBytes()!==f)throw new ga("Number of bits and data bytes does not match");let b=0,w=0,S=0;const R=new Array;for(let X=0;X<p;++X){const te=new Int32Array(1),ue=new Int32Array(1);Sa.getNumDataBytesAndNumECBytesForBlockID(d,f,p,X,te,ue);const je=te[0],Fe=new Uint8Array(je);o.toBytes(8*b,Fe,0,je);const Ue=Sa.generateECBytes(Fe,ue[0]);R.push(new s0(Fe,Ue)),w=Math.max(w,je),S=Math.max(S,Ue.length),b+=te[0]}if(f!==b)throw new ga("Data bytes does not match offset");const P=new V;for(let X=0;X<w;++X)for(const te of R){const ue=te.getDataBytes();X<ue.length&&P.appendBits(ue[X],8)}for(let X=0;X<S;++X)for(const te of R){const ue=te.getErrorCorrectionBytes();X<ue.length&&P.appendBits(ue[X],8)}if(d!==P.getSizeInBytes())throw new ga("Interleaving error: "+d+" and "+P.getSizeInBytes()+" differ.");return P}static generateECBytes(o,d){const f=o.length,p=new Int32Array(f+d);for(let w=0;w<f;w++)p[w]=o[w]&255;new Mo(mt.QR_CODE_FIELD_256).encode(p,d);const b=new Uint8Array(d);for(let w=0;w<d;w++)b[w]=p[f+w];return b}static appendModeInfo(o,d){d.appendBits(o.getBits(),4)}static appendLengthInfo(o,d,f,p){const b=f.getCharacterCountBits(d);if(o>=1<<b)throw new ga(o+" is bigger than "+((1<<b)-1));p.appendBits(o,b)}static appendBytes(o,d,f,p){switch(d){case Nr.NUMERIC:Sa.appendNumericBytes(o,f);break;case Nr.ALPHANUMERIC:Sa.appendAlphanumericBytes(o,f);break;case Nr.BYTE:Sa.append8BitBytes(o,f,p);break;case Nr.KANJI:Sa.appendKanjiBytes(o,f);break;default:throw new ga("Invalid mode: "+d)}}static getDigit(o){return o.charCodeAt(0)-48}static isDigit(o){const d=Sa.getDigit(o);return d>=0&&d<=9}static appendNumericBytes(o,d){const f=o.length;let p=0;for(;p<f;){const b=Sa.getDigit(o.charAt(p));if(p+2<f){const w=Sa.getDigit(o.charAt(p+1)),S=Sa.getDigit(o.charAt(p+2));d.appendBits(b*100+w*10+S,10),p+=3}else if(p+1<f){const w=Sa.getDigit(o.charAt(p+1));d.appendBits(b*10+w,7),p+=2}else d.appendBits(b,4),p++}}static appendAlphanumericBytes(o,d){const f=o.length;let p=0;for(;p<f;){const b=Sa.getAlphanumericCode(o.charCodeAt(p));if(b===-1)throw new ga;if(p+1<f){const w=Sa.getAlphanumericCode(o.charCodeAt(p+1));if(w===-1)throw new ga;d.appendBits(b*45+w,11),p+=2}else d.appendBits(b,6),p++}}static append8BitBytes(o,d,f){let p;try{p=oe.encode(o,f)}catch(b){throw new ga(b)}for(let b=0,w=p.length;b!==w;b++){const S=p[b];d.appendBits(S,8)}}static appendKanjiBytes(o,d){let f;try{f=oe.encode(o,Q.SJIS)}catch(b){throw new ga(b)}const p=f.length;for(let b=0;b<p;b+=2){const w=f[b]&255,S=f[b+1]&255,R=w<<8&4294967295|S;let P=-1;if(R>=33088&&R<=40956?P=R-33088:R>=57408&&R<=60351&&(P=R-49472),P===-1)throw new ga("Invalid byte sequence");const X=(P>>8)*192+(P&255);d.appendBits(X,13)}}static appendECI(o,d){d.appendBits(Nr.ECI.getBits(),4),d.appendBits(o.getValue(),8)}}Sa.ALPHANUMERIC_TABLE=Int32Array.from([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,36,-1,-1,-1,37,38,-1,-1,-1,-1,39,40,-1,41,42,43,0,1,2,3,4,5,6,7,8,9,44,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,-1,-1,-1,-1,-1]),Sa.DEFAULT_BYTE_MODE_ENCODING=Q.UTF8.getName();class wi{write(o,d,f,p=null){if(o.length===0)throw new N("Found empty contents");if(d<0||f<0)throw new N("Requested dimensions are too small: "+d+"x"+f);let b=kr.L,w=wi.QUIET_ZONE_SIZE;p!==null&&(p.get(Ga.ERROR_CORRECTION)!==void 0&&(b=kr.fromString(p.get(Ga.ERROR_CORRECTION).toString())),p.get(Ga.MARGIN)!==void 0&&(w=Number.parseInt(p.get(Ga.MARGIN).toString(),10)));const S=Sa.encode(o,b,p);return this.renderResult(S,d,f,w)}writeToDom(o,d,f,p,b=null){typeof o=="string"&&(o=document.querySelector(o));const w=this.write(d,f,p,b);o&&o.appendChild(w)}renderResult(o,d,f,p){const b=o.getMatrix();if(b===null)throw new ar;const w=b.getWidth(),S=b.getHeight(),R=w+p*2,P=S+p*2,X=Math.max(d,R),te=Math.max(f,P),ue=Math.min(Math.floor(X/R),Math.floor(te/P)),je=Math.floor((X-w*ue)/2),Fe=Math.floor((te-S*ue)/2),Ue=this.createSVGElement(X,te);for(let tt=0,ut=Fe;tt<S;tt++,ut+=ue)for(let Xt=0,Gt=je;Xt<w;Xt++,Gt+=ue)if(b.get(Xt,tt)===1){const Ft=this.createSvgRectElement(Gt,ut,ue,ue);Ue.appendChild(Ft)}return Ue}createSVGElement(o,d){const f=document.createElementNS(wi.SVG_NS,"svg");return f.setAttributeNS(null,"height",o.toString()),f.setAttributeNS(null,"width",d.toString()),f}createSvgRectElement(o,d,f,p){const b=document.createElementNS(wi.SVG_NS,"rect");return b.setAttributeNS(null,"x",o.toString()),b.setAttributeNS(null,"y",d.toString()),b.setAttributeNS(null,"height",f.toString()),b.setAttributeNS(null,"width",p.toString()),b.setAttributeNS(null,"fill","#000000"),b}}wi.QUIET_ZONE_SIZE=4,wi.SVG_NS="http://www.w3.org/2000/svg";class ai{encode(o,d,f,p,b){if(o.length===0)throw new N("Found empty contents");if(d!==ve.QR_CODE)throw new N("Can only encode QR_CODE, but got "+d);if(f<0||p<0)throw new N(`Requested dimensions are too small: ${f}x${p}`);let w=kr.L,S=ai.QUIET_ZONE_SIZE;b!==null&&(b.get(Ga.ERROR_CORRECTION)!==void 0&&(w=kr.fromString(b.get(Ga.ERROR_CORRECTION).toString())),b.get(Ga.MARGIN)!==void 0&&(S=Number.parseInt(b.get(Ga.MARGIN).toString(),10)));const R=Sa.encode(o,w,b);return ai.renderResult(R,f,p,S)}static renderResult(o,d,f,p){const b=o.getMatrix();if(b===null)throw new ar;const w=b.getWidth(),S=b.getHeight(),R=w+p*2,P=S+p*2,X=Math.max(d,R),te=Math.max(f,P),ue=Math.min(Math.floor(X/R),Math.floor(te/P)),je=Math.floor((X-w*ue)/2),Fe=Math.floor((te-S*ue)/2),Ue=new Ce(X,te);for(let tt=0,ut=Fe;tt<S;tt++,ut+=ue)for(let Xt=0,Gt=je;Xt<w;Xt++,Gt+=ue)b.get(Xt,tt)===1&&Ue.setRegion(Gt,ut,ue,ue);return Ue}}ai.QUIET_ZONE_SIZE=4;class Bi{encode(o,d,f,p,b){let w;switch(d){case ve.QR_CODE:w=new ai;break;default:throw new N("No encoder available for format "+d)}return w.encode(o,d,f,p,b)}}class Ds extends fe{constructor(o,d,f,p,b,w,S,R){if(super(w,S),this.yuvData=o,this.dataWidth=d,this.dataHeight=f,this.left=p,this.top=b,p+w>d||b+S>f)throw new N("Crop rectangle does not fit within image data.");R&&this.reverseHorizontal(w,S)}getRow(o,d){if(o<0||o>=this.getHeight())throw new N("Requested row is outside the image: "+o);const f=this.getWidth();(d==null||d.length<f)&&(d=new Uint8ClampedArray(f));const p=(o+this.top)*this.dataWidth+this.left;return A.arraycopy(this.yuvData,p,d,0,f),d}getMatrix(){const o=this.getWidth(),d=this.getHeight();if(o===this.dataWidth&&d===this.dataHeight)return this.yuvData;const f=o*d,p=new Uint8ClampedArray(f);let b=this.top*this.dataWidth+this.left;if(o===this.dataWidth)return A.arraycopy(this.yuvData,b,p,0,f),p;for(let w=0;w<d;w++){const S=w*o;A.arraycopy(this.yuvData,b,p,S,o),b+=this.dataWidth}return p}isCropSupported(){return!0}crop(o,d,f,p){return new Ds(this.yuvData,this.dataWidth,this.dataHeight,this.left+o,this.top+d,f,p,!1)}renderThumbnail(){const o=this.getWidth()/Ds.THUMBNAIL_SCALE_FACTOR,d=this.getHeight()/Ds.THUMBNAIL_SCALE_FACTOR,f=new Int32Array(o*d),p=this.yuvData;let b=this.top*this.dataWidth+this.left;for(let w=0;w<d;w++){const S=w*o;for(let R=0;R<o;R++){const P=p[b+R*Ds.THUMBNAIL_SCALE_FACTOR]&255;f[S+R]=4278190080|P*65793}b+=this.dataWidth*Ds.THUMBNAIL_SCALE_FACTOR}return f}getThumbnailWidth(){return this.getWidth()/Ds.THUMBNAIL_SCALE_FACTOR}getThumbnailHeight(){return this.getHeight()/Ds.THUMBNAIL_SCALE_FACTOR}reverseHorizontal(o,d){const f=this.yuvData;for(let p=0,b=this.top*this.dataWidth+this.left;p<d;p++,b+=this.dataWidth){const w=b+o/2;for(let S=b,R=b+o-1;S<w;S++,R--){const P=f[S];f[S]=f[R],f[R]=P}}}invert(){return new Oe(this)}}Ds.THUMBNAIL_SCALE_FACTOR=2;class Ui extends fe{constructor(o,d,f,p,b,w,S){if(super(d,f),this.dataWidth=p,this.dataHeight=b,this.left=w,this.top=S,o.BYTES_PER_ELEMENT===4){const R=d*f,P=new Uint8ClampedArray(R);for(let X=0;X<R;X++){const te=o[X],ue=te>>16&255,je=te>>7&510,Fe=te&255;P[X]=(ue+je+Fe)/4&255}this.luminances=P}else this.luminances=o;if(p===void 0&&(this.dataWidth=d),b===void 0&&(this.dataHeight=f),w===void 0&&(this.left=0),S===void 0&&(this.top=0),this.left+d>this.dataWidth||this.top+f>this.dataHeight)throw new N("Crop rectangle does not fit within image data.")}getRow(o,d){if(o<0||o>=this.getHeight())throw new N("Requested row is outside the image: "+o);const f=this.getWidth();(d==null||d.length<f)&&(d=new Uint8ClampedArray(f));const p=(o+this.top)*this.dataWidth+this.left;return A.arraycopy(this.luminances,p,d,0,f),d}getMatrix(){const o=this.getWidth(),d=this.getHeight();if(o===this.dataWidth&&d===this.dataHeight)return this.luminances;const f=o*d,p=new Uint8ClampedArray(f);let b=this.top*this.dataWidth+this.left;if(o===this.dataWidth)return A.arraycopy(this.luminances,b,p,0,f),p;for(let w=0;w<d;w++){const S=w*o;A.arraycopy(this.luminances,b,p,S,o),b+=this.dataWidth}return p}isCropSupported(){return!0}crop(o,d,f,p){return new Ui(this.luminances,f,p,this.dataWidth,this.dataHeight,this.left+o,this.top+d)}invert(){return new Oe(this)}}class es extends Q{static forName(o){return this.getCharacterSetECIByName(o)}}class io{}io.ISO_8859_1=Q.ISO8859_1;class zi{isCompact(){return this.compact}setCompact(o){this.compact=o}getSize(){return this.size}setSize(o){this.size=o}getLayers(){return this.layers}setLayers(o){this.layers=o}getCodeWords(){return this.codeWords}setCodeWords(o){this.codeWords=o}getMatrix(){return this.matrix}setMatrix(o){this.matrix=o}}class zc{static singletonList(o){return[o]}static min(o,d){return o.sort(d)[0]}}class pl{constructor(o){this.previous=o}getPrevious(){return this.previous}}class ni extends pl{constructor(o,d,f){super(o),this.value=d,this.bitCount=f}appendTo(o,d){o.appendBits(this.value,this.bitCount)}add(o,d){return new ni(this,o,d)}addBinaryShift(o,d){return console.warn("addBinaryShift on SimpleToken, this simply returns a copy of this token"),new ni(this,o,d)}toString(){let o=this.value&(1<<this.bitCount)-1;return o|=1<<this.bitCount,"<"+B.toBinaryString(o|1<<this.bitCount).substring(1)+">"}}class yl extends ni{constructor(o,d,f){super(o,0,0),this.binaryShiftStart=d,this.binaryShiftByteCount=f}appendTo(o,d){for(let f=0;f<this.binaryShiftByteCount;f++)(f===0||f===31&&this.binaryShiftByteCount<=62)&&(o.appendBits(31,5),this.binaryShiftByteCount>62?o.appendBits(this.binaryShiftByteCount-31,16):f===0?o.appendBits(Math.min(this.binaryShiftByteCount,31),5):o.appendBits(this.binaryShiftByteCount-31,5)),o.appendBits(d[this.binaryShiftStart+f],8)}addBinaryShift(o,d){return new yl(this,o,d)}toString(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"}}function Hc(ee,o,d){return new yl(ee,o,d)}function Hi(ee,o,d){return new ni(ee,o,d)}const oo=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],ln=0,si=1,hs=2,ks=3,Ns=4,Ls=new ni(null,0,0),Vi=[Int32Array.from([0,(5<<16)+28,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(9<<16)+480+14,0,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(4<<16)+14,(9<<16)+448+28,0,(9<<16)+448+29,932798]),Int32Array.from([(5<<16)+29,(5<<16)+28,656318,0,(5<<16)+30]),Int32Array.from([(5<<16)+31,656380,656382,656381,0])];function Lo(ee){for(let o of ee)U.fill(o,-1);return ee[ln][Ns]=0,ee[si][Ns]=0,ee[si][ln]=28,ee[ks][Ns]=0,ee[hs][Ns]=0,ee[hs][ln]=15,ee}const lo=Lo(U.createInt32Array(6,6));class zn{constructor(o,d,f,p){this.token=o,this.mode=d,this.binaryShiftByteCount=f,this.bitCount=p}getMode(){return this.mode}getToken(){return this.token}getBinaryShiftByteCount(){return this.binaryShiftByteCount}getBitCount(){return this.bitCount}latchAndAppend(o,d){let f=this.bitCount,p=this.token;if(o!==this.mode){let w=Vi[this.mode][o];p=Hi(p,w&65535,w>>16),f+=w>>16}let b=o===hs?4:5;return p=Hi(p,d,b),new zn(p,o,0,f+b)}shiftAndAppend(o,d){let f=this.token,p=this.mode===hs?4:5;return f=Hi(f,lo[this.mode][o],p),f=Hi(f,d,5),new zn(f,this.mode,0,this.bitCount+p+5)}addBinaryShiftChar(o){let d=this.token,f=this.mode,p=this.bitCount;if(this.mode===Ns||this.mode===hs){let S=Vi[f][ln];d=Hi(d,S&65535,S>>16),p+=S>>16,f=ln}let b=this.binaryShiftByteCount===0||this.binaryShiftByteCount===31?18:this.binaryShiftByteCount===62?9:8,w=new zn(d,f,this.binaryShiftByteCount+1,p+b);return w.binaryShiftByteCount===2078&&(w=w.endBinaryShift(o+1)),w}endBinaryShift(o){if(this.binaryShiftByteCount===0)return this;let d=this.token;return d=Hc(d,o-this.binaryShiftByteCount,this.binaryShiftByteCount),new zn(d,this.mode,0,this.bitCount)}isBetterThanOrEqualTo(o){let d=this.bitCount+(Vi[this.mode][o.mode]>>16);return this.binaryShiftByteCount<o.binaryShiftByteCount?d+=zn.calculateBinaryShiftCost(o)-zn.calculateBinaryShiftCost(this):this.binaryShiftByteCount>o.binaryShiftByteCount&&o.binaryShiftByteCount>0&&(d+=10),d<=o.bitCount}toBitArray(o){let d=[];for(let p=this.endBinaryShift(o.length).token;p!==null;p=p.getPrevious())d.unshift(p);let f=new V;for(const p of d)p.appendTo(f,o);return f}toString(){return se.format("%s bits=%d bytes=%d",oo[this.mode],this.bitCount,this.binaryShiftByteCount)}static calculateBinaryShiftCost(o){return o.binaryShiftByteCount>62?21:o.binaryShiftByteCount>31?20:o.binaryShiftByteCount>0?10:0}}zn.INITIAL_STATE=new zn(Ls,ln,0,0);function Vc(ee){const o=se.getCharCode(" "),d=se.getCharCode("."),f=se.getCharCode(",");ee[ln][o]=1;const p=se.getCharCode("Z"),b=se.getCharCode("A");for(let ue=b;ue<=p;ue++)ee[ln][ue]=ue-b+2;ee[si][o]=1;const w=se.getCharCode("z"),S=se.getCharCode("a");for(let ue=S;ue<=w;ue++)ee[si][ue]=ue-S+2;ee[hs][o]=1;const R=se.getCharCode("9"),P=se.getCharCode("0");for(let ue=P;ue<=R;ue++)ee[hs][ue]=ue-P+2;ee[hs][f]=12,ee[hs][d]=13;const X=["\0"," ","","","","","","","\x07","\b"," ",`
|
||
`,"\v","\f","\r","\x1B","","","","","@","\\","^","_","`","|","~",""];for(let ue=0;ue<X.length;ue++)ee[ks][se.getCharCode(X[ue])]=ue;const te=["\0","\r","\0","\0","\0","\0","!","'","#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}"];for(let ue=0;ue<te.length;ue++)se.getCharCode(te[ue])>0&&(ee[Ns][se.getCharCode(te[ue])]=ue);return ee}const fs=Vc(U.createInt32Array(5,256));class Is{constructor(o){this.text=o}encode(){const o=se.getCharCode(" "),d=se.getCharCode(`
|
||
`);let f=zc.singletonList(zn.INITIAL_STATE);for(let b=0;b<this.text.length;b++){let w,S=b+1<this.text.length?this.text[b+1]:0;switch(this.text[b]){case se.getCharCode("\r"):w=S===d?2:0;break;case se.getCharCode("."):w=S===o?3:0;break;case se.getCharCode(","):w=S===o?4:0;break;case se.getCharCode(":"):w=S===o?5:0;break;default:w=0}w>0?(f=Is.updateStateListForPair(f,b,w),b++):f=this.updateStateListForChar(f,b)}return zc.min(f,(b,w)=>b.getBitCount()-w.getBitCount()).toBitArray(this.text)}updateStateListForChar(o,d){const f=[];for(let p of o)this.updateStateForChar(p,d,f);return Is.simplifyStates(f)}updateStateForChar(o,d,f){let p=this.text[d]&255,b=fs[o.getMode()][p]>0,w=null;for(let S=0;S<=Ns;S++){let R=fs[S][p];if(R>0){if(w==null&&(w=o.endBinaryShift(d)),!b||S===o.getMode()||S===hs){const P=w.latchAndAppend(S,R);f.push(P)}if(!b&&lo[o.getMode()][S]>=0){const P=w.shiftAndAppend(S,R);f.push(P)}}}if(o.getBinaryShiftByteCount()>0||fs[o.getMode()][p]===0){let S=o.addBinaryShiftChar(d);f.push(S)}}static updateStateListForPair(o,d,f){const p=[];for(let b of o)this.updateStateForPair(b,d,f,p);return this.simplifyStates(p)}static updateStateForPair(o,d,f,p){let b=o.endBinaryShift(d);if(p.push(b.latchAndAppend(Ns,f)),o.getMode()!==Ns&&p.push(b.shiftAndAppend(Ns,f)),f===3||f===4){let w=b.latchAndAppend(hs,16-f).latchAndAppend(hs,1);p.push(w)}if(o.getBinaryShiftByteCount()>0){let w=o.addBinaryShiftChar(d).addBinaryShiftChar(d+1);p.push(w)}}static simplifyStates(o){let d=[];for(const f of o){let p=!0;for(const b of d){if(b.isBetterThanOrEqualTo(f)){p=!1;break}f.isBetterThanOrEqualTo(b)&&(d=d.filter(w=>w!==b))}p&&d.push(f)}return d}}class ta{constructor(){}static encodeBytes(o){return ta.encode(o,ta.DEFAULT_EC_PERCENT,ta.DEFAULT_AZTEC_LAYERS)}static encode(o,d,f){let p=new Is(o).encode(),b=B.truncDivision(p.getSize()*d,100)+11,w=p.getSize()+b,S,R,P,X,te;if(f!==ta.DEFAULT_AZTEC_LAYERS){if(S=f<0,R=Math.abs(f),R>(S?ta.MAX_NB_BITS_COMPACT:ta.MAX_NB_BITS))throw new N(se.format("Illegal value %s for layers",f));P=ta.totalBitsInLayer(R,S),X=ta.WORD_SIZE[R];let Ft=P-P%X;if(te=ta.stuffBits(p,X),te.getSize()+b>Ft)throw new N("Data to large for user specified layer");if(S&&te.getSize()>X*64)throw new N("Data to large for user specified layer")}else{X=0,te=null;for(let Ft=0;;Ft++){if(Ft>ta.MAX_NB_BITS)throw new N("Data too large for an Aztec code");if(S=Ft<=3,R=S?Ft+1:Ft,P=ta.totalBitsInLayer(R,S),w>P)continue;(te==null||X!==ta.WORD_SIZE[R])&&(X=ta.WORD_SIZE[R],te=ta.stuffBits(p,X));let Wr=P-P%X;if(!(S&&te.getSize()>X*64)&&te.getSize()+b<=Wr)break}}let ue=ta.generateCheckWords(te,P,X),je=te.getSize()/X,Fe=ta.generateModeMessage(S,R,je),Ue=(S?11:14)+R*4,tt=new Int32Array(Ue),ut;if(S){ut=Ue;for(let Ft=0;Ft<tt.length;Ft++)tt[Ft]=Ft}else{ut=Ue+1+2*B.truncDivision(B.truncDivision(Ue,2)-1,15);let Ft=B.truncDivision(Ue,2),Wr=B.truncDivision(ut,2);for(let Ur=0;Ur<Ft;Ur++){let fa=Ur+B.truncDivision(Ur,15);tt[Ft-Ur-1]=Wr-fa-1,tt[Ft+Ur]=Wr+fa+1}}let Xt=new Ce(ut);for(let Ft=0,Wr=0;Ft<R;Ft++){let Ur=(R-Ft)*4+(S?9:12);for(let fa=0;fa<Ur;fa++){let Rn=fa*2;for(let Mn=0;Mn<2;Mn++)ue.get(Wr+Rn+Mn)&&Xt.set(tt[Ft*2+Mn],tt[Ft*2+fa]),ue.get(Wr+Ur*2+Rn+Mn)&&Xt.set(tt[Ft*2+fa],tt[Ue-1-Ft*2-Mn]),ue.get(Wr+Ur*4+Rn+Mn)&&Xt.set(tt[Ue-1-Ft*2-Mn],tt[Ue-1-Ft*2-fa]),ue.get(Wr+Ur*6+Rn+Mn)&&Xt.set(tt[Ue-1-Ft*2-fa],tt[Ft*2+Mn])}Wr+=Ur*8}if(ta.drawModeMessage(Xt,S,ut,Fe),S)ta.drawBullsEye(Xt,B.truncDivision(ut,2),5);else{ta.drawBullsEye(Xt,B.truncDivision(ut,2),7);for(let Ft=0,Wr=0;Ft<B.truncDivision(Ue,2)-1;Ft+=15,Wr+=16)for(let Ur=B.truncDivision(ut,2)&1;Ur<ut;Ur+=2)Xt.set(B.truncDivision(ut,2)-Wr,Ur),Xt.set(B.truncDivision(ut,2)+Wr,Ur),Xt.set(Ur,B.truncDivision(ut,2)-Wr),Xt.set(Ur,B.truncDivision(ut,2)+Wr)}let Gt=new zi;return Gt.setCompact(S),Gt.setSize(ut),Gt.setLayers(R),Gt.setCodeWords(je),Gt.setMatrix(Xt),Gt}static drawBullsEye(o,d,f){for(let p=0;p<f;p+=2)for(let b=d-p;b<=d+p;b++)o.set(b,d-p),o.set(b,d+p),o.set(d-p,b),o.set(d+p,b);o.set(d-f,d-f),o.set(d-f+1,d-f),o.set(d-f,d-f+1),o.set(d+f,d-f),o.set(d+f,d-f+1),o.set(d+f,d+f-1)}static generateModeMessage(o,d,f){let p=new V;return o?(p.appendBits(d-1,2),p.appendBits(f-1,6),p=ta.generateCheckWords(p,28,4)):(p.appendBits(d-1,5),p.appendBits(f-1,11),p=ta.generateCheckWords(p,40,4)),p}static drawModeMessage(o,d,f,p){let b=B.truncDivision(f,2);if(d)for(let w=0;w<7;w++){let S=b-3+w;p.get(w)&&o.set(S,b-5),p.get(w+7)&&o.set(b+5,S),p.get(20-w)&&o.set(S,b+5),p.get(27-w)&&o.set(b-5,S)}else for(let w=0;w<10;w++){let S=b-5+w+B.truncDivision(w,5);p.get(w)&&o.set(S,b-7),p.get(w+10)&&o.set(b+7,S),p.get(29-w)&&o.set(S,b+7),p.get(39-w)&&o.set(b-7,S)}}static generateCheckWords(o,d,f){let p=o.getSize()/f,b=new Mo(ta.getGF(f)),w=B.truncDivision(d,f),S=ta.bitsToWords(o,f,w);b.encode(S,w-p);let R=d%f,P=new V;P.appendBits(0,R);for(const X of Array.from(S))P.appendBits(X,f);return P}static bitsToWords(o,d,f){let p=new Int32Array(f),b,w;for(b=0,w=o.getSize()/d;b<w;b++){let S=0;for(let R=0;R<d;R++)S|=o.get(b*d+R)?1<<d-R-1:0;p[b]=S}return p}static getGF(o){switch(o){case 4:return mt.AZTEC_PARAM;case 6:return mt.AZTEC_DATA_6;case 8:return mt.AZTEC_DATA_8;case 10:return mt.AZTEC_DATA_10;case 12:return mt.AZTEC_DATA_12;default:throw new N("Unsupported word size "+o)}}static stuffBits(o,d){let f=new V,p=o.getSize(),b=(1<<d)-2;for(let w=0;w<p;w+=d){let S=0;for(let R=0;R<d;R++)(w+R>=p||o.get(w+R))&&(S|=1<<d-1-R);(S&b)===b?(f.appendBits(S&b,d),w--):(S&b)===0?(f.appendBits(S|1,d),w--):f.appendBits(S,d)}return f}static totalBitsInLayer(o,d){return((d?88:112)+16*o)*o}}ta.DEFAULT_EC_PERCENT=33,ta.DEFAULT_AZTEC_LAYERS=0,ta.MAX_NB_BITS=32,ta.MAX_NB_BITS_COMPACT=4,ta.WORD_SIZE=Int32Array.from([4,6,6,8,8,8,8,8,8,10,10,10,10,10,10,10,10,10,10,10,10,10,10,12,12,12,12,12,12,12,12,12,12]);class Wi{encode(o,d,f,p){return this.encodeWithHints(o,d,f,p,null)}encodeWithHints(o,d,f,p,b){let w=io.ISO_8859_1,S=ta.DEFAULT_EC_PERCENT,R=ta.DEFAULT_AZTEC_LAYERS;return b!=null&&(b.has(Ga.CHARACTER_SET)&&(w=es.forName(b.get(Ga.CHARACTER_SET).toString())),b.has(Ga.ERROR_CORRECTION)&&(S=B.parseInt(b.get(Ga.ERROR_CORRECTION).toString())),b.has(Ga.AZTEC_LAYERS)&&(R=B.parseInt(b.get(Ga.AZTEC_LAYERS).toString()))),Wi.encodeLayers(o,d,f,p,w,S,R)}static encodeLayers(o,d,f,p,b,w,S){if(d!==ve.AZTEC)throw new N("Can only encode AZTEC, but got "+d);let R=ta.encode(se.getBytes(o,b),w,S);return Wi.renderResult(R,f,p)}static renderResult(o,d,f){let p=o.getMatrix();if(p==null)throw new ar;let b=p.getWidth(),w=p.getHeight(),S=Math.max(d,b),R=Math.max(f,w),P=Math.min(S/b,R/w),X=(S-b*P)/2,te=(R-w*P)/2,ue=new Ce(S,R);for(let je=0,Fe=te;je<w;je++,Fe+=P)for(let Ue=0,tt=X;Ue<b;Ue++,tt+=P)p.get(Ue,je)&&ue.setRegion(tt,Fe,P,P);return ue}}a.AbstractExpandedDecoder=we,a.ArgumentException=k,a.ArithmeticException=Lt,a.AztecCode=zi,a.AztecCodeReader=Wt,a.AztecCodeWriter=Wi,a.AztecDecoder=nr,a.AztecDetector=Ct,a.AztecDetectorResult=Pt,a.AztecEncoder=ta,a.AztecHighLevelEncoder=Is,a.AztecPoint=jt,a.BarcodeFormat=ve,a.Binarizer=D,a.BinaryBitmap=C,a.BitArray=V,a.BitMatrix=Ce,a.BitSource=la,a.BrowserAztecCodeReader=pr,a.BrowserBarcodeReader=Za,a.BrowserCodeReader=ie,a.BrowserDatamatrixCodeReader=Rs,a.BrowserMultiFormatReader=rc,a.BrowserPDF417Reader=_i,a.BrowserQRCodeReader=Uc,a.BrowserQRCodeSvgWriter=wi,a.CharacterSetECI=Q,a.ChecksumException=O,a.Code128Reader=We,a.Code39Reader=At,a.DataMatrixDecodedBitStreamParser=Da,a.DataMatrixReader=Jr,a.DecodeHintType=W,a.DecoderResult=ze,a.DefaultGridSampler=Be,a.DetectorResult=Br,a.EAN13Reader=vr,a.EncodeHintType=Ga,a.Exception=x,a.FormatException=H,a.GenericGF=mt,a.GenericGFPoly=Ze,a.GlobalHistogramBinarizer=me,a.GridSampler=De,a.GridSamplerInstance=vt,a.HTMLCanvasElementLuminanceSource=ye,a.HybridBinarizer=K,a.ITFReader=lt,a.IllegalArgumentException=N,a.IllegalStateException=ar,a.InvertedLuminanceSource=Oe,a.LuminanceSource=fe,a.MathUtils=$t,a.MultiFormatOneDReader=qr,a.MultiFormatReader=Bc,a.MultiFormatWriter=Bi,a.NotFoundException=ae,a.OneDReader=Ge,a.PDF417DecodedBitStreamParser=ft,a.PDF417DecoderErrorCorrection=ws,a.PDF417Reader=yn,a.PDF417ResultMetadata=Pi,a.PerspectiveTransform=Je,a.PlanarYUVLuminanceSource=Ds,a.QRCodeByteMatrix=Do,a.QRCodeDataMask=gn,a.QRCodeDecodedBitStreamParser=_a,a.QRCodeDecoderErrorCorrectionLevel=kr,a.QRCodeDecoderFormatInformation=sn,a.QRCodeEncoder=Sa,a.QRCodeEncoderQRCode=Fi,a.QRCodeMaskUtil=Ha,a.QRCodeMatrixUtil=Or,a.QRCodeMode=Nr,a.QRCodeReader=on,a.QRCodeVersion=sr,a.QRCodeWriter=ai,a.RGBLuminanceSource=Ui,a.RSS14Reader=xr,a.RSSExpandedReader=Ee,a.ReaderException=Qn,a.ReedSolomonDecoder=or,a.ReedSolomonEncoder=Mo,a.ReedSolomonException=Zt,a.Result=re,a.ResultMetadataType=Ae,a.ResultPoint=St,a.StringUtils=se,a.UnsupportedOperationException=Ne,a.VideoInputDevice=J,a.WhiteRectangleDetector=it,a.WriterException=ga,a.ZXingArrays=U,a.ZXingCharset=es,a.ZXingInteger=B,a.ZXingStandardCharsets=io,a.ZXingStringBuilder=ce,a.ZXingStringEncoding=oe,a.ZXingSystem=A,a.createAbstractExpandedDecoder=zt,Object.defineProperty(a,"__esModule",{value:!0})}))})(eu,eu.exports)),eu.exports}var Xa=cL();const dL=gp(Xa),uL=c6({__proto__:null,default:dL},[Xa]);var b_=(function(){function e(r,a,n){if(this.formatMap=new Map([[yr.QR_CODE,Xa.BarcodeFormat.QR_CODE],[yr.AZTEC,Xa.BarcodeFormat.AZTEC],[yr.CODABAR,Xa.BarcodeFormat.CODABAR],[yr.CODE_39,Xa.BarcodeFormat.CODE_39],[yr.CODE_93,Xa.BarcodeFormat.CODE_93],[yr.CODE_128,Xa.BarcodeFormat.CODE_128],[yr.DATA_MATRIX,Xa.BarcodeFormat.DATA_MATRIX],[yr.MAXICODE,Xa.BarcodeFormat.MAXICODE],[yr.ITF,Xa.BarcodeFormat.ITF],[yr.EAN_13,Xa.BarcodeFormat.EAN_13],[yr.EAN_8,Xa.BarcodeFormat.EAN_8],[yr.PDF_417,Xa.BarcodeFormat.PDF_417],[yr.RSS_14,Xa.BarcodeFormat.RSS_14],[yr.RSS_EXPANDED,Xa.BarcodeFormat.RSS_EXPANDED],[yr.UPC_A,Xa.BarcodeFormat.UPC_A],[yr.UPC_E,Xa.BarcodeFormat.UPC_E],[yr.UPC_EAN_EXTENSION,Xa.BarcodeFormat.UPC_EAN_EXTENSION]]),this.reverseFormatMap=this.createReverseFormatMap(),!uL)throw"Use html5qrcode.min.js without edit, ZXing not found.";this.verbose=a,this.logger=n;var i=this.createZXingFormats(r),c=new Map;c.set(Xa.DecodeHintType.POSSIBLE_FORMATS,i),c.set(Xa.DecodeHintType.TRY_HARDER,!1),this.hints=c}return e.prototype.decodeAsync=function(r){var a=this;return new Promise(function(n,i){try{n(a.decode(r))}catch(c){i(c)}})},e.prototype.decode=function(r){var a=new Xa.MultiFormatReader(this.verbose,this.hints),n=new Xa.HTMLCanvasElementLuminanceSource(r),i=new Xa.BinaryBitmap(new Xa.HybridBinarizer(n)),c=a.decode(i);return{text:c.text,format:lk.create(this.toHtml5QrcodeSupportedFormats(c.format)),debugData:this.createDebugData()}},e.prototype.createReverseFormatMap=function(){var r=new Map;return this.formatMap.forEach(function(a,n,i){r.set(a,n)}),r},e.prototype.toHtml5QrcodeSupportedFormats=function(r){if(!this.reverseFormatMap.has(r))throw"reverseFormatMap doesn't have ".concat(r);return this.reverseFormatMap.get(r)},e.prototype.createZXingFormats=function(r){for(var a=[],n=0,i=r;n<i.length;n++){var c=i[n];this.formatMap.has(c)?a.push(this.formatMap.get(c)):this.logger.logError("".concat(c," is not supported by")+"ZXingHtml5QrcodeShim")}return a},e.prototype.createDebugData=function(){return{decoderName:"zxing-js"}},e})(),hL=function(e,r,a,n){function i(c){return c instanceof a?c:new a(function(u){u(c)})}return new(a||(a=Promise))(function(c,u){function g(k){try{x(n.next(k))}catch(N){u(N)}}function y(k){try{x(n.throw(k))}catch(N){u(N)}}function x(k){k.done?c(k.value):i(k.value).then(g,y)}x((n=n.apply(e,r||[])).next())})},fL=function(e,r){var a={label:0,sent:function(){if(c[0]&1)throw c[1];return c[1]},trys:[],ops:[]},n,i,c,u;return u={next:g(0),throw:g(1),return:g(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function g(x){return function(k){return y([x,k])}}function y(x){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,x[0]&&(a=0)),a;)try{if(n=1,i&&(c=x[0]&2?i.return:x[0]?i.throw||((c=i.return)&&c.call(i),0):i.next)&&!(c=c.call(i,x[1])).done)return c;switch(i=0,c&&(x=[x[0]&2,c.value]),x[0]){case 0:case 1:c=x;break;case 4:return a.label++,{value:x[1],done:!1};case 5:a.label++,i=x[1],x=[0];continue;case 7:x=a.ops.pop(),a.trys.pop();continue;default:if(c=a.trys,!(c=c.length>0&&c[c.length-1])&&(x[0]===6||x[0]===2)){a=0;continue}if(x[0]===3&&(!c||x[1]>c[0]&&x[1]<c[3])){a.label=x[1];break}if(x[0]===6&&a.label<c[1]){a.label=c[1],c=x;break}if(c&&a.label<c[2]){a.label=c[2],a.ops.push(x);break}c[2]&&a.ops.pop(),a.trys.pop();continue}x=r.call(e,a)}catch(k){x=[6,k],i=0}finally{n=c=0}if(x[0]&5)throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}},v_=(function(){function e(r,a,n){if(this.formatMap=new Map([[yr.QR_CODE,"qr_code"],[yr.AZTEC,"aztec"],[yr.CODABAR,"codabar"],[yr.CODE_39,"code_39"],[yr.CODE_93,"code_93"],[yr.CODE_128,"code_128"],[yr.DATA_MATRIX,"data_matrix"],[yr.ITF,"itf"],[yr.EAN_13,"ean_13"],[yr.EAN_8,"ean_8"],[yr.PDF_417,"pdf417"],[yr.UPC_A,"upc_a"],[yr.UPC_E,"upc_e"]]),this.reverseFormatMap=this.createReverseFormatMap(),!e.isSupported())throw"Use html5qrcode.min.js without edit, Use BarcodeDetectorDelegate only if it isSupported();";this.verbose=a,this.logger=n;var i=this.createBarcodeDetectorFormats(r);if(this.detector=new BarcodeDetector(i),!this.detector)throw"BarcodeDetector detector not supported"}return e.isSupported=function(){if(!("BarcodeDetector"in window))return!1;var r=new BarcodeDetector({formats:["qr_code"]});return typeof r!="undefined"},e.prototype.decodeAsync=function(r){return hL(this,void 0,void 0,function(){var a,n;return fL(this,function(i){switch(i.label){case 0:return[4,this.detector.detect(r)];case 1:if(a=i.sent(),!a||a.length===0)throw"No barcode or QR code detected.";return n=this.selectLargestBarcode(a),[2,{text:n.rawValue,format:lk.create(this.toHtml5QrcodeSupportedFormats(n.format)),debugData:this.createDebugData()}]}})})},e.prototype.selectLargestBarcode=function(r){for(var a=null,n=0,i=0,c=r;i<c.length;i++){var u=c[i],g=u.boundingBox.width*u.boundingBox.height;g>n&&(n=g,a=u)}if(!a)throw"No largest barcode found";return a},e.prototype.createBarcodeDetectorFormats=function(r){for(var a=[],n=0,i=r;n<i.length;n++){var c=i[n];this.formatMap.has(c)?a.push(this.formatMap.get(c)):this.logger.warn("".concat(c," is not supported by")+"BarcodeDetectorDelegate")}return{formats:a}},e.prototype.toHtml5QrcodeSupportedFormats=function(r){if(!this.reverseFormatMap.has(r))throw"reverseFormatMap doesn't have ".concat(r);return this.reverseFormatMap.get(r)},e.prototype.createReverseFormatMap=function(){var r=new Map;return this.formatMap.forEach(function(a,n,i){r.set(a,n)}),r},e.prototype.createDebugData=function(){return{decoderName:"BarcodeDetector"}},e})(),__=function(e,r,a,n){function i(c){return c instanceof a?c:new a(function(u){u(c)})}return new(a||(a=Promise))(function(c,u){function g(k){try{x(n.next(k))}catch(N){u(N)}}function y(k){try{x(n.throw(k))}catch(N){u(N)}}function x(k){k.done?c(k.value):i(k.value).then(g,y)}x((n=n.apply(e,r||[])).next())})},w_=function(e,r){var a={label:0,sent:function(){if(c[0]&1)throw c[1];return c[1]},trys:[],ops:[]},n,i,c,u;return u={next:g(0),throw:g(1),return:g(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function g(x){return function(k){return y([x,k])}}function y(x){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,x[0]&&(a=0)),a;)try{if(n=1,i&&(c=x[0]&2?i.return:x[0]?i.throw||((c=i.return)&&c.call(i),0):i.next)&&!(c=c.call(i,x[1])).done)return c;switch(i=0,c&&(x=[x[0]&2,c.value]),x[0]){case 0:case 1:c=x;break;case 4:return a.label++,{value:x[1],done:!1};case 5:a.label++,i=x[1],x=[0];continue;case 7:x=a.ops.pop(),a.trys.pop();continue;default:if(c=a.trys,!(c=c.length>0&&c[c.length-1])&&(x[0]===6||x[0]===2)){a=0;continue}if(x[0]===3&&(!c||x[1]>c[0]&&x[1]<c[3])){a.label=x[1];break}if(x[0]===6&&a.label<c[1]){a.label=c[1],c=x;break}if(c&&a.label<c[2]){a.label=c[2],a.ops.push(x);break}c[2]&&a.ops.pop(),a.trys.pop();continue}x=r.call(e,a)}catch(k){x=[6,k],i=0}finally{n=c=0}if(x[0]&5)throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}},mL=(function(){function e(r,a,n,i){this.EXECUTIONS_TO_REPORT_PERFORMANCE=100,this.executions=0,this.executionResults=[],this.wasPrimaryDecoderUsedInLastDecode=!1,this.verbose=n,a&&v_.isSupported()?(this.primaryDecoder=new v_(r,n,i),this.secondaryDecoder=new b_(r,n,i)):this.primaryDecoder=new b_(r,n,i)}return e.prototype.decodeAsync=function(r){return __(this,void 0,void 0,function(){var a;return w_(this,function(n){switch(n.label){case 0:a=performance.now(),n.label=1;case 1:return n.trys.push([1,,3,4]),[4,this.getDecoder().decodeAsync(r)];case 2:return[2,n.sent()];case 3:return this.possiblyLogPerformance(a),[7];case 4:return[2]}})})},e.prototype.decodeRobustlyAsync=function(r){return __(this,void 0,void 0,function(){var a,n;return w_(this,function(i){switch(i.label){case 0:a=performance.now(),i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.primaryDecoder.decodeAsync(r)];case 2:return[2,i.sent()];case 3:if(n=i.sent(),this.secondaryDecoder)return[2,this.secondaryDecoder.decodeAsync(r)];throw n;case 4:return this.possiblyLogPerformance(a),[7];case 5:return[2]}})})},e.prototype.getDecoder=function(){return this.secondaryDecoder?this.wasPrimaryDecoderUsedInLastDecode===!1?(this.wasPrimaryDecoderUsedInLastDecode=!0,this.primaryDecoder):(this.wasPrimaryDecoderUsedInLastDecode=!1,this.secondaryDecoder):this.primaryDecoder},e.prototype.possiblyLogPerformance=function(r){if(this.verbose){var a=performance.now()-r;this.executionResults.push(a),this.executions++,this.possiblyFlushPerformanceReport()}},e.prototype.possiblyFlushPerformanceReport=function(){if(!(this.executions<this.EXECUTIONS_TO_REPORT_PERFORMANCE)){for(var r=0,a=0,n=this.executionResults;a<n.length;a++){var i=n[a];r+=i}var c=r/this.executionResults.length;console.log("".concat(c," ms for ").concat(this.executionResults.length," last runs.")),this.executions=0,this.executionResults=[]}},e})(),r1=(function(){var e=function(r,a){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var c in i)Object.prototype.hasOwnProperty.call(i,c)&&(n[c]=i[c])},e(r,a)};return function(r,a){if(typeof a!="function"&&a!==null)throw new TypeError("Class extends value "+String(a)+" is not a constructor or null");e(r,a);function n(){this.constructor=r}r.prototype=a===null?Object.create(a):(n.prototype=a.prototype,new n)}})(),Wf=function(e,r,a,n){function i(c){return c instanceof a?c:new a(function(u){u(c)})}return new(a||(a=Promise))(function(c,u){function g(k){try{x(n.next(k))}catch(N){u(N)}}function y(k){try{x(n.throw(k))}catch(N){u(N)}}function x(k){k.done?c(k.value):i(k.value).then(g,y)}x((n=n.apply(e,r||[])).next())})},Gf=function(e,r){var a={label:0,sent:function(){if(c[0]&1)throw c[1];return c[1]},trys:[],ops:[]},n,i,c,u;return u={next:g(0),throw:g(1),return:g(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function g(x){return function(k){return y([x,k])}}function y(x){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,x[0]&&(a=0)),a;)try{if(n=1,i&&(c=x[0]&2?i.return:x[0]?i.throw||((c=i.return)&&c.call(i),0):i.next)&&!(c=c.call(i,x[1])).done)return c;switch(i=0,c&&(x=[x[0]&2,c.value]),x[0]){case 0:case 1:c=x;break;case 4:return a.label++,{value:x[1],done:!1};case 5:a.label++,i=x[1],x=[0];continue;case 7:x=a.ops.pop(),a.trys.pop();continue;default:if(c=a.trys,!(c=c.length>0&&c[c.length-1])&&(x[0]===6||x[0]===2)){a=0;continue}if(x[0]===3&&(!c||x[1]>c[0]&&x[1]<c[3])){a.label=x[1];break}if(x[0]===6&&a.label<c[1]){a.label=c[1],c=x;break}if(c&&a.label<c[2]){a.label=c[2],a.ops.push(x);break}c[2]&&a.ops.pop(),a.trys.pop();continue}x=r.call(e,a)}catch(k){x=[6,k],i=0}finally{n=c=0}if(x[0]&5)throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}},dk=(function(){function e(r,a){this.name=r,this.track=a}return e.prototype.isSupported=function(){return this.track.getCapabilities?this.name in this.track.getCapabilities():!1},e.prototype.apply=function(r){var a={};a[this.name]=r;var n={advanced:[a]};return this.track.applyConstraints(n)},e.prototype.value=function(){var r=this.track.getSettings();if(this.name in r){var a=r[this.name];return a}return null},e})(),gL=(function(e){r1(r,e);function r(a,n){return e.call(this,a,n)||this}return r.prototype.min=function(){return this.getCapabilities().min},r.prototype.max=function(){return this.getCapabilities().max},r.prototype.step=function(){return this.getCapabilities().step},r.prototype.apply=function(a){var n={};n[this.name]=a;var i={advanced:[n]};return this.track.applyConstraints(i)},r.prototype.getCapabilities=function(){this.failIfNotSupported();var a=this.track.getCapabilities(),n=a[this.name];return{min:n.min,max:n.max,step:n.step}},r.prototype.failIfNotSupported=function(){if(!this.isSupported())throw new Error("".concat(this.name," capability not supported"))},r})(dk),xL=(function(e){r1(r,e);function r(a){return e.call(this,"zoom",a)||this}return r})(gL),pL=(function(e){r1(r,e);function r(a){return e.call(this,"torch",a)||this}return r})(dk),yL=(function(){function e(r){this.track=r}return e.prototype.zoomFeature=function(){return new xL(this.track)},e.prototype.torchFeature=function(){return new pL(this.track)},e})(),bL=(function(){function e(r,a,n){this.isClosed=!1,this.parentElement=r,this.mediaStream=a,this.callbacks=n,this.surface=this.createVideoElement(this.parentElement.clientWidth),r.append(this.surface)}return e.prototype.createVideoElement=function(r){var a=document.createElement("video");return a.style.width="".concat(r,"px"),a.style.display="block",a.muted=!0,a.setAttribute("muted","true"),a.playsInline=!0,a},e.prototype.setupSurface=function(){var r=this;this.surface.onabort=function(){throw"RenderedCameraImpl video surface onabort() called"},this.surface.onerror=function(){throw"RenderedCameraImpl video surface onerror() called"};var a=function(){var n=r.surface.clientWidth,i=r.surface.clientHeight;r.callbacks.onRenderSurfaceReady(n,i),r.surface.removeEventListener("playing",a)};this.surface.addEventListener("playing",a),this.surface.srcObject=this.mediaStream,this.surface.play()},e.create=function(r,a,n,i){return Wf(this,void 0,void 0,function(){var c,u;return Gf(this,function(g){switch(g.label){case 0:return c=new e(r,a,i),n.aspectRatio?(u={aspectRatio:n.aspectRatio},[4,c.getFirstTrackOrFail().applyConstraints(u)]):[3,2];case 1:g.sent(),g.label=2;case 2:return c.setupSurface(),[2,c]}})})},e.prototype.failIfClosed=function(){if(this.isClosed)throw"The RenderedCamera has already been closed."},e.prototype.getFirstTrackOrFail=function(){if(this.failIfClosed(),this.mediaStream.getVideoTracks().length===0)throw"No video tracks found";return this.mediaStream.getVideoTracks()[0]},e.prototype.pause=function(){this.failIfClosed(),this.surface.pause()},e.prototype.resume=function(r){this.failIfClosed();var a=this,n=function(){setTimeout(r,200),a.surface.removeEventListener("playing",n)};this.surface.addEventListener("playing",n),this.surface.play()},e.prototype.isPaused=function(){return this.failIfClosed(),this.surface.paused},e.prototype.getSurface=function(){return this.failIfClosed(),this.surface},e.prototype.getRunningTrackCapabilities=function(){return this.getFirstTrackOrFail().getCapabilities()},e.prototype.getRunningTrackSettings=function(){return this.getFirstTrackOrFail().getSettings()},e.prototype.applyVideoConstraints=function(r){return Wf(this,void 0,void 0,function(){return Gf(this,function(a){if("aspectRatio"in r)throw"Changing 'aspectRatio' in run-time is not yet supported.";return[2,this.getFirstTrackOrFail().applyConstraints(r)]})})},e.prototype.close=function(){if(this.isClosed)return Promise.resolve();var r=this;return new Promise(function(a,n){var i=r.mediaStream.getVideoTracks(),c=i.length,u=0;r.mediaStream.getVideoTracks().forEach(function(g){r.mediaStream.removeTrack(g),g.stop(),++u,u>=c&&(r.isClosed=!0,r.parentElement.removeChild(r.surface),a())})})},e.prototype.getCapabilities=function(){return new yL(this.getFirstTrackOrFail())},e})(),vL=(function(){function e(r){this.mediaStream=r}return e.prototype.render=function(r,a,n){return Wf(this,void 0,void 0,function(){return Gf(this,function(i){return[2,bL.create(r,this.mediaStream,a,n)]})})},e.create=function(r){return Wf(this,void 0,void 0,function(){var a,n;return Gf(this,function(i){switch(i.label){case 0:if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return a={audio:!1,video:r},[4,navigator.mediaDevices.getUserMedia(a)];case 1:return n=i.sent(),[2,new e(n)]}})})},e})(),k_=function(e,r,a,n){function i(c){return c instanceof a?c:new a(function(u){u(c)})}return new(a||(a=Promise))(function(c,u){function g(k){try{x(n.next(k))}catch(N){u(N)}}function y(k){try{x(n.throw(k))}catch(N){u(N)}}function x(k){k.done?c(k.value):i(k.value).then(g,y)}x((n=n.apply(e,r||[])).next())})},N_=function(e,r){var a={label:0,sent:function(){if(c[0]&1)throw c[1];return c[1]},trys:[],ops:[]},n,i,c,u;return u={next:g(0),throw:g(1),return:g(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function g(x){return function(k){return y([x,k])}}function y(x){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,x[0]&&(a=0)),a;)try{if(n=1,i&&(c=x[0]&2?i.return:x[0]?i.throw||((c=i.return)&&c.call(i),0):i.next)&&!(c=c.call(i,x[1])).done)return c;switch(i=0,c&&(x=[x[0]&2,c.value]),x[0]){case 0:case 1:c=x;break;case 4:return a.label++,{value:x[1],done:!1};case 5:a.label++,i=x[1],x=[0];continue;case 7:x=a.ops.pop(),a.trys.pop();continue;default:if(c=a.trys,!(c=c.length>0&&c[c.length-1])&&(x[0]===6||x[0]===2)){a=0;continue}if(x[0]===3&&(!c||x[1]>c[0]&&x[1]<c[3])){a.label=x[1];break}if(x[0]===6&&a.label<c[1]){a.label=c[1],c=x;break}if(c&&a.label<c[2]){a.label=c[2],a.ops.push(x);break}c[2]&&a.ops.pop(),a.trys.pop();continue}x=r.call(e,a)}catch(k){x=[6,k],i=0}finally{n=c=0}if(x[0]&5)throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}},_L=(function(){function e(){}return e.failIfNotSupported=function(){return k_(this,void 0,void 0,function(){return N_(this,function(r){if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return[2,new e]})})},e.prototype.create=function(r){return k_(this,void 0,void 0,function(){return N_(this,function(a){return[2,vL.create(r)]})})},e})(),wL=function(e,r,a,n){function i(c){return c instanceof a?c:new a(function(u){u(c)})}return new(a||(a=Promise))(function(c,u){function g(k){try{x(n.next(k))}catch(N){u(N)}}function y(k){try{x(n.throw(k))}catch(N){u(N)}}function x(k){k.done?c(k.value):i(k.value).then(g,y)}x((n=n.apply(e,r||[])).next())})},kL=function(e,r){var a={label:0,sent:function(){if(c[0]&1)throw c[1];return c[1]},trys:[],ops:[]},n,i,c,u;return u={next:g(0),throw:g(1),return:g(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function g(x){return function(k){return y([x,k])}}function y(x){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,x[0]&&(a=0)),a;)try{if(n=1,i&&(c=x[0]&2?i.return:x[0]?i.throw||((c=i.return)&&c.call(i),0):i.next)&&!(c=c.call(i,x[1])).done)return c;switch(i=0,c&&(x=[x[0]&2,c.value]),x[0]){case 0:case 1:c=x;break;case 4:return a.label++,{value:x[1],done:!1};case 5:a.label++,i=x[1],x=[0];continue;case 7:x=a.ops.pop(),a.trys.pop();continue;default:if(c=a.trys,!(c=c.length>0&&c[c.length-1])&&(x[0]===6||x[0]===2)){a=0;continue}if(x[0]===3&&(!c||x[1]>c[0]&&x[1]<c[3])){a.label=x[1];break}if(x[0]===6&&a.label<c[1]){a.label=c[1],c=x;break}if(c&&a.label<c[2]){a.label=c[2],a.ops.push(x);break}c[2]&&a.ops.pop(),a.trys.pop();continue}x=r.call(e,a)}catch(k){x=[6,k],i=0}finally{n=c=0}if(x[0]&5)throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}},NL=(function(){function e(){}return e.retrieve=function(){if(navigator.mediaDevices)return e.getCamerasFromMediaDevices();var r=MediaStreamTrack;return MediaStreamTrack&&r.getSources?e.getCamerasFromMediaStreamTrack():e.rejectWithError()},e.rejectWithError=function(){var r=Md.unableToQuerySupportedDevices();return e.isHttpsOrLocalhost()||(r=Md.insecureContextCameraQueryError()),Promise.reject(r)},e.isHttpsOrLocalhost=function(){if(location.protocol==="https:")return!0;var r=location.host.split(":")[0];return r==="127.0.0.1"||r==="localhost"},e.getCamerasFromMediaDevices=function(){return wL(this,void 0,void 0,function(){var r,a,n,i,c,u,g;return kL(this,function(y){switch(y.label){case 0:return r=function(x){for(var k=x.getVideoTracks(),N=0,C=k;N<C.length;N++){var O=C[N];O.enabled=!1,O.stop(),x.removeTrack(O)}},[4,navigator.mediaDevices.getUserMedia({audio:!1,video:!0})];case 1:return a=y.sent(),[4,navigator.mediaDevices.enumerateDevices()];case 2:for(n=y.sent(),i=[],c=0,u=n;c<u.length;c++)g=u[c],g.kind==="videoinput"&&i.push({id:g.deviceId,label:g.label});return r(a),[2,i]}})})},e.getCamerasFromMediaStreamTrack=function(){return new Promise(function(r,a){var n=function(c){for(var u=[],g=0,y=c;g<y.length;g++){var x=y[g];x.kind==="video"&&u.push({id:x.id,label:x.label})}r(u)},i=MediaStreamTrack;i.getSources(n)})},e})(),hn;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.NOT_STARTED=1]="NOT_STARTED",e[e.SCANNING=2]="SCANNING",e[e.PAUSED=3]="PAUSED"})(hn||(hn={}));var SL=(function(){function e(){this.state=hn.NOT_STARTED,this.onGoingTransactionNewState=hn.UNKNOWN}return e.prototype.directTransition=function(r){this.failIfTransitionOngoing(),this.validateTransition(r),this.state=r},e.prototype.startTransition=function(r){return this.failIfTransitionOngoing(),this.validateTransition(r),this.onGoingTransactionNewState=r,this},e.prototype.execute=function(){if(this.onGoingTransactionNewState===hn.UNKNOWN)throw"Transaction is already cancelled, cannot execute().";var r=this.onGoingTransactionNewState;this.onGoingTransactionNewState=hn.UNKNOWN,this.directTransition(r)},e.prototype.cancel=function(){if(this.onGoingTransactionNewState===hn.UNKNOWN)throw"Transaction is already cancelled, cannot cancel().";this.onGoingTransactionNewState=hn.UNKNOWN},e.prototype.getState=function(){return this.state},e.prototype.failIfTransitionOngoing=function(){if(this.onGoingTransactionNewState!==hn.UNKNOWN)throw"Cannot transition to a new state, already under transition"},e.prototype.validateTransition=function(r){switch(this.state){case hn.UNKNOWN:throw"Transition from unknown is not allowed";case hn.NOT_STARTED:this.failIfNewStateIs(r,[hn.PAUSED]);break;case hn.SCANNING:break;case hn.PAUSED:break}},e.prototype.failIfNewStateIs=function(r,a){for(var n=0,i=a;n<i.length;n++){var c=i[n];if(r===c)throw"Cannot transition from ".concat(this.state," to ").concat(r)}},e})(),CL=(function(){function e(r){this.stateManager=r}return e.prototype.startTransition=function(r){return this.stateManager.startTransition(r)},e.prototype.directTransition=function(r){this.stateManager.directTransition(r)},e.prototype.getState=function(){return this.stateManager.getState()},e.prototype.canScanFile=function(){return this.stateManager.getState()===hn.NOT_STARTED},e.prototype.isScanning=function(){return this.stateManager.getState()!==hn.NOT_STARTED},e.prototype.isStrictlyScanning=function(){return this.stateManager.getState()===hn.SCANNING},e.prototype.isPaused=function(){return this.stateManager.getState()===hn.PAUSED},e})(),EL=(function(){function e(){}return e.create=function(){return new CL(new SL)},e})(),jL=(function(){var e=function(r,a){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var c in i)Object.prototype.hasOwnProperty.call(i,c)&&(n[c]=i[c])},e(r,a)};return function(r,a){if(typeof a!="function"&&a!==null)throw new TypeError("Class extends value "+String(a)+" is not a constructor or null");e(r,a);function n(){this.constructor=r}r.prototype=a===null?Object.create(a):(n.prototype=a.prototype,new n)}})(),ui=(function(e){jL(r,e);function r(){return e!==null&&e.apply(this,arguments)||this}return r.DEFAULT_WIDTH=300,r.DEFAULT_WIDTH_OFFSET=2,r.FILE_SCAN_MIN_HEIGHT=300,r.FILE_SCAN_HIDDEN_CANVAS_PADDING=100,r.MIN_QR_BOX_SIZE=50,r.SHADED_LEFT=1,r.SHADED_RIGHT=2,r.SHADED_TOP=3,r.SHADED_BOTTOM=4,r.SHADED_REGION_ELEMENT_ID="qr-shaded-region",r.VERBOSE=!1,r.BORDER_SHADER_DEFAULT_COLOR="#ffffff",r.BORDER_SHADER_MATCH_COLOR="rgb(90, 193, 56)",r})(sL),TL=(function(){function e(r,a){this.logger=a,this.fps=ui.SCAN_DEFAULT_FPS,r?(r.fps&&(this.fps=r.fps),this.disableFlip=r.disableFlip===!0,this.qrbox=r.qrbox,this.aspectRatio=r.aspectRatio,this.videoConstraints=r.videoConstraints):this.disableFlip=ui.DEFAULT_DISABLE_FLIP}return e.prototype.isMediaStreamConstraintsValid=function(){return this.videoConstraints?ck.isMediaStreamConstraintsValid(this.videoConstraints,this.logger):(this.logger.logError("Empty videoConstraints",!0),!1)},e.prototype.isShadedBoxEnabled=function(){return!Ko(this.qrbox)},e.create=function(r,a){return new e(r,a)},e})(),AL=(function(){function e(r,a){if(this.element=null,this.canvasElement=null,this.scannerPausedUiElement=null,this.hasBorderShaders=null,this.borderShaders=null,this.qrMatch=null,this.renderedCamera=null,this.qrRegion=null,this.context=null,this.lastScanImageFile=null,this.isScanning=!1,!document.getElementById(r))throw"HTML Element with id=".concat(r," not found");this.elementId=r,this.verbose=!1;var n;typeof a=="boolean"?this.verbose=a===!0:a&&(n=a,this.verbose=n.verbose===!0,n.experimentalFeatures),this.logger=new oL(this.verbose),this.qrcode=new mL(this.getSupportedFormats(a),this.getUseBarCodeDetectorIfSupported(n),this.verbose,this.logger),this.foreverScanTimeout,this.shouldScan=!0,this.stateManagerProxy=EL.create()}return e.prototype.start=function(r,a,n,i){var c=this;if(!r)throw"cameraIdOrConfig is required";if(!n||typeof n!="function")throw"qrCodeSuccessCallback is required and should be a function.";var u;i?u=i:u=this.verbose?this.logger.log:function(){};var g=TL.create(a,this.logger);this.clearElement();var y=!1;g.videoConstraints&&(g.isMediaStreamConstraintsValid()?y=!0:this.logger.logError("'videoConstraints' is not valid 'MediaStreamConstraints, it will be ignored.'",!0));var x=y,k=document.getElementById(this.elementId);k.clientWidth?k.clientWidth:ui.DEFAULT_WIDTH,k.style.position="relative",this.shouldScan=!0,this.element=k;var N=this,C=this.stateManagerProxy.startTransition(hn.SCANNING);return new Promise(function(O,D){var A=x?g.videoConstraints:N.createVideoConstraints(r);if(!A){C.cancel(),D("videoConstraints should be defined");return}var I={};(!x||g.aspectRatio)&&(I.aspectRatio=g.aspectRatio);var z={onRenderSurfaceReady:function(U,B){N.setupUi(U,B,g),N.isScanning=!0,N.foreverScan(g,n,u)}};_L.failIfNotSupported().then(function(U){U.create(A).then(function(B){return B.render(c.element,I,z).then(function(V){N.renderedCamera=V,C.execute(),O(null)}).catch(function(V){C.cancel(),D(V)})}).catch(function(B){C.cancel(),D(Md.errorGettingUserMedia(B))})}).catch(function(U){C.cancel(),D(Md.cameraStreamingNotSupported())})})},e.prototype.pause=function(r){if(!this.stateManagerProxy.isStrictlyScanning())throw"Cannot pause, scanner is not scanning.";this.stateManagerProxy.directTransition(hn.PAUSED),this.showPausedState(),(Ko(r)||r!==!0)&&(r=!1),r&&this.renderedCamera&&this.renderedCamera.pause()},e.prototype.resume=function(){if(!this.stateManagerProxy.isPaused())throw"Cannot result, scanner is not paused.";if(!this.renderedCamera)throw"renderedCamera doesn't exist while trying resume()";var r=this,a=function(){r.stateManagerProxy.directTransition(hn.SCANNING),r.hidePausedState()};if(!this.renderedCamera.isPaused()){a();return}this.renderedCamera.resume(function(){a()})},e.prototype.getState=function(){return this.stateManagerProxy.getState()},e.prototype.stop=function(){var r=this;if(!this.stateManagerProxy.isScanning())throw"Cannot stop, scanner is not running or paused.";var a=this.stateManagerProxy.startTransition(hn.NOT_STARTED);this.shouldScan=!1,this.foreverScanTimeout&&clearTimeout(this.foreverScanTimeout);var n=function(){if(r.element){var c=document.getElementById(ui.SHADED_REGION_ELEMENT_ID);c&&r.element.removeChild(c)}},i=this;return this.renderedCamera.close().then(function(){return i.renderedCamera=null,i.element&&(i.element.removeChild(i.canvasElement),i.canvasElement=null),n(),i.qrRegion&&(i.qrRegion=null),i.context&&(i.context=null),a.execute(),i.hidePausedState(),i.isScanning=!1,Promise.resolve()})},e.prototype.scanFile=function(r,a){return this.scanFileV2(r,a).then(function(n){return n.decodedText})},e.prototype.scanFileV2=function(r,a){var n=this;if(!r||!(r instanceof File))throw"imageFile argument is mandatory and should be instance of File. Use 'event.target.files[0]'.";if(Ko(a)&&(a=!0),!this.stateManagerProxy.canScanFile())throw"Cannot start file scan - ongoing camera scan";return new Promise(function(i,c){n.possiblyCloseLastScanImageFile(),n.clearElement(),n.lastScanImageFile=URL.createObjectURL(r);var u=new Image;u.onload=function(){var g=u.width,y=u.height,x=document.getElementById(n.elementId),k=x.clientWidth?x.clientWidth:ui.DEFAULT_WIDTH,N=Math.max(x.clientHeight?x.clientHeight:y,ui.FILE_SCAN_MIN_HEIGHT),C=n.computeCanvasDrawConfig(g,y,k,N);if(a){var O=n.createCanvasElement(k,N,"qr-canvas-visible");O.style.display="inline-block",x.appendChild(O);var D=O.getContext("2d");if(!D)throw"Unable to get 2d context from canvas";D.canvas.width=k,D.canvas.height=N,D.drawImage(u,0,0,g,y,C.x,C.y,C.width,C.height)}var A=ui.FILE_SCAN_HIDDEN_CANVAS_PADDING,I=Math.max(u.width,C.width),z=Math.max(u.height,C.height),U=I+2*A,B=z+2*A,V=n.createCanvasElement(U,B);x.appendChild(V);var Z=V.getContext("2d");if(!Z)throw"Unable to get 2d context from canvas";Z.canvas.width=U,Z.canvas.height=B,Z.drawImage(u,0,0,g,y,A,A,I,z);try{n.qrcode.decodeRobustlyAsync(V).then(function(W){i(p_.createFromQrcodeResult(W))}).catch(c)}catch(W){c("QR code parse error, error = ".concat(W))}},u.onerror=c,u.onabort=c,u.onstalled=c,u.onsuspend=c,u.src=URL.createObjectURL(r)})},e.prototype.clear=function(){this.clearElement()},e.getCameras=function(){return NL.retrieve()},e.prototype.getRunningTrackCapabilities=function(){return this.getRenderedCameraOrFail().getRunningTrackCapabilities()},e.prototype.getRunningTrackSettings=function(){return this.getRenderedCameraOrFail().getRunningTrackSettings()},e.prototype.getRunningTrackCameraCapabilities=function(){return this.getRenderedCameraOrFail().getCapabilities()},e.prototype.applyVideoConstraints=function(r){if(r){if(!ck.isMediaStreamConstraintsValid(r,this.logger))throw"invalid videoConstaints passed, check logs for more details"}else throw"videoConstaints is required argument.";return this.getRenderedCameraOrFail().applyVideoConstraints(r)},e.prototype.getRenderedCameraOrFail=function(){if(this.renderedCamera==null)throw"Scanning is not in running state, call this API only when QR code scanning using camera is in running state.";return this.renderedCamera},e.prototype.getSupportedFormats=function(r){var a=[yr.QR_CODE,yr.AZTEC,yr.CODABAR,yr.CODE_39,yr.CODE_93,yr.CODE_128,yr.DATA_MATRIX,yr.MAXICODE,yr.ITF,yr.EAN_13,yr.EAN_8,yr.PDF_417,yr.RSS_14,yr.RSS_EXPANDED,yr.UPC_A,yr.UPC_E,yr.UPC_EAN_EXTENSION];if(!r||typeof r=="boolean"||!r.formatsToSupport)return a;if(!Array.isArray(r.formatsToSupport))throw"configOrVerbosityFlag.formatsToSupport should be undefined or an array.";if(r.formatsToSupport.length===0)throw"Atleast 1 formatsToSupport is needed.";for(var n=[],i=0,c=r.formatsToSupport;i<c.length;i++){var u=c[i];nL(u)?n.push(u):this.logger.warn("Invalid format: ".concat(u," passed in config, ignoring."))}if(n.length===0)throw"None of formatsToSupport match supported values.";return n},e.prototype.getUseBarCodeDetectorIfSupported=function(r){if(Ko(r))return!0;if(!Ko(r.useBarCodeDetectorIfSupported))return r.useBarCodeDetectorIfSupported!==!1;if(Ko(r.experimentalFeatures))return!0;var a=r.experimentalFeatures;return Ko(a.useBarCodeDetectorIfSupported)?!0:a.useBarCodeDetectorIfSupported!==!1},e.prototype.validateQrboxSize=function(r,a,n){var i=this,c=n.qrbox;this.validateQrboxConfig(c);var u=this.toQrdimensions(r,a,c),g=function(x){if(x<ui.MIN_QR_BOX_SIZE)throw"minimum size of 'config.qrbox' dimension value is"+" ".concat(ui.MIN_QR_BOX_SIZE,"px.")},y=function(x){return x>r&&(i.logger.warn("`qrbox.width` or `qrbox` is larger than the width of the root element. The width will be truncated to the width of root element."),x=r),x};g(u.width),g(u.height),u.width=y(u.width)},e.prototype.validateQrboxConfig=function(r){if(typeof r!="number"&&typeof r!="function"&&(r.width===void 0||r.height===void 0))throw"Invalid instance of QrDimensions passed for 'config.qrbox'. Both 'width' and 'height' should be set."},e.prototype.toQrdimensions=function(r,a,n){if(typeof n=="number")return{width:n,height:n};if(typeof n=="function")try{return n(r,a)}catch(i){throw new Error("qrbox config was passed as a function but it failed with unknown error"+i)}return n},e.prototype.setupUi=function(r,a,n){n.isShadedBoxEnabled()&&this.validateQrboxSize(r,a,n);var i=Ko(n.qrbox)?{width:r,height:a}:n.qrbox;this.validateQrboxConfig(i);var c=this.toQrdimensions(r,a,i);c.height>a&&this.logger.warn("[Html5Qrcode] config.qrbox has height that isgreater than the height of the video stream. Shading will be ignored");var u=n.isShadedBoxEnabled()&&c.height<=a,g={x:0,y:0,width:r,height:a},y=u?this.getShadedRegionBounds(r,a,c):g,x=this.createCanvasElement(y.width,y.height),k={willReadFrequently:!0},N=x.getContext("2d",k);N.canvas.width=y.width,N.canvas.height=y.height,this.element.append(x),u&&this.possiblyInsertShadingElement(this.element,r,a,c),this.createScannerPausedUiElement(this.element),this.qrRegion=y,this.context=N,this.canvasElement=x},e.prototype.createScannerPausedUiElement=function(r){var a=document.createElement("div");a.innerText=Md.scannerPaused(),a.style.display="none",a.style.position="absolute",a.style.top="0px",a.style.zIndex="1",a.style.background="rgba(9, 9, 9, 0.46)",a.style.color="#FFECEC",a.style.textAlign="center",a.style.width="100%",r.appendChild(a),this.scannerPausedUiElement=a},e.prototype.scanContext=function(r,a){var n=this;return this.stateManagerProxy.isPaused()?Promise.resolve(!1):this.qrcode.decodeAsync(this.canvasElement).then(function(i){return r(i.text,p_.createFromQrcodeResult(i)),n.possiblyUpdateShaders(!0),!0}).catch(function(i){n.possiblyUpdateShaders(!1);var c=Md.codeParseError(i);return a(c,iL.createFrom(c)),!1})},e.prototype.foreverScan=function(r,a,n){var i=this;if(this.shouldScan&&this.renderedCamera){var c=this.renderedCamera.getSurface(),u=c.videoWidth/c.clientWidth,g=c.videoHeight/c.clientHeight;if(!this.qrRegion)throw"qrRegion undefined when localMediaStream is ready.";var y=this.qrRegion.width*u,x=this.qrRegion.height*g,k=this.qrRegion.x*u,N=this.qrRegion.y*g;this.context.drawImage(c,k,N,y,x,0,0,this.qrRegion.width,this.qrRegion.height);var C=function(){i.foreverScanTimeout=setTimeout(function(){i.foreverScan(r,a,n)},i.getTimeoutFps(r.fps))};this.scanContext(a,n).then(function(O){!O&&r.disableFlip!==!0?(i.context.translate(i.context.canvas.width,0),i.context.scale(-1,1),i.scanContext(a,n).finally(function(){C()})):C()}).catch(function(O){i.logger.logError("Error happend while scanning context",O),C()})}},e.prototype.createVideoConstraints=function(r){if(typeof r=="string")return{deviceId:{exact:r}};if(typeof r=="object"){var a="facingMode",n="deviceId",i={user:!0,environment:!0},c="exact",u=function(D){if(D in i)return!0;throw"config has invalid 'facingMode' value = "+"'".concat(D,"'")},g=Object.keys(r);if(g.length!==1)throw"'cameraIdOrConfig' object should have exactly 1 key,"+" if passed as an object, found ".concat(g.length," keys");var y=Object.keys(r)[0];if(y!==a&&y!==n)throw"Only '".concat(a,"' and '").concat(n,"' ")+" are supported for 'cameraIdOrConfig'";if(y===a){var x=r.facingMode;if(typeof x=="string"){if(u(x))return{facingMode:x}}else if(typeof x=="object")if(c in x){if(u(x["".concat(c)]))return{facingMode:{exact:x["".concat(c)]}}}else throw"'facingMode' should be string or object with"+" ".concat(c," as key.");else{var k=typeof x;throw"Invalid type of 'facingMode' = ".concat(k)}}else{var N=r.deviceId;if(typeof N=="string")return{deviceId:N};if(typeof N=="object"){if(c in N)return{deviceId:{exact:N["".concat(c)]}};throw"'deviceId' should be string or object with"+" ".concat(c," as key.")}else{var C=typeof N;throw"Invalid type of 'deviceId' = ".concat(C)}}}var O=typeof r;throw"Invalid type of 'cameraIdOrConfig' = ".concat(O)},e.prototype.computeCanvasDrawConfig=function(r,a,n,i){if(r<=n&&a<=i){var c=(n-r)/2,u=(i-a)/2;return{x:c,y:u,width:r,height:a}}else{var g=r,y=a;return r>n&&(a=n/r*a,r=n),a>i&&(r=i/a*r,a=i),this.logger.log("Image downsampled from "+"".concat(g,"X").concat(y)+" to ".concat(r,"X").concat(a,".")),this.computeCanvasDrawConfig(r,a,n,i)}},e.prototype.clearElement=function(){if(this.stateManagerProxy.isScanning())throw"Cannot clear while scan is ongoing, close it first.";var r=document.getElementById(this.elementId);r&&(r.innerHTML="")},e.prototype.possiblyUpdateShaders=function(r){this.qrMatch!==r&&(this.hasBorderShaders&&this.borderShaders&&this.borderShaders.length&&this.borderShaders.forEach(function(a){a.style.backgroundColor=r?ui.BORDER_SHADER_MATCH_COLOR:ui.BORDER_SHADER_DEFAULT_COLOR}),this.qrMatch=r)},e.prototype.possiblyCloseLastScanImageFile=function(){this.lastScanImageFile&&(URL.revokeObjectURL(this.lastScanImageFile),this.lastScanImageFile=null)},e.prototype.createCanvasElement=function(r,a,n){var i=r,c=a,u=document.createElement("canvas");return u.style.width="".concat(i,"px"),u.style.height="".concat(c,"px"),u.style.display="none",u.id=Ko(n)?"qr-canvas":n,u},e.prototype.getShadedRegionBounds=function(r,a,n){if(n.width>r||n.height>a)throw"'config.qrbox' dimensions should not be greater than the dimensions of the root HTML element.";return{x:(r-n.width)/2,y:(a-n.height)/2,width:n.width,height:n.height}},e.prototype.possiblyInsertShadingElement=function(r,a,n,i){if(!(a-i.width<1||n-i.height<1)){var c=document.createElement("div");c.style.position="absolute";var u=(a-i.width)/2,g=(n-i.height)/2;if(c.style.borderLeft="".concat(u,"px solid rgba(0, 0, 0, 0.48)"),c.style.borderRight="".concat(u,"px solid rgba(0, 0, 0, 0.48)"),c.style.borderTop="".concat(g,"px solid rgba(0, 0, 0, 0.48)"),c.style.borderBottom="".concat(g,"px solid rgba(0, 0, 0, 0.48)"),c.style.boxSizing="border-box",c.style.top="0px",c.style.bottom="0px",c.style.left="0px",c.style.right="0px",c.id="".concat(ui.SHADED_REGION_ELEMENT_ID),a-i.width<11||n-i.height<11)this.hasBorderShaders=!1;else{var y=5,x=40;this.insertShaderBorders(c,x,y,-y,null,0,!0),this.insertShaderBorders(c,x,y,-y,null,0,!1),this.insertShaderBorders(c,x,y,null,-y,0,!0),this.insertShaderBorders(c,x,y,null,-y,0,!1),this.insertShaderBorders(c,y,x+y,-y,null,-y,!0),this.insertShaderBorders(c,y,x+y,null,-y,-y,!0),this.insertShaderBorders(c,y,x+y,-y,null,-y,!1),this.insertShaderBorders(c,y,x+y,null,-y,-y,!1),this.hasBorderShaders=!0}r.append(c)}},e.prototype.insertShaderBorders=function(r,a,n,i,c,u,g){var y=document.createElement("div");y.style.position="absolute",y.style.backgroundColor=ui.BORDER_SHADER_DEFAULT_COLOR,y.style.width="".concat(a,"px"),y.style.height="".concat(n,"px"),i!==null&&(y.style.top="".concat(i,"px")),c!==null&&(y.style.bottom="".concat(c,"px")),g?y.style.left="".concat(u,"px"):y.style.right="".concat(u,"px"),this.borderShaders||(this.borderShaders=[]),this.borderShaders.push(y),r.appendChild(y)},e.prototype.showPausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="block"},e.prototype.hidePausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="none"},e.prototype.getTimeoutFps=function(r){return 1e3/r},e})(),S_;(function(e){e[e.STATUS_DEFAULT=0]="STATUS_DEFAULT",e[e.STATUS_SUCCESS=1]="STATUS_SUCCESS",e[e.STATUS_WARNING=2]="STATUS_WARNING",e[e.STATUS_REQUESTING_PERMISSION=3]="STATUS_REQUESTING_PERMISSION"})(S_||(S_={}));const Bx="/asm_app";function OL(e){const r=(e||"").trim();if(!r)return null;let a=r;try{if(/^https?:\/\//i.test(r)){const n=new URL(r);a=n.pathname+n.search+n.hash}}catch(n){}return(a.startsWith(Bx+"/")||a===Bx)&&(a=a.slice(Bx.length)||"/"),a.startsWith("/")?a.split("?")[0]||a:/^(ACC-ASS-|AST-|ACC-WO-)/i.test(a)||/^[A-Z0-9-]+$/i.test(a)?/^(ACC-WO-|WO-)/i.test(a)?`/work-orders/${a}`:`/assets/${a}`:null}const RL=({isOpen:e,onClose:r,onScan:a,title:n="Scan QR Code",facingMode:i="environment"})=>{const c=ua(),g=`qr-reader-${E.useId().replace(/:/g,"")}`,y=E.useRef(null),x=E.useRef(!1),[k,N]=E.useState(null),[C,O]=E.useState(!1),D=()=>xe(null,null,function*(){const I=y.current;if(y.current=null,!!I)try{I.isScanning&&(yield I.stop()),I.clear()}catch(z){}}),A=I=>xe(null,null,function*(){if(x.current)return;x.current=!0;const z=OL(I);if(a){yield D(),r(),a(I,z);return}if(z){yield D(),r(),c(z);return}x.current=!1,N(`Unrecognized QR code: ${I}`)});return E.useEffect(()=>{if(!e)return;let I=!1;x.current=!1,N(null),O(!0);const z=()=>xe(null,null,function*(){try{if(yield D(),I)return;const B=new AL(g);y.current=B,yield B.start({facingMode:i},{fps:10,qrbox:(V,Z)=>{const W=Math.min(V,Z),H=Math.max(180,Math.floor(W*.7));return{width:H,height:H}},aspectRatio:1},V=>{A(V)},()=>{})}catch(B){if(console.error("QR scanner start failed:",B),!I){const V=B instanceof Error?B.message:"Could not open camera";N(V.includes("NotAllowedError")||V.toLowerCase().includes("permission")?"Camera permission denied. Please allow camera access and try again.":`Camera unavailable: ${V}`)}}finally{I||O(!1)}}),U=window.setTimeout(()=>{z()},100);return()=>{I=!0,window.clearTimeout(U),D()}},[e,g,i]),e?Su.createPortal(t.jsx("div",{className:"fixed inset-0 z-[10050] flex items-center justify-center bg-black/70 p-4",children:t.jsxs("div",{className:"w-full max-w-md overflow-hidden rounded-xl bg-white shadow-2xl dark:bg-gray-800",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-700",children:[t.jsxs("h3",{className:"flex items-center gap-2 text-base font-semibold text-gray-900 dark:text-white",children:[t.jsx(Sw,{className:"text-teal-600"}),n]}),t.jsx("button",{type:"button",onClick:()=>{D().then(r)},className:"rounded-lg p-2 text-gray-500 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","aria-label":"Close scanner",children:t.jsx(qt,{})})]}),t.jsxs("div",{className:"space-y-3 p-4",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Point the camera at an asset QR code. You will stay inside the app."}),C&&!k&&t.jsx("p",{className:"text-center text-sm text-teal-600 dark:text-teal-400",children:"Starting camera…"}),k&&t.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300",children:k}),t.jsx("div",{id:g,className:"overflow-hidden rounded-lg bg-black [&_video]:max-h-[60vh] [&_video]:w-full [&_video]:object-cover"})]}),t.jsx("div",{className:"border-t border-gray-200 px-4 py-3 dark:border-gray-700",children:t.jsx("button",{type:"button",onClick:()=>{D().then(r)},className:"w-full rounded-lg bg-gray-200 px-4 py-2 text-sm font-medium text-gray-800 hover:bg-gray-300 dark:bg-gray-700 dark:text-gray-100 dark:hover:bg-gray-600",children:"Cancel"})})]})}),document.body):null},ML=({className:e,label:r="Scan QR",title:a,onScan:n})=>{const[i,c]=E.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:()=>c(!0),className:e||"bg-teal-600 hover:bg-teal-700 text-white px-4 py-2 rounded-lg flex items-center justify-center gap-2 shadow transition-all w-full sm:w-auto",children:[t.jsx(Sw,{}),t.jsx("span",{className:"font-medium",children:r})]}),t.jsx(RL,{isOpen:i,onClose:()=>c(!1),onScan:n,title:a})]})},Fu=({currentPage:e,totalCount:r=0,pageSize:a,hasMore:n=!1,itemLabel:i,onPageChange:c,className:u=""})=>{const{t:g}=oa(),y=i!=null?i:g("listPages.results"),x=r>0?Math.max(1,Math.ceil(r/a)):0,k=r>0,N=(e-1)*a+1,C=k?Math.min(e*a,r):e*a,[O,D]=E.useState(""),A=U=>{U.preventDefault();const B=parseInt(O.trim(),10);if(!Number.isNaN(B)&&B>=1){const V=k?Math.min(B,x):B;c(V),D("")}},I=()=>{if(x<=7)return Array.from({length:x},(B,V)=>V+1);const U=[];U.push(1),e>3&&U.push("ellipsis");for(let B=Math.max(2,e-1);B<=Math.min(x-1,e+1);B++)U.includes(B)||U.push(B);return e<x-2&&U.push("ellipsis"),x>1&&U.push(x),U};return n||e>1||k&&x>1?t.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 ${u}`,children:[t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:k?g("pagination.showingToOf",{start:N,end:C,total:r,label:y}):g("pagination.showingTo",{start:N,end:C,label:y})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>c(e-1),disabled:e<=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:g("pagination.previous")}),k&&x>1&&t.jsx("div",{className:"flex items-center gap-1",children:I().map((U,B)=>U==="ellipsis"?t.jsx("span",{className:"px-2 text-gray-500 dark:text-gray-400",children:"…"},`e-${B}`):t.jsx("button",{type:"button",onClick:()=>c(U),className:`min-w-[2rem] px-2 py-1 text-sm font-medium rounded-lg transition-colors ${U===e?"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:U},U))}),t.jsx("button",{type:"button",onClick:()=>c(e+1),disabled:k?e>=x:!n,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:g("pagination.next")}),t.jsxs("form",{onSubmit:A,className:"flex items-center gap-1 ml-2",children:[t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400 whitespace-nowrap",children:g("pagination.goTo")}),t.jsx("input",{type:"number",min:1,max:k?x:void 0,value:O,onChange:U=>D(U.target.value),placeholder:k?`1-${x}`:g("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"}),t.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:g("pagination.go")})]})]})]}):null},Bu=({sortBy:e,dateFilterBy:r,dateStart:a,dateEnd:n,onSortByChange:i,onDateFilterByChange:c,onDateStartChange:u,onDateEndChange:g,includeAssetNameSort:y=!1})=>{const{t:x}=oa(),k="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";return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:x("filters.sortBy",{defaultValue:"Sort By"})}),t.jsxs("select",{value:e,onChange:N=>i(N.target.value),className:k,children:[t.jsx("option",{value:"creation desc",children:x("filters.sortCreationNewest",{defaultValue:"Created (Newest)"})}),t.jsx("option",{value:"creation asc",children:x("filters.sortCreationOldest",{defaultValue:"Created (Oldest)"})}),t.jsx("option",{value:"modified desc",children:x("filters.sortModifiedNewest",{defaultValue:"Modified (Newest)"})}),t.jsx("option",{value:"modified asc",children:x("filters.sortModifiedOldest",{defaultValue:"Modified (Oldest)"})}),y&&t.jsxs(t.Fragment,{children:[t.jsx("option",{value:"asset_name asc",children:x("filters.sortAssetNameAsc",{defaultValue:"Asset Name (A-Z)"})}),t.jsx("option",{value:"asset_name desc",children:x("filters.sortAssetNameDesc",{defaultValue:"Asset Name (Z-A)"})})]}),t.jsx("option",{value:"name asc",children:x("filters.sortNameAsc",{defaultValue:"Name (A-Z)"})}),t.jsx("option",{value:"name desc",children:x("filters.sortNameDesc",{defaultValue:"Name (Z-A)"})})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:x("filters.filterBy",{defaultValue:"Filter By"})}),t.jsxs("select",{value:r,onChange:N=>c(N.target.value),className:k,children:[t.jsx("option",{value:"",children:x("filters.filterBy",{defaultValue:"Filter By"})}),t.jsx("option",{value:"creation",children:x("filters.createdDate",{defaultValue:"Created Date"})}),t.jsx("option",{value:"modified",children:x("filters.latestModifiedDate",{defaultValue:"Latest Modified Date"})})]})]}),r&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:x("filters.startDate",{defaultValue:"Start Date"})}),t.jsx("input",{type:"date",value:a,onChange:N=>{const C=N.target.value;u(C),n&&C>n&&g(C)},className:k})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:x("filters.endDate",{defaultValue:"End Date"})}),t.jsx("input",{type:"date",value:n,onChange:N=>g(N.target.value),min:a||void 0,className:k})]})]})]})},DL=["creation desc","creation asc","modified desc","modified asc","name asc","name desc","asset_name asc","asset_name desc"];function LL(e,r="creation desc"){return DL.includes(e)?e:r}function uk(e,r,a){if(!e||!r&&!a)return{};const n={};return e==="creation"?(r&&(n.creation_from=r),a&&(n.creation_to=a)):(r&&(n.modified_from=r),a&&(n.modified_to=a)),n}function xm(e,r,a,n){const i=_e(_e({},e),uk(r,a,n)),c=u=>{const g=`${u}_from`,y=`${u}_to`,x=i[g],k=i[y];if(delete i[g],delete i[y],x&&k)i[u]=["between",[`${x} 00:00:00`,`${k} 23:59:59`]];else if(x)i[u]=[">=",`${x} 00:00:00`];else if(k){const N=new Date(k);isNaN(N.getTime())||(N.setDate(N.getDate()+1),i[u]=["<",`${N.toISOString().slice(0,10)} 00:00:00`])}};return r==="creation"&&c("creation"),r==="modified"&&c("modified"),i}function pm(e="creation desc"){const[r,a]=Li(),n=LL(r.get("sort_by")||e,e),i=r.get("date_filter_by")||"",c=r.get("date_start")||"",u=r.get("date_end")||"",g=Math.max(0,parseInt(r.get("page")||"1",10)-1),y=E.useCallback((A,I=!1)=>{const z=new URLSearchParams(r);for(const[U,B]of Object.entries(A))B===null||B===""?z.delete(U):z.set(U,B);I&&z.delete("page"),a(z,{replace:!0})},[r,a]),x=E.useCallback(A=>y({sort_by:A},!0),[y]),k=E.useCallback(A=>y({date_filter_by:A||null},!0),[y]),N=E.useCallback(A=>y({date_start:A||null},!0),[y]),C=E.useCallback(A=>y({date_end:A||null},!0),[y]),O=E.useCallback(A=>y({page:A<=0?null:String(A+1)}),[y]),D=E.useCallback(()=>y({page:null}),[y]);return E.useMemo(()=>({sortBy:n,dateFilterBy:i,dateStart:c,dateEnd:u,page:g,setSortBy:x,setDateFilterBy:k,setDateStart:N,setDateEnd:C,setPage:O,resetPage:D}),[n,i,c,u,g,x,k,N,C,O,D])}function ym(){const[e,r]=E.useState(()=>_u()),[a,n]=E.useState(!_u());return E.useEffect(()=>{let i=!1;return cm().then(({siteName:c})=>{i||!c||r(c)}).finally(()=>{i||n(!1)}),()=>{i=!0}},[]),{userPhccSiteName:e,siteLocked:!!e,loading:a}}function a1(){const[e,r]=E.useState(()=>Kp()),[a,n]=E.useState(!1),[i,c]=E.useState([]),[u,g]=E.useState(!0);E.useEffect(()=>{let k=!1;return cm().then(({hospital:N,isLocked:C,allowedHospitals:O})=>{k||(c(O),n(C),N&&r(N))}).finally(()=>{k||g(!1)}),()=>{k=!0}},[]);const y=E.useCallback(k=>{a||r(k)},[a]),x=E.useMemo(()=>_3(i),[i]);return{filterHospital:e,filtersLocked:a,allowedHospitals:i,hospitalLinkFilters:x,loading:u,handleHospitalChange:y}}const IL=({isOpen:e,onClose:r,selectedCount:a,totalCount:n,pageCount:i,onExport:c,isExporting:u,exportColumns:g})=>{const{t:y}=oa(),[x,k]=E.useState(a>0?"selected":"all_with_filters"),[N,C]=E.useState("csv"),[O,D]=E.useState(g.filter(U=>U.default).map(U=>U.key));E.useEffect(()=>{a>0?k("selected"):k("all_with_filters")},[a]);const A=U=>{D(B=>B.includes(U)?B.filter(V=>V!==U):[...B,U])},I=()=>{D(g.map(U=>U.key))},z=()=>{D(g.filter(U=>U.default).map(U=>U.key))};return e?t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.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:[t.jsx("div",{className:"bg-gradient-to-r from-green-500 to-green-600 px-6 py-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(cs,{className:"text-white text-xl"}),t.jsxs("h3",{className:"text-lg font-semibold text-white",children:[y("listPages.export")," ",y("assets.title")]})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:u,children:t.jsx(qt,{size:20})})]})}),t.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:y("listPages.exportFormat")}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${x==="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"} ${a===0?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"selected",checked:x==="selected",onChange:()=>k("selected"),disabled:a===0,className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Selected Rows"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export ",a," selected asset",a!==1?"s":""]})]}),a>0&&t.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:[a," selected"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${x==="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:[t.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:x==="all_on_page",onChange:()=>k("all_on_page"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Current Page"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export ",i," asset",i!==1?"s":""," on current page"]})]}),t.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"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${x==="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:[t.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:x==="all_with_filters",onChange:()=>k("all_with_filters"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"All Records (with current filters)"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export all ",n," asset",n!==1?"s":""," matching current filters"]})]}),t.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:[n," total"]})]})]})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:y("listPages.exportFormat")}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${N==="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:[t.jsx("input",{type:"radio",name:"format",value:"csv",checked:N==="csv",onChange:()=>C("csv"),className:"text-green-600 focus:ring-green-500"}),t.jsx(Kd,{className:"text-green-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:y("listPages.csv")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Comma-separated values"})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${N==="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:[t.jsx("input",{type:"radio",name:"format",value:"excel",checked:N==="excel",onChange:()=>C("excel"),className:"text-green-600 focus:ring-green-500"}),t.jsx(cl,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:y("listPages.excel")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"XLSX spreadsheet"})]})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Columns to Export"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:I,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Select All"}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:z,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Reset to Default"})]})]}),t.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:g.map(U=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${O.includes(U.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:[t.jsx("input",{type:"checkbox",checked:O.includes(U.key),onChange:()=>A(U.key),className:"rounded text-green-600 focus:ring-green-500"}),t.jsx("span",{className:"text-sm truncate",children:U.label})]},U.key))}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:[O.length," column",O.length!==1?"s":""," selected"]})]})]}),t.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:[t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[x==="selected"&&`Exporting ${a} selected row${a!==1?"s":""}`,x==="all_on_page"&&`Exporting ${i} row${i!==1?"s":""} from current page`,x==="all_with_filters"&&`Exporting all ${n} row${n!==1?"s":""}`]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:r,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:u,children:"Cancel"}),t.jsx("button",{onClick:()=>c(x,N,O),disabled:O.length===0||u,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:u?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Exporting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Co,{}),"Export"]})})]})]})]})}):null},PL=()=>{const{t:e}=oa(),r=ua(),[a,n]=Li(),i=E.useRef(!1),{sortBy:c,dateFilterBy:u,dateStart:g,dateEnd:y,page:x,setSortBy:k,setDateFilterBy:N,setDateStart:C,setDateEnd:O,setPage:D,resetPage:A}=pm("creation desc"),[I,z]=E.useState(""),[U,B]=E.useState(null),[V,Z]=E.useState(null),W=E.useRef(null),H=20,le=[{key:"name",label:e("commonFields.assetId"),default:!0},{key:"asset_name",label:e("commonFields.assetName"),default:!0},{key:"custom_serial_number",label:e("commonFields.serialNumber"),default:!0},{key:"company",label:e("commonFields.company"),default:!0},{key:"custom_site",label:"Site Name",default:!1},{key:"location",label:e("commonFields.location"),default:!0},{key:"department",label:e("commonFields.department"),default:!1},{key:"custom_device_status",label:e("commonFields.deviceStatus"),default:!0},{key:"custom_modality",label:e("commonFields.modality"),default:!1},{key:"custom_manufacturer",label:e("commonFields.manufacturer"),default:!1},{key:"supplier",label:e("commonFields.supplier"),default:!1},{key:"asset_category",label:e("commonFields.assetCategory"),default:!1},{key:"purchase_date",label:e("commonFields.purchaseDate"),default:!1},{key:"gross_purchase_amount",label:e("commonFields.purchaseAmount"),default:!1},{key:"available_for_use_date",label:e("commonFields.availableForUseDate"),default:!1},{key:"creation",label:e("commonFields.createdOn"),default:!1},{key:"modified",label:e("commonFields.modifiedOn"),default:!0},{key:"owner",label:e("commonFields.createdBy"),default:!1},{key:"modified_by",label:e("commonFields.modifiedBy"),default:!1}],[Q,Ne]=E.useState(!1),[oe,se]=E.useState(new Set),[ce,Ce]=E.useState(!1),[ae,me]=E.useState(!1),{permissionFilters:K,loading:fe,error:Oe}=dm("Asset"),[ye,J]=E.useState(!1),G=["Maintenance Manager","Maintenance User","System Manager"];E.useEffect(()=>{xe(null,null,function*(){try{console.log("🔍 [Role Check] Starting role check...");const Sr=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:G.join(",")})})).json();console.log("🔍 [Role Check] API Response:",Sr),Sr.message?(console.log("🔍 [Role Check] User roles:",Sr.message.user_roles),console.log("🔍 [Role Check] Matching roles:",Sr.message.matching_roles),console.log("✅ [Role Check] Has allowed role:",Sr.message.has_role),J(Sr.message.has_role)):(console.error("❌ [Role Check] Invalid response:",Sr),J(!1))}catch(kt){console.error("❌ [Role Check] Error:",kt),J(!1)}})},[]);const{filterHospital:ie,filtersLocked:re,handleHospitalChange:ne,hospitalLinkFilters:ve}=a1(),{userPhccSiteName:Ve,siteLocked:Ae}=ym(),[ze,Re]=E.useState(""),[Ze,Lt]=E.useState(()=>a.get("company")||""),[mt,Zt]=E.useState(()=>a.get("site_name")||a.get("custom_site")||""),[ar,or]=E.useState(""),[yt,nr]=E.useState(""),[$t,Er]=E.useState(""),[St,Br]=E.useState(""),[Pt,it]=E.useState(""),[De,Je]=E.useState(()=>a.get("device_status")||""),[Be,vt]=E.useState(""),[jt,Ct]=E.useState(""),[Wt,pr]=E.useState(!1),[Ge,We]=E.useState(0),[At,lt]=E.useState([]),[Dt,mr]=E.useState(!1),[tr,pt]=E.useState(""),[Jt,vr]=E.useState(""),[Ir,Le]=E.useState(""),qe=E.useRef(null),Ke=E.useRef(null),Yt=E.useMemo(()=>hl(Ze,Ve),[Ze,Ve]);E.useEffect(()=>{re&&ie&&Lt(ie)},[re,ie]),E.useEffect(()=>{Ae&&Ve&&Zt(Ve)},[Ae,Ve]),E.useEffect(()=>{if(!i.current){i.current=!0;return}n(Pe=>{const kt=new URLSearchParams(Pe);return Ze?kt.set("company",Ze):kt.delete("company"),mt?kt.set("site_name",mt):kt.delete("site_name"),kt.delete("custom_site"),De?kt.set("device_status",De):kt.delete("device_status"),kt.set("page","1"),kt})},[Ze,mt,De,n]),E.useEffect(()=>{const Pe=localStorage.getItem("assetFilterPresets");Pe&<(JSON.parse(Pe))},[]),E.useEffect(()=>{const Pe=[ze,Ze,mt,$t,St,Pt,ar,yt,De,Be,jt,I].filter(Boolean).length;We(Pe)},[ze,Ze,mt,$t,St,Pt,ar,yt,De,Be,jt,I]);const gr={};ze&&(gr.name=ze),Ze&&(gr.company=Ze),mt&&(gr.custom_site=mt),ar&&(gr.custom_manufacturer=ar),yt&&(gr.supplier=yt),$t&&(gr.location=$t),St&&(gr.department=St),Pt&&(gr.custom_modality=Pt),De&&(gr.custom_device_status=De),Be&&(gr.asset_name=["like",`%${Be}%`]),jt&&(gr.custom_serial_number=["like",`%${jt}%`]),I&&(gr.asset_name=["like",`%${I}%`]),Object.assign(gr,uk(u,g,y));const{assets:jr,totalCount:Zr,hasMore:en,loading:Qt,error:wr,refetch:Vt}=rL(gr,H,x*H,c,K),{deleteAsset:Ut,loading:de}=ok();E.useEffect(()=>{!Qt&&!Q&&!fe&&Ne(!0)},[Qt,Q,fe]),E.useEffect(()=>{A()},[ze,Ze,mt,ar,yt,$t,St,Pt,De,Be,jt,I,c,u,g,y]),E.useEffect(()=>{se(new Set)},[ze,Ze,mt,ar,yt,$t,St,Pt,De,Be,jt,I,x]);const ge=Pe=>{vr(Pe),qe.current&&clearTimeout(qe.current),qe.current=window.setTimeout(()=>{vt(Pe)},800)},be=Pe=>{Le(Pe),Ke.current&&clearTimeout(Ke.current),Ke.current=window.setTimeout(()=>{Ct(Pe)},800)},we=(Pe,kt)=>{Pe.key==="Enter"&&(Pe.preventDefault(),kt==="assetName"?(qe.current&&clearTimeout(qe.current),vt(Jt)):kt==="serialNumber"&&(Ke.current&&clearTimeout(Ke.current),Ct(Ir)))},ke=()=>{if(!tr.trim()){alert("Please enter a filter name");return}const Pe={id:Date.now(),name:tr,filters:{filterAssetId:ze,filterCompany:Ze,filterSite:mt,filterLocation:$t,filterDepartment:St,filterModality:Pt,filterManufacturer:ar,filterSupplier:yt,filterDeviceStatus:De,filterAssetName:Be,filterSerialNumber:jt,searchTerm:I}},kt=[...At,Pe];lt(kt),pt(""),mr(!1),localStorage.setItem("assetFilterPresets",JSON.stringify(kt))},Te=Pe=>{const kt=Pe.filters;Re(kt.filterAssetId||""),Lt(kt.filterCompany||""),Zt(kt.filterSite||""),Er(kt.filterLocation||""),Br(kt.filterDepartment||""),it(kt.filterModality||""),or(kt.filterManufacturer||""),nr(kt.filterSupplier||""),Je(kt.filterDeviceStatus||""),vt(kt.filterAssetName||""),vr(kt.filterAssetName||""),Ct(kt.filterSerialNumber||""),Le(kt.filterSerialNumber||""),z(kt.searchTerm||"")},Qe=Pe=>{const kt=At.filter(Sr=>Sr.id!==Pe);lt(kt),localStorage.setItem("assetFilterPresets",JSON.stringify(kt))};E.useEffect(()=>()=>{qe.current&&clearTimeout(qe.current),Ke.current&&clearTimeout(Ke.current)},[]);const bt=Pe=>Pe?new Date(Pe).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"-";E.useEffect(()=>{const Pe=kt=>{W.current&&!W.current.contains(kt.target)&&Z(null)};return V&&document.addEventListener("mousedown",Pe),()=>{document.removeEventListener("mousedown",Pe)}},[V]);const et=Pe=>{se(kt=>{const Sr=new Set(kt);return Sr.has(Pe)?Sr.delete(Pe):Sr.add(Pe),Sr})},at=()=>{oe.size===jr.length?se(new Set):se(new Set(jr.map(Pe=>Pe.name)))},nt=jr.length>0&&oe.size===jr.length,Ot=oe.size>0&&oe.size<jr.length,It=E.useCallback(()=>xe(null,null,function*(){const Pe=[];let kt=0;const Sr=100;let la=!0;for(;la;)try{const Un=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Asset",filters:_e(_e({},gr),K),fields:["*"],limit_start:kt*Sr,limit_page_length:Sr,order_by:"creation desc"})})).json()).message||[];Pe.push(...Un),Un.length<Sr?la=!1:kt++,kt>100&&(console.warn("Export safety limit reached"),la=!1)}catch(Dr){throw console.error("Error fetching assets for export:",Dr),Dr}return Pe}),[gr,K]),Ht=(Pe,kt,Sr)=>xe(null,null,function*(){me(!0);try{let la=[];switch(Pe){case"selected":la=jr.filter(Da=>oe.has(Da.name));break;case"all_on_page":la=jr;break;case"all_with_filters":la=yield It();break}if(la.length===0){alert("No data to export");return}const Dr=Sr.map(Da=>{const Un=le.find(hr=>hr.key===Da);return(Un==null?void 0:Un.label)||Da});if(kt==="csv"){const Da=[Dr.join(","),...la.map(Rs=>Sr.map(_s=>{let kr=Rs[_s]||"";return typeof kr=="string"&&(kr.includes(",")||kr.includes('"')||kr.includes(`
|
||
`))&&(kr=`"${kr.replace(/"/g,'""')}"`),kr}).join(","))].join(`
|
||
`),Un=new Blob(["\uFEFF"+Da],{type:"text/csv;charset=utf-8;"}),hr=URL.createObjectURL(Un),Jr=document.createElement("a");Jr.href=hr,Jr.download=`assets_export_${new Date().toISOString().split("T")[0]}.csv`,Jr.click(),URL.revokeObjectURL(hr)}else if(kt==="excel"){const Da=[Dr,...la.map(Jr=>Sr.map(Rs=>Jr[Rs]||""))],Un=Wa.aoa_to_sheet(Da),hr=Wa.book_new();Wa.book_append_sheet(hr,Un,"Assets"),ul(hr,`assets_export_${new Date().toISOString().split("T")[0]}.xlsx`)}Ce(!1),se(new Set)}catch(la){console.error("Export failed:",la),alert(`Export failed: ${la instanceof Error?la.message:"Unknown error"}`)}finally{me(!1)}}),zt=()=>r("/assets/new"),Kt=Pe=>r(`/assets/${Pe}`),fr=Pe=>r(`/assets/${Pe}`),Ee=Pe=>r(`/assets/new?duplicate=${Pe}`),wt=Pe=>{const kt=new URLSearchParams;Pe.name&&kt.append("asset",Pe.name),Pe.asset_name&&kt.append("asset_name",Pe.asset_name),Pe.custom_asset_type&&kt.append("asset_type",Pe.custom_asset_type),Pe.custom_manufacturer&&kt.append("manufacturer",Pe.custom_manufacturer),Pe.custom_serial_number&&kt.append("serial_number",Pe.custom_serial_number),Pe.custom_local_id&&kt.append("local_id",Pe.custom_local_id),Pe.custom_moh_id&&kt.append("moh_id",Pe.custom_moh_id),Pe.department&&kt.append("department",Pe.department),Pe.custom_site_contractor&&kt.append("site_contractor",Pe.custom_site_contractor),Pe.custom_subcontractor&&kt.append("subcontractor",Pe.custom_subcontractor),Pe.company&&kt.append("company",Pe.company),Pe.custom_service_agreement&&kt.append("custom_service_agreement",Pe.custom_service_agreement),Pe.custom_service_coverage&&kt.append("custom_service_coverage",Pe.custom_service_coverage),Pe.custom_site&&kt.append("site_name",Pe.custom_site),Pe.custom_smeh_engg&&kt.append("smeh_engg",Pe.custom_smeh_engg),r(`/work-orders/new?${kt.toString()}`)},xr=Pe=>{r(`/work-orders?asset=${encodeURIComponent(Pe)}`)},qr=Pe=>xe(null,null,function*(){try{yield Ut(Pe),B(null),Vt(),alert("Asset deleted successfully!")}catch(kt){alert(`Failed to delete asset: ${kt instanceof Error?kt.message:"Unknown error"}`)}}),Za=Pe=>{window.open(`/assets/${Pe}?print=true`,"_blank")},Tr=()=>{Re(""),re||Lt(""),Ae||Zt(""),or(""),nr(""),Er(""),Br(""),it(""),Je(""),vt(""),Ct(""),vr(""),Le(""),z(""),qe.current&&clearTimeout(qe.current),Ke.current&&clearTimeout(Ke.current)},Ar=ze||Ze||mt||ar||yt||$t||St||Pt||De||Be||jt||I;return fe&&!Q?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading permissions..."})]})}):Oe?t.jsx("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:"⚠️ Permission Error"}),t.jsxs("div",{className:"text-red-700 dark:text-red-400 space-y-3",children:[t.jsx("p",{children:t.jsx("strong",{children:"Unable to load user permissions."})}),t.jsx("p",{children:Oe}),t.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"})]})]})}):Qt&&!Q?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("listPages.loading")})]})}):wr?t.jsx("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:t.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-yellow-800 dark:text-yellow-300 mb-4",children:"⚠️ Asset API Not Available"}),t.jsxs("div",{className:"text-yellow-700 dark:text-yellow-400 space-y-3",children:[t.jsx("p",{children:t.jsx("strong",{children:"The Asset API endpoint is not deployed yet."})}),t.jsx("button",{onClick:()=>r("/assets/new"),className:"mt-2 bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:"Try Creating a New Asset (Demo)"}),t.jsx("button",{onClick:Vt,className:"mt-2 ml-2 bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded",children:"Try Again"})]})]})}):t.jsxs("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-gray-800 dark:text-white break-words",children:e("assets.title")}),t.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:["Total: ",Zr," asset",Zr!==1?"s":"",oe.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",oe.size," selected"]}),Qt&&Q&&t.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[t.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-blue-500"}),"Updating..."]})]})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx(ML,{label:"Scan QR",title:"Scan Asset QR"}),t.jsxs("button",{onClick:()=>Ce(!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:Zr===0,children:[t.jsx(cs,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")}),oe.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:oe.size})]}),ye&&t.jsxs("button",{onClick:zt,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:[t.jsx(Mi,{}),t.jsx("span",{className:"font-medium",children:e("assets.addAsset")})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[t.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:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx("button",{onClick:()=>pr(!Wt),className:"text-white hover:bg-white/20 p-2 rounded-lg transition-all",children:Wt?t.jsx(Vl,{size:14}):t.jsx(nl,{size:14})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ri,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:e("listPages.filters")})]}),Ge>0&&t.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:Ge})]}),Ar&&t.jsx("div",{className:"flex-1 overflow-x-auto scrollbar-hide mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[ze&&t.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:[t.jsx("span",{className:"font-semibold",children:"Asset ID:"})," ",ze,t.jsx("button",{onClick:Pe=>{Pe.stopPropagation(),Re("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),Ze&&t.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:[t.jsx("span",{className:"font-semibold",children:"Hospital:"})," ",Ze,t.jsx("button",{onClick:Pe=>{Pe.stopPropagation(),Lt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),mt&&t.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:[t.jsx("span",{className:"font-semibold",children:"Site:"})," ",mt,!Ae&&t.jsx("button",{onClick:Pe=>{Pe.stopPropagation(),Zt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),Be&&t.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:[t.jsx("span",{className:"font-semibold",children:"Name:"})," ",Be,t.jsx("button",{onClick:Pe=>{Pe.stopPropagation(),vt(""),vr("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),jt&&t.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:[t.jsx("span",{className:"font-semibold",children:"Serial:"})," ",jt,t.jsx("button",{onClick:Pe=>{Pe.stopPropagation(),Ct(""),Le("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),De&&t.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:[t.jsx("span",{className:"font-semibold",children:"Status:"})," ",De,t.jsx("button",{onClick:Pe=>{Pe.stopPropagation(),Je("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),$t&&t.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:[t.jsx("span",{className:"font-semibold",children:"Location:"})," ",$t,t.jsx("button",{onClick:Pe=>{Pe.stopPropagation(),Er("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),St&&t.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:[t.jsx("span",{className:"font-semibold",children:"Dept:"})," ",St,t.jsx("button",{onClick:Pe=>{Pe.stopPropagation(),Br("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),Pt&&t.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:[t.jsx("span",{className:"font-semibold",children:"Modality:"})," ",Pt,t.jsx("button",{onClick:Pe=>{Pe.stopPropagation(),it("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),ar&&t.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:[t.jsx("span",{className:"font-semibold",children:"Mfr:"})," ",ar,t.jsx("button",{onClick:Pe=>{Pe.stopPropagation(),or("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),yt&&t.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:[t.jsx("span",{className:"font-semibold",children:"Supplier:"})," ",yt,t.jsx("button",{onClick:Pe=>{Pe.stopPropagation(),nr("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Ge>0&&t.jsxs("button",{onClick:()=>mr(!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:[t.jsx(Fn,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),Ar&&t.jsxs("button",{onClick:Tr,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:[t.jsx(qt,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]})]})}),Wt&&t.jsxs("div",{className:"p-4",children:[At.length>0&&t.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[t.jsx(Zl,{className:"text-yellow-500",size:12}),"Saved Filters"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:At.map(Pe=>t.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:[t.jsx("button",{onClick:()=>Te(Pe),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:Pe.name}),t.jsx("button",{onClick:()=>Qe(Pe.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(ma,{size:10})})]},Pe.id))})]}),t.jsx("div",{className:"space-y-5",children:t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-3",children:[t.jsx(Bu,{sortBy:c,dateFilterBy:u,dateStart:g,dateEnd:y,onSortByChange:k,onDateFilterByChange:N,onDateStartChange:C,onDateEndChange:O,includeAssetNameSort:!0}),t.jsxs("div",{className:"relative z-[60]",children:[t.jsx(er,{label:"Asset ID",doctype:"Asset",value:ze,onChange:Pe=>Re(Pe),placeholder:"Select Asset ID",disabled:!1,compact:!0}),ze&&t.jsx("button",{onClick:()=>Re(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Asset Name"}),t.jsx("input",{type:"text",value:Jt,onChange:Pe=>ge(Pe.target.value),onKeyDown:Pe=>we(Pe,"assetName"),placeholder:"Type to search...",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"}),Jt&&Jt!==Be&&t.jsx("span",{className:"absolute right-2 top-6 text-[9px] text-blue-500 animate-pulse",children:"typing..."}),Be&&t.jsx("button",{onClick:()=>{vt(""),vr("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Serial Number"}),t.jsx("input",{type:"text",value:Ir,onChange:Pe=>be(Pe.target.value),onKeyDown:Pe=>we(Pe,"serialNumber"),placeholder:"Type to search...",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"}),Ir&&Ir!==jt&&t.jsx("span",{className:"absolute right-2 top-6 text-[9px] text-blue-500 animate-pulse",children:"typing..."}),jt&&t.jsx("button",{onClick:()=>{Ct(""),Le("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[59]",children:[t.jsx(er,{label:"Hospital",doctype:"Company",value:Ze,onChange:Pe=>{ne(Pe),Lt(Pe)},placeholder:"Select Hospital",disabled:re,compact:!0,filters:ve}),Ze&&!re&&t.jsx("button",{onClick:()=>{ne(""),Lt("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[58]",children:[t.jsx(er,{label:"PHCC Site",doctype:"Mobile Team Site",value:mt,onChange:Pe=>Zt(Pe),placeholder:"Select Site",disabled:Ae,filters:Yt,compact:!0}),mt&&!Ae&&t.jsx("button",{onClick:()=>Zt(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Device Status"}),t.jsxs("select",{value:De,onChange:Pe=>Je(Pe.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:[t.jsx("option",{value:"",children:"All Status"}),t.jsx("option",{value:"Up",children:"✓ Up"}),t.jsx("option",{value:"Down",children:"⚠ Down"})]}),De&&t.jsx("button",{onClick:()=>Je(""),className:"absolute right-8 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[57]",children:[t.jsx(er,{label:"Location",doctype:"Location",value:$t,onChange:Pe=>Er(Pe),placeholder:"Select Location",disabled:!1,compact:!0}),$t&&t.jsx("button",{onClick:()=>Er(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[56]",children:[t.jsx(er,{label:"Department",doctype:"Department",value:St,onChange:Pe=>Br(Pe),placeholder:"Select Department",disabled:!1,compact:!0}),St&&t.jsx("button",{onClick:()=>Br(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[55]",children:[t.jsx(er,{label:"Modality",doctype:"Modality",value:Pt,onChange:Pe=>it(Pe),placeholder:"Select Modality",disabled:!1,compact:!0}),Pt&&t.jsx("button",{onClick:()=>it(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[54]",children:[t.jsx(er,{label:"Manufacturer",doctype:"Manufacturer",value:ar,onChange:Pe=>or(Pe),placeholder:"Select Manufacturer",disabled:!1,compact:!0}),ar&&t.jsx("button",{onClick:()=>or(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[53]",children:[t.jsx(er,{label:"Supplier",doctype:"Supplier",value:yt,onChange:Pe=>nr(Pe),placeholder:"Select Supplier",disabled:!1,compact:!0}),yt&&t.jsx("button",{onClick:()=>nr(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]})]})})})]})]}),Dt&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:"Save Filter Preset"}),t.jsx("input",{type:"text",value:tr,onChange:Pe=>pt(Pe.target.value),onKeyDown:Pe=>{Pe.key==="Enter"&&(Pe.preventDefault(),ke())},placeholder:"Enter filter name (e.g., 'My Active Assets')",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}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{mr(!1),pt("")},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"}),t.jsxs("button",{onClick:ke,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:[t.jsx(Fn,{size:12}),"Save Filter"]})]})]})}),t.jsx(IL,{isOpen:ce,onClose:()=>Ce(!1),selectedCount:oe.size,totalCount:Zr,pageCount:jr.length,onExport:Ht,isExporting:ae,exportColumns:le}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden relative",children:[Qt&&Q&&t.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:t.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[t.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-blue-500"}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Filtering..."})]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left",children:t.jsx("button",{onClick:at,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:nt?"Deselect all":"Select all",children:nt?t.jsx(qs,{className:"text-blue-600 dark:text-blue-400",size:18}):Ot?t.jsxs("div",{className:"relative",children:[t.jsx(Pn,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Pn,{size:18})})}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Asset Name"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Serial No"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Company"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Location"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Status"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Updated on"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Actions"})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:jr.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(_o,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:"No assets found"}),Ar?t.jsx("button",{onClick:Tr,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:"Clear filters"}):ye?t.jsx("button",{onClick:zt,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:"Create your first asset"}):null]})})}):jr.map(Pe=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${oe.has(Pe.name)?"bg-blue-50 dark:bg-blue-900/20":""}`,onClick:()=>Kt(Pe.name),children:[t.jsx("td",{className:"px-4 py-4",onClick:kt=>kt.stopPropagation(),children:t.jsx("button",{onClick:()=>et(Pe.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:oe.has(Pe.name)?t.jsx(qs,{className:"text-blue-600 dark:text-blue-400",size:18}):t.jsx(Pn,{size:18})})}),t.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:Pe.asset_name}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:Pe.name})]}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:Pe.custom_serial_number||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:Pe.company||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:Pe.location||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:Pe.custom_device_status||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:bt(Pe.modified)}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:t.jsxs("div",{className:"flex items-center gap-1",onClick:kt=>kt.stopPropagation(),children:[t.jsx("button",{onClick:()=>Kt(Pe.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:t.jsx(to,{})}),t.jsx("button",{onClick:()=>fr(Pe.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 Asset",children:t.jsx(Yn,{})}),t.jsx("button",{onClick:()=>Ee(Pe.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 Asset",children:t.jsx(Zd,{})}),t.jsx("button",{onClick:()=>wt(Pe),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:"Create Work Order",children:t.jsx(rv,{})}),t.jsx("button",{onClick:()=>xr(Pe.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:"View Linked Work Orders",children:t.jsx(Kx,{})}),t.jsx("button",{onClick:()=>B(Pe.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 Asset",disabled:de,children:t.jsx(ma,{})}),t.jsxs("div",{className:"relative",ref:V===Pe.name?W:null,children:[t.jsx("button",{onClick:()=>Z(V===Pe.name?null:Pe.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:t.jsx(Eu,{})}),V===Pe.name&&t.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:[t.jsxs("button",{onClick:()=>{wt(Pe),Z(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:[t.jsx(rv,{className:"text-orange-500"}),"Create Work Order"]}),t.jsxs("button",{onClick:()=>{xr(Pe.name),Z(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:[t.jsx(Kx,{className:"text-cyan-500"}),"View Linked WOs"]}),t.jsxs("button",{onClick:()=>{Za(Pe.name),Z(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:[t.jsx(sl,{className:"text-purple-500"}),"Print Asset"]})]})]})]})})]},Pe.name))})]})}),t.jsx(Fu,{currentPage:x+1,totalCount:Zr,pageSize:H,hasMore:en,itemLabel:e("pagination.assets"),onPageChange:Pe=>D(Math.max(0,Pe-1))})]}),U&&t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.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:t.jsx(ma,{className:"text-red-600 dark:text-red-400 text-xl"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Delete Asset"}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:"Are you sure you want to delete this asset? This action cannot be undone."}),t.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:t.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[t.jsx("strong",{children:"Asset ID:"})," ",U]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>B(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:"Cancel"}),t.jsx("button",{onClick:()=>qr(U),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?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Deleting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(ma,{}),"Delete Asset"]})})]})]})]})})}),t.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;
|
||
}
|
||
`})]})},FL=e=>{const[r,a]=E.useState([]),[n,i]=E.useState(new Set),[c,u]=E.useState(!0),[g,y]=E.useState(null);return E.useEffect(()=>{xe(null,null,function*(){try{u(!0);const N=yield _t.apiCall(`/api/resource/DocType/${e}`),O=(N.data||N).fields||[],D=new Set;O.forEach(A=>{A.allow_on_submit===1&&D.add(A.fieldname)}),a(O),i(D),y(null)}catch(N){console.error(`[DocTypeMeta] Error fetching DocType meta for ${e}:`,N),y(N instanceof Error?N.message:"Unknown error"),a([]),i(new Set)}finally{u(!1)}})},[e]),{fields:r,allowOnSubmitFields:n,isAllowedOnSubmit:k=>n.has(k),loading:c,error:g}};function Ux(e,r){if(!e||(e=e.trim(),!e))return!1;if(!e.startsWith("eval:"))return!!r[e];const a=e.substring(5).trim();try{return new Function("doc",`
|
||
try {
|
||
return Boolean(${a});
|
||
} catch (e) {
|
||
console.warn('Expression evaluation error:', e);
|
||
return false;
|
||
}
|
||
`)(r)}catch(n){return console.warn(`Failed to evaluate expression: ${e}`,n),!1}}function BL(e){if(!e)return null;const r=e.split(".");return r.length!==2?null:{linkField:r[0],targetField:r[1]}}const zx={};function hk(e,r){const[a,n]=E.useState([]),[i,c]=E.useState(!0),[u,g]=E.useState(null);E.useEffect(()=>{if(!e){c(!1);return}if(zx[e]){n(zx[e]),c(!1);return}xe(null,null,function*(){var U;c(!0);try{const B=yield _t.apiCall(`/api/method/frappe.client.get_doc?doctype=DocType&name=${encodeURIComponent(e)}`,{credentials:"include"});if((U=B==null?void 0:B.message)!=null&&U.fields){const V=B.message.fields.map(Z=>({fieldname:Z.fieldname,label:Z.label,fieldtype:Z.fieldtype,options:Z.options,reqd:Z.reqd,hidden:Z.hidden,read_only:Z.read_only,depends_on:Z.depends_on,mandatory_depends_on:Z.mandatory_depends_on,read_only_depends_on:Z.read_only_depends_on,fetch_from:Z.fetch_from,fetch_if_empty:Z.fetch_if_empty,default:Z.default,description:Z.description,in_list_view:Z.in_list_view,permlevel:Z.permlevel,allow_on_submit:Z.allow_on_submit}));zx[e]=V,n(V)}}catch(B){console.warn(`Could not fetch DocType meta for ${e}:`,B.message),g(B.message)}finally{c(!1)}})},[e]);const y=E.useMemo(()=>{const z={};return a.forEach(U=>{z[U.fieldname]=U}),z},[a]),x=E.useCallback(z=>{const U=y[z];if(!U)return{isVisible:!0,isReadOnly:!1,isMandatory:!1};let B=!(U.hidden===1||U.hidden===!0);U.depends_on&&B&&(B=Ux(U.depends_on,r));let V=U.read_only===1||U.read_only===!0;U.read_only_depends_on&&(V=V||Ux(U.read_only_depends_on,r));let Z=U.reqd===1||U.reqd===!0;return U.mandatory_depends_on&&(Z=Z||Ux(U.mandatory_depends_on,r)),{isVisible:B,isReadOnly:V,isMandatory:Z}},[y,r]),k=E.useCallback(z=>x(z).isVisible,[x]),N=E.useCallback(z=>{const U=x(z);return U.isVisible&&U.isMandatory},[x]),C=E.useCallback(z=>x(z).isReadOnly,[x]),O=E.useCallback(z=>{const U=y[z];return(U==null?void 0:U.label)||z},[y]),D=E.useCallback(z=>{const U=y[z];return U!=null&&U.options?U.fieldtype==="Select"?U.options.split(`
|
||
`).filter(B=>B.trim()!==""):[]:[]},[y]),A=E.useCallback((z,U)=>{const B=y[z];if(!(B!=null&&B.fetch_from)||!U)return;const V=BL(B.fetch_from);if(V)return U[V.targetField]},[y]),I=E.useCallback(()=>{const z={};return a.forEach(U=>{const B=x(U.fieldname);if(B.isVisible&&B.isMandatory){const V=r[U.fieldname];(V==null||V==="")&&(z[U.fieldname]=`${U.label||U.fieldname} is required`)}}),{valid:Object.keys(z).length===0,errors:z}},[a,r,x]);return{loading:i,error:u,fields:a,getFieldState:x,shouldShowField:k,isMandatory:N,isReadOnly:C,getFieldLabel:O,getFieldOptions:D,getFetchFromValue:A,validateMandatory:I}}function Kl(e,{enabled:r=!0,fields:a}){const n=a.join("|");E.useEffect(()=>{if(!r)return;let i=!1;return sM().then(c=>{i||!c||e(u=>{const g={};for(const y of a)u[y]||(g[y]=c);return Object.keys(g).length===0?u:_e(_e({},u),g)})}),()=>{i=!0}},[r,n,e])}function fk(e){var r,a,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(r=0;r<i;r++)e[r]&&(a=fk(e[r]))&&(n&&(n+=" "),n+=a)}else for(a in e)e[a]&&(n&&(n+=" "),n+=a);return n}function Ec(){for(var e,r,a=0,n="",i=arguments.length;a<i;a++)(e=arguments[a])&&(r=fk(e))&&(n&&(n+=" "),n+=r);return n}function UL(e){if(typeof document=="undefined")return;let r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}UL(`: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 Uu=e=>typeof e=="number"&&!isNaN(e),Mc=e=>typeof e=="string",ll=e=>typeof e=="function",zL=e=>Mc(e)||Uu(e),dp=e=>Mc(e)||ll(e)?e:null,HL=(e,r)=>e===!1||Uu(e)&&e>0?e:r,up=e=>E.isValidElement(e)||Mc(e)||ll(e)||Uu(e);function VL(e,r,a=300){let{scrollHeight:n,style:i}=e;requestAnimationFrame(()=>{i.minHeight="initial",i.height=n+"px",i.transition=`all ${a}ms`,requestAnimationFrame(()=>{i.height="0",i.padding="0",i.margin="0",setTimeout(r,a)})})}function WL({enter:e,exit:r,appendPosition:a=!1,collapse:n=!0,collapseDuration:i=300}){return function({children:c,position:u,preventExitTransition:g,done:y,nodeRef:x,isIn:k,playToast:N}){let C=a?`${e}--${u}`:e,O=a?`${r}--${u}`:r,D=E.useRef(0);return E.useLayoutEffect(()=>{let A=x.current,I=C.split(" "),z=U=>{U.target===x.current&&(N(),A.removeEventListener("animationend",z),A.removeEventListener("animationcancel",z),D.current===0&&U.type!=="animationcancel"&&A.classList.remove(...I))};A.classList.add(...I),A.addEventListener("animationend",z),A.addEventListener("animationcancel",z)},[]),E.useEffect(()=>{let A=x.current,I=()=>{A.removeEventListener("animationend",I),n?VL(A,y,i):y()};k||(g?I():(D.current=1,A.className+=` ${O}`,A.addEventListener("animationend",I)))},[k]),ea.createElement(ea.Fragment,null,c)}}function C_(e,r){return{content:mk(e.content,e.props),containerId:e.props.containerId,id:e.props.toastId,theme:e.props.theme,type:e.props.type,data:e.props.data||{},isLoading:e.props.isLoading,icon:e.props.icon,reason:e.removalReason,status:r}}function mk(e,r,a=!1){return E.isValidElement(e)&&!Mc(e.type)?E.cloneElement(e,{closeToast:r.closeToast,toastProps:r,data:r.data,isPaused:a}):ll(e)?e({closeToast:r.closeToast,toastProps:r,data:r.data,isPaused:a}):e}function GL({closeToast:e,theme:r,ariaLabel:a="close"}){return ea.createElement("button",{className:`Toastify__close-button Toastify__close-button--${r}`,type:"button",onClick:n=>{n.stopPropagation(),e(!0)},"aria-label":a},ea.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},ea.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 $L({delay:e,isRunning:r,closeToast:a,type:n="default",hide:i,className:c,controlledProgress:u,progress:g,rtl:y,isIn:x,theme:k}){let N=i||u&&g===0,C={animationDuration:`${e}ms`,animationPlayState:r?"running":"paused"};u&&(C.transform=`scaleX(${g})`);let O=Ec("Toastify__progress-bar",u?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated",`Toastify__progress-bar-theme--${k}`,`Toastify__progress-bar--${n}`,{"Toastify__progress-bar--rtl":y}),D=ll(c)?c({rtl:y,type:n,defaultClassName:O}):Ec(O,c),A={[u&&g>=1?"onTransitionEnd":"onAnimationEnd"]:u&&g<1?null:()=>{x&&a()}};return ea.createElement("div",{className:"Toastify__progress-bar--wrp","data-hidden":N},ea.createElement("div",{className:`Toastify__progress-bar--bg Toastify__progress-bar-theme--${k} Toastify__progress-bar--${n}`}),ea.createElement("div",_e({role:"progressbar","aria-hidden":N?"true":"false","aria-label":"notification timer",className:D,style:C},A)))}var XL=1,gk=()=>`${XL++}`;function YL(e,r,a){let n=1,i=0,c=[],u=[],g=r,y=new Map,x=new Set,k=U=>(x.add(U),()=>x.delete(U)),N=()=>{u=Array.from(y.values()),x.forEach(U=>U())},C=({containerId:U,toastId:B,updateId:V})=>{let Z=U?U!==e:e!==1,W=y.has(B)&&V==null;return Z||W},O=(U,B)=>{y.forEach(V=>{var Z;(B==null||B===V.props.toastId)&&((Z=V.toggle)==null||Z.call(V,U))})},D=U=>{var B,V;(V=(B=U.props)==null?void 0:B.onClose)==null||V.call(B,U.removalReason),U.isActive=!1},A=U=>{if(U==null)y.forEach(D);else{let B=y.get(U);B&&D(B)}N()},I=()=>{i-=c.length,c=[]},z=U=>{var B,V;let{toastId:Z,updateId:W}=U.props,H=W==null;U.staleId&&y.delete(U.staleId),U.isActive=!0,y.set(Z,U),N(),a(C_(U,H?"added":"updated")),H&&((V=(B=U.props).onOpen)==null||V.call(B))};return{id:e,props:g,observe:k,toggle:O,removeToast:A,toasts:y,clearQueue:I,buildToast:(U,B)=>{if(C(B))return;let{toastId:V,updateId:Z,data:W,staleId:H,delay:le}=B,Q=Z==null;Q&&i++;let Ne=$e(_e($e(_e({},g),{style:g.toastStyle,key:n++}),Object.fromEntries(Object.entries(B).filter(([se,ce])=>ce!=null))),{toastId:V,updateId:Z,data:W,isIn:!1,className:dp(B.className||g.toastClassName),progressClassName:dp(B.progressClassName||g.progressClassName),autoClose:B.isLoading?!1:HL(B.autoClose,g.autoClose),closeToast(se){y.get(V).removalReason=se,A(V)},deleteToast(){let se=y.get(V);if(se!=null){if(a(C_(se,"removed")),y.delete(V),i--,i<0&&(i=0),c.length>0){z(c.shift());return}N()}}});Ne.closeButton=g.closeButton,B.closeButton===!1||up(B.closeButton)?Ne.closeButton=B.closeButton:B.closeButton===!0&&(Ne.closeButton=up(g.closeButton)?g.closeButton:!0);let oe={content:U,props:Ne,staleId:H};g.limit&&g.limit>0&&i>g.limit&&Q?c.push(oe):Uu(le)?setTimeout(()=>{z(oe)},le):z(oe)},setProps(U){g=U},setToggle:(U,B)=>{let V=y.get(U);V&&(V.toggle=B)},isToastActive:U=>{var B;return(B=y.get(U))==null?void 0:B.isActive},getSnapshot:()=>u}}var As=new Map,wu=[],hp=new Set,ZL=e=>hp.forEach(r=>r(e)),xk=()=>As.size>0;function qL(){wu.forEach(e=>yk(e.content,e.options)),wu=[]}var KL=(e,{containerId:r})=>{var a;return(a=As.get(r||1))==null?void 0:a.toasts.get(e)};function pk(e,r){var a;if(r)return!!((a=As.get(r))!=null&&a.isToastActive(e));let n=!1;return As.forEach(i=>{i.isToastActive(e)&&(n=!0)}),n}function JL(e){if(!xk()){wu=wu.filter(r=>e!=null&&r.options.toastId!==e);return}if(e==null||zL(e))As.forEach(r=>{r.removeToast(e)});else if(e&&("containerId"in e||"id"in e)){let r=As.get(e.containerId);r?r.removeToast(e.id):As.forEach(a=>{a.removeToast(e.id)})}}var QL=(e={})=>{As.forEach(r=>{r.props.limit&&(!e.containerId||r.id===e.containerId)&&r.clearQueue()})};function yk(e,r){up(e)&&(xk()||wu.push({content:e,options:r}),As.forEach(a=>{a.buildToast(e,r)}))}function eI(e){var r;(r=As.get(e.containerId||1))==null||r.setToggle(e.id,e.fn)}function bk(e,r){As.forEach(a=>{(r==null||!(r!=null&&r.containerId)||(r==null?void 0:r.containerId)===a.id)&&a.toggle(e,r==null?void 0:r.id)})}function tI(e){let r=e.containerId||1;return{subscribe(a){let n=YL(r,e,ZL);As.set(r,n);let i=n.observe(a);return qL(),()=>{i(),As.delete(r)}},setProps(a){var n;(n=As.get(r))==null||n.setProps(a)},getSnapshot(){var a;return(a=As.get(r))==null?void 0:a.getSnapshot()}}}function rI(e){return hp.add(e),()=>{hp.delete(e)}}function aI(e){return e&&(Mc(e.toastId)||Uu(e.toastId))?e.toastId:gk()}function zu(e,r){return yk(e,r),r.toastId}function bm(e,r){return $e(_e({},r),{type:r&&r.type||e,toastId:aI(r)})}function vm(e){return(r,a)=>zu(r,bm(e,a))}function dr(e,r){return zu(e,bm("default",r))}dr.loading=(e,r)=>zu(e,bm("default",_e({isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1},r)));function nI(e,{pending:r,error:a,success:n},i){let c;r&&(c=Mc(r)?dr.loading(r,i):dr.loading(r.render,_e(_e({},i),r)));let u={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},g=(x,k,N)=>{if(k==null){dr.dismiss(c);return}let C=$e(_e(_e({type:x},u),i),{data:N}),O=Mc(k)?{render:k}:k;return c?dr.update(c,_e(_e({},C),O)):dr(O.render,_e(_e({},C),O)),N},y=ll(e)?e():e;return y.then(x=>g("success",n,x)).catch(x=>g("error",a,x)),y}dr.promise=nI;dr.success=vm("success");dr.info=vm("info");dr.error=vm("error");dr.warning=vm("warning");dr.warn=dr.warning;dr.dark=(e,r)=>zu(e,bm("default",_e({theme:"dark"},r)));function sI(e){JL(e)}dr.dismiss=sI;dr.clearWaitingQueue=QL;dr.isActive=pk;dr.update=(e,r={})=>{let a=KL(e,r);if(a){let{props:n,content:i}=a,c=$e(_e(_e({delay:100},n),r),{toastId:r.toastId||e,updateId:gk()});c.toastId!==e&&(c.staleId=e);let u=c.render||i;delete c.render,zu(u,c)}};dr.done=e=>{dr.update(e,{progress:1})};dr.onChange=rI;dr.play=e=>bk(!0,e);dr.pause=e=>bk(!1,e);function iI(e){var r;let{subscribe:a,getSnapshot:n,setProps:i}=E.useRef(tI(e)).current;i(e);let c=(r=E.useSyncExternalStore(a,n,n))==null?void 0:r.slice();function u(g){if(!c)return[];let y=new Map;return e.newestOnTop&&c.reverse(),c.forEach(x=>{let{position:k}=x.props;y.has(k)||y.set(k,[]),y.get(k).push(x)}),Array.from(y,x=>g(x[0],x[1]))}return{getToastToRender:u,isToastActive:pk,count:c==null?void 0:c.length}}function oI(e){let[r,a]=E.useState(!1),[n,i]=E.useState(!1),c=E.useRef(null),u=E.useRef({start:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,didMove:!1}).current,{autoClose:g,pauseOnHover:y,closeToast:x,onClick:k,closeOnClick:N}=e;eI({id:e.toastId,containerId:e.containerId,fn:a}),E.useEffect(()=>{if(e.pauseOnFocusLoss)return C(),()=>{O()}},[e.pauseOnFocusLoss]);function C(){document.hasFocus()||z(),window.addEventListener("focus",I),window.addEventListener("blur",z)}function O(){window.removeEventListener("focus",I),window.removeEventListener("blur",z)}function D(H){if(e.draggable===!0||e.draggable===H.pointerType){U();let le=c.current;u.canCloseOnClick=!0,u.canDrag=!0,le.style.transition="none",e.draggableDirection==="x"?(u.start=H.clientX,u.removalDistance=le.offsetWidth*(e.draggablePercent/100)):(u.start=H.clientY,u.removalDistance=le.offsetHeight*(e.draggablePercent===80?e.draggablePercent*1.5:e.draggablePercent)/100)}}function A(H){let{top:le,bottom:Q,left:Ne,right:oe}=c.current.getBoundingClientRect();H.nativeEvent.type!=="touchend"&&e.pauseOnHover&&H.clientX>=Ne&&H.clientX<=oe&&H.clientY>=le&&H.clientY<=Q?z():I()}function I(){a(!0)}function z(){a(!1)}function U(){u.didMove=!1,document.addEventListener("pointermove",V),document.addEventListener("pointerup",Z)}function B(){document.removeEventListener("pointermove",V),document.removeEventListener("pointerup",Z)}function V(H){let le=c.current;if(u.canDrag&&le){u.didMove=!0,r&&z(),e.draggableDirection==="x"?u.delta=H.clientX-u.start:u.delta=H.clientY-u.start,u.start!==H.clientX&&(u.canCloseOnClick=!1);let Q=e.draggableDirection==="x"?`${u.delta}px, var(--y)`:`0, calc(${u.delta}px + var(--y))`;le.style.transform=`translate3d(${Q},0)`,le.style.opacity=`${1-Math.abs(u.delta/u.removalDistance)}`}}function Z(){B();let H=c.current;if(u.canDrag&&u.didMove&&H){if(u.canDrag=!1,Math.abs(u.delta)>u.removalDistance){i(!0),e.closeToast(!0),e.collapseAll();return}H.style.transition="transform 0.2s, opacity 0.2s",H.style.removeProperty("transform"),H.style.removeProperty("opacity")}}let W={onPointerDown:D,onPointerUp:A};return g&&y&&(W.onMouseEnter=z,e.stacked||(W.onMouseLeave=I)),N&&(W.onClick=H=>{k&&k(H),u.canCloseOnClick&&x(!0)}),{playToast:I,pauseToast:z,isRunning:r,preventExitTransition:n,toastRef:c,eventHandlers:W}}var lI=typeof window!="undefined"?E.useLayoutEffect:E.useEffect,_m=i=>{var c=i,{theme:e,type:r,isLoading:a}=c,n=Gs(c,["theme","type","isLoading"]);return ea.createElement("svg",_e({viewBox:"0 0 24 24",width:"100%",height:"100%",fill:e==="colored"?"currentColor":`var(--toastify-icon-color-${r})`},n))};function cI(e){return ea.createElement(_m,_e({},e),ea.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 dI(e){return ea.createElement(_m,_e({},e),ea.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 uI(e){return ea.createElement(_m,_e({},e),ea.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 hI(e){return ea.createElement(_m,_e({},e),ea.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 fI(){return ea.createElement("div",{className:"Toastify__spinner"})}var fp={info:dI,warning:cI,success:uI,error:hI,spinner:fI},mI=e=>e in fp;function gI({theme:e,type:r,isLoading:a,icon:n}){let i=null,c={theme:e,type:r};return n===!1||(ll(n)?i=n($e(_e({},c),{isLoading:a})):E.isValidElement(n)?i=E.cloneElement(n,c):a?i=fp.spinner():mI(r)&&(i=fp[r](c))),i}var xI=e=>{let{isRunning:r,preventExitTransition:a,toastRef:n,eventHandlers:i,playToast:c}=oI(e),{closeButton:u,children:g,autoClose:y,onClick:x,type:k,hideProgressBar:N,closeToast:C,transition:O,position:D,className:A,style:I,progressClassName:z,updateId:U,role:B,progress:V,rtl:Z,toastId:W,deleteToast:H,isIn:le,isLoading:Q,closeOnClick:Ne,theme:oe,ariaLabel:se}=e,ce=Ec("Toastify__toast",`Toastify__toast-theme--${oe}`,`Toastify__toast--${k}`,{"Toastify__toast--rtl":Z},{"Toastify__toast--close-on-click":Ne}),Ce=ll(A)?A({rtl:Z,position:D,type:k,defaultClassName:ce}):Ec(ce,A),ae=gI(e),me=!!V||!y,K={closeToast:C,type:k,theme:oe},fe=null;return u===!1||(ll(u)?fe=u(K):E.isValidElement(u)?fe=E.cloneElement(u,K):fe=GL(K)),ea.createElement(O,{isIn:le,done:H,position:D,preventExitTransition:a,nodeRef:n,playToast:c},ea.createElement("div",_e($e(_e({id:W,tabIndex:0,onClick:x,"data-in":le,className:Ce},i),{style:I,ref:n}),le&&{role:B,"aria-label":se}),ae!=null&&ea.createElement("div",{className:Ec("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!Q})},ae),mk(g,e,!r),fe,!e.customProgressBar&&ea.createElement($L,$e(_e({},U&&!me?{key:`p-${U}`}:{}),{rtl:Z,theme:oe,delay:y,isRunning:r,isIn:le,closeToast:C,hide:N,type:k,className:z,controlledProgress:me,progress:V||0}))))},pI=(e,r=!1)=>({enter:`Toastify--animate Toastify__${e}-enter`,exit:`Toastify--animate Toastify__${e}-exit`,appendPosition:r}),Hu=WL(pI("bounce",!0)),yI={position:"top-right",transition:Hu,autoClose:5e3,closeButton:!0,pauseOnHover:!0,pauseOnFocusLoss:!0,draggable:"touch",draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light","aria-label":"Notifications Alt+T",hotKeys:e=>e.altKey&&e.code==="KeyT"};function wm(e){let r=_e(_e({},yI),e),a=e.stacked,[n,i]=E.useState(!0),c=E.useRef(null),{getToastToRender:u,isToastActive:g,count:y}=iI(r),{className:x,style:k,rtl:N,containerId:C,hotKeys:O}=r;function D(I){let z=Ec("Toastify__toast-container",`Toastify__toast-container--${I}`,{"Toastify__toast-container--rtl":N});return ll(x)?x({position:I,rtl:N,defaultClassName:z}):Ec(z,dp(x))}function A(){a&&(i(!0),dr.play())}return lI(()=>{var I;if(a){let z=c.current.querySelectorAll('[data-in="true"]'),U=12,B=(I=r.position)==null?void 0:I.includes("top"),V=0,Z=0;Array.from(z).reverse().forEach((W,H)=>{let le=W;le.classList.add("Toastify__toast--stacked"),H>0&&(le.dataset.collapsed=`${n}`),le.dataset.pos||(le.dataset.pos=B?"top":"bot");let Q=V*(n?.2:1)+(n?0:U*H);le.style.setProperty("--y",`${B?Q:Q*-1}px`),le.style.setProperty("--g",`${U}`),le.style.setProperty("--s",`${1-(n?Z:0)}`),V+=le.offsetHeight,Z+=.025})}},[n,y,a]),E.useEffect(()=>{function I(z){var U;let B=c.current;O(z)&&((U=B.querySelector('[tabIndex="0"]'))==null||U.focus(),i(!1),dr.pause()),z.key==="Escape"&&(document.activeElement===B||B!=null&&B.contains(document.activeElement))&&(i(!0),dr.play())}return document.addEventListener("keydown",I),()=>{document.removeEventListener("keydown",I)}},[O]),ea.createElement("section",{ref:c,className:"Toastify",id:C,onMouseEnter:()=>{a&&(i(!1),dr.pause())},onMouseLeave:A,"aria-live":"polite","aria-atomic":"false","aria-relevant":"additions text","aria-label":r["aria-label"]},u((I,z)=>{let U=z.length?_e({},k):$e(_e({},k),{pointerEvents:"none"});return ea.createElement("div",{tabIndex:-1,className:D(I),"data-stacked":a,style:U,key:`c-${I}`},z.map(({content:B,props:V})=>ea.createElement(xI,$e(_e({},V),{stacked:a,collapseAll:A,isIn:g(V.toastId,V.containerId),key:`t-${V.key}`}),B)))}))}function E_(){return xe(this,null,function*(){if(typeof window!="undefined"&&window.csrf_token)return window.csrf_token||null;try{return(yield _t.apiCall("/api/method/frappe.sessions.get_csrf_token"))||null}catch(e){return null}})}const Z0={getComments(e,r){return xe(this,null,function*(){var c;const a=JSON.stringify([["reference_doctype","=",e],["reference_name","=",r],["comment_type","in",["Comment","Info","Edit","Attachment","Like"]]]),n=JSON.stringify(["name","owner","creation","modified","modified_by","comment_type","comment_email","comment_by","content","reference_doctype","reference_name","published","seen"]),i=yield _t.apiCall(`/api/resource/Comment?filters=${encodeURIComponent(a)}&fields=${encodeURIComponent(n)}&order_by=creation asc&limit_page_length=100`);return(c=i==null?void 0:i.data)!=null?c:[]})},postComment(e,r,a){return xe(this,null,function*(){const i=yield E_(),c={"Content-Type":"application/json"};i&&(c["X-Frappe-CSRF-Token"]=i);const u=yield fetch("/api/resource/Comment",{method:"POST",credentials:"include",headers:c,body:JSON.stringify({comment_type:"Comment",reference_doctype:e,reference_name:r,content:a})});if(!u.ok){const y=yield u.json().catch(()=>({}));throw new Error((y==null?void 0:y.exc)||(y==null?void 0:y._server_messages)||"Failed to post comment")}return(yield u.json()).data})},deleteComment(e){return xe(this,null,function*(){const a=yield E_(),n={};a&&(n["X-Frappe-CSRF-Token"]=a);const i=yield fetch(`/api/resource/Comment/${encodeURIComponent(e)}`,{method:"DELETE",credentials:"include",headers:n});if(!i.ok){const c=yield i.json().catch(()=>({}));throw new Error((c==null?void 0:c.exc)||"Failed to delete comment")}})},searchUsers(e){return xe(this,null,function*(){var u;const a=JSON.stringify(e?[["enabled","=",1],["user_type","=","System User"],["name","like",`%${e}%`]]:[["enabled","=",1],["user_type","=","System User"]]),n=JSON.stringify(["name","full_name","user_image"]),i=yield fetch(`/api/resource/User?filters=${encodeURIComponent(a)}&fields=${encodeURIComponent(n)}&limit_page_length=20&order_by=full_name asc`,{credentials:"include"});return i.ok?((u=(yield i.json()).data)!=null?u:[]).filter(g=>g.name!=="Administrator"&&g.name!=="Guest"):[]})},getCurrentUser(){return xe(this,null,function*(){return(yield(yield fetch("/api/method/frappe.auth.get_logged_user",{credentials:"include"})).json()).message||""})}};function bI({referenceDoctype:e,referenceName:r,pollInterval:a=3e4}){const[n,i]=E.useState([]),[c,u]=E.useState(!0),[g,y]=E.useState(!1),[x,k]=E.useState(null),[N,C]=E.useState(""),[O,D]=E.useState([]),[A,I]=E.useState(!1),z=E.useRef(null);E.useEffect(()=>{Z0.getCurrentUser().then(C).catch(()=>{})},[]);const U=E.useCallback(()=>xe(null,null,function*(){if(!r){i([]),u(!1);return}try{const W=yield Z0.getComments(e,r);i(W),k(null)}catch(W){console.error("Error fetching comments:",W),k(W.message||"Failed to load comments")}finally{u(!1)}}),[e,r]);E.useEffect(()=>{u(!0),U()},[U]),E.useEffect(()=>{if(!a||!r)return;const W=setInterval(U,a);return()=>clearInterval(W)},[a,U,r]);const B=E.useCallback(W=>xe(null,null,function*(){if(r){y(!0);try{yield Z0.postComment(e,r,W),yield U()}catch(H){throw H}finally{y(!1)}}}),[e,r,U]),V=E.useCallback(W=>xe(null,null,function*(){try{yield Z0.deleteComment(W),i(H=>H.filter(le=>le.name!==W))}catch(H){throw H}}),[]),Z=E.useCallback(W=>xe(null,null,function*(){z.current&&clearTimeout(z.current),I(!0),z.current=setTimeout(()=>xe(null,null,function*(){try{const H=yield Z0.searchUsers(W);D(H)}catch(H){D([])}finally{I(!1)}}),250)}),[]);return{comments:n,loading:c,posting:g,error:x,currentUser:N,refetch:U,postComment:B,deleteComment:V,mentionUsers:O,mentionLoading:A,searchMentionUsers:Z}}const vI=({value:e,onChange:r,onSubmit:a,placeholder:n="Type a comment… Use @ to mention someone",disabled:i=!1,mentionUsers:c,mentionLoading:u,onMentionSearch:g,posting:y=!1})=>{const x=E.useRef(null),k=E.useRef(null),[N,C]=E.useState(!1),[O,D]=E.useState(""),[A,I]=E.useState(null),[z,U]=E.useState(0),[B,V]=E.useState([]),Z=E.useCallback(()=>{var ce;const se=x.current;se&&(se.getBoundingClientRect(),(ce=se.offsetParent)==null||ce.getBoundingClientRect())},[]),W=se=>{var K;const ce=se.target.value,Ce=(K=se.target.selectionStart)!=null?K:0;r(ce);const ae=ce.substring(0,Ce),me=ae.lastIndexOf("@");if(me!==-1){const fe=me>0?ce[me-1]:" ";if(fe===" "||fe===`
|
||
`||me===0){const Oe=ae.substring(me+1);if(!Oe.includes(" ")||Oe.length<=30){C(!0),D(Oe),I(me),U(0),g(Oe),Z();return}}}C(!1),I(null)},H=E.useCallback(se=>{var Oe;if(A===null)return;const ce=x.current,Ce=e.substring(0,A),ae=(Oe=ce==null?void 0:ce.selectionStart)!=null?Oe:A+O.length+1,me=e.substring(ae),K=se.full_name||se.name,fe=`${Ce}@${K} ${me}`;V(ye=>[...ye,{startIndex:A,displayText:K,userId:se.name,fullName:se.full_name||se.name}]),r(fe),C(!1),I(null),D(""),setTimeout(()=>{if(ce){ce.focus();const ye=Ce.length+K.length+2;ce.selectionStart=ye,ce.selectionEnd=ye}},0)},[A,O,e,r]),le=E.useCallback(se=>{let ce=se;const Ce=window.location.origin,ae=[...B].sort((me,K)=>K.startIndex-me.startIndex);for(const me of ae){const K=`@${me.displayText}`,fe=ce.indexOf(K);if(fe===-1)continue;const Oe=`${Ce}/app/user-profile/${encodeURIComponent(me.userId)}`,ye=`<span class="mention" data-id="${me.userId}" data-value="<a href="${Oe}" target="_blank">${me.fullName}" data-denotation-char="@" data-is-group="false" data-link="${Oe}">\uFEFF<span contenteditable="false"><span class="ql-mention-denotation-char">@</span><a href="${Oe}" target="_blank">${me.fullName}</a></span>\uFEFF</span>`;ce=ce.substring(0,fe)+ye+ce.substring(fe+K.length)}return ce=ce.replace(/\n/g,"<br>"),`<div class="ql-editor read-mode"><p>${ce}</p></div>`},[B]),Q=()=>{const se=e.trim();if(!se||y)return;const ce=le(se);a(ce),V([])},Ne=se=>{if(N&&c.length>0)switch(se.key){case"ArrowDown":se.preventDefault(),U(ce=>Math.min(ce+1,c.length-1));return;case"ArrowUp":se.preventDefault(),U(ce=>Math.max(ce-1,0));return;case"Enter":se.preventDefault(),H(c[z]);return;case"Escape":se.preventDefault(),C(!1);return}se.key==="Enter"&&(se.ctrlKey||se.metaKey)&&(se.preventDefault(),Q())};E.useEffect(()=>{const se=ce=>{k.current&&!k.current.contains(ce.target)&&x.current&&!x.current.contains(ce.target)&&C(!1)};return document.addEventListener("mousedown",se),()=>document.removeEventListener("mousedown",se)},[]),E.useEffect(()=>{if(!k.current)return;const se=k.current.querySelector(`[data-idx="${z}"]`);se==null||se.scrollIntoView({block:"nearest"})},[z]);const oe="";return t.jsxs("div",{className:"relative",children:[N&&t.jsx("div",{ref:k,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:u&&c.length===0?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-sm text-gray-500 dark:text-gray-400",children:[t.jsx(Ja,{className:"animate-spin",size:12}),"Searching users…"]}):c.length===0?t.jsx("div",{className:"px-3 py-4 text-sm text-gray-500 dark:text-gray-400",children:"No users found"}):c.map((se,ce)=>t.jsxs("button",{"data-idx":ce,type:"button",className:`w-full flex items-center gap-2.5 px-3 py-2 text-left transition-colors
|
||
${ce===z?"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:()=>U(ce),onMouseDown:Ce=>{Ce.preventDefault(),H(se)},children:[se.user_image?t.jsx("img",{src:`${oe}${se.user_image}`,alt:"",className:"w-7 h-7 rounded-full object-cover flex-shrink-0"}):t.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:t.jsx(Wl,{className:"text-gray-500 dark:text-gray-400",size:10})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:se.full_name||se.name}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:se.name})]})]},se.name))}),t.jsxs("div",{className:"flex gap-2 items-end",children:[t.jsx("textarea",{ref:x,value:e,onChange:W,onKeyDown:Ne,placeholder:n,disabled:i||y,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`}),t.jsx("button",{type:"button",onClick:Q,disabled:i||y||!e.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:y?t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"animate-spin",size:12}),t.jsx("span",{children:"Posting…"})]}):t.jsx("span",{children:"Comment"})})]}),t.jsxs("p",{className:"mt-1 text-[10px] text-gray-400 dark:text-gray-500",children:[t.jsx("kbd",{className:"px-1 py-0.5 bg-gray-100 dark:bg-gray-700 rounded text-[9px]",children:"@"})," to mention · ",t.jsx("kbd",{className:"px-1 py-0.5 bg-gray-100 dark:bg-gray-700 rounded text-[9px]",children:"Ctrl+Enter"})," to post"]})]})},j_={Comment:{icon:t.jsx(uf,{size:10}),color:"text-blue-600 dark:text-blue-400",label:"Comment"},Info:{icon:t.jsx(Ad,{size:10}),color:"text-gray-500 dark:text-gray-400",label:"Info"},Edit:{icon:t.jsx(Yn,{size:10}),color:"text-orange-500 dark:text-orange-400",label:"Edit"},Attachment:{icon:t.jsx(hC,{size:10}),color:"text-purple-500 dark:text-purple-400",label:"Attachment"},Like:{icon:t.jsx(q0,{size:10}),color:"text-pink-500 dark:text-pink-400",label:"Like"}},_I=e=>{if(!e)return"";const r=new Date(e),a=new Date,n=a.getTime()-r.getTime(),i=Math.floor(n/6e4),c=Math.floor(n/36e5),u=Math.floor(n/864e5);return i<1?"Just now":i<60?`${i}m ago`:c<24?`${c}h ago`:u<7?`${u}d ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:r.getFullYear()!==a.getFullYear()?"numeric":void 0})},wI=e=>{if(!e)return"Unknown";const r=e.indexOf("@");return r===-1?e:e.substring(0,r).replace(/[._-]/g," ").replace(/\b\w/g,a=>a.toUpperCase())},kI=({html:e})=>{const r=e.replace(/<div class="ql-editor[^"]*">/g,"").replace(/<\/div>$/g,"");return t.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:r}})},Vu=({referenceDoctype:e,referenceName:r,title:a="Comments & Discussion",pollInterval:n=3e4,initialLimit:i=5,collapsible:c=!0,startCollapsed:u=!1})=>{const{comments:g,loading:y,posting:x,error:k,currentUser:N,refetch:C,postComment:O,deleteComment:D,mentionUsers:A,mentionLoading:I,searchMentionUsers:z}=bI({referenceDoctype:e,referenceName:r,pollInterval:n}),[U,B]=E.useState(!u),[V,Z]=E.useState(!1),[W,H]=E.useState(""),[le,Q]=E.useState(null),Ne=E.useMemo(()=>g.filter(Ce=>Ce.comment_type==="Comment"),[g]),oe=E.useMemo(()=>V?g:g.slice(-i),[g,V,i]),se=Ce=>xe(null,null,function*(){try{yield O(Ce),H(""),dr.success("Comment posted!",{position:"top-right",autoClose:2e3,icon:t.jsx(Ca,{})})}catch(ae){dr.error(`Failed to post comment: ${ae.message||"Unknown error"}`,{position:"top-right",autoClose:5e3,icon:t.jsx(jn,{})})}}),ce=Ce=>xe(null,null,function*(){Q(Ce);try{yield D(Ce),dr.success("Comment deleted",{position:"top-right",autoClose:2e3,icon:t.jsx(Ca,{})})}catch(ae){dr.error(`Failed to delete: ${ae.message||"Unknown error"}`,{position:"top-right",autoClose:5e3,icon:t.jsx(jn,{})})}finally{Q(null)}});return r?t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 overflow-hidden",children:[t.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&&B(Ce=>!Ce),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(uf,{className:"text-teal-500",size:16}),t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white",children:a}),Ne.length>0&&t.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})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:Ce=>{Ce.stopPropagation(),C()},disabled:y,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:t.jsx(Eo,{className:y?"animate-spin":"",size:11})}),c&&t.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:U?t.jsx(Vl,{size:12}):t.jsx(nl,{size:12})})]})]}),U&&t.jsxs("div",{className:"p-5 space-y-5",children:[k&&t.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:[t.jsx(an,{size:12}),k]}),y&&g.length===0&&t.jsxs("div",{className:"flex items-center justify-center py-8",children:[t.jsx(Ja,{className:"animate-spin text-teal-500 mr-2",size:16}),t.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Loading comments…"})]}),g.length>0&&t.jsxs(t.Fragment,{children:[!V&&g.length>i&&t.jsxs("button",{type:"button",onClick:()=>Z(!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 ",g.length-i," older comment",g.length-i!==1?"s":""]}),t.jsx("div",{className:"space-y-3",children:oe.map(Ce=>{const ae=j_[Ce.comment_type]||j_.Comment,me=Ce.comment_email===N||Ce.owner===N,K=le===Ce.name;return t.jsx("div",{className:`group relative rounded-lg border transition-colors ${Ce.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:t.jsxs("div",{className:"px-4 py-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.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:t.jsx(Wl,{className:"text-teal-600 dark:text-teal-400",size:10})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:Ce.comment_by||wI(Ce.comment_email||Ce.owner)}),Ce.comment_type!=="Comment"&&t.jsxs("span",{className:`ml-2 inline-flex items-center gap-1 text-[10px] font-medium ${ae.color}`,children:[ae.icon,ae.label]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-[11px] text-gray-400 dark:text-gray-500 flex items-center gap-1",title:new Date(Ce.creation).toLocaleString(),children:[t.jsx($s,{size:9}),_I(Ce.creation)]}),me&&Ce.comment_type==="Comment"&&t.jsx("button",{type:"button",onClick:()=>ce(Ce.name),disabled:K,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:K?t.jsx(Ja,{className:"animate-spin",size:10}):t.jsx(ma,{size:10})})]})]}),t.jsx("div",{className:"ml-9",children:t.jsx(kI,{html:Ce.content})})]})},Ce.name)})}),V&&g.length>i&&t.jsx("button",{type:"button",onClick:()=>Z(!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"})]}),!y&&g.length===0&&t.jsxs("div",{className:"text-center py-8",children:[t.jsx(uf,{className:"mx-auto text-gray-300 dark:text-gray-600 mb-2",size:28}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No comments yet. Start the discussion!"})]}),t.jsx("div",{className:"pt-3 border-t border-gray-200 dark:border-gray-700",children:t.jsx(vI,{value:W,onChange:H,onSubmit:se,disabled:!r,posting:x,mentionUsers:A,mentionLoading:I,onMentionSearch:z})})]})]}):t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t.jsx(uf,{className:"text-gray-400"}),t.jsx("span",{className:"text-sm",children:"Save the document first to enable comments."})]})})},NI=({doctype:e,docname:r,limit:a=50,enabled:n=!0})=>{const[i,c]=E.useState([]),[u,g]=E.useState(!1),[y,x]=E.useState(null),k=E.useCallback(()=>xe(null,null,function*(){if(!(!n||!e||!r)){g(!0),x(null);try{const N=yield _t.apiCall(`/api/resource/Version?filters=[["ref_doctype","=","${encodeURIComponent(e)}"],["docname","=","${encodeURIComponent(r)}"]]&fields=["name","owner","creation","data"]&order_by=creation desc&limit=${a}`);if(N!=null&&N.data&&N.data.length>0){const C=N.data.map(O=>{let D={added:[],changed:[],removed:[],row_changed:[]};try{D=JSON.parse(O.data||"{}")}catch(I){console.error("Error parsing version data:",I)}let A=[];return Array.isArray(D.changed)?A=D.changed.map(I=>({field:I[0]||"",oldValue:I[1],newValue:I[2]})):D.changed&&typeof D.changed=="object"&&(A=Object.entries(D.changed).map(([I,z])=>{const[U,B]=z;return{field:I,oldValue:U,newValue:B}})),{name:O.name,owner:O.owner,creation:O.creation,changes:A,added:D.added||[],removed:D.removed||[],rowChanged:D.row_changed||[]}});c(C)}else c([])}catch(N){console.error(`Error fetching audit logs for ${e}/${r}:`,N),x(N instanceof Error?N.message:"Failed to load activity log"),c([])}finally{g(!1)}}}),[e,r,a,n]);return E.useEffect(()=>{k()},[k]),{auditLogs:i,loading:u,error:y,refetch:k}},SI=e=>e?e.replace(/^custom_/,"").replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase()):"",T_=e=>e==null||e===""?"(empty)":e===0?"0":e===1?"1":typeof e=="boolean"?e?"Yes":"No":typeof e=="object"?JSON.stringify(e):String(e),vk=e=>{if(!e)return"";const r=new Date(e),a=new Date,n=a.getTime()-r.getTime(),i=Math.floor(n/6e4),c=Math.floor(n/36e5),u=Math.floor(n/864e5);return i<1?"Just now":i<60?`${i} min${i>1?"s":""} ago`:c<24?`${c} hour${c>1?"s":""} ago`:u<7?`${u} day${u>1?"s":""} ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:r.getFullYear()!==a.getFullYear()?"numeric":void 0,hour:"2-digit",minute:"2-digit"})},_k=e=>{if(!e)return"Unknown";const r=e.indexOf("@");return r===-1?e:e.substring(0,r)},CI=e=>{const r=e.toLowerCase();return r.includes("status")||r.includes("state")||r.includes("workflow")?"text-purple-600 dark:text-purple-400":r.includes("date")?"text-blue-600 dark:text-blue-400":r.includes("technician")||r.includes("supervisor")||r.includes("assigned")||r.includes("location")||r.includes("department")||r.includes("building")||r.includes("room")?"text-green-600 dark:text-green-400":"text-gray-600 dark:text-gray-400"},EI=({log:e,isLatest:r,compact:a})=>{const n=a?"w-2.5 h-2.5":"w-3 h-3",i=a?"w-5 h-5":"w-6 h-6",c=a?8:10,u=a?"text-[10px]":"text-xs",g=a?"text-[9px]":"text-[10px]";return t.jsxs("div",{className:`relative ${a?"pl-6":"pl-8"}`,children:[t.jsx("div",{className:`absolute ${a?"left-1":"left-1.5"} top-1.5 ${n} rounded-full border-2 border-white dark:border-gray-800 ${r?"bg-blue-500":"bg-gray-300 dark:bg-gray-600"}`}),t.jsxs("div",{className:`${a?"p-2":"p-3"} rounded-lg ${r?"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:[t.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:`${i} rounded-full bg-gray-200 dark:bg-gray-600 flex items-center justify-center`,children:t.jsx(Wl,{className:"text-gray-500 dark:text-gray-400",size:c})}),t.jsx("span",{className:`${u} font-medium text-gray-700 dark:text-gray-300`,children:_k(e.owner)})]}),t.jsxs("div",{className:`flex items-center gap-1 ${u} text-gray-500 dark:text-gray-400`,children:[t.jsx($s,{size:c}),t.jsx("span",{title:new Date(e.creation).toLocaleString(),children:vk(e.creation)})]})]}),t.jsxs("div",{className:"space-y-1",children:[e.changes.length>0?e.changes.map((y,x)=>t.jsxs("div",{className:u,children:[t.jsx("span",{className:`font-medium ${CI(y.field)}`,children:SI(y.field)}),t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:" changed from "}),t.jsx("span",{className:`px-1 py-0.5 bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400 rounded ${g} font-mono`,children:T_(y.oldValue)}),t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:" → "}),t.jsx("span",{className:`px-1 py-0.5 bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400 rounded ${g} font-mono`,children:T_(y.newValue)})]},x)):t.jsx("p",{className:`${u} text-gray-500 dark:text-gray-400 italic`,children:"Document updated"}),e.added&&e.added.length>0&&t.jsxs("div",{className:`${u} text-green-600 dark:text-green-400`,children:[t.jsx("span",{className:"font-medium",children:"Added:"})," ",e.added.length," item(s)"]}),e.removed&&e.removed.length>0&&t.jsxs("div",{className:`${u} text-red-600 dark:text-red-400`,children:[t.jsx("span",{className:"font-medium",children:"Removed:"})," ",e.removed.length," item(s)"]}),e.rowChanged&&e.rowChanged.length>0&&t.jsxs("div",{className:`${u} text-orange-600 dark:text-orange-400`,children:[t.jsx("span",{className:"font-medium",children:"Modified:"})," ",e.rowChanged.length," row(s)"]})]})]})]})},A_=({creationDate:e,createdBy:r,doctype:a,compact:n})=>{const i=n?"w-2.5 h-2.5":"w-3 h-3",c=n?"w-5 h-5":"w-6 h-6",u=n?8:10,g=n?"text-[10px]":"text-xs",y=a.replace(/_/g," ");return t.jsxs("div",{className:`relative ${n?"pl-6":"pl-8"}`,children:[t.jsx("div",{className:`absolute ${n?"left-1":"left-1.5"} top-1.5 ${i} rounded-full border-2 border-white dark:border-gray-800 bg-green-500`}),t.jsxs("div",{className:`${n?"p-2":"p-3"} rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-100 dark:border-green-800/50`,children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:`${c} rounded-full bg-green-200 dark:bg-green-800 flex items-center justify-center`,children:t.jsx(Wl,{className:"text-green-600 dark:text-green-400",size:u})}),t.jsx("span",{className:`${g} font-medium text-gray-700 dark:text-gray-300`,children:_k(r)})]}),t.jsxs("div",{className:`flex items-center gap-1 ${g} text-gray-500 dark:text-gray-400`,children:[t.jsx($s,{size:u}),t.jsx("span",{title:new Date(e).toLocaleString(),children:vk(e)})]})]}),t.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 ${g} font-medium`,children:[t.jsx(Ca,{size:u}),"Created this ",y]})]})]})},Wu=({doctype:e,docname:r,creationDate:a,createdBy:n,title:i="Activity Log",limit:c=50,initialVisible:u=5,collapsible:g=!0,startCollapsed:y=!1,compact:x=!1,className:k="",onRefresh:N})=>{const[C,O]=E.useState(!y),[D,A]=E.useState(!1),{auditLogs:I,loading:z,refetch:U}=NI({doctype:e,docname:r,limit:c,enabled:!!r}),B=()=>{U(),N==null||N()};if(!r)return null;const V=x?14:16,Z=x?"text-sm":"text-base",W=x?"left-2":"left-3",H=x?"text-[10px]":"text-xs",le=x?8:10,Q=D?I:I.slice(0,u);return t.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 overflow-hidden ${k}`,children:[t.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:`flex items-center gap-2 flex-1 ${g?"cursor-pointer":""}`,onClick:()=>g&&O(!C),children:[t.jsx(Nf,{className:"text-blue-500",size:V}),t.jsx("h2",{className:`${Z} font-semibold text-gray-800 dark:text-white`,children:i}),I.length>0&&t.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:I.length})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:Ne=>{Ne.stopPropagation(),B()},disabled:z,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:t.jsx(Eo,{className:z?"animate-spin":"",size:x?10:12})}),g&&t.jsx("button",{type:"button",onClick:()=>O(!C),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors p-1",children:C?t.jsx(Vl,{size:x?12:14}):t.jsx(nl,{size:x?12:14})})]})]}),C&&t.jsxs("div",{className:"p-3",children:[z&&t.jsxs("div",{className:"flex items-center justify-center py-6",children:[t.jsx(Ja,{className:"animate-spin text-blue-500 mr-2",size:14}),t.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Loading..."})]}),!z&&I.length===0&&t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:`absolute ${W} top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700`}),t.jsxs("div",{className:`relative ${x?"pl-6":"pl-8"} mb-3`,children:[t.jsx("div",{className:`absolute ${x?"left-1":"left-1.5"} top-1 ${x?"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`}),t.jsx("div",{className:`${x?"p-2":"p-3"} rounded-lg bg-gray-50 dark:bg-gray-700/50`,children:t.jsx("p",{className:`${x?"text-[10px]":"text-xs"} text-gray-500 dark:text-gray-400 italic`,children:"No changes recorded yet"})})]}),a&&n&&t.jsx(A_,{creationDate:a,createdBy:n,doctype:e,compact:x})]}),!z&&I.length>0&&t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:`absolute ${W} top-0 bottom-0 w-0.5 bg-gray-200 dark:bg-gray-700`}),t.jsx("div",{className:"space-y-3",children:Q.map((Ne,oe)=>t.jsx(EI,{log:Ne,isLatest:oe===0,compact:x},Ne.name))}),I.length>u&&t.jsx("div",{className:"mt-3 text-center",children:t.jsx("button",{type:"button",onClick:()=>A(!D),className:`inline-flex items-center gap-1 px-2 py-1 ${H} 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:D?t.jsxs(t.Fragment,{children:[t.jsx(Vl,{size:le})," Show Less"]}):t.jsxs(t.Fragment,{children:[t.jsx(nl,{size:le})," Show All (",I.length,")"]})})}),a&&n&&t.jsx("div",{className:"mt-3",children:t.jsx(A_,{creationDate:a,createdBy:n,doctype:e,compact:x})})]})]})]})},wk="asm-html-report-overlay",jI=()=>typeof window!="undefined"&&window.matchMedia("(max-width: 1023px)").matches;function O_(e){if(!e||/^https?:\/\//i.test(e))return e;const r=window.location.origin;return e.startsWith("/")?`${r}${e}`:`${r}/${e}`}function R_(e){const r=`${window.location.origin}/`;return/<base[\s>]/i.test(e)?e:/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,a=>`${a}<base href="${r}">`):`<head><base href="${r}"></head>${e}`}function mp(e){const r=e.trim();return/^<!DOCTYPE/i.test(r)||/^<html/i.test(r)?R_(r):R_(`<!DOCTYPE html><html><head><meta charset="utf-8"></head><body>${r}</body></html>`)}function Sd(){window.alert("Please allow popups for this site to view the report.")}function M_(){var e;(e=document.getElementById(wk))==null||e.remove()}function TI(e){document.body.style.overflow="",M_();const r=document.createElement("div");r.id=wk,r.style.cssText="position:fixed;inset:0;z-index:2147483646;background:#fff;display:flex;flex-direction:column;height:100dvh;width:100vw;";const a=document.createElement("div");a.style.cssText="display:flex;gap:8px;padding:8px 12px;border-bottom:1px solid #e5e7eb;background:#f9fafb;flex-shrink:0;";const n=document.createElement("button");n.type="button",n.textContent="Print",n.style.cssText="min-height:44px;padding:0 16px;border-radius:8px;border:1px solid #d1d5db;background:#fff;font-size:14px;font-weight:600;";const i=document.createElement("button");i.type="button",i.textContent="Close",i.style.cssText="min-height:44px;padding:0 16px;border-radius:8px;border:1px solid #d1d5db;background:#fff;font-size:14px;font-weight:600;margin-left:auto;";const c=document.createElement("iframe");c.title="Report",c.style.cssText="flex:1;width:100%;border:0;background:#fff;";let u=null;const g=x=>{u&&(URL.revokeObjectURL(u),u=null);const k=mp(x),N=new Blob([k],{type:"text/html;charset=utf-8"});u=URL.createObjectURL(N),c.src=u},y=()=>{u&&URL.revokeObjectURL(u),M_()};return n.addEventListener("click",()=>{var x,k;try{(x=c.contentWindow)==null||x.focus(),(k=c.contentWindow)==null||k.print()}catch(N){window.alert("Unable to print this report on this device.")}}),i.addEventListener("click",y),a.appendChild(n),a.appendChild(i),r.appendChild(a),r.appendChild(c),document.body.appendChild(r),e&&g(e),{write:g,close:y}}function AI(e){const r=window.open("","_blank");return r?(e&&(r.document.open(),r.document.write(mp(e)),r.document.close()),{write:a=>{r.document.open(),r.document.write(mp(a)),r.document.close()},close:()=>r.close()}):null}function Cd(e){return jI()?TI(e):AI(e)}const OI=()=>{var it;const{assetName:e}=Yl(),r=ua(),[a]=Li(),n=a.get("duplicate"),i=e==="new",c=i&&!!n,{isAllowedOnSubmit:u}=FL("Asset"),[g,y]=E.useState({asset_name:"",company:"",custom_serial_number:"",custom_local_id:"",location:"",custom_manufacturer:"",department:"",custom_asset_type:"",asset_category:"",custom_moh_id:"",custom_floor:"",custom_moh_engg:"",custom_smeh_engg:"",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_moh_supervisor:"",custom_team_leader:"",is_existing_asset:!0,__islocal:!1}),{shouldShowField:x,isMandatory:k,isReadOnly:N}=hk("Asset",g),{asset:C,loading:O,error:D,refetch:A}=aL(c?n:i?null:e||null),{createAsset:I,updateAsset:z,submitAsset:U,loading:B}=ok(),[V,Z]=E.useState(i),W=(it=C==null?void 0:C.docstatus)!=null?it:0,H=W===1,le=W===2,Q=W===0,[Ne,oe]=E.useState(!1),se=E.useRef(null);E.useEffect(()=>{if(!Ne||!window.matchMedia("(min-width: 1024px)").matches)return;const Je=Be=>{se.current&&!se.current.contains(Be.target)&&oe(!1)};return document.addEventListener("click",Je),()=>document.removeEventListener("click",Je)},[Ne]),E.useEffect(()=>{if(!Ne||window.matchMedia("(min-width: 1024px)").matches)return;const Je=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=Je}},[Ne]),E.useEffect(()=>{},[C,W,Q,H,le,V]);const ce=E.useCallback(De=>!V||le||N(De)?!0:H?!u(De):!Q,[V,le,H,Q,u,N]);E.useCallback(De=>x(De),[x]),E.useCallback(De=>k(De),[k]);const[Ce,ae]=E.useState(""),[me,K]=E.useState({}),{userPhccSiteName:fe,siteLocked:Oe}=ym(),ye=E.useMemo(()=>nn(g.company),[g.company]),J=E.useMemo(()=>hl(g.company,fe),[g.company,fe]),G=E.useMemo(()=>g.company?{custom_site_name:g.company,role_profile_name:"MOH Supervisor"}:{},[g.company]),ie=E.useMemo(()=>g.company?{custom_site_name:g.company,role_profile_name:"Technician"}:{},[g.company]);E.useEffect(()=>{i&&!g.available_for_use_date&&y(De=>$e(_e({},De),{available_for_use_date:new Date().toISOString().split("T")[0],__islocal:!0}))},[i]),E.useEffect(()=>{function De(){return xe(this,null,function*(){try{const Je=yield _t.getUserDetails();ae(Je.custom_site_name||"")}catch(Je){console.error("Error loading user details",Je)}})}De()},[]),E.useEffect(()=>{fe&&y(De=>De.custom_site?De:$e(_e({},De),{custom_site:fe}))},[fe]),Kl(y,{fields:["company","asset_owner_company"]});const re=()=>{const Je={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]};y(Be=>$e(_e({},Be),{finance_books:[...Be.finance_books||[],Je]}))},ne=De=>{y(Je=>{const Be=[...Je.finance_books||[]];return Be.splice(De,1),$e(_e({},Je),{finance_books:Be})})},ve=(De,Je)=>{y(Be=>{const vt=[...Be.finance_books||[]];return vt[De]=_e(_e({},vt[De]||{}),Je),$e(_e({},Be),{finance_books:vt})})};E.useEffect(()=>{if(g.calculate_depreciation&&(!g.finance_books||g.finance_books.length===0)){const Je={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]};y(Be=>$e(_e({},Be),{finance_books:[Je]}))}},[g.calculate_depreciation]);const Ve=(De,Je,Be)=>{y(vt=>{const jt=[...vt.custom_spare_parts||[]],Ct=_e({},jt[De]);Je==="qty"||Je==="rate"?(Ct[Je]=Be,Ct.amount=(Ct.qty||0)*(Ct.rate||0)):Ct[Je]=Be,jt[De]=Ct;const Wt=jt.reduce((pr,Ge)=>pr+(Ge.amount||0),0);return $e(_e({},vt),{custom_spare_parts:jt,custom_total_spare_parts_amount:Wt})})},Ae=()=>{y(De=>$e(_e({},De),{custom_spare_parts:[...De.custom_spare_parts||[],{qty:0,rate:0,amount:0}]}))},ze=De=>{y(Je=>{const Be=[...Je.custom_spare_parts||[]];Be.splice(De,1);const vt=Be.reduce((jt,Ct)=>jt+(Ct.amount||0),0);return $e(_e({},Je),{custom_spare_parts:Be,custom_total_spare_parts_amount:vt})})};E.useEffect(()=>{if(g.available_for_use_date){const De=new Date(g.available_for_use_date),Be=new Date().getTime()-De.getTime(),jt=Math.floor(Be/(1e3*60*60*24))*24,Ct=jt-(g.custom_down_time||0);y(Wt=>$e(_e({},Wt),{custom_total_hours:jt,custom_up_time:Ct}))}},[g.available_for_use_date,g.custom_down_time]);const Re=E.useRef("");E.useEffect(()=>{if(!V){Re.current=g.custom_asset_type||"";return}const De=(g.custom_asset_type||"").toString().trim().toLowerCase(),Je=(Re.current||"").toString().trim().toLowerCase();De!==Je&&(Re.current=g.custom_asset_type||"",De==="biomedical"?g.custom_site_contractor!=="SAMAMA"&&y(Be=>$e(_e({},Be),{custom_site_contractor:"SAMAMA"})):Je==="biomedical"&&g.custom_site_contractor==="SAMAMA"&&y(Be=>$e(_e({},Be),{custom_site_contractor:""})))},[g.custom_asset_type,V]),E.useEffect(()=>{const De={};g.company&&(De.company=g.company);const Je=nn(Ce)||nn(g.company);(Ce||g.company)&&(Je?De.department_name=["not like","Non Bio%"]:De.department_name=["not like","Non Bio%"]),K(De)},[g.company,Ce]),E.useEffect(()=>{C&&(Re.current=C.custom_asset_type||"",y({asset_name:c?`${C.asset_name} (Copy)`:C.asset_name||"",company:C.company||"",custom_serial_number:c?"":C.custom_serial_number||"",custom_local_id:c?"":C.custom_local_id||"",location:C.location||"",custom_manufacturer:C.custom_manufacturer||"",department:C.department||"",custom_moh_supervisor:C.custom_moh_supervisor||"",custom_team_leader:C.custom_team_leader||"",custom_asset_type:C.custom_asset_type||"",asset_category:C.asset_category||"",custom_moh_id:C.custom_moh_id||"",custom_floor:C.custom_floor||"",custom_moh_engg:C.custom_moh_engg||"",custom_smeh_engg:C.custom_smeh_engg||"",custom_manufacturing_year:C.custom_manufacturing_year||"",custom_model:C.custom_model||"",custom_class:C.custom_class||"",custom_device_status:C.custom_device_status||"",custom_down_time:C.custom_down_time||0,asset_owner_company:C.asset_owner_company||"",custom_up_time:C.custom_up_time||0,custom_total_hours:C.custom_total_hours||0,custom_modality:C.custom_modality||"",custom_attach_image:C.custom_attach_image||"",custom_site_contractor:C.custom_site_contractor||"",custom_site:C.custom_site||"",custom_total_amount:C.custom_total_amount||0,gross_purchase_amount:C.gross_purchase_amount||0,available_for_use_date:C.available_for_use_date||"",calculate_depreciation:C.calculate_depreciation||!1,finance_books:C.finance_books||[],custom_service_agreement:C.custom_service_agreement||"",custom_service_coverage:C.custom_service_coverage||"",custom_start_date:C.custom_start_date?C.custom_start_date.split(" ")[0]:"",custom_end_date:C.custom_end_date?C.custom_end_date.split(" ")[0]:"",custom_warranty:C.custom_warranty||!1,custom_extended_warranty:C.custom_extended_warranty||!1,custom__service_contract:C.custom__service_contract||!1,custom_covering_spare_parts:C.custom_covering_spare_parts||!1,custom_spare_parts_labour:C.custom_spare_parts_labour||!1,custom_covering_labour:C.custom_covering_labour||!1,custom_ppm_only:C.custom_ppm_only||!1,custom_support_plan:C.custom_support_plan||"",custom_spare_parts:C.custom_spare_parts||[],custom_total_spare_parts_amount:C.custom_total_spare_parts_amount||0}))},[C,c]);const[Ze,Lt]=E.useState(null);E.useEffect(()=>{if(!e||e==="new")return;xe(null,null,function*(){var Je;try{const Be=`/files/${e}-qr.png`;if((yield fetch(Be,{method:"HEAD"})).ok){Lt(Be);return}const jt=yield _t.apiCall(`/api/resource/File?filters=[["File","attached_to_name","=","${e}"]]`);((Je=jt==null?void 0:jt.data)==null?void 0:Je.length)>0&&Lt(jt.data[0].file_url)}catch(Be){console.error("Error loading QR code:",Be)}})},[e,C]);const mt=De=>{const{name:Je,value:Be}=De.target;y(vt=>$e(_e({},vt),{[Je]:Be}))},Zt=De=>xe(null,null,function*(){if(De.preventDefault(),!g.asset_name){alert("Please enter an Asset Name");return}if(!g.custom_asset_type){alert("Please select an Asset Type");return}console.log("Submitting asset data:",g);try{if(i||c){const Je=yield I(g);if(Je.name){const vt=`/files/${Je.name}-qr.png`;Lt(vt)}alert(c?"Asset duplicated successfully!":"Asset created successfully!"),r(`/assets/${Je.name}`)}else e&&(yield z(e,g),alert("Asset updated successfully!"),Z(!1),A())}catch(Je){console.error("Asset save error:",Je);const Be=Je instanceof Error?Je.message:"Unknown error";Be.includes("404")||Be.includes("not found")||Be.includes("has no attribute")||Be.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: `+Be):alert(`Failed to save asset:
|
||
|
||
`+Be)}}),ar=()=>xe(null,null,function*(){if(!e||i){alert("Cannot submit: Asset not saved yet");return}if(window.confirm('Are you sure you want to submit this asset? Once submitted, only fields marked as "Allow on Submit" can be edited.'))try{yield U(e),alert("Asset submitted successfully!"),A(),Z(!1)}catch(De){console.error("Asset submit error:",De);const Je=De instanceof Error?De.message:"Unknown error";alert(`Failed to submit asset:
|
||
|
||
`+Je)}});if(O)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading asset details..."})]})});if(D&&!i&&!c)return t.jsx("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[t.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["Error: ",D]}),t.jsx("button",{onClick:()=>r("/assets"),className:"mt-2 text-red-700 dark:text-red-400 underline hover:text-red-800 dark:hover:text-red-300",children:"Back to assets list"})]})});if(D&&c)return t.jsx("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:t.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-yellow-800 dark:text-yellow-300 mb-2",children:"Source Asset Not Found"}),t.jsx("p",{className:"text-yellow-700 dark:text-yellow-400",children:"The asset you're trying to duplicate could not be found."}),t.jsxs("div",{className:"mt-4 flex gap-3",children:[t.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:"Create New Asset"}),t.jsx("button",{onClick:()=>r("/assets"),className:"px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg transition-colors",children:"Back to Assets List"})]})]})});const or=De=>{if(window.matchMedia("(min-width: 1024px)").matches){De(),oe(!1);return}oe(!1),window.setTimeout(()=>De(),0)},yt=()=>{if(!Ze||!C)return;const De=Cd();if(!De){Sd();return}De.write(`
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>Print QR Code - ${C.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> ${C.name}<br/>
|
||
<strong>Asset Name:</strong> ${C.asset_name||"N/A"}
|
||
</div>
|
||
<img src="${O_(Ze)}" alt="QR Code" class="qr-image" onload="window.print();" />
|
||
</div>
|
||
</body>
|
||
</html>
|
||
`)},nr=()=>{const De=Cd();if(!De){Sd();return}De.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="${O_("/files/Stay Plugged.jpg")}" alt="Stay Plugged" class="stay-plugged-image" onload="window.print();" />
|
||
</div>
|
||
</body>
|
||
</html>
|
||
`)},$t=()=>xe(null,null,function*(){if(!e||i){alert("Please save the asset first to view PPM Plan");return}const De=Cd(`
|
||
<!DOCTYPE html>
|
||
<html><head><title>PPM Plan</title></head>
|
||
<body style="font-family:Arial,sans-serif;padding:24px;">Loading PPM Plan...</body></html>
|
||
`);if(!De){Sd();return}try{const Je=yield _t.apiCall(`/api/resource/Asset Maintenance Log?filters=[["asset_name","=","${e}"],["maintenance_status","=","Planned"]]&fields=["name","due_date","periodicity","custom_asset_names","asset_name","maintenance_type","assign_to_name"]`),Be=(Je==null?void 0:Je.data)||[],vt=(lt,Dt)=>{const mr=new Date(lt);return mr.setDate(mr.getDate()+Dt),mr},jt=(lt,Dt)=>{const mr=new Date(lt);return mr.setMonth(mr.getMonth()+Dt),mr},Ct=(lt,Dt)=>{const mr=new Date(lt);return mr.setFullYear(mr.getFullYear()+Dt),mr},Wt=(lt,Dt)=>{switch(Dt){case"Daily":return vt(lt,1);case"Weekly":return vt(lt,7);case"Monthly":return jt(lt,1);case"Quarterly":return jt(lt,3);case"Half-yearly":return jt(lt,6);case"Yearly":return Ct(lt,1);case"2 Yearly":return Ct(lt,2);case"3 Yearly":return Ct(lt,3);default:return jt(lt,1)}},pr=lt=>lt.toISOString().split("T")[0],Ge=Ct(new Date,5),We=[];for(const lt of Be){let Dt=new Date(lt.due_date);const mr=lt.periodicity||"Monthly";for(let tr=0;tr<60&&(We.push({asset_name:lt.asset_name||"",custom_asset_names:lt.custom_asset_names||"",serial_number:g.custom_serial_number||"N/A",due_date:pr(Dt),periodicity:mr,maintenance_type:lt.maintenance_type||"",assign_to_name:lt.assign_to_name||"",status:"Planned"}),Dt=Wt(Dt,mr),!(Dt>Ge));tr++);}We.sort((lt,Dt)=>new Date(lt.due_date).getTime()-new Date(Dt.due_date).getTime());const At=We.length>0?We.map((lt,Dt)=>`
|
||
<tr class="${Dt%2===0?"bg-white":"bg-gray-50"}">
|
||
<td class="border px-3 py-2">${lt.asset_name}</td>
|
||
<td class="border px-3 py-2">${lt.custom_asset_names}</td>
|
||
<td class="border px-3 py-2">${lt.serial_number}</td>
|
||
<td class="border px-3 py-2">${lt.due_date}</td>
|
||
<td class="border px-3 py-2">${lt.periodicity}</td>
|
||
<td class="border px-3 py-2">${lt.maintenance_type}</td>
|
||
<td class="border px-3 py-2">${lt.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">${lt.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>';De.write(`
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>PPM Plan - ${e}</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> ${e} |
|
||
<strong>Asset Name:</strong> ${g.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>
|
||
${At}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="summary">
|
||
<strong>Summary:</strong> ${We.length} planned maintenance entries for the next 5 years
|
||
</div>
|
||
</div>
|
||
</body>
|
||
</html>
|
||
`)}catch(Je){console.error("Error fetching PPM Plan:",Je),alert("Failed to load PPM Plan. Please try again.")}}),Er=()=>xe(null,null,function*(){if(!e||i){alert("Please save the asset first to view Asset History");return}try{const De=Cd(`
|
||
<!DOCTYPE html>
|
||
<html><head><title>Asset History</title></head>
|
||
<body style="font-family:Arial,sans-serif;padding:24px;">Loading Asset History...</body></html>
|
||
`);if(!De){Sd();return}const Je=yield _t.apiCall(`/api/resource/Asset/${e}`),Be=(Je==null?void 0:Je.data)||{},vt=yield _t.apiCall(`/api/resource/Work_Order?filters=[["asset","=","${e}"]]&fields=["name","work_order_type","repair_status","creation","total_repair_cost"]`),jt=(vt==null?void 0:vt.data)||[],Ct=yield _t.apiCall(`/api/resource/Asset Maintenance?filters=[["asset_name","=","${e}"]]&fields=["name","maintenance_team","custom_type_of_maintenance"]`),Wt=(Ct==null?void 0:Ct.data)||[];let pr=[],Ge=[];for(const Ke of Wt){const Yt=yield _t.apiCall(`/api/resource/Asset Maintenance/${Ke.name}`),gr=(Yt==null?void 0:Yt.data)||{};gr.asset_maintenance_tasks&&(Ge=[...Ge,...gr.asset_maintenance_tasks.map(Zr=>$e(_e({},Zr),{maintenance_id:Ke.name}))]);const jr=yield _t.apiCall(`/api/resource/Asset Maintenance Log?filters=[["asset_maintenance","=","${Ke.name}"]]&fields=["name","maintenance_status","assign_to_name","maintenance_type","due_date","completion_date","periodicity","actions_performed"]&order_by=completion_date desc`);pr=[...pr,...(jr==null?void 0:jr.data)||[]]}const We=pr.filter(Ke=>Ke.maintenance_status==="Completed"),At=pr.filter(Ke=>Ke.maintenance_status!=="Completed"),lt={};pr.forEach(Ke=>{lt[Ke.maintenance_status]=(lt[Ke.maintenance_status]||0)+1});const Dt=Be.custom_spare_parts||[],mr={};Dt.forEach(Ke=>{const Yt=Ke.work_order||"Unassigned";mr[Yt]||(mr[Yt]=[]),mr[Yt].push(Ke)});const tr=jt.length>0?jt.map((Ke,Yt)=>{const gr=Ke.repair_status==="Completed"?"bg-green-100 text-green-800":Ke.repair_status==="Work In Progress"?"bg-yellow-100 text-yellow-800":"bg-gray-100 text-gray-800";return`
|
||
<tr class="${Yt%2===0?"bg-white":"bg-gray-50"}">
|
||
<td class="px-4 py-3 font-medium text-blue-600">${Ke.name}</td>
|
||
<td class="px-4 py-3">${Ke.work_order_type||"-"}</td>
|
||
<td class="px-4 py-3"><span class="px-2 py-1 rounded-full text-xs font-medium ${gr}">${Ke.repair_status||"-"}</span></td>
|
||
<td class="px-4 py-3 font-semibold">${parseFloat(Ke.total_repair_cost||0).toFixed(2)} ر.س</td>
|
||
<td class="px-4 py-3 text-gray-500">${Ke.creation?new Date(Ke.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 pt="";Object.keys(mr).length>0?Object.keys(mr).forEach(Ke=>{pt+=`
|
||
<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">${Ke}</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>
|
||
${mr[Ke].map((Yt,gr)=>`
|
||
<tr class="${gr%2===0?"bg-white":"bg-gray-50"}">
|
||
<td class="px-4 py-2">${Yt.item_code||"-"}</td>
|
||
<td class="px-4 py-2">${Yt.qty||0}</td>
|
||
<td class="px-4 py-2">${Yt.rate||0} ر.س</td>
|
||
<td class="px-4 py-2 font-medium">${Yt.amount||0} ر.س</td>
|
||
</tr>
|
||
`).join("")}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
`}):pt='<p class="text-gray-500 text-center py-8">No Spare Parts Used</p>';const Jt=Wt.length>0?Wt.map(Ke=>`
|
||
<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">${Ke.name}</p>
|
||
</div>
|
||
<div class="text-right">
|
||
<p class="text-sm text-gray-500">Type</p>
|
||
<p class="font-medium">${Ke.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">${Ke.maintenance_team||"-"}</p>
|
||
</div>
|
||
</div>
|
||
`).join(""):'<p class="text-gray-500 text-center py-8">No Maintenance Records Found</p>',vr=Ge.length>0?Ge.map((Ke,Yt)=>`
|
||
<tr class="${Yt%2===0?"bg-white":"bg-gray-50"}">
|
||
<td class="px-4 py-3">${Ke.assign_to_name||"-"}</td>
|
||
<td class="px-4 py-3">${Ke.periodicity||"-"}</td>
|
||
<td class="px-4 py-3">${Ke.next_due_date||"-"}</td>
|
||
<td class="px-4 py-3 text-blue-600 text-sm">${Ke.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>',Ir=Object.keys(lt).length>0?Object.entries(lt).map(([Ke,Yt])=>`
|
||
<div class="flex items-center justify-between p-3 rounded-lg border ${Ke==="Completed"?"bg-green-100 text-green-800 border-green-200":Ke==="Planned"?"bg-blue-100 text-blue-800 border-blue-200":"bg-yellow-100 text-yellow-800 border-yellow-200"}">
|
||
<span class="font-medium">${Ke}</span>
|
||
<span class="text-2xl font-bold">${Yt}</span>
|
||
</div>
|
||
`).join(""):'<p class="text-gray-500 text-center">No Data</p>',Le=We.length>0?We.map((Ke,Yt)=>`
|
||
<tr class="${Yt%2===0?"bg-white":"bg-gray-50"}">
|
||
<td class="px-3 py-2 text-blue-600 font-medium">${Ke.name}</td>
|
||
<td class="px-3 py-2">${Ke.assign_to_name||"-"}</td>
|
||
<td class="px-3 py-2">${Ke.maintenance_type||"-"}</td>
|
||
<td class="px-3 py-2">${Ke.due_date||"-"}</td>
|
||
<td class="px-3 py-2 text-green-600 font-medium">${Ke.completion_date||"-"}</td>
|
||
<td class="px-3 py-2">${Ke.periodicity||"-"}</td>
|
||
<td class="px-3 py-2 text-sm text-gray-600">${Ke.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>',qe=At.length>0?At.map((Ke,Yt)=>{const gr=Ke.maintenance_status==="Planned"?"bg-blue-100 text-blue-800":"bg-yellow-100 text-yellow-800";return`
|
||
<tr class="${Yt%2===0?"bg-white":"bg-gray-50"}">
|
||
<td class="px-3 py-2 text-blue-600 font-medium">${Ke.name}</td>
|
||
<td class="px-3 py-2">${Ke.assign_to_name||"-"}</td>
|
||
<td class="px-3 py-2">${Ke.maintenance_type||"-"}</td>
|
||
<td class="px-3 py-2">${Ke.due_date||"-"}</td>
|
||
<td class="px-3 py-2">${Ke.periodicity||"-"}</td>
|
||
<td class="px-3 py-2"><span class="px-2 py-1 rounded-full text-xs font-medium ${gr}">${Ke.maintenance_status||"-"}</span></td>
|
||
<td class="px-3 py-2 text-sm text-gray-600">${Ke.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>';De.write(`
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>Asset History - ${e}</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">${e}</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">${Be.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">${Be.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">${Be.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">${Be.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">${Be.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>
|
||
${tr}
|
||
</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">
|
||
${pt}
|
||
</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">
|
||
${Jt}
|
||
</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>
|
||
${vr}
|
||
</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">
|
||
${Ir}
|
||
</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>
|
||
${Le}
|
||
</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>
|
||
${qe}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Footer -->
|
||
<div class="text-center text-gray-500 text-sm mt-8 pb-8">
|
||
Generated on ${new Date().toLocaleString()} | Asset: ${e}
|
||
</div>
|
||
</div>
|
||
</body>
|
||
</html>
|
||
`)}catch(De){console.error("Error fetching Asset History:",De),alert("Failed to load Asset History. Please try again.")}}),St=()=>{if(!e||i){alert("Please save the asset first to view Installation Report");return}const De=Cd();if(!De){Sd();return}const Je=new Date,Be=Wt=>{const pr=String(Wt.getDate()).padStart(2,"0"),Ge=String(Wt.getMonth()+1).padStart(2,"0"),We=Wt.getFullYear();return`${pr}/${Ge}/${We}`},vt=(C==null?void 0:C.custom_spare_parts)||[];let jt="";const Ct=3;if(vt.length>0){vt.forEach((Wt,pr)=>{jt+=`
|
||
<tr>
|
||
<td>${pr+1}</td>
|
||
<td>${Wt.item_name||""}</td>
|
||
<td>${Wt.item_code||""}</td>
|
||
<td>${Wt.uom||""}</td>
|
||
<td>${Wt.qty||""}</td>
|
||
</tr>
|
||
`});for(let Wt=vt.length;Wt<Ct;Wt++)jt+=`
|
||
<tr>
|
||
<td>${Wt+1}</td>
|
||
<td> </td>
|
||
<td> </td>
|
||
<td> </td>
|
||
<td> </td>
|
||
</tr>
|
||
`}else for(let Wt=0;Wt<Ct;Wt++)jt+=`
|
||
<tr>
|
||
<td>${Wt+1}</td>
|
||
<td> </td>
|
||
<td> </td>
|
||
<td> </td>
|
||
<td> </td>
|
||
</tr>
|
||
`;De.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 - ${e}</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">${e||""}</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">${Be(Je)}</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">${Be(Je)}</span> م</div>
|
||
</div>
|
||
|
||
<div style="margin: 15px 0; font-weight: bold;">
|
||
مستشفى <span class="dotted-line" style="min-width: 200px;">${g.company||""}</span>
|
||
</div>
|
||
|
||
<!-- Main Content -->
|
||
<div class="main-content">
|
||
تشهد مستشفى <span class="dotted-line" style="min-width: 180px;">${g.company||""}</span> بأن <span class="dotted-line" style="min-width: 180px;">${g.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">${g.asset_name||""}</span>
|
||
<span class="arabic-label">اسم الجهاز:</span>
|
||
</div>
|
||
<div class="equipment-item">
|
||
<span>MFR</span>
|
||
<span class="colon">:</span>
|
||
<span class="field-value">${g.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">${g.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">${g.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;">${g.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>
|
||
${jt}
|
||
</tbody>
|
||
</table>
|
||
|
||
<!-- Footer Text -->
|
||
<div class="footer-text">
|
||
وذلك طبقا لعقد صيانة وإصلاح الأجهزة الطبية بمستشفى <span class="dotted-line" style="min-width: 150px;">${g.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">المسئول في القسم 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">مدير شركة سمامة 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">مهندس/ فني التركيب 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">مشرف الوزارة بالمستشفى 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">مدير المستشفى/ المركز 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>
|
||
`)},Br=()=>{if(!e||i){alert("Please save the asset first to view Dismantling Report");return}const De=Cd();if(!De){Sd();return}const Je=new Date,Be=Ct=>{const Wt=String(Ct.getDate()).padStart(2,"0"),pr=String(Ct.getMonth()+1).padStart(2,"0"),Ge=Ct.getFullYear();return`${Wt}/${pr}/${Ge}`},vt=C!=null&&C.creation?new Date(C.creation):null;let jt="";if(vt){const Ct=Math.floor((Je.getTime()-vt.getTime())/31536e6),Wt=Math.floor((Je.getTime()-vt.getTime())%(1e3*60*60*24*365)/(1e3*60*60*24*30));jt=`${Ct} سنة و ${Wt} شهر`}De.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 - ${e}</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;">${g.department||""}</span>
|
||
</div>
|
||
|
||
<!-- Equipment Data Section -->
|
||
<div class="section-title">0-1 بيانات الجهاز المطلوب تكهينه :</div>
|
||
|
||
<table class="equipment-table">
|
||
<tr>
|
||
<td>اسم الجهاز</td>
|
||
<td>${g.asset_name||""}</td>
|
||
<td>الرقم التسلسلي</td>
|
||
<td>${g.custom_serial_number||""}</td>
|
||
</tr>
|
||
<tr>
|
||
<td>الشركة الصانعة</td>
|
||
<td>${g.custom_manufacturer||""}</td>
|
||
<td>تاريخ التوريد</td>
|
||
<td>${vt?Be(vt):""}</td>
|
||
</tr>
|
||
<tr>
|
||
<td>الطراز/الموديل</td>
|
||
<td>${g.custom_model||""}</td>
|
||
<td>مدة استخدام الجهاز</td>
|
||
<td>${jt}</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> </td>
|
||
<td> </td>
|
||
<td> </td>
|
||
<td> </td>
|
||
<td> </td>
|
||
<td> </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>
|
||
`)},Pt=()=>t.jsxs(t.Fragment,{children:[Ze&&t.jsxs("button",{type:"button",onClick:()=>or(yt),className:"w-full text-left px-4 py-3 min-h-[48px] text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx($h,{size:14}),"Print QR"]}),t.jsxs("button",{type:"button",onClick:()=>or(nr),className:"w-full text-left px-4 py-3 min-h-[48px] text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx($h,{size:14}),"Stay Plugged"]}),t.jsxs("button",{type:"button",onClick:()=>or($t),className:"w-full text-left px-4 py-3 min-h-[48px] text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(al,{size:14}),"PPM Plan"]}),t.jsxs("button",{type:"button",onClick:()=>or(Er),className:"w-full text-left px-4 py-3 min-h-[48px] text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(Nf,{size:14}),"Asset History"]}),t.jsxs("button",{type:"button",onClick:()=>or(St),className:"w-full text-left px-4 py-3 min-h-[48px] text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2",children:[t.jsx(iC,{size:14}),"Installation Report"]}),(C==null?void 0:C.status)==="Scrapped"&&t.jsxs("button",{type:"button",onClick:()=>or(Br),className:"w-full text-left px-4 py-3 min-h-[48px] text-sm 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:[t.jsx(xC,{size:14}),"Dismantling Report"]})]});return t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-4 sm:p-6 min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("button",{onClick:()=>r("/assets"),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[t.jsx(bi,{}),t.jsx("span",{className:"text-gray-900 dark:text-white font-medium",children:c?"Duplicate Asset":i?"New Asset Details":"Asset Details"})]}),C&&t.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${W===0?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300":W===1?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300":"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300"}`,children:W===0?"Draft":W===1?"Submitted":"Cancelled"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[!i&&!V&&!le&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative",ref:se,children:[t.jsxs("button",{type:"button",onClick:()=>oe(!Ne),className:"bg-blue-600 hover:bg-blue-700 text-white px-3 py-2 min-h-[44px] rounded-lg flex items-center gap-2",children:["Actions",t.jsx(nl,{size:12,className:`transition-transform ${Ne?"rotate-180":""}`})]}),Ne&&t.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 hidden lg:block",children:t.jsx("div",{className:"py-1",children:Pt()})})]}),Ne&&Su.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"fixed inset-0 z-[10000] bg-black/50 lg:hidden",onClick:()=>oe(!1),"aria-label":"Close actions"}),t.jsxs("div",{className:"fixed inset-x-0 bottom-0 z-[10001] max-h-[85vh] overflow-y-auto rounded-t-2xl bg-white dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 lg:hidden",children:[t.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:t.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Actions"})}),t.jsx("div",{className:"py-1",children:Pt()})]})]}),document.body),t.jsxs("button",{onClick:()=>Z(!0),className:"bg-blue-600 hover:bg-blue-700 text-white px-3 py-2 min-h-[44px] rounded-lg flex items-center gap-2",children:[t.jsx(Yn,{}),"Edit"]}),Q&&t.jsxs("button",{onClick:ar,disabled:B,className:"bg-purple-600 hover:bg-purple-700 text-white px-3 py-2 min-h-[44px] rounded-lg flex items-center gap-2 disabled:opacity-50",children:[t.jsx(Cw,{}),B?"Submitting...":"Submit"]})]}),le&&t.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 italic",children:"Cancelled documents cannot be edited"}),V&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{i?r("/assets"):Z(!1)},className:"bg-gray-300 hover:bg-gray-400 text-gray-700 dark:text-gray-800 px-2 py-1 rounded-lg",disabled:B,children:"Cancel"}),t.jsxs("button",{onClick:Zt,disabled:B,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:[t.jsx(Fn,{}),B?"Saving...":"Save Changes"]})]})]})]}),t.jsxs("form",{onSubmit:Zt,children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.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:"Asset Information"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Asset Name ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",name:"asset_name",value:g.asset_name,onChange:mt,placeholder:"e.g. Laptop Model X",required:!0,disabled:ce("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"})]}),t.jsx(er,{label:"Asset Type",doctype:"Asset Type",value:g.custom_asset_type||"",onChange:De=>y($e(_e({},g),{custom_asset_type:De})),disabled:ce("custom_asset_type")}),t.jsx(er,{label:"Asset Category",doctype:"Asset Category",value:g.asset_category||"",onChange:De=>y($e(_e({},g),{asset_category:De})),disabled:ce("asset_category")}),t.jsx(er,{label:"Modality",doctype:"Modality",value:g.custom_modality||"",onChange:De=>y($e(_e({},g),{custom_modality:De})),disabled:ce("custom_modality")}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Class"}),t.jsxs("select",{name:"custom_class",value:g.custom_class,onChange:mt,disabled:ce("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:[t.jsx("option",{value:"",children:"Select class"}),t.jsx("option",{value:"Class A",children:"Class A"}),t.jsx("option",{value:"Class B",children:"Class B"}),t.jsx("option",{value:"Class C",children:"Class C"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Asset ID"}),t.jsx("input",{type:"text",value:i||c?"Auto-generated":C==null?void 0:C.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"}),c&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:["💡 Duplicating from: ",n]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Device Status ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("select",{name:"custom_device_status",value:g.custom_device_status,onChange:mt,disabled:!V,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:[t.jsx("option",{value:"Up",children:"Up"}),t.jsx("option",{value:"Down",children:"Down"})]})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.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:"Technical Specs"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Serial Code"}),t.jsx("input",{type:"text",name:"custom_serial_number",value:g.custom_serial_number,onChange:mt,placeholder:"e.g. SN-12345",disabled:ce("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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Local ID"}),t.jsx("input",{type:"text",name:"custom_local_id",value:g.custom_local_id||"",onChange:mt,placeholder:"Local ID",disabled:ce("custom_local_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"})]}),t.jsx(er,{label:"Manufacturer",doctype:"Manufacturer",value:g.custom_manufacturer||"",onChange:De=>y($e(_e({},g),{custom_manufacturer:De})),disabled:ce("custom_manufacturer")}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Model"}),t.jsx("input",{type:"text",name:"custom_model",value:g.custom_model,onChange:mt,placeholder:"Model number",disabled:ce("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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Total Hours"}),t.jsx("input",{type:"number",name:"custom_total_hours",value:g.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"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"Calculated from Available For Use Date"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Down Time (Hours)"}),t.jsx("input",{type:"number",name:"custom_down_time",value:g.custom_down_time||0,onChange:mt,placeholder:"0",disabled:ce("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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Up Time (Hours)"}),t.jsx("input",{type:"number",name:"custom_up_time",value:g.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"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"Calculated: Total Hours - Down Time"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.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:"Location"}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(er,{label:"Hospital",doctype:"Company",value:g.company||"",onChange:De=>{y($e(_e({},g),{company:De,asset_owner_company:De,department:"",custom_site:"",custom_moh_supervisor:"",custom_smeh_engg:""}))},disabled:ce("company"),filters:{domain:"Healthcare"}}),ye&&t.jsx(er,{label:"Site Name",doctype:"Mobile Team Site",value:g.custom_site||"",onChange:De=>y($e(_e({},g),{custom_site:De})),disabled:ce("custom_site")||!g.company||Oe,filters:J,placeholder:"Select Site"},g.company||"site-name"),t.jsx(er,{label:"Department",doctype:"Department",value:g.department||"",onChange:De=>y($e(_e({},g),{department:De})),disabled:ce("department"),filters:me}),t.jsx(er,{label:"Location",doctype:"Location",value:g.location||"",onChange:De=>y($e(_e({},g),{location:De})),disabled:ce("location")}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"MOH ID"}),t.jsx("input",{type:"text",name:"custom_moh_id",value:g.custom_moh_id||"",onChange:mt,placeholder:"MOH ID",disabled:ce("custom_moh_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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Floor"}),t.jsx("input",{type:"text",name:"custom_floor",value:g.custom_floor||"",onChange:mt,placeholder:"Floor",disabled:ce("custom_floor"),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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Building"}),t.jsx("input",{type:"text",placeholder:"Building name",disabled:!V,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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Room Number"}),t.jsx("input",{type:"text",placeholder:"e.g. Room 001-002",disabled:!V,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"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.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:"More Details"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex flex-col items-center my-4",children:[t.jsx("div",{className:"border-2 border-gray-300 dark:border-gray-600 p-3 rounded-lg bg-white dark:bg-gray-700",children:Ze?t.jsxs(t.Fragment,{children:[t.jsx("img",{src:Ze,alt:`QR Code for ${(C==null?void 0:C.name)||"Asset"}`,className:"w-[120px] h-[120px] object-contain",onError:De=>{const Je=De.target;Je.style.display="none";const Be=Je.nextElementSibling;Be&&(Be.style.display="flex")}}),t.jsx("div",{className:"w-[120px] h-[120px] hidden items-center justify-center bg-gray-100 dark:bg-gray-700 rounded",children:t.jsx($h,{size:80,className:"text-gray-400 dark:text-gray-500"})})]}):t.jsx("div",{className:"w-[120px] h-[120px] flex items-center justify-center bg-gray-100 dark:bg-gray-700 rounded",children:t.jsx($h,{size:80,className:"text-gray-400 dark:text-gray-500"})})}),(C==null?void 0:C.name)&&t.jsxs("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400 text-center",children:["Asset ID: ",C.name]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Description"}),t.jsx("textarea",{rows:4,placeholder:"Brief description of the asset",disabled:!V,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"})]})]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 mt-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.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:"Coverage"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Site Contractor"}),t.jsx("input",{type:"text",name:"custom_site_contractor",value:g.custom_site_contractor,onChange:mt,disabled:ce("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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Contract Number"}),t.jsx("input",{type:"text",disabled:!V,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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Service Agreement"}),t.jsxs("select",{name:"custom_service_agreement",value:g.custom_service_agreement||"",onChange:mt,disabled:ce("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:[t.jsx("option",{value:"",children:"Select Service Agreement"}),t.jsx("option",{value:"Warranty",children:"Warranty"}),t.jsx("option",{value:"Contract",children:"Contract"}),t.jsx("option",{value:"Frame Work",children:"Frame Work"}),t.jsx("option",{value:"Main Contractor",children:"Main Contractor"}),t.jsx("option",{value:"Out of warranty",children:"Out of warranty"}),t.jsx("option",{value:"Under Dismantle",children:"Under Dismantle"}),t.jsx("option",{value:"Under Installation",children:"Under Installation"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Service Coverage"}),t.jsxs("select",{name:"custom_service_coverage",value:g.custom_service_coverage||"",onChange:mt,disabled:ce("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:[t.jsx("option",{value:"",children:"Select Service Coverage"}),t.jsx("option",{value:"PM Only",children:"PM Only"}),t.jsx("option",{value:"Labour",children:"Labour"}),t.jsx("option",{value:"Labour & Parts",children:"Labour & Parts"}),t.jsx("option",{value:"Comprehensive",children:"Comprehensive"})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Start Date"}),t.jsx("input",{type:"date",name:"custom_start_date",value:g.custom_start_date||"",onChange:mt,disabled:ce("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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"End Date"}),t.jsx("input",{type:"date",name:"custom_end_date",value:g.custom_end_date||"",onChange:mt,disabled:ce("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"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Total Amount"}),t.jsx("input",{type:"number",name:"custom_total_amount",value:g.custom_total_amount,onChange:mt,disabled:ce("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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Comments"}),t.jsx("textarea",{rows:2,disabled:!V,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"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.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"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Purchase Order Number"}),t.jsx("input",{type:"text",placeholder:"PO number",disabled:!V,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"})]}),t.jsx(er,{label:"MOH Supervisor",doctype:"User",query:"frappe.core.doctype.user.user.user_query",value:g.custom_moh_supervisor||"",onChange:De=>y($e(_e({},g),{custom_moh_supervisor:De})),disabled:ce("custom_moh_supervisor")||!g.company,filters:G,placeholder:g.company?"Select MOH Supervisor":"Select Hospital first"},`moh-supervisor-${g.company||"none"}`),t.jsx(er,{label:"SMEH Engg",doctype:"User",query:"frappe.core.doctype.user.user.user_query",value:g.custom_smeh_engg||"",onChange:De=>y($e(_e({},g),{custom_smeh_engg:De})),disabled:ce("custom_smeh_engg")||!g.company,filters:ie,placeholder:g.company?"Select SMEH Engg":"Select Hospital first"},`smeh-engg-${g.company||"none"}`),t.jsx(er,{label:"Team Leader",doctype:"User",value:g.custom_team_leader||"",onChange:De=>y($e(_e({},g),{custom_team_leader:De})),disabled:ce("custom_team_leader")}),t.jsx(er,{label:"Supplier/Vendor",doctype:"Supplier",value:g.supplier||"",onChange:De=>y($e(_e({},g),{supplier:De})),disabled:ce("supplier")}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Gross Purchase Amount"}),t.jsx("input",{type:"number",name:"gross_purchase_amount",value:g.gross_purchase_amount||0,onChange:mt,disabled:ce("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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Purchase Date"}),t.jsx("input",{type:"date",disabled:!V,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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Installation Date"}),t.jsx("input",{type:"date",disabled:!V,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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Available For Use Date"}),t.jsx("input",{type:"date",name:"available_for_use_date",value:g.available_for_use_date||"",onChange:De=>y(Je=>$e(_e({},Je),{available_for_use_date:De.target.value})),disabled:ce("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"})]})]})]})]}),t.jsx("div",{className:"mt-6",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6",children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:"Financial Details"}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:"The depreciation method is an accounting method used to allocate the cost of a tangible asset over its useful life."}),t.jsxs("div",{className:"flex items-center mb-6",children:[t.jsx("input",{id:"calculate_depreciation",type:"checkbox",checked:g.calculate_depreciation,onChange:De=>y($e(_e({},g),{calculate_depreciation:De.target.checked})),disabled:!V,className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700"}),t.jsx("label",{htmlFor:"calculate_depreciation",className:"ml-2 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Calculate Depreciation"})]}),g.calculate_depreciation&&t.jsxs("div",{className:"border-t pt-4",children:[t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[t.jsx("h3",{className:"text-md font-semibold text-gray-800 dark:text-white",children:"Asset Finance Books"}),V&&t.jsxs("button",{type:"button",onClick:re,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 flex items-center gap-2",children:[t.jsx("span",{children:"+"})," Add Row"]})]}),(!g.finance_books||g.finance_books.length===0)&&t.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400 bg-gray-50 dark:bg-gray-900 rounded-lg",children:'No finance books added yet. Click "Add Row" to add one.'}),g.finance_books&&g.finance_books.length>0&&t.jsx("div",{className:"overflow-visible",children:t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full border-collapse",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-300 dark:border-gray-600",children:[t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[200px]",children:"Finance Book"}),t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[200px]",children:"Depreciation Method*"}),t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[180px]",children:"Total Depreciations*"}),t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[180px]",children:"Frequency (Months)*"}),t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[200px]",children:"Depreciation Posting Date*"}),V&&t.jsx("th",{className:"text-center px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300 min-w-[120px]",children:"Action"})]})}),t.jsx("tbody",{children:g.finance_books.map((De,Je)=>{var Be,vt;return t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-750",children:[t.jsx("td",{className:"px-4 py-3 relative",style:{overflow:"visible"},children:t.jsx("div",{className:"relative z-20",children:t.jsx(er,{label:"",doctype:"Finance Book",value:De.finance_book||"",onChange:jt=>ve(Je,{finance_book:jt}),disabled:!V})})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("select",{value:De.depreciation_method||"",onChange:jt=>ve(Je,{depreciation_method:jt.target.value}),disabled:!V,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:[t.jsx("option",{value:"",children:"Select Method"}),t.jsx("option",{value:"Straight Line",children:"Straight Line"}),t.jsx("option",{value:"Double Declining Balance",children:"Double Declining Balance"}),t.jsx("option",{value:"Written Down Value",children:"Written Down Value"}),t.jsx("option",{value:"Manual",children:"Manual"})]})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"number",value:(Be=De.total_number_of_depreciations)!=null?Be:"",onChange:jt=>ve(Je,{total_number_of_depreciations:Number(jt.target.value)}),disabled:!V,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"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"number",value:(vt=De.frequency_of_depreciation)!=null?vt:"",onChange:jt=>ve(Je,{frequency_of_depreciation:Number(jt.target.value)}),disabled:!V,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"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"date",value:De.depreciation_start_date||"",onChange:jt=>ve(Je,{depreciation_start_date:jt.target.value}),disabled:!V,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"})}),V&&t.jsx("td",{className:"px-4 py-3 text-center",children:t.jsx("button",{type:"button",onClick:()=>ne(Je),className:"px-3 py-2 bg-red-600 text-white rounded-md hover:bg-red-700 transition-colors",children:"Remove"})})]},Je)})})]})})})]})]})}),t.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6 mt-6",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.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"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Expected End-of-Life Date"}),t.jsx("input",{type:"date",disabled:!V,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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Disposal Method"}),t.jsxs("select",{disabled:!V,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:[t.jsx("option",{value:"",children:"Recycling"}),t.jsx("option",{value:"Donation",children:"Donation"}),t.jsx("option",{value:"Sale",children:"Sale"})]})]})]})]})}),t.jsxs("div",{className:"mt-6 bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.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:"Warranty & Service Contract"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx("input",{id:"custom_warranty",type:"checkbox",checked:g.custom_warranty||!1,onChange:De=>{y($e(_e({},g),{custom_warranty:De.target.checked}))},disabled:ce("custom_warranty"),className:`h-5 w-5 rounded border-2 border-black focus:ring-2 focus:ring-blue-500 ${g.custom_warranty?"bg-green-500 border-black":"bg-red-500 border-black"}`}),t.jsx("label",{htmlFor:"custom_warranty",className:"ml-2 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Warranty"})]}),t.jsxs("div",{className:"flex items-center",children:[t.jsx("input",{id:"custom_extended_warranty",type:"checkbox",checked:g.custom_extended_warranty||!1,onChange:De=>{y($e(_e({},g),{custom_extended_warranty:De.target.checked}))},disabled:ce("custom_extended_warranty"),className:`h-5 w-5 rounded border-2 border-black focus:ring-2 focus:ring-blue-500 ${g.custom_extended_warranty?"bg-green-500 border-black":"bg-red-500 border-black"}`}),t.jsx("label",{htmlFor:"custom_extended_warranty",className:"ml-2 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Extended Warranty"})]}),t.jsxs("div",{className:"flex items-center",children:[t.jsx("input",{id:"custom__service_contract",type:"checkbox",checked:g.custom__service_contract||!1,onChange:De=>{y($e(_e({},g),{custom__service_contract:De.target.checked}))},disabled:ce("custom__service_contract"),className:`h-5 w-5 rounded border-2 border-black focus:ring-2 focus:ring-blue-500 ${g.custom__service_contract?"bg-green-500 border-black":"bg-red-500 border-black"}`}),t.jsx("label",{htmlFor:"custom__service_contract",className:"ml-2 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Service Contract"})]}),t.jsxs("div",{className:"flex items-center",children:[t.jsx("input",{id:"custom_covering_spare_parts",type:"checkbox",checked:g.custom_covering_spare_parts||!1,onChange:De=>{y($e(_e({},g),{custom_covering_spare_parts:De.target.checked}))},disabled:ce("custom_covering_spare_parts"),className:`h-5 w-5 rounded border-2 border-black focus:ring-2 focus:ring-blue-500 ${g.custom_covering_spare_parts?"bg-green-500 border-black":"bg-red-500 border-black"}`}),t.jsx("label",{htmlFor:"custom_covering_spare_parts",className:"ml-2 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Covering Spare Parts"})]}),t.jsxs("div",{className:"flex items-center",children:[t.jsx("input",{id:"custom_spare_parts_labour",type:"checkbox",checked:g.custom_spare_parts_labour||!1,onChange:De=>{y($e(_e({},g),{custom_spare_parts_labour:De.target.checked}))},disabled:ce("custom_spare_parts_labour"),className:`h-5 w-5 rounded border-2 border-black focus:ring-2 focus:ring-blue-500 ${g.custom_spare_parts_labour?"bg-green-500 border-black":"bg-red-500 border-black"}`}),t.jsx("label",{htmlFor:"custom_spare_parts_labour",className:"ml-2 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Spare Parts Labour"})]}),t.jsxs("div",{className:"flex items-center",children:[t.jsx("input",{id:"custom_covering_labour",type:"checkbox",checked:g.custom_covering_labour||!1,onChange:De=>{y($e(_e({},g),{custom_covering_labour:De.target.checked}))},disabled:ce("custom_covering_labour"),className:`h-5 w-5 rounded border-2 border-black focus:ring-2 focus:ring-blue-500 ${g.custom_covering_labour?"bg-green-500 border-black":"bg-red-500 border-black"}`}),t.jsx("label",{htmlFor:"custom_covering_labour",className:"ml-2 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Covering Labour"})]}),t.jsxs("div",{className:"flex items-center",children:[t.jsx("input",{id:"custom_ppm_only",type:"checkbox",checked:g.custom_ppm_only||!1,onChange:De=>{y($e(_e({},g),{custom_ppm_only:De.target.checked}))},disabled:ce("custom_ppm_only"),className:`h-5 w-5 rounded border-2 border-black focus:ring-2 focus:ring-blue-500 ${g.custom_ppm_only?"bg-green-500 border-black":"bg-red-500 border-black"}`}),t.jsx("label",{htmlFor:"custom_ppm_only",className:"ml-2 text-sm font-medium text-gray-700 dark:text-gray-300",children:"PPM Only"})]})]}),t.jsxs("div",{className:"mt-4",children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Support Plan"}),t.jsx("input",{type:"text",name:"custom_support_plan",value:g.custom_support_plan||"",onChange:mt,disabled:ce("custom_support_plan"),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"})]})]}),t.jsxs("div",{className:"mt-6 bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white",children:"Spare Parts"}),V&&t.jsxs("button",{type:"button",onClick:Ae,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 flex items-center gap-2 text-sm",children:[t.jsx("span",{children:"+"})," Add Row"]})]}),(!g.custom_spare_parts||g.custom_spare_parts.length===0)&&t.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400 bg-gray-50 dark:bg-gray-900 rounded-lg",children:'No spare parts added yet. Click "Add Row" to add one.'}),g.custom_spare_parts&&g.custom_spare_parts.length>0&&t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full border-collapse",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-300 dark:border-gray-600",children:[t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Item Code"}),t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Item Name"}),t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Qty"}),t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Rate"}),t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Amount"}),t.jsx("th",{className:"text-left px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"UOM"}),V&&t.jsx("th",{className:"text-center px-4 py-3 text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Action"})]})}),t.jsx("tbody",{children:g.custom_spare_parts.map((De,Je)=>t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-750",children:[t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"text",value:De.item_code||"",onChange:Be=>Ve(Je,"item_code",Be.target.value),disabled:!V,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"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"text",value:De.item_name||"",onChange:Be=>Ve(Je,"item_name",Be.target.value),disabled:!V,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"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"number",value:De.qty||0,onChange:Be=>Ve(Je,"qty",Number(Be.target.value)),disabled:!V,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"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"number",value:De.rate||0,onChange:Be=>Ve(Je,"rate",Number(Be.target.value)),disabled:!V,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"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"number",value:De.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"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("input",{type:"text",value:De.uom||"",onChange:Be=>Ve(Je,"uom",Be.target.value),disabled:!V,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"})}),V&&t.jsx("td",{className:"px-4 py-3 text-center",children:t.jsx("button",{type:"button",onClick:()=>ze(Je),className:"px-3 py-2 bg-red-600 text-white rounded-md hover:bg-red-700 transition-colors text-sm",children:"Remove"})})]},Je))}),t.jsx("tfoot",{children:t.jsxs("tr",{className:"bg-gray-100 dark:bg-gray-700 font-semibold",children:[t.jsx("td",{colSpan:4,className:"px-4 py-3 text-right text-sm text-gray-700 dark:text-gray-300",children:"Total Amount:"}),t.jsx("td",{className:"px-4 py-3 text-sm text-gray-900 dark:text-white",children:g.custom_total_spare_parts_amount||0}),t.jsx("td",{colSpan:V?2:1})]})})]})})]})]}),!i&&!c&&t.jsxs("div",{className:"mt-6 space-y-6 max-w-5xl",children:[t.jsx(Vu,{referenceDoctype:"Asset",referenceName:e||null,pollInterval:3e4,initialLimit:5}),t.jsx(Wu,{doctype:"Asset",docname:e||null,creationDate:C==null?void 0:C.creation,createdBy:C==null?void 0:C.owner,initialVisible:5,collapsible:!1,startCollapsed:!1})]})]})};function kk(){const[e,r]=E.useState(vc),[a,n]=E.useState(bx),[i,c]=E.useState(!vc()),u=E.useCallback(()=>xe(null,null,function*(){const g=localStorage.getItem("user");if(!g){r(""),n(""),c(!1);return}try{c(!0);const y=yield Kf(),x=JSON.parse(g),k=$e(_e({},x),{email:y.email||y.name||x.email,role_profile_name:y.role_profile_name||"",full_name:y.full_name||x.full_name,custom_site_name:y.custom_site_name||"",custom_phcc_site_name:y.custom_phcc_site_name||""});localStorage.setItem("user",JSON.stringify(k)),r(k.role_profile_name||""),n(k.email||y.name||"")}catch(y){console.error("[useRoleProfile] Failed to load role profile:",y),r(vc()),n(bx())}finally{c(!1)}}),[]);return E.useEffect(()=>{vc()?(r(vc()),n(bx()),c(!1)):u()},[u]),{roleProfile:e,userEmail:a,loading:i,refreshRoleProfile:u}}const RI=({isOpen:e,onClose:r,selectedCount:a,totalCount:n,pageCount:i,onExport:c,isExporting:u,exportColumns:g})=>{const{t:y}=oa(),[x,k]=E.useState(a>0?"selected":"all_with_filters"),[N,C]=E.useState("csv"),[O,D]=E.useState(g.filter(U=>U.default).map(U=>U.key));E.useEffect(()=>{a>0?k("selected"):k("all_with_filters")},[a]);const A=U=>{D(B=>B.includes(U)?B.filter(V=>V!==U):[...B,U])},I=()=>{D(g.map(U=>U.key))},z=()=>{D(g.filter(U=>U.default).map(U=>U.key))};return e?t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.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:[t.jsx("div",{className:"bg-gradient-to-r from-green-500 to-green-600 px-6 py-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(cs,{className:"text-white text-xl"}),t.jsxs("h3",{className:"text-lg font-semibold text-white",children:[y("listPages.export")," ",y("workOrders.title")]})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:u,children:t.jsx(qt,{size:20})})]})}),t.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"What to Export"}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${x==="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"} ${a===0?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"selected",checked:x==="selected",onChange:()=>k("selected"),disabled:a===0,className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Selected Rows"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export ",a," selected work order",a!==1?"s":""]})]}),a>0&&t.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:[a," selected"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${x==="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:[t.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:x==="all_on_page",onChange:()=>k("all_on_page"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Current Page"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export ",i," work order",i!==1?"s":""," on current page"]})]}),t.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"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${x==="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:[t.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:x==="all_with_filters",onChange:()=>k("all_with_filters"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"All Records (with current filters)"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export all ",n," work order",n!==1?"s":""," matching current filters"]})]}),t.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:[n," total"]})]})]})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"Export Format"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${N==="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:[t.jsx("input",{type:"radio",name:"format",value:"csv",checked:N==="csv",onChange:()=>C("csv"),className:"text-green-600 focus:ring-green-500"}),t.jsx(Kd,{className:"text-green-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"CSV"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Comma-separated values"})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${N==="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:[t.jsx("input",{type:"radio",name:"format",value:"excel",checked:N==="excel",onChange:()=>C("excel"),className:"text-green-600 focus:ring-green-500"}),t.jsx(cl,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Excel"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"XLSX spreadsheet"})]})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Columns to Export"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:I,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Select All"}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:z,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Reset to Default"})]})]}),t.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:g.map(U=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${O.includes(U.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:[t.jsx("input",{type:"checkbox",checked:O.includes(U.key),onChange:()=>A(U.key),className:"rounded text-green-600 focus:ring-green-500"}),t.jsx("span",{className:"text-sm truncate",children:U.label})]},U.key))}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:[O.length," column",O.length!==1?"s":""," selected"]})]})]}),t.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:[t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[x==="selected"&&`Exporting ${a} selected row${a!==1?"s":""}`,x==="all_on_page"&&`Exporting ${i} row${i!==1?"s":""} from current page`,x==="all_with_filters"&&`Exporting all ${n} row${n!==1?"s":""}`]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:r,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:u,children:"Cancel"}),t.jsx("button",{onClick:()=>c(x,N,O),disabled:O.length===0||u,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:u?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Exporting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Co,{}),"Export"]})})]})]})]})}):null},MI=()=>{const{t:e}=oa(),r=ua(),[a,n]=Li(),i=E.useMemo(()=>{const Ee=parseInt(a.get("page")||"1",10);return Math.max(0,Number.isNaN(Ee)?0:Ee-1)},[a]),c=E.useCallback(Ee=>{n(wt=>{const xr=new URLSearchParams(wt);return xr.set("page",String(Ee+1)),xr})},[n]),[u,g]=E.useState(null),[y,x]=E.useState(null),k=E.useRef(null),N=20,C=[{key:"name",label:e("commonFields.workOrderId"),default:!0},{key:"asset",label:e("commonFields.assetId"),default:!0},{key:"asset_name",label:e("commonFields.assetName"),default:!0},{key:"work_order_type",label:e("commonFields.workOrderType"),default:!0},{key:"company",label:e("commonFields.company"),default:!0},{key:"site_name",label:e("commonFields.siteName")||"Site Name",default:!0},{key:"department",label:e("commonFields.department"),default:!0},{key:"repair_status",label:e("commonFields.status"),default:!0},{key:"custom_priority_",label:e("commonFields.priority"),default:!0},{key:"custom_serial_number",label:e("commonFields.serialNumber"),default:!1},{key:"custom_manufacturer",label:e("commonFields.manufacturer"),default:!1},{key:"supplier",label:e("commonFields.supplier"),default:!1},{key:"description",label:e("commonFields.description"),default:!1},{key:"assigned_to",label:e("commonFields.assignedTo"),default:!1},{key:"scheduled_date",label:e("commonFields.scheduledDate"),default:!1},{key:"completed_date",label:e("commonFields.completedDate"),default:!1},{key:"creation",label:e("commonFields.createdOn"),default:!0},{key:"modified",label:e("commonFields.modifiedOn"),default:!1},{key:"owner",label:e("commonFields.createdBy"),default:!1}];a.get("asset");const[O,D]=E.useState(!1),[A,I]=E.useState(new Set),[z,U]=E.useState(!1),[B,V]=E.useState(!1),{permissionFilters:Z,loading:W,error:H}=dm("Work_Order"),{roleProfile:le,userEmail:Q}=kk(),Ne=["creation desc","creation asc","modified desc","modified asc","name asc","name desc"],[oe,se]=E.useState(()=>a.get("date_filter_by")||""),[ce,Ce]=E.useState(()=>a.get("date_start")||""),[ae,me]=E.useState(()=>a.get("date_end")||""),[K,fe]=E.useState(()=>a.get("sort_by")||"modified desc"),[Oe,ye]=E.useState(()=>a.get("work_order_id")||""),[J,G]=E.useState(()=>a.get("asset")||""),[ie,re]=E.useState(()=>a.get("work_order_type")||""),[ne,ve]=E.useState(()=>a.get("company")||""),{userPhccSiteName:Ve,siteLocked:Ae}=ym(),[ze,Re]=E.useState(()=>a.get("site_name")||""),[Ze,Lt]=E.useState(()=>a.get("status")||""),[mt,Zt]=E.useState(()=>a.get("serial_number")||""),[ar,or]=E.useState(()=>a.get("manufacturer")||""),[yt,nr]=E.useState(()=>a.get("supplier")||""),[$t,Er]=E.useState(()=>a.get("department")||""),[St,Br]=E.useState(()=>a.get("priority")||""),Pt=E.useRef(!1),it=oe&&(ce||ae),[De,Je]=E.useState(!1),[Be,vt]=E.useState(0),[jt,Ct]=E.useState([]),[Wt,pr]=E.useState(!1),[Ge,We]=E.useState(""),[At,lt]=E.useState(()=>a.get("serial_number")||""),Dt=E.useRef(null),mr=E.useMemo(()=>hl(ne,Ve),[ne,Ve]);E.useEffect(()=>{Ae&&Ve&&Re(Ve)},[Ae,Ve]),E.useEffect(()=>{const Ee=localStorage.getItem("workOrderFilterPresets");Ee&&Ct(JSON.parse(Ee))},[]),E.useEffect(()=>{const Ee=[Oe,J,ie,ne,ze,Ze,mt,ar,yt,$t,St].filter(Boolean).length+(it?1:0);vt(Ee)},[it,Oe,J,ie,ne,ze,Ze,mt,ar,yt,$t,St]);const tr={};if(Oe&&(tr.name=Oe),J&&(tr.asset=J),ie&&(tr.work_order_type=ie),ne&&(tr.company=ne),ze&&(tr.site_name=ze),Ze){const Ee=Ze.split(",").map(wt=>wt.trim()).filter(Boolean);tr.repair_status=Ee.length>1?["in",Ee]:Ze}mt&&(tr.custom_serial_number=["like",`%${mt}%`]),ar&&(tr.custom_manufacturer=ar),yt&&(tr.supplier=yt),$t&&(tr.department=$t),St&&(tr.custom_priority_=St),Object.assign(tr,xm({},oe,ce,ae));const pt=Ne.includes(K)?K:"modified desc",Jt=E.useMemo(()=>O8(tr,Z,le,Q),[tr,Z,le,Q]),{workOrders:vr,totalCount:Ir,hasMore:Le,loading:qe,error:Ke,refetch:Yt}=yw(Jt,N,i*N,pt,{}),{deleteWorkOrder:gr,loading:jr}=bw();E.useEffect(()=>{!qe&&!O&&!W&&D(!0)},[qe,O,W]),E.useEffect(()=>{if(!Pt.current){Pt.current=!0;return}n(Ee=>{const wt=new URLSearchParams(Ee);return oe?wt.set("date_filter_by",oe):wt.delete("date_filter_by"),ce?wt.set("date_start",ce):wt.delete("date_start"),ae?wt.set("date_end",ae):wt.delete("date_end"),Oe?wt.set("work_order_id",Oe):wt.delete("work_order_id"),J?wt.set("asset",J):wt.delete("asset"),ie?wt.set("work_order_type",ie):wt.delete("work_order_type"),ne?wt.set("company",ne):wt.delete("company"),ze?wt.set("site_name",ze):wt.delete("site_name"),Ze?wt.set("status",Ze):wt.delete("status"),mt?wt.set("serial_number",mt):wt.delete("serial_number"),ar?wt.set("manufacturer",ar):wt.delete("manufacturer"),yt?wt.set("supplier",yt):wt.delete("supplier"),$t?wt.set("department",$t):wt.delete("department"),St?wt.set("priority",St):wt.delete("priority"),K&&K!=="modified desc"?wt.set("sort_by",K):wt.delete("sort_by"),wt.set("page","1"),wt})},[oe,ce,ae,Oe,J,ie,ne,ze,Ze,mt,ar,yt,$t,St,K]),E.useEffect(()=>{I(new Set)},[oe,ce,ae,Oe,J,ie,ne,ze,Ze,mt,ar,yt,$t,St,i]);const Zr=Ee=>{lt(Ee),Dt.current&&clearTimeout(Dt.current),Dt.current=window.setTimeout(()=>{Zt(Ee)},800)},en=Ee=>{Ee.key==="Enter"&&(Ee.preventDefault(),Dt.current&&clearTimeout(Dt.current),Zt(At))},Qt=()=>{if(!Ge.trim()){alert("Please enter a filter name");return}const Ee={id:Date.now(),name:Ge,filters:{dateFilterBy:oe,dateStart:ce,dateEnd:ae,sortBy:K,filterWorkOrderId:Oe,filterAsset:J,filterType:ie,filterCompany:ne,filterSiteName:ze,filterStatus:Ze,filterSerialNumber:mt,filterManufacturer:ar,filterSupplier:yt,filterDepartment:$t,filterPriority:St}},wt=[...jt,Ee];Ct(wt),We(""),pr(!1),localStorage.setItem("workOrderFilterPresets",JSON.stringify(wt))},wr=Ee=>{const wt=Ee.filters;se(wt.dateFilterBy||""),Ce(wt.dateStart||""),me(wt.dateEnd||""),fe(wt.sortBy||"modified desc"),ye(wt.filterWorkOrderId||""),G(wt.filterAsset||""),re(wt.filterType||""),ve(wt.filterCompany||""),Re(wt.filterSiteName||""),Lt(wt.filterStatus||""),Zt(wt.filterSerialNumber||""),lt(wt.filterSerialNumber||""),or(wt.filterManufacturer||""),nr(wt.filterSupplier||""),Er(wt.filterDepartment||""),Br(wt.filterPriority||"")},Vt=Ee=>{const wt=jt.filter(xr=>xr.id!==Ee);Ct(wt),localStorage.setItem("workOrderFilterPresets",JSON.stringify(wt))};E.useEffect(()=>()=>{Dt.current&&clearTimeout(Dt.current)},[]),E.useEffect(()=>{const Ee=wt=>{k.current&&!k.current.contains(wt.target)&&x(null)};return y&&document.addEventListener("mousedown",Ee),()=>{document.removeEventListener("mousedown",Ee)}},[y]);const Ut=Ee=>{I(wt=>{const xr=new Set(wt);return xr.has(Ee)?xr.delete(Ee):xr.add(Ee),xr})},de=()=>{A.size===vr.length?I(new Set):I(new Set(vr.map(Ee=>Ee.name)))},ge=vr.length>0&&A.size===vr.length,be=A.size>0&&A.size<vr.length,we=E.useCallback(()=>xe(null,null,function*(){const Ee=[];let wt=0;const xr=100;let qr=!0;for(;qr;)try{const Tr=(yield Ul.getWorkOrders(Jt,["*"],xr,wt*xr,pt)).work_orders||[];Ee.push(...Tr),Tr.length<xr?qr=!1:wt++,wt>100&&(console.warn("Export safety limit reached"),qr=!1)}catch(Za){throw console.error("Error fetching work orders for export:",Za),Za}return Ee}),[Jt,pt]),ke=(Ee,wt,xr)=>xe(null,null,function*(){V(!0);try{let qr=[];switch(Ee){case"selected":qr=vr.filter(Tr=>A.has(Tr.name));break;case"all_on_page":qr=vr;break;case"all_with_filters":qr=yield we();break}if(qr.length===0){alert("No data to export");return}const Za=xr.map(Tr=>{const Ar=C.find(Pe=>Pe.key===Tr);return(Ar==null?void 0:Ar.label)||Tr});if(wt==="csv"){const Tr=[Za.join(","),...qr.map(Sr=>xr.map(la=>{let Dr=Sr[la]||"";return typeof Dr=="string"&&(Dr.includes(",")||Dr.includes('"')||Dr.includes(`
|
||
`))&&(Dr=`"${Dr.replace(/"/g,'""')}"`),Dr}).join(","))].join(`
|
||
`),Ar=new Blob(["\uFEFF"+Tr],{type:"text/csv;charset=utf-8;"}),Pe=URL.createObjectURL(Ar),kt=document.createElement("a");kt.href=Pe,kt.download=`work_orders_export_${new Date().toISOString().split("T")[0]}.csv`,kt.click(),URL.revokeObjectURL(Pe)}else if(wt==="excel"){const Tr=[Za,...qr.map(kt=>xr.map(Sr=>kt[Sr]||""))],Ar=Wa.aoa_to_sheet(Tr),Pe=Wa.book_new();Wa.book_append_sheet(Pe,Ar,"Work Orders"),ul(Pe,`work_orders_export_${new Date().toISOString().split("T")[0]}.xlsx`)}U(!1),I(new Set)}catch(qr){console.error("Export failed:",qr),alert(`Export failed: ${qr instanceof Error?qr.message:"Unknown error"}`)}finally{V(!1)}}),Te=()=>r("/work-orders/new"),Qe=Ee=>r(`/work-orders/${Ee}`),bt=Ee=>r(`/work-orders/${Ee}`),et=Ee=>r(`/work-orders/new?duplicate=${Ee}`),at=Ee=>xe(null,null,function*(){try{yield gr(Ee),g(null),Yt(),alert("Work order deleted successfully!")}catch(wt){alert(`Failed to delete work order: ${wt instanceof Error?wt.message:"Unknown error"}`)}}),nt=Ee=>{window.open(`/work-orders/${Ee}?print=true`,"_blank")},Ot=()=>{se(""),Ce(""),me(""),fe("modified desc"),ye(""),G(""),re(""),ve(""),Ae||Re(""),Lt(""),Zt(""),lt(""),or(""),nr(""),Er(""),Br(""),n(Ee=>{const wt=new URLSearchParams(Ee);return wt.delete("date_filter_by"),wt.delete("date_start"),wt.delete("date_end"),wt.delete("sort_by"),wt.delete("work_order_id"),wt.delete("asset"),wt.delete("work_order_type"),wt.delete("company"),wt.delete("site_name"),wt.delete("status"),wt.delete("serial_number"),wt.delete("manufacturer"),wt.delete("supplier"),wt.delete("department"),wt.delete("priority"),wt.set("page","1"),wt}),Dt.current&&clearTimeout(Dt.current)},It=it||Oe||J||ie||ne||ze||Ze||mt||ar||yt||$t||St,Ht=Ee=>Ee?new Date(Ee).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"-",zt=Ee=>{switch(Ee==null?void 0:Ee.toLowerCase()){case"completed":return t.jsx(Ca,{className:"text-green-500"});case"in progress":return t.jsx($s,{className:"text-blue-500"});case"pending":return t.jsx(an,{className:"text-yellow-500"});default:return t.jsx($s,{className:"text-gray-400"})}},Kt=Ee=>{switch(Ee==null?void 0:Ee.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"}},fr=Ee=>{switch(Ee==null?void 0:Ee.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 W&&!O?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading permissions..."})]})}):H?t.jsx("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:"⚠️ Permission Error"}),t.jsxs("div",{className:"text-red-700 dark:text-red-400 space-y-3",children:[t.jsx("p",{children:t.jsx("strong",{children:"Unable to load user permissions."})}),t.jsx("p",{children:H}),t.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"})]})]})}):qe&&!O?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading work orders..."})]})}):Ke?t.jsx("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:t.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-yellow-800 dark:text-yellow-300 mb-4",children:"⚠️ Work Order API Not Available"}),t.jsxs("div",{className:"text-yellow-700 dark:text-yellow-400 space-y-3",children:[t.jsx("p",{children:t.jsx("strong",{children:"The Work Order API endpoint is not deployed yet."})}),t.jsx("button",{onClick:()=>r("/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)"}),t.jsx("button",{onClick:Yt,className:"mt-2 ml-2 bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded",children:"Try Again"})]})]})}):t.jsxs("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-gray-800 dark:text-white break-words",children:e("workOrders.title")}),t.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:["Total: ",Ir," work order",Ir!==1?"s":"",A.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",A.size," selected"]}),qe&&O&&t.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[t.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-blue-500"}),"Updating..."]})]})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("button",{onClick:()=>U(!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:Ir===0,children:[t.jsx(cs,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")}),A.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:A.size})]}),t.jsxs("button",{onClick:Te,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:[t.jsx(Mi,{}),t.jsx("span",{className:"font-medium",children:e("workOrders.addWorkOrder")})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[t.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:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx("button",{onClick:()=>Je(!De),className:"text-white hover:bg-white/20 p-2 rounded-lg transition-all",children:De?t.jsx(Vl,{size:14}):t.jsx(nl,{size:14})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ri,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:"Filters"})]}),Be>0&&t.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:Be})]}),It&&t.jsx("div",{className:"flex-1 overflow-x-auto scrollbar-hide mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[it&&t.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:[t.jsxs("span",{className:"font-semibold",children:[e("filters.filterBy"),":"]})," ",e(oe==="creation"?"filters.createdDate":"filters.latestModifiedDate")," ",ce&&` ${ce}`," ",ae&&` - ${ae}`,t.jsx("button",{onClick:Ee=>{Ee.stopPropagation(),se(""),Ce(""),me("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),Oe&&t.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:[t.jsx("span",{className:"font-semibold",children:"WO ID:"})," ",Oe,t.jsx("button",{onClick:Ee=>{Ee.stopPropagation(),ye("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),J&&t.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:[t.jsx("span",{className:"font-semibold",children:"Asset:"})," ",J,t.jsx("button",{onClick:Ee=>{Ee.stopPropagation(),G(""),a.delete("asset"),n(a)},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),ie&&t.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:[t.jsx("span",{className:"font-semibold",children:"Type:"})," ",ie,t.jsx("button",{onClick:Ee=>{Ee.stopPropagation(),re("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),ne&&t.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:[t.jsx("span",{className:"font-semibold",children:"Hospital:"})," ",ne,t.jsx("button",{onClick:Ee=>{Ee.stopPropagation(),ve("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),ze&&t.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:[t.jsx("span",{className:"font-semibold",children:"Site:"})," ",ze,!Ae&&t.jsx("button",{onClick:Ee=>{Ee.stopPropagation(),Re(""),a.delete("site_name"),n(a)},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),Ze&&t.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:[t.jsx("span",{className:"font-semibold",children:"Status:"})," ",Ze,t.jsx("button",{onClick:Ee=>{Ee.stopPropagation(),Lt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),mt&&t.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:[t.jsx("span",{className:"font-semibold",children:"Serial:"})," ",mt,t.jsx("button",{onClick:Ee=>{Ee.stopPropagation(),Zt(""),lt("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),ar&&t.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:[t.jsx("span",{className:"font-semibold",children:"Mfr:"})," ",ar,t.jsx("button",{onClick:Ee=>{Ee.stopPropagation(),or("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),yt&&t.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:[t.jsx("span",{className:"font-semibold",children:"Supplier:"})," ",yt,t.jsx("button",{onClick:Ee=>{Ee.stopPropagation(),nr("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),$t&&t.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:[t.jsx("span",{className:"font-semibold",children:"Dept:"})," ",$t,t.jsx("button",{onClick:Ee=>{Ee.stopPropagation(),Er("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),St&&t.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:[t.jsx("span",{className:"font-semibold",children:"Priority:"})," ",St,t.jsx("button",{onClick:Ee=>{Ee.stopPropagation(),Br("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Be>0&&t.jsxs("button",{onClick:()=>pr(!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:[t.jsx(Fn,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),It&&t.jsxs("button",{onClick:Ot,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:[t.jsx(qt,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]})]})}),De&&t.jsxs("div",{className:"p-4",children:[jt.length>0&&t.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[t.jsx(Zl,{className:"text-yellow-500",size:12}),"Saved Filters"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:jt.map(Ee=>t.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:[t.jsx("button",{onClick:()=>wr(Ee),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:Ee.name}),t.jsx("button",{onClick:()=>Vt(Ee.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(ma,{size:10})})]},Ee.id))})]}),t.jsx("div",{className:"space-y-5",children:t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-3",children:[t.jsx(Bu,{sortBy:K,dateFilterBy:oe,dateStart:ce,dateEnd:ae,onSortByChange:fe,onDateFilterByChange:se,onDateStartChange:Ce,onDateEndChange:me}),t.jsxs("div",{className:"relative z-[60]",children:[t.jsx(er,{label:"Work Order ID",doctype:"Work_Order",value:Oe,onChange:Ee=>ye(Ee),placeholder:"Select WO ID",disabled:!1,compact:!0}),Oe&&t.jsx("button",{onClick:()=>ye(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[59]",children:[t.jsx(er,{label:"Asset",doctype:"Asset",value:J,onChange:Ee=>G(Ee),placeholder:"Select Asset",disabled:!1,compact:!0}),J&&t.jsx("button",{onClick:()=>{G(""),a.delete("asset"),n(a)},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[58]",children:[t.jsx(er,{label:"Type",doctype:"Issue Type",value:ie,onChange:Ee=>re(Ee),placeholder:"Select Type",disabled:!1,compact:!0}),ie&&t.jsx("button",{onClick:()=>re(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[57]",children:[t.jsx(er,{label:"Hospital",doctype:"Company",value:ne,onChange:Ee=>ve(Ee),placeholder:"Select Hospital",disabled:!1,compact:!0,filters:{domain:"Healthcare"}}),ne&&t.jsx("button",{onClick:()=>ve(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[56]",children:[t.jsx(er,{label:"PHCC Site",doctype:"Mobile Team Site",value:ze,onChange:Ee=>Re(Ee),placeholder:"Select Site",disabled:Ae,filters:mr,compact:!0}),ze&&!Ae&&t.jsx("button",{onClick:()=>{Re(""),a.delete("site_name"),n(a)},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Status"}),t.jsxs("select",{value:Ze,onChange:Ee=>Lt(Ee.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:[t.jsx("option",{value:"",children:"All Status"}),t.jsx("option",{value:"Open",children:"Open"}),t.jsx("option",{value:"Work In Progress",children:"Work In Progress"}),t.jsx("option",{value:"Pending Review",children:"Pending Review"}),t.jsx("option",{value:"Completed",children:"Completed"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"}),t.jsx("option",{value:"Closed",children:"Closed"})]}),Ze&&t.jsx("button",{onClick:()=>Lt(""),className:"absolute right-8 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Serial Number"}),t.jsx("input",{type:"text",value:At,onChange:Ee=>Zr(Ee.target.value),onKeyDown:en,placeholder:"Type to search...",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"}),At&&At!==mt&&t.jsx("span",{className:"absolute right-2 top-6 text-[9px] text-blue-500 animate-pulse",children:"typing..."}),mt&&t.jsx("button",{onClick:()=>{Zt(""),lt("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[55]",children:[t.jsx(er,{label:"Manufacturer",doctype:"Manufacturer",value:ar,onChange:Ee=>or(Ee),placeholder:"Select Manufacturer",disabled:!1,compact:!0}),ar&&t.jsx("button",{onClick:()=>or(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[54]",children:[t.jsx(er,{label:"Supplier",doctype:"Supplier",value:yt,onChange:Ee=>nr(Ee),placeholder:"Select Supplier",disabled:!1,compact:!0}),yt&&t.jsx("button",{onClick:()=>nr(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[53]",children:[t.jsx(er,{label:"Department",doctype:"Department",value:$t,onChange:Ee=>Er(Ee),placeholder:"Select Department",disabled:!1,compact:!0}),$t&&t.jsx("button",{onClick:()=>Er(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Priority"}),t.jsxs("select",{value:St,onChange:Ee=>Br(Ee.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:[t.jsx("option",{value:"",children:"All Priorities"}),t.jsx("option",{value:"Normal",children:"Normal"}),t.jsx("option",{value:"Urgent",children:"Urgent"})]}),St&&t.jsx("button",{onClick:()=>Br(""),className:"absolute right-8 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(qt,{size:10})})]})]})})})]})]}),Wt&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:"Save Filter Preset"}),t.jsx("input",{type:"text",value:Ge,onChange:Ee=>We(Ee.target.value),onKeyDown:Ee=>{Ee.key==="Enter"&&(Ee.preventDefault(),Qt())},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}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{pr(!1),We("")},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"}),t.jsxs("button",{onClick:Qt,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:[t.jsx(Fn,{size:12}),"Save Filter"]})]})]})}),t.jsx(RI,{isOpen:z,onClose:()=>U(!1),selectedCount:A.size,totalCount:Ir,pageCount:vr.length,onExport:ke,isExporting:B,exportColumns:C}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden relative",children:[qe&&O&&t.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:t.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[t.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-blue-500"}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Filtering..."})]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left",children:t.jsx("button",{onClick:de,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:ge?"Deselect all":"Select all",children:ge?t.jsx(qs,{className:"text-blue-600 dark:text-blue-400",size:18}):be?t.jsxs("div",{className:"relative",children:[t.jsx(Pn,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Pn,{size:18})})}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Work Order ID"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Asset"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Type"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Department"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Status"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Priority"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Actions"})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:vr.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(_o,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:"No work orders found"}),It?t.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:"Clear filters"}):t.jsx("button",{onClick:Te,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:"Create your first work order"})]})})}):vr.map(Ee=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${A.has(Ee.name)?"bg-blue-50 dark:bg-blue-900/20":""}`,onClick:()=>Qe(Ee.name),children:[t.jsx("td",{className:"px-4 py-4",onClick:wt=>wt.stopPropagation(),children:t.jsx("button",{onClick:()=>Ut(Ee.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:A.has(Ee.name)?t.jsx(qs,{className:"text-blue-600 dark:text-blue-400",size:18}):t.jsx(Pn,{size:18})})}),t.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:Ee.name}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:Ht(Ee.modified)})]}),t.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[t.jsx("div",{className:"text-sm text-gray-900 dark:text-white",children:Ee.asset_name||"-"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:Ee.asset||""})]}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:Ee.work_order_type||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:Ee.department||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsxs("div",{className:"flex items-center gap-2",children:[zt(Ee.repair_status||""),t.jsx("span",{className:`px-3 py-1 inline-flex text-xs leading-5 font-semibold rounded-full ${Kt(Ee.repair_status||"")}`,children:Ee.repair_status||"Unknown"})]})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("span",{className:`px-3 py-1 inline-flex text-xs leading-5 font-semibold rounded-full ${fr(Ee.custom_priority_||"")}`,children:Ee.custom_priority_||"Normal"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:t.jsxs("div",{className:"flex items-center gap-1",onClick:wt=>wt.stopPropagation(),children:[t.jsx("button",{onClick:()=>Qe(Ee.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:t.jsx(to,{})}),t.jsx("button",{onClick:()=>bt(Ee.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:t.jsx(Yn,{})}),t.jsx("button",{onClick:()=>et(Ee.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:t.jsx(Zd,{})}),t.jsx("button",{onClick:()=>g(Ee.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 Work Order",disabled:jr,children:t.jsx(ma,{})}),t.jsxs("div",{className:"relative",ref:y===Ee.name?k:null,children:[t.jsx("button",{onClick:()=>x(y===Ee.name?null:Ee.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:t.jsx(Eu,{})}),y===Ee.name&&t.jsx("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:t.jsxs("button",{onClick:()=>{nt(Ee.name),x(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:[t.jsx(sl,{className:"text-purple-500"}),"Print Work Order"]})})]})]})})]},Ee.name))})]})}),t.jsx(Fu,{currentPage:i+1,totalCount:Ir,pageSize:N,hasMore:Le,itemLabel:e("pagination.workOrders"),onPageChange:Ee=>c(Math.max(0,Ee-1))})]}),u&&t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.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:t.jsx(ma,{className:"text-red-600 dark:text-red-400 text-xl"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Delete Work Order"}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:"Are you sure you want to delete this work order? This action cannot be undone."}),t.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:t.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[t.jsx("strong",{children:"Work Order ID:"})," ",u]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.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:jr,children:"Cancel"}),t.jsx("button",{onClick:()=>at(u),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:jr,children:jr?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Deleting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(ma,{}),"Delete Work Order"]})})]})]})]})})}),t.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;
|
||
}
|
||
`})]})};let Dd=null,Ld=null;const DI=(e,r)=>{Dd=e,r&&(Ld=r),console.log("[Workflow] User set manually:",e,"Roles:",r)},LI=()=>{Dd=null,Ld=null},n1=()=>xe(null,null,function*(){try{if(Dd&&Ld)return console.log("[Workflow] Using cached user:",Dd,"roles:",Ld),{user:Dd,roles:Ld};const e=yield _t.getUserDetails();if(e&&e.email){const r=e.email||e.user_id,a=e.roles||[];return Dd=r,Ld=a,console.log("[Workflow] User from getUserDetails():",r),console.log("[Workflow] Roles from getUserDetails():",a),{user:r,roles:a}}return console.warn("[Workflow] getUserDetails() returned no user"),{user:"",roles:[]}}catch(e){return console.error("[Workflow] Error getting user details:",e),{user:"",roles:[]}}}),II=()=>xe(null,null,function*(){const{user:e}=yield n1();return e}),km=()=>xe(null,null,function*(){const{roles:e}=yield n1();return e}),Nm=()=>xe(null,null,function*(){try{const e=yield km(),r=e.includes("System Manager");return console.log("[Workflow] Is System Manager:",r,"Roles:",e),r}catch(e){return console.error("[Workflow] Error checking System Manager role:",e),!1}}),s1=(e,r)=>{if(!e||e.trim()==="")return!0;try{console.log("[Workflow] Evaluating condition:",e),console.log("[Workflow] Document data for condition:",{asset_type:r.asset_type,site_name:r.site_name,company:r.company,need_procurement:r.need_procurement,custom_assign_to_contractor:r.custom_assign_to_contractor,docstatus:r.docstatus});let a=e;a=a.replace(/\band\b/g,"&&"),a=a.replace(/\bor\b/g,"||"),a=a.replace(/\bnot\s+/g,"!"),a=a.replace(/\bTrue\b/g,"true"),a=a.replace(/\bFalse\b/g,"false"),a=a.replace(/\bNone\b/g,"null"),a=a.replace(/doc\.(\w+)/g,(i,c)=>{const u=r[c];return u==null||u===""?'""':typeof u=="string"?`"${u.replace(/"/g,'\\"')}"`:typeof u=="boolean"?u?"true":"false":typeof u=="number"?String(u):JSON.stringify(u)}),a=a.replace(/!=/g,"!=="),a=a.replace(new RegExp("(?<![=!])==(?!=)","g"),"==="),console.log("[Workflow] Transformed condition:",a);const n=new Function(`return (${a})`)();return console.log("[Workflow] Condition result:",n),!!n}catch(a){return console.error("[Workflow] Error evaluating condition:",e,a),!1}},Sm=e=>xe(null,null,function*(){var r,a,n,i;try{console.log("[Workflow] Getting workflow info for doctype:",e);const c=yield _t.apiCall(`/api/resource/Workflow?filters=[["document_type","=","${e}"],["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:",e),null;const u=c.data[0].name;console.log("[Workflow] Found workflow:",u);const g=yield _t.apiCall(`/api/resource/Workflow/${encodeURIComponent(u)}`);return console.log("[Workflow] Full workflow data:",g==null?void 0:g.data),console.log("[Workflow] Transitions count:",(a=(r=g==null?void 0:g.data)==null?void 0:r.transitions)==null?void 0:a.length),console.log("[Workflow] States count:",(i=(n=g==null?void 0:g.data)==null?void 0:n.states)==null?void 0:i.length),{workflow_name:g.data.name,workflow_state:"",workflow_state_field:g.data.workflow_state_field,transitions:g.data.transitions||[],states:g.data.states||[]}}catch(c){return console.error("[Workflow] Error fetching workflow info:",c),null}}),Nk=(e,r,a)=>xe(null,null,function*(){try{console.log("[Workflow] Getting all transitions for state:",r);const n=yield Sm(e);if(!n)return console.warn("[Workflow] No workflow info found"),[];console.log("[Workflow] All transitions from workflow:",n.transitions.length);let i=n.transitions.filter(g=>g.state===r);console.log("[Workflow] Transitions for state",r,":",i.length),a&&(i=i.filter(g=>{const y=s1(g.condition,a);return console.log(`[Workflow] Transition "${g.action}" (allowed: ${g.allowed}) condition "${g.condition||"none"}" = ${y}`),y}),console.log("[Workflow] Transitions after condition evaluation:",i.length));const c=new Set,u=[];for(const g of i){const y=`${g.action}::${g.next_state}`;c.has(y)?console.log(`[Workflow] Skipping duplicate: ${g.action} → ${g.next_state} (allowed: ${g.allowed})`):(c.add(y),u.push(g))}return console.log("[Workflow] Unique transitions after deduplication:",u.length),u}catch(n){return console.error("[Workflow] Error fetching all transitions:",n),[]}}),PI=(e,r,a,n)=>xe(null,null,function*(){var i;try{console.log("[Workflow] getWorkflowTransitions called with:",{doctype:e,docname:r,currentState:a});const c=yield Nm(),u=yield km();if(console.log("[Workflow] User is System Manager:",c),console.log("[Workflow] User roles:",u),c&&a){console.log("[Workflow] System Manager detected, getting all transitions for state:",a);const x=yield Nk(e,a,n);return console.log("[Workflow] Final transitions for System Manager:",x.map(k=>`${k.action} → ${k.next_state}`)),x}console.log("[Workflow] Non-System Manager, using Frappe API");const g=yield _t.apiCall("/api/method/frappe.model.workflow.get_transitions",{method:"POST",body:JSON.stringify({doc:JSON.stringify({doctype:e,name:r})})});console.log("[Workflow] Frappe transitions raw response:",g);let y=[];if(Array.isArray(g)?y=g:g!=null&&g.message&&Array.isArray(g.message)?y=g.message:g!=null&&g.data&&Array.isArray(g.data)?y=g.data:(i=g==null?void 0:g.data)!=null&&i.message&&Array.isArray(g.data.message)&&(y=g.data.message),console.log("[Workflow] Parsed transitions:",y),console.log("[Workflow] Transitions count:",y.length),y.length===0&&a&&n){console.log("[Workflow] Frappe API returned no transitions, trying local filtering");const x=yield Sm(e);if(x){const k=x.transitions.filter(O=>!(O.state!==a||!u.includes(O.allowed)||!s1(O.condition,n))),N=new Set,C=[];for(const O of k){const D=`${O.action}::${O.next_state}`;N.has(D)||(N.add(D),C.push(O))}return console.log("[Workflow] Local filtered transitions:",C),C}}return y}catch(c){return console.error("[Workflow] Error fetching workflow transitions:",c),[]}}),FI=(e,r,a,n)=>xe(null,null,function*(){try{if(console.log("[Workflow] Applying action:",{doctype:e,docname:r,action:a,nextState:n}),(yield Nm())&&n)try{const u=yield _t.apiCall("/api/method/frappe.model.workflow.apply_workflow",{method:"POST",body:JSON.stringify({doc:JSON.stringify({doctype:e,name:r}),action:a})});return console.log("[Workflow] Action applied successfully via workflow API"),u==null?void 0:u.message}catch(u){console.log("[Workflow] Normal workflow failed, System Manager forcing state change...");const g=yield _t.apiCall(`/api/resource/${e}/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({workflow_state:n})});return console.log("[Workflow] Force update response:",g),g==null?void 0:g.data}const c=yield _t.apiCall("/api/method/frappe.model.workflow.apply_workflow",{method:"POST",body:JSON.stringify({doc:JSON.stringify({doctype:e,name:r}),action:a})});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}}),BI=(e,r,a)=>xe(null,null,function*(){try{if(yield Nm())return console.log("[Workflow] System Manager can always edit"),!0;const i=yield Sm(e);if(!i)return!0;const c=yield km(),u=i.states.filter(y=>y.state===a);if(u.length===0)return!0;const g=u.some(y=>c.includes(y.allow_edit));return console.log("[Workflow] Can user edit:",g,"User roles:",c,"Allowed roles:",u.map(y=>y.allow_edit)),g}catch(n){return console.error("[Workflow] Error checking edit permission:",n),!1}}),Sk=e=>{const r={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 Team Leader":{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 Project Manager":{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 Site Manager":{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"},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 r[e]||r.Draft},Ck=e=>({Apply:"bg-blue-600 hover:bg-blue-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","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","Approve & Close":"bg-green-600 hover:bg-green-700 text-white","Work Done":"bg-green-600 hover:bg-green-700 text-white"})[e]||"bg-blue-600 hover:bg-blue-700 text-white",Ek=e=>({Apply:"📤","Send For Repair":"🔧","Send For Approval":"📋","Material Request":"📦",Accept:"✅",Reject:"❌",Close:"🔒","Re-Open":"🔓",Cancel:"🚫",Approve:"✅","Approve & Close":"✅","Work Done":"✅"})[e]||"▶️",bc={getWorkflowTransitions:PI,applyWorkflowAction:FI,getWorkflowInfo:Sm,getCurrentUserRoles:km,getCurrentUser:II,getCurrentUserAndRoles:n1,setCurrentUser:DI,clearCurrentUser:LI,canUserEditDocument:BI,getWorkflowStateStyle:Sk,getActionButtonStyle:Ck,getActionIcon:Ek,isSystemManager:Nm,getAllTransitionsForState:Nk,evaluateCondition:s1},jk=({doctype:e,docname:r,workflowState:a,enabled:n=!0,docData:i})=>{const[c,u]=E.useState([]),[g,y]=E.useState(null),[x,k]=E.useState([]),[N,C]=E.useState(""),[O,D]=E.useState(!1),[A,I]=E.useState(!1),[z,U]=E.useState(!1),[B,V]=E.useState(null),[Z,W]=E.useState(!0);E.useEffect(()=>{if(!n)return;xe(null,null,function*(){try{const Ne=yield bc.getWorkflowInfo(e);y(Ne)}catch(Ne){console.error("Error fetching workflow info:",Ne)}})},[e,n]),E.useEffect(()=>{if(!n)return;xe(null,null,function*(){try{const[Ne,oe,se]=yield Promise.all([bc.getCurrentUserRoles(),bc.getCurrentUser(),bc.isSystemManager()]);k(Ne),C(oe),D(se),se&&W(!0)}catch(Ne){console.error("Error fetching user info:",Ne)}})},[n]);const H=E.useCallback(()=>xe(null,null,function*(){if(!r||!n){u([]);return}I(!0),V(null);try{const Q=yield bc.getWorkflowTransitions(e,r,a,i);if(console.log("[useWorkflow] Available transitions:",Q),u(Q),a){const Ne=yield bc.canUserEditDocument(e,r,a);W(Ne)}}catch(Q){console.error("Error fetching transitions:",Q),V("Failed to load workflow actions"),u([])}finally{I(!1)}}),[e,r,a,n,i]);E.useEffect(()=>{H()},[H]);const le=E.useCallback((Q,Ne)=>xe(null,null,function*(){if(!r)return V("Document not saved yet"),!1;U(!0),V(null);try{return yield bc.applyWorkflowAction(e,r,Q,Ne),yield H(),!0}catch(oe){console.error("Error applying workflow action:",oe);let se="Failed to apply action";if(oe.message)se=oe.message;else if(oe._server_messages)try{se=JSON.parse(oe._server_messages).map(Ce=>{try{return JSON.parse(Ce).message}catch(ae){return Ce}}).join(`
|
||
`)}catch(ce){se=oe._server_messages}return V(se),!1}finally{U(!1)}}),[e,r,H]);return{transitions:c,workflowInfo:g,userRoles:x,currentUser:N,isSystemManager:O,loading:A,actionLoading:z,error:B,canEdit:Z,applyAction:le,refreshTransitions:H,getStateStyle:Sk,getButtonStyle:Ck,getIcon:Ek}},UI=({doctype:e,docname:r,workflowState:a,onActionComplete:n,onStateChange:i,showStateInfo:c=!0,className:u=""})=>{const{transitions:g,loading:y,actionLoading:x,error:k,applyAction:N,getStateStyle:C,getButtonStyle:O,getIcon:D}=jk({doctype:e,docname:r,workflowState:a,enabled:!!r}),[A,I]=E.useState(null),z=["Reject","Cancel","Close"],U=Z=>xe(null,null,function*(){if(z.includes(Z)&&A!==Z){I(Z);return}I(null);const W=yield N(Z);n&&n(Z,W),W&&i&&i()}),B=()=>{I(null)};if(!r)return null;const V=C(a||"Draft");return t.jsxs("div",{className:`space-y-4 ${u}`,children:[c&&a&&t.jsx("div",{className:`p-4 rounded-lg border ${V.bg} ${V.border}`,children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Workflow State"}),t.jsx("p",{className:`text-lg font-semibold ${V.text}`,children:a})]}),t.jsx("div",{className:`w-3 h-3 rounded-full ${V.bg.replace("100","500").replace("900/30","500")}`})]})}),y&&t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t.jsx(Ja,{className:"animate-spin"}),t.jsx("span",{className:"text-sm",children:"Loading workflow actions..."})]}),k&&t.jsx("div",{className:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(an,{className:"text-red-500 mt-0.5"}),t.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:k})]})}),A&&t.jsxs("div",{className:"p-4 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:[t.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[t.jsx(an,{className:"text-yellow-500 mt-0.5"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-yellow-800 dark:text-yellow-200",children:"Confirm Action"}),t.jsxs("p",{className:"text-xs text-yellow-600 dark:text-yellow-400 mt-1",children:["Are you sure you want to ",t.jsx("strong",{children:A})," this work order?"]})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>U(A),disabled:x,className:"px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white text-sm rounded-md disabled:opacity-50",children:x?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(Ja,{className:"animate-spin",size:12}),"Processing..."]}):`Yes, ${A}`}),t.jsx("button",{onClick:B,disabled:x,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"})]})]}),!y&&g.length>0&&!A&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 flex items-center gap-1",children:[t.jsx(Ad,{size:12}),"Available Actions"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:g.map((Z,W)=>t.jsxs("button",{onClick:()=>U(Z.action),disabled:x,className:`px-4 py-2 rounded-lg text-sm font-medium transition-colors disabled:opacity-50 flex items-center gap-2 ${O(Z.action)}`,title:`Move to: ${Z.next_state}`,children:[x?t.jsx(Ja,{className:"animate-spin",size:14}):t.jsx("span",{children:D(Z.action)}),Z.action]},`${Z.action}-${W}`))}),t.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:g.map((Z,W)=>t.jsxs("span",{className:"inline-block mr-3",children:[Z.action," → ",t.jsx("span",{className:"font-medium",children:Z.next_state})]},W))})]}),!y&&g.length===0&&r&&t.jsx("div",{className:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center",children:"No workflow actions available for your role"})})]})},zI=({workOrder:e})=>{const[r,a]=E.useState(!0),[n,i]=E.useState(null);return E.useEffect(()=>{if(!e){a(!1),i(null);return}let c=!1;return xe(null,null,function*(){a(!0);try{const u=yield ff.getFeedbackForWorkOrder(e);c||i(u)}catch(u){c||i(null)}finally{c||a(!1)}}),()=>{c=!0}},[e]),r||!(n!=null&&n.rating)?null:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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:"WO Feedback"}),t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Zl,{className:"text-amber-500 mt-0.5 shrink-0"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase mb-1",children:"Rating"}),t.jsx("p",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:n.rating}),n.requester_name&&t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:[t.jsx("span",{className:"font-medium",children:"Requester:"})," ",n.requester_name]}),n.comments&&t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:[t.jsx("span",{className:"font-medium",children:"Comments:"})," ",n.comments]})]})]})]})};function D_(e){return e?e.replace(" ","T").slice(0,16):""}function $f(e){if(!e)return"";if(e.includes("T")){const[r,a]=e.split("T");return a?`${r} ${a.length===5?`${a}:00`:a}`:r}return e}function HI(){const e=new Date,r=a=>String(a).padStart(2,"0");return`${e.getFullYear()}-${r(e.getMonth()+1)}-${r(e.getDate())}T${r(e.getHours())}:${r(e.getMinutes())}`}function Tk(e,r){if(!e||!r)return 0;const a=new Date($f(e).replace(" ","T")),n=new Date($f(r).replace(" ","T"));return Number.isNaN(a.getTime())||Number.isNaN(n.getTime())||n<a?0:Math.round((n.getTime()-a.getTime())/(1e3*3600)*100)/100}function L_(e){const r=_e({},e),a=HI();return r.repair_status==="Work In Progress"&&!r.first_responded_on&&(r.first_responded_on=a),r.repair_status==="Completed"&&!r.completion_date&&(r.completion_date=a),r.total_hours_spent=Tk(r.first_responded_on,r.completion_date),r}const VI="Service Report",I_=()=>new Date().toISOString().split("T")[0],WI=(e,r)=>{if(!e)return"";const a=new Date(e);return a.setDate(a.getDate()+r),a.toISOString().split("T")[0]},GI=()=>{var vr,Ir;const{workOrderName:e}=Yl(),r=ua(),[a]=Li(),n=a.get("duplicate"),i=a.get("asset"),c=!!i,u=e==="new",g=u&&!!n,y=()=>{if(!e||u)return;const qe=`/printview?doctype=Work_Order&name=${encodeURIComponent(e)}&format=${encodeURIComponent(VI)}&trigger_print=1`;window.open(qe,"_blank")||dr.warning("Please allow popups for this site to print the Service Report.",{position:"top-right",autoClose:5e3,icon:t.jsx(an,{})})},{workOrder:x,loading:k,error:N,refetch:C}=V8(g?n:u?null:e||null),{createWorkOrder:O,updateWorkOrder:D,loading:A}=bw(),[I,z]=E.useState(u),[U,B]=E.useState(!1),[V,Z]=E.useState(null),[W,H]=E.useState({company:"",work_order_type:u&&!g?"Repair (CM)":"",asset:"",asset_name:"",description:"",repair_status:"Open",workflow_state:"Draft",department:"",custom_priority_:"Normal",asset_type:"",manufacturer:"",supplier:"",serial_number:"",custom_local_id:"",custom_moh_id:"",model:"",custom_site_contractor:"",custom_subcontractor:"",failure_date:u?I_():"",custom_deadline_date:"",completion_date:"",first_responded_on:"",actions_performed:"",stock_consumption:0,stock_items:[],site_name:"",need_procurement:0,custom_assign_to_contractor:"",docstatus:0,custom_assigned_supervisor:"",custom_moh_supervisor:"",total_hours_spent:0,custom_pending_reason:"",total_repair_cost:0,custom_service_agreement:"",custom_service_coverage:"",custom_start_date:"",custom_end_date:"",custom_total_amount:0,__islocal:!1});Kl(H,{enabled:u&&!c,fields:["company"]});const le=W.asset_type==="Non Biomedical",Q=E.useCallback((Le,qe,Ke)=>{if(!Le)return"";let Yt=0;const gr=Ke===1;return qe==="Normal"?Yt=gr?30:5:qe==="Urgent"&&(Yt=gr?30:1),WI(Le,Yt)},[]);E.useEffect(()=>{if(!I)return;const Le=Q(W.failure_date,W.custom_priority_||"Normal",W.need_procurement||0);Le&&Le!==W.custom_deadline_date&&H(qe=>$e(_e({},qe),{custom_deadline_date:Le}))},[W.failure_date,W.custom_priority_,W.need_procurement,I,Q]),E.useEffect(()=>{I&&H(Le=>{const qe=L_(Le);return qe.first_responded_on===Le.first_responded_on&&qe.completion_date===Le.completion_date&&qe.total_hours_spent===Le.total_hours_spent?Le:qe})},[W.repair_status,I]),E.useEffect(()=>{if(!I)return;const Le=Tk(W.first_responded_on,W.completion_date);H(qe=>(qe.total_hours_spent||0)===Le?qe:$e(_e({},qe),{total_hours_spent:Le}))},[W.first_responded_on,W.completion_date,I]),E.useEffect(()=>{le&&I&&H(Le=>$e(_e({},Le),{asset:"",asset_name:"",serial_number:"",custom_local_id:"",custom_moh_id:"",manufacturer:"",supplier:"",model:""}))},[le,I]);const{shouldShowField:Ne,isMandatory:oe,isReadOnly:se}=hk("Work_Order",W);E.useCallback(Le=>Ne(Le),[Ne]),E.useCallback(Le=>oe(Le),[oe]);const ce=E.useCallback(Le=>se(Le),[se]);E.useCallback(Le=>I?ce(Le):!0,[I,ce]);const Ce=E.useMemo(()=>{var qe,Ke;if(u)return;const Le=I?_e(_e({},x||{}),W):x||W;return{asset_type:Le.asset_type||"",site_name:Le.site_name||"",need_procurement:(qe=Le.need_procurement)!=null?qe:0,custom_assign_to_contractor:Le.custom_assign_to_contractor||"",docstatus:(Ke=Le.docstatus)!=null?Ke:0,company:Le.company||"",department:Le.department||"",repair_status:Le.repair_status||""}},[u,I,x,W.asset_type,W.site_name,W.need_procurement,W.custom_assign_to_contractor,W.docstatus,W.company,W.department,W.repair_status]),{transitions:ae,loading:me,actionLoading:K,error:fe,canEdit:Oe,isSystemManager:ye,applyAction:J,getStateStyle:G,getButtonStyle:ie,getIcon:re}=jk({doctype:"Work_Order",docname:u?null:e||null,workflowState:x==null?void 0:x.workflow_state,enabled:!u,docData:Ce}),ne="Al Jouf Central Warehouse - AJH",[ve,Ve]=E.useState({}),Ae=(Le,qe)=>xe(null,null,function*(){if(!Le||!qe)return 0;try{const Ke=yield _t.apiCall(`/api/resource/Bin?filters=[["item_code","=","${Le}"],["warehouse","=","${qe}"]]&fields=["actual_qty"]&limit=1`);return Ke!=null&&Ke.data&&Ke.data.length>0&&Ke.data[0].actual_qty||0}catch(Ke){return console.error("Error fetching available stock:",Ke),0}}),ze=Le=>xe(null,null,function*(){var qe;if(!Le)return 0;try{const Ke=yield _t.apiCall(`/api/resource/Item/${Le}?fields=["valuation_rate"]`);return((qe=Ke==null?void 0:Ke.data)==null?void 0:qe.valuation_rate)||0}catch(Ke){return console.error("Error fetching valuation rate:",Ke),0}}),Re=(Le,qe)=>xe(null,null,function*(){const Ke=[...W.stock_items||[]];if(Ke[Le]=$e(_e({},Ke[Le]),{item_code:qe}),qe){const Yt=yield ze(qe);if(Ke[Le].valuation_rate=Yt,Ke[Le].total_value=Yt*(Ke[Le].consumed_quantity||1),Ke[Le].warehouse){const gr=yield Ae(qe,Ke[Le].warehouse);Ke[Le].custom_available_stock=gr,Lt(Le,Ke[Le].consumed_quantity,gr,qe,Ke[Le].warehouse)}}H($e(_e({},W),{stock_items:Ke}))}),Ze=(Le,qe)=>xe(null,null,function*(){const Ke=[...W.stock_items||[]];if(Ke[Le]=$e(_e({},Ke[Le]),{warehouse:qe}),qe&&Ke[Le].item_code){const Yt=yield Ae(Ke[Le].item_code,qe);Ke[Le].custom_available_stock=Yt,Lt(Le,Ke[Le].consumed_quantity,Yt,Ke[Le].item_code,qe)}H($e(_e({},W),{stock_items:Ke}))}),Lt=(Le,qe,Ke,Yt,gr)=>{qe>Ke?(Ve(jr=>$e(_e({},jr),{[Le]:`Insufficient stock for ${Yt} in ${gr}. Available: ${Ke}, Required: ${qe}`})),dr.warning(`Insufficient stock for ${Yt}. Available: ${Ke}, Required: ${qe}`,{position:"top-right",autoClose:5e3,icon:t.jsx(an,{}),toastId:`stock-warning-${Le}`})):Ve(jr=>{const Zr=_e({},jr);return delete Zr[Le],Zr})},mt=(Le,qe)=>{const Ke=[...W.stock_items||[]],Yt=Ke[Le].valuation_rate||0,gr=Ke[Le].custom_available_stock||0;Ke[Le]=$e(_e({},Ke[Le]),{consumed_quantity:qe,total_value:Yt*qe}),Ke[Le].item_code&&Ke[Le].warehouse&&Lt(Le,qe,gr,Ke[Le].item_code,Ke[Le].warehouse),H($e(_e({},W),{stock_items:Ke}))},[Zt,ar]=E.useState({}),{userPhccSiteName:or,siteLocked:yt}=ym(),nr=E.useMemo(()=>nn(W.company),[W.company]),$t=E.useMemo(()=>hl(W.company,or),[W.company,or]);E.useEffect(()=>{or&&H(Le=>Le.site_name?Le:$e(_e({},Le),{site_name:or}))},[or]);const Er=E.useMemo(()=>W.company?{custom_site_name:W.company,role_profile_name:"Technician"}:{},[W.company]),St=E.useMemo(()=>W.company?{custom_site_name:W.company,role_profile_name:"MOH Supervisor"}:{},[W.company]),Br=E.useMemo(()=>W.company?{custom_site_name:W.company,role_profile_name:"Maintenace Manager"}:{},[W.company]);E.useEffect(()=>{const Le={};W.company&&(Le.company=W.company),ar(Le)},[W.company]);const Pt=Le=>xe(null,null,function*(){if(!Le)return null;try{B(!0);const qe=yield _t.apiCall(`/api/resource/Asset/${Le}`);return(qe==null?void 0:qe.data)||null}catch(qe){return console.error("Error fetching asset details:",qe),null}finally{B(!1)}}),it=Le=>xe(null,null,function*(){if(!Le)return null;try{B(!0);const qe=yield _t.apiCall(`/api/resource/Asset?filters=[["custom_serial_number","=","${Le}"]]&fields=["name","asset_name","company","department","custom_serial_number","custom_local_id","custom_moh_id","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","custom_team_leader","custom_moh_supervisor","custom_smeh_engg"]&limit=1`);return qe!=null&&qe.data&&qe.data.length>0?qe.data[0]:null}catch(qe){return console.error("Error fetching asset by serial number:",qe),null}finally{B(!1)}}),De=Le=>Le?Le.split(" ")[0]:"",Je=Le=>{Le&&H(qe=>$e(_e({},qe),{asset:Le.name||qe.asset,asset_name:Le.asset_name||"",company:Le.company||"",department:Le.department||"",serial_number:Le.custom_serial_number||"",custom_local_id:Le.custom_local_id||"",custom_moh_id:Le.custom_moh_id||"",asset_type:Le.custom_asset_type||"",manufacturer:Le.custom_manufacturer||"",supplier:Le.supplier||"",custom_site_contractor:Le.custom_site_contractor||"",custom_subcontractor:Le.custom_subcontractor||"",model:Le.custom_model||"",site_name:Le.custom_site||"",custom_service_agreement:Le.custom_service_agreement||"",custom_service_coverage:Le.custom_service_coverage||"",custom_start_date:De(Le.custom_start_date)||"",custom_end_date:De(Le.custom_end_date)||"",custom_total_amount:Le.custom_total_amount||0,custom_assigned_supervisor:Le.custom_team_leader||"",custom_moh_supervisor:Le.custom_moh_supervisor||"",custom_assign_to_contractor:Le.custom_smeh_engg||""}))},Be=Le=>xe(null,null,function*(){if(H(qe=>$e(_e({},qe),{asset:Le})),Le){const qe=yield Pt(Le);qe&&Je(qe)}else H(qe=>$e(_e({},qe),{asset:"",asset_name:"",serial_number:"",custom_local_id:"",custom_moh_id:"",asset_type:"",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_assigned_supervisor:"",custom_moh_supervisor:"",custom_assign_to_contractor:""}))}),vt=()=>xe(null,null,function*(){if(!W.serial_number){dr.warning("Please enter a serial number to search",{position:"top-right",autoClose:3e3,icon:t.jsx(an,{})});return}const Le=yield it(W.serial_number);Le?(Je(Le),dr.success(`Asset found: ${Le.asset_name||Le.name}`,{position:"top-right",autoClose:3e3,icon:t.jsx(Ca,{})})):dr.error("No asset found with this serial number",{position:"top-right",autoClose:4e3,icon:t.jsx(jn,{})})}),jt=()=>xe(null,null,function*(){if(W.serial_number&&!W.asset){const Le=yield it(W.serial_number);Le&&Je(Le)}});E.useEffect(()=>{if(u&&c&&!g){const Le={asset:a.get("asset")||"",asset_name:a.get("asset_name")||"",asset_type:a.get("asset_type")||"",manufacturer:a.get("manufacturer")||"",supplier:a.get("supplier")||"",serial_number:a.get("serial_number")||"",custom_local_id:a.get("local_id")||"",custom_moh_id:a.get("moh_id")||"",department:a.get("department")||"",custom_site_contractor:a.get("site_contractor")||"",custom_subcontractor:a.get("subcontractor")||"",company:a.get("company")||"",site_name:a.get("site_name")||"",custom_assigned_supervisor:a.get("team_leader")||"",custom_moh_supervisor:a.get("moh_supervisor")||"",custom_assign_to_contractor:a.get("smeh_engg")||""};H(qe=>$e(_e(_e({},qe),Le),{repair_status:"Open",workflow_state:"Draft",custom_priority_:"Normal",failure_date:I_()}))}},[u,c,g,a]),E.useEffect(()=>{x&&H({company:x.company||"",work_order_type:x.work_order_type||"",asset:x.asset||"",asset_name:g?`${x.asset_name} (Copy)`:x.asset_name||"",description:x.description||"",repair_status:g?"Open":x.repair_status||"Open",workflow_state:g?"Draft":x.workflow_state||"Draft",department:x.department||"",custom_priority_:x.custom_priority_||"Normal",asset_type:x.asset_type||"",manufacturer:x.manufacturer||"",supplier:x.supplier||"",serial_number:x.serial_number||"",custom_local_id:x.custom_local_id||"",custom_moh_id:x.custom_moh_id||"",model:x.model||"",custom_site_contractor:x.custom_site_contractor||"",custom_subcontractor:x.custom_subcontractor||"",failure_date:De(x.failure_date)||"",custom_deadline_date:De(x.custom_deadline_date)||"",first_responded_on:D_(x.first_responded_on)||"",completion_date:D_(x.completion_date)||"",actions_performed:x.actions_performed||"",stock_consumption:x.stock_consumption||0,stock_items:x.stock_items||[],site_name:x.site_name||"",need_procurement:x.need_procurement||0,custom_assign_to_contractor:x.custom_assign_to_contractor||"",docstatus:x.docstatus||0,custom_assigned_supervisor:x.custom_assigned_supervisor||"",custom_moh_supervisor:x.custom_moh_supervisor||"",total_hours_spent:x.total_hours_spent||0,custom_pending_reason:x.custom_pending_reason||"",total_repair_cost:x.total_repair_cost||0,custom_service_agreement:x.custom_service_agreement||"",custom_service_coverage:x.custom_service_coverage||"",custom_start_date:De(x.custom_start_date)||"",custom_end_date:De(x.custom_end_date)||"",custom_total_amount:x.custom_total_amount||0})},[x,g]);const Ct=Le=>{const{name:qe,value:Ke}=Le.target;H(Yt=>$e(_e({},Yt),{[qe]:Ke}))},Wt=Le=>{const qe=Le.target.value;H(Ke=>$e(_e({},Ke),{custom_priority_:qe}))},pr=Le=>{const qe=Le.target.value;H(Ke=>$e(_e({},Ke),{failure_date:qe}))},Ge=Le=>{const qe=Le.target.checked?1:0;H(Ke=>$e(_e({},Ke),{need_procurement:qe}))},We=Le=>{H(Le==="Non Biomedical"?qe=>$e(_e({},qe),{asset_type:Le,asset:"",asset_name:"",serial_number:"",custom_local_id:"",custom_moh_id:"",manufacturer:"",supplier:"",model:""}):qe=>$e(_e({},qe),{asset_type:Le}))},At=Le=>xe(null,null,function*(){if(Le.preventDefault(),!W.work_order_type){dr.error("Please select a Work Order Type",{position:"top-right",autoClose:4e3,icon:t.jsx(jn,{})});return}try{const qe=L_($e(_e({},W),{first_responded_on:$f(W.first_responded_on),completion_date:$f(W.completion_date)}));if(u||g){const Ke=yield O(qe),Yt=g?"Work order duplicated successfully!":c?"Work order created from asset successfully!":"Work order created successfully!";dr.success(Yt,{position:"top-right",autoClose:3e3,icon:t.jsx(Ca,{})}),r(`/work-orders/${Ke.name}`)}else e&&(yield D(e,qe),dr.success("Work order updated successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Ca,{})}),z(!1),C())}catch(qe){console.error("Work order save error:",qe);const Ke=qe instanceof Error?qe.message:"Unknown error",Yt=JSON.stringify(qe);Ke.includes("TimestampMismatchError")||Ke.includes("Document has been modified")||Ke.includes("Please refresh")||Yt.includes("TimestampMismatchError")?(dr.error("Document was modified by another user. Refreshing...",{position:"top-right",autoClose:4e3,icon:t.jsx(an,{})}),yield C(),dr.info("Please review the latest changes and try saving again.",{position:"top-right",autoClose:5e3,icon:t.jsx(Ad,{})})):dr.error(`Failed to save work order: ${Ke}`,{position:"top-right",autoClose:6e3,icon:t.jsx(jn,{})})}}),lt=(Le,qe)=>xe(null,null,function*(){if(["Reject","Cancel","Close"].includes(Le)&&(V==null?void 0:V.action)!==Le){Z({action:Le,nextState:qe||""});return}Z(null);const Yt=dr.loading(`Applying action "${Le}"...`,{position:"top-right"}),gr=yield J(Le,qe);if(dr.dismiss(Yt),gr)dr.success(`Action "${Le}" completed successfully!`,{position:"top-right",autoClose:3e3,icon:t.jsx(Ca,{})}),C();else{const jr=fe||"Please try again.";jr.includes("TimestampMismatchError")||jr.includes("Document has been modified")||jr.includes("Please refresh")?(dr.error("Document was modified. Refreshing...",{position:"top-right",autoClose:4e3,icon:t.jsx(an,{})}),yield C(),dr.info("Please try the action again after reviewing the latest changes.",{position:"top-right",autoClose:5e3,icon:t.jsx(Ad,{})})):dr.error(`Failed to apply action "${Le}". ${jr}`,{position:"top-right",autoClose:6e3,icon:t.jsx(jn,{})})}});if(k)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading work order details..."})]})});if(N&&!u&&!g)return t.jsx("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[t.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["Error: ",N]}),t.jsx("button",{onClick:()=>r("/work-orders"),className:"mt-2 text-red-700 dark:text-red-400 underline hover:text-red-800 dark:hover:text-red-300",children:"Back to work orders list"})]})});const Dt=()=>g?"Duplicate Work Order":c?"Create Work Order from Asset":u?"New Work Order":"Work Order Details",mr=(x==null?void 0:x.workflow_state)||W.workflow_state||"Draft",tr=G(mr),pt=(Ir=(vr=x==null?void 0:x.docstatus)!=null?vr:W.docstatus)!=null?Ir:0;x!=null&&x.workflow_state||W.workflow_state;const Jt=u||ye&&pt===0||Oe;return t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-4 sm:p-6 min-w-0 overflow-x-hidden",children:[t.jsx(wm,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Hu}),t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("button",{onClick:()=>r("/work-orders"),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[t.jsx(bi,{}),t.jsx("span",{className:"text-gray-900 dark:text-white",children:Dt()})]}),!u&&t.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${tr.bg} ${tr.text} ${tr.border} border`,children:mr}),c&&t.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:[t.jsx(Nx,{size:10}),"Linked from Asset: ",i]}),U&&t.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:[t.jsx(Ja,{className:"animate-spin",size:12}),"Loading asset details..."]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[!u&&t.jsxs("button",{onClick:y,className:"bg-purple-600 hover:bg-purple-700 text-white px-6 py-2 rounded-lg flex items-center gap-2",title:"Print Service Report",children:[t.jsx(sl,{}),"Service Report"]}),!u&&!I&&Jt&&t.jsxs("button",{onClick:()=>{z(!0),dr.info("Edit mode enabled",{position:"top-right",autoClose:2e3,icon:t.jsx(Yn,{})})},className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(Yn,{}),"Edit"]}),I&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{u?r("/work-orders"):(z(!1),dr.info("Edit cancelled - changes discarded",{position:"top-right",autoClose:2e3,icon:t.jsx(jn,{})}))},className:"bg-gray-300 hover:bg-gray-400 text-gray-700 px-6 py-2 rounded-lg",disabled:A,children:"Cancel"}),t.jsxs("button",{onClick:At,disabled:A||U,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:[t.jsx(Fn,{}),A?"Saving...":"Save Changes"]})]})]})]}),c&&u&&t.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:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Nx,{className:"text-orange-500 mt-0.5"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold text-orange-800 dark:text-orange-300",children:"Creating Work Order from Asset"}),t.jsxs("p",{className:"text-xs text-orange-700 dark:text-orange-400 mt-1",children:["Asset information has been pre-filled from ",t.jsx("strong",{children:W.asset_name||i}),". Please select a Work Order Type and add any additional details."]})]})]})}),t.jsx("form",{onSubmit:At,className:"space-y-6",style:{overflow:"visible"},children:t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6",style:{overflow:"visible"},children:[t.jsxs("div",{className:"lg:col-span-3 space-y-6",style:{overflow:"visible"},children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white",children:"Asset Information"}),c&&t.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:[t.jsx(Nx,{size:8}),"From Asset"]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[t.jsx("div",{children:t.jsx(er,{label:"Hospital",doctype:"Company",value:W.company||"",onChange:Le=>{H($e(_e({},W),{company:Le,department:"",site_name:"",custom_assign_to_contractor:"",custom_moh_supervisor:"",custom_assigned_supervisor:""}))},disabled:!I,filters:{domain:"Healthcare"}})}),t.jsx("div",{children:t.jsx(er,{label:"Asset Type",doctype:"Asset Type",value:W.asset_type||"",onChange:We,disabled:!I})}),nr&&t.jsx("div",{children:t.jsx(er,{label:"Site Name",doctype:"Mobile Team Site",value:W.site_name||"",onChange:Le=>H($e(_e({},W),{site_name:Le})),disabled:!I||!W.company||yt,filters:$t,placeholder:"Select Site"},W.company||"site-name")}),!le&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative z-[50]",children:[t.jsx(er,{label:"Asset ID",doctype:"Asset",value:W.asset||"",onChange:Be,disabled:!I||U,filters:W.company?{company:W.company}:{}}),W.asset&&t.jsx("p",{className:"mt-1 text-xs text-green-600 dark:text-green-400",children:"✓ Asset details auto-populated"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Serial Number"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",name:"serial_number",value:W.serial_number,onChange:Ct,onBlur:jt,disabled:!I||U,placeholder:"Enter serial number",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"}),I&&t.jsx("button",{type:"button",onClick:vt,disabled:U||!W.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:"Search asset by serial number",children:t.jsx(_o,{size:14})})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Local ID"}),t.jsx("input",{type:"text",name:"custom_local_id",value:W.custom_local_id||"",onChange:Ct,disabled:!I||U,placeholder:"Local 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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"MOH ID"}),t.jsx("input",{type:"text",name:"custom_moh_id",value:W.custom_moh_id||"",onChange:Ct,disabled:!I||U,placeholder:"MOH 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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Asset Name"}),t.jsx("input",{type:"text",name:"asset_name",value:W.asset_name,onChange:Ct,disabled:!I,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"})]}),t.jsx("div",{children:t.jsx(er,{label:"Manufacturer",doctype:"Manufacturer",value:W.manufacturer||"",onChange:Le=>H($e(_e({},W),{manufacturer:Le})),disabled:!I})}),t.jsx("div",{children:t.jsx(er,{label:"Supplier",doctype:"Supplier",value:W.supplier||"",onChange:Le=>H($e(_e({},W),{supplier:Le})),disabled:!I})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Model"}),t.jsx("input",{type:"text",name:"model",value:W.model,onChange:Ct,disabled:!I,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"})]})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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:"Work Order Information"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Work Order ID"}),t.jsx("input",{type:"text",value:u||g?"Auto-generated":x==null?void 0:x.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"})]}),t.jsx("div",{className:"relative z-[50]",children:t.jsx(er,{label:"Work Order Type",doctype:"Issue Type",value:W.work_order_type||"",onChange:Le=>H($e(_e({},W),{work_order_type:Le})),disabled:!I})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Priority"}),t.jsxs("select",{name:"custom_priority_",value:W.custom_priority_,onChange:Wt,disabled:!I,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:[t.jsx("option",{value:"Normal",children:"Normal"}),t.jsx("option",{value:"Urgent",children:"Urgent"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Status"}),t.jsx("input",{type:"text",value:W.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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Pending Reason"}),t.jsxs("select",{name:"custom_pending_reason",value:W.custom_pending_reason||"",onChange:Ct,disabled:!I,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:[t.jsx("option",{value:"",children:"Select Pending Reason"}),t.jsx("option",{value:"Need Part",children:"Need Part"}),t.jsx("option",{value:"Waiting For Quotation",children:"Waiting For Quotation"}),t.jsx("option",{value:"Waiting For PO",children:"Waiting For PO"}),t.jsx("option",{value:"Waiting For Part Delivery",children:"Waiting For Part Delivery"})]})]}),t.jsx("div",{className:"flex items-center",children:t.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:W.need_procurement===1,onChange:Ge,disabled:!I,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 disabled:opacity-50"}),t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Need Procurement"})]})})]})]}),!le&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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:"Service Agreement Details"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Site Contractor"}),t.jsx("input",{type:"text",name:"custom_site_contractor",value:W.custom_site_contractor,onChange:Ct,disabled:!I,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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Subcontractor"}),t.jsx("input",{type:"text",name:"custom_subcontractor",value:W.custom_subcontractor,onChange:Ct,disabled:!I,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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Service Agreement"}),t.jsxs("select",{name:"custom_service_agreement",value:W.custom_service_agreement||"",onChange:Ct,disabled:!I,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:[t.jsx("option",{value:"",children:"Select Service Agreement"}),t.jsx("option",{value:"Warranty",children:"Warranty"}),t.jsx("option",{value:"Contract",children:"Contract"}),t.jsx("option",{value:"Frame Work",children:"Frame Work"}),t.jsx("option",{value:"Main Contractor",children:"Main Contractor"}),t.jsx("option",{value:"Out of warranty",children:"Out of warranty"}),t.jsx("option",{value:"Under Dismantle",children:"Under Dismantle"}),t.jsx("option",{value:"Under Installation",children:"Under Installation"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Service Coverage"}),t.jsxs("select",{name:"custom_service_coverage",value:W.custom_service_coverage||"",onChange:Ct,disabled:!I,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:[t.jsx("option",{value:"",children:"Select Service Coverage"}),t.jsx("option",{value:"PM Only",children:"PM Only"}),t.jsx("option",{value:"Labour",children:"Labour"}),t.jsx("option",{value:"Labour & Parts",children:"Labour & Parts"}),t.jsx("option",{value:"Comprehensive",children:"Comprehensive"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Start Date"}),t.jsx("input",{type:"date",name:"custom_start_date",value:W.custom_start_date||"",onChange:Ct,disabled:!I,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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"End Date"}),t.jsx("input",{type:"date",name:"custom_end_date",value:W.custom_end_date||"",onChange:Ct,disabled:!I,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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Total Amount"}),t.jsx("input",{type:"number",name:"custom_total_amount",min:"0",step:"0.01",value:W.custom_total_amount||0,onChange:Ct,disabled:!I,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"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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:"Description"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Nature of Complaint"}),t.jsx("textarea",{name:"description",value:W.description,onChange:Ct,disabled:!I,placeholder:"Describe the nature of complaint...",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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Work Performed"}),t.jsx("textarea",{name:"actions_performed",value:W.actions_performed,onChange:Ct,disabled:!I,placeholder:"Describe the work performed...",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"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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:"Location & Assignment"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[t.jsx("div",{children:t.jsx(er,{label:"MOH Supervisor",doctype:"User",query:"frappe.core.doctype.user.user.user_query",value:W.custom_moh_supervisor||"",onChange:Le=>H($e(_e({},W),{custom_moh_supervisor:Le})),disabled:!I||!W.company,filters:St,placeholder:W.company?"Select MOH Supervisor":"Select Hospital first"},`moh-supervisor-${W.company||"none"}`)}),t.jsx("div",{children:t.jsx(er,{label:"Team Leader",doctype:"User",query:"frappe.core.doctype.user.user.user_query",value:W.custom_assigned_supervisor||"",onChange:Le=>H($e(_e({},W),{custom_assigned_supervisor:Le})),disabled:!I||!W.company,filters:Br,placeholder:W.company?"Select Team Leader":"Select Hospital first"},`team-leader-${W.company||"none"}`)}),t.jsx("div",{children:t.jsx(er,{label:"Assigned Technician",doctype:"User",query:"frappe.core.doctype.user.user.user_query",value:W.custom_assign_to_contractor||"",onChange:Le=>H($e(_e({},W),{custom_assign_to_contractor:Le})),disabled:!I||!W.company,filters:Er,placeholder:W.company?"Select Technician":"Select Hospital first"},`assigned-technician-${W.company||"none"}`)}),t.jsx("div",{children:t.jsx(er,{label:"Department",doctype:"Department",value:W.department||"",onChange:Le=>H($e(_e({},W),{department:Le})),disabled:!I,filters:Zt})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Failure Date"}),t.jsx("input",{type:"date",name:"failure_date",value:W.failure_date,onChange:pr,disabled:!I,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"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Deadline Date",t.jsx("span",{className:"ml-1 text-xs text-gray-400",children:"(Auto-calculated)"})]}),t.jsx("input",{type:"date",name:"custom_deadline_date",value:W.custom_deadline_date,onChange:Ct,disabled:!I,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"}),I&&W.failure_date&&t.jsxs("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:[W.custom_priority_==="Urgent"?"Urgent":"Normal"," priority",W.need_procurement===1?" + Procurement":"",":"," ","+",W.need_procurement===1?30:W.custom_priority_==="Urgent"?1:5," days"]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Total Hours Spent",t.jsx("span",{className:"ml-1 text-xs text-gray-400",children:"(Calculated from response to completion)"})]}),t.jsx("input",{type:"number",name:"total_hours_spent",min:"0",step:"0.01",value:W.total_hours_spent||0,readOnly:!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-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["First Responded On",t.jsx("span",{className:"ml-1 text-xs text-gray-400",children:"(Auto-set on repair start)"})]}),t.jsx("input",{type:"datetime-local",name:"first_responded_on",value:W.first_responded_on,readOnly:!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-900 dark:text-white"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Completion Date & Time",t.jsx("span",{className:"ml-1 text-xs text-gray-400",children:"(Auto-set on Complete)"})]}),t.jsx("input",{type:"datetime-local",name:"completion_date",value:W.completion_date,readOnly:!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-900 dark:text-white"})]})]})]}),t.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:[t.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"}),t.jsxs("div",{className:"mb-4",children:[t.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:W.stock_consumption===1,onChange:Le=>{var qe;H($e(_e({},W),{stock_consumption:Le.target.checked?1:0,stock_items:Le.target.checked?(qe=W.stock_items)!=null&&qe.length?W.stock_items:[{item_code:"",warehouse:ne,consumed_quantity:1,valuation_rate:0,custom_available_stock:0,total_value:0}]:[]}))},disabled:!I,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"}),t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Parts Consumed"})]}),t.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"})]}),W.stock_consumption===1&&t.jsxs("div",{className:"mt-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Stock Items"}),I&&t.jsxs("button",{type:"button",onClick:()=>{H($e(_e({},W),{stock_items:[...W.stock_items||[],{item_code:"",warehouse:ne,consumed_quantity:1,valuation_rate:0,custom_available_stock:0,total_value:0}]})),dr.info("New stock item row added",{position:"top-right",autoClose:2e3,icon:t.jsx(Mi,{})})},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:[t.jsx(Mi,{size:10}),"Add Item"]})]}),t.jsx("div",{className:"stock-items-table-wrapper",children:t.jsx("div",{className:"stock-items-scroll-container",children:t.jsxs("table",{className:"w-full text-sm border border-gray-200 dark:border-gray-700 rounded-lg",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700",children:t.jsxs("tr",{children:[t.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:"#"}),t.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:["Item ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.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:"Valuation Rate"}),t.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:["Warehouse ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.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:"Consumed Qty"}),t.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:"Available Stock"}),t.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:"Total Value"}),I&&t.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:"Action"})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:(W.stock_items||[]).length===0?t.jsx("tr",{children:t.jsxs("td",{colSpan:I?8:7,className:"px-4 py-8 text-center text-gray-500 dark:text-gray-400",children:[t.jsx("p",{children:"No items added yet"}),I&&t.jsx("button",{type:"button",onClick:()=>{H($e(_e({},W),{stock_items:[{item_code:"",warehouse:ne,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:"+ Add first item"})]})}):(W.stock_items||[]).map((Le,qe)=>t.jsxs(ea.Fragment,{children:[t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 ${ve[qe]?"bg-red-50 dark:bg-red-900/20":""}`,children:[t.jsx("td",{className:"px-3 py-3 text-gray-500 dark:text-gray-400",children:qe+1}),t.jsx("td",{className:"px-3 py-3 relative",style:{zIndex:50-qe},children:t.jsx("div",{className:"relative",children:t.jsx(er,{label:"",doctype:"Item",value:Le.item_code,onChange:Ke=>Re(qe,Ke),disabled:!I,placeholder:"Select Item",compact:!0,usePortal:!0,filters:_e({is_stock_item:1},W.company?{custom_hospital_name:W.company}:{})})})}),t.jsx("td",{className:"px-3 py-3",children:t.jsx("input",{type:"number",min:"0",step:"0.01",value:Le.valuation_rate||0,onChange:Ke=>{const Yt=[...W.stock_items||[]],gr=parseFloat(Ke.target.value)||0,jr=Yt[qe].consumed_quantity||0;Yt[qe]=$e(_e({},Yt[qe]),{valuation_rate:gr,total_value:gr*jr}),H($e(_e({},W),{stock_items:Yt}))},disabled:!I,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"})}),t.jsx("td",{className:"px-3 py-3 relative",style:{zIndex:50-qe},children:t.jsx("div",{className:"relative",children:t.jsx(er,{label:"",doctype:"Warehouse",value:Le.warehouse,onChange:Ke=>Ze(qe,Ke),disabled:!I,placeholder:"Select Warehouse",compact:!0,usePortal:!0})})}),t.jsx("td",{className:"px-3 py-3",children:t.jsx("input",{type:"number",min:"1",value:Le.consumed_quantity||1,onChange:Ke=>mt(qe,parseInt(Ke.target.value)||1),disabled:!I,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 ${ve[qe]?"border-red-500 dark:border-red-500":"border-gray-300 dark:border-gray-600"}`})}),t.jsx("td",{className:"px-3 py-3",children:t.jsx("input",{type:"number",min:"0",value:Le.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:"Auto-populated from stock"})}),t.jsx("td",{className:"px-3 py-3",children:t.jsx("input",{type:"number",min:"0",step:"0.01",value:Le.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"})}),I&&t.jsx("td",{className:"px-3 py-3 text-center",children:t.jsx("button",{type:"button",onClick:()=>{var gr;const Ke=(gr=W.stock_items)==null?void 0:gr[qe],Yt=(W.stock_items||[]).filter((jr,Zr)=>Zr!==qe);H($e(_e({},W),{stock_items:Yt})),Ve(jr=>{const Zr=_e({},jr);return delete Zr[qe],Zr}),dr.warning(`Stock item ${(Ke==null?void 0:Ke.item_code)||"row"} removed`,{position:"top-right",autoClose:2e3,icon:t.jsx(ma,{})})},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:"Remove item",children:t.jsx(ma,{size:14})})})]}),ve[qe]&&t.jsx("tr",{className:"bg-red-50 dark:bg-red-900/30",children:t.jsx("td",{colSpan:I?8:7,className:"px-4 py-2",children:t.jsxs("div",{className:"flex items-center gap-2 text-red-600 dark:text-red-400 text-xs",children:[t.jsx(an,{}),t.jsx("span",{children:ve[qe]})]})})})]},qe))})]})})}),(W.stock_items||[]).length>0&&t.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:[t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["Total Items: ",t.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:(W.stock_items||[]).length})]}),t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["Total Qty: ",t.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:(W.stock_items||[]).reduce((Le,qe)=>Le+(qe.consumed_quantity||0),0)})]}),t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["Total Value: ",t.jsx("span",{className:"font-semibold text-green-600 dark:text-green-400",children:(W.stock_items||[]).reduce((Le,qe)=>Le+(qe.total_value||0),0).toFixed(2)})]})]})]}),t.jsx("div",{className:"mt-6 pt-4 border-t border-gray-200 dark:border-gray-700",children:t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Total Repair Cost"}),t.jsx("input",{type:"number",name:"total_repair_cost",min:"0",step:"0.01",value:W.total_repair_cost||0,onChange:Ct,disabled:!I,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"})]})})})]})]}),t.jsxs("div",{className:"space-y-6",children:[!u&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsx("div",{className:"flex items-center justify-between mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-white",children:"Workflow Actions"})}),t.jsxs("div",{className:`p-4 rounded-lg border mb-4 ${tr.bg} ${tr.border}`,children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Current State"}),t.jsx("p",{className:`text-lg font-semibold ${tr.text}`,children:mr})]}),me&&t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400 mb-4",children:[t.jsx(Ja,{className:"animate-spin"}),t.jsx("span",{className:"text-sm",children:"Loading actions..."})]}),fe&&t.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:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(an,{className:"text-red-500 mt-0.5"}),t.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:fe})]})}),V&&t.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:[t.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[t.jsx(an,{className:"text-yellow-500 mt-0.5"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-yellow-800 dark:text-yellow-200",children:"Confirm Action"}),t.jsxs("p",{className:"text-xs text-yellow-600 dark:text-yellow-400 mt-1",children:["Are you sure you want to ",t.jsx("strong",{children:V.action})," this work order?"]})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>lt(V.action,V.nextState),disabled:K,className:"px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white text-sm rounded-md disabled:opacity-50",children:K?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(Ja,{className:"animate-spin",size:12}),"Processing..."]}):`Yes, ${V.action}`}),t.jsx("button",{onClick:()=>Z(null),disabled:K,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"})]})]}),!me&&ae.length>0&&!V&&t.jsxs("div",{className:"space-y-3",children:[ye&&t.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:t.jsxs("p",{className:"text-xs text-purple-700 dark:text-purple-300",children:[t.jsx("strong",{children:"System Manager:"})," Showing all valid actions for this state (conditions evaluated)."]})}),t.jsxs("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 flex items-center gap-1",children:[t.jsx(Ad,{size:12}),"Available Actions (",ae.length,")"]}),t.jsx("div",{className:"flex flex-col gap-2",children:ae.map((Le,qe)=>t.jsxs("button",{onClick:()=>lt(Le.action,Le.next_state),disabled:K,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 ${ie(Le.action)}`,children:[K?t.jsx(Ja,{className:"animate-spin",size:14}):t.jsx("span",{children:re(Le.action)}),Le.action]},`${Le.action}-${Le.next_state}-${qe}`))}),t.jsxs("div",{className:"mt-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:"Action Results:"}),ae.map((Le,qe)=>t.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-300",children:[Le.action," → ",t.jsx("span",{className:"font-medium",children:Le.next_state})]},qe))]})]}),!me&&ae.length===0&&t.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center",children:"No workflow actions available"}),t.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)"})]})]}),!u&&["Approved","Closed"].includes(mr)&&e&&t.jsx(zI,{workOrder:e}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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"}),!u&&x&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Repair Status"}),t.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:x.repair_status||"Open"})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Priority"}),t.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:x.custom_priority_||"Normal"})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Created"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:x.creation?new Date(x.creation).toLocaleString():"-"})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Last Modified"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:x.modified?new Date(x.modified).toLocaleString():"-"})]})]}),u&&t.jsxs("div",{className:"text-center py-8",children:[t.jsx(Ad,{className:"text-4xl text-gray-400 dark:text-gray-500 mx-auto mb-2"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Status information will appear after creation"})]})]}),!u&&!g&&t.jsx(Wu,{doctype:"Work_Order",docname:e||null,creationDate:x==null?void 0:x.creation,createdBy:x==null?void 0:x.owner,initialVisible:5,collapsible:!1,startCollapsed:!1,compact:!0})]})]})}),!u&&!g&&t.jsx("div",{className:"mt-6 space-y-6 max-w-5xl",children:t.jsx(Vu,{referenceDoctype:"Work_Order",referenceName:e||null,pollInterval:3e4,initialLimit:5})}),t.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;
|
||
}
|
||
`})]})},$I=()=>{const{t:e}=oa(),r=ua(),[a]=Li(),[n,i]=E.useState(0),[c,u]=E.useState(""),[g,y]=E.useState(()=>a.get("status")||""),[x,k]=E.useState(()=>a.get("assignee")||""),[N,C]=E.useState(()=>a.get("date_start")||""),[O,D]=E.useState(()=>a.get("date_end")||""),[A,I]=E.useState(()=>a.get("company")||""),[z,U]=E.useState(()=>a.get("site_name")||""),[B,V]=E.useState(null),[Z,W]=E.useState(null),H=E.useRef(null),le=20;E.useEffect(()=>{y(a.get("status")||""),k(a.get("assignee")||""),C(a.get("date_start")||""),D(a.get("date_end")||""),I(a.get("company")||""),U(a.get("site_name")||""),i(0)},[a]);const Q=E.useMemo(()=>{const Re={};return g&&(Re.maintenance_status=g),x&&(Re.assign_to_name=x),A&&(Re.company=A),z&&(Re.site_name=z),N&&O?Re.due_date=["between",[N,O]]:N?Re.due_date=[">=",N]:O&&(Re.due_date=["<=",O]),Re},[g,x,A,z,N,O]),{logs:Ne,totalCount:oe,hasMore:se,loading:ce,error:Ce,refetch:ae}=Qf(Q,le,n*le,"due_date asc"),{deleteLog:me,loading:K}=vw();E.useEffect(()=>{const Re=Ze=>{H.current&&!H.current.contains(Ze.target)&&W(null)};return Z&&document.addEventListener("mousedown",Re),()=>{document.removeEventListener("mousedown",Re)}},[Z]);const fe=()=>{r("/maintenance/new")},Oe=Re=>{r(`/maintenance/${Re}`)},ye=Re=>{r(`/maintenance/${Re}`)},J=Re=>xe(null,null,function*(){try{yield me(Re),V(null),ae(),alert("Maintenance log deleted successfully!")}catch(Ze){alert(`Failed to delete: ${Ze instanceof Error?Ze.message:"Unknown error"}`)}}),G=Re=>{r(`/maintenance/new?duplicate=${Re}`)},ie=Re=>{const Ze=JSON.stringify(Re,null,2),Lt=new Blob([Ze],{type:"application/json"}),mt=URL.createObjectURL(Lt),Zt=document.createElement("a");Zt.href=mt,Zt.download=`maintenance_${Re.name}.json`,Zt.click(),URL.revokeObjectURL(mt)},re=Re=>{window.open(`/maintenance/${Re}?print=true`,"_blank")},ne=()=>{const Ze=[["Log ID","Asset","Type","Status","Due Date","Assigned To"].join(","),...Ne.map(ar=>[ar.name,ar.asset_name||"",ar.maintenance_type||"",ar.maintenance_status||"",ar.due_date||"",ar.assign_to_name||""].join(","))].join(`
|
||
`),Lt=new Blob([Ze],{type:"text/csv"}),mt=URL.createObjectURL(Lt),Zt=document.createElement("a");Zt.href=mt,Zt.download=`maintenance_logs_${new Date().toISOString().split("T")[0]}.csv`,Zt.click(),URL.revokeObjectURL(mt)},ve=Re=>{switch(Re==null?void 0:Re.toLowerCase()){case"completed":return t.jsx(Ca,{className:"text-green-500"});case"planned":return t.jsx(Nw,{className:"text-blue-500"});case"overdue":return t.jsx(an,{className:"text-red-500"});default:return t.jsx($s,{className:"text-gray-400"})}},Ve=Re=>{switch(Re==null?void 0:Re.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"}},Ae=(Re,Ze)=>!Re||(Ze==null?void 0:Ze.toLowerCase())==="completed"?!1:new Date(Re)<new Date;if(ce&&n===0)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("listPages.loading")})]})});if(Ce)return t.jsx("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:t.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-yellow-800 dark:text-yellow-300 mb-4",children:"⚠️ Maintenance API Not Available"}),t.jsxs("div",{className:"text-yellow-700 dark:text-yellow-400 space-y-3",children:[t.jsx("p",{children:t.jsx("strong",{children:"The Asset Maintenance API endpoint is not deployed yet."})}),t.jsxs("div",{className:"mt-4 flex gap-3",children:[t.jsx("button",{onClick:()=>r("/maintenance/new"),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:"Try Creating New (Demo)"}),t.jsx("button",{onClick:ae,className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded",children:"Try Again"})]})]}),t.jsx("div",{className:"mt-4 p-4 bg-white dark:bg-gray-800 rounded border border-yellow-300 dark:border-yellow-700",children:t.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[t.jsx("strong",{children:"Technical Error:"})," ",Ce]})})]})});const ze=Ne.filter(Re=>{var Ze,Lt,mt;return((Ze=Re.name)==null?void 0:Ze.toLowerCase().includes(c.toLowerCase()))||((Lt=Re.asset_name)==null?void 0:Lt.toLowerCase().includes(c.toLowerCase()))||((mt=Re.task_name)==null?void 0:mt.toLowerCase().includes(c.toLowerCase()))});return t.jsxs("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-gray-800 dark:text-white break-words",children:e("maintenance.title")}),t.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:[e("listPages.total"),": ",oe," ",e("maintenance.maintenanceLogs")]})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("button",{onClick:ne,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:Ne.length===0,children:[t.jsx(cs,{}),t.jsx("span",{className:"font-medium",children:e("listPages.exportAllOnPage")})]}),t.jsxs("button",{onClick:fe,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:[t.jsx(Mi,{}),t.jsx("span",{className:"font-medium",children:e("maintenance.addMaintenance")})]})]})]}),t.jsxs("div",{className:"mb-6 grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:t.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:[t.jsx(_o,{className:"text-gray-400 dark:text-gray-500"}),t.jsx("input",{type:"text",placeholder:e("listPages.searchPlaceholder"),value:c,onChange:Re=>u(Re.target.value),className:"flex-1 outline-none text-gray-700 dark:text-gray-200 bg-transparent"})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:t.jsxs("select",{value:g,onChange:Re=>{y(Re.target.value),i(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:[t.jsx("option",{value:"",children:e("listPages.allStatuses")}),t.jsx("option",{value:"Planned",children:"Planned"}),t.jsx("option",{value:"Completed",children:"Completed"}),t.jsx("option",{value:"Overdue",children:"Overdue"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"})]})})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden",children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("maintenance.logId")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.assetShort")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.typeShort")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("ppm.dueDate")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.status")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("listPages.actions")})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:ze.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(_o,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("listPages.noMaintenanceLogsFound")}),t.jsx("button",{onClick:fe,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:e("listPages.createFirstMaintenanceLog")})]})})}):ze.map(Re=>{const Ze=Ae(Re.due_date||"",Re.maintenance_status||"");return t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${Ze?"bg-red-50 dark:bg-red-900/10":""}`,onClick:()=>Oe(Re.name),children:[t.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:Re.name}),t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:Re.creation?new Date(Re.creation).toLocaleDateString():""})]}),t.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[t.jsx("div",{className:"text-sm text-gray-900 dark:text-white",children:Re.asset_name||"-"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:Re.custom_asset_type||""})]}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:Re.maintenance_type||"-"}),t.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[t.jsx("div",{className:"text-sm text-gray-900 dark:text-white",children:Re.due_date?new Date(Re.due_date).toLocaleDateString():"-"}),Ze&&t.jsx("div",{className:"text-xs text-red-600 dark:text-red-400 font-semibold",children:"Overdue"})]}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsxs("div",{className:"flex items-center gap-2",children:[ve(Re.maintenance_status||""),t.jsx("span",{className:`px-3 py-1 inline-flex text-xs leading-5 font-semibold rounded-full ${Ve(Re.maintenance_status||"")}`,children:Re.maintenance_status||"Unknown"})]})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:t.jsxs("div",{className:"flex items-center gap-1",onClick:Lt=>Lt.stopPropagation(),children:[t.jsx("button",{onClick:()=>Oe(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:t.jsx(to,{})}),t.jsx("button",{onClick:()=>ye(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 Log",children:t.jsx(Yn,{})}),t.jsx("button",{onClick:()=>G(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",children:t.jsx(Zd,{})}),t.jsx("button",{onClick:()=>V(Re.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:K,children:t.jsx(ma,{})}),t.jsxs("div",{className:"relative",ref:Z===Re.name?H:null,children:[t.jsx("button",{onClick:()=>W(Z===Re.name?null:Re.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:t.jsx(Eu,{})}),Z===Re.name&&t.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:[t.jsxs("button",{onClick:()=>{ie(Re),W(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:[t.jsx(Co,{className:"text-blue-500"}),"Export as JSON"]}),t.jsxs("button",{onClick:()=>{re(Re.name),W(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:[t.jsx(sl,{className:"text-purple-500"}),"Print Log"]})]})]})]})})]},Re.name)})})]})}),ze.length>0&&t.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:[t.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Showing ",t.jsx("span",{className:"font-medium",children:n*le+1})," to"," ",t.jsx("span",{className:"font-medium",children:Math.min((n+1)*le,oe)})," ","of ",t.jsx("span",{className:"font-medium",children:oe})," results"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:n===0,onClick:()=>i(n-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"}),t.jsx("button",{disabled:!se,onClick:()=>i(n+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"})]})]})]}),B&&t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.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:t.jsx(ma,{className:"text-red-600 dark:text-red-400 text-xl"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Delete Maintenance Log"}),t.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."}),t.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:t.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[t.jsx("strong",{children:"Log ID:"})," ",B]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>V(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:K,children:"Cancel"}),t.jsx("button",{onClick:()=>J(B),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:K,children:K?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Deleting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(ma,{}),"Delete Log"]})})]})]})]})})})]})},XI=_t,YI=({message:e,type:r,onClose:a})=>{E.useEffect(()=>{const i=setTimeout(a,1e4);return()=>clearTimeout(i)},[a]);const n=r==="warning"?"bg-yellow-500":r==="success"?"bg-green-500":"bg-red-500";return t.jsx("div",{className:`fixed top-4 right-4 ${n} text-white px-6 py-4 rounded-lg shadow-lg z-50 max-w-md`,children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(an,{className:"mt-0.5 flex-shrink-0"}),t.jsx("p",{className:"text-sm",children:e}),t.jsx("button",{onClick:a,className:"ml-2 text-white hover:text-gray-200",children:t.jsx(qt,{})})]})})},ZI=()=>{const{t:e}=oa(),{logName:r}=Yl(),a=ua(),[n]=Li(),i=n.get("duplicate"),c=r==="new",u=c&&!!i,{log:g,loading:y,error:x}=G8(u?i:c?null:r||null),{createLog:k,updateLog:N,loading:C}=vw(),O=(g==null?void 0:g.workflow_state)==="Approved",[D,A]=E.useState(c),[I,z]=E.useState([]),[U,B]=E.useState(null),[V,Z]=E.useState(!1),[W,H]=E.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:""});Kl(H,{enabled:c&&!u,fields:["custom_hospital_name"]});const le=E.useCallback((ye,J,G)=>{if(G!=="Completed"){H(ve=>$e(_e({},ve),{custom_early_completion:""}));return}if(!ye||!J)return;const ie=new Date(ye),re=new Date(J),ne=new Date(ie.getFullYear(),ie.getMonth(),1);if(re<ne){H(Ae=>$e(_e({},Ae),{custom_early_completion:"Yes"}));const ve=re.toLocaleDateString(),Ve=ie.toLocaleDateString();B({message:`⚠️ Warning: Completion Date (${ve}) is before the Due Date Month (${Ve}). Please verify.`,type:"warning"})}},[]),Q=E.useCallback(ye=>xe(null,null,function*(){var J;if(ye){Z(!0);try{const G=yield XI.apiCall(`/api/resource/PPM Templates/${encodeURIComponent(ye)}`,"GET");if((J=G==null?void 0:G.data)!=null&&J.ppm_template_table&&Array.isArray(G.data.ppm_template_table)){const ie=G.data.ppm_template_table.map((re,ne)=>({idx:ne+1,maintenance_name:re.maintenance_name||"",working:0,defect_found:0,not_working:0}));z(ie)}}catch(G){console.error("Error loading PPM template:",G),B({message:"Failed to load PPM template. Please add items manually.",type:"error"})}finally{Z(!1)}}}),[]);E.useEffect(()=>{g&&(g.workflow_state==="Approved"&&A(!1),H({asset_name:g.asset_name||"",custom_asset_type:g.custom_asset_type||"",item_code:g.item_code||"",item_name:g.item_name||"",custom_asset_names:g.custom_asset_names||"",custom_hospital_name:g.custom_hospital_name||"",task:g.task||"",task_name:g.task_name||"",maintenance_type:g.maintenance_type||"Preventive Maintenance",periodicity:g.periodicity||"",has_certificate:g.has_certificate||0,custom_early_completion:u?"":g.custom_early_completion||"",maintenance_status:u?"Planned":g.maintenance_status||"Planned",custom_accepted_by_moh:g.custom_accepted_by_moh||0,assign_to_name:g.assign_to_name||"",due_date:g.due_date||"",completion_date:u?"":g.completion_date||"",custom_early_completion_reason:u?"":g.custom_early_completion_reason||"",custom_accepted_by_moh_:g.custom_accepted_by_moh_||0,custom_template:g.custom_template||"",custom_table:g.custom_table||[],description:g.description||""}),g.custom_table&&Array.isArray(g.custom_table)&&g.custom_table.length>0?z(g.custom_table.map((ye,J)=>({name:ye.name,idx:ye.idx||J+1,maintenance_name:ye.maintenance_name||"",working:ye.working||0,defect_found:ye.defect_found||0,not_working:ye.not_working||0}))):g.custom_template&&(!g.custom_table||g.custom_table.length===0)&&Q(g.custom_template))},[g,u,Q]),E.useEffect(()=>{W.completion_date&&W.due_date&&le(W.due_date,W.completion_date,W.maintenance_status)},[W.completion_date,W.due_date,W.maintenance_status,le]);const Ne=ye=>{const{name:J,value:G,type:ie}=ye.target,re=ye.target.checked;H(ne=>$e(_e({},ne),{[J]:ie==="checkbox"?re?1:0:G}))},oe=ye=>{const J=ye.target.value;H(G=>$e(_e({},G),{maintenance_status:J})),J==="Completed"?le(W.due_date||"",W.completion_date||"",J):H(G=>$e(_e({},G),{custom_early_completion:""}))},se=ye=>{const J=ye.target.value;H(G=>$e(_e({},G),{completion_date:J})),W.maintenance_status==="Completed"&&le(W.due_date||"",J,W.maintenance_status)},ce=ye=>xe(null,null,function*(){const J=ye.target.value;H(G=>$e(_e({},G),{custom_template:J})),(J&&I.length===0||J&&I.length>0&&window.confirm("Loading a template will replace existing checklist items. Continue?"))&&Q(J)}),Ce=()=>{const ye={idx:I.length+1,maintenance_name:"",working:0,defect_found:0,not_working:0};z([...I,ye])},ae=ye=>{const J=I.filter((G,ie)=>ie!==ye).map((G,ie)=>$e(_e({},G),{idx:ie+1}));z(J)},me=(ye,J,G)=>{const ie=[...I];ie[ye]=$e(_e({},ie[ye]),{[J]:G}),z(ie)},K=ye=>xe(null,null,function*(){if(ye.preventDefault(),!W.asset_name){alert("Please enter Asset Name");return}if(!W.maintenance_type){alert("Please select Maintenance Type");return}const J=I.map((ie,re)=>{const ne={idx:ie.idx||re+1,maintenance_name:ie.maintenance_name||"",working:ie.working?1:0,defect_found:ie.defect_found?1:0,not_working:ie.not_working?1:0};return ie.name&&typeof ie.name=="string"&&ie.name.trim()!==""&&(ne.name=ie.name),ne}),G=$e(_e({},W),{custom_table:J});console.log("Submitting maintenance log data:",G);try{if(c||u){const ie=yield k(G);alert(u?"Maintenance log duplicated successfully!":"Maintenance log created successfully!"),a(`/maintenance/${ie.name}`)}else r&&(yield N(r,G),alert("Maintenance log updated successfully!"),A(!1))}catch(ie){console.error("Maintenance log save error:",ie),alert("Failed to save: "+(ie instanceof Error?ie.message:"Unknown error"))}}),fe=ye=>({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"})[ye]||"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",Oe=ye=>({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"})[ye]||"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300";return y?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading maintenance log..."})]})}):x&&!c&&!u?t.jsx("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[t.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["Error: ",x]}),t.jsx("button",{onClick:()=>a("/maintenance"),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"})]})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-4 sm:p-6 min-w-0 overflow-x-hidden",children:[U&&t.jsx(YI,{message:U.message,type:U.type,onClose:()=>B(null)}),t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("button",{onClick:()=>a("/maintenance"),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[t.jsx(bi,{}),t.jsx("span",{className:"text-gray-900 dark:text-white font-semibold",children:u?"Duplicate Maintenance Log":c?"New Maintenance Log":"Maintenance Log Details"})]}),!c&&(g==null?void 0:g.workflow_state)&&t.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium ${fe(g.workflow_state)}`,children:g.workflow_state})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[!c&&!D&&!O&&t.jsxs("button",{onClick:()=>A(!0),className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(Yn,{}),"Edit"]}),D&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{c?a("/maintenance"):A(!1)},className:"bg-gray-300 hover:bg-gray-400 text-gray-700 px-6 py-2 rounded-lg",disabled:C,children:"Cancel"}),t.jsxs("button",{onClick:K,disabled:C,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:[t.jsx(Fn,{}),C?"Saving...":"Save Changes"]})]})]})]}),t.jsx("form",{onSubmit:K,className:"space-y-6",children:t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Log ID"}),t.jsx("input",{type:"text",value:c||u?"Auto-generated":(g==null?void 0:g.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"}),u&&t.jsxs("p",{className:"mt-1 text-xs text-blue-600 dark:text-blue-400",children:["💡 Duplicating from: ",i]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Hospital"}),t.jsx("input",{type:"text",name:"custom_hospital_name",value:W.custom_hospital_name||"",onChange:Ne,disabled:!D,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"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Asset Name ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",name:"asset_name",value:W.asset_name,onChange:Ne,required:!0,disabled:!D,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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Asset Display Name"}),t.jsx("input",{type:"text",name:"custom_asset_names",value:W.custom_asset_names||"",onChange:Ne,disabled:!D,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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Asset Type"}),t.jsx("input",{type:"text",name:"custom_asset_type",value:W.custom_asset_type||"",onChange:Ne,disabled:!D,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"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Maintenance Type ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("select",{name:"maintenance_type",value:W.maintenance_type,onChange:Ne,required:!0,disabled:!D,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:[t.jsx("option",{value:"Preventive Maintenance",children:"Preventive Maintenance"}),t.jsx("option",{value:"Corrective Maintenance",children:"Corrective Maintenance"}),t.jsx("option",{value:"Calibration",children:"Calibration"}),t.jsx("option",{value:"Inspection",children:"Inspection"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Periodicity"}),t.jsxs("select",{name:"periodicity",value:W.periodicity||"",onChange:Ne,disabled:!D,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:[t.jsx("option",{value:"",children:"Select periodicity"}),t.jsx("option",{value:"Daily",children:"Daily"}),t.jsx("option",{value:"Weekly",children:"Weekly"}),t.jsx("option",{value:"Monthly",children:"Monthly"}),t.jsx("option",{value:"Quarterly",children:"Quarterly"}),t.jsx("option",{value:"Half Yearly",children:"Half Yearly"}),t.jsx("option",{value:"Yearly",children:"Yearly"}),t.jsx("option",{value:"2 Yearly",children:"2 Yearly"}),t.jsx("option",{value:"3 Yearly",children:"3 Yearly"})]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Template",V&&t.jsx("span",{className:"ml-2 text-blue-500",children:"(Loading...)"})]}),t.jsx("input",{type:"text",name:"custom_template",value:W.custom_template||"",onChange:ce,disabled:!D,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"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Enter template name to auto-load checklist items"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Status"}),t.jsxs("select",{name:"maintenance_status",value:W.maintenance_status,onChange:oe,disabled:!D,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:[t.jsx("option",{value:"Planned",children:"Planned"}),t.jsx("option",{value:"Completed",children:"Completed"}),t.jsx("option",{value:"Overdue",children:"Overdue"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Assigned To"}),t.jsx("input",{type:"text",name:"assign_to_name",value:W.assign_to_name||"",onChange:Ne,disabled:!D,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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Due Date"}),t.jsx("input",{type:"date",name:"due_date",value:W.due_date||"",onChange:Ne,disabled:!D,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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Completion Date"}),t.jsx("input",{type:"date",name:"completion_date",value:W.completion_date||"",onChange:se,disabled:!D,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"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Early Completion",W.custom_early_completion==="Yes"&&t.jsx("span",{className:"ml-2 text-yellow-500",children:"⚠️ Auto-detected"})]}),t.jsx("input",{type:"text",value:W.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"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Auto-set based on completion date vs due date"})]}),W.custom_early_completion==="Yes"&&t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Early Completion Reason ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",name:"custom_early_completion_reason",value:W.custom_early_completion_reason||"",onChange:Ne,disabled:!D,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"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"checkbox",name:"custom_accepted_by_moh",checked:!!W.custom_accepted_by_moh,onChange:Ne,disabled:!D,className:"w-4 h-4 text-blue-600 rounded focus:ring-2 focus:ring-blue-500"}),t.jsx("label",{className:"text-xs font-medium text-gray-700 dark:text-gray-300",children:"Accepted by MOH"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex justify-between items-center mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-base font-semibold text-gray-800 dark:text-white flex items-center gap-2",children:[t.jsx(dC,{}),"PPM Checklist Table",V&&t.jsx("span",{className:"text-sm text-blue-500 font-normal",children:"(Loading template...)"})]}),D&&t.jsxs("button",{type:"button",onClick:Ce,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:[t.jsx(Mi,{className:"text-xs"}),"Add Row"]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"bg-gray-50 dark:bg-gray-700",children:[t.jsx("th",{className:"text-left py-3 px-3 text-xs font-medium text-gray-700 dark:text-gray-300 w-12",children:"#"}),t.jsx("th",{className:"text-left py-3 px-3 text-xs font-medium text-gray-700 dark:text-gray-300",children:"Maintenance Task"}),t.jsx("th",{className:"text-center py-3 px-3 text-xs font-medium text-green-600 dark:text-green-400 w-24",children:t.jsxs("div",{className:"flex items-center justify-center gap-1",children:[t.jsx(Cw,{})," Working"]})}),t.jsx("th",{className:"text-center py-3 px-3 text-xs font-medium text-yellow-600 dark:text-yellow-400 w-28",children:t.jsxs("div",{className:"flex items-center justify-center gap-1",children:[t.jsx(an,{})," Defect"]})}),t.jsx("th",{className:"text-center py-3 px-3 text-xs font-medium text-red-600 dark:text-red-400 w-28",children:t.jsxs("div",{className:"flex items-center justify-center gap-1",children:[t.jsx(qt,{})," Not Working"]})}),D&&t.jsx("th",{className:"text-center py-3 px-3 text-xs font-medium text-gray-700 dark:text-gray-300 w-16",children:"Action"})]})}),t.jsx("tbody",{children:I.length===0?t.jsx("tr",{children:t.jsxs("td",{colSpan:D?6:5,className:"text-center py-8 text-gray-500 dark:text-gray-400",children:["No checklist items. ",D&&'Enter a template name above or click "Add Row" to add items.']})}):I.map((ye,J)=>t.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700/50",children:[t.jsx("td",{className:"py-3 px-3 text-sm text-gray-600 dark:text-gray-400",children:ye.idx||J+1}),t.jsx("td",{className:"py-3 px-3",children:D?t.jsx("input",{type:"text",value:ye.maintenance_name,onChange:G=>me(J,"maintenance_name",G.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"}):t.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:ye.maintenance_name})}),t.jsx("td",{className:"py-3 px-3 text-center",children:t.jsx("input",{type:"checkbox",checked:!!ye.working,onChange:G=>me(J,"working",G.target.checked?1:0),disabled:!D,className:"w-5 h-5 text-green-600 rounded focus:ring-2 focus:ring-green-500 cursor-pointer disabled:cursor-default"})}),t.jsx("td",{className:"py-3 px-3 text-center",children:t.jsx("input",{type:"checkbox",checked:!!ye.defect_found,onChange:G=>me(J,"defect_found",G.target.checked?1:0),disabled:!D,className:"w-5 h-5 text-yellow-600 rounded focus:ring-2 focus:ring-yellow-500 cursor-pointer disabled:cursor-default"})}),t.jsx("td",{className:"py-3 px-3 text-center",children:t.jsx("input",{type:"checkbox",checked:!!ye.not_working,onChange:G=>me(J,"not_working",G.target.checked?1:0),disabled:!D,className:"w-5 h-5 text-red-600 rounded focus:ring-2 focus:ring-red-500 cursor-pointer disabled:cursor-default"})}),D&&t.jsx("td",{className:"py-3 px-3 text-center",children:t.jsx("button",{type:"button",onClick:()=>ae(J),className:"text-red-500 hover:text-red-700 p-1",title:"Remove row",children:t.jsx(ma,{})})})]},ye.name||J))})]})})]})]}),t.jsxs("div",{className:"space-y-6",children:[!c&&g&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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"}),t.jsx(UI,{doctype:"Asset Maintenance Log",docname:g.name||null,workflowState:g.workflow_state,showStateInfo:!1,onActionComplete:(ye,J)=>{J&&console.log(`Action "${ye}" completed successfully`)},onStateChange:()=>{window.location.reload()}})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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&&g?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Current Status"}),t.jsx("span",{className:`inline-block px-3 py-1 rounded-full text-sm font-medium ${Oe(W.maintenance_status)}`,children:W.maintenance_status||"Planned"})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Workflow State"}),t.jsx("span",{className:`inline-block px-3 py-1 rounded-full text-sm font-medium ${fe(g.workflow_state||"Draft")}`,children:g.workflow_state||"Draft"})]}),W.custom_early_completion==="Yes"&&t.jsxs("div",{className:"p-4 bg-yellow-50 dark:bg-yellow-900/20 rounded-lg border border-yellow-200 dark:border-yellow-800",children:[t.jsx("p",{className:"text-xs text-yellow-600 dark:text-yellow-400 mb-1",children:"⚠️ Early Completion"}),t.jsx("p",{className:"text-sm text-yellow-700 dark:text-yellow-300 font-medium",children:"Completion date is before the due month"})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Due Date"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:W.due_date?new Date(W.due_date).toLocaleDateString():"Not set"}),W.due_date&&new Date(W.due_date)<new Date&&W.maintenance_status!=="Completed"&&t.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 font-semibold mt-1",children:"⚠️ Overdue"})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Completion Date"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:W.completion_date?new Date(W.completion_date).toLocaleDateString():"Not completed"})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Assigned To"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:W.assign_to_name||"Unassigned"})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"PPM Checklist"}),t.jsxs("p",{className:"text-sm text-gray-900 dark:text-white",children:[I.length," item(s)"]}),I.length>0&&t.jsxs("div",{className:"mt-2 text-xs space-y-1",children:[t.jsxs("p",{className:"text-green-600 dark:text-green-400",children:["✓ Working: ",I.filter(ye=>ye.working).length]}),t.jsxs("p",{className:"text-yellow-600 dark:text-yellow-400",children:["⚠ Defects: ",I.filter(ye=>ye.defect_found).length]}),t.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["✗ Not Working: ",I.filter(ye=>ye.not_working).length]})]})]})]}):t.jsxs("div",{className:"text-center py-8",children:[t.jsx($s,{className:"text-4xl text-gray-400 dark:text-gray-500 mx-auto mb-2"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Status information will appear after creation"})]})]}),!c&&g&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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"}),t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Created By"}),t.jsx("p",{className:"text-gray-900 dark:text-white",children:g.owner||"-"})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Created On"}),t.jsx("p",{className:"text-gray-900 dark:text-white",children:g.creation?new Date(g.creation).toLocaleString():"-"})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Modified By"}),t.jsx("p",{className:"text-gray-900 dark:text-white",children:g.modified_by||"-"})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Modified On"}),t.jsx("p",{className:"text-gray-900 dark:text-white",children:g.modified?new Date(g.modified).toLocaleString():"-"})]})]})]})]})]})})]})};class qI{getAssetMaintenances(r,a,n=20,i=0,c){return xe(this,null,function*(){const u=new URLSearchParams;r&&u.append("filters",JSON.stringify(r)),a&&a.length>0&&u.append("fields",JSON.stringify(a)),u.append("limit",n.toString()),u.append("offset",i.toString()),c&&u.append("order_by",c);const g=`${Lr.ENDPOINTS.GET_ASSET_MAINTENANCES}?${u.toString()}`;return _t.apiCall(g)})}getAssetMaintenanceDetails(r){return xe(this,null,function*(){const a=new URLSearchParams;a.append("maintenance_name",r);const n=`${Lr.ENDPOINTS.GET_ASSET_MAINTENANCE_DETAILS}?${a.toString()}`;return _t.apiCall(n)})}createAssetMaintenance(r){return xe(this,null,function*(){const a=`${Lr.ENDPOINTS.CREATE_ASSET_MAINTENANCE}`;return _t.apiCall(a,{method:"POST",body:JSON.stringify({maintenance_data:JSON.stringify(r)})})})}updateAssetMaintenance(r,a){return xe(this,null,function*(){const n=`${Lr.ENDPOINTS.UPDATE_ASSET_MAINTENANCE}`;return _t.apiCall(n,{method:"POST",body:JSON.stringify({maintenance_name:r,maintenance_data:JSON.stringify(a)})})})}deleteAssetMaintenance(r){return xe(this,null,function*(){const a=`${Lr.ENDPOINTS.DELETE_ASSET_MAINTENANCE}`;return _t.apiCall(a,{method:"POST",body:JSON.stringify({maintenance_name:r})})})}getMaintenanceTasks(r){return xe(this,null,function*(){const a=new URLSearchParams;a.append("maintenance_name",r);const n=`${Lr.ENDPOINTS.GET_MAINTENANCE_TASKS}?${a.toString()}`;return _t.apiCall(n)})}getServiceCoverage(r){return xe(this,null,function*(){const a=new URLSearchParams;a.append("maintenance_name",r);const n=`${Lr.ENDPOINTS.GET_SERVICE_COVERAGE}?${a.toString()}`;return _t.apiCall(n)})}getMaintenancesByAsset(r,a,n=20,i=0){return xe(this,null,function*(){const c=new URLSearchParams;c.append("asset_name",r),a&&c.append("filters",JSON.stringify(a)),c.append("limit",n.toString()),c.append("offset",i.toString());const u=`${Lr.ENDPOINTS.GET_MAINTENANCES_BY_ASSET}?${c.toString()}`;return _t.apiCall(u)})}getActiveServiceContracts(r,a=20,n=0){return xe(this,null,function*(){const i=new URLSearchParams;r&&i.append("filters",JSON.stringify(r)),i.append("limit",a.toString()),i.append("offset",n.toString());const c=`${Lr.ENDPOINTS.GET_ACTIVE_SERVICE_CONTRACTS}?${i.toString()}`;return _t.apiCall(c)})}}const du=new qI;function KI(e,r=20,a=0,n){const[i,c]=E.useState([]),[u,g]=E.useState(0),[y,x]=E.useState(!1),[k,N]=E.useState(!0),[C,O]=E.useState(null),[D,A]=E.useState(0),I=E.useRef(!1),z=JSON.stringify(e);E.useEffect(()=>{if(I.current&&C)return;let B=!1;return I.current=!0,xe(null,null,function*(){try{N(!0);const Z=yield du.getAssetMaintenances(e,void 0,r,a,n);B||(c(Z.asset_maintenances),g(Z.total_count),x(Z.has_more),O(null))}catch(Z){if(!B){const W=Z instanceof Error?Z.message:"Failed to fetch PPM schedules";W.includes("417")||W.includes("Expectation Failed")||W.includes("has no attribute")?O("API endpoint not deployed. Please deploy ppm_api.py to your Frappe server."):O(W),c([]),g(0),x(!1)}}finally{B||N(!1)}}),()=>{B=!0}},[z,r,a,n,D]);const U=E.useCallback(()=>{I.current=!1,A(B=>B+1)},[]);return{ppms:i,totalCount:u,hasMore:y,loading:k,error:C,refetch:U}}function JI(e){const[r,a]=E.useState(null),[n,i]=E.useState(!0),[c,u]=E.useState(null),g=E.useCallback(()=>xe(null,null,function*(){if(!e){a(null),i(!1);return}try{i(!0),u(null);const x=yield du.getAssetMaintenanceDetails(e);a(x)}catch(x){u(x instanceof Error?x.message:"Failed to fetch PPM details")}finally{i(!1)}}),[e]);E.useEffect(()=>{g()},[g]);const y=E.useCallback(()=>{g()},[g]);return{ppm:r,loading:n,error:c,refetch:y}}function Ak(){const[e,r]=E.useState(!1),[a,n]=E.useState(null),i=E.useCallback(g=>xe(null,null,function*(){try{return r(!0),n(null),yield du.createAssetMaintenance(g)}catch(y){const x=y instanceof Error?y.message:"Failed to create PPM schedule";throw n(x),y}finally{r(!1)}}),[]),c=E.useCallback((g,y)=>xe(null,null,function*(){try{return r(!0),n(null),yield du.updateAssetMaintenance(g,y)}catch(x){const k=x instanceof Error?x.message:"Failed to update PPM schedule";throw n(k),x}finally{r(!1)}}),[]),u=E.useCallback(g=>xe(null,null,function*(){try{return r(!0),n(null),yield du.deleteAssetMaintenance(g)}catch(y){const x=y instanceof Error?y.message:"Failed to delete PPM schedule";throw n(x),y}finally{r(!1)}}),[]);return{createPPM:i,updatePPM:c,deletePPM:u,loading:e,error:a}}const QI=()=>{const{t:e}=oa(),r=ua(),[a,n]=E.useState(0),[i,c]=E.useState(""),[u,g]=E.useState(""),[y,x]=E.useState(null),[k,N]=E.useState(null),C=E.useRef(null),O=20,D=u?{company:u}:{},{ppms:A,totalCount:I,hasMore:z,loading:U,error:B,refetch:V}=KI(D,O,a*O,"creation desc"),{deletePPM:Z,loading:W}=Ak();E.useEffect(()=>{const ae=me=>{C.current&&!C.current.contains(me.target)&&N(null)};return k&&document.addEventListener("mousedown",ae),()=>{document.removeEventListener("mousedown",ae)}},[k]);const H=()=>{r("/ppm/new")},le=ae=>{r(`/ppm/${ae}`)},Q=ae=>{r(`/ppm/${ae}`)},Ne=ae=>xe(null,null,function*(){try{yield Z(ae),x(null),V(),alert("PPM schedule deleted successfully!")}catch(me){alert(`Failed to delete: ${me instanceof Error?me.message:"Unknown error"}`)}}),oe=ae=>{r(`/ppm/new?duplicate=${ae}`)},se=ae=>{const me=JSON.stringify(ae,null,2),K=new Blob([me],{type:"application/json"}),fe=URL.createObjectURL(K),Oe=document.createElement("a");Oe.href=fe,Oe.download=`ppm_${ae.name}.json`,Oe.click(),URL.revokeObjectURL(fe)},ce=()=>{const me=[["PPM ID","Company","Asset","Asset Type","Frequency","No. of PMs","Total Amount"].join(","),...A.map(ye=>[ye.name,ye.company||"",ye.asset_name||"",ye.custom_asset_type||"",ye.custom_frequency||"",ye.custom_no_of_pms||"",ye.custom_total_amount||""].join(","))].join(`
|
||
`),K=new Blob([me],{type:"text/csv"}),fe=URL.createObjectURL(K),Oe=document.createElement("a");Oe.href=fe,Oe.download=`ppm_schedules_${new Date().toISOString().split("T")[0]}.csv`,Oe.click(),URL.revokeObjectURL(fe)};if(U&&a===0)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:e("listPages.loading")})]})});if(B)return t.jsx("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:t.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-yellow-800 dark:text-yellow-300 mb-4",children:"⚠️ PPM API Not Available"}),t.jsxs("div",{className:"text-yellow-700 dark:text-yellow-400 space-y-3",children:[t.jsx("p",{children:t.jsx("strong",{children:"The PPM API endpoint is not deployed yet."})}),t.jsxs("div",{className:"mt-4 flex gap-3",children:[t.jsx("button",{onClick:()=>r("/ppm/new"),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:"Try Creating New (Demo)"}),t.jsx("button",{onClick:V,className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded",children:"Try Again"})]})]}),t.jsx("div",{className:"mt-4 p-4 bg-white dark:bg-gray-800 rounded border border-yellow-300 dark:border-yellow-700",children:t.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[t.jsx("strong",{children:"Technical Error:"})," ",B]})})]})});const Ce=A.filter(ae=>{var me,K,fe,Oe;return((me=ae.name)==null?void 0:me.toLowerCase().includes(i.toLowerCase()))||((K=ae.asset_name)==null?void 0:K.toLowerCase().includes(i.toLowerCase()))||((fe=ae.company)==null?void 0:fe.toLowerCase().includes(i.toLowerCase()))||((Oe=ae.custom_asset_type)==null?void 0:Oe.toLowerCase().includes(i.toLowerCase()))});return t.jsxs("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-gray-800 dark:text-white break-words",children:e("ppm.title")}),t.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:["Total: ",I," PPM schedule",I!==1?"s":""]})]}),t.jsxs("div",{className:"flex gap-3",children:[t.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:A.length===0,children:[t.jsx(cs,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")})]}),t.jsxs("button",{onClick:H,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:[t.jsx(Mi,{}),t.jsx("span",{className:"font-medium",children:e("ppm.addPPM")})]})]})]}),t.jsxs("div",{className:"mb-6 grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:t.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:[t.jsx(_o,{className:"text-gray-400 dark:text-gray-500"}),t.jsx("input",{type:"text",placeholder:"Search by ID, asset, company...",value:i,onChange:ae=>c(ae.target.value),className:"flex-1 outline-none text-gray-700 dark:text-gray-200 bg-transparent"})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:t.jsx("input",{type:"text",placeholder:"Filter by Company",value:u,onChange:ae=>{g(ae.target.value),n(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"})})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden",children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"PPM ID"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Company"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Asset"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Asset Type"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Frequency"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"No. of PMs"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Total Amount"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Actions"})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:Ce.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(_o,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:"No PPM schedules found"}),t.jsx("button",{onClick:H,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:"Create your first PPM schedule"})]})})}):Ce.map(ae=>t.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors cursor-pointer",onClick:()=>le(ae.name),children:[t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:ae.name})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(kf,{className:"text-gray-400"}),t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:ae.company||"-"})]})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:ae.asset_name||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:ae.custom_asset_type||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Nw,{className:"text-blue-500"}),t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:ae.custom_frequency||"-"})]})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:ae.custom_no_of_pms||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:ae.custom_total_amount?`$${ae.custom_total_amount.toLocaleString()}`:"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:t.jsxs("div",{className:"relative",onClick:me=>me.stopPropagation(),children:[t.jsx("button",{onClick:()=>N(k===ae.name?null:ae.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:t.jsx(Eu,{})}),k===ae.name&&t.jsxs("div",{ref:C,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:[t.jsxs("button",{onClick:()=>{le(ae.name),N(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:[t.jsx(to,{}),"View"]}),t.jsxs("button",{onClick:()=>{Q(ae.name),N(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:[t.jsx(Yn,{}),"Edit"]}),t.jsxs("button",{onClick:()=>{oe(ae.name),N(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:[t.jsx(Zd,{}),"Duplicate"]}),t.jsxs("button",{onClick:()=>{se(ae),N(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:[t.jsx(cs,{}),"Export"]}),t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700"}),t.jsxs("button",{onClick:()=>{x(ae.name),N(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:[t.jsx(ma,{}),"Delete"]})]})]})})]},ae.name))})]})}),(z||a>0)&&t.jsxs("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[t.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Showing ",a*O+1," to ",Math.min((a+1)*O,I)," of ",I," results"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>n(Math.max(0,a-1)),disabled:a===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:"Previous"}),t.jsx("button",{onClick:()=>n(a+1),disabled:!z,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:"Next"})]})]})]}),y&&t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4",children:[t.jsx("h3",{className:"text-lg font-bold text-gray-900 dark:text-white mb-4",children:"Confirm Delete"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:"Are you sure you want to delete this PPM schedule? This action cannot be undone."}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>x(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:"Cancel"}),t.jsx("button",{onClick:()=>Ne(y),disabled:W,className:"px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 disabled:opacity-50",children:W?"Deleting...":"Delete"})]})]})})]})},eP=()=>{const{ppmName:e}=Yl(),r=ua(),[a]=Li(),n=a.get("duplicate"),i=e==="new",c=i&&!!n,{ppm:u,loading:g,error:y,refetch:x}=JI(c?n:i?null:e||null),{createPPM:k,updatePPM:N,loading:C}=Ak(),[O,D]=E.useState(i),[A,I]=E.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});Kl(I,{enabled:i&&!c,fields:["company"]}),E.useEffect(()=>{u&&I({company:u.company||"",asset_name:u.asset_name||"",custom_asset_type:u.custom_asset_type||"",maintenance_team:u.maintenance_team||"",custom_frequency:u.custom_frequency||"",custom_total_amount:u.custom_total_amount||0,custom_no_of_pms:u.custom_no_of_pms||0,custom_price_per_pm:u.custom_price_per_pm||0})},[u,c]);const z=B=>{const{name:V,value:Z}=B.target;I(W=>$e(_e({},W),{[V]:V.includes("amount")||V.includes("pms")||V.includes("price")?parseFloat(Z)||0:Z}))},U=B=>xe(null,null,function*(){var V;if(B.preventDefault(),!A.asset_name){alert("Please enter Asset Name");return}try{if(i||c){const Z=yield k(A);alert(c?"PPM schedule duplicated successfully!":"PPM schedule created successfully!"),(V=Z.asset_maintenance)!=null&&V.name?r(`/ppm/${Z.asset_maintenance.name}`):(x(),r("/ppm"))}else e&&(yield N(e,A),alert("PPM schedule updated successfully!"),D(!1),x())}catch(Z){console.error("PPM save error:",Z),alert("Failed to save: "+(Z instanceof Error?Z.message:"Unknown error"))}});return g?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading PPM schedule..."})]})}):y&&!i&&!c?t.jsx("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[t.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["Error: ",y]}),t.jsx("button",{onClick:()=>r("/ppm"),className:"mt-2 text-red-700 dark:text-red-400 underline hover:text-red-800 dark:hover:text-red-300",children:"Back to PPM schedules"})]})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-4 sm:p-6 min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center flex-wrap",children:[t.jsx("div",{className:"flex items-center gap-4",children:t.jsxs("button",{onClick:()=>r("/ppm"),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[t.jsx(bi,{}),t.jsx("span",{className:"text-gray-900 dark:text-white",children:c?"Duplicate PPM Schedule":i?"New PPM Schedule":"PPM Schedule Details"})]})}),t.jsx("div",{className:"flex items-center gap-3",children:!i&&!O&&t.jsxs("button",{onClick:()=>D(!0),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(Yn,{}),"Edit"]})})]}),t.jsxs("form",{onSubmit:U,children:[t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6",children:[t.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white mb-4",children:"Basic Information"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Company *"}),O?t.jsx("input",{type:"text",name:"company",value:A.company,onChange:z,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}):t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-gray-900 dark:text-white",children:(u==null?void 0:u.company)||"-"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Asset Name *"}),O?t.jsx("input",{type:"text",name:"asset_name",value:A.asset_name,onChange:z,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}):t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-gray-900 dark:text-white",children:(u==null?void 0:u.asset_name)||"-"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Asset Type"}),O?t.jsx("input",{type:"text",name:"custom_asset_type",value:A.custom_asset_type,onChange:z,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"}):t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-gray-900 dark:text-white",children:(u==null?void 0:u.custom_asset_type)||"-"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Maintenance Team"}),O?t.jsx("input",{type:"text",name:"maintenance_team",value:A.maintenance_team,onChange:z,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"}):t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-gray-900 dark:text-white",children:(u==null?void 0:u.maintenance_team)||"-"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Frequency"}),O?t.jsx("input",{type:"text",name:"custom_frequency",value:A.custom_frequency,onChange:z,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:"e.g., Monthly, Quarterly, Yearly"}):t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-gray-900 dark:text-white",children:(u==null?void 0:u.custom_frequency)||"-"})})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6",children:[t.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white mb-4",children:"Financial Information"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Number of PMs"}),O?t.jsx("input",{type:"number",name:"custom_no_of_pms",value:A.custom_no_of_pms,onChange:z,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"}):t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-gray-900 dark:text-white",children:(u==null?void 0:u.custom_no_of_pms)||"-"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Price per PM"}),O?t.jsx("input",{type:"number",name:"custom_price_per_pm",value:A.custom_price_per_pm,onChange:z,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"}):t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-gray-900 dark:text-white",children:u!=null&&u.custom_price_per_pm?`$${u.custom_price_per_pm.toLocaleString()}`:"-"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Total Amount"}),O?t.jsx("input",{type:"number",name:"custom_total_amount",value:A.custom_total_amount,onChange:z,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"}):t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-gray-900 dark:text-white font-semibold",children:u!=null&&u.custom_total_amount?`$${u.custom_total_amount.toLocaleString()}`:"-"})})]})]})]})]}),t.jsx("div",{className:"lg:col-span-1",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6 space-y-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:"Schedule Information"}),!i&&u&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"PPM ID"}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:u.name})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Created"}),t.jsx("p",{className:"text-xs text-gray-900 dark:text-white",children:u.creation?new Date(u.creation).toLocaleString():"-"})]})]}),i&&t.jsxs("div",{className:"text-center py-8",children:[t.jsx(Aw,{className:"text-4xl text-gray-400 dark:text-gray-500 mx-auto mb-2"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Schedule information will appear after creation"})]})]})})]}),O&&t.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[t.jsx("button",{type:"button",onClick:()=>{i?r("/ppm"):(D(!1),u&&I({company:u.company||"",asset_name:u.asset_name||"",custom_asset_type:u.custom_asset_type||"",maintenance_team:u.maintenance_team||"",custom_frequency:u.custom_frequency||"",custom_total_amount:u.custom_total_amount||0,custom_no_of_pms:u.custom_no_of_pms||0,custom_price_per_pm:u.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:"Cancel"}),t.jsxs("button",{type:"submit",disabled:C,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:[t.jsx(Fn,{}),C?"Saving...":i?"Create":"Save Changes"]})]})]})]})};class tP{submitDocument(r,a){return xe(this,null,function*(){try{const n=yield this.fetchWithTimeout(`${Lr.BASE_URL}/api/resource/PM Schedule Generator/${encodeURIComponent(r)}`,{method:"GET",headers:{Accept:"application/json"},credentials:"include"},3e4);if(!n.ok){const g=yield n.text();console.warn("Failed to fetch document for submit:",g);return}const c=(yield n.json()).data;if(!c){console.warn("No document data received");return}const u=yield this.fetchWithTimeout(`${Lr.BASE_URL}/api/method/frappe.client.submit`,{method:"POST",headers:a,credentials:"include",body:JSON.stringify({doc:c})},6e4);if(u.ok)console.log("✅ Document submitted successfully");else{const g=yield u.text();console.warn("Failed to submit document:",g)}}catch(n){console.warn("Error submitting document:",n.message)}})}fetchWithTimeout(r,a,n=12e4){return xe(this,null,function*(){var u,g;const i=new AbortController,c=setTimeout(()=>i.abort(),n);try{const y=yield fetch(r,$e(_e({},a),{signal:i.signal}));return clearTimeout(c),y}catch(y){throw clearTimeout(c),y.name==="AbortError"?new Error(`Request timeout after ${n}ms. The server may be slow or the request is too large.`):(u=y.message)!=null&&u.includes("Failed to fetch")||(g=y.message)!=null&&g.includes("ERR_CONNECTION_TIMED_OUT")?new Error(`Connection timeout. Please check:
|
||
1. Your internet connection
|
||
2. Server is accessible
|
||
3. Try with fewer assets`):y}})}getFilteredAssets(r){return xe(this,null,function*(){const a=[];r.modality&&a.push(["custom_modality","=",r.modality]),r.asset_type&&a.push(["custom_asset_type","=",r.asset_type]),r.department&&a.push(["department","=",r.department]),r.location&&a.push(["location","=",r.location]),r.manufacturer&&a.push(["custom_manufacturer","=",r.manufacturer]),r.model&&a.push(["custom_model","=",r.model]);const n=JSON.stringify(a),i=JSON.stringify(["name","asset_name","custom_asset_type","department","location","custom_manufacturer","custom_model","custom_modality","company"]),c=yield _t.apiCall(`/api/resource/Asset?filters=${encodeURIComponent(n)}&fields=${encodeURIComponent(i)}&limit_page_length=1000`);return(c==null?void 0:c.data)||[]})}createBulkMaintenanceSchedules(r){return xe(this,null,function*(){var c,g,y,x,k,N;if(!r.hospital)throw new Error("Hospital/Company is required to create PM Schedule Generator");if(!r.periodicity)throw new Error("Periodicity is required");if(r.assets.length===0)throw new Error("At least one asset must be selected");r.assets.length>50&&console.warn(`Creating schedules for ${r.assets.length} assets. This may take a while...`);const a={doctype:"PM Schedule Generator",hospital:r.hospital,start_date:r.start_date,end_date:r.end_date,periodicity:r.periodicity,pm_for:r.pm_for||null,no_of_pms:r.no_of_pms||null,maintenance_team:r.maintenance_team||null,maintenance_manager:r.maintenance_manager||null,assign_to:r.assign_to||null,modality:r.modality||null,manufacturer:r.manufacturer||null,model:r.model||null,department:r.department||null,maintenance_entries:r.assets.map(C=>({doctype:"PM Entry Line",asset:C.name,start_date:r.start_date,end_date:r.end_date,manufacturer:C.custom_manufacturer||null,model:C.custom_model||null}))};console.log("Creating PM Schedule Generator with document:",JSON.stringify(a,null,2));const n=yield _t.getCSRFToken(),i={"Content-Type":"application/json",Accept:"application/json"};n&&(i["X-Frappe-CSRF-Token"]=n);try{const C=yield this.fetchWithTimeout(`${Lr.BASE_URL}/api/method/frappe.client.insert`,{method:"POST",headers:i,credentials:"include",body:JSON.stringify({doc:a})},12e4),O=yield C.text();if(console.log("frappe.client.insert response:",O),!C.ok)throw new Error(`HTTP ${C.status}: ${O}`);const D=JSON.parse(O),A=(c=D==null?void 0:D.message)==null?void 0:c.name;if(A)return console.log("✅ PM Schedule Generator created successfully:",A),yield this.submitDocument(A,i),{success:!0,created:r.assets.length,document:A,message:`PM Schedule Generator "${A}" created and submitted with ${r.assets.length} assets`};throw new Error("No document name in response")}catch(C){console.warn("Method 1 (frappe.client.insert) failed:",C.message);try{const u=a,{doctype:O,maintenance_entries:D}=u,A=Gs(u,["doctype","maintenance_entries"]),I=$e(_e({},A),{maintenance_entries:D.map(H=>{var le=H,{doctype:Z}=le,W=Gs(le,["doctype"]);return W})});console.log("Trying Resource API with:",JSON.stringify(I,null,2));const z=yield this.fetchWithTimeout(`${Lr.BASE_URL}/api/resource/PM%20Schedule%20Generator`,{method:"POST",headers:i,credentials:"include",body:JSON.stringify(I)},12e4),U=yield z.text();if(console.log("Resource API response:",U),!z.ok)throw new Error(`HTTP ${z.status}: ${U}`);const B=JSON.parse(U),V=(g=B==null?void 0:B.data)==null?void 0:g.name;if(V)return console.log("✅ PM Schedule Generator created via Resource API:",V),yield this.submitDocument(V,i),{success:!0,created:r.assets.length,document:V,message:`PM Schedule Generator "${V}" created and submitted with ${r.assets.length} assets`};throw new Error("No document name in response")}catch(O){console.warn("Method 2 (Resource API) failed:",O.message);const D=[];throw(((y=C==null?void 0:C.message)==null?void 0:y.includes("timeout"))||((x=C==null?void 0:C.message)==null?void 0:x.includes("Failed to fetch")))&&(((k=O==null?void 0:O.message)==null?void 0:k.includes("timeout"))||((N=O==null?void 0:O.message)==null?void 0:N.includes("Failed to fetch")))?D.push(`⚠️ Connection timeout detected. This usually means:
|
||
• The server is taking too long to process ${r.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`):(D.push("Failed to create PM Schedule Generator. Errors:"),C!=null&&C.message&&D.push(`• frappe.client.insert: ${C.message.substring(0,150)}`),O!=null&&O.message&&D.push(`• Resource API: ${O.message.substring(0,150)}`),D.push(`
|
||
Please ensure:
|
||
1. Hospital (${r.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.
|
||
|
||
${D.join(`
|
||
`)}`)}}})}getFilterOptions(){return xe(this,null,function*(){try{const r=yield _t.apiCall(`/api/resource/Asset?fields=${encodeURIComponent(JSON.stringify(["custom_modality","custom_asset_type","department","location","custom_manufacturer","custom_model"]))}&limit_page_length=1000`),a=(r==null?void 0:r.data)||[];return{modalities:[...new Set(a.map(i=>i.custom_modality).filter(Boolean))],assetTypes:[...new Set(a.map(i=>i.custom_asset_type).filter(Boolean))],departments:[...new Set(a.map(i=>i.department).filter(Boolean))],locations:[...new Set(a.map(i=>i.location).filter(Boolean))],manufacturers:[...new Set(a.map(i=>i.custom_manufacturer).filter(Boolean))],models:[...new Set(a.map(i=>i.custom_model).filter(Boolean))],company:[...new Set(a.map(i=>i.company).filter(Boolean))]}}catch(r){return console.error("Error fetching filter options:",r),{modalities:[],assetTypes:[],departments:[],locations:[],manufacturers:[],models:[],company:[]}}})}getMaintenanceTeams(){return xe(this,null,function*(){try{const r=yield _t.apiCall(`/api/resource/Asset Maintenance Team?fields=${encodeURIComponent(JSON.stringify(["name"]))}&limit_page_length=1000`);return r!=null&&r.data&&r.data.length>0?r.data.map(a=>({name:a.name,maintenance_team_name:a.name})):[]}catch(r){return console.warn("Could not fetch maintenance teams:",(r==null?void 0:r.message)||"Unknown error"),[]}})}getMaintenanceTeamDetails(r){return xe(this,null,function*(){try{const a=yield _t.apiCall(`/api/resource/Asset Maintenance Team/${encodeURIComponent(r)}`);if(a!=null&&a.data){const n=a.data,i=[];return n.maintenance_team_members&&Array.isArray(n.maintenance_team_members)&&n.maintenance_team_members.forEach(c=>{c.team_member&&i.push(c.team_member)}),{name:n.name,maintenance_manager:n.maintenance_manager||void 0,team_members:i.length>0?i:void 0}}return null}catch(a){return console.warn("Could not fetch maintenance team details:",(a==null?void 0:a.message)||"Unknown error"),null}})}}const of=new tP,rP=()=>{const{t:e}=oa(),r=ua(),[a,n]=E.useState({}),[i,c]=E.useState([]),[u,g]=E.useState({start_date:"",end_date:"",maintenance_team:"",assign_to:"",pm_for:"",maintenance_manager:"",periodicity:"Monthly",maintenance_type:"Preventive",no_of_pms:"",department:""}),[y,x]=E.useState(!1),[k,N]=E.useState(!1),[C,O]=E.useState([]),[D,A]=E.useState({modalities:[],assetTypes:[],departments:[],locations:[],manufacturers:[],models:[],company:[]}),[I,z]=E.useState([]),[U,B]=E.useState(""),[V,Z]=E.useState(null);E.useEffect(()=>{H(),le()},[]);const W=(K,fe,Oe)=>{if(!K||!fe||!Oe)return null;const ye=parseInt(Oe,10);if(isNaN(ye)||ye<1)return null;const J=ye-1;if(J<0)return null;const G=new Date(K),ie=new Date(G);switch(fe){case"Daily":ie.setDate(ie.getDate()+J);break;case"Weekly":ie.setDate(ie.getDate()+J*7);break;case"Monthly":ie.setMonth(ie.getMonth()+J);break;case"Quarterly":ie.setMonth(ie.getMonth()+J*3);break;case"Half-yearly":ie.setMonth(ie.getMonth()+J*6);break;case"Yearly":ie.setFullYear(ie.getFullYear()+J);break;case"2 Yearly":ie.setFullYear(ie.getFullYear()+J*2);break;case"3 Yearly":ie.setFullYear(ie.getFullYear()+J*3);break;default:return null}const re=ie.getFullYear(),ne=String(ie.getMonth()+1).padStart(2,"0"),ve=String(ie.getDate()).padStart(2,"0");return`${re}-${ne}-${ve}`};E.useEffect(()=>{xe(null,null,function*(){if(u.maintenance_team){const fe=yield of.getMaintenanceTeamDetails(u.maintenance_team);fe&&g(Oe=>$e(_e({},Oe),{maintenance_manager:fe.maintenance_manager||"",assign_to:fe.team_members&&fe.team_members.length===1?fe.team_members[0]:Oe.assign_to}))}else g(fe=>$e(_e({},fe),{maintenance_manager:"",assign_to:""}))})},[u.maintenance_team]),E.useEffect(()=>{if(u.start_date&&u.periodicity&&u.no_of_pms){const K=W(u.start_date,u.periodicity,u.no_of_pms);K&&g(fe=>$e(_e({},fe),{end_date:K}))}},[u.start_date,u.periodicity,u.no_of_pms]);const H=()=>xe(null,null,function*(){const K=yield of.getFilterOptions();A(K)}),le=()=>xe(null,null,function*(){const K=yield of.getMaintenanceTeams();z(K)}),Q=()=>xe(null,null,function*(){N(!0);try{const K=new URLSearchParams;a.company&&K.append("company",a.company),a.custom_modality&&K.append("custom_modality",a.custom_modality),a.custom_manufacturer&&K.append("custom_manufacturer",a.custom_manufacturer),a.custom_device_status&&K.append("custom_device_status",a.custom_device_status),a.custom_model&&K.append("custom_model",a.custom_model),a.department&&K.append("department",a.department);const fe=yield fetch(`/api/method/get_assets?${K.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!fe.ok)throw new Error(`HTTP error! status: ${fe.status}`);const ye=(yield fe.json()).message||[];O(ye),c([])}catch(K){console.error("Error fetching assets:",K),alert("Failed to fetch assets: "+(K instanceof Error?K.message:"Unknown error"))}finally{N(!1)}}),Ne=(K,fe)=>{n(Oe=>$e(_e({},Oe),{[K]:fe||void 0}))},oe=K=>{c(fe=>fe.includes(K)?fe.filter(Oe=>Oe!==K):[...fe,K])},se=()=>{const K=ce();i.length===K.length&&K.length>0?c([]):c(K.map(fe=>fe.name))},ce=()=>{if(!U)return C;const K=U.toLowerCase();return C.filter(fe=>{var Oe,ye,J,G,ie,re;return((Oe=fe.asset_name)==null?void 0:Oe.toLowerCase().includes(K))||((ye=fe.custom_modality)==null?void 0:ye.toLowerCase().includes(K))||((J=fe.company)==null?void 0:J.toLowerCase().includes(K))||((G=fe.custom_manufacturer)==null?void 0:G.toLowerCase().includes(K))||((ie=fe.custom_model)==null?void 0:ie.toLowerCase().includes(K))||((re=fe.custom_device_status)==null?void 0:re.toLowerCase().includes(K))})},Ce=()=>xe(null,null,function*(){if(i.length===0){alert("Please select at least one asset");return}if(!a.company){alert("Please select a Hospital/Company in the filters first");return}if(!u.pm_for){alert("Please enter a PM Name");return}if(!u.start_date||!u.end_date){alert("Please select start and end dates");return}if(new Date(u.start_date)>new Date(u.end_date)){alert("Start date must be before end date");return}if(!u.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)?`)){x(!0);try{const fe=C.filter(J=>i.includes(J.name)).map(J=>({name:J.name,custom_manufacturer:J.custom_manufacturer,custom_model:J.custom_model})),Oe={assets:fe,start_date:u.start_date,end_date:u.end_date,maintenance_team:u.maintenance_team||void 0,assign_to:u.assign_to||void 0,maintenance_manager:u.maintenance_manager||void 0,periodicity:u.periodicity,maintenance_type:u.maintenance_type,no_of_pms:u.no_of_pms||void 0,pm_for:u.pm_for||void 0,hospital:a.company,modality:a.custom_modality,manufacturer:a.custom_manufacturer,model:a.custom_model,department:u.department||a.department||void 0};console.log("=== DEBUG: Selected Asset Details ===",fe),console.log("=== DEBUG: bulkData ===",Oe);const ye=yield of.createBulkMaintenanceSchedules(Oe);Z({show:!0,document:ye.document,count:ye.created||i.length,type:"pm_schedule"}),c([]),g({start_date:"",end_date:"",maintenance_team:"",assign_to:"",pm_for:"",maintenance_manager:"",periodicity:"Monthly",maintenance_type:"Preventive",no_of_pms:"",department:""})}catch(fe){console.error("Error creating schedules:",fe);const Oe=fe instanceof Error?fe.message:"Unknown error";alert(`Failed to create maintenance schedules:
|
||
|
||
${Oe}`)}finally{x(!1)}}}),ae=ce(),me=Object.values(a).some(K=>K);return t.jsxs("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:[t.jsxs("div",{className:"mb-6 flex items-center gap-4",children:[t.jsxs("button",{onClick:()=>r("/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:[t.jsx(bi,{}),t.jsx("span",{children:"Back to PPM Planner"})]}),t.jsx("h1",{className:"text-3xl font-bold text-gray-800 dark:text-white",children:"PPM Planner - Bulk Schedule Generator"})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6 mb-6",children:[t.jsxs("h2",{className:"text-xl font-semibold mb-4 flex items-center gap-2 text-gray-800 dark:text-white",children:[t.jsx(Ri,{})," Filter Assets"]}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[t.jsx("div",{children:t.jsx(er,{label:"Hospital/Company *",doctype:"Company",value:a.company||"",onChange:K=>Ne("company",K),placeholder:"Select a hospital/company"})}),t.jsx("div",{children:t.jsx(er,{label:"Modality",doctype:"Modality",value:a.custom_modality||"",onChange:K=>Ne("custom_modality",K),placeholder:"Leave empty for all modalities"})}),t.jsx("div",{children:t.jsx(er,{label:"Manufacturer",doctype:"Manufacturer",value:a.custom_manufacturer||"",onChange:K=>Ne("custom_manufacturer",K),placeholder:"Leave empty for all manufacturers"})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Device Status"}),t.jsxs("select",{value:a.custom_device_status||"",onChange:K=>Ne("custom_device_status",K.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:[t.jsx("option",{value:"",children:"All Statuses"}),t.jsx("option",{value:"Up",children:"Up"}),t.jsx("option",{value:"Down",children:"Down"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Model"}),t.jsxs("select",{value:a.custom_model||"",onChange:K=>Ne("custom_model",K.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:[t.jsx("option",{value:"",children:"Select Model (optional)"}),D.models.map(K=>t.jsx("option",{value:K,children:K},K))]})]}),t.jsx("div",{children:t.jsx(er,{label:"Department",doctype:"Department",value:a.department||"",onChange:K=>Ne("department",K),placeholder:"Select department (optional)"})})]}),t.jsxs("div",{className:"mt-4 flex gap-3",children:[t.jsx("button",{onClick:Q,disabled:k,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:k?t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"animate-spin"}),"Loading..."]}):t.jsxs(t.Fragment,{children:[t.jsx(_o,{}),"Fetch Assets"]})}),me&&t.jsx("button",{onClick:()=>{n({}),O([]),c([])},className:"bg-gray-600 hover:bg-gray-700 text-white px-6 py-2 rounded-lg",children:"Clear Filters"})]})]}),C.length>0&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6 mb-6",children:[t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[t.jsxs("h2",{className:"text-xl font-semibold text-gray-800 dark:text-white",children:["Select Assets (",i.length," of ",C.length," selected)"]}),t.jsxs("div",{className:"flex gap-3 items-center",children:[t.jsxs("div",{className:"relative",children:[t.jsx(_o,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"}),t.jsx("input",{type:"text",placeholder:"Search assets...",value:U,onChange:K=>B(K.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"})]}),t.jsx("button",{onClick:se,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===ae.length&&ae.length>0?"Deselect All":"Select All"})]})]}),t.jsx("div",{className:"max-h-96 overflow-y-auto border border-gray-200 dark:border-gray-700 rounded-lg",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 sticky top-0",children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:t.jsx("input",{type:"checkbox",checked:i.length===ae.length&&ae.length>0,onChange:se,className:"rounded"})}),t.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Asset Name"}),t.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Modality"}),t.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Manufacturer"}),t.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Model"}),t.jsx("th",{className:"text-left p-3 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Status"})]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:ae.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"p-6 text-center text-gray-500 dark:text-gray-400",children:"No assets match your search criteria"})}):ae.map(K=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors ${i.includes(K.name)?"bg-blue-50 dark:bg-blue-900/20":""}`,children:[t.jsx("td",{className:"p-3",children:t.jsx("input",{type:"checkbox",checked:i.includes(K.name),onChange:()=>oe(K.name),className:"rounded"})}),t.jsx("td",{className:"p-3 text-sm text-gray-900 dark:text-white font-medium",children:K.asset_name}),t.jsx("td",{className:"p-3 text-sm text-gray-700 dark:text-gray-300",children:K.custom_modality||"-"}),t.jsx("td",{className:"p-3 text-sm text-gray-700 dark:text-gray-300",children:K.custom_manufacturer||"-"}),t.jsx("td",{className:"p-3 text-sm text-gray-700 dark:text-gray-300",children:K.custom_model||"-"}),t.jsx("td",{className:"p-3 text-sm",children:t.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${K.custom_device_status==="Active"?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":K.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:K.custom_device_status||"-"})})]},K.name))})]})})]}),i.length>0&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6 mb-6",children:[t.jsxs("h2",{className:"text-xl font-semibold mb-4 flex items-center gap-2 text-gray-800 dark:text-white",children:[t.jsx(df,{})," Schedule Configuration"]}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"PPM Name *"}),t.jsx("input",{type:"text",value:u.pm_for,onChange:K=>g(fe=>$e(_e({},fe),{pm_for:K.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})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"First PPM Date *"}),t.jsx("input",{type:"date",value:u.start_date,onChange:K=>g(fe=>$e(_e({},fe),{start_date:K.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})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Periodicity *"}),t.jsxs("select",{value:u.periodicity,onChange:K=>g(fe=>$e(_e({},fe),{periodicity:K.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:[t.jsx("option",{value:"Daily",children:"Daily"}),t.jsx("option",{value:"Weekly",children:"Weekly"}),t.jsx("option",{value:"Monthly",children:"Monthly"}),t.jsx("option",{value:"Quarterly",children:"Quarterly"}),t.jsx("option",{value:"Half-yearly",children:"Half-yearly"}),t.jsx("option",{value:"Yearly",children:"Yearly"}),t.jsx("option",{value:"2 Yearly",children:"2 Yearly"}),t.jsx("option",{value:"3 Yearly",children:"3 Yearly"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Maintenance Type"}),t.jsxs("select",{value:u.maintenance_type,onChange:K=>g(fe=>$e(_e({},fe),{maintenance_type:K.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:[t.jsx("option",{value:"Preventive",children:"Preventive"}),t.jsx("option",{value:"Corrective",children:"Corrective"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"No. of PMs"}),t.jsx("input",{type:"number",value:u.no_of_pms,onChange:K=>g(fe=>$e(_e({},fe),{no_of_pms:K.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"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"End date will be auto-calculated"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium mb-2 text-gray-700 dark:text-gray-300",children:"Last PPM Date *"}),t.jsx("input",{type:"date",value:u.end_date,onChange:K=>g(fe=>$e(_e({},fe),{end_date:K.target.value})),min:u.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})]}),t.jsxs("div",{children:[t.jsx(er,{label:"Maintenance Team",doctype:"Asset Maintenance Team",value:u.maintenance_team,onChange:K=>g(fe=>$e(_e({},fe),{maintenance_team:K}))}),u.maintenance_manager&&t.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:[t.jsx("span",{className:"font-medium",children:"Maintenance Manager:"})," ",u.maintenance_manager]})]}),t.jsxs("div",{children:[t.jsx(er,{label:"Assign To *",doctype:"User",value:u.assign_to,onChange:K=>g(fe=>$e(_e({},fe),{assign_to:K})),placeholder:u.maintenance_team?"Select user (auto-selected if only one team member)":"Select user to assign tasks"}),t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"Required for Asset Maintenance creation"}),u.assign_to&&t.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:[t.jsx("span",{className:"font-medium",children:"Assigned To:"})," ",u.assign_to]})]}),t.jsx("div",{children:t.jsx(er,{label:"Department",doctype:"Department",value:u.department,onChange:K=>g(fe=>$e(_e({},fe),{department:K})),placeholder:"Select department (optional)"})})]}),t.jsx("button",{onClick:Ce,disabled:y||!u.start_date||!u.end_date||!u.pm_for||!u.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:y?t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"animate-spin"}),"Creating Schedules..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Ca,{}),"Generate Maintenance Schedules (",i.length," asset",i.length!==1?"s":"",")"]})})]}),C.length===0&&!k&&!(V!=null&&V.show)&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-12 text-center",children:[t.jsx(Ri,{className:"mx-auto text-4xl text-gray-400 dark:text-gray-600 mb-4"}),t.jsx("h3",{className:"text-lg font-semibold text-gray-700 dark:text-gray-300 mb-2",children:"No Assets Loaded"}),t.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.'}),t.jsx("p",{className:"text-sm text-blue-600 dark:text-blue-400",children:"Note: Only submitted assets without existing maintenance schedules will be shown."})]}),(V==null?void 0:V.show)&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl max-w-lg w-full p-6",children:[t.jsxs("div",{className:"text-center mb-6",children:[t.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:t.jsx(Ca,{className:"text-green-600 dark:text-green-400 text-3xl"})}),t.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:"Schedules Created Successfully!"}),t.jsxs("p",{className:"text-gray-600 dark:text-gray-400",children:[V.count," maintenance schedule",V.count!==1?"s":""," have been created."]})]}),t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 rounded-lg p-4 mb-6",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"What was created:"}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Document:"}),t.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-400",children:V.document})]}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["A PM Schedule Generator document has been created with ",V.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."]})]})]}),t.jsxs("div",{className:"flex flex-col gap-3",children:[V.document&&t.jsxs("button",{onClick:()=>{r(`/ppm-planner/${V.document}`),Z(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:[t.jsx(df,{}),"View PPM Planner"]}),t.jsxs("button",{onClick:()=>r("/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:[t.jsx(df,{}),"View Calendar"]}),t.jsx("button",{onClick:()=>Z(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 i1(e={},r=20,a=0,n="creation desc",i={}){const[c,u]=E.useState([]),[g,y]=E.useState(0),[x,k]=E.useState(!1),[N,C]=E.useState(!0),[O,D]=E.useState(null),[A,I]=E.useState(0),z=JSON.stringify(e),U=JSON.stringify(i);E.useEffect(()=>{let V=!1;const Z=z,W=U,H=r,le=a,Q=n;return xe(null,null,function*(){try{C(!0),D(null);let oe={},se={};try{oe=Z?JSON.parse(Z):{}}catch(ae){oe={}}try{se=W?JSON.parse(W):{}}catch(ae){se={}}const ce=_e(_e({},oe),se),Ce=yield _t.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:H,offset:le,order_by:Q,include_child_tables:!0,fields:JSON.stringify(["name","pm_for","hospital","modality","periodicity","start_date","end_date","due_date"])})});if(!V){const ae=(Ce==null?void 0:Ce.message)||Ce;if(ae&&ae.pm_schedules){const me=ae.pm_schedules||[];if(console.log("[usePMSchedules] Loaded",me.length,"PM Schedules"),me.length>0){const K=me[0];console.log("[usePMSchedules] 🔍 FIRST SCHEDULE FIELDS:",{name:K.name,pm_for:K.pm_for,"pm_for (bracket)":K.pm_for,allKeys:Object.keys(K),allKeysList:Object.keys(K).join(", "),fullObject:K})}u(me),y(ae.total_count||0),k(ae.has_more||!1)}else console.warn("[usePMSchedules] No pm_schedules in response:",Ce),u([]),y(0),k(!1)}}catch(oe){V||(console.error("Error fetching PM Schedules:",oe),D(oe instanceof Error?oe.message:"Failed to fetch PM Schedules"),u([]),y(0))}finally{V||C(!1)}}),()=>{V=!0}},[z,U,r,a,n,A]);const B=E.useCallback(()=>{I(V=>V+1)},[]);return{pmSchedules:c,totalCount:g,hasMore:x,loading:N,error:O,refetch:B}}function aP(e){const[r,a]=E.useState(null),[n,i]=E.useState(!0),[c,u]=E.useState(null),g=E.useCallback(()=>xe(null,null,function*(){if(!e){a(null),i(!1);return}i(!0),u(null);try{const y=yield _t.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:e})});if(console.log("[usePMScheduleDetails] API Response:",y),y&&y.name&&!y.error)console.log("[usePMScheduleDetails] Setting PM Schedule:",y),a(y);else{const x=(y==null?void 0:y.error)||"PM Schedule not found";console.warn("[usePMScheduleDetails] Error or not found:",x),u(x),a(null)}}catch(y){console.error("Error fetching PM Schedule details:",y),u(y instanceof Error?y.message:"Failed to fetch PM Schedule"),a(null)}finally{i(!1)}}),[e]);return E.useEffect(()=>{g()},[g]),{pmSchedule:r,loading:n,error:c,refetch:g}}function Ok(){const[e,r]=E.useState(!1);return{createPMSchedule:k=>xe(null,null,function*(){r(!0);try{const N=yield _t.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(k)})});if(N!=null&&N.success)return N.pm_schedule;throw new Error((N==null?void 0:N.error)||"Failed to create PM Schedule")}finally{r(!1)}}),updatePMSchedule:(k,N)=>xe(null,null,function*(){r(!0);try{const C=yield _t.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:k,pm_schedule_data:JSON.stringify(N)})});if(C!=null&&C.success)return C.pm_schedule;throw new Error((C==null?void 0:C.error)||"Failed to update PM Schedule")}finally{r(!1)}}),deletePMSchedule:k=>xe(null,null,function*(){r(!0);try{const N=yield _t.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:k})});if(!(N!=null&&N.success))throw new Error((N==null?void 0:N.error)||"Failed to delete PM Schedule")}finally{r(!1)}}),submitPMSchedule:k=>xe(null,null,function*(){r(!0);try{const N=yield _t.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:k})});if(N!=null&&N.success)return N.pm_schedule;throw new Error((N==null?void 0:N.error)||"Failed to submit PM Schedule")}finally{r(!1)}}),cancelPMSchedule:k=>xe(null,null,function*(){r(!0);try{const N=yield _t.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:k})});if(N!=null&&N.success)return N.pm_schedule;throw new Error((N==null?void 0:N.error)||"Failed to cancel PM Schedule")}finally{r(!1)}}),addMaintenanceEntry:(k,N)=>xe(null,null,function*(){r(!0);try{const C=yield _t.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:k,entry_data:JSON.stringify(N)})});if(C!=null&&C.success)return C.maintenance_entries;throw new Error((C==null?void 0:C.error)||"Failed to add maintenance entry")}finally{r(!1)}}),removeMaintenanceEntry:(k,N)=>xe(null,null,function*(){r(!0);try{const C=yield _t.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:k,entry_name:N})});if(C!=null&&C.success)return C.maintenance_entries;throw new Error((C==null?void 0:C.error)||"Failed to remove maintenance entry")}finally{r(!1)}}),updateMaintenanceEntry:(k,N,C)=>xe(null,null,function*(){r(!0);try{const O=yield _t.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:k,entry_name:N,entry_data:JSON.stringify(C)})});if(O!=null&&O.success)return O.maintenance_entries;throw new Error((O==null?void 0:O.error)||"Failed to update maintenance entry")}finally{r(!1)}}),loading:e}}const nP=({isOpen:e,onClose:r,selectedCount:a,totalCount:n,pageCount:i,onExport:c,isExporting:u,exportColumns:g})=>{const{t:y}=oa(),[x,k]=E.useState(a>0?"selected":"all_with_filters"),[N,C]=E.useState("csv"),[O,D]=E.useState(g.filter(U=>U.default).map(U=>U.key));E.useEffect(()=>{a>0?k("selected"):k("all_with_filters")},[a]);const A=U=>{D(B=>B.includes(U)?B.filter(V=>V!==U):[...B,U])},I=()=>{D(g.map(U=>U.key))},z=()=>{D(g.filter(U=>U.default).map(U=>U.key))};return e?t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.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:[t.jsx("div",{className:"bg-gradient-to-r from-green-500 to-green-600 px-6 py-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(cs,{className:"text-white text-xl"}),t.jsxs("h3",{className:"text-lg font-semibold text-white",children:[y("listPages.export")," PPM Schedules"]})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:u,children:t.jsx(qt,{size:20})})]})}),t.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"Export Scope"}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${x==="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"} ${a===0?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"selected",checked:x==="selected",onChange:()=>k("selected"),disabled:a===0,className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Selected Rows"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export ",a," selected schedule",a!==1?"s":""]})]}),a>0&&t.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:[a," selected"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${x==="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:[t.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:x==="all_on_page",onChange:()=>k("all_on_page"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Current Page"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export ",i," schedule",i!==1?"s":""," on current page"]})]}),t.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"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${x==="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:[t.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:x==="all_with_filters",onChange:()=>k("all_with_filters"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"All Records (with current filters)"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export all ",n," schedule",n!==1?"s":""," matching current filters"]})]}),t.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:[n," total"]})]})]})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:y("listPages.exportFormat")}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${N==="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:[t.jsx("input",{type:"radio",name:"format",value:"csv",checked:N==="csv",onChange:()=>C("csv"),className:"text-green-600 focus:ring-green-500"}),t.jsx(Kd,{className:"text-green-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:y("listPages.csv")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Comma-separated values"})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${N==="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:[t.jsx("input",{type:"radio",name:"format",value:"excel",checked:N==="excel",onChange:()=>C("excel"),className:"text-green-600 focus:ring-green-500"}),t.jsx(cl,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:y("listPages.excel")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"XLSX spreadsheet"})]})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Columns to Export"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:I,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Select All"}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:z,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Reset to Default"})]})]}),t.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:g.map(U=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${O.includes(U.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:[t.jsx("input",{type:"checkbox",checked:O.includes(U.key),onChange:()=>A(U.key),className:"rounded text-green-600 focus:ring-green-500"}),t.jsx("span",{className:"text-sm truncate",children:U.label})]},U.key))}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:[O.length," column",O.length!==1?"s":""," selected"]})]})]}),t.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:[t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[x==="selected"&&`Exporting ${a} selected row${a!==1?"s":""}`,x==="all_on_page"&&`Exporting ${i} row${i!==1?"s":""} from current page`,x==="all_with_filters"&&`Exporting all ${n} row${n!==1?"s":""}`]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:r,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:u,children:"Cancel"}),t.jsx("button",{onClick:()=>c(x,N,O),disabled:O.length===0||u,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:u?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Exporting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Co,{}),"Export"]})})]})]})]})}):null},sP=({isOpen:e,onClose:r,selectedItems:a,onPrint:n,isPrinting:i})=>{const{t:c}=oa(),[u,g]=E.useState(""),[y,x]=E.useState(!0),[k,N]=E.useState(""),[C,O]=E.useState("A4"),[D,A]=E.useState([]),[I,z]=E.useState([]),[U,B]=E.useState(!1);E.useEffect(()=>{e&&(V(),Z())},[e]);const V=()=>xe(null,null,function*(){B(!0);try{const Q=((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);A(Q),Q.length>0&&!u&&g(Q[0])}catch(H){console.error("Error fetching print formats:",H)}finally{B(!1)}}),Z=()=>xe(null,null,function*(){try{const Q=((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);z(Q),Q.length>0&&!k&&N(Q[0])}catch(H){console.error("Error fetching letterheads:",H)}}),W=()=>{if(!u){alert("Please select a print format");return}n(u,k,!y,C)};return e?t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.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:[t.jsx("div",{className:"bg-gradient-to-r from-purple-500 to-purple-600 px-6 py-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(sl,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Print PM Schedules"})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:i,children:t.jsx(qt,{size:20})})]})}),t.jsxs("div",{className:"p-6",children:[t.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:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(qs,{className:"text-purple-600 dark:text-purple-400"}),t.jsxs("span",{className:"font-medium text-purple-800 dark:text-purple-300",children:[a.length," schedule",a.length!==1?"s":""," selected for printing"]})]}),t.jsxs("div",{className:"mt-2 text-sm text-purple-600 dark:text-purple-400 max-h-20 overflow-y-auto",children:[a.slice(0,5).join(", "),a.length>5&&` and ${a.length-5} more...`]})]}),t.jsxs("div",{className:"mb-4",children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Print Format ",t.jsx("span",{className:"text-red-500",children:"*"})]}),U?t.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-purple-500"}),"Loading formats..."]}):D.length===0?t.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."}):t.jsxs("select",{value:u,onChange:H=>g(H.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:[t.jsx("option",{value:"",children:"Select Print Format"}),D.map(H=>t.jsx("option",{value:H,children:H},H))]})]}),t.jsx("div",{className:"mb-4",children:t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:y,onChange:H=>x(H.target.checked),className:"rounded text-purple-600 focus:ring-purple-500"}),t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Use Letterhead"})]})}),y&&t.jsxs("div",{className:"mb-4",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Letterhead"}),t.jsxs("select",{value:k,onChange:H=>N(H.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:[t.jsx("option",{value:"",children:"Default Letterhead"}),I.map(H=>t.jsx("option",{value:H,children:H},H))]})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Page Size"}),t.jsxs("select",{value:C,onChange:H=>O(H.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:[t.jsx("option",{value:"A4",children:"A4"}),t.jsx("option",{value:"Letter",children:"Letter"}),t.jsx("option",{value:"A3",children:"A3"}),t.jsx("option",{value:"A5",children:"A5"}),t.jsx("option",{value:"Legal",children:"Legal"})]})]})]}),t.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:[t.jsx("button",{onClick:r,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"}),t.jsx("button",{onClick:W,disabled:!u||i||a.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?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Preparing..."]}):t.jsxs(t.Fragment,{children:[t.jsx(sl,{}),"Print ",a.length," Schedule",a.length!==1?"s":""]})})]})]})}):null},iP=()=>{const{t:e}=oa(),r=ua(),[a,n]=E.useState(0),[i,c]=E.useState(""),[u,g]=E.useState(null),[y,x]=E.useState(null),k=E.useRef(null),[N,C]=E.useState(!1),{filterHospital:O,filtersLocked:D,handleHospitalChange:A}=a1(),[I,z]=E.useState(""),[U,B]=E.useState(""),[V,Z]=E.useState(""),[W,H]=E.useState(new Set),[le,Q]=E.useState(!1),[Ne,oe]=E.useState(!1),[se,ce]=E.useState(!1),[Ce,ae]=E.useState(!1),me=20,K=[{key:"name",label:e("commonFields.pmId"),default:!0},{key:"pm_for",label:e("commonFields.name"),default:!0},{key:"hospital",label:e("commonFields.hospital"),default:!0},{key:"modality",label:e("commonFields.modality"),default:!0},{key:"manufacturer",label:e("commonFields.manufacturer"),default:!0},{key:"periodicity",label:e("ppm.periodicity"),default:!0},{key:"maintenance_team",label:"Maintenance Team",default:!1},{key:"docstatus",label:e("commonFields.status"),default:!0},{key:"creation",label:e("commonFields.createdOn"),default:!1},{key:"modified",label:e("commonFields.modifiedOn"),default:!1},{key:"owner",label:e("commonFields.createdBy"),default:!1},{key:"modified_by",label:e("commonFields.modifiedBy"),default:!1}],fe={};O&&(fe.hospital=O),I&&(fe.modality=I),U&&(fe.manufacturer=U),V&&(fe.periodicity=V);const{pmSchedules:Oe,totalCount:ye,hasMore:J,loading:G,error:ie,refetch:re}=i1(fe,me,a*me,"creation desc"),{deletePMSchedule:ne,loading:ve}=Ok();E.useEffect(()=>{const it=De=>{k.current&&!k.current.contains(De.target)&&x(null)};return y&&document.addEventListener("mousedown",it),()=>{document.removeEventListener("mousedown",it)}},[y]),E.useEffect(()=>{H(new Set)},[O,I,U,V,i,a]);const Ve=Oe.filter(it=>{var Je,Be,vt,jt,Ct,Wt;if(!i)return!0;const De=i.toLowerCase();return((Je=it.name)==null?void 0:Je.toLowerCase().includes(De))||((Be=it.pm_for)==null?void 0:Be.toLowerCase().includes(De))||((vt=it.hospital)==null?void 0:vt.toLowerCase().includes(De))||((jt=it.modality)==null?void 0:jt.toLowerCase().includes(De))||((Ct=it.manufacturer)==null?void 0:Ct.toLowerCase().includes(De))||((Wt=it.maintenance_team)==null?void 0:Wt.toLowerCase().includes(De))}),Ae=()=>{W.size===Ve.length?H(new Set):H(new Set(Ve.map(it=>it.name)))},ze=Ve.length>0&&W.size===Ve.length,Re=W.size>0&&W.size<Ve.length,Ze=it=>{H(De=>{const Je=new Set(De);return Je.has(it)?Je.delete(it):Je.add(it),Je})},Lt=E.useCallback(()=>xe(null,null,function*(){const it=[];let De=0;const Je=100;let Be=!0;for(;Be;)try{const Ct=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"PM Schedule Generator",filters:fe,fields:["*"],limit_start:De*Je,limit_page_length:Je,order_by:"creation desc"})})).json()).message||[];it.push(...Ct),Ct.length<Je?Be=!1:De++,De>100&&(console.warn("Export safety limit reached"),Be=!1)}catch(vt){throw console.error("Error fetching schedules for export:",vt),vt}return it}),[fe]),mt=(it,De,Je)=>xe(null,null,function*(){oe(!0);try{let Be=[];switch(it){case"selected":Be=Ve.filter(Ct=>W.has(Ct.name));break;case"all_on_page":Be=Ve;break;case"all_with_filters":Be=yield Lt();break}if(Be.length===0){alert("No data to export");return}const vt=Be.map(Ct=>{const Wt=_e({},Ct);if(Je.includes("docstatus")){const pr=Er(Ct);Wt.docstatus=pr===1?"Submitted":pr===2?"Cancelled":"Draft"}return Wt}),jt=Je.map(Ct=>{const Wt=K.find(pr=>pr.key===Ct);return(Wt==null?void 0:Wt.label)||Ct});if(De==="csv"){const Ct=[jt.join(","),...vt.map(We=>Je.map(At=>{let lt=We[At]||"";return typeof lt=="string"&&(lt.includes(",")||lt.includes('"')||lt.includes(`
|
||
`))&&(lt=`"${lt.replace(/"/g,'""')}"`),lt}).join(","))].join(`
|
||
`),Wt=new Blob(["\uFEFF"+Ct],{type:"text/csv;charset=utf-8;"}),pr=URL.createObjectURL(Wt),Ge=document.createElement("a");Ge.href=pr,Ge.download=`ppm_schedules_export_${new Date().toISOString().split("T")[0]}.csv`,Ge.click(),URL.revokeObjectURL(pr)}else if(De==="excel"){const Ct=[jt,...vt.map(Ge=>Je.map(We=>Ge[We]||""))],Wt=Wa.aoa_to_sheet(Ct),pr=Wa.book_new();Wa.book_append_sheet(pr,Wt,"PPM Schedules"),ul(pr,`ppm_schedules_export_${new Date().toISOString().split("T")[0]}.xlsx`)}Q(!1),H(new Set)}catch(Be){console.error("Export failed:",Be),alert(`Export failed: ${Be instanceof Error?Be.message:"Unknown error"}`)}finally{oe(!1)}}),Zt=(it,De,Je,Be)=>{ae(!0);try{const vt=Array.from(W);if(vt.length===0){alert("No schedules selected for printing");return}const jt=window.location.origin,Ct=new URLSearchParams;Ct.append("doctype","PM Schedule Generator"),Ct.append("name",JSON.stringify(vt)),Ct.append("format",it),Ct.append("no_letterhead",Je?"1":"0"),De&&!Je&&Ct.append("letterhead",De),Ct.append("options",JSON.stringify({"page-size":Be}));const Wt=`${jt}/api/method/frappe.utils.print_format.download_multi_pdf?${Ct.toString()}`;window.open(Wt,"_blank"),ce(!1)}catch(vt){console.error("Print failed:",vt),alert(`Print failed: ${vt instanceof Error?vt.message:"Unknown error"}`)}finally{ae(!1)}},ar=()=>{r("/ppm-planner/new")},or=it=>{r(`/ppm-planner/${it}`)},yt=it=>{r(`/ppm-planner/${it}`)},nr=it=>xe(null,null,function*(){try{yield ne(it),re(),g(null)}catch(De){console.error("Error deleting PM Schedule:",De),alert("Failed to delete PM Schedule")}}),$t=()=>{D||A(""),z(""),B(""),Z(""),n(0)},Er=it=>{var De;return it.docstatus!==void 0?Number(it.docstatus):((De=it.maintenance_entries)==null?void 0:De.length)>0?Number(it.maintenance_entries[0].docstatus):0},St=O||I||U||V,Br=[O,I,U,V].filter(Boolean).length,Pt=Math.ceil(ye/me);return t.jsxs("div",{className:"flex flex-col h-screen bg-gray-50 dark:bg-gray-900",children:[t.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:[t.jsxs("div",{className:"flex justify-between items-center mb-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(al,{className:"text-blue-600 dark:text-blue-400",size:24}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-gray-800 dark:text-white",children:e("sidebar.ppmPlanner")}),t.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:[e("ppm.manageSchedules"),W.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",W.size," selected"]})]})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("button",{onClick:()=>Q(!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:ye===0,children:[t.jsx(cs,{}),t.jsx("span",{children:e("listPages.export")}),W.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:W.size})]}),t.jsxs("button",{onClick:()=>ce(!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:W.size===0,title:W.size===0?"Select schedules to print":`Print ${W.size} selected`,children:[t.jsx(sl,{}),t.jsx("span",{children:"Print"}),W.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:W.size})]}),t.jsxs("button",{onClick:ar,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:[t.jsx(Mi,{}),t.jsx("span",{children:e("ppm.addPPM")})]})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("div",{className:"flex-1 relative",children:[t.jsx(_o,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400",size:14}),t.jsx("input",{type:"text",placeholder:e("listPages.searchPlaceholder"),value:i,onChange:it=>c(it.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"})]}),t.jsxs("button",{onClick:()=>C(!N),className:`px-3 py-1.5 border rounded-lg transition-colors flex items-center gap-2 text-sm ${St?"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:[t.jsx(Ri,{}),t.jsx("span",{children:e("listPages.filters")}),Br>0&&t.jsx("span",{className:"bg-blue-600 text-white rounded-full w-5 h-5 flex items-center justify-center text-xs",children:Br}),N?t.jsx(Vl,{}):t.jsx(nl,{})]})]}),N&&t.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:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[t.jsx("div",{children:t.jsx(er,{label:e("commonFields.hospital"),doctype:"Company",value:O,onChange:A,placeholder:e("filters.allHospitals"),filters:{domain:"Healthcare"},disabled:D})}),t.jsx("div",{children:t.jsx(er,{label:e("commonFields.modality"),doctype:"Modality",value:I,onChange:z,placeholder:e("filters.allModalities"),filters:{}})}),t.jsx("div",{children:t.jsx(er,{label:e("commonFields.manufacturer"),doctype:"Manufacturer",value:U,onChange:B,placeholder:e("filters.allManufacturers"),filters:{}})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:e("ppm.periodicity")}),t.jsxs("select",{value:V,onChange:it=>Z(it.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:[t.jsx("option",{value:"",children:e("listPages.all")}),t.jsx("option",{value:"Daily",children:"Daily"}),t.jsx("option",{value:"Weekly",children:"Weekly"}),t.jsx("option",{value:"Monthly",children:"Monthly"}),t.jsx("option",{value:"Quarterly",children:"Quarterly"}),t.jsx("option",{value:"Half-yearly",children:"Half-yearly"}),t.jsx("option",{value:"Yearly",children:"Yearly"})]})]})]}),St&&t.jsx("div",{className:"mt-4 flex justify-end",children:t.jsxs("button",{onClick:$t,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:[t.jsx(qt,{}),e("listPages.clearFilters")]})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto p-4 lg:p-5",children:G&&a===0?t.jsxs("div",{className:"flex items-center justify-center h-full",children:[t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"}),t.jsx("span",{className:"ml-3 text-gray-600 dark:text-gray-400",children:e("listPages.loading")})]}):ie?t.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:t.jsx("p",{className:"text-red-600 dark:text-red-400",children:ie})}):Ve.length===0?t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-8 text-center",children:[t.jsx(al,{className:"mx-auto text-gray-400 mb-4",size:48}),t.jsx("h3",{className:"text-lg font-semibold text-gray-700 dark:text-gray-300 mb-2",children:e("listPages.noResults")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:e(i||St?"listPages.tryAdjustingFilters":"listPages.getStartedCreateFirst")}),!i&&!St&&t.jsx("button",{onClick:ar,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors",children:e("ppm.addPPM")})]}):t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden",children:[t.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left",children:t.jsx("button",{onClick:Ae,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:ze?"Deselect all":"Select all",children:ze?t.jsx(qs,{className:"text-blue-600 dark:text-blue-400",size:18}):Re?t.jsxs("div",{className:"relative",children:[t.jsx(Pn,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Pn,{size:18})})}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:e("commonFields.pmId")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:e("commonFields.name")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:e("commonFields.hospital")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:e("commonFields.modality")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:e("commonFields.manufacturer")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:e("ppm.periodicity")}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:e("commonFields.status")}),t.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:e("listPages.actions")})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:Ve.map(it=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors ${W.has(it.name)?"bg-blue-50 dark:bg-blue-900/20":""}`,children:[t.jsx("td",{className:"px-4 py-4",children:t.jsx("button",{onClick:()=>Ze(it.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:W.has(it.name)?t.jsx(qs,{className:"text-blue-600 dark:text-blue-400",size:18}):t.jsx(Pn,{size:18})})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("button",{onClick:()=>or(it.name),className:"text-blue-600 dark:text-blue-400 hover:underline font-medium",children:it.name})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:it.pm_for||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:it.hospital||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:it.modality||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:it.manufacturer||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:it.periodicity||"-"}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:(()=>{const De=Er(it);return t.jsx("span",{className:`px-2 py-1 text-xs font-semibold rounded-full ${De===1?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":De===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:De===1?"Submitted":De===2?"Cancelled":"Draft"})})()}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:t.jsxs("div",{className:"relative inline-block",ref:y===it.name?k:null,children:[t.jsx("button",{onClick:()=>x(y===it.name?null:it.name),className:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 p-2",children:t.jsx(Eu,{})}),y===it.name&&t.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:[t.jsxs("button",{onClick:()=>{or(it.name),x(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:[t.jsx(to,{})," ",e("listPages.view")]}),t.jsxs("button",{onClick:()=>{yt(it.name),x(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:[t.jsx(Yn,{})," ",e("listPages.edit")]}),t.jsxs("button",{onClick:()=>{g(it.name),x(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:[t.jsx(ma,{})," ",e("listPages.delete")]})]})]})})]},it.name))})]}),Pt>1&&t.jsxs("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[e("listPages.showing")," ",a*me+1," ",e("listPages.to")," ",Math.min((a+1)*me,ye)," ",e("listPages.of")," ",ye," ",e("listPages.results")]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>n(Math.max(0,a-1)),disabled:a===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"}),t.jsx("button",{onClick:()=>n(a+1),disabled:!J,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"})]})]})]})}),t.jsx(nP,{isOpen:le,onClose:()=>Q(!1),selectedCount:W.size,totalCount:ye,pageCount:Ve.length,onExport:mt,isExporting:Ne,exportColumns:K}),t.jsx(sP,{isOpen:se,onClose:()=>ce(!1),selectedItems:Array.from(W),onPrint:Zt,isPrinting:Ce}),u&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 max-w-md",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:e("confirmations.confirmDelete")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:e("confirmations.cannotUndo")}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>g(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:ve,children:e("common.cancel")}),t.jsx("button",{onClick:()=>nr(u),className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors",disabled:ve,children:e(ve?"common.deleting":"common.delete")})]})]})}),t.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;
|
||
}
|
||
`})]})},oP=()=>{const{t:e}=oa(),{scheduleName:r}=Yl(),a=ua(),{pmSchedule:n,loading:i,error:c,refetch:u}=aP(r||null),{updatePMSchedule:g,deletePMSchedule:y,submitPMSchedule:x,cancelPMSchedule:k,loading:N}=Ok(),{logs:C,refetch:O}=Qf({},1e4,0),[D,A]=E.useState(!1),[I,z]=E.useState(!1),[U,B]=E.useState(!1),[V,Z]=E.useState(""),[W,H]=E.useState(""),[le,Q]=E.useState(!1),[Ne,oe]=E.useState(!1),[se,ce]=E.useState(new Set),[Ce,ae]=E.useState(!1),[me,K]=E.useState(!1),[fe,Oe]=E.useState(new Set),[ye,J]=E.useState([]),[G,ie]=E.useState([]),[re,ne]=E.useState([]),[ve,Ve]=E.useState(""),[Ae,ze]=E.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:""});Kl(ze,{enabled:!!n&&!n.hospital,fields:["hospital"]}),E.useEffect(()=>{xe(null,null,function*(){try{const At=yield(yield fetch("/api/method/frappe.auth.get_logged_user",{method:"GET",credentials:"include"})).json();At.message&&Ve(At.message)}catch(We){console.error("Error fetching current user:",We)}})},[]),E.useEffect(()=>{if(r){const Ge=localStorage.getItem(`ppm_activity_${r}`);Ge&&ne(JSON.parse(Ge))}},[r]),E.useEffect(()=>{if(n!=null&&n.maintenance_entries&&C.length>0){const Ge=[],We=[];n.maintenance_entries.forEach(At=>{C.filter(Dt=>Dt.asset_name===At.asset).forEach(Dt=>{Dt.workflow_state==="Applied"?We.push($e(_e({},Dt),{asset_display_name:At.asset_name||At.asset})):Dt.maintenance_status==="Planned"&&(!Dt.workflow_state||Dt.workflow_state==="Draft")&&Ge.push($e(_e({},Dt),{asset_display_name:At.asset_name||At.asset}))})}),J(Ge),ie(We)}},[n,C]),E.useEffect(()=>{if(C.length>0&&(n!=null&&n.maintenance_entries)){const Ge=[];if(n.maintenance_entries.forEach(We=>{C.filter(lt=>lt.asset_name===We.asset).forEach(lt=>{const Dt=lt.maintenance_status==="Planned"&&(!lt.workflow_state||lt.workflow_state==="Draft"),mr=lt.workflow_state==="Applied";(Dt||mr)&<.due_date&&Ge.push(lt.due_date)})}),Ge.length>0){const We=Ge.sort((At,lt)=>new Date(At).getTime()-new Date(lt).getTime())[0];console.log("📅 Pending due dates:",Ge),console.log("📅 Earliest (Next PM Date):",We),ze(At=>At.next_pm_date!==We?$e(_e({},At),{next_pm_date:We}):At)}else console.log("📅 No pending entries found - all completed"),ze(We=>$e(_e({},We),{next_pm_date:""}))}},[n,C]),E.useEffect(()=>{n&&ze({hospital:n.hospital||"",modality:n.modality||"",device_status:n.device_status||"",start_date:n.start_date||"",end_date:n.end_date||"",maintenance_team:n.maintenance_team||"",maintenance_manager:n.maintenance_manager||"",periodicity:n.periodicity||"Monthly",assign_to:n.assign_to||"",due_date:n.due_date||"",next_pm_date:n.next_pm_date||"",manufacturer:n.manufacturer||"",model:n.model||"",pm_for:n.pm_for||"",asset_name:n.asset_name||"",no_of_pms:n.no_of_pms||""})},[n]),E.useEffect(()=>{if(V&&Ae.next_pm_date){const Ge=new Date(V),We=new Date(Ae.next_pm_date);Q(Ge<We)}else Q(!1)},[V,Ae.next_pm_date]);const Re=(Ge,We,At)=>{if(!Ge||!We||!At)return null;const lt=parseInt(At,10);if(isNaN(lt)||lt<1)return null;const Dt=lt-1;if(Dt<0)return null;const mr=new Date(Ge),tr=new Date(mr);switch(We){case"Daily":tr.setDate(tr.getDate()+Dt);break;case"Weekly":tr.setDate(tr.getDate()+Dt*7);break;case"Monthly":tr.setMonth(tr.getMonth()+Dt);break;case"Quarterly":tr.setMonth(tr.getMonth()+Dt*3);break;case"Half-yearly":tr.setMonth(tr.getMonth()+Dt*6);break;case"Yearly":tr.setFullYear(tr.getFullYear()+Dt);break;case"2 Yearly":tr.setFullYear(tr.getFullYear()+Dt*2);break;case"3 Yearly":tr.setFullYear(tr.getFullYear()+Dt*3);break;default:return null}const pt=tr.getFullYear(),Jt=String(tr.getMonth()+1).padStart(2,"0"),vr=String(tr.getDate()).padStart(2,"0");return`${pt}-${Jt}-${vr}`},Ze=Ge=>{const{name:We,value:At}=Ge.target;ze(lt=>{const Dt=$e(_e({},lt),{[We]:At});if(We==="start_date"||We==="periodicity"||We==="no_of_pms"){const mr=Re(We==="start_date"?At:lt.start_date,We==="periodicity"?At:lt.periodicity,We==="no_of_pms"?At:lt.no_of_pms);mr&&(Dt.end_date=mr)}return Dt})},Lt=()=>xe(null,null,function*(){if(r)try{yield g(r,Ae),A(!1),u(),alert("PPM Planner updated successfully")}catch(Ge){console.error("Error updating PPM Planner:",Ge),alert("Failed to update PPM Planner")}}),mt=()=>xe(null,null,function*(){if(r)try{yield y(r),a("/ppm-planner")}catch(Ge){console.error("Error deleting PPM Planner:",Ge),alert("Failed to delete PPM Planner")}}),Zt=()=>xe(null,null,function*(){if(r)try{yield x(r),u(),alert("PPM Planner submitted successfully")}catch(Ge){console.error("Error submitting PPM Planner:",Ge),alert("Failed to submit PPM Planner")}}),ar=()=>xe(null,null,function*(){if(r)try{yield k(r),u(),alert("PPM Planner cancelled successfully")}catch(Ge){console.error("Error cancelling PPM Planner:",Ge),alert("Failed to cancel PPM Planner")}}),or=()=>{if(ye.length===0){alert("No planned maintenance entries found to apply.");return}const Ge=new Date().toISOString().split("T")[0];Z(Ge),H(""),ce(new Set(ye.map(We=>We.name))),B(!0)},yt=Ge=>{ce(We=>{const At=new Set(We);return At.has(Ge)?At.delete(Ge):At.add(Ge),At})},nr=()=>{ce(new Set(ye.map(Ge=>Ge.name)))},$t=()=>{ce(new Set)},Er=()=>xe(null,null,function*(){if(!V){alert("Please enter a completion date.");return}if(le&&!W.trim()){alert("Please provide a reason for early completion.");return}if(se.size===0){alert("Please select at least one entry to complete.");return}oe(!0);try{let Ge=0,We=0;const At=[],lt=ye.filter(tr=>se.has(tr.name));for(const tr of lt)try{const pt={maintenance_status:"Completed",workflow_state:"Applied",completion_date:V};le&&W&&(pt.custom_early_completion_reason=W,pt.custom_early_completion="Yes");const vr=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:tr.name,fieldname:pt})})).json();vr.message?(Ge++,At.push(tr.name)):(We++,console.error(`Failed to apply ${tr.name}:`,vr))}catch(pt){We++,console.error(`Error applying ${tr.name}:`,pt)}const mr=[{id:Date.now().toString(),user:ve||"Unknown User",timestamp:new Date().toISOString(),action:"Applied",entriesCount:Ge,completionDate:V,earlyReason:le?W:void 0,entries:At},...re];ne(mr),r&&localStorage.setItem(`ppm_activity_${r}`,JSON.stringify(mr)),B(!1),Z(""),H(""),ce(new Set),O(),u(),alert(We===0?`Successfully applied ${Ge} maintenance entries. They are now pending approval.`:`Applied ${Ge} entries. Failed to apply ${We} entries.`)}catch(Ge){console.error("Error applying entries:",Ge),alert("Failed to apply entries.")}finally{oe(!1)}}),St=()=>{if(G.length===0){alert("No entries pending approval.");return}Oe(new Set(G.map(Ge=>Ge.name))),ae(!0)},Br=Ge=>{Oe(We=>{const At=new Set(We);return At.has(Ge)?At.delete(Ge):At.add(Ge),At})},Pt=()=>{Oe(new Set(G.map(Ge=>Ge.name)))},it=()=>{Oe(new Set)},De=()=>xe(null,null,function*(){if(fe.size===0){alert("Please select at least one entry to approve.");return}K(!0);try{let Ge=0,We=0;const At=[],lt=G.filter(tr=>fe.has(tr.name));for(const tr of lt)try{const Jt=yield(yield fetch(`/api/resource/Asset Maintenance Log/${encodeURIComponent(tr.name)}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json();if(!Jt.data){console.error(`Failed to get document ${tr.name}`),We++;continue}const vr=$e(_e({},Jt.data),{workflow_state:"Approved",docstatus:1}),Le=yield(yield fetch(`/api/resource/Asset Maintenance Log/${encodeURIComponent(tr.name)}`,{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(vr)})).json();if(Le.data&&Le.data.docstatus===1)Ge++,At.push(tr.name),console.log(`✅ Successfully approved and submitted: ${tr.name}`);else{console.log(`Trying alternative submit method for ${tr.name}...`);const qe=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:tr.name,workflow_action:"Approve"})}),Yt=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:tr.name,method:"submit"})})).json();Yt.message||!Yt.exc?(Ge++,At.push(tr.name),console.log(`✅ Successfully submitted via run_doc_method: ${tr.name}`)):(We++,console.error(`Failed to submit ${tr.name}:`,Yt))}}catch(pt){We++,console.error(`Error approving ${tr.name}:`,pt)}const mr=[{id:Date.now().toString(),user:ve||"Unknown User",timestamp:new Date().toISOString(),action:"Approved",entriesCount:Ge,entries:At},...re];ne(mr),r&&localStorage.setItem(`ppm_activity_${r}`,JSON.stringify(mr)),ae(!1),Oe(new Set),setTimeout(()=>{O(),u()},1e3),alert(We===0?`Successfully approved and submitted ${Ge} maintenance entries. New planned entries should be created automatically.`:`Approved ${Ge} entries. Failed to approve ${We} entries.`)}catch(Ge){console.error("Error approving entries:",Ge),alert("Failed to approve entries.")}finally{K(!1)}}),Je=Ge=>{switch(Ge){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"}},Be=Ge=>C.filter(At=>At.asset_name===Ge).filter(At=>{const lt=At.maintenance_status==="Planned"&&(!At.workflow_state||At.workflow_state==="Draft"),Dt=At.workflow_state==="Applied";return lt||Dt}),vt=Ge=>Be(Ge).length>0,jt=()=>n!=null&&n.maintenance_entries?n.maintenance_entries.filter(Ge=>vt(Ge.asset)):[];if(i)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Ja,{className:"animate-spin text-blue-600",size:24}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Loading PPM Planner..."})]})});if(c)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[t.jsx("p",{className:"text-red-600 dark:text-red-400",children:c}),t.jsx("button",{onClick:()=>a("/ppm-planner"),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(!n)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:[t.jsx("p",{className:"text-yellow-600 dark:text-yellow-400",children:"PPM Planner not found"}),t.jsx("button",{onClick:()=>a("/ppm-planner"),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 Ct=n.docstatus===0,Wt=n.docstatus===1;n.docstatus;const pr=jt();return t.jsxs("div",{className:"flex flex-col h-screen bg-gray-50 dark:bg-gray-900",children:[t.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:[t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>a("/ppm-planner"),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:t.jsx(bi,{className:"text-gray-600 dark:text-gray-400"})}),t.jsx(al,{className:"text-blue-600 dark:text-blue-400",size:28}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:n.name}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"PPM Planner Details"})]}),t.jsx("span",{className:`ml-4 px-3 py-1 text-sm font-semibold rounded-full ${Wt?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":Ct?"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:Wt?"Submitted":Ct?"Draft":"Cancelled"})]}),t.jsxs("div",{className:"flex gap-2",children:[Wt&&t.jsxs("div",{className:"flex gap-2 mr-4 pr-4 border-r border-gray-300 dark:border-gray-600",children:[ye.length>0&&t.jsxs("button",{onClick:or,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors flex items-center gap-2",children:[t.jsx(Gh,{}),"Bulk Complete(",ye.length,")"]}),G.length>0&&t.jsxs("button",{onClick:St,className:"px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors flex items-center gap-2",children:[t.jsx(q0,{}),"Approve (",G.length,")"]})]}),Ct&&!D&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>A(!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:[t.jsx(Yn,{}),"Edit"]}),t.jsxs("button",{onClick:Zt,disabled:N,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:[t.jsx(Ca,{}),"Submit"]}),t.jsxs("button",{onClick:()=>z(!0),disabled:N,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:[t.jsx(ma,{}),"Delete"]})]}),D&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:Lt,disabled:N,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:[N?t.jsx(Ja,{className:"animate-spin"}):t.jsx(Fn,{}),"Save"]}),t.jsx("button",{onClick:()=>{A(!1),ze({hospital:n.hospital||"",modality:n.modality||"",device_status:n.device_status||"",start_date:n.start_date||"",end_date:n.end_date||"",maintenance_team:n.maintenance_team||"",maintenance_manager:n.maintenance_manager||"",periodicity:n.periodicity||"Monthly",assign_to:n.assign_to||"",due_date:n.due_date||"",next_pm_date:n.next_pm_date||"",manufacturer:n.manufacturer||"",model:n.model||"",pm_for:n.pm_for||"",asset_name:n.asset_name||"",no_of_pms:n.no_of_pms||""})},disabled:N,className:"px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg transition-colors disabled:opacity-50",children:"Cancel"})]}),Wt&&t.jsx("button",{onClick:ar,disabled:N,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"})]})]}),Wt&&t.jsxs("div",{className:"flex items-center gap-4 mt-2 pt-3 border-t border-gray-200 dark:border-gray-700",children:[t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Workflow Status:"}),ye.length>0&&t.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:[ye.length," Planned"]}),G.length>0&&t.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:[G.length," Pending Approval"]}),ye.length===0&&G.length===0&&t.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 ✓"})]})]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsx("div",{className:"flex-1 overflow-auto p-6",children:t.jsx("div",{className:"max-w-4xl mx-auto bg-white dark:bg-gray-800 rounded-lg shadow",children:t.jsxs("div",{className:"p-6 space-y-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:"Basic Information"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsx("div",{children:D?t.jsx(er,{label:"Hospital *",doctype:"Company",value:Ae.hospital,onChange:Ge=>ze(We=>$e(_e({},We),{hospital:Ge})),placeholder:"Select Hospital",filters:{}}):t.jsxs(t.Fragment,{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Hospital"}),t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:n.hospital||"-"})]})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Modality"}),D?t.jsx("input",{type:"text",name:"modality",value:Ae.modality,onChange:Ze,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"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:n.modality||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Device Status"}),D?t.jsx("input",{type:"text",name:"device_status",value:Ae.device_status,onChange:Ze,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"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:n.device_status||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Periodicity *"}),D?t.jsxs("select",{name:"periodicity",value:Ae.periodicity,onChange:Ze,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:[t.jsx("option",{value:"Daily",children:"Daily"}),t.jsx("option",{value:"Weekly",children:"Weekly"}),t.jsx("option",{value:"Monthly",children:"Monthly"}),t.jsx("option",{value:"Quarterly",children:"Quarterly"}),t.jsx("option",{value:"Half-yearly",children:"Half-yearly"}),t.jsx("option",{value:"Yearly",children:"Yearly"})]}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:n.periodicity||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Manufacturer"}),D?t.jsx("input",{type:"text",name:"manufacturer",value:Ae.manufacturer,onChange:Ze,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"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:n.manufacturer||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Model"}),D?t.jsx("input",{type:"text",name:"model",value:Ae.model,onChange:Ze,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"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:n.model||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"PM Name"}),D?t.jsx("input",{type:"text",name:"pm_for",value:Ae.pm_for,onChange:Ze,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"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:n.pm_for||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Asset Name"}),D?t.jsx("input",{type:"text",name:"asset_name",value:Ae.asset_name,onChange:Ze,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"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:n.asset_name||"-"})]})]})]}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:"Schedule Dates"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Start Date *"}),D?t.jsx("input",{type:"date",name:"start_date",value:Ae.start_date,onChange:Ze,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"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:n.start_date?new Date(n.start_date).toLocaleDateString():"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"End Date *"}),D?t.jsx("input",{type:"date",name:"end_date",value:Ae.end_date,onChange:Ze,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"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:n.end_date?new Date(n.end_date).toLocaleDateString():"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"First PM Date"}),D?t.jsx("input",{type:"date",name:"due_date",value:Ae.due_date,onChange:Ze,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"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:n.due_date?new Date(n.due_date).toLocaleDateString():"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Next PM Date"}),D?t.jsx("input",{type:"date",name:"next_pm_date",value:Ae.next_pm_date,onChange:Ze,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"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:Ae.next_pm_date?new Date(Ae.next_pm_date).toLocaleDateString():n.next_pm_date?new Date(n.next_pm_date).toLocaleDateString():"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"No. of PMs"}),D?t.jsx("input",{type:"number",name:"no_of_pms",value:Ae.no_of_pms,onChange:Ze,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"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:n.no_of_pms||"-"})]})]})]}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:"Assignment"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Maintenance Team"}),D?t.jsx("input",{type:"text",name:"maintenance_team",value:Ae.maintenance_team,onChange:Ze,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"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:n.maintenance_team||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Maintenance Manager"}),D?t.jsx("input",{type:"text",name:"maintenance_manager",value:Ae.maintenance_manager,onChange:Ze,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"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:n.maintenance_manager||"-"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Assign To"}),D?t.jsx("input",{type:"text",name:"assign_to",value:Ae.assign_to,onChange:Ze,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"}):t.jsx("div",{className:"px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-white",children:n.assign_to||"-"})]})]})]}),pr.length>0&&t.jsxs("div",{children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:["Pending Maintenance Entries",t.jsx("span",{className:"ml-2 text-sm font-normal text-gray-500 dark:text-gray-400",children:"(Showing Planned & Applied only)"})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full border-collapse border border-gray-300 dark:border-gray-600",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"bg-gray-100 dark:bg-gray-700",children:[t.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"}),t.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"}),t.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"}),t.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"}),t.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"}),t.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"})]})}),t.jsx("tbody",{children:pr.map((Ge,We)=>{const At=Be(Ge.asset);return At.map((lt,Dt)=>t.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50",children:[Dt===0&&t.jsxs(t.Fragment,{children:[t.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm text-gray-900 dark:text-white",rowSpan:At.length,children:Ge.asset?t.jsx("button",{onClick:()=>a(`/assets/${Ge.asset}`),className:"text-blue-600 dark:text-blue-400 hover:underline",children:Ge.asset}):"-"}),t.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm text-gray-900 dark:text-white",rowSpan:At.length,children:Ge.asset_name||"-"}),t.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm text-gray-900 dark:text-white",rowSpan:At.length,children:Ge.manufacturer||"-"})]}),t.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm text-gray-900 dark:text-white",children:t.jsx("button",{onClick:()=>a(`/maintenance/${lt.name}`),className:"text-blue-600 dark:text-blue-400 hover:underline",children:lt.name})}),t.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm",children:t.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-medium ${lt.workflow_state==="Applied"?Je("Applied"):Je("Planned")}`,children:lt.workflow_state==="Applied"?"Applied (Pending Approval)":"Planned"})}),t.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-4 py-2 text-sm text-gray-900 dark:text-white",children:lt.due_date?new Date(lt.due_date).toLocaleDateString():"-"})]},`${Ge.name}-${lt.name}`))})})]})})]}),Wt&&pr.length===0&&t.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:[t.jsx(Ca,{className:"mx-auto text-green-600 dark:text-green-400 text-3xl mb-2"}),t.jsx("h3",{className:"text-lg font-semibold text-green-800 dark:text-green-300 mb-1",children:"All Maintenance Entries Completed"}),t.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."})]}),t.jsxs("div",{className:"pt-4 border-t border-gray-200 dark:border-gray-700",children:[t.jsx("h2",{className:"text-sm font-semibold text-gray-600 dark:text-gray-400 mb-3",children:"Metadata"}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-500",children:"Created:"}),t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:n.creation?new Date(n.creation).toLocaleString():"-"})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-500",children:"Created By:"}),t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:n.owner||"-"})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-500",children:"Modified:"}),t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:n.modified?new Date(n.modified).toLocaleString():"-"})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-500",children:"Modified By:"}),t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:n.modified_by||"-"})]})]})]})]})})}),t.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:t.jsxs("div",{className:"p-4",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[t.jsx(Nf,{className:"text-blue-600 dark:text-blue-400"}),t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Activity Log"})]}),re.length===0?t.jsxs("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:[t.jsx(Nf,{className:"mx-auto text-3xl mb-2 opacity-50"}),t.jsx("p",{className:"text-sm",children:"No activity recorded yet"})]}):t.jsx("div",{className:"space-y-3",children:re.map(Ge=>t.jsx("div",{className:`rounded-lg p-3 border ${Ge.action==="Approved"?"bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800":Ge.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:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("div",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center ${Ge.action==="Approved"?"bg-green-100 dark:bg-green-900/30":Ge.action==="Applied"?"bg-blue-100 dark:bg-blue-900/30":"bg-gray-100 dark:bg-gray-600"}`,children:Ge.action==="Approved"?t.jsx(q0,{className:"text-green-600 dark:text-green-400 text-sm"}):t.jsx(Gh,{className:"text-blue-600 dark:text-blue-400 text-sm"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:`text-sm font-medium ${Ge.action==="Approved"?"text-green-800 dark:text-green-300":Ge.action==="Applied"?"text-blue-800 dark:text-blue-300":"text-gray-900 dark:text-white"}`,children:Ge.action}),t.jsxs("div",{className:"flex items-center gap-1 mt-1 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx(Wl,{className:"text-[10px]"}),t.jsx("span",{className:"truncate",children:Ge.user})]}),t.jsxs("div",{className:"flex items-center gap-1 mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx($s,{className:"text-[10px]"}),t.jsx("span",{children:new Date(Ge.timestamp).toLocaleString()})]}),t.jsx("div",{className:"mt-2 pt-2 border-t border-gray-200 dark:border-gray-600",children:t.jsxs("div",{className:"text-xs space-y-1",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Entries:"}),t.jsx("span",{className:`font-medium ${Ge.action==="Approved"?"text-green-600 dark:text-green-400":"text-blue-600 dark:text-blue-400"}`,children:Ge.entriesCount})]}),Ge.completionDate&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Completion Date:"}),t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:new Date(Ge.completionDate).toLocaleDateString()})]})]})})]})]})},Ge.id))})]})})]}),U&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 max-w-lg w-full mx-4",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center",children:t.jsx(Gh,{className:"text-blue-600 dark:text-blue-400"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Apply for Approval"}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[se.size," of ",ye.length," ",ye.length===1?"entry":"entries"," selected"]})]})]}),t.jsxs("div",{className:"mb-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400",children:"Select Entries to Complete:"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:nr,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Select All"}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{type:"button",onClick:$t,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Deselect All"})]})]}),t.jsx("div",{className:"max-h-48 overflow-y-auto bg-gray-50 dark:bg-gray-700 rounded-lg p-3 space-y-2",children:ye.map((Ge,We)=>t.jsxs("label",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-all ${se.has(Ge.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:[t.jsx("input",{type:"checkbox",checked:se.has(Ge.name),onChange:()=>yt(Ge.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"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.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:We+1}),t.jsxs("div",{className:"truncate",children:[t.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:Ge.asset_display_name||Ge.asset_name||"Unknown Asset"}),t.jsx("span",{className:"text-gray-400 dark:text-gray-500 mx-1",children:"-"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:Ge.name})]})]}),Ge.due_date&&t.jsxs("div",{className:"ml-7 text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:["Due: ",new Date(Ge.due_date).toLocaleDateString()]})]})]},Ge.name))}),t.jsxs("div",{className:"mt-2 flex items-center justify-between text-xs",children:[t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[se.size," selected"]}),se.size===0&&t.jsx("span",{className:"text-red-500 dark:text-red-400",children:"Please select at least one entry"})]})]}),t.jsxs("div",{className:"mb-4",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Completion Date *"}),t.jsx("input",{type:"date",value:V,onChange:Ge=>Z(Ge.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"})]}),Ae.next_pm_date&&t.jsx("div",{className:"mb-4 p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx(al,{className:"text-blue-600 dark:text-blue-400"}),t.jsxs("span",{className:"text-gray-700 dark:text-gray-300",children:["Next PM Date: ",t.jsx("strong",{className:"text-blue-600 dark:text-blue-400",children:new Date(Ae.next_pm_date).toLocaleDateString()})]})]})}),le&&t.jsxs("div",{className:"mb-4",children:[t.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:t.jsxs("p",{className:"text-sm text-amber-700 dark:text-amber-400 flex items-center gap-2",children:[t.jsx("span",{className:"text-lg",children:"⚠️"}),"Completion date is before the Next PM Date. Please provide a reason."]})}),t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Early Completion Reason *"}),t.jsx("textarea",{value:W,onChange:Ge=>H(Ge.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"})]}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>{B(!1),Z(""),H(""),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"}),t.jsx("button",{onClick:Er,disabled:Ne||!V||se.size===0||le&&!W.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?t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"animate-spin"}),"Applying..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Gh,{}),"Complete (",se.size,")"]})})]})]})}),Ce&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 max-w-lg w-full mx-4",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-10 h-10 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center",children:t.jsx(q0,{className:"text-green-600 dark:text-green-400"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Approve Entries"}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[fe.size," of ",G.length," ",G.length===1?"entry":"entries"," selected"]})]})]}),t.jsxs("div",{className:"mb-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400",children:"Select Entries to Approve:"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:Pt,className:"text-xs text-green-600 dark:text-green-400 hover:underline",children:"Select All"}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{type:"button",onClick:it,className:"text-xs text-green-600 dark:text-green-400 hover:underline",children:"Deselect All"})]})]}),t.jsx("div",{className:"max-h-48 overflow-y-auto bg-gray-50 dark:bg-gray-700 rounded-lg p-3 space-y-2",children:G.map((Ge,We)=>t.jsxs("label",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-all ${fe.has(Ge.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:[t.jsx("input",{type:"checkbox",checked:fe.has(Ge.name),onChange:()=>Br(Ge.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"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.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:We+1}),t.jsxs("div",{className:"truncate",children:[t.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:Ge.asset_display_name||Ge.asset_name||"Unknown Asset"}),t.jsx("span",{className:"text-gray-400 dark:text-gray-500 mx-1",children:"-"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:Ge.name})]})]}),Ge.completion_date&&t.jsxs("div",{className:"ml-7 text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:["Completed: ",new Date(Ge.completion_date).toLocaleDateString()]})]})]},Ge.name))}),t.jsxs("div",{className:"mt-2 flex items-center justify-between text-xs",children:[t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[fe.size," selected"]}),fe.size===0&&t.jsx("span",{className:"text-red-500 dark:text-red-400",children:"Please select at least one entry"})]})]}),t.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:t.jsxs("p",{className:"text-sm text-green-700 dark:text-green-400",children:["✓ Approving will ",t.jsx("strong",{children:"submit"})," the documents (docstatus = 1) and trigger auto-creation of next planned entries."]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>{ae(!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:me,children:"Cancel"}),t.jsx("button",{onClick:De,disabled:me||fe.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:me?t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"animate-spin"}),"Approving..."]}):t.jsxs(t.Fragment,{children:[t.jsx(q0,{}),"Approve (",fe.size,")"]})})]})]})}),I&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 max-w-md",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white mb-4",children:"Confirm Delete"}),t.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."}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>z(!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:N,children:"Cancel"}),t.jsx("button",{onClick:mt,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors",disabled:N,children:N?"Deleting...":"Delete"})]})]})})]})},lP=({month:e,year:r,filters:a={},viewType:n="maintenance-log",timeView:i="day-month"})=>{const c=ua(),u=new Date,[g,y]=E.useState(e!=null?e:u.getMonth()),[x,k]=E.useState(r!=null?r:u.getFullYear()),N=new Date(x,g,1).toISOString().split("T")[0],C=new Date(x,g+1,0).toISOString().split("T")[0],O=JSON.stringify(a),D=E.useMemo(()=>a,[O]),A=E.useMemo(()=>_e({due_date:["between",[N,C]]},D),[N,C,D]),I=E.useMemo(()=>({}),[]),z=E.useMemo(()=>({}),[]),{logs:U,loading:B}=Qf(n==="maintenance-log"?A:I,n==="maintenance-log"?1e3:0,0,"due_date asc"),{pmSchedules:V,loading:Z}=i1(n==="ppm-planner"?D:I,1e3,0,"creation desc",z),W=n==="maintenance-log"?B:Z,H=E.useMemo(()=>n==="maintenance-log"?U.filter(K=>{if(!K.due_date)return!1;const fe=new Date(K.due_date);return fe.getMonth()===g&&fe.getFullYear()===x}):V.filter(fe=>{const Oe=fe.due_date||fe.start_date;if(!Oe)return!1;const[ye,J,G]=Oe.split("-").map(Number),ie=new Date(ye,J-1,G);return ie.getMonth()===g&&ie.getFullYear()===x}),[U,V,g,x,n]);E.useEffect(()=>{n==="ppm-planner"&&!Z&&(console.log("=== PPM PLANNER DEBUG ==="),console.log("[MaintenanceCalendar] Viewing Month:",g+1,"Year:",x),console.log("[MaintenanceCalendar] Total PM Schedules fetched:",V.length),console.log("[MaintenanceCalendar] Filtered for current month:",H.length),H.length>0?(console.log("[MaintenanceCalendar] Schedules showing in this month:"),H.forEach(K=>{console.log(` - ${K.name}: due_date=${K.due_date}, start_date=${K.start_date}`)})):(console.log("[MaintenanceCalendar] No schedules match this month."),console.log("[MaintenanceCalendar] Due dates in fetched data:"),V.slice(0,5).forEach(K=>{const fe=K.due_date||K.start_date;console.log(` - ${K.name}: due_date=${K.due_date}, start_date=${K.start_date}, will show in: ${fe?(()=>{const[Oe,ye]=fe.split("-").map(Number);return`${ye}/${Oe}`})():"unknown"}`)}),console.log("[MaintenanceCalendar] TIP: Navigate to the month where due_dates match to see schedules.")),console.log("========================="))},[n,V,Z,H.length,g,x]);const le=(K,fe)=>{const Oe=new Date(fe)<new Date&&K!=="Completed";switch(K){case"Completed":return"bg-green-500 text-white border-green-600";case"Planned":return Oe?"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"}},Q=new Date(x,g,1).getDay(),Ne=new Date(x,g+1,0).getDate(),oe=Array.from({length:Ne},(K,fe)=>fe+1),se=K=>{K>0?g===11?(y(0),k(x+1)):y(g+1):g===0?(y(11),k(x-1)):y(g-1)},ce=K=>n==="maintenance-log"?H.filter(fe=>fe.due_date?new Date(fe.due_date).getDate()===K:!1):H.filter(Oe=>{const ye=Oe.due_date||Oe.start_date;if(!ye)return!1;const[J,G,ie]=ye.split("-").map(Number),re=new Date(J,G-1,ie);return re.getDate()===K&&re.getMonth()===g&&re.getFullYear()===x}),Ce=()=>{y(u.getMonth()),k(u.getFullYear())},ae=["January","February","March","April","May","June","July","August","September","October","November","December"],me=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow h-full flex flex-col overflow-hidden",children:[t.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:[t.jsxs("div",{className:"flex items-center gap-2 lg:gap-3",children:[t.jsx(al,{className:"text-blue-600 dark:text-blue-400",size:20}),t.jsxs("h2",{className:"text-xl lg:text-2xl font-bold text-gray-800 dark:text-white",children:[ae[g]," ",x]})]}),t.jsxs("div",{className:"flex gap-1 lg:gap-2",children:[t.jsx("button",{onClick:()=>se(-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:"Previous Month",children:t.jsx(Ew,{})}),t.jsx("button",{onClick:Ce,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:"Today"}),t.jsx("button",{onClick:()=>se(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:"Next Month",children:t.jsx(jw,{})})]})]}),W?t.jsxs("div",{className:"flex items-center justify-center flex-1",children:[t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"}),t.jsxs("span",{className:"ml-3 text-gray-600 dark:text-gray-400",children:["Loading ",n==="maintenance-log"?"maintenance logs":"PPM Planners","..."]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex-1 overflow-auto p-4 lg:p-6",children:[t.jsx("div",{className:"grid grid-cols-7 gap-1 lg:gap-2 mb-2",children:me.map(K=>t.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:K},K))}),t.jsxs("div",{className:"grid grid-cols-7 gap-1 lg:gap-2 auto-rows-fr",children:[Array.from({length:Q}).map((K,fe)=>t.jsx("div",{className:"p-1 lg:p-2"},`empty-${fe}`)),oe.map(K=>{const fe=ce(K),Oe=K===u.getDate()&&g===u.getMonth()&&x===u.getFullYear();return t.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 ${Oe?"border-blue-500 border-2 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700"}`,children:[t.jsx("div",{className:`font-semibold mb-1 text-xs lg:text-sm flex-shrink-0 ${Oe?"text-blue-700 dark:text-blue-300":"text-gray-700 dark:text-gray-300"}`,children:K}),t.jsxs("div",{className:"space-y-1 flex-1 overflow-hidden",children:[fe.slice(0,2).map(ye=>{if(n==="maintenance-log"){const J=ye,G=new Date(J.due_date||"")<new Date&&J.maintenance_status!=="Completed";return t.jsx("div",{onClick:()=>c(`/maintenance/${J.name}`),className:`text-xs p-1 rounded border ${le(J.maintenance_status||"Planned",J.due_date||"")} truncate cursor-pointer hover:opacity-80 transition-opacity`,title:`${J.asset_name||J.name} - ${J.maintenance_status||"Planned"}${G?" (Overdue)":""} - Click to view details`,children:t.jsx("div",{className:"truncate font-medium text-xs",children:J.asset_name||J.name})},J.name)}else{const J=ye,ie=J.pm_for||J.pm_for||J["PM Name"]||null||J.name||"PPM Planner",re=J.name?`${J.name}${J.modality?` - ${J.modality}`:""}${J.hospital?` - ${J.hospital}`:""} - Click to view PPM Planner`:"Click to view PPM Planner";return t.jsx("div",{onClick:()=>c(`/ppm-planner/${J.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:re,children:t.jsx("div",{className:"truncate font-medium text-xs",children:ie})},J.name)}}),fe.length>2&&t.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-medium",children:["+",fe.length-2]})]})]},K)})]})]}),t.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:t.jsxs("div",{className:"flex flex-col lg:flex-row justify-between items-center gap-3 lg:gap-4",children:[t.jsxs("div",{className:"flex flex-wrap gap-3 lg:gap-4 items-center justify-center lg:justify-start",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-3 h-3 bg-green-500 rounded border border-green-600"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Completed"})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-3 h-3 bg-yellow-500 rounded border border-yellow-600"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Planned"})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-3 h-3 bg-red-500 rounded border border-red-600"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Overdue"})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-3 h-3 border-2 border-blue-500 rounded bg-blue-50 dark:bg-blue-900/20"}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Today"})]})]}),t.jsx("div",{className:"flex gap-4 lg:gap-6 text-center",children:n==="maintenance-log"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-lg lg:text-xl font-bold text-green-600 dark:text-green-400",children:H.filter(K=>K.maintenance_status==="Completed").length}),t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Completed"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-lg lg:text-xl font-bold text-yellow-600 dark:text-yellow-400",children:H.filter(K=>K.maintenance_status==="Planned"&&new Date(K.due_date||"")>=new Date).length}),t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Planned"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-lg lg:text-xl font-bold text-red-600 dark:text-red-400",children:H.filter(K=>new Date(K.due_date||"")<new Date&&K.maintenance_status!=="Completed").length}),t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Overdue"})]})]}):t.jsxs("div",{children:[t.jsx("div",{className:"text-lg lg:text-xl font-bold text-purple-600 dark:text-purple-400",children:H.length}),t.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:"PPM Planners"})]})})]})})]})]})},cP=()=>{const e=ua(),[r]=Li(),{filterHospital:a,filtersLocked:n,handleHospitalChange:i}=a1(),[c,u]=E.useState(""),[g,y]=E.useState(""),[x,k]=E.useState("");E.useEffect(()=>{if(n)return;const V=r.get("hospital"),Z=r.get("status");V&&i(V),Z&&y(Z)},[r,n,i]);const[N,C]=E.useState("maintenance-log"),[O,D]=E.useState(!1),[A,I]=E.useState(0);E.useEffect(()=>{const V=[a,c,g,x].filter(Boolean).length;I(V)},[a,c,g,x]);const z=()=>{n||i(""),u(""),y(""),k("")},U=a||c||g||x,B=E.useMemo(()=>{const V={};return a&&(V.company=a),c&&(V.department=c),g&&(V.maintenance_status=g),x&&(V.assign_to_name=x),V},[a,c,g,x]);return t.jsxs("div",{className:"flex flex-col h-screen bg-gray-50 dark:bg-gray-900 overflow-hidden",children:[t.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:[t.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-3 md:gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t.jsx(al,{className:"text-blue-600 dark:text-blue-400 flex-shrink-0",size:22}),t.jsx("div",{className:"min-w-0",children:t.jsx("h1",{className:"text-lg md:text-xl font-bold text-gray-800 dark:text-white whitespace-nowrap",children:"Maintenance Calendar"})})]}),t.jsxs("div",{className:"flex items-end gap-2 md:gap-3 flex-wrap md:flex-nowrap",children:[t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"View Type"}),t.jsxs("select",{value:N,onChange:V=>C(V.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:[t.jsx("option",{value:"maintenance-log",children:"Maintenance Log"}),t.jsx("option",{value:"ppm-planner",children:"PPM Planner"})]})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1 invisible",children:"Filters"}),t.jsxs("button",{onClick:()=>D(!O),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 ${U?"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:[t.jsx(Ri,{size:14}),t.jsx("span",{className:"hidden sm:inline",children:"Filters"}),A>0&&t.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:A}),O?t.jsx(Vl,{size:12}):t.jsx(nl,{size:12})]})]}),N==="ppm-planner"&&t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1 invisible",children:"Yearly Map"}),t.jsxs("button",{onClick:()=>e("/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:"View Yearly PPM Planner Map",children:[t.jsx(uC,{size:14}),t.jsx("span",{className:"hidden sm:inline",children:"Yearly Map"}),t.jsx("span",{className:"sm:hidden",children:"Map"})]})]})]})]}),O&&t.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:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[t.jsxs("div",{className:"relative z-[60]",children:[t.jsx(er,{label:"Hospital",doctype:"Company",value:a,onChange:i,placeholder:"Select Hospital",compact:!0,disabled:n}),a&&!n&&t.jsx("button",{onClick:()=>i(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[55]",children:[t.jsx(er,{label:"Department",doctype:"Department",value:c,onChange:V=>u(V),placeholder:"All Departments",compact:!0}),c&&t.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Status"}),t.jsxs("select",{value:g,onChange:V=>y(V.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:[t.jsx("option",{value:"",children:"All Statuses"}),t.jsx("option",{value:"Planned",children:"Planned"}),t.jsx("option",{value:"Completed",children:"Completed"}),t.jsx("option",{value:"Overdue",children:"Overdue"}),t.jsx("option",{value:"Cancelled",children:"Cancelled"})]}),g&&t.jsx("button",{onClick:()=>y(""),className:"absolute right-8 top-7 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[50]",children:[t.jsx(er,{label:"Assigned To",doctype:"User",value:x,onChange:V=>k(V),placeholder:"All Technicians",compact:!0}),x&&t.jsx("button",{onClick:()=>k(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]})]}),U&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsxs("button",{onClick:z,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:[t.jsx(qt,{}),"Clear Filters"]})})]})]}),t.jsx("div",{className:"flex-1 overflow-hidden px-3 pb-3 lg:px-4 lg:pb-4",children:t.jsx(lP,{filters:B,viewType:N,timeView:"day-month"})})]})},P_=()=>{const e=ua(),[r,a]=E.useState(2025),[n,i]=E.useState(2030),c=E.useMemo(()=>({}),[]),u=E.useMemo(()=>({}),[]),{pmSchedules:g,loading:y,error:x}=i1(c,1e3,0,"creation desc",u),k=(A,I,z,U,B)=>{const V=A.toLowerCase().trim(),Z=I.getFullYear(),W=I.getMonth(),H=new Date(U,B,1),le=new Date(U,B+1,0,23,59,59,999);if(H>z||le<I)return!1;const Q=(U-Z)*12+(B-W);switch(V){case"daily":return H<=z&&le>=I;case"weekly":return H<=z&&le>=I;case"monthly":return Q>=0&&H<=z;case"quarterly":return Q>=0&&Q%3===0&&H<=z;case"half-yearly":case"half yearly":return Q>=0&&Q%6===0&&H<=z;case"yearly":case"annually":return B===W&&H<=z&&H>=I;case"2 yearly":case"2-yearly":return Q>=0&&Q%24===0&&H<=z;case"3 yearly":case"3-yearly":return Q>=0&&Q%36===0&&H<=z;default:return H<=z&&le>=I}},N=E.useMemo(()=>{const A={};for(let I=r;I<=n;I++){A[I]={};for(let z=0;z<12;z++)A[I][z]=[]}return g.forEach(I=>{let z=null,U=null;if(I.start_date){const[Z,W,H]=I.start_date.split("-").map(Number)}if(I.end_date){const[Z,W,H]=I.end_date.split("-").map(Number);z=new Date(Z,W-1,H)}if(I.due_date){const[Z,W,H]=I.due_date.split("-").map(Number);U=new Date(Z,W-1,H)}if(!U)return;const B=z||U,V=I.periodicity||"monthly";for(let Z=r;Z<=n;Z++)for(let W=0;W<12;W++)k(V,U,B,Z,W)&&(A[Z][W].some(le=>le.name===I.name)||A[Z][W].push(I))}),A},[g,r,n]);E.useEffect(()=>{y||(console.log("[YearlyPPMPlannerPage] PM Schedules count:",g.length),console.log("[YearlyPPMPlannerPage] Matrix years:",r,"to",n))},[g,y,r,n]);const C=A=>{a(I=>I+A),i(I=>I+A)},O=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],D=Array.from({length:n-r+1},(A,I)=>r+I);return t.jsxs("div",{className:"flex flex-col h-screen bg-gray-50 dark:bg-gray-900 overflow-hidden",children:[t.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:t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>e("/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:t.jsx(bi,{className:"text-gray-600 dark:text-gray-400",size:18})}),t.jsx(al,{className:"text-blue-600 dark:text-blue-400",size:24}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-gray-800 dark:text-white",children:"Site or Cluster PPM Calendar"}),t.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"View PM Schedule Generators across multiple years"})]})]}),t.jsxs("button",{onClick:()=>e("/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:[t.jsx(df,{size:14}),"Month"]})]})}),t.jsx("div",{className:"flex-shrink-0 px-3 lg:px-4 py-2",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700 p-2",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("button",{onClick:()=>C(-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:t.jsx(Ew,{})}),t.jsxs("h2",{className:"text-lg font-bold text-gray-800 dark:text-white",children:[r," - ",n]}),t.jsx("button",{onClick:()=>C(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:t.jsx(jw,{})})]})})}),t.jsx("div",{className:"flex-1 overflow-auto px-3 pb-3 lg:px-4 lg:pb-4",children:y?t.jsxs("div",{className:"flex items-center justify-center h-full",children:[t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"}),t.jsx("span",{className:"ml-3 text-gray-600 dark:text-gray-400",children:"Loading PPM Planners..."})]}):x?t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:t.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["Error loading PPM Planners: ",x]})})}):t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full border-collapse",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 sticky top-0 z-10",children:t.jsxs("tr",{children:[t.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"}),O.map((A,I)=>t.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:A},I))]})}),t.jsx("tbody",{children:D.map(A=>t.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[t.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:A}),O.map((I,z)=>{var B;const U=((B=N[A])==null?void 0:B[z])||[];return t.jsx("td",{className:"border border-gray-300 dark:border-gray-600 px-2 py-2 align-top min-h-[60px]",children:U.length>0?t.jsx("div",{className:"space-y-1",children:U.map(V=>{const Z=V.pm_for||V.pm_for||V["PM Name"]||null;U.indexOf(V)===0&&console.log("[YearlyCalendar] 🔍 SCHEDULE IN CELL:",{name:V.name,pm_for:V.pm_for,"pm_for (bracket)":V.pm_for,allKeys:Object.keys(V),pmName:Z});const W=Z||V.name||"PPM Planner",H=[];V.name&&H.push(V.name),V.modality&&H.push(V.modality),V.hospital&&H.push(V.hospital);const le=H.length>0?`${H.join(" - ")} - Click to view details`:"Click to view details";return t.jsx("div",{onClick:()=>e(`/ppm-planner/${V.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:le,children:t.jsx("div",{className:"font-medium text-blue-900 dark:text-blue-300 leading-tight group-hover:underline break-words",children:W})},V.name)})}):t.jsx("div",{className:"text-xs text-gray-300 dark:text-gray-700 text-center py-1",children:"-"})},z)})]},A))})]})})})})]})};function Rk(e,r){const a=E.useRef(r);E.useEffect(function(){r!==a.current&&e.attributionControl!=null&&(a.current!=null&&e.attributionControl.removeAttribution(a.current),r!=null&&e.attributionControl.addAttribution(r)),a.current=r},[e,r])}const dP=1;function uP(e){return Object.freeze({__version:dP,map:e})}function hP(e,r){return Object.freeze(_e(_e({},e),r))}const o1=E.createContext(null);function l1(){const e=E.use(o1);if(e==null)throw new Error("No context provided: useLeafletContext() can only be used in a descendant of <MapContainer>");return e}function fP(e){function r(a,n){const{instance:i,context:c}=e(a).current;E.useImperativeHandle(n,()=>i);const{children:u}=a;return u==null?null:ea.createElement(o1,{value:c},u)}return E.forwardRef(r)}function mP(e){function r(a,n){const[i,c]=E.useState(!1),{instance:u}=e(a,c).current;E.useImperativeHandle(n,()=>u),E.useEffect(function(){i&&u.update()},[u,i,a.children]);const g=u._contentNode;return g?Su.createPortal(a.children,g):null}return E.forwardRef(r)}function gP(e){function r(a,n){const{instance:i}=e(a).current;return E.useImperativeHandle(n,()=>i),null}return E.forwardRef(r)}function Mk(e,r){const a=E.useRef(void 0);E.useEffect(function(){return r!=null&&e.instance.on(r),a.current=r,function(){a.current!=null&&e.instance.off(a.current),a.current=null}},[e,r])}function c1(e,r){var n;const a=(n=e.pane)!=null?n:r.pane;return a?$e(_e({},e),{pane:a}):e}function xP(e,r){return function(n,i){const c=l1(),u=e(c1(n,c),c);return Rk(c.map,n.attribution),Mk(u.current,n.eventHandlers),r(u.current,c,n,i),u}}var tu={exports:{}};var pP=tu.exports,F_;function yP(){return F_||(F_=1,(function(e,r){(function(a,n){n(r)})(pP,(function(a){var n="1.9.4";function i(h){var v,j,F,Y;for(j=1,F=arguments.length;j<F;j++){Y=arguments[j];for(v in Y)h[v]=Y[v]}return h}var c=Object.create||(function(){function h(){}return function(v){return h.prototype=v,new h}})();function u(h,v){var j=Array.prototype.slice;if(h.bind)return h.bind.apply(h,j.call(arguments,1));var F=j.call(arguments,2);return function(){return h.apply(v,F.length?F.concat(j.call(arguments)):arguments)}}var g=0;function y(h){return"_leaflet_id"in h||(h._leaflet_id=++g),h._leaflet_id}function x(h,v,j){var F,Y,he,Me;return Me=function(){F=!1,Y&&(he.apply(j,Y),Y=!1)},he=function(){F?Y=arguments:(h.apply(j,arguments),setTimeout(Me,v),F=!0)},he}function k(h,v,j){var F=v[1],Y=v[0],he=F-Y;return h===F&&j?h:((h-Y)%he+he)%he+Y}function N(){return!1}function C(h,v){if(v===!1)return h;var j=Math.pow(10,v===void 0?6:v);return Math.round(h*j)/j}function O(h){return h.trim?h.trim():h.replace(/^\s+|\s+$/g,"")}function D(h){return O(h).split(/\s+/)}function A(h,v){Object.prototype.hasOwnProperty.call(h,"options")||(h.options=h.options?c(h.options):{});for(var j in v)h.options[j]=v[j];return h.options}function I(h,v,j){var F=[];for(var Y in h)F.push(encodeURIComponent(j?Y.toUpperCase():Y)+"="+encodeURIComponent(h[Y]));return(!v||v.indexOf("?")===-1?"?":"&")+F.join("&")}var z=/\{ *([\w_ -]+) *\}/g;function U(h,v){return h.replace(z,function(j,F){var Y=v[F];if(Y===void 0)throw new Error("No value provided for variable "+j);return typeof Y=="function"&&(Y=Y(v)),Y})}var B=Array.isArray||function(h){return Object.prototype.toString.call(h)==="[object Array]"};function V(h,v){for(var j=0;j<h.length;j++)if(h[j]===v)return j;return-1}var Z="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function W(h){return window["webkit"+h]||window["moz"+h]||window["ms"+h]}var H=0;function le(h){var v=+new Date,j=Math.max(0,16-(v-H));return H=v+j,window.setTimeout(h,j)}var Q=window.requestAnimationFrame||W("RequestAnimationFrame")||le,Ne=window.cancelAnimationFrame||W("CancelAnimationFrame")||W("CancelRequestAnimationFrame")||function(h){window.clearTimeout(h)};function oe(h,v,j){if(j&&Q===le)h.call(v);else return Q.call(window,u(h,v))}function se(h){h&&Ne.call(window,h)}var ce={__proto__:null,extend:i,create:c,bind:u,get lastId(){return g},stamp:y,throttle:x,wrapNum:k,falseFn:N,formatNum:C,trim:O,splitWords:D,setOptions:A,getParamString:I,template:U,isArray:B,indexOf:V,emptyImageUrl:Z,requestFn:Q,cancelFn:Ne,requestAnimFrame:oe,cancelAnimFrame:se};function Ce(){}Ce.extend=function(h){var v=function(){A(this),this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()},j=v.__super__=this.prototype,F=c(j);F.constructor=v,v.prototype=F;for(var Y in this)Object.prototype.hasOwnProperty.call(this,Y)&&Y!=="prototype"&&Y!=="__super__"&&(v[Y]=this[Y]);return h.statics&&i(v,h.statics),h.includes&&(ae(h.includes),i.apply(null,[F].concat(h.includes))),i(F,h),delete F.statics,delete F.includes,F.options&&(F.options=j.options?c(j.options):{},i(F.options,h.options)),F._initHooks=[],F.callInitHooks=function(){if(!this._initHooksCalled){j.callInitHooks&&j.callInitHooks.call(this),this._initHooksCalled=!0;for(var he=0,Me=F._initHooks.length;he<Me;he++)F._initHooks[he].call(this)}},v},Ce.include=function(h){var v=this.prototype.options;return i(this.prototype,h),h.options&&(this.prototype.options=v,this.mergeOptions(h.options)),this},Ce.mergeOptions=function(h){return i(this.prototype.options,h),this},Ce.addInitHook=function(h){var v=Array.prototype.slice.call(arguments,1),j=typeof h=="function"?h:function(){this[h].apply(this,v)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(j),this};function ae(h){if(!(typeof L=="undefined"||!L||!L.Mixin)){h=B(h)?h:[h];for(var v=0;v<h.length;v++)h[v]===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 me={on:function(h,v,j){if(typeof h=="object")for(var F in h)this._on(F,h[F],v);else{h=D(h);for(var Y=0,he=h.length;Y<he;Y++)this._on(h[Y],v,j)}return this},off:function(h,v,j){if(!arguments.length)delete this._events;else if(typeof h=="object")for(var F in h)this._off(F,h[F],v);else{h=D(h);for(var Y=arguments.length===1,he=0,Me=h.length;he<Me;he++)Y?this._off(h[he]):this._off(h[he],v,j)}return this},_on:function(h,v,j,F){if(typeof v!="function"){console.warn("wrong listener type: "+typeof v);return}if(this._listens(h,v,j)===!1){j===this&&(j=void 0);var Y={fn:v,ctx:j};F&&(Y.once=!0),this._events=this._events||{},this._events[h]=this._events[h]||[],this._events[h].push(Y)}},_off:function(h,v,j){var F,Y,he;if(this._events&&(F=this._events[h],!!F)){if(arguments.length===1){if(this._firingCount)for(Y=0,he=F.length;Y<he;Y++)F[Y].fn=N;delete this._events[h];return}if(typeof v!="function"){console.warn("wrong listener type: "+typeof v);return}var Me=this._listens(h,v,j);if(Me!==!1){var Ye=F[Me];this._firingCount&&(Ye.fn=N,this._events[h]=F=F.slice()),F.splice(Me,1)}}},fire:function(h,v,j){if(!this.listens(h,j))return this;var F=i({},v,{type:h,target:this,sourceTarget:v&&v.sourceTarget||this});if(this._events){var Y=this._events[h];if(Y){this._firingCount=this._firingCount+1||1;for(var he=0,Me=Y.length;he<Me;he++){var Ye=Y[he],ct=Ye.fn;Ye.once&&this.off(h,ct,Ye.ctx),ct.call(Ye.ctx||this,F)}this._firingCount--}}return j&&this._propagateEvent(F),this},listens:function(h,v,j,F){typeof h!="string"&&console.warn('"string" type argument expected');var Y=v;typeof v!="function"&&(F=!!v,Y=void 0,j=void 0);var he=this._events&&this._events[h];if(he&&he.length&&this._listens(h,Y,j)!==!1)return!0;if(F){for(var Me in this._eventParents)if(this._eventParents[Me].listens(h,v,j,F))return!0}return!1},_listens:function(h,v,j){if(!this._events)return!1;var F=this._events[h]||[];if(!v)return!!F.length;j===this&&(j=void 0);for(var Y=0,he=F.length;Y<he;Y++)if(F[Y].fn===v&&F[Y].ctx===j)return Y;return!1},once:function(h,v,j){if(typeof h=="object")for(var F in h)this._on(F,h[F],v,!0);else{h=D(h);for(var Y=0,he=h.length;Y<he;Y++)this._on(h[Y],v,j,!0)}return this},addEventParent:function(h){return this._eventParents=this._eventParents||{},this._eventParents[y(h)]=h,this},removeEventParent:function(h){return this._eventParents&&delete this._eventParents[y(h)],this},_propagateEvent:function(h){for(var v in this._eventParents)this._eventParents[v].fire(h.type,i({layer:h.target,propagatedFrom:h.target},h),!0)}};me.addEventListener=me.on,me.removeEventListener=me.clearAllEventListeners=me.off,me.addOneTimeEventListener=me.once,me.fireEvent=me.fire,me.hasEventListeners=me.listens;var K=Ce.extend(me);function fe(h,v,j){this.x=j?Math.round(h):h,this.y=j?Math.round(v):v}var Oe=Math.trunc||function(h){return h>0?Math.floor(h):Math.ceil(h)};fe.prototype={clone:function(){return new fe(this.x,this.y)},add:function(h){return this.clone()._add(ye(h))},_add:function(h){return this.x+=h.x,this.y+=h.y,this},subtract:function(h){return this.clone()._subtract(ye(h))},_subtract:function(h){return this.x-=h.x,this.y-=h.y,this},divideBy:function(h){return this.clone()._divideBy(h)},_divideBy:function(h){return this.x/=h,this.y/=h,this},multiplyBy:function(h){return this.clone()._multiplyBy(h)},_multiplyBy:function(h){return this.x*=h,this.y*=h,this},scaleBy:function(h){return new fe(this.x*h.x,this.y*h.y)},unscaleBy:function(h){return new fe(this.x/h.x,this.y/h.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(h){h=ye(h);var v=h.x-this.x,j=h.y-this.y;return Math.sqrt(v*v+j*j)},equals:function(h){return h=ye(h),h.x===this.x&&h.y===this.y},contains:function(h){return h=ye(h),Math.abs(h.x)<=Math.abs(this.x)&&Math.abs(h.y)<=Math.abs(this.y)},toString:function(){return"Point("+C(this.x)+", "+C(this.y)+")"}};function ye(h,v,j){return h instanceof fe?h:B(h)?new fe(h[0],h[1]):h==null?h:typeof h=="object"&&"x"in h&&"y"in h?new fe(h.x,h.y):new fe(h,v,j)}function J(h,v){if(h)for(var j=v?[h,v]:h,F=0,Y=j.length;F<Y;F++)this.extend(j[F])}J.prototype={extend:function(h){var v,j;if(!h)return this;if(h instanceof fe||typeof h[0]=="number"||"x"in h)v=j=ye(h);else if(h=G(h),v=h.min,j=h.max,!v||!j)return this;return!this.min&&!this.max?(this.min=v.clone(),this.max=j.clone()):(this.min.x=Math.min(v.x,this.min.x),this.max.x=Math.max(j.x,this.max.x),this.min.y=Math.min(v.y,this.min.y),this.max.y=Math.max(j.y,this.max.y)),this},getCenter:function(h){return ye((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,h)},getBottomLeft:function(){return ye(this.min.x,this.max.y)},getTopRight:function(){return ye(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(h){var v,j;return typeof h[0]=="number"||h instanceof fe?h=ye(h):h=G(h),h instanceof J?(v=h.min,j=h.max):v=j=h,v.x>=this.min.x&&j.x<=this.max.x&&v.y>=this.min.y&&j.y<=this.max.y},intersects:function(h){h=G(h);var v=this.min,j=this.max,F=h.min,Y=h.max,he=Y.x>=v.x&&F.x<=j.x,Me=Y.y>=v.y&&F.y<=j.y;return he&&Me},overlaps:function(h){h=G(h);var v=this.min,j=this.max,F=h.min,Y=h.max,he=Y.x>v.x&&F.x<j.x,Me=Y.y>v.y&&F.y<j.y;return he&&Me},isValid:function(){return!!(this.min&&this.max)},pad:function(h){var v=this.min,j=this.max,F=Math.abs(v.x-j.x)*h,Y=Math.abs(v.y-j.y)*h;return G(ye(v.x-F,v.y-Y),ye(j.x+F,j.y+Y))},equals:function(h){return h?(h=G(h),this.min.equals(h.getTopLeft())&&this.max.equals(h.getBottomRight())):!1}};function G(h,v){return!h||h instanceof J?h:new J(h,v)}function ie(h,v){if(h)for(var j=v?[h,v]:h,F=0,Y=j.length;F<Y;F++)this.extend(j[F])}ie.prototype={extend:function(h){var v=this._southWest,j=this._northEast,F,Y;if(h instanceof ne)F=h,Y=h;else if(h instanceof ie){if(F=h._southWest,Y=h._northEast,!F||!Y)return this}else return h?this.extend(ve(h)||re(h)):this;return!v&&!j?(this._southWest=new ne(F.lat,F.lng),this._northEast=new ne(Y.lat,Y.lng)):(v.lat=Math.min(F.lat,v.lat),v.lng=Math.min(F.lng,v.lng),j.lat=Math.max(Y.lat,j.lat),j.lng=Math.max(Y.lng,j.lng)),this},pad:function(h){var v=this._southWest,j=this._northEast,F=Math.abs(v.lat-j.lat)*h,Y=Math.abs(v.lng-j.lng)*h;return new ie(new ne(v.lat-F,v.lng-Y),new ne(j.lat+F,j.lng+Y))},getCenter:function(){return new ne((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 ne(this.getNorth(),this.getWest())},getSouthEast:function(){return new ne(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(h){typeof h[0]=="number"||h instanceof ne||"lat"in h?h=ve(h):h=re(h);var v=this._southWest,j=this._northEast,F,Y;return h instanceof ie?(F=h.getSouthWest(),Y=h.getNorthEast()):F=Y=h,F.lat>=v.lat&&Y.lat<=j.lat&&F.lng>=v.lng&&Y.lng<=j.lng},intersects:function(h){h=re(h);var v=this._southWest,j=this._northEast,F=h.getSouthWest(),Y=h.getNorthEast(),he=Y.lat>=v.lat&&F.lat<=j.lat,Me=Y.lng>=v.lng&&F.lng<=j.lng;return he&&Me},overlaps:function(h){h=re(h);var v=this._southWest,j=this._northEast,F=h.getSouthWest(),Y=h.getNorthEast(),he=Y.lat>v.lat&&F.lat<j.lat,Me=Y.lng>v.lng&&F.lng<j.lng;return he&&Me},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(h,v){return h?(h=re(h),this._southWest.equals(h.getSouthWest(),v)&&this._northEast.equals(h.getNorthEast(),v)):!1},isValid:function(){return!!(this._southWest&&this._northEast)}};function re(h,v){return h instanceof ie?h:new ie(h,v)}function ne(h,v,j){if(isNaN(h)||isNaN(v))throw new Error("Invalid LatLng object: ("+h+", "+v+")");this.lat=+h,this.lng=+v,j!==void 0&&(this.alt=+j)}ne.prototype={equals:function(h,v){if(!h)return!1;h=ve(h);var j=Math.max(Math.abs(this.lat-h.lat),Math.abs(this.lng-h.lng));return j<=(v===void 0?1e-9:v)},toString:function(h){return"LatLng("+C(this.lat,h)+", "+C(this.lng,h)+")"},distanceTo:function(h){return Ae.distance(this,ve(h))},wrap:function(){return Ae.wrapLatLng(this)},toBounds:function(h){var v=180*h/40075017,j=v/Math.cos(Math.PI/180*this.lat);return re([this.lat-v,this.lng-j],[this.lat+v,this.lng+j])},clone:function(){return new ne(this.lat,this.lng,this.alt)}};function ve(h,v,j){return h instanceof ne?h:B(h)&&typeof h[0]!="object"?h.length===3?new ne(h[0],h[1],h[2]):h.length===2?new ne(h[0],h[1]):null:h==null?h:typeof h=="object"&&"lat"in h?new ne(h.lat,"lng"in h?h.lng:h.lon,h.alt):v===void 0?null:new ne(h,v,j)}var Ve={latLngToPoint:function(h,v){var j=this.projection.project(h),F=this.scale(v);return this.transformation._transform(j,F)},pointToLatLng:function(h,v){var j=this.scale(v),F=this.transformation.untransform(h,j);return this.projection.unproject(F)},project:function(h){return this.projection.project(h)},unproject:function(h){return this.projection.unproject(h)},scale:function(h){return 256*Math.pow(2,h)},zoom:function(h){return Math.log(h/256)/Math.LN2},getProjectedBounds:function(h){if(this.infinite)return null;var v=this.projection.bounds,j=this.scale(h),F=this.transformation.transform(v.min,j),Y=this.transformation.transform(v.max,j);return new J(F,Y)},infinite:!1,wrapLatLng:function(h){var v=this.wrapLng?k(h.lng,this.wrapLng,!0):h.lng,j=this.wrapLat?k(h.lat,this.wrapLat,!0):h.lat,F=h.alt;return new ne(j,v,F)},wrapLatLngBounds:function(h){var v=h.getCenter(),j=this.wrapLatLng(v),F=v.lat-j.lat,Y=v.lng-j.lng;if(F===0&&Y===0)return h;var he=h.getSouthWest(),Me=h.getNorthEast(),Ye=new ne(he.lat-F,he.lng-Y),ct=new ne(Me.lat-F,Me.lng-Y);return new ie(Ye,ct)}},Ae=i({},Ve,{wrapLng:[-180,180],R:6371e3,distance:function(h,v){var j=Math.PI/180,F=h.lat*j,Y=v.lat*j,he=Math.sin((v.lat-h.lat)*j/2),Me=Math.sin((v.lng-h.lng)*j/2),Ye=he*he+Math.cos(F)*Math.cos(Y)*Me*Me,ct=2*Math.atan2(Math.sqrt(Ye),Math.sqrt(1-Ye));return this.R*ct}}),ze=6378137,Re={R:ze,MAX_LATITUDE:85.0511287798,project:function(h){var v=Math.PI/180,j=this.MAX_LATITUDE,F=Math.max(Math.min(j,h.lat),-j),Y=Math.sin(F*v);return new fe(this.R*h.lng*v,this.R*Math.log((1+Y)/(1-Y))/2)},unproject:function(h){var v=180/Math.PI;return new ne((2*Math.atan(Math.exp(h.y/this.R))-Math.PI/2)*v,h.x*v/this.R)},bounds:(function(){var h=ze*Math.PI;return new J([-h,-h],[h,h])})()};function Ze(h,v,j,F){if(B(h)){this._a=h[0],this._b=h[1],this._c=h[2],this._d=h[3];return}this._a=h,this._b=v,this._c=j,this._d=F}Ze.prototype={transform:function(h,v){return this._transform(h.clone(),v)},_transform:function(h,v){return v=v||1,h.x=v*(this._a*h.x+this._b),h.y=v*(this._c*h.y+this._d),h},untransform:function(h,v){return v=v||1,new fe((h.x/v-this._b)/this._a,(h.y/v-this._d)/this._c)}};function Lt(h,v,j,F){return new Ze(h,v,j,F)}var mt=i({},Ae,{code:"EPSG:3857",projection:Re,transformation:(function(){var h=.5/(Math.PI*Re.R);return Lt(h,.5,-h,.5)})()}),Zt=i({},mt,{code:"EPSG:900913"});function ar(h){return document.createElementNS("http://www.w3.org/2000/svg",h)}function or(h,v){var j="",F,Y,he,Me,Ye,ct;for(F=0,he=h.length;F<he;F++){for(Ye=h[F],Y=0,Me=Ye.length;Y<Me;Y++)ct=Ye[Y],j+=(Y?"L":"M")+ct.x+" "+ct.y;j+=v?Ut.svg?"z":"x":""}return j||"M0 0"}var yt=document.documentElement.style,nr="ActiveXObject"in window,$t=nr&&!document.addEventListener,Er="msLaunchUri"in navigator&&!("documentMode"in document),St=Vt("webkit"),Br=Vt("android"),Pt=Vt("android 2")||Vt("android 3"),it=parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1],10),De=Br&&Vt("Google")&&it<537&&!("AudioNode"in window),Je=!!window.opera,Be=!Er&&Vt("chrome"),vt=Vt("gecko")&&!St&&!Je&&!nr,jt=!Be&&Vt("safari"),Ct=Vt("phantom"),Wt="OTransition"in yt,pr=navigator.platform.indexOf("Win")===0,Ge=nr&&"transition"in yt,We="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!Pt,At="MozPerspective"in yt,lt=!window.L_DISABLE_3D&&(Ge||We||At)&&!Wt&&!Ct,Dt=typeof orientation!="undefined"||Vt("mobile"),mr=Dt&&St,tr=Dt&&We,pt=!window.PointerEvent&&window.MSPointerEvent,Jt=!!(window.PointerEvent||pt),vr="ontouchstart"in window||!!window.TouchEvent,Ir=!window.L_NO_TOUCH&&(vr||Jt),Le=Dt&&Je,qe=Dt&&vt,Ke=(window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI)>1,Yt=(function(){var h=!1;try{var v=Object.defineProperty({},"passive",{get:function(){h=!0}});window.addEventListener("testPassiveEventSupport",N,v),window.removeEventListener("testPassiveEventSupport",N,v)}catch(j){}return h})(),gr=(function(){return!!document.createElement("canvas").getContext})(),jr=!!(document.createElementNS&&ar("svg").createSVGRect),Zr=!!jr&&(function(){var h=document.createElement("div");return h.innerHTML="<svg/>",(h.firstChild&&h.firstChild.namespaceURI)==="http://www.w3.org/2000/svg"})(),en=!jr&&(function(){try{var h=document.createElement("div");h.innerHTML='<v:shape adj="1"/>';var v=h.firstChild;return v.style.behavior="url(#default#VML)",v&&typeof v.adj=="object"}catch(j){return!1}})(),Qt=navigator.platform.indexOf("Mac")===0,wr=navigator.platform.indexOf("Linux")===0;function Vt(h){return navigator.userAgent.toLowerCase().indexOf(h)>=0}var Ut={ie:nr,ielt9:$t,edge:Er,webkit:St,android:Br,android23:Pt,androidStock:De,opera:Je,chrome:Be,gecko:vt,safari:jt,phantom:Ct,opera12:Wt,win:pr,ie3d:Ge,webkit3d:We,gecko3d:At,any3d:lt,mobile:Dt,mobileWebkit:mr,mobileWebkit3d:tr,msPointer:pt,pointer:Jt,touch:Ir,touchNative:vr,mobileOpera:Le,mobileGecko:qe,retina:Ke,passiveEvents:Yt,canvas:gr,svg:jr,vml:en,inlineSvg:Zr,mac:Qt,linux:wr},de=Ut.msPointer?"MSPointerDown":"pointerdown",ge=Ut.msPointer?"MSPointerMove":"pointermove",be=Ut.msPointer?"MSPointerUp":"pointerup",we=Ut.msPointer?"MSPointerCancel":"pointercancel",ke={touchstart:de,touchmove:ge,touchend:be,touchcancel:we},Te={touchstart:Kt,touchmove:zt,touchend:zt,touchcancel:zt},Qe={},bt=!1;function et(h,v,j){return v==="touchstart"&&Ht(),Te[v]?(j=Te[v].bind(this,j),h.addEventListener(ke[v],j,!1),j):(console.warn("wrong event specified:",v),N)}function at(h,v,j){if(!ke[v]){console.warn("wrong event specified:",v);return}h.removeEventListener(ke[v],j,!1)}function nt(h){Qe[h.pointerId]=h}function Ot(h){Qe[h.pointerId]&&(Qe[h.pointerId]=h)}function It(h){delete Qe[h.pointerId]}function Ht(){bt||(document.addEventListener(de,nt,!0),document.addEventListener(ge,Ot,!0),document.addEventListener(be,It,!0),document.addEventListener(we,It,!0),bt=!0)}function zt(h,v){if(v.pointerType!==(v.MSPOINTER_TYPE_MOUSE||"mouse")){v.touches=[];for(var j in Qe)v.touches.push(Qe[j]);v.changedTouches=[v],h(v)}}function Kt(h,v){v.MSPOINTER_TYPE_TOUCH&&v.pointerType===v.MSPOINTER_TYPE_TOUCH&&qa(v),zt(h,v)}function fr(h){var v={},j,F;for(F in h)j=h[F],v[F]=j&&j.bind?j.bind(h):j;return h=v,v.type="dblclick",v.detail=2,v.isTrusted=!1,v._simulated=!0,v}var Ee=200;function wt(h,v){h.addEventListener("dblclick",v);var j=0,F;function Y(he){if(he.detail!==1){F=he.detail;return}if(!(he.pointerType==="mouse"||he.sourceCapabilities&&!he.sourceCapabilities.firesTouchEvents)){var Me=Qs(he);if(!(Me.some(function(ct){return ct instanceof HTMLLabelElement&&ct.attributes.for})&&!Me.some(function(ct){return ct instanceof HTMLInputElement||ct instanceof HTMLSelectElement}))){var Ye=Date.now();Ye-j<=Ee?(F++,F===2&&v(fr(he))):F=1,j=Ye}}}return h.addEventListener("click",Y),{dblclick:v,simDblclick:Y}}function xr(h,v){h.removeEventListener("dblclick",v.dblclick),h.removeEventListener("click",v.simDblclick)}var qr=rt(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),Za=rt(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),Tr=Za==="webkitTransition"||Za==="OTransition"?Za+"End":"transitionend";function Ar(h){return typeof h=="string"?document.getElementById(h):h}function Pe(h,v){var j=h.style[v]||h.currentStyle&&h.currentStyle[v];if((!j||j==="auto")&&document.defaultView){var F=document.defaultView.getComputedStyle(h,null);j=F?F[v]:null}return j==="auto"?null:j}function kt(h,v,j){var F=document.createElement(h);return F.className=v||"",j&&j.appendChild(F),F}function Sr(h){var v=h.parentNode;v&&v.removeChild(h)}function la(h){for(;h.firstChild;)h.removeChild(h.firstChild)}function Dr(h){var v=h.parentNode;v&&v.lastChild!==h&&v.appendChild(h)}function Da(h){var v=h.parentNode;v&&v.firstChild!==h&&v.insertBefore(h,v.firstChild)}function Un(h,v){if(h.classList!==void 0)return h.classList.contains(v);var j=_s(h);return j.length>0&&new RegExp("(^|\\s)"+v+"(\\s|$)").test(j)}function hr(h,v){if(h.classList!==void 0)for(var j=D(v),F=0,Y=j.length;F<Y;F++)h.classList.add(j[F]);else if(!Un(h,v)){var he=_s(h);Rs(h,(he?he+" ":"")+v)}}function Jr(h,v){h.classList!==void 0?h.classList.remove(v):Rs(h,O((" "+_s(h)+" ").replace(" "+v+" "," ")))}function Rs(h,v){h.className.baseVal===void 0?h.className=v:h.className.baseVal=v}function _s(h){return h.correspondingElement&&(h=h.correspondingElement),h.className.baseVal===void 0?h.className:h.className.baseVal}function kr(h,v){"opacity"in h.style?h.style.opacity=v:"filter"in h.style&&sn(h,v)}function sn(h,v){var j=!1,F="DXImageTransform.Microsoft.Alpha";try{j=h.filters.item(F)}catch(Y){if(v===1)return}v=Math.round(v*100),j?(j.Enabled=v!==100,j.Opacity=v):h.style.filter+=" progid:"+F+"(opacity="+v+")"}function rt(h){for(var v=document.documentElement.style,j=0;j<h.length;j++)if(h[j]in v)return h[j];return!1}function Se(h,v,j){var F=v||new fe(0,0);h.style[qr]=(Ut.ie3d?"translate("+F.x+"px,"+F.y+"px)":"translate3d("+F.x+"px,"+F.y+"px,0)")+(j?" scale("+j+")":"")}function sr(h,v){h._leaflet_pos=v,Ut.any3d?Se(h,v):(h.style.left=v.x+"px",h.style.top=v.y+"px")}function Ea(h){return h._leaflet_pos||new fe(0,0)}var gn,Ms,jo;if("onselectstart"in document)gn=function(){Rr(window,"selectstart",qa)},Ms=function(){cr(window,"selectstart",qa)};else{var xn=rt(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]);gn=function(){if(xn){var h=document.documentElement.style;jo=h[xn],h[xn]="none"}},Ms=function(){xn&&(document.documentElement.style[xn]=jo,jo=void 0)}}function Nr(){Rr(window,"dragstart",qa)}function _a(){cr(window,"dragstart",qa)}var To,Jl;function vi(h){for(;h.tabIndex===-1;)h=h.parentNode;h.style&&(On(),To=h,Jl=h.style.outlineStyle,h.style.outlineStyle="none",Rr(window,"keydown",On))}function On(){To&&(To.style.outlineStyle=Jl,To=void 0,Jl=void 0,cr(window,"keydown",On))}function so(h){do h=h.parentNode;while((!h.offsetWidth||!h.offsetHeight)&&h!==document.body);return h}function Ao(h){var v=h.getBoundingClientRect();return{x:v.width/h.offsetWidth||1,y:v.height/h.offsetHeight||1,boundingClientRect:v}}var za={__proto__:null,TRANSFORM:qr,TRANSITION:Za,TRANSITION_END:Tr,get:Ar,getStyle:Pe,create:kt,remove:Sr,empty:la,toFront:Dr,toBack:Da,hasClass:Un,addClass:hr,removeClass:Jr,setClass:Rs,getClass:_s,setOpacity:kr,testProp:rt,setTransform:Se,setPosition:sr,getPosition:Ea,get disableTextSelection(){return gn},get enableTextSelection(){return Ms},disableImageDrag:Nr,enableImageDrag:_a,preventOutline:vi,restoreOutline:On,getSizedParentNode:so,getScale:Ao};function Rr(h,v,j,F){if(v&&typeof v=="object")for(var Y in v)wa(h,Y,v[Y],j);else{v=D(v);for(var he=0,Me=v.length;he<Me;he++)wa(h,v[he],j,F)}return this}var on="_leaflet_events";function cr(h,v,j,F){if(arguments.length===1)Ql(h),delete h[on];else if(v&&typeof v=="object")for(var Y in v)Oo(h,Y,v[Y],j);else if(v=D(v),arguments.length===2)Ql(h,function(Ye){return V(v,Ye)!==-1});else for(var he=0,Me=v.length;he<Me;he++)Oo(h,v[he],j,F);return this}function Ql(h,v){for(var j in h[on]){var F=j.split(/\d/)[0];(!v||v(F))&&Oo(h,F,null,null,j)}}var Fr={mouseenter:"mouseover",mouseleave:"mouseout",wheel:!("onwheel"in window)&&"mousewheel"};function wa(h,v,j,F){var Y=v+y(j)+(F?"_"+y(F):"");if(h[on]&&h[on][Y])return this;var he=function(Ye){return j.call(F||h,Ye||window.event)},Me=he;!Ut.touchNative&&Ut.pointer&&v.indexOf("touch")===0?he=et(h,v,he):Ut.touch&&v==="dblclick"?he=wt(h,he):"addEventListener"in h?v==="touchstart"||v==="touchmove"||v==="wheel"||v==="mousewheel"?h.addEventListener(Fr[v]||v,he,Ut.passiveEvents?{passive:!1}:!1):v==="mouseenter"||v==="mouseleave"?(he=function(Ye){Ye=Ye||window.event,Kn(h,Ye)&&Me(Ye)},h.addEventListener(Fr[v],he,!1)):h.addEventListener(v,Me,!1):h.attachEvent("on"+v,he),h[on]=h[on]||{},h[on][Y]=he}function Oo(h,v,j,F,Y){Y=Y||v+y(j)+(F?"_"+y(F):"");var he=h[on]&&h[on][Y];if(!he)return this;!Ut.touchNative&&Ut.pointer&&v.indexOf("touch")===0?at(h,v,he):Ut.touch&&v==="dblclick"?xr(h,he):"removeEventListener"in h?h.removeEventListener(Fr[v]||v,he,!1):h.detachEvent("on"+v,he),h[on][Y]=null}function Zn(h){return h.stopPropagation?h.stopPropagation():h.originalEvent?h.originalEvent._stopped=!0:h.cancelBubble=!0,this}function ws(h){return wa(h,"wheel",Zn),this}function qn(h){return Rr(h,"mousedown touchstart dblclick contextmenu",Zn),h._leaflet_disable_click=!0,this}function qa(h){return h.preventDefault?h.preventDefault():h.returnValue=!1,this}function us(h){return qa(h),Zn(h),this}function Qs(h){if(h.composedPath)return h.composedPath();for(var v=[],j=h.target;j;)v.push(j),j=j.parentNode;return v}function ei(h,v){if(!v)return new fe(h.clientX,h.clientY);var j=Ao(v),F=j.boundingClientRect;return new fe((h.clientX-F.left)/j.x-v.clientLeft,(h.clientY-F.top)/j.y-v.clientTop)}var ec=Ut.linux&&Ut.chrome?window.devicePixelRatio:Ut.mac?window.devicePixelRatio*3:window.devicePixelRatio>0?2*window.devicePixelRatio:1;function tn(h){return Ut.edge?h.wheelDeltaY/2:h.deltaY&&h.deltaMode===0?-h.deltaY/ec:h.deltaY&&h.deltaMode===1?-h.deltaY*20:h.deltaY&&h.deltaMode===2?-h.deltaY*60:h.deltaX||h.deltaZ?0:h.wheelDelta?(h.wheelDeltaY||h.wheelDelta)/2:h.detail&&Math.abs(h.detail)<32765?-h.detail*20:h.detail?h.detail/-32765*60:0}function Kn(h,v){var j=v.relatedTarget;if(!j)return!0;try{for(;j&&j!==h;)j=j.parentNode}catch(F){return!1}return j!==h}var pn={__proto__:null,on:Rr,off:cr,stopPropagation:Zn,disableScrollPropagation:ws,disableClickPropagation:qn,preventDefault:qa,stop:us,getPropagationPath:Qs,getMousePosition:ei,getWheelDelta:tn,isExternalTarget:Kn,addListener:Rr,removeListener:cr},Pi=K.extend({run:function(h,v,j,F){this.stop(),this._el=h,this._inProgress=!0,this._duration=j||.25,this._easeOutPower=1/Math.max(F||.5,.2),this._startPos=Ea(h),this._offset=v.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=oe(this._animate,this),this._step()},_step:function(h){var v=+new Date-this._startTime,j=this._duration*1e3;v<j?this._runFrame(this._easeOut(v/j),h):(this._runFrame(1),this._complete())},_runFrame:function(h,v){var j=this._startPos.add(this._offset.multiplyBy(h));v&&j._round(),sr(this._el,j),this.fire("step")},_complete:function(){se(this._animId),this._inProgress=!1,this.fire("end")},_easeOut:function(h){return 1-Math.pow(1-h,this._easeOutPower)}}),Qr=K.extend({options:{crs:mt,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(h,v){v=A(this,v),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(h),this._initLayout(),this._onResize=u(this._onResize,this),this._initEvents(),v.maxBounds&&this.setMaxBounds(v.maxBounds),v.zoom!==void 0&&(this._zoom=this._limitZoom(v.zoom)),v.center&&v.zoom!==void 0&&this.setView(ve(v.center),v.zoom,{reset:!0}),this.callInitHooks(),this._zoomAnimated=Za&&Ut.any3d&&!Ut.mobileOpera&&this.options.zoomAnimation,this._zoomAnimated&&(this._createAnimProxy(),Rr(this._proxy,Tr,this._catchTransitionEnd,this)),this._addLayers(this.options.layers)},setView:function(h,v,j){if(v=v===void 0?this._zoom:this._limitZoom(v),h=this._limitCenter(ve(h),v,this.options.maxBounds),j=j||{},this._stop(),this._loaded&&!j.reset&&j!==!0){j.animate!==void 0&&(j.zoom=i({animate:j.animate},j.zoom),j.pan=i({animate:j.animate,duration:j.duration},j.pan));var F=this._zoom!==v?this._tryAnimatedZoom&&this._tryAnimatedZoom(h,v,j.zoom):this._tryAnimatedPan(h,j.pan);if(F)return clearTimeout(this._sizeTimer),this}return this._resetView(h,v,j.pan&&j.pan.noMoveStart),this},setZoom:function(h,v){return this._loaded?this.setView(this.getCenter(),h,{zoom:v}):(this._zoom=h,this)},zoomIn:function(h,v){return h=h||(Ut.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom+h,v)},zoomOut:function(h,v){return h=h||(Ut.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom-h,v)},setZoomAround:function(h,v,j){var F=this.getZoomScale(v),Y=this.getSize().divideBy(2),he=h instanceof fe?h:this.latLngToContainerPoint(h),Me=he.subtract(Y).multiplyBy(1-1/F),Ye=this.containerPointToLatLng(Y.add(Me));return this.setView(Ye,v,{zoom:j})},_getBoundsCenterZoom:function(h,v){v=v||{},h=h.getBounds?h.getBounds():re(h);var j=ye(v.paddingTopLeft||v.padding||[0,0]),F=ye(v.paddingBottomRight||v.padding||[0,0]),Y=this.getBoundsZoom(h,!1,j.add(F));if(Y=typeof v.maxZoom=="number"?Math.min(v.maxZoom,Y):Y,Y===1/0)return{center:h.getCenter(),zoom:Y};var he=F.subtract(j).divideBy(2),Me=this.project(h.getSouthWest(),Y),Ye=this.project(h.getNorthEast(),Y),ct=this.unproject(Me.add(Ye).divideBy(2).add(he),Y);return{center:ct,zoom:Y}},fitBounds:function(h,v){if(h=re(h),!h.isValid())throw new Error("Bounds are not valid.");var j=this._getBoundsCenterZoom(h,v);return this.setView(j.center,j.zoom,v)},fitWorld:function(h){return this.fitBounds([[-90,-180],[90,180]],h)},panTo:function(h,v){return this.setView(h,this._zoom,{pan:v})},panBy:function(h,v){if(h=ye(h).round(),v=v||{},!h.x&&!h.y)return this.fire("moveend");if(v.animate!==!0&&!this.getSize().contains(h))return this._resetView(this.unproject(this.project(this.getCenter()).add(h)),this.getZoom()),this;if(this._panAnim||(this._panAnim=new Pi,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),v.noMoveStart||this.fire("movestart"),v.animate!==!1){hr(this._mapPane,"leaflet-pan-anim");var j=this._getMapPanePos().subtract(h).round();this._panAnim.run(this._mapPane,j,v.duration||.25,v.easeLinearity)}else this._rawPanBy(h),this.fire("move").fire("moveend");return this},flyTo:function(h,v,j){if(j=j||{},j.animate===!1||!Ut.any3d)return this.setView(h,v,j);this._stop();var F=this.project(this.getCenter()),Y=this.project(h),he=this.getSize(),Me=this._zoom;h=ve(h),v=v===void 0?Me:v;var Ye=Math.max(he.x,he.y),ct=Ye*this.getZoomScale(Me,v),Rt=Y.distanceTo(F)||1,lr=1.42,Cr=lr*lr;function Xr(rn){var Gi=rn?-1:1,Fo=rn?ct:Ye,u0=ct*ct-Ye*Ye+Gi*Cr*Cr*Rt*Rt,oc=2*Fo*Cr*Rt,lc=u0/oc,mo=Math.sqrt(lc*lc+1)-lc,$i=mo<1e-9?-18:Math.log(mo);return $i}function Dn(rn){return(Math.exp(rn)-Math.exp(-rn))/2}function cn(rn){return(Math.exp(rn)+Math.exp(-rn))/2}function Cs(rn){return Dn(rn)/cn(rn)}var xa=Xr(0);function pa(rn){return Ye*(cn(xa)/cn(xa+lr*rn))}function ra(rn){return Ye*(cn(xa)*Cs(xa+lr*rn)-Dn(xa))/Cr}function ho(rn){return 1-Math.pow(1-rn,1.5)}var Bs=Date.now(),Yc=(Xr(1)-xa)/lr,fo=j.duration?1e3*j.duration:1e3*Yc*.8;function d0(){var rn=(Date.now()-Bs)/fo,Gi=ho(rn)*Yc;rn<=1?(this._flyToFrame=oe(d0,this),this._move(this.unproject(F.add(Y.subtract(F).multiplyBy(ra(Gi)/Rt)),Me),this.getScaleZoom(Ye/pa(Gi),Me),{flyTo:!0})):this._move(h,v)._moveEnd(!0)}return this._moveStart(!0,j.noMoveStart),d0.call(this),this},flyToBounds:function(h,v){var j=this._getBoundsCenterZoom(h,v);return this.flyTo(j.center,j.zoom,v)},setMaxBounds:function(h){return h=re(h),this.listens("moveend",this._panInsideMaxBounds)&&this.off("moveend",this._panInsideMaxBounds),h.isValid()?(this.options.maxBounds=h,this._loaded&&this._panInsideMaxBounds(),this.on("moveend",this._panInsideMaxBounds)):(this.options.maxBounds=null,this)},setMinZoom:function(h){var v=this.options.minZoom;return this.options.minZoom=h,this._loaded&&v!==h&&(this.fire("zoomlevelschange"),this.getZoom()<this.options.minZoom)?this.setZoom(h):this},setMaxZoom:function(h){var v=this.options.maxZoom;return this.options.maxZoom=h,this._loaded&&v!==h&&(this.fire("zoomlevelschange"),this.getZoom()>this.options.maxZoom)?this.setZoom(h):this},panInsideBounds:function(h,v){this._enforcingBounds=!0;var j=this.getCenter(),F=this._limitCenter(j,this._zoom,re(h));return j.equals(F)||this.panTo(F,v),this._enforcingBounds=!1,this},panInside:function(h,v){v=v||{};var j=ye(v.paddingTopLeft||v.padding||[0,0]),F=ye(v.paddingBottomRight||v.padding||[0,0]),Y=this.project(this.getCenter()),he=this.project(h),Me=this.getPixelBounds(),Ye=G([Me.min.add(j),Me.max.subtract(F)]),ct=Ye.getSize();if(!Ye.contains(he)){this._enforcingBounds=!0;var Rt=he.subtract(Ye.getCenter()),lr=Ye.extend(he).getSize().subtract(ct);Y.x+=Rt.x<0?-lr.x:lr.x,Y.y+=Rt.y<0?-lr.y:lr.y,this.panTo(this.unproject(Y),v),this._enforcingBounds=!1}return this},invalidateSize:function(h){if(!this._loaded)return this;h=i({animate:!1,pan:!0},h===!0?{animate:!0}:h);var v=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var j=this.getSize(),F=v.divideBy(2).round(),Y=j.divideBy(2).round(),he=F.subtract(Y);return!he.x&&!he.y?this:(h.animate&&h.pan?this.panBy(he):(h.pan&&this._rawPanBy(he),this.fire("move"),h.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(u(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:v,newSize:j}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(h){if(h=this._locateOptions=i({timeout:1e4,watch:!1},h),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var v=u(this._handleGeolocationResponse,this),j=u(this._handleGeolocationError,this);return h.watch?this._locationWatchId=navigator.geolocation.watchPosition(v,j,h):navigator.geolocation.getCurrentPosition(v,j,h),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(h){if(this._container._leaflet_id){var v=h.code,j=h.message||(v===1?"permission denied":v===2?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:v,message:"Geolocation error: "+j+"."})}},_handleGeolocationResponse:function(h){if(this._container._leaflet_id){var v=h.coords.latitude,j=h.coords.longitude,F=new ne(v,j),Y=F.toBounds(h.coords.accuracy*2),he=this._locateOptions;if(he.setView){var Me=this.getBoundsZoom(Y);this.setView(F,he.maxZoom?Math.min(Me,he.maxZoom):Me)}var Ye={latlng:F,bounds:Y,timestamp:h.timestamp};for(var ct in h.coords)typeof h.coords[ct]=="number"&&(Ye[ct]=h.coords[ct]);this.fire("locationfound",Ye)}},addHandler:function(h,v){if(!v)return this;var j=this[h]=new v(this);return this._handlers.push(j),this.options[h]&&j.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(v){this._container._leaflet_id=void 0,this._containerId=void 0}this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),Sr(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(se(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload");var h;for(h in this._layers)this._layers[h].remove();for(h in this._panes)Sr(this._panes[h]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(h,v){var j="leaflet-pane"+(h?" leaflet-"+h.replace("Pane","")+"-pane":""),F=kt("div",j,v||this._mapPane);return h&&(this._panes[h]=F),F},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var h=this.getPixelBounds(),v=this.unproject(h.getBottomLeft()),j=this.unproject(h.getTopRight());return new ie(v,j)},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(h,v,j){h=re(h),j=ye(j||[0,0]);var F=this.getZoom()||0,Y=this.getMinZoom(),he=this.getMaxZoom(),Me=h.getNorthWest(),Ye=h.getSouthEast(),ct=this.getSize().subtract(j),Rt=G(this.project(Ye,F),this.project(Me,F)).getSize(),lr=Ut.any3d?this.options.zoomSnap:1,Cr=ct.x/Rt.x,Xr=ct.y/Rt.y,Dn=v?Math.max(Cr,Xr):Math.min(Cr,Xr);return F=this.getScaleZoom(Dn,F),lr&&(F=Math.round(F/(lr/100))*(lr/100),F=v?Math.ceil(F/lr)*lr:Math.floor(F/lr)*lr),Math.max(Y,Math.min(he,F))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new fe(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(h,v){var j=this._getTopLeftPoint(h,v);return new J(j,j.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(h){return this.options.crs.getProjectedBounds(h===void 0?this.getZoom():h)},getPane:function(h){return typeof h=="string"?this._panes[h]:h},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(h,v){var j=this.options.crs;return v=v===void 0?this._zoom:v,j.scale(h)/j.scale(v)},getScaleZoom:function(h,v){var j=this.options.crs;v=v===void 0?this._zoom:v;var F=j.zoom(h*j.scale(v));return isNaN(F)?1/0:F},project:function(h,v){return v=v===void 0?this._zoom:v,this.options.crs.latLngToPoint(ve(h),v)},unproject:function(h,v){return v=v===void 0?this._zoom:v,this.options.crs.pointToLatLng(ye(h),v)},layerPointToLatLng:function(h){var v=ye(h).add(this.getPixelOrigin());return this.unproject(v)},latLngToLayerPoint:function(h){var v=this.project(ve(h))._round();return v._subtract(this.getPixelOrigin())},wrapLatLng:function(h){return this.options.crs.wrapLatLng(ve(h))},wrapLatLngBounds:function(h){return this.options.crs.wrapLatLngBounds(re(h))},distance:function(h,v){return this.options.crs.distance(ve(h),ve(v))},containerPointToLayerPoint:function(h){return ye(h).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(h){return ye(h).add(this._getMapPanePos())},containerPointToLatLng:function(h){var v=this.containerPointToLayerPoint(ye(h));return this.layerPointToLatLng(v)},latLngToContainerPoint:function(h){return this.layerPointToContainerPoint(this.latLngToLayerPoint(ve(h)))},mouseEventToContainerPoint:function(h){return ei(h,this._container)},mouseEventToLayerPoint:function(h){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(h))},mouseEventToLatLng:function(h){return this.layerPointToLatLng(this.mouseEventToLayerPoint(h))},_initContainer:function(h){var v=this._container=Ar(h);if(v){if(v._leaflet_id)throw new Error("Map container is already initialized.")}else throw new Error("Map container not found.");Rr(v,"scroll",this._onScroll,this),this._containerId=y(v)},_initLayout:function(){var h=this._container;this._fadeAnimated=this.options.fadeAnimation&&Ut.any3d,hr(h,"leaflet-container"+(Ut.touch?" leaflet-touch":"")+(Ut.retina?" leaflet-retina":"")+(Ut.ielt9?" leaflet-oldie":"")+(Ut.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var v=Pe(h,"position");v!=="absolute"&&v!=="relative"&&v!=="fixed"&&v!=="sticky"&&(h.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var h=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),sr(this._mapPane,new fe(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(hr(h.markerPane,"leaflet-zoom-hide"),hr(h.shadowPane,"leaflet-zoom-hide"))},_resetView:function(h,v,j){sr(this._mapPane,new fe(0,0));var F=!this._loaded;this._loaded=!0,v=this._limitZoom(v),this.fire("viewprereset");var Y=this._zoom!==v;this._moveStart(Y,j)._move(h,v)._moveEnd(Y),this.fire("viewreset"),F&&this.fire("load")},_moveStart:function(h,v){return h&&this.fire("zoomstart"),v||this.fire("movestart"),this},_move:function(h,v,j,F){v===void 0&&(v=this._zoom);var Y=this._zoom!==v;return this._zoom=v,this._lastCenter=h,this._pixelOrigin=this._getNewPixelOrigin(h),F?j&&j.pinch&&this.fire("zoom",j):((Y||j&&j.pinch)&&this.fire("zoom",j),this.fire("move",j)),this},_moveEnd:function(h){return h&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return se(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(h){sr(this._mapPane,this._getMapPanePos().subtract(h))},_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(h){this._targets={},this._targets[y(this._container)]=this;var v=h?cr:Rr;v(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&v(window,"resize",this._onResize,this),Ut.any3d&&this.options.transform3DLimit&&(h?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){se(this._resizeRequest),this._resizeRequest=oe(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var h=this._getMapPanePos();Math.max(Math.abs(h.x),Math.abs(h.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(h,v){for(var j=[],F,Y=v==="mouseout"||v==="mouseover",he=h.target||h.srcElement,Me=!1;he;){if(F=this._targets[y(he)],F&&(v==="click"||v==="preclick")&&this._draggableMoved(F)){Me=!0;break}if(F&&F.listens(v,!0)&&(Y&&!Kn(he,h)||(j.push(F),Y))||he===this._container)break;he=he.parentNode}return!j.length&&!Me&&!Y&&this.listens(v,!0)&&(j=[this]),j},_isClickDisabled:function(h){for(;h&&h!==this._container;){if(h._leaflet_disable_click)return!0;h=h.parentNode}},_handleDOMEvent:function(h){var v=h.target||h.srcElement;if(!(!this._loaded||v._leaflet_disable_events||h.type==="click"&&this._isClickDisabled(v))){var j=h.type;j==="mousedown"&&vi(v),this._fireDOMEvent(h,j)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(h,v,j){if(h.type==="click"){var F=i({},h);F.type="preclick",this._fireDOMEvent(F,F.type,j)}var Y=this._findEventTargets(h,v);if(j){for(var he=[],Me=0;Me<j.length;Me++)j[Me].listens(v,!0)&&he.push(j[Me]);Y=he.concat(Y)}if(Y.length){v==="contextmenu"&&qa(h);var Ye=Y[0],ct={originalEvent:h};if(h.type!=="keypress"&&h.type!=="keydown"&&h.type!=="keyup"){var Rt=Ye.getLatLng&&(!Ye._radius||Ye._radius<=10);ct.containerPoint=Rt?this.latLngToContainerPoint(Ye.getLatLng()):this.mouseEventToContainerPoint(h),ct.layerPoint=this.containerPointToLayerPoint(ct.containerPoint),ct.latlng=Rt?Ye.getLatLng():this.layerPointToLatLng(ct.layerPoint)}for(Me=0;Me<Y.length;Me++)if(Y[Me].fire(v,ct,!0),ct.originalEvent._stopped||Y[Me].options.bubblingMouseEvents===!1&&V(this._mouseEvents,v)!==-1)return}},_draggableMoved:function(h){return h=h.dragging&&h.dragging.enabled()?h:this,h.dragging&&h.dragging.moved()||this.boxZoom&&this.boxZoom.moved()},_clearHandlers:function(){for(var h=0,v=this._handlers.length;h<v;h++)this._handlers[h].disable()},whenReady:function(h,v){return this._loaded?h.call(v||this,{target:this}):this.on("load",h,v),this},_getMapPanePos:function(){return Ea(this._mapPane)||new fe(0,0)},_moved:function(){var h=this._getMapPanePos();return h&&!h.equals([0,0])},_getTopLeftPoint:function(h,v){var j=h&&v!==void 0?this._getNewPixelOrigin(h,v):this.getPixelOrigin();return j.subtract(this._getMapPanePos())},_getNewPixelOrigin:function(h,v){var j=this.getSize()._divideBy(2);return this.project(h,v)._subtract(j)._add(this._getMapPanePos())._round()},_latLngToNewLayerPoint:function(h,v,j){var F=this._getNewPixelOrigin(j,v);return this.project(h,v)._subtract(F)},_latLngBoundsToNewLayerBounds:function(h,v,j){var F=this._getNewPixelOrigin(j,v);return G([this.project(h.getSouthWest(),v)._subtract(F),this.project(h.getNorthWest(),v)._subtract(F),this.project(h.getSouthEast(),v)._subtract(F),this.project(h.getNorthEast(),v)._subtract(F)])},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(h){return this.latLngToLayerPoint(h).subtract(this._getCenterLayerPoint())},_limitCenter:function(h,v,j){if(!j)return h;var F=this.project(h,v),Y=this.getSize().divideBy(2),he=new J(F.subtract(Y),F.add(Y)),Me=this._getBoundsOffset(he,j,v);return Math.abs(Me.x)<=1&&Math.abs(Me.y)<=1?h:this.unproject(F.add(Me),v)},_limitOffset:function(h,v){if(!v)return h;var j=this.getPixelBounds(),F=new J(j.min.add(h),j.max.add(h));return h.add(this._getBoundsOffset(F,v))},_getBoundsOffset:function(h,v,j){var F=G(this.project(v.getNorthEast(),j),this.project(v.getSouthWest(),j)),Y=F.min.subtract(h.min),he=F.max.subtract(h.max),Me=this._rebound(Y.x,-he.x),Ye=this._rebound(Y.y,-he.y);return new fe(Me,Ye)},_rebound:function(h,v){return h+v>0?Math.round(h-v)/2:Math.max(0,Math.ceil(h))-Math.max(0,Math.floor(v))},_limitZoom:function(h){var v=this.getMinZoom(),j=this.getMaxZoom(),F=Ut.any3d?this.options.zoomSnap:1;return F&&(h=Math.round(h/F)*F),Math.max(v,Math.min(j,h))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){Jr(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(h,v){var j=this._getCenterOffset(h)._trunc();return(v&&v.animate)!==!0&&!this.getSize().contains(j)?!1:(this.panBy(j,v),!0)},_createAnimProxy:function(){var h=this._proxy=kt("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(h),this.on("zoomanim",function(v){var j=qr,F=this._proxy.style[j];Se(this._proxy,this.project(v.center,v.zoom),this.getZoomScale(v.zoom,1)),F===this._proxy.style[j]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){Sr(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var h=this.getCenter(),v=this.getZoom();Se(this._proxy,this.project(h,v),this.getZoomScale(v,1))},_catchTransitionEnd:function(h){this._animatingZoom&&h.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(h,v,j){if(this._animatingZoom)return!0;if(j=j||{},!this._zoomAnimated||j.animate===!1||this._nothingToAnimate()||Math.abs(v-this._zoom)>this.options.zoomAnimationThreshold)return!1;var F=this.getZoomScale(v),Y=this._getCenterOffset(h)._divideBy(1-1/F);return j.animate!==!0&&!this.getSize().contains(Y)?!1:(oe(function(){this._moveStart(!0,j.noMoveStart||!1)._animateZoom(h,v,!0)},this),!0)},_animateZoom:function(h,v,j,F){this._mapPane&&(j&&(this._animatingZoom=!0,this._animateToCenter=h,this._animateToZoom=v,hr(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:h,zoom:v,noUpdate:F}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(u(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&Jr(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 fl(h,v){return new Qr(h,v)}var Jn=Ce.extend({options:{position:"topright"},initialize:function(h){A(this,h)},getPosition:function(){return this.options.position},setPosition:function(h){var v=this._map;return v&&v.removeControl(this),this.options.position=h,v&&v.addControl(this),this},getContainer:function(){return this._container},addTo:function(h){this.remove(),this._map=h;var v=this._container=this.onAdd(h),j=this.getPosition(),F=h._controlCorners[j];return hr(v,"leaflet-control"),j.indexOf("bottom")!==-1?F.insertBefore(v,F.firstChild):F.appendChild(v),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(Sr(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(h){this._map&&h&&h.screenX>0&&h.screenY>0&&this._map.getContainer().focus()}}),ti=function(h){return new Jn(h)};Qr.include({addControl:function(h){return h.addTo(this),this},removeControl:function(h){return h.remove(),this},_initControlPos:function(){var h=this._controlCorners={},v="leaflet-",j=this._controlContainer=kt("div",v+"control-container",this._container);function F(Y,he){var Me=v+Y+" "+v+he;h[Y+he]=kt("div",Me,j)}F("top","left"),F("top","right"),F("bottom","left"),F("bottom","right")},_clearControlPos:function(){for(var h in this._controlCorners)Sr(this._controlCorners[h]);Sr(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var Ro=Jn.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(h,v,j,F){return j<F?-1:F<j?1:0}},initialize:function(h,v,j){A(this,j),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._preventClick=!1;for(var F in h)this._addLayer(h[F],F);for(F in v)this._addLayer(v[F],F,!0)},onAdd:function(h){this._initLayout(),this._update(),this._map=h,h.on("zoomend",this._checkDisabledLayers,this);for(var v=0;v<this._layers.length;v++)this._layers[v].layer.on("add remove",this._onLayerChange,this);return this._container},addTo:function(h){return Jn.prototype.addTo.call(this,h),this._expandIfNotCollapsed()},onRemove:function(){this._map.off("zoomend",this._checkDisabledLayers,this);for(var h=0;h<this._layers.length;h++)this._layers[h].layer.off("add remove",this._onLayerChange,this)},addBaseLayer:function(h,v){return this._addLayer(h,v),this._map?this._update():this},addOverlay:function(h,v){return this._addLayer(h,v,!0),this._map?this._update():this},removeLayer:function(h){h.off("add remove",this._onLayerChange,this);var v=this._getLayer(y(h));return v&&this._layers.splice(this._layers.indexOf(v),1),this._map?this._update():this},expand:function(){hr(this._container,"leaflet-control-layers-expanded"),this._section.style.height=null;var h=this._map.getSize().y-(this._container.offsetTop+50);return h<this._section.clientHeight?(hr(this._section,"leaflet-control-layers-scrollbar"),this._section.style.height=h+"px"):Jr(this._section,"leaflet-control-layers-scrollbar"),this._checkDisabledLayers(),this},collapse:function(){return Jr(this._container,"leaflet-control-layers-expanded"),this},_initLayout:function(){var h="leaflet-control-layers",v=this._container=kt("div",h),j=this.options.collapsed;v.setAttribute("aria-haspopup",!0),qn(v),ws(v);var F=this._section=kt("section",h+"-list");j&&(this._map.on("click",this.collapse,this),Rr(v,{mouseenter:this._expandSafely,mouseleave:this.collapse},this));var Y=this._layersLink=kt("a",h+"-toggle",v);Y.href="#",Y.title="Layers",Y.setAttribute("role","button"),Rr(Y,{keydown:function(he){he.keyCode===13&&this._expandSafely()},click:function(he){qa(he),this._expandSafely()}},this),j||this.expand(),this._baseLayersList=kt("div",h+"-base",F),this._separator=kt("div",h+"-separator",F),this._overlaysList=kt("div",h+"-overlays",F),v.appendChild(F)},_getLayer:function(h){for(var v=0;v<this._layers.length;v++)if(this._layers[v]&&y(this._layers[v].layer)===h)return this._layers[v]},_addLayer:function(h,v,j){this._map&&h.on("add remove",this._onLayerChange,this),this._layers.push({layer:h,name:v,overlay:j}),this.options.sortLayers&&this._layers.sort(u(function(F,Y){return this.options.sortFunction(F.layer,Y.layer,F.name,Y.name)},this)),this.options.autoZIndex&&h.setZIndex&&(this._lastZIndex++,h.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()},_update:function(){if(!this._container)return this;la(this._baseLayersList),la(this._overlaysList),this._layerControlInputs=[];var h,v,j,F,Y=0;for(j=0;j<this._layers.length;j++)F=this._layers[j],this._addItem(F),v=v||F.overlay,h=h||!F.overlay,Y+=F.overlay?0:1;return this.options.hideSingleBase&&(h=h&&Y>1,this._baseLayersList.style.display=h?"":"none"),this._separator.style.display=v&&h?"":"none",this},_onLayerChange:function(h){this._handlingClick||this._update();var v=this._getLayer(y(h.target)),j=v.overlay?h.type==="add"?"overlayadd":"overlayremove":h.type==="add"?"baselayerchange":null;j&&this._map.fire(j,v)},_createRadioElement:function(h,v){var j='<input type="radio" class="leaflet-control-layers-selector" name="'+h+'"'+(v?' checked="checked"':"")+"/>",F=document.createElement("div");return F.innerHTML=j,F.firstChild},_addItem:function(h){var v=document.createElement("label"),j=this._map.hasLayer(h.layer),F;h.overlay?(F=document.createElement("input"),F.type="checkbox",F.className="leaflet-control-layers-selector",F.defaultChecked=j):F=this._createRadioElement("leaflet-base-layers_"+y(this),j),this._layerControlInputs.push(F),F.layerId=y(h.layer),Rr(F,"click",this._onInputClick,this);var Y=document.createElement("span");Y.innerHTML=" "+h.name;var he=document.createElement("span");v.appendChild(he),he.appendChild(F),he.appendChild(Y);var Me=h.overlay?this._overlaysList:this._baseLayersList;return Me.appendChild(v),this._checkDisabledLayers(),v},_onInputClick:function(){if(!this._preventClick){var h=this._layerControlInputs,v,j,F=[],Y=[];this._handlingClick=!0;for(var he=h.length-1;he>=0;he--)v=h[he],j=this._getLayer(v.layerId).layer,v.checked?F.push(j):v.checked||Y.push(j);for(he=0;he<Y.length;he++)this._map.hasLayer(Y[he])&&this._map.removeLayer(Y[he]);for(he=0;he<F.length;he++)this._map.hasLayer(F[he])||this._map.addLayer(F[he]);this._handlingClick=!1,this._refocusOnMap()}},_checkDisabledLayers:function(){for(var h=this._layerControlInputs,v,j,F=this._map.getZoom(),Y=h.length-1;Y>=0;Y--)v=h[Y],j=this._getLayer(v.layerId).layer,v.disabled=j.options.minZoom!==void 0&&F<j.options.minZoom||j.options.maxZoom!==void 0&&F>j.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var h=this._section;this._preventClick=!0,Rr(h,"click",qa),this.expand();var v=this;setTimeout(function(){cr(h,"click",qa),v._preventClick=!1})}}),ha=function(h,v,j){return new Ro(h,v,j)},ml=Jn.extend({options:{position:"topleft",zoomInText:'<span aria-hidden="true">+</span>',zoomInTitle:"Zoom in",zoomOutText:'<span aria-hidden="true">−</span>',zoomOutTitle:"Zoom out"},onAdd:function(h){var v="leaflet-control-zoom",j=kt("div",v+" leaflet-bar"),F=this.options;return this._zoomInButton=this._createButton(F.zoomInText,F.zoomInTitle,v+"-in",j,this._zoomIn),this._zoomOutButton=this._createButton(F.zoomOutText,F.zoomOutTitle,v+"-out",j,this._zoomOut),this._updateDisabled(),h.on("zoomend zoomlevelschange",this._updateDisabled,this),j},onRemove:function(h){h.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(h){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&this._map.zoomIn(this._map.options.zoomDelta*(h.shiftKey?3:1))},_zoomOut:function(h){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(h.shiftKey?3:1))},_createButton:function(h,v,j,F,Y){var he=kt("a",j,F);return he.innerHTML=h,he.href="#",he.title=v,he.setAttribute("role","button"),he.setAttribute("aria-label",v),qn(he),Rr(he,"click",us),Rr(he,"click",Y,this),Rr(he,"click",this._refocusOnMap,this),he},_updateDisabled:function(){var h=this._map,v="leaflet-disabled";Jr(this._zoomInButton,v),Jr(this._zoomOutButton,v),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||h._zoom===h.getMinZoom())&&(hr(this._zoomOutButton,v),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||h._zoom===h.getMaxZoom())&&(hr(this._zoomInButton,v),this._zoomInButton.setAttribute("aria-disabled","true"))}});Qr.mergeOptions({zoomControl:!0}),Qr.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new ml,this.addControl(this.zoomControl))});var gl=function(h){return new ml(h)},ri=Jn.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(h){var v="leaflet-control-scale",j=kt("div",v),F=this.options;return this._addScales(F,v+"-line",j),h.on(F.updateWhenIdle?"moveend":"move",this._update,this),h.whenReady(this._update,this),j},onRemove:function(h){h.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(h,v,j){h.metric&&(this._mScale=kt("div",v,j)),h.imperial&&(this._iScale=kt("div",v,j))},_update:function(){var h=this._map,v=h.getSize().y/2,j=h.distance(h.containerPointToLatLng([0,v]),h.containerPointToLatLng([this.options.maxWidth,v]));this._updateScales(j)},_updateScales:function(h){this.options.metric&&h&&this._updateMetric(h),this.options.imperial&&h&&this._updateImperial(h)},_updateMetric:function(h){var v=this._getRoundNum(h),j=v<1e3?v+" m":v/1e3+" km";this._updateScale(this._mScale,j,v/h)},_updateImperial:function(h){var v=h*3.2808399,j,F,Y;v>5280?(j=v/5280,F=this._getRoundNum(j),this._updateScale(this._iScale,F+" mi",F/j)):(Y=this._getRoundNum(v),this._updateScale(this._iScale,Y+" ft",Y/v))},_updateScale:function(h,v,j){h.style.width=Math.round(this.options.maxWidth*j)+"px",h.innerHTML=v},_getRoundNum:function(h){var v=Math.pow(10,(Math.floor(h)+"").length-1),j=h/v;return j=j>=10?10:j>=5?5:j>=3?3:j>=2?2:1,v*j}}),tc=function(h){return new ri(h)},ft='<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>',Hr=Jn.extend({options:{position:"bottomright",prefix:'<a href="https://leafletjs.com" title="A JavaScript library for interactive maps">'+(Ut.inlineSvg?ft+" ":"")+"Leaflet</a>"},initialize:function(h){A(this,h),this._attributions={}},onAdd:function(h){h.attributionControl=this,this._container=kt("div","leaflet-control-attribution"),qn(this._container);for(var v in h._layers)h._layers[v].getAttribution&&this.addAttribution(h._layers[v].getAttribution());return this._update(),h.on("layeradd",this._addAttribution,this),this._container},onRemove:function(h){h.off("layeradd",this._addAttribution,this)},_addAttribution:function(h){h.layer.getAttribution&&(this.addAttribution(h.layer.getAttribution()),h.layer.once("remove",function(){this.removeAttribution(h.layer.getAttribution())},this))},setPrefix:function(h){return this.options.prefix=h,this._update(),this},addAttribution:function(h){return h?(this._attributions[h]||(this._attributions[h]=0),this._attributions[h]++,this._update(),this):this},removeAttribution:function(h){return h?(this._attributions[h]&&(this._attributions[h]--,this._update()),this):this},_update:function(){if(this._map){var h=[];for(var v in this._attributions)this._attributions[v]&&h.push(v);var j=[];this.options.prefix&&j.push(this.options.prefix),h.length&&j.push(h.join(", ")),this._container.innerHTML=j.join(' <span aria-hidden="true">|</span> ')}}});Qr.mergeOptions({attributionControl:!0}),Qr.addInitHook(function(){this.options.attributionControl&&new Hr().addTo(this)});var yn=function(h){return new Hr(h)};Jn.Layers=Ro,Jn.Zoom=ml,Jn.Scale=ri,Jn.Attribution=Hr,ti.layers=ha,ti.zoom=gl,ti.scale=tc,ti.attribution=yn;var Qn=Ce.extend({initialize:function(h){this._map=h},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}});Qn.addTo=function(h,v){return h.addHandler(v,this),this};var Bc={Events:me},rc=Ut.touch?"touchstart mousedown":"mousedown",_i=K.extend({options:{clickTolerance:3},initialize:function(h,v,j,F){A(this,F),this._element=h,this._dragStartTarget=v||h,this._preventOutline=j},enable:function(){this._enabled||(Rr(this._dragStartTarget,rc,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(_i._dragging===this&&this.finishDrag(!0),cr(this._dragStartTarget,rc,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(h){if(this._enabled&&(this._moved=!1,!Un(this._element,"leaflet-zoom-anim"))){if(h.touches&&h.touches.length!==1){_i._dragging===this&&this.finishDrag();return}if(!(_i._dragging||h.shiftKey||h.which!==1&&h.button!==1&&!h.touches)&&(_i._dragging=this,this._preventOutline&&vi(this._element),Nr(),gn(),!this._moving)){this.fire("down");var v=h.touches?h.touches[0]:h,j=so(this._element);this._startPoint=new fe(v.clientX,v.clientY),this._startPos=Ea(this._element),this._parentScale=Ao(j);var F=h.type==="mousedown";Rr(document,F?"mousemove":"touchmove",this._onMove,this),Rr(document,F?"mouseup":"touchend touchcancel",this._onUp,this)}}},_onMove:function(h){if(this._enabled){if(h.touches&&h.touches.length>1){this._moved=!0;return}var v=h.touches&&h.touches.length===1?h.touches[0]:h,j=new fe(v.clientX,v.clientY)._subtract(this._startPoint);!j.x&&!j.y||Math.abs(j.x)+Math.abs(j.y)<this.options.clickTolerance||(j.x/=this._parentScale.x,j.y/=this._parentScale.y,qa(h),this._moved||(this.fire("dragstart"),this._moved=!0,hr(document.body,"leaflet-dragging"),this._lastTarget=h.target||h.srcElement,window.SVGElementInstance&&this._lastTarget instanceof window.SVGElementInstance&&(this._lastTarget=this._lastTarget.correspondingUseElement),hr(this._lastTarget,"leaflet-drag-target")),this._newPos=this._startPos.add(j),this._moving=!0,this._lastEvent=h,this._updatePosition())}},_updatePosition:function(){var h={originalEvent:this._lastEvent};this.fire("predrag",h),sr(this._element,this._newPos),this.fire("drag",h)},_onUp:function(){this._enabled&&this.finishDrag()},finishDrag:function(h){Jr(document.body,"leaflet-dragging"),this._lastTarget&&(Jr(this._lastTarget,"leaflet-drag-target"),this._lastTarget=null),cr(document,"mousemove touchmove",this._onMove,this),cr(document,"mouseup touchend touchcancel",this._onUp,this),_a(),Ms();var v=this._moved&&this._moving;this._moving=!1,_i._dragging=!1,v&&this.fire("dragend",{noInertia:h,distance:this._newPos.distanceTo(this._startPos)})}});function Uc(h,v,j){var F,Y=[1,4,2,8],he,Me,Ye,ct,Rt,lr,Cr,Xr;for(he=0,lr=h.length;he<lr;he++)h[he]._code=Bi(h[he],v);for(Ye=0;Ye<4;Ye++){for(Cr=Y[Ye],F=[],he=0,lr=h.length,Me=lr-1;he<lr;Me=he++)ct=h[he],Rt=h[Me],ct._code&Cr?Rt._code&Cr||(Xr=ai(Rt,ct,Cr,v,j),Xr._code=Bi(Xr,v),F.push(Xr)):(Rt._code&Cr&&(Xr=ai(Rt,ct,Cr,v,j),Xr._code=Bi(Xr,v),F.push(Xr)),F.push(ct));h=F}return h}function xl(h,v){var j,F,Y,he,Me,Ye,ct,Rt,lr;if(!h||h.length===0)throw new Error("latlngs not passed");es(h)||(console.warn("latlngs are not flat! Only the first ring will be used"),h=h[0]);var Cr=ve([0,0]),Xr=re(h),Dn=Xr.getNorthWest().distanceTo(Xr.getSouthWest())*Xr.getNorthEast().distanceTo(Xr.getNorthWest());Dn<1700&&(Cr=Ga(h));var cn=h.length,Cs=[];for(j=0;j<cn;j++){var xa=ve(h[j]);Cs.push(v.project(ve([xa.lat-Cr.lat,xa.lng-Cr.lng])))}for(Ye=ct=Rt=0,j=0,F=cn-1;j<cn;F=j++)Y=Cs[j],he=Cs[F],Me=Y.y*he.x-he.y*Y.x,ct+=(Y.x+he.x)*Me,Rt+=(Y.y+he.y)*Me,Ye+=Me*3;Ye===0?lr=Cs[0]:lr=[ct/Ye,Rt/Ye];var pa=v.unproject(ye(lr));return ve([pa.lat+Cr.lat,pa.lng+Cr.lng])}function Ga(h){for(var v=0,j=0,F=0,Y=0;Y<h.length;Y++){var he=ve(h[Y]);v+=he.lat,j+=he.lng,F++}return ve([v/F,j/F])}var Mo={__proto__:null,clipPolygon:Uc,polygonCenter:xl,centroid:Ga};function Ha(h,v){if(!v||!h.length)return h.slice();var j=v*v;return h=s0(h,j),h=ga(h,j),h}function Do(h,v,j){return Math.sqrt(Ui(h,v,j,!0))}function Fi(h,v,j){return Ui(h,v,j)}function ga(h,v){var j=h.length,F=typeof Uint8Array!="undefined"?Uint8Array:Array,Y=new F(j);Y[0]=Y[j-1]=1,Or(h,Y,v,0,j-1);var he,Me=[];for(he=0;he<j;he++)Y[he]&&Me.push(h[he]);return Me}function Or(h,v,j,F,Y){var he=0,Me,Ye,ct;for(Ye=F+1;Ye<=Y-1;Ye++)ct=Ui(h[Ye],h[F],h[Y],!0),ct>he&&(Me=Ye,he=ct);he>j&&(v[Me]=1,Or(h,v,j,F,Me),Or(h,v,j,Me,Y))}function s0(h,v){for(var j=[h[0]],F=1,Y=0,he=h.length;F<he;F++)Ds(h[F],h[Y])>v&&(j.push(h[F]),Y=F);return Y<he-1&&j.push(h[he-1]),j}var Sa;function wi(h,v,j,F,Y){var he=F?Sa:Bi(h,j),Me=Bi(v,j),Ye,ct,Rt;for(Sa=Me;;){if(!(he|Me))return[h,v];if(he&Me)return!1;Ye=he||Me,ct=ai(h,v,Ye,j,Y),Rt=Bi(ct,j),Ye===he?(h=ct,he=Rt):(v=ct,Me=Rt)}}function ai(h,v,j,F,Y){var he=v.x-h.x,Me=v.y-h.y,Ye=F.min,ct=F.max,Rt,lr;return j&8?(Rt=h.x+he*(ct.y-h.y)/Me,lr=ct.y):j&4?(Rt=h.x+he*(Ye.y-h.y)/Me,lr=Ye.y):j&2?(Rt=ct.x,lr=h.y+Me*(ct.x-h.x)/he):j&1&&(Rt=Ye.x,lr=h.y+Me*(Ye.x-h.x)/he),new fe(Rt,lr,Y)}function Bi(h,v){var j=0;return h.x<v.min.x?j|=1:h.x>v.max.x&&(j|=2),h.y<v.min.y?j|=4:h.y>v.max.y&&(j|=8),j}function Ds(h,v){var j=v.x-h.x,F=v.y-h.y;return j*j+F*F}function Ui(h,v,j,F){var Y=v.x,he=v.y,Me=j.x-Y,Ye=j.y-he,ct=Me*Me+Ye*Ye,Rt;return ct>0&&(Rt=((h.x-Y)*Me+(h.y-he)*Ye)/ct,Rt>1?(Y=j.x,he=j.y):Rt>0&&(Y+=Me*Rt,he+=Ye*Rt)),Me=h.x-Y,Ye=h.y-he,F?Me*Me+Ye*Ye:new fe(Y,he)}function es(h){return!B(h[0])||typeof h[0][0]!="object"&&typeof h[0][0]!="undefined"}function io(h){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),es(h)}function zi(h,v){var j,F,Y,he,Me,Ye,ct,Rt;if(!h||h.length===0)throw new Error("latlngs not passed");es(h)||(console.warn("latlngs are not flat! Only the first ring will be used"),h=h[0]);var lr=ve([0,0]),Cr=re(h),Xr=Cr.getNorthWest().distanceTo(Cr.getSouthWest())*Cr.getNorthEast().distanceTo(Cr.getNorthWest());Xr<1700&&(lr=Ga(h));var Dn=h.length,cn=[];for(j=0;j<Dn;j++){var Cs=ve(h[j]);cn.push(v.project(ve([Cs.lat-lr.lat,Cs.lng-lr.lng])))}for(j=0,F=0;j<Dn-1;j++)F+=cn[j].distanceTo(cn[j+1])/2;if(F===0)Rt=cn[0];else for(j=0,he=0;j<Dn-1;j++)if(Me=cn[j],Ye=cn[j+1],Y=Me.distanceTo(Ye),he+=Y,he>F){ct=(he-F)/Y,Rt=[Ye.x-ct*(Ye.x-Me.x),Ye.y-ct*(Ye.y-Me.y)];break}var xa=v.unproject(ye(Rt));return ve([xa.lat+lr.lat,xa.lng+lr.lng])}var zc={__proto__:null,simplify:Ha,pointToSegmentDistance:Do,closestPointOnSegment:Fi,clipSegment:wi,_getEdgeIntersection:ai,_getBitCode:Bi,_sqClosestPointOnSegment:Ui,isFlat:es,_flat:io,polylineCenter:zi},pl={project:function(h){return new fe(h.lng,h.lat)},unproject:function(h){return new ne(h.y,h.x)},bounds:new J([-180,-90],[180,90])},ni={R:6378137,R_MINOR:6356752314245179e-9,bounds:new J([-2003750834279e-5,-1549657073972e-5],[2003750834279e-5,1876465623138e-5]),project:function(h){var v=Math.PI/180,j=this.R,F=h.lat*v,Y=this.R_MINOR/j,he=Math.sqrt(1-Y*Y),Me=he*Math.sin(F),Ye=Math.tan(Math.PI/4-F/2)/Math.pow((1-Me)/(1+Me),he/2);return F=-j*Math.log(Math.max(Ye,1e-10)),new fe(h.lng*v*j,F)},unproject:function(h){for(var v=180/Math.PI,j=this.R,F=this.R_MINOR/j,Y=Math.sqrt(1-F*F),he=Math.exp(-h.y/j),Me=Math.PI/2-2*Math.atan(he),Ye=0,ct=.1,Rt;Ye<15&&Math.abs(ct)>1e-7;Ye++)Rt=Y*Math.sin(Me),Rt=Math.pow((1-Rt)/(1+Rt),Y/2),ct=Math.PI/2-2*Math.atan(he*Rt)-Me,Me+=ct;return new ne(Me*v,h.x*v/j)}},yl={__proto__:null,LonLat:pl,Mercator:ni,SphericalMercator:Re},Hc=i({},Ae,{code:"EPSG:3395",projection:ni,transformation:(function(){var h=.5/(Math.PI*ni.R);return Lt(h,.5,-h,.5)})()}),Hi=i({},Ae,{code:"EPSG:4326",projection:pl,transformation:Lt(1/180,1,-1/180,.5)}),oo=i({},Ve,{projection:pl,transformation:Lt(1,0,-1,0),scale:function(h){return Math.pow(2,h)},zoom:function(h){return Math.log(h)/Math.LN2},distance:function(h,v){var j=v.lng-h.lng,F=v.lat-h.lat;return Math.sqrt(j*j+F*F)},infinite:!0});Ve.Earth=Ae,Ve.EPSG3395=Hc,Ve.EPSG3857=mt,Ve.EPSG900913=Zt,Ve.EPSG4326=Hi,Ve.Simple=oo;var ln=K.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(h){return h.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(h){return h&&h.removeLayer(this),this},getPane:function(h){return this._map.getPane(h?this.options[h]||h:this.options.pane)},addInteractiveTarget:function(h){return this._map._targets[y(h)]=this,this},removeInteractiveTarget:function(h){return delete this._map._targets[y(h)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(h){var v=h.target;if(v.hasLayer(this)){if(this._map=v,this._zoomAnimated=v._zoomAnimated,this.getEvents){var j=this.getEvents();v.on(j,this),this.once("remove",function(){v.off(j,this)},this)}this.onAdd(v),this.fire("add"),v.fire("layeradd",{layer:this})}}});Qr.include({addLayer:function(h){if(!h._layerAdd)throw new Error("The provided object is not a Layer.");var v=y(h);return this._layers[v]?this:(this._layers[v]=h,h._mapToAdd=this,h.beforeAdd&&h.beforeAdd(this),this.whenReady(h._layerAdd,h),this)},removeLayer:function(h){var v=y(h);return this._layers[v]?(this._loaded&&h.onRemove(this),delete this._layers[v],this._loaded&&(this.fire("layerremove",{layer:h}),h.fire("remove")),h._map=h._mapToAdd=null,this):this},hasLayer:function(h){return y(h)in this._layers},eachLayer:function(h,v){for(var j in this._layers)h.call(v,this._layers[j]);return this},_addLayers:function(h){h=h?B(h)?h:[h]:[];for(var v=0,j=h.length;v<j;v++)this.addLayer(h[v])},_addZoomLimit:function(h){(!isNaN(h.options.maxZoom)||!isNaN(h.options.minZoom))&&(this._zoomBoundLayers[y(h)]=h,this._updateZoomLevels())},_removeZoomLimit:function(h){var v=y(h);this._zoomBoundLayers[v]&&(delete this._zoomBoundLayers[v],this._updateZoomLevels())},_updateZoomLevels:function(){var h=1/0,v=-1/0,j=this._getZoomSpan();for(var F in this._zoomBoundLayers){var Y=this._zoomBoundLayers[F].options;h=Y.minZoom===void 0?h:Math.min(h,Y.minZoom),v=Y.maxZoom===void 0?v:Math.max(v,Y.maxZoom)}this._layersMaxZoom=v===-1/0?void 0:v,this._layersMinZoom=h===1/0?void 0:h,j!==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 si=ln.extend({initialize:function(h,v){A(this,v),this._layers={};var j,F;if(h)for(j=0,F=h.length;j<F;j++)this.addLayer(h[j])},addLayer:function(h){var v=this.getLayerId(h);return this._layers[v]=h,this._map&&this._map.addLayer(h),this},removeLayer:function(h){var v=h in this._layers?h:this.getLayerId(h);return this._map&&this._layers[v]&&this._map.removeLayer(this._layers[v]),delete this._layers[v],this},hasLayer:function(h){var v=typeof h=="number"?h:this.getLayerId(h);return v in this._layers},clearLayers:function(){return this.eachLayer(this.removeLayer,this)},invoke:function(h){var v=Array.prototype.slice.call(arguments,1),j,F;for(j in this._layers)F=this._layers[j],F[h]&&F[h].apply(F,v);return this},onAdd:function(h){this.eachLayer(h.addLayer,h)},onRemove:function(h){this.eachLayer(h.removeLayer,h)},eachLayer:function(h,v){for(var j in this._layers)h.call(v,this._layers[j]);return this},getLayer:function(h){return this._layers[h]},getLayers:function(){var h=[];return this.eachLayer(h.push,h),h},setZIndex:function(h){return this.invoke("setZIndex",h)},getLayerId:function(h){return y(h)}}),hs=function(h,v){return new si(h,v)},ks=si.extend({addLayer:function(h){return this.hasLayer(h)?this:(h.addEventParent(this),si.prototype.addLayer.call(this,h),this.fire("layeradd",{layer:h}))},removeLayer:function(h){return this.hasLayer(h)?(h in this._layers&&(h=this._layers[h]),h.removeEventParent(this),si.prototype.removeLayer.call(this,h),this.fire("layerremove",{layer:h})):this},setStyle:function(h){return this.invoke("setStyle",h)},bringToFront:function(){return this.invoke("bringToFront")},bringToBack:function(){return this.invoke("bringToBack")},getBounds:function(){var h=new ie;for(var v in this._layers){var j=this._layers[v];h.extend(j.getBounds?j.getBounds():j.getLatLng())}return h}}),Ns=function(h,v){return new ks(h,v)},Ls=Ce.extend({options:{popupAnchor:[0,0],tooltipAnchor:[0,0],crossOrigin:!1},initialize:function(h){A(this,h)},createIcon:function(h){return this._createIcon("icon",h)},createShadow:function(h){return this._createIcon("shadow",h)},_createIcon:function(h,v){var j=this._getIconUrl(h);if(!j){if(h==="icon")throw new Error("iconUrl not set in Icon options (see the docs).");return null}var F=this._createImg(j,v&&v.tagName==="IMG"?v:null);return this._setIconStyles(F,h),(this.options.crossOrigin||this.options.crossOrigin==="")&&(F.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),F},_setIconStyles:function(h,v){var j=this.options,F=j[v+"Size"];typeof F=="number"&&(F=[F,F]);var Y=ye(F),he=ye(v==="shadow"&&j.shadowAnchor||j.iconAnchor||Y&&Y.divideBy(2,!0));h.className="leaflet-marker-"+v+" "+(j.className||""),he&&(h.style.marginLeft=-he.x+"px",h.style.marginTop=-he.y+"px"),Y&&(h.style.width=Y.x+"px",h.style.height=Y.y+"px")},_createImg:function(h,v){return v=v||document.createElement("img"),v.src=h,v},_getIconUrl:function(h){return Ut.retina&&this.options[h+"RetinaUrl"]||this.options[h+"Url"]}});function Vi(h){return new Ls(h)}var Lo=Ls.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(h){return typeof Lo.imagePath!="string"&&(Lo.imagePath=this._detectIconPath()),(this.options.imagePath||Lo.imagePath)+Ls.prototype._getIconUrl.call(this,h)},_stripUrl:function(h){var v=function(j,F,Y){var he=F.exec(j);return he&&he[Y]};return h=v(h,/^url\((['"])?(.+)\1\)$/,2),h&&v(h,/^(.*)marker-icon\.png$/,1)},_detectIconPath:function(){var h=kt("div","leaflet-default-icon-path",document.body),v=Pe(h,"background-image")||Pe(h,"backgroundImage");if(document.body.removeChild(h),v=this._stripUrl(v),v)return v;var j=document.querySelector('link[href$="leaflet.css"]');return j?j.href.substring(0,j.href.length-11-1):""}}),lo=Qn.extend({initialize:function(h){this._marker=h},addHooks:function(){var h=this._marker._icon;this._draggable||(this._draggable=new _i(h,h,!0)),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),hr(h,"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&&Jr(this._marker._icon,"leaflet-marker-draggable")},moved:function(){return this._draggable&&this._draggable._moved},_adjustPan:function(h){var v=this._marker,j=v._map,F=this._marker.options.autoPanSpeed,Y=this._marker.options.autoPanPadding,he=Ea(v._icon),Me=j.getPixelBounds(),Ye=j.getPixelOrigin(),ct=G(Me.min._subtract(Ye).add(Y),Me.max._subtract(Ye).subtract(Y));if(!ct.contains(he)){var Rt=ye((Math.max(ct.max.x,he.x)-ct.max.x)/(Me.max.x-ct.max.x)-(Math.min(ct.min.x,he.x)-ct.min.x)/(Me.min.x-ct.min.x),(Math.max(ct.max.y,he.y)-ct.max.y)/(Me.max.y-ct.max.y)-(Math.min(ct.min.y,he.y)-ct.min.y)/(Me.min.y-ct.min.y)).multiplyBy(F);j.panBy(Rt,{animate:!1}),this._draggable._newPos._add(Rt),this._draggable._startPos._add(Rt),sr(v._icon,this._draggable._newPos),this._onDrag(h),this._panRequest=oe(this._adjustPan.bind(this,h))}},_onDragStart:function(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup&&this._marker.closePopup(),this._marker.fire("movestart").fire("dragstart")},_onPreDrag:function(h){this._marker.options.autoPan&&(se(this._panRequest),this._panRequest=oe(this._adjustPan.bind(this,h)))},_onDrag:function(h){var v=this._marker,j=v._shadow,F=Ea(v._icon),Y=v._map.layerPointToLatLng(F);j&&sr(j,F),v._latlng=Y,h.latlng=Y,h.oldLatLng=this._oldLatLng,v.fire("move",h).fire("drag",h)},_onDragEnd:function(h){se(this._panRequest),delete this._oldLatLng,this._marker.fire("moveend").fire("dragend",h)}}),zn=ln.extend({options:{icon:new Lo,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(h,v){A(this,v),this._latlng=ve(h)},onAdd:function(h){this._zoomAnimated=this._zoomAnimated&&h.options.markerZoomAnimation,this._zoomAnimated&&h.on("zoomanim",this._animateZoom,this),this._initIcon(),this.update()},onRemove:function(h){this.dragging&&this.dragging.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&h.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(h){var v=this._latlng;return this._latlng=ve(h),this.update(),this.fire("move",{oldLatLng:v,latlng:this._latlng})},setZIndexOffset:function(h){return this.options.zIndexOffset=h,this.update()},getIcon:function(){return this.options.icon},setIcon:function(h){return this.options.icon=h,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 h=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(h)}return this},_initIcon:function(){var h=this.options,v="leaflet-zoom-"+(this._zoomAnimated?"animated":"hide"),j=h.icon.createIcon(this._icon),F=!1;j!==this._icon&&(this._icon&&this._removeIcon(),F=!0,h.title&&(j.title=h.title),j.tagName==="IMG"&&(j.alt=h.alt||"")),hr(j,v),h.keyboard&&(j.tabIndex="0",j.setAttribute("role","button")),this._icon=j,h.riseOnHover&&this.on({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&Rr(j,"focus",this._panOnFocus,this);var Y=h.icon.createShadow(this._shadow),he=!1;Y!==this._shadow&&(this._removeShadow(),he=!0),Y&&(hr(Y,v),Y.alt=""),this._shadow=Y,h.opacity<1&&this._updateOpacity(),F&&this.getPane().appendChild(this._icon),this._initInteraction(),Y&&he&&this.getPane(h.shadowPane).appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&cr(this._icon,"focus",this._panOnFocus,this),Sr(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&Sr(this._shadow),this._shadow=null},_setPos:function(h){this._icon&&sr(this._icon,h),this._shadow&&sr(this._shadow,h),this._zIndex=h.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(h){this._icon&&(this._icon.style.zIndex=this._zIndex+h)},_animateZoom:function(h){var v=this._map._latLngToNewLayerPoint(this._latlng,h.zoom,h.center).round();this._setPos(v)},_initInteraction:function(){if(this.options.interactive&&(hr(this._icon,"leaflet-interactive"),this.addInteractiveTarget(this._icon),lo)){var h=this.options.draggable;this.dragging&&(h=this.dragging.enabled(),this.dragging.disable()),this.dragging=new lo(this),h&&this.dragging.enable()}},setOpacity:function(h){return this.options.opacity=h,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var h=this.options.opacity;this._icon&&kr(this._icon,h),this._shadow&&kr(this._shadow,h)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_panOnFocus:function(){var h=this._map;if(h){var v=this.options.icon.options,j=v.iconSize?ye(v.iconSize):ye(0,0),F=v.iconAnchor?ye(v.iconAnchor):ye(0,0);h.panInside(this._latlng,{paddingTopLeft:F,paddingBottomRight:j.subtract(F)})}},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor}});function Vc(h,v){return new zn(h,v)}var fs=ln.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(h){this._renderer=h.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(h){return A(this,h),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&h&&Object.prototype.hasOwnProperty.call(h,"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)}}),Is=fs.extend({options:{fill:!0,radius:10},initialize:function(h,v){A(this,v),this._latlng=ve(h),this._radius=this.options.radius},setLatLng:function(h){var v=this._latlng;return this._latlng=ve(h),this.redraw(),this.fire("move",{oldLatLng:v,latlng:this._latlng})},getLatLng:function(){return this._latlng},setRadius:function(h){return this.options.radius=this._radius=h,this.redraw()},getRadius:function(){return this._radius},setStyle:function(h){var v=h&&h.radius||this._radius;return fs.prototype.setStyle.call(this,h),this.setRadius(v),this},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng),this._updateBounds()},_updateBounds:function(){var h=this._radius,v=this._radiusY||h,j=this._clickTolerance(),F=[h+j,v+j];this._pxBounds=new J(this._point.subtract(F),this._point.add(F))},_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(h){return h.distanceTo(this._point)<=this._radius+this._clickTolerance()}});function ta(h,v){return new Is(h,v)}var Wi=Is.extend({initialize:function(h,v,j){if(typeof v=="number"&&(v=i({},j,{radius:v})),A(this,v),this._latlng=ve(h),isNaN(this.options.radius))throw new Error("Circle radius cannot be NaN");this._mRadius=this.options.radius},setRadius:function(h){return this._mRadius=h,this.redraw()},getRadius:function(){return this._mRadius},getBounds:function(){var h=[this._radius,this._radiusY||this._radius];return new ie(this._map.layerPointToLatLng(this._point.subtract(h)),this._map.layerPointToLatLng(this._point.add(h)))},setStyle:fs.prototype.setStyle,_project:function(){var h=this._latlng.lng,v=this._latlng.lat,j=this._map,F=j.options.crs;if(F.distance===Ae.distance){var Y=Math.PI/180,he=this._mRadius/Ae.R/Y,Me=j.project([v+he,h]),Ye=j.project([v-he,h]),ct=Me.add(Ye).divideBy(2),Rt=j.unproject(ct).lat,lr=Math.acos((Math.cos(he*Y)-Math.sin(v*Y)*Math.sin(Rt*Y))/(Math.cos(v*Y)*Math.cos(Rt*Y)))/Y;(isNaN(lr)||lr===0)&&(lr=he/Math.cos(Math.PI/180*v)),this._point=ct.subtract(j.getPixelOrigin()),this._radius=isNaN(lr)?0:ct.x-j.project([Rt,h-lr]).x,this._radiusY=ct.y-Me.y}else{var Cr=F.unproject(F.project(this._latlng).subtract([this._mRadius,0]));this._point=j.latLngToLayerPoint(this._latlng),this._radius=this._point.x-j.latLngToLayerPoint(Cr).x}this._updateBounds()}});function ee(h,v,j){return new Wi(h,v,j)}var o=fs.extend({options:{smoothFactor:1,noClip:!1},initialize:function(h,v){A(this,v),this._setLatLngs(h)},getLatLngs:function(){return this._latlngs},setLatLngs:function(h){return this._setLatLngs(h),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(h){for(var v=1/0,j=null,F=Ui,Y,he,Me=0,Ye=this._parts.length;Me<Ye;Me++)for(var ct=this._parts[Me],Rt=1,lr=ct.length;Rt<lr;Rt++){Y=ct[Rt-1],he=ct[Rt];var Cr=F(h,Y,he,!0);Cr<v&&(v=Cr,j=F(h,Y,he))}return j&&(j.distance=Math.sqrt(v)),j},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");return zi(this._defaultShape(),this._map.options.crs)},getBounds:function(){return this._bounds},addLatLng:function(h,v){return v=v||this._defaultShape(),h=ve(h),v.push(h),this._bounds.extend(h),this.redraw()},_setLatLngs:function(h){this._bounds=new ie,this._latlngs=this._convertLatLngs(h)},_defaultShape:function(){return es(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(h){for(var v=[],j=es(h),F=0,Y=h.length;F<Y;F++)j?(v[F]=ve(h[F]),this._bounds.extend(v[F])):v[F]=this._convertLatLngs(h[F]);return v},_project:function(){var h=new J;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,h),this._bounds.isValid()&&h.isValid()&&(this._rawPxBounds=h,this._updateBounds())},_updateBounds:function(){var h=this._clickTolerance(),v=new fe(h,h);this._rawPxBounds&&(this._pxBounds=new J([this._rawPxBounds.min.subtract(v),this._rawPxBounds.max.add(v)]))},_projectLatlngs:function(h,v,j){var F=h[0]instanceof ne,Y=h.length,he,Me;if(F){for(Me=[],he=0;he<Y;he++)Me[he]=this._map.latLngToLayerPoint(h[he]),j.extend(Me[he]);v.push(Me)}else for(he=0;he<Y;he++)this._projectLatlngs(h[he],v,j)},_clipPoints:function(){var h=this._renderer._bounds;if(this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(h))){if(this.options.noClip){this._parts=this._rings;return}var v=this._parts,j,F,Y,he,Me,Ye,ct;for(j=0,Y=0,he=this._rings.length;j<he;j++)for(ct=this._rings[j],F=0,Me=ct.length;F<Me-1;F++)Ye=wi(ct[F],ct[F+1],h,F,!0),Ye&&(v[Y]=v[Y]||[],v[Y].push(Ye[0]),(Ye[1]!==ct[F+1]||F===Me-2)&&(v[Y].push(Ye[1]),Y++))}},_simplifyPoints:function(){for(var h=this._parts,v=this.options.smoothFactor,j=0,F=h.length;j<F;j++)h[j]=Ha(h[j],v)},_update:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())},_updatePath:function(){this._renderer._updatePoly(this)},_containsPoint:function(h,v){var j,F,Y,he,Me,Ye,ct=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(h))return!1;for(j=0,he=this._parts.length;j<he;j++)for(Ye=this._parts[j],F=0,Me=Ye.length,Y=Me-1;F<Me;Y=F++)if(!(!v&&F===0)&&Do(h,Ye[Y],Ye[F])<=ct)return!0;return!1}});function d(h,v){return new o(h,v)}o._flat=io;var f=o.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 xl(this._defaultShape(),this._map.options.crs)},_convertLatLngs:function(h){var v=o.prototype._convertLatLngs.call(this,h),j=v.length;return j>=2&&v[0]instanceof ne&&v[0].equals(v[j-1])&&v.pop(),v},_setLatLngs:function(h){o.prototype._setLatLngs.call(this,h),es(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return es(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var h=this._renderer._bounds,v=this.options.weight,j=new fe(v,v);if(h=new J(h.min.subtract(j),h.max.add(j)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(h))){if(this.options.noClip){this._parts=this._rings;return}for(var F=0,Y=this._rings.length,he;F<Y;F++)he=Uc(this._rings[F],h,!0),he.length&&this._parts.push(he)}},_updatePath:function(){this._renderer._updatePoly(this,!0)},_containsPoint:function(h){var v=!1,j,F,Y,he,Me,Ye,ct,Rt;if(!this._pxBounds||!this._pxBounds.contains(h))return!1;for(he=0,ct=this._parts.length;he<ct;he++)for(j=this._parts[he],Me=0,Rt=j.length,Ye=Rt-1;Me<Rt;Ye=Me++)F=j[Me],Y=j[Ye],F.y>h.y!=Y.y>h.y&&h.x<(Y.x-F.x)*(h.y-F.y)/(Y.y-F.y)+F.x&&(v=!v);return v||o.prototype._containsPoint.call(this,h,!0)}});function p(h,v){return new f(h,v)}var b=ks.extend({initialize:function(h,v){A(this,v),this._layers={},h&&this.addData(h)},addData:function(h){var v=B(h)?h:h.features,j,F,Y;if(v){for(j=0,F=v.length;j<F;j++)Y=v[j],(Y.geometries||Y.geometry||Y.features||Y.coordinates)&&this.addData(Y);return this}var he=this.options;if(he.filter&&!he.filter(h))return this;var Me=w(h,he);return Me?(Me.feature=je(h),Me.defaultOptions=Me.options,this.resetStyle(Me),he.onEachFeature&&he.onEachFeature(h,Me),this.addLayer(Me)):this},resetStyle:function(h){return h===void 0?this.eachLayer(this.resetStyle,this):(h.options=i({},h.defaultOptions),this._setLayerStyle(h,this.options.style),this)},setStyle:function(h){return this.eachLayer(function(v){this._setLayerStyle(v,h)},this)},_setLayerStyle:function(h,v){h.setStyle&&(typeof v=="function"&&(v=v(h.feature)),h.setStyle(v))}});function w(h,v){var j=h.type==="Feature"?h.geometry:h,F=j?j.coordinates:null,Y=[],he=v&&v.pointToLayer,Me=v&&v.coordsToLatLng||R,Ye,ct,Rt,lr;if(!F&&!j)return null;switch(j.type){case"Point":return Ye=Me(F),S(he,h,Ye,v);case"MultiPoint":for(Rt=0,lr=F.length;Rt<lr;Rt++)Ye=Me(F[Rt]),Y.push(S(he,h,Ye,v));return new ks(Y);case"LineString":case"MultiLineString":return ct=P(F,j.type==="LineString"?0:1,Me),new o(ct,v);case"Polygon":case"MultiPolygon":return ct=P(F,j.type==="Polygon"?1:2,Me),new f(ct,v);case"GeometryCollection":for(Rt=0,lr=j.geometries.length;Rt<lr;Rt++){var Cr=w({geometry:j.geometries[Rt],type:"Feature",properties:h.properties},v);Cr&&Y.push(Cr)}return new ks(Y);case"FeatureCollection":for(Rt=0,lr=j.features.length;Rt<lr;Rt++){var Xr=w(j.features[Rt],v);Xr&&Y.push(Xr)}return new ks(Y);default:throw new Error("Invalid GeoJSON object.")}}function S(h,v,j,F){return h?h(v,j):new zn(j,F&&F.markersInheritOptions&&F)}function R(h){return new ne(h[1],h[0],h[2])}function P(h,v,j){for(var F=[],Y=0,he=h.length,Me;Y<he;Y++)Me=v?P(h[Y],v-1,j):(j||R)(h[Y]),F.push(Me);return F}function X(h,v){return h=ve(h),h.alt!==void 0?[C(h.lng,v),C(h.lat,v),C(h.alt,v)]:[C(h.lng,v),C(h.lat,v)]}function te(h,v,j,F){for(var Y=[],he=0,Me=h.length;he<Me;he++)Y.push(v?te(h[he],es(h[he])?0:v-1,j,F):X(h[he],F));return!v&&j&&Y.length>0&&Y.push(Y[0].slice()),Y}function ue(h,v){return h.feature?i({},h.feature,{geometry:v}):je(v)}function je(h){return h.type==="Feature"||h.type==="FeatureCollection"?h:{type:"Feature",properties:{},geometry:h}}var Fe={toGeoJSON:function(h){return ue(this,{type:"Point",coordinates:X(this.getLatLng(),h)})}};zn.include(Fe),Wi.include(Fe),Is.include(Fe),o.include({toGeoJSON:function(h){var v=!es(this._latlngs),j=te(this._latlngs,v?1:0,!1,h);return ue(this,{type:(v?"Multi":"")+"LineString",coordinates:j})}}),f.include({toGeoJSON:function(h){var v=!es(this._latlngs),j=v&&!es(this._latlngs[0]),F=te(this._latlngs,j?2:v?1:0,!0,h);return v||(F=[F]),ue(this,{type:(j?"Multi":"")+"Polygon",coordinates:F})}}),si.include({toMultiPoint:function(h){var v=[];return this.eachLayer(function(j){v.push(j.toGeoJSON(h).geometry.coordinates)}),ue(this,{type:"MultiPoint",coordinates:v})},toGeoJSON:function(h){var v=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(v==="MultiPoint")return this.toMultiPoint(h);var j=v==="GeometryCollection",F=[];return this.eachLayer(function(Y){if(Y.toGeoJSON){var he=Y.toGeoJSON(h);if(j)F.push(he.geometry);else{var Me=je(he);Me.type==="FeatureCollection"?F.push.apply(F,Me.features):F.push(Me)}}}),j?ue(this,{geometries:F,type:"GeometryCollection"}):{type:"FeatureCollection",features:F}}});function Ue(h,v){return new b(h,v)}var tt=Ue,ut=ln.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(h,v,j){this._url=h,this._bounds=re(v),A(this,j)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(hr(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){Sr(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(h){return this.options.opacity=h,this._image&&this._updateOpacity(),this},setStyle:function(h){return h.opacity&&this.setOpacity(h.opacity),this},bringToFront:function(){return this._map&&Dr(this._image),this},bringToBack:function(){return this._map&&Da(this._image),this},setUrl:function(h){return this._url=h,this._image&&(this._image.src=h),this},setBounds:function(h){return this._bounds=re(h),this._map&&this._reset(),this},getEvents:function(){var h={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(h.zoomanim=this._animateZoom),h},setZIndex:function(h){return this.options.zIndex=h,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var h=this._url.tagName==="IMG",v=this._image=h?this._url:kt("img");if(hr(v,"leaflet-image-layer"),this._zoomAnimated&&hr(v,"leaflet-zoom-animated"),this.options.className&&hr(v,this.options.className),v.onselectstart=N,v.onmousemove=N,v.onload=u(this.fire,this,"load"),v.onerror=u(this._overlayOnError,this,"error"),(this.options.crossOrigin||this.options.crossOrigin==="")&&(v.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),h){this._url=v.src;return}v.src=this._url,v.alt=this.options.alt},_animateZoom:function(h){var v=this._map.getZoomScale(h.zoom),j=this._map._latLngBoundsToNewLayerBounds(this._bounds,h.zoom,h.center).min;Se(this._image,j,v)},_reset:function(){var h=this._image,v=new J(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),j=v.getSize();sr(h,v.min),h.style.width=j.x+"px",h.style.height=j.y+"px"},_updateOpacity:function(){kr(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 h=this.options.errorOverlayUrl;h&&this._url!==h&&(this._url=h,this._image.src=h)},getCenter:function(){return this._bounds.getCenter()}}),Xt=function(h,v,j){return new ut(h,v,j)},Gt=ut.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var h=this._url.tagName==="VIDEO",v=this._image=h?this._url:kt("video");if(hr(v,"leaflet-image-layer"),this._zoomAnimated&&hr(v,"leaflet-zoom-animated"),this.options.className&&hr(v,this.options.className),v.onselectstart=N,v.onmousemove=N,v.onloadeddata=u(this.fire,this,"load"),h){for(var j=v.getElementsByTagName("source"),F=[],Y=0;Y<j.length;Y++)F.push(j[Y].src);this._url=j.length>0?F:[v.src];return}B(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(v.style,"objectFit")&&(v.style.objectFit="fill"),v.autoplay=!!this.options.autoplay,v.loop=!!this.options.loop,v.muted=!!this.options.muted,v.playsInline=!!this.options.playsInline;for(var he=0;he<this._url.length;he++){var Me=kt("source");Me.src=this._url[he],v.appendChild(Me)}}});function Ft(h,v,j){return new Gt(h,v,j)}var Wr=ut.extend({_initImage:function(){var h=this._image=this._url;hr(h,"leaflet-image-layer"),this._zoomAnimated&&hr(h,"leaflet-zoom-animated"),this.options.className&&hr(h,this.options.className),h.onselectstart=N,h.onmousemove=N}});function Ur(h,v,j){return new Wr(h,v,j)}var fa=ln.extend({options:{interactive:!1,offset:[0,0],className:"",pane:void 0,content:""},initialize:function(h,v){h&&(h instanceof ne||B(h))?(this._latlng=ve(h),A(this,v)):(A(this,h),this._source=v),this.options.content&&(this._content=this.options.content)},openOn:function(h){return h=arguments.length?h:this._source._map,h.hasLayer(this)||h.addLayer(this),this},close:function(){return this._map&&this._map.removeLayer(this),this},toggle:function(h){return this._map?this.close():(arguments.length?this._source=h:h=this._source,this._prepareOpen(),this.openOn(h._map)),this},onAdd:function(h){this._zoomAnimated=h._zoomAnimated,this._container||this._initLayout(),h._fadeAnimated&&kr(this._container,0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),h._fadeAnimated&&kr(this._container,1),this.bringToFront(),this.options.interactive&&(hr(this._container,"leaflet-interactive"),this.addInteractiveTarget(this._container))},onRemove:function(h){h._fadeAnimated?(kr(this._container,0),this._removeTimeout=setTimeout(u(Sr,void 0,this._container),200)):Sr(this._container),this.options.interactive&&(Jr(this._container,"leaflet-interactive"),this.removeInteractiveTarget(this._container))},getLatLng:function(){return this._latlng},setLatLng:function(h){return this._latlng=ve(h),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(h){return this._content=h,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 h={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(h.zoomanim=this._animateZoom),h},isOpen:function(){return!!this._map&&this._map.hasLayer(this)},bringToFront:function(){return this._map&&Dr(this._container),this},bringToBack:function(){return this._map&&Da(this._container),this},_prepareOpen:function(h){var v=this._source;if(!v._map)return!1;if(v instanceof ks){v=null;var j=this._source._layers;for(var F in j)if(j[F]._map){v=j[F];break}if(!v)return!1;this._source=v}if(!h)if(v.getCenter)h=v.getCenter();else if(v.getLatLng)h=v.getLatLng();else if(v.getBounds)h=v.getBounds().getCenter();else throw new Error("Unable to get source layer LatLng.");return this.setLatLng(h),this._map&&this.update(),!0},_updateContent:function(){if(this._content){var h=this._contentNode,v=typeof this._content=="function"?this._content(this._source||this):this._content;if(typeof v=="string")h.innerHTML=v;else{for(;h.hasChildNodes();)h.removeChild(h.firstChild);h.appendChild(v)}this.fire("contentupdate")}},_updatePosition:function(){if(this._map){var h=this._map.latLngToLayerPoint(this._latlng),v=ye(this.options.offset),j=this._getAnchor();this._zoomAnimated?sr(this._container,h.add(j)):v=v.add(h).add(j);var F=this._containerBottom=-v.y,Y=this._containerLeft=-Math.round(this._containerWidth/2)+v.x;this._container.style.bottom=F+"px",this._container.style.left=Y+"px"}},_getAnchor:function(){return[0,0]}});Qr.include({_initOverlay:function(h,v,j,F){var Y=v;return Y instanceof h||(Y=new h(F).setContent(v)),j&&Y.setLatLng(j),Y}}),ln.include({_initOverlay:function(h,v,j,F){var Y=j;return Y instanceof h?(A(Y,F),Y._source=this):(Y=v&&!F?v:new h(F,this),Y.setContent(j)),Y}});var Rn=fa.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(h){return h=arguments.length?h:this._source._map,!h.hasLayer(this)&&h._popup&&h._popup.options.autoClose&&h.removeLayer(h._popup),h._popup=this,fa.prototype.openOn.call(this,h)},onAdd:function(h){fa.prototype.onAdd.call(this,h),h.fire("popupopen",{popup:this}),this._source&&(this._source.fire("popupopen",{popup:this},!0),this._source instanceof fs||this._source.on("preclick",Zn))},onRemove:function(h){fa.prototype.onRemove.call(this,h),h.fire("popupclose",{popup:this}),this._source&&(this._source.fire("popupclose",{popup:this},!0),this._source instanceof fs||this._source.off("preclick",Zn))},getEvents:function(){var h=fa.prototype.getEvents.call(this);return(this.options.closeOnClick!==void 0?this.options.closeOnClick:this._map.options.closePopupOnClick)&&(h.preclick=this.close),this.options.keepInView&&(h.moveend=this._adjustPan),h},_initLayout:function(){var h="leaflet-popup",v=this._container=kt("div",h+" "+(this.options.className||"")+" leaflet-zoom-animated"),j=this._wrapper=kt("div",h+"-content-wrapper",v);if(this._contentNode=kt("div",h+"-content",j),qn(v),ws(this._contentNode),Rr(v,"contextmenu",Zn),this._tipContainer=kt("div",h+"-tip-container",v),this._tip=kt("div",h+"-tip",this._tipContainer),this.options.closeButton){var F=this._closeButton=kt("a",h+"-close-button",v);F.setAttribute("role","button"),F.setAttribute("aria-label","Close popup"),F.href="#close",F.innerHTML='<span aria-hidden="true">×</span>',Rr(F,"click",function(Y){qa(Y),this.close()},this)}},_updateLayout:function(){var h=this._contentNode,v=h.style;v.width="",v.whiteSpace="nowrap";var j=h.offsetWidth;j=Math.min(j,this.options.maxWidth),j=Math.max(j,this.options.minWidth),v.width=j+1+"px",v.whiteSpace="",v.height="";var F=h.offsetHeight,Y=this.options.maxHeight,he="leaflet-popup-scrolled";Y&&F>Y?(v.height=Y+"px",hr(h,he)):Jr(h,he),this._containerWidth=this._container.offsetWidth},_animateZoom:function(h){var v=this._map._latLngToNewLayerPoint(this._latlng,h.zoom,h.center),j=this._getAnchor();sr(this._container,v.add(j))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning){this._autopanning=!1;return}var h=this._map,v=parseInt(Pe(this._container,"marginBottom"),10)||0,j=this._container.offsetHeight+v,F=this._containerWidth,Y=new fe(this._containerLeft,-j-this._containerBottom);Y._add(Ea(this._container));var he=h.layerPointToContainerPoint(Y),Me=ye(this.options.autoPanPadding),Ye=ye(this.options.autoPanPaddingTopLeft||Me),ct=ye(this.options.autoPanPaddingBottomRight||Me),Rt=h.getSize(),lr=0,Cr=0;he.x+F+ct.x>Rt.x&&(lr=he.x+F-Rt.x+ct.x),he.x-lr-Ye.x<0&&(lr=he.x-Ye.x),he.y+j+ct.y>Rt.y&&(Cr=he.y+j-Rt.y+ct.y),he.y-Cr-Ye.y<0&&(Cr=he.y-Ye.y),(lr||Cr)&&(this.options.keepInView&&(this._autopanning=!0),h.fire("autopanstart").panBy([lr,Cr]))}},_getAnchor:function(){return ye(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),Mn=function(h,v){return new Rn(h,v)};Qr.mergeOptions({closePopupOnClick:!0}),Qr.include({openPopup:function(h,v,j){return this._initOverlay(Rn,h,v,j).openOn(this),this},closePopup:function(h){return h=arguments.length?h:this._popup,h&&h.close(),this}}),ln.include({bindPopup:function(h,v){return this._popup=this._initOverlay(Rn,this._popup,h,v),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(h){return this._popup&&(this instanceof ks||(this._popup._source=this),this._popup._prepareOpen(h||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(h){return this._popup&&this._popup.setContent(h),this},getPopup:function(){return this._popup},_openPopup:function(h){if(!(!this._popup||!this._map)){us(h);var v=h.layer||h.target;if(this._popup._source===v&&!(v instanceof fs)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(h.latlng);return}this._popup._source=v,this.openPopup(h.latlng)}},_movePopup:function(h){this._popup.setLatLng(h.latlng)},_onKeyPress:function(h){h.originalEvent.keyCode===13&&this._openPopup(h)}});var ca=fa.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(h){fa.prototype.onAdd.call(this,h),this.setOpacity(this.options.opacity),h.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(h){fa.prototype.onRemove.call(this,h),h.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var h=fa.prototype.getEvents.call(this);return this.options.permanent||(h.preclick=this.close),h},_initLayout:function(){var h="leaflet-tooltip",v=h+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=kt("div",v),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+y(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(h){var v,j,F=this._map,Y=this._container,he=F.latLngToContainerPoint(F.getCenter()),Me=F.layerPointToContainerPoint(h),Ye=this.options.direction,ct=Y.offsetWidth,Rt=Y.offsetHeight,lr=ye(this.options.offset),Cr=this._getAnchor();Ye==="top"?(v=ct/2,j=Rt):Ye==="bottom"?(v=ct/2,j=0):Ye==="center"?(v=ct/2,j=Rt/2):Ye==="right"?(v=0,j=Rt/2):Ye==="left"?(v=ct,j=Rt/2):Me.x<he.x?(Ye="right",v=0,j=Rt/2):(Ye="left",v=ct+(lr.x+Cr.x)*2,j=Rt/2),h=h.subtract(ye(v,j,!0)).add(lr).add(Cr),Jr(Y,"leaflet-tooltip-right"),Jr(Y,"leaflet-tooltip-left"),Jr(Y,"leaflet-tooltip-top"),Jr(Y,"leaflet-tooltip-bottom"),hr(Y,"leaflet-tooltip-"+Ye),sr(Y,h)},_updatePosition:function(){var h=this._map.latLngToLayerPoint(this._latlng);this._setPosition(h)},setOpacity:function(h){this.options.opacity=h,this._container&&kr(this._container,h)},_animateZoom:function(h){var v=this._map._latLngToNewLayerPoint(this._latlng,h.zoom,h.center);this._setPosition(v)},_getAnchor:function(){return ye(this._source&&this._source._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}}),bn=function(h,v){return new ca(h,v)};Qr.include({openTooltip:function(h,v,j){return this._initOverlay(ca,h,v,j).openOn(this),this},closeTooltip:function(h){return h.close(),this}}),ln.include({bindTooltip:function(h,v){return this._tooltip&&this.isTooltipOpen()&&this.unbindTooltip(),this._tooltip=this._initOverlay(ca,this._tooltip,h,v),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(h){if(!(!h&&this._tooltipHandlersAdded)){var v=h?"off":"on",j={remove:this.closeTooltip,move:this._moveTooltip};this._tooltip.options.permanent?j.add=this._openTooltip:(j.mouseover=this._openTooltip,j.mouseout=this.closeTooltip,j.click=this._openTooltip,this._map?this._addFocusListeners():j.add=this._addFocusListeners),this._tooltip.options.sticky&&(j.mousemove=this._moveTooltip),this[v](j),this._tooltipHandlersAdded=!h}},openTooltip:function(h){return this._tooltip&&(this instanceof ks||(this._tooltip._source=this),this._tooltip._prepareOpen(h)&&(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(h){return this._tooltip&&this._tooltip.setContent(h),this},getTooltip:function(){return this._tooltip},_addFocusListeners:function(){this.getElement?this._addFocusListenersOnLayer(this):this.eachLayer&&this.eachLayer(this._addFocusListenersOnLayer,this)},_addFocusListenersOnLayer:function(h){var v=typeof h.getElement=="function"&&h.getElement();v&&(Rr(v,"focus",function(){this._tooltip._source=h,this.openTooltip()},this),Rr(v,"blur",this.closeTooltip,this))},_setAriaDescribedByOnLayer:function(h){var v=typeof h.getElement=="function"&&h.getElement();v&&v.setAttribute("aria-describedby",this._tooltip._container.id)},_openTooltip:function(h){if(!(!this._tooltip||!this._map)){if(this._map.dragging&&this._map.dragging.moving()&&!this._openOnceFlag){this._openOnceFlag=!0;var v=this;this._map.once("moveend",function(){v._openOnceFlag=!1,v._openTooltip(h)});return}this._tooltip._source=h.layer||h.target,this.openTooltip(this._tooltip.options.sticky?h.latlng:void 0)}},_moveTooltip:function(h){var v=h.latlng,j,F;this._tooltip.options.sticky&&h.originalEvent&&(j=this._map.mouseEventToContainerPoint(h.originalEvent),F=this._map.containerPointToLayerPoint(j),v=this._map.layerPointToLatLng(F)),this._tooltip.setLatLng(v)}});var Hn=Ls.extend({options:{iconSize:[12,12],html:!1,bgPos:null,className:"leaflet-div-icon"},createIcon:function(h){var v=h&&h.tagName==="DIV"?h:document.createElement("div"),j=this.options;if(j.html instanceof Element?(la(v),v.appendChild(j.html)):v.innerHTML=j.html!==!1?j.html:"",j.bgPos){var F=ye(j.bgPos);v.style.backgroundPosition=-F.x+"px "+-F.y+"px"}return this._setIconStyles(v,"icon"),v},createShadow:function(){return null}});function co(h){return new Hn(h)}Ls.Default=Lo;var Ss=ln.extend({options:{tileSize:256,opacity:1,updateWhenIdle:Ut.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(h){A(this,h)},onAdd:function(){this._initContainer(),this._levels={},this._tiles={},this._resetView()},beforeAdd:function(h){h._addZoomLimit(this)},onRemove:function(h){this._removeAllTiles(),Sr(this._container),h._removeZoomLimit(this),this._container=null,this._tileZoom=void 0},bringToFront:function(){return this._map&&(Dr(this._container),this._setAutoZIndex(Math.max)),this},bringToBack:function(){return this._map&&(Da(this._container),this._setAutoZIndex(Math.min)),this},getContainer:function(){return this._container},setOpacity:function(h){return this.options.opacity=h,this._updateOpacity(),this},setZIndex:function(h){return this.options.zIndex=h,this._updateZIndex(),this},isLoading:function(){return this._loading},redraw:function(){if(this._map){this._removeAllTiles();var h=this._clampZoom(this._map.getZoom());h!==this._tileZoom&&(this._tileZoom=h,this._updateLevels()),this._update()}return this},getEvents:function(){var h={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||(this._onMove=x(this._onMoveEnd,this.options.updateInterval,this)),h.move=this._onMove),this._zoomAnimated&&(h.zoomanim=this._animateZoom),h},createTile:function(){return document.createElement("div")},getTileSize:function(){var h=this.options.tileSize;return h instanceof fe?h:new fe(h,h)},_updateZIndex:function(){this._container&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(h){for(var v=this.getPane().children,j=-h(-1/0,1/0),F=0,Y=v.length,he;F<Y;F++)he=v[F].style.zIndex,v[F]!==this._container&&he&&(j=h(j,+he));isFinite(j)&&(this.options.zIndex=j+h(-1,1),this._updateZIndex())},_updateOpacity:function(){if(this._map&&!Ut.ielt9){kr(this._container,this.options.opacity);var h=+new Date,v=!1,j=!1;for(var F in this._tiles){var Y=this._tiles[F];if(!(!Y.current||!Y.loaded)){var he=Math.min(1,(h-Y.loaded)/200);kr(Y.el,he),he<1?v=!0:(Y.active?j=!0:this._onOpaqueTile(Y),Y.active=!0)}}j&&!this._noPrune&&this._pruneTiles(),v&&(se(this._fadeFrame),this._fadeFrame=oe(this._updateOpacity,this))}},_onOpaqueTile:N,_initContainer:function(){this._container||(this._container=kt("div","leaflet-layer "+(this.options.className||"")),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))},_updateLevels:function(){var h=this._tileZoom,v=this.options.maxZoom;if(h!==void 0){for(var j in this._levels)j=Number(j),this._levels[j].el.children.length||j===h?(this._levels[j].el.style.zIndex=v-Math.abs(h-j),this._onUpdateLevel(j)):(Sr(this._levels[j].el),this._removeTilesAtZoom(j),this._onRemoveLevel(j),delete this._levels[j]);var F=this._levels[h],Y=this._map;return F||(F=this._levels[h]={},F.el=kt("div","leaflet-tile-container leaflet-zoom-animated",this._container),F.el.style.zIndex=v,F.origin=Y.project(Y.unproject(Y.getPixelOrigin()),h).round(),F.zoom=h,this._setZoomTransform(F,Y.getCenter(),Y.getZoom()),N(F.el.offsetWidth),this._onCreateLevel(F)),this._level=F,F}},_onUpdateLevel:N,_onRemoveLevel:N,_onCreateLevel:N,_pruneTiles:function(){if(this._map){var h,v,j=this._map.getZoom();if(j>this.options.maxZoom||j<this.options.minZoom){this._removeAllTiles();return}for(h in this._tiles)v=this._tiles[h],v.retain=v.current;for(h in this._tiles)if(v=this._tiles[h],v.current&&!v.active){var F=v.coords;this._retainParent(F.x,F.y,F.z,F.z-5)||this._retainChildren(F.x,F.y,F.z,F.z+2)}for(h in this._tiles)this._tiles[h].retain||this._removeTile(h)}},_removeTilesAtZoom:function(h){for(var v in this._tiles)this._tiles[v].coords.z===h&&this._removeTile(v)},_removeAllTiles:function(){for(var h in this._tiles)this._removeTile(h)},_invalidateAll:function(){for(var h in this._levels)Sr(this._levels[h].el),this._onRemoveLevel(Number(h)),delete this._levels[h];this._removeAllTiles(),this._tileZoom=void 0},_retainParent:function(h,v,j,F){var Y=Math.floor(h/2),he=Math.floor(v/2),Me=j-1,Ye=new fe(+Y,+he);Ye.z=+Me;var ct=this._tileCoordsToKey(Ye),Rt=this._tiles[ct];return Rt&&Rt.active?(Rt.retain=!0,!0):(Rt&&Rt.loaded&&(Rt.retain=!0),Me>F?this._retainParent(Y,he,Me,F):!1)},_retainChildren:function(h,v,j,F){for(var Y=2*h;Y<2*h+2;Y++)for(var he=2*v;he<2*v+2;he++){var Me=new fe(Y,he);Me.z=j+1;var Ye=this._tileCoordsToKey(Me),ct=this._tiles[Ye];if(ct&&ct.active){ct.retain=!0;continue}else ct&&ct.loaded&&(ct.retain=!0);j+1<F&&this._retainChildren(Y,he,j+1,F)}},_resetView:function(h){var v=h&&(h.pinch||h.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),v,v)},_animateZoom:function(h){this._setView(h.center,h.zoom,!0,h.noUpdate)},_clampZoom:function(h){var v=this.options;return v.minNativeZoom!==void 0&&h<v.minNativeZoom?v.minNativeZoom:v.maxNativeZoom!==void 0&&v.maxNativeZoom<h?v.maxNativeZoom:h},_setView:function(h,v,j,F){var Y=Math.round(v);this.options.maxZoom!==void 0&&Y>this.options.maxZoom||this.options.minZoom!==void 0&&Y<this.options.minZoom?Y=void 0:Y=this._clampZoom(Y);var he=this.options.updateWhenZooming&&Y!==this._tileZoom;(!F||he)&&(this._tileZoom=Y,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),Y!==void 0&&this._update(h),j||this._pruneTiles(),this._noPrune=!!j),this._setZoomTransforms(h,v)},_setZoomTransforms:function(h,v){for(var j in this._levels)this._setZoomTransform(this._levels[j],h,v)},_setZoomTransform:function(h,v,j){var F=this._map.getZoomScale(j,h.zoom),Y=h.origin.multiplyBy(F).subtract(this._map._getNewPixelOrigin(v,j)).round();Ut.any3d?Se(h.el,Y,F):sr(h.el,Y)},_resetGrid:function(){var h=this._map,v=h.options.crs,j=this._tileSize=this.getTileSize(),F=this._tileZoom,Y=this._map.getPixelWorldBounds(this._tileZoom);Y&&(this._globalTileRange=this._pxBoundsToTileRange(Y)),this._wrapX=v.wrapLng&&!this.options.noWrap&&[Math.floor(h.project([0,v.wrapLng[0]],F).x/j.x),Math.ceil(h.project([0,v.wrapLng[1]],F).x/j.y)],this._wrapY=v.wrapLat&&!this.options.noWrap&&[Math.floor(h.project([v.wrapLat[0],0],F).y/j.x),Math.ceil(h.project([v.wrapLat[1],0],F).y/j.y)]},_onMoveEnd:function(){!this._map||this._map._animatingZoom||this._update()},_getTiledPixelBounds:function(h){var v=this._map,j=v._animatingZoom?Math.max(v._animateToZoom,v.getZoom()):v.getZoom(),F=v.getZoomScale(j,this._tileZoom),Y=v.project(h,this._tileZoom).floor(),he=v.getSize().divideBy(F*2);return new J(Y.subtract(he),Y.add(he))},_update:function(h){var v=this._map;if(v){var j=this._clampZoom(v.getZoom());if(h===void 0&&(h=v.getCenter()),this._tileZoom!==void 0){var F=this._getTiledPixelBounds(h),Y=this._pxBoundsToTileRange(F),he=Y.getCenter(),Me=[],Ye=this.options.keepBuffer,ct=new J(Y.getBottomLeft().subtract([Ye,-Ye]),Y.getTopRight().add([Ye,-Ye]));if(!(isFinite(Y.min.x)&&isFinite(Y.min.y)&&isFinite(Y.max.x)&&isFinite(Y.max.y)))throw new Error("Attempted to load an infinite number of tiles");for(var Rt in this._tiles){var lr=this._tiles[Rt].coords;(lr.z!==this._tileZoom||!ct.contains(new fe(lr.x,lr.y)))&&(this._tiles[Rt].current=!1)}if(Math.abs(j-this._tileZoom)>1){this._setView(h,j);return}for(var Cr=Y.min.y;Cr<=Y.max.y;Cr++)for(var Xr=Y.min.x;Xr<=Y.max.x;Xr++){var Dn=new fe(Xr,Cr);if(Dn.z=this._tileZoom,!!this._isValidTile(Dn)){var cn=this._tiles[this._tileCoordsToKey(Dn)];cn?cn.current=!0:Me.push(Dn)}}if(Me.sort(function(xa,pa){return xa.distanceTo(he)-pa.distanceTo(he)}),Me.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var Cs=document.createDocumentFragment();for(Xr=0;Xr<Me.length;Xr++)this._addTile(Me[Xr],Cs);this._level.el.appendChild(Cs)}}}},_isValidTile:function(h){var v=this._map.options.crs;if(!v.infinite){var j=this._globalTileRange;if(!v.wrapLng&&(h.x<j.min.x||h.x>j.max.x)||!v.wrapLat&&(h.y<j.min.y||h.y>j.max.y))return!1}if(!this.options.bounds)return!0;var F=this._tileCoordsToBounds(h);return re(this.options.bounds).overlaps(F)},_keyToBounds:function(h){return this._tileCoordsToBounds(this._keyToTileCoords(h))},_tileCoordsToNwSe:function(h){var v=this._map,j=this.getTileSize(),F=h.scaleBy(j),Y=F.add(j),he=v.unproject(F,h.z),Me=v.unproject(Y,h.z);return[he,Me]},_tileCoordsToBounds:function(h){var v=this._tileCoordsToNwSe(h),j=new ie(v[0],v[1]);return this.options.noWrap||(j=this._map.wrapLatLngBounds(j)),j},_tileCoordsToKey:function(h){return h.x+":"+h.y+":"+h.z},_keyToTileCoords:function(h){var v=h.split(":"),j=new fe(+v[0],+v[1]);return j.z=+v[2],j},_removeTile:function(h){var v=this._tiles[h];v&&(Sr(v.el),delete this._tiles[h],this.fire("tileunload",{tile:v.el,coords:this._keyToTileCoords(h)}))},_initTile:function(h){hr(h,"leaflet-tile");var v=this.getTileSize();h.style.width=v.x+"px",h.style.height=v.y+"px",h.onselectstart=N,h.onmousemove=N,Ut.ielt9&&this.options.opacity<1&&kr(h,this.options.opacity)},_addTile:function(h,v){var j=this._getTilePos(h),F=this._tileCoordsToKey(h),Y=this.createTile(this._wrapCoords(h),u(this._tileReady,this,h));this._initTile(Y),this.createTile.length<2&&oe(u(this._tileReady,this,h,null,Y)),sr(Y,j),this._tiles[F]={el:Y,coords:h,current:!0},v.appendChild(Y),this.fire("tileloadstart",{tile:Y,coords:h})},_tileReady:function(h,v,j){v&&this.fire("tileerror",{error:v,tile:j,coords:h});var F=this._tileCoordsToKey(h);j=this._tiles[F],j&&(j.loaded=+new Date,this._map._fadeAnimated?(kr(j.el,0),se(this._fadeFrame),this._fadeFrame=oe(this._updateOpacity,this)):(j.active=!0,this._pruneTiles()),v||(hr(j.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:j.el,coords:h})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),Ut.ielt9||!this._map._fadeAnimated?oe(this._pruneTiles,this):setTimeout(u(this._pruneTiles,this),250)))},_getTilePos:function(h){return h.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(h){var v=new fe(this._wrapX?k(h.x,this._wrapX):h.x,this._wrapY?k(h.y,this._wrapY):h.y);return v.z=h.z,v},_pxBoundsToTileRange:function(h){var v=this.getTileSize();return new J(h.min.unscaleBy(v).floor(),h.max.unscaleBy(v).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var h in this._tiles)if(!this._tiles[h].loaded)return!1;return!0}});function Wc(h){return new Ss(h)}var ki=Ss.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(h,v){this._url=h,v=A(this,v),v.detectRetina&&Ut.retina&&v.maxZoom>0?(v.tileSize=Math.floor(v.tileSize/2),v.zoomReverse?(v.zoomOffset--,v.minZoom=Math.min(v.maxZoom,v.minZoom+1)):(v.zoomOffset++,v.maxZoom=Math.max(v.minZoom,v.maxZoom-1)),v.minZoom=Math.max(0,v.minZoom)):v.zoomReverse?v.minZoom=Math.min(v.maxZoom,v.minZoom):v.maxZoom=Math.max(v.minZoom,v.maxZoom),typeof v.subdomains=="string"&&(v.subdomains=v.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(h,v){return this._url===h&&v===void 0&&(v=!0),this._url=h,v||this.redraw(),this},createTile:function(h,v){var j=document.createElement("img");return Rr(j,"load",u(this._tileOnLoad,this,v,j)),Rr(j,"error",u(this._tileOnError,this,v,j)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(j.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),typeof this.options.referrerPolicy=="string"&&(j.referrerPolicy=this.options.referrerPolicy),j.alt="",j.src=this.getTileUrl(h),j},getTileUrl:function(h){var v={r:Ut.retina?"@2x":"",s:this._getSubdomain(h),x:h.x,y:h.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var j=this._globalTileRange.max.y-h.y;this.options.tms&&(v.y=j),v["-y"]=j}return U(this._url,i(v,this.options))},_tileOnLoad:function(h,v){Ut.ielt9?setTimeout(u(h,this,null,v),0):h(null,v)},_tileOnError:function(h,v,j){var F=this.options.errorTileUrl;F&&v.getAttribute("src")!==F&&(v.src=F),h(j,v)},_onTileRemove:function(h){h.tile.onload=null},_getZoomForUrl:function(){var h=this._tileZoom,v=this.options.maxZoom,j=this.options.zoomReverse,F=this.options.zoomOffset;return j&&(h=v-h),h+F},_getSubdomain:function(h){var v=Math.abs(h.x+h.y)%this.options.subdomains.length;return this.options.subdomains[v]},_abortLoading:function(){var h,v;for(h in this._tiles)if(this._tiles[h].coords.z!==this._tileZoom&&(v=this._tiles[h].el,v.onload=N,v.onerror=N,!v.complete)){v.src=Z;var j=this._tiles[h].coords;Sr(v),delete this._tiles[h],this.fire("tileabort",{tile:v,coords:j})}},_removeTile:function(h){var v=this._tiles[h];if(v)return v.el.setAttribute("src",Z),Ss.prototype._removeTile.call(this,h)},_tileReady:function(h,v,j){if(!(!this._map||j&&j.getAttribute("src")===Z))return Ss.prototype._tileReady.call(this,h,v,j)}});function Ps(h,v){return new ki(h,v)}var ac=ki.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(h,v){this._url=h;var j=i({},this.defaultWmsParams);for(var F in v)F in this.options||(j[F]=v[F]);v=A(this,v);var Y=v.detectRetina&&Ut.retina?2:1,he=this.getTileSize();j.width=he.x*Y,j.height=he.y*Y,this.wmsParams=j},onAdd:function(h){this._crs=this.options.crs||h.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var v=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[v]=this._crs.code,ki.prototype.onAdd.call(this,h)},getTileUrl:function(h){var v=this._tileCoordsToNwSe(h),j=this._crs,F=G(j.project(v[0]),j.project(v[1])),Y=F.min,he=F.max,Me=(this._wmsVersion>=1.3&&this._crs===Hi?[Y.y,Y.x,he.y,he.x]:[Y.x,Y.y,he.x,he.y]).join(","),Ye=ki.prototype.getTileUrl.call(this,h);return Ye+I(this.wmsParams,Ye,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+Me},setParams:function(h,v){return i(this.wmsParams,h),v||this.redraw(),this}});function Fs(h,v){return new ac(h,v)}ki.WMS=ac,Ps.wms=Fs;var ms=ln.extend({options:{padding:.1},initialize:function(h){A(this,h),y(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),hr(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 h={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(h.zoomanim=this._onAnimZoom),h},_onAnimZoom:function(h){this._updateTransform(h.center,h.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(h,v){var j=this._map.getZoomScale(v,this._zoom),F=this._map.getSize().multiplyBy(.5+this.options.padding),Y=this._map.project(this._center,v),he=F.multiplyBy(-j).add(Y).subtract(this._map._getNewPixelOrigin(h,v));Ut.any3d?Se(this._container,he,j):sr(this._container,he)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var h in this._layers)this._layers[h]._reset()},_onZoomEnd:function(){for(var h in this._layers)this._layers[h]._project()},_updatePaths:function(){for(var h in this._layers)this._layers[h]._update()},_update:function(){var h=this.options.padding,v=this._map.getSize(),j=this._map.containerPointToLayerPoint(v.multiplyBy(-h)).round();this._bounds=new J(j,j.add(v.multiplyBy(1+h*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),Gc=ms.extend({options:{tolerance:0},getEvents:function(){var h=ms.prototype.getEvents.call(this);return h.viewprereset=this._onViewPreReset,h},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){ms.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var h=this._container=document.createElement("canvas");Rr(h,"mousemove",this._onMouseMove,this),Rr(h,"click dblclick mousedown mouseup contextmenu",this._onClick,this),Rr(h,"mouseout",this._handleMouseOut,this),h._leaflet_disable_events=!0,this._ctx=h.getContext("2d")},_destroyContainer:function(){se(this._redrawRequest),delete this._ctx,Sr(this._container),cr(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var h;this._redrawBounds=null;for(var v in this._layers)h=this._layers[v],h._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){ms.prototype._update.call(this);var h=this._bounds,v=this._container,j=h.getSize(),F=Ut.retina?2:1;sr(v,h.min),v.width=F*j.x,v.height=F*j.y,v.style.width=j.x+"px",v.style.height=j.y+"px",Ut.retina&&this._ctx.scale(2,2),this._ctx.translate(-h.min.x,-h.min.y),this.fire("update")}},_reset:function(){ms.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(h){this._updateDashArray(h),this._layers[y(h)]=h;var v=h._order={layer:h,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=v),this._drawLast=v,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(h){this._requestRedraw(h)},_removePath:function(h){var v=h._order,j=v.next,F=v.prev;j?j.prev=F:this._drawLast=F,F?F.next=j:this._drawFirst=j,delete h._order,delete this._layers[y(h)],this._requestRedraw(h)},_updatePath:function(h){this._extendRedrawBounds(h),h._project(),h._update(),this._requestRedraw(h)},_updateStyle:function(h){this._updateDashArray(h),this._requestRedraw(h)},_updateDashArray:function(h){if(typeof h.options.dashArray=="string"){var v=h.options.dashArray.split(/[, ]+/),j=[],F,Y;for(Y=0;Y<v.length;Y++){if(F=Number(v[Y]),isNaN(F))return;j.push(F)}h.options._dashArray=j}else h.options._dashArray=h.options.dashArray},_requestRedraw:function(h){this._map&&(this._extendRedrawBounds(h),this._redrawRequest=this._redrawRequest||oe(this._redraw,this))},_extendRedrawBounds:function(h){if(h._pxBounds){var v=(h.options.weight||0)+1;this._redrawBounds=this._redrawBounds||new J,this._redrawBounds.extend(h._pxBounds.min.subtract([v,v])),this._redrawBounds.extend(h._pxBounds.max.add([v,v]))}},_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 h=this._redrawBounds;if(h){var v=h.getSize();this._ctx.clearRect(h.min.x,h.min.y,v.x,v.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 h,v=this._redrawBounds;if(this._ctx.save(),v){var j=v.getSize();this._ctx.beginPath(),this._ctx.rect(v.min.x,v.min.y,j.x,j.y),this._ctx.clip()}this._drawing=!0;for(var F=this._drawFirst;F;F=F.next)h=F.layer,(!v||h._pxBounds&&h._pxBounds.intersects(v))&&h._updatePath();this._drawing=!1,this._ctx.restore()},_updatePoly:function(h,v){if(this._drawing){var j,F,Y,he,Me=h._parts,Ye=Me.length,ct=this._ctx;if(Ye){for(ct.beginPath(),j=0;j<Ye;j++){for(F=0,Y=Me[j].length;F<Y;F++)he=Me[j][F],ct[F?"lineTo":"moveTo"](he.x,he.y);v&&ct.closePath()}this._fillStroke(ct,h)}}},_updateCircle:function(h){if(!(!this._drawing||h._empty())){var v=h._point,j=this._ctx,F=Math.max(Math.round(h._radius),1),Y=(Math.max(Math.round(h._radiusY),1)||F)/F;Y!==1&&(j.save(),j.scale(1,Y)),j.beginPath(),j.arc(v.x,v.y/Y,F,0,Math.PI*2,!1),Y!==1&&j.restore(),this._fillStroke(j,h)}},_fillStroke:function(h,v){var j=v.options;j.fill&&(h.globalAlpha=j.fillOpacity,h.fillStyle=j.fillColor||j.color,h.fill(j.fillRule||"evenodd")),j.stroke&&j.weight!==0&&(h.setLineDash&&h.setLineDash(v.options&&v.options._dashArray||[]),h.globalAlpha=j.opacity,h.lineWidth=j.weight,h.strokeStyle=j.color,h.lineCap=j.lineCap,h.lineJoin=j.lineJoin,h.stroke())},_onClick:function(h){for(var v=this._map.mouseEventToLayerPoint(h),j,F,Y=this._drawFirst;Y;Y=Y.next)j=Y.layer,j.options.interactive&&j._containsPoint(v)&&(!(h.type==="click"||h.type==="preclick")||!this._map._draggableMoved(j))&&(F=j);this._fireEvent(F?[F]:!1,h)},_onMouseMove:function(h){if(!(!this._map||this._map.dragging.moving()||this._map._animatingZoom)){var v=this._map.mouseEventToLayerPoint(h);this._handleMouseHover(h,v)}},_handleMouseOut:function(h){var v=this._hoveredLayer;v&&(Jr(this._container,"leaflet-interactive"),this._fireEvent([v],h,"mouseout"),this._hoveredLayer=null,this._mouseHoverThrottled=!1)},_handleMouseHover:function(h,v){if(!this._mouseHoverThrottled){for(var j,F,Y=this._drawFirst;Y;Y=Y.next)j=Y.layer,j.options.interactive&&j._containsPoint(v)&&(F=j);F!==this._hoveredLayer&&(this._handleMouseOut(h),F&&(hr(this._container,"leaflet-interactive"),this._fireEvent([F],h,"mouseover"),this._hoveredLayer=F)),this._fireEvent(this._hoveredLayer?[this._hoveredLayer]:!1,h),this._mouseHoverThrottled=!0,setTimeout(u(function(){this._mouseHoverThrottled=!1},this),32)}},_fireEvent:function(h,v,j){this._map._fireDOMEvent(v,j||v.type,h)},_bringToFront:function(h){var v=h._order;if(v){var j=v.next,F=v.prev;if(j)j.prev=F;else return;F?F.next=j:j&&(this._drawFirst=j),v.prev=this._drawLast,this._drawLast.next=v,v.next=null,this._drawLast=v,this._requestRedraw(h)}},_bringToBack:function(h){var v=h._order;if(v){var j=v.next,F=v.prev;if(F)F.next=j;else return;j?j.prev=F:F&&(this._drawLast=F),v.prev=null,v.next=this._drawFirst,this._drawFirst.prev=v,this._drawFirst=v,this._requestRedraw(h)}}});function nc(h){return Ut.canvas?new Gc(h):null}var uo=(function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(h){return document.createElement("<lvml:"+h+' class="lvml">')}}catch(h){}return function(h){return document.createElement("<"+h+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}})(),i0={_initContainer:function(){this._container=kt("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(ms.prototype._update.call(this),this.fire("update"))},_initPath:function(h){var v=h._container=uo("shape");hr(v,"leaflet-vml-shape "+(this.options.className||"")),v.coordsize="1 1",h._path=uo("path"),v.appendChild(h._path),this._updateStyle(h),this._layers[y(h)]=h},_addPath:function(h){var v=h._container;this._container.appendChild(v),h.options.interactive&&h.addInteractiveTarget(v)},_removePath:function(h){var v=h._container;Sr(v),h.removeInteractiveTarget(v),delete this._layers[y(h)]},_updateStyle:function(h){var v=h._stroke,j=h._fill,F=h.options,Y=h._container;Y.stroked=!!F.stroke,Y.filled=!!F.fill,F.stroke?(v||(v=h._stroke=uo("stroke")),Y.appendChild(v),v.weight=F.weight+"px",v.color=F.color,v.opacity=F.opacity,F.dashArray?v.dashStyle=B(F.dashArray)?F.dashArray.join(" "):F.dashArray.replace(/( *, *)/g," "):v.dashStyle="",v.endcap=F.lineCap.replace("butt","flat"),v.joinstyle=F.lineJoin):v&&(Y.removeChild(v),h._stroke=null),F.fill?(j||(j=h._fill=uo("fill")),Y.appendChild(j),j.color=F.fillColor||F.color,j.opacity=F.fillOpacity):j&&(Y.removeChild(j),h._fill=null)},_updateCircle:function(h){var v=h._point.round(),j=Math.round(h._radius),F=Math.round(h._radiusY||j);this._setPath(h,h._empty()?"M0 0":"AL "+v.x+","+v.y+" "+j+","+F+" 0,"+65535*360)},_setPath:function(h,v){h._path.v=v},_bringToFront:function(h){Dr(h._container)},_bringToBack:function(h){Da(h._container)}},Ni=Ut.vml?uo:ar,bl=ms.extend({_initContainer:function(){this._container=Ni("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=Ni("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){Sr(this._container),cr(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){ms.prototype._update.call(this);var h=this._bounds,v=h.getSize(),j=this._container;(!this._svgSize||!this._svgSize.equals(v))&&(this._svgSize=v,j.setAttribute("width",v.x),j.setAttribute("height",v.y)),sr(j,h.min),j.setAttribute("viewBox",[h.min.x,h.min.y,v.x,v.y].join(" ")),this.fire("update")}},_initPath:function(h){var v=h._path=Ni("path");h.options.className&&hr(v,h.options.className),h.options.interactive&&hr(v,"leaflet-interactive"),this._updateStyle(h),this._layers[y(h)]=h},_addPath:function(h){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(h._path),h.addInteractiveTarget(h._path)},_removePath:function(h){Sr(h._path),h.removeInteractiveTarget(h._path),delete this._layers[y(h)]},_updatePath:function(h){h._project(),h._update()},_updateStyle:function(h){var v=h._path,j=h.options;v&&(j.stroke?(v.setAttribute("stroke",j.color),v.setAttribute("stroke-opacity",j.opacity),v.setAttribute("stroke-width",j.weight),v.setAttribute("stroke-linecap",j.lineCap),v.setAttribute("stroke-linejoin",j.lineJoin),j.dashArray?v.setAttribute("stroke-dasharray",j.dashArray):v.removeAttribute("stroke-dasharray"),j.dashOffset?v.setAttribute("stroke-dashoffset",j.dashOffset):v.removeAttribute("stroke-dashoffset")):v.setAttribute("stroke","none"),j.fill?(v.setAttribute("fill",j.fillColor||j.color),v.setAttribute("fill-opacity",j.fillOpacity),v.setAttribute("fill-rule",j.fillRule||"evenodd")):v.setAttribute("fill","none"))},_updatePoly:function(h,v){this._setPath(h,or(h._parts,v))},_updateCircle:function(h){var v=h._point,j=Math.max(Math.round(h._radius),1),F=Math.max(Math.round(h._radiusY),1)||j,Y="a"+j+","+F+" 0 1,0 ",he=h._empty()?"M0 0":"M"+(v.x-j)+","+v.y+Y+j*2+",0 "+Y+-j*2+",0 ";this._setPath(h,he)},_setPath:function(h,v){h._path.setAttribute("d",v)},_bringToFront:function(h){Dr(h._path)},_bringToBack:function(h){Da(h._path)}});Ut.vml&&bl.include(i0);function sc(h){return Ut.svg||Ut.vml?new bl(h):null}Qr.include({getRenderer:function(h){var v=h.options.renderer||this._getPaneRenderer(h.options.pane)||this.options.renderer||this._renderer;return v||(v=this._renderer=this._createRenderer()),this.hasLayer(v)||this.addLayer(v),v},_getPaneRenderer:function(h){if(h==="overlayPane"||h===void 0)return!1;var v=this._paneRenderers[h];return v===void 0&&(v=this._createRenderer({pane:h}),this._paneRenderers[h]=v),v},_createRenderer:function(h){return this.options.preferCanvas&&nc(h)||sc(h)}});var Io=f.extend({initialize:function(h,v){f.prototype.initialize.call(this,this._boundsToLatLngs(h),v)},setBounds:function(h){return this.setLatLngs(this._boundsToLatLngs(h))},_boundsToLatLngs:function(h){return h=re(h),[h.getSouthWest(),h.getNorthWest(),h.getNorthEast(),h.getSouthEast()]}});function Em(h,v){return new Io(h,v)}bl.create=Ni,bl.pointsToPath=or,b.geometryToLayer=w,b.coordsToLatLng=R,b.coordsToLatLngs=P,b.latLngToCoords=X,b.latLngsToCoords=te,b.getFeature=ue,b.asFeature=je,Qr.mergeOptions({boxZoom:!0});var gs=Qn.extend({initialize:function(h){this._map=h,this._container=h._container,this._pane=h._panes.overlayPane,this._resetStateTimeout=0,h.on("unload",this._destroy,this)},addHooks:function(){Rr(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){cr(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){Sr(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(h){if(!h.shiftKey||h.which!==1&&h.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),gn(),Nr(),this._startPoint=this._map.mouseEventToContainerPoint(h),Rr(document,{contextmenu:us,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(h){this._moved||(this._moved=!0,this._box=kt("div","leaflet-zoom-box",this._container),hr(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(h);var v=new J(this._point,this._startPoint),j=v.getSize();sr(this._box,v.min),this._box.style.width=j.x+"px",this._box.style.height=j.y+"px"},_finish:function(){this._moved&&(Sr(this._box),Jr(this._container,"leaflet-crosshair")),Ms(),_a(),cr(document,{contextmenu:us,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(h){if(!(h.which!==1&&h.button!==1)&&(this._finish(),!!this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(u(this._resetState,this),0);var v=new ie(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(v).fire("boxzoomend",{boxZoomBounds:v})}},_onKeyDown:function(h){h.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});Qr.addInitHook("addHandler","boxZoom",gs),Qr.mergeOptions({doubleClickZoom:!0});var $c=Qn.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(h){var v=this._map,j=v.getZoom(),F=v.options.zoomDelta,Y=h.originalEvent.shiftKey?j-F:j+F;v.options.doubleClickZoom==="center"?v.setZoom(Y):v.setZoomAround(h.containerPoint,Y)}});Qr.addInitHook("addHandler","doubleClickZoom",$c),Qr.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var Si=Qn.extend({addHooks:function(){if(!this._draggable){var h=this._map;this._draggable=new _i(h._mapPane,h._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),h.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),h.on("zoomend",this._onZoomEnd,this),h.whenReady(this._onZoomEnd,this))}hr(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){Jr(this._map._container,"leaflet-grab"),Jr(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 h=this._map;if(h._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var v=re(this._map.options.maxBounds);this._offsetLimit=G(this._map.latLngToContainerPoint(v.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(v.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;h.fire("movestart").fire("dragstart"),h.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(h){if(this._map.options.inertia){var v=this._lastTime=+new Date,j=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(j),this._times.push(v),this._prunePositions(v)}this._map.fire("move",h).fire("drag",h)},_prunePositions:function(h){for(;this._positions.length>1&&h-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var h=this._map.getSize().divideBy(2),v=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=v.subtract(h).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(h,v){return h-(h-v)*this._viscosity},_onPreDragLimit:function(){if(!(!this._viscosity||!this._offsetLimit)){var h=this._draggable._newPos.subtract(this._draggable._startPos),v=this._offsetLimit;h.x<v.min.x&&(h.x=this._viscousLimit(h.x,v.min.x)),h.y<v.min.y&&(h.y=this._viscousLimit(h.y,v.min.y)),h.x>v.max.x&&(h.x=this._viscousLimit(h.x,v.max.x)),h.y>v.max.y&&(h.y=this._viscousLimit(h.y,v.max.y)),this._draggable._newPos=this._draggable._startPos.add(h)}},_onPreDragWrap:function(){var h=this._worldWidth,v=Math.round(h/2),j=this._initialWorldOffset,F=this._draggable._newPos.x,Y=(F-v+j)%h+v-j,he=(F+v+j)%h-v-j,Me=Math.abs(Y+j)<Math.abs(he+j)?Y:he;this._draggable._absPos=this._draggable._newPos.clone(),this._draggable._newPos.x=Me},_onDragEnd:function(h){var v=this._map,j=v.options,F=!j.inertia||h.noInertia||this._times.length<2;if(v.fire("dragend",h),F)v.fire("moveend");else{this._prunePositions(+new Date);var Y=this._lastPos.subtract(this._positions[0]),he=(this._lastTime-this._times[0])/1e3,Me=j.easeLinearity,Ye=Y.multiplyBy(Me/he),ct=Ye.distanceTo([0,0]),Rt=Math.min(j.inertiaMaxSpeed,ct),lr=Ye.multiplyBy(Rt/ct),Cr=Rt/(j.inertiaDeceleration*Me),Xr=lr.multiplyBy(-Cr/2).round();!Xr.x&&!Xr.y?v.fire("moveend"):(Xr=v._limitOffset(Xr,v.options.maxBounds),oe(function(){v.panBy(Xr,{duration:Cr,easeLinearity:Me,noMoveStart:!0,animate:!0})}))}}});Qr.addInitHook("addHandler","dragging",Si),Qr.mergeOptions({keyboard:!0,keyboardPanDelta:80});var o0=Qn.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(h){this._map=h,this._setPanDelta(h.options.keyboardPanDelta),this._setZoomDelta(h.options.zoomDelta)},addHooks:function(){var h=this._map._container;h.tabIndex<=0&&(h.tabIndex="0"),Rr(h,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),cr(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 h=document.body,v=document.documentElement,j=h.scrollTop||v.scrollTop,F=h.scrollLeft||v.scrollLeft;this._map._container.focus(),window.scrollTo(F,j)}},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanDelta:function(h){var v=this._panKeys={},j=this.keyCodes,F,Y;for(F=0,Y=j.left.length;F<Y;F++)v[j.left[F]]=[-1*h,0];for(F=0,Y=j.right.length;F<Y;F++)v[j.right[F]]=[h,0];for(F=0,Y=j.down.length;F<Y;F++)v[j.down[F]]=[0,h];for(F=0,Y=j.up.length;F<Y;F++)v[j.up[F]]=[0,-1*h]},_setZoomDelta:function(h){var v=this._zoomKeys={},j=this.keyCodes,F,Y;for(F=0,Y=j.zoomIn.length;F<Y;F++)v[j.zoomIn[F]]=h;for(F=0,Y=j.zoomOut.length;F<Y;F++)v[j.zoomOut[F]]=-h},_addHooks:function(){Rr(document,"keydown",this._onKeyDown,this)},_removeHooks:function(){cr(document,"keydown",this._onKeyDown,this)},_onKeyDown:function(h){if(!(h.altKey||h.ctrlKey||h.metaKey)){var v=h.keyCode,j=this._map,F;if(v in this._panKeys){if(!j._panAnim||!j._panAnim._inProgress)if(F=this._panKeys[v],h.shiftKey&&(F=ye(F).multiplyBy(3)),j.options.maxBounds&&(F=j._limitOffset(ye(F),j.options.maxBounds)),j.options.worldCopyJump){var Y=j.wrapLatLng(j.unproject(j.project(j.getCenter()).add(F)));j.panTo(Y)}else j.panBy(F)}else if(v in this._zoomKeys)j.setZoom(j.getZoom()+(h.shiftKey?3:1)*this._zoomKeys[v]);else if(v===27&&j._popup&&j._popup.options.closeOnEscapeKey)j.closePopup();else return;us(h)}}});Qr.addInitHook("addHandler","keyboard",o0),Qr.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60});var ic=Qn.extend({addHooks:function(){Rr(this._map._container,"wheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){cr(this._map._container,"wheel",this._onWheelScroll,this)},_onWheelScroll:function(h){var v=tn(h),j=this._map.options.wheelDebounceTime;this._delta+=v,this._lastMousePos=this._map.mouseEventToContainerPoint(h),this._startTime||(this._startTime=+new Date);var F=Math.max(j-(+new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(u(this._performZoom,this),F),us(h)},_performZoom:function(){var h=this._map,v=h.getZoom(),j=this._map.options.zoomSnap||0;h._stop();var F=this._delta/(this._map.options.wheelPxPerZoomLevel*4),Y=4*Math.log(2/(1+Math.exp(-Math.abs(F))))/Math.LN2,he=j?Math.ceil(Y/j)*j:Y,Me=h._limitZoom(v+(this._delta>0?he:-he))-v;this._delta=0,this._startTime=null,Me&&(h.options.scrollWheelZoom==="center"?h.setZoom(v+Me):h.setZoomAround(this._lastMousePos,v+Me))}});Qr.addInitHook("addHandler","scrollWheelZoom",ic);var Po=600;Qr.mergeOptions({tapHold:Ut.touchNative&&Ut.safari&&Ut.mobile,tapTolerance:15});var Xc=Qn.extend({addHooks:function(){Rr(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){cr(this._map._container,"touchstart",this._onDown,this)},_onDown:function(h){if(clearTimeout(this._holdTimeout),h.touches.length===1){var v=h.touches[0];this._startPos=this._newPos=new fe(v.clientX,v.clientY),this._holdTimeout=setTimeout(u(function(){this._cancel(),this._isTapValid()&&(Rr(document,"touchend",qa),Rr(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",v))},this),Po),Rr(document,"touchend touchcancel contextmenu",this._cancel,this),Rr(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function h(){cr(document,"touchend",qa),cr(document,"touchend touchcancel",h)},_cancel:function(){clearTimeout(this._holdTimeout),cr(document,"touchend touchcancel contextmenu",this._cancel,this),cr(document,"touchmove",this._onMove,this)},_onMove:function(h){var v=h.touches[0];this._newPos=new fe(v.clientX,v.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(h,v){var j=new MouseEvent(h,{bubbles:!0,cancelable:!0,view:window,screenX:v.screenX,screenY:v.screenY,clientX:v.clientX,clientY:v.clientY});j._simulated=!0,v.target.dispatchEvent(j)}});Qr.addInitHook("addHandler","tapHold",Xc),Qr.mergeOptions({touchZoom:Ut.touch,bounceAtZoomLimits:!0});var l0=Qn.extend({addHooks:function(){hr(this._map._container,"leaflet-touch-zoom"),Rr(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){Jr(this._map._container,"leaflet-touch-zoom"),cr(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(h){var v=this._map;if(!(!h.touches||h.touches.length!==2||v._animatingZoom||this._zooming)){var j=v.mouseEventToContainerPoint(h.touches[0]),F=v.mouseEventToContainerPoint(h.touches[1]);this._centerPoint=v.getSize()._divideBy(2),this._startLatLng=v.containerPointToLatLng(this._centerPoint),v.options.touchZoom!=="center"&&(this._pinchStartLatLng=v.containerPointToLatLng(j.add(F)._divideBy(2))),this._startDist=j.distanceTo(F),this._startZoom=v.getZoom(),this._moved=!1,this._zooming=!0,v._stop(),Rr(document,"touchmove",this._onTouchMove,this),Rr(document,"touchend touchcancel",this._onTouchEnd,this),qa(h)}},_onTouchMove:function(h){if(!(!h.touches||h.touches.length!==2||!this._zooming)){var v=this._map,j=v.mouseEventToContainerPoint(h.touches[0]),F=v.mouseEventToContainerPoint(h.touches[1]),Y=j.distanceTo(F)/this._startDist;if(this._zoom=v.getScaleZoom(Y,this._startZoom),!v.options.bounceAtZoomLimits&&(this._zoom<v.getMinZoom()&&Y<1||this._zoom>v.getMaxZoom()&&Y>1)&&(this._zoom=v._limitZoom(this._zoom)),v.options.touchZoom==="center"){if(this._center=this._startLatLng,Y===1)return}else{var he=j._add(F)._divideBy(2)._subtract(this._centerPoint);if(Y===1&&he.x===0&&he.y===0)return;this._center=v.unproject(v.project(this._pinchStartLatLng,this._zoom).subtract(he),this._zoom)}this._moved||(v._moveStart(!0,!1),this._moved=!0),se(this._animRequest);var Me=u(v._move,v,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=oe(Me,this,!0),qa(h)}},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,se(this._animRequest),cr(document,"touchmove",this._onTouchMove,this),cr(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))}});Qr.addInitHook("addHandler","touchZoom",l0),Qr.BoxZoom=gs,Qr.DoubleClickZoom=$c,Qr.Drag=Si,Qr.Keyboard=o0,Qr.ScrollWheelZoom=ic,Qr.TapHold=Xc,Qr.TouchZoom=l0,a.Bounds=J,a.Browser=Ut,a.CRS=Ve,a.Canvas=Gc,a.Circle=Wi,a.CircleMarker=Is,a.Class=Ce,a.Control=Jn,a.DivIcon=Hn,a.DivOverlay=fa,a.DomEvent=pn,a.DomUtil=za,a.Draggable=_i,a.Evented=K,a.FeatureGroup=ks,a.GeoJSON=b,a.GridLayer=Ss,a.Handler=Qn,a.Icon=Ls,a.ImageOverlay=ut,a.LatLng=ne,a.LatLngBounds=ie,a.Layer=ln,a.LayerGroup=si,a.LineUtil=zc,a.Map=Qr,a.Marker=zn,a.Mixin=Bc,a.Path=fs,a.Point=fe,a.PolyUtil=Mo,a.Polygon=f,a.Polyline=o,a.Popup=Rn,a.PosAnimation=Pi,a.Projection=yl,a.Rectangle=Io,a.Renderer=ms,a.SVG=bl,a.SVGOverlay=Wr,a.TileLayer=ki,a.Tooltip=ca,a.Transformation=Ze,a.Util=ce,a.VideoOverlay=Gt,a.bind=u,a.bounds=G,a.canvas=nc,a.circle=ee,a.circleMarker=ta,a.control=ti,a.divIcon=co,a.extend=i,a.featureGroup=Ns,a.geoJSON=Ue,a.geoJson=tt,a.gridLayer=Wc,a.icon=Vi,a.imageOverlay=Xt,a.latLng=ve,a.latLngBounds=re,a.layerGroup=hs,a.map=fl,a.marker=Vc,a.point=ye,a.polygon=p,a.polyline=d,a.popup=Mn,a.rectangle=Em,a.setOptions=A,a.stamp=y,a.svg=sc,a.svgOverlay=Ur,a.tileLayer=Ps,a.tooltip=bn,a.transformation=Lt,a.version=n,a.videoOverlay=Ft;var c0=window.L;a.noConflict=function(){return window.L=c0,this},window.L=a}))})(tu,tu.exports)),tu.exports}var n0=yP();const d1=gp(n0);function Cm(e,r,a){return Object.freeze({instance:e,context:r,container:a})}function u1(e,r){return r==null?function(n,i){const c=E.useRef(void 0);return c.current||(c.current=e(n,i)),c}:function(n,i){const c=E.useRef(void 0);c.current||(c.current=e(n,i));const u=E.useRef(n),{instance:g}=c.current;return E.useEffect(function(){u.current!==n&&(r(g,n,u.current),u.current=n)},[g,n,r]),c}}function bP(e,r){E.useEffect(function(){var i;return((i=r.layerContainer)!=null?i:r.map).addLayer(e.instance),function(){var u;(u=r.layerContainer)==null||u.removeLayer(e.instance),r.map.removeLayer(e.instance)}},[r,e])}function Dk(e){return function(a){const n=l1(),i=e(c1(a,n),n);return Rk(n.map,a.attribution),Mk(i.current,a.eventHandlers),bP(i.current,n),i}}function vP(e,r){const a=u1(e,r),n=Dk(a);return fP(n)}function Lk(e,r){const a=u1(e),n=xP(a,r);return mP(n)}function _P(e,r){const a=u1(e,r),n=Dk(a);return gP(n)}function wP(e,r,a){const{opacity:n,zIndex:i}=r;n!=null&&n!==a.opacity&&e.setOpacity(n),i!=null&&i!==a.zIndex&&e.setZIndex(i)}function kP(){return l1().map}function NP(C,N){var O=C,{bounds:e,boundsOptions:r,center:a,children:n,className:i,id:c,placeholder:u,style:g,whenReady:y,zoom:x}=O,k=Gs(O,["bounds","boundsOptions","center","children","className","id","placeholder","style","whenReady","zoom"]);const[D]=E.useState({className:i,id:c,style:g}),[A,I]=E.useState(null),z=E.useRef(void 0);E.useImperativeHandle(N,()=>{var V;return(V=A==null?void 0:A.map)!=null?V:null},[A]);const U=E.useCallback(V=>{if(V!==null&&!z.current){const Z=new n0.Map(V,k);z.current=Z,a!=null&&x!=null?Z.setView(a,x):e!=null&&Z.fitBounds(e,r),y!=null&&Z.whenReady(y),I(uP(Z))}},[]);E.useEffect(()=>()=>{A==null||A.map.remove()},[A]);const B=A?ea.createElement(o1,{value:A},n):u!=null?u:null;return ea.createElement("div",$e(_e({},D),{ref:U}),B)}const SP=E.forwardRef(NP),CP=vP(function(i,n){var c=i,{position:r}=c,a=Gs(c,["position"]);const u=new n0.Marker(r,a);return Cm(u,hP(n,{overlayContainer:u}))},function(r,a,n){a.position!==n.position&&r.setLatLng(a.position),a.icon!=null&&a.icon!==n.icon&&r.setIcon(a.icon),a.zIndexOffset!=null&&a.zIndexOffset!==n.zIndexOffset&&r.setZIndexOffset(a.zIndexOffset),a.opacity!=null&&a.opacity!==n.opacity&&r.setOpacity(a.opacity),r.dragging!=null&&a.draggable!==n.draggable&&(a.draggable===!0?r.dragging.enable():r.dragging.disable())}),EP=Lk(function(r,a){const n=new n0.Popup(r,a.overlayContainer);return Cm(n,a)},function(r,a,{position:n},i){E.useEffect(function(){const{instance:u}=r;function g(x){x.popup===u&&(u.update(),i(!0))}function y(x){x.popup===u&&i(!1)}return a.map.on({popupopen:g,popupclose:y}),a.overlayContainer==null?(n!=null&&u.setLatLng(n),u.openOn(a.map)):a.overlayContainer.bindPopup(u),function(){var k;a.map.off({popupopen:g,popupclose:y}),(k=a.overlayContainer)==null||k.unbindPopup(),a.map.removeLayer(u)}},[r,a,i,n])}),jP=_P(function(i,n){var c=i,{url:r}=c,a=Gs(c,["url"]);const u=new n0.TileLayer(r,c1(a,n));return Cm(u,n)},function(r,a,n){wP(r,a,n);const{url:i}=a;i!=null&&i!==n.url&&r.setUrl(i)}),TP=Lk(function(r,a){const n=new n0.Tooltip(r,a.overlayContainer);return Cm(n,a)},function(r,a,{position:n},i){E.useEffect(function(){const u=a.overlayContainer;if(u==null)return;const{instance:g}=r,y=k=>{k.tooltip===g&&(n!=null&&g.setLatLng(n),g.update(),i(!0))},x=k=>{k.tooltip===g&&i(!1)};return u.on({tooltipopen:y,tooltipclose:x}),u.bindTooltip(g),function(){u.off({tooltipopen:y,tooltipclose:x}),u._map!=null&&u.unbindTooltip()}},[r,a,i,n])}),AP="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=",OP="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC",RP=d1.icon({iconUrl:AP,shadowUrl:OP,iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]});d1.Marker.prototype.options.icon=RP;const MP=({locations:e})=>{const r=kP();return E.useEffect(()=>{if(e.length>0&&e.some(a=>a.latitude&&a.longitude)){const a=d1.latLngBounds(e.filter(n=>n.latitude&&n.longitude).map(n=>[n.latitude,n.longitude]));r.fitBounds(a,{padding:[30,30],maxZoom:8})}else r.setView([24.8,45.5],6)},[e,r]),null},DP=()=>{const e=ua(),[r,a]=E.useState(""),[n,i]=E.useState([]),[c,u]=E.useState(!0),g=E.useRef({}),{filterHospital:y,filterSiteName:x,hospitalLocked:k,siteLocked:N,allowedHospitals:C,loading:O,handleHospitalChange:D,handleSiteChange:A}=j3(),I=nn(y),z=E.useMemo(()=>{const oe={custom_is_hospital:1};return C.length>0&&(oe.name=["in",C]),oe},[C]),U=E.useMemo(()=>hl(y,N?x:void 0),[y,x,N]),B=E.useMemo(()=>{const oe={custom_is_phcc:1};return N&&x&&(oe.name=x),oe},[N,x]),V=E.useCallback((oe,se,ce,Ce)=>{const ae=Ce||y;return se==="hospital"&&x&&ae&&nn(ae)&&(oe[ce]=x),oe},[y,x]),Z=(oe,se)=>xe(null,null,function*(){var fe,Oe,ye,J,G,ie,re,ne,ve,Ve,Ae,ze,Re;const ce=se==="phcc",Ce=ce?"custom_site":"company",ae=ce?"site_name":"company",me={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,phcc_asset_names:[]},K=se==="hospital"?oe.name:void 0;try{const Ze=V({[Ce]:oe.name},se,"custom_site",K),Lt=yield _t.apiCall(`/api/resource/Asset?filters=${encodeURIComponent(JSON.stringify(Ze))}&fields=["name"]&limit_page_length=0`),mt=(Lt==null?void 0:Lt.data)||[];me.assets=mt.length,ce&&(me.phcc_asset_names=mt.map(it=>it.name));const Zt=V({[ae]:oe.name,custom_priority_:"Normal",repair_status:["in",["Open","Work In Progress"]]},se,"site_name",K),ar=yield _t.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify(Zt))}&fields=["name"]`);me.normal_work_orders=((fe=ar==null?void 0:ar.data)==null?void 0:fe.length)||0;const or=V({[ae]:oe.name,custom_priority_:"Urgent",repair_status:["in",["Open","Work In Progress"]]},se,"site_name",K),yt=yield _t.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify(or))}&fields=["name"]`);me.urgent_work_orders=((Oe=yt==null?void 0:yt.data)==null?void 0:Oe.length)||0;const nr=it=>V({[ae]:oe.name,repair_status:it},se,"site_name",K),[$t,Er,St,Br,Pt]=yield Promise.all([_t.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify(nr("Open")))}&fields=["name"]`),_t.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify(nr("Work In Progress")))}&fields=["name"]`),_t.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify(nr("Pending Review")))}&fields=["name"]`),_t.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify(nr("Completed")))}&fields=["name"]`),_t.apiCall(`/api/resource/Work_Order?filters=${encodeURIComponent(JSON.stringify(nr("Closed")))}&fields=["name"]`)]);if(me.wo_open=((ye=$t==null?void 0:$t.data)==null?void 0:ye.length)||0,me.wo_progress=((J=Er==null?void 0:Er.data)==null?void 0:J.length)||0,me.wo_review=((G=St==null?void 0:St.data)==null?void 0:G.length)||0,me.wo_completed=((ie=Br==null?void 0:Br.data)==null?void 0:ie.length)||0,me.wo_closed=((re=Pt==null?void 0:Pt.data)==null?void 0:re.length)||0,ce&&me.phcc_asset_names&&me.phcc_asset_names.length>0){const[it,De,Je]=yield Promise.all([_t.apiCall(`/api/resource/Asset Maintenance Log?filters=${encodeURIComponent(JSON.stringify({asset_name:["in",me.phcc_asset_names],maintenance_status:"Planned"}))}&fields=["name"]`),_t.apiCall(`/api/resource/Asset Maintenance Log?filters=${encodeURIComponent(JSON.stringify({asset_name:["in",me.phcc_asset_names],maintenance_status:"Completed"}))}&fields=["name"]`),_t.apiCall(`/api/resource/Asset Maintenance Log?filters=${encodeURIComponent(JSON.stringify({asset_name:["in",me.phcc_asset_names],maintenance_status:"Overdue"}))}&fields=["name"]`)]);me.planned_maintenance=((ne=it==null?void 0:it.data)==null?void 0:ne.length)||0,me.completed_maintenance=((ve=De==null?void 0:De.data)==null?void 0:ve.length)||0,me.overdue_maintenance=((Ve=Je==null?void 0:Je.data)==null?void 0:Ve.length)||0}else if(!ce){const it=vt=>V({custom_hospital_name:oe.name,maintenance_status:vt},se,"site_name",K),[De,Je,Be]=yield Promise.all([_t.apiCall(`/api/resource/Asset Maintenance Log?filters=${encodeURIComponent(JSON.stringify(it("Planned")))}&fields=["name"]`),_t.apiCall(`/api/resource/Asset Maintenance Log?filters=${encodeURIComponent(JSON.stringify(it("Completed")))}&fields=["name"]`),_t.apiCall(`/api/resource/Asset Maintenance Log?filters=${encodeURIComponent(JSON.stringify(it("Overdue")))}&fields=["name"]`)]);me.planned_maintenance=((Ae=De==null?void 0:De.data)==null?void 0:Ae.length)||0,me.completed_maintenance=((ze=Je==null?void 0:Je.data)==null?void 0:ze.length)||0,me.overdue_maintenance=((Re=Be==null?void 0:Be.data)==null?void 0:Re.length)||0}}catch(Ze){console.error(`Error fetching counts for ${oe.name}:`,Ze)}return _e({name:oe.name,latitude:parseFloat(oe.latitude),longitude:parseFloat(oe.longitude),location_type:se},me)}),W=()=>xe(null,null,function*(){u(!0);try{let oe=[];const se=[],ce=N&&x?x:r;if(!ce||y){const ae={latitude:["!=",""],longitude:["!=",""],custom_is_hospital:1};y?ae.name=y:C.length>0&&(ae.name=["in",C]),se.push(xe(null,null,function*(){const me=yield _t.apiCall(`/api/resource/Location?filters=${encodeURIComponent(JSON.stringify(ae))}&fields=["name","latitude","longitude"]&limit_page_length=0`),fe=((me==null?void 0:me.data)||[]).map(Oe=>Z(Oe,"hospital"));return Promise.all(fe)}))}if(!y||ce){const ae={latitude:["!=",""],longitude:["!=",""],custom_is_phcc:1};ce&&(ae.name=ce),se.push(xe(null,null,function*(){const me=yield _t.apiCall(`/api/resource/Location?filters=${encodeURIComponent(JSON.stringify(ae))}&fields=["name","latitude","longitude"]&limit_page_length=0`),fe=((me==null?void 0:me.data)||[]).map(Oe=>Z(Oe,"phcc"));return Promise.all(fe)}))}oe=(yield Promise.all(se)).flat().filter(ae=>!isNaN(ae.latitude)&&!isNaN(ae.longitude)),i(oe)}catch(oe){console.error("Error fetching map data:",oe)}finally{u(!1)}});E.useEffect(()=>{O||(N&&x&&a(x),W())},[y,x,r,O,N,C]);const H=(oe,se,ce)=>{const Ce=new URLSearchParams;oe.location_type==="phcc"?Ce.set("site_name",oe.name):(Ce.set("company",oe.name),x&&nn(oe.name)&&Ce.set("site_name",x)),se&&Ce.set("priority",se),ce&&Ce.set("status",ce),e(`/work-orders?${Ce.toString()}`)},le=oe=>{const se=new URLSearchParams,ce=oe.location_type==="phcc"?"custom_site":"company";se.set(ce,oe.name),e(`/assets?${se.toString()}`)},Q=(oe,se)=>{const ce=new URLSearchParams;oe.location_type==="phcc"?ce.set("phcc",oe.name):ce.set("hospital",oe.name),se&&ce.set("status",se),e(`/maintenance-calendar?${ce.toString()}`)},Ne=oe=>{const ce=oe.location_type==="phcc"?t.jsx("span",{className:"ml-2 px-2 py-0.5 bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300 text-xs font-semibold rounded-full",children:"PHCC"}):t.jsx("span",{className:"ml-2 px-2 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 text-xs font-semibold rounded-full",children:"Hospital"});return t.jsxs("div",{className:"p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg min-w-[280px] max-w-[320px]",children:[t.jsxs("div",{className:"mb-4 pb-3 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h3",{className:"text-lg font-bold text-gray-900 dark:text-white flex items-center flex-wrap",children:[oe.name,ce]}),t.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:["Total Assets: ",t.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:oe.assets})]})]}),t.jsxs("div",{className:"mb-4",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200 mb-2",children:"Work Order Status"}),t.jsxs("div",{className:"flex gap-2 mb-3",children:[t.jsxs("button",{onClick:()=>H(oe,"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:["Normal: ",oe.normal_work_orders]}),t.jsxs("button",{onClick:()=>H(oe,"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:["Urgent: ",oe.urgent_work_orders]})]}),t.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-200 dark:border-gray-700",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-semibold text-gray-700 dark:text-gray-300",children:"Status"}),t.jsx("th",{className:"px-3 py-2 text-left font-semibold text-gray-700 dark:text-gray-300",children:"Count"})]})}),t.jsxs("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:[t.jsxs("tr",{className:"bg-red-50 dark:bg-red-900/20 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors",children:[t.jsx("td",{className:"px-3 py-2 text-red-800 dark:text-red-300 font-medium",children:"Open"}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:()=>H(oe,void 0,"Open"),className:"text-red-700 dark:text-red-400 font-bold hover:underline cursor-pointer",children:oe.wo_open})})]}),t.jsxs("tr",{className:"bg-yellow-50 dark:bg-yellow-900/20 hover:bg-yellow-100 dark:hover:bg-yellow-900/30 transition-colors",children:[t.jsx("td",{className:"px-3 py-2 text-yellow-800 dark:text-yellow-300 font-medium",children:"Work In Progress"}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:()=>H(oe,void 0,"Work In Progress"),className:"text-yellow-700 dark:text-yellow-400 font-bold hover:underline cursor-pointer",children:oe.wo_progress})})]}),t.jsxs("tr",{className:"bg-blue-50 dark:bg-blue-900/20 hover:bg-blue-100 dark:hover:bg-blue-900/30 transition-colors",children:[t.jsx("td",{className:"px-3 py-2 text-blue-800 dark:text-blue-300 font-medium",children:"Pending Review"}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:()=>H(oe,void 0,"Pending Review"),className:"text-blue-700 dark:text-blue-400 font-bold hover:underline cursor-pointer",children:oe.wo_review})})]}),t.jsxs("tr",{className:"bg-green-50 dark:bg-green-900/20 hover:bg-green-100 dark:hover:bg-green-900/30 transition-colors",children:[t.jsx("td",{className:"px-3 py-2 text-green-800 dark:text-green-300 font-medium",children:"Completed"}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:()=>H(oe,void 0,"Completed"),className:"text-green-700 dark:text-green-400 font-bold hover:underline cursor-pointer",children:oe.wo_completed})})]}),t.jsxs("tr",{className:"bg-gray-50 dark:bg-gray-700/40 hover:bg-gray-100 dark:hover:bg-gray-700/60 transition-colors",children:[t.jsx("td",{className:"px-3 py-2 text-gray-800 dark:text-gray-300 font-medium",children:"Closed"}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("button",{onClick:()=>H(oe,void 0,"Closed"),className:"text-gray-700 dark:text-gray-300 font-bold hover:underline cursor-pointer",children:oe.wo_closed})})]})]})]})})]}),t.jsxs("div",{className:"mb-4",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200 mb-2",children:"Preventive Maintenance"}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsxs("button",{onClick:()=>Q(oe,"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:["Planned: ",oe.planned_maintenance]}),t.jsxs("button",{onClick:()=>Q(oe,"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:["Completed: ",oe.completed_maintenance]}),t.jsxs("button",{onClick:()=>Q(oe,"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:["Overdue: ",oe.overdue_maintenance]})]})]}),t.jsxs("div",{className:"flex gap-2 pt-3 border-t border-gray-200 dark:border-gray-700",children:[t.jsx("button",{onClick:()=>le(oe),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:"View Assets"}),t.jsx("button",{onClick:()=>H(oe),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:"View Work Orders"})]})]})};return t.jsxs("div",{className:"h-screen flex flex-col bg-gray-50 dark:bg-gray-900",children:[t.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:t.jsx("h1",{className:"text-xl font-semibold text-gray-800 dark:text-white",children:"Active Map"})}),t.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 relative z-[1000]",children:t.jsxs("div",{className:"flex flex-wrap gap-4 relative z-[1000]",children:[t.jsx("div",{className:"w-64 relative z-[1000]",children:t.jsx(er,{label:"Hospital",doctype:"Location",value:y,onChange:D,filters:z,placeholder:"All Hospitals",disabled:k})}),I&&t.jsx("div",{className:"w-64 relative z-[1000]",children:t.jsx(er,{label:"Site Name",doctype:"Mobile Team Site",value:x,onChange:A,filters:U,placeholder:"All Sites",disabled:N})}),t.jsx("div",{className:"w-64 relative z-[1000]",children:t.jsx(er,{label:"PHCC",doctype:"Location",value:N&&x?x:r,onChange:a,filters:B,placeholder:"Select PHCC",disabled:N})})]})}),t.jsxs("div",{className:"flex-1 relative",style:{zIndex:1},children:[c&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-white bg-opacity-75 dark:bg-gray-900 dark:bg-opacity-75 z-[1000]",children:t.jsx("div",{className:"text-gray-600 dark:text-gray-300",children:O?"Loading filters...":"Loading map data..."})}),t.jsxs(SP,{center:[24.8,45.5],zoom:6,style:{height:"100%",width:"100%"},zoomControl:!0,children:[t.jsx(jP,{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),t.jsx(MP,{locations:n}),n.map(oe=>{const se=oe.urgent_work_orders>0?"🚨 URGENT! ":"",ce=oe.location_type==="phcc",Ce=ce?"🏥 PHCC":"🏨 Hospital",ae=`${oe.name}-${oe.latitude}-${oe.longitude}`;return t.jsxs(CP,{position:[oe.latitude,oe.longitude],ref:me=>{me&&(g.current[ae]=me,setTimeout(()=>{const K=me.getElement();K&&(K.classList.remove("urgent-marker","red-marker","phcc-marker"),oe.urgent_work_orders>0?K.classList.add("urgent-marker","red-marker"):ce&&K.classList.add("phcc-marker"))},100))},children:[t.jsx(TP,{permanent:!1,direction:"right",className:"hospital-tooltip-modern",children:t.jsxs("div",{className:"p-2 bg-white dark:bg-gray-800 rounded-lg shadow-lg min-w-[200px]",children:[t.jsxs("div",{className:"mb-2 pb-2 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h4",{className:"text-sm font-bold text-gray-900 dark:text-white",children:[se,oe.name]}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:Ce}),t.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5",children:["Assets: ",t.jsx("span",{className:"font-semibold text-gray-900 dark:text-white",children:oe.assets})]})]}),t.jsxs("div",{className:"space-y-1 text-xs",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Normal WOs:"}),t.jsx("span",{className:"font-semibold text-blue-700 dark:text-blue-300",children:oe.normal_work_orders})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Urgent WOs:"}),t.jsx("span",{className:"font-semibold text-red-700 dark:text-red-300",children:oe.urgent_work_orders})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Planned PMs:"}),t.jsx("span",{className:"font-semibold text-orange-700 dark:text-orange-300",children:oe.planned_maintenance})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Completed PMs:"}),t.jsx("span",{className:"font-semibold text-green-700 dark:text-green-300",children:oe.completed_maintenance})]})]})]})}),t.jsx(EP,{className:ce?"phcc-popup-container":"hospital-popup-container",maxWidth:320,maxHeight:450,autoPan:!0,keepInView:!0,closeButton:!0,autoClose:!1,children:Ne(oe)})]},ae)})]})]}),t.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;
|
||
}
|
||
|
||
/* PHCC Popup Container - with green left border */
|
||
.phcc-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);
|
||
border-left: 4px solid #28a745;
|
||
}
|
||
|
||
.phcc-popup-container .leaflet-popup-content {
|
||
margin: 0;
|
||
width: auto !important;
|
||
}
|
||
|
||
/* Red Flashing Animation for Urgent Work Orders (Both Hospital & PHCC) */
|
||
/* Fixed: Stays red throughout, just pulses brighter */
|
||
.urgent-marker {
|
||
animation: urgent-flash 2s infinite;
|
||
}
|
||
|
||
@keyframes urgent-flash {
|
||
0%, 50% {
|
||
filter: hue-rotate(120deg) saturate(2) brightness(0.8);
|
||
}
|
||
25%, 75% {
|
||
filter: hue-rotate(120deg) saturate(2.5) brightness(1.5) drop-shadow(0 0 10px red);
|
||
}
|
||
}
|
||
|
||
/* Red marker style (base state for urgent) */
|
||
.red-marker {
|
||
filter: hue-rotate(120deg) saturate(2) brightness(0.8);
|
||
}
|
||
|
||
/* Green marker style for PHCC */
|
||
.phcc-marker {
|
||
filter: hue-rotate(-120deg) saturate(1.3) brightness(1.1);
|
||
}
|
||
|
||
.leaflet-popup {
|
||
z-index: 2000 !important;
|
||
}
|
||
|
||
.leaflet-tooltip {
|
||
z-index: 2000 !important;
|
||
}
|
||
`})]})},B_=()=>{const e=ua(),[r,a]=E.useState(null);return E.useEffect(()=>{let n=!1;return gw().then(i=>{n||(i?a(i):e("/login",{replace:!0}))}).catch(()=>{n||e("/login",{replace:!0})}),()=>{n=!0}},[e]),r?t.jsx(fu,{to:r,replace:!0}):t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-indigo-600 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400 text-sm",children:"Loading..."})]})})};class LP{buildListParams(r,a,n=20,i=0,c){const u=new URLSearchParams;return r&&u.append("filters",JSON.stringify(r)),a&&u.append("fields",JSON.stringify(a)),u.append("limit_page_length",n.toString()),u.append("limit_start",i.toString()),c&&u.append("order_by",c),u}getItemCount(r){return xe(this,null,function*(){const a=yield _t.apiCall("/api/method/frappe.client.get_count",{method:"POST",body:JSON.stringify({doctype:"Item",filters:r||{}})});return typeof a=="number"?a:0})}getItems(r,a,n=20,i=0,c){return xe(this,null,function*(){try{const u=this.buildListParams(r,a,n,i,c),[g,y]=yield Promise.all([_t.apiCall(`/api/resource/Item?${u.toString()}`),this.getItemCount(r)]);return{data:g.data||[],total:y}}catch(u){throw console.error("Error fetching items:",u),u}})}getItem(r){return xe(this,null,function*(){try{return(yield _t.apiCall(`/api/resource/Item/${r}`)).data}catch(a){throw console.error("Error fetching item:",a),a}})}createItem(r){return xe(this,null,function*(){try{return(yield _t.apiCall("/api/resource/Item",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).data}catch(a){throw console.error("Error creating item:",a),a}})}updateItem(r,a){return xe(this,null,function*(){try{return(yield _t.apiCall(`/api/resource/Item/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).data}catch(n){throw console.error("Error updating item:",n),n}})}deleteItem(r){return xe(this,null,function*(){try{yield _t.apiCall(`/api/resource/Item/${r}`,{method:"DELETE"})}catch(a){throw console.error("Error deleting item:",a),a}})}submitItem(r){return xe(this,null,function*(){try{return(yield _t.apiCall(`/api/resource/Item/${r}/submit`,{method:"POST"})).data}catch(a){throw console.error("Error submitting item:",a),a}})}cancelItem(r){return xe(this,null,function*(){try{return(yield _t.apiCall(`/api/resource/Item/${r}/cancel`,{method:"POST"})).data}catch(a){throw console.error("Error cancelling item:",a),a}})}}const Id=new LP,IP=(e,r)=>{const a=_e({},e||{});for(const[n,i]of Object.entries(r))if(!a[n])a[n]=i;else if(Array.isArray(i)&&i[0]==="in"){const c=i[1],u=a[n];if(typeof u=="string")c.includes(u)||(a[n]=["in",[]]);else if(Array.isArray(u)&&u[0]==="in"){const y=u[1].filter(x=>c.includes(x));a[n]=["in",y]}else a[n]=i}return a};function PP(e,r=20,a=0,n,i={}){const[c,u]=E.useState([]),[g,y]=E.useState(0),[x,k]=E.useState(!1),[N,C]=E.useState(!0),[O,D]=E.useState(null),[A,I]=E.useState(0),z=E.useRef(!1),U=JSON.stringify(e),B=JSON.stringify(i);E.useEffect(()=>{if(z.current&&O)return;let Z=!1;return z.current=!0,xe(null,null,function*(){try{C(!0);const H=IP(e,i),le=["name","item_code","item_name","item_group","stock_uom","disabled","is_stock_item","custom_hospital_name","opening_stock","valuation_rate","standard_rate","creation","modified","owner","docstatus"],Q=yield Id.getItems(H,le,r,a,n);Z||(u(Q.data),y(Q.total),k(a+Q.data.length<Q.total),D(null))}catch(H){if(!Z){const le=H instanceof Error?H.message:"Failed to fetch items";D(le),u([]),y(0),k(!1)}}finally{Z||C(!1)}}),()=>{Z=!0}},[U,B,r,a,n,A]);const V=E.useCallback(()=>{z.current=!1,I(Z=>Z+1)},[]);return{items:c,totalCount:g,hasMore:x,loading:N,error:O,refetch:V}}function FP(e){const[r,a]=E.useState(null),[n,i]=E.useState(!0),[c,u]=E.useState(null),g=E.useCallback(()=>xe(null,null,function*(){if(!e){a(null),i(!1);return}try{i(!0),u(null);const x=yield Id.getItem(e);a(x)}catch(x){u(x instanceof Error?x.message:"Failed to fetch item details")}finally{i(!1)}}),[e]);E.useEffect(()=>{g()},[g]);const y=E.useCallback(()=>{g()},[g]);return{item:r,loading:n,error:c,refetch:y}}function Ik(){const[e,r]=E.useState(!1),[a,n]=E.useState(null),i=E.useCallback(y=>xe(null,null,function*(){try{return r(!0),n(null),yield Id.createItem(y)}catch(x){const k=x instanceof Error?x.message:"Failed to create item";throw n(k),x}finally{r(!1)}}),[]),c=E.useCallback((y,x)=>xe(null,null,function*(){try{return r(!0),n(null),yield Id.updateItem(y,x)}catch(k){const N=k instanceof Error?k.message:"Failed to update item";throw n(N),k}finally{r(!1)}}),[]),u=E.useCallback(y=>xe(null,null,function*(){try{r(!0),n(null),yield Id.deleteItem(y)}catch(x){const k=x instanceof Error?x.message:"Failed to delete item";throw n(k),x}finally{r(!1)}}),[]),g=E.useCallback(y=>xe(null,null,function*(){try{return r(!0),n(null),yield Id.submitItem(y)}catch(x){const k=x instanceof Error?x.message:"Failed to submit item";throw n(k),x}finally{r(!1)}}),[]);return{createItem:i,updateItem:c,deleteItem:u,submitItem:g,loading:e,error:a}}const BP=({isOpen:e,onClose:r,selectedCount:a,totalCount:n,pageCount:i,onExport:c,isExporting:u,exportColumns:g})=>{const{t:y}=oa(),[x,k]=E.useState(a>0?"selected":"all_with_filters"),[N,C]=E.useState("csv"),[O,D]=E.useState(g.filter(U=>U.default).map(U=>U.key));E.useEffect(()=>{a>0?k("selected"):k("all_with_filters")},[a]);const A=U=>{D(B=>B.includes(U)?B.filter(V=>V!==U):[...B,U])},I=()=>{D(g.map(U=>U.key))},z=()=>{D(g.filter(U=>U.default).map(U=>U.key))};return e?t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.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:[t.jsx("div",{className:"bg-gradient-to-r from-green-500 to-green-600 px-6 py-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(cs,{className:"text-white text-xl"}),t.jsxs("h3",{className:"text-lg font-semibold text-white",children:[y("listPages.export")," Items"]})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:u,children:t.jsx(qt,{size:20})})]})}),t.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"Select Data to Export"}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${x==="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"} ${a===0?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"selected",checked:x==="selected",onChange:()=>k("selected"),disabled:a===0,className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Selected Rows"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export ",a," selected item",a!==1?"s":""]})]}),a>0&&t.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:[a," selected"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${x==="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:[t.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:x==="all_on_page",onChange:()=>k("all_on_page"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Current Page"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export ",i," item",i!==1?"s":""," on current page"]})]}),t.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"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${x==="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:[t.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:x==="all_with_filters",onChange:()=>k("all_with_filters"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"All Records (with current filters)"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export all ",n," item",n!==1?"s":""," matching current filters"]})]}),t.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:[n," total"]})]})]})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"Export Format"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${N==="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:[t.jsx("input",{type:"radio",name:"format",value:"csv",checked:N==="csv",onChange:()=>C("csv"),className:"text-green-600 focus:ring-green-500"}),t.jsx(Kd,{className:"text-green-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"CSV"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Comma-separated values"})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${N==="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:[t.jsx("input",{type:"radio",name:"format",value:"excel",checked:N==="excel",onChange:()=>C("excel"),className:"text-green-600 focus:ring-green-500"}),t.jsx(cl,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Excel"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"XLSX spreadsheet"})]})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Columns to Export"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:I,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Select All"}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:z,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Reset to Default"})]})]}),t.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:g.map(U=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${O.includes(U.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:[t.jsx("input",{type:"checkbox",checked:O.includes(U.key),onChange:()=>A(U.key),className:"rounded text-green-600 focus:ring-green-500"}),t.jsx("span",{className:"text-sm truncate",children:U.label})]},U.key))}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:[O.length," column",O.length!==1?"s":""," selected"]})]})]}),t.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:[t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[x==="selected"&&`Exporting ${a} selected row${a!==1?"s":""}`,x==="all_on_page"&&`Exporting ${i} row${i!==1?"s":""} from current page`,x==="all_with_filters"&&`Exporting all ${n} row${n!==1?"s":""}`]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:r,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:u,children:"Cancel"}),t.jsx("button",{onClick:()=>c(x,N,O),disabled:O.length===0||u,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:u?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Exporting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Co,{}),"Export"]})})]})]})]})}):null},UP=()=>{const{t:e}=oa(),r=ua(),{sortBy:a,dateFilterBy:n,dateStart:i,dateEnd:c,page:u,setSortBy:g,setDateFilterBy:y,setDateStart:x,setDateEnd:k,setPage:N,resetPage:C}=pm("creation desc"),[O,D]=E.useState(null),A=20,I=[{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:"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}],[z,U]=E.useState(!1),[B,V]=E.useState(new Set),[Z,W]=E.useState(!1),[H,le]=E.useState(!1),{permissionFilters:Q,loading:Ne}=dm("Item"),[oe,se]=E.useState(""),[ce,Ce]=E.useState(""),[ae,me]=E.useState(""),[K,fe]=E.useState(""),[Oe,ye]=E.useState(!1),[J,G]=E.useState(0),[ie,re]=E.useState([]),[ne,ve]=E.useState(!1),[Ve,Ae]=E.useState(""),[ze,Re]=E.useState(""),Ze=E.useRef(null);E.useEffect(()=>{const pt=localStorage.getItem("itemFilterPresets");pt&&re(JSON.parse(pt))},[]),E.useEffect(()=>{const pt=[oe,ce,ae,K].filter(Boolean).length;G(pt)},[oe,ce,ae,K]);const Lt=xm(_e(_e(_e(_e({},oe?{name:oe}:{}),ce?{item_group:ce}:{}),ae?{custom_hospital_name:ae}:{}),K?{item_name:["like",`%${K}%`]}:{}),n,i,c),{items:mt,totalCount:Zt,hasMore:ar,loading:or,error:yt,refetch:nr}=PP(Object.keys(Lt).length>0?Lt:void 0,A,u*A,a,Q),{deleteItem:$t,loading:Er}=Ik();E.useEffect(()=>{!or&&!z&&!Ne&&U(!0)},[or,z,Ne]),E.useEffect(()=>{C()},[oe,ce,ae,K,a,n,i,c]),E.useEffect(()=>{V(new Set)},[oe,ce,ae,K,u]);const St=pt=>{Re(pt),Ze.current&&clearTimeout(Ze.current),Ze.current=window.setTimeout(()=>{fe(pt)},800)},Br=pt=>{pt.key==="Enter"&&(pt.preventDefault(),Ze.current&&clearTimeout(Ze.current),fe(ze))},Pt=()=>{if(!Ve.trim()){alert("Please enter a filter name");return}const pt={id:Date.now(),name:Ve,filters:{filterItemId:oe,filterItemGroup:ce,filterCompany:ae,filterItemName:K}},Jt=[...ie,pt];re(Jt),Ae(""),ve(!1),localStorage.setItem("itemFilterPresets",JSON.stringify(Jt))},it=pt=>{const Jt=pt.filters;se(Jt.filterItemId||""),Ce(Jt.filterItemGroup||""),me(Jt.filterCompany||""),fe(Jt.filterItemName||""),Re(Jt.filterItemName||"")},De=pt=>{const Jt=ie.filter(vr=>vr.id!==pt);re(Jt),localStorage.setItem("itemFilterPresets",JSON.stringify(Jt))};E.useEffect(()=>()=>{Ze.current&&clearTimeout(Ze.current)},[]);const Je=()=>{se(""),Ce(""),me(""),fe(""),Re(""),Ze.current&&clearTimeout(Ze.current)},Be=oe||ce||ae||K,vt=pt=>pt?new Date(pt).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"-",jt=pt=>{V(Jt=>{const vr=new Set(Jt);return vr.has(pt)?vr.delete(pt):vr.add(pt),vr})},Ct=()=>{B.size===mt.length?V(new Set):V(new Set(mt.map(pt=>pt.name)))},Wt=mt.length>0&&B.size===mt.length,pr=B.size>0&&B.size<mt.length,Ge=E.useCallback(()=>xe(null,null,function*(){const pt=[];let Jt=0;const vr=100;let Ir=!0;for(;Ir;)try{const Ke=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Item",filters:_e(_e({},Lt),Q),fields:["*"],limit_start:Jt*vr,limit_page_length:vr,order_by:"creation desc"})})).json()).message||[];pt.push(...Ke),Ke.length<vr?Ir=!1:Jt++,Jt>100&&(console.warn("Export safety limit reached"),Ir=!1)}catch(Le){throw console.error("Error fetching items for export:",Le),Le}return pt}),[Lt,Q]),We=(pt,Jt,vr)=>xe(null,null,function*(){le(!0);try{let Ir=[];switch(pt){case"selected":Ir=mt.filter(qe=>B.has(qe.name));break;case"all_on_page":Ir=mt;break;case"all_with_filters":Ir=yield Ge();break}if(Ir.length===0){alert("No data to export");return}const Le=vr.map(qe=>{const Ke=I.find(Yt=>Yt.key===qe);return(Ke==null?void 0:Ke.label)||qe});if(Jt==="csv"){const qe=[Le.join(","),...Ir.map(jr=>vr.map(Zr=>{let en=jr[Zr]||"";return typeof en=="string"&&(en.includes(",")||en.includes('"')||en.includes(`
|
||
`))&&(en=`"${en.replace(/"/g,'""')}"`),en}).join(","))].join(`
|
||
`),Ke=new Blob(["\uFEFF"+qe],{type:"text/csv;charset=utf-8;"}),Yt=URL.createObjectURL(Ke),gr=document.createElement("a");gr.href=Yt,gr.download=`items_export_${new Date().toISOString().split("T")[0]}.csv`,gr.click(),URL.revokeObjectURL(Yt)}else if(Jt==="excel"){const qe=[Le,...Ir.map(gr=>vr.map(jr=>gr[jr]||""))],Ke=Wa.aoa_to_sheet(qe),Yt=Wa.book_new();Wa.book_append_sheet(Yt,Ke,"Items"),ul(Yt,`items_export_${new Date().toISOString().split("T")[0]}.xlsx`)}W(!1),V(new Set)}catch(Ir){console.error("Export failed:",Ir),alert(`Export failed: ${Ir instanceof Error?Ir.message:"Unknown error"}`)}finally{le(!1)}}),At=()=>{r("/inventory/new")},lt=pt=>{r(`/inventory/${pt}`)},Dt=pt=>{r(`/inventory/${pt}`)},mr=pt=>xe(null,null,function*(){try{yield $t(pt),D(null),nr(),alert("Item deleted successfully!")}catch(Jt){alert(`Failed to delete: ${Jt instanceof Error?Jt.message:"Unknown error"}`)}}),tr=pt=>{r(`/inventory/new?duplicate=${pt}`)};return or&&!z?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading items..."})]})}):yt?t.jsx("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:"⚠️ Error Loading Items"}),t.jsxs("div",{className:"text-red-700 dark:text-red-400 space-y-3",children:[t.jsx("p",{children:t.jsx("strong",{children:"Failed to load items."})}),t.jsxs("div",{className:"mt-4 flex gap-3",children:[t.jsx("button",{onClick:()=>r("/inventory/new"),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:"Create New Item"}),t.jsx("button",{onClick:nr,className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded",children:"Try Again"})]})]}),t.jsx("div",{className:"mt-4 p-4 bg-white dark:bg-gray-800 rounded border border-red-300 dark:border-red-700",children:t.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[t.jsx("strong",{children:"Technical Error:"})," ",yt]})})]})}):t.jsxs("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-gray-800 dark:text-white break-words",children:"Inventory"}),t.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:["Total: ",Zt," item",Zt!==1?"s":"",B.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",B.size," selected"]}),or&&z&&t.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[t.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-blue-500"}),"Updating..."]})]})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("button",{onClick:()=>W(!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:Zt===0,children:[t.jsx(cs,{}),t.jsx("span",{className:"font-medium",children:e("listPages.export")}),B.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:B.size})]}),t.jsxs("button",{onClick:At,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:[t.jsx(Mi,{}),t.jsx("span",{className:"font-medium",children:"Add Item"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[t.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:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx("button",{onClick:()=>ye(!Oe),className:"text-white hover:bg-white/20 p-2 rounded-lg transition-all",children:Oe?t.jsx(Vl,{size:14}):t.jsx(nl,{size:14})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ri,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:e("listPages.filters")})]}),J>0&&t.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:J})]}),Be&&t.jsx("div",{className:"flex-1 overflow-x-auto scrollbar-hide mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[oe&&t.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:[t.jsx("span",{className:"font-semibold",children:"Item ID:"})," ",oe,t.jsx("button",{onClick:pt=>{pt.stopPropagation(),se("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),K&&t.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:[t.jsx("span",{className:"font-semibold",children:"Name:"})," ",K,t.jsx("button",{onClick:pt=>{pt.stopPropagation(),fe(""),Re("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),ae&&t.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:[t.jsx("span",{className:"font-semibold",children:"Hospital:"})," ",ae,t.jsx("button",{onClick:pt=>{pt.stopPropagation(),me("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]}),ce&&t.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:[t.jsx("span",{className:"font-semibold",children:"Item Group:"})," ",ce,t.jsx("button",{onClick:pt=>{pt.stopPropagation(),Ce("")},className:"hover:text-red-500 transition-colors",children:t.jsx(qt,{className:"text-[9px]"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[J>0&&t.jsxs("button",{onClick:()=>ve(!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:[t.jsx(Fn,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),Be&&t.jsxs("button",{onClick:Je,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:[t.jsx(qt,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]})]})}),Oe&&t.jsxs("div",{className:"p-4",children:[ie.length>0&&t.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[t.jsx(Zl,{className:"text-yellow-500",size:12}),"Saved Filters"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:ie.map(pt=>t.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:[t.jsx("button",{onClick:()=>it(pt),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:pt.name}),t.jsx("button",{onClick:()=>De(pt.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(ma,{size:10})})]},pt.id))})]}),t.jsx("div",{className:"space-y-5",children:t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[t.jsx(Bu,{sortBy:a,dateFilterBy:n,dateStart:i,dateEnd:c,onSortByChange:g,onDateFilterByChange:y,onDateStartChange:x,onDateEndChange:k}),t.jsxs("div",{className:"relative z-[60]",children:[t.jsx(er,{label:"Item",doctype:"Item",value:oe,onChange:pt=>se(pt),placeholder:"Select Item",disabled:!1,compact:!0}),oe&&t.jsx("button",{onClick:()=>se(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Item Name"}),t.jsx("input",{type:"text",value:ze,onChange:pt=>St(pt.target.value),onKeyDown:Br,placeholder:"Type to search...",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"}),ze&&ze!==K&&t.jsx("span",{className:"absolute right-2 top-6 text-[9px] text-blue-500 animate-pulse",children:"typing..."}),K&&t.jsx("button",{onClick:()=>{fe(""),Re("")},className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[59]",children:[t.jsx(er,{label:"Hospital",doctype:"Company",value:ae,onChange:pt=>me(pt),placeholder:"Select Hospital",disabled:!1,compact:!0,filters:{domain:"Healthcare"}}),ae&&t.jsx("button",{onClick:()=>me(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[58]",children:[t.jsx(er,{label:"Item Group",doctype:"Item Group",value:ce,onChange:pt=>Ce(pt),placeholder:"Select Item Group",disabled:!1,compact:!0}),ce&&t.jsx("button",{onClick:()=>Ce(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]})]})})})]})]}),ne&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:"Save Filter Preset"}),t.jsx("input",{type:"text",value:Ve,onChange:pt=>Ae(pt.target.value),onKeyDown:pt=>{pt.key==="Enter"&&(pt.preventDefault(),Pt())},placeholder:"Enter filter name (e.g., 'Medical Supplies')",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}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{ve(!1),Ae("")},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"}),t.jsxs("button",{onClick:Pt,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:[t.jsx(Fn,{size:12}),"Save Filter"]})]})]})}),t.jsx(BP,{isOpen:Z,onClose:()=>W(!1),selectedCount:B.size,totalCount:Zt,pageCount:mt.length,onExport:We,isExporting:H,exportColumns:I}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden relative",children:[or&&z&&t.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:t.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[t.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-blue-500"}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Filtering..."})]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left",children:t.jsx("button",{onClick:Ct,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:Wt?"Deselect all":"Select all",children:Wt?t.jsx(qs,{className:"text-blue-600 dark:text-blue-400",size:18}):pr?t.jsxs("div",{className:"relative",children:[t.jsx(Pn,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Pn,{size:18})})}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Item Code"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Item Name"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Item Group"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Hospital"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Updated On"}),t.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Actions"})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:mt.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"px-6 py-12 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(rC,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:"No items found"}),Be?t.jsx("button",{onClick:Je,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:"Clear filters"}):t.jsx("button",{onClick:At,className:"mt-4 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:"Create your first item"})]})})}):mt.map(pt=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors cursor-pointer ${B.has(pt.name)?"bg-blue-50 dark:bg-blue-900/20":""}`,onClick:()=>lt(pt.name),children:[t.jsx("td",{className:"px-4 py-4",onClick:Jt=>Jt.stopPropagation(),children:t.jsx("button",{onClick:()=>jt(pt.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:B.has(pt.name)?t.jsx(qs,{className:"text-blue-600 dark:text-blue-400",size:18}):t.jsx(Pn,{size:18})})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:pt.item_code||pt.name})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:pt.item_name||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:pt.item_group||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:pt.custom_hospital_name||"-"})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:t.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:vt(pt.modified)})}),t.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:t.jsxs("div",{className:"flex items-center gap-1",onClick:Jt=>Jt.stopPropagation(),children:[t.jsx("button",{onClick:()=>lt(pt.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:t.jsx(to,{})}),t.jsx("button",{onClick:()=>Dt(pt.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:t.jsx(Yn,{})}),t.jsx("button",{onClick:()=>tr(pt.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:t.jsx(Zd,{})}),t.jsx("button",{onClick:()=>D(pt.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 Item",disabled:Er,children:t.jsx(ma,{})})]})})]},pt.name))})]})}),t.jsx(Fu,{currentPage:u+1,totalCount:Zt,pageSize:A,hasMore:ar,itemLabel:e("pagination.items"),onPageChange:pt=>N(Math.max(0,pt-1))})]}),O&&t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.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:t.jsx(ma,{className:"text-red-600 dark:text-red-400 text-xl"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Delete Item"}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:"Are you sure you want to delete this item? This action cannot be undone."}),t.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:t.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[t.jsx("strong",{children:"Item ID:"})," ",O]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.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",disabled:Er,children:"Cancel"}),t.jsx("button",{onClick:()=>mr(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 disabled:opacity-50",disabled:Er,children:Er?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Deleting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(ma,{}),"Delete Item"]})})]})]})]})})}),t.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;
|
||
}
|
||
`})]})},zP=()=>{var ce;const{itemName:e}=Yl(),r=ua(),[a]=Li(),n=a.get("duplicate"),i=e==="new",c=i&&!!n,[u,g]=E.useState(0),[y,x]=E.useState(!1),[k,N]=E.useState({item_code:"",item_name:"",item_group:"",custom_hospital_name:"",custom_part_description:"",stock_uom:"Nos",custom_item_cost_per_unit:0,disabled:0,is_stock_item:1,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,is_purchase_item:1,is_sales_item:1,country_of_origin:"Saudi Arabia"}),{item:C,loading:O,error:D,refetch:A}=FP(c?n:i?null:e||null),{createItem:I,updateItem:z,loading:U}=Ik(),[B,V]=E.useState(i);Kl(N,{enabled:i&&!c,fields:["custom_hospital_name"]});const Z=(ce=C==null?void 0:C.docstatus)!=null?ce:0,W=Z===1,H=Z===2,le=Z===0,Q=k.item_group==="Tools",Ne=E.useCallback(Ce=>xe(null,null,function*(){var ae;if(Ce){x(!0);try{let me=null;typeof window!="undefined"&&window.csrf_token&&(me=window.csrf_token);const K=JSON.stringify([["item_code","=",Ce]]),fe=JSON.stringify(["actual_qty","warehouse"]),Oe=`${Lr.BASE_URL}/api/resource/Bin?filters=${encodeURIComponent(K)}&fields=${encodeURIComponent(fe)}&limit_page_length=0`,ye={Accept:"application/json","Content-Type":"application/json"};me&&(ye["X-Frappe-CSRF-Token"]=me);const J=yield fetch(Oe,{method:"GET",headers:ye,credentials:"include"});if(!J.ok)throw new Error(`HTTP error! status: ${J.status}`);const ie=((ae=(yield J.json()).data)==null?void 0:ae.reduce((re,ne)=>re+(ne.actual_qty||0),0))||0;g(ie)}catch(me){console.error("Failed to fetch balance qty:",me),g(0)}finally{x(!1)}}}),[]);E.useEffect(()=>{!i&&(C!=null&&C.item_code)&&Ne(C.item_code)},[i,C==null?void 0:C.item_code,Ne]),E.useEffect(()=>{var Ce,ae,me,K,fe,Oe;C&&!c?(N({item_code:C.item_code||"",item_name:C.item_name||"",item_group:C.item_group||"",custom_hospital_name:C.custom_hospital_name||"",custom_part_description:C.custom_part_description||"",stock_uom:C.stock_uom||"Nos",custom_item_cost_per_unit:C.custom_item_cost_per_unit||0,disabled:C.disabled||0,is_stock_item:(Ce=C.is_stock_item)!=null?Ce:1,opening_stock:C.opening_stock||0,valuation_rate:C.valuation_rate||0,standard_rate:C.standard_rate||0,custom_last_calibration_date:C.custom_last_calibration_date||"",custom_next_due_calibration_date:C.custom_next_due_calibration_date||"",description:C.description||"",brand:C.brand||"",custom_warranty_in_months:C.custom_warranty_in_months||"",valuation_method:C.valuation_method||"",has_batch_no:C.has_batch_no||0,has_serial_no:C.has_serial_no||0,is_purchase_item:(ae=C.is_purchase_item)!=null?ae:1,is_sales_item:(me=C.is_sales_item)!=null?me:1,country_of_origin:C.country_of_origin||"Saudi Arabia",uoms:C.uoms||[],item_defaults:C.item_defaults||[]}),V(!1)):c&&C&&N({item_code:"",item_name:C.item_name||"",item_group:C.item_group||"",custom_hospital_name:C.custom_hospital_name||"",custom_part_description:C.custom_part_description||"",stock_uom:C.stock_uom||"Nos",custom_item_cost_per_unit:C.custom_item_cost_per_unit||0,disabled:0,is_stock_item:(K=C.is_stock_item)!=null?K:1,opening_stock:C.opening_stock||0,valuation_rate:C.valuation_rate||0,standard_rate:C.standard_rate||0,custom_last_calibration_date:C.custom_last_calibration_date||"",custom_next_due_calibration_date:C.custom_next_due_calibration_date||"",description:C.description||"",brand:C.brand||"",custom_warranty_in_months:C.custom_warranty_in_months||"",valuation_method:C.valuation_method||"",has_batch_no:C.has_batch_no||0,has_serial_no:C.has_serial_no||0,is_purchase_item:(fe=C.is_purchase_item)!=null?fe:1,is_sales_item:(Oe=C.is_sales_item)!=null?Oe:1,country_of_origin:C.country_of_origin||"Saudi Arabia",uoms:C.uoms||[],item_defaults:C.item_defaults||[]})},[C,c]);const oe=()=>xe(null,null,function*(){try{if(i){const Ce=yield I(k);r(`/inventory/${Ce.name}`)}else yield z(e,k),yield A(),k.item_code&&Ne(k.item_code),V(!1),alert("Item updated successfully!")}catch(Ce){alert(`Failed to save: ${Ce instanceof Error?Ce.message:"Unknown error"}`)}}),se=E.useCallback(Ce=>!!(!B||H||W),[B,H,W]);return O?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading item..."})]})}):D&&!i?t.jsx("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:"Error Loading Item"}),t.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:D}),t.jsx("button",{onClick:()=>r("/inventory"),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:"Back to Inventory"})]})}):t.jsxs("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("button",{onClick:()=>r("/inventory"),className:"text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200",children:t.jsx(bi,{size:20})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-bold text-gray-800 dark:text-white",children:i?"New Item":(C==null?void 0:C.item_name)||(C==null?void 0:C.item_code)||"Item"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:i?"Create a new item":`Item Code: ${(C==null?void 0:C.item_code)||e}`})]})]}),t.jsxs("div",{className:"flex gap-3",children:[!i&&!B&&le&&t.jsxs("button",{onClick:()=>V(!0),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(Yn,{}),"Edit"]}),B&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{i?r("/inventory"):(V(!1),A())},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg",children:"Cancel"}),t.jsxs("button",{onClick:oe,disabled:U,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:[t.jsx(Fn,{}),U?"Saving...":"Save"]})]})]})]}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[t.jsx("div",{className:"md:col-span-2",children:t.jsx("h2",{className:"text-xl font-semibold text-gray-800 dark:text-white mb-4",children:"Basic Information"})}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Item Code ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",value:k.item_code,onChange:Ce=>N($e(_e({},k),{item_code:Ce.target.value})),disabled:se("item_code")||!i,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",required:!0})]}),t.jsx("div",{children:t.jsx(er,{label:"Hospital",doctype:"Company",value:k.custom_hospital_name||"",onChange:Ce=>N($e(_e({},k),{custom_hospital_name:Ce})),disabled:se("custom_hospital_name"),placeholder:"Select Hospital",filters:{domain:"Healthcare"}})}),t.jsx("div",{children:t.jsx(er,{label:"Item Group",doctype:"Item Group",value:k.item_group||"",onChange:Ce=>N($e(_e({},k),{item_group:Ce})),disabled:se("item_group"),placeholder:"Select item group"})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Stock UOM"}),t.jsx("input",{type:"text",value:k.stock_uom,onChange:Ce=>N($e(_e({},k),{stock_uom:Ce.target.value})),disabled:se("stock_uom"),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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Part Description"}),t.jsx("input",{type:"text",value:k.custom_part_description,onChange:Ce=>N($e(_e({},k),{custom_part_description:Ce.target.value})),disabled:se("custom_part_description"),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"})]}),t.jsx("div",{className:"md:col-span-2 mt-6",children:t.jsx("h2",{className:"text-xl font-semibold text-gray-800 dark:text-white mb-4",children:"Stock Information"})}),t.jsx("div",{className:"md:col-span-2",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 items-end",children:[t.jsxs("div",{className:"flex items-center gap-2 h-[42px]",children:[t.jsx("input",{type:"checkbox",id:"is_stock_item",checked:k.is_stock_item===1,onChange:Ce=>N($e(_e({},k),{is_stock_item:Ce.target.checked?1:0})),disabled:se("is_stock_item"),className:"w-4 h-4"}),t.jsx("label",{htmlFor:"is_stock_item",className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Is Stock Item"})]}),i&&k.is_stock_item===1&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Opening Stock"}),t.jsx("input",{type:"number",value:k.opening_stock,onChange:Ce=>N($e(_e({},k),{opening_stock:parseFloat(Ce.target.value)||0})),disabled:se("opening_stock"),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"})]}),i&&k.is_stock_item===1&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Valuation Rate"}),t.jsx("input",{type:"number",step:"0.01",value:k.valuation_rate,onChange:Ce=>N($e(_e({},k),{valuation_rate:parseFloat(Ce.target.value)||0})),disabled:se("valuation_rate"),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"})]}),!i&&k.is_stock_item===1&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Balance Qty"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"number",value:u,readOnly:!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-900 dark:text-white cursor-not-allowed"}),t.jsx("button",{type:"button",onClick:()=>k.item_code&&Ne(k.item_code),disabled:y,className:"p-2 text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 disabled:opacity-50",title:"Refresh Balance Qty",children:t.jsx(Eo,{className:y?"animate-spin":""})})]})]})]})}),Q&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"md:col-span-2 mt-6",children:t.jsx("h2",{className:"text-xl font-semibold text-gray-800 dark:text-white mb-4",children:"Calibration Information"})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Last Calibration Date"}),t.jsx("input",{type:"date",value:k.custom_last_calibration_date,onChange:Ce=>N($e(_e({},k),{custom_last_calibration_date:Ce.target.value})),disabled:se("custom_last_calibration_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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Next Due Calibration Date"}),t.jsx("input",{type:"date",value:k.custom_next_due_calibration_date,onChange:Ce=>N($e(_e({},k),{custom_next_due_calibration_date:Ce.target.value})),disabled:se("custom_next_due_calibration_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"})]})]}),t.jsx("div",{className:"md:col-span-2 mt-6",children:t.jsx("h2",{className:"text-xl font-semibold text-gray-800 dark:text-white mb-4",children:"Additional Information"})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Description"}),t.jsx("textarea",{value:k.description,onChange:Ce=>N($e(_e({},k),{description:Ce.target.value})),disabled:se("description"),rows:3,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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Warranty (Months)"}),t.jsx("input",{type:"text",value:k.custom_warranty_in_months,onChange:Ce=>N($e(_e({},k),{custom_warranty_in_months:Ce.target.value})),disabled:se("custom_warranty_in_months"),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"})]})]})}),!i&&!c&&t.jsxs("div",{className:"mt-6 space-y-6",children:[t.jsx(Vu,{referenceDoctype:"Item",referenceName:e||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5}),t.jsx(Wu,{doctype:"Item",docname:e||null,creationDate:C==null?void 0:C.creation,createdBy:C==null?void 0:C.owner,initialVisible:5,startCollapsed:!0})]})]})};const HP=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),VP=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,a,n)=>n?n.toUpperCase():a.toLowerCase()),U_=e=>{const r=VP(e);return r.charAt(0).toUpperCase()+r.slice(1)},Pk=(...e)=>e.filter((r,a,n)=>!!r&&r.trim()!==""&&n.indexOf(r)===a).join(" ").trim(),WP=e=>{for(const r in e)if(r.startsWith("aria-")||r==="role"||r==="title")return!0};var GP={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 $P=E.forwardRef((x,y)=>{var k=x,{color:e="currentColor",size:r=24,strokeWidth:a=2,absoluteStrokeWidth:n,className:i="",children:c,iconNode:u}=k,g=Gs(k,["color","size","strokeWidth","absoluteStrokeWidth","className","children","iconNode"]);return E.createElement("svg",_e(_e($e(_e({ref:y},GP),{width:r,height:r,stroke:e,strokeWidth:n?Number(a)*24/Number(r):a,className:Pk("lucide",i)}),!c&&!WP(g)&&{"aria-hidden":"true"}),g),[...u.map(([N,C])=>E.createElement(N,C)),...Array.isArray(c)?c:[c]])});const Bn=(e,r)=>{const a=E.forwardRef((u,c)=>{var g=u,{className:n}=g,i=Gs(g,["className"]);return E.createElement($P,_e({ref:c,iconNode:r,className:Pk(`lucide-${HP(U_(e))}`,`lucide-${e}`,n)},i))});return a.displayName=U_(e),a};const XP=[["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"}]],YP=Bn("bell",XP);const ZP=[["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"}]],qP=Bn("calendar-check",ZP);const KP=[["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"}]],JP=Bn("calendar",KP);const QP=[["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"}]],eF=Bn("circle-question-mark",QP);const tF=[["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"}]],rF=Bn("circle-user",tF);const aF=[["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"}]],nF=Bn("clipboard-list",aF);const sF=[["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"}]],iF=Bn("construction",sF);const oF=[["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"}]],lF=Bn("file-text",oF);const cF=[["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"}]],dF=Bn("languages",cF);const uF=[["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"}]],hF=Bn("layout-dashboard",uF);const fF=[["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"}]],mF=Bn("log-out",fF);const gF=[["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"}]],xF=Bn("map",gF);const pF=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Fk=Bn("menu",pF);const yF=[["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"}]],bF=Bn("moon",yF);const vF=[["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"}]],z_=Bn("package",vF);const _F=[["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"}]],wF=Bn("shopping-cart",_F);const kF=[["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"}]],NF=Bn("sun",kF);const SF=[["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"}]],CF=Bn("users",SF);const EF=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],jF=Bn("x",EF),H_=({title:e="Coming Soon"})=>t.jsx("div",{className:"flex items-center justify-center min-h-screen bg-gray-50 dark:bg-gray-900 p-4",children:t.jsxs("div",{className:"text-center max-w-md",children:[t.jsx("div",{className:"mb-6 flex justify-center",children:t.jsx("div",{className:"bg-blue-100 dark:bg-blue-900/30 p-6 rounded-full",children:t.jsx(iF,{size:64,className:"text-blue-600 dark:text-blue-400"})})}),t.jsx("h1",{className:"text-4xl font-bold text-gray-900 dark:text-white mb-4",children:e}),t.jsx("p",{className:"text-lg text-gray-600 dark:text-gray-400 mb-8",children:"This feature is currently under development and will be available soon."}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 shadow-lg",children:t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"We're working hard to bring you the best experience. Stay tuned for updates!"})})]})}),Bk=E.createContext(void 0),TF=({children:e})=>{const{i18n:r}=oa(),[a,n]=E.useState(()=>localStorage.getItem("i18nextLng")==="ar"?"ar":"en"),i=a==="ar";E.useEffect(()=>{const u=document.documentElement,g=document.documentElement;r.changeLanguage(a),g.setAttribute("lang",a),i?(g.setAttribute("dir","rtl"),u.classList.add("rtl"),u.classList.remove("ltr")):(g.setAttribute("dir","ltr"),u.classList.add("ltr"),u.classList.remove("rtl"))},[a,r,i]);const c=u=>xe(null,null,function*(){n(u),localStorage.setItem("i18nextLng",u),yield jd()});return t.jsx(Bk.Provider,{value:{language:a,changeLanguage:c,isRTL:i},children:e})},h1=()=>{const e=E.useContext(Bk);if(!e)throw new Error("useLanguage must be used within LanguageProvider");return e},Uk=E.createContext(void 0),AF=({children:e})=>{const[r,a]=E.useState(!1),n=E.useCallback(()=>a(!0),[]),i=E.useCallback(()=>a(!1),[]),c=E.useMemo(()=>({mobileOpen:r,openMobileSidebar:n,closeMobileSidebar:i}),[r,n,i]);return t.jsx(Uk.Provider,{value:c,children:e})};function f1(){const e=E.useContext(Uk);if(!e)throw new Error("useSidebarLayout must be used within SidebarLayoutProvider");return e}function OF(){const[e,r]=E.useState(()=>typeof window!="undefined"?window.matchMedia("(min-width: 1024px)").matches:!0);return E.useEffect(()=>{const a=window.matchMedia("(min-width: 1024px)"),n=()=>r(a.matches);return n(),a.addEventListener("change",n),()=>a.removeEventListener("change",n)},[]),e}const RF=({userEmail:e})=>{const[r,a]=E.useState(!1),n=yi(),{isRTL:i}=h1(),{t:c}=oa(),{closeMobileSidebar:u}=f1(),g=OF(),{roleProfile:y}=kk(),x=Cu(y)||Np(y),k="/assets/asm_ui_app/asm_app/",N="?v=1785757497",C="?v=1785757497",O=k.endsWith("/")?`${k}sidebar-background.jpg${N}`:`${k}/sidebar-background.jpg${N}`,D=e==="financemanager@gmail.com",A=V=>{switch(V){case"assets":case"work-orders":case"ppm-planner":case"maintenance-calendar":return!D;default:return!0}},z=[{id:"dashboard",title:c("common.dashboard"),icon:t.jsx(hF,{size:20}),path:"/dashboard",visible:x?Zi("dashboard",y):A("dashboard")},{id:"assets",title:c("common.assets"),icon:t.jsx(z_,{size:20}),path:"/assets",visible:x?Zi("assets",y):A("assets")},{id:"inventory",title:"Inventory",icon:t.jsx(z_,{size:20}),path:"/inventory",visible:x?Zi("inventory",y):A("inventory")},{id:"work-orders",title:c("common.workOrders"),icon:t.jsx(nF,{size:20}),path:"/work-orders",visible:x?Zi("work-orders",y):A("work-orders")},{id:"ppm-planner",title:"PPM Planner",icon:t.jsx(qP,{size:20}),path:"/ppm-planner",visible:x?Zi("ppm-planner",y):A("ppm-planner")},{id:"maintenance-calendar",title:"Maintenance Calendar",icon:t.jsx(JP,{size:20}),path:"/maintenance-calendar",visible:x?Zi("maintenance-calendar",y):A("maintenance-calendar")},{id:"active-map",title:"Active Map",icon:t.jsx(xF,{size:20}),path:"/active-map",visible:x?Zi("active-map",y):A("active-map")},{id:"maintenance-teams",title:"Maintenance Team",icon:t.jsx(CF,{size:20}),path:"/maintenance-teams",visible:x?Zi("maintenance-teams",y):A("maintenance-teams")},{id:"procurement",title:"Procurement",icon:t.jsx(wF,{size:20}),path:"/procurement",visible:x?Zi("procurement",y):A("procurement")},{id:"sla",title:"Service Level Agreement (SLA)",icon:t.jsx(lF,{size:20}),path:"/sla",visible:x?Zi("sla",y):A("sla")},{id:"support",title:"Support",icon:t.jsx(eF,{size:20}),path:"/support",visible:x?Zi("support",y):A("support")}].filter(V=>V.visible),U=V=>n.pathname===V,B=()=>{g||u()};return t.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
|
||
w-64
|
||
${r?"lg:w-16":"lg:w-64"}
|
||
`,style:{backgroundImage:`url(${O})`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat"},children:[t.jsx("div",{className:"absolute inset-0 bg-black/60 dark:bg-black/70 z-0"}),t.jsxs("div",{className:"relative z-10 flex flex-col h-full bg-white/0 dark:bg-white/0",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200/30 dark:border-gray-700/30",children:[!r&&t.jsxs("div",{className:"flex items-center space-x-3",children:[t.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:[t.jsx("img",{src:`${k}${k.endsWith("/")?"":"/"}seera-logo.png${C}`,alt:"Seera-ASM",className:"w-full h-full object-contain",onError:V=>{var Z;V.currentTarget.style.display="none",(Z=V.currentTarget.nextElementSibling)==null||Z.classList.remove("hidden")}}),t.jsxs("svg",{className:"w-6 h-6 hidden",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"#6366F1",fillOpacity:"0.9"}),t.jsx("path",{d:"M2 17L12 22L22 17V12L12 17L2 12V17Z",fill:"#8B5CF6",fillOpacity:"0.7"}),t.jsx("path",{d:"M12 12V17",stroke:"#A855F7",strokeWidth:"2",strokeLinecap:"round"})]})]}),t.jsx("h1",{className:"text-white dark:text-white text-lg font-semibold drop-shadow-lg",children:c("sidebar.title")})]}),r&&t.jsxs("div",{className:"w-8 h-8 flex items-center justify-center bg-white dark:bg-gray-700 rounded-lg p-1",children:[t.jsx("img",{src:`${k}${k.endsWith("/")?"":"/"}seera-logo.png?v=1765198405${C}`,alt:"Seera-ASM",className:"w-full h-full object-contain",onError:V=>{var Z;V.currentTarget.style.display="none",(Z=V.currentTarget.nextElementSibling)==null||Z.classList.remove("hidden")}}),t.jsxs("svg",{className:"w-5 h-5 hidden",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"#6366F1",fillOpacity:"0.9"}),t.jsx("path",{d:"M2 17L12 22L22 17V12L12 17L2 12V17Z",fill:"#8B5CF6",fillOpacity:"0.7"}),t.jsx("path",{d:"M12 12V17",stroke:"#A855F7",strokeWidth:"2",strokeLinecap:"round"})]})]}),t.jsx("button",{onClick:()=>a(!r),className:"hidden lg:inline-flex text-white dark:text-white hover:bg-white/20 dark:hover:bg-white/20 p-2 rounded-lg transition-colors",children:r?t.jsx(Fk,{size:20}):t.jsx(jF,{size:20})})]}),t.jsx("nav",{className:"flex-1 overflow-y-auto py-4",children:z.map(V=>t.jsxs(kp,{to:V.path,onClick:B,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
|
||
${U(V.path)?"bg-white/30 dark:bg-white/30 text-white dark:text-white border-l-4 border-white":""}
|
||
${r?"justify-center":""}
|
||
`,title:r?V.title:"",children:[t.jsx("span",{children:V.icon}),!r&&t.jsx("span",{className:`${i?"mr-4":"ml-4"} font-medium`,children:V.title})]},V.id))}),t.jsx("div",{className:`${r?"p-2":"p-4"} border-t border-white/10 backdrop-blur-sm bg-white/5 relative z-10`,children:!r&&t.jsx("div",{className:"text-xs text-white/70 dark:text-white/70 text-center",children:c("sidebar.version")})})]})]})},zk=E.createContext(void 0),MF=({children:e})=>{const[r,a]=E.useState(()=>localStorage.getItem("theme")||"light");E.useEffect(()=>{const i=document.documentElement;localStorage.setItem("theme",r),r==="dark"?i.classList.add("dark"):i.classList.remove("dark")},[r]);const n=()=>{a(i=>i==="light"?"dark":"light")};return t.jsx(zk.Provider,{value:{theme:r,toggleTheme:n},children:e})},DF=()=>{const e=E.useContext(zk);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e};class LF{getNotifications(r=50,a=0){return xe(this,null,function*(){var c,u,g,y;const n=localStorage.getItem("user"),i=n?JSON.parse(n).email:"";if(!i)return[];try{const x=JSON.stringify([["for_user","=",i]]),k=JSON.stringify(["name","subject","email_content","document_type","document_name","read","creation","from_user","type"]),N=yield _t.apiCall(`/api/resource/Notification Log?filters=${encodeURIComponent(x)}&fields=${encodeURIComponent(k)}&order_by=creation desc&limit=${r}&offset=${a}`);return console.log("[NotificationService] Fetched notifications:",N==null?void 0:N.data),((c=N==null?void 0:N.data)==null?void 0:c.length)>0&&console.log("[NotificationService] First notification sample:",N.data[0]),(N==null?void 0:N.data)||[]}catch(x){return(u=x==null?void 0:x.message)!=null&&u.includes("417")||(g=x==null?void 0:x.message)!=null&&g.includes("EXPECTATION FAILED")?[]:((y=x==null?void 0:x.message)!=null&&y.includes("417")||console.warn("Notifications API not available:",(x==null?void 0:x.message)||"Unknown error"),[])}})}markAsRead(r){return xe(this,null,function*(){var a,n,i,c;try{return yield _t.apiCall(`/api/resource/Notification Log/${r}`,{method:"PUT",body:JSON.stringify({read:1})})}catch(u){if((a=u==null?void 0:u.message)!=null&&a.includes("417")||(n=u==null?void 0:u.message)!=null&&n.includes("EXPECTATION FAILED")||(i=u==null?void 0:u.message)!=null&&i.includes("PermissionError")||(c=u==null?void 0:u.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:",(u==null?void 0:u.message)||"Unknown error"),u}})}markAllAsRead(){return xe(this,null,function*(){try{const a=(yield this.getNotifications(1e3)).filter(i=>!i.read);let n=0;for(const i of a)try{const c=yield this.markAsRead(i.name);(c==null?void 0:c.success)!==!1&&n++}catch(c){console.error(`Error marking notification ${i.name} as read:`,c)}return{success:!0,marked:n,total:a.length}}catch(r){return console.error("Error marking all notifications as read:",r),{success:!1,marked:0,total:0}}})}getUnreadCount(){return xe(this,null,function*(){try{return(yield this.getNotifications(1e3)).filter(a=>!a.read).length}catch(r){return console.error("Error getting unread count:",r),0}})}}const Hx=new LF;function IF(){const[e,r]=E.useState([]),[a,n]=E.useState(0),[i,c]=E.useState(!0),[u,g]=E.useState(null),y=E.useCallback(()=>xe(null,null,function*(){var N,C;try{c(!0),g(null);const O=yield Hx.getNotifications();r(O),n(O.filter(D=>!D.read).length)}catch(O){if((N=O==null?void 0:O.message)!=null&&N.includes("417")||(C=O==null?void 0:O.message)!=null&&C.includes("EXPECTATION FAILED"))r([]),n(0),g(null);else{const D=O instanceof Error?O.message:"Failed to fetch notifications";g(D),console.warn("Error fetching notifications:",O)}}finally{c(!1)}}),[]);E.useEffect(()=>{y();const N=setInterval(y,3e4);return()=>clearInterval(N)},[y]);const x=E.useCallback(N=>xe(null,null,function*(){try{yield Hx.markAsRead(N),r(C=>C.map(O=>O.name===N?$e(_e({},O),{read:1}):O)),n(C=>Math.max(0,C-1))}catch(C){throw console.error("Error marking notification as read:",C),C}}),[]),k=E.useCallback(()=>xe(null,null,function*(){try{yield Hx.markAllAsRead(),r(N=>N.map(C=>$e(_e({},C),{read:1}))),n(0)}catch(N){throw console.error("Error marking all notifications as read:",N),N}}),[]);return{notifications:e,unreadCount:a,loading:i,error:u,markAsRead:x,markAllAsRead:k,refetch:y}}const PF=()=>{const{notifications:e,unreadCount:r,markAsRead:a,markAllAsRead:n}=IF(),[i,c]=E.useState(!1),u=E.useRef(null),g=E.useRef(null),y=ua();E.useEffect(()=>{const A=I=>{var U,B;const z=I.target;(U=u.current)!=null&&U.contains(z)||(B=g.current)!=null&&B.contains(z)||c(!1)};return i&&document.addEventListener("mousedown",A),()=>{document.removeEventListener("mousedown",A)}},[i]),E.useEffect(()=>{if(!i||!window.matchMedia("(max-width: 1023px)").matches)return;const I=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=I}},[i]);const x=A=>xe(null,null,function*(){if(!A.read)try{yield a(A.name)}catch(I){console.warn("[NotificationBell] Could not mark as read (permission issue):",I)}if(A.document_type&&A.document_name){const I=A.document_type,z=A.document_name,U=I.replace(/_/g," ").trim();if(U==="Asset Maintenance Log"||U==="Asset Maintenance")y(`/maintenance/${z}`);else if(U==="Work Order"||U==="Asset Repair")y(`/work-orders/${z}`);else if(U==="Asset")y(`/assets/${z}`);else if(U==="PM Schedule Generator"||U==="PM Schedule")y(`/ppm-planner/${z}`);else if(U==="PPM")y(`/ppm/${z}`);else if(U==="Item")y(`/inventory/${z}`);else{const B=I.toLowerCase().replace(/\s+/g,"-").replace(/_/g,"-");window.open(`/app/${B}/${z}`,"_blank")}}c(!1)}),k=A=>{const I=new Date(A),U=new Date().getTime()-I.getTime(),B=Math.floor(U/6e4),V=Math.floor(U/36e5),Z=Math.floor(U/864e5);return B<1?"Just now":B<60?`${B}m ago`:V<24?`${V}h ago`:Z<7?`${Z}d ago`:I.toLocaleDateString()},N=e.filter(A=>!A.read),C=e.filter(A=>A.read).slice(0,10),O=()=>t.jsxs("div",{ref:g,className:`
|
||
fixed z-[9999] flex flex-col overflow-hidden
|
||
bg-white dark:bg-gray-800 rounded-xl shadow-2xl
|
||
border border-gray-200 dark:border-gray-700
|
||
left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2
|
||
w-[calc(100vw-2rem)] max-w-md max-h-[75vh]
|
||
lg:left-auto lg:top-[3.75rem] lg:right-4 lg:translate-x-0 lg:translate-y-0 lg:w-80 lg:max-h-96
|
||
`,children:[t.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between gap-2",children:[t.jsxs("h3",{className:"font-semibold text-gray-800 dark:text-white flex items-center gap-2 min-w-0",children:[t.jsx(Q2,{}),t.jsx("span",{className:"truncate",children:"Notifications"}),r>0&&t.jsxs("span",{className:"text-xs bg-red-500 text-white px-2 py-0.5 rounded-full shrink-0",children:[r," new"]})]}),r>0&&t.jsx("button",{type:"button",onClick:n,className:"text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 shrink-0",children:"Mark all read"})]}),t.jsx("div",{className:"overflow-y-auto flex-1 min-h-0",children:e.length===0?t.jsxs("div",{className:"p-8 text-center text-gray-500 dark:text-gray-400",children:[t.jsx(Q2,{className:"mx-auto text-3xl mb-2 opacity-50"}),t.jsx("p",{children:"No notifications"})]}):t.jsxs(t.Fragment,{children:[N.length>0&&t.jsxs("div",{className:"p-2",children:[t.jsx("div",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 px-2 mb-1",children:"NEW"}),N.map(A=>t.jsx("div",{onClick:()=>x(A),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:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:A.subject||A.document_type||"Notification"}),A.email_content&&t.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-1 line-clamp-2",children:A.email_content}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-500 mt-1",children:k(A.creation)})]}),t.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full flex-shrink-0 mt-1"})]})},A.name))]}),C.length>0&&t.jsxs("div",{className:"p-2 border-t border-gray-200 dark:border-gray-700",children:[N.length>0&&t.jsx("div",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 px-2 mb-1",children:"EARLIER"}),C.map(A=>t.jsx("div",{onClick:()=>x(A),className:"p-3 hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer",children:t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 truncate",children:A.subject||A.document_type||"Notification"}),A.email_content&&t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1 line-clamp-2",children:A.email_content}),t.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:k(A.creation)})]})})},A.name))]})]})})]}),D=E.useCallback(()=>c(!1),[]);return t.jsxs("div",{className:"relative",ref:u,children:[t.jsxs("button",{type:"button",onClick:()=>c(A=>!A),className:"relative p-2 min-h-[44px] min-w-[44px] flex items-center justify-center 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","aria-expanded":i,"aria-label":"Notifications",children:[t.jsx(YP,{size:20}),r>0&&t.jsx("span",{className:"absolute top-1 right-1 flex items-center justify-center w-5 h-5 text-xs font-bold text-white bg-red-500 rounded-full",children:r>9?"9+":r})]}),i&&Su.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"fixed inset-0 z-[9998] bg-black/40 lg:bg-black/20",onClick:D,"aria-label":"Close notifications"}),O()]}),document.body)]})},FF=()=>{try{const e=localStorage.getItem("user");if(!e)return"";const r=JSON.parse(e);return r.full_name||r.email||r.user_id||r.name||""}catch(e){return""}},BF=({userEmail:e})=>{const r=ua(),a=yi(),{theme:n,toggleTheme:i}=DF(),{language:c,changeLanguage:u}=h1(),{t:g}=oa(),[y,x]=E.useState(FF),{openMobileSidebar:k}=f1();E.useEffect(()=>{xe(null,null,function*(){var D;try{const z=(yield(yield fetch("/api/method/frappe.auth.get_logged_user",{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json()).message;if(z){const B=yield(yield fetch(`/api/resource/User/${encodeURIComponent(z)}?fields=["full_name"]`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"})).json();x(((D=B.data)==null?void 0:D.full_name)||z);return}}catch(A){console.error("Error fetching user display name:",A)}e&&x(e)})},[e]);const N=()=>xe(null,null,function*(){var O;localStorage.removeItem("user"),localStorage.removeItem("sid");try{const D=((O=document.cookie.split("; ").find(A=>A.startsWith("X-Frappe-CSRF-Token=")))==null?void 0:O.split("=")[1])||"";yield fetch("/api/method/frappe.auth.logout",{method:"POST",headers:{"Content-Type":"application/json","X-Frappe-CSRF-Token":D},credentials:"include"}),yield fetch("/?cmd=web_logout",{credentials:"include"})}catch(D){console.error("Logout error:",D)}finally{window.location.href="/asm_app/login"}}),C=a.pathname==="/user-profile";return t.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-between gap-2 flex-shrink-0",children:[t.jsx("button",{type:"button",onClick:k,className:"lg:hidden p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors text-gray-700 dark:text-gray-300","aria-label":g("common.menu",{defaultValue:"Open menu"}),children:t.jsx(Fk,{size:20})}),t.jsxs("div",{className:"flex items-center justify-end gap-2 flex-1 min-w-0",children:[t.jsxs("button",{type:"button",onClick:()=>r("/user-profile"),className:`
|
||
flex items-center gap-2 px-3 py-2 rounded-lg transition-colors text-white
|
||
${C?"bg-indigo-700 ring-2 ring-indigo-300 dark:ring-indigo-500":"bg-indigo-600 hover:bg-indigo-700"}
|
||
`,"aria-label":y||g("common.userProfile",{defaultValue:"User Profile"}),children:[y&&t.jsx("span",{className:"text-sm font-medium max-w-[180px] truncate",children:y}),t.jsx(rF,{size:20,className:"flex-shrink-0"})]}),t.jsx("div",{className:"relative",children:t.jsx(PF,{})}),t.jsx("button",{onClick:()=>u(c==="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:g("common.language"),children:t.jsx(dF,{size:20})}),t.jsx("button",{onClick:i,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors text-gray-700 dark:text-gray-300",title:g(n==="light"?"common.darkMode":"common.lightMode"),children:n==="light"?t.jsx(bF,{size:20}):t.jsx(NF,{size:20})}),t.jsx("button",{onClick:N,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:g("common.logout"),children:t.jsx(mF,{size:20})})]})]})};class UF{constructor(){Ti(this,"baseURL");this.baseURL=Lr.BASE_URL}getCSRFToken(){return xe(this,null,function*(){try{return typeof window!="undefined"&&window.csrf_token?window.csrf_token:null}catch(r){return null}})}getHeaders(){return xe(this,null,function*(){const r={Accept:"application/json","Content-Type":"application/json"},a=yield this.getCSRFToken();return a&&(r["X-Frappe-CSRF-Token"]=a),r})}getIssues(){return xe(this,arguments,function*(r={}){const{filters:a={},fields:n=["name","subject","raised_by","status","priority","issue_type","opening_date","company","contact","creation","modified","first_responded_on","resolution_date","resolution_by"],limit_start:i=0,limit_page_length:c=20,order_by:u="creation desc"}=r,g=new URLSearchParams;if(g.append("fields",JSON.stringify(n)),g.append("limit_start",i.toString()),g.append("limit_page_length",c.toString()),g.append("order_by",u),Object.keys(a).length>0){const k=Object.entries(a).map(([N,C])=>[N,"=",C]);g.append("filters",JSON.stringify(k))}const y=yield fetch(`${this.baseURL}/api/resource/Issue?${g.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!y.ok)throw new Error(`HTTP error! status: ${y.status}`);return{data:(yield y.json()).data||[]}})}getIssue(r){return xe(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Issue/${encodeURIComponent(r)}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return(yield a.json()).data})}createIssue(r){return xe(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Issue`,{method:"POST",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(r)});if(!a.ok){const i=yield a.json().catch(()=>({}));throw new Error(i.message||`HTTP error! status: ${a.status}`)}return(yield a.json()).data})}updateIssue(r,a){return xe(this,null,function*(){const n=yield fetch(`${this.baseURL}/api/resource/Issue/${encodeURIComponent(r)}`,{method:"PUT",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(a)});if(!n.ok){const c=yield n.json().catch(()=>({}));throw new Error(c.message||`HTTP error! status: ${n.status}`)}return(yield n.json()).data})}deleteIssue(r){return xe(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Issue/${encodeURIComponent(r)}`,{method:"DELETE",headers:yield this.getHeaders(),credentials:"include"});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`)})}getIssueCount(){return xe(this,arguments,function*(r={}){var c,u;const a=new URLSearchParams;if(a.append("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const g=Object.entries(r).map(([y,x])=>[y,"=",x]);a.append("filters",JSON.stringify(g))}const n=yield fetch(`${this.baseURL}/api/resource/Issue?${a.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return((u=(c=(yield n.json()).data)==null?void 0:c[0])==null?void 0:u.count)||0})}}const Vd=new UF,zF=(e={})=>{const[r,a]=E.useState([]),[n,i]=E.useState(!0),[c,u]=E.useState(null),[g,y]=E.useState(0),x=E.useCallback(()=>xe(null,null,function*(){try{i(!0),u(null);const k=yield Vd.getIssues(e);a(k.data);const N=yield Vd.getIssueCount(e.filters);y(N)}catch(k){u(k instanceof Error?k.message:"Failed to fetch issues")}finally{i(!1)}}),[JSON.stringify(e)]);return E.useEffect(()=>{x()},[x]),{issues:r,loading:n,error:c,totalCount:g,refetch:x}},HF=e=>{const[r,a]=E.useState(null),[n,i]=E.useState(!1),[c,u]=E.useState(null),g=E.useCallback(()=>xe(null,null,function*(){if(!e){a(null);return}try{i(!0),u(null);const y=yield Vd.getIssue(e);a(y)}catch(y){u(y instanceof Error?y.message:"Failed to fetch issue details")}finally{i(!1)}}),[e]);return E.useEffect(()=>{g()},[g]),{issue:r,loading:n,error:c,refetch:g}},VF=()=>{const[e,r]=E.useState(!1),[a,n]=E.useState(null);return{createIssue:g=>xe(null,null,function*(){try{return r(!0),n(null),yield Vd.createIssue(g)}catch(y){const x=y instanceof Error?y.message:"Failed to create issue";throw n(x),y}finally{r(!1)}}),updateIssue:(g,y)=>xe(null,null,function*(){try{return r(!0),n(null),yield Vd.updateIssue(g,y)}catch(x){const k=x instanceof Error?x.message:"Failed to update issue";throw n(k),x}finally{r(!1)}}),deleteIssue:g=>xe(null,null,function*(){try{r(!0),n(null),yield Vd.deleteIssue(g)}catch(y){const x=y instanceof Error?y.message:"Failed to delete issue";throw n(x),y}finally{r(!1)}}),loading:e,error:a}},WF=({isOpen:e,onClose:r,selectedCount:a,totalCount:n,pageCount:i,onExport:c,isExporting:u,exportColumns:g})=>{const[y,x]=E.useState(a>0?"selected":"all_with_filters"),[k,N]=E.useState("csv"),[C,O]=E.useState(g.filter(z=>z.default).map(z=>z.key));E.useEffect(()=>{a>0?x("selected"):x("all_with_filters")},[a]);const D=z=>{O(U=>U.includes(z)?U.filter(B=>B!==z):[...U,z])},A=()=>O(g.map(z=>z.key)),I=()=>O(g.filter(z=>z.default).map(z=>z.key));return e?t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.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:[t.jsx("div",{className:"bg-gradient-to-r from-green-500 to-green-600 px-6 py-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(cs,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Export Issues"})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:u,children:t.jsx(qt,{size:20})})]})}),t.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"Select Data to Export"}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${y==="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"} ${a===0?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"selected",checked:y==="selected",onChange:()=>x("selected"),disabled:a===0,className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Selected Rows"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export ",a," selected issue",a!==1?"s":""]})]}),a>0&&t.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:[a," selected"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${y==="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:[t.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:y==="all_on_page",onChange:()=>x("all_on_page"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Current Page"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export ",i," issue",i!==1?"s":""," on current page"]})]}),t.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"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${y==="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:[t.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:y==="all_with_filters",onChange:()=>x("all_with_filters"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"All Records (with current filters)"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export all ",n," issue",n!==1?"s":""," matching current filters"]})]}),t.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:[n," total"]})]})]})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"Export Format"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${k==="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:[t.jsx("input",{type:"radio",name:"format",value:"csv",checked:k==="csv",onChange:()=>N("csv"),className:"text-green-600 focus:ring-green-500"}),t.jsx(Kd,{className:"text-green-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"CSV"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Comma-separated values"})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${k==="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:[t.jsx("input",{type:"radio",name:"format",value:"excel",checked:k==="excel",onChange:()=>N("excel"),className:"text-green-600 focus:ring-green-500"}),t.jsx(cl,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Excel"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"XLSX spreadsheet"})]})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Columns to Export"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:A,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Select All"}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:I,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Reset to Default"})]})]}),t.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:g.map(z=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${C.includes(z.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:[t.jsx("input",{type:"checkbox",checked:C.includes(z.key),onChange:()=>D(z.key),className:"rounded text-green-600 focus:ring-green-500"}),t.jsx("span",{className:"text-sm truncate",children:z.label})]},z.key))}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:[C.length," column",C.length!==1?"s":""," selected"]})]})]}),t.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:[t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[y==="selected"&&`Exporting ${a} selected row${a!==1?"s":""}`,y==="all_on_page"&&`Exporting ${i} row${i!==1?"s":""} from current page`,y==="all_with_filters"&&`Exporting all ${n} row${n!==1?"s":""}`]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:r,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:u,children:"Cancel"}),t.jsx("button",{onClick:()=>c(y,k,C),disabled:C.length===0||u,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:u?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Exporting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Co,{}),"Export"]})})]})]})]})}):null},GF=e=>{switch(e==null?void 0:e.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"}},$F=e=>{switch(e==null?void 0:e.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"}},XF=()=>{const{t:e}=oa(),r=ua(),a=[{key:"name",label:e("issues.issueId"),default:!0},{key:"subject",label:e("issues.subject"),default:!0},{key:"status",label:e("commonFields.status"),default:!0},{key:"priority",label:e("commonFields.priority"),default:!0},{key:"raised_by",label:e("issues.raisedBy"),default:!0},{key:"company",label:e("commonFields.company"),default:!0},{key:"contact",label:e("issues.contact"),default:!1},{key:"issue_type",label:e("issues.issueType"),default:!1},{key:"opening_date",label:e("issues.openingDate"),default:!0},{key:"resolution_date",label:e("issues.resolutionDate"),default:!1},{key:"resolution_by",label:e("issues.resolvedBy"),default:!1},{key:"first_responded_on",label:e("issues.firstRespondedOn"),default:!1},{key:"description",label:e("commonFields.description"),default:!1},{key:"resolution_details",label:e("issues.resolutionDetails"),default:!1},{key:"creation",label:e("commonFields.createdOn"),default:!1},{key:"modified",label:e("commonFields.modifiedOn"),default:!1},{key:"owner",label:e("commonFields.createdBy"),default:!1}],{sortBy:n,dateFilterBy:i,dateStart:c,dateEnd:u,page:g,setSortBy:y,setDateFilterBy:x,setDateStart:k,setDateEnd:N,setPage:C,resetPage:O}=pm("creation desc"),D=20,[A,I]=E.useState(!1),[z,U]=E.useState(new Set),[B,V]=E.useState(!1),[Z,W]=E.useState(!1),[H,le]=E.useState(null),[Q,Ne]=E.useState(""),[oe,se]=E.useState(""),[ce,Ce]=E.useState(""),[ae,me]=E.useState(""),[K,fe]=E.useState(!1),[Oe,ye]=E.useState(0),[J,G]=E.useState([]),[ie,re]=E.useState(!1),[ne,ve]=E.useState("");E.useEffect(()=>{const Be=localStorage.getItem("issueFilterPresets");Be&&G(JSON.parse(Be))},[]),E.useEffect(()=>{const Be=[Q,oe,ce,ae].filter(Boolean).length;ye(Be)},[Q,oe,ce,ae]);const Ve=E.useMemo(()=>xm(_e(_e(_e(_e({},Q?{status:Q}:{}),oe?{priority:oe}:{}),ce?{company:ce}:{}),ae?{name:ae}:{}),i,c,u),[Q,oe,ce,ae,i,c,u]),{issues:Ae,loading:ze,error:Re,totalCount:Ze,refetch:Lt}=zF({filters:Ve,limit_start:g*D,limit_page_length:D,order_by:n});E.useEffect(()=>{!ze&&!A&&I(!0)},[ze,A]),E.useEffect(()=>{O()},[Q,oe,ce,ae,n,i,c,u]),E.useEffect(()=>{U(new Set)},[Q,oe,ce,ae,g]);const mt=(g+1)*D<Ze,Zt=Be=>Be?new Date(Be).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",ar=()=>{Ne(""),se(""),Ce(""),me(""),O()},or=Q||oe||ce||ae,yt=()=>{if(!ne.trim()){alert("Please enter a filter name");return}const Be={id:Date.now(),name:ne,filters:{statusFilter:Q,priorityFilter:oe,companyFilter:ce,issueIdFilter:ae}},vt=[...J,Be];G(vt),ve(""),re(!1),localStorage.setItem("issueFilterPresets",JSON.stringify(vt))},nr=Be=>{const vt=Be.filters;Ne(vt.statusFilter||""),se(vt.priorityFilter||""),Ce(vt.companyFilter||""),me(vt.issueIdFilter||"")},$t=Be=>{const vt=J.filter(jt=>jt.id!==Be);G(vt),localStorage.setItem("issueFilterPresets",JSON.stringify(vt))},Er=Be=>{U(vt=>{const jt=new Set(vt);return jt.has(Be)?jt.delete(Be):jt.add(Be),jt})},St=()=>{z.size===Ae.length?U(new Set):U(new Set(Ae.map(Be=>Be.name)))},Br=Ae.length>0&&z.size===Ae.length,Pt=z.size>0&&z.size<Ae.length,it=E.useCallback(()=>xe(null,null,function*(){const Be=[];let vt=0;const jt=100;let Ct=!0;for(;Ct;)try{const Ge=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Issue",filters:Ve,fields:["*"],limit_start:vt*jt,limit_page_length:jt,order_by:n})})).json()).message||[];Be.push(...Ge),Ge.length<jt?Ct=!1:vt++,vt>100&&(console.warn("Export safety limit reached"),Ct=!1)}catch(Wt){throw console.error("Error fetching issues for export:",Wt),Wt}return Be}),[Ve]),De=(Be,vt,jt)=>xe(null,null,function*(){W(!0);try{let Ct=[];switch(Be){case"selected":Ct=Ae.filter(pr=>z.has(pr.name));break;case"all_on_page":Ct=Ae;break;case"all_with_filters":Ct=yield it();break}if(Ct.length===0){alert("No data to export");return}const Wt=jt.map(pr=>{var Ge;return((Ge=a.find(We=>We.key===pr))==null?void 0:Ge.label)||pr});if(vt==="csv"){const pr=[Wt.join(","),...Ct.map(lt=>jt.map(Dt=>{let mr=lt[Dt]||"";return typeof mr=="string"&&(mr.includes(",")||mr.includes('"')||mr.includes(`
|
||
`))&&(mr=`"${mr.replace(/"/g,'""')}"`),mr}).join(","))].join(`
|
||
`),Ge=new Blob(["\uFEFF"+pr],{type:"text/csv;charset=utf-8;"}),We=URL.createObjectURL(Ge),At=document.createElement("a");At.href=We,At.download=`issues_export_${new Date().toISOString().split("T")[0]}.csv`,At.click(),URL.revokeObjectURL(We)}else if(vt==="excel"){const pr=[Wt,...Ct.map(At=>jt.map(lt=>At[lt]||""))],Ge=Wa.aoa_to_sheet(pr),We=Wa.book_new();Wa.book_append_sheet(We,Ge,"Issues"),ul(We,`issues_export_${new Date().toISOString().split("T")[0]}.xlsx`)}V(!1),U(new Set)}catch(Ct){console.error("Export failed:",Ct),alert(`Export failed: ${Ct instanceof Error?Ct.message:"Unknown error"}`)}finally{W(!1)}}),Je=Be=>xe(null,null,function*(){try{if(!(yield fetch(`/api/resource/Issue/${Be}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to delete");le(null),Lt(),alert("Issue deleted successfully!")}catch(vt){alert(`Failed to delete: ${vt instanceof Error?vt.message:"Unknown error"}`)}});return ze&&!A?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading issues..."})]})}):Re?t.jsx("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:"Error Loading Issues"}),t.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:Re}),t.jsx("button",{onClick:Lt,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:"Try Again"})]})}):t.jsxs("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center",children:[t.jsx("div",{children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ev,{className:"text-3xl text-blue-600 dark:text-blue-400"}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:"Support Issues"}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Total: ",Ze," issue",Ze!==1?"s":"",z.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",z.size," selected"]}),ze&&A&&t.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[t.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-blue-500"}),"Updating..."]})]})]})]})}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("button",{onClick:()=>fe(!K),className:`px-4 py-2 rounded-lg flex items-center gap-2 transition-colors ${K||or?"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:[t.jsx(Ri,{}),"Filters",Oe>0&&t.jsx("span",{className:"bg-blue-600 text-white text-xs px-1.5 py-0.5 rounded-full",children:Oe})]}),t.jsxs("button",{onClick:Lt,disabled:ze,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:[t.jsx(Eo,{className:ze?"animate-spin":""}),"Refresh"]}),t.jsxs("button",{onClick:()=>V(!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:Ze===0,children:[t.jsx(cs,{}),t.jsx("span",{className:"font-medium",children:"Export"}),z.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:z.size})]}),t.jsxs("button",{onClick:()=>r("/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:[t.jsx(Mi,{}),t.jsx("span",{className:"font-medium",children:"New Issue"})]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-4",children:[t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Total Issues"}),t.jsx("p",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:Ze})]}),t.jsx(sC,{className:"text-3xl text-blue-500"})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Open"}),t.jsx("p",{className:"text-2xl font-bold text-blue-600",children:Ae.filter(Be=>Be.status==="Open").length})]}),t.jsx($s,{className:"text-3xl text-blue-500"})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Resolved"}),t.jsx("p",{className:"text-2xl font-bold text-green-600",children:Ae.filter(Be=>Be.status==="Resolved").length})]}),t.jsx(Ca,{className:"text-3xl text-green-500"})]})}),t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4 border border-gray-200 dark:border-gray-700",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Closed"}),t.jsx("p",{className:"text-2xl font-bold text-gray-600 dark:text-gray-300",children:Ae.filter(Be=>Be.status==="Closed").length})]}),t.jsx(jn,{className:"text-3xl text-gray-500"})]})})]}),K&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[t.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:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Ri,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:"Filters"}),Oe>0&&t.jsx("span",{className:"bg-white text-blue-600 px-2 py-0.5 rounded-full text-xs font-bold",children:Oe})]}),or&&t.jsx("div",{className:"flex-1 overflow-x-auto scrollbar-hide mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[ae&&t.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:[t.jsx("span",{className:"font-semibold",children:"Issue:"})," ",ae,t.jsx("button",{onClick:()=>me(""),className:"hover:text-red-500",children:t.jsx(qt,{className:"text-[9px]"})})]}),Q&&t.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:[t.jsx("span",{className:"font-semibold",children:"Status:"})," ",Q,t.jsx("button",{onClick:()=>Ne(""),className:"hover:text-red-500",children:t.jsx(qt,{className:"text-[9px]"})})]}),oe&&t.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:[t.jsx("span",{className:"font-semibold",children:"Priority:"})," ",oe,t.jsx("button",{onClick:()=>se(""),className:"hover:text-red-500",children:t.jsx(qt,{className:"text-[9px]"})})]}),ce&&t.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:[t.jsx("span",{className:"font-semibold",children:"Company:"})," ",ce,t.jsx("button",{onClick:()=>Ce(""),className:"hover:text-red-500",children:t.jsx(qt,{className:"text-[9px]"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Oe>0&&t.jsxs("button",{onClick:()=>re(!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:[t.jsx(Fn,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),or&&t.jsxs("button",{onClick:ar,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:[t.jsx(qt,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]})]})}),t.jsxs("div",{className:"p-4",children:[J.length>0&&t.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[t.jsx(Zl,{className:"text-yellow-500",size:12}),"Saved Filters"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:J.map(Be=>t.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:[t.jsx("button",{onClick:()=>nr(Be),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:Be.name}),t.jsx("button",{onClick:()=>$t(Be.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(ma,{size:10})})]},Be.id))})]}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[t.jsx(Bu,{sortBy:n,dateFilterBy:i,dateStart:c,dateEnd:u,onSortByChange:y,onDateFilterByChange:x,onDateStartChange:k,onDateEndChange:N}),t.jsxs("div",{className:"relative z-[60]",children:[t.jsx(er,{label:"Issue",doctype:"Issue",value:ae,onChange:Be=>{me(Be),O()},placeholder:"Select Issue",disabled:!1,compact:!0}),ae&&t.jsx("button",{onClick:()=>me(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("label",{className:"block text-[10px] font-medium text-gray-700 dark:text-gray-300 mb-0.5",children:"Status"}),t.jsxs("select",{value:Q,onChange:Be=>{Ne(Be.target.value),O()},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:[t.jsx("option",{value:"",children:"All Statuses"}),t.jsx("option",{value:"Open",children:"Open"}),t.jsx("option",{value:"Replied",children:"Replied"}),t.jsx("option",{value:"On Hold",children:"On Hold"}),t.jsx("option",{value:"Resolved",children:"Resolved"}),t.jsx("option",{value:"Closed",children:"Closed"})]})]}),t.jsxs("div",{className:"relative z-[59]",children:[t.jsx(er,{label:e("commonFields.priority"),doctype:"Issue Priority",value:oe,onChange:Be=>{se(Be),O()},placeholder:e("issues.allPriorities"),disabled:!1,compact:!0}),oe&&t.jsx("button",{onClick:()=>se(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[58]",children:[t.jsx(er,{label:e("commonFields.company"),doctype:"Company",value:ce,onChange:Be=>{Ce(Be),O()},placeholder:e("issues.allCompanies"),disabled:!1,compact:!0}),ce&&t.jsx("button",{onClick:()=>Ce(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]})]})})]})]}),ie&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:"Save Filter Preset"}),t.jsx("input",{type:"text",value:ne,onChange:Be=>ve(Be.target.value),onKeyDown:Be=>{Be.key==="Enter"&&(Be.preventDefault(),yt())},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}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{re(!1),ve("")},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"}),t.jsxs("button",{onClick:yt,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:[t.jsx(Fn,{size:12}),"Save Filter"]})]})]})}),t.jsx(WF,{isOpen:B,onClose:()=>V(!1),selectedCount:z.size,totalCount:Ze,pageCount:Ae.length,onExport:De,isExporting:Z,exportColumns:a}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700 overflow-hidden relative",children:[ze&&A&&t.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:t.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[t.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-blue-500"}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Filtering..."})]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left",children:t.jsx("button",{onClick:St,className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",title:e(Br?"listPages.deselectAllTitle":"listPages.selectAllTitle"),children:Br?t.jsx(qs,{className:"text-blue-600 dark:text-blue-400",size:18}):Pt?t.jsxs("div",{className:"relative",children:[t.jsx(Pn,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Pn,{size:18})})}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("issues.issueId")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("issues.subject")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.status")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.priority")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.company")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("issues.openingDate")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("listPages.actions")})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:Ae.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:8,className:"px-4 py-12 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(ev,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:"No issues found"}),or?t.jsx("button",{onClick:ar,className:"mt-4 text-blue-600 dark:text-blue-400 hover:underline",children:"Clear filters"}):t.jsx("button",{onClick:()=>r("/support/new"),className:"mt-4 text-blue-600 dark:text-blue-400 hover:underline",children:"Create your first issue"})]})})}):Ae.map(Be=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer transition-colors ${z.has(Be.name)?"bg-blue-50 dark:bg-blue-900/20":""}`,onClick:()=>r(`/support/${Be.name}`),children:[t.jsx("td",{className:"px-4 py-3",onClick:vt=>vt.stopPropagation(),children:t.jsx("button",{onClick:()=>Er(Be.name),className:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors",children:z.has(Be.name)?t.jsx(qs,{className:"text-blue-600 dark:text-blue-400",size:18}):t.jsx(Pn,{size:18})})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-400",children:Be.name})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm text-gray-900 dark:text-white line-clamp-1",children:Be.subject||"-"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${GF(Be.status)}`,children:Be.status||"-"})}),t.jsx("td",{className:"px-4 py-3",children:Be.priority?t.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${$F(Be.priority)}`,children:Be.priority}):t.jsx("span",{className:"text-gray-400",children:"-"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300 line-clamp-1",children:Be.company||"-"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:Zt(Be.opening_date)})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-1",onClick:vt=>vt.stopPropagation(),children:[t.jsx("button",{onClick:()=>r(`/support/${Be.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:e("issues.viewDetails"),children:t.jsx(to,{})}),t.jsx("button",{onClick:()=>r(`/support/${Be.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:e("issues.editIssue"),children:t.jsx(Yn,{})}),t.jsx("button",{onClick:()=>le(Be.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:e("issues.deleteIssue"),children:t.jsx(ma,{})})]})})]},Be.name))})]})}),t.jsx(Fu,{currentPage:g+1,totalCount:Ze,pageSize:D,hasMore:mt,itemLabel:e("pagination.issues"),onPageChange:Be=>C(Math.max(0,Be-1))})]}),H&&t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.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:t.jsx(ma,{className:"text-red-600 dark:text-red-400 text-xl"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Delete Issue"}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:"Are you sure you want to delete this issue? This action cannot be undone."}),t.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:t.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[t.jsx("strong",{children:"Issue ID:"})," ",H]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>le(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:"Cancel"}),t.jsxs("button",{onClick:()=>Je(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",children:[t.jsx(ma,{}),"Delete Issue"]})]})]})]})})}),t.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; }
|
||
`})]})},YF=()=>new Date().toISOString().split("T")[0],ZF=()=>new Date().toTimeString().split(" ")[0],qF=e=>{switch(e==null?void 0:e.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"}}},KF=()=>{const{t:e}=oa(),{issueName:r}=Yl(),a=ua(),n=r==="new",[i,c]=E.useState({subject:"",raised_by:"",status:"Open",priority:"",issue_type:"",description:"",contact:"",company:"",customer:"",project:"",resolution_details:"",opening_date:n?YF():"",opening_time:n?ZF():"",first_responded_on:"",resolution_date:"",resolution_by:""}),{issue:u,loading:g,error:y,refetch:x}=HF(n?null:r||null),{createIssue:k,updateIssue:N,deleteIssue:C,loading:O}=VF(),[D,A]=E.useState(n),[I,z]=E.useState(!1);Kl(c,{enabled:n,fields:["company"]}),E.useEffect(()=>{u&&!n&&(c({subject:u.subject||"",raised_by:u.raised_by||"",status:u.status||"Open",priority:u.priority||"",issue_type:u.issue_type||"",description:u.description||"",contact:u.contact||"",company:u.company||"",customer:u.customer||"",project:u.project||"",resolution_details:u.resolution_details||"",opening_date:u.opening_date||"",opening_time:u.opening_time||"",first_responded_on:u.first_responded_on?u.first_responded_on.split(" ")[0]:"",resolution_date:u.resolution_date?u.resolution_date.split(" ")[0]:"",resolution_by:u.resolution_by||""}),A(!1))},[u,n]);const U=Q=>{const{name:Ne,value:oe}=Q.target;c(se=>$e(_e({},se),{[Ne]:oe}))},B=()=>xe(null,null,function*(){if(!i.subject){dr.error("Please enter a subject",{position:"top-right",autoClose:4e3,icon:t.jsx(jn,{})});return}try{if(n){const Q=yield k(i);dr.success("Issue created successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Ca,{})}),a(`/support/${Q.name}`)}else yield N(r,i),dr.success("Issue updated successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Ca,{})}),A(!1),x()}catch(Q){const Ne=Q instanceof Error?Q.message:"Unknown error";dr.error(`Failed to save: ${Ne}`,{position:"top-right",autoClose:6e3,icon:t.jsx(jn,{})})}}),V=()=>xe(null,null,function*(){try{yield C(r),dr.success("Issue deleted successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Ca,{})}),a("/support")}catch(Q){const Ne=Q instanceof Error?Q.message:"Unknown error";dr.error(`Failed to delete: ${Ne}`,{position:"top-right",autoClose:6e3,icon:t.jsx(jn,{})})}}),Z=E.useCallback(Q=>!!(!D||["opening_date","opening_time"].includes(Q)&&!n),[D,n]),W=Q=>Q?new Date(Q).toLocaleString():"-";if(g)return t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading issue details..."})]})});if(y&&!n)return t.jsx("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:"Error Loading Issue"}),t.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:y}),t.jsx("button",{onClick:()=>a("/support"),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:"Back to Issues"})]})});const H=(u==null?void 0:u.status)||i.status||"Open",le=qF(H);return t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-4 sm:p-6 min-w-0 overflow-x-hidden",children:[t.jsx(wm,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Hu}),t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("button",{onClick:()=>a("/support"),className:"text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200",children:t.jsx(bi,{size:20})}),t.jsxs("div",{children:[t.jsxs("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white flex items-center gap-3",children:[n?e("issues.newIssue"):(u==null?void 0:u.name)||e("issues.issueDetails"),!n&&t.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-medium ${le.bg} ${le.text} ${le.border} border`,children:H})]}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:n?e("issues.createNewIssue"):i.subject})]})]}),t.jsxs("div",{className:"flex gap-3",children:[!n&&!D&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>A(!0),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(Yn,{}),e("common.edit")]}),t.jsxs("button",{onClick:()=>z(!0),className:"bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(ma,{}),e("common.delete")]})]}),D&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{n?a("/support"):(A(!1),x())},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg",children:e("common.cancel")}),t.jsxs("button",{onClick:B,disabled:O,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:[t.jsx(Fn,{}),e(O?"common.saving":"common.save")]})]})]})]}),I&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[t.jsx(an,{className:"text-red-500 text-xl mt-0.5"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Delete Issue"}),t.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."})]})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>z(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:"Cancel"}),t.jsx("button",{onClick:V,disabled:O,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg disabled:opacity-50",children:O?"Deleting...":"Delete"})]})]})}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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:[t.jsx(nC,{className:"text-blue-500"}),e("issues.issueDetails")]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[e("issues.subject")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",name:"subject",value:i.subject,onChange:U,disabled:Z("subject"),placeholder:e("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"})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("commonFields.status")}),t.jsxs("select",{name:"status",value:i.status,onChange:U,disabled:Z("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:[t.jsx("option",{value:"Open",children:"Open"}),t.jsx("option",{value:"Replied",children:"Replied"}),t.jsx("option",{value:"On Hold",children:"On Hold"}),t.jsx("option",{value:"Resolved",children:"Resolved"}),t.jsx("option",{value:"Closed",children:"Closed"})]})]}),t.jsx("div",{children:t.jsx(er,{label:e("commonFields.priority"),doctype:"Issue Priority",value:i.priority||"",onChange:Q=>c($e(_e({},i),{priority:Q})),disabled:Z("priority"),placeholder:e("issues.selectPriority")})})]}),t.jsx("div",{children:t.jsx(er,{label:e("issues.issueType"),doctype:"Issue Type",value:i.issue_type||"",onChange:Q=>c($e(_e({},i),{issue_type:Q})),disabled:Z("issue_type"),placeholder:e("issues.selectIssueType")})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("commonFields.description")}),t.jsx("textarea",{name:"description",value:i.description,onChange:U,disabled:Z("description"),placeholder:e("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"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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:[t.jsx(Wl,{className:"text-green-500"}),e("issues.contactInformation")]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("issues.raisedBy")}),t.jsxs("div",{className:"relative",children:[t.jsx(Tw,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"}),t.jsx("input",{type:"email",name:"raised_by",value:i.raised_by,onChange:U,disabled:Z("raised_by"),placeholder:e("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"})]})]}),t.jsx("div",{children:t.jsx(er,{label:e("commonFields.company"),doctype:"Company",value:i.company||"",onChange:Q=>c($e(_e({},i),{company:Q})),disabled:Z("company"),placeholder:e("issues.selectCompany")})})]})]}),!n&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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:[t.jsx(Ca,{className:"text-purple-500"}),e("issues.resolution")]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("issues.firstRespondedOn")}),t.jsx("input",{type:"date",name:"first_responded_on",value:i.first_responded_on||"",onChange:U,disabled:Z("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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("issues.resolutionDate")}),t.jsx("input",{type:"date",name:"resolution_date",value:i.resolution_date||"",onChange:U,disabled:Z("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"})]})]}),t.jsx("div",{children:t.jsx(er,{label:e("issues.resolvedBy"),doctype:"User",value:i.resolution_by||"",onChange:Q=>c($e(_e({},i),{resolution_by:Q})),disabled:Z("resolution_by"),placeholder:e("maintenance.selectUser")})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("issues.resolutionDetails")}),t.jsx("textarea",{name:"resolution_details",value:i.resolution_details,onChange:U,disabled:Z("resolution_details"),placeholder:e("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"})]})]})]})]}),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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:[t.jsx(gC,{className:"text-orange-500"}),e("issues.statusInformation")]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:`p-4 rounded-lg border ${le.bg} ${le.border}`,children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("issues.currentStatus")}),t.jsx("p",{className:`text-xl font-semibold ${le.text}`,children:H})]}),i.priority&&t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("commonFields.priority")}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:i.priority})]}),i.issue_type&&t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("issues.issueType")}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:i.issue_type})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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:[t.jsx(al,{className:"text-teal-500"}),e("issues.timeline")]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("issues.openingDate")}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:i.opening_date||"-"})]}),t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Opening Time"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:i.opening_time||"-"})]}),!n&&u&&t.jsx(t.Fragment,{children:t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Created"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:W(u.creation)})]})})]})]}),!n&&t.jsxs("div",{className:"space-y-6",children:[t.jsx(Vu,{referenceDoctype:"Issue",referenceName:r||null,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5}),t.jsx(Wu,{doctype:"Issue",docname:r||null,creationDate:u==null?void 0:u.creation,createdBy:u==null?void 0:u.owner,initialVisible:5,startCollapsed:!0})]}),i.company&&!n&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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:[t.jsx(kf,{className:"text-indigo-500"}),"Company"]}),t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:i.company})})]})]})]})]})};class JF{constructor(){Ti(this,"baseURL");this.baseURL=Lr.BASE_URL}getCSRFToken(){return xe(this,null,function*(){try{return typeof window!="undefined"&&window.csrf_token?window.csrf_token:null}catch(r){return null}})}getHeaders(){return xe(this,null,function*(){const r={Accept:"application/json","Content-Type":"application/json"},a=yield this.getCSRFToken();return a&&(r["X-Frappe-CSRF-Token"]=a),r})}getMaintenanceTeams(){return xe(this,arguments,function*(r={}){const{filters:a={},fields:n=["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:u="creation desc"}=r,g=new URLSearchParams;if(g.append("fields",JSON.stringify(n)),g.append("limit_start",i.toString()),g.append("limit_page_length",c.toString()),g.append("order_by",u),Object.keys(a).length>0){const k=Object.entries(a).map(([N,C])=>[N,"=",C]);g.append("filters",JSON.stringify(k))}const y=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team?${g.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!y.ok)throw new Error(`HTTP error! status: ${y.status}`);return{data:(yield y.json()).data||[]}})}getMaintenanceTeam(r){return xe(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team/${encodeURIComponent(r)}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return(yield a.json()).data})}createMaintenanceTeam(r){return xe(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team`,{method:"POST",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(r)});if(!a.ok){const i=yield a.json().catch(()=>({}));throw new Error(i.message||`HTTP error! status: ${a.status}`)}return(yield a.json()).data})}updateMaintenanceTeam(r,a){return xe(this,null,function*(){const n=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team/${encodeURIComponent(r)}`,{method:"PUT",headers:yield this.getHeaders(),credentials:"include",body:JSON.stringify(a)});if(!n.ok){const c=yield n.json().catch(()=>({}));throw new Error(c.message||`HTTP error! status: ${n.status}`)}return(yield n.json()).data})}deleteMaintenanceTeam(r){return xe(this,null,function*(){const a=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team/${encodeURIComponent(r)}`,{method:"DELETE",headers:yield this.getHeaders(),credentials:"include"});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`)})}getMaintenanceTeamCount(){return xe(this,arguments,function*(r={}){var c,u;const a=new URLSearchParams;if(a.append("fields",JSON.stringify(["count(name) as count"])),Object.keys(r).length>0){const g=Object.entries(r).map(([y,x])=>[y,"=",x]);a.append("filters",JSON.stringify(g))}const n=yield fetch(`${this.baseURL}/api/resource/Asset Maintenance Team?${a.toString()}`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return((u=(c=(yield n.json()).data)==null?void 0:c[0])==null?void 0:u.count)||0})}getUserFullName(r){return xe(this,null,function*(){var a;try{const n=yield fetch(`${this.baseURL}/api/resource/User/${encodeURIComponent(r)}?fields=["full_name"]`,{method:"GET",headers:yield this.getHeaders(),credentials:"include"});return n.ok&&((a=(yield n.json()).data)==null?void 0:a.full_name)||""}catch(n){return""}})}}const kc=new JF,QF=(e={})=>{const[r,a]=E.useState([]),[n,i]=E.useState(!0),[c,u]=E.useState(null),[g,y]=E.useState(0),x=E.useCallback(()=>xe(null,null,function*(){try{i(!0),u(null);const k=yield kc.getMaintenanceTeams(e);a(k.data);const N=yield kc.getMaintenanceTeamCount(e.filters);y(N)}catch(k){u(k instanceof Error?k.message:"Failed to fetch maintenance teams")}finally{i(!1)}}),[JSON.stringify(e)]);return E.useEffect(()=>{x()},[x]),{teams:r,loading:n,error:c,totalCount:g,refetch:x}},eB=e=>{const[r,a]=E.useState(null),[n,i]=E.useState(!1),[c,u]=E.useState(null),g=E.useCallback(()=>xe(null,null,function*(){if(!e){a(null);return}try{i(!0),u(null);const y=yield kc.getMaintenanceTeam(e);a(y)}catch(y){u(y instanceof Error?y.message:"Failed to fetch maintenance team details")}finally{i(!1)}}),[e]);return E.useEffect(()=>{g()},[g]),{team:r,loading:n,error:c,refetch:g}},tB=()=>{const[e,r]=E.useState(!1),[a,n]=E.useState(null);return{createTeam:y=>xe(null,null,function*(){try{return r(!0),n(null),yield kc.createMaintenanceTeam(y)}catch(x){const k=x instanceof Error?x.message:"Failed to create maintenance team";throw n(k),x}finally{r(!1)}}),updateTeam:(y,x)=>xe(null,null,function*(){try{return r(!0),n(null),yield kc.updateMaintenanceTeam(y,x)}catch(k){const N=k instanceof Error?k.message:"Failed to update maintenance team";throw n(N),k}finally{r(!1)}}),deleteTeam:y=>xe(null,null,function*(){try{r(!0),n(null),yield kc.deleteMaintenanceTeam(y)}catch(x){const k=x instanceof Error?x.message:"Failed to delete maintenance team";throw n(k),x}finally{r(!1)}}),getUserFullName:y=>xe(null,null,function*(){return yield kc.getUserFullName(y)}),loading:e,error:a}},rB=({isOpen:e,onClose:r,selectedCount:a,totalCount:n,pageCount:i,onExport:c,isExporting:u,exportColumns:g})=>{const[y,x]=E.useState(a>0?"selected":"all_with_filters"),[k,N]=E.useState("csv"),[C,O]=E.useState(g.filter(z=>z.default).map(z=>z.key));E.useEffect(()=>{x(a>0?"selected":"all_with_filters")},[a]);const D=z=>O(U=>U.includes(z)?U.filter(B=>B!==z):[...U,z]),A=()=>O(g.map(z=>z.key)),I=()=>O(g.filter(z=>z.default).map(z=>z.key));return e?t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[70] p-4",children:t.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:[t.jsx("div",{className:"bg-gradient-to-r from-green-500 to-green-600 px-6 py-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(cs,{className:"text-white text-xl"}),t.jsx("h3",{className:"text-lg font-semibold text-white",children:"Export Maintenance Teams"})]}),t.jsx("button",{onClick:r,className:"text-white/80 hover:text-white transition-colors",disabled:u,children:t.jsx(qt,{size:20})})]})}),t.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-180px)]",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"Select Data to Export"}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${y==="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"} ${a===0?"opacity-50 cursor-not-allowed":""}`,children:[t.jsx("input",{type:"radio",name:"scope",value:"selected",checked:y==="selected",onChange:()=>x("selected"),disabled:a===0,className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Selected Rows"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export ",a," selected team",a!==1?"s":""]})]}),a>0&&t.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:[a," selected"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${y==="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:[t.jsx("input",{type:"radio",name:"scope",value:"all_on_page",checked:y==="all_on_page",onChange:()=>x("all_on_page"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Current Page"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export ",i," team",i!==1?"s":""," on current page"]})]}),t.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"]})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${y==="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:[t.jsx("input",{type:"radio",name:"scope",value:"all_with_filters",checked:y==="all_with_filters",onChange:()=>x("all_with_filters"),className:"text-green-600 focus:ring-green-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"All Records (with current filters)"}),t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Export all ",n," team",n!==1?"s":""," matching current filters"]})]}),t.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:[n," total"]})]})]})]}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"Export Format"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${k==="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:[t.jsx("input",{type:"radio",name:"format",value:"csv",checked:k==="csv",onChange:()=>N("csv"),className:"text-green-600 focus:ring-green-500"}),t.jsx(Kd,{className:"text-green-600 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"CSV"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Comma-separated values"})]})]}),t.jsxs("label",{className:`flex-1 flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${k==="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:[t.jsx("input",{type:"radio",name:"format",value:"excel",checked:k==="excel",onChange:()=>N("excel"),className:"text-green-600 focus:ring-green-500"}),t.jsx(cl,{className:"text-green-700 text-xl"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:"Excel"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"XLSX spreadsheet"})]})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"Columns to Export"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:A,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Select All"}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:I,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline",children:"Reset to Default"})]})]}),t.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:g.map(z=>t.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer transition-all ${C.includes(z.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:[t.jsx("input",{type:"checkbox",checked:C.includes(z.key),onChange:()=>D(z.key),className:"rounded text-green-600 focus:ring-green-500"}),t.jsx("span",{className:"text-sm truncate",children:z.label})]},z.key))}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:[C.length," column",C.length!==1?"s":""," selected"]})]})]}),t.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:[t.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[y==="selected"&&`Exporting ${a} selected row${a!==1?"s":""}`,y==="all_on_page"&&`Exporting ${i} row${i!==1?"s":""} from current page`,y==="all_with_filters"&&`Exporting all ${n} row${n!==1?"s":""}`]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:r,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:u,children:"Cancel"}),t.jsx("button",{onClick:()=>c(y,k,C),disabled:C.length===0||u,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:u?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"Exporting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Co,{}),"Export"]})})]})]})]})}):null},aB=()=>{const{t:e}=oa(),r=ua(),a=[{key:"name",label:e("maintenance.teamId"),default:!0},{key:"maintenance_team_name",label:e("maintenance.teamName"),default:!0},{key:"maintenance_manager",label:e("maintenance.managerEmail"),default:!0},{key:"maintenance_manager_name",label:e("maintenance.managerName"),default:!0},{key:"company",label:e("commonFields.hospital"),default:!0},{key:"custom_expertise",label:e("maintenance.expertise"),default:!0},{key:"creation",label:e("commonFields.createdOn"),default:!1},{key:"modified",label:e("commonFields.modifiedOn"),default:!1}],{sortBy:n,dateFilterBy:i,dateStart:c,dateEnd:u,page:g,setSortBy:y,setDateFilterBy:x,setDateStart:k,setDateEnd:N,setPage:C,resetPage:O}=pm("creation desc"),D=20,[A,I]=E.useState(!1),[z,U]=E.useState(new Set),[B,V]=E.useState(!1),[Z,W]=E.useState(!1),[H,le]=E.useState(null),[Q,Ne]=E.useState(""),[oe,se]=E.useState(""),[ce,Ce]=E.useState(!1),[ae,me]=E.useState(0),[K,fe]=E.useState([]),[Oe,ye]=E.useState(!1),[J,G]=E.useState("");E.useEffect(()=>{const Pt=localStorage.getItem("maintenanceTeamFilterPresets");Pt&&fe(JSON.parse(Pt))},[]),E.useEffect(()=>{const Pt=[Q,oe].filter(Boolean).length;me(Pt)},[Q,oe]);const ie=E.useMemo(()=>xm(_e(_e({},Q?{company:Q}:{}),oe?{name:oe}:{}),i,c,u),[Q,oe,i,c,u]),{teams:re,loading:ne,error:ve,totalCount:Ve,refetch:Ae}=QF({filters:ie,limit_start:g*D,limit_page_length:D,order_by:n});E.useEffect(()=>{!ne&&!A&&I(!0)},[ne,A]),E.useEffect(()=>{O()},[Q,oe,n,i,c,u]),E.useEffect(()=>{U(new Set)},[Q,oe,g]);const ze=(g+1)*D<Ve,Re=Pt=>Pt?new Date(Pt).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",Ze=()=>{Ne(""),se(""),O()},Lt=Q||oe,mt=()=>{if(!J.trim()){alert("Please enter a filter name");return}const Pt={id:Date.now(),name:J,filters:{companyFilter:Q,teamNameFilter:oe}},it=[...K,Pt];fe(it),G(""),ye(!1),localStorage.setItem("maintenanceTeamFilterPresets",JSON.stringify(it))},Zt=Pt=>{const it=Pt.filters;Ne(it.companyFilter||""),se(it.teamNameFilter||"")},ar=Pt=>{const it=K.filter(De=>De.id!==Pt);fe(it),localStorage.setItem("maintenanceTeamFilterPresets",JSON.stringify(it))},or=Pt=>{U(it=>{const De=new Set(it);return De.has(Pt)?De.delete(Pt):De.add(Pt),De})},yt=()=>{z.size===re.length?U(new Set):U(new Set(re.map(Pt=>Pt.name)))},nr=re.length>0&&z.size===re.length,$t=z.size>0&&z.size<re.length,Er=E.useCallback(()=>xe(null,null,function*(){const Pt=[];let it=0;const De=100;let Je=!0;for(;Je;)try{const jt=(yield(yield fetch("/api/method/frappe.client.get_list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({doctype:"Asset Maintenance Team",filters:ie,fields:["*"],limit_start:it*De,limit_page_length:De,order_by:n})})).json()).message||[];Pt.push(...jt),jt.length<De?Je=!1:it++,it>100&&(console.warn("Export safety limit reached"),Je=!1)}catch(Be){throw console.error("Error fetching teams for export:",Be),Be}return Pt}),[ie]),St=(Pt,it,De)=>xe(null,null,function*(){W(!0);try{let Je=[];switch(Pt){case"selected":Je=re.filter(vt=>z.has(vt.name));break;case"all_on_page":Je=re;break;case"all_with_filters":Je=yield Er();break}if(Je.length===0){alert("No data to export");return}const Be=De.map(vt=>{var jt;return((jt=a.find(Ct=>Ct.key===vt))==null?void 0:jt.label)||vt});if(it==="csv"){const vt=[Be.join(","),...Je.map(pr=>De.map(Ge=>{let We=pr[Ge]||"";return typeof We=="string"&&(We.includes(",")||We.includes('"')||We.includes(`
|
||
`))&&(We=`"${We.replace(/"/g,'""')}"`),We}).join(","))].join(`
|
||
`),jt=new Blob(["\uFEFF"+vt],{type:"text/csv;charset=utf-8;"}),Ct=URL.createObjectURL(jt),Wt=document.createElement("a");Wt.href=Ct,Wt.download=`maintenance_teams_export_${new Date().toISOString().split("T")[0]}.csv`,Wt.click(),URL.revokeObjectURL(Ct)}else if(it==="excel"){const vt=[Be,...Je.map(Wt=>De.map(pr=>Wt[pr]||""))],jt=Wa.aoa_to_sheet(vt),Ct=Wa.book_new();Wa.book_append_sheet(Ct,jt,"Maintenance Teams"),ul(Ct,`maintenance_teams_export_${new Date().toISOString().split("T")[0]}.xlsx`)}V(!1),U(new Set)}catch(Je){console.error("Export failed:",Je),alert(`Export failed: ${Je instanceof Error?Je.message:"Unknown error"}`)}finally{W(!1)}}),Br=Pt=>xe(null,null,function*(){try{if(!(yield fetch(`/api/resource/Asset Maintenance Team/${encodeURIComponent(Pt)}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to delete");le(null),Ae(),alert("Maintenance Team deleted successfully!")}catch(it){alert(`Failed to delete: ${it instanceof Error?it.message:"Unknown error"}`)}});return ne&&!A?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading maintenance teams..."})]})}):ve?t.jsx("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:"Error Loading Maintenance Teams"}),t.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:ve}),t.jsx("button",{onClick:Ae,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded",children:"Try Again"})]})}):t.jsxs("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:[t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center",children:[t.jsx("div",{children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Pd,{className:"text-3xl text-indigo-600 dark:text-indigo-400"}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white",children:"Maintenance Teams"}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Total: ",Ve," team",Ve!==1?"s":"",z.size>0&&t.jsxs("span",{className:"ml-2 text-blue-600 dark:text-blue-400",children:["• ",z.size," selected"]}),ne&&A&&t.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[t.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-blue-500"}),"Updating..."]})]})]})]})}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("button",{onClick:()=>Ce(!ce),className:`px-4 py-2 rounded-lg flex items-center gap-2 transition-colors ${ce||Lt?"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:[t.jsx(Ri,{}),"Filters",ae>0&&t.jsx("span",{className:"bg-blue-600 text-white text-xs px-1.5 py-0.5 rounded-full",children:ae})]}),t.jsxs("button",{onClick:Ae,disabled:ne,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:[t.jsx(Eo,{className:ne?"animate-spin":""}),"Refresh"]}),t.jsxs("button",{onClick:()=>V(!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:Ve===0,children:[t.jsx(cs,{}),t.jsx("span",{className:"font-medium",children:"Export"}),z.size>0&&t.jsx("span",{className:"bg-white/20 px-1.5 py-0.5 rounded text-xs",children:z.size})]}),t.jsxs("button",{onClick:()=>r("/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:[t.jsx(Mi,{}),t.jsx("span",{className:"font-medium",children:"New Team"})]})]})]}),ce&&t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 mb-4",children:[t.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:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Ri,{className:"text-white",size:16}),t.jsx("h3",{className:"text-white font-semibold text-sm",children:"Filters"}),ae>0&&t.jsx("span",{className:"bg-white text-indigo-600 px-2 py-0.5 rounded-full text-xs font-bold",children:ae})]}),Lt&&t.jsx("div",{className:"flex-1 overflow-x-auto scrollbar-hide mx-2",children:t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[Q&&t.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:[t.jsx("span",{className:"font-semibold",children:"Hospital:"})," ",Q,t.jsx("button",{onClick:()=>Ne(""),className:"hover:text-red-500",children:t.jsx(qt,{className:"text-[9px]"})})]}),oe&&t.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:[t.jsx("span",{className:"font-semibold",children:"Team:"})," ",oe,t.jsx("button",{onClick:()=>se(""),className:"hover:text-red-500",children:t.jsx(qt,{className:"text-[9px]"})})]})]})}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[ae>0&&t.jsxs("button",{onClick:()=>ye(!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:[t.jsx(Fn,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),Lt&&t.jsxs("button",{onClick:Ze,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:[t.jsx(qt,{size:12}),t.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]})]})}),t.jsxs("div",{className:"p-4",children:[K.length>0&&t.jsxs("div",{className:"mb-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[t.jsx(Zl,{className:"text-yellow-500",size:12}),"Saved Filters"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:K.map(Pt=>t.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:[t.jsx("button",{onClick:()=>Zt(Pt),className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:Pt.name}),t.jsx("button",{onClick:()=>ar(Pt.id),className:"opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 transition-opacity",children:t.jsx(ma,{size:10})})]},Pt.id))})]}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 p-3 rounded-lg",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[t.jsx(Bu,{sortBy:n,dateFilterBy:i,dateStart:c,dateEnd:u,onSortByChange:y,onDateFilterByChange:x,onDateStartChange:k,onDateEndChange:N}),t.jsxs("div",{className:"relative z-[60]",children:[t.jsx(er,{label:"Hospital",doctype:"Company",value:Q,onChange:Pt=>{Ne(Pt),O()},placeholder:"Select Hospital",disabled:!1,compact:!0}),Q&&t.jsx("button",{onClick:()=>Ne(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]}),t.jsxs("div",{className:"relative z-[59]",children:[t.jsx(er,{label:e("maintenance.teamName"),doctype:"Asset Maintenance Team",value:oe,onChange:Pt=>{se(Pt),O()},placeholder:e("maintenance.selectTeam"),disabled:!1,compact:!0}),oe&&t.jsx("button",{onClick:()=>se(""),className:"absolute right-2 top-6 text-gray-400 hover:text-red-500 transition-colors z-10",children:t.jsx(qt,{size:10})})]})]})})]})]}),Oe&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6 animate-scale-in",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:e("listPages.saveFilterPreset")}),t.jsx("input",{type:"text",value:J,onChange:Pt=>G(Pt.target.value),onKeyDown:Pt=>{Pt.key==="Enter"&&(Pt.preventDefault(),mt())},placeholder:e("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}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{ye(!1),G("")},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:e("common.cancel")}),t.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:[t.jsx(Fn,{size:12}),e("listPages.saveFilter")]})]})]})}),t.jsx(rB,{isOpen:B,onClose:()=>V(!1),selectedCount:z.size,totalCount:Ve,pageCount:re.length,onExport:St,isExporting:Z,exportColumns:a}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700 overflow-hidden relative",children:[ne&&A&&t.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:t.jsxs("div",{className:"flex items-center gap-3 bg-white dark:bg-gray-700 px-4 py-2 rounded-lg shadow-lg",children:[t.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-indigo-500"}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:e("listPages.filtering")})]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-100 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left",children:t.jsx("button",{onClick:yt,className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors",title:e(nr?"listPages.deselectAllTitle":"listPages.selectAllTitle"),children:nr?t.jsx(qs,{className:"text-indigo-600 dark:text-indigo-400",size:18}):$t?t.jsxs("div",{className:"relative",children:[t.jsx(Pn,{size:18}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-2 h-0.5 bg-current"})})]}):t.jsx(Pn,{size:18})})}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("maintenance.teamName")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("maintenance.managerName")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.hospital")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("maintenance.expertise")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("commonFields.createdOn")}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:e("listPages.actions")})]})}),t.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:re.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"px-4 py-12 text-center text-gray-500 dark:text-gray-400",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(Pd,{className:"text-4xl text-gray-300 dark:text-gray-600 mb-2"}),t.jsx("p",{children:e("listPages.noMaintenanceTeamsFound")}),Lt?t.jsx("button",{onClick:Ze,className:"mt-4 text-indigo-600 dark:text-indigo-400 hover:underline",children:e("listPages.clearFilters")}):t.jsx("button",{onClick:()=>r("/maintenance-teams/new"),className:"mt-4 text-indigo-600 dark:text-indigo-400 hover:underline",children:e("listPages.createFirstTeam")})]})})}):re.map(Pt=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 cursor-pointer transition-colors ${z.has(Pt.name)?"bg-indigo-50 dark:bg-indigo-900/20":""}`,onClick:()=>r(`/maintenance-teams/${Pt.name}`),children:[t.jsx("td",{className:"px-4 py-3",onClick:it=>it.stopPropagation(),children:t.jsx("button",{onClick:()=>or(Pt.name),className:"text-gray-500 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors",children:z.has(Pt.name)?t.jsx(qs,{className:"text-indigo-600 dark:text-indigo-400",size:18}):t.jsx(Pn,{size:18})})}),t.jsxs("td",{className:"px-4 py-3",children:[t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:Pt.maintenance_team_name}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:Pt.name})]}),t.jsxs("td",{className:"px-4 py-3",children:[t.jsx("div",{className:"text-sm text-gray-900 dark:text-white",children:Pt.maintenance_manager_name||"-"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:Pt.maintenance_manager||"-"})]}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:Pt.company||"-"})}),t.jsx("td",{className:"px-4 py-3",children:Pt.custom_expertise?t.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:Pt.custom_expertise}):t.jsx("span",{className:"text-gray-400",children:"-"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:Re(Pt.creation)})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-1",onClick:it=>it.stopPropagation(),children:[t.jsx("button",{onClick:()=>r(`/maintenance-teams/${Pt.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:e("maintenance.viewDetails"),children:t.jsx(to,{})}),t.jsx("button",{onClick:()=>r(`/maintenance-teams/${Pt.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:e("maintenance.editTeam"),children:t.jsx(Yn,{})}),t.jsx("button",{onClick:()=>r(`/maintenance-teams/new?duplicate=${Pt.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:e("maintenance.duplicateTeam"),children:t.jsx(Zd,{})}),t.jsx("button",{onClick:()=>le(Pt.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:e("maintenance.deleteTeam"),children:t.jsx(ma,{})})]})})]},Pt.name))})]})}),t.jsx(Fu,{currentPage:g+1,totalCount:Ve,pageSize:D,hasMore:ze,itemLabel:e("pagination.maintenanceTeams"),onPageChange:Pt=>C(Math.max(0,Pt-1))})]}),H&&t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-2xl",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.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:t.jsx(ma,{className:"text-red-600 dark:text-red-400 text-xl"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"Delete Maintenance Team"}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:"Are you sure you want to delete this maintenance team? This action cannot be undone."}),t.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:t.jsxs("p",{className:"text-xs text-yellow-800 dark:text-yellow-300",children:[t.jsx("strong",{children:"Team:"})," ",H]})}),t.jsxs("div",{className:"flex gap-3 justify-end",children:[t.jsx("button",{onClick:()=>le(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:"Cancel"}),t.jsxs("button",{onClick:()=>Br(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",children:[t.jsx(ma,{}),"Delete Team"]})]})]})]})})}),t.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; }
|
||
`})]})},nB=()=>{var Oe;const{t:e}=oa(),{teamName:r}=Yl(),[a]=Li(),n=ua(),i=r==="new",c=a.get("duplicate"),[u,g]=E.useState({maintenance_team_name:"",maintenance_manager:"",maintenance_manager_name:"",company:"",custom_expertise:"",maintenance_team_members:[]}),{team:y,loading:x,error:k,refetch:N}=eB(i?c||null:r||null),{createTeam:C,updateTeam:O,deleteTeam:D,getUserFullName:A,loading:I}=tB(),[z,U]=E.useState(i),[B,V]=E.useState(!1);Kl(g,{enabled:i&&!c,fields:["company"]});const[Z,W]=E.useState(null),[H,le]=E.useState(null),Q=ye=>xe(null,null,function*(){if(!ye)return{exists:!1};try{const J=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(!J.ok)return yield Ne(ye);const ie=(yield J.json()).message||[];for(const re of ie)if(!(re.name===r||re.name===(y==null?void 0:y.name))&&re["maintenance_team_members.team_member"]===ye)return{exists:!0,teamName:re.maintenance_team_name||re.name};return yield Ne(ye)}catch(J){return console.error("Error checking member in other teams:",J),yield Ne(ye)}}),Ne=ye=>xe(null,null,function*(){var J,G;try{const ie=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(!ie.ok)return{exists:!1};const ne=(yield ie.json()).data||[];for(const ve of ne){if(ve.name===r||ve.name===(y==null?void 0:y.name))continue;const Ve=yield fetch(`/api/resource/Asset Maintenance Team/${encodeURIComponent(ve.name)}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!Ve.ok)continue;const Ae=yield Ve.json();if((((J=Ae.data)==null?void 0:J.maintenance_team_members)||[]).some(Ze=>Ze.team_member===ye))return{exists:!0,teamName:((G=Ae.data)==null?void 0:G.maintenance_team_name)||ve.name}}return{exists:!1}}catch(ie){return console.error("Fallback check failed:",ie),{exists:!1}}});E.useEffect(()=>{var ye;y&&(g({maintenance_team_name:i&&c?`${y.maintenance_team_name} (Copy)`:y.maintenance_team_name||"",maintenance_manager:y.maintenance_manager||"",maintenance_manager_name:y.maintenance_manager_name||"",company:y.company||"",custom_expertise:y.custom_expertise||"",maintenance_team_members:((ye=y.maintenance_team_members)==null?void 0:ye.map((J,G)=>$e(_e({},J),{idx:G+1,name:i?void 0:J.name})))||[]}),i||U(!1))},[y,i,c]);const oe=ye=>{const{name:J,value:G}=ye.target;g(ie=>$e(_e({},ie),{[J]:G}))},se=ye=>xe(null,null,function*(){if(g(J=>$e(_e({},J),{maintenance_manager:ye})),ye){const J=yield A(ye);g(G=>$e(_e({},G),{maintenance_manager_name:J}))}else g(J=>$e(_e({},J),{maintenance_manager_name:""}))}),ce=(ye,J,G)=>xe(null,null,function*(){var ie;if(J==="team_member"&&G){if((ie=u.maintenance_team_members)==null?void 0:ie.some((ze,Re)=>Re!==ye&&ze.team_member===G)){dr.error("This member is already added to this team!",{position:"top-right",autoClose:4e3,icon:t.jsx(jn,{})});return}le(ye),dr.info("Checking member availability...",{position:"top-right",autoClose:2e3,icon:()=>t.jsx("span",{children:"🔍"})});const{exists:ne,teamName:ve}=yield Q(G);if(le(null),ne){dr.error(t.jsxs("div",{children:[t.jsx("strong",{children:"Cannot add member!"}),t.jsx("br",{}),t.jsxs("span",{className:"text-sm",children:["This member is already assigned to: ",t.jsx("b",{children:ve})]})]}),{position:"top-right",autoClose:5e3,icon:t.jsx(jn,{})});return}const Ve=yield A(G),Ae=[...u.maintenance_team_members||[]];Ae[ye]=$e(_e({},Ae[ye]),{team_member:G,full_name:Ve}),g(ze=>$e(_e({},ze),{maintenance_team_members:Ae})),dr.success("Member added successfully!",{position:"top-right",autoClose:2e3,icon:t.jsx(Ca,{})})}else{const re=[...u.maintenance_team_members||[]];re[ye]=$e(_e({},re[ye]),{[J]:G}),g(ne=>$e(_e({},ne),{maintenance_team_members:re}))}}),Ce=()=>{var J;const ye={team_member:"",full_name:"",maintenance_role:"",idx:(((J=u.maintenance_team_members)==null?void 0:J.length)||0)+1};g(G=>$e(_e({},G),{maintenance_team_members:[...G.maintenance_team_members||[],ye]}))},ae=ye=>{var G;const J=((G=u.maintenance_team_members)==null?void 0:G.filter((ie,re)=>re!==ye))||[];J.forEach((ie,re)=>{ie.idx=re+1}),g(ie=>$e(_e({},ie),{maintenance_team_members:J})),W(null)},me=()=>xe(null,null,function*(){var ye;if(!u.maintenance_team_name){dr.error("Please enter a team name",{position:"top-right",autoClose:4e3,icon:t.jsx(jn,{})});return}try{const J=$e(_e({},u),{maintenance_team_members:(ye=u.maintenance_team_members)==null?void 0:ye.map(G=>({team_member:G.team_member,full_name:G.full_name,maintenance_role:G.maintenance_role})).filter(G=>G.team_member)});if(i){const G=yield C(J);dr.success("Maintenance Team created successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Ca,{})}),n(`/maintenance-teams/${G.name}`)}else yield O(r,J),dr.success("Maintenance Team updated successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Ca,{})}),U(!1),N()}catch(J){const G=J instanceof Error?J.message:"Unknown error";dr.error(`Failed to save: ${G}`,{position:"top-right",autoClose:6e3,icon:t.jsx(jn,{})})}}),K=()=>xe(null,null,function*(){try{yield D(r),dr.success("Maintenance Team deleted successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Ca,{})}),n("/maintenance-teams")}catch(ye){const J=ye instanceof Error?ye.message:"Unknown error";dr.error(`Failed to delete: ${J}`,{position:"top-right",autoClose:6e3,icon:t.jsx(jn,{})})}}),fe=E.useCallback(ye=>!z,[z]);return x?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-500 mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading maintenance team..."})]})}):k&&!i?t.jsx("div",{className:"p-4 sm:p-6 bg-gray-50 dark:bg-gray-900 min-h-screen min-w-0 overflow-x-hidden",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsx("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:e("maintenance.errorLoadingTeam")}),t.jsx("p",{className:"text-red-700 dark:text-red-400 mb-4",children:k}),t.jsx("button",{onClick:()=>n("/maintenance-teams"),className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded",children:e("maintenance.backToTeams")})]})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-4 sm:p-6 min-w-0 overflow-x-hidden",children:[t.jsx(wm,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Hu}),t.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between lg:items-center flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("button",{onClick:()=>n("/maintenance-teams"),className:"text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200",children:t.jsx(bi,{size:20})}),t.jsxs("div",{children:[t.jsxs("h1",{className:"text-2xl font-bold text-gray-800 dark:text-white flex items-center gap-3",children:[t.jsx(Pd,{className:"text-indigo-500"}),i?"New Maintenance Team":(y==null?void 0:y.maintenance_team_name)||"Maintenance Team"]}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:i?"Create a new maintenance team":y==null?void 0:y.name})]})]}),t.jsxs("div",{className:"flex gap-3",children:[!i&&!z&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>U(!0),className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(Yn,{}),e("common.edit")]}),t.jsxs("button",{onClick:()=>V(!0),className:"bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-lg flex items-center gap-2",children:[t.jsx(ma,{}),e("common.delete")]})]}),z&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{i?n("/maintenance-teams"):(U(!1),N())},className:"bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg",children:e("common.cancel")}),t.jsxs("button",{onClick:me,disabled:I,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:[t.jsx(Fn,{}),e(I?"common.saving":"common.save")]})]})]})]}),B&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 shadow-xl",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[t.jsx(an,{className:"text-red-500 text-xl mt-0.5"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:e("maintenance.deleteTeam")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:e("confirmations.cannotUndo")})]})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>V(!1),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:e("common.cancel")}),t.jsx("button",{onClick:K,disabled:I,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg disabled:opacity-50",children:e(I?"common.deleting":"common.delete")})]})]})}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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:[t.jsx(Pd,{className:"text-indigo-500"}),e("maintenance.teamInformation")]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"md:col-span-2",children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[e("maintenance.teamName")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",name:"maintenance_team_name",value:u.maintenance_team_name,onChange:oe,disabled:fe("maintenance_team_name"),placeholder:e("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"})]}),t.jsx("div",{children:t.jsx(er,{label:e("commonFields.hospital"),doctype:"Company",value:u.company||"",onChange:ye=>g($e(_e({},u),{company:ye})),disabled:fe("company"),placeholder:e("maintenance.selectHospital")})}),t.jsx("div",{children:t.jsx(er,{label:e("maintenance.expertise"),doctype:"Issue Type",value:u.custom_expertise||"",onChange:ye=>g($e(_e({},u),{custom_expertise:ye})),disabled:fe("custom_expertise"),placeholder:e("maintenance.selectExpertise")})}),t.jsx("div",{children:t.jsx(er,{label:e("maintenance.manager"),doctype:"User",value:u.maintenance_manager||"",onChange:se,disabled:fe("maintenance_manager"),placeholder:e("maintenance.selectManager")})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e("maintenance.managerName")}),t.jsx("input",{type:"text",value:u.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"})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white flex items-center gap-2",children:[t.jsx(yC,{className:"text-green-500"}),"Team Members"]}),z&&t.jsxs("button",{onClick:Ce,disabled:H!==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:[t.jsx(Mi,{size:12}),"Add Member"]})]}),u.maintenance_team_members&&u.maintenance_team_members.length>0?t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"#"}),t.jsxs("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:["Team Member",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"Full Name"}),t.jsxs("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:["Role",t.jsx("span",{className:"text-red-500",children:"*"})]}),z&&t.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"Action"})]})}),t.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:u.maintenance_team_members.map((ye,J)=>t.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700/50 ${H===J?"opacity-70":""}`,children:[t.jsx("td",{className:"px-3 py-2 text-sm text-gray-600 dark:text-gray-400",children:J+1}),t.jsx("td",{className:"px-3 py-2",children:z?t.jsxs("div",{className:"relative",children:[t.jsx(er,{label:"",doctype:"User",value:ye.team_member||"",onChange:G=>ce(J,"team_member",G),disabled:H!==null,placeholder:e("maintenance.selectUser"),compact:!0}),H===J&&t.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2",children:t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-indigo-500"})})]}):t.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:ye.team_member||"-"})}),t.jsx("td",{className:"px-3 py-2 text-sm text-gray-600 dark:text-gray-300",children:ye.full_name||"-"}),t.jsx("td",{className:"px-3 py-2",children:z?t.jsx(er,{label:"",doctype:"Role",value:ye.maintenance_role||"",onChange:G=>ce(J,"maintenance_role",G),disabled:H!==null,placeholder:e("maintenance.selectRole"),compact:!0}):t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:ye.maintenance_role||"-"})}),z&&t.jsx("td",{className:"px-3 py-2 text-center",children:t.jsx("button",{onClick:()=>W(J),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:e("maintenance.removeMember"),children:t.jsx(ma,{size:14})})})]},J))})]})}):t.jsxs("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:[t.jsx(Pd,{className:"text-4xl mx-auto mb-2 text-gray-300 dark:text-gray-600"}),t.jsx("p",{children:e("maintenance.noTeamMembersYet")}),z&&t.jsxs("button",{onClick:Ce,className:"mt-3 text-indigo-600 dark:text-indigo-400 hover:underline",children:["+ ",e("maintenance.addFirstMember")]})]})]})]}),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md p-6 border border-gray-200 dark:border-gray-700",children:[t.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:[t.jsx(vC,{className:"text-blue-500"}),e("maintenance.teamSummary")]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"p-4 bg-indigo-50 dark:bg-indigo-900/30 rounded-lg border border-indigo-200 dark:border-indigo-800",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("maintenance.totalMembers")}),t.jsx("p",{className:"text-2xl font-bold text-indigo-600 dark:text-indigo-300",children:((Oe=u.maintenance_team_members)==null?void 0:Oe.filter(ye=>ye.team_member).length)||0})]}),u.maintenance_manager_name&&t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:e("maintenance.manager")}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:u.maintenance_manager_name})]}),u.company&&t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Hospital"}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:u.company})]}),u.custom_expertise&&t.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Expertise"}),t.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:u.custom_expertise})]})]})]}),!i&&(y==null?void 0:y.name)&&t.jsxs("div",{className:"space-y-6",children:[t.jsx(Vu,{referenceDoctype:"Asset Maintenance Team",referenceName:y.name,title:"Comments & Discussion",pollInterval:3e4,initialLimit:5}),t.jsx(Wu,{doctype:"Asset Maintenance Team",docname:y.name,creationDate:y.creation,createdBy:y.owner,initialVisible:5,startCollapsed:!0})]})]})]}),Z!==null&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-sm w-full mx-4 shadow-xl",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[t.jsx(an,{className:"text-orange-500 text-xl mt-0.5"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:"Remove Team Member"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Are you sure you want to remove this team member?"})]})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>W(null),className:"px-4 py-2 bg-gray-300 hover:bg-gray-400 text-gray-700 rounded-lg",children:"Cancel"}),t.jsx("button",{onClick:()=>ae(Z),className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg",children:"Remove"})]})]})})]})},sB=()=>{const e=ua(),[r,a]=E.useState(!0),[n,i]=E.useState(!1),[c,u]=E.useState(!1),[g,y]=E.useState(!1),[x,k]=E.useState(null),[N,C]=E.useState(null),[O,D]=E.useState({first_name:"",middle_name:"",last_name:"",role_profile_name:"",custom_user_id:""}),[A,I]=E.useState(!1),[z,U]=E.useState({old_password:"",new_password:"",confirm_password:""}),[B,V]=E.useState(!1),[Z,W]=E.useState(!1),[H,le]=E.useState(!1);E.useEffect(()=>{xe(null,null,function*(){var Ce;try{a(!0);const ae=yield _t.getCSRFToken(),me={"Content-Type":"application/json",Accept:"application/json"};ae&&(me["X-Frappe-CSRF-Token"]=ae);const Oe=((Ce=(yield(yield fetch("/api/method/asset_lite.api.user_roles.check_has_role",{method:"POST",headers:me,credentials:"include",body:JSON.stringify({roles:"System Manager"})})).json()).message)==null?void 0:Ce.has_role)||!1;u(Oe),console.log("Is System Manager:",Oe);const ye=yield Kf();console.log("Full profile data:",JSON.stringify(ye,null,2)),console.log("role_profile_name:",ye.role_profile_name),console.log("All keys:",Object.keys(ye)),k(ye),D({first_name:ye.first_name||"",middle_name:ye.middle_name||"",last_name:ye.last_name||"",role_profile_name:ye.role_profile_name||"",custom_user_id:ye.custom_user_id||""}),console.log("FormData role_profile_name:",ye.role_profile_name||"")}catch(ae){const me=ae instanceof Error?ae.message:"Failed to load profile";C(me),dr.error(me,{position:"top-right",autoClose:5e3,icon:t.jsx(jn,{})})}finally{a(!1)}})},[]);const Q=ce=>{const{name:Ce,value:ae}=ce.target;D(me=>$e(_e({},me),{[Ce]:ae}))},Ne=ce=>{const{name:Ce,value:ae}=ce.target;U(me=>$e(_e({},me),{[Ce]:ae}))},oe=()=>xe(null,null,function*(){if(x!=null&&x.email)try{i(!0);const ce={first_name:O.first_name,middle_name:O.middle_name,last_name:O.last_name};c&&(ce.role_profile_name=O.role_profile_name);const Ce=yield C8(x.email,ce);k(ae=>ae?_e(_e({},ae),Ce):Ce),dr.success("Profile updated successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Ca,{})})}catch(ce){const Ce=ce instanceof Error?ce.message:"Failed to update profile";dr.error(Ce,{position:"top-right",autoClose:5e3,icon:t.jsx(jn,{})})}finally{i(!1)}}),se=()=>xe(null,null,function*(){if(!z.old_password){dr.error("Please enter your current password",{position:"top-right",autoClose:3e3,icon:t.jsx(an,{})});return}if(!z.new_password){dr.error("Please enter a new password",{position:"top-right",autoClose:3e3,icon:t.jsx(an,{})});return}if(z.new_password.length<8){dr.error("Password must be at least 8 characters long",{position:"top-right",autoClose:3e3,icon:t.jsx(an,{})});return}if(z.new_password!==z.confirm_password){dr.error("New passwords do not match",{position:"top-right",autoClose:3e3,icon:t.jsx(an,{})});return}try{y(!0),yield E8(z.new_password,z.old_password),dr.success("Password changed successfully!",{position:"top-right",autoClose:3e3,icon:t.jsx(Ca,{})}),U({old_password:"",new_password:"",confirm_password:""}),I(!1)}catch(ce){const Ce=ce instanceof Error?ce.message:"Failed to change password";dr.error(Ce,{position:"top-right",autoClose:5e3,icon:t.jsx(jn,{})})}finally{y(!1)}});return r?t.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"text-center",children:[t.jsx(Ja,{className:"animate-spin text-blue-500 text-4xl mx-auto"}),t.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading profile..."})]})}):N&&!x?t.jsx("div",{className:"p-6 bg-gray-50 dark:bg-gray-900 min-h-screen",children:t.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-6",children:[t.jsxs("h2",{className:"text-xl font-bold text-red-800 dark:text-red-300 mb-4",children:[t.jsx(jn,{className:"inline mr-2"}),"Error Loading Profile"]}),t.jsx("p",{className:"text-red-700 dark:text-red-400",children:N}),t.jsx("button",{onClick:()=>e(-1),className:"mt-4 bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded",children:"Go Back"})]})}):t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 p-6",children:[t.jsx(wm,{position:"top-right",autoClose:4e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"colored",transition:Hu}),t.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[t.jsx("div",{className:"flex items-center gap-4",children:t.jsxs("button",{onClick:()=>e(-1),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 flex items-center gap-2",children:[t.jsx(bi,{}),t.jsx("span",{className:"text-gray-900 dark:text-white text-xl font-semibold",children:"User Profile"})]})}),t.jsx("button",{onClick:oe,disabled:n,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:n?t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"animate-spin"}),"Saving..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Fn,{}),"Save Changes"]})})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[t.jsx("div",{className:"lg:col-span-1",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 overflow-hidden",children:[t.jsxs("div",{className:"bg-gradient-to-r from-blue-500 to-blue-600 p-6 text-center",children:[t.jsx("div",{className:"w-24 h-24 bg-white/20 rounded-full mx-auto flex items-center justify-center mb-4",children:x!=null&&x.user_image?t.jsx("img",{src:x.user_image,alt:"Profile",className:"w-20 h-20 rounded-full object-cover"}):t.jsx(Wl,{className:"text-white text-4xl"})}),t.jsx("h2",{className:"text-xl font-bold text-white",children:(x==null?void 0:x.full_name)||"User"}),t.jsx("p",{className:"text-white/80 text-sm mt-1",children:x==null?void 0:x.email})]}),t.jsxs("div",{className:"p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx(cC,{className:"text-blue-500"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Username"}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:(x==null?void 0:x.username)||"-"})]})]}),t.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx(bC,{className:"text-green-500"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Role Profile"}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:(x==null?void 0:x.role_profile_name)||"-"})]})]}),t.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[t.jsx(fC,{className:"text-purple-500"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Status"}),t.jsx("p",{className:`text-sm font-medium ${x!=null&&x.enabled?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:x!=null&&x.enabled?"Active":"Inactive"})]})]})]})]})}),t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 p-6",children:[t.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:[t.jsx(Wl,{className:"text-blue-500"}),"Basic Information"]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Email",t.jsx("span",{className:"ml-1 text-gray-400",children:"(Read-only)"})]}),t.jsxs("div",{className:"relative",children:[t.jsx(Tw,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400",size:14}),t.jsx("input",{type:"email",value:(x==null?void 0:x.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"})]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Full Name",t.jsx("span",{className:"ml-1 text-gray-400",children:"(Auto-generated)"})]}),t.jsx("input",{type:"text",value:(x==null?void 0:x.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"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["First Name ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",name:"first_name",value:O.first_name,onChange:Q,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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Middle Name"}),t.jsx("input",{type:"text",name:"middle_name",value:O.middle_name,onChange:Q,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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Last Name"}),t.jsx("input",{type:"text",name:"last_name",value:O.last_name,onChange:Q,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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:"User ID No"}),t.jsx("input",{type:"text",name:"custom_user_id",value:O.custom_user_id,onChange:Q,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"})]}),t.jsx("div",{children:c?t.jsx(er,{label:"Role Profile",doctype:"Role Profile",value:O.role_profile_name,onChange:ce=>D(Ce=>$e(_e({},Ce),{role_profile_name:ce})),placeholder:"Select Role Profile"}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Role Profile",t.jsx("span",{className:"ml-1 text-gray-400",children:"(Read-only)"})]}),t.jsx("input",{type:"text",value:O.role_profile_name||"-",readOnly:!0,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"})]})}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Site Name",t.jsx("span",{className:"ml-1 text-gray-400",children:"(Read-only)"})]}),t.jsxs("div",{className:"relative",children:[t.jsx(kf,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400",size:14}),t.jsx("input",{type:"text",value:(x==null?void 0:x.custom_site_name)||"-",readOnly:!0,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"})]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["PHCC Site Name",t.jsx("span",{className:"ml-1 text-gray-400",children:"(Read-only)"})]}),t.jsxs("div",{className:"relative",children:[t.jsx(kf,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400",size:14}),t.jsx("input",{type:"text",value:(x==null?void 0:x.custom_phcc_site_name)||"-",readOnly:!0,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"})]})]})]})]}),t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-md border border-gray-200 dark:border-gray-700 p-6",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4 pb-2 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-800 dark:text-white flex items-center gap-2",children:[t.jsx(kx,{className:"text-orange-500"}),"Change Password"]}),t.jsx("button",{onClick:()=>I(!A),className:"text-sm text-blue-600 dark:text-blue-400 hover:underline",children:A?"Cancel":"Change Password"})]}),A?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Current Password ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("div",{className:"relative",children:[t.jsx("input",{type:B?"text":"password",name:"old_password",value:z.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"}),t.jsx("button",{type:"button",onClick:()=>V(!B),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:B?t.jsx(wx,{size:14}):t.jsx(to,{size:14})})]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["New Password ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("div",{className:"relative",children:[t.jsx("input",{type:Z?"text":"password",name:"new_password",value:z.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"}),t.jsx("button",{type:"button",onClick:()=>W(!Z),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:Z?t.jsx(wx,{size:14}):t.jsx(to,{size:14})})]}),z.new_password&&z.new_password.length<8&&t.jsx("p",{className:"mt-1 text-xs text-red-500",children:"Password must be at least 8 characters"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Confirm New Password ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("div",{className:"relative",children:[t.jsx("input",{type:H?"text":"password",name:"confirm_password",value:z.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"}),t.jsx("button",{type:"button",onClick:()=>le(!H),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:H?t.jsx(wx,{size:14}):t.jsx(to,{size:14})})]}),z.confirm_password&&z.new_password!==z.confirm_password&&t.jsx("p",{className:"mt-1 text-xs text-red-500",children:"Passwords do not match"}),z.confirm_password&&z.new_password===z.confirm_password&&z.new_password.length>=8&&t.jsxs("p",{className:"mt-1 text-xs text-green-500 flex items-center gap-1",children:[t.jsx(Ca,{size:10})," Passwords match"]})]}),t.jsx("div",{className:"pt-2",children:t.jsx("button",{onClick:se,disabled:g,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:g?t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"animate-spin"}),"Changing Password..."]}):t.jsxs(t.Fragment,{children:[t.jsx(kx,{}),"Change Password"]})})})]}):t.jsxs("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:[t.jsx(kx,{className:"mx-auto text-3xl mb-2 text-gray-300 dark:text-gray-600"}),t.jsx("p",{className:"text-sm",children:'Click "Change Password" to update your password'})]})]})]})]})]})},iB=({children:e})=>{const r=yi(),{isRTL:a}=h1(),{mobileOpen:n,closeMobileSidebar:i}=f1(),c=localStorage.getItem("user"),u=c?JSON.parse(c).email:"";return E.useEffect(()=>{const g=window.matchMedia("(min-width: 1024px)"),y=()=>{g.matches&&i()};return y(),g.addEventListener("change",y),()=>g.removeEventListener("change",y)},[i]),t.jsxs("div",{className:"flex h-screen overflow-hidden bg-gray-50 dark:bg-gray-900",children:[n&&t.jsx("button",{type:"button",className:"fixed inset-0 z-40 bg-black/50 lg:hidden",onClick:i,"aria-label":"Close menu"}),t.jsx("div",{className:`
|
||
fixed top-0 z-50 h-full transition-transform duration-300 ease-in-out lg:static lg:z-auto lg:translate-x-0
|
||
${a?`right-0 ${n?"translate-x-0":"translate-x-full"}`:`left-0 ${n?"translate-x-0":"-translate-x-full"}`}
|
||
`,children:t.jsx(RF,{userEmail:u})}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[t.jsx(BF,{userEmail:u}),t.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 dark:bg-gray-900",children:e},r.pathname)]})]})},Fa=({children:e})=>t.jsx(AF,{children:t.jsx(iB,{children:e})}),Ba=({children:e})=>localStorage.getItem("user")?t.jsx(t.Fragment,{children:e}):t.jsx(fu,{to:"/login",replace:!0}),oB=({children:e})=>Cu(vc())?t.jsx(fu,{to:fw(vc()),replace:!0}):t.jsx(t.Fragment,{children:e}),lB=()=>t.jsx(g8,{basename:"/asm_app",children:t.jsxs(G5,{children:[t.jsx(da,{path:"/login",element:t.jsx(R8,{})}),t.jsx(da,{path:"/dashboard",element:t.jsx(Ba,{children:t.jsx(oB,{children:t.jsx(Fa,{children:t.jsx(lM,{})})})})}),t.jsx(da,{path:"/wo-feedback",element:t.jsx(_M,{})}),t.jsx(da,{path:"/work-order-feedback",element:t.jsx(fu,{to:"/wo-feedback",replace:!0})}),t.jsx(da,{path:"/assets",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(PL,{})})})}),t.jsx(da,{path:"/assets/:assetName",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(OI,{})})})}),t.jsx(da,{path:"/work-orders",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(MI,{})})})}),t.jsx(da,{path:"/work-orders/:workOrderName",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(GI,{})})})}),t.jsx(da,{path:"/maintenance",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx($I,{})})})}),t.jsx(da,{path:"/maintenance/:logName",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(ZI,{})})})}),t.jsx(da,{path:"/ppm",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(QI,{})})})}),t.jsx(da,{path:"/ppm/:ppmName",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(eP,{})})})}),t.jsx(da,{path:"/ppm-planner",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(iP,{})})})}),t.jsx(da,{path:"/ppm-planner/new",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(rP,{})})})}),t.jsx(da,{path:"/ppm-planner/:scheduleName",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(oP,{})})})}),t.jsx(da,{path:"/maintenance-calendar",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(P_,{})})})}),t.jsx(da,{path:"/maintenance-calendar/month-view",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(cP,{})})})}),t.jsx(da,{path:"/yearly-ppm-planner",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(P_,{})})})}),t.jsx(da,{path:"/active-map",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(DP,{})})})}),t.jsx(da,{path:"/inventory",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(UP,{})})})}),t.jsx(da,{path:"/inventory/:itemName",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(zP,{})})})}),t.jsx(da,{path:"/users",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(JD,{})})})}),t.jsx(da,{path:"/events",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(QD,{})})})}),t.jsx(da,{path:"/old-dashboard",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(U8,{})})})}),t.jsx(da,{path:"/maintenance-teams",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(aB,{})})})}),t.jsx(da,{path:"/maintenance-teams/:teamName",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(nB,{})})})}),t.jsx(da,{path:"/procurement",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(H_,{title:"Procurement"})})})}),t.jsx(da,{path:"/sla",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(H_,{title:"Service Level Agreement (SLA)"})})})}),t.jsx(da,{path:"/support",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(XF,{})})})}),t.jsx(da,{path:"/support/:issueName",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(KF,{})})})}),t.jsx(da,{path:"/user-profile",element:t.jsx(Ba,{children:t.jsx(Fa,{children:t.jsx(sB,{})})})}),t.jsx(da,{index:!0,element:t.jsx(B_,{})}),t.jsx(da,{path:"/",element:t.jsx(B_,{})}),t.jsx(da,{path:"*",element:t.jsx(fu,{to:"/login",replace:!0})})]})});y6.createRoot(document.getElementById("root")).render(t.jsx(E.StrictMode,{children:t.jsx(TF,{children:t.jsx(MF,{children:t.jsx(lB,{})})})}))});export default cB();
|