726 lines
735 KiB
JavaScript
726 lines
735 KiB
JavaScript
var vf=e=>{throw TypeError(e)};var zc=(e,t,n)=>t.has(e)||vf("Cannot "+n);var M=(e,t,n)=>(zc(e,t,"read from private field"),n?n.call(e):t.get(e)),me=(e,t,n)=>t.has(e)?vf("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),te=(e,t,n,r)=>(zc(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),be=(e,t,n)=>(zc(e,t,"access private method"),n);var Ll=(e,t,n,r)=>({set _(a){te(e,t,a,n)},get _(){return M(e,t,r)}});function Qv(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const i=Object.getOwnPropertyDescriptor(r,a);i&&Object.defineProperty(e,a,i.get?i:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=n(a);fetch(a.href,i)}})();function Hv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var sg={exports:{}},rc={},ng={exports:{}},Ee={};/**
|
||
* @license React
|
||
* react.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/var bl=Symbol.for("react.element"),Wv=Symbol.for("react.portal"),Gv=Symbol.for("react.fragment"),Zv=Symbol.for("react.strict_mode"),Jv=Symbol.for("react.profiler"),Xv=Symbol.for("react.provider"),Yv=Symbol.for("react.context"),ej=Symbol.for("react.forward_ref"),tj=Symbol.for("react.suspense"),sj=Symbol.for("react.memo"),nj=Symbol.for("react.lazy"),jf=Symbol.iterator;function rj(e){return e===null||typeof e!="object"?null:(e=jf&&e[jf]||e["@@iterator"],typeof e=="function"?e:null)}var rg={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ag=Object.assign,ig={};function Ya(e,t,n){this.props=e,this.context=t,this.refs=ig,this.updater=n||rg}Ya.prototype.isReactComponent={};Ya.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Ya.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function lg(){}lg.prototype=Ya.prototype;function Yu(e,t,n){this.props=e,this.context=t,this.refs=ig,this.updater=n||rg}var em=Yu.prototype=new lg;em.constructor=Yu;ag(em,Ya.prototype);em.isPureReactComponent=!0;var bf=Array.isArray,og=Object.prototype.hasOwnProperty,tm={current:null},cg={key:!0,ref:!0,__self:!0,__source:!0};function dg(e,t,n){var r,a={},i=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(i=""+t.key),t)og.call(t,r)&&!cg.hasOwnProperty(r)&&(a[r]=t[r]);var o=arguments.length-2;if(o===1)a.children=n;else if(1<o){for(var c=Array(o),d=0;d<o;d++)c[d]=arguments[d+2];a.children=c}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)a[r]===void 0&&(a[r]=o[r]);return{$$typeof:bl,type:e,key:i,ref:l,props:a,_owner:tm.current}}function aj(e,t){return{$$typeof:bl,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function sm(e){return typeof e=="object"&&e!==null&&e.$$typeof===bl}function ij(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Nf=/\/+/g;function $c(e,t){return typeof e=="object"&&e!==null&&e.key!=null?ij(""+e.key):t.toString(36)}function ro(e,t,n,r,a){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var l=!1;if(e===null)l=!0;else switch(i){case"string":case"number":l=!0;break;case"object":switch(e.$$typeof){case bl:case Wv:l=!0}}if(l)return l=e,a=a(l),e=r===""?"."+$c(l,0):r,bf(a)?(n="",e!=null&&(n=e.replace(Nf,"$&/")+"/"),ro(a,t,n,"",function(d){return d})):a!=null&&(sm(a)&&(a=aj(a,n+(!a.key||l&&l.key===a.key?"":(""+a.key).replace(Nf,"$&/")+"/")+e)),t.push(a)),1;if(l=0,r=r===""?".":r+":",bf(e))for(var o=0;o<e.length;o++){i=e[o];var c=r+$c(i,o);l+=ro(i,t,n,c,a)}else if(c=rj(e),typeof c=="function")for(e=c.call(e),o=0;!(i=e.next()).done;)i=i.value,c=r+$c(i,o++),l+=ro(i,t,n,c,a);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return l}function Ol(e,t,n){if(e==null)return e;var r=[],a=0;return ro(e,r,"","",function(i){return t.call(n,i,a++)}),r}function lj(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Jt={current:null},ao={transition:null},oj={ReactCurrentDispatcher:Jt,ReactCurrentBatchConfig:ao,ReactCurrentOwner:tm};function ug(){throw Error("act(...) is not supported in production builds of React.")}Ee.Children={map:Ol,forEach:function(e,t,n){Ol(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Ol(e,function(){t++}),t},toArray:function(e){return Ol(e,function(t){return t})||[]},only:function(e){if(!sm(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Ee.Component=Ya;Ee.Fragment=Gv;Ee.Profiler=Jv;Ee.PureComponent=Yu;Ee.StrictMode=Zv;Ee.Suspense=tj;Ee.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=oj;Ee.act=ug;Ee.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=ag({},e.props),a=e.key,i=e.ref,l=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,l=tm.current),t.key!==void 0&&(a=""+t.key),e.type&&e.type.defaultProps)var o=e.type.defaultProps;for(c in t)og.call(t,c)&&!cg.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&o!==void 0?o[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){o=Array(c);for(var d=0;d<c;d++)o[d]=arguments[d+2];r.children=o}return{$$typeof:bl,type:e.type,key:a,ref:i,props:r,_owner:l}};Ee.createContext=function(e){return e={$$typeof:Yv,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Xv,_context:e},e.Consumer=e};Ee.createElement=dg;Ee.createFactory=function(e){var t=dg.bind(null,e);return t.type=e,t};Ee.createRef=function(){return{current:null}};Ee.forwardRef=function(e){return{$$typeof:ej,render:e}};Ee.isValidElement=sm;Ee.lazy=function(e){return{$$typeof:nj,_payload:{_status:-1,_result:e},_init:lj}};Ee.memo=function(e,t){return{$$typeof:sj,type:e,compare:t===void 0?null:t}};Ee.startTransition=function(e){var t=ao.transition;ao.transition={};try{e()}finally{ao.transition=t}};Ee.unstable_act=ug;Ee.useCallback=function(e,t){return Jt.current.useCallback(e,t)};Ee.useContext=function(e){return Jt.current.useContext(e)};Ee.useDebugValue=function(){};Ee.useDeferredValue=function(e){return Jt.current.useDeferredValue(e)};Ee.useEffect=function(e,t){return Jt.current.useEffect(e,t)};Ee.useId=function(){return Jt.current.useId()};Ee.useImperativeHandle=function(e,t,n){return Jt.current.useImperativeHandle(e,t,n)};Ee.useInsertionEffect=function(e,t){return Jt.current.useInsertionEffect(e,t)};Ee.useLayoutEffect=function(e,t){return Jt.current.useLayoutEffect(e,t)};Ee.useMemo=function(e,t){return Jt.current.useMemo(e,t)};Ee.useReducer=function(e,t,n){return Jt.current.useReducer(e,t,n)};Ee.useRef=function(e){return Jt.current.useRef(e)};Ee.useState=function(e){return Jt.current.useState(e)};Ee.useSyncExternalStore=function(e,t,n){return Jt.current.useSyncExternalStore(e,t,n)};Ee.useTransition=function(){return Jt.current.useTransition()};Ee.version="18.3.1";ng.exports=Ee;var j=ng.exports;const Tt=Hv(j),cj=Qv({__proto__:null,default:Tt},[j]);/**
|
||
* @license React
|
||
* react-jsx-runtime.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/var dj=j,uj=Symbol.for("react.element"),mj=Symbol.for("react.fragment"),hj=Object.prototype.hasOwnProperty,fj=dj.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,pj={key:!0,ref:!0,__self:!0,__source:!0};function mg(e,t,n){var r,a={},i=null,l=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(l=t.ref);for(r in t)hj.call(t,r)&&!pj.hasOwnProperty(r)&&(a[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)a[r]===void 0&&(a[r]=t[r]);return{$$typeof:uj,type:e,key:i,ref:l,props:a,_owner:fj.current}}rc.Fragment=mj;rc.jsx=mg;rc.jsxs=mg;sg.exports=rc;var s=sg.exports,Nd={},hg={exports:{}},bs={},fg={exports:{}},pg={};/**
|
||
* @license React
|
||
* scheduler.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/(function(e){function t(B,_){var Q=B.length;B.push(_);e:for(;0<Q;){var le=Q-1>>>1,de=B[le];if(0<a(de,_))B[le]=_,B[Q]=de,Q=le;else break e}}function n(B){return B.length===0?null:B[0]}function r(B){if(B.length===0)return null;var _=B[0],Q=B.pop();if(Q!==_){B[0]=Q;e:for(var le=0,de=B.length,Ke=de>>>1;le<Ke;){var Ve=2*(le+1)-1,st=B[Ve],C=Ve+1,nt=B[C];if(0>a(st,Q))C<de&&0>a(nt,st)?(B[le]=nt,B[C]=Q,le=C):(B[le]=st,B[Ve]=Q,le=Ve);else if(C<de&&0>a(nt,Q))B[le]=nt,B[C]=Q,le=C;else break e}}return _}function a(B,_){var Q=B.sortIndex-_.sortIndex;return Q!==0?Q:B.id-_.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var c=[],d=[],u=1,h=null,x=3,m=!1,f=!1,p=!1,b=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,y=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(B){for(var _=n(d);_!==null;){if(_.callback===null)r(d);else if(_.startTime<=B)r(d),_.sortIndex=_.expirationTime,t(c,_);else break;_=n(d)}}function N(B){if(p=!1,v(B),!f)if(n(c)!==null)f=!0,k(E);else{var _=n(d);_!==null&&K(N,_.startTime-B)}}function E(B,_){f=!1,p&&(p=!1,g(w),w=-1),m=!0;var Q=x;try{for(v(_),h=n(c);h!==null&&(!(h.expirationTime>_)||B&&!O());){var le=h.callback;if(typeof le=="function"){h.callback=null,x=h.priorityLevel;var de=le(h.expirationTime<=_);_=e.unstable_now(),typeof de=="function"?h.callback=de:h===n(c)&&r(c),v(_)}else r(c);h=n(c)}if(h!==null)var Ke=!0;else{var Ve=n(d);Ve!==null&&K(N,Ve.startTime-_),Ke=!1}return Ke}finally{h=null,x=Q,m=!1}}var P=!1,I=null,w=-1,S=5,A=-1;function O(){return!(e.unstable_now()-A<S)}function R(){if(I!==null){var B=e.unstable_now();A=B;var _=!0;try{_=I(!0,B)}finally{_?q():(P=!1,I=null)}}else P=!1}var q;if(typeof y=="function")q=function(){y(R)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,z=D.port2;D.port1.onmessage=R,q=function(){z.postMessage(null)}}else q=function(){b(R,0)};function k(B){I=B,P||(P=!0,q())}function K(B,_){w=b(function(){B(e.unstable_now())},_)}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(B){B.callback=null},e.unstable_continueExecution=function(){f||m||(f=!0,k(E))},e.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):S=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(B){switch(x){case 1:case 2:case 3:var _=3;break;default:_=x}var Q=x;x=_;try{return B()}finally{x=Q}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(B,_){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var Q=x;x=B;try{return _()}finally{x=Q}},e.unstable_scheduleCallback=function(B,_,Q){var le=e.unstable_now();switch(typeof Q=="object"&&Q!==null?(Q=Q.delay,Q=typeof Q=="number"&&0<Q?le+Q:le):Q=le,B){case 1:var de=-1;break;case 2:de=250;break;case 5:de=1073741823;break;case 4:de=1e4;break;default:de=5e3}return de=Q+de,B={id:u++,callback:_,priorityLevel:B,startTime:Q,expirationTime:de,sortIndex:-1},Q>le?(B.sortIndex=Q,t(d,B),n(c)===null&&B===n(d)&&(p?(g(w),w=-1):p=!0,K(N,Q-le))):(B.sortIndex=de,t(c,B),f||m||(f=!0,k(E))),B},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(B){var _=x;return function(){var Q=x;x=_;try{return B.apply(this,arguments)}finally{x=Q}}}})(pg);fg.exports=pg;var xj=fg.exports;/**
|
||
* @license React
|
||
* react-dom.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/var gj=j,js=xj;function Y(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var xg=new Set,$i={};function Yr(e,t){Ua(e,t),Ua(e+"Capture",t)}function Ua(e,t){for($i[e]=t,e=0;e<t.length;e++)xg.add(t[e])}var Dn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wd=Object.prototype.hasOwnProperty,yj=/^[: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]*$/,wf={},Sf={};function vj(e){return wd.call(Sf,e)?!0:wd.call(wf,e)?!1:yj.test(e)?Sf[e]=!0:(wf[e]=!0,!1)}function jj(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function bj(e,t,n,r){if(t===null||typeof t>"u"||jj(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Xt(e,t,n,r,a,i,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=a,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=l}var Lt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Lt[e]=new Xt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Lt[t]=new Xt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Lt[e]=new Xt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Lt[e]=new Xt(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Lt[e]=new Xt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Lt[e]=new Xt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Lt[e]=new Xt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Lt[e]=new Xt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Lt[e]=new Xt(e,5,!1,e.toLowerCase(),null,!1,!1)});var nm=/[\-:]([a-z])/g;function rm(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(nm,rm);Lt[t]=new Xt(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(nm,rm);Lt[t]=new Xt(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(nm,rm);Lt[t]=new Xt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Lt[e]=new Xt(e,1,!1,e.toLowerCase(),null,!1,!1)});Lt.xlinkHref=new Xt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Lt[e]=new Xt(e,1,!1,e.toLowerCase(),null,!0,!0)});function am(e,t,n,r){var a=Lt.hasOwnProperty(t)?Lt[t]:null;(a!==null?a.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(bj(t,n,a,r)&&(n=null),r||a===null?vj(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):a.mustUseProperty?e[a.propertyName]=n===null?a.type===3?!1:"":n:(t=a.attributeName,r=a.attributeNamespace,n===null?e.removeAttribute(t):(a=a.type,n=a===3||a===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var Fn=gj.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,zl=Symbol.for("react.element"),la=Symbol.for("react.portal"),oa=Symbol.for("react.fragment"),im=Symbol.for("react.strict_mode"),Sd=Symbol.for("react.profiler"),gg=Symbol.for("react.provider"),yg=Symbol.for("react.context"),lm=Symbol.for("react.forward_ref"),kd=Symbol.for("react.suspense"),Cd=Symbol.for("react.suspense_list"),om=Symbol.for("react.memo"),$n=Symbol.for("react.lazy"),vg=Symbol.for("react.offscreen"),kf=Symbol.iterator;function ui(e){return e===null||typeof e!="object"?null:(e=kf&&e[kf]||e["@@iterator"],typeof e=="function"?e:null)}var ot=Object.assign,_c;function bi(e){if(_c===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);_c=t&&t[1]||""}return`
|
||
`+_c+e}var Kc=!1;function Bc(e,t){if(!e||Kc)return"";Kc=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(d){var r=d}Reflect.construct(e,[],t)}else{try{t.call()}catch(d){r=d}e.call(t.prototype)}else{try{throw Error()}catch(d){r=d}e()}}catch(d){if(d&&r&&typeof d.stack=="string"){for(var a=d.stack.split(`
|
||
`),i=r.stack.split(`
|
||
`),l=a.length-1,o=i.length-1;1<=l&&0<=o&&a[l]!==i[o];)o--;for(;1<=l&&0<=o;l--,o--)if(a[l]!==i[o]){if(l!==1||o!==1)do if(l--,o--,0>o||a[l]!==i[o]){var c=`
|
||
`+a[l].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{Kc=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?bi(e):""}function Nj(e){switch(e.tag){case 5:return bi(e.type);case 16:return bi("Lazy");case 13:return bi("Suspense");case 19:return bi("SuspenseList");case 0:case 2:case 15:return e=Bc(e.type,!1),e;case 11:return e=Bc(e.type.render,!1),e;case 1:return e=Bc(e.type,!0),e;default:return""}}function Ed(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case oa:return"Fragment";case la:return"Portal";case Sd:return"Profiler";case im:return"StrictMode";case kd:return"Suspense";case Cd:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case yg:return(e.displayName||"Context")+".Consumer";case gg:return(e._context.displayName||"Context")+".Provider";case lm:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case om:return t=e.displayName||null,t!==null?t:Ed(e.type)||"Memo";case $n:t=e._payload,e=e._init;try{return Ed(e(t))}catch{}}return null}function wj(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ed(t);case 8:return t===im?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function fr(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function jg(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Sj(e){var t=jg(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var a=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(l){r=""+l,i.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function $l(e){e._valueTracker||(e._valueTracker=Sj(e))}function bg(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=jg(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function wo(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Dd(e,t){var n=t.checked;return ot({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Cf(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=fr(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Ng(e,t){t=t.checked,t!=null&&am(e,"checked",t,!1)}function Ad(e,t){Ng(e,t);var n=fr(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Pd(e,t.type,n):t.hasOwnProperty("defaultValue")&&Pd(e,t.type,fr(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Ef(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Pd(e,t,n){(t!=="number"||wo(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Ni=Array.isArray;function ja(e,t,n,r){if(e=e.options,t){t={};for(var a=0;a<n.length;a++)t["$"+n[a]]=!0;for(n=0;n<e.length;n++)a=t.hasOwnProperty("$"+e[n].value),e[n].selected!==a&&(e[n].selected=a),a&&r&&(e[n].defaultSelected=!0)}else{for(n=""+fr(n),t=null,a=0;a<e.length;a++){if(e[a].value===n){e[a].selected=!0,r&&(e[a].defaultSelected=!0);return}t!==null||e[a].disabled||(t=e[a])}t!==null&&(t.selected=!0)}}function Md(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Y(91));return ot({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Df(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Y(92));if(Ni(n)){if(1<n.length)throw Error(Y(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:fr(n)}}function wg(e,t){var n=fr(t.value),r=fr(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function Af(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Sg(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Td(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Sg(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var _l,kg=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,a){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,a)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(_l=_l||document.createElement("div"),_l.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=_l.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function _i(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ei={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},kj=["Webkit","ms","Moz","O"];Object.keys(Ei).forEach(function(e){kj.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ei[t]=Ei[e]})});function Cg(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Ei.hasOwnProperty(e)&&Ei[e]?(""+t).trim():t+"px"}function Eg(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,a=Cg(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,a):e[n]=a}}var Cj=ot({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Fd(e,t){if(t){if(Cj[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Y(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Y(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Y(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Y(62))}}function Id(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Rd=null;function cm(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ld=null,ba=null,Na=null;function Pf(e){if(e=Sl(e)){if(typeof Ld!="function")throw Error(Y(280));var t=e.stateNode;t&&(t=cc(t),Ld(e.stateNode,e.type,t))}}function Dg(e){ba?Na?Na.push(e):Na=[e]:ba=e}function Ag(){if(ba){var e=ba,t=Na;if(Na=ba=null,Pf(e),t)for(e=0;e<t.length;e++)Pf(t[e])}}function Pg(e,t){return e(t)}function Mg(){}var Uc=!1;function Tg(e,t,n){if(Uc)return e(t,n);Uc=!0;try{return Pg(e,t,n)}finally{Uc=!1,(ba!==null||Na!==null)&&(Mg(),Ag())}}function Ki(e,t){var n=e.stateNode;if(n===null)return null;var r=cc(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(Y(231,t,typeof n));return n}var Od=!1;if(Dn)try{var mi={};Object.defineProperty(mi,"passive",{get:function(){Od=!0}}),window.addEventListener("test",mi,mi),window.removeEventListener("test",mi,mi)}catch{Od=!1}function Ej(e,t,n,r,a,i,l,o,c){var d=Array.prototype.slice.call(arguments,3);try{t.apply(n,d)}catch(u){this.onError(u)}}var Di=!1,So=null,ko=!1,zd=null,Dj={onError:function(e){Di=!0,So=e}};function Aj(e,t,n,r,a,i,l,o,c){Di=!1,So=null,Ej.apply(Dj,arguments)}function Pj(e,t,n,r,a,i,l,o,c){if(Aj.apply(this,arguments),Di){if(Di){var d=So;Di=!1,So=null}else throw Error(Y(198));ko||(ko=!0,zd=d)}}function ea(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function Fg(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Mf(e){if(ea(e)!==e)throw Error(Y(188))}function Mj(e){var t=e.alternate;if(!t){if(t=ea(e),t===null)throw Error(Y(188));return t!==e?null:e}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var i=a.alternate;if(i===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===i.child){for(i=a.child;i;){if(i===n)return Mf(a),e;if(i===r)return Mf(a),t;i=i.sibling}throw Error(Y(188))}if(n.return!==r.return)n=a,r=i;else{for(var l=!1,o=a.child;o;){if(o===n){l=!0,n=a,r=i;break}if(o===r){l=!0,r=a,n=i;break}o=o.sibling}if(!l){for(o=i.child;o;){if(o===n){l=!0,n=i,r=a;break}if(o===r){l=!0,r=i,n=a;break}o=o.sibling}if(!l)throw Error(Y(189))}}if(n.alternate!==r)throw Error(Y(190))}if(n.tag!==3)throw Error(Y(188));return n.stateNode.current===n?e:t}function Ig(e){return e=Mj(e),e!==null?Rg(e):null}function Rg(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Rg(e);if(t!==null)return t;e=e.sibling}return null}var Lg=js.unstable_scheduleCallback,Tf=js.unstable_cancelCallback,Tj=js.unstable_shouldYield,Fj=js.unstable_requestPaint,ft=js.unstable_now,Ij=js.unstable_getCurrentPriorityLevel,dm=js.unstable_ImmediatePriority,Og=js.unstable_UserBlockingPriority,Co=js.unstable_NormalPriority,Rj=js.unstable_LowPriority,zg=js.unstable_IdlePriority,ac=null,rn=null;function Lj(e){if(rn&&typeof rn.onCommitFiberRoot=="function")try{rn.onCommitFiberRoot(ac,e,void 0,(e.current.flags&128)===128)}catch{}}var Bs=Math.clz32?Math.clz32:$j,Oj=Math.log,zj=Math.LN2;function $j(e){return e>>>=0,e===0?32:31-(Oj(e)/zj|0)|0}var Kl=64,Bl=4194304;function wi(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Eo(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,a=e.suspendedLanes,i=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~a;o!==0?r=wi(o):(i&=l,i!==0&&(r=wi(i)))}else l=n&~a,l!==0?r=wi(l):i!==0&&(r=wi(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&a)&&(a=r&-r,i=t&-t,a>=i||a===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Bs(t),a=1<<n,r|=e[n],t&=~a;return r}function _j(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Kj(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,i=e.pendingLanes;0<i;){var l=31-Bs(i),o=1<<l,c=a[l];c===-1?(!(o&n)||o&r)&&(a[l]=_j(o,t)):c<=t&&(e.expiredLanes|=o),i&=~o}}function $d(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function $g(){var e=Kl;return Kl<<=1,!(Kl&4194240)&&(Kl=64),e}function qc(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Nl(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Bs(t),e[t]=n}function Bj(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var a=31-Bs(n),i=1<<a;t[a]=0,r[a]=-1,e[a]=-1,n&=~i}}function um(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Bs(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}var Ue=0;function _g(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Kg,mm,Bg,Ug,qg,_d=!1,Ul=[],rr=null,ar=null,ir=null,Bi=new Map,Ui=new Map,Kn=[],Uj="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Ff(e,t){switch(e){case"focusin":case"focusout":rr=null;break;case"dragenter":case"dragleave":ar=null;break;case"mouseover":case"mouseout":ir=null;break;case"pointerover":case"pointerout":Bi.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ui.delete(t.pointerId)}}function hi(e,t,n,r,a,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[a]},t!==null&&(t=Sl(t),t!==null&&mm(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function qj(e,t,n,r,a){switch(t){case"focusin":return rr=hi(rr,e,t,n,r,a),!0;case"dragenter":return ar=hi(ar,e,t,n,r,a),!0;case"mouseover":return ir=hi(ir,e,t,n,r,a),!0;case"pointerover":var i=a.pointerId;return Bi.set(i,hi(Bi.get(i)||null,e,t,n,r,a)),!0;case"gotpointercapture":return i=a.pointerId,Ui.set(i,hi(Ui.get(i)||null,e,t,n,r,a)),!0}return!1}function Vg(e){var t=kr(e.target);if(t!==null){var n=ea(t);if(n!==null){if(t=n.tag,t===13){if(t=Fg(n),t!==null){e.blockedOn=t,qg(e.priority,function(){Bg(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function io(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Kd(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Rd=r,n.target.dispatchEvent(r),Rd=null}else return t=Sl(n),t!==null&&mm(t),e.blockedOn=n,!1;t.shift()}return!0}function If(e,t,n){io(e)&&n.delete(t)}function Vj(){_d=!1,rr!==null&&io(rr)&&(rr=null),ar!==null&&io(ar)&&(ar=null),ir!==null&&io(ir)&&(ir=null),Bi.forEach(If),Ui.forEach(If)}function fi(e,t){e.blockedOn===t&&(e.blockedOn=null,_d||(_d=!0,js.unstable_scheduleCallback(js.unstable_NormalPriority,Vj)))}function qi(e){function t(a){return fi(a,e)}if(0<Ul.length){fi(Ul[0],e);for(var n=1;n<Ul.length;n++){var r=Ul[n];r.blockedOn===e&&(r.blockedOn=null)}}for(rr!==null&&fi(rr,e),ar!==null&&fi(ar,e),ir!==null&&fi(ir,e),Bi.forEach(t),Ui.forEach(t),n=0;n<Kn.length;n++)r=Kn[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Kn.length&&(n=Kn[0],n.blockedOn===null);)Vg(n),n.blockedOn===null&&Kn.shift()}var wa=Fn.ReactCurrentBatchConfig,Do=!0;function Qj(e,t,n,r){var a=Ue,i=wa.transition;wa.transition=null;try{Ue=1,hm(e,t,n,r)}finally{Ue=a,wa.transition=i}}function Hj(e,t,n,r){var a=Ue,i=wa.transition;wa.transition=null;try{Ue=4,hm(e,t,n,r)}finally{Ue=a,wa.transition=i}}function hm(e,t,n,r){if(Do){var a=Kd(e,t,n,r);if(a===null)ed(e,t,r,Ao,n),Ff(e,r);else if(qj(a,e,t,n,r))r.stopPropagation();else if(Ff(e,r),t&4&&-1<Uj.indexOf(e)){for(;a!==null;){var i=Sl(a);if(i!==null&&Kg(i),i=Kd(e,t,n,r),i===null&&ed(e,t,r,Ao,n),i===a)break;a=i}a!==null&&r.stopPropagation()}else ed(e,t,r,null,n)}}var Ao=null;function Kd(e,t,n,r){if(Ao=null,e=cm(r),e=kr(e),e!==null)if(t=ea(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Fg(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Ao=e,null}function Qg(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Ij()){case dm:return 1;case Og:return 4;case Co:case Rj:return 16;case zg:return 536870912;default:return 16}default:return 16}}var tr=null,fm=null,lo=null;function Hg(){if(lo)return lo;var e,t=fm,n=t.length,r,a="value"in tr?tr.value:tr.textContent,i=a.length;for(e=0;e<n&&t[e]===a[e];e++);var l=n-e;for(r=1;r<=l&&t[n-r]===a[i-r];r++);return lo=a.slice(e,1<r?1-r:void 0)}function oo(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function ql(){return!0}function Rf(){return!1}function Ns(e){function t(n,r,a,i,l){this._reactName=n,this._targetInst=a,this.type=r,this.nativeEvent=i,this.target=l,this.currentTarget=null;for(var o in e)e.hasOwnProperty(o)&&(n=e[o],this[o]=n?n(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?ql:Rf,this.isPropagationStopped=Rf,this}return ot(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=ql)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=ql)},persist:function(){},isPersistent:ql}),t}var ei={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},pm=Ns(ei),wl=ot({},ei,{view:0,detail:0}),Wj=Ns(wl),Vc,Qc,pi,ic=ot({},wl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:xm,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==pi&&(pi&&e.type==="mousemove"?(Vc=e.screenX-pi.screenX,Qc=e.screenY-pi.screenY):Qc=Vc=0,pi=e),Vc)},movementY:function(e){return"movementY"in e?e.movementY:Qc}}),Lf=Ns(ic),Gj=ot({},ic,{dataTransfer:0}),Zj=Ns(Gj),Jj=ot({},wl,{relatedTarget:0}),Hc=Ns(Jj),Xj=ot({},ei,{animationName:0,elapsedTime:0,pseudoElement:0}),Yj=Ns(Xj),eb=ot({},ei,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),tb=Ns(eb),sb=ot({},ei,{data:0}),Of=Ns(sb),nb={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},rb={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"},ab={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ib(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=ab[e])?!!t[e]:!1}function xm(){return ib}var lb=ot({},wl,{key:function(e){if(e.key){var t=nb[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=oo(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?rb[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:xm,charCode:function(e){return e.type==="keypress"?oo(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?oo(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),ob=Ns(lb),cb=ot({},ic,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),zf=Ns(cb),db=ot({},wl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:xm}),ub=Ns(db),mb=ot({},ei,{propertyName:0,elapsedTime:0,pseudoElement:0}),hb=Ns(mb),fb=ot({},ic,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),pb=Ns(fb),xb=[9,13,27,32],gm=Dn&&"CompositionEvent"in window,Ai=null;Dn&&"documentMode"in document&&(Ai=document.documentMode);var gb=Dn&&"TextEvent"in window&&!Ai,Wg=Dn&&(!gm||Ai&&8<Ai&&11>=Ai),$f=" ",_f=!1;function Gg(e,t){switch(e){case"keyup":return xb.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Zg(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ca=!1;function yb(e,t){switch(e){case"compositionend":return Zg(t);case"keypress":return t.which!==32?null:(_f=!0,$f);case"textInput":return e=t.data,e===$f&&_f?null:e;default:return null}}function vb(e,t){if(ca)return e==="compositionend"||!gm&&Gg(e,t)?(e=Hg(),lo=fm=tr=null,ca=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Wg&&t.locale!=="ko"?null:t.data;default:return null}}var jb={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 Kf(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!jb[e.type]:t==="textarea"}function Jg(e,t,n,r){Dg(r),t=Po(t,"onChange"),0<t.length&&(n=new pm("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Pi=null,Vi=null;function bb(e){oy(e,0)}function lc(e){var t=ma(e);if(bg(t))return e}function Nb(e,t){if(e==="change")return t}var Xg=!1;if(Dn){var Wc;if(Dn){var Gc="oninput"in document;if(!Gc){var Bf=document.createElement("div");Bf.setAttribute("oninput","return;"),Gc=typeof Bf.oninput=="function"}Wc=Gc}else Wc=!1;Xg=Wc&&(!document.documentMode||9<document.documentMode)}function Uf(){Pi&&(Pi.detachEvent("onpropertychange",Yg),Vi=Pi=null)}function Yg(e){if(e.propertyName==="value"&&lc(Vi)){var t=[];Jg(t,Vi,e,cm(e)),Tg(bb,t)}}function wb(e,t,n){e==="focusin"?(Uf(),Pi=t,Vi=n,Pi.attachEvent("onpropertychange",Yg)):e==="focusout"&&Uf()}function Sb(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return lc(Vi)}function kb(e,t){if(e==="click")return lc(t)}function Cb(e,t){if(e==="input"||e==="change")return lc(t)}function Eb(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var qs=typeof Object.is=="function"?Object.is:Eb;function Qi(e,t){if(qs(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var a=n[r];if(!wd.call(t,a)||!qs(e[a],t[a]))return!1}return!0}function qf(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Vf(e,t){var n=qf(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=qf(n)}}function ey(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ey(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ty(){for(var e=window,t=wo();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=wo(e.document)}return t}function ym(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Db(e){var t=ty(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&ey(n.ownerDocument.documentElement,n)){if(r!==null&&ym(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var a=n.textContent.length,i=Math.min(r.start,a);r=r.end===void 0?i:Math.min(r.end,a),!e.extend&&i>r&&(a=r,r=i,i=a),a=Vf(n,i);var l=Vf(n,r);a&&l&&(e.rangeCount!==1||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(a.node,a.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var Ab=Dn&&"documentMode"in document&&11>=document.documentMode,da=null,Bd=null,Mi=null,Ud=!1;function Qf(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ud||da==null||da!==wo(r)||(r=da,"selectionStart"in r&&ym(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Mi&&Qi(Mi,r)||(Mi=r,r=Po(Bd,"onSelect"),0<r.length&&(t=new pm("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=da)))}function Vl(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ua={animationend:Vl("Animation","AnimationEnd"),animationiteration:Vl("Animation","AnimationIteration"),animationstart:Vl("Animation","AnimationStart"),transitionend:Vl("Transition","TransitionEnd")},Zc={},sy={};Dn&&(sy=document.createElement("div").style,"AnimationEvent"in window||(delete ua.animationend.animation,delete ua.animationiteration.animation,delete ua.animationstart.animation),"TransitionEvent"in window||delete ua.transitionend.transition);function oc(e){if(Zc[e])return Zc[e];if(!ua[e])return e;var t=ua[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in sy)return Zc[e]=t[n];return e}var ny=oc("animationend"),ry=oc("animationiteration"),ay=oc("animationstart"),iy=oc("transitionend"),ly=new Map,Hf="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function gr(e,t){ly.set(e,t),Yr(t,[e])}for(var Jc=0;Jc<Hf.length;Jc++){var Xc=Hf[Jc],Pb=Xc.toLowerCase(),Mb=Xc[0].toUpperCase()+Xc.slice(1);gr(Pb,"on"+Mb)}gr(ny,"onAnimationEnd");gr(ry,"onAnimationIteration");gr(ay,"onAnimationStart");gr("dblclick","onDoubleClick");gr("focusin","onFocus");gr("focusout","onBlur");gr(iy,"onTransitionEnd");Ua("onMouseEnter",["mouseout","mouseover"]);Ua("onMouseLeave",["mouseout","mouseover"]);Ua("onPointerEnter",["pointerout","pointerover"]);Ua("onPointerLeave",["pointerout","pointerover"]);Yr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Yr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Yr("onBeforeInput",["compositionend","keypress","textInput","paste"]);Yr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Yr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Yr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Si="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(" "),Tb=new Set("cancel close invalid load scroll toggle".split(" ").concat(Si));function Wf(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,Pj(r,t,void 0,e),e.currentTarget=null}function oy(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],a=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var l=r.length-1;0<=l;l--){var o=r[l],c=o.instance,d=o.currentTarget;if(o=o.listener,c!==i&&a.isPropagationStopped())break e;Wf(a,o,d),i=c}else for(l=0;l<r.length;l++){if(o=r[l],c=o.instance,d=o.currentTarget,o=o.listener,c!==i&&a.isPropagationStopped())break e;Wf(a,o,d),i=c}}}if(ko)throw e=zd,ko=!1,zd=null,e}function Ze(e,t){var n=t[Wd];n===void 0&&(n=t[Wd]=new Set);var r=e+"__bubble";n.has(r)||(cy(t,e,2,!1),n.add(r))}function Yc(e,t,n){var r=0;t&&(r|=4),cy(n,e,r,t)}var Ql="_reactListening"+Math.random().toString(36).slice(2);function Hi(e){if(!e[Ql]){e[Ql]=!0,xg.forEach(function(n){n!=="selectionchange"&&(Tb.has(n)||Yc(n,!1,e),Yc(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Ql]||(t[Ql]=!0,Yc("selectionchange",!1,t))}}function cy(e,t,n,r){switch(Qg(t)){case 1:var a=Qj;break;case 4:a=Hj;break;default:a=hm}n=a.bind(null,t,n,e),a=void 0,!Od||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(a=!0),r?a!==void 0?e.addEventListener(t,n,{capture:!0,passive:a}):e.addEventListener(t,n,!0):a!==void 0?e.addEventListener(t,n,{passive:a}):e.addEventListener(t,n,!1)}function ed(e,t,n,r,a){var i=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var l=r.tag;if(l===3||l===4){var o=r.stateNode.containerInfo;if(o===a||o.nodeType===8&&o.parentNode===a)break;if(l===4)for(l=r.return;l!==null;){var c=l.tag;if((c===3||c===4)&&(c=l.stateNode.containerInfo,c===a||c.nodeType===8&&c.parentNode===a))return;l=l.return}for(;o!==null;){if(l=kr(o),l===null)return;if(c=l.tag,c===5||c===6){r=i=l;continue e}o=o.parentNode}}r=r.return}Tg(function(){var d=i,u=cm(n),h=[];e:{var x=ly.get(e);if(x!==void 0){var m=pm,f=e;switch(e){case"keypress":if(oo(n)===0)break e;case"keydown":case"keyup":m=ob;break;case"focusin":f="focus",m=Hc;break;case"focusout":f="blur",m=Hc;break;case"beforeblur":case"afterblur":m=Hc;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":m=Lf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=Zj;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=ub;break;case ny:case ry:case ay:m=Yj;break;case iy:m=hb;break;case"scroll":m=Wj;break;case"wheel":m=pb;break;case"copy":case"cut":case"paste":m=tb;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=zf}var p=(t&4)!==0,b=!p&&e==="scroll",g=p?x!==null?x+"Capture":null:x;p=[];for(var y=d,v;y!==null;){v=y;var N=v.stateNode;if(v.tag===5&&N!==null&&(v=N,g!==null&&(N=Ki(y,g),N!=null&&p.push(Wi(y,N,v)))),b)break;y=y.return}0<p.length&&(x=new m(x,f,null,n,u),h.push({event:x,listeners:p}))}}if(!(t&7)){e:{if(x=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",x&&n!==Rd&&(f=n.relatedTarget||n.fromElement)&&(kr(f)||f[An]))break e;if((m||x)&&(x=u.window===u?u:(x=u.ownerDocument)?x.defaultView||x.parentWindow:window,m?(f=n.relatedTarget||n.toElement,m=d,f=f?kr(f):null,f!==null&&(b=ea(f),f!==b||f.tag!==5&&f.tag!==6)&&(f=null)):(m=null,f=d),m!==f)){if(p=Lf,N="onMouseLeave",g="onMouseEnter",y="mouse",(e==="pointerout"||e==="pointerover")&&(p=zf,N="onPointerLeave",g="onPointerEnter",y="pointer"),b=m==null?x:ma(m),v=f==null?x:ma(f),x=new p(N,y+"leave",m,n,u),x.target=b,x.relatedTarget=v,N=null,kr(u)===d&&(p=new p(g,y+"enter",f,n,u),p.target=v,p.relatedTarget=b,N=p),b=N,m&&f)t:{for(p=m,g=f,y=0,v=p;v;v=na(v))y++;for(v=0,N=g;N;N=na(N))v++;for(;0<y-v;)p=na(p),y--;for(;0<v-y;)g=na(g),v--;for(;y--;){if(p===g||g!==null&&p===g.alternate)break t;p=na(p),g=na(g)}p=null}else p=null;m!==null&&Gf(h,x,m,p,!1),f!==null&&b!==null&&Gf(h,b,f,p,!0)}}e:{if(x=d?ma(d):window,m=x.nodeName&&x.nodeName.toLowerCase(),m==="select"||m==="input"&&x.type==="file")var E=Nb;else if(Kf(x))if(Xg)E=Cb;else{E=Sb;var P=wb}else(m=x.nodeName)&&m.toLowerCase()==="input"&&(x.type==="checkbox"||x.type==="radio")&&(E=kb);if(E&&(E=E(e,d))){Jg(h,E,n,u);break e}P&&P(e,x,d),e==="focusout"&&(P=x._wrapperState)&&P.controlled&&x.type==="number"&&Pd(x,"number",x.value)}switch(P=d?ma(d):window,e){case"focusin":(Kf(P)||P.contentEditable==="true")&&(da=P,Bd=d,Mi=null);break;case"focusout":Mi=Bd=da=null;break;case"mousedown":Ud=!0;break;case"contextmenu":case"mouseup":case"dragend":Ud=!1,Qf(h,n,u);break;case"selectionchange":if(Ab)break;case"keydown":case"keyup":Qf(h,n,u)}var I;if(gm)e:{switch(e){case"compositionstart":var w="onCompositionStart";break e;case"compositionend":w="onCompositionEnd";break e;case"compositionupdate":w="onCompositionUpdate";break e}w=void 0}else ca?Gg(e,n)&&(w="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(w="onCompositionStart");w&&(Wg&&n.locale!=="ko"&&(ca||w!=="onCompositionStart"?w==="onCompositionEnd"&&ca&&(I=Hg()):(tr=u,fm="value"in tr?tr.value:tr.textContent,ca=!0)),P=Po(d,w),0<P.length&&(w=new Of(w,e,null,n,u),h.push({event:w,listeners:P}),I?w.data=I:(I=Zg(n),I!==null&&(w.data=I)))),(I=gb?yb(e,n):vb(e,n))&&(d=Po(d,"onBeforeInput"),0<d.length&&(u=new Of("onBeforeInput","beforeinput",null,n,u),h.push({event:u,listeners:d}),u.data=I))}oy(h,t)})}function Wi(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Po(e,t){for(var n=t+"Capture",r=[];e!==null;){var a=e,i=a.stateNode;a.tag===5&&i!==null&&(a=i,i=Ki(e,n),i!=null&&r.unshift(Wi(e,i,a)),i=Ki(e,t),i!=null&&r.push(Wi(e,i,a))),e=e.return}return r}function na(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Gf(e,t,n,r,a){for(var i=t._reactName,l=[];n!==null&&n!==r;){var o=n,c=o.alternate,d=o.stateNode;if(c!==null&&c===r)break;o.tag===5&&d!==null&&(o=d,a?(c=Ki(n,i),c!=null&&l.unshift(Wi(n,c,o))):a||(c=Ki(n,i),c!=null&&l.push(Wi(n,c,o)))),n=n.return}l.length!==0&&e.push({event:t,listeners:l})}var Fb=/\r\n?/g,Ib=/\u0000|\uFFFD/g;function Zf(e){return(typeof e=="string"?e:""+e).replace(Fb,`
|
||
`).replace(Ib,"")}function Hl(e,t,n){if(t=Zf(t),Zf(e)!==t&&n)throw Error(Y(425))}function Mo(){}var qd=null,Vd=null;function Qd(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Hd=typeof setTimeout=="function"?setTimeout:void 0,Rb=typeof clearTimeout=="function"?clearTimeout:void 0,Jf=typeof Promise=="function"?Promise:void 0,Lb=typeof queueMicrotask=="function"?queueMicrotask:typeof Jf<"u"?function(e){return Jf.resolve(null).then(e).catch(Ob)}:Hd;function Ob(e){setTimeout(function(){throw e})}function td(e,t){var n=t,r=0;do{var a=n.nextSibling;if(e.removeChild(n),a&&a.nodeType===8)if(n=a.data,n==="/$"){if(r===0){e.removeChild(a),qi(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=a}while(n);qi(t)}function lr(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function Xf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var ti=Math.random().toString(36).slice(2),tn="__reactFiber$"+ti,Gi="__reactProps$"+ti,An="__reactContainer$"+ti,Wd="__reactEvents$"+ti,zb="__reactListeners$"+ti,$b="__reactHandles$"+ti;function kr(e){var t=e[tn];if(t)return t;for(var n=e.parentNode;n;){if(t=n[An]||n[tn]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Xf(e);e!==null;){if(n=e[tn])return n;e=Xf(e)}return t}e=n,n=e.parentNode}return null}function Sl(e){return e=e[tn]||e[An],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function ma(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Y(33))}function cc(e){return e[Gi]||null}var Gd=[],ha=-1;function yr(e){return{current:e}}function Je(e){0>ha||(e.current=Gd[ha],Gd[ha]=null,ha--)}function Qe(e,t){ha++,Gd[ha]=e.current,e.current=t}var pr={},Ut=yr(pr),os=yr(!1),qr=pr;function qa(e,t){var n=e.type.contextTypes;if(!n)return pr;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var a={},i;for(i in n)a[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=a),a}function cs(e){return e=e.childContextTypes,e!=null}function To(){Je(os),Je(Ut)}function Yf(e,t,n){if(Ut.current!==pr)throw Error(Y(168));Qe(Ut,t),Qe(os,n)}function dy(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var a in r)if(!(a in t))throw Error(Y(108,wj(e)||"Unknown",a));return ot({},n,r)}function Fo(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||pr,qr=Ut.current,Qe(Ut,e),Qe(os,os.current),!0}function ep(e,t,n){var r=e.stateNode;if(!r)throw Error(Y(169));n?(e=dy(e,t,qr),r.__reactInternalMemoizedMergedChildContext=e,Je(os),Je(Ut),Qe(Ut,e)):Je(os),Qe(os,n)}var gn=null,dc=!1,sd=!1;function uy(e){gn===null?gn=[e]:gn.push(e)}function _b(e){dc=!0,uy(e)}function vr(){if(!sd&&gn!==null){sd=!0;var e=0,t=Ue;try{var n=gn;for(Ue=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}gn=null,dc=!1}catch(a){throw gn!==null&&(gn=gn.slice(e+1)),Lg(dm,vr),a}finally{Ue=t,sd=!1}}return null}var fa=[],pa=0,Io=null,Ro=0,Cs=[],Es=0,Vr=null,wn=1,Sn="";function Nr(e,t){fa[pa++]=Ro,fa[pa++]=Io,Io=e,Ro=t}function my(e,t,n){Cs[Es++]=wn,Cs[Es++]=Sn,Cs[Es++]=Vr,Vr=e;var r=wn;e=Sn;var a=32-Bs(r)-1;r&=~(1<<a),n+=1;var i=32-Bs(t)+a;if(30<i){var l=a-a%5;i=(r&(1<<l)-1).toString(32),r>>=l,a-=l,wn=1<<32-Bs(t)+a|n<<a|r,Sn=i+e}else wn=1<<i|n<<a|r,Sn=e}function vm(e){e.return!==null&&(Nr(e,1),my(e,1,0))}function jm(e){for(;e===Io;)Io=fa[--pa],fa[pa]=null,Ro=fa[--pa],fa[pa]=null;for(;e===Vr;)Vr=Cs[--Es],Cs[Es]=null,Sn=Cs[--Es],Cs[Es]=null,wn=Cs[--Es],Cs[Es]=null}var vs=null,ys=null,tt=!1,$s=null;function hy(e,t){var n=Ds(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function tp(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,vs=e,ys=lr(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,vs=e,ys=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Vr!==null?{id:wn,overflow:Sn}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Ds(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,vs=e,ys=null,!0):!1;default:return!1}}function Zd(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Jd(e){if(tt){var t=ys;if(t){var n=t;if(!tp(e,t)){if(Zd(e))throw Error(Y(418));t=lr(n.nextSibling);var r=vs;t&&tp(e,t)?hy(r,n):(e.flags=e.flags&-4097|2,tt=!1,vs=e)}}else{if(Zd(e))throw Error(Y(418));e.flags=e.flags&-4097|2,tt=!1,vs=e}}}function sp(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;vs=e}function Wl(e){if(e!==vs)return!1;if(!tt)return sp(e),tt=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Qd(e.type,e.memoizedProps)),t&&(t=ys)){if(Zd(e))throw fy(),Error(Y(418));for(;t;)hy(e,t),t=lr(t.nextSibling)}if(sp(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Y(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){ys=lr(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}ys=null}}else ys=vs?lr(e.stateNode.nextSibling):null;return!0}function fy(){for(var e=ys;e;)e=lr(e.nextSibling)}function Va(){ys=vs=null,tt=!1}function bm(e){$s===null?$s=[e]:$s.push(e)}var Kb=Fn.ReactCurrentBatchConfig;function xi(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(Y(309));var r=n.stateNode}if(!r)throw Error(Y(147,e));var a=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(l){var o=a.refs;l===null?delete o[i]:o[i]=l},t._stringRef=i,t)}if(typeof e!="string")throw Error(Y(284));if(!n._owner)throw Error(Y(290,e))}return e}function Gl(e,t){throw e=Object.prototype.toString.call(t),Error(Y(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function np(e){var t=e._init;return t(e._payload)}function py(e){function t(g,y){if(e){var v=g.deletions;v===null?(g.deletions=[y],g.flags|=16):v.push(y)}}function n(g,y){if(!e)return null;for(;y!==null;)t(g,y),y=y.sibling;return null}function r(g,y){for(g=new Map;y!==null;)y.key!==null?g.set(y.key,y):g.set(y.index,y),y=y.sibling;return g}function a(g,y){return g=ur(g,y),g.index=0,g.sibling=null,g}function i(g,y,v){return g.index=v,e?(v=g.alternate,v!==null?(v=v.index,v<y?(g.flags|=2,y):v):(g.flags|=2,y)):(g.flags|=1048576,y)}function l(g){return e&&g.alternate===null&&(g.flags|=2),g}function o(g,y,v,N){return y===null||y.tag!==6?(y=cd(v,g.mode,N),y.return=g,y):(y=a(y,v),y.return=g,y)}function c(g,y,v,N){var E=v.type;return E===oa?u(g,y,v.props.children,N,v.key):y!==null&&(y.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===$n&&np(E)===y.type)?(N=a(y,v.props),N.ref=xi(g,y,v),N.return=g,N):(N=xo(v.type,v.key,v.props,null,g.mode,N),N.ref=xi(g,y,v),N.return=g,N)}function d(g,y,v,N){return y===null||y.tag!==4||y.stateNode.containerInfo!==v.containerInfo||y.stateNode.implementation!==v.implementation?(y=dd(v,g.mode,N),y.return=g,y):(y=a(y,v.children||[]),y.return=g,y)}function u(g,y,v,N,E){return y===null||y.tag!==7?(y=Kr(v,g.mode,N,E),y.return=g,y):(y=a(y,v),y.return=g,y)}function h(g,y,v){if(typeof y=="string"&&y!==""||typeof y=="number")return y=cd(""+y,g.mode,v),y.return=g,y;if(typeof y=="object"&&y!==null){switch(y.$$typeof){case zl:return v=xo(y.type,y.key,y.props,null,g.mode,v),v.ref=xi(g,null,y),v.return=g,v;case la:return y=dd(y,g.mode,v),y.return=g,y;case $n:var N=y._init;return h(g,N(y._payload),v)}if(Ni(y)||ui(y))return y=Kr(y,g.mode,v,null),y.return=g,y;Gl(g,y)}return null}function x(g,y,v,N){var E=y!==null?y.key:null;if(typeof v=="string"&&v!==""||typeof v=="number")return E!==null?null:o(g,y,""+v,N);if(typeof v=="object"&&v!==null){switch(v.$$typeof){case zl:return v.key===E?c(g,y,v,N):null;case la:return v.key===E?d(g,y,v,N):null;case $n:return E=v._init,x(g,y,E(v._payload),N)}if(Ni(v)||ui(v))return E!==null?null:u(g,y,v,N,null);Gl(g,v)}return null}function m(g,y,v,N,E){if(typeof N=="string"&&N!==""||typeof N=="number")return g=g.get(v)||null,o(y,g,""+N,E);if(typeof N=="object"&&N!==null){switch(N.$$typeof){case zl:return g=g.get(N.key===null?v:N.key)||null,c(y,g,N,E);case la:return g=g.get(N.key===null?v:N.key)||null,d(y,g,N,E);case $n:var P=N._init;return m(g,y,v,P(N._payload),E)}if(Ni(N)||ui(N))return g=g.get(v)||null,u(y,g,N,E,null);Gl(y,N)}return null}function f(g,y,v,N){for(var E=null,P=null,I=y,w=y=0,S=null;I!==null&&w<v.length;w++){I.index>w?(S=I,I=null):S=I.sibling;var A=x(g,I,v[w],N);if(A===null){I===null&&(I=S);break}e&&I&&A.alternate===null&&t(g,I),y=i(A,y,w),P===null?E=A:P.sibling=A,P=A,I=S}if(w===v.length)return n(g,I),tt&&Nr(g,w),E;if(I===null){for(;w<v.length;w++)I=h(g,v[w],N),I!==null&&(y=i(I,y,w),P===null?E=I:P.sibling=I,P=I);return tt&&Nr(g,w),E}for(I=r(g,I);w<v.length;w++)S=m(I,g,w,v[w],N),S!==null&&(e&&S.alternate!==null&&I.delete(S.key===null?w:S.key),y=i(S,y,w),P===null?E=S:P.sibling=S,P=S);return e&&I.forEach(function(O){return t(g,O)}),tt&&Nr(g,w),E}function p(g,y,v,N){var E=ui(v);if(typeof E!="function")throw Error(Y(150));if(v=E.call(v),v==null)throw Error(Y(151));for(var P=E=null,I=y,w=y=0,S=null,A=v.next();I!==null&&!A.done;w++,A=v.next()){I.index>w?(S=I,I=null):S=I.sibling;var O=x(g,I,A.value,N);if(O===null){I===null&&(I=S);break}e&&I&&O.alternate===null&&t(g,I),y=i(O,y,w),P===null?E=O:P.sibling=O,P=O,I=S}if(A.done)return n(g,I),tt&&Nr(g,w),E;if(I===null){for(;!A.done;w++,A=v.next())A=h(g,A.value,N),A!==null&&(y=i(A,y,w),P===null?E=A:P.sibling=A,P=A);return tt&&Nr(g,w),E}for(I=r(g,I);!A.done;w++,A=v.next())A=m(I,g,w,A.value,N),A!==null&&(e&&A.alternate!==null&&I.delete(A.key===null?w:A.key),y=i(A,y,w),P===null?E=A:P.sibling=A,P=A);return e&&I.forEach(function(R){return t(g,R)}),tt&&Nr(g,w),E}function b(g,y,v,N){if(typeof v=="object"&&v!==null&&v.type===oa&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case zl:e:{for(var E=v.key,P=y;P!==null;){if(P.key===E){if(E=v.type,E===oa){if(P.tag===7){n(g,P.sibling),y=a(P,v.props.children),y.return=g,g=y;break e}}else if(P.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===$n&&np(E)===P.type){n(g,P.sibling),y=a(P,v.props),y.ref=xi(g,P,v),y.return=g,g=y;break e}n(g,P);break}else t(g,P);P=P.sibling}v.type===oa?(y=Kr(v.props.children,g.mode,N,v.key),y.return=g,g=y):(N=xo(v.type,v.key,v.props,null,g.mode,N),N.ref=xi(g,y,v),N.return=g,g=N)}return l(g);case la:e:{for(P=v.key;y!==null;){if(y.key===P)if(y.tag===4&&y.stateNode.containerInfo===v.containerInfo&&y.stateNode.implementation===v.implementation){n(g,y.sibling),y=a(y,v.children||[]),y.return=g,g=y;break e}else{n(g,y);break}else t(g,y);y=y.sibling}y=dd(v,g.mode,N),y.return=g,g=y}return l(g);case $n:return P=v._init,b(g,y,P(v._payload),N)}if(Ni(v))return f(g,y,v,N);if(ui(v))return p(g,y,v,N);Gl(g,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,y!==null&&y.tag===6?(n(g,y.sibling),y=a(y,v),y.return=g,g=y):(n(g,y),y=cd(v,g.mode,N),y.return=g,g=y),l(g)):n(g,y)}return b}var Qa=py(!0),xy=py(!1),Lo=yr(null),Oo=null,xa=null,Nm=null;function wm(){Nm=xa=Oo=null}function Sm(e){var t=Lo.current;Je(Lo),e._currentValue=t}function Xd(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Sa(e,t){Oo=e,Nm=xa=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ls=!0),e.firstContext=null)}function Ts(e){var t=e._currentValue;if(Nm!==e)if(e={context:e,memoizedValue:t,next:null},xa===null){if(Oo===null)throw Error(Y(308));xa=e,Oo.dependencies={lanes:0,firstContext:e}}else xa=xa.next=e;return t}var Cr=null;function km(e){Cr===null?Cr=[e]:Cr.push(e)}function gy(e,t,n,r){var a=t.interleaved;return a===null?(n.next=n,km(t)):(n.next=a.next,a.next=n),t.interleaved=n,Pn(e,r)}function Pn(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var _n=!1;function Cm(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function yy(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Cn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function or(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Te&2){var a=r.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),r.pending=t,Pn(e,n)}return a=r.interleaved,a===null?(t.next=t,km(r)):(t.next=a.next,a.next=t),r.interleaved=t,Pn(e,n)}function co(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,um(e,n)}}function rp(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var a=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?a=i=l:i=i.next=l,n=n.next}while(n!==null);i===null?a=i=t:i=i.next=t}else a=i=t;n={baseState:r.baseState,firstBaseUpdate:a,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function zo(e,t,n,r){var a=e.updateQueue;_n=!1;var i=a.firstBaseUpdate,l=a.lastBaseUpdate,o=a.shared.pending;if(o!==null){a.shared.pending=null;var c=o,d=c.next;c.next=null,l===null?i=d:l.next=d,l=c;var u=e.alternate;u!==null&&(u=u.updateQueue,o=u.lastBaseUpdate,o!==l&&(o===null?u.firstBaseUpdate=d:o.next=d,u.lastBaseUpdate=c))}if(i!==null){var h=a.baseState;l=0,u=d=c=null,o=i;do{var x=o.lane,m=o.eventTime;if((r&x)===x){u!==null&&(u=u.next={eventTime:m,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var f=e,p=o;switch(x=t,m=n,p.tag){case 1:if(f=p.payload,typeof f=="function"){h=f.call(m,h,x);break e}h=f;break e;case 3:f.flags=f.flags&-65537|128;case 0:if(f=p.payload,x=typeof f=="function"?f.call(m,h,x):f,x==null)break e;h=ot({},h,x);break e;case 2:_n=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,x=a.effects,x===null?a.effects=[o]:x.push(o))}else m={eventTime:m,lane:x,tag:o.tag,payload:o.payload,callback:o.callback,next:null},u===null?(d=u=m,c=h):u=u.next=m,l|=x;if(o=o.next,o===null){if(o=a.shared.pending,o===null)break;x=o,o=x.next,x.next=null,a.lastBaseUpdate=x,a.shared.pending=null}}while(!0);if(u===null&&(c=h),a.baseState=c,a.firstBaseUpdate=d,a.lastBaseUpdate=u,t=a.shared.interleaved,t!==null){a=t;do l|=a.lane,a=a.next;while(a!==t)}else i===null&&(a.shared.lanes=0);Hr|=l,e.lanes=l,e.memoizedState=h}}function ap(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],a=r.callback;if(a!==null){if(r.callback=null,r=n,typeof a!="function")throw Error(Y(191,a));a.call(r)}}}var kl={},an=yr(kl),Zi=yr(kl),Ji=yr(kl);function Er(e){if(e===kl)throw Error(Y(174));return e}function Em(e,t){switch(Qe(Ji,t),Qe(Zi,e),Qe(an,kl),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Td(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Td(t,e)}Je(an),Qe(an,t)}function Ha(){Je(an),Je(Zi),Je(Ji)}function vy(e){Er(Ji.current);var t=Er(an.current),n=Td(t,e.type);t!==n&&(Qe(Zi,e),Qe(an,n))}function Dm(e){Zi.current===e&&(Je(an),Je(Zi))}var at=yr(0);function $o(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var nd=[];function Am(){for(var e=0;e<nd.length;e++)nd[e]._workInProgressVersionPrimary=null;nd.length=0}var uo=Fn.ReactCurrentDispatcher,rd=Fn.ReactCurrentBatchConfig,Qr=0,it=null,Nt=null,Et=null,_o=!1,Ti=!1,Xi=0,Bb=0;function zt(){throw Error(Y(321))}function Pm(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!qs(e[n],t[n]))return!1;return!0}function Mm(e,t,n,r,a,i){if(Qr=i,it=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,uo.current=e===null||e.memoizedState===null?Qb:Hb,e=n(r,a),Ti){i=0;do{if(Ti=!1,Xi=0,25<=i)throw Error(Y(301));i+=1,Et=Nt=null,t.updateQueue=null,uo.current=Wb,e=n(r,a)}while(Ti)}if(uo.current=Ko,t=Nt!==null&&Nt.next!==null,Qr=0,Et=Nt=it=null,_o=!1,t)throw Error(Y(300));return e}function Tm(){var e=Xi!==0;return Xi=0,e}function Zs(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Et===null?it.memoizedState=Et=e:Et=Et.next=e,Et}function Fs(){if(Nt===null){var e=it.alternate;e=e!==null?e.memoizedState:null}else e=Nt.next;var t=Et===null?it.memoizedState:Et.next;if(t!==null)Et=t,Nt=e;else{if(e===null)throw Error(Y(310));Nt=e,e={memoizedState:Nt.memoizedState,baseState:Nt.baseState,baseQueue:Nt.baseQueue,queue:Nt.queue,next:null},Et===null?it.memoizedState=Et=e:Et=Et.next=e}return Et}function Yi(e,t){return typeof t=="function"?t(e):t}function ad(e){var t=Fs(),n=t.queue;if(n===null)throw Error(Y(311));n.lastRenderedReducer=e;var r=Nt,a=r.baseQueue,i=n.pending;if(i!==null){if(a!==null){var l=a.next;a.next=i.next,i.next=l}r.baseQueue=a=i,n.pending=null}if(a!==null){i=a.next,r=r.baseState;var o=l=null,c=null,d=i;do{var u=d.lane;if((Qr&u)===u)c!==null&&(c=c.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),r=d.hasEagerState?d.eagerState:e(r,d.action);else{var h={lane:u,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(o=c=h,l=r):c=c.next=h,it.lanes|=u,Hr|=u}d=d.next}while(d!==null&&d!==i);c===null?l=r:c.next=o,qs(r,t.memoizedState)||(ls=!0),t.memoizedState=r,t.baseState=l,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){a=e;do i=a.lane,it.lanes|=i,Hr|=i,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function id(e){var t=Fs(),n=t.queue;if(n===null)throw Error(Y(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,i=t.memoizedState;if(a!==null){n.pending=null;var l=a=a.next;do i=e(i,l.action),l=l.next;while(l!==a);qs(i,t.memoizedState)||(ls=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function jy(){}function by(e,t){var n=it,r=Fs(),a=t(),i=!qs(r.memoizedState,a);if(i&&(r.memoizedState=a,ls=!0),r=r.queue,Fm(Sy.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||Et!==null&&Et.memoizedState.tag&1){if(n.flags|=2048,el(9,wy.bind(null,n,r,a,t),void 0,null),Pt===null)throw Error(Y(349));Qr&30||Ny(n,t,a)}return a}function Ny(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=it.updateQueue,t===null?(t={lastEffect:null,stores:null},it.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function wy(e,t,n,r){t.value=n,t.getSnapshot=r,ky(t)&&Cy(e)}function Sy(e,t,n){return n(function(){ky(t)&&Cy(e)})}function ky(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!qs(e,n)}catch{return!0}}function Cy(e){var t=Pn(e,1);t!==null&&Us(t,e,1,-1)}function ip(e){var t=Zs();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Yi,lastRenderedState:e},t.queue=e,e=e.dispatch=Vb.bind(null,it,e),[t.memoizedState,e]}function el(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=it.updateQueue,t===null?(t={lastEffect:null,stores:null},it.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function Ey(){return Fs().memoizedState}function mo(e,t,n,r){var a=Zs();it.flags|=e,a.memoizedState=el(1|t,n,void 0,r===void 0?null:r)}function uc(e,t,n,r){var a=Fs();r=r===void 0?null:r;var i=void 0;if(Nt!==null){var l=Nt.memoizedState;if(i=l.destroy,r!==null&&Pm(r,l.deps)){a.memoizedState=el(t,n,i,r);return}}it.flags|=e,a.memoizedState=el(1|t,n,i,r)}function lp(e,t){return mo(8390656,8,e,t)}function Fm(e,t){return uc(2048,8,e,t)}function Dy(e,t){return uc(4,2,e,t)}function Ay(e,t){return uc(4,4,e,t)}function Py(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function My(e,t,n){return n=n!=null?n.concat([e]):null,uc(4,4,Py.bind(null,t,e),n)}function Im(){}function Ty(e,t){var n=Fs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Pm(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Fy(e,t){var n=Fs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Pm(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Iy(e,t,n){return Qr&21?(qs(n,t)||(n=$g(),it.lanes|=n,Hr|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ls=!0),e.memoizedState=n)}function Ub(e,t){var n=Ue;Ue=n!==0&&4>n?n:4,e(!0);var r=rd.transition;rd.transition={};try{e(!1),t()}finally{Ue=n,rd.transition=r}}function Ry(){return Fs().memoizedState}function qb(e,t,n){var r=dr(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ly(e))Oy(t,n);else if(n=gy(e,t,n,r),n!==null){var a=Zt();Us(n,e,r,a),zy(n,t,r)}}function Vb(e,t,n){var r=dr(e),a={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ly(e))Oy(t,a);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var l=t.lastRenderedState,o=i(l,n);if(a.hasEagerState=!0,a.eagerState=o,qs(o,l)){var c=t.interleaved;c===null?(a.next=a,km(t)):(a.next=c.next,c.next=a),t.interleaved=a;return}}catch{}finally{}n=gy(e,t,a,r),n!==null&&(a=Zt(),Us(n,e,r,a),zy(n,t,r))}}function Ly(e){var t=e.alternate;return e===it||t!==null&&t===it}function Oy(e,t){Ti=_o=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function zy(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,um(e,n)}}var Ko={readContext:Ts,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useInsertionEffect:zt,useLayoutEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useMutableSource:zt,useSyncExternalStore:zt,useId:zt,unstable_isNewReconciler:!1},Qb={readContext:Ts,useCallback:function(e,t){return Zs().memoizedState=[e,t===void 0?null:t],e},useContext:Ts,useEffect:lp,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,mo(4194308,4,Py.bind(null,t,e),n)},useLayoutEffect:function(e,t){return mo(4194308,4,e,t)},useInsertionEffect:function(e,t){return mo(4,2,e,t)},useMemo:function(e,t){var n=Zs();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Zs();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=qb.bind(null,it,e),[r.memoizedState,e]},useRef:function(e){var t=Zs();return e={current:e},t.memoizedState=e},useState:ip,useDebugValue:Im,useDeferredValue:function(e){return Zs().memoizedState=e},useTransition:function(){var e=ip(!1),t=e[0];return e=Ub.bind(null,e[1]),Zs().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=it,a=Zs();if(tt){if(n===void 0)throw Error(Y(407));n=n()}else{if(n=t(),Pt===null)throw Error(Y(349));Qr&30||Ny(r,t,n)}a.memoizedState=n;var i={value:n,getSnapshot:t};return a.queue=i,lp(Sy.bind(null,r,i,e),[e]),r.flags|=2048,el(9,wy.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Zs(),t=Pt.identifierPrefix;if(tt){var n=Sn,r=wn;n=(r&~(1<<32-Bs(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Xi++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=Bb++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Hb={readContext:Ts,useCallback:Ty,useContext:Ts,useEffect:Fm,useImperativeHandle:My,useInsertionEffect:Dy,useLayoutEffect:Ay,useMemo:Fy,useReducer:ad,useRef:Ey,useState:function(){return ad(Yi)},useDebugValue:Im,useDeferredValue:function(e){var t=Fs();return Iy(t,Nt.memoizedState,e)},useTransition:function(){var e=ad(Yi)[0],t=Fs().memoizedState;return[e,t]},useMutableSource:jy,useSyncExternalStore:by,useId:Ry,unstable_isNewReconciler:!1},Wb={readContext:Ts,useCallback:Ty,useContext:Ts,useEffect:Fm,useImperativeHandle:My,useInsertionEffect:Dy,useLayoutEffect:Ay,useMemo:Fy,useReducer:id,useRef:Ey,useState:function(){return id(Yi)},useDebugValue:Im,useDeferredValue:function(e){var t=Fs();return Nt===null?t.memoizedState=e:Iy(t,Nt.memoizedState,e)},useTransition:function(){var e=id(Yi)[0],t=Fs().memoizedState;return[e,t]},useMutableSource:jy,useSyncExternalStore:by,useId:Ry,unstable_isNewReconciler:!1};function Rs(e,t){if(e&&e.defaultProps){t=ot({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Yd(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:ot({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var mc={isMounted:function(e){return(e=e._reactInternals)?ea(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Zt(),a=dr(e),i=Cn(r,a);i.payload=t,n!=null&&(i.callback=n),t=or(e,i,a),t!==null&&(Us(t,e,a,r),co(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Zt(),a=dr(e),i=Cn(r,a);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=or(e,i,a),t!==null&&(Us(t,e,a,r),co(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Zt(),r=dr(e),a=Cn(n,r);a.tag=2,t!=null&&(a.callback=t),t=or(e,a,r),t!==null&&(Us(t,e,r,n),co(t,e,r))}};function op(e,t,n,r,a,i,l){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,l):t.prototype&&t.prototype.isPureReactComponent?!Qi(n,r)||!Qi(a,i):!0}function $y(e,t,n){var r=!1,a=pr,i=t.contextType;return typeof i=="object"&&i!==null?i=Ts(i):(a=cs(t)?qr:Ut.current,r=t.contextTypes,i=(r=r!=null)?qa(e,a):pr),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=mc,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=i),t}function cp(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&mc.enqueueReplaceState(t,t.state,null)}function eu(e,t,n,r){var a=e.stateNode;a.props=n,a.state=e.memoizedState,a.refs={},Cm(e);var i=t.contextType;typeof i=="object"&&i!==null?a.context=Ts(i):(i=cs(t)?qr:Ut.current,a.context=qa(e,i)),a.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(Yd(e,t,i,n),a.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof a.getSnapshotBeforeUpdate=="function"||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(t=a.state,typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount(),t!==a.state&&mc.enqueueReplaceState(a,a.state,null),zo(e,n,a,r),a.state=e.memoizedState),typeof a.componentDidMount=="function"&&(e.flags|=4194308)}function Wa(e,t){try{var n="",r=t;do n+=Nj(r),r=r.return;while(r);var a=n}catch(i){a=`
|
||
Error generating stack: `+i.message+`
|
||
`+i.stack}return{value:e,source:t,stack:a,digest:null}}function ld(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function tu(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Gb=typeof WeakMap=="function"?WeakMap:Map;function _y(e,t,n){n=Cn(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Uo||(Uo=!0,uu=r),tu(e,t)},n}function Ky(e,t,n){n=Cn(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var a=t.value;n.payload=function(){return r(a)},n.callback=function(){tu(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){tu(e,t),typeof r!="function"&&(cr===null?cr=new Set([this]):cr.add(this));var l=t.stack;this.componentDidCatch(t.value,{componentStack:l!==null?l:""})}),n}function dp(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Gb;var a=new Set;r.set(t,a)}else a=r.get(t),a===void 0&&(a=new Set,r.set(t,a));a.has(n)||(a.add(n),e=cN.bind(null,e,t,n),t.then(e,e))}function up(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function mp(e,t,n,r,a){return e.mode&1?(e.flags|=65536,e.lanes=a,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Cn(-1,1),t.tag=2,or(n,t,1))),n.lanes|=1),e)}var Zb=Fn.ReactCurrentOwner,ls=!1;function Gt(e,t,n,r){t.child=e===null?xy(t,null,n,r):Qa(t,e.child,n,r)}function hp(e,t,n,r,a){n=n.render;var i=t.ref;return Sa(t,a),r=Mm(e,t,n,r,i,a),n=Tm(),e!==null&&!ls?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Mn(e,t,a)):(tt&&n&&vm(t),t.flags|=1,Gt(e,t,r,a),t.child)}function fp(e,t,n,r,a){if(e===null){var i=n.type;return typeof i=="function"&&!Bm(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,By(e,t,i,r,a)):(e=xo(n.type,null,r,t,t.mode,a),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&a)){var l=i.memoizedProps;if(n=n.compare,n=n!==null?n:Qi,n(l,r)&&e.ref===t.ref)return Mn(e,t,a)}return t.flags|=1,e=ur(i,r),e.ref=t.ref,e.return=t,t.child=e}function By(e,t,n,r,a){if(e!==null){var i=e.memoizedProps;if(Qi(i,r)&&e.ref===t.ref)if(ls=!1,t.pendingProps=r=i,(e.lanes&a)!==0)e.flags&131072&&(ls=!0);else return t.lanes=e.lanes,Mn(e,t,a)}return su(e,t,n,r,a)}function Uy(e,t,n){var r=t.pendingProps,a=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Qe(ya,ps),ps|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Qe(ya,ps),ps|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,Qe(ya,ps),ps|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,Qe(ya,ps),ps|=r;return Gt(e,t,a,n),t.child}function qy(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function su(e,t,n,r,a){var i=cs(n)?qr:Ut.current;return i=qa(t,i),Sa(t,a),n=Mm(e,t,n,r,i,a),r=Tm(),e!==null&&!ls?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Mn(e,t,a)):(tt&&r&&vm(t),t.flags|=1,Gt(e,t,n,a),t.child)}function pp(e,t,n,r,a){if(cs(n)){var i=!0;Fo(t)}else i=!1;if(Sa(t,a),t.stateNode===null)ho(e,t),$y(t,n,r),eu(t,n,r,a),r=!0;else if(e===null){var l=t.stateNode,o=t.memoizedProps;l.props=o;var c=l.context,d=n.contextType;typeof d=="object"&&d!==null?d=Ts(d):(d=cs(n)?qr:Ut.current,d=qa(t,d));var u=n.getDerivedStateFromProps,h=typeof u=="function"||typeof l.getSnapshotBeforeUpdate=="function";h||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(o!==r||c!==d)&&cp(t,l,r,d),_n=!1;var x=t.memoizedState;l.state=x,zo(t,r,l,a),c=t.memoizedState,o!==r||x!==c||os.current||_n?(typeof u=="function"&&(Yd(t,n,u,r),c=t.memoizedState),(o=_n||op(t,n,o,r,x,c,d))?(h||typeof l.UNSAFE_componentWillMount!="function"&&typeof l.componentWillMount!="function"||(typeof l.componentWillMount=="function"&&l.componentWillMount(),typeof l.UNSAFE_componentWillMount=="function"&&l.UNSAFE_componentWillMount()),typeof l.componentDidMount=="function"&&(t.flags|=4194308)):(typeof l.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),l.props=r,l.state=c,l.context=d,r=o):(typeof l.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{l=t.stateNode,yy(e,t),o=t.memoizedProps,d=t.type===t.elementType?o:Rs(t.type,o),l.props=d,h=t.pendingProps,x=l.context,c=n.contextType,typeof c=="object"&&c!==null?c=Ts(c):(c=cs(n)?qr:Ut.current,c=qa(t,c));var m=n.getDerivedStateFromProps;(u=typeof m=="function"||typeof l.getSnapshotBeforeUpdate=="function")||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(o!==h||x!==c)&&cp(t,l,r,c),_n=!1,x=t.memoizedState,l.state=x,zo(t,r,l,a);var f=t.memoizedState;o!==h||x!==f||os.current||_n?(typeof m=="function"&&(Yd(t,n,m,r),f=t.memoizedState),(d=_n||op(t,n,d,r,x,f,c)||!1)?(u||typeof l.UNSAFE_componentWillUpdate!="function"&&typeof l.componentWillUpdate!="function"||(typeof l.componentWillUpdate=="function"&&l.componentWillUpdate(r,f,c),typeof l.UNSAFE_componentWillUpdate=="function"&&l.UNSAFE_componentWillUpdate(r,f,c)),typeof l.componentDidUpdate=="function"&&(t.flags|=4),typeof l.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof l.componentDidUpdate!="function"||o===e.memoizedProps&&x===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&x===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=f),l.props=r,l.state=f,l.context=c,r=d):(typeof l.componentDidUpdate!="function"||o===e.memoizedProps&&x===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&x===e.memoizedState||(t.flags|=1024),r=!1)}return nu(e,t,n,r,i,a)}function nu(e,t,n,r,a,i){qy(e,t);var l=(t.flags&128)!==0;if(!r&&!l)return a&&ep(t,n,!1),Mn(e,t,i);r=t.stateNode,Zb.current=t;var o=l&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&l?(t.child=Qa(t,e.child,null,i),t.child=Qa(t,null,o,i)):Gt(e,t,o,i),t.memoizedState=r.state,a&&ep(t,n,!0),t.child}function Vy(e){var t=e.stateNode;t.pendingContext?Yf(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Yf(e,t.context,!1),Em(e,t.containerInfo)}function xp(e,t,n,r,a){return Va(),bm(a),t.flags|=256,Gt(e,t,n,r),t.child}var ru={dehydrated:null,treeContext:null,retryLane:0};function au(e){return{baseLanes:e,cachePool:null,transitions:null}}function Qy(e,t,n){var r=t.pendingProps,a=at.current,i=!1,l=(t.flags&128)!==0,o;if((o=l)||(o=e!==null&&e.memoizedState===null?!1:(a&2)!==0),o?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(a|=1),Qe(at,a&1),e===null)return Jd(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(l=r.children,e=r.fallback,i?(r=t.mode,i=t.child,l={mode:"hidden",children:l},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=l):i=pc(l,r,0,null),e=Kr(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=au(n),t.memoizedState=ru,e):Rm(t,l));if(a=e.memoizedState,a!==null&&(o=a.dehydrated,o!==null))return Jb(e,t,l,r,o,a,n);if(i){i=r.fallback,l=t.mode,a=e.child,o=a.sibling;var c={mode:"hidden",children:r.children};return!(l&1)&&t.child!==a?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=ur(a,c),r.subtreeFlags=a.subtreeFlags&14680064),o!==null?i=ur(o,i):(i=Kr(i,l,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,l=e.child.memoizedState,l=l===null?au(n):{baseLanes:l.baseLanes|n,cachePool:null,transitions:l.transitions},i.memoizedState=l,i.childLanes=e.childLanes&~n,t.memoizedState=ru,r}return i=e.child,e=i.sibling,r=ur(i,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Rm(e,t){return t=pc({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Zl(e,t,n,r){return r!==null&&bm(r),Qa(t,e.child,null,n),e=Rm(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Jb(e,t,n,r,a,i,l){if(n)return t.flags&256?(t.flags&=-257,r=ld(Error(Y(422))),Zl(e,t,l,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,a=t.mode,r=pc({mode:"visible",children:r.children},a,0,null),i=Kr(i,a,l,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&Qa(t,e.child,null,l),t.child.memoizedState=au(l),t.memoizedState=ru,i);if(!(t.mode&1))return Zl(e,t,l,null);if(a.data==="$!"){if(r=a.nextSibling&&a.nextSibling.dataset,r)var o=r.dgst;return r=o,i=Error(Y(419)),r=ld(i,r,void 0),Zl(e,t,l,r)}if(o=(l&e.childLanes)!==0,ls||o){if(r=Pt,r!==null){switch(l&-l){case 4:a=2;break;case 16:a=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=a&(r.suspendedLanes|l)?0:a,a!==0&&a!==i.retryLane&&(i.retryLane=a,Pn(e,a),Us(r,e,a,-1))}return Km(),r=ld(Error(Y(421))),Zl(e,t,l,r)}return a.data==="$?"?(t.flags|=128,t.child=e.child,t=dN.bind(null,e),a._reactRetry=t,null):(e=i.treeContext,ys=lr(a.nextSibling),vs=t,tt=!0,$s=null,e!==null&&(Cs[Es++]=wn,Cs[Es++]=Sn,Cs[Es++]=Vr,wn=e.id,Sn=e.overflow,Vr=t),t=Rm(t,r.children),t.flags|=4096,t)}function gp(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Xd(e.return,t,n)}function od(e,t,n,r,a){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:a}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=a)}function Hy(e,t,n){var r=t.pendingProps,a=r.revealOrder,i=r.tail;if(Gt(e,t,r.children,n),r=at.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&gp(e,n,t);else if(e.tag===19)gp(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Qe(at,r),!(t.mode&1))t.memoizedState=null;else switch(a){case"forwards":for(n=t.child,a=null;n!==null;)e=n.alternate,e!==null&&$o(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),od(t,!1,a,n,i);break;case"backwards":for(n=null,a=t.child,t.child=null;a!==null;){if(e=a.alternate,e!==null&&$o(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}od(t,!0,n,null,i);break;case"together":od(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function ho(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Mn(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Hr|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Y(153));if(t.child!==null){for(e=t.child,n=ur(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ur(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Xb(e,t,n){switch(t.tag){case 3:Vy(t),Va();break;case 5:vy(t);break;case 1:cs(t.type)&&Fo(t);break;case 4:Em(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,a=t.memoizedProps.value;Qe(Lo,r._currentValue),r._currentValue=a;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Qe(at,at.current&1),t.flags|=128,null):n&t.child.childLanes?Qy(e,t,n):(Qe(at,at.current&1),e=Mn(e,t,n),e!==null?e.sibling:null);Qe(at,at.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Hy(e,t,n);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),Qe(at,at.current),r)break;return null;case 22:case 23:return t.lanes=0,Uy(e,t,n)}return Mn(e,t,n)}var Wy,iu,Gy,Zy;Wy=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};iu=function(){};Gy=function(e,t,n,r){var a=e.memoizedProps;if(a!==r){e=t.stateNode,Er(an.current);var i=null;switch(n){case"input":a=Dd(e,a),r=Dd(e,r),i=[];break;case"select":a=ot({},a,{value:void 0}),r=ot({},r,{value:void 0}),i=[];break;case"textarea":a=Md(e,a),r=Md(e,r),i=[];break;default:typeof a.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Mo)}Fd(n,r);var l;n=null;for(d in a)if(!r.hasOwnProperty(d)&&a.hasOwnProperty(d)&&a[d]!=null)if(d==="style"){var o=a[d];for(l in o)o.hasOwnProperty(l)&&(n||(n={}),n[l]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&($i.hasOwnProperty(d)?i||(i=[]):(i=i||[]).push(d,null));for(d in r){var c=r[d];if(o=a!=null?a[d]:void 0,r.hasOwnProperty(d)&&c!==o&&(c!=null||o!=null))if(d==="style")if(o){for(l in o)!o.hasOwnProperty(l)||c&&c.hasOwnProperty(l)||(n||(n={}),n[l]="");for(l in c)c.hasOwnProperty(l)&&o[l]!==c[l]&&(n||(n={}),n[l]=c[l])}else n||(i||(i=[]),i.push(d,n)),n=c;else d==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,o=o?o.__html:void 0,c!=null&&o!==c&&(i=i||[]).push(d,c)):d==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(d,""+c):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&($i.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&Ze("scroll",e),i||o===c||(i=[])):(i=i||[]).push(d,c))}n&&(i=i||[]).push("style",n);var d=i;(t.updateQueue=d)&&(t.flags|=4)}};Zy=function(e,t,n,r){n!==r&&(t.flags|=4)};function gi(e,t){if(!tt)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function $t(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var a=e.child;a!==null;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags&14680064,r|=a.flags&14680064,a.return=e,a=a.sibling;else for(a=e.child;a!==null;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags,r|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Yb(e,t,n){var r=t.pendingProps;switch(jm(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return $t(t),null;case 1:return cs(t.type)&&To(),$t(t),null;case 3:return r=t.stateNode,Ha(),Je(os),Je(Ut),Am(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Wl(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,$s!==null&&(fu($s),$s=null))),iu(e,t),$t(t),null;case 5:Dm(t);var a=Er(Ji.current);if(n=t.type,e!==null&&t.stateNode!=null)Gy(e,t,n,r,a),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Y(166));return $t(t),null}if(e=Er(an.current),Wl(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[tn]=t,r[Gi]=i,e=(t.mode&1)!==0,n){case"dialog":Ze("cancel",r),Ze("close",r);break;case"iframe":case"object":case"embed":Ze("load",r);break;case"video":case"audio":for(a=0;a<Si.length;a++)Ze(Si[a],r);break;case"source":Ze("error",r);break;case"img":case"image":case"link":Ze("error",r),Ze("load",r);break;case"details":Ze("toggle",r);break;case"input":Cf(r,i),Ze("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},Ze("invalid",r);break;case"textarea":Df(r,i),Ze("invalid",r)}Fd(n,i),a=null;for(var l in i)if(i.hasOwnProperty(l)){var o=i[l];l==="children"?typeof o=="string"?r.textContent!==o&&(i.suppressHydrationWarning!==!0&&Hl(r.textContent,o,e),a=["children",o]):typeof o=="number"&&r.textContent!==""+o&&(i.suppressHydrationWarning!==!0&&Hl(r.textContent,o,e),a=["children",""+o]):$i.hasOwnProperty(l)&&o!=null&&l==="onScroll"&&Ze("scroll",r)}switch(n){case"input":$l(r),Ef(r,i,!0);break;case"textarea":$l(r),Af(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=Mo)}r=a,t.updateQueue=r,r!==null&&(t.flags|=4)}else{l=a.nodeType===9?a:a.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Sg(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=l.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[tn]=t,e[Gi]=r,Wy(e,t,!1,!1),t.stateNode=e;e:{switch(l=Id(n,r),n){case"dialog":Ze("cancel",e),Ze("close",e),a=r;break;case"iframe":case"object":case"embed":Ze("load",e),a=r;break;case"video":case"audio":for(a=0;a<Si.length;a++)Ze(Si[a],e);a=r;break;case"source":Ze("error",e),a=r;break;case"img":case"image":case"link":Ze("error",e),Ze("load",e),a=r;break;case"details":Ze("toggle",e),a=r;break;case"input":Cf(e,r),a=Dd(e,r),Ze("invalid",e);break;case"option":a=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},a=ot({},r,{value:void 0}),Ze("invalid",e);break;case"textarea":Df(e,r),a=Md(e,r),Ze("invalid",e);break;default:a=r}Fd(n,a),o=a;for(i in o)if(o.hasOwnProperty(i)){var c=o[i];i==="style"?Eg(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&kg(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&_i(e,c):typeof c=="number"&&_i(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&($i.hasOwnProperty(i)?c!=null&&i==="onScroll"&&Ze("scroll",e):c!=null&&am(e,i,c,l))}switch(n){case"input":$l(e),Ef(e,r,!1);break;case"textarea":$l(e),Af(e);break;case"option":r.value!=null&&e.setAttribute("value",""+fr(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?ja(e,!!r.multiple,i,!1):r.defaultValue!=null&&ja(e,!!r.multiple,r.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=Mo)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return $t(t),null;case 6:if(e&&t.stateNode!=null)Zy(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Y(166));if(n=Er(Ji.current),Er(an.current),Wl(t)){if(r=t.stateNode,n=t.memoizedProps,r[tn]=t,(i=r.nodeValue!==n)&&(e=vs,e!==null))switch(e.tag){case 3:Hl(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Hl(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[tn]=t,t.stateNode=r}return $t(t),null;case 13:if(Je(at),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(tt&&ys!==null&&t.mode&1&&!(t.flags&128))fy(),Va(),t.flags|=98560,i=!1;else if(i=Wl(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(Y(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(Y(317));i[tn]=t}else Va(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;$t(t),i=!1}else $s!==null&&(fu($s),$s=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||at.current&1?St===0&&(St=3):Km())),t.updateQueue!==null&&(t.flags|=4),$t(t),null);case 4:return Ha(),iu(e,t),e===null&&Hi(t.stateNode.containerInfo),$t(t),null;case 10:return Sm(t.type._context),$t(t),null;case 17:return cs(t.type)&&To(),$t(t),null;case 19:if(Je(at),i=t.memoizedState,i===null)return $t(t),null;if(r=(t.flags&128)!==0,l=i.rendering,l===null)if(r)gi(i,!1);else{if(St!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(l=$o(e),l!==null){for(t.flags|=128,gi(i,!1),r=l.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)i=n,e=r,i.flags&=14680066,l=i.alternate,l===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=l.childLanes,i.lanes=l.lanes,i.child=l.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=l.memoizedProps,i.memoizedState=l.memoizedState,i.updateQueue=l.updateQueue,i.type=l.type,e=l.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return Qe(at,at.current&1|2),t.child}e=e.sibling}i.tail!==null&&ft()>Ga&&(t.flags|=128,r=!0,gi(i,!1),t.lanes=4194304)}else{if(!r)if(e=$o(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),gi(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!tt)return $t(t),null}else 2*ft()-i.renderingStartTime>Ga&&n!==1073741824&&(t.flags|=128,r=!0,gi(i,!1),t.lanes=4194304);i.isBackwards?(l.sibling=t.child,t.child=l):(n=i.last,n!==null?n.sibling=l:t.child=l,i.last=l)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=ft(),t.sibling=null,n=at.current,Qe(at,r?n&1|2:n&1),t):($t(t),null);case 22:case 23:return _m(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ps&1073741824&&($t(t),t.subtreeFlags&6&&(t.flags|=8192)):$t(t),null;case 24:return null;case 25:return null}throw Error(Y(156,t.tag))}function eN(e,t){switch(jm(t),t.tag){case 1:return cs(t.type)&&To(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ha(),Je(os),Je(Ut),Am(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Dm(t),null;case 13:if(Je(at),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Y(340));Va()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Je(at),null;case 4:return Ha(),null;case 10:return Sm(t.type._context),null;case 22:case 23:return _m(),null;case 24:return null;default:return null}}var Jl=!1,Kt=!1,tN=typeof WeakSet=="function"?WeakSet:Set,he=null;function ga(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){mt(e,t,r)}else n.current=null}function lu(e,t,n){try{n()}catch(r){mt(e,t,r)}}var yp=!1;function sN(e,t){if(qd=Do,e=ty(),ym(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var l=0,o=-1,c=-1,d=0,u=0,h=e,x=null;t:for(;;){for(var m;h!==n||a!==0&&h.nodeType!==3||(o=l+a),h!==i||r!==0&&h.nodeType!==3||(c=l+r),h.nodeType===3&&(l+=h.nodeValue.length),(m=h.firstChild)!==null;)x=h,h=m;for(;;){if(h===e)break t;if(x===n&&++d===a&&(o=l),x===i&&++u===r&&(c=l),(m=h.nextSibling)!==null)break;h=x,x=h.parentNode}h=m}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Vd={focusedElem:e,selectionRange:n},Do=!1,he=t;he!==null;)if(t=he,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,he=e;else for(;he!==null;){t=he;try{var f=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(f!==null){var p=f.memoizedProps,b=f.memoizedState,g=t.stateNode,y=g.getSnapshotBeforeUpdate(t.elementType===t.type?p:Rs(t.type,p),b);g.__reactInternalSnapshotBeforeUpdate=y}break;case 3:var v=t.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Y(163))}}catch(N){mt(t,t.return,N)}if(e=t.sibling,e!==null){e.return=t.return,he=e;break}he=t.return}return f=yp,yp=!1,f}function Fi(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var a=r=r.next;do{if((a.tag&e)===e){var i=a.destroy;a.destroy=void 0,i!==void 0&&lu(t,n,i)}a=a.next}while(a!==r)}}function hc(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ou(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Jy(e){var t=e.alternate;t!==null&&(e.alternate=null,Jy(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[tn],delete t[Gi],delete t[Wd],delete t[zb],delete t[$b])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Xy(e){return e.tag===5||e.tag===3||e.tag===4}function vp(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Xy(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function cu(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Mo));else if(r!==4&&(e=e.child,e!==null))for(cu(e,t,n),e=e.sibling;e!==null;)cu(e,t,n),e=e.sibling}function du(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(du(e,t,n),e=e.sibling;e!==null;)du(e,t,n),e=e.sibling}var Mt=null,zs=!1;function On(e,t,n){for(n=n.child;n!==null;)Yy(e,t,n),n=n.sibling}function Yy(e,t,n){if(rn&&typeof rn.onCommitFiberUnmount=="function")try{rn.onCommitFiberUnmount(ac,n)}catch{}switch(n.tag){case 5:Kt||ga(n,t);case 6:var r=Mt,a=zs;Mt=null,On(e,t,n),Mt=r,zs=a,Mt!==null&&(zs?(e=Mt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Mt.removeChild(n.stateNode));break;case 18:Mt!==null&&(zs?(e=Mt,n=n.stateNode,e.nodeType===8?td(e.parentNode,n):e.nodeType===1&&td(e,n),qi(e)):td(Mt,n.stateNode));break;case 4:r=Mt,a=zs,Mt=n.stateNode.containerInfo,zs=!0,On(e,t,n),Mt=r,zs=a;break;case 0:case 11:case 14:case 15:if(!Kt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){a=r=r.next;do{var i=a,l=i.destroy;i=i.tag,l!==void 0&&(i&2||i&4)&&lu(n,t,l),a=a.next}while(a!==r)}On(e,t,n);break;case 1:if(!Kt&&(ga(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){mt(n,t,o)}On(e,t,n);break;case 21:On(e,t,n);break;case 22:n.mode&1?(Kt=(r=Kt)||n.memoizedState!==null,On(e,t,n),Kt=r):On(e,t,n);break;default:On(e,t,n)}}function jp(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new tN),t.forEach(function(r){var a=uN.bind(null,e,r);n.has(r)||(n.add(r),r.then(a,a))})}}function Is(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r];try{var i=e,l=t,o=l;e:for(;o!==null;){switch(o.tag){case 5:Mt=o.stateNode,zs=!1;break e;case 3:Mt=o.stateNode.containerInfo,zs=!0;break e;case 4:Mt=o.stateNode.containerInfo,zs=!0;break e}o=o.return}if(Mt===null)throw Error(Y(160));Yy(i,l,a),Mt=null,zs=!1;var c=a.alternate;c!==null&&(c.return=null),a.return=null}catch(d){mt(a,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)e0(t,e),t=t.sibling}function e0(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Is(t,e),Ws(e),r&4){try{Fi(3,e,e.return),hc(3,e)}catch(p){mt(e,e.return,p)}try{Fi(5,e,e.return)}catch(p){mt(e,e.return,p)}}break;case 1:Is(t,e),Ws(e),r&512&&n!==null&&ga(n,n.return);break;case 5:if(Is(t,e),Ws(e),r&512&&n!==null&&ga(n,n.return),e.flags&32){var a=e.stateNode;try{_i(a,"")}catch(p){mt(e,e.return,p)}}if(r&4&&(a=e.stateNode,a!=null)){var i=e.memoizedProps,l=n!==null?n.memoizedProps:i,o=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{o==="input"&&i.type==="radio"&&i.name!=null&&Ng(a,i),Id(o,l);var d=Id(o,i);for(l=0;l<c.length;l+=2){var u=c[l],h=c[l+1];u==="style"?Eg(a,h):u==="dangerouslySetInnerHTML"?kg(a,h):u==="children"?_i(a,h):am(a,u,h,d)}switch(o){case"input":Ad(a,i);break;case"textarea":wg(a,i);break;case"select":var x=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!i.multiple;var m=i.value;m!=null?ja(a,!!i.multiple,m,!1):x!==!!i.multiple&&(i.defaultValue!=null?ja(a,!!i.multiple,i.defaultValue,!0):ja(a,!!i.multiple,i.multiple?[]:"",!1))}a[Gi]=i}catch(p){mt(e,e.return,p)}}break;case 6:if(Is(t,e),Ws(e),r&4){if(e.stateNode===null)throw Error(Y(162));a=e.stateNode,i=e.memoizedProps;try{a.nodeValue=i}catch(p){mt(e,e.return,p)}}break;case 3:if(Is(t,e),Ws(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{qi(t.containerInfo)}catch(p){mt(e,e.return,p)}break;case 4:Is(t,e),Ws(e);break;case 13:Is(t,e),Ws(e),a=e.child,a.flags&8192&&(i=a.memoizedState!==null,a.stateNode.isHidden=i,!i||a.alternate!==null&&a.alternate.memoizedState!==null||(zm=ft())),r&4&&jp(e);break;case 22:if(u=n!==null&&n.memoizedState!==null,e.mode&1?(Kt=(d=Kt)||u,Is(t,e),Kt=d):Is(t,e),Ws(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!u&&e.mode&1)for(he=e,u=e.child;u!==null;){for(h=he=u;he!==null;){switch(x=he,m=x.child,x.tag){case 0:case 11:case 14:case 15:Fi(4,x,x.return);break;case 1:ga(x,x.return);var f=x.stateNode;if(typeof f.componentWillUnmount=="function"){r=x,n=x.return;try{t=r,f.props=t.memoizedProps,f.state=t.memoizedState,f.componentWillUnmount()}catch(p){mt(r,n,p)}}break;case 5:ga(x,x.return);break;case 22:if(x.memoizedState!==null){Np(h);continue}}m!==null?(m.return=x,he=m):Np(h)}u=u.sibling}e:for(u=null,h=e;;){if(h.tag===5){if(u===null){u=h;try{a=h.stateNode,d?(i=a.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(o=h.stateNode,c=h.memoizedProps.style,l=c!=null&&c.hasOwnProperty("display")?c.display:null,o.style.display=Cg("display",l))}catch(p){mt(e,e.return,p)}}}else if(h.tag===6){if(u===null)try{h.stateNode.nodeValue=d?"":h.memoizedProps}catch(p){mt(e,e.return,p)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===e)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===e)break e;for(;h.sibling===null;){if(h.return===null||h.return===e)break e;u===h&&(u=null),h=h.return}u===h&&(u=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:Is(t,e),Ws(e),r&4&&jp(e);break;case 21:break;default:Is(t,e),Ws(e)}}function Ws(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(Xy(n)){var r=n;break e}n=n.return}throw Error(Y(160))}switch(r.tag){case 5:var a=r.stateNode;r.flags&32&&(_i(a,""),r.flags&=-33);var i=vp(e);du(e,i,a);break;case 3:case 4:var l=r.stateNode.containerInfo,o=vp(e);cu(e,o,l);break;default:throw Error(Y(161))}}catch(c){mt(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function nN(e,t,n){he=e,t0(e)}function t0(e,t,n){for(var r=(e.mode&1)!==0;he!==null;){var a=he,i=a.child;if(a.tag===22&&r){var l=a.memoizedState!==null||Jl;if(!l){var o=a.alternate,c=o!==null&&o.memoizedState!==null||Kt;o=Jl;var d=Kt;if(Jl=l,(Kt=c)&&!d)for(he=a;he!==null;)l=he,c=l.child,l.tag===22&&l.memoizedState!==null?wp(a):c!==null?(c.return=l,he=c):wp(a);for(;i!==null;)he=i,t0(i),i=i.sibling;he=a,Jl=o,Kt=d}bp(e)}else a.subtreeFlags&8772&&i!==null?(i.return=a,he=i):bp(e)}}function bp(e){for(;he!==null;){var t=he;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Kt||hc(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Kt)if(n===null)r.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:Rs(t.type,n.memoizedProps);r.componentDidUpdate(a,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&ap(t,i,r);break;case 3:var l=t.updateQueue;if(l!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}ap(t,l,n)}break;case 5:var o=t.stateNode;if(n===null&&t.flags&4){n=o;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var d=t.alternate;if(d!==null){var u=d.memoizedState;if(u!==null){var h=u.dehydrated;h!==null&&qi(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Y(163))}Kt||t.flags&512&&ou(t)}catch(x){mt(t,t.return,x)}}if(t===e){he=null;break}if(n=t.sibling,n!==null){n.return=t.return,he=n;break}he=t.return}}function Np(e){for(;he!==null;){var t=he;if(t===e){he=null;break}var n=t.sibling;if(n!==null){n.return=t.return,he=n;break}he=t.return}}function wp(e){for(;he!==null;){var t=he;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{hc(4,t)}catch(c){mt(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var a=t.return;try{r.componentDidMount()}catch(c){mt(t,a,c)}}var i=t.return;try{ou(t)}catch(c){mt(t,i,c)}break;case 5:var l=t.return;try{ou(t)}catch(c){mt(t,l,c)}}}catch(c){mt(t,t.return,c)}if(t===e){he=null;break}var o=t.sibling;if(o!==null){o.return=t.return,he=o;break}he=t.return}}var rN=Math.ceil,Bo=Fn.ReactCurrentDispatcher,Lm=Fn.ReactCurrentOwner,Ms=Fn.ReactCurrentBatchConfig,Te=0,Pt=null,vt=null,Rt=0,ps=0,ya=yr(0),St=0,tl=null,Hr=0,fc=0,Om=0,Ii=null,is=null,zm=0,Ga=1/0,xn=null,Uo=!1,uu=null,cr=null,Xl=!1,sr=null,qo=0,Ri=0,mu=null,fo=-1,po=0;function Zt(){return Te&6?ft():fo!==-1?fo:fo=ft()}function dr(e){return e.mode&1?Te&2&&Rt!==0?Rt&-Rt:Kb.transition!==null?(po===0&&(po=$g()),po):(e=Ue,e!==0||(e=window.event,e=e===void 0?16:Qg(e.type)),e):1}function Us(e,t,n,r){if(50<Ri)throw Ri=0,mu=null,Error(Y(185));Nl(e,n,r),(!(Te&2)||e!==Pt)&&(e===Pt&&(!(Te&2)&&(fc|=n),St===4&&Bn(e,Rt)),ds(e,r),n===1&&Te===0&&!(t.mode&1)&&(Ga=ft()+500,dc&&vr()))}function ds(e,t){var n=e.callbackNode;Kj(e,t);var r=Eo(e,e===Pt?Rt:0);if(r===0)n!==null&&Tf(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Tf(n),t===1)e.tag===0?_b(Sp.bind(null,e)):uy(Sp.bind(null,e)),Lb(function(){!(Te&6)&&vr()}),n=null;else{switch(_g(r)){case 1:n=dm;break;case 4:n=Og;break;case 16:n=Co;break;case 536870912:n=zg;break;default:n=Co}n=c0(n,s0.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function s0(e,t){if(fo=-1,po=0,Te&6)throw Error(Y(327));var n=e.callbackNode;if(ka()&&e.callbackNode!==n)return null;var r=Eo(e,e===Pt?Rt:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Vo(e,r);else{t=r;var a=Te;Te|=2;var i=r0();(Pt!==e||Rt!==t)&&(xn=null,Ga=ft()+500,_r(e,t));do try{lN();break}catch(o){n0(e,o)}while(!0);wm(),Bo.current=i,Te=a,vt!==null?t=0:(Pt=null,Rt=0,t=St)}if(t!==0){if(t===2&&(a=$d(e),a!==0&&(r=a,t=hu(e,a))),t===1)throw n=tl,_r(e,0),Bn(e,r),ds(e,ft()),n;if(t===6)Bn(e,r);else{if(a=e.current.alternate,!(r&30)&&!aN(a)&&(t=Vo(e,r),t===2&&(i=$d(e),i!==0&&(r=i,t=hu(e,i))),t===1))throw n=tl,_r(e,0),Bn(e,r),ds(e,ft()),n;switch(e.finishedWork=a,e.finishedLanes=r,t){case 0:case 1:throw Error(Y(345));case 2:wr(e,is,xn);break;case 3:if(Bn(e,r),(r&130023424)===r&&(t=zm+500-ft(),10<t)){if(Eo(e,0)!==0)break;if(a=e.suspendedLanes,(a&r)!==r){Zt(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=Hd(wr.bind(null,e,is,xn),t);break}wr(e,is,xn);break;case 4:if(Bn(e,r),(r&4194240)===r)break;for(t=e.eventTimes,a=-1;0<r;){var l=31-Bs(r);i=1<<l,l=t[l],l>a&&(a=l),r&=~i}if(r=a,r=ft()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*rN(r/1960))-r,10<r){e.timeoutHandle=Hd(wr.bind(null,e,is,xn),r);break}wr(e,is,xn);break;case 5:wr(e,is,xn);break;default:throw Error(Y(329))}}}return ds(e,ft()),e.callbackNode===n?s0.bind(null,e):null}function hu(e,t){var n=Ii;return e.current.memoizedState.isDehydrated&&(_r(e,t).flags|=256),e=Vo(e,t),e!==2&&(t=is,is=n,t!==null&&fu(t)),e}function fu(e){is===null?is=e:is.push.apply(is,e)}function aN(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var a=n[r],i=a.getSnapshot;a=a.value;try{if(!qs(i(),a))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Bn(e,t){for(t&=~Om,t&=~fc,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Bs(t),r=1<<n;e[n]=-1,t&=~r}}function Sp(e){if(Te&6)throw Error(Y(327));ka();var t=Eo(e,0);if(!(t&1))return ds(e,ft()),null;var n=Vo(e,t);if(e.tag!==0&&n===2){var r=$d(e);r!==0&&(t=r,n=hu(e,r))}if(n===1)throw n=tl,_r(e,0),Bn(e,t),ds(e,ft()),n;if(n===6)throw Error(Y(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,wr(e,is,xn),ds(e,ft()),null}function $m(e,t){var n=Te;Te|=1;try{return e(t)}finally{Te=n,Te===0&&(Ga=ft()+500,dc&&vr())}}function Wr(e){sr!==null&&sr.tag===0&&!(Te&6)&&ka();var t=Te;Te|=1;var n=Ms.transition,r=Ue;try{if(Ms.transition=null,Ue=1,e)return e()}finally{Ue=r,Ms.transition=n,Te=t,!(Te&6)&&vr()}}function _m(){ps=ya.current,Je(ya)}function _r(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Rb(n)),vt!==null)for(n=vt.return;n!==null;){var r=n;switch(jm(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&To();break;case 3:Ha(),Je(os),Je(Ut),Am();break;case 5:Dm(r);break;case 4:Ha();break;case 13:Je(at);break;case 19:Je(at);break;case 10:Sm(r.type._context);break;case 22:case 23:_m()}n=n.return}if(Pt=e,vt=e=ur(e.current,null),Rt=ps=t,St=0,tl=null,Om=fc=Hr=0,is=Ii=null,Cr!==null){for(t=0;t<Cr.length;t++)if(n=Cr[t],r=n.interleaved,r!==null){n.interleaved=null;var a=r.next,i=n.pending;if(i!==null){var l=i.next;i.next=a,r.next=l}n.pending=r}Cr=null}return e}function n0(e,t){do{var n=vt;try{if(wm(),uo.current=Ko,_o){for(var r=it.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}_o=!1}if(Qr=0,Et=Nt=it=null,Ti=!1,Xi=0,Lm.current=null,n===null||n.return===null){St=1,tl=t,vt=null;break}e:{var i=e,l=n.return,o=n,c=t;if(t=Rt,o.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,u=o,h=u.tag;if(!(u.mode&1)&&(h===0||h===11||h===15)){var x=u.alternate;x?(u.updateQueue=x.updateQueue,u.memoizedState=x.memoizedState,u.lanes=x.lanes):(u.updateQueue=null,u.memoizedState=null)}var m=up(l);if(m!==null){m.flags&=-257,mp(m,l,o,i,t),m.mode&1&&dp(i,d,t),t=m,c=d;var f=t.updateQueue;if(f===null){var p=new Set;p.add(c),t.updateQueue=p}else f.add(c);break e}else{if(!(t&1)){dp(i,d,t),Km();break e}c=Error(Y(426))}}else if(tt&&o.mode&1){var b=up(l);if(b!==null){!(b.flags&65536)&&(b.flags|=256),mp(b,l,o,i,t),bm(Wa(c,o));break e}}i=c=Wa(c,o),St!==4&&(St=2),Ii===null?Ii=[i]:Ii.push(i),i=l;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var g=_y(i,c,t);rp(i,g);break e;case 1:o=c;var y=i.type,v=i.stateNode;if(!(i.flags&128)&&(typeof y.getDerivedStateFromError=="function"||v!==null&&typeof v.componentDidCatch=="function"&&(cr===null||!cr.has(v)))){i.flags|=65536,t&=-t,i.lanes|=t;var N=Ky(i,o,t);rp(i,N);break e}}i=i.return}while(i!==null)}i0(n)}catch(E){t=E,vt===n&&n!==null&&(vt=n=n.return);continue}break}while(!0)}function r0(){var e=Bo.current;return Bo.current=Ko,e===null?Ko:e}function Km(){(St===0||St===3||St===2)&&(St=4),Pt===null||!(Hr&268435455)&&!(fc&268435455)||Bn(Pt,Rt)}function Vo(e,t){var n=Te;Te|=2;var r=r0();(Pt!==e||Rt!==t)&&(xn=null,_r(e,t));do try{iN();break}catch(a){n0(e,a)}while(!0);if(wm(),Te=n,Bo.current=r,vt!==null)throw Error(Y(261));return Pt=null,Rt=0,St}function iN(){for(;vt!==null;)a0(vt)}function lN(){for(;vt!==null&&!Tj();)a0(vt)}function a0(e){var t=o0(e.alternate,e,ps);e.memoizedProps=e.pendingProps,t===null?i0(e):vt=t,Lm.current=null}function i0(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=eN(n,t),n!==null){n.flags&=32767,vt=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{St=6,vt=null;return}}else if(n=Yb(n,t,ps),n!==null){vt=n;return}if(t=t.sibling,t!==null){vt=t;return}vt=t=e}while(t!==null);St===0&&(St=5)}function wr(e,t,n){var r=Ue,a=Ms.transition;try{Ms.transition=null,Ue=1,oN(e,t,n,r)}finally{Ms.transition=a,Ue=r}return null}function oN(e,t,n,r){do ka();while(sr!==null);if(Te&6)throw Error(Y(327));n=e.finishedWork;var a=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(Y(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(Bj(e,i),e===Pt&&(vt=Pt=null,Rt=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Xl||(Xl=!0,c0(Co,function(){return ka(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=Ms.transition,Ms.transition=null;var l=Ue;Ue=1;var o=Te;Te|=4,Lm.current=null,sN(e,n),e0(n,e),Db(Vd),Do=!!qd,Vd=qd=null,e.current=n,nN(n),Fj(),Te=o,Ue=l,Ms.transition=i}else e.current=n;if(Xl&&(Xl=!1,sr=e,qo=a),i=e.pendingLanes,i===0&&(cr=null),Lj(n.stateNode),ds(e,ft()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)a=t[n],r(a.value,{componentStack:a.stack,digest:a.digest});if(Uo)throw Uo=!1,e=uu,uu=null,e;return qo&1&&e.tag!==0&&ka(),i=e.pendingLanes,i&1?e===mu?Ri++:(Ri=0,mu=e):Ri=0,vr(),null}function ka(){if(sr!==null){var e=_g(qo),t=Ms.transition,n=Ue;try{if(Ms.transition=null,Ue=16>e?16:e,sr===null)var r=!1;else{if(e=sr,sr=null,qo=0,Te&6)throw Error(Y(331));var a=Te;for(Te|=4,he=e.current;he!==null;){var i=he,l=i.child;if(he.flags&16){var o=i.deletions;if(o!==null){for(var c=0;c<o.length;c++){var d=o[c];for(he=d;he!==null;){var u=he;switch(u.tag){case 0:case 11:case 15:Fi(8,u,i)}var h=u.child;if(h!==null)h.return=u,he=h;else for(;he!==null;){u=he;var x=u.sibling,m=u.return;if(Jy(u),u===d){he=null;break}if(x!==null){x.return=m,he=x;break}he=m}}}var f=i.alternate;if(f!==null){var p=f.child;if(p!==null){f.child=null;do{var b=p.sibling;p.sibling=null,p=b}while(p!==null)}}he=i}}if(i.subtreeFlags&2064&&l!==null)l.return=i,he=l;else e:for(;he!==null;){if(i=he,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Fi(9,i,i.return)}var g=i.sibling;if(g!==null){g.return=i.return,he=g;break e}he=i.return}}var y=e.current;for(he=y;he!==null;){l=he;var v=l.child;if(l.subtreeFlags&2064&&v!==null)v.return=l,he=v;else e:for(l=y;he!==null;){if(o=he,o.flags&2048)try{switch(o.tag){case 0:case 11:case 15:hc(9,o)}}catch(E){mt(o,o.return,E)}if(o===l){he=null;break e}var N=o.sibling;if(N!==null){N.return=o.return,he=N;break e}he=o.return}}if(Te=a,vr(),rn&&typeof rn.onPostCommitFiberRoot=="function")try{rn.onPostCommitFiberRoot(ac,e)}catch{}r=!0}return r}finally{Ue=n,Ms.transition=t}}return!1}function kp(e,t,n){t=Wa(n,t),t=_y(e,t,1),e=or(e,t,1),t=Zt(),e!==null&&(Nl(e,1,t),ds(e,t))}function mt(e,t,n){if(e.tag===3)kp(e,e,n);else for(;t!==null;){if(t.tag===3){kp(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(cr===null||!cr.has(r))){e=Wa(n,e),e=Ky(t,e,1),t=or(t,e,1),e=Zt(),t!==null&&(Nl(t,1,e),ds(t,e));break}}t=t.return}}function cN(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Zt(),e.pingedLanes|=e.suspendedLanes&n,Pt===e&&(Rt&n)===n&&(St===4||St===3&&(Rt&130023424)===Rt&&500>ft()-zm?_r(e,0):Om|=n),ds(e,t)}function l0(e,t){t===0&&(e.mode&1?(t=Bl,Bl<<=1,!(Bl&130023424)&&(Bl=4194304)):t=1);var n=Zt();e=Pn(e,t),e!==null&&(Nl(e,t,n),ds(e,n))}function dN(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),l0(e,n)}function uN(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(Y(314))}r!==null&&r.delete(t),l0(e,n)}var o0;o0=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||os.current)ls=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ls=!1,Xb(e,t,n);ls=!!(e.flags&131072)}else ls=!1,tt&&t.flags&1048576&&my(t,Ro,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;ho(e,t),e=t.pendingProps;var a=qa(t,Ut.current);Sa(t,n),a=Mm(null,t,r,e,a,n);var i=Tm();return t.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,cs(r)?(i=!0,Fo(t)):i=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Cm(t),a.updater=mc,t.stateNode=a,a._reactInternals=t,eu(t,r,e,n),t=nu(null,t,r,!0,i,n)):(t.tag=0,tt&&i&&vm(t),Gt(null,t,a,n),t=t.child),t;case 16:r=t.elementType;e:{switch(ho(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=hN(r),e=Rs(r,e),a){case 0:t=su(null,t,r,e,n);break e;case 1:t=pp(null,t,r,e,n);break e;case 11:t=hp(null,t,r,e,n);break e;case 14:t=fp(null,t,r,Rs(r.type,e),n);break e}throw Error(Y(306,r,""))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Rs(r,a),su(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Rs(r,a),pp(e,t,r,a,n);case 3:e:{if(Vy(t),e===null)throw Error(Y(387));r=t.pendingProps,i=t.memoizedState,a=i.element,yy(e,t),zo(t,r,null,n);var l=t.memoizedState;if(r=l.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){a=Wa(Error(Y(423)),t),t=xp(e,t,r,n,a);break e}else if(r!==a){a=Wa(Error(Y(424)),t),t=xp(e,t,r,n,a);break e}else for(ys=lr(t.stateNode.containerInfo.firstChild),vs=t,tt=!0,$s=null,n=xy(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Va(),r===a){t=Mn(e,t,n);break e}Gt(e,t,r,n)}t=t.child}return t;case 5:return vy(t),e===null&&Jd(t),r=t.type,a=t.pendingProps,i=e!==null?e.memoizedProps:null,l=a.children,Qd(r,a)?l=null:i!==null&&Qd(r,i)&&(t.flags|=32),qy(e,t),Gt(e,t,l,n),t.child;case 6:return e===null&&Jd(t),null;case 13:return Qy(e,t,n);case 4:return Em(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Qa(t,null,r,n):Gt(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Rs(r,a),hp(e,t,r,a,n);case 7:return Gt(e,t,t.pendingProps,n),t.child;case 8:return Gt(e,t,t.pendingProps.children,n),t.child;case 12:return Gt(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,a=t.pendingProps,i=t.memoizedProps,l=a.value,Qe(Lo,r._currentValue),r._currentValue=l,i!==null)if(qs(i.value,l)){if(i.children===a.children&&!os.current){t=Mn(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var o=i.dependencies;if(o!==null){l=i.child;for(var c=o.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=Cn(-1,n&-n),c.tag=2;var d=i.updateQueue;if(d!==null){d=d.shared;var u=d.pending;u===null?c.next=c:(c.next=u.next,u.next=c),d.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),Xd(i.return,n,t),o.lanes|=n;break}c=c.next}}else if(i.tag===10)l=i.type===t.type?null:i.child;else if(i.tag===18){if(l=i.return,l===null)throw Error(Y(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),Xd(l,n,t),l=i.sibling}else l=i.child;if(l!==null)l.return=i;else for(l=i;l!==null;){if(l===t){l=null;break}if(i=l.sibling,i!==null){i.return=l.return,l=i;break}l=l.return}i=l}Gt(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,Sa(t,n),a=Ts(a),r=r(a),t.flags|=1,Gt(e,t,r,n),t.child;case 14:return r=t.type,a=Rs(r,t.pendingProps),a=Rs(r.type,a),fp(e,t,r,a,n);case 15:return By(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Rs(r,a),ho(e,t),t.tag=1,cs(r)?(e=!0,Fo(t)):e=!1,Sa(t,n),$y(t,r,a),eu(t,r,a,n),nu(null,t,r,!0,e,n);case 19:return Hy(e,t,n);case 22:return Uy(e,t,n)}throw Error(Y(156,t.tag))};function c0(e,t){return Lg(e,t)}function mN(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ds(e,t,n,r){return new mN(e,t,n,r)}function Bm(e){return e=e.prototype,!(!e||!e.isReactComponent)}function hN(e){if(typeof e=="function")return Bm(e)?1:0;if(e!=null){if(e=e.$$typeof,e===lm)return 11;if(e===om)return 14}return 2}function ur(e,t){var n=e.alternate;return n===null?(n=Ds(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function xo(e,t,n,r,a,i){var l=2;if(r=e,typeof e=="function")Bm(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case oa:return Kr(n.children,a,i,t);case im:l=8,a|=8;break;case Sd:return e=Ds(12,n,t,a|2),e.elementType=Sd,e.lanes=i,e;case kd:return e=Ds(13,n,t,a),e.elementType=kd,e.lanes=i,e;case Cd:return e=Ds(19,n,t,a),e.elementType=Cd,e.lanes=i,e;case vg:return pc(n,a,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case gg:l=10;break e;case yg:l=9;break e;case lm:l=11;break e;case om:l=14;break e;case $n:l=16,r=null;break e}throw Error(Y(130,e==null?e:typeof e,""))}return t=Ds(l,n,t,a),t.elementType=e,t.type=r,t.lanes=i,t}function Kr(e,t,n,r){return e=Ds(7,e,r,t),e.lanes=n,e}function pc(e,t,n,r){return e=Ds(22,e,r,t),e.elementType=vg,e.lanes=n,e.stateNode={isHidden:!1},e}function cd(e,t,n){return e=Ds(6,e,null,t),e.lanes=n,e}function dd(e,t,n){return t=Ds(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function fN(e,t,n,r,a){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=qc(0),this.expirationTimes=qc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=qc(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function Um(e,t,n,r,a,i,l,o,c){return e=new fN(e,t,n,o,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Ds(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Cm(i),e}function pN(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:la,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function d0(e){if(!e)return pr;e=e._reactInternals;e:{if(ea(e)!==e||e.tag!==1)throw Error(Y(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(cs(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Y(171))}if(e.tag===1){var n=e.type;if(cs(n))return dy(e,n,t)}return t}function u0(e,t,n,r,a,i,l,o,c){return e=Um(n,r,!0,e,a,i,l,o,c),e.context=d0(null),n=e.current,r=Zt(),a=dr(n),i=Cn(r,a),i.callback=t??null,or(n,i,a),e.current.lanes=a,Nl(e,a,r),ds(e,r),e}function xc(e,t,n,r){var a=t.current,i=Zt(),l=dr(a);return n=d0(n),t.context===null?t.context=n:t.pendingContext=n,t=Cn(i,l),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=or(a,t,l),e!==null&&(Us(e,a,l,i),co(e,a,l)),l}function Qo(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function Cp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function qm(e,t){Cp(e,t),(e=e.alternate)&&Cp(e,t)}function xN(){return null}var m0=typeof reportError=="function"?reportError:function(e){console.error(e)};function Vm(e){this._internalRoot=e}gc.prototype.render=Vm.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Y(409));xc(e,t,null,null)};gc.prototype.unmount=Vm.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Wr(function(){xc(null,e,null,null)}),t[An]=null}};function gc(e){this._internalRoot=e}gc.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ug();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Kn.length&&t!==0&&t<Kn[n].priority;n++);Kn.splice(n,0,e),n===0&&Vg(e)}};function Qm(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function yc(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Ep(){}function gN(e,t,n,r,a){if(a){if(typeof r=="function"){var i=r;r=function(){var d=Qo(l);i.call(d)}}var l=u0(t,r,e,0,null,!1,!1,"",Ep);return e._reactRootContainer=l,e[An]=l.current,Hi(e.nodeType===8?e.parentNode:e),Wr(),l}for(;a=e.lastChild;)e.removeChild(a);if(typeof r=="function"){var o=r;r=function(){var d=Qo(c);o.call(d)}}var c=Um(e,0,!1,null,null,!1,!1,"",Ep);return e._reactRootContainer=c,e[An]=c.current,Hi(e.nodeType===8?e.parentNode:e),Wr(function(){xc(t,c,n,r)}),c}function vc(e,t,n,r,a){var i=n._reactRootContainer;if(i){var l=i;if(typeof a=="function"){var o=a;a=function(){var c=Qo(l);o.call(c)}}xc(t,l,e,a)}else l=gN(n,t,e,a,r);return Qo(l)}Kg=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=wi(t.pendingLanes);n!==0&&(um(t,n|1),ds(t,ft()),!(Te&6)&&(Ga=ft()+500,vr()))}break;case 13:Wr(function(){var r=Pn(e,1);if(r!==null){var a=Zt();Us(r,e,1,a)}}),qm(e,1)}};mm=function(e){if(e.tag===13){var t=Pn(e,134217728);if(t!==null){var n=Zt();Us(t,e,134217728,n)}qm(e,134217728)}};Bg=function(e){if(e.tag===13){var t=dr(e),n=Pn(e,t);if(n!==null){var r=Zt();Us(n,e,t,r)}qm(e,t)}};Ug=function(){return Ue};qg=function(e,t){var n=Ue;try{return Ue=e,t()}finally{Ue=n}};Ld=function(e,t,n){switch(t){case"input":if(Ad(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=cc(r);if(!a)throw Error(Y(90));bg(r),Ad(r,a)}}}break;case"textarea":wg(e,n);break;case"select":t=n.value,t!=null&&ja(e,!!n.multiple,t,!1)}};Pg=$m;Mg=Wr;var yN={usingClientEntryPoint:!1,Events:[Sl,ma,cc,Dg,Ag,$m]},yi={findFiberByHostInstance:kr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},vN={bundleType:yi.bundleType,version:yi.version,rendererPackageName:yi.rendererPackageName,rendererConfig:yi.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Fn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Ig(e),e===null?null:e.stateNode},findFiberByHostInstance:yi.findFiberByHostInstance||xN,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Yl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Yl.isDisabled&&Yl.supportsFiber)try{ac=Yl.inject(vN),rn=Yl}catch{}}bs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=yN;bs.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Qm(t))throw Error(Y(200));return pN(e,t,null,n)};bs.createRoot=function(e,t){if(!Qm(e))throw Error(Y(299));var n=!1,r="",a=m0;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=Um(e,1,!1,null,null,n,!1,r,a),e[An]=t.current,Hi(e.nodeType===8?e.parentNode:e),new Vm(t)};bs.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(Y(188)):(e=Object.keys(e).join(","),Error(Y(268,e)));return e=Ig(t),e=e===null?null:e.stateNode,e};bs.flushSync=function(e){return Wr(e)};bs.hydrate=function(e,t,n){if(!yc(t))throw Error(Y(200));return vc(null,e,t,!0,n)};bs.hydrateRoot=function(e,t,n){if(!Qm(e))throw Error(Y(405));var r=n!=null&&n.hydratedSources||null,a=!1,i="",l=m0;if(n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(l=n.onRecoverableError)),t=u0(t,null,e,1,n??null,a,!1,i,l),e[An]=t.current,Hi(e),r)for(e=0;e<r.length;e++)n=r[e],a=n._getVersion,a=a(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,a]:t.mutableSourceEagerHydrationData.push(n,a);return new gc(t)};bs.render=function(e,t,n){if(!yc(t))throw Error(Y(200));return vc(null,e,t,!1,n)};bs.unmountComponentAtNode=function(e){if(!yc(e))throw Error(Y(40));return e._reactRootContainer?(Wr(function(){vc(null,null,e,!1,function(){e._reactRootContainer=null,e[An]=null})}),!0):!1};bs.unstable_batchedUpdates=$m;bs.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!yc(n))throw Error(Y(200));if(e==null||e._reactInternals===void 0)throw Error(Y(38));return vc(e,t,n,!1,r)};bs.version="18.3.1-next-f1338f8080-20240426";function h0(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(h0)}catch(e){console.error(e)}}h0(),hg.exports=bs;var jN=hg.exports,Dp=jN;Nd.createRoot=Dp.createRoot,Nd.hydrateRoot=Dp.hydrateRoot;/**
|
||
* @remix-run/router v1.23.2
|
||
*
|
||
* Copyright (c) Remix Software Inc.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE.md file in the root directory of this source tree.
|
||
*
|
||
* @license MIT
|
||
*/function sl(){return sl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},sl.apply(this,arguments)}var nr;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(nr||(nr={}));const Ap="popstate";function bN(e){e===void 0&&(e={});function t(r,a){let{pathname:i,search:l,hash:o}=r.location;return pu("",{pathname:i,search:l,hash:o},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function n(r,a){return typeof a=="string"?a:Ho(a)}return wN(t,n,null,e)}function lt(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Hm(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function NN(){return Math.random().toString(36).substr(2,8)}function Pp(e,t){return{usr:e.state,key:e.key,idx:t}}function pu(e,t,n,r){return n===void 0&&(n=null),sl({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?si(t):t,{state:n,key:t&&t.key||r||NN()})}function Ho(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function si(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function wN(e,t,n,r){r===void 0&&(r={});let{window:a=document.defaultView,v5Compat:i=!1}=r,l=a.history,o=nr.Pop,c=null,d=u();d==null&&(d=0,l.replaceState(sl({},l.state,{idx:d}),""));function u(){return(l.state||{idx:null}).idx}function h(){o=nr.Pop;let b=u(),g=b==null?null:b-d;d=b,c&&c({action:o,location:p.location,delta:g})}function x(b,g){o=nr.Push;let y=pu(p.location,b,g);d=u()+1;let v=Pp(y,d),N=p.createHref(y);try{l.pushState(v,"",N)}catch(E){if(E instanceof DOMException&&E.name==="DataCloneError")throw E;a.location.assign(N)}i&&c&&c({action:o,location:p.location,delta:1})}function m(b,g){o=nr.Replace;let y=pu(p.location,b,g);d=u();let v=Pp(y,d),N=p.createHref(y);l.replaceState(v,"",N),i&&c&&c({action:o,location:p.location,delta:0})}function f(b){let g=a.location.origin!=="null"?a.location.origin:a.location.href,y=typeof b=="string"?b:Ho(b);return y=y.replace(/ $/,"%20"),lt(g,"No window.location.(origin|href) available to create URL for href: "+y),new URL(y,g)}let p={get action(){return o},get location(){return e(a,l)},listen(b){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(Ap,h),c=b,()=>{a.removeEventListener(Ap,h),c=null}},createHref(b){return t(a,b)},createURL:f,encodeLocation(b){let g=f(b);return{pathname:g.pathname,search:g.search,hash:g.hash}},push:x,replace:m,go(b){return l.go(b)}};return p}var Mp;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Mp||(Mp={}));function SN(e,t,n){return n===void 0&&(n="/"),kN(e,t,n)}function kN(e,t,n,r){let a=typeof t=="string"?si(t):t,i=Za(a.pathname||"/",n);if(i==null)return null;let l=f0(e);CN(l);let o=null;for(let c=0;o==null&&c<l.length;++c){let d=ON(i);o=RN(l[c],d)}return o}function f0(e,t,n,r){t===void 0&&(t=[]),n===void 0&&(n=[]),r===void 0&&(r="");let a=(i,l,o)=>{let c={relativePath:o===void 0?i.path||"":o,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};c.relativePath.startsWith("/")&&(lt(c.relativePath.startsWith(r),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(r.length));let d=mr([r,c.relativePath]),u=n.concat(c);i.children&&i.children.length>0&&(lt(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),f0(i.children,t,u,d)),!(i.path==null&&!i.index)&&t.push({path:d,score:FN(d,i.index),routesMeta:u})};return e.forEach((i,l)=>{var o;if(i.path===""||!((o=i.path)!=null&&o.includes("?")))a(i,l);else for(let c of p0(i.path))a(i,l,c)}),t}function p0(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let l=p0(r.join("/")),o=[];return o.push(...l.map(c=>c===""?i:[i,c].join("/"))),a&&o.push(...l),o.map(c=>e.startsWith("/")&&c===""?"/":c)}function CN(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:IN(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const EN=/^:[\w-]+$/,DN=3,AN=2,PN=1,MN=10,TN=-2,Tp=e=>e==="*";function FN(e,t){let n=e.split("/"),r=n.length;return n.some(Tp)&&(r+=TN),t&&(r+=AN),n.filter(a=>!Tp(a)).reduce((a,i)=>a+(EN.test(i)?DN:i===""?PN:MN),r)}function IN(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function RN(e,t,n){let{routesMeta:r}=e,a={},i="/",l=[];for(let o=0;o<r.length;++o){let c=r[o],d=o===r.length-1,u=i==="/"?t:t.slice(i.length)||"/",h=xu({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},u),x=c.route;if(!h)return null;Object.assign(a,h.params),l.push({params:a,pathname:mr([i,h.pathname]),pathnameBase:BN(mr([i,h.pathnameBase])),route:x}),h.pathnameBase!=="/"&&(i=mr([i,h.pathnameBase]))}return l}function xu(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=LN(e.path,e.caseSensitive,e.end),a=t.match(n);if(!a)return null;let i=a[0],l=i.replace(/(.)\/+$/,"$1"),o=a.slice(1);return{params:r.reduce((d,u,h)=>{let{paramName:x,isOptional:m}=u;if(x==="*"){let p=o[h]||"";l=i.slice(0,i.length-p.length).replace(/(.)\/+$/,"$1")}const f=o[h];return m&&!f?d[x]=void 0:d[x]=(f||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:l,pattern:e}}function LN(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),Hm(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 r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,c)=>(r.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function ON(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Hm(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Za(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const zN=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,$N=e=>zN.test(e);function _N(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?si(e):e,i;if(n)if($N(n))i=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),Hm(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?i=Fp(n.substring(1),"/"):i=Fp(n,t)}else i=t;return{pathname:i,search:UN(r),hash:qN(a)}}function Fp(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function ud(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function KN(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Wm(e,t){let n=KN(e);return t?n.map((r,a)=>a===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Gm(e,t,n,r){r===void 0&&(r=!1);let a;typeof e=="string"?a=si(e):(a=sl({},e),lt(!a.pathname||!a.pathname.includes("?"),ud("?","pathname","search",a)),lt(!a.pathname||!a.pathname.includes("#"),ud("#","pathname","hash",a)),lt(!a.search||!a.search.includes("#"),ud("#","search","hash",a)));let i=e===""||a.pathname==="",l=i?"/":a.pathname,o;if(l==null)o=n;else{let h=t.length-1;if(!r&&l.startsWith("..")){let x=l.split("/");for(;x[0]==="..";)x.shift(),h-=1;a.pathname=x.join("/")}o=h>=0?t[h]:"/"}let c=_N(a,o),d=l&&l!=="/"&&l.endsWith("/"),u=(i||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||u)&&(c.pathname+="/"),c}const mr=e=>e.join("/").replace(/\/\/+/g,"/"),BN=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),UN=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,qN=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function VN(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const x0=["post","put","patch","delete"];new Set(x0);const QN=["get",...x0];new Set(QN);/**
|
||
* React Router v6.30.3
|
||
*
|
||
* Copyright (c) Remix Software Inc.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE.md file in the root directory of this source tree.
|
||
*
|
||
* @license MIT
|
||
*/function nl(){return nl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},nl.apply(this,arguments)}const jc=j.createContext(null),g0=j.createContext(null),In=j.createContext(null),bc=j.createContext(null),cn=j.createContext({outlet:null,matches:[],isDataRoute:!1}),y0=j.createContext(null);function HN(e,t){let{relative:n}=t===void 0?{}:t;ni()||lt(!1);let{basename:r,navigator:a}=j.useContext(In),{hash:i,pathname:l,search:o}=wc(e,{relative:n}),c=l;return r!=="/"&&(c=l==="/"?r:mr([r,l])),a.createHref({pathname:c,search:o,hash:i})}function ni(){return j.useContext(bc)!=null}function Rn(){return ni()||lt(!1),j.useContext(bc).location}function v0(e){j.useContext(In).static||j.useLayoutEffect(e)}function Yt(){let{isDataRoute:e}=j.useContext(cn);return e?ow():WN()}function WN(){ni()||lt(!1);let e=j.useContext(jc),{basename:t,future:n,navigator:r}=j.useContext(In),{matches:a}=j.useContext(cn),{pathname:i}=Rn(),l=JSON.stringify(Wm(a,n.v7_relativeSplatPath)),o=j.useRef(!1);return v0(()=>{o.current=!0}),j.useCallback(function(d,u){if(u===void 0&&(u={}),!o.current)return;if(typeof d=="number"){r.go(d);return}let h=Gm(d,JSON.parse(l),i,u.relative==="path");e==null&&t!=="/"&&(h.pathname=h.pathname==="/"?t:mr([t,h.pathname])),(u.replace?r.replace:r.push)(h,u.state,u)},[t,r,l,i,e])}const GN=j.createContext(null);function ZN(e){let t=j.useContext(cn).outlet;return t&&j.createElement(GN.Provider,{value:e},t)}function Nc(){let{matches:e}=j.useContext(cn),t=e[e.length-1];return t?t.params:{}}function wc(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=j.useContext(In),{matches:a}=j.useContext(cn),{pathname:i}=Rn(),l=JSON.stringify(Wm(a,r.v7_relativeSplatPath));return j.useMemo(()=>Gm(e,JSON.parse(l),i,n==="path"),[e,l,i,n])}function JN(e,t){return XN(e,t)}function XN(e,t,n,r){ni()||lt(!1);let{navigator:a}=j.useContext(In),{matches:i}=j.useContext(cn),l=i[i.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let d=Rn(),u;if(t){var h;let b=typeof t=="string"?si(t):t;c==="/"||(h=b.pathname)!=null&&h.startsWith(c)||lt(!1),u=b}else u=d;let x=u.pathname||"/",m=x;if(c!=="/"){let b=c.replace(/^\//,"").split("/");m="/"+x.replace(/^\//,"").split("/").slice(b.length).join("/")}let f=SN(e,{pathname:m}),p=nw(f&&f.map(b=>Object.assign({},b,{params:Object.assign({},o,b.params),pathname:mr([c,a.encodeLocation?a.encodeLocation(b.pathname).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?c:mr([c,a.encodeLocation?a.encodeLocation(b.pathnameBase).pathname:b.pathnameBase])})),i,n,r);return t&&p?j.createElement(bc.Provider,{value:{location:nl({pathname:"/",search:"",hash:"",state:null,key:"default"},u),navigationType:nr.Pop}},p):p}function YN(){let e=lw(),t=VN(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return j.createElement(j.Fragment,null,j.createElement("h2",null,"Unexpected Application Error!"),j.createElement("h3",{style:{fontStyle:"italic"}},t),n?j.createElement("pre",{style:a},n):null,null)}const ew=j.createElement(YN,null);class tw extends j.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?j.createElement(cn.Provider,{value:this.props.routeContext},j.createElement(y0.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function sw(e){let{routeContext:t,match:n,children:r}=e,a=j.useContext(jc);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),j.createElement(cn.Provider,{value:t},r)}function nw(e,t,n,r){var a;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(a=n)==null?void 0:a.errors;if(o!=null){let u=l.findIndex(h=>h.route.id&&(o==null?void 0:o[h.route.id])!==void 0);u>=0||lt(!1),l=l.slice(0,Math.min(l.length,u+1))}let c=!1,d=-1;if(n&&r&&r.v7_partialHydration)for(let u=0;u<l.length;u++){let h=l[u];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(d=u),h.route.id){let{loaderData:x,errors:m}=n,f=h.route.loader&&x[h.route.id]===void 0&&(!m||m[h.route.id]===void 0);if(h.route.lazy||f){c=!0,d>=0?l=l.slice(0,d+1):l=[l[0]];break}}}return l.reduceRight((u,h,x)=>{let m,f=!1,p=null,b=null;n&&(m=o&&h.route.id?o[h.route.id]:void 0,p=h.route.errorElement||ew,c&&(d<0&&x===0?(cw("route-fallback"),f=!0,b=null):d===x&&(f=!0,b=h.route.hydrateFallbackElement||null)));let g=t.concat(l.slice(0,x+1)),y=()=>{let v;return m?v=p:f?v=b:h.route.Component?v=j.createElement(h.route.Component,null):h.route.element?v=h.route.element:v=u,j.createElement(sw,{match:h,routeContext:{outlet:u,matches:g,isDataRoute:n!=null},children:v})};return n&&(h.route.ErrorBoundary||h.route.errorElement||x===0)?j.createElement(tw,{location:n.location,revalidation:n.revalidation,component:p,error:m,children:y(),routeContext:{outlet:null,matches:g,isDataRoute:!0}}):y()},null)}var j0=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(j0||{}),b0=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(b0||{});function rw(e){let t=j.useContext(jc);return t||lt(!1),t}function aw(e){let t=j.useContext(g0);return t||lt(!1),t}function iw(e){let t=j.useContext(cn);return t||lt(!1),t}function N0(e){let t=iw(),n=t.matches[t.matches.length-1];return n.route.id||lt(!1),n.route.id}function lw(){var e;let t=j.useContext(y0),n=aw(),r=N0();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function ow(){let{router:e}=rw(j0.UseNavigateStable),t=N0(b0.UseNavigateStable),n=j.useRef(!1);return v0(()=>{n.current=!0}),j.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?e.navigate(a):e.navigate(a,nl({fromRouteId:t},i)))},[e,t])}const Ip={};function cw(e,t,n){Ip[e]||(Ip[e]=!0)}function dw(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function va(e){let{to:t,replace:n,state:r,relative:a}=e;ni()||lt(!1);let{future:i,static:l}=j.useContext(In),{matches:o}=j.useContext(cn),{pathname:c}=Rn(),d=Yt(),u=Gm(t,Wm(o,i.v7_relativeSplatPath),c,a==="path"),h=JSON.stringify(u);return j.useEffect(()=>d(JSON.parse(h),{replace:n,state:r,relative:a}),[d,h,a,n,r]),null}function uw(e){return ZN(e.context)}function ze(e){lt(!1)}function mw(e){let{basename:t="/",children:n=null,location:r,navigationType:a=nr.Pop,navigator:i,static:l=!1,future:o}=e;ni()&<(!1);let c=t.replace(/^\/*/,"/"),d=j.useMemo(()=>({basename:c,navigator:i,static:l,future:nl({v7_relativeSplatPath:!1},o)}),[c,o,i,l]);typeof r=="string"&&(r=si(r));let{pathname:u="/",search:h="",hash:x="",state:m=null,key:f="default"}=r,p=j.useMemo(()=>{let b=Za(u,c);return b==null?null:{location:{pathname:b,search:h,hash:x,state:m,key:f},navigationType:a}},[c,u,h,x,m,f,a]);return p==null?null:j.createElement(In.Provider,{value:d},j.createElement(bc.Provider,{children:n,value:p}))}function hw(e){let{children:t,location:n}=e;return JN(gu(t),n)}new Promise(()=>{});function gu(e,t){t===void 0&&(t=[]);let n=[];return j.Children.forEach(e,(r,a)=>{if(!j.isValidElement(r))return;let i=[...t,a];if(r.type===j.Fragment){n.push.apply(n,gu(r.props.children,i));return}r.type!==ze&<(!1),!r.props.index||!r.props.children||lt(!1);let l={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=gu(r.props.children,i)),n.push(l)}),n}/**
|
||
* React Router DOM v6.30.3
|
||
*
|
||
* Copyright (c) Remix Software Inc.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE.md file in the root directory of this source tree.
|
||
*
|
||
* @license MIT
|
||
*/function Wo(){return Wo=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Wo.apply(this,arguments)}function w0(e,t){if(e==null)return{};var n={},r=Object.keys(e),a,i;for(i=0;i<r.length;i++)a=r[i],!(t.indexOf(a)>=0)&&(n[a]=e[a]);return n}function fw(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function pw(e,t){return e.button===0&&(!t||t==="_self")&&!fw(e)}function yu(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function xw(e,t){let n=yu(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(i=>{n.append(a,i)})}),n}const gw=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],yw=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],vw="6";try{window.__reactRouterVersion=vw}catch{}const jw=j.createContext({isTransitioning:!1}),bw="startTransition",Rp=cj[bw];function Nw(e){let{basename:t,children:n,future:r,window:a}=e,i=j.useRef();i.current==null&&(i.current=bN({window:a,v5Compat:!0}));let l=i.current,[o,c]=j.useState({action:l.action,location:l.location}),{v7_startTransition:d}=r||{},u=j.useCallback(h=>{d&&Rp?Rp(()=>c(h)):c(h)},[c,d]);return j.useLayoutEffect(()=>l.listen(u),[l,u]),j.useEffect(()=>dw(r),[r]),j.createElement(mw,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const ww=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Sw=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ke=j.forwardRef(function(t,n){let{onClick:r,relative:a,reloadDocument:i,replace:l,state:o,target:c,to:d,preventScrollReset:u,viewTransition:h}=t,x=w0(t,gw),{basename:m}=j.useContext(In),f,p=!1;if(typeof d=="string"&&Sw.test(d)&&(f=d,ww))try{let v=new URL(window.location.href),N=d.startsWith("//")?new URL(v.protocol+d):new URL(d),E=Za(N.pathname,m);N.origin===v.origin&&E!=null?d=E+N.search+N.hash:p=!0}catch{}let b=HN(d,{relative:a}),g=Cw(d,{replace:l,state:o,target:c,preventScrollReset:u,relative:a,viewTransition:h});function y(v){r&&r(v),v.defaultPrevented||g(v)}return j.createElement("a",Wo({},x,{href:f||b,onClick:p||i?r:y,ref:n,target:c}))}),md=j.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:a=!1,className:i="",end:l=!1,style:o,to:c,viewTransition:d,children:u}=t,h=w0(t,yw),x=wc(c,{relative:h.relative}),m=Rn(),f=j.useContext(g0),{navigator:p,basename:b}=j.useContext(In),g=f!=null&&Ew(x)&&d===!0,y=p.encodeLocation?p.encodeLocation(x).pathname:x.pathname,v=m.pathname,N=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;a||(v=v.toLowerCase(),N=N?N.toLowerCase():null,y=y.toLowerCase()),N&&b&&(N=Za(N,b)||N);const E=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let P=v===y||!l&&v.startsWith(y)&&v.charAt(E)==="/",I=N!=null&&(N===y||!l&&N.startsWith(y)&&N.charAt(y.length)==="/"),w={isActive:P,isPending:I,isTransitioning:g},S=P?r:void 0,A;typeof i=="function"?A=i(w):A=[i,P?"active":null,I?"pending":null,g?"transitioning":null].filter(Boolean).join(" ");let O=typeof o=="function"?o(w):o;return j.createElement(ke,Wo({},h,{"aria-current":S,className:A,ref:n,style:O,to:c,viewTransition:d}),typeof u=="function"?u(w):u)});var vu;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(vu||(vu={}));var Lp;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Lp||(Lp={}));function kw(e){let t=j.useContext(jc);return t||lt(!1),t}function Cw(e,t){let{target:n,replace:r,state:a,preventScrollReset:i,relative:l,viewTransition:o}=t===void 0?{}:t,c=Yt(),d=Rn(),u=wc(e,{relative:l});return j.useCallback(h=>{if(pw(h,n)){h.preventDefault();let x=r!==void 0?r:Ho(d)===Ho(u);c(e,{replace:x,state:a,preventScrollReset:i,relative:l,viewTransition:o})}},[d,c,u,r,a,n,e,i,l,o])}function Sc(e){let t=j.useRef(yu(e)),n=j.useRef(!1),r=Rn(),a=j.useMemo(()=>xw(r.search,n.current?null:t.current),[r.search]),i=Yt(),l=j.useCallback((o,c)=>{const d=yu(typeof o=="function"?o(a):o);n.current=!0,i("?"+d,c)},[i,a]);return[a,l]}function Ew(e,t){t===void 0&&(t={});let n=j.useContext(jw);n==null&<(!1);let{basename:r}=kw(vu.useViewTransitionState),a=wc(e,{relative:t.relative});if(!n.isTransitioning)return!1;let i=Za(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Za(n.nextLocation.pathname,r)||n.nextLocation.pathname;return xu(a.pathname,l)!=null||xu(a.pathname,i)!=null}var ta=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Dw={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Vn,Xu,qx,Aw=(qx=class{constructor(){me(this,Vn,Dw);me(this,Xu,!1)}setTimeoutProvider(e){te(this,Vn,e)}setTimeout(e,t){return M(this,Vn).setTimeout(e,t)}clearTimeout(e){M(this,Vn).clearTimeout(e)}setInterval(e,t){return M(this,Vn).setInterval(e,t)}clearInterval(e){M(this,Vn).clearInterval(e)}},Vn=new WeakMap,Xu=new WeakMap,qx),Dr=new Aw;function Pw(e){setTimeout(e,0)}var Gr=typeof window>"u"||"Deno"in globalThis;function _t(){}function Mw(e,t){return typeof e=="function"?e(t):e}function ju(e){return typeof e=="number"&&e>=0&&e!==1/0}function S0(e,t){return Math.max(e+(t||0)-Date.now(),0)}function hr(e,t){return typeof e=="function"?e(t):e}function ks(e,t){return typeof e=="function"?e(t):e}function Op(e,t){const{type:n="all",exact:r,fetchStatus:a,predicate:i,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==Zm(l,t.options))return!1}else if(!rl(t.queryKey,l))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||a&&a!==t.state.fetchStatus||i&&!i(t))}function zp(e,t){const{exact:n,status:r,predicate:a,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Zr(t.options.mutationKey)!==Zr(i))return!1}else if(!rl(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||a&&!a(t))}function Zm(e,t){return((t==null?void 0:t.queryKeyHashFn)||Zr)(e)}function Zr(e){return JSON.stringify(e,(t,n)=>bu(n)?Object.keys(n).sort().reduce((r,a)=>(r[a]=n[a],r),{}):n)}function rl(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>rl(e[n],t[n])):!1}var Tw=Object.prototype.hasOwnProperty;function Jm(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=$p(e)&&$p(t);if(!r&&!(bu(e)&&bu(t)))return t;const i=(r?e:Object.keys(e)).length,l=r?t:Object.keys(t),o=l.length,c=r?new Array(o):{};let d=0;for(let u=0;u<o;u++){const h=r?u:l[u],x=e[h],m=t[h];if(x===m){c[h]=x,(r?u<i:Tw.call(e,h))&&d++;continue}if(x===null||m===null||typeof x!="object"||typeof m!="object"){c[h]=m;continue}const f=Jm(x,m,n+1);c[h]=f,f===x&&d++}return i===o&&d===i?e:c}function al(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function $p(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function bu(e){if(!_p(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!_p(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function _p(e){return Object.prototype.toString.call(e)==="[object Object]"}function Fw(e){return new Promise(t=>{Dr.setTimeout(t,e)})}function Nu(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Jm(e,t):t}function Iw(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Rw(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Xm=Symbol();function k0(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Xm?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Ym(e,t){return typeof e=="function"?e(...t):!!e}function Lw(e,t,n){let r=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),r||(r=!0,a.aborted?n():a.addEventListener("abort",n,{once:!0})),a)}),e}var Mr,Qn,Da,Vx,Ow=(Vx=class extends ta{constructor(){super();me(this,Mr);me(this,Qn);me(this,Da);te(this,Da,t=>{if(!Gr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){M(this,Qn)||this.setEventListener(M(this,Da))}onUnsubscribe(){var t;this.hasListeners()||((t=M(this,Qn))==null||t.call(this),te(this,Qn,void 0))}setEventListener(t){var n;te(this,Da,t),(n=M(this,Qn))==null||n.call(this),te(this,Qn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){M(this,Mr)!==t&&(te(this,Mr,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof M(this,Mr)=="boolean"?M(this,Mr):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Mr=new WeakMap,Qn=new WeakMap,Da=new WeakMap,Vx),eh=new Ow;function wu(){let e,t;const n=new Promise((a,i)=>{e=a,t=i});n.status="pending",n.catch(()=>{});function r(a){Object.assign(n,a),delete n.resolve,delete n.reject}return n.resolve=a=>{r({status:"fulfilled",value:a}),e(a)},n.reject=a=>{r({status:"rejected",reason:a}),t(a)},n}var zw=Pw;function $w(){let e=[],t=0,n=o=>{o()},r=o=>{o()},a=zw;const i=o=>{t?e.push(o):a(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&a(()=>{r(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;t++;try{c=o()}finally{t--,t||l()}return c},batchCalls:o=>(...c)=>{i(()=>{o(...c)})},schedule:i,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{a=o}}}var ht=$w(),Aa,Hn,Pa,Qx,_w=(Qx=class extends ta{constructor(){super();me(this,Aa,!0);me(this,Hn);me(this,Pa);te(this,Pa,t=>{if(!Gr&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){M(this,Hn)||this.setEventListener(M(this,Pa))}onUnsubscribe(){var t;this.hasListeners()||((t=M(this,Hn))==null||t.call(this),te(this,Hn,void 0))}setEventListener(t){var n;te(this,Pa,t),(n=M(this,Hn))==null||n.call(this),te(this,Hn,t(this.setOnline.bind(this)))}setOnline(t){M(this,Aa)!==t&&(te(this,Aa,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return M(this,Aa)}},Aa=new WeakMap,Hn=new WeakMap,Pa=new WeakMap,Qx),Go=new _w;function Kw(e){return Math.min(1e3*2**e,3e4)}function C0(e){return(e??"online")==="online"?Go.isOnline():!0}var Su=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function E0(e){let t=!1,n=0,r;const a=wu(),i=()=>a.status!=="pending",l=p=>{var b;if(!i()){const g=new Su(p);x(g),(b=e.onCancel)==null||b.call(e,g)}},o=()=>{t=!0},c=()=>{t=!1},d=()=>eh.isFocused()&&(e.networkMode==="always"||Go.isOnline())&&e.canRun(),u=()=>C0(e.networkMode)&&e.canRun(),h=p=>{i()||(r==null||r(),a.resolve(p))},x=p=>{i()||(r==null||r(),a.reject(p))},m=()=>new Promise(p=>{var b;r=g=>{(i()||d())&&p(g)},(b=e.onPause)==null||b.call(e)}).then(()=>{var p;r=void 0,i()||(p=e.onContinue)==null||p.call(e)}),f=()=>{if(i())return;let p;const b=n===0?e.initialPromise:void 0;try{p=b??e.fn()}catch(g){p=Promise.reject(g)}Promise.resolve(p).then(h).catch(g=>{var P;if(i())return;const y=e.retry??(Gr?0:3),v=e.retryDelay??Kw,N=typeof v=="function"?v(n,g):v,E=y===!0||typeof y=="number"&&n<y||typeof y=="function"&&y(n,g);if(t||!E){x(g);return}n++,(P=e.onFail)==null||P.call(e,n,g),Fw(N).then(()=>d()?void 0:m()).then(()=>{t?x(g):f()})})};return{promise:a,status:()=>a.status,cancel:l,continue:()=>(r==null||r(),a),cancelRetry:o,continueRetry:c,canStart:u,start:()=>(u()?f():m().then(f),a)}}var Tr,Hx,D0=(Hx=class{constructor(){me(this,Tr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ju(this.gcTime)&&te(this,Tr,Dr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Gr?1/0:5*60*1e3))}clearGcTimeout(){M(this,Tr)&&(Dr.clearTimeout(M(this,Tr)),te(this,Tr,void 0))}},Tr=new WeakMap,Hx),Fr,Ma,ws,Ir,Ct,ml,Rr,Ls,pn,Wx,Bw=(Wx=class extends D0{constructor(t){super();me(this,Ls);me(this,Fr);me(this,Ma);me(this,ws);me(this,Ir);me(this,Ct);me(this,ml);me(this,Rr);te(this,Rr,!1),te(this,ml,t.defaultOptions),this.setOptions(t.options),this.observers=[],te(this,Ir,t.client),te(this,ws,M(this,Ir).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,te(this,Fr,Bp(this.options)),this.state=t.state??M(this,Fr),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=M(this,Ct))==null?void 0:t.promise}setOptions(t){if(this.options={...M(this,ml),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=Bp(this.options);n.data!==void 0&&(this.setState(Kp(n.data,n.dataUpdatedAt)),te(this,Fr,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&M(this,ws).remove(this)}setData(t,n){const r=Nu(this.state.data,t,this.options);return be(this,Ls,pn).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){be(this,Ls,pn).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,a;const n=(r=M(this,Ct))==null?void 0:r.promise;return(a=M(this,Ct))==null||a.cancel(t),n?n.then(_t).catch(_t):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(M(this,Fr))}isActive(){return this.observers.some(t=>ks(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Xm||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>hr(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!S0(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=M(this,Ct))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=M(this,Ct))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),M(this,ws).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(M(this,Ct)&&(M(this,Rr)?M(this,Ct).cancel({revert:!0}):M(this,Ct).cancelRetry()),this.scheduleGc()),M(this,ws).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||be(this,Ls,pn).call(this,{type:"invalidate"})}async fetch(t,n){var c,d,u,h,x,m,f,p,b,g,y,v;if(this.state.fetchStatus!=="idle"&&((c=M(this,Ct))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(M(this,Ct))return M(this,Ct).continueRetry(),M(this,Ct).promise}if(t&&this.setOptions(t),!this.options.queryFn){const N=this.observers.find(E=>E.options.queryFn);N&&this.setOptions(N.options)}const r=new AbortController,a=N=>{Object.defineProperty(N,"signal",{enumerable:!0,get:()=>(te(this,Rr,!0),r.signal)})},i=()=>{const N=k0(this.options,n),P=(()=>{const I={client:M(this,Ir),queryKey:this.queryKey,meta:this.meta};return a(I),I})();return te(this,Rr,!1),this.options.persister?this.options.persister(N,P,this):N(P)},o=(()=>{const N={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:M(this,Ir),state:this.state,fetchFn:i};return a(N),N})();(d=this.options.behavior)==null||d.onFetch(o,this),te(this,Ma,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=o.fetchOptions)==null?void 0:u.meta))&&be(this,Ls,pn).call(this,{type:"fetch",meta:(h=o.fetchOptions)==null?void 0:h.meta}),te(this,Ct,E0({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:N=>{N instanceof Su&&N.revert&&this.setState({...M(this,Ma),fetchStatus:"idle"}),r.abort()},onFail:(N,E)=>{be(this,Ls,pn).call(this,{type:"failed",failureCount:N,error:E})},onPause:()=>{be(this,Ls,pn).call(this,{type:"pause"})},onContinue:()=>{be(this,Ls,pn).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const N=await M(this,Ct).start();if(N===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(N),(m=(x=M(this,ws).config).onSuccess)==null||m.call(x,N,this),(p=(f=M(this,ws).config).onSettled)==null||p.call(f,N,this.state.error,this),N}catch(N){if(N instanceof Su){if(N.silent)return M(this,Ct).promise;if(N.revert){if(this.state.data===void 0)throw N;return this.state.data}}throw be(this,Ls,pn).call(this,{type:"error",error:N}),(g=(b=M(this,ws).config).onError)==null||g.call(b,N,this),(v=(y=M(this,ws).config).onSettled)==null||v.call(y,this.state.data,N,this),N}finally{this.scheduleGc()}}},Fr=new WeakMap,Ma=new WeakMap,ws=new WeakMap,Ir=new WeakMap,Ct=new WeakMap,ml=new WeakMap,Rr=new WeakMap,Ls=new WeakSet,pn=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...A0(r.data,this.options),fetchMeta:t.meta??null};case"success":const a={...r,...Kp(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return te(this,Ma,t.manual?a:void 0),a;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),ht.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),M(this,ws).notify({query:this,type:"updated",action:t})})},Wx);function A0(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:C0(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Kp(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Bp(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var ns,De,hl,Qt,Lr,Ta,vn,Wn,fl,Fa,Ia,Or,zr,Gn,Ra,$e,ki,ku,Cu,Eu,Du,Au,Pu,Mu,P0,Gx,th=(Gx=class extends ta{constructor(t,n){super();me(this,$e);me(this,ns);me(this,De);me(this,hl);me(this,Qt);me(this,Lr);me(this,Ta);me(this,vn);me(this,Wn);me(this,fl);me(this,Fa);me(this,Ia);me(this,Or);me(this,zr);me(this,Gn);me(this,Ra,new Set);this.options=n,te(this,ns,t),te(this,Wn,null),te(this,vn,wu()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(M(this,De).addObserver(this),Up(M(this,De),this.options)?be(this,$e,ki).call(this):this.updateResult(),be(this,$e,Du).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Tu(M(this,De),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Tu(M(this,De),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,be(this,$e,Au).call(this),be(this,$e,Pu).call(this),M(this,De).removeObserver(this)}setOptions(t){const n=this.options,r=M(this,De);if(this.options=M(this,ns).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ks(this.options.enabled,M(this,De))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");be(this,$e,Mu).call(this),M(this,De).setOptions(this.options),n._defaulted&&!al(this.options,n)&&M(this,ns).getQueryCache().notify({type:"observerOptionsUpdated",query:M(this,De),observer:this});const a=this.hasListeners();a&&qp(M(this,De),r,this.options,n)&&be(this,$e,ki).call(this),this.updateResult(),a&&(M(this,De)!==r||ks(this.options.enabled,M(this,De))!==ks(n.enabled,M(this,De))||hr(this.options.staleTime,M(this,De))!==hr(n.staleTime,M(this,De)))&&be(this,$e,ku).call(this);const i=be(this,$e,Cu).call(this);a&&(M(this,De)!==r||ks(this.options.enabled,M(this,De))!==ks(n.enabled,M(this,De))||i!==M(this,Gn))&&be(this,$e,Eu).call(this,i)}getOptimisticResult(t){const n=M(this,ns).getQueryCache().build(M(this,ns),t),r=this.createResult(n,t);return qw(this,r)&&(te(this,Qt,r),te(this,Ta,this.options),te(this,Lr,M(this,De).state)),r}getCurrentResult(){return M(this,Qt)}trackResult(t,n){return new Proxy(t,{get:(r,a)=>(this.trackProp(a),n==null||n(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&M(this,vn).status==="pending"&&M(this,vn).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,a))})}trackProp(t){M(this,Ra).add(t)}getCurrentQuery(){return M(this,De)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=M(this,ns).defaultQueryOptions(t),r=M(this,ns).getQueryCache().build(M(this,ns),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return be(this,$e,ki).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),M(this,Qt)))}createResult(t,n){var S;const r=M(this,De),a=this.options,i=M(this,Qt),l=M(this,Lr),o=M(this,Ta),d=t!==r?t.state:M(this,hl),{state:u}=t;let h={...u},x=!1,m;if(n._optimisticResults){const A=this.hasListeners(),O=!A&&Up(t,n),R=A&&qp(t,r,n,a);(O||R)&&(h={...h,...A0(u.data,t.options)}),n._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:f,errorUpdatedAt:p,status:b}=h;m=h.data;let g=!1;if(n.placeholderData!==void 0&&m===void 0&&b==="pending"){let A;i!=null&&i.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(A=i.data,g=!0):A=typeof n.placeholderData=="function"?n.placeholderData((S=M(this,Ia))==null?void 0:S.state.data,M(this,Ia)):n.placeholderData,A!==void 0&&(b="success",m=Nu(i==null?void 0:i.data,A,n),x=!0)}if(n.select&&m!==void 0&&!g)if(i&&m===(l==null?void 0:l.data)&&n.select===M(this,fl))m=M(this,Fa);else try{te(this,fl,n.select),m=n.select(m),m=Nu(i==null?void 0:i.data,m,n),te(this,Fa,m),te(this,Wn,null)}catch(A){te(this,Wn,A)}M(this,Wn)&&(f=M(this,Wn),m=M(this,Fa),p=Date.now(),b="error");const y=h.fetchStatus==="fetching",v=b==="pending",N=b==="error",E=v&&y,P=m!==void 0,w={status:b,fetchStatus:h.fetchStatus,isPending:v,isSuccess:b==="success",isError:N,isInitialLoading:E,isLoading:E,data:m,dataUpdatedAt:h.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>d.dataUpdateCount||h.errorUpdateCount>d.errorUpdateCount,isFetching:y,isRefetching:y&&!v,isLoadingError:N&&!P,isPaused:h.fetchStatus==="paused",isPlaceholderData:x,isRefetchError:N&&P,isStale:sh(t,n),refetch:this.refetch,promise:M(this,vn),isEnabled:ks(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const A=w.data!==void 0,O=w.status==="error"&&!A,R=z=>{O?z.reject(w.error):A&&z.resolve(w.data)},q=()=>{const z=te(this,vn,w.promise=wu());R(z)},D=M(this,vn);switch(D.status){case"pending":t.queryHash===r.queryHash&&R(D);break;case"fulfilled":(O||w.data!==D.value)&&q();break;case"rejected":(!O||w.error!==D.reason)&&q();break}}return w}updateResult(){const t=M(this,Qt),n=this.createResult(M(this,De),this.options);if(te(this,Lr,M(this,De).state),te(this,Ta,this.options),M(this,Lr).data!==void 0&&te(this,Ia,M(this,De)),al(n,t))return;te(this,Qt,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!M(this,Ra).size)return!0;const l=new Set(i??M(this,Ra));return this.options.throwOnError&&l.add("error"),Object.keys(M(this,Qt)).some(o=>{const c=o;return M(this,Qt)[c]!==t[c]&&l.has(c)})};be(this,$e,P0).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&be(this,$e,Du).call(this)}},ns=new WeakMap,De=new WeakMap,hl=new WeakMap,Qt=new WeakMap,Lr=new WeakMap,Ta=new WeakMap,vn=new WeakMap,Wn=new WeakMap,fl=new WeakMap,Fa=new WeakMap,Ia=new WeakMap,Or=new WeakMap,zr=new WeakMap,Gn=new WeakMap,Ra=new WeakMap,$e=new WeakSet,ki=function(t){be(this,$e,Mu).call(this);let n=M(this,De).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(_t)),n},ku=function(){be(this,$e,Au).call(this);const t=hr(this.options.staleTime,M(this,De));if(Gr||M(this,Qt).isStale||!ju(t))return;const r=S0(M(this,Qt).dataUpdatedAt,t)+1;te(this,Or,Dr.setTimeout(()=>{M(this,Qt).isStale||this.updateResult()},r))},Cu=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(M(this,De)):this.options.refetchInterval)??!1},Eu=function(t){be(this,$e,Pu).call(this),te(this,Gn,t),!(Gr||ks(this.options.enabled,M(this,De))===!1||!ju(M(this,Gn))||M(this,Gn)===0)&&te(this,zr,Dr.setInterval(()=>{(this.options.refetchIntervalInBackground||eh.isFocused())&&be(this,$e,ki).call(this)},M(this,Gn)))},Du=function(){be(this,$e,ku).call(this),be(this,$e,Eu).call(this,be(this,$e,Cu).call(this))},Au=function(){M(this,Or)&&(Dr.clearTimeout(M(this,Or)),te(this,Or,void 0))},Pu=function(){M(this,zr)&&(Dr.clearInterval(M(this,zr)),te(this,zr,void 0))},Mu=function(){const t=M(this,ns).getQueryCache().build(M(this,ns),this.options);if(t===M(this,De))return;const n=M(this,De);te(this,De,t),te(this,hl,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},P0=function(t){ht.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(M(this,Qt))}),M(this,ns).getQueryCache().notify({query:M(this,De),type:"observerResultsUpdated"})})},Gx);function Uw(e,t){return ks(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Up(e,t){return Uw(e,t)||e.state.data!==void 0&&Tu(e,t,t.refetchOnMount)}function Tu(e,t,n){if(ks(t.enabled,e)!==!1&&hr(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&sh(e,t)}return!1}function qp(e,t,n,r){return(e!==t||ks(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&sh(e,n)}function sh(e,t){return ks(t.enabled,e)!==!1&&e.isStaleByTime(hr(t.staleTime,e))}function qw(e,t){return!al(e.getCurrentResult(),t)}function Vp(e){return{onFetch:(t,n)=>{var u,h,x,m,f;const r=t.options,a=(x=(h=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:h.fetchMore)==null?void 0:x.direction,i=((m=t.state.data)==null?void 0:m.pages)||[],l=((f=t.state.data)==null?void 0:f.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const d=async()=>{let p=!1;const b=v=>{Lw(v,()=>t.signal,()=>p=!0)},g=k0(t.options,t.fetchOptions),y=async(v,N,E)=>{if(p)return Promise.reject();if(N==null&&v.pages.length)return Promise.resolve(v);const I=(()=>{const O={client:t.client,queryKey:t.queryKey,pageParam:N,direction:E?"backward":"forward",meta:t.options.meta};return b(O),O})(),w=await g(I),{maxPages:S}=t.options,A=E?Rw:Iw;return{pages:A(v.pages,w,S),pageParams:A(v.pageParams,N,S)}};if(a&&i.length){const v=a==="backward",N=v?Vw:Qp,E={pages:i,pageParams:l},P=N(r,E);o=await y(E,P,v)}else{const v=e??i.length;do{const N=c===0?l[0]??r.initialPageParam:Qp(r,o);if(c>0&&N==null)break;o=await y(o,N),c++}while(c<v)}return o};t.options.persister?t.fetchFn=()=>{var p,b;return(b=(p=t.options).persister)==null?void 0:b.call(p,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=d}}}function Qp(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Vw(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var pl,Xs,Ht,$r,Ys,zn,Zx,Qw=(Zx=class extends D0{constructor(t){super();me(this,Ys);me(this,pl);me(this,Xs);me(this,Ht);me(this,$r);te(this,pl,t.client),this.mutationId=t.mutationId,te(this,Ht,t.mutationCache),te(this,Xs,[]),this.state=t.state||M0(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){M(this,Xs).includes(t)||(M(this,Xs).push(t),this.clearGcTimeout(),M(this,Ht).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){te(this,Xs,M(this,Xs).filter(n=>n!==t)),this.scheduleGc(),M(this,Ht).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){M(this,Xs).length||(this.state.status==="pending"?this.scheduleGc():M(this,Ht).remove(this))}continue(){var t;return((t=M(this,$r))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,d,u,h,x,m,f,p,b,g,y,v,N,E,P,I,w,S;const n=()=>{be(this,Ys,zn).call(this,{type:"continue"})},r={client:M(this,pl),meta:this.options.meta,mutationKey:this.options.mutationKey};te(this,$r,E0({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(A,O)=>{be(this,Ys,zn).call(this,{type:"failed",failureCount:A,error:O})},onPause:()=>{be(this,Ys,zn).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>M(this,Ht).canRun(this)}));const a=this.state.status==="pending",i=!M(this,$r).canStart();try{if(a)n();else{be(this,Ys,zn).call(this,{type:"pending",variables:t,isPaused:i}),await((o=(l=M(this,Ht).config).onMutate)==null?void 0:o.call(l,t,this,r));const O=await((d=(c=this.options).onMutate)==null?void 0:d.call(c,t,r));O!==this.state.context&&be(this,Ys,zn).call(this,{type:"pending",context:O,variables:t,isPaused:i})}const A=await M(this,$r).start();return await((h=(u=M(this,Ht).config).onSuccess)==null?void 0:h.call(u,A,t,this.state.context,this,r)),await((m=(x=this.options).onSuccess)==null?void 0:m.call(x,A,t,this.state.context,r)),await((p=(f=M(this,Ht).config).onSettled)==null?void 0:p.call(f,A,null,this.state.variables,this.state.context,this,r)),await((g=(b=this.options).onSettled)==null?void 0:g.call(b,A,null,t,this.state.context,r)),be(this,Ys,zn).call(this,{type:"success",data:A}),A}catch(A){try{await((v=(y=M(this,Ht).config).onError)==null?void 0:v.call(y,A,t,this.state.context,this,r))}catch(O){Promise.reject(O)}try{await((E=(N=this.options).onError)==null?void 0:E.call(N,A,t,this.state.context,r))}catch(O){Promise.reject(O)}try{await((I=(P=M(this,Ht).config).onSettled)==null?void 0:I.call(P,void 0,A,this.state.variables,this.state.context,this,r))}catch(O){Promise.reject(O)}try{await((S=(w=this.options).onSettled)==null?void 0:S.call(w,void 0,A,t,this.state.context,r))}catch(O){Promise.reject(O)}throw be(this,Ys,zn).call(this,{type:"error",error:A}),A}finally{M(this,Ht).runNext(this)}}},pl=new WeakMap,Xs=new WeakMap,Ht=new WeakMap,$r=new WeakMap,Ys=new WeakSet,zn=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),ht.batch(()=>{M(this,Xs).forEach(r=>{r.onMutationUpdate(t)}),M(this,Ht).notify({mutation:this,type:"updated",action:t})})},Zx);function M0(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var jn,Os,xl,Jx,Hw=(Jx=class extends ta{constructor(t={}){super();me(this,jn);me(this,Os);me(this,xl);this.config=t,te(this,jn,new Set),te(this,Os,new Map),te(this,xl,0)}build(t,n,r){const a=new Qw({client:t,mutationCache:this,mutationId:++Ll(this,xl)._,options:t.defaultMutationOptions(n),state:r});return this.add(a),a}add(t){M(this,jn).add(t);const n=eo(t);if(typeof n=="string"){const r=M(this,Os).get(n);r?r.push(t):M(this,Os).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(M(this,jn).delete(t)){const n=eo(t);if(typeof n=="string"){const r=M(this,Os).get(n);if(r)if(r.length>1){const a=r.indexOf(t);a!==-1&&r.splice(a,1)}else r[0]===t&&M(this,Os).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=eo(t);if(typeof n=="string"){const r=M(this,Os).get(n),a=r==null?void 0:r.find(i=>i.state.status==="pending");return!a||a===t}else return!0}runNext(t){var r;const n=eo(t);if(typeof n=="string"){const a=(r=M(this,Os).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ht.batch(()=>{M(this,jn).forEach(t=>{this.notify({type:"removed",mutation:t})}),M(this,jn).clear(),M(this,Os).clear()})}getAll(){return Array.from(M(this,jn))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>zp(n,r))}findAll(t={}){return this.getAll().filter(n=>zp(t,n))}notify(t){ht.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return ht.batch(()=>Promise.all(t.map(n=>n.continue().catch(_t))))}},jn=new WeakMap,Os=new WeakMap,xl=new WeakMap,Jx);function eo(e){var t;return(t=e.options.scope)==null?void 0:t.id}var bn,Zn,rs,Nn,En,go,Fu,Xx,Ww=(Xx=class extends ta{constructor(n,r){super();me(this,En);me(this,bn);me(this,Zn);me(this,rs);me(this,Nn);te(this,bn,n),this.setOptions(r),this.bindMethods(),be(this,En,go).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var a;const r=this.options;this.options=M(this,bn).defaultMutationOptions(n),al(this.options,r)||M(this,bn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:M(this,rs),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Zr(r.mutationKey)!==Zr(this.options.mutationKey)?this.reset():((a=M(this,rs))==null?void 0:a.state.status)==="pending"&&M(this,rs).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=M(this,rs))==null||n.removeObserver(this)}onMutationUpdate(n){be(this,En,go).call(this),be(this,En,Fu).call(this,n)}getCurrentResult(){return M(this,Zn)}reset(){var n;(n=M(this,rs))==null||n.removeObserver(this),te(this,rs,void 0),be(this,En,go).call(this),be(this,En,Fu).call(this)}mutate(n,r){var a;return te(this,Nn,r),(a=M(this,rs))==null||a.removeObserver(this),te(this,rs,M(this,bn).getMutationCache().build(M(this,bn),this.options)),M(this,rs).addObserver(this),M(this,rs).execute(n)}},bn=new WeakMap,Zn=new WeakMap,rs=new WeakMap,Nn=new WeakMap,En=new WeakSet,go=function(){var r;const n=((r=M(this,rs))==null?void 0:r.state)??M0();te(this,Zn,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Fu=function(n){ht.batch(()=>{var r,a,i,l,o,c,d,u;if(M(this,Nn)&&this.hasListeners()){const h=M(this,Zn).variables,x=M(this,Zn).context,m={client:M(this,bn),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(a=(r=M(this,Nn)).onSuccess)==null||a.call(r,n.data,h,x,m)}catch(f){Promise.reject(f)}try{(l=(i=M(this,Nn)).onSettled)==null||l.call(i,n.data,null,h,x,m)}catch(f){Promise.reject(f)}}else if((n==null?void 0:n.type)==="error"){try{(c=(o=M(this,Nn)).onError)==null||c.call(o,n.error,h,x,m)}catch(f){Promise.reject(f)}try{(u=(d=M(this,Nn)).onSettled)==null||u.call(d,void 0,n.error,h,x,m)}catch(f){Promise.reject(f)}}}this.listeners.forEach(h=>{h(M(this,Zn))})})},Xx);function Hp(e,t){const n=new Set(t);return e.filter(r=>!n.has(r))}function Gw(e,t,n){const r=e.slice(0);return r[t]=n,r}var La,fs,Oa,za,Ss,Jn,gl,yl,vl,jl,Ot,Iu,Ru,Lu,Ou,zu,Yx,Zw=(Yx=class extends ta{constructor(t,n,r){super();me(this,Ot);me(this,La);me(this,fs);me(this,Oa);me(this,za);me(this,Ss);me(this,Jn);me(this,gl);me(this,yl);me(this,vl);me(this,jl,[]);te(this,La,t),te(this,za,r),te(this,Oa,[]),te(this,Ss,[]),te(this,fs,[]),this.setQueries(n)}onSubscribe(){this.listeners.size===1&&M(this,Ss).forEach(t=>{t.subscribe(n=>{be(this,Ot,Ou).call(this,t,n)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,M(this,Ss).forEach(t=>{t.destroy()})}setQueries(t,n){te(this,Oa,t),te(this,za,n),ht.batch(()=>{const r=M(this,Ss),a=be(this,Ot,Lu).call(this,M(this,Oa));a.forEach(h=>h.observer.setOptions(h.defaultedQueryOptions));const i=a.map(h=>h.observer),l=i.map(h=>h.getCurrentResult()),o=r.length!==i.length,c=i.some((h,x)=>h!==r[x]),d=o||c,u=d?!0:l.some((h,x)=>{const m=M(this,fs)[x];return!m||!al(h,m)});!d&&!u||(d&&(te(this,jl,a),te(this,Ss,i)),te(this,fs,l),this.hasListeners()&&(d&&(Hp(r,i).forEach(h=>{h.destroy()}),Hp(i,r).forEach(h=>{h.subscribe(x=>{be(this,Ot,Ou).call(this,h,x)})})),be(this,Ot,zu).call(this)))})}getCurrentResult(){return M(this,fs)}getQueries(){return M(this,Ss).map(t=>t.getCurrentQuery())}getObservers(){return M(this,Ss)}getOptimisticResult(t,n){const r=be(this,Ot,Lu).call(this,t),a=r.map(l=>l.observer.getOptimisticResult(l.defaultedQueryOptions)),i=r.map(l=>l.defaultedQueryOptions.queryHash);return[a,l=>be(this,Ot,Ru).call(this,l??a,n,i),()=>be(this,Ot,Iu).call(this,a,r)]}},La=new WeakMap,fs=new WeakMap,Oa=new WeakMap,za=new WeakMap,Ss=new WeakMap,Jn=new WeakMap,gl=new WeakMap,yl=new WeakMap,vl=new WeakMap,jl=new WeakMap,Ot=new WeakSet,Iu=function(t,n){return n.map((r,a)=>{const i=t[a];return r.defaultedQueryOptions.notifyOnChangeProps?i:r.observer.trackResult(i,l=>{n.forEach(o=>{o.observer.trackProp(l)})})})},Ru=function(t,n,r){if(n){const a=M(this,vl),i=r!==void 0&&a!==void 0&&(a.length!==r.length||r.some((l,o)=>l!==a[o]));return(!M(this,Jn)||M(this,fs)!==M(this,yl)||i||n!==M(this,gl))&&(te(this,gl,n),te(this,yl,M(this,fs)),r!==void 0&&te(this,vl,r),te(this,Jn,Jm(M(this,Jn),n(t)))),M(this,Jn)}return t},Lu=function(t){const n=new Map;M(this,Ss).forEach(a=>{const i=a.options.queryHash;if(!i)return;const l=n.get(i);l?l.push(a):n.set(i,[a])});const r=[];return t.forEach(a=>{var c;const i=M(this,La).defaultQueryOptions(a),o=((c=n.get(i.queryHash))==null?void 0:c.shift())??new th(M(this,La),i);r.push({defaultedQueryOptions:i,observer:o})}),r},Ou=function(t,n){const r=M(this,Ss).indexOf(t);r!==-1&&(te(this,fs,Gw(M(this,fs),r,n)),be(this,Ot,zu).call(this))},zu=function(){var t;if(this.hasListeners()){const n=M(this,Jn),r=be(this,Ot,Iu).call(this,M(this,fs),M(this,jl)),a=be(this,Ot,Ru).call(this,r,(t=M(this,za))==null?void 0:t.combine);n!==a&&ht.batch(()=>{this.listeners.forEach(i=>{i(M(this,fs))})})}},Yx),en,eg,Jw=(eg=class extends ta{constructor(t={}){super();me(this,en);this.config=t,te(this,en,new Map)}build(t,n,r){const a=n.queryKey,i=n.queryHash??Zm(a,n);let l=this.get(i);return l||(l=new Bw({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(a)}),this.add(l)),l}add(t){M(this,en).has(t.queryHash)||(M(this,en).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=M(this,en).get(t.queryHash);n&&(t.destroy(),n===t&&M(this,en).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ht.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return M(this,en).get(t)}getAll(){return[...M(this,en).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Op(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>Op(t,r)):n}notify(t){ht.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){ht.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ht.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},en=new WeakMap,eg),dt,Xn,Yn,$a,_a,er,Ka,Ba,tg,Xw=(tg=class{constructor(e={}){me(this,dt);me(this,Xn);me(this,Yn);me(this,$a);me(this,_a);me(this,er);me(this,Ka);me(this,Ba);te(this,dt,e.queryCache||new Jw),te(this,Xn,e.mutationCache||new Hw),te(this,Yn,e.defaultOptions||{}),te(this,$a,new Map),te(this,_a,new Map),te(this,er,0)}mount(){Ll(this,er)._++,M(this,er)===1&&(te(this,Ka,eh.subscribe(async e=>{e&&(await this.resumePausedMutations(),M(this,dt).onFocus())})),te(this,Ba,Go.subscribe(async e=>{e&&(await this.resumePausedMutations(),M(this,dt).onOnline())})))}unmount(){var e,t;Ll(this,er)._--,M(this,er)===0&&((e=M(this,Ka))==null||e.call(this),te(this,Ka,void 0),(t=M(this,Ba))==null||t.call(this),te(this,Ba,void 0))}isFetching(e){return M(this,dt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return M(this,Xn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=M(this,dt).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=M(this,dt).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(hr(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return M(this,dt).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),a=M(this,dt).get(r.queryHash),i=a==null?void 0:a.state.data,l=Mw(t,i);if(l!==void 0)return M(this,dt).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return ht.batch(()=>M(this,dt).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=M(this,dt).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=M(this,dt);ht.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=M(this,dt);return ht.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=ht.batch(()=>M(this,dt).findAll(e).map(a=>a.cancel(n)));return Promise.all(r).then(_t).catch(_t)}invalidateQueries(e,t={}){return ht.batch(()=>(M(this,dt).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=ht.batch(()=>M(this,dt).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,n);return n.throwOnError||(i=i.catch(_t)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(_t)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=M(this,dt).build(this,t);return n.isStaleByTime(hr(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(_t).catch(_t)}fetchInfiniteQuery(e){return e.behavior=Vp(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(_t).catch(_t)}ensureInfiniteQueryData(e){return e.behavior=Vp(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Go.isOnline()?M(this,Xn).resumePausedMutations():Promise.resolve()}getQueryCache(){return M(this,dt)}getMutationCache(){return M(this,Xn)}getDefaultOptions(){return M(this,Yn)}setDefaultOptions(e){te(this,Yn,e)}setQueryDefaults(e,t){M(this,$a).set(Zr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...M(this,$a).values()],n={};return t.forEach(r=>{rl(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){M(this,_a).set(Zr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...M(this,_a).values()],n={};return t.forEach(r=>{rl(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...M(this,Yn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Zm(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Xm&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...M(this,Yn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){M(this,dt).clear(),M(this,Xn).clear()}},dt=new WeakMap,Xn=new WeakMap,Yn=new WeakMap,$a=new WeakMap,_a=new WeakMap,er=new WeakMap,Ka=new WeakMap,Ba=new WeakMap,tg),T0=j.createContext(void 0),ge=e=>{const t=j.useContext(T0);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Yw=({client:e,children:t})=>(j.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(T0.Provider,{value:e,children:t})),F0=j.createContext(!1),I0=()=>j.useContext(F0);F0.Provider;function e1(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var t1=j.createContext(e1()),R0=()=>j.useContext(t1),L0=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Ym(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},O0=e=>{j.useEffect(()=>{e.clearReset()},[e])},z0=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(a&&e.data===void 0||Ym(n,[e.error,r])),$0=e=>{if(e.suspense){const n=a=>a==="static"?a:Math.max(a??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...a)=>n(r(...a)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},_0=(e,t)=>e.isLoading&&e.isFetching&&!t,$u=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Zo=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function s1({queries:e,...t},n){const r=ge(),a=I0(),i=R0(),l=j.useMemo(()=>e.map(p=>{const b=r.defaultQueryOptions(p);return b._optimisticResults=a?"isRestoring":"optimistic",b}),[e,r,a]);l.forEach(p=>{$0(p);const b=r.getQueryCache().get(p.queryHash);L0(p,i,b)}),O0(i);const[o]=j.useState(()=>new Zw(r,l,t)),[c,d,u]=o.getOptimisticResult(l,t.combine),h=!a&&t.subscribed!==!1;j.useSyncExternalStore(j.useCallback(p=>h?o.subscribe(ht.batchCalls(p)):_t,[o,h]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),j.useEffect(()=>{o.setQueries(l,t)},[l,t,o]);const m=c.some((p,b)=>$u(l[b],p))?c.flatMap((p,b)=>{const g=l[b];if(g){const y=new th(r,g);if($u(g,p))return Zo(g,y,i);_0(p,a)&&Zo(g,y,i)}return[]}):[];if(m.length>0)throw Promise.all(m);const f=c.find((p,b)=>{const g=l[b];return g&&z0({result:p,errorResetBoundary:i,throwOnError:g.throwOnError,query:r.getQueryCache().get(g.queryHash),suspense:g.suspense})});if(f!=null&&f.error)throw f.error;return d(u())}function n1(e,t,n){var x,m,f,p;const r=I0(),a=R0(),i=ge(),l=i.defaultQueryOptions(e);(m=(x=i.getDefaultOptions().queries)==null?void 0:x._experimental_beforeQuery)==null||m.call(x,l);const o=i.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",$0(l),L0(l,a,o),O0(a);const c=!i.getQueryCache().get(l.queryHash),[d]=j.useState(()=>new t(i,l)),u=d.getOptimisticResult(l),h=!r&&e.subscribed!==!1;if(j.useSyncExternalStore(j.useCallback(b=>{const g=h?d.subscribe(ht.batchCalls(b)):_t;return d.updateResult(),g},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),j.useEffect(()=>{d.setOptions(l)},[l,d]),$u(l,u))throw Zo(l,d,a);if(z0({result:u,errorResetBoundary:a,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw u.error;if((p=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_afterQuery)==null||p.call(f,l,u),l.experimental_prefetchInRender&&!Gr&&_0(u,r)){const b=c?Zo(l,d,a):o==null?void 0:o.promise;b==null||b.catch(_t).finally(()=>{d.updateResult()})}return l.notifyOnChangeProps?u:d.trackResult(u)}function fe(e,t){return n1(e,th)}function G(e,t){const n=ge(),[r]=j.useState(()=>new Ww(n,e));j.useEffect(()=>{r.setOptions(e)},[r,e]);const a=j.useSyncExternalStore(j.useCallback(l=>r.subscribe(ht.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=j.useCallback((l,o)=>{r.mutate(l,o).catch(_t)},[r]);if(a.error&&Ym(r.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}let r1={data:""},a1=e=>{if(typeof window=="object"){let t=(e?e.querySelector("#_goober"):window._goober)||Object.assign(document.createElement("style"),{innerHTML:" ",id:"_goober"});return t.nonce=window.__nonce__,t.parentNode||(e||document.head).appendChild(t),t.firstChild}return e||r1},i1=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,l1=/\/\*[^]*?\*\/| +/g,Wp=/\n+/g,Un=(e,t)=>{let n="",r="",a="";for(let i in e){let l=e[i];i[0]=="@"?i[1]=="i"?n=i+" "+l+";":r+=i[1]=="f"?Un(l,i):i+"{"+Un(l,i[1]=="k"?"":t)+"}":typeof l=="object"?r+=Un(l,t?t.replace(/([^,])+/g,o=>i.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,c=>/&/.test(c)?c.replace(/&/g,o):o?o+" "+c:c)):i):l!=null&&(i=/^--/.test(i)?i:i.replace(/[A-Z]/g,"-$&").toLowerCase(),a+=Un.p?Un.p(i,l):i+":"+l+";")}return n+(t&&a?t+"{"+a+"}":a)+r},hn={},K0=e=>{if(typeof e=="object"){let t="";for(let n in e)t+=n+K0(e[n]);return t}return e},o1=(e,t,n,r,a)=>{let i=K0(e),l=hn[i]||(hn[i]=(c=>{let d=0,u=11;for(;d<c.length;)u=101*u+c.charCodeAt(d++)>>>0;return"go"+u})(i));if(!hn[l]){let c=i!==e?e:(d=>{let u,h,x=[{}];for(;u=i1.exec(d.replace(l1,""));)u[4]?x.shift():u[3]?(h=u[3].replace(Wp," ").trim(),x.unshift(x[0][h]=x[0][h]||{})):x[0][u[1]]=u[2].replace(Wp," ").trim();return x[0]})(e);hn[l]=Un(a?{["@keyframes "+l]:c}:c,n?"":"."+l)}let o=n&&hn.g?hn.g:null;return n&&(hn.g=hn[l]),((c,d,u,h)=>{h?d.data=d.data.replace(h,c):d.data.indexOf(c)===-1&&(d.data=u?c+d.data:d.data+c)})(hn[l],t,r,o),l},c1=(e,t,n)=>e.reduce((r,a,i)=>{let l=t[i];if(l&&l.call){let o=l(n),c=o&&o.props&&o.props.className||/^go/.test(o)&&o;l=c?"."+c:o&&typeof o=="object"?o.props?"":Un(o,""):o===!1?"":o}return r+a+(l??"")},"");function kc(e){let t=this||{},n=e.call?e(t.p):e;return o1(n.unshift?n.raw?c1(n,[].slice.call(arguments,1),t.p):n.reduce((r,a)=>Object.assign(r,a&&a.call?a(t.p):a),{}):n,a1(t.target),t.g,t.o,t.k)}let B0,_u,Ku;kc.bind({g:1});let Tn=kc.bind({k:1});function d1(e,t,n,r){Un.p=t,B0=e,_u=n,Ku=r}function jr(e,t){let n=this||{};return function(){let r=arguments;function a(i,l){let o=Object.assign({},i),c=o.className||a.className;n.p=Object.assign({theme:_u&&_u()},o),n.o=/ *go\d+/.test(c),o.className=kc.apply(n,r)+(c?" "+c:"");let d=e;return e[0]&&(d=o.as||e,delete o.as),Ku&&d[0]&&Ku(o),B0(d,o)}return a}}var u1=e=>typeof e=="function",Jo=(e,t)=>u1(e)?e(t):e,m1=(()=>{let e=0;return()=>(++e).toString()})(),U0=(()=>{let e;return()=>{if(e===void 0&&typeof window<"u"){let t=matchMedia("(prefers-reduced-motion: reduce)");e=!t||t.matches}return e}})(),h1=20,nh="default",q0=(e,t)=>{let{toastLimit:n}=e.settings;switch(t.type){case 0:return{...e,toasts:[t.toast,...e.toasts].slice(0,n)};case 1:return{...e,toasts:e.toasts.map(l=>l.id===t.toast.id?{...l,...t.toast}:l)};case 2:let{toast:r}=t;return q0(e,{type:e.toasts.find(l=>l.id===r.id)?1:0,toast:r});case 3:let{toastId:a}=t;return{...e,toasts:e.toasts.map(l=>l.id===a||a===void 0?{...l,dismissed:!0,visible:!1}:l)};case 4:return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(l=>l.id!==t.toastId)};case 5:return{...e,pausedAt:t.time};case 6:let i=t.time-(e.pausedAt||0);return{...e,pausedAt:void 0,toasts:e.toasts.map(l=>({...l,pauseDuration:l.pauseDuration+i}))}}},yo=[],V0={toasts:[],pausedAt:void 0,settings:{toastLimit:h1}},sn={},Q0=(e,t=nh)=>{sn[t]=q0(sn[t]||V0,e),yo.forEach(([n,r])=>{n===t&&r(sn[t])})},H0=e=>Object.keys(sn).forEach(t=>Q0(e,t)),f1=e=>Object.keys(sn).find(t=>sn[t].toasts.some(n=>n.id===e)),Cc=(e=nh)=>t=>{Q0(t,e)},p1={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},x1=(e={},t=nh)=>{let[n,r]=j.useState(sn[t]||V0),a=j.useRef(sn[t]);j.useEffect(()=>(a.current!==sn[t]&&r(sn[t]),yo.push([t,r]),()=>{let l=yo.findIndex(([o])=>o===t);l>-1&&yo.splice(l,1)}),[t]);let i=n.toasts.map(l=>{var o,c,d;return{...e,...e[l.type],...l,removeDelay:l.removeDelay||((o=e[l.type])==null?void 0:o.removeDelay)||(e==null?void 0:e.removeDelay),duration:l.duration||((c=e[l.type])==null?void 0:c.duration)||(e==null?void 0:e.duration)||p1[l.type],style:{...e.style,...(d=e[l.type])==null?void 0:d.style,...l.style}}});return{...n,toasts:i}},g1=(e,t="blank",n)=>({createdAt:Date.now(),visible:!0,dismissed:!1,type:t,ariaProps:{role:"status","aria-live":"polite"},message:e,pauseDuration:0,...n,id:(n==null?void 0:n.id)||m1()}),Cl=e=>(t,n)=>{let r=g1(t,e,n);return Cc(r.toasterId||f1(r.id))({type:2,toast:r}),r.id},wt=(e,t)=>Cl("blank")(e,t);wt.error=Cl("error");wt.success=Cl("success");wt.loading=Cl("loading");wt.custom=Cl("custom");wt.dismiss=(e,t)=>{let n={type:3,toastId:e};t?Cc(t)(n):H0(n)};wt.dismissAll=e=>wt.dismiss(void 0,e);wt.remove=(e,t)=>{let n={type:4,toastId:e};t?Cc(t)(n):H0(n)};wt.removeAll=e=>wt.remove(void 0,e);wt.promise=(e,t,n)=>{let r=wt.loading(t.loading,{...n,...n==null?void 0:n.loading});return typeof e=="function"&&(e=e()),e.then(a=>{let i=t.success?Jo(t.success,a):void 0;return i?wt.success(i,{id:r,...n,...n==null?void 0:n.success}):wt.dismiss(r),a}).catch(a=>{let i=t.error?Jo(t.error,a):void 0;i?wt.error(i,{id:r,...n,...n==null?void 0:n.error}):wt.dismiss(r)}),e};var y1=1e3,v1=(e,t="default")=>{let{toasts:n,pausedAt:r}=x1(e,t),a=j.useRef(new Map).current,i=j.useCallback((h,x=y1)=>{if(a.has(h))return;let m=setTimeout(()=>{a.delete(h),l({type:4,toastId:h})},x);a.set(h,m)},[]);j.useEffect(()=>{if(r)return;let h=Date.now(),x=n.map(m=>{if(m.duration===1/0)return;let f=(m.duration||0)+m.pauseDuration-(h-m.createdAt);if(f<0){m.visible&&wt.dismiss(m.id);return}return setTimeout(()=>wt.dismiss(m.id,t),f)});return()=>{x.forEach(m=>m&&clearTimeout(m))}},[n,r,t]);let l=j.useCallback(Cc(t),[t]),o=j.useCallback(()=>{l({type:5,time:Date.now()})},[l]),c=j.useCallback((h,x)=>{l({type:1,toast:{id:h,height:x}})},[l]),d=j.useCallback(()=>{r&&l({type:6,time:Date.now()})},[r,l]),u=j.useCallback((h,x)=>{let{reverseOrder:m=!1,gutter:f=8,defaultPosition:p}=x||{},b=n.filter(v=>(v.position||p)===(h.position||p)&&v.height),g=b.findIndex(v=>v.id===h.id),y=b.filter((v,N)=>N<g&&v.visible).length;return b.filter(v=>v.visible).slice(...m?[y+1]:[0,y]).reduce((v,N)=>v+(N.height||0)+f,0)},[n]);return j.useEffect(()=>{n.forEach(h=>{if(h.dismissed)i(h.id,h.removeDelay);else{let x=a.get(h.id);x&&(clearTimeout(x),a.delete(h.id))}})},[n,i]),{toasts:n,handlers:{updateHeight:c,startPause:o,endPause:d,calculateOffset:u}}},j1=Tn`
|
||
from {
|
||
transform: scale(0) rotate(45deg);
|
||
opacity: 0;
|
||
}
|
||
to {
|
||
transform: scale(1) rotate(45deg);
|
||
opacity: 1;
|
||
}`,b1=Tn`
|
||
from {
|
||
transform: scale(0);
|
||
opacity: 0;
|
||
}
|
||
to {
|
||
transform: scale(1);
|
||
opacity: 1;
|
||
}`,N1=Tn`
|
||
from {
|
||
transform: scale(0) rotate(90deg);
|
||
opacity: 0;
|
||
}
|
||
to {
|
||
transform: scale(1) rotate(90deg);
|
||
opacity: 1;
|
||
}`,w1=jr("div")`
|
||
width: 20px;
|
||
opacity: 0;
|
||
height: 20px;
|
||
border-radius: 10px;
|
||
background: ${e=>e.primary||"#ff4b4b"};
|
||
position: relative;
|
||
transform: rotate(45deg);
|
||
|
||
animation: ${j1} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)
|
||
forwards;
|
||
animation-delay: 100ms;
|
||
|
||
&:after,
|
||
&:before {
|
||
content: '';
|
||
animation: ${b1} 0.15s ease-out forwards;
|
||
animation-delay: 150ms;
|
||
position: absolute;
|
||
border-radius: 3px;
|
||
opacity: 0;
|
||
background: ${e=>e.secondary||"#fff"};
|
||
bottom: 9px;
|
||
left: 4px;
|
||
height: 2px;
|
||
width: 12px;
|
||
}
|
||
|
||
&:before {
|
||
animation: ${N1} 0.15s ease-out forwards;
|
||
animation-delay: 180ms;
|
||
transform: rotate(90deg);
|
||
}
|
||
`,S1=Tn`
|
||
from {
|
||
transform: rotate(0deg);
|
||
}
|
||
to {
|
||
transform: rotate(360deg);
|
||
}
|
||
`,k1=jr("div")`
|
||
width: 12px;
|
||
height: 12px;
|
||
box-sizing: border-box;
|
||
border: 2px solid;
|
||
border-radius: 100%;
|
||
border-color: ${e=>e.secondary||"#e0e0e0"};
|
||
border-right-color: ${e=>e.primary||"#616161"};
|
||
animation: ${S1} 1s linear infinite;
|
||
`,C1=Tn`
|
||
from {
|
||
transform: scale(0) rotate(45deg);
|
||
opacity: 0;
|
||
}
|
||
to {
|
||
transform: scale(1) rotate(45deg);
|
||
opacity: 1;
|
||
}`,E1=Tn`
|
||
0% {
|
||
height: 0;
|
||
width: 0;
|
||
opacity: 0;
|
||
}
|
||
40% {
|
||
height: 0;
|
||
width: 6px;
|
||
opacity: 1;
|
||
}
|
||
100% {
|
||
opacity: 1;
|
||
height: 10px;
|
||
}`,D1=jr("div")`
|
||
width: 20px;
|
||
opacity: 0;
|
||
height: 20px;
|
||
border-radius: 10px;
|
||
background: ${e=>e.primary||"#61d345"};
|
||
position: relative;
|
||
transform: rotate(45deg);
|
||
|
||
animation: ${C1} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)
|
||
forwards;
|
||
animation-delay: 100ms;
|
||
&:after {
|
||
content: '';
|
||
box-sizing: border-box;
|
||
animation: ${E1} 0.2s ease-out forwards;
|
||
opacity: 0;
|
||
animation-delay: 200ms;
|
||
position: absolute;
|
||
border-right: 2px solid;
|
||
border-bottom: 2px solid;
|
||
border-color: ${e=>e.secondary||"#fff"};
|
||
bottom: 6px;
|
||
left: 6px;
|
||
height: 10px;
|
||
width: 6px;
|
||
}
|
||
`,A1=jr("div")`
|
||
position: absolute;
|
||
`,P1=jr("div")`
|
||
position: relative;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
min-width: 20px;
|
||
min-height: 20px;
|
||
`,M1=Tn`
|
||
from {
|
||
transform: scale(0.6);
|
||
opacity: 0.4;
|
||
}
|
||
to {
|
||
transform: scale(1);
|
||
opacity: 1;
|
||
}`,T1=jr("div")`
|
||
position: relative;
|
||
transform: scale(0.6);
|
||
opacity: 0.4;
|
||
min-width: 20px;
|
||
animation: ${M1} 0.3s 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275)
|
||
forwards;
|
||
`,F1=({toast:e})=>{let{icon:t,type:n,iconTheme:r}=e;return t!==void 0?typeof t=="string"?j.createElement(T1,null,t):t:n==="blank"?null:j.createElement(P1,null,j.createElement(k1,{...r}),n!=="loading"&&j.createElement(A1,null,n==="error"?j.createElement(w1,{...r}):j.createElement(D1,{...r})))},I1=e=>`
|
||
0% {transform: translate3d(0,${e*-200}%,0) scale(.6); opacity:.5;}
|
||
100% {transform: translate3d(0,0,0) scale(1); opacity:1;}
|
||
`,R1=e=>`
|
||
0% {transform: translate3d(0,0,-1px) scale(1); opacity:1;}
|
||
100% {transform: translate3d(0,${e*-150}%,-1px) scale(.6); opacity:0;}
|
||
`,L1="0%{opacity:0;} 100%{opacity:1;}",O1="0%{opacity:1;} 100%{opacity:0;}",z1=jr("div")`
|
||
display: flex;
|
||
align-items: center;
|
||
background: #fff;
|
||
color: #363636;
|
||
line-height: 1.3;
|
||
will-change: transform;
|
||
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05);
|
||
max-width: 350px;
|
||
pointer-events: auto;
|
||
padding: 8px 10px;
|
||
border-radius: 8px;
|
||
`,$1=jr("div")`
|
||
display: flex;
|
||
justify-content: center;
|
||
margin: 4px 10px;
|
||
color: inherit;
|
||
flex: 1 1 auto;
|
||
white-space: pre-line;
|
||
`,_1=(e,t)=>{let n=e.includes("top")?1:-1,[r,a]=U0()?[L1,O1]:[I1(n),R1(n)];return{animation:t?`${Tn(r)} 0.35s cubic-bezier(.21,1.02,.73,1) forwards`:`${Tn(a)} 0.4s forwards cubic-bezier(.06,.71,.55,1)`}},K1=j.memo(({toast:e,position:t,style:n,children:r})=>{let a=e.height?_1(e.position||t||"top-center",e.visible):{opacity:0},i=j.createElement(F1,{toast:e}),l=j.createElement($1,{...e.ariaProps},Jo(e.message,e));return j.createElement(z1,{className:e.className,style:{...a,...n,...e.style}},typeof r=="function"?r({icon:i,message:l}):j.createElement(j.Fragment,null,i,l))});d1(j.createElement);var B1=({id:e,className:t,style:n,onHeightUpdate:r,children:a})=>{let i=j.useCallback(l=>{if(l){let o=()=>{let c=l.getBoundingClientRect().height;r(e,c)};o(),new MutationObserver(o).observe(l,{subtree:!0,childList:!0,characterData:!0})}},[e,r]);return j.createElement("div",{ref:i,className:t,style:n},a)},U1=(e,t)=>{let n=e.includes("top"),r=n?{top:0}:{bottom:0},a=e.includes("center")?{justifyContent:"center"}:e.includes("right")?{justifyContent:"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:U0()?void 0:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:`translateY(${t*(n?1:-1)}px)`,...r,...a}},q1=kc`
|
||
z-index: 9999;
|
||
> * {
|
||
pointer-events: auto;
|
||
}
|
||
`,to=16,V1=({reverseOrder:e,position:t="top-center",toastOptions:n,gutter:r,children:a,toasterId:i,containerStyle:l,containerClassName:o})=>{let{toasts:c,handlers:d}=v1(n,i);return j.createElement("div",{"data-rht-toaster":i||"",style:{position:"fixed",zIndex:9999,top:to,left:to,right:to,bottom:to,pointerEvents:"none",...l},className:o,onMouseEnter:d.startPause,onMouseLeave:d.endPause},c.map(u=>{let h=u.position||t,x=d.calculateOffset(u,{reverseOrder:e,gutter:r,defaultPosition:t}),m=U1(h,x);return j.createElement(B1,{id:u.id,key:u.id,onHeightUpdate:d.updateHeight,className:u.visible?q1:"",style:m},u.type==="custom"?Jo(u.message,u):a?a(u):j.createElement(K1,{toast:u,position:h}))}))},Re=wt;function W0(e,t){return function(){return e.apply(t,arguments)}}const{toString:Q1}=Object.prototype,{getPrototypeOf:rh}=Object,{iterator:Ec,toStringTag:G0}=Symbol,Dc=(e=>t=>{const n=Q1.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Qs=e=>(e=e.toLowerCase(),t=>Dc(t)===e),Ac=e=>t=>typeof t===e,{isArray:ri}=Array,Ja=Ac("undefined");function El(e){return e!==null&&!Ja(e)&&e.constructor!==null&&!Ja(e.constructor)&&us(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Z0=Qs("ArrayBuffer");function H1(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Z0(e.buffer),t}const W1=Ac("string"),us=Ac("function"),J0=Ac("number"),Dl=e=>e!==null&&typeof e=="object",G1=e=>e===!0||e===!1,vo=e=>{if(Dc(e)!=="object")return!1;const t=rh(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(G0 in e)&&!(Ec in e)},Z1=e=>{if(!Dl(e)||El(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},J1=Qs("Date"),X1=Qs("File"),Y1=Qs("Blob"),eS=Qs("FileList"),tS=e=>Dl(e)&&us(e.pipe),sS=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||us(e.append)&&((t=Dc(e))==="formdata"||t==="object"&&us(e.toString)&&e.toString()==="[object FormData]"))},nS=Qs("URLSearchParams"),[rS,aS,iS,lS]=["ReadableStream","Request","Response","Headers"].map(Qs),oS=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Al(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,a;if(typeof e!="object"&&(e=[e]),ri(e))for(r=0,a=e.length;r<a;r++)t.call(null,e[r],r,e);else{if(El(e))return;const i=n?Object.getOwnPropertyNames(e):Object.keys(e),l=i.length;let o;for(r=0;r<l;r++)o=i[r],t.call(null,e[o],o,e)}}function X0(e,t){if(El(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,a;for(;r-- >0;)if(a=n[r],t===a.toLowerCase())return a;return null}const Ar=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Y0=e=>!Ja(e)&&e!==Ar;function Bu(){const{caseless:e,skipUndefined:t}=Y0(this)&&this||{},n={},r=(a,i)=>{const l=e&&X0(n,i)||i;vo(n[l])&&vo(a)?n[l]=Bu(n[l],a):vo(a)?n[l]=Bu({},a):ri(a)?n[l]=a.slice():(!t||!Ja(a))&&(n[l]=a)};for(let a=0,i=arguments.length;a<i;a++)arguments[a]&&Al(arguments[a],r);return n}const cS=(e,t,n,{allOwnKeys:r}={})=>(Al(t,(a,i)=>{n&&us(a)?e[i]=W0(a,n):e[i]=a},{allOwnKeys:r}),e),dS=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),uS=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},mS=(e,t,n,r)=>{let a,i,l;const o={};if(t=t||{},e==null)return t;do{for(a=Object.getOwnPropertyNames(e),i=a.length;i-- >0;)l=a[i],(!r||r(l,e,t))&&!o[l]&&(t[l]=e[l],o[l]=!0);e=n!==!1&&rh(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},hS=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},fS=e=>{if(!e)return null;if(ri(e))return e;let t=e.length;if(!J0(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},pS=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&rh(Uint8Array)),xS=(e,t)=>{const r=(e&&e[Ec]).call(e);let a;for(;(a=r.next())&&!a.done;){const i=a.value;t.call(e,i[0],i[1])}},gS=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},yS=Qs("HTMLFormElement"),vS=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,a){return r.toUpperCase()+a}),Gp=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),jS=Qs("RegExp"),ev=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Al(n,(a,i)=>{let l;(l=t(a,i,e))!==!1&&(r[i]=l||a)}),Object.defineProperties(e,r)},bS=e=>{ev(e,(t,n)=>{if(us(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(us(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},NS=(e,t)=>{const n={},r=a=>{a.forEach(i=>{n[i]=!0})};return ri(e)?r(e):r(String(e).split(t)),n},wS=()=>{},SS=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function kS(e){return!!(e&&us(e.append)&&e[G0]==="FormData"&&e[Ec])}const CS=e=>{const t=new Array(10),n=(r,a)=>{if(Dl(r)){if(t.indexOf(r)>=0)return;if(El(r))return r;if(!("toJSON"in r)){t[a]=r;const i=ri(r)?[]:{};return Al(r,(l,o)=>{const c=n(l,a+1);!Ja(c)&&(i[o]=c)}),t[a]=void 0,i}}return r};return n(e,0)},ES=Qs("AsyncFunction"),DS=e=>e&&(Dl(e)||us(e))&&us(e.then)&&us(e.catch),tv=((e,t)=>e?setImmediate:t?((n,r)=>(Ar.addEventListener("message",({source:a,data:i})=>{a===Ar&&i===n&&r.length&&r.shift()()},!1),a=>{r.push(a),Ar.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",us(Ar.postMessage)),AS=typeof queueMicrotask<"u"?queueMicrotask.bind(Ar):typeof process<"u"&&process.nextTick||tv,PS=e=>e!=null&&us(e[Ec]),V={isArray:ri,isArrayBuffer:Z0,isBuffer:El,isFormData:sS,isArrayBufferView:H1,isString:W1,isNumber:J0,isBoolean:G1,isObject:Dl,isPlainObject:vo,isEmptyObject:Z1,isReadableStream:rS,isRequest:aS,isResponse:iS,isHeaders:lS,isUndefined:Ja,isDate:J1,isFile:X1,isBlob:Y1,isRegExp:jS,isFunction:us,isStream:tS,isURLSearchParams:nS,isTypedArray:pS,isFileList:eS,forEach:Al,merge:Bu,extend:cS,trim:oS,stripBOM:dS,inherits:uS,toFlatObject:mS,kindOf:Dc,kindOfTest:Qs,endsWith:hS,toArray:fS,forEachEntry:xS,matchAll:gS,isHTMLForm:yS,hasOwnProperty:Gp,hasOwnProp:Gp,reduceDescriptors:ev,freezeMethods:bS,toObjectSet:NS,toCamelCase:vS,noop:wS,toFiniteNumber:SS,findKey:X0,global:Ar,isContextDefined:Y0,isSpecCompliantForm:kS,toJSONObject:CS,isAsyncFn:ES,isThenable:DS,setImmediate:tv,asap:AS,isIterable:PS};function Se(e,t,n,r,a){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),a&&(this.response=a,this.status=a.status?a.status:null)}V.inherits(Se,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:V.toJSONObject(this.config),code:this.code,status:this.status}}});const sv=Se.prototype,nv={};["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=>{nv[e]={value:e}});Object.defineProperties(Se,nv);Object.defineProperty(sv,"isAxiosError",{value:!0});Se.from=(e,t,n,r,a,i)=>{const l=Object.create(sv);V.toFlatObject(e,l,function(u){return u!==Error.prototype},d=>d!=="isAxiosError");const o=e&&e.message?e.message:"Error",c=t==null&&e?e.code:t;return Se.call(l,o,c,n,r,a),e&&l.cause==null&&Object.defineProperty(l,"cause",{value:e,configurable:!0}),l.name=e&&e.name||"Error",i&&Object.assign(l,i),l};const MS=null;function Uu(e){return V.isPlainObject(e)||V.isArray(e)}function rv(e){return V.endsWith(e,"[]")?e.slice(0,-2):e}function Zp(e,t,n){return e?e.concat(t).map(function(a,i){return a=rv(a),!n&&i?"["+a+"]":a}).join(n?".":""):t}function TS(e){return V.isArray(e)&&!e.some(Uu)}const FS=V.toFlatObject(V,{},null,function(t){return/^is[A-Z]/.test(t)});function Pc(e,t,n){if(!V.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=V.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(p,b){return!V.isUndefined(b[p])});const r=n.metaTokens,a=n.visitor||u,i=n.dots,l=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&V.isSpecCompliantForm(t);if(!V.isFunction(a))throw new TypeError("visitor must be a function");function d(f){if(f===null)return"";if(V.isDate(f))return f.toISOString();if(V.isBoolean(f))return f.toString();if(!c&&V.isBlob(f))throw new Se("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(f)||V.isTypedArray(f)?c&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function u(f,p,b){let g=f;if(f&&!b&&typeof f=="object"){if(V.endsWith(p,"{}"))p=r?p:p.slice(0,-2),f=JSON.stringify(f);else if(V.isArray(f)&&TS(f)||(V.isFileList(f)||V.endsWith(p,"[]"))&&(g=V.toArray(f)))return p=rv(p),g.forEach(function(v,N){!(V.isUndefined(v)||v===null)&&t.append(l===!0?Zp([p],N,i):l===null?p:p+"[]",d(v))}),!1}return Uu(f)?!0:(t.append(Zp(b,p,i),d(f)),!1)}const h=[],x=Object.assign(FS,{defaultVisitor:u,convertValue:d,isVisitable:Uu});function m(f,p){if(!V.isUndefined(f)){if(h.indexOf(f)!==-1)throw Error("Circular reference detected in "+p.join("."));h.push(f),V.forEach(f,function(g,y){(!(V.isUndefined(g)||g===null)&&a.call(t,g,V.isString(y)?y.trim():y,p,x))===!0&&m(g,p?p.concat(y):[y])}),h.pop()}}if(!V.isObject(e))throw new TypeError("data must be an object");return m(e),t}function Jp(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ah(e,t){this._pairs=[],e&&Pc(e,this,t)}const av=ah.prototype;av.append=function(t,n){this._pairs.push([t,n])};av.toString=function(t){const n=t?function(r){return t.call(this,r,Jp)}:Jp;return this._pairs.map(function(a){return n(a[0])+"="+n(a[1])},"").join("&")};function IS(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function iv(e,t,n){if(!t)return e;const r=n&&n.encode||IS;V.isFunction(n)&&(n={serialize:n});const a=n&&n.serialize;let i;if(a?i=a(t,n):i=V.isURLSearchParams(t)?t.toString():new ah(t,n).toString(r),i){const l=e.indexOf("#");l!==-1&&(e=e.slice(0,l)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Xp{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){V.forEach(this.handlers,function(r){r!==null&&t(r)})}}const lv={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},RS=typeof URLSearchParams<"u"?URLSearchParams:ah,LS=typeof FormData<"u"?FormData:null,OS=typeof Blob<"u"?Blob:null,zS={isBrowser:!0,classes:{URLSearchParams:RS,FormData:LS,Blob:OS},protocols:["http","https","file","blob","url","data"]},ih=typeof window<"u"&&typeof document<"u",qu=typeof navigator=="object"&&navigator||void 0,$S=ih&&(!qu||["ReactNative","NativeScript","NS"].indexOf(qu.product)<0),_S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",KS=ih&&window.location.href||"http://localhost",BS=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ih,hasStandardBrowserEnv:$S,hasStandardBrowserWebWorkerEnv:_S,navigator:qu,origin:KS},Symbol.toStringTag,{value:"Module"})),Bt={...BS,...zS};function US(e,t){return Pc(e,new Bt.classes.URLSearchParams,{visitor:function(n,r,a,i){return Bt.isNode&&V.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}function qS(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function VS(e){const t={},n=Object.keys(e);let r;const a=n.length;let i;for(r=0;r<a;r++)i=n[r],t[i]=e[i];return t}function ov(e){function t(n,r,a,i){let l=n[i++];if(l==="__proto__")return!0;const o=Number.isFinite(+l),c=i>=n.length;return l=!l&&V.isArray(a)?a.length:l,c?(V.hasOwnProp(a,l)?a[l]=[a[l],r]:a[l]=r,!o):((!a[l]||!V.isObject(a[l]))&&(a[l]=[]),t(n,r,a[l],i)&&V.isArray(a[l])&&(a[l]=VS(a[l])),!o)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(r,a)=>{t(qS(r),a,n,0)}),n}return null}function QS(e,t,n){if(V.isString(e))try{return(t||JSON.parse)(e),V.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Pl={transitional:lv,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",a=r.indexOf("application/json")>-1,i=V.isObject(t);if(i&&V.isHTMLForm(t)&&(t=new FormData(t)),V.isFormData(t))return a?JSON.stringify(ov(t)):t;if(V.isArrayBuffer(t)||V.isBuffer(t)||V.isStream(t)||V.isFile(t)||V.isBlob(t)||V.isReadableStream(t))return t;if(V.isArrayBufferView(t))return t.buffer;if(V.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return US(t,this.formSerializer).toString();if((o=V.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Pc(o?{"files[]":t}:t,c&&new c,this.formSerializer)}}return i||a?(n.setContentType("application/json",!1),QS(t)):t}],transformResponse:[function(t){const n=this.transitional||Pl.transitional,r=n&&n.forcedJSONParsing,a=this.responseType==="json";if(V.isResponse(t)||V.isReadableStream(t))return t;if(t&&V.isString(t)&&(r&&!this.responseType||a)){const l=!(n&&n.silentJSONParsing)&&a;try{return JSON.parse(t,this.parseReviver)}catch(o){if(l)throw o.name==="SyntaxError"?Se.from(o,Se.ERR_BAD_RESPONSE,this,null,this.response):o}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Bt.classes.FormData,Blob:Bt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};V.forEach(["delete","get","head","post","put","patch"],e=>{Pl.headers[e]={}});const HS=V.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"]),WS=e=>{const t={};let n,r,a;return e&&e.split(`
|
||
`).forEach(function(l){a=l.indexOf(":"),n=l.substring(0,a).trim().toLowerCase(),r=l.substring(a+1).trim(),!(!n||t[n]&&HS[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Yp=Symbol("internals");function vi(e){return e&&String(e).trim().toLowerCase()}function jo(e){return e===!1||e==null?e:V.isArray(e)?e.map(jo):String(e)}function GS(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const ZS=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function hd(e,t,n,r,a){if(V.isFunction(r))return r.call(this,t,n);if(a&&(t=n),!!V.isString(t)){if(V.isString(r))return t.indexOf(r)!==-1;if(V.isRegExp(r))return r.test(t)}}function JS(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function XS(e,t){const n=V.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(a,i,l){return this[r].call(this,t,a,i,l)},configurable:!0})})}let ms=class{constructor(t){t&&this.set(t)}set(t,n,r){const a=this;function i(o,c,d){const u=vi(c);if(!u)throw new Error("header name must be a non-empty string");const h=V.findKey(a,u);(!h||a[h]===void 0||d===!0||d===void 0&&a[h]!==!1)&&(a[h||c]=jo(o))}const l=(o,c)=>V.forEach(o,(d,u)=>i(d,u,c));if(V.isPlainObject(t)||t instanceof this.constructor)l(t,n);else if(V.isString(t)&&(t=t.trim())&&!ZS(t))l(WS(t),n);else if(V.isObject(t)&&V.isIterable(t)){let o={},c,d;for(const u of t){if(!V.isArray(u))throw TypeError("Object iterator must return a key-value pair");o[d=u[0]]=(c=o[d])?V.isArray(c)?[...c,u[1]]:[c,u[1]]:u[1]}l(o,n)}else t!=null&&i(n,t,r);return this}get(t,n){if(t=vi(t),t){const r=V.findKey(this,t);if(r){const a=this[r];if(!n)return a;if(n===!0)return GS(a);if(V.isFunction(n))return n.call(this,a,r);if(V.isRegExp(n))return n.exec(a);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=vi(t),t){const r=V.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||hd(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let a=!1;function i(l){if(l=vi(l),l){const o=V.findKey(r,l);o&&(!n||hd(r,r[o],o,n))&&(delete r[o],a=!0)}}return V.isArray(t)?t.forEach(i):i(t),a}clear(t){const n=Object.keys(this);let r=n.length,a=!1;for(;r--;){const i=n[r];(!t||hd(this,this[i],i,t,!0))&&(delete this[i],a=!0)}return a}normalize(t){const n=this,r={};return V.forEach(this,(a,i)=>{const l=V.findKey(r,i);if(l){n[l]=jo(a),delete n[i];return}const o=t?JS(i):String(i).trim();o!==i&&delete n[i],n[o]=jo(a),r[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return V.forEach(this,(r,a)=>{r!=null&&r!==!1&&(n[a]=t&&V.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
|
||
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(a=>r.set(a)),r}static accessor(t){const r=(this[Yp]=this[Yp]={accessors:{}}).accessors,a=this.prototype;function i(l){const o=vi(l);r[o]||(XS(a,l),r[o]=!0)}return V.isArray(t)?t.forEach(i):i(t),this}};ms.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);V.reduceDescriptors(ms.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});V.freezeMethods(ms);function fd(e,t){const n=this||Pl,r=t||n,a=ms.from(r.headers);let i=r.data;return V.forEach(e,function(o){i=o.call(n,i,a.normalize(),t?t.status:void 0)}),a.normalize(),i}function cv(e){return!!(e&&e.__CANCEL__)}function ai(e,t,n){Se.call(this,e??"canceled",Se.ERR_CANCELED,t,n),this.name="CanceledError"}V.inherits(ai,Se,{__CANCEL__:!0});function dv(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Se("Request failed with status code "+n.status,[Se.ERR_BAD_REQUEST,Se.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function YS(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function e2(e,t){e=e||10;const n=new Array(e),r=new Array(e);let a=0,i=0,l;return t=t!==void 0?t:1e3,function(c){const d=Date.now(),u=r[i];l||(l=d),n[a]=c,r[a]=d;let h=i,x=0;for(;h!==a;)x+=n[h++],h=h%e;if(a=(a+1)%e,a===i&&(i=(i+1)%e),d-l<t)return;const m=u&&d-u;return m?Math.round(x*1e3/m):void 0}}function t2(e,t){let n=0,r=1e3/t,a,i;const l=(d,u=Date.now())=>{n=u,a=null,i&&(clearTimeout(i),i=null),e(...d)};return[(...d)=>{const u=Date.now(),h=u-n;h>=r?l(d,u):(a=d,i||(i=setTimeout(()=>{i=null,l(a)},r-h)))},()=>a&&l(a)]}const Xo=(e,t,n=3)=>{let r=0;const a=e2(50,250);return t2(i=>{const l=i.loaded,o=i.lengthComputable?i.total:void 0,c=l-r,d=a(c),u=l<=o;r=l;const h={loaded:l,total:o,progress:o?l/o:void 0,bytes:c,rate:d||void 0,estimated:d&&o&&u?(o-l)/d:void 0,event:i,lengthComputable:o!=null,[t?"download":"upload"]:!0};e(h)},n)},ex=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},tx=e=>(...t)=>V.asap(()=>e(...t)),s2=Bt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Bt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Bt.origin),Bt.navigator&&/(msie|trident)/i.test(Bt.navigator.userAgent)):()=>!0,n2=Bt.hasStandardBrowserEnv?{write(e,t,n,r,a,i,l){if(typeof document>"u")return;const o=[`${e}=${encodeURIComponent(t)}`];V.isNumber(n)&&o.push(`expires=${new Date(n).toUTCString()}`),V.isString(r)&&o.push(`path=${r}`),V.isString(a)&&o.push(`domain=${a}`),i===!0&&o.push("secure"),V.isString(l)&&o.push(`SameSite=${l}`),document.cookie=o.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function r2(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function a2(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function uv(e,t,n){let r=!r2(t);return e&&(r||n==!1)?a2(e,t):t}const sx=e=>e instanceof ms?{...e}:e;function Jr(e,t){t=t||{};const n={};function r(d,u,h,x){return V.isPlainObject(d)&&V.isPlainObject(u)?V.merge.call({caseless:x},d,u):V.isPlainObject(u)?V.merge({},u):V.isArray(u)?u.slice():u}function a(d,u,h,x){if(V.isUndefined(u)){if(!V.isUndefined(d))return r(void 0,d,h,x)}else return r(d,u,h,x)}function i(d,u){if(!V.isUndefined(u))return r(void 0,u)}function l(d,u){if(V.isUndefined(u)){if(!V.isUndefined(d))return r(void 0,d)}else return r(void 0,u)}function o(d,u,h){if(h in t)return r(d,u);if(h in e)return r(void 0,d)}const c={url:i,method:i,data:i,baseURL:l,transformRequest:l,transformResponse:l,paramsSerializer:l,timeout:l,timeoutMessage:l,withCredentials:l,withXSRFToken:l,adapter:l,responseType:l,xsrfCookieName:l,xsrfHeaderName:l,onUploadProgress:l,onDownloadProgress:l,decompress:l,maxContentLength:l,maxBodyLength:l,beforeRedirect:l,transport:l,httpAgent:l,httpsAgent:l,cancelToken:l,socketPath:l,responseEncoding:l,validateStatus:o,headers:(d,u,h)=>a(sx(d),sx(u),h,!0)};return V.forEach(Object.keys({...e,...t}),function(u){const h=c[u]||a,x=h(e[u],t[u],u);V.isUndefined(x)&&h!==o||(n[u]=x)}),n}const mv=e=>{const t=Jr({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:a,xsrfCookieName:i,headers:l,auth:o}=t;if(t.headers=l=ms.from(l),t.url=iv(uv(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),o&&l.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),V.isFormData(n)){if(Bt.hasStandardBrowserEnv||Bt.hasStandardBrowserWebWorkerEnv)l.setContentType(void 0);else if(V.isFunction(n.getHeaders)){const c=n.getHeaders(),d=["content-type","content-length"];Object.entries(c).forEach(([u,h])=>{d.includes(u.toLowerCase())&&l.set(u,h)})}}if(Bt.hasStandardBrowserEnv&&(r&&V.isFunction(r)&&(r=r(t)),r||r!==!1&&s2(t.url))){const c=a&&i&&n2.read(i);c&&l.set(a,c)}return t},i2=typeof XMLHttpRequest<"u",l2=i2&&function(e){return new Promise(function(n,r){const a=mv(e);let i=a.data;const l=ms.from(a.headers).normalize();let{responseType:o,onUploadProgress:c,onDownloadProgress:d}=a,u,h,x,m,f;function p(){m&&m(),f&&f(),a.cancelToken&&a.cancelToken.unsubscribe(u),a.signal&&a.signal.removeEventListener("abort",u)}let b=new XMLHttpRequest;b.open(a.method.toUpperCase(),a.url,!0),b.timeout=a.timeout;function g(){if(!b)return;const v=ms.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),E={data:!o||o==="text"||o==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:v,config:e,request:b};dv(function(I){n(I),p()},function(I){r(I),p()},E),b=null}"onloadend"in b?b.onloadend=g:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(g)},b.onabort=function(){b&&(r(new Se("Request aborted",Se.ECONNABORTED,e,b)),b=null)},b.onerror=function(N){const E=N&&N.message?N.message:"Network Error",P=new Se(E,Se.ERR_NETWORK,e,b);P.event=N||null,r(P),b=null},b.ontimeout=function(){let N=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const E=a.transitional||lv;a.timeoutErrorMessage&&(N=a.timeoutErrorMessage),r(new Se(N,E.clarifyTimeoutError?Se.ETIMEDOUT:Se.ECONNABORTED,e,b)),b=null},i===void 0&&l.setContentType(null),"setRequestHeader"in b&&V.forEach(l.toJSON(),function(N,E){b.setRequestHeader(E,N)}),V.isUndefined(a.withCredentials)||(b.withCredentials=!!a.withCredentials),o&&o!=="json"&&(b.responseType=a.responseType),d&&([x,f]=Xo(d,!0),b.addEventListener("progress",x)),c&&b.upload&&([h,m]=Xo(c),b.upload.addEventListener("progress",h),b.upload.addEventListener("loadend",m)),(a.cancelToken||a.signal)&&(u=v=>{b&&(r(!v||v.type?new ai(null,e,b):v),b.abort(),b=null)},a.cancelToken&&a.cancelToken.subscribe(u),a.signal&&(a.signal.aborted?u():a.signal.addEventListener("abort",u)));const y=YS(a.url);if(y&&Bt.protocols.indexOf(y)===-1){r(new Se("Unsupported protocol "+y+":",Se.ERR_BAD_REQUEST,e));return}b.send(i||null)})},o2=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,a;const i=function(d){if(!a){a=!0,o();const u=d instanceof Error?d:this.reason;r.abort(u instanceof Se?u:new ai(u instanceof Error?u.message:u))}};let l=t&&setTimeout(()=>{l=null,i(new Se(`timeout ${t} of ms exceeded`,Se.ETIMEDOUT))},t);const o=()=>{e&&(l&&clearTimeout(l),l=null,e.forEach(d=>{d.unsubscribe?d.unsubscribe(i):d.removeEventListener("abort",i)}),e=null)};e.forEach(d=>d.addEventListener("abort",i));const{signal:c}=r;return c.unsubscribe=()=>V.asap(o),c}},c2=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,a;for(;r<n;)a=r+t,yield e.slice(r,a),r=a},d2=async function*(e,t){for await(const n of u2(e))yield*c2(n,t)},u2=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},nx=(e,t,n,r)=>{const a=d2(e,t);let i=0,l,o=c=>{l||(l=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:d,value:u}=await a.next();if(d){o(),c.close();return}let h=u.byteLength;if(n){let x=i+=h;n(x)}c.enqueue(new Uint8Array(u))}catch(d){throw o(d),d}},cancel(c){return o(c),a.return()}},{highWaterMark:2})},rx=64*1024,{isFunction:so}=V,m2=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:ax,TextEncoder:ix}=V.global,lx=(e,...t)=>{try{return!!e(...t)}catch{return!1}},h2=e=>{e=V.merge.call({skipUndefined:!0},m2,e);const{fetch:t,Request:n,Response:r}=e,a=t?so(t):typeof fetch=="function",i=so(n),l=so(r);if(!a)return!1;const o=a&&so(ax),c=a&&(typeof ix=="function"?(f=>p=>f.encode(p))(new ix):async f=>new Uint8Array(await new n(f).arrayBuffer())),d=i&&o&&lx(()=>{let f=!1;const p=new n(Bt.origin,{body:new ax,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!p}),u=l&&o&&lx(()=>V.isReadableStream(new r("").body)),h={stream:u&&(f=>f.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!h[f]&&(h[f]=(p,b)=>{let g=p&&p[f];if(g)return g.call(p);throw new Se(`Response type '${f}' is not supported`,Se.ERR_NOT_SUPPORT,b)})});const x=async f=>{if(f==null)return 0;if(V.isBlob(f))return f.size;if(V.isSpecCompliantForm(f))return(await new n(Bt.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(V.isArrayBufferView(f)||V.isArrayBuffer(f))return f.byteLength;if(V.isURLSearchParams(f)&&(f=f+""),V.isString(f))return(await c(f)).byteLength},m=async(f,p)=>{const b=V.toFiniteNumber(f.getContentLength());return b??x(p)};return async f=>{let{url:p,method:b,data:g,signal:y,cancelToken:v,timeout:N,onDownloadProgress:E,onUploadProgress:P,responseType:I,headers:w,withCredentials:S="same-origin",fetchOptions:A}=mv(f),O=t||fetch;I=I?(I+"").toLowerCase():"text";let R=o2([y,v&&v.toAbortSignal()],N),q=null;const D=R&&R.unsubscribe&&(()=>{R.unsubscribe()});let z;try{if(P&&d&&b!=="get"&&b!=="head"&&(z=await m(w,g))!==0){let le=new n(p,{method:"POST",body:g,duplex:"half"}),de;if(V.isFormData(g)&&(de=le.headers.get("content-type"))&&w.setContentType(de),le.body){const[Ke,Ve]=ex(z,Xo(tx(P)));g=nx(le.body,rx,Ke,Ve)}}V.isString(S)||(S=S?"include":"omit");const k=i&&"credentials"in n.prototype,K={...A,signal:R,method:b.toUpperCase(),headers:w.normalize().toJSON(),body:g,duplex:"half",credentials:k?S:void 0};q=i&&new n(p,K);let B=await(i?O(q,A):O(p,K));const _=u&&(I==="stream"||I==="response");if(u&&(E||_&&D)){const le={};["status","statusText","headers"].forEach(st=>{le[st]=B[st]});const de=V.toFiniteNumber(B.headers.get("content-length")),[Ke,Ve]=E&&ex(de,Xo(tx(E),!0))||[];B=new r(nx(B.body,rx,Ke,()=>{Ve&&Ve(),D&&D()}),le)}I=I||"text";let Q=await h[V.findKey(h,I)||"text"](B,f);return!_&&D&&D(),await new Promise((le,de)=>{dv(le,de,{data:Q,headers:ms.from(B.headers),status:B.status,statusText:B.statusText,config:f,request:q})})}catch(k){throw D&&D(),k&&k.name==="TypeError"&&/Load failed|fetch/i.test(k.message)?Object.assign(new Se("Network Error",Se.ERR_NETWORK,f,q),{cause:k.cause||k}):Se.from(k,k&&k.code,f,q)}}},f2=new Map,hv=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:a}=t,i=[r,a,n];let l=i.length,o=l,c,d,u=f2;for(;o--;)c=i[o],d=u.get(c),d===void 0&&u.set(c,d=o?new Map:h2(t)),u=d;return d};hv();const lh={http:MS,xhr:l2,fetch:{get:hv}};V.forEach(lh,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const ox=e=>`- ${e}`,p2=e=>V.isFunction(e)||e===null||e===!1;function x2(e,t){e=V.isArray(e)?e:[e];const{length:n}=e;let r,a;const i={};for(let l=0;l<n;l++){r=e[l];let o;if(a=r,!p2(r)&&(a=lh[(o=String(r)).toLowerCase()],a===void 0))throw new Se(`Unknown adapter '${o}'`);if(a&&(V.isFunction(a)||(a=a.get(t))))break;i[o||"#"+l]=a}if(!a){const l=Object.entries(i).map(([c,d])=>`adapter ${c} `+(d===!1?"is not supported by the environment":"is not available in the build"));let o=n?l.length>1?`since :
|
||
`+l.map(ox).join(`
|
||
`):" "+ox(l[0]):"as no adapter specified";throw new Se("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return a}const fv={getAdapter:x2,adapters:lh};function pd(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ai(null,e)}function cx(e){return pd(e),e.headers=ms.from(e.headers),e.data=fd.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),fv.getAdapter(e.adapter||Pl.adapter,e)(e).then(function(r){return pd(e),r.data=fd.call(e,e.transformResponse,r),r.headers=ms.from(r.headers),r},function(r){return cv(r)||(pd(e),r&&r.response&&(r.response.data=fd.call(e,e.transformResponse,r.response),r.response.headers=ms.from(r.response.headers))),Promise.reject(r)})}const pv="1.13.2",Mc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Mc[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const dx={};Mc.transitional=function(t,n,r){function a(i,l){return"[Axios v"+pv+"] Transitional option '"+i+"'"+l+(r?". "+r:"")}return(i,l,o)=>{if(t===!1)throw new Se(a(l," has been removed"+(n?" in "+n:"")),Se.ERR_DEPRECATED);return n&&!dx[l]&&(dx[l]=!0,console.warn(a(l," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,l,o):!0}};Mc.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function g2(e,t,n){if(typeof e!="object")throw new Se("options must be an object",Se.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let a=r.length;for(;a-- >0;){const i=r[a],l=t[i];if(l){const o=e[i],c=o===void 0||l(o,i,e);if(c!==!0)throw new Se("option "+i+" must be "+c,Se.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Se("Unknown option "+i,Se.ERR_BAD_OPTION)}}const bo={assertOptions:g2,validators:Mc},Gs=bo.validators;let Br=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Xp,response:new Xp}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let a={};Error.captureStackTrace?Error.captureStackTrace(a):a=new Error;const i=a.stack?a.stack.replace(/^.+\n/,""):"";try{r.stack?i&&!String(r.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
||
`+i):r.stack=i}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Jr(this.defaults,n);const{transitional:r,paramsSerializer:a,headers:i}=n;r!==void 0&&bo.assertOptions(r,{silentJSONParsing:Gs.transitional(Gs.boolean),forcedJSONParsing:Gs.transitional(Gs.boolean),clarifyTimeoutError:Gs.transitional(Gs.boolean)},!1),a!=null&&(V.isFunction(a)?n.paramsSerializer={serialize:a}:bo.assertOptions(a,{encode:Gs.function,serialize:Gs.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),bo.assertOptions(n,{baseUrl:Gs.spelling("baseURL"),withXsrfToken:Gs.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let l=i&&V.merge(i.common,i[n.method]);i&&V.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),n.headers=ms.concat(l,i);const o=[];let c=!0;this.interceptors.request.forEach(function(p){typeof p.runWhen=="function"&&p.runWhen(n)===!1||(c=c&&p.synchronous,o.unshift(p.fulfilled,p.rejected))});const d=[];this.interceptors.response.forEach(function(p){d.push(p.fulfilled,p.rejected)});let u,h=0,x;if(!c){const f=[cx.bind(this),void 0];for(f.unshift(...o),f.push(...d),x=f.length,u=Promise.resolve(n);h<x;)u=u.then(f[h++],f[h++]);return u}x=o.length;let m=n;for(;h<x;){const f=o[h++],p=o[h++];try{m=f(m)}catch(b){p.call(this,b);break}}try{u=cx.call(this,m)}catch(f){return Promise.reject(f)}for(h=0,x=d.length;h<x;)u=u.then(d[h++],d[h++]);return u}getUri(t){t=Jr(this.defaults,t);const n=uv(t.baseURL,t.url,t.allowAbsoluteUrls);return iv(n,t.params,t.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(t){Br.prototype[t]=function(n,r){return this.request(Jr(r||{},{method:t,url:n,data:(r||{}).data}))}});V.forEach(["post","put","patch"],function(t){function n(r){return function(i,l,o){return this.request(Jr(o||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:l}))}}Br.prototype[t]=n(),Br.prototype[t+"Form"]=n(!0)});let y2=class xv{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const r=this;this.promise.then(a=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](a);r._listeners=null}),this.promise.then=a=>{let i;const l=new Promise(o=>{r.subscribe(o),i=o}).then(a);return l.cancel=function(){r.unsubscribe(i)},l},t(function(i,l,o){r.reason||(r.reason=new ai(i,l,o),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new xv(function(a){t=a}),cancel:t}}};function v2(e){return function(n){return e.apply(null,n)}}function j2(e){return V.isObject(e)&&e.isAxiosError===!0}const Vu={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(Vu).forEach(([e,t])=>{Vu[t]=e});function gv(e){const t=new Br(e),n=W0(Br.prototype.request,t);return V.extend(n,Br.prototype,t,{allOwnKeys:!0}),V.extend(n,t,null,{allOwnKeys:!0}),n.create=function(a){return gv(Jr(e,a))},n}const pt=gv(Pl);pt.Axios=Br;pt.CanceledError=ai;pt.CancelToken=y2;pt.isCancel=cv;pt.VERSION=pv;pt.toFormData=Pc;pt.AxiosError=Se;pt.Cancel=pt.CanceledError;pt.all=function(t){return Promise.all(t)};pt.spread=v2;pt.isAxiosError=j2;pt.mergeConfig=Jr;pt.AxiosHeaders=ms;pt.formToJSON=e=>ov(V.isHTMLForm(e)?new FormData(e):e);pt.getAdapter=fv.getAdapter;pt.HttpStatusCode=Vu;pt.default=pt;const{Axios:g4,AxiosError:y4,CanceledError:v4,isCancel:j4,CancelToken:b4,VERSION:N4,all:w4,Cancel:S4,isAxiosError:k4,spread:C4,toFormData:E4,AxiosHeaders:D4,HttpStatusCode:A4,formToJSON:P4,getAdapter:M4,mergeConfig:T4}=pt,$=pt.create({baseURL:"/api",headers:{"Content-Type":"application/json"}});$.interceptors.request.use(e=>{const t=localStorage.getItem("token");return t&&(e.headers.Authorization=`Bearer ${t}`),e});$.interceptors.response.use(e=>e,e=>{var a,i,l,o,c,d,u;const t=((i=(a=e.config)==null?void 0:a.url)==null?void 0:i.includes("/auth/login"))||((o=(l=e.config)==null?void 0:l.url)==null?void 0:o.includes("/auth/customer-login"));((c=e.response)==null?void 0:c.status)===401&&!t&&(localStorage.removeItem("token"),localStorage.removeItem("user"),window.location.href="/login");const n=((u=(d=e.response)==null?void 0:d.data)==null?void 0:u.error)||e.message||"Ein Fehler ist aufgetreten",r=new Error(n);return Promise.reject(r)});const no={login:async(e,t)=>(await $.post("/auth/login",{email:e,password:t})).data,customerLogin:async(e,t)=>(await $.post("/auth/customer-login",{email:e,password:t})).data,me:async()=>(await $.get("/auth/me")).data},At={getAll:async e=>(await $.get("/customers",{params:e})).data,getById:async e=>(await $.get(`/customers/${e}`)).data,create:async e=>(await $.post("/customers",e)).data,update:async(e,t)=>(await $.put(`/customers/${e}`,t)).data,delete:async e=>(await $.delete(`/customers/${e}`)).data,getPortalSettings:async e=>(await $.get(`/customers/${e}/portal`)).data,updatePortalSettings:async(e,t)=>(await $.put(`/customers/${e}/portal`,t)).data,setPortalPassword:async(e,t)=>(await $.post(`/customers/${e}/portal/password`,{password:t})).data,getPortalPassword:async e=>(await $.get(`/customers/${e}/portal/password`)).data,getRepresentatives:async e=>(await $.get(`/customers/${e}/representatives`)).data,addRepresentative:async(e,t,n)=>(await $.post(`/customers/${e}/representatives`,{representativeId:t,notes:n})).data,removeRepresentative:async(e,t)=>(await $.delete(`/customers/${e}/representatives/${t}`)).data,searchForRepresentative:async(e,t)=>(await $.get(`/customers/${e}/representatives/search`,{params:{search:t}})).data},Qu={getByCustomer:async e=>(await $.get(`/customers/${e}/addresses`)).data,create:async(e,t)=>(await $.post(`/customers/${e}/addresses`,t)).data,update:async(e,t)=>(await $.put(`/addresses/${e}`,t)).data,delete:async e=>(await $.delete(`/addresses/${e}`)).data},Yo={getByCustomer:async(e,t=!1)=>(await $.get(`/customers/${e}/bank-cards`,{params:{showInactive:t}})).data,create:async(e,t)=>(await $.post(`/customers/${e}/bank-cards`,t)).data,update:async(e,t)=>(await $.put(`/bank-cards/${e}`,t)).data,delete:async e=>(await $.delete(`/bank-cards/${e}`)).data},ec={getByCustomer:async(e,t=!1)=>(await $.get(`/customers/${e}/documents`,{params:{showInactive:t}})).data,create:async(e,t)=>(await $.post(`/customers/${e}/documents`,t)).data,update:async(e,t)=>(await $.put(`/documents/${e}`,t)).data,delete:async e=>(await $.delete(`/documents/${e}`)).data},ln={getByCustomer:async(e,t=!1)=>(await $.get(`/customers/${e}/meters`,{params:{showInactive:t}})).data,create:async(e,t)=>(await $.post(`/customers/${e}/meters`,t)).data,update:async(e,t)=>(await $.put(`/meters/${e}`,t)).data,delete:async e=>(await $.delete(`/meters/${e}`)).data,getReadings:async e=>(await $.get(`/meters/${e}/readings`)).data,addReading:async(e,t)=>(await $.post(`/meters/${e}/readings`,t)).data,updateReading:async(e,t,n)=>(await $.put(`/meters/${e}/readings/${t}`,n)).data,deleteReading:async(e,t)=>(await $.delete(`/meters/${e}/readings/${t}`)).data},aa={getInvoices:async e=>(await $.get(`/energy-details/${e}/invoices`)).data,addInvoice:async(e,t)=>(await $.post(`/energy-details/${e}/invoices`,t)).data,updateInvoice:async(e,t,n)=>(await $.put(`/energy-details/${e}/invoices/${t}`,n)).data,deleteInvoice:async(e,t)=>(await $.delete(`/energy-details/${e}/invoices/${t}`)).data,uploadDocument:async(e,t)=>{const n=new FormData;return n.append("document",t),(await $.post(`/upload/invoices/${e}`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteDocument:async e=>(await $.delete(`/upload/invoices/${e}`)).data},xs={getByCustomer:async(e,t=!1)=>(await $.get(`/customers/${e}/stressfrei-emails`,{params:{includeInactive:t}})).data,create:async(e,t)=>(await $.post(`/customers/${e}/stressfrei-emails`,t)).data,update:async(e,t)=>(await $.put(`/stressfrei-emails/${e}`,t)).data,delete:async e=>(await $.delete(`/stressfrei-emails/${e}`)).data,enableMailbox:async e=>(await $.post(`/stressfrei-emails/${e}/enable-mailbox`)).data,syncMailboxStatus:async e=>(await $.post(`/stressfrei-emails/${e}/sync-mailbox-status`)).data,getMailboxCredentials:async e=>(await $.get(`/stressfrei-emails/${e}/credentials`)).data,resetPassword:async e=>(await $.post(`/stressfrei-emails/${e}/reset-password`)).data,syncEmails:async(e,t=!1)=>(await $.post(`/stressfrei-emails/${e}/sync`,{},{params:{full:t}})).data,sendEmail:async(e,t)=>(await $.post(`/stressfrei-emails/${e}/send`,t)).data,getFolderCounts:async e=>(await $.get(`/stressfrei-emails/${e}/folder-counts`)).data},Pe={getForCustomer:async(e,t)=>(await $.get(`/customers/${e}/emails`,{params:t})).data,getForContract:async(e,t)=>(await $.get(`/contracts/${e}/emails`,{params:t})).data,getContractFolderCounts:async e=>(await $.get(`/contracts/${e}/emails/folder-counts`)).data,getMailboxAccounts:async e=>(await $.get(`/customers/${e}/mailbox-accounts`)).data,getById:async e=>(await $.get(`/emails/${e}`)).data,getThread:async e=>(await $.get(`/emails/${e}/thread`)).data,markAsRead:async(e,t)=>(await $.patch(`/emails/${e}/read`,{isRead:t})).data,toggleStar:async e=>(await $.post(`/emails/${e}/star`)).data,assignToContract:async(e,t)=>(await $.post(`/emails/${e}/assign`,{contractId:t})).data,unassignFromContract:async e=>(await $.delete(`/emails/${e}/assign`)).data,delete:async e=>(await $.delete(`/emails/${e}`)).data,getAttachmentUrl:(e,t,n)=>{const r=localStorage.getItem("token"),a=encodeURIComponent(t),i=n?"&view=true":"";return`${$.defaults.baseURL}/emails/${e}/attachments/${a}?token=${r}${i}`},getUnreadCount:async e=>(await $.get("/emails/unread-count",{params:e})).data,getTrash:async e=>(await $.get(`/customers/${e}/emails/trash`)).data,getTrashCount:async e=>(await $.get(`/customers/${e}/emails/trash/count`)).data,restore:async e=>(await $.post(`/emails/${e}/restore`)).data,permanentDelete:async e=>(await $.delete(`/emails/${e}/permanent`)).data,getAttachmentTargets:async e=>(await $.get(`/emails/${e}/attachment-targets`)).data,saveAttachmentTo:async(e,t,n)=>{const r=encodeURIComponent(t);return(await $.post(`/emails/${e}/attachments/${r}/save-to`,n)).data},saveEmailAsPdf:async(e,t)=>(await $.post(`/emails/${e}/save-as-pdf`,t)).data,saveEmailAsInvoice:async(e,t)=>(await $.post(`/emails/${e}/save-as-invoice`,t)).data,saveAttachmentAsInvoice:async(e,t,n)=>{const r=encodeURIComponent(t);return(await $.post(`/emails/${e}/attachments/${r}/save-as-invoice`,n)).data}},Oe={getAll:async e=>(await $.get("/contracts",{params:e})).data,getTreeForCustomer:async e=>(await $.get("/contracts",{params:{customerId:e,tree:"true"}})).data,getById:async e=>(await $.get(`/contracts/${e}`)).data,create:async e=>(await $.post("/contracts",e)).data,update:async(e,t)=>(await $.put(`/contracts/${e}`,t)).data,delete:async e=>(await $.delete(`/contracts/${e}`)).data,createFollowUp:async e=>(await $.post(`/contracts/${e}/follow-up`)).data,getPassword:async e=>(await $.get(`/contracts/${e}/password`)).data,getSimCardCredentials:async e=>(await $.get(`/contracts/simcard/${e}/credentials`)).data,getInternetCredentials:async e=>(await $.get(`/contracts/${e}/internet-credentials`)).data,getSipCredentials:async e=>(await $.get(`/contracts/phonenumber/${e}/sip-credentials`)).data,getCockpit:async()=>(await $.get("/contracts/cockpit")).data,snooze:async(e,t)=>(await $.patch(`/contracts/${e}/snooze`,t)).data},tc={getByContract:async e=>(await $.get(`/contracts/${e}/history`)).data,create:async(e,t)=>(await $.post(`/contracts/${e}/history`,t)).data,update:async(e,t,n)=>(await $.put(`/contracts/${e}/history/${t}`,n)).data,delete:async(e,t)=>(await $.delete(`/contracts/${e}/history/${t}`)).data},et={getAll:async e=>(await $.get("/tasks",{params:e})).data,getStats:async()=>(await $.get("/tasks/stats")).data,getByContract:async(e,t)=>(await $.get(`/contracts/${e}/tasks`,{params:{status:t}})).data,create:async(e,t)=>(await $.post(`/contracts/${e}/tasks`,t)).data,update:async(e,t)=>(await $.put(`/tasks/${e}`,t)).data,complete:async e=>(await $.post(`/tasks/${e}/complete`)).data,reopen:async e=>(await $.post(`/tasks/${e}/reopen`)).data,delete:async e=>(await $.delete(`/tasks/${e}`)).data,createSubtask:async(e,t)=>(await $.post(`/tasks/${e}/subtasks`,{title:t})).data,createReply:async(e,t)=>(await $.post(`/tasks/${e}/reply`,{title:t})).data,updateSubtask:async(e,t)=>(await $.put(`/subtasks/${e}`,{title:t})).data,completeSubtask:async e=>(await $.post(`/subtasks/${e}/complete`)).data,reopenSubtask:async e=>(await $.post(`/subtasks/${e}/reopen`)).data,deleteSubtask:async e=>(await $.delete(`/subtasks/${e}`)).data,createSupportTicket:async(e,t)=>(await $.post(`/contracts/${e}/support-ticket`,t)).data},Xr={getPublic:async()=>(await $.get("/settings/public")).data,getAll:async()=>(await $.get("/settings")).data,update:async e=>(await $.put("/settings",e)).data,updateOne:async(e,t)=>(await $.put(`/settings/${e}`,{value:t})).data},br={list:async()=>(await $.get("/settings/backups")).data,create:async()=>(await $.post("/settings/backup")).data,restore:async e=>(await $.post(`/settings/backup/${e}/restore`)).data,delete:async e=>(await $.delete(`/settings/backup/${e}`)).data,getDownloadUrl:e=>`/api/settings/backup/${e}/download`,upload:async e=>{const t=new FormData;return t.append("backup",e),(await $.post("/settings/backup/upload",t,{headers:{"Content-Type":"multipart/form-data"}})).data},factoryReset:async()=>(await $.post("/settings/factory-reset")).data},il={getAll:async(e=!1)=>(await $.get("/platforms",{params:{includeInactive:e}})).data,getById:async e=>(await $.get(`/platforms/${e}`)).data,create:async e=>(await $.post("/platforms",e)).data,update:async(e,t)=>(await $.put(`/platforms/${e}`,t)).data,delete:async e=>(await $.delete(`/platforms/${e}`)).data},ll={getAll:async(e=!1)=>(await $.get("/cancellation-periods",{params:{includeInactive:e}})).data,getById:async e=>(await $.get(`/cancellation-periods/${e}`)).data,create:async e=>(await $.post("/cancellation-periods",e)).data,update:async(e,t)=>(await $.put(`/cancellation-periods/${e}`,t)).data,delete:async e=>(await $.delete(`/cancellation-periods/${e}`)).data},ol={getAll:async(e=!1)=>(await $.get("/contract-durations",{params:{includeInactive:e}})).data,getById:async e=>(await $.get(`/contract-durations/${e}`)).data,create:async e=>(await $.post("/contract-durations",e)).data,update:async(e,t)=>(await $.put(`/contract-durations/${e}`,t)).data,delete:async e=>(await $.delete(`/contract-durations/${e}`)).data},cl={getAll:async(e=!1)=>(await $.get("/contract-categories",{params:{includeInactive:e}})).data,getById:async e=>(await $.get(`/contract-categories/${e}`)).data,create:async e=>(await $.post("/contract-categories",e)).data,update:async(e,t)=>(await $.put(`/contract-categories/${e}`,t)).data,delete:async e=>(await $.delete(`/contract-categories/${e}`)).data},Xa={getAll:async(e=!1)=>(await $.get("/providers",{params:{includeInactive:e}})).data,getById:async e=>(await $.get(`/providers/${e}`)).data,create:async e=>(await $.post("/providers",e)).data,update:async(e,t)=>(await $.put(`/providers/${e}`,t)).data,delete:async e=>(await $.delete(`/providers/${e}`)).data,getTariffs:async(e,t=!1)=>(await $.get(`/providers/${e}/tariffs`,{params:{includeInactive:t}})).data,createTariff:async(e,t)=>(await $.post(`/providers/${e}/tariffs`,t)).data},yv={getById:async e=>(await $.get(`/tariffs/${e}`)).data,update:async(e,t)=>(await $.put(`/tariffs/${e}`,t)).data,delete:async e=>(await $.delete(`/tariffs/${e}`)).data},ut={uploadBankCardDocument:async(e,t)=>{const n=new FormData;return n.append("document",t),(await $.post(`/upload/bank-cards/${e}`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},uploadIdentityDocument:async(e,t)=>{const n=new FormData;return n.append("document",t),(await $.post(`/upload/documents/${e}`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteBankCardDocument:async e=>(await $.delete(`/upload/bank-cards/${e}`)).data,deleteIdentityDocument:async e=>(await $.delete(`/upload/documents/${e}`)).data,uploadBusinessRegistration:async(e,t)=>{const n=new FormData;return n.append("document",t),(await $.post(`/upload/customers/${e}/business-registration`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteBusinessRegistration:async e=>(await $.delete(`/upload/customers/${e}/business-registration`)).data,uploadCommercialRegister:async(e,t)=>{const n=new FormData;return n.append("document",t),(await $.post(`/upload/customers/${e}/commercial-register`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCommercialRegister:async e=>(await $.delete(`/upload/customers/${e}/commercial-register`)).data,uploadPrivacyPolicy:async(e,t)=>{const n=new FormData;return n.append("document",t),(await $.post(`/upload/customers/${e}/privacy-policy`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deletePrivacyPolicy:async e=>(await $.delete(`/upload/customers/${e}/privacy-policy`)).data,uploadCancellationLetter:async(e,t)=>{const n=new FormData;return n.append("document",t),(await $.post(`/upload/contracts/${e}/cancellation-letter`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationLetter:async e=>(await $.delete(`/upload/contracts/${e}/cancellation-letter`)).data,uploadCancellationConfirmation:async(e,t)=>{const n=new FormData;return n.append("document",t),(await $.post(`/upload/contracts/${e}/cancellation-confirmation`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationConfirmation:async e=>(await $.delete(`/upload/contracts/${e}/cancellation-confirmation`)).data,uploadCancellationLetterOptions:async(e,t)=>{const n=new FormData;return n.append("document",t),(await $.post(`/upload/contracts/${e}/cancellation-letter-options`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationLetterOptions:async e=>(await $.delete(`/upload/contracts/${e}/cancellation-letter-options`)).data,uploadCancellationConfirmationOptions:async(e,t)=>{const n=new FormData;return n.append("document",t),(await $.post(`/upload/contracts/${e}/cancellation-confirmation-options`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationConfirmationOptions:async e=>(await $.delete(`/upload/contracts/${e}/cancellation-confirmation-options`)).data},Li={getAll:async e=>(await $.get("/users",{params:e})).data,getById:async e=>(await $.get(`/users/${e}`)).data,create:async e=>(await $.post("/users",e)).data,update:async(e,t)=>(await $.put(`/users/${e}`,t)).data,delete:async e=>(await $.delete(`/users/${e}`)).data,getRoles:async()=>(await $.get("/users/roles/list")).data},Ci={getSchema:async()=>(await $.get("/developer/schema")).data,getTableData:async(e,t=1,n=50)=>(await $.get(`/developer/table/${e}`,{params:{page:t,limit:n}})).data,updateRow:async(e,t,n)=>(await $.put(`/developer/table/${e}/${t}`,n)).data,deleteRow:async(e,t)=>(await $.delete(`/developer/table/${e}/${t}`)).data,getReference:async e=>(await $.get(`/developer/reference/${e}`)).data},yn={getConfigs:async()=>(await $.get("/email-providers/configs")).data,getConfig:async e=>(await $.get(`/email-providers/configs/${e}`)).data,createConfig:async e=>(await $.post("/email-providers/configs",e)).data,updateConfig:async(e,t)=>(await $.put(`/email-providers/configs/${e}`,t)).data,deleteConfig:async e=>(await $.delete(`/email-providers/configs/${e}`)).data,testConnection:async e=>{const t=e!=null&&e.testData?{...e.testData}:e!=null&&e.id?{id:e.id}:{};return(await $.post("/email-providers/test-connection",t)).data},getDomain:async()=>(await $.get("/email-providers/domain")).data,checkEmailExists:async e=>(await $.get(`/email-providers/check/${e}`)).data,provisionEmail:async(e,t)=>(await $.post("/email-providers/provision",{localPart:e,customerEmail:t})).data,deprovisionEmail:async e=>(await $.delete(`/email-providers/deprovision/${e}`)).data},vv=j.createContext(null);function b2({children:e}){const[t,n]=j.useState(null),[r,a]=j.useState(!0),[i,l]=j.useState(()=>localStorage.getItem("developerMode")==="true"),o=p=>{l(p),localStorage.setItem("developerMode",String(p))};j.useEffect(()=>{var p;console.log("useEffect check - user:",t==null?void 0:t.email,"developerMode:",i,"has developer:access:",(p=t==null?void 0:t.permissions)==null?void 0:p.includes("developer:access")),t&&i&&!t.permissions.includes("developer:access")&&(console.log("Disabling developer mode because user lacks developer:access permission"),o(!1))},[t,i]),j.useEffect(()=>{localStorage.getItem("token")?no.me().then(b=>{b.success&&b.data?n(b.data):localStorage.removeItem("token")}).catch(()=>{localStorage.removeItem("token")}).finally(()=>{a(!1)}):a(!1)},[]);const c=async(p,b)=>{const g=await no.login(p,b);if(g.success&&g.data)localStorage.setItem("token",g.data.token),n(g.data.user);else throw new Error(g.error||"Login fehlgeschlagen")},d=async(p,b)=>{const g=await no.customerLogin(p,b);if(g.success&&g.data)localStorage.setItem("token",g.data.token),n(g.data.user);else throw new Error(g.error||"Login fehlgeschlagen")},u=()=>{localStorage.removeItem("token"),n(null)},h=async()=>{var b;if(localStorage.getItem("token"))try{const g=await no.me();console.log("refreshUser response:",g),console.log("permissions:",(b=g.data)==null?void 0:b.permissions),g.success&&g.data&&n(g.data)}catch(g){console.error("refreshUser error:",g)}},x=p=>t?t.permissions.includes(p):!1,m=!!(t!=null&&t.customerId),f=!!(t!=null&&t.isCustomerPortal);return s.jsx(vv.Provider,{value:{user:t,isLoading:r,isAuthenticated:!!t,login:c,customerLogin:d,logout:u,hasPermission:x,isCustomer:m,isCustomerPortal:f,developerMode:i,setDeveloperMode:o,refreshUser:h},children:e})}function We(){const e=j.useContext(vv);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}const xd={scrollToTopThreshold:.7},jv=j.createContext(void 0),ux="opencrm_app_settings";function N2({children:e}){const[t,n]=j.useState(()=>{const a=localStorage.getItem(ux);if(a)try{return{...xd,...JSON.parse(a)}}catch{return xd}return xd});j.useEffect(()=>{localStorage.setItem(ux,JSON.stringify(t))},[t]);const r=a=>{n(i=>({...i,...a}))};return s.jsx(jv.Provider,{value:{settings:t,updateSettings:r},children:e})}function bv(){const e=j.useContext(jv);if(!e)throw new Error("useAppSettings must be used within AppSettingsProvider");return e}function w2(){const{pathname:e}=Rn();return j.useEffect(()=>{window.scrollTo(0,0)},[e]),null}/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const S2=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Nv=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/var k2={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"};/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const C2=j.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:a="",children:i,iconNode:l,...o},c)=>j.createElement("svg",{ref:c,...k2,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Nv("lucide",a),...o},[...l.map(([d,u])=>j.createElement(d,u)),...Array.isArray(i)?i:[i]]));/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ne=(e,t)=>{const n=j.forwardRef(({className:r,...a},i)=>j.createElement(C2,{ref:i,iconNode:t,className:Nv(`lucide-${S2(e)}`,r),...a}));return n.displayName=`${e}`,n};/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const E2=ne("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Vs=ne("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const wv=ne("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Sv=ne("BellOff",[["path",{d:"M8.7 3A6 6 0 0 1 18 8a21.3 21.3 0 0 0 .6 5",key:"o7mx20"}],["path",{d:"M17 17H3s3-2 3-9a4.67 4.67 0 0 1 .3-1.7",key:"16f1lm"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const D2=ne("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const A2=ne("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const P2=ne("Cable",[["path",{d:"M17 21v-2a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1",key:"10bnsj"}],["path",{d:"M19 15V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V9",key:"1eqmu1"}],["path",{d:"M21 21v-2h-4",key:"14zm7j"}],["path",{d:"M3 5h4V3",key:"z442eg"}],["path",{d:"M7 5a1 1 0 0 1 1 1v1a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1V3",key:"ebdjd7"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const M2=ne("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const kv=ne("Calendar",[["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"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Cv=ne("Car",[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const xr=ne("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const dn=ne("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const T2=ne("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Ft=ne("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Tc=ne("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const kn=ne("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const As=ne("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const mx=ne("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const No=ne("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const dl=ne("ClipboardList",[["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"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const on=ne("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Fc=ne("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const oh=ne("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ch=ne("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Ic=ne("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Ps=ne("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const dh=ne("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const It=ne("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Ae=ne("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const F2=ne("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Be=ne("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const I2=ne("FileType",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Ev=ne("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const R2=ne("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Dv=ne("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const hx=ne("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const uh=ne("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const L2=ne("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const fx=ne("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const O2=ne("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Av=ne("IdCard",[["path",{d:"M16 10h2",key:"8sgtl7"}],["path",{d:"M16 14h2",key:"epxaof"}],["path",{d:"M6.17 15a3 3 0 0 1 5.66 0",key:"n6f512"}],["circle",{cx:"9",cy:"11",r:"2",key:"yxgjnd"}],["rect",{x:"2",y:"5",width:"20",height:"14",rx:"2",key:"qneu4z"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Ur=ne("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Ml=ne("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const z2=ne("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const $2=ne("LayoutDashboard",[["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"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const px=ne("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const _2=ne("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Pv=ne("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const nn=ne("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const K2=ne("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const B2=ne("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ul=ne("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const U2=ne("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const q2=ne("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Rc=ne("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const _e=ne("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const mh=ne("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Sr=ne("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const V2=ne("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const hh=ne("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Mv=ne("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Tl=ne("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Fl=ne("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Tv=ne("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const fh=ne("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const He=ne("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ph=ne("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Q2=ne("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const H2=ne("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Ne=ne("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const hs=ne("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Fv=ne("Tv",[["rect",{width:"20",height:"15",x:"2",y:"7",rx:"2",ry:"2",key:"10ag99"}],["polyline",{points:"17 2 12 7 7 2",key:"11pgbg"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Iv=ne("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Hu=ne("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const W2=ne("UserCog",[["circle",{cx:"18",cy:"15",r:"3",key:"gjjjvw"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M10 15H6a4 4 0 0 0-4 4v2",key:"1nfge6"}],["path",{d:"m21.7 16.4-.9-.3",key:"12j9ji"}],["path",{d:"m15.2 13.9-.9-.3",key:"1fdjdi"}],["path",{d:"m16.6 18.7.3-.9",key:"heedtr"}],["path",{d:"m19.1 12.2.3-.9",key:"1af3ki"}],["path",{d:"m19.6 18.7-.4-1",key:"1x9vze"}],["path",{d:"m16.8 12.3-.4-1",key:"vqeiwj"}],["path",{d:"m14.3 16.6 1-.4",key:"1qlj63"}],["path",{d:"m20.7 13.8 1-.4",key:"1v5t8k"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const G2=ne("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ii=ne("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Ca=ne("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const xx=ne("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Ea=ne("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const qt=ne("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const xh=ne("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Z2=ne("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/**
|
||
* @license lucide-react v0.454.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const J2=ne("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function X2(){const{user:e,logout:t,hasPermission:n,isCustomer:r,developerMode:a}=We(),i=[{to:"/",icon:$2,label:"Dashboard",show:!0,end:!0},{to:"/customers",icon:Ca,label:"Kunden",show:n("customers:read")&&!r},{to:"/contracts",icon:Be,label:"Verträge",show:n("contracts:read"),end:!0},{to:"/contracts/cockpit",icon:kn,label:"Vertrags-Cockpit",show:n("contracts:read")&&!r},{to:"/tasks",icon:r?ul:dl,label:r?"Support-Anfragen":"Aufgaben",show:n("contracts:read")}],l=[{to:"/developer/database",icon:Ic,label:"Datenbankstruktur"}];return s.jsxs("aside",{className:"w-64 bg-gray-900 text-white min-h-screen flex flex-col",children:[s.jsx("div",{className:"p-4 border-b border-gray-800",children:s.jsx("h1",{className:"text-xl font-bold",children:"OpenCRM"})}),s.jsxs("nav",{className:"flex-1 p-4 overflow-y-auto",children:[s.jsx("ul",{className:"space-y-2",children:i.filter(o=>o.show).map(o=>s.jsx("li",{children:s.jsxs(md,{to:o.to,end:o.end,className:({isActive:c})=>`flex items-center gap-3 px-4 py-2 rounded-lg transition-colors ${c?"bg-blue-600 text-white":"text-gray-300 hover:bg-gray-800"}`,children:[s.jsx(o.icon,{className:"w-5 h-5"}),o.label]})},o.to))}),a&&n("developer:access")&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mt-6 mb-2 px-4",children:s.jsxs("p",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider flex items-center gap-2",children:[s.jsx(Fc,{className:"w-3 h-3"}),"Entwickler"]})}),s.jsx("ul",{className:"space-y-2",children:l.map(o=>s.jsx("li",{children:s.jsxs(md,{to:o.to,className:({isActive:c})=>`flex items-center gap-3 px-4 py-2 rounded-lg transition-colors ${c?"bg-purple-600 text-white":"text-purple-300 hover:bg-gray-800"}`,children:[s.jsx(o.icon,{className:"w-5 h-5"}),o.label]})},o.to))})]}),s.jsx("div",{className:"mt-6 pt-6 border-t border-gray-800",children:s.jsxs(md,{to:"/settings",className:({isActive:o})=>`flex items-center gap-3 px-4 py-2 rounded-lg transition-colors ${o?"bg-blue-600 text-white":"text-gray-300 hover:bg-gray-800"}`,children:[s.jsx(Tv,{className:"w-5 h-5"}),"Einstellungen"]})})]}),s.jsxs("div",{className:"p-4 border-t border-gray-800",children:[s.jsxs("div",{className:"mb-4 text-sm",children:[s.jsx("p",{className:"text-gray-400",children:"Angemeldet als"}),s.jsxs("p",{className:"font-medium",children:[e==null?void 0:e.firstName," ",e==null?void 0:e.lastName]})]}),s.jsxs("button",{onClick:t,className:"flex items-center gap-3 w-full px-4 py-2 text-gray-300 hover:bg-gray-800 rounded-lg transition-colors",children:[s.jsx(_2,{className:"w-5 h-5"}),"Abmelden"]})]})]})}function Y2(){const{settings:e}=bv(),[t,n]=j.useState(!1);j.useEffect(()=>{const a=()=>{window.scrollY>window.innerHeight*e.scrollToTopThreshold?n(!0):n(!1)};return window.addEventListener("scroll",a),()=>window.removeEventListener("scroll",a)},[e.scrollToTopThreshold]);const r=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?s.jsx("button",{onClick:r,className:"fixed bottom-6 right-6 p-3 bg-gray-200 hover:bg-gray-300 text-gray-600 rounded-full shadow-md transition-all duration-300 opacity-70 hover:opacity-100 z-50","aria-label":"Nach oben scrollen",title:"Nach oben",children:s.jsx(Tc,{className:"w-5 h-5"})}):null}function ek(){return s.jsxs("div",{className:"flex min-h-screen",children:[s.jsx(X2,{}),s.jsx("main",{className:"flex-1 p-8 overflow-auto",children:s.jsx(uw,{})}),s.jsx(Y2,{})]})}const T=j.forwardRef(({className:e="",variant:t="primary",size:n="md",children:r,disabled:a,...i},l)=>{const o="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",c={primary:"bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500",secondary:"bg-gray-200 text-gray-900 hover:bg-gray-300 focus:ring-gray-500",danger:"bg-red-600 text-white hover:bg-red-700 focus:ring-red-500",ghost:"bg-transparent text-gray-700 hover:bg-gray-100 focus:ring-gray-500"},d={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base"};return s.jsx("button",{ref:l,className:`${o} ${c[t]} ${d[n]} ${e}`,disabled:a,...i,children:r})});T.displayName="Button";const H=j.forwardRef(({className:e="",label:t,error:n,id:r,onClear:a,...i},l)=>{const o=r||i.name,c=i.type==="date",d=i.value!==void 0&&i.value!==null&&i.value!=="",u=c&&a&&d;return s.jsxs("div",{className:"w-full",children:[t&&s.jsx("label",{htmlFor:o,className:"block text-sm font-medium text-gray-700 mb-1",children:t}),s.jsxs("div",{className:u?"flex gap-2":"",children:[s.jsx("input",{ref:l,id:o,className:`block w-full px-3 py-2 border rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${n?"border-red-500":"border-gray-300"} ${e}`,...i}),u&&s.jsx("button",{type:"button",onClick:a,className:"px-3 py-2 text-gray-400 hover:text-red-500 hover:bg-red-50 border border-gray-300 rounded-lg transition-colors",title:"Datum löschen",children:s.jsx(Ne,{className:"w-4 h-4"})})]}),n&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:n})]})});H.displayName="Input";function X({children:e,className:t="",title:n,actions:r}){return s.jsxs("div",{className:`bg-white rounded-lg shadow ${t}`,children:[(n||r)&&s.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 flex items-center justify-between",children:[n&&s.jsx("div",{className:"text-lg font-medium text-gray-900",children:n}),r&&s.jsx("div",{className:"flex items-center gap-2",children:r})]}),s.jsx("div",{className:"p-6",children:e})]})}function tk(){const[e,t]=j.useState(""),[n,r]=j.useState(""),[a,i]=j.useState(""),[l,o]=j.useState(!1),{login:c,customerLogin:d}=We(),u=Yt(),h=async x=>{x.preventDefault(),i(""),o(!0);try{await c(e,n),u("/");return}catch{}try{await d(e,n),u("/")}catch{i("Ungültige Anmeldedaten"),o(!1)}};return s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100",children:s.jsxs(X,{className:"w-full max-w-md",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"OpenCRM"}),s.jsx("p",{className:"text-gray-600 mt-2",children:"Melden Sie sich an"})]}),a&&s.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:a}),s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(H,{label:"E-Mail",type:"email",value:e,onChange:x=>t(x.target.value),required:!0,autoComplete:"email"}),s.jsx(H,{label:"Passwort",type:"password",value:n,onChange:x=>r(x.target.value),required:!0,autoComplete:"current-password"}),s.jsx(T,{type:"submit",className:"w-full",disabled:l,children:l?"Anmeldung...":"Anmelden"})]})]})})}function qe({isOpen:e,onClose:t,title:n,children:r,size:a="md"}){if(j.useEffect(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),!e)return null;const i={sm:"max-w-md",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"};return s.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:s.jsxs("div",{className:"flex min-h-full items-center justify-center p-4",children:[s.jsx("div",{className:"fixed inset-0 bg-black/50",onClick:t}),s.jsxs("div",{className:`relative bg-white rounded-lg shadow-xl w-full ${i[a]}`,children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",children:[s.jsx("h2",{className:"text-lg font-semibold",children:n}),s.jsx(T,{variant:"ghost",size:"sm",onClick:t,children:s.jsx(qt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-6",children:r})]})]})})}function sk(){var w,S,A,O,R,q;const{user:e,isCustomer:t,isCustomerPortal:n}=We(),[r,a]=j.useState(!1),{data:i,isLoading:l}=fe({queryKey:["app-settings-public"],queryFn:()=>Xr.getPublic(),enabled:n,staleTime:0}),o=!l&&((w=i==null?void 0:i.data)==null?void 0:w.customerSupportTicketsEnabled)==="true",{data:c}=fe({queryKey:["customers-count"],queryFn:()=>At.getAll({limit:1}),enabled:!t}),{data:d}=fe({queryKey:["contracts",t?e==null?void 0:e.customerId:void 0],queryFn:()=>Oe.getAll(t?{customerId:e==null?void 0:e.customerId}:{limit:1})}),{data:u}=fe({queryKey:["contracts-active",t?e==null?void 0:e.customerId:void 0],queryFn:()=>Oe.getAll({status:"ACTIVE",...t?{customerId:e==null?void 0:e.customerId}:{limit:1}})}),{data:h}=fe({queryKey:["contracts-pending",t?e==null?void 0:e.customerId:void 0],queryFn:()=>Oe.getAll({status:"PENDING",...t?{customerId:e==null?void 0:e.customerId}:{limit:1}})}),{data:x}=fe({queryKey:["task-stats"],queryFn:()=>et.getStats()}),{data:m}=fe({queryKey:["contract-cockpit"],queryFn:()=>Oe.getCockpit(),enabled:!t,staleTime:0}),{ownContracts:f,representedContracts:p}=j.useMemo(()=>{if(!n||!(d!=null&&d.data))return{ownContracts:[],representedContracts:[]};const D=[],z={};for(const k of d.data)if(k.customerId===(e==null?void 0:e.customerId))D.push(k);else{const K=k.customerId;if(!z[K]){const B=k.customer?k.customer.companyName||`${k.customer.firstName} ${k.customer.lastName}`:`Kunde ${K}`;z[K]={customerName:B,contracts:[]}}z[K].contracts.push(k)}return{ownContracts:D,representedContracts:Object.values(z).sort((k,K)=>k.customerName.localeCompare(K.customerName))}},[d==null?void 0:d.data,n,e==null?void 0:e.customerId]),b=j.useMemo(()=>f.filter(D=>D.status==="ACTIVE").length,[f]),g=j.useMemo(()=>f.filter(D=>D.status==="PENDING").length,[f]),y=j.useMemo(()=>f.filter(D=>D.status==="EXPIRED").length,[f]),v=j.useMemo(()=>p.reduce((D,z)=>D+z.contracts.length,0),[p]),N=j.useMemo(()=>p.reduce((D,z)=>D+z.contracts.filter(k=>k.status==="ACTIVE").length,0),[p]),E=j.useMemo(()=>p.reduce((D,z)=>D+z.contracts.filter(k=>k.status==="EXPIRED").length,0),[p]),P=((S=x==null?void 0:x.data)==null?void 0:S.openCount)||0,I=D=>s.jsx(X,{className:D.link?"cursor-pointer hover:shadow-md transition-shadow":"",children:D.link?s.jsx(ke,{to:D.link,className:"block",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:`p-3 rounded-lg ${D.color}`,children:s.jsx(D.icon,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm text-gray-500",children:D.label}),s.jsx("p",{className:"text-2xl font-bold",children:D.value})]})]})}):s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:`p-3 rounded-lg ${D.color}`,children:s.jsx(D.icon,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm text-gray-500",children:D.label}),s.jsx("p",{className:"text-2xl font-bold",children:D.value})]})]})},D.label);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("h1",{className:"text-2xl font-bold",children:["Willkommen, ",e==null?void 0:e.firstName,"!"]}),n&&o&&s.jsxs(T,{onClick:()=>a(!0),children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Support-Anfrage"]})]}),n?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(ii,{className:"w-5 h-5 text-blue-600"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Meine Verträge"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[I({label:"Eigene Verträge",value:f.length,icon:Be,color:"bg-blue-500",link:"/contracts"}),I({label:"Davon aktiv",value:b,icon:As,color:"bg-green-500"}),I({label:"Davon ausstehend",value:g,icon:on,color:"bg-yellow-500"}),I({label:"Davon abgelaufen",value:y,icon:mx,color:"bg-red-500"})]})]}),v>0&&s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(Ca,{className:"w-5 h-5 text-purple-600"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Fremdverträge"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[I({label:"Fremdverträge",value:v,icon:Ca,color:"bg-purple-500",link:"/contracts"}),I({label:"Davon aktiv",value:N,icon:As,color:"bg-green-500"}),s.jsx("div",{className:"hidden lg:block"}),I({label:"Davon abgelaufen",value:E,icon:mx,color:"bg-red-500"})]})]}),s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(ul,{className:"w-5 h-5 text-orange-600"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Support-Anfragen"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:I({label:"Offene Anfragen",value:P,icon:ul,color:"bg-orange-500",link:"/tasks"})})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-6",children:[I({label:"Kunden",value:((A=c==null?void 0:c.pagination)==null?void 0:A.total)||0,icon:Ca,color:"bg-blue-500",link:"/customers"}),I({label:"Verträge gesamt",value:((O=d==null?void 0:d.pagination)==null?void 0:O.total)||0,icon:Be,color:"bg-purple-500",link:"/contracts"}),I({label:"Aktive Verträge",value:((R=u==null?void 0:u.pagination)==null?void 0:R.total)||0,icon:As,color:"bg-green-500"}),I({label:"Ausstehende Verträge",value:((q=h==null?void 0:h.pagination)==null?void 0:q.total)||0,icon:kn,color:"bg-yellow-500"})]}),(m==null?void 0:m.data)&&s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(kn,{className:"w-5 h-5 text-red-500"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Vertrags-Cockpit"})]}),s.jsx(ke,{to:"/contracts/cockpit",className:"text-sm text-blue-600 hover:underline",children:"Alle anzeigen"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsx(X,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(ke,{to:"/contracts/cockpit?filter=critical",className:"block",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-lg bg-red-100",children:s.jsx(kn,{className:"w-6 h-6 text-red-500"})}),s.jsxs("div",{className:"ml-4",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Kritisch (<",m.data.thresholds.criticalDays," Tage)"]}),s.jsx("p",{className:"text-2xl font-bold text-red-600",children:m.data.summary.criticalCount})]})]})})}),s.jsx(X,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(ke,{to:"/contracts/cockpit?filter=warning",className:"block",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-lg bg-yellow-100",children:s.jsx(hs,{className:"w-6 h-6 text-yellow-500"})}),s.jsxs("div",{className:"ml-4",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Warnung (<",m.data.thresholds.warningDays," Tage)"]}),s.jsx("p",{className:"text-2xl font-bold text-yellow-600",children:m.data.summary.warningCount})]})]})})}),s.jsx(X,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(ke,{to:"/contracts/cockpit?filter=ok",className:"block",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-lg bg-green-100",children:s.jsx(As,{className:"w-6 h-6 text-green-500"})}),s.jsxs("div",{className:"ml-4",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["OK (<",m.data.thresholds.okDays," Tage)"]}),s.jsx("p",{className:"text-2xl font-bold text-green-600",children:m.data.summary.okCount})]})]})})}),s.jsx(X,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(ke,{to:"/contracts/cockpit",className:"block",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:"p-3 rounded-lg bg-gray-100",children:s.jsx(Be,{className:"w-6 h-6 text-gray-500"})}),s.jsxs("div",{className:"ml-4",children:[s.jsx("p",{className:"text-sm text-gray-500",children:"Handlungsbedarf"}),s.jsx("p",{className:"text-2xl font-bold text-gray-600",children:m.data.summary.totalContracts})]})]})})})]})]}),s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(dl,{className:"w-5 h-5 text-orange-600"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Aufgaben"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:I({label:"Offene Aufgaben",value:P,icon:dl,color:"bg-orange-500",link:"/tasks"})})]})]}),n&&s.jsx(nk,{isOpen:r,onClose:()=>a(!1)})]})}function nk({isOpen:e,onClose:t}){const{user:n}=We(),r=Yt(),a=ge(),[i,l]=j.useState("own"),[o,c]=j.useState(null),[d,u]=j.useState(""),[h,x]=j.useState(""),[m,f]=j.useState(!1),[p,b]=j.useState(""),{data:g}=fe({queryKey:["contracts",n==null?void 0:n.customerId],queryFn:()=>Oe.getAll({customerId:n==null?void 0:n.customerId}),enabled:e}),y=j.useMemo(()=>{if(!(g!=null&&g.data))return{own:[],represented:{}};const w=[],S={};for(const A of g.data)if(A.customerId===(n==null?void 0:n.customerId))w.push(A);else{if(!S[A.customerId]){const O=A.customer?A.customer.companyName||`${A.customer.firstName} ${A.customer.lastName}`:`Kunde ${A.customerId}`;S[A.customerId]={name:O,contracts:[]}}S[A.customerId].contracts.push(A)}return{own:w,represented:S}},[g==null?void 0:g.data,n==null?void 0:n.customerId]),v=Object.keys(y.represented).length>0,N=j.useMemo(()=>{var w;return i==="own"?y.own:((w=y.represented[i])==null?void 0:w.contracts)||[]},[i,y]),E=j.useMemo(()=>{if(!p)return N;const w=p.toLowerCase();return N.filter(S=>S.contractNumber.toLowerCase().includes(w)||(S.providerName||"").toLowerCase().includes(w)||(S.tariffName||"").toLowerCase().includes(w))},[N,p]),P=async()=>{if(!(!o||!d.trim())){f(!0);try{await et.createSupportTicket(o,{title:d.trim(),description:h.trim()||void 0}),a.invalidateQueries({queryKey:["task-stats"]}),a.invalidateQueries({queryKey:["all-tasks"]}),t(),u(""),x(""),c(null),l("own"),r(`/contracts/${o}`)}catch(w){console.error("Fehler beim Erstellen der Support-Anfrage:",w),alert("Fehler beim Erstellen der Support-Anfrage. Bitte versuchen Sie es erneut.")}finally{f(!1)}}},I=()=>{u(""),x(""),c(null),l("own"),b(""),t()};return s.jsx(qe,{isOpen:e,onClose:I,title:"Neue Support-Anfrage",children:s.jsxs("div",{className:"space-y-4",children:[v&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kunde"}),s.jsxs("select",{value:i,onChange:w=>{const S=w.target.value;l(S==="own"?"own":parseInt(S)),c(null),b("")},className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"own",children:"Eigene Verträge"}),Object.entries(y.represented).map(([w,{name:S}])=>s.jsx("option",{value:w,children:S},w))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),s.jsx(H,{placeholder:"Vertrag suchen...",value:p,onChange:w=>b(w.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-lg",children:E.length>0?E.map(w=>s.jsxs("div",{onClick:()=>c(w.id),className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${o===w.id?"bg-blue-50 border-blue-200":""}`,children:[s.jsx("div",{className:"font-medium",children:w.contractNumber}),s.jsxs("div",{className:"text-sm text-gray-500",children:[w.providerName||"Kein Anbieter",w.tariffName&&` - ${w.tariffName}`]})]},w.id)):s.jsx("div",{className:"p-3 text-gray-500 text-center",children:"Keine Verträge gefunden."})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Titel *"}),s.jsx(H,{value:d,onChange:w=>u(w.target.value),placeholder:"Kurze Beschreibung Ihres Anliegens"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung"}),s.jsx("textarea",{value:h,onChange:w=>x(w.target.value),placeholder:"Detaillierte Beschreibung (optional)",rows:4,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:I,children:"Abbrechen"}),s.jsx(T,{onClick:P,disabled:!o||!d.trim()||m,children:m?"Wird erstellt...":"Anfrage erstellen"})]})]})})}function ve({children:e,variant:t="default",className:n="",onClick:r}){const a={default:"bg-gray-100 text-gray-800",success:"bg-green-100 text-green-800",warning:"bg-yellow-100 text-yellow-800",danger:"bg-red-100 text-red-800",info:"bg-blue-100 text-blue-800"};return s.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${a[t]} ${n}`,onClick:r,children:e})}function rk(){const[e,t]=j.useState(""),[n,r]=j.useState(""),[a,i]=j.useState(1),{hasPermission:l}=We(),{data:o,isLoading:c}=fe({queryKey:["customers",e,n,a],queryFn:()=>At.getAll({search:e,type:n||void 0,page:a,limit:20})});return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Kunden"}),l("customers:create")&&s.jsx(ke,{to:"/customers/new",children:s.jsxs(T,{children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Neuer Kunde"]})})]}),s.jsx(X,{className:"mb-6",children:s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx(H,{placeholder:"Suchen...",value:e,onChange:d=>t(d.target.value),className:"flex-1"}),s.jsxs("select",{value:n,onChange:d=>r(d.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg w-28 flex-shrink-0",children:[s.jsx("option",{value:"",children:"Alle"}),s.jsx("option",{value:"PRIVATE",children:"Privat"}),s.jsx("option",{value:"BUSINESS",children:"Firma"})]}),s.jsx(T,{variant:"secondary",className:"flex-shrink-0",children:s.jsx(Tl,{className:"w-4 h-4"})})]})}),s.jsx(X,{children:c?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):o!=null&&o.data&&o.data.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Kundennr."}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Name"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Typ"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"E-Mail"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Verträge"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:o.data.map(d=>{var u;return s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-mono text-sm",children:d.customerNumber}),s.jsx("td",{className:"py-3 px-4",children:d.type==="BUSINESS"&&d.companyName?d.companyName:`${d.firstName} ${d.lastName}`}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ve,{variant:d.type==="BUSINESS"?"info":"default",children:d.type==="BUSINESS"?"Firma":"Privat"})}),s.jsx("td",{className:"py-3 px-4",children:d.email||"-"}),s.jsx("td",{className:"py-3 px-4",children:((u=d._count)==null?void 0:u.contracts)||0}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(ke,{to:`/customers/${d.id}`,children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Ae,{className:"w-4 h-4"})})}),l("customers:update")&&s.jsx(ke,{to:`/customers/${d.id}/edit`,children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(He,{className:"w-4 h-4"})})})]})})]},d.id)})})]})}),o.pagination&&o.pagination.totalPages>1&&s.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",o.pagination.page," von ",o.pagination.totalPages," (",o.pagination.total," Einträge)"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>i(d=>Math.max(1,d-1)),disabled:a===1,children:"Zurück"}),s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>i(d=>d+1),disabled:a>=o.pagination.totalPages,children:"Weiter"})]})]})]}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Kunden gefunden."})})]})}function ak({emails:e,selectedEmailId:t,onSelectEmail:n,onEmailDeleted:r,isLoading:a,folder:i="INBOX",accountId:l}){const o=i==="SENT",[c,d]=j.useState(null),{hasPermission:u}=We(),h=S=>{if(o)try{const A=JSON.parse(S.toAddresses);if(A.length>0)return`An: ${A[0]}${A.length>1?` (+${A.length-1})`:""}`}catch{return"An: (Unbekannt)"}return S.fromName||S.fromAddress},x=ge(),m=G({mutationFn:S=>Pe.toggleStar(S),onSuccess:(S,A)=>{x.invalidateQueries({queryKey:["emails"]}),x.invalidateQueries({queryKey:["email",A]})}}),f=G({mutationFn:({emailId:S,isRead:A})=>Pe.markAsRead(S,A),onSuccess:(S,A)=>{x.invalidateQueries({queryKey:["emails"]}),x.invalidateQueries({queryKey:["email",A.emailId]}),l&&x.invalidateQueries({queryKey:["folder-counts",l]})}}),p=G({mutationFn:S=>Pe.delete(S),onSuccess:(S,A)=>{x.invalidateQueries({queryKey:["emails"]}),l&&x.invalidateQueries({queryKey:["folder-counts",l]}),Re.success("E-Mail in Papierkorb verschoben"),d(null),r==null||r(A)},onError:S=>{console.error("Delete error:",S),Re.error(S.message||"Fehler beim Löschen der E-Mail"),d(null)}}),b=G({mutationFn:S=>Pe.unassignFromContract(S),onSuccess:()=>{x.invalidateQueries({queryKey:["emails"]}),Re.success("Vertragszuordnung aufgehoben")},onError:S=>{console.error("Unassign error:",S),Re.error(S.message||"Fehler beim Aufheben der Zuordnung")}}),g=(S,A)=>{S.stopPropagation(),b.mutate(A)},y=(S,A)=>{S.stopPropagation(),d(A)},v=S=>{S.stopPropagation(),c&&p.mutate(c)},N=S=>{S.stopPropagation(),d(null)},E=S=>{const A=new Date(S),O=new Date;return A.toDateString()===O.toDateString()?A.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}):A.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})},P=(S,A)=>{S.stopPropagation(),m.mutate(A)},I=(S,A)=>{S.stopPropagation(),f.mutate({emailId:A.id,isRead:!A.isRead})},w=S=>{S.isRead||f.mutate({emailId:S.id,isRead:!0}),n(S)};return a?s.jsx("div",{className:"flex items-center justify-center h-64",children:s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):e.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-gray-500",children:[s.jsx(nn,{className:"w-12 h-12 mb-2 opacity-50"}),s.jsx("p",{children:"Keine E-Mails vorhanden"})]}):s.jsxs("div",{className:"divide-y divide-gray-200",children:[e.map(S=>s.jsxs("div",{onClick:()=>w(S),className:["flex items-start gap-3 p-3 cursor-pointer transition-colors",t===S.id?"bg-blue-100":["hover:bg-gray-100",S.isRead?"bg-gray-50/50":"bg-white"].join(" ")].join(" "),style:{borderLeft:t===S.id?"4px solid #2563eb":"4px solid transparent"},children:[s.jsx("button",{onClick:A=>I(A,S),className:`
|
||
flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200
|
||
${S.isRead?"text-gray-400":"text-blue-600"}
|
||
`,title:S.isRead?"Als ungelesen markieren":"Als gelesen markieren",children:S.isRead?s.jsx(Pv,{className:"w-4 h-4"}):s.jsx(nn,{className:"w-4 h-4"})}),s.jsx("button",{onClick:A=>P(A,S.id),className:`
|
||
flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200
|
||
${S.isStarred?"text-yellow-500":"text-gray-400"}
|
||
`,title:S.isStarred?"Stern entfernen":"Als wichtig markieren",children:s.jsx(ph,{className:`w-4 h-4 ${S.isStarred?"fill-current":""}`})}),u("emails:delete")&&s.jsx("button",{onClick:A=>y(A,S.id),className:"flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-red-100 text-gray-400 hover:text-red-600",title:"E-Mail löschen",children:s.jsx(Ne,{className:"w-4 h-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[s.jsx("span",{className:`text-sm truncate ${S.isRead?"text-gray-700":"font-semibold text-gray-900"}`,children:h(S)}),s.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:E(S.receivedAt)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-sm truncate ${S.isRead?"text-gray-600":"font-medium text-gray-900"}`,children:S.subject||"(Kein Betreff)"}),S.hasAttachments&&s.jsx(Rc,{className:"w-3 h-3 text-gray-400 flex-shrink-0"})]}),S.contract&&s.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[s.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800",children:S.contract.contractNumber}),(i==="INBOX"||i==="SENT"&&!S.isAutoAssigned)&&s.jsx("button",{onClick:A=>g(A,S.id),className:"p-0.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded",title:"Zuordnung aufheben",disabled:b.isPending,children:s.jsx(qt,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(Ft,{className:"w-4 h-4 text-gray-400 flex-shrink-0 mt-2"})]},S.id)),c&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:"Die E-Mail wird in den Papierkorb verschoben."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:N,disabled:p.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:v,disabled:p.isPending,children:p.isPending?"Löschen...":"Löschen"})]})]})})]})}const Ie=j.forwardRef(({className:e="",label:t,error:n,options:r,id:a,placeholder:i="Bitte wählen...",...l},o)=>{const c=a||l.name,d=/\bw-\d+\b|\bw-\[|\bflex-/.test(e);return s.jsxs("div",{className:d?e:"w-full",children:[t&&s.jsx("label",{htmlFor:c,className:"block text-sm font-medium text-gray-700 mb-1",children:t}),s.jsxs("select",{ref:o,id:c,className:`block w-full px-3 py-2 border rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${n?"border-red-500":"border-gray-300"}`,...l,children:[s.jsx("option",{value:"",children:i}),r.map(u=>s.jsx("option",{value:u.value,children:u.label},u.value))]}),n&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:n})]})});Ie.displayName="Select";function ik({isOpen:e,onClose:t,emailId:n,attachmentFilename:r,onSuccess:a}){var O,R,q;const[i,l]=j.useState(null),[o,c]=j.useState(new Set(["customer"])),[d,u]=j.useState("document"),[h,x]=j.useState({invoiceDate:new Date().toISOString().split("T")[0],invoiceType:"INTERIM",notes:""}),m=ge(),{data:f,isLoading:p,error:b}=fe({queryKey:["attachment-targets",n],queryFn:()=>Pe.getAttachmentTargets(n),enabled:e}),g=f==null?void 0:f.data,y=((O=g==null?void 0:g.contract)==null?void 0:O.type)==="ELECTRICITY"||((R=g==null?void 0:g.contract)==null?void 0:R.type)==="GAS",v=G({mutationFn:()=>{if(!i)throw new Error("Kein Ziel ausgewählt");return Pe.saveAttachmentTo(n,r,{entityType:i.entityType,entityId:i.entityId,targetKey:i.targetKey})},onSuccess:()=>{var D,z;Re.success("Anhang gespeichert"),m.invalidateQueries({queryKey:["attachment-targets",n]}),m.invalidateQueries({queryKey:["customers"]}),m.invalidateQueries({queryKey:["contracts"]}),(D=g==null?void 0:g.customer)!=null&&D.id&&m.invalidateQueries({queryKey:["customer",g.customer.id.toString()]}),(z=g==null?void 0:g.contract)!=null&&z.id&&m.invalidateQueries({queryKey:["contract",g.contract.id.toString()]}),a==null||a(),E()},onError:D=>{Re.error(D.message||"Fehler beim Speichern")}}),N=G({mutationFn:()=>Pe.saveAttachmentAsInvoice(n,r,{invoiceDate:h.invoiceDate,invoiceType:h.invoiceType,notes:h.notes||void 0}),onSuccess:()=>{var D;Re.success("Anhang als Rechnung gespeichert"),m.invalidateQueries({queryKey:["attachment-targets",n]}),m.invalidateQueries({queryKey:["customers"]}),m.invalidateQueries({queryKey:["contracts"]}),(D=g==null?void 0:g.contract)!=null&&D.id&&m.invalidateQueries({queryKey:["contract",g.contract.id.toString()]}),a==null||a(),E()},onError:D=>{Re.error(D.message||"Fehler beim Speichern der Rechnung")}}),E=()=>{l(null),u("document"),x({invoiceDate:new Date().toISOString().split("T")[0],invoiceType:"INTERIM",notes:""}),t()},P=D=>{const z=new Set(o);z.has(D)?z.delete(D):z.add(D),c(z)},I=(D,z,k,K)=>{l({entityType:D,entityId:k,targetKey:z.key,hasDocument:z.hasDocument,label:K?`${K} → ${z.label}`:z.label})},w=(D,z,k,K)=>D.map(B=>{const _=(i==null?void 0:i.entityType)===z&&(i==null?void 0:i.entityId)===k&&(i==null?void 0:i.targetKey)===B.key;return s.jsxs("div",{onClick:()=>I(z,B,k,K),className:`
|
||
flex items-center gap-3 p-3 cursor-pointer transition-colors rounded-lg ml-4
|
||
${_?"bg-blue-100 ring-2 ring-blue-500":"hover:bg-gray-100"}
|
||
`,children:[s.jsx("div",{className:"flex-1 min-w-0",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-medium text-gray-900",children:B.label}),B.hasDocument&&s.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded-full bg-yellow-100 text-yellow-800",children:[s.jsx(hs,{className:"w-3 h-3"}),"Vorhanden"]})]})}),_&&s.jsx(xr,{className:"w-5 h-5 text-blue-600"})]},B.key)}),S=(D,z)=>s.jsxs("div",{className:"mb-2",children:[s.jsx("div",{className:"text-sm font-medium text-gray-700 px-3 py-1 bg-gray-50 rounded",children:D.label}),w(D.slots,z,D.id,D.label)]},D.id),A=(D,z,k,K,B=!1)=>{const _=o.has(z);return s.jsxs("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>P(z),className:"w-full flex items-center gap-2 p-3 bg-gray-50 hover:bg-gray-100 transition-colors",children:[_?s.jsx(dn,{className:"w-4 h-4 text-gray-500"}):s.jsx(Ft,{className:"w-4 h-4 text-gray-500"}),k,s.jsx("span",{className:"font-medium text-gray-900",children:D})]}),_&&s.jsx("div",{className:"p-2",children:B?s.jsx("p",{className:"text-sm text-gray-500 text-center py-4",children:"Keine Einträge vorhanden"}):K})]})};return s.jsx(qe,{isOpen:e,onClose:E,title:"Anhang speichern unter",size:"lg",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"p-3 bg-gray-50 rounded-lg",children:s.jsxs("p",{className:"text-sm text-gray-600",children:[s.jsx("span",{className:"font-medium",children:"Datei:"})," ",r]})}),p&&s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}),b&&s.jsx("div",{className:"p-4 bg-red-50 text-red-700 rounded-lg",children:"Fehler beim Laden der Dokumentziele"}),g&&s.jsxs(s.Fragment,{children:[y&&s.jsxs("div",{className:"flex gap-2 p-1 bg-gray-100 rounded-lg",children:[s.jsxs("button",{onClick:()=>u("document"),className:`flex-1 flex items-center justify-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-colors ${d==="document"?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Be,{className:"w-4 h-4"}),"Als Dokument"]}),s.jsxs("button",{onClick:()=>u("invoice"),className:`flex-1 flex items-center justify-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-colors ${d==="invoice"?"bg-white text-green-600 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(mh,{className:"w-4 h-4"}),"Als Rechnung"]})]}),d==="document"&&s.jsxs("div",{className:"space-y-3 max-h-96 overflow-auto",children:[A(`Kunde: ${g.customer.name}`,"customer",s.jsx(ii,{className:"w-4 h-4 text-blue-600"}),w(g.customer.slots,"customer"),g.customer.slots.length===0),A("Ausweisdokumente","identityDocuments",s.jsx(Av,{className:"w-4 h-4 text-green-600"}),g.identityDocuments.map(D=>S(D,"identityDocument")),g.identityDocuments.length===0),A("Bankkarten","bankCards",s.jsx(ch,{className:"w-4 h-4 text-purple-600"}),g.bankCards.map(D=>S(D,"bankCard")),g.bankCards.length===0),g.contract&&A(`Vertrag: ${g.contract.contractNumber}`,"contract",s.jsx(Be,{className:"w-4 h-4 text-orange-600"}),w(g.contract.slots,"contract"),g.contract.slots.length===0),!g.contract&&s.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg text-sm text-gray-600",children:[s.jsx(Be,{className:"w-4 h-4 inline-block mr-2 text-gray-400"}),"E-Mail ist keinem Vertrag zugeordnet. Ordnen Sie die E-Mail einem Vertrag zu, um Vertragsdokumente als Ziel auswählen zu können."]})]}),d==="invoice"&&y&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"p-3 bg-green-50 rounded-lg",children:s.jsxs("p",{className:"text-sm text-green-700",children:["Der Anhang wird als Rechnung für den Vertrag ",s.jsx("strong",{children:(q=g.contract)==null?void 0:q.contractNumber})," gespeichert."]})}),s.jsx(H,{label:"Rechnungsdatum",type:"date",value:h.invoiceDate,onChange:D=>x({...h,invoiceDate:D.target.value}),required:!0}),s.jsx(Ie,{label:"Rechnungstyp",value:h.invoiceType,onChange:D=>x({...h,invoiceType:D.target.value}),options:[{value:"INTERIM",label:"Zwischenrechnung"},{value:"FINAL",label:"Schlussrechnung"}]}),s.jsx(H,{label:"Notizen (optional)",value:h.notes,onChange:D=>x({...h,notes:D.target.value}),placeholder:"Optionale Anmerkungen..."})]})]}),d==="document"&&(i==null?void 0:i.hasDocument)&&s.jsxs("div",{className:"p-3 bg-yellow-50 border border-yellow-200 rounded-lg flex items-start gap-2",children:[s.jsx(hs,{className:"w-5 h-5 text-yellow-600 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm text-yellow-800",children:[s.jsx("strong",{children:"Achtung:"})," An diesem Feld ist bereits ein Dokument hinterlegt. Das vorhandene Dokument wird durch den neuen Anhang ersetzt."]})]}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:E,children:"Abbrechen"}),d==="document"?s.jsx(T,{onClick:()=>v.mutate(),disabled:!i||v.isPending||N.isPending,children:v.isPending?"Wird gespeichert...":"Speichern"}):s.jsx(T,{onClick:()=>N.mutate(),disabled:!h.invoiceDate||v.isPending||N.isPending,children:N.isPending?"Wird gespeichert...":"Als Rechnung speichern"})]})]})})}function lk({isOpen:e,onClose:t,emailId:n,onSuccess:r}){var O,R,q;const[a,i]=j.useState(null),[l,o]=j.useState(new Set(["customer"])),[c,d]=j.useState("document"),[u,h]=j.useState({invoiceDate:new Date().toISOString().split("T")[0],invoiceType:"INTERIM",notes:""}),x=ge(),{data:m,isLoading:f,error:p}=fe({queryKey:["attachment-targets",n],queryFn:()=>Pe.getAttachmentTargets(n),enabled:e}),b=m==null?void 0:m.data,g=((O=b==null?void 0:b.contract)==null?void 0:O.type)==="ELECTRICITY"||((R=b==null?void 0:b.contract)==null?void 0:R.type)==="GAS",y=G({mutationFn:()=>{if(!a)throw new Error("Kein Ziel ausgewählt");return Pe.saveEmailAsPdf(n,{entityType:a.entityType,entityId:a.entityId,targetKey:a.targetKey})},onSuccess:()=>{var D,z;Re.success("E-Mail als PDF gespeichert"),x.invalidateQueries({queryKey:["attachment-targets",n]}),x.invalidateQueries({queryKey:["customers"]}),x.invalidateQueries({queryKey:["contracts"]}),(D=b==null?void 0:b.customer)!=null&&D.id&&x.invalidateQueries({queryKey:["customer",b.customer.id.toString()]}),(z=b==null?void 0:b.contract)!=null&&z.id&&x.invalidateQueries({queryKey:["contract",b.contract.id.toString()]}),r==null||r(),N()},onError:D=>{Re.error(D.message||"Fehler beim Speichern")}}),v=G({mutationFn:()=>Pe.saveEmailAsInvoice(n,{invoiceDate:u.invoiceDate,invoiceType:u.invoiceType,notes:u.notes||void 0}),onSuccess:()=>{var D;Re.success("E-Mail als Rechnung gespeichert"),x.invalidateQueries({queryKey:["attachment-targets",n]}),x.invalidateQueries({queryKey:["customers"]}),x.invalidateQueries({queryKey:["contracts"]}),(D=b==null?void 0:b.contract)!=null&&D.id&&x.invalidateQueries({queryKey:["contract",b.contract.id.toString()]}),r==null||r(),N()},onError:D=>{Re.error(D.message||"Fehler beim Speichern der Rechnung")}}),N=()=>{i(null),d("document"),h({invoiceDate:new Date().toISOString().split("T")[0],invoiceType:"INTERIM",notes:""}),t()},E=D=>{const z=new Set(l);z.has(D)?z.delete(D):z.add(D),o(z)},P=(D,z,k,K)=>{i({entityType:D,entityId:k,targetKey:z.key,hasDocument:z.hasDocument,label:K?`${K} → ${z.label}`:z.label})},I=(D,z,k,K)=>D.map(B=>{const _=(a==null?void 0:a.entityType)===z&&(a==null?void 0:a.entityId)===k&&(a==null?void 0:a.targetKey)===B.key;return s.jsxs("div",{onClick:()=>P(z,B,k,K),className:`
|
||
flex items-center gap-3 p-3 cursor-pointer transition-colors rounded-lg ml-4
|
||
${_?"bg-blue-100 ring-2 ring-blue-500":"hover:bg-gray-100"}
|
||
`,children:[s.jsx("div",{className:"flex-1 min-w-0",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-medium text-gray-900",children:B.label}),B.hasDocument&&s.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded-full bg-yellow-100 text-yellow-800",children:[s.jsx(hs,{className:"w-3 h-3"}),"Vorhanden"]})]})}),_&&s.jsx(xr,{className:"w-5 h-5 text-blue-600"})]},B.key)}),w=(D,z)=>s.jsxs("div",{className:"mb-2",children:[s.jsx("div",{className:"text-sm font-medium text-gray-700 px-3 py-1 bg-gray-50 rounded",children:D.label}),I(D.slots,z,D.id,D.label)]},D.id),S=(D,z,k,K,B=!1)=>{const _=l.has(z);return s.jsxs("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>E(z),className:"w-full flex items-center gap-2 p-3 bg-gray-50 hover:bg-gray-100 transition-colors",children:[_?s.jsx(dn,{className:"w-4 h-4 text-gray-500"}):s.jsx(Ft,{className:"w-4 h-4 text-gray-500"}),k,s.jsx("span",{className:"font-medium text-gray-900",children:D})]}),_&&s.jsx("div",{className:"p-2",children:B?s.jsx("p",{className:"text-sm text-gray-500 text-center py-4",children:"Keine Einträge vorhanden"}):K})]})},A=y.isPending||v.isPending;return s.jsx(qe,{isOpen:e,onClose:N,title:"E-Mail als PDF speichern",size:"lg",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"p-3 bg-blue-50 rounded-lg",children:s.jsx("p",{className:"text-sm text-blue-700",children:"Die E-Mail wird als PDF exportiert (inkl. Absender, Empfänger, Datum und Inhalt) und im gewählten Dokumentenfeld gespeichert."})}),f&&s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}),p&&s.jsx("div",{className:"p-4 bg-red-50 text-red-700 rounded-lg",children:"Fehler beim Laden der Dokumentziele"}),b&&s.jsxs(s.Fragment,{children:[g&&s.jsxs("div",{className:"flex gap-2 p-1 bg-gray-100 rounded-lg",children:[s.jsxs("button",{onClick:()=>d("document"),className:`flex-1 flex items-center justify-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-colors ${c==="document"?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Be,{className:"w-4 h-4"}),"Als Dokument"]}),s.jsxs("button",{onClick:()=>d("invoice"),className:`flex-1 flex items-center justify-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-colors ${c==="invoice"?"bg-white text-green-600 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(mh,{className:"w-4 h-4"}),"Als Rechnung"]})]}),c==="document"&&s.jsxs("div",{className:"space-y-3 max-h-96 overflow-auto",children:[S(`Kunde: ${b.customer.name}`,"customer",s.jsx(ii,{className:"w-4 h-4 text-blue-600"}),I(b.customer.slots,"customer"),b.customer.slots.length===0),S("Ausweisdokumente","identityDocuments",s.jsx(Av,{className:"w-4 h-4 text-green-600"}),b.identityDocuments.map(D=>w(D,"identityDocument")),b.identityDocuments.length===0),S("Bankkarten","bankCards",s.jsx(ch,{className:"w-4 h-4 text-purple-600"}),b.bankCards.map(D=>w(D,"bankCard")),b.bankCards.length===0),b.contract&&S(`Vertrag: ${b.contract.contractNumber}`,"contract",s.jsx(Be,{className:"w-4 h-4 text-orange-600"}),I(b.contract.slots,"contract"),b.contract.slots.length===0),!b.contract&&s.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg text-sm text-gray-600",children:[s.jsx(Be,{className:"w-4 h-4 inline-block mr-2 text-gray-400"}),"E-Mail ist keinem Vertrag zugeordnet. Ordnen Sie die E-Mail einem Vertrag zu, um Vertragsdokumente als Ziel auswählen zu können."]})]}),c==="invoice"&&g&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"p-3 bg-green-50 rounded-lg",children:s.jsxs("p",{className:"text-sm text-green-700",children:["Die E-Mail wird als Rechnung für den Vertrag ",s.jsx("strong",{children:(q=b.contract)==null?void 0:q.contractNumber})," gespeichert."]})}),s.jsx(H,{label:"Rechnungsdatum",type:"date",value:u.invoiceDate,onChange:D=>h({...u,invoiceDate:D.target.value}),required:!0}),s.jsx(Ie,{label:"Rechnungstyp",value:u.invoiceType,onChange:D=>h({...u,invoiceType:D.target.value}),options:[{value:"INTERIM",label:"Zwischenrechnung"},{value:"FINAL",label:"Schlussrechnung"}]}),s.jsx(H,{label:"Notizen (optional)",value:u.notes,onChange:D=>h({...u,notes:D.target.value}),placeholder:"Optionale Anmerkungen..."})]})]}),c==="document"&&(a==null?void 0:a.hasDocument)&&s.jsxs("div",{className:"p-3 bg-yellow-50 border border-yellow-200 rounded-lg flex items-start gap-2",children:[s.jsx(hs,{className:"w-5 h-5 text-yellow-600 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm text-yellow-800",children:[s.jsx("strong",{children:"Achtung:"})," An diesem Feld ist bereits ein Dokument hinterlegt. Das vorhandene Dokument wird durch die PDF ersetzt."]})]}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:N,children:"Abbrechen"}),c==="document"?s.jsx(T,{onClick:()=>y.mutate(),disabled:!a||A,children:A?"Wird erstellt...":"Als PDF speichern"}):s.jsx(T,{onClick:()=>v.mutate(),disabled:!u.invoiceDate||A,children:A?"Wird erstellt...":"Als Rechnung speichern"})]})]})})}function Rv({email:e,onReply:t,onAssignContract:n,onDeleted:r,isSentFolder:a=!1,isContractView:i=!1,isTrashView:l=!1,onRestored:o,accountId:c}){const[d,u]=j.useState(!0),[h,x]=j.useState(e.isStarred),[m,f]=j.useState(!1),[p,b]=j.useState(!1),[g,y]=j.useState(!1),[v,N]=j.useState(null),[E,P]=j.useState(!1),I=ge(),{hasPermission:w}=We();j.useEffect(()=>{x(e.isStarred)},[e.id,e.isStarred]);const S=G({mutationFn:()=>Pe.toggleStar(e.id),onMutate:()=>{x(Q=>!Q)},onSuccess:()=>{I.invalidateQueries({queryKey:["emails"]}),I.invalidateQueries({queryKey:["email",e.id]})},onError:()=>{x(e.isStarred)}}),A=G({mutationFn:()=>Pe.unassignFromContract(e.id),onSuccess:()=>{I.invalidateQueries({queryKey:["emails"]}),I.invalidateQueries({queryKey:["email",e.id]}),e.contractId&&I.invalidateQueries({queryKey:["contract-folder-counts",e.contractId]}),Re.success("Vertragszuordnung aufgehoben")},onError:Q=>{console.error("Unassign error:",Q),Re.error(Q.message||"Fehler beim Aufheben der Zuordnung")}}),O=G({mutationFn:()=>Pe.delete(e.id),onSuccess:()=>{I.invalidateQueries({queryKey:["emails"]}),c&&I.invalidateQueries({queryKey:["folder-counts",c]}),e.contractId&&I.invalidateQueries({queryKey:["contract-folder-counts",e.contractId]}),Re.success("E-Mail in Papierkorb verschoben"),f(!1),r==null||r()},onError:Q=>{console.error("Delete error:",Q),Re.error(Q.message||"Fehler beim Löschen der E-Mail"),f(!1)}}),R=G({mutationFn:()=>Pe.restore(e.id),onSuccess:()=>{I.invalidateQueries({queryKey:["emails"]}),c&&I.invalidateQueries({queryKey:["folder-counts",c]}),e.contractId&&I.invalidateQueries({queryKey:["contract-folder-counts",e.contractId]}),Re.success("E-Mail wiederhergestellt"),b(!1),o==null||o()},onError:Q=>{console.error("Restore error:",Q),Re.error(Q.message||"Fehler beim Wiederherstellen der E-Mail"),b(!1)}}),q=G({mutationFn:()=>Pe.permanentDelete(e.id),onSuccess:()=>{I.invalidateQueries({queryKey:["emails"]}),c&&I.invalidateQueries({queryKey:["folder-counts",c]}),Re.success("E-Mail endgültig gelöscht"),y(!1),r==null||r()},onError:Q=>{console.error("Permanent delete error:",Q),Re.error(Q.message||"Fehler beim endgültigen Löschen der E-Mail"),y(!1)}}),D=Q=>new Date(Q).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}),z=Q=>{try{return JSON.parse(Q)}catch{return[]}},k=Q=>{if(!Q)return[];try{return JSON.parse(Q)}catch{return[]}},K=z(e.toAddresses),B=e.ccAddresses?z(e.ccAddresses):[],_=k(e.attachmentNames);return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"p-4 border-b border-gray-200 space-y-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:e.subject||"(Kein Betreff)"}),s.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:l?s.jsxs(s.Fragment,{children:[s.jsxs(T,{variant:"secondary",size:"sm",onClick:()=>b(!0),title:"Wiederherstellen",children:[s.jsx(Iv,{className:"w-4 h-4 mr-1"}),"Wiederherstellen"]}),s.jsxs(T,{variant:"danger",size:"sm",onClick:()=>y(!0),title:"Endgültig löschen",children:[s.jsx(Ne,{className:"w-4 h-4 mr-1"}),"Endgültig löschen"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>S.mutate(),className:`p-2 rounded-lg hover:bg-gray-100 ${h?"text-yellow-500":"text-gray-400"}`,title:h?"Stern entfernen":"Als wichtig markieren",children:s.jsx(ph,{className:`w-5 h-5 ${h?"fill-current":""}`})}),s.jsxs(T,{variant:"secondary",size:"sm",onClick:t,children:[s.jsx(V2,{className:"w-4 h-4 mr-1"}),"Antworten"]}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>P(!0),title:"E-Mail als PDF speichern",children:s.jsx(F2,{className:"w-4 h-4"})}),w("emails:delete")&&s.jsx(T,{variant:"danger",size:"sm",onClick:()=>f(!0),title:"E-Mail löschen",children:s.jsx(Ne,{className:"w-4 h-4"})})]})})]}),s.jsxs("div",{className:"text-sm space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-gray-500 w-12",children:"Von:"}),s.jsxs("span",{className:"font-medium text-gray-900",children:[e.fromName&&`${e.fromName} `,s.jsxs("span",{className:"text-gray-600",children:["<",e.fromAddress,">"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-gray-500 w-12",children:"An:"}),s.jsx("span",{className:"text-gray-700",children:K.join(", ")})]}),B.length>0&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-gray-500 w-12",children:"CC:"}),s.jsx("span",{className:"text-gray-700",children:B.join(", ")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-gray-500 w-12",children:"Am:"}),s.jsx("span",{className:"text-gray-700",children:D(e.receivedAt)})]})]}),s.jsx("div",{className:"flex items-center gap-2 pt-2",children:e.contract?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-green-50 border border-green-200 rounded-lg",children:[s.jsx(px,{className:"w-4 h-4 text-green-600"}),s.jsxs("span",{className:"text-sm text-green-800",children:["Zugeordnet zu:"," ",s.jsx(ke,{to:`/contracts/${e.contract.id}`,className:"font-medium hover:underline",children:e.contract.contractNumber})]}),!e.isAutoAssigned&&s.jsx("button",{onClick:()=>A.mutate(),className:"ml-2 p-1 hover:bg-green-100 rounded",title:"Zuordnung aufheben",children:s.jsx(qt,{className:"w-4 h-4 text-green-600"})})]}):!i&&s.jsxs(T,{variant:"secondary",size:"sm",onClick:n,children:[s.jsx(px,{className:"w-4 h-4 mr-1"}),"Vertrag zuordnen"]})}),_.length>0&&s.jsxs("div",{className:"pt-2",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(Rc,{className:"w-4 h-4 text-gray-400"}),s.jsxs("span",{className:"text-sm text-gray-500",children:[_.length," Anhang",_.length>1?"e":""]})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:_.map((Q,le)=>s.jsxs("div",{className:"inline-flex items-center gap-1 px-3 py-2 bg-gray-100 rounded-lg text-sm text-gray-700",children:[s.jsx("span",{className:"max-w-[200px] truncate mr-1",children:Q}),s.jsx("a",{href:Pe.getAttachmentUrl(e.id,Q,!0),target:"_blank",rel:"noopener noreferrer",className:"p-1 hover:bg-gray-200 rounded transition-colors",title:`${Q} öffnen`,children:s.jsx(dh,{className:"w-4 h-4 text-gray-500"})}),s.jsx("a",{href:Pe.getAttachmentUrl(e.id,Q),download:Q,className:"p-1 hover:bg-gray-200 rounded transition-colors",title:`${Q} herunterladen`,children:s.jsx(Ps,{className:"w-4 h-4 text-gray-500"})}),!l&&s.jsx("button",{onClick:()=>N(Q),className:"p-1 hover:bg-blue-100 rounded transition-colors",title:`${Q} speichern unter...`,children:s.jsx(Mv,{className:"w-4 h-4 text-blue-500"})})]},le))})]})]}),e.htmlBody&&e.textBody&&s.jsxs("div",{className:"px-4 py-2 border-b border-gray-200 flex items-center gap-2",children:[s.jsx("button",{onClick:()=>u(!0),className:`px-3 py-1 text-sm rounded ${d?"bg-blue-100 text-blue-700":"text-gray-600 hover:bg-gray-100"}`,children:"HTML"}),s.jsx("button",{onClick:()=>u(!1),className:`px-3 py-1 text-sm rounded ${d?"text-gray-600 hover:bg-gray-100":"bg-blue-100 text-blue-700"}`,children:"Text"})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4",children:d&&e.htmlBody?s.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:e.htmlBody}}):s.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-700 font-sans",children:e.textBody||"Kein Inhalt"})}),m&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:"Die E-Mail wird in den Papierkorb verschoben."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>f(!1),disabled:O.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:()=>O.mutate(),disabled:O.isPending,children:O.isPending?"Löschen...":"Löschen"})]})]})}),p&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail wiederherstellen?"}),s.jsxs("p",{className:"text-gray-600 mb-4",children:["Die E-Mail wird wieder in den ursprünglichen Ordner (",e.folder==="SENT"?"Gesendet":"Posteingang",") verschoben."]}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>b(!1),disabled:R.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"primary",onClick:()=>R.mutate(),disabled:R.isPending,children:R.isPending?"Wird wiederhergestellt...":"Wiederherstellen"})]})]})}),g&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail endgültig löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:"Diese Aktion kann nicht rückgängig gemacht werden. Die E-Mail wird unwiderruflich gelöscht."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>y(!1),disabled:q.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:()=>q.mutate(),disabled:q.isPending,children:q.isPending?"Wird gelöscht...":"Endgültig löschen"})]})]})}),v&&s.jsx(ik,{isOpen:!0,onClose:()=>N(null),emailId:e.id,attachmentFilename:v}),E&&s.jsx(lk,{isOpen:!0,onClose:()=>P(!1),emailId:e.id})]})}function Lv({isOpen:e,onClose:t,account:n,replyTo:r,onSuccess:a,contractId:i}){const[l,o]=j.useState(""),[c,d]=j.useState(""),[u,h]=j.useState(""),[x,m]=j.useState(""),[f,p]=j.useState([]),[b,g]=j.useState(null),y=j.useRef(null);j.useEffect(()=>{if(e){if(r){o(r.fromAddress||"");const R=r.subject||"",q=/^(Re|Aw|Fwd|Wg):\s*/i.test(R);h(q?R:`Re: ${R}`);const D=new Date(r.receivedAt).toLocaleString("de-DE"),z=r.textBody?`
|
||
|
||
--- Ursprüngliche Nachricht ---
|
||
Von: ${r.fromName||r.fromAddress}
|
||
Am: ${D}
|
||
|
||
${r.textBody}`:"";m(z)}else o(""),h(""),m("");d(""),p([]),g(null)}},[e,r]);const v=10*1024*1024,N=25*1024*1024,E=R=>new Promise((q,D)=>{const z=new FileReader;z.readAsDataURL(R),z.onload=()=>{const K=z.result.split(",")[1];q(K)},z.onerror=D}),P=async R=>{const q=R.target.files;if(!q)return;const D=[];let z=f.reduce((k,K)=>k+K.content.length*.75,0);for(const k of Array.from(q)){if(k.size>v){g(`Datei "${k.name}" ist zu groß (max. 10 MB)`);continue}if(z+k.size>N){g("Maximale Gesamtgröße der Anhänge erreicht (25 MB)");break}try{const K=await E(k);D.push({filename:k.name,content:K,contentType:k.type||"application/octet-stream"}),z+=k.size}catch{g(`Fehler beim Lesen von "${k.name}"`)}}D.length>0&&p(k=>[...k,...D]),y.current&&(y.current.value="")},I=R=>{p(q=>q.filter((D,z)=>z!==R))},w=R=>{const q=R.length*.75;return q<1024?`${Math.round(q)} B`:q<1024*1024?`${(q/1024).toFixed(1)} KB`:`${(q/(1024*1024)).toFixed(1)} MB`},S=G({mutationFn:()=>xs.sendEmail(n.id,{to:l.split(",").map(R=>R.trim()).filter(Boolean),cc:c?c.split(",").map(R=>R.trim()).filter(Boolean):void 0,subject:u,text:x,inReplyTo:r==null?void 0:r.messageId,references:r!=null&&r.messageId?[r.messageId]:void 0,attachments:f.length>0?f:void 0,contractId:i}),onSuccess:()=>{a==null||a(),A()},onError:R=>{g(R instanceof Error?R.message:"Fehler beim Senden")}}),A=()=>{t()},O=()=>{if(!l.trim()){g("Bitte Empfänger angeben");return}if(!u.trim()){g("Bitte Betreff angeben");return}g(null),S.mutate()};return s.jsx(qe,{isOpen:e,onClose:A,title:r?"Antworten":"Neue E-Mail",size:"lg",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Von"}),s.jsx("div",{className:"px-3 py-2 bg-gray-100 rounded-lg text-sm text-gray-700",children:n.email})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["An ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",value:l,onChange:R=>o(R.target.value),placeholder:"empfaenger@example.com",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),s.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Mehrere Empfänger mit Komma trennen"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"CC"}),s.jsx("input",{type:"text",value:c,onChange:R=>d(R.target.value),placeholder:"cc@example.com",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["Betreff ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",value:u,onChange:R=>h(R.target.value),placeholder:"Betreff eingeben",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Nachricht"}),s.jsx("textarea",{value:x,onChange:R=>m(R.target.value),rows:10,placeholder:"Ihre Nachricht...",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Anhänge"}),s.jsx("input",{type:"file",ref:y,onChange:P,multiple:!0,className:"hidden"}),s.jsxs("button",{type:"button",onClick:()=>{var R;return(R=y.current)==null?void 0:R.click()},className:"inline-flex items-center px-3 py-2 text-sm border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors",children:[s.jsx(Rc,{className:"w-4 h-4 mr-2"}),"Datei anhängen"]}),f.length>0&&s.jsx("div",{className:"mt-2 space-y-2",children:f.map((R,q)=>s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-gray-50 rounded-lg",children:[s.jsxs("div",{className:"flex items-center min-w-0",children:[s.jsx(Be,{className:"w-4 h-4 text-gray-500 mr-2 flex-shrink-0"}),s.jsx("span",{className:"text-sm text-gray-700 truncate",children:R.filename}),s.jsxs("span",{className:"ml-2 text-xs text-gray-500 flex-shrink-0",children:["(",w(R.content),")"]})]}),s.jsx("button",{type:"button",onClick:()=>I(q),className:"ml-2 p-1 text-gray-400 hover:text-red-500 transition-colors",title:"Anhang entfernen",children:s.jsx(qt,{className:"w-4 h-4"})})]},q))}),s.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Max. 10 MB pro Datei, 25 MB gesamt"})]}),b&&s.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700",children:b}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:A,children:"Abbrechen"}),s.jsxs(T,{onClick:O,disabled:S.isPending,children:[s.jsx(Fl,{className:"w-4 h-4 mr-2"}),S.isPending?"Wird gesendet...":"Senden"]})]})]})})}function ok({isOpen:e,onClose:t,email:n,customerId:r,onSuccess:a}){const[i,l]=j.useState(""),[o,c]=j.useState(null),d=ge(),{data:u,isLoading:h}=fe({queryKey:["contracts","customer",r],queryFn:()=>Oe.getAll({customerId:r}),enabled:e}),m=((u==null?void 0:u.data)||[]).filter(y=>{var N,E,P,I;if(!i)return!0;const v=i.toLowerCase();return y.contractNumber.toLowerCase().includes(v)||((E=(N=y.contractCategory)==null?void 0:N.name)==null?void 0:E.toLowerCase().includes(v))||((I=(P=y.provider)==null?void 0:P.name)==null?void 0:I.toLowerCase().includes(v))}),f=G({mutationFn:y=>Pe.assignToContract(n.id,y),onSuccess:(y,v)=>{d.invalidateQueries({queryKey:["emails"]}),d.invalidateQueries({queryKey:["email",n.id]}),d.invalidateQueries({queryKey:["contract-folder-counts",v]}),a==null||a(),p()}}),p=()=>{l(""),c(null),t()},b=()=>{o&&f.mutate(o)},g=y=>y?new Date(y).toLocaleDateString("de-DE"):"-";return s.jsx(qe,{isOpen:e,onClose:p,title:"E-Mail Vertrag zuordnen",size:"lg",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[s.jsxs("p",{className:"text-sm text-gray-600",children:[s.jsx("span",{className:"font-medium",children:"Betreff:"})," ",n.subject||"(Kein Betreff)"]}),s.jsxs("p",{className:"text-sm text-gray-600",children:[s.jsx("span",{className:"font-medium",children:"Von:"})," ",n.fromAddress]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(Tl,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx("input",{type:"text",value:i,onChange:y=>l(y.target.value),placeholder:"Vertrag suchen...",className:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),s.jsx("div",{className:"border border-gray-200 rounded-lg max-h-80 overflow-auto",children:h?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}):m.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[s.jsx(Be,{className:"w-8 h-8 mb-2 opacity-50"}),s.jsx("p",{className:"text-sm",children:"Keine Verträge gefunden"})]}):s.jsx("div",{className:"divide-y divide-gray-200",children:m.map(y=>{var v;return s.jsx("div",{onClick:()=>c(y.id),className:`
|
||
flex items-center gap-3 p-3 cursor-pointer transition-colors
|
||
${o===y.id?"bg-blue-50 border-l-2 border-l-blue-500":"hover:bg-gray-50"}
|
||
`,children:s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-medium text-gray-900",children:y.contractNumber}),s.jsx("span",{className:`
|
||
px-2 py-0.5 text-xs rounded-full
|
||
${y.status==="ACTIVE"?"bg-green-100 text-green-800":y.status==="PENDING"?"bg-yellow-100 text-yellow-800":y.status==="CANCELLED"?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"}
|
||
`,children:y.status})]}),s.jsxs("div",{className:"text-sm text-gray-600 truncate",children:[(v=y.contractCategory)==null?void 0:v.name,y.provider&&` - ${y.provider.name}`]}),s.jsxs("div",{className:"text-xs text-gray-500",children:["Start: ",g(y.startDate)]})]})},y.id)})})}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:p,children:"Abbrechen"}),s.jsx(T,{onClick:b,disabled:!o||f.isPending,children:f.isPending?"Wird zugeordnet...":"Zuordnen"})]})]})})}function Ov({emails:e,selectedEmailId:t,onSelectEmail:n,onEmailRestored:r,onEmailDeleted:a,isLoading:i}){const[l,o]=j.useState(null),[c,d]=j.useState(null),u=ge(),h=P=>{if(P.folder==="SENT")try{const I=JSON.parse(P.toAddresses);if(I.length>0)return`An: ${I[0]}${I.length>1?` (+${I.length-1})`:""}`}catch{return"An: (Unbekannt)"}return P.fromName||P.fromAddress},x=G({mutationFn:P=>Pe.restore(P),onSuccess:(P,I)=>{u.invalidateQueries({queryKey:["emails"]}),Re.success("E-Mail wiederhergestellt"),o(null),d(null),r==null||r(I)},onError:P=>{console.error("Restore error:",P),Re.error(P.message||"Fehler beim Wiederherstellen"),o(null),d(null)}}),m=G({mutationFn:P=>Pe.permanentDelete(P),onSuccess:(P,I)=>{u.invalidateQueries({queryKey:["emails"]}),Re.success("E-Mail endgültig gelöscht"),o(null),d(null),a==null||a(I)},onError:P=>{console.error("Permanent delete error:",P),Re.error(P.message||"Fehler beim endgültigen Löschen"),o(null),d(null)}}),f=G({mutationFn:P=>Pe.unassignFromContract(P),onSuccess:()=>{u.invalidateQueries({queryKey:["emails"]}),Re.success("Vertragszuordnung aufgehoben")},onError:P=>{console.error("Unassign error:",P),Re.error(P.message||"Fehler beim Aufheben der Zuordnung")}}),p=(P,I)=>{P.stopPropagation(),f.mutate(I)},b=(P,I)=>{P.stopPropagation(),o(I),d("restore")},g=(P,I)=>{P.stopPropagation(),o(I),d("delete")},y=P=>{P.stopPropagation(),l&&c&&(c==="restore"?x.mutate(l):m.mutate(l))},v=P=>{P.stopPropagation(),o(null),d(null)},N=P=>new Date(P).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"}),E=P=>{if(!P)return"";const I=new Date(P),w=new Date;return I.toDateString()===w.toDateString()?`Gelöscht um ${I.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"})}`:`Gelöscht am ${I.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})}`};return i?s.jsx("div",{className:"flex items-center justify-center h-64",children:s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-red-600"})}):e.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-gray-500",children:[s.jsx(Ne,{className:"w-12 h-12 mb-2 opacity-50"}),s.jsx("p",{children:"Papierkorb ist leer"})]}):s.jsxs("div",{className:"divide-y divide-gray-200",children:[e.map(P=>s.jsxs("div",{onClick:()=>n(P),className:["flex items-start gap-3 p-3 cursor-pointer transition-colors",t===P.id?"bg-red-100":"hover:bg-gray-100 bg-gray-50/50"].join(" "),style:{borderLeft:t===P.id?"4px solid #dc2626":"4px solid transparent"},children:[s.jsx("div",{className:"flex-shrink-0 mt-1 p-1 -ml-1 text-gray-400",title:P.folder==="SENT"?"Aus Gesendet":"Aus Posteingang",children:P.folder==="SENT"?s.jsx(Fl,{className:"w-4 h-4"}):s.jsx(Ur,{className:"w-4 h-4"})}),s.jsx("button",{onClick:I=>b(I,P.id),className:"flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-green-100 text-gray-400 hover:text-green-600",title:"Wiederherstellen",children:s.jsx(Iv,{className:"w-4 h-4"})}),s.jsx("button",{onClick:I=>g(I,P.id),className:"flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-red-100 text-gray-400 hover:text-red-600",title:"Endgültig löschen",children:s.jsx(Ne,{className:"w-4 h-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[s.jsx("span",{className:"text-sm truncate text-gray-700",children:h(P)}),s.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:N(P.receivedAt)})]}),s.jsx("div",{className:"text-sm truncate text-gray-600",children:P.subject||"(Kein Betreff)"}),s.jsx("div",{className:"text-xs text-red-500 mt-1",children:E(P.deletedAt)}),P.contract&&s.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[s.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800",children:P.contract.contractNumber}),(P.folder==="INBOX"||P.folder==="SENT"&&!P.isAutoAssigned)&&s.jsx("button",{onClick:I=>p(I,P.id),className:"p-0.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded",title:"Zuordnung aufheben",disabled:f.isPending,children:s.jsx(qt,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(Ft,{className:"w-4 h-4 text-gray-400 flex-shrink-0 mt-2"})]},P.id)),l&&c&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:c==="restore"?"E-Mail wiederherstellen?":"E-Mail endgültig löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:c==="restore"?"Die E-Mail wird wieder in den ursprünglichen Ordner verschoben.":"Die E-Mail wird unwiderruflich gelöscht. Diese Aktion kann nicht rückgängig gemacht werden."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:v,disabled:x.isPending||m.isPending,children:"Abbrechen"}),s.jsx(T,{variant:c==="restore"?"primary":"danger",onClick:y,disabled:x.isPending||m.isPending,children:x.isPending||m.isPending?"Wird ausgeführt...":c==="restore"?"Wiederherstellen":"Endgültig löschen"})]})]})})]})}function ck({customerId:e}){const[t,n]=j.useState(null),[r,a]=j.useState("INBOX"),[i,l]=j.useState(null),[o,c]=j.useState(!1),[d,u]=j.useState(!1),[h,x]=j.useState(null),m=ge(),{hasPermission:f}=We(),p=f("emails:delete"),{data:b,isLoading:g}=fe({queryKey:["mailbox-accounts",e],queryFn:()=>Pe.getMailboxAccounts(e)}),y=(b==null?void 0:b.data)||[];j.useEffect(()=>{y.length>0&&!t&&n(y[0].id)},[y,t]);const v=y.find(de=>de.id===t),{data:N,isLoading:E,refetch:P}=fe({queryKey:["emails","customer",e,t,r],queryFn:()=>Pe.getForCustomer(e,{accountId:t||void 0,folder:r}),enabled:!!t&&r!=="TRASH"}),I=(N==null?void 0:N.data)||[],{data:w,isLoading:S}=fe({queryKey:["emails","trash",e],queryFn:()=>Pe.getTrash(e),enabled:r==="TRASH"&&p}),A=(w==null?void 0:w.data)||[],{data:O}=fe({queryKey:["folder-counts",t],queryFn:()=>xs.getFolderCounts(t),enabled:!!t}),R=(O==null?void 0:O.data)||{inbox:0,inboxUnread:0,sent:0,sentUnread:0,trash:0,trashUnread:0},{data:q}=fe({queryKey:["email",i==null?void 0:i.id],queryFn:()=>Pe.getById(i.id),enabled:!!(i!=null&&i.id)}),D=(q==null?void 0:q.data)||i,z=G({mutationFn:de=>xs.syncEmails(de),onSuccess:()=>{m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["folder-counts",t]}),m.invalidateQueries({queryKey:["mailbox-accounts",e]})}}),k=()=>{t&&z.mutate(t)},K=de=>{l(de)},B=()=>{x(D||null),c(!0)},_=()=>{x(null),c(!0)},Q=()=>{u(!0)};if(!g&&y.length===0)return s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(nn,{className:"w-16 h-16 mb-4 opacity-30"}),s.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"Keine E-Mail-Konten vorhanden"}),s.jsx("p",{className:"text-sm text-center max-w-md",children:"Erstellen Sie eine Stressfrei-Wechseln E-Mail-Adresse mit aktivierter Mailbox, um E-Mails hier empfangen und versenden zu können."})]});const le=de=>{a(de),l(null)};return s.jsxs("div",{className:"flex flex-col h-full",style:{minHeight:"600px"},children:[s.jsxs("div",{className:"flex items-center justify-between gap-4 p-4 border-b border-gray-200 bg-gray-50",children:[y.length>1?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ur,{className:"w-5 h-5 text-gray-500"}),s.jsx("select",{value:t||"",onChange:de=>{n(Number(de.target.value)),l(null)},className:"px-3 py-2 border border-gray-300 rounded-lg bg-white focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm",children:y.map(de=>s.jsx("option",{value:de.id,children:de.email},de.id))})]}):s.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-600",children:[s.jsx(Ur,{className:"w-5 h-5 text-gray-500"}),s.jsx("span",{children:v==null?void 0:v.email})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-gray-200 rounded-lg p-1",children:[s.jsxs("button",{onClick:()=>le("INBOX"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${r==="INBOX"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Ur,{className:"w-4 h-4"}),"Posteingang",R.inbox>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${R.inboxUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${R.inboxUnread} ungelesen / ${R.inbox} gesamt`,children:R.inboxUnread>0?`${R.inboxUnread}/${R.inbox}`:R.inbox})]}),s.jsxs("button",{onClick:()=>le("SENT"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${r==="SENT"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Fl,{className:"w-4 h-4"}),"Gesendet",R.sent>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${R.sentUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${R.sentUnread} ungelesen / ${R.sent} gesamt`,children:R.sentUnread>0?`${R.sentUnread}/${R.sent}`:R.sent})]}),p&&s.jsxs("button",{onClick:()=>le("TRASH"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${r==="TRASH"?"bg-white text-red-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Ne,{className:"w-4 h-4"}),"Papierkorb",R.trash>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${R.trashUnread>0?"bg-red-100 text-red-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${R.trashUnread} ungelesen / ${R.trash} gesamt`,children:R.trashUnread>0?`${R.trashUnread}/${R.trash}`:R.trash})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r!=="TRASH"&&s.jsxs(T,{variant:"secondary",size:"sm",onClick:k,disabled:z.isPending||!t,children:[s.jsx(Sr,{className:`w-4 h-4 mr-1 ${z.isPending?"animate-spin":""}`}),z.isPending?"Sync...":"Synchronisieren"]}),s.jsxs(T,{size:"sm",onClick:_,disabled:!v,children:[s.jsx(_e,{className:"w-4 h-4 mr-1"}),"Neue E-Mail"]})]})]}),s.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[s.jsx("div",{className:"w-1/3 border-r border-gray-200 overflow-auto",children:r==="TRASH"?s.jsx(Ov,{emails:A,selectedEmailId:i==null?void 0:i.id,onSelectEmail:K,onEmailRestored:de=>{(i==null?void 0:i.id)===de&&l(null),m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["folder-counts",t]})},onEmailDeleted:de=>{(i==null?void 0:i.id)===de&&l(null),m.invalidateQueries({queryKey:["emails","trash"]}),m.invalidateQueries({queryKey:["folder-counts",t]})},isLoading:S}):s.jsx(ak,{emails:I,selectedEmailId:i==null?void 0:i.id,onSelectEmail:K,onEmailDeleted:de=>{(i==null?void 0:i.id)===de&&l(null),m.invalidateQueries({queryKey:["folder-counts",t]})},isLoading:E,folder:r,accountId:t})}),s.jsx("div",{className:"flex-1 overflow-auto",children:D?s.jsx(Rv,{email:D,onReply:B,onAssignContract:Q,onDeleted:()=>{l(null),m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["folder-counts",t]})},isSentFolder:r==="SENT",isTrashView:r==="TRASH",onRestored:()=>{l(null),m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["folder-counts",t]})},accountId:t||void 0}):s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-500",children:[s.jsx(nn,{className:"w-12 h-12 mb-2 opacity-30"}),s.jsx("p",{children:"Wählen Sie eine E-Mail aus"})]})})]}),v&&s.jsx(Lv,{isOpen:o,onClose:()=>{c(!1),x(null)},account:v,replyTo:h||void 0,onSuccess:()=>{m.invalidateQueries({queryKey:["emails","customer",e,t,"SENT"]}),m.invalidateQueries({queryKey:["folder-counts",t]}),r==="SENT"&&P()}}),D&&s.jsx(ok,{isOpen:d,onClose:()=>u(!1),email:D,customerId:e,onSuccess:()=>{P()}})]})}function dk({contractId:e,customerId:t}){const[n,r]=j.useState(null),[a,i]=j.useState("INBOX"),[l,o]=j.useState(null),[c,d]=j.useState(!1),[u,h]=j.useState(null),[x,m]=j.useState(null),f=ge(),{hasPermission:p}=We(),b=p("emails:delete"),{data:g,isLoading:y}=fe({queryKey:["mailbox-accounts",t],queryFn:()=>Pe.getMailboxAccounts(t)}),v=(g==null?void 0:g.data)||[];j.useEffect(()=>{v.length>0&&!n&&r(v[0].id)},[v,n]);const N=v.find(J=>J.id===n),{data:E,isLoading:P,refetch:I}=fe({queryKey:["emails","contract",e,a],queryFn:()=>Pe.getForContract(e,{folder:a}),enabled:a!=="TRASH"}),w=(E==null?void 0:E.data)||[],{data:S,isLoading:A}=fe({queryKey:["emails","trash",t],queryFn:()=>Pe.getTrash(t),enabled:a==="TRASH"&&b}),O=(S==null?void 0:S.data)||[],{data:R}=fe({queryKey:["contract-folder-counts",e],queryFn:()=>Pe.getContractFolderCounts(e)}),q=(R==null?void 0:R.data)||{inbox:0,inboxUnread:0,sent:0,sentUnread:0},{data:D}=fe({queryKey:["folder-counts",n],queryFn:()=>xs.getFolderCounts(n),enabled:!!n&&b}),z=(D==null?void 0:D.data)||{trash:0,trashUnread:0},{data:k}=fe({queryKey:["email",l==null?void 0:l.id],queryFn:()=>Pe.getById(l.id),enabled:!!(l!=null&&l.id)}),K=(k==null?void 0:k.data)||l,B=G({mutationFn:J=>xs.syncEmails(J),onSuccess:()=>{f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]}),Re.success("Synchronisation abgeschlossen")},onError:J=>{Re.error(J.message||"Synchronisation fehlgeschlagen")}}),_=G({mutationFn:J=>Pe.toggleStar(J),onSuccess:(J,ue)=>{f.invalidateQueries({queryKey:["emails","contract",e]}),f.invalidateQueries({queryKey:["email",ue]})}}),Q=G({mutationFn:({emailId:J,isRead:ue})=>Pe.markAsRead(J,ue),onSuccess:(J,ue)=>{f.invalidateQueries({queryKey:["emails","contract",e]}),f.invalidateQueries({queryKey:["email",ue.emailId]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]})}}),le=G({mutationFn:J=>Pe.unassignFromContract(J),onSuccess:()=>{f.invalidateQueries({queryKey:["emails","contract",e]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),o(null),Re.success("Zuordnung aufgehoben")},onError:J=>{Re.error(J.message||"Fehler beim Aufheben der Zuordnung")}}),de=G({mutationFn:J=>Pe.delete(J),onSuccess:(J,ue)=>{f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]}),Re.success("E-Mail in Papierkorb verschoben"),m(null),(l==null?void 0:l.id)===ue&&o(null)},onError:J=>{Re.error(J.message||"Fehler beim Löschen der E-Mail"),m(null)}}),Ke=()=>{n&&B.mutate(n)},Ve=J=>{const ue=new Date(J),ts=new Date;return ue.toDateString()===ts.toDateString()?ue.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}):ue.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})},st=(J,ue)=>{J.stopPropagation(),_.mutate(ue)},C=(J,ue)=>{J.stopPropagation(),Q.mutate({emailId:ue.id,isRead:!ue.isRead})},nt=J=>{J.isRead||Q.mutate({emailId:J.id,isRead:!0}),o(J)},es=()=>{h(K||null),d(!0)},Vt=()=>{h(null),d(!0)},ae=(J,ue)=>{J.stopPropagation(),(l==null?void 0:l.id)===ue&&o(null),le.mutate(ue)},Ge=(J,ue)=>{J.stopPropagation(),m(ue)},xt=J=>{J.stopPropagation(),x&&de.mutate(x)},Z=J=>{J.stopPropagation(),m(null)},Fe=J=>{i(J),o(null)},Xe=J=>{if(a==="SENT")try{const ue=JSON.parse(J.toAddresses);if(ue.length>0)return`An: ${ue[0]}${ue.length>1?` (+${ue.length-1})`:""}`}catch{return"An: (Unbekannt)"}return J.fromName||J.fromAddress};return!y&&v.length===0?s.jsx(X,{title:"E-Mails",children:s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[s.jsx(nn,{className:"w-10 h-10 mb-2 opacity-30"}),s.jsx("p",{className:"text-sm",children:"Keine E-Mail-Konten vorhanden"}),s.jsx("p",{className:"text-xs mt-1",children:"Erstellen Sie eine E-Mail-Adresse beim Kunden mit aktivierter Mailbox"})]})}):s.jsxs(X,{title:s.jsx("div",{className:"flex items-center gap-4",children:s.jsx("span",{children:"E-Mails"})}),actions:s.jsxs("div",{className:"flex items-center gap-2",children:[a!=="TRASH"&&s.jsxs(T,{variant:"secondary",size:"sm",onClick:Ke,disabled:B.isPending||!n,children:[s.jsx(Sr,{className:`w-4 h-4 mr-1 ${B.isPending?"animate-spin":""}`}),B.isPending?"Sync...":"Sync"]}),N&&s.jsxs(T,{size:"sm",onClick:Vt,children:[s.jsx(_e,{className:"w-4 h-4 mr-1"}),"Neue E-Mail"]})]}),children:[s.jsxs("div",{className:"flex items-center justify-between gap-4 pb-4 border-b border-gray-200 -mt-2",children:[v.length>1?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ur,{className:"w-4 h-4 text-gray-500"}),s.jsx("select",{value:n||"",onChange:J=>{r(Number(J.target.value)),o(null)},className:"px-2 py-1.5 border border-gray-300 rounded-lg bg-white focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm",children:v.map(J=>s.jsx("option",{value:J.id,children:J.email},J.id))})]}):s.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[s.jsx(Ur,{className:"w-4 h-4 text-gray-500"}),s.jsx("span",{children:N==null?void 0:N.email})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-gray-200 rounded-lg p-1",children:[s.jsxs("button",{onClick:()=>Fe("INBOX"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${a==="INBOX"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Ur,{className:"w-4 h-4"}),"Posteingang",q.inbox>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${q.inboxUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${q.inboxUnread} ungelesen / ${q.inbox} gesamt`,children:q.inboxUnread>0?`${q.inboxUnread}/${q.inbox}`:q.inbox})]}),s.jsxs("button",{onClick:()=>Fe("SENT"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${a==="SENT"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Fl,{className:"w-4 h-4"}),"Gesendet",q.sent>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${q.sentUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${q.sentUnread} ungelesen / ${q.sent} gesamt`,children:q.sentUnread>0?`${q.sentUnread}/${q.sent}`:q.sent})]}),b&&s.jsxs("button",{onClick:()=>Fe("TRASH"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${a==="TRASH"?"bg-white text-red-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Ne,{className:"w-4 h-4"}),"Papierkorb",z.trash>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${z.trashUnread>0?"bg-red-100 text-red-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${z.trashUnread} ungelesen / ${z.trash} gesamt`,children:z.trashUnread>0?`${z.trashUnread}/${z.trash}`:z.trash})]})]})]}),(a==="TRASH"?A:P)?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}):(a==="TRASH"?O.length===0:w.length===0)?s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[s.jsx(nn,{className:"w-10 h-10 mb-2 opacity-30"}),s.jsx("p",{className:"text-sm",children:a==="INBOX"?"Keine E-Mails zugeordnet":a==="SENT"?"Keine E-Mails über diesen Vertrag gesendet":"Papierkorb ist leer"}),a==="INBOX"&&s.jsx("p",{className:"text-xs mt-1",children:"E-Mails können im E-Mail-Tab des Kunden zugeordnet werden"})]}):s.jsxs("div",{className:"flex -mx-6 -mb-6",style:{minHeight:"400px"},children:[s.jsx("div",{className:"w-1/3 border-r border-gray-200 overflow-auto",children:a==="TRASH"?s.jsx(Ov,{emails:O,selectedEmailId:l==null?void 0:l.id,onSelectEmail:nt,onEmailRestored:J=>{(l==null?void 0:l.id)===J&&o(null),f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["folder-counts",n]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]})},onEmailDeleted:J=>{(l==null?void 0:l.id)===J&&o(null),f.invalidateQueries({queryKey:["emails","trash"]}),f.invalidateQueries({queryKey:["folder-counts",n]})},isLoading:A}):s.jsx("div",{className:"divide-y divide-gray-200",children:w.map(J=>s.jsxs("div",{onClick:()=>nt(J),className:["flex items-start gap-2 p-3 cursor-pointer transition-colors",(l==null?void 0:l.id)===J.id?"bg-blue-100":["hover:bg-gray-100",J.isRead?"bg-gray-50/50":"bg-white"].join(" ")].join(" "),style:{borderLeft:(l==null?void 0:l.id)===J.id?"4px solid #2563eb":"4px solid transparent"},children:[s.jsx("button",{onClick:ue=>C(ue,J),className:`
|
||
flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200
|
||
${J.isRead?"text-gray-400":"text-blue-600"}
|
||
`,title:J.isRead?"Als ungelesen markieren":"Als gelesen markieren",children:J.isRead?s.jsx(Pv,{className:"w-4 h-4"}):s.jsx(nn,{className:"w-4 h-4"})}),s.jsx("button",{onClick:ue=>st(ue,J.id),className:`
|
||
flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200
|
||
${J.isStarred?"text-yellow-500":"text-gray-400"}
|
||
`,title:J.isStarred?"Stern entfernen":"Als wichtig markieren",children:s.jsx(ph,{className:`w-4 h-4 ${J.isStarred?"fill-current":""}`})}),p("emails:delete")&&s.jsx("button",{onClick:ue=>Ge(ue,J.id),className:"flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-red-100 text-gray-400 hover:text-red-600",title:"E-Mail löschen",children:s.jsx(Ne,{className:"w-4 h-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[s.jsx("span",{className:`text-sm truncate ${J.isRead?"text-gray-700":"font-semibold text-gray-900"}`,children:Xe(J)}),s.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:Ve(J.receivedAt)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-sm truncate ${J.isRead?"text-gray-600":"font-medium text-gray-900"}`,children:J.subject||"(Kein Betreff)"}),J.hasAttachments&&s.jsx(Rc,{className:"w-3 h-3 text-gray-400 flex-shrink-0"})]}),J.contract&&s.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[s.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800",children:J.contract.contractNumber}),(a==="INBOX"||a==="SENT"&&!J.isAutoAssigned)&&s.jsx("button",{onClick:ue=>ae(ue,J.id),className:"p-0.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded",title:"Zuordnung aufheben",disabled:le.isPending,children:s.jsx(qt,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(Ft,{className:"w-4 h-4 text-gray-400 flex-shrink-0 mt-2"})]},J.id))})}),s.jsx("div",{className:"flex-1 overflow-auto",children:K&&l?s.jsx(Rv,{email:K,onReply:es,onAssignContract:()=>{},onDeleted:()=>{o(null),f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]})},isSentFolder:a==="SENT",isContractView:a!=="TRASH",isTrashView:a==="TRASH",onRestored:()=>{o(null),f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]})},accountId:K==null?void 0:K.stressfreiEmailId}):s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-500",children:[s.jsx(nn,{className:"w-12 h-12 mb-2 opacity-30"}),s.jsx("p",{children:"Wählen Sie eine E-Mail aus"})]})})]}),x&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:"Die E-Mail wird in den Papierkorb verschoben."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:Z,disabled:de.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:xt,disabled:de.isPending,children:de.isPending?"Löschen...":"Löschen"})]})]})}),N&&s.jsx(Lv,{isOpen:c,onClose:()=>{d(!1),h(null)},account:N,replyTo:u||void 0,contractId:e,onSuccess:()=>{f.invalidateQueries({queryKey:["emails","contract",e,"SENT"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),a==="SENT"&&I()}})]})}function uk({tabs:e,defaultTab:t}){var a,i;const[n,r]=j.useState(t||((a=e[0])==null?void 0:a.id));return s.jsxs("div",{children:[s.jsx("div",{className:"border-b border-gray-200",children:s.jsx("nav",{className:"flex -mb-px space-x-8",children:e.map(l=>s.jsx("button",{onClick:()=>r(l.id),className:`py-4 px-1 border-b-2 font-medium text-sm whitespace-nowrap ${n===l.id?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"}`,children:l.label},l.id))})}),s.jsx("div",{className:"mt-4",children:(i=e.find(l=>l.id===n))==null?void 0:i.content})]})}function Dt({onUpload:e,existingFile:t,accept:n=".pdf,.jpg,.jpeg,.png",label:r="Dokument hochladen",disabled:a=!1}){const i=j.useRef(null),[l,o]=j.useState(!1),[c,d]=j.useState(!1),u=async p=>{if(p){o(!0);try{await e(p)}catch(b){console.error("Upload failed:",b),alert("Upload fehlgeschlagen")}finally{o(!1)}}},h=p=>{var g;const b=(g=p.target.files)==null?void 0:g[0];b&&u(b)},x=p=>{var g;p.preventDefault(),d(!1);const b=(g=p.dataTransfer.files)==null?void 0:g[0];b&&u(b)},m=p=>{p.preventDefault(),d(!0)},f=()=>{d(!1)};return s.jsxs("div",{className:"space-y-2",children:[t?!a&&s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>{var p;return(p=i.current)==null?void 0:p.click()},disabled:l,children:l?"Wird hochgeladen...":"Ersetzen"}):s.jsx("div",{className:`border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors ${c?"border-blue-500 bg-blue-50":"border-gray-300 hover:border-gray-400"} ${a?"opacity-50 cursor-not-allowed":""}`,onClick:()=>{var p;return!a&&((p=i.current)==null?void 0:p.click())},onDrop:a?void 0:x,onDragOver:a?void 0:m,onDragLeave:a?void 0:f,children:l?s.jsxs("div",{className:"text-gray-500",children:[s.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-blue-500 border-t-transparent rounded-full mx-auto mb-2"}),"Wird hochgeladen..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Hu,{className:"w-6 h-6 text-gray-400 mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-gray-600",children:r}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"PDF, JPG oder PNG (max. 10MB)"})]})}),s.jsx("input",{ref:i,type:"file",accept:n,onChange:h,className:"hidden",disabled:a||l})]})}function oe({value:e,className:t="",size:n="sm",title:r="In Zwischenablage kopieren"}){const[a,i]=j.useState(!1),l=async c=>{c.preventDefault(),c.stopPropagation();try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)}catch(d){console.error("Failed to copy:",d)}},o=n==="sm"?"w-3.5 h-3.5":"w-4 h-4";return s.jsx("button",{type:"button",onClick:l,className:`inline-flex items-center justify-center p-1 rounded transition-colors ${a?"text-green-600 bg-green-50":"text-gray-400 hover:text-blue-600 hover:bg-blue-50"} ${t}`,title:a?"Kopiert!":r,children:a?s.jsx(xr,{className:o}):s.jsx(oh,{className:o})})}function Wu({values:e,separator:t=`
|
||
`,children:n,className:r=""}){const a=e.filter(i=>i!=null&&i!=="").map(String).join(t);return a?s.jsxs("div",{className:`relative group ${r}`,children:[n,s.jsx(oe,{value:a,className:"absolute top-0 right-0 opacity-60 group-hover:opacity-100",title:"Alles kopieren"})]}):s.jsx(s.Fragment,{children:n})}function mk(){var B,_;const{id:e}=Nc(),t=Yt(),n=ge(),{hasPermission:r}=We(),[a]=Sc(),i=parseInt(e),l=a.get("tab")||"addresses",[o,c]=j.useState(!1),[d,u]=j.useState(!1),[h,x]=j.useState(!1),[m,f]=j.useState(!1),[p,b]=j.useState(!1),[g,y]=j.useState(!1),[v,N]=j.useState(null),[E,P]=j.useState(null),[I,w]=j.useState(null),[S,A]=j.useState(null),[O,R]=j.useState(null),{data:q,isLoading:D}=fe({queryKey:["customer",e],queryFn:()=>At.getById(i)}),z=G({mutationFn:()=>At.delete(i),onSuccess:()=>{t("/customers")}});if(D)return s.jsx("div",{className:"text-center py-8",children:"Laden..."});if(!(q!=null&&q.data))return s.jsx("div",{className:"text-center py-8 text-red-600",children:"Kunde nicht gefunden"});const k=q.data,K=[{id:"addresses",label:"Adressen",content:s.jsx(pk,{customerId:i,addresses:k.addresses||[],canEdit:r("customers:update"),onAdd:()=>c(!0),onEdit:Q=>w(Q)})},{id:"bankcards",label:"Bankkarten",content:s.jsx(xk,{customerId:i,bankCards:k.bankCards||[],canEdit:r("customers:update"),showInactive:g,onToggleInactive:()=>y(!g),onAdd:()=>u(!0),onEdit:Q=>N(Q)})},{id:"documents",label:"Ausweise",content:s.jsx(gk,{customerId:i,documents:k.identityDocuments||[],canEdit:r("customers:update"),showInactive:g,onToggleInactive:()=>y(!g),onAdd:()=>x(!0),onEdit:Q=>P(Q)})},{id:"meters",label:"Zähler",content:s.jsx(yk,{customerId:i,meters:k.meters||[],canEdit:r("customers:update"),showInactive:g,onToggleInactive:()=>y(!g),onAdd:()=>f(!0),onEdit:Q=>A(Q)})},{id:"stressfrei",label:"Stressfrei-Wechseln",content:s.jsx(Nk,{customerId:i,emails:k.stressfreiEmails||[],canEdit:r("customers:update"),showInactive:g,onToggleInactive:()=>y(!g),onAdd:()=>b(!0),onEdit:Q=>R(Q)})},{id:"emails",label:"E-Mail-Postfach",content:s.jsx(ck,{customerId:i})},{id:"contracts",label:"Verträge",content:s.jsx(vk,{customerId:i})},...r("customers:update")?[{id:"portal",label:"Portal",content:s.jsx(bk,{customerId:i,canEdit:r("customers:update")})}]:[]];return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold",children:k.type==="BUSINESS"&&k.companyName?k.companyName:`${k.firstName} ${k.lastName}`}),s.jsxs("p",{className:"text-gray-500 font-mono flex items-center gap-1",children:[k.customerNumber,s.jsx(oe,{value:k.customerNumber})]})]}),s.jsxs("div",{className:"flex gap-2",children:[r("customers:update")&&s.jsx(ke,{to:`/customers/${e}/edit`,children:s.jsxs(T,{variant:"secondary",children:[s.jsx(He,{className:"w-4 h-4 mr-2"}),"Bearbeiten"]})}),r("customers:delete")&&s.jsxs(T,{variant:"danger",onClick:()=>{confirm("Kunde wirklich löschen?")&&z.mutate()},children:[s.jsx(Ne,{className:"w-4 h-4 mr-2"}),"Löschen"]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6",children:[s.jsx(X,{title:"Stammdaten",className:"lg:col-span-2",children:s.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Typ"}),s.jsx("dd",{children:s.jsx(ve,{variant:k.type==="BUSINESS"?"info":"default",children:k.type==="BUSINESS"?"Geschäftskunde":"Privatkunde"})})]}),k.salutation&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Anrede"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[k.salutation,s.jsx(oe,{value:k.salutation})]})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vorname"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[k.firstName,s.jsx(oe,{value:k.firstName})]})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Nachname"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[k.lastName,s.jsx(oe,{value:k.lastName})]})]}),k.companyName&&s.jsxs("div",{className:"col-span-2",children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Firma"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[k.companyName,s.jsx(oe,{value:k.companyName})]})]}),k.foundingDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Gründungsdatum"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[new Date(k.foundingDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}),s.jsx(oe,{value:new Date(k.foundingDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]})]}),k.birthDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Geburtsdatum"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[new Date(k.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}),s.jsx(oe,{value:new Date(k.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]})]}),k.birthPlace&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Geburtsort"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[k.birthPlace,s.jsx(oe,{value:k.birthPlace})]})]})]})}),s.jsx(X,{title:"Kontakt",children:s.jsxs("dl",{className:"space-y-3",children:[k.email&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"E-Mail"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[s.jsx("a",{href:`mailto:${k.email}`,className:"text-blue-600 hover:underline",children:k.email}),s.jsx(oe,{value:k.email})]})]}),k.phone&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Telefon"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[s.jsx("a",{href:`tel:${k.phone}`,className:"text-blue-600 hover:underline",children:k.phone}),s.jsx(oe,{value:k.phone})]})]}),k.mobile&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Mobil"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[s.jsx("a",{href:`tel:${k.mobile}`,className:"text-blue-600 hover:underline",children:k.mobile}),s.jsx(oe,{value:k.mobile})]})]})]})})]}),k.type==="BUSINESS"&&s.jsx(hk,{customer:k,canEdit:r("customers:update"),onUpdate:()=>n.invalidateQueries({queryKey:["customer",e]})}),s.jsx(fk,{customer:k,canEdit:r("customers:update"),onUpdate:()=>n.invalidateQueries({queryKey:["customer",e]})}),k.notes&&s.jsx(X,{title:"Notizen",className:"mb-6",children:s.jsx("p",{className:"whitespace-pre-wrap",children:k.notes})}),s.jsx(X,{children:s.jsx(uk,{tabs:K,defaultTab:l})}),s.jsx(gx,{isOpen:o,onClose:()=>c(!1),customerId:i}),s.jsx(gx,{isOpen:!!I,onClose:()=>w(null),customerId:i,address:I}),s.jsx(yx,{isOpen:d,onClose:()=>u(!1),customerId:i}),s.jsx(yx,{isOpen:!!v,onClose:()=>N(null),customerId:i,bankCard:v}),s.jsx(vx,{isOpen:h,onClose:()=>x(!1),customerId:i}),s.jsx(vx,{isOpen:!!E,onClose:()=>P(null),customerId:i,document:E}),s.jsx(jx,{isOpen:m,onClose:()=>f(!1),customerId:i}),s.jsx(jx,{isOpen:!!S,onClose:()=>A(null),customerId:i,meter:S}),s.jsx(Nx,{isOpen:p,onClose:()=>b(!1),customerId:i,customerEmail:(B=q==null?void 0:q.data)==null?void 0:B.email}),s.jsx(Nx,{isOpen:!!O,onClose:()=>R(null),customerId:i,email:O,customerEmail:(_=q==null?void 0:q.data)==null?void 0:_.email})]})}function hk({customer:e,canEdit:t,onUpdate:n}){const r=async c=>{try{await ut.uploadBusinessRegistration(e.id,c),n()}catch(d){console.error("Upload fehlgeschlagen:",d),alert("Upload fehlgeschlagen")}},a=async()=>{if(confirm("Gewerbeanmeldung wirklich löschen?"))try{await ut.deleteBusinessRegistration(e.id),n()}catch(c){console.error("Löschen fehlgeschlagen:",c),alert("Löschen fehlgeschlagen")}},i=async c=>{try{await ut.uploadCommercialRegister(e.id,c),n()}catch(d){console.error("Upload fehlgeschlagen:",d),alert("Upload fehlgeschlagen")}},l=async()=>{if(confirm("Handelsregisterauszug wirklich löschen?"))try{await ut.deleteCommercialRegister(e.id),n()}catch(c){console.error("Löschen fehlgeschlagen:",c),alert("Löschen fehlgeschlagen")}};return!(e.taxNumber||e.commercialRegisterNumber||e.businessRegistrationPath||e.commercialRegisterPath)&&!t?null:s.jsxs(X,{title:"Geschäftsdaten",className:"mb-6",children:[s.jsxs("dl",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.taxNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Steuernummer"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[e.taxNumber,s.jsx(oe,{value:e.taxNumber})]})]}),e.commercialRegisterNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Handelsregisternummer"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[e.commercialRegisterNumber,s.jsx(oe,{value:e.commercialRegisterNumber})]})]})]}),s.jsxs("div",{className:"mt-4 pt-4 border-t grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Gewerbeanmeldung"}),e.businessRegistrationPath?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("a",{href:`/api${e.businessRegistrationPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${e.businessRegistrationPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ps,{className:"w-4 h-4"}),"Download"]}),t&&s.jsxs(s.Fragment,{children:[s.jsx(Dt,{onUpload:r,existingFile:e.businessRegistrationPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:a,className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ne,{className:"w-4 h-4"}),"Löschen"]})]})]}):t?s.jsx(Dt,{onUpload:r,accept:".pdf",label:"PDF hochladen"}):s.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Handelsregisterauszug"}),e.commercialRegisterPath?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("a",{href:`/api${e.commercialRegisterPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${e.commercialRegisterPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ps,{className:"w-4 h-4"}),"Download"]}),t&&s.jsxs(s.Fragment,{children:[s.jsx(Dt,{onUpload:i,existingFile:e.commercialRegisterPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:l,className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ne,{className:"w-4 h-4"}),"Löschen"]})]})]}):t?s.jsx(Dt,{onUpload:i,accept:".pdf",label:"PDF hochladen"}):s.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]})]})]})}function fk({customer:e,canEdit:t,onUpdate:n}){const r=async i=>{try{await ut.uploadPrivacyPolicy(e.id,i),n()}catch(l){console.error("Upload fehlgeschlagen:",l),alert("Upload fehlgeschlagen")}},a=async()=>{if(confirm("Datenschutzerklärung wirklich löschen?"))try{await ut.deletePrivacyPolicy(e.id),n()}catch(i){console.error("Löschen fehlgeschlagen:",i),alert("Löschen fehlgeschlagen")}};return!e.privacyPolicyPath&&!t?null:s.jsx(X,{title:"Dokumente",className:"mb-6",children:s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Datenschutzerklärung"}),e.privacyPolicyPath?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("a",{href:`/api${e.privacyPolicyPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${e.privacyPolicyPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ps,{className:"w-4 h-4"}),"Download"]}),t&&s.jsxs(s.Fragment,{children:[s.jsx(Dt,{onUpload:r,existingFile:e.privacyPolicyPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:a,className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ne,{className:"w-4 h-4"}),"Löschen"]})]})]}):t?s.jsx(Dt,{onUpload:r,accept:".pdf",label:"PDF hochladen"}):s.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]})})}function pk({customerId:e,addresses:t,canEdit:n,onAdd:r,onEdit:a}){const i=ge(),l=G({mutationFn:Qu.delete,onSuccess:()=>i.invalidateQueries({queryKey:["customer",e.toString()]})});return s.jsxs("div",{children:[n&&s.jsx("div",{className:"mb-4",children:s.jsxs(T,{size:"sm",onClick:r,children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Adresse hinzufügen"]})}),t.length>0?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:t.map(o=>s.jsxs("div",{className:"border rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(K2,{className:"w-4 h-4 text-gray-400"}),s.jsx(ve,{variant:o.type==="BILLING"?"info":"default",children:o.type==="BILLING"?"Rechnung":"Liefer-/Meldeadresse"}),o.isDefault&&s.jsx(ve,{variant:"success",children:"Standard"})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>a(o),title:"Bearbeiten",children:s.jsx(He,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wirklich löschen?")&&l.mutate(o.id)},title:"Löschen",children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})]}),s.jsxs(Wu,{values:[`${o.street} ${o.houseNumber}`,`${o.postalCode} ${o.city}`,o.country],children:[s.jsxs("p",{children:[o.street," ",o.houseNumber]}),s.jsxs("p",{children:[o.postalCode," ",o.city]}),s.jsx("p",{className:"text-gray-500",children:o.country})]})]},o.id))}):s.jsx("p",{className:"text-gray-500",children:"Keine Adressen vorhanden."})]})}function xk({customerId:e,bankCards:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=ge(),c=G({mutationFn:({id:m,data:f})=>Yo.update(m,f),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=G({mutationFn:Yo.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),u=async(m,f)=>{try{await ut.uploadBankCardDocument(m,f),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(p){console.error("Upload fehlgeschlagen:",p),alert("Upload fehlgeschlagen")}},h=async m=>{if(confirm("Dokument wirklich löschen?"))try{await ut.deleteBankCardDocument(m),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(f){console.error("Löschen fehlgeschlagen:",f),alert("Löschen fehlgeschlagen")}},x=r?t:t.filter(m=>m.isActive);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&s.jsxs(T,{size:"sm",onClick:i,children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Bankkarte hinzufügen"]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:a,className:"rounded"}),"Inaktive anzeigen"]})]}),x.length>0?s.jsx("div",{className:"space-y-4",children:x.map(m=>s.jsxs("div",{className:`border rounded-lg p-4 ${m.isActive?"":"opacity-50 bg-gray-50"}`,children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(ch,{className:"w-4 h-4 text-gray-400"}),!m.isActive&&s.jsx(ve,{variant:"danger",children:"Inaktiv"}),m.expiryDate&&new Date(m.expiryDate)<new Date&&s.jsx(ve,{variant:"warning",children:"Abgelaufen"})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>l(m),title:"Bearbeiten",children:s.jsx(He,{className:"w-4 h-4"})}),m.isActive?s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte deaktivieren?")&&c.mutate({id:m.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(It,{className:"w-4 h-4"})}):s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte wieder aktivieren?")&&c.mutate({id:m.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(Ae,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte wirklich löschen?")&&d.mutate(m.id)},title:"Löschen",children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})]}),s.jsxs("p",{className:"font-medium flex items-center gap-1",children:[m.accountHolder,s.jsx(oe,{value:m.accountHolder})]}),s.jsxs("p",{className:"font-mono flex items-center gap-1",children:[m.iban,s.jsx(oe,{value:m.iban})]}),m.bic&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["BIC: ",m.bic,s.jsx(oe,{value:m.bic})]}),m.bankName&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:[m.bankName,s.jsx(oe,{value:m.bankName})]}),m.expiryDate&&s.jsxs("p",{className:"text-sm text-gray-500",children:["Gültig bis: ",new Date(m.expiryDate).toLocaleDateString("de-DE")]}),s.jsx("div",{className:"mt-3 pt-3 border-t",children:m.documentPath?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("a",{href:`/api${m.documentPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${m.documentPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ps,{className:"w-4 h-4"}),"Download"]}),n&&s.jsxs(s.Fragment,{children:[s.jsx(Dt,{onUpload:f=>u(m.id,f),existingFile:m.documentPath,accept:".pdf",label:"Ersetzen",disabled:!m.isActive}),s.jsxs("button",{onClick:()=>h(m.id),className:"text-red-600 hover:underline text-sm flex items-center gap-1",title:"Dokument löschen",children:[s.jsx(Ne,{className:"w-4 h-4"}),"Löschen"]})]})]}):n&&m.isActive&&s.jsx(Dt,{onUpload:f=>u(m.id,f),accept:".pdf",label:"PDF hochladen"})})]},m.id))}):s.jsx("p",{className:"text-gray-500",children:"Keine Bankkarten vorhanden."})]})}function gk({customerId:e,documents:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=ge(),c=G({mutationFn:({id:f,data:p})=>ec.update(f,p),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=G({mutationFn:ec.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),u=async(f,p)=>{try{await ut.uploadIdentityDocument(f,p),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(b){console.error("Upload fehlgeschlagen:",b),alert("Upload fehlgeschlagen")}},h=async f=>{if(confirm("Dokument wirklich löschen?"))try{await ut.deleteIdentityDocument(f),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(p){console.error("Löschen fehlgeschlagen:",p),alert("Löschen fehlgeschlagen")}},x=r?t:t.filter(f=>f.isActive),m={ID_CARD:"Personalausweis",PASSPORT:"Reisepass",DRIVERS_LICENSE:"Führerschein",OTHER:"Sonstiges"};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&s.jsxs(T,{size:"sm",onClick:i,children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Ausweis hinzufügen"]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:a,className:"rounded"}),"Inaktive anzeigen"]})]}),x.length>0?s.jsx("div",{className:"space-y-4",children:x.map(f=>s.jsxs("div",{className:`border rounded-lg p-4 ${f.isActive?"":"opacity-50 bg-gray-50"}`,children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(Be,{className:"w-4 h-4 text-gray-400"}),s.jsx(ve,{children:m[f.type]}),!f.isActive&&s.jsx(ve,{variant:"danger",children:"Inaktiv"}),f.expiryDate&&new Date(f.expiryDate)<new Date&&s.jsx(ve,{variant:"warning",children:"Abgelaufen"})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>l(f),title:"Bearbeiten",children:s.jsx(He,{className:"w-4 h-4"})}),f.isActive?s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis deaktivieren?")&&c.mutate({id:f.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(It,{className:"w-4 h-4"})}):s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis wieder aktivieren?")&&c.mutate({id:f.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(Ae,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis wirklich löschen?")&&d.mutate(f.id)},title:"Löschen",children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})]}),s.jsxs("p",{className:"font-mono flex items-center gap-1",children:[f.documentNumber,s.jsx(oe,{value:f.documentNumber})]}),f.issuingAuthority&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["Ausgestellt von: ",f.issuingAuthority,s.jsx(oe,{value:f.issuingAuthority})]}),f.expiryDate&&s.jsxs("p",{className:"text-sm text-gray-500",children:["Gültig bis: ",new Date(f.expiryDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})]}),f.type==="DRIVERS_LICENSE"&&f.licenseClasses&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["Klassen: ",f.licenseClasses,s.jsx(oe,{value:f.licenseClasses})]}),f.type==="DRIVERS_LICENSE"&&f.licenseIssueDate&&s.jsxs("p",{className:"text-sm text-gray-500",children:["Klasse B seit: ",new Date(f.licenseIssueDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})]}),s.jsx("div",{className:"mt-3 pt-3 border-t",children:f.documentPath?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("a",{href:`/api${f.documentPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${f.documentPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ps,{className:"w-4 h-4"}),"Download"]}),n&&s.jsxs(s.Fragment,{children:[s.jsx(Dt,{onUpload:p=>u(f.id,p),existingFile:f.documentPath,accept:".pdf",label:"Ersetzen",disabled:!f.isActive}),s.jsxs("button",{onClick:()=>h(f.id),className:"text-red-600 hover:underline text-sm flex items-center gap-1",title:"Dokument löschen",children:[s.jsx(Ne,{className:"w-4 h-4"}),"Löschen"]})]})]}):n&&f.isActive&&s.jsx(Dt,{onUpload:p=>u(f.id,p),accept:".pdf",label:"PDF hochladen"})})]},f.id))}):s.jsx("p",{className:"text-gray-500",children:"Keine Ausweise vorhanden."})]})}function yk({customerId:e,meters:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const[o,c]=j.useState(null),[d,u]=j.useState(null),[h,x]=j.useState(null),m=ge(),f=G({mutationFn:({id:v,data:N})=>ln.update(v,N),onSuccess:()=>m.invalidateQueries({queryKey:["customer",e.toString()]})}),p=G({mutationFn:ln.delete,onSuccess:()=>m.invalidateQueries({queryKey:["customer",e.toString()]})}),b=G({mutationFn:({meterId:v,readingId:N})=>ln.deleteReading(v,N),onSuccess:()=>m.invalidateQueries({queryKey:["customer",e.toString()]})}),g=r?t:t.filter(v=>v.isActive),y=v=>v?[...v].sort((N,E)=>new Date(E.readingDate).getTime()-new Date(N.readingDate).getTime()):[];return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&s.jsxs(T,{size:"sm",onClick:i,children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Zähler hinzufügen"]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:a,className:"rounded"}),"Inaktive anzeigen"]})]}),g.length>0?s.jsx("div",{className:"space-y-4",children:g.map(v=>{const N=y(v.readings),E=d===v.id;return s.jsxs("div",{className:`border rounded-lg p-4 ${v.isActive?"":"opacity-50 bg-gray-50"}`,children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(Dv,{className:"w-4 h-4 text-gray-400"}),s.jsx(ve,{variant:v.type==="ELECTRICITY"?"warning":"info",children:v.type==="ELECTRICITY"?"Strom":"Gas"}),!v.isActive&&s.jsx(ve,{variant:"danger",children:"Inaktiv"})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[v.isActive&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>c({meterId:v.id,meterType:v.type}),title:"Zählerstand hinzufügen",children:s.jsx(_e,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>l(v),title:"Bearbeiten",children:s.jsx(He,{className:"w-4 h-4"})}),v.isActive?s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler deaktivieren?")&&f.mutate({id:v.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(It,{className:"w-4 h-4"})}):s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler wieder aktivieren?")&&f.mutate({id:v.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(Ae,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler wirklich löschen? Alle Zählerstände werden ebenfalls gelöscht.")&&p.mutate(v.id)},title:"Löschen",children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})]}),s.jsxs("p",{className:"font-mono text-lg flex items-center gap-1",children:[v.meterNumber,s.jsx(oe,{value:v.meterNumber})]}),v.location&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["Standort: ",v.location,s.jsx(oe,{value:v.location})]}),N.length>0&&s.jsxs("div",{className:"mt-3 pt-3 border-t",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("p",{className:"text-sm font-medium",children:"Zählerstände:"}),N.length>3&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>u(E?null:v.id),children:E?"Weniger anzeigen":`Alle ${N.length} anzeigen`})]}),s.jsx("div",{className:"space-y-1",children:(E?N:N.slice(0,3)).map(P=>s.jsxs("div",{className:"flex justify-between items-center text-sm group",children:[s.jsxs("span",{className:"text-gray-500 flex items-center gap-1",children:[new Date(P.readingDate).toLocaleDateString("de-DE"),s.jsx(oe,{value:new Date(P.readingDate).toLocaleDateString("de-DE")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"font-mono flex items-center gap-1",children:[P.value.toLocaleString("de-DE")," ",P.unit,s.jsx(oe,{value:P.value.toString(),title:"Nur Wert kopieren"}),s.jsx(oe,{value:`${P.value.toLocaleString("de-DE")} ${P.unit}`,title:"Mit Einheit kopieren"})]}),n&&s.jsxs("div",{className:"opacity-0 group-hover:opacity-100 flex gap-1",children:[s.jsx("button",{onClick:()=>x({meterId:v.id,meterType:v.type,reading:P}),className:"text-gray-400 hover:text-blue-600",title:"Bearbeiten",children:s.jsx(He,{className:"w-3 h-3"})}),s.jsx("button",{onClick:()=>{confirm("Zählerstand wirklich löschen?")&&b.mutate({meterId:v.id,readingId:P.id})},className:"text-gray-400 hover:text-red-600",title:"Löschen",children:s.jsx(Ne,{className:"w-3 h-3"})})]})]})]},P.id))})]})]},v.id)})}):s.jsx("p",{className:"text-gray-500",children:"Keine Zähler vorhanden."}),o&&s.jsx(bx,{isOpen:!0,onClose:()=>c(null),meterId:o.meterId,meterType:o.meterType,customerId:e}),h&&s.jsx(bx,{isOpen:!0,onClose:()=>x(null),meterId:h.meterId,meterType:h.meterType,customerId:e,reading:h.reading})]})}function vk({customerId:e}){const{hasPermission:t}=We(),n=Yt(),r=ge(),[a,i]=j.useState(new Set),[l,o]=j.useState(!1),{data:c,isLoading:d}=fe({queryKey:["contract-tree",e],queryFn:()=>Oe.getTreeForCustomer(e)}),u=(c==null?void 0:c.data)||[],h=G({mutationFn:Oe.delete,onSuccess:()=>{r.invalidateQueries({queryKey:["customer",e.toString()]}),r.invalidateQueries({queryKey:["customers"]}),r.invalidateQueries({queryKey:["contracts"]}),r.invalidateQueries({queryKey:["contract-tree",e]})},onError:y=>{alert((y==null?void 0:y.message)||"Fehler beim Löschen des Vertrags")}}),x={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},m={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"},f=[{status:"DRAFT",label:"Entwurf",description:"Vertrag wird noch vorbereitet",color:"text-gray-600"},{status:"PENDING",label:"Ausstehend",description:"Wartet auf Aktivierung",color:"text-yellow-600"},{status:"ACTIVE",label:"Aktiv",description:"Vertrag läuft normal",color:"text-green-600"},{status:"EXPIRED",label:"Abgelaufen",description:"Laufzeit vorbei, läuft aber ohne Kündigung weiter",color:"text-orange-600"},{status:"CANCELLED",label:"Gekündigt",description:"Aktive Kündigung eingereicht, Vertrag endet",color:"text-red-600"},{status:"DEACTIVATED",label:"Deaktiviert",description:"Manuell beendet/archiviert",color:"text-gray-500"}],p=y=>{i(v=>{const N=new Set(v);return N.has(y)?N.delete(y):N.add(y),N})},b=(y,v)=>y.map(N=>s.jsx("div",{children:g(N,v)},N.contract.id)),g=(y,v=0)=>{var S,A,O,R,q,D,z;const{contract:N,predecessors:E,hasHistory:P}=y,I=a.has(N.id),w=v>0;return s.jsxs("div",{children:[s.jsxs("div",{className:`
|
||
border rounded-lg p-4 transition-colors
|
||
${w?"ml-6 border-l-4 border-l-gray-300 bg-gray-50":"hover:bg-gray-50"}
|
||
`,children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[!w&&P?s.jsx("button",{onClick:()=>p(N.id),className:"p-1 hover:bg-gray-200 rounded transition-colors",title:I?"Einklappen":"Vorgänger anzeigen",children:I?s.jsx(dn,{className:"w-4 h-4 text-gray-500"}):s.jsx(Ft,{className:"w-4 h-4 text-gray-500"})}):w?null:s.jsx("div",{className:"w-6"}),s.jsxs("span",{className:"font-mono flex items-center gap-1",children:[N.contractNumber,s.jsx(oe,{value:N.contractNumber})]}),s.jsx(ve,{children:x[N.type]||N.type}),s.jsx(ve,{variant:m[N.status]||"default",children:N.status}),v===0&&!w&&s.jsx("button",{onClick:k=>{k.stopPropagation(),o(!0)},className:"text-gray-400 hover:text-blue-600 transition-colors",title:"Status-Erklärung",children:s.jsx(Ml,{className:"w-4 h-4"})}),w&&s.jsx("span",{className:"text-xs text-gray-500 ml-2",children:"(Vorgänger)"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${N.id}`,{state:{from:"customer",customerId:e.toString()}}),title:"Ansehen",children:s.jsx(Ae,{className:"w-4 h-4"})}),t("contracts:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${N.id}/edit`),title:"Bearbeiten",children:s.jsx(He,{className:"w-4 h-4"})}),t("contracts:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertrag wirklich löschen?")&&h.mutate(N.id)},title:"Löschen",children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})]}),(N.providerName||((S=N.provider)==null?void 0:S.name))&&s.jsxs("p",{className:`flex items-center gap-1 ${w?"ml-6":""}`,children:[N.providerName||((A=N.provider)==null?void 0:A.name),(N.tariffName||((O=N.tariff)==null?void 0:O.name))&&` - ${N.tariffName||((R=N.tariff)==null?void 0:R.name)}`,s.jsx(oe,{value:(N.providerName||((q=N.provider)==null?void 0:q.name)||"")+(N.tariffName||(D=N.tariff)!=null&&D.name?` - ${N.tariffName||((z=N.tariff)==null?void 0:z.name)}`:"")})]}),N.startDate&&s.jsxs("p",{className:`text-sm text-gray-500 ${w?"ml-6":""}`,children:["Beginn: ",new Date(N.startDate).toLocaleDateString("de-DE"),N.endDate&&` | Ende: ${new Date(N.endDate).toLocaleDateString("de-DE")}`]})]}),(v===0&&I||v>0)&&E.length>0&&s.jsx("div",{className:"mt-2",children:b(E,v+1)})]},N.id)};return d?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}):s.jsxs("div",{children:[t("contracts:create")&&s.jsx("div",{className:"mb-4",children:s.jsx(ke,{to:`/contracts/new?customerId=${e}`,children:s.jsxs(T,{size:"sm",children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Vertrag anlegen"]})})}),u.length>0?s.jsx("div",{className:"space-y-4",children:u.map(y=>g(y,0))}):s.jsx("p",{className:"text-gray-500",children:"Keine Verträge vorhanden."}),l&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"fixed inset-0 bg-black/20",onClick:()=>o(!1)}),s.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl p-4 max-w-sm w-full mx-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:"Vertragsstatus-Übersicht"}),s.jsx("button",{onClick:()=>o(!1),className:"text-gray-400 hover:text-gray-600",children:s.jsx(qt,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"space-y-2",children:f.map(({status:y,label:v,description:N,color:E})=>s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:`font-medium text-sm min-w-[90px] ${E}`,children:v}),s.jsx("span",{className:"text-sm text-gray-600",children:N})]},y))})]})]})]})}function jk({customerId:e}){const[t,n]=j.useState(!1),[r,a]=j.useState(null),[i,l]=j.useState(!1),o=async()=>{var c;if(t){n(!1);return}l(!0);try{const d=await At.getPortalPassword(e);a(((c=d.data)==null?void 0:c.password)||null),n(!0)}catch(d){console.error("Fehler beim Laden des Passworts:",d),alert("Fehler beim Laden des Passworts")}finally{l(!1)}};return s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s.jsx("p",{className:"text-xs text-green-600",children:"Passwort ist gesetzt"}),s.jsx("button",{type:"button",onClick:o,className:"text-xs text-blue-600 hover:underline flex items-center gap-1",disabled:i,children:i?"Laden...":t?s.jsxs(s.Fragment,{children:[s.jsx(It,{className:"w-3 h-3"}),"Verbergen"]}):s.jsxs(s.Fragment,{children:[s.jsx(Ae,{className:"w-3 h-3"}),"Anzeigen"]})}),t&&r&&s.jsxs("span",{className:"text-xs font-mono bg-gray-100 px-2 py-1 rounded flex items-center gap-1",children:[r,s.jsx(oe,{value:r})]}),t&&!r&&s.jsx("span",{className:"text-xs text-gray-500",children:"(Passwort nicht verfügbar)"})]})}function bk({customerId:e,canEdit:t}){const n=ge(),[r,a]=j.useState(!1),[i,l]=j.useState(""),[o,c]=j.useState(""),[d,u]=j.useState([]),[h,x]=j.useState(!1),{data:m,isLoading:f}=fe({queryKey:["customer-portal",e],queryFn:()=>At.getPortalSettings(e)}),{data:p,isLoading:b}=fe({queryKey:["customer-representatives",e],queryFn:()=>At.getRepresentatives(e)}),g=G({mutationFn:w=>At.updatePortalSettings(e,w),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-portal",e]})}}),y=G({mutationFn:w=>At.setPortalPassword(e,w),onSuccess:()=>{l(""),n.invalidateQueries({queryKey:["customer-portal",e]}),alert("Passwort wurde gesetzt")},onError:w=>{alert(w.message)}}),v=G({mutationFn:w=>At.addRepresentative(e,w),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-representatives",e]}),c(""),u([])},onError:w=>{alert(w.message)}}),N=G({mutationFn:w=>At.removeRepresentative(e,w),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-representatives",e]})}}),E=async()=>{if(!(o.length<2)){x(!0);try{const w=await At.searchForRepresentative(e,o);u(w.data||[])}catch(w){console.error("Suche fehlgeschlagen:",w)}finally{x(!1)}}};if(f||b)return s.jsx("div",{className:"text-center py-4 text-gray-500",children:"Laden..."});const P=m==null?void 0:m.data,I=(p==null?void 0:p.data)||[];return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"border rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsx(uh,{className:"w-5 h-5 text-gray-400"}),s.jsx("h3",{className:"font-medium",children:"Portal-Zugang"})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("label",{className:"flex items-center gap-3",children:[s.jsx("input",{type:"checkbox",checked:(P==null?void 0:P.portalEnabled)||!1,onChange:w=>g.mutate({portalEnabled:w.target.checked}),className:"rounded w-5 h-5",disabled:!t}),s.jsx("span",{children:"Portal aktiviert"}),(P==null?void 0:P.portalEnabled)&&s.jsx(ve,{variant:"success",children:"Aktiv"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Portal E-Mail"}),s.jsx("div",{className:"flex gap-2",children:s.jsx(H,{value:(P==null?void 0:P.portalEmail)||"",onChange:w=>g.mutate({portalEmail:w.target.value||null}),placeholder:"portal@example.com",disabled:!t||!(P!=null&&P.portalEnabled),className:"flex-1"})}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Diese E-Mail wird für den Login ins Kundenportal verwendet."})]}),(P==null?void 0:P.portalEnabled)&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:P!=null&&P.hasPassword?"Neues Passwort setzen":"Passwort setzen"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(H,{type:r?"text":"password",value:i,onChange:w=>l(w.target.value),placeholder:"Mindestens 6 Zeichen",disabled:!t}),s.jsx("button",{type:"button",onClick:()=>a(!r),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400",children:r?s.jsx(It,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]}),s.jsx(T,{onClick:()=>y.mutate(i),disabled:!t||i.length<6||y.isPending,children:y.isPending?"Speichern...":"Setzen"})]}),(P==null?void 0:P.hasPassword)&&s.jsx(jk,{customerId:e})]}),(P==null?void 0:P.portalLastLogin)&&s.jsxs("p",{className:"text-sm text-gray-500",children:["Letzte Anmeldung: ",new Date(P.portalLastLogin).toLocaleString("de-DE")]})]})]}),s.jsxs("div",{className:"border rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsx(G2,{className:"w-5 h-5 text-gray-400"}),s.jsx("h3",{className:"font-medium",children:"Vertreter (können Verträge einsehen)"})]}),s.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Hier können Sie anderen Kunden erlauben, die Verträge dieses Kunden einzusehen. Beispiel: Der Sohn kann die Verträge seiner Mutter einsehen."}),t&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx(H,{value:o,onChange:w=>c(w.target.value),placeholder:"Kunden suchen (Name, Kundennummer)...",onKeyDown:w=>w.key==="Enter"&&E(),className:"flex-1"}),s.jsx(T,{variant:"secondary",onClick:E,disabled:o.length<2||h,children:s.jsx(Tl,{className:"w-4 h-4"})})]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Nur Kunden mit aktiviertem Portal können als Vertreter hinzugefügt werden."}),d.length>0&&s.jsx("div",{className:"mt-2 border rounded-lg divide-y",children:d.map(w=>s.jsxs("div",{className:"flex items-center justify-between p-3 hover:bg-gray-50",children:[s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:w.companyName||`${w.firstName} ${w.lastName}`}),s.jsx("p",{className:"text-sm text-gray-500",children:w.customerNumber})]}),s.jsxs(T,{size:"sm",onClick:()=>v.mutate(w.id),disabled:v.isPending,children:[s.jsx(_e,{className:"w-4 h-4 mr-1"}),"Hinzufügen"]})]},w.id))})]}),I.length>0?s.jsx("div",{className:"space-y-2",children:I.map(w=>{var S,A,O,R;return s.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-lg",children:[s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:((S=w.representative)==null?void 0:S.companyName)||`${(A=w.representative)==null?void 0:A.firstName} ${(O=w.representative)==null?void 0:O.lastName}`}),s.jsx("p",{className:"text-sm text-gray-500",children:(R=w.representative)==null?void 0:R.customerNumber})]}),t&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertreter wirklich entfernen?")&&N.mutate(w.representativeId)},children:s.jsx(qt,{className:"w-4 h-4 text-red-500"})})]},w.id)})}):s.jsx("p",{className:"text-gray-500 text-sm",children:"Keine Vertreter konfiguriert."})]})]})}function gx({isOpen:e,onClose:t,customerId:n,address:r}){const a=ge(),i=!!r,l=()=>({type:(r==null?void 0:r.type)||"DELIVERY_RESIDENCE",street:(r==null?void 0:r.street)||"",houseNumber:(r==null?void 0:r.houseNumber)||"",postalCode:(r==null?void 0:r.postalCode)||"",city:(r==null?void 0:r.city)||"",country:(r==null?void 0:r.country)||"Deutschland",isDefault:(r==null?void 0:r.isDefault)||!1}),[o,c]=j.useState(l),d=G({mutationFn:m=>Qu.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({type:"DELIVERY_RESIDENCE",street:"",houseNumber:"",postalCode:"",city:"",country:"Deutschland",isDefault:!1})}}),u=G({mutationFn:m=>Qu.update(r.id,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),h=m=>{m.preventDefault(),i?u.mutate(o):d.mutate(o)},x=d.isPending||u.isPending;return i&&o.street!==r.street&&c(l()),s.jsx(qe,{isOpen:e,onClose:t,title:i?"Adresse bearbeiten":"Adresse hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(Ie,{label:"Adresstyp",value:o.type,onChange:m=>c({...o,type:m.target.value}),options:[{value:"DELIVERY_RESIDENCE",label:"Liefer-/Meldeadresse"},{value:"BILLING",label:"Rechnungsadresse"}]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsx("div",{className:"col-span-2",children:s.jsx(H,{label:"Straße",value:o.street,onChange:m=>c({...o,street:m.target.value}),required:!0})}),s.jsx(H,{label:"Hausnr.",value:o.houseNumber,onChange:m=>c({...o,houseNumber:m.target.value}),required:!0})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsx(H,{label:"PLZ",value:o.postalCode,onChange:m=>c({...o,postalCode:m.target.value}),required:!0}),s.jsx("div",{className:"col-span-2",children:s.jsx(H,{label:"Ort",value:o.city,onChange:m=>c({...o,city:m.target.value}),required:!0})})]}),s.jsx(H,{label:"Land",value:o.country,onChange:m=>c({...o,country:m.target.value})}),s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:o.isDefault,onChange:m=>c({...o,isDefault:m.target.checked}),className:"rounded"}),"Als Standard setzen"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:x,children:x?"Speichern...":"Speichern"})]})]})})}function yx({isOpen:e,onClose:t,customerId:n,bankCard:r}){const a=ge(),i=!!r,l=()=>({accountHolder:(r==null?void 0:r.accountHolder)||"",iban:(r==null?void 0:r.iban)||"",bic:(r==null?void 0:r.bic)||"",bankName:(r==null?void 0:r.bankName)||"",expiryDate:r!=null&&r.expiryDate?new Date(r.expiryDate).toISOString().split("T")[0]:"",isActive:(r==null?void 0:r.isActive)??!0}),[o,c]=j.useState(l);j.useState(()=>{c(l())});const d=G({mutationFn:m=>Yo.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({accountHolder:"",iban:"",bic:"",bankName:"",expiryDate:"",isActive:!0})}}),u=G({mutationFn:m=>Yo.update(r.id,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),h=m=>{m.preventDefault();const f={...o,expiryDate:o.expiryDate?new Date(o.expiryDate):void 0};i?u.mutate(f):d.mutate(f)},x=d.isPending||u.isPending;return i&&o.iban!==r.iban&&c(l()),s.jsx(qe,{isOpen:e,onClose:t,title:i?"Bankkarte bearbeiten":"Bankkarte hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(H,{label:"Kontoinhaber",value:o.accountHolder,onChange:m=>c({...o,accountHolder:m.target.value}),required:!0}),s.jsx(H,{label:"IBAN",value:o.iban,onChange:m=>c({...o,iban:m.target.value}),required:!0}),s.jsx(H,{label:"BIC",value:o.bic,onChange:m=>c({...o,bic:m.target.value})}),s.jsx(H,{label:"Bank",value:o.bankName,onChange:m=>c({...o,bankName:m.target.value})}),s.jsx(H,{label:"Ablaufdatum",type:"date",value:o.expiryDate,onChange:m=>c({...o,expiryDate:m.target.value}),onClear:()=>c({...o,expiryDate:""})}),i&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:o.isActive,onChange:m=>c({...o,isActive:m.target.checked}),className:"rounded"}),"Aktiv"]}),!i&&s.jsx("p",{className:"text-sm text-gray-500 bg-gray-50 p-3 rounded",children:"Dokument-Upload ist nach dem Speichern in der Übersicht möglich."}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:x,children:x?"Speichern...":"Speichern"})]})]})})}function vx({isOpen:e,onClose:t,customerId:n,document:r}){const a=ge(),i=!!r,l=()=>({type:(r==null?void 0:r.type)||"ID_CARD",documentNumber:(r==null?void 0:r.documentNumber)||"",issuingAuthority:(r==null?void 0:r.issuingAuthority)||"",issueDate:r!=null&&r.issueDate?new Date(r.issueDate).toISOString().split("T")[0]:"",expiryDate:r!=null&&r.expiryDate?new Date(r.expiryDate).toISOString().split("T")[0]:"",isActive:(r==null?void 0:r.isActive)??!0,licenseClasses:(r==null?void 0:r.licenseClasses)||"",licenseIssueDate:r!=null&&r.licenseIssueDate?new Date(r.licenseIssueDate).toISOString().split("T")[0]:""}),[o,c]=j.useState(l),d=G({mutationFn:m=>ec.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({type:"ID_CARD",documentNumber:"",issuingAuthority:"",issueDate:"",expiryDate:"",isActive:!0,licenseClasses:"",licenseIssueDate:""})}}),u=G({mutationFn:m=>ec.update(r.id,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),h=m=>{m.preventDefault();const f={...o,issueDate:o.issueDate?new Date(o.issueDate):void 0,expiryDate:o.expiryDate?new Date(o.expiryDate):void 0};o.type==="DRIVERS_LICENSE"?(f.licenseClasses=o.licenseClasses||void 0,f.licenseIssueDate=o.licenseIssueDate?new Date(o.licenseIssueDate):void 0):(delete f.licenseClasses,delete f.licenseIssueDate),i?u.mutate(f):d.mutate(f)},x=d.isPending||u.isPending;return i&&o.documentNumber!==r.documentNumber&&c(l()),s.jsx(qe,{isOpen:e,onClose:t,title:i?"Ausweis bearbeiten":"Ausweis hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(Ie,{label:"Ausweistyp",value:o.type,onChange:m=>c({...o,type:m.target.value}),options:[{value:"ID_CARD",label:"Personalausweis"},{value:"PASSPORT",label:"Reisepass"},{value:"DRIVERS_LICENSE",label:"Führerschein"},{value:"OTHER",label:"Sonstiges"}]}),s.jsx(H,{label:"Ausweisnummer",value:o.documentNumber,onChange:m=>c({...o,documentNumber:m.target.value}),required:!0}),s.jsx(H,{label:"Ausstellende Behörde",value:o.issuingAuthority,onChange:m=>c({...o,issuingAuthority:m.target.value})}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(H,{label:"Ausstellungsdatum",type:"date",value:o.issueDate,onChange:m=>c({...o,issueDate:m.target.value}),onClear:()=>c({...o,issueDate:""})}),s.jsx(H,{label:"Ablaufdatum",type:"date",value:o.expiryDate,onChange:m=>c({...o,expiryDate:m.target.value}),onClear:()=>c({...o,expiryDate:""})})]}),o.type==="DRIVERS_LICENSE"&&s.jsxs(s.Fragment,{children:[s.jsx(H,{label:"Führerscheinklassen",value:o.licenseClasses,onChange:m=>c({...o,licenseClasses:m.target.value}),placeholder:"z.B. B, BE, AM, L"}),s.jsx(H,{label:"Erwerb Klasse B (Pkw)",type:"date",value:o.licenseIssueDate,onChange:m=>c({...o,licenseIssueDate:m.target.value}),onClear:()=>c({...o,licenseIssueDate:""})})]}),i&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:o.isActive,onChange:m=>c({...o,isActive:m.target.checked}),className:"rounded"}),"Aktiv"]}),!i&&s.jsx("p",{className:"text-sm text-gray-500 bg-gray-50 p-3 rounded",children:"Dokument-Upload ist nach dem Speichern in der Übersicht möglich."}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:x,children:x?"Speichern...":"Speichern"})]})]})})}function jx({isOpen:e,onClose:t,customerId:n,meter:r}){const a=ge(),i=!!r,l=()=>({meterNumber:(r==null?void 0:r.meterNumber)||"",type:(r==null?void 0:r.type)||"ELECTRICITY",location:(r==null?void 0:r.location)||"",isActive:(r==null?void 0:r.isActive)??!0}),[o,c]=j.useState(l),d=G({mutationFn:m=>ln.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({meterNumber:"",type:"ELECTRICITY",location:"",isActive:!0})}}),u=G({mutationFn:m=>ln.update(r.id,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),h=m=>{m.preventDefault(),i?u.mutate(o):d.mutate(o)},x=d.isPending||u.isPending;return i&&o.meterNumber!==r.meterNumber&&c(l()),s.jsx(qe,{isOpen:e,onClose:t,title:i?"Zähler bearbeiten":"Zähler hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(H,{label:"Zählernummer",value:o.meterNumber,onChange:m=>c({...o,meterNumber:m.target.value}),required:!0}),s.jsx(Ie,{label:"Zählertyp",value:o.type,onChange:m=>c({...o,type:m.target.value}),options:[{value:"ELECTRICITY",label:"Strom"},{value:"GAS",label:"Gas"}]}),s.jsx(H,{label:"Standort",value:o.location,onChange:m=>c({...o,location:m.target.value}),placeholder:"z.B. Keller, Wohnung"}),i&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:o.isActive,onChange:m=>c({...o,isActive:m.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:x,children:x?"Speichern...":"Speichern"})]})]})})}function bx({isOpen:e,onClose:t,meterId:n,meterType:r,customerId:a,reading:i}){const l=ge(),o=!!i,c=r==="ELECTRICITY"?"kWh":"m³",d=()=>{var b;return{readingDate:i!=null&&i.readingDate?new Date(i.readingDate).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],value:((b=i==null?void 0:i.value)==null?void 0:b.toString())||"",notes:(i==null?void 0:i.notes)||""}},[u,h]=j.useState(d),x=G({mutationFn:b=>ln.addReading(n,b),onSuccess:()=>{l.invalidateQueries({queryKey:["customer",a.toString()]}),t()}}),m=G({mutationFn:b=>ln.updateReading(n,i.id,b),onSuccess:()=>{l.invalidateQueries({queryKey:["customer",a.toString()]}),t()}}),f=b=>{b.preventDefault();const g={readingDate:new Date(u.readingDate),value:parseFloat(u.value),unit:c,notes:u.notes||void 0};o?m.mutate(g):x.mutate(g)},p=x.isPending||m.isPending;return o&&u.value!==i.value.toString()&&h(d()),s.jsx(qe,{isOpen:e,onClose:t,title:o?"Zählerstand bearbeiten":"Zählerstand erfassen",children:s.jsxs("form",{onSubmit:f,className:"space-y-4",children:[s.jsx(H,{label:"Ablesedatum",type:"date",value:u.readingDate,onChange:b=>h({...u,readingDate:b.target.value}),required:!0}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsx("div",{className:"col-span-2",children:s.jsx(H,{label:"Zählerstand",type:"number",step:"0.01",value:u.value,onChange:b=>h({...u,value:b.target.value}),required:!0})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Einheit"}),s.jsx("div",{className:"h-10 flex items-center px-3 bg-gray-100 border border-gray-300 rounded-md text-gray-700",children:c})]})]}),s.jsx(H,{label:"Notizen",value:u.notes,onChange:b=>h({...u,notes:b.target.value}),placeholder:"Optionale Notizen..."}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}const gd="@stressfrei-wechseln.de";function Nk({customerId:e,emails:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=ge(),c=G({mutationFn:({id:h,data:x})=>xs.update(h,x),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=G({mutationFn:xs.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),u=r?t:t.filter(h=>h.isActive);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&s.jsxs(T,{size:"sm",onClick:i,children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Adresse hinzufügen"]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:a,className:"rounded"}),"Inaktive anzeigen"]})]}),s.jsxs("p",{className:"text-sm text-gray-500 mb-4 bg-blue-50 border border-blue-200 rounded-lg p-3",children:[s.jsx("strong",{children:"Hinweis:"})," Hier werden E-Mail-Weiterleitungsadressen verwaltet, die für die Registrierung bei Anbietern verwendet werden. E-Mails an diese Adressen werden sowohl an den Kunden als auch an Sie weitergeleitet."]}),u.length>0?s.jsx("div",{className:"space-y-3",children:u.map(h=>s.jsx("div",{className:`border rounded-lg p-4 ${h.isActive?"":"opacity-50 bg-gray-50"}`,children:s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(nn,{className:"w-4 h-4 text-gray-400"}),s.jsx("span",{className:"font-mono text-sm",children:h.email}),s.jsx(oe,{value:h.email}),!h.isActive&&s.jsx(ve,{variant:"danger",children:"Inaktiv"})]}),h.notes&&s.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-gray-500",children:[s.jsx(Be,{className:"w-4 h-4 flex-shrink-0"}),s.jsx("span",{children:h.notes})]})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>l(h),title:"Bearbeiten",children:s.jsx(He,{className:"w-4 h-4"})}),h.isActive?s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse deaktivieren?")&&c.mutate({id:h.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(It,{className:"w-4 h-4"})}):s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wieder aktivieren?")&&c.mutate({id:h.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(Ae,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wirklich löschen?")&&d.mutate(h.id)},title:"Löschen",children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})]})},h.id))}):s.jsx("p",{className:"text-gray-500",children:"Keine Stressfrei-Wechseln Adressen vorhanden."})]})}function wk({credentials:e,onHide:t,onResetPassword:n,isResettingPassword:r}){const[a,i]=j.useState(null),l=async(u,h)=>{try{await navigator.clipboard.writeText(u),i(h),setTimeout(()=>i(null),2e3)}catch{const x=document.createElement("textarea");x.value=u,document.body.appendChild(x),x.select(),document.execCommand("copy"),document.body.removeChild(x),i(h),setTimeout(()=>i(null),2e3)}},o=({text:u,fieldName:h})=>s.jsx("button",{type:"button",onClick:()=>l(u,h),className:"p-1.5 text-gray-400 hover:text-blue-600 hover:bg-blue-50 rounded transition-colors",title:"In Zwischenablage kopieren",children:a===h?s.jsx(xr,{className:"w-4 h-4 text-green-600"}):s.jsx(oh,{className:"w-4 h-4"})}),c=e.imap?`${e.imap.server}:${e.imap.port}`:"",d=e.smtp?`${e.smtp.server}:${e.smtp.port}`:"";return s.jsxs("div",{className:"bg-gray-50 border border-gray-200 rounded-lg p-4 space-y-3",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide",children:"Zugangsdaten"}),s.jsx("button",{type:"button",onClick:t,className:"text-gray-400 hover:text-gray-600 p-1 hover:bg-gray-200 rounded",title:"Zugangsdaten ausblenden",children:s.jsx(It,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"bg-white rounded-lg p-3 border border-gray-100",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Benutzername"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-sm text-gray-900 font-mono flex-1 break-all",children:e.email}),s.jsx(o,{text:e.email,fieldName:"email"})]})]}),s.jsxs("div",{className:"bg-white rounded-lg p-3 border border-gray-100",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Passwort"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-sm text-gray-900 font-mono flex-1 break-all",children:e.password}),s.jsx(o,{text:e.password,fieldName:"password"})]}),s.jsx("button",{type:"button",onClick:n,disabled:r,className:"mt-2 text-xs text-blue-600 hover:text-blue-800 disabled:opacity-50",children:r?"Generiere...":"Neu generieren"})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.imap&&s.jsxs("div",{className:"bg-white rounded-lg p-3 border border-gray-100",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"IMAP (Empfang)"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-sm text-gray-900 font-mono flex-1",children:c}),s.jsx(o,{text:c,fieldName:"imap"})]}),s.jsx("span",{className:"text-xs text-gray-400 mt-1 block",children:e.imap.encryption})]}),e.smtp&&s.jsxs("div",{className:"bg-white rounded-lg p-3 border border-gray-100",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"SMTP (Versand)"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-sm text-gray-900 font-mono flex-1",children:d}),s.jsx(o,{text:d,fieldName:"smtp"})]}),s.jsx("span",{className:"text-xs text-gray-400 mt-1 block",children:e.smtp.encryption})]})]})]})}function Nx({isOpen:e,onClose:t,customerId:n,email:r,customerEmail:a}){const[i,l]=j.useState(""),[o,c]=j.useState(""),[d,u]=j.useState(!1),[h,x]=j.useState(!1),[m,f]=j.useState(null),[p,b]=j.useState("idle"),[g,y]=j.useState(!1),[v,N]=j.useState(!1),[E,P]=j.useState(!1),[I,w]=j.useState(!1),[S,A]=j.useState(null),[O,R]=j.useState(!1),[q,D]=j.useState(!1),z=ge(),k=!!r,{data:K}=fe({queryKey:["email-provider-configs"],queryFn:()=>yn.getConfigs(),enabled:e}),B=((K==null?void 0:K.data)||[]).some(ae=>ae.isActive&&ae.isDefault),_=ae=>{if(!ae)return"";const Ge=ae.indexOf("@");return Ge>0?ae.substring(0,Ge):ae},Q=async ae=>{var Ge;if(!(!B||!ae)){b("checking");try{const xt=await yn.checkEmailExists(ae);b((Ge=xt.data)!=null&&Ge.exists?"exists":"not_exists")}catch{b("error")}}},le=async()=>{var ae,Ge;if(!(!a||!i)){y(!0),f(null);try{const xt=await yn.provisionEmail(i,a);(ae=xt.data)!=null&&ae.success?b("exists"):f(((Ge=xt.data)==null?void 0:Ge.error)||"Provisionierung fehlgeschlagen")}catch(xt){f(xt instanceof Error?xt.message:"Fehler bei der Provisionierung")}finally{y(!1)}}},de=async()=>{if(r){N(!0),f(null);try{const ae=await xs.enableMailbox(r.id);ae.success?(P(!0),z.invalidateQueries({queryKey:["customer",n.toString()]}),z.invalidateQueries({queryKey:["mailbox-accounts",n]})):f(ae.error||"Mailbox-Aktivierung fehlgeschlagen")}catch(ae){f(ae instanceof Error?ae.message:"Fehler bei der Mailbox-Aktivierung")}finally{N(!1)}}},Ke=async()=>{if(r)try{const ae=await xs.syncMailboxStatus(r.id);ae.success&&ae.data&&(P(ae.data.hasMailbox),ae.data.wasUpdated&&z.invalidateQueries({queryKey:["customer",n.toString()]}))}catch(ae){console.error("Fehler beim Synchronisieren des Mailbox-Status:",ae)}},Ve=async()=>{if(r){R(!0);try{const ae=await xs.getMailboxCredentials(r.id);ae.success&&ae.data&&(A(ae.data),w(!0))}catch(ae){console.error("Fehler beim Laden der Zugangsdaten:",ae)}finally{R(!1)}}},st=async()=>{if(r&&confirm("Neues Passwort generieren? Das alte Passwort wird ungültig.")){D(!0);try{const ae=await xs.resetPassword(r.id);ae.success&&ae.data?(S&&A({...S,password:ae.data.password}),alert("Passwort wurde erfolgreich zurückgesetzt.")):alert(ae.error||"Fehler beim Zurücksetzen des Passworts")}catch(ae){console.error("Fehler beim Zurücksetzen des Passworts:",ae),alert(ae instanceof Error?ae.message:"Fehler beim Zurücksetzen des Passworts")}finally{D(!1)}}};j.useEffect(()=>{if(e){if(r){const ae=_(r.email);l(ae),c(r.notes||""),b("idle"),P(r.hasMailbox||!1),B&&(Q(ae),Ke())}else l(""),c(""),u(!1),x(!1),b("idle"),P(!1);f(null),w(!1),A(null)}},[e,r,B]);const C=G({mutationFn:async ae=>xs.create(n,{email:ae.email,notes:ae.notes,provisionAtProvider:ae.provision,createMailbox:ae.createMailbox}),onSuccess:()=>{z.invalidateQueries({queryKey:["customer",n.toString()]}),z.invalidateQueries({queryKey:["mailbox-accounts",n]}),l(""),c(""),u(!1),x(!1),t()},onError:ae=>{f(ae instanceof Error?ae.message:"Fehler bei der Provisionierung")}}),nt=G({mutationFn:ae=>xs.update(r.id,ae),onSuccess:()=>{z.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),es=ae=>{ae.preventDefault(),f(null);const Ge=i+gd;k?nt.mutate({email:Ge,notes:o||void 0}):C.mutate({email:Ge,notes:o||void 0,provision:d,createMailbox:d&&h})},Vt=C.isPending||nt.isPending;return s.jsx(qe,{isOpen:e,onClose:t,title:k?"Adresse bearbeiten":"Adresse hinzufügen",children:s.jsxs("form",{onSubmit:es,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"E-Mail-Adresse"}),s.jsxs("div",{className:"flex",children:[s.jsx("input",{type:"text",value:i,onChange:ae=>l(ae.target.value.toLowerCase().replace(/[^a-z0-9._-]/g,"")),placeholder:"kunde-freenet",required:!0,className:"block w-full px-3 py-2 border border-gray-300 rounded-l-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),s.jsx("span",{className:"inline-flex items-center px-3 py-2 border border-l-0 border-gray-300 bg-gray-100 text-gray-600 rounded-r-lg text-sm",children:gd})]}),s.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Vollständige Adresse: ",s.jsxs("span",{className:"font-mono",children:[i||"...",gd]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Notizen (optional)"}),s.jsx("textarea",{value:o,onChange:ae=>c(ae.target.value),rows:3,className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"z.B. für Freenet-Konten, für Klarmobil..."})]}),B&&a&&s.jsx("div",{className:"bg-blue-50 p-3 rounded-lg",children:k?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm font-medium text-gray-700",children:"E-Mail-Provider Status"}),p==="checking"&&s.jsx("span",{className:"text-xs text-gray-500",children:"Prüfe..."}),p==="exists"&&s.jsxs("span",{className:"text-xs text-green-600 flex items-center gap-1",children:[s.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:s.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"})}),"Beim Provider vorhanden"]}),p==="not_exists"&&s.jsx("span",{className:"text-xs text-orange-600",children:"Nicht beim Provider angelegt"}),p==="error"&&s.jsx("span",{className:"text-xs text-red-600",children:"Status konnte nicht geprüft werden"})]}),p==="not_exists"&&s.jsxs("div",{className:"pt-2 border-t border-blue-100",children:[s.jsxs("p",{className:"text-xs text-gray-500 mb-2",children:["Die E-Mail-Weiterleitung ist noch nicht auf dem Server eingerichtet. Weiterleitungsziel: ",a]}),s.jsx(T,{type:"button",size:"sm",onClick:le,disabled:g,children:g?"Wird angelegt...":"Jetzt beim Provider anlegen"})]}),p==="error"&&s.jsx(T,{type:"button",size:"sm",variant:"secondary",onClick:()=>Q(i),children:"Erneut prüfen"}),p==="exists"&&s.jsxs("div",{className:"pt-3 mt-3 border-t border-blue-100",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Mailbox (IMAP/SMTP)"}),E?s.jsxs("span",{className:"text-xs text-green-600 flex items-center gap-1",children:[s.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:s.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"})}),"Mailbox aktiv"]}):s.jsx("span",{className:"text-xs text-orange-600",children:"Keine Mailbox"})]}),!E&&s.jsxs("div",{className:"mt-2",children:[s.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"Aktiviere eine echte Mailbox um E-Mails direkt im CRM zu empfangen und zu versenden."}),s.jsx(T,{type:"button",size:"sm",onClick:de,disabled:v,children:v?"Wird aktiviert...":"Mailbox aktivieren"})]}),E&&s.jsx("div",{className:"mt-3",children:I?S&&s.jsx(wk,{credentials:S,onHide:()=>w(!1),onResetPassword:st,isResettingPassword:q}):s.jsx(T,{type:"button",size:"sm",variant:"secondary",onClick:Ve,disabled:O,children:O?"Laden...":s.jsxs(s.Fragment,{children:[s.jsx(Ae,{className:"w-4 h-4 mr-1"}),"Zugangsdaten anzeigen"]})})})]})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:d,onChange:ae=>{u(ae.target.checked),ae.target.checked||x(!1)},className:"mt-1 rounded border-gray-300"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Beim E-Mail-Provider anlegen"}),s.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Die E-Mail-Weiterleitung wird automatisch auf dem konfigurierten Server erstellt. Weiterleitungsziel: ",a]})]})]}),d&&s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer ml-6",children:[s.jsx("input",{type:"checkbox",checked:h,onChange:ae=>x(ae.target.checked),className:"mt-1 rounded border-gray-300"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Echte Mailbox erstellen (IMAP/SMTP-Zugang)"}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Ermöglicht E-Mails direkt im CRM zu empfangen und zu versenden."})]})]})]})}),m&&s.jsx("div",{className:"bg-red-50 p-3 rounded-lg text-red-700 text-sm",children:m}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:Vt||!i,children:Vt?"Speichern...":"Speichern"})]})]})})}var Il=e=>e.type==="checkbox",Pr=e=>e instanceof Date,as=e=>e==null;const zv=e=>typeof e=="object";var jt=e=>!as(e)&&!Array.isArray(e)&&zv(e)&&!Pr(e),Sk=e=>jt(e)&&e.target?Il(e.target)?e.target.checked:e.target.value:e,kk=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Ck=(e,t)=>e.has(kk(t)),Ek=e=>{const t=e.constructor&&e.constructor.prototype;return jt(t)&&t.hasOwnProperty("isPrototypeOf")},gh=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function bt(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(gh&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(jt(e)&&Ek(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=bt(e[a]));return r}var Lc=e=>/^\w*$/.test(e),rt=e=>e===void 0,yh=e=>Array.isArray(e)?e.filter(Boolean):[],vh=e=>yh(e.replace(/["|']|\]/g,"").split(/\.|\[/)),xe=(e,t,n)=>{if(!t||!jt(e))return n;const r=(Lc(t)?[t]:vh(t)).reduce((a,i)=>as(a)?a:a[i],e);return rt(r)||r===e?rt(e[t])?n:e[t]:r},Js=e=>typeof e=="boolean",_s=e=>typeof e=="function",Ye=(e,t,n)=>{let r=-1;const a=Lc(t)?[t]:vh(t),i=a.length,l=i-1;for(;++r<i;){const o=a[r];let c=n;if(r!==l){const d=e[o];c=jt(d)||Array.isArray(d)?d:isNaN(+a[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=c,e=e[o]}};const wx={BLUR:"blur",FOCUS_OUT:"focusout"},Ks={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},fn={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Dk=Tt.createContext(null);Dk.displayName="HookFormControlContext";var Ak=(e,t,n,r=!0)=>{const a={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const l=i;return t._proxyFormState[l]!==Ks.all&&(t._proxyFormState[l]=!r||Ks.all),e[l]}});return a};const Pk=typeof window<"u"?Tt.useLayoutEffect:Tt.useEffect;var gs=e=>typeof e=="string",Mk=(e,t,n,r,a)=>gs(e)?(r&&t.watch.add(e),xe(n,e,a)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),xe(n,i))):(r&&(t.watchAll=!0),n),Gu=e=>as(e)||!zv(e);function qn(e,t,n=new WeakSet){if(Gu(e)||Gu(t))return Object.is(e,t);if(Pr(e)&&Pr(t))return Object.is(e.getTime(),t.getTime());const r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const i of r){const l=e[i];if(!a.includes(i))return!1;if(i!=="ref"){const o=t[i];if(Pr(l)&&Pr(o)||jt(l)&&jt(o)||Array.isArray(l)&&Array.isArray(o)?!qn(l,o,n):!Object.is(l,o))return!1}}return!0}const Tk=Tt.createContext(null);Tk.displayName="HookFormContext";var Fk=(e,t,n,r,a)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:a||!0}}:{},Oi=e=>Array.isArray(e)?e:[e],Sx=()=>{let e=[];return{get observers(){return e},next:a=>{for(const i of e)i.next&&i.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(i=>i!==a)}}),unsubscribe:()=>{e=[]}}};function $v(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const a=e[r],i=t[r];if(a&&jt(a)&&i){const l=$v(a,i);jt(l)&&(n[r]=l)}else e[r]&&(n[r]=i)}return n}var Wt=e=>jt(e)&&!Object.keys(e).length,jh=e=>e.type==="file",sc=e=>{if(!gh)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},_v=e=>e.type==="select-multiple",bh=e=>e.type==="radio",Ik=e=>bh(e)||Il(e),yd=e=>sc(e)&&e.isConnected;function Rk(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=rt(e)?r++:e[t[r++]];return e}function Lk(e){for(const t in e)if(e.hasOwnProperty(t)&&!rt(e[t]))return!1;return!0}function yt(e,t){const n=Array.isArray(t)?t:Lc(t)?[t]:vh(t),r=n.length===1?e:Rk(e,n),a=n.length-1,i=n[a];return r&&delete r[i],a!==0&&(jt(r)&&Wt(r)||Array.isArray(r)&&Lk(r))&&yt(e,n.slice(0,-1)),e}var Ok=e=>{for(const t in e)if(_s(e[t]))return!0;return!1};function Kv(e){return Array.isArray(e)||jt(e)&&!Ok(e)}function Zu(e,t={}){for(const n in e){const r=e[n];Kv(r)?(t[n]=Array.isArray(r)?[]:{},Zu(r,t[n])):rt(r)||(t[n]=!0)}return t}function ia(e,t,n){n||(n=Zu(t));for(const r in e){const a=e[r];if(Kv(a))rt(t)||Gu(n[r])?n[r]=Zu(a,Array.isArray(a)?[]:{}):ia(a,as(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!qn(a,i)}}return n}const kx={value:!1,isValid:!1},Cx={value:!0,isValid:!0};var Bv=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!rt(e[0].attributes.value)?rt(e[0].value)||e[0].value===""?Cx:{value:e[0].value,isValid:!0}:Cx:kx}return kx},Uv=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>rt(e)?e:t?e===""?NaN:e&&+e:n&&gs(e)?new Date(e):r?r(e):e;const Ex={isValid:!1,value:null};var qv=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Ex):Ex;function Dx(e){const t=e.ref;return jh(t)?t.files:bh(t)?qv(e.refs).value:_v(t)?[...t.selectedOptions].map(({value:n})=>n):Il(t)?Bv(e.refs).value:Uv(rt(t.value)?e.ref.value:t.value,e)}var zk=(e,t,n,r)=>{const a={};for(const i of e){const l=xe(t,i);l&&Ye(a,i,l._f)}return{criteriaMode:n,names:[...e],fields:a,shouldUseNativeValidation:r}},nc=e=>e instanceof RegExp,ji=e=>rt(e)?e:nc(e)?e.source:jt(e)?nc(e.value)?e.value.source:e.value:e,Ax=e=>({isOnSubmit:!e||e===Ks.onSubmit,isOnBlur:e===Ks.onBlur,isOnChange:e===Ks.onChange,isOnAll:e===Ks.all,isOnTouch:e===Ks.onTouched});const Px="AsyncFunction";var $k=e=>!!e&&!!e.validate&&!!(_s(e.validate)&&e.validate.constructor.name===Px||jt(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Px)),_k=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Mx=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const zi=(e,t,n,r)=>{for(const a of n||Object.keys(e)){const i=xe(e,a);if(i){const{_f:l,...o}=i;if(l){if(l.refs&&l.refs[0]&&t(l.refs[0],a)&&!r)return!0;if(l.ref&&t(l.ref,l.name)&&!r)return!0;if(zi(o,t))break}else if(jt(o)&&zi(o,t))break}}};function Tx(e,t,n){const r=xe(e,n);if(r||Lc(n))return{error:r,name:n};const a=n.split(".");for(;a.length;){const i=a.join("."),l=xe(t,i),o=xe(e,i);if(l&&!Array.isArray(l)&&n!==i)return{name:n};if(o&&o.type)return{name:i,error:o};if(o&&o.root&&o.root.type)return{name:`${i}.root`,error:o.root};a.pop()}return{name:n}}var Kk=(e,t,n,r)=>{n(e);const{name:a,...i}=e;return Wt(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(l=>t[l]===(!r||Ks.all))},Bk=(e,t,n)=>!e||!t||e===t||Oi(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),Uk=(e,t,n,r,a)=>a.isOnAll?!1:!n&&a.isOnTouch?!(t||e):(n?r.isOnBlur:a.isOnBlur)?!e:(n?r.isOnChange:a.isOnChange)?e:!0,qk=(e,t)=>!yh(xe(e,t)).length&&yt(e,t),Vk=(e,t,n)=>{const r=Oi(xe(e,n));return Ye(r,"root",t[n]),Ye(e,n,r),e};function Fx(e,t,n="validate"){if(gs(e)||Array.isArray(e)&&e.every(gs)||Js(e)&&!e)return{type:n,message:gs(e)?e:"",ref:t}}var ra=e=>jt(e)&&!nc(e)?e:{value:e,message:""},Ix=async(e,t,n,r,a,i)=>{const{ref:l,refs:o,required:c,maxLength:d,minLength:u,min:h,max:x,pattern:m,validate:f,name:p,valueAsNumber:b,mount:g}=e._f,y=xe(n,p);if(!g||t.has(p))return{};const v=o?o[0]:l,N=R=>{a&&v.reportValidity&&(v.setCustomValidity(Js(R)?"":R||""),v.reportValidity())},E={},P=bh(l),I=Il(l),w=P||I,S=(b||jh(l))&&rt(l.value)&&rt(y)||sc(l)&&l.value===""||y===""||Array.isArray(y)&&!y.length,A=Fk.bind(null,p,r,E),O=(R,q,D,z=fn.maxLength,k=fn.minLength)=>{const K=R?q:D;E[p]={type:R?z:k,message:K,ref:l,...A(R?z:k,K)}};if(i?!Array.isArray(y)||!y.length:c&&(!w&&(S||as(y))||Js(y)&&!y||I&&!Bv(o).isValid||P&&!qv(o).isValid)){const{value:R,message:q}=gs(c)?{value:!!c,message:c}:ra(c);if(R&&(E[p]={type:fn.required,message:q,ref:v,...A(fn.required,q)},!r))return N(q),E}if(!S&&(!as(h)||!as(x))){let R,q;const D=ra(x),z=ra(h);if(!as(y)&&!isNaN(y)){const k=l.valueAsNumber||y&&+y;as(D.value)||(R=k>D.value),as(z.value)||(q=k<z.value)}else{const k=l.valueAsDate||new Date(y),K=Q=>new Date(new Date().toDateString()+" "+Q),B=l.type=="time",_=l.type=="week";gs(D.value)&&y&&(R=B?K(y)>K(D.value):_?y>D.value:k>new Date(D.value)),gs(z.value)&&y&&(q=B?K(y)<K(z.value):_?y<z.value:k<new Date(z.value))}if((R||q)&&(O(!!R,D.message,z.message,fn.max,fn.min),!r))return N(E[p].message),E}if((d||u)&&!S&&(gs(y)||i&&Array.isArray(y))){const R=ra(d),q=ra(u),D=!as(R.value)&&y.length>+R.value,z=!as(q.value)&&y.length<+q.value;if((D||z)&&(O(D,R.message,q.message),!r))return N(E[p].message),E}if(m&&!S&&gs(y)){const{value:R,message:q}=ra(m);if(nc(R)&&!y.match(R)&&(E[p]={type:fn.pattern,message:q,ref:l,...A(fn.pattern,q)},!r))return N(q),E}if(f){if(_s(f)){const R=await f(y,n),q=Fx(R,v);if(q&&(E[p]={...q,...A(fn.validate,q.message)},!r))return N(q.message),E}else if(jt(f)){let R={};for(const q in f){if(!Wt(R)&&!r)break;const D=Fx(await f[q](y,n),v,q);D&&(R={...D,...A(q,D.message)},N(D.message),r&&(E[p]=R))}if(!Wt(R)&&(E[p]={ref:v,...R},!r))return E}}return N(!0),E};const Qk={mode:Ks.onSubmit,reValidateMode:Ks.onChange,shouldFocusError:!0};function Hk(e={}){let t={...Qk,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:_s(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},a=jt(t.defaultValues)||jt(t.values)?bt(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:bt(a),l={action:!1,mount:!1,watch:!1,keepIsValid:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,d=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={...u};let x={...h};const m={array:Sx(),state:Sx()},f=t.criteriaMode===Ks.all,p=L=>U=>{clearTimeout(d),d=setTimeout(L,U)},b=async L=>{if(!l.keepIsValid&&!t.disabled&&(h.isValid||x.isValid||L)){let U;t.resolver?(U=Wt((await w()).errors),g()):U=await A(r,!0),U!==n.isValid&&m.state.next({isValid:U})}},g=(L,U)=>{!t.disabled&&(h.isValidating||h.validatingFields||x.isValidating||x.validatingFields)&&((L||Array.from(o.mount)).forEach(W=>{W&&(U?Ye(n.validatingFields,W,U):yt(n.validatingFields,W))}),m.state.next({validatingFields:n.validatingFields,isValidating:!Wt(n.validatingFields)}))},y=(L,U=[],W,ce,se=!0,ee=!0)=>{if(ce&&W&&!t.disabled){if(l.action=!0,ee&&Array.isArray(xe(r,L))){const ye=W(xe(r,L),ce.argA,ce.argB);se&&Ye(r,L,ye)}if(ee&&Array.isArray(xe(n.errors,L))){const ye=W(xe(n.errors,L),ce.argA,ce.argB);se&&Ye(n.errors,L,ye),qk(n.errors,L)}if((h.touchedFields||x.touchedFields)&&ee&&Array.isArray(xe(n.touchedFields,L))){const ye=W(xe(n.touchedFields,L),ce.argA,ce.argB);se&&Ye(n.touchedFields,L,ye)}(h.dirtyFields||x.dirtyFields)&&(n.dirtyFields=ia(a,i)),m.state.next({name:L,isDirty:R(L,U),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Ye(i,L,U)},v=(L,U)=>{Ye(n.errors,L,U),m.state.next({errors:n.errors})},N=L=>{n.errors=L,m.state.next({errors:n.errors,isValid:!1})},E=(L,U,W,ce)=>{const se=xe(r,L);if(se){const ee=xe(i,L,rt(W)?xe(a,L):W);rt(ee)||ce&&ce.defaultChecked||U?Ye(i,L,U?ee:Dx(se._f)):z(L,ee),l.mount&&!l.action&&b()}},P=(L,U,W,ce,se)=>{let ee=!1,ye=!1;const Le={name:L};if(!t.disabled){if(!W||ce){(h.isDirty||x.isDirty)&&(ye=n.isDirty,n.isDirty=Le.isDirty=R(),ee=ye!==Le.isDirty);const Me=qn(xe(a,L),U);ye=!!xe(n.dirtyFields,L),Me?yt(n.dirtyFields,L):Ye(n.dirtyFields,L,!0),Le.dirtyFields=n.dirtyFields,ee=ee||(h.dirtyFields||x.dirtyFields)&&ye!==!Me}if(W){const Me=xe(n.touchedFields,L);Me||(Ye(n.touchedFields,L,W),Le.touchedFields=n.touchedFields,ee=ee||(h.touchedFields||x.touchedFields)&&Me!==W)}ee&&se&&m.state.next(Le)}return ee?Le:{}},I=(L,U,W,ce)=>{const se=xe(n.errors,L),ee=(h.isValid||x.isValid)&&Js(U)&&n.isValid!==U;if(t.delayError&&W?(c=p(()=>v(L,W)),c(t.delayError)):(clearTimeout(d),c=null,W?Ye(n.errors,L,W):yt(n.errors,L)),(W?!qn(se,W):se)||!Wt(ce)||ee){const ye={...ce,...ee&&Js(U)?{isValid:U}:{},errors:n.errors,name:L};n={...n,...ye},m.state.next(ye)}},w=async L=>(g(L,!0),await t.resolver(i,t.context,zk(L||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),S=async L=>{const{errors:U}=await w(L);if(g(L),L)for(const W of L){const ce=xe(U,W);ce?Ye(n.errors,W,ce):yt(n.errors,W)}else n.errors=U;return U},A=async(L,U,W={valid:!0})=>{for(const ce in L){const se=L[ce];if(se){const{_f:ee,...ye}=se;if(ee){const Le=o.array.has(ee.name),Me=se._f&&$k(se._f);Me&&h.validatingFields&&g([ee.name],!0);const kt=await Ix(se,o.disabled,i,f,t.shouldUseNativeValidation&&!U,Le);if(Me&&h.validatingFields&&g([ee.name]),kt[ee.name]&&(W.valid=!1,U||e.shouldUseNativeValidation))break;!U&&(xe(kt,ee.name)?Le?Vk(n.errors,kt,ee.name):Ye(n.errors,ee.name,kt[ee.name]):yt(n.errors,ee.name))}!Wt(ye)&&await A(ye,U,W)}}return W.valid},O=()=>{for(const L of o.unMount){const U=xe(r,L);U&&(U._f.refs?U._f.refs.every(W=>!yd(W)):!yd(U._f.ref))&&es(L)}o.unMount=new Set},R=(L,U)=>!t.disabled&&(L&&U&&Ye(i,L,U),!qn(le(),a)),q=(L,U,W)=>Mk(L,o,{...l.mount?i:rt(U)?a:gs(L)?{[L]:U}:U},W,U),D=L=>yh(xe(l.mount?i:a,L,t.shouldUnregister?xe(a,L,[]):[])),z=(L,U,W={})=>{const ce=xe(r,L);let se=U;if(ce){const ee=ce._f;ee&&(!ee.disabled&&Ye(i,L,Uv(U,ee)),se=sc(ee.ref)&&as(U)?"":U,_v(ee.ref)?[...ee.ref.options].forEach(ye=>ye.selected=se.includes(ye.value)):ee.refs?Il(ee.ref)?ee.refs.forEach(ye=>{(!ye.defaultChecked||!ye.disabled)&&(Array.isArray(se)?ye.checked=!!se.find(Le=>Le===ye.value):ye.checked=se===ye.value||!!se)}):ee.refs.forEach(ye=>ye.checked=ye.value===se):jh(ee.ref)?ee.ref.value="":(ee.ref.value=se,ee.ref.type||m.state.next({name:L,values:bt(i)})))}(W.shouldDirty||W.shouldTouch)&&P(L,se,W.shouldTouch,W.shouldDirty,!0),W.shouldValidate&&Q(L)},k=(L,U,W)=>{for(const ce in U){if(!U.hasOwnProperty(ce))return;const se=U[ce],ee=L+"."+ce,ye=xe(r,ee);(o.array.has(L)||jt(se)||ye&&!ye._f)&&!Pr(se)?k(ee,se,W):z(ee,se,W)}},K=(L,U,W={})=>{const ce=xe(r,L),se=o.array.has(L),ee=bt(U);Ye(i,L,ee),se?(m.array.next({name:L,values:bt(i)}),(h.isDirty||h.dirtyFields||x.isDirty||x.dirtyFields)&&W.shouldDirty&&m.state.next({name:L,dirtyFields:ia(a,i),isDirty:R(L,ee)})):ce&&!ce._f&&!as(ee)?k(L,ee,W):z(L,ee,W),Mx(L,o)?m.state.next({...n,name:L,values:bt(i)}):m.state.next({name:l.mount?L:void 0,values:bt(i)})},B=async L=>{l.mount=!0;const U=L.target;let W=U.name,ce=!0;const se=xe(r,W),ee=Me=>{ce=Number.isNaN(Me)||Pr(Me)&&isNaN(Me.getTime())||qn(Me,xe(i,W,Me))},ye=Ax(t.mode),Le=Ax(t.reValidateMode);if(se){let Me,kt;const mn=U.type?Dx(se._f):Sk(L),Hs=L.type===wx.BLUR||L.type===wx.FOCUS_OUT,Ln=!_k(se._f)&&!t.resolver&&!xe(n.errors,W)&&!se._f.deps||Uk(Hs,xe(n.touchedFields,W),n.isSubmitted,Le,ye),li=Mx(W,o,Hs);Ye(i,W,mn),Hs?(!U||!U.readOnly)&&(se._f.onBlur&&se._f.onBlur(L),c&&c(0)):se._f.onChange&&se._f.onChange(L);const sa=P(W,mn,Hs),Oc=!Wt(sa)||li;if(!Hs&&m.state.next({name:W,type:L.type,values:bt(i)}),Ln)return(h.isValid||x.isValid)&&(t.mode==="onBlur"?Hs&&b():Hs||b()),Oc&&m.state.next({name:W,...li?{}:sa});if(!Hs&&li&&m.state.next({...n}),t.resolver){const{errors:oi}=await w([W]);if(g([W]),ee(mn),ce){const Rl=Tx(n.errors,r,W),ci=Tx(oi,r,Rl.name||W);Me=ci.error,W=ci.name,kt=Wt(oi)}}else g([W],!0),Me=(await Ix(se,o.disabled,i,f,t.shouldUseNativeValidation))[W],g([W]),ee(mn),ce&&(Me?kt=!1:(h.isValid||x.isValid)&&(kt=await A(r,!0)));ce&&(se._f.deps&&(!Array.isArray(se._f.deps)||se._f.deps.length>0)&&Q(se._f.deps),I(W,kt,Me,sa))}},_=(L,U)=>{if(xe(n.errors,U)&&L.focus)return L.focus(),1},Q=async(L,U={})=>{let W,ce;const se=Oi(L);if(t.resolver){const ee=await S(rt(L)?L:se);W=Wt(ee),ce=L?!se.some(ye=>xe(ee,ye)):W}else L?(ce=(await Promise.all(se.map(async ee=>{const ye=xe(r,ee);return await A(ye&&ye._f?{[ee]:ye}:ye)}))).every(Boolean),!(!ce&&!n.isValid)&&b()):ce=W=await A(r);return m.state.next({...!gs(L)||(h.isValid||x.isValid)&&W!==n.isValid?{}:{name:L},...t.resolver||!L?{isValid:W}:{},errors:n.errors}),U.shouldFocus&&!ce&&zi(r,_,L?se:o.mount),ce},le=(L,U)=>{let W={...l.mount?i:a};return U&&(W=$v(U.dirtyFields?n.dirtyFields:n.touchedFields,W)),rt(L)?W:gs(L)?xe(W,L):L.map(ce=>xe(W,ce))},de=(L,U)=>({invalid:!!xe((U||n).errors,L),isDirty:!!xe((U||n).dirtyFields,L),error:xe((U||n).errors,L),isValidating:!!xe(n.validatingFields,L),isTouched:!!xe((U||n).touchedFields,L)}),Ke=L=>{L&&Oi(L).forEach(U=>yt(n.errors,U)),m.state.next({errors:L?n.errors:{}})},Ve=(L,U,W)=>{const ce=(xe(r,L,{_f:{}})._f||{}).ref,se=xe(n.errors,L)||{},{ref:ee,message:ye,type:Le,...Me}=se;Ye(n.errors,L,{...Me,...U,ref:ce}),m.state.next({name:L,errors:n.errors,isValid:!1}),W&&W.shouldFocus&&ce&&ce.focus&&ce.focus()},st=(L,U)=>_s(L)?m.state.subscribe({next:W=>"values"in W&&L(q(void 0,U),W)}):q(L,U,!0),C=L=>m.state.subscribe({next:U=>{Bk(L.name,U.name,L.exact)&&Kk(U,L.formState||h,ts,L.reRenderRoot)&&L.callback({values:{...i},...n,...U,defaultValues:a})}}).unsubscribe,nt=L=>(l.mount=!0,x={...x,...L.formState},C({...L,formState:{...u,...L.formState}})),es=(L,U={})=>{for(const W of L?Oi(L):o.mount)o.mount.delete(W),o.array.delete(W),U.keepValue||(yt(r,W),yt(i,W)),!U.keepError&&yt(n.errors,W),!U.keepDirty&&yt(n.dirtyFields,W),!U.keepTouched&&yt(n.touchedFields,W),!U.keepIsValidating&&yt(n.validatingFields,W),!t.shouldUnregister&&!U.keepDefaultValue&&yt(a,W);m.state.next({values:bt(i)}),m.state.next({...n,...U.keepDirty?{isDirty:R()}:{}}),!U.keepIsValid&&b()},Vt=({disabled:L,name:U})=>{if(Js(L)&&l.mount||L||o.disabled.has(U)){const se=o.disabled.has(U)!==!!L;L?o.disabled.add(U):o.disabled.delete(U),se&&l.mount&&!l.action&&b()}},ae=(L,U={})=>{let W=xe(r,L);const ce=Js(U.disabled)||Js(t.disabled);return Ye(r,L,{...W||{},_f:{...W&&W._f?W._f:{ref:{name:L}},name:L,mount:!0,...U}}),o.mount.add(L),W?Vt({disabled:Js(U.disabled)?U.disabled:t.disabled,name:L}):E(L,!0,U.value),{...ce?{disabled:U.disabled||t.disabled}:{},...t.progressive?{required:!!U.required,min:ji(U.min),max:ji(U.max),minLength:ji(U.minLength),maxLength:ji(U.maxLength),pattern:ji(U.pattern)}:{},name:L,onChange:B,onBlur:B,ref:se=>{if(se){ae(L,U),W=xe(r,L);const ee=rt(se.value)&&se.querySelectorAll&&se.querySelectorAll("input,select,textarea")[0]||se,ye=Ik(ee),Le=W._f.refs||[];if(ye?Le.find(Me=>Me===ee):ee===W._f.ref)return;Ye(r,L,{_f:{...W._f,...ye?{refs:[...Le.filter(yd),ee,...Array.isArray(xe(a,L))?[{}]:[]],ref:{type:ee.type,name:L}}:{ref:ee}}}),E(L,!1,void 0,ee)}else W=xe(r,L,{}),W._f&&(W._f.mount=!1),(t.shouldUnregister||U.shouldUnregister)&&!(Ck(o.array,L)&&l.action)&&o.unMount.add(L)}}},Ge=()=>t.shouldFocusError&&zi(r,_,o.mount),xt=L=>{Js(L)&&(m.state.next({disabled:L}),zi(r,(U,W)=>{const ce=xe(r,W);ce&&(U.disabled=ce._f.disabled||L,Array.isArray(ce._f.refs)&&ce._f.refs.forEach(se=>{se.disabled=ce._f.disabled||L}))},0,!1))},Z=(L,U)=>async W=>{let ce;W&&(W.preventDefault&&W.preventDefault(),W.persist&&W.persist());let se=bt(i);if(m.state.next({isSubmitting:!0}),t.resolver){const{errors:ee,values:ye}=await w();g(),n.errors=ee,se=bt(ye)}else await A(r);if(o.disabled.size)for(const ee of o.disabled)yt(se,ee);if(yt(n.errors,"root"),Wt(n.errors)){m.state.next({errors:{}});try{await L(se,W)}catch(ee){ce=ee}}else U&&await U({...n.errors},W),Ge(),setTimeout(Ge);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Wt(n.errors)&&!ce,submitCount:n.submitCount+1,errors:n.errors}),ce)throw ce},Fe=(L,U={})=>{xe(r,L)&&(rt(U.defaultValue)?K(L,bt(xe(a,L))):(K(L,U.defaultValue),Ye(a,L,bt(U.defaultValue))),U.keepTouched||yt(n.touchedFields,L),U.keepDirty||(yt(n.dirtyFields,L),n.isDirty=U.defaultValue?R(L,bt(xe(a,L))):R()),U.keepError||(yt(n.errors,L),h.isValid&&b()),m.state.next({...n}))},Xe=(L,U={})=>{const W=L?bt(L):a,ce=bt(W),se=Wt(L),ee=se?a:ce;if(U.keepDefaultValues||(a=W),!U.keepValues){if(U.keepDirtyValues){const ye=new Set([...o.mount,...Object.keys(ia(a,i))]);for(const Le of Array.from(ye)){const Me=xe(n.dirtyFields,Le),kt=xe(i,Le),mn=xe(ee,Le);Me&&!rt(kt)?Ye(ee,Le,kt):!Me&&!rt(mn)&&K(Le,mn)}}else{if(gh&&rt(L))for(const ye of o.mount){const Le=xe(r,ye);if(Le&&Le._f){const Me=Array.isArray(Le._f.refs)?Le._f.refs[0]:Le._f.ref;if(sc(Me)){const kt=Me.closest("form");if(kt){kt.reset();break}}}}if(U.keepFieldsRef)for(const ye of o.mount)K(ye,xe(ee,ye));else r={}}i=t.shouldUnregister?U.keepDefaultValues?bt(a):{}:bt(ee),m.array.next({values:{...ee}}),m.state.next({values:{...ee}})}o={mount:U.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!h.isValid||!!U.keepIsValid||!!U.keepDirtyValues||!t.shouldUnregister&&!Wt(ee),l.watch=!!t.shouldUnregister,l.keepIsValid=!!U.keepIsValid,l.action=!1,U.keepErrors||(n.errors={}),m.state.next({submitCount:U.keepSubmitCount?n.submitCount:0,isDirty:se?!1:U.keepDirty?n.isDirty:!!(U.keepDefaultValues&&!qn(L,a)),isSubmitted:U.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:se?{}:U.keepDirtyValues?U.keepDefaultValues&&i?ia(a,i):n.dirtyFields:U.keepDefaultValues&&L?ia(a,L):U.keepDirty?n.dirtyFields:{},touchedFields:U.keepTouched?n.touchedFields:{},errors:U.keepErrors?n.errors:{},isSubmitSuccessful:U.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},J=(L,U)=>Xe(_s(L)?L(i):L,{...t.resetOptions,...U}),ue=(L,U={})=>{const W=xe(r,L),ce=W&&W._f;if(ce){const se=ce.refs?ce.refs[0]:ce.ref;se.focus&&setTimeout(()=>{se.focus(),U.shouldSelect&&_s(se.select)&&se.select()})}},ts=L=>{n={...n,...L}},gt={control:{register:ae,unregister:es,getFieldState:de,handleSubmit:Z,setError:Ve,_subscribe:C,_runSchema:w,_updateIsValidating:g,_focusError:Ge,_getWatch:q,_getDirty:R,_setValid:b,_setFieldArray:y,_setDisabledField:Vt,_setErrors:N,_getFieldArray:D,_reset:Xe,_resetDefaultValues:()=>_s(t.defaultValues)&&t.defaultValues().then(L=>{J(L,t.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:O,_disableForm:xt,_subjects:m,_proxyFormState:h,get _fields(){return r},get _formValues(){return i},get _state(){return l},set _state(L){l=L},get _defaultValues(){return a},get _names(){return o},set _names(L){o=L},get _formState(){return n},get _options(){return t},set _options(L){t={...t,...L}}},subscribe:nt,trigger:Q,register:ae,handleSubmit:Z,watch:st,setValue:K,getValues:le,reset:J,resetField:Fe,clearErrors:Ke,unregister:es,setError:Ve,setFocus:ue,getFieldState:de};return{...gt,formControl:gt}}function Vv(e={}){const t=Tt.useRef(void 0),n=Tt.useRef(void 0),[r,a]=Tt.useState({isDirty:!1,isValidating:!1,isLoading:_s(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:_s(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!_s(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...o}=Hk(e);t.current={...o,formState:r}}const i=t.current.control;return i._options=e,Pk(()=>{const l=i._subscribe({formState:i._proxyFormState,callback:()=>a({...i._formState}),reRenderRoot:!0});return a(o=>({...o,isReady:!0})),i._formState.isReady=!0,l},[i]),Tt.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),Tt.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),Tt.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),Tt.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),Tt.useEffect(()=>{if(i._proxyFormState.isDirty){const l=i._getDirty();l!==r.isDirty&&i._subjects.state.next({isDirty:l})}},[i,r.isDirty]),Tt.useEffect(()=>{var l;e.values&&!qn(e.values,n.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((l=i._options.resetOptions)===null||l===void 0)&&l.keepIsValid||i._setValid(),n.current=e.values,a(o=>({...o}))):i._resetDefaultValues()},[i,e.values]),Tt.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),t.current.formState=Tt.useMemo(()=>Ak(r,i),[i,r]),t.current}function Rx(){var g,y;const{id:e}=Nc(),t=Yt(),n=ge(),r=!!e,{register:a,handleSubmit:i,reset:l,watch:o,setValue:c,formState:{errors:d}}=Vv(),u=o("type"),{data:h}=fe({queryKey:["customer",e],queryFn:()=>At.getById(parseInt(e)),enabled:r});j.useEffect(()=>{if(h!=null&&h.data){const v={...h.data};v.birthDate&&(v.birthDate=v.birthDate.split("T")[0]),v.foundingDate&&(v.foundingDate=v.foundingDate.split("T")[0]),l(v)}},[h,l]);const x=G({mutationFn:At.create,onSuccess:()=>{n.invalidateQueries({queryKey:["customers"]}),t("/customers")}}),m=G({mutationFn:v=>At.update(parseInt(e),v),onSuccess:()=>{n.invalidateQueries({queryKey:["customers"]}),n.invalidateQueries({queryKey:["customer",e]}),t(`/customers/${e}`)}}),f=v=>{const N={type:v.type,salutation:v.salutation||void 0,firstName:v.firstName,lastName:v.lastName,companyName:v.companyName||void 0,email:v.email||void 0,phone:v.phone||void 0,mobile:v.mobile||void 0,taxNumber:v.taxNumber||void 0,commercialRegisterNumber:v.commercialRegisterNumber||void 0,notes:v.notes||void 0,birthPlace:v.birthPlace||void 0};v.birthDate&&typeof v.birthDate=="string"&&v.birthDate.trim()!==""?N.birthDate=new Date(v.birthDate).toISOString():N.birthDate=null,v.foundingDate&&typeof v.foundingDate=="string"&&v.foundingDate.trim()!==""?N.foundingDate=new Date(v.foundingDate).toISOString():N.foundingDate=null,r?m.mutate(N):x.mutate(N)},p=x.isPending||m.isPending,b=x.error||m.error;return s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold mb-6",children:r?"Kunde bearbeiten":"Neuer Kunde"}),b&&s.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:b instanceof Error?b.message:"Ein Fehler ist aufgetreten"}),s.jsxs("form",{onSubmit:i(f),children:[s.jsx(X,{className:"mb-6",title:"Stammdaten",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Ie,{label:"Kundentyp",...a("type"),options:[{value:"PRIVATE",label:"Privatkunde"},{value:"BUSINESS",label:"Geschäftskunde"}]}),s.jsx(Ie,{label:"Anrede",...a("salutation"),options:[{value:"Herr",label:"Herr"},{value:"Frau",label:"Frau"},{value:"Divers",label:"Divers"}]}),s.jsx(H,{label:"Vorname",...a("firstName",{required:"Vorname erforderlich"}),error:(g=d.firstName)==null?void 0:g.message}),s.jsx(H,{label:"Nachname",...a("lastName",{required:"Nachname erforderlich"}),error:(y=d.lastName)==null?void 0:y.message}),u==="BUSINESS"&&s.jsxs(s.Fragment,{children:[s.jsx(H,{label:"Firmenname",...a("companyName"),className:"md:col-span-2"}),s.jsx(H,{label:"Gründungsdatum",type:"date",...a("foundingDate"),value:o("foundingDate")||"",onClear:()=>c("foundingDate","")})]}),u!=="BUSINESS"&&s.jsxs(s.Fragment,{children:[s.jsx(H,{label:"Geburtsdatum",type:"date",...a("birthDate"),value:o("birthDate")||"",onClear:()=>c("birthDate","")}),s.jsx(H,{label:"Geburtsort",...a("birthPlace")})]})]})}),s.jsx(X,{className:"mb-6",title:"Kontaktdaten",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(H,{label:"E-Mail",type:"email",...a("email")}),s.jsx(H,{label:"Telefon",...a("phone")}),s.jsx(H,{label:"Mobil",...a("mobile")})]})}),u==="BUSINESS"&&s.jsxs(X,{className:"mb-6",title:"Geschäftsdaten",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(H,{label:"Steuernummer",...a("taxNumber")}),s.jsx(H,{label:"Handelsregisternummer",...a("commercialRegisterNumber"),placeholder:"z.B. HRB 12345"})]}),r&&s.jsx("p",{className:"mt-4 text-sm text-gray-500",children:"Dokumente (Gewerbeanmeldung, Handelsregisterauszug) können nach dem Speichern in der Kundendetailansicht hochgeladen werden."})]}),s.jsx(X,{className:"mb-6",title:"Notizen",children:s.jsx("textarea",{...a("notes"),rows:4,className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"Interne Notizen..."})}),s.jsxs("div",{className:"flex justify-end gap-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:()=>t(-1),children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})]})}const vd={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabelinternet",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},jd={DRAFT:"Entwurf",PENDING:"Ausstehend",ACTIVE:"Aktiv",CANCELLED:"Gekündigt",EXPIRED:"Abgelaufen",DEACTIVATED:"Deaktiviert"},Lx={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"},Wk=[{status:"DRAFT",label:"Entwurf",description:"Vertrag wird noch vorbereitet",color:"text-gray-600"},{status:"PENDING",label:"Ausstehend",description:"Wartet auf Aktivierung",color:"text-yellow-600"},{status:"ACTIVE",label:"Aktiv",description:"Vertrag läuft normal",color:"text-green-600"},{status:"EXPIRED",label:"Abgelaufen",description:"Laufzeit vorbei, läuft aber ohne Kündigung weiter",color:"text-orange-600"},{status:"CANCELLED",label:"Gekündigt",description:"Aktive Kündigung eingereicht, Vertrag endet",color:"text-red-600"},{status:"DEACTIVATED",label:"Deaktiviert",description:"Manuell beendet/archiviert",color:"text-gray-500"}];function Gk({isOpen:e,onClose:t}){return e?s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"fixed inset-0 bg-black/20",onClick:t}),s.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl p-4 max-w-sm w-full mx-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:"Vertragsstatus-Übersicht"}),s.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600",children:s.jsx(qt,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"space-y-2",children:Wk.map(({status:n,label:r,description:a,color:i})=>s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:`font-medium text-sm min-w-[90px] ${i}`,children:r}),s.jsx("span",{className:"text-sm text-gray-600",children:a})]},n))})]})]}):null}function Zk(){const[e,t]=Sc(),n=Yt(),[r,a]=j.useState(e.get("search")||""),[i,l]=j.useState(e.get("type")||""),[o,c]=j.useState(e.get("status")||""),[d,u]=j.useState(parseInt(e.get("page")||"1",10)),[h,x]=j.useState(new Set),[m,f]=j.useState(!1),{hasPermission:p,isCustomer:b,isCustomerPortal:g,user:y}=We(),v=ge();j.useEffect(()=>{const D=new URLSearchParams;r&&D.set("search",r),i&&D.set("type",i),o&&D.set("status",o),d>1&&D.set("page",d.toString()),t(D,{replace:!0})},[r,i,o,d,t]);const N=G({mutationFn:Oe.delete,onSuccess:()=>{v.invalidateQueries({queryKey:["contracts"]})}}),{data:E,isLoading:P}=fe({queryKey:["contracts",r,i,o,d,b?y==null?void 0:y.customerId:null],queryFn:()=>Oe.getAll({search:r||void 0,type:i||void 0,status:o||void 0,page:d,limit:20,customerId:b?y==null?void 0:y.customerId:void 0})}),I=j.useMemo(()=>{if(!g||!(E!=null&&E.data))return[];const D=new Set;return y!=null&&y.customerId&&D.add(y.customerId),E.data.forEach(z=>D.add(z.customerId)),[...D]},[E==null?void 0:E.data,g,y==null?void 0:y.customerId]),w=s1({queries:I.map(D=>({queryKey:["contract-tree",D],queryFn:()=>Oe.getTreeForCustomer(D),enabled:g}))}),S=j.useMemo(()=>{const D=new Map;return I.forEach((z,k)=>{var B;const K=w[k];(B=K==null?void 0:K.data)!=null&&B.data&&D.set(z,K.data.data)}),D},[I,w]),A=j.useMemo(()=>{if(!g||!(E!=null&&E.data))return null;const D={};for(const z of E.data){const k=z.customerId;if(!D[k]){const K=z.customer?z.customer.companyName||`${z.customer.firstName} ${z.customer.lastName}`:`Kunde ${k}`;D[k]={customerId:k,customerName:K,isOwn:k===(y==null?void 0:y.customerId),contracts:[],tree:S.get(k)||[]}}D[k].contracts.push(z)}return Object.values(D).sort((z,k)=>z.isOwn&&!k.isOwn?-1:!z.isOwn&&k.isOwn?1:z.customerName.localeCompare(k.customerName))},[E==null?void 0:E.data,g,y==null?void 0:y.customerId,S]),O=D=>{x(z=>{const k=new Set(z);return k.has(D)?k.delete(D):k.add(D),k})},R=(D,z)=>D.map(k=>s.jsx("div",{children:q(k,z)},k.contract.id)),q=(D,z=0)=>{var le,de,Ke,Ve,st,C,nt;const{contract:k,predecessors:K,hasHistory:B}=D,_=h.has(k.id),Q=z>0;return s.jsxs("div",{children:[s.jsxs("div",{className:`
|
||
border rounded-lg p-4 transition-colors
|
||
${Q?"ml-6 border-l-4 border-l-gray-300 bg-gray-50":"hover:bg-gray-50"}
|
||
`,children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[!Q&&B?s.jsx("button",{onClick:()=>O(k.id),className:"p-1 hover:bg-gray-200 rounded transition-colors",title:_?"Einklappen":"Vorgänger anzeigen",children:_?s.jsx(dn,{className:"w-4 h-4 text-gray-500"}):s.jsx(Ft,{className:"w-4 h-4 text-gray-500"})}):Q?null:s.jsx("div",{className:"w-6"}),s.jsxs("span",{className:"font-mono flex items-center gap-1",children:[k.contractNumber,s.jsx(oe,{value:k.contractNumber})]}),s.jsx(ve,{children:vd[k.type]||k.type}),s.jsx(ve,{variant:Lx[k.status]||"default",children:jd[k.status]||k.status}),Q&&s.jsx("span",{className:"text-xs text-gray-500 ml-2",children:"(Vorgänger)"})]}),s.jsx("div",{className:"flex gap-2",children:s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${k.id}`,{state:{from:"contracts"}}),title:"Ansehen",children:s.jsx(Ae,{className:"w-4 h-4"})})})]}),(k.providerName||((le=k.provider)==null?void 0:le.name))&&s.jsxs("p",{className:`flex items-center gap-1 ${Q?"ml-6":""}`,children:[k.providerName||((de=k.provider)==null?void 0:de.name),(k.tariffName||((Ke=k.tariff)==null?void 0:Ke.name))&&` - ${k.tariffName||((Ve=k.tariff)==null?void 0:Ve.name)}`,s.jsx(oe,{value:(k.providerName||((st=k.provider)==null?void 0:st.name)||"")+(k.tariffName||(C=k.tariff)!=null&&C.name?` - ${k.tariffName||((nt=k.tariff)==null?void 0:nt.name)}`:"")})]}),k.startDate&&s.jsxs("p",{className:`text-sm text-gray-500 ${Q?"ml-6":""}`,children:["Beginn: ",new Date(k.startDate).toLocaleDateString("de-DE"),k.endDate&&` | Ende: ${new Date(k.endDate).toLocaleDateString("de-DE")}`]})]}),(z===0&&_||z>0)&&K.length>0&&s.jsx("div",{className:"mt-2",children:R(K,z+1)})]},k.id)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Verträge"}),p("contracts:create")&&!b&&s.jsx(ke,{to:"/contracts/new",children:s.jsxs(T,{children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Neuer Vertrag"]})})]}),s.jsx(X,{className:"mb-6",children:s.jsxs("div",{className:"flex gap-4 flex-wrap",children:[s.jsx("div",{className:"flex-1 min-w-[200px]",children:s.jsx(H,{placeholder:"Suchen...",value:r,onChange:D=>a(D.target.value)})}),s.jsx(Ie,{value:i,onChange:D=>l(D.target.value),options:Object.entries(vd).map(([D,z])=>({value:D,label:z})),className:"w-48"}),s.jsx(Ie,{value:o,onChange:D=>c(D.target.value),options:Object.entries(jd).map(([D,z])=>({value:D,label:z})),className:"w-48"}),s.jsx(T,{variant:"secondary",children:s.jsx(Tl,{className:"w-4 h-4"})})]})}),P?s.jsx(X,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."})}):E!=null&&E.data&&E.data.length>0?s.jsx(s.Fragment,{children:g&&A?s.jsx("div",{className:"space-y-6",children:A.map(D=>s.jsxs(X,{children:[s.jsx("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:D.isOwn?s.jsxs(s.Fragment,{children:[s.jsx(ii,{className:"w-5 h-5 text-blue-600"}),s.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Meine Verträge"}),s.jsx(ve,{variant:"default",children:D.contracts.length})]}):s.jsxs(s.Fragment,{children:[s.jsx(Ca,{className:"w-5 h-5 text-purple-600"}),s.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:["Verträge von ",D.customerName]}),s.jsx(ve,{variant:"default",children:D.contracts.length})]})}),D.tree.length>0?s.jsx("div",{className:"space-y-4",children:D.tree.map(z=>q(z,0))}):s.jsx("p",{className:"text-gray-500",children:"Keine Verträge vorhanden."})]},D.isOwn?"own":D.customerName))}):s.jsxs(X,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Vertragsnr."}),!b&&s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Kunde"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Typ"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Anbieter / Tarif"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:s.jsxs("span",{className:"flex items-center gap-1",children:["Status",s.jsx("button",{onClick:()=>f(!0),className:"text-gray-400 hover:text-blue-600 transition-colors",title:"Status-Erklärung",children:s.jsx(Ml,{className:"w-4 h-4"})})]})}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beginn"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:E.data.map(D=>s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-mono text-sm",children:D.contractNumber}),!b&&s.jsx("td",{className:"py-3 px-4",children:D.customer&&s.jsx(ke,{to:`/customers/${D.customer.id}`,className:"text-blue-600 hover:underline",children:D.customer.companyName||`${D.customer.firstName} ${D.customer.lastName}`})}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ve,{children:vd[D.type]})}),s.jsxs("td",{className:"py-3 px-4",children:[D.providerName||"-",D.tariffName&&s.jsxs("span",{className:"text-gray-500",children:[" / ",D.tariffName]})]}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ve,{variant:Lx[D.status],children:jd[D.status]})}),s.jsx("td",{className:"py-3 px-4",children:D.startDate?new Date(D.startDate).toLocaleDateString("de-DE"):"-"}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${D.id}`,{state:{from:"contracts"}}),children:s.jsx(Ae,{className:"w-4 h-4"})}),p("contracts:update")&&!b&&s.jsx(ke,{to:`/contracts/${D.id}/edit`,children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(He,{className:"w-4 h-4"})})}),p("contracts:delete")&&!b&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertrag wirklich löschen?")&&N.mutate(D.id)},children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})})]},D.id))})]})}),E.pagination&&E.pagination.totalPages>1&&s.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",E.pagination.page," von ",E.pagination.totalPages," (",E.pagination.total," Einträge)"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>u(D=>Math.max(1,D-1)),disabled:d===1,children:"Zurück"}),s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>u(D=>D+1),disabled:d>=E.pagination.totalPages,children:"Weiter"})]})]})]})}):s.jsx(X,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Verträge gefunden."})}),s.jsx(Gk,{isOpen:m,onClose:()=>f(!1)})]})}const Jk={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabelinternet",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},Xk={DRAFT:"Entwurf",PENDING:"Ausstehend",ACTIVE:"Aktiv",CANCELLED:"Gekündigt",EXPIRED:"Abgelaufen",DEACTIVATED:"Deaktiviert"},Yk={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"};function eC({contractId:e,isOpen:t,onClose:n}){var o,c,d,u,h,x,m,f,p,b,g;const{data:r,isLoading:a,error:i}=fe({queryKey:["contract",e],queryFn:()=>Oe.getById(e),enabled:t}),l=r==null?void 0:r.data;return s.jsxs(qe,{isOpen:t,onClose:n,title:"Vertragsdetails",size:"xl",children:[a&&s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}),i&&s.jsx("div",{className:"text-center py-8 text-red-600",children:"Fehler beim Laden des Vertrags"}),l&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-3 pb-4 border-b",children:[s.jsxs("span",{className:"text-xl font-bold font-mono flex items-center gap-2",children:[l.contractNumber,s.jsx(oe,{value:l.contractNumber})]}),s.jsx(ve,{children:Jk[l.type]||l.type}),s.jsx(ve,{variant:Yk[l.status]||"default",children:Xk[l.status]||l.status})]}),(l.providerName||((o=l.provider)==null?void 0:o.name)||l.tariffName||((c=l.tariff)==null?void 0:c.name))&&s.jsx(X,{title:"Anbieter & Tarif",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[(l.providerName||((d=l.provider)==null?void 0:d.name))&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[l.providerName||((u=l.provider)==null?void 0:u.name),s.jsx(oe,{value:l.providerName||((h=l.provider)==null?void 0:h.name)||""})]})]}),(l.tariffName||((x=l.tariff)==null?void 0:x.name))&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Tarif"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[l.tariffName||((m=l.tariff)==null?void 0:m.name),s.jsx(oe,{value:l.tariffName||((f=l.tariff)==null?void 0:f.name)||""})]})]}),l.customerNumberAtProvider&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kundennummer beim Anbieter"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[l.customerNumberAtProvider,s.jsx(oe,{value:l.customerNumberAtProvider})]})]}),l.contractNumberAtProvider&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsnummer beim Anbieter"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[l.contractNumberAtProvider,s.jsx(oe,{value:l.contractNumberAtProvider})]})]})]})}),(l.type==="ELECTRICITY"||l.type==="GAS")&&((p=l.energyDetails)==null?void 0:p.meter)&&s.jsx(X,{title:"Zähler",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Zählernummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[l.energyDetails.meter.meterNumber,s.jsx(oe,{value:l.energyDetails.meter.meterNumber})]})]}),l.energyDetails.maloId&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"MaLo-ID"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[l.energyDetails.maloId,s.jsx(oe,{value:l.energyDetails.maloId})]})]})]})}),s.jsx(X,{title:"Laufzeit",children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[l.startDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsbeginn"}),s.jsx("dd",{children:new Date(l.startDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),l.endDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsende"}),s.jsx("dd",{children:new Date(l.endDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),l.contractDuration&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Laufzeit"}),s.jsx("dd",{children:l.contractDuration.description})]}),l.cancellationPeriod&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsfrist"}),s.jsx("dd",{children:l.cancellationPeriod.description})]})]})}),(l.portalUsername||((b=l.provider)==null?void 0:b.portalUrl))&&s.jsx(X,{title:"Portal-Zugangsdaten",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[((g=l.provider)==null?void 0:g.portalUrl)&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Portal-URL"}),s.jsx("dd",{children:s.jsx("a",{href:l.provider.portalUrl,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:l.provider.portalUrl})})]}),l.portalUsername&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Benutzername"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[l.portalUsername,s.jsx(oe,{value:l.portalUsername})]})]})]})}),l.address&&s.jsxs(X,{title:"Lieferadresse",children:[s.jsxs("p",{children:[l.address.street," ",l.address.houseNumber]}),s.jsxs("p",{children:[l.address.postalCode," ",l.address.city]})]}),l.notes&&s.jsx(X,{title:"Notizen",children:s.jsx("p",{className:"whitespace-pre-wrap text-gray-700",children:l.notes})})]})]})}function tC({contractId:e,canEdit:t}){const[n,r]=j.useState(!1),[a,i]=j.useState(!1),[l,o]=j.useState(null),c=ge(),{data:d,isLoading:u}=fe({queryKey:["contract-history",e],queryFn:()=>tc.getByContract(e)}),h=G({mutationFn:f=>tc.delete(e,f),onSuccess:()=>{c.invalidateQueries({queryKey:["contract-history",e]})}}),x=(d==null?void 0:d.data)||[],m=[...x].sort((f,p)=>new Date(p.createdAt).getTime()-new Date(f.createdAt).getTime());return s.jsxs("div",{className:"bg-white rounded-lg border p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(O2,{className:"w-4 h-4 text-gray-500"}),s.jsx("h4",{className:"text-sm font-medium text-gray-700",children:"Vertragshistorie"}),s.jsx(ve,{variant:"default",children:x.length})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[t&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>i(!0),children:s.jsx(_e,{className:"w-4 h-4"})}),x.length>0&&s.jsx("button",{onClick:()=>r(!n),className:"text-gray-500 hover:text-gray-700",children:n?s.jsx(Tc,{className:"w-4 h-4"}):s.jsx(dn,{className:"w-4 h-4"})})]})]}),u&&s.jsx("p",{className:"text-sm text-gray-500",children:"Laden..."}),!n&&!u&&m.length>0&&s.jsxs("div",{className:"text-sm text-gray-600",children:[s.jsx("span",{className:"font-medium",children:new Date(m[0].createdAt).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})})," - ",m[0].title]}),n&&!u&&m.length>0&&s.jsx("div",{className:"space-y-2",children:m.map(f=>s.jsxs("div",{className:"flex items-start justify-between p-3 bg-gray-50 rounded-lg group",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("span",{className:"text-sm font-medium text-gray-800",children:f.title}),f.isAutomatic?s.jsxs("span",{className:"flex items-center gap-1 px-1.5 py-0.5 text-xs rounded bg-blue-100 text-blue-700",title:"Automatisch erstellt",children:[s.jsx(D2,{className:"w-3 h-3"}),"Auto"]}):s.jsxs("span",{className:"flex items-center gap-1 px-1.5 py-0.5 text-xs rounded bg-gray-100 text-gray-600",title:"Manuell erstellt",children:[s.jsx(ii,{className:"w-3 h-3"}),"Manuell"]})]}),f.description&&s.jsx("p",{className:"text-sm text-gray-600 whitespace-pre-wrap mb-1",children:f.description}),s.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-400",children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(on,{className:"w-3 h-3"}),new Date(f.createdAt).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})]}),s.jsxs("span",{children:["von ",f.createdBy]})]})]}),t&&!f.isAutomatic&&s.jsxs("div",{className:"flex items-center gap-2 opacity-0 group-hover:opacity-100 ml-3",children:[s.jsx("button",{onClick:()=>o(f),className:"text-gray-500 hover:text-blue-600",title:"Bearbeiten",children:s.jsx(He,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm("Eintrag wirklich löschen?")&&h.mutate(f.id)},className:"text-gray-500 hover:text-red-600",title:"Löschen",children:s.jsx(Ne,{className:"w-4 h-4"})})]})]},f.id))}),n&&!u&&m.length===0&&s.jsx("p",{className:"text-sm text-gray-500 italic",children:"Keine Historie vorhanden."}),(a||l)&&s.jsx(sC,{isOpen:!0,onClose:()=>{i(!1),o(null)},contractId:e,entry:l})]})}function sC({isOpen:e,onClose:t,contractId:n,entry:r}){const a=ge(),i=!!r,[l,o]=j.useState({title:(r==null?void 0:r.title)||"",description:(r==null?void 0:r.description)||""}),[c,d]=j.useState(null),u=G({mutationFn:()=>tc.create(n,{title:l.title,description:l.description||void 0}),onSuccess:()=>{a.invalidateQueries({queryKey:["contract-history",n]}),t()},onError:f=>{d(f.message)}}),h=G({mutationFn:()=>tc.update(n,r.id,{title:l.title,description:l.description||void 0}),onSuccess:()=>{a.invalidateQueries({queryKey:["contract-history",n]}),t()},onError:f=>{d(f.message)}}),x=f=>{if(f.preventDefault(),d(null),!l.title.trim()){d("Titel ist erforderlich");return}i?h.mutate():u.mutate()},m=u.isPending||h.isPending;return s.jsx(qe,{isOpen:e,onClose:t,title:i?"Eintrag bearbeiten":"Historie-Eintrag hinzufügen",children:s.jsxs("form",{onSubmit:x,className:"space-y-4",children:[c&&s.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded-lg text-red-700 text-sm",children:c}),s.jsx(H,{label:"Titel *",value:l.title,onChange:f=>o({...l,title:f.target.value}),placeholder:"z.B. kWh auf 18000 erhöht",required:!0}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung (optional)"}),s.jsx("textarea",{value:l.description,onChange:f=>o({...l,description:f.target.value}),placeholder:"Weitere Details...",rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:m,children:m?"Wird gespeichert...":i?"Speichern":"Hinzufügen"})]})]})})}const Ox={INTERIM:"Zwischenrechnung",FINAL:"Schlussrechnung",NOT_AVAILABLE:"Nicht verfügbar"};function nC({ecdId:e,invoices:t,contractId:n,canEdit:r}){const[a,i]=j.useState(!1),[l,o]=j.useState(!1),[c,d]=j.useState(null),u=ge(),h=G({mutationFn:p=>aa.deleteInvoice(e,p),onSuccess:()=>{u.invalidateQueries({queryKey:["contract",n.toString()]})}}),x=[...t].sort((p,b)=>new Date(b.invoiceDate).getTime()-new Date(p.invoiceDate).getTime()),m=t.some(p=>p.invoiceType==="FINAL"),f=t.some(p=>p.invoiceType==="NOT_AVAILABLE");return s.jsxs("div",{className:"mt-4 pt-4 border-t",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Be,{className:"w-4 h-4 text-gray-500"}),s.jsx("h4",{className:"text-sm font-medium text-gray-700",children:"Rechnungen"}),s.jsx(ve,{variant:"default",children:t.length}),m?s.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded-full bg-green-100 text-green-800",children:[s.jsx(xr,{className:"w-3 h-3"}),"Schlussrechnung"]}):f?s.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded-full bg-yellow-100 text-yellow-800",children:[s.jsx(hs,{className:"w-3 h-3"}),"Nicht verfügbar"]}):t.length>0?s.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded-full bg-orange-100 text-orange-800",children:[s.jsx(hs,{className:"w-3 h-3"}),"Schlussrechnung fehlt"]}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>o(!0),children:s.jsx(_e,{className:"w-4 h-4"})}),t.length>0&&s.jsx("button",{onClick:()=>i(!a),className:"text-gray-500 hover:text-gray-700",children:a?s.jsx(Tc,{className:"w-4 h-4"}):s.jsx(dn,{className:"w-4 h-4"})})]})]}),!a&&x.length>0&&s.jsxs("div",{className:"text-sm text-gray-600",children:["Letzte: ",new Date(x[0].invoiceDate).toLocaleDateString("de-DE")," - ",Ox[x[0].invoiceType]]}),a&&x.length>0&&s.jsx("div",{className:"space-y-2",children:x.map(p=>s.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-lg group",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium",children:new Date(p.invoiceDate).toLocaleDateString("de-DE")}),s.jsx("div",{className:"text-xs text-gray-500",children:Ox[p.invoiceType]})]}),p.documentPath&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("a",{href:`/api${p.documentPath}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-blue-600 hover:text-blue-800 text-sm",title:"Anzeigen",children:s.jsx(Ae,{className:"w-4 h-4"})}),s.jsx("a",{href:`/api${p.documentPath}`,download:!0,className:"flex items-center gap-1 text-blue-600 hover:text-blue-800 text-sm",title:"Download",children:s.jsx(Ps,{className:"w-4 h-4"})})]}),p.notes&&s.jsx("span",{className:"text-xs text-gray-400 italic",children:p.notes})]}),r&&s.jsxs("div",{className:"flex items-center gap-2 opacity-0 group-hover:opacity-100",children:[s.jsx("button",{onClick:()=>d(p),className:"text-gray-500 hover:text-blue-600",title:"Bearbeiten",children:s.jsx(He,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm("Rechnung wirklich löschen?")&&h.mutate(p.id)},className:"text-gray-500 hover:text-red-600",title:"Löschen",children:s.jsx(Ne,{className:"w-4 h-4"})})]})]},p.id))}),a&&x.length===0&&s.jsx("p",{className:"text-sm text-gray-500 italic",children:"Keine Rechnungen vorhanden."}),(l||c)&&s.jsx(rC,{isOpen:!0,onClose:()=>{o(!1),d(null)},ecdId:e,contractId:n,invoice:c})]})}function rC({isOpen:e,onClose:t,ecdId:n,contractId:r,invoice:a}){const i=ge(),l=!!a,o=j.useRef(null),[c,d]=j.useState({invoiceDate:a!=null&&a.invoiceDate?new Date(a.invoiceDate).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],invoiceType:(a==null?void 0:a.invoiceType)||"INTERIM",notes:(a==null?void 0:a.notes)||""}),[u,h]=j.useState(null),[x,m]=j.useState(null),f=G({mutationFn:async N=>{var P;const E=await aa.addInvoice(n,{invoiceDate:c.invoiceDate,invoiceType:c.invoiceType,notes:c.notes||void 0});return(P=E.data)!=null&&P.id&&await aa.uploadDocument(E.data.id,N),E},onSuccess:()=>{i.invalidateQueries({queryKey:["contract",r.toString()]}),t()},onError:N=>{m(N.message)}}),p=G({mutationFn:async()=>await aa.addInvoice(n,{invoiceDate:c.invoiceDate,invoiceType:c.invoiceType,notes:c.notes||void 0}),onSuccess:()=>{i.invalidateQueries({queryKey:["contract",r.toString()]}),t()},onError:N=>{m(N.message)}}),b=G({mutationFn:async N=>{const E=await aa.updateInvoice(n,a.id,{invoiceDate:c.invoiceDate,invoiceType:c.invoiceType,notes:c.notes||void 0});return N&&await aa.uploadDocument(a.id,N),E},onSuccess:()=>{i.invalidateQueries({queryKey:["contract",r.toString()]}),t()},onError:N=>{m(N.message)}}),g=N=>{if(N.preventDefault(),m(null),l){if(c.invoiceType!=="NOT_AVAILABLE"&&!(a!=null&&a.documentPath)&&!u){m("Bitte laden Sie ein Dokument hoch");return}b.mutate(u)}else if(c.invoiceType==="NOT_AVAILABLE")p.mutate();else if(u)f.mutate(u);else{m("Bitte laden Sie ein Dokument hoch");return}},y=N=>{var P;const E=(P=N.target.files)==null?void 0:P[0];if(E){if(E.type!=="application/pdf"){m("Nur PDF-Dateien sind erlaubt");return}if(E.size>10*1024*1024){m("Datei ist zu groß (max. 10 MB)");return}h(E),m(null)}},v=f.isPending||p.isPending||b.isPending;return s.jsx(qe,{isOpen:e,onClose:t,title:l?"Rechnung bearbeiten":"Rechnung hinzufügen",children:s.jsxs("form",{onSubmit:g,className:"space-y-4",children:[x&&s.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded-lg text-red-700 text-sm",children:x}),s.jsx(H,{label:"Rechnungsdatum",type:"date",value:c.invoiceDate,onChange:N=>d({...c,invoiceDate:N.target.value}),required:!0}),s.jsx(Ie,{label:"Rechnungstyp",value:c.invoiceType,onChange:N=>d({...c,invoiceType:N.target.value}),options:[{value:"INTERIM",label:"Zwischenrechnung"},{value:"FINAL",label:"Schlussrechnung"},{value:"NOT_AVAILABLE",label:"Nicht verfügbar"}]}),c.invoiceType!=="NOT_AVAILABLE"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Dokument (PDF) *"}),(a==null?void 0:a.documentPath)&&!u&&s.jsxs("div",{className:"mb-2 text-sm text-green-600 flex items-center gap-1",children:[s.jsx(xr,{className:"w-4 h-4"}),"Dokument vorhanden"]}),u&&s.jsxs("div",{className:"mb-2 text-sm text-blue-600 flex items-center gap-1",children:[s.jsx(Be,{className:"w-4 h-4"}),u.name]}),s.jsx("input",{type:"file",ref:o,accept:".pdf",onChange:y,className:"hidden"}),s.jsx(T,{type:"button",variant:"secondary",onClick:()=>{var N;return(N=o.current)==null?void 0:N.click()},children:a!=null&&a.documentPath||u?"Ersetzen":"PDF hochladen"})]}),c.invoiceType==="NOT_AVAILABLE"&&s.jsx("div",{className:"p-3 bg-yellow-50 border border-yellow-200 rounded-lg text-yellow-800 text-sm",children:'Bei diesem Typ wird kein Dokument benötigt. Die Rechnung wird als "nicht mehr zu bekommen" markiert.'}),s.jsx(H,{label:"Notizen (optional)",value:c.notes,onChange:N=>d({...c,notes:N.target.value}),placeholder:"Optionale Anmerkungen..."}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:v,children:v?"Wird gespeichert...":l?"Speichern":"Hinzufügen"})]})]})})}const aC=10.5;function zx(e,t){const n=new Date(e),r=new Date(t);n.setHours(0,0,0,0),r.setHours(0,0,0,0);const a=r.getTime()-n.getTime();return Math.ceil(a/(1e3*60*60*24))}function iC(e,t,n){const r=new Date(t),a=new Date(n);return r.setHours(0,0,0,0),a.setHours(0,0,0,0),e.filter(i=>{const l=new Date(i.readingDate);return l.setHours(0,0,0,0),l>=r&&l<=a})}function lC(e,t,n,r){const a=iC(e,t,n);if(a.length===0)return{type:"none",consumptionKwh:0};if(a.length===1)return{type:"insufficient",consumptionKwh:0,message:"Berechnung auf Grund fehlender Stände nicht möglich"};const i=[...a].sort((f,p)=>new Date(f.readingDate).getTime()-new Date(p.readingDate).getTime()),l=i[0],o=i[i.length-1],c=new Date(o.readingDate),d=new Date(n);if(c.setHours(0,0,0,0),d.setHours(0,0,0,0),c>=d){const f=o.value-l.value;return $x("exact",f,r,l,o)}const u=zx(l.readingDate,o.readingDate);if(u<1)return{type:"insufficient",consumptionKwh:0,message:"Zeitraum zwischen Zählerständen zu kurz für Berechnung"};const h=zx(t,n),m=(o.value-l.value)/u*h;return $x("projected",m,r,l,o,n)}function $x(e,t,n,r,a,i){return n==="GAS"?{type:e,consumptionM3:t,consumptionKwh:t*aC,startReading:r,endReading:a,projectedEndDate:i}:{type:e,consumptionKwh:t,startReading:r,endReading:a,projectedEndDate:i}}function oC(e,t,n,r){if(t==null&&n==null)return null;const a=(t??0)*12,i=e*(n??0),l=a+i,o=l-(r??0),c=o/12;return{annualBaseCost:a,annualConsumptionCost:i,annualTotalCost:l,monthlyPayment:c,bonus:r??void 0,effectiveAnnualCost:o}}const cC={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabelinternet",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},dC={DRAFT:"Entwurf",PENDING:"Ausstehend",ACTIVE:"Aktiv",CANCELLED:"Gekündigt",EXPIRED:"Abgelaufen",DEACTIVATED:"Deaktiviert"},uC={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"},mC=[{status:"DRAFT",label:"Entwurf",description:"Vertrag wird noch vorbereitet",color:"text-gray-600"},{status:"PENDING",label:"Ausstehend",description:"Wartet auf Aktivierung",color:"text-yellow-600"},{status:"ACTIVE",label:"Aktiv",description:"Vertrag läuft normal",color:"text-green-600"},{status:"EXPIRED",label:"Abgelaufen",description:"Laufzeit vorbei, läuft aber ohne Kündigung weiter",color:"text-orange-600"},{status:"CANCELLED",label:"Gekündigt",description:"Aktive Kündigung eingereicht, Vertrag endet",color:"text-red-600"},{status:"DEACTIVATED",label:"Deaktiviert",description:"Manuell beendet/archiviert",color:"text-gray-500"}];function hC({isOpen:e,onClose:t}){return e?s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"fixed inset-0 bg-black/20",onClick:t}),s.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl p-4 max-w-sm w-full mx-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:"Vertragsstatus-Übersicht"}),s.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600",children:s.jsx(qt,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"space-y-2",children:mC.map(({status:n,label:r,description:a,color:i})=>s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:`font-medium text-sm min-w-[90px] ${i}`,children:r}),s.jsx("span",{className:"text-sm text-gray-600",children:a})]},n))})]})]}):null}function fC(e){const t=e.match(/^(\d+)([TMWJ])$/);if(!t)return!1;const n=parseInt(t[1]),r=t[2];let a=0;return r==="T"?a=n:r==="W"?a=n*7:r==="M"?a=n*30:r==="J"&&(a=n*365),a<=30}function pC({simCard:e}){const[t,n]=j.useState(!1),[r,a]=j.useState(null),[i,l]=j.useState(!1),o=async()=>{if(t)n(!1),a(null);else{l(!0);try{const c=await Oe.getSimCardCredentials(e.id);c.data&&(a(c.data),n(!0))}catch{alert("PIN/PUK konnte nicht geladen werden")}finally{l(!1)}}};return s.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg border",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.isMain&&s.jsx(ve,{variant:"success",children:"Hauptkarte"}),e.isMultisim&&s.jsx(ve,{variant:"warning",children:"Multisim"})]}),s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-sm",children:[e.phoneNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Rufnummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[e.phoneNumber,s.jsx(oe,{value:e.phoneNumber})]})]}),e.simCardNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"SIM-Nr."}),s.jsxs("dd",{className:"font-mono text-xs flex items-center gap-1",children:[e.simCardNumber,s.jsx(oe,{value:e.simCardNumber})]})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"PIN"}),s.jsx("dd",{className:"font-mono flex items-center gap-1",children:t&&(r!=null&&r.pin)?s.jsxs(s.Fragment,{children:[r.pin,s.jsx(oe,{value:r.pin})]}):"••••"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"PUK"}),s.jsx("dd",{className:"font-mono flex items-center gap-1",children:t&&(r!=null&&r.puk)?s.jsxs(s.Fragment,{children:[r.puk,s.jsx(oe,{value:r.puk})]}):"••••••••"})]})]}),s.jsx("div",{className:"mt-2",children:s.jsx(T,{variant:"ghost",size:"sm",onClick:o,disabled:i,children:i?"Laden...":t?s.jsxs(s.Fragment,{children:[s.jsx(It,{className:"w-4 h-4 mr-1"})," PIN/PUK verbergen"]}):s.jsxs(s.Fragment,{children:[s.jsx(Ae,{className:"w-4 h-4 mr-1"})," PIN/PUK anzeigen"]})})})]})}function xC({meterId:e,meterType:t,readings:n,contractId:r,canEdit:a}){const[i,l]=j.useState(!1),[o,c]=j.useState(!1),[d,u]=j.useState(null),h=ge(),x=G({mutationFn:p=>ln.deleteReading(e,p),onSuccess:()=>{h.invalidateQueries({queryKey:["contract",r.toString()]})}}),m=[...n].sort((p,b)=>new Date(b.readingDate).getTime()-new Date(p.readingDate).getTime()),f=t==="ELECTRICITY"?"kWh":"m³";return s.jsxs("div",{className:"mt-4 pt-4 border-t",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Dv,{className:"w-4 h-4 text-gray-500"}),s.jsx("h4",{className:"text-sm font-medium text-gray-700",children:"Zählerstände"}),s.jsx(ve,{variant:"default",children:n.length})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[a&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>c(!0),title:"Zählerstand erfassen",children:s.jsx(_e,{className:"w-4 h-4"})}),n.length>0&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>l(!i),children:i?s.jsx(Tc,{className:"w-4 h-4"}):s.jsx(dn,{className:"w-4 h-4"})})]})]}),i&&n.length>0&&s.jsx("div",{className:"space-y-2 bg-gray-50 rounded-lg p-3",children:m.map(p=>s.jsxs("div",{className:"flex justify-between items-center text-sm group py-1 border-b border-gray-200 last:border-0",children:[s.jsxs("span",{className:"text-gray-500 flex items-center gap-1",children:[new Date(p.readingDate).toLocaleDateString("de-DE"),s.jsx(oe,{value:new Date(p.readingDate).toLocaleDateString("de-DE")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"font-mono flex items-center gap-1",children:[p.value.toLocaleString("de-DE")," ",p.unit,s.jsx(oe,{value:p.value.toString(),title:"Nur Wert kopieren"})]}),a&&s.jsxs("div",{className:"opacity-0 group-hover:opacity-100 flex gap-1",children:[s.jsx("button",{onClick:()=>u(p),className:"text-gray-400 hover:text-blue-600",title:"Bearbeiten",children:s.jsx(He,{className:"w-3 h-3"})}),s.jsx("button",{onClick:()=>{confirm("Zählerstand wirklich löschen?")&&x.mutate(p.id)},className:"text-gray-400 hover:text-red-600",title:"Löschen",children:s.jsx(Ne,{className:"w-3 h-3"})})]})]})]},p.id))}),!i&&n.length>0&&s.jsxs("p",{className:"text-sm text-gray-500",children:["Letzter Stand: ",m[0].value.toLocaleString("de-DE")," ",m[0].unit," (",new Date(m[0].readingDate).toLocaleDateString("de-DE"),")"]}),n.length===0&&s.jsx("p",{className:"text-sm text-gray-500",children:"Keine Zählerstände vorhanden."}),(o||d)&&s.jsx(gC,{isOpen:!0,onClose:()=>{c(!1),u(null)},meterId:e,contractId:r,reading:d,defaultUnit:f})]})}function gC({isOpen:e,onClose:t,meterId:n,contractId:r,reading:a,defaultUnit:i}){var f;const l=ge(),o=!!a,[c,d]=j.useState({readingDate:a!=null&&a.readingDate?new Date(a.readingDate).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],value:((f=a==null?void 0:a.value)==null?void 0:f.toString())||"",notes:(a==null?void 0:a.notes)||""}),u=G({mutationFn:p=>ln.addReading(n,p),onSuccess:()=>{l.invalidateQueries({queryKey:["contract",r.toString()]}),t()}}),h=G({mutationFn:p=>ln.updateReading(n,a.id,p),onSuccess:()=>{l.invalidateQueries({queryKey:["contract",r.toString()]}),t()}}),x=p=>{p.preventDefault();const b={readingDate:new Date(c.readingDate),value:parseFloat(c.value),unit:i,notes:c.notes||void 0};o?h.mutate(b):u.mutate(b)},m=u.isPending||h.isPending;return s.jsx(qe,{isOpen:e,onClose:t,title:o?"Zählerstand bearbeiten":"Zählerstand erfassen",children:s.jsxs("form",{onSubmit:x,className:"space-y-4",children:[s.jsx(H,{label:"Ablesedatum",type:"date",value:c.readingDate,onChange:p=>d({...c,readingDate:p.target.value}),required:!0}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsx("div",{className:"col-span-2",children:s.jsx(H,{label:"Zählerstand",type:"number",step:"0.01",value:c.value,onChange:p=>d({...c,value:p.target.value}),required:!0})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Einheit"}),s.jsx("div",{className:"h-10 flex items-center px-3 bg-gray-100 border border-gray-300 rounded-md text-gray-700",children:i})]})]}),s.jsx(H,{label:"Notizen (optional)",value:c.notes,onChange:p=>d({...c,notes:p.target.value})}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:m||!c.value,children:m?"Speichern...":o?"Speichern":"Erfassen"})]})]})})}function yC({contractType:e,readings:t,startDate:n,endDate:r,basePrice:a,unitPrice:i,bonus:l}){const o=lC(t,n,r,e),c=o.consumptionKwh>0?oC(o.consumptionKwh,a,i,l):null;if(o.type==="none")return null;const d=(h,x=2)=>h.toLocaleString("de-DE",{minimumFractionDigits:x,maximumFractionDigits:x}),u=h=>new Date(h).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"});return s.jsxs("div",{className:"mt-4 pt-4 border-t",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(M2,{className:"w-4 h-4 text-gray-500"}),s.jsx("h4",{className:"text-sm font-medium text-gray-700",children:"Verbrauch & Kosten"}),o.type==="exact"&&s.jsx(ve,{variant:"success",children:"Exakt"}),o.type==="projected"&&s.jsx(ve,{variant:"warning",children:"Hochrechnung"})]}),o.type==="insufficient"?s.jsx("p",{className:"text-sm text-gray-500 italic",children:o.message}):s.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsxs("h5",{className:"text-sm font-medium text-gray-600 mb-2",children:["Berechneter Verbrauch",o.type==="projected"&&" (hochgerechnet)"]}),s.jsx("div",{className:"text-lg font-semibold text-gray-900",children:e==="GAS"?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"font-mono",children:[d(o.consumptionM3||0)," m³"]}),s.jsxs("span",{className:"text-gray-500 text-sm ml-2",children:["= ",d(o.consumptionKwh)," kWh"]})]}):s.jsxs("span",{className:"font-mono",children:[d(o.consumptionKwh)," kWh"]})}),o.startReading&&o.endReading&&s.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:["Basierend auf Zählerständen vom ",u(o.startReading.readingDate)," bis ",u(o.endReading.readingDate)]})]}),c&&s.jsxs("div",{className:"border-t border-gray-200 pt-4",children:[s.jsx("h5",{className:"text-sm font-medium text-gray-600 mb-3",children:"Kostenvorschau"}),s.jsxs("div",{className:"space-y-2 text-sm",children:[a!=null&&a>0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsxs("span",{className:"text-gray-600",children:["Grundpreis: ",d(a)," €/Mon × 12"]}),s.jsxs("span",{className:"font-mono",children:[d(c.annualBaseCost)," €"]})]}),i!=null&&i>0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsxs("span",{className:"text-gray-600",children:["Arbeitspreis: ",d(o.consumptionKwh)," kWh × ",d(i,4)," €"]}),s.jsxs("span",{className:"font-mono",children:[d(c.annualConsumptionCost)," €"]})]}),s.jsx("div",{className:"border-t border-gray-300 pt-2",children:s.jsxs("div",{className:"flex justify-between font-medium",children:[s.jsx("span",{className:"text-gray-700",children:"Jahreskosten"}),s.jsxs("span",{className:"font-mono",children:[d(c.annualTotalCost)," €"]})]})}),c.bonus!=null&&c.bonus>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex justify-between text-green-600",children:[s.jsx("span",{children:"Bonus"}),s.jsxs("span",{className:"font-mono",children:["- ",d(c.bonus)," €"]})]}),s.jsx("div",{className:"border-t border-gray-300 pt-2",children:s.jsxs("div",{className:"flex justify-between font-semibold",children:[s.jsx("span",{className:"text-gray-800",children:"Effektive Jahreskosten"}),s.jsxs("span",{className:"font-mono",children:[d(c.effectiveAnnualCost)," €"]})]})})]}),s.jsx("div",{className:"border-t border-gray-300 pt-2 mt-2",children:s.jsxs("div",{className:"flex justify-between text-blue-700 font-semibold",children:[s.jsx("span",{children:"Monatlicher Abschlag"}),s.jsxs("span",{className:"font-mono",children:[d(c.monthlyPayment)," €"]})]})})]})]})]})]})}function _x({task:e,contractId:t,canEdit:n,isCustomerPortal:r,isCompleted:a,onEdit:i}){const[l,o]=j.useState(""),[c,d]=j.useState(!1),[u,h]=j.useState(null),[x,m]=j.useState(""),f=ge(),p=G({mutationFn:K=>et.complete(K),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),b=G({mutationFn:K=>et.reopen(K),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),g=G({mutationFn:K=>et.delete(K),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),y=G({mutationFn:K=>et.createSubtask(e.id,K),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]}),o(""),d(!1)},onError:K=>{console.error("Fehler beim Erstellen der Unteraufgabe:",K),alert("Fehler beim Erstellen der Unteraufgabe. Bitte versuchen Sie es erneut.")}}),v=G({mutationFn:K=>et.createReply(e.id,K),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]}),o(""),d(!1)},onError:K=>{console.error("Fehler beim Erstellen der Antwort:",K),alert("Fehler beim Erstellen der Antwort. Bitte versuchen Sie es erneut.")}}),N=G({mutationFn:({id:K,title:B})=>et.updateSubtask(K,B),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]}),h(null),m("")}}),E=G({mutationFn:K=>et.completeSubtask(K),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),P=G({mutationFn:K=>et.reopenSubtask(K),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),I=G({mutationFn:K=>et.deleteSubtask(K),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),w=K=>{K.preventDefault(),l.trim()&&(r?v.mutate(l.trim()):y.mutate(l.trim()))},S=K=>{K.preventDefault(),x.trim()&&u&&N.mutate({id:u,title:x.trim()})},A=(K,B)=>{h(K),m(B)},O=()=>{h(null),m("")},R=e.subtasks||[],q=R.filter(K=>K.status==="OPEN"),D=R.filter(K=>K.status==="COMPLETED"),z=r?{singular:"Antwort",placeholder:"Antwort...",deleteConfirm:"Antwort löschen?"}:{singular:"Unteraufgabe",placeholder:"Unteraufgabe...",deleteConfirm:"Unteraufgabe löschen?"},k=(K,B)=>u===K.id?s.jsx("div",{className:"py-1",children:s.jsxs("form",{onSubmit:S,className:"flex items-center gap-2",children:[s.jsx(No,{className:"w-4 h-4 text-gray-300 flex-shrink-0"}),s.jsx("input",{type:"text",value:x,onChange:Q=>m(Q.target.value),className:"flex-1 text-sm px-2 py-1 border rounded focus:outline-none focus:ring-1 focus:ring-blue-500",autoFocus:!0}),s.jsx(T,{type:"submit",size:"sm",disabled:!x.trim()||N.isPending,children:"✓"}),s.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:O,children:"×"})]})},K.id):s.jsx("div",{className:`py-1 group/subtask ${B?"opacity-60":""}`,children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("button",{onClick:()=>B?P.mutate(K.id):E.mutate(K.id),disabled:E.isPending||P.isPending||r,className:`flex-shrink-0 mt-0.5 ${r?"cursor-default":B?"hover:text-yellow-600":"hover:text-green-600"}`,children:B?s.jsx(As,{className:"w-4 h-4 text-green-500"}):s.jsx(No,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:`text-sm ${B?"line-through text-gray-500":""}`,children:K.title}),n&&!r&&!B&&s.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover/subtask:opacity-100",children:[s.jsx("button",{onClick:()=>A(K.id,K.title),className:"text-gray-400 hover:text-blue-600 p-0.5",title:"Bearbeiten",children:s.jsx(He,{className:"w-3 h-3"})}),s.jsx("button",{onClick:()=>{confirm(z.deleteConfirm)&&I.mutate(K.id)},className:"text-gray-400 hover:text-red-600 p-0.5",title:"Löschen",children:s.jsx(Ne,{className:"w-3 h-3"})})]}),n&&!r&&B&&s.jsx("button",{onClick:()=>{confirm(z.deleteConfirm)&&I.mutate(K.id)},className:"text-gray-400 hover:text-red-600 p-0.5 opacity-0 group-hover/subtask:opacity-100",title:"Löschen",children:s.jsx(Ne,{className:"w-3 h-3"})})]}),s.jsxs("p",{className:"text-xs text-gray-400",children:[K.createdBy&&`${K.createdBy} • `,B?`Erledigt am ${K.completedAt?new Date(K.completedAt).toLocaleDateString("de-DE"):new Date(K.updatedAt).toLocaleDateString("de-DE")}`:new Date(K.createdAt).toLocaleDateString("de-DE")]})]})]})},K.id);return s.jsx("div",{className:`p-3 bg-gray-50 rounded-lg group ${a?"bg-gray-50/50 opacity-70":""}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>a?b.mutate(e.id):p.mutate(e.id),disabled:p.isPending||b.isPending||r,className:`mt-0.5 flex-shrink-0 ${r?"cursor-default":a?"hover:text-yellow-600":"hover:text-green-600"}`,title:r?void 0:a?"Wieder öffnen":"Als erledigt markieren",children:a?s.jsx(As,{className:"w-5 h-5 text-green-500"}):s.jsx(No,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`font-medium ${a?"line-through text-gray-500":""}`,children:e.title}),e.visibleInPortal&&s.jsx(ve,{variant:"default",className:"text-xs",children:"Portal"}),R.length>0&&s.jsxs("span",{className:"text-xs text-gray-400",children:["(",D.length,"/",R.length,")"]})]}),e.description&&s.jsx("p",{className:`text-sm mt-1 whitespace-pre-wrap ${a?"text-gray-500":"text-gray-600"}`,children:e.description}),s.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:[e.createdBy&&`${e.createdBy} • `,a?`Erledigt am ${e.completedAt?new Date(e.completedAt).toLocaleDateString("de-DE"):"-"}`:new Date(e.createdAt).toLocaleDateString("de-DE")]}),R.length>0&&s.jsxs("div",{className:"mt-3 ml-2 space-y-0 border-l-2 border-gray-200 pl-3",children:[q.map(K=>k(K,!1)),D.map(K=>k(K,!0))]}),!a&&(n&&!r||r)&&s.jsx("div",{className:"mt-2 ml-2",children:c?s.jsxs("form",{onSubmit:w,className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",value:l,onChange:K=>o(K.target.value),placeholder:z.placeholder,className:"flex-1 text-sm px-2 py-1 border rounded focus:outline-none focus:ring-1 focus:ring-blue-500",autoFocus:!0}),s.jsx(T,{type:"submit",size:"sm",disabled:!l.trim()||y.isPending||v.isPending,children:s.jsx(_e,{className:"w-3 h-3"})}),s.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:()=>{d(!1),o("")},children:"×"})]}):s.jsxs("button",{onClick:()=>d(!0),className:"text-xs text-gray-400 hover:text-blue-600 flex items-center gap-1",children:[s.jsx(_e,{className:"w-3 h-3"}),z.singular]})})]}),n&&!r&&s.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100",children:[!a&&s.jsx("button",{onClick:i,className:"text-gray-400 hover:text-blue-600 p-1",title:"Bearbeiten",children:s.jsx(He,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm("Aufgabe wirklich löschen?")&&g.mutate(e.id)},className:"text-gray-400 hover:text-red-600 p-1",title:"Löschen",children:s.jsx(Ne,{className:"w-4 h-4"})})]})]})})}function vC({contractId:e,canEdit:t,isCustomerPortal:n}){var v;const[r,a]=j.useState(!1),[i,l]=j.useState(null),{data:o,isLoading:c}=fe({queryKey:["contract-tasks",e],queryFn:()=>et.getByContract(e),staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:d,isLoading:u}=fe({queryKey:["app-settings-public"],queryFn:()=>Xr.getPublic(),enabled:n,staleTime:0}),h=!u&&((v=d==null?void 0:d.data)==null?void 0:v.customerSupportTicketsEnabled)==="true",x=(o==null?void 0:o.data)||[],m=x.filter(N=>N.status==="OPEN"),f=x.filter(N=>N.status==="COMPLETED"),p=n?{title:"Support-Anfragen",button:"Anfrage erstellen",empty:"Keine Support-Anfragen vorhanden."}:{title:"Aufgaben",button:"Aufgabe",empty:"Keine Aufgaben vorhanden."},b=n?ul:dl;if(c||n&&u)return s.jsx(X,{className:"mb-6",title:p.title,children:s.jsx("div",{className:"text-center py-4 text-gray-500",children:"Laden..."})});const y=t&&!n||n&&h;return s.jsxs(X,{className:"mb-6",title:p.title,children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(b,{className:"w-5 h-5 text-gray-500"}),s.jsxs("span",{className:"text-sm text-gray-600",children:[m.length," offen, ",f.length," erledigt"]})]}),y&&s.jsxs(T,{size:"sm",onClick:()=>a(!0),children:[s.jsx(_e,{className:"w-4 h-4 mr-1"}),p.button]})]}),x.length===0?s.jsx("p",{className:"text-center py-4 text-gray-500",children:p.empty}):s.jsxs("div",{className:"space-y-2",children:[m.map(N=>s.jsx(_x,{task:N,contractId:e,canEdit:t,isCustomerPortal:n,isCompleted:!1,onEdit:()=>l(N)},N.id)),f.length>0&&m.length>0&&s.jsx("div",{className:"border-t my-3"}),f.map(N=>s.jsx(_x,{task:N,contractId:e,canEdit:t,isCustomerPortal:n,isCompleted:!0,onEdit:()=>{}},N.id))]}),(r||i)&&s.jsx(jC,{isOpen:!0,onClose:()=>{a(!1),l(null)},contractId:e,task:i,isCustomerPortal:n})]})}function jC({isOpen:e,onClose:t,contractId:n,task:r,isCustomerPortal:a=!1}){const i=ge(),l=!!r,[o,c]=j.useState({title:(r==null?void 0:r.title)||"",description:(r==null?void 0:r.description)||"",visibleInPortal:(r==null?void 0:r.visibleInPortal)||!1});j.useEffect(()=>{e&&c({title:(r==null?void 0:r.title)||"",description:(r==null?void 0:r.description)||"",visibleInPortal:(r==null?void 0:r.visibleInPortal)||!1})},[e,r]);const d=G({mutationFn:p=>et.create(n,p),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",n]}),t()}}),u=G({mutationFn:p=>et.createSupportTicket(n,p),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",n]}),t()}}),h=G({mutationFn:p=>et.update(r.id,p),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",n]}),t()}}),x=p=>{p.preventDefault(),l?h.mutate({title:o.title,description:o.description||void 0,visibleInPortal:o.visibleInPortal}):a?u.mutate({title:o.title,description:o.description||void 0}):d.mutate({title:o.title,description:o.description||void 0,visibleInPortal:o.visibleInPortal})},m=d.isPending||u.isPending||h.isPending,f=a?{modalTitle:l?"Anfrage bearbeiten":"Neue Support-Anfrage",titleLabel:"Betreff",titlePlaceholder:"Kurze Beschreibung Ihrer Anfrage",descLabel:"Ihre Nachricht",descPlaceholder:"Beschreiben Sie Ihr Anliegen...",submitBtn:l?"Speichern":"Anfrage senden"}:{modalTitle:l?"Aufgabe bearbeiten":"Neue Aufgabe",titleLabel:"Titel",titlePlaceholder:"Kurze Beschreibung der Aufgabe",descLabel:"Beschreibung (optional)",descPlaceholder:"Details zur Aufgabe...",submitBtn:l?"Speichern":"Erstellen"};return s.jsx(qe,{isOpen:e,onClose:t,title:f.modalTitle,children:s.jsxs("form",{onSubmit:x,className:"space-y-4",children:[s.jsx(H,{label:f.titleLabel,value:o.title,onChange:p=>c({...o,title:p.target.value}),required:!0,placeholder:f.titlePlaceholder}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:f.descLabel}),s.jsx("textarea",{value:o.description,onChange:p=>c({...o,description:p.target.value}),className:"w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",rows:a?5:3,placeholder:f.descPlaceholder})]}),!a&&s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:o.visibleInPortal,onChange:p=>c({...o,visibleInPortal:p.target.checked}),className:"w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),s.jsx("span",{className:"text-sm text-gray-700",children:"Im Kundenportal sichtbar"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:m||!o.title.trim(),children:m?"Speichern...":f.submitBtn})]})]})})}function bC(){var nt,es,Vt,ae,Ge,xt;const{id:e}=Nc(),t=Yt(),r=Rn().state,a=ge(),{hasPermission:i,isCustomer:l,isCustomerPortal:o}=We(),c=parseInt(e),[d,u]=j.useState(!1),[h,x]=j.useState(null),[m,f]=j.useState(!1),[p,b]=j.useState(!1),[g,y]=j.useState(null),[v,N]=j.useState({}),[E,P]=j.useState({}),[I,w]=j.useState(!1),[S,A]=j.useState(!1),[O,R]=j.useState(!1),[q,D]=j.useState(!1),{data:z,isLoading:k}=fe({queryKey:["contract",e],queryFn:()=>Oe.getById(c)}),K=G({mutationFn:()=>Oe.delete(c),onSuccess:()=>{t("/contracts")}}),B=G({mutationFn:()=>Oe.createFollowUp(c),onSuccess:Z=>{Z.data?t(`/contracts/${Z.data.id}/edit`):alert("Folgevertrag wurde erstellt, aber keine ID zurückgegeben")},onError:Z=>{console.error("Folgevertrag Fehler:",Z),alert(`Fehler beim Erstellen des Folgevertrags: ${Z instanceof Error?Z.message:"Unbekannter Fehler"}`)}}),_=G({mutationFn:()=>Oe.snooze(c,{}),onSuccess:()=>{a.invalidateQueries({queryKey:["contract",e]}),a.invalidateQueries({queryKey:["contract-cockpit"]}),D(!1)},onError:Z=>{console.error("Un-Snooze Fehler:",Z),alert(`Fehler beim Aufheben der Zurückstellung: ${Z instanceof Error?Z.message:"Unbekannter Fehler"}`)}}),Q=G({mutationFn:Z=>{const Xe={cancellationConfirmationDate:Z?new Date(Z).toISOString():null};return Oe.update(c,Xe)},onSuccess:()=>{a.invalidateQueries({queryKey:["contract",e]}),a.invalidateQueries({queryKey:["contract-cockpit"]})},onError:Z=>{console.error("Fehler beim Speichern des Datums:",Z),alert("Fehler beim Speichern des Datums")}}),le=G({mutationFn:Z=>{const Xe={cancellationConfirmationOptionsDate:Z?new Date(Z).toISOString():null};return Oe.update(c,Xe)},onSuccess:()=>{a.invalidateQueries({queryKey:["contract",e]}),a.invalidateQueries({queryKey:["contract-cockpit"]})},onError:Z=>{console.error("Fehler beim Speichern des Datums:",Z),alert("Fehler beim Speichern des Datums")}}),de=async()=>{var Z;if(d)u(!1),x(null);else try{const Fe=await Oe.getPassword(c);(Z=Fe.data)!=null&&Z.password&&(x(Fe.data.password),u(!0))}catch{alert("Passwort konnte nicht entschlüsselt werden")}},Ke=async()=>{var Z;if(p)b(!1),y(null);else try{const Fe=await Oe.getInternetCredentials(c);(Z=Fe.data)!=null&&Z.password&&(y(Fe.data.password),b(!0))}catch{alert("Internet-Passwort konnte nicht entschlüsselt werden")}},Ve=async Z=>{var Fe;if(v[Z])N(Xe=>({...Xe,[Z]:!1})),P(Xe=>({...Xe,[Z]:null}));else try{const J=(Fe=(await Oe.getSipCredentials(Z)).data)==null?void 0:Fe.password;J&&(P(ue=>({...ue,[Z]:J})),N(ue=>({...ue,[Z]:!0})))}catch{alert("SIP-Passwort konnte nicht entschlüsselt werden")}},st=async()=>{var Xe,J,ue;const Z=z==null?void 0:z.data,Fe=((Xe=Z==null?void 0:Z.stressfreiEmail)==null?void 0:Xe.email)||(Z==null?void 0:Z.portalUsername);if(!((J=Z==null?void 0:Z.provider)!=null&&J.portalUrl)||!Fe){alert("Portal-URL oder Benutzername fehlt");return}f(!0);try{const ts=await Oe.getPassword(c);if(!((ue=ts.data)!=null&&ue.password)){alert("Passwort konnte nicht entschlüsselt werden");return}const un=Z.provider,gt=un.portalUrl,L=un.usernameFieldName||"username",U=un.passwordFieldName||"password",W=new URL(gt);W.searchParams.set(L,Fe),W.searchParams.set(U,ts.data.password),window.open(W.toString(),"_blank")}catch{alert("Fehler beim Auto-Login")}finally{f(!1)}};if(k)return s.jsx("div",{className:"text-center py-8",children:"Laden..."});if(!(z!=null&&z.data))return s.jsx("div",{className:"text-center py-8 text-red-600",children:"Vertrag nicht gefunden"});const C=z.data;return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{if((r==null?void 0:r.from)==="customer"&&(r!=null&&r.customerId))t(`/customers/${r.customerId}?tab=contracts`);else if((r==null?void 0:r.from)==="cockpit"){const Z=r.filter?`?filter=${r.filter}`:"";t(`/contracts/cockpit${Z}`)}else(r==null?void 0:r.from)==="contracts"?t("/contracts"):C.customer?t(`/customers/${C.customer.id}?tab=contracts`):t("/contracts")},children:s.jsx(Vs,{className:"w-4 h-4"})}),s.jsx("h1",{className:"text-2xl font-bold",children:C.contractNumber}),s.jsx(ve,{children:cC[C.type]}),s.jsx(ve,{variant:uC[C.status],children:dC[C.status]}),s.jsx("button",{onClick:()=>R(!0),className:"text-gray-400 hover:text-blue-600 transition-colors",title:"Status-Erklärung",children:s.jsx(Ml,{className:"w-4 h-4"})}),C.nextReviewDate&&new Date(C.nextReviewDate)>new Date&&s.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 bg-amber-100 text-amber-800 rounded-full text-xs",children:[s.jsx(Sv,{className:"w-3 h-3"}),s.jsxs("span",{children:["Zurückgestellt bis ",new Date(C.nextReviewDate).toLocaleDateString("de-DE")]}),i("contracts:update")&&s.jsx("button",{onClick:()=>D(!0),className:"ml-1 p-0.5 hover:bg-amber-200 rounded",title:"Zurückstellung aufheben",children:s.jsx(qt,{className:"w-3 h-3"})})]})]}),C.customer&&s.jsxs("p",{className:"text-gray-500 ml-10",children:["Kunde:"," ",s.jsx(ke,{to:`/customers/${C.customer.id}`,className:"text-blue-600 hover:underline",children:C.customer.companyName||`${C.customer.firstName} ${C.customer.lastName}`})]})]}),!l&&s.jsxs("div",{className:"flex gap-2",children:[C.previousContract&&s.jsx(ke,{to:`/contracts/${C.previousContract.id}`,children:s.jsxs(T,{variant:"secondary",children:[s.jsx(Vs,{className:"w-4 h-4 mr-2"}),"Vorgängervertrag"]})}),i("contracts:create")&&!C.followUpContract&&s.jsxs(T,{variant:"secondary",onClick:()=>A(!0),disabled:B.isPending,children:[s.jsx(oh,{className:"w-4 h-4 mr-2"}),B.isPending?"Erstelle...":"Folgevertrag anlegen"]}),C.followUpContract&&s.jsx(ke,{to:`/contracts/${C.followUpContract.id}`,children:s.jsxs(T,{variant:"secondary",children:[s.jsx(wv,{className:"w-4 h-4 mr-2"}),"Folgevertrag anzeigen"]})}),i("contracts:update")&&s.jsx(ke,{to:`/contracts/${e}/edit`,children:s.jsxs(T,{variant:"secondary",children:[s.jsx(He,{className:"w-4 h-4 mr-2"}),"Bearbeiten"]})}),i("contracts:delete")&&s.jsxs(T,{variant:"danger",onClick:()=>{confirm("Vertrag wirklich löschen?")&&K.mutate()},children:[s.jsx(Ne,{className:"w-4 h-4 mr-2"}),"Löschen"]})]})]}),C.previousContract&&s.jsx(X,{className:"mb-6 border-l-4 border-l-blue-500",title:"Vorgängervertrag",children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsnummer"}),s.jsx("dd",{children:s.jsx("button",{onClick:()=>w(!0),className:"text-blue-600 hover:underline",children:C.previousContract.contractNumber})})]}),C.previousContract.providerName&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),s.jsx("dd",{children:C.previousContract.providerName})]}),C.previousContract.customerNumberAtProvider&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kundennummer"}),s.jsx("dd",{className:"font-mono",children:C.previousContract.customerNumberAtProvider})]}),C.previousContract.contractNumberAtProvider&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsnummer"}),s.jsx("dd",{className:"font-mono",children:C.previousContract.contractNumberAtProvider})]}),C.previousContract.portalUsername&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Zugangsdaten"}),s.jsx("dd",{children:C.previousContract.portalUsername})]})]})}),!C.previousContract&&(C.previousProvider||C.previousCustomerNumber||C.previousContractNumber)&&s.jsx(X,{className:"mb-6 border-l-4 border-l-gray-400",title:"Altanbieter",children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[C.previousProvider&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),s.jsx("dd",{children:C.previousProvider.name})]}),C.previousCustomerNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kundennummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[C.previousCustomerNumber,s.jsx(oe,{value:C.previousCustomerNumber})]})]}),C.previousContractNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsnummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[C.previousContractNumber,s.jsx(oe,{value:C.previousContractNumber})]})]})]})}),C.cancellationConfirmationDate&&s.jsxs("div",{className:"mb-6 p-4 bg-red-50 border-2 border-red-400 rounded-lg flex items-start gap-3",children:[s.jsx("span",{className:"text-red-600 text-xl font-bold",children:"!"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold text-red-800",children:"Kündigungsbestätigung vorhanden"}),s.jsxs("p",{className:"text-sm text-red-700 mt-1",children:["Dieser Vertrag hat eine Kündigungsbestätigung vom"," ",s.jsx("strong",{children:new Date(C.cancellationConfirmationDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}),".",C.cancellationConfirmationOptionsDate&&s.jsxs(s.Fragment,{children:[" Optionen-Bestätigung: ",s.jsx("strong",{children:new Date(C.cancellationConfirmationOptionsDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}),"."]})]})]})]}),C.type==="MOBILE"&&((nt=C.mobileDetails)==null?void 0:nt.requiresMultisim)&&s.jsxs("div",{className:"mb-6 p-4 bg-amber-50 border border-amber-300 rounded-lg flex items-start gap-3",children:[s.jsx("span",{className:"text-amber-600 text-xl font-bold",children:"!"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold text-amber-800",children:"Multisim erforderlich"}),s.jsx("p",{className:"text-sm text-amber-700 mt-1",children:"Dieser Kunde benötigt eine Multisim-Karte. Multisim ist bei Klarmobil, Congstar und Otelo nicht buchbar. Bitte einen Anbieter wie Freenet oder vergleichbar wählen."})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6",children:[s.jsx(X,{title:"Anbieter & Tarif",children:s.jsxs("dl",{className:"space-y-3",children:[(C.provider||C.providerName)&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),s.jsx("dd",{className:"font-medium",children:((es=C.provider)==null?void 0:es.name)||C.providerName})]}),(C.tariff||C.tariffName)&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Tarif"}),s.jsx("dd",{children:((Vt=C.tariff)==null?void 0:Vt.name)||C.tariffName})]}),C.customerNumberAtProvider&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kundennummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[C.customerNumberAtProvider,s.jsx(oe,{value:C.customerNumberAtProvider})]})]}),C.contractNumberAtProvider&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsnummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[C.contractNumberAtProvider,s.jsx(oe,{value:C.contractNumberAtProvider})]})]}),C.salesPlatform&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertriebsplattform"}),s.jsx("dd",{children:C.salesPlatform.name})]}),C.commission!==null&&C.commission!==void 0&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Provision"}),s.jsx("dd",{children:C.commission.toLocaleString("de-DE",{style:"currency",currency:"EUR"})})]}),C.priceFirst12Months&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Preis erste 12 Monate"}),s.jsx("dd",{children:C.priceFirst12Months})]}),C.priceFrom13Months&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Preis ab 13. Monat"}),s.jsx("dd",{children:C.priceFrom13Months})]}),C.priceAfter24Months&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Preis nach 24 Monaten"}),s.jsx("dd",{children:C.priceAfter24Months})]})]})}),s.jsxs(X,{title:"Laufzeit und Kündigung",className:C.cancellationConfirmationDate?"border-2 border-red-400":"",children:[C.contractDuration&&fC(C.contractDuration.code)&&s.jsxs("p",{className:"text-sm text-gray-500 mb-4 bg-blue-50 border border-blue-200 rounded-lg p-3",children:[s.jsx("strong",{children:"Hinweis:"})," Dieser Vertrag gilt als unbefristet mit der jeweiligen Kündigungsfrist."]}),s.jsxs("dl",{className:"space-y-3",children:[C.startDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsbeginn"}),s.jsx("dd",{children:new Date(C.startDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),C.endDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsende"}),s.jsx("dd",{children:new Date(C.endDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),C.contractDuration&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragslaufzeit"}),s.jsx("dd",{children:C.contractDuration.description})]}),C.cancellationPeriod&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsfrist"}),s.jsx("dd",{children:C.cancellationPeriod.description})]}),C.cancellationConfirmationDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsbestätigungsdatum"}),s.jsx("dd",{children:new Date(C.cancellationConfirmationDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),C.cancellationConfirmationOptionsDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsbestätigungsoptionendatum"}),s.jsx("dd",{children:new Date(C.cancellationConfirmationOptionsDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),C.wasSpecialCancellation&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Sonderkündigung"}),s.jsx("dd",{children:s.jsx(ve,{variant:"warning",children:"Ja"})})]})]}),i("contracts:update")&&s.jsxs("div",{className:"mt-6 pt-6 border-t",children:[s.jsx("h4",{className:"font-medium mb-4",children:"Kündigungsdokumente"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsschreiben"}),C.cancellationLetterPath?s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${C.cancellationLetterPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${C.cancellationLetterPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ps,{className:"w-4 h-4"}),"Download"]}),s.jsx(Dt,{onUpload:async Z=>{await ut.uploadCancellationLetter(c,Z),a.invalidateQueries({queryKey:["contract",e]})},existingFile:C.cancellationLetterPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await ut.deleteCancellationLetter(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ne,{className:"w-4 h-4"}),"Löschen"]})]}):s.jsx(Dt,{onUpload:async Z=>{await ut.uploadCancellationLetter(c,Z),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsbestätigung"}),C.cancellationConfirmationPath?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${C.cancellationConfirmationPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${C.cancellationConfirmationPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ps,{className:"w-4 h-4"}),"Download"]}),s.jsx(Dt,{onUpload:async Z=>{await ut.uploadCancellationConfirmation(c,Z),a.invalidateQueries({queryKey:["contract",e]})},existingFile:C.cancellationConfirmationPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await ut.deleteCancellationConfirmation(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ne,{className:"w-4 h-4"}),"Löschen"]})]}),s.jsxs("div",{className:"mt-2",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Bestätigung erhalten am"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"date",value:C.cancellationConfirmationDate?C.cancellationConfirmationDate.split("T")[0]:"",onChange:Z=>{const Fe=Z.target.value||null;Q.mutate(Fe)},className:"block w-full max-w-[180px] px-2 py-1 text-sm border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"}),C.cancellationConfirmationDate&&s.jsx("button",{onClick:()=>Q.mutate(null),className:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 rounded",title:"Datum löschen",children:s.jsx(Ne,{className:"w-4 h-4"})})]})]})]}):s.jsx(Dt,{onUpload:async Z=>{await ut.uploadCancellationConfirmation(c,Z),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsschreiben Optionen"}),C.cancellationLetterOptionsPath?s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${C.cancellationLetterOptionsPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${C.cancellationLetterOptionsPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ps,{className:"w-4 h-4"}),"Download"]}),s.jsx(Dt,{onUpload:async Z=>{await ut.uploadCancellationLetterOptions(c,Z),a.invalidateQueries({queryKey:["contract",e]})},existingFile:C.cancellationLetterOptionsPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await ut.deleteCancellationLetterOptions(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ne,{className:"w-4 h-4"}),"Löschen"]})]}):s.jsx(Dt,{onUpload:async Z=>{await ut.uploadCancellationLetterOptions(c,Z),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsbestätigung Optionen"}),C.cancellationConfirmationOptionsPath?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${C.cancellationConfirmationOptionsPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ae,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${C.cancellationConfirmationOptionsPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ps,{className:"w-4 h-4"}),"Download"]}),s.jsx(Dt,{onUpload:async Z=>{await ut.uploadCancellationConfirmationOptions(c,Z),a.invalidateQueries({queryKey:["contract",e]})},existingFile:C.cancellationConfirmationOptionsPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await ut.deleteCancellationConfirmationOptions(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ne,{className:"w-4 h-4"}),"Löschen"]})]}),s.jsxs("div",{className:"mt-2",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Bestätigung erhalten am"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"date",value:C.cancellationConfirmationOptionsDate?C.cancellationConfirmationOptionsDate.split("T")[0]:"",onChange:Z=>{const Fe=Z.target.value||null;le.mutate(Fe)},className:"block w-full max-w-[180px] px-2 py-1 text-sm border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"}),C.cancellationConfirmationOptionsDate&&s.jsx("button",{onClick:()=>le.mutate(null),className:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 rounded",title:"Datum löschen",children:s.jsx(Ne,{className:"w-4 h-4"})})]})]})]}):s.jsx(Dt,{onUpload:async Z=>{await ut.uploadCancellationConfirmationOptions(c,Z),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]})]})]})]})]}),(C.portalUsername||C.stressfreiEmail||C.portalPasswordEncrypted)&&s.jsxs(X,{className:"mb-6",title:"Zugangsdaten",children:[s.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[(C.portalUsername||C.stressfreiEmail)&&s.jsxs("div",{children:[s.jsxs("dt",{className:"text-sm text-gray-500",children:["Benutzername",C.stressfreiEmail&&s.jsx("span",{className:"ml-2 text-xs text-blue-600",children:"(Stressfrei-Wechseln)"})]}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[((ae=C.stressfreiEmail)==null?void 0:ae.email)||C.portalUsername,s.jsx(oe,{value:((Ge=C.stressfreiEmail)==null?void 0:Ge.email)||C.portalUsername||""})]})]}),C.portalPasswordEncrypted&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Passwort"}),s.jsxs("dd",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono",children:d&&h?h:"••••••••"}),d&&h&&s.jsx(oe,{value:h}),s.jsx(T,{variant:"ghost",size:"sm",onClick:de,children:d?s.jsx(It,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]}),((xt=C.provider)==null?void 0:xt.portalUrl)&&(C.portalUsername||C.stressfreiEmail)&&C.portalPasswordEncrypted&&s.jsxs("div",{className:"mt-4 pt-4 border-t",children:[s.jsxs(T,{onClick:st,disabled:m,className:"w-full sm:w-auto",children:[s.jsx(dh,{className:"w-4 h-4 mr-2"}),m?"Wird geöffnet...":"Zum Kundenportal (Auto-Login)"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Öffnet das Portal mit vorausgefüllten Zugangsdaten"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6 mb-6",children:[C.address&&s.jsx(X,{title:"Lieferadresse",children:s.jsxs(Wu,{values:[`${C.address.street} ${C.address.houseNumber}`,`${C.address.postalCode} ${C.address.city}`,C.address.country],children:[s.jsxs("p",{children:[C.address.street," ",C.address.houseNumber]}),s.jsxs("p",{children:[C.address.postalCode," ",C.address.city]}),s.jsx("p",{className:"text-gray-500",children:C.address.country})]})}),(C.billingAddress||C.address)&&s.jsx(X,{title:"Rechnungsadresse",children:(()=>{const Z=C.billingAddress||C.address;return Z?s.jsxs(Wu,{values:[`${Z.street} ${Z.houseNumber}`,`${Z.postalCode} ${Z.city}`,Z.country],children:[s.jsxs("p",{children:[Z.street," ",Z.houseNumber]}),s.jsxs("p",{children:[Z.postalCode," ",Z.city]}),s.jsx("p",{className:"text-gray-500",children:Z.country}),!C.billingAddress&&C.address&&s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"(wie Lieferadresse)"})]}):null})()}),C.bankCard&&s.jsxs(X,{title:"Bankkarte",children:[s.jsx("p",{className:"font-medium",children:C.bankCard.accountHolder}),s.jsxs("p",{className:"font-mono flex items-center gap-1",children:[C.bankCard.iban,s.jsx(oe,{value:C.bankCard.iban})]}),C.bankCard.bankName&&s.jsx("p",{className:"text-gray-500",children:C.bankCard.bankName})]}),C.identityDocument&&s.jsxs(X,{title:"Ausweis",children:[s.jsxs("p",{className:"font-mono flex items-center gap-1",children:[C.identityDocument.documentNumber,s.jsx(oe,{value:C.identityDocument.documentNumber})]}),s.jsx("p",{className:"text-gray-500",children:C.identityDocument.type})]})]}),C.energyDetails&&s.jsxs(X,{className:"mb-6",title:C.type==="ELECTRICITY"?"Strom-Details":"Gas-Details",children:[s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[C.energyDetails.meter&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Zählernummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[C.energyDetails.meter.meterNumber,s.jsx(oe,{value:C.energyDetails.meter.meterNumber})]})]}),C.energyDetails.maloId&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"MaLo-ID"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[C.energyDetails.maloId,s.jsx(oe,{value:C.energyDetails.maloId})]})]}),C.energyDetails.annualConsumption&&s.jsxs("div",{children:[s.jsxs("dt",{className:"text-sm text-gray-500",children:["Jahresverbrauch ",C.type==="ELECTRICITY"?"":"(m³)"]}),s.jsxs("dd",{children:[C.energyDetails.annualConsumption.toLocaleString("de-DE")," ",C.type==="ELECTRICITY"?"kWh":"m³"]})]}),C.type==="GAS"&&C.energyDetails.annualConsumptionKwh&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Jahresverbrauch (kWh)"}),s.jsxs("dd",{children:[C.energyDetails.annualConsumptionKwh.toLocaleString("de-DE")," kWh"]})]}),C.energyDetails.basePrice!=null&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Grundpreis"}),s.jsxs("dd",{children:[C.energyDetails.basePrice.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:10})," €/Monat"]})]}),C.energyDetails.unitPrice!=null&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Arbeitspreis"}),s.jsxs("dd",{children:[C.energyDetails.unitPrice.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:10})," €/kWh"]})]}),C.energyDetails.bonus&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Bonus"}),s.jsxs("dd",{children:[C.energyDetails.bonus.toLocaleString("de-DE")," €"]})]}),C.energyDetails.previousProviderName&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vorversorger"}),s.jsx("dd",{children:C.energyDetails.previousProviderName})]}),C.energyDetails.previousCustomerNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vorherige Kundennr."}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[C.energyDetails.previousCustomerNumber,s.jsx(oe,{value:C.energyDetails.previousCustomerNumber})]})]})]}),C.energyDetails.meter&&s.jsx(xC,{meterId:C.energyDetails.meter.id,meterType:C.energyDetails.meter.type,readings:C.energyDetails.meter.readings||[],contractId:c,canEdit:i("contracts:update")&&!l}),C.energyDetails.meter&&C.startDate&&C.endDate&&s.jsx(yC,{contractType:C.type,readings:C.energyDetails.meter.readings||[],startDate:C.startDate,endDate:C.endDate,basePrice:C.energyDetails.basePrice,unitPrice:C.energyDetails.unitPrice,bonus:C.energyDetails.bonus}),s.jsx(nC,{ecdId:C.energyDetails.id,invoices:C.energyDetails.invoices||[],contractId:c,canEdit:i("contracts:update")&&!l})]}),C.internetDetails&&s.jsxs(X,{className:"mb-6",title:C.type==="DSL"?"DSL-Details":C.type==="CABLE"?"Kabelinternet-Details":"Glasfaser-Details",children:[s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[C.internetDetails.downloadSpeed&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Download"}),s.jsxs("dd",{children:[C.internetDetails.downloadSpeed," Mbit/s"]})]}),C.internetDetails.uploadSpeed&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Upload"}),s.jsxs("dd",{children:[C.internetDetails.uploadSpeed," Mbit/s"]})]}),C.internetDetails.routerModel&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Router"}),s.jsx("dd",{children:C.internetDetails.routerModel})]}),C.internetDetails.routerSerialNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Router S/N"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[C.internetDetails.routerSerialNumber,s.jsx(oe,{value:C.internetDetails.routerSerialNumber})]})]}),C.internetDetails.installationDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Installation"}),s.jsx("dd",{children:new Date(C.internetDetails.installationDate).toLocaleDateString("de-DE")})]}),C.internetDetails.homeId&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Home-ID"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[C.internetDetails.homeId,s.jsx(oe,{value:C.internetDetails.homeId})]})]}),C.internetDetails.activationCode&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Aktivierungscode"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[C.internetDetails.activationCode,s.jsx(oe,{value:C.internetDetails.activationCode})]})]})]}),(C.internetDetails.internetUsername||C.internetDetails.internetPasswordEncrypted)&&s.jsxs("div",{className:"mt-4 pt-4 border-t",children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"Internet-Zugangsdaten"}),s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[C.internetDetails.internetUsername&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Benutzername"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[C.internetDetails.internetUsername,s.jsx(oe,{value:C.internetDetails.internetUsername})]})]}),C.internetDetails.internetPasswordEncrypted&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Passwort"}),s.jsxs("dd",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono",children:p&&g?g:"••••••••"}),p&&g&&s.jsx(oe,{value:g}),s.jsx(T,{variant:"ghost",size:"sm",onClick:Ke,children:p?s.jsx(It,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]})]}),C.internetDetails.phoneNumbers&&C.internetDetails.phoneNumbers.length>0&&s.jsxs("div",{className:"mt-4 pt-4 border-t",children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"Rufnummern & SIP-Zugangsdaten"}),s.jsx("div",{className:"space-y-3",children:C.internetDetails.phoneNumbers.map(Z=>s.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsxs("span",{className:"font-mono font-medium flex items-center gap-1",children:[Z.phoneNumber,s.jsx(oe,{value:Z.phoneNumber})]}),Z.isMain&&s.jsx(ve,{variant:"success",children:"Hauptnummer"})]}),(Z.sipUsername||Z.sipPasswordEncrypted||Z.sipServer)&&s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-sm",children:[Z.sipUsername&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"SIP-Benutzer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[Z.sipUsername,s.jsx(oe,{value:Z.sipUsername})]})]}),Z.sipPasswordEncrypted&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"SIP-Passwort"}),s.jsxs("dd",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono",children:v[Z.id]&&E[Z.id]?E[Z.id]:"••••••••"}),v[Z.id]&&E[Z.id]&&s.jsx(oe,{value:E[Z.id]}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>Ve(Z.id),children:v[Z.id]?s.jsx(It,{className:"w-3 h-3"}):s.jsx(Ae,{className:"w-3 h-3"})})]})]}),Z.sipServer&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"SIP-Server"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[Z.sipServer,s.jsx(oe,{value:Z.sipServer})]})]})]})]},Z.id))})]})]}),C.mobileDetails&&s.jsxs(X,{className:"mb-6",title:"Mobilfunk-Details",children:[s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[C.mobileDetails.dataVolume&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Datenvolumen"}),s.jsxs("dd",{children:[C.mobileDetails.dataVolume," GB"]})]}),C.mobileDetails.includedMinutes&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Inklusiv-Minuten"}),s.jsx("dd",{children:C.mobileDetails.includedMinutes})]}),C.mobileDetails.includedSMS&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Inklusiv-SMS"}),s.jsx("dd",{children:C.mobileDetails.includedSMS})]}),C.mobileDetails.deviceModel&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Gerät"}),s.jsx("dd",{children:C.mobileDetails.deviceModel})]}),C.mobileDetails.deviceImei&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"IMEI"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[C.mobileDetails.deviceImei,s.jsx(oe,{value:C.mobileDetails.deviceImei})]})]}),C.mobileDetails.requiresMultisim&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Multisim"}),s.jsx("dd",{children:s.jsx(ve,{variant:"warning",children:"Erforderlich"})})]})]}),C.mobileDetails.simCards&&C.mobileDetails.simCards.length>0&&s.jsxs("div",{className:"mt-6 pt-6 border-t",children:[s.jsx("h4",{className:"font-medium mb-4",children:"SIM-Karten"}),s.jsx("div",{className:"space-y-3",children:C.mobileDetails.simCards.map(Z=>s.jsx(pC,{simCard:Z},Z.id))})]}),(!C.mobileDetails.simCards||C.mobileDetails.simCards.length===0)&&(C.mobileDetails.phoneNumber||C.mobileDetails.simCardNumber)&&s.jsxs("div",{className:"mt-6 pt-6 border-t",children:[s.jsx("h4",{className:"font-medium mb-4",children:"SIM-Karte (Legacy)"}),s.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[C.mobileDetails.phoneNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Rufnummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[C.mobileDetails.phoneNumber,s.jsx(oe,{value:C.mobileDetails.phoneNumber})]})]}),C.mobileDetails.simCardNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SIM-Kartennummer"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[C.mobileDetails.simCardNumber,s.jsx(oe,{value:C.mobileDetails.simCardNumber})]})]})]})]})]}),C.tvDetails&&s.jsx(X,{className:"mb-6",title:"TV-Details",children:s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[C.tvDetails.receiverModel&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Receiver"}),s.jsx("dd",{children:C.tvDetails.receiverModel})]}),C.tvDetails.smartcardNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Smartcard"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[C.tvDetails.smartcardNumber,s.jsx(oe,{value:C.tvDetails.smartcardNumber})]})]}),C.tvDetails.package&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Paket"}),s.jsx("dd",{children:C.tvDetails.package})]})]})}),C.carInsuranceDetails&&s.jsx(X,{className:"mb-6",title:"KFZ-Versicherung Details",children:s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[C.carInsuranceDetails.licensePlate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kennzeichen"}),s.jsxs("dd",{className:"font-mono font-bold flex items-center gap-1",children:[C.carInsuranceDetails.licensePlate,s.jsx(oe,{value:C.carInsuranceDetails.licensePlate})]})]}),C.carInsuranceDetails.vehicleType&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Fahrzeug"}),s.jsx("dd",{children:C.carInsuranceDetails.vehicleType})]}),C.carInsuranceDetails.hsn&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"HSN/TSN"}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[C.carInsuranceDetails.hsn,"/",C.carInsuranceDetails.tsn,s.jsx(oe,{value:`${C.carInsuranceDetails.hsn}/${C.carInsuranceDetails.tsn}`})]})]}),C.carInsuranceDetails.vin&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"FIN"}),s.jsxs("dd",{className:"font-mono text-sm flex items-center gap-1",children:[C.carInsuranceDetails.vin,s.jsx(oe,{value:C.carInsuranceDetails.vin})]})]}),C.carInsuranceDetails.firstRegistration&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Erstzulassung"}),s.jsx("dd",{children:new Date(C.carInsuranceDetails.firstRegistration).toLocaleDateString("de-DE")})]}),C.carInsuranceDetails.noClaimsClass&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SF-Klasse"}),s.jsx("dd",{children:C.carInsuranceDetails.noClaimsClass})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Versicherungsart"}),s.jsx("dd",{children:s.jsx(ve,{variant:C.carInsuranceDetails.insuranceType==="FULL"?"success":C.carInsuranceDetails.insuranceType==="PARTIAL"?"warning":"default",children:C.carInsuranceDetails.insuranceType==="FULL"?"Vollkasko":C.carInsuranceDetails.insuranceType==="PARTIAL"?"Teilkasko":"Haftpflicht"})})]}),C.carInsuranceDetails.deductiblePartial&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SB Teilkasko"}),s.jsxs("dd",{children:[C.carInsuranceDetails.deductiblePartial," €"]})]}),C.carInsuranceDetails.deductibleFull&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SB Vollkasko"}),s.jsxs("dd",{children:[C.carInsuranceDetails.deductibleFull," €"]})]}),C.carInsuranceDetails.policyNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Versicherungsschein-Nr."}),s.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[C.carInsuranceDetails.policyNumber,s.jsx(oe,{value:C.carInsuranceDetails.policyNumber})]})]}),C.carInsuranceDetails.previousInsurer&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vorversicherer"}),s.jsx("dd",{children:C.carInsuranceDetails.previousInsurer})]})]})}),s.jsx(vC,{contractId:c,canEdit:i("contracts:update"),isCustomerPortal:o}),!o&&i("contracts:read")&&C.customerId&&s.jsx(dk,{contractId:c,customerId:C.customerId}),C.notes&&s.jsx(X,{title:"Notizen",children:s.jsx("p",{className:"whitespace-pre-wrap",children:C.notes})}),!o&&i("contracts:read")&&s.jsx(tC,{contractId:c,canEdit:i("contracts:update")}),I&&C.previousContract&&s.jsx(eC,{contractId:C.previousContract.id,isOpen:!0,onClose:()=>w(!1)}),s.jsx(qe,{isOpen:S,onClose:()=>A(!1),title:"Folgevertrag anlegen",size:"sm",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-700",children:"Möchten Sie wirklich einen Folgevertrag für diesen Vertrag anlegen?"}),s.jsx("p",{className:"text-sm text-gray-500",children:"Die Daten des aktuellen Vertrags werden als Vorlage übernommen."}),s.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[s.jsx(T,{variant:"secondary",onClick:()=>A(!1),children:"Nein"}),s.jsx(T,{onClick:()=>{A(!1),B.mutate()},children:"Ja, anlegen"})]})]})}),s.jsx(hC,{isOpen:O,onClose:()=>R(!1)}),s.jsx(qe,{isOpen:q,onClose:()=>D(!1),title:"Zurückstellung aufheben?",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-700",children:"Möchten Sie die Zurückstellung für diesen Vertrag wirklich aufheben?"}),s.jsx("p",{className:"text-sm text-gray-500",children:"Der Vertrag wird danach wieder im Cockpit angezeigt, wenn Fristen anstehen oder abgelaufen sind."}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:()=>D(!1),children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:()=>_.mutate(),disabled:_.isPending,children:_.isPending?"Wird aufgehoben...":"Ja, aufheben"})]})]})})]})}const NC=[{value:"DRAFT",label:"Entwurf"},{value:"PENDING",label:"Ausstehend"},{value:"ACTIVE",label:"Aktiv"},{value:"CANCELLED",label:"Gekündigt"},{value:"EXPIRED",label:"Abgelaufen"},{value:"DEACTIVATED",label:"Deaktiviert"}],wC=[{status:"DRAFT",label:"Entwurf",description:"Vertrag wird noch vorbereitet",color:"text-gray-600"},{status:"PENDING",label:"Ausstehend",description:"Wartet auf Aktivierung",color:"text-yellow-600"},{status:"ACTIVE",label:"Aktiv",description:"Vertrag läuft normal",color:"text-green-600"},{status:"EXPIRED",label:"Abgelaufen",description:"Laufzeit vorbei, läuft aber ohne Kündigung weiter",color:"text-orange-600"},{status:"CANCELLED",label:"Gekündigt",description:"Aktive Kündigung eingereicht, Vertrag endet",color:"text-red-600"},{status:"DEACTIVATED",label:"Deaktiviert",description:"Manuell beendet/archiviert",color:"text-gray-500"}];function SC({isOpen:e,onClose:t}){return e?s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"fixed inset-0 bg-black/20",onClick:t}),s.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl p-4 max-w-sm w-full mx-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:"Vertragsstatus-Übersicht"}),s.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600",children:s.jsx(qt,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"space-y-2",children:wC.map(({status:n,label:r,description:a,color:i})=>s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:`font-medium text-sm min-w-[90px] ${i}`,children:r}),s.jsx("span",{className:"text-sm text-gray-600",children:a})]},n))})]})]}):null}function Kx(){var oi,Rl,ci,Nh,wh,Sh,kh,Ch,Eh;const{id:e}=Nc(),[t]=Sc(),n=Yt(),r=ge(),a=!!e,i=t.get("customerId"),{register:l,handleSubmit:o,reset:c,watch:d,setValue:u,formState:{errors:h}}=Vv({defaultValues:{customerId:i||"",type:"ELECTRICITY",status:"DRAFT",previousContractId:""}}),x=d("type"),m=d("customerId"),f=d("previousContractId"),{data:p}=fe({queryKey:["contract",e],queryFn:()=>Oe.getById(parseInt(e)),enabled:a}),{data:b}=fe({queryKey:["customers-all"],queryFn:()=>At.getAll({limit:1e3})}),{data:g}=fe({queryKey:["customer",m],queryFn:()=>At.getById(parseInt(m)),enabled:!!m}),{data:y}=fe({queryKey:["customer-contracts-for-predecessor",m],queryFn:()=>Oe.getAll({customerId:parseInt(m),limit:1e3}),enabled:!!m}),{data:v}=fe({queryKey:["platforms"],queryFn:()=>il.getAll()}),{data:N}=fe({queryKey:["cancellation-periods"],queryFn:()=>ll.getAll()}),{data:E}=fe({queryKey:["contract-durations"],queryFn:()=>ol.getAll()}),{data:P}=fe({queryKey:["providers"],queryFn:()=>Xa.getAll()}),{data:I}=fe({queryKey:["contract-categories"],queryFn:()=>cl.getAll()}),w=d("providerId"),[S,A]=j.useState(null),[O,R]=j.useState([]),[q,D]=j.useState([]),[z,k]=j.useState(!1),[K,B]=j.useState("manual"),[_,Q]=j.useState(""),[le,de]=j.useState(!1),[Ke,Ve]=j.useState(!1),[st,C]=j.useState({}),[nt,es]=j.useState({}),[Vt,ae]=j.useState({}),[Ge,xt]=j.useState(!1);j.useEffect(()=>{a||k(!0)},[a]),j.useEffect(()=>{!a&&i&&(b!=null&&b.data)&&b.data.some(ie=>ie.id.toString()===i)&&u("customerId",i)},[a,i,b,u]),j.useEffect(()=>{z&&S&&w!==S&&u("tariffId",""),A(w)},[w,S,u,z]),j.useEffect(()=>{if(!a&&(I!=null&&I.data)&&I.data.length>0){const F=d("type"),ie=I.data.filter(pe=>pe.isActive),we=ie.some(pe=>pe.code===F);if(!F||!we){const pe=ie.sort((je,ct)=>je.sortOrder-ct.sortOrder)[0];pe&&u("type",pe.code)}}},[I,a,u,d]),j.useEffect(()=>{a&&(p!=null&&p.data)&&!m&&u("customerId",p.data.customerId.toString())},[a,p,m,u]),j.useEffect(()=>{var F,ie,we,pe,je,ct,Ce,di,Dh,Ah,Ph,Mh,Th,Fh,Ih,Rh,Lh,Oh,zh,$h,_h,Kh,Bh,Uh,qh,Vh,Qh,Hh,Wh,Gh,Zh,Jh,Xh,Yh,ef,tf,sf,nf,rf,af,lf,of,cf,df,uf,mf,hf,ff,pf,xf,gf,yf;if(p!=null&&p.data&&(v!=null&&v.data)&&(I!=null&&I.data)&&(P!=null&&P.data)&&(g!=null&&g.data)){const re=p.data;c({customerId:re.customerId.toString(),type:re.type,status:re.status,addressId:((F=re.addressId)==null?void 0:F.toString())||"",billingAddressId:((ie=re.billingAddressId)==null?void 0:ie.toString())||"",bankCardId:((we=re.bankCardId)==null?void 0:we.toString())||"",identityDocumentId:((pe=re.identityDocumentId)==null?void 0:pe.toString())||"",salesPlatformId:((je=re.salesPlatformId)==null?void 0:je.toString())||"",providerId:((ct=re.providerId)==null?void 0:ct.toString())||"",tariffId:((Ce=re.tariffId)==null?void 0:Ce.toString())||"",providerName:re.providerName||"",tariffName:re.tariffName||"",customerNumberAtProvider:re.customerNumberAtProvider||"",contractNumberAtProvider:re.contractNumberAtProvider||"",priceFirst12Months:re.priceFirst12Months||"",priceFrom13Months:re.priceFrom13Months||"",priceAfter24Months:re.priceAfter24Months||"",startDate:re.startDate?re.startDate.split("T")[0]:"",endDate:re.endDate?re.endDate.split("T")[0]:"",cancellationPeriodId:((di=re.cancellationPeriodId)==null?void 0:di.toString())||"",contractDurationId:((Dh=re.contractDurationId)==null?void 0:Dh.toString())||"",commission:re.commission||"",portalUsername:re.portalUsername||"",notes:re.notes||"",meterId:((Ph=(Ah=re.energyDetails)==null?void 0:Ah.meterId)==null?void 0:Ph.toString())||"",maloId:((Mh=re.energyDetails)==null?void 0:Mh.maloId)||"",annualConsumption:((Th=re.energyDetails)==null?void 0:Th.annualConsumption)||"",annualConsumptionKwh:((Fh=re.energyDetails)==null?void 0:Fh.annualConsumptionKwh)||"",basePrice:((Ih=re.energyDetails)==null?void 0:Ih.basePrice)||"",unitPrice:((Rh=re.energyDetails)==null?void 0:Rh.unitPrice)||"",bonus:((Lh=re.energyDetails)==null?void 0:Lh.bonus)||"",downloadSpeed:((Oh=re.internetDetails)==null?void 0:Oh.downloadSpeed)||"",uploadSpeed:((zh=re.internetDetails)==null?void 0:zh.uploadSpeed)||"",routerModel:(($h=re.internetDetails)==null?void 0:$h.routerModel)||"",routerSerialNumber:((_h=re.internetDetails)==null?void 0:_h.routerSerialNumber)||"",installationDate:(Kh=re.internetDetails)!=null&&Kh.installationDate?re.internetDetails.installationDate.split("T")[0]:"",internetUsername:((Bh=re.internetDetails)==null?void 0:Bh.internetUsername)||"",homeId:((Uh=re.internetDetails)==null?void 0:Uh.homeId)||"",activationCode:((qh=re.internetDetails)==null?void 0:qh.activationCode)||"",requiresMultisim:((Vh=re.mobileDetails)==null?void 0:Vh.requiresMultisim)||!1,dataVolume:((Qh=re.mobileDetails)==null?void 0:Qh.dataVolume)||"",includedMinutes:((Hh=re.mobileDetails)==null?void 0:Hh.includedMinutes)||"",includedSMS:((Wh=re.mobileDetails)==null?void 0:Wh.includedSMS)||"",deviceModel:((Gh=re.mobileDetails)==null?void 0:Gh.deviceModel)||"",deviceImei:((Zh=re.mobileDetails)==null?void 0:Zh.deviceImei)||"",phoneNumber:((Jh=re.mobileDetails)==null?void 0:Jh.phoneNumber)||"",simCardNumber:((Xh=re.mobileDetails)==null?void 0:Xh.simCardNumber)||"",receiverModel:((Yh=re.tvDetails)==null?void 0:Yh.receiverModel)||"",smartcardNumber:((ef=re.tvDetails)==null?void 0:ef.smartcardNumber)||"",tvPackage:((tf=re.tvDetails)==null?void 0:tf.package)||"",licensePlate:((sf=re.carInsuranceDetails)==null?void 0:sf.licensePlate)||"",hsn:((nf=re.carInsuranceDetails)==null?void 0:nf.hsn)||"",tsn:((rf=re.carInsuranceDetails)==null?void 0:rf.tsn)||"",vin:((af=re.carInsuranceDetails)==null?void 0:af.vin)||"",vehicleType:((lf=re.carInsuranceDetails)==null?void 0:lf.vehicleType)||"",firstRegistration:(of=re.carInsuranceDetails)!=null&&of.firstRegistration?re.carInsuranceDetails.firstRegistration.split("T")[0]:"",noClaimsClass:((cf=re.carInsuranceDetails)==null?void 0:cf.noClaimsClass)||"",insuranceType:((df=re.carInsuranceDetails)==null?void 0:df.insuranceType)||"LIABILITY",deductiblePartial:((uf=re.carInsuranceDetails)==null?void 0:uf.deductiblePartial)||"",deductibleFull:((mf=re.carInsuranceDetails)==null?void 0:mf.deductibleFull)||"",policyNumber:((hf=re.carInsuranceDetails)==null?void 0:hf.policyNumber)||"",previousInsurer:((ff=re.carInsuranceDetails)==null?void 0:ff.previousInsurer)||"",cancellationConfirmationDate:re.cancellationConfirmationDate?re.cancellationConfirmationDate.split("T")[0]:"",cancellationConfirmationOptionsDate:re.cancellationConfirmationOptionsDate?re.cancellationConfirmationOptionsDate.split("T")[0]:"",wasSpecialCancellation:re.wasSpecialCancellation||!1,previousContractId:((pf=re.previousContractId)==null?void 0:pf.toString())||"",previousProviderId:((xf=re.previousProviderId)==null?void 0:xf.toString())||"",previousCustomerNumber:re.previousCustomerNumber||"",previousContractNumber:re.previousContractNumber||""}),(gf=re.mobileDetails)!=null&&gf.simCards&&re.mobileDetails.simCards.length>0?R(re.mobileDetails.simCards.map(ss=>({id:ss.id,phoneNumber:ss.phoneNumber||"",simCardNumber:ss.simCardNumber||"",pin:"",puk:"",hasExistingPin:!!ss.pin,hasExistingPuk:!!ss.puk,isMultisim:ss.isMultisim,isMain:ss.isMain}))):R([]),(yf=re.internetDetails)!=null&&yf.phoneNumbers&&re.internetDetails.phoneNumbers.length>0?D(re.internetDetails.phoneNumbers.map(ss=>({id:ss.id,phoneNumber:ss.phoneNumber||"",sipUsername:ss.sipUsername||"",sipPassword:"",hasExistingSipPassword:!!ss.sipPasswordEncrypted,sipServer:ss.sipServer||"",isMain:ss.isMain}))):D([]),re.stressfreiEmailId?(B("stressfrei"),Q(re.stressfreiEmailId.toString())):(B("manual"),Q("")),k(!0)}},[p,c,v,I,P,g]);const Z=d("startDate"),Fe=d("contractDurationId");j.useEffect(()=>{if(Z&&Fe&&(E!=null&&E.data)){const F=E.data.find(ie=>ie.id===parseInt(Fe));if(F){const ie=new Date(Z),pe=F.code.match(/^(\d+)([MTJ])$/);if(pe){const je=parseInt(pe[1]),ct=pe[2];let Ce=new Date(ie);ct==="T"?Ce.setDate(Ce.getDate()+je):ct==="M"?Ce.setMonth(Ce.getMonth()+je):ct==="J"&&Ce.setFullYear(Ce.getFullYear()+je),u("endDate",Ce.toISOString().split("T")[0])}}}},[Z,Fe,E,u]);const Xe=G({mutationFn:Oe.create,onSuccess:(F,ie)=>{r.invalidateQueries({queryKey:["contracts"]}),ie.customerId&&r.invalidateQueries({queryKey:["customer",ie.customerId.toString()]}),r.invalidateQueries({queryKey:["customers"]}),n(i?`/customers/${i}?tab=contracts`:"/contracts")}}),J=G({mutationFn:F=>Oe.update(parseInt(e),F),onSuccess:(F,ie)=>{r.invalidateQueries({queryKey:["contracts"]}),r.invalidateQueries({queryKey:["contract",e]}),ie.customerId&&r.invalidateQueries({queryKey:["customer",ie.customerId.toString()]}),r.invalidateQueries({queryKey:["customers"]}),n(`/contracts/${e}`)}}),ue=F=>{const ie=Ce=>{if(Ce==null||Ce==="")return;const di=parseInt(String(Ce));return isNaN(di)?void 0:di},we=kt.find(Ce=>Ce.code===F.type),pe=ie(F.customerId);if(!pe){alert("Bitte wählen Sie einen Kunden aus");return}if(!F.type||!we){alert("Bitte wählen Sie einen Vertragstyp aus");return}const je=Ce=>Ce==null||Ce===""?null:Ce,ct={customerId:pe,type:F.type,contractCategoryId:we.id,status:F.status,addressId:ie(F.addressId)??null,billingAddressId:ie(F.billingAddressId)??null,bankCardId:ie(F.bankCardId)??null,identityDocumentId:ie(F.identityDocumentId)??null,salesPlatformId:ie(F.salesPlatformId)??null,providerId:ie(F.providerId)??null,tariffId:ie(F.tariffId)??null,providerName:je(F.providerName),tariffName:je(F.tariffName),customerNumberAtProvider:je(F.customerNumberAtProvider),contractNumberAtProvider:je(F.contractNumberAtProvider),priceFirst12Months:je(F.priceFirst12Months),priceFrom13Months:je(F.priceFrom13Months),priceAfter24Months:je(F.priceAfter24Months),startDate:F.startDate?new Date(F.startDate):null,endDate:F.endDate?new Date(F.endDate):null,cancellationPeriodId:ie(F.cancellationPeriodId)??null,contractDurationId:ie(F.contractDurationId)??null,commission:F.commission?parseFloat(F.commission):null,portalUsername:K==="manual"?je(F.portalUsername):null,stressfreiEmailId:K==="stressfrei"&&_?parseInt(_):null,portalPassword:F.portalPassword||void 0,notes:je(F.notes),cancellationConfirmationDate:F.cancellationConfirmationDate?new Date(F.cancellationConfirmationDate):null,cancellationConfirmationOptionsDate:F.cancellationConfirmationOptionsDate?new Date(F.cancellationConfirmationOptionsDate):null,wasSpecialCancellation:F.wasSpecialCancellation||!1,previousContractId:ie(F.previousContractId)??null,previousProviderId:F.previousContractId?null:ie(F.previousProviderId)??null,previousCustomerNumber:F.previousContractId?null:je(F.previousCustomerNumber),previousContractNumber:F.previousContractId?null:je(F.previousContractNumber)};["ELECTRICITY","GAS"].includes(F.type)&&(ct.energyDetails={meterId:ie(F.meterId)??null,maloId:je(F.maloId),annualConsumption:F.annualConsumption?parseFloat(F.annualConsumption):null,annualConsumptionKwh:F.annualConsumptionKwh?parseFloat(F.annualConsumptionKwh):null,basePrice:F.basePrice?parseFloat(F.basePrice):null,unitPrice:F.unitPrice?parseFloat(F.unitPrice):null,bonus:F.bonus?parseFloat(F.bonus):null}),["DSL","CABLE","FIBER"].includes(F.type)&&(ct.internetDetails={downloadSpeed:ie(F.downloadSpeed)??null,uploadSpeed:ie(F.uploadSpeed)??null,routerModel:je(F.routerModel),routerSerialNumber:je(F.routerSerialNumber),installationDate:F.installationDate?new Date(F.installationDate):null,internetUsername:je(F.internetUsername),internetPassword:F.internetPassword||void 0,homeId:je(F.homeId),activationCode:je(F.activationCode),phoneNumbers:q.length>0?q.map(Ce=>({id:Ce.id,phoneNumber:Ce.phoneNumber||"",isMain:Ce.isMain??!1,sipUsername:je(Ce.sipUsername),sipPassword:Ce.sipPassword||void 0,sipServer:je(Ce.sipServer)})):void 0}),F.type==="MOBILE"&&(ct.mobileDetails={requiresMultisim:F.requiresMultisim||!1,dataVolume:F.dataVolume?parseFloat(F.dataVolume):null,includedMinutes:ie(F.includedMinutes)??null,includedSMS:ie(F.includedSMS)??null,deviceModel:je(F.deviceModel),deviceImei:je(F.deviceImei),phoneNumber:je(F.phoneNumber),simCardNumber:je(F.simCardNumber),simCards:O.length>0?O.map(Ce=>({id:Ce.id,phoneNumber:je(Ce.phoneNumber),simCardNumber:je(Ce.simCardNumber),pin:Ce.pin||void 0,puk:Ce.puk||void 0,isMultisim:Ce.isMultisim,isMain:Ce.isMain})):void 0}),F.type==="TV"&&(ct.tvDetails={receiverModel:je(F.receiverModel),smartcardNumber:je(F.smartcardNumber),package:je(F.tvPackage)}),F.type==="CAR_INSURANCE"&&(ct.carInsuranceDetails={licensePlate:je(F.licensePlate),hsn:je(F.hsn),tsn:je(F.tsn),vin:je(F.vin),vehicleType:je(F.vehicleType),firstRegistration:F.firstRegistration?new Date(F.firstRegistration):null,noClaimsClass:je(F.noClaimsClass),insuranceType:F.insuranceType,deductiblePartial:F.deductiblePartial?parseFloat(F.deductiblePartial):null,deductibleFull:F.deductibleFull?parseFloat(F.deductibleFull):null,policyNumber:je(F.policyNumber),previousInsurer:je(F.previousInsurer)}),a?J.mutate(ct):Xe.mutate(ct)},ts=Xe.isPending||J.isPending,un=Xe.error||J.error,gt=g==null?void 0:g.data,L=(gt==null?void 0:gt.addresses)||[],U=((oi=gt==null?void 0:gt.bankCards)==null?void 0:oi.filter(F=>F.isActive))||[],W=((Rl=gt==null?void 0:gt.identityDocuments)==null?void 0:Rl.filter(F=>F.isActive))||[],ce=((ci=gt==null?void 0:gt.meters)==null?void 0:ci.filter(F=>F.isActive))||[],se=((Nh=gt==null?void 0:gt.stressfreiEmails)==null?void 0:Nh.filter(F=>F.isActive))||[],ee=(v==null?void 0:v.data)||[],ye=(N==null?void 0:N.data)||[],Le=(E==null?void 0:E.data)||[],Me=((wh=P==null?void 0:P.data)==null?void 0:wh.filter(F=>F.isActive))||[],kt=((Sh=I==null?void 0:I.data)==null?void 0:Sh.filter(F=>F.isActive).sort((F,ie)=>F.sortOrder-ie.sortOrder))||[],mn=kt.map(F=>({value:F.code,label:F.name})),Hs=((y==null?void 0:y.data)||[]).filter(F=>!a||F.id!==parseInt(e)).sort((F,ie)=>new Date(ie.startDate||0).getTime()-new Date(F.startDate||0).getTime()),Ln=Me.find(F=>F.id===parseInt(w||"0")),li=((kh=Ln==null?void 0:Ln.tariffs)==null?void 0:kh.filter(F=>F.isActive))||[],sa=F=>{const ie=F.companyName||`${F.firstName} ${F.lastName}`,we=F.birthDate?` (geb. ${new Date(F.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})`:"";return`${F.customerNumber} - ${ie}${we}`},Oc=(()=>{var we;const ie=((b==null?void 0:b.data)||[]).map(pe=>({value:pe.id.toString(),label:sa(pe)}));if(a&&((we=p==null?void 0:p.data)!=null&&we.customer)){const pe=p.data.customer;ie.some(ct=>ct.value===pe.id.toString())||ie.unshift({value:pe.id.toString(),label:sa(pe)})}return ie})();return s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold mb-6",children:a?"Vertrag bearbeiten":"Neuer Vertrag"}),un&&s.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:un instanceof Error?un.message:"Ein Fehler ist aufgetreten"}),s.jsxs("form",{onSubmit:o(ue),children:[s.jsx(X,{className:"mb-6",title:"Vertragsdaten",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Ie,{label:"Kunde *",...l("customerId",{required:"Kunde erforderlich"}),options:Oc,error:(Ch=h.customerId)==null?void 0:Ch.message}),s.jsx(Ie,{label:"Vertragstyp *",...l("type",{required:"Typ erforderlich"}),options:mn}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Status"}),s.jsx("button",{type:"button",onClick:()=>xt(!0),className:"text-gray-400 hover:text-blue-600 transition-colors",title:"Status-Erklärung",children:s.jsx(Ml,{className:"w-4 h-4"})})]}),s.jsx(Ie,{...l("status"),options:NC})]}),s.jsx(Ie,{label:"Vertriebsplattform",...l("salesPlatformId"),options:ee.map(F=>({value:F.id,label:F.name}))}),m&&s.jsx(Ie,{label:"Vorgänger-Vertrag",...l("previousContractId"),options:Hs.map(F=>({value:F.id,label:`${F.contractNumber} (${F.type}${F.startDate?` - ${new Date(F.startDate).toLocaleDateString("de-DE")}`:""})`})),placeholder:"Keinen Vorgänger auswählen"}),m&&!f&&s.jsxs("div",{className:"mt-4 p-4 bg-gray-50 rounded-lg border border-gray-200",children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"Altanbieter-Daten"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(Ie,{label:"Altanbieter",...l("previousProviderId"),options:Me.map(F=>({value:F.id,label:F.name})),placeholder:"Bitte wählen..."}),s.jsx(H,{label:"Kundennr. beim Altanbieter",...l("previousCustomerNumber")}),s.jsx(H,{label:"Vertragsnr. beim Altanbieter",...l("previousContractNumber")})]})]})]})}),m&&s.jsxs(X,{className:"mb-6",title:"Kundendaten verknüpfen",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[s.jsx(Ie,{label:"Lieferadresse",...l("addressId"),options:L.filter(F=>F.type==="DELIVERY_RESIDENCE").map(F=>({value:F.id,label:`${F.street} ${F.houseNumber}, ${F.postalCode} ${F.city}`}))}),s.jsx(Ie,{label:"Rechnungsadresse",...l("billingAddressId"),options:L.filter(F=>F.type==="BILLING").map(F=>({value:F.id,label:`${F.street} ${F.houseNumber}, ${F.postalCode} ${F.city}`})),placeholder:"Wie Lieferadresse"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Ie,{label:"Bankkarte",...l("bankCardId"),options:U.map(F=>({value:F.id,label:`${F.iban} (${F.accountHolder})`}))}),s.jsx(Ie,{label:"Ausweis",...l("identityDocumentId"),options:W.map(F=>({value:F.id,label:`${F.documentNumber} (${F.type})`}))})]})]}),s.jsx(X,{className:"mb-6",title:"Anbieter & Tarif",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Ie,{label:"Anbieter",...l("providerId"),options:Me.map(F=>({value:F.id,label:F.name}))}),s.jsx(Ie,{label:"Tarif",...l("tariffId"),options:li.map(F=>({value:F.id,label:F.name})),disabled:!w}),s.jsx(H,{label:"Kundennummer beim Anbieter",...l("customerNumberAtProvider")}),s.jsx(H,{label:"Vertragsnummer beim Anbieter",...l("contractNumberAtProvider")}),s.jsx(H,{label:"Provision (€)",type:"number",step:"0.01",...l("commission")}),s.jsx(H,{label:"Preis erste 12 Monate",...l("priceFirst12Months"),placeholder:"z.B. 29,99 €/Monat"}),s.jsx(H,{label:"Preis ab 13. Monat",...l("priceFrom13Months"),placeholder:"z.B. 39,99 €/Monat"}),s.jsx(H,{label:"Preis nach 24 Monaten",...l("priceAfter24Months"),placeholder:"z.B. 49,99 €/Monat"})]})}),s.jsxs(X,{className:"mb-6",title:"Laufzeit und Kündigung",children:[s.jsxs("p",{className:"text-sm text-gray-500 mb-4 bg-blue-50 border border-blue-200 rounded-lg p-3",children:[s.jsx("strong",{children:"Hinweis:"})," Ist die Laufzeit ≤ 4 Wochen, 1 Monat oder 30 Tage, gilt der Vertrag als unbefristet mit der jeweiligen Kündigungsfrist."]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(H,{label:"Vertragsbeginn",type:"date",...l("startDate"),value:d("startDate")||"",onClear:()=>u("startDate","")}),s.jsx(H,{label:"Vertragsende (berechnet)",type:"date",...l("endDate"),disabled:!0,className:"bg-gray-50"}),s.jsx(Ie,{label:"Vertragslaufzeit",...l("contractDurationId"),options:Le.map(F=>({value:F.id,label:F.description}))}),s.jsx(Ie,{label:"Kündigungsfrist",...l("cancellationPeriodId"),options:ye.map(F=>({value:F.id,label:F.description}))}),s.jsx(H,{label:"Kündigungsbestätigungsdatum",type:"date",...l("cancellationConfirmationDate"),value:d("cancellationConfirmationDate")||"",onClear:()=>u("cancellationConfirmationDate","")}),s.jsx(H,{label:"Kündigungsbestätigungsoptionendatum",type:"date",...l("cancellationConfirmationOptionsDate"),value:d("cancellationConfirmationOptionsDate")||"",onClear:()=>u("cancellationConfirmationOptionsDate","")}),s.jsx("div",{className:"col-span-2",children:s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",...l("wasSpecialCancellation"),className:"rounded border-gray-300"}),s.jsx("span",{children:"Wurde sondergekündigt?"})]})})]})]}),s.jsx(X,{className:"mb-6",title:"Zugangsdaten (verschlüsselt gespeichert)",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Portal Benutzername"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"radio",name:"usernameType",checked:K==="manual",onChange:()=>{B("manual"),Q("")},className:"text-blue-600"}),s.jsx("span",{className:"text-sm",children:"Manuell eingeben"})]}),K==="manual"&&s.jsx(H,{...l("portalUsername"),placeholder:"Benutzername eingeben..."}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"radio",name:"usernameType",checked:K==="stressfrei",onChange:()=>{B("stressfrei"),u("portalUsername","")},className:"text-blue-600"}),s.jsx("span",{className:"text-sm",children:"Stressfrei-Wechseln Adresse"})]}),K==="stressfrei"&&s.jsx(Ie,{value:_,onChange:F=>Q(F.target.value),options:se.map(F=>({value:F.id,label:F.email+(F.notes?` (${F.notes})`:"")})),placeholder:se.length===0?"Keine Stressfrei-Adressen vorhanden":"Adresse auswählen..."}),K==="stressfrei"&&se.length===0&&s.jsx("p",{className:"text-xs text-amber-600",children:"Keine Stressfrei-Wechseln Adressen für diesen Kunden vorhanden. Bitte zuerst beim Kunden anlegen."})]})]}),s.jsxs("div",{className:"mt-8",children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:a?"Neues Passwort (leer lassen = unverändert)":"Portal Passwort"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:le?"text":"password",...l("portalPassword"),className:"block w-full px-3 py-2 pr-10 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),s.jsx("button",{type:"button",onClick:()=>de(!le),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:le?s.jsx(It,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]})}),["ELECTRICITY","GAS"].includes(x)&&s.jsxs(X,{className:"mb-6",title:x==="ELECTRICITY"?"Strom-Details":"Gas-Details",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Ie,{label:"Zähler",...l("meterId"),options:ce.filter(F=>F.type===x).map(F=>({value:F.id,label:`${F.meterNumber}${F.location?` (${F.location})`:""}`}))}),s.jsx(H,{label:"MaLo-ID (Marktlokations-ID)",...l("maloId")}),s.jsx(H,{label:`Jahresverbrauch (${x==="ELECTRICITY"?"kWh":"m³"})`,type:"number",...l("annualConsumption")}),x==="GAS"&&s.jsx(H,{label:"Jahresverbrauch (kWh)",type:"number",...l("annualConsumptionKwh")}),s.jsx(H,{label:"Grundpreis (€/Monat)",type:"number",step:"any",...l("basePrice")}),s.jsx(H,{label:"Arbeitspreis (€/kWh)",type:"number",step:"any",...l("unitPrice")}),s.jsx(H,{label:"Bonus (€)",type:"number",step:"0.01",...l("bonus")})]}),a&&s.jsxs("div",{className:"mt-4 p-3 bg-blue-50 border border-blue-200 rounded-lg text-sm text-blue-700",children:[s.jsx("strong",{children:"Hinweis:"})," Zählerstände und Rechnungen werden in der"," ",s.jsx("span",{className:"font-medium",children:"Vertragsdetailansicht"})," verwaltet, nicht hier im Bearbeitungsformular."]})]}),["DSL","CABLE","FIBER"].includes(x)&&s.jsxs(s.Fragment,{children:[s.jsx(X,{className:"mb-6",title:x==="DSL"?"DSL-Details":x==="CABLE"?"Kabelinternet-Details":"Glasfaser-Details",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(H,{label:"Download (Mbit/s)",type:"number",...l("downloadSpeed")}),s.jsx(H,{label:"Upload (Mbit/s)",type:"number",...l("uploadSpeed")}),s.jsx(H,{label:"Router Modell",...l("routerModel")}),s.jsx(H,{label:"Router Seriennummer",...l("routerSerialNumber")}),s.jsx(H,{label:"Installationsdatum",type:"date",...l("installationDate"),value:d("installationDate")||"",onClear:()=>u("installationDate","")}),x==="FIBER"&&s.jsx(H,{label:"Home-ID",...l("homeId")}),((Eh=Ln==null?void 0:Ln.name)==null?void 0:Eh.toLowerCase().includes("vodafone"))&&["DSL","CABLE"].includes(x)&&s.jsx(H,{label:"Aktivierungscode",...l("activationCode")})]})}),s.jsx(X,{className:"mb-6",title:"Internet-Zugangsdaten (verschlüsselt)",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(H,{label:"Benutzername",...l("internetUsername")}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:a?"Neues Passwort (leer = beibehalten)":"Passwort"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:Ke?"text":"password",...l("internetPassword"),className:"block w-full px-3 py-2 pr-10 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),s.jsx("button",{type:"button",onClick:()=>Ve(!Ke),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:Ke?s.jsx(It,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]})}),s.jsxs(X,{className:"mb-6",title:"Rufnummern & SIP-Zugangsdaten",children:[s.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Hier können Sie Festnetz-Rufnummern mit SIP-Zugangsdaten erfassen."}),q.length>0&&s.jsx("div",{className:"space-y-4 mb-4",children:q.map((F,ie)=>s.jsxs("div",{className:"p-4 border rounded-lg bg-gray-50",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("span",{className:"font-medium",children:["Rufnummer ",ie+1]}),s.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[s.jsx("input",{type:"checkbox",checked:F.isMain,onChange:we=>{const pe=[...q];we.target.checked?pe.forEach((je,ct)=>je.isMain=ct===ie):pe[ie].isMain=!1,D(pe)},className:"rounded border-gray-300"}),"Hauptnummer"]})]}),s.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:()=>{D(q.filter((we,pe)=>pe!==ie))},children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[s.jsx(H,{label:"Rufnummer",value:F.phoneNumber,onChange:we=>{const pe=[...q];pe[ie].phoneNumber=we.target.value,D(pe)},placeholder:"z.B. 030 123456"}),s.jsx(H,{label:"SIP-Benutzername",value:F.sipUsername,onChange:we=>{const pe=[...q];pe[ie].sipUsername=we.target.value,D(pe)}}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:F.hasExistingSipPassword?"SIP-Passwort (bereits hinterlegt)":"SIP-Passwort"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:st[ie]?"text":"password",value:F.sipPassword,onChange:we=>{const pe=[...q];pe[ie].sipPassword=we.target.value,D(pe)},placeholder:F.hasExistingSipPassword?"Leer = beibehalten":"",className:"block w-full px-3 py-2 pr-10 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),s.jsx("button",{type:"button",onClick:()=>C(we=>({...we,[ie]:!we[ie]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:st[ie]?s.jsx(It,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]}),s.jsx(H,{label:"SIP-Server",value:F.sipServer,onChange:we=>{const pe=[...q];pe[ie].sipServer=we.target.value,D(pe)},placeholder:"z.B. sip.provider.de"})]})]},ie))}),s.jsxs(T,{type:"button",variant:"secondary",onClick:()=>{D([...q,{phoneNumber:"",sipUsername:"",sipPassword:"",sipServer:"",isMain:q.length===0}])},children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Rufnummer hinzufügen"]})]})]}),x==="MOBILE"&&s.jsxs(s.Fragment,{children:[s.jsxs(X,{className:"mb-6",title:"Mobilfunk-Details",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(H,{label:"Datenvolumen (GB)",type:"number",...l("dataVolume")}),s.jsx(H,{label:"Inklusiv-Minuten",type:"number",...l("includedMinutes")}),s.jsx(H,{label:"Inklusiv-SMS",type:"number",...l("includedSMS")}),s.jsx(H,{label:"Gerät (Modell)",...l("deviceModel")}),s.jsx(H,{label:"Gerät (IMEI)",...l("deviceImei")})]}),s.jsx("div",{className:"mt-4 pt-4 border-t",children:s.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",...l("requiresMultisim"),className:"mt-1 rounded border-gray-300"}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium",children:"Multisim erforderlich"}),s.jsx("p",{className:"text-sm text-amber-600 mt-1",children:"Hinweis: Multisim ist bei Klarmobil, Congstar und Otelo nicht buchbar. Muss Freenet oder vergleichbar sein."})]})]})})]}),s.jsxs(X,{className:"mb-6",title:"SIM-Karten",children:[s.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Hier können Sie alle SIM-Karten zum Vertrag erfassen (Hauptkarte und Multisim-Karten)."}),O.length>0&&s.jsx("div",{className:"space-y-4 mb-4",children:O.map((F,ie)=>s.jsxs("div",{className:"p-4 border rounded-lg bg-gray-50",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("span",{className:"font-medium",children:["SIM-Karte ",ie+1]}),s.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[s.jsx("input",{type:"checkbox",checked:F.isMain,onChange:we=>{const pe=[...O];we.target.checked?pe.forEach((je,ct)=>je.isMain=ct===ie):pe[ie].isMain=!1,R(pe)},className:"rounded border-gray-300"}),"Hauptkarte"]}),s.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[s.jsx("input",{type:"checkbox",checked:F.isMultisim,onChange:we=>{const pe=[...O];pe[ie].isMultisim=we.target.checked,R(pe)},className:"rounded border-gray-300"}),"Multisim"]})]}),s.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:()=>{R(O.filter((we,pe)=>pe!==ie))},children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[s.jsx(H,{label:"Rufnummer",value:F.phoneNumber,onChange:we=>{const pe=[...O];pe[ie].phoneNumber=we.target.value,R(pe)},placeholder:"z.B. 0171 1234567"}),s.jsx(H,{label:"SIM-Kartennummer",value:F.simCardNumber,onChange:we=>{const pe=[...O];pe[ie].simCardNumber=we.target.value,R(pe)},placeholder:"ICCID"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:F.hasExistingPin?"PIN (bereits hinterlegt)":"PIN"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:nt[ie]?"text":"password",value:F.pin,onChange:we=>{const pe=[...O];pe[ie].pin=we.target.value,R(pe)},placeholder:F.hasExistingPin?"Leer = beibehalten":"4-stellig",className:"block w-full px-3 py-2 pr-10 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),s.jsx("button",{type:"button",onClick:()=>es(we=>({...we,[ie]:!we[ie]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:nt[ie]?s.jsx(It,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:F.hasExistingPuk?"PUK (bereits hinterlegt)":"PUK"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:Vt[ie]?"text":"password",value:F.puk,onChange:we=>{const pe=[...O];pe[ie].puk=we.target.value,R(pe)},placeholder:F.hasExistingPuk?"Leer = beibehalten":"8-stellig",className:"block w-full px-3 py-2 pr-10 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),s.jsx("button",{type:"button",onClick:()=>ae(we=>({...we,[ie]:!we[ie]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:Vt[ie]?s.jsx(It,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]})]},ie))}),s.jsxs(T,{type:"button",variant:"secondary",onClick:()=>{R([...O,{phoneNumber:"",simCardNumber:"",pin:"",puk:"",isMultisim:!1,isMain:O.length===0}])},children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"SIM-Karte hinzufügen"]})]})]}),x==="TV"&&s.jsx(X,{className:"mb-6",title:"TV-Details",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(H,{label:"Receiver Modell",...l("receiverModel")}),s.jsx(H,{label:"Smartcard-Nummer",...l("smartcardNumber")}),s.jsx(H,{label:"Paket",...l("tvPackage"),placeholder:"z.B. Basis, Premium, Sport"})]})}),x==="CAR_INSURANCE"&&s.jsx(X,{className:"mb-6",title:"KFZ-Versicherung Details",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(H,{label:"Kennzeichen",...l("licensePlate")}),s.jsx(H,{label:"HSN",...l("hsn")}),s.jsx(H,{label:"TSN",...l("tsn")}),s.jsx(H,{label:"FIN (VIN)",...l("vin")}),s.jsx(H,{label:"Fahrzeugtyp",...l("vehicleType")}),s.jsx(H,{label:"Erstzulassung",type:"date",...l("firstRegistration"),value:d("firstRegistration")||"",onClear:()=>u("firstRegistration","")}),s.jsx(H,{label:"SF-Klasse",...l("noClaimsClass")}),s.jsx(Ie,{label:"Versicherungsart",...l("insuranceType"),options:[{value:"LIABILITY",label:"Haftpflicht"},{value:"PARTIAL",label:"Teilkasko"},{value:"FULL",label:"Vollkasko"}]}),s.jsx(H,{label:"SB Teilkasko (€)",type:"number",...l("deductiblePartial")}),s.jsx(H,{label:"SB Vollkasko (€)",type:"number",...l("deductibleFull")}),s.jsx(H,{label:"Versicherungsscheinnummer",...l("policyNumber")}),s.jsx(H,{label:"Vorversicherer",...l("previousInsurer")})]})}),s.jsx(X,{className:"mb-6",title:"Notizen",children:s.jsx("textarea",{...l("notes"),rows:4,className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"Interne Notizen..."})}),s.jsxs("div",{className:"flex justify-end gap-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:()=>n(-1),children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:ts,children:ts?"Speichern...":"Speichern"})]})]}),s.jsx(SC,{isOpen:Ge,onClose:()=>xt(!1)})]})}const kC={ELECTRICITY:xh,GAS:Ev,DSL:Ea,CABLE:Ea,FIBER:Ea,MOBILE:fh,TV:Fv,CAR_INSURANCE:Cv},CC={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabel",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ"},EC={critical:"bg-red-100 border-red-300 text-red-800",warning:"bg-yellow-100 border-yellow-300 text-yellow-800",ok:"bg-green-100 border-green-300 text-green-800",none:"bg-gray-100 border-gray-300 text-gray-800"},DC={critical:"danger",warning:"warning",ok:"success",none:"default"},AC={cancellation_deadline:kv,contract_ending:on,missing_cancellation_letter:Be,missing_cancellation_confirmation:Be,missing_portal_credentials:z2,missing_customer_number:Be,missing_provider:Be,missing_address:Be,missing_bank:Be,missing_meter:xh,missing_sim:fh,open_tasks:dl,pending_status:on,draft_status:Be,review_due:hh,missing_invoice:mh},PC={cancellationDeadlines:"Kündigungsfristen",contractEnding:"Vertragsenden",missingCredentials:"Fehlende Zugangsdaten",missingData:"Fehlende Daten",openTasks:"Offene Aufgaben",pendingContracts:"Wartende Verträge",missingInvoices:"Fehlende Rechnungen",reviewDue:"Erneute Prüfung fällig"};function MC(){var w;const[e,t]=Sc(),[n,r]=j.useState(new Set),a=e.get("filter"),[i,l]=j.useState(a||"all");j.useEffect(()=>{i==="all"?e.delete("filter"):e.set("filter",i),t(e,{replace:!0})},[i,e,t]);const{data:o,isLoading:c,error:d}=fe({queryKey:["contract-cockpit"],queryFn:()=>Oe.getCockpit(),staleTime:0}),u=ge(),[h,x]=j.useState(null),[m,f]=j.useState(""),p=j.useRef(null);j.useEffect(()=>{const S=A=>{p.current&&!p.current.contains(A.target)&&(x(null),f(""))};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[]);const b=G({mutationFn:({contractId:S,data:A})=>Oe.snooze(S,A),onSuccess:()=>{u.invalidateQueries({queryKey:["contract-cockpit"]}),x(null),f("")}}),g=(S,A)=>{A?b.mutate({contractId:S,data:{months:A}}):m&&b.mutate({contractId:S,data:{nextReviewDate:m}})},y=S=>{b.mutate({contractId:S,data:{}})},v=S=>{r(A=>{const O=new Set(A);return O.has(S)?O.delete(S):O.add(S),O})},N=j.useMemo(()=>{var A;if(!((A=o==null?void 0:o.data)!=null&&A.contracts))return[];const S=o.data.contracts;switch(i){case"critical":return S.filter(O=>O.highestUrgency==="critical");case"warning":return S.filter(O=>O.highestUrgency==="warning");case"ok":return S.filter(O=>O.highestUrgency==="ok");case"deadlines":return S.filter(O=>O.issues.some(R=>["cancellation_deadline","contract_ending"].includes(R.type)));case"credentials":return S.filter(O=>O.issues.some(R=>R.type.includes("credentials")));case"data":return S.filter(O=>O.issues.some(R=>R.type.startsWith("missing_")&&!R.type.includes("credentials")));case"tasks":return S.filter(O=>O.issues.some(R=>["open_tasks","pending_status","draft_status"].includes(R.type)));case"review":return S.filter(O=>O.issues.some(R=>R.type==="review_due"));case"invoices":return S.filter(O=>O.issues.some(R=>R.type.includes("invoice")));default:return S}},[(w=o==null?void 0:o.data)==null?void 0:w.contracts,i]);if(c)return s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"text-gray-500",children:"Laden..."})});if(d||!(o!=null&&o.data))return s.jsx("div",{className:"text-center py-12",children:s.jsx("p",{className:"text-red-500",children:"Fehler beim Laden des Cockpits"})});const{summary:E,thresholds:P}=o.data,I=S=>{var R,q,D,z;const A=n.has(S.id),O=kC[S.type]||Be;return s.jsxs("div",{className:`border rounded-lg mb-2 ${EC[S.highestUrgency]}`,children:[s.jsxs("div",{className:"flex items-center p-4 cursor-pointer hover:bg-opacity-50",onClick:()=>v(S.id),children:[s.jsx("div",{className:"w-6 mr-2",children:A?s.jsx(dn,{className:"w-5 h-5"}):s.jsx(Ft,{className:"w-5 h-5"})}),s.jsx(O,{className:"w-5 h-5 mr-3"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(ke,{to:`/contracts/${S.id}`,state:{from:"cockpit",filter:i!=="all"?i:void 0},className:"font-medium hover:underline",onClick:k=>k.stopPropagation(),children:S.contractNumber}),s.jsxs(ve,{variant:DC[S.highestUrgency],children:[S.issues.length," ",S.highestUrgency==="ok"?S.issues.length===1?"Hinweis":"Hinweise":S.issues.length===1?"Problem":"Probleme"]}),s.jsx("span",{className:"text-sm",children:CC[S.type]})]}),s.jsxs("div",{className:"text-sm mt-1",children:[s.jsxs(ke,{to:`/customers/${S.customer.id}`,className:"hover:underline",onClick:k=>k.stopPropagation(),children:[S.customer.customerNumber," - ",S.customer.name]}),(((R=S.provider)==null?void 0:R.name)||S.providerName)&&s.jsxs("span",{className:"ml-2",children:["| ",((q=S.provider)==null?void 0:q.name)||S.providerName,(((D=S.tariff)==null?void 0:D.name)||S.tariffName)&&` - ${((z=S.tariff)==null?void 0:z.name)||S.tariffName}`]})]})]}),s.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[s.jsxs("div",{className:"relative",ref:h===S.id?p:void 0,children:[s.jsx("button",{onClick:k=>{k.stopPropagation(),x(h===S.id?null:S.id),f("")},className:"p-2 hover:bg-white hover:bg-opacity-50 rounded",title:"Zurückstellen",children:s.jsx(Sv,{className:"w-4 h-4"})}),h===S.id&&s.jsxs("div",{className:"absolute right-0 top-full mt-1 w-56 bg-white border rounded-lg shadow-lg z-50 p-3",onClick:k=>k.stopPropagation(),children:[s.jsx("div",{className:"text-sm font-medium mb-2",children:"Zurückstellen"}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("button",{onClick:()=>g(S.id,3),className:"w-full text-left px-3 py-2 text-sm hover:bg-gray-100 rounded",disabled:b.isPending,children:"+3 Monate"}),s.jsxs("button",{onClick:()=>g(S.id,6),className:"w-full text-left px-3 py-2 text-sm hover:bg-gray-100 rounded bg-blue-50 border-blue-200",disabled:b.isPending,children:["+6 Monate ",s.jsx("span",{className:"text-xs text-gray-500",children:"(Empfohlen)"})]}),s.jsx("button",{onClick:()=>g(S.id,12),className:"w-full text-left px-3 py-2 text-sm hover:bg-gray-100 rounded",disabled:b.isPending,children:"+12 Monate"})]}),s.jsxs("div",{className:"border-t mt-2 pt-2",children:[s.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Eigenes Datum:"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(H,{type:"date",value:m,onChange:k=>f(k.target.value),className:"flex-1 text-sm",min:new Date().toISOString().split("T")[0]}),s.jsx(T,{size:"sm",onClick:()=>g(S.id),disabled:!m||b.isPending,children:"OK"})]})]}),S.issues.some(k=>k.type==="review_due")&&s.jsx("div",{className:"border-t mt-2 pt-2",children:s.jsxs("button",{onClick:()=>y(S.id),className:"w-full text-left px-3 py-2 text-sm hover:bg-red-50 text-red-600 rounded flex items-center gap-2",disabled:b.isPending,children:[s.jsx(hh,{className:"w-4 h-4"}),"Snooze aufheben"]})})]})]}),s.jsx(ke,{to:`/contracts/${S.id}`,state:{from:"cockpit",filter:i!=="all"?i:void 0},className:"p-2 hover:bg-white hover:bg-opacity-50 rounded",onClick:k=>k.stopPropagation(),title:"Zum Vertrag",children:s.jsx(Ae,{className:"w-4 h-4"})})]})]}),A&&s.jsx("div",{className:"border-t px-4 py-3 bg-white bg-opacity-50",children:s.jsx("div",{className:"space-y-2",children:S.issues.map((k,K)=>{const B=AC[k.type]||kn,_=k.urgency==="critical"?kn:k.urgency==="warning"?hs:k.urgency==="ok"?As:on;return s.jsxs("div",{className:"flex items-start gap-3 text-sm",children:[s.jsx(_,{className:`w-4 h-4 mt-0.5 flex-shrink-0 ${k.urgency==="critical"?"text-red-500":k.urgency==="warning"?"text-yellow-500":k.urgency==="ok"?"text-green-500":"text-gray-500"}`}),s.jsx(B,{className:"w-4 h-4 mt-0.5 flex-shrink-0 text-gray-500"}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium",children:k.label}),k.details&&s.jsx("span",{className:"text-gray-600 ml-2",children:k.details})]})]},K)})})})]},S.id)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(kn,{className:"w-6 h-6 text-red-500"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Vertrags-Cockpit"})]}),s.jsx(ke,{to:"/settings/deadlines",className:"text-sm text-blue-600 hover:underline",children:"Fristenschwellen anpassen"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-6",children:[s.jsx(X,{className:"!p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-red-100 rounded-lg",children:s.jsx(kn,{className:"w-6 h-6 text-red-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-red-600",children:E.criticalCount}),s.jsxs("p",{className:"text-sm text-gray-500",children:["Kritisch (<",P.criticalDays," Tage)"]})]})]})}),s.jsx(X,{className:"!p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-yellow-100 rounded-lg",children:s.jsx(hs,{className:"w-6 h-6 text-yellow-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-yellow-600",children:E.warningCount}),s.jsxs("p",{className:"text-sm text-gray-500",children:["Warnung (<",P.warningDays," Tage)"]})]})]})}),s.jsx(X,{className:"!p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-green-100 rounded-lg",children:s.jsx(As,{className:"w-6 h-6 text-green-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-green-600",children:E.okCount}),s.jsxs("p",{className:"text-sm text-gray-500",children:["OK (<",P.okDays," Tage)"]})]})]})}),s.jsx(X,{className:"!p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-gray-100 rounded-lg",children:s.jsx(Be,{className:"w-6 h-6 text-gray-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-gray-600",children:E.totalContracts}),s.jsx("p",{className:"text-sm text-gray-500",children:"Verträge mit Handlungsbedarf"})]})]})})]}),s.jsx(X,{className:"mb-6",children:s.jsx("div",{className:"flex flex-wrap gap-4",children:Object.entries(E.byCategory).map(([S,A])=>A>0&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsxs("span",{className:"font-medium",children:[PC[S]||S,":"]}),s.jsx(ve,{variant:"default",children:A})]},S))})}),s.jsx(X,{className:"mb-6",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("span",{className:"text-sm text-gray-600",children:"Filter:"}),s.jsx(Ie,{value:i,onChange:S=>l(S.target.value),options:[{value:"all",label:`Alle (${o.data.contracts.length})`},{value:"critical",label:`Kritisch (${E.criticalCount})`},{value:"warning",label:`Warnung (${E.warningCount})`},{value:"ok",label:`OK (${E.okCount})`},{value:"deadlines",label:`Fristen (${E.byCategory.cancellationDeadlines+E.byCategory.contractEnding})`},{value:"credentials",label:`Zugangsdaten (${E.byCategory.missingCredentials})`},{value:"data",label:`Fehlende Daten (${E.byCategory.missingData})`},{value:"tasks",label:`Aufgaben/Status (${E.byCategory.openTasks+E.byCategory.pendingContracts})`},{value:"review",label:`Erneute Prüfung (${E.byCategory.reviewDue||0})`},{value:"invoices",label:`Fehlende Rechnungen (${E.byCategory.missingInvoices||0})`}],className:"w-64"}),s.jsxs("span",{className:"text-sm text-gray-500",children:[N.length," Verträge angezeigt"]})]})}),N.length===0?s.jsx(X,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:i==="all"?s.jsxs(s.Fragment,{children:[s.jsx(As,{className:"w-12 h-12 mx-auto mb-4 text-green-500"}),s.jsx("p",{className:"text-lg font-medium",children:"Alles in Ordnung!"}),s.jsx("p",{children:"Keine Verträge mit Handlungsbedarf gefunden."})]}):s.jsx("p",{children:"Keine Verträge für diesen Filter gefunden."})})}):s.jsx("div",{children:N.map(I)})]})}const Bx={OPEN:"Offen",COMPLETED:"Erledigt"},TC={OPEN:"warning",COMPLETED:"success"};function FC(){var B;const e=Yt(),t=ge(),{isCustomerPortal:n,user:r,hasPermission:a}=We(),[i,l]=j.useState("OPEN"),[o,c]=j.useState(new Set),[d,u]=j.useState(!1),[h,x]=j.useState({}),[m,f]=j.useState(null),p=n?"Support-Anfragen":"Aufgaben",b=n?"Anfrage":"Aufgabe",{data:g,isLoading:y}=fe({queryKey:["app-settings-public"],queryFn:()=>Xr.getPublic(),enabled:n,staleTime:0}),v=!y&&((B=g==null?void 0:g.data)==null?void 0:B.customerSupportTicketsEnabled)==="true",{data:N,isLoading:E}=fe({queryKey:["all-tasks",i],queryFn:()=>et.getAll({status:i||void 0}),staleTime:0}),P=G({mutationFn:_=>et.completeSubtask(_),onSuccess:()=>{t.invalidateQueries({queryKey:["all-tasks"]}),t.invalidateQueries({queryKey:["task-stats"]})}}),I=G({mutationFn:_=>et.reopenSubtask(_),onSuccess:()=>{t.invalidateQueries({queryKey:["all-tasks"]}),t.invalidateQueries({queryKey:["task-stats"]})}}),w=G({mutationFn:({taskId:_,title:Q})=>n?et.createReply(_,Q):et.createSubtask(_,Q),onSuccess:(_,{taskId:Q})=>{t.invalidateQueries({queryKey:["all-tasks"]}),x(le=>({...le,[Q]:""}))}}),S=G({mutationFn:_=>et.delete(_),onSuccess:()=>{t.invalidateQueries({queryKey:["all-tasks"]}),t.invalidateQueries({queryKey:["task-stats"]})}}),A=G({mutationFn:({taskId:_,data:Q})=>et.update(_,Q),onSuccess:()=>{t.invalidateQueries({queryKey:["all-tasks"]}),f(null)}}),O=j.useMemo(()=>{var de;if(!(N!=null&&N.data))return{ownTasks:[],representedTasks:[],allTasks:[]};const _=N.data;if(!n)return{allTasks:_,ownTasks:[],representedTasks:[]};const Q=[],le=[];for(const Ke of _)((de=Ke.contract)==null?void 0:de.customerId)===(r==null?void 0:r.customerId)?Q.push(Ke):le.push(Ke);return{ownTasks:Q,representedTasks:le,allTasks:[]}},[N==null?void 0:N.data,n,r==null?void 0:r.customerId]),R=_=>{c(Q=>{const le=new Set(Q);return le.has(_)?le.delete(_):le.add(_),le})},q=_=>{P.isPending||I.isPending||(_.status==="COMPLETED"?I.mutate(_.id):P.mutate(_.id))},D=_=>{var le;const Q=(le=h[_])==null?void 0:le.trim();Q&&w.mutate({taskId:_,title:Q})},z=!n&&a("contracts:update"),k=(_,Q=!1)=>{var Ge,xt,Z,Fe,Xe,J;const le=o.has(_.id),de=_.subtasks&&_.subtasks.length>0,Ke=((Ge=_.subtasks)==null?void 0:Ge.filter(ue=>ue.status==="COMPLETED").length)||0,Ve=((xt=_.subtasks)==null?void 0:xt.length)||0,st=_.status==="COMPLETED",C=new Date(_.createdAt).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}),nt=!n&&a("contracts:update"),es=!n&&a("contracts:update"),Vt=_.contract?`${_.contract.contractNumber} - ${((Z=_.contract.provider)==null?void 0:Z.name)||_.contract.providerName||"Kein Anbieter"}`:`Vertrag #${_.contractId}`,ae=(Fe=_.contract)!=null&&Fe.customer?_.contract.customer.companyName||`${_.contract.customer.firstName} ${_.contract.customer.lastName}`:"";return s.jsxs("div",{className:"border rounded-lg mb-2",children:[s.jsxs("div",{className:"flex items-center p-4 hover:bg-gray-50 cursor-pointer",onClick:()=>R(_.id),children:[s.jsx("div",{className:"w-6 mr-2",children:le?s.jsx(dn,{className:"w-5 h-5 text-gray-400"}):s.jsx(Ft,{className:"w-5 h-5 text-gray-400"})}),s.jsx("div",{className:"mr-3",children:_.status==="COMPLETED"?s.jsx(As,{className:"w-5 h-5 text-green-500"}):s.jsx(on,{className:"w-5 h-5 text-yellow-500"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"font-medium",children:_.title}),s.jsx(ve,{variant:TC[_.status],children:Bx[_.status]}),de&&s.jsxs("span",{className:"text-xs text-gray-500",children:["(",Ke,"/",Ve," erledigt)"]})]}),s.jsxs("div",{className:"text-sm text-gray-500 mt-1 flex items-center gap-2",children:[s.jsx(Be,{className:"w-4 h-4"}),s.jsx(ke,{to:`/contracts/${_.contractId}`,className:"text-blue-600 hover:underline",onClick:ue=>ue.stopPropagation(),children:Vt}),Q&&ae&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-gray-400",children:"|"}),s.jsx("span",{children:ae})]})]}),_.description&&s.jsx("p",{className:"text-sm text-gray-600 mt-1 line-clamp-2",children:_.description}),s.jsxs("div",{className:"text-xs text-gray-400 mt-1",children:[_.createdBy," • ",C]})]}),s.jsxs("div",{className:"ml-4 flex gap-2",children:[nt&&s.jsx(T,{variant:"ghost",size:"sm",onClick:ue=>{ue.stopPropagation(),f(_)},title:"Bearbeiten",children:s.jsx(He,{className:"w-4 h-4"})}),es&&s.jsx(T,{variant:"ghost",size:"sm",onClick:ue=>{ue.stopPropagation(),confirm("Aufgabe wirklich löschen?")&&S.mutate(_.id)},title:"Löschen",className:"text-red-500 hover:text-red-700",children:s.jsx(Ne,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:ue=>{ue.stopPropagation(),e(`/contracts/${_.contractId}`)},title:"Zum Vertrag",children:s.jsx(Ae,{className:"w-4 h-4"})})]})]}),le&&s.jsxs("div",{className:"border-t bg-gray-50 px-4 py-3",children:[de&&s.jsx("div",{className:"space-y-2 mb-4",children:(Xe=_.subtasks)==null?void 0:Xe.map(ue=>{const ts=new Date(ue.createdAt).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"});return s.jsxs("div",{className:`flex items-start gap-2 text-sm ml-6 ${z?"cursor-pointer hover:bg-gray-100 rounded px-2 py-1 -mx-2":""}`,onClick:z?()=>q(ue):void 0,children:[s.jsx("span",{className:"flex-shrink-0 mt-0.5",children:ue.status==="COMPLETED"?s.jsx(As,{className:"w-4 h-4 text-green-500"}):s.jsx(No,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:ue.status==="COMPLETED"?"text-gray-500 line-through":"",children:[ue.title,s.jsxs("span",{className:"text-xs text-gray-400 ml-2",children:[ue.createdBy," • ",ts]})]})]},ue.id)})}),!st&&(z||n)&&s.jsxs("div",{className:"flex gap-2 ml-6",children:[s.jsx(H,{placeholder:n?"Antwort schreiben...":"Neue Unteraufgabe...",value:h[_.id]||"",onChange:ue=>x(ts=>({...ts,[_.id]:ue.target.value})),onKeyDown:ue=>{ue.key==="Enter"&&!ue.shiftKey&&(ue.preventDefault(),D(_.id))},className:"flex-1"}),s.jsx(T,{size:"sm",onClick:()=>D(_.id),disabled:!((J=h[_.id])!=null&&J.trim())||w.isPending,children:s.jsx(Fl,{className:"w-4 h-4"})})]}),!de&&st&&s.jsx("p",{className:"text-gray-500 text-sm text-center py-2",children:"Keine Unteraufgaben vorhanden."})]})]},_.id)},K=n?v:a("contracts:update");return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold",children:p}),K&&s.jsxs(T,{onClick:()=>u(!0),children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Neue ",b]})]}),s.jsx(X,{className:"mb-6",children:s.jsx("div",{className:"flex gap-4 flex-wrap items-center",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-gray-600",children:"Status:"}),s.jsx(Ie,{value:i,onChange:_=>l(_.target.value),options:[{value:"",label:"Alle"},...Object.entries(Bx).map(([_,Q])=>({value:_,label:Q}))],className:"w-40"})]})})}),E?s.jsx(X,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."})}):s.jsx(s.Fragment,{children:n?s.jsxs("div",{className:"space-y-6",children:[s.jsxs(X,{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:[s.jsx(ii,{className:"w-5 h-5 text-blue-600"}),s.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:["Meine ",p]}),s.jsx(ve,{variant:"default",children:O.ownTasks.length})]}),O.ownTasks.length>0?s.jsx("div",{children:O.ownTasks.map(_=>k(_,!1))}):s.jsxs("p",{className:"text-gray-500 text-center py-4",children:["Keine eigenen ",p.toLowerCase()," vorhanden."]})]}),O.representedTasks.length>0&&s.jsxs(X,{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:[s.jsx(Ca,{className:"w-5 h-5 text-purple-600"}),s.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:[p," freigegebener Kunden"]}),s.jsx(ve,{variant:"default",children:O.representedTasks.length})]}),s.jsx("div",{children:O.representedTasks.map(_=>k(_,!0))})]})]}):s.jsx(X,{children:O.allTasks&&O.allTasks.length>0?s.jsx("div",{children:O.allTasks.map(_=>k(_,!0))}):s.jsxs("div",{className:"text-center py-8 text-gray-500",children:["Keine ",p.toLowerCase()," gefunden."]})})}),n?s.jsx(IC,{isOpen:d,onClose:()=>u(!1)}):s.jsx(RC,{isOpen:d,onClose:()=>u(!1)}),m&&s.jsx(LC,{task:m,onClose:()=>f(null),onSave:_=>A.mutate({taskId:m.id,data:_}),isPending:A.isPending})]})}function IC({isOpen:e,onClose:t}){const{user:n}=We(),r=Yt(),a=ge(),[i,l]=j.useState("own"),[o,c]=j.useState(null),[d,u]=j.useState(""),[h,x]=j.useState(""),[m,f]=j.useState(!1),[p,b]=j.useState(""),{data:g}=fe({queryKey:["contracts",n==null?void 0:n.customerId],queryFn:()=>Oe.getAll({customerId:n==null?void 0:n.customerId}),enabled:e}),y=j.useMemo(()=>{if(!(g!=null&&g.data))return{own:[],represented:{}};const w=[],S={};for(const A of g.data)if(A.customerId===(n==null?void 0:n.customerId))w.push(A);else{if(!S[A.customerId]){const O=A.customer?A.customer.companyName||`${A.customer.firstName} ${A.customer.lastName}`:`Kunde ${A.customerId}`;S[A.customerId]={name:O,contracts:[]}}S[A.customerId].contracts.push(A)}return{own:w,represented:S}},[g==null?void 0:g.data,n==null?void 0:n.customerId]),v=Object.keys(y.represented).length>0,N=j.useMemo(()=>{var w;return i==="own"?y.own:((w=y.represented[i])==null?void 0:w.contracts)||[]},[i,y]),E=j.useMemo(()=>{if(!p)return N;const w=p.toLowerCase();return N.filter(S=>S.contractNumber.toLowerCase().includes(w)||(S.providerName||"").toLowerCase().includes(w)||(S.tariffName||"").toLowerCase().includes(w))},[N,p]),P=async()=>{if(!(!o||!d.trim())){f(!0);try{await et.createSupportTicket(o,{title:d.trim(),description:h.trim()||void 0}),a.invalidateQueries({queryKey:["all-tasks"]}),a.invalidateQueries({queryKey:["task-stats"]}),t(),u(""),x(""),c(null),l("own"),r(`/contracts/${o}`)}catch(w){console.error("Fehler beim Erstellen der Support-Anfrage:",w),alert("Fehler beim Erstellen der Support-Anfrage. Bitte versuchen Sie es erneut.")}finally{f(!1)}}},I=()=>{u(""),x(""),c(null),l("own"),b(""),t()};return s.jsx(qe,{isOpen:e,onClose:I,title:"Neue Support-Anfrage",children:s.jsxs("div",{className:"space-y-4",children:[v&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kunde"}),s.jsxs("select",{value:i,onChange:w=>{const S=w.target.value;l(S==="own"?"own":parseInt(S)),c(null),b("")},className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",children:[s.jsx("option",{value:"own",children:"Eigene Verträge"}),Object.entries(y.represented).map(([w,{name:S}])=>s.jsx("option",{value:w,children:S},w))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),s.jsx(H,{placeholder:"Vertrag suchen...",value:p,onChange:w=>b(w.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-lg",children:E.length>0?E.map(w=>s.jsxs("div",{onClick:()=>c(w.id),className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${o===w.id?"bg-blue-50 border-blue-200":""}`,children:[s.jsx("div",{className:"font-medium",children:w.contractNumber}),s.jsxs("div",{className:"text-sm text-gray-500",children:[w.providerName||"Kein Anbieter",w.tariffName&&` - ${w.tariffName}`]})]},w.id)):s.jsx("div",{className:"p-3 text-gray-500 text-center",children:"Keine Verträge gefunden."})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Titel *"}),s.jsx(H,{value:d,onChange:w=>u(w.target.value),placeholder:"Kurze Beschreibung Ihres Anliegens"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung"}),s.jsx("textarea",{value:h,onChange:w=>x(w.target.value),placeholder:"Detaillierte Beschreibung (optional)",rows:4,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:I,children:"Abbrechen"}),s.jsx(T,{onClick:P,disabled:!o||!d.trim()||m,children:m?"Wird erstellt...":"Anfrage erstellen"})]})]})})}function RC({isOpen:e,onClose:t}){const n=Yt(),r=ge(),[a,i]=j.useState(null),[l,o]=j.useState(null),[c,d]=j.useState(""),[u,h]=j.useState(""),[x,m]=j.useState(!1),[f,p]=j.useState(!1),[b,g]=j.useState(""),[y,v]=j.useState(""),{data:N}=fe({queryKey:["customers-for-task"],queryFn:()=>At.getAll({limit:100}),enabled:e}),{data:E}=fe({queryKey:["contracts-for-task",a],queryFn:()=>Oe.getAll({customerId:a}),enabled:e&&a!==null}),P=j.useMemo(()=>{if(!(N!=null&&N.data))return[];if(!b)return N.data;const O=b.toLowerCase();return N.data.filter(R=>R.customerNumber.toLowerCase().includes(O)||R.firstName.toLowerCase().includes(O)||R.lastName.toLowerCase().includes(O)||(R.companyName||"").toLowerCase().includes(O))},[N==null?void 0:N.data,b]),I=j.useMemo(()=>{if(!(E!=null&&E.data))return[];if(!y)return E.data;const O=y.toLowerCase();return E.data.filter(R=>R.contractNumber.toLowerCase().includes(O)||(R.providerName||"").toLowerCase().includes(O)||(R.tariffName||"").toLowerCase().includes(O))},[E==null?void 0:E.data,y]),w=async()=>{if(!(!l||!c.trim())){p(!0);try{await et.create(l,{title:c.trim(),description:u.trim()||void 0,visibleInPortal:x}),r.invalidateQueries({queryKey:["all-tasks"]}),r.invalidateQueries({queryKey:["task-stats"]}),t(),d(""),h(""),m(!1),o(null),i(null),n(`/contracts/${l}`)}catch(O){console.error("Fehler beim Erstellen der Aufgabe:",O),alert("Fehler beim Erstellen der Aufgabe. Bitte versuchen Sie es erneut.")}finally{p(!1)}}},S=()=>{d(""),h(""),m(!1),o(null),i(null),g(""),v(""),t()},A=O=>{const R=O.companyName||`${O.firstName} ${O.lastName}`;return`${O.customerNumber} - ${R}`};return s.jsx(qe,{isOpen:e,onClose:S,title:"Neue Aufgabe",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kunde *"}),s.jsx(H,{placeholder:"Kunde suchen...",value:b,onChange:O=>g(O.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-40 overflow-y-auto border rounded-lg",children:P.length>0?P.map(O=>s.jsx("div",{onClick:()=>{i(O.id),o(null),v("")},className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${a===O.id?"bg-blue-50 border-blue-200":""}`,children:s.jsx("div",{className:"font-medium",children:A(O)})},O.id)):s.jsx("div",{className:"p-3 text-gray-500 text-center",children:"Keine Kunden gefunden."})})]}),a&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),s.jsx(H,{placeholder:"Vertrag suchen...",value:y,onChange:O=>v(O.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-40 overflow-y-auto border rounded-lg",children:I.length>0?I.map(O=>s.jsxs("div",{onClick:()=>o(O.id),className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${l===O.id?"bg-blue-50 border-blue-200":""}`,children:[s.jsx("div",{className:"font-medium",children:O.contractNumber}),s.jsxs("div",{className:"text-sm text-gray-500",children:[O.providerName||"Kein Anbieter",O.tariffName&&` - ${O.tariffName}`]})]},O.id)):s.jsx("div",{className:"p-3 text-gray-500 text-center",children:E?"Keine Verträge gefunden.":"Laden..."})})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Titel *"}),s.jsx(H,{value:c,onChange:O=>d(O.target.value),placeholder:"Aufgabentitel"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung"}),s.jsx("textarea",{value:u,onChange:O=>h(O.target.value),placeholder:"Detaillierte Beschreibung (optional)",rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),s.jsx("div",{children:s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:x,onChange:O=>m(O.target.checked),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),s.jsx("span",{className:"text-sm text-gray-700",children:"Im Kundenportal sichtbar"})]})}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:S,children:"Abbrechen"}),s.jsx(T,{onClick:w,disabled:!l||!c.trim()||f,children:f?"Wird erstellt...":"Aufgabe erstellen"})]})]})})}function LC({task:e,onClose:t,onSave:n,isPending:r}){const[a,i]=j.useState(e.title),[l,o]=j.useState(e.description||""),[c,d]=j.useState(e.visibleInPortal||!1),u=()=>{a.trim()&&n({title:a.trim(),description:l.trim()||void 0,visibleInPortal:c})};return s.jsx(qe,{isOpen:!0,onClose:t,title:"Aufgabe bearbeiten",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Titel *"}),s.jsx(H,{value:a,onChange:h=>i(h.target.value),placeholder:"Aufgabentitel"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung"}),s.jsx("textarea",{value:l,onChange:h=>o(h.target.value),placeholder:"Detaillierte Beschreibung (optional)",rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),s.jsx("div",{children:s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:c,onChange:h=>d(h.target.checked),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),s.jsx("span",{className:"text-sm text-gray-700",children:"Im Kundenportal sichtbar"})]})}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{onClick:u,disabled:!a.trim()||r,children:r?"Wird gespeichert...":"Speichern"})]})]})})}function OC(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,i]=j.useState(!1),{hasPermission:l}=We(),o=ge(),{data:c,isLoading:d}=fe({queryKey:["platforms",a],queryFn:()=>il.getAll(a)}),u=G({mutationFn:il.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["platforms"]})}}),h=m=>{r(m),t(!0)},x=()=>{t(!1),r(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Vertriebsplattformen"}),l("platforms:create")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Neue Plattform"]})]}),s.jsxs(X,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:m=>i(m.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),d?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Name"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Kontakt"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:c.data.map(m=>s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-medium",children:m.name}),s.jsx("td",{className:"py-3 px-4 text-gray-500",children:m.contactInfo||"-"}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ve,{variant:m.isActive?"success":"danger",children:m.isActive?"Aktiv":"Inaktiv"})}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>h(m),children:s.jsx(He,{className:"w-4 h-4"})}),l("platforms:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Plattform wirklich löschen?")&&u.mutate(m.id)},children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})})]},m.id))})]})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Plattformen vorhanden."})]}),s.jsx(zC,{isOpen:e,onClose:x,platform:n})]})}function zC({isOpen:e,onClose:t,platform:n}){const r=ge(),[a,i]=j.useState({name:"",contactInfo:"",isActive:!0});j.useState(()=>{i(n?{name:n.name,contactInfo:n.contactInfo||"",isActive:n.isActive}:{name:"",contactInfo:"",isActive:!0})}),n&&a.name!==n.name?i({name:n.name,contactInfo:n.contactInfo||"",isActive:n.isActive}):!n&&a.name;const l=G({mutationFn:il.create,onSuccess:()=>{r.invalidateQueries({queryKey:["platforms"]}),t(),i({name:"",contactInfo:"",isActive:!0})}}),o=G({mutationFn:u=>il.update(n.id,u),onSuccess:()=>{r.invalidateQueries({queryKey:["platforms"]}),t()}}),c=u=>{u.preventDefault(),n?o.mutate(a):l.mutate(a)},d=l.isPending||o.isPending;return s.jsx(qe,{isOpen:e,onClose:t,title:n?"Plattform bearbeiten":"Neue Plattform",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(H,{label:"Name *",value:a.name,onChange:u=>i({...a,name:u.target.value}),required:!0}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kontaktinformationen"}),s.jsx("textarea",{value:a.contactInfo,onChange:u=>i({...a,contactInfo:u.target.value}),rows:3,className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"E-Mail, Telefon, Ansprechpartner..."})]}),n&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:a.isActive,onChange:u=>i({...a,isActive:u.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}function $C(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,i]=j.useState(!1),{hasPermission:l}=We(),o=ge(),{data:c,isLoading:d}=fe({queryKey:["cancellation-periods",a],queryFn:()=>ll.getAll(a)}),u=G({mutationFn:ll.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["cancellation-periods"]})}}),h=m=>{r(m),t(!0)},x=()=>{t(!1),r(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(ke,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Vs,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Kündigungsfristen"}),l("platforms:create")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Neue Frist"]})]}),s.jsxs(X,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:m=>i(m.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),s.jsxs("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg text-sm",children:[s.jsx("strong",{children:"Code-Format:"})," Zahl + Buchstabe (T=Tage, M=Monate, J=Jahre)",s.jsx("br",{}),s.jsx("strong",{children:"Beispiele:"})," 14T = 14 Tage, 3M = 3 Monate, 1J = 1 Jahr"]}),d?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Code"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beschreibung"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:c.data.map(m=>s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-mono font-medium",children:m.code}),s.jsx("td",{className:"py-3 px-4",children:m.description}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ve,{variant:m.isActive?"success":"danger",children:m.isActive?"Aktiv":"Inaktiv"})}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>h(m),children:s.jsx(He,{className:"w-4 h-4"})}),l("platforms:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Kündigungsfrist wirklich löschen?")&&u.mutate(m.id)},children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})})]},m.id))})]})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Kündigungsfristen vorhanden."})]}),s.jsx(_C,{isOpen:e,onClose:x,period:n})]})}function _C({isOpen:e,onClose:t,period:n}){const r=ge(),[a,i]=j.useState({code:"",description:"",isActive:!0});j.useEffect(()=>{e&&i(n?{code:n.code,description:n.description,isActive:n.isActive}:{code:"",description:"",isActive:!0})},[e,n]);const l=G({mutationFn:ll.create,onSuccess:()=>{r.invalidateQueries({queryKey:["cancellation-periods"]}),t(),i({code:"",description:"",isActive:!0})}}),o=G({mutationFn:u=>ll.update(n.id,u),onSuccess:()=>{r.invalidateQueries({queryKey:["cancellation-periods"]}),t()}}),c=u=>{u.preventDefault(),n?o.mutate(a):l.mutate(a)},d=l.isPending||o.isPending;return s.jsx(qe,{isOpen:e,onClose:t,title:n?"Kündigungsfrist bearbeiten":"Neue Kündigungsfrist",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(H,{label:"Code *",value:a.code,onChange:u=>i({...a,code:u.target.value.toUpperCase()}),required:!0,placeholder:"z.B. 14T, 3M, 1J"}),s.jsx(H,{label:"Beschreibung *",value:a.description,onChange:u=>i({...a,description:u.target.value}),required:!0,placeholder:"z.B. 14 Tage, 3 Monate, 1 Jahr"}),n&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:a.isActive,onChange:u=>i({...a,isActive:u.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}function KC(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,i]=j.useState(!1),{hasPermission:l}=We(),o=ge(),{data:c,isLoading:d}=fe({queryKey:["contract-durations",a],queryFn:()=>ol.getAll(a)}),u=G({mutationFn:ol.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["contract-durations"]})}}),h=m=>{r(m),t(!0)},x=()=>{t(!1),r(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(ke,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Vs,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Vertragslaufzeiten"}),l("platforms:create")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Neue Laufzeit"]})]}),s.jsxs(X,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:m=>i(m.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),s.jsxs("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg text-sm",children:[s.jsx("strong",{children:"Code-Format:"})," Zahl + Buchstabe (T=Tage, M=Monate, J=Jahre)",s.jsx("br",{}),s.jsx("strong",{children:"Beispiele:"})," 12M = 12 Monate, 24M = 24 Monate, 2J = 2 Jahre"]}),d?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Code"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beschreibung"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:c.data.map(m=>s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-mono font-medium",children:m.code}),s.jsx("td",{className:"py-3 px-4",children:m.description}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ve,{variant:m.isActive?"success":"danger",children:m.isActive?"Aktiv":"Inaktiv"})}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>h(m),children:s.jsx(He,{className:"w-4 h-4"})}),l("platforms:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Laufzeit wirklich löschen?")&&u.mutate(m.id)},children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})})]},m.id))})]})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Laufzeiten vorhanden."})]}),s.jsx(BC,{isOpen:e,onClose:x,duration:n})]})}function BC({isOpen:e,onClose:t,duration:n}){const r=ge(),[a,i]=j.useState({code:"",description:"",isActive:!0});j.useEffect(()=>{e&&i(n?{code:n.code,description:n.description,isActive:n.isActive}:{code:"",description:"",isActive:!0})},[e,n]);const l=G({mutationFn:ol.create,onSuccess:()=>{r.invalidateQueries({queryKey:["contract-durations"]}),t(),i({code:"",description:"",isActive:!0})}}),o=G({mutationFn:u=>ol.update(n.id,u),onSuccess:()=>{r.invalidateQueries({queryKey:["contract-durations"]}),t()}}),c=u=>{u.preventDefault(),n?o.mutate(a):l.mutate(a)},d=l.isPending||o.isPending;return s.jsx(qe,{isOpen:e,onClose:t,title:n?"Laufzeit bearbeiten":"Neue Laufzeit",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(H,{label:"Code *",value:a.code,onChange:u=>i({...a,code:u.target.value.toUpperCase()}),required:!0,placeholder:"z.B. 12M, 24M, 2J"}),s.jsx(H,{label:"Beschreibung *",value:a.description,onChange:u=>i({...a,description:u.target.value}),required:!0,placeholder:"z.B. 12 Monate, 24 Monate, 2 Jahre"}),n&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:a.isActive,onChange:u=>i({...a,isActive:u.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}function UC(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,i]=j.useState(!1),[l,o]=j.useState(new Set),{hasPermission:c}=We(),d=ge(),{data:u,isLoading:h}=fe({queryKey:["providers",a],queryFn:()=>Xa.getAll(a)}),x=G({mutationFn:Xa.delete,onSuccess:()=>{d.invalidateQueries({queryKey:["providers"]})},onError:b=>{alert(b.message)}}),m=b=>{o(g=>{const y=new Set(g);return y.has(b)?y.delete(b):y.add(b),y})},f=b=>{r(b),t(!0)},p=()=>{t(!1),r(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(ke,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Vs,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Anbieter & Tarife"}),c("providers:create")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Neuer Anbieter"]})]}),s.jsxs(X,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:b=>i(b.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),h?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):u!=null&&u.data&&u.data.length>0?s.jsx("div",{className:"space-y-2",children:u.data.map(b=>s.jsx(qC,{provider:b,isExpanded:l.has(b.id),onToggle:()=>m(b.id),onEdit:()=>f(b),onDelete:()=>{confirm("Anbieter wirklich löschen?")&&x.mutate(b.id)},hasPermission:c,showInactive:a},b.id))}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Anbieter vorhanden."})]}),s.jsx(VC,{isOpen:e,onClose:p,provider:n})]})}function qC({provider:e,isExpanded:t,onToggle:n,onEdit:r,onDelete:a,hasPermission:i,showInactive:l}){var f,p;const[o,c]=j.useState(!1),[d,u]=j.useState(null),h=ge(),x=G({mutationFn:yv.delete,onSuccess:()=>{h.invalidateQueries({queryKey:["providers"]})},onError:b=>{alert(b.message)}}),m=((f=e.tariffs)==null?void 0:f.filter(b=>l||b.isActive))||[];return s.jsxs("div",{className:"border rounded-lg",children:[s.jsxs("div",{className:"flex items-center p-4 hover:bg-gray-50",children:[s.jsx("button",{onClick:n,className:"mr-3 p-1 hover:bg-gray-200 rounded",children:t?s.jsx(dn,{className:"w-5 h-5 text-gray-400"}):s.jsx(Ft,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"font-medium",children:e.name}),s.jsx(ve,{variant:e.isActive?"success":"danger",children:e.isActive?"Aktiv":"Inaktiv"}),s.jsxs("span",{className:"text-sm text-gray-500",children:["(",m.length," Tarife, ",((p=e._count)==null?void 0:p.contracts)||0," Verträge)"]})]}),e.portalUrl&&s.jsxs("a",{href:e.portalUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 hover:underline flex items-center gap-1 mt-1",children:[s.jsx(dh,{className:"w-3 h-3"}),e.portalUrl]})]}),s.jsxs("div",{className:"flex gap-2 ml-4",children:[i("providers:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:r,title:"Bearbeiten",children:s.jsx(He,{className:"w-4 h-4"})}),i("providers:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:a,title:"Löschen",children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})]}),t&&s.jsxs("div",{className:"border-t bg-gray-50 p-4",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsx("h4",{className:"font-medium text-gray-700",children:"Tarife"}),i("providers:create")&&s.jsxs(T,{size:"sm",onClick:()=>c(!0),children:[s.jsx(_e,{className:"w-4 h-4 mr-1"}),"Tarif hinzufügen"]})]}),m.length>0?s.jsx("div",{className:"space-y-2",children:m.map(b=>{var g;return s.jsxs("div",{className:"flex items-center justify-between bg-white p-3 rounded border",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{children:b.name}),s.jsx(ve,{variant:b.isActive?"success":"danger",className:"text-xs",children:b.isActive?"Aktiv":"Inaktiv"}),((g=b._count)==null?void 0:g.contracts)!==void 0&&s.jsxs("span",{className:"text-xs text-gray-500",children:["(",b._count.contracts," Verträge)"]})]}),s.jsxs("div",{className:"flex gap-1",children:[i("providers:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{u(b),c(!0)},title:"Bearbeiten",children:s.jsx(He,{className:"w-3 h-3"})}),i("providers:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Tarif wirklich löschen?")&&x.mutate(b.id)},title:"Löschen",children:s.jsx(Ne,{className:"w-3 h-3 text-red-500"})})]})]},b.id)})}):s.jsx("p",{className:"text-sm text-gray-500",children:"Keine Tarife vorhanden."})]}),s.jsx(QC,{isOpen:o,onClose:()=>{c(!1),u(null)},providerId:e.id,tariff:d})]})}function VC({isOpen:e,onClose:t,provider:n}){const r=ge(),[a,i]=j.useState({name:"",portalUrl:"",usernameFieldName:"",passwordFieldName:"",isActive:!0});j.useEffect(()=>{e&&i(n?{name:n.name,portalUrl:n.portalUrl||"",usernameFieldName:n.usernameFieldName||"",passwordFieldName:n.passwordFieldName||"",isActive:n.isActive}:{name:"",portalUrl:"",usernameFieldName:"",passwordFieldName:"",isActive:!0})},[e,n]);const l=G({mutationFn:Xa.create,onSuccess:()=>{r.invalidateQueries({queryKey:["providers"]}),t()},onError:u=>{alert(u.message)}}),o=G({mutationFn:u=>Xa.update(n.id,u),onSuccess:()=>{r.invalidateQueries({queryKey:["providers"]}),t()},onError:u=>{alert(u.message)}}),c=u=>{u.preventDefault(),n?o.mutate(a):l.mutate(a)},d=l.isPending||o.isPending;return s.jsx(qe,{isOpen:e,onClose:t,title:n?"Anbieter bearbeiten":"Neuer Anbieter",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(H,{label:"Anbietername *",value:a.name,onChange:u=>i({...a,name:u.target.value}),required:!0,placeholder:"z.B. Vodafone, E.ON, Allianz"}),s.jsx(H,{label:"Portal-URL (Login-Seite)",value:a.portalUrl,onChange:u=>i({...a,portalUrl:u.target.value}),placeholder:"https://kundenportal.anbieter.de/login"}),s.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg space-y-3",children:[s.jsxs("p",{className:"text-sm text-gray-600",children:[s.jsx("strong",{children:"Auto-Login Felder"})," (optional)",s.jsx("br",{}),"Feldnamen für URL-Parameter beim Auto-Login:"]}),s.jsx(H,{label:"Benutzername-Feldname",value:a.usernameFieldName,onChange:u=>i({...a,usernameFieldName:u.target.value}),placeholder:"z.B. username, email, login"}),s.jsx(H,{label:"Passwort-Feldname",value:a.passwordFieldName,onChange:u=>i({...a,passwordFieldName:u.target.value}),placeholder:"z.B. password, pwd, kennwort"})]}),n&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:a.isActive,onChange:u=>i({...a,isActive:u.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}function QC({isOpen:e,onClose:t,providerId:n,tariff:r}){const a=ge(),[i,l]=j.useState({name:"",isActive:!0});j.useEffect(()=>{e&&l(r?{name:r.name,isActive:r.isActive}:{name:"",isActive:!0})},[e,r]);const o=G({mutationFn:h=>Xa.createTariff(n,h),onSuccess:()=>{a.invalidateQueries({queryKey:["providers"]}),t()},onError:h=>{alert(h.message)}}),c=G({mutationFn:h=>yv.update(r.id,h),onSuccess:()=>{a.invalidateQueries({queryKey:["providers"]}),t()},onError:h=>{alert(h.message)}}),d=h=>{h.preventDefault(),r?c.mutate(i):o.mutate(i)},u=o.isPending||c.isPending;return s.jsx(qe,{isOpen:e,onClose:t,title:r?"Tarif bearbeiten":"Neuer Tarif",children:s.jsxs("form",{onSubmit:d,className:"space-y-4",children:[s.jsx(H,{label:"Tarifname *",value:i.name,onChange:h=>l({...i,name:h.target.value}),required:!0,placeholder:"z.B. Comfort Plus, Basic 100"}),r&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:i.isActive,onChange:h=>l({...i,isActive:h.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}const Ju={Zap:s.jsx(xh,{className:"w-5 h-5"}),Flame:s.jsx(Ev,{className:"w-5 h-5"}),Wifi:s.jsx(Ea,{className:"w-5 h-5"}),Cable:s.jsx(P2,{className:"w-5 h-5"}),Network:s.jsx(q2,{className:"w-5 h-5"}),Smartphone:s.jsx(fh,{className:"w-5 h-5"}),Tv:s.jsx(Fv,{className:"w-5 h-5"}),Car:s.jsx(Cv,{className:"w-5 h-5"}),FileText:s.jsx(Be,{className:"w-5 h-5"})},HC=[{value:"Zap",label:"Blitz (Strom)"},{value:"Flame",label:"Flamme (Gas)"},{value:"Wifi",label:"WLAN (DSL)"},{value:"Cable",label:"Kabel"},{value:"Network",label:"Netzwerk (Glasfaser)"},{value:"Smartphone",label:"Smartphone (Mobilfunk)"},{value:"Tv",label:"TV"},{value:"Car",label:"Auto (KFZ)"},{value:"FileText",label:"Dokument (Sonstige)"}],WC=[{value:"#FFC107",label:"Gelb"},{value:"#FF5722",label:"Orange"},{value:"#2196F3",label:"Blau"},{value:"#9C27B0",label:"Lila"},{value:"#4CAF50",label:"Grün"},{value:"#E91E63",label:"Pink"},{value:"#607D8B",label:"Grau"},{value:"#795548",label:"Braun"},{value:"#00BCD4",label:"Cyan"},{value:"#F44336",label:"Rot"}];function GC(){const[e,t]=j.useState(!1),[n,r]=j.useState(null),[a,i]=j.useState(!1),{hasPermission:l}=We(),o=ge(),{data:c,isLoading:d}=fe({queryKey:["contract-categories",a],queryFn:()=>cl.getAll(a)}),u=G({mutationFn:cl.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["contract-categories"]})},onError:m=>{alert(m.message)}}),h=m=>{r(m),t(!0)},x=()=>{t(!1),r(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(ke,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Vs,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Vertragstypen"}),l("developer:access")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Neuer Vertragstyp"]})]}),s.jsxs(X,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:m=>i(m.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),d?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?s.jsx("div",{className:"space-y-2",children:c.data.map(m=>{var f;return s.jsxs("div",{className:"flex items-center p-4 border rounded-lg hover:bg-gray-50",children:[s.jsx("div",{className:"mr-3 text-gray-400",children:s.jsx(L2,{className:"w-5 h-5"})}),s.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center mr-4",style:{backgroundColor:m.color||"#E5E7EB",color:"#fff"},children:m.icon&&Ju[m.icon]?Ju[m.icon]:s.jsx(Be,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"font-medium",children:m.name}),s.jsx(ve,{variant:m.isActive?"success":"danger",children:m.isActive?"Aktiv":"Inaktiv"}),s.jsxs("span",{className:"text-sm text-gray-500",children:["(",((f=m._count)==null?void 0:f.contracts)||0," Verträge)"]})]}),s.jsxs("div",{className:"text-sm text-gray-500",children:["Code: ",s.jsx("span",{className:"font-mono",children:m.code})]})]}),s.jsxs("div",{className:"flex gap-2 ml-4",children:[l("developer:access")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>h(m),title:"Bearbeiten",children:s.jsx(He,{className:"w-4 h-4"})}),l("developer:access")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertragstyp wirklich löschen?")&&u.mutate(m.id)},title:"Löschen",children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})]},m.id)})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Vertragstypen vorhanden."})]}),s.jsx(ZC,{isOpen:e,onClose:x,category:n})]})}function ZC({isOpen:e,onClose:t,category:n}){const r=ge(),[a,i]=j.useState({code:"",name:"",icon:"FileText",color:"#607D8B",sortOrder:0,isActive:!0});j.useEffect(()=>{e&&i(n?{code:n.code,name:n.name,icon:n.icon||"FileText",color:n.color||"#607D8B",sortOrder:n.sortOrder,isActive:n.isActive}:{code:"",name:"",icon:"FileText",color:"#607D8B",sortOrder:0,isActive:!0})},[e,n]);const l=G({mutationFn:cl.create,onSuccess:()=>{r.invalidateQueries({queryKey:["contract-categories"]}),t()},onError:u=>{alert(u.message)}}),o=G({mutationFn:u=>cl.update(n.id,u),onSuccess:()=>{r.invalidateQueries({queryKey:["contract-categories"]}),t()},onError:u=>{alert(u.message)}}),c=u=>{u.preventDefault(),n?o.mutate(a):l.mutate(a)},d=l.isPending||o.isPending;return s.jsx(qe,{isOpen:e,onClose:t,title:n?"Vertragstyp bearbeiten":"Neuer Vertragstyp",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(H,{label:"Code (technisch) *",value:a.code,onChange:u=>i({...a,code:u.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")}),required:!0,placeholder:"z.B. ELECTRICITY, MOBILE_BUSINESS",disabled:!!n}),s.jsx(H,{label:"Anzeigename *",value:a.name,onChange:u=>i({...a,name:u.target.value}),required:!0,placeholder:"z.B. Strom, Mobilfunk Business"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Icon"}),s.jsx("div",{className:"grid grid-cols-4 gap-2",children:HC.map(u=>s.jsxs("button",{type:"button",onClick:()=>i({...a,icon:u.value}),className:`p-3 border rounded-lg flex flex-col items-center gap-1 text-xs ${a.icon===u.value?"border-blue-500 bg-blue-50":"border-gray-200 hover:bg-gray-50"}`,children:[Ju[u.value],s.jsx("span",{className:"truncate w-full text-center",children:u.label.split(" ")[0]})]},u.value))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Farbe"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:WC.map(u=>s.jsx("button",{type:"button",onClick:()=>i({...a,color:u.value}),className:`w-8 h-8 rounded-full border-2 ${a.color===u.value?"border-gray-800 ring-2 ring-offset-2 ring-gray-400":"border-transparent"}`,style:{backgroundColor:u.value},title:u.label},u.value))})]}),s.jsx(H,{label:"Sortierung",type:"number",value:a.sortOrder,onChange:u=>i({...a,sortOrder:parseInt(u.target.value)||0}),placeholder:"0"}),n&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:a.isActive,onChange:u=>i({...a,isActive:u.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}const JC=[{value:"0.1",label:"10%"},{value:"0.2",label:"20%"},{value:"0.3",label:"30%"},{value:"0.4",label:"40%"},{value:"0.5",label:"50%"},{value:"0.6",label:"60%"},{value:"0.7",label:"70% (Standard)"},{value:"0.8",label:"80%"},{value:"0.9",label:"90%"},{value:"999",label:"Deaktiviert"}];function XC(){const{settings:e,updateSettings:t}=bv();return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(ke,{to:"/settings",className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:s.jsx(Vs,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ae,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Ansicht"})]})]}),s.jsx(X,{title:"Scroll-Verhalten",children:s.jsx("div",{className:"space-y-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Nach-oben-Button"}),s.jsx("p",{className:"text-sm text-gray-500",children:"Ab welcher Scroll-Position der Button unten rechts erscheinen soll"})]}),s.jsx("div",{className:"w-48",children:s.jsx(Ie,{options:JC,value:e.scrollToTopThreshold.toString(),onChange:n=>t({scrollToTopThreshold:parseFloat(n.target.value)})})})]})})})]})}function YC(){const e=ge(),{data:t,isLoading:n}=fe({queryKey:["app-settings"],queryFn:()=>Xr.getAll()}),[r,a]=j.useState(!1);j.useEffect(()=>{t!=null&&t.data&&a(t.data.customerSupportTicketsEnabled==="true")},[t]);const i=G({mutationFn:o=>Xr.update(o),onSuccess:()=>{e.invalidateQueries({queryKey:["app-settings"]}),e.invalidateQueries({queryKey:["app-settings-public"]})}}),l=o=>{a(o),i.mutate({customerSupportTicketsEnabled:o?"true":"false"})};return n?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"text-gray-500",children:"Laden..."})}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(ke,{to:"/settings",className:"text-gray-500 hover:text-gray-700",children:s.jsx(Vs,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(uh,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Kundenportal"})]})]}),s.jsxs(X,{title:"Support-Anfragen",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(ul,{className:"w-5 h-5 text-gray-500"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Kunden können Support-Anfragen erstellen"}),s.jsx("p",{className:"text-sm text-gray-500",children:"Wenn aktiviert, können Kunden im Portal Support-Anfragen zu ihren Verträgen erstellen. Diese erscheinen als Aufgaben in der Vertragsdetailansicht."})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:o=>l(o.target.checked),disabled:i.isPending,className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"})]})]}),r&&s.jsx("div",{className:"mt-4 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:s.jsxs("p",{className:"text-sm text-blue-800",children:[s.jsx("strong",{children:"Hinweis:"}),' Kunden sehen diese Anfragen als "Support-Anfragen" in ihrem Portal. Sie können die Anfrage mit einem Titel und einer Beschreibung erstellen. Ihre Mitarbeiter können dann mit Antworten (Unteraufgaben) reagieren.']})})]})]})}function e4(){const e=ge(),{data:t,isLoading:n}=fe({queryKey:["app-settings"],queryFn:()=>Xr.getAll()}),[r,a]=j.useState("14"),[i,l]=j.useState("42"),[o,c]=j.useState("90"),[d,u]=j.useState(!1);j.useEffect(()=>{t!=null&&t.data&&(a(t.data.deadlineCriticalDays||"14"),l(t.data.deadlineWarningDays||"42"),c(t.data.deadlineOkDays||"90"),u(!1))},[t]);const h=G({mutationFn:f=>Xr.update(f),onSuccess:()=>{e.invalidateQueries({queryKey:["app-settings"]}),e.invalidateQueries({queryKey:["contract-cockpit"]}),u(!1)}}),x=()=>{const f=parseInt(r),p=parseInt(i),b=parseInt(o);if(isNaN(f)||isNaN(p)||isNaN(b)){alert("Bitte gültige Zahlen eingeben");return}if(f>=p||p>=b){alert("Die Werte müssen aufsteigend sein: Kritisch < Warnung < OK");return}h.mutate({deadlineCriticalDays:r,deadlineWarningDays:i,deadlineOkDays:o})},m=(f,p)=>{f(p),u(!0)};return n?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"text-gray-500",children:"Laden..."})}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(ke,{to:"/settings",className:"text-gray-500 hover:text-gray-700",children:s.jsx(Vs,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(on,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Fristenschwellen"})]})]}),s.jsxs(X,{title:"Farbkodierung für Fristen",children:[s.jsx("p",{className:"text-gray-600 mb-6",children:"Definiere, ab wann Vertragsfristen als kritisch (rot), Warnung (gelb) oder OK (grün) angezeigt werden sollen. Die Werte geben die Anzahl der Tage bis zur Frist an."}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center gap-4 p-4 bg-red-50 border border-red-200 rounded-lg",children:[s.jsx(kn,{className:"w-8 h-8 text-red-500 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block font-medium text-red-800 mb-1",children:"Kritisch (Rot)"}),s.jsx("p",{className:"text-sm text-red-600 mb-2",children:"Fristen mit weniger als X Tagen werden rot markiert"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(H,{type:"number",min:"1",value:r,onChange:f=>m(a,f.target.value),className:"w-24"}),s.jsx("span",{className:"text-red-700",children:"Tage"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-4 p-4 bg-yellow-50 border border-yellow-200 rounded-lg",children:[s.jsx(hs,{className:"w-8 h-8 text-yellow-500 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block font-medium text-yellow-800 mb-1",children:"Warnung (Gelb)"}),s.jsx("p",{className:"text-sm text-yellow-600 mb-2",children:"Fristen mit weniger als X Tagen werden gelb markiert"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(H,{type:"number",min:"1",value:i,onChange:f=>m(l,f.target.value),className:"w-24"}),s.jsx("span",{className:"text-yellow-700",children:"Tage"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-4 p-4 bg-green-50 border border-green-200 rounded-lg",children:[s.jsx(As,{className:"w-8 h-8 text-green-500 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block font-medium text-green-800 mb-1",children:"OK (Grün)"}),s.jsx("p",{className:"text-sm text-green-600 mb-2",children:"Fristen mit weniger als X Tagen werden grün markiert (darüber nicht angezeigt)"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(H,{type:"number",min:"1",value:o,onChange:f=>m(c,f.target.value),className:"w-24"}),s.jsx("span",{className:"text-green-700",children:"Tage"})]})]})]})]}),s.jsxs("div",{className:"mt-6 pt-4 border-t flex justify-between items-center",children:[s.jsx("p",{className:"text-sm text-gray-500",children:"Beispiel: Bei 14/42/90 Tagen wird eine Frist die in 10 Tagen abläuft rot, eine in 30 Tagen gelb, und eine in 60 Tagen grün markiert."}),s.jsx(T,{onClick:x,disabled:!d||h.isPending,children:h.isPending?"Speichere...":"Speichern"})]})]})]})}const t4=[{value:"PLESK",label:"Plesk"},{value:"CPANEL",label:"cPanel"},{value:"DIRECTADMIN",label:"DirectAdmin"}],Ux=[{value:"SSL",label:"SSL/TLS",description:"Verschlüsselung von Anfang an"},{value:"STARTTLS",label:"STARTTLS",description:"Startet unverschlüsselt, dann Upgrade"},{value:"NONE",label:"Keine",description:"Keine Verschlüsselung"}],bd={name:"",type:"PLESK",apiUrl:"",apiKey:"",username:"",password:"",domain:"stressfrei-wechseln.de",defaultForwardEmail:"",imapEncryption:"SSL",smtpEncryption:"SSL",allowSelfSignedCerts:!1,isActive:!0,isDefault:!1};function s4(){const e=Yt(),t=ge(),[n,r]=j.useState(!1),[a,i]=j.useState(null),[l,o]=j.useState(bd),[c,d]=j.useState(!1),[u,h]=j.useState(null),[x,m]=j.useState(!1),[f,p]=j.useState({}),[b,g]=j.useState(null),{data:y,isLoading:v}=fe({queryKey:["email-provider-configs"],queryFn:()=>yn.getConfigs()}),N=G({mutationFn:k=>yn.createConfig(k),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]}),A()}}),E=G({mutationFn:({id:k,data:K})=>yn.updateConfig(k,K),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]}),A()}}),P=G({mutationFn:k=>yn.deleteConfig(k),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]})}}),I=(y==null?void 0:y.data)||[],w=()=>{o(bd),i(null),d(!1),h(null),r(!0)},S=k=>{o({name:k.name,type:k.type,apiUrl:k.apiUrl,apiKey:k.apiKey||"",username:k.username||"",password:"",domain:k.domain,defaultForwardEmail:k.defaultForwardEmail||"",imapEncryption:k.imapEncryption??"SSL",smtpEncryption:k.smtpEncryption??"SSL",allowSelfSignedCerts:k.allowSelfSignedCerts??!1,isActive:k.isActive,isDefault:k.isDefault}),i(k.id),d(!1),h(null),r(!0)},A=()=>{r(!1),i(null),o(bd),d(!1),h(null)},O=async k=>{var K,B,_;g(k.id),p(Q=>({...Q,[k.id]:null}));try{const Q=await yn.testConnection({id:k.id}),le={success:((K=Q.data)==null?void 0:K.success)||!1,message:(B=Q.data)==null?void 0:B.message,error:(_=Q.data)==null?void 0:_.error};p(de=>({...de,[k.id]:le}))}catch(Q){p(le=>({...le,[k.id]:{success:!1,error:Q instanceof Error?Q.message:"Unbekannter Fehler beim Testen"}}))}finally{g(null)}},R=async()=>{var k,K,B;if(!l.apiUrl||!l.domain){h({success:!1,error:"Bitte geben Sie API-URL und Domain ein."});return}m(!0),h(null);try{const _=await yn.testConnection({testData:{type:l.type,apiUrl:l.apiUrl,apiKey:l.apiKey||void 0,username:l.username||void 0,password:l.password||void 0,domain:l.domain}});h({success:((k=_.data)==null?void 0:k.success)||!1,message:(K=_.data)==null?void 0:K.message,error:(B=_.data)==null?void 0:B.error})}catch(_){h({success:!1,error:_ instanceof Error?_.message:"Unbekannter Fehler beim Verbindungstest"})}finally{m(!1)}},q=k=>{k.preventDefault();const K={name:l.name,type:l.type,apiUrl:l.apiUrl,apiKey:l.apiKey,username:l.username,domain:l.domain,defaultForwardEmail:l.defaultForwardEmail,imapEncryption:l.imapEncryption,smtpEncryption:l.smtpEncryption,allowSelfSignedCerts:l.allowSelfSignedCerts,isActive:l.isActive,isDefault:l.isDefault};l.password&&(K.password=l.password),a?E.mutate({id:a,data:K}):N.mutate(K)},D=(k,K)=>{confirm(`Möchten Sie den Provider "${K}" wirklich löschen?`)&&P.mutate(k)},z=k=>k.error?k.error:k.message?k.message:"Verbindung fehlgeschlagen";return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsxs(T,{variant:"ghost",onClick:()=>e("/settings"),children:[s.jsx(Vs,{className:"w-4 h-4 mr-2"}),"Zurück"]}),s.jsx("h1",{className:"text-2xl font-bold",children:"Email-Provisionierung"})]}),s.jsxs(X,{className:"mb-6",children:[s.jsx("p",{className:"text-gray-600 mb-4",children:'Hier konfigurieren Sie die automatische Erstellung von Stressfrei-Wechseln E-Mail-Adressen. Wenn beim Anlegen einer Stressfrei-Adresse die Option "Bei Provider anlegen" aktiviert ist, wird die E-Mail-Weiterleitung automatisch erstellt.'}),s.jsxs(T,{onClick:w,children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Provider hinzufügen"]})]}),v?s.jsx("div",{className:"text-center py-8",children:"Laden..."}):I.length===0?s.jsx(X,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Noch keine Email-Provider konfiguriert."})}):s.jsx("div",{className:"space-y-4",children:I.map(k=>{const K=f[k.id],B=b===k.id;return s.jsx(X,{children:s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h3",{className:"font-semibold text-lg",children:k.name}),s.jsx("span",{className:"px-2 py-1 text-xs rounded bg-blue-100 text-blue-800",children:k.type}),k.isDefault&&s.jsx("span",{className:"px-2 py-1 text-xs rounded bg-green-100 text-green-800",children:"Standard"}),!k.isActive&&s.jsx("span",{className:"px-2 py-1 text-xs rounded bg-gray-100 text-gray-600",children:"Inaktiv"})]}),s.jsxs("dl",{className:"mt-3 grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"API-URL"}),s.jsx("dd",{className:"font-mono text-xs truncate",children:k.apiUrl})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Domain"}),s.jsx("dd",{children:k.domain})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Benutzer"}),s.jsx("dd",{children:k.username||"-"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Standard-Weiterleitung"}),s.jsx("dd",{className:"truncate",children:k.defaultForwardEmail||"-"})]})]}),K&&s.jsx("div",{className:`mt-3 p-3 rounded-lg text-sm ${K.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:K.success?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xr,{className:"w-4 h-4 flex-shrink-0"}),s.jsx("span",{children:"Verbindung erfolgreich!"})]}):s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(xx,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),s.jsx("span",{children:z(K)})]})})]}),s.jsxs("div",{className:"flex gap-2 ml-4",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>O(k),disabled:B,title:"Verbindung testen",children:B?s.jsx("span",{className:"w-4 h-4 border-2 border-gray-400 border-t-transparent rounded-full animate-spin"}):s.jsx(Ea,{className:"w-4 h-4 text-blue-500"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>S(k),children:s.jsx(He,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>D(k.id,k.name),children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})]})},k.id)})}),n&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsx("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto",children:s.jsxs("div",{className:"p-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h2",{className:"text-xl font-semibold",children:a?"Provider bearbeiten":"Neuer Provider"}),s.jsx("button",{onClick:A,className:"text-gray-400 hover:text-gray-600",children:s.jsx(qt,{className:"w-5 h-5"})})]}),(N.error||E.error)&&s.jsx("div",{className:"mb-4 p-3 rounded-lg bg-red-50 text-red-800 text-sm",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(qt,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),s.jsx("span",{children:N.error instanceof Error?N.error.message:E.error instanceof Error?E.error.message:"Fehler beim Speichern"})]})}),s.jsxs("form",{onSubmit:q,className:"space-y-4",children:[s.jsx(H,{label:"Name *",value:l.name,onChange:k=>o({...l,name:k.target.value}),placeholder:"z.B. Plesk Hauptserver",required:!0}),s.jsx(Ie,{label:"Provider-Typ *",value:l.type,onChange:k=>o({...l,type:k.target.value}),options:t4}),s.jsx(H,{label:"API-URL *",value:l.apiUrl,onChange:k=>o({...l,apiUrl:k.target.value}),placeholder:"https://server.de:8443",required:!0}),s.jsx(H,{label:"API-Key",value:l.apiKey,onChange:k=>o({...l,apiKey:k.target.value}),placeholder:"Optional - alternativ zu Benutzername/Passwort"}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(H,{label:"Benutzername",value:l.username,onChange:k=>o({...l,username:k.target.value}),placeholder:"admin"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:a?"Neues Passwort (leer = beibehalten)":"Passwort"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:c?"text":"password",value:l.password,onChange:k=>o({...l,password:k.target.value}),className:"block w-full px-3 py-2 pr-10 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),s.jsx("button",{type:"button",onClick:()=>d(!c),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:c?s.jsx(It,{className:"w-4 h-4"}):s.jsx(Ae,{className:"w-4 h-4"})})]})]})]}),s.jsx(H,{label:"Domain *",value:l.domain,onChange:k=>o({...l,domain:k.target.value}),placeholder:"stressfrei-wechseln.de",required:!0}),s.jsx(H,{label:"Standard-Weiterleitungsadresse",value:l.defaultForwardEmail,onChange:k=>o({...l,defaultForwardEmail:k.target.value}),placeholder:"info@meinefirma.de",type:"email"}),s.jsx("p",{className:"text-xs text-gray-500 -mt-2",children:"Diese E-Mail-Adresse wird zusätzlich zur Kunden-E-Mail als Weiterleitungsziel hinzugefügt."}),s.jsxs("div",{className:"pt-4 border-t",children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"E-Mail-Verbindungseinstellungen"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["IMAP Verschlüsselung",s.jsxs("span",{className:"text-gray-400 font-normal ml-1",children:["(Port ",l.imapEncryption==="SSL"?"993":"143",")"]})]}),s.jsx("select",{value:l.imapEncryption,onChange:k=>o({...l,imapEncryption:k.target.value}),className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm",children:Ux.map(k=>s.jsxs("option",{value:k.value,children:[k.label," - ",k.description]},k.value))})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["SMTP Verschlüsselung",s.jsxs("span",{className:"text-gray-400 font-normal ml-1",children:["(Port ",l.smtpEncryption==="SSL"?"465":l.smtpEncryption==="STARTTLS"?"587":"25",")"]})]}),s.jsx("select",{value:l.smtpEncryption,onChange:k=>o({...l,smtpEncryption:k.target.value}),className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm",children:Ux.map(k=>s.jsxs("option",{value:k.value,children:[k.label," - ",k.description]},k.value))})]})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:l.allowSelfSignedCerts,onChange:k=>o({...l,allowSelfSignedCerts:k.target.checked}),className:"rounded border-gray-300"}),s.jsx("span",{className:"text-sm",children:"Selbstsignierte Zertifikate erlauben"})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"Aktivieren Sie diese Option für Testumgebungen mit selbstsignierten SSL-Zertifikaten."})]})]}),s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:l.isActive,onChange:k=>o({...l,isActive:k.target.checked}),className:"rounded border-gray-300"}),s.jsx("span",{className:"text-sm",children:"Aktiv"})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:l.isDefault,onChange:k=>o({...l,isDefault:k.target.checked}),className:"rounded border-gray-300"}),s.jsx("span",{className:"text-sm",children:"Als Standard verwenden"})]})]}),s.jsxs("div",{className:"pt-4 border-t",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:R,disabled:x,className:"w-full",children:x?"Teste Verbindung...":s.jsxs(s.Fragment,{children:[s.jsx(Ea,{className:"w-4 h-4 mr-2"}),"Verbindung testen"]})}),u&&s.jsx("div",{className:`mt-2 p-3 rounded-lg text-sm ${u.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:u.success?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xr,{className:"w-4 h-4 flex-shrink-0"}),s.jsx("span",{children:"Verbindung erfolgreich!"})]}):s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(xx,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),s.jsx("span",{children:z(u)})]})})]}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:A,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:N.isPending||E.isPending,children:N.isPending||E.isPending?"Speichern...":"Speichern"})]})]})]})})})]})}function n4(){const[e,t]=j.useState(null),[n,r]=j.useState(null),[a,i]=j.useState(!1),[l,o]=j.useState(""),[c,d]=j.useState(null),u=j.useRef(null),h=ge(),{logout:x}=We(),{data:m,isLoading:f}=fe({queryKey:["backups"],queryFn:()=>br.list()}),p=(m==null?void 0:m.data)||[],b=G({mutationFn:()=>br.create(),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]})}}),g=G({mutationFn:S=>br.restore(S),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),t(null)}}),y=G({mutationFn:S=>br.delete(S),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),r(null)}}),v=G({mutationFn:S=>br.upload(S),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),d(null),u.current&&(u.current.value="")},onError:S=>{d(S.message||"Upload fehlgeschlagen")}}),N=G({mutationFn:()=>br.factoryReset(),onSuccess:()=>{i(!1),o(""),x()}}),E=S=>{var O;const A=(O=S.target.files)==null?void 0:O[0];if(A){if(!A.name.endsWith(".zip")){d("Nur ZIP-Dateien sind erlaubt");return}d(null),v.mutate(A)}},P=async S=>{const A=localStorage.getItem("token"),O=br.getDownloadUrl(S);try{const R=await fetch(O,{headers:{Authorization:`Bearer ${A}`}});if(!R.ok)throw new Error("Download fehlgeschlagen");const q=await R.blob(),D=window.URL.createObjectURL(q),z=document.createElement("a");z.href=D,z.download=`opencrm-backup-${S}.zip`,document.body.appendChild(z),z.click(),document.body.removeChild(z),window.URL.revokeObjectURL(D)}catch(R){console.error("Download error:",R)}},I=S=>new Date(S).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}),w=S=>S<1024?`${S} B`:S<1024*1024?`${(S/1024).toFixed(1)} KB`:`${(S/(1024*1024)).toFixed(1)} MB`;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-gray-900 flex items-center gap-2",children:[s.jsx(Ic,{className:"w-5 h-5"}),"Datenbank & Zurücksetzen"]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Backups erstellen, wiederherstellen oder auf Werkseinstellungen zurücksetzen."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"file",ref:u,accept:".zip",onChange:E,className:"hidden"}),s.jsx(T,{variant:"secondary",onClick:()=>{var S;return(S=u.current)==null?void 0:S.click()},disabled:v.isPending,children:v.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Sr,{className:"w-4 h-4 mr-2 animate-spin"}),"Hochladen..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Hu,{className:"w-4 h-4 mr-2"}),"Backup hochladen"]})}),s.jsx(T,{onClick:()=>b.mutate(),disabled:b.isPending,children:b.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Sr,{className:"w-4 h-4 mr-2 animate-spin"}),"Wird erstellt..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ps,{className:"w-4 h-4 mr-2"}),"Neues Backup"]})})]})]}),c&&s.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 text-red-700",children:c}),s.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-blue-800 mb-2",children:"Hinweise zur Datensicherung"}),s.jsxs("ul",{className:"text-sm text-blue-700 space-y-1 list-disc list-inside",children:[s.jsx("li",{children:"Backups enthalten alle Datenbankdaten und hochgeladene Dokumente"}),s.jsx("li",{children:"Erstellen Sie vor Datenbankmigrationen immer ein Backup"}),s.jsx("li",{children:"Backups können als ZIP heruntergeladen und auf einem anderen System wiederhergestellt werden"}),s.jsx("li",{children:"Bei der Wiederherstellung werden bestehende Daten mit dem Backup-Stand überschrieben"})]})]}),s.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 overflow-hidden",children:[s.jsx("div",{className:"px-4 py-3 bg-gray-50 border-b border-gray-200",children:s.jsx("h3",{className:"text-sm font-medium text-gray-700",children:"Verfügbare Backups"})}),f?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Sr,{className:"w-6 h-6 animate-spin text-gray-400"})}):p.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(fx,{className:"w-12 h-12 mb-2 opacity-30"}),s.jsx("p",{children:"Keine Backups vorhanden"}),s.jsx("p",{className:"text-sm mt-1",children:"Erstellen Sie Ihr erstes Backup"})]}):s.jsx("div",{className:"divide-y divide-gray-200",children:p.map(S=>s.jsx("div",{className:"p-4 hover:bg-gray-50",children:s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[s.jsx("span",{className:"font-mono text-sm bg-gray-100 px-2 py-1 rounded",children:S.name}),s.jsxs("span",{className:"text-sm text-gray-500 flex items-center gap-1",children:[s.jsx(on,{className:"w-4 h-4"}),I(S.timestamp)]})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600",children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Be,{className:"w-4 h-4"}),S.totalRecords.toLocaleString("de-DE")," Datensätze"]}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(fx,{className:"w-4 h-4"}),w(S.sizeBytes)]}),S.hasUploads&&s.jsxs("span",{className:"flex items-center gap-1 text-green-600",children:[s.jsx(R2,{className:"w-4 h-4"}),"Dokumente (",w(S.uploadSizeBytes),")"]})]}),s.jsxs("details",{className:"mt-2",children:[s.jsxs("summary",{className:"text-xs text-gray-500 cursor-pointer hover:text-gray-700",children:["Tabellen anzeigen (",S.tables.filter(A=>A.count>0).length," mit Daten)"]}),s.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:S.tables.filter(A=>A.count>0).map(A=>s.jsxs("span",{className:"text-xs bg-gray-100 px-2 py-0.5 rounded",children:[A.table,": ",A.count]},A.table))})]})]}),s.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>P(S.name),title:"Als ZIP herunterladen",children:s.jsx(E2,{className:"w-4 h-4"})}),s.jsxs(T,{variant:"secondary",size:"sm",onClick:()=>t(S.name),disabled:g.isPending,children:[s.jsx(Hu,{className:"w-4 h-4 mr-1"}),"Wiederherstellen"]}),s.jsx(T,{variant:"danger",size:"sm",onClick:()=>r(S.name),disabled:y.isPending,children:s.jsx(Ne,{className:"w-4 h-4"})})]})]})},S.name))})]}),e&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Backup wiederherstellen?"}),s.jsxs("p",{className:"text-gray-600 mb-4",children:["Möchten Sie das Backup ",s.jsx("strong",{children:e})," wirklich wiederherstellen?"]}),s.jsxs("p",{className:"text-amber-600 text-sm mb-4 bg-amber-50 p-3 rounded-lg",children:[s.jsx("strong",{children:"Achtung:"})," Bestehende Daten und Dokumente werden mit dem Backup-Stand überschrieben. Dies kann nicht rückgängig gemacht werden."]}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>t(null),disabled:g.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"primary",onClick:()=>g.mutate(e),disabled:g.isPending,children:g.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Sr,{className:"w-4 h-4 mr-2 animate-spin"}),"Wird wiederhergestellt..."]}):"Ja, wiederherstellen"})]})]})}),n&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Backup löschen?"}),s.jsxs("p",{className:"text-gray-600 mb-4",children:["Möchten Sie das Backup ",s.jsx("strong",{children:n})," wirklich löschen? Dies kann nicht rückgängig gemacht werden."]}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>r(null),disabled:y.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:()=>y.mutate(n),disabled:y.isPending,children:y.isPending?"Wird gelöscht...":"Ja, löschen"})]})]})}),s.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 mt-8",children:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-red-100 rounded-lg",children:s.jsx(hs,{className:"w-6 h-6 text-red-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-red-800 mb-2",children:"Werkseinstellungen"}),s.jsxs("p",{className:"text-sm text-red-700 mb-4",children:["Setzt das System auf den Ausgangszustand zurück. ",s.jsx("strong",{children:"Alle Daten werden unwiderruflich gelöscht"})," - Kunden, Verträge, Benutzer, Dokumente und Einstellungen. Nur die hier gespeicherten Backups bleiben erhalten."]}),s.jsxs("ul",{className:"text-sm text-red-700 mb-4 list-disc list-inside space-y-1",children:[s.jsx("li",{children:"Alle Kunden und Verträge werden gelöscht"}),s.jsx("li",{children:"Alle Benutzer werden gelöscht"}),s.jsx("li",{children:"Alle hochgeladenen Dokumente werden gelöscht"}),s.jsx("li",{children:"Ein neuer Admin-Benutzer wird erstellt (admin@admin.com / admin)"}),s.jsxs("li",{children:[s.jsx("strong",{children:"Backups bleiben erhalten"})," und können danach wiederhergestellt werden"]})]}),s.jsxs(T,{variant:"danger",onClick:()=>i(!0),children:[s.jsx(hh,{className:"w-4 h-4 mr-2"}),"Werkseinstellungen"]})]})]})}),a&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-lg mx-4",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"p-2 bg-red-100 rounded-lg",children:s.jsx(hs,{className:"w-6 h-6 text-red-600"})}),s.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Wirklich auf Werkseinstellungen zurücksetzen?"})]}),s.jsxs("p",{className:"text-gray-600 mb-4",children:["Diese Aktion löscht ",s.jsx("strong",{children:"alle Daten unwiderruflich"}),". Es gibt kein Zurück!"]}),s.jsxs("p",{className:"text-sm text-gray-600 mb-4",children:["Geben Sie zur Bestätigung ",s.jsx("strong",{className:"font-mono bg-gray-100 px-1",children:"LÖSCHEN"})," ein:"]}),s.jsx("input",{type:"text",value:l,onChange:S=>o(S.target.value),placeholder:"LÖSCHEN",className:"w-full px-3 py-2 border border-gray-300 rounded-lg mb-4 focus:ring-2 focus:ring-red-500 focus:border-red-500"}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>{i(!1),o("")},disabled:N.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:()=>N.mutate(),disabled:l!=="LÖSCHEN"||N.isPending,children:N.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Sr,{className:"w-4 h-4 mr-2 animate-spin"}),"Wird zurückgesetzt..."]}):"Ja, alles löschen"})]})]})})]})}function r4(){var y;const[e,t]=j.useState(""),[n,r]=j.useState(1),[a,i]=j.useState(!1),[l,o]=j.useState(null),c=ge(),{refreshUser:d}=We(),{data:u,isLoading:h}=fe({queryKey:["users",e,n],queryFn:()=>Li.getAll({search:e||void 0,page:n,limit:20})}),{data:x}=fe({queryKey:["roles"],queryFn:()=>Li.getRoles()}),m=G({mutationFn:Li.delete,onSuccess:()=>{c.invalidateQueries({queryKey:["users"]})},onError:v=>{alert((v==null?void 0:v.message)||"Fehler beim Löschen des Benutzers")}}),f=v=>{var N;return(N=v.roles)==null?void 0:N.some(E=>E.name==="Admin")},p=((y=u==null?void 0:u.data)==null?void 0:y.filter(v=>v.isActive&&f(v)).length)||0,b=v=>{o(v),i(!0)},g=()=>{i(!1),o(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(ke,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Vs,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Benutzer"}),s.jsxs(T,{onClick:()=>i(!0),children:[s.jsx(_e,{className:"w-4 h-4 mr-2"}),"Neuer Benutzer"]})]}),s.jsx(X,{className:"mb-6",children:s.jsxs("div",{className:"flex gap-4",children:[s.jsx("div",{className:"flex-1",children:s.jsx(H,{placeholder:"Suchen...",value:e,onChange:v=>t(v.target.value)})}),s.jsx(T,{variant:"secondary",children:s.jsx(Tl,{className:"w-4 h-4"})})]})}),s.jsxs("div",{className:"mb-6 bg-blue-50 border border-blue-200 rounded-lg p-4 flex items-start gap-3",children:[s.jsx(Ml,{className:"w-5 h-5 text-blue-600 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm text-blue-800",children:[s.jsx("strong",{children:"Hinweis:"})," Bei Änderungen an Rollen oder Berechtigungen wird der betroffene Benutzer automatisch ausgeloggt und muss sich erneut anmelden."]})]}),s.jsx(X,{children:h?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):u!=null&&u.data&&u.data.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Name"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"E-Mail"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Rollen"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:u.data.map(v=>{var N;return s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsxs("td",{className:"py-3 px-4",children:[v.firstName," ",v.lastName]}),s.jsx("td",{className:"py-3 px-4",children:v.email}),s.jsx("td",{className:"py-3 px-4",children:s.jsx("div",{className:"flex gap-1 flex-wrap",children:(N=v.roles)==null?void 0:N.filter(E=>E.name!=="Developer").map(E=>s.jsx(ve,{variant:"info",children:E.name},E.id||E.name))})}),s.jsx("td",{className:"py-3 px-4",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ve,{variant:v.isActive?"success":"danger",children:v.isActive?"Aktiv":"Inaktiv"}),v.hasDeveloperAccess&&s.jsxs(ve,{variant:"warning",className:"flex items-center gap-1",children:[s.jsx(Fc,{className:"w-3 h-3"}),"Dev"]})]})}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>b(v),children:s.jsx(He,{className:"w-4 h-4"})}),(()=>{const E=f(v)&&v.isActive&&p<=1;return s.jsx(T,{variant:"ghost",size:"sm",disabled:E,title:E?"Letzter Administrator kann nicht gelöscht werden":void 0,onClick:()=>{confirm("Benutzer wirklich löschen?")&&m.mutate(v.id)},children:s.jsx(Ne,{className:`w-4 h-4 ${E?"text-gray-300":"text-red-500"}`})})})()]})})]},v.id)})})]})}),u.pagination&&u.pagination.totalPages>1&&s.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",u.pagination.page," von ",u.pagination.totalPages]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>r(v=>Math.max(1,v-1)),disabled:n===1,children:"Zurück"}),s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>r(v=>v+1),disabled:n>=u.pagination.totalPages,children:"Weiter"})]})]})]}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Benutzer gefunden."})}),s.jsx(a4,{isOpen:a,onClose:g,user:l,roles:(x==null?void 0:x.data)||[],onUserUpdated:d})]})}function a4({isOpen:e,onClose:t,user:n,roles:r,onUserUpdated:a}){const i=ge(),[l,o]=j.useState(null),[c,d]=j.useState({email:"",password:"",firstName:"",lastName:"",roleIds:[],isActive:!0,hasDeveloperAccess:!1});j.useEffect(()=>{var p;e&&(o(null),d(n?{email:n.email,password:"",firstName:n.firstName,lastName:n.lastName,roleIds:((p=n.roles)==null?void 0:p.filter(b=>b.name!=="Developer").map(b=>b.id))||[],isActive:n.isActive??!0,hasDeveloperAccess:n.hasDeveloperAccess??!1}:{email:"",password:"",firstName:"",lastName:"",roleIds:[],isActive:!0,hasDeveloperAccess:!1}))},[e,n]);const u=G({mutationFn:Li.create,onSuccess:()=>{i.invalidateQueries({queryKey:["users"]}),t()},onError:p=>{o((p==null?void 0:p.message)||"Fehler beim Erstellen des Benutzers")}}),h=G({mutationFn:p=>Li.update(n.id,p),onSuccess:async()=>{i.invalidateQueries({queryKey:["users"]}),await a(),t()},onError:p=>{o((p==null?void 0:p.message)||"Fehler beim Aktualisieren des Benutzers")}}),x=p=>{if(p.preventDefault(),n){const b={email:c.email,firstName:c.firstName,lastName:c.lastName,roleIds:c.roleIds,isActive:c.isActive,hasDeveloperAccess:c.hasDeveloperAccess};c.password&&(b.password=c.password),h.mutate(b)}else u.mutate({email:c.email,password:c.password,firstName:c.firstName,lastName:c.lastName,roleIds:c.roleIds,hasDeveloperAccess:c.hasDeveloperAccess})},m=p=>{d(b=>({...b,roleIds:b.roleIds.includes(p)?b.roleIds.filter(g=>g!==p):[...b.roleIds,p]}))},f=u.isPending||h.isPending;return s.jsx(qe,{isOpen:e,onClose:t,title:n?"Benutzer bearbeiten":"Neuer Benutzer",children:s.jsxs("form",{onSubmit:x,className:"space-y-4",children:[l&&s.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-3 flex items-start gap-2",children:[s.jsx(hs,{className:"w-5 h-5 text-red-500 flex-shrink-0 mt-0.5"}),s.jsx("p",{className:"text-red-700 text-sm",children:l})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(H,{label:"Vorname *",value:c.firstName,onChange:p=>d({...c,firstName:p.target.value}),required:!0}),s.jsx(H,{label:"Nachname *",value:c.lastName,onChange:p=>d({...c,lastName:p.target.value}),required:!0})]}),s.jsx(H,{label:"E-Mail *",type:"email",value:c.email,onChange:p=>d({...c,email:p.target.value}),required:!0}),s.jsx(H,{label:n?"Neues Passwort (leer = unverändert)":"Passwort *",type:"password",value:c.password,onChange:p=>d({...c,password:p.target.value}),required:!n}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Rollen"}),s.jsxs("div",{className:"space-y-2",children:[r.filter(p=>p.name!=="Developer").map(p=>s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:c.roleIds.includes(p.id),onChange:()=>m(p.id),className:"rounded"}),s.jsx("span",{children:p.name}),p.description&&s.jsxs("span",{className:"text-sm text-gray-500",children:["(",p.description,")"]})]},p.id)),s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:c.hasDeveloperAccess,onChange:p=>d({...c,hasDeveloperAccess:p.target.checked}),className:"rounded border-purple-300 text-purple-600 focus:ring-purple-500"}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Fc,{className:"w-4 h-4 text-purple-600"}),"Entwicklerzugriff"]}),s.jsx("span",{className:"text-sm text-gray-500",children:"(Datenbanktools)"})]})]}),n&&s.jsxs("p",{className:"mt-2 text-xs text-amber-600 flex items-center gap-1",children:[s.jsx(hs,{className:"w-3 h-3"}),"Bei Rollenänderung wird der Benutzer automatisch ausgeloggt."]})]}),n&&s.jsx("div",{className:"space-y-3 pt-3 border-t",children:s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:c.isActive,onChange:p=>d({...c,isActive:p.target.checked}),className:"rounded"}),"Aktiv"]})}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:f,children:f?"Speichern...":"Speichern"})]})]})})}function i4(){const{hasPermission:e,developerMode:t,setDeveloperMode:n}=We(),r=[{to:"/settings/users",icon:W2,title:"Benutzer",description:"Verwalten Sie Benutzerkonten, Rollen und Berechtigungen.",show:e("users:read")},{to:"/settings/platforms",icon:Q2,title:"Vertriebsplattformen",description:"Verwalten Sie die Plattformen, über die Verträge abgeschlossen werden.",show:e("platforms:read")},{to:"/settings/cancellation-periods",icon:on,title:"Kündigungsfristen",description:"Konfigurieren Sie die verfügbaren Kündigungsfristen für Verträge.",show:e("platforms:read")},{to:"/settings/contract-durations",icon:kv,title:"Vertragslaufzeiten",description:"Konfigurieren Sie die verfügbaren Laufzeiten für Verträge.",show:e("platforms:read")},{to:"/settings/providers",icon:A2,title:"Anbieter & Tarife",description:"Verwalten Sie Anbieter und deren Tarife für Verträge.",show:e("providers:read")||e("platforms:read")},{to:"/settings/contract-categories",icon:I2,title:"Vertragstypen",description:"Konfigurieren Sie die verfügbaren Vertragstypen (Strom, Gas, Mobilfunk, etc.).",show:e("platforms:read")}];return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[s.jsx(Tv,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Einstellungen"})]}),s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-lg font-semibold mb-4 text-gray-700",children:"Stammdaten"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:r.filter(a=>a.show).map(a=>s.jsx(ke,{to:a.to,className:"block p-4 bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-md hover:border-blue-300 transition-all group",children:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx(a.icon,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:[a.title,s.jsx(Ft,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:a.description})]})]})},a.to))})]}),e("settings:update")&&s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-lg font-semibold mb-4 text-gray-700",children:"System"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(ke,{to:"/settings/portal",className:"block p-4 bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-md hover:border-blue-300 transition-all group",children:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx(uh,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Kundenportal",s.jsx(Ft,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Konfigurieren Sie das Kundenportal und Support-Anfragen."})]})]})}),s.jsx(ke,{to:"/settings/deadlines",className:"block p-4 bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-md hover:border-blue-300 transition-all group",children:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx(on,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Fristenschwellen",s.jsx(Ft,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Konfigurieren Sie die Farbkodierung für Vertragsfristen im Cockpit."})]})]})}),s.jsx(ke,{to:"/settings/email-providers",className:"block p-4 bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-md hover:border-blue-300 transition-all group",children:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx(nn,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Email-Provisionierung",s.jsx(Ft,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Konfigurieren Sie die automatische E-Mail-Erstellung für Stressfrei-Wechseln Adressen."})]})]})}),s.jsx(ke,{to:"/settings/database-backup",className:"block p-4 bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-md hover:border-blue-300 transition-all group",children:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx(Ic,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Datenbank & Zurücksetzen",s.jsx(Ft,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Backups erstellen, wiederherstellen oder auf Werkseinstellungen zurücksetzen."})]})]})})]})]}),s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-lg font-semibold mb-4 text-gray-700",children:"Persönlich"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:s.jsx(ke,{to:"/settings/view",className:"block p-4 bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-md hover:border-blue-300 transition-all group",children:s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:s.jsx(Ae,{className:"w-6 h-6 text-blue-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Ansicht",s.jsx(Ft,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Passen Sie die Darstellung der Anwendung an."})]})]})})})]}),e("developer:access")&&s.jsxs(X,{title:"Entwickleroptionen",className:"mb-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Fc,{className:"w-5 h-5 text-gray-500"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Entwicklermodus"}),s.jsx("p",{className:"text-sm text-gray-500",children:"Aktiviert erweiterte Funktionen wie direkten Datenbankzugriff"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t,onChange:a=>n(a.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"})]})]}),t&&s.jsx("div",{className:"mt-4 p-3 bg-yellow-50 border border-yellow-200 rounded-lg",children:s.jsxs("p",{className:"text-sm text-yellow-800",children:[s.jsx("strong",{children:"Warnung:"})," Der Entwicklermodus ermöglicht direkten Zugriff auf die Datenbank. Unsachgemäße Änderungen können zu Datenverlust oder Inkonsistenzen führen."]})})]}),s.jsx(X,{title:"Über",children:s.jsxs("dl",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Version"}),s.jsx("dd",{children:"1.0.0"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"System"}),s.jsx("dd",{children:"OpenCRM"})]})]})})]})}function l4({onSelectTable:e}){const t=j.useRef(null),[n,r]=j.useState(1),[a,i]=j.useState({x:0,y:0}),[l,o]=j.useState(!1),[c,d]=j.useState({x:0,y:0}),[u,h]=j.useState({}),[x,m]=j.useState(null),{data:f,isLoading:p}=fe({queryKey:["developer-schema"],queryFn:Ci.getSchema}),b=(f==null?void 0:f.data)||[];j.useEffect(()=>{if(b.length>0&&Object.keys(u).length===0){const w=Math.ceil(Math.sqrt(b.length)),S={x:280,y:200},A={};b.forEach((O,R)=>{const q=R%w,D=Math.floor(R/w);A[O.name]={x:50+q*S.x,y:50+D*S.y}}),h(A)}},[b,u]);const g=j.useCallback(w=>{(w.target===w.currentTarget||w.target.tagName==="svg")&&(o(!0),d({x:w.clientX-a.x,y:w.clientY-a.y}))},[a]),y=j.useCallback(w=>{var S;if(l&&!x)i({x:w.clientX-c.x,y:w.clientY-c.y});else if(x){const A=(S=t.current)==null?void 0:S.getBoundingClientRect();A&&h(O=>({...O,[x]:{x:(w.clientX-A.left-a.x)/n-100,y:(w.clientY-A.top-a.y)/n-20}}))}},[l,x,c,a,n]),v=j.useCallback(()=>{o(!1),m(null)},[]),N=w=>{r(S=>Math.min(2,Math.max(.3,S+w)))},E=()=>{r(1),i({x:0,y:0})},P=j.useCallback(()=>{const w=[];return b.forEach(S=>{const A=u[S.name];A&&S.foreignKeys.forEach(O=>{const R=u[O.targetTable];if(!R)return;const q=b.find(z=>z.name===O.targetTable),D=q==null?void 0:q.relations.find(z=>z.targetTable===S.name);w.push({from:{table:S.name,x:A.x+100,y:A.y+60},to:{table:O.targetTable,x:R.x+100,y:R.y+60},type:(D==null?void 0:D.type)||"one",label:O.field})})}),w},[b,u]);if(p)return s.jsx("div",{className:"flex items-center justify-center h-full",children:"Laden..."});const I=P();return s.jsxs("div",{className:"relative h-full w-full bg-gray-50 overflow-hidden",ref:t,children:[s.jsxs("div",{className:"absolute top-4 right-4 z-10 flex gap-2 bg-white rounded-lg shadow-md p-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>N(.1),title:"Vergrößern",children:s.jsx(Z2,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>N(-.1),title:"Verkleinern",children:s.jsx(J2,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:E,title:"Zurücksetzen",children:s.jsx(B2,{className:"w-4 h-4"})}),s.jsxs("div",{className:"text-xs text-gray-500 flex items-center px-2",children:[Math.round(n*100),"%"]})]}),s.jsxs("div",{className:"absolute top-4 left-4 z-10 bg-white rounded-lg shadow-md p-2 text-xs text-gray-500",children:[s.jsx(U2,{className:"w-3 h-3 inline mr-1"}),"Tabellen ziehen zum Verschieben"]}),s.jsx("svg",{className:"w-full h-full cursor-grab",style:{cursor:l?"grabbing":"grab"},onMouseDown:g,onMouseMove:y,onMouseUp:v,onMouseLeave:v,children:s.jsxs("g",{transform:`translate(${a.x}, ${a.y}) scale(${n})`,children:[s.jsxs("defs",{children:[s.jsx("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:s.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#6b7280"})}),s.jsx("marker",{id:"many-marker",markerWidth:"12",markerHeight:"12",refX:"6",refY:"6",orient:"auto",children:s.jsx("circle",{cx:"6",cy:"6",r:"3",fill:"#6b7280"})})]}),I.map((w,S)=>{const A=w.to.x-w.from.x,O=w.to.y-w.from.y,R=w.from.x+A/2,q=w.from.y+O/2,D=w.from.x+A*.25,z=w.from.y,k=w.from.x+A*.75,K=w.to.y;return s.jsxs("g",{children:[s.jsx("path",{d:`M ${w.from.x} ${w.from.y} C ${D} ${z}, ${k} ${K}, ${w.to.x} ${w.to.y}`,fill:"none",stroke:"#9ca3af",strokeWidth:"2",markerEnd:"url(#arrowhead)"}),s.jsx("text",{x:R,y:q-8,fontSize:"10",fill:"#6b7280",textAnchor:"middle",className:"select-none",children:w.type==="many"?"1:n":"1:1"})]},S)}),b.map(w=>{const S=u[w.name];if(!S)return null;const A=200,O=32,R=20,q=[...new Set([w.primaryKey,...w.foreignKeys.map(z=>z.field)])],D=O+Math.min(q.length,5)*R+8;return s.jsxs("g",{transform:`translate(${S.x}, ${S.y})`,style:{cursor:"move"},onMouseDown:z=>{z.stopPropagation(),m(w.name)},children:[s.jsx("rect",{x:"3",y:"3",width:A,height:D,rx:"6",fill:"rgba(0,0,0,0.1)"}),s.jsx("rect",{x:"0",y:"0",width:A,height:D,rx:"6",fill:"white",stroke:"#e5e7eb",strokeWidth:"1"}),s.jsx("rect",{x:"0",y:"0",width:A,height:O,rx:"6",fill:"#3b82f6",className:"cursor-pointer",onClick:()=>e==null?void 0:e(w.name)}),s.jsx("rect",{x:"0",y:O-6,width:A,height:"6",fill:"#3b82f6"}),s.jsx("text",{x:A/2,y:"21",fontSize:"13",fontWeight:"bold",fill:"white",textAnchor:"middle",className:"select-none pointer-events-none",children:w.name}),q.slice(0,5).map((z,k)=>{const K=z===w.primaryKey||w.primaryKey.includes(z),B=w.foreignKeys.some(_=>_.field===z);return s.jsx("g",{transform:`translate(8, ${O+4+k*R})`,children:s.jsxs("text",{x:"0",y:"14",fontSize:"11",fill:K?"#dc2626":B?"#2563eb":"#374151",fontFamily:"monospace",className:"select-none",children:[K&&"🔑 ",B&&!K&&"🔗 ",z]})},z)}),q.length>5&&s.jsxs("text",{x:A/2,y:D-4,fontSize:"10",fill:"#9ca3af",textAnchor:"middle",className:"select-none",children:["+",q.length-5," mehr..."]})]},w.name)})]})}),s.jsxs("div",{className:"absolute bottom-4 left-4 bg-white rounded-lg shadow-md p-3 text-xs",children:[s.jsx("div",{className:"font-medium mb-2",children:"Legende"}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-red-600",children:"🔑"}),s.jsx("span",{children:"Primary Key"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-blue-600",children:"🔗"}),s.jsx("span",{children:"Foreign Key"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-6 h-0.5 bg-gray-400"}),s.jsx("span",{children:"Beziehung"})]})]})]})]})}function o4(){var I;const[e,t]=j.useState(null),[n,r]=j.useState(1),[a,i]=j.useState(null),[l,o]=j.useState(!1),c=ge(),{data:d,isLoading:u,error:h}=fe({queryKey:["developer-schema"],queryFn:Ci.getSchema});console.log("Schema data:",d),console.log("Schema error:",h);const{data:x,isLoading:m}=fe({queryKey:["developer-table",e,n],queryFn:()=>Ci.getTableData(e,n),enabled:!!e}),f=G({mutationFn:({tableName:w,id:S,data:A})=>Ci.updateRow(w,S,A),onSuccess:()=>{c.invalidateQueries({queryKey:["developer-table",e]}),i(null)},onError:w=>{var S,A;alert(((A=(S=w.response)==null?void 0:S.data)==null?void 0:A.error)||"Fehler beim Speichern")}}),p=G({mutationFn:({tableName:w,id:S})=>Ci.deleteRow(w,S),onSuccess:()=>{c.invalidateQueries({queryKey:["developer-table",e]})},onError:w=>{var S,A;alert(((A=(S=w.response)==null?void 0:S.data)==null?void 0:A.error)||"Fehler beim Löschen")}}),b=(d==null?void 0:d.data)||[],g=b.find(w=>w.name===e),y=(w,S)=>S.primaryKey.includes(",")?S.primaryKey.split(",").map(A=>w[A]).join("-"):String(w[S.primaryKey]),v=w=>w==null?"-":typeof w=="boolean"?w?"Ja":"Nein":typeof w=="object"?w instanceof Date||typeof w=="string"&&w.match(/^\d{4}-\d{2}-\d{2}/)?new Date(w).toLocaleString("de-DE"):JSON.stringify(w):String(w),N=()=>{!a||!e||f.mutate({tableName:e,id:a.id,data:a.data})},E=w=>{e&&confirm("Datensatz wirklich löschen?")&&p.mutate({tableName:e,id:w})};if(u)return s.jsx("div",{className:"text-center py-8",children:"Laden..."});const P=w=>{t(w),r(1),o(!1)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ic,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Datenbankstruktur"})]}),s.jsxs(T,{onClick:()=>o(!0),children:[s.jsx(hx,{className:"w-4 h-4 mr-2"}),"ER-Diagramm"]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6",children:[s.jsx(X,{title:"Tabellen",className:"lg:col-span-1",children:s.jsx("div",{className:"space-y-1 max-h-[600px] overflow-y-auto",children:b.map(w=>s.jsxs("button",{onClick:()=>{t(w.name),r(1)},className:`w-full text-left px-3 py-2 rounded-lg flex items-center gap-2 transition-colors ${e===w.name?"bg-blue-100 text-blue-700":"hover:bg-gray-100"}`,children:[s.jsx(H2,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm font-mono",children:w.name})]},w.name))})}),s.jsx("div",{className:"lg:col-span-3 space-y-6",children:e&&g?s.jsxs(s.Fragment,{children:[s.jsxs(X,{title:`${e} - Beziehungen`,children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-gray-500 mb-2",children:"Fremdschlüssel (referenziert)"}),g.foreignKeys.length>0?s.jsx("div",{className:"space-y-1",children:g.foreignKeys.map(w=>s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"font-mono text-gray-600",children:w.field}),s.jsx(wv,{className:"w-4 h-4 text-gray-400"}),s.jsx(ve,{variant:"info",className:"cursor-pointer",onClick:()=>{t(w.targetTable),r(1)},children:w.targetTable})]},w.field))}):s.jsx("p",{className:"text-sm text-gray-400",children:"Keine"})]}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-gray-500 mb-2",children:"Relationen (wird referenziert von)"}),g.relations.length>0?s.jsx("div",{className:"space-y-1",children:g.relations.map(w=>s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"font-mono text-gray-600",children:w.field}),s.jsx(ve,{variant:w.type==="many"?"warning":"default",children:w.type==="many"?"1:n":"1:1"}),s.jsx(ve,{variant:"info",className:"cursor-pointer",onClick:()=>{t(w.targetTable),r(1)},children:w.targetTable})]},w.field))}):s.jsx("p",{className:"text-sm text-gray-400",children:"Keine"})]})]}),s.jsx("div",{className:"mt-4 pt-4 border-t",children:s.jsxs("div",{className:"flex gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"Primary Key:"})," ",s.jsx("span",{className:"font-mono",children:g.primaryKey})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"Readonly:"})," ",s.jsx("span",{className:"font-mono text-red-600",children:g.readonlyFields.join(", ")||"-"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"Required:"})," ",s.jsx("span",{className:"font-mono text-green-600",children:g.requiredFields.join(", ")||"-"})]})]})})]}),s.jsx(X,{title:`${e} - Daten`,children:m?s.jsx("div",{className:"text-center py-4",children:"Laden..."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b bg-gray-50",children:[(x==null?void 0:x.data)&&x.data.length>0&&Object.keys(x.data[0]).map(w=>s.jsxs("th",{className:"text-left py-2 px-3 font-medium text-gray-600 whitespace-nowrap",children:[w,g.readonlyFields.includes(w)&&s.jsx("span",{className:"ml-1 text-red-400 text-xs",children:"*"}),g.requiredFields.includes(w)&&s.jsx("span",{className:"ml-1 text-green-400 text-xs",children:"!"})]},w)),s.jsx("th",{className:"text-right py-2 px-3 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsxs("tbody",{children:[(I=x==null?void 0:x.data)==null?void 0:I.map(w=>{const S=y(w,g);return s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[Object.entries(w).map(([A,O])=>s.jsx("td",{className:"py-2 px-3 font-mono text-xs max-w-[200px] truncate",children:v(O)},A)),s.jsx("td",{className:"py-2 px-3 text-right whitespace-nowrap",children:s.jsxs("div",{className:"flex justify-end gap-1",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>i({id:S,data:{...w}}),children:s.jsx(He,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>E(S),children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})})]},S)}),(!(x!=null&&x.data)||x.data.length===0)&&s.jsx("tr",{children:s.jsx("td",{colSpan:100,className:"py-4 text-center text-gray-500",children:"Keine Daten vorhanden"})})]})]})}),(x==null?void 0:x.pagination)&&x.pagination.totalPages>1&&s.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",x.pagination.page," von ",x.pagination.totalPages," (",x.pagination.total," Einträge)"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>r(w=>Math.max(1,w-1)),disabled:n===1,children:s.jsx(T2,{className:"w-4 h-4"})}),s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>r(w=>w+1),disabled:n>=x.pagination.totalPages,children:s.jsx(Ft,{className:"w-4 h-4"})})]})]})]})})]}):s.jsx(X,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Wähle eine Tabelle aus der Liste aus"})})})]}),s.jsx(qe,{isOpen:!!a,onClose:()=>i(null),title:`${e} bearbeiten`,children:a&&g&&s.jsxs("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto",children:[Object.entries(a.data).map(([w,S])=>{const A=g.readonlyFields.includes(w),O=g.requiredFields.includes(w);return s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[w,A&&s.jsx("span",{className:"ml-1 text-red-400",children:"(readonly)"}),O&&s.jsx("span",{className:"ml-1 text-green-600",children:"*"})]}),A?s.jsx("div",{className:"px-3 py-2 bg-gray-100 rounded-lg font-mono text-sm",children:v(S)}):typeof S=="boolean"?s.jsxs("select",{value:String(a.data[w]),onChange:R=>i({...a,data:{...a.data,[w]:R.target.value==="true"}}),className:"w-full px-3 py-2 border rounded-lg",children:[s.jsx("option",{value:"true",children:"Ja"}),s.jsx("option",{value:"false",children:"Nein"})]}):s.jsx("input",{type:typeof S=="number"?"number":"text",value:a.data[w]??"",onChange:R=>i({...a,data:{...a.data,[w]:typeof S=="number"?R.target.value?Number(R.target.value):null:R.target.value||null}}),className:"w-full px-3 py-2 border rounded-lg font-mono text-sm",disabled:A})]},w)}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[s.jsxs(T,{variant:"secondary",onClick:()=>i(null),children:[s.jsx(qt,{className:"w-4 h-4 mr-2"}),"Abbrechen"]}),s.jsxs(T,{onClick:N,disabled:f.isPending,children:[s.jsx(Mv,{className:"w-4 h-4 mr-2"}),f.isPending?"Speichern...":"Speichern"]})]})]})}),l&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:()=>o(!1)}),s.jsxs("div",{className:"relative bg-white rounded-xl shadow-2xl w-[90vw] h-[85vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(hx,{className:"w-5 h-5 text-blue-600"}),s.jsx("h2",{className:"text-lg font-semibold",children:"ER-Diagramm - Datenbankbeziehungen"})]}),s.jsx("button",{onClick:()=>o(!1),className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:s.jsx(qt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 overflow-hidden",children:s.jsx(l4,{onSelectTable:P})})]})]})]})}function c4({children:e}){const{isAuthenticated:t,isLoading:n}=We();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:s.jsx("div",{className:"text-gray-500",children:"Laden..."})}):t?s.jsx(s.Fragment,{children:e}):s.jsx(va,{to:"/login",replace:!0})}function d4({children:e}){const{hasPermission:t,developerMode:n}=We();return!t("developer:access")||!n?s.jsx(va,{to:"/",replace:!0}):s.jsx(s.Fragment,{children:e})}function u4(){const{isAuthenticated:e,isLoading:t}=We();return t?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:s.jsx("div",{className:"text-gray-500",children:"Laden..."})}):s.jsxs(s.Fragment,{children:[s.jsx(w2,{}),s.jsxs(hw,{children:[s.jsx(ze,{path:"/login",element:e?s.jsx(va,{to:"/",replace:!0}):s.jsx(tk,{})}),s.jsxs(ze,{path:"/",element:s.jsx(c4,{children:s.jsx(ek,{})}),children:[s.jsx(ze,{index:!0,element:s.jsx(sk,{})}),s.jsx(ze,{path:"customers",element:s.jsx(rk,{})}),s.jsx(ze,{path:"customers/new",element:s.jsx(Rx,{})}),s.jsx(ze,{path:"customers/:id",element:s.jsx(mk,{})}),s.jsx(ze,{path:"customers/:id/edit",element:s.jsx(Rx,{})}),s.jsx(ze,{path:"contracts",element:s.jsx(Zk,{})}),s.jsx(ze,{path:"contracts/cockpit",element:s.jsx(MC,{})}),s.jsx(ze,{path:"contracts/new",element:s.jsx(Kx,{})}),s.jsx(ze,{path:"contracts/:id",element:s.jsx(bC,{})}),s.jsx(ze,{path:"contracts/:id/edit",element:s.jsx(Kx,{})}),s.jsx(ze,{path:"tasks",element:s.jsx(FC,{})}),s.jsx(ze,{path:"settings",element:s.jsx(i4,{})}),s.jsx(ze,{path:"settings/users",element:s.jsx(r4,{})}),s.jsx(ze,{path:"settings/platforms",element:s.jsx(OC,{})}),s.jsx(ze,{path:"settings/cancellation-periods",element:s.jsx($C,{})}),s.jsx(ze,{path:"settings/contract-durations",element:s.jsx(KC,{})}),s.jsx(ze,{path:"settings/providers",element:s.jsx(UC,{})}),s.jsx(ze,{path:"settings/contract-categories",element:s.jsx(GC,{})}),s.jsx(ze,{path:"settings/view",element:s.jsx(XC,{})}),s.jsx(ze,{path:"settings/portal",element:s.jsx(YC,{})}),s.jsx(ze,{path:"settings/deadlines",element:s.jsx(e4,{})}),s.jsx(ze,{path:"settings/email-providers",element:s.jsx(s4,{})}),s.jsx(ze,{path:"settings/database-backup",element:s.jsx(n4,{})}),s.jsx(ze,{path:"users",element:s.jsx(va,{to:"/settings/users",replace:!0})}),s.jsx(ze,{path:"platforms",element:s.jsx(va,{to:"/settings/platforms",replace:!0})}),s.jsx(ze,{path:"developer/database",element:s.jsx(d4,{children:s.jsx(o4,{})})})]}),s.jsx(ze,{path:"*",element:s.jsx(va,{to:"/",replace:!0})})]})]})}const m4=new Xw({defaultOptions:{queries:{retry:1,staleTime:0,gcTime:0,refetchOnMount:"always"}}});Nd.createRoot(document.getElementById("root")).render(s.jsx(Tt.StrictMode,{children:s.jsx(Yw,{client:m4,children:s.jsx(Nw,{children:s.jsx(N2,{children:s.jsxs(b2,{children:[s.jsx(u4,{}),s.jsx(V1,{position:"top-right",toastOptions:{duration:4e3,style:{background:"#363636",color:"#fff"},success:{iconTheme:{primary:"#10b981",secondary:"#fff"}},error:{iconTheme:{primary:"#ef4444",secondary:"#fff"}}}})]})})})})}));
|