679 lines
657 KiB
JavaScript
679 lines
657 KiB
JavaScript
var Lh=e=>{throw TypeError(e)};var vc=(e,t,n)=>t.has(e)||Lh("Cannot "+n);var D=(e,t,n)=>(vc(e,t,"read from private field"),n?n.call(e):t.get(e)),me=(e,t,n)=>t.has(e)?Lh("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),re=(e,t,n,r)=>(vc(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),be=(e,t,n)=>(vc(e,t,"access private method"),n);var xl=(e,t,n,r)=>({set _(a){re(e,t,a,n)},get _(){return D(e,t,r)}});function X0(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 Y0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var px={exports:{}},zo={},xx={exports:{}},Se={};/**
|
||
* @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 Yi=Symbol.for("react.element"),ev=Symbol.for("react.portal"),tv=Symbol.for("react.fragment"),sv=Symbol.for("react.strict_mode"),nv=Symbol.for("react.profiler"),rv=Symbol.for("react.provider"),av=Symbol.for("react.context"),iv=Symbol.for("react.forward_ref"),lv=Symbol.for("react.suspense"),ov=Symbol.for("react.memo"),cv=Symbol.for("react.lazy"),Rh=Symbol.iterator;function uv(e){return e===null||typeof e!="object"?null:(e=Rh&&e[Rh]||e["@@iterator"],typeof e=="function"?e:null)}var gx={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},yx=Object.assign,vx={};function Oa(e,t,n){this.props=e,this.context=t,this.refs=vx,this.updater=n||gx}Oa.prototype.isReactComponent={};Oa.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")};Oa.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function jx(){}jx.prototype=Oa.prototype;function Dd(e,t,n){this.props=e,this.context=t,this.refs=vx,this.updater=n||gx}var Pd=Dd.prototype=new jx;Pd.constructor=Dd;yx(Pd,Oa.prototype);Pd.isPureReactComponent=!0;var Oh=Array.isArray,bx=Object.prototype.hasOwnProperty,Ad={current:null},Nx={key:!0,ref:!0,__self:!0,__source:!0};function wx(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)bx.call(t,r)&&!Nx.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),u=0;u<o;u++)c[u]=arguments[u+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:Yi,type:e,key:i,ref:l,props:a,_owner:Ad.current}}function dv(e,t){return{$$typeof:Yi,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Md(e){return typeof e=="object"&&e!==null&&e.$$typeof===Yi}function mv(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var zh=/\/+/g;function jc(e,t){return typeof e=="object"&&e!==null&&e.key!=null?mv(""+e.key):t.toString(36)}function zl(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 Yi:case ev:l=!0}}if(l)return l=e,a=a(l),e=r===""?"."+jc(l,0):r,Oh(a)?(n="",e!=null&&(n=e.replace(zh,"$&/")+"/"),zl(a,t,n,"",function(u){return u})):a!=null&&(Md(a)&&(a=dv(a,n+(!a.key||l&&l.key===a.key?"":(""+a.key).replace(zh,"$&/")+"/")+e)),t.push(a)),1;if(l=0,r=r===""?".":r+":",Oh(e))for(var o=0;o<e.length;o++){i=e[o];var c=r+jc(i,o);l+=zl(i,t,n,c,a)}else if(c=uv(e),typeof c=="function")for(e=c.call(e),o=0;!(i=e.next()).done;)i=i.value,c=r+jc(i,o++),l+=zl(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 gl(e,t,n){if(e==null)return e;var r=[],a=0;return zl(e,r,"","",function(i){return t.call(n,i,a++)}),r}function hv(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 Kt={current:null},_l={transition:null},fv={ReactCurrentDispatcher:Kt,ReactCurrentBatchConfig:_l,ReactCurrentOwner:Ad};function Sx(){throw Error("act(...) is not supported in production builds of React.")}Se.Children={map:gl,forEach:function(e,t,n){gl(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return gl(e,function(){t++}),t},toArray:function(e){return gl(e,function(t){return t})||[]},only:function(e){if(!Md(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Se.Component=Oa;Se.Fragment=tv;Se.Profiler=nv;Se.PureComponent=Dd;Se.StrictMode=sv;Se.Suspense=lv;Se.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=fv;Se.act=Sx;Se.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=yx({},e.props),a=e.key,i=e.ref,l=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,l=Ad.current),t.key!==void 0&&(a=""+t.key),e.type&&e.type.defaultProps)var o=e.type.defaultProps;for(c in t)bx.call(t,c)&&!Nx.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 u=0;u<c;u++)o[u]=arguments[u+2];r.children=o}return{$$typeof:Yi,type:e.type,key:a,ref:i,props:r,_owner:l}};Se.createContext=function(e){return e={$$typeof:av,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:rv,_context:e},e.Consumer=e};Se.createElement=wx;Se.createFactory=function(e){var t=wx.bind(null,e);return t.type=e,t};Se.createRef=function(){return{current:null}};Se.forwardRef=function(e){return{$$typeof:iv,render:e}};Se.isValidElement=Md;Se.lazy=function(e){return{$$typeof:cv,_payload:{_status:-1,_result:e},_init:hv}};Se.memo=function(e,t){return{$$typeof:ov,type:e,compare:t===void 0?null:t}};Se.startTransition=function(e){var t=_l.transition;_l.transition={};try{e()}finally{_l.transition=t}};Se.unstable_act=Sx;Se.useCallback=function(e,t){return Kt.current.useCallback(e,t)};Se.useContext=function(e){return Kt.current.useContext(e)};Se.useDebugValue=function(){};Se.useDeferredValue=function(e){return Kt.current.useDeferredValue(e)};Se.useEffect=function(e,t){return Kt.current.useEffect(e,t)};Se.useId=function(){return Kt.current.useId()};Se.useImperativeHandle=function(e,t,n){return Kt.current.useImperativeHandle(e,t,n)};Se.useInsertionEffect=function(e,t){return Kt.current.useInsertionEffect(e,t)};Se.useLayoutEffect=function(e,t){return Kt.current.useLayoutEffect(e,t)};Se.useMemo=function(e,t){return Kt.current.useMemo(e,t)};Se.useReducer=function(e,t,n){return Kt.current.useReducer(e,t,n)};Se.useRef=function(e){return Kt.current.useRef(e)};Se.useState=function(e){return Kt.current.useState(e)};Se.useSyncExternalStore=function(e,t,n){return Kt.current.useSyncExternalStore(e,t,n)};Se.useTransition=function(){return Kt.current.useTransition()};Se.version="18.3.1";xx.exports=Se;var b=xx.exports;const Ct=Y0(b),pv=X0({__proto__:null,default:Ct},[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 xv=b,gv=Symbol.for("react.element"),yv=Symbol.for("react.fragment"),vv=Object.prototype.hasOwnProperty,jv=xv.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,bv={key:!0,ref:!0,__self:!0,__source:!0};function kx(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)vv.call(t,r)&&!bv.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:gv,type:e,key:i,ref:l,props:a,_owner:jv.current}}zo.Fragment=yv;zo.jsx=kx;zo.jsxs=kx;px.exports=zo;var s=px.exports,nu={},Cx={exports:{}},cs={},Ex={exports:{}},Dx={};/**
|
||
* @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(R,Q){var ee=R.length;R.push(Q);e:for(;0<ee;){var fe=ee-1>>>1,ue=R[fe];if(0<a(ue,Q))R[fe]=Q,R[ee]=ue,ee=fe;else break e}}function n(R){return R.length===0?null:R[0]}function r(R){if(R.length===0)return null;var Q=R[0],ee=R.pop();if(ee!==Q){R[0]=ee;e:for(var fe=0,ue=R.length,nt=ue>>>1;fe<nt;){var H=2*(fe+1)-1,ke=R[H],Ae=H+1,rt=R[Ae];if(0>a(ke,ee))Ae<ue&&0>a(rt,ke)?(R[fe]=rt,R[Ae]=ee,fe=Ae):(R[fe]=ke,R[H]=ee,fe=H);else if(Ae<ue&&0>a(rt,ee))R[fe]=rt,R[Ae]=ee,fe=Ae;else break e}}return Q}function a(R,Q){var ee=R.sortIndex-Q.sortIndex;return ee!==0?ee:R.id-Q.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=[],u=[],d=1,h=null,p=3,m=!1,f=!1,y=!1,N=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(R){for(var Q=n(u);Q!==null;){if(Q.callback===null)r(u);else if(Q.startTime<=R)r(u),Q.sortIndex=Q.expirationTime,t(c,Q);else break;Q=n(u)}}function j(R){if(y=!1,x(R),!f)if(n(c)!==null)f=!0,C(k);else{var Q=n(u);Q!==null&&w(j,Q.startTime-R)}}function k(R,Q){f=!1,y&&(y=!1,v(S),S=-1),m=!0;var ee=p;try{for(x(Q),h=n(c);h!==null&&(!(h.expirationTime>Q)||R&&!_());){var fe=h.callback;if(typeof fe=="function"){h.callback=null,p=h.priorityLevel;var ue=fe(h.expirationTime<=Q);Q=e.unstable_now(),typeof ue=="function"?h.callback=ue:h===n(c)&&r(c),x(Q)}else r(c);h=n(c)}if(h!==null)var nt=!0;else{var H=n(u);H!==null&&w(j,H.startTime-Q),nt=!1}return nt}finally{h=null,p=ee,m=!1}}var F=!1,E=null,S=-1,P=5,A=-1;function _(){return!(e.unstable_now()-A<P)}function L(){if(E!==null){var R=e.unstable_now();A=R;var Q=!0;try{Q=E(!0,R)}finally{Q?V():(F=!1,E=null)}}else F=!1}var V;if(typeof g=="function")V=function(){g(L)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,O=q.port2;q.port1.onmessage=L,V=function(){O.postMessage(null)}}else V=function(){N(L,0)};function C(R){E=R,F||(F=!0,V())}function w(R,Q){S=N(function(){R(e.unstable_now())},Q)}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(R){R.callback=null},e.unstable_continueExecution=function(){f||m||(f=!0,C(k))},e.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<R?Math.floor(1e3/R):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(R){switch(p){case 1:case 2:case 3:var Q=3;break;default:Q=p}var ee=p;p=Q;try{return R()}finally{p=ee}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(R,Q){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var ee=p;p=R;try{return Q()}finally{p=ee}},e.unstable_scheduleCallback=function(R,Q,ee){var fe=e.unstable_now();switch(typeof ee=="object"&&ee!==null?(ee=ee.delay,ee=typeof ee=="number"&&0<ee?fe+ee:fe):ee=fe,R){case 1:var ue=-1;break;case 2:ue=250;break;case 5:ue=1073741823;break;case 4:ue=1e4;break;default:ue=5e3}return ue=ee+ue,R={id:d++,callback:Q,priorityLevel:R,startTime:ee,expirationTime:ue,sortIndex:-1},ee>fe?(R.sortIndex=ee,t(u,R),n(c)===null&&R===n(u)&&(y?(v(S),S=-1):y=!0,w(j,ee-fe))):(R.sortIndex=ue,t(c,R),f||m||(f=!0,C(k))),R},e.unstable_shouldYield=_,e.unstable_wrapCallback=function(R){var Q=p;return function(){var ee=p;p=Q;try{return R.apply(this,arguments)}finally{p=ee}}}})(Dx);Ex.exports=Dx;var Nv=Ex.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 wv=b,os=Nv;function Z(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 Px=new Set,Ni={};function zr(e,t){Ea(e,t),Ea(e+"Capture",t)}function Ea(e,t){for(Ni[e]=t,e=0;e<t.length;e++)Px.add(t[e])}var fn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ru=Object.prototype.hasOwnProperty,Sv=/^[: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]*$/,_h={},$h={};function kv(e){return ru.call($h,e)?!0:ru.call(_h,e)?!1:Sv.test(e)?$h[e]=!0:(_h[e]=!0,!1)}function Cv(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 Ev(e,t,n,r){if(t===null||typeof t>"u"||Cv(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 qt(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 Pt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Pt[e]=new qt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Pt[t]=new qt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Pt[e]=new qt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Pt[e]=new qt(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){Pt[e]=new qt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Pt[e]=new qt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Pt[e]=new qt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Pt[e]=new qt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Pt[e]=new qt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Td=/[\-:]([a-z])/g;function Fd(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(Td,Fd);Pt[t]=new qt(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(Td,Fd);Pt[t]=new qt(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(Td,Fd);Pt[t]=new qt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Pt[e]=new qt(e,1,!1,e.toLowerCase(),null,!1,!1)});Pt.xlinkHref=new qt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Pt[e]=new qt(e,1,!1,e.toLowerCase(),null,!0,!0)});function Id(e,t,n,r){var a=Pt.hasOwnProperty(t)?Pt[t]:null;(a!==null?a.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(Ev(t,n,a,r)&&(n=null),r||a===null?kv(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 bn=wv.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,yl=Symbol.for("react.element"),Wr=Symbol.for("react.portal"),Gr=Symbol.for("react.fragment"),Ld=Symbol.for("react.strict_mode"),au=Symbol.for("react.profiler"),Ax=Symbol.for("react.provider"),Mx=Symbol.for("react.context"),Rd=Symbol.for("react.forward_ref"),iu=Symbol.for("react.suspense"),lu=Symbol.for("react.suspense_list"),Od=Symbol.for("react.memo"),En=Symbol.for("react.lazy"),Tx=Symbol.for("react.offscreen"),Uh=Symbol.iterator;function Wa(e){return e===null||typeof e!="object"?null:(e=Uh&&e[Uh]||e["@@iterator"],typeof e=="function"?e:null)}var Ze=Object.assign,bc;function ri(e){if(bc===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);bc=t&&t[1]||""}return`
|
||
`+bc+e}var Nc=!1;function wc(e,t){if(!e||Nc)return"";Nc=!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(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var a=u.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{Nc=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?ri(e):""}function Dv(e){switch(e.tag){case 5:return ri(e.type);case 16:return ri("Lazy");case 13:return ri("Suspense");case 19:return ri("SuspenseList");case 0:case 2:case 15:return e=wc(e.type,!1),e;case 11:return e=wc(e.type.render,!1),e;case 1:return e=wc(e.type,!0),e;default:return""}}function ou(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 Gr:return"Fragment";case Wr:return"Portal";case au:return"Profiler";case Ld:return"StrictMode";case iu:return"Suspense";case lu:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Mx:return(e.displayName||"Context")+".Consumer";case Ax:return(e._context.displayName||"Context")+".Provider";case Rd:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Od:return t=e.displayName||null,t!==null?t:ou(e.type)||"Memo";case En:t=e._payload,e=e._init;try{return ou(e(t))}catch{}}return null}function Pv(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 ou(t);case 8:return t===Ld?"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 tr(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Fx(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Av(e){var t=Fx(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 vl(e){e._valueTracker||(e._valueTracker=Av(e))}function Ix(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Fx(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function so(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 cu(e,t){var n=t.checked;return Ze({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Bh(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=tr(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 Lx(e,t){t=t.checked,t!=null&&Id(e,"checked",t,!1)}function uu(e,t){Lx(e,t);var n=tr(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")?du(e,t.type,n):t.hasOwnProperty("defaultValue")&&du(e,t.type,tr(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Kh(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 du(e,t,n){(t!=="number"||so(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var ai=Array.isArray;function la(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=""+tr(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 mu(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Z(91));return Ze({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function qh(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Z(92));if(ai(n)){if(1<n.length)throw Error(Z(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:tr(n)}}function Rx(e,t){var n=tr(t.value),r=tr(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 Vh(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Ox(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 hu(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Ox(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var jl,zx=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(jl=jl||document.createElement("div"),jl.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=jl.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function wi(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ui={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},Mv=["Webkit","ms","Moz","O"];Object.keys(ui).forEach(function(e){Mv.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ui[t]=ui[e]})});function _x(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||ui.hasOwnProperty(e)&&ui[e]?(""+t).trim():t+"px"}function $x(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,a=_x(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,a):e[n]=a}}var Tv=Ze({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 fu(e,t){if(t){if(Tv[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Z(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Z(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Z(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Z(62))}}function pu(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 xu=null;function zd(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var gu=null,oa=null,ca=null;function Qh(e){if(e=sl(e)){if(typeof gu!="function")throw Error(Z(280));var t=e.stateNode;t&&(t=Ko(t),gu(e.stateNode,e.type,t))}}function Ux(e){oa?ca?ca.push(e):ca=[e]:oa=e}function Bx(){if(oa){var e=oa,t=ca;if(ca=oa=null,Qh(e),t)for(e=0;e<t.length;e++)Qh(t[e])}}function Kx(e,t){return e(t)}function qx(){}var Sc=!1;function Vx(e,t,n){if(Sc)return e(t,n);Sc=!0;try{return Kx(e,t,n)}finally{Sc=!1,(oa!==null||ca!==null)&&(qx(),Bx())}}function Si(e,t){var n=e.stateNode;if(n===null)return null;var r=Ko(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(Z(231,t,typeof n));return n}var yu=!1;if(fn)try{var Ga={};Object.defineProperty(Ga,"passive",{get:function(){yu=!0}}),window.addEventListener("test",Ga,Ga),window.removeEventListener("test",Ga,Ga)}catch{yu=!1}function Fv(e,t,n,r,a,i,l,o,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(d){this.onError(d)}}var di=!1,no=null,ro=!1,vu=null,Iv={onError:function(e){di=!0,no=e}};function Lv(e,t,n,r,a,i,l,o,c){di=!1,no=null,Fv.apply(Iv,arguments)}function Rv(e,t,n,r,a,i,l,o,c){if(Lv.apply(this,arguments),di){if(di){var u=no;di=!1,no=null}else throw Error(Z(198));ro||(ro=!0,vu=u)}}function _r(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 Qx(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 Hh(e){if(_r(e)!==e)throw Error(Z(188))}function Ov(e){var t=e.alternate;if(!t){if(t=_r(e),t===null)throw Error(Z(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 Hh(a),e;if(i===r)return Hh(a),t;i=i.sibling}throw Error(Z(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(Z(189))}}if(n.alternate!==r)throw Error(Z(190))}if(n.tag!==3)throw Error(Z(188));return n.stateNode.current===n?e:t}function Hx(e){return e=Ov(e),e!==null?Wx(e):null}function Wx(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Wx(e);if(t!==null)return t;e=e.sibling}return null}var Gx=os.unstable_scheduleCallback,Wh=os.unstable_cancelCallback,zv=os.unstable_shouldYield,_v=os.unstable_requestPaint,it=os.unstable_now,$v=os.unstable_getCurrentPriorityLevel,_d=os.unstable_ImmediatePriority,Zx=os.unstable_UserBlockingPriority,ao=os.unstable_NormalPriority,Uv=os.unstable_LowPriority,Jx=os.unstable_IdlePriority,_o=null,Vs=null;function Bv(e){if(Vs&&typeof Vs.onCommitFiberRoot=="function")try{Vs.onCommitFiberRoot(_o,e,void 0,(e.current.flags&128)===128)}catch{}}var Ts=Math.clz32?Math.clz32:Vv,Kv=Math.log,qv=Math.LN2;function Vv(e){return e>>>=0,e===0?32:31-(Kv(e)/qv|0)|0}var bl=64,Nl=4194304;function ii(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 io(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=ii(o):(i&=l,i!==0&&(r=ii(i)))}else l=n&~a,l!==0?r=ii(l):i!==0&&(r=ii(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-Ts(t),a=1<<n,r|=e[n],t&=~a;return r}function Qv(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 Hv(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,i=e.pendingLanes;0<i;){var l=31-Ts(i),o=1<<l,c=a[l];c===-1?(!(o&n)||o&r)&&(a[l]=Qv(o,t)):c<=t&&(e.expiredLanes|=o),i&=~o}}function ju(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Xx(){var e=bl;return bl<<=1,!(bl&4194240)&&(bl=64),e}function kc(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function el(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ts(t),e[t]=n}function Wv(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-Ts(n),i=1<<a;t[a]=0,r[a]=-1,e[a]=-1,n&=~i}}function $d(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ts(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}var Ie=0;function Yx(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var eg,Ud,tg,sg,ng,bu=!1,wl=[],Vn=null,Qn=null,Hn=null,ki=new Map,Ci=new Map,Pn=[],Gv="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 Gh(e,t){switch(e){case"focusin":case"focusout":Vn=null;break;case"dragenter":case"dragleave":Qn=null;break;case"mouseover":case"mouseout":Hn=null;break;case"pointerover":case"pointerout":ki.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ci.delete(t.pointerId)}}function Za(e,t,n,r,a,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[a]},t!==null&&(t=sl(t),t!==null&&Ud(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function Zv(e,t,n,r,a){switch(t){case"focusin":return Vn=Za(Vn,e,t,n,r,a),!0;case"dragenter":return Qn=Za(Qn,e,t,n,r,a),!0;case"mouseover":return Hn=Za(Hn,e,t,n,r,a),!0;case"pointerover":var i=a.pointerId;return ki.set(i,Za(ki.get(i)||null,e,t,n,r,a)),!0;case"gotpointercapture":return i=a.pointerId,Ci.set(i,Za(Ci.get(i)||null,e,t,n,r,a)),!0}return!1}function rg(e){var t=dr(e.target);if(t!==null){var n=_r(t);if(n!==null){if(t=n.tag,t===13){if(t=Qx(n),t!==null){e.blockedOn=t,ng(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 $l(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Nu(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);xu=r,n.target.dispatchEvent(r),xu=null}else return t=sl(n),t!==null&&Ud(t),e.blockedOn=n,!1;t.shift()}return!0}function Zh(e,t,n){$l(e)&&n.delete(t)}function Jv(){bu=!1,Vn!==null&&$l(Vn)&&(Vn=null),Qn!==null&&$l(Qn)&&(Qn=null),Hn!==null&&$l(Hn)&&(Hn=null),ki.forEach(Zh),Ci.forEach(Zh)}function Ja(e,t){e.blockedOn===t&&(e.blockedOn=null,bu||(bu=!0,os.unstable_scheduleCallback(os.unstable_NormalPriority,Jv)))}function Ei(e){function t(a){return Ja(a,e)}if(0<wl.length){Ja(wl[0],e);for(var n=1;n<wl.length;n++){var r=wl[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Vn!==null&&Ja(Vn,e),Qn!==null&&Ja(Qn,e),Hn!==null&&Ja(Hn,e),ki.forEach(t),Ci.forEach(t),n=0;n<Pn.length;n++)r=Pn[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Pn.length&&(n=Pn[0],n.blockedOn===null);)rg(n),n.blockedOn===null&&Pn.shift()}var ua=bn.ReactCurrentBatchConfig,lo=!0;function Xv(e,t,n,r){var a=Ie,i=ua.transition;ua.transition=null;try{Ie=1,Bd(e,t,n,r)}finally{Ie=a,ua.transition=i}}function Yv(e,t,n,r){var a=Ie,i=ua.transition;ua.transition=null;try{Ie=4,Bd(e,t,n,r)}finally{Ie=a,ua.transition=i}}function Bd(e,t,n,r){if(lo){var a=Nu(e,t,n,r);if(a===null)Lc(e,t,r,oo,n),Gh(e,r);else if(Zv(a,e,t,n,r))r.stopPropagation();else if(Gh(e,r),t&4&&-1<Gv.indexOf(e)){for(;a!==null;){var i=sl(a);if(i!==null&&eg(i),i=Nu(e,t,n,r),i===null&&Lc(e,t,r,oo,n),i===a)break;a=i}a!==null&&r.stopPropagation()}else Lc(e,t,r,null,n)}}var oo=null;function Nu(e,t,n,r){if(oo=null,e=zd(r),e=dr(e),e!==null)if(t=_r(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Qx(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 oo=e,null}function ag(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($v()){case _d:return 1;case Zx:return 4;case ao:case Uv:return 16;case Jx:return 536870912;default:return 16}default:return 16}}var Bn=null,Kd=null,Ul=null;function ig(){if(Ul)return Ul;var e,t=Kd,n=t.length,r,a="value"in Bn?Bn.value:Bn.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 Ul=a.slice(e,1<r?1-r:void 0)}function Bl(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 Sl(){return!0}function Jh(){return!1}function us(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)?Sl:Jh,this.isPropagationStopped=Jh,this}return Ze(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=Sl)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Sl)},persist:function(){},isPersistent:Sl}),t}var za={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},qd=us(za),tl=Ze({},za,{view:0,detail:0}),ej=us(tl),Cc,Ec,Xa,$o=Ze({},tl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Vd,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!==Xa&&(Xa&&e.type==="mousemove"?(Cc=e.screenX-Xa.screenX,Ec=e.screenY-Xa.screenY):Ec=Cc=0,Xa=e),Cc)},movementY:function(e){return"movementY"in e?e.movementY:Ec}}),Xh=us($o),tj=Ze({},$o,{dataTransfer:0}),sj=us(tj),nj=Ze({},tl,{relatedTarget:0}),Dc=us(nj),rj=Ze({},za,{animationName:0,elapsedTime:0,pseudoElement:0}),aj=us(rj),ij=Ze({},za,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),lj=us(ij),oj=Ze({},za,{data:0}),Yh=us(oj),cj={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},uj={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"},dj={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mj(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=dj[e])?!!t[e]:!1}function Vd(){return mj}var hj=Ze({},tl,{key:function(e){if(e.key){var t=cj[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Bl(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?uj[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Vd,charCode:function(e){return e.type==="keypress"?Bl(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Bl(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),fj=us(hj),pj=Ze({},$o,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ef=us(pj),xj=Ze({},tl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Vd}),gj=us(xj),yj=Ze({},za,{propertyName:0,elapsedTime:0,pseudoElement:0}),vj=us(yj),jj=Ze({},$o,{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}),bj=us(jj),Nj=[9,13,27,32],Qd=fn&&"CompositionEvent"in window,mi=null;fn&&"documentMode"in document&&(mi=document.documentMode);var wj=fn&&"TextEvent"in window&&!mi,lg=fn&&(!Qd||mi&&8<mi&&11>=mi),tf=" ",sf=!1;function og(e,t){switch(e){case"keyup":return Nj.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function cg(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Zr=!1;function Sj(e,t){switch(e){case"compositionend":return cg(t);case"keypress":return t.which!==32?null:(sf=!0,tf);case"textInput":return e=t.data,e===tf&&sf?null:e;default:return null}}function kj(e,t){if(Zr)return e==="compositionend"||!Qd&&og(e,t)?(e=ig(),Ul=Kd=Bn=null,Zr=!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 lg&&t.locale!=="ko"?null:t.data;default:return null}}var Cj={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 nf(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Cj[e.type]:t==="textarea"}function ug(e,t,n,r){Ux(r),t=co(t,"onChange"),0<t.length&&(n=new qd("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var hi=null,Di=null;function Ej(e){bg(e,0)}function Uo(e){var t=Yr(e);if(Ix(t))return e}function Dj(e,t){if(e==="change")return t}var dg=!1;if(fn){var Pc;if(fn){var Ac="oninput"in document;if(!Ac){var rf=document.createElement("div");rf.setAttribute("oninput","return;"),Ac=typeof rf.oninput=="function"}Pc=Ac}else Pc=!1;dg=Pc&&(!document.documentMode||9<document.documentMode)}function af(){hi&&(hi.detachEvent("onpropertychange",mg),Di=hi=null)}function mg(e){if(e.propertyName==="value"&&Uo(Di)){var t=[];ug(t,Di,e,zd(e)),Vx(Ej,t)}}function Pj(e,t,n){e==="focusin"?(af(),hi=t,Di=n,hi.attachEvent("onpropertychange",mg)):e==="focusout"&&af()}function Aj(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Uo(Di)}function Mj(e,t){if(e==="click")return Uo(t)}function Tj(e,t){if(e==="input"||e==="change")return Uo(t)}function Fj(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Is=typeof Object.is=="function"?Object.is:Fj;function Pi(e,t){if(Is(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(!ru.call(t,a)||!Is(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 hg(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?hg(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function fg(){for(var e=window,t=so();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=so(e.document)}return t}function Hd(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 Ij(e){var t=fg(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&hg(n.ownerDocument.documentElement,n)){if(r!==null&&Hd(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 Lj=fn&&"documentMode"in document&&11>=document.documentMode,Jr=null,wu=null,fi=null,Su=!1;function cf(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Su||Jr==null||Jr!==so(r)||(r=Jr,"selectionStart"in r&&Hd(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}),fi&&Pi(fi,r)||(fi=r,r=co(wu,"onSelect"),0<r.length&&(t=new qd("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Jr)))}function kl(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Xr={animationend:kl("Animation","AnimationEnd"),animationiteration:kl("Animation","AnimationIteration"),animationstart:kl("Animation","AnimationStart"),transitionend:kl("Transition","TransitionEnd")},Mc={},pg={};fn&&(pg=document.createElement("div").style,"AnimationEvent"in window||(delete Xr.animationend.animation,delete Xr.animationiteration.animation,delete Xr.animationstart.animation),"TransitionEvent"in window||delete Xr.transitionend.transition);function Bo(e){if(Mc[e])return Mc[e];if(!Xr[e])return e;var t=Xr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in pg)return Mc[e]=t[n];return e}var xg=Bo("animationend"),gg=Bo("animationiteration"),yg=Bo("animationstart"),vg=Bo("transitionend"),jg=new Map,uf="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 rr(e,t){jg.set(e,t),zr(t,[e])}for(var Tc=0;Tc<uf.length;Tc++){var Fc=uf[Tc],Rj=Fc.toLowerCase(),Oj=Fc[0].toUpperCase()+Fc.slice(1);rr(Rj,"on"+Oj)}rr(xg,"onAnimationEnd");rr(gg,"onAnimationIteration");rr(yg,"onAnimationStart");rr("dblclick","onDoubleClick");rr("focusin","onFocus");rr("focusout","onBlur");rr(vg,"onTransitionEnd");Ea("onMouseEnter",["mouseout","mouseover"]);Ea("onMouseLeave",["mouseout","mouseover"]);Ea("onPointerEnter",["pointerout","pointerover"]);Ea("onPointerLeave",["pointerout","pointerover"]);zr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));zr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));zr("onBeforeInput",["compositionend","keypress","textInput","paste"]);zr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));zr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));zr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var li="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),zj=new Set("cancel close invalid load scroll toggle".split(" ").concat(li));function df(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,Rv(r,t,void 0,e),e.currentTarget=null}function bg(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,u=o.currentTarget;if(o=o.listener,c!==i&&a.isPropagationStopped())break e;df(a,o,u),i=c}else for(l=0;l<r.length;l++){if(o=r[l],c=o.instance,u=o.currentTarget,o=o.listener,c!==i&&a.isPropagationStopped())break e;df(a,o,u),i=c}}}if(ro)throw e=vu,ro=!1,vu=null,e}function _e(e,t){var n=t[Pu];n===void 0&&(n=t[Pu]=new Set);var r=e+"__bubble";n.has(r)||(Ng(t,e,2,!1),n.add(r))}function Ic(e,t,n){var r=0;t&&(r|=4),Ng(n,e,r,t)}var Cl="_reactListening"+Math.random().toString(36).slice(2);function Ai(e){if(!e[Cl]){e[Cl]=!0,Px.forEach(function(n){n!=="selectionchange"&&(zj.has(n)||Ic(n,!1,e),Ic(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Cl]||(t[Cl]=!0,Ic("selectionchange",!1,t))}}function Ng(e,t,n,r){switch(ag(t)){case 1:var a=Xv;break;case 4:a=Yv;break;default:a=Bd}n=a.bind(null,t,n,e),a=void 0,!yu||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 Lc(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=dr(o),l===null)return;if(c=l.tag,c===5||c===6){r=i=l;continue e}o=o.parentNode}}r=r.return}Vx(function(){var u=i,d=zd(n),h=[];e:{var p=jg.get(e);if(p!==void 0){var m=qd,f=e;switch(e){case"keypress":if(Bl(n)===0)break e;case"keydown":case"keyup":m=fj;break;case"focusin":f="focus",m=Dc;break;case"focusout":f="blur",m=Dc;break;case"beforeblur":case"afterblur":m=Dc;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=Xh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=sj;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=gj;break;case xg:case gg:case yg:m=aj;break;case vg:m=vj;break;case"scroll":m=ej;break;case"wheel":m=bj;break;case"copy":case"cut":case"paste":m=lj;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=ef}var y=(t&4)!==0,N=!y&&e==="scroll",v=y?p!==null?p+"Capture":null:p;y=[];for(var g=u,x;g!==null;){x=g;var j=x.stateNode;if(x.tag===5&&j!==null&&(x=j,v!==null&&(j=Si(g,v),j!=null&&y.push(Mi(g,j,x)))),N)break;g=g.return}0<y.length&&(p=new m(p,f,null,n,d),h.push({event:p,listeners:y}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",p&&n!==xu&&(f=n.relatedTarget||n.fromElement)&&(dr(f)||f[pn]))break e;if((m||p)&&(p=d.window===d?d:(p=d.ownerDocument)?p.defaultView||p.parentWindow:window,m?(f=n.relatedTarget||n.toElement,m=u,f=f?dr(f):null,f!==null&&(N=_r(f),f!==N||f.tag!==5&&f.tag!==6)&&(f=null)):(m=null,f=u),m!==f)){if(y=Xh,j="onMouseLeave",v="onMouseEnter",g="mouse",(e==="pointerout"||e==="pointerover")&&(y=ef,j="onPointerLeave",v="onPointerEnter",g="pointer"),N=m==null?p:Yr(m),x=f==null?p:Yr(f),p=new y(j,g+"leave",m,n,d),p.target=N,p.relatedTarget=x,j=null,dr(d)===u&&(y=new y(v,g+"enter",f,n,d),y.target=x,y.relatedTarget=N,j=y),N=j,m&&f)t:{for(y=m,v=f,g=0,x=y;x;x=qr(x))g++;for(x=0,j=v;j;j=qr(j))x++;for(;0<g-x;)y=qr(y),g--;for(;0<x-g;)v=qr(v),x--;for(;g--;){if(y===v||v!==null&&y===v.alternate)break t;y=qr(y),v=qr(v)}y=null}else y=null;m!==null&&mf(h,p,m,y,!1),f!==null&&N!==null&&mf(h,N,f,y,!0)}}e:{if(p=u?Yr(u):window,m=p.nodeName&&p.nodeName.toLowerCase(),m==="select"||m==="input"&&p.type==="file")var k=Dj;else if(nf(p))if(dg)k=Tj;else{k=Aj;var F=Pj}else(m=p.nodeName)&&m.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(k=Mj);if(k&&(k=k(e,u))){ug(h,k,n,d);break e}F&&F(e,p,u),e==="focusout"&&(F=p._wrapperState)&&F.controlled&&p.type==="number"&&du(p,"number",p.value)}switch(F=u?Yr(u):window,e){case"focusin":(nf(F)||F.contentEditable==="true")&&(Jr=F,wu=u,fi=null);break;case"focusout":fi=wu=Jr=null;break;case"mousedown":Su=!0;break;case"contextmenu":case"mouseup":case"dragend":Su=!1,cf(h,n,d);break;case"selectionchange":if(Lj)break;case"keydown":case"keyup":cf(h,n,d)}var E;if(Qd)e:{switch(e){case"compositionstart":var S="onCompositionStart";break e;case"compositionend":S="onCompositionEnd";break e;case"compositionupdate":S="onCompositionUpdate";break e}S=void 0}else Zr?og(e,n)&&(S="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(S="onCompositionStart");S&&(lg&&n.locale!=="ko"&&(Zr||S!=="onCompositionStart"?S==="onCompositionEnd"&&Zr&&(E=ig()):(Bn=d,Kd="value"in Bn?Bn.value:Bn.textContent,Zr=!0)),F=co(u,S),0<F.length&&(S=new Yh(S,e,null,n,d),h.push({event:S,listeners:F}),E?S.data=E:(E=cg(n),E!==null&&(S.data=E)))),(E=wj?Sj(e,n):kj(e,n))&&(u=co(u,"onBeforeInput"),0<u.length&&(d=new Yh("onBeforeInput","beforeinput",null,n,d),h.push({event:d,listeners:u}),d.data=E))}bg(h,t)})}function Mi(e,t,n){return{instance:e,listener:t,currentTarget:n}}function co(e,t){for(var n=t+"Capture",r=[];e!==null;){var a=e,i=a.stateNode;a.tag===5&&i!==null&&(a=i,i=Si(e,n),i!=null&&r.unshift(Mi(e,i,a)),i=Si(e,t),i!=null&&r.push(Mi(e,i,a))),e=e.return}return r}function qr(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function mf(e,t,n,r,a){for(var i=t._reactName,l=[];n!==null&&n!==r;){var o=n,c=o.alternate,u=o.stateNode;if(c!==null&&c===r)break;o.tag===5&&u!==null&&(o=u,a?(c=Si(n,i),c!=null&&l.unshift(Mi(n,c,o))):a||(c=Si(n,i),c!=null&&l.push(Mi(n,c,o)))),n=n.return}l.length!==0&&e.push({event:t,listeners:l})}var _j=/\r\n?/g,$j=/\u0000|\uFFFD/g;function hf(e){return(typeof e=="string"?e:""+e).replace(_j,`
|
||
`).replace($j,"")}function El(e,t,n){if(t=hf(t),hf(e)!==t&&n)throw Error(Z(425))}function uo(){}var ku=null,Cu=null;function Eu(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 Du=typeof setTimeout=="function"?setTimeout:void 0,Uj=typeof clearTimeout=="function"?clearTimeout:void 0,ff=typeof Promise=="function"?Promise:void 0,Bj=typeof queueMicrotask=="function"?queueMicrotask:typeof ff<"u"?function(e){return ff.resolve(null).then(e).catch(Kj)}:Du;function Kj(e){setTimeout(function(){throw e})}function Rc(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),Ei(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=a}while(n);Ei(t)}function Wn(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 pf(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 _a=Math.random().toString(36).slice(2),Ks="__reactFiber$"+_a,Ti="__reactProps$"+_a,pn="__reactContainer$"+_a,Pu="__reactEvents$"+_a,qj="__reactListeners$"+_a,Vj="__reactHandles$"+_a;function dr(e){var t=e[Ks];if(t)return t;for(var n=e.parentNode;n;){if(t=n[pn]||n[Ks]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=pf(e);e!==null;){if(n=e[Ks])return n;e=pf(e)}return t}e=n,n=e.parentNode}return null}function sl(e){return e=e[Ks]||e[pn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Yr(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Z(33))}function Ko(e){return e[Ti]||null}var Au=[],ea=-1;function ar(e){return{current:e}}function Ue(e){0>ea||(e.current=Au[ea],Au[ea]=null,ea--)}function Oe(e,t){ea++,Au[ea]=e.current,e.current=t}var sr={},Lt=ar(sr),Xt=ar(!1),Pr=sr;function Da(e,t){var n=e.type.contextTypes;if(!n)return sr;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 Yt(e){return e=e.childContextTypes,e!=null}function mo(){Ue(Xt),Ue(Lt)}function xf(e,t,n){if(Lt.current!==sr)throw Error(Z(168));Oe(Lt,t),Oe(Xt,n)}function wg(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(Z(108,Pv(e)||"Unknown",a));return Ze({},n,r)}function ho(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||sr,Pr=Lt.current,Oe(Lt,e),Oe(Xt,Xt.current),!0}function gf(e,t,n){var r=e.stateNode;if(!r)throw Error(Z(169));n?(e=wg(e,t,Pr),r.__reactInternalMemoizedMergedChildContext=e,Ue(Xt),Ue(Lt),Oe(Lt,e)):Ue(Xt),Oe(Xt,n)}var tn=null,qo=!1,Oc=!1;function Sg(e){tn===null?tn=[e]:tn.push(e)}function Qj(e){qo=!0,Sg(e)}function ir(){if(!Oc&&tn!==null){Oc=!0;var e=0,t=Ie;try{var n=tn;for(Ie=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}tn=null,qo=!1}catch(a){throw tn!==null&&(tn=tn.slice(e+1)),Gx(_d,ir),a}finally{Ie=t,Oc=!1}}return null}var ta=[],sa=0,fo=null,po=0,hs=[],fs=0,Ar=null,on=1,cn="";function cr(e,t){ta[sa++]=po,ta[sa++]=fo,fo=e,po=t}function kg(e,t,n){hs[fs++]=on,hs[fs++]=cn,hs[fs++]=Ar,Ar=e;var r=on;e=cn;var a=32-Ts(r)-1;r&=~(1<<a),n+=1;var i=32-Ts(t)+a;if(30<i){var l=a-a%5;i=(r&(1<<l)-1).toString(32),r>>=l,a-=l,on=1<<32-Ts(t)+a|n<<a|r,cn=i+e}else on=1<<i|n<<a|r,cn=e}function Wd(e){e.return!==null&&(cr(e,1),kg(e,1,0))}function Gd(e){for(;e===fo;)fo=ta[--sa],ta[sa]=null,po=ta[--sa],ta[sa]=null;for(;e===Ar;)Ar=hs[--fs],hs[fs]=null,cn=hs[--fs],hs[fs]=null,on=hs[--fs],hs[fs]=null}var ls=null,is=null,Ve=!1,Es=null;function Cg(e,t){var n=xs(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 yf(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,ls=e,is=Wn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ls=e,is=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Ar!==null?{id:on,overflow:cn}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=xs(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ls=e,is=null,!0):!1;default:return!1}}function Mu(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Tu(e){if(Ve){var t=is;if(t){var n=t;if(!yf(e,t)){if(Mu(e))throw Error(Z(418));t=Wn(n.nextSibling);var r=ls;t&&yf(e,t)?Cg(r,n):(e.flags=e.flags&-4097|2,Ve=!1,ls=e)}}else{if(Mu(e))throw Error(Z(418));e.flags=e.flags&-4097|2,Ve=!1,ls=e}}}function vf(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ls=e}function Dl(e){if(e!==ls)return!1;if(!Ve)return vf(e),Ve=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Eu(e.type,e.memoizedProps)),t&&(t=is)){if(Mu(e))throw Eg(),Error(Z(418));for(;t;)Cg(e,t),t=Wn(t.nextSibling)}if(vf(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Z(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){is=Wn(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}is=null}}else is=ls?Wn(e.stateNode.nextSibling):null;return!0}function Eg(){for(var e=is;e;)e=Wn(e.nextSibling)}function Pa(){is=ls=null,Ve=!1}function Zd(e){Es===null?Es=[e]:Es.push(e)}var Hj=bn.ReactCurrentBatchConfig;function Ya(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(Z(309));var r=n.stateNode}if(!r)throw Error(Z(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(Z(284));if(!n._owner)throw Error(Z(290,e))}return e}function Pl(e,t){throw e=Object.prototype.toString.call(t),Error(Z(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function jf(e){var t=e._init;return t(e._payload)}function Dg(e){function t(v,g){if(e){var x=v.deletions;x===null?(v.deletions=[g],v.flags|=16):x.push(g)}}function n(v,g){if(!e)return null;for(;g!==null;)t(v,g),g=g.sibling;return null}function r(v,g){for(v=new Map;g!==null;)g.key!==null?v.set(g.key,g):v.set(g.index,g),g=g.sibling;return v}function a(v,g){return v=Xn(v,g),v.index=0,v.sibling=null,v}function i(v,g,x){return v.index=x,e?(x=v.alternate,x!==null?(x=x.index,x<g?(v.flags|=2,g):x):(v.flags|=2,g)):(v.flags|=1048576,g)}function l(v){return e&&v.alternate===null&&(v.flags|=2),v}function o(v,g,x,j){return g===null||g.tag!==6?(g=qc(x,v.mode,j),g.return=v,g):(g=a(g,x),g.return=v,g)}function c(v,g,x,j){var k=x.type;return k===Gr?d(v,g,x.props.children,j,x.key):g!==null&&(g.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===En&&jf(k)===g.type)?(j=a(g,x.props),j.ref=Ya(v,g,x),j.return=v,j):(j=Gl(x.type,x.key,x.props,null,v.mode,j),j.ref=Ya(v,g,x),j.return=v,j)}function u(v,g,x,j){return g===null||g.tag!==4||g.stateNode.containerInfo!==x.containerInfo||g.stateNode.implementation!==x.implementation?(g=Vc(x,v.mode,j),g.return=v,g):(g=a(g,x.children||[]),g.return=v,g)}function d(v,g,x,j,k){return g===null||g.tag!==7?(g=Er(x,v.mode,j,k),g.return=v,g):(g=a(g,x),g.return=v,g)}function h(v,g,x){if(typeof g=="string"&&g!==""||typeof g=="number")return g=qc(""+g,v.mode,x),g.return=v,g;if(typeof g=="object"&&g!==null){switch(g.$$typeof){case yl:return x=Gl(g.type,g.key,g.props,null,v.mode,x),x.ref=Ya(v,null,g),x.return=v,x;case Wr:return g=Vc(g,v.mode,x),g.return=v,g;case En:var j=g._init;return h(v,j(g._payload),x)}if(ai(g)||Wa(g))return g=Er(g,v.mode,x,null),g.return=v,g;Pl(v,g)}return null}function p(v,g,x,j){var k=g!==null?g.key:null;if(typeof x=="string"&&x!==""||typeof x=="number")return k!==null?null:o(v,g,""+x,j);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case yl:return x.key===k?c(v,g,x,j):null;case Wr:return x.key===k?u(v,g,x,j):null;case En:return k=x._init,p(v,g,k(x._payload),j)}if(ai(x)||Wa(x))return k!==null?null:d(v,g,x,j,null);Pl(v,x)}return null}function m(v,g,x,j,k){if(typeof j=="string"&&j!==""||typeof j=="number")return v=v.get(x)||null,o(g,v,""+j,k);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case yl:return v=v.get(j.key===null?x:j.key)||null,c(g,v,j,k);case Wr:return v=v.get(j.key===null?x:j.key)||null,u(g,v,j,k);case En:var F=j._init;return m(v,g,x,F(j._payload),k)}if(ai(j)||Wa(j))return v=v.get(x)||null,d(g,v,j,k,null);Pl(g,j)}return null}function f(v,g,x,j){for(var k=null,F=null,E=g,S=g=0,P=null;E!==null&&S<x.length;S++){E.index>S?(P=E,E=null):P=E.sibling;var A=p(v,E,x[S],j);if(A===null){E===null&&(E=P);break}e&&E&&A.alternate===null&&t(v,E),g=i(A,g,S),F===null?k=A:F.sibling=A,F=A,E=P}if(S===x.length)return n(v,E),Ve&&cr(v,S),k;if(E===null){for(;S<x.length;S++)E=h(v,x[S],j),E!==null&&(g=i(E,g,S),F===null?k=E:F.sibling=E,F=E);return Ve&&cr(v,S),k}for(E=r(v,E);S<x.length;S++)P=m(E,v,S,x[S],j),P!==null&&(e&&P.alternate!==null&&E.delete(P.key===null?S:P.key),g=i(P,g,S),F===null?k=P:F.sibling=P,F=P);return e&&E.forEach(function(_){return t(v,_)}),Ve&&cr(v,S),k}function y(v,g,x,j){var k=Wa(x);if(typeof k!="function")throw Error(Z(150));if(x=k.call(x),x==null)throw Error(Z(151));for(var F=k=null,E=g,S=g=0,P=null,A=x.next();E!==null&&!A.done;S++,A=x.next()){E.index>S?(P=E,E=null):P=E.sibling;var _=p(v,E,A.value,j);if(_===null){E===null&&(E=P);break}e&&E&&_.alternate===null&&t(v,E),g=i(_,g,S),F===null?k=_:F.sibling=_,F=_,E=P}if(A.done)return n(v,E),Ve&&cr(v,S),k;if(E===null){for(;!A.done;S++,A=x.next())A=h(v,A.value,j),A!==null&&(g=i(A,g,S),F===null?k=A:F.sibling=A,F=A);return Ve&&cr(v,S),k}for(E=r(v,E);!A.done;S++,A=x.next())A=m(E,v,S,A.value,j),A!==null&&(e&&A.alternate!==null&&E.delete(A.key===null?S:A.key),g=i(A,g,S),F===null?k=A:F.sibling=A,F=A);return e&&E.forEach(function(L){return t(v,L)}),Ve&&cr(v,S),k}function N(v,g,x,j){if(typeof x=="object"&&x!==null&&x.type===Gr&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case yl:e:{for(var k=x.key,F=g;F!==null;){if(F.key===k){if(k=x.type,k===Gr){if(F.tag===7){n(v,F.sibling),g=a(F,x.props.children),g.return=v,v=g;break e}}else if(F.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===En&&jf(k)===F.type){n(v,F.sibling),g=a(F,x.props),g.ref=Ya(v,F,x),g.return=v,v=g;break e}n(v,F);break}else t(v,F);F=F.sibling}x.type===Gr?(g=Er(x.props.children,v.mode,j,x.key),g.return=v,v=g):(j=Gl(x.type,x.key,x.props,null,v.mode,j),j.ref=Ya(v,g,x),j.return=v,v=j)}return l(v);case Wr:e:{for(F=x.key;g!==null;){if(g.key===F)if(g.tag===4&&g.stateNode.containerInfo===x.containerInfo&&g.stateNode.implementation===x.implementation){n(v,g.sibling),g=a(g,x.children||[]),g.return=v,v=g;break e}else{n(v,g);break}else t(v,g);g=g.sibling}g=Vc(x,v.mode,j),g.return=v,v=g}return l(v);case En:return F=x._init,N(v,g,F(x._payload),j)}if(ai(x))return f(v,g,x,j);if(Wa(x))return y(v,g,x,j);Pl(v,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,g!==null&&g.tag===6?(n(v,g.sibling),g=a(g,x),g.return=v,v=g):(n(v,g),g=qc(x,v.mode,j),g.return=v,v=g),l(v)):n(v,g)}return N}var Aa=Dg(!0),Pg=Dg(!1),xo=ar(null),go=null,na=null,Jd=null;function Xd(){Jd=na=go=null}function Yd(e){var t=xo.current;Ue(xo),e._currentValue=t}function Fu(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 da(e,t){go=e,Jd=na=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Jt=!0),e.firstContext=null)}function vs(e){var t=e._currentValue;if(Jd!==e)if(e={context:e,memoizedValue:t,next:null},na===null){if(go===null)throw Error(Z(308));na=e,go.dependencies={lanes:0,firstContext:e}}else na=na.next=e;return t}var mr=null;function em(e){mr===null?mr=[e]:mr.push(e)}function Ag(e,t,n,r){var a=t.interleaved;return a===null?(n.next=n,em(t)):(n.next=a.next,a.next=n),t.interleaved=n,xn(e,r)}function xn(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 Dn=!1;function tm(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Mg(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 dn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Gn(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,xn(e,n)}return a=r.interleaved,a===null?(t.next=t,em(r)):(t.next=a.next,a.next=t),r.interleaved=t,xn(e,n)}function Kl(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,$d(e,n)}}function bf(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 yo(e,t,n,r){var a=e.updateQueue;Dn=!1;var i=a.firstBaseUpdate,l=a.lastBaseUpdate,o=a.shared.pending;if(o!==null){a.shared.pending=null;var c=o,u=c.next;c.next=null,l===null?i=u:l.next=u,l=c;var d=e.alternate;d!==null&&(d=d.updateQueue,o=d.lastBaseUpdate,o!==l&&(o===null?d.firstBaseUpdate=u:o.next=u,d.lastBaseUpdate=c))}if(i!==null){var h=a.baseState;l=0,d=u=c=null,o=i;do{var p=o.lane,m=o.eventTime;if((r&p)===p){d!==null&&(d=d.next={eventTime:m,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var f=e,y=o;switch(p=t,m=n,y.tag){case 1:if(f=y.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=y.payload,p=typeof f=="function"?f.call(m,h,p):f,p==null)break e;h=Ze({},h,p);break e;case 2:Dn=!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},d===null?(u=d=m,c=h):d=d.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(d===null&&(c=h),a.baseState=c,a.firstBaseUpdate=u,a.lastBaseUpdate=d,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);Tr|=l,e.lanes=l,e.memoizedState=h}}function Nf(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(Z(191,a));a.call(r)}}}var nl={},Qs=ar(nl),Fi=ar(nl),Ii=ar(nl);function hr(e){if(e===nl)throw Error(Z(174));return e}function sm(e,t){switch(Oe(Ii,t),Oe(Fi,e),Oe(Qs,nl),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:hu(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=hu(t,e)}Ue(Qs),Oe(Qs,t)}function Ma(){Ue(Qs),Ue(Fi),Ue(Ii)}function Tg(e){hr(Ii.current);var t=hr(Qs.current),n=hu(t,e.type);t!==n&&(Oe(Fi,e),Oe(Qs,n))}function nm(e){Fi.current===e&&(Ue(Qs),Ue(Fi))}var He=ar(0);function vo(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 zc=[];function rm(){for(var e=0;e<zc.length;e++)zc[e]._workInProgressVersionPrimary=null;zc.length=0}var ql=bn.ReactCurrentDispatcher,_c=bn.ReactCurrentBatchConfig,Mr=0,We=null,ht=null,jt=null,jo=!1,pi=!1,Li=0,Wj=0;function Mt(){throw Error(Z(321))}function am(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Is(e[n],t[n]))return!1;return!0}function im(e,t,n,r,a,i){if(Mr=i,We=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,ql.current=e===null||e.memoizedState===null?Xj:Yj,e=n(r,a),pi){i=0;do{if(pi=!1,Li=0,25<=i)throw Error(Z(301));i+=1,jt=ht=null,t.updateQueue=null,ql.current=eb,e=n(r,a)}while(pi)}if(ql.current=bo,t=ht!==null&&ht.next!==null,Mr=0,jt=ht=We=null,jo=!1,t)throw Error(Z(300));return e}function lm(){var e=Li!==0;return Li=0,e}function zs(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return jt===null?We.memoizedState=jt=e:jt=jt.next=e,jt}function js(){if(ht===null){var e=We.alternate;e=e!==null?e.memoizedState:null}else e=ht.next;var t=jt===null?We.memoizedState:jt.next;if(t!==null)jt=t,ht=e;else{if(e===null)throw Error(Z(310));ht=e,e={memoizedState:ht.memoizedState,baseState:ht.baseState,baseQueue:ht.baseQueue,queue:ht.queue,next:null},jt===null?We.memoizedState=jt=e:jt=jt.next=e}return jt}function Ri(e,t){return typeof t=="function"?t(e):t}function $c(e){var t=js(),n=t.queue;if(n===null)throw Error(Z(311));n.lastRenderedReducer=e;var r=ht,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,u=i;do{var d=u.lane;if((Mr&d)===d)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var h={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(o=c=h,l=r):c=c.next=h,We.lanes|=d,Tr|=d}u=u.next}while(u!==null&&u!==i);c===null?l=r:c.next=o,Is(r,t.memoizedState)||(Jt=!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,We.lanes|=i,Tr|=i,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Uc(e){var t=js(),n=t.queue;if(n===null)throw Error(Z(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);Is(i,t.memoizedState)||(Jt=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function Fg(){}function Ig(e,t){var n=We,r=js(),a=t(),i=!Is(r.memoizedState,a);if(i&&(r.memoizedState=a,Jt=!0),r=r.queue,om(Og.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||jt!==null&&jt.memoizedState.tag&1){if(n.flags|=2048,Oi(9,Rg.bind(null,n,r,a,t),void 0,null),wt===null)throw Error(Z(349));Mr&30||Lg(n,t,a)}return a}function Lg(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=We.updateQueue,t===null?(t={lastEffect:null,stores:null},We.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Rg(e,t,n,r){t.value=n,t.getSnapshot=r,zg(t)&&_g(e)}function Og(e,t,n){return n(function(){zg(t)&&_g(e)})}function zg(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Is(e,n)}catch{return!0}}function _g(e){var t=xn(e,1);t!==null&&Fs(t,e,1,-1)}function wf(e){var t=zs();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ri,lastRenderedState:e},t.queue=e,e=e.dispatch=Jj.bind(null,We,e),[t.memoizedState,e]}function Oi(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=We.updateQueue,t===null?(t={lastEffect:null,stores:null},We.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 $g(){return js().memoizedState}function Vl(e,t,n,r){var a=zs();We.flags|=e,a.memoizedState=Oi(1|t,n,void 0,r===void 0?null:r)}function Vo(e,t,n,r){var a=js();r=r===void 0?null:r;var i=void 0;if(ht!==null){var l=ht.memoizedState;if(i=l.destroy,r!==null&&am(r,l.deps)){a.memoizedState=Oi(t,n,i,r);return}}We.flags|=e,a.memoizedState=Oi(1|t,n,i,r)}function Sf(e,t){return Vl(8390656,8,e,t)}function om(e,t){return Vo(2048,8,e,t)}function Ug(e,t){return Vo(4,2,e,t)}function Bg(e,t){return Vo(4,4,e,t)}function Kg(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 qg(e,t,n){return n=n!=null?n.concat([e]):null,Vo(4,4,Kg.bind(null,t,e),n)}function cm(){}function Vg(e,t){var n=js();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&am(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Qg(e,t){var n=js();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&am(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Hg(e,t,n){return Mr&21?(Is(n,t)||(n=Xx(),We.lanes|=n,Tr|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Jt=!0),e.memoizedState=n)}function Gj(e,t){var n=Ie;Ie=n!==0&&4>n?n:4,e(!0);var r=_c.transition;_c.transition={};try{e(!1),t()}finally{Ie=n,_c.transition=r}}function Wg(){return js().memoizedState}function Zj(e,t,n){var r=Jn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Gg(e))Zg(t,n);else if(n=Ag(e,t,n,r),n!==null){var a=Bt();Fs(n,e,r,a),Jg(n,t,r)}}function Jj(e,t,n){var r=Jn(e),a={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Gg(e))Zg(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,Is(o,l)){var c=t.interleaved;c===null?(a.next=a,em(t)):(a.next=c.next,c.next=a),t.interleaved=a;return}}catch{}finally{}n=Ag(e,t,a,r),n!==null&&(a=Bt(),Fs(n,e,r,a),Jg(n,t,r))}}function Gg(e){var t=e.alternate;return e===We||t!==null&&t===We}function Zg(e,t){pi=jo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Jg(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,$d(e,n)}}var bo={readContext:vs,useCallback:Mt,useContext:Mt,useEffect:Mt,useImperativeHandle:Mt,useInsertionEffect:Mt,useLayoutEffect:Mt,useMemo:Mt,useReducer:Mt,useRef:Mt,useState:Mt,useDebugValue:Mt,useDeferredValue:Mt,useTransition:Mt,useMutableSource:Mt,useSyncExternalStore:Mt,useId:Mt,unstable_isNewReconciler:!1},Xj={readContext:vs,useCallback:function(e,t){return zs().memoizedState=[e,t===void 0?null:t],e},useContext:vs,useEffect:Sf,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Vl(4194308,4,Kg.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Vl(4194308,4,e,t)},useInsertionEffect:function(e,t){return Vl(4,2,e,t)},useMemo:function(e,t){var n=zs();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=zs();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Zj.bind(null,We,e),[r.memoizedState,e]},useRef:function(e){var t=zs();return e={current:e},t.memoizedState=e},useState:wf,useDebugValue:cm,useDeferredValue:function(e){return zs().memoizedState=e},useTransition:function(){var e=wf(!1),t=e[0];return e=Gj.bind(null,e[1]),zs().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=We,a=zs();if(Ve){if(n===void 0)throw Error(Z(407));n=n()}else{if(n=t(),wt===null)throw Error(Z(349));Mr&30||Lg(r,t,n)}a.memoizedState=n;var i={value:n,getSnapshot:t};return a.queue=i,Sf(Og.bind(null,r,i,e),[e]),r.flags|=2048,Oi(9,Rg.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=zs(),t=wt.identifierPrefix;if(Ve){var n=cn,r=on;n=(r&~(1<<32-Ts(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Li++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=Wj++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Yj={readContext:vs,useCallback:Vg,useContext:vs,useEffect:om,useImperativeHandle:qg,useInsertionEffect:Ug,useLayoutEffect:Bg,useMemo:Qg,useReducer:$c,useRef:$g,useState:function(){return $c(Ri)},useDebugValue:cm,useDeferredValue:function(e){var t=js();return Hg(t,ht.memoizedState,e)},useTransition:function(){var e=$c(Ri)[0],t=js().memoizedState;return[e,t]},useMutableSource:Fg,useSyncExternalStore:Ig,useId:Wg,unstable_isNewReconciler:!1},eb={readContext:vs,useCallback:Vg,useContext:vs,useEffect:om,useImperativeHandle:qg,useInsertionEffect:Ug,useLayoutEffect:Bg,useMemo:Qg,useReducer:Uc,useRef:$g,useState:function(){return Uc(Ri)},useDebugValue:cm,useDeferredValue:function(e){var t=js();return ht===null?t.memoizedState=e:Hg(t,ht.memoizedState,e)},useTransition:function(){var e=Uc(Ri)[0],t=js().memoizedState;return[e,t]},useMutableSource:Fg,useSyncExternalStore:Ig,useId:Wg,unstable_isNewReconciler:!1};function ws(e,t){if(e&&e.defaultProps){t=Ze({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Iu(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Ze({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Qo={isMounted:function(e){return(e=e._reactInternals)?_r(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Bt(),a=Jn(e),i=dn(r,a);i.payload=t,n!=null&&(i.callback=n),t=Gn(e,i,a),t!==null&&(Fs(t,e,a,r),Kl(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Bt(),a=Jn(e),i=dn(r,a);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Gn(e,i,a),t!==null&&(Fs(t,e,a,r),Kl(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Bt(),r=Jn(e),a=dn(n,r);a.tag=2,t!=null&&(a.callback=t),t=Gn(e,a,r),t!==null&&(Fs(t,e,r,n),Kl(t,e,r))}};function kf(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?!Pi(n,r)||!Pi(a,i):!0}function Xg(e,t,n){var r=!1,a=sr,i=t.contextType;return typeof i=="object"&&i!==null?i=vs(i):(a=Yt(t)?Pr:Lt.current,r=t.contextTypes,i=(r=r!=null)?Da(e,a):sr),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Qo,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=i),t}function Cf(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&&Qo.enqueueReplaceState(t,t.state,null)}function Lu(e,t,n,r){var a=e.stateNode;a.props=n,a.state=e.memoizedState,a.refs={},tm(e);var i=t.contextType;typeof i=="object"&&i!==null?a.context=vs(i):(i=Yt(t)?Pr:Lt.current,a.context=Da(e,i)),a.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(Iu(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&&Qo.enqueueReplaceState(a,a.state,null),yo(e,n,a,r),a.state=e.memoizedState),typeof a.componentDidMount=="function"&&(e.flags|=4194308)}function Ta(e,t){try{var n="",r=t;do n+=Dv(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 Bc(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Ru(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var tb=typeof WeakMap=="function"?WeakMap:Map;function Yg(e,t,n){n=dn(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){wo||(wo=!0,Qu=r),Ru(e,t)},n}function ey(e,t,n){n=dn(-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(){Ru(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){Ru(e,t),typeof r!="function"&&(Zn===null?Zn=new Set([this]):Zn.add(this));var l=t.stack;this.componentDidCatch(t.value,{componentStack:l!==null?l:""})}),n}function Ef(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new tb;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=pb.bind(null,e,t,n),t.then(e,e))}function Df(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 Pf(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=dn(-1,1),t.tag=2,Gn(n,t,1))),n.lanes|=1),e)}var sb=bn.ReactCurrentOwner,Jt=!1;function $t(e,t,n,r){t.child=e===null?Pg(t,null,n,r):Aa(t,e.child,n,r)}function Af(e,t,n,r,a){n=n.render;var i=t.ref;return da(t,a),r=im(e,t,n,r,i,a),n=lm(),e!==null&&!Jt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,gn(e,t,a)):(Ve&&n&&Wd(t),t.flags|=1,$t(e,t,r,a),t.child)}function Mf(e,t,n,r,a){if(e===null){var i=n.type;return typeof i=="function"&&!gm(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=Gl(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:Pi,n(l,r)&&e.ref===t.ref)return gn(e,t,a)}return t.flags|=1,e=Xn(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(Pi(i,r)&&e.ref===t.ref)if(Jt=!1,t.pendingProps=r=i,(e.lanes&a)!==0)e.flags&131072&&(Jt=!0);else return t.lanes=e.lanes,gn(e,t,a)}return Ou(e,t,n,r,a)}function sy(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},Oe(aa,ns),ns|=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,Oe(aa,ns),ns|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,Oe(aa,ns),ns|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,Oe(aa,ns),ns|=r;return $t(e,t,a,n),t.child}function ny(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Ou(e,t,n,r,a){var i=Yt(n)?Pr:Lt.current;return i=Da(t,i),da(t,a),n=im(e,t,n,r,i,a),r=lm(),e!==null&&!Jt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,gn(e,t,a)):(Ve&&r&&Wd(t),t.flags|=1,$t(e,t,n,a),t.child)}function Tf(e,t,n,r,a){if(Yt(n)){var i=!0;ho(t)}else i=!1;if(da(t,a),t.stateNode===null)Ql(e,t),Xg(t,n,r),Lu(t,n,r,a),r=!0;else if(e===null){var l=t.stateNode,o=t.memoizedProps;l.props=o;var c=l.context,u=n.contextType;typeof u=="object"&&u!==null?u=vs(u):(u=Yt(n)?Pr:Lt.current,u=Da(t,u));var d=n.getDerivedStateFromProps,h=typeof d=="function"||typeof l.getSnapshotBeforeUpdate=="function";h||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(o!==r||c!==u)&&Cf(t,l,r,u),Dn=!1;var p=t.memoizedState;l.state=p,yo(t,r,l,a),c=t.memoizedState,o!==r||p!==c||Xt.current||Dn?(typeof d=="function"&&(Iu(t,n,d,r),c=t.memoizedState),(o=Dn||kf(t,n,o,r,p,c,u))?(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=u,r=o):(typeof l.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{l=t.stateNode,Mg(e,t),o=t.memoizedProps,u=t.type===t.elementType?o:ws(t.type,o),l.props=u,h=t.pendingProps,p=l.context,c=n.contextType,typeof c=="object"&&c!==null?c=vs(c):(c=Yt(n)?Pr:Lt.current,c=Da(t,c));var m=n.getDerivedStateFromProps;(d=typeof m=="function"||typeof l.getSnapshotBeforeUpdate=="function")||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(o!==h||p!==c)&&Cf(t,l,r,c),Dn=!1,p=t.memoizedState,l.state=p,yo(t,r,l,a);var f=t.memoizedState;o!==h||p!==f||Xt.current||Dn?(typeof m=="function"&&(Iu(t,n,m,r),f=t.memoizedState),(u=Dn||kf(t,n,u,r,p,f,c)||!1)?(d||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=u):(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 zu(e,t,n,r,i,a)}function zu(e,t,n,r,a,i){ny(e,t);var l=(t.flags&128)!==0;if(!r&&!l)return a&&gf(t,n,!1),gn(e,t,i);r=t.stateNode,sb.current=t;var o=l&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&l?(t.child=Aa(t,e.child,null,i),t.child=Aa(t,null,o,i)):$t(e,t,o,i),t.memoizedState=r.state,a&&gf(t,n,!0),t.child}function ry(e){var t=e.stateNode;t.pendingContext?xf(e,t.pendingContext,t.pendingContext!==t.context):t.context&&xf(e,t.context,!1),sm(e,t.containerInfo)}function Ff(e,t,n,r,a){return Pa(),Zd(a),t.flags|=256,$t(e,t,n,r),t.child}var _u={dehydrated:null,treeContext:null,retryLane:0};function $u(e){return{baseLanes:e,cachePool:null,transitions:null}}function ay(e,t,n){var r=t.pendingProps,a=He.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),Oe(He,a&1),e===null)return Tu(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=Go(l,r,0,null),e=Er(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=$u(n),t.memoizedState=_u,e):um(t,l));if(a=e.memoizedState,a!==null&&(o=a.dehydrated,o!==null))return nb(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=Xn(a,c),r.subtreeFlags=a.subtreeFlags&14680064),o!==null?i=Xn(o,i):(i=Er(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?$u(n):{baseLanes:l.baseLanes|n,cachePool:null,transitions:l.transitions},i.memoizedState=l,i.childLanes=e.childLanes&~n,t.memoizedState=_u,r}return i=e.child,e=i.sibling,r=Xn(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 um(e,t){return t=Go({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Al(e,t,n,r){return r!==null&&Zd(r),Aa(t,e.child,null,n),e=um(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function nb(e,t,n,r,a,i,l){if(n)return t.flags&256?(t.flags&=-257,r=Bc(Error(Z(422))),Al(e,t,l,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,a=t.mode,r=Go({mode:"visible",children:r.children},a,0,null),i=Er(i,a,l,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&Aa(t,e.child,null,l),t.child.memoizedState=$u(l),t.memoizedState=_u,i);if(!(t.mode&1))return Al(e,t,l,null);if(a.data==="$!"){if(r=a.nextSibling&&a.nextSibling.dataset,r)var o=r.dgst;return r=o,i=Error(Z(419)),r=Bc(i,r,void 0),Al(e,t,l,r)}if(o=(l&e.childLanes)!==0,Jt||o){if(r=wt,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,xn(e,a),Fs(r,e,a,-1))}return xm(),r=Bc(Error(Z(421))),Al(e,t,l,r)}return a.data==="$?"?(t.flags|=128,t.child=e.child,t=xb.bind(null,e),a._reactRetry=t,null):(e=i.treeContext,is=Wn(a.nextSibling),ls=t,Ve=!0,Es=null,e!==null&&(hs[fs++]=on,hs[fs++]=cn,hs[fs++]=Ar,on=e.id,cn=e.overflow,Ar=t),t=um(t,r.children),t.flags|=4096,t)}function If(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Fu(e.return,t,n)}function Kc(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 iy(e,t,n){var r=t.pendingProps,a=r.revealOrder,i=r.tail;if($t(e,t,r.children,n),r=He.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&&If(e,n,t);else if(e.tag===19)If(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(Oe(He,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&&vo(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),Kc(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&&vo(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}Kc(t,!0,n,null,i);break;case"together":Kc(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Ql(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function gn(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Tr|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Z(153));if(t.child!==null){for(e=t.child,n=Xn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Xn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function rb(e,t,n){switch(t.tag){case 3:ry(t),Pa();break;case 5:Tg(t);break;case 1:Yt(t.type)&&ho(t);break;case 4:sm(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,a=t.memoizedProps.value;Oe(xo,r._currentValue),r._currentValue=a;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Oe(He,He.current&1),t.flags|=128,null):n&t.child.childLanes?ay(e,t,n):(Oe(He,He.current&1),e=gn(e,t,n),e!==null?e.sibling:null);Oe(He,He.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return iy(e,t,n);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),Oe(He,He.current),r)break;return null;case 22:case 23:return t.lanes=0,sy(e,t,n)}return gn(e,t,n)}var ly,Uu,oy,cy;ly=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}};Uu=function(){};oy=function(e,t,n,r){var a=e.memoizedProps;if(a!==r){e=t.stateNode,hr(Qs.current);var i=null;switch(n){case"input":a=cu(e,a),r=cu(e,r),i=[];break;case"select":a=Ze({},a,{value:void 0}),r=Ze({},r,{value:void 0}),i=[];break;case"textarea":a=mu(e,a),r=mu(e,r),i=[];break;default:typeof a.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=uo)}fu(n,r);var l;n=null;for(u in a)if(!r.hasOwnProperty(u)&&a.hasOwnProperty(u)&&a[u]!=null)if(u==="style"){var o=a[u];for(l in o)o.hasOwnProperty(l)&&(n||(n={}),n[l]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(Ni.hasOwnProperty(u)?i||(i=[]):(i=i||[]).push(u,null));for(u in r){var c=r[u];if(o=a!=null?a[u]:void 0,r.hasOwnProperty(u)&&c!==o&&(c!=null||o!=null))if(u==="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(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,o=o?o.__html:void 0,c!=null&&o!==c&&(i=i||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(Ni.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&_e("scroll",e),i||o===c||(i=[])):(i=i||[]).push(u,c))}n&&(i=i||[]).push("style",n);var u=i;(t.updateQueue=u)&&(t.flags|=4)}};cy=function(e,t,n,r){n!==r&&(t.flags|=4)};function ei(e,t){if(!Ve)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 Tt(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 ab(e,t,n){var r=t.pendingProps;switch(Gd(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Tt(t),null;case 1:return Yt(t.type)&&mo(),Tt(t),null;case 3:return r=t.stateNode,Ma(),Ue(Xt),Ue(Lt),rm(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Dl(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Es!==null&&(Gu(Es),Es=null))),Uu(e,t),Tt(t),null;case 5:nm(t);var a=hr(Ii.current);if(n=t.type,e!==null&&t.stateNode!=null)oy(e,t,n,r,a),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Z(166));return Tt(t),null}if(e=hr(Qs.current),Dl(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[Ks]=t,r[Ti]=i,e=(t.mode&1)!==0,n){case"dialog":_e("cancel",r),_e("close",r);break;case"iframe":case"object":case"embed":_e("load",r);break;case"video":case"audio":for(a=0;a<li.length;a++)_e(li[a],r);break;case"source":_e("error",r);break;case"img":case"image":case"link":_e("error",r),_e("load",r);break;case"details":_e("toggle",r);break;case"input":Bh(r,i),_e("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},_e("invalid",r);break;case"textarea":qh(r,i),_e("invalid",r)}fu(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&&El(r.textContent,o,e),a=["children",o]):typeof o=="number"&&r.textContent!==""+o&&(i.suppressHydrationWarning!==!0&&El(r.textContent,o,e),a=["children",""+o]):Ni.hasOwnProperty(l)&&o!=null&&l==="onScroll"&&_e("scroll",r)}switch(n){case"input":vl(r),Kh(r,i,!0);break;case"textarea":vl(r),Vh(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=uo)}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=Ox(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[Ks]=t,e[Ti]=r,ly(e,t,!1,!1),t.stateNode=e;e:{switch(l=pu(n,r),n){case"dialog":_e("cancel",e),_e("close",e),a=r;break;case"iframe":case"object":case"embed":_e("load",e),a=r;break;case"video":case"audio":for(a=0;a<li.length;a++)_e(li[a],e);a=r;break;case"source":_e("error",e),a=r;break;case"img":case"image":case"link":_e("error",e),_e("load",e),a=r;break;case"details":_e("toggle",e),a=r;break;case"input":Bh(e,r),a=cu(e,r),_e("invalid",e);break;case"option":a=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},a=Ze({},r,{value:void 0}),_e("invalid",e);break;case"textarea":qh(e,r),a=mu(e,r),_e("invalid",e);break;default:a=r}fu(n,a),o=a;for(i in o)if(o.hasOwnProperty(i)){var c=o[i];i==="style"?$x(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&zx(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&wi(e,c):typeof c=="number"&&wi(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Ni.hasOwnProperty(i)?c!=null&&i==="onScroll"&&_e("scroll",e):c!=null&&Id(e,i,c,l))}switch(n){case"input":vl(e),Kh(e,r,!1);break;case"textarea":vl(e),Vh(e);break;case"option":r.value!=null&&e.setAttribute("value",""+tr(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?la(e,!!r.multiple,i,!1):r.defaultValue!=null&&la(e,!!r.multiple,r.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=uo)}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 Tt(t),null;case 6:if(e&&t.stateNode!=null)cy(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Z(166));if(n=hr(Ii.current),hr(Qs.current),Dl(t)){if(r=t.stateNode,n=t.memoizedProps,r[Ks]=t,(i=r.nodeValue!==n)&&(e=ls,e!==null))switch(e.tag){case 3:El(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&El(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Ks]=t,t.stateNode=r}return Tt(t),null;case 13:if(Ue(He),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Ve&&is!==null&&t.mode&1&&!(t.flags&128))Eg(),Pa(),t.flags|=98560,i=!1;else if(i=Dl(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(Z(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(Z(317));i[Ks]=t}else Pa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Tt(t),i=!1}else Es!==null&&(Gu(Es),Es=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||He.current&1?xt===0&&(xt=3):xm())),t.updateQueue!==null&&(t.flags|=4),Tt(t),null);case 4:return Ma(),Uu(e,t),e===null&&Ai(t.stateNode.containerInfo),Tt(t),null;case 10:return Yd(t.type._context),Tt(t),null;case 17:return Yt(t.type)&&mo(),Tt(t),null;case 19:if(Ue(He),i=t.memoizedState,i===null)return Tt(t),null;if(r=(t.flags&128)!==0,l=i.rendering,l===null)if(r)ei(i,!1);else{if(xt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(l=vo(e),l!==null){for(t.flags|=128,ei(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 Oe(He,He.current&1|2),t.child}e=e.sibling}i.tail!==null&&it()>Fa&&(t.flags|=128,r=!0,ei(i,!1),t.lanes=4194304)}else{if(!r)if(e=vo(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ei(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!Ve)return Tt(t),null}else 2*it()-i.renderingStartTime>Fa&&n!==1073741824&&(t.flags|=128,r=!0,ei(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=it(),t.sibling=null,n=He.current,Oe(He,r?n&1|2:n&1),t):(Tt(t),null);case 22:case 23:return pm(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ns&1073741824&&(Tt(t),t.subtreeFlags&6&&(t.flags|=8192)):Tt(t),null;case 24:return null;case 25:return null}throw Error(Z(156,t.tag))}function ib(e,t){switch(Gd(t),t.tag){case 1:return Yt(t.type)&&mo(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ma(),Ue(Xt),Ue(Lt),rm(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return nm(t),null;case 13:if(Ue(He),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Z(340));Pa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ue(He),null;case 4:return Ma(),null;case 10:return Yd(t.type._context),null;case 22:case 23:return pm(),null;case 24:return null;default:return null}}var Ml=!1,Ft=!1,lb=typeof WeakSet=="function"?WeakSet:Set,ie=null;function ra(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){tt(e,t,r)}else n.current=null}function Bu(e,t,n){try{n()}catch(r){tt(e,t,r)}}var Lf=!1;function ob(e,t){if(ku=lo,e=fg(),Hd(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,u=0,d=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&&++u===a&&(o=l),p===i&&++d===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(Cu={focusedElem:e,selectionRange:n},lo=!1,ie=t;ie!==null;)if(t=ie,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,ie=e;else for(;ie!==null;){t=ie;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 y=f.memoizedProps,N=f.memoizedState,v=t.stateNode,g=v.getSnapshotBeforeUpdate(t.elementType===t.type?y:ws(t.type,y),N);v.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Z(163))}}catch(j){tt(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,ie=e;break}ie=t.return}return f=Lf,Lf=!1,f}function xi(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&&Bu(t,n,i)}a=a.next}while(a!==r)}}function Ho(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 Ku(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[Ks],delete t[Ti],delete t[Pu],delete t[qj],delete t[Vj])),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 dy(e){return e.tag===5||e.tag===3||e.tag===4}function Rf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||dy(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 qu(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=uo));else if(r!==4&&(e=e.child,e!==null))for(qu(e,t,n),e=e.sibling;e!==null;)qu(e,t,n),e=e.sibling}function Vu(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(Vu(e,t,n),e=e.sibling;e!==null;)Vu(e,t,n),e=e.sibling}var kt=null,Cs=!1;function kn(e,t,n){for(n=n.child;n!==null;)my(e,t,n),n=n.sibling}function my(e,t,n){if(Vs&&typeof Vs.onCommitFiberUnmount=="function")try{Vs.onCommitFiberUnmount(_o,n)}catch{}switch(n.tag){case 5:Ft||ra(n,t);case 6:var r=kt,a=Cs;kt=null,kn(e,t,n),kt=r,Cs=a,kt!==null&&(Cs?(e=kt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):kt.removeChild(n.stateNode));break;case 18:kt!==null&&(Cs?(e=kt,n=n.stateNode,e.nodeType===8?Rc(e.parentNode,n):e.nodeType===1&&Rc(e,n),Ei(e)):Rc(kt,n.stateNode));break;case 4:r=kt,a=Cs,kt=n.stateNode.containerInfo,Cs=!0,kn(e,t,n),kt=r,Cs=a;break;case 0:case 11:case 14:case 15:if(!Ft&&(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)&&Bu(n,t,l),a=a.next}while(a!==r)}kn(e,t,n);break;case 1:if(!Ft&&(ra(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){tt(n,t,o)}kn(e,t,n);break;case 21:kn(e,t,n);break;case 22:n.mode&1?(Ft=(r=Ft)||n.memoizedState!==null,kn(e,t,n),Ft=r):kn(e,t,n);break;default:kn(e,t,n)}}function Of(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new lb),t.forEach(function(r){var a=gb.bind(null,e,r);n.has(r)||(n.add(r),r.then(a,a))})}}function Ns(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:kt=o.stateNode,Cs=!1;break e;case 3:kt=o.stateNode.containerInfo,Cs=!0;break e;case 4:kt=o.stateNode.containerInfo,Cs=!0;break e}o=o.return}if(kt===null)throw Error(Z(160));my(i,l,a),kt=null,Cs=!1;var c=a.alternate;c!==null&&(c.return=null),a.return=null}catch(u){tt(a,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)hy(t,e),t=t.sibling}function hy(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Ns(t,e),Rs(e),r&4){try{xi(3,e,e.return),Ho(3,e)}catch(y){tt(e,e.return,y)}try{xi(5,e,e.return)}catch(y){tt(e,e.return,y)}}break;case 1:Ns(t,e),Rs(e),r&512&&n!==null&&ra(n,n.return);break;case 5:if(Ns(t,e),Rs(e),r&512&&n!==null&&ra(n,n.return),e.flags&32){var a=e.stateNode;try{wi(a,"")}catch(y){tt(e,e.return,y)}}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&&Lx(a,i),pu(o,l);var u=pu(o,i);for(l=0;l<c.length;l+=2){var d=c[l],h=c[l+1];d==="style"?$x(a,h):d==="dangerouslySetInnerHTML"?zx(a,h):d==="children"?wi(a,h):Id(a,d,h,u)}switch(o){case"input":uu(a,i);break;case"textarea":Rx(a,i);break;case"select":var p=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!i.multiple;var m=i.value;m!=null?la(a,!!i.multiple,m,!1):p!==!!i.multiple&&(i.defaultValue!=null?la(a,!!i.multiple,i.defaultValue,!0):la(a,!!i.multiple,i.multiple?[]:"",!1))}a[Ti]=i}catch(y){tt(e,e.return,y)}}break;case 6:if(Ns(t,e),Rs(e),r&4){if(e.stateNode===null)throw Error(Z(162));a=e.stateNode,i=e.memoizedProps;try{a.nodeValue=i}catch(y){tt(e,e.return,y)}}break;case 3:if(Ns(t,e),Rs(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Ei(t.containerInfo)}catch(y){tt(e,e.return,y)}break;case 4:Ns(t,e),Rs(e);break;case 13:Ns(t,e),Rs(e),a=e.child,a.flags&8192&&(i=a.memoizedState!==null,a.stateNode.isHidden=i,!i||a.alternate!==null&&a.alternate.memoizedState!==null||(hm=it())),r&4&&Of(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(Ft=(u=Ft)||d,Ns(t,e),Ft=u):Ns(t,e),Rs(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(ie=e,d=e.child;d!==null;){for(h=ie=d;ie!==null;){switch(p=ie,m=p.child,p.tag){case 0:case 11:case 14:case 15:xi(4,p,p.return);break;case 1:ra(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(y){tt(r,n,y)}}break;case 5:ra(p,p.return);break;case 22:if(p.memoizedState!==null){_f(h);continue}}m!==null?(m.return=p,ie=m):_f(h)}d=d.sibling}e:for(d=null,h=e;;){if(h.tag===5){if(d===null){d=h;try{a=h.stateNode,u?(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=_x("display",l))}catch(y){tt(e,e.return,y)}}}else if(h.tag===6){if(d===null)try{h.stateNode.nodeValue=u?"":h.memoizedProps}catch(y){tt(e,e.return,y)}}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;d===h&&(d=null),h=h.return}d===h&&(d=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:Ns(t,e),Rs(e),r&4&&Of(e);break;case 21:break;default:Ns(t,e),Rs(e)}}function Rs(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(dy(n)){var r=n;break e}n=n.return}throw Error(Z(160))}switch(r.tag){case 5:var a=r.stateNode;r.flags&32&&(wi(a,""),r.flags&=-33);var i=Rf(e);Vu(e,i,a);break;case 3:case 4:var l=r.stateNode.containerInfo,o=Rf(e);qu(e,o,l);break;default:throw Error(Z(161))}}catch(c){tt(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function cb(e,t,n){ie=e,fy(e)}function fy(e,t,n){for(var r=(e.mode&1)!==0;ie!==null;){var a=ie,i=a.child;if(a.tag===22&&r){var l=a.memoizedState!==null||Ml;if(!l){var o=a.alternate,c=o!==null&&o.memoizedState!==null||Ft;o=Ml;var u=Ft;if(Ml=l,(Ft=c)&&!u)for(ie=a;ie!==null;)l=ie,c=l.child,l.tag===22&&l.memoizedState!==null?$f(a):c!==null?(c.return=l,ie=c):$f(a);for(;i!==null;)ie=i,fy(i),i=i.sibling;ie=a,Ml=o,Ft=u}zf(e)}else a.subtreeFlags&8772&&i!==null?(i.return=a,ie=i):zf(e)}}function zf(e){for(;ie!==null;){var t=ie;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Ft||Ho(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Ft)if(n===null)r.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:ws(t.type,n.memoizedProps);r.componentDidUpdate(a,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Nf(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}Nf(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 u=t.alternate;if(u!==null){var d=u.memoizedState;if(d!==null){var h=d.dehydrated;h!==null&&Ei(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Z(163))}Ft||t.flags&512&&Ku(t)}catch(p){tt(t,t.return,p)}}if(t===e){ie=null;break}if(n=t.sibling,n!==null){n.return=t.return,ie=n;break}ie=t.return}}function _f(e){for(;ie!==null;){var t=ie;if(t===e){ie=null;break}var n=t.sibling;if(n!==null){n.return=t.return,ie=n;break}ie=t.return}}function $f(e){for(;ie!==null;){var t=ie;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Ho(4,t)}catch(c){tt(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var a=t.return;try{r.componentDidMount()}catch(c){tt(t,a,c)}}var i=t.return;try{Ku(t)}catch(c){tt(t,i,c)}break;case 5:var l=t.return;try{Ku(t)}catch(c){tt(t,l,c)}}}catch(c){tt(t,t.return,c)}if(t===e){ie=null;break}var o=t.sibling;if(o!==null){o.return=t.return,ie=o;break}ie=t.return}}var ub=Math.ceil,No=bn.ReactCurrentDispatcher,dm=bn.ReactCurrentOwner,ys=bn.ReactCurrentBatchConfig,Pe=0,wt=null,ut=null,Dt=0,ns=0,aa=ar(0),xt=0,zi=null,Tr=0,Wo=0,mm=0,gi=null,Zt=null,hm=0,Fa=1/0,en=null,wo=!1,Qu=null,Zn=null,Tl=!1,Kn=null,So=0,yi=0,Hu=null,Hl=-1,Wl=0;function Bt(){return Pe&6?it():Hl!==-1?Hl:Hl=it()}function Jn(e){return e.mode&1?Pe&2&&Dt!==0?Dt&-Dt:Hj.transition!==null?(Wl===0&&(Wl=Xx()),Wl):(e=Ie,e!==0||(e=window.event,e=e===void 0?16:ag(e.type)),e):1}function Fs(e,t,n,r){if(50<yi)throw yi=0,Hu=null,Error(Z(185));el(e,n,r),(!(Pe&2)||e!==wt)&&(e===wt&&(!(Pe&2)&&(Wo|=n),xt===4&&An(e,Dt)),es(e,r),n===1&&Pe===0&&!(t.mode&1)&&(Fa=it()+500,qo&&ir()))}function es(e,t){var n=e.callbackNode;Hv(e,t);var r=io(e,e===wt?Dt:0);if(r===0)n!==null&&Wh(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Wh(n),t===1)e.tag===0?Qj(Uf.bind(null,e)):Sg(Uf.bind(null,e)),Bj(function(){!(Pe&6)&&ir()}),n=null;else{switch(Yx(r)){case 1:n=_d;break;case 4:n=Zx;break;case 16:n=ao;break;case 536870912:n=Jx;break;default:n=ao}n=Ny(n,py.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function py(e,t){if(Hl=-1,Wl=0,Pe&6)throw Error(Z(327));var n=e.callbackNode;if(ma()&&e.callbackNode!==n)return null;var r=io(e,e===wt?Dt:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=ko(e,r);else{t=r;var a=Pe;Pe|=2;var i=gy();(wt!==e||Dt!==t)&&(en=null,Fa=it()+500,Cr(e,t));do try{hb();break}catch(o){xy(e,o)}while(!0);Xd(),No.current=i,Pe=a,ut!==null?t=0:(wt=null,Dt=0,t=xt)}if(t!==0){if(t===2&&(a=ju(e),a!==0&&(r=a,t=Wu(e,a))),t===1)throw n=zi,Cr(e,0),An(e,r),es(e,it()),n;if(t===6)An(e,r);else{if(a=e.current.alternate,!(r&30)&&!db(a)&&(t=ko(e,r),t===2&&(i=ju(e),i!==0&&(r=i,t=Wu(e,i))),t===1))throw n=zi,Cr(e,0),An(e,r),es(e,it()),n;switch(e.finishedWork=a,e.finishedLanes=r,t){case 0:case 1:throw Error(Z(345));case 2:ur(e,Zt,en);break;case 3:if(An(e,r),(r&130023424)===r&&(t=hm+500-it(),10<t)){if(io(e,0)!==0)break;if(a=e.suspendedLanes,(a&r)!==r){Bt(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=Du(ur.bind(null,e,Zt,en),t);break}ur(e,Zt,en);break;case 4:if(An(e,r),(r&4194240)===r)break;for(t=e.eventTimes,a=-1;0<r;){var l=31-Ts(r);i=1<<l,l=t[l],l>a&&(a=l),r&=~i}if(r=a,r=it()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*ub(r/1960))-r,10<r){e.timeoutHandle=Du(ur.bind(null,e,Zt,en),r);break}ur(e,Zt,en);break;case 5:ur(e,Zt,en);break;default:throw Error(Z(329))}}}return es(e,it()),e.callbackNode===n?py.bind(null,e):null}function Wu(e,t){var n=gi;return e.current.memoizedState.isDehydrated&&(Cr(e,t).flags|=256),e=ko(e,t),e!==2&&(t=Zt,Zt=n,t!==null&&Gu(t)),e}function Gu(e){Zt===null?Zt=e:Zt.push.apply(Zt,e)}function db(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(!Is(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 An(e,t){for(t&=~mm,t&=~Wo,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Ts(t),r=1<<n;e[n]=-1,t&=~r}}function Uf(e){if(Pe&6)throw Error(Z(327));ma();var t=io(e,0);if(!(t&1))return es(e,it()),null;var n=ko(e,t);if(e.tag!==0&&n===2){var r=ju(e);r!==0&&(t=r,n=Wu(e,r))}if(n===1)throw n=zi,Cr(e,0),An(e,t),es(e,it()),n;if(n===6)throw Error(Z(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,ur(e,Zt,en),es(e,it()),null}function fm(e,t){var n=Pe;Pe|=1;try{return e(t)}finally{Pe=n,Pe===0&&(Fa=it()+500,qo&&ir())}}function Fr(e){Kn!==null&&Kn.tag===0&&!(Pe&6)&&ma();var t=Pe;Pe|=1;var n=ys.transition,r=Ie;try{if(ys.transition=null,Ie=1,e)return e()}finally{Ie=r,ys.transition=n,Pe=t,!(Pe&6)&&ir()}}function pm(){ns=aa.current,Ue(aa)}function Cr(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Uj(n)),ut!==null)for(n=ut.return;n!==null;){var r=n;switch(Gd(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&mo();break;case 3:Ma(),Ue(Xt),Ue(Lt),rm();break;case 5:nm(r);break;case 4:Ma();break;case 13:Ue(He);break;case 19:Ue(He);break;case 10:Yd(r.type._context);break;case 22:case 23:pm()}n=n.return}if(wt=e,ut=e=Xn(e.current,null),Dt=ns=t,xt=0,zi=null,mm=Wo=Tr=0,Zt=gi=null,mr!==null){for(t=0;t<mr.length;t++)if(n=mr[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}mr=null}return e}function xy(e,t){do{var n=ut;try{if(Xd(),ql.current=bo,jo){for(var r=We.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}jo=!1}if(Mr=0,jt=ht=We=null,pi=!1,Li=0,dm.current=null,n===null||n.return===null){xt=1,zi=t,ut=null;break}e:{var i=e,l=n.return,o=n,c=t;if(t=Dt,o.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,d=o,h=d.tag;if(!(d.mode&1)&&(h===0||h===11||h===15)){var p=d.alternate;p?(d.updateQueue=p.updateQueue,d.memoizedState=p.memoizedState,d.lanes=p.lanes):(d.updateQueue=null,d.memoizedState=null)}var m=Df(l);if(m!==null){m.flags&=-257,Pf(m,l,o,i,t),m.mode&1&&Ef(i,u,t),t=m,c=u;var f=t.updateQueue;if(f===null){var y=new Set;y.add(c),t.updateQueue=y}else f.add(c);break e}else{if(!(t&1)){Ef(i,u,t),xm();break e}c=Error(Z(426))}}else if(Ve&&o.mode&1){var N=Df(l);if(N!==null){!(N.flags&65536)&&(N.flags|=256),Pf(N,l,o,i,t),Zd(Ta(c,o));break e}}i=c=Ta(c,o),xt!==4&&(xt=2),gi===null?gi=[i]:gi.push(i),i=l;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var v=Yg(i,c,t);bf(i,v);break e;case 1:o=c;var g=i.type,x=i.stateNode;if(!(i.flags&128)&&(typeof g.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(Zn===null||!Zn.has(x)))){i.flags|=65536,t&=-t,i.lanes|=t;var j=ey(i,o,t);bf(i,j);break e}}i=i.return}while(i!==null)}vy(n)}catch(k){t=k,ut===n&&n!==null&&(ut=n=n.return);continue}break}while(!0)}function gy(){var e=No.current;return No.current=bo,e===null?bo:e}function xm(){(xt===0||xt===3||xt===2)&&(xt=4),wt===null||!(Tr&268435455)&&!(Wo&268435455)||An(wt,Dt)}function ko(e,t){var n=Pe;Pe|=2;var r=gy();(wt!==e||Dt!==t)&&(en=null,Cr(e,t));do try{mb();break}catch(a){xy(e,a)}while(!0);if(Xd(),Pe=n,No.current=r,ut!==null)throw Error(Z(261));return wt=null,Dt=0,xt}function mb(){for(;ut!==null;)yy(ut)}function hb(){for(;ut!==null&&!zv();)yy(ut)}function yy(e){var t=by(e.alternate,e,ns);e.memoizedProps=e.pendingProps,t===null?vy(e):ut=t,dm.current=null}function vy(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=ib(n,t),n!==null){n.flags&=32767,ut=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{xt=6,ut=null;return}}else if(n=ab(n,t,ns),n!==null){ut=n;return}if(t=t.sibling,t!==null){ut=t;return}ut=t=e}while(t!==null);xt===0&&(xt=5)}function ur(e,t,n){var r=Ie,a=ys.transition;try{ys.transition=null,Ie=1,fb(e,t,n,r)}finally{ys.transition=a,Ie=r}return null}function fb(e,t,n,r){do ma();while(Kn!==null);if(Pe&6)throw Error(Z(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(Z(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(Wv(e,i),e===wt&&(ut=wt=null,Dt=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Tl||(Tl=!0,Ny(ao,function(){return ma(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=ys.transition,ys.transition=null;var l=Ie;Ie=1;var o=Pe;Pe|=4,dm.current=null,ob(e,n),hy(n,e),Ij(Cu),lo=!!ku,Cu=ku=null,e.current=n,cb(n),_v(),Pe=o,Ie=l,ys.transition=i}else e.current=n;if(Tl&&(Tl=!1,Kn=e,So=a),i=e.pendingLanes,i===0&&(Zn=null),Bv(n.stateNode),es(e,it()),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(wo)throw wo=!1,e=Qu,Qu=null,e;return So&1&&e.tag!==0&&ma(),i=e.pendingLanes,i&1?e===Hu?yi++:(yi=0,Hu=e):yi=0,ir(),null}function ma(){if(Kn!==null){var e=Yx(So),t=ys.transition,n=Ie;try{if(ys.transition=null,Ie=16>e?16:e,Kn===null)var r=!1;else{if(e=Kn,Kn=null,So=0,Pe&6)throw Error(Z(331));var a=Pe;for(Pe|=4,ie=e.current;ie!==null;){var i=ie,l=i.child;if(ie.flags&16){var o=i.deletions;if(o!==null){for(var c=0;c<o.length;c++){var u=o[c];for(ie=u;ie!==null;){var d=ie;switch(d.tag){case 0:case 11:case 15:xi(8,d,i)}var h=d.child;if(h!==null)h.return=d,ie=h;else for(;ie!==null;){d=ie;var p=d.sibling,m=d.return;if(uy(d),d===u){ie=null;break}if(p!==null){p.return=m,ie=p;break}ie=m}}}var f=i.alternate;if(f!==null){var y=f.child;if(y!==null){f.child=null;do{var N=y.sibling;y.sibling=null,y=N}while(y!==null)}}ie=i}}if(i.subtreeFlags&2064&&l!==null)l.return=i,ie=l;else e:for(;ie!==null;){if(i=ie,i.flags&2048)switch(i.tag){case 0:case 11:case 15:xi(9,i,i.return)}var v=i.sibling;if(v!==null){v.return=i.return,ie=v;break e}ie=i.return}}var g=e.current;for(ie=g;ie!==null;){l=ie;var x=l.child;if(l.subtreeFlags&2064&&x!==null)x.return=l,ie=x;else e:for(l=g;ie!==null;){if(o=ie,o.flags&2048)try{switch(o.tag){case 0:case 11:case 15:Ho(9,o)}}catch(k){tt(o,o.return,k)}if(o===l){ie=null;break e}var j=o.sibling;if(j!==null){j.return=o.return,ie=j;break e}ie=o.return}}if(Pe=a,ir(),Vs&&typeof Vs.onPostCommitFiberRoot=="function")try{Vs.onPostCommitFiberRoot(_o,e)}catch{}r=!0}return r}finally{Ie=n,ys.transition=t}}return!1}function Bf(e,t,n){t=Ta(n,t),t=Yg(e,t,1),e=Gn(e,t,1),t=Bt(),e!==null&&(el(e,1,t),es(e,t))}function tt(e,t,n){if(e.tag===3)Bf(e,e,n);else for(;t!==null;){if(t.tag===3){Bf(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Zn===null||!Zn.has(r))){e=Ta(n,e),e=ey(t,e,1),t=Gn(t,e,1),e=Bt(),t!==null&&(el(t,1,e),es(t,e));break}}t=t.return}}function pb(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Bt(),e.pingedLanes|=e.suspendedLanes&n,wt===e&&(Dt&n)===n&&(xt===4||xt===3&&(Dt&130023424)===Dt&&500>it()-hm?Cr(e,0):mm|=n),es(e,t)}function jy(e,t){t===0&&(e.mode&1?(t=Nl,Nl<<=1,!(Nl&130023424)&&(Nl=4194304)):t=1);var n=Bt();e=xn(e,t),e!==null&&(el(e,t,n),es(e,n))}function xb(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),jy(e,n)}function gb(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(Z(314))}r!==null&&r.delete(t),jy(e,n)}var by;by=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Xt.current)Jt=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Jt=!1,rb(e,t,n);Jt=!!(e.flags&131072)}else Jt=!1,Ve&&t.flags&1048576&&kg(t,po,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ql(e,t),e=t.pendingProps;var a=Da(t,Lt.current);da(t,n),a=im(null,t,r,e,a,n);var i=lm();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,Yt(r)?(i=!0,ho(t)):i=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,tm(t),a.updater=Qo,t.stateNode=a,a._reactInternals=t,Lu(t,r,e,n),t=zu(null,t,r,!0,i,n)):(t.tag=0,Ve&&i&&Wd(t),$t(null,t,a,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ql(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=vb(r),e=ws(r,e),a){case 0:t=Ou(null,t,r,e,n);break e;case 1:t=Tf(null,t,r,e,n);break e;case 11:t=Af(null,t,r,e,n);break e;case 14:t=Mf(null,t,r,ws(r.type,e),n);break e}throw Error(Z(306,r,""))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:ws(r,a),Ou(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:ws(r,a),Tf(e,t,r,a,n);case 3:e:{if(ry(t),e===null)throw Error(Z(387));r=t.pendingProps,i=t.memoizedState,a=i.element,Mg(e,t),yo(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=Ta(Error(Z(423)),t),t=Ff(e,t,r,n,a);break e}else if(r!==a){a=Ta(Error(Z(424)),t),t=Ff(e,t,r,n,a);break e}else for(is=Wn(t.stateNode.containerInfo.firstChild),ls=t,Ve=!0,Es=null,n=Pg(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Pa(),r===a){t=gn(e,t,n);break e}$t(e,t,r,n)}t=t.child}return t;case 5:return Tg(t),e===null&&Tu(t),r=t.type,a=t.pendingProps,i=e!==null?e.memoizedProps:null,l=a.children,Eu(r,a)?l=null:i!==null&&Eu(r,i)&&(t.flags|=32),ny(e,t),$t(e,t,l,n),t.child;case 6:return e===null&&Tu(t),null;case 13:return ay(e,t,n);case 4:return sm(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Aa(t,null,r,n):$t(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:ws(r,a),Af(e,t,r,a,n);case 7:return $t(e,t,t.pendingProps,n),t.child;case 8:return $t(e,t,t.pendingProps.children,n),t.child;case 12:return $t(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,Oe(xo,r._currentValue),r._currentValue=l,i!==null)if(Is(i.value,l)){if(i.children===a.children&&!Xt.current){t=gn(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=dn(-1,n&-n),c.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),Fu(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(Z(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),Fu(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}$t(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,da(t,n),a=vs(a),r=r(a),t.flags|=1,$t(e,t,r,n),t.child;case 14:return r=t.type,a=ws(r,t.pendingProps),a=ws(r.type,a),Mf(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:ws(r,a),Ql(e,t),t.tag=1,Yt(r)?(e=!0,ho(t)):e=!1,da(t,n),Xg(t,r,a),Lu(t,r,a,n),zu(null,t,r,!0,e,n);case 19:return iy(e,t,n);case 22:return sy(e,t,n)}throw Error(Z(156,t.tag))};function Ny(e,t){return Gx(e,t)}function yb(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 xs(e,t,n,r){return new yb(e,t,n,r)}function gm(e){return e=e.prototype,!(!e||!e.isReactComponent)}function vb(e){if(typeof e=="function")return gm(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Rd)return 11;if(e===Od)return 14}return 2}function Xn(e,t){var n=e.alternate;return n===null?(n=xs(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 Gl(e,t,n,r,a,i){var l=2;if(r=e,typeof e=="function")gm(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case Gr:return Er(n.children,a,i,t);case Ld:l=8,a|=8;break;case au:return e=xs(12,n,t,a|2),e.elementType=au,e.lanes=i,e;case iu:return e=xs(13,n,t,a),e.elementType=iu,e.lanes=i,e;case lu:return e=xs(19,n,t,a),e.elementType=lu,e.lanes=i,e;case Tx:return Go(n,a,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Ax:l=10;break e;case Mx:l=9;break e;case Rd:l=11;break e;case Od:l=14;break e;case En:l=16,r=null;break e}throw Error(Z(130,e==null?e:typeof e,""))}return t=xs(l,n,t,a),t.elementType=e,t.type=r,t.lanes=i,t}function Er(e,t,n,r){return e=xs(7,e,r,t),e.lanes=n,e}function Go(e,t,n,r){return e=xs(22,e,r,t),e.elementType=Tx,e.lanes=n,e.stateNode={isHidden:!1},e}function qc(e,t,n){return e=xs(6,e,null,t),e.lanes=n,e}function Vc(e,t,n){return t=xs(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function jb(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=kc(0),this.expirationTimes=kc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=kc(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function ym(e,t,n,r,a,i,l,o,c){return e=new jb(e,t,n,o,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=xs(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},tm(i),e}function bb(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Wr,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function wy(e){if(!e)return sr;e=e._reactInternals;e:{if(_r(e)!==e||e.tag!==1)throw Error(Z(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Yt(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Z(171))}if(e.tag===1){var n=e.type;if(Yt(n))return wg(e,n,t)}return t}function Sy(e,t,n,r,a,i,l,o,c){return e=ym(n,r,!0,e,a,i,l,o,c),e.context=wy(null),n=e.current,r=Bt(),a=Jn(n),i=dn(r,a),i.callback=t??null,Gn(n,i,a),e.current.lanes=a,el(e,a,r),es(e,r),e}function Zo(e,t,n,r){var a=t.current,i=Bt(),l=Jn(a);return n=wy(n),t.context===null?t.context=n:t.pendingContext=n,t=dn(i,l),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Gn(a,t,l),e!==null&&(Fs(e,a,l,i),Kl(e,a,l)),l}function Co(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 Kf(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function vm(e,t){Kf(e,t),(e=e.alternate)&&Kf(e,t)}function Nb(){return null}var ky=typeof reportError=="function"?reportError:function(e){console.error(e)};function jm(e){this._internalRoot=e}Jo.prototype.render=jm.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Z(409));Zo(e,t,null,null)};Jo.prototype.unmount=jm.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Fr(function(){Zo(null,e,null,null)}),t[pn]=null}};function Jo(e){this._internalRoot=e}Jo.prototype.unstable_scheduleHydration=function(e){if(e){var t=sg();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Pn.length&&t!==0&&t<Pn[n].priority;n++);Pn.splice(n,0,e),n===0&&rg(e)}};function bm(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Xo(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function qf(){}function wb(e,t,n,r,a){if(a){if(typeof r=="function"){var i=r;r=function(){var u=Co(l);i.call(u)}}var l=Sy(t,r,e,0,null,!1,!1,"",qf);return e._reactRootContainer=l,e[pn]=l.current,Ai(e.nodeType===8?e.parentNode:e),Fr(),l}for(;a=e.lastChild;)e.removeChild(a);if(typeof r=="function"){var o=r;r=function(){var u=Co(c);o.call(u)}}var c=ym(e,0,!1,null,null,!1,!1,"",qf);return e._reactRootContainer=c,e[pn]=c.current,Ai(e.nodeType===8?e.parentNode:e),Fr(function(){Zo(t,c,n,r)}),c}function Yo(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=Co(l);o.call(c)}}Zo(t,l,e,a)}else l=wb(n,t,e,a,r);return Co(l)}eg=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=ii(t.pendingLanes);n!==0&&($d(t,n|1),es(t,it()),!(Pe&6)&&(Fa=it()+500,ir()))}break;case 13:Fr(function(){var r=xn(e,1);if(r!==null){var a=Bt();Fs(r,e,1,a)}}),vm(e,1)}};Ud=function(e){if(e.tag===13){var t=xn(e,134217728);if(t!==null){var n=Bt();Fs(t,e,134217728,n)}vm(e,134217728)}};tg=function(e){if(e.tag===13){var t=Jn(e),n=xn(e,t);if(n!==null){var r=Bt();Fs(n,e,t,r)}vm(e,t)}};sg=function(){return Ie};ng=function(e,t){var n=Ie;try{return Ie=e,t()}finally{Ie=n}};gu=function(e,t,n){switch(t){case"input":if(uu(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=Ko(r);if(!a)throw Error(Z(90));Ix(r),uu(r,a)}}}break;case"textarea":Rx(e,n);break;case"select":t=n.value,t!=null&&la(e,!!n.multiple,t,!1)}};Kx=fm;qx=Fr;var Sb={usingClientEntryPoint:!1,Events:[sl,Yr,Ko,Ux,Bx,fm]},ti={findFiberByHostInstance:dr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},kb={bundleType:ti.bundleType,version:ti.version,rendererPackageName:ti.rendererPackageName,rendererConfig:ti.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:bn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Hx(e),e===null?null:e.stateNode},findFiberByHostInstance:ti.findFiberByHostInstance||Nb,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 Fl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Fl.isDisabled&&Fl.supportsFiber)try{_o=Fl.inject(kb),Vs=Fl}catch{}}cs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Sb;cs.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!bm(t))throw Error(Z(200));return bb(e,t,null,n)};cs.createRoot=function(e,t){if(!bm(e))throw Error(Z(299));var n=!1,r="",a=ky;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=ym(e,1,!1,null,null,n,!1,r,a),e[pn]=t.current,Ai(e.nodeType===8?e.parentNode:e),new jm(t)};cs.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(Z(188)):(e=Object.keys(e).join(","),Error(Z(268,e)));return e=Hx(t),e=e===null?null:e.stateNode,e};cs.flushSync=function(e){return Fr(e)};cs.hydrate=function(e,t,n){if(!Xo(t))throw Error(Z(200));return Yo(null,e,t,!0,n)};cs.hydrateRoot=function(e,t,n){if(!bm(e))throw Error(Z(405));var r=n!=null&&n.hydratedSources||null,a=!1,i="",l=ky;if(n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(l=n.onRecoverableError)),t=Sy(t,null,e,1,n??null,a,!1,i,l),e[pn]=t.current,Ai(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 Jo(t)};cs.render=function(e,t,n){if(!Xo(t))throw Error(Z(200));return Yo(null,e,t,!1,n)};cs.unmountComponentAtNode=function(e){if(!Xo(e))throw Error(Z(40));return e._reactRootContainer?(Fr(function(){Yo(null,null,e,!1,function(){e._reactRootContainer=null,e[pn]=null})}),!0):!1};cs.unstable_batchedUpdates=fm;cs.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Xo(n))throw Error(Z(200));if(e==null||e._reactInternals===void 0)throw Error(Z(38));return Yo(e,t,n,!1,r)};cs.version="18.3.1-next-f1338f8080-20240426";function Cy(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Cy)}catch(e){console.error(e)}}Cy(),Cx.exports=cs;var Cb=Cx.exports,Vf=Cb;nu.createRoot=Vf.createRoot,nu.hydrateRoot=Vf.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 _i(){return _i=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},_i.apply(this,arguments)}var qn;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(qn||(qn={}));const Qf="popstate";function Eb(e){e===void 0&&(e={});function t(r,a){let{pathname:i,search:l,hash:o}=r.location;return Zu("",{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:Eo(a)}return Pb(t,n,null,e)}function Ge(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Nm(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Db(){return Math.random().toString(36).substr(2,8)}function Hf(e,t){return{usr:e.state,key:e.key,idx:t}}function Zu(e,t,n,r){return n===void 0&&(n=null),_i({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?$a(t):t,{state:n,key:t&&t.key||r||Db()})}function Eo(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 $a(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 Pb(e,t,n,r){r===void 0&&(r={});let{window:a=document.defaultView,v5Compat:i=!1}=r,l=a.history,o=qn.Pop,c=null,u=d();u==null&&(u=0,l.replaceState(_i({},l.state,{idx:u}),""));function d(){return(l.state||{idx:null}).idx}function h(){o=qn.Pop;let N=d(),v=N==null?null:N-u;u=N,c&&c({action:o,location:y.location,delta:v})}function p(N,v){o=qn.Push;let g=Zu(y.location,N,v);u=d()+1;let x=Hf(g,u),j=y.createHref(g);try{l.pushState(x,"",j)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;a.location.assign(j)}i&&c&&c({action:o,location:y.location,delta:1})}function m(N,v){o=qn.Replace;let g=Zu(y.location,N,v);u=d();let x=Hf(g,u),j=y.createHref(g);l.replaceState(x,"",j),i&&c&&c({action:o,location:y.location,delta:0})}function f(N){let v=a.location.origin!=="null"?a.location.origin:a.location.href,g=typeof N=="string"?N:Eo(N);return g=g.replace(/ $/,"%20"),Ge(v,"No window.location.(origin|href) available to create URL for href: "+g),new URL(g,v)}let y={get action(){return o},get location(){return e(a,l)},listen(N){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(Qf,h),c=N,()=>{a.removeEventListener(Qf,h),c=null}},createHref(N){return t(a,N)},createURL:f,encodeLocation(N){let v=f(N);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:p,replace:m,go(N){return l.go(N)}};return y}var Wf;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Wf||(Wf={}));function Ab(e,t,n){return n===void 0&&(n="/"),Mb(e,t,n)}function Mb(e,t,n,r){let a=typeof t=="string"?$a(t):t,i=Ia(a.pathname||"/",n);if(i==null)return null;let l=Ey(e);Tb(l);let o=null;for(let c=0;o==null&&c<l.length;++c){let u=Kb(i);o=Ub(l[c],u)}return o}function Ey(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("/")&&(Ge(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 u=Yn([r,c.relativePath]),d=n.concat(c);i.children&&i.children.length>0&&(Ge(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),Ey(i.children,t,d,u)),!(i.path==null&&!i.index)&&t.push({path:u,score:_b(u,i.index),routesMeta:d})};return e.forEach((i,l)=>{var o;if(i.path===""||!((o=i.path)!=null&&o.includes("?")))a(i,l);else for(let c of Dy(i.path))a(i,l,c)}),t}function Dy(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=Dy(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 Tb(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:$b(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const Fb=/^:[\w-]+$/,Ib=3,Lb=2,Rb=1,Ob=10,zb=-2,Gf=e=>e==="*";function _b(e,t){let n=e.split("/"),r=n.length;return n.some(Gf)&&(r+=zb),t&&(r+=Lb),n.filter(a=>!Gf(a)).reduce((a,i)=>a+(Fb.test(i)?Ib:i===""?Rb:Ob),r)}function $b(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 Ub(e,t,n){let{routesMeta:r}=e,a={},i="/",l=[];for(let o=0;o<r.length;++o){let c=r[o],u=o===r.length-1,d=i==="/"?t:t.slice(i.length)||"/",h=Ju({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),p=c.route;if(!h)return null;Object.assign(a,h.params),l.push({params:a,pathname:Yn([i,h.pathname]),pathnameBase:Wb(Yn([i,h.pathnameBase])),route:p}),h.pathnameBase!=="/"&&(i=Yn([i,h.pathnameBase]))}return l}function Ju(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Bb(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((u,d,h)=>{let{paramName:p,isOptional:m}=d;if(p==="*"){let y=o[h]||"";l=i.slice(0,i.length-y.length).replace(/(.)\/+$/,"$1")}const f=o[h];return m&&!f?u[p]=void 0:u[p]=(f||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:l,pattern:e}}function Bb(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),Nm(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 Kb(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Nm(!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 Ia(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 qb=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Vb=e=>qb.test(e);function Qb(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?$a(e):e,i;if(n)if(Vb(n))i=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),Nm(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?i=Zf(n.substring(1),"/"):i=Zf(n,t)}else i=t;return{pathname:i,search:Gb(r),hash:Zb(a)}}function Zf(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 Qc(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 Hb(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function wm(e,t){let n=Hb(e);return t?n.map((r,a)=>a===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Sm(e,t,n,r){r===void 0&&(r=!1);let a;typeof e=="string"?a=$a(e):(a=_i({},e),Ge(!a.pathname||!a.pathname.includes("?"),Qc("?","pathname","search",a)),Ge(!a.pathname||!a.pathname.includes("#"),Qc("#","pathname","hash",a)),Ge(!a.search||!a.search.includes("#"),Qc("#","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=Qb(a,o),u=l&&l!=="/"&&l.endsWith("/"),d=(i||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}const Yn=e=>e.join("/").replace(/\/\/+/g,"/"),Wb=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Gb=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Zb=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Jb(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const Py=["post","put","patch","delete"];new Set(Py);const Xb=["get",...Py];new Set(Xb);/**
|
||
* 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 $i(){return $i=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},$i.apply(this,arguments)}const ec=b.createContext(null),Ay=b.createContext(null),Nn=b.createContext(null),tc=b.createContext(null),Ws=b.createContext({outlet:null,matches:[],isDataRoute:!1}),My=b.createContext(null);function Yb(e,t){let{relative:n}=t===void 0?{}:t;Ua()||Ge(!1);let{basename:r,navigator:a}=b.useContext(Nn),{hash:i,pathname:l,search:o}=nc(e,{relative:n}),c=l;return r!=="/"&&(c=l==="/"?r:Yn([r,l])),a.createHref({pathname:c,search:o,hash:i})}function Ua(){return b.useContext(tc)!=null}function wn(){return Ua()||Ge(!1),b.useContext(tc).location}function Ty(e){b.useContext(Nn).static||b.useLayoutEffect(e)}function Vt(){let{isDataRoute:e}=b.useContext(Ws);return e?fN():eN()}function eN(){Ua()||Ge(!1);let e=b.useContext(ec),{basename:t,future:n,navigator:r}=b.useContext(Nn),{matches:a}=b.useContext(Ws),{pathname:i}=wn(),l=JSON.stringify(wm(a,n.v7_relativeSplatPath)),o=b.useRef(!1);return Ty(()=>{o.current=!0}),b.useCallback(function(u,d){if(d===void 0&&(d={}),!o.current)return;if(typeof u=="number"){r.go(u);return}let h=Sm(u,JSON.parse(l),i,d.relative==="path");e==null&&t!=="/"&&(h.pathname=h.pathname==="/"?t:Yn([t,h.pathname])),(d.replace?r.replace:r.push)(h,d.state,d)},[t,r,l,i,e])}const tN=b.createContext(null);function sN(e){let t=b.useContext(Ws).outlet;return t&&b.createElement(tN.Provider,{value:e},t)}function sc(){let{matches:e}=b.useContext(Ws),t=e[e.length-1];return t?t.params:{}}function nc(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=b.useContext(Nn),{matches:a}=b.useContext(Ws),{pathname:i}=wn(),l=JSON.stringify(wm(a,r.v7_relativeSplatPath));return b.useMemo(()=>Sm(e,JSON.parse(l),i,n==="path"),[e,l,i,n])}function nN(e,t){return rN(e,t)}function rN(e,t,n,r){Ua()||Ge(!1);let{navigator:a}=b.useContext(Nn),{matches:i}=b.useContext(Ws),l=i[i.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let u=wn(),d;if(t){var h;let N=typeof t=="string"?$a(t):t;c==="/"||(h=N.pathname)!=null&&h.startsWith(c)||Ge(!1),d=N}else d=u;let p=d.pathname||"/",m=p;if(c!=="/"){let N=c.replace(/^\//,"").split("/");m="/"+p.replace(/^\//,"").split("/").slice(N.length).join("/")}let f=Ab(e,{pathname:m}),y=cN(f&&f.map(N=>Object.assign({},N,{params:Object.assign({},o,N.params),pathname:Yn([c,a.encodeLocation?a.encodeLocation(N.pathname).pathname:N.pathname]),pathnameBase:N.pathnameBase==="/"?c:Yn([c,a.encodeLocation?a.encodeLocation(N.pathnameBase).pathname:N.pathnameBase])})),i,n,r);return t&&y?b.createElement(tc.Provider,{value:{location:$i({pathname:"/",search:"",hash:"",state:null,key:"default"},d),navigationType:qn.Pop}},y):y}function aN(){let e=hN(),t=Jb(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 iN=b.createElement(aN,null);class lN 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(Ws.Provider,{value:this.props.routeContext},b.createElement(My.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function oN(e){let{routeContext:t,match:n,children:r}=e,a=b.useContext(ec);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),b.createElement(Ws.Provider,{value:t},r)}function cN(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 d=l.findIndex(h=>h.route.id&&(o==null?void 0:o[h.route.id])!==void 0);d>=0||Ge(!1),l=l.slice(0,Math.min(l.length,d+1))}let c=!1,u=-1;if(n&&r&&r.v7_partialHydration)for(let d=0;d<l.length;d++){let h=l[d];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(u=d),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,u>=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((d,h,p)=>{let m,f=!1,y=null,N=null;n&&(m=o&&h.route.id?o[h.route.id]:void 0,y=h.route.errorElement||iN,c&&(u<0&&p===0?(pN("route-fallback"),f=!0,N=null):u===p&&(f=!0,N=h.route.hydrateFallbackElement||null)));let v=t.concat(l.slice(0,p+1)),g=()=>{let x;return m?x=y:f?x=N:h.route.Component?x=b.createElement(h.route.Component,null):h.route.element?x=h.route.element:x=d,b.createElement(oN,{match:h,routeContext:{outlet:d,matches:v,isDataRoute:n!=null},children:x})};return n&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?b.createElement(lN,{location:n.location,revalidation:n.revalidation,component:y,error:m,children:g(),routeContext:{outlet:null,matches:v,isDataRoute:!0}}):g()},null)}var Fy=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Fy||{}),Iy=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}(Iy||{});function uN(e){let t=b.useContext(ec);return t||Ge(!1),t}function dN(e){let t=b.useContext(Ay);return t||Ge(!1),t}function mN(e){let t=b.useContext(Ws);return t||Ge(!1),t}function Ly(e){let t=mN(),n=t.matches[t.matches.length-1];return n.route.id||Ge(!1),n.route.id}function hN(){var e;let t=b.useContext(My),n=dN(),r=Ly();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function fN(){let{router:e}=uN(Fy.UseNavigateStable),t=Ly(Iy.UseNavigateStable),n=b.useRef(!1);return Ty(()=>{n.current=!0}),b.useCallback(function(a,i){i===void 0&&(i={}),n.current&&(typeof a=="number"?e.navigate(a):e.navigate(a,$i({fromRouteId:t},i)))},[e,t])}const Jf={};function pN(e,t,n){Jf[e]||(Jf[e]=!0)}function xN(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function ia(e){let{to:t,replace:n,state:r,relative:a}=e;Ua()||Ge(!1);let{future:i,static:l}=b.useContext(Nn),{matches:o}=b.useContext(Ws),{pathname:c}=wn(),u=Vt(),d=Sm(t,wm(o,i.v7_relativeSplatPath),c,a==="path"),h=JSON.stringify(d);return b.useEffect(()=>u(JSON.parse(h),{replace:n,state:r,relative:a}),[u,h,a,n,r]),null}function gN(e){return sN(e.context)}function Te(e){Ge(!1)}function yN(e){let{basename:t="/",children:n=null,location:r,navigationType:a=qn.Pop,navigator:i,static:l=!1,future:o}=e;Ua()&&Ge(!1);let c=t.replace(/^\/*/,"/"),u=b.useMemo(()=>({basename:c,navigator:i,static:l,future:$i({v7_relativeSplatPath:!1},o)}),[c,o,i,l]);typeof r=="string"&&(r=$a(r));let{pathname:d="/",search:h="",hash:p="",state:m=null,key:f="default"}=r,y=b.useMemo(()=>{let N=Ia(d,c);return N==null?null:{location:{pathname:N,search:h,hash:p,state:m,key:f},navigationType:a}},[c,d,h,p,m,f,a]);return y==null?null:b.createElement(Nn.Provider,{value:u},b.createElement(tc.Provider,{children:n,value:y}))}function vN(e){let{children:t,location:n}=e;return nN(Xu(t),n)}new Promise(()=>{});function Xu(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,Xu(r.props.children,i));return}r.type!==Te&&Ge(!1),!r.props.index||!r.props.children||Ge(!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=Xu(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 Do(){return Do=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},Do.apply(this,arguments)}function Ry(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 jN(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function bN(e,t){return e.button===0&&(!t||t==="_self")&&!jN(e)}function Yu(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function NN(e,t){let n=Yu(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(i=>{n.append(a,i)})}),n}const wN=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],SN=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],kN="6";try{window.__reactRouterVersion=kN}catch{}const CN=b.createContext({isTransitioning:!1}),EN="startTransition",Xf=pv[EN];function DN(e){let{basename:t,children:n,future:r,window:a}=e,i=b.useRef();i.current==null&&(i.current=Eb({window:a,v5Compat:!0}));let l=i.current,[o,c]=b.useState({action:l.action,location:l.location}),{v7_startTransition:u}=r||{},d=b.useCallback(h=>{u&&Xf?Xf(()=>c(h)):c(h)},[c,u]);return b.useLayoutEffect(()=>l.listen(d),[l,d]),b.useEffect(()=>xN(r),[r]),b.createElement(yN,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const PN=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",AN=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ne=b.forwardRef(function(t,n){let{onClick:r,relative:a,reloadDocument:i,replace:l,state:o,target:c,to:u,preventScrollReset:d,viewTransition:h}=t,p=Ry(t,wN),{basename:m}=b.useContext(Nn),f,y=!1;if(typeof u=="string"&&AN.test(u)&&(f=u,PN))try{let x=new URL(window.location.href),j=u.startsWith("//")?new URL(x.protocol+u):new URL(u),k=Ia(j.pathname,m);j.origin===x.origin&&k!=null?u=k+j.search+j.hash:y=!0}catch{}let N=Yb(u,{relative:a}),v=TN(u,{replace:l,state:o,target:c,preventScrollReset:d,relative:a,viewTransition:h});function g(x){r&&r(x),x.defaultPrevented||v(x)}return b.createElement("a",Do({},p,{href:f||N,onClick:y||i?r:g,ref:n,target:c}))}),Hc=b.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:a=!1,className:i="",end:l=!1,style:o,to:c,viewTransition:u,children:d}=t,h=Ry(t,SN),p=nc(c,{relative:h.relative}),m=wn(),f=b.useContext(Ay),{navigator:y,basename:N}=b.useContext(Nn),v=f!=null&&FN(p)&&u===!0,g=y.encodeLocation?y.encodeLocation(p).pathname:p.pathname,x=m.pathname,j=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;a||(x=x.toLowerCase(),j=j?j.toLowerCase():null,g=g.toLowerCase()),j&&N&&(j=Ia(j,N)||j);const k=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let F=x===g||!l&&x.startsWith(g)&&x.charAt(k)==="/",E=j!=null&&(j===g||!l&&j.startsWith(g)&&j.charAt(g.length)==="/"),S={isActive:F,isPending:E,isTransitioning:v},P=F?r:void 0,A;typeof i=="function"?A=i(S):A=[i,F?"active":null,E?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let _=typeof o=="function"?o(S):o;return b.createElement(Ne,Do({},h,{"aria-current":P,className:A,ref:n,style:_,to:c,viewTransition:u}),typeof d=="function"?d(S):d)});var ed;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(ed||(ed={}));var Yf;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Yf||(Yf={}));function MN(e){let t=b.useContext(ec);return t||Ge(!1),t}function TN(e,t){let{target:n,replace:r,state:a,preventScrollReset:i,relative:l,viewTransition:o}=t===void 0?{}:t,c=Vt(),u=wn(),d=nc(e,{relative:l});return b.useCallback(h=>{if(bN(h,n)){h.preventDefault();let p=r!==void 0?r:Eo(u)===Eo(d);c(e,{replace:p,state:a,preventScrollReset:i,relative:l,viewTransition:o})}},[u,c,d,r,a,n,e,i,l,o])}function rc(e){let t=b.useRef(Yu(e)),n=b.useRef(!1),r=wn(),a=b.useMemo(()=>NN(r.search,n.current?null:t.current),[r.search]),i=Vt(),l=b.useCallback((o,c)=>{const u=Yu(typeof o=="function"?o(a):o);n.current=!0,i("?"+u,c)},[i,a]);return[a,l]}function FN(e,t){t===void 0&&(t={});let n=b.useContext(CN);n==null&&Ge(!1);let{basename:r}=MN(ed.useViewTransitionState),a=nc(e,{relative:t.relative});if(!n.isTransitioning)return!1;let i=Ia(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Ia(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Ju(a.pathname,l)!=null||Ju(a.pathname,i)!=null}var Ba=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(){}},IN={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Fn,Ed,rx,LN=(rx=class{constructor(){me(this,Fn,IN);me(this,Ed,!1)}setTimeoutProvider(e){re(this,Fn,e)}setTimeout(e,t){return D(this,Fn).setTimeout(e,t)}clearTimeout(e){D(this,Fn).clearTimeout(e)}setInterval(e,t){return D(this,Fn).setInterval(e,t)}clearInterval(e){D(this,Fn).clearInterval(e)}},Fn=new WeakMap,Ed=new WeakMap,rx),fr=new LN;function RN(e){setTimeout(e,0)}var Ir=typeof window>"u"||"Deno"in globalThis;function Ut(){}function ON(e,t){return typeof e=="function"?e(t):e}function td(e){return typeof e=="number"&&e>=0&&e!==1/0}function Oy(e,t){return Math.max(e+(t||0)-Date.now(),0)}function er(e,t){return typeof e=="function"?e(t):e}function ms(e,t){return typeof e=="function"?e(t):e}function ep(e,t){const{type:n="all",exact:r,fetchStatus:a,predicate:i,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==km(l,t.options))return!1}else if(!Ui(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 tp(e,t){const{exact:n,status:r,predicate:a,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Lr(t.options.mutationKey)!==Lr(i))return!1}else if(!Ui(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||a&&!a(t))}function km(e,t){return((t==null?void 0:t.queryKeyHashFn)||Lr)(e)}function Lr(e){return JSON.stringify(e,(t,n)=>sd(n)?Object.keys(n).sort().reduce((r,a)=>(r[a]=n[a],r),{}):n)}function Ui(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Ui(e[n],t[n])):!1}var zN=Object.prototype.hasOwnProperty;function zy(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=sp(e)&&sp(t);if(!r&&!(sd(e)&&sd(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 u=0;for(let d=0;d<o;d++){const h=r?d:l[d],p=e[h],m=t[h];if(p===m){c[h]=p,(r?d<i:zN.call(e,h))&&u++;continue}if(p===null||m===null||typeof p!="object"||typeof m!="object"){c[h]=m;continue}const f=zy(p,m,n+1);c[h]=f,f===p&&u++}return i===o&&u===i?e:c}function Po(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 sp(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function sd(e){if(!np(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!np(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function np(e){return Object.prototype.toString.call(e)==="[object Object]"}function _N(e){return new Promise(t=>{fr.setTimeout(t,e)})}function nd(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?zy(e,t):t}function $N(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function UN(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Cm=Symbol();function _y(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Cm?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Em(e,t){return typeof e=="function"?e(...t):!!e}function BN(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 gr,In,pa,ax,KN=(ax=class extends Ba{constructor(){super();me(this,gr);me(this,In);me(this,pa);re(this,pa,t=>{if(!Ir&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){D(this,In)||this.setEventListener(D(this,pa))}onUnsubscribe(){var t;this.hasListeners()||((t=D(this,In))==null||t.call(this),re(this,In,void 0))}setEventListener(t){var n;re(this,pa,t),(n=D(this,In))==null||n.call(this),re(this,In,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){D(this,gr)!==t&&(re(this,gr,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof D(this,gr)=="boolean"?D(this,gr):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},gr=new WeakMap,In=new WeakMap,pa=new WeakMap,ax),Dm=new KN;function rd(){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 qN=RN;function VN(){let e=[],t=0,n=o=>{o()},r=o=>{o()},a=qN;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 ft=VN(),xa,Ln,ga,ix,QN=(ix=class extends Ba{constructor(){super();me(this,xa,!0);me(this,Ln);me(this,ga);re(this,ga,t=>{if(!Ir&&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(){D(this,Ln)||this.setEventListener(D(this,ga))}onUnsubscribe(){var t;this.hasListeners()||((t=D(this,Ln))==null||t.call(this),re(this,Ln,void 0))}setEventListener(t){var n;re(this,ga,t),(n=D(this,Ln))==null||n.call(this),re(this,Ln,t(this.setOnline.bind(this)))}setOnline(t){D(this,xa)!==t&&(re(this,xa,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return D(this,xa)}},xa=new WeakMap,Ln=new WeakMap,ga=new WeakMap,ix),Ao=new QN;function HN(e){return Math.min(1e3*2**e,3e4)}function $y(e){return(e??"online")==="online"?Ao.isOnline():!0}var ad=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Uy(e){let t=!1,n=0,r;const a=rd(),i=()=>a.status!=="pending",l=y=>{var N;if(!i()){const v=new ad(y);p(v),(N=e.onCancel)==null||N.call(e,v)}},o=()=>{t=!0},c=()=>{t=!1},u=()=>Dm.isFocused()&&(e.networkMode==="always"||Ao.isOnline())&&e.canRun(),d=()=>$y(e.networkMode)&&e.canRun(),h=y=>{i()||(r==null||r(),a.resolve(y))},p=y=>{i()||(r==null||r(),a.reject(y))},m=()=>new Promise(y=>{var N;r=v=>{(i()||u())&&y(v)},(N=e.onPause)==null||N.call(e)}).then(()=>{var y;r=void 0,i()||(y=e.onContinue)==null||y.call(e)}),f=()=>{if(i())return;let y;const N=n===0?e.initialPromise:void 0;try{y=N??e.fn()}catch(v){y=Promise.reject(v)}Promise.resolve(y).then(h).catch(v=>{var F;if(i())return;const g=e.retry??(Ir?0:3),x=e.retryDelay??HN,j=typeof x=="function"?x(n,v):x,k=g===!0||typeof g=="number"&&n<g||typeof g=="function"&&g(n,v);if(t||!k){p(v);return}n++,(F=e.onFail)==null||F.call(e,n,v),_N(j).then(()=>u()?void 0:m()).then(()=>{t?p(v):f()})})};return{promise:a,status:()=>a.status,cancel:l,continue:()=>(r==null||r(),a),cancelRetry:o,continueRetry:c,canStart:d,start:()=>(d()?f():m().then(f),a)}}var yr,lx,By=(lx=class{constructor(){me(this,yr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),td(this.gcTime)&&re(this,yr,fr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ir?1/0:5*60*1e3))}clearGcTimeout(){D(this,yr)&&(fr.clearTimeout(D(this,yr)),re(this,yr,void 0))}},yr=new WeakMap,lx),vr,ya,ds,jr,vt,Wi,br,Ss,Ys,ox,WN=(ox=class extends By{constructor(t){super();me(this,Ss);me(this,vr);me(this,ya);me(this,ds);me(this,jr);me(this,vt);me(this,Wi);me(this,br);re(this,br,!1),re(this,Wi,t.defaultOptions),this.setOptions(t.options),this.observers=[],re(this,jr,t.client),re(this,ds,D(this,jr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,re(this,vr,ap(this.options)),this.state=t.state??D(this,vr),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=D(this,vt))==null?void 0:t.promise}setOptions(t){if(this.options={...D(this,Wi),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=ap(this.options);n.data!==void 0&&(this.setState(rp(n.data,n.dataUpdatedAt)),re(this,vr,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&D(this,ds).remove(this)}setData(t,n){const r=nd(this.state.data,t,this.options);return be(this,Ss,Ys).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){be(this,Ss,Ys).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,a;const n=(r=D(this,vt))==null?void 0:r.promise;return(a=D(this,vt))==null||a.cancel(t),n?n.then(Ut).catch(Ut):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(D(this,vr))}isActive(){return this.observers.some(t=>ms(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Cm||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>er(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:!Oy(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=D(this,vt))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=D(this,vt))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),D(this,ds).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(D(this,vt)&&(D(this,br)?D(this,vt).cancel({revert:!0}):D(this,vt).cancelRetry()),this.scheduleGc()),D(this,ds).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||be(this,Ss,Ys).call(this,{type:"invalidate"})}async fetch(t,n){var c,u,d,h,p,m,f,y,N,v,g,x;if(this.state.fetchStatus!=="idle"&&((c=D(this,vt))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(D(this,vt))return D(this,vt).continueRetry(),D(this,vt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const j=this.observers.find(k=>k.options.queryFn);j&&this.setOptions(j.options)}const r=new AbortController,a=j=>{Object.defineProperty(j,"signal",{enumerable:!0,get:()=>(re(this,br,!0),r.signal)})},i=()=>{const j=_y(this.options,n),F=(()=>{const E={client:D(this,jr),queryKey:this.queryKey,meta:this.meta};return a(E),E})();return re(this,br,!1),this.options.persister?this.options.persister(j,F,this):j(F)},o=(()=>{const j={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:D(this,jr),state:this.state,fetchFn:i};return a(j),j})();(u=this.options.behavior)==null||u.onFetch(o,this),re(this,ya,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=o.fetchOptions)==null?void 0:d.meta))&&be(this,Ss,Ys).call(this,{type:"fetch",meta:(h=o.fetchOptions)==null?void 0:h.meta}),re(this,vt,Uy({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:j=>{j instanceof ad&&j.revert&&this.setState({...D(this,ya),fetchStatus:"idle"}),r.abort()},onFail:(j,k)=>{be(this,Ss,Ys).call(this,{type:"failed",failureCount:j,error:k})},onPause:()=>{be(this,Ss,Ys).call(this,{type:"pause"})},onContinue:()=>{be(this,Ss,Ys).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const j=await D(this,vt).start();if(j===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(j),(m=(p=D(this,ds).config).onSuccess)==null||m.call(p,j,this),(y=(f=D(this,ds).config).onSettled)==null||y.call(f,j,this.state.error,this),j}catch(j){if(j instanceof ad){if(j.silent)return D(this,vt).promise;if(j.revert){if(this.state.data===void 0)throw j;return this.state.data}}throw be(this,Ss,Ys).call(this,{type:"error",error:j}),(v=(N=D(this,ds).config).onError)==null||v.call(N,j,this),(x=(g=D(this,ds).config).onSettled)==null||x.call(g,this.state.data,j,this),j}finally{this.scheduleGc()}}},vr=new WeakMap,ya=new WeakMap,ds=new WeakMap,jr=new WeakMap,vt=new WeakMap,Wi=new WeakMap,br=new WeakMap,Ss=new WeakSet,Ys=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,...Ky(r.data,this.options),fetchMeta:t.meta??null};case"success":const a={...r,...rp(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return re(this,ya,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),ft.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),D(this,ds).notify({query:this,type:"updated",action:t})})},ox);function Ky(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:$y(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function rp(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function ap(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 Ht,Ee,Gi,Ot,Nr,va,nn,Rn,Zi,ja,ba,wr,Sr,On,Na,Fe,oi,id,ld,od,cd,ud,dd,md,qy,cx,GN=(cx=class extends Ba{constructor(t,n){super();me(this,Fe);me(this,Ht);me(this,Ee);me(this,Gi);me(this,Ot);me(this,Nr);me(this,va);me(this,nn);me(this,Rn);me(this,Zi);me(this,ja);me(this,ba);me(this,wr);me(this,Sr);me(this,On);me(this,Na,new Set);this.options=n,re(this,Ht,t),re(this,Rn,null),re(this,nn,rd()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(D(this,Ee).addObserver(this),ip(D(this,Ee),this.options)?be(this,Fe,oi).call(this):this.updateResult(),be(this,Fe,cd).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return hd(D(this,Ee),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return hd(D(this,Ee),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,be(this,Fe,ud).call(this),be(this,Fe,dd).call(this),D(this,Ee).removeObserver(this)}setOptions(t){const n=this.options,r=D(this,Ee);if(this.options=D(this,Ht).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ms(this.options.enabled,D(this,Ee))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");be(this,Fe,md).call(this),D(this,Ee).setOptions(this.options),n._defaulted&&!Po(this.options,n)&&D(this,Ht).getQueryCache().notify({type:"observerOptionsUpdated",query:D(this,Ee),observer:this});const a=this.hasListeners();a&&lp(D(this,Ee),r,this.options,n)&&be(this,Fe,oi).call(this),this.updateResult(),a&&(D(this,Ee)!==r||ms(this.options.enabled,D(this,Ee))!==ms(n.enabled,D(this,Ee))||er(this.options.staleTime,D(this,Ee))!==er(n.staleTime,D(this,Ee)))&&be(this,Fe,id).call(this);const i=be(this,Fe,ld).call(this);a&&(D(this,Ee)!==r||ms(this.options.enabled,D(this,Ee))!==ms(n.enabled,D(this,Ee))||i!==D(this,On))&&be(this,Fe,od).call(this,i)}getOptimisticResult(t){const n=D(this,Ht).getQueryCache().build(D(this,Ht),t),r=this.createResult(n,t);return JN(this,r)&&(re(this,Ot,r),re(this,va,this.options),re(this,Nr,D(this,Ee).state)),r}getCurrentResult(){return D(this,Ot)}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&&D(this,nn).status==="pending"&&D(this,nn).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,a))})}trackProp(t){D(this,Na).add(t)}getCurrentQuery(){return D(this,Ee)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=D(this,Ht).defaultQueryOptions(t),r=D(this,Ht).getQueryCache().build(D(this,Ht),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return be(this,Fe,oi).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),D(this,Ot)))}createResult(t,n){var P;const r=D(this,Ee),a=this.options,i=D(this,Ot),l=D(this,Nr),o=D(this,va),u=t!==r?t.state:D(this,Gi),{state:d}=t;let h={...d},p=!1,m;if(n._optimisticResults){const A=this.hasListeners(),_=!A&&ip(t,n),L=A&&lp(t,r,n,a);(_||L)&&(h={...h,...Ky(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:f,errorUpdatedAt:y,status:N}=h;m=h.data;let v=!1;if(n.placeholderData!==void 0&&m===void 0&&N==="pending"){let A;i!=null&&i.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(A=i.data,v=!0):A=typeof n.placeholderData=="function"?n.placeholderData((P=D(this,ba))==null?void 0:P.state.data,D(this,ba)):n.placeholderData,A!==void 0&&(N="success",m=nd(i==null?void 0:i.data,A,n),p=!0)}if(n.select&&m!==void 0&&!v)if(i&&m===(l==null?void 0:l.data)&&n.select===D(this,Zi))m=D(this,ja);else try{re(this,Zi,n.select),m=n.select(m),m=nd(i==null?void 0:i.data,m,n),re(this,ja,m),re(this,Rn,null)}catch(A){re(this,Rn,A)}D(this,Rn)&&(f=D(this,Rn),m=D(this,ja),y=Date.now(),N="error");const g=h.fetchStatus==="fetching",x=N==="pending",j=N==="error",k=x&&g,F=m!==void 0,S={status:N,fetchStatus:h.fetchStatus,isPending:x,isSuccess:N==="success",isError:j,isInitialLoading:k,isLoading:k,data:m,dataUpdatedAt:h.dataUpdatedAt,error:f,errorUpdatedAt:y,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:g,isRefetching:g&&!x,isLoadingError:j&&!F,isPaused:h.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:j&&F,isStale:Pm(t,n),refetch:this.refetch,promise:D(this,nn),isEnabled:ms(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const A=S.data!==void 0,_=S.status==="error"&&!A,L=O=>{_?O.reject(S.error):A&&O.resolve(S.data)},V=()=>{const O=re(this,nn,S.promise=rd());L(O)},q=D(this,nn);switch(q.status){case"pending":t.queryHash===r.queryHash&&L(q);break;case"fulfilled":(_||S.data!==q.value)&&V();break;case"rejected":(!_||S.error!==q.reason)&&V();break}}return S}updateResult(){const t=D(this,Ot),n=this.createResult(D(this,Ee),this.options);if(re(this,Nr,D(this,Ee).state),re(this,va,this.options),D(this,Nr).data!==void 0&&re(this,ba,D(this,Ee)),Po(n,t))return;re(this,Ot,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!D(this,Na).size)return!0;const l=new Set(i??D(this,Na));return this.options.throwOnError&&l.add("error"),Object.keys(D(this,Ot)).some(o=>{const c=o;return D(this,Ot)[c]!==t[c]&&l.has(c)})};be(this,Fe,qy).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&be(this,Fe,cd).call(this)}},Ht=new WeakMap,Ee=new WeakMap,Gi=new WeakMap,Ot=new WeakMap,Nr=new WeakMap,va=new WeakMap,nn=new WeakMap,Rn=new WeakMap,Zi=new WeakMap,ja=new WeakMap,ba=new WeakMap,wr=new WeakMap,Sr=new WeakMap,On=new WeakMap,Na=new WeakMap,Fe=new WeakSet,oi=function(t){be(this,Fe,md).call(this);let n=D(this,Ee).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Ut)),n},id=function(){be(this,Fe,ud).call(this);const t=er(this.options.staleTime,D(this,Ee));if(Ir||D(this,Ot).isStale||!td(t))return;const r=Oy(D(this,Ot).dataUpdatedAt,t)+1;re(this,wr,fr.setTimeout(()=>{D(this,Ot).isStale||this.updateResult()},r))},ld=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(D(this,Ee)):this.options.refetchInterval)??!1},od=function(t){be(this,Fe,dd).call(this),re(this,On,t),!(Ir||ms(this.options.enabled,D(this,Ee))===!1||!td(D(this,On))||D(this,On)===0)&&re(this,Sr,fr.setInterval(()=>{(this.options.refetchIntervalInBackground||Dm.isFocused())&&be(this,Fe,oi).call(this)},D(this,On)))},cd=function(){be(this,Fe,id).call(this),be(this,Fe,od).call(this,be(this,Fe,ld).call(this))},ud=function(){D(this,wr)&&(fr.clearTimeout(D(this,wr)),re(this,wr,void 0))},dd=function(){D(this,Sr)&&(fr.clearInterval(D(this,Sr)),re(this,Sr,void 0))},md=function(){const t=D(this,Ht).getQueryCache().build(D(this,Ht),this.options);if(t===D(this,Ee))return;const n=D(this,Ee);re(this,Ee,t),re(this,Gi,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},qy=function(t){ft.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(D(this,Ot))}),D(this,Ht).getQueryCache().notify({query:D(this,Ee),type:"observerResultsUpdated"})})},cx);function ZN(e,t){return ms(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function ip(e,t){return ZN(e,t)||e.state.data!==void 0&&hd(e,t,t.refetchOnMount)}function hd(e,t,n){if(ms(t.enabled,e)!==!1&&er(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Pm(e,t)}return!1}function lp(e,t,n,r){return(e!==t||ms(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Pm(e,n)}function Pm(e,t){return ms(t.enabled,e)!==!1&&e.isStaleByTime(er(t.staleTime,e))}function JN(e,t){return!Po(e.getCurrentResult(),t)}function op(e){return{onFetch:(t,n)=>{var d,h,p,m,f;const r=t.options,a=(p=(h=(d=t.fetchOptions)==null?void 0:d.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 u=async()=>{let y=!1;const N=x=>{BN(x,()=>t.signal,()=>y=!0)},v=_y(t.options,t.fetchOptions),g=async(x,j,k)=>{if(y)return Promise.reject();if(j==null&&x.pages.length)return Promise.resolve(x);const E=(()=>{const _={client:t.client,queryKey:t.queryKey,pageParam:j,direction:k?"backward":"forward",meta:t.options.meta};return N(_),_})(),S=await v(E),{maxPages:P}=t.options,A=k?UN:$N;return{pages:A(x.pages,S,P),pageParams:A(x.pageParams,j,P)}};if(a&&i.length){const x=a==="backward",j=x?XN:cp,k={pages:i,pageParams:l},F=j(r,k);o=await g(k,F,x)}else{const x=e??i.length;do{const j=c===0?l[0]??r.initialPageParam:cp(r,o);if(c>0&&j==null)break;o=await g(o,j),c++}while(c<x)}return o};t.options.persister?t.fetchFn=()=>{var y,N;return(N=(y=t.options).persister)==null?void 0:N.call(y,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function cp(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 XN(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 Ji,$s,zt,kr,Us,Cn,ux,YN=(ux=class extends By{constructor(t){super();me(this,Us);me(this,Ji);me(this,$s);me(this,zt);me(this,kr);re(this,Ji,t.client),this.mutationId=t.mutationId,re(this,zt,t.mutationCache),re(this,$s,[]),this.state=t.state||Vy(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){D(this,$s).includes(t)||(D(this,$s).push(t),this.clearGcTimeout(),D(this,zt).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){re(this,$s,D(this,$s).filter(n=>n!==t)),this.scheduleGc(),D(this,zt).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){D(this,$s).length||(this.state.status==="pending"?this.scheduleGc():D(this,zt).remove(this))}continue(){var t;return((t=D(this,kr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,u,d,h,p,m,f,y,N,v,g,x,j,k,F,E,S,P;const n=()=>{be(this,Us,Cn).call(this,{type:"continue"})},r={client:D(this,Ji),meta:this.options.meta,mutationKey:this.options.mutationKey};re(this,kr,Uy({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(A,_)=>{be(this,Us,Cn).call(this,{type:"failed",failureCount:A,error:_})},onPause:()=>{be(this,Us,Cn).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>D(this,zt).canRun(this)}));const a=this.state.status==="pending",i=!D(this,kr).canStart();try{if(a)n();else{be(this,Us,Cn).call(this,{type:"pending",variables:t,isPaused:i}),await((o=(l=D(this,zt).config).onMutate)==null?void 0:o.call(l,t,this,r));const _=await((u=(c=this.options).onMutate)==null?void 0:u.call(c,t,r));_!==this.state.context&&be(this,Us,Cn).call(this,{type:"pending",context:_,variables:t,isPaused:i})}const A=await D(this,kr).start();return await((h=(d=D(this,zt).config).onSuccess)==null?void 0:h.call(d,A,t,this.state.context,this,r)),await((m=(p=this.options).onSuccess)==null?void 0:m.call(p,A,t,this.state.context,r)),await((y=(f=D(this,zt).config).onSettled)==null?void 0:y.call(f,A,null,this.state.variables,this.state.context,this,r)),await((v=(N=this.options).onSettled)==null?void 0:v.call(N,A,null,t,this.state.context,r)),be(this,Us,Cn).call(this,{type:"success",data:A}),A}catch(A){try{await((x=(g=D(this,zt).config).onError)==null?void 0:x.call(g,A,t,this.state.context,this,r))}catch(_){Promise.reject(_)}try{await((k=(j=this.options).onError)==null?void 0:k.call(j,A,t,this.state.context,r))}catch(_){Promise.reject(_)}try{await((E=(F=D(this,zt).config).onSettled)==null?void 0:E.call(F,void 0,A,this.state.variables,this.state.context,this,r))}catch(_){Promise.reject(_)}try{await((P=(S=this.options).onSettled)==null?void 0:P.call(S,void 0,A,t,this.state.context,r))}catch(_){Promise.reject(_)}throw be(this,Us,Cn).call(this,{type:"error",error:A}),A}finally{D(this,zt).runNext(this)}}},Ji=new WeakMap,$s=new WeakMap,zt=new WeakMap,kr=new WeakMap,Us=new WeakSet,Cn=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),ft.batch(()=>{D(this,$s).forEach(r=>{r.onMutationUpdate(t)}),D(this,zt).notify({mutation:this,type:"updated",action:t})})},ux);function Vy(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var rn,ks,Xi,dx,ew=(dx=class extends Ba{constructor(t={}){super();me(this,rn);me(this,ks);me(this,Xi);this.config=t,re(this,rn,new Set),re(this,ks,new Map),re(this,Xi,0)}build(t,n,r){const a=new YN({client:t,mutationCache:this,mutationId:++xl(this,Xi)._,options:t.defaultMutationOptions(n),state:r});return this.add(a),a}add(t){D(this,rn).add(t);const n=Il(t);if(typeof n=="string"){const r=D(this,ks).get(n);r?r.push(t):D(this,ks).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(D(this,rn).delete(t)){const n=Il(t);if(typeof n=="string"){const r=D(this,ks).get(n);if(r)if(r.length>1){const a=r.indexOf(t);a!==-1&&r.splice(a,1)}else r[0]===t&&D(this,ks).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Il(t);if(typeof n=="string"){const r=D(this,ks).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=Il(t);if(typeof n=="string"){const a=(r=D(this,ks).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(){ft.batch(()=>{D(this,rn).forEach(t=>{this.notify({type:"removed",mutation:t})}),D(this,rn).clear(),D(this,ks).clear()})}getAll(){return Array.from(D(this,rn))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>tp(n,r))}findAll(t={}){return this.getAll().filter(n=>tp(t,n))}notify(t){ft.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return ft.batch(()=>Promise.all(t.map(n=>n.continue().catch(Ut))))}},rn=new WeakMap,ks=new WeakMap,Xi=new WeakMap,dx);function Il(e){var t;return(t=e.options.scope)==null?void 0:t.id}var an,zn,Wt,ln,hn,Zl,fd,mx,tw=(mx=class extends Ba{constructor(n,r){super();me(this,hn);me(this,an);me(this,zn);me(this,Wt);me(this,ln);re(this,an,n),this.setOptions(r),this.bindMethods(),be(this,hn,Zl).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=D(this,an).defaultMutationOptions(n),Po(this.options,r)||D(this,an).getMutationCache().notify({type:"observerOptionsUpdated",mutation:D(this,Wt),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Lr(r.mutationKey)!==Lr(this.options.mutationKey)?this.reset():((a=D(this,Wt))==null?void 0:a.state.status)==="pending"&&D(this,Wt).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=D(this,Wt))==null||n.removeObserver(this)}onMutationUpdate(n){be(this,hn,Zl).call(this),be(this,hn,fd).call(this,n)}getCurrentResult(){return D(this,zn)}reset(){var n;(n=D(this,Wt))==null||n.removeObserver(this),re(this,Wt,void 0),be(this,hn,Zl).call(this),be(this,hn,fd).call(this)}mutate(n,r){var a;return re(this,ln,r),(a=D(this,Wt))==null||a.removeObserver(this),re(this,Wt,D(this,an).getMutationCache().build(D(this,an),this.options)),D(this,Wt).addObserver(this),D(this,Wt).execute(n)}},an=new WeakMap,zn=new WeakMap,Wt=new WeakMap,ln=new WeakMap,hn=new WeakSet,Zl=function(){var r;const n=((r=D(this,Wt))==null?void 0:r.state)??Vy();re(this,zn,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},fd=function(n){ft.batch(()=>{var r,a,i,l,o,c,u,d;if(D(this,ln)&&this.hasListeners()){const h=D(this,zn).variables,p=D(this,zn).context,m={client:D(this,an),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(a=(r=D(this,ln)).onSuccess)==null||a.call(r,n.data,h,p,m)}catch(f){Promise.reject(f)}try{(l=(i=D(this,ln)).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=D(this,ln)).onError)==null||c.call(o,n.error,h,p,m)}catch(f){Promise.reject(f)}try{(d=(u=D(this,ln)).onSettled)==null||d.call(u,void 0,n.error,h,p,m)}catch(f){Promise.reject(f)}}}this.listeners.forEach(h=>{h(D(this,zn))})})},mx),Bs,hx,sw=(hx=class extends Ba{constructor(t={}){super();me(this,Bs);this.config=t,re(this,Bs,new Map)}build(t,n,r){const a=n.queryKey,i=n.queryHash??km(a,n);let l=this.get(i);return l||(l=new WN({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(a)}),this.add(l)),l}add(t){D(this,Bs).has(t.queryHash)||(D(this,Bs).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=D(this,Bs).get(t.queryHash);n&&(t.destroy(),n===t&&D(this,Bs).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ft.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return D(this,Bs).get(t)}getAll(){return[...D(this,Bs).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>ep(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>ep(t,r)):n}notify(t){ft.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){ft.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ft.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Bs=new WeakMap,hx),Ye,_n,$n,wa,Sa,Un,ka,Ca,fx,nw=(fx=class{constructor(e={}){me(this,Ye);me(this,_n);me(this,$n);me(this,wa);me(this,Sa);me(this,Un);me(this,ka);me(this,Ca);re(this,Ye,e.queryCache||new sw),re(this,_n,e.mutationCache||new ew),re(this,$n,e.defaultOptions||{}),re(this,wa,new Map),re(this,Sa,new Map),re(this,Un,0)}mount(){xl(this,Un)._++,D(this,Un)===1&&(re(this,ka,Dm.subscribe(async e=>{e&&(await this.resumePausedMutations(),D(this,Ye).onFocus())})),re(this,Ca,Ao.subscribe(async e=>{e&&(await this.resumePausedMutations(),D(this,Ye).onOnline())})))}unmount(){var e,t;xl(this,Un)._--,D(this,Un)===0&&((e=D(this,ka))==null||e.call(this),re(this,ka,void 0),(t=D(this,Ca))==null||t.call(this),re(this,Ca,void 0))}isFetching(e){return D(this,Ye).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return D(this,_n).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=D(this,Ye).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=D(this,Ye).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(er(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return D(this,Ye).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=D(this,Ye).get(r.queryHash),i=a==null?void 0:a.state.data,l=ON(t,i);if(l!==void 0)return D(this,Ye).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return ft.batch(()=>D(this,Ye).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=D(this,Ye).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=D(this,Ye);ft.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=D(this,Ye);return ft.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=ft.batch(()=>D(this,Ye).findAll(e).map(a=>a.cancel(n)));return Promise.all(r).then(Ut).catch(Ut)}invalidateQueries(e,t={}){return ft.batch(()=>(D(this,Ye).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=ft.batch(()=>D(this,Ye).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,n);return n.throwOnError||(i=i.catch(Ut)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Ut)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=D(this,Ye).build(this,t);return n.isStaleByTime(er(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ut).catch(Ut)}fetchInfiniteQuery(e){return e.behavior=op(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ut).catch(Ut)}ensureInfiniteQueryData(e){return e.behavior=op(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Ao.isOnline()?D(this,_n).resumePausedMutations():Promise.resolve()}getQueryCache(){return D(this,Ye)}getMutationCache(){return D(this,_n)}getDefaultOptions(){return D(this,$n)}setDefaultOptions(e){re(this,$n,e)}setQueryDefaults(e,t){D(this,wa).set(Lr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...D(this,wa).values()],n={};return t.forEach(r=>{Ui(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){D(this,Sa).set(Lr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...D(this,Sa).values()],n={};return t.forEach(r=>{Ui(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...D(this,$n).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=km(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===Cm&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...D(this,$n).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){D(this,Ye).clear(),D(this,_n).clear()}},Ye=new WeakMap,_n=new WeakMap,$n=new WeakMap,wa=new WeakMap,Sa=new WeakMap,Un=new WeakMap,ka=new WeakMap,Ca=new WeakMap,fx),Qy=b.createContext(void 0),pe=e=>{const t=b.useContext(Qy);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},rw=({client:e,children:t})=>(b.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Qy.Provider,{value:e,children:t})),Hy=b.createContext(!1),aw=()=>b.useContext(Hy);Hy.Provider;function iw(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var lw=b.createContext(iw()),ow=()=>b.useContext(lw),cw=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Em(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},uw=e=>{b.useEffect(()=>{e.clearReset()},[e])},dw=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(a&&e.data===void 0||Em(n,[e.error,r])),mw=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))}},hw=(e,t)=>e.isLoading&&e.isFetching&&!t,fw=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,up=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function pw(e,t,n){var p,m,f,y;const r=aw(),a=ow(),i=pe(),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",mw(l),cw(l,a,o),uw(a);const c=!i.getQueryCache().get(l.queryHash),[u]=b.useState(()=>new t(i,l)),d=u.getOptimisticResult(l),h=!r&&e.subscribed!==!1;if(b.useSyncExternalStore(b.useCallback(N=>{const v=h?u.subscribe(ft.batchCalls(N)):Ut;return u.updateResult(),v},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),b.useEffect(()=>{u.setOptions(l)},[l,u]),fw(l,d))throw up(l,u,a);if(dw({result:d,errorResetBoundary:a,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw d.error;if((y=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_afterQuery)==null||y.call(f,l,d),l.experimental_prefetchInRender&&!Ir&&hw(d,r)){const N=c?up(l,u,a):o==null?void 0:o.promise;N==null||N.catch(Ut).finally(()=>{u.updateResult()})}return l.notifyOnChangeProps?d:u.trackResult(d)}function he(e,t){return pw(e,GN)}function W(e,t){const n=pe(),[r]=b.useState(()=>new tw(n,e));b.useEffect(()=>{r.setOptions(e)},[r,e]);const a=b.useSyncExternalStore(b.useCallback(l=>r.subscribe(ft.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=b.useCallback((l,o)=>{r.mutate(l,o).catch(Ut)},[r]);if(a.error&&Em(r.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}let xw={data:""},gw=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||xw},yw=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,vw=/\/\*[^]*?\*\/| +/g,dp=/\n+/g,Mn=(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"?Mn(l,i):i+"{"+Mn(l,i[1]=="k"?"":t)+"}":typeof l=="object"?r+=Mn(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+=Mn.p?Mn.p(i,l):i+":"+l+";")}return n+(t&&a?t+"{"+a+"}":a)+r},Js={},Wy=e=>{if(typeof e=="object"){let t="";for(let n in e)t+=n+Wy(e[n]);return t}return e},jw=(e,t,n,r,a)=>{let i=Wy(e),l=Js[i]||(Js[i]=(c=>{let u=0,d=11;for(;u<c.length;)d=101*d+c.charCodeAt(u++)>>>0;return"go"+d})(i));if(!Js[l]){let c=i!==e?e:(u=>{let d,h,p=[{}];for(;d=yw.exec(u.replace(vw,""));)d[4]?p.shift():d[3]?(h=d[3].replace(dp," ").trim(),p.unshift(p[0][h]=p[0][h]||{})):p[0][d[1]]=d[2].replace(dp," ").trim();return p[0]})(e);Js[l]=Mn(a?{["@keyframes "+l]:c}:c,n?"":"."+l)}let o=n&&Js.g?Js.g:null;return n&&(Js.g=Js[l]),((c,u,d,h)=>{h?u.data=u.data.replace(h,c):u.data.indexOf(c)===-1&&(u.data=d?c+u.data:u.data+c)})(Js[l],t,r,o),l},bw=(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?"":Mn(o,""):o===!1?"":o}return r+a+(l??"")},"");function ac(e){let t=this||{},n=e.call?e(t.p):e;return jw(n.unshift?n.raw?bw(n,[].slice.call(arguments,1),t.p):n.reduce((r,a)=>Object.assign(r,a&&a.call?a(t.p):a),{}):n,gw(t.target),t.g,t.o,t.k)}let Gy,pd,xd;ac.bind({g:1});let yn=ac.bind({k:1});function Nw(e,t,n,r){Mn.p=t,Gy=e,pd=n,xd=r}function lr(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:pd&&pd()},o),n.o=/ *go\d+/.test(c),o.className=ac.apply(n,r)+(c?" "+c:"");let u=e;return e[0]&&(u=o.as||e,delete o.as),xd&&u[0]&&xd(o),Gy(u,o)}return a}}var ww=e=>typeof e=="function",Mo=(e,t)=>ww(e)?e(t):e,Sw=(()=>{let e=0;return()=>(++e).toString()})(),Zy=(()=>{let e;return()=>{if(e===void 0&&typeof window<"u"){let t=matchMedia("(prefers-reduced-motion: reduce)");e=!t||t.matches}return e}})(),kw=20,Am="default",Jy=(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 Jy(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}))}}},Jl=[],Xy={toasts:[],pausedAt:void 0,settings:{toastLimit:kw}},qs={},Yy=(e,t=Am)=>{qs[t]=Jy(qs[t]||Xy,e),Jl.forEach(([n,r])=>{n===t&&r(qs[t])})},e0=e=>Object.keys(qs).forEach(t=>Yy(e,t)),Cw=e=>Object.keys(qs).find(t=>qs[t].toasts.some(n=>n.id===e)),ic=(e=Am)=>t=>{Yy(t,e)},Ew={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},Dw=(e={},t=Am)=>{let[n,r]=b.useState(qs[t]||Xy),a=b.useRef(qs[t]);b.useEffect(()=>(a.current!==qs[t]&&r(qs[t]),Jl.push([t,r]),()=>{let l=Jl.findIndex(([o])=>o===t);l>-1&&Jl.splice(l,1)}),[t]);let i=n.toasts.map(l=>{var o,c,u;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)||Ew[l.type],style:{...e.style,...(u=e[l.type])==null?void 0:u.style,...l.style}}});return{...n,toasts:i}},Pw=(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)||Sw()}),rl=e=>(t,n)=>{let r=Pw(t,e,n);return ic(r.toasterId||Cw(r.id))({type:2,toast:r}),r.id},pt=(e,t)=>rl("blank")(e,t);pt.error=rl("error");pt.success=rl("success");pt.loading=rl("loading");pt.custom=rl("custom");pt.dismiss=(e,t)=>{let n={type:3,toastId:e};t?ic(t)(n):e0(n)};pt.dismissAll=e=>pt.dismiss(void 0,e);pt.remove=(e,t)=>{let n={type:4,toastId:e};t?ic(t)(n):e0(n)};pt.removeAll=e=>pt.remove(void 0,e);pt.promise=(e,t,n)=>{let r=pt.loading(t.loading,{...n,...n==null?void 0:n.loading});return typeof e=="function"&&(e=e()),e.then(a=>{let i=t.success?Mo(t.success,a):void 0;return i?pt.success(i,{id:r,...n,...n==null?void 0:n.success}):pt.dismiss(r),a}).catch(a=>{let i=t.error?Mo(t.error,a):void 0;i?pt.error(i,{id:r,...n,...n==null?void 0:n.error}):pt.dismiss(r)}),e};var Aw=1e3,Mw=(e,t="default")=>{let{toasts:n,pausedAt:r}=Dw(e,t),a=b.useRef(new Map).current,i=b.useCallback((h,p=Aw)=>{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&&pt.dismiss(m.id);return}return setTimeout(()=>pt.dismiss(m.id,t),f)});return()=>{p.forEach(m=>m&&clearTimeout(m))}},[n,r,t]);let l=b.useCallback(ic(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]),u=b.useCallback(()=>{r&&l({type:6,time:Date.now()})},[r,l]),d=b.useCallback((h,p)=>{let{reverseOrder:m=!1,gutter:f=8,defaultPosition:y}=p||{},N=n.filter(x=>(x.position||y)===(h.position||y)&&x.height),v=N.findIndex(x=>x.id===h.id),g=N.filter((x,j)=>j<v&&x.visible).length;return N.filter(x=>x.visible).slice(...m?[g+1]:[0,g]).reduce((x,j)=>x+(j.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:u,calculateOffset:d}}},Tw=yn`
|
||
from {
|
||
transform: scale(0) rotate(45deg);
|
||
opacity: 0;
|
||
}
|
||
to {
|
||
transform: scale(1) rotate(45deg);
|
||
opacity: 1;
|
||
}`,Fw=yn`
|
||
from {
|
||
transform: scale(0);
|
||
opacity: 0;
|
||
}
|
||
to {
|
||
transform: scale(1);
|
||
opacity: 1;
|
||
}`,Iw=yn`
|
||
from {
|
||
transform: scale(0) rotate(90deg);
|
||
opacity: 0;
|
||
}
|
||
to {
|
||
transform: scale(1) rotate(90deg);
|
||
opacity: 1;
|
||
}`,Lw=lr("div")`
|
||
width: 20px;
|
||
opacity: 0;
|
||
height: 20px;
|
||
border-radius: 10px;
|
||
background: ${e=>e.primary||"#ff4b4b"};
|
||
position: relative;
|
||
transform: rotate(45deg);
|
||
|
||
animation: ${Tw} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)
|
||
forwards;
|
||
animation-delay: 100ms;
|
||
|
||
&:after,
|
||
&:before {
|
||
content: '';
|
||
animation: ${Fw} 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: ${Iw} 0.15s ease-out forwards;
|
||
animation-delay: 180ms;
|
||
transform: rotate(90deg);
|
||
}
|
||
`,Rw=yn`
|
||
from {
|
||
transform: rotate(0deg);
|
||
}
|
||
to {
|
||
transform: rotate(360deg);
|
||
}
|
||
`,Ow=lr("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: ${Rw} 1s linear infinite;
|
||
`,zw=yn`
|
||
from {
|
||
transform: scale(0) rotate(45deg);
|
||
opacity: 0;
|
||
}
|
||
to {
|
||
transform: scale(1) rotate(45deg);
|
||
opacity: 1;
|
||
}`,_w=yn`
|
||
0% {
|
||
height: 0;
|
||
width: 0;
|
||
opacity: 0;
|
||
}
|
||
40% {
|
||
height: 0;
|
||
width: 6px;
|
||
opacity: 1;
|
||
}
|
||
100% {
|
||
opacity: 1;
|
||
height: 10px;
|
||
}`,$w=lr("div")`
|
||
width: 20px;
|
||
opacity: 0;
|
||
height: 20px;
|
||
border-radius: 10px;
|
||
background: ${e=>e.primary||"#61d345"};
|
||
position: relative;
|
||
transform: rotate(45deg);
|
||
|
||
animation: ${zw} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)
|
||
forwards;
|
||
animation-delay: 100ms;
|
||
&:after {
|
||
content: '';
|
||
box-sizing: border-box;
|
||
animation: ${_w} 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;
|
||
}
|
||
`,Uw=lr("div")`
|
||
position: absolute;
|
||
`,Bw=lr("div")`
|
||
position: relative;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
min-width: 20px;
|
||
min-height: 20px;
|
||
`,Kw=yn`
|
||
from {
|
||
transform: scale(0.6);
|
||
opacity: 0.4;
|
||
}
|
||
to {
|
||
transform: scale(1);
|
||
opacity: 1;
|
||
}`,qw=lr("div")`
|
||
position: relative;
|
||
transform: scale(0.6);
|
||
opacity: 0.4;
|
||
min-width: 20px;
|
||
animation: ${Kw} 0.3s 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275)
|
||
forwards;
|
||
`,Vw=({toast:e})=>{let{icon:t,type:n,iconTheme:r}=e;return t!==void 0?typeof t=="string"?b.createElement(qw,null,t):t:n==="blank"?null:b.createElement(Bw,null,b.createElement(Ow,{...r}),n!=="loading"&&b.createElement(Uw,null,n==="error"?b.createElement(Lw,{...r}):b.createElement($w,{...r})))},Qw=e=>`
|
||
0% {transform: translate3d(0,${e*-200}%,0) scale(.6); opacity:.5;}
|
||
100% {transform: translate3d(0,0,0) scale(1); opacity:1;}
|
||
`,Hw=e=>`
|
||
0% {transform: translate3d(0,0,-1px) scale(1); opacity:1;}
|
||
100% {transform: translate3d(0,${e*-150}%,-1px) scale(.6); opacity:0;}
|
||
`,Ww="0%{opacity:0;} 100%{opacity:1;}",Gw="0%{opacity:1;} 100%{opacity:0;}",Zw=lr("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;
|
||
`,Jw=lr("div")`
|
||
display: flex;
|
||
justify-content: center;
|
||
margin: 4px 10px;
|
||
color: inherit;
|
||
flex: 1 1 auto;
|
||
white-space: pre-line;
|
||
`,Xw=(e,t)=>{let n=e.includes("top")?1:-1,[r,a]=Zy()?[Ww,Gw]:[Qw(n),Hw(n)];return{animation:t?`${yn(r)} 0.35s cubic-bezier(.21,1.02,.73,1) forwards`:`${yn(a)} 0.4s forwards cubic-bezier(.06,.71,.55,1)`}},Yw=b.memo(({toast:e,position:t,style:n,children:r})=>{let a=e.height?Xw(e.position||t||"top-center",e.visible):{opacity:0},i=b.createElement(Vw,{toast:e}),l=b.createElement(Jw,{...e.ariaProps},Mo(e.message,e));return b.createElement(Zw,{className:e.className,style:{...a,...n,...e.style}},typeof r=="function"?r({icon:i,message:l}):b.createElement(b.Fragment,null,i,l))});Nw(b.createElement);var e1=({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)},t1=(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:Zy()?void 0:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:`translateY(${t*(n?1:-1)}px)`,...r,...a}},s1=ac`
|
||
z-index: 9999;
|
||
> * {
|
||
pointer-events: auto;
|
||
}
|
||
`,Ll=16,n1=({reverseOrder:e,position:t="top-center",toastOptions:n,gutter:r,children:a,toasterId:i,containerStyle:l,containerClassName:o})=>{let{toasts:c,handlers:u}=Mw(n,i);return b.createElement("div",{"data-rht-toaster":i||"",style:{position:"fixed",zIndex:9999,top:Ll,left:Ll,right:Ll,bottom:Ll,pointerEvents:"none",...l},className:o,onMouseEnter:u.startPause,onMouseLeave:u.endPause},c.map(d=>{let h=d.position||t,p=u.calculateOffset(d,{reverseOrder:e,gutter:r,defaultPosition:t}),m=t1(h,p);return b.createElement(e1,{id:d.id,key:d.id,onHeightUpdate:u.updateHeight,className:d.visible?s1:"",style:m},d.type==="custom"?Mo(d.message,d):a?a(d):b.createElement(Yw,{toast:d,position:h}))}))},ps=pt;function t0(e,t){return function(){return e.apply(t,arguments)}}const{toString:r1}=Object.prototype,{getPrototypeOf:Mm}=Object,{iterator:lc,toStringTag:s0}=Symbol,oc=(e=>t=>{const n=r1.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ls=e=>(e=e.toLowerCase(),t=>oc(t)===e),cc=e=>t=>typeof t===e,{isArray:Ka}=Array,La=cc("undefined");function al(e){return e!==null&&!La(e)&&e.constructor!==null&&!La(e.constructor)&&ts(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const n0=Ls("ArrayBuffer");function a1(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&n0(e.buffer),t}const i1=cc("string"),ts=cc("function"),r0=cc("number"),il=e=>e!==null&&typeof e=="object",l1=e=>e===!0||e===!1,Xl=e=>{if(oc(e)!=="object")return!1;const t=Mm(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(s0 in e)&&!(lc in e)},o1=e=>{if(!il(e)||al(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},c1=Ls("Date"),u1=Ls("File"),d1=Ls("Blob"),m1=Ls("FileList"),h1=e=>il(e)&&ts(e.pipe),f1=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||ts(e.append)&&((t=oc(e))==="formdata"||t==="object"&&ts(e.toString)&&e.toString()==="[object FormData]"))},p1=Ls("URLSearchParams"),[x1,g1,y1,v1]=["ReadableStream","Request","Response","Headers"].map(Ls),j1=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ll(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,a;if(typeof e!="object"&&(e=[e]),Ka(e))for(r=0,a=e.length;r<a;r++)t.call(null,e[r],r,e);else{if(al(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 a0(e,t){if(al(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 pr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,i0=e=>!La(e)&&e!==pr;function gd(){const{caseless:e,skipUndefined:t}=i0(this)&&this||{},n={},r=(a,i)=>{const l=e&&a0(n,i)||i;Xl(n[l])&&Xl(a)?n[l]=gd(n[l],a):Xl(a)?n[l]=gd({},a):Ka(a)?n[l]=a.slice():(!t||!La(a))&&(n[l]=a)};for(let a=0,i=arguments.length;a<i;a++)arguments[a]&&ll(arguments[a],r);return n}const b1=(e,t,n,{allOwnKeys:r}={})=>(ll(t,(a,i)=>{n&&ts(a)?e[i]=t0(a,n):e[i]=a},{allOwnKeys:r}),e),N1=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),w1=(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)},S1=(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&&Mm(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},k1=(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},C1=e=>{if(!e)return null;if(Ka(e))return e;let t=e.length;if(!r0(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},E1=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Mm(Uint8Array)),D1=(e,t)=>{const r=(e&&e[lc]).call(e);let a;for(;(a=r.next())&&!a.done;){const i=a.value;t.call(e,i[0],i[1])}},P1=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},A1=Ls("HTMLFormElement"),M1=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,a){return r.toUpperCase()+a}),mp=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),T1=Ls("RegExp"),l0=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};ll(n,(a,i)=>{let l;(l=t(a,i,e))!==!1&&(r[i]=l||a)}),Object.defineProperties(e,r)},F1=e=>{l0(e,(t,n)=>{if(ts(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(ts(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+"'")})}})},I1=(e,t)=>{const n={},r=a=>{a.forEach(i=>{n[i]=!0})};return Ka(e)?r(e):r(String(e).split(t)),n},L1=()=>{},R1=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function O1(e){return!!(e&&ts(e.append)&&e[s0]==="FormData"&&e[lc])}const z1=e=>{const t=new Array(10),n=(r,a)=>{if(il(r)){if(t.indexOf(r)>=0)return;if(al(r))return r;if(!("toJSON"in r)){t[a]=r;const i=Ka(r)?[]:{};return ll(r,(l,o)=>{const c=n(l,a+1);!La(c)&&(i[o]=c)}),t[a]=void 0,i}}return r};return n(e,0)},_1=Ls("AsyncFunction"),$1=e=>e&&(il(e)||ts(e))&&ts(e.then)&&ts(e.catch),o0=((e,t)=>e?setImmediate:t?((n,r)=>(pr.addEventListener("message",({source:a,data:i})=>{a===pr&&i===n&&r.length&&r.shift()()},!1),a=>{r.push(a),pr.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",ts(pr.postMessage)),U1=typeof queueMicrotask<"u"?queueMicrotask.bind(pr):typeof process<"u"&&process.nextTick||o0,B1=e=>e!=null&&ts(e[lc]),U={isArray:Ka,isArrayBuffer:n0,isBuffer:al,isFormData:f1,isArrayBufferView:a1,isString:i1,isNumber:r0,isBoolean:l1,isObject:il,isPlainObject:Xl,isEmptyObject:o1,isReadableStream:x1,isRequest:g1,isResponse:y1,isHeaders:v1,isUndefined:La,isDate:c1,isFile:u1,isBlob:d1,isRegExp:T1,isFunction:ts,isStream:h1,isURLSearchParams:p1,isTypedArray:E1,isFileList:m1,forEach:ll,merge:gd,extend:b1,trim:j1,stripBOM:N1,inherits:w1,toFlatObject:S1,kindOf:oc,kindOfTest:Ls,endsWith:k1,toArray:C1,forEachEntry:D1,matchAll:P1,isHTMLForm:A1,hasOwnProperty:mp,hasOwnProp:mp,reduceDescriptors:l0,freezeMethods:F1,toObjectSet:I1,toCamelCase:M1,noop:L1,toFiniteNumber:R1,findKey:a0,global:pr,isContextDefined:i0,isSpecCompliantForm:O1,toJSONObject:z1,isAsyncFn:_1,isThenable:$1,setImmediate:o0,asap:U1,isIterable:B1};function je(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)}U.inherits(je,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:U.toJSONObject(this.config),code:this.code,status:this.status}}});const c0=je.prototype,u0={};["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=>{u0[e]={value:e}});Object.defineProperties(je,u0);Object.defineProperty(c0,"isAxiosError",{value:!0});je.from=(e,t,n,r,a,i)=>{const l=Object.create(c0);U.toFlatObject(e,l,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const o=e&&e.message?e.message:"Error",c=t==null&&e?e.code:t;return je.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 K1=null;function yd(e){return U.isPlainObject(e)||U.isArray(e)}function d0(e){return U.endsWith(e,"[]")?e.slice(0,-2):e}function hp(e,t,n){return e?e.concat(t).map(function(a,i){return a=d0(a),!n&&i?"["+a+"]":a}).join(n?".":""):t}function q1(e){return U.isArray(e)&&!e.some(yd)}const V1=U.toFlatObject(U,{},null,function(t){return/^is[A-Z]/.test(t)});function uc(e,t,n){if(!U.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=U.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,N){return!U.isUndefined(N[y])});const r=n.metaTokens,a=n.visitor||d,i=n.dots,l=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&U.isSpecCompliantForm(t);if(!U.isFunction(a))throw new TypeError("visitor must be a function");function u(f){if(f===null)return"";if(U.isDate(f))return f.toISOString();if(U.isBoolean(f))return f.toString();if(!c&&U.isBlob(f))throw new je("Blob is not supported. Use a Buffer instead.");return U.isArrayBuffer(f)||U.isTypedArray(f)?c&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function d(f,y,N){let v=f;if(f&&!N&&typeof f=="object"){if(U.endsWith(y,"{}"))y=r?y:y.slice(0,-2),f=JSON.stringify(f);else if(U.isArray(f)&&q1(f)||(U.isFileList(f)||U.endsWith(y,"[]"))&&(v=U.toArray(f)))return y=d0(y),v.forEach(function(x,j){!(U.isUndefined(x)||x===null)&&t.append(l===!0?hp([y],j,i):l===null?y:y+"[]",u(x))}),!1}return yd(f)?!0:(t.append(hp(N,y,i),u(f)),!1)}const h=[],p=Object.assign(V1,{defaultVisitor:d,convertValue:u,isVisitable:yd});function m(f,y){if(!U.isUndefined(f)){if(h.indexOf(f)!==-1)throw Error("Circular reference detected in "+y.join("."));h.push(f),U.forEach(f,function(v,g){(!(U.isUndefined(v)||v===null)&&a.call(t,v,U.isString(g)?g.trim():g,y,p))===!0&&m(v,y?y.concat(g):[g])}),h.pop()}}if(!U.isObject(e))throw new TypeError("data must be an object");return m(e),t}function fp(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Tm(e,t){this._pairs=[],e&&uc(e,this,t)}const m0=Tm.prototype;m0.append=function(t,n){this._pairs.push([t,n])};m0.toString=function(t){const n=t?function(r){return t.call(this,r,fp)}:fp;return this._pairs.map(function(a){return n(a[0])+"="+n(a[1])},"").join("&")};function Q1(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function h0(e,t,n){if(!t)return e;const r=n&&n.encode||Q1;U.isFunction(n)&&(n={serialize:n});const a=n&&n.serialize;let i;if(a?i=a(t,n):i=U.isURLSearchParams(t)?t.toString():new Tm(t,n).toString(r),i){const l=e.indexOf("#");l!==-1&&(e=e.slice(0,l)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class pp{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){U.forEach(this.handlers,function(r){r!==null&&t(r)})}}const f0={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},H1=typeof URLSearchParams<"u"?URLSearchParams:Tm,W1=typeof FormData<"u"?FormData:null,G1=typeof Blob<"u"?Blob:null,Z1={isBrowser:!0,classes:{URLSearchParams:H1,FormData:W1,Blob:G1},protocols:["http","https","file","blob","url","data"]},Fm=typeof window<"u"&&typeof document<"u",vd=typeof navigator=="object"&&navigator||void 0,J1=Fm&&(!vd||["ReactNative","NativeScript","NS"].indexOf(vd.product)<0),X1=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Y1=Fm&&window.location.href||"http://localhost",e2=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Fm,hasStandardBrowserEnv:J1,hasStandardBrowserWebWorkerEnv:X1,navigator:vd,origin:Y1},Symbol.toStringTag,{value:"Module"})),It={...e2,...Z1};function t2(e,t){return uc(e,new It.classes.URLSearchParams,{visitor:function(n,r,a,i){return It.isNode&&U.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}function s2(e){return U.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function n2(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 p0(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&&U.isArray(a)?a.length:l,c?(U.hasOwnProp(a,l)?a[l]=[a[l],r]:a[l]=r,!o):((!a[l]||!U.isObject(a[l]))&&(a[l]=[]),t(n,r,a[l],i)&&U.isArray(a[l])&&(a[l]=n2(a[l])),!o)}if(U.isFormData(e)&&U.isFunction(e.entries)){const n={};return U.forEachEntry(e,(r,a)=>{t(s2(r),a,n,0)}),n}return null}function r2(e,t,n){if(U.isString(e))try{return(t||JSON.parse)(e),U.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const ol={transitional:f0,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",a=r.indexOf("application/json")>-1,i=U.isObject(t);if(i&&U.isHTMLForm(t)&&(t=new FormData(t)),U.isFormData(t))return a?JSON.stringify(p0(t)):t;if(U.isArrayBuffer(t)||U.isBuffer(t)||U.isStream(t)||U.isFile(t)||U.isBlob(t)||U.isReadableStream(t))return t;if(U.isArrayBufferView(t))return t.buffer;if(U.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 t2(t,this.formSerializer).toString();if((o=U.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return uc(o?{"files[]":t}:t,c&&new c,this.formSerializer)}}return i||a?(n.setContentType("application/json",!1),r2(t)):t}],transformResponse:[function(t){const n=this.transitional||ol.transitional,r=n&&n.forcedJSONParsing,a=this.responseType==="json";if(U.isResponse(t)||U.isReadableStream(t))return t;if(t&&U.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"?je.from(o,je.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:It.classes.FormData,Blob:It.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};U.forEach(["delete","get","head","post","put","patch"],e=>{ol.headers[e]={}});const a2=U.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"]),i2=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]&&a2[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},xp=Symbol("internals");function si(e){return e&&String(e).trim().toLowerCase()}function Yl(e){return e===!1||e==null?e:U.isArray(e)?e.map(Yl):String(e)}function l2(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 o2=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Wc(e,t,n,r,a){if(U.isFunction(r))return r.call(this,t,n);if(a&&(t=n),!!U.isString(t)){if(U.isString(r))return t.indexOf(r)!==-1;if(U.isRegExp(r))return r.test(t)}}function c2(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function u2(e,t){const n=U.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 ss=class{constructor(t){t&&this.set(t)}set(t,n,r){const a=this;function i(o,c,u){const d=si(c);if(!d)throw new Error("header name must be a non-empty string");const h=U.findKey(a,d);(!h||a[h]===void 0||u===!0||u===void 0&&a[h]!==!1)&&(a[h||c]=Yl(o))}const l=(o,c)=>U.forEach(o,(u,d)=>i(u,d,c));if(U.isPlainObject(t)||t instanceof this.constructor)l(t,n);else if(U.isString(t)&&(t=t.trim())&&!o2(t))l(i2(t),n);else if(U.isObject(t)&&U.isIterable(t)){let o={},c,u;for(const d of t){if(!U.isArray(d))throw TypeError("Object iterator must return a key-value pair");o[u=d[0]]=(c=o[u])?U.isArray(c)?[...c,d[1]]:[c,d[1]]:d[1]}l(o,n)}else t!=null&&i(n,t,r);return this}get(t,n){if(t=si(t),t){const r=U.findKey(this,t);if(r){const a=this[r];if(!n)return a;if(n===!0)return l2(a);if(U.isFunction(n))return n.call(this,a,r);if(U.isRegExp(n))return n.exec(a);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=si(t),t){const r=U.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Wc(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let a=!1;function i(l){if(l=si(l),l){const o=U.findKey(r,l);o&&(!n||Wc(r,r[o],o,n))&&(delete r[o],a=!0)}}return U.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||Wc(this,this[i],i,t,!0))&&(delete this[i],a=!0)}return a}normalize(t){const n=this,r={};return U.forEach(this,(a,i)=>{const l=U.findKey(r,i);if(l){n[l]=Yl(a),delete n[i];return}const o=t?c2(i):String(i).trim();o!==i&&delete n[i],n[o]=Yl(a),r[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return U.forEach(this,(r,a)=>{r!=null&&r!==!1&&(n[a]=t&&U.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[xp]=this[xp]={accessors:{}}).accessors,a=this.prototype;function i(l){const o=si(l);r[o]||(u2(a,l),r[o]=!0)}return U.isArray(t)?t.forEach(i):i(t),this}};ss.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);U.reduceDescriptors(ss.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});U.freezeMethods(ss);function Gc(e,t){const n=this||ol,r=t||n,a=ss.from(r.headers);let i=r.data;return U.forEach(e,function(o){i=o.call(n,i,a.normalize(),t?t.status:void 0)}),a.normalize(),i}function x0(e){return!!(e&&e.__CANCEL__)}function qa(e,t,n){je.call(this,e??"canceled",je.ERR_CANCELED,t,n),this.name="CanceledError"}U.inherits(qa,je,{__CANCEL__:!0});function g0(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new je("Request failed with status code "+n.status,[je.ERR_BAD_REQUEST,je.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function d2(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function m2(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 u=Date.now(),d=r[i];l||(l=u),n[a]=c,r[a]=u;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),u-l<t)return;const m=d&&u-d;return m?Math.round(p*1e3/m):void 0}}function h2(e,t){let n=0,r=1e3/t,a,i;const l=(u,d=Date.now())=>{n=d,a=null,i&&(clearTimeout(i),i=null),e(...u)};return[(...u)=>{const d=Date.now(),h=d-n;h>=r?l(u,d):(a=u,i||(i=setTimeout(()=>{i=null,l(a)},r-h)))},()=>a&&l(a)]}const To=(e,t,n=3)=>{let r=0;const a=m2(50,250);return h2(i=>{const l=i.loaded,o=i.lengthComputable?i.total:void 0,c=l-r,u=a(c),d=l<=o;r=l;const h={loaded:l,total:o,progress:o?l/o:void 0,bytes:c,rate:u||void 0,estimated:u&&o&&d?(o-l)/u:void 0,event:i,lengthComputable:o!=null,[t?"download":"upload"]:!0};e(h)},n)},gp=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},yp=e=>(...t)=>U.asap(()=>e(...t)),f2=It.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,It.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(It.origin),It.navigator&&/(msie|trident)/i.test(It.navigator.userAgent)):()=>!0,p2=It.hasStandardBrowserEnv?{write(e,t,n,r,a,i,l){if(typeof document>"u")return;const o=[`${e}=${encodeURIComponent(t)}`];U.isNumber(n)&&o.push(`expires=${new Date(n).toUTCString()}`),U.isString(r)&&o.push(`path=${r}`),U.isString(a)&&o.push(`domain=${a}`),i===!0&&o.push("secure"),U.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 x2(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function g2(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function y0(e,t,n){let r=!x2(t);return e&&(r||n==!1)?g2(e,t):t}const vp=e=>e instanceof ss?{...e}:e;function Rr(e,t){t=t||{};const n={};function r(u,d,h,p){return U.isPlainObject(u)&&U.isPlainObject(d)?U.merge.call({caseless:p},u,d):U.isPlainObject(d)?U.merge({},d):U.isArray(d)?d.slice():d}function a(u,d,h,p){if(U.isUndefined(d)){if(!U.isUndefined(u))return r(void 0,u,h,p)}else return r(u,d,h,p)}function i(u,d){if(!U.isUndefined(d))return r(void 0,d)}function l(u,d){if(U.isUndefined(d)){if(!U.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function o(u,d,h){if(h in t)return r(u,d);if(h in e)return r(void 0,u)}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:(u,d,h)=>a(vp(u),vp(d),h,!0)};return U.forEach(Object.keys({...e,...t}),function(d){const h=c[d]||a,p=h(e[d],t[d],d);U.isUndefined(p)&&h!==o||(n[d]=p)}),n}const v0=e=>{const t=Rr({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:a,xsrfCookieName:i,headers:l,auth:o}=t;if(t.headers=l=ss.from(l),t.url=h0(y0(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),o&&l.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),U.isFormData(n)){if(It.hasStandardBrowserEnv||It.hasStandardBrowserWebWorkerEnv)l.setContentType(void 0);else if(U.isFunction(n.getHeaders)){const c=n.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([d,h])=>{u.includes(d.toLowerCase())&&l.set(d,h)})}}if(It.hasStandardBrowserEnv&&(r&&U.isFunction(r)&&(r=r(t)),r||r!==!1&&f2(t.url))){const c=a&&i&&p2.read(i);c&&l.set(a,c)}return t},y2=typeof XMLHttpRequest<"u",v2=y2&&function(e){return new Promise(function(n,r){const a=v0(e);let i=a.data;const l=ss.from(a.headers).normalize();let{responseType:o,onUploadProgress:c,onDownloadProgress:u}=a,d,h,p,m,f;function y(){m&&m(),f&&f(),a.cancelToken&&a.cancelToken.unsubscribe(d),a.signal&&a.signal.removeEventListener("abort",d)}let N=new XMLHttpRequest;N.open(a.method.toUpperCase(),a.url,!0),N.timeout=a.timeout;function v(){if(!N)return;const x=ss.from("getAllResponseHeaders"in N&&N.getAllResponseHeaders()),k={data:!o||o==="text"||o==="json"?N.responseText:N.response,status:N.status,statusText:N.statusText,headers:x,config:e,request:N};g0(function(E){n(E),y()},function(E){r(E),y()},k),N=null}"onloadend"in N?N.onloadend=v:N.onreadystatechange=function(){!N||N.readyState!==4||N.status===0&&!(N.responseURL&&N.responseURL.indexOf("file:")===0)||setTimeout(v)},N.onabort=function(){N&&(r(new je("Request aborted",je.ECONNABORTED,e,N)),N=null)},N.onerror=function(j){const k=j&&j.message?j.message:"Network Error",F=new je(k,je.ERR_NETWORK,e,N);F.event=j||null,r(F),N=null},N.ontimeout=function(){let j=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const k=a.transitional||f0;a.timeoutErrorMessage&&(j=a.timeoutErrorMessage),r(new je(j,k.clarifyTimeoutError?je.ETIMEDOUT:je.ECONNABORTED,e,N)),N=null},i===void 0&&l.setContentType(null),"setRequestHeader"in N&&U.forEach(l.toJSON(),function(j,k){N.setRequestHeader(k,j)}),U.isUndefined(a.withCredentials)||(N.withCredentials=!!a.withCredentials),o&&o!=="json"&&(N.responseType=a.responseType),u&&([p,f]=To(u,!0),N.addEventListener("progress",p)),c&&N.upload&&([h,m]=To(c),N.upload.addEventListener("progress",h),N.upload.addEventListener("loadend",m)),(a.cancelToken||a.signal)&&(d=x=>{N&&(r(!x||x.type?new qa(null,e,N):x),N.abort(),N=null)},a.cancelToken&&a.cancelToken.subscribe(d),a.signal&&(a.signal.aborted?d():a.signal.addEventListener("abort",d)));const g=d2(a.url);if(g&&It.protocols.indexOf(g)===-1){r(new je("Unsupported protocol "+g+":",je.ERR_BAD_REQUEST,e));return}N.send(i||null)})},j2=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,a;const i=function(u){if(!a){a=!0,o();const d=u instanceof Error?u:this.reason;r.abort(d instanceof je?d:new qa(d instanceof Error?d.message:d))}};let l=t&&setTimeout(()=>{l=null,i(new je(`timeout ${t} of ms exceeded`,je.ETIMEDOUT))},t);const o=()=>{e&&(l&&clearTimeout(l),l=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),e=null)};e.forEach(u=>u.addEventListener("abort",i));const{signal:c}=r;return c.unsubscribe=()=>U.asap(o),c}},b2=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},N2=async function*(e,t){for await(const n of w2(e))yield*b2(n,t)},w2=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()}},jp=(e,t,n,r)=>{const a=N2(e,t);let i=0,l,o=c=>{l||(l=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:u,value:d}=await a.next();if(u){o(),c.close();return}let h=d.byteLength;if(n){let p=i+=h;n(p)}c.enqueue(new Uint8Array(d))}catch(u){throw o(u),u}},cancel(c){return o(c),a.return()}},{highWaterMark:2})},bp=64*1024,{isFunction:Rl}=U,S2=(({Request:e,Response:t})=>({Request:e,Response:t}))(U.global),{ReadableStream:Np,TextEncoder:wp}=U.global,Sp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},k2=e=>{e=U.merge.call({skipUndefined:!0},S2,e);const{fetch:t,Request:n,Response:r}=e,a=t?Rl(t):typeof fetch=="function",i=Rl(n),l=Rl(r);if(!a)return!1;const o=a&&Rl(Np),c=a&&(typeof wp=="function"?(f=>y=>f.encode(y))(new wp):async f=>new Uint8Array(await new n(f).arrayBuffer())),u=i&&o&&Sp(()=>{let f=!1;const y=new n(It.origin,{body:new Np,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!y}),d=l&&o&&Sp(()=>U.isReadableStream(new r("").body)),h={stream:d&&(f=>f.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!h[f]&&(h[f]=(y,N)=>{let v=y&&y[f];if(v)return v.call(y);throw new je(`Response type '${f}' is not supported`,je.ERR_NOT_SUPPORT,N)})});const p=async f=>{if(f==null)return 0;if(U.isBlob(f))return f.size;if(U.isSpecCompliantForm(f))return(await new n(It.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(U.isArrayBufferView(f)||U.isArrayBuffer(f))return f.byteLength;if(U.isURLSearchParams(f)&&(f=f+""),U.isString(f))return(await c(f)).byteLength},m=async(f,y)=>{const N=U.toFiniteNumber(f.getContentLength());return N??p(y)};return async f=>{let{url:y,method:N,data:v,signal:g,cancelToken:x,timeout:j,onDownloadProgress:k,onUploadProgress:F,responseType:E,headers:S,withCredentials:P="same-origin",fetchOptions:A}=v0(f),_=t||fetch;E=E?(E+"").toLowerCase():"text";let L=j2([g,x&&x.toAbortSignal()],j),V=null;const q=L&&L.unsubscribe&&(()=>{L.unsubscribe()});let O;try{if(F&&u&&N!=="get"&&N!=="head"&&(O=await m(S,v))!==0){let fe=new n(y,{method:"POST",body:v,duplex:"half"}),ue;if(U.isFormData(v)&&(ue=fe.headers.get("content-type"))&&S.setContentType(ue),fe.body){const[nt,H]=gp(O,To(yp(F)));v=jp(fe.body,bp,nt,H)}}U.isString(P)||(P=P?"include":"omit");const C=i&&"credentials"in n.prototype,w={...A,signal:L,method:N.toUpperCase(),headers:S.normalize().toJSON(),body:v,duplex:"half",credentials:C?P:void 0};V=i&&new n(y,w);let R=await(i?_(V,A):_(y,w));const Q=d&&(E==="stream"||E==="response");if(d&&(k||Q&&q)){const fe={};["status","statusText","headers"].forEach(ke=>{fe[ke]=R[ke]});const ue=U.toFiniteNumber(R.headers.get("content-length")),[nt,H]=k&&gp(ue,To(yp(k),!0))||[];R=new r(jp(R.body,bp,nt,()=>{H&&H(),q&&q()}),fe)}E=E||"text";let ee=await h[U.findKey(h,E)||"text"](R,f);return!Q&&q&&q(),await new Promise((fe,ue)=>{g0(fe,ue,{data:ee,headers:ss.from(R.headers),status:R.status,statusText:R.statusText,config:f,request:V})})}catch(C){throw q&&q(),C&&C.name==="TypeError"&&/Load failed|fetch/i.test(C.message)?Object.assign(new je("Network Error",je.ERR_NETWORK,f,V),{cause:C.cause||C}):je.from(C,C&&C.code,f,V)}}},C2=new Map,j0=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,u,d=C2;for(;o--;)c=i[o],u=d.get(c),u===void 0&&d.set(c,u=o?new Map:k2(t)),d=u;return u};j0();const Im={http:K1,xhr:v2,fetch:{get:j0}};U.forEach(Im,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const kp=e=>`- ${e}`,E2=e=>U.isFunction(e)||e===null||e===!1;function D2(e,t){e=U.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,!E2(r)&&(a=Im[(o=String(r)).toLowerCase()],a===void 0))throw new je(`Unknown adapter '${o}'`);if(a&&(U.isFunction(a)||(a=a.get(t))))break;i[o||"#"+l]=a}if(!a){const l=Object.entries(i).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let o=n?l.length>1?`since :
|
||
`+l.map(kp).join(`
|
||
`):" "+kp(l[0]):"as no adapter specified";throw new je("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return a}const b0={getAdapter:D2,adapters:Im};function Zc(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new qa(null,e)}function Cp(e){return Zc(e),e.headers=ss.from(e.headers),e.data=Gc.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),b0.getAdapter(e.adapter||ol.adapter,e)(e).then(function(r){return Zc(e),r.data=Gc.call(e,e.transformResponse,r),r.headers=ss.from(r.headers),r},function(r){return x0(r)||(Zc(e),r&&r.response&&(r.response.data=Gc.call(e,e.transformResponse,r.response),r.response.headers=ss.from(r.response.headers))),Promise.reject(r)})}const N0="1.13.2",dc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{dc[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Ep={};dc.transitional=function(t,n,r){function a(i,l){return"[Axios v"+N0+"] Transitional option '"+i+"'"+l+(r?". "+r:"")}return(i,l,o)=>{if(t===!1)throw new je(a(l," has been removed"+(n?" in "+n:"")),je.ERR_DEPRECATED);return n&&!Ep[l]&&(Ep[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}};dc.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function P2(e,t,n){if(typeof e!="object")throw new je("options must be an object",je.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 je("option "+i+" must be "+c,je.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new je("Unknown option "+i,je.ERR_BAD_OPTION)}}const eo={assertOptions:P2,validators:dc},Os=eo.validators;let Dr=class{constructor(t){this.defaults=t||{},this.interceptors={request:new pp,response:new pp}}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=Rr(this.defaults,n);const{transitional:r,paramsSerializer:a,headers:i}=n;r!==void 0&&eo.assertOptions(r,{silentJSONParsing:Os.transitional(Os.boolean),forcedJSONParsing:Os.transitional(Os.boolean),clarifyTimeoutError:Os.transitional(Os.boolean)},!1),a!=null&&(U.isFunction(a)?n.paramsSerializer={serialize:a}:eo.assertOptions(a,{encode:Os.function,serialize:Os.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),eo.assertOptions(n,{baseUrl:Os.spelling("baseURL"),withXsrfToken:Os.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let l=i&&U.merge(i.common,i[n.method]);i&&U.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),n.headers=ss.concat(l,i);const o=[];let c=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(n)===!1||(c=c&&y.synchronous,o.unshift(y.fulfilled,y.rejected))});const u=[];this.interceptors.response.forEach(function(y){u.push(y.fulfilled,y.rejected)});let d,h=0,p;if(!c){const f=[Cp.bind(this),void 0];for(f.unshift(...o),f.push(...u),p=f.length,d=Promise.resolve(n);h<p;)d=d.then(f[h++],f[h++]);return d}p=o.length;let m=n;for(;h<p;){const f=o[h++],y=o[h++];try{m=f(m)}catch(N){y.call(this,N);break}}try{d=Cp.call(this,m)}catch(f){return Promise.reject(f)}for(h=0,p=u.length;h<p;)d=d.then(u[h++],u[h++]);return d}getUri(t){t=Rr(this.defaults,t);const n=y0(t.baseURL,t.url,t.allowAbsoluteUrls);return h0(n,t.params,t.paramsSerializer)}};U.forEach(["delete","get","head","options"],function(t){Dr.prototype[t]=function(n,r){return this.request(Rr(r||{},{method:t,url:n,data:(r||{}).data}))}});U.forEach(["post","put","patch"],function(t){function n(r){return function(i,l,o){return this.request(Rr(o||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:l}))}}Dr.prototype[t]=n(),Dr.prototype[t+"Form"]=n(!0)});let A2=class w0{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 qa(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 w0(function(a){t=a}),cancel:t}}};function M2(e){return function(n){return e.apply(null,n)}}function T2(e){return U.isObject(e)&&e.isAxiosError===!0}const jd={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(jd).forEach(([e,t])=>{jd[t]=e});function S0(e){const t=new Dr(e),n=t0(Dr.prototype.request,t);return U.extend(n,Dr.prototype,t,{allOwnKeys:!0}),U.extend(n,t,null,{allOwnKeys:!0}),n.create=function(a){return S0(Rr(e,a))},n}const lt=S0(ol);lt.Axios=Dr;lt.CanceledError=qa;lt.CancelToken=A2;lt.isCancel=x0;lt.VERSION=N0;lt.toFormData=uc;lt.AxiosError=je;lt.Cancel=lt.CanceledError;lt.all=function(t){return Promise.all(t)};lt.spread=M2;lt.isAxiosError=T2;lt.mergeConfig=Rr;lt.AxiosHeaders=ss;lt.formToJSON=e=>p0(U.isHTMLForm(e)?new FormData(e):e);lt.getAdapter=b0.getAdapter;lt.HttpStatusCode=jd;lt.default=lt;const{Axios:lC,AxiosError:oC,CanceledError:cC,isCancel:uC,CancelToken:dC,VERSION:mC,all:hC,Cancel:fC,isAxiosError:pC,spread:xC,toFormData:gC,AxiosHeaders:yC,HttpStatusCode:vC,formToJSON:jC,getAdapter:bC,mergeConfig:NC}=lt,z=lt.create({baseURL:"/api",headers:{"Content-Type":"application/json"}});z.interceptors.request.use(e=>{const t=localStorage.getItem("token");return t&&(e.headers.Authorization=`Bearer ${t}`),e});z.interceptors.response.use(e=>e,e=>{var a,i,l,o,c,u,d;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=((d=(u=e.response)==null?void 0:u.data)==null?void 0:d.error)||e.message||"Ein Fehler ist aufgetreten",r=new Error(n);return Promise.reject(r)});const Ol={login:async(e,t)=>(await z.post("/auth/login",{email:e,password:t})).data,customerLogin:async(e,t)=>(await z.post("/auth/customer-login",{email:e,password:t})).data,me:async()=>(await z.get("/auth/me")).data},Nt={getAll:async e=>(await z.get("/customers",{params:e})).data,getById:async e=>(await z.get(`/customers/${e}`)).data,create:async e=>(await z.post("/customers",e)).data,update:async(e,t)=>(await z.put(`/customers/${e}`,t)).data,delete:async e=>(await z.delete(`/customers/${e}`)).data,getPortalSettings:async e=>(await z.get(`/customers/${e}/portal`)).data,updatePortalSettings:async(e,t)=>(await z.put(`/customers/${e}/portal`,t)).data,setPortalPassword:async(e,t)=>(await z.post(`/customers/${e}/portal/password`,{password:t})).data,getPortalPassword:async e=>(await z.get(`/customers/${e}/portal/password`)).data,getRepresentatives:async e=>(await z.get(`/customers/${e}/representatives`)).data,addRepresentative:async(e,t,n)=>(await z.post(`/customers/${e}/representatives`,{representativeId:t,notes:n})).data,removeRepresentative:async(e,t)=>(await z.delete(`/customers/${e}/representatives/${t}`)).data,searchForRepresentative:async(e,t)=>(await z.get(`/customers/${e}/representatives/search`,{params:{search:t}})).data},bd={getByCustomer:async e=>(await z.get(`/customers/${e}/addresses`)).data,create:async(e,t)=>(await z.post(`/customers/${e}/addresses`,t)).data,update:async(e,t)=>(await z.put(`/addresses/${e}`,t)).data,delete:async e=>(await z.delete(`/addresses/${e}`)).data},Fo={getByCustomer:async(e,t=!1)=>(await z.get(`/customers/${e}/bank-cards`,{params:{showInactive:t}})).data,create:async(e,t)=>(await z.post(`/customers/${e}/bank-cards`,t)).data,update:async(e,t)=>(await z.put(`/bank-cards/${e}`,t)).data,delete:async e=>(await z.delete(`/bank-cards/${e}`)).data},Io={getByCustomer:async(e,t=!1)=>(await z.get(`/customers/${e}/documents`,{params:{showInactive:t}})).data,create:async(e,t)=>(await z.post(`/customers/${e}/documents`,t)).data,update:async(e,t)=>(await z.put(`/documents/${e}`,t)).data,delete:async e=>(await z.delete(`/documents/${e}`)).data},Hs={getByCustomer:async(e,t=!1)=>(await z.get(`/customers/${e}/meters`,{params:{showInactive:t}})).data,create:async(e,t)=>(await z.post(`/customers/${e}/meters`,t)).data,update:async(e,t)=>(await z.put(`/meters/${e}`,t)).data,delete:async e=>(await z.delete(`/meters/${e}`)).data,getReadings:async e=>(await z.get(`/meters/${e}/readings`)).data,addReading:async(e,t)=>(await z.post(`/meters/${e}/readings`,t)).data,updateReading:async(e,t,n)=>(await z.put(`/meters/${e}/readings/${t}`,n)).data,deleteReading:async(e,t)=>(await z.delete(`/meters/${e}/readings/${t}`)).data},Ds={getByCustomer:async(e,t=!1)=>(await z.get(`/customers/${e}/stressfrei-emails`,{params:{includeInactive:t}})).data,create:async(e,t)=>(await z.post(`/customers/${e}/stressfrei-emails`,t)).data,update:async(e,t)=>(await z.put(`/stressfrei-emails/${e}`,t)).data,delete:async e=>(await z.delete(`/stressfrei-emails/${e}`)).data,enableMailbox:async e=>(await z.post(`/stressfrei-emails/${e}/enable-mailbox`)).data,syncMailboxStatus:async e=>(await z.post(`/stressfrei-emails/${e}/sync-mailbox-status`)).data,getMailboxCredentials:async e=>(await z.get(`/stressfrei-emails/${e}/credentials`)).data,resetPassword:async e=>(await z.post(`/stressfrei-emails/${e}/reset-password`)).data,syncEmails:async(e,t=!1)=>(await z.post(`/stressfrei-emails/${e}/sync`,{},{params:{full:t}})).data,sendEmail:async(e,t)=>(await z.post(`/stressfrei-emails/${e}/send`,t)).data,getFolderCounts:async e=>(await z.get(`/stressfrei-emails/${e}/folder-counts`)).data},qe={getForCustomer:async(e,t)=>(await z.get(`/customers/${e}/emails`,{params:t})).data,getForContract:async(e,t)=>(await z.get(`/contracts/${e}/emails`,{params:t})).data,getContractFolderCounts:async e=>(await z.get(`/contracts/${e}/emails/folder-counts`)).data,getMailboxAccounts:async e=>(await z.get(`/customers/${e}/mailbox-accounts`)).data,getById:async e=>(await z.get(`/emails/${e}`)).data,getThread:async e=>(await z.get(`/emails/${e}/thread`)).data,markAsRead:async(e,t)=>(await z.patch(`/emails/${e}/read`,{isRead:t})).data,toggleStar:async e=>(await z.post(`/emails/${e}/star`)).data,assignToContract:async(e,t)=>(await z.post(`/emails/${e}/assign`,{contractId:t})).data,unassignFromContract:async e=>(await z.delete(`/emails/${e}/assign`)).data,delete:async e=>(await z.delete(`/emails/${e}`)).data,getAttachmentUrl:(e,t,n)=>{const r=localStorage.getItem("token"),a=encodeURIComponent(t),i=n?"&view=true":"";return`${z.defaults.baseURL}/emails/${e}/attachments/${a}?token=${r}${i}`},getUnreadCount:async e=>(await z.get("/emails/unread-count",{params:e})).data,getTrash:async e=>(await z.get(`/customers/${e}/emails/trash`)).data,getTrashCount:async e=>(await z.get(`/customers/${e}/emails/trash/count`)).data,restore:async e=>(await z.post(`/emails/${e}/restore`)).data,permanentDelete:async e=>(await z.delete(`/emails/${e}/permanent`)).data},$e={getAll:async e=>(await z.get("/contracts",{params:e})).data,getById:async e=>(await z.get(`/contracts/${e}`)).data,create:async e=>(await z.post("/contracts",e)).data,update:async(e,t)=>(await z.put(`/contracts/${e}`,t)).data,delete:async e=>(await z.delete(`/contracts/${e}`)).data,createFollowUp:async e=>(await z.post(`/contracts/${e}/follow-up`)).data,getPassword:async e=>(await z.get(`/contracts/${e}/password`)).data,getSimCardCredentials:async e=>(await z.get(`/contracts/simcard/${e}/credentials`)).data,getInternetCredentials:async e=>(await z.get(`/contracts/${e}/internet-credentials`)).data,getSipCredentials:async e=>(await z.get(`/contracts/phonenumber/${e}/sip-credentials`)).data,getCockpit:async()=>(await z.get("/contracts/cockpit")).data},st={getAll:async e=>(await z.get("/tasks",{params:e})).data,getStats:async()=>(await z.get("/tasks/stats")).data,getByContract:async(e,t)=>(await z.get(`/contracts/${e}/tasks`,{params:{status:t}})).data,create:async(e,t)=>(await z.post(`/contracts/${e}/tasks`,t)).data,update:async(e,t)=>(await z.put(`/tasks/${e}`,t)).data,complete:async e=>(await z.post(`/tasks/${e}/complete`)).data,reopen:async e=>(await z.post(`/tasks/${e}/reopen`)).data,delete:async e=>(await z.delete(`/tasks/${e}`)).data,createSubtask:async(e,t)=>(await z.post(`/tasks/${e}/subtasks`,{title:t})).data,createReply:async(e,t)=>(await z.post(`/tasks/${e}/reply`,{title:t})).data,updateSubtask:async(e,t)=>(await z.put(`/subtasks/${e}`,{title:t})).data,completeSubtask:async e=>(await z.post(`/subtasks/${e}/complete`)).data,reopenSubtask:async e=>(await z.post(`/subtasks/${e}/reopen`)).data,deleteSubtask:async e=>(await z.delete(`/subtasks/${e}`)).data,createSupportTicket:async(e,t)=>(await z.post(`/contracts/${e}/support-ticket`,t)).data},Or={getPublic:async()=>(await z.get("/settings/public")).data,getAll:async()=>(await z.get("/settings")).data,update:async e=>(await z.put("/settings",e)).data,updateOne:async(e,t)=>(await z.put(`/settings/${e}`,{value:t})).data},or={list:async()=>(await z.get("/settings/backups")).data,create:async()=>(await z.post("/settings/backup")).data,restore:async e=>(await z.post(`/settings/backup/${e}/restore`)).data,delete:async e=>(await z.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 z.post("/settings/backup/upload",t,{headers:{"Content-Type":"multipart/form-data"}})).data},factoryReset:async()=>(await z.post("/settings/factory-reset")).data},Bi={getAll:async(e=!1)=>(await z.get("/platforms",{params:{includeInactive:e}})).data,getById:async e=>(await z.get(`/platforms/${e}`)).data,create:async e=>(await z.post("/platforms",e)).data,update:async(e,t)=>(await z.put(`/platforms/${e}`,t)).data,delete:async e=>(await z.delete(`/platforms/${e}`)).data},Ki={getAll:async(e=!1)=>(await z.get("/cancellation-periods",{params:{includeInactive:e}})).data,getById:async e=>(await z.get(`/cancellation-periods/${e}`)).data,create:async e=>(await z.post("/cancellation-periods",e)).data,update:async(e,t)=>(await z.put(`/cancellation-periods/${e}`,t)).data,delete:async e=>(await z.delete(`/cancellation-periods/${e}`)).data},qi={getAll:async(e=!1)=>(await z.get("/contract-durations",{params:{includeInactive:e}})).data,getById:async e=>(await z.get(`/contract-durations/${e}`)).data,create:async e=>(await z.post("/contract-durations",e)).data,update:async(e,t)=>(await z.put(`/contract-durations/${e}`,t)).data,delete:async e=>(await z.delete(`/contract-durations/${e}`)).data},Vi={getAll:async(e=!1)=>(await z.get("/contract-categories",{params:{includeInactive:e}})).data,getById:async e=>(await z.get(`/contract-categories/${e}`)).data,create:async e=>(await z.post("/contract-categories",e)).data,update:async(e,t)=>(await z.put(`/contract-categories/${e}`,t)).data,delete:async e=>(await z.delete(`/contract-categories/${e}`)).data},Ra={getAll:async(e=!1)=>(await z.get("/providers",{params:{includeInactive:e}})).data,getById:async e=>(await z.get(`/providers/${e}`)).data,create:async e=>(await z.post("/providers",e)).data,update:async(e,t)=>(await z.put(`/providers/${e}`,t)).data,delete:async e=>(await z.delete(`/providers/${e}`)).data,getTariffs:async(e,t=!1)=>(await z.get(`/providers/${e}/tariffs`,{params:{includeInactive:t}})).data,createTariff:async(e,t)=>(await z.post(`/providers/${e}/tariffs`,t)).data},k0={getById:async e=>(await z.get(`/tariffs/${e}`)).data,update:async(e,t)=>(await z.put(`/tariffs/${e}`,t)).data,delete:async e=>(await z.delete(`/tariffs/${e}`)).data},et={uploadBankCardDocument:async(e,t)=>{const n=new FormData;return n.append("document",t),(await z.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 z.post(`/upload/documents/${e}`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteBankCardDocument:async e=>(await z.delete(`/upload/bank-cards/${e}`)).data,deleteIdentityDocument:async e=>(await z.delete(`/upload/documents/${e}`)).data,uploadBusinessRegistration:async(e,t)=>{const n=new FormData;return n.append("document",t),(await z.post(`/upload/customers/${e}/business-registration`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteBusinessRegistration:async e=>(await z.delete(`/upload/customers/${e}/business-registration`)).data,uploadCommercialRegister:async(e,t)=>{const n=new FormData;return n.append("document",t),(await z.post(`/upload/customers/${e}/commercial-register`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCommercialRegister:async e=>(await z.delete(`/upload/customers/${e}/commercial-register`)).data,uploadPrivacyPolicy:async(e,t)=>{const n=new FormData;return n.append("document",t),(await z.post(`/upload/customers/${e}/privacy-policy`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deletePrivacyPolicy:async e=>(await z.delete(`/upload/customers/${e}/privacy-policy`)).data,uploadCancellationLetter:async(e,t)=>{const n=new FormData;return n.append("document",t),(await z.post(`/upload/contracts/${e}/cancellation-letter`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationLetter:async e=>(await z.delete(`/upload/contracts/${e}/cancellation-letter`)).data,uploadCancellationConfirmation:async(e,t)=>{const n=new FormData;return n.append("document",t),(await z.post(`/upload/contracts/${e}/cancellation-confirmation`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationConfirmation:async e=>(await z.delete(`/upload/contracts/${e}/cancellation-confirmation`)).data,uploadCancellationLetterOptions:async(e,t)=>{const n=new FormData;return n.append("document",t),(await z.post(`/upload/contracts/${e}/cancellation-letter-options`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationLetterOptions:async e=>(await z.delete(`/upload/contracts/${e}/cancellation-letter-options`)).data,uploadCancellationConfirmationOptions:async(e,t)=>{const n=new FormData;return n.append("document",t),(await z.post(`/upload/contracts/${e}/cancellation-confirmation-options`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationConfirmationOptions:async e=>(await z.delete(`/upload/contracts/${e}/cancellation-confirmation-options`)).data},vi={getAll:async e=>(await z.get("/users",{params:e})).data,getById:async e=>(await z.get(`/users/${e}`)).data,create:async e=>(await z.post("/users",e)).data,update:async(e,t)=>(await z.put(`/users/${e}`,t)).data,delete:async e=>(await z.delete(`/users/${e}`)).data,getRoles:async()=>(await z.get("/users/roles/list")).data},ci={getSchema:async()=>(await z.get("/developer/schema")).data,getTableData:async(e,t=1,n=50)=>(await z.get(`/developer/table/${e}`,{params:{page:t,limit:n}})).data,updateRow:async(e,t,n)=>(await z.put(`/developer/table/${e}/${t}`,n)).data,deleteRow:async(e,t)=>(await z.delete(`/developer/table/${e}/${t}`)).data,getReference:async e=>(await z.get(`/developer/reference/${e}`)).data},sn={getConfigs:async()=>(await z.get("/email-providers/configs")).data,getConfig:async e=>(await z.get(`/email-providers/configs/${e}`)).data,createConfig:async e=>(await z.post("/email-providers/configs",e)).data,updateConfig:async(e,t)=>(await z.put(`/email-providers/configs/${e}`,t)).data,deleteConfig:async e=>(await z.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 z.post("/email-providers/test-connection",t)).data},getDomain:async()=>(await z.get("/email-providers/domain")).data,checkEmailExists:async e=>(await z.get(`/email-providers/check/${e}`)).data,provisionEmail:async(e,t)=>(await z.post("/email-providers/provision",{localPart:e,customerEmail:t})).data,deprovisionEmail:async e=>(await z.delete(`/email-providers/deprovision/${e}`)).data},C0=b.createContext(null);function F2({children:e}){const[t,n]=b.useState(null),[r,a]=b.useState(!0),[i,l]=b.useState(()=>localStorage.getItem("developerMode")==="true"),o=y=>{l(y),localStorage.setItem("developerMode",String(y))};b.useEffect(()=>{var y;console.log("useEffect check - user:",t==null?void 0:t.email,"developerMode:",i,"has developer:access:",(y=t==null?void 0:t.permissions)==null?void 0:y.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")?Ol.me().then(N=>{N.success&&N.data?n(N.data):localStorage.removeItem("token")}).catch(()=>{localStorage.removeItem("token")}).finally(()=>{a(!1)}):a(!1)},[]);const c=async(y,N)=>{const v=await Ol.login(y,N);if(v.success&&v.data)localStorage.setItem("token",v.data.token),n(v.data.user);else throw new Error(v.error||"Login fehlgeschlagen")},u=async(y,N)=>{const v=await Ol.customerLogin(y,N);if(v.success&&v.data)localStorage.setItem("token",v.data.token),n(v.data.user);else throw new Error(v.error||"Login fehlgeschlagen")},d=()=>{localStorage.removeItem("token"),n(null)},h=async()=>{var N;if(localStorage.getItem("token"))try{const v=await Ol.me();console.log("refreshUser response:",v),console.log("permissions:",(N=v.data)==null?void 0:N.permissions),v.success&&v.data&&n(v.data)}catch(v){console.error("refreshUser error:",v)}},p=y=>t?t.permissions.includes(y):!1,m=!!(t!=null&&t.customerId),f=!!(t!=null&&t.isCustomerPortal);return s.jsx(C0.Provider,{value:{user:t,isLoading:r,isAuthenticated:!!t,login:c,customerLogin:u,logout:d,hasPermission:p,isCustomer:m,isCustomerPortal:f,developerMode:i,setDeveloperMode:o,refreshUser:h},children:e})}function Be(){const e=b.useContext(C0);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}const Jc={scrollToTopThreshold:.7},E0=b.createContext(void 0),Dp="opencrm_app_settings";function I2({children:e}){const[t,n]=b.useState(()=>{const a=localStorage.getItem(Dp);if(a)try{return{...Jc,...JSON.parse(a)}}catch{return Jc}return Jc});b.useEffect(()=>{localStorage.setItem(Dp,JSON.stringify(t))},[t]);const r=a=>{n(i=>({...i,...a}))};return s.jsx(E0.Provider,{value:{settings:t,updateSettings:r},children:e})}function D0(){const e=b.useContext(E0);if(!e)throw new Error("useAppSettings must be used within AppSettingsProvider");return e}function L2(){const{pathname:e}=wn();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 R2=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),P0=(...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 O2={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 z2=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,...O2,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:P0("lucide",a),...o},[...l.map(([u,d])=>b.createElement(u,d)),...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 se=(e,t)=>{const n=b.forwardRef(({className:r,...a},i)=>b.createElement(z2,{ref:i,iconNode:t,className:P0(`lucide-${R2(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 _2=se("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 Gs=se("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 A0=se("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 $2=se("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 U2=se("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 M0=se("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 T0=se("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 Nd=se("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 mc=se("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 B2=se("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 rs=se("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 F0=se("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 un=se("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 gs=se("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 Pp=se("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 to=se("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 Qi=se("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 vn=se("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 hc=se("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 I0=se("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 K2=se("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 fc=se("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 Ms=se("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 Lm=se("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 Et=se("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=se("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 at=se("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 q2=se("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 L0=se("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 V2=se("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 R0=se("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 Ap=se("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 Rm=se("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 Q2=se("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 Mp=se("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 Lo=se("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 H2=se("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 W2=se("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 G2=se("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 Tp=se("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 Z2=se("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 O0=se("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 mn=se("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 J2=se("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 X2=se("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 Hi=se("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 Y2=se("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 eS=se("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 pc=se("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 Re=se("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 Qr=se("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 tS=se("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 sS=se("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 nS=se("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=se("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 ul=se("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 z0=se("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 Om=se("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 Je=se("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 zm=se("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 rS=se("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 aS=se("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 ve=se("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 nr=se("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 _0=se("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 $0=se("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 wd=se("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 iS=se("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 lS=se("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 _m=se("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 ha=se("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 Fp=se("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 fa=se("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 jn=se("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 $m=se("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 oS=se("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 cS=se("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 uS(){const{user:e,logout:t,hasPermission:n,isCustomer:r,developerMode:a}=Be(),i=[{to:"/",icon:G2,label:"Dashboard",show:!0,end:!0},{to:"/customers",icon:ha,label:"Kunden",show:n("customers:read")&&!r},{to:"/contracts",icon:at,label:"Verträge",show:n("contracts:read"),end:!0},{to:"/contracts/cockpit",icon:un,label:"Vertrags-Cockpit",show:n("contracts:read")&&!r},{to:"/tasks",icon:r?Hi:Qi,label:r?"Support-Anfragen":"Aufgaben",show:n("contracts:read")}],l=[{to:"/developer/database",icon:fc,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(Hc,{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(hc,{className:"w-3 h-3"}),"Entwickler"]})}),s.jsx("ul",{className:"space-y-2",children:l.map(o=>s.jsx("li",{children:s.jsxs(Hc,{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(Hc,{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(z0,{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(Z2,{className:"w-5 h-5"}),"Abmelden"]})]})]})}function dS(){const{settings:e}=D0(),[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(F0,{className:"w-5 h-5"})}):null}function mS(){return s.jsxs("div",{className:"flex min-h-screen",children:[s.jsx(uS,{}),s.jsx("main",{className:"flex-1 p-8 overflow-auto",children:s.jsx(gN,{})}),s.jsx(dS,{})]})}const T=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"},u={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]} ${u[n]} ${e}`,disabled:a,...i,children:r})});T.displayName="Button";const K=b.forwardRef(({className:e="",label:t,error:n,id:r,onClear:a,...i},l)=>{const o=r||i.name,c=i.type==="date",u=i.value!==void 0&&i.value!==null&&i.value!=="",d=c&&a&&u;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:d?"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}),d&&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(ve,{className:"w-4 h-4"})})]}),n&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:n})]})});K.displayName="Input";function X({children:e,className:t="",title:n,actions:r}){return s.jsxs("div",{className:`bg-white rounded-lg shadow ${t}`,children:[(n||r)&&s.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 flex items-center justify-between",children:[n&&s.jsx("div",{className:"text-lg font-medium text-gray-900",children:n}),r&&s.jsx("div",{className:"flex items-center gap-2",children:r})]}),s.jsx("div",{className:"p-6",children:e})]})}function hS(){const[e,t]=b.useState(""),[n,r]=b.useState(""),[a,i]=b.useState(""),[l,o]=b.useState(!1),{login:c,customerLogin:u}=Be(),d=Vt(),h=async p=>{p.preventDefault(),i(""),o(!0);try{await c(e,n),d("/");return}catch{}try{await u(e,n),d("/")}catch{i("Ungültige Anmeldedaten"),o(!1)}};return s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100",children:s.jsxs(X,{className:"w-full max-w-md",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"OpenCRM"}),s.jsx("p",{className:"text-gray-600 mt-2",children:"Melden Sie sich an"})]}),a&&s.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:a}),s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(K,{label:"E-Mail",type:"email",value:e,onChange:p=>t(p.target.value),required:!0,autoComplete:"email"}),s.jsx(K,{label:"Passwort",type:"password",value:n,onChange:p=>r(p.target.value),required:!0,autoComplete:"current-password"}),s.jsx(T,{type:"submit",className:"w-full",disabled:l,children:l?"Anmeldung...":"Anmelden"})]})]})})}function ot({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(T,{variant:"ghost",size:"sm",onClick:t,children:s.jsx(jn,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-6",children:r})]})]})})}function fS(){var S,P,A,_,L,V;const{user:e,isCustomer:t,isCustomerPortal:n}=Be(),[r,a]=b.useState(!1),{data:i,isLoading:l}=he({queryKey:["app-settings-public"],queryFn:()=>Or.getPublic(),enabled:n,staleTime:0}),o=!l&&((S=i==null?void 0:i.data)==null?void 0:S.customerSupportTicketsEnabled)==="true",{data:c}=he({queryKey:["customers-count"],queryFn:()=>Nt.getAll({limit:1}),enabled:!t}),{data:u}=he({queryKey:["contracts",t?e==null?void 0:e.customerId:void 0],queryFn:()=>$e.getAll(t?{customerId:e==null?void 0:e.customerId}:{limit:1})}),{data:d}=he({queryKey:["contracts-active",t?e==null?void 0:e.customerId:void 0],queryFn:()=>$e.getAll({status:"ACTIVE",...t?{customerId:e==null?void 0:e.customerId}:{limit:1}})}),{data:h}=he({queryKey:["contracts-pending",t?e==null?void 0:e.customerId:void 0],queryFn:()=>$e.getAll({status:"PENDING",...t?{customerId:e==null?void 0:e.customerId}:{limit:1}})}),{data:p}=he({queryKey:["task-stats"],queryFn:()=>st.getStats()}),{data:m}=he({queryKey:["contract-cockpit"],queryFn:()=>$e.getCockpit(),enabled:!t,staleTime:0}),{ownContracts:f,representedContracts:y}=b.useMemo(()=>{if(!n||!(u!=null&&u.data))return{ownContracts:[],representedContracts:[]};const q=[],O={};for(const C of u.data)if(C.customerId===(e==null?void 0:e.customerId))q.push(C);else{const w=C.customerId;if(!O[w]){const R=C.customer?C.customer.companyName||`${C.customer.firstName} ${C.customer.lastName}`:`Kunde ${w}`;O[w]={customerName:R,contracts:[]}}O[w].contracts.push(C)}return{ownContracts:q,representedContracts:Object.values(O).sort((C,w)=>C.customerName.localeCompare(w.customerName))}},[u==null?void 0:u.data,n,e==null?void 0:e.customerId]),N=b.useMemo(()=>f.filter(q=>q.status==="ACTIVE").length,[f]),v=b.useMemo(()=>f.filter(q=>q.status==="PENDING").length,[f]),g=b.useMemo(()=>f.filter(q=>q.status==="EXPIRED").length,[f]),x=b.useMemo(()=>y.reduce((q,O)=>q+O.contracts.length,0),[y]),j=b.useMemo(()=>y.reduce((q,O)=>q+O.contracts.filter(C=>C.status==="ACTIVE").length,0),[y]),k=b.useMemo(()=>y.reduce((q,O)=>q+O.contracts.filter(C=>C.status==="EXPIRED").length,0),[y]),F=((P=p==null?void 0:p.data)==null?void 0:P.openCount)||0,E=q=>s.jsx(X,{className:q.link?"cursor-pointer hover:shadow-md transition-shadow":"",children:q.link?s.jsx(Ne,{to:q.link,className:"block",children:s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:`p-3 rounded-lg ${q.color}`,children:s.jsx(q.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:q.label}),s.jsx("p",{className:"text-2xl font-bold",children:q.value})]})]})}):s.jsxs("div",{className:"flex items-center",children:[s.jsx("div",{className:`p-3 rounded-lg ${q.color}`,children:s.jsx(q.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:q.label}),s.jsx("p",{className:"text-2xl font-bold",children:q.value})]})]})},q.label);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("h1",{className:"text-2xl font-bold",children:["Willkommen, ",e==null?void 0:e.firstName,"!"]}),n&&o&&s.jsxs(T,{onClick:()=>a(!0),children:[s.jsx(Re,{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(_m,{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:[E({label:"Eigene Verträge",value:f.length,icon:at,color:"bg-blue-500",link:"/contracts"}),E({label:"Davon aktiv",value:N,icon:gs,color:"bg-green-500"}),E({label:"Davon ausstehend",value:v,icon:vn,color:"bg-yellow-500"}),E({label:"Davon abgelaufen",value:g,icon:Pp,color:"bg-red-500"})]})]}),x>0&&s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(ha,{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:[E({label:"Fremdverträge",value:x,icon:ha,color:"bg-purple-500",link:"/contracts"}),E({label:"Davon aktiv",value:j,icon:gs,color:"bg-green-500"}),s.jsx("div",{className:"hidden lg:block"}),E({label:"Davon abgelaufen",value:k,icon:Pp,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(Hi,{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:E({label:"Offene Anfragen",value:F,icon:Hi,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:[E({label:"Kunden",value:((A=c==null?void 0:c.pagination)==null?void 0:A.total)||0,icon:ha,color:"bg-blue-500",link:"/customers"}),E({label:"Verträge gesamt",value:((_=u==null?void 0:u.pagination)==null?void 0:_.total)||0,icon:at,color:"bg-purple-500",link:"/contracts"}),E({label:"Aktive Verträge",value:((L=d==null?void 0:d.pagination)==null?void 0:L.total)||0,icon:gs,color:"bg-green-500"}),E({label:"Ausstehende Verträge",value:((V=h==null?void 0:h.pagination)==null?void 0:V.total)||0,icon:un,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(un,{className:"w-5 h-5 text-red-500"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Vertrags-Cockpit"})]}),s.jsx(Ne,{to:"/contracts/cockpit",className:"text-sm text-blue-600 hover:underline",children:"Alle anzeigen"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsx(X,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(Ne,{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(un,{className:"w-6 h-6 text-red-500"})}),s.jsxs("div",{className:"ml-4",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Kritisch (<",m.data.thresholds.criticalDays," Tage)"]}),s.jsx("p",{className:"text-2xl font-bold text-red-600",children:m.data.summary.criticalCount})]})]})})}),s.jsx(X,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(Ne,{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(nr,{className:"w-6 h-6 text-yellow-500"})}),s.jsxs("div",{className:"ml-4",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Warnung (<",m.data.thresholds.warningDays," Tage)"]}),s.jsx("p",{className:"text-2xl font-bold text-yellow-600",children:m.data.summary.warningCount})]})]})})}),s.jsx(X,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(Ne,{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(gs,{className:"w-6 h-6 text-green-500"})}),s.jsxs("div",{className:"ml-4",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["OK (<",m.data.thresholds.okDays," Tage)"]}),s.jsx("p",{className:"text-2xl font-bold text-green-600",children:m.data.summary.okCount})]})]})})}),s.jsx(X,{className:"cursor-pointer hover:shadow-md transition-shadow",children:s.jsx(Ne,{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(at,{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(Qi,{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:E({label:"Offene Aufgaben",value:F,icon:Qi,color:"bg-orange-500",link:"/tasks"})})]})]}),n&&s.jsx(pS,{isOpen:r,onClose:()=>a(!1)})]})}function pS({isOpen:e,onClose:t}){const{user:n}=Be(),r=Vt(),a=pe(),[i,l]=b.useState("own"),[o,c]=b.useState(null),[u,d]=b.useState(""),[h,p]=b.useState(""),[m,f]=b.useState(!1),[y,N]=b.useState(""),{data:v}=he({queryKey:["contracts",n==null?void 0:n.customerId],queryFn:()=>$e.getAll({customerId:n==null?void 0:n.customerId}),enabled:e}),g=b.useMemo(()=>{if(!(v!=null&&v.data))return{own:[],represented:{}};const S=[],P={};for(const A of v.data)if(A.customerId===(n==null?void 0:n.customerId))S.push(A);else{if(!P[A.customerId]){const _=A.customer?A.customer.companyName||`${A.customer.firstName} ${A.customer.lastName}`:`Kunde ${A.customerId}`;P[A.customerId]={name:_,contracts:[]}}P[A.customerId].contracts.push(A)}return{own:S,represented:P}},[v==null?void 0:v.data,n==null?void 0:n.customerId]),x=Object.keys(g.represented).length>0,j=b.useMemo(()=>{var S;return i==="own"?g.own:((S=g.represented[i])==null?void 0:S.contracts)||[]},[i,g]),k=b.useMemo(()=>{if(!y)return j;const S=y.toLowerCase();return j.filter(P=>P.contractNumber.toLowerCase().includes(S)||(P.providerName||"").toLowerCase().includes(S)||(P.tariffName||"").toLowerCase().includes(S))},[j,y]),F=async()=>{if(!(!o||!u.trim())){f(!0);try{await st.createSupportTicket(o,{title:u.trim(),description:h.trim()||void 0}),a.invalidateQueries({queryKey:["task-stats"]}),a.invalidateQueries({queryKey:["all-tasks"]}),t(),d(""),p(""),c(null),l("own"),r(`/contracts/${o}`)}catch(S){console.error("Fehler beim Erstellen der Support-Anfrage:",S),alert("Fehler beim Erstellen der Support-Anfrage. Bitte versuchen Sie es erneut.")}finally{f(!1)}}},E=()=>{d(""),p(""),c(null),l("own"),N(""),t()};return s.jsx(ot,{isOpen:e,onClose:E,title:"Neue Support-Anfrage",children:s.jsxs("div",{className:"space-y-4",children:[x&&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:S=>{const P=S.target.value;l(P==="own"?"own":parseInt(P)),c(null),N("")},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(g.represented).map(([S,{name:P}])=>s.jsx("option",{value:S,children:P},S))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),s.jsx(K,{placeholder:"Vertrag suchen...",value:y,onChange:S=>N(S.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-lg",children:k.length>0?k.map(S=>s.jsxs("div",{onClick:()=>c(S.id),className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${o===S.id?"bg-blue-50 border-blue-200":""}`,children:[s.jsx("div",{className:"font-medium",children:S.contractNumber}),s.jsxs("div",{className:"text-sm text-gray-500",children:[S.providerName||"Kein Anbieter",S.tariffName&&` - ${S.tariffName}`]})]},S.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(K,{value:u,onChange:S=>d(S.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:S=>p(S.target.value),placeholder:"Detaillierte Beschreibung (optional)",rows:4,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:E,children:"Abbrechen"}),s.jsx(T,{onClick:F,disabled:!o||!u.trim()||m,children:m?"Wird erstellt...":"Anfrage erstellen"})]})]})})}function ge({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 xS(){const[e,t]=b.useState(""),[n,r]=b.useState(""),[a,i]=b.useState(1),{hasPermission:l}=Be(),{data:o,isLoading:c}=he({queryKey:["customers",e,n,a],queryFn:()=>Nt.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(Ne,{to:"/customers/new",children:s.jsxs(T,{children:[s.jsx(Re,{className:"w-4 h-4 mr-2"}),"Neuer Kunde"]})})]}),s.jsx(X,{className:"mb-6",children:s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx(K,{placeholder:"Suchen...",value:e,onChange:u=>t(u.target.value),className:"flex-1"}),s.jsxs("select",{value:n,onChange:u=>r(u.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg w-28 flex-shrink-0",children:[s.jsx("option",{value:"",children:"Alle"}),s.jsx("option",{value:"PRIVATE",children:"Privat"}),s.jsx("option",{value:"BUSINESS",children:"Firma"})]}),s.jsx(T,{variant:"secondary",className:"flex-shrink-0",children:s.jsx(cl,{className:"w-4 h-4"})})]})}),s.jsx(X,{children:c?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):o!=null&&o.data&&o.data.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Kundennr."}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Name"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Typ"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"E-Mail"}),s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Verträge"}),s.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsx("tbody",{children:o.data.map(u=>{var d;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:u.customerNumber}),s.jsx("td",{className:"py-3 px-4",children:u.type==="BUSINESS"&&u.companyName?u.companyName:`${u.firstName} ${u.lastName}`}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ge,{variant:u.type==="BUSINESS"?"info":"default",children:u.type==="BUSINESS"?"Firma":"Privat"})}),s.jsx("td",{className:"py-3 px-4",children:u.email||"-"}),s.jsx("td",{className:"py-3 px-4",children:((d=u._count)==null?void 0:d.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(Ne,{to:`/customers/${u.id}`,children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(De,{className:"w-4 h-4"})})}),l("customers:update")&&s.jsx(Ne,{to:`/customers/${u.id}/edit`,children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Je,{className:"w-4 h-4"})})})]})})]},u.id)})})]})}),o.pagination&&o.pagination.totalPages>1&&s.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[s.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",o.pagination.page," von ",o.pagination.totalPages," (",o.pagination.total," Einträge)"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>i(u=>Math.max(1,u-1)),disabled:a===1,children:"Zurück"}),s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>i(u=>u+1),disabled:a>=o.pagination.totalPages,children:"Weiter"})]})]})]}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Kunden gefunden."})})]})}function gS({emails:e,selectedEmailId:t,onSelectEmail:n,onEmailDeleted:r,isLoading:a,folder:i="INBOX",accountId:l}){const o=i==="SENT",[c,u]=b.useState(null),{hasPermission:d}=Be(),h=E=>{if(o)try{const S=JSON.parse(E.toAddresses);if(S.length>0)return`An: ${S[0]}${S.length>1?` (+${S.length-1})`:""}`}catch{return"An: (Unbekannt)"}return E.fromName||E.fromAddress},p=pe(),m=W({mutationFn:E=>qe.toggleStar(E),onSuccess:(E,S)=>{p.invalidateQueries({queryKey:["emails"]}),p.invalidateQueries({queryKey:["email",S]})}}),f=W({mutationFn:({emailId:E,isRead:S})=>qe.markAsRead(E,S),onSuccess:(E,S)=>{p.invalidateQueries({queryKey:["emails"]}),p.invalidateQueries({queryKey:["email",S.emailId]}),l&&p.invalidateQueries({queryKey:["folder-counts",l]})}}),y=W({mutationFn:E=>qe.delete(E),onSuccess:(E,S)=>{p.invalidateQueries({queryKey:["emails"]}),l&&p.invalidateQueries({queryKey:["folder-counts",l]}),ps.success("E-Mail in Papierkorb verschoben"),u(null),r==null||r(S)},onError:E=>{console.error("Delete error:",E),ps.error(E.message||"Fehler beim Löschen der E-Mail"),u(null)}}),N=(E,S)=>{E.stopPropagation(),u(S)},v=E=>{E.stopPropagation(),c&&y.mutate(c)},g=E=>{E.stopPropagation(),u(null)},x=E=>{const S=new Date(E),P=new Date;return S.toDateString()===P.toDateString()?S.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}):S.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})},j=(E,S)=>{E.stopPropagation(),m.mutate(S)},k=(E,S)=>{E.stopPropagation(),f.mutate({emailId:S.id,isRead:!S.isRead})},F=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(mn,{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:()=>F(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:S=>k(S,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(O0,{className:"w-4 h-4"}):s.jsx(mn,{className:"w-4 h-4"})}),s.jsx("button",{onClick:S=>j(S,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(zm,{className:`w-4 h-4 ${E.isStarred?"fill-current":""}`})}),d("emails:delete")&&s.jsx("button",{onClick:S=>N(S,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(ve,{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:x(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(pc,{className:"w-3 h-3 text-gray-400 flex-shrink-0"})]}),E.contract&&s.jsx("div",{className:"mt-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})})]}),s.jsx(rs,{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(T,{variant:"secondary",onClick:g,disabled:y.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:v,disabled:y.isPending,children:y.isPending?"Löschen...":"Löschen"})]})]})})]})}function U0({email:e,onReply:t,onAssignContract:n,onDeleted:r,isSentFolder:a=!1,isContractView:i=!1,isTrashView:l=!1,onRestored:o,accountId:c}){const[u,d]=b.useState(!0),[h,p]=b.useState(e.isStarred),[m,f]=b.useState(!1),[y,N]=b.useState(!1),[v,g]=b.useState(!1),x=pe(),{hasPermission:j}=Be();b.useEffect(()=>{p(e.isStarred)},[e.id,e.isStarred]);const k=W({mutationFn:()=>qe.toggleStar(e.id),onMutate:()=>{p(C=>!C)},onSuccess:()=>{x.invalidateQueries({queryKey:["emails"]}),x.invalidateQueries({queryKey:["email",e.id]})},onError:()=>{p(e.isStarred)}}),F=W({mutationFn:()=>qe.unassignFromContract(e.id),onSuccess:()=>{x.invalidateQueries({queryKey:["emails"]}),x.invalidateQueries({queryKey:["email",e.id]})}}),E=W({mutationFn:()=>qe.delete(e.id),onSuccess:()=>{x.invalidateQueries({queryKey:["emails"]}),c&&x.invalidateQueries({queryKey:["folder-counts",c]}),e.contractId&&x.invalidateQueries({queryKey:["contract-folder-counts",e.contractId]}),ps.success("E-Mail in Papierkorb verschoben"),f(!1),r==null||r()},onError:C=>{console.error("Delete error:",C),ps.error(C.message||"Fehler beim Löschen der E-Mail"),f(!1)}}),S=W({mutationFn:()=>qe.restore(e.id),onSuccess:()=>{x.invalidateQueries({queryKey:["emails"]}),c&&x.invalidateQueries({queryKey:["folder-counts",c]}),e.contractId&&x.invalidateQueries({queryKey:["contract-folder-counts",e.contractId]}),ps.success("E-Mail wiederhergestellt"),N(!1),o==null||o()},onError:C=>{console.error("Restore error:",C),ps.error(C.message||"Fehler beim Wiederherstellen der E-Mail"),N(!1)}}),P=W({mutationFn:()=>qe.permanentDelete(e.id),onSuccess:()=>{x.invalidateQueries({queryKey:["emails"]}),c&&x.invalidateQueries({queryKey:["folder-counts",c]}),ps.success("E-Mail endgültig gelöscht"),g(!1),r==null||r()},onError:C=>{console.error("Permanent delete error:",C),ps.error(C.message||"Fehler beim endgültigen Löschen der E-Mail"),g(!1)}}),A=C=>new Date(C).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}),_=C=>{try{return JSON.parse(C)}catch{return[]}},L=C=>{if(!C)return[];try{return JSON.parse(C)}catch{return[]}},V=_(e.toAddresses),q=e.ccAddresses?_(e.ccAddresses):[],O=L(e.attachmentNames);return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"p-4 border-b border-gray-200 space-y-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:e.subject||"(Kein Betreff)"}),s.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:l?s.jsxs(s.Fragment,{children:[s.jsxs(T,{variant:"secondary",size:"sm",onClick:()=>N(!0),title:"Wiederherstellen",children:[s.jsx($0,{className:"w-4 h-4 mr-1"}),"Wiederherstellen"]}),s.jsxs(T,{variant:"danger",size:"sm",onClick:()=>g(!0),title:"Endgültig löschen",children:[s.jsx(ve,{className:"w-4 h-4 mr-1"}),"Endgültig löschen"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>k.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(zm,{className:`w-5 h-5 ${h?"fill-current":""}`})}),s.jsxs(T,{variant:"secondary",size:"sm",onClick:t,children:[s.jsx(tS,{className:"w-4 h-4 mr-1"}),"Antworten"]}),j("emails:delete")&&s.jsx(T,{variant:"danger",size:"sm",onClick:()=>f(!0),title:"E-Mail löschen",children:s.jsx(ve,{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:V.join(", ")})]}),q.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:q.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:A(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(Tp,{className:"w-4 h-4 text-green-600"}),s.jsxs("span",{className:"text-sm text-green-800",children:["Zugeordnet zu:"," ",s.jsx(Ne,{to:`/contracts/${e.contract.id}`,className:"font-medium hover:underline",children:e.contract.contractNumber})]}),!(i&&a)&&!e.isAutoAssigned&&s.jsx("button",{onClick:()=>F.mutate(),className:"ml-2 p-1 hover:bg-green-100 rounded",title:"Zuordnung aufheben",children:s.jsx(jn,{className:"w-4 h-4 text-green-600"})})]}):!i&&s.jsxs(T,{variant:"secondary",size:"sm",onClick:n,children:[s.jsx(Tp,{className:"w-4 h-4 mr-1"}),"Vertrag zuordnen"]})}),O.length>0&&s.jsxs("div",{className:"pt-2",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(pc,{className:"w-4 h-4 text-gray-400"}),s.jsxs("span",{className:"text-sm text-gray-500",children:[O.length," Anhang",O.length>1?"e":""]})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:O.map((C,w)=>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:C}),s.jsx("a",{href:qe.getAttachmentUrl(e.id,C,!0),target:"_blank",rel:"noopener noreferrer",className:"p-1 hover:bg-gray-200 rounded transition-colors",title:`${C} öffnen`,children:s.jsx(Lm,{className:"w-4 h-4 text-gray-500"})}),s.jsx("a",{href:qe.getAttachmentUrl(e.id,C),download:C,className:"p-1 hover:bg-gray-200 rounded transition-colors",title:`${C} herunterladen`,children:s.jsx(Ms,{className:"w-4 h-4 text-gray-500"})})]},w))})]})]}),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:()=>d(!0),className:`px-3 py-1 text-sm rounded ${u?"bg-blue-100 text-blue-700":"text-gray-600 hover:bg-gray-100"}`,children:"HTML"}),s.jsx("button",{onClick:()=>d(!1),className:`px-3 py-1 text-sm rounded ${u?"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:u&&e.htmlBody?s.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:e.htmlBody}}):s.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-700 font-sans",children:e.textBody||"Kein Inhalt"})}),m&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:"Die E-Mail wird in den Papierkorb verschoben."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>f(!1),disabled:E.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:()=>E.mutate(),disabled:E.isPending,children:E.isPending?"Löschen...":"Löschen"})]})]})}),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 wiederherstellen?"}),s.jsxs("p",{className:"text-gray-600 mb-4",children:["Die E-Mail wird wieder in den ursprünglichen Ordner (",e.folder==="SENT"?"Gesendet":"Posteingang",") verschoben."]}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>N(!1),disabled:S.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"primary",onClick:()=>S.mutate(),disabled:S.isPending,children:S.isPending?"Wird wiederhergestellt...":"Wiederherstellen"})]})]})}),v&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail endgültig löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:"Diese Aktion kann nicht rückgängig gemacht werden. Die E-Mail wird unwiderruflich gelöscht."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>g(!1),disabled:P.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:()=>P.mutate(),disabled:P.isPending,children:P.isPending?"Wird gelöscht...":"Endgültig löschen"})]})]})})]})}function B0({isOpen:e,onClose:t,account:n,replyTo:r,onSuccess:a,contractId:i}){const[l,o]=b.useState(""),[c,u]=b.useState(""),[d,h]=b.useState(""),[p,m]=b.useState(""),[f,y]=b.useState([]),[N,v]=b.useState(null),g=b.useRef(null);b.useEffect(()=>{if(e){if(r){o(r.fromAddress||"");const L=r.subject||"",V=/^(Re|Aw|Fwd|Wg):\s*/i.test(L);h(V?L:`Re: ${L}`);const q=new Date(r.receivedAt).toLocaleString("de-DE"),O=r.textBody?`
|
||
|
||
--- Ursprüngliche Nachricht ---
|
||
Von: ${r.fromName||r.fromAddress}
|
||
Am: ${q}
|
||
|
||
${r.textBody}`:"";m(O)}else o(""),h(""),m("");u(""),y([]),v(null)}},[e,r]);const x=10*1024*1024,j=25*1024*1024,k=L=>new Promise((V,q)=>{const O=new FileReader;O.readAsDataURL(L),O.onload=()=>{const w=O.result.split(",")[1];V(w)},O.onerror=q}),F=async L=>{const V=L.target.files;if(!V)return;const q=[];let O=f.reduce((C,w)=>C+w.content.length*.75,0);for(const C of Array.from(V)){if(C.size>x){v(`Datei "${C.name}" ist zu groß (max. 10 MB)`);continue}if(O+C.size>j){v("Maximale Gesamtgröße der Anhänge erreicht (25 MB)");break}try{const w=await k(C);q.push({filename:C.name,content:w,contentType:C.type||"application/octet-stream"}),O+=C.size}catch{v(`Fehler beim Lesen von "${C.name}"`)}}q.length>0&&y(C=>[...C,...q]),g.current&&(g.current.value="")},E=L=>{y(V=>V.filter((q,O)=>O!==L))},S=L=>{const V=L.length*.75;return V<1024?`${Math.round(V)} B`:V<1024*1024?`${(V/1024).toFixed(1)} KB`:`${(V/(1024*1024)).toFixed(1)} MB`},P=W({mutationFn:()=>Ds.sendEmail(n.id,{to:l.split(",").map(L=>L.trim()).filter(Boolean),cc:c?c.split(",").map(L=>L.trim()).filter(Boolean):void 0,subject:d,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(),A()},onError:L=>{v(L instanceof Error?L.message:"Fehler beim Senden")}}),A=()=>{t()},_=()=>{if(!l.trim()){v("Bitte Empfänger angeben");return}if(!d.trim()){v("Bitte Betreff angeben");return}v(null),P.mutate()};return s.jsx(ot,{isOpen:e,onClose:A,title:r?"Antworten":"Neue E-Mail",size:"lg",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Von"}),s.jsx("div",{className:"px-3 py-2 bg-gray-100 rounded-lg text-sm text-gray-700",children:n.email})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["An ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",value:l,onChange:L=>o(L.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:L=>u(L.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:d,onChange:L=>h(L.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:L=>m(L.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:g,onChange:F,multiple:!0,className:"hidden"}),s.jsxs("button",{type:"button",onClick:()=>{var L;return(L=g.current)==null?void 0:L.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(pc,{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((L,V)=>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(at,{className:"w-4 h-4 text-gray-500 mr-2 flex-shrink-0"}),s.jsx("span",{className:"text-sm text-gray-700 truncate",children:L.filename}),s.jsxs("span",{className:"ml-2 text-xs text-gray-500 flex-shrink-0",children:["(",S(L.content),")"]})]}),s.jsx("button",{type:"button",onClick:()=>E(V),className:"ml-2 p-1 text-gray-400 hover:text-red-500 transition-colors",title:"Anhang entfernen",children:s.jsx(jn,{className:"w-4 h-4"})})]},V))}),s.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Max. 10 MB pro Datei, 25 MB gesamt"})]}),N&&s.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700",children:N}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:A,children:"Abbrechen"}),s.jsxs(T,{onClick:_,disabled:P.isPending,children:[s.jsx(ul,{className:"w-4 h-4 mr-2"}),P.isPending?"Wird gesendet...":"Senden"]})]})]})})}function yS({isOpen:e,onClose:t,email:n,customerId:r,onSuccess:a}){const[i,l]=b.useState(""),[o,c]=b.useState(null),u=pe(),{data:d,isLoading:h}=he({queryKey:["contracts","customer",r],queryFn:()=>$e.getAll({customerId:r}),enabled:e}),m=((d==null?void 0:d.data)||[]).filter(g=>{var j,k,F,E;if(!i)return!0;const x=i.toLowerCase();return g.contractNumber.toLowerCase().includes(x)||((k=(j=g.contractCategory)==null?void 0:j.name)==null?void 0:k.toLowerCase().includes(x))||((E=(F=g.provider)==null?void 0:F.name)==null?void 0:E.toLowerCase().includes(x))}),f=W({mutationFn:g=>qe.assignToContract(n.id,g),onSuccess:(g,x)=>{u.invalidateQueries({queryKey:["emails"]}),u.invalidateQueries({queryKey:["email",n.id]}),u.invalidateQueries({queryKey:["contract-folder-counts",x]}),a==null||a(),y()}}),y=()=>{l(""),c(null),t()},N=()=>{o&&f.mutate(o)},v=g=>g?new Date(g).toLocaleDateString("de-DE"):"-";return s.jsx(ot,{isOpen:e,onClose:y,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:g=>l(g.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(at,{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(g=>{var x;return s.jsx("div",{onClick:()=>c(g.id),className:`
|
||
flex items-center gap-3 p-3 cursor-pointer transition-colors
|
||
${o===g.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:g.contractNumber}),s.jsx("span",{className:`
|
||
px-2 py-0.5 text-xs rounded-full
|
||
${g.status==="ACTIVE"?"bg-green-100 text-green-800":g.status==="PENDING"?"bg-yellow-100 text-yellow-800":g.status==="CANCELLED"?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"}
|
||
`,children:g.status})]}),s.jsxs("div",{className:"text-sm text-gray-600 truncate",children:[(x=g.contractCategory)==null?void 0:x.name,g.provider&&` - ${g.provider.name}`]}),s.jsxs("div",{className:"text-xs text-gray-500",children:["Start: ",v(g.startDate)]})]})},g.id)})})}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:y,children:"Abbrechen"}),s.jsx(T,{onClick:N,disabled:!o||f.isPending,children:f.isPending?"Wird zugeordnet...":"Zuordnen"})]})]})})}function vS({emails:e,selectedEmailId:t,onSelectEmail:n,onEmailRestored:r,onEmailDeleted:a,isLoading:i}){const[l,o]=b.useState(null),[c,u]=b.useState(null),d=pe(),h=j=>{if(j.folder==="SENT")try{const k=JSON.parse(j.toAddresses);if(k.length>0)return`An: ${k[0]}${k.length>1?` (+${k.length-1})`:""}`}catch{return"An: (Unbekannt)"}return j.fromName||j.fromAddress},p=W({mutationFn:j=>qe.restore(j),onSuccess:(j,k)=>{d.invalidateQueries({queryKey:["emails"]}),ps.success("E-Mail wiederhergestellt"),o(null),u(null),r==null||r(k)},onError:j=>{console.error("Restore error:",j),ps.error(j.message||"Fehler beim Wiederherstellen"),o(null),u(null)}}),m=W({mutationFn:j=>qe.permanentDelete(j),onSuccess:(j,k)=>{d.invalidateQueries({queryKey:["emails"]}),ps.success("E-Mail endgültig gelöscht"),o(null),u(null),a==null||a(k)},onError:j=>{console.error("Permanent delete error:",j),ps.error(j.message||"Fehler beim endgültigen Löschen"),o(null),u(null)}}),f=(j,k)=>{j.stopPropagation(),o(k),u("restore")},y=(j,k)=>{j.stopPropagation(),o(k),u("delete")},N=j=>{j.stopPropagation(),l&&c&&(c==="restore"?p.mutate(l):m.mutate(l))},v=j=>{j.stopPropagation(),o(null),u(null)},g=j=>new Date(j).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"}),x=j=>{if(!j)return"";const k=new Date(j),F=new Date;return k.toDateString()===F.toDateString()?`Gelöscht um ${k.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"})}`:`Gelöscht am ${k.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(ve,{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(j=>s.jsxs("div",{onClick:()=>n(j),className:["flex items-start gap-3 p-3 cursor-pointer transition-colors",t===j.id?"bg-red-100":"hover:bg-gray-100 bg-gray-50/50"].join(" "),style:{borderLeft:t===j.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:j.folder==="SENT"?"Aus Gesendet":"Aus Posteingang",children:j.folder==="SENT"?s.jsx(ul,{className:"w-4 h-4"}):s.jsx(Lo,{className:"w-4 h-4"})}),s.jsx("button",{onClick:k=>f(k,j.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($0,{className:"w-4 h-4"})}),s.jsx("button",{onClick:k=>y(k,j.id),className:"flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-red-100 text-gray-400 hover:text-red-600",title:"Endgültig löschen",children:s.jsx(ve,{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(j)}),s.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:g(j.receivedAt)})]}),s.jsx("div",{className:"text-sm truncate text-gray-600",children:j.subject||"(Kein Betreff)"}),s.jsx("div",{className:"text-xs text-red-500 mt-1",children:x(j.deletedAt)})]}),s.jsx(rs,{className:"w-4 h-4 text-gray-400 flex-shrink-0 mt-2"})]},j.id)),l&&c&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:c==="restore"?"E-Mail wiederherstellen?":"E-Mail endgültig löschen?"}),s.jsx("p",{className:"text-gray-600 mb-4",children:c==="restore"?"Die E-Mail wird wieder in den ursprünglichen Ordner verschoben.":"Die E-Mail wird unwiderruflich gelöscht. Diese Aktion kann nicht rückgängig gemacht werden."}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:v,disabled:p.isPending||m.isPending,children:"Abbrechen"}),s.jsx(T,{variant:c==="restore"?"primary":"danger",onClick:N,disabled:p.isPending||m.isPending,children:p.isPending||m.isPending?"Wird ausgeführt...":c==="restore"?"Wiederherstellen":"Endgültig löschen"})]})]})})]})}function jS({customerId:e}){const[t,n]=b.useState(null),[r,a]=b.useState("INBOX"),[i,l]=b.useState(null),[o,c]=b.useState(!1),[u,d]=b.useState(!1),[h,p]=b.useState(null),m=pe(),{hasPermission:f}=Be(),y=f("emails:delete"),{data:N,isLoading:v}=he({queryKey:["mailbox-accounts",e],queryFn:()=>qe.getMailboxAccounts(e)}),g=(N==null?void 0:N.data)||[];b.useEffect(()=>{g.length>0&&!t&&n(g[0].id)},[g,t]);const x=g.find(ue=>ue.id===t),{data:j,isLoading:k,refetch:F}=he({queryKey:["emails","customer",e,t,r],queryFn:()=>qe.getForCustomer(e,{accountId:t||void 0,folder:r}),enabled:!!t&&r!=="TRASH"}),E=(j==null?void 0:j.data)||[],{data:S,isLoading:P}=he({queryKey:["emails","trash",e],queryFn:()=>qe.getTrash(e),enabled:r==="TRASH"&&y}),A=(S==null?void 0:S.data)||[],{data:_}=he({queryKey:["folder-counts",t],queryFn:()=>Ds.getFolderCounts(t),enabled:!!t}),L=(_==null?void 0:_.data)||{inbox:0,inboxUnread:0,sent:0,sentUnread:0,trash:0,trashUnread:0},{data:V}=he({queryKey:["email",i==null?void 0:i.id],queryFn:()=>qe.getById(i.id),enabled:!!(i!=null&&i.id)}),q=(V==null?void 0:V.data)||i,O=W({mutationFn:ue=>Ds.syncEmails(ue),onSuccess:()=>{m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["folder-counts",t]}),m.invalidateQueries({queryKey:["mailbox-accounts",e]})}}),C=()=>{t&&O.mutate(t)},w=ue=>{l(ue)},R=()=>{p(q||null),c(!0)},Q=()=>{p(null),c(!0)},ee=()=>{d(!0)};if(!v&&g.length===0)return s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(mn,{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 fe=ue=>{a(ue),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:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Lo,{className:"w-5 h-5 text-gray-500"}),s.jsx("select",{value:t||"",onChange:ue=>{n(Number(ue.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:g.map(ue=>s.jsx("option",{value:ue.id,children:ue.email},ue.id))})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-gray-200 rounded-lg p-1",children:[s.jsxs("button",{onClick:()=>fe("INBOX"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${r==="INBOX"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Lo,{className:"w-4 h-4"}),"Posteingang",L.inbox>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${L.inboxUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${L.inboxUnread} ungelesen / ${L.inbox} gesamt`,children:L.inboxUnread>0?`${L.inboxUnread}/${L.inbox}`:L.inbox})]}),s.jsxs("button",{onClick:()=>fe("SENT"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${r==="SENT"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(ul,{className:"w-4 h-4"}),"Gesendet",L.sent>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${L.sentUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${L.sentUnread} ungelesen / ${L.sent} gesamt`,children:L.sentUnread>0?`${L.sentUnread}/${L.sent}`:L.sent})]}),y&&s.jsxs("button",{onClick:()=>fe("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(ve,{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})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r!=="TRASH"&&s.jsxs(T,{variant:"secondary",size:"sm",onClick:C,disabled:O.isPending||!t,children:[s.jsx(Qr,{className:`w-4 h-4 mr-1 ${O.isPending?"animate-spin":""}`}),O.isPending?"Sync...":"Synchronisieren"]}),s.jsxs(T,{size:"sm",onClick:Q,disabled:!x,children:[s.jsx(Re,{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(vS,{emails:A,selectedEmailId:i==null?void 0:i.id,onSelectEmail:w,onEmailRestored:ue=>{(i==null?void 0:i.id)===ue&&l(null),m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["folder-counts",t]})},onEmailDeleted:ue=>{(i==null?void 0:i.id)===ue&&l(null),m.invalidateQueries({queryKey:["emails","trash"]}),m.invalidateQueries({queryKey:["folder-counts",t]})},isLoading:P}):s.jsx(gS,{emails:E,selectedEmailId:i==null?void 0:i.id,onSelectEmail:w,onEmailDeleted:ue=>{(i==null?void 0:i.id)===ue&&l(null),m.invalidateQueries({queryKey:["folder-counts",t]})},isLoading:k,folder:r,accountId:t})}),s.jsx("div",{className:"flex-1 overflow-auto",children:q?s.jsx(U0,{email:q,onReply:R,onAssignContract:ee,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(mn,{className:"w-12 h-12 mb-2 opacity-30"}),s.jsx("p",{children:"Wählen Sie eine E-Mail aus"})]})})]}),x&&s.jsx(B0,{isOpen:o,onClose:()=>{c(!1),p(null)},account:x,replyTo:h||void 0,onSuccess:()=>{m.invalidateQueries({queryKey:["emails","customer",e,t,"SENT"]}),m.invalidateQueries({queryKey:["folder-counts",t]}),r==="SENT"&&F()}}),q&&s.jsx(yS,{isOpen:u,onClose:()=>d(!1),email:q,customerId:e,onSuccess:()=>{F()}})]})}function bS({contractId:e,customerId:t}){const[n,r]=b.useState("INBOX"),[a,i]=b.useState(null),[l,o]=b.useState(!1),[c,u]=b.useState(null),d=pe(),{data:h,isLoading:p,refetch:m}=he({queryKey:["emails","contract",e,n],queryFn:()=>qe.getForContract(e,{folder:n})}),f=(h==null?void 0:h.data)||[],{data:y}=he({queryKey:["contract-folder-counts",e],queryFn:()=>qe.getContractFolderCounts(e)}),N=(y==null?void 0:y.data)||{inbox:0,inboxUnread:0,sent:0,sentUnread:0},{data:v}=he({queryKey:["mailbox-accounts",t],queryFn:()=>qe.getMailboxAccounts(t)}),x=((v==null?void 0:v.data)||[])[0],{data:j}=he({queryKey:["email",a==null?void 0:a.id],queryFn:()=>qe.getById(a.id),enabled:!!(a!=null&&a.id)}),k=(j==null?void 0:j.data)||a,F=W({mutationFn:R=>qe.toggleStar(R),onSuccess:(R,Q)=>{d.invalidateQueries({queryKey:["emails","contract",e]}),d.invalidateQueries({queryKey:["email",Q]})}}),E=W({mutationFn:({emailId:R,isRead:Q})=>qe.markAsRead(R,Q),onSuccess:(R,Q)=>{d.invalidateQueries({queryKey:["emails","contract",e]}),d.invalidateQueries({queryKey:["email",Q.emailId]}),d.invalidateQueries({queryKey:["contract-folder-counts",e]})}}),S=W({mutationFn:R=>qe.unassignFromContract(R),onSuccess:()=>{d.invalidateQueries({queryKey:["emails","contract",e]}),d.invalidateQueries({queryKey:["contract-folder-counts",e]}),i(null)}}),P=R=>{const Q=new Date(R),ee=new Date;return Q.toDateString()===ee.toDateString()?Q.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}):Q.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})},A=(R,Q)=>{R.stopPropagation(),F.mutate(Q)},_=(R,Q)=>{R.stopPropagation(),E.mutate({emailId:Q.id,isRead:!Q.isRead})},L=R=>{R.isRead||E.mutate({emailId:R.id,isRead:!0}),i(R)},V=()=>{u(k||null),o(!0)},q=()=>{u(null),o(!0)},O=(R,Q)=>{R.stopPropagation(),(a==null?void 0:a.id)===Q&&i(null),S.mutate(Q)},C=R=>{r(R),i(null)},w=R=>{if(n==="SENT")try{const Q=JSON.parse(R.toAddresses);if(Q.length>0)return`An: ${Q[0]}${Q.length>1?` (+${Q.length-1})`:""}`}catch{return"An: (Unbekannt)"}return R.fromName||R.fromAddress};return s.jsxs(X,{title:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("span",{children:"E-Mails"}),s.jsxs("div",{className:"flex items-center gap-1 bg-gray-200 rounded-lg p-1",children:[s.jsxs("button",{onClick:()=>C("INBOX"),className:`flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md transition-colors ${n==="INBOX"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(Lo,{className:"w-3.5 h-3.5"}),"Empfangen",N.inbox>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${N.inboxUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${N.inboxUnread} ungelesen / ${N.inbox} gesamt`,children:N.inboxUnread>0?`${N.inboxUnread}/${N.inbox}`:N.inbox})]}),s.jsxs("button",{onClick:()=>C("SENT"),className:`flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md transition-colors ${n==="SENT"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[s.jsx(ul,{className:"w-3.5 h-3.5"}),"Gesendet",N.sent>0&&s.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${N.sentUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${N.sentUnread} ungelesen / ${N.sent} gesamt`,children:N.sentUnread>0?`${N.sentUnread}/${N.sent}`:N.sent})]})]})]}),actions:x&&s.jsxs(T,{variant:"secondary",size:"sm",onClick:q,children:[s.jsx(Re,{className:"w-4 h-4 mr-1"}),"Neue E-Mail"]}),children:[p?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}):f.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[s.jsx(mn,{className:"w-10 h-10 mb-2 opacity-30"}),s.jsx("p",{className:"text-sm",children:n==="INBOX"?"Keine E-Mails zugeordnet":"Keine E-Mails über diesen Vertrag gesendet"}),n==="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-2/5 border-r border-gray-200 overflow-auto",children:s.jsx("div",{className:"divide-y divide-gray-200",children:f.map(R=>s.jsxs("div",{onClick:()=>L(R),className:["flex items-start gap-2 p-3 cursor-pointer transition-colors",(a==null?void 0:a.id)===R.id?"bg-blue-100":["hover:bg-gray-100",R.isRead?"bg-gray-50/50":"bg-white"].join(" ")].join(" "),style:{borderLeft:(a==null?void 0:a.id)===R.id?"4px solid #2563eb":"4px solid transparent"},children:[s.jsx("button",{onClick:Q=>_(Q,R),className:`
|
||
flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200
|
||
${R.isRead?"text-gray-400":"text-blue-600"}
|
||
`,title:R.isRead?"Als ungelesen markieren":"Als gelesen markieren",children:R.isRead?s.jsx(O0,{className:"w-4 h-4"}):s.jsx(mn,{className:"w-4 h-4"})}),s.jsx("button",{onClick:Q=>A(Q,R.id),className:`
|
||
flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200
|
||
${R.isStarred?"text-yellow-500":"text-gray-400"}
|
||
`,title:R.isStarred?"Stern entfernen":"Als wichtig markieren",children:s.jsx(zm,{className:`w-4 h-4 ${R.isStarred?"fill-current":""}`})}),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 ${R.isRead?"text-gray-700":"font-semibold text-gray-900"}`,children:w(R)}),s.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:P(R.receivedAt)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-sm truncate ${R.isRead?"text-gray-600":"font-medium text-gray-900"}`,children:R.subject||"(Kein Betreff)"}),R.hasAttachments&&s.jsx(pc,{className:"w-3 h-3 text-gray-400 flex-shrink-0"})]})]}),(n==="INBOX"||n==="SENT"&&!R.isAutoAssigned)&&s.jsx("button",{onClick:Q=>O(Q,R.id),className:"flex-shrink-0 mt-1 p-1 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded",title:"Zuordnung aufheben",children:s.jsx(jn,{className:"w-4 h-4"})}),s.jsx(rs,{className:"w-4 h-4 text-gray-400 flex-shrink-0 mt-2"})]},R.id))})}),s.jsx("div",{className:"flex-1 overflow-auto",children:k&&a?s.jsx(U0,{email:k,onReply:V,onAssignContract:()=>{},onDeleted:()=>{i(null),d.invalidateQueries({queryKey:["emails","contract",e]}),d.invalidateQueries({queryKey:["contract-folder-counts",e]})},isSentFolder:n==="SENT",isContractView:!0,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(mn,{className:"w-12 h-12 mb-2 opacity-30"}),s.jsx("p",{children:"Wählen Sie eine E-Mail aus"})]})})]}),x&&s.jsx(B0,{isOpen:l,onClose:()=>{o(!1),u(null)},account:x,replyTo:c||void 0,contractId:e,onSuccess:()=>{d.invalidateQueries({queryKey:["emails","contract",e,"SENT"]}),d.invalidateQueries({queryKey:["contract-folder-counts",e]}),n==="SENT"&&m()}})]})}function NS({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 Le=b.forwardRef(({className:e="",label:t,error:n,options:r,id:a,placeholder:i="Bitte wählen...",...l},o)=>{const c=a||l.name,u=/\bw-\d+\b|\bw-\[|\bflex-/.test(e);return s.jsxs("div",{className:u?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(d=>s.jsx("option",{value:d.value,children:d.label},d.value))]}),n&&s.jsx("p",{className:"mt-1 text-sm text-red-600",children:n})]})});Le.displayName="Select";function bt({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,u]=b.useState(!1),d=async y=>{if(y){o(!0);try{await e(y)}catch(N){console.error("Upload failed:",N),alert("Upload fehlgeschlagen")}finally{o(!1)}}},h=y=>{var v;const N=(v=y.target.files)==null?void 0:v[0];N&&d(N)},p=y=>{var v;y.preventDefault(),u(!1);const N=(v=y.dataTransfer.files)==null?void 0:v[0];N&&d(N)},m=y=>{y.preventDefault(),u(!0)},f=()=>{u(!1)};return s.jsxs("div",{className:"space-y-2",children:[t?!a&&s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>{var y;return(y=i.current)==null?void 0:y.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 y;return!a&&((y=i.current)==null?void 0:y.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(wd,{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(u){console.error("Failed to copy:",u)}},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(Nd,{className:o}):s.jsx(I0,{className:o})})}function K0({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 wS(){var R,Q;const{id:e}=sc(),t=Vt(),n=pe(),{hasPermission:r}=Be(),[a]=rc(),i=parseInt(e),l=a.get("tab")||"addresses",[o,c]=b.useState(!1),[u,d]=b.useState(!1),[h,p]=b.useState(!1),[m,f]=b.useState(!1),[y,N]=b.useState(!1),[v,g]=b.useState(!1),[x,j]=b.useState(null),[k,F]=b.useState(null),[E,S]=b.useState(null),[P,A]=b.useState(null),[_,L]=b.useState(null),{data:V,isLoading:q}=he({queryKey:["customer",e],queryFn:()=>Nt.getById(i)}),O=W({mutationFn:()=>Nt.delete(i),onSuccess:()=>{t("/customers")}});if(q)return s.jsx("div",{className:"text-center py-8",children:"Laden..."});if(!(V!=null&&V.data))return s.jsx("div",{className:"text-center py-8 text-red-600",children:"Kunde nicht gefunden"});const C=V.data,w=[{id:"addresses",label:"Adressen",content:s.jsx(CS,{customerId:i,addresses:C.addresses||[],canEdit:r("customers:update"),onAdd:()=>c(!0),onEdit:ee=>S(ee)})},{id:"bankcards",label:"Bankkarten",content:s.jsx(ES,{customerId:i,bankCards:C.bankCards||[],canEdit:r("customers:update"),showInactive:v,onToggleInactive:()=>g(!v),onAdd:()=>d(!0),onEdit:ee=>j(ee)})},{id:"documents",label:"Ausweise",content:s.jsx(DS,{customerId:i,documents:C.identityDocuments||[],canEdit:r("customers:update"),showInactive:v,onToggleInactive:()=>g(!v),onAdd:()=>p(!0),onEdit:ee=>F(ee)})},{id:"meters",label:"Zähler",content:s.jsx(PS,{customerId:i,meters:C.meters||[],canEdit:r("customers:update"),showInactive:v,onToggleInactive:()=>g(!v),onAdd:()=>f(!0),onEdit:ee=>A(ee)})},{id:"stressfrei",label:"Stressfrei-Wechseln",content:s.jsx(FS,{customerId:i,emails:C.stressfreiEmails||[],canEdit:r("customers:update"),showInactive:v,onToggleInactive:()=>g(!v),onAdd:()=>N(!0),onEdit:ee=>L(ee)})},{id:"emails",label:"E-Mail-Postfach",content:s.jsx(jS,{customerId:i})},{id:"contracts",label:"Verträge",content:s.jsx(AS,{customerId:i,contracts:C.contracts||[]})},...r("customers:update")?[{id:"portal",label:"Portal",content:s.jsx(TS,{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:C.type==="BUSINESS"&&C.companyName?C.companyName:`${C.firstName} ${C.lastName}`}),s.jsxs("p",{className:"text-gray-500 font-mono flex items-center gap-1",children:[C.customerNumber,s.jsx(ce,{value:C.customerNumber})]})]}),s.jsxs("div",{className:"flex gap-2",children:[r("customers:update")&&s.jsx(Ne,{to:`/customers/${e}/edit`,children:s.jsxs(T,{variant:"secondary",children:[s.jsx(Je,{className:"w-4 h-4 mr-2"}),"Bearbeiten"]})}),r("customers:delete")&&s.jsxs(T,{variant:"danger",onClick:()=>{confirm("Kunde wirklich löschen?")&&O.mutate()},children:[s.jsx(ve,{className:"w-4 h-4 mr-2"}),"Löschen"]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6",children:[s.jsx(X,{title:"Stammdaten",className:"lg:col-span-2",children:s.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Typ"}),s.jsx("dd",{children:s.jsx(ge,{variant:C.type==="BUSINESS"?"info":"default",children:C.type==="BUSINESS"?"Geschäftskunde":"Privatkunde"})})]}),C.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:[C.salutation,s.jsx(ce,{value:C.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:[C.firstName,s.jsx(ce,{value:C.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:[C.lastName,s.jsx(ce,{value:C.lastName})]})]}),C.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:[C.companyName,s.jsx(ce,{value:C.companyName})]})]}),C.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(C.foundingDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}),s.jsx(ce,{value:new Date(C.foundingDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]})]}),C.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(C.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}),s.jsx(ce,{value:new Date(C.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]})]}),C.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:[C.birthPlace,s.jsx(ce,{value:C.birthPlace})]})]})]})}),s.jsx(X,{title:"Kontakt",children:s.jsxs("dl",{className:"space-y-3",children:[C.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:${C.email}`,className:"text-blue-600 hover:underline",children:C.email}),s.jsx(ce,{value:C.email})]})]}),C.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:${C.phone}`,className:"text-blue-600 hover:underline",children:C.phone}),s.jsx(ce,{value:C.phone})]})]}),C.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:${C.mobile}`,className:"text-blue-600 hover:underline",children:C.mobile}),s.jsx(ce,{value:C.mobile})]})]})]})})]}),C.type==="BUSINESS"&&s.jsx(SS,{customer:C,canEdit:r("customers:update"),onUpdate:()=>n.invalidateQueries({queryKey:["customer",e]})}),s.jsx(kS,{customer:C,canEdit:r("customers:update"),onUpdate:()=>n.invalidateQueries({queryKey:["customer",e]})}),C.notes&&s.jsx(X,{title:"Notizen",className:"mb-6",children:s.jsx("p",{className:"whitespace-pre-wrap",children:C.notes})}),s.jsx(X,{children:s.jsx(NS,{tabs:w,defaultTab:l})}),s.jsx(Ip,{isOpen:o,onClose:()=>c(!1),customerId:i}),s.jsx(Ip,{isOpen:!!E,onClose:()=>S(null),customerId:i,address:E}),s.jsx(Lp,{isOpen:u,onClose:()=>d(!1),customerId:i}),s.jsx(Lp,{isOpen:!!x,onClose:()=>j(null),customerId:i,bankCard:x}),s.jsx(Rp,{isOpen:h,onClose:()=>p(!1),customerId:i}),s.jsx(Rp,{isOpen:!!k,onClose:()=>F(null),customerId:i,document:k}),s.jsx(Op,{isOpen:m,onClose:()=>f(!1),customerId:i}),s.jsx(Op,{isOpen:!!P,onClose:()=>A(null),customerId:i,meter:P}),s.jsx(_p,{isOpen:y,onClose:()=>N(!1),customerId:i,customerEmail:(R=V==null?void 0:V.data)==null?void 0:R.email}),s.jsx(_p,{isOpen:!!_,onClose:()=>L(null),customerId:i,email:_,customerEmail:(Q=V==null?void 0:V.data)==null?void 0:Q.email})]})}function SS({customer:e,canEdit:t,onUpdate:n}){const r=async c=>{try{await et.uploadBusinessRegistration(e.id,c),n()}catch(u){console.error("Upload fehlgeschlagen:",u),alert("Upload fehlgeschlagen")}},a=async()=>{if(confirm("Gewerbeanmeldung wirklich löschen?"))try{await et.deleteBusinessRegistration(e.id),n()}catch(c){console.error("Löschen fehlgeschlagen:",c),alert("Löschen fehlgeschlagen")}},i=async c=>{try{await et.uploadCommercialRegister(e.id,c),n()}catch(u){console.error("Upload fehlgeschlagen:",u),alert("Upload fehlgeschlagen")}},l=async()=>{if(confirm("Handelsregisterauszug wirklich löschen?"))try{await et.deleteCommercialRegister(e.id),n()}catch(c){console.error("Löschen fehlgeschlagen:",c),alert("Löschen fehlgeschlagen")}};return!(e.taxNumber||e.commercialRegisterNumber||e.businessRegistrationPath||e.commercialRegisterPath)&&!t?null:s.jsxs(X,{title:"Geschäftsdaten",className:"mb-6",children:[s.jsxs("dl",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.taxNumber&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Steuernummer"}),s.jsxs("dd",{className:"flex items-center gap-1",children:[e.taxNumber,s.jsx(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(Ms,{className:"w-4 h-4"}),"Download"]}),t&&s.jsxs(s.Fragment,{children:[s.jsx(bt,{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(ve,{className:"w-4 h-4"}),"Löschen"]})]})]}):t?s.jsx(bt,{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(Ms,{className:"w-4 h-4"}),"Download"]}),t&&s.jsxs(s.Fragment,{children:[s.jsx(bt,{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(ve,{className:"w-4 h-4"}),"Löschen"]})]})]}):t?s.jsx(bt,{onUpload:i,accept:".pdf",label:"PDF hochladen"}):s.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]})]})]})}function kS({customer:e,canEdit:t,onUpdate:n}){const r=async i=>{try{await et.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 et.deletePrivacyPolicy(e.id),n()}catch(i){console.error("Löschen fehlgeschlagen:",i),alert("Löschen fehlgeschlagen")}};return!e.privacyPolicyPath&&!t?null:s.jsx(X,{title:"Dokumente",className:"mb-6",children:s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Datenschutzerklärung"}),e.privacyPolicyPath?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("a",{href:`/api${e.privacyPolicyPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(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(Ms,{className:"w-4 h-4"}),"Download"]}),t&&s.jsxs(s.Fragment,{children:[s.jsx(bt,{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(ve,{className:"w-4 h-4"}),"Löschen"]})]})]}):t?s.jsx(bt,{onUpload:r,accept:".pdf",label:"PDF hochladen"}):s.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]})})}function CS({customerId:e,addresses:t,canEdit:n,onAdd:r,onEdit:a}){const i=pe(),l=W({mutationFn:bd.delete,onSuccess:()=>i.invalidateQueries({queryKey:["customer",e.toString()]})});return s.jsxs("div",{children:[n&&s.jsx("div",{className:"mb-4",children:s.jsxs(T,{size:"sm",onClick:r,children:[s.jsx(Re,{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(J2,{className:"w-4 h-4 text-gray-400"}),s.jsx(ge,{variant:o.type==="BILLING"?"info":"default",children:o.type==="BILLING"?"Rechnung":"Liefer-/Meldeadresse"}),o.isDefault&&s.jsx(ge,{variant:"success",children:"Standard"})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>a(o),title:"Bearbeiten",children:s.jsx(Je,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wirklich löschen?")&&l.mutate(o.id)},title:"Löschen",children:s.jsx(ve,{className:"w-4 h-4 text-red-500"})})]})]}),s.jsxs(K0,{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 ES({customerId:e,bankCards:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=pe(),c=W({mutationFn:({id:m,data:f})=>Fo.update(m,f),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),u=W({mutationFn:Fo.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=async(m,f)=>{try{await et.uploadBankCardDocument(m,f),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(y){console.error("Upload fehlgeschlagen:",y),alert("Upload fehlgeschlagen")}},h=async m=>{if(confirm("Dokument wirklich löschen?"))try{await et.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(T,{size:"sm",onClick:i,children:[s.jsx(Re,{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(K2,{className:"w-4 h-4 text-gray-400"}),!m.isActive&&s.jsx(ge,{variant:"danger",children:"Inaktiv"}),m.expiryDate&&new Date(m.expiryDate)<new Date&&s.jsx(ge,{variant:"warning",children:"Abgelaufen"})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>l(m),title:"Bearbeiten",children:s.jsx(Je,{className:"w-4 h-4"})}),m.isActive?s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte deaktivieren?")&&c.mutate({id:m.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(Et,{className:"w-4 h-4"})}):s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte wieder aktivieren?")&&c.mutate({id:m.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(De,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte wirklich löschen?")&&u.mutate(m.id)},title:"Löschen",children:s.jsx(ve,{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(Ms,{className:"w-4 h-4"}),"Download"]}),n&&s.jsxs(s.Fragment,{children:[s.jsx(bt,{onUpload:f=>d(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(ve,{className:"w-4 h-4"}),"Löschen"]})]})]}):n&&m.isActive&&s.jsx(bt,{onUpload:f=>d(m.id,f),accept:".pdf",label:"PDF hochladen"})})]},m.id))}):s.jsx("p",{className:"text-gray-500",children:"Keine Bankkarten vorhanden."})]})}function DS({customerId:e,documents:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=pe(),c=W({mutationFn:({id:f,data:y})=>Io.update(f,y),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),u=W({mutationFn:Io.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=async(f,y)=>{try{await et.uploadIdentityDocument(f,y),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(N){console.error("Upload fehlgeschlagen:",N),alert("Upload fehlgeschlagen")}},h=async f=>{if(confirm("Dokument wirklich löschen?"))try{await et.deleteIdentityDocument(f),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(y){console.error("Löschen fehlgeschlagen:",y),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(T,{size:"sm",onClick:i,children:[s.jsx(Re,{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(at,{className:"w-4 h-4 text-gray-400"}),s.jsx(ge,{children:m[f.type]}),!f.isActive&&s.jsx(ge,{variant:"danger",children:"Inaktiv"}),f.expiryDate&&new Date(f.expiryDate)<new Date&&s.jsx(ge,{variant:"warning",children:"Abgelaufen"})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>l(f),title:"Bearbeiten",children:s.jsx(Je,{className:"w-4 h-4"})}),f.isActive?s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis deaktivieren?")&&c.mutate({id:f.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(Et,{className:"w-4 h-4"})}):s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis wieder aktivieren?")&&c.mutate({id:f.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(De,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis wirklich löschen?")&&u.mutate(f.id)},title:"Löschen",children:s.jsx(ve,{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(Ms,{className:"w-4 h-4"}),"Download"]}),n&&s.jsxs(s.Fragment,{children:[s.jsx(bt,{onUpload:y=>d(f.id,y),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(ve,{className:"w-4 h-4"}),"Löschen"]})]})]}):n&&f.isActive&&s.jsx(bt,{onUpload:y=>d(f.id,y),accept:".pdf",label:"PDF hochladen"})})]},f.id))}):s.jsx("p",{className:"text-gray-500",children:"Keine Ausweise vorhanden."})]})}function PS({customerId:e,meters:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const[o,c]=b.useState(null),[u,d]=b.useState(null),[h,p]=b.useState(null),m=pe(),f=W({mutationFn:({id:x,data:j})=>Hs.update(x,j),onSuccess:()=>m.invalidateQueries({queryKey:["customer",e.toString()]})}),y=W({mutationFn:Hs.delete,onSuccess:()=>m.invalidateQueries({queryKey:["customer",e.toString()]})}),N=W({mutationFn:({meterId:x,readingId:j})=>Hs.deleteReading(x,j),onSuccess:()=>m.invalidateQueries({queryKey:["customer",e.toString()]})}),v=r?t:t.filter(x=>x.isActive),g=x=>x?[...x].sort((j,k)=>new Date(k.readingDate).getTime()-new Date(j.readingDate).getTime()):[];return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&s.jsxs(T,{size:"sm",onClick:i,children:[s.jsx(Re,{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"]})]}),v.length>0?s.jsx("div",{className:"space-y-4",children:v.map(x=>{const j=g(x.readings),k=u===x.id;return s.jsxs("div",{className:`border rounded-lg p-4 ${x.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(R0,{className:"w-4 h-4 text-gray-400"}),s.jsx(ge,{variant:x.type==="ELECTRICITY"?"warning":"info",children:x.type==="ELECTRICITY"?"Strom":"Gas"}),!x.isActive&&s.jsx(ge,{variant:"danger",children:"Inaktiv"})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[x.isActive&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>c(x.id),title:"Zählerstand hinzufügen",children:s.jsx(Re,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>l(x),title:"Bearbeiten",children:s.jsx(Je,{className:"w-4 h-4"})}),x.isActive?s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler deaktivieren?")&&f.mutate({id:x.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(Et,{className:"w-4 h-4"})}):s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler wieder aktivieren?")&&f.mutate({id:x.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(De,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler wirklich löschen? Alle Zählerstände werden ebenfalls gelöscht.")&&y.mutate(x.id)},title:"Löschen",children:s.jsx(ve,{className:"w-4 h-4 text-red-500"})})]})]}),s.jsxs("p",{className:"font-mono text-lg flex items-center gap-1",children:[x.meterNumber,s.jsx(ce,{value:x.meterNumber})]}),x.location&&s.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["Standort: ",x.location,s.jsx(ce,{value:x.location})]}),j.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:"}),j.length>3&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>d(k?null:x.id),children:k?"Weniger anzeigen":`Alle ${j.length} anzeigen`})]}),s.jsx("div",{className:"space-y-1",children:(k?j:j.slice(0,3)).map(F=>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(F.readingDate).toLocaleDateString("de-DE"),s.jsx(ce,{value:new Date(F.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:[F.value.toLocaleString("de-DE")," ",F.unit,s.jsx(ce,{value:F.value.toString(),title:"Nur Wert kopieren"}),s.jsx(ce,{value:`${F.value.toLocaleString("de-DE")} ${F.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:x.id,reading:F}),className:"text-gray-400 hover:text-blue-600",title:"Bearbeiten",children:s.jsx(Je,{className:"w-3 h-3"})}),s.jsx("button",{onClick:()=>{confirm("Zählerstand wirklich löschen?")&&N.mutate({meterId:x.id,readingId:F.id})},className:"text-gray-400 hover:text-red-600",title:"Löschen",children:s.jsx(ve,{className:"w-3 h-3"})})]})]})]},F.id))})]})]},x.id)})}):s.jsx("p",{className:"text-gray-500",children:"Keine Zähler vorhanden."}),o&&s.jsx(zp,{isOpen:!0,onClose:()=>c(null),meterId:o,customerId:e}),h&&s.jsx(zp,{isOpen:!0,onClose:()=>p(null),meterId:h.meterId,customerId:e,reading:h.reading})]})}function AS({customerId:e,contracts:t}){const{hasPermission:n}=Be(),r=Vt(),a=pe(),i=W({mutationFn:$e.delete,onSuccess:()=>{a.invalidateQueries({queryKey:["customer",e.toString()]}),a.invalidateQueries({queryKey:["customers"]}),a.invalidateQueries({queryKey:["contracts"]})},onError:c=>{alert((c==null?void 0:c.message)||"Fehler beim Löschen des Vertrags")}}),l={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},o={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"};return s.jsxs("div",{children:[n("contracts:create")&&s.jsx("div",{className:"mb-4",children:s.jsx(Ne,{to:`/contracts/new?customerId=${e}`,children:s.jsxs(T,{size:"sm",children:[s.jsx(Re,{className:"w-4 h-4 mr-2"}),"Vertrag anlegen"]})})}),t.length>0?s.jsx("div",{className:"space-y-4",children:t.map(c=>s.jsxs("div",{className:"border rounded-lg p-4 hover:bg-gray-50 transition-colors",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"font-mono flex items-center gap-1",children:[c.contractNumber,s.jsx(ce,{value:c.contractNumber})]}),s.jsx(ge,{children:l[c.type]}),s.jsx(ge,{variant:o[c.status],children:c.status})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>r(`/contracts/${c.id}`,{state:{from:"customer",customerId:e.toString()}}),title:"Ansehen",children:s.jsx(De,{className:"w-4 h-4"})}),n("contracts:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>r(`/contracts/${c.id}/edit`),title:"Bearbeiten",children:s.jsx(Je,{className:"w-4 h-4"})}),n("contracts:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertrag wirklich löschen?")&&i.mutate(c.id)},title:"Löschen",children:s.jsx(ve,{className:"w-4 h-4 text-red-500"})})]})]}),c.providerName&&s.jsxs("p",{className:"flex items-center gap-1",children:[c.providerName,c.tariffName&&` - ${c.tariffName}`,s.jsx(ce,{value:c.providerName+(c.tariffName?` - ${c.tariffName}`:"")})]}),c.startDate&&s.jsxs("p",{className:"text-sm text-gray-500",children:["Beginn: ",new Date(c.startDate).toLocaleDateString("de-DE"),c.endDate&&` | Ende: ${new Date(c.endDate).toLocaleDateString("de-DE")}`]})]},c.id))}):s.jsx("p",{className:"text-gray-500",children:"Keine Verträge vorhanden."})]})}function MS({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 u=await Nt.getPortalPassword(e);a(((c=u.data)==null?void 0:c.password)||null),n(!0)}catch(u){console.error("Fehler beim Laden des Passworts:",u),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(Et,{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 TS({customerId:e,canEdit:t}){const n=pe(),[r,a]=b.useState(!1),[i,l]=b.useState(""),[o,c]=b.useState(""),[u,d]=b.useState([]),[h,p]=b.useState(!1),{data:m,isLoading:f}=he({queryKey:["customer-portal",e],queryFn:()=>Nt.getPortalSettings(e)}),{data:y,isLoading:N}=he({queryKey:["customer-representatives",e],queryFn:()=>Nt.getRepresentatives(e)}),v=W({mutationFn:S=>Nt.updatePortalSettings(e,S),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-portal",e]})}}),g=W({mutationFn:S=>Nt.setPortalPassword(e,S),onSuccess:()=>{l(""),n.invalidateQueries({queryKey:["customer-portal",e]}),alert("Passwort wurde gesetzt")},onError:S=>{alert(S.message)}}),x=W({mutationFn:S=>Nt.addRepresentative(e,S),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-representatives",e]}),c(""),d([])},onError:S=>{alert(S.message)}}),j=W({mutationFn:S=>Nt.removeRepresentative(e,S),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-representatives",e]})}}),k=async()=>{if(!(o.length<2)){p(!0);try{const S=await Nt.searchForRepresentative(e,o);d(S.data||[])}catch(S){console.error("Suche fehlgeschlagen:",S)}finally{p(!1)}}};if(f||N)return s.jsx("div",{className:"text-center py-4 text-gray-500",children:"Laden..."});const F=m==null?void 0:m.data,E=(y==null?void 0:y.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(Rm,{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:(F==null?void 0:F.portalEnabled)||!1,onChange:S=>v.mutate({portalEnabled:S.target.checked}),className:"rounded w-5 h-5",disabled:!t}),s.jsx("span",{children:"Portal aktiviert"}),(F==null?void 0:F.portalEnabled)&&s.jsx(ge,{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(K,{value:(F==null?void 0:F.portalEmail)||"",onChange:S=>v.mutate({portalEmail:S.target.value||null}),placeholder:"portal@example.com",disabled:!t||!(F!=null&&F.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."})]}),(F==null?void 0:F.portalEnabled)&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:F!=null&&F.hasPassword?"Neues Passwort setzen":"Passwort setzen"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(K,{type:r?"text":"password",value:i,onChange:S=>l(S.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(Et,{className:"w-4 h-4"}):s.jsx(De,{className:"w-4 h-4"})})]}),s.jsx(T,{onClick:()=>g.mutate(i),disabled:!t||i.length<6||g.isPending,children:g.isPending?"Speichern...":"Setzen"})]}),(F==null?void 0:F.hasPassword)&&s.jsx(MS,{customerId:e})]}),(F==null?void 0:F.portalLastLogin)&&s.jsxs("p",{className:"text-sm text-gray-500",children:["Letzte Anmeldung: ",new Date(F.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(lS,{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(K,{value:o,onChange:S=>c(S.target.value),placeholder:"Kunden suchen (Name, Kundennummer)...",onKeyDown:S=>S.key==="Enter"&&k(),className:"flex-1"}),s.jsx(T,{variant:"secondary",onClick:k,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."}),u.length>0&&s.jsx("div",{className:"mt-2 border rounded-lg divide-y",children:u.map(S=>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:S.companyName||`${S.firstName} ${S.lastName}`}),s.jsx("p",{className:"text-sm text-gray-500",children:S.customerNumber})]}),s.jsxs(T,{size:"sm",onClick:()=>x.mutate(S.id),disabled:x.isPending,children:[s.jsx(Re,{className:"w-4 h-4 mr-1"}),"Hinzufügen"]})]},S.id))})]}),E.length>0?s.jsx("div",{className:"space-y-2",children:E.map(S=>{var P,A,_,L;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:((P=S.representative)==null?void 0:P.companyName)||`${(A=S.representative)==null?void 0:A.firstName} ${(_=S.representative)==null?void 0:_.lastName}`}),s.jsx("p",{className:"text-sm text-gray-500",children:(L=S.representative)==null?void 0:L.customerNumber})]}),t&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertreter wirklich entfernen?")&&j.mutate(S.representativeId)},children:s.jsx(jn,{className:"w-4 h-4 text-red-500"})})]},S.id)})}):s.jsx("p",{className:"text-gray-500 text-sm",children:"Keine Vertreter konfiguriert."})]})]})}function Ip({isOpen:e,onClose:t,customerId:n,address:r}){const a=pe(),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),u=W({mutationFn:m=>bd.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({type:"DELIVERY_RESIDENCE",street:"",houseNumber:"",postalCode:"",city:"",country:"Deutschland",isDefault:!1})}}),d=W({mutationFn:m=>bd.update(r.id,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),h=m=>{m.preventDefault(),i?d.mutate(o):u.mutate(o)},p=u.isPending||d.isPending;return i&&o.street!==r.street&&c(l()),s.jsx(ot,{isOpen:e,onClose:t,title:i?"Adresse bearbeiten":"Adresse hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(Le,{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(K,{label:"Straße",value:o.street,onChange:m=>c({...o,street:m.target.value}),required:!0})}),s.jsx(K,{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(K,{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(K,{label:"Ort",value:o.city,onChange:m=>c({...o,city:m.target.value}),required:!0})})]}),s.jsx(K,{label:"Land",value:o.country,onChange:m=>c({...o,country:m.target.value})}),s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:o.isDefault,onChange:m=>c({...o,isDefault:m.target.checked}),className:"rounded"}),"Als Standard setzen"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function Lp({isOpen:e,onClose:t,customerId:n,bankCard:r}){const a=pe(),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 u=W({mutationFn:m=>Fo.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({accountHolder:"",iban:"",bic:"",bankName:"",expiryDate:"",isActive:!0})}}),d=W({mutationFn:m=>Fo.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?d.mutate(f):u.mutate(f)},p=u.isPending||d.isPending;return i&&o.iban!==r.iban&&c(l()),s.jsx(ot,{isOpen:e,onClose:t,title:i?"Bankkarte bearbeiten":"Bankkarte hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(K,{label:"Kontoinhaber",value:o.accountHolder,onChange:m=>c({...o,accountHolder:m.target.value}),required:!0}),s.jsx(K,{label:"IBAN",value:o.iban,onChange:m=>c({...o,iban:m.target.value}),required:!0}),s.jsx(K,{label:"BIC",value:o.bic,onChange:m=>c({...o,bic:m.target.value})}),s.jsx(K,{label:"Bank",value:o.bankName,onChange:m=>c({...o,bankName:m.target.value})}),s.jsx(K,{label:"Ablaufdatum",type:"date",value:o.expiryDate,onChange:m=>c({...o,expiryDate:m.target.value}),onClear:()=>c({...o,expiryDate:""})}),i&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:o.isActive,onChange:m=>c({...o,isActive:m.target.checked}),className:"rounded"}),"Aktiv"]}),!i&&s.jsx("p",{className:"text-sm text-gray-500 bg-gray-50 p-3 rounded",children:"Dokument-Upload ist nach dem Speichern in der Übersicht möglich."}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function Rp({isOpen:e,onClose:t,customerId:n,document:r}){const a=pe(),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),u=W({mutationFn:m=>Io.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({type:"ID_CARD",documentNumber:"",issuingAuthority:"",issueDate:"",expiryDate:"",isActive:!0,licenseClasses:"",licenseIssueDate:""})}}),d=W({mutationFn:m=>Io.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?d.mutate(f):u.mutate(f)},p=u.isPending||d.isPending;return i&&o.documentNumber!==r.documentNumber&&c(l()),s.jsx(ot,{isOpen:e,onClose:t,title:i?"Ausweis bearbeiten":"Ausweis hinzufügen",children:s.jsxs("form",{onSubmit:h,className:"space-y-4",children:[s.jsx(Le,{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(K,{label:"Ausweisnummer",value:o.documentNumber,onChange:m=>c({...o,documentNumber:m.target.value}),required:!0}),s.jsx(K,{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(K,{label:"Ausstellungsdatum",type:"date",value:o.issueDate,onChange:m=>c({...o,issueDate:m.target.value}),onClear:()=>c({...o,issueDate:""})}),s.jsx(K,{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(K,{label:"Führerscheinklassen",value:o.licenseClasses,onChange:m=>c({...o,licenseClasses:m.target.value}),placeholder:"z.B. B, BE, AM, L"}),s.jsx(K,{label:"Erwerb Klasse B (Pkw)",type:"date",value:o.licenseIssueDate,onChange:m=>c({...o,licenseIssueDate:m.target.value}),onClear:()=>c({...o,licenseIssueDate:""})})]}),i&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:o.isActive,onChange:m=>c({...o,isActive:m.target.checked}),className:"rounded"}),"Aktiv"]}),!i&&s.jsx("p",{className:"text-sm text-gray-500 bg-gray-50 p-3 rounded",children:"Dokument-Upload ist nach dem Speichern in der Übersicht möglich."}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function Op({isOpen:e,onClose:t,customerId:n,meter:r}){const a=pe(),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),u=W({mutationFn:m=>Hs.create(n,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t(),c({meterNumber:"",type:"ELECTRICITY",location:"",isActive:!0})}}),d=W({mutationFn:m=>Hs.update(r.id,m),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),h=m=>{m.preventDefault(),i?d.mutate(o):u.mutate(o)},p=u.isPending||d.isPending;return i&&o.meterNumber!==r.meterNumber&&c(l()),s.jsx(ot,{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(K,{label:"Zählernummer",value:o.meterNumber,onChange:m=>c({...o,meterNumber:m.target.value}),required:!0}),s.jsx(Le,{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(K,{label:"Standort",value:o.location,onChange:m=>c({...o,location:m.target.value}),placeholder:"z.B. Keller, Wohnung"}),i&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:o.isActive,onChange:m=>c({...o,isActive:m.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function zp({isOpen:e,onClose:t,meterId:n,customerId:r,reading:a}){const i=pe(),l=!!a,o=()=>{var f;return{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())||"",unit:(a==null?void 0:a.unit)||"kWh",notes:(a==null?void 0:a.notes)||""}},[c,u]=b.useState(o),d=W({mutationFn:f=>Hs.addReading(n,f),onSuccess:()=>{i.invalidateQueries({queryKey:["customer",r.toString()]}),t()}}),h=W({mutationFn:f=>Hs.updateReading(n,a.id,f),onSuccess:()=>{i.invalidateQueries({queryKey:["customer",r.toString()]}),t()}}),p=f=>{f.preventDefault();const y={readingDate:new Date(c.readingDate),value:parseFloat(c.value),unit:c.unit,notes:c.notes||void 0};l?h.mutate(y):d.mutate(y)},m=d.isPending||h.isPending;return l&&c.value!==a.value.toString()&&u(o()),s.jsx(ot,{isOpen:e,onClose:t,title:l?"Zählerstand bearbeiten":"Zählerstand erfassen",children:s.jsxs("form",{onSubmit:p,className:"space-y-4",children:[s.jsx(K,{label:"Ablesedatum",type:"date",value:c.readingDate,onChange:f=>u({...c,readingDate:f.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(K,{label:"Zählerstand",type:"number",step:"0.01",value:c.value,onChange:f=>u({...c,value:f.target.value}),required:!0})}),s.jsx(Le,{label:"Einheit",value:c.unit,onChange:f=>u({...c,unit:f.target.value}),options:[{value:"kWh",label:"kWh"},{value:"m³",label:"m³"}]})]}),s.jsx(K,{label:"Notizen",value:c.notes,onChange:f=>u({...c,notes:f.target.value}),placeholder:"Optionale Notizen..."}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:m,children:m?"Speichern...":"Speichern"})]})]})})}const Xc="@stressfrei-wechseln.de";function FS({customerId:e,emails:t,canEdit:n,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=pe(),c=W({mutationFn:({id:h,data:p})=>Ds.update(h,p),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),u=W({mutationFn:Ds.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=r?t:t.filter(h=>h.isActive);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&s.jsxs(T,{size:"sm",onClick:i,children:[s.jsx(Re,{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."]}),d.length>0?s.jsx("div",{className:"space-y-3",children:d.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(mn,{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(ge,{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(at,{className:"w-4 h-4 flex-shrink-0"}),s.jsx("span",{children:h.notes})]})]}),n&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>l(h),title:"Bearbeiten",children:s.jsx(Je,{className:"w-4 h-4"})}),h.isActive?s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse deaktivieren?")&&c.mutate({id:h.id,data:{isActive:!1}})},title:"Deaktivieren",children:s.jsx(Et,{className:"w-4 h-4"})}):s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wieder aktivieren?")&&c.mutate({id:h.id,data:{isActive:!0}})},title:"Aktivieren",children:s.jsx(De,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wirklich löschen?")&&u.mutate(h.id)},title:"Löschen",children:s.jsx(ve,{className:"w-4 h-4 text-red-500"})})]})]})},h.id))}):s.jsx("p",{className:"text-gray-500",children:"Keine Stressfrei-Wechseln Adressen vorhanden."})]})}function _p({isOpen:e,onClose:t,customerId:n,email:r,customerEmail:a}){const[i,l]=b.useState(""),[o,c]=b.useState(""),[u,d]=b.useState(!1),[h,p]=b.useState(!1),[m,f]=b.useState(null),[y,N]=b.useState("idle"),[v,g]=b.useState(!1),[x,j]=b.useState(!1),[k,F]=b.useState(!1),[E,S]=b.useState(!1),[P,A]=b.useState(null),[_,L]=b.useState(!1),[V,q]=b.useState(!1),O=pe(),C=!!r,{data:w}=he({queryKey:["email-provider-configs"],queryFn:()=>sn.getConfigs(),enabled:e}),R=((w==null?void 0:w.data)||[]).some(G=>G.isActive&&G.isDefault),Q=G=>{if(!G)return"";const ze=G.indexOf("@");return ze>0?G.substring(0,ze):G},ee=async G=>{var ze;if(!(!R||!G)){N("checking");try{const Rt=await sn.checkEmailExists(G);N((ze=Rt.data)!=null&&ze.exists?"exists":"not_exists")}catch{N("error")}}},fe=async()=>{var G,ze;if(!(!a||!i)){g(!0),f(null);try{const Rt=await sn.provisionEmail(i,a);(G=Rt.data)!=null&&G.success?N("exists"):f(((ze=Rt.data)==null?void 0:ze.error)||"Provisionierung fehlgeschlagen")}catch(Rt){f(Rt instanceof Error?Rt.message:"Fehler bei der Provisionierung")}finally{g(!1)}}},ue=async()=>{if(r){j(!0),f(null);try{const G=await Ds.enableMailbox(r.id);G.success?(F(!0),O.invalidateQueries({queryKey:["customer",n.toString()]}),O.invalidateQueries({queryKey:["mailbox-accounts",n]})):f(G.error||"Mailbox-Aktivierung fehlgeschlagen")}catch(G){f(G instanceof Error?G.message:"Fehler bei der Mailbox-Aktivierung")}finally{j(!1)}}},nt=async()=>{if(r)try{const G=await Ds.syncMailboxStatus(r.id);G.success&&G.data&&(F(G.data.hasMailbox),G.data.wasUpdated&&O.invalidateQueries({queryKey:["customer",n.toString()]}))}catch(G){console.error("Fehler beim Synchronisieren des Mailbox-Status:",G)}},H=async()=>{if(r){L(!0);try{const G=await Ds.getMailboxCredentials(r.id);G.success&&G.data&&(A(G.data),S(!0))}catch(G){console.error("Fehler beim Laden der Zugangsdaten:",G)}finally{L(!1)}}},ke=async()=>{if(r&&confirm("Neues Passwort generieren? Das alte Passwort wird ungültig.")){q(!0);try{const G=await Ds.resetPassword(r.id);G.success&&G.data?(P&&A({...P,password:G.data.password}),alert("Passwort wurde erfolgreich zurückgesetzt.")):alert(G.error||"Fehler beim Zurücksetzen des Passworts")}catch(G){console.error("Fehler beim Zurücksetzen des Passworts:",G),alert(G instanceof Error?G.message:"Fehler beim Zurücksetzen des Passworts")}finally{q(!1)}}};b.useEffect(()=>{if(e){if(r){const G=Q(r.email);l(G),c(r.notes||""),N("idle"),F(r.hasMailbox||!1),R&&(ee(G),nt())}else l(""),c(""),d(!1),p(!1),N("idle"),F(!1);f(null),S(!1),A(null)}},[e,r,R]);const Ae=W({mutationFn:async G=>Ds.create(n,{email:G.email,notes:G.notes,provisionAtProvider:G.provision,createMailbox:G.createMailbox}),onSuccess:()=>{O.invalidateQueries({queryKey:["customer",n.toString()]}),O.invalidateQueries({queryKey:["mailbox-accounts",n]}),l(""),c(""),d(!1),p(!1),t()},onError:G=>{f(G instanceof Error?G.message:"Fehler bei der Provisionierung")}}),rt=W({mutationFn:G=>Ds.update(r.id,G),onSuccess:()=>{O.invalidateQueries({queryKey:["customer",n.toString()]}),t()}}),St=G=>{G.preventDefault(),f(null);const ze=i+Xc;C?rt.mutate({email:ze,notes:o||void 0}):Ae.mutate({email:ze,notes:o||void 0,provision:u,createMailbox:u&&h})},At=Ae.isPending||rt.isPending;return s.jsx(ot,{isOpen:e,onClose:t,title:C?"Adresse bearbeiten":"Adresse hinzufügen",children:s.jsxs("form",{onSubmit:St,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:G=>l(G.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:Xc})]}),s.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Vollständige Adresse: ",s.jsxs("span",{className:"font-mono",children:[i||"...",Xc]})]})]}),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:G=>c(G.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..."})]}),R&&a&&s.jsx("div",{className:"bg-blue-50 p-3 rounded-lg",children:C?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"}),y==="checking"&&s.jsx("span",{className:"text-xs text-gray-500",children:"Prüfe..."}),y==="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"]}),y==="not_exists"&&s.jsx("span",{className:"text-xs text-orange-600",children:"Nicht beim Provider angelegt"}),y==="error"&&s.jsx("span",{className:"text-xs text-red-600",children:"Status konnte nicht geprüft werden"})]}),y==="not_exists"&&s.jsxs("div",{className:"pt-2 border-t border-blue-100",children:[s.jsxs("p",{className:"text-xs text-gray-500 mb-2",children:["Die E-Mail-Weiterleitung ist noch nicht auf dem Server eingerichtet. Weiterleitungsziel: ",a]}),s.jsx(T,{type:"button",size:"sm",onClick:fe,disabled:v,children:v?"Wird angelegt...":"Jetzt beim Provider anlegen"})]}),y==="error"&&s.jsx(T,{type:"button",size:"sm",variant:"secondary",onClick:()=>ee(i),children:"Erneut prüfen"}),y==="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)"}),k?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"})]}),!k&&s.jsxs("div",{className:"mt-2",children:[s.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"Aktiviere eine echte Mailbox um E-Mails direkt im CRM zu empfangen und zu versenden."}),s.jsx(T,{type:"button",size:"sm",onClick:ue,disabled:x,children:x?"Wird aktiviert...":"Mailbox aktivieren"})]}),k&&s.jsx("div",{className:"mt-3",children:E?P&&s.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg p-3 space-y-2",children:[s.jsxs("div",{className:"flex justify-between items-center mb-2",children:[s.jsx("span",{className:"text-xs font-medium text-gray-500 uppercase",children:"Zugangsdaten"}),s.jsx("button",{type:"button",onClick:()=>S(!1),className:"text-gray-400 hover:text-gray-600",children:s.jsx(Et,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"E-Mail:"}),s.jsx("p",{className:"font-mono text-gray-900 break-all",children:P.email})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"Passwort:"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"font-mono text-gray-900 break-all select-all flex-1",children:P.password}),s.jsx("button",{type:"button",onClick:ke,disabled:V,className:"text-blue-600 hover:text-blue-800 text-xs whitespace-nowrap disabled:opacity-50",title:"Neues Kennwort generieren",children:V?"Generiere...":"Neu generieren"})]})]})]}),P.imap&&s.jsxs("div",{className:"pt-2 border-t border-gray-100",children:[s.jsx("span",{className:"text-xs font-medium text-gray-500",children:"IMAP (Empfang)"}),s.jsxs("p",{className:"font-mono text-xs text-gray-900",children:[P.imap.server,":",P.imap.port," (",P.imap.encryption,")"]})]}),P.smtp&&s.jsxs("div",{className:"pt-2 border-t border-gray-100",children:[s.jsx("span",{className:"text-xs font-medium text-gray-500",children:"SMTP (Versand)"}),s.jsxs("p",{className:"font-mono text-xs text-gray-900",children:[P.smtp.server,":",P.smtp.port," (",P.smtp.encryption,")"]})]})]}):s.jsx(T,{type:"button",size:"sm",variant:"secondary",onClick:H,disabled:_,children:_?"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:u,onChange:G=>{d(G.target.checked),G.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]})]})]}),u&&s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer ml-6",children:[s.jsx("input",{type:"checkbox",checked:h,onChange:G=>p(G.target.checked),className:"mt-1 rounded border-gray-300"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Echte Mailbox erstellen (IMAP/SMTP-Zugang)"}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Ermöglicht E-Mails direkt im CRM zu empfangen und zu versenden."})]})]})]})}),m&&s.jsx("div",{className:"bg-red-50 p-3 rounded-lg text-red-700 text-sm",children:m}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:At||!i,children:At?"Speichern...":"Speichern"})]})]})})}var dl=e=>e.type==="checkbox",xr=e=>e instanceof Date,Gt=e=>e==null;const q0=e=>typeof e=="object";var dt=e=>!Gt(e)&&!Array.isArray(e)&&q0(e)&&!xr(e),IS=e=>dt(e)&&e.target?dl(e.target)?e.target.checked:e.target.value:e,LS=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,RS=(e,t)=>e.has(LS(t)),OS=e=>{const t=e.constructor&&e.constructor.prototype;return dt(t)&&t.hasOwnProperty("isPrototypeOf")},Um=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function mt(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Um&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(dt(e)&&OS(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=mt(e[a]));return r}var xc=e=>/^\w*$/.test(e),Qe=e=>e===void 0,Bm=e=>Array.isArray(e)?e.filter(Boolean):[],Km=e=>Bm(e.replace(/["|']|\]/g,"").split(/\.|\[/)),oe=(e,t,n)=>{if(!t||!dt(e))return n;const r=(xc(t)?[t]:Km(t)).reduce((a,i)=>Gt(a)?a:a[i],e);return Qe(r)||r===e?Qe(e[t])?n:e[t]:r},_s=e=>typeof e=="boolean",Ps=e=>typeof e=="function",Ke=(e,t,n)=>{let r=-1;const a=xc(t)?[t]:Km(t),i=a.length,l=i-1;for(;++r<i;){const o=a[r];let c=n;if(r!==l){const u=e[o];c=dt(u)||Array.isArray(u)?u:isNaN(+a[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=c,e=e[o]}};const $p={BLUR:"blur",FOCUS_OUT:"focusout"},As={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Xs={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},zS=Ct.createContext(null);zS.displayName="HookFormControlContext";var _S=(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]!==As.all&&(t._proxyFormState[l]=!r||As.all),e[l]}});return a};const $S=typeof window<"u"?Ct.useLayoutEffect:Ct.useEffect;var as=e=>typeof e=="string",US=(e,t,n,r,a)=>as(e)?(r&&t.watch.add(e),oe(n,e,a)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),oe(n,i))):(r&&(t.watchAll=!0),n),Sd=e=>Gt(e)||!q0(e);function Tn(e,t,n=new WeakSet){if(Sd(e)||Sd(t))return Object.is(e,t);if(xr(e)&&xr(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(xr(l)&&xr(o)||dt(l)&&dt(o)||Array.isArray(l)&&Array.isArray(o)?!Tn(l,o,n):!Object.is(l,o))return!1}}return!0}const BS=Ct.createContext(null);BS.displayName="HookFormContext";var KS=(e,t,n,r,a)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:a||!0}}:{},ji=e=>Array.isArray(e)?e:[e],Up=()=>{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 V0(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const a=e[r],i=t[r];if(a&&dt(a)&&i){const l=V0(a,i);dt(l)&&(n[r]=l)}else e[r]&&(n[r]=i)}return n}var _t=e=>dt(e)&&!Object.keys(e).length,qm=e=>e.type==="file",Ro=e=>{if(!Um)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Q0=e=>e.type==="select-multiple",Vm=e=>e.type==="radio",qS=e=>Vm(e)||dl(e),Yc=e=>Ro(e)&&e.isConnected;function VS(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=Qe(e)?r++:e[t[r++]];return e}function QS(e){for(const t in e)if(e.hasOwnProperty(t)&&!Qe(e[t]))return!1;return!0}function ct(e,t){const n=Array.isArray(t)?t:xc(t)?[t]:Km(t),r=n.length===1?e:VS(e,n),a=n.length-1,i=n[a];return r&&delete r[i],a!==0&&(dt(r)&&_t(r)||Array.isArray(r)&&QS(r))&&ct(e,n.slice(0,-1)),e}var HS=e=>{for(const t in e)if(Ps(e[t]))return!0;return!1};function H0(e){return Array.isArray(e)||dt(e)&&!HS(e)}function kd(e,t={}){for(const n in e){const r=e[n];H0(r)?(t[n]=Array.isArray(r)?[]:{},kd(r,t[n])):Qe(r)||(t[n]=!0)}return t}function Hr(e,t,n){n||(n=kd(t));for(const r in e){const a=e[r];if(H0(a))Qe(t)||Sd(n[r])?n[r]=kd(a,Array.isArray(a)?[]:{}):Hr(a,Gt(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!Tn(a,i)}}return n}const Bp={value:!1,isValid:!1},Kp={value:!0,isValid:!0};var W0=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&&!Qe(e[0].attributes.value)?Qe(e[0].value)||e[0].value===""?Kp:{value:e[0].value,isValid:!0}:Kp:Bp}return Bp},G0=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Qe(e)?e:t?e===""?NaN:e&&+e:n&&as(e)?new Date(e):r?r(e):e;const qp={isValid:!1,value:null};var Z0=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,qp):qp;function Vp(e){const t=e.ref;return qm(t)?t.files:Vm(t)?Z0(e.refs).value:Q0(t)?[...t.selectedOptions].map(({value:n})=>n):dl(t)?W0(e.refs).value:G0(Qe(t.value)?e.ref.value:t.value,e)}var WS=(e,t,n,r)=>{const a={};for(const i of e){const l=oe(t,i);l&&Ke(a,i,l._f)}return{criteriaMode:n,names:[...e],fields:a,shouldUseNativeValidation:r}},Oo=e=>e instanceof RegExp,ni=e=>Qe(e)?e:Oo(e)?e.source:dt(e)?Oo(e.value)?e.value.source:e.value:e,Qp=e=>({isOnSubmit:!e||e===As.onSubmit,isOnBlur:e===As.onBlur,isOnChange:e===As.onChange,isOnAll:e===As.all,isOnTouch:e===As.onTouched});const Hp="AsyncFunction";var GS=e=>!!e&&!!e.validate&&!!(Ps(e.validate)&&e.validate.constructor.name===Hp||dt(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Hp)),ZS=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Wp=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const bi=(e,t,n,r)=>{for(const a of n||Object.keys(e)){const i=oe(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(bi(o,t))break}else if(dt(o)&&bi(o,t))break}}};function Gp(e,t,n){const r=oe(e,n);if(r||xc(n))return{error:r,name:n};const a=n.split(".");for(;a.length;){const i=a.join("."),l=oe(t,i),o=oe(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 JS=(e,t,n,r)=>{n(e);const{name:a,...i}=e;return _t(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(l=>t[l]===(!r||As.all))},XS=(e,t,n)=>!e||!t||e===t||ji(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),YS=(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,ek=(e,t)=>!Bm(oe(e,t)).length&&ct(e,t),tk=(e,t,n)=>{const r=ji(oe(e,n));return Ke(r,"root",t[n]),Ke(e,n,r),e};function Zp(e,t,n="validate"){if(as(e)||Array.isArray(e)&&e.every(as)||_s(e)&&!e)return{type:n,message:as(e)?e:"",ref:t}}var Vr=e=>dt(e)&&!Oo(e)?e:{value:e,message:""},Jp=async(e,t,n,r,a,i)=>{const{ref:l,refs:o,required:c,maxLength:u,minLength:d,min:h,max:p,pattern:m,validate:f,name:y,valueAsNumber:N,mount:v}=e._f,g=oe(n,y);if(!v||t.has(y))return{};const x=o?o[0]:l,j=L=>{a&&x.reportValidity&&(x.setCustomValidity(_s(L)?"":L||""),x.reportValidity())},k={},F=Vm(l),E=dl(l),S=F||E,P=(N||qm(l))&&Qe(l.value)&&Qe(g)||Ro(l)&&l.value===""||g===""||Array.isArray(g)&&!g.length,A=KS.bind(null,y,r,k),_=(L,V,q,O=Xs.maxLength,C=Xs.minLength)=>{const w=L?V:q;k[y]={type:L?O:C,message:w,ref:l,...A(L?O:C,w)}};if(i?!Array.isArray(g)||!g.length:c&&(!S&&(P||Gt(g))||_s(g)&&!g||E&&!W0(o).isValid||F&&!Z0(o).isValid)){const{value:L,message:V}=as(c)?{value:!!c,message:c}:Vr(c);if(L&&(k[y]={type:Xs.required,message:V,ref:x,...A(Xs.required,V)},!r))return j(V),k}if(!P&&(!Gt(h)||!Gt(p))){let L,V;const q=Vr(p),O=Vr(h);if(!Gt(g)&&!isNaN(g)){const C=l.valueAsNumber||g&&+g;Gt(q.value)||(L=C>q.value),Gt(O.value)||(V=C<O.value)}else{const C=l.valueAsDate||new Date(g),w=ee=>new Date(new Date().toDateString()+" "+ee),R=l.type=="time",Q=l.type=="week";as(q.value)&&g&&(L=R?w(g)>w(q.value):Q?g>q.value:C>new Date(q.value)),as(O.value)&&g&&(V=R?w(g)<w(O.value):Q?g<O.value:C<new Date(O.value))}if((L||V)&&(_(!!L,q.message,O.message,Xs.max,Xs.min),!r))return j(k[y].message),k}if((u||d)&&!P&&(as(g)||i&&Array.isArray(g))){const L=Vr(u),V=Vr(d),q=!Gt(L.value)&&g.length>+L.value,O=!Gt(V.value)&&g.length<+V.value;if((q||O)&&(_(q,L.message,V.message),!r))return j(k[y].message),k}if(m&&!P&&as(g)){const{value:L,message:V}=Vr(m);if(Oo(L)&&!g.match(L)&&(k[y]={type:Xs.pattern,message:V,ref:l,...A(Xs.pattern,V)},!r))return j(V),k}if(f){if(Ps(f)){const L=await f(g,n),V=Zp(L,x);if(V&&(k[y]={...V,...A(Xs.validate,V.message)},!r))return j(V.message),k}else if(dt(f)){let L={};for(const V in f){if(!_t(L)&&!r)break;const q=Zp(await f[V](g,n),x,V);q&&(L={...q,...A(V,q.message)},j(q.message),r&&(k[y]=L))}if(!_t(L)&&(k[y]={ref:x,...L},!r))return k}}return j(!0),k};const sk={mode:As.onSubmit,reValidateMode:As.onChange,shouldFocusError:!0};function nk(e={}){let t={...sk,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:Ps(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},a=dt(t.defaultValues)||dt(t.values)?mt(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:mt(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,u=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={...d};let p={...h};const m={array:Up(),state:Up()},f=t.criteriaMode===As.all,y=M=>$=>{clearTimeout(u),u=setTimeout(M,$)},N=async M=>{if(!l.keepIsValid&&!t.disabled&&(h.isValid||p.isValid||M)){let $;t.resolver?($=_t((await S()).errors),v()):$=await A(r,!0),$!==n.isValid&&m.state.next({isValid:$})}},v=(M,$)=>{!t.disabled&&(h.isValidating||h.validatingFields||p.isValidating||p.validatingFields)&&((M||Array.from(o.mount)).forEach(B=>{B&&($?Ke(n.validatingFields,B,$):ct(n.validatingFields,B))}),m.state.next({validatingFields:n.validatingFields,isValidating:!_t(n.validatingFields)}))},g=(M,$=[],B,ae,Y=!0,J=!0)=>{if(ae&&B&&!t.disabled){if(l.action=!0,J&&Array.isArray(oe(r,M))){const de=B(oe(r,M),ae.argA,ae.argB);Y&&Ke(r,M,de)}if(J&&Array.isArray(oe(n.errors,M))){const de=B(oe(n.errors,M),ae.argA,ae.argB);Y&&Ke(n.errors,M,de),ek(n.errors,M)}if((h.touchedFields||p.touchedFields)&&J&&Array.isArray(oe(n.touchedFields,M))){const de=B(oe(n.touchedFields,M),ae.argA,ae.argB);Y&&Ke(n.touchedFields,M,de)}(h.dirtyFields||p.dirtyFields)&&(n.dirtyFields=Hr(a,i)),m.state.next({name:M,isDirty:L(M,$),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Ke(i,M,$)},x=(M,$)=>{Ke(n.errors,M,$),m.state.next({errors:n.errors})},j=M=>{n.errors=M,m.state.next({errors:n.errors,isValid:!1})},k=(M,$,B,ae)=>{const Y=oe(r,M);if(Y){const J=oe(i,M,Qe(B)?oe(a,M):B);Qe(J)||ae&&ae.defaultChecked||$?Ke(i,M,$?J:Vp(Y._f)):O(M,J),l.mount&&!l.action&&N()}},F=(M,$,B,ae,Y)=>{let J=!1,de=!1;const Ce={name:M};if(!t.disabled){if(!B||ae){(h.isDirty||p.isDirty)&&(de=n.isDirty,n.isDirty=Ce.isDirty=L(),J=de!==Ce.isDirty);const Me=Tn(oe(a,M),$);de=!!oe(n.dirtyFields,M),Me?ct(n.dirtyFields,M):Ke(n.dirtyFields,M,!0),Ce.dirtyFields=n.dirtyFields,J=J||(h.dirtyFields||p.dirtyFields)&&de!==!Me}if(B){const Me=oe(n.touchedFields,M);Me||(Ke(n.touchedFields,M,B),Ce.touchedFields=n.touchedFields,J=J||(h.touchedFields||p.touchedFields)&&Me!==B)}J&&Y&&m.state.next(Ce)}return J?Ce:{}},E=(M,$,B,ae)=>{const Y=oe(n.errors,M),J=(h.isValid||p.isValid)&&_s($)&&n.isValid!==$;if(t.delayError&&B?(c=y(()=>x(M,B)),c(t.delayError)):(clearTimeout(u),c=null,B?Ke(n.errors,M,B):ct(n.errors,M)),(B?!Tn(Y,B):Y)||!_t(ae)||J){const de={...ae,...J&&_s($)?{isValid:$}:{},errors:n.errors,name:M};n={...n,...de},m.state.next(de)}},S=async M=>(v(M,!0),await t.resolver(i,t.context,WS(M||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),P=async M=>{const{errors:$}=await S(M);if(v(M),M)for(const B of M){const ae=oe($,B);ae?Ke(n.errors,B,ae):ct(n.errors,B)}else n.errors=$;return $},A=async(M,$,B={valid:!0})=>{for(const ae in M){const Y=M[ae];if(Y){const{_f:J,...de}=Y;if(J){const Ce=o.array.has(J.name),Me=Y._f&&GS(Y._f);Me&&h.validatingFields&&v([J.name],!0);const yt=await Jp(Y,o.disabled,i,f,t.shouldUseNativeValidation&&!$,Ce);if(Me&&h.validatingFields&&v([J.name]),yt[J.name]&&(B.valid=!1,$||e.shouldUseNativeValidation))break;!$&&(oe(yt,J.name)?Ce?tk(n.errors,yt,J.name):Ke(n.errors,J.name,yt[J.name]):ct(n.errors,J.name))}!_t(de)&&await A(de,$,B)}}return B.valid},_=()=>{for(const M of o.unMount){const $=oe(r,M);$&&($._f.refs?$._f.refs.every(B=>!Yc(B)):!Yc($._f.ref))&&St(M)}o.unMount=new Set},L=(M,$)=>!t.disabled&&(M&&$&&Ke(i,M,$),!Tn(fe(),a)),V=(M,$,B)=>US(M,o,{...l.mount?i:Qe($)?a:as(M)?{[M]:$}:$},B,$),q=M=>Bm(oe(l.mount?i:a,M,t.shouldUnregister?oe(a,M,[]):[])),O=(M,$,B={})=>{const ae=oe(r,M);let Y=$;if(ae){const J=ae._f;J&&(!J.disabled&&Ke(i,M,G0($,J)),Y=Ro(J.ref)&&Gt($)?"":$,Q0(J.ref)?[...J.ref.options].forEach(de=>de.selected=Y.includes(de.value)):J.refs?dl(J.ref)?J.refs.forEach(de=>{(!de.defaultChecked||!de.disabled)&&(Array.isArray(Y)?de.checked=!!Y.find(Ce=>Ce===de.value):de.checked=Y===de.value||!!Y)}):J.refs.forEach(de=>de.checked=de.value===Y):qm(J.ref)?J.ref.value="":(J.ref.value=Y,J.ref.type||m.state.next({name:M,values:mt(i)})))}(B.shouldDirty||B.shouldTouch)&&F(M,Y,B.shouldTouch,B.shouldDirty,!0),B.shouldValidate&&ee(M)},C=(M,$,B)=>{for(const ae in $){if(!$.hasOwnProperty(ae))return;const Y=$[ae],J=M+"."+ae,de=oe(r,J);(o.array.has(M)||dt(Y)||de&&!de._f)&&!xr(Y)?C(J,Y,B):O(J,Y,B)}},w=(M,$,B={})=>{const ae=oe(r,M),Y=o.array.has(M),J=mt($);Ke(i,M,J),Y?(m.array.next({name:M,values:mt(i)}),(h.isDirty||h.dirtyFields||p.isDirty||p.dirtyFields)&&B.shouldDirty&&m.state.next({name:M,dirtyFields:Hr(a,i),isDirty:L(M,J)})):ae&&!ae._f&&!Gt(J)?C(M,J,B):O(M,J,B),Wp(M,o)?m.state.next({...n,name:M,values:mt(i)}):m.state.next({name:l.mount?M:void 0,values:mt(i)})},R=async M=>{l.mount=!0;const $=M.target;let B=$.name,ae=!0;const Y=oe(r,B),J=Me=>{ae=Number.isNaN(Me)||xr(Me)&&isNaN(Me.getTime())||Tn(Me,oe(i,B,Me))},de=Qp(t.mode),Ce=Qp(t.reValidateMode);if(Y){let Me,yt;const Zs=$.type?Vp(Y._f):IS(M),bs=M.type===$p.BLUR||M.type===$p.FOCUS_OUT,hl=!ZS(Y._f)&&!t.resolver&&!oe(n.errors,B)&&!Y._f.deps||YS(bs,oe(n.touchedFields,B),n.isSubmitted,Ce,de),Br=Wp(B,o,bs);Ke(i,B,Zs),bs?(!$||!$.readOnly)&&(Y._f.onBlur&&Y._f.onBlur(M),c&&c(0)):Y._f.onChange&&Y._f.onChange(M);const Kr=F(B,Zs,bs),fl=!_t(Kr)||Br;if(!bs&&m.state.next({name:B,type:M.type,values:mt(i)}),hl)return(h.isValid||p.isValid)&&(t.mode==="onBlur"?bs&&N():bs||N()),fl&&m.state.next({name:B,...Br?{}:Kr});if(!bs&&Br&&m.state.next({...n}),t.resolver){const{errors:Va}=await S([B]);if(v([B]),J(Zs),ae){const pl=Gp(n.errors,r,B),Qa=Gp(Va,r,pl.name||B);Me=Qa.error,B=Qa.name,yt=_t(Va)}}else v([B],!0),Me=(await Jp(Y,o.disabled,i,f,t.shouldUseNativeValidation))[B],v([B]),J(Zs),ae&&(Me?yt=!1:(h.isValid||p.isValid)&&(yt=await A(r,!0)));ae&&(Y._f.deps&&(!Array.isArray(Y._f.deps)||Y._f.deps.length>0)&&ee(Y._f.deps),E(B,yt,Me,Kr))}},Q=(M,$)=>{if(oe(n.errors,$)&&M.focus)return M.focus(),1},ee=async(M,$={})=>{let B,ae;const Y=ji(M);if(t.resolver){const J=await P(Qe(M)?M:Y);B=_t(J),ae=M?!Y.some(de=>oe(J,de)):B}else M?(ae=(await Promise.all(Y.map(async J=>{const de=oe(r,J);return await A(de&&de._f?{[J]:de}:de)}))).every(Boolean),!(!ae&&!n.isValid)&&N()):ae=B=await A(r);return m.state.next({...!as(M)||(h.isValid||p.isValid)&&B!==n.isValid?{}:{name:M},...t.resolver||!M?{isValid:B}:{},errors:n.errors}),$.shouldFocus&&!ae&&bi(r,Q,M?Y:o.mount),ae},fe=(M,$)=>{let B={...l.mount?i:a};return $&&(B=V0($.dirtyFields?n.dirtyFields:n.touchedFields,B)),Qe(M)?B:as(M)?oe(B,M):M.map(ae=>oe(B,ae))},ue=(M,$)=>({invalid:!!oe(($||n).errors,M),isDirty:!!oe(($||n).dirtyFields,M),error:oe(($||n).errors,M),isValidating:!!oe(n.validatingFields,M),isTouched:!!oe(($||n).touchedFields,M)}),nt=M=>{M&&ji(M).forEach($=>ct(n.errors,$)),m.state.next({errors:M?n.errors:{}})},H=(M,$,B)=>{const ae=(oe(r,M,{_f:{}})._f||{}).ref,Y=oe(n.errors,M)||{},{ref:J,message:de,type:Ce,...Me}=Y;Ke(n.errors,M,{...Me,...$,ref:ae}),m.state.next({name:M,errors:n.errors,isValid:!1}),B&&B.shouldFocus&&ae&&ae.focus&&ae.focus()},ke=(M,$)=>Ps(M)?m.state.subscribe({next:B=>"values"in B&&M(V(void 0,$),B)}):V(M,$,!0),Ae=M=>m.state.subscribe({next:$=>{XS(M.name,$.name,M.exact)&&JS($,M.formState||h,yc,M.reRenderRoot)&&M.callback({values:{...i},...n,...$,defaultValues:a})}}).unsubscribe,rt=M=>(l.mount=!0,p={...p,...M.formState},Ae({...M,formState:{...d,...M.formState}})),St=(M,$={})=>{for(const B of M?ji(M):o.mount)o.mount.delete(B),o.array.delete(B),$.keepValue||(ct(r,B),ct(i,B)),!$.keepError&&ct(n.errors,B),!$.keepDirty&&ct(n.dirtyFields,B),!$.keepTouched&&ct(n.touchedFields,B),!$.keepIsValidating&&ct(n.validatingFields,B),!t.shouldUnregister&&!$.keepDefaultValue&&ct(a,B);m.state.next({values:mt(i)}),m.state.next({...n,...$.keepDirty?{isDirty:L()}:{}}),!$.keepIsValid&&N()},At=({disabled:M,name:$})=>{if(_s(M)&&l.mount||M||o.disabled.has($)){const Y=o.disabled.has($)!==!!M;M?o.disabled.add($):o.disabled.delete($),Y&&l.mount&&!l.action&&N()}},G=(M,$={})=>{let B=oe(r,M);const ae=_s($.disabled)||_s(t.disabled);return Ke(r,M,{...B||{},_f:{...B&&B._f?B._f:{ref:{name:M}},name:M,mount:!0,...$}}),o.mount.add(M),B?At({disabled:_s($.disabled)?$.disabled:t.disabled,name:M}):k(M,!0,$.value),{...ae?{disabled:$.disabled||t.disabled}:{},...t.progressive?{required:!!$.required,min:ni($.min),max:ni($.max),minLength:ni($.minLength),maxLength:ni($.maxLength),pattern:ni($.pattern)}:{},name:M,onChange:R,onBlur:R,ref:Y=>{if(Y){G(M,$),B=oe(r,M);const J=Qe(Y.value)&&Y.querySelectorAll&&Y.querySelectorAll("input,select,textarea")[0]||Y,de=qS(J),Ce=B._f.refs||[];if(de?Ce.find(Me=>Me===J):J===B._f.ref)return;Ke(r,M,{_f:{...B._f,...de?{refs:[...Ce.filter(Yc),J,...Array.isArray(oe(a,M))?[{}]:[]],ref:{type:J.type,name:M}}:{ref:J}}}),k(M,!1,void 0,J)}else B=oe(r,M,{}),B._f&&(B._f.mount=!1),(t.shouldUnregister||$.shouldUnregister)&&!(RS(o.array,M)&&l.action)&&o.unMount.add(M)}}},ze=()=>t.shouldFocusError&&bi(r,Q,o.mount),Rt=M=>{_s(M)&&(m.state.next({disabled:M}),bi(r,($,B)=>{const ae=oe(r,B);ae&&($.disabled=ae._f.disabled||M,Array.isArray(ae._f.refs)&&ae._f.refs.forEach(Y=>{Y.disabled=ae._f.disabled||M}))},0,!1))},$r=(M,$)=>async B=>{let ae;B&&(B.preventDefault&&B.preventDefault(),B.persist&&B.persist());let Y=mt(i);if(m.state.next({isSubmitting:!0}),t.resolver){const{errors:J,values:de}=await S();v(),n.errors=J,Y=mt(de)}else await A(r);if(o.disabled.size)for(const J of o.disabled)ct(Y,J);if(ct(n.errors,"root"),_t(n.errors)){m.state.next({errors:{}});try{await M(Y,B)}catch(J){ae=J}}else $&&await $({...n.errors},B),ze(),setTimeout(ze);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:_t(n.errors)&&!ae,submitCount:n.submitCount+1,errors:n.errors}),ae)throw ae},Sn=(M,$={})=>{oe(r,M)&&(Qe($.defaultValue)?w(M,mt(oe(a,M))):(w(M,$.defaultValue),Ke(a,M,mt($.defaultValue))),$.keepTouched||ct(n.touchedFields,M),$.keepDirty||(ct(n.dirtyFields,M),n.isDirty=$.defaultValue?L(M,mt(oe(a,M))):L()),$.keepError||(ct(n.errors,M),h.isValid&&N()),m.state.next({...n}))},Ur=(M,$={})=>{const B=M?mt(M):a,ae=mt(B),Y=_t(M),J=Y?a:ae;if($.keepDefaultValues||(a=B),!$.keepValues){if($.keepDirtyValues){const de=new Set([...o.mount,...Object.keys(Hr(a,i))]);for(const Ce of Array.from(de)){const Me=oe(n.dirtyFields,Ce),yt=oe(i,Ce),Zs=oe(J,Ce);Me&&!Qe(yt)?Ke(J,Ce,yt):!Me&&!Qe(Zs)&&w(Ce,Zs)}}else{if(Um&&Qe(M))for(const de of o.mount){const Ce=oe(r,de);if(Ce&&Ce._f){const Me=Array.isArray(Ce._f.refs)?Ce._f.refs[0]:Ce._f.ref;if(Ro(Me)){const yt=Me.closest("form");if(yt){yt.reset();break}}}}if($.keepFieldsRef)for(const de of o.mount)w(de,oe(J,de));else r={}}i=t.shouldUnregister?$.keepDefaultValues?mt(a):{}:mt(J),m.array.next({values:{...J}}),m.state.next({values:{...J}})}o={mount:$.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!h.isValid||!!$.keepIsValid||!!$.keepDirtyValues||!t.shouldUnregister&&!_t(J),l.watch=!!t.shouldUnregister,l.keepIsValid=!!$.keepIsValid,l.action=!1,$.keepErrors||(n.errors={}),m.state.next({submitCount:$.keepSubmitCount?n.submitCount:0,isDirty:Y?!1:$.keepDirty?n.isDirty:!!($.keepDefaultValues&&!Tn(M,a)),isSubmitted:$.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:Y?{}:$.keepDirtyValues?$.keepDefaultValues&&i?Hr(a,i):n.dirtyFields:$.keepDefaultValues&&M?Hr(a,M):$.keepDirty?n.dirtyFields:{},touchedFields:$.keepTouched?n.touchedFields:{},errors:$.keepErrors?n.errors:{},isSubmitSuccessful:$.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},gt=(M,$)=>Ur(Ps(M)?M(i):M,{...t.resetOptions,...$}),gc=(M,$={})=>{const B=oe(r,M),ae=B&&B._f;if(ae){const Y=ae.refs?ae.refs[0]:ae.ref;Y.focus&&setTimeout(()=>{Y.focus(),$.shouldSelect&&Ps(Y.select)&&Y.select()})}},yc=M=>{n={...n,...M}},ml={control:{register:G,unregister:St,getFieldState:ue,handleSubmit:$r,setError:H,_subscribe:Ae,_runSchema:S,_updateIsValidating:v,_focusError:ze,_getWatch:V,_getDirty:L,_setValid:N,_setFieldArray:g,_setDisabledField:At,_setErrors:j,_getFieldArray:q,_reset:Ur,_resetDefaultValues:()=>Ps(t.defaultValues)&&t.defaultValues().then(M=>{gt(M,t.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:_,_disableForm:Rt,_subjects:m,_proxyFormState:h,get _fields(){return r},get _formValues(){return i},get _state(){return l},set _state(M){l=M},get _defaultValues(){return a},get _names(){return o},set _names(M){o=M},get _formState(){return n},get _options(){return t},set _options(M){t={...t,...M}}},subscribe:rt,trigger:ee,register:G,handleSubmit:$r,watch:ke,setValue:w,getValues:fe,reset:gt,resetField:Sn,clearErrors:nt,unregister:St,setError:H,setFocus:gc,getFieldState:ue};return{...ml,formControl:ml}}function J0(e={}){const t=Ct.useRef(void 0),n=Ct.useRef(void 0),[r,a]=Ct.useState({isDirty:!1,isValidating:!1,isLoading:Ps(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:Ps(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!Ps(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...o}=nk(e);t.current={...o,formState:r}}const i=t.current.control;return i._options=e,$S(()=>{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]),Ct.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),Ct.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),Ct.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),Ct.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),Ct.useEffect(()=>{if(i._proxyFormState.isDirty){const l=i._getDirty();l!==r.isDirty&&i._subjects.state.next({isDirty:l})}},[i,r.isDirty]),Ct.useEffect(()=>{var l;e.values&&!Tn(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]),Ct.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=Ct.useMemo(()=>_S(r,i),[i,r]),t.current}function Xp(){var v,g;const{id:e}=sc(),t=Vt(),n=pe(),r=!!e,{register:a,handleSubmit:i,reset:l,watch:o,setValue:c,formState:{errors:u}}=J0(),d=o("type"),{data:h}=he({queryKey:["customer",e],queryFn:()=>Nt.getById(parseInt(e)),enabled:r});b.useEffect(()=>{if(h!=null&&h.data){const x={...h.data};x.birthDate&&(x.birthDate=x.birthDate.split("T")[0]),x.foundingDate&&(x.foundingDate=x.foundingDate.split("T")[0]),l(x)}},[h,l]);const p=W({mutationFn:Nt.create,onSuccess:()=>{n.invalidateQueries({queryKey:["customers"]}),t("/customers")}}),m=W({mutationFn:x=>Nt.update(parseInt(e),x),onSuccess:()=>{n.invalidateQueries({queryKey:["customers"]}),n.invalidateQueries({queryKey:["customer",e]}),t(`/customers/${e}`)}}),f=x=>{const j={type:x.type,salutation:x.salutation||void 0,firstName:x.firstName,lastName:x.lastName,companyName:x.companyName||void 0,email:x.email||void 0,phone:x.phone||void 0,mobile:x.mobile||void 0,taxNumber:x.taxNumber||void 0,commercialRegisterNumber:x.commercialRegisterNumber||void 0,notes:x.notes||void 0,birthPlace:x.birthPlace||void 0};x.birthDate&&typeof x.birthDate=="string"&&x.birthDate.trim()!==""?j.birthDate=new Date(x.birthDate).toISOString():j.birthDate=null,x.foundingDate&&typeof x.foundingDate=="string"&&x.foundingDate.trim()!==""?j.foundingDate=new Date(x.foundingDate).toISOString():j.foundingDate=null,r?m.mutate(j):p.mutate(j)},y=p.isPending||m.isPending,N=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"}),N&&s.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:N instanceof Error?N.message:"Ein Fehler ist aufgetreten"}),s.jsxs("form",{onSubmit:i(f),children:[s.jsx(X,{className:"mb-6",title:"Stammdaten",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Le,{label:"Kundentyp",...a("type"),options:[{value:"PRIVATE",label:"Privatkunde"},{value:"BUSINESS",label:"Geschäftskunde"}]}),s.jsx(Le,{label:"Anrede",...a("salutation"),options:[{value:"Herr",label:"Herr"},{value:"Frau",label:"Frau"},{value:"Divers",label:"Divers"}]}),s.jsx(K,{label:"Vorname",...a("firstName",{required:"Vorname erforderlich"}),error:(v=u.firstName)==null?void 0:v.message}),s.jsx(K,{label:"Nachname",...a("lastName",{required:"Nachname erforderlich"}),error:(g=u.lastName)==null?void 0:g.message}),d==="BUSINESS"&&s.jsxs(s.Fragment,{children:[s.jsx(K,{label:"Firmenname",...a("companyName"),className:"md:col-span-2"}),s.jsx(K,{label:"Gründungsdatum",type:"date",...a("foundingDate"),value:o("foundingDate")||"",onClear:()=>c("foundingDate","")})]}),d!=="BUSINESS"&&s.jsxs(s.Fragment,{children:[s.jsx(K,{label:"Geburtsdatum",type:"date",...a("birthDate"),value:o("birthDate")||"",onClear:()=>c("birthDate","")}),s.jsx(K,{label:"Geburtsort",...a("birthPlace")})]})]})}),s.jsx(X,{className:"mb-6",title:"Kontaktdaten",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(K,{label:"E-Mail",type:"email",...a("email")}),s.jsx(K,{label:"Telefon",...a("phone")}),s.jsx(K,{label:"Mobil",...a("mobile")})]})}),d==="BUSINESS"&&s.jsxs(X,{className:"mb-6",title:"Geschäftsdaten",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(K,{label:"Steuernummer",...a("taxNumber")}),s.jsx(K,{label:"Handelsregisternummer",...a("commercialRegisterNumber"),placeholder:"z.B. HRB 12345"})]}),r&&s.jsx("p",{className:"mt-4 text-sm text-gray-500",children:"Dokumente (Gewerbeanmeldung, Handelsregisterauszug) können nach dem Speichern in der Kundendetailansicht hochgeladen werden."})]}),s.jsx(X,{className:"mb-6",title:"Notizen",children:s.jsx("textarea",{...a("notes"),rows:4,className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"Interne Notizen..."})}),s.jsxs("div",{className:"flex justify-end gap-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:()=>t(-1),children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:y,children:y?"Speichern...":"Speichern"})]})]})]})}const eu={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabelinternet",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},tu={DRAFT:"Entwurf",PENDING:"Ausstehend",ACTIVE:"Aktiv",CANCELLED:"Gekündigt",EXPIRED:"Abgelaufen",DEACTIVATED:"Deaktiviert"},Yp={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"};function rk(){const[e,t]=rc(),n=Vt(),[r,a]=b.useState(e.get("search")||""),[i,l]=b.useState(e.get("type")||""),[o,c]=b.useState(e.get("status")||""),[u,d]=b.useState(parseInt(e.get("page")||"1",10)),{hasPermission:h,isCustomer:p,isCustomerPortal:m,user:f}=Be(),y=pe();b.useEffect(()=>{const j=new URLSearchParams;r&&j.set("search",r),i&&j.set("type",i),o&&j.set("status",o),u>1&&j.set("page",u.toString()),t(j,{replace:!0})},[r,i,o,u,t]);const N=W({mutationFn:$e.delete,onSuccess:()=>{y.invalidateQueries({queryKey:["contracts"]})}}),{data:v,isLoading:g}=he({queryKey:["contracts",r,i,o,u,p?f==null?void 0:f.customerId:null],queryFn:()=>$e.getAll({search:r||void 0,type:i||void 0,status:o||void 0,page:u,limit:20,customerId:p?f==null?void 0:f.customerId:void 0})}),x=b.useMemo(()=>{if(!m||!(v!=null&&v.data))return null;const j={};for(const k of v.data){const F=k.customerId;if(!j[F]){const E=k.customer?k.customer.companyName||`${k.customer.firstName} ${k.customer.lastName}`:`Kunde ${F}`;j[F]={customerName:E,isOwn:F===(f==null?void 0:f.customerId),contracts:[]}}j[F].contracts.push(k)}return Object.values(j).sort((k,F)=>k.isOwn&&!F.isOwn?-1:!k.isOwn&&F.isOwn?1:k.customerName.localeCompare(F.customerName))},[v==null?void 0:v.data,m,f==null?void 0:f.customerId]);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"}),h("contracts:create")&&!p&&s.jsx(Ne,{to:"/contracts/new",children:s.jsxs(T,{children:[s.jsx(Re,{className:"w-4 h-4 mr-2"}),"Neuer Vertrag"]})})]}),s.jsx(X,{className:"mb-6",children:s.jsxs("div",{className:"flex gap-4 flex-wrap",children:[s.jsx("div",{className:"flex-1 min-w-[200px]",children:s.jsx(K,{placeholder:"Suchen...",value:r,onChange:j=>a(j.target.value)})}),s.jsx(Le,{value:i,onChange:j=>l(j.target.value),options:Object.entries(eu).map(([j,k])=>({value:j,label:k})),className:"w-48"}),s.jsx(Le,{value:o,onChange:j=>c(j.target.value),options:Object.entries(tu).map(([j,k])=>({value:j,label:k})),className:"w-48"}),s.jsx(T,{variant:"secondary",children:s.jsx(cl,{className:"w-4 h-4"})})]})}),g?s.jsx(X,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."})}):v!=null&&v.data&&v.data.length>0?s.jsx(s.Fragment,{children:m&&x?s.jsx("div",{className:"space-y-6",children:x.map(j=>s.jsxs(X,{children:[s.jsx("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:j.isOwn?s.jsxs(s.Fragment,{children:[s.jsx(_m,{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(ge,{variant:"default",children:j.contracts.length})]}):s.jsxs(s.Fragment,{children:[s.jsx(ha,{className:"w-5 h-5 text-purple-600"}),s.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:["Verträge von ",j.customerName]}),s.jsx(ge,{variant:"default",children:j.contracts.length})]})}),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."}),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:j.contracts.map(k=>s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-mono text-sm",children:k.contractNumber}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ge,{children:eu[k.type]})}),s.jsxs("td",{className:"py-3 px-4",children:[k.providerName||"-",k.tariffName&&s.jsxs("span",{className:"text-gray-500",children:[" / ",k.tariffName]})]}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ge,{variant:Yp[k.status],children:tu[k.status]})}),s.jsx("td",{className:"py-3 px-4",children:k.startDate?new Date(k.startDate).toLocaleDateString("de-DE"):"-"}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${k.id}`,{state:{from:"contracts"}}),children:s.jsx(De,{className:"w-4 h-4"})})})]},k.id))})]})})]},j.isOwn?"own":j.customerName))}):s.jsxs(X,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b",children:[s.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Vertragsnr."}),!p&&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:v.data.map(j=>s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsx("td",{className:"py-3 px-4 font-mono text-sm",children:j.contractNumber}),!p&&s.jsx("td",{className:"py-3 px-4",children:j.customer&&s.jsx(Ne,{to:`/customers/${j.customer.id}`,className:"text-blue-600 hover:underline",children:j.customer.companyName||`${j.customer.firstName} ${j.customer.lastName}`})}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ge,{children:eu[j.type]})}),s.jsxs("td",{className:"py-3 px-4",children:[j.providerName||"-",j.tariffName&&s.jsxs("span",{className:"text-gray-500",children:[" / ",j.tariffName]})]}),s.jsx("td",{className:"py-3 px-4",children:s.jsx(ge,{variant:Yp[j.status],children:tu[j.status]})}),s.jsx("td",{className:"py-3 px-4",children:j.startDate?new Date(j.startDate).toLocaleDateString("de-DE"):"-"}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${j.id}`,{state:{from:"contracts"}}),children:s.jsx(De,{className:"w-4 h-4"})}),h("contracts:update")&&!p&&s.jsx(Ne,{to:`/contracts/${j.id}/edit`,children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Je,{className:"w-4 h-4"})})}),h("contracts:delete")&&!p&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertrag wirklich löschen?")&&N.mutate(j.id)},children:s.jsx(ve,{className:"w-4 h-4 text-red-500"})})]})})]},j.id))})]})}),v.pagination&&v.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 ",v.pagination.page," von ",v.pagination.totalPages," (",v.pagination.total," Einträge)"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>d(j=>Math.max(1,j-1)),disabled:u===1,children:"Zurück"}),s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>d(j=>j+1),disabled:u>=v.pagination.totalPages,children:"Weiter"})]})]})]})}):s.jsx(X,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Verträge gefunden."})})]})}const ak={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabelinternet",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},ik={DRAFT:"Entwurf",PENDING:"Ausstehend",ACTIVE:"Aktiv",CANCELLED:"Gekündigt",EXPIRED:"Abgelaufen",DEACTIVATED:"Deaktiviert"},lk={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"};function ok(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 ck({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 $e.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(ge,{variant:"success",children:"Hauptkarte"}),e.isMultisim&&s.jsx(ge,{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(T,{variant:"ghost",size:"sm",onClick:o,disabled:i,children:i?"Laden...":t?s.jsxs(s.Fragment,{children:[s.jsx(Et,{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 uk({meterId:e,meterType:t,readings:n,contractId:r,canEdit:a}){const[i,l]=b.useState(!1),[o,c]=b.useState(!1),[u,d]=b.useState(null),h=pe(),p=W({mutationFn:y=>Hs.deleteReading(e,y),onSuccess:()=>{h.invalidateQueries({queryKey:["contract",r.toString()]})}}),m=[...n].sort((y,N)=>new Date(N.readingDate).getTime()-new Date(y.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(R0,{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(ge,{variant:"default",children:n.length})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[a&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>c(!0),title:"Zählerstand erfassen",children:s.jsx(Re,{className:"w-4 h-4"})}),n.length>0&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>l(!i),children:i?s.jsx(F0,{className:"w-4 h-4"}):s.jsx(mc,{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(y=>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(y.readingDate).toLocaleDateString("de-DE"),s.jsx(ce,{value:new Date(y.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:[y.value.toLocaleString("de-DE")," ",y.unit,s.jsx(ce,{value:y.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:()=>d(y),className:"text-gray-400 hover:text-blue-600",title:"Bearbeiten",children:s.jsx(Je,{className:"w-3 h-3"})}),s.jsx("button",{onClick:()=>{confirm("Zählerstand wirklich löschen?")&&p.mutate(y.id)},className:"text-gray-400 hover:text-red-600",title:"Löschen",children:s.jsx(ve,{className:"w-3 h-3"})})]})]})]},y.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||u)&&s.jsx(dk,{isOpen:!0,onClose:()=>{c(!1),d(null)},meterId:e,contractId:r,reading:u,defaultUnit:f})]})}function dk({isOpen:e,onClose:t,meterId:n,contractId:r,reading:a,defaultUnit:i}){var f;const l=pe(),o=!!a,[c,u]=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())||"",unit:(a==null?void 0:a.unit)||i,notes:(a==null?void 0:a.notes)||""}),d=W({mutationFn:y=>Hs.addReading(n,y),onSuccess:()=>{l.invalidateQueries({queryKey:["contract",r.toString()]}),t()}}),h=W({mutationFn:y=>Hs.updateReading(n,a.id,y),onSuccess:()=>{l.invalidateQueries({queryKey:["contract",r.toString()]}),t()}}),p=y=>{y.preventDefault();const N={readingDate:new Date(c.readingDate),value:parseFloat(c.value),unit:c.unit,notes:c.notes||void 0};o?h.mutate(N):d.mutate(N)},m=d.isPending||h.isPending;return s.jsx(ot,{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(K,{label:"Ablesedatum",type:"date",value:c.readingDate,onChange:y=>u({...c,readingDate:y.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(K,{label:"Zählerstand",type:"number",step:"0.01",value:c.value,onChange:y=>u({...c,value:y.target.value}),required:!0})}),s.jsx(Le,{label:"Einheit",value:c.unit,onChange:y=>u({...c,unit:y.target.value}),options:[{value:"kWh",label:"kWh"},{value:"m³",label:"m³"}]})]}),s.jsx(K,{label:"Notizen (optional)",value:c.notes,onChange:y=>u({...c,notes:y.target.value})}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:m||!c.value,children:m?"Speichern...":o?"Speichern":"Erfassen"})]})]})})}function ex({task:e,contractId:t,canEdit:n,isCustomerPortal:r,isCompleted:a,onEdit:i}){const[l,o]=b.useState(""),[c,u]=b.useState(!1),[d,h]=b.useState(null),[p,m]=b.useState(""),f=pe(),y=W({mutationFn:w=>st.complete(w),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),N=W({mutationFn:w=>st.reopen(w),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),v=W({mutationFn:w=>st.delete(w),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),g=W({mutationFn:w=>st.createSubtask(e.id,w),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]}),o(""),u(!1)},onError:w=>{console.error("Fehler beim Erstellen der Unteraufgabe:",w),alert("Fehler beim Erstellen der Unteraufgabe. Bitte versuchen Sie es erneut.")}}),x=W({mutationFn:w=>st.createReply(e.id,w),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]}),o(""),u(!1)},onError:w=>{console.error("Fehler beim Erstellen der Antwort:",w),alert("Fehler beim Erstellen der Antwort. Bitte versuchen Sie es erneut.")}}),j=W({mutationFn:({id:w,title:R})=>st.updateSubtask(w,R),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]}),h(null),m("")}}),k=W({mutationFn:w=>st.completeSubtask(w),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),F=W({mutationFn:w=>st.reopenSubtask(w),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),E=W({mutationFn:w=>st.deleteSubtask(w),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),S=w=>{w.preventDefault(),l.trim()&&(r?x.mutate(l.trim()):g.mutate(l.trim()))},P=w=>{w.preventDefault(),p.trim()&&d&&j.mutate({id:d,title:p.trim()})},A=(w,R)=>{h(w),m(R)},_=()=>{h(null),m("")},L=e.subtasks||[],V=L.filter(w=>w.status==="OPEN"),q=L.filter(w=>w.status==="COMPLETED"),O=r?{singular:"Antwort",placeholder:"Antwort...",deleteConfirm:"Antwort löschen?"}:{singular:"Unteraufgabe",placeholder:"Unteraufgabe...",deleteConfirm:"Unteraufgabe löschen?"},C=(w,R)=>d===w.id?s.jsx("div",{className:"py-1",children:s.jsxs("form",{onSubmit:P,className:"flex items-center gap-2",children:[s.jsx(to,{className:"w-4 h-4 text-gray-300 flex-shrink-0"}),s.jsx("input",{type:"text",value:p,onChange:ee=>m(ee.target.value),className:"flex-1 text-sm px-2 py-1 border rounded focus:outline-none focus:ring-1 focus:ring-blue-500",autoFocus:!0}),s.jsx(T,{type:"submit",size:"sm",disabled:!p.trim()||j.isPending,children:"✓"}),s.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:_,children:"×"})]})},w.id):s.jsx("div",{className:`py-1 group/subtask ${R?"opacity-60":""}`,children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("button",{onClick:()=>R?F.mutate(w.id):k.mutate(w.id),disabled:k.isPending||F.isPending||r,className:`flex-shrink-0 mt-0.5 ${r?"cursor-default":R?"hover:text-yellow-600":"hover:text-green-600"}`,children:R?s.jsx(gs,{className:"w-4 h-4 text-green-500"}):s.jsx(to,{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 ${R?"line-through text-gray-500":""}`,children:w.title}),n&&!r&&!R&&s.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover/subtask:opacity-100",children:[s.jsx("button",{onClick:()=>A(w.id,w.title),className:"text-gray-400 hover:text-blue-600 p-0.5",title:"Bearbeiten",children:s.jsx(Je,{className:"w-3 h-3"})}),s.jsx("button",{onClick:()=>{confirm(O.deleteConfirm)&&E.mutate(w.id)},className:"text-gray-400 hover:text-red-600 p-0.5",title:"Löschen",children:s.jsx(ve,{className:"w-3 h-3"})})]}),n&&!r&&R&&s.jsx("button",{onClick:()=>{confirm(O.deleteConfirm)&&E.mutate(w.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(ve,{className:"w-3 h-3"})})]}),s.jsxs("p",{className:"text-xs text-gray-400",children:[w.createdBy&&`${w.createdBy} • `,R?`Erledigt am ${w.completedAt?new Date(w.completedAt).toLocaleDateString("de-DE"):new Date(w.updatedAt).toLocaleDateString("de-DE")}`:new Date(w.createdAt).toLocaleDateString("de-DE")]})]})]})},w.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?N.mutate(e.id):y.mutate(e.id),disabled:y.isPending||N.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(gs,{className:"w-5 h-5 text-green-500"}):s.jsx(to,{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(ge,{variant:"default",className:"text-xs",children:"Portal"}),L.length>0&&s.jsxs("span",{className:"text-xs text-gray-400",children:["(",q.length,"/",L.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")]}),L.length>0&&s.jsxs("div",{className:"mt-3 ml-2 space-y-0 border-l-2 border-gray-200 pl-3",children:[V.map(w=>C(w,!1)),q.map(w=>C(w,!0))]}),!a&&(n&&!r||r)&&s.jsx("div",{className:"mt-2 ml-2",children:c?s.jsxs("form",{onSubmit:S,className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",value:l,onChange:w=>o(w.target.value),placeholder:O.placeholder,className:"flex-1 text-sm px-2 py-1 border rounded focus:outline-none focus:ring-1 focus:ring-blue-500",autoFocus:!0}),s.jsx(T,{type:"submit",size:"sm",disabled:!l.trim()||g.isPending||x.isPending,children:s.jsx(Re,{className:"w-3 h-3"})}),s.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:()=>{u(!1),o("")},children:"×"})]}):s.jsxs("button",{onClick:()=>u(!0),className:"text-xs text-gray-400 hover:text-blue-600 flex items-center gap-1",children:[s.jsx(Re,{className:"w-3 h-3"}),O.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(Je,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm("Aufgabe wirklich löschen?")&&v.mutate(e.id)},className:"text-gray-400 hover:text-red-600 p-1",title:"Löschen",children:s.jsx(ve,{className:"w-4 h-4"})})]})]})})}function mk({contractId:e,canEdit:t,isCustomerPortal:n}){var x;const[r,a]=b.useState(!1),[i,l]=b.useState(null),{data:o,isLoading:c}=he({queryKey:["contract-tasks",e],queryFn:()=>st.getByContract(e),staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:u,isLoading:d}=he({queryKey:["app-settings-public"],queryFn:()=>Or.getPublic(),enabled:n,staleTime:0}),h=!d&&((x=u==null?void 0:u.data)==null?void 0:x.customerSupportTicketsEnabled)==="true",p=(o==null?void 0:o.data)||[],m=p.filter(j=>j.status==="OPEN"),f=p.filter(j=>j.status==="COMPLETED"),y=n?{title:"Support-Anfragen",button:"Anfrage erstellen",empty:"Keine Support-Anfragen vorhanden."}:{title:"Aufgaben",button:"Aufgabe",empty:"Keine Aufgaben vorhanden."},N=n?Hi:Qi;if(c||n&&d)return s.jsx(X,{className:"mb-6",title:y.title,children:s.jsx("div",{className:"text-center py-4 text-gray-500",children:"Laden..."})});const g=t&&!n||n&&h;return s.jsxs(X,{className:"mb-6",title:y.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(N,{className:"w-5 h-5 text-gray-500"}),s.jsxs("span",{className:"text-sm text-gray-600",children:[m.length," offen, ",f.length," erledigt"]})]}),g&&s.jsxs(T,{size:"sm",onClick:()=>a(!0),children:[s.jsx(Re,{className:"w-4 h-4 mr-1"}),y.button]})]}),p.length===0?s.jsx("p",{className:"text-center py-4 text-gray-500",children:y.empty}):s.jsxs("div",{className:"space-y-2",children:[m.map(j=>s.jsx(ex,{task:j,contractId:e,canEdit:t,isCustomerPortal:n,isCompleted:!1,onEdit:()=>l(j)},j.id)),f.length>0&&m.length>0&&s.jsx("div",{className:"border-t my-3"}),f.map(j=>s.jsx(ex,{task:j,contractId:e,canEdit:t,isCustomerPortal:n,isCompleted:!0,onEdit:()=>{}},j.id))]}),(r||i)&&s.jsx(hk,{isOpen:!0,onClose:()=>{a(!1),l(null)},contractId:e,task:i,isCustomerPortal:n})]})}function hk({isOpen:e,onClose:t,contractId:n,task:r,isCustomerPortal:a=!1}){const i=pe(),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 u=W({mutationFn:y=>st.create(n,y),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",n]}),t()}}),d=W({mutationFn:y=>st.createSupportTicket(n,y),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",n]}),t()}}),h=W({mutationFn:y=>st.update(r.id,y),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",n]}),t()}}),p=y=>{y.preventDefault(),l?h.mutate({title:o.title,description:o.description||void 0,visibleInPortal:o.visibleInPortal}):a?d.mutate({title:o.title,description:o.description||void 0}):u.mutate({title:o.title,description:o.description||void 0,visibleInPortal:o.visibleInPortal})},m=u.isPending||d.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(ot,{isOpen:e,onClose:t,title:f.modalTitle,children:s.jsxs("form",{onSubmit:p,className:"space-y-4",children:[s.jsx(K,{label:f.titleLabel,value:o.title,onChange:y=>c({...o,title:y.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:y=>c({...o,description:y.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:y=>c({...o,visibleInPortal:y.target.checked}),className:"w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),s.jsx("span",{className:"text-sm text-gray-700",children:"Im Kundenportal sichtbar"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:m||!o.title.trim(),children:m?"Speichern...":f.submitBtn})]})]})})}function fk(){var R,Q,ee,fe,ue,nt;const{id:e}=sc(),t=Vt(),r=wn().state,a=pe(),{hasPermission:i,isCustomer:l,isCustomerPortal:o}=Be(),c=parseInt(e),[u,d]=b.useState(!1),[h,p]=b.useState(null),[m,f]=b.useState(!1),[y,N]=b.useState(!1),[v,g]=b.useState(null),[x,j]=b.useState({}),[k,F]=b.useState({}),{data:E,isLoading:S}=he({queryKey:["contract",e],queryFn:()=>$e.getById(c)}),P=W({mutationFn:()=>$e.delete(c),onSuccess:()=>{t("/contracts")}}),A=W({mutationFn:()=>$e.createFollowUp(c),onSuccess:H=>{H.data?t(`/contracts/${H.data.id}/edit`):alert("Folgevertrag wurde erstellt, aber keine ID zurückgegeben")},onError:H=>{console.error("Folgevertrag Fehler:",H),alert(`Fehler beim Erstellen des Folgevertrags: ${H instanceof Error?H.message:"Unbekannter Fehler"}`)}}),_=W({mutationFn:H=>{const Ae={cancellationConfirmationDate:H?new Date(H).toISOString():null};return $e.update(c,Ae)},onSuccess:()=>{a.invalidateQueries({queryKey:["contract",e]}),a.invalidateQueries({queryKey:["contract-cockpit"]})},onError:H=>{console.error("Fehler beim Speichern des Datums:",H),alert("Fehler beim Speichern des Datums")}}),L=W({mutationFn:H=>{const Ae={cancellationConfirmationOptionsDate:H?new Date(H).toISOString():null};return $e.update(c,Ae)},onSuccess:()=>{a.invalidateQueries({queryKey:["contract",e]}),a.invalidateQueries({queryKey:["contract-cockpit"]})},onError:H=>{console.error("Fehler beim Speichern des Datums:",H),alert("Fehler beim Speichern des Datums")}}),V=async()=>{var H;if(u)d(!1),p(null);else try{const ke=await $e.getPassword(c);(H=ke.data)!=null&&H.password&&(p(ke.data.password),d(!0))}catch{alert("Passwort konnte nicht entschlüsselt werden")}},q=async()=>{var H;if(y)N(!1),g(null);else try{const ke=await $e.getInternetCredentials(c);(H=ke.data)!=null&&H.password&&(g(ke.data.password),N(!0))}catch{alert("Internet-Passwort konnte nicht entschlüsselt werden")}},O=async H=>{var ke;if(x[H])j(Ae=>({...Ae,[H]:!1})),F(Ae=>({...Ae,[H]:null}));else try{const rt=(ke=(await $e.getSipCredentials(H)).data)==null?void 0:ke.password;rt&&(F(St=>({...St,[H]:rt})),j(St=>({...St,[H]:!0})))}catch{alert("SIP-Passwort konnte nicht entschlüsselt werden")}},C=async()=>{var Ae,rt,St;const H=E==null?void 0:E.data,ke=((Ae=H==null?void 0:H.stressfreiEmail)==null?void 0:Ae.email)||(H==null?void 0:H.portalUsername);if(!((rt=H==null?void 0:H.provider)!=null&&rt.portalUrl)||!ke){alert("Portal-URL oder Benutzername fehlt");return}f(!0);try{const At=await $e.getPassword(c);if(!((St=At.data)!=null&&St.password)){alert("Passwort konnte nicht entschlüsselt werden");return}const G=H.provider,ze=G.portalUrl,Rt=G.usernameFieldName||"username",$r=G.passwordFieldName||"password",Sn=new URL(ze);Sn.searchParams.set(Rt,ke),Sn.searchParams.set($r,At.data.password),window.open(Sn.toString(),"_blank")}catch{alert("Fehler beim Auto-Login")}finally{f(!1)}};if(S)return s.jsx("div",{className:"text-center py-8",children:"Laden..."});if(!(E!=null&&E.data))return s.jsx("div",{className:"text-center py-8 text-red-600",children:"Vertrag nicht gefunden"});const w=E.data;return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{if((r==null?void 0:r.from)==="customer"&&(r!=null&&r.customerId))t(`/customers/${r.customerId}?tab=contracts`);else if((r==null?void 0:r.from)==="cockpit"){const H=r.filter?`?filter=${r.filter}`:"";t(`/contracts/cockpit${H}`)}else(r==null?void 0:r.from)==="contracts"?t("/contracts"):w.customer?t(`/customers/${w.customer.id}?tab=contracts`):t("/contracts")},children:s.jsx(Gs,{className:"w-4 h-4"})}),s.jsx("h1",{className:"text-2xl font-bold",children:w.contractNumber}),s.jsx(ge,{children:ak[w.type]}),s.jsx(ge,{variant:lk[w.status],children:ik[w.status]})]}),w.customer&&s.jsxs("p",{className:"text-gray-500 ml-10",children:["Kunde:"," ",s.jsx(Ne,{to:`/customers/${w.customer.id}`,className:"text-blue-600 hover:underline",children:w.customer.companyName||`${w.customer.firstName} ${w.customer.lastName}`})]})]}),!l&&s.jsxs("div",{className:"flex gap-2",children:[i("contracts:create")&&!w.followUpContract&&s.jsxs(T,{variant:"secondary",onClick:()=>A.mutate(),disabled:A.isPending,children:[s.jsx(I0,{className:"w-4 h-4 mr-2"}),A.isPending?"Erstelle...":"Folgevertrag anlegen"]}),w.followUpContract&&s.jsx(Ne,{to:`/contracts/${w.followUpContract.id}`,children:s.jsxs(T,{variant:"secondary",children:[s.jsx(A0,{className:"w-4 h-4 mr-2"}),"Folgevertrag anzeigen"]})}),i("contracts:update")&&s.jsx(Ne,{to:`/contracts/${e}/edit`,children:s.jsxs(T,{variant:"secondary",children:[s.jsx(Je,{className:"w-4 h-4 mr-2"}),"Bearbeiten"]})}),i("contracts:delete")&&s.jsxs(T,{variant:"danger",onClick:()=>{confirm("Vertrag wirklich löschen?")&&P.mutate()},children:[s.jsx(ve,{className:"w-4 h-4 mr-2"}),"Löschen"]})]})]}),w.previousContract&&s.jsx(X,{className:"mb-6 border-l-4 border-l-blue-500",title:"Vorgängervertrag",children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsnummer"}),s.jsx("dd",{children:s.jsx(Ne,{to:`/contracts/${w.previousContract.id}`,className:"text-blue-600 hover:underline",children:w.previousContract.contractNumber})})]}),w.previousContract.providerName&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),s.jsx("dd",{children:w.previousContract.providerName})]}),w.previousContract.customerNumberAtProvider&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kundennummer"}),s.jsx("dd",{className:"font-mono",children:w.previousContract.customerNumberAtProvider})]}),w.previousContract.portalUsername&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Zugangsdaten"}),s.jsx("dd",{children:w.previousContract.portalUsername})]})]})}),w.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(w.cancellationConfirmationDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}),".",w.cancellationConfirmationOptionsDate&&s.jsxs(s.Fragment,{children:[" Optionen-Bestätigung: ",s.jsx("strong",{children:new Date(w.cancellationConfirmationOptionsDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}),"."]})]})]})]}),w.type==="MOBILE"&&((R=w.mobileDetails)==null?void 0:R.requiresMultisim)&&s.jsxs("div",{className:"mb-6 p-4 bg-amber-50 border border-amber-300 rounded-lg flex items-start gap-3",children:[s.jsx("span",{className:"text-amber-600 text-xl font-bold",children:"!"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold text-amber-800",children:"Multisim erforderlich"}),s.jsx("p",{className:"text-sm text-amber-700 mt-1",children:"Dieser Kunde benötigt eine Multisim-Karte. Multisim ist bei Klarmobil, Congstar und Otelo nicht buchbar. Bitte einen Anbieter wie Freenet oder vergleichbar wählen."})]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6",children:[s.jsx(X,{title:"Anbieter & Tarif",children:s.jsxs("dl",{className:"space-y-3",children:[(w.provider||w.providerName)&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),s.jsx("dd",{className:"font-medium",children:((Q=w.provider)==null?void 0:Q.name)||w.providerName})]}),(w.tariff||w.tariffName)&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Tarif"}),s.jsx("dd",{children:((ee=w.tariff)==null?void 0:ee.name)||w.tariffName})]}),w.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:[w.customerNumberAtProvider,s.jsx(ce,{value:w.customerNumberAtProvider})]})]}),w.salesPlatform&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertriebsplattform"}),s.jsx("dd",{children:w.salesPlatform.name})]}),w.commission!==null&&w.commission!==void 0&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Provision"}),s.jsx("dd",{children:w.commission.toLocaleString("de-DE",{style:"currency",currency:"EUR"})})]}),w.priceFirst12Months&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Preis erste 12 Monate"}),s.jsx("dd",{children:w.priceFirst12Months})]}),w.priceFrom13Months&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Preis ab 13. Monat"}),s.jsx("dd",{children:w.priceFrom13Months})]}),w.priceAfter24Months&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Preis nach 24 Monaten"}),s.jsx("dd",{children:w.priceAfter24Months})]})]})}),s.jsxs(X,{title:"Laufzeit und Kündigung",className:w.cancellationConfirmationDate?"border-2 border-red-400":"",children:[w.contractDuration&&ok(w.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:[w.startDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsbeginn"}),s.jsx("dd",{children:new Date(w.startDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),w.endDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsende"}),s.jsx("dd",{children:new Date(w.endDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),w.contractDuration&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragslaufzeit"}),s.jsx("dd",{children:w.contractDuration.description})]}),w.cancellationPeriod&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsfrist"}),s.jsx("dd",{children:w.cancellationPeriod.description})]}),w.cancellationConfirmationDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsbestätigungsdatum"}),s.jsx("dd",{children:new Date(w.cancellationConfirmationDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),w.cancellationConfirmationOptionsDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsbestätigungsoptionendatum"}),s.jsx("dd",{children:new Date(w.cancellationConfirmationOptionsDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),w.wasSpecialCancellation&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Sonderkündigung"}),s.jsx("dd",{children:s.jsx(ge,{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"}),w.cancellationLetterPath?s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${w.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${w.cancellationLetterPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ms,{className:"w-4 h-4"}),"Download"]}),s.jsx(bt,{onUpload:async H=>{await et.uploadCancellationLetter(c,H),a.invalidateQueries({queryKey:["contract",e]})},existingFile:w.cancellationLetterPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await et.deleteCancellationLetter(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(ve,{className:"w-4 h-4"}),"Löschen"]})]}):s.jsx(bt,{onUpload:async H=>{await et.uploadCancellationLetter(c,H),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"}),w.cancellationConfirmationPath?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${w.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${w.cancellationConfirmationPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ms,{className:"w-4 h-4"}),"Download"]}),s.jsx(bt,{onUpload:async H=>{await et.uploadCancellationConfirmation(c,H),a.invalidateQueries({queryKey:["contract",e]})},existingFile:w.cancellationConfirmationPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await et.deleteCancellationConfirmation(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(ve,{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:w.cancellationConfirmationDate?w.cancellationConfirmationDate.split("T")[0]:"",onChange:H=>{const ke=H.target.value||null;_.mutate(ke)},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"}),w.cancellationConfirmationDate&&s.jsx("button",{onClick:()=>_.mutate(null),className:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 rounded",title:"Datum löschen",children:s.jsx(ve,{className:"w-4 h-4"})})]})]})]}):s.jsx(bt,{onUpload:async H=>{await et.uploadCancellationConfirmation(c,H),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"}),w.cancellationLetterOptionsPath?s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${w.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${w.cancellationLetterOptionsPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ms,{className:"w-4 h-4"}),"Download"]}),s.jsx(bt,{onUpload:async H=>{await et.uploadCancellationLetterOptions(c,H),a.invalidateQueries({queryKey:["contract",e]})},existingFile:w.cancellationLetterOptionsPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await et.deleteCancellationLetterOptions(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(ve,{className:"w-4 h-4"}),"Löschen"]})]}):s.jsx(bt,{onUpload:async H=>{await et.uploadCancellationLetterOptions(c,H),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"}),w.cancellationConfirmationOptionsPath?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("a",{href:`/api${w.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${w.cancellationConfirmationOptionsPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(Ms,{className:"w-4 h-4"}),"Download"]}),s.jsx(bt,{onUpload:async H=>{await et.uploadCancellationConfirmationOptions(c,H),a.invalidateQueries({queryKey:["contract",e]})},existingFile:w.cancellationConfirmationOptionsPath,accept:".pdf",label:"Ersetzen"}),s.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await et.deleteCancellationConfirmationOptions(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[s.jsx(ve,{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:w.cancellationConfirmationOptionsDate?w.cancellationConfirmationOptionsDate.split("T")[0]:"",onChange:H=>{const ke=H.target.value||null;L.mutate(ke)},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"}),w.cancellationConfirmationOptionsDate&&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(ve,{className:"w-4 h-4"})})]})]})]}):s.jsx(bt,{onUpload:async H=>{await et.uploadCancellationConfirmationOptions(c,H),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]})]})]})]})]}),(w.portalUsername||w.stressfreiEmail||w.portalPasswordEncrypted)&&s.jsxs(X,{className:"mb-6",title:"Zugangsdaten",children:[s.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[(w.portalUsername||w.stressfreiEmail)&&s.jsxs("div",{children:[s.jsxs("dt",{className:"text-sm text-gray-500",children:["Benutzername",w.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:[((fe=w.stressfreiEmail)==null?void 0:fe.email)||w.portalUsername,s.jsx(ce,{value:((ue=w.stressfreiEmail)==null?void 0:ue.email)||w.portalUsername||""})]})]}),w.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:u&&h?h:"••••••••"}),u&&h&&s.jsx(ce,{value:h}),s.jsx(T,{variant:"ghost",size:"sm",onClick:V,children:u?s.jsx(Et,{className:"w-4 h-4"}):s.jsx(De,{className:"w-4 h-4"})})]})]})]}),((nt=w.provider)==null?void 0:nt.portalUrl)&&(w.portalUsername||w.stressfreiEmail)&&w.portalPasswordEncrypted&&s.jsxs("div",{className:"mt-4 pt-4 border-t",children:[s.jsxs(T,{onClick:C,disabled:m,className:"w-full sm:w-auto",children:[s.jsx(Lm,{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-3 gap-6 mb-6",children:[w.address&&s.jsx(X,{title:"Adresse",children:s.jsxs(K0,{values:[`${w.address.street} ${w.address.houseNumber}`,`${w.address.postalCode} ${w.address.city}`,w.address.country],children:[s.jsxs("p",{children:[w.address.street," ",w.address.houseNumber]}),s.jsxs("p",{children:[w.address.postalCode," ",w.address.city]}),s.jsx("p",{className:"text-gray-500",children:w.address.country})]})}),w.bankCard&&s.jsxs(X,{title:"Bankkarte",children:[s.jsx("p",{className:"font-medium",children:w.bankCard.accountHolder}),s.jsxs("p",{className:"font-mono flex items-center gap-1",children:[w.bankCard.iban,s.jsx(ce,{value:w.bankCard.iban})]}),w.bankCard.bankName&&s.jsx("p",{className:"text-gray-500",children:w.bankCard.bankName})]}),w.identityDocument&&s.jsxs(X,{title:"Ausweis",children:[s.jsxs("p",{className:"font-mono flex items-center gap-1",children:[w.identityDocument.documentNumber,s.jsx(ce,{value:w.identityDocument.documentNumber})]}),s.jsx("p",{className:"text-gray-500",children:w.identityDocument.type})]})]}),w.energyDetails&&s.jsxs(X,{className:"mb-6",title:w.type==="ELECTRICITY"?"Strom-Details":"Gas-Details",children:[s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[w.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:[w.energyDetails.meter.meterNumber,s.jsx(ce,{value:w.energyDetails.meter.meterNumber})]})]}),w.energyDetails.annualConsumption&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Jahresverbrauch"}),s.jsxs("dd",{children:[w.energyDetails.annualConsumption.toLocaleString("de-DE")," ",w.type==="ELECTRICITY"?"kWh":"m³"]})]}),w.energyDetails.basePrice&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Grundpreis"}),s.jsxs("dd",{children:[w.energyDetails.basePrice.toLocaleString("de-DE")," €/Monat"]})]}),w.energyDetails.unitPrice&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Arbeitspreis"}),s.jsxs("dd",{children:[w.energyDetails.unitPrice.toLocaleString("de-DE")," ct/",w.type==="ELECTRICITY"?"kWh":"m³"]})]}),w.energyDetails.bonus&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Bonus"}),s.jsxs("dd",{children:[w.energyDetails.bonus.toLocaleString("de-DE")," €"]})]}),w.energyDetails.previousProviderName&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vorversorger"}),s.jsx("dd",{children:w.energyDetails.previousProviderName})]}),w.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:[w.energyDetails.previousCustomerNumber,s.jsx(ce,{value:w.energyDetails.previousCustomerNumber})]})]})]}),w.energyDetails.meter&&s.jsx(uk,{meterId:w.energyDetails.meter.id,meterType:w.energyDetails.meter.type,readings:w.energyDetails.meter.readings||[],contractId:c,canEdit:i("contracts:update")&&!l})]}),w.internetDetails&&s.jsxs(X,{className:"mb-6",title:w.type==="DSL"?"DSL-Details":w.type==="CABLE"?"Kabelinternet-Details":"Glasfaser-Details",children:[s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[w.internetDetails.downloadSpeed&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Download"}),s.jsxs("dd",{children:[w.internetDetails.downloadSpeed," Mbit/s"]})]}),w.internetDetails.uploadSpeed&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Upload"}),s.jsxs("dd",{children:[w.internetDetails.uploadSpeed," Mbit/s"]})]}),w.internetDetails.routerModel&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Router"}),s.jsx("dd",{children:w.internetDetails.routerModel})]}),w.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:[w.internetDetails.routerSerialNumber,s.jsx(ce,{value:w.internetDetails.routerSerialNumber})]})]}),w.internetDetails.installationDate&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Installation"}),s.jsx("dd",{children:new Date(w.internetDetails.installationDate).toLocaleDateString("de-DE")})]}),w.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:[w.internetDetails.homeId,s.jsx(ce,{value:w.internetDetails.homeId})]})]}),w.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:[w.internetDetails.activationCode,s.jsx(ce,{value:w.internetDetails.activationCode})]})]})]}),(w.internetDetails.internetUsername||w.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:[w.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:[w.internetDetails.internetUsername,s.jsx(ce,{value:w.internetDetails.internetUsername})]})]}),w.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:y&&v?v:"••••••••"}),y&&v&&s.jsx(ce,{value:v}),s.jsx(T,{variant:"ghost",size:"sm",onClick:q,children:y?s.jsx(Et,{className:"w-4 h-4"}):s.jsx(De,{className:"w-4 h-4"})})]})]})]})]}),w.internetDetails.phoneNumbers&&w.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:w.internetDetails.phoneNumbers.map(H=>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:[H.phoneNumber,s.jsx(ce,{value:H.phoneNumber})]}),H.isMain&&s.jsx(ge,{variant:"success",children:"Hauptnummer"})]}),(H.sipUsername||H.sipPasswordEncrypted||H.sipServer)&&s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-sm",children:[H.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:[H.sipUsername,s.jsx(ce,{value:H.sipUsername})]})]}),H.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:x[H.id]&&k[H.id]?k[H.id]:"••••••••"}),x[H.id]&&k[H.id]&&s.jsx(ce,{value:k[H.id]}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>O(H.id),children:x[H.id]?s.jsx(Et,{className:"w-3 h-3"}):s.jsx(De,{className:"w-3 h-3"})})]})]}),H.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:[H.sipServer,s.jsx(ce,{value:H.sipServer})]})]})]})]},H.id))})]})]}),w.mobileDetails&&s.jsxs(X,{className:"mb-6",title:"Mobilfunk-Details",children:[s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[w.mobileDetails.dataVolume&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Datenvolumen"}),s.jsxs("dd",{children:[w.mobileDetails.dataVolume," GB"]})]}),w.mobileDetails.includedMinutes&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Inklusiv-Minuten"}),s.jsx("dd",{children:w.mobileDetails.includedMinutes})]}),w.mobileDetails.includedSMS&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Inklusiv-SMS"}),s.jsx("dd",{children:w.mobileDetails.includedSMS})]}),w.mobileDetails.deviceModel&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Gerät"}),s.jsx("dd",{children:w.mobileDetails.deviceModel})]}),w.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:[w.mobileDetails.deviceImei,s.jsx(ce,{value:w.mobileDetails.deviceImei})]})]}),w.mobileDetails.requiresMultisim&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Multisim"}),s.jsx("dd",{children:s.jsx(ge,{variant:"warning",children:"Erforderlich"})})]})]}),w.mobileDetails.simCards&&w.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:w.mobileDetails.simCards.map(H=>s.jsx(ck,{simCard:H},H.id))})]}),(!w.mobileDetails.simCards||w.mobileDetails.simCards.length===0)&&(w.mobileDetails.phoneNumber||w.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:[w.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:[w.mobileDetails.phoneNumber,s.jsx(ce,{value:w.mobileDetails.phoneNumber})]})]}),w.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:[w.mobileDetails.simCardNumber,s.jsx(ce,{value:w.mobileDetails.simCardNumber})]})]})]})]})]}),w.tvDetails&&s.jsx(X,{className:"mb-6",title:"TV-Details",children:s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[w.tvDetails.receiverModel&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Receiver"}),s.jsx("dd",{children:w.tvDetails.receiverModel})]}),w.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:[w.tvDetails.smartcardNumber,s.jsx(ce,{value:w.tvDetails.smartcardNumber})]})]}),w.tvDetails.package&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Paket"}),s.jsx("dd",{children:w.tvDetails.package})]})]})}),w.carInsuranceDetails&&s.jsx(X,{className:"mb-6",title:"KFZ-Versicherung Details",children:s.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[w.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:[w.carInsuranceDetails.licensePlate,s.jsx(ce,{value:w.carInsuranceDetails.licensePlate})]})]}),w.carInsuranceDetails.vehicleType&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Fahrzeug"}),s.jsx("dd",{children:w.carInsuranceDetails.vehicleType})]}),w.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:[w.carInsuranceDetails.hsn,"/",w.carInsuranceDetails.tsn,s.jsx(ce,{value:`${w.carInsuranceDetails.hsn}/${w.carInsuranceDetails.tsn}`})]})]}),w.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:[w.carInsuranceDetails.vin,s.jsx(ce,{value:w.carInsuranceDetails.vin})]})]}),w.carInsuranceDetails.firstRegistration&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Erstzulassung"}),s.jsx("dd",{children:new Date(w.carInsuranceDetails.firstRegistration).toLocaleDateString("de-DE")})]}),w.carInsuranceDetails.noClaimsClass&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SF-Klasse"}),s.jsx("dd",{children:w.carInsuranceDetails.noClaimsClass})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Versicherungsart"}),s.jsx("dd",{children:s.jsx(ge,{variant:w.carInsuranceDetails.insuranceType==="FULL"?"success":w.carInsuranceDetails.insuranceType==="PARTIAL"?"warning":"default",children:w.carInsuranceDetails.insuranceType==="FULL"?"Vollkasko":w.carInsuranceDetails.insuranceType==="PARTIAL"?"Teilkasko":"Haftpflicht"})})]}),w.carInsuranceDetails.deductiblePartial&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SB Teilkasko"}),s.jsxs("dd",{children:[w.carInsuranceDetails.deductiblePartial," €"]})]}),w.carInsuranceDetails.deductibleFull&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"SB Vollkasko"}),s.jsxs("dd",{children:[w.carInsuranceDetails.deductibleFull," €"]})]}),w.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:[w.carInsuranceDetails.policyNumber,s.jsx(ce,{value:w.carInsuranceDetails.policyNumber})]})]}),w.carInsuranceDetails.previousInsurer&&s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Vorversicherer"}),s.jsx("dd",{children:w.carInsuranceDetails.previousInsurer})]})]})}),s.jsx(mk,{contractId:c,canEdit:i("contracts:update"),isCustomerPortal:o}),!o&&i("contracts:read")&&w.customerId&&s.jsx(bS,{contractId:c,customerId:w.customerId}),w.notes&&s.jsx(X,{title:"Notizen",children:s.jsx("p",{className:"whitespace-pre-wrap",children:w.notes})})]})}const pk=[{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 tx(){var bs,hl,Br,Kr,fl,Va,pl,Qa,Hm;const{id:e}=sc(),[t]=rc(),n=Vt(),r=pe(),a=!!e,i=t.get("customerId"),{register:l,handleSubmit:o,reset:c,watch:u,setValue:d,formState:{errors:h}}=J0({defaultValues:{customerId:i||"",type:"ELECTRICITY",status:"DRAFT"}}),p=u("type"),m=u("customerId"),{data:f}=he({queryKey:["contract",e],queryFn:()=>$e.getById(parseInt(e)),enabled:a}),{data:y}=he({queryKey:["customers-all"],queryFn:()=>Nt.getAll({limit:1e3})}),{data:N}=he({queryKey:["customer",m],queryFn:()=>Nt.getById(parseInt(m)),enabled:!!m}),{data:v}=he({queryKey:["platforms"],queryFn:()=>Bi.getAll()}),{data:g}=he({queryKey:["cancellation-periods"],queryFn:()=>Ki.getAll()}),{data:x}=he({queryKey:["contract-durations"],queryFn:()=>qi.getAll()}),{data:j}=he({queryKey:["providers"],queryFn:()=>Ra.getAll()}),{data:k}=he({queryKey:["contract-categories"],queryFn:()=>Vi.getAll()}),F=u("providerId"),[E,S]=b.useState(null),[P,A]=b.useState([]),[_,L]=b.useState([]),[V,q]=b.useState(!1),[O,C]=b.useState("manual"),[w,R]=b.useState(""),[Q,ee]=b.useState(!1),[fe,ue]=b.useState(!1),[nt,H]=b.useState({}),[ke,Ae]=b.useState({}),[rt,St]=b.useState({});b.useEffect(()=>{a||q(!0)},[a]),b.useEffect(()=>{!a&&i&&(y!=null&&y.data)&&y.data.some(ne=>ne.id.toString()===i)&&d("customerId",i)},[a,i,y,d]),b.useEffect(()=>{V&&E!==null&&F!==E&&d("tariffId",""),S(F)},[F,E,d,V]),b.useEffect(()=>{if(!a&&(k!=null&&k.data)&&k.data.length>0){const I=u("type"),ne=k.data.filter(le=>le.isActive),ye=ne.some(le=>le.code===I);if(!I||!ye){const le=ne.sort((xe,Xe)=>xe.sortOrder-Xe.sortOrder)[0];le&&d("type",le.code)}}},[k,a,d,u]),b.useEffect(()=>{var I,ne,ye,le,xe,Xe,we,Ha,Wm,Gm,Zm,Jm,Xm,Ym,eh,th,sh,nh,rh,ah,ih,lh,oh,ch,uh,dh,mh,hh,fh,ph,xh,gh,yh,vh,jh,bh,Nh,wh,Sh,kh,Ch,Eh,Dh,Ph,Ah,Mh,Th,Fh,Ih;if(f!=null&&f.data&&(v!=null&&v.data)&&(k!=null&&k.data)){const te=f.data;c({customerId:te.customerId.toString(),type:te.type,status:te.status,addressId:((I=te.addressId)==null?void 0:I.toString())||"",bankCardId:((ne=te.bankCardId)==null?void 0:ne.toString())||"",identityDocumentId:((ye=te.identityDocumentId)==null?void 0:ye.toString())||"",salesPlatformId:((le=te.salesPlatformId)==null?void 0:le.toString())||"",providerId:((xe=te.providerId)==null?void 0:xe.toString())||"",tariffId:((Xe=te.tariffId)==null?void 0:Xe.toString())||"",providerName:te.providerName||"",tariffName:te.tariffName||"",customerNumberAtProvider:te.customerNumberAtProvider||"",priceFirst12Months:te.priceFirst12Months||"",priceFrom13Months:te.priceFrom13Months||"",priceAfter24Months:te.priceAfter24Months||"",startDate:te.startDate?te.startDate.split("T")[0]:"",endDate:te.endDate?te.endDate.split("T")[0]:"",cancellationPeriodId:((we=te.cancellationPeriodId)==null?void 0:we.toString())||"",contractDurationId:((Ha=te.contractDurationId)==null?void 0:Ha.toString())||"",commission:te.commission||"",portalUsername:te.portalUsername||"",notes:te.notes||"",meterId:((Gm=(Wm=te.energyDetails)==null?void 0:Wm.meterId)==null?void 0:Gm.toString())||"",annualConsumption:((Zm=te.energyDetails)==null?void 0:Zm.annualConsumption)||"",basePrice:((Jm=te.energyDetails)==null?void 0:Jm.basePrice)||"",unitPrice:((Xm=te.energyDetails)==null?void 0:Xm.unitPrice)||"",bonus:((Ym=te.energyDetails)==null?void 0:Ym.bonus)||"",previousProviderName:((eh=te.energyDetails)==null?void 0:eh.previousProviderName)||"",previousCustomerNumber:((th=te.energyDetails)==null?void 0:th.previousCustomerNumber)||"",downloadSpeed:((sh=te.internetDetails)==null?void 0:sh.downloadSpeed)||"",uploadSpeed:((nh=te.internetDetails)==null?void 0:nh.uploadSpeed)||"",routerModel:((rh=te.internetDetails)==null?void 0:rh.routerModel)||"",routerSerialNumber:((ah=te.internetDetails)==null?void 0:ah.routerSerialNumber)||"",installationDate:(ih=te.internetDetails)!=null&&ih.installationDate?te.internetDetails.installationDate.split("T")[0]:"",internetUsername:((lh=te.internetDetails)==null?void 0:lh.internetUsername)||"",homeId:((oh=te.internetDetails)==null?void 0:oh.homeId)||"",activationCode:((ch=te.internetDetails)==null?void 0:ch.activationCode)||"",requiresMultisim:((uh=te.mobileDetails)==null?void 0:uh.requiresMultisim)||!1,dataVolume:((dh=te.mobileDetails)==null?void 0:dh.dataVolume)||"",includedMinutes:((mh=te.mobileDetails)==null?void 0:mh.includedMinutes)||"",includedSMS:((hh=te.mobileDetails)==null?void 0:hh.includedSMS)||"",deviceModel:((fh=te.mobileDetails)==null?void 0:fh.deviceModel)||"",deviceImei:((ph=te.mobileDetails)==null?void 0:ph.deviceImei)||"",phoneNumber:((xh=te.mobileDetails)==null?void 0:xh.phoneNumber)||"",simCardNumber:((gh=te.mobileDetails)==null?void 0:gh.simCardNumber)||"",receiverModel:((yh=te.tvDetails)==null?void 0:yh.receiverModel)||"",smartcardNumber:((vh=te.tvDetails)==null?void 0:vh.smartcardNumber)||"",tvPackage:((jh=te.tvDetails)==null?void 0:jh.package)||"",licensePlate:((bh=te.carInsuranceDetails)==null?void 0:bh.licensePlate)||"",hsn:((Nh=te.carInsuranceDetails)==null?void 0:Nh.hsn)||"",tsn:((wh=te.carInsuranceDetails)==null?void 0:wh.tsn)||"",vin:((Sh=te.carInsuranceDetails)==null?void 0:Sh.vin)||"",vehicleType:((kh=te.carInsuranceDetails)==null?void 0:kh.vehicleType)||"",firstRegistration:(Ch=te.carInsuranceDetails)!=null&&Ch.firstRegistration?te.carInsuranceDetails.firstRegistration.split("T")[0]:"",noClaimsClass:((Eh=te.carInsuranceDetails)==null?void 0:Eh.noClaimsClass)||"",insuranceType:((Dh=te.carInsuranceDetails)==null?void 0:Dh.insuranceType)||"LIABILITY",deductiblePartial:((Ph=te.carInsuranceDetails)==null?void 0:Ph.deductiblePartial)||"",deductibleFull:((Ah=te.carInsuranceDetails)==null?void 0:Ah.deductibleFull)||"",policyNumber:((Mh=te.carInsuranceDetails)==null?void 0:Mh.policyNumber)||"",previousInsurer:((Th=te.carInsuranceDetails)==null?void 0:Th.previousInsurer)||"",cancellationConfirmationDate:te.cancellationConfirmationDate?te.cancellationConfirmationDate.split("T")[0]:"",cancellationConfirmationOptionsDate:te.cancellationConfirmationOptionsDate?te.cancellationConfirmationOptionsDate.split("T")[0]:"",wasSpecialCancellation:te.wasSpecialCancellation||!1}),(Fh=te.mobileDetails)!=null&&Fh.simCards&&te.mobileDetails.simCards.length>0?A(te.mobileDetails.simCards.map(Qt=>({id:Qt.id,phoneNumber:Qt.phoneNumber||"",simCardNumber:Qt.simCardNumber||"",pin:"",puk:"",hasExistingPin:!!Qt.pin,hasExistingPuk:!!Qt.puk,isMultisim:Qt.isMultisim,isMain:Qt.isMain}))):A([]),(Ih=te.internetDetails)!=null&&Ih.phoneNumbers&&te.internetDetails.phoneNumbers.length>0?L(te.internetDetails.phoneNumbers.map(Qt=>({id:Qt.id,phoneNumber:Qt.phoneNumber||"",sipUsername:Qt.sipUsername||"",sipPassword:"",hasExistingSipPassword:!!Qt.sipPasswordEncrypted,sipServer:Qt.sipServer||"",isMain:Qt.isMain}))):L([]),te.stressfreiEmailId?(C("stressfrei"),R(te.stressfreiEmailId.toString())):(C("manual"),R("")),q(!0)}},[f,c,v,k]);const At=u("startDate"),G=u("contractDurationId");b.useEffect(()=>{if(At&&G&&(x!=null&&x.data)){const I=x.data.find(ne=>ne.id===parseInt(G));if(I){const ne=new Date(At),le=I.code.match(/^(\d+)([MTJ])$/);if(le){const xe=parseInt(le[1]),Xe=le[2];let we=new Date(ne);Xe==="T"?we.setDate(we.getDate()+xe):Xe==="M"?we.setMonth(we.getMonth()+xe):Xe==="J"&&we.setFullYear(we.getFullYear()+xe),d("endDate",we.toISOString().split("T")[0])}}}},[At,G,x,d]);const ze=W({mutationFn:$e.create,onSuccess:(I,ne)=>{r.invalidateQueries({queryKey:["contracts"]}),ne.customerId&&r.invalidateQueries({queryKey:["customer",ne.customerId.toString()]}),r.invalidateQueries({queryKey:["customers"]}),n(i?`/customers/${i}?tab=contracts`:"/contracts")}}),Rt=W({mutationFn:I=>$e.update(parseInt(e),I),onSuccess:(I,ne)=>{r.invalidateQueries({queryKey:["contracts"]}),r.invalidateQueries({queryKey:["contract",e]}),ne.customerId&&r.invalidateQueries({queryKey:["customer",ne.customerId.toString()]}),r.invalidateQueries({queryKey:["customers"]}),n(`/contracts/${e}`)}}),$r=I=>{const ne=we=>{if(we==null||we==="")return;const Ha=parseInt(String(we));return isNaN(Ha)?void 0:Ha},ye=J.find(we=>we.code===I.type),le=ne(I.customerId);if(!le){alert("Bitte wählen Sie einen Kunden aus");return}if(!I.type||!ye){alert("Bitte wählen Sie einen Vertragstyp aus");return}const xe=we=>we==null||we===""?null:we,Xe={customerId:le,type:I.type,contractCategoryId:ye.id,status:I.status,addressId:ne(I.addressId)??null,bankCardId:ne(I.bankCardId)??null,identityDocumentId:ne(I.identityDocumentId)??null,salesPlatformId:ne(I.salesPlatformId)??null,providerId:ne(I.providerId)??null,tariffId:ne(I.tariffId)??null,providerName:xe(I.providerName),tariffName:xe(I.tariffName),customerNumberAtProvider:xe(I.customerNumberAtProvider),priceFirst12Months:xe(I.priceFirst12Months),priceFrom13Months:xe(I.priceFrom13Months),priceAfter24Months:xe(I.priceAfter24Months),startDate:I.startDate?new Date(I.startDate):null,endDate:I.endDate?new Date(I.endDate):null,cancellationPeriodId:ne(I.cancellationPeriodId)??null,contractDurationId:ne(I.contractDurationId)??null,commission:I.commission?parseFloat(I.commission):null,portalUsername:O==="manual"?xe(I.portalUsername):null,stressfreiEmailId:O==="stressfrei"&&w?parseInt(w):null,portalPassword:I.portalPassword||void 0,notes:xe(I.notes),cancellationConfirmationDate:I.cancellationConfirmationDate?new Date(I.cancellationConfirmationDate):null,cancellationConfirmationOptionsDate:I.cancellationConfirmationOptionsDate?new Date(I.cancellationConfirmationOptionsDate):null,wasSpecialCancellation:I.wasSpecialCancellation||!1};["ELECTRICITY","GAS"].includes(I.type)&&(Xe.energyDetails={meterId:ne(I.meterId)??null,annualConsumption:I.annualConsumption?parseFloat(I.annualConsumption):null,basePrice:I.basePrice?parseFloat(I.basePrice):null,unitPrice:I.unitPrice?parseFloat(I.unitPrice):null,bonus:I.bonus?parseFloat(I.bonus):null,previousProviderName:xe(I.previousProviderName),previousCustomerNumber:xe(I.previousCustomerNumber)}),["DSL","CABLE","FIBER"].includes(I.type)&&(Xe.internetDetails={downloadSpeed:ne(I.downloadSpeed)??null,uploadSpeed:ne(I.uploadSpeed)??null,routerModel:xe(I.routerModel),routerSerialNumber:xe(I.routerSerialNumber),installationDate:I.installationDate?new Date(I.installationDate):null,internetUsername:xe(I.internetUsername),internetPassword:I.internetPassword||void 0,homeId:xe(I.homeId),activationCode:xe(I.activationCode),phoneNumbers:_.length>0?_.map(we=>({id:we.id,phoneNumber:we.phoneNumber||"",isMain:we.isMain??!1,sipUsername:xe(we.sipUsername),sipPassword:we.sipPassword||void 0,sipServer:xe(we.sipServer)})):void 0}),I.type==="MOBILE"&&(Xe.mobileDetails={requiresMultisim:I.requiresMultisim||!1,dataVolume:I.dataVolume?parseFloat(I.dataVolume):null,includedMinutes:ne(I.includedMinutes)??null,includedSMS:ne(I.includedSMS)??null,deviceModel:xe(I.deviceModel),deviceImei:xe(I.deviceImei),phoneNumber:xe(I.phoneNumber),simCardNumber:xe(I.simCardNumber),simCards:P.length>0?P.map(we=>({id:we.id,phoneNumber:xe(we.phoneNumber),simCardNumber:xe(we.simCardNumber),pin:we.pin||void 0,puk:we.puk||void 0,isMultisim:we.isMultisim,isMain:we.isMain})):void 0}),I.type==="TV"&&(Xe.tvDetails={receiverModel:xe(I.receiverModel),smartcardNumber:xe(I.smartcardNumber),package:xe(I.tvPackage)}),I.type==="CAR_INSURANCE"&&(Xe.carInsuranceDetails={licensePlate:xe(I.licensePlate),hsn:xe(I.hsn),tsn:xe(I.tsn),vin:xe(I.vin),vehicleType:xe(I.vehicleType),firstRegistration:I.firstRegistration?new Date(I.firstRegistration):null,noClaimsClass:xe(I.noClaimsClass),insuranceType:I.insuranceType,deductiblePartial:I.deductiblePartial?parseFloat(I.deductiblePartial):null,deductibleFull:I.deductibleFull?parseFloat(I.deductibleFull):null,policyNumber:xe(I.policyNumber),previousInsurer:xe(I.previousInsurer)}),a?Rt.mutate(Xe):ze.mutate(Xe)},Sn=ze.isPending||Rt.isPending,Ur=ze.error||Rt.error,gt=N==null?void 0:N.data,gc=(gt==null?void 0:gt.addresses)||[],yc=((bs=gt==null?void 0:gt.bankCards)==null?void 0:bs.filter(I=>I.isActive))||[],Qm=((hl=gt==null?void 0:gt.identityDocuments)==null?void 0:hl.filter(I=>I.isActive))||[],ml=((Br=gt==null?void 0:gt.meters)==null?void 0:Br.filter(I=>I.isActive))||[],M=((Kr=gt==null?void 0:gt.stressfreiEmails)==null?void 0:Kr.filter(I=>I.isActive))||[],$=(v==null?void 0:v.data)||[],B=(g==null?void 0:g.data)||[],ae=(x==null?void 0:x.data)||[],Y=((fl=j==null?void 0:j.data)==null?void 0:fl.filter(I=>I.isActive))||[],J=((Va=k==null?void 0:k.data)==null?void 0:Va.filter(I=>I.isActive).sort((I,ne)=>I.sortOrder-ne.sortOrder))||[],de=J.map(I=>({value:I.code,label:I.name})),Ce=Y.find(I=>I.id===parseInt(F||"0")),Me=((pl=Ce==null?void 0:Ce.tariffs)==null?void 0:pl.filter(I=>I.isActive))||[],yt=I=>{const ne=I.companyName||`${I.firstName} ${I.lastName}`,ye=I.birthDate?` (geb. ${new Date(I.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})`:"";return`${I.customerNumber} - ${ne}${ye}`},Zs=(()=>{var ye;const ne=((y==null?void 0:y.data)||[]).map(le=>({value:le.id.toString(),label:yt(le)}));if(a&&((ye=f==null?void 0:f.data)!=null&&ye.customer)){const le=f.data.customer;ne.some(Xe=>Xe.value===le.id.toString())||ne.unshift({value:le.id.toString(),label:yt(le)})}return ne})();return s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold mb-6",children:a?"Vertrag bearbeiten":"Neuer Vertrag"}),Ur&&s.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:Ur instanceof Error?Ur.message:"Ein Fehler ist aufgetreten"}),s.jsxs("form",{onSubmit:o($r),children:[s.jsx(X,{className:"mb-6",title:"Vertragsdaten",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Le,{label:"Kunde *",...l("customerId",{required:"Kunde erforderlich"}),options:Zs,error:(Qa=h.customerId)==null?void 0:Qa.message}),s.jsx(Le,{label:"Vertragstyp *",...l("type",{required:"Typ erforderlich"}),options:de}),s.jsx(Le,{label:"Status",...l("status"),options:pk}),s.jsx(Le,{label:"Vertriebsplattform",...l("salesPlatformId"),options:$.map(I=>({value:I.id,label:I.name}))})]})}),m&&s.jsx(X,{className:"mb-6",title:"Kundendaten verknüpfen",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(Le,{label:"Adresse",...l("addressId"),options:gc.map(I=>({value:I.id,label:`${I.street} ${I.houseNumber}, ${I.postalCode} ${I.city} (${I.type==="BILLING"?"Rechnung":"Liefer"})`}))}),s.jsx(Le,{label:"Bankkarte",...l("bankCardId"),options:yc.map(I=>({value:I.id,label:`${I.iban} (${I.accountHolder})`}))}),s.jsx(Le,{label:"Ausweis",...l("identityDocumentId"),options:Qm.map(I=>({value:I.id,label:`${I.documentNumber} (${I.type})`}))})]})}),s.jsx(X,{className:"mb-6",title:"Anbieter & Tarif",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Le,{label:"Anbieter",...l("providerId"),options:Y.map(I=>({value:I.id,label:I.name}))}),s.jsx(Le,{label:"Tarif",...l("tariffId"),options:Me.map(I=>({value:I.id,label:I.name})),disabled:!F}),s.jsx(K,{label:"Kundennummer beim Anbieter",...l("customerNumberAtProvider")}),s.jsx(K,{label:"Provision (€)",type:"number",step:"0.01",...l("commission")}),s.jsx(K,{label:"Preis erste 12 Monate",...l("priceFirst12Months"),placeholder:"z.B. 29,99 €/Monat"}),s.jsx(K,{label:"Preis ab 13. Monat",...l("priceFrom13Months"),placeholder:"z.B. 39,99 €/Monat"}),s.jsx(K,{label:"Preis nach 24 Monaten",...l("priceAfter24Months"),placeholder:"z.B. 49,99 €/Monat"})]})}),s.jsxs(X,{className:"mb-6",title:"Laufzeit und Kündigung",children:[s.jsxs("p",{className:"text-sm text-gray-500 mb-4 bg-blue-50 border border-blue-200 rounded-lg p-3",children:[s.jsx("strong",{children:"Hinweis:"})," Ist die Laufzeit ≤ 4 Wochen, 1 Monat oder 30 Tage, gilt der Vertrag als unbefristet mit der jeweiligen Kündigungsfrist."]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(K,{label:"Vertragsbeginn",type:"date",...l("startDate"),value:u("startDate")||"",onClear:()=>d("startDate","")}),s.jsx(K,{label:"Vertragsende (berechnet)",type:"date",...l("endDate"),disabled:!0,className:"bg-gray-50"}),s.jsx(Le,{label:"Vertragslaufzeit",...l("contractDurationId"),options:ae.map(I=>({value:I.id,label:I.description}))}),s.jsx(Le,{label:"Kündigungsfrist",...l("cancellationPeriodId"),options:B.map(I=>({value:I.id,label:I.description}))}),s.jsx(K,{label:"Kündigungsbestätigungsdatum",type:"date",...l("cancellationConfirmationDate"),value:u("cancellationConfirmationDate")||"",onClear:()=>d("cancellationConfirmationDate","")}),s.jsx(K,{label:"Kündigungsbestätigungsoptionendatum",type:"date",...l("cancellationConfirmationOptionsDate"),value:u("cancellationConfirmationOptionsDate")||"",onClear:()=>d("cancellationConfirmationOptionsDate","")}),s.jsx("div",{className:"col-span-2",children:s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",...l("wasSpecialCancellation"),className:"rounded border-gray-300"}),s.jsx("span",{children:"Wurde sondergekündigt?"})]})})]})]}),s.jsx(X,{className:"mb-6",title:"Zugangsdaten (verschlüsselt gespeichert)",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Portal Benutzername"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"radio",name:"usernameType",checked:O==="manual",onChange:()=>{C("manual"),R("")},className:"text-blue-600"}),s.jsx("span",{className:"text-sm",children:"Manuell eingeben"})]}),O==="manual"&&s.jsx(K,{...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:O==="stressfrei",onChange:()=>{C("stressfrei"),d("portalUsername","")},className:"text-blue-600"}),s.jsx("span",{className:"text-sm",children:"Stressfrei-Wechseln Adresse"})]}),O==="stressfrei"&&s.jsx(Le,{value:w,onChange:I=>R(I.target.value),options:M.map(I=>({value:I.id,label:I.email+(I.notes?` (${I.notes})`:"")})),placeholder:M.length===0?"Keine Stressfrei-Adressen vorhanden":"Adresse auswählen..."}),O==="stressfrei"&&M.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:Q?"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:()=>ee(!Q),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:Q?s.jsx(Et,{className:"w-4 h-4"}):s.jsx(De,{className:"w-4 h-4"})})]})]})]})}),["ELECTRICITY","GAS"].includes(p)&&s.jsx(X,{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(Le,{label:"Zähler",...l("meterId"),options:ml.filter(I=>I.type===p).map(I=>({value:I.id,label:`${I.meterNumber}${I.location?` (${I.location})`:""}`}))}),s.jsx(K,{label:`Jahresverbrauch (${p==="ELECTRICITY"?"kWh":"m³"})`,type:"number",...l("annualConsumption")}),s.jsx(K,{label:"Grundpreis (€/Monat)",type:"number",step:"0.01",...l("basePrice")}),s.jsx(K,{label:`Arbeitspreis (ct/${p==="ELECTRICITY"?"kWh":"m³"})`,type:"number",step:"0.01",...l("unitPrice")}),s.jsx(K,{label:"Bonus (€)",type:"number",step:"0.01",...l("bonus")}),s.jsx(K,{label:"Vorversorger",...l("previousProviderName")}),s.jsx(K,{label:"Kundennr. beim Vorversorger",...l("previousCustomerNumber")})]})}),["DSL","CABLE","FIBER"].includes(p)&&s.jsxs(s.Fragment,{children:[s.jsx(X,{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(K,{label:"Download (Mbit/s)",type:"number",...l("downloadSpeed")}),s.jsx(K,{label:"Upload (Mbit/s)",type:"number",...l("uploadSpeed")}),s.jsx(K,{label:"Router Modell",...l("routerModel")}),s.jsx(K,{label:"Router Seriennummer",...l("routerSerialNumber")}),s.jsx(K,{label:"Installationsdatum",type:"date",...l("installationDate"),value:u("installationDate")||"",onClear:()=>d("installationDate","")}),p==="FIBER"&&s.jsx(K,{label:"Home-ID",...l("homeId")}),((Hm=Ce==null?void 0:Ce.name)==null?void 0:Hm.toLowerCase().includes("vodafone"))&&["DSL","CABLE"].includes(p)&&s.jsx(K,{label:"Aktivierungscode",...l("activationCode")})]})}),s.jsx(X,{className:"mb-6",title:"Internet-Zugangsdaten (verschlüsselt)",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(K,{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:fe?"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:()=>ue(!fe),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:fe?s.jsx(Et,{className:"w-4 h-4"}):s.jsx(De,{className:"w-4 h-4"})})]})]})]})}),s.jsxs(X,{className:"mb-6",title:"Rufnummern & SIP-Zugangsdaten",children:[s.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Hier können Sie Festnetz-Rufnummern mit SIP-Zugangsdaten erfassen."}),_.length>0&&s.jsx("div",{className:"space-y-4 mb-4",children:_.map((I,ne)=>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 ",ne+1]}),s.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[s.jsx("input",{type:"checkbox",checked:I.isMain,onChange:ye=>{const le=[..._];ye.target.checked?le.forEach((xe,Xe)=>xe.isMain=Xe===ne):le[ne].isMain=!1,L(le)},className:"rounded border-gray-300"}),"Hauptnummer"]})]}),s.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:()=>{L(_.filter((ye,le)=>le!==ne))},children:s.jsx(ve,{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(K,{label:"Rufnummer",value:I.phoneNumber,onChange:ye=>{const le=[..._];le[ne].phoneNumber=ye.target.value,L(le)},placeholder:"z.B. 030 123456"}),s.jsx(K,{label:"SIP-Benutzername",value:I.sipUsername,onChange:ye=>{const le=[..._];le[ne].sipUsername=ye.target.value,L(le)}}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:I.hasExistingSipPassword?"SIP-Passwort (bereits hinterlegt)":"SIP-Passwort"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:nt[ne]?"text":"password",value:I.sipPassword,onChange:ye=>{const le=[..._];le[ne].sipPassword=ye.target.value,L(le)},placeholder:I.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:()=>H(ye=>({...ye,[ne]:!ye[ne]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:nt[ne]?s.jsx(Et,{className:"w-4 h-4"}):s.jsx(De,{className:"w-4 h-4"})})]})]}),s.jsx(K,{label:"SIP-Server",value:I.sipServer,onChange:ye=>{const le=[..._];le[ne].sipServer=ye.target.value,L(le)},placeholder:"z.B. sip.provider.de"})]})]},ne))}),s.jsxs(T,{type:"button",variant:"secondary",onClick:()=>{L([..._,{phoneNumber:"",sipUsername:"",sipPassword:"",sipServer:"",isMain:_.length===0}])},children:[s.jsx(Re,{className:"w-4 h-4 mr-2"}),"Rufnummer hinzufügen"]})]})]}),p==="MOBILE"&&s.jsxs(s.Fragment,{children:[s.jsxs(X,{className:"mb-6",title:"Mobilfunk-Details",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(K,{label:"Datenvolumen (GB)",type:"number",...l("dataVolume")}),s.jsx(K,{label:"Inklusiv-Minuten",type:"number",...l("includedMinutes")}),s.jsx(K,{label:"Inklusiv-SMS",type:"number",...l("includedSMS")}),s.jsx(K,{label:"Gerät (Modell)",...l("deviceModel")}),s.jsx(K,{label:"Gerät (IMEI)",...l("deviceImei")})]}),s.jsx("div",{className:"mt-4 pt-4 border-t",children:s.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",...l("requiresMultisim"),className:"mt-1 rounded border-gray-300"}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium",children:"Multisim erforderlich"}),s.jsx("p",{className:"text-sm text-amber-600 mt-1",children:"Hinweis: Multisim ist bei Klarmobil, Congstar und Otelo nicht buchbar. Muss Freenet oder vergleichbar sein."})]})]})})]}),s.jsxs(X,{className:"mb-6",title:"SIM-Karten",children:[s.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Hier können Sie alle SIM-Karten zum Vertrag erfassen (Hauptkarte und Multisim-Karten)."}),P.length>0&&s.jsx("div",{className:"space-y-4 mb-4",children:P.map((I,ne)=>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 ",ne+1]}),s.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[s.jsx("input",{type:"checkbox",checked:I.isMain,onChange:ye=>{const le=[...P];ye.target.checked?le.forEach((xe,Xe)=>xe.isMain=Xe===ne):le[ne].isMain=!1,A(le)},className:"rounded border-gray-300"}),"Hauptkarte"]}),s.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[s.jsx("input",{type:"checkbox",checked:I.isMultisim,onChange:ye=>{const le=[...P];le[ne].isMultisim=ye.target.checked,A(le)},className:"rounded border-gray-300"}),"Multisim"]})]}),s.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:()=>{A(P.filter((ye,le)=>le!==ne))},children:s.jsx(ve,{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(K,{label:"Rufnummer",value:I.phoneNumber,onChange:ye=>{const le=[...P];le[ne].phoneNumber=ye.target.value,A(le)},placeholder:"z.B. 0171 1234567"}),s.jsx(K,{label:"SIM-Kartennummer",value:I.simCardNumber,onChange:ye=>{const le=[...P];le[ne].simCardNumber=ye.target.value,A(le)},placeholder:"ICCID"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:I.hasExistingPin?"PIN (bereits hinterlegt)":"PIN"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:ke[ne]?"text":"password",value:I.pin,onChange:ye=>{const le=[...P];le[ne].pin=ye.target.value,A(le)},placeholder:I.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:()=>Ae(ye=>({...ye,[ne]:!ye[ne]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:ke[ne]?s.jsx(Et,{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:I.hasExistingPuk?"PUK (bereits hinterlegt)":"PUK"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:rt[ne]?"text":"password",value:I.puk,onChange:ye=>{const le=[...P];le[ne].puk=ye.target.value,A(le)},placeholder:I.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:()=>St(ye=>({...ye,[ne]:!ye[ne]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:rt[ne]?s.jsx(Et,{className:"w-4 h-4"}):s.jsx(De,{className:"w-4 h-4"})})]})]})]})]},ne))}),s.jsxs(T,{type:"button",variant:"secondary",onClick:()=>{A([...P,{phoneNumber:"",simCardNumber:"",pin:"",puk:"",isMultisim:!1,isMain:P.length===0}])},children:[s.jsx(Re,{className:"w-4 h-4 mr-2"}),"SIM-Karte hinzufügen"]})]})]}),p==="TV"&&s.jsx(X,{className:"mb-6",title:"TV-Details",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(K,{label:"Receiver Modell",...l("receiverModel")}),s.jsx(K,{label:"Smartcard-Nummer",...l("smartcardNumber")}),s.jsx(K,{label:"Paket",...l("tvPackage"),placeholder:"z.B. Basis, Premium, Sport"})]})}),p==="CAR_INSURANCE"&&s.jsx(X,{className:"mb-6",title:"KFZ-Versicherung Details",children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(K,{label:"Kennzeichen",...l("licensePlate")}),s.jsx(K,{label:"HSN",...l("hsn")}),s.jsx(K,{label:"TSN",...l("tsn")}),s.jsx(K,{label:"FIN (VIN)",...l("vin")}),s.jsx(K,{label:"Fahrzeugtyp",...l("vehicleType")}),s.jsx(K,{label:"Erstzulassung",type:"date",...l("firstRegistration"),value:u("firstRegistration")||"",onClear:()=>d("firstRegistration","")}),s.jsx(K,{label:"SF-Klasse",...l("noClaimsClass")}),s.jsx(Le,{label:"Versicherungsart",...l("insuranceType"),options:[{value:"LIABILITY",label:"Haftpflicht"},{value:"PARTIAL",label:"Teilkasko"},{value:"FULL",label:"Vollkasko"}]}),s.jsx(K,{label:"SB Teilkasko (€)",type:"number",...l("deductiblePartial")}),s.jsx(K,{label:"SB Vollkasko (€)",type:"number",...l("deductibleFull")}),s.jsx(K,{label:"Versicherungsscheinnummer",...l("policyNumber")}),s.jsx(K,{label:"Vorversicherer",...l("previousInsurer")})]})}),s.jsx(X,{className:"mb-6",title:"Notizen",children:s.jsx("textarea",{...l("notes"),rows:4,className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"Interne Notizen..."})}),s.jsxs("div",{className:"flex justify-end gap-4",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:()=>n(-1),children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:Sn,children:Sn?"Speichern...":"Speichern"})]})]})]})}const xk={ELECTRICITY:$m,GAS:L0,DSL:fa,CABLE:fa,FIBER:fa,MOBILE:Om,TV:_0,CAR_INSURANCE:T0},gk={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabel",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ"},yk={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"},vk={critical:"danger",warning:"warning",ok:"success",none:"default"},jk={cancellation_deadline:M0,contract_ending:vn,missing_cancellation_letter:at,missing_cancellation_confirmation:at,missing_portal_credentials:W2,missing_customer_number:at,missing_provider:at,missing_address:at,missing_bank:at,missing_meter:$m,missing_sim:Om,open_tasks:Qi,pending_status:vn,draft_status:at},bk={cancellationDeadlines:"Kündigungsfristen",contractEnding:"Vertragsenden",missingCredentials:"Fehlende Zugangsdaten",missingData:"Fehlende Daten",openTasks:"Offene Aufgaben",pendingContracts:"Wartende Verträge"};function Nk(){var y;const[e,t]=rc(),[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:u}=he({queryKey:["contract-cockpit"],queryFn:()=>$e.getCockpit(),staleTime:0}),d=N=>{r(v=>{const g=new Set(v);return g.has(N)?g.delete(N):g.add(N),g})},h=b.useMemo(()=>{var v;if(!((v=o==null?void 0:o.data)!=null&&v.contracts))return[];const N=o.data.contracts;switch(i){case"critical":return N.filter(g=>g.highestUrgency==="critical");case"warning":return N.filter(g=>g.highestUrgency==="warning");case"ok":return N.filter(g=>g.highestUrgency==="ok");case"deadlines":return N.filter(g=>g.issues.some(x=>["cancellation_deadline","contract_ending"].includes(x.type)));case"credentials":return N.filter(g=>g.issues.some(x=>x.type.includes("credentials")));case"data":return N.filter(g=>g.issues.some(x=>x.type.startsWith("missing_")&&!x.type.includes("credentials")));case"tasks":return N.filter(g=>g.issues.some(x=>["open_tasks","pending_status","draft_status"].includes(x.type)));default:return N}},[(y=o==null?void 0:o.data)==null?void 0:y.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(u||!(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=N=>{var x,j,k,F;const v=n.has(N.id),g=xk[N.type]||at;return s.jsxs("div",{className:`border rounded-lg mb-2 ${yk[N.highestUrgency]}`,children:[s.jsxs("div",{className:"flex items-center p-4 cursor-pointer hover:bg-opacity-50",onClick:()=>d(N.id),children:[s.jsx("div",{className:"w-6 mr-2",children:v?s.jsx(mc,{className:"w-5 h-5"}):s.jsx(rs,{className:"w-5 h-5"})}),s.jsx(g,{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(Ne,{to:`/contracts/${N.id}`,state:{from:"cockpit",filter:i!=="all"?i:void 0},className:"font-medium hover:underline",onClick:E=>E.stopPropagation(),children:N.contractNumber}),s.jsxs(ge,{variant:vk[N.highestUrgency],children:[N.issues.length," ",N.highestUrgency==="ok"?N.issues.length===1?"Hinweis":"Hinweise":N.issues.length===1?"Problem":"Probleme"]}),s.jsx("span",{className:"text-sm",children:gk[N.type]})]}),s.jsxs("div",{className:"text-sm mt-1",children:[s.jsxs(Ne,{to:`/customers/${N.customer.id}`,className:"hover:underline",onClick:E=>E.stopPropagation(),children:[N.customer.customerNumber," - ",N.customer.name]}),(((x=N.provider)==null?void 0:x.name)||N.providerName)&&s.jsxs("span",{className:"ml-2",children:["| ",((j=N.provider)==null?void 0:j.name)||N.providerName,(((k=N.tariff)==null?void 0:k.name)||N.tariffName)&&` - ${((F=N.tariff)==null?void 0:F.name)||N.tariffName}`]})]})]}),s.jsx(Ne,{to:`/contracts/${N.id}`,state:{from:"cockpit",filter:i!=="all"?i:void 0},className:"ml-4 p-2 hover:bg-white hover:bg-opacity-50 rounded",onClick:E=>E.stopPropagation(),title:"Zum Vertrag",children:s.jsx(De,{className:"w-4 h-4"})})]}),v&&s.jsx("div",{className:"border-t px-4 py-3 bg-white bg-opacity-50",children:s.jsx("div",{className:"space-y-2",children:N.issues.map((E,S)=>{const P=jk[E.type]||un,A=E.urgency==="critical"?un:E.urgency==="warning"?nr:E.urgency==="ok"?gs:vn;return s.jsxs("div",{className:"flex items-start gap-3 text-sm",children:[s.jsx(A,{className:`w-4 h-4 mt-0.5 flex-shrink-0 ${E.urgency==="critical"?"text-red-500":E.urgency==="warning"?"text-yellow-500":E.urgency==="ok"?"text-green-500":"text-gray-500"}`}),s.jsx(P,{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:E.label}),E.details&&s.jsx("span",{className:"text-gray-600 ml-2",children:E.details})]})]},S)})})})]},N.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(un,{className:"w-6 h-6 text-red-500"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Vertrags-Cockpit"})]}),s.jsx(Ne,{to:"/settings/deadlines",className:"text-sm text-blue-600 hover:underline",children:"Fristenschwellen anpassen"})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-6",children:[s.jsx(X,{className:"!p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-red-100 rounded-lg",children:s.jsx(un,{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(X,{className:"!p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-yellow-100 rounded-lg",children:s.jsx(nr,{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(X,{className:"!p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-green-100 rounded-lg",children:s.jsx(gs,{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(X,{className:"!p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-gray-100 rounded-lg",children:s.jsx(at,{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(X,{className:"mb-6",children:s.jsx("div",{className:"flex flex-wrap gap-4",children:Object.entries(p.byCategory).map(([N,v])=>v>0&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsxs("span",{className:"font-medium",children:[bk[N]||N,":"]}),s.jsx(ge,{variant:"default",children:v})]},N))})}),s.jsx(X,{className:"mb-6",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("span",{className:"text-sm text-gray-600",children:"Filter:"}),s.jsx(Le,{value:i,onChange:N=>l(N.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(X,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:i==="all"?s.jsxs(s.Fragment,{children:[s.jsx(gs,{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 sx={OPEN:"Offen",COMPLETED:"Erledigt"},wk={OPEN:"warning",COMPLETED:"success"};function Sk(){var q;const e=Vt(),t=pe(),{isCustomerPortal:n,user:r,hasPermission:a}=Be(),[i,l]=b.useState("OPEN"),[o,c]=b.useState(new Set),[u,d]=b.useState(!1),[h,p]=b.useState({}),m=n?"Support-Anfragen":"Aufgaben",f=n?"Anfrage":"Aufgabe",{data:y,isLoading:N}=he({queryKey:["app-settings-public"],queryFn:()=>Or.getPublic(),enabled:n,staleTime:0}),v=!N&&((q=y==null?void 0:y.data)==null?void 0:q.customerSupportTicketsEnabled)==="true",{data:g,isLoading:x}=he({queryKey:["all-tasks",i],queryFn:()=>st.getAll({status:i||void 0}),staleTime:0}),j=W({mutationFn:O=>st.completeSubtask(O),onSuccess:()=>{t.invalidateQueries({queryKey:["all-tasks"]}),t.invalidateQueries({queryKey:["task-stats"]})}}),k=W({mutationFn:O=>st.reopenSubtask(O),onSuccess:()=>{t.invalidateQueries({queryKey:["all-tasks"]}),t.invalidateQueries({queryKey:["task-stats"]})}}),F=W({mutationFn:({taskId:O,title:C})=>n?st.createReply(O,C):st.createSubtask(O,C),onSuccess:(O,{taskId:C})=>{t.invalidateQueries({queryKey:["all-tasks"]}),p(w=>({...w,[C]:""}))}}),E=b.useMemo(()=>{var R;if(!(g!=null&&g.data))return{ownTasks:[],representedTasks:[],allTasks:[]};const O=g.data;if(!n)return{allTasks:O,ownTasks:[],representedTasks:[]};const C=[],w=[];for(const Q of O)((R=Q.contract)==null?void 0:R.customerId)===(r==null?void 0:r.customerId)?C.push(Q):w.push(Q);return{ownTasks:C,representedTasks:w,allTasks:[]}},[g==null?void 0:g.data,n,r==null?void 0:r.customerId]),S=O=>{c(C=>{const w=new Set(C);return w.has(O)?w.delete(O):w.add(O),w})},P=O=>{j.isPending||k.isPending||(O.status==="COMPLETED"?k.mutate(O.id):j.mutate(O.id))},A=O=>{var w;const C=(w=h[O])==null?void 0:w.trim();C&&F.mutate({taskId:O,title:C})},_=!n&&a("contracts:update"),L=(O,C=!1)=>{var H,ke,Ae,rt,St,At;const w=o.has(O.id),R=O.subtasks&&O.subtasks.length>0,Q=((H=O.subtasks)==null?void 0:H.filter(G=>G.status==="COMPLETED").length)||0,ee=((ke=O.subtasks)==null?void 0:ke.length)||0,fe=O.status==="COMPLETED",ue=O.contract?`${O.contract.contractNumber} - ${((Ae=O.contract.provider)==null?void 0:Ae.name)||O.contract.providerName||"Kein Anbieter"}`:`Vertrag #${O.contractId}`,nt=(rt=O.contract)!=null&&rt.customer?O.contract.customer.companyName||`${O.contract.customer.firstName} ${O.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:()=>S(O.id),children:[s.jsx("div",{className:"w-6 mr-2",children:w?s.jsx(mc,{className:"w-5 h-5 text-gray-400"}):s.jsx(rs,{className:"w-5 h-5 text-gray-400"})}),s.jsx("div",{className:"mr-3",children:O.status==="COMPLETED"?s.jsx(gs,{className:"w-5 h-5 text-green-500"}):s.jsx(vn,{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:O.title}),s.jsx(ge,{variant:wk[O.status],children:sx[O.status]}),R&&s.jsxs("span",{className:"text-xs text-gray-500",children:["(",Q,"/",ee," erledigt)"]})]}),s.jsxs("div",{className:"text-sm text-gray-500 mt-1 flex items-center gap-2",children:[s.jsx(at,{className:"w-4 h-4"}),s.jsx(Ne,{to:`/contracts/${O.contractId}`,className:"text-blue-600 hover:underline",onClick:G=>G.stopPropagation(),children:ue}),C&&nt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-gray-400",children:"|"}),s.jsx("span",{children:nt})]})]}),O.description&&s.jsx("p",{className:"text-sm text-gray-600 mt-1 line-clamp-2",children:O.description})]}),s.jsx("div",{className:"ml-4 flex gap-2",children:s.jsx(T,{variant:"ghost",size:"sm",onClick:G=>{G.stopPropagation(),e(`/contracts/${O.contractId}`)},title:"Zum Vertrag",children:s.jsx(De,{className:"w-4 h-4"})})})]}),w&&s.jsxs("div",{className:"border-t bg-gray-50 px-4 py-3",children:[R&&s.jsx("div",{className:"space-y-2 mb-4",children:(St=O.subtasks)==null?void 0:St.map(G=>{const ze=new Date(G.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 ${_?"cursor-pointer hover:bg-gray-100 rounded px-2 py-1 -mx-2":""}`,onClick:_?()=>P(G):void 0,children:[s.jsx("span",{className:"flex-shrink-0 mt-0.5",children:G.status==="COMPLETED"?s.jsx(gs,{className:"w-4 h-4 text-green-500"}):s.jsx(to,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:G.status==="COMPLETED"?"text-gray-500 line-through":"",children:[G.title,s.jsxs("span",{className:"text-xs text-gray-400 ml-2",children:[G.createdBy," • ",ze]})]})]},G.id)})}),!fe&&(_||n)&&s.jsxs("div",{className:"flex gap-2 ml-6",children:[s.jsx(K,{placeholder:n?"Antwort schreiben...":"Neue Unteraufgabe...",value:h[O.id]||"",onChange:G=>p(ze=>({...ze,[O.id]:G.target.value})),onKeyDown:G=>{G.key==="Enter"&&!G.shiftKey&&(G.preventDefault(),A(O.id))},className:"flex-1"}),s.jsx(T,{size:"sm",onClick:()=>A(O.id),disabled:!((At=h[O.id])!=null&&At.trim())||F.isPending,children:s.jsx(ul,{className:"w-4 h-4"})})]}),!R&&fe&&s.jsx("p",{className:"text-gray-500 text-sm text-center py-2",children:"Keine Unteraufgaben vorhanden."})]})]},O.id)},V=n?v:a("contracts:update");return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold",children:m}),V&&s.jsxs(T,{onClick:()=>d(!0),children:[s.jsx(Re,{className:"w-4 h-4 mr-2"}),"Neue ",f]})]}),s.jsx(X,{className:"mb-6",children:s.jsx("div",{className:"flex gap-4 flex-wrap items-center",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-gray-600",children:"Status:"}),s.jsx(Le,{value:i,onChange:O=>l(O.target.value),options:[{value:"",label:"Alle"},...Object.entries(sx).map(([O,C])=>({value:O,label:C}))],className:"w-40"})]})})}),x?s.jsx(X,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."})}):s.jsx(s.Fragment,{children:n?s.jsxs("div",{className:"space-y-6",children:[s.jsxs(X,{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:[s.jsx(_m,{className:"w-5 h-5 text-blue-600"}),s.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:["Meine ",m]}),s.jsx(ge,{variant:"default",children:E.ownTasks.length})]}),E.ownTasks.length>0?s.jsx("div",{children:E.ownTasks.map(O=>L(O,!1))}):s.jsxs("p",{className:"text-gray-500 text-center py-4",children:["Keine eigenen ",m.toLowerCase()," vorhanden."]})]}),E.representedTasks.length>0&&s.jsxs(X,{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:[s.jsx(ha,{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(ge,{variant:"default",children:E.representedTasks.length})]}),s.jsx("div",{children:E.representedTasks.map(O=>L(O,!0))})]})]}):s.jsx(X,{children:E.allTasks&&E.allTasks.length>0?s.jsx("div",{children:E.allTasks.map(O=>L(O,!0))}):s.jsxs("div",{className:"text-center py-8 text-gray-500",children:["Keine ",m.toLowerCase()," gefunden."]})})}),n?s.jsx(kk,{isOpen:u,onClose:()=>d(!1)}):s.jsx(Ck,{isOpen:u,onClose:()=>d(!1)})]})}function kk({isOpen:e,onClose:t}){const{user:n}=Be(),r=Vt(),a=pe(),[i,l]=b.useState("own"),[o,c]=b.useState(null),[u,d]=b.useState(""),[h,p]=b.useState(""),[m,f]=b.useState(!1),[y,N]=b.useState(""),{data:v}=he({queryKey:["contracts",n==null?void 0:n.customerId],queryFn:()=>$e.getAll({customerId:n==null?void 0:n.customerId}),enabled:e}),g=b.useMemo(()=>{if(!(v!=null&&v.data))return{own:[],represented:{}};const S=[],P={};for(const A of v.data)if(A.customerId===(n==null?void 0:n.customerId))S.push(A);else{if(!P[A.customerId]){const _=A.customer?A.customer.companyName||`${A.customer.firstName} ${A.customer.lastName}`:`Kunde ${A.customerId}`;P[A.customerId]={name:_,contracts:[]}}P[A.customerId].contracts.push(A)}return{own:S,represented:P}},[v==null?void 0:v.data,n==null?void 0:n.customerId]),x=Object.keys(g.represented).length>0,j=b.useMemo(()=>{var S;return i==="own"?g.own:((S=g.represented[i])==null?void 0:S.contracts)||[]},[i,g]),k=b.useMemo(()=>{if(!y)return j;const S=y.toLowerCase();return j.filter(P=>P.contractNumber.toLowerCase().includes(S)||(P.providerName||"").toLowerCase().includes(S)||(P.tariffName||"").toLowerCase().includes(S))},[j,y]),F=async()=>{if(!(!o||!u.trim())){f(!0);try{await st.createSupportTicket(o,{title:u.trim(),description:h.trim()||void 0}),a.invalidateQueries({queryKey:["all-tasks"]}),a.invalidateQueries({queryKey:["task-stats"]}),t(),d(""),p(""),c(null),l("own"),r(`/contracts/${o}`)}catch(S){console.error("Fehler beim Erstellen der Support-Anfrage:",S),alert("Fehler beim Erstellen der Support-Anfrage. Bitte versuchen Sie es erneut.")}finally{f(!1)}}},E=()=>{d(""),p(""),c(null),l("own"),N(""),t()};return s.jsx(ot,{isOpen:e,onClose:E,title:"Neue Support-Anfrage",children:s.jsxs("div",{className:"space-y-4",children:[x&&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:S=>{const P=S.target.value;l(P==="own"?"own":parseInt(P)),c(null),N("")},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(g.represented).map(([S,{name:P}])=>s.jsx("option",{value:S,children:P},S))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),s.jsx(K,{placeholder:"Vertrag suchen...",value:y,onChange:S=>N(S.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-lg",children:k.length>0?k.map(S=>s.jsxs("div",{onClick:()=>c(S.id),className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${o===S.id?"bg-blue-50 border-blue-200":""}`,children:[s.jsx("div",{className:"font-medium",children:S.contractNumber}),s.jsxs("div",{className:"text-sm text-gray-500",children:[S.providerName||"Kein Anbieter",S.tariffName&&` - ${S.tariffName}`]})]},S.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(K,{value:u,onChange:S=>d(S.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:S=>p(S.target.value),placeholder:"Detaillierte Beschreibung (optional)",rows:4,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:E,children:"Abbrechen"}),s.jsx(T,{onClick:F,disabled:!o||!u.trim()||m,children:m?"Wird erstellt...":"Anfrage erstellen"})]})]})})}function Ck({isOpen:e,onClose:t}){const n=Vt(),r=pe(),[a,i]=b.useState(null),[l,o]=b.useState(null),[c,u]=b.useState(""),[d,h]=b.useState(""),[p,m]=b.useState(!1),[f,y]=b.useState(!1),[N,v]=b.useState(""),[g,x]=b.useState(""),{data:j}=he({queryKey:["customers-for-task"],queryFn:()=>Nt.getAll({limit:100}),enabled:e}),{data:k}=he({queryKey:["contracts-for-task",a],queryFn:()=>$e.getAll({customerId:a}),enabled:e&&a!==null}),F=b.useMemo(()=>{if(!(j!=null&&j.data))return[];if(!N)return j.data;const _=N.toLowerCase();return j.data.filter(L=>L.customerNumber.toLowerCase().includes(_)||L.firstName.toLowerCase().includes(_)||L.lastName.toLowerCase().includes(_)||(L.companyName||"").toLowerCase().includes(_))},[j==null?void 0:j.data,N]),E=b.useMemo(()=>{if(!(k!=null&&k.data))return[];if(!g)return k.data;const _=g.toLowerCase();return k.data.filter(L=>L.contractNumber.toLowerCase().includes(_)||(L.providerName||"").toLowerCase().includes(_)||(L.tariffName||"").toLowerCase().includes(_))},[k==null?void 0:k.data,g]),S=async()=>{if(!(!l||!c.trim())){y(!0);try{await st.create(l,{title:c.trim(),description:d.trim()||void 0,visibleInPortal:p}),r.invalidateQueries({queryKey:["all-tasks"]}),r.invalidateQueries({queryKey:["task-stats"]}),t(),u(""),h(""),m(!1),o(null),i(null),n(`/contracts/${l}`)}catch(_){console.error("Fehler beim Erstellen der Aufgabe:",_),alert("Fehler beim Erstellen der Aufgabe. Bitte versuchen Sie es erneut.")}finally{y(!1)}}},P=()=>{u(""),h(""),m(!1),o(null),i(null),v(""),x(""),t()},A=_=>{const L=_.companyName||`${_.firstName} ${_.lastName}`;return`${_.customerNumber} - ${L}`};return s.jsx(ot,{isOpen:e,onClose:P,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(K,{placeholder:"Kunde suchen...",value:N,onChange:_=>v(_.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-40 overflow-y-auto border rounded-lg",children:F.length>0?F.map(_=>s.jsx("div",{onClick:()=>{i(_.id),o(null),x("")},className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${a===_.id?"bg-blue-50 border-blue-200":""}`,children:s.jsx("div",{className:"font-medium",children:A(_)})},_.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(K,{placeholder:"Vertrag suchen...",value:g,onChange:_=>x(_.target.value),className:"mb-2"}),s.jsx("div",{className:"max-h-40 overflow-y-auto border rounded-lg",children:E.length>0?E.map(_=>s.jsxs("div",{onClick:()=>o(_.id),className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${l===_.id?"bg-blue-50 border-blue-200":""}`,children:[s.jsx("div",{className:"font-medium",children:_.contractNumber}),s.jsxs("div",{className:"text-sm text-gray-500",children:[_.providerName||"Kein Anbieter",_.tariffName&&` - ${_.tariffName}`]})]},_.id)):s.jsx("div",{className:"p-3 text-gray-500 text-center",children:k?"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(K,{value:c,onChange:_=>u(_.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:d,onChange:_=>h(_.target.value),placeholder:"Detaillierte Beschreibung (optional)",rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),s.jsx("div",{children:s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:p,onChange:_=>m(_.target.checked),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),s.jsx("span",{className:"text-sm text-gray-700",children:"Im Kundenportal sichtbar"})]})}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[s.jsx(T,{variant:"secondary",onClick:P,children:"Abbrechen"}),s.jsx(T,{onClick:S,disabled:!l||!c.trim()||f,children:f?"Wird erstellt...":"Aufgabe erstellen"})]})]})})}function Ek(){const[e,t]=b.useState(!1),[n,r]=b.useState(null),[a,i]=b.useState(!1),{hasPermission:l}=Be(),o=pe(),{data:c,isLoading:u}=he({queryKey:["platforms",a],queryFn:()=>Bi.getAll(a)}),d=W({mutationFn:Bi.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(T,{onClick:()=>t(!0),children:[s.jsx(Re,{className:"w-4 h-4 mr-2"}),"Neue Plattform"]})]}),s.jsxs(X,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:m=>i(m.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),u?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(ge,{variant:m.isActive?"success":"danger",children:m.isActive?"Aktiv":"Inaktiv"})}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>h(m),children:s.jsx(Je,{className:"w-4 h-4"})}),l("platforms:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Plattform wirklich löschen?")&&d.mutate(m.id)},children:s.jsx(ve,{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(Dk,{isOpen:e,onClose:p,platform:n})]})}function Dk({isOpen:e,onClose:t,platform:n}){const r=pe(),[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=W({mutationFn:Bi.create,onSuccess:()=>{r.invalidateQueries({queryKey:["platforms"]}),t(),i({name:"",contactInfo:"",isActive:!0})}}),o=W({mutationFn:d=>Bi.update(n.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["platforms"]}),t()}}),c=d=>{d.preventDefault(),n?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return s.jsx(ot,{isOpen:e,onClose:t,title:n?"Plattform bearbeiten":"Neue Plattform",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(K,{label:"Name *",value:a.name,onChange:d=>i({...a,name:d.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:d=>i({...a,contactInfo:d.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:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}function Pk(){const[e,t]=b.useState(!1),[n,r]=b.useState(null),[a,i]=b.useState(!1),{hasPermission:l}=Be(),o=pe(),{data:c,isLoading:u}=he({queryKey:["cancellation-periods",a],queryFn:()=>Ki.getAll(a)}),d=W({mutationFn:Ki.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(Ne,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Gs,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Kündigungsfristen"}),l("platforms:create")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx(Re,{className:"w-4 h-4 mr-2"}),"Neue Frist"]})]}),s.jsxs(X,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:m=>i(m.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),s.jsxs("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg text-sm",children:[s.jsx("strong",{children:"Code-Format:"})," Zahl + Buchstabe (T=Tage, M=Monate, J=Jahre)",s.jsx("br",{}),s.jsx("strong",{children:"Beispiele:"})," 14T = 14 Tage, 3M = 3 Monate, 1J = 1 Jahr"]}),u?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(ge,{variant:m.isActive?"success":"danger",children:m.isActive?"Aktiv":"Inaktiv"})}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>h(m),children:s.jsx(Je,{className:"w-4 h-4"})}),l("platforms:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Kündigungsfrist wirklich löschen?")&&d.mutate(m.id)},children:s.jsx(ve,{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(Ak,{isOpen:e,onClose:p,period:n})]})}function Ak({isOpen:e,onClose:t,period:n}){const r=pe(),[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=W({mutationFn:Ki.create,onSuccess:()=>{r.invalidateQueries({queryKey:["cancellation-periods"]}),t(),i({code:"",description:"",isActive:!0})}}),o=W({mutationFn:d=>Ki.update(n.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["cancellation-periods"]}),t()}}),c=d=>{d.preventDefault(),n?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return s.jsx(ot,{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(K,{label:"Code *",value:a.code,onChange:d=>i({...a,code:d.target.value.toUpperCase()}),required:!0,placeholder:"z.B. 14T, 3M, 1J"}),s.jsx(K,{label:"Beschreibung *",value:a.description,onChange:d=>i({...a,description:d.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:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}function Mk(){const[e,t]=b.useState(!1),[n,r]=b.useState(null),[a,i]=b.useState(!1),{hasPermission:l}=Be(),o=pe(),{data:c,isLoading:u}=he({queryKey:["contract-durations",a],queryFn:()=>qi.getAll(a)}),d=W({mutationFn:qi.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(Ne,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Gs,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Vertragslaufzeiten"}),l("platforms:create")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx(Re,{className:"w-4 h-4 mr-2"}),"Neue Laufzeit"]})]}),s.jsxs(X,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:m=>i(m.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),s.jsxs("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg text-sm",children:[s.jsx("strong",{children:"Code-Format:"})," Zahl + Buchstabe (T=Tage, M=Monate, J=Jahre)",s.jsx("br",{}),s.jsx("strong",{children:"Beispiele:"})," 12M = 12 Monate, 24M = 24 Monate, 2J = 2 Jahre"]}),u?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(ge,{variant:m.isActive?"success":"danger",children:m.isActive?"Aktiv":"Inaktiv"})}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>h(m),children:s.jsx(Je,{className:"w-4 h-4"})}),l("platforms:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Laufzeit wirklich löschen?")&&d.mutate(m.id)},children:s.jsx(ve,{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(Tk,{isOpen:e,onClose:p,duration:n})]})}function Tk({isOpen:e,onClose:t,duration:n}){const r=pe(),[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=W({mutationFn:qi.create,onSuccess:()=>{r.invalidateQueries({queryKey:["contract-durations"]}),t(),i({code:"",description:"",isActive:!0})}}),o=W({mutationFn:d=>qi.update(n.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["contract-durations"]}),t()}}),c=d=>{d.preventDefault(),n?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return s.jsx(ot,{isOpen:e,onClose:t,title:n?"Laufzeit bearbeiten":"Neue Laufzeit",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(K,{label:"Code *",value:a.code,onChange:d=>i({...a,code:d.target.value.toUpperCase()}),required:!0,placeholder:"z.B. 12M, 24M, 2J"}),s.jsx(K,{label:"Beschreibung *",value:a.description,onChange:d=>i({...a,description:d.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:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}function Fk(){const[e,t]=b.useState(!1),[n,r]=b.useState(null),[a,i]=b.useState(!1),[l,o]=b.useState(new Set),{hasPermission:c}=Be(),u=pe(),{data:d,isLoading:h}=he({queryKey:["providers",a],queryFn:()=>Ra.getAll(a)}),p=W({mutationFn:Ra.delete,onSuccess:()=>{u.invalidateQueries({queryKey:["providers"]})},onError:N=>{alert(N.message)}}),m=N=>{o(v=>{const g=new Set(v);return g.has(N)?g.delete(N):g.add(N),g})},f=N=>{r(N),t(!0)},y=()=>{t(!1),r(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(Ne,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Gs,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Anbieter & Tarife"}),c("providers:create")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx(Re,{className:"w-4 h-4 mr-2"}),"Neuer Anbieter"]})]}),s.jsxs(X,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:N=>i(N.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),h?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):d!=null&&d.data&&d.data.length>0?s.jsx("div",{className:"space-y-2",children:d.data.map(N=>s.jsx(Ik,{provider:N,isExpanded:l.has(N.id),onToggle:()=>m(N.id),onEdit:()=>f(N),onDelete:()=>{confirm("Anbieter wirklich löschen?")&&p.mutate(N.id)},hasPermission:c,showInactive:a},N.id))}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Anbieter vorhanden."})]}),s.jsx(Lk,{isOpen:e,onClose:y,provider:n})]})}function Ik({provider:e,isExpanded:t,onToggle:n,onEdit:r,onDelete:a,hasPermission:i,showInactive:l}){var f,y;const[o,c]=b.useState(!1),[u,d]=b.useState(null),h=pe(),p=W({mutationFn:k0.delete,onSuccess:()=>{h.invalidateQueries({queryKey:["providers"]})},onError:N=>{alert(N.message)}}),m=((f=e.tariffs)==null?void 0:f.filter(N=>l||N.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(mc,{className:"w-5 h-5 text-gray-400"}):s.jsx(rs,{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(ge,{variant:e.isActive?"success":"danger",children:e.isActive?"Aktiv":"Inaktiv"}),s.jsxs("span",{className:"text-sm text-gray-500",children:["(",m.length," Tarife, ",((y=e._count)==null?void 0:y.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(Lm,{className:"w-3 h-3"}),e.portalUrl]})]}),s.jsxs("div",{className:"flex gap-2 ml-4",children:[i("providers:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:r,title:"Bearbeiten",children:s.jsx(Je,{className:"w-4 h-4"})}),i("providers:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:a,title:"Löschen",children:s.jsx(ve,{className:"w-4 h-4 text-red-500"})})]})]}),t&&s.jsxs("div",{className:"border-t bg-gray-50 p-4",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsx("h4",{className:"font-medium text-gray-700",children:"Tarife"}),i("providers:create")&&s.jsxs(T,{size:"sm",onClick:()=>c(!0),children:[s.jsx(Re,{className:"w-4 h-4 mr-1"}),"Tarif hinzufügen"]})]}),m.length>0?s.jsx("div",{className:"space-y-2",children:m.map(N=>{var v;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:N.name}),s.jsx(ge,{variant:N.isActive?"success":"danger",className:"text-xs",children:N.isActive?"Aktiv":"Inaktiv"}),((v=N._count)==null?void 0:v.contracts)!==void 0&&s.jsxs("span",{className:"text-xs text-gray-500",children:["(",N._count.contracts," Verträge)"]})]}),s.jsxs("div",{className:"flex gap-1",children:[i("providers:update")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{d(N),c(!0)},title:"Bearbeiten",children:s.jsx(Je,{className:"w-3 h-3"})}),i("providers:delete")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Tarif wirklich löschen?")&&p.mutate(N.id)},title:"Löschen",children:s.jsx(ve,{className:"w-3 h-3 text-red-500"})})]})]},N.id)})}):s.jsx("p",{className:"text-sm text-gray-500",children:"Keine Tarife vorhanden."})]}),s.jsx(Rk,{isOpen:o,onClose:()=>{c(!1),d(null)},providerId:e.id,tariff:u})]})}function Lk({isOpen:e,onClose:t,provider:n}){const r=pe(),[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=W({mutationFn:Ra.create,onSuccess:()=>{r.invalidateQueries({queryKey:["providers"]}),t()},onError:d=>{alert(d.message)}}),o=W({mutationFn:d=>Ra.update(n.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["providers"]}),t()},onError:d=>{alert(d.message)}}),c=d=>{d.preventDefault(),n?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return s.jsx(ot,{isOpen:e,onClose:t,title:n?"Anbieter bearbeiten":"Neuer Anbieter",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(K,{label:"Anbietername *",value:a.name,onChange:d=>i({...a,name:d.target.value}),required:!0,placeholder:"z.B. Vodafone, E.ON, Allianz"}),s.jsx(K,{label:"Portal-URL (Login-Seite)",value:a.portalUrl,onChange:d=>i({...a,portalUrl:d.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(K,{label:"Benutzername-Feldname",value:a.usernameFieldName,onChange:d=>i({...a,usernameFieldName:d.target.value}),placeholder:"z.B. username, email, login"}),s.jsx(K,{label:"Passwort-Feldname",value:a.passwordFieldName,onChange:d=>i({...a,passwordFieldName:d.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:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}function Rk({isOpen:e,onClose:t,providerId:n,tariff:r}){const a=pe(),[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=W({mutationFn:h=>Ra.createTariff(n,h),onSuccess:()=>{a.invalidateQueries({queryKey:["providers"]}),t()},onError:h=>{alert(h.message)}}),c=W({mutationFn:h=>k0.update(r.id,h),onSuccess:()=>{a.invalidateQueries({queryKey:["providers"]}),t()},onError:h=>{alert(h.message)}}),u=h=>{h.preventDefault(),r?c.mutate(i):o.mutate(i)},d=o.isPending||c.isPending;return s.jsx(ot,{isOpen:e,onClose:t,title:r?"Tarif bearbeiten":"Neuer Tarif",children:s.jsxs("form",{onSubmit:u,className:"space-y-4",children:[s.jsx(K,{label:"Tarifname *",value:i.name,onChange:h=>l({...i,name:h.target.value}),required:!0,placeholder:"z.B. Comfort Plus, Basic 100"}),r&&s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:i.isActive,onChange:h=>l({...i,isActive:h.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}const Cd={Zap:s.jsx($m,{className:"w-5 h-5"}),Flame:s.jsx(L0,{className:"w-5 h-5"}),Wifi:s.jsx(fa,{className:"w-5 h-5"}),Cable:s.jsx(U2,{className:"w-5 h-5"}),Network:s.jsx(eS,{className:"w-5 h-5"}),Smartphone:s.jsx(Om,{className:"w-5 h-5"}),Tv:s.jsx(_0,{className:"w-5 h-5"}),Car:s.jsx(T0,{className:"w-5 h-5"}),FileText:s.jsx(at,{className:"w-5 h-5"})},Ok=[{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)"}],zk=[{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 _k(){const[e,t]=b.useState(!1),[n,r]=b.useState(null),[a,i]=b.useState(!1),{hasPermission:l}=Be(),o=pe(),{data:c,isLoading:u}=he({queryKey:["contract-categories",a],queryFn:()=>Vi.getAll(a)}),d=W({mutationFn:Vi.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(Ne,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Gs,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Vertragstypen"}),l("developer:access")&&s.jsxs(T,{onClick:()=>t(!0),children:[s.jsx(Re,{className:"w-4 h-4 mr-2"}),"Neuer Vertragstyp"]})]}),s.jsxs(X,{children:[s.jsx("div",{className:"mb-4",children:s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:m=>i(m.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),u?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(Q2,{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&&Cd[m.icon]?Cd[m.icon]:s.jsx(at,{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(ge,{variant:m.isActive?"success":"danger",children:m.isActive?"Aktiv":"Inaktiv"}),s.jsxs("span",{className:"text-sm text-gray-500",children:["(",((f=m._count)==null?void 0:f.contracts)||0," Verträge)"]})]}),s.jsxs("div",{className:"text-sm text-gray-500",children:["Code: ",s.jsx("span",{className:"font-mono",children:m.code})]})]}),s.jsxs("div",{className:"flex gap-2 ml-4",children:[l("developer:access")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>h(m),title:"Bearbeiten",children:s.jsx(Je,{className:"w-4 h-4"})}),l("developer:access")&&s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertragstyp wirklich löschen?")&&d.mutate(m.id)},title:"Löschen",children:s.jsx(ve,{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($k,{isOpen:e,onClose:p,category:n})]})}function $k({isOpen:e,onClose:t,category:n}){const r=pe(),[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=W({mutationFn:Vi.create,onSuccess:()=>{r.invalidateQueries({queryKey:["contract-categories"]}),t()},onError:d=>{alert(d.message)}}),o=W({mutationFn:d=>Vi.update(n.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["contract-categories"]}),t()},onError:d=>{alert(d.message)}}),c=d=>{d.preventDefault(),n?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return s.jsx(ot,{isOpen:e,onClose:t,title:n?"Vertragstyp bearbeiten":"Neuer Vertragstyp",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(K,{label:"Code (technisch) *",value:a.code,onChange:d=>i({...a,code:d.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")}),required:!0,placeholder:"z.B. ELECTRICITY, MOBILE_BUSINESS",disabled:!!n}),s.jsx(K,{label:"Anzeigename *",value:a.name,onChange:d=>i({...a,name:d.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:Ok.map(d=>s.jsxs("button",{type:"button",onClick:()=>i({...a,icon:d.value}),className:`p-3 border rounded-lg flex flex-col items-center gap-1 text-xs ${a.icon===d.value?"border-blue-500 bg-blue-50":"border-gray-200 hover:bg-gray-50"}`,children:[Cd[d.value],s.jsx("span",{className:"truncate w-full text-center",children:d.label.split(" ")[0]})]},d.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:zk.map(d=>s.jsx("button",{type:"button",onClick:()=>i({...a,color:d.value}),className:`w-8 h-8 rounded-full border-2 ${a.color===d.value?"border-gray-800 ring-2 ring-offset-2 ring-gray-400":"border-transparent"}`,style:{backgroundColor:d.value},title:d.label},d.value))})]}),s.jsx(K,{label:"Sortierung",type:"number",value:a.sortOrder,onChange:d=>i({...a,sortOrder:parseInt(d.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:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}const Uk=[{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 Bk(){const{settings:e,updateSettings:t}=D0();return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(Ne,{to:"/settings",className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:s.jsx(Gs,{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(X,{title:"Scroll-Verhalten",children:s.jsx("div",{className:"space-y-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Nach-oben-Button"}),s.jsx("p",{className:"text-sm text-gray-500",children:"Ab welcher Scroll-Position der Button unten rechts erscheinen soll"})]}),s.jsx("div",{className:"w-48",children:s.jsx(Le,{options:Uk,value:e.scrollToTopThreshold.toString(),onChange:n=>t({scrollToTopThreshold:parseFloat(n.target.value)})})})]})})})]})}function Kk(){const e=pe(),{data:t,isLoading:n}=he({queryKey:["app-settings"],queryFn:()=>Or.getAll()}),[r,a]=b.useState(!1);b.useEffect(()=>{t!=null&&t.data&&a(t.data.customerSupportTicketsEnabled==="true")},[t]);const i=W({mutationFn:o=>Or.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(Ne,{to:"/settings",className:"text-gray-500 hover:text-gray-700",children:s.jsx(Gs,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Rm,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Kundenportal"})]})]}),s.jsxs(X,{title:"Support-Anfragen",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Hi,{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 qk(){const e=pe(),{data:t,isLoading:n}=he({queryKey:["app-settings"],queryFn:()=>Or.getAll()}),[r,a]=b.useState("14"),[i,l]=b.useState("42"),[o,c]=b.useState("90"),[u,d]=b.useState(!1);b.useEffect(()=>{t!=null&&t.data&&(a(t.data.deadlineCriticalDays||"14"),l(t.data.deadlineWarningDays||"42"),c(t.data.deadlineOkDays||"90"),d(!1))},[t]);const h=W({mutationFn:f=>Or.update(f),onSuccess:()=>{e.invalidateQueries({queryKey:["app-settings"]}),e.invalidateQueries({queryKey:["contract-cockpit"]}),d(!1)}}),p=()=>{const f=parseInt(r),y=parseInt(i),N=parseInt(o);if(isNaN(f)||isNaN(y)||isNaN(N)){alert("Bitte gültige Zahlen eingeben");return}if(f>=y||y>=N){alert("Die Werte müssen aufsteigend sein: Kritisch < Warnung < OK");return}h.mutate({deadlineCriticalDays:r,deadlineWarningDays:i,deadlineOkDays:o})},m=(f,y)=>{f(y),d(!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(Ne,{to:"/settings",className:"text-gray-500 hover:text-gray-700",children:s.jsx(Gs,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(vn,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Fristenschwellen"})]})]}),s.jsxs(X,{title:"Farbkodierung für Fristen",children:[s.jsx("p",{className:"text-gray-600 mb-6",children:"Definiere, ab wann Vertragsfristen als kritisch (rot), Warnung (gelb) oder OK (grün) angezeigt werden sollen. Die Werte geben die Anzahl der Tage bis zur Frist an."}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center gap-4 p-4 bg-red-50 border border-red-200 rounded-lg",children:[s.jsx(un,{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(K,{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(nr,{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(K,{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(gs,{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(K,{type:"number",min:"1",value:o,onChange:f=>m(c,f.target.value),className:"w-24"}),s.jsx("span",{className:"text-green-700",children:"Tage"})]})]})]})]}),s.jsxs("div",{className:"mt-6 pt-4 border-t flex justify-between items-center",children:[s.jsx("p",{className:"text-sm text-gray-500",children:"Beispiel: Bei 14/42/90 Tagen wird eine Frist die in 10 Tagen abläuft rot, eine in 30 Tagen gelb, und eine in 60 Tagen grün markiert."}),s.jsx(T,{onClick:p,disabled:!u||h.isPending,children:h.isPending?"Speichere...":"Speichern"})]})]})]})}const Vk=[{value:"PLESK",label:"Plesk"},{value:"CPANEL",label:"cPanel"},{value:"DIRECTADMIN",label:"DirectAdmin"}],nx=[{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"}],su={name:"",type:"PLESK",apiUrl:"",apiKey:"",username:"",password:"",domain:"stressfrei-wechseln.de",defaultForwardEmail:"",imapEncryption:"SSL",smtpEncryption:"SSL",allowSelfSignedCerts:!1,isActive:!0,isDefault:!1};function Qk(){const e=Vt(),t=pe(),[n,r]=b.useState(!1),[a,i]=b.useState(null),[l,o]=b.useState(su),[c,u]=b.useState(!1),[d,h]=b.useState(null),[p,m]=b.useState(!1),[f,y]=b.useState({}),[N,v]=b.useState(null),{data:g,isLoading:x}=he({queryKey:["email-provider-configs"],queryFn:()=>sn.getConfigs()}),j=W({mutationFn:C=>sn.createConfig(C),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]}),A()}}),k=W({mutationFn:({id:C,data:w})=>sn.updateConfig(C,w),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]}),A()}}),F=W({mutationFn:C=>sn.deleteConfig(C),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]})}}),E=(g==null?void 0:g.data)||[],S=()=>{o(su),i(null),u(!1),h(null),r(!0)},P=C=>{o({name:C.name,type:C.type,apiUrl:C.apiUrl,apiKey:C.apiKey||"",username:C.username||"",password:"",domain:C.domain,defaultForwardEmail:C.defaultForwardEmail||"",imapEncryption:C.imapEncryption??"SSL",smtpEncryption:C.smtpEncryption??"SSL",allowSelfSignedCerts:C.allowSelfSignedCerts??!1,isActive:C.isActive,isDefault:C.isDefault}),i(C.id),u(!1),h(null),r(!0)},A=()=>{r(!1),i(null),o(su),u(!1),h(null)},_=async C=>{var w,R,Q;v(C.id),y(ee=>({...ee,[C.id]:null}));try{const ee=await sn.testConnection({id:C.id}),fe={success:((w=ee.data)==null?void 0:w.success)||!1,message:(R=ee.data)==null?void 0:R.message,error:(Q=ee.data)==null?void 0:Q.error};y(ue=>({...ue,[C.id]:fe}))}catch(ee){y(fe=>({...fe,[C.id]:{success:!1,error:ee instanceof Error?ee.message:"Unbekannter Fehler beim Testen"}}))}finally{v(null)}},L=async()=>{var C,w,R;if(!l.apiUrl||!l.domain){h({success:!1,error:"Bitte geben Sie API-URL und Domain ein."});return}m(!0),h(null);try{const Q=await sn.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:((C=Q.data)==null?void 0:C.success)||!1,message:(w=Q.data)==null?void 0:w.message,error:(R=Q.data)==null?void 0:R.error})}catch(Q){h({success:!1,error:Q instanceof Error?Q.message:"Unbekannter Fehler beim Verbindungstest"})}finally{m(!1)}},V=C=>{C.preventDefault();const w={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&&(w.password=l.password),a?k.mutate({id:a,data:w}):j.mutate(w)},q=(C,w)=>{confirm(`Möchten Sie den Provider "${w}" wirklich löschen?`)&&F.mutate(C)},O=C=>C.error?C.error:C.message?C.message:"Verbindung fehlgeschlagen";return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsxs(T,{variant:"ghost",onClick:()=>e("/settings"),children:[s.jsx(Gs,{className:"w-4 h-4 mr-2"}),"Zurück"]}),s.jsx("h1",{className:"text-2xl font-bold",children:"Email-Provisionierung"})]}),s.jsxs(X,{className:"mb-6",children:[s.jsx("p",{className:"text-gray-600 mb-4",children:'Hier konfigurieren Sie die automatische Erstellung von Stressfrei-Wechseln E-Mail-Adressen. Wenn beim Anlegen einer Stressfrei-Adresse die Option "Bei Provider anlegen" aktiviert ist, wird die E-Mail-Weiterleitung automatisch erstellt.'}),s.jsxs(T,{onClick:S,children:[s.jsx(Re,{className:"w-4 h-4 mr-2"}),"Provider hinzufügen"]})]}),x?s.jsx("div",{className:"text-center py-8",children:"Laden..."}):E.length===0?s.jsx(X,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Noch keine Email-Provider konfiguriert."})}):s.jsx("div",{className:"space-y-4",children:E.map(C=>{const w=f[C.id],R=N===C.id;return s.jsx(X,{children:s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h3",{className:"font-semibold text-lg",children:C.name}),s.jsx("span",{className:"px-2 py-1 text-xs rounded bg-blue-100 text-blue-800",children:C.type}),C.isDefault&&s.jsx("span",{className:"px-2 py-1 text-xs rounded bg-green-100 text-green-800",children:"Standard"}),!C.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:C.apiUrl})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Domain"}),s.jsx("dd",{children:C.domain})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Benutzer"}),s.jsx("dd",{children:C.username||"-"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-gray-500",children:"Standard-Weiterleitung"}),s.jsx("dd",{className:"truncate",children:C.defaultForwardEmail||"-"})]})]}),w&&s.jsx("div",{className:`mt-3 p-3 rounded-lg text-sm ${w.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:w.success?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Nd,{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(Fp,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),s.jsx("span",{children:O(w)})]})})]}),s.jsxs("div",{className:"flex gap-2 ml-4",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>_(C),disabled:R,title:"Verbindung testen",children:R?s.jsx("span",{className:"w-4 h-4 border-2 border-gray-400 border-t-transparent rounded-full animate-spin"}):s.jsx(fa,{className:"w-4 h-4 text-blue-500"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>P(C),children:s.jsx(Je,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>q(C.id,C.name),children:s.jsx(ve,{className:"w-4 h-4 text-red-500"})})]})]})},C.id)})}),n&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsx("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto",children:s.jsxs("div",{className:"p-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h2",{className:"text-xl font-semibold",children:a?"Provider bearbeiten":"Neuer Provider"}),s.jsx("button",{onClick:A,className:"text-gray-400 hover:text-gray-600",children:s.jsx(jn,{className:"w-5 h-5"})})]}),(j.error||k.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(jn,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),s.jsx("span",{children:j.error instanceof Error?j.error.message:k.error instanceof Error?k.error.message:"Fehler beim Speichern"})]})}),s.jsxs("form",{onSubmit:V,className:"space-y-4",children:[s.jsx(K,{label:"Name *",value:l.name,onChange:C=>o({...l,name:C.target.value}),placeholder:"z.B. Plesk Hauptserver",required:!0}),s.jsx(Le,{label:"Provider-Typ *",value:l.type,onChange:C=>o({...l,type:C.target.value}),options:Vk}),s.jsx(K,{label:"API-URL *",value:l.apiUrl,onChange:C=>o({...l,apiUrl:C.target.value}),placeholder:"https://server.de:8443",required:!0}),s.jsx(K,{label:"API-Key",value:l.apiKey,onChange:C=>o({...l,apiKey:C.target.value}),placeholder:"Optional - alternativ zu Benutzername/Passwort"}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(K,{label:"Benutzername",value:l.username,onChange:C=>o({...l,username:C.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:C=>o({...l,password:C.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:()=>u(!c),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:c?s.jsx(Et,{className:"w-4 h-4"}):s.jsx(De,{className:"w-4 h-4"})})]})]})]}),s.jsx(K,{label:"Domain *",value:l.domain,onChange:C=>o({...l,domain:C.target.value}),placeholder:"stressfrei-wechseln.de",required:!0}),s.jsx(K,{label:"Standard-Weiterleitungsadresse",value:l.defaultForwardEmail,onChange:C=>o({...l,defaultForwardEmail:C.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:C=>o({...l,imapEncryption:C.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:nx.map(C=>s.jsxs("option",{value:C.value,children:[C.label," - ",C.description]},C.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:C=>o({...l,smtpEncryption:C.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:nx.map(C=>s.jsxs("option",{value:C.value,children:[C.label," - ",C.description]},C.value))})]})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:l.allowSelfSignedCerts,onChange:C=>o({...l,allowSelfSignedCerts:C.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:C=>o({...l,isActive:C.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:C=>o({...l,isDefault:C.target.checked}),className:"rounded border-gray-300"}),s.jsx("span",{className:"text-sm",children:"Als Standard verwenden"})]})]}),s.jsxs("div",{className:"pt-4 border-t",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:L,disabled:p,className:"w-full",children:p?"Teste Verbindung...":s.jsxs(s.Fragment,{children:[s.jsx(fa,{className:"w-4 h-4 mr-2"}),"Verbindung testen"]})}),d&&s.jsx("div",{className:`mt-2 p-3 rounded-lg text-sm ${d.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:d.success?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Nd,{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(Fp,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),s.jsx("span",{children:O(d)})]})})]}),s.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:A,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:j.isPending||k.isPending,children:j.isPending||k.isPending?"Speichern...":"Speichern"})]})]})]})})})]})}function Hk(){const[e,t]=b.useState(null),[n,r]=b.useState(null),[a,i]=b.useState(!1),[l,o]=b.useState(""),[c,u]=b.useState(null),d=b.useRef(null),h=pe(),{logout:p}=Be(),{data:m,isLoading:f}=he({queryKey:["backups"],queryFn:()=>or.list()}),y=(m==null?void 0:m.data)||[],N=W({mutationFn:()=>or.create(),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]})}}),v=W({mutationFn:P=>or.restore(P),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),t(null)}}),g=W({mutationFn:P=>or.delete(P),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),r(null)}}),x=W({mutationFn:P=>or.upload(P),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),u(null),d.current&&(d.current.value="")},onError:P=>{u(P.message||"Upload fehlgeschlagen")}}),j=W({mutationFn:()=>or.factoryReset(),onSuccess:()=>{i(!1),o(""),p()}}),k=P=>{var _;const A=(_=P.target.files)==null?void 0:_[0];if(A){if(!A.name.endsWith(".zip")){u("Nur ZIP-Dateien sind erlaubt");return}u(null),x.mutate(A)}},F=async P=>{const A=localStorage.getItem("token"),_=or.getDownloadUrl(P);try{const L=await fetch(_,{headers:{Authorization:`Bearer ${A}`}});if(!L.ok)throw new Error("Download fehlgeschlagen");const V=await L.blob(),q=window.URL.createObjectURL(V),O=document.createElement("a");O.href=q,O.download=`opencrm-backup-${P}.zip`,document.body.appendChild(O),O.click(),document.body.removeChild(O),window.URL.revokeObjectURL(q)}catch(L){console.error("Download error:",L)}},E=P=>new Date(P).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}),S=P=>P<1024?`${P} B`:P<1024*1024?`${(P/1024).toFixed(1)} KB`:`${(P/(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(fc,{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:d,accept:".zip",onChange:k,className:"hidden"}),s.jsx(T,{variant:"secondary",onClick:()=>{var P;return(P=d.current)==null?void 0:P.click()},disabled:x.isPending,children:x.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Qr,{className:"w-4 h-4 mr-2 animate-spin"}),"Hochladen..."]}):s.jsxs(s.Fragment,{children:[s.jsx(wd,{className:"w-4 h-4 mr-2"}),"Backup hochladen"]})}),s.jsx(T,{onClick:()=>N.mutate(),disabled:N.isPending,children:N.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Qr,{className:"w-4 h-4 mr-2 animate-spin"}),"Wird erstellt..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ms,{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(Qr,{className:"w-6 h-6 animate-spin text-gray-400"})}):y.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Mp,{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:y.map(P=>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:P.name}),s.jsxs("span",{className:"text-sm text-gray-500 flex items-center gap-1",children:[s.jsx(vn,{className:"w-4 h-4"}),E(P.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(at,{className:"w-4 h-4"}),P.totalRecords.toLocaleString("de-DE")," Datensätze"]}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Mp,{className:"w-4 h-4"}),S(P.sizeBytes)]}),P.hasUploads&&s.jsxs("span",{className:"flex items-center gap-1 text-green-600",children:[s.jsx(V2,{className:"w-4 h-4"}),"Dokumente (",S(P.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 (",P.tables.filter(A=>A.count>0).length," mit Daten)"]}),s.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:P.tables.filter(A=>A.count>0).map(A=>s.jsxs("span",{className:"text-xs bg-gray-100 px-2 py-0.5 rounded",children:[A.table,": ",A.count]},A.table))})]})]}),s.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>F(P.name),title:"Als ZIP herunterladen",children:s.jsx(_2,{className:"w-4 h-4"})}),s.jsxs(T,{variant:"secondary",size:"sm",onClick:()=>t(P.name),disabled:v.isPending,children:[s.jsx(wd,{className:"w-4 h-4 mr-1"}),"Wiederherstellen"]}),s.jsx(T,{variant:"danger",size:"sm",onClick:()=>r(P.name),disabled:g.isPending,children:s.jsx(ve,{className:"w-4 h-4"})})]})]})},P.name))})]}),e&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Backup wiederherstellen?"}),s.jsxs("p",{className:"text-gray-600 mb-4",children:["Möchten Sie das Backup ",s.jsx("strong",{children:e})," wirklich wiederherstellen?"]}),s.jsxs("p",{className:"text-amber-600 text-sm mb-4 bg-amber-50 p-3 rounded-lg",children:[s.jsx("strong",{children:"Achtung:"})," Bestehende Daten und Dokumente werden mit dem Backup-Stand überschrieben. Dies kann nicht rückgängig gemacht werden."]}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>t(null),disabled:v.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"primary",onClick:()=>v.mutate(e),disabled:v.isPending,children:v.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Qr,{className:"w-4 h-4 mr-2 animate-spin"}),"Wird wiederhergestellt..."]}):"Ja, wiederherstellen"})]})]})}),n&&s.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Backup löschen?"}),s.jsxs("p",{className:"text-gray-600 mb-4",children:["Möchten Sie das Backup ",s.jsx("strong",{children:n})," wirklich löschen? Dies kann nicht rückgängig gemacht werden."]}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>r(null),disabled:g.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:()=>g.mutate(n),disabled:g.isPending,children:g.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(nr,{className:"w-6 h-6 text-red-600"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-red-800 mb-2",children:"Werkseinstellungen"}),s.jsxs("p",{className:"text-sm text-red-700 mb-4",children:["Setzt das System auf den Ausgangszustand zurück. ",s.jsx("strong",{children:"Alle Daten werden unwiderruflich gelöscht"})," - Kunden, Verträge, Benutzer, Dokumente und Einstellungen. Nur die hier gespeicherten Backups bleiben erhalten."]}),s.jsxs("ul",{className:"text-sm text-red-700 mb-4 list-disc list-inside space-y-1",children:[s.jsx("li",{children:"Alle Kunden und Verträge werden gelöscht"}),s.jsx("li",{children:"Alle Benutzer werden gelöscht"}),s.jsx("li",{children:"Alle hochgeladenen Dokumente werden gelöscht"}),s.jsx("li",{children:"Ein neuer Admin-Benutzer wird erstellt (admin@admin.com / admin)"}),s.jsxs("li",{children:[s.jsx("strong",{children:"Backups bleiben erhalten"})," und können danach wiederhergestellt werden"]})]}),s.jsxs(T,{variant:"danger",onClick:()=>i(!0),children:[s.jsx(sS,{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(nr,{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:P=>o(P.target.value),placeholder:"LÖSCHEN",className:"w-full px-3 py-2 border border-gray-300 rounded-lg mb-4 focus:ring-2 focus:ring-red-500 focus:border-red-500"}),s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsx(T,{variant:"secondary",onClick:()=>{i(!1),o("")},disabled:j.isPending,children:"Abbrechen"}),s.jsx(T,{variant:"danger",onClick:()=>j.mutate(),disabled:l!=="LÖSCHEN"||j.isPending,children:j.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Qr,{className:"w-4 h-4 mr-2 animate-spin"}),"Wird zurückgesetzt..."]}):"Ja, alles löschen"})]})]})})]})}function Wk(){var g;const[e,t]=b.useState(""),[n,r]=b.useState(1),[a,i]=b.useState(!1),[l,o]=b.useState(null),c=pe(),{refreshUser:u}=Be(),{data:d,isLoading:h}=he({queryKey:["users",e,n],queryFn:()=>vi.getAll({search:e||void 0,page:n,limit:20})}),{data:p}=he({queryKey:["roles"],queryFn:()=>vi.getRoles()}),m=W({mutationFn:vi.delete,onSuccess:()=>{c.invalidateQueries({queryKey:["users"]})},onError:x=>{alert((x==null?void 0:x.message)||"Fehler beim Löschen des Benutzers")}}),f=x=>{var j;return(j=x.roles)==null?void 0:j.some(k=>k.name==="Admin")},y=((g=d==null?void 0:d.data)==null?void 0:g.filter(x=>x.isActive&&f(x)).length)||0,N=x=>{o(x),i(!0)},v=()=>{i(!1),o(null)};return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsx(Ne,{to:"/settings",children:s.jsx(T,{variant:"ghost",size:"sm",children:s.jsx(Gs,{className:"w-4 h-4"})})}),s.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Benutzer"}),s.jsxs(T,{onClick:()=>i(!0),children:[s.jsx(Re,{className:"w-4 h-4 mr-2"}),"Neuer Benutzer"]})]}),s.jsx(X,{className:"mb-6",children:s.jsxs("div",{className:"flex gap-4",children:[s.jsx("div",{className:"flex-1",children:s.jsx(K,{placeholder:"Suchen...",value:e,onChange:x=>t(x.target.value)})}),s.jsx(T,{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(H2,{className:"w-5 h-5 text-blue-600 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm text-blue-800",children:[s.jsx("strong",{children:"Hinweis:"})," Bei Änderungen an Rollen oder Berechtigungen wird der betroffene Benutzer automatisch ausgeloggt und muss sich erneut anmelden."]})]}),s.jsx(X,{children:h?s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):d!=null&&d.data&&d.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:d.data.map(x=>{var j;return s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[s.jsxs("td",{className:"py-3 px-4",children:[x.firstName," ",x.lastName]}),s.jsx("td",{className:"py-3 px-4",children:x.email}),s.jsx("td",{className:"py-3 px-4",children:s.jsx("div",{className:"flex gap-1 flex-wrap",children:(j=x.roles)==null?void 0:j.filter(k=>k.name!=="Developer").map(k=>s.jsx(ge,{variant:"info",children:k.name},k.id||k.name))})}),s.jsx("td",{className:"py-3 px-4",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ge,{variant:x.isActive?"success":"danger",children:x.isActive?"Aktiv":"Inaktiv"}),x.hasDeveloperAccess&&s.jsxs(ge,{variant:"warning",className:"flex items-center gap-1",children:[s.jsx(hc,{className:"w-3 h-3"}),"Dev"]})]})}),s.jsx("td",{className:"py-3 px-4 text-right",children:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>N(x),children:s.jsx(Je,{className:"w-4 h-4"})}),(()=>{const k=f(x)&&x.isActive&&y<=1;return s.jsx(T,{variant:"ghost",size:"sm",disabled:k,title:k?"Letzter Administrator kann nicht gelöscht werden":void 0,onClick:()=>{confirm("Benutzer wirklich löschen?")&&m.mutate(x.id)},children:s.jsx(ve,{className:`w-4 h-4 ${k?"text-gray-300":"text-red-500"}`})})})()]})})]},x.id)})})]})}),d.pagination&&d.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 ",d.pagination.page," von ",d.pagination.totalPages]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>r(x=>Math.max(1,x-1)),disabled:n===1,children:"Zurück"}),s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>r(x=>x+1),disabled:n>=d.pagination.totalPages,children:"Weiter"})]})]})]}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Benutzer gefunden."})}),s.jsx(Gk,{isOpen:a,onClose:v,user:l,roles:(p==null?void 0:p.data)||[],onUserUpdated:u})]})}function Gk({isOpen:e,onClose:t,user:n,roles:r,onUserUpdated:a}){const i=pe(),[l,o]=b.useState(null),[c,u]=b.useState({email:"",password:"",firstName:"",lastName:"",roleIds:[],isActive:!0,hasDeveloperAccess:!1});b.useEffect(()=>{var y;e&&(o(null),u(n?{email:n.email,password:"",firstName:n.firstName,lastName:n.lastName,roleIds:((y=n.roles)==null?void 0:y.filter(N=>N.name!=="Developer").map(N=>N.id))||[],isActive:n.isActive??!0,hasDeveloperAccess:n.hasDeveloperAccess??!1}:{email:"",password:"",firstName:"",lastName:"",roleIds:[],isActive:!0,hasDeveloperAccess:!1}))},[e,n]);const d=W({mutationFn:vi.create,onSuccess:()=>{i.invalidateQueries({queryKey:["users"]}),t()},onError:y=>{o((y==null?void 0:y.message)||"Fehler beim Erstellen des Benutzers")}}),h=W({mutationFn:y=>vi.update(n.id,y),onSuccess:async()=>{i.invalidateQueries({queryKey:["users"]}),await a(),t()},onError:y=>{o((y==null?void 0:y.message)||"Fehler beim Aktualisieren des Benutzers")}}),p=y=>{if(y.preventDefault(),n){const N={email:c.email,firstName:c.firstName,lastName:c.lastName,roleIds:c.roleIds,isActive:c.isActive,hasDeveloperAccess:c.hasDeveloperAccess};c.password&&(N.password=c.password),h.mutate(N)}else d.mutate({email:c.email,password:c.password,firstName:c.firstName,lastName:c.lastName,roleIds:c.roleIds,hasDeveloperAccess:c.hasDeveloperAccess})},m=y=>{u(N=>({...N,roleIds:N.roleIds.includes(y)?N.roleIds.filter(v=>v!==y):[...N.roleIds,y]}))},f=d.isPending||h.isPending;return s.jsx(ot,{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(nr,{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(K,{label:"Vorname *",value:c.firstName,onChange:y=>u({...c,firstName:y.target.value}),required:!0}),s.jsx(K,{label:"Nachname *",value:c.lastName,onChange:y=>u({...c,lastName:y.target.value}),required:!0})]}),s.jsx(K,{label:"E-Mail *",type:"email",value:c.email,onChange:y=>u({...c,email:y.target.value}),required:!0}),s.jsx(K,{label:n?"Neues Passwort (leer = unverändert)":"Passwort *",type:"password",value:c.password,onChange:y=>u({...c,password:y.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(y=>y.name!=="Developer").map(y=>s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:c.roleIds.includes(y.id),onChange:()=>m(y.id),className:"rounded"}),s.jsx("span",{children:y.name}),y.description&&s.jsxs("span",{className:"text-sm text-gray-500",children:["(",y.description,")"]})]},y.id)),s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:c.hasDeveloperAccess,onChange:y=>u({...c,hasDeveloperAccess:y.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(hc,{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(nr,{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:y=>u({...c,isActive:y.target.checked}),className:"rounded"}),"Aktiv"]})}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(T,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),s.jsx(T,{type:"submit",disabled:f,children:f?"Speichern...":"Speichern"})]})]})})}function Zk(){const{hasPermission:e,developerMode:t,setDeveloperMode:n}=Be(),r=[{to:"/settings/users",icon:iS,title:"Benutzer",description:"Verwalten Sie Benutzerkonten, Rollen und Berechtigungen.",show:e("users:read")},{to:"/settings/platforms",icon:rS,title:"Vertriebsplattformen",description:"Verwalten Sie die Plattformen, über die Verträge abgeschlossen werden.",show:e("platforms:read")},{to:"/settings/cancellation-periods",icon:vn,title:"Kündigungsfristen",description:"Konfigurieren Sie die verfügbaren Kündigungsfristen für Verträge.",show:e("platforms:read")},{to:"/settings/contract-durations",icon:M0,title:"Vertragslaufzeiten",description:"Konfigurieren Sie die verfügbaren Laufzeiten für Verträge.",show:e("platforms:read")},{to:"/settings/providers",icon:$2,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:q2,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(z0,{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(Ne,{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(rs,{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(Ne,{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(Rm,{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(rs,{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(Ne,{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(vn,{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(rs,{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(Ne,{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(mn,{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(rs,{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(Ne,{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(fc,{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(rs,{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(Ne,{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(rs,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),s.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Passen Sie die Darstellung der Anwendung an."})]})]})})})]}),e("developer:access")&&s.jsxs(X,{title:"Entwickleroptionen",className:"mb-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(hc,{className:"w-5 h-5 text-gray-500"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Entwicklermodus"}),s.jsx("p",{className:"text-sm text-gray-500",children:"Aktiviert erweiterte Funktionen wie direkten Datenbankzugriff"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t,onChange:a=>n(a.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"})]})]}),t&&s.jsx("div",{className:"mt-4 p-3 bg-yellow-50 border border-yellow-200 rounded-lg",children:s.jsxs("p",{className:"text-sm text-yellow-800",children:[s.jsx("strong",{children:"Warnung:"})," Der Entwicklermodus ermöglicht direkten Zugriff auf die Datenbank. Unsachgemäße Änderungen können zu Datenverlust oder Inkonsistenzen führen."]})})]}),s.jsx(X,{title:"Über",children:s.jsxs("dl",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"Version"}),s.jsx("dd",{children:"1.0.0"})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-sm text-gray-500",children:"System"}),s.jsx("dd",{children:"OpenCRM"})]})]})})]})}function Jk({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,u]=b.useState({x:0,y:0}),[d,h]=b.useState({}),[p,m]=b.useState(null),{data:f,isLoading:y}=he({queryKey:["developer-schema"],queryFn:ci.getSchema}),N=(f==null?void 0:f.data)||[];b.useEffect(()=>{if(N.length>0&&Object.keys(d).length===0){const S=Math.ceil(Math.sqrt(N.length)),P={x:280,y:200},A={};N.forEach((_,L)=>{const V=L%S,q=Math.floor(L/S);A[_.name]={x:50+V*P.x,y:50+q*P.y}}),h(A)}},[N,d]);const v=b.useCallback(S=>{(S.target===S.currentTarget||S.target.tagName==="svg")&&(o(!0),u({x:S.clientX-a.x,y:S.clientY-a.y}))},[a]),g=b.useCallback(S=>{var P;if(l&&!p)i({x:S.clientX-c.x,y:S.clientY-c.y});else if(p){const A=(P=t.current)==null?void 0:P.getBoundingClientRect();A&&h(_=>({..._,[p]:{x:(S.clientX-A.left-a.x)/n-100,y:(S.clientY-A.top-a.y)/n-20}}))}},[l,p,c,a,n]),x=b.useCallback(()=>{o(!1),m(null)},[]),j=S=>{r(P=>Math.min(2,Math.max(.3,P+S)))},k=()=>{r(1),i({x:0,y:0})},F=b.useCallback(()=>{const S=[];return N.forEach(P=>{const A=d[P.name];A&&P.foreignKeys.forEach(_=>{const L=d[_.targetTable];if(!L)return;const V=N.find(O=>O.name===_.targetTable),q=V==null?void 0:V.relations.find(O=>O.targetTable===P.name);S.push({from:{table:P.name,x:A.x+100,y:A.y+60},to:{table:_.targetTable,x:L.x+100,y:L.y+60},type:(q==null?void 0:q.type)||"one",label:_.field})})}),S},[N,d]);if(y)return s.jsx("div",{className:"flex items-center justify-center h-full",children:"Laden..."});const E=F();return s.jsxs("div",{className:"relative h-full w-full bg-gray-50 overflow-hidden",ref:t,children:[s.jsxs("div",{className:"absolute top-4 right-4 z-10 flex gap-2 bg-white rounded-lg shadow-md p-2",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>j(.1),title:"Vergrößern",children:s.jsx(oS,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>j(-.1),title:"Verkleinern",children:s.jsx(cS,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:k,title:"Zurücksetzen",children:s.jsx(X2,{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(Y2,{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:v,onMouseMove:g,onMouseUp:x,onMouseLeave:x,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"})})]}),E.map((S,P)=>{const A=S.to.x-S.from.x,_=S.to.y-S.from.y,L=S.from.x+A/2,V=S.from.y+_/2,q=S.from.x+A*.25,O=S.from.y,C=S.from.x+A*.75,w=S.to.y;return s.jsxs("g",{children:[s.jsx("path",{d:`M ${S.from.x} ${S.from.y} C ${q} ${O}, ${C} ${w}, ${S.to.x} ${S.to.y}`,fill:"none",stroke:"#9ca3af",strokeWidth:"2",markerEnd:"url(#arrowhead)"}),s.jsx("text",{x:L,y:V-8,fontSize:"10",fill:"#6b7280",textAnchor:"middle",className:"select-none",children:S.type==="many"?"1:n":"1:1"})]},P)}),N.map(S=>{const P=d[S.name];if(!P)return null;const A=200,_=32,L=20,V=[...new Set([S.primaryKey,...S.foreignKeys.map(O=>O.field)])],q=_+Math.min(V.length,5)*L+8;return s.jsxs("g",{transform:`translate(${P.x}, ${P.y})`,style:{cursor:"move"},onMouseDown:O=>{O.stopPropagation(),m(S.name)},children:[s.jsx("rect",{x:"3",y:"3",width:A,height:q,rx:"6",fill:"rgba(0,0,0,0.1)"}),s.jsx("rect",{x:"0",y:"0",width:A,height:q,rx:"6",fill:"white",stroke:"#e5e7eb",strokeWidth:"1"}),s.jsx("rect",{x:"0",y:"0",width:A,height:_,rx:"6",fill:"#3b82f6",className:"cursor-pointer",onClick:()=>e==null?void 0:e(S.name)}),s.jsx("rect",{x:"0",y:_-6,width:A,height:"6",fill:"#3b82f6"}),s.jsx("text",{x:A/2,y:"21",fontSize:"13",fontWeight:"bold",fill:"white",textAnchor:"middle",className:"select-none pointer-events-none",children:S.name}),V.slice(0,5).map((O,C)=>{const w=O===S.primaryKey||S.primaryKey.includes(O),R=S.foreignKeys.some(Q=>Q.field===O);return s.jsx("g",{transform:`translate(8, ${_+4+C*L})`,children:s.jsxs("text",{x:"0",y:"14",fontSize:"11",fill:w?"#dc2626":R?"#2563eb":"#374151",fontFamily:"monospace",className:"select-none",children:[w&&"🔑 ",R&&!w&&"🔗 ",O]})},O)}),V.length>5&&s.jsxs("text",{x:A/2,y:q-4,fontSize:"10",fill:"#9ca3af",textAnchor:"middle",className:"select-none",children:["+",V.length-5," mehr..."]})]},S.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 Xk(){var E;const[e,t]=b.useState(null),[n,r]=b.useState(1),[a,i]=b.useState(null),[l,o]=b.useState(!1),c=pe(),{data:u,isLoading:d,error:h}=he({queryKey:["developer-schema"],queryFn:ci.getSchema});console.log("Schema data:",u),console.log("Schema error:",h);const{data:p,isLoading:m}=he({queryKey:["developer-table",e,n],queryFn:()=>ci.getTableData(e,n),enabled:!!e}),f=W({mutationFn:({tableName:S,id:P,data:A})=>ci.updateRow(S,P,A),onSuccess:()=>{c.invalidateQueries({queryKey:["developer-table",e]}),i(null)},onError:S=>{var P,A;alert(((A=(P=S.response)==null?void 0:P.data)==null?void 0:A.error)||"Fehler beim Speichern")}}),y=W({mutationFn:({tableName:S,id:P})=>ci.deleteRow(S,P),onSuccess:()=>{c.invalidateQueries({queryKey:["developer-table",e]})},onError:S=>{var P,A;alert(((A=(P=S.response)==null?void 0:P.data)==null?void 0:A.error)||"Fehler beim Löschen")}}),N=(u==null?void 0:u.data)||[],v=N.find(S=>S.name===e),g=(S,P)=>P.primaryKey.includes(",")?P.primaryKey.split(",").map(A=>S[A]).join("-"):String(S[P.primaryKey]),x=S=>S==null?"-":typeof S=="boolean"?S?"Ja":"Nein":typeof S=="object"?S instanceof Date||typeof S=="string"&&S.match(/^\d{4}-\d{2}-\d{2}/)?new Date(S).toLocaleString("de-DE"):JSON.stringify(S):String(S),j=()=>{!a||!e||f.mutate({tableName:e,id:a.id,data:a.data})},k=S=>{e&&confirm("Datensatz wirklich löschen?")&&y.mutate({tableName:e,id:S})};if(d)return s.jsx("div",{className:"text-center py-8",children:"Laden..."});const F=S=>{t(S),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(fc,{className:"w-6 h-6"}),s.jsx("h1",{className:"text-2xl font-bold",children:"Datenbankstruktur"})]}),s.jsxs(T,{onClick:()=>o(!0),children:[s.jsx(Ap,{className:"w-4 h-4 mr-2"}),"ER-Diagramm"]})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6",children:[s.jsx(X,{title:"Tabellen",className:"lg:col-span-1",children:s.jsx("div",{className:"space-y-1 max-h-[600px] overflow-y-auto",children:N.map(S=>s.jsxs("button",{onClick:()=>{t(S.name),r(1)},className:`w-full text-left px-3 py-2 rounded-lg flex items-center gap-2 transition-colors ${e===S.name?"bg-blue-100 text-blue-700":"hover:bg-gray-100"}`,children:[s.jsx(aS,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm font-mono",children:S.name})]},S.name))})}),s.jsx("div",{className:"lg:col-span-3 space-y-6",children:e&&v?s.jsxs(s.Fragment,{children:[s.jsxs(X,{title:`${e} - Beziehungen`,children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-gray-500 mb-2",children:"Fremdschlüssel (referenziert)"}),v.foreignKeys.length>0?s.jsx("div",{className:"space-y-1",children:v.foreignKeys.map(S=>s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"font-mono text-gray-600",children:S.field}),s.jsx(A0,{className:"w-4 h-4 text-gray-400"}),s.jsx(ge,{variant:"info",className:"cursor-pointer",onClick:()=>{t(S.targetTable),r(1)},children:S.targetTable})]},S.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)"}),v.relations.length>0?s.jsx("div",{className:"space-y-1",children:v.relations.map(S=>s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"font-mono text-gray-600",children:S.field}),s.jsx(ge,{variant:S.type==="many"?"warning":"default",children:S.type==="many"?"1:n":"1:1"}),s.jsx(ge,{variant:"info",className:"cursor-pointer",onClick:()=>{t(S.targetTable),r(1)},children:S.targetTable})]},S.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:v.primaryKey})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"Readonly:"})," ",s.jsx("span",{className:"font-mono text-red-600",children:v.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:v.requiredFields.join(", ")||"-"})]})]})})]}),s.jsx(X,{title:`${e} - Daten`,children:m?s.jsx("div",{className:"text-center py-4",children:"Laden..."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b bg-gray-50",children:[(p==null?void 0:p.data)&&p.data.length>0&&Object.keys(p.data[0]).map(S=>s.jsxs("th",{className:"text-left py-2 px-3 font-medium text-gray-600 whitespace-nowrap",children:[S,v.readonlyFields.includes(S)&&s.jsx("span",{className:"ml-1 text-red-400 text-xs",children:"*"}),v.requiredFields.includes(S)&&s.jsx("span",{className:"ml-1 text-green-400 text-xs",children:"!"})]},S)),s.jsx("th",{className:"text-right py-2 px-3 font-medium text-gray-600",children:"Aktionen"})]})}),s.jsxs("tbody",{children:[(E=p==null?void 0:p.data)==null?void 0:E.map(S=>{const P=g(S,v);return s.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[Object.entries(S).map(([A,_])=>s.jsx("td",{className:"py-2 px-3 font-mono text-xs max-w-[200px] truncate",children:x(_)},A)),s.jsx("td",{className:"py-2 px-3 text-right whitespace-nowrap",children:s.jsxs("div",{className:"flex justify-end gap-1",children:[s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>i({id:P,data:{...S}}),children:s.jsx(Je,{className:"w-4 h-4"})}),s.jsx(T,{variant:"ghost",size:"sm",onClick:()=>k(P),children:s.jsx(ve,{className:"w-4 h-4 text-red-500"})})]})})]},P)}),(!(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(T,{variant:"secondary",size:"sm",onClick:()=>r(S=>Math.max(1,S-1)),disabled:n===1,children:s.jsx(B2,{className:"w-4 h-4"})}),s.jsx(T,{variant:"secondary",size:"sm",onClick:()=>r(S=>S+1),disabled:n>=p.pagination.totalPages,children:s.jsx(rs,{className:"w-4 h-4"})})]})]})]})})]}):s.jsx(X,{children:s.jsx("div",{className:"text-center py-8 text-gray-500",children:"Wähle eine Tabelle aus der Liste aus"})})})]}),s.jsx(ot,{isOpen:!!a,onClose:()=>i(null),title:`${e} bearbeiten`,children:a&&v&&s.jsxs("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto",children:[Object.entries(a.data).map(([S,P])=>{const A=v.readonlyFields.includes(S),_=v.requiredFields.includes(S);return s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[S,A&&s.jsx("span",{className:"ml-1 text-red-400",children:"(readonly)"}),_&&s.jsx("span",{className:"ml-1 text-green-600",children:"*"})]}),A?s.jsx("div",{className:"px-3 py-2 bg-gray-100 rounded-lg font-mono text-sm",children:x(P)}):typeof P=="boolean"?s.jsxs("select",{value:String(a.data[S]),onChange:L=>i({...a,data:{...a.data,[S]:L.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 P=="number"?"number":"text",value:a.data[S]??"",onChange:L=>i({...a,data:{...a.data,[S]:typeof P=="number"?L.target.value?Number(L.target.value):null:L.target.value||null}}),className:"w-full px-3 py-2 border rounded-lg font-mono text-sm",disabled:A})]},S)}),s.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[s.jsxs(T,{variant:"secondary",onClick:()=>i(null),children:[s.jsx(jn,{className:"w-4 h-4 mr-2"}),"Abbrechen"]}),s.jsxs(T,{onClick:j,disabled:f.isPending,children:[s.jsx(nS,{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(Ap,{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(jn,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 overflow-hidden",children:s.jsx(Jk,{onSelectTable:F})})]})]})]})}function Yk({children:e}){const{isAuthenticated:t,isLoading:n}=Be();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(ia,{to:"/login",replace:!0})}function eC({children:e}){const{hasPermission:t,developerMode:n}=Be();return!t("developer:access")||!n?s.jsx(ia,{to:"/",replace:!0}):s.jsx(s.Fragment,{children:e})}function tC(){const{isAuthenticated:e,isLoading:t}=Be();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(L2,{}),s.jsxs(vN,{children:[s.jsx(Te,{path:"/login",element:e?s.jsx(ia,{to:"/",replace:!0}):s.jsx(hS,{})}),s.jsxs(Te,{path:"/",element:s.jsx(Yk,{children:s.jsx(mS,{})}),children:[s.jsx(Te,{index:!0,element:s.jsx(fS,{})}),s.jsx(Te,{path:"customers",element:s.jsx(xS,{})}),s.jsx(Te,{path:"customers/new",element:s.jsx(Xp,{})}),s.jsx(Te,{path:"customers/:id",element:s.jsx(wS,{})}),s.jsx(Te,{path:"customers/:id/edit",element:s.jsx(Xp,{})}),s.jsx(Te,{path:"contracts",element:s.jsx(rk,{})}),s.jsx(Te,{path:"contracts/cockpit",element:s.jsx(Nk,{})}),s.jsx(Te,{path:"contracts/new",element:s.jsx(tx,{})}),s.jsx(Te,{path:"contracts/:id",element:s.jsx(fk,{})}),s.jsx(Te,{path:"contracts/:id/edit",element:s.jsx(tx,{})}),s.jsx(Te,{path:"tasks",element:s.jsx(Sk,{})}),s.jsx(Te,{path:"settings",element:s.jsx(Zk,{})}),s.jsx(Te,{path:"settings/users",element:s.jsx(Wk,{})}),s.jsx(Te,{path:"settings/platforms",element:s.jsx(Ek,{})}),s.jsx(Te,{path:"settings/cancellation-periods",element:s.jsx(Pk,{})}),s.jsx(Te,{path:"settings/contract-durations",element:s.jsx(Mk,{})}),s.jsx(Te,{path:"settings/providers",element:s.jsx(Fk,{})}),s.jsx(Te,{path:"settings/contract-categories",element:s.jsx(_k,{})}),s.jsx(Te,{path:"settings/view",element:s.jsx(Bk,{})}),s.jsx(Te,{path:"settings/portal",element:s.jsx(Kk,{})}),s.jsx(Te,{path:"settings/deadlines",element:s.jsx(qk,{})}),s.jsx(Te,{path:"settings/email-providers",element:s.jsx(Qk,{})}),s.jsx(Te,{path:"settings/database-backup",element:s.jsx(Hk,{})}),s.jsx(Te,{path:"users",element:s.jsx(ia,{to:"/settings/users",replace:!0})}),s.jsx(Te,{path:"platforms",element:s.jsx(ia,{to:"/settings/platforms",replace:!0})}),s.jsx(Te,{path:"developer/database",element:s.jsx(eC,{children:s.jsx(Xk,{})})})]}),s.jsx(Te,{path:"*",element:s.jsx(ia,{to:"/",replace:!0})})]})]})}const sC=new nw({defaultOptions:{queries:{retry:1,staleTime:0,gcTime:0,refetchOnMount:"always"}}});nu.createRoot(document.getElementById("root")).render(s.jsx(Ct.StrictMode,{children:s.jsx(rw,{client:sC,children:s.jsx(DN,{children:s.jsx(I2,{children:s.jsxs(F2,{children:[s.jsx(tC,{}),s.jsx(n1,{position:"top-right",toastOptions:{duration:4e3,style:{background:"#363636",color:"#fff"},success:{iconTheme:{primary:"#10b981",secondary:"#fff"}},error:{iconTheme:{primary:"#ef4444",secondary:"#fff"}}}})]})})})})}));
|