opencrm/frontend/dist/assets/index-CzqYCocn.js

706 lines
698 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

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

var uf=e=>{throw TypeError(e)};var Ic=(e,t,n)=>t.has(e)||uf("Cannot "+n);var M=(e,t,n)=>(Ic(e,t,"read from private field"),n?n.call(e):t.get(e)),de=(e,t,n)=>t.has(e)?uf("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),se=(e,t,n,r)=>(Ic(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ve=(e,t,n)=>(Ic(e,t,"access private method"),n);var Tl=(e,t,n,r)=>({set _(a){se(e,t,a,n)},get _(){return M(e,t,r)}});function Ov(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 zv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Hx={exports:{}},ec={},Wx={exports:{}},Ce={};/**
* @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 xl=Symbol.for("react.element"),$v=Symbol.for("react.portal"),_v=Symbol.for("react.fragment"),Kv=Symbol.for("react.strict_mode"),Uv=Symbol.for("react.profiler"),Bv=Symbol.for("react.provider"),qv=Symbol.for("react.context"),Vv=Symbol.for("react.forward_ref"),Qv=Symbol.for("react.suspense"),Hv=Symbol.for("react.memo"),Wv=Symbol.for("react.lazy"),mf=Symbol.iterator;function Gv(e){return e===null||typeof e!="object"?null:(e=mf&&e[mf]||e["@@iterator"],typeof e=="function"?e:null)}var Gx={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Zx=Object.assign,Jx={};function Za(e,t,n){this.props=e,this.context=t,this.refs=Jx,this.updater=n||Gx}Za.prototype.isReactComponent={};Za.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")};Za.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Xx(){}Xx.prototype=Za.prototype;function Gu(e,t,n){this.props=e,this.context=t,this.refs=Jx,this.updater=n||Gx}var Zu=Gu.prototype=new Xx;Zu.constructor=Gu;Zx(Zu,Za.prototype);Zu.isPureReactComponent=!0;var hf=Array.isArray,Yx=Object.prototype.hasOwnProperty,Ju={current:null},eg={key:!0,ref:!0,__self:!0,__source:!0};function tg(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)Yx.call(t,r)&&!eg.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:xl,type:e,key:i,ref:l,props:a,_owner:Ju.current}}function Zv(e,t){return{$$typeof:xl,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Xu(e){return typeof e=="object"&&e!==null&&e.$$typeof===xl}function Jv(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var ff=/\/+/g;function Rc(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Jv(""+e.key):t.toString(36)}function to(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 xl:case $v:l=!0}}if(l)return l=e,a=a(l),e=r===""?"."+Rc(l,0):r,hf(a)?(n="",e!=null&&(n=e.replace(ff,"$&/")+"/"),to(a,t,n,"",function(d){return d})):a!=null&&(Xu(a)&&(a=Zv(a,n+(!a.key||l&&l.key===a.key?"":(""+a.key).replace(ff,"$&/")+"/")+e)),t.push(a)),1;if(l=0,r=r===""?".":r+":",hf(e))for(var o=0;o<e.length;o++){i=e[o];var c=r+Rc(i,o);l+=to(i,t,n,c,a)}else if(c=Gv(e),typeof c=="function")for(e=c.call(e),o=0;!(i=e.next()).done;)i=i.value,c=r+Rc(i,o++),l+=to(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 Il(e,t,n){if(e==null)return e;var r=[],a=0;return to(e,r,"","",function(i){return t.call(n,i,a++)}),r}function Xv(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 Ht={current:null},so={transition:null},Yv={ReactCurrentDispatcher:Ht,ReactCurrentBatchConfig:so,ReactCurrentOwner:Ju};function sg(){throw Error("act(...) is not supported in production builds of React.")}Ce.Children={map:Il,forEach:function(e,t,n){Il(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Il(e,function(){t++}),t},toArray:function(e){return Il(e,function(t){return t})||[]},only:function(e){if(!Xu(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Ce.Component=Za;Ce.Fragment=_v;Ce.Profiler=Uv;Ce.PureComponent=Gu;Ce.StrictMode=Kv;Ce.Suspense=Qv;Ce.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Yv;Ce.act=sg;Ce.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=Zx({},e.props),a=e.key,i=e.ref,l=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,l=Ju.current),t.key!==void 0&&(a=""+t.key),e.type&&e.type.defaultProps)var o=e.type.defaultProps;for(c in t)Yx.call(t,c)&&!eg.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:xl,type:e.type,key:a,ref:i,props:r,_owner:l}};Ce.createContext=function(e){return e={$$typeof:qv,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Bv,_context:e},e.Consumer=e};Ce.createElement=tg;Ce.createFactory=function(e){var t=tg.bind(null,e);return t.type=e,t};Ce.createRef=function(){return{current:null}};Ce.forwardRef=function(e){return{$$typeof:Vv,render:e}};Ce.isValidElement=Xu;Ce.lazy=function(e){return{$$typeof:Wv,_payload:{_status:-1,_result:e},_init:Xv}};Ce.memo=function(e,t){return{$$typeof:Hv,type:e,compare:t===void 0?null:t}};Ce.startTransition=function(e){var t=so.transition;so.transition={};try{e()}finally{so.transition=t}};Ce.unstable_act=sg;Ce.useCallback=function(e,t){return Ht.current.useCallback(e,t)};Ce.useContext=function(e){return Ht.current.useContext(e)};Ce.useDebugValue=function(){};Ce.useDeferredValue=function(e){return Ht.current.useDeferredValue(e)};Ce.useEffect=function(e,t){return Ht.current.useEffect(e,t)};Ce.useId=function(){return Ht.current.useId()};Ce.useImperativeHandle=function(e,t,n){return Ht.current.useImperativeHandle(e,t,n)};Ce.useInsertionEffect=function(e,t){return Ht.current.useInsertionEffect(e,t)};Ce.useLayoutEffect=function(e,t){return Ht.current.useLayoutEffect(e,t)};Ce.useMemo=function(e,t){return Ht.current.useMemo(e,t)};Ce.useReducer=function(e,t,n){return Ht.current.useReducer(e,t,n)};Ce.useRef=function(e){return Ht.current.useRef(e)};Ce.useState=function(e){return Ht.current.useState(e)};Ce.useSyncExternalStore=function(e,t,n){return Ht.current.useSyncExternalStore(e,t,n)};Ce.useTransition=function(){return Ht.current.useTransition()};Ce.version="18.3.1";Wx.exports=Ce;var b=Wx.exports;const At=zv(b),ej=Ov({__proto__:null,default:At},[b]);/**
* @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 tj=b,sj=Symbol.for("react.element"),nj=Symbol.for("react.fragment"),rj=Object.prototype.hasOwnProperty,aj=tj.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ij={key:!0,ref:!0,__self:!0,__source:!0};function ng(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)rj.call(t,r)&&!ij.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:sj,type:e,key:i,ref:l,props:a,_owner:aj.current}}ec.Fragment=nj;ec.jsx=ng;ec.jsxs=ng;Hx.exports=ec;var s=Hx.exports,yd={},rg={exports:{}},fs={},ag={exports:{}},ig={};/**
* @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,J){var H=B.length;B.push(J);e:for(;0<H;){var S=H-1>>>1,oe=B[S];if(0<a(oe,J))B[S]=J,B[H]=oe,H=S;else break e}}function n(B){return B.length===0?null:B[0]}function r(B){if(B.length===0)return null;var J=B[0],H=B.pop();if(H!==J){B[0]=H;e:for(var S=0,oe=B.length,Ve=oe>>>1;S<Ve;){var Fe=2*(S+1)-1,Ye=B[Fe],Ze=Fe+1,xt=B[Ze];if(0>a(Ye,H))Ze<oe&&0>a(xt,Ye)?(B[S]=xt,B[Ze]=H,S=Ze):(B[S]=Ye,B[Fe]=H,S=Fe);else if(Ze<oe&&0>a(xt,H))B[S]=xt,B[Ze]=H,S=Ze;else break e}}return J}function a(B,J){var H=B.sortIndex-J.sortIndex;return H!==0?H:B.id-J.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,p=3,m=!1,f=!1,x=!1,j=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function g(B){for(var J=n(d);J!==null;){if(J.callback===null)r(d);else if(J.startTime<=B)r(d),J.sortIndex=J.expirationTime,t(c,J);else break;J=n(d)}}function w(B){if(x=!1,g(B),!f)if(n(c)!==null)f=!0,A(C);else{var J=n(d);J!==null&&K(w,J.startTime-B)}}function C(B,J){f=!1,x&&(x=!1,y(N),N=-1),m=!0;var H=p;try{for(g(J),h=n(c);h!==null&&(!(h.expirationTime>J)||B&&!z());){var S=h.callback;if(typeof S=="function"){h.callback=null,p=h.priorityLevel;var oe=S(h.expirationTime<=J);J=e.unstable_now(),typeof oe=="function"?h.callback=oe:h===n(c)&&r(c),g(J)}else r(c);h=n(c)}if(h!==null)var Ve=!0;else{var Fe=n(d);Fe!==null&&K(w,Fe.startTime-J),Ve=!1}return Ve}finally{h=null,p=H,m=!1}}var k=!1,F=null,N=-1,E=5,P=-1;function z(){return!(e.unstable_now()-P<E)}function D(){if(F!==null){var B=e.unstable_now();P=B;var J=!0;try{J=F(!0,B)}finally{J?_():(k=!1,F=null)}}else k=!1}var _;if(typeof v=="function")_=function(){v(D)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,L=$.port2;$.port1.onmessage=D,_=function(){L.postMessage(null)}}else _=function(){j(D,0)};function A(B){F=B,k||(k=!0,_())}function K(B,J){N=j(function(){B(e.unstable_now())},J)}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,A(C))},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"):E=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(B){switch(p){case 1:case 2:case 3:var J=3;break;default:J=p}var H=p;p=J;try{return B()}finally{p=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(B,J){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var H=p;p=B;try{return J()}finally{p=H}},e.unstable_scheduleCallback=function(B,J,H){var S=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?S+H:S):H=S,B){case 1:var oe=-1;break;case 2:oe=250;break;case 5:oe=1073741823;break;case 4:oe=1e4;break;default:oe=5e3}return oe=H+oe,B={id:u++,callback:J,priorityLevel:B,startTime:H,expirationTime:oe,sortIndex:-1},H>S?(B.sortIndex=H,t(d,B),n(c)===null&&B===n(d)&&(x?(y(N),N=-1):x=!0,K(w,H-S))):(B.sortIndex=oe,t(c,B),f||m||(f=!0,A(C))),B},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(B){var J=p;return function(){var H=p;p=J;try{return B.apply(this,arguments)}finally{p=H}}}})(ig);ag.exports=ig;var lj=ag.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 oj=b,hs=lj;function X(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 lg=new Set,Ii={};function Gr(e,t){$a(e,t),$a(e+"Capture",t)}function $a(e,t){for(Ii[e]=t,e=0;e<t.length;e++)lg.add(t[e])}var Sn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),vd=Object.prototype.hasOwnProperty,cj=/^[: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]*$/,pf={},xf={};function dj(e){return vd.call(xf,e)?!0:vd.call(pf,e)?!1:cj.test(e)?xf[e]=!0:(pf[e]=!0,!1)}function uj(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 mj(e,t,n,r){if(t===null||typeof t>"u"||uj(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 Wt(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 It={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){It[e]=new Wt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];It[t]=new Wt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){It[e]=new Wt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){It[e]=new Wt(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){It[e]=new Wt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){It[e]=new Wt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){It[e]=new Wt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){It[e]=new Wt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){It[e]=new Wt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Yu=/[\-:]([a-z])/g;function em(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(Yu,em);It[t]=new Wt(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(Yu,em);It[t]=new Wt(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(Yu,em);It[t]=new Wt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){It[e]=new Wt(e,1,!1,e.toLowerCase(),null,!1,!1)});It.xlinkHref=new Wt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){It[e]=new Wt(e,1,!1,e.toLowerCase(),null,!0,!0)});function tm(e,t,n,r){var a=It.hasOwnProperty(t)?It[t]:null;(a!==null?a.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(mj(t,n,a,r)&&(n=null),r||a===null?dj(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 An=oj.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Rl=Symbol.for("react.element"),na=Symbol.for("react.portal"),ra=Symbol.for("react.fragment"),sm=Symbol.for("react.strict_mode"),jd=Symbol.for("react.profiler"),og=Symbol.for("react.provider"),cg=Symbol.for("react.context"),nm=Symbol.for("react.forward_ref"),bd=Symbol.for("react.suspense"),Nd=Symbol.for("react.suspense_list"),rm=Symbol.for("react.memo"),Rn=Symbol.for("react.lazy"),dg=Symbol.for("react.offscreen"),gf=Symbol.iterator;function ii(e){return e===null||typeof e!="object"?null:(e=gf&&e[gf]||e["@@iterator"],typeof e=="function"?e:null)}var rt=Object.assign,Lc;function xi(e){if(Lc===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Lc=t&&t[1]||""}return`
`+Lc+e}var Oc=!1;function zc(e,t){if(!e||Oc)return"";Oc=!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{Oc=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?xi(e):""}function hj(e){switch(e.tag){case 5:return xi(e.type);case 16:return xi("Lazy");case 13:return xi("Suspense");case 19:return xi("SuspenseList");case 0:case 2:case 15:return e=zc(e.type,!1),e;case 11:return e=zc(e.type.render,!1),e;case 1:return e=zc(e.type,!0),e;default:return""}}function wd(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 ra:return"Fragment";case na:return"Portal";case jd:return"Profiler";case sm:return"StrictMode";case bd:return"Suspense";case Nd:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case cg:return(e.displayName||"Context")+".Consumer";case og:return(e._context.displayName||"Context")+".Provider";case nm:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case rm:return t=e.displayName||null,t!==null?t:wd(e.type)||"Memo";case Rn:t=e._payload,e=e._init;try{return wd(e(t))}catch{}}return null}function fj(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 wd(t);case 8:return t===sm?"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 dr(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ug(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function pj(e){var t=ug(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 Ll(e){e._valueTracker||(e._valueTracker=pj(e))}function mg(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=ug(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function jo(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 Sd(e,t){var n=t.checked;return rt({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function yf(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=dr(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 hg(e,t){t=t.checked,t!=null&&tm(e,"checked",t,!1)}function kd(e,t){hg(e,t);var n=dr(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")?Cd(e,t.type,n):t.hasOwnProperty("defaultValue")&&Cd(e,t.type,dr(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function vf(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 Cd(e,t,n){(t!=="number"||jo(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var gi=Array.isArray;function xa(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=""+dr(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 Ed(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(X(91));return rt({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function jf(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(X(92));if(gi(n)){if(1<n.length)throw Error(X(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:dr(n)}}function fg(e,t){var n=dr(t.value),r=dr(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 bf(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function pg(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 Dd(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?pg(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Ol,xg=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(Ol=Ol||document.createElement("div"),Ol.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Ol.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ri(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ni={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},xj=["Webkit","ms","Moz","O"];Object.keys(Ni).forEach(function(e){xj.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ni[t]=Ni[e]})});function gg(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Ni.hasOwnProperty(e)&&Ni[e]?(""+t).trim():t+"px"}function yg(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,a=gg(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,a):e[n]=a}}var gj=rt({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 Pd(e,t){if(t){if(gj[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(X(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(X(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(X(61))}if(t.style!=null&&typeof t.style!="object")throw Error(X(62))}}function Ad(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 Md=null;function am(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Fd=null,ga=null,ya=null;function Nf(e){if(e=vl(e)){if(typeof Fd!="function")throw Error(X(280));var t=e.stateNode;t&&(t=ac(t),Fd(e.stateNode,e.type,t))}}function vg(e){ga?ya?ya.push(e):ya=[e]:ga=e}function jg(){if(ga){var e=ga,t=ya;if(ya=ga=null,Nf(e),t)for(e=0;e<t.length;e++)Nf(t[e])}}function bg(e,t){return e(t)}function Ng(){}var $c=!1;function wg(e,t,n){if($c)return e(t,n);$c=!0;try{return bg(e,t,n)}finally{$c=!1,(ga!==null||ya!==null)&&(Ng(),jg())}}function Li(e,t){var n=e.stateNode;if(n===null)return null;var r=ac(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(X(231,t,typeof n));return n}var Td=!1;if(Sn)try{var li={};Object.defineProperty(li,"passive",{get:function(){Td=!0}}),window.addEventListener("test",li,li),window.removeEventListener("test",li,li)}catch{Td=!1}function yj(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 wi=!1,bo=null,No=!1,Id=null,vj={onError:function(e){wi=!0,bo=e}};function jj(e,t,n,r,a,i,l,o,c){wi=!1,bo=null,yj.apply(vj,arguments)}function bj(e,t,n,r,a,i,l,o,c){if(jj.apply(this,arguments),wi){if(wi){var d=bo;wi=!1,bo=null}else throw Error(X(198));No||(No=!0,Id=d)}}function Zr(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 Sg(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 wf(e){if(Zr(e)!==e)throw Error(X(188))}function Nj(e){var t=e.alternate;if(!t){if(t=Zr(e),t===null)throw Error(X(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 wf(a),e;if(i===r)return wf(a),t;i=i.sibling}throw Error(X(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(X(189))}}if(n.alternate!==r)throw Error(X(190))}if(n.tag!==3)throw Error(X(188));return n.stateNode.current===n?e:t}function kg(e){return e=Nj(e),e!==null?Cg(e):null}function Cg(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Cg(e);if(t!==null)return t;e=e.sibling}return null}var Eg=hs.unstable_scheduleCallback,Sf=hs.unstable_cancelCallback,wj=hs.unstable_shouldYield,Sj=hs.unstable_requestPaint,ft=hs.unstable_now,kj=hs.unstable_getCurrentPriorityLevel,im=hs.unstable_ImmediatePriority,Dg=hs.unstable_UserBlockingPriority,wo=hs.unstable_NormalPriority,Cj=hs.unstable_LowPriority,Pg=hs.unstable_IdlePriority,tc=null,sn=null;function Ej(e){if(sn&&typeof sn.onCommitFiberRoot=="function")try{sn.onCommitFiberRoot(tc,e,void 0,(e.current.flags&128)===128)}catch{}}var $s=Math.clz32?Math.clz32:Aj,Dj=Math.log,Pj=Math.LN2;function Aj(e){return e>>>=0,e===0?32:31-(Dj(e)/Pj|0)|0}var zl=64,$l=4194304;function yi(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 So(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=yi(o):(i&=l,i!==0&&(r=yi(i)))}else l=n&~a,l!==0?r=yi(l):i!==0&&(r=yi(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-$s(t),a=1<<n,r|=e[n],t&=~a;return r}function Mj(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 Fj(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,i=e.pendingLanes;0<i;){var l=31-$s(i),o=1<<l,c=a[l];c===-1?(!(o&n)||o&r)&&(a[l]=Mj(o,t)):c<=t&&(e.expiredLanes|=o),i&=~o}}function Rd(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Ag(){var e=zl;return zl<<=1,!(zl&4194240)&&(zl=64),e}function _c(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function gl(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-$s(t),e[t]=n}function Tj(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-$s(n),i=1<<a;t[a]=0,r[a]=-1,e[a]=-1,n&=~i}}function lm(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-$s(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}var $e=0;function Mg(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Fg,om,Tg,Ig,Rg,Ld=!1,_l=[],er=null,tr=null,sr=null,Oi=new Map,zi=new Map,On=[],Ij="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 kf(e,t){switch(e){case"focusin":case"focusout":er=null;break;case"dragenter":case"dragleave":tr=null;break;case"mouseover":case"mouseout":sr=null;break;case"pointerover":case"pointerout":Oi.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":zi.delete(t.pointerId)}}function oi(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=vl(t),t!==null&&om(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function Rj(e,t,n,r,a){switch(t){case"focusin":return er=oi(er,e,t,n,r,a),!0;case"dragenter":return tr=oi(tr,e,t,n,r,a),!0;case"mouseover":return sr=oi(sr,e,t,n,r,a),!0;case"pointerover":var i=a.pointerId;return Oi.set(i,oi(Oi.get(i)||null,e,t,n,r,a)),!0;case"gotpointercapture":return i=a.pointerId,zi.set(i,oi(zi.get(i)||null,e,t,n,r,a)),!0}return!1}function Lg(e){var t=br(e.target);if(t!==null){var n=Zr(t);if(n!==null){if(t=n.tag,t===13){if(t=Sg(n),t!==null){e.blockedOn=t,Rg(e.priority,function(){Tg(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 no(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Od(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Md=r,n.target.dispatchEvent(r),Md=null}else return t=vl(n),t!==null&&om(t),e.blockedOn=n,!1;t.shift()}return!0}function Cf(e,t,n){no(e)&&n.delete(t)}function Lj(){Ld=!1,er!==null&&no(er)&&(er=null),tr!==null&&no(tr)&&(tr=null),sr!==null&&no(sr)&&(sr=null),Oi.forEach(Cf),zi.forEach(Cf)}function ci(e,t){e.blockedOn===t&&(e.blockedOn=null,Ld||(Ld=!0,hs.unstable_scheduleCallback(hs.unstable_NormalPriority,Lj)))}function $i(e){function t(a){return ci(a,e)}if(0<_l.length){ci(_l[0],e);for(var n=1;n<_l.length;n++){var r=_l[n];r.blockedOn===e&&(r.blockedOn=null)}}for(er!==null&&ci(er,e),tr!==null&&ci(tr,e),sr!==null&&ci(sr,e),Oi.forEach(t),zi.forEach(t),n=0;n<On.length;n++)r=On[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<On.length&&(n=On[0],n.blockedOn===null);)Lg(n),n.blockedOn===null&&On.shift()}var va=An.ReactCurrentBatchConfig,ko=!0;function Oj(e,t,n,r){var a=$e,i=va.transition;va.transition=null;try{$e=1,cm(e,t,n,r)}finally{$e=a,va.transition=i}}function zj(e,t,n,r){var a=$e,i=va.transition;va.transition=null;try{$e=4,cm(e,t,n,r)}finally{$e=a,va.transition=i}}function cm(e,t,n,r){if(ko){var a=Od(e,t,n,r);if(a===null)Zc(e,t,r,Co,n),kf(e,r);else if(Rj(a,e,t,n,r))r.stopPropagation();else if(kf(e,r),t&4&&-1<Ij.indexOf(e)){for(;a!==null;){var i=vl(a);if(i!==null&&Fg(i),i=Od(e,t,n,r),i===null&&Zc(e,t,r,Co,n),i===a)break;a=i}a!==null&&r.stopPropagation()}else Zc(e,t,r,null,n)}}var Co=null;function Od(e,t,n,r){if(Co=null,e=am(r),e=br(e),e!==null)if(t=Zr(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Sg(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 Co=e,null}function Og(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(kj()){case im:return 1;case Dg:return 4;case wo:case Cj:return 16;case Pg:return 536870912;default:return 16}default:return 16}}var Jn=null,dm=null,ro=null;function zg(){if(ro)return ro;var e,t=dm,n=t.length,r,a="value"in Jn?Jn.value:Jn.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 ro=a.slice(e,1<r?1-r:void 0)}function ao(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 Kl(){return!0}function Ef(){return!1}function ps(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)?Kl:Ef,this.isPropagationStopped=Ef,this}return rt(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=Kl)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Kl)},persist:function(){},isPersistent:Kl}),t}var Ja={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},um=ps(Ja),yl=rt({},Ja,{view:0,detail:0}),$j=ps(yl),Kc,Uc,di,sc=rt({},yl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:mm,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!==di&&(di&&e.type==="mousemove"?(Kc=e.screenX-di.screenX,Uc=e.screenY-di.screenY):Uc=Kc=0,di=e),Kc)},movementY:function(e){return"movementY"in e?e.movementY:Uc}}),Df=ps(sc),_j=rt({},sc,{dataTransfer:0}),Kj=ps(_j),Uj=rt({},yl,{relatedTarget:0}),Bc=ps(Uj),Bj=rt({},Ja,{animationName:0,elapsedTime:0,pseudoElement:0}),qj=ps(Bj),Vj=rt({},Ja,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Qj=ps(Vj),Hj=rt({},Ja,{data:0}),Pf=ps(Hj),Wj={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Gj={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"},Zj={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Jj(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Zj[e])?!!t[e]:!1}function mm(){return Jj}var Xj=rt({},yl,{key:function(e){if(e.key){var t=Wj[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ao(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Gj[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:mm,charCode:function(e){return e.type==="keypress"?ao(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ao(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Yj=ps(Xj),eb=rt({},sc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Af=ps(eb),tb=rt({},yl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:mm}),sb=ps(tb),nb=rt({},Ja,{propertyName:0,elapsedTime:0,pseudoElement:0}),rb=ps(nb),ab=rt({},sc,{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}),ib=ps(ab),lb=[9,13,27,32],hm=Sn&&"CompositionEvent"in window,Si=null;Sn&&"documentMode"in document&&(Si=document.documentMode);var ob=Sn&&"TextEvent"in window&&!Si,$g=Sn&&(!hm||Si&&8<Si&&11>=Si),Mf=" ",Ff=!1;function _g(e,t){switch(e){case"keyup":return lb.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Kg(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var aa=!1;function cb(e,t){switch(e){case"compositionend":return Kg(t);case"keypress":return t.which!==32?null:(Ff=!0,Mf);case"textInput":return e=t.data,e===Mf&&Ff?null:e;default:return null}}function db(e,t){if(aa)return e==="compositionend"||!hm&&_g(e,t)?(e=zg(),ro=dm=Jn=null,aa=!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 $g&&t.locale!=="ko"?null:t.data;default:return null}}var ub={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 Tf(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!ub[e.type]:t==="textarea"}function Ug(e,t,n,r){vg(r),t=Eo(t,"onChange"),0<t.length&&(n=new um("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var ki=null,_i=null;function mb(e){Yg(e,0)}function nc(e){var t=oa(e);if(mg(t))return e}function hb(e,t){if(e==="change")return t}var Bg=!1;if(Sn){var qc;if(Sn){var Vc="oninput"in document;if(!Vc){var If=document.createElement("div");If.setAttribute("oninput","return;"),Vc=typeof If.oninput=="function"}qc=Vc}else qc=!1;Bg=qc&&(!document.documentMode||9<document.documentMode)}function Rf(){ki&&(ki.detachEvent("onpropertychange",qg),_i=ki=null)}function qg(e){if(e.propertyName==="value"&&nc(_i)){var t=[];Ug(t,_i,e,am(e)),wg(mb,t)}}function fb(e,t,n){e==="focusin"?(Rf(),ki=t,_i=n,ki.attachEvent("onpropertychange",qg)):e==="focusout"&&Rf()}function pb(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return nc(_i)}function xb(e,t){if(e==="click")return nc(t)}function gb(e,t){if(e==="input"||e==="change")return nc(t)}function yb(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Ks=typeof Object.is=="function"?Object.is:yb;function Ki(e,t){if(Ks(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(!vd.call(t,a)||!Ks(e[a],t[a]))return!1}return!0}function Lf(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Of(e,t){var n=Lf(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=Lf(n)}}function Vg(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Vg(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Qg(){for(var e=window,t=jo();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=jo(e.document)}return t}function fm(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 vb(e){var t=Qg(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Vg(n.ownerDocument.documentElement,n)){if(r!==null&&fm(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=Of(n,i);var l=Of(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 jb=Sn&&"documentMode"in document&&11>=document.documentMode,ia=null,zd=null,Ci=null,$d=!1;function zf(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;$d||ia==null||ia!==jo(r)||(r=ia,"selectionStart"in r&&fm(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}),Ci&&Ki(Ci,r)||(Ci=r,r=Eo(zd,"onSelect"),0<r.length&&(t=new um("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=ia)))}function Ul(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var la={animationend:Ul("Animation","AnimationEnd"),animationiteration:Ul("Animation","AnimationIteration"),animationstart:Ul("Animation","AnimationStart"),transitionend:Ul("Transition","TransitionEnd")},Qc={},Hg={};Sn&&(Hg=document.createElement("div").style,"AnimationEvent"in window||(delete la.animationend.animation,delete la.animationiteration.animation,delete la.animationstart.animation),"TransitionEvent"in window||delete la.transitionend.transition);function rc(e){if(Qc[e])return Qc[e];if(!la[e])return e;var t=la[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Hg)return Qc[e]=t[n];return e}var Wg=rc("animationend"),Gg=rc("animationiteration"),Zg=rc("animationstart"),Jg=rc("transitionend"),Xg=new Map,$f="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 mr(e,t){Xg.set(e,t),Gr(t,[e])}for(var Hc=0;Hc<$f.length;Hc++){var Wc=$f[Hc],bb=Wc.toLowerCase(),Nb=Wc[0].toUpperCase()+Wc.slice(1);mr(bb,"on"+Nb)}mr(Wg,"onAnimationEnd");mr(Gg,"onAnimationIteration");mr(Zg,"onAnimationStart");mr("dblclick","onDoubleClick");mr("focusin","onFocus");mr("focusout","onBlur");mr(Jg,"onTransitionEnd");$a("onMouseEnter",["mouseout","mouseover"]);$a("onMouseLeave",["mouseout","mouseover"]);$a("onPointerEnter",["pointerout","pointerover"]);$a("onPointerLeave",["pointerout","pointerover"]);Gr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Gr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Gr("onBeforeInput",["compositionend","keypress","textInput","paste"]);Gr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Gr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Gr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var vi="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(" "),wb=new Set("cancel close invalid load scroll toggle".split(" ").concat(vi));function _f(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,bj(r,t,void 0,e),e.currentTarget=null}function Yg(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;_f(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;_f(a,o,d),i=c}}}if(No)throw e=Id,No=!1,Id=null,e}function Qe(e,t){var n=t[qd];n===void 0&&(n=t[qd]=new Set);var r=e+"__bubble";n.has(r)||(ey(t,e,2,!1),n.add(r))}function Gc(e,t,n){var r=0;t&&(r|=4),ey(n,e,r,t)}var Bl="_reactListening"+Math.random().toString(36).slice(2);function Ui(e){if(!e[Bl]){e[Bl]=!0,lg.forEach(function(n){n!=="selectionchange"&&(wb.has(n)||Gc(n,!1,e),Gc(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Bl]||(t[Bl]=!0,Gc("selectionchange",!1,t))}}function ey(e,t,n,r){switch(Og(t)){case 1:var a=Oj;break;case 4:a=zj;break;default:a=cm}n=a.bind(null,t,n,e),a=void 0,!Td||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 Zc(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=br(o),l===null)return;if(c=l.tag,c===5||c===6){r=i=l;continue e}o=o.parentNode}}r=r.return}wg(function(){var d=i,u=am(n),h=[];e:{var p=Xg.get(e);if(p!==void 0){var m=um,f=e;switch(e){case"keypress":if(ao(n)===0)break e;case"keydown":case"keyup":m=Yj;break;case"focusin":f="focus",m=Bc;break;case"focusout":f="blur",m=Bc;break;case"beforeblur":case"afterblur":m=Bc;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=Df;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=Kj;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=sb;break;case Wg:case Gg:case Zg:m=qj;break;case Jg:m=rb;break;case"scroll":m=$j;break;case"wheel":m=ib;break;case"copy":case"cut":case"paste":m=Qj;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=Af}var x=(t&4)!==0,j=!x&&e==="scroll",y=x?p!==null?p+"Capture":null:p;x=[];for(var v=d,g;v!==null;){g=v;var w=g.stateNode;if(g.tag===5&&w!==null&&(g=w,y!==null&&(w=Li(v,y),w!=null&&x.push(Bi(v,w,g)))),j)break;v=v.return}0<x.length&&(p=new m(p,f,null,n,u),h.push({event:p,listeners:x}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",p&&n!==Md&&(f=n.relatedTarget||n.fromElement)&&(br(f)||f[kn]))break e;if((m||p)&&(p=u.window===u?u:(p=u.ownerDocument)?p.defaultView||p.parentWindow:window,m?(f=n.relatedTarget||n.toElement,m=d,f=f?br(f):null,f!==null&&(j=Zr(f),f!==j||f.tag!==5&&f.tag!==6)&&(f=null)):(m=null,f=d),m!==f)){if(x=Df,w="onMouseLeave",y="onMouseEnter",v="mouse",(e==="pointerout"||e==="pointerover")&&(x=Af,w="onPointerLeave",y="onPointerEnter",v="pointer"),j=m==null?p:oa(m),g=f==null?p:oa(f),p=new x(w,v+"leave",m,n,u),p.target=j,p.relatedTarget=g,w=null,br(u)===d&&(x=new x(y,v+"enter",f,n,u),x.target=g,x.relatedTarget=j,w=x),j=w,m&&f)t:{for(x=m,y=f,v=0,g=x;g;g=ea(g))v++;for(g=0,w=y;w;w=ea(w))g++;for(;0<v-g;)x=ea(x),v--;for(;0<g-v;)y=ea(y),g--;for(;v--;){if(x===y||y!==null&&x===y.alternate)break t;x=ea(x),y=ea(y)}x=null}else x=null;m!==null&&Kf(h,p,m,x,!1),f!==null&&j!==null&&Kf(h,j,f,x,!0)}}e:{if(p=d?oa(d):window,m=p.nodeName&&p.nodeName.toLowerCase(),m==="select"||m==="input"&&p.type==="file")var C=hb;else if(Tf(p))if(Bg)C=gb;else{C=pb;var k=fb}else(m=p.nodeName)&&m.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(C=xb);if(C&&(C=C(e,d))){Ug(h,C,n,u);break e}k&&k(e,p,d),e==="focusout"&&(k=p._wrapperState)&&k.controlled&&p.type==="number"&&Cd(p,"number",p.value)}switch(k=d?oa(d):window,e){case"focusin":(Tf(k)||k.contentEditable==="true")&&(ia=k,zd=d,Ci=null);break;case"focusout":Ci=zd=ia=null;break;case"mousedown":$d=!0;break;case"contextmenu":case"mouseup":case"dragend":$d=!1,zf(h,n,u);break;case"selectionchange":if(jb)break;case"keydown":case"keyup":zf(h,n,u)}var F;if(hm)e:{switch(e){case"compositionstart":var N="onCompositionStart";break e;case"compositionend":N="onCompositionEnd";break e;case"compositionupdate":N="onCompositionUpdate";break e}N=void 0}else aa?_g(e,n)&&(N="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(N="onCompositionStart");N&&($g&&n.locale!=="ko"&&(aa||N!=="onCompositionStart"?N==="onCompositionEnd"&&aa&&(F=zg()):(Jn=u,dm="value"in Jn?Jn.value:Jn.textContent,aa=!0)),k=Eo(d,N),0<k.length&&(N=new Pf(N,e,null,n,u),h.push({event:N,listeners:k}),F?N.data=F:(F=Kg(n),F!==null&&(N.data=F)))),(F=ob?cb(e,n):db(e,n))&&(d=Eo(d,"onBeforeInput"),0<d.length&&(u=new Pf("onBeforeInput","beforeinput",null,n,u),h.push({event:u,listeners:d}),u.data=F))}Yg(h,t)})}function Bi(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Eo(e,t){for(var n=t+"Capture",r=[];e!==null;){var a=e,i=a.stateNode;a.tag===5&&i!==null&&(a=i,i=Li(e,n),i!=null&&r.unshift(Bi(e,i,a)),i=Li(e,t),i!=null&&r.push(Bi(e,i,a))),e=e.return}return r}function ea(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Kf(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=Li(n,i),c!=null&&l.unshift(Bi(n,c,o))):a||(c=Li(n,i),c!=null&&l.push(Bi(n,c,o)))),n=n.return}l.length!==0&&e.push({event:t,listeners:l})}var Sb=/\r\n?/g,kb=/\u0000|\uFFFD/g;function Uf(e){return(typeof e=="string"?e:""+e).replace(Sb,`
`).replace(kb,"")}function ql(e,t,n){if(t=Uf(t),Uf(e)!==t&&n)throw Error(X(425))}function Do(){}var _d=null,Kd=null;function Ud(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 Bd=typeof setTimeout=="function"?setTimeout:void 0,Cb=typeof clearTimeout=="function"?clearTimeout:void 0,Bf=typeof Promise=="function"?Promise:void 0,Eb=typeof queueMicrotask=="function"?queueMicrotask:typeof Bf<"u"?function(e){return Bf.resolve(null).then(e).catch(Db)}:Bd;function Db(e){setTimeout(function(){throw e})}function Jc(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),$i(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=a}while(n);$i(t)}function nr(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 qf(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 Xa=Math.random().toString(36).slice(2),Ys="__reactFiber$"+Xa,qi="__reactProps$"+Xa,kn="__reactContainer$"+Xa,qd="__reactEvents$"+Xa,Pb="__reactListeners$"+Xa,Ab="__reactHandles$"+Xa;function br(e){var t=e[Ys];if(t)return t;for(var n=e.parentNode;n;){if(t=n[kn]||n[Ys]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=qf(e);e!==null;){if(n=e[Ys])return n;e=qf(e)}return t}e=n,n=e.parentNode}return null}function vl(e){return e=e[Ys]||e[kn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function oa(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(X(33))}function ac(e){return e[qi]||null}var Vd=[],ca=-1;function hr(e){return{current:e}}function We(e){0>ca||(e.current=Vd[ca],Vd[ca]=null,ca--)}function Be(e,t){ca++,Vd[ca]=e.current,e.current=t}var ur={},Kt=hr(ur),ss=hr(!1),_r=ur;function _a(e,t){var n=e.type.contextTypes;if(!n)return ur;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 ns(e){return e=e.childContextTypes,e!=null}function Po(){We(ss),We(Kt)}function Vf(e,t,n){if(Kt.current!==ur)throw Error(X(168));Be(Kt,t),Be(ss,n)}function ty(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(X(108,fj(e)||"Unknown",a));return rt({},n,r)}function Ao(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ur,_r=Kt.current,Be(Kt,e),Be(ss,ss.current),!0}function Qf(e,t,n){var r=e.stateNode;if(!r)throw Error(X(169));n?(e=ty(e,t,_r),r.__reactInternalMemoizedMergedChildContext=e,We(ss),We(Kt),Be(Kt,e)):We(ss),Be(ss,n)}var hn=null,ic=!1,Xc=!1;function sy(e){hn===null?hn=[e]:hn.push(e)}function Mb(e){ic=!0,sy(e)}function fr(){if(!Xc&&hn!==null){Xc=!0;var e=0,t=$e;try{var n=hn;for($e=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}hn=null,ic=!1}catch(a){throw hn!==null&&(hn=hn.slice(e+1)),Eg(im,fr),a}finally{$e=t,Xc=!1}}return null}var da=[],ua=0,Mo=null,Fo=0,js=[],bs=0,Kr=null,vn=1,jn="";function yr(e,t){da[ua++]=Fo,da[ua++]=Mo,Mo=e,Fo=t}function ny(e,t,n){js[bs++]=vn,js[bs++]=jn,js[bs++]=Kr,Kr=e;var r=vn;e=jn;var a=32-$s(r)-1;r&=~(1<<a),n+=1;var i=32-$s(t)+a;if(30<i){var l=a-a%5;i=(r&(1<<l)-1).toString(32),r>>=l,a-=l,vn=1<<32-$s(t)+a|n<<a|r,jn=i+e}else vn=1<<i|n<<a|r,jn=e}function pm(e){e.return!==null&&(yr(e,1),ny(e,1,0))}function xm(e){for(;e===Mo;)Mo=da[--ua],da[ua]=null,Fo=da[--ua],da[ua]=null;for(;e===Kr;)Kr=js[--bs],js[bs]=null,jn=js[--bs],js[bs]=null,vn=js[--bs],js[bs]=null}var ms=null,us=null,Xe=!1,Rs=null;function ry(e,t){var n=Ns(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 Hf(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,ms=e,us=nr(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ms=e,us=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Kr!==null?{id:vn,overflow:jn}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Ns(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ms=e,us=null,!0):!1;default:return!1}}function Qd(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Hd(e){if(Xe){var t=us;if(t){var n=t;if(!Hf(e,t)){if(Qd(e))throw Error(X(418));t=nr(n.nextSibling);var r=ms;t&&Hf(e,t)?ry(r,n):(e.flags=e.flags&-4097|2,Xe=!1,ms=e)}}else{if(Qd(e))throw Error(X(418));e.flags=e.flags&-4097|2,Xe=!1,ms=e}}}function Wf(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ms=e}function Vl(e){if(e!==ms)return!1;if(!Xe)return Wf(e),Xe=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Ud(e.type,e.memoizedProps)),t&&(t=us)){if(Qd(e))throw ay(),Error(X(418));for(;t;)ry(e,t),t=nr(t.nextSibling)}if(Wf(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(X(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){us=nr(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}us=null}}else us=ms?nr(e.stateNode.nextSibling):null;return!0}function ay(){for(var e=us;e;)e=nr(e.nextSibling)}function Ka(){us=ms=null,Xe=!1}function gm(e){Rs===null?Rs=[e]:Rs.push(e)}var Fb=An.ReactCurrentBatchConfig;function ui(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(X(309));var r=n.stateNode}if(!r)throw Error(X(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(X(284));if(!n._owner)throw Error(X(290,e))}return e}function Ql(e,t){throw e=Object.prototype.toString.call(t),Error(X(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Gf(e){var t=e._init;return t(e._payload)}function iy(e){function t(y,v){if(e){var g=y.deletions;g===null?(y.deletions=[v],y.flags|=16):g.push(v)}}function n(y,v){if(!e)return null;for(;v!==null;)t(y,v),v=v.sibling;return null}function r(y,v){for(y=new Map;v!==null;)v.key!==null?y.set(v.key,v):y.set(v.index,v),v=v.sibling;return y}function a(y,v){return y=lr(y,v),y.index=0,y.sibling=null,y}function i(y,v,g){return y.index=g,e?(g=y.alternate,g!==null?(g=g.index,g<v?(y.flags|=2,v):g):(y.flags|=2,v)):(y.flags|=1048576,v)}function l(y){return e&&y.alternate===null&&(y.flags|=2),y}function o(y,v,g,w){return v===null||v.tag!==6?(v=ad(g,y.mode,w),v.return=y,v):(v=a(v,g),v.return=y,v)}function c(y,v,g,w){var C=g.type;return C===ra?u(y,v,g.props.children,w,g.key):v!==null&&(v.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Rn&&Gf(C)===v.type)?(w=a(v,g.props),w.ref=ui(y,v,g),w.return=y,w):(w=ho(g.type,g.key,g.props,null,y.mode,w),w.ref=ui(y,v,g),w.return=y,w)}function d(y,v,g,w){return v===null||v.tag!==4||v.stateNode.containerInfo!==g.containerInfo||v.stateNode.implementation!==g.implementation?(v=id(g,y.mode,w),v.return=y,v):(v=a(v,g.children||[]),v.return=y,v)}function u(y,v,g,w,C){return v===null||v.tag!==7?(v=Or(g,y.mode,w,C),v.return=y,v):(v=a(v,g),v.return=y,v)}function h(y,v,g){if(typeof v=="string"&&v!==""||typeof v=="number")return v=ad(""+v,y.mode,g),v.return=y,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case Rl:return g=ho(v.type,v.key,v.props,null,y.mode,g),g.ref=ui(y,null,v),g.return=y,g;case na:return v=id(v,y.mode,g),v.return=y,v;case Rn:var w=v._init;return h(y,w(v._payload),g)}if(gi(v)||ii(v))return v=Or(v,y.mode,g,null),v.return=y,v;Ql(y,v)}return null}function p(y,v,g,w){var C=v!==null?v.key:null;if(typeof g=="string"&&g!==""||typeof g=="number")return C!==null?null:o(y,v,""+g,w);if(typeof g=="object"&&g!==null){switch(g.$$typeof){case Rl:return g.key===C?c(y,v,g,w):null;case na:return g.key===C?d(y,v,g,w):null;case Rn:return C=g._init,p(y,v,C(g._payload),w)}if(gi(g)||ii(g))return C!==null?null:u(y,v,g,w,null);Ql(y,g)}return null}function m(y,v,g,w,C){if(typeof w=="string"&&w!==""||typeof w=="number")return y=y.get(g)||null,o(v,y,""+w,C);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Rl:return y=y.get(w.key===null?g:w.key)||null,c(v,y,w,C);case na:return y=y.get(w.key===null?g:w.key)||null,d(v,y,w,C);case Rn:var k=w._init;return m(y,v,g,k(w._payload),C)}if(gi(w)||ii(w))return y=y.get(g)||null,u(v,y,w,C,null);Ql(v,w)}return null}function f(y,v,g,w){for(var C=null,k=null,F=v,N=v=0,E=null;F!==null&&N<g.length;N++){F.index>N?(E=F,F=null):E=F.sibling;var P=p(y,F,g[N],w);if(P===null){F===null&&(F=E);break}e&&F&&P.alternate===null&&t(y,F),v=i(P,v,N),k===null?C=P:k.sibling=P,k=P,F=E}if(N===g.length)return n(y,F),Xe&&yr(y,N),C;if(F===null){for(;N<g.length;N++)F=h(y,g[N],w),F!==null&&(v=i(F,v,N),k===null?C=F:k.sibling=F,k=F);return Xe&&yr(y,N),C}for(F=r(y,F);N<g.length;N++)E=m(F,y,N,g[N],w),E!==null&&(e&&E.alternate!==null&&F.delete(E.key===null?N:E.key),v=i(E,v,N),k===null?C=E:k.sibling=E,k=E);return e&&F.forEach(function(z){return t(y,z)}),Xe&&yr(y,N),C}function x(y,v,g,w){var C=ii(g);if(typeof C!="function")throw Error(X(150));if(g=C.call(g),g==null)throw Error(X(151));for(var k=C=null,F=v,N=v=0,E=null,P=g.next();F!==null&&!P.done;N++,P=g.next()){F.index>N?(E=F,F=null):E=F.sibling;var z=p(y,F,P.value,w);if(z===null){F===null&&(F=E);break}e&&F&&z.alternate===null&&t(y,F),v=i(z,v,N),k===null?C=z:k.sibling=z,k=z,F=E}if(P.done)return n(y,F),Xe&&yr(y,N),C;if(F===null){for(;!P.done;N++,P=g.next())P=h(y,P.value,w),P!==null&&(v=i(P,v,N),k===null?C=P:k.sibling=P,k=P);return Xe&&yr(y,N),C}for(F=r(y,F);!P.done;N++,P=g.next())P=m(F,y,N,P.value,w),P!==null&&(e&&P.alternate!==null&&F.delete(P.key===null?N:P.key),v=i(P,v,N),k===null?C=P:k.sibling=P,k=P);return e&&F.forEach(function(D){return t(y,D)}),Xe&&yr(y,N),C}function j(y,v,g,w){if(typeof g=="object"&&g!==null&&g.type===ra&&g.key===null&&(g=g.props.children),typeof g=="object"&&g!==null){switch(g.$$typeof){case Rl:e:{for(var C=g.key,k=v;k!==null;){if(k.key===C){if(C=g.type,C===ra){if(k.tag===7){n(y,k.sibling),v=a(k,g.props.children),v.return=y,y=v;break e}}else if(k.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Rn&&Gf(C)===k.type){n(y,k.sibling),v=a(k,g.props),v.ref=ui(y,k,g),v.return=y,y=v;break e}n(y,k);break}else t(y,k);k=k.sibling}g.type===ra?(v=Or(g.props.children,y.mode,w,g.key),v.return=y,y=v):(w=ho(g.type,g.key,g.props,null,y.mode,w),w.ref=ui(y,v,g),w.return=y,y=w)}return l(y);case na:e:{for(k=g.key;v!==null;){if(v.key===k)if(v.tag===4&&v.stateNode.containerInfo===g.containerInfo&&v.stateNode.implementation===g.implementation){n(y,v.sibling),v=a(v,g.children||[]),v.return=y,y=v;break e}else{n(y,v);break}else t(y,v);v=v.sibling}v=id(g,y.mode,w),v.return=y,y=v}return l(y);case Rn:return k=g._init,j(y,v,k(g._payload),w)}if(gi(g))return f(y,v,g,w);if(ii(g))return x(y,v,g,w);Ql(y,g)}return typeof g=="string"&&g!==""||typeof g=="number"?(g=""+g,v!==null&&v.tag===6?(n(y,v.sibling),v=a(v,g),v.return=y,y=v):(n(y,v),v=ad(g,y.mode,w),v.return=y,y=v),l(y)):n(y,v)}return j}var Ua=iy(!0),ly=iy(!1),To=hr(null),Io=null,ma=null,ym=null;function vm(){ym=ma=Io=null}function jm(e){var t=To.current;We(To),e._currentValue=t}function Wd(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 ja(e,t){Io=e,ym=ma=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ts=!0),e.firstContext=null)}function ks(e){var t=e._currentValue;if(ym!==e)if(e={context:e,memoizedValue:t,next:null},ma===null){if(Io===null)throw Error(X(308));ma=e,Io.dependencies={lanes:0,firstContext:e}}else ma=ma.next=e;return t}var Nr=null;function bm(e){Nr===null?Nr=[e]:Nr.push(e)}function oy(e,t,n,r){var a=t.interleaved;return a===null?(n.next=n,bm(t)):(n.next=a.next,a.next=n),t.interleaved=n,Cn(e,r)}function Cn(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 Ln=!1;function Nm(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function cy(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 Nn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function rr(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Pe&2){var a=r.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),r.pending=t,Cn(e,n)}return a=r.interleaved,a===null?(t.next=t,bm(r)):(t.next=a.next,a.next=t),r.interleaved=t,Cn(e,n)}function io(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,lm(e,n)}}function Zf(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 Ro(e,t,n,r){var a=e.updateQueue;Ln=!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 p=o.lane,m=o.eventTime;if((r&p)===p){u!==null&&(u=u.next={eventTime:m,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var f=e,x=o;switch(p=t,m=n,x.tag){case 1:if(f=x.payload,typeof f=="function"){h=f.call(m,h,p);break e}h=f;break e;case 3:f.flags=f.flags&-65537|128;case 0:if(f=x.payload,p=typeof f=="function"?f.call(m,h,p):f,p==null)break e;h=rt({},h,p);break e;case 2:Ln=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,p=a.effects,p===null?a.effects=[o]:p.push(o))}else m={eventTime:m,lane:p,tag:o.tag,payload:o.payload,callback:o.callback,next:null},u===null?(d=u=m,c=h):u=u.next=m,l|=p;if(o=o.next,o===null){if(o=a.shared.pending,o===null)break;p=o,o=p.next,p.next=null,a.lastBaseUpdate=p,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);Br|=l,e.lanes=l,e.memoizedState=h}}function Jf(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(X(191,a));a.call(r)}}}var jl={},nn=hr(jl),Vi=hr(jl),Qi=hr(jl);function wr(e){if(e===jl)throw Error(X(174));return e}function wm(e,t){switch(Be(Qi,t),Be(Vi,e),Be(nn,jl),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Dd(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Dd(t,e)}We(nn),Be(nn,t)}function Ba(){We(nn),We(Vi),We(Qi)}function dy(e){wr(Qi.current);var t=wr(nn.current),n=Dd(t,e.type);t!==n&&(Be(Vi,e),Be(nn,n))}function Sm(e){Vi.current===e&&(We(nn),We(Vi))}var tt=hr(0);function Lo(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 Yc=[];function km(){for(var e=0;e<Yc.length;e++)Yc[e]._workInProgressVersionPrimary=null;Yc.length=0}var lo=An.ReactCurrentDispatcher,ed=An.ReactCurrentBatchConfig,Ur=0,st=null,bt=null,kt=null,Oo=!1,Ei=!1,Hi=0,Tb=0;function Lt(){throw Error(X(321))}function Cm(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Ks(e[n],t[n]))return!1;return!0}function Em(e,t,n,r,a,i){if(Ur=i,st=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,lo.current=e===null||e.memoizedState===null?Ob:zb,e=n(r,a),Ei){i=0;do{if(Ei=!1,Hi=0,25<=i)throw Error(X(301));i+=1,kt=bt=null,t.updateQueue=null,lo.current=$b,e=n(r,a)}while(Ei)}if(lo.current=zo,t=bt!==null&&bt.next!==null,Ur=0,kt=bt=st=null,Oo=!1,t)throw Error(X(300));return e}function Dm(){var e=Hi!==0;return Hi=0,e}function Ws(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return kt===null?st.memoizedState=kt=e:kt=kt.next=e,kt}function Cs(){if(bt===null){var e=st.alternate;e=e!==null?e.memoizedState:null}else e=bt.next;var t=kt===null?st.memoizedState:kt.next;if(t!==null)kt=t,bt=e;else{if(e===null)throw Error(X(310));bt=e,e={memoizedState:bt.memoizedState,baseState:bt.baseState,baseQueue:bt.baseQueue,queue:bt.queue,next:null},kt===null?st.memoizedState=kt=e:kt=kt.next=e}return kt}function Wi(e,t){return typeof t=="function"?t(e):t}function td(e){var t=Cs(),n=t.queue;if(n===null)throw Error(X(311));n.lastRenderedReducer=e;var r=bt,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((Ur&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,st.lanes|=u,Br|=u}d=d.next}while(d!==null&&d!==i);c===null?l=r:c.next=o,Ks(r,t.memoizedState)||(ts=!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,st.lanes|=i,Br|=i,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function sd(e){var t=Cs(),n=t.queue;if(n===null)throw Error(X(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);Ks(i,t.memoizedState)||(ts=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function uy(){}function my(e,t){var n=st,r=Cs(),a=t(),i=!Ks(r.memoizedState,a);if(i&&(r.memoizedState=a,ts=!0),r=r.queue,Pm(py.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||kt!==null&&kt.memoizedState.tag&1){if(n.flags|=2048,Gi(9,fy.bind(null,n,r,a,t),void 0,null),Dt===null)throw Error(X(349));Ur&30||hy(n,t,a)}return a}function hy(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=st.updateQueue,t===null?(t={lastEffect:null,stores:null},st.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function fy(e,t,n,r){t.value=n,t.getSnapshot=r,xy(t)&&gy(e)}function py(e,t,n){return n(function(){xy(t)&&gy(e)})}function xy(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Ks(e,n)}catch{return!0}}function gy(e){var t=Cn(e,1);t!==null&&_s(t,e,1,-1)}function Xf(e){var t=Ws();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Wi,lastRenderedState:e},t.queue=e,e=e.dispatch=Lb.bind(null,st,e),[t.memoizedState,e]}function Gi(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=st.updateQueue,t===null?(t={lastEffect:null,stores:null},st.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 yy(){return Cs().memoizedState}function oo(e,t,n,r){var a=Ws();st.flags|=e,a.memoizedState=Gi(1|t,n,void 0,r===void 0?null:r)}function lc(e,t,n,r){var a=Cs();r=r===void 0?null:r;var i=void 0;if(bt!==null){var l=bt.memoizedState;if(i=l.destroy,r!==null&&Cm(r,l.deps)){a.memoizedState=Gi(t,n,i,r);return}}st.flags|=e,a.memoizedState=Gi(1|t,n,i,r)}function Yf(e,t){return oo(8390656,8,e,t)}function Pm(e,t){return lc(2048,8,e,t)}function vy(e,t){return lc(4,2,e,t)}function jy(e,t){return lc(4,4,e,t)}function by(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 Ny(e,t,n){return n=n!=null?n.concat([e]):null,lc(4,4,by.bind(null,t,e),n)}function Am(){}function wy(e,t){var n=Cs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Cm(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Sy(e,t){var n=Cs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Cm(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function ky(e,t,n){return Ur&21?(Ks(n,t)||(n=Ag(),st.lanes|=n,Br|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ts=!0),e.memoizedState=n)}function Ib(e,t){var n=$e;$e=n!==0&&4>n?n:4,e(!0);var r=ed.transition;ed.transition={};try{e(!1),t()}finally{$e=n,ed.transition=r}}function Cy(){return Cs().memoizedState}function Rb(e,t,n){var r=ir(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ey(e))Dy(t,n);else if(n=oy(e,t,n,r),n!==null){var a=Qt();_s(n,e,r,a),Py(n,t,r)}}function Lb(e,t,n){var r=ir(e),a={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ey(e))Dy(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,Ks(o,l)){var c=t.interleaved;c===null?(a.next=a,bm(t)):(a.next=c.next,c.next=a),t.interleaved=a;return}}catch{}finally{}n=oy(e,t,a,r),n!==null&&(a=Qt(),_s(n,e,r,a),Py(n,t,r))}}function Ey(e){var t=e.alternate;return e===st||t!==null&&t===st}function Dy(e,t){Ei=Oo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Py(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,lm(e,n)}}var zo={readContext:ks,useCallback:Lt,useContext:Lt,useEffect:Lt,useImperativeHandle:Lt,useInsertionEffect:Lt,useLayoutEffect:Lt,useMemo:Lt,useReducer:Lt,useRef:Lt,useState:Lt,useDebugValue:Lt,useDeferredValue:Lt,useTransition:Lt,useMutableSource:Lt,useSyncExternalStore:Lt,useId:Lt,unstable_isNewReconciler:!1},Ob={readContext:ks,useCallback:function(e,t){return Ws().memoizedState=[e,t===void 0?null:t],e},useContext:ks,useEffect:Yf,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,oo(4194308,4,by.bind(null,t,e),n)},useLayoutEffect:function(e,t){return oo(4194308,4,e,t)},useInsertionEffect:function(e,t){return oo(4,2,e,t)},useMemo:function(e,t){var n=Ws();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ws();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=Rb.bind(null,st,e),[r.memoizedState,e]},useRef:function(e){var t=Ws();return e={current:e},t.memoizedState=e},useState:Xf,useDebugValue:Am,useDeferredValue:function(e){return Ws().memoizedState=e},useTransition:function(){var e=Xf(!1),t=e[0];return e=Ib.bind(null,e[1]),Ws().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=st,a=Ws();if(Xe){if(n===void 0)throw Error(X(407));n=n()}else{if(n=t(),Dt===null)throw Error(X(349));Ur&30||hy(r,t,n)}a.memoizedState=n;var i={value:n,getSnapshot:t};return a.queue=i,Yf(py.bind(null,r,i,e),[e]),r.flags|=2048,Gi(9,fy.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Ws(),t=Dt.identifierPrefix;if(Xe){var n=jn,r=vn;n=(r&~(1<<32-$s(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Hi++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=Tb++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},zb={readContext:ks,useCallback:wy,useContext:ks,useEffect:Pm,useImperativeHandle:Ny,useInsertionEffect:vy,useLayoutEffect:jy,useMemo:Sy,useReducer:td,useRef:yy,useState:function(){return td(Wi)},useDebugValue:Am,useDeferredValue:function(e){var t=Cs();return ky(t,bt.memoizedState,e)},useTransition:function(){var e=td(Wi)[0],t=Cs().memoizedState;return[e,t]},useMutableSource:uy,useSyncExternalStore:my,useId:Cy,unstable_isNewReconciler:!1},$b={readContext:ks,useCallback:wy,useContext:ks,useEffect:Pm,useImperativeHandle:Ny,useInsertionEffect:vy,useLayoutEffect:jy,useMemo:Sy,useReducer:sd,useRef:yy,useState:function(){return sd(Wi)},useDebugValue:Am,useDeferredValue:function(e){var t=Cs();return bt===null?t.memoizedState=e:ky(t,bt.memoizedState,e)},useTransition:function(){var e=sd(Wi)[0],t=Cs().memoizedState;return[e,t]},useMutableSource:uy,useSyncExternalStore:my,useId:Cy,unstable_isNewReconciler:!1};function Ms(e,t){if(e&&e.defaultProps){t=rt({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Gd(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:rt({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var oc={isMounted:function(e){return(e=e._reactInternals)?Zr(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Qt(),a=ir(e),i=Nn(r,a);i.payload=t,n!=null&&(i.callback=n),t=rr(e,i,a),t!==null&&(_s(t,e,a,r),io(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Qt(),a=ir(e),i=Nn(r,a);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=rr(e,i,a),t!==null&&(_s(t,e,a,r),io(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Qt(),r=ir(e),a=Nn(n,r);a.tag=2,t!=null&&(a.callback=t),t=rr(e,a,r),t!==null&&(_s(t,e,r,n),io(t,e,r))}};function ep(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?!Ki(n,r)||!Ki(a,i):!0}function Ay(e,t,n){var r=!1,a=ur,i=t.contextType;return typeof i=="object"&&i!==null?i=ks(i):(a=ns(t)?_r:Kt.current,r=t.contextTypes,i=(r=r!=null)?_a(e,a):ur),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=oc,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=i),t}function tp(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&&oc.enqueueReplaceState(t,t.state,null)}function Zd(e,t,n,r){var a=e.stateNode;a.props=n,a.state=e.memoizedState,a.refs={},Nm(e);var i=t.contextType;typeof i=="object"&&i!==null?a.context=ks(i):(i=ns(t)?_r:Kt.current,a.context=_a(e,i)),a.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(Gd(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&&oc.enqueueReplaceState(a,a.state,null),Ro(e,n,a,r),a.state=e.memoizedState),typeof a.componentDidMount=="function"&&(e.flags|=4194308)}function qa(e,t){try{var n="",r=t;do n+=hj(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 nd(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Jd(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var _b=typeof WeakMap=="function"?WeakMap:Map;function My(e,t,n){n=Nn(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){_o||(_o=!0,lu=r),Jd(e,t)},n}function Fy(e,t,n){n=Nn(-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(){Jd(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){Jd(e,t),typeof r!="function"&&(ar===null?ar=new Set([this]):ar.add(this));var l=t.stack;this.componentDidCatch(t.value,{componentStack:l!==null?l:""})}),n}function sp(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new _b;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=eN.bind(null,e,t,n),t.then(e,e))}function np(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 rp(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=Nn(-1,1),t.tag=2,rr(n,t,1))),n.lanes|=1),e)}var Kb=An.ReactCurrentOwner,ts=!1;function Vt(e,t,n,r){t.child=e===null?ly(t,null,n,r):Ua(t,e.child,n,r)}function ap(e,t,n,r,a){n=n.render;var i=t.ref;return ja(t,a),r=Em(e,t,n,r,i,a),n=Dm(),e!==null&&!ts?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,En(e,t,a)):(Xe&&n&&pm(t),t.flags|=1,Vt(e,t,r,a),t.child)}function ip(e,t,n,r,a){if(e===null){var i=n.type;return typeof i=="function"&&!zm(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,Ty(e,t,i,r,a)):(e=ho(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:Ki,n(l,r)&&e.ref===t.ref)return En(e,t,a)}return t.flags|=1,e=lr(i,r),e.ref=t.ref,e.return=t,t.child=e}function Ty(e,t,n,r,a){if(e!==null){var i=e.memoizedProps;if(Ki(i,r)&&e.ref===t.ref)if(ts=!1,t.pendingProps=r=i,(e.lanes&a)!==0)e.flags&131072&&(ts=!0);else return t.lanes=e.lanes,En(e,t,a)}return Xd(e,t,n,r,a)}function Iy(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},Be(fa,os),os|=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,Be(fa,os),os|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,Be(fa,os),os|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,Be(fa,os),os|=r;return Vt(e,t,a,n),t.child}function Ry(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Xd(e,t,n,r,a){var i=ns(n)?_r:Kt.current;return i=_a(t,i),ja(t,a),n=Em(e,t,n,r,i,a),r=Dm(),e!==null&&!ts?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,En(e,t,a)):(Xe&&r&&pm(t),t.flags|=1,Vt(e,t,n,a),t.child)}function lp(e,t,n,r,a){if(ns(n)){var i=!0;Ao(t)}else i=!1;if(ja(t,a),t.stateNode===null)co(e,t),Ay(t,n,r),Zd(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=ks(d):(d=ns(n)?_r:Kt.current,d=_a(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)&&tp(t,l,r,d),Ln=!1;var p=t.memoizedState;l.state=p,Ro(t,r,l,a),c=t.memoizedState,o!==r||p!==c||ss.current||Ln?(typeof u=="function"&&(Gd(t,n,u,r),c=t.memoizedState),(o=Ln||ep(t,n,o,r,p,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,cy(e,t),o=t.memoizedProps,d=t.type===t.elementType?o:Ms(t.type,o),l.props=d,h=t.pendingProps,p=l.context,c=n.contextType,typeof c=="object"&&c!==null?c=ks(c):(c=ns(n)?_r:Kt.current,c=_a(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||p!==c)&&tp(t,l,r,c),Ln=!1,p=t.memoizedState,l.state=p,Ro(t,r,l,a);var f=t.memoizedState;o!==h||p!==f||ss.current||Ln?(typeof m=="function"&&(Gd(t,n,m,r),f=t.memoizedState),(d=Ln||ep(t,n,d,r,p,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&&p===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&p===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&&p===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),r=!1)}return Yd(e,t,n,r,i,a)}function Yd(e,t,n,r,a,i){Ry(e,t);var l=(t.flags&128)!==0;if(!r&&!l)return a&&Qf(t,n,!1),En(e,t,i);r=t.stateNode,Kb.current=t;var o=l&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&l?(t.child=Ua(t,e.child,null,i),t.child=Ua(t,null,o,i)):Vt(e,t,o,i),t.memoizedState=r.state,a&&Qf(t,n,!0),t.child}function Ly(e){var t=e.stateNode;t.pendingContext?Vf(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Vf(e,t.context,!1),wm(e,t.containerInfo)}function op(e,t,n,r,a){return Ka(),gm(a),t.flags|=256,Vt(e,t,n,r),t.child}var eu={dehydrated:null,treeContext:null,retryLane:0};function tu(e){return{baseLanes:e,cachePool:null,transitions:null}}function Oy(e,t,n){var r=t.pendingProps,a=tt.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),Be(tt,a&1),e===null)return Hd(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=uc(l,r,0,null),e=Or(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=tu(n),t.memoizedState=eu,e):Mm(t,l));if(a=e.memoizedState,a!==null&&(o=a.dehydrated,o!==null))return Ub(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=lr(a,c),r.subtreeFlags=a.subtreeFlags&14680064),o!==null?i=lr(o,i):(i=Or(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?tu(n):{baseLanes:l.baseLanes|n,cachePool:null,transitions:l.transitions},i.memoizedState=l,i.childLanes=e.childLanes&~n,t.memoizedState=eu,r}return i=e.child,e=i.sibling,r=lr(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 Mm(e,t){return t=uc({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Hl(e,t,n,r){return r!==null&&gm(r),Ua(t,e.child,null,n),e=Mm(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Ub(e,t,n,r,a,i,l){if(n)return t.flags&256?(t.flags&=-257,r=nd(Error(X(422))),Hl(e,t,l,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,a=t.mode,r=uc({mode:"visible",children:r.children},a,0,null),i=Or(i,a,l,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&Ua(t,e.child,null,l),t.child.memoizedState=tu(l),t.memoizedState=eu,i);if(!(t.mode&1))return Hl(e,t,l,null);if(a.data==="$!"){if(r=a.nextSibling&&a.nextSibling.dataset,r)var o=r.dgst;return r=o,i=Error(X(419)),r=nd(i,r,void 0),Hl(e,t,l,r)}if(o=(l&e.childLanes)!==0,ts||o){if(r=Dt,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,Cn(e,a),_s(r,e,a,-1))}return Om(),r=nd(Error(X(421))),Hl(e,t,l,r)}return a.data==="$?"?(t.flags|=128,t.child=e.child,t=tN.bind(null,e),a._reactRetry=t,null):(e=i.treeContext,us=nr(a.nextSibling),ms=t,Xe=!0,Rs=null,e!==null&&(js[bs++]=vn,js[bs++]=jn,js[bs++]=Kr,vn=e.id,jn=e.overflow,Kr=t),t=Mm(t,r.children),t.flags|=4096,t)}function cp(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Wd(e.return,t,n)}function rd(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 zy(e,t,n){var r=t.pendingProps,a=r.revealOrder,i=r.tail;if(Vt(e,t,r.children,n),r=tt.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&&cp(e,n,t);else if(e.tag===19)cp(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(Be(tt,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&&Lo(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),rd(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&&Lo(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}rd(t,!0,n,null,i);break;case"together":rd(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function co(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function En(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Br|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(X(153));if(t.child!==null){for(e=t.child,n=lr(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=lr(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Bb(e,t,n){switch(t.tag){case 3:Ly(t),Ka();break;case 5:dy(t);break;case 1:ns(t.type)&&Ao(t);break;case 4:wm(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,a=t.memoizedProps.value;Be(To,r._currentValue),r._currentValue=a;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Be(tt,tt.current&1),t.flags|=128,null):n&t.child.childLanes?Oy(e,t,n):(Be(tt,tt.current&1),e=En(e,t,n),e!==null?e.sibling:null);Be(tt,tt.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return zy(e,t,n);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),Be(tt,tt.current),r)break;return null;case 22:case 23:return t.lanes=0,Iy(e,t,n)}return En(e,t,n)}var $y,su,_y,Ky;$y=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}};su=function(){};_y=function(e,t,n,r){var a=e.memoizedProps;if(a!==r){e=t.stateNode,wr(nn.current);var i=null;switch(n){case"input":a=Sd(e,a),r=Sd(e,r),i=[];break;case"select":a=rt({},a,{value:void 0}),r=rt({},r,{value:void 0}),i=[];break;case"textarea":a=Ed(e,a),r=Ed(e,r),i=[];break;default:typeof a.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Do)}Pd(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"&&(Ii.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"&&(Ii.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&Qe("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)}};Ky=function(e,t,n,r){n!==r&&(t.flags|=4)};function mi(e,t){if(!Xe)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 Ot(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 qb(e,t,n){var r=t.pendingProps;switch(xm(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ot(t),null;case 1:return ns(t.type)&&Po(),Ot(t),null;case 3:return r=t.stateNode,Ba(),We(ss),We(Kt),km(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Vl(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Rs!==null&&(du(Rs),Rs=null))),su(e,t),Ot(t),null;case 5:Sm(t);var a=wr(Qi.current);if(n=t.type,e!==null&&t.stateNode!=null)_y(e,t,n,r,a),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(X(166));return Ot(t),null}if(e=wr(nn.current),Vl(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[Ys]=t,r[qi]=i,e=(t.mode&1)!==0,n){case"dialog":Qe("cancel",r),Qe("close",r);break;case"iframe":case"object":case"embed":Qe("load",r);break;case"video":case"audio":for(a=0;a<vi.length;a++)Qe(vi[a],r);break;case"source":Qe("error",r);break;case"img":case"image":case"link":Qe("error",r),Qe("load",r);break;case"details":Qe("toggle",r);break;case"input":yf(r,i),Qe("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},Qe("invalid",r);break;case"textarea":jf(r,i),Qe("invalid",r)}Pd(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&&ql(r.textContent,o,e),a=["children",o]):typeof o=="number"&&r.textContent!==""+o&&(i.suppressHydrationWarning!==!0&&ql(r.textContent,o,e),a=["children",""+o]):Ii.hasOwnProperty(l)&&o!=null&&l==="onScroll"&&Qe("scroll",r)}switch(n){case"input":Ll(r),vf(r,i,!0);break;case"textarea":Ll(r),bf(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=Do)}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=pg(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[Ys]=t,e[qi]=r,$y(e,t,!1,!1),t.stateNode=e;e:{switch(l=Ad(n,r),n){case"dialog":Qe("cancel",e),Qe("close",e),a=r;break;case"iframe":case"object":case"embed":Qe("load",e),a=r;break;case"video":case"audio":for(a=0;a<vi.length;a++)Qe(vi[a],e);a=r;break;case"source":Qe("error",e),a=r;break;case"img":case"image":case"link":Qe("error",e),Qe("load",e),a=r;break;case"details":Qe("toggle",e),a=r;break;case"input":yf(e,r),a=Sd(e,r),Qe("invalid",e);break;case"option":a=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},a=rt({},r,{value:void 0}),Qe("invalid",e);break;case"textarea":jf(e,r),a=Ed(e,r),Qe("invalid",e);break;default:a=r}Pd(n,a),o=a;for(i in o)if(o.hasOwnProperty(i)){var c=o[i];i==="style"?yg(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&xg(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Ri(e,c):typeof c=="number"&&Ri(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Ii.hasOwnProperty(i)?c!=null&&i==="onScroll"&&Qe("scroll",e):c!=null&&tm(e,i,c,l))}switch(n){case"input":Ll(e),vf(e,r,!1);break;case"textarea":Ll(e),bf(e);break;case"option":r.value!=null&&e.setAttribute("value",""+dr(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?xa(e,!!r.multiple,i,!1):r.defaultValue!=null&&xa(e,!!r.multiple,r.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=Do)}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 Ot(t),null;case 6:if(e&&t.stateNode!=null)Ky(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(X(166));if(n=wr(Qi.current),wr(nn.current),Vl(t)){if(r=t.stateNode,n=t.memoizedProps,r[Ys]=t,(i=r.nodeValue!==n)&&(e=ms,e!==null))switch(e.tag){case 3:ql(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&ql(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Ys]=t,t.stateNode=r}return Ot(t),null;case 13:if(We(tt),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Xe&&us!==null&&t.mode&1&&!(t.flags&128))ay(),Ka(),t.flags|=98560,i=!1;else if(i=Vl(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(X(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(X(317));i[Ys]=t}else Ka(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ot(t),i=!1}else Rs!==null&&(du(Rs),Rs=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||tt.current&1?wt===0&&(wt=3):Om())),t.updateQueue!==null&&(t.flags|=4),Ot(t),null);case 4:return Ba(),su(e,t),e===null&&Ui(t.stateNode.containerInfo),Ot(t),null;case 10:return jm(t.type._context),Ot(t),null;case 17:return ns(t.type)&&Po(),Ot(t),null;case 19:if(We(tt),i=t.memoizedState,i===null)return Ot(t),null;if(r=(t.flags&128)!==0,l=i.rendering,l===null)if(r)mi(i,!1);else{if(wt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(l=Lo(e),l!==null){for(t.flags|=128,mi(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 Be(tt,tt.current&1|2),t.child}e=e.sibling}i.tail!==null&&ft()>Va&&(t.flags|=128,r=!0,mi(i,!1),t.lanes=4194304)}else{if(!r)if(e=Lo(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),mi(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!Xe)return Ot(t),null}else 2*ft()-i.renderingStartTime>Va&&n!==1073741824&&(t.flags|=128,r=!0,mi(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=tt.current,Be(tt,r?n&1|2:n&1),t):(Ot(t),null);case 22:case 23:return Lm(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?os&1073741824&&(Ot(t),t.subtreeFlags&6&&(t.flags|=8192)):Ot(t),null;case 24:return null;case 25:return null}throw Error(X(156,t.tag))}function Vb(e,t){switch(xm(t),t.tag){case 1:return ns(t.type)&&Po(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ba(),We(ss),We(Kt),km(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Sm(t),null;case 13:if(We(tt),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(X(340));Ka()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return We(tt),null;case 4:return Ba(),null;case 10:return jm(t.type._context),null;case 22:case 23:return Lm(),null;case 24:return null;default:return null}}var Wl=!1,$t=!1,Qb=typeof WeakSet=="function"?WeakSet:Set,ue=null;function ha(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ut(e,t,r)}else n.current=null}function nu(e,t,n){try{n()}catch(r){ut(e,t,r)}}var dp=!1;function Hb(e,t){if(_d=ko,e=Qg(),fm(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,p=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;)p=h,h=m;for(;;){if(h===e)break t;if(p===n&&++d===a&&(o=l),p===i&&++u===r&&(c=l),(m=h.nextSibling)!==null)break;h=p,p=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(Kd={focusedElem:e,selectionRange:n},ko=!1,ue=t;ue!==null;)if(t=ue,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,ue=e;else for(;ue!==null;){t=ue;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 x=f.memoizedProps,j=f.memoizedState,y=t.stateNode,v=y.getSnapshotBeforeUpdate(t.elementType===t.type?x:Ms(t.type,x),j);y.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var g=t.stateNode.containerInfo;g.nodeType===1?g.textContent="":g.nodeType===9&&g.documentElement&&g.removeChild(g.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(X(163))}}catch(w){ut(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,ue=e;break}ue=t.return}return f=dp,dp=!1,f}function Di(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&&nu(t,n,i)}a=a.next}while(a!==r)}}function cc(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 ru(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 Uy(e){var t=e.alternate;t!==null&&(e.alternate=null,Uy(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ys],delete t[qi],delete t[qd],delete t[Pb],delete t[Ab])),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 By(e){return e.tag===5||e.tag===3||e.tag===4}function up(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||By(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 au(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=Do));else if(r!==4&&(e=e.child,e!==null))for(au(e,t,n),e=e.sibling;e!==null;)au(e,t,n),e=e.sibling}function iu(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(iu(e,t,n),e=e.sibling;e!==null;)iu(e,t,n),e=e.sibling}var Pt=null,Is=!1;function Tn(e,t,n){for(n=n.child;n!==null;)qy(e,t,n),n=n.sibling}function qy(e,t,n){if(sn&&typeof sn.onCommitFiberUnmount=="function")try{sn.onCommitFiberUnmount(tc,n)}catch{}switch(n.tag){case 5:$t||ha(n,t);case 6:var r=Pt,a=Is;Pt=null,Tn(e,t,n),Pt=r,Is=a,Pt!==null&&(Is?(e=Pt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Pt.removeChild(n.stateNode));break;case 18:Pt!==null&&(Is?(e=Pt,n=n.stateNode,e.nodeType===8?Jc(e.parentNode,n):e.nodeType===1&&Jc(e,n),$i(e)):Jc(Pt,n.stateNode));break;case 4:r=Pt,a=Is,Pt=n.stateNode.containerInfo,Is=!0,Tn(e,t,n),Pt=r,Is=a;break;case 0:case 11:case 14:case 15:if(!$t&&(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)&&nu(n,t,l),a=a.next}while(a!==r)}Tn(e,t,n);break;case 1:if(!$t&&(ha(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){ut(n,t,o)}Tn(e,t,n);break;case 21:Tn(e,t,n);break;case 22:n.mode&1?($t=(r=$t)||n.memoizedState!==null,Tn(e,t,n),$t=r):Tn(e,t,n);break;default:Tn(e,t,n)}}function mp(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Qb),t.forEach(function(r){var a=sN.bind(null,e,r);n.has(r)||(n.add(r),r.then(a,a))})}}function As(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:Pt=o.stateNode,Is=!1;break e;case 3:Pt=o.stateNode.containerInfo,Is=!0;break e;case 4:Pt=o.stateNode.containerInfo,Is=!0;break e}o=o.return}if(Pt===null)throw Error(X(160));qy(i,l,a),Pt=null,Is=!1;var c=a.alternate;c!==null&&(c.return=null),a.return=null}catch(d){ut(a,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Vy(t,e),t=t.sibling}function Vy(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(As(t,e),Qs(e),r&4){try{Di(3,e,e.return),cc(3,e)}catch(x){ut(e,e.return,x)}try{Di(5,e,e.return)}catch(x){ut(e,e.return,x)}}break;case 1:As(t,e),Qs(e),r&512&&n!==null&&ha(n,n.return);break;case 5:if(As(t,e),Qs(e),r&512&&n!==null&&ha(n,n.return),e.flags&32){var a=e.stateNode;try{Ri(a,"")}catch(x){ut(e,e.return,x)}}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&&hg(a,i),Ad(o,l);var d=Ad(o,i);for(l=0;l<c.length;l+=2){var u=c[l],h=c[l+1];u==="style"?yg(a,h):u==="dangerouslySetInnerHTML"?xg(a,h):u==="children"?Ri(a,h):tm(a,u,h,d)}switch(o){case"input":kd(a,i);break;case"textarea":fg(a,i);break;case"select":var p=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!i.multiple;var m=i.value;m!=null?xa(a,!!i.multiple,m,!1):p!==!!i.multiple&&(i.defaultValue!=null?xa(a,!!i.multiple,i.defaultValue,!0):xa(a,!!i.multiple,i.multiple?[]:"",!1))}a[qi]=i}catch(x){ut(e,e.return,x)}}break;case 6:if(As(t,e),Qs(e),r&4){if(e.stateNode===null)throw Error(X(162));a=e.stateNode,i=e.memoizedProps;try{a.nodeValue=i}catch(x){ut(e,e.return,x)}}break;case 3:if(As(t,e),Qs(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{$i(t.containerInfo)}catch(x){ut(e,e.return,x)}break;case 4:As(t,e),Qs(e);break;case 13:As(t,e),Qs(e),a=e.child,a.flags&8192&&(i=a.memoizedState!==null,a.stateNode.isHidden=i,!i||a.alternate!==null&&a.alternate.memoizedState!==null||(Im=ft())),r&4&&mp(e);break;case 22:if(u=n!==null&&n.memoizedState!==null,e.mode&1?($t=(d=$t)||u,As(t,e),$t=d):As(t,e),Qs(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!u&&e.mode&1)for(ue=e,u=e.child;u!==null;){for(h=ue=u;ue!==null;){switch(p=ue,m=p.child,p.tag){case 0:case 11:case 14:case 15:Di(4,p,p.return);break;case 1:ha(p,p.return);var f=p.stateNode;if(typeof f.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,f.props=t.memoizedProps,f.state=t.memoizedState,f.componentWillUnmount()}catch(x){ut(r,n,x)}}break;case 5:ha(p,p.return);break;case 22:if(p.memoizedState!==null){fp(h);continue}}m!==null?(m.return=p,ue=m):fp(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=gg("display",l))}catch(x){ut(e,e.return,x)}}}else if(h.tag===6){if(u===null)try{h.stateNode.nodeValue=d?"":h.memoizedProps}catch(x){ut(e,e.return,x)}}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:As(t,e),Qs(e),r&4&&mp(e);break;case 21:break;default:As(t,e),Qs(e)}}function Qs(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(By(n)){var r=n;break e}n=n.return}throw Error(X(160))}switch(r.tag){case 5:var a=r.stateNode;r.flags&32&&(Ri(a,""),r.flags&=-33);var i=up(e);iu(e,i,a);break;case 3:case 4:var l=r.stateNode.containerInfo,o=up(e);au(e,o,l);break;default:throw Error(X(161))}}catch(c){ut(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Wb(e,t,n){ue=e,Qy(e)}function Qy(e,t,n){for(var r=(e.mode&1)!==0;ue!==null;){var a=ue,i=a.child;if(a.tag===22&&r){var l=a.memoizedState!==null||Wl;if(!l){var o=a.alternate,c=o!==null&&o.memoizedState!==null||$t;o=Wl;var d=$t;if(Wl=l,($t=c)&&!d)for(ue=a;ue!==null;)l=ue,c=l.child,l.tag===22&&l.memoizedState!==null?pp(a):c!==null?(c.return=l,ue=c):pp(a);for(;i!==null;)ue=i,Qy(i),i=i.sibling;ue=a,Wl=o,$t=d}hp(e)}else a.subtreeFlags&8772&&i!==null?(i.return=a,ue=i):hp(e)}}function hp(e){for(;ue!==null;){var t=ue;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:$t||cc(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!$t)if(n===null)r.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:Ms(t.type,n.memoizedProps);r.componentDidUpdate(a,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Jf(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}Jf(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&&$i(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(X(163))}$t||t.flags&512&&ru(t)}catch(p){ut(t,t.return,p)}}if(t===e){ue=null;break}if(n=t.sibling,n!==null){n.return=t.return,ue=n;break}ue=t.return}}function fp(e){for(;ue!==null;){var t=ue;if(t===e){ue=null;break}var n=t.sibling;if(n!==null){n.return=t.return,ue=n;break}ue=t.return}}function pp(e){for(;ue!==null;){var t=ue;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{cc(4,t)}catch(c){ut(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var a=t.return;try{r.componentDidMount()}catch(c){ut(t,a,c)}}var i=t.return;try{ru(t)}catch(c){ut(t,i,c)}break;case 5:var l=t.return;try{ru(t)}catch(c){ut(t,l,c)}}}catch(c){ut(t,t.return,c)}if(t===e){ue=null;break}var o=t.sibling;if(o!==null){o.return=t.return,ue=o;break}ue=t.return}}var Gb=Math.ceil,$o=An.ReactCurrentDispatcher,Fm=An.ReactCurrentOwner,Ss=An.ReactCurrentBatchConfig,Pe=0,Dt=null,yt=null,Tt=0,os=0,fa=hr(0),wt=0,Zi=null,Br=0,dc=0,Tm=0,Pi=null,es=null,Im=0,Va=1/0,mn=null,_o=!1,lu=null,ar=null,Gl=!1,Xn=null,Ko=0,Ai=0,ou=null,uo=-1,mo=0;function Qt(){return Pe&6?ft():uo!==-1?uo:uo=ft()}function ir(e){return e.mode&1?Pe&2&&Tt!==0?Tt&-Tt:Fb.transition!==null?(mo===0&&(mo=Ag()),mo):(e=$e,e!==0||(e=window.event,e=e===void 0?16:Og(e.type)),e):1}function _s(e,t,n,r){if(50<Ai)throw Ai=0,ou=null,Error(X(185));gl(e,n,r),(!(Pe&2)||e!==Dt)&&(e===Dt&&(!(Pe&2)&&(dc|=n),wt===4&&zn(e,Tt)),rs(e,r),n===1&&Pe===0&&!(t.mode&1)&&(Va=ft()+500,ic&&fr()))}function rs(e,t){var n=e.callbackNode;Fj(e,t);var r=So(e,e===Dt?Tt:0);if(r===0)n!==null&&Sf(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Sf(n),t===1)e.tag===0?Mb(xp.bind(null,e)):sy(xp.bind(null,e)),Eb(function(){!(Pe&6)&&fr()}),n=null;else{switch(Mg(r)){case 1:n=im;break;case 4:n=Dg;break;case 16:n=wo;break;case 536870912:n=Pg;break;default:n=wo}n=e0(n,Hy.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function Hy(e,t){if(uo=-1,mo=0,Pe&6)throw Error(X(327));var n=e.callbackNode;if(ba()&&e.callbackNode!==n)return null;var r=So(e,e===Dt?Tt:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Uo(e,r);else{t=r;var a=Pe;Pe|=2;var i=Gy();(Dt!==e||Tt!==t)&&(mn=null,Va=ft()+500,Lr(e,t));do try{Xb();break}catch(o){Wy(e,o)}while(!0);vm(),$o.current=i,Pe=a,yt!==null?t=0:(Dt=null,Tt=0,t=wt)}if(t!==0){if(t===2&&(a=Rd(e),a!==0&&(r=a,t=cu(e,a))),t===1)throw n=Zi,Lr(e,0),zn(e,r),rs(e,ft()),n;if(t===6)zn(e,r);else{if(a=e.current.alternate,!(r&30)&&!Zb(a)&&(t=Uo(e,r),t===2&&(i=Rd(e),i!==0&&(r=i,t=cu(e,i))),t===1))throw n=Zi,Lr(e,0),zn(e,r),rs(e,ft()),n;switch(e.finishedWork=a,e.finishedLanes=r,t){case 0:case 1:throw Error(X(345));case 2:vr(e,es,mn);break;case 3:if(zn(e,r),(r&130023424)===r&&(t=Im+500-ft(),10<t)){if(So(e,0)!==0)break;if(a=e.suspendedLanes,(a&r)!==r){Qt(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=Bd(vr.bind(null,e,es,mn),t);break}vr(e,es,mn);break;case 4:if(zn(e,r),(r&4194240)===r)break;for(t=e.eventTimes,a=-1;0<r;){var l=31-$s(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*Gb(r/1960))-r,10<r){e.timeoutHandle=Bd(vr.bind(null,e,es,mn),r);break}vr(e,es,mn);break;case 5:vr(e,es,mn);break;default:throw Error(X(329))}}}return rs(e,ft()),e.callbackNode===n?Hy.bind(null,e):null}function cu(e,t){var n=Pi;return e.current.memoizedState.isDehydrated&&(Lr(e,t).flags|=256),e=Uo(e,t),e!==2&&(t=es,es=n,t!==null&&du(t)),e}function du(e){es===null?es=e:es.push.apply(es,e)}function Zb(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(!Ks(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 zn(e,t){for(t&=~Tm,t&=~dc,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-$s(t),r=1<<n;e[n]=-1,t&=~r}}function xp(e){if(Pe&6)throw Error(X(327));ba();var t=So(e,0);if(!(t&1))return rs(e,ft()),null;var n=Uo(e,t);if(e.tag!==0&&n===2){var r=Rd(e);r!==0&&(t=r,n=cu(e,r))}if(n===1)throw n=Zi,Lr(e,0),zn(e,t),rs(e,ft()),n;if(n===6)throw Error(X(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,vr(e,es,mn),rs(e,ft()),null}function Rm(e,t){var n=Pe;Pe|=1;try{return e(t)}finally{Pe=n,Pe===0&&(Va=ft()+500,ic&&fr())}}function qr(e){Xn!==null&&Xn.tag===0&&!(Pe&6)&&ba();var t=Pe;Pe|=1;var n=Ss.transition,r=$e;try{if(Ss.transition=null,$e=1,e)return e()}finally{$e=r,Ss.transition=n,Pe=t,!(Pe&6)&&fr()}}function Lm(){os=fa.current,We(fa)}function Lr(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Cb(n)),yt!==null)for(n=yt.return;n!==null;){var r=n;switch(xm(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Po();break;case 3:Ba(),We(ss),We(Kt),km();break;case 5:Sm(r);break;case 4:Ba();break;case 13:We(tt);break;case 19:We(tt);break;case 10:jm(r.type._context);break;case 22:case 23:Lm()}n=n.return}if(Dt=e,yt=e=lr(e.current,null),Tt=os=t,wt=0,Zi=null,Tm=dc=Br=0,es=Pi=null,Nr!==null){for(t=0;t<Nr.length;t++)if(n=Nr[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}Nr=null}return e}function Wy(e,t){do{var n=yt;try{if(vm(),lo.current=zo,Oo){for(var r=st.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}Oo=!1}if(Ur=0,kt=bt=st=null,Ei=!1,Hi=0,Fm.current=null,n===null||n.return===null){wt=1,Zi=t,yt=null;break}e:{var i=e,l=n.return,o=n,c=t;if(t=Tt,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 p=u.alternate;p?(u.updateQueue=p.updateQueue,u.memoizedState=p.memoizedState,u.lanes=p.lanes):(u.updateQueue=null,u.memoizedState=null)}var m=np(l);if(m!==null){m.flags&=-257,rp(m,l,o,i,t),m.mode&1&&sp(i,d,t),t=m,c=d;var f=t.updateQueue;if(f===null){var x=new Set;x.add(c),t.updateQueue=x}else f.add(c);break e}else{if(!(t&1)){sp(i,d,t),Om();break e}c=Error(X(426))}}else if(Xe&&o.mode&1){var j=np(l);if(j!==null){!(j.flags&65536)&&(j.flags|=256),rp(j,l,o,i,t),gm(qa(c,o));break e}}i=c=qa(c,o),wt!==4&&(wt=2),Pi===null?Pi=[i]:Pi.push(i),i=l;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var y=My(i,c,t);Zf(i,y);break e;case 1:o=c;var v=i.type,g=i.stateNode;if(!(i.flags&128)&&(typeof v.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(ar===null||!ar.has(g)))){i.flags|=65536,t&=-t,i.lanes|=t;var w=Fy(i,o,t);Zf(i,w);break e}}i=i.return}while(i!==null)}Jy(n)}catch(C){t=C,yt===n&&n!==null&&(yt=n=n.return);continue}break}while(!0)}function Gy(){var e=$o.current;return $o.current=zo,e===null?zo:e}function Om(){(wt===0||wt===3||wt===2)&&(wt=4),Dt===null||!(Br&268435455)&&!(dc&268435455)||zn(Dt,Tt)}function Uo(e,t){var n=Pe;Pe|=2;var r=Gy();(Dt!==e||Tt!==t)&&(mn=null,Lr(e,t));do try{Jb();break}catch(a){Wy(e,a)}while(!0);if(vm(),Pe=n,$o.current=r,yt!==null)throw Error(X(261));return Dt=null,Tt=0,wt}function Jb(){for(;yt!==null;)Zy(yt)}function Xb(){for(;yt!==null&&!wj();)Zy(yt)}function Zy(e){var t=Yy(e.alternate,e,os);e.memoizedProps=e.pendingProps,t===null?Jy(e):yt=t,Fm.current=null}function Jy(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=Vb(n,t),n!==null){n.flags&=32767,yt=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{wt=6,yt=null;return}}else if(n=qb(n,t,os),n!==null){yt=n;return}if(t=t.sibling,t!==null){yt=t;return}yt=t=e}while(t!==null);wt===0&&(wt=5)}function vr(e,t,n){var r=$e,a=Ss.transition;try{Ss.transition=null,$e=1,Yb(e,t,n,r)}finally{Ss.transition=a,$e=r}return null}function Yb(e,t,n,r){do ba();while(Xn!==null);if(Pe&6)throw Error(X(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(X(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(Tj(e,i),e===Dt&&(yt=Dt=null,Tt=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Gl||(Gl=!0,e0(wo,function(){return ba(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=Ss.transition,Ss.transition=null;var l=$e;$e=1;var o=Pe;Pe|=4,Fm.current=null,Hb(e,n),Vy(n,e),vb(Kd),ko=!!_d,Kd=_d=null,e.current=n,Wb(n),Sj(),Pe=o,$e=l,Ss.transition=i}else e.current=n;if(Gl&&(Gl=!1,Xn=e,Ko=a),i=e.pendingLanes,i===0&&(ar=null),Ej(n.stateNode),rs(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(_o)throw _o=!1,e=lu,lu=null,e;return Ko&1&&e.tag!==0&&ba(),i=e.pendingLanes,i&1?e===ou?Ai++:(Ai=0,ou=e):Ai=0,fr(),null}function ba(){if(Xn!==null){var e=Mg(Ko),t=Ss.transition,n=$e;try{if(Ss.transition=null,$e=16>e?16:e,Xn===null)var r=!1;else{if(e=Xn,Xn=null,Ko=0,Pe&6)throw Error(X(331));var a=Pe;for(Pe|=4,ue=e.current;ue!==null;){var i=ue,l=i.child;if(ue.flags&16){var o=i.deletions;if(o!==null){for(var c=0;c<o.length;c++){var d=o[c];for(ue=d;ue!==null;){var u=ue;switch(u.tag){case 0:case 11:case 15:Di(8,u,i)}var h=u.child;if(h!==null)h.return=u,ue=h;else for(;ue!==null;){u=ue;var p=u.sibling,m=u.return;if(Uy(u),u===d){ue=null;break}if(p!==null){p.return=m,ue=p;break}ue=m}}}var f=i.alternate;if(f!==null){var x=f.child;if(x!==null){f.child=null;do{var j=x.sibling;x.sibling=null,x=j}while(x!==null)}}ue=i}}if(i.subtreeFlags&2064&&l!==null)l.return=i,ue=l;else e:for(;ue!==null;){if(i=ue,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Di(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,ue=y;break e}ue=i.return}}var v=e.current;for(ue=v;ue!==null;){l=ue;var g=l.child;if(l.subtreeFlags&2064&&g!==null)g.return=l,ue=g;else e:for(l=v;ue!==null;){if(o=ue,o.flags&2048)try{switch(o.tag){case 0:case 11:case 15:cc(9,o)}}catch(C){ut(o,o.return,C)}if(o===l){ue=null;break e}var w=o.sibling;if(w!==null){w.return=o.return,ue=w;break e}ue=o.return}}if(Pe=a,fr(),sn&&typeof sn.onPostCommitFiberRoot=="function")try{sn.onPostCommitFiberRoot(tc,e)}catch{}r=!0}return r}finally{$e=n,Ss.transition=t}}return!1}function gp(e,t,n){t=qa(n,t),t=My(e,t,1),e=rr(e,t,1),t=Qt(),e!==null&&(gl(e,1,t),rs(e,t))}function ut(e,t,n){if(e.tag===3)gp(e,e,n);else for(;t!==null;){if(t.tag===3){gp(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(ar===null||!ar.has(r))){e=qa(n,e),e=Fy(t,e,1),t=rr(t,e,1),e=Qt(),t!==null&&(gl(t,1,e),rs(t,e));break}}t=t.return}}function eN(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Qt(),e.pingedLanes|=e.suspendedLanes&n,Dt===e&&(Tt&n)===n&&(wt===4||wt===3&&(Tt&130023424)===Tt&&500>ft()-Im?Lr(e,0):Tm|=n),rs(e,t)}function Xy(e,t){t===0&&(e.mode&1?(t=$l,$l<<=1,!($l&130023424)&&($l=4194304)):t=1);var n=Qt();e=Cn(e,t),e!==null&&(gl(e,t,n),rs(e,n))}function tN(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Xy(e,n)}function sN(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(X(314))}r!==null&&r.delete(t),Xy(e,n)}var Yy;Yy=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ss.current)ts=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ts=!1,Bb(e,t,n);ts=!!(e.flags&131072)}else ts=!1,Xe&&t.flags&1048576&&ny(t,Fo,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;co(e,t),e=t.pendingProps;var a=_a(t,Kt.current);ja(t,n),a=Em(null,t,r,e,a,n);var i=Dm();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,ns(r)?(i=!0,Ao(t)):i=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Nm(t),a.updater=oc,t.stateNode=a,a._reactInternals=t,Zd(t,r,e,n),t=Yd(null,t,r,!0,i,n)):(t.tag=0,Xe&&i&&pm(t),Vt(null,t,a,n),t=t.child),t;case 16:r=t.elementType;e:{switch(co(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=rN(r),e=Ms(r,e),a){case 0:t=Xd(null,t,r,e,n);break e;case 1:t=lp(null,t,r,e,n);break e;case 11:t=ap(null,t,r,e,n);break e;case 14:t=ip(null,t,r,Ms(r.type,e),n);break e}throw Error(X(306,r,""))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Ms(r,a),Xd(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Ms(r,a),lp(e,t,r,a,n);case 3:e:{if(Ly(t),e===null)throw Error(X(387));r=t.pendingProps,i=t.memoizedState,a=i.element,cy(e,t),Ro(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=qa(Error(X(423)),t),t=op(e,t,r,n,a);break e}else if(r!==a){a=qa(Error(X(424)),t),t=op(e,t,r,n,a);break e}else for(us=nr(t.stateNode.containerInfo.firstChild),ms=t,Xe=!0,Rs=null,n=ly(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ka(),r===a){t=En(e,t,n);break e}Vt(e,t,r,n)}t=t.child}return t;case 5:return dy(t),e===null&&Hd(t),r=t.type,a=t.pendingProps,i=e!==null?e.memoizedProps:null,l=a.children,Ud(r,a)?l=null:i!==null&&Ud(r,i)&&(t.flags|=32),Ry(e,t),Vt(e,t,l,n),t.child;case 6:return e===null&&Hd(t),null;case 13:return Oy(e,t,n);case 4:return wm(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Ua(t,null,r,n):Vt(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Ms(r,a),ap(e,t,r,a,n);case 7:return Vt(e,t,t.pendingProps,n),t.child;case 8:return Vt(e,t,t.pendingProps.children,n),t.child;case 12:return Vt(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,Be(To,r._currentValue),r._currentValue=l,i!==null)if(Ks(i.value,l)){if(i.children===a.children&&!ss.current){t=En(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=Nn(-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),Wd(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(X(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),Wd(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}Vt(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,ja(t,n),a=ks(a),r=r(a),t.flags|=1,Vt(e,t,r,n),t.child;case 14:return r=t.type,a=Ms(r,t.pendingProps),a=Ms(r.type,a),ip(e,t,r,a,n);case 15:return Ty(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Ms(r,a),co(e,t),t.tag=1,ns(r)?(e=!0,Ao(t)):e=!1,ja(t,n),Ay(t,r,a),Zd(t,r,a,n),Yd(null,t,r,!0,e,n);case 19:return zy(e,t,n);case 22:return Iy(e,t,n)}throw Error(X(156,t.tag))};function e0(e,t){return Eg(e,t)}function nN(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 Ns(e,t,n,r){return new nN(e,t,n,r)}function zm(e){return e=e.prototype,!(!e||!e.isReactComponent)}function rN(e){if(typeof e=="function")return zm(e)?1:0;if(e!=null){if(e=e.$$typeof,e===nm)return 11;if(e===rm)return 14}return 2}function lr(e,t){var n=e.alternate;return n===null?(n=Ns(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 ho(e,t,n,r,a,i){var l=2;if(r=e,typeof e=="function")zm(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case ra:return Or(n.children,a,i,t);case sm:l=8,a|=8;break;case jd:return e=Ns(12,n,t,a|2),e.elementType=jd,e.lanes=i,e;case bd:return e=Ns(13,n,t,a),e.elementType=bd,e.lanes=i,e;case Nd:return e=Ns(19,n,t,a),e.elementType=Nd,e.lanes=i,e;case dg:return uc(n,a,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case og:l=10;break e;case cg:l=9;break e;case nm:l=11;break e;case rm:l=14;break e;case Rn:l=16,r=null;break e}throw Error(X(130,e==null?e:typeof e,""))}return t=Ns(l,n,t,a),t.elementType=e,t.type=r,t.lanes=i,t}function Or(e,t,n,r){return e=Ns(7,e,r,t),e.lanes=n,e}function uc(e,t,n,r){return e=Ns(22,e,r,t),e.elementType=dg,e.lanes=n,e.stateNode={isHidden:!1},e}function ad(e,t,n){return e=Ns(6,e,null,t),e.lanes=n,e}function id(e,t,n){return t=Ns(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function aN(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=_c(0),this.expirationTimes=_c(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=_c(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function $m(e,t,n,r,a,i,l,o,c){return e=new aN(e,t,n,o,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Ns(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Nm(i),e}function iN(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:na,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function t0(e){if(!e)return ur;e=e._reactInternals;e:{if(Zr(e)!==e||e.tag!==1)throw Error(X(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(ns(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(X(171))}if(e.tag===1){var n=e.type;if(ns(n))return ty(e,n,t)}return t}function s0(e,t,n,r,a,i,l,o,c){return e=$m(n,r,!0,e,a,i,l,o,c),e.context=t0(null),n=e.current,r=Qt(),a=ir(n),i=Nn(r,a),i.callback=t??null,rr(n,i,a),e.current.lanes=a,gl(e,a,r),rs(e,r),e}function mc(e,t,n,r){var a=t.current,i=Qt(),l=ir(a);return n=t0(n),t.context===null?t.context=n:t.pendingContext=n,t=Nn(i,l),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=rr(a,t,l),e!==null&&(_s(e,a,l,i),io(e,a,l)),l}function Bo(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 yp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function _m(e,t){yp(e,t),(e=e.alternate)&&yp(e,t)}function lN(){return null}var n0=typeof reportError=="function"?reportError:function(e){console.error(e)};function Km(e){this._internalRoot=e}hc.prototype.render=Km.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(X(409));mc(e,t,null,null)};hc.prototype.unmount=Km.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;qr(function(){mc(null,e,null,null)}),t[kn]=null}};function hc(e){this._internalRoot=e}hc.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ig();e={blockedOn:null,target:e,priority:t};for(var n=0;n<On.length&&t!==0&&t<On[n].priority;n++);On.splice(n,0,e),n===0&&Lg(e)}};function Um(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function fc(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function vp(){}function oN(e,t,n,r,a){if(a){if(typeof r=="function"){var i=r;r=function(){var d=Bo(l);i.call(d)}}var l=s0(t,r,e,0,null,!1,!1,"",vp);return e._reactRootContainer=l,e[kn]=l.current,Ui(e.nodeType===8?e.parentNode:e),qr(),l}for(;a=e.lastChild;)e.removeChild(a);if(typeof r=="function"){var o=r;r=function(){var d=Bo(c);o.call(d)}}var c=$m(e,0,!1,null,null,!1,!1,"",vp);return e._reactRootContainer=c,e[kn]=c.current,Ui(e.nodeType===8?e.parentNode:e),qr(function(){mc(t,c,n,r)}),c}function pc(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=Bo(l);o.call(c)}}mc(t,l,e,a)}else l=oN(n,t,e,a,r);return Bo(l)}Fg=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=yi(t.pendingLanes);n!==0&&(lm(t,n|1),rs(t,ft()),!(Pe&6)&&(Va=ft()+500,fr()))}break;case 13:qr(function(){var r=Cn(e,1);if(r!==null){var a=Qt();_s(r,e,1,a)}}),_m(e,1)}};om=function(e){if(e.tag===13){var t=Cn(e,134217728);if(t!==null){var n=Qt();_s(t,e,134217728,n)}_m(e,134217728)}};Tg=function(e){if(e.tag===13){var t=ir(e),n=Cn(e,t);if(n!==null){var r=Qt();_s(n,e,t,r)}_m(e,t)}};Ig=function(){return $e};Rg=function(e,t){var n=$e;try{return $e=e,t()}finally{$e=n}};Fd=function(e,t,n){switch(t){case"input":if(kd(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=ac(r);if(!a)throw Error(X(90));mg(r),kd(r,a)}}}break;case"textarea":fg(e,n);break;case"select":t=n.value,t!=null&&xa(e,!!n.multiple,t,!1)}};bg=Rm;Ng=qr;var cN={usingClientEntryPoint:!1,Events:[vl,oa,ac,vg,jg,Rm]},hi={findFiberByHostInstance:br,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},dN={bundleType:hi.bundleType,version:hi.version,rendererPackageName:hi.rendererPackageName,rendererConfig:hi.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:An.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=kg(e),e===null?null:e.stateNode},findFiberByHostInstance:hi.findFiberByHostInstance||lN,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 Zl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Zl.isDisabled&&Zl.supportsFiber)try{tc=Zl.inject(dN),sn=Zl}catch{}}fs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=cN;fs.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Um(t))throw Error(X(200));return iN(e,t,null,n)};fs.createRoot=function(e,t){if(!Um(e))throw Error(X(299));var n=!1,r="",a=n0;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=$m(e,1,!1,null,null,n,!1,r,a),e[kn]=t.current,Ui(e.nodeType===8?e.parentNode:e),new Km(t)};fs.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(X(188)):(e=Object.keys(e).join(","),Error(X(268,e)));return e=kg(t),e=e===null?null:e.stateNode,e};fs.flushSync=function(e){return qr(e)};fs.hydrate=function(e,t,n){if(!fc(t))throw Error(X(200));return pc(null,e,t,!0,n)};fs.hydrateRoot=function(e,t,n){if(!Um(e))throw Error(X(405));var r=n!=null&&n.hydratedSources||null,a=!1,i="",l=n0;if(n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(l=n.onRecoverableError)),t=s0(t,null,e,1,n??null,a,!1,i,l),e[kn]=t.current,Ui(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 hc(t)};fs.render=function(e,t,n){if(!fc(t))throw Error(X(200));return pc(null,e,t,!1,n)};fs.unmountComponentAtNode=function(e){if(!fc(e))throw Error(X(40));return e._reactRootContainer?(qr(function(){pc(null,null,e,!1,function(){e._reactRootContainer=null,e[kn]=null})}),!0):!1};fs.unstable_batchedUpdates=Rm;fs.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!fc(n))throw Error(X(200));if(e==null||e._reactInternals===void 0)throw Error(X(38));return pc(e,t,n,!1,r)};fs.version="18.3.1-next-f1338f8080-20240426";function r0(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r0)}catch(e){console.error(e)}}r0(),rg.exports=fs;var uN=rg.exports,jp=uN;yd.createRoot=jp.createRoot,yd.hydrateRoot=jp.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 Ji(){return Ji=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},Ji.apply(this,arguments)}var Yn;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(Yn||(Yn={}));const bp="popstate";function mN(e){e===void 0&&(e={});function t(r,a){let{pathname:i,search:l,hash:o}=r.location;return uu("",{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:qo(a)}return fN(t,n,null,e)}function nt(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Bm(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function hN(){return Math.random().toString(36).substr(2,8)}function Np(e,t){return{usr:e.state,key:e.key,idx:t}}function uu(e,t,n,r){return n===void 0&&(n=null),Ji({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?Ya(t):t,{state:n,key:t&&t.key||r||hN()})}function qo(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 Ya(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 fN(e,t,n,r){r===void 0&&(r={});let{window:a=document.defaultView,v5Compat:i=!1}=r,l=a.history,o=Yn.Pop,c=null,d=u();d==null&&(d=0,l.replaceState(Ji({},l.state,{idx:d}),""));function u(){return(l.state||{idx:null}).idx}function h(){o=Yn.Pop;let j=u(),y=j==null?null:j-d;d=j,c&&c({action:o,location:x.location,delta:y})}function p(j,y){o=Yn.Push;let v=uu(x.location,j,y);d=u()+1;let g=Np(v,d),w=x.createHref(v);try{l.pushState(g,"",w)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;a.location.assign(w)}i&&c&&c({action:o,location:x.location,delta:1})}function m(j,y){o=Yn.Replace;let v=uu(x.location,j,y);d=u();let g=Np(v,d),w=x.createHref(v);l.replaceState(g,"",w),i&&c&&c({action:o,location:x.location,delta:0})}function f(j){let y=a.location.origin!=="null"?a.location.origin:a.location.href,v=typeof j=="string"?j:qo(j);return v=v.replace(/ $/,"%20"),nt(y,"No window.location.(origin|href) available to create URL for href: "+v),new URL(v,y)}let x={get action(){return o},get location(){return e(a,l)},listen(j){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(bp,h),c=j,()=>{a.removeEventListener(bp,h),c=null}},createHref(j){return t(a,j)},createURL:f,encodeLocation(j){let y=f(j);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:p,replace:m,go(j){return l.go(j)}};return x}var wp;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(wp||(wp={}));function pN(e,t,n){return n===void 0&&(n="/"),xN(e,t,n)}function xN(e,t,n,r){let a=typeof t=="string"?Ya(t):t,i=Qa(a.pathname||"/",n);if(i==null)return null;let l=a0(e);gN(l);let o=null;for(let c=0;o==null&&c<l.length;++c){let d=DN(i);o=CN(l[c],d)}return o}function a0(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("/")&&(nt(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=or([r,c.relativePath]),u=n.concat(c);i.children&&i.children.length>0&&(nt(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),a0(i.children,t,u,d)),!(i.path==null&&!i.index)&&t.push({path:d,score:SN(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 i0(i.path))a(i,l,c)}),t}function i0(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=i0(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 gN(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:kN(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const yN=/^:[\w-]+$/,vN=3,jN=2,bN=1,NN=10,wN=-2,Sp=e=>e==="*";function SN(e,t){let n=e.split("/"),r=n.length;return n.some(Sp)&&(r+=wN),t&&(r+=jN),n.filter(a=>!Sp(a)).reduce((a,i)=>a+(yN.test(i)?vN:i===""?bN:NN),r)}function kN(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 CN(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=mu({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},u),p=c.route;if(!h)return null;Object.assign(a,h.params),l.push({params:a,pathname:or([i,h.pathname]),pathnameBase:TN(or([i,h.pathnameBase])),route:p}),h.pathnameBase!=="/"&&(i=or([i,h.pathnameBase]))}return l}function mu(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=EN(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:p,isOptional:m}=u;if(p==="*"){let x=o[h]||"";l=i.slice(0,i.length-x.length).replace(/(.)\/+$/,"$1")}const f=o[h];return m&&!f?d[p]=void 0:d[p]=(f||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:l,pattern:e}}function EN(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),Bm(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 DN(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Bm(!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 Qa(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 PN=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,AN=e=>PN.test(e);function MN(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?Ya(e):e,i;if(n)if(AN(n))i=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),Bm(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?i=kp(n.substring(1),"/"):i=kp(n,t)}else i=t;return{pathname:i,search:IN(r),hash:RN(a)}}function kp(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 ld(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 FN(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function qm(e,t){let n=FN(e);return t?n.map((r,a)=>a===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Vm(e,t,n,r){r===void 0&&(r=!1);let a;typeof e=="string"?a=Ya(e):(a=Ji({},e),nt(!a.pathname||!a.pathname.includes("?"),ld("?","pathname","search",a)),nt(!a.pathname||!a.pathname.includes("#"),ld("#","pathname","hash",a)),nt(!a.search||!a.search.includes("#"),ld("#","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 p=l.split("/");for(;p[0]==="..";)p.shift(),h-=1;a.pathname=p.join("/")}o=h>=0?t[h]:"/"}let c=MN(a,o),d=l&&l!=="/"&&l.endsWith("/"),u=(i||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||u)&&(c.pathname+="/"),c}const or=e=>e.join("/").replace(/\/\/+/g,"/"),TN=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),IN=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,RN=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function LN(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const l0=["post","put","patch","delete"];new Set(l0);const ON=["get",...l0];new Set(ON);/**
* 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 Xi(){return Xi=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},Xi.apply(this,arguments)}const xc=b.createContext(null),o0=b.createContext(null),Mn=b.createContext(null),gc=b.createContext(null),an=b.createContext({outlet:null,matches:[],isDataRoute:!1}),c0=b.createContext(null);function zN(e,t){let{relative:n}=t===void 0?{}:t;ei()||nt(!1);let{basename:r,navigator:a}=b.useContext(Mn),{hash:i,pathname:l,search:o}=vc(e,{relative:n}),c=l;return r!=="/"&&(c=l==="/"?r:or([r,l])),a.createHref({pathname:c,search:o,hash:i})}function ei(){return b.useContext(gc)!=null}function Fn(){return ei()||nt(!1),b.useContext(gc).location}function d0(e){b.useContext(Mn).static||b.useLayoutEffect(e)}function Gt(){let{isDataRoute:e}=b.useContext(an);return e?YN():$N()}function $N(){ei()||nt(!1);let e=b.useContext(xc),{basename:t,future:n,navigator:r}=b.useContext(Mn),{matches:a}=b.useContext(an),{pathname:i}=Fn(),l=JSON.stringify(qm(a,n.v7_relativeSplatPath)),o=b.useRef(!1);return d0(()=>{o.current=!0}),b.useCallback(function(d,u){if(u===void 0&&(u={}),!o.current)return;if(typeof d=="number"){r.go(d);return}let h=Vm(d,JSON.parse(l),i,u.relative==="path");e==null&&t!=="/"&&(h.pathname=h.pathname==="/"?t:or([t,h.pathname])),(u.replace?r.replace:r.push)(h,u.state,u)},[t,r,l,i,e])}const _N=b.createContext(null);function KN(e){let t=b.useContext(an).outlet;return t&&b.createElement(_N.Provider,{value:e},t)}function yc(){let{matches:e}=b.useContext(an),t=e[e.length-1];return t?t.params:{}}function vc(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=b.useContext(Mn),{matches:a}=b.useContext(an),{pathname:i}=Fn(),l=JSON.stringify(qm(a,r.v7_relativeSplatPath));return b.useMemo(()=>Vm(e,JSON.parse(l),i,n==="path"),[e,l,i,n])}function UN(e,t){return BN(e,t)}function BN(e,t,n,r){ei()||nt(!1);let{navigator:a}=b.useContext(Mn),{matches:i}=b.useContext(an),l=i[i.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let d=Fn(),u;if(t){var h;let j=typeof t=="string"?Ya(t):t;c==="/"||(h=j.pathname)!=null&&h.startsWith(c)||nt(!1),u=j}else u=d;let p=u.pathname||"/",m=p;if(c!=="/"){let j=c.replace(/^\//,"").split("/");m="/"+p.replace(/^\//,"").split("/").slice(j.length).join("/")}let f=pN(e,{pathname:m}),x=WN(f&&f.map(j=>Object.assign({},j,{params:Object.assign({},o,j.params),pathname:or([c,a.encodeLocation?a.encodeLocation(j.pathname).pathname:j.pathname]),pathnameBase:j.pathnameBase==="/"?c:or([c,a.encodeLocation?a.encodeLocation(j.pathnameBase).pathname:j.pathnameBase])})),i,n,r);return t&&x?b.createElement(gc.Provider,{value:{location:Xi({pathname:"/",search:"",hash:"",state:null,key:"default"},u),navigationType:Yn.Pop}},x):x}function qN(){let e=XN(),t=LN(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 b.createElement(b.Fragment,null,b.createElement("h2",null,"Unexpected Application Error!"),b.createElement("h3",{style:{fontStyle:"italic"}},t),n?b.createElement("pre",{style:a},n):null,null)}const VN=b.createElement(qN,null);class QN extends b.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?b.createElement(an.Provider,{value:this.props.routeContext},b.createElement(c0.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function HN(e){let{routeContext:t,match:n,children:r}=e,a=b.useContext(xc);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),b.createElement(an.Provider,{value:t},r)}function WN(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||nt(!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:p,errors:m}=n,f=h.route.loader&&p[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,p)=>{let m,f=!1,x=null,j=null;n&&(m=o&&h.route.id?o[h.route.id]:void 0,x=h.route.errorElement||VN,c&&(d<0&&p===0?(ew("route-fallback"),f=!0,j=null):d===p&&(f=!0,j=h.route.hydrateFallbackElement||null)));let y=t.concat(l.slice(0,p+1)),v=()=>{let g;return m?g=x:f?g=j:h.route.Component?g=b.createElement(h.route.Component,null):h.route.element?g=h.route.element:g=u,b.createElement(HN,{match:h,routeContext:{outlet:u,matches:y,isDataRoute:n!=null},children:g})};return n&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?b.createElement(QN,{location:n.location,revalidation:n.revalidation,component:x,error:m,children:v(),routeContext:{outlet:null,matches:y,isDataRoute:!0}}):v()},null)}var u0=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(u0||{}),m0=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}(m0||{});function GN(e){let t=b.useContext(xc);return t||nt(!1),t}function ZN(e){let t=b.useContext(o0);return t||nt(!1),t}function JN(e){let t=b.useContext(an);return t||nt(!1),t}function h0(e){let t=JN(),n=t.matches[t.matches.length-1];return n.route.id||nt(!1),n.route.id}function XN(){var e;let t=b.useContext(c0),n=ZN(),r=h0();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function YN(){let{router:e}=GN(u0.UseNavigateStable),t=h0(m0.UseNavigateStable),n=b.useRef(!1);return d0(()=>{n.current=!0}),b.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?e.navigate(a):e.navigate(a,Xi({fromRouteId:t},i)))},[e,t])}const Cp={};function ew(e,t,n){Cp[e]||(Cp[e]=!0)}function tw(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function pa(e){let{to:t,replace:n,state:r,relative:a}=e;ei()||nt(!1);let{future:i,static:l}=b.useContext(Mn),{matches:o}=b.useContext(an),{pathname:c}=Fn(),d=Gt(),u=Vm(t,qm(o,i.v7_relativeSplatPath),c,a==="path"),h=JSON.stringify(u);return b.useEffect(()=>d(JSON.parse(h),{replace:n,state:r,relative:a}),[d,h,a,n,r]),null}function sw(e){return KN(e.context)}function Le(e){nt(!1)}function nw(e){let{basename:t="/",children:n=null,location:r,navigationType:a=Yn.Pop,navigator:i,static:l=!1,future:o}=e;ei()&&nt(!1);let c=t.replace(/^\/*/,"/"),d=b.useMemo(()=>({basename:c,navigator:i,static:l,future:Xi({v7_relativeSplatPath:!1},o)}),[c,o,i,l]);typeof r=="string"&&(r=Ya(r));let{pathname:u="/",search:h="",hash:p="",state:m=null,key:f="default"}=r,x=b.useMemo(()=>{let j=Qa(u,c);return j==null?null:{location:{pathname:j,search:h,hash:p,state:m,key:f},navigationType:a}},[c,u,h,p,m,f,a]);return x==null?null:b.createElement(Mn.Provider,{value:d},b.createElement(gc.Provider,{children:n,value:x}))}function rw(e){let{children:t,location:n}=e;return UN(hu(t),n)}new Promise(()=>{});function hu(e,t){t===void 0&&(t=[]);let n=[];return b.Children.forEach(e,(r,a)=>{if(!b.isValidElement(r))return;let i=[...t,a];if(r.type===b.Fragment){n.push.apply(n,hu(r.props.children,i));return}r.type!==Le&&nt(!1),!r.props.index||!r.props.children||nt(!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=hu(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 Vo(){return Vo=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},Vo.apply(this,arguments)}function f0(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 aw(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function iw(e,t){return e.button===0&&(!t||t==="_self")&&!aw(e)}function fu(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 lw(e,t){let n=fu(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(i=>{n.append(a,i)})}),n}const ow=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],cw=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],dw="6";try{window.__reactRouterVersion=dw}catch{}const uw=b.createContext({isTransitioning:!1}),mw="startTransition",Ep=ej[mw];function hw(e){let{basename:t,children:n,future:r,window:a}=e,i=b.useRef();i.current==null&&(i.current=mN({window:a,v5Compat:!0}));let l=i.current,[o,c]=b.useState({action:l.action,location:l.location}),{v7_startTransition:d}=r||{},u=b.useCallback(h=>{d&&Ep?Ep(()=>c(h)):c(h)},[c,d]);return b.useLayoutEffect(()=>l.listen(u),[l,u]),b.useEffect(()=>tw(r),[r]),b.createElement(nw,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const fw=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",pw=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Se=b.forwardRef(function(t,n){let{onClick:r,relative:a,reloadDocument:i,replace:l,state:o,target:c,to:d,preventScrollReset:u,viewTransition:h}=t,p=f0(t,ow),{basename:m}=b.useContext(Mn),f,x=!1;if(typeof d=="string"&&pw.test(d)&&(f=d,fw))try{let g=new URL(window.location.href),w=d.startsWith("//")?new URL(g.protocol+d):new URL(d),C=Qa(w.pathname,m);w.origin===g.origin&&C!=null?d=C+w.search+w.hash:x=!0}catch{}let j=zN(d,{relative:a}),y=gw(d,{replace:l,state:o,target:c,preventScrollReset:u,relative:a,viewTransition:h});function v(g){r&&r(g),g.defaultPrevented||y(g)}return b.createElement("a",Vo({},p,{href:f||j,onClick:x||i?r:v,ref:n,target:c}))}),od=b.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=f0(t,cw),p=vc(c,{relative:h.relative}),m=Fn(),f=b.useContext(o0),{navigator:x,basename:j}=b.useContext(Mn),y=f!=null&&yw(p)&&d===!0,v=x.encodeLocation?x.encodeLocation(p).pathname:p.pathname,g=m.pathname,w=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;a||(g=g.toLowerCase(),w=w?w.toLowerCase():null,v=v.toLowerCase()),w&&j&&(w=Qa(w,j)||w);const C=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let k=g===v||!l&&g.startsWith(v)&&g.charAt(C)==="/",F=w!=null&&(w===v||!l&&w.startsWith(v)&&w.charAt(v.length)==="/"),N={isActive:k,isPending:F,isTransitioning:y},E=k?r:void 0,P;typeof i=="function"?P=i(N):P=[i,k?"active":null,F?"pending":null,y?"transitioning":null].filter(Boolean).join(" ");let z=typeof o=="function"?o(N):o;return b.createElement(Se,Vo({},h,{"aria-current":E,className:P,ref:n,style:z,to:c,viewTransition:d}),typeof u=="function"?u(N):u)});var pu;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(pu||(pu={}));var Dp;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Dp||(Dp={}));function xw(e){let t=b.useContext(xc);return t||nt(!1),t}function gw(e,t){let{target:n,replace:r,state:a,preventScrollReset:i,relative:l,viewTransition:o}=t===void 0?{}:t,c=Gt(),d=Fn(),u=vc(e,{relative:l});return b.useCallback(h=>{if(iw(h,n)){h.preventDefault();let p=r!==void 0?r:qo(d)===qo(u);c(e,{replace:p,state:a,preventScrollReset:i,relative:l,viewTransition:o})}},[d,c,u,r,a,n,e,i,l,o])}function jc(e){let t=b.useRef(fu(e)),n=b.useRef(!1),r=Fn(),a=b.useMemo(()=>lw(r.search,n.current?null:t.current),[r.search]),i=Gt(),l=b.useCallback((o,c)=>{const d=fu(typeof o=="function"?o(a):o);n.current=!0,i("?"+d,c)},[i,a]);return[a,l]}function yw(e,t){t===void 0&&(t={});let n=b.useContext(uw);n==null&&nt(!1);let{basename:r}=xw(pu.useViewTransitionState),a=vc(e,{relative:t.relative});if(!n.isTransitioning)return!1;let i=Qa(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Qa(n.nextLocation.pathname,r)||n.nextLocation.pathname;return mu(a.pathname,l)!=null||mu(a.pathname,i)!=null}var Jr=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(){}},vw={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Kn,Wu,Rx,jw=(Rx=class{constructor(){de(this,Kn,vw);de(this,Wu,!1)}setTimeoutProvider(e){se(this,Kn,e)}setTimeout(e,t){return M(this,Kn).setTimeout(e,t)}clearTimeout(e){M(this,Kn).clearTimeout(e)}setInterval(e,t){return M(this,Kn).setInterval(e,t)}clearInterval(e){M(this,Kn).clearInterval(e)}},Kn=new WeakMap,Wu=new WeakMap,Rx),Sr=new jw;function bw(e){setTimeout(e,0)}var Vr=typeof window>"u"||"Deno"in globalThis;function zt(){}function Nw(e,t){return typeof e=="function"?e(t):e}function xu(e){return typeof e=="number"&&e>=0&&e!==1/0}function p0(e,t){return Math.max(e+(t||0)-Date.now(),0)}function cr(e,t){return typeof e=="function"?e(t):e}function vs(e,t){return typeof e=="function"?e(t):e}function Pp(e,t){const{type:n="all",exact:r,fetchStatus:a,predicate:i,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==Qm(l,t.options))return!1}else if(!Yi(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 Ap(e,t){const{exact:n,status:r,predicate:a,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Qr(t.options.mutationKey)!==Qr(i))return!1}else if(!Yi(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||a&&!a(t))}function Qm(e,t){return((t==null?void 0:t.queryKeyHashFn)||Qr)(e)}function Qr(e){return JSON.stringify(e,(t,n)=>gu(n)?Object.keys(n).sort().reduce((r,a)=>(r[a]=n[a],r),{}):n)}function Yi(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Yi(e[n],t[n])):!1}var ww=Object.prototype.hasOwnProperty;function Hm(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=Mp(e)&&Mp(t);if(!r&&!(gu(e)&&gu(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],p=e[h],m=t[h];if(p===m){c[h]=p,(r?u<i:ww.call(e,h))&&d++;continue}if(p===null||m===null||typeof p!="object"||typeof m!="object"){c[h]=m;continue}const f=Hm(p,m,n+1);c[h]=f,f===p&&d++}return i===o&&d===i?e:c}function el(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 Mp(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function gu(e){if(!Fp(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!Fp(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Fp(e){return Object.prototype.toString.call(e)==="[object Object]"}function Sw(e){return new Promise(t=>{Sr.setTimeout(t,e)})}function yu(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Hm(e,t):t}function kw(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Cw(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Wm=Symbol();function x0(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Wm?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Gm(e,t){return typeof e=="function"?e(...t):!!e}function Ew(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 Er,Un,Sa,Lx,Dw=(Lx=class extends Jr{constructor(){super();de(this,Er);de(this,Un);de(this,Sa);se(this,Sa,t=>{if(!Vr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){M(this,Un)||this.setEventListener(M(this,Sa))}onUnsubscribe(){var t;this.hasListeners()||((t=M(this,Un))==null||t.call(this),se(this,Un,void 0))}setEventListener(t){var n;se(this,Sa,t),(n=M(this,Un))==null||n.call(this),se(this,Un,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){M(this,Er)!==t&&(se(this,Er,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof M(this,Er)=="boolean"?M(this,Er):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Er=new WeakMap,Un=new WeakMap,Sa=new WeakMap,Lx),Zm=new Dw;function vu(){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 Pw=bw;function Aw(){let e=[],t=0,n=o=>{o()},r=o=>{o()},a=Pw;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=Aw(),ka,Bn,Ca,Ox,Mw=(Ox=class extends Jr{constructor(){super();de(this,ka,!0);de(this,Bn);de(this,Ca);se(this,Ca,t=>{if(!Vr&&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,Bn)||this.setEventListener(M(this,Ca))}onUnsubscribe(){var t;this.hasListeners()||((t=M(this,Bn))==null||t.call(this),se(this,Bn,void 0))}setEventListener(t){var n;se(this,Ca,t),(n=M(this,Bn))==null||n.call(this),se(this,Bn,t(this.setOnline.bind(this)))}setOnline(t){M(this,ka)!==t&&(se(this,ka,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return M(this,ka)}},ka=new WeakMap,Bn=new WeakMap,Ca=new WeakMap,Ox),Qo=new Mw;function Fw(e){return Math.min(1e3*2**e,3e4)}function g0(e){return(e??"online")==="online"?Qo.isOnline():!0}var ju=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function y0(e){let t=!1,n=0,r;const a=vu(),i=()=>a.status!=="pending",l=x=>{var j;if(!i()){const y=new ju(x);p(y),(j=e.onCancel)==null||j.call(e,y)}},o=()=>{t=!0},c=()=>{t=!1},d=()=>Zm.isFocused()&&(e.networkMode==="always"||Qo.isOnline())&&e.canRun(),u=()=>g0(e.networkMode)&&e.canRun(),h=x=>{i()||(r==null||r(),a.resolve(x))},p=x=>{i()||(r==null||r(),a.reject(x))},m=()=>new Promise(x=>{var j;r=y=>{(i()||d())&&x(y)},(j=e.onPause)==null||j.call(e)}).then(()=>{var x;r=void 0,i()||(x=e.onContinue)==null||x.call(e)}),f=()=>{if(i())return;let x;const j=n===0?e.initialPromise:void 0;try{x=j??e.fn()}catch(y){x=Promise.reject(y)}Promise.resolve(x).then(h).catch(y=>{var k;if(i())return;const v=e.retry??(Vr?0:3),g=e.retryDelay??Fw,w=typeof g=="function"?g(n,y):g,C=v===!0||typeof v=="number"&&n<v||typeof v=="function"&&v(n,y);if(t||!C){p(y);return}n++,(k=e.onFail)==null||k.call(e,n,y),Sw(w).then(()=>d()?void 0:m()).then(()=>{t?p(y):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 Dr,zx,v0=(zx=class{constructor(){de(this,Dr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),xu(this.gcTime)&&se(this,Dr,Sr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Vr?1/0:5*60*1e3))}clearGcTimeout(){M(this,Dr)&&(Sr.clearTimeout(M(this,Dr)),se(this,Dr,void 0))}},Dr=new WeakMap,zx),Pr,Ea,gs,Ar,St,ll,Mr,Fs,un,$x,Tw=($x=class extends v0{constructor(t){super();de(this,Fs);de(this,Pr);de(this,Ea);de(this,gs);de(this,Ar);de(this,St);de(this,ll);de(this,Mr);se(this,Mr,!1),se(this,ll,t.defaultOptions),this.setOptions(t.options),this.observers=[],se(this,Ar,t.client),se(this,gs,M(this,Ar).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,se(this,Pr,Ip(this.options)),this.state=t.state??M(this,Pr),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=M(this,St))==null?void 0:t.promise}setOptions(t){if(this.options={...M(this,ll),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=Ip(this.options);n.data!==void 0&&(this.setState(Tp(n.data,n.dataUpdatedAt)),se(this,Pr,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&M(this,gs).remove(this)}setData(t,n){const r=yu(this.state.data,t,this.options);return ve(this,Fs,un).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){ve(this,Fs,un).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,a;const n=(r=M(this,St))==null?void 0:r.promise;return(a=M(this,St))==null||a.cancel(t),n?n.then(zt).catch(zt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(M(this,Pr))}isActive(){return this.observers.some(t=>vs(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Wm||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>cr(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:!p0(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=M(this,St))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=M(this,St))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),M(this,gs).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,St)&&(M(this,Mr)?M(this,St).cancel({revert:!0}):M(this,St).cancelRetry()),this.scheduleGc()),M(this,gs).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ve(this,Fs,un).call(this,{type:"invalidate"})}async fetch(t,n){var c,d,u,h,p,m,f,x,j,y,v,g;if(this.state.fetchStatus!=="idle"&&((c=M(this,St))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(M(this,St))return M(this,St).continueRetry(),M(this,St).promise}if(t&&this.setOptions(t),!this.options.queryFn){const w=this.observers.find(C=>C.options.queryFn);w&&this.setOptions(w.options)}const r=new AbortController,a=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(se(this,Mr,!0),r.signal)})},i=()=>{const w=x0(this.options,n),k=(()=>{const F={client:M(this,Ar),queryKey:this.queryKey,meta:this.meta};return a(F),F})();return se(this,Mr,!1),this.options.persister?this.options.persister(w,k,this):w(k)},o=(()=>{const w={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:M(this,Ar),state:this.state,fetchFn:i};return a(w),w})();(d=this.options.behavior)==null||d.onFetch(o,this),se(this,Ea,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=o.fetchOptions)==null?void 0:u.meta))&&ve(this,Fs,un).call(this,{type:"fetch",meta:(h=o.fetchOptions)==null?void 0:h.meta}),se(this,St,y0({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:w=>{w instanceof ju&&w.revert&&this.setState({...M(this,Ea),fetchStatus:"idle"}),r.abort()},onFail:(w,C)=>{ve(this,Fs,un).call(this,{type:"failed",failureCount:w,error:C})},onPause:()=>{ve(this,Fs,un).call(this,{type:"pause"})},onContinue:()=>{ve(this,Fs,un).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const w=await M(this,St).start();if(w===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(w),(m=(p=M(this,gs).config).onSuccess)==null||m.call(p,w,this),(x=(f=M(this,gs).config).onSettled)==null||x.call(f,w,this.state.error,this),w}catch(w){if(w instanceof ju){if(w.silent)return M(this,St).promise;if(w.revert){if(this.state.data===void 0)throw w;return this.state.data}}throw ve(this,Fs,un).call(this,{type:"error",error:w}),(y=(j=M(this,gs).config).onError)==null||y.call(j,w,this),(g=(v=M(this,gs).config).onSettled)==null||g.call(v,this.state.data,w,this),w}finally{this.scheduleGc()}}},Pr=new WeakMap,Ea=new WeakMap,gs=new WeakMap,Ar=new WeakMap,St=new WeakMap,ll=new WeakMap,Mr=new WeakMap,Fs=new WeakSet,un=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,...j0(r.data,this.options),fetchMeta:t.meta??null};case"success":const a={...r,...Tp(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return se(this,Ea,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,gs).notify({query:this,type:"updated",action:t})})},$x);function j0(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:g0(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Tp(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Ip(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 Jt,Ee,ol,Ut,Fr,Da,pn,qn,cl,Pa,Aa,Tr,Ir,Vn,Ma,Oe,ji,bu,Nu,wu,Su,ku,Cu,Eu,b0,_x,Jm=(_x=class extends Jr{constructor(t,n){super();de(this,Oe);de(this,Jt);de(this,Ee);de(this,ol);de(this,Ut);de(this,Fr);de(this,Da);de(this,pn);de(this,qn);de(this,cl);de(this,Pa);de(this,Aa);de(this,Tr);de(this,Ir);de(this,Vn);de(this,Ma,new Set);this.options=n,se(this,Jt,t),se(this,qn,null),se(this,pn,vu()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(M(this,Ee).addObserver(this),Rp(M(this,Ee),this.options)?ve(this,Oe,ji).call(this):this.updateResult(),ve(this,Oe,Su).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Du(M(this,Ee),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Du(M(this,Ee),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ve(this,Oe,ku).call(this),ve(this,Oe,Cu).call(this),M(this,Ee).removeObserver(this)}setOptions(t){const n=this.options,r=M(this,Ee);if(this.options=M(this,Jt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof vs(this.options.enabled,M(this,Ee))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ve(this,Oe,Eu).call(this),M(this,Ee).setOptions(this.options),n._defaulted&&!el(this.options,n)&&M(this,Jt).getQueryCache().notify({type:"observerOptionsUpdated",query:M(this,Ee),observer:this});const a=this.hasListeners();a&&Lp(M(this,Ee),r,this.options,n)&&ve(this,Oe,ji).call(this),this.updateResult(),a&&(M(this,Ee)!==r||vs(this.options.enabled,M(this,Ee))!==vs(n.enabled,M(this,Ee))||cr(this.options.staleTime,M(this,Ee))!==cr(n.staleTime,M(this,Ee)))&&ve(this,Oe,bu).call(this);const i=ve(this,Oe,Nu).call(this);a&&(M(this,Ee)!==r||vs(this.options.enabled,M(this,Ee))!==vs(n.enabled,M(this,Ee))||i!==M(this,Vn))&&ve(this,Oe,wu).call(this,i)}getOptimisticResult(t){const n=M(this,Jt).getQueryCache().build(M(this,Jt),t),r=this.createResult(n,t);return Rw(this,r)&&(se(this,Ut,r),se(this,Da,this.options),se(this,Fr,M(this,Ee).state)),r}getCurrentResult(){return M(this,Ut)}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,pn).status==="pending"&&M(this,pn).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,a))})}trackProp(t){M(this,Ma).add(t)}getCurrentQuery(){return M(this,Ee)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=M(this,Jt).defaultQueryOptions(t),r=M(this,Jt).getQueryCache().build(M(this,Jt),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return ve(this,Oe,ji).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),M(this,Ut)))}createResult(t,n){var E;const r=M(this,Ee),a=this.options,i=M(this,Ut),l=M(this,Fr),o=M(this,Da),d=t!==r?t.state:M(this,ol),{state:u}=t;let h={...u},p=!1,m;if(n._optimisticResults){const P=this.hasListeners(),z=!P&&Rp(t,n),D=P&&Lp(t,r,n,a);(z||D)&&(h={...h,...j0(u.data,t.options)}),n._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:f,errorUpdatedAt:x,status:j}=h;m=h.data;let y=!1;if(n.placeholderData!==void 0&&m===void 0&&j==="pending"){let P;i!=null&&i.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(P=i.data,y=!0):P=typeof n.placeholderData=="function"?n.placeholderData((E=M(this,Aa))==null?void 0:E.state.data,M(this,Aa)):n.placeholderData,P!==void 0&&(j="success",m=yu(i==null?void 0:i.data,P,n),p=!0)}if(n.select&&m!==void 0&&!y)if(i&&m===(l==null?void 0:l.data)&&n.select===M(this,cl))m=M(this,Pa);else try{se(this,cl,n.select),m=n.select(m),m=yu(i==null?void 0:i.data,m,n),se(this,Pa,m),se(this,qn,null)}catch(P){se(this,qn,P)}M(this,qn)&&(f=M(this,qn),m=M(this,Pa),x=Date.now(),j="error");const v=h.fetchStatus==="fetching",g=j==="pending",w=j==="error",C=g&&v,k=m!==void 0,N={status:j,fetchStatus:h.fetchStatus,isPending:g,isSuccess:j==="success",isError:w,isInitialLoading:C,isLoading:C,data:m,dataUpdatedAt:h.dataUpdatedAt,error:f,errorUpdatedAt:x,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:v,isRefetching:v&&!g,isLoadingError:w&&!k,isPaused:h.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:w&&k,isStale:Xm(t,n),refetch:this.refetch,promise:M(this,pn),isEnabled:vs(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const P=N.data!==void 0,z=N.status==="error"&&!P,D=L=>{z?L.reject(N.error):P&&L.resolve(N.data)},_=()=>{const L=se(this,pn,N.promise=vu());D(L)},$=M(this,pn);switch($.status){case"pending":t.queryHash===r.queryHash&&D($);break;case"fulfilled":(z||N.data!==$.value)&&_();break;case"rejected":(!z||N.error!==$.reason)&&_();break}}return N}updateResult(){const t=M(this,Ut),n=this.createResult(M(this,Ee),this.options);if(se(this,Fr,M(this,Ee).state),se(this,Da,this.options),M(this,Fr).data!==void 0&&se(this,Aa,M(this,Ee)),el(n,t))return;se(this,Ut,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!M(this,Ma).size)return!0;const l=new Set(i??M(this,Ma));return this.options.throwOnError&&l.add("error"),Object.keys(M(this,Ut)).some(o=>{const c=o;return M(this,Ut)[c]!==t[c]&&l.has(c)})};ve(this,Oe,b0).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ve(this,Oe,Su).call(this)}},Jt=new WeakMap,Ee=new WeakMap,ol=new WeakMap,Ut=new WeakMap,Fr=new WeakMap,Da=new WeakMap,pn=new WeakMap,qn=new WeakMap,cl=new WeakMap,Pa=new WeakMap,Aa=new WeakMap,Tr=new WeakMap,Ir=new WeakMap,Vn=new WeakMap,Ma=new WeakMap,Oe=new WeakSet,ji=function(t){ve(this,Oe,Eu).call(this);let n=M(this,Ee).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(zt)),n},bu=function(){ve(this,Oe,ku).call(this);const t=cr(this.options.staleTime,M(this,Ee));if(Vr||M(this,Ut).isStale||!xu(t))return;const r=p0(M(this,Ut).dataUpdatedAt,t)+1;se(this,Tr,Sr.setTimeout(()=>{M(this,Ut).isStale||this.updateResult()},r))},Nu=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(M(this,Ee)):this.options.refetchInterval)??!1},wu=function(t){ve(this,Oe,Cu).call(this),se(this,Vn,t),!(Vr||vs(this.options.enabled,M(this,Ee))===!1||!xu(M(this,Vn))||M(this,Vn)===0)&&se(this,Ir,Sr.setInterval(()=>{(this.options.refetchIntervalInBackground||Zm.isFocused())&&ve(this,Oe,ji).call(this)},M(this,Vn)))},Su=function(){ve(this,Oe,bu).call(this),ve(this,Oe,wu).call(this,ve(this,Oe,Nu).call(this))},ku=function(){M(this,Tr)&&(Sr.clearTimeout(M(this,Tr)),se(this,Tr,void 0))},Cu=function(){M(this,Ir)&&(Sr.clearInterval(M(this,Ir)),se(this,Ir,void 0))},Eu=function(){const t=M(this,Jt).getQueryCache().build(M(this,Jt),this.options);if(t===M(this,Ee))return;const n=M(this,Ee);se(this,Ee,t),se(this,ol,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},b0=function(t){ht.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(M(this,Ut))}),M(this,Jt).getQueryCache().notify({query:M(this,Ee),type:"observerResultsUpdated"})})},_x);function Iw(e,t){return vs(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Rp(e,t){return Iw(e,t)||e.state.data!==void 0&&Du(e,t,t.refetchOnMount)}function Du(e,t,n){if(vs(t.enabled,e)!==!1&&cr(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Xm(e,t)}return!1}function Lp(e,t,n,r){return(e!==t||vs(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Xm(e,n)}function Xm(e,t){return vs(t.enabled,e)!==!1&&e.isStaleByTime(cr(t.staleTime,e))}function Rw(e,t){return!el(e.getCurrentResult(),t)}function Op(e){return{onFetch:(t,n)=>{var u,h,p,m,f;const r=t.options,a=(p=(h=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:h.fetchMore)==null?void 0:p.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 x=!1;const j=g=>{Ew(g,()=>t.signal,()=>x=!0)},y=x0(t.options,t.fetchOptions),v=async(g,w,C)=>{if(x)return Promise.reject();if(w==null&&g.pages.length)return Promise.resolve(g);const F=(()=>{const z={client:t.client,queryKey:t.queryKey,pageParam:w,direction:C?"backward":"forward",meta:t.options.meta};return j(z),z})(),N=await y(F),{maxPages:E}=t.options,P=C?Cw:kw;return{pages:P(g.pages,N,E),pageParams:P(g.pageParams,w,E)}};if(a&&i.length){const g=a==="backward",w=g?Lw:zp,C={pages:i,pageParams:l},k=w(r,C);o=await v(C,k,g)}else{const g=e??i.length;do{const w=c===0?l[0]??r.initialPageParam:zp(r,o);if(c>0&&w==null)break;o=await v(o,w),c++}while(c<g)}return o};t.options.persister?t.fetchFn=()=>{var x,j;return(j=(x=t.options).persister)==null?void 0:j.call(x,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=d}}}function zp(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 Lw(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 dl,Zs,Bt,Rr,Js,In,Kx,Ow=(Kx=class extends v0{constructor(t){super();de(this,Js);de(this,dl);de(this,Zs);de(this,Bt);de(this,Rr);se(this,dl,t.client),this.mutationId=t.mutationId,se(this,Bt,t.mutationCache),se(this,Zs,[]),this.state=t.state||N0(),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,Zs).includes(t)||(M(this,Zs).push(t),this.clearGcTimeout(),M(this,Bt).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){se(this,Zs,M(this,Zs).filter(n=>n!==t)),this.scheduleGc(),M(this,Bt).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){M(this,Zs).length||(this.state.status==="pending"?this.scheduleGc():M(this,Bt).remove(this))}continue(){var t;return((t=M(this,Rr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,d,u,h,p,m,f,x,j,y,v,g,w,C,k,F,N,E;const n=()=>{ve(this,Js,In).call(this,{type:"continue"})},r={client:M(this,dl),meta:this.options.meta,mutationKey:this.options.mutationKey};se(this,Rr,y0({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(P,z)=>{ve(this,Js,In).call(this,{type:"failed",failureCount:P,error:z})},onPause:()=>{ve(this,Js,In).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>M(this,Bt).canRun(this)}));const a=this.state.status==="pending",i=!M(this,Rr).canStart();try{if(a)n();else{ve(this,Js,In).call(this,{type:"pending",variables:t,isPaused:i}),await((o=(l=M(this,Bt).config).onMutate)==null?void 0:o.call(l,t,this,r));const z=await((d=(c=this.options).onMutate)==null?void 0:d.call(c,t,r));z!==this.state.context&&ve(this,Js,In).call(this,{type:"pending",context:z,variables:t,isPaused:i})}const P=await M(this,Rr).start();return await((h=(u=M(this,Bt).config).onSuccess)==null?void 0:h.call(u,P,t,this.state.context,this,r)),await((m=(p=this.options).onSuccess)==null?void 0:m.call(p,P,t,this.state.context,r)),await((x=(f=M(this,Bt).config).onSettled)==null?void 0:x.call(f,P,null,this.state.variables,this.state.context,this,r)),await((y=(j=this.options).onSettled)==null?void 0:y.call(j,P,null,t,this.state.context,r)),ve(this,Js,In).call(this,{type:"success",data:P}),P}catch(P){try{await((g=(v=M(this,Bt).config).onError)==null?void 0:g.call(v,P,t,this.state.context,this,r))}catch(z){Promise.reject(z)}try{await((C=(w=this.options).onError)==null?void 0:C.call(w,P,t,this.state.context,r))}catch(z){Promise.reject(z)}try{await((F=(k=M(this,Bt).config).onSettled)==null?void 0:F.call(k,void 0,P,this.state.variables,this.state.context,this,r))}catch(z){Promise.reject(z)}try{await((E=(N=this.options).onSettled)==null?void 0:E.call(N,void 0,P,t,this.state.context,r))}catch(z){Promise.reject(z)}throw ve(this,Js,In).call(this,{type:"error",error:P}),P}finally{M(this,Bt).runNext(this)}}},dl=new WeakMap,Zs=new WeakMap,Bt=new WeakMap,Rr=new WeakMap,Js=new WeakSet,In=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,Zs).forEach(r=>{r.onMutationUpdate(t)}),M(this,Bt).notify({mutation:this,type:"updated",action:t})})},Kx);function N0(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var xn,Ts,ul,Ux,zw=(Ux=class extends Jr{constructor(t={}){super();de(this,xn);de(this,Ts);de(this,ul);this.config=t,se(this,xn,new Set),se(this,Ts,new Map),se(this,ul,0)}build(t,n,r){const a=new Ow({client:t,mutationCache:this,mutationId:++Tl(this,ul)._,options:t.defaultMutationOptions(n),state:r});return this.add(a),a}add(t){M(this,xn).add(t);const n=Jl(t);if(typeof n=="string"){const r=M(this,Ts).get(n);r?r.push(t):M(this,Ts).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(M(this,xn).delete(t)){const n=Jl(t);if(typeof n=="string"){const r=M(this,Ts).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,Ts).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Jl(t);if(typeof n=="string"){const r=M(this,Ts).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=Jl(t);if(typeof n=="string"){const a=(r=M(this,Ts).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,xn).forEach(t=>{this.notify({type:"removed",mutation:t})}),M(this,xn).clear(),M(this,Ts).clear()})}getAll(){return Array.from(M(this,xn))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Ap(n,r))}findAll(t={}){return this.getAll().filter(n=>Ap(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(zt))))}},xn=new WeakMap,Ts=new WeakMap,ul=new WeakMap,Ux);function Jl(e){var t;return(t=e.options.scope)==null?void 0:t.id}var gn,Qn,Xt,yn,wn,fo,Pu,Bx,$w=(Bx=class extends Jr{constructor(n,r){super();de(this,wn);de(this,gn);de(this,Qn);de(this,Xt);de(this,yn);se(this,gn,n),this.setOptions(r),this.bindMethods(),ve(this,wn,fo).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,gn).defaultMutationOptions(n),el(this.options,r)||M(this,gn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:M(this,Xt),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Qr(r.mutationKey)!==Qr(this.options.mutationKey)?this.reset():((a=M(this,Xt))==null?void 0:a.state.status)==="pending"&&M(this,Xt).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=M(this,Xt))==null||n.removeObserver(this)}onMutationUpdate(n){ve(this,wn,fo).call(this),ve(this,wn,Pu).call(this,n)}getCurrentResult(){return M(this,Qn)}reset(){var n;(n=M(this,Xt))==null||n.removeObserver(this),se(this,Xt,void 0),ve(this,wn,fo).call(this),ve(this,wn,Pu).call(this)}mutate(n,r){var a;return se(this,yn,r),(a=M(this,Xt))==null||a.removeObserver(this),se(this,Xt,M(this,gn).getMutationCache().build(M(this,gn),this.options)),M(this,Xt).addObserver(this),M(this,Xt).execute(n)}},gn=new WeakMap,Qn=new WeakMap,Xt=new WeakMap,yn=new WeakMap,wn=new WeakSet,fo=function(){var r;const n=((r=M(this,Xt))==null?void 0:r.state)??N0();se(this,Qn,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Pu=function(n){ht.batch(()=>{var r,a,i,l,o,c,d,u;if(M(this,yn)&&this.hasListeners()){const h=M(this,Qn).variables,p=M(this,Qn).context,m={client:M(this,gn),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(a=(r=M(this,yn)).onSuccess)==null||a.call(r,n.data,h,p,m)}catch(f){Promise.reject(f)}try{(l=(i=M(this,yn)).onSettled)==null||l.call(i,n.data,null,h,p,m)}catch(f){Promise.reject(f)}}else if((n==null?void 0:n.type)==="error"){try{(c=(o=M(this,yn)).onError)==null||c.call(o,n.error,h,p,m)}catch(f){Promise.reject(f)}try{(u=(d=M(this,yn)).onSettled)==null||u.call(d,void 0,n.error,h,p,m)}catch(f){Promise.reject(f)}}}this.listeners.forEach(h=>{h(M(this,Qn))})})},Bx);function $p(e,t){const n=new Set(t);return e.filter(r=>!n.has(r))}function _w(e,t,n){const r=e.slice(0);return r[t]=n,r}var Fa,ls,Ta,Ia,ys,Hn,ml,hl,fl,pl,Rt,Au,Mu,Fu,Tu,Iu,qx,Kw=(qx=class extends Jr{constructor(t,n,r){super();de(this,Rt);de(this,Fa);de(this,ls);de(this,Ta);de(this,Ia);de(this,ys);de(this,Hn);de(this,ml);de(this,hl);de(this,fl);de(this,pl,[]);se(this,Fa,t),se(this,Ia,r),se(this,Ta,[]),se(this,ys,[]),se(this,ls,[]),this.setQueries(n)}onSubscribe(){this.listeners.size===1&&M(this,ys).forEach(t=>{t.subscribe(n=>{ve(this,Rt,Tu).call(this,t,n)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,M(this,ys).forEach(t=>{t.destroy()})}setQueries(t,n){se(this,Ta,t),se(this,Ia,n),ht.batch(()=>{const r=M(this,ys),a=ve(this,Rt,Fu).call(this,M(this,Ta));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,p)=>h!==r[p]),d=o||c,u=d?!0:l.some((h,p)=>{const m=M(this,ls)[p];return!m||!el(h,m)});!d&&!u||(d&&(se(this,pl,a),se(this,ys,i)),se(this,ls,l),this.hasListeners()&&(d&&($p(r,i).forEach(h=>{h.destroy()}),$p(i,r).forEach(h=>{h.subscribe(p=>{ve(this,Rt,Tu).call(this,h,p)})})),ve(this,Rt,Iu).call(this)))})}getCurrentResult(){return M(this,ls)}getQueries(){return M(this,ys).map(t=>t.getCurrentQuery())}getObservers(){return M(this,ys)}getOptimisticResult(t,n){const r=ve(this,Rt,Fu).call(this,t),a=r.map(l=>l.observer.getOptimisticResult(l.defaultedQueryOptions)),i=r.map(l=>l.defaultedQueryOptions.queryHash);return[a,l=>ve(this,Rt,Mu).call(this,l??a,n,i),()=>ve(this,Rt,Au).call(this,a,r)]}},Fa=new WeakMap,ls=new WeakMap,Ta=new WeakMap,Ia=new WeakMap,ys=new WeakMap,Hn=new WeakMap,ml=new WeakMap,hl=new WeakMap,fl=new WeakMap,pl=new WeakMap,Rt=new WeakSet,Au=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)})})})},Mu=function(t,n,r){if(n){const a=M(this,fl),i=r!==void 0&&a!==void 0&&(a.length!==r.length||r.some((l,o)=>l!==a[o]));return(!M(this,Hn)||M(this,ls)!==M(this,hl)||i||n!==M(this,ml))&&(se(this,ml,n),se(this,hl,M(this,ls)),r!==void 0&&se(this,fl,r),se(this,Hn,Hm(M(this,Hn),n(t)))),M(this,Hn)}return t},Fu=function(t){const n=new Map;M(this,ys).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,Fa).defaultQueryOptions(a),o=((c=n.get(i.queryHash))==null?void 0:c.shift())??new Jm(M(this,Fa),i);r.push({defaultedQueryOptions:i,observer:o})}),r},Tu=function(t,n){const r=M(this,ys).indexOf(t);r!==-1&&(se(this,ls,_w(M(this,ls),r,n)),ve(this,Rt,Iu).call(this))},Iu=function(){var t;if(this.hasListeners()){const n=M(this,Hn),r=ve(this,Rt,Au).call(this,M(this,ls),M(this,pl)),a=ve(this,Rt,Mu).call(this,r,(t=M(this,Ia))==null?void 0:t.combine);n!==a&&ht.batch(()=>{this.listeners.forEach(i=>{i(M(this,ls))})})}},qx),Xs,Vx,Uw=(Vx=class extends Jr{constructor(t={}){super();de(this,Xs);this.config=t,se(this,Xs,new Map)}build(t,n,r){const a=n.queryKey,i=n.queryHash??Qm(a,n);let l=this.get(i);return l||(l=new Tw({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(a)}),this.add(l)),l}add(t){M(this,Xs).has(t.queryHash)||(M(this,Xs).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=M(this,Xs).get(t.queryHash);n&&(t.destroy(),n===t&&M(this,Xs).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ht.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return M(this,Xs).get(t)}getAll(){return[...M(this,Xs).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Pp(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>Pp(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()})})}},Xs=new WeakMap,Vx),ct,Wn,Gn,Ra,La,Zn,Oa,za,Qx,Bw=(Qx=class{constructor(e={}){de(this,ct);de(this,Wn);de(this,Gn);de(this,Ra);de(this,La);de(this,Zn);de(this,Oa);de(this,za);se(this,ct,e.queryCache||new Uw),se(this,Wn,e.mutationCache||new zw),se(this,Gn,e.defaultOptions||{}),se(this,Ra,new Map),se(this,La,new Map),se(this,Zn,0)}mount(){Tl(this,Zn)._++,M(this,Zn)===1&&(se(this,Oa,Zm.subscribe(async e=>{e&&(await this.resumePausedMutations(),M(this,ct).onFocus())})),se(this,za,Qo.subscribe(async e=>{e&&(await this.resumePausedMutations(),M(this,ct).onOnline())})))}unmount(){var e,t;Tl(this,Zn)._--,M(this,Zn)===0&&((e=M(this,Oa))==null||e.call(this),se(this,Oa,void 0),(t=M(this,za))==null||t.call(this),se(this,za,void 0))}isFetching(e){return M(this,ct).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return M(this,Wn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=M(this,ct).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=M(this,ct).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(cr(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return M(this,ct).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,ct).get(r.queryHash),i=a==null?void 0:a.state.data,l=Nw(t,i);if(l!==void 0)return M(this,ct).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return ht.batch(()=>M(this,ct).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,ct).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=M(this,ct);ht.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=M(this,ct);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,ct).findAll(e).map(a=>a.cancel(n)));return Promise.all(r).then(zt).catch(zt)}invalidateQueries(e,t={}){return ht.batch(()=>(M(this,ct).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,ct).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,n);return n.throwOnError||(i=i.catch(zt)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(zt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=M(this,ct).build(this,t);return n.isStaleByTime(cr(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(zt).catch(zt)}fetchInfiniteQuery(e){return e.behavior=Op(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(zt).catch(zt)}ensureInfiniteQueryData(e){return e.behavior=Op(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Qo.isOnline()?M(this,Wn).resumePausedMutations():Promise.resolve()}getQueryCache(){return M(this,ct)}getMutationCache(){return M(this,Wn)}getDefaultOptions(){return M(this,Gn)}setDefaultOptions(e){se(this,Gn,e)}setQueryDefaults(e,t){M(this,Ra).set(Qr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...M(this,Ra).values()],n={};return t.forEach(r=>{Yi(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){M(this,La).set(Qr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...M(this,La).values()],n={};return t.forEach(r=>{Yi(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...M(this,Gn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Qm(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===Wm&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...M(this,Gn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){M(this,ct).clear(),M(this,Wn).clear()}},ct=new WeakMap,Wn=new WeakMap,Gn=new WeakMap,Ra=new WeakMap,La=new WeakMap,Zn=new WeakMap,Oa=new WeakMap,za=new WeakMap,Qx),w0=b.createContext(void 0),xe=e=>{const t=b.useContext(w0);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},qw=({client:e,children:t})=>(b.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(w0.Provider,{value:e,children:t})),S0=b.createContext(!1),k0=()=>b.useContext(S0);S0.Provider;function Vw(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Qw=b.createContext(Vw()),C0=()=>b.useContext(Qw),E0=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Gm(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},D0=e=>{b.useEffect(()=>{e.clearReset()},[e])},P0=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(a&&e.data===void 0||Gm(n,[e.error,r])),A0=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))}},M0=(e,t)=>e.isLoading&&e.isFetching&&!t,Ru=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Ho=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Hw({queries:e,...t},n){const r=xe(),a=k0(),i=C0(),l=b.useMemo(()=>e.map(x=>{const j=r.defaultQueryOptions(x);return j._optimisticResults=a?"isRestoring":"optimistic",j}),[e,r,a]);l.forEach(x=>{A0(x);const j=r.getQueryCache().get(x.queryHash);E0(x,i,j)}),D0(i);const[o]=b.useState(()=>new Kw(r,l,t)),[c,d,u]=o.getOptimisticResult(l,t.combine),h=!a&&t.subscribed!==!1;b.useSyncExternalStore(b.useCallback(x=>h?o.subscribe(ht.batchCalls(x)):zt,[o,h]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),b.useEffect(()=>{o.setQueries(l,t)},[l,t,o]);const m=c.some((x,j)=>Ru(l[j],x))?c.flatMap((x,j)=>{const y=l[j];if(y){const v=new Jm(r,y);if(Ru(y,x))return Ho(y,v,i);M0(x,a)&&Ho(y,v,i)}return[]}):[];if(m.length>0)throw Promise.all(m);const f=c.find((x,j)=>{const y=l[j];return y&&P0({result:x,errorResetBoundary:i,throwOnError:y.throwOnError,query:r.getQueryCache().get(y.queryHash),suspense:y.suspense})});if(f!=null&&f.error)throw f.error;return d(u())}function Ww(e,t,n){var p,m,f,x;const r=k0(),a=C0(),i=xe(),l=i.defaultQueryOptions(e);(m=(p=i.getDefaultOptions().queries)==null?void 0:p._experimental_beforeQuery)==null||m.call(p,l);const o=i.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",A0(l),E0(l,a,o),D0(a);const c=!i.getQueryCache().get(l.queryHash),[d]=b.useState(()=>new t(i,l)),u=d.getOptimisticResult(l),h=!r&&e.subscribed!==!1;if(b.useSyncExternalStore(b.useCallback(j=>{const y=h?d.subscribe(ht.batchCalls(j)):zt;return d.updateResult(),y},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),b.useEffect(()=>{d.setOptions(l)},[l,d]),Ru(l,u))throw Ho(l,d,a);if(P0({result:u,errorResetBoundary:a,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw u.error;if((x=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_afterQuery)==null||x.call(f,l,u),l.experimental_prefetchInRender&&!Vr&&M0(u,r)){const j=c?Ho(l,d,a):o==null?void 0:o.promise;j==null||j.catch(zt).finally(()=>{d.updateResult()})}return l.notifyOnChangeProps?u:d.trackResult(u)}function me(e,t){return Ww(e,Jm)}function G(e,t){const n=xe(),[r]=b.useState(()=>new $w(n,e));b.useEffect(()=>{r.setOptions(e)},[r,e]);const a=b.useSyncExternalStore(b.useCallback(l=>r.subscribe(ht.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=b.useCallback((l,o)=>{r.mutate(l,o).catch(zt)},[r]);if(a.error&&Gm(r.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}let Gw={data:""},Zw=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||Gw},Jw=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,Xw=/\/\*[^]*?\*\/| +/g,_p=/\n+/g,$n=(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"?$n(l,i):i+"{"+$n(l,i[1]=="k"?"":t)+"}":typeof l=="object"?r+=$n(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+=$n.p?$n.p(i,l):i+":"+l+";")}return n+(t&&a?t+"{"+a+"}":a)+r},cn={},F0=e=>{if(typeof e=="object"){let t="";for(let n in e)t+=n+F0(e[n]);return t}return e},Yw=(e,t,n,r,a)=>{let i=F0(e),l=cn[i]||(cn[i]=(c=>{let d=0,u=11;for(;d<c.length;)u=101*u+c.charCodeAt(d++)>>>0;return"go"+u})(i));if(!cn[l]){let c=i!==e?e:(d=>{let u,h,p=[{}];for(;u=Jw.exec(d.replace(Xw,""));)u[4]?p.shift():u[3]?(h=u[3].replace(_p," ").trim(),p.unshift(p[0][h]=p[0][h]||{})):p[0][u[1]]=u[2].replace(_p," ").trim();return p[0]})(e);cn[l]=$n(a?{["@keyframes "+l]:c}:c,n?"":"."+l)}let o=n&&cn.g?cn.g:null;return n&&(cn.g=cn[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)})(cn[l],t,r,o),l},e1=(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?"":$n(o,""):o===!1?"":o}return r+a+(l??"")},"");function bc(e){let t=this||{},n=e.call?e(t.p):e;return Yw(n.unshift?n.raw?e1(n,[].slice.call(arguments,1),t.p):n.reduce((r,a)=>Object.assign(r,a&&a.call?a(t.p):a),{}):n,Zw(t.target),t.g,t.o,t.k)}let T0,Lu,Ou;bc.bind({g:1});let Dn=bc.bind({k:1});function t1(e,t,n,r){$n.p=t,T0=e,Lu=n,Ou=r}function pr(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:Lu&&Lu()},o),n.o=/ *go\d+/.test(c),o.className=bc.apply(n,r)+(c?" "+c:"");let d=e;return e[0]&&(d=o.as||e,delete o.as),Ou&&d[0]&&Ou(o),T0(d,o)}return a}}var s1=e=>typeof e=="function",Wo=(e,t)=>s1(e)?e(t):e,n1=(()=>{let e=0;return()=>(++e).toString()})(),I0=(()=>{let e;return()=>{if(e===void 0&&typeof window<"u"){let t=matchMedia("(prefers-reduced-motion: reduce)");e=!t||t.matches}return e}})(),r1=20,Ym="default",R0=(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 R0(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}))}}},po=[],L0={toasts:[],pausedAt:void 0,settings:{toastLimit:r1}},en={},O0=(e,t=Ym)=>{en[t]=R0(en[t]||L0,e),po.forEach(([n,r])=>{n===t&&r(en[t])})},z0=e=>Object.keys(en).forEach(t=>O0(e,t)),a1=e=>Object.keys(en).find(t=>en[t].toasts.some(n=>n.id===e)),Nc=(e=Ym)=>t=>{O0(t,e)},i1={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},l1=(e={},t=Ym)=>{let[n,r]=b.useState(en[t]||L0),a=b.useRef(en[t]);b.useEffect(()=>(a.current!==en[t]&&r(en[t]),po.push([t,r]),()=>{let l=po.findIndex(([o])=>o===t);l>-1&&po.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)||i1[l.type],style:{...e.style,...(d=e[l.type])==null?void 0:d.style,...l.style}}});return{...n,toasts:i}},o1=(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)||n1()}),bl=e=>(t,n)=>{let r=o1(t,e,n);return Nc(r.toasterId||a1(r.id))({type:2,toast:r}),r.id},Nt=(e,t)=>bl("blank")(e,t);Nt.error=bl("error");Nt.success=bl("success");Nt.loading=bl("loading");Nt.custom=bl("custom");Nt.dismiss=(e,t)=>{let n={type:3,toastId:e};t?Nc(t)(n):z0(n)};Nt.dismissAll=e=>Nt.dismiss(void 0,e);Nt.remove=(e,t)=>{let n={type:4,toastId:e};t?Nc(t)(n):z0(n)};Nt.removeAll=e=>Nt.remove(void 0,e);Nt.promise=(e,t,n)=>{let r=Nt.loading(t.loading,{...n,...n==null?void 0:n.loading});return typeof e=="function"&&(e=e()),e.then(a=>{let i=t.success?Wo(t.success,a):void 0;return i?Nt.success(i,{id:r,...n,...n==null?void 0:n.success}):Nt.dismiss(r),a}).catch(a=>{let i=t.error?Wo(t.error,a):void 0;i?Nt.error(i,{id:r,...n,...n==null?void 0:n.error}):Nt.dismiss(r)}),e};var c1=1e3,d1=(e,t="default")=>{let{toasts:n,pausedAt:r}=l1(e,t),a=b.useRef(new Map).current,i=b.useCallback((h,p=c1)=>{if(a.has(h))return;let m=setTimeout(()=>{a.delete(h),l({type:4,toastId:h})},p);a.set(h,m)},[]);b.useEffect(()=>{if(r)return;let h=Date.now(),p=n.map(m=>{if(m.duration===1/0)return;let f=(m.duration||0)+m.pauseDuration-(h-m.createdAt);if(f<0){m.visible&&Nt.dismiss(m.id);return}return setTimeout(()=>Nt.dismiss(m.id,t),f)});return()=>{p.forEach(m=>m&&clearTimeout(m))}},[n,r,t]);let l=b.useCallback(Nc(t),[t]),o=b.useCallback(()=>{l({type:5,time:Date.now()})},[l]),c=b.useCallback((h,p)=>{l({type:1,toast:{id:h,height:p}})},[l]),d=b.useCallback(()=>{r&&l({type:6,time:Date.now()})},[r,l]),u=b.useCallback((h,p)=>{let{reverseOrder:m=!1,gutter:f=8,defaultPosition:x}=p||{},j=n.filter(g=>(g.position||x)===(h.position||x)&&g.height),y=j.findIndex(g=>g.id===h.id),v=j.filter((g,w)=>w<y&&g.visible).length;return j.filter(g=>g.visible).slice(...m?[v+1]:[0,v]).reduce((g,w)=>g+(w.height||0)+f,0)},[n]);return b.useEffect(()=>{n.forEach(h=>{if(h.dismissed)i(h.id,h.removeDelay);else{let p=a.get(h.id);p&&(clearTimeout(p),a.delete(h.id))}})},[n,i]),{toasts:n,handlers:{updateHeight:c,startPause:o,endPause:d,calculateOffset:u}}},u1=Dn`
from {
transform: scale(0) rotate(45deg);
opacity: 0;
}
to {
transform: scale(1) rotate(45deg);
opacity: 1;
}`,m1=Dn`
from {
transform: scale(0);
opacity: 0;
}
to {
transform: scale(1);
opacity: 1;
}`,h1=Dn`
from {
transform: scale(0) rotate(90deg);
opacity: 0;
}
to {
transform: scale(1) rotate(90deg);
opacity: 1;
}`,f1=pr("div")`
width: 20px;
opacity: 0;
height: 20px;
border-radius: 10px;
background: ${e=>e.primary||"#ff4b4b"};
position: relative;
transform: rotate(45deg);
animation: ${u1} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)
forwards;
animation-delay: 100ms;
&:after,
&:before {
content: '';
animation: ${m1} 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: ${h1} 0.15s ease-out forwards;
animation-delay: 180ms;
transform: rotate(90deg);
}
`,p1=Dn`
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
`,x1=pr("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: ${p1} 1s linear infinite;
`,g1=Dn`
from {
transform: scale(0) rotate(45deg);
opacity: 0;
}
to {
transform: scale(1) rotate(45deg);
opacity: 1;
}`,y1=Dn`
0% {
height: 0;
width: 0;
opacity: 0;
}
40% {
height: 0;
width: 6px;
opacity: 1;
}
100% {
opacity: 1;
height: 10px;
}`,v1=pr("div")`
width: 20px;
opacity: 0;
height: 20px;
border-radius: 10px;
background: ${e=>e.primary||"#61d345"};
position: relative;
transform: rotate(45deg);
animation: ${g1} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)
forwards;
animation-delay: 100ms;
&:after {
content: '';
box-sizing: border-box;
animation: ${y1} 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;
}
`,j1=pr("div")`
position: absolute;
`,b1=pr("div")`
position: relative;
display: flex;
justify-content: center;
align-items: center;
min-width: 20px;
min-height: 20px;
`,N1=Dn`
from {
transform: scale(0.6);
opacity: 0.4;
}
to {
transform: scale(1);
opacity: 1;
}`,w1=pr("div")`
position: relative;
transform: scale(0.6);
opacity: 0.4;
min-width: 20px;
animation: ${N1} 0.3s 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275)
forwards;
`,S1=({toast:e})=>{let{icon:t,type:n,iconTheme:r}=e;return t!==void 0?typeof t=="string"?b.createElement(w1,null,t):t:n==="blank"?null:b.createElement(b1,null,b.createElement(x1,{...r}),n!=="loading"&&b.createElement(j1,null,n==="error"?b.createElement(f1,{...r}):b.createElement(v1,{...r})))},k1=e=>`
0% {transform: translate3d(0,${e*-200}%,0) scale(.6); opacity:.5;}
100% {transform: translate3d(0,0,0) scale(1); opacity:1;}
`,C1=e=>`
0% {transform: translate3d(0,0,-1px) scale(1); opacity:1;}
100% {transform: translate3d(0,${e*-150}%,-1px) scale(.6); opacity:0;}
`,E1="0%{opacity:0;} 100%{opacity:1;}",D1="0%{opacity:1;} 100%{opacity:0;}",P1=pr("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;
`,A1=pr("div")`
display: flex;
justify-content: center;
margin: 4px 10px;
color: inherit;
flex: 1 1 auto;
white-space: pre-line;
`,M1=(e,t)=>{let n=e.includes("top")?1:-1,[r,a]=I0()?[E1,D1]:[k1(n),C1(n)];return{animation:t?`${Dn(r)} 0.35s cubic-bezier(.21,1.02,.73,1) forwards`:`${Dn(a)} 0.4s forwards cubic-bezier(.06,.71,.55,1)`}},F1=b.memo(({toast:e,position:t,style:n,children:r})=>{let a=e.height?M1(e.position||t||"top-center",e.visible):{opacity:0},i=b.createElement(S1,{toast:e}),l=b.createElement(A1,{...e.ariaProps},Wo(e.message,e));return b.createElement(P1,{className:e.className,style:{...a,...n,...e.style}},typeof r=="function"?r({icon:i,message:l}):b.createElement(b.Fragment,null,i,l))});t1(b.createElement);var T1=({id:e,className:t,style:n,onHeightUpdate:r,children:a})=>{let i=b.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 b.createElement("div",{ref:i,className:t,style:n},a)},I1=(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:I0()?void 0:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:`translateY(${t*(n?1:-1)}px)`,...r,...a}},R1=bc`
z-index: 9999;
> * {
pointer-events: auto;
}
`,Xl=16,L1=({reverseOrder:e,position:t="top-center",toastOptions:n,gutter:r,children:a,toasterId:i,containerStyle:l,containerClassName:o})=>{let{toasts:c,handlers:d}=d1(n,i);return b.createElement("div",{"data-rht-toaster":i||"",style:{position:"fixed",zIndex:9999,top:Xl,left:Xl,right:Xl,bottom:Xl,pointerEvents:"none",...l},className:o,onMouseEnter:d.startPause,onMouseLeave:d.endPause},c.map(u=>{let h=u.position||t,p=d.calculateOffset(u,{reverseOrder:e,gutter:r,defaultPosition:t}),m=I1(h,p);return b.createElement(T1,{id:u.id,key:u.id,onHeightUpdate:d.updateHeight,className:u.visible?R1:"",style:m},u.type==="custom"?Wo(u.message,u):a?a(u):b.createElement(F1,{toast:u,position:h}))}))},Ke=Nt;function $0(e,t){return function(){return e.apply(t,arguments)}}const{toString:O1}=Object.prototype,{getPrototypeOf:eh}=Object,{iterator:wc,toStringTag:_0}=Symbol,Sc=(e=>t=>{const n=O1.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),qs=e=>(e=e.toLowerCase(),t=>Sc(t)===e),kc=e=>t=>typeof t===e,{isArray:ti}=Array,Ha=kc("undefined");function Nl(e){return e!==null&&!Ha(e)&&e.constructor!==null&&!Ha(e.constructor)&&as(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const K0=qs("ArrayBuffer");function z1(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&K0(e.buffer),t}const $1=kc("string"),as=kc("function"),U0=kc("number"),wl=e=>e!==null&&typeof e=="object",_1=e=>e===!0||e===!1,xo=e=>{if(Sc(e)!=="object")return!1;const t=eh(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(_0 in e)&&!(wc in e)},K1=e=>{if(!wl(e)||Nl(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},U1=qs("Date"),B1=qs("File"),q1=qs("Blob"),V1=qs("FileList"),Q1=e=>wl(e)&&as(e.pipe),H1=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||as(e.append)&&((t=Sc(e))==="formdata"||t==="object"&&as(e.toString)&&e.toString()==="[object FormData]"))},W1=qs("URLSearchParams"),[G1,Z1,J1,X1]=["ReadableStream","Request","Response","Headers"].map(qs),Y1=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Sl(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,a;if(typeof e!="object"&&(e=[e]),ti(e))for(r=0,a=e.length;r<a;r++)t.call(null,e[r],r,e);else{if(Nl(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 B0(e,t){if(Nl(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 kr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,q0=e=>!Ha(e)&&e!==kr;function zu(){const{caseless:e,skipUndefined:t}=q0(this)&&this||{},n={},r=(a,i)=>{const l=e&&B0(n,i)||i;xo(n[l])&&xo(a)?n[l]=zu(n[l],a):xo(a)?n[l]=zu({},a):ti(a)?n[l]=a.slice():(!t||!Ha(a))&&(n[l]=a)};for(let a=0,i=arguments.length;a<i;a++)arguments[a]&&Sl(arguments[a],r);return n}const eS=(e,t,n,{allOwnKeys:r}={})=>(Sl(t,(a,i)=>{n&&as(a)?e[i]=$0(a,n):e[i]=a},{allOwnKeys:r}),e),tS=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),sS=(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)},nS=(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&&eh(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},rS=(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},aS=e=>{if(!e)return null;if(ti(e))return e;let t=e.length;if(!U0(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},iS=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&eh(Uint8Array)),lS=(e,t)=>{const r=(e&&e[wc]).call(e);let a;for(;(a=r.next())&&!a.done;){const i=a.value;t.call(e,i[0],i[1])}},oS=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},cS=qs("HTMLFormElement"),dS=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,a){return r.toUpperCase()+a}),Kp=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),uS=qs("RegExp"),V0=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Sl(n,(a,i)=>{let l;(l=t(a,i,e))!==!1&&(r[i]=l||a)}),Object.defineProperties(e,r)},mS=e=>{V0(e,(t,n)=>{if(as(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(as(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+"'")})}})},hS=(e,t)=>{const n={},r=a=>{a.forEach(i=>{n[i]=!0})};return ti(e)?r(e):r(String(e).split(t)),n},fS=()=>{},pS=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function xS(e){return!!(e&&as(e.append)&&e[_0]==="FormData"&&e[wc])}const gS=e=>{const t=new Array(10),n=(r,a)=>{if(wl(r)){if(t.indexOf(r)>=0)return;if(Nl(r))return r;if(!("toJSON"in r)){t[a]=r;const i=ti(r)?[]:{};return Sl(r,(l,o)=>{const c=n(l,a+1);!Ha(c)&&(i[o]=c)}),t[a]=void 0,i}}return r};return n(e,0)},yS=qs("AsyncFunction"),vS=e=>e&&(wl(e)||as(e))&&as(e.then)&&as(e.catch),Q0=((e,t)=>e?setImmediate:t?((n,r)=>(kr.addEventListener("message",({source:a,data:i})=>{a===kr&&i===n&&r.length&&r.shift()()},!1),a=>{r.push(a),kr.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",as(kr.postMessage)),jS=typeof queueMicrotask<"u"?queueMicrotask.bind(kr):typeof process<"u"&&process.nextTick||Q0,bS=e=>e!=null&&as(e[wc]),q={isArray:ti,isArrayBuffer:K0,isBuffer:Nl,isFormData:H1,isArrayBufferView:z1,isString:$1,isNumber:U0,isBoolean:_1,isObject:wl,isPlainObject:xo,isEmptyObject:K1,isReadableStream:G1,isRequest:Z1,isResponse:J1,isHeaders:X1,isUndefined:Ha,isDate:U1,isFile:B1,isBlob:q1,isRegExp:uS,isFunction:as,isStream:Q1,isURLSearchParams:W1,isTypedArray:iS,isFileList:V1,forEach:Sl,merge:zu,extend:eS,trim:Y1,stripBOM:tS,inherits:sS,toFlatObject:nS,kindOf:Sc,kindOfTest:qs,endsWith:rS,toArray:aS,forEachEntry:lS,matchAll:oS,isHTMLForm:cS,hasOwnProperty:Kp,hasOwnProp:Kp,reduceDescriptors:V0,freezeMethods:mS,toObjectSet:hS,toCamelCase:dS,noop:fS,toFiniteNumber:pS,findKey:B0,global:kr,isContextDefined:q0,isSpecCompliantForm:xS,toJSONObject:gS,isAsyncFn:yS,isThenable:vS,setImmediate:Q0,asap:jS,isIterable:bS};function we(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)}q.inherits(we,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:q.toJSONObject(this.config),code:this.code,status:this.status}}});const H0=we.prototype,W0={};["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=>{W0[e]={value:e}});Object.defineProperties(we,W0);Object.defineProperty(H0,"isAxiosError",{value:!0});we.from=(e,t,n,r,a,i)=>{const l=Object.create(H0);q.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 we.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 NS=null;function $u(e){return q.isPlainObject(e)||q.isArray(e)}function G0(e){return q.endsWith(e,"[]")?e.slice(0,-2):e}function Up(e,t,n){return e?e.concat(t).map(function(a,i){return a=G0(a),!n&&i?"["+a+"]":a}).join(n?".":""):t}function wS(e){return q.isArray(e)&&!e.some($u)}const SS=q.toFlatObject(q,{},null,function(t){return/^is[A-Z]/.test(t)});function Cc(e,t,n){if(!q.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=q.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,j){return!q.isUndefined(j[x])});const r=n.metaTokens,a=n.visitor||u,i=n.dots,l=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&q.isSpecCompliantForm(t);if(!q.isFunction(a))throw new TypeError("visitor must be a function");function d(f){if(f===null)return"";if(q.isDate(f))return f.toISOString();if(q.isBoolean(f))return f.toString();if(!c&&q.isBlob(f))throw new we("Blob is not supported. Use a Buffer instead.");return q.isArrayBuffer(f)||q.isTypedArray(f)?c&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function u(f,x,j){let y=f;if(f&&!j&&typeof f=="object"){if(q.endsWith(x,"{}"))x=r?x:x.slice(0,-2),f=JSON.stringify(f);else if(q.isArray(f)&&wS(f)||(q.isFileList(f)||q.endsWith(x,"[]"))&&(y=q.toArray(f)))return x=G0(x),y.forEach(function(g,w){!(q.isUndefined(g)||g===null)&&t.append(l===!0?Up([x],w,i):l===null?x:x+"[]",d(g))}),!1}return $u(f)?!0:(t.append(Up(j,x,i),d(f)),!1)}const h=[],p=Object.assign(SS,{defaultVisitor:u,convertValue:d,isVisitable:$u});function m(f,x){if(!q.isUndefined(f)){if(h.indexOf(f)!==-1)throw Error("Circular reference detected in "+x.join("."));h.push(f),q.forEach(f,function(y,v){(!(q.isUndefined(y)||y===null)&&a.call(t,y,q.isString(v)?v.trim():v,x,p))===!0&&m(y,x?x.concat(v):[v])}),h.pop()}}if(!q.isObject(e))throw new TypeError("data must be an object");return m(e),t}function Bp(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function th(e,t){this._pairs=[],e&&Cc(e,this,t)}const Z0=th.prototype;Z0.append=function(t,n){this._pairs.push([t,n])};Z0.toString=function(t){const n=t?function(r){return t.call(this,r,Bp)}:Bp;return this._pairs.map(function(a){return n(a[0])+"="+n(a[1])},"").join("&")};function kS(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function J0(e,t,n){if(!t)return e;const r=n&&n.encode||kS;q.isFunction(n)&&(n={serialize:n});const a=n&&n.serialize;let i;if(a?i=a(t,n):i=q.isURLSearchParams(t)?t.toString():new th(t,n).toString(r),i){const l=e.indexOf("#");l!==-1&&(e=e.slice(0,l)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class qp{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){q.forEach(this.handlers,function(r){r!==null&&t(r)})}}const X0={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},CS=typeof URLSearchParams<"u"?URLSearchParams:th,ES=typeof FormData<"u"?FormData:null,DS=typeof Blob<"u"?Blob:null,PS={isBrowser:!0,classes:{URLSearchParams:CS,FormData:ES,Blob:DS},protocols:["http","https","file","blob","url","data"]},sh=typeof window<"u"&&typeof document<"u",_u=typeof navigator=="object"&&navigator||void 0,AS=sh&&(!_u||["ReactNative","NativeScript","NS"].indexOf(_u.product)<0),MS=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",FS=sh&&window.location.href||"http://localhost",TS=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:sh,hasStandardBrowserEnv:AS,hasStandardBrowserWebWorkerEnv:MS,navigator:_u,origin:FS},Symbol.toStringTag,{value:"Module"})),_t={...TS,...PS};function IS(e,t){return Cc(e,new _t.classes.URLSearchParams,{visitor:function(n,r,a,i){return _t.isNode&&q.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}function RS(e){return q.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function LS(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 Y0(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&&q.isArray(a)?a.length:l,c?(q.hasOwnProp(a,l)?a[l]=[a[l],r]:a[l]=r,!o):((!a[l]||!q.isObject(a[l]))&&(a[l]=[]),t(n,r,a[l],i)&&q.isArray(a[l])&&(a[l]=LS(a[l])),!o)}if(q.isFormData(e)&&q.isFunction(e.entries)){const n={};return q.forEachEntry(e,(r,a)=>{t(RS(r),a,n,0)}),n}return null}function OS(e,t,n){if(q.isString(e))try{return(t||JSON.parse)(e),q.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const kl={transitional:X0,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",a=r.indexOf("application/json")>-1,i=q.isObject(t);if(i&&q.isHTMLForm(t)&&(t=new FormData(t)),q.isFormData(t))return a?JSON.stringify(Y0(t)):t;if(q.isArrayBuffer(t)||q.isBuffer(t)||q.isStream(t)||q.isFile(t)||q.isBlob(t)||q.isReadableStream(t))return t;if(q.isArrayBufferView(t))return t.buffer;if(q.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 IS(t,this.formSerializer).toString();if((o=q.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Cc(o?{"files[]":t}:t,c&&new c,this.formSerializer)}}return i||a?(n.setContentType("application/json",!1),OS(t)):t}],transformResponse:[function(t){const n=this.transitional||kl.transitional,r=n&&n.forcedJSONParsing,a=this.responseType==="json";if(q.isResponse(t)||q.isReadableStream(t))return t;if(t&&q.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"?we.from(o,we.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:_t.classes.FormData,Blob:_t.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};q.forEach(["delete","get","head","post","put","patch"],e=>{kl.headers[e]={}});const zS=q.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"]),$S=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]&&zS[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Vp=Symbol("internals");function fi(e){return e&&String(e).trim().toLowerCase()}function go(e){return e===!1||e==null?e:q.isArray(e)?e.map(go):String(e)}function _S(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 KS=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function cd(e,t,n,r,a){if(q.isFunction(r))return r.call(this,t,n);if(a&&(t=n),!!q.isString(t)){if(q.isString(r))return t.indexOf(r)!==-1;if(q.isRegExp(r))return r.test(t)}}function US(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function BS(e,t){const n=q.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 is=class{constructor(t){t&&this.set(t)}set(t,n,r){const a=this;function i(o,c,d){const u=fi(c);if(!u)throw new Error("header name must be a non-empty string");const h=q.findKey(a,u);(!h||a[h]===void 0||d===!0||d===void 0&&a[h]!==!1)&&(a[h||c]=go(o))}const l=(o,c)=>q.forEach(o,(d,u)=>i(d,u,c));if(q.isPlainObject(t)||t instanceof this.constructor)l(t,n);else if(q.isString(t)&&(t=t.trim())&&!KS(t))l($S(t),n);else if(q.isObject(t)&&q.isIterable(t)){let o={},c,d;for(const u of t){if(!q.isArray(u))throw TypeError("Object iterator must return a key-value pair");o[d=u[0]]=(c=o[d])?q.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=fi(t),t){const r=q.findKey(this,t);if(r){const a=this[r];if(!n)return a;if(n===!0)return _S(a);if(q.isFunction(n))return n.call(this,a,r);if(q.isRegExp(n))return n.exec(a);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=fi(t),t){const r=q.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||cd(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let a=!1;function i(l){if(l=fi(l),l){const o=q.findKey(r,l);o&&(!n||cd(r,r[o],o,n))&&(delete r[o],a=!0)}}return q.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||cd(this,this[i],i,t,!0))&&(delete this[i],a=!0)}return a}normalize(t){const n=this,r={};return q.forEach(this,(a,i)=>{const l=q.findKey(r,i);if(l){n[l]=go(a),delete n[i];return}const o=t?US(i):String(i).trim();o!==i&&delete n[i],n[o]=go(a),r[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return q.forEach(this,(r,a)=>{r!=null&&r!==!1&&(n[a]=t&&q.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[Vp]=this[Vp]={accessors:{}}).accessors,a=this.prototype;function i(l){const o=fi(l);r[o]||(BS(a,l),r[o]=!0)}return q.isArray(t)?t.forEach(i):i(t),this}};is.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);q.reduceDescriptors(is.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});q.freezeMethods(is);function dd(e,t){const n=this||kl,r=t||n,a=is.from(r.headers);let i=r.data;return q.forEach(e,function(o){i=o.call(n,i,a.normalize(),t?t.status:void 0)}),a.normalize(),i}function ev(e){return!!(e&&e.__CANCEL__)}function si(e,t,n){we.call(this,e??"canceled",we.ERR_CANCELED,t,n),this.name="CanceledError"}q.inherits(si,we,{__CANCEL__:!0});function tv(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new we("Request failed with status code "+n.status,[we.ERR_BAD_REQUEST,we.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function qS(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function VS(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,p=0;for(;h!==a;)p+=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(p*1e3/m):void 0}}function QS(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 Go=(e,t,n=3)=>{let r=0;const a=VS(50,250);return QS(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)},Qp=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Hp=e=>(...t)=>q.asap(()=>e(...t)),HS=_t.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,_t.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(_t.origin),_t.navigator&&/(msie|trident)/i.test(_t.navigator.userAgent)):()=>!0,WS=_t.hasStandardBrowserEnv?{write(e,t,n,r,a,i,l){if(typeof document>"u")return;const o=[`${e}=${encodeURIComponent(t)}`];q.isNumber(n)&&o.push(`expires=${new Date(n).toUTCString()}`),q.isString(r)&&o.push(`path=${r}`),q.isString(a)&&o.push(`domain=${a}`),i===!0&&o.push("secure"),q.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 GS(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function ZS(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function sv(e,t,n){let r=!GS(t);return e&&(r||n==!1)?ZS(e,t):t}const Wp=e=>e instanceof is?{...e}:e;function Hr(e,t){t=t||{};const n={};function r(d,u,h,p){return q.isPlainObject(d)&&q.isPlainObject(u)?q.merge.call({caseless:p},d,u):q.isPlainObject(u)?q.merge({},u):q.isArray(u)?u.slice():u}function a(d,u,h,p){if(q.isUndefined(u)){if(!q.isUndefined(d))return r(void 0,d,h,p)}else return r(d,u,h,p)}function i(d,u){if(!q.isUndefined(u))return r(void 0,u)}function l(d,u){if(q.isUndefined(u)){if(!q.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(Wp(d),Wp(u),h,!0)};return q.forEach(Object.keys({...e,...t}),function(u){const h=c[u]||a,p=h(e[u],t[u],u);q.isUndefined(p)&&h!==o||(n[u]=p)}),n}const nv=e=>{const t=Hr({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:a,xsrfCookieName:i,headers:l,auth:o}=t;if(t.headers=l=is.from(l),t.url=J0(sv(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),o&&l.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),q.isFormData(n)){if(_t.hasStandardBrowserEnv||_t.hasStandardBrowserWebWorkerEnv)l.setContentType(void 0);else if(q.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(_t.hasStandardBrowserEnv&&(r&&q.isFunction(r)&&(r=r(t)),r||r!==!1&&HS(t.url))){const c=a&&i&&WS.read(i);c&&l.set(a,c)}return t},JS=typeof XMLHttpRequest<"u",XS=JS&&function(e){return new Promise(function(n,r){const a=nv(e);let i=a.data;const l=is.from(a.headers).normalize();let{responseType:o,onUploadProgress:c,onDownloadProgress:d}=a,u,h,p,m,f;function x(){m&&m(),f&&f(),a.cancelToken&&a.cancelToken.unsubscribe(u),a.signal&&a.signal.removeEventListener("abort",u)}let j=new XMLHttpRequest;j.open(a.method.toUpperCase(),a.url,!0),j.timeout=a.timeout;function y(){if(!j)return;const g=is.from("getAllResponseHeaders"in j&&j.getAllResponseHeaders()),C={data:!o||o==="text"||o==="json"?j.responseText:j.response,status:j.status,statusText:j.statusText,headers:g,config:e,request:j};tv(function(F){n(F),x()},function(F){r(F),x()},C),j=null}"onloadend"in j?j.onloadend=y:j.onreadystatechange=function(){!j||j.readyState!==4||j.status===0&&!(j.responseURL&&j.responseURL.indexOf("file:")===0)||setTimeout(y)},j.onabort=function(){j&&(r(new we("Request aborted",we.ECONNABORTED,e,j)),j=null)},j.onerror=function(w){const C=w&&w.message?w.message:"Network Error",k=new we(C,we.ERR_NETWORK,e,j);k.event=w||null,r(k),j=null},j.ontimeout=function(){let w=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const C=a.transitional||X0;a.timeoutErrorMessage&&(w=a.timeoutErrorMessage),r(new we(w,C.clarifyTimeoutError?we.ETIMEDOUT:we.ECONNABORTED,e,j)),j=null},i===void 0&&l.setContentType(null),"setRequestHeader"in j&&q.forEach(l.toJSON(),function(w,C){j.setRequestHeader(C,w)}),q.isUndefined(a.withCredentials)||(j.withCredentials=!!a.withCredentials),o&&o!=="json"&&(j.responseType=a.responseType),d&&([p,f]=Go(d,!0),j.addEventListener("progress",p)),c&&j.upload&&([h,m]=Go(c),j.upload.addEventListener("progress",h),j.upload.addEventListener("loadend",m)),(a.cancelToken||a.signal)&&(u=g=>{j&&(r(!g||g.type?new si(null,e,j):g),j.abort(),j=null)},a.cancelToken&&a.cancelToken.subscribe(u),a.signal&&(a.signal.aborted?u():a.signal.addEventListener("abort",u)));const v=qS(a.url);if(v&&_t.protocols.indexOf(v)===-1){r(new we("Unsupported protocol "+v+":",we.ERR_BAD_REQUEST,e));return}j.send(i||null)})},YS=(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 we?u:new si(u instanceof Error?u.message:u))}};let l=t&&setTimeout(()=>{l=null,i(new we(`timeout ${t} of ms exceeded`,we.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=()=>q.asap(o),c}},e2=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},t2=async function*(e,t){for await(const n of s2(e))yield*e2(n,t)},s2=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()}},Gp=(e,t,n,r)=>{const a=t2(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 p=i+=h;n(p)}c.enqueue(new Uint8Array(u))}catch(d){throw o(d),d}},cancel(c){return o(c),a.return()}},{highWaterMark:2})},Zp=64*1024,{isFunction:Yl}=q,n2=(({Request:e,Response:t})=>({Request:e,Response:t}))(q.global),{ReadableStream:Jp,TextEncoder:Xp}=q.global,Yp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},r2=e=>{e=q.merge.call({skipUndefined:!0},n2,e);const{fetch:t,Request:n,Response:r}=e,a=t?Yl(t):typeof fetch=="function",i=Yl(n),l=Yl(r);if(!a)return!1;const o=a&&Yl(Jp),c=a&&(typeof Xp=="function"?(f=>x=>f.encode(x))(new Xp):async f=>new Uint8Array(await new n(f).arrayBuffer())),d=i&&o&&Yp(()=>{let f=!1;const x=new n(_t.origin,{body:new Jp,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!x}),u=l&&o&&Yp(()=>q.isReadableStream(new r("").body)),h={stream:u&&(f=>f.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!h[f]&&(h[f]=(x,j)=>{let y=x&&x[f];if(y)return y.call(x);throw new we(`Response type '${f}' is not supported`,we.ERR_NOT_SUPPORT,j)})});const p=async f=>{if(f==null)return 0;if(q.isBlob(f))return f.size;if(q.isSpecCompliantForm(f))return(await new n(_t.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(q.isArrayBufferView(f)||q.isArrayBuffer(f))return f.byteLength;if(q.isURLSearchParams(f)&&(f=f+""),q.isString(f))return(await c(f)).byteLength},m=async(f,x)=>{const j=q.toFiniteNumber(f.getContentLength());return j??p(x)};return async f=>{let{url:x,method:j,data:y,signal:v,cancelToken:g,timeout:w,onDownloadProgress:C,onUploadProgress:k,responseType:F,headers:N,withCredentials:E="same-origin",fetchOptions:P}=nv(f),z=t||fetch;F=F?(F+"").toLowerCase():"text";let D=YS([v,g&&g.toAbortSignal()],w),_=null;const $=D&&D.unsubscribe&&(()=>{D.unsubscribe()});let L;try{if(k&&d&&j!=="get"&&j!=="head"&&(L=await m(N,y))!==0){let S=new n(x,{method:"POST",body:y,duplex:"half"}),oe;if(q.isFormData(y)&&(oe=S.headers.get("content-type"))&&N.setContentType(oe),S.body){const[Ve,Fe]=Qp(L,Go(Hp(k)));y=Gp(S.body,Zp,Ve,Fe)}}q.isString(E)||(E=E?"include":"omit");const A=i&&"credentials"in n.prototype,K={...P,signal:D,method:j.toUpperCase(),headers:N.normalize().toJSON(),body:y,duplex:"half",credentials:A?E:void 0};_=i&&new n(x,K);let B=await(i?z(_,P):z(x,K));const J=u&&(F==="stream"||F==="response");if(u&&(C||J&&$)){const S={};["status","statusText","headers"].forEach(Ye=>{S[Ye]=B[Ye]});const oe=q.toFiniteNumber(B.headers.get("content-length")),[Ve,Fe]=C&&Qp(oe,Go(Hp(C),!0))||[];B=new r(Gp(B.body,Zp,Ve,()=>{Fe&&Fe(),$&&$()}),S)}F=F||"text";let H=await h[q.findKey(h,F)||"text"](B,f);return!J&&$&&$(),await new Promise((S,oe)=>{tv(S,oe,{data:H,headers:is.from(B.headers),status:B.status,statusText:B.statusText,config:f,request:_})})}catch(A){throw $&&$(),A&&A.name==="TypeError"&&/Load failed|fetch/i.test(A.message)?Object.assign(new we("Network Error",we.ERR_NETWORK,f,_),{cause:A.cause||A}):we.from(A,A&&A.code,f,_)}}},a2=new Map,rv=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=a2;for(;o--;)c=i[o],d=u.get(c),d===void 0&&u.set(c,d=o?new Map:r2(t)),u=d;return d};rv();const nh={http:NS,xhr:XS,fetch:{get:rv}};q.forEach(nh,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const ex=e=>`- ${e}`,i2=e=>q.isFunction(e)||e===null||e===!1;function l2(e,t){e=q.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,!i2(r)&&(a=nh[(o=String(r)).toLowerCase()],a===void 0))throw new we(`Unknown adapter '${o}'`);if(a&&(q.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(ex).join(`
`):" "+ex(l[0]):"as no adapter specified";throw new we("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return a}const av={getAdapter:l2,adapters:nh};function ud(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new si(null,e)}function tx(e){return ud(e),e.headers=is.from(e.headers),e.data=dd.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),av.getAdapter(e.adapter||kl.adapter,e)(e).then(function(r){return ud(e),r.data=dd.call(e,e.transformResponse,r),r.headers=is.from(r.headers),r},function(r){return ev(r)||(ud(e),r&&r.response&&(r.response.data=dd.call(e,e.transformResponse,r.response),r.response.headers=is.from(r.response.headers))),Promise.reject(r)})}const iv="1.13.2",Ec={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ec[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const sx={};Ec.transitional=function(t,n,r){function a(i,l){return"[Axios v"+iv+"] Transitional option '"+i+"'"+l+(r?". "+r:"")}return(i,l,o)=>{if(t===!1)throw new we(a(l," has been removed"+(n?" in "+n:"")),we.ERR_DEPRECATED);return n&&!sx[l]&&(sx[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}};Ec.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function o2(e,t,n){if(typeof e!="object")throw new we("options must be an object",we.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 we("option "+i+" must be "+c,we.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new we("Unknown option "+i,we.ERR_BAD_OPTION)}}const yo={assertOptions:o2,validators:Ec},Hs=yo.validators;let zr=class{constructor(t){this.defaults=t||{},this.interceptors={request:new qp,response:new qp}}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=Hr(this.defaults,n);const{transitional:r,paramsSerializer:a,headers:i}=n;r!==void 0&&yo.assertOptions(r,{silentJSONParsing:Hs.transitional(Hs.boolean),forcedJSONParsing:Hs.transitional(Hs.boolean),clarifyTimeoutError:Hs.transitional(Hs.boolean)},!1),a!=null&&(q.isFunction(a)?n.paramsSerializer={serialize:a}:yo.assertOptions(a,{encode:Hs.function,serialize:Hs.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),yo.assertOptions(n,{baseUrl:Hs.spelling("baseURL"),withXsrfToken:Hs.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let l=i&&q.merge(i.common,i[n.method]);i&&q.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),n.headers=is.concat(l,i);const o=[];let c=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(n)===!1||(c=c&&x.synchronous,o.unshift(x.fulfilled,x.rejected))});const d=[];this.interceptors.response.forEach(function(x){d.push(x.fulfilled,x.rejected)});let u,h=0,p;if(!c){const f=[tx.bind(this),void 0];for(f.unshift(...o),f.push(...d),p=f.length,u=Promise.resolve(n);h<p;)u=u.then(f[h++],f[h++]);return u}p=o.length;let m=n;for(;h<p;){const f=o[h++],x=o[h++];try{m=f(m)}catch(j){x.call(this,j);break}}try{u=tx.call(this,m)}catch(f){return Promise.reject(f)}for(h=0,p=d.length;h<p;)u=u.then(d[h++],d[h++]);return u}getUri(t){t=Hr(this.defaults,t);const n=sv(t.baseURL,t.url,t.allowAbsoluteUrls);return J0(n,t.params,t.paramsSerializer)}};q.forEach(["delete","get","head","options"],function(t){zr.prototype[t]=function(n,r){return this.request(Hr(r||{},{method:t,url:n,data:(r||{}).data}))}});q.forEach(["post","put","patch"],function(t){function n(r){return function(i,l,o){return this.request(Hr(o||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:l}))}}zr.prototype[t]=n(),zr.prototype[t+"Form"]=n(!0)});let c2=class lv{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 si(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 lv(function(a){t=a}),cancel:t}}};function d2(e){return function(n){return e.apply(null,n)}}function u2(e){return q.isObject(e)&&e.isAxiosError===!0}const Ku={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(Ku).forEach(([e,t])=>{Ku[t]=e});function ov(e){const t=new zr(e),n=$0(zr.prototype.request,t);return q.extend(n,zr.prototype,t,{allOwnKeys:!0}),q.extend(n,t,null,{allOwnKeys:!0}),n.create=function(a){return ov(Hr(e,a))},n}const pt=ov(kl);pt.Axios=zr;pt.CanceledError=si;pt.CancelToken=c2;pt.isCancel=ev;pt.VERSION=iv;pt.toFormData=Cc;pt.AxiosError=we;pt.Cancel=pt.CanceledError;pt.all=function(t){return Promise.all(t)};pt.spread=d2;pt.isAxiosError=u2;pt.mergeConfig=Hr;pt.AxiosHeaders=is;pt.formToJSON=e=>Y0(q.isHTMLForm(e)?new FormData(e):e);pt.getAdapter=av.getAdapter;pt.HttpStatusCode=Ku;pt.default=pt;const{Axios:JC,AxiosError:XC,CanceledError:YC,isCancel:e4,CancelToken:t4,VERSION:s4,all:n4,Cancel:r4,isAxiosError:a4,spread:i4,toFormData:l4,AxiosHeaders:o4,HttpStatusCode:c4,formToJSON:d4,getAdapter:u4,mergeConfig:m4}=pt,O=pt.create({baseURL:"/api",headers:{"Content-Type":"application/json"}});O.interceptors.request.use(e=>{const t=localStorage.getItem("token");return t&&(e.headers.Authorization=`Bearer ${t}`),e});O.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 eo={login:async(e,t)=>(await O.post("/auth/login",{email:e,password:t})).data,customerLogin:async(e,t)=>(await O.post("/auth/customer-login",{email:e,password:t})).data,me:async()=>(await O.get("/auth/me")).data},Et={getAll:async e=>(await O.get("/customers",{params:e})).data,getById:async e=>(await O.get(`/customers/${e}`)).data,create:async e=>(await O.post("/customers",e)).data,update:async(e,t)=>(await O.put(`/customers/${e}`,t)).data,delete:async e=>(await O.delete(`/customers/${e}`)).data,getPortalSettings:async e=>(await O.get(`/customers/${e}/portal`)).data,updatePortalSettings:async(e,t)=>(await O.put(`/customers/${e}/portal`,t)).data,setPortalPassword:async(e,t)=>(await O.post(`/customers/${e}/portal/password`,{password:t})).data,getPortalPassword:async e=>(await O.get(`/customers/${e}/portal/password`)).data,getRepresentatives:async e=>(await O.get(`/customers/${e}/representatives`)).data,addRepresentative:async(e,t,n)=>(await O.post(`/customers/${e}/representatives`,{representativeId:t,notes:n})).data,removeRepresentative:async(e,t)=>(await O.delete(`/customers/${e}/representatives/${t}`)).data,searchForRepresentative:async(e,t)=>(await O.get(`/customers/${e}/representatives/search`,{params:{search:t}})).data},Uu={getByCustomer:async e=>(await O.get(`/customers/${e}/addresses`)).data,create:async(e,t)=>(await O.post(`/customers/${e}/addresses`,t)).data,update:async(e,t)=>(await O.put(`/addresses/${e}`,t)).data,delete:async e=>(await O.delete(`/addresses/${e}`)).data},Zo={getByCustomer:async(e,t=!1)=>(await O.get(`/customers/${e}/bank-cards`,{params:{showInactive:t}})).data,create:async(e,t)=>(await O.post(`/customers/${e}/bank-cards`,t)).data,update:async(e,t)=>(await O.put(`/bank-cards/${e}`,t)).data,delete:async e=>(await O.delete(`/bank-cards/${e}`)).data},Jo={getByCustomer:async(e,t=!1)=>(await O.get(`/customers/${e}/documents`,{params:{showInactive:t}})).data,create:async(e,t)=>(await O.post(`/customers/${e}/documents`,t)).data,update:async(e,t)=>(await O.put(`/documents/${e}`,t)).data,delete:async e=>(await O.delete(`/documents/${e}`)).data},rn={getByCustomer:async(e,t=!1)=>(await O.get(`/customers/${e}/meters`,{params:{showInactive:t}})).data,create:async(e,t)=>(await O.post(`/customers/${e}/meters`,t)).data,update:async(e,t)=>(await O.put(`/meters/${e}`,t)).data,delete:async e=>(await O.delete(`/meters/${e}`)).data,getReadings:async e=>(await O.get(`/meters/${e}/readings`)).data,addReading:async(e,t)=>(await O.post(`/meters/${e}/readings`,t)).data,updateReading:async(e,t,n)=>(await O.put(`/meters/${e}/readings/${t}`,n)).data,deleteReading:async(e,t)=>(await O.delete(`/meters/${e}/readings/${t}`)).data},cs={getByCustomer:async(e,t=!1)=>(await O.get(`/customers/${e}/stressfrei-emails`,{params:{includeInactive:t}})).data,create:async(e,t)=>(await O.post(`/customers/${e}/stressfrei-emails`,t)).data,update:async(e,t)=>(await O.put(`/stressfrei-emails/${e}`,t)).data,delete:async e=>(await O.delete(`/stressfrei-emails/${e}`)).data,enableMailbox:async e=>(await O.post(`/stressfrei-emails/${e}/enable-mailbox`)).data,syncMailboxStatus:async e=>(await O.post(`/stressfrei-emails/${e}/sync-mailbox-status`)).data,getMailboxCredentials:async e=>(await O.get(`/stressfrei-emails/${e}/credentials`)).data,resetPassword:async e=>(await O.post(`/stressfrei-emails/${e}/reset-password`)).data,syncEmails:async(e,t=!1)=>(await O.post(`/stressfrei-emails/${e}/sync`,{},{params:{full:t}})).data,sendEmail:async(e,t)=>(await O.post(`/stressfrei-emails/${e}/send`,t)).data,getFolderCounts:async e=>(await O.get(`/stressfrei-emails/${e}/folder-counts`)).data},Me={getForCustomer:async(e,t)=>(await O.get(`/customers/${e}/emails`,{params:t})).data,getForContract:async(e,t)=>(await O.get(`/contracts/${e}/emails`,{params:t})).data,getContractFolderCounts:async e=>(await O.get(`/contracts/${e}/emails/folder-counts`)).data,getMailboxAccounts:async e=>(await O.get(`/customers/${e}/mailbox-accounts`)).data,getById:async e=>(await O.get(`/emails/${e}`)).data,getThread:async e=>(await O.get(`/emails/${e}/thread`)).data,markAsRead:async(e,t)=>(await O.patch(`/emails/${e}/read`,{isRead:t})).data,toggleStar:async e=>(await O.post(`/emails/${e}/star`)).data,assignToContract:async(e,t)=>(await O.post(`/emails/${e}/assign`,{contractId:t})).data,unassignFromContract:async e=>(await O.delete(`/emails/${e}/assign`)).data,delete:async e=>(await O.delete(`/emails/${e}`)).data,getAttachmentUrl:(e,t,n)=>{const r=localStorage.getItem("token"),a=encodeURIComponent(t),i=n?"&view=true":"";return`${O.defaults.baseURL}/emails/${e}/attachments/${a}?token=${r}${i}`},getUnreadCount:async e=>(await O.get("/emails/unread-count",{params:e})).data,getTrash:async e=>(await O.get(`/customers/${e}/emails/trash`)).data,getTrashCount:async e=>(await O.get(`/customers/${e}/emails/trash/count`)).data,restore:async e=>(await O.post(`/emails/${e}/restore`)).data,permanentDelete:async e=>(await O.delete(`/emails/${e}/permanent`)).data,getAttachmentTargets:async e=>(await O.get(`/emails/${e}/attachment-targets`)).data,saveAttachmentTo:async(e,t,n)=>{const r=encodeURIComponent(t);return(await O.post(`/emails/${e}/attachments/${r}/save-to`,n)).data},saveEmailAsPdf:async(e,t)=>(await O.post(`/emails/${e}/save-as-pdf`,t)).data},ze={getAll:async e=>(await O.get("/contracts",{params:e})).data,getTreeForCustomer:async e=>(await O.get("/contracts",{params:{customerId:e,tree:"true"}})).data,getById:async e=>(await O.get(`/contracts/${e}`)).data,create:async e=>(await O.post("/contracts",e)).data,update:async(e,t)=>(await O.put(`/contracts/${e}`,t)).data,delete:async e=>(await O.delete(`/contracts/${e}`)).data,createFollowUp:async e=>(await O.post(`/contracts/${e}/follow-up`)).data,getPassword:async e=>(await O.get(`/contracts/${e}/password`)).data,getSimCardCredentials:async e=>(await O.get(`/contracts/simcard/${e}/credentials`)).data,getInternetCredentials:async e=>(await O.get(`/contracts/${e}/internet-credentials`)).data,getSipCredentials:async e=>(await O.get(`/contracts/phonenumber/${e}/sip-credentials`)).data,getCockpit:async()=>(await O.get("/contracts/cockpit")).data},mt={getAll:async e=>(await O.get("/tasks",{params:e})).data,getStats:async()=>(await O.get("/tasks/stats")).data,getByContract:async(e,t)=>(await O.get(`/contracts/${e}/tasks`,{params:{status:t}})).data,create:async(e,t)=>(await O.post(`/contracts/${e}/tasks`,t)).data,update:async(e,t)=>(await O.put(`/tasks/${e}`,t)).data,complete:async e=>(await O.post(`/tasks/${e}/complete`)).data,reopen:async e=>(await O.post(`/tasks/${e}/reopen`)).data,delete:async e=>(await O.delete(`/tasks/${e}`)).data,createSubtask:async(e,t)=>(await O.post(`/tasks/${e}/subtasks`,{title:t})).data,createReply:async(e,t)=>(await O.post(`/tasks/${e}/reply`,{title:t})).data,updateSubtask:async(e,t)=>(await O.put(`/subtasks/${e}`,{title:t})).data,completeSubtask:async e=>(await O.post(`/subtasks/${e}/complete`)).data,reopenSubtask:async e=>(await O.post(`/subtasks/${e}/reopen`)).data,deleteSubtask:async e=>(await O.delete(`/subtasks/${e}`)).data,createSupportTicket:async(e,t)=>(await O.post(`/contracts/${e}/support-ticket`,t)).data},Wr={getPublic:async()=>(await O.get("/settings/public")).data,getAll:async()=>(await O.get("/settings")).data,update:async e=>(await O.put("/settings",e)).data,updateOne:async(e,t)=>(await O.put(`/settings/${e}`,{value:t})).data},gr={list:async()=>(await O.get("/settings/backups")).data,create:async()=>(await O.post("/settings/backup")).data,restore:async e=>(await O.post(`/settings/backup/${e}/restore`)).data,delete:async e=>(await O.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 O.post("/settings/backup/upload",t,{headers:{"Content-Type":"multipart/form-data"}})).data},factoryReset:async()=>(await O.post("/settings/factory-reset")).data},tl={getAll:async(e=!1)=>(await O.get("/platforms",{params:{includeInactive:e}})).data,getById:async e=>(await O.get(`/platforms/${e}`)).data,create:async e=>(await O.post("/platforms",e)).data,update:async(e,t)=>(await O.put(`/platforms/${e}`,t)).data,delete:async e=>(await O.delete(`/platforms/${e}`)).data},sl={getAll:async(e=!1)=>(await O.get("/cancellation-periods",{params:{includeInactive:e}})).data,getById:async e=>(await O.get(`/cancellation-periods/${e}`)).data,create:async e=>(await O.post("/cancellation-periods",e)).data,update:async(e,t)=>(await O.put(`/cancellation-periods/${e}`,t)).data,delete:async e=>(await O.delete(`/cancellation-periods/${e}`)).data},nl={getAll:async(e=!1)=>(await O.get("/contract-durations",{params:{includeInactive:e}})).data,getById:async e=>(await O.get(`/contract-durations/${e}`)).data,create:async e=>(await O.post("/contract-durations",e)).data,update:async(e,t)=>(await O.put(`/contract-durations/${e}`,t)).data,delete:async e=>(await O.delete(`/contract-durations/${e}`)).data},rl={getAll:async(e=!1)=>(await O.get("/contract-categories",{params:{includeInactive:e}})).data,getById:async e=>(await O.get(`/contract-categories/${e}`)).data,create:async e=>(await O.post("/contract-categories",e)).data,update:async(e,t)=>(await O.put(`/contract-categories/${e}`,t)).data,delete:async e=>(await O.delete(`/contract-categories/${e}`)).data},Wa={getAll:async(e=!1)=>(await O.get("/providers",{params:{includeInactive:e}})).data,getById:async e=>(await O.get(`/providers/${e}`)).data,create:async e=>(await O.post("/providers",e)).data,update:async(e,t)=>(await O.put(`/providers/${e}`,t)).data,delete:async e=>(await O.delete(`/providers/${e}`)).data,getTariffs:async(e,t=!1)=>(await O.get(`/providers/${e}/tariffs`,{params:{includeInactive:t}})).data,createTariff:async(e,t)=>(await O.post(`/providers/${e}/tariffs`,t)).data},cv={getById:async e=>(await O.get(`/tariffs/${e}`)).data,update:async(e,t)=>(await O.put(`/tariffs/${e}`,t)).data,delete:async e=>(await O.delete(`/tariffs/${e}`)).data},dt={uploadBankCardDocument:async(e,t)=>{const n=new FormData;return n.append("document",t),(await O.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 O.post(`/upload/documents/${e}`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteBankCardDocument:async e=>(await O.delete(`/upload/bank-cards/${e}`)).data,deleteIdentityDocument:async e=>(await O.delete(`/upload/documents/${e}`)).data,uploadBusinessRegistration:async(e,t)=>{const n=new FormData;return n.append("document",t),(await O.post(`/upload/customers/${e}/business-registration`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteBusinessRegistration:async e=>(await O.delete(`/upload/customers/${e}/business-registration`)).data,uploadCommercialRegister:async(e,t)=>{const n=new FormData;return n.append("document",t),(await O.post(`/upload/customers/${e}/commercial-register`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCommercialRegister:async e=>(await O.delete(`/upload/customers/${e}/commercial-register`)).data,uploadPrivacyPolicy:async(e,t)=>{const n=new FormData;return n.append("document",t),(await O.post(`/upload/customers/${e}/privacy-policy`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deletePrivacyPolicy:async e=>(await O.delete(`/upload/customers/${e}/privacy-policy`)).data,uploadCancellationLetter:async(e,t)=>{const n=new FormData;return n.append("document",t),(await O.post(`/upload/contracts/${e}/cancellation-letter`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationLetter:async e=>(await O.delete(`/upload/contracts/${e}/cancellation-letter`)).data,uploadCancellationConfirmation:async(e,t)=>{const n=new FormData;return n.append("document",t),(await O.post(`/upload/contracts/${e}/cancellation-confirmation`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationConfirmation:async e=>(await O.delete(`/upload/contracts/${e}/cancellation-confirmation`)).data,uploadCancellationLetterOptions:async(e,t)=>{const n=new FormData;return n.append("document",t),(await O.post(`/upload/contracts/${e}/cancellation-letter-options`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationLetterOptions:async e=>(await O.delete(`/upload/contracts/${e}/cancellation-letter-options`)).data,uploadCancellationConfirmationOptions:async(e,t)=>{const n=new FormData;return n.append("document",t),(await O.post(`/upload/contracts/${e}/cancellation-confirmation-options`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationConfirmationOptions:async e=>(await O.delete(`/upload/contracts/${e}/cancellation-confirmation-options`)).data},Mi={getAll:async e=>(await O.get("/users",{params:e})).data,getById:async e=>(await O.get(`/users/${e}`)).data,create:async e=>(await O.post("/users",e)).data,update:async(e,t)=>(await O.put(`/users/${e}`,t)).data,delete:async e=>(await O.delete(`/users/${e}`)).data,getRoles:async()=>(await O.get("/users/roles/list")).data},bi={getSchema:async()=>(await O.get("/developer/schema")).data,getTableData:async(e,t=1,n=50)=>(await O.get(`/developer/table/${e}`,{params:{page:t,limit:n}})).data,updateRow:async(e,t,n)=>(await O.put(`/developer/table/${e}/${t}`,n)).data,deleteRow:async(e,t)=>(await O.delete(`/developer/table/${e}/${t}`)).data,getReference:async e=>(await O.get(`/developer/reference/${e}`)).data},fn={getConfigs:async()=>(await O.get("/email-providers/configs")).data,getConfig:async e=>(await O.get(`/email-providers/configs/${e}`)).data,createConfig:async e=>(await O.post("/email-providers/configs",e)).data,updateConfig:async(e,t)=>(await O.put(`/email-providers/configs/${e}`,t)).data,deleteConfig:async e=>(await O.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 O.post("/email-providers/test-connection",t)).data},getDomain:async()=>(await O.get("/email-providers/domain")).data,checkEmailExists:async e=>(await O.get(`/email-providers/check/${e}`)).data,provisionEmail:async(e,t)=>(await O.post("/email-providers/provision",{localPart:e,customerEmail:t})).data,deprovisionEmail:async e=>(await O.delete(`/email-providers/deprovision/${e}`)).data},dv=b.createContext(null);function m2({children:e}){const[t,n]=b.useState(null),[r,a]=b.useState(!0),[i,l]=b.useState(()=>localStorage.getItem("developerMode")==="true"),o=x=>{l(x),localStorage.setItem("developerMode",String(x))};b.useEffect(()=>{var x;console.log("useEffect check - user:",t==null?void 0:t.email,"developerMode:",i,"has developer:access:",(x=t==null?void 0:t.permissions)==null?void 0:x.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]),b.useEffect(()=>{localStorage.getItem("token")?eo.me().then(j=>{j.success&&j.data?n(j.data):localStorage.removeItem("token")}).catch(()=>{localStorage.removeItem("token")}).finally(()=>{a(!1)}):a(!1)},[]);const c=async(x,j)=>{const y=await eo.login(x,j);if(y.success&&y.data)localStorage.setItem("token",y.data.token),n(y.data.user);else throw new Error(y.error||"Login fehlgeschlagen")},d=async(x,j)=>{const y=await eo.customerLogin(x,j);if(y.success&&y.data)localStorage.setItem("token",y.data.token),n(y.data.user);else throw new Error(y.error||"Login fehlgeschlagen")},u=()=>{localStorage.removeItem("token"),n(null)},h=async()=>{var j;if(localStorage.getItem("token"))try{const y=await eo.me();console.log("refreshUser response:",y),console.log("permissions:",(j=y.data)==null?void 0:j.permissions),y.success&&y.data&&n(y.data)}catch(y){console.error("refreshUser error:",y)}},p=x=>t?t.permissions.includes(x):!1,m=!!(t!=null&&t.customerId),f=!!(t!=null&&t.isCustomerPortal);return s.jsx(dv.Provider,{value:{user:t,isLoading:r,isAuthenticated:!!t,login:c,customerLogin:d,logout:u,hasPermission:p,isCustomer:m,isCustomerPortal:f,developerMode:i,setDeveloperMode:o,refreshUser:h},children:e})}function qe(){const e=b.useContext(dv);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}const md={scrollToTopThreshold:.7},uv=b.createContext(void 0),nx="opencrm_app_settings";function h2({children:e}){const[t,n]=b.useState(()=>{const a=localStorage.getItem(nx);if(a)try{return{...md,...JSON.parse(a)}}catch{return md}return md});b.useEffect(()=>{localStorage.setItem(nx,JSON.stringify(t))},[t]);const r=a=>{n(i=>({...i,...a}))};return s.jsx(uv.Provider,{value:{settings:t,updateSettings:r},children:e})}function mv(){const e=b.useContext(uv);if(!e)throw new Error("useAppSettings must be used within AppSettingsProvider");return e}function f2(){const{pathname:e}=Fn();return b.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 p2=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),hv=(...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 x2={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 g2=b.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:a="",children:i,iconNode:l,...o},c)=>b.createElement("svg",{ref:c,...x2,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:hv("lucide",a),...o},[...l.map(([d,u])=>b.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 ae=(e,t)=>{const n=b.forwardRef(({className:r,...a},i)=>b.createElement(g2,{ref:i,iconNode:t,className:hv(`lucide-${p2(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 y2=ae("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 Us=ae("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 fv=ae("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 v2=ae("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 j2=ae("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 b2=ae("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 pv=ae("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 xv=ae("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 Ga=ae("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 xr=ae("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 N2=ae("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 Mt=ae("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 gv=ae("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 bn=ae("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 ws=ae("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 rx=ae("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 vo=ae("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 al=ae("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 Pn=ae("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 Dc=ae("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 rh=ae("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 ah=ae("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 Pc=ae("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 zs=ae("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 ih=ae("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 Ft=ae("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 De=ae("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 w2=ae("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 He=ae("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 S2=ae("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 yv=ae("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 k2=ae("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 vv=ae("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 ax=ae("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 lh=ae("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 C2=ae("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 ix=ae("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 jv=ae("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 $r=ae("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 E2=ae("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 D2=ae("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 P2=ae("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 lx=ae("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 A2=ae("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 bv=ae("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 tn=ae("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 M2=ae("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 F2=ae("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 il=ae("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 T2=ae("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 I2=ae("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 Ac=ae("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 Ue=ae("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 jr=ae("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 R2=ae("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 L2=ae("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 Nv=ae("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 Cl=ae("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 El=ae("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 wv=ae("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 oh=ae("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 at=ae("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 ch=ae("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 O2=ae("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 z2=ae("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=ae("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 Es=ae("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 Sv=ae("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 kv=ae("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 Bu=ae("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 $2=ae("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 _2=ae("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 Dl=ae("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 Na=ae("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 ox=ae("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 wa=ae("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 Bs=ae("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 dh=ae("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 K2=ae("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 U2=ae("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 B2(){const{user:e,logout:t,hasPermission:n,isCustomer:r,developerMode:a}=qe(),i=[{to:"/",icon:P2,label:"Dashboard",show:!0,end:!0},{to:"/customers",icon:Na,label:"Kunden",show:n("customers:read")&&!r},{to:"/contracts",icon:He,label:"Verträge",show:n("contracts:read"),end:!0},{to:"/contracts/cockpit",icon:bn,label:"Vertrags-Cockpit",show:n("contracts:read")&&!r},{to:"/tasks",icon:r?il:al,label:r?"Support-Anfragen":"Aufgaben",show:n("contracts:read")}],l=[{to:"/developer/database",icon:Pc,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(od,{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(Dc,{className:"w-3 h-3"}),"Entwickler"]})}),s.jsx("ul",{className:"space-y-2",children:l.map(o=>s.jsx("li",{children:s.jsxs(od,{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(od,{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(wv,{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(A2,{className:"w-5 h-5"}),"Abmelden"]})]})]})}function q2(){const{settings:e}=mv(),[t,n]=b.useState(!1);b.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(gv,{className:"w-5 h-5"})}):null}function V2(){return s.jsxs("div",{className:"flex min-h-screen",children:[s.jsx(B2,{}),s.jsx("main",{className:"flex-1 p-8 overflow-auto",children:s.jsx(sw,{})}),s.jsx(q2,{})]})}const I=b.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})});I.displayName="Button";const V=b.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})]})});V.displayName="Input";function Y({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 Q2(){const[e,t]=b.useState(""),[n,r]=b.useState(""),[a,i]=b.useState(""),[l,o]=b.useState(!1),{login:c,customerLogin:d}=qe(),u=Gt(),h=async p=>{p.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(Y,{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(V,{label:"E-Mail",type:"email",value:e,onChange:p=>t(p.target.value),required:!0,autoComplete:"email"}),s.jsx(V,{label:"Passwort",type:"password",value:n,onChange:p=>r(p.target.value),required:!0,autoComplete:"current-password"}),s.jsx(I,{type:"submit",className:"w-full",disabled:l,children:l?"Anmeldung...":"Anmelden"})]})]})})}function Ge({isOpen:e,onClose:t,title:n,children:r,size:a="md"}){if(b.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(I,{variant:"ghost",size:"sm",onClick:t,children:s.jsx(Bs,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-6",children:r})]})]})})}function H2(){var N,E,P,z,D,_;const{user:e,isCustomer:t,isCustomerPortal:n}=qe(),[r,a]=b.useState(!1),{data:i,isLoading:l}=me({queryKey:["app-settings-public"],queryFn:()=>Wr.getPublic(),enabled:n,staleTime:0}),o=!l&&((N=i==null?void 0:i.data)==null?void 0:N.customerSupportTicketsEnabled)==="true",{data:c}=me({queryKey:["customers-count"],queryFn:()=>Et.getAll({limit:1}),enabled:!t}),{data:d}=me({queryKey:["contracts",t?e==null?void 0:e.customerId:void 0],queryFn:()=>ze.getAll(t?{customerId:e==null?void 0:e.customerId}:{limit:1})}),{data:u}=me({queryKey:["contracts-active",t?e==null?void 0:e.customerId:void 0],queryFn:()=>ze.getAll({status:"ACTIVE",...t?{customerId:e==null?void 0:e.customerId}:{limit:1}})}),{data:h}=me({queryKey:["contracts-pending",t?e==null?void 0:e.customerId:void 0],queryFn:()=>ze.getAll({status:"PENDING",...t?{customerId:e==null?void 0:e.customerId}:{limit:1}})}),{data:p}=me({queryKey:["task-stats"],queryFn:()=>mt.getStats()}),{data:m}=me({queryKey:["contract-cockpit"],queryFn:()=>ze.getCockpit(),enabled:!t,staleTime:0}),{ownContracts:f,representedContracts:x}=b.useMemo(()=>{if(!n||!(d!=null&&d.data))return{ownContracts:[],representedContracts:[]};const $=[],L={};for(const A of d.data)if(A.customerId===(e==null?void 0:e.customerId))$.push(A);else{const K=A.customerId;if(!L[K]){const B=A.customer?A.customer.companyName||`${A.customer.firstName} ${A.customer.lastName}`:`Kunde ${K}`;L[K]={customerName:B,contracts:[]}}L[K].contracts.push(A)}return{ownContracts:$,representedContracts:Object.values(L).sort((A,K)=>A.customerName.localeCompare(K.customerName))}},[d==null?void 0:d.data,n,e==null?void 0:e.customerId]),j=b.useMemo(()=>f.filter($=>$.status==="ACTIVE").length,[f]),y=b.useMemo(()=>f.filter($=>$.status==="PENDING").length,[f]),v=b.useMemo(()=>f.filter($=>$.status==="EXPIRED").length,[f]),g=b.useMemo(()=>x.reduce(($,L)=>$+L.contracts.length,0),[x]),w=b.useMemo(()=>x.reduce(($,L)=>$+L.contracts.filter(A=>A.status==="ACTIVE").length,0),[x]),C=b.useMemo(()=>x.reduce(($,L)=>$+L.contracts.filter(A=>A.status==="EXPIRED").length,0),[x]),k=((E=p==null?void 0:p.data)==null?void 0:E.openCount)||0,F=$=>s.jsx(Y,{className:$.link?"cursor-pointer hover:shadow-md transition-shadow":"",children:$.link?s.jsx(Se,{to:$.link,className:"block",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:`p-3 rounded-lg ${$.color}`,children:s.jsx($.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:$.label}),s.jsx("p",{className:"text-2xl font-bold",children:$.value})]})]})}):s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:`p-3 rounded-lg ${$.color}`,children:s.jsx($.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:$.label}),s.jsx("p",{className:"text-2xl font-bold",children:$.value})]})]})},$.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(I,{onClick:()=>a(!0),children:[s.jsx(Ue,{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(Dl,{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:[F({label:"Eigene Verträge",value:f.length,icon:He,color:"bg-blue-500",link:"/contracts"}),F({label:"Davon aktiv",value:j,icon:ws,color:"bg-green-500"}),F({label:"Davon ausstehend",value:y,icon:Pn,color:"bg-yellow-500"}),F({label:"Davon abgelaufen",value:v,icon:rx,color:"bg-red-500"})]})]}),g>0&&s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(Na,{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:[F({label:"Fremdverträge",value:g,icon:Na,color:"bg-purple-500",link:"/contracts"}),F({label:"Davon aktiv",value:w,icon:ws,color:"bg-green-500"}),s.jsx("div",{className:"hidden lg:block"}),F({label:"Davon abgelaufen",value:C,icon:rx,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(il,{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:F({label:"Offene Anfragen",value:k,icon:il,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:[F({label:"Kunden",value:((P=c==null?void 0:c.pagination)==null?void 0:P.total)||0,icon:Na,color:"bg-blue-500",link:"/customers"}),F({label:"Verträge gesamt",value:((z=d==null?void 0:d.pagination)==null?void 0:z.total)||0,icon:He,color:"bg-purple-500",link:"/contracts"}),F({label:"Aktive Verträge",value:((D=u==null?void 0:u.pagination)==null?void 0:D.total)||0,icon:ws,color:"bg-green-500"}),F({label:"Ausstehende Verträge",value:((_=h==null?void 0:h.pagination)==null?void 0:_.total)||0,icon:bn,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(bn,{className:"w-5 h-5 text-red-500"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Vertrags-Cockpit"})]}),s.jsx(Se,{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(Y,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(Se,{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(bn,{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(Y,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(Se,{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(Es,{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(Y,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(Se,{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(ws,{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(Y,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(Se,{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(He,{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(al,{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:F({label:"Offene Aufgaben",value:k,icon:al,color:"bg-orange-500",link:"/tasks"})})]})]}),n&&s.jsx(W2,{isOpen:r,onClose:()=>a(!1)})]})}function W2({isOpen:e,onClose:t}){const{user:n}=qe(),r=Gt(),a=xe(),[i,l]=b.useState("own"),[o,c]=b.useState(null),[d,u]=b.useState(""),[h,p]=b.useState(""),[m,f]=b.useState(!1),[x,j]=b.useState(""),{data:y}=me({queryKey:["contracts",n==null?void 0:n.customerId],queryFn:()=>ze.getAll({customerId:n==null?void 0:n.customerId}),enabled:e}),v=b.useMemo(()=>{if(!(y!=null&&y.data))return{own:[],represented:{}};const N=[],E={};for(const P of y.data)if(P.customerId===(n==null?void 0:n.customerId))N.push(P);else{if(!E[P.customerId]){const z=P.customer?P.customer.companyName||`${P.customer.firstName} ${P.customer.lastName}`:`Kunde ${P.customerId}`;E[P.customerId]={name:z,contracts:[]}}E[P.customerId].contracts.push(P)}return{own:N,represented:E}},[y==null?void 0:y.data,n==null?void 0:n.customerId]),g=Object.keys(v.represented).length>0,w=b.useMemo(()=>{var N;return i==="own"?v.own:((N=v.represented[i])==null?void 0:N.contracts)||[]},[i,v]),C=b.useMemo(()=>{if(!x)return w;const N=x.toLowerCase();return w.filter(E=>E.contractNumber.toLowerCase().includes(N)||(E.providerName||"").toLowerCase().includes(N)||(E.tariffName||"").toLowerCase().includes(N))},[w,x]),k=async()=>{if(!(!o||!d.trim())){f(!0);try{await mt.createSupportTicket(o,{title:d.trim(),description:h.trim()||void 0}),a.invalidateQueries({queryKey:["task-stats"]}),a.invalidateQueries({queryKey:["all-tasks"]}),t(),u(""),p(""),c(null),l("own"),r(`/contracts/${o}`)}catch(N){console.error("Fehler beim Erstellen der Support-Anfrage:",N),alert("Fehler beim Erstellen der Support-Anfrage. Bitte versuchen Sie es erneut.")}finally{f(!1)}}},F=()=>{u(""),p(""),c(null),l("own"),j(""),t()};return s.jsx(Ge,{isOpen:e,onClose:F,title:"Neue Support-Anfrage",children:s.jsxs("div",{className:"space-y-4",children:[g&&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:N=>{const E=N.target.value;l(E==="own"?"own":parseInt(E)),c(null),j("")},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(v.represented).map(([N,{name:E}])=>s.jsx("option",{value:N,children:E},N))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),s.jsx(V,{placeholder:"Vertrag suchen...",value:x,onChange:N=>j(N.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-lg",children:C.length>0?C.map(N=>s.jsxs("div",{onClick:()=>c(N.id),className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${o===N.id?"bg-blue-50 border-blue-200":""}`,children:[s.jsx("div",{className:"font-medium",children:N.contractNumber}),s.jsxs("div",{className:"text-sm text-gray-500",children:[N.providerName||"Kein Anbieter",N.tariffName&&` - ${N.tariffName}`]})]},N.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(V,{value:d,onChange:N=>u(N.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:N=>p(N.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(I,{variant:"secondary",onClick:F,children:"Abbrechen"}),s.jsx(I,{onClick:k,disabled:!o||!d.trim()||m,children:m?"Wird erstellt...":"Anfrage erstellen"})]})]})})}function ye({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 G2(){const[e,t]=b.useState(""),[n,r]=b.useState(""),[a,i]=b.useState(1),{hasPermission:l}=qe(),{data:o,isLoading:c}=me({queryKey:["customers",e,n,a],queryFn:()=>Et.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(Se,{to:"/customers/new",children:s.jsxs(I,{children:[s.jsx(Ue,{className:"w-4 h-4 mr-2"}),"Neuer Kunde"]})})]}),s.jsx(Y,{className:"mb-6",children:s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx(V,{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(I,{variant:"secondary",className:"flex-shrink-0",children:s.jsx(Cl,{className:"w-4 h-4"})})]})}),s.jsx(Y,{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(ye,{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(Se,{to:`/customers/${d.id}`,children:s.jsx(I,{variant:"ghost",size:"sm",children:s.jsx(De,{className:"w-4 h-4"})})}),l("customers:update")&&s.jsx(Se,{to:`/customers/${d.id}/edit`,children:s.jsx(I,{variant:"ghost",size:"sm",children:s.jsx(at,{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(I,{variant:"secondary",size:"sm",onClick:()=>i(d=>Math.max(1,d-1)),disabled:a===1,children:"Zurück"}),s.jsx(I,{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 Z2({emails:e,selectedEmailId:t,onSelectEmail:n,onEmailDeleted:r,isLoading:a,folder:i="INBOX",accountId:l}){const o=i==="SENT",[c,d]=b.useState(null),{hasPermission:u}=qe(),h=E=>{if(o)try{const P=JSON.parse(E.toAddresses);if(P.length>0)return`An: ${P[0]}${P.length>1?` (+${P.length-1})`:""}`}catch{return"An: (Unbekannt)"}return E.fromName||E.fromAddress},p=xe(),m=G({mutationFn:E=>Me.toggleStar(E),onSuccess:(E,P)=>{p.invalidateQueries({queryKey:["emails"]}),p.invalidateQueries({queryKey:["email",P]})}}),f=G({mutationFn:({emailId:E,isRead:P})=>Me.markAsRead(E,P),onSuccess:(E,P)=>{p.invalidateQueries({queryKey:["emails"]}),p.invalidateQueries({queryKey:["email",P.emailId]}),l&&p.invalidateQueries({queryKey:["folder-counts",l]})}}),x=G({mutationFn:E=>Me.delete(E),onSuccess:(E,P)=>{p.invalidateQueries({queryKey:["emails"]}),l&&p.invalidateQueries({queryKey:["folder-counts",l]}),Ke.success("E-Mail in Papierkorb verschoben"),d(null),r==null||r(P)},onError:E=>{console.error("Delete error:",E),Ke.error(E.message||"Fehler beim Löschen der E-Mail"),d(null)}}),j=G({mutationFn:E=>Me.unassignFromContract(E),onSuccess:()=>{p.invalidateQueries({queryKey:["emails"]}),Ke.success("Vertragszuordnung aufgehoben")},onError:E=>{console.error("Unassign error:",E),Ke.error(E.message||"Fehler beim Aufheben der Zuordnung")}}),y=(E,P)=>{E.stopPropagation(),j.mutate(P)},v=(E,P)=>{E.stopPropagation(),d(P)},g=E=>{E.stopPropagation(),c&&x.mutate(c)},w=E=>{E.stopPropagation(),d(null)},C=E=>{const P=new Date(E),z=new Date;return P.toDateString()===z.toDateString()?P.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}):P.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})},k=(E,P)=>{E.stopPropagation(),m.mutate(P)},F=(E,P)=>{E.stopPropagation(),f.mutate({emailId:P.id,isRead:!P.isRead})},N=E=>{E.isRead||f.mutate({emailId:E.id,isRead:!0}),n(E)};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(tn,{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(E=>s.jsxs("div",{onClick:()=>N(E),className:["flex items-start gap-3 p-3 cursor-pointer transition-colors",t===E.id?"bg-blue-100":["hover:bg-gray-100",E.isRead?"bg-gray-50/50":"bg-white"].join(" ")].join(" "),style:{borderLeft:t===E.id?"4px solid #2563eb":"4px solid transparent"},children:[s.jsx("button",{onClick:P=>F(P,E),className:`
flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200
${E.isRead?"text-gray-400":"text-blue-600"}
`,title:E.isRead?"Als ungelesen markieren":"Als gelesen markieren",children:E.isRead?s.jsx(bv,{className:"w-4 h-4"}):s.jsx(tn,{className:"w-4 h-4"})}),s.jsx("button",{onClick:P=>k(P,E.id),className:`
flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200
${E.isStarred?"text-yellow-500":"text-gray-400"}
`,title:E.isStarred?"Stern entfernen":"Als wichtig markieren",children:s.jsx(ch,{className:`w-4 h-4 ${E.isStarred?"fill-current":""}`})}),u("emails:delete")&&s.jsx("button",{onClick:P=>v(P,E.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 ${E.isRead?"text-gray-700":"font-semibold text-gray-900"}`,children:h(E)}),s.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:C(E.receivedAt)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-sm truncate ${E.isRead?"text-gray-600":"font-medium text-gray-900"}`,children:E.subject||"(Kein Betreff)"}),E.hasAttachments&&s.jsx(Ac,{className:"w-3 h-3 text-gray-400 flex-shrink-0"})]}),E.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:E.contract.contractNumber}),(i==="INBOX"||i==="SENT"&&!E.isAutoAssigned)&&s.jsx("button",{onClick:P=>y(P,E.id),className:"p-0.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded",title:"Zuordnung aufheben",disabled:j.isPending,children:s.jsx(Bs,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(Mt,{className:"w-4 h-4 text-gray-400 flex-shrink-0 mt-2"})]},E.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(I,{variant:"secondary",onClick:w,disabled:x.isPending,children:"Abbrechen"}),s.jsx(I,{variant:"danger",onClick:g,disabled:x.isPending,children:x.isPending?"Löschen...":"Löschen"})]})]})})]})}function J2({isOpen:e,onClose:t,emailId:n,attachmentFilename:r,onSuccess:a}){const[i,l]=b.useState(null),[o,c]=b.useState(new Set(["customer"])),d=xe(),{data:u,isLoading:h,error:p}=me({queryKey:["attachment-targets",n],queryFn:()=>Me.getAttachmentTargets(n),enabled:e}),m=u==null?void 0:u.data,f=G({mutationFn:()=>{if(!i)throw new Error("Kein Ziel ausgewählt");return Me.saveAttachmentTo(n,r,{entityType:i.entityType,entityId:i.entityId,targetKey:i.targetKey})},onSuccess:()=>{var C,k;Ke.success("Anhang gespeichert"),d.invalidateQueries({queryKey:["attachment-targets",n]}),d.invalidateQueries({queryKey:["customers"]}),d.invalidateQueries({queryKey:["contracts"]}),(C=m==null?void 0:m.customer)!=null&&C.id&&d.invalidateQueries({queryKey:["customer",m.customer.id.toString()]}),(k=m==null?void 0:m.contract)!=null&&k.id&&d.invalidateQueries({queryKey:["contract",m.contract.id.toString()]}),a==null||a(),x()},onError:C=>{Ke.error(C.message||"Fehler beim Speichern")}}),x=()=>{l(null),t()},j=C=>{const k=new Set(o);k.has(C)?k.delete(C):k.add(C),c(k)},y=(C,k,F,N)=>{l({entityType:C,entityId:F,targetKey:k.key,hasDocument:k.hasDocument,label:N?`${N} ${k.label}`:k.label})},v=(C,k,F,N)=>C.map(E=>{const P=(i==null?void 0:i.entityType)===k&&(i==null?void 0:i.entityId)===F&&(i==null?void 0:i.targetKey)===E.key;return s.jsxs("div",{onClick:()=>y(k,E,F,N),className:`
flex items-center gap-3 p-3 cursor-pointer transition-colors rounded-lg ml-4
${P?"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:E.label}),E.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(Es,{className:"w-3 h-3"}),"Vorhanden"]})]})}),P&&s.jsx(Ga,{className:"w-5 h-5 text-blue-600"})]},E.key)}),g=(C,k)=>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:C.label}),v(C.slots,k,C.id,C.label)]},C.id),w=(C,k,F,N,E=!1)=>{const P=o.has(k);return s.jsxs("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>j(k),className:"w-full flex items-center gap-2 p-3 bg-gray-50 hover:bg-gray-100 transition-colors",children:[P?s.jsx(xr,{className:"w-4 h-4 text-gray-500"}):s.jsx(Mt,{className:"w-4 h-4 text-gray-500"}),F,s.jsx("span",{className:"font-medium text-gray-900",children:C})]}),P&&s.jsx("div",{className:"p-2",children:E?s.jsx("p",{className:"text-sm text-gray-500 text-center py-4",children:"Keine Einträge vorhanden"}):N})]})};return s.jsx(Ge,{isOpen:e,onClose:x,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]})}),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"})}),p&&s.jsx("div",{className:"p-4 bg-red-50 text-red-700 rounded-lg",children:"Fehler beim Laden der Dokumentziele"}),m&&s.jsxs("div",{className:"space-y-3 max-h-96 overflow-auto",children:[w(`Kunde: ${m.customer.name}`,"customer",s.jsx(Dl,{className:"w-4 h-4 text-blue-600"}),v(m.customer.slots,"customer"),m.customer.slots.length===0),w("Ausweisdokumente","identityDocuments",s.jsx(jv,{className:"w-4 h-4 text-green-600"}),m.identityDocuments.map(C=>g(C,"identityDocument")),m.identityDocuments.length===0),w("Bankkarten","bankCards",s.jsx(ah,{className:"w-4 h-4 text-purple-600"}),m.bankCards.map(C=>g(C,"bankCard")),m.bankCards.length===0),m.contract&&w(`Vertrag: ${m.contract.contractNumber}`,"contract",s.jsx(He,{className:"w-4 h-4 text-orange-600"}),v(m.contract.slots,"contract"),m.contract.slots.length===0),!m.contract&&s.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg text-sm text-gray-600",children:[s.jsx(He,{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."]})]}),(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(Es,{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(I,{variant:"secondary",onClick:x,children:"Abbrechen"}),s.jsx(I,{onClick:()=>f.mutate(),disabled:!i||f.isPending,children:f.isPending?"Wird gespeichert...":"Speichern"})]})]})})}function X2({isOpen:e,onClose:t,emailId:n,onSuccess:r}){const[a,i]=b.useState(null),[l,o]=b.useState(new Set(["customer"])),c=xe(),{data:d,isLoading:u,error:h}=me({queryKey:["attachment-targets",n],queryFn:()=>Me.getAttachmentTargets(n),enabled:e}),p=d==null?void 0:d.data,m=G({mutationFn:()=>{if(!a)throw new Error("Kein Ziel ausgewählt");return Me.saveEmailAsPdf(n,{entityType:a.entityType,entityId:a.entityId,targetKey:a.targetKey})},onSuccess:()=>{var w,C;Ke.success("E-Mail als PDF gespeichert"),c.invalidateQueries({queryKey:["attachment-targets",n]}),c.invalidateQueries({queryKey:["customers"]}),c.invalidateQueries({queryKey:["contracts"]}),(w=p==null?void 0:p.customer)!=null&&w.id&&c.invalidateQueries({queryKey:["customer",p.customer.id.toString()]}),(C=p==null?void 0:p.contract)!=null&&C.id&&c.invalidateQueries({queryKey:["contract",p.contract.id.toString()]}),r==null||r(),f()},onError:w=>{Ke.error(w.message||"Fehler beim Speichern")}}),f=()=>{i(null),t()},x=w=>{const C=new Set(l);C.has(w)?C.delete(w):C.add(w),o(C)},j=(w,C,k,F)=>{i({entityType:w,entityId:k,targetKey:C.key,hasDocument:C.hasDocument,label:F?`${F} ${C.label}`:C.label})},y=(w,C,k,F)=>w.map(N=>{const E=(a==null?void 0:a.entityType)===C&&(a==null?void 0:a.entityId)===k&&(a==null?void 0:a.targetKey)===N.key;return s.jsxs("div",{onClick:()=>j(C,N,k,F),className:`
flex items-center gap-3 p-3 cursor-pointer transition-colors rounded-lg ml-4
${E?"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:N.label}),N.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(Es,{className:"w-3 h-3"}),"Vorhanden"]})]})}),E&&s.jsx(Ga,{className:"w-5 h-5 text-blue-600"})]},N.key)}),v=(w,C)=>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:w.label}),y(w.slots,C,w.id,w.label)]},w.id),g=(w,C,k,F,N=!1)=>{const E=l.has(C);return s.jsxs("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>x(C),className:"w-full flex items-center gap-2 p-3 bg-gray-50 hover:bg-gray-100 transition-colors",children:[E?s.jsx(xr,{className:"w-4 h-4 text-gray-500"}):s.jsx(Mt,{className:"w-4 h-4 text-gray-500"}),k,s.jsx("span",{className:"font-medium text-gray-900",children:w})]}),E&&s.jsx("div",{className:"p-2",children:N?s.jsx("p",{className:"text-sm text-gray-500 text-center py-4",children:"Keine Einträge vorhanden"}):F})]})};return s.jsx(Ge,{isOpen:e,onClose:f,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."})}),u&&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"})}),h&&s.jsx("div",{className:"p-4 bg-red-50 text-red-700 rounded-lg",children:"Fehler beim Laden der Dokumentziele"}),p&&s.jsxs("div",{className:"space-y-3 max-h-96 overflow-auto",children:[g(`Kunde: ${p.customer.name}`,"customer",s.jsx(Dl,{className:"w-4 h-4 text-blue-600"}),y(p.customer.slots,"customer"),p.customer.slots.length===0),g("Ausweisdokumente","identityDocuments",s.jsx(jv,{className:"w-4 h-4 text-green-600"}),p.identityDocuments.map(w=>v(w,"identityDocument")),p.identityDocuments.length===0),g("Bankkarten","bankCards",s.jsx(ah,{className:"w-4 h-4 text-purple-600"}),p.bankCards.map(w=>v(w,"bankCard")),p.bankCards.length===0),p.contract&&g(`Vertrag: ${p.contract.contractNumber}`,"contract",s.jsx(He,{className:"w-4 h-4 text-orange-600"}),y(p.contract.slots,"contract"),p.contract.slots.length===0),!p.contract&&s.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg text-sm text-gray-600",children:[s.jsx(He,{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."]})]}),(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(Es,{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(I,{variant:"secondary",onClick:f,children:"Abbrechen"}),s.jsx(I,{onClick:()=>m.mutate(),disabled:!a||m.isPending,children:m.isPending?"Wird erstellt...":"Als PDF speichern"})]})]})})}function Cv({email:e,onReply:t,onAssignContract:n,onDeleted:r,isSentFolder:a=!1,isContractView:i=!1,isTrashView:l=!1,onRestored:o,accountId:c}){const[d,u]=b.useState(!0),[h,p]=b.useState(e.isStarred),[m,f]=b.useState(!1),[x,j]=b.useState(!1),[y,v]=b.useState(!1),[g,w]=b.useState(null),[C,k]=b.useState(!1),F=xe(),{hasPermission:N}=qe();b.useEffect(()=>{p(e.isStarred)},[e.id,e.isStarred]);const E=G({mutationFn:()=>Me.toggleStar(e.id),onMutate:()=>{p(H=>!H)},onSuccess:()=>{F.invalidateQueries({queryKey:["emails"]}),F.invalidateQueries({queryKey:["email",e.id]})},onError:()=>{p(e.isStarred)}}),P=G({mutationFn:()=>Me.unassignFromContract(e.id),onSuccess:()=>{F.invalidateQueries({queryKey:["emails"]}),F.invalidateQueries({queryKey:["email",e.id]}),e.contractId&&F.invalidateQueries({queryKey:["contract-folder-counts",e.contractId]}),Ke.success("Vertragszuordnung aufgehoben")},onError:H=>{console.error("Unassign error:",H),Ke.error(H.message||"Fehler beim Aufheben der Zuordnung")}}),z=G({mutationFn:()=>Me.delete(e.id),onSuccess:()=>{F.invalidateQueries({queryKey:["emails"]}),c&&F.invalidateQueries({queryKey:["folder-counts",c]}),e.contractId&&F.invalidateQueries({queryKey:["contract-folder-counts",e.contractId]}),Ke.success("E-Mail in Papierkorb verschoben"),f(!1),r==null||r()},onError:H=>{console.error("Delete error:",H),Ke.error(H.message||"Fehler beim Löschen der E-Mail"),f(!1)}}),D=G({mutationFn:()=>Me.restore(e.id),onSuccess:()=>{F.invalidateQueries({queryKey:["emails"]}),c&&F.invalidateQueries({queryKey:["folder-counts",c]}),e.contractId&&F.invalidateQueries({queryKey:["contract-folder-counts",e.contractId]}),Ke.success("E-Mail wiederhergestellt"),j(!1),o==null||o()},onError:H=>{console.error("Restore error:",H),Ke.error(H.message||"Fehler beim Wiederherstellen der E-Mail"),j(!1)}}),_=G({mutationFn:()=>Me.permanentDelete(e.id),onSuccess:()=>{F.invalidateQueries({queryKey:["emails"]}),c&&F.invalidateQueries({queryKey:["folder-counts",c]}),Ke.success("E-Mail endgültig gelöscht"),v(!1),r==null||r()},onError:H=>{console.error("Permanent delete error:",H),Ke.error(H.message||"Fehler beim endgültigen Löschen der E-Mail"),v(!1)}}),$=H=>new Date(H).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}),L=H=>{try{return JSON.parse(H)}catch{return[]}},A=H=>{if(!H)return[];try{return JSON.parse(H)}catch{return[]}},K=L(e.toAddresses),B=e.ccAddresses?L(e.ccAddresses):[],J=A(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(I,{variant:"secondary",size:"sm",onClick:()=>j(!0),title:"Wiederherstellen",children:[s.jsx(kv,{className:"w-4 h-4 mr-1"}),"Wiederherstellen"]}),s.jsxs(I,{variant:"danger",size:"sm",onClick:()=>v(!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:()=>E.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(ch,{className:`w-5 h-5 ${h?"fill-current":""}`})}),s.jsxs(I,{variant:"secondary",size:"sm",onClick:t,children:[s.jsx(R2,{className:"w-4 h-4 mr-1"}),"Antworten"]}),s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>k(!0),title:"E-Mail als PDF speichern",children:s.jsx(w2,{className:"w-4 h-4"})}),N("emails:delete")&&s.jsx(I,{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:$(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(lx,{className:"w-4 h-4 text-green-600"}),s.jsxs("span",{className:"text-sm text-green-800",children:["Zugeordnet zu:"," ",s.jsx(Se,{to:`/contracts/${e.contract.id}`,className:"font-medium hover:underline",children:e.contract.contractNumber})]}),!e.isAutoAssigned&&s.jsx("button",{onClick:()=>P.mutate(),className:"ml-2 p-1 hover:bg-green-100 rounded",title:"Zuordnung aufheben",children:s.jsx(Bs,{className:"w-4 h-4 text-green-600"})})]}):!i&&s.jsxs(I,{variant:"secondary",size:"sm",onClick:n,children:[s.jsx(lx,{className:"w-4 h-4 mr-1"}),"Vertrag zuordnen"]})}),J.length>0&&s.jsxs("div",{className:"pt-2",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(Ac,{className:"w-4 h-4 text-gray-400"}),s.jsxs("span",{className:"text-sm text-gray-500",children:[J.length," Anhang",J.length>1?"e":""]})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:J.map((H,S)=>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:H}),s.jsx("a",{href:Me.getAttachmentUrl(e.id,H,!0),target:"_blank",rel:"noopener noreferrer",className:"p-1 hover:bg-gray-200 rounded transition-colors",title:`${H} öffnen`,children:s.jsx(ih,{className:"w-4 h-4 text-gray-500"})}),s.jsx("a",{href:Me.getAttachmentUrl(e.id,H),download:H,className:"p-1 hover:bg-gray-200 rounded transition-colors",title:`${H} herunterladen`,children:s.jsx(zs,{className:"w-4 h-4 text-gray-500"})}),!l&&s.jsx("button",{onClick:()=>w(H),className:"p-1 hover:bg-blue-100 rounded transition-colors",title:`${H} speichern unter...`,children:s.jsx(Nv,{className:"w-4 h-4 text-blue-500"})})]},S))})]})]}),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(I,{variant:"secondary",onClick:()=>f(!1),disabled:z.isPending,children:"Abbrechen"}),s.jsx(I,{variant:"danger",onClick:()=>z.mutate(),disabled:z.isPending,children:z.isPending?"Löschen...":"Löschen"})]})]})}),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 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(I,{variant:"secondary",onClick:()=>j(!1),disabled:D.isPending,children:"Abbrechen"}),s.jsx(I,{variant:"primary",onClick:()=>D.mutate(),disabled:D.isPending,children:D.isPending?"Wird wiederhergestellt...":"Wiederherstellen"})]})]})}),y&&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(I,{variant:"secondary",onClick:()=>v(!1),disabled:_.isPending,children:"Abbrechen"}),s.jsx(I,{variant:"danger",onClick:()=>_.mutate(),disabled:_.isPending,children:_.isPending?"Wird gelöscht...":"Endgültig löschen"})]})]})}),g&&s.jsx(J2,{isOpen:!0,onClose:()=>w(null),emailId:e.id,attachmentFilename:g}),C&&s.jsx(X2,{isOpen:!0,onClose:()=>k(!1),emailId:e.id})]})}function Ev({isOpen:e,onClose:t,account:n,replyTo:r,onSuccess:a,contractId:i}){const[l,o]=b.useState(""),[c,d]=b.useState(""),[u,h]=b.useState(""),[p,m]=b.useState(""),[f,x]=b.useState([]),[j,y]=b.useState(null),v=b.useRef(null);b.useEffect(()=>{if(e){if(r){o(r.fromAddress||"");const D=r.subject||"",_=/^(Re|Aw|Fwd|Wg):\s*/i.test(D);h(_?D:`Re: ${D}`);const $=new Date(r.receivedAt).toLocaleString("de-DE"),L=r.textBody?`
--- Ursprüngliche Nachricht ---
Von: ${r.fromName||r.fromAddress}
Am: ${$}
${r.textBody}`:"";m(L)}else o(""),h(""),m("");d(""),x([]),y(null)}},[e,r]);const g=10*1024*1024,w=25*1024*1024,C=D=>new Promise((_,$)=>{const L=new FileReader;L.readAsDataURL(D),L.onload=()=>{const K=L.result.split(",")[1];_(K)},L.onerror=$}),k=async D=>{const _=D.target.files;if(!_)return;const $=[];let L=f.reduce((A,K)=>A+K.content.length*.75,0);for(const A of Array.from(_)){if(A.size>g){y(`Datei "${A.name}" ist zu groß (max. 10 MB)`);continue}if(L+A.size>w){y("Maximale Gesamtgröße der Anhänge erreicht (25 MB)");break}try{const K=await C(A);$.push({filename:A.name,content:K,contentType:A.type||"application/octet-stream"}),L+=A.size}catch{y(`Fehler beim Lesen von "${A.name}"`)}}$.length>0&&x(A=>[...A,...$]),v.current&&(v.current.value="")},F=D=>{x(_=>_.filter(($,L)=>L!==D))},N=D=>{const _=D.length*.75;return _<1024?`${Math.round(_)} B`:_<1024*1024?`${(_/1024).toFixed(1)} KB`:`${(_/(1024*1024)).toFixed(1)} MB`},E=G({mutationFn:()=>cs.sendEmail(n.id,{to:l.split(",").map(D=>D.trim()).filter(Boolean),cc:c?c.split(",").map(D=>D.trim()).filter(Boolean):void 0,subject:u,text:p,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(),P()},onError:D=>{y(D instanceof Error?D.message:"Fehler beim Senden")}}),P=()=>{t()},z=()=>{if(!l.trim()){y("Bitte Empfänger angeben");return}if(!u.trim()){y("Bitte Betreff angeben");return}y(null),E.mutate()};return s.jsx(Ge,{isOpen:e,onClose:P,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:D=>o(D.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:D=>d(D.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:D=>h(D.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:p,onChange:D=>m(D.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:v,onChange:k,multiple:!0,className:"hidden"}),s.jsxs("button",{type:"button",onClick:()=>{var D;return(D=v.current)==null?void 0:D.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(Ac,{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((D,_)=>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(He,{className:"w-4 h-4 text-gray-500 mr-2 flex-shrink-0"}),s.jsx("span",{className:"text-sm text-gray-700 truncate",children:D.filename}),s.jsxs("span",{className:"ml-2 text-xs text-gray-500 flex-shrink-0",children:["(",N(D.content),")"]})]}),s.jsx("button",{type:"button",onClick:()=>F(_),className:"ml-2 p-1 text-gray-400 hover:text-red-500 transition-colors",title:"Anhang entfernen",children:s.jsx(Bs,{className:"w-4 h-4"})})]},_))}),s.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Max. 10 MB pro Datei, 25 MB gesamt"})]}),j&&s.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700",children:j}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[s.jsx(I,{variant:"secondary",onClick:P,children:"Abbrechen"}),s.jsxs(I,{onClick:z,disabled:E.isPending,children:[s.jsx(El,{className:"w-4 h-4 mr-2"}),E.isPending?"Wird gesendet...":"Senden"]})]})]})})}function Y2({isOpen:e,onClose:t,email:n,customerId:r,onSuccess:a}){const[i,l]=b.useState(""),[o,c]=b.useState(null),d=xe(),{data:u,isLoading:h}=me({queryKey:["contracts","customer",r],queryFn:()=>ze.getAll({customerId:r}),enabled:e}),m=((u==null?void 0:u.data)||[]).filter(v=>{var w,C,k,F;if(!i)return!0;const g=i.toLowerCase();return v.contractNumber.toLowerCase().includes(g)||((C=(w=v.contractCategory)==null?void 0:w.name)==null?void 0:C.toLowerCase().includes(g))||((F=(k=v.provider)==null?void 0:k.name)==null?void 0:F.toLowerCase().includes(g))}),f=G({mutationFn:v=>Me.assignToContract(n.id,v),onSuccess:(v,g)=>{d.invalidateQueries({queryKey:["emails"]}),d.invalidateQueries({queryKey:["email",n.id]}),d.invalidateQueries({queryKey:["contract-folder-counts",g]}),a==null||a(),x()}}),x=()=>{l(""),c(null),t()},j=()=>{o&&f.mutate(o)},y=v=>v?new Date(v).toLocaleDateString("de-DE"):"-";return s.jsx(Ge,{isOpen:e,onClose:x,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(Cl,{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:v=>l(v.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(He,{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(v=>{var g;return s.jsx("div",{onClick:()=>c(v.id),className:`
flex items-center gap-3 p-3 cursor-pointer transition-colors
${o===v.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:v.contractNumber}),s.jsx("span",{className:`
px-2 py-0.5 text-xs rounded-full
${v.status==="ACTIVE"?"bg-green-100 text-green-800":v.status==="PENDING"?"bg-yellow-100 text-yellow-800":v.status==="CANCELLED"?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"}
`,children:v.status})]}),s.jsxs("div",{className:"text-sm text-gray-600 truncate",children:[(g=v.contractCategory)==null?void 0:g.name,v.provider&&` - ${v.provider.name}`]}),s.jsxs("div",{className:"text-xs text-gray-500",children:["Start: ",y(v.startDate)]})]})},v.id)})})}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[s.jsx(I,{variant:"secondary",onClick:x,children:"Abbrechen"}),s.jsx(I,{onClick:j,disabled:!o||f.isPending,children:f.isPending?"Wird zugeordnet...":"Zuordnen"})]})]})})}function Dv({emails:e,selectedEmailId:t,onSelectEmail:n,onEmailRestored:r,onEmailDeleted:a,isLoading:i}){const[l,o]=b.useState(null),[c,d]=b.useState(null),u=xe(),h=k=>{if(k.folder==="SENT")try{const F=JSON.parse(k.toAddresses);if(F.length>0)return`An: ${F[0]}${F.length>1?` (+${F.length-1})`:""}`}catch{return"An: (Unbekannt)"}return k.fromName||k.fromAddress},p=G({mutationFn:k=>Me.restore(k),onSuccess:(k,F)=>{u.invalidateQueries({queryKey:["emails"]}),Ke.success("E-Mail wiederhergestellt"),o(null),d(null),r==null||r(F)},onError:k=>{console.error("Restore error:",k),Ke.error(k.message||"Fehler beim Wiederherstellen"),o(null),d(null)}}),m=G({mutationFn:k=>Me.permanentDelete(k),onSuccess:(k,F)=>{u.invalidateQueries({queryKey:["emails"]}),Ke.success("E-Mail endgültig gelöscht"),o(null),d(null),a==null||a(F)},onError:k=>{console.error("Permanent delete error:",k),Ke.error(k.message||"Fehler beim endgültigen Löschen"),o(null),d(null)}}),f=G({mutationFn:k=>Me.unassignFromContract(k),onSuccess:()=>{u.invalidateQueries({queryKey:["emails"]}),Ke.success("Vertragszuordnung aufgehoben")},onError:k=>{console.error("Unassign error:",k),Ke.error(k.message||"Fehler beim Aufheben der Zuordnung")}}),x=(k,F)=>{k.stopPropagation(),f.mutate(F)},j=(k,F)=>{k.stopPropagation(),o(F),d("restore")},y=(k,F)=>{k.stopPropagation(),o(F),d("delete")},v=k=>{k.stopPropagation(),l&&c&&(c==="restore"?p.mutate(l):m.mutate(l))},g=k=>{k.stopPropagation(),o(null),d(null)},w=k=>new Date(k).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"}),C=k=>{if(!k)return"";const F=new Date(k),N=new Date;return F.toDateString()===N.toDateString()?`Gelöscht um ${F.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"})}`:`Gelöscht am ${F.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(k=>s.jsxs("div",{onClick:()=>n(k),className:["flex items-start gap-3 p-3 cursor-pointer transition-colors",t===k.id?"bg-red-100":"hover:bg-gray-100 bg-gray-50/50"].join(" "),style:{borderLeft:t===k.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:k.folder==="SENT"?"Aus Gesendet":"Aus Posteingang",children:k.folder==="SENT"?s.jsx(El,{className:"w-4 h-4"}):s.jsx($r,{className:"w-4 h-4"})}),s.jsx("button",{onClick:F=>j(F,k.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(kv,{className:"w-4 h-4"})}),s.jsx("button",{onClick:F=>y(F,k.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(k)}),s.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:w(k.receivedAt)})]}),s.jsx("div",{className:"text-sm truncate text-gray-600",children:k.subject||"(Kein Betreff)"}),s.jsx("div",{className:"text-xs text-red-500 mt-1",children:C(k.deletedAt)}),k.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:k.contract.contractNumber}),(k.folder==="INBOX"||k.folder==="SENT"&&!k.isAutoAssigned)&&s.jsx("button",{onClick:F=>x(F,k.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(Bs,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(Mt,{className:"w-4 h-4 text-gray-400 flex-shrink-0 mt-2"})]},k.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(I,{variant:"secondary",onClick:g,disabled:p.isPending||m.isPending,children:"Abbrechen"}),s.jsx(I,{variant:c==="restore"?"primary":"danger",onClick:v,disabled:p.isPending||m.isPending,children:p.isPending||m.isPending?"Wird ausgeführt...":c==="restore"?"Wiederherstellen":"Endgültig löschen"})]})]})})]})}function ek({customerId:e}){const[t,n]=b.useState(null),[r,a]=b.useState("INBOX"),[i,l]=b.useState(null),[o,c]=b.useState(!1),[d,u]=b.useState(!1),[h,p]=b.useState(null),m=xe(),{hasPermission:f}=qe(),x=f("emails:delete"),{data:j,isLoading:y}=me({queryKey:["mailbox-accounts",e],queryFn:()=>Me.getMailboxAccounts(e)}),v=(j==null?void 0:j.data)||[];b.useEffect(()=>{v.length>0&&!t&&n(v[0].id)},[v,t]);const g=v.find(oe=>oe.id===t),{data:w,isLoading:C,refetch:k}=me({queryKey:["emails","customer",e,t,r],queryFn:()=>Me.getForCustomer(e,{accountId:t||void 0,folder:r}),enabled:!!t&&r!=="TRASH"}),F=(w==null?void 0:w.data)||[],{data:N,isLoading:E}=me({queryKey:["emails","trash",e],queryFn:()=>Me.getTrash(e),enabled:r==="TRASH"&&x}),P=(N==null?void 0:N.data)||[],{data:z}=me({queryKey:["folder-counts",t],queryFn:()=>cs.getFolderCounts(t),enabled:!!t}),D=(z==null?void 0:z.data)||{inbox:0,inboxUnread:0,sent:0,sentUnread:0,trash:0,trashUnread:0},{data:_}=me({queryKey:["email",i==null?void 0:i.id],queryFn:()=>Me.getById(i.id),enabled:!!(i!=null&&i.id)}),$=(_==null?void 0:_.data)||i,L=G({mutationFn:oe=>cs.syncEmails(oe),onSuccess:()=>{m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["folder-counts",t]}),m.invalidateQueries({queryKey:["mailbox-accounts",e]})}}),A=()=>{t&&L.mutate(t)},K=oe=>{l(oe)},B=()=>{p($||null),c(!0)},J=()=>{p(null),c(!0)},H=()=>{u(!0)};if(!y&&v.length===0)return s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(tn,{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 S=oe=>{a(oe),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:[v.length>1?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($r,{className:"w-5 h-5 text-gray-500"}),s.jsx("select",{value:t||"",onChange:oe=>{n(Number(oe.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:v.map(oe=>s.jsx("option",{value:oe.id,children:oe.email},oe.id))})]}):s.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-600",children:[s.jsx($r,{className:"w-5 h-5 text-gray-500"}),s.jsx("span",{children:g==null?void 0:g.email})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-gray-200 rounded-lg p-1",children:[s.jsxs("button",{onClick:()=>S("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($r,{className:"w-4 h-4"}),"Posteingang",D.inbox>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${D.inboxUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${D.inboxUnread} ungelesen / ${D.inbox} gesamt`,children:D.inboxUnread>0?`${D.inboxUnread}/${D.inbox}`:D.inbox})]}),s.jsxs("button",{onClick:()=>S("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(El,{className:"w-4 h-4"}),"Gesendet",D.sent>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${D.sentUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${D.sentUnread} ungelesen / ${D.sent} gesamt`,children:D.sentUnread>0?`${D.sentUnread}/${D.sent}`:D.sent})]}),x&&s.jsxs("button",{onClick:()=>S("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",D.trash>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${D.trashUnread>0?"bg-red-100 text-red-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${D.trashUnread} ungelesen / ${D.trash} gesamt`,children:D.trashUnread>0?`${D.trashUnread}/${D.trash}`:D.trash})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r!=="TRASH"&&s.jsxs(I,{variant:"secondary",size:"sm",onClick:A,disabled:L.isPending||!t,children:[s.jsx(jr,{className:`w-4 h-4 mr-1 ${L.isPending?"animate-spin":""}`}),L.isPending?"Sync...":"Synchronisieren"]}),s.jsxs(I,{size:"sm",onClick:J,disabled:!g,children:[s.jsx(Ue,{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(Dv,{emails:P,selectedEmailId:i==null?void 0:i.id,onSelectEmail:K,onEmailRestored:oe=>{(i==null?void 0:i.id)===oe&&l(null),m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["folder-counts",t]})},onEmailDeleted:oe=>{(i==null?void 0:i.id)===oe&&l(null),m.invalidateQueries({queryKey:["emails","trash"]}),m.invalidateQueries({queryKey:["folder-counts",t]})},isLoading:E}):s.jsx(Z2,{emails:F,selectedEmailId:i==null?void 0:i.id,onSelectEmail:K,onEmailDeleted:oe=>{(i==null?void 0:i.id)===oe&&l(null),m.invalidateQueries({queryKey:["folder-counts",t]})},isLoading:C,folder:r,accountId:t})}),s.jsx("div",{className:"flex-1 overflow-auto",children:$?s.jsx(Cv,{email:$,onReply:B,onAssignContract:H,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(tn,{className:"w-12 h-12 mb-2 opacity-30"}),s.jsx("p",{children:"Wählen Sie eine E-Mail aus"})]})})]}),g&&s.jsx(Ev,{isOpen:o,onClose:()=>{c(!1),p(null)},account:g,replyTo:h||void 0,onSuccess:()=>{m.invalidateQueries({queryKey:["emails","customer",e,t,"SENT"]}),m.invalidateQueries({queryKey:["folder-counts",t]}),r==="SENT"&&k()}}),$&&s.jsx(Y2,{isOpen:d,onClose:()=>u(!1),email:$,customerId:e,onSuccess:()=>{k()}})]})}function tk({contractId:e,customerId:t}){const[n,r]=b.useState(null),[a,i]=b.useState("INBOX"),[l,o]=b.useState(null),[c,d]=b.useState(!1),[u,h]=b.useState(null),[p,m]=b.useState(null),f=xe(),{hasPermission:x}=qe(),j=x("emails:delete"),{data:y,isLoading:v}=me({queryKey:["mailbox-accounts",t],queryFn:()=>Me.getMailboxAccounts(t)}),g=(y==null?void 0:y.data)||[];b.useEffect(()=>{g.length>0&&!n&&r(g[0].id)},[g,n]);const w=g.find(te=>te.id===n),{data:C,isLoading:k,refetch:F}=me({queryKey:["emails","contract",e,a],queryFn:()=>Me.getForContract(e,{folder:a}),enabled:a!=="TRASH"}),N=(C==null?void 0:C.data)||[],{data:E,isLoading:P}=me({queryKey:["emails","trash",t],queryFn:()=>Me.getTrash(t),enabled:a==="TRASH"&&j}),z=(E==null?void 0:E.data)||[],{data:D}=me({queryKey:["contract-folder-counts",e],queryFn:()=>Me.getContractFolderCounts(e)}),_=(D==null?void 0:D.data)||{inbox:0,inboxUnread:0,sent:0,sentUnread:0},{data:$}=me({queryKey:["folder-counts",n],queryFn:()=>cs.getFolderCounts(n),enabled:!!n&&j}),L=($==null?void 0:$.data)||{trash:0,trashUnread:0},{data:A}=me({queryKey:["email",l==null?void 0:l.id],queryFn:()=>Me.getById(l.id),enabled:!!(l!=null&&l.id)}),K=(A==null?void 0:A.data)||l,B=G({mutationFn:te=>cs.syncEmails(te),onSuccess:()=>{f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]}),Ke.success("Synchronisation abgeschlossen")},onError:te=>{Ke.error(te.message||"Synchronisation fehlgeschlagen")}}),J=G({mutationFn:te=>Me.toggleStar(te),onSuccess:(te,ge)=>{f.invalidateQueries({queryKey:["emails","contract",e]}),f.invalidateQueries({queryKey:["email",ge]})}}),H=G({mutationFn:({emailId:te,isRead:ge})=>Me.markAsRead(te,ge),onSuccess:(te,ge)=>{f.invalidateQueries({queryKey:["emails","contract",e]}),f.invalidateQueries({queryKey:["email",ge.emailId]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]})}}),S=G({mutationFn:te=>Me.unassignFromContract(te),onSuccess:()=>{f.invalidateQueries({queryKey:["emails","contract",e]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),o(null),Ke.success("Zuordnung aufgehoben")},onError:te=>{Ke.error(te.message||"Fehler beim Aufheben der Zuordnung")}}),oe=G({mutationFn:te=>Me.delete(te),onSuccess:(te,ge)=>{f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),n&&f.invalidateQueries({queryKey:["folder-counts",n]}),Ke.success("E-Mail in Papierkorb verschoben"),m(null),(l==null?void 0:l.id)===ge&&o(null)},onError:te=>{Ke.error(te.message||"Fehler beim Löschen der E-Mail"),m(null)}}),Ve=()=>{n&&B.mutate(n)},Fe=te=>{const ge=new Date(te),Vs=new Date;return ge.toDateString()===Vs.toDateString()?ge.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}):ge.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})},Ye=(te,ge)=>{te.stopPropagation(),J.mutate(ge)},Ze=(te,ge)=>{te.stopPropagation(),H.mutate({emailId:ge.id,isRead:!ge.isRead})},xt=te=>{te.isRead||H.mutate({emailId:te.id,isRead:!0}),o(te)},W=()=>{h(K||null),d(!0)},Ae=()=>{h(null),d(!0)},Z=(te,ge)=>{te.stopPropagation(),(l==null?void 0:l.id)===ge&&o(null),S.mutate(ge)},Te=(te,ge)=>{te.stopPropagation(),m(ge)},it=te=>{te.stopPropagation(),p&&oe.mutate(p)},xs=te=>{te.stopPropagation(),m(null)},Ds=te=>{i(te),o(null)},ln=te=>{if(a==="SENT")try{const ge=JSON.parse(te.toAddresses);if(ge.length>0)return`An: ${ge[0]}${ge.length>1?` (+${ge.length-1})`:""}`}catch{return"An: (Unbekannt)"}return te.fromName||te.fromAddress};return!v&&g.length===0?s.jsx(Y,{title:"E-Mails",children:s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[s.jsx(tn,{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(Y,{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(I,{variant:"secondary",size:"sm",onClick:Ve,disabled:B.isPending||!n,children:[s.jsx(jr,{className:`w-4 h-4 mr-1 ${B.isPending?"animate-spin":""}`}),B.isPending?"Sync...":"Sync"]}),w&&s.jsxs(I,{size:"sm",onClick:Ae,children:[s.jsx(Ue,{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:[g.length>1?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($r,{className:"w-4 h-4 text-gray-500"}),s.jsx("select",{value:n||"",onChange:te=>{r(Number(te.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:g.map(te=>s.jsx("option",{value:te.id,children:te.email},te.id))})]}):s.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[s.jsx($r,{className:"w-4 h-4 text-gray-500"}),s.jsx("span",{children:w==null?void 0:w.email})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-gray-200 rounded-lg p-1",children:[s.jsxs("button",{onClick:()=>Ds("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($r,{className:"w-4 h-4"}),"Posteingang",_.inbox>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${_.inboxUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${_.inboxUnread} ungelesen / ${_.inbox} gesamt`,children:_.inboxUnread>0?`${_.inboxUnread}/${_.inbox}`:_.inbox})]}),s.jsxs("button",{onClick:()=>Ds("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(El,{className:"w-4 h-4"}),"Gesendet",_.sent>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${_.sentUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${_.sentUnread} ungelesen / ${_.sent} gesamt`,children:_.sentUnread>0?`${_.sentUnread}/${_.sent}`:_.sent})]}),j&&s.jsxs("button",{onClick:()=>Ds("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",L.trash>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${L.trashUnread>0?"bg-red-100 text-red-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${L.trashUnread} ungelesen / ${L.trash} gesamt`,children:L.trashUnread>0?`${L.trashUnread}/${L.trash}`:L.trash})]})]})]}),(a==="TRASH"?P:k)?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"?z.length===0:N.length===0)?s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[s.jsx(tn,{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(Dv,{emails:z,selectedEmailId:l==null?void 0:l.id,onSelectEmail:xt,onEmailRestored:te=>{(l==null?void 0:l.id)===te&&o(null),f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["folder-counts",n]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]})},onEmailDeleted:te=>{(l==null?void 0:l.id)===te&&o(null),f.invalidateQueries({queryKey:["emails","trash"]}),f.invalidateQueries({queryKey:["folder-counts",n]})},isLoading:P}):s.jsx("div",{className:"divide-y divide-gray-200",children:N.map(te=>s.jsxs("div",{onClick:()=>xt(te),className:["flex items-start gap-2 p-3 cursor-pointer transition-colors",(l==null?void 0:l.id)===te.id?"bg-blue-100":["hover:bg-gray-100",te.isRead?"bg-gray-50/50":"bg-white"].join(" ")].join(" "),style:{borderLeft:(l==null?void 0:l.id)===te.id?"4px solid #2563eb":"4px solid transparent"},children:[s.jsx("button",{onClick:ge=>Ze(ge,te),className:`
flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200
${te.isRead?"text-gray-400":"text-blue-600"}
`,title:te.isRead?"Als ungelesen markieren":"Als gelesen markieren",children:te.isRead?s.jsx(bv,{className:"w-4 h-4"}):s.jsx(tn,{className:"w-4 h-4"})}),s.jsx("button",{onClick:ge=>Ye(ge,te.id),className:`
flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200
${te.isStarred?"text-yellow-500":"text-gray-400"}
`,title:te.isStarred?"Stern entfernen":"Als wichtig markieren",children:s.jsx(ch,{className:`w-4 h-4 ${te.isStarred?"fill-current":""}`})}),x("emails:delete")&&s.jsx("button",{onClick:ge=>Te(ge,te.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 ${te.isRead?"text-gray-700":"font-semibold text-gray-900"}`,children:ln(te)}),s.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:Fe(te.receivedAt)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-sm truncate ${te.isRead?"text-gray-600":"font-medium text-gray-900"}`,children:te.subject||"(Kein Betreff)"}),te.hasAttachments&&s.jsx(Ac,{className:"w-3 h-3 text-gray-400 flex-shrink-0"})]}),te.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:te.contract.contractNumber}),(a==="INBOX"||a==="SENT"&&!te.isAutoAssigned)&&s.jsx("button",{onClick:ge=>Z(ge,te.id),className:"p-0.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded",title:"Zuordnung aufheben",disabled:S.isPending,children:s.jsx(Bs,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(Mt,{className:"w-4 h-4 text-gray-400 flex-shrink-0 mt-2"})]},te.id))})}),s.jsx("div",{className:"flex-1 overflow-auto",children:K&&l?s.jsx(Cv,{email:K,onReply:W,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(tn,{className:"w-12 h-12 mb-2 opacity-30"}),s.jsx("p",{children:"Wählen Sie eine E-Mail aus"})]})})]}),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 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(I,{variant:"secondary",onClick:xs,disabled:oe.isPending,children:"Abbrechen"}),s.jsx(I,{variant:"danger",onClick:it,disabled:oe.isPending,children:oe.isPending?"Löschen...":"Löschen"})]})]})}),w&&s.jsx(Ev,{isOpen:c,onClose:()=>{d(!1),h(null)},account:w,replyTo:u||void 0,contractId:e,onSuccess:()=>{f.invalidateQueries({queryKey:["emails","contract",e,"SENT"]}),f.invalidateQueries({queryKey:["contract-folder-counts",e]}),a==="SENT"&&F()}})]})}function sk({tabs:e,defaultTab:t}){var a,i;const[n,r]=b.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})]})}const _e=b.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})]})});_e.displayName="Select";function Ct({onUpload:e,existingFile:t,accept:n=".pdf,.jpg,.jpeg,.png",label:r="Dokument hochladen",disabled:a=!1}){const i=b.useRef(null),[l,o]=b.useState(!1),[c,d]=b.useState(!1),u=async x=>{if(x){o(!0);try{await e(x)}catch(j){console.error("Upload failed:",j),alert("Upload fehlgeschlagen")}finally{o(!1)}}},h=x=>{var y;const j=(y=x.target.files)==null?void 0:y[0];j&&u(j)},p=x=>{var y;x.preventDefault(),d(!1);const j=(y=x.dataTransfer.files)==null?void 0:y[0];j&&u(j)},m=x=>{x.preventDefault(),d(!0)},f=()=>{d(!1)};return s.jsxs("div",{className:"space-y-2",children:[t?!a&&s.jsx(I,{variant:"secondary",size:"sm",onClick:()=>{var x;return(x=i.current)==null?void 0:x.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 x;return!a&&((x=i.current)==null?void 0:x.click())},onDrop:a?void 0:p,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(Bu,{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 ce({value:e,className:t="",size:n="sm",title:r="In Zwischenablage kopieren"}){const[a,i]=b.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(Ga,{className:o}):s.jsx(rh,{className:o})})}function qu({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(ce,{value:a,className:"absolute top-0 right-0 opacity-60 group-hover:opacity-100",title:"Alles kopieren"})]}):s.jsx(s.Fragment,{children:n})}function nk(){var B,J;const{id:e}=yc(),t=Gt(),n=xe(),{hasPermission:r}=qe(),[a]=jc(),i=parseInt(e),l=a.get("tab")||"addresses",[o,c]=b.useState(!1),[d,u]=b.useState(!1),[h,p]=b.useState(!1),[m,f]=b.useState(!1),[x,j]=b.useState(!1),[y,v]=b.useState(!1),[g,w]=b.useState(null),[C,k]=b.useState(null),[F,N]=b.useState(null),[E,P]=b.useState(null),[z,D]=b.useState(null),{data:_,isLoading:$}=me({queryKey:["customer",e],queryFn:()=>Et.getById(i)}),L=G({mutationFn:()=>Et.delete(i),onSuccess:()=>{t("/customers")}});if($)return s.jsx("div",{className:"text-center py-8",children:"Laden..."});if(!(_!=null&&_.data))return s.jsx("div",{className:"text-center py-8 text-red-600",children:"Kunde nicht gefunden"});const A=_.data,K=[{id:"addresses",label:"Adressen",content:s.jsx(ik,{customerId:i,addresses:A.addresses||[],canEdit:r("customers:update"),onAdd:()=>c(!0),onEdit:H=>N(H)})},{id:"bankcards",label:"Bankkarten",content:s.jsx(lk,{customerId:i,bankCards:A.bankCards||[],canEdit:r("customers:update"),showInactive:y,onToggleInactive:()=>v(!y),onAdd:()=>u(!0),onEdit:H=>w(H)})},{id:"documents",label:"Ausweise",content:s.jsx(ok,{customerId:i,documents:A.identityDocuments||[],canEdit:r("customers:update"),showInactive:y,onToggleInactive:()=>v(!y),onAdd:()=>p(!0),onEdit:H=>k(H)})},{id:"meters",label:"Zähler",content:s.jsx(ck,{customerId:i,meters:A.meters||[],canEdit:r("customers:update"),showInactive:y,onToggleInactive:()=>v(!y),onAdd:()=>f(!0),onEdit:H=>P(H)})},{id:"stressfrei",label:"Stressfrei-Wechseln",content:s.jsx(hk,{customerId:i,emails:A.stressfreiEmails||[],canEdit:r("customers:update"),showInactive:y,onToggleInactive:()=>v(!y),onAdd:()=>j(!0),onEdit:H=>D(H)})},{id:"emails",label:"E-Mail-Postfach",content:s.jsx(ek,{customerId:i})},{id:"contracts",label:"Verträge",content:s.jsx(dk,{customerId:i})},...r("customers:update")?[{id:"portal",label:"Portal",content:s.jsx(mk,{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:A.type==="BUSINESS"&&A.companyName?A.companyName:`${A.firstName} ${A.lastName}`}),s.jsxs("p",{className:"text-gray-500 font-mono flex items-center gap-1",children:[A.customerNumber,s.jsx(ce,{value:A.customerNumber})]})]}),s.jsxs("div",{className:"flex gap-2",children:[r("customers:update")&&s.jsx(Se,{to:`/customers/${e}/edit`,children:s.jsxs(I,{variant:"secondary",children:[s.jsx(at,{className:"w-4 h-4 mr-2"}),"Bearbeiten"]})}),r("customers:delete")&&s.jsxs(I,{variant:"danger",onClick:()=>{confirm("Kunde wirklich löschen?")&&L.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(Y,{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(ye,{variant:A.type==="BUSINESS"?"info":"default",children:A.type==="BUSINESS"?"Geschäftskunde":"Privatkunde"})})]}),A.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:[A.salutation,s.jsx(ce,{value:A.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:[A.firstName,s.jsx(ce,{value:A.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:[A.lastName,s.jsx(ce,{value:A.lastName})]})]}),A.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:[A.companyName,s.jsx(ce,{value:A.companyName})]})]}),A.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(A.foundingDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}),s.jsx(ce,{value:new Date(A.foundingDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]})]}),A.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(A.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}),s.jsx(ce,{value:new Date(A.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]})]}),A.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:[A.birthPlace,s.jsx(ce,{value:A.birthPlace})]})]})]})}),s.jsx(Y,{title:"Kontakt",children:s.jsxs("dl",{className:"space-y-3",children:[A.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:${A.email}`,className:"text-blue-600 hover:underline",children:A.email}),s.jsx(ce,{value:A.email})]})]}),A.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:${A.phone}`,className:"text-blue-600 hover:underline",children:A.phone}),s.jsx(ce,{value:A.phone})]})]}),A.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:${A.mobile}`,className:"text-blue-600 hover:underline",children:A.mobile}),s.jsx(ce,{value:A.mobile})]})]})]})})]}),A.type==="BUSINESS"&&s.jsx(rk,{customer:A,canEdit:r("customers:update"),onUpdate:()=>n.invalidateQueries({queryKey:["customer",e]})}),s.jsx(ak,{customer:A,canEdit:r("customers:update"),onUpdate:()=>n.invalidateQueries({queryKey:["customer",e]})}),A.notes&&s.jsx(Y,{title:"Notizen",className:"mb-6",children:s.jsx("p",{className:"whitespace-pre-wrap",children:A.notes})}),s.jsx(Y,{children:s.jsx(sk,{tabs:K,defaultTab:l})}),s.jsx(cx,{isOpen:o,onClose:()=>c(!1),customerId:i}),s.jsx(cx,{isOpen:!!F,onClose:()=>N(null),customerId:i,address:F}),s.jsx(dx,{isOpen:d,onClose:()=>u(!1),customerId:i}),s.jsx(dx,{isOpen:!!g,onClose:()=>w(null),customerId:i,bankCard:g}),s.jsx(ux,{isOpen:h,onClose:()=>p(!1),customerId:i}),s.jsx(ux,{isOpen:!!C,onClose:()=>k(null),customerId:i,document:C}),s.jsx(mx,{isOpen:m,onClose:()=>f(!1),customerId:i}),s.jsx(mx,{isOpen:!!E,onClose:()=>P(null),customerId:i,meter:E}),s.jsx(fx,{isOpen:x,onClose:()=>j(!1),customerId:i,customerEmail:(B=_==null?void 0:_.data)==null?void 0:B.email}),s.jsx(fx,{isOpen:!!z,onClose:()=>D(null),customerId:i,email:z,customerEmail:(J=_==null?void 0:_.data)==null?void 0:J.email})]})}function rk({customer:e,canEdit:t,onUpdate:n}){const r=async c=>{try{await dt.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 dt.deleteBusinessRegistration(e.id),n()}catch(c){console.error("Löschen fehlgeschlagen:",c),alert("Löschen fehlgeschlagen")}},i=async c=>{try{await dt.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 dt.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(Y,{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(ce,{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(ce,{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(De,{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(zs,{className:"w-4 h-4"}),"Download"]}),t&&s.jsxs(s.Fragment,{children:[s.jsx(Ct,{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(Ct,{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(De,{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(zs,{className:"w-4 h-4"}),"Download"]}),t&&s.jsxs(s.Fragment,{children:[s.jsx(Ct,{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(Ct,{onUpload:i,accept:".pdf",label:"PDF hochladen"}):s.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]})]})]})}function ak({customer:e,canEdit:t,onUpdate:n}){const r=async i=>{try{await dt.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 dt.deletePrivacyPolicy(e.id),n()}catch(i){console.error("Löschen fehlgeschlagen:",i),alert("Löschen fehlgeschlagen")}};return!e.privacyPolicyPath&&!t?null:s.jsx(Y,{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(De,{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(zs,{className:"w-4 h-4"}),"Download"]}),t&&s.jsxs(s.Fragment,{children:[s.jsx(Ct,{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(Ct,{onUpload:r,accept:".pdf",label:"PDF hochladen"}):s.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]})})}function ik({customerId:e,addresses:t,canEdit:n,onAdd:r,onEdit:a}){const i=xe(),l=G({mutationFn:Uu.delete,onSuccess:()=>i.invalidateQueries({queryKey:["customer",e.toString()]})});return s.jsxs("div",{children:[n&&s.jsx("div",{className:"mb-4",children:s.jsxs(I,{size:"sm",onClick:r,children:[s.jsx(Ue,{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(M2,{className:"w-4 h-4 text-gray-400"}),s.jsx(ye,{variant:o.type==="BILLING"?"info":"default",children:o.type==="BILLING"?"Rechnung":"Liefer-/Meldeadresse"}),o.isDefault&&s.jsx(ye,{variant:"success",children:"Standard"})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>a(o),title:"Bearbeiten",children:s.jsx(at,{className:"w-4 h-4"})}),s.jsx(I,{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(qu,{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 lk({customerId:e,bankCards:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=xe(),c=G({mutationFn:({id:m,data:f})=>Zo.update(m,f),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=G({mutationFn:Zo.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),u=async(m,f)=>{try{await dt.uploadBankCardDocument(m,f),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(x){console.error("Upload fehlgeschlagen:",x),alert("Upload fehlgeschlagen")}},h=async m=>{if(confirm("Dokument wirklich löschen?"))try{await dt.deleteBankCardDocument(m),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(f){console.error("Löschen fehlgeschlagen:",f),alert("Löschen fehlgeschlagen")}},p=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(I,{size:"sm",onClick:i,children:[s.jsx(Ue,{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"]})]}),p.length>0?s.jsx("div",{className:"space-y-4",children:p.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(ah,{className:"w-4 h-4 text-gray-400"}),!m.isActive&&s.jsx(ye,{variant:"danger",children:"Inaktiv"}),m.expiryDate&&new Date(m.expiryDate)<new Date&&s.jsx(ye,{variant:"warning",children:"Abgelaufen"})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>l(m),title:"Bearbeiten",children:s.jsx(at,{className:"w-4 h-4"})}),m.isActive?s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte deaktivieren?")&&c.mutate({id:m.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(Ft,{className:"w-4 h-4"})}):s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte wieder aktivieren?")&&c.mutate({id:m.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(De,{className:"w-4 h-4"})}),s.jsx(I,{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(ce,{value:m.accountHolder})]}),s.jsxs("p",{className:"font-mono flex items-center gap-1",children:[m.iban,s.jsx(ce,{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(ce,{value:m.bic})]}),m.bankName&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:[m.bankName,s.jsx(ce,{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(De,{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(zs,{className:"w-4 h-4"}),"Download"]}),n&&s.jsxs(s.Fragment,{children:[s.jsx(Ct,{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(Ct,{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 ok({customerId:e,documents:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=xe(),c=G({mutationFn:({id:f,data:x})=>Jo.update(f,x),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=G({mutationFn:Jo.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),u=async(f,x)=>{try{await dt.uploadIdentityDocument(f,x),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(j){console.error("Upload fehlgeschlagen:",j),alert("Upload fehlgeschlagen")}},h=async f=>{if(confirm("Dokument wirklich löschen?"))try{await dt.deleteIdentityDocument(f),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(x){console.error("Löschen fehlgeschlagen:",x),alert("Löschen fehlgeschlagen")}},p=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(I,{size:"sm",onClick:i,children:[s.jsx(Ue,{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"]})]}),p.length>0?s.jsx("div",{className:"space-y-4",children:p.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(He,{className:"w-4 h-4 text-gray-400"}),s.jsx(ye,{children:m[f.type]}),!f.isActive&&s.jsx(ye,{variant:"danger",children:"Inaktiv"}),f.expiryDate&&new Date(f.expiryDate)<new Date&&s.jsx(ye,{variant:"warning",children:"Abgelaufen"})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>l(f),title:"Bearbeiten",children:s.jsx(at,{className:"w-4 h-4"})}),f.isActive?s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis deaktivieren?")&&c.mutate({id:f.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(Ft,{className:"w-4 h-4"})}):s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis wieder aktivieren?")&&c.mutate({id:f.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(De,{className:"w-4 h-4"})}),s.jsx(I,{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(ce,{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(ce,{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(ce,{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(De,{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(zs,{className:"w-4 h-4"}),"Download"]}),n&&s.jsxs(s.Fragment,{children:[s.jsx(Ct,{onUpload:x=>u(f.id,x),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(Ct,{onUpload:x=>u(f.id,x),accept:".pdf",label:"PDF hochladen"})})]},f.id))}):s.jsx("p",{className:"text-gray-500",children:"Keine Ausweise vorhanden."})]})}function ck({customerId:e,meters:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const[o,c]=b.useState(null),[d,u]=b.useState(null),[h,p]=b.useState(null),m=xe(),f=G({mutationFn:({id:g,data:w})=>rn.update(g,w),onSuccess:()=>m.invalidateQueries({queryKey:["customer",e.toString()]})}),x=G({mutationFn:rn.delete,onSuccess:()=>m.invalidateQueries({queryKey:["customer",e.toString()]})}),j=G({mutationFn:({meterId:g,readingId:w})=>rn.deleteReading(g,w),onSuccess:()=>m.invalidateQueries({queryKey:["customer",e.toString()]})}),y=r?t:t.filter(g=>g.isActive),v=g=>g?[...g].sort((w,C)=>new Date(C.readingDate).getTime()-new Date(w.readingDate).getTime()):[];return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&s.jsxs(I,{size:"sm",onClick:i,children:[s.jsx(Ue,{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"]})]}),y.length>0?s.jsx("div",{className:"space-y-4",children:y.map(g=>{const w=v(g.readings),C=d===g.id;return s.jsxs("div",{className:`border rounded-lg p-4 ${g.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(vv,{className:"w-4 h-4 text-gray-400"}),s.jsx(ye,{variant:g.type==="ELECTRICITY"?"warning":"info",children:g.type==="ELECTRICITY"?"Strom":"Gas"}),!g.isActive&&s.jsx(ye,{variant:"danger",children:"Inaktiv"})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[g.isActive&&s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>c({meterId:g.id,meterType:g.type}),title:"Zählerstand hinzufügen",children:s.jsx(Ue,{className:"w-4 h-4"})}),s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>l(g),title:"Bearbeiten",children:s.jsx(at,{className:"w-4 h-4"})}),g.isActive?s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler deaktivieren?")&&f.mutate({id:g.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(Ft,{className:"w-4 h-4"})}):s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler wieder aktivieren?")&&f.mutate({id:g.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(De,{className:"w-4 h-4"})}),s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler wirklich löschen? Alle Zählerstände werden ebenfalls gelöscht.")&&x.mutate(g.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:[g.meterNumber,s.jsx(ce,{value:g.meterNumber})]}),g.location&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["Standort: ",g.location,s.jsx(ce,{value:g.location})]}),w.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:"}),w.length>3&&s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>u(C?null:g.id),children:C?"Weniger anzeigen":`Alle ${w.length} anzeigen`})]}),s.jsx("div",{className:"space-y-1",children:(C?w:w.slice(0,3)).map(k=>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(k.readingDate).toLocaleDateString("de-DE"),s.jsx(ce,{value:new Date(k.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:[k.value.toLocaleString("de-DE")," ",k.unit,s.jsx(ce,{value:k.value.toString(),title:"Nur Wert kopieren"}),s.jsx(ce,{value:`${k.value.toLocaleString("de-DE")} ${k.unit}`,title:"Mit Einheit kopieren"})]}),n&&s.jsxs("div",{className:"opacity-0 group-hover:opacity-100 flex gap-1",children:[s.jsx("button",{onClick:()=>p({meterId:g.id,meterType:g.type,reading:k}),className:"text-gray-400 hover:text-blue-600",title:"Bearbeiten",children:s.jsx(at,{className:"w-3 h-3"})}),s.jsx("button",{onClick:()=>{confirm("Zählerstand wirklich löschen?")&&j.mutate({meterId:g.id,readingId:k.id})},className:"text-gray-400 hover:text-red-600",title:"Löschen",children:s.jsx(Ne,{className:"w-3 h-3"})})]})]})]},k.id))})]})]},g.id)})}):s.jsx("p",{className:"text-gray-500",children:"Keine Zähler vorhanden."}),o&&s.jsx(hx,{isOpen:!0,onClose:()=>c(null),meterId:o.meterId,meterType:o.meterType,customerId:e}),h&&s.jsx(hx,{isOpen:!0,onClose:()=>p(null),meterId:h.meterId,meterType:h.meterType,customerId:e,reading:h.reading})]})}function dk({customerId:e}){const{hasPermission:t}=qe(),n=Gt(),r=xe(),[a,i]=b.useState(new Set),{data:l,isLoading:o}=me({queryKey:["contract-tree",e],queryFn:()=>ze.getTreeForCustomer(e)}),c=(l==null?void 0:l.data)||[],d=G({mutationFn:ze.delete,onSuccess:()=>{r.invalidateQueries({queryKey:["customer",e.toString()]}),r.invalidateQueries({queryKey:["customers"]}),r.invalidateQueries({queryKey:["contracts"]}),r.invalidateQueries({queryKey:["contract-tree",e]})},onError:x=>{alert((x==null?void 0:x.message)||"Fehler beim Löschen des Vertrags")}}),u={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},h={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"},p=x=>{i(j=>{const y=new Set(j);return y.has(x)?y.delete(x):y.add(x),y})},m=(x,j)=>x.map(y=>s.jsx("div",{children:f(y,j)},y.contract.id)),f=(x,j=0)=>{var k,F,N,E,P,z,D;const{contract:y,predecessors:v,hasHistory:g}=x,w=a.has(y.id),C=j>0;return s.jsxs("div",{children:[s.jsxs("div",{className:`
border rounded-lg p-4 transition-colors
${C?"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:[!C&&g?s.jsx("button",{onClick:()=>p(y.id),className:"p-1 hover:bg-gray-200 rounded transition-colors",title:w?"Einklappen":"Vorgänger anzeigen",children:w?s.jsx(xr,{className:"w-4 h-4 text-gray-500"}):s.jsx(Mt,{className:"w-4 h-4 text-gray-500"})}):C?null:s.jsx("div",{className:"w-6"}),s.jsxs("span",{className:"font-mono flex items-center gap-1",children:[y.contractNumber,s.jsx(ce,{value:y.contractNumber})]}),s.jsx(ye,{children:u[y.type]||y.type}),s.jsx(ye,{variant:h[y.status]||"default",children:y.status}),C&&s.jsx("span",{className:"text-xs text-gray-500 ml-2",children:"(Vorgänger)"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${y.id}`,{state:{from:"customer",customerId:e.toString()}}),title:"Ansehen",children:s.jsx(De,{className:"w-4 h-4"})}),t("contracts:update")&&s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${y.id}/edit`),title:"Bearbeiten",children:s.jsx(at,{className:"w-4 h-4"})}),t("contracts:delete")&&s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertrag wirklich löschen?")&&d.mutate(y.id)},title:"Löschen",children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})]}),(y.providerName||((k=y.provider)==null?void 0:k.name))&&s.jsxs("p",{className:`flex items-center gap-1 ${C?"ml-6":""}`,children:[y.providerName||((F=y.provider)==null?void 0:F.name),(y.tariffName||((N=y.tariff)==null?void 0:N.name))&&` - ${y.tariffName||((E=y.tariff)==null?void 0:E.name)}`,s.jsx(ce,{value:(y.providerName||((P=y.provider)==null?void 0:P.name)||"")+(y.tariffName||(z=y.tariff)!=null&&z.name?` - ${y.tariffName||((D=y.tariff)==null?void 0:D.name)}`:"")})]}),y.startDate&&s.jsxs("p",{className:`text-sm text-gray-500 ${C?"ml-6":""}`,children:["Beginn: ",new Date(y.startDate).toLocaleDateString("de-DE"),y.endDate&&` | Ende: ${new Date(y.endDate).toLocaleDateString("de-DE")}`]})]}),(j===0&&w||j>0)&&v.length>0&&s.jsx("div",{className:"mt-2",children:m(v,j+1)})]},y.id)};return o?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(Se,{to:`/contracts/new?customerId=${e}`,children:s.jsxs(I,{size:"sm",children:[s.jsx(Ue,{className:"w-4 h-4 mr-2"}),"Vertrag anlegen"]})})}),c.length>0?s.jsx("div",{className:"space-y-4",children:c.map(x=>f(x,0))}):s.jsx("p",{className:"text-gray-500",children:"Keine Verträge vorhanden."})]})}function uk({customerId:e}){const[t,n]=b.useState(!1),[r,a]=b.useState(null),[i,l]=b.useState(!1),o=async()=>{var c;if(t){n(!1);return}l(!0);try{const d=await Et.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(Ft,{className:"w-3 h-3"}),"Verbergen"]}):s.jsxs(s.Fragment,{children:[s.jsx(De,{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(ce,{value:r})]}),t&&!r&&s.jsx("span",{className:"text-xs text-gray-500",children:"(Passwort nicht verfügbar)"})]})}function mk({customerId:e,canEdit:t}){const n=xe(),[r,a]=b.useState(!1),[i,l]=b.useState(""),[o,c]=b.useState(""),[d,u]=b.useState([]),[h,p]=b.useState(!1),{data:m,isLoading:f}=me({queryKey:["customer-portal",e],queryFn:()=>Et.getPortalSettings(e)}),{data:x,isLoading:j}=me({queryKey:["customer-representatives",e],queryFn:()=>Et.getRepresentatives(e)}),y=G({mutationFn:N=>Et.updatePortalSettings(e,N),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-portal",e]})}}),v=G({mutationFn:N=>Et.setPortalPassword(e,N),onSuccess:()=>{l(""),n.invalidateQueries({queryKey:["customer-portal",e]}),alert("Passwort wurde gesetzt")},onError:N=>{alert(N.message)}}),g=G({mutationFn:N=>Et.addRepresentative(e,N),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-representatives",e]}),c(""),u([])},onError:N=>{alert(N.message)}}),w=G({mutationFn:N=>Et.removeRepresentative(e,N),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-representatives",e]})}}),C=async()=>{if(!(o.length<2)){p(!0);try{const N=await Et.searchForRepresentative(e,o);u(N.data||[])}catch(N){console.error("Suche fehlgeschlagen:",N)}finally{p(!1)}}};if(f||j)return s.jsx("div",{className:"text-center py-4 text-gray-500",children:"Laden..."});const k=m==null?void 0:m.data,F=(x==null?void 0:x.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(lh,{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:(k==null?void 0:k.portalEnabled)||!1,onChange:N=>y.mutate({portalEnabled:N.target.checked}),className:"rounded w-5 h-5",disabled:!t}),s.jsx("span",{children:"Portal aktiviert"}),(k==null?void 0:k.portalEnabled)&&s.jsx(ye,{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(V,{value:(k==null?void 0:k.portalEmail)||"",onChange:N=>y.mutate({portalEmail:N.target.value||null}),placeholder:"portal@example.com",disabled:!t||!(k!=null&&k.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."})]}),(k==null?void 0:k.portalEnabled)&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:k!=null&&k.hasPassword?"Neues Passwort setzen":"Passwort setzen"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(V,{type:r?"text":"password",value:i,onChange:N=>l(N.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(Ft,{className:"w-4 h-4"}):s.jsx(De,{className:"w-4 h-4"})})]}),s.jsx(I,{onClick:()=>v.mutate(i),disabled:!t||i.length<6||v.isPending,children:v.isPending?"Speichern...":"Setzen"})]}),(k==null?void 0:k.hasPassword)&&s.jsx(uk,{customerId:e})]}),(k==null?void 0:k.portalLastLogin)&&s.jsxs("p",{className:"text-sm text-gray-500",children:["Letzte Anmeldung: ",new Date(k.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(_2,{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(V,{value:o,onChange:N=>c(N.target.value),placeholder:"Kunden suchen (Name, Kundennummer)...",onKeyDown:N=>N.key==="Enter"&&C(),className:"flex-1"}),s.jsx(I,{variant:"secondary",onClick:C,disabled:o.length<2||h,children:s.jsx(Cl,{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(N=>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:N.companyName||`${N.firstName} ${N.lastName}`}),s.jsx("p",{className:"text-sm text-gray-500",children:N.customerNumber})]}),s.jsxs(I,{size:"sm",onClick:()=>g.mutate(N.id),disabled:g.isPending,children:[s.jsx(Ue,{className:"w-4 h-4 mr-1"}),"Hinzufügen"]})]},N.id))})]}),F.length>0?s.jsx("div",{className:"space-y-2",children:F.map(N=>{var E,P,z,D;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:((E=N.representative)==null?void 0:E.companyName)||`${(P=N.representative)==null?void 0:P.firstName} ${(z=N.representative)==null?void 0:z.lastName}`}),s.jsx("p",{className:"text-sm text-gray-500",children:(D=N.representative)==null?void 0:D.customerNumber})]}),t&&s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertreter wirklich entfernen?")&&w.mutate(N.representativeId)},children:s.jsx(Bs,{className:"w-4 h-4 text-red-500"})})]},N.id)})}):s.jsx("p",{className:"text-gray-500 text-sm",children:"Keine Vertreter konfiguriert."})]})]})}function cx({isOpen:e,onClose:t,customerId:n,address:r}){const a=xe(),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]=b.useState(l),d=G({mutationFn:m=>Uu.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=>Uu.update(r.id,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),h=m=>{m.preventDefault(),i?u.mutate(o):d.mutate(o)},p=d.isPending||u.isPending;return i&&o.street!==r.street&&c(l()),s.jsx(Ge,{isOpen:e,onClose:t,title:i?"Adresse bearbeiten":"Adresse hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(_e,{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(V,{label:"Straße",value:o.street,onChange:m=>c({...o,street:m.target.value}),required:!0})}),s.jsx(V,{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(V,{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(V,{label:"Ort",value:o.city,onChange:m=>c({...o,city:m.target.value}),required:!0})})]}),s.jsx(V,{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(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function dx({isOpen:e,onClose:t,customerId:n,bankCard:r}){const a=xe(),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]=b.useState(l);b.useState(()=>{c(l())});const d=G({mutationFn:m=>Zo.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({accountHolder:"",iban:"",bic:"",bankName:"",expiryDate:"",isActive:!0})}}),u=G({mutationFn:m=>Zo.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)},p=d.isPending||u.isPending;return i&&o.iban!==r.iban&&c(l()),s.jsx(Ge,{isOpen:e,onClose:t,title:i?"Bankkarte bearbeiten":"Bankkarte hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(V,{label:"Kontoinhaber",value:o.accountHolder,onChange:m=>c({...o,accountHolder:m.target.value}),required:!0}),s.jsx(V,{label:"IBAN",value:o.iban,onChange:m=>c({...o,iban:m.target.value}),required:!0}),s.jsx(V,{label:"BIC",value:o.bic,onChange:m=>c({...o,bic:m.target.value})}),s.jsx(V,{label:"Bank",value:o.bankName,onChange:m=>c({...o,bankName:m.target.value})}),s.jsx(V,{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(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function ux({isOpen:e,onClose:t,customerId:n,document:r}){const a=xe(),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]=b.useState(l),d=G({mutationFn:m=>Jo.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=>Jo.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)},p=d.isPending||u.isPending;return i&&o.documentNumber!==r.documentNumber&&c(l()),s.jsx(Ge,{isOpen:e,onClose:t,title:i?"Ausweis bearbeiten":"Ausweis hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(_e,{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(V,{label:"Ausweisnummer",value:o.documentNumber,onChange:m=>c({...o,documentNumber:m.target.value}),required:!0}),s.jsx(V,{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(V,{label:"Ausstellungsdatum",type:"date",value:o.issueDate,onChange:m=>c({...o,issueDate:m.target.value}),onClear:()=>c({...o,issueDate:""})}),s.jsx(V,{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(V,{label:"Führerscheinklassen",value:o.licenseClasses,onChange:m=>c({...o,licenseClasses:m.target.value}),placeholder:"z.B. B, BE, AM, L"}),s.jsx(V,{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(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function mx({isOpen:e,onClose:t,customerId:n,meter:r}){const a=xe(),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]=b.useState(l),d=G({mutationFn:m=>rn.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({meterNumber:"",type:"ELECTRICITY",location:"",isActive:!0})}}),u=G({mutationFn:m=>rn.update(r.id,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),h=m=>{m.preventDefault(),i?u.mutate(o):d.mutate(o)},p=d.isPending||u.isPending;return i&&o.meterNumber!==r.meterNumber&&c(l()),s.jsx(Ge,{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(V,{label:"Zählernummer",value:o.meterNumber,onChange:m=>c({...o,meterNumber:m.target.value}),required:!0}),s.jsx(_e,{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(V,{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(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function hx({isOpen:e,onClose:t,meterId:n,meterType:r,customerId:a,reading:i}){const l=xe(),o=!!i,c=r==="ELECTRICITY"?"kWh":"m³",d=()=>{var j;return{readingDate:i!=null&&i.readingDate?new Date(i.readingDate).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],value:((j=i==null?void 0:i.value)==null?void 0:j.toString())||"",notes:(i==null?void 0:i.notes)||""}},[u,h]=b.useState(d),p=G({mutationFn:j=>rn.addReading(n,j),onSuccess:()=>{l.invalidateQueries({queryKey:["customer",a.toString()]}),t()}}),m=G({mutationFn:j=>rn.updateReading(n,i.id,j),onSuccess:()=>{l.invalidateQueries({queryKey:["customer",a.toString()]}),t()}}),f=j=>{j.preventDefault();const y={readingDate:new Date(u.readingDate),value:parseFloat(u.value),unit:c,notes:u.notes||void 0};o?m.mutate(y):p.mutate(y)},x=p.isPending||m.isPending;return o&&u.value!==i.value.toString()&&h(d()),s.jsx(Ge,{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(V,{label:"Ablesedatum",type:"date",value:u.readingDate,onChange:j=>h({...u,readingDate:j.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(V,{label:"Zählerstand",type:"number",step:"0.01",value:u.value,onChange:j=>h({...u,value:j.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(V,{label:"Notizen",value:u.notes,onChange:j=>h({...u,notes:j.target.value}),placeholder:"Optionale Notizen..."}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:x,children:x?"Speichern...":"Speichern"})]})]})})}const hd="@stressfrei-wechseln.de";function hk({customerId:e,emails:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=xe(),c=G({mutationFn:({id:h,data:p})=>cs.update(h,p),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=G({mutationFn:cs.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(I,{size:"sm",onClick:i,children:[s.jsx(Ue,{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(tn,{className:"w-4 h-4 text-gray-400"}),s.jsx("span",{className:"font-mono text-sm",children:h.email}),s.jsx(ce,{value:h.email}),!h.isActive&&s.jsx(ye,{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(He,{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(I,{variant:"ghost",size:"sm",onClick:()=>l(h),title:"Bearbeiten",children:s.jsx(at,{className:"w-4 h-4"})}),h.isActive?s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse deaktivieren?")&&c.mutate({id:h.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(Ft,{className:"w-4 h-4"})}):s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wieder aktivieren?")&&c.mutate({id:h.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(De,{className:"w-4 h-4"})}),s.jsx(I,{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 fk({credentials:e,onHide:t,onResetPassword:n,isResettingPassword:r}){const[a,i]=b.useState(null),l=async(u,h)=>{try{await navigator.clipboard.writeText(u),i(h),setTimeout(()=>i(null),2e3)}catch{const p=document.createElement("textarea");p.value=u,document.body.appendChild(p),p.select(),document.execCommand("copy"),document.body.removeChild(p),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(Ga,{className:"w-4 h-4 text-green-600"}):s.jsx(rh,{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(Ft,{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 fx({isOpen:e,onClose:t,customerId:n,email:r,customerEmail:a}){const[i,l]=b.useState(""),[o,c]=b.useState(""),[d,u]=b.useState(!1),[h,p]=b.useState(!1),[m,f]=b.useState(null),[x,j]=b.useState("idle"),[y,v]=b.useState(!1),[g,w]=b.useState(!1),[C,k]=b.useState(!1),[F,N]=b.useState(!1),[E,P]=b.useState(null),[z,D]=b.useState(!1),[_,$]=b.useState(!1),L=xe(),A=!!r,{data:K}=me({queryKey:["email-provider-configs"],queryFn:()=>fn.getConfigs(),enabled:e}),B=((K==null?void 0:K.data)||[]).some(Z=>Z.isActive&&Z.isDefault),J=Z=>{if(!Z)return"";const Te=Z.indexOf("@");return Te>0?Z.substring(0,Te):Z},H=async Z=>{var Te;if(!(!B||!Z)){j("checking");try{const it=await fn.checkEmailExists(Z);j((Te=it.data)!=null&&Te.exists?"exists":"not_exists")}catch{j("error")}}},S=async()=>{var Z,Te;if(!(!a||!i)){v(!0),f(null);try{const it=await fn.provisionEmail(i,a);(Z=it.data)!=null&&Z.success?j("exists"):f(((Te=it.data)==null?void 0:Te.error)||"Provisionierung fehlgeschlagen")}catch(it){f(it instanceof Error?it.message:"Fehler bei der Provisionierung")}finally{v(!1)}}},oe=async()=>{if(r){w(!0),f(null);try{const Z=await cs.enableMailbox(r.id);Z.success?(k(!0),L.invalidateQueries({queryKey:["customer",n.toString()]}),L.invalidateQueries({queryKey:["mailbox-accounts",n]})):f(Z.error||"Mailbox-Aktivierung fehlgeschlagen")}catch(Z){f(Z instanceof Error?Z.message:"Fehler bei der Mailbox-Aktivierung")}finally{w(!1)}}},Ve=async()=>{if(r)try{const Z=await cs.syncMailboxStatus(r.id);Z.success&&Z.data&&(k(Z.data.hasMailbox),Z.data.wasUpdated&&L.invalidateQueries({queryKey:["customer",n.toString()]}))}catch(Z){console.error("Fehler beim Synchronisieren des Mailbox-Status:",Z)}},Fe=async()=>{if(r){D(!0);try{const Z=await cs.getMailboxCredentials(r.id);Z.success&&Z.data&&(P(Z.data),N(!0))}catch(Z){console.error("Fehler beim Laden der Zugangsdaten:",Z)}finally{D(!1)}}},Ye=async()=>{if(r&&confirm("Neues Passwort generieren? Das alte Passwort wird ungültig.")){$(!0);try{const Z=await cs.resetPassword(r.id);Z.success&&Z.data?(E&&P({...E,password:Z.data.password}),alert("Passwort wurde erfolgreich zurückgesetzt.")):alert(Z.error||"Fehler beim Zurücksetzen des Passworts")}catch(Z){console.error("Fehler beim Zurücksetzen des Passworts:",Z),alert(Z instanceof Error?Z.message:"Fehler beim Zurücksetzen des Passworts")}finally{$(!1)}}};b.useEffect(()=>{if(e){if(r){const Z=J(r.email);l(Z),c(r.notes||""),j("idle"),k(r.hasMailbox||!1),B&&(H(Z),Ve())}else l(""),c(""),u(!1),p(!1),j("idle"),k(!1);f(null),N(!1),P(null)}},[e,r,B]);const Ze=G({mutationFn:async Z=>cs.create(n,{email:Z.email,notes:Z.notes,provisionAtProvider:Z.provision,createMailbox:Z.createMailbox}),onSuccess:()=>{L.invalidateQueries({queryKey:["customer",n.toString()]}),L.invalidateQueries({queryKey:["mailbox-accounts",n]}),l(""),c(""),u(!1),p(!1),t()},onError:Z=>{f(Z instanceof Error?Z.message:"Fehler bei der Provisionierung")}}),xt=G({mutationFn:Z=>cs.update(r.id,Z),onSuccess:()=>{L.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),W=Z=>{Z.preventDefault(),f(null);const Te=i+hd;A?xt.mutate({email:Te,notes:o||void 0}):Ze.mutate({email:Te,notes:o||void 0,provision:d,createMailbox:d&&h})},Ae=Ze.isPending||xt.isPending;return s.jsx(Ge,{isOpen:e,onClose:t,title:A?"Adresse bearbeiten":"Adresse hinzufügen",children:s.jsxs("form",{onSubmit:W,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:Z=>l(Z.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:hd})]}),s.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Vollständige Adresse: ",s.jsxs("span",{className:"font-mono",children:[i||"...",hd]})]})]}),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:Z=>c(Z.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:A?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"}),x==="checking"&&s.jsx("span",{className:"text-xs text-gray-500",children:"Prüfe..."}),x==="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"]}),x==="not_exists"&&s.jsx("span",{className:"text-xs text-orange-600",children:"Nicht beim Provider angelegt"}),x==="error"&&s.jsx("span",{className:"text-xs text-red-600",children:"Status konnte nicht geprüft werden"})]}),x==="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(I,{type:"button",size:"sm",onClick:S,disabled:y,children:y?"Wird angelegt...":"Jetzt beim Provider anlegen"})]}),x==="error"&&s.jsx(I,{type:"button",size:"sm",variant:"secondary",onClick:()=>H(i),children:"Erneut prüfen"}),x==="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)"}),C?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"})]}),!C&&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(I,{type:"button",size:"sm",onClick:oe,disabled:g,children:g?"Wird aktiviert...":"Mailbox aktivieren"})]}),C&&s.jsx("div",{className:"mt-3",children:F?E&&s.jsx(fk,{credentials:E,onHide:()=>N(!1),onResetPassword:Ye,isResettingPassword:_}):s.jsx(I,{type:"button",size:"sm",variant:"secondary",onClick:Fe,disabled:z,children:z?"Laden...":s.jsxs(s.Fragment,{children:[s.jsx(De,{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:Z=>{u(Z.target.checked),Z.target.checked||p(!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:Z=>p(Z.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(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:Ae||!i,children:Ae?"Speichern...":"Speichern"})]})]})})}var Pl=e=>e.type==="checkbox",Cr=e=>e instanceof Date,Yt=e=>e==null;const Pv=e=>typeof e=="object";var vt=e=>!Yt(e)&&!Array.isArray(e)&&Pv(e)&&!Cr(e),pk=e=>vt(e)&&e.target?Pl(e.target)?e.target.checked:e.target.value:e,xk=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,gk=(e,t)=>e.has(xk(t)),yk=e=>{const t=e.constructor&&e.constructor.prototype;return vt(t)&&t.hasOwnProperty("isPrototypeOf")},uh=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function jt(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(uh&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(vt(e)&&yk(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=jt(e[a]));return r}var Mc=e=>/^\w*$/.test(e),et=e=>e===void 0,mh=e=>Array.isArray(e)?e.filter(Boolean):[],hh=e=>mh(e.replace(/["|']|\]/g,"").split(/\.|\[/)),fe=(e,t,n)=>{if(!t||!vt(e))return n;const r=(Mc(t)?[t]:hh(t)).reduce((a,i)=>Yt(a)?a:a[i],e);return et(r)||r===e?et(e[t])?n:e[t]:r},Gs=e=>typeof e=="boolean",Ls=e=>typeof e=="function",Je=(e,t,n)=>{let r=-1;const a=Mc(t)?[t]:hh(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=vt(d)||Array.isArray(d)?d:isNaN(+a[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=c,e=e[o]}};const px={BLUR:"blur",FOCUS_OUT:"focusout"},Os={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},dn={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},vk=At.createContext(null);vk.displayName="HookFormControlContext";var jk=(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]!==Os.all&&(t._proxyFormState[l]=!r||Os.all),e[l]}});return a};const bk=typeof window<"u"?At.useLayoutEffect:At.useEffect;var ds=e=>typeof e=="string",Nk=(e,t,n,r,a)=>ds(e)?(r&&t.watch.add(e),fe(n,e,a)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),fe(n,i))):(r&&(t.watchAll=!0),n),Vu=e=>Yt(e)||!Pv(e);function _n(e,t,n=new WeakSet){if(Vu(e)||Vu(t))return Object.is(e,t);if(Cr(e)&&Cr(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(Cr(l)&&Cr(o)||vt(l)&&vt(o)||Array.isArray(l)&&Array.isArray(o)?!_n(l,o,n):!Object.is(l,o))return!1}}return!0}const wk=At.createContext(null);wk.displayName="HookFormContext";var Sk=(e,t,n,r,a)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:a||!0}}:{},Fi=e=>Array.isArray(e)?e:[e],xx=()=>{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 Av(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const a=e[r],i=t[r];if(a&&vt(a)&&i){const l=Av(a,i);vt(l)&&(n[r]=l)}else e[r]&&(n[r]=i)}return n}var qt=e=>vt(e)&&!Object.keys(e).length,fh=e=>e.type==="file",Xo=e=>{if(!uh)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Mv=e=>e.type==="select-multiple",ph=e=>e.type==="radio",kk=e=>ph(e)||Pl(e),fd=e=>Xo(e)&&e.isConnected;function Ck(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=et(e)?r++:e[t[r++]];return e}function Ek(e){for(const t in e)if(e.hasOwnProperty(t)&&!et(e[t]))return!1;return!0}function gt(e,t){const n=Array.isArray(t)?t:Mc(t)?[t]:hh(t),r=n.length===1?e:Ck(e,n),a=n.length-1,i=n[a];return r&&delete r[i],a!==0&&(vt(r)&&qt(r)||Array.isArray(r)&&Ek(r))&&gt(e,n.slice(0,-1)),e}var Dk=e=>{for(const t in e)if(Ls(e[t]))return!0;return!1};function Fv(e){return Array.isArray(e)||vt(e)&&!Dk(e)}function Qu(e,t={}){for(const n in e){const r=e[n];Fv(r)?(t[n]=Array.isArray(r)?[]:{},Qu(r,t[n])):et(r)||(t[n]=!0)}return t}function sa(e,t,n){n||(n=Qu(t));for(const r in e){const a=e[r];if(Fv(a))et(t)||Vu(n[r])?n[r]=Qu(a,Array.isArray(a)?[]:{}):sa(a,Yt(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!_n(a,i)}}return n}const gx={value:!1,isValid:!1},yx={value:!0,isValid:!0};var Tv=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&&!et(e[0].attributes.value)?et(e[0].value)||e[0].value===""?yx:{value:e[0].value,isValid:!0}:yx:gx}return gx},Iv=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>et(e)?e:t?e===""?NaN:e&&+e:n&&ds(e)?new Date(e):r?r(e):e;const vx={isValid:!1,value:null};var Rv=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,vx):vx;function jx(e){const t=e.ref;return fh(t)?t.files:ph(t)?Rv(e.refs).value:Mv(t)?[...t.selectedOptions].map(({value:n})=>n):Pl(t)?Tv(e.refs).value:Iv(et(t.value)?e.ref.value:t.value,e)}var Pk=(e,t,n,r)=>{const a={};for(const i of e){const l=fe(t,i);l&&Je(a,i,l._f)}return{criteriaMode:n,names:[...e],fields:a,shouldUseNativeValidation:r}},Yo=e=>e instanceof RegExp,pi=e=>et(e)?e:Yo(e)?e.source:vt(e)?Yo(e.value)?e.value.source:e.value:e,bx=e=>({isOnSubmit:!e||e===Os.onSubmit,isOnBlur:e===Os.onBlur,isOnChange:e===Os.onChange,isOnAll:e===Os.all,isOnTouch:e===Os.onTouched});const Nx="AsyncFunction";var Ak=e=>!!e&&!!e.validate&&!!(Ls(e.validate)&&e.validate.constructor.name===Nx||vt(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Nx)),Mk=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),wx=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Ti=(e,t,n,r)=>{for(const a of n||Object.keys(e)){const i=fe(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(Ti(o,t))break}else if(vt(o)&&Ti(o,t))break}}};function Sx(e,t,n){const r=fe(e,n);if(r||Mc(n))return{error:r,name:n};const a=n.split(".");for(;a.length;){const i=a.join("."),l=fe(t,i),o=fe(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 Fk=(e,t,n,r)=>{n(e);const{name:a,...i}=e;return qt(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(l=>t[l]===(!r||Os.all))},Tk=(e,t,n)=>!e||!t||e===t||Fi(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),Ik=(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,Rk=(e,t)=>!mh(fe(e,t)).length&&gt(e,t),Lk=(e,t,n)=>{const r=Fi(fe(e,n));return Je(r,"root",t[n]),Je(e,n,r),e};function kx(e,t,n="validate"){if(ds(e)||Array.isArray(e)&&e.every(ds)||Gs(e)&&!e)return{type:n,message:ds(e)?e:"",ref:t}}var ta=e=>vt(e)&&!Yo(e)?e:{value:e,message:""},Cx=async(e,t,n,r,a,i)=>{const{ref:l,refs:o,required:c,maxLength:d,minLength:u,min:h,max:p,pattern:m,validate:f,name:x,valueAsNumber:j,mount:y}=e._f,v=fe(n,x);if(!y||t.has(x))return{};const g=o?o[0]:l,w=D=>{a&&g.reportValidity&&(g.setCustomValidity(Gs(D)?"":D||""),g.reportValidity())},C={},k=ph(l),F=Pl(l),N=k||F,E=(j||fh(l))&&et(l.value)&&et(v)||Xo(l)&&l.value===""||v===""||Array.isArray(v)&&!v.length,P=Sk.bind(null,x,r,C),z=(D,_,$,L=dn.maxLength,A=dn.minLength)=>{const K=D?_:$;C[x]={type:D?L:A,message:K,ref:l,...P(D?L:A,K)}};if(i?!Array.isArray(v)||!v.length:c&&(!N&&(E||Yt(v))||Gs(v)&&!v||F&&!Tv(o).isValid||k&&!Rv(o).isValid)){const{value:D,message:_}=ds(c)?{value:!!c,message:c}:ta(c);if(D&&(C[x]={type:dn.required,message:_,ref:g,...P(dn.required,_)},!r))return w(_),C}if(!E&&(!Yt(h)||!Yt(p))){let D,_;const $=ta(p),L=ta(h);if(!Yt(v)&&!isNaN(v)){const A=l.valueAsNumber||v&&+v;Yt($.value)||(D=A>$.value),Yt(L.value)||(_=A<L.value)}else{const A=l.valueAsDate||new Date(v),K=H=>new Date(new Date().toDateString()+" "+H),B=l.type=="time",J=l.type=="week";ds($.value)&&v&&(D=B?K(v)>K($.value):J?v>$.value:A>new Date($.value)),ds(L.value)&&v&&(_=B?K(v)<K(L.value):J?v<L.value:A<new Date(L.value))}if((D||_)&&(z(!!D,$.message,L.message,dn.max,dn.min),!r))return w(C[x].message),C}if((d||u)&&!E&&(ds(v)||i&&Array.isArray(v))){const D=ta(d),_=ta(u),$=!Yt(D.value)&&v.length>+D.value,L=!Yt(_.value)&&v.length<+_.value;if(($||L)&&(z($,D.message,_.message),!r))return w(C[x].message),C}if(m&&!E&&ds(v)){const{value:D,message:_}=ta(m);if(Yo(D)&&!v.match(D)&&(C[x]={type:dn.pattern,message:_,ref:l,...P(dn.pattern,_)},!r))return w(_),C}if(f){if(Ls(f)){const D=await f(v,n),_=kx(D,g);if(_&&(C[x]={..._,...P(dn.validate,_.message)},!r))return w(_.message),C}else if(vt(f)){let D={};for(const _ in f){if(!qt(D)&&!r)break;const $=kx(await f[_](v,n),g,_);$&&(D={...$,...P(_,$.message)},w($.message),r&&(C[x]=D))}if(!qt(D)&&(C[x]={ref:g,...D},!r))return C}}return w(!0),C};const Ok={mode:Os.onSubmit,reValidateMode:Os.onChange,shouldFocusError:!0};function zk(e={}){let t={...Ok,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:Ls(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},a=vt(t.defaultValues)||vt(t.values)?jt(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:jt(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 p={...h};const m={array:xx(),state:xx()},f=t.criteriaMode===Os.all,x=R=>U=>{clearTimeout(d),d=setTimeout(R,U)},j=async R=>{if(!l.keepIsValid&&!t.disabled&&(h.isValid||p.isValid||R)){let U;t.resolver?(U=qt((await N()).errors),y()):U=await P(r,!0),U!==n.isValid&&m.state.next({isValid:U})}},y=(R,U)=>{!t.disabled&&(h.isValidating||h.validatingFields||p.isValidating||p.validatingFields)&&((R||Array.from(o.mount)).forEach(Q=>{Q&&(U?Je(n.validatingFields,Q,U):gt(n.validatingFields,Q))}),m.state.next({validatingFields:n.validatingFields,isValidating:!qt(n.validatingFields)}))},v=(R,U=[],Q,le,ne=!0,ee=!0)=>{if(le&&Q&&!t.disabled){if(l.action=!0,ee&&Array.isArray(fe(r,R))){const pe=Q(fe(r,R),le.argA,le.argB);ne&&Je(r,R,pe)}if(ee&&Array.isArray(fe(n.errors,R))){const pe=Q(fe(n.errors,R),le.argA,le.argB);ne&&Je(n.errors,R,pe),Rk(n.errors,R)}if((h.touchedFields||p.touchedFields)&&ee&&Array.isArray(fe(n.touchedFields,R))){const pe=Q(fe(n.touchedFields,R),le.argA,le.argB);ne&&Je(n.touchedFields,R,pe)}(h.dirtyFields||p.dirtyFields)&&(n.dirtyFields=sa(a,i)),m.state.next({name:R,isDirty:D(R,U),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Je(i,R,U)},g=(R,U)=>{Je(n.errors,R,U),m.state.next({errors:n.errors})},w=R=>{n.errors=R,m.state.next({errors:n.errors,isValid:!1})},C=(R,U,Q,le)=>{const ne=fe(r,R);if(ne){const ee=fe(i,R,et(Q)?fe(a,R):Q);et(ee)||le&&le.defaultChecked||U?Je(i,R,U?ee:jx(ne._f)):L(R,ee),l.mount&&!l.action&&j()}},k=(R,U,Q,le,ne)=>{let ee=!1,pe=!1;const Ie={name:R};if(!t.disabled){if(!Q||le){(h.isDirty||p.isDirty)&&(pe=n.isDirty,n.isDirty=Ie.isDirty=D(),ee=pe!==Ie.isDirty);const Re=_n(fe(a,R),U);pe=!!fe(n.dirtyFields,R),Re?gt(n.dirtyFields,R):Je(n.dirtyFields,R,!0),Ie.dirtyFields=n.dirtyFields,ee=ee||(h.dirtyFields||p.dirtyFields)&&pe!==!Re}if(Q){const Re=fe(n.touchedFields,R);Re||(Je(n.touchedFields,R,Q),Ie.touchedFields=n.touchedFields,ee=ee||(h.touchedFields||p.touchedFields)&&Re!==Q)}ee&&ne&&m.state.next(Ie)}return ee?Ie:{}},F=(R,U,Q,le)=>{const ne=fe(n.errors,R),ee=(h.isValid||p.isValid)&&Gs(U)&&n.isValid!==U;if(t.delayError&&Q?(c=x(()=>g(R,Q)),c(t.delayError)):(clearTimeout(d),c=null,Q?Je(n.errors,R,Q):gt(n.errors,R)),(Q?!_n(ne,Q):ne)||!qt(le)||ee){const pe={...le,...ee&&Gs(U)?{isValid:U}:{},errors:n.errors,name:R};n={...n,...pe},m.state.next(pe)}},N=async R=>(y(R,!0),await t.resolver(i,t.context,Pk(R||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),E=async R=>{const{errors:U}=await N(R);if(y(R),R)for(const Q of R){const le=fe(U,Q);le?Je(n.errors,Q,le):gt(n.errors,Q)}else n.errors=U;return U},P=async(R,U,Q={valid:!0})=>{for(const le in R){const ne=R[le];if(ne){const{_f:ee,...pe}=ne;if(ee){const Ie=o.array.has(ee.name),Re=ne._f&&Ak(ne._f);Re&&h.validatingFields&&y([ee.name],!0);const lt=await Cx(ne,o.disabled,i,f,t.shouldUseNativeValidation&&!U,Ie);if(Re&&h.validatingFields&&y([ee.name]),lt[ee.name]&&(Q.valid=!1,U||e.shouldUseNativeValidation))break;!U&&(fe(lt,ee.name)?Ie?Lk(n.errors,lt,ee.name):Je(n.errors,ee.name,lt[ee.name]):gt(n.errors,ee.name))}!qt(pe)&&await P(pe,U,Q)}}return Q.valid},z=()=>{for(const R of o.unMount){const U=fe(r,R);U&&(U._f.refs?U._f.refs.every(Q=>!fd(Q)):!fd(U._f.ref))&&W(R)}o.unMount=new Set},D=(R,U)=>!t.disabled&&(R&&U&&Je(i,R,U),!_n(S(),a)),_=(R,U,Q)=>Nk(R,o,{...l.mount?i:et(U)?a:ds(R)?{[R]:U}:U},Q,U),$=R=>mh(fe(l.mount?i:a,R,t.shouldUnregister?fe(a,R,[]):[])),L=(R,U,Q={})=>{const le=fe(r,R);let ne=U;if(le){const ee=le._f;ee&&(!ee.disabled&&Je(i,R,Iv(U,ee)),ne=Xo(ee.ref)&&Yt(U)?"":U,Mv(ee.ref)?[...ee.ref.options].forEach(pe=>pe.selected=ne.includes(pe.value)):ee.refs?Pl(ee.ref)?ee.refs.forEach(pe=>{(!pe.defaultChecked||!pe.disabled)&&(Array.isArray(ne)?pe.checked=!!ne.find(Ie=>Ie===pe.value):pe.checked=ne===pe.value||!!ne)}):ee.refs.forEach(pe=>pe.checked=pe.value===ne):fh(ee.ref)?ee.ref.value="":(ee.ref.value=ne,ee.ref.type||m.state.next({name:R,values:jt(i)})))}(Q.shouldDirty||Q.shouldTouch)&&k(R,ne,Q.shouldTouch,Q.shouldDirty,!0),Q.shouldValidate&&H(R)},A=(R,U,Q)=>{for(const le in U){if(!U.hasOwnProperty(le))return;const ne=U[le],ee=R+"."+le,pe=fe(r,ee);(o.array.has(R)||vt(ne)||pe&&!pe._f)&&!Cr(ne)?A(ee,ne,Q):L(ee,ne,Q)}},K=(R,U,Q={})=>{const le=fe(r,R),ne=o.array.has(R),ee=jt(U);Je(i,R,ee),ne?(m.array.next({name:R,values:jt(i)}),(h.isDirty||h.dirtyFields||p.isDirty||p.dirtyFields)&&Q.shouldDirty&&m.state.next({name:R,dirtyFields:sa(a,i),isDirty:D(R,ee)})):le&&!le._f&&!Yt(ee)?A(R,ee,Q):L(R,ee,Q),wx(R,o)?m.state.next({...n,name:R,values:jt(i)}):m.state.next({name:l.mount?R:void 0,values:jt(i)})},B=async R=>{l.mount=!0;const U=R.target;let Q=U.name,le=!0;const ne=fe(r,Q),ee=Re=>{le=Number.isNaN(Re)||Cr(Re)&&isNaN(Re.getTime())||_n(Re,fe(i,Q,Re))},pe=bx(t.mode),Ie=bx(t.reValidateMode);if(ne){let Re,lt;const on=U.type?jx(ne._f):pk(R),Ps=R.type===px.BLUR||R.type===px.FOCUS_OUT,Tc=!Mk(ne._f)&&!t.resolver&&!fe(n.errors,Q)&&!ne._f.deps||Ik(Ps,fe(n.touchedFields,Q),n.isSubmitted,Ie,pe),Xr=wx(Q,o,Ps);Je(i,Q,on),Ps?(!U||!U.readOnly)&&(ne._f.onBlur&&ne._f.onBlur(R),c&&c(0)):ne._f.onChange&&ne._f.onChange(R);const Yr=k(Q,on,Ps),Ml=!qt(Yr)||Xr;if(!Ps&&m.state.next({name:Q,type:R.type,values:jt(i)}),Tc)return(h.isValid||p.isValid)&&(t.mode==="onBlur"?Ps&&j():Ps||j()),Ml&&m.state.next({name:Q,...Xr?{}:Yr});if(!Ps&&Xr&&m.state.next({...n}),t.resolver){const{errors:ni}=await N([Q]);if(y([Q]),ee(on),le){const Fl=Sx(n.errors,r,Q),ri=Sx(ni,r,Fl.name||Q);Re=ri.error,Q=ri.name,lt=qt(ni)}}else y([Q],!0),Re=(await Cx(ne,o.disabled,i,f,t.shouldUseNativeValidation))[Q],y([Q]),ee(on),le&&(Re?lt=!1:(h.isValid||p.isValid)&&(lt=await P(r,!0)));le&&(ne._f.deps&&(!Array.isArray(ne._f.deps)||ne._f.deps.length>0)&&H(ne._f.deps),F(Q,lt,Re,Yr))}},J=(R,U)=>{if(fe(n.errors,U)&&R.focus)return R.focus(),1},H=async(R,U={})=>{let Q,le;const ne=Fi(R);if(t.resolver){const ee=await E(et(R)?R:ne);Q=qt(ee),le=R?!ne.some(pe=>fe(ee,pe)):Q}else R?(le=(await Promise.all(ne.map(async ee=>{const pe=fe(r,ee);return await P(pe&&pe._f?{[ee]:pe}:pe)}))).every(Boolean),!(!le&&!n.isValid)&&j()):le=Q=await P(r);return m.state.next({...!ds(R)||(h.isValid||p.isValid)&&Q!==n.isValid?{}:{name:R},...t.resolver||!R?{isValid:Q}:{},errors:n.errors}),U.shouldFocus&&!le&&Ti(r,J,R?ne:o.mount),le},S=(R,U)=>{let Q={...l.mount?i:a};return U&&(Q=Av(U.dirtyFields?n.dirtyFields:n.touchedFields,Q)),et(R)?Q:ds(R)?fe(Q,R):R.map(le=>fe(Q,le))},oe=(R,U)=>({invalid:!!fe((U||n).errors,R),isDirty:!!fe((U||n).dirtyFields,R),error:fe((U||n).errors,R),isValidating:!!fe(n.validatingFields,R),isTouched:!!fe((U||n).touchedFields,R)}),Ve=R=>{R&&Fi(R).forEach(U=>gt(n.errors,U)),m.state.next({errors:R?n.errors:{}})},Fe=(R,U,Q)=>{const le=(fe(r,R,{_f:{}})._f||{}).ref,ne=fe(n.errors,R)||{},{ref:ee,message:pe,type:Ie,...Re}=ne;Je(n.errors,R,{...Re,...U,ref:le}),m.state.next({name:R,errors:n.errors,isValid:!1}),Q&&Q.shouldFocus&&le&&le.focus&&le.focus()},Ye=(R,U)=>Ls(R)?m.state.subscribe({next:Q=>"values"in Q&&R(_(void 0,U),Q)}):_(R,U,!0),Ze=R=>m.state.subscribe({next:U=>{Tk(R.name,U.name,R.exact)&&Fk(U,R.formState||h,Vs,R.reRenderRoot)&&R.callback({values:{...i},...n,...U,defaultValues:a})}}).unsubscribe,xt=R=>(l.mount=!0,p={...p,...R.formState},Ze({...R,formState:{...u,...R.formState}})),W=(R,U={})=>{for(const Q of R?Fi(R):o.mount)o.mount.delete(Q),o.array.delete(Q),U.keepValue||(gt(r,Q),gt(i,Q)),!U.keepError&&gt(n.errors,Q),!U.keepDirty&&gt(n.dirtyFields,Q),!U.keepTouched&&gt(n.touchedFields,Q),!U.keepIsValidating&&gt(n.validatingFields,Q),!t.shouldUnregister&&!U.keepDefaultValue&&gt(a,Q);m.state.next({values:jt(i)}),m.state.next({...n,...U.keepDirty?{isDirty:D()}:{}}),!U.keepIsValid&&j()},Ae=({disabled:R,name:U})=>{if(Gs(R)&&l.mount||R||o.disabled.has(U)){const ne=o.disabled.has(U)!==!!R;R?o.disabled.add(U):o.disabled.delete(U),ne&&l.mount&&!l.action&&j()}},Z=(R,U={})=>{let Q=fe(r,R);const le=Gs(U.disabled)||Gs(t.disabled);return Je(r,R,{...Q||{},_f:{...Q&&Q._f?Q._f:{ref:{name:R}},name:R,mount:!0,...U}}),o.mount.add(R),Q?Ae({disabled:Gs(U.disabled)?U.disabled:t.disabled,name:R}):C(R,!0,U.value),{...le?{disabled:U.disabled||t.disabled}:{},...t.progressive?{required:!!U.required,min:pi(U.min),max:pi(U.max),minLength:pi(U.minLength),maxLength:pi(U.maxLength),pattern:pi(U.pattern)}:{},name:R,onChange:B,onBlur:B,ref:ne=>{if(ne){Z(R,U),Q=fe(r,R);const ee=et(ne.value)&&ne.querySelectorAll&&ne.querySelectorAll("input,select,textarea")[0]||ne,pe=kk(ee),Ie=Q._f.refs||[];if(pe?Ie.find(Re=>Re===ee):ee===Q._f.ref)return;Je(r,R,{_f:{...Q._f,...pe?{refs:[...Ie.filter(fd),ee,...Array.isArray(fe(a,R))?[{}]:[]],ref:{type:ee.type,name:R}}:{ref:ee}}}),C(R,!1,void 0,ee)}else Q=fe(r,R,{}),Q._f&&(Q._f.mount=!1),(t.shouldUnregister||U.shouldUnregister)&&!(gk(o.array,R)&&l.action)&&o.unMount.add(R)}}},Te=()=>t.shouldFocusError&&Ti(r,J,o.mount),it=R=>{Gs(R)&&(m.state.next({disabled:R}),Ti(r,(U,Q)=>{const le=fe(r,Q);le&&(U.disabled=le._f.disabled||R,Array.isArray(le._f.refs)&&le._f.refs.forEach(ne=>{ne.disabled=le._f.disabled||R}))},0,!1))},xs=(R,U)=>async Q=>{let le;Q&&(Q.preventDefault&&Q.preventDefault(),Q.persist&&Q.persist());let ne=jt(i);if(m.state.next({isSubmitting:!0}),t.resolver){const{errors:ee,values:pe}=await N();y(),n.errors=ee,ne=jt(pe)}else await P(r);if(o.disabled.size)for(const ee of o.disabled)gt(ne,ee);if(gt(n.errors,"root"),qt(n.errors)){m.state.next({errors:{}});try{await R(ne,Q)}catch(ee){le=ee}}else U&&await U({...n.errors},Q),Te(),setTimeout(Te);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:qt(n.errors)&&!le,submitCount:n.submitCount+1,errors:n.errors}),le)throw le},Ds=(R,U={})=>{fe(r,R)&&(et(U.defaultValue)?K(R,jt(fe(a,R))):(K(R,U.defaultValue),Je(a,R,jt(U.defaultValue))),U.keepTouched||gt(n.touchedFields,R),U.keepDirty||(gt(n.dirtyFields,R),n.isDirty=U.defaultValue?D(R,jt(fe(a,R))):D()),U.keepError||(gt(n.errors,R),h.isValid&&j()),m.state.next({...n}))},ln=(R,U={})=>{const Q=R?jt(R):a,le=jt(Q),ne=qt(R),ee=ne?a:le;if(U.keepDefaultValues||(a=Q),!U.keepValues){if(U.keepDirtyValues){const pe=new Set([...o.mount,...Object.keys(sa(a,i))]);for(const Ie of Array.from(pe)){const Re=fe(n.dirtyFields,Ie),lt=fe(i,Ie),on=fe(ee,Ie);Re&&!et(lt)?Je(ee,Ie,lt):!Re&&!et(on)&&K(Ie,on)}}else{if(uh&&et(R))for(const pe of o.mount){const Ie=fe(r,pe);if(Ie&&Ie._f){const Re=Array.isArray(Ie._f.refs)?Ie._f.refs[0]:Ie._f.ref;if(Xo(Re)){const lt=Re.closest("form");if(lt){lt.reset();break}}}}if(U.keepFieldsRef)for(const pe of o.mount)K(pe,fe(ee,pe));else r={}}i=t.shouldUnregister?U.keepDefaultValues?jt(a):{}:jt(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&&!qt(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:ne?!1:U.keepDirty?n.isDirty:!!(U.keepDefaultValues&&!_n(R,a)),isSubmitted:U.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:ne?{}:U.keepDirtyValues?U.keepDefaultValues&&i?sa(a,i):n.dirtyFields:U.keepDefaultValues&&R?sa(a,R):U.keepDirty?n.dirtyFields:{},touchedFields:U.keepTouched?n.touchedFields:{},errors:U.keepErrors?n.errors:{},isSubmitSuccessful:U.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},te=(R,U)=>ln(Ls(R)?R(i):R,{...t.resetOptions,...U}),ge=(R,U={})=>{const Q=fe(r,R),le=Q&&Q._f;if(le){const ne=le.refs?le.refs[0]:le.ref;ne.focus&&setTimeout(()=>{ne.focus(),U.shouldSelect&&Ls(ne.select)&&ne.select()})}},Vs=R=>{n={...n,...R}},Al={control:{register:Z,unregister:W,getFieldState:oe,handleSubmit:xs,setError:Fe,_subscribe:Ze,_runSchema:N,_updateIsValidating:y,_focusError:Te,_getWatch:_,_getDirty:D,_setValid:j,_setFieldArray:v,_setDisabledField:Ae,_setErrors:w,_getFieldArray:$,_reset:ln,_resetDefaultValues:()=>Ls(t.defaultValues)&&t.defaultValues().then(R=>{te(R,t.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:z,_disableForm:it,_subjects:m,_proxyFormState:h,get _fields(){return r},get _formValues(){return i},get _state(){return l},set _state(R){l=R},get _defaultValues(){return a},get _names(){return o},set _names(R){o=R},get _formState(){return n},get _options(){return t},set _options(R){t={...t,...R}}},subscribe:xt,trigger:H,register:Z,handleSubmit:xs,watch:Ye,setValue:K,getValues:S,reset:te,resetField:Ds,clearErrors:Ve,unregister:W,setError:Fe,setFocus:ge,getFieldState:oe};return{...Al,formControl:Al}}function Lv(e={}){const t=At.useRef(void 0),n=At.useRef(void 0),[r,a]=At.useState({isDirty:!1,isValidating:!1,isLoading:Ls(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:Ls(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!Ls(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...o}=zk(e);t.current={...o,formState:r}}const i=t.current.control;return i._options=e,bk(()=>{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]),At.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),At.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),At.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),At.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),At.useEffect(()=>{if(i._proxyFormState.isDirty){const l=i._getDirty();l!==r.isDirty&&i._subjects.state.next({isDirty:l})}},[i,r.isDirty]),At.useEffect(()=>{var l;e.values&&!_n(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]),At.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=At.useMemo(()=>jk(r,i),[i,r]),t.current}function Ex(){var y,v;const{id:e}=yc(),t=Gt(),n=xe(),r=!!e,{register:a,handleSubmit:i,reset:l,watch:o,setValue:c,formState:{errors:d}}=Lv(),u=o("type"),{data:h}=me({queryKey:["customer",e],queryFn:()=>Et.getById(parseInt(e)),enabled:r});b.useEffect(()=>{if(h!=null&&h.data){const g={...h.data};g.birthDate&&(g.birthDate=g.birthDate.split("T")[0]),g.foundingDate&&(g.foundingDate=g.foundingDate.split("T")[0]),l(g)}},[h,l]);const p=G({mutationFn:Et.create,onSuccess:()=>{n.invalidateQueries({queryKey:["customers"]}),t("/customers")}}),m=G({mutationFn:g=>Et.update(parseInt(e),g),onSuccess:()=>{n.invalidateQueries({queryKey:["customers"]}),n.invalidateQueries({queryKey:["customer",e]}),t(`/customers/${e}`)}}),f=g=>{const w={type:g.type,salutation:g.salutation||void 0,firstName:g.firstName,lastName:g.lastName,companyName:g.companyName||void 0,email:g.email||void 0,phone:g.phone||void 0,mobile:g.mobile||void 0,taxNumber:g.taxNumber||void 0,commercialRegisterNumber:g.commercialRegisterNumber||void 0,notes:g.notes||void 0,birthPlace:g.birthPlace||void 0};g.birthDate&&typeof g.birthDate=="string"&&g.birthDate.trim()!==""?w.birthDate=new Date(g.birthDate).toISOString():w.birthDate=null,g.foundingDate&&typeof g.foundingDate=="string"&&g.foundingDate.trim()!==""?w.foundingDate=new Date(g.foundingDate).toISOString():w.foundingDate=null,r?m.mutate(w):p.mutate(w)},x=p.isPending||m.isPending,j=p.error||m.error;return s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold mb-6",children:r?"Kunde bearbeiten":"Neuer Kunde"}),j&&s.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:j instanceof Error?j.message:"Ein Fehler ist aufgetreten"}),s.jsxs("form",{onSubmit:i(f),children:[s.jsx(Y,{className:"mb-6",title:"Stammdaten",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(_e,{label:"Kundentyp",...a("type"),options:[{value:"PRIVATE",label:"Privatkunde"},{value:"BUSINESS",label:"Geschäftskunde"}]}),s.jsx(_e,{label:"Anrede",...a("salutation"),options:[{value:"Herr",label:"Herr"},{value:"Frau",label:"Frau"},{value:"Divers",label:"Divers"}]}),s.jsx(V,{label:"Vorname",...a("firstName",{required:"Vorname erforderlich"}),error:(y=d.firstName)==null?void 0:y.message}),s.jsx(V,{label:"Nachname",...a("lastName",{required:"Nachname erforderlich"}),error:(v=d.lastName)==null?void 0:v.message}),u==="BUSINESS"&&s.jsxs(s.Fragment,{children:[s.jsx(V,{label:"Firmenname",...a("companyName"),className:"md:col-span-2"}),s.jsx(V,{label:"Gründungsdatum",type:"date",...a("foundingDate"),value:o("foundingDate")||"",onClear:()=>c("foundingDate","")})]}),u!=="BUSINESS"&&s.jsxs(s.Fragment,{children:[s.jsx(V,{label:"Geburtsdatum",type:"date",...a("birthDate"),value:o("birthDate")||"",onClear:()=>c("birthDate","")}),s.jsx(V,{label:"Geburtsort",...a("birthPlace")})]})]})}),s.jsx(Y,{className:"mb-6",title:"Kontaktdaten",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(V,{label:"E-Mail",type:"email",...a("email")}),s.jsx(V,{label:"Telefon",...a("phone")}),s.jsx(V,{label:"Mobil",...a("mobile")})]})}),u==="BUSINESS"&&s.jsxs(Y,{className:"mb-6",title:"Geschäftsdaten",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(V,{label:"Steuernummer",...a("taxNumber")}),s.jsx(V,{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(Y,{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(I,{type:"button",variant:"secondary",onClick:()=>t(-1),children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:x,children:x?"Speichern...":"Speichern"})]})]})]})}const pd={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabelinternet",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},xd={DRAFT:"Entwurf",PENDING:"Ausstehend",ACTIVE:"Aktiv",CANCELLED:"Gekündigt",EXPIRED:"Abgelaufen",DEACTIVATED:"Deaktiviert"},Dx={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"};function $k(){const[e,t]=jc(),n=Gt(),[r,a]=b.useState(e.get("search")||""),[i,l]=b.useState(e.get("type")||""),[o,c]=b.useState(e.get("status")||""),[d,u]=b.useState(parseInt(e.get("page")||"1",10)),[h,p]=b.useState(new Set),{hasPermission:m,isCustomer:f,isCustomerPortal:x,user:j}=qe(),y=xe();b.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 v=G({mutationFn:ze.delete,onSuccess:()=>{y.invalidateQueries({queryKey:["contracts"]})}}),{data:g,isLoading:w}=me({queryKey:["contracts",r,i,o,d,f?j==null?void 0:j.customerId:null],queryFn:()=>ze.getAll({search:r||void 0,type:i||void 0,status:o||void 0,page:d,limit:20,customerId:f?j==null?void 0:j.customerId:void 0})}),C=b.useMemo(()=>{if(!x||!(g!=null&&g.data))return[];const D=new Set;return j!=null&&j.customerId&&D.add(j.customerId),g.data.forEach(_=>D.add(_.customerId)),[...D]},[g==null?void 0:g.data,x,j==null?void 0:j.customerId]),k=Hw({queries:C.map(D=>({queryKey:["contract-tree",D],queryFn:()=>ze.getTreeForCustomer(D),enabled:x}))}),F=b.useMemo(()=>{const D=new Map;return C.forEach((_,$)=>{var A;const L=k[$];(A=L==null?void 0:L.data)!=null&&A.data&&D.set(_,L.data.data)}),D},[C,k]),N=b.useMemo(()=>{if(!x||!(g!=null&&g.data))return null;const D={};for(const _ of g.data){const $=_.customerId;if(!D[$]){const L=_.customer?_.customer.companyName||`${_.customer.firstName} ${_.customer.lastName}`:`Kunde ${$}`;D[$]={customerId:$,customerName:L,isOwn:$===(j==null?void 0:j.customerId),contracts:[],tree:F.get($)||[]}}D[$].contracts.push(_)}return Object.values(D).sort((_,$)=>_.isOwn&&!$.isOwn?-1:!_.isOwn&&$.isOwn?1:_.customerName.localeCompare($.customerName))},[g==null?void 0:g.data,x,j==null?void 0:j.customerId,F]),E=D=>{p(_=>{const $=new Set(_);return $.has(D)?$.delete(D):$.add(D),$})},P=(D,_)=>D.map($=>s.jsx("div",{children:z($,_)},$.contract.id)),z=(D,_=0)=>{var J,H,S,oe,Ve,Fe,Ye;const{contract:$,predecessors:L,hasHistory:A}=D,K=h.has($.id),B=_>0;return s.jsxs("div",{children:[s.jsxs("div",{className:`
border rounded-lg p-4 transition-colors
${B?"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:[!B&&A?s.jsx("button",{onClick:()=>E($.id),className:"p-1 hover:bg-gray-200 rounded transition-colors",title:K?"Einklappen":"Vorgänger anzeigen",children:K?s.jsx(xr,{className:"w-4 h-4 text-gray-500"}):s.jsx(Mt,{className:"w-4 h-4 text-gray-500"})}):B?null:s.jsx("div",{className:"w-6"}),s.jsxs("span",{className:"font-mono flex items-center gap-1",children:[$.contractNumber,s.jsx(ce,{value:$.contractNumber})]}),s.jsx(ye,{children:pd[$.type]||$.type}),s.jsx(ye,{variant:Dx[$.status]||"default",children:xd[$.status]||$.status}),B&&s.jsx("span",{className:"text-xs text-gray-500 ml-2",children:"(Vorgänger)"})]}),s.jsx("div",{className:"flex gap-2",children:s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${$.id}`,{state:{from:"contracts"}}),title:"Ansehen",children:s.jsx(De,{className:"w-4 h-4"})})})]}),($.providerName||((J=$.provider)==null?void 0:J.name))&&s.jsxs("p",{className:`flex items-center gap-1 ${B?"ml-6":""}`,children:[$.providerName||((H=$.provider)==null?void 0:H.name),($.tariffName||((S=$.tariff)==null?void 0:S.name))&&` - ${$.tariffName||((oe=$.tariff)==null?void 0:oe.name)}`,s.jsx(ce,{value:($.providerName||((Ve=$.provider)==null?void 0:Ve.name)||"")+($.tariffName||(Fe=$.tariff)!=null&&Fe.name?` - ${$.tariffName||((Ye=$.tariff)==null?void 0:Ye.name)}`:"")})]}),$.startDate&&s.jsxs("p",{className:`text-sm text-gray-500 ${B?"ml-6":""}`,children:["Beginn: ",new Date($.startDate).toLocaleDateString("de-DE"),$.endDate&&` | Ende: ${new Date($.endDate).toLocaleDateString("de-DE")}`]})]}),(_===0&&K||_>0)&&L.length>0&&s.jsx("div",{className:"mt-2",children:P(L,_+1)})]},$.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"}),m("contracts:create")&&!f&&s.jsx(Se,{to:"/contracts/new",children:s.jsxs(I,{children:[s.jsx(Ue,{className:"w-4 h-4 mr-2"}),"Neuer Vertrag"]})})]}),s.jsx(Y,{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(V,{placeholder:"Suchen...",value:r,onChange:D=>a(D.target.value)})}),s.jsx(_e,{value:i,onChange:D=>l(D.target.value),options:Object.entries(pd).map(([D,_])=>({value:D,label:_})),className:"w-48"}),s.jsx(_e,{value:o,onChange:D=>c(D.target.value),options:Object.entries(xd).map(([D,_])=>({value:D,label:_})),className:"w-48"}),s.jsx(I,{variant:"secondary",children:s.jsx(Cl,{className:"w-4 h-4"})})]})}),w?s.jsx(Y,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."})}):g!=null&&g.data&&g.data.length>0?s.jsx(s.Fragment,{children:x&&N?s.jsx("div",{className:"space-y-6",children:N.map(D=>s.jsxs(Y,{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(Dl,{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(ye,{variant:"default",children:D.contracts.length})]}):s.jsxs(s.Fragment,{children:[s.jsx(Na,{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(ye,{variant:"default",children:D.contracts.length})]})}),D.tree.length>0?s.jsx("div",{className:"space-y-4",children:D.tree.map(_=>z(_,0))}):s.jsx("p",{className:"text-gray-500",children:"Keine Verträge vorhanden."})]},D.isOwn?"own":D.customerName))}):s.jsxs(Y,{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."}),!f&&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:"Status"}),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:g.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}),!f&&s.jsx("td",{className:"py-3 px-4",children:D.customer&&s.jsx(Se,{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(ye,{children:pd[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(ye,{variant:Dx[D.status],children:xd[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(I,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${D.id}`,{state:{from:"contracts"}}),children:s.jsx(De,{className:"w-4 h-4"})}),m("contracts:update")&&!f&&s.jsx(Se,{to:`/contracts/${D.id}/edit`,children:s.jsx(I,{variant:"ghost",size:"sm",children:s.jsx(at,{className:"w-4 h-4"})})}),m("contracts:delete")&&!f&&s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertrag wirklich löschen?")&&v.mutate(D.id)},children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})})]},D.id))})]})}),g.pagination&&g.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 ",g.pagination.page," von ",g.pagination.totalPages," (",g.pagination.total," Einträge)"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(I,{variant:"secondary",size:"sm",onClick:()=>u(D=>Math.max(1,D-1)),disabled:d===1,children:"Zurück"}),s.jsx(I,{variant:"secondary",size:"sm",onClick:()=>u(D=>D+1),disabled:d>=g.pagination.totalPages,children:"Weiter"})]})]})]})}):s.jsx(Y,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Verträge gefunden."})})]})}const _k={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabelinternet",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},Kk={DRAFT:"Entwurf",PENDING:"Ausstehend",ACTIVE:"Aktiv",CANCELLED:"Gekündigt",EXPIRED:"Abgelaufen",DEACTIVATED:"Deaktiviert"},Uk={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"};function Bk({contractId:e,isOpen:t,onClose:n}){var o,c,d,u,h,p,m,f,x,j;const{data:r,isLoading:a,error:i}=me({queryKey:["contract",e],queryFn:()=>ze.getById(e),enabled:t}),l=r==null?void 0:r.data;return s.jsxs(Ge,{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(ce,{value:l.contractNumber})]}),s.jsx(ye,{children:_k[l.type]||l.type}),s.jsx(ye,{variant:Uk[l.status]||"default",children:Kk[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(Y,{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(ce,{value:l.providerName||((h=l.provider)==null?void 0:h.name)||""})]})]}),(l.tariffName||((p=l.tariff)==null?void 0:p.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(ce,{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(ce,{value:l.customerNumberAtProvider})]})]})]})}),s.jsx(Y,{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||((x=l.provider)==null?void 0:x.portalUrl))&&s.jsx(Y,{title:"Portal-Zugangsdaten",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[((j=l.provider)==null?void 0:j.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(ce,{value:l.portalUsername})]})]})]})}),l.address&&s.jsxs(Y,{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(Y,{title:"Notizen",children:s.jsx("p",{className:"whitespace-pre-wrap text-gray-700",children:l.notes})})]})]})}const qk=10.5;function Px(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 Vk(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 Qk(e,t,n,r){const a=Vk(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,x)=>new Date(f.readingDate).getTime()-new Date(x.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 Ax("exact",f,r,l,o)}const u=Px(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=Px(t,n),m=(o.value-l.value)/u*h;return Ax("projected",m,r,l,o,n)}function Ax(e,t,n,r,a,i){return n==="GAS"?{type:e,consumptionM3:t,consumptionKwh:t*qk,startReading:r,endReading:a,projectedEndDate:i}:{type:e,consumptionKwh:t,startReading:r,endReading:a,projectedEndDate:i}}function Hk(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 Wk={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabelinternet",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},Gk={DRAFT:"Entwurf",PENDING:"Ausstehend",ACTIVE:"Aktiv",CANCELLED:"Gekündigt",EXPIRED:"Abgelaufen",DEACTIVATED:"Deaktiviert"},Zk={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"};function Jk(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 Xk({simCard:e}){const[t,n]=b.useState(!1),[r,a]=b.useState(null),[i,l]=b.useState(!1),o=async()=>{if(t)n(!1),a(null);else{l(!0);try{const c=await ze.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(ye,{variant:"success",children:"Hauptkarte"}),e.isMultisim&&s.jsx(ye,{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(ce,{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(ce,{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(ce,{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(ce,{value:r.puk})]}):"••••••••"})]})]}),s.jsx("div",{className:"mt-2",children:s.jsx(I,{variant:"ghost",size:"sm",onClick:o,disabled:i,children:i?"Laden...":t?s.jsxs(s.Fragment,{children:[s.jsx(Ft,{className:"w-4 h-4 mr-1"})," PIN/PUK verbergen"]}):s.jsxs(s.Fragment,{children:[s.jsx(De,{className:"w-4 h-4 mr-1"})," PIN/PUK anzeigen"]})})})]})}function Yk({meterId:e,meterType:t,readings:n,contractId:r,canEdit:a}){const[i,l]=b.useState(!1),[o,c]=b.useState(!1),[d,u]=b.useState(null),h=xe(),p=G({mutationFn:x=>rn.deleteReading(e,x),onSuccess:()=>{h.invalidateQueries({queryKey:["contract",r.toString()]})}}),m=[...n].sort((x,j)=>new Date(j.readingDate).getTime()-new Date(x.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(vv,{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(ye,{variant:"default",children:n.length})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[a&&s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>c(!0),title:"Zählerstand erfassen",children:s.jsx(Ue,{className:"w-4 h-4"})}),n.length>0&&s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>l(!i),children:i?s.jsx(gv,{className:"w-4 h-4"}):s.jsx(xr,{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(x=>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(x.readingDate).toLocaleDateString("de-DE"),s.jsx(ce,{value:new Date(x.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:[x.value.toLocaleString("de-DE")," ",x.unit,s.jsx(ce,{value:x.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(x),className:"text-gray-400 hover:text-blue-600",title:"Bearbeiten",children:s.jsx(at,{className:"w-3 h-3"})}),s.jsx("button",{onClick:()=>{confirm("Zählerstand wirklich löschen?")&&p.mutate(x.id)},className:"text-gray-400 hover:text-red-600",title:"Löschen",children:s.jsx(Ne,{className:"w-3 h-3"})})]})]})]},x.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(eC,{isOpen:!0,onClose:()=>{c(!1),u(null)},meterId:e,contractId:r,reading:d,defaultUnit:f})]})}function eC({isOpen:e,onClose:t,meterId:n,contractId:r,reading:a,defaultUnit:i}){var f;const l=xe(),o=!!a,[c,d]=b.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:x=>rn.addReading(n,x),onSuccess:()=>{l.invalidateQueries({queryKey:["contract",r.toString()]}),t()}}),h=G({mutationFn:x=>rn.updateReading(n,a.id,x),onSuccess:()=>{l.invalidateQueries({queryKey:["contract",r.toString()]}),t()}}),p=x=>{x.preventDefault();const j={readingDate:new Date(c.readingDate),value:parseFloat(c.value),unit:i,notes:c.notes||void 0};o?h.mutate(j):u.mutate(j)},m=u.isPending||h.isPending;return s.jsx(Ge,{isOpen:e,onClose:t,title:o?"Zählerstand bearbeiten":"Zählerstand erfassen",children:s.jsxs("form",{onSubmit:p,className:"space-y-4",children:[s.jsx(V,{label:"Ablesedatum",type:"date",value:c.readingDate,onChange:x=>d({...c,readingDate:x.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(V,{label:"Zählerstand",type:"number",step:"0.01",value:c.value,onChange:x=>d({...c,value:x.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(V,{label:"Notizen (optional)",value:c.notes,onChange:x=>d({...c,notes:x.target.value})}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:m||!c.value,children:m?"Speichern...":o?"Speichern":"Erfassen"})]})]})})}function tC({contractType:e,readings:t,startDate:n,endDate:r,basePrice:a,unitPrice:i,bonus:l}){const o=Qk(t,n,r,e),c=o.consumptionKwh>0?Hk(o.consumptionKwh,a,i,l):null;if(o.type==="none")return null;const d=(h,p=2)=>h.toLocaleString("de-DE",{minimumFractionDigits:p,maximumFractionDigits:p}),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(b2,{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(ye,{variant:"success",children:"Exakt"}),o.type==="projected"&&s.jsx(ye,{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 Mx({task:e,contractId:t,canEdit:n,isCustomerPortal:r,isCompleted:a,onEdit:i}){const[l,o]=b.useState(""),[c,d]=b.useState(!1),[u,h]=b.useState(null),[p,m]=b.useState(""),f=xe(),x=G({mutationFn:K=>mt.complete(K),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),j=G({mutationFn:K=>mt.reopen(K),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),y=G({mutationFn:K=>mt.delete(K),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),v=G({mutationFn:K=>mt.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.")}}),g=G({mutationFn:K=>mt.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.")}}),w=G({mutationFn:({id:K,title:B})=>mt.updateSubtask(K,B),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]}),h(null),m("")}}),C=G({mutationFn:K=>mt.completeSubtask(K),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),k=G({mutationFn:K=>mt.reopenSubtask(K),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),F=G({mutationFn:K=>mt.deleteSubtask(K),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),N=K=>{K.preventDefault(),l.trim()&&(r?g.mutate(l.trim()):v.mutate(l.trim()))},E=K=>{K.preventDefault(),p.trim()&&u&&w.mutate({id:u,title:p.trim()})},P=(K,B)=>{h(K),m(B)},z=()=>{h(null),m("")},D=e.subtasks||[],_=D.filter(K=>K.status==="OPEN"),$=D.filter(K=>K.status==="COMPLETED"),L=r?{singular:"Antwort",placeholder:"Antwort...",deleteConfirm:"Antwort löschen?"}:{singular:"Unteraufgabe",placeholder:"Unteraufgabe...",deleteConfirm:"Unteraufgabe löschen?"},A=(K,B)=>u===K.id?s.jsx("div",{className:"py-1",children:s.jsxs("form",{onSubmit:E,className:"flex items-center gap-2",children:[s.jsx(vo,{className:"w-4 h-4 text-gray-300 flex-shrink-0"}),s.jsx("input",{type:"text",value:p,onChange:H=>m(H.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(I,{type:"submit",size:"sm",disabled:!p.trim()||w.isPending,children:"✓"}),s.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:z,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?k.mutate(K.id):C.mutate(K.id),disabled:C.isPending||k.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(ws,{className:"w-4 h-4 text-green-500"}):s.jsx(vo,{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:()=>P(K.id,K.title),className:"text-gray-400 hover:text-blue-600 p-0.5",title:"Bearbeiten",children:s.jsx(at,{className:"w-3 h-3"})}),s.jsx("button",{onClick:()=>{confirm(L.deleteConfirm)&&F.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(L.deleteConfirm)&&F.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?j.mutate(e.id):x.mutate(e.id),disabled:x.isPending||j.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(ws,{className:"w-5 h-5 text-green-500"}):s.jsx(vo,{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(ye,{variant:"default",className:"text-xs",children:"Portal"}),D.length>0&&s.jsxs("span",{className:"text-xs text-gray-400",children:["(",$.length,"/",D.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")]}),D.length>0&&s.jsxs("div",{className:"mt-3 ml-2 space-y-0 border-l-2 border-gray-200 pl-3",children:[_.map(K=>A(K,!1)),$.map(K=>A(K,!0))]}),!a&&(n&&!r||r)&&s.jsx("div",{className:"mt-2 ml-2",children:c?s.jsxs("form",{onSubmit:N,className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",value:l,onChange:K=>o(K.target.value),placeholder:L.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(I,{type:"submit",size:"sm",disabled:!l.trim()||v.isPending||g.isPending,children:s.jsx(Ue,{className:"w-3 h-3"})}),s.jsx(I,{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(Ue,{className:"w-3 h-3"}),L.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(at,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm("Aufgabe wirklich löschen?")&&y.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 sC({contractId:e,canEdit:t,isCustomerPortal:n}){var g;const[r,a]=b.useState(!1),[i,l]=b.useState(null),{data:o,isLoading:c}=me({queryKey:["contract-tasks",e],queryFn:()=>mt.getByContract(e),staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:d,isLoading:u}=me({queryKey:["app-settings-public"],queryFn:()=>Wr.getPublic(),enabled:n,staleTime:0}),h=!u&&((g=d==null?void 0:d.data)==null?void 0:g.customerSupportTicketsEnabled)==="true",p=(o==null?void 0:o.data)||[],m=p.filter(w=>w.status==="OPEN"),f=p.filter(w=>w.status==="COMPLETED"),x=n?{title:"Support-Anfragen",button:"Anfrage erstellen",empty:"Keine Support-Anfragen vorhanden."}:{title:"Aufgaben",button:"Aufgabe",empty:"Keine Aufgaben vorhanden."},j=n?il:al;if(c||n&&u)return s.jsx(Y,{className:"mb-6",title:x.title,children:s.jsx("div",{className:"text-center py-4 text-gray-500",children:"Laden..."})});const v=t&&!n||n&&h;return s.jsxs(Y,{className:"mb-6",title:x.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(j,{className:"w-5 h-5 text-gray-500"}),s.jsxs("span",{className:"text-sm text-gray-600",children:[m.length," offen, ",f.length," erledigt"]})]}),v&&s.jsxs(I,{size:"sm",onClick:()=>a(!0),children:[s.jsx(Ue,{className:"w-4 h-4 mr-1"}),x.button]})]}),p.length===0?s.jsx("p",{className:"text-center py-4 text-gray-500",children:x.empty}):s.jsxs("div",{className:"space-y-2",children:[m.map(w=>s.jsx(Mx,{task:w,contractId:e,canEdit:t,isCustomerPortal:n,isCompleted:!1,onEdit:()=>l(w)},w.id)),f.length>0&&m.length>0&&s.jsx("div",{className:"border-t my-3"}),f.map(w=>s.jsx(Mx,{task:w,contractId:e,canEdit:t,isCustomerPortal:n,isCompleted:!0,onEdit:()=>{}},w.id))]}),(r||i)&&s.jsx(nC,{isOpen:!0,onClose:()=>{a(!1),l(null)},contractId:e,task:i,isCustomerPortal:n})]})}function nC({isOpen:e,onClose:t,contractId:n,task:r,isCustomerPortal:a=!1}){const i=xe(),l=!!r,[o,c]=b.useState({title:(r==null?void 0:r.title)||"",description:(r==null?void 0:r.description)||"",visibleInPortal:(r==null?void 0:r.visibleInPortal)||!1});b.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:x=>mt.create(n,x),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",n]}),t()}}),u=G({mutationFn:x=>mt.createSupportTicket(n,x),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",n]}),t()}}),h=G({mutationFn:x=>mt.update(r.id,x),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",n]}),t()}}),p=x=>{x.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(Ge,{isOpen:e,onClose:t,title:f.modalTitle,children:s.jsxs("form",{onSubmit:p,className:"space-y-4",children:[s.jsx(V,{label:f.titleLabel,value:o.title,onChange:x=>c({...o,title:x.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:x=>c({...o,description:x.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:x=>c({...o,visibleInPortal:x.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(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:m||!o.title.trim(),children:m?"Speichern...":f.submitBtn})]})]})})}function rC(){var oe,Ve,Fe,Ye,Ze,xt;const{id:e}=yc(),t=Gt(),r=Fn().state,a=xe(),{hasPermission:i,isCustomer:l,isCustomerPortal:o}=qe(),c=parseInt(e),[d,u]=b.useState(!1),[h,p]=b.useState(null),[m,f]=b.useState(!1),[x,j]=b.useState(!1),[y,v]=b.useState(null),[g,w]=b.useState({}),[C,k]=b.useState({}),[F,N]=b.useState(!1),[E,P]=b.useState(!1),{data:z,isLoading:D}=me({queryKey:["contract",e],queryFn:()=>ze.getById(c)}),_=G({mutationFn:()=>ze.delete(c),onSuccess:()=>{t("/contracts")}}),$=G({mutationFn:()=>ze.createFollowUp(c),onSuccess:W=>{W.data?t(`/contracts/${W.data.id}/edit`):alert("Folgevertrag wurde erstellt, aber keine ID zurückgegeben")},onError:W=>{console.error("Folgevertrag Fehler:",W),alert(`Fehler beim Erstellen des Folgevertrags: ${W instanceof Error?W.message:"Unbekannter Fehler"}`)}}),L=G({mutationFn:W=>{const Z={cancellationConfirmationDate:W?new Date(W).toISOString():null};return ze.update(c,Z)},onSuccess:()=>{a.invalidateQueries({queryKey:["contract",e]}),a.invalidateQueries({queryKey:["contract-cockpit"]})},onError:W=>{console.error("Fehler beim Speichern des Datums:",W),alert("Fehler beim Speichern des Datums")}}),A=G({mutationFn:W=>{const Z={cancellationConfirmationOptionsDate:W?new Date(W).toISOString():null};return ze.update(c,Z)},onSuccess:()=>{a.invalidateQueries({queryKey:["contract",e]}),a.invalidateQueries({queryKey:["contract-cockpit"]})},onError:W=>{console.error("Fehler beim Speichern des Datums:",W),alert("Fehler beim Speichern des Datums")}}),K=async()=>{var W;if(d)u(!1),p(null);else try{const Ae=await ze.getPassword(c);(W=Ae.data)!=null&&W.password&&(p(Ae.data.password),u(!0))}catch{alert("Passwort konnte nicht entschlüsselt werden")}},B=async()=>{var W;if(x)j(!1),v(null);else try{const Ae=await ze.getInternetCredentials(c);(W=Ae.data)!=null&&W.password&&(v(Ae.data.password),j(!0))}catch{alert("Internet-Passwort konnte nicht entschlüsselt werden")}},J=async W=>{var Ae;if(g[W])w(Z=>({...Z,[W]:!1})),k(Z=>({...Z,[W]:null}));else try{const Te=(Ae=(await ze.getSipCredentials(W)).data)==null?void 0:Ae.password;Te&&(k(it=>({...it,[W]:Te})),w(it=>({...it,[W]:!0})))}catch{alert("SIP-Passwort konnte nicht entschlüsselt werden")}},H=async()=>{var Z,Te,it;const W=z==null?void 0:z.data,Ae=((Z=W==null?void 0:W.stressfreiEmail)==null?void 0:Z.email)||(W==null?void 0:W.portalUsername);if(!((Te=W==null?void 0:W.provider)!=null&&Te.portalUrl)||!Ae){alert("Portal-URL oder Benutzername fehlt");return}f(!0);try{const xs=await ze.getPassword(c);if(!((it=xs.data)!=null&&it.password)){alert("Passwort konnte nicht entschlüsselt werden");return}const Ds=W.provider,ln=Ds.portalUrl,te=Ds.usernameFieldName||"username",ge=Ds.passwordFieldName||"password",Vs=new URL(ln);Vs.searchParams.set(te,Ae),Vs.searchParams.set(ge,xs.data.password),window.open(Vs.toString(),"_blank")}catch{alert("Fehler beim Auto-Login")}finally{f(!1)}};if(D)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 S=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(I,{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 W=r.filter?`?filter=${r.filter}`:"";t(`/contracts/cockpit${W}`)}else(r==null?void 0:r.from)==="contracts"?t("/contracts"):S.customer?t(`/customers/${S.customer.id}?tab=contracts`):t("/contracts")},children:s.jsx(Us,{className:"w-4 h-4"})}),s.jsx("h1",{className:"text-2xl font-bold",children:S.contractNumber}),s.jsx(ye,{children:Wk[S.type]}),s.jsx(ye,{variant:Zk[S.status],children:Gk[S.status]})]}),S.customer&&s.jsxs("p",{className:"text-gray-500 ml-10",children:["Kunde:"," ",s.jsx(Se,{to:`/customers/${S.customer.id}`,className:"text-blue-600 hover:underline",children:S.customer.companyName||`${S.customer.firstName} ${S.customer.lastName}`})]})]}),!l&&s.jsxs("div",{className:"flex gap-2",children:[S.previousContract&&s.jsx(Se,{to:`/contracts/${S.previousContract.id}`,children:s.jsxs(I,{variant:"secondary",children:[s.jsx(Us,{className:"w-4 h-4 mr-2"}),"Vorgängervertrag"]})}),i("contracts:create")&&!S.followUpContract&&s.jsxs(I,{variant:"secondary",onClick:()=>P(!0),disabled:$.isPending,children:[s.jsx(rh,{className:"w-4 h-4 mr-2"}),$.isPending?"Erstelle...":"Folgevertrag anlegen"]}),S.followUpContract&&s.jsx(Se,{to:`/contracts/${S.followUpContract.id}`,children:s.jsxs(I,{variant:"secondary",children:[s.jsx(fv,{className:"w-4 h-4 mr-2"}),"Folgevertrag anzeigen"]})}),i("contracts:update")&&s.jsx(Se,{to:`/contracts/${e}/edit`,children:s.jsxs(I,{variant:"secondary",children:[s.jsx(at,{className:"w-4 h-4 mr-2"}),"Bearbeiten"]})}),i("contracts:delete")&&s.jsxs(I,{variant:"danger",onClick:()=>{confirm("Vertrag wirklich löschen?")&&_.mutate()},children:[s.jsx(Ne,{className:"w-4 h-4 mr-2"}),"Löschen"]})]})]}),S.previousContract&&s.jsx(Y,{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:()=>N(!0),className:"text-blue-600 hover:underline",children:S.previousContract.contractNumber})})]}),S.previousContract.providerName&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),s.jsx("dd",{children:S.previousContract.providerName})]}),S.previousContract.customerNumberAtProvider&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kundennummer"}),s.jsx("dd",{className:"font-mono",children:S.previousContract.customerNumberAtProvider})]}),S.previousContract.portalUsername&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Zugangsdaten"}),s.jsx("dd",{children:S.previousContract.portalUsername})]})]})}),S.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(S.cancellationConfirmationDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}),".",S.cancellationConfirmationOptionsDate&&s.jsxs(s.Fragment,{children:[" Optionen-Bestätigung: ",s.jsx("strong",{children:new Date(S.cancellationConfirmationOptionsDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}),"."]})]})]})]}),S.type==="MOBILE"&&((oe=S.mobileDetails)==null?void 0:oe.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(Y,{title:"Anbieter & Tarif",children:s.jsxs("dl",{className:"space-y-3",children:[(S.provider||S.providerName)&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),s.jsx("dd",{className:"font-medium",children:((Ve=S.provider)==null?void 0:Ve.name)||S.providerName})]}),(S.tariff||S.tariffName)&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Tarif"}),s.jsx("dd",{children:((Fe=S.tariff)==null?void 0:Fe.name)||S.tariffName})]}),S.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:[S.customerNumberAtProvider,s.jsx(ce,{value:S.customerNumberAtProvider})]})]}),S.salesPlatform&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertriebsplattform"}),s.jsx("dd",{children:S.salesPlatform.name})]}),S.commission!==null&&S.commission!==void 0&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Provision"}),s.jsx("dd",{children:S.commission.toLocaleString("de-DE",{style:"currency",currency:"EUR"})})]}),S.priceFirst12Months&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Preis erste 12 Monate"}),s.jsx("dd",{children:S.priceFirst12Months})]}),S.priceFrom13Months&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Preis ab 13. Monat"}),s.jsx("dd",{children:S.priceFrom13Months})]}),S.priceAfter24Months&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Preis nach 24 Monaten"}),s.jsx("dd",{children:S.priceAfter24Months})]})]})}),s.jsxs(Y,{title:"Laufzeit und Kündigung",className:S.cancellationConfirmationDate?"border-2 border-red-400":"",children:[S.contractDuration&&Jk(S.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:[S.startDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsbeginn"}),s.jsx("dd",{children:new Date(S.startDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),S.endDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsende"}),s.jsx("dd",{children:new Date(S.endDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),S.contractDuration&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragslaufzeit"}),s.jsx("dd",{children:S.contractDuration.description})]}),S.cancellationPeriod&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsfrist"}),s.jsx("dd",{children:S.cancellationPeriod.description})]}),S.cancellationConfirmationDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsbestätigungsdatum"}),s.jsx("dd",{children:new Date(S.cancellationConfirmationDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),S.cancellationConfirmationOptionsDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsbestätigungsoptionendatum"}),s.jsx("dd",{children:new Date(S.cancellationConfirmationOptionsDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),S.wasSpecialCancellation&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Sonderkündigung"}),s.jsx("dd",{children:s.jsx(ye,{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"}),S.cancellationLetterPath?s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${S.cancellationLetterPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(De,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${S.cancellationLetterPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(zs,{className:"w-4 h-4"}),"Download"]}),s.jsx(Ct,{onUpload:async W=>{await dt.uploadCancellationLetter(c,W),a.invalidateQueries({queryKey:["contract",e]})},existingFile:S.cancellationLetterPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await dt.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(Ct,{onUpload:async W=>{await dt.uploadCancellationLetter(c,W),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"}),S.cancellationConfirmationPath?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${S.cancellationConfirmationPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(De,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${S.cancellationConfirmationPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(zs,{className:"w-4 h-4"}),"Download"]}),s.jsx(Ct,{onUpload:async W=>{await dt.uploadCancellationConfirmation(c,W),a.invalidateQueries({queryKey:["contract",e]})},existingFile:S.cancellationConfirmationPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await dt.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:S.cancellationConfirmationDate?S.cancellationConfirmationDate.split("T")[0]:"",onChange:W=>{const Ae=W.target.value||null;L.mutate(Ae)},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"}),S.cancellationConfirmationDate&&s.jsx("button",{onClick:()=>L.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(Ct,{onUpload:async W=>{await dt.uploadCancellationConfirmation(c,W),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"}),S.cancellationLetterOptionsPath?s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${S.cancellationLetterOptionsPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(De,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${S.cancellationLetterOptionsPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(zs,{className:"w-4 h-4"}),"Download"]}),s.jsx(Ct,{onUpload:async W=>{await dt.uploadCancellationLetterOptions(c,W),a.invalidateQueries({queryKey:["contract",e]})},existingFile:S.cancellationLetterOptionsPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await dt.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(Ct,{onUpload:async W=>{await dt.uploadCancellationLetterOptions(c,W),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"}),S.cancellationConfirmationOptionsPath?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${S.cancellationConfirmationOptionsPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(De,{className:"w-4 h-4"}),"Anzeigen"]}),s.jsxs("a",{href:`/api${S.cancellationConfirmationOptionsPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(zs,{className:"w-4 h-4"}),"Download"]}),s.jsx(Ct,{onUpload:async W=>{await dt.uploadCancellationConfirmationOptions(c,W),a.invalidateQueries({queryKey:["contract",e]})},existingFile:S.cancellationConfirmationOptionsPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await dt.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:S.cancellationConfirmationOptionsDate?S.cancellationConfirmationOptionsDate.split("T")[0]:"",onChange:W=>{const Ae=W.target.value||null;A.mutate(Ae)},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"}),S.cancellationConfirmationOptionsDate&&s.jsx("button",{onClick:()=>A.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(Ct,{onUpload:async W=>{await dt.uploadCancellationConfirmationOptions(c,W),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]})]})]})]})]}),(S.portalUsername||S.stressfreiEmail||S.portalPasswordEncrypted)&&s.jsxs(Y,{className:"mb-6",title:"Zugangsdaten",children:[s.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[(S.portalUsername||S.stressfreiEmail)&&s.jsxs("div",{children:[s.jsxs("dt",{className:"text-sm text-gray-500",children:["Benutzername",S.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:[((Ye=S.stressfreiEmail)==null?void 0:Ye.email)||S.portalUsername,s.jsx(ce,{value:((Ze=S.stressfreiEmail)==null?void 0:Ze.email)||S.portalUsername||""})]})]}),S.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(ce,{value:h}),s.jsx(I,{variant:"ghost",size:"sm",onClick:K,children:d?s.jsx(Ft,{className:"w-4 h-4"}):s.jsx(De,{className:"w-4 h-4"})})]})]})]}),((xt=S.provider)==null?void 0:xt.portalUrl)&&(S.portalUsername||S.stressfreiEmail)&&S.portalPasswordEncrypted&&s.jsxs("div",{className:"mt-4 pt-4 border-t",children:[s.jsxs(I,{onClick:H,disabled:m,className:"w-full sm:w-auto",children:[s.jsx(ih,{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:[S.address&&s.jsx(Y,{title:"Lieferadresse",children:s.jsxs(qu,{values:[`${S.address.street} ${S.address.houseNumber}`,`${S.address.postalCode} ${S.address.city}`,S.address.country],children:[s.jsxs("p",{children:[S.address.street," ",S.address.houseNumber]}),s.jsxs("p",{children:[S.address.postalCode," ",S.address.city]}),s.jsx("p",{className:"text-gray-500",children:S.address.country})]})}),(S.billingAddress||S.address)&&s.jsx(Y,{title:"Rechnungsadresse",children:(()=>{const W=S.billingAddress||S.address;return W?s.jsxs(qu,{values:[`${W.street} ${W.houseNumber}`,`${W.postalCode} ${W.city}`,W.country],children:[s.jsxs("p",{children:[W.street," ",W.houseNumber]}),s.jsxs("p",{children:[W.postalCode," ",W.city]}),s.jsx("p",{className:"text-gray-500",children:W.country}),!S.billingAddress&&S.address&&s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"(wie Lieferadresse)"})]}):null})()}),S.bankCard&&s.jsxs(Y,{title:"Bankkarte",children:[s.jsx("p",{className:"font-medium",children:S.bankCard.accountHolder}),s.jsxs("p",{className:"font-mono flex items-center gap-1",children:[S.bankCard.iban,s.jsx(ce,{value:S.bankCard.iban})]}),S.bankCard.bankName&&s.jsx("p",{className:"text-gray-500",children:S.bankCard.bankName})]}),S.identityDocument&&s.jsxs(Y,{title:"Ausweis",children:[s.jsxs("p",{className:"font-mono flex items-center gap-1",children:[S.identityDocument.documentNumber,s.jsx(ce,{value:S.identityDocument.documentNumber})]}),s.jsx("p",{className:"text-gray-500",children:S.identityDocument.type})]})]}),S.energyDetails&&s.jsxs(Y,{className:"mb-6",title:S.type==="ELECTRICITY"?"Strom-Details":"Gas-Details",children:[s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[S.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:[S.energyDetails.meter.meterNumber,s.jsx(ce,{value:S.energyDetails.meter.meterNumber})]})]}),S.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:[S.energyDetails.maloId,s.jsx(ce,{value:S.energyDetails.maloId})]})]}),S.energyDetails.annualConsumption&&s.jsxs("div",{children:[s.jsxs("dt",{className:"text-sm text-gray-500",children:["Jahresverbrauch ",S.type==="ELECTRICITY"?"":"(m³)"]}),s.jsxs("dd",{children:[S.energyDetails.annualConsumption.toLocaleString("de-DE")," ",S.type==="ELECTRICITY"?"kWh":"m³"]})]}),S.type==="GAS"&&S.energyDetails.annualConsumptionKwh&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Jahresverbrauch (kWh)"}),s.jsxs("dd",{children:[S.energyDetails.annualConsumptionKwh.toLocaleString("de-DE")," kWh"]})]}),S.energyDetails.basePrice!=null&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Grundpreis"}),s.jsxs("dd",{children:[S.energyDetails.basePrice.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:10})," €/Monat"]})]}),S.energyDetails.unitPrice!=null&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Arbeitspreis"}),s.jsxs("dd",{children:[S.energyDetails.unitPrice.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:10})," €/kWh"]})]}),S.energyDetails.bonus&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Bonus"}),s.jsxs("dd",{children:[S.energyDetails.bonus.toLocaleString("de-DE")," €"]})]}),S.energyDetails.previousProviderName&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vorversorger"}),s.jsx("dd",{children:S.energyDetails.previousProviderName})]}),S.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:[S.energyDetails.previousCustomerNumber,s.jsx(ce,{value:S.energyDetails.previousCustomerNumber})]})]})]}),S.energyDetails.meter&&s.jsx(Yk,{meterId:S.energyDetails.meter.id,meterType:S.energyDetails.meter.type,readings:S.energyDetails.meter.readings||[],contractId:c,canEdit:i("contracts:update")&&!l}),S.energyDetails.meter&&S.startDate&&S.endDate&&s.jsx(tC,{contractType:S.type,readings:S.energyDetails.meter.readings||[],startDate:S.startDate,endDate:S.endDate,basePrice:S.energyDetails.basePrice,unitPrice:S.energyDetails.unitPrice,bonus:S.energyDetails.bonus})]}),S.internetDetails&&s.jsxs(Y,{className:"mb-6",title:S.type==="DSL"?"DSL-Details":S.type==="CABLE"?"Kabelinternet-Details":"Glasfaser-Details",children:[s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[S.internetDetails.downloadSpeed&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Download"}),s.jsxs("dd",{children:[S.internetDetails.downloadSpeed," Mbit/s"]})]}),S.internetDetails.uploadSpeed&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Upload"}),s.jsxs("dd",{children:[S.internetDetails.uploadSpeed," Mbit/s"]})]}),S.internetDetails.routerModel&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Router"}),s.jsx("dd",{children:S.internetDetails.routerModel})]}),S.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:[S.internetDetails.routerSerialNumber,s.jsx(ce,{value:S.internetDetails.routerSerialNumber})]})]}),S.internetDetails.installationDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Installation"}),s.jsx("dd",{children:new Date(S.internetDetails.installationDate).toLocaleDateString("de-DE")})]}),S.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:[S.internetDetails.homeId,s.jsx(ce,{value:S.internetDetails.homeId})]})]}),S.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:[S.internetDetails.activationCode,s.jsx(ce,{value:S.internetDetails.activationCode})]})]})]}),(S.internetDetails.internetUsername||S.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:[S.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:[S.internetDetails.internetUsername,s.jsx(ce,{value:S.internetDetails.internetUsername})]})]}),S.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:x&&y?y:"••••••••"}),x&&y&&s.jsx(ce,{value:y}),s.jsx(I,{variant:"ghost",size:"sm",onClick:B,children:x?s.jsx(Ft,{className:"w-4 h-4"}):s.jsx(De,{className:"w-4 h-4"})})]})]})]})]}),S.internetDetails.phoneNumbers&&S.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:S.internetDetails.phoneNumbers.map(W=>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:[W.phoneNumber,s.jsx(ce,{value:W.phoneNumber})]}),W.isMain&&s.jsx(ye,{variant:"success",children:"Hauptnummer"})]}),(W.sipUsername||W.sipPasswordEncrypted||W.sipServer)&&s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-sm",children:[W.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:[W.sipUsername,s.jsx(ce,{value:W.sipUsername})]})]}),W.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:g[W.id]&&C[W.id]?C[W.id]:"••••••••"}),g[W.id]&&C[W.id]&&s.jsx(ce,{value:C[W.id]}),s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>J(W.id),children:g[W.id]?s.jsx(Ft,{className:"w-3 h-3"}):s.jsx(De,{className:"w-3 h-3"})})]})]}),W.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:[W.sipServer,s.jsx(ce,{value:W.sipServer})]})]})]})]},W.id))})]})]}),S.mobileDetails&&s.jsxs(Y,{className:"mb-6",title:"Mobilfunk-Details",children:[s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[S.mobileDetails.dataVolume&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Datenvolumen"}),s.jsxs("dd",{children:[S.mobileDetails.dataVolume," GB"]})]}),S.mobileDetails.includedMinutes&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Inklusiv-Minuten"}),s.jsx("dd",{children:S.mobileDetails.includedMinutes})]}),S.mobileDetails.includedSMS&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Inklusiv-SMS"}),s.jsx("dd",{children:S.mobileDetails.includedSMS})]}),S.mobileDetails.deviceModel&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Gerät"}),s.jsx("dd",{children:S.mobileDetails.deviceModel})]}),S.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:[S.mobileDetails.deviceImei,s.jsx(ce,{value:S.mobileDetails.deviceImei})]})]}),S.mobileDetails.requiresMultisim&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Multisim"}),s.jsx("dd",{children:s.jsx(ye,{variant:"warning",children:"Erforderlich"})})]})]}),S.mobileDetails.simCards&&S.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:S.mobileDetails.simCards.map(W=>s.jsx(Xk,{simCard:W},W.id))})]}),(!S.mobileDetails.simCards||S.mobileDetails.simCards.length===0)&&(S.mobileDetails.phoneNumber||S.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:[S.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:[S.mobileDetails.phoneNumber,s.jsx(ce,{value:S.mobileDetails.phoneNumber})]})]}),S.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:[S.mobileDetails.simCardNumber,s.jsx(ce,{value:S.mobileDetails.simCardNumber})]})]})]})]})]}),S.tvDetails&&s.jsx(Y,{className:"mb-6",title:"TV-Details",children:s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[S.tvDetails.receiverModel&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Receiver"}),s.jsx("dd",{children:S.tvDetails.receiverModel})]}),S.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:[S.tvDetails.smartcardNumber,s.jsx(ce,{value:S.tvDetails.smartcardNumber})]})]}),S.tvDetails.package&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Paket"}),s.jsx("dd",{children:S.tvDetails.package})]})]})}),S.carInsuranceDetails&&s.jsx(Y,{className:"mb-6",title:"KFZ-Versicherung Details",children:s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[S.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:[S.carInsuranceDetails.licensePlate,s.jsx(ce,{value:S.carInsuranceDetails.licensePlate})]})]}),S.carInsuranceDetails.vehicleType&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Fahrzeug"}),s.jsx("dd",{children:S.carInsuranceDetails.vehicleType})]}),S.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:[S.carInsuranceDetails.hsn,"/",S.carInsuranceDetails.tsn,s.jsx(ce,{value:`${S.carInsuranceDetails.hsn}/${S.carInsuranceDetails.tsn}`})]})]}),S.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:[S.carInsuranceDetails.vin,s.jsx(ce,{value:S.carInsuranceDetails.vin})]})]}),S.carInsuranceDetails.firstRegistration&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Erstzulassung"}),s.jsx("dd",{children:new Date(S.carInsuranceDetails.firstRegistration).toLocaleDateString("de-DE")})]}),S.carInsuranceDetails.noClaimsClass&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SF-Klasse"}),s.jsx("dd",{children:S.carInsuranceDetails.noClaimsClass})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Versicherungsart"}),s.jsx("dd",{children:s.jsx(ye,{variant:S.carInsuranceDetails.insuranceType==="FULL"?"success":S.carInsuranceDetails.insuranceType==="PARTIAL"?"warning":"default",children:S.carInsuranceDetails.insuranceType==="FULL"?"Vollkasko":S.carInsuranceDetails.insuranceType==="PARTIAL"?"Teilkasko":"Haftpflicht"})})]}),S.carInsuranceDetails.deductiblePartial&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SB Teilkasko"}),s.jsxs("dd",{children:[S.carInsuranceDetails.deductiblePartial," €"]})]}),S.carInsuranceDetails.deductibleFull&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SB Vollkasko"}),s.jsxs("dd",{children:[S.carInsuranceDetails.deductibleFull," €"]})]}),S.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:[S.carInsuranceDetails.policyNumber,s.jsx(ce,{value:S.carInsuranceDetails.policyNumber})]})]}),S.carInsuranceDetails.previousInsurer&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vorversicherer"}),s.jsx("dd",{children:S.carInsuranceDetails.previousInsurer})]})]})}),s.jsx(sC,{contractId:c,canEdit:i("contracts:update"),isCustomerPortal:o}),!o&&i("contracts:read")&&S.customerId&&s.jsx(tk,{contractId:c,customerId:S.customerId}),S.notes&&s.jsx(Y,{title:"Notizen",children:s.jsx("p",{className:"whitespace-pre-wrap",children:S.notes})}),F&&S.previousContract&&s.jsx(Bk,{contractId:S.previousContract.id,isOpen:!0,onClose:()=>N(!1)}),s.jsx(Ge,{isOpen:E,onClose:()=>P(!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(I,{variant:"secondary",onClick:()=>P(!1),children:"Nein"}),s.jsx(I,{onClick:()=>{P(!1),$.mutate()},children:"Ja, anlegen"})]})]})})]})}const aC=[{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"}];function Fx(){var Xr,Yr,Ml,ni,Fl,ri,xh,gh,yh;const{id:e}=yc(),[t]=jc(),n=Gt(),r=xe(),a=!!e,i=t.get("customerId"),{register:l,handleSubmit:o,reset:c,watch:d,setValue:u,formState:{errors:h}}=Lv({defaultValues:{customerId:i||"",type:"ELECTRICITY",status:"DRAFT",previousContractId:""}}),p=d("type"),m=d("customerId"),{data:f}=me({queryKey:["contract",e],queryFn:()=>ze.getById(parseInt(e)),enabled:a}),{data:x}=me({queryKey:["customers-all"],queryFn:()=>Et.getAll({limit:1e3})}),{data:j}=me({queryKey:["customer",m],queryFn:()=>Et.getById(parseInt(m)),enabled:!!m}),{data:y}=me({queryKey:["customer-contracts-for-predecessor",m],queryFn:()=>ze.getAll({customerId:parseInt(m),limit:1e3}),enabled:!!m}),{data:v}=me({queryKey:["platforms"],queryFn:()=>tl.getAll()}),{data:g}=me({queryKey:["cancellation-periods"],queryFn:()=>sl.getAll()}),{data:w}=me({queryKey:["contract-durations"],queryFn:()=>nl.getAll()}),{data:C}=me({queryKey:["providers"],queryFn:()=>Wa.getAll()}),{data:k}=me({queryKey:["contract-categories"],queryFn:()=>rl.getAll()}),F=d("providerId"),[N,E]=b.useState(null),[P,z]=b.useState([]),[D,_]=b.useState([]),[$,L]=b.useState(!1),[A,K]=b.useState("manual"),[B,J]=b.useState(""),[H,S]=b.useState(!1),[oe,Ve]=b.useState(!1),[Fe,Ye]=b.useState({}),[Ze,xt]=b.useState({}),[W,Ae]=b.useState({});b.useEffect(()=>{a||L(!0)},[a]),b.useEffect(()=>{!a&&i&&(x!=null&&x.data)&&x.data.some(ie=>ie.id.toString()===i)&&u("customerId",i)},[a,i,x,u]),b.useEffect(()=>{$&&N&&F!==N&&u("tariffId",""),E(F)},[F,N,u,$]),b.useEffect(()=>{if(!a&&(k!=null&&k.data)&&k.data.length>0){const T=d("type"),ie=k.data.filter(he=>he.isActive),be=ie.some(he=>he.code===T);if(!T||!be){const he=ie.sort((je,ot)=>je.sortOrder-ot.sortOrder)[0];he&&u("type",he.code)}}},[k,a,u,d]),b.useEffect(()=>{a&&(f!=null&&f.data)&&!m&&u("customerId",f.data.customerId.toString())},[a,f,m,u]),b.useEffect(()=>{var T,ie,be,he,je,ot,ke,ai,vh,jh,bh,Nh,wh,Sh,kh,Ch,Eh,Dh,Ph,Ah,Mh,Fh,Th,Ih,Rh,Lh,Oh,zh,$h,_h,Kh,Uh,Bh,qh,Vh,Qh,Hh,Wh,Gh,Zh,Jh,Xh,Yh,ef,tf,sf,nf,rf,af,lf,of,cf,df;if(f!=null&&f.data&&(v!=null&&v.data)&&(k!=null&&k.data)&&(C!=null&&C.data)&&(j!=null&&j.data)){const re=f.data;c({customerId:re.customerId.toString(),type:re.type,status:re.status,addressId:((T=re.addressId)==null?void 0:T.toString())||"",billingAddressId:((ie=re.billingAddressId)==null?void 0:ie.toString())||"",bankCardId:((be=re.bankCardId)==null?void 0:be.toString())||"",identityDocumentId:((he=re.identityDocumentId)==null?void 0:he.toString())||"",salesPlatformId:((je=re.salesPlatformId)==null?void 0:je.toString())||"",providerId:((ot=re.providerId)==null?void 0:ot.toString())||"",tariffId:((ke=re.tariffId)==null?void 0:ke.toString())||"",providerName:re.providerName||"",tariffName:re.tariffName||"",customerNumberAtProvider:re.customerNumberAtProvider||"",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:((ai=re.cancellationPeriodId)==null?void 0:ai.toString())||"",contractDurationId:((vh=re.contractDurationId)==null?void 0:vh.toString())||"",commission:re.commission||"",portalUsername:re.portalUsername||"",notes:re.notes||"",meterId:((bh=(jh=re.energyDetails)==null?void 0:jh.meterId)==null?void 0:bh.toString())||"",maloId:((Nh=re.energyDetails)==null?void 0:Nh.maloId)||"",annualConsumption:((wh=re.energyDetails)==null?void 0:wh.annualConsumption)||"",annualConsumptionKwh:((Sh=re.energyDetails)==null?void 0:Sh.annualConsumptionKwh)||"",basePrice:((kh=re.energyDetails)==null?void 0:kh.basePrice)||"",unitPrice:((Ch=re.energyDetails)==null?void 0:Ch.unitPrice)||"",bonus:((Eh=re.energyDetails)==null?void 0:Eh.bonus)||"",previousProviderName:((Dh=re.energyDetails)==null?void 0:Dh.previousProviderName)||"",previousCustomerNumber:((Ph=re.energyDetails)==null?void 0:Ph.previousCustomerNumber)||"",downloadSpeed:((Ah=re.internetDetails)==null?void 0:Ah.downloadSpeed)||"",uploadSpeed:((Mh=re.internetDetails)==null?void 0:Mh.uploadSpeed)||"",routerModel:((Fh=re.internetDetails)==null?void 0:Fh.routerModel)||"",routerSerialNumber:((Th=re.internetDetails)==null?void 0:Th.routerSerialNumber)||"",installationDate:(Ih=re.internetDetails)!=null&&Ih.installationDate?re.internetDetails.installationDate.split("T")[0]:"",internetUsername:((Rh=re.internetDetails)==null?void 0:Rh.internetUsername)||"",homeId:((Lh=re.internetDetails)==null?void 0:Lh.homeId)||"",activationCode:((Oh=re.internetDetails)==null?void 0:Oh.activationCode)||"",requiresMultisim:((zh=re.mobileDetails)==null?void 0:zh.requiresMultisim)||!1,dataVolume:(($h=re.mobileDetails)==null?void 0:$h.dataVolume)||"",includedMinutes:((_h=re.mobileDetails)==null?void 0:_h.includedMinutes)||"",includedSMS:((Kh=re.mobileDetails)==null?void 0:Kh.includedSMS)||"",deviceModel:((Uh=re.mobileDetails)==null?void 0:Uh.deviceModel)||"",deviceImei:((Bh=re.mobileDetails)==null?void 0:Bh.deviceImei)||"",phoneNumber:((qh=re.mobileDetails)==null?void 0:qh.phoneNumber)||"",simCardNumber:((Vh=re.mobileDetails)==null?void 0:Vh.simCardNumber)||"",receiverModel:((Qh=re.tvDetails)==null?void 0:Qh.receiverModel)||"",smartcardNumber:((Hh=re.tvDetails)==null?void 0:Hh.smartcardNumber)||"",tvPackage:((Wh=re.tvDetails)==null?void 0:Wh.package)||"",licensePlate:((Gh=re.carInsuranceDetails)==null?void 0:Gh.licensePlate)||"",hsn:((Zh=re.carInsuranceDetails)==null?void 0:Zh.hsn)||"",tsn:((Jh=re.carInsuranceDetails)==null?void 0:Jh.tsn)||"",vin:((Xh=re.carInsuranceDetails)==null?void 0:Xh.vin)||"",vehicleType:((Yh=re.carInsuranceDetails)==null?void 0:Yh.vehicleType)||"",firstRegistration:(ef=re.carInsuranceDetails)!=null&&ef.firstRegistration?re.carInsuranceDetails.firstRegistration.split("T")[0]:"",noClaimsClass:((tf=re.carInsuranceDetails)==null?void 0:tf.noClaimsClass)||"",insuranceType:((sf=re.carInsuranceDetails)==null?void 0:sf.insuranceType)||"LIABILITY",deductiblePartial:((nf=re.carInsuranceDetails)==null?void 0:nf.deductiblePartial)||"",deductibleFull:((rf=re.carInsuranceDetails)==null?void 0:rf.deductibleFull)||"",policyNumber:((af=re.carInsuranceDetails)==null?void 0:af.policyNumber)||"",previousInsurer:((lf=re.carInsuranceDetails)==null?void 0:lf.previousInsurer)||"",cancellationConfirmationDate:re.cancellationConfirmationDate?re.cancellationConfirmationDate.split("T")[0]:"",cancellationConfirmationOptionsDate:re.cancellationConfirmationOptionsDate?re.cancellationConfirmationOptionsDate.split("T")[0]:"",wasSpecialCancellation:re.wasSpecialCancellation||!1,previousContractId:((of=re.previousContractId)==null?void 0:of.toString())||""}),(cf=re.mobileDetails)!=null&&cf.simCards&&re.mobileDetails.simCards.length>0?z(re.mobileDetails.simCards.map(Zt=>({id:Zt.id,phoneNumber:Zt.phoneNumber||"",simCardNumber:Zt.simCardNumber||"",pin:"",puk:"",hasExistingPin:!!Zt.pin,hasExistingPuk:!!Zt.puk,isMultisim:Zt.isMultisim,isMain:Zt.isMain}))):z([]),(df=re.internetDetails)!=null&&df.phoneNumbers&&re.internetDetails.phoneNumbers.length>0?_(re.internetDetails.phoneNumbers.map(Zt=>({id:Zt.id,phoneNumber:Zt.phoneNumber||"",sipUsername:Zt.sipUsername||"",sipPassword:"",hasExistingSipPassword:!!Zt.sipPasswordEncrypted,sipServer:Zt.sipServer||"",isMain:Zt.isMain}))):_([]),re.stressfreiEmailId?(K("stressfrei"),J(re.stressfreiEmailId.toString())):(K("manual"),J("")),L(!0)}},[f,c,v,k,C,j]);const Z=d("startDate"),Te=d("contractDurationId");b.useEffect(()=>{if(Z&&Te&&(w!=null&&w.data)){const T=w.data.find(ie=>ie.id===parseInt(Te));if(T){const ie=new Date(Z),he=T.code.match(/^(\d+)([MTJ])$/);if(he){const je=parseInt(he[1]),ot=he[2];let ke=new Date(ie);ot==="T"?ke.setDate(ke.getDate()+je):ot==="M"?ke.setMonth(ke.getMonth()+je):ot==="J"&&ke.setFullYear(ke.getFullYear()+je),u("endDate",ke.toISOString().split("T")[0])}}}},[Z,Te,w,u]);const it=G({mutationFn:ze.create,onSuccess:(T,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")}}),xs=G({mutationFn:T=>ze.update(parseInt(e),T),onSuccess:(T,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}`)}}),Ds=T=>{const ie=ke=>{if(ke==null||ke==="")return;const ai=parseInt(String(ke));return isNaN(ai)?void 0:ai},be=pe.find(ke=>ke.code===T.type),he=ie(T.customerId);if(!he){alert("Bitte wählen Sie einen Kunden aus");return}if(!T.type||!be){alert("Bitte wählen Sie einen Vertragstyp aus");return}const je=ke=>ke==null||ke===""?null:ke,ot={customerId:he,type:T.type,contractCategoryId:be.id,status:T.status,addressId:ie(T.addressId)??null,billingAddressId:ie(T.billingAddressId)??null,bankCardId:ie(T.bankCardId)??null,identityDocumentId:ie(T.identityDocumentId)??null,salesPlatformId:ie(T.salesPlatformId)??null,providerId:ie(T.providerId)??null,tariffId:ie(T.tariffId)??null,providerName:je(T.providerName),tariffName:je(T.tariffName),customerNumberAtProvider:je(T.customerNumberAtProvider),priceFirst12Months:je(T.priceFirst12Months),priceFrom13Months:je(T.priceFrom13Months),priceAfter24Months:je(T.priceAfter24Months),startDate:T.startDate?new Date(T.startDate):null,endDate:T.endDate?new Date(T.endDate):null,cancellationPeriodId:ie(T.cancellationPeriodId)??null,contractDurationId:ie(T.contractDurationId)??null,commission:T.commission?parseFloat(T.commission):null,portalUsername:A==="manual"?je(T.portalUsername):null,stressfreiEmailId:A==="stressfrei"&&B?parseInt(B):null,portalPassword:T.portalPassword||void 0,notes:je(T.notes),cancellationConfirmationDate:T.cancellationConfirmationDate?new Date(T.cancellationConfirmationDate):null,cancellationConfirmationOptionsDate:T.cancellationConfirmationOptionsDate?new Date(T.cancellationConfirmationOptionsDate):null,wasSpecialCancellation:T.wasSpecialCancellation||!1,previousContractId:ie(T.previousContractId)??null};["ELECTRICITY","GAS"].includes(T.type)&&(ot.energyDetails={meterId:ie(T.meterId)??null,maloId:je(T.maloId),annualConsumption:T.annualConsumption?parseFloat(T.annualConsumption):null,annualConsumptionKwh:T.annualConsumptionKwh?parseFloat(T.annualConsumptionKwh):null,basePrice:T.basePrice?parseFloat(T.basePrice):null,unitPrice:T.unitPrice?parseFloat(T.unitPrice):null,bonus:T.bonus?parseFloat(T.bonus):null,previousProviderName:je(T.previousProviderName),previousCustomerNumber:je(T.previousCustomerNumber)}),["DSL","CABLE","FIBER"].includes(T.type)&&(ot.internetDetails={downloadSpeed:ie(T.downloadSpeed)??null,uploadSpeed:ie(T.uploadSpeed)??null,routerModel:je(T.routerModel),routerSerialNumber:je(T.routerSerialNumber),installationDate:T.installationDate?new Date(T.installationDate):null,internetUsername:je(T.internetUsername),internetPassword:T.internetPassword||void 0,homeId:je(T.homeId),activationCode:je(T.activationCode),phoneNumbers:D.length>0?D.map(ke=>({id:ke.id,phoneNumber:ke.phoneNumber||"",isMain:ke.isMain??!1,sipUsername:je(ke.sipUsername),sipPassword:ke.sipPassword||void 0,sipServer:je(ke.sipServer)})):void 0}),T.type==="MOBILE"&&(ot.mobileDetails={requiresMultisim:T.requiresMultisim||!1,dataVolume:T.dataVolume?parseFloat(T.dataVolume):null,includedMinutes:ie(T.includedMinutes)??null,includedSMS:ie(T.includedSMS)??null,deviceModel:je(T.deviceModel),deviceImei:je(T.deviceImei),phoneNumber:je(T.phoneNumber),simCardNumber:je(T.simCardNumber),simCards:P.length>0?P.map(ke=>({id:ke.id,phoneNumber:je(ke.phoneNumber),simCardNumber:je(ke.simCardNumber),pin:ke.pin||void 0,puk:ke.puk||void 0,isMultisim:ke.isMultisim,isMain:ke.isMain})):void 0}),T.type==="TV"&&(ot.tvDetails={receiverModel:je(T.receiverModel),smartcardNumber:je(T.smartcardNumber),package:je(T.tvPackage)}),T.type==="CAR_INSURANCE"&&(ot.carInsuranceDetails={licensePlate:je(T.licensePlate),hsn:je(T.hsn),tsn:je(T.tsn),vin:je(T.vin),vehicleType:je(T.vehicleType),firstRegistration:T.firstRegistration?new Date(T.firstRegistration):null,noClaimsClass:je(T.noClaimsClass),insuranceType:T.insuranceType,deductiblePartial:T.deductiblePartial?parseFloat(T.deductiblePartial):null,deductibleFull:T.deductibleFull?parseFloat(T.deductibleFull):null,policyNumber:je(T.policyNumber),previousInsurer:je(T.previousInsurer)}),a?xs.mutate(ot):it.mutate(ot)},ln=it.isPending||xs.isPending,te=it.error||xs.error,ge=j==null?void 0:j.data,Vs=(ge==null?void 0:ge.addresses)||[],Fc=((Xr=ge==null?void 0:ge.bankCards)==null?void 0:Xr.filter(T=>T.isActive))||[],Al=((Yr=ge==null?void 0:ge.identityDocuments)==null?void 0:Yr.filter(T=>T.isActive))||[],R=((Ml=ge==null?void 0:ge.meters)==null?void 0:Ml.filter(T=>T.isActive))||[],U=((ni=ge==null?void 0:ge.stressfreiEmails)==null?void 0:ni.filter(T=>T.isActive))||[],Q=(v==null?void 0:v.data)||[],le=(g==null?void 0:g.data)||[],ne=(w==null?void 0:w.data)||[],ee=((Fl=C==null?void 0:C.data)==null?void 0:Fl.filter(T=>T.isActive))||[],pe=((ri=k==null?void 0:k.data)==null?void 0:ri.filter(T=>T.isActive).sort((T,ie)=>T.sortOrder-ie.sortOrder))||[],Ie=pe.map(T=>({value:T.code,label:T.name})),Re=((y==null?void 0:y.data)||[]).filter(T=>!a||T.id!==parseInt(e)).sort((T,ie)=>new Date(ie.startDate||0).getTime()-new Date(T.startDate||0).getTime()),lt=ee.find(T=>T.id===parseInt(F||"0")),on=((xh=lt==null?void 0:lt.tariffs)==null?void 0:xh.filter(T=>T.isActive))||[],Ps=T=>{const ie=T.companyName||`${T.firstName} ${T.lastName}`,be=T.birthDate?` (geb. ${new Date(T.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})`:"";return`${T.customerNumber} - ${ie}${be}`},Tc=(()=>{var be;const ie=((x==null?void 0:x.data)||[]).map(he=>({value:he.id.toString(),label:Ps(he)}));if(a&&((be=f==null?void 0:f.data)!=null&&be.customer)){const he=f.data.customer;ie.some(ot=>ot.value===he.id.toString())||ie.unshift({value:he.id.toString(),label:Ps(he)})}return ie})();return s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold mb-6",children:a?"Vertrag bearbeiten":"Neuer Vertrag"}),te&&s.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:te instanceof Error?te.message:"Ein Fehler ist aufgetreten"}),s.jsxs("form",{onSubmit:o(Ds),children:[s.jsx(Y,{className:"mb-6",title:"Vertragsdaten",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(_e,{label:"Kunde *",...l("customerId",{required:"Kunde erforderlich"}),options:Tc,error:(gh=h.customerId)==null?void 0:gh.message}),s.jsx(_e,{label:"Vertragstyp *",...l("type",{required:"Typ erforderlich"}),options:Ie}),s.jsx(_e,{label:"Status",...l("status"),options:aC}),s.jsx(_e,{label:"Vertriebsplattform",...l("salesPlatformId"),options:Q.map(T=>({value:T.id,label:T.name}))}),m&&s.jsx(_e,{label:"Vorgänger-Vertrag",...l("previousContractId"),options:Re.map(T=>({value:T.id,label:`${T.contractNumber} (${T.type}${T.startDate?` - ${new Date(T.startDate).toLocaleDateString("de-DE")}`:""})`})),placeholder:"Keinen Vorgänger auswählen"})]})}),m&&s.jsxs(Y,{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(_e,{label:"Lieferadresse",...l("addressId"),options:Vs.filter(T=>T.type==="DELIVERY_RESIDENCE").map(T=>({value:T.id,label:`${T.street} ${T.houseNumber}, ${T.postalCode} ${T.city}`}))}),s.jsx(_e,{label:"Rechnungsadresse",...l("billingAddressId"),options:Vs.filter(T=>T.type==="BILLING").map(T=>({value:T.id,label:`${T.street} ${T.houseNumber}, ${T.postalCode} ${T.city}`})),placeholder:"Wie Lieferadresse"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(_e,{label:"Bankkarte",...l("bankCardId"),options:Fc.map(T=>({value:T.id,label:`${T.iban} (${T.accountHolder})`}))}),s.jsx(_e,{label:"Ausweis",...l("identityDocumentId"),options:Al.map(T=>({value:T.id,label:`${T.documentNumber} (${T.type})`}))})]})]}),s.jsx(Y,{className:"mb-6",title:"Anbieter & Tarif",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(_e,{label:"Anbieter",...l("providerId"),options:ee.map(T=>({value:T.id,label:T.name}))}),s.jsx(_e,{label:"Tarif",...l("tariffId"),options:on.map(T=>({value:T.id,label:T.name})),disabled:!F}),s.jsx(V,{label:"Kundennummer beim Anbieter",...l("customerNumberAtProvider")}),s.jsx(V,{label:"Provision (€)",type:"number",step:"0.01",...l("commission")}),s.jsx(V,{label:"Preis erste 12 Monate",...l("priceFirst12Months"),placeholder:"z.B. 29,99 €/Monat"}),s.jsx(V,{label:"Preis ab 13. Monat",...l("priceFrom13Months"),placeholder:"z.B. 39,99 €/Monat"}),s.jsx(V,{label:"Preis nach 24 Monaten",...l("priceAfter24Months"),placeholder:"z.B. 49,99 €/Monat"})]})}),s.jsxs(Y,{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(V,{label:"Vertragsbeginn",type:"date",...l("startDate"),value:d("startDate")||"",onClear:()=>u("startDate","")}),s.jsx(V,{label:"Vertragsende (berechnet)",type:"date",...l("endDate"),disabled:!0,className:"bg-gray-50"}),s.jsx(_e,{label:"Vertragslaufzeit",...l("contractDurationId"),options:ne.map(T=>({value:T.id,label:T.description}))}),s.jsx(_e,{label:"Kündigungsfrist",...l("cancellationPeriodId"),options:le.map(T=>({value:T.id,label:T.description}))}),s.jsx(V,{label:"Kündigungsbestätigungsdatum",type:"date",...l("cancellationConfirmationDate"),value:d("cancellationConfirmationDate")||"",onClear:()=>u("cancellationConfirmationDate","")}),s.jsx(V,{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(Y,{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:A==="manual",onChange:()=>{K("manual"),J("")},className:"text-blue-600"}),s.jsx("span",{className:"text-sm",children:"Manuell eingeben"})]}),A==="manual"&&s.jsx(V,{...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:A==="stressfrei",onChange:()=>{K("stressfrei"),u("portalUsername","")},className:"text-blue-600"}),s.jsx("span",{className:"text-sm",children:"Stressfrei-Wechseln Adresse"})]}),A==="stressfrei"&&s.jsx(_e,{value:B,onChange:T=>J(T.target.value),options:U.map(T=>({value:T.id,label:T.email+(T.notes?` (${T.notes})`:"")})),placeholder:U.length===0?"Keine Stressfrei-Adressen vorhanden":"Adresse auswählen..."}),A==="stressfrei"&&U.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:H?"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:()=>S(!H),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:H?s.jsx(Ft,{className:"w-4 h-4"}):s.jsx(De,{className:"w-4 h-4"})})]})]})]})}),["ELECTRICITY","GAS"].includes(p)&&s.jsx(Y,{className:"mb-6",title:p==="ELECTRICITY"?"Strom-Details":"Gas-Details",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(_e,{label:"Zähler",...l("meterId"),options:R.filter(T=>T.type===p).map(T=>({value:T.id,label:`${T.meterNumber}${T.location?` (${T.location})`:""}`}))}),s.jsx(V,{label:"MaLo-ID (Marktlokations-ID)",...l("maloId")}),s.jsx(V,{label:`Jahresverbrauch (${p==="ELECTRICITY"?"kWh":"m³"})`,type:"number",...l("annualConsumption")}),p==="GAS"&&s.jsx(V,{label:"Jahresverbrauch (kWh)",type:"number",...l("annualConsumptionKwh")}),s.jsx(V,{label:"Grundpreis (€/Monat)",type:"number",step:"any",...l("basePrice")}),s.jsx(V,{label:"Arbeitspreis (€/kWh)",type:"number",step:"any",...l("unitPrice")}),s.jsx(V,{label:"Bonus (€)",type:"number",step:"0.01",...l("bonus")}),s.jsx(V,{label:"Vorversorger",...l("previousProviderName")}),s.jsx(V,{label:"Kundennr. beim Vorversorger",...l("previousCustomerNumber")})]})}),["DSL","CABLE","FIBER"].includes(p)&&s.jsxs(s.Fragment,{children:[s.jsx(Y,{className:"mb-6",title:p==="DSL"?"DSL-Details":p==="CABLE"?"Kabelinternet-Details":"Glasfaser-Details",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(V,{label:"Download (Mbit/s)",type:"number",...l("downloadSpeed")}),s.jsx(V,{label:"Upload (Mbit/s)",type:"number",...l("uploadSpeed")}),s.jsx(V,{label:"Router Modell",...l("routerModel")}),s.jsx(V,{label:"Router Seriennummer",...l("routerSerialNumber")}),s.jsx(V,{label:"Installationsdatum",type:"date",...l("installationDate"),value:d("installationDate")||"",onClear:()=>u("installationDate","")}),p==="FIBER"&&s.jsx(V,{label:"Home-ID",...l("homeId")}),((yh=lt==null?void 0:lt.name)==null?void 0:yh.toLowerCase().includes("vodafone"))&&["DSL","CABLE"].includes(p)&&s.jsx(V,{label:"Aktivierungscode",...l("activationCode")})]})}),s.jsx(Y,{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(V,{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:oe?"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(!oe),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:oe?s.jsx(Ft,{className:"w-4 h-4"}):s.jsx(De,{className:"w-4 h-4"})})]})]})]})}),s.jsxs(Y,{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."}),D.length>0&&s.jsx("div",{className:"space-y-4 mb-4",children:D.map((T,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:T.isMain,onChange:be=>{const he=[...D];be.target.checked?he.forEach((je,ot)=>je.isMain=ot===ie):he[ie].isMain=!1,_(he)},className:"rounded border-gray-300"}),"Hauptnummer"]})]}),s.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>{_(D.filter((be,he)=>he!==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(V,{label:"Rufnummer",value:T.phoneNumber,onChange:be=>{const he=[...D];he[ie].phoneNumber=be.target.value,_(he)},placeholder:"z.B. 030 123456"}),s.jsx(V,{label:"SIP-Benutzername",value:T.sipUsername,onChange:be=>{const he=[...D];he[ie].sipUsername=be.target.value,_(he)}}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:T.hasExistingSipPassword?"SIP-Passwort (bereits hinterlegt)":"SIP-Passwort"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:Fe[ie]?"text":"password",value:T.sipPassword,onChange:be=>{const he=[...D];he[ie].sipPassword=be.target.value,_(he)},placeholder:T.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:()=>Ye(be=>({...be,[ie]:!be[ie]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:Fe[ie]?s.jsx(Ft,{className:"w-4 h-4"}):s.jsx(De,{className:"w-4 h-4"})})]})]}),s.jsx(V,{label:"SIP-Server",value:T.sipServer,onChange:be=>{const he=[...D];he[ie].sipServer=be.target.value,_(he)},placeholder:"z.B. sip.provider.de"})]})]},ie))}),s.jsxs(I,{type:"button",variant:"secondary",onClick:()=>{_([...D,{phoneNumber:"",sipUsername:"",sipPassword:"",sipServer:"",isMain:D.length===0}])},children:[s.jsx(Ue,{className:"w-4 h-4 mr-2"}),"Rufnummer hinzufügen"]})]})]}),p==="MOBILE"&&s.jsxs(s.Fragment,{children:[s.jsxs(Y,{className:"mb-6",title:"Mobilfunk-Details",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(V,{label:"Datenvolumen (GB)",type:"number",...l("dataVolume")}),s.jsx(V,{label:"Inklusiv-Minuten",type:"number",...l("includedMinutes")}),s.jsx(V,{label:"Inklusiv-SMS",type:"number",...l("includedSMS")}),s.jsx(V,{label:"Gerät (Modell)",...l("deviceModel")}),s.jsx(V,{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(Y,{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)."}),P.length>0&&s.jsx("div",{className:"space-y-4 mb-4",children:P.map((T,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:T.isMain,onChange:be=>{const he=[...P];be.target.checked?he.forEach((je,ot)=>je.isMain=ot===ie):he[ie].isMain=!1,z(he)},className:"rounded border-gray-300"}),"Hauptkarte"]}),s.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[s.jsx("input",{type:"checkbox",checked:T.isMultisim,onChange:be=>{const he=[...P];he[ie].isMultisim=be.target.checked,z(he)},className:"rounded border-gray-300"}),"Multisim"]})]}),s.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>{z(P.filter((be,he)=>he!==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(V,{label:"Rufnummer",value:T.phoneNumber,onChange:be=>{const he=[...P];he[ie].phoneNumber=be.target.value,z(he)},placeholder:"z.B. 0171 1234567"}),s.jsx(V,{label:"SIM-Kartennummer",value:T.simCardNumber,onChange:be=>{const he=[...P];he[ie].simCardNumber=be.target.value,z(he)},placeholder:"ICCID"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:T.hasExistingPin?"PIN (bereits hinterlegt)":"PIN"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:Ze[ie]?"text":"password",value:T.pin,onChange:be=>{const he=[...P];he[ie].pin=be.target.value,z(he)},placeholder:T.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:()=>xt(be=>({...be,[ie]:!be[ie]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:Ze[ie]?s.jsx(Ft,{className:"w-4 h-4"}):s.jsx(De,{className:"w-4 h-4"})})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:T.hasExistingPuk?"PUK (bereits hinterlegt)":"PUK"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:W[ie]?"text":"password",value:T.puk,onChange:be=>{const he=[...P];he[ie].puk=be.target.value,z(he)},placeholder:T.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(be=>({...be,[ie]:!be[ie]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:W[ie]?s.jsx(Ft,{className:"w-4 h-4"}):s.jsx(De,{className:"w-4 h-4"})})]})]})]})]},ie))}),s.jsxs(I,{type:"button",variant:"secondary",onClick:()=>{z([...P,{phoneNumber:"",simCardNumber:"",pin:"",puk:"",isMultisim:!1,isMain:P.length===0}])},children:[s.jsx(Ue,{className:"w-4 h-4 mr-2"}),"SIM-Karte hinzufügen"]})]})]}),p==="TV"&&s.jsx(Y,{className:"mb-6",title:"TV-Details",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(V,{label:"Receiver Modell",...l("receiverModel")}),s.jsx(V,{label:"Smartcard-Nummer",...l("smartcardNumber")}),s.jsx(V,{label:"Paket",...l("tvPackage"),placeholder:"z.B. Basis, Premium, Sport"})]})}),p==="CAR_INSURANCE"&&s.jsx(Y,{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(V,{label:"Kennzeichen",...l("licensePlate")}),s.jsx(V,{label:"HSN",...l("hsn")}),s.jsx(V,{label:"TSN",...l("tsn")}),s.jsx(V,{label:"FIN (VIN)",...l("vin")}),s.jsx(V,{label:"Fahrzeugtyp",...l("vehicleType")}),s.jsx(V,{label:"Erstzulassung",type:"date",...l("firstRegistration"),value:d("firstRegistration")||"",onClear:()=>u("firstRegistration","")}),s.jsx(V,{label:"SF-Klasse",...l("noClaimsClass")}),s.jsx(_e,{label:"Versicherungsart",...l("insuranceType"),options:[{value:"LIABILITY",label:"Haftpflicht"},{value:"PARTIAL",label:"Teilkasko"},{value:"FULL",label:"Vollkasko"}]}),s.jsx(V,{label:"SB Teilkasko (€)",type:"number",...l("deductiblePartial")}),s.jsx(V,{label:"SB Vollkasko (€)",type:"number",...l("deductibleFull")}),s.jsx(V,{label:"Versicherungsscheinnummer",...l("policyNumber")}),s.jsx(V,{label:"Vorversicherer",...l("previousInsurer")})]})}),s.jsx(Y,{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(I,{type:"button",variant:"secondary",onClick:()=>n(-1),children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:ln,children:ln?"Speichern...":"Speichern"})]})]})]})}const iC={ELECTRICITY:dh,GAS:yv,DSL:wa,CABLE:wa,FIBER:wa,MOBILE:oh,TV:Sv,CAR_INSURANCE:xv},lC={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabel",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ"},oC={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"},cC={critical:"danger",warning:"warning",ok:"success",none:"default"},dC={cancellation_deadline:pv,contract_ending:Pn,missing_cancellation_letter:He,missing_cancellation_confirmation:He,missing_portal_credentials:D2,missing_customer_number:He,missing_provider:He,missing_address:He,missing_bank:He,missing_meter:dh,missing_sim:oh,open_tasks:al,pending_status:Pn,draft_status:He},uC={cancellationDeadlines:"Kündigungsfristen",contractEnding:"Vertragsenden",missingCredentials:"Fehlende Zugangsdaten",missingData:"Fehlende Daten",openTasks:"Offene Aufgaben",pendingContracts:"Wartende Verträge"};function mC(){var x;const[e,t]=jc(),[n,r]=b.useState(new Set),a=e.get("filter"),[i,l]=b.useState(a||"all");b.useEffect(()=>{i==="all"?e.delete("filter"):e.set("filter",i),t(e,{replace:!0})},[i,e,t]);const{data:o,isLoading:c,error:d}=me({queryKey:["contract-cockpit"],queryFn:()=>ze.getCockpit(),staleTime:0}),u=j=>{r(y=>{const v=new Set(y);return v.has(j)?v.delete(j):v.add(j),v})},h=b.useMemo(()=>{var y;if(!((y=o==null?void 0:o.data)!=null&&y.contracts))return[];const j=o.data.contracts;switch(i){case"critical":return j.filter(v=>v.highestUrgency==="critical");case"warning":return j.filter(v=>v.highestUrgency==="warning");case"ok":return j.filter(v=>v.highestUrgency==="ok");case"deadlines":return j.filter(v=>v.issues.some(g=>["cancellation_deadline","contract_ending"].includes(g.type)));case"credentials":return j.filter(v=>v.issues.some(g=>g.type.includes("credentials")));case"data":return j.filter(v=>v.issues.some(g=>g.type.startsWith("missing_")&&!g.type.includes("credentials")));case"tasks":return j.filter(v=>v.issues.some(g=>["open_tasks","pending_status","draft_status"].includes(g.type)));default:return j}},[(x=o==null?void 0:o.data)==null?void 0:x.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:p,thresholds:m}=o.data,f=j=>{var g,w,C,k;const y=n.has(j.id),v=iC[j.type]||He;return s.jsxs("div",{className:`border rounded-lg mb-2 ${oC[j.highestUrgency]}`,children:[s.jsxs("div",{className:"flex items-center p-4 cursor-pointer hover:bg-opacity-50",onClick:()=>u(j.id),children:[s.jsx("div",{className:"w-6 mr-2",children:y?s.jsx(xr,{className:"w-5 h-5"}):s.jsx(Mt,{className:"w-5 h-5"})}),s.jsx(v,{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(Se,{to:`/contracts/${j.id}`,state:{from:"cockpit",filter:i!=="all"?i:void 0},className:"font-medium hover:underline",onClick:F=>F.stopPropagation(),children:j.contractNumber}),s.jsxs(ye,{variant:cC[j.highestUrgency],children:[j.issues.length," ",j.highestUrgency==="ok"?j.issues.length===1?"Hinweis":"Hinweise":j.issues.length===1?"Problem":"Probleme"]}),s.jsx("span",{className:"text-sm",children:lC[j.type]})]}),s.jsxs("div",{className:"text-sm mt-1",children:[s.jsxs(Se,{to:`/customers/${j.customer.id}`,className:"hover:underline",onClick:F=>F.stopPropagation(),children:[j.customer.customerNumber," - ",j.customer.name]}),(((g=j.provider)==null?void 0:g.name)||j.providerName)&&s.jsxs("span",{className:"ml-2",children:["| ",((w=j.provider)==null?void 0:w.name)||j.providerName,(((C=j.tariff)==null?void 0:C.name)||j.tariffName)&&` - ${((k=j.tariff)==null?void 0:k.name)||j.tariffName}`]})]})]}),s.jsx(Se,{to:`/contracts/${j.id}`,state:{from:"cockpit",filter:i!=="all"?i:void 0},className:"ml-4 p-2 hover:bg-white hover:bg-opacity-50 rounded",onClick:F=>F.stopPropagation(),title:"Zum Vertrag",children:s.jsx(De,{className:"w-4 h-4"})})]}),y&&s.jsx("div",{className:"border-t px-4 py-3 bg-white bg-opacity-50",children:s.jsx("div",{className:"space-y-2",children:j.issues.map((F,N)=>{const E=dC[F.type]||bn,P=F.urgency==="critical"?bn:F.urgency==="warning"?Es:F.urgency==="ok"?ws:Pn;return s.jsxs("div",{className:"flex items-start gap-3 text-sm",children:[s.jsx(P,{className:`w-4 h-4 mt-0.5 flex-shrink-0 ${F.urgency==="critical"?"text-red-500":F.urgency==="warning"?"text-yellow-500":F.urgency==="ok"?"text-green-500":"text-gray-500"}`}),s.jsx(E,{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:F.label}),F.details&&s.jsx("span",{className:"text-gray-600 ml-2",children:F.details})]})]},N)})})})]},j.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(bn,{className:"w-6 h-6 text-red-500"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Vertrags-Cockpit"})]}),s.jsx(Se,{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(Y,{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(bn,{className:"w-6 h-6 text-red-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-red-600",children:p.criticalCount}),s.jsxs("p",{className:"text-sm text-gray-500",children:["Kritisch (<",m.criticalDays," Tage)"]})]})]})}),s.jsx(Y,{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(Es,{className:"w-6 h-6 text-yellow-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-yellow-600",children:p.warningCount}),s.jsxs("p",{className:"text-sm text-gray-500",children:["Warnung (<",m.warningDays," Tage)"]})]})]})}),s.jsx(Y,{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(ws,{className:"w-6 h-6 text-green-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-green-600",children:p.okCount}),s.jsxs("p",{className:"text-sm text-gray-500",children:["OK (<",m.okDays," Tage)"]})]})]})}),s.jsx(Y,{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(He,{className:"w-6 h-6 text-gray-500"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-gray-600",children:p.totalContracts}),s.jsx("p",{className:"text-sm text-gray-500",children:"Verträge mit Handlungsbedarf"})]})]})})]}),s.jsx(Y,{className:"mb-6",children:s.jsx("div",{className:"flex flex-wrap gap-4",children:Object.entries(p.byCategory).map(([j,y])=>y>0&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsxs("span",{className:"font-medium",children:[uC[j]||j,":"]}),s.jsx(ye,{variant:"default",children:y})]},j))})}),s.jsx(Y,{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(_e,{value:i,onChange:j=>l(j.target.value),options:[{value:"all",label:`Alle (${o.data.contracts.length})`},{value:"critical",label:`Kritisch (${p.criticalCount})`},{value:"warning",label:`Warnung (${p.warningCount})`},{value:"ok",label:`OK (${p.okCount})`},{value:"deadlines",label:`Fristen (${p.byCategory.cancellationDeadlines+p.byCategory.contractEnding})`},{value:"credentials",label:`Zugangsdaten (${p.byCategory.missingCredentials})`},{value:"data",label:`Fehlende Daten (${p.byCategory.missingData})`},{value:"tasks",label:`Aufgaben/Status (${p.byCategory.openTasks+p.byCategory.pendingContracts})`}],className:"w-64"}),s.jsxs("span",{className:"text-sm text-gray-500",children:[h.length," Verträge angezeigt"]})]})}),h.length===0?s.jsx(Y,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:i==="all"?s.jsxs(s.Fragment,{children:[s.jsx(ws,{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:h.map(f)})]})}const Tx={OPEN:"Offen",COMPLETED:"Erledigt"},hC={OPEN:"warning",COMPLETED:"success"};function fC(){var $;const e=Gt(),t=xe(),{isCustomerPortal:n,user:r,hasPermission:a}=qe(),[i,l]=b.useState("OPEN"),[o,c]=b.useState(new Set),[d,u]=b.useState(!1),[h,p]=b.useState({}),m=n?"Support-Anfragen":"Aufgaben",f=n?"Anfrage":"Aufgabe",{data:x,isLoading:j}=me({queryKey:["app-settings-public"],queryFn:()=>Wr.getPublic(),enabled:n,staleTime:0}),y=!j&&(($=x==null?void 0:x.data)==null?void 0:$.customerSupportTicketsEnabled)==="true",{data:v,isLoading:g}=me({queryKey:["all-tasks",i],queryFn:()=>mt.getAll({status:i||void 0}),staleTime:0}),w=G({mutationFn:L=>mt.completeSubtask(L),onSuccess:()=>{t.invalidateQueries({queryKey:["all-tasks"]}),t.invalidateQueries({queryKey:["task-stats"]})}}),C=G({mutationFn:L=>mt.reopenSubtask(L),onSuccess:()=>{t.invalidateQueries({queryKey:["all-tasks"]}),t.invalidateQueries({queryKey:["task-stats"]})}}),k=G({mutationFn:({taskId:L,title:A})=>n?mt.createReply(L,A):mt.createSubtask(L,A),onSuccess:(L,{taskId:A})=>{t.invalidateQueries({queryKey:["all-tasks"]}),p(K=>({...K,[A]:""}))}}),F=b.useMemo(()=>{var B;if(!(v!=null&&v.data))return{ownTasks:[],representedTasks:[],allTasks:[]};const L=v.data;if(!n)return{allTasks:L,ownTasks:[],representedTasks:[]};const A=[],K=[];for(const J of L)((B=J.contract)==null?void 0:B.customerId)===(r==null?void 0:r.customerId)?A.push(J):K.push(J);return{ownTasks:A,representedTasks:K,allTasks:[]}},[v==null?void 0:v.data,n,r==null?void 0:r.customerId]),N=L=>{c(A=>{const K=new Set(A);return K.has(L)?K.delete(L):K.add(L),K})},E=L=>{w.isPending||C.isPending||(L.status==="COMPLETED"?C.mutate(L.id):w.mutate(L.id))},P=L=>{var K;const A=(K=h[L])==null?void 0:K.trim();A&&k.mutate({taskId:L,title:A})},z=!n&&a("contracts:update"),D=(L,A=!1)=>{var Fe,Ye,Ze,xt,W,Ae;const K=o.has(L.id),B=L.subtasks&&L.subtasks.length>0,J=((Fe=L.subtasks)==null?void 0:Fe.filter(Z=>Z.status==="COMPLETED").length)||0,H=((Ye=L.subtasks)==null?void 0:Ye.length)||0,S=L.status==="COMPLETED",oe=L.contract?`${L.contract.contractNumber} - ${((Ze=L.contract.provider)==null?void 0:Ze.name)||L.contract.providerName||"Kein Anbieter"}`:`Vertrag #${L.contractId}`,Ve=(xt=L.contract)!=null&&xt.customer?L.contract.customer.companyName||`${L.contract.customer.firstName} ${L.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:()=>N(L.id),children:[s.jsx("div",{className:"w-6 mr-2",children:K?s.jsx(xr,{className:"w-5 h-5 text-gray-400"}):s.jsx(Mt,{className:"w-5 h-5 text-gray-400"})}),s.jsx("div",{className:"mr-3",children:L.status==="COMPLETED"?s.jsx(ws,{className:"w-5 h-5 text-green-500"}):s.jsx(Pn,{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:L.title}),s.jsx(ye,{variant:hC[L.status],children:Tx[L.status]}),B&&s.jsxs("span",{className:"text-xs text-gray-500",children:["(",J,"/",H," erledigt)"]})]}),s.jsxs("div",{className:"text-sm text-gray-500 mt-1 flex items-center gap-2",children:[s.jsx(He,{className:"w-4 h-4"}),s.jsx(Se,{to:`/contracts/${L.contractId}`,className:"text-blue-600 hover:underline",onClick:Z=>Z.stopPropagation(),children:oe}),A&&Ve&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-gray-400",children:"|"}),s.jsx("span",{children:Ve})]})]}),L.description&&s.jsx("p",{className:"text-sm text-gray-600 mt-1 line-clamp-2",children:L.description})]}),s.jsx("div",{className:"ml-4 flex gap-2",children:s.jsx(I,{variant:"ghost",size:"sm",onClick:Z=>{Z.stopPropagation(),e(`/contracts/${L.contractId}`)},title:"Zum Vertrag",children:s.jsx(De,{className:"w-4 h-4"})})})]}),K&&s.jsxs("div",{className:"border-t bg-gray-50 px-4 py-3",children:[B&&s.jsx("div",{className:"space-y-2 mb-4",children:(W=L.subtasks)==null?void 0:W.map(Z=>{const Te=new Date(Z.createdAt).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"});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?()=>E(Z):void 0,children:[s.jsx("span",{className:"flex-shrink-0 mt-0.5",children:Z.status==="COMPLETED"?s.jsx(ws,{className:"w-4 h-4 text-green-500"}):s.jsx(vo,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:Z.status==="COMPLETED"?"text-gray-500 line-through":"",children:[Z.title,s.jsxs("span",{className:"text-xs text-gray-400 ml-2",children:[Z.createdBy," • ",Te]})]})]},Z.id)})}),!S&&(z||n)&&s.jsxs("div",{className:"flex gap-2 ml-6",children:[s.jsx(V,{placeholder:n?"Antwort schreiben...":"Neue Unteraufgabe...",value:h[L.id]||"",onChange:Z=>p(Te=>({...Te,[L.id]:Z.target.value})),onKeyDown:Z=>{Z.key==="Enter"&&!Z.shiftKey&&(Z.preventDefault(),P(L.id))},className:"flex-1"}),s.jsx(I,{size:"sm",onClick:()=>P(L.id),disabled:!((Ae=h[L.id])!=null&&Ae.trim())||k.isPending,children:s.jsx(El,{className:"w-4 h-4"})})]}),!B&&S&&s.jsx("p",{className:"text-gray-500 text-sm text-center py-2",children:"Keine Unteraufgaben vorhanden."})]})]},L.id)},_=n?y: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:m}),_&&s.jsxs(I,{onClick:()=>u(!0),children:[s.jsx(Ue,{className:"w-4 h-4 mr-2"}),"Neue ",f]})]}),s.jsx(Y,{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(_e,{value:i,onChange:L=>l(L.target.value),options:[{value:"",label:"Alle"},...Object.entries(Tx).map(([L,A])=>({value:L,label:A}))],className:"w-40"})]})})}),g?s.jsx(Y,{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(Y,{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:[s.jsx(Dl,{className:"w-5 h-5 text-blue-600"}),s.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:["Meine ",m]}),s.jsx(ye,{variant:"default",children:F.ownTasks.length})]}),F.ownTasks.length>0?s.jsx("div",{children:F.ownTasks.map(L=>D(L,!1))}):s.jsxs("p",{className:"text-gray-500 text-center py-4",children:["Keine eigenen ",m.toLowerCase()," vorhanden."]})]}),F.representedTasks.length>0&&s.jsxs(Y,{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:[s.jsx(Na,{className:"w-5 h-5 text-purple-600"}),s.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:[m," freigegebener Kunden"]}),s.jsx(ye,{variant:"default",children:F.representedTasks.length})]}),s.jsx("div",{children:F.representedTasks.map(L=>D(L,!0))})]})]}):s.jsx(Y,{children:F.allTasks&&F.allTasks.length>0?s.jsx("div",{children:F.allTasks.map(L=>D(L,!0))}):s.jsxs("div",{className:"text-center py-8 text-gray-500",children:["Keine ",m.toLowerCase()," gefunden."]})})}),n?s.jsx(pC,{isOpen:d,onClose:()=>u(!1)}):s.jsx(xC,{isOpen:d,onClose:()=>u(!1)})]})}function pC({isOpen:e,onClose:t}){const{user:n}=qe(),r=Gt(),a=xe(),[i,l]=b.useState("own"),[o,c]=b.useState(null),[d,u]=b.useState(""),[h,p]=b.useState(""),[m,f]=b.useState(!1),[x,j]=b.useState(""),{data:y}=me({queryKey:["contracts",n==null?void 0:n.customerId],queryFn:()=>ze.getAll({customerId:n==null?void 0:n.customerId}),enabled:e}),v=b.useMemo(()=>{if(!(y!=null&&y.data))return{own:[],represented:{}};const N=[],E={};for(const P of y.data)if(P.customerId===(n==null?void 0:n.customerId))N.push(P);else{if(!E[P.customerId]){const z=P.customer?P.customer.companyName||`${P.customer.firstName} ${P.customer.lastName}`:`Kunde ${P.customerId}`;E[P.customerId]={name:z,contracts:[]}}E[P.customerId].contracts.push(P)}return{own:N,represented:E}},[y==null?void 0:y.data,n==null?void 0:n.customerId]),g=Object.keys(v.represented).length>0,w=b.useMemo(()=>{var N;return i==="own"?v.own:((N=v.represented[i])==null?void 0:N.contracts)||[]},[i,v]),C=b.useMemo(()=>{if(!x)return w;const N=x.toLowerCase();return w.filter(E=>E.contractNumber.toLowerCase().includes(N)||(E.providerName||"").toLowerCase().includes(N)||(E.tariffName||"").toLowerCase().includes(N))},[w,x]),k=async()=>{if(!(!o||!d.trim())){f(!0);try{await mt.createSupportTicket(o,{title:d.trim(),description:h.trim()||void 0}),a.invalidateQueries({queryKey:["all-tasks"]}),a.invalidateQueries({queryKey:["task-stats"]}),t(),u(""),p(""),c(null),l("own"),r(`/contracts/${o}`)}catch(N){console.error("Fehler beim Erstellen der Support-Anfrage:",N),alert("Fehler beim Erstellen der Support-Anfrage. Bitte versuchen Sie es erneut.")}finally{f(!1)}}},F=()=>{u(""),p(""),c(null),l("own"),j(""),t()};return s.jsx(Ge,{isOpen:e,onClose:F,title:"Neue Support-Anfrage",children:s.jsxs("div",{className:"space-y-4",children:[g&&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:N=>{const E=N.target.value;l(E==="own"?"own":parseInt(E)),c(null),j("")},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(v.represented).map(([N,{name:E}])=>s.jsx("option",{value:N,children:E},N))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),s.jsx(V,{placeholder:"Vertrag suchen...",value:x,onChange:N=>j(N.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-lg",children:C.length>0?C.map(N=>s.jsxs("div",{onClick:()=>c(N.id),className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${o===N.id?"bg-blue-50 border-blue-200":""}`,children:[s.jsx("div",{className:"font-medium",children:N.contractNumber}),s.jsxs("div",{className:"text-sm text-gray-500",children:[N.providerName||"Kein Anbieter",N.tariffName&&` - ${N.tariffName}`]})]},N.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(V,{value:d,onChange:N=>u(N.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:N=>p(N.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(I,{variant:"secondary",onClick:F,children:"Abbrechen"}),s.jsx(I,{onClick:k,disabled:!o||!d.trim()||m,children:m?"Wird erstellt...":"Anfrage erstellen"})]})]})})}function xC({isOpen:e,onClose:t}){const n=Gt(),r=xe(),[a,i]=b.useState(null),[l,o]=b.useState(null),[c,d]=b.useState(""),[u,h]=b.useState(""),[p,m]=b.useState(!1),[f,x]=b.useState(!1),[j,y]=b.useState(""),[v,g]=b.useState(""),{data:w}=me({queryKey:["customers-for-task"],queryFn:()=>Et.getAll({limit:100}),enabled:e}),{data:C}=me({queryKey:["contracts-for-task",a],queryFn:()=>ze.getAll({customerId:a}),enabled:e&&a!==null}),k=b.useMemo(()=>{if(!(w!=null&&w.data))return[];if(!j)return w.data;const z=j.toLowerCase();return w.data.filter(D=>D.customerNumber.toLowerCase().includes(z)||D.firstName.toLowerCase().includes(z)||D.lastName.toLowerCase().includes(z)||(D.companyName||"").toLowerCase().includes(z))},[w==null?void 0:w.data,j]),F=b.useMemo(()=>{if(!(C!=null&&C.data))return[];if(!v)return C.data;const z=v.toLowerCase();return C.data.filter(D=>D.contractNumber.toLowerCase().includes(z)||(D.providerName||"").toLowerCase().includes(z)||(D.tariffName||"").toLowerCase().includes(z))},[C==null?void 0:C.data,v]),N=async()=>{if(!(!l||!c.trim())){x(!0);try{await mt.create(l,{title:c.trim(),description:u.trim()||void 0,visibleInPortal:p}),r.invalidateQueries({queryKey:["all-tasks"]}),r.invalidateQueries({queryKey:["task-stats"]}),t(),d(""),h(""),m(!1),o(null),i(null),n(`/contracts/${l}`)}catch(z){console.error("Fehler beim Erstellen der Aufgabe:",z),alert("Fehler beim Erstellen der Aufgabe. Bitte versuchen Sie es erneut.")}finally{x(!1)}}},E=()=>{d(""),h(""),m(!1),o(null),i(null),y(""),g(""),t()},P=z=>{const D=z.companyName||`${z.firstName} ${z.lastName}`;return`${z.customerNumber} - ${D}`};return s.jsx(Ge,{isOpen:e,onClose:E,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(V,{placeholder:"Kunde suchen...",value:j,onChange:z=>y(z.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-40 overflow-y-auto border rounded-lg",children:k.length>0?k.map(z=>s.jsx("div",{onClick:()=>{i(z.id),o(null),g("")},className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${a===z.id?"bg-blue-50 border-blue-200":""}`,children:s.jsx("div",{className:"font-medium",children:P(z)})},z.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(V,{placeholder:"Vertrag suchen...",value:v,onChange:z=>g(z.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-40 overflow-y-auto border rounded-lg",children:F.length>0?F.map(z=>s.jsxs("div",{onClick:()=>o(z.id),className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${l===z.id?"bg-blue-50 border-blue-200":""}`,children:[s.jsx("div",{className:"font-medium",children:z.contractNumber}),s.jsxs("div",{className:"text-sm text-gray-500",children:[z.providerName||"Kein Anbieter",z.tariffName&&` - ${z.tariffName}`]})]},z.id)):s.jsx("div",{className:"p-3 text-gray-500 text-center",children:C?"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(V,{value:c,onChange:z=>d(z.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:z=>h(z.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:p,onChange:z=>m(z.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(I,{variant:"secondary",onClick:E,children:"Abbrechen"}),s.jsx(I,{onClick:N,disabled:!l||!c.trim()||f,children:f?"Wird erstellt...":"Aufgabe erstellen"})]})]})})}function gC(){const[e,t]=b.useState(!1),[n,r]=b.useState(null),[a,i]=b.useState(!1),{hasPermission:l}=qe(),o=xe(),{data:c,isLoading:d}=me({queryKey:["platforms",a],queryFn:()=>tl.getAll(a)}),u=G({mutationFn:tl.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["platforms"]})}}),h=m=>{r(m),t(!0)},p=()=>{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(I,{onClick:()=>t(!0),children:[s.jsx(Ue,{className:"w-4 h-4 mr-2"}),"Neue Plattform"]})]}),s.jsxs(Y,{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(ye,{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(I,{variant:"ghost",size:"sm",onClick:()=>h(m),children:s.jsx(at,{className:"w-4 h-4"})}),l("platforms:delete")&&s.jsx(I,{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(yC,{isOpen:e,onClose:p,platform:n})]})}function yC({isOpen:e,onClose:t,platform:n}){const r=xe(),[a,i]=b.useState({name:"",contactInfo:"",isActive:!0});b.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:tl.create,onSuccess:()=>{r.invalidateQueries({queryKey:["platforms"]}),t(),i({name:"",contactInfo:"",isActive:!0})}}),o=G({mutationFn:u=>tl.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(Ge,{isOpen:e,onClose:t,title:n?"Plattform bearbeiten":"Neue Plattform",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(V,{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(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}function vC(){const[e,t]=b.useState(!1),[n,r]=b.useState(null),[a,i]=b.useState(!1),{hasPermission:l}=qe(),o=xe(),{data:c,isLoading:d}=me({queryKey:["cancellation-periods",a],queryFn:()=>sl.getAll(a)}),u=G({mutationFn:sl.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["cancellation-periods"]})}}),h=m=>{r(m),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(Se,{to:"/settings",children:s.jsx(I,{variant:"ghost",size:"sm",children:s.jsx(Us,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Kündigungsfristen"}),l("platforms:create")&&s.jsxs(I,{onClick:()=>t(!0),children:[s.jsx(Ue,{className:"w-4 h-4 mr-2"}),"Neue Frist"]})]}),s.jsxs(Y,{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(ye,{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(I,{variant:"ghost",size:"sm",onClick:()=>h(m),children:s.jsx(at,{className:"w-4 h-4"})}),l("platforms:delete")&&s.jsx(I,{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(jC,{isOpen:e,onClose:p,period:n})]})}function jC({isOpen:e,onClose:t,period:n}){const r=xe(),[a,i]=b.useState({code:"",description:"",isActive:!0});b.useEffect(()=>{e&&i(n?{code:n.code,description:n.description,isActive:n.isActive}:{code:"",description:"",isActive:!0})},[e,n]);const l=G({mutationFn:sl.create,onSuccess:()=>{r.invalidateQueries({queryKey:["cancellation-periods"]}),t(),i({code:"",description:"",isActive:!0})}}),o=G({mutationFn:u=>sl.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(Ge,{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(V,{label:"Code *",value:a.code,onChange:u=>i({...a,code:u.target.value.toUpperCase()}),required:!0,placeholder:"z.B. 14T, 3M, 1J"}),s.jsx(V,{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(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}function bC(){const[e,t]=b.useState(!1),[n,r]=b.useState(null),[a,i]=b.useState(!1),{hasPermission:l}=qe(),o=xe(),{data:c,isLoading:d}=me({queryKey:["contract-durations",a],queryFn:()=>nl.getAll(a)}),u=G({mutationFn:nl.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["contract-durations"]})}}),h=m=>{r(m),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(Se,{to:"/settings",children:s.jsx(I,{variant:"ghost",size:"sm",children:s.jsx(Us,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Vertragslaufzeiten"}),l("platforms:create")&&s.jsxs(I,{onClick:()=>t(!0),children:[s.jsx(Ue,{className:"w-4 h-4 mr-2"}),"Neue Laufzeit"]})]}),s.jsxs(Y,{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(ye,{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(I,{variant:"ghost",size:"sm",onClick:()=>h(m),children:s.jsx(at,{className:"w-4 h-4"})}),l("platforms:delete")&&s.jsx(I,{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(NC,{isOpen:e,onClose:p,duration:n})]})}function NC({isOpen:e,onClose:t,duration:n}){const r=xe(),[a,i]=b.useState({code:"",description:"",isActive:!0});b.useEffect(()=>{e&&i(n?{code:n.code,description:n.description,isActive:n.isActive}:{code:"",description:"",isActive:!0})},[e,n]);const l=G({mutationFn:nl.create,onSuccess:()=>{r.invalidateQueries({queryKey:["contract-durations"]}),t(),i({code:"",description:"",isActive:!0})}}),o=G({mutationFn:u=>nl.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(Ge,{isOpen:e,onClose:t,title:n?"Laufzeit bearbeiten":"Neue Laufzeit",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(V,{label:"Code *",value:a.code,onChange:u=>i({...a,code:u.target.value.toUpperCase()}),required:!0,placeholder:"z.B. 12M, 24M, 2J"}),s.jsx(V,{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(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}function wC(){const[e,t]=b.useState(!1),[n,r]=b.useState(null),[a,i]=b.useState(!1),[l,o]=b.useState(new Set),{hasPermission:c}=qe(),d=xe(),{data:u,isLoading:h}=me({queryKey:["providers",a],queryFn:()=>Wa.getAll(a)}),p=G({mutationFn:Wa.delete,onSuccess:()=>{d.invalidateQueries({queryKey:["providers"]})},onError:j=>{alert(j.message)}}),m=j=>{o(y=>{const v=new Set(y);return v.has(j)?v.delete(j):v.add(j),v})},f=j=>{r(j),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(Se,{to:"/settings",children:s.jsx(I,{variant:"ghost",size:"sm",children:s.jsx(Us,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Anbieter & Tarife"}),c("providers:create")&&s.jsxs(I,{onClick:()=>t(!0),children:[s.jsx(Ue,{className:"w-4 h-4 mr-2"}),"Neuer Anbieter"]})]}),s.jsxs(Y,{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:j=>i(j.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(j=>s.jsx(SC,{provider:j,isExpanded:l.has(j.id),onToggle:()=>m(j.id),onEdit:()=>f(j),onDelete:()=>{confirm("Anbieter wirklich löschen?")&&p.mutate(j.id)},hasPermission:c,showInactive:a},j.id))}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Anbieter vorhanden."})]}),s.jsx(kC,{isOpen:e,onClose:x,provider:n})]})}function SC({provider:e,isExpanded:t,onToggle:n,onEdit:r,onDelete:a,hasPermission:i,showInactive:l}){var f,x;const[o,c]=b.useState(!1),[d,u]=b.useState(null),h=xe(),p=G({mutationFn:cv.delete,onSuccess:()=>{h.invalidateQueries({queryKey:["providers"]})},onError:j=>{alert(j.message)}}),m=((f=e.tariffs)==null?void 0:f.filter(j=>l||j.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(xr,{className:"w-5 h-5 text-gray-400"}):s.jsx(Mt,{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(ye,{variant:e.isActive?"success":"danger",children:e.isActive?"Aktiv":"Inaktiv"}),s.jsxs("span",{className:"text-sm text-gray-500",children:["(",m.length," Tarife, ",((x=e._count)==null?void 0:x.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(ih,{className:"w-3 h-3"}),e.portalUrl]})]}),s.jsxs("div",{className:"flex gap-2 ml-4",children:[i("providers:update")&&s.jsx(I,{variant:"ghost",size:"sm",onClick:r,title:"Bearbeiten",children:s.jsx(at,{className:"w-4 h-4"})}),i("providers:delete")&&s.jsx(I,{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(I,{size:"sm",onClick:()=>c(!0),children:[s.jsx(Ue,{className:"w-4 h-4 mr-1"}),"Tarif hinzufügen"]})]}),m.length>0?s.jsx("div",{className:"space-y-2",children:m.map(j=>{var y;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:j.name}),s.jsx(ye,{variant:j.isActive?"success":"danger",className:"text-xs",children:j.isActive?"Aktiv":"Inaktiv"}),((y=j._count)==null?void 0:y.contracts)!==void 0&&s.jsxs("span",{className:"text-xs text-gray-500",children:["(",j._count.contracts," Verträge)"]})]}),s.jsxs("div",{className:"flex gap-1",children:[i("providers:update")&&s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{u(j),c(!0)},title:"Bearbeiten",children:s.jsx(at,{className:"w-3 h-3"})}),i("providers:delete")&&s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Tarif wirklich löschen?")&&p.mutate(j.id)},title:"Löschen",children:s.jsx(Ne,{className:"w-3 h-3 text-red-500"})})]})]},j.id)})}):s.jsx("p",{className:"text-sm text-gray-500",children:"Keine Tarife vorhanden."})]}),s.jsx(CC,{isOpen:o,onClose:()=>{c(!1),u(null)},providerId:e.id,tariff:d})]})}function kC({isOpen:e,onClose:t,provider:n}){const r=xe(),[a,i]=b.useState({name:"",portalUrl:"",usernameFieldName:"",passwordFieldName:"",isActive:!0});b.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:Wa.create,onSuccess:()=>{r.invalidateQueries({queryKey:["providers"]}),t()},onError:u=>{alert(u.message)}}),o=G({mutationFn:u=>Wa.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(Ge,{isOpen:e,onClose:t,title:n?"Anbieter bearbeiten":"Neuer Anbieter",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(V,{label:"Anbietername *",value:a.name,onChange:u=>i({...a,name:u.target.value}),required:!0,placeholder:"z.B. Vodafone, E.ON, Allianz"}),s.jsx(V,{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(V,{label:"Benutzername-Feldname",value:a.usernameFieldName,onChange:u=>i({...a,usernameFieldName:u.target.value}),placeholder:"z.B. username, email, login"}),s.jsx(V,{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(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}function CC({isOpen:e,onClose:t,providerId:n,tariff:r}){const a=xe(),[i,l]=b.useState({name:"",isActive:!0});b.useEffect(()=>{e&&l(r?{name:r.name,isActive:r.isActive}:{name:"",isActive:!0})},[e,r]);const o=G({mutationFn:h=>Wa.createTariff(n,h),onSuccess:()=>{a.invalidateQueries({queryKey:["providers"]}),t()},onError:h=>{alert(h.message)}}),c=G({mutationFn:h=>cv.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(Ge,{isOpen:e,onClose:t,title:r?"Tarif bearbeiten":"Neuer Tarif",children:s.jsxs("form",{onSubmit:d,className:"space-y-4",children:[s.jsx(V,{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(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}const Hu={Zap:s.jsx(dh,{className:"w-5 h-5"}),Flame:s.jsx(yv,{className:"w-5 h-5"}),Wifi:s.jsx(wa,{className:"w-5 h-5"}),Cable:s.jsx(j2,{className:"w-5 h-5"}),Network:s.jsx(I2,{className:"w-5 h-5"}),Smartphone:s.jsx(oh,{className:"w-5 h-5"}),Tv:s.jsx(Sv,{className:"w-5 h-5"}),Car:s.jsx(xv,{className:"w-5 h-5"}),FileText:s.jsx(He,{className:"w-5 h-5"})},EC=[{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)"}],DC=[{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 PC(){const[e,t]=b.useState(!1),[n,r]=b.useState(null),[a,i]=b.useState(!1),{hasPermission:l}=qe(),o=xe(),{data:c,isLoading:d}=me({queryKey:["contract-categories",a],queryFn:()=>rl.getAll(a)}),u=G({mutationFn:rl.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["contract-categories"]})},onError:m=>{alert(m.message)}}),h=m=>{r(m),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(Se,{to:"/settings",children:s.jsx(I,{variant:"ghost",size:"sm",children:s.jsx(Us,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Vertragstypen"}),l("developer:access")&&s.jsxs(I,{onClick:()=>t(!0),children:[s.jsx(Ue,{className:"w-4 h-4 mr-2"}),"Neuer Vertragstyp"]})]}),s.jsxs(Y,{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(C2,{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&&Hu[m.icon]?Hu[m.icon]:s.jsx(He,{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(ye,{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(I,{variant:"ghost",size:"sm",onClick:()=>h(m),title:"Bearbeiten",children:s.jsx(at,{className:"w-4 h-4"})}),l("developer:access")&&s.jsx(I,{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(AC,{isOpen:e,onClose:p,category:n})]})}function AC({isOpen:e,onClose:t,category:n}){const r=xe(),[a,i]=b.useState({code:"",name:"",icon:"FileText",color:"#607D8B",sortOrder:0,isActive:!0});b.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:rl.create,onSuccess:()=>{r.invalidateQueries({queryKey:["contract-categories"]}),t()},onError:u=>{alert(u.message)}}),o=G({mutationFn:u=>rl.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(Ge,{isOpen:e,onClose:t,title:n?"Vertragstyp bearbeiten":"Neuer Vertragstyp",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(V,{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(V,{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:EC.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:[Hu[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:DC.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(V,{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(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}const MC=[{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 FC(){const{settings:e,updateSettings:t}=mv();return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(Se,{to:"/settings",className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:s.jsx(Us,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(De,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Ansicht"})]})]}),s.jsx(Y,{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(_e,{options:MC,value:e.scrollToTopThreshold.toString(),onChange:n=>t({scrollToTopThreshold:parseFloat(n.target.value)})})})]})})})]})}function TC(){const e=xe(),{data:t,isLoading:n}=me({queryKey:["app-settings"],queryFn:()=>Wr.getAll()}),[r,a]=b.useState(!1);b.useEffect(()=>{t!=null&&t.data&&a(t.data.customerSupportTicketsEnabled==="true")},[t]);const i=G({mutationFn:o=>Wr.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(Se,{to:"/settings",className:"text-gray-500 hover:text-gray-700",children:s.jsx(Us,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(lh,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Kundenportal"})]})]}),s.jsxs(Y,{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(il,{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 IC(){const e=xe(),{data:t,isLoading:n}=me({queryKey:["app-settings"],queryFn:()=>Wr.getAll()}),[r,a]=b.useState("14"),[i,l]=b.useState("42"),[o,c]=b.useState("90"),[d,u]=b.useState(!1);b.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=>Wr.update(f),onSuccess:()=>{e.invalidateQueries({queryKey:["app-settings"]}),e.invalidateQueries({queryKey:["contract-cockpit"]}),u(!1)}}),p=()=>{const f=parseInt(r),x=parseInt(i),j=parseInt(o);if(isNaN(f)||isNaN(x)||isNaN(j)){alert("Bitte gültige Zahlen eingeben");return}if(f>=x||x>=j){alert("Die Werte müssen aufsteigend sein: Kritisch < Warnung < OK");return}h.mutate({deadlineCriticalDays:r,deadlineWarningDays:i,deadlineOkDays:o})},m=(f,x)=>{f(x),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(Se,{to:"/settings",className:"text-gray-500 hover:text-gray-700",children:s.jsx(Us,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Pn,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Fristenschwellen"})]})]}),s.jsxs(Y,{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(bn,{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(V,{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(Es,{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(V,{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(ws,{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(V,{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(I,{onClick:p,disabled:!d||h.isPending,children:h.isPending?"Speichere...":"Speichern"})]})]})]})}const RC=[{value:"PLESK",label:"Plesk"},{value:"CPANEL",label:"cPanel"},{value:"DIRECTADMIN",label:"DirectAdmin"}],Ix=[{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"}],gd={name:"",type:"PLESK",apiUrl:"",apiKey:"",username:"",password:"",domain:"stressfrei-wechseln.de",defaultForwardEmail:"",imapEncryption:"SSL",smtpEncryption:"SSL",allowSelfSignedCerts:!1,isActive:!0,isDefault:!1};function LC(){const e=Gt(),t=xe(),[n,r]=b.useState(!1),[a,i]=b.useState(null),[l,o]=b.useState(gd),[c,d]=b.useState(!1),[u,h]=b.useState(null),[p,m]=b.useState(!1),[f,x]=b.useState({}),[j,y]=b.useState(null),{data:v,isLoading:g}=me({queryKey:["email-provider-configs"],queryFn:()=>fn.getConfigs()}),w=G({mutationFn:A=>fn.createConfig(A),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]}),P()}}),C=G({mutationFn:({id:A,data:K})=>fn.updateConfig(A,K),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]}),P()}}),k=G({mutationFn:A=>fn.deleteConfig(A),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]})}}),F=(v==null?void 0:v.data)||[],N=()=>{o(gd),i(null),d(!1),h(null),r(!0)},E=A=>{o({name:A.name,type:A.type,apiUrl:A.apiUrl,apiKey:A.apiKey||"",username:A.username||"",password:"",domain:A.domain,defaultForwardEmail:A.defaultForwardEmail||"",imapEncryption:A.imapEncryption??"SSL",smtpEncryption:A.smtpEncryption??"SSL",allowSelfSignedCerts:A.allowSelfSignedCerts??!1,isActive:A.isActive,isDefault:A.isDefault}),i(A.id),d(!1),h(null),r(!0)},P=()=>{r(!1),i(null),o(gd),d(!1),h(null)},z=async A=>{var K,B,J;y(A.id),x(H=>({...H,[A.id]:null}));try{const H=await fn.testConnection({id:A.id}),S={success:((K=H.data)==null?void 0:K.success)||!1,message:(B=H.data)==null?void 0:B.message,error:(J=H.data)==null?void 0:J.error};x(oe=>({...oe,[A.id]:S}))}catch(H){x(S=>({...S,[A.id]:{success:!1,error:H instanceof Error?H.message:"Unbekannter Fehler beim Testen"}}))}finally{y(null)}},D=async()=>{var A,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 J=await fn.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:((A=J.data)==null?void 0:A.success)||!1,message:(K=J.data)==null?void 0:K.message,error:(B=J.data)==null?void 0:B.error})}catch(J){h({success:!1,error:J instanceof Error?J.message:"Unbekannter Fehler beim Verbindungstest"})}finally{m(!1)}},_=A=>{A.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?C.mutate({id:a,data:K}):w.mutate(K)},$=(A,K)=>{confirm(`Möchten Sie den Provider "${K}" wirklich löschen?`)&&k.mutate(A)},L=A=>A.error?A.error:A.message?A.message:"Verbindung fehlgeschlagen";return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsxs(I,{variant:"ghost",onClick:()=>e("/settings"),children:[s.jsx(Us,{className:"w-4 h-4 mr-2"}),"Zurück"]}),s.jsx("h1",{className:"text-2xl font-bold",children:"Email-Provisionierung"})]}),s.jsxs(Y,{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(I,{onClick:N,children:[s.jsx(Ue,{className:"w-4 h-4 mr-2"}),"Provider hinzufügen"]})]}),g?s.jsx("div",{className:"text-center py-8",children:"Laden..."}):F.length===0?s.jsx(Y,{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:F.map(A=>{const K=f[A.id],B=j===A.id;return s.jsx(Y,{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:A.name}),s.jsx("span",{className:"px-2 py-1 text-xs rounded bg-blue-100 text-blue-800",children:A.type}),A.isDefault&&s.jsx("span",{className:"px-2 py-1 text-xs rounded bg-green-100 text-green-800",children:"Standard"}),!A.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:A.apiUrl})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Domain"}),s.jsx("dd",{children:A.domain})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Benutzer"}),s.jsx("dd",{children:A.username||"-"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Standard-Weiterleitung"}),s.jsx("dd",{className:"truncate",children:A.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(Ga,{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(ox,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),s.jsx("span",{children:L(K)})]})})]}),s.jsxs("div",{className:"flex gap-2 ml-4",children:[s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>z(A),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(wa,{className:"w-4 h-4 text-blue-500"})}),s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>E(A),children:s.jsx(at,{className:"w-4 h-4"})}),s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>$(A.id,A.name),children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})]})},A.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:P,className:"text-gray-400 hover:text-gray-600",children:s.jsx(Bs,{className:"w-5 h-5"})})]}),(w.error||C.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(Bs,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),s.jsx("span",{children:w.error instanceof Error?w.error.message:C.error instanceof Error?C.error.message:"Fehler beim Speichern"})]})}),s.jsxs("form",{onSubmit:_,className:"space-y-4",children:[s.jsx(V,{label:"Name *",value:l.name,onChange:A=>o({...l,name:A.target.value}),placeholder:"z.B. Plesk Hauptserver",required:!0}),s.jsx(_e,{label:"Provider-Typ *",value:l.type,onChange:A=>o({...l,type:A.target.value}),options:RC}),s.jsx(V,{label:"API-URL *",value:l.apiUrl,onChange:A=>o({...l,apiUrl:A.target.value}),placeholder:"https://server.de:8443",required:!0}),s.jsx(V,{label:"API-Key",value:l.apiKey,onChange:A=>o({...l,apiKey:A.target.value}),placeholder:"Optional - alternativ zu Benutzername/Passwort"}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(V,{label:"Benutzername",value:l.username,onChange:A=>o({...l,username:A.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:A=>o({...l,password:A.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(Ft,{className:"w-4 h-4"}):s.jsx(De,{className:"w-4 h-4"})})]})]})]}),s.jsx(V,{label:"Domain *",value:l.domain,onChange:A=>o({...l,domain:A.target.value}),placeholder:"stressfrei-wechseln.de",required:!0}),s.jsx(V,{label:"Standard-Weiterleitungsadresse",value:l.defaultForwardEmail,onChange:A=>o({...l,defaultForwardEmail:A.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:A=>o({...l,imapEncryption:A.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:Ix.map(A=>s.jsxs("option",{value:A.value,children:[A.label," - ",A.description]},A.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:A=>o({...l,smtpEncryption:A.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:Ix.map(A=>s.jsxs("option",{value:A.value,children:[A.label," - ",A.description]},A.value))})]})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:l.allowSelfSignedCerts,onChange:A=>o({...l,allowSelfSignedCerts:A.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:A=>o({...l,isActive:A.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:A=>o({...l,isDefault:A.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(I,{type:"button",variant:"secondary",onClick:D,disabled:p,className:"w-full",children:p?"Teste Verbindung...":s.jsxs(s.Fragment,{children:[s.jsx(wa,{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(Ga,{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(ox,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),s.jsx("span",{children:L(u)})]})})]}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[s.jsx(I,{type:"button",variant:"secondary",onClick:P,children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:w.isPending||C.isPending,children:w.isPending||C.isPending?"Speichern...":"Speichern"})]})]})]})})})]})}function OC(){const[e,t]=b.useState(null),[n,r]=b.useState(null),[a,i]=b.useState(!1),[l,o]=b.useState(""),[c,d]=b.useState(null),u=b.useRef(null),h=xe(),{logout:p}=qe(),{data:m,isLoading:f}=me({queryKey:["backups"],queryFn:()=>gr.list()}),x=(m==null?void 0:m.data)||[],j=G({mutationFn:()=>gr.create(),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]})}}),y=G({mutationFn:E=>gr.restore(E),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),t(null)}}),v=G({mutationFn:E=>gr.delete(E),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),r(null)}}),g=G({mutationFn:E=>gr.upload(E),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),d(null),u.current&&(u.current.value="")},onError:E=>{d(E.message||"Upload fehlgeschlagen")}}),w=G({mutationFn:()=>gr.factoryReset(),onSuccess:()=>{i(!1),o(""),p()}}),C=E=>{var z;const P=(z=E.target.files)==null?void 0:z[0];if(P){if(!P.name.endsWith(".zip")){d("Nur ZIP-Dateien sind erlaubt");return}d(null),g.mutate(P)}},k=async E=>{const P=localStorage.getItem("token"),z=gr.getDownloadUrl(E);try{const D=await fetch(z,{headers:{Authorization:`Bearer ${P}`}});if(!D.ok)throw new Error("Download fehlgeschlagen");const _=await D.blob(),$=window.URL.createObjectURL(_),L=document.createElement("a");L.href=$,L.download=`opencrm-backup-${E}.zip`,document.body.appendChild(L),L.click(),document.body.removeChild(L),window.URL.revokeObjectURL($)}catch(D){console.error("Download error:",D)}},F=E=>new Date(E).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}),N=E=>E<1024?`${E} B`:E<1024*1024?`${(E/1024).toFixed(1)} KB`:`${(E/(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(Pc,{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:C,className:"hidden"}),s.jsx(I,{variant:"secondary",onClick:()=>{var E;return(E=u.current)==null?void 0:E.click()},disabled:g.isPending,children:g.isPending?s.jsxs(s.Fragment,{children:[s.jsx(jr,{className:"w-4 h-4 mr-2 animate-spin"}),"Hochladen..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Bu,{className:"w-4 h-4 mr-2"}),"Backup hochladen"]})}),s.jsx(I,{onClick:()=>j.mutate(),disabled:j.isPending,children:j.isPending?s.jsxs(s.Fragment,{children:[s.jsx(jr,{className:"w-4 h-4 mr-2 animate-spin"}),"Wird erstellt..."]}):s.jsxs(s.Fragment,{children:[s.jsx(zs,{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(jr,{className:"w-6 h-6 animate-spin text-gray-400"})}):x.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(ix,{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:x.map(E=>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:E.name}),s.jsxs("span",{className:"text-sm text-gray-500 flex items-center gap-1",children:[s.jsx(Pn,{className:"w-4 h-4"}),F(E.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(He,{className:"w-4 h-4"}),E.totalRecords.toLocaleString("de-DE")," Datensätze"]}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(ix,{className:"w-4 h-4"}),N(E.sizeBytes)]}),E.hasUploads&&s.jsxs("span",{className:"flex items-center gap-1 text-green-600",children:[s.jsx(k2,{className:"w-4 h-4"}),"Dokumente (",N(E.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 (",E.tables.filter(P=>P.count>0).length," mit Daten)"]}),s.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:E.tables.filter(P=>P.count>0).map(P=>s.jsxs("span",{className:"text-xs bg-gray-100 px-2 py-0.5 rounded",children:[P.table,": ",P.count]},P.table))})]})]}),s.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[s.jsx(I,{variant:"secondary",size:"sm",onClick:()=>k(E.name),title:"Als ZIP herunterladen",children:s.jsx(y2,{className:"w-4 h-4"})}),s.jsxs(I,{variant:"secondary",size:"sm",onClick:()=>t(E.name),disabled:y.isPending,children:[s.jsx(Bu,{className:"w-4 h-4 mr-1"}),"Wiederherstellen"]}),s.jsx(I,{variant:"danger",size:"sm",onClick:()=>r(E.name),disabled:v.isPending,children:s.jsx(Ne,{className:"w-4 h-4"})})]})]})},E.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(I,{variant:"secondary",onClick:()=>t(null),disabled:y.isPending,children:"Abbrechen"}),s.jsx(I,{variant:"primary",onClick:()=>y.mutate(e),disabled:y.isPending,children:y.isPending?s.jsxs(s.Fragment,{children:[s.jsx(jr,{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(I,{variant:"secondary",onClick:()=>r(null),disabled:v.isPending,children:"Abbrechen"}),s.jsx(I,{variant:"danger",onClick:()=>v.mutate(n),disabled:v.isPending,children:v.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(Es,{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(I,{variant:"danger",onClick:()=>i(!0),children:[s.jsx(L2,{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(Es,{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:E=>o(E.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(I,{variant:"secondary",onClick:()=>{i(!1),o("")},disabled:w.isPending,children:"Abbrechen"}),s.jsx(I,{variant:"danger",onClick:()=>w.mutate(),disabled:l!=="LÖSCHEN"||w.isPending,children:w.isPending?s.jsxs(s.Fragment,{children:[s.jsx(jr,{className:"w-4 h-4 mr-2 animate-spin"}),"Wird zurückgesetzt..."]}):"Ja, alles löschen"})]})]})})]})}function zC(){var v;const[e,t]=b.useState(""),[n,r]=b.useState(1),[a,i]=b.useState(!1),[l,o]=b.useState(null),c=xe(),{refreshUser:d}=qe(),{data:u,isLoading:h}=me({queryKey:["users",e,n],queryFn:()=>Mi.getAll({search:e||void 0,page:n,limit:20})}),{data:p}=me({queryKey:["roles"],queryFn:()=>Mi.getRoles()}),m=G({mutationFn:Mi.delete,onSuccess:()=>{c.invalidateQueries({queryKey:["users"]})},onError:g=>{alert((g==null?void 0:g.message)||"Fehler beim Löschen des Benutzers")}}),f=g=>{var w;return(w=g.roles)==null?void 0:w.some(C=>C.name==="Admin")},x=((v=u==null?void 0:u.data)==null?void 0:v.filter(g=>g.isActive&&f(g)).length)||0,j=g=>{o(g),i(!0)},y=()=>{i(!1),o(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(Se,{to:"/settings",children:s.jsx(I,{variant:"ghost",size:"sm",children:s.jsx(Us,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Benutzer"}),s.jsxs(I,{onClick:()=>i(!0),children:[s.jsx(Ue,{className:"w-4 h-4 mr-2"}),"Neuer Benutzer"]})]}),s.jsx(Y,{className:"mb-6",children:s.jsxs("div",{className:"flex gap-4",children:[s.jsx("div",{className:"flex-1",children:s.jsx(V,{placeholder:"Suchen...",value:e,onChange:g=>t(g.target.value)})}),s.jsx(I,{variant:"secondary",children:s.jsx(Cl,{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(E2,{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(Y,{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(g=>{var w;return s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsxs("td",{className:"py-3 px-4",children:[g.firstName," ",g.lastName]}),s.jsx("td",{className:"py-3 px-4",children:g.email}),s.jsx("td",{className:"py-3 px-4",children:s.jsx("div",{className:"flex gap-1 flex-wrap",children:(w=g.roles)==null?void 0:w.filter(C=>C.name!=="Developer").map(C=>s.jsx(ye,{variant:"info",children:C.name},C.id||C.name))})}),s.jsx("td",{className:"py-3 px-4",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ye,{variant:g.isActive?"success":"danger",children:g.isActive?"Aktiv":"Inaktiv"}),g.hasDeveloperAccess&&s.jsxs(ye,{variant:"warning",className:"flex items-center gap-1",children:[s.jsx(Dc,{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(I,{variant:"ghost",size:"sm",onClick:()=>j(g),children:s.jsx(at,{className:"w-4 h-4"})}),(()=>{const C=f(g)&&g.isActive&&x<=1;return s.jsx(I,{variant:"ghost",size:"sm",disabled:C,title:C?"Letzter Administrator kann nicht gelöscht werden":void 0,onClick:()=>{confirm("Benutzer wirklich löschen?")&&m.mutate(g.id)},children:s.jsx(Ne,{className:`w-4 h-4 ${C?"text-gray-300":"text-red-500"}`})})})()]})})]},g.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(I,{variant:"secondary",size:"sm",onClick:()=>r(g=>Math.max(1,g-1)),disabled:n===1,children:"Zurück"}),s.jsx(I,{variant:"secondary",size:"sm",onClick:()=>r(g=>g+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($C,{isOpen:a,onClose:y,user:l,roles:(p==null?void 0:p.data)||[],onUserUpdated:d})]})}function $C({isOpen:e,onClose:t,user:n,roles:r,onUserUpdated:a}){const i=xe(),[l,o]=b.useState(null),[c,d]=b.useState({email:"",password:"",firstName:"",lastName:"",roleIds:[],isActive:!0,hasDeveloperAccess:!1});b.useEffect(()=>{var x;e&&(o(null),d(n?{email:n.email,password:"",firstName:n.firstName,lastName:n.lastName,roleIds:((x=n.roles)==null?void 0:x.filter(j=>j.name!=="Developer").map(j=>j.id))||[],isActive:n.isActive??!0,hasDeveloperAccess:n.hasDeveloperAccess??!1}:{email:"",password:"",firstName:"",lastName:"",roleIds:[],isActive:!0,hasDeveloperAccess:!1}))},[e,n]);const u=G({mutationFn:Mi.create,onSuccess:()=>{i.invalidateQueries({queryKey:["users"]}),t()},onError:x=>{o((x==null?void 0:x.message)||"Fehler beim Erstellen des Benutzers")}}),h=G({mutationFn:x=>Mi.update(n.id,x),onSuccess:async()=>{i.invalidateQueries({queryKey:["users"]}),await a(),t()},onError:x=>{o((x==null?void 0:x.message)||"Fehler beim Aktualisieren des Benutzers")}}),p=x=>{if(x.preventDefault(),n){const j={email:c.email,firstName:c.firstName,lastName:c.lastName,roleIds:c.roleIds,isActive:c.isActive,hasDeveloperAccess:c.hasDeveloperAccess};c.password&&(j.password=c.password),h.mutate(j)}else u.mutate({email:c.email,password:c.password,firstName:c.firstName,lastName:c.lastName,roleIds:c.roleIds,hasDeveloperAccess:c.hasDeveloperAccess})},m=x=>{d(j=>({...j,roleIds:j.roleIds.includes(x)?j.roleIds.filter(y=>y!==x):[...j.roleIds,x]}))},f=u.isPending||h.isPending;return s.jsx(Ge,{isOpen:e,onClose:t,title:n?"Benutzer bearbeiten":"Neuer Benutzer",children:s.jsxs("form",{onSubmit:p,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(Es,{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(V,{label:"Vorname *",value:c.firstName,onChange:x=>d({...c,firstName:x.target.value}),required:!0}),s.jsx(V,{label:"Nachname *",value:c.lastName,onChange:x=>d({...c,lastName:x.target.value}),required:!0})]}),s.jsx(V,{label:"E-Mail *",type:"email",value:c.email,onChange:x=>d({...c,email:x.target.value}),required:!0}),s.jsx(V,{label:n?"Neues Passwort (leer = unverändert)":"Passwort *",type:"password",value:c.password,onChange:x=>d({...c,password:x.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(x=>x.name!=="Developer").map(x=>s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:c.roleIds.includes(x.id),onChange:()=>m(x.id),className:"rounded"}),s.jsx("span",{children:x.name}),x.description&&s.jsxs("span",{className:"text-sm text-gray-500",children:["(",x.description,")"]})]},x.id)),s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:c.hasDeveloperAccess,onChange:x=>d({...c,hasDeveloperAccess:x.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(Dc,{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(Es,{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:x=>d({...c,isActive:x.target.checked}),className:"rounded"}),"Aktiv"]})}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(I,{type:"submit",disabled:f,children:f?"Speichern...":"Speichern"})]})]})})}function _C(){const{hasPermission:e,developerMode:t,setDeveloperMode:n}=qe(),r=[{to:"/settings/users",icon:$2,title:"Benutzer",description:"Verwalten Sie Benutzerkonten, Rollen und Berechtigungen.",show:e("users:read")},{to:"/settings/platforms",icon:O2,title:"Vertriebsplattformen",description:"Verwalten Sie die Plattformen, über die Verträge abgeschlossen werden.",show:e("platforms:read")},{to:"/settings/cancellation-periods",icon:Pn,title:"Kündigungsfristen",description:"Konfigurieren Sie die verfügbaren Kündigungsfristen für Verträge.",show:e("platforms:read")},{to:"/settings/contract-durations",icon:pv,title:"Vertragslaufzeiten",description:"Konfigurieren Sie die verfügbaren Laufzeiten für Verträge.",show:e("platforms:read")},{to:"/settings/providers",icon:v2,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:S2,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(wv,{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(Se,{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(Mt,{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(Se,{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(lh,{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(Mt,{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(Se,{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(Pn,{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(Mt,{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(Se,{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(tn,{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(Mt,{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(Se,{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(Pc,{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(Mt,{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(Se,{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(De,{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(Mt,{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(Y,{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(Dc,{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(Y,{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 KC({onSelectTable:e}){const t=b.useRef(null),[n,r]=b.useState(1),[a,i]=b.useState({x:0,y:0}),[l,o]=b.useState(!1),[c,d]=b.useState({x:0,y:0}),[u,h]=b.useState({}),[p,m]=b.useState(null),{data:f,isLoading:x}=me({queryKey:["developer-schema"],queryFn:bi.getSchema}),j=(f==null?void 0:f.data)||[];b.useEffect(()=>{if(j.length>0&&Object.keys(u).length===0){const N=Math.ceil(Math.sqrt(j.length)),E={x:280,y:200},P={};j.forEach((z,D)=>{const _=D%N,$=Math.floor(D/N);P[z.name]={x:50+_*E.x,y:50+$*E.y}}),h(P)}},[j,u]);const y=b.useCallback(N=>{(N.target===N.currentTarget||N.target.tagName==="svg")&&(o(!0),d({x:N.clientX-a.x,y:N.clientY-a.y}))},[a]),v=b.useCallback(N=>{var E;if(l&&!p)i({x:N.clientX-c.x,y:N.clientY-c.y});else if(p){const P=(E=t.current)==null?void 0:E.getBoundingClientRect();P&&h(z=>({...z,[p]:{x:(N.clientX-P.left-a.x)/n-100,y:(N.clientY-P.top-a.y)/n-20}}))}},[l,p,c,a,n]),g=b.useCallback(()=>{o(!1),m(null)},[]),w=N=>{r(E=>Math.min(2,Math.max(.3,E+N)))},C=()=>{r(1),i({x:0,y:0})},k=b.useCallback(()=>{const N=[];return j.forEach(E=>{const P=u[E.name];P&&E.foreignKeys.forEach(z=>{const D=u[z.targetTable];if(!D)return;const _=j.find(L=>L.name===z.targetTable),$=_==null?void 0:_.relations.find(L=>L.targetTable===E.name);N.push({from:{table:E.name,x:P.x+100,y:P.y+60},to:{table:z.targetTable,x:D.x+100,y:D.y+60},type:($==null?void 0:$.type)||"one",label:z.field})})}),N},[j,u]);if(x)return s.jsx("div",{className:"flex items-center justify-center h-full",children:"Laden..."});const F=k();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(I,{variant:"ghost",size:"sm",onClick:()=>w(.1),title:"Vergrößern",children:s.jsx(K2,{className:"w-4 h-4"})}),s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>w(-.1),title:"Verkleinern",children:s.jsx(U2,{className:"w-4 h-4"})}),s.jsx(I,{variant:"ghost",size:"sm",onClick:C,title:"Zurücksetzen",children:s.jsx(F2,{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(T2,{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:y,onMouseMove:v,onMouseUp:g,onMouseLeave:g,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"})})]}),F.map((N,E)=>{const P=N.to.x-N.from.x,z=N.to.y-N.from.y,D=N.from.x+P/2,_=N.from.y+z/2,$=N.from.x+P*.25,L=N.from.y,A=N.from.x+P*.75,K=N.to.y;return s.jsxs("g",{children:[s.jsx("path",{d:`M ${N.from.x} ${N.from.y} C ${$} ${L}, ${A} ${K}, ${N.to.x} ${N.to.y}`,fill:"none",stroke:"#9ca3af",strokeWidth:"2",markerEnd:"url(#arrowhead)"}),s.jsx("text",{x:D,y:_-8,fontSize:"10",fill:"#6b7280",textAnchor:"middle",className:"select-none",children:N.type==="many"?"1:n":"1:1"})]},E)}),j.map(N=>{const E=u[N.name];if(!E)return null;const P=200,z=32,D=20,_=[...new Set([N.primaryKey,...N.foreignKeys.map(L=>L.field)])],$=z+Math.min(_.length,5)*D+8;return s.jsxs("g",{transform:`translate(${E.x}, ${E.y})`,style:{cursor:"move"},onMouseDown:L=>{L.stopPropagation(),m(N.name)},children:[s.jsx("rect",{x:"3",y:"3",width:P,height:$,rx:"6",fill:"rgba(0,0,0,0.1)"}),s.jsx("rect",{x:"0",y:"0",width:P,height:$,rx:"6",fill:"white",stroke:"#e5e7eb",strokeWidth:"1"}),s.jsx("rect",{x:"0",y:"0",width:P,height:z,rx:"6",fill:"#3b82f6",className:"cursor-pointer",onClick:()=>e==null?void 0:e(N.name)}),s.jsx("rect",{x:"0",y:z-6,width:P,height:"6",fill:"#3b82f6"}),s.jsx("text",{x:P/2,y:"21",fontSize:"13",fontWeight:"bold",fill:"white",textAnchor:"middle",className:"select-none pointer-events-none",children:N.name}),_.slice(0,5).map((L,A)=>{const K=L===N.primaryKey||N.primaryKey.includes(L),B=N.foreignKeys.some(J=>J.field===L);return s.jsx("g",{transform:`translate(8, ${z+4+A*D})`,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&&"🔗 ",L]})},L)}),_.length>5&&s.jsxs("text",{x:P/2,y:$-4,fontSize:"10",fill:"#9ca3af",textAnchor:"middle",className:"select-none",children:["+",_.length-5," mehr..."]})]},N.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 UC(){var F;const[e,t]=b.useState(null),[n,r]=b.useState(1),[a,i]=b.useState(null),[l,o]=b.useState(!1),c=xe(),{data:d,isLoading:u,error:h}=me({queryKey:["developer-schema"],queryFn:bi.getSchema});console.log("Schema data:",d),console.log("Schema error:",h);const{data:p,isLoading:m}=me({queryKey:["developer-table",e,n],queryFn:()=>bi.getTableData(e,n),enabled:!!e}),f=G({mutationFn:({tableName:N,id:E,data:P})=>bi.updateRow(N,E,P),onSuccess:()=>{c.invalidateQueries({queryKey:["developer-table",e]}),i(null)},onError:N=>{var E,P;alert(((P=(E=N.response)==null?void 0:E.data)==null?void 0:P.error)||"Fehler beim Speichern")}}),x=G({mutationFn:({tableName:N,id:E})=>bi.deleteRow(N,E),onSuccess:()=>{c.invalidateQueries({queryKey:["developer-table",e]})},onError:N=>{var E,P;alert(((P=(E=N.response)==null?void 0:E.data)==null?void 0:P.error)||"Fehler beim Löschen")}}),j=(d==null?void 0:d.data)||[],y=j.find(N=>N.name===e),v=(N,E)=>E.primaryKey.includes(",")?E.primaryKey.split(",").map(P=>N[P]).join("-"):String(N[E.primaryKey]),g=N=>N==null?"-":typeof N=="boolean"?N?"Ja":"Nein":typeof N=="object"?N instanceof Date||typeof N=="string"&&N.match(/^\d{4}-\d{2}-\d{2}/)?new Date(N).toLocaleString("de-DE"):JSON.stringify(N):String(N),w=()=>{!a||!e||f.mutate({tableName:e,id:a.id,data:a.data})},C=N=>{e&&confirm("Datensatz wirklich löschen?")&&x.mutate({tableName:e,id:N})};if(u)return s.jsx("div",{className:"text-center py-8",children:"Laden..."});const k=N=>{t(N),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(Pc,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Datenbankstruktur"})]}),s.jsxs(I,{onClick:()=>o(!0),children:[s.jsx(ax,{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(Y,{title:"Tabellen",className:"lg:col-span-1",children:s.jsx("div",{className:"space-y-1 max-h-[600px] overflow-y-auto",children:j.map(N=>s.jsxs("button",{onClick:()=>{t(N.name),r(1)},className:`w-full text-left px-3 py-2 rounded-lg flex items-center gap-2 transition-colors ${e===N.name?"bg-blue-100 text-blue-700":"hover:bg-gray-100"}`,children:[s.jsx(z2,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm font-mono",children:N.name})]},N.name))})}),s.jsx("div",{className:"lg:col-span-3 space-y-6",children:e&&y?s.jsxs(s.Fragment,{children:[s.jsxs(Y,{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)"}),y.foreignKeys.length>0?s.jsx("div",{className:"space-y-1",children:y.foreignKeys.map(N=>s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"font-mono text-gray-600",children:N.field}),s.jsx(fv,{className:"w-4 h-4 text-gray-400"}),s.jsx(ye,{variant:"info",className:"cursor-pointer",onClick:()=>{t(N.targetTable),r(1)},children:N.targetTable})]},N.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)"}),y.relations.length>0?s.jsx("div",{className:"space-y-1",children:y.relations.map(N=>s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"font-mono text-gray-600",children:N.field}),s.jsx(ye,{variant:N.type==="many"?"warning":"default",children:N.type==="many"?"1:n":"1:1"}),s.jsx(ye,{variant:"info",className:"cursor-pointer",onClick:()=>{t(N.targetTable),r(1)},children:N.targetTable})]},N.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:y.primaryKey})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"Readonly:"})," ",s.jsx("span",{className:"font-mono text-red-600",children:y.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:y.requiredFields.join(", ")||"-"})]})]})})]}),s.jsx(Y,{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:[(p==null?void 0:p.data)&&p.data.length>0&&Object.keys(p.data[0]).map(N=>s.jsxs("th",{className:"text-left py-2 px-3 font-medium text-gray-600 whitespace-nowrap",children:[N,y.readonlyFields.includes(N)&&s.jsx("span",{className:"ml-1 text-red-400 text-xs",children:"*"}),y.requiredFields.includes(N)&&s.jsx("span",{className:"ml-1 text-green-400 text-xs",children:"!"})]},N)),s.jsx("th",{className:"text-right py-2 px-3 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsxs("tbody",{children:[(F=p==null?void 0:p.data)==null?void 0:F.map(N=>{const E=v(N,y);return s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[Object.entries(N).map(([P,z])=>s.jsx("td",{className:"py-2 px-3 font-mono text-xs max-w-[200px] truncate",children:g(z)},P)),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(I,{variant:"ghost",size:"sm",onClick:()=>i({id:E,data:{...N}}),children:s.jsx(at,{className:"w-4 h-4"})}),s.jsx(I,{variant:"ghost",size:"sm",onClick:()=>C(E),children:s.jsx(Ne,{className:"w-4 h-4 text-red-500"})})]})})]},E)}),(!(p!=null&&p.data)||p.data.length===0)&&s.jsx("tr",{children:s.jsx("td",{colSpan:100,className:"py-4 text-center text-gray-500",children:"Keine Daten vorhanden"})})]})]})}),(p==null?void 0:p.pagination)&&p.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 ",p.pagination.page," von ",p.pagination.totalPages," (",p.pagination.total," Einträge)"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(I,{variant:"secondary",size:"sm",onClick:()=>r(N=>Math.max(1,N-1)),disabled:n===1,children:s.jsx(N2,{className:"w-4 h-4"})}),s.jsx(I,{variant:"secondary",size:"sm",onClick:()=>r(N=>N+1),disabled:n>=p.pagination.totalPages,children:s.jsx(Mt,{className:"w-4 h-4"})})]})]})]})})]}):s.jsx(Y,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Wähle eine Tabelle aus der Liste aus"})})})]}),s.jsx(Ge,{isOpen:!!a,onClose:()=>i(null),title:`${e} bearbeiten`,children:a&&y&&s.jsxs("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto",children:[Object.entries(a.data).map(([N,E])=>{const P=y.readonlyFields.includes(N),z=y.requiredFields.includes(N);return s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[N,P&&s.jsx("span",{className:"ml-1 text-red-400",children:"(readonly)"}),z&&s.jsx("span",{className:"ml-1 text-green-600",children:"*"})]}),P?s.jsx("div",{className:"px-3 py-2 bg-gray-100 rounded-lg font-mono text-sm",children:g(E)}):typeof E=="boolean"?s.jsxs("select",{value:String(a.data[N]),onChange:D=>i({...a,data:{...a.data,[N]:D.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 E=="number"?"number":"text",value:a.data[N]??"",onChange:D=>i({...a,data:{...a.data,[N]:typeof E=="number"?D.target.value?Number(D.target.value):null:D.target.value||null}}),className:"w-full px-3 py-2 border rounded-lg font-mono text-sm",disabled:P})]},N)}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[s.jsxs(I,{variant:"secondary",onClick:()=>i(null),children:[s.jsx(Bs,{className:"w-4 h-4 mr-2"}),"Abbrechen"]}),s.jsxs(I,{onClick:w,disabled:f.isPending,children:[s.jsx(Nv,{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(ax,{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(Bs,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 overflow-hidden",children:s.jsx(KC,{onSelectTable:k})})]})]})]})}function BC({children:e}){const{isAuthenticated:t,isLoading:n}=qe();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(pa,{to:"/login",replace:!0})}function qC({children:e}){const{hasPermission:t,developerMode:n}=qe();return!t("developer:access")||!n?s.jsx(pa,{to:"/",replace:!0}):s.jsx(s.Fragment,{children:e})}function VC(){const{isAuthenticated:e,isLoading:t}=qe();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(f2,{}),s.jsxs(rw,{children:[s.jsx(Le,{path:"/login",element:e?s.jsx(pa,{to:"/",replace:!0}):s.jsx(Q2,{})}),s.jsxs(Le,{path:"/",element:s.jsx(BC,{children:s.jsx(V2,{})}),children:[s.jsx(Le,{index:!0,element:s.jsx(H2,{})}),s.jsx(Le,{path:"customers",element:s.jsx(G2,{})}),s.jsx(Le,{path:"customers/new",element:s.jsx(Ex,{})}),s.jsx(Le,{path:"customers/:id",element:s.jsx(nk,{})}),s.jsx(Le,{path:"customers/:id/edit",element:s.jsx(Ex,{})}),s.jsx(Le,{path:"contracts",element:s.jsx($k,{})}),s.jsx(Le,{path:"contracts/cockpit",element:s.jsx(mC,{})}),s.jsx(Le,{path:"contracts/new",element:s.jsx(Fx,{})}),s.jsx(Le,{path:"contracts/:id",element:s.jsx(rC,{})}),s.jsx(Le,{path:"contracts/:id/edit",element:s.jsx(Fx,{})}),s.jsx(Le,{path:"tasks",element:s.jsx(fC,{})}),s.jsx(Le,{path:"settings",element:s.jsx(_C,{})}),s.jsx(Le,{path:"settings/users",element:s.jsx(zC,{})}),s.jsx(Le,{path:"settings/platforms",element:s.jsx(gC,{})}),s.jsx(Le,{path:"settings/cancellation-periods",element:s.jsx(vC,{})}),s.jsx(Le,{path:"settings/contract-durations",element:s.jsx(bC,{})}),s.jsx(Le,{path:"settings/providers",element:s.jsx(wC,{})}),s.jsx(Le,{path:"settings/contract-categories",element:s.jsx(PC,{})}),s.jsx(Le,{path:"settings/view",element:s.jsx(FC,{})}),s.jsx(Le,{path:"settings/portal",element:s.jsx(TC,{})}),s.jsx(Le,{path:"settings/deadlines",element:s.jsx(IC,{})}),s.jsx(Le,{path:"settings/email-providers",element:s.jsx(LC,{})}),s.jsx(Le,{path:"settings/database-backup",element:s.jsx(OC,{})}),s.jsx(Le,{path:"users",element:s.jsx(pa,{to:"/settings/users",replace:!0})}),s.jsx(Le,{path:"platforms",element:s.jsx(pa,{to:"/settings/platforms",replace:!0})}),s.jsx(Le,{path:"developer/database",element:s.jsx(qC,{children:s.jsx(UC,{})})})]}),s.jsx(Le,{path:"*",element:s.jsx(pa,{to:"/",replace:!0})})]})]})}const QC=new Bw({defaultOptions:{queries:{retry:1,staleTime:0,gcTime:0,refetchOnMount:"always"}}});yd.createRoot(document.getElementById("root")).render(s.jsx(At.StrictMode,{children:s.jsx(qw,{client:QC,children:s.jsx(hw,{children:s.jsx(h2,{children:s.jsxs(m2,{children:[s.jsx(VC,{}),s.jsx(L1,{position:"top-right",toastOptions:{duration:4e3,style:{background:"#363636",color:"#fff"},success:{iconTheme:{primary:"#10b981",secondary:"#fff"}},error:{iconTheme:{primary:"#ef4444",secondary:"#fff"}}}})]})})})})}));