(function(){const h=document.createElement("link").relList;if(h&&h.supports&&h.supports("modulepreload"))return;for(const P of document.querySelectorAll('link[rel="modulepreload"]'))D(P);new MutationObserver(P=>{for(const z of P)if(z.type==="childList")for(const K of z.addedNodes)K.tagName==="LINK"&&K.rel==="modulepreload"&&D(K)}).observe(document,{childList:!0,subtree:!0});function p(P){const z={};return P.integrity&&(z.integrity=P.integrity),P.referrerPolicy&&(z.referrerPolicy=P.referrerPolicy),P.crossOrigin==="use-credentials"?z.credentials="include":P.crossOrigin==="anonymous"?z.credentials="omit":z.credentials="same-origin",z}function D(P){if(P.ep)return;P.ep=!0;const z=p(P);fetch(P.href,z)}})();function Ic(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Pi={exports:{}},Bs={},Ri={exports:{}},me={};var uc;function hf(){if(uc)return me;uc=1;var i=Symbol.for("react.element"),h=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),D=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),z=Symbol.for("react.provider"),K=Symbol.for("react.context"),ee=Symbol.for("react.forward_ref"),U=Symbol.for("react.suspense"),M=Symbol.for("react.memo"),G=Symbol.for("react.lazy"),L=Symbol.iterator;function H(d){return d===null||typeof d!="object"?null:(d=L&&d[L]||d["@@iterator"],typeof d=="function"?d:null)}var re={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Ee=Object.assign,te={};function se(d,j,J){this.props=d,this.context=j,this.refs=te,this.updater=J||re}se.prototype.isReactComponent={},se.prototype.setState=function(d,j){if(typeof d!="object"&&typeof d!="function"&&d!=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,d,j,"setState")},se.prototype.forceUpdate=function(d){this.updater.enqueueForceUpdate(this,d,"forceUpdate")};function b(){}b.prototype=se.prototype;function oe(d,j,J){this.props=d,this.context=j,this.refs=te,this.updater=J||re}var Se=oe.prototype=new b;Se.constructor=oe,Ee(Se,se.prototype),Se.isPureReactComponent=!0;var le=Array.isArray,Ce=Object.prototype.hasOwnProperty,Ae={current:null},$e={key:!0,ref:!0,__self:!0,__source:!0};function Qe(d,j,J){var ae,ue={},ce=null,ve=null;if(j!=null)for(ae in j.ref!==void 0&&(ve=j.ref),j.key!==void 0&&(ce=""+j.key),j)Ce.call(j,ae)&&!$e.hasOwnProperty(ae)&&(ue[ae]=j[ae]);var he=arguments.length-2;if(he===1)ue.children=J;else if(1>>1,j=T[d];if(0>>1;dP(ue,A))ceP(ve,ue)?(T[d]=ve,T[ce]=A,d=ce):(T[d]=ue,T[ae]=A,d=ae);else if(ceP(ve,A))T[d]=ve,T[ce]=A,d=ce;else break e}}return Q}function P(T,Q){var A=T.sortIndex-Q.sortIndex;return A!==0?A:T.id-Q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var z=performance;i.unstable_now=function(){return z.now()}}else{var K=Date,ee=K.now();i.unstable_now=function(){return K.now()-ee}}var U=[],M=[],G=1,L=null,H=3,re=!1,Ee=!1,te=!1,se=typeof setTimeout=="function"?setTimeout:null,b=typeof clearTimeout=="function"?clearTimeout:null,oe=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function Se(T){for(var Q=p(M);Q!==null;){if(Q.callback===null)D(M);else if(Q.startTime<=T)D(M),Q.sortIndex=Q.expirationTime,h(U,Q);else break;Q=p(M)}}function le(T){if(te=!1,Se(T),!Ee)if(p(U)!==null)Ee=!0,Ne(Ce);else{var Q=p(M);Q!==null&&fe(le,Q.startTime-T)}}function Ce(T,Q){Ee=!1,te&&(te=!1,b(Qe),Qe=-1),re=!0;var A=H;try{for(Se(Q),L=p(U);L!==null&&(!(L.expirationTime>Q)||T&&!at());){var d=L.callback;if(typeof d=="function"){L.callback=null,H=L.priorityLevel;var j=d(L.expirationTime<=Q);Q=i.unstable_now(),typeof j=="function"?L.callback=j:L===p(U)&&D(U),Se(Q)}else D(U);L=p(U)}if(L!==null)var J=!0;else{var ae=p(M);ae!==null&&fe(le,ae.startTime-Q),J=!1}return J}finally{L=null,H=A,re=!1}}var Ae=!1,$e=null,Qe=-1,Ze=5,it=-1;function at(){return!(i.unstable_now()-itT||125d?(T.sortIndex=A,h(M,T),p(U)===null&&T===p(M)&&(te?(b(Qe),Qe=-1):te=!0,fe(le,A-d))):(T.sortIndex=j,h(U,T),Ee||re||(Ee=!0,Ne(Ce))),T},i.unstable_shouldYield=at,i.unstable_wrapCallback=function(T){var Q=H;return function(){var A=H;H=Q;try{return T.apply(this,arguments)}finally{H=A}}}})(Li)),Li}var mc;function _f(){return mc||(mc=1,Mi.exports=xf()),Mi.exports}var hc;function Sf(){if(hc)return wt;hc=1;var i=Ui(),h=_f();function p(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),U=Object.prototype.hasOwnProperty,M=/^[: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]*$/,G={},L={};function H(e){return U.call(L,e)?!0:U.call(G,e)?!1:M.test(e)?L[e]=!0:(G[e]=!0,!1)}function re(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 Ee(e,t,n,r){if(t===null||typeof t>"u"||re(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 te(e,t,n,r,s,l,u){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=l,this.removeEmptyString=u}var se={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){se[e]=new te(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];se[t]=new te(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){se[e]=new te(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){se[e]=new te(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){se[e]=new te(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){se[e]=new te(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){se[e]=new te(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){se[e]=new te(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){se[e]=new te(e,5,!1,e.toLowerCase(),null,!1,!1)});var b=/[\-:]([a-z])/g;function oe(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(b,oe);se[t]=new te(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(b,oe);se[t]=new te(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(b,oe);se[t]=new te(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){se[e]=new te(e,1,!1,e.toLowerCase(),null,!1,!1)}),se.xlinkHref=new te("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){se[e]=new te(e,1,!1,e.toLowerCase(),null,!0,!0)});function Se(e,t,n,r){var s=se.hasOwnProperty(t)?se[t]:null;(s!==null?s.type!==0:r||!(2c||s[u]!==l[c]){var f=` `+s[u].replace(" at new "," at ");return e.displayName&&f.includes("")&&(f=f.replace("",e.displayName)),f}while(1<=u&&0<=c);break}}}finally{J=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?j(e):""}function ue(e){switch(e.tag){case 5:return j(e.type);case 16:return j("Lazy");case 13:return j("Suspense");case 19:return j("SuspenseList");case 0:case 2:case 15:return e=ae(e.type,!1),e;case 11:return e=ae(e.type.render,!1),e;case 1:return e=ae(e.type,!0),e;default:return""}}function ce(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 $e:return"Fragment";case Ae:return"Portal";case Ze:return"Profiler";case Qe:return"StrictMode";case We:return"Suspense";case be:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case at:return(e.displayName||"Context")+".Consumer";case it:return(e._context.displayName||"Context")+".Provider";case mt:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ge:return t=e.displayName||null,t!==null?t:ce(e.type)||"Memo";case Ne:t=e._payload,e=e._init;try{return ce(e(t))}catch{}}return null}function ve(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 ce(t);case 8:return t===Qe?"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 he(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Z(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function we(e){var t=Z(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 s=n.get,l=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(u){r=""+u,l.call(this,u)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(u){r=""+u},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function jt(e){e._valueTracker||(e._valueTracker=we(e))}function kn(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Z(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function an(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 un(e,t){var n=t.checked;return A({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Un(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=he(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 Lt(e,t){t=t.checked,t!=null&&Se(e,"checked",t,!1)}function It(e,t){Lt(e,t);var n=he(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")?Jt(e,t.type,n):t.hasOwnProperty("defaultValue")&&Jt(e,t.type,he(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Cn(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 Jt(e,t,n){(t!=="number"||an(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var kt=Array.isArray;function At(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=Ot.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ct(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Xt={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},Fe=["Webkit","ms","Moz","O"];Object.keys(Xt).forEach(function(e){Fe.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Xt[t]=Xt[e]})});function fn(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Xt.hasOwnProperty(e)&&Xt[e]?(""+t).trim():t+"px"}function pn(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=fn(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var Or=A({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 zt(e,t){if(t){if(Or[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(p(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(p(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(p(61))}if(t.style!=null&&typeof t.style!="object")throw Error(p(62))}}function mn(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 $t=null;function hn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var gn=null,Zt=null,ht=null;function hr(e){if(e=Ns(e)){if(typeof gn!="function")throw Error(p(280));var t=e.stateNode;t&&(t=oo(t),gn(e.stateNode,e.type,t))}}function en(e){Zt?ht?ht.push(e):ht=[e]:Zt=e}function Qn(){if(Zt){var e=Zt,t=ht;if(ht=Zt=null,hr(e),t)for(e=0;e>>=0,e===0?32:31-(Ur(e)/Yo|0)|0}var Sr=64,wr=4194304;function qn(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 a(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,l=e.pingedLanes,u=n&268435455;if(u!==0){var c=u&~s;c!==0?r=qn(c):(l&=u,l!==0&&(r=qn(l)))}else u=n&~s,u!==0?r=qn(u):l!==0&&(r=qn(l));if(r===0)return 0;if(t!==0&&t!==r&&(t&s)===0&&(s=r&-r,l=t&-t,s>=l||s===16&&(l&4194240)!==0))return t;if((r&4)!==0&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Vt(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-pe(t),e[t]=n}function Gn(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=vs),na=" ",ra=!1;function sa(e,t){switch(e){case"keyup":return ud.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function oa(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Vr=!1;function dd(e,t){switch(e){case"compositionend":return oa(t);case"keypress":return t.which!==32?null:(ra=!0,na);case"textInput":return e=t.data,e===na&&ra?null:e;default:return null}}function fd(e,t){if(Vr)return e==="compositionend"||!al&&sa(e,t)?(e=Ji(),Gs=nl=Zn=null,Vr=!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)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=fa(n)}}function ma(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ma(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ha(){for(var e=window,t=an();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=an(e.document)}return t}function dl(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 Sd(e){var t=ha(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&ma(n.ownerDocument.documentElement,n)){if(r!==null&&dl(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 s=n.textContent.length,l=Math.min(r.start,s);r=r.end===void 0?l:Math.min(r.end,s),!e.extend&&l>r&&(s=r,r=l,l=s),s=pa(n,l);var u=pa(n,r);s&&u&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==u.node||e.focusOffset!==u.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),l>r?(e.addRange(t),e.extend(u.node,u.offset)):(t.setEnd(u.node,u.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=document.documentMode,Qr=null,fl=null,Ss=null,pl=!1;function ga(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;pl||Qr==null||Qr!==an(r)||(r=Qr,"selectionStart"in r&&dl(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}),Ss&&_s(Ss,r)||(Ss=r,r=no(fl,"onSelect"),0br||(e.current=Cl[br],Cl[br]=null,br--)}function Te(e,t){br++,Cl[br]=e.current,e.current=t}var rr={},nt=nr(rr),vt=nr(!1),Cr=rr;function Jr(e,t){var n=e.type.contextTypes;if(!n)return rr;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},l;for(l in n)s[l]=t[l];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function yt(e){return e=e.childContextTypes,e!=null}function lo(){Ie(vt),Ie(nt)}function Ma(e,t,n){if(nt.current!==rr)throw Error(p(168));Te(nt,t),Te(vt,n)}function La(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(p(108,ve(e)||"Unknown",s));return A({},n,r)}function io(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||rr,Cr=nt.current,Te(nt,e),Te(vt,vt.current),!0}function Ia(e,t,n){var r=e.stateNode;if(!r)throw Error(p(169));n?(e=La(e,t,Cr),r.__reactInternalMemoizedMergedChildContext=e,Ie(vt),Ie(nt),Te(nt,e)):Ie(vt),Te(vt,n)}var Ln=null,ao=!1,Nl=!1;function Aa(e){Ln===null?Ln=[e]:Ln.push(e)}function Id(e){ao=!0,Aa(e)}function sr(){if(!Nl&&Ln!==null){Nl=!0;var e=0,t=ke;try{var n=Ln;for(ke=1;e>=u,s-=u,In=1<<32-pe(t)+s|n<ne?(Xe=X,X=null):Xe=X.sibling;var xe=k(y,X,x[ne],R);if(xe===null){X===null&&(X=Xe);break}e&&X&&xe.alternate===null&&t(y,X),m=l(xe,m,ne),Y===null?W=xe:Y.sibling=xe,Y=xe,X=Xe}if(ne===x.length)return n(y,X),De&&Er(y,ne),W;if(X===null){for(;nene?(Xe=X,X=null):Xe=X.sibling;var pr=k(y,X,xe.value,R);if(pr===null){X===null&&(X=Xe);break}e&&X&&pr.alternate===null&&t(y,X),m=l(pr,m,ne),Y===null?W=pr:Y.sibling=pr,Y=pr,X=Xe}if(xe.done)return n(y,X),De&&Er(y,ne),W;if(X===null){for(;!xe.done;ne++,xe=x.next())xe=E(y,xe.value,R),xe!==null&&(m=l(xe,m,ne),Y===null?W=xe:Y.sibling=xe,Y=xe);return De&&Er(y,ne),W}for(X=r(y,X);!xe.done;ne++,xe=x.next())xe=$(X,y,ne,xe.value,R),xe!==null&&(e&&xe.alternate!==null&&X.delete(xe.key===null?ne:xe.key),m=l(xe,m,ne),Y===null?W=xe:Y.sibling=xe,Y=xe);return e&&X.forEach(function(mf){return t(y,mf)}),De&&Er(y,ne),W}function He(y,m,x,R){if(typeof x=="object"&&x!==null&&x.type===$e&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case Ce:e:{for(var W=x.key,Y=m;Y!==null;){if(Y.key===W){if(W=x.type,W===$e){if(Y.tag===7){n(y,Y.sibling),m=s(Y,x.props.children),m.return=y,y=m;break e}}else if(Y.elementType===W||typeof W=="object"&&W!==null&&W.$$typeof===Ne&&Ua(W)===Y.type){n(y,Y.sibling),m=s(Y,x.props),m.ref=Es(y,Y,x),m.return=y,y=m;break e}n(y,Y);break}else t(y,Y);Y=Y.sibling}x.type===$e?(m=Dr(x.props.children,y.mode,R,x.key),m.return=y,y=m):(R=zo(x.type,x.key,x.props,null,y.mode,R),R.ref=Es(y,m,x),R.return=y,y=R)}return u(y);case Ae:e:{for(Y=x.key;m!==null;){if(m.key===Y)if(m.tag===4&&m.stateNode.containerInfo===x.containerInfo&&m.stateNode.implementation===x.implementation){n(y,m.sibling),m=s(m,x.children||[]),m.return=y,y=m;break e}else{n(y,m);break}else t(y,m);m=m.sibling}m=ji(x,y.mode,R),m.return=y,y=m}return u(y);case Ne:return Y=x._init,He(y,m,Y(x._payload),R)}if(kt(x))return B(y,m,x,R);if(Q(x))return V(y,m,x,R);po(y,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,m!==null&&m.tag===6?(n(y,m.sibling),m=s(m,x),m.return=y,y=m):(n(y,m),m=wi(x,y.mode,R),m.return=y,y=m),u(y)):n(y,m)}return He}var es=Ba(!0),Ha=Ba(!1),mo=nr(null),ho=null,ts=null,Ll=null;function Il(){Ll=ts=ho=null}function Al(e){var t=mo.current;Ie(mo),e._currentValue=t}function Dl(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 ns(e,t){ho=e,Ll=ts=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(xt=!0),e.firstContext=null)}function Kt(e){var t=e._currentValue;if(Ll!==e)if(e={context:e,memoizedValue:t,next:null},ts===null){if(ho===null)throw Error(p(308));ts=e,ho.dependencies={lanes:0,firstContext:e}}else ts=ts.next=e;return t}var Pr=null;function Ol(e){Pr===null?Pr=[e]:Pr.push(e)}function Va(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Ol(t)):(n.next=s.next,s.next=n),t.interleaved=n,Dn(e,r)}function Dn(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 or=!1;function zl(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Qa(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 On(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function lr(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(ye&2)!==0){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Dn(e,n)}return s=r.interleaved,s===null?(t.next=t,Ol(r)):(t.next=s.next,s.next=t),r.interleaved=t,Dn(e,n)}function go(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,jr(e,n)}}function Wa(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,l=null;if(n=n.firstBaseUpdate,n!==null){do{var u={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};l===null?s=l=u:l=l.next=u,n=n.next}while(n!==null);l===null?s=l=t:l=l.next=t}else s=l=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:l,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 vo(e,t,n,r){var s=e.updateQueue;or=!1;var l=s.firstBaseUpdate,u=s.lastBaseUpdate,c=s.shared.pending;if(c!==null){s.shared.pending=null;var f=c,_=f.next;f.next=null,u===null?l=_:u.next=_,u=f;var C=e.alternate;C!==null&&(C=C.updateQueue,c=C.lastBaseUpdate,c!==u&&(c===null?C.firstBaseUpdate=_:c.next=_,C.lastBaseUpdate=f))}if(l!==null){var E=s.baseState;u=0,C=_=f=null,c=l;do{var k=c.lane,$=c.eventTime;if((r&k)===k){C!==null&&(C=C.next={eventTime:$,lane:0,tag:c.tag,payload:c.payload,callback:c.callback,next:null});e:{var B=e,V=c;switch(k=t,$=n,V.tag){case 1:if(B=V.payload,typeof B=="function"){E=B.call($,E,k);break e}E=B;break e;case 3:B.flags=B.flags&-65537|128;case 0:if(B=V.payload,k=typeof B=="function"?B.call($,E,k):B,k==null)break e;E=A({},E,k);break e;case 2:or=!0}}c.callback!==null&&c.lane!==0&&(e.flags|=64,k=s.effects,k===null?s.effects=[c]:k.push(c))}else $={eventTime:$,lane:k,tag:c.tag,payload:c.payload,callback:c.callback,next:null},C===null?(_=C=$,f=E):C=C.next=$,u|=k;if(c=c.next,c===null){if(c=s.shared.pending,c===null)break;k=c,c=k.next,k.next=null,s.lastBaseUpdate=k,s.shared.pending=null}}while(!0);if(C===null&&(f=E),s.baseState=f,s.firstBaseUpdate=_,s.lastBaseUpdate=C,t=s.shared.interleaved,t!==null){s=t;do u|=s.lane,s=s.next;while(s!==t)}else l===null&&(s.shared.lanes=0);Mr|=u,e.lanes=u,e.memoizedState=E}}function Ka(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Hl.transition;Hl.transition={};try{e(!1),t()}finally{ke=n,Hl.transition=r}}function du(){return qt().memoizedState}function zd(e,t,n){var r=cr(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},fu(e))pu(t,n);else if(n=Va(e,t,n,r),n!==null){var s=pt();ln(n,e,r,s),mu(n,t,r)}}function $d(e,t,n){var r=cr(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(fu(e))pu(t,s);else{var l=e.alternate;if(e.lanes===0&&(l===null||l.lanes===0)&&(l=t.lastRenderedReducer,l!==null))try{var u=t.lastRenderedState,c=l(u,n);if(s.hasEagerState=!0,s.eagerState=c,tn(c,u)){var f=t.interleaved;f===null?(s.next=s,Ol(t)):(s.next=f.next,f.next=s),t.interleaved=s;return}}catch{}n=Va(e,t,s,r),n!==null&&(s=pt(),ln(n,e,r,s),mu(n,t,r))}}function fu(e){var t=e.alternate;return e===ze||t!==null&&t===ze}function pu(e,t){Ms=_o=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function mu(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,jr(e,n)}}var jo={readContext:Kt,useCallback:rt,useContext:rt,useEffect:rt,useImperativeHandle:rt,useInsertionEffect:rt,useLayoutEffect:rt,useMemo:rt,useReducer:rt,useRef:rt,useState:rt,useDebugValue:rt,useDeferredValue:rt,useTransition:rt,useMutableSource:rt,useSyncExternalStore:rt,useId:rt,unstable_isNewReconciler:!1},Fd={readContext:Kt,useCallback:function(e,t){return Sn().memoizedState=[e,t===void 0?null:t],e},useContext:Kt,useEffect:ru,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,So(4194308,4,lu.bind(null,t,e),n)},useLayoutEffect:function(e,t){return So(4194308,4,e,t)},useInsertionEffect:function(e,t){return So(4,2,e,t)},useMemo:function(e,t){var n=Sn();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Sn();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=zd.bind(null,ze,e),[r.memoizedState,e]},useRef:function(e){var t=Sn();return e={current:e},t.memoizedState=e},useState:tu,useDebugValue:bl,useDeferredValue:function(e){return Sn().memoizedState=e},useTransition:function(){var e=tu(!1),t=e[0];return e=Od.bind(null,e[1]),Sn().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ze,s=Sn();if(De){if(n===void 0)throw Error(p(407));n=n()}else{if(n=t(),Ye===null)throw Error(p(349));(Tr&30)!==0||Ja(r,t,n)}s.memoizedState=n;var l={value:n,getSnapshot:t};return s.queue=l,ru(Xa.bind(null,r,l,e),[e]),r.flags|=2048,As(9,Ya.bind(null,r,l,n,t),void 0,null),n},useId:function(){var e=Sn(),t=Ye.identifierPrefix;if(De){var n=An,r=In;n=(r&~(1<<32-pe(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Ls++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=u.createElement(n,{is:r.is}):(e=u.createElement(n),n==="select"&&(u=e,r.multiple?u.multiple=!0:r.size&&(u.size=r.size))):e=u.createElementNS(e,n),e[xn]=t,e[Cs]=r,Au(e,t,!1,!1),t.stateNode=e;e:{switch(u=mn(n,r),n){case"dialog":Le("cancel",e),Le("close",e),s=r;break;case"iframe":case"object":case"embed":Le("load",e),s=r;break;case"video":case"audio":for(s=0;sis&&(t.flags|=128,r=!0,Ds(l,!1),t.lanes=4194304)}else{if(!r)if(e=yo(u),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Ds(l,!0),l.tail===null&&l.tailMode==="hidden"&&!u.alternate&&!De)return st(t),null}else 2*_e()-l.renderingStartTime>is&&n!==1073741824&&(t.flags|=128,r=!0,Ds(l,!1),t.lanes=4194304);l.isBackwards?(u.sibling=t.child,t.child=u):(n=l.last,n!==null?n.sibling=u:t.child=u,l.last=u)}return l.tail!==null?(t=l.tail,l.rendering=t,l.tail=t.sibling,l.renderingStartTime=_e(),t.sibling=null,n=Oe.current,Te(Oe,r?n&1|2:n&1),t):(st(t),null);case 22:case 23:return xi(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(Tt&1073741824)!==0&&(st(t),t.subtreeFlags&6&&(t.flags|=8192)):st(t),null;case 24:return null;case 25:return null}throw Error(p(156,t.tag))}function qd(e,t){switch(Pl(t),t.tag){case 1:return yt(t.type)&&lo(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return rs(),Ie(vt),Ie(nt),Bl(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return Fl(t),null;case 13:if(Ie(Oe),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(p(340));Zr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ie(Oe),null;case 4:return rs(),null;case 10:return Al(t.type._context),null;case 22:case 23:return xi(),null;case 24:return null;default:return null}}var Eo=!1,ot=!1,Gd=typeof WeakSet=="function"?WeakSet:Set,F=null;function os(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ue(e,t,r)}else n.current=null}function ii(e,t,n){try{n()}catch(r){Ue(e,t,r)}}var zu=!1;function bd(e,t){if(xl=Ks,e=ha(),dl(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 s=r.anchorOffset,l=r.focusNode;r=r.focusOffset;try{n.nodeType,l.nodeType}catch{n=null;break e}var u=0,c=-1,f=-1,_=0,C=0,E=e,k=null;t:for(;;){for(var $;E!==n||s!==0&&E.nodeType!==3||(c=u+s),E!==l||r!==0&&E.nodeType!==3||(f=u+r),E.nodeType===3&&(u+=E.nodeValue.length),($=E.firstChild)!==null;)k=E,E=$;for(;;){if(E===e)break t;if(k===n&&++_===s&&(c=u),k===l&&++C===r&&(f=u),($=E.nextSibling)!==null)break;E=k,k=E.parentNode}E=$}n=c===-1||f===-1?null:{start:c,end:f}}else n=null}n=n||{start:0,end:0}}else n=null;for(_l={focusedElem:e,selectionRange:n},Ks=!1,F=t;F!==null;)if(t=F,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,F=e;else for(;F!==null;){t=F;try{var B=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(B!==null){var V=B.memoizedProps,He=B.memoizedState,y=t.stateNode,m=y.getSnapshotBeforeUpdate(t.elementType===t.type?V:rn(t.type,V),He);y.__reactInternalSnapshotBeforeUpdate=m}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(p(163))}}catch(R){Ue(t,t.return,R)}if(e=t.sibling,e!==null){e.return=t.return,F=e;break}F=t.return}return B=zu,zu=!1,B}function Os(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var l=s.destroy;s.destroy=void 0,l!==void 0&&ii(t,n,l)}s=s.next}while(s!==r)}}function Po(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 ai(e){var t=e.ref;if(t!==null){var n=e.stateNode;e.tag,e=n,typeof t=="function"?t(e):t.current=e}}function $u(e){var t=e.alternate;t!==null&&(e.alternate=null,$u(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[xn],delete t[Cs],delete t[kl],delete t[Md],delete t[Ld])),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 Fu(e){return e.tag===5||e.tag===3||e.tag===4}function Uu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Fu(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 ui(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=so));else if(r!==4&&(e=e.child,e!==null))for(ui(e,t,n),e=e.sibling;e!==null;)ui(e,t,n),e=e.sibling}function ci(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(ci(e,t,n),e=e.sibling;e!==null;)ci(e,t,n),e=e.sibling}var et=null,sn=!1;function ir(e,t,n){for(n=n.child;n!==null;)Bu(e,t,n),n=n.sibling}function Bu(e,t,n){if(I&&typeof I.onCommitFiberUnmount=="function")try{I.onCommitFiberUnmount(v,n)}catch{}switch(n.tag){case 5:ot||os(n,t);case 6:var r=et,s=sn;et=null,ir(e,t,n),et=r,sn=s,et!==null&&(sn?(e=et,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):et.removeChild(n.stateNode));break;case 18:et!==null&&(sn?(e=et,n=n.stateNode,e.nodeType===8?jl(e.parentNode,n):e.nodeType===1&&jl(e,n),ms(e)):jl(et,n.stateNode));break;case 4:r=et,s=sn,et=n.stateNode.containerInfo,sn=!0,ir(e,t,n),et=r,sn=s;break;case 0:case 11:case 14:case 15:if(!ot&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var l=s,u=l.destroy;l=l.tag,u!==void 0&&((l&2)!==0||(l&4)!==0)&&ii(n,t,u),s=s.next}while(s!==r)}ir(e,t,n);break;case 1:if(!ot&&(os(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(c){Ue(n,t,c)}ir(e,t,n);break;case 21:ir(e,t,n);break;case 22:n.mode&1?(ot=(r=ot)||n.memoizedState!==null,ir(e,t,n),ot=r):ir(e,t,n);break;default:ir(e,t,n)}}function Hu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Gd),t.forEach(function(r){var s=sf.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function on(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=u),r&=~l}if(r=s,r=_e()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Yd(r/1960))-r,10e?16:e,ur===null)var r=!1;else{if(e=ur,ur=null,Io=0,(ye&6)!==0)throw Error(p(331));var s=ye;for(ye|=4,F=e.current;F!==null;){var l=F,u=l.child;if((F.flags&16)!==0){var c=l.deletions;if(c!==null){for(var f=0;f_e()-pi?Ir(e,0):fi|=n),St(e,t)}function tc(e,t){t===0&&((e.mode&1)===0?t=1:(t=wr,wr<<=1,(wr&130023424)===0&&(wr=4194304)));var n=pt();e=Dn(e,t),e!==null&&(Vt(e,t,n),St(e,n))}function rf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),tc(e,n)}function sf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(p(314))}r!==null&&r.delete(t),tc(e,n)}var nc;nc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||vt.current)xt=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return xt=!1,Wd(e,t,n);xt=(e.flags&131072)!==0}else xt=!1,De&&(t.flags&1048576)!==0&&Da(t,co,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;No(e,t),e=t.pendingProps;var s=Jr(t,nt.current);ns(t,n),s=Ql(null,t,r,e,s,n);var l=Wl();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,yt(r)?(l=!0,io(t)):l=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,zl(t),s.updater=ko,t.stateNode=s,s._reactInternals=t,Yl(t,r,e,n),t=ti(null,t,r,!0,l,n)):(t.tag=0,De&&l&&El(t),ft(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(No(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=lf(r),e=rn(r,e),s){case 0:t=ei(null,t,r,e,n);break e;case 1:t=Pu(null,t,r,e,n);break e;case 11:t=ju(null,t,r,e,n);break e;case 14:t=ku(null,t,r,rn(r.type,e),n);break e}throw Error(p(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:rn(r,s),ei(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:rn(r,s),Pu(e,t,r,s,n);case 3:e:{if(Ru(t),e===null)throw Error(p(387));r=t.pendingProps,l=t.memoizedState,s=l.element,Qa(e,t),vo(t,r,null,n);var u=t.memoizedState;if(r=u.element,l.isDehydrated)if(l={element:r,isDehydrated:!1,cache:u.cache,pendingSuspenseBoundaries:u.pendingSuspenseBoundaries,transitions:u.transitions},t.updateQueue.baseState=l,t.memoizedState=l,t.flags&256){s=ss(Error(p(423)),t),t=Tu(e,t,r,n,s);break e}else if(r!==s){s=ss(Error(p(424)),t),t=Tu(e,t,r,n,s);break e}else for(Rt=tr(t.stateNode.containerInfo.firstChild),Pt=t,De=!0,nn=null,n=Ha(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Zr(),r===s){t=zn(e,t,n);break e}ft(e,t,r,n)}t=t.child}return t;case 5:return qa(t),e===null&&Tl(t),r=t.type,s=t.pendingProps,l=e!==null?e.memoizedProps:null,u=s.children,Sl(r,s)?u=null:l!==null&&Sl(r,l)&&(t.flags|=32),Eu(e,t),ft(e,t,u,n),t.child;case 6:return e===null&&Tl(t),null;case 13:return Mu(e,t,n);case 4:return $l(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=es(t,null,r,n):ft(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:rn(r,s),ju(e,t,r,s,n);case 7:return ft(e,t,t.pendingProps,n),t.child;case 8:return ft(e,t,t.pendingProps.children,n),t.child;case 12:return ft(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,l=t.memoizedProps,u=s.value,Te(mo,r._currentValue),r._currentValue=u,l!==null)if(tn(l.value,u)){if(l.children===s.children&&!vt.current){t=zn(e,t,n);break e}}else for(l=t.child,l!==null&&(l.return=t);l!==null;){var c=l.dependencies;if(c!==null){u=l.child;for(var f=c.firstContext;f!==null;){if(f.context===r){if(l.tag===1){f=On(-1,n&-n),f.tag=2;var _=l.updateQueue;if(_!==null){_=_.shared;var C=_.pending;C===null?f.next=f:(f.next=C.next,C.next=f),_.pending=f}}l.lanes|=n,f=l.alternate,f!==null&&(f.lanes|=n),Dl(l.return,n,t),c.lanes|=n;break}f=f.next}}else if(l.tag===10)u=l.type===t.type?null:l.child;else if(l.tag===18){if(u=l.return,u===null)throw Error(p(341));u.lanes|=n,c=u.alternate,c!==null&&(c.lanes|=n),Dl(u,n,t),u=l.sibling}else u=l.child;if(u!==null)u.return=l;else for(u=l;u!==null;){if(u===t){u=null;break}if(l=u.sibling,l!==null){l.return=u.return,u=l;break}u=u.return}l=u}ft(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,ns(t,n),s=Kt(s),r=r(s),t.flags|=1,ft(e,t,r,n),t.child;case 14:return r=t.type,s=rn(r,t.pendingProps),s=rn(r.type,s),ku(e,t,r,s,n);case 15:return Cu(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:rn(r,s),No(e,t),t.tag=1,yt(r)?(e=!0,io(t)):e=!1,ns(t,n),gu(t,r,s),Yl(t,r,s,n),ti(null,t,r,!0,e,n);case 19:return Iu(e,t,n);case 22:return Nu(e,t,n)}throw Error(p(156,t.tag))};function rc(e,t){return xr(e,t)}function of(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 bt(e,t,n,r){return new of(e,t,n,r)}function Si(e){return e=e.prototype,!(!e||!e.isReactComponent)}function lf(e){if(typeof e=="function")return Si(e)?1:0;if(e!=null){if(e=e.$$typeof,e===mt)return 11;if(e===ge)return 14}return 2}function fr(e,t){var n=e.alternate;return n===null?(n=bt(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 zo(e,t,n,r,s,l){var u=2;if(r=e,typeof e=="function")Si(e)&&(u=1);else if(typeof e=="string")u=5;else e:switch(e){case $e:return Dr(n.children,s,l,t);case Qe:u=8,s|=8;break;case Ze:return e=bt(12,n,t,s|2),e.elementType=Ze,e.lanes=l,e;case We:return e=bt(13,n,t,s),e.elementType=We,e.lanes=l,e;case be:return e=bt(19,n,t,s),e.elementType=be,e.lanes=l,e;case fe:return $o(n,s,l,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case it:u=10;break e;case at:u=9;break e;case mt:u=11;break e;case ge:u=14;break e;case Ne:u=16,r=null;break e}throw Error(p(130,e==null?e:typeof e,""))}return t=bt(u,n,t,s),t.elementType=e,t.type=r,t.lanes=l,t}function Dr(e,t,n,r){return e=bt(7,e,r,t),e.lanes=n,e}function $o(e,t,n,r){return e=bt(22,e,r,t),e.elementType=fe,e.lanes=n,e.stateNode={isHidden:!1},e}function wi(e,t,n){return e=bt(6,e,null,t),e.lanes=n,e}function ji(e,t,n){return t=bt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function af(e,t,n,r,s){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=gt(0),this.expirationTimes=gt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=gt(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function ki(e,t,n,r,s,l,u,c,f){return e=new af(e,t,n,c,f),t===1?(t=1,l===!0&&(t|=8)):t=0,l=bt(3,null,null,t),e.current=l,l.stateNode=e,l.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},zl(l),e}function uf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(h){console.error(h)}}return i(),Ti.exports=Sf(),Ti.exports}var vc;function jf(){if(vc)return Wo;vc=1;var i=wf();return Wo.createRoot=i.createRoot,Wo.hydrateRoot=i.hydrateRoot,Wo}var kf=jf();const Cf=Ic(kf),Nf="/api";async function Re(i,h){const p=await fetch(`${Nf}${i}`,{...h,headers:{"Content-Type":"application/json",...h?.headers??{}}}),D=await p.json();if(!p.ok){const P=D.error?.message??"Ошибка запроса";throw new Error(P)}return D}const Me={async listModels(i){return Re("/llm/models",{method:"POST",body:JSON.stringify({llmProvider:i.llmProvider,apiKey:i.apiKey,model:i.model,baseUrl:i.baseUrl})})},async testConnection(i){return Re("/llm/test-connection",{method:"POST",body:JSON.stringify({llmProvider:i.llmProvider,apiKey:i.apiKey,model:i.model,baseUrl:i.baseUrl})})},async normalize(i){return Re("/normalize",{method:"POST",body:JSON.stringify({llmProvider:i.connection.llmProvider,apiKey:i.connection.apiKey,model:i.connection.model,baseUrl:i.connection.baseUrl,temperature:i.connection.temperature,maxOutputTokens:i.connection.maxOutputTokens,promptVersion:i.promptVersion,systemPrompt:i.prompts.systemPrompt,developerPrompt:i.prompts.developerPrompt,domainPrompt:i.prompts.domainPrompt,fewShotExamples:i.prompts.fewShotExamples,userQuestion:i.query.userQuestion,context:{period_hint:i.query.periodHint??"",business_context:i.query.businessContext??"",expected_route:i.query.expectedRoute??""},saveAsTestCase:!!i.saveAsTestCase,useMock:!!i.useMock})})},async loadHistory(){return Re("/history")},async loadTrace(i){return Re(`/history/${i}`)},async loadPresets(){return Re("/presets")},async savePreset(i){return Re("/presets/save",{method:"POST",body:JSON.stringify(i)})},async runEval(i){return Re("/eval/run",{method:"POST",body:JSON.stringify({normalizeConfig:{llmProvider:i.connection.llmProvider,apiKey:i.connection.apiKey,model:i.connection.model,baseUrl:i.connection.baseUrl,temperature:i.connection.temperature,maxOutputTokens:i.connection.maxOutputTokens,promptVersion:i.promptVersion,systemPrompt:i.prompts.systemPrompt,developerPrompt:i.prompts.developerPrompt,domainPrompt:i.prompts.domainPrompt,fewShotExamples:i.prompts.fewShotExamples},caseIds:i.caseIds,useMock:!!i.useMock,mode:i.mode??"standard",caseSetFile:i.caseSetFile,rawQuestions:i.rawQuestions,eval_target:i.evalTarget,compare_with_report_file:i.compareWithReportFile,analysis_date:i.analysisDate})})},async startEvalRunAsync(i){return Re("/eval/run-async/start",{method:"POST",body:JSON.stringify({normalizeConfig:{llmProvider:i.connection.llmProvider,apiKey:i.connection.apiKey,model:i.connection.model,baseUrl:i.connection.baseUrl,temperature:i.connection.temperature,maxOutputTokens:i.connection.maxOutputTokens,promptVersion:i.promptVersion,systemPrompt:i.prompts.systemPrompt,developerPrompt:i.prompts.developerPrompt,domainPrompt:i.prompts.domainPrompt,fewShotExamples:i.prompts.fewShotExamples},caseIds:i.caseIds,useMock:!!i.useMock,mode:i.mode??"standard",caseSetFile:i.caseSetFile,rawQuestions:i.rawQuestions,eval_target:i.evalTarget,compare_with_report_file:i.compareWithReportFile,questions:i.questions,analysis_date:i.analysisDate})})},async loadEvalRunAsyncStatus(i){return Re(`/eval/run-async/${encodeURIComponent(i)}`)},async startRun(){return Re("/accounting-agent/v1/runs/start",{method:"POST",body:JSON.stringify({initiator:"ndc_operator",source:"gui"})})},async finishRun(i){return Re("/accounting-agent/v1/runs/finish",{method:"POST",body:JSON.stringify({runId:i,status:"DONE",source:"gui",reason:"Остановлено оператором из GUI"})})},async listRuns(){return Re("/accounting-agent/v1/runs")},async listResults(){return Re("/accounting-agent/v1/results")},async runTrace(i){return Re(`/accounting-agent/v1/trace/run/${i}`)},async sendAssistantMessage(i){return Re("/assistant/message",{method:"POST",body:JSON.stringify({session_id:i.sessionId??"",mode:"assistant",message:i.userMessage,user_message:i.userMessage,llmProvider:i.connection.llmProvider,apiKey:i.connection.apiKey,model:i.connection.model,baseUrl:i.connection.baseUrl,temperature:i.connection.temperature,maxOutputTokens:i.connection.maxOutputTokens,promptVersion:i.promptVersion??"address_query_runtime_v1",systemPrompt:i.prompts.systemPrompt,developerPrompt:i.prompts.developerPrompt,domainPrompt:i.prompts.domainPrompt,fewShotExamples:i.prompts.fewShotExamples,context:{period_hint:i.context?.periodHint??"",business_context:i.context?.businessContext??""},useMock:!!i.useMock})})},async loadAssistantSession(i){return Re(`/assistant/session/${i}`)},async loadAutoRunsHistory(i){const h=new URLSearchParams;i?.from&&h.set("from",i.from),i?.to&&h.set("to",i.to),i?.target&&h.set("target",i.target),i?.mode&&h.set("mode",i.mode),i?.use_mock&&h.set("use_mock",i.use_mock),i?.prompt_contains&&h.set("prompt_contains",i.prompt_contains),typeof i?.limit=="number"&&h.set("limit",String(i.limit)),typeof i?.scan_limit=="number"&&h.set("scan_limit",String(i.scan_limit));const p=h.toString();return Re(`/autoruns/history${p?`?${p}`:""}`)},async loadAutoRunDetail(i){return Re(`/autoruns/history/${encodeURIComponent(i)}`)},async loadAutoRunCaseDialog(i,h){return Re(`/autoruns/history/${encodeURIComponent(i)}/case/${encodeURIComponent(h)}/dialog`)},async loadAutoRunAnnotations(i){const h=new URLSearchParams;i?.run_id&&h.set("run_id",i.run_id),i?.case_id&&h.set("case_id",i.case_id),typeof i?.min_rating=="number"&&h.set("min_rating",String(i.min_rating)),i?.manual_case_decision&&h.set("manual_case_decision",i.manual_case_decision),typeof i?.limit=="number"&&h.set("limit",String(i.limit));const p=h.toString();return Re(`/autoruns/annotations${p?`?${p}`:""}`)},async saveAutoRunAnnotation(i){return Re("/autoruns/annotations",{method:"POST",body:JSON.stringify(i)})},async updateAutoRunAnnotation(i){return Re(`/autoruns/annotations/${encodeURIComponent(i.annotation_id)}`,{method:"PATCH",body:JSON.stringify({resolved:i.resolved,resolved_by:i.resolved_by})})},async loadAutoRunPostAnalysis(i){const h=new URLSearchParams;i?.run_id&&h.set("run_id",i.run_id),typeof i?.limit_per_queue=="number"&&h.set("limit_per_queue",String(i.limit_per_queue)),typeof i?.annotation_limit=="number"&&h.set("annotation_limit",String(i.annotation_limit)),typeof i?.scan_limit=="number"&&h.set("scan_limit",String(i.scan_limit)),i?.from&&h.set("from",i.from),i?.to&&h.set("to",i.to),i?.target&&h.set("target",i.target),i?.mode&&h.set("mode",i.mode),i?.use_mock&&h.set("use_mock",i.use_mock),i?.prompt_contains&&h.set("prompt_contains",i.prompt_contains);const p=h.toString();return Re(`/autoruns/post-analysis${p?`?${p}`:""}`)},async loadAutoRunAutogenHistory(i){const h=new URLSearchParams;i?.mode&&h.set("mode",i.mode),typeof i?.limit=="number"&&h.set("limit",String(i.limit));const p=h.toString();return Re(`/autoruns/autogen/history${p?`?${p}`:""}`)},async loadAutoRunAutogenPersonalityCatalog(){return Re("/autoruns/autogen/personality-catalog")},async generateAutoRunQuestions(i){return Re("/autoruns/autogen/generate",{method:"POST",body:JSON.stringify(i)})}};function Mt({value:i}){return o.jsx("pre",{className:"json-view",children:JSON.stringify(i??{},null,2)})}function jn({title:i,subtitle:h,actions:p,className:D,hideHeader:P,children:z}){return o.jsxs("section",{className:D?`panel-frame ${D}`:"panel-frame",children:[P?null:o.jsxs("header",{className:"panel-header",children:[o.jsxs("div",{children:[o.jsx("h2",{children:i}),h?o.jsx("p",{children:h}):null]}),p?o.jsx("div",{className:"panel-actions",children:p}):null]}),o.jsx("div",{className:"panel-body",children:z})]})}function Ef(i){const h=new Date(i);return Number.isNaN(h.getTime())?i:h.toLocaleString("ru-RU")}function Pf({sessionId:i,conversation:h,statusText:p,errorMessage:D,useMock:P,appLogs:z}){const K=h.filter(M=>M.role==="assistant").length,ee=h.filter(M=>M.role==="user").length,U=h.length>0?h[h.length-1]:null;return o.jsxs(jn,{title:"SAM",subtitle:"System Assistant Monitor: срез по текущей сессии и логам.",children:[o.jsxs("div",{className:"metrics-grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"session_id"}),o.jsx("strong",{children:i||"новая сессия"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"mock_mode"}),o.jsx("strong",{children:P?"on":"off"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"сообщений пользователя"}),o.jsx("strong",{children:ee})]}),o.jsxs("div",{children:[o.jsx("span",{children:"ответов ассистента"}),o.jsx("strong",{children:K})]}),o.jsxs("div",{children:[o.jsx("span",{children:"статус"}),o.jsx("strong",{children:p||"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"ошибка"}),o.jsx("strong",{children:D||"нет"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"последнее сообщение"}),o.jsx("strong",{children:U?.created_at?Ef(U.created_at):"нет данных"})]})]}),o.jsx("h3",{style:{marginTop:12},children:"Последние системные логи"}),o.jsx(Mt,{value:z.slice(0,120)})]})}const Rf=/(?:^|\n)\s*#{0,6}\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json|debug_payload|technical_breakdown)\b/i,Tf=[/\b(?:debug_payload_json|technical_breakdown_json)\b/i,/\b(?:route_summary|semantic_profile|domain_scope|relation_patterns|account_scope)\b/i,/\b(?:coverage_report|retrieval_status|problem_unit_state|candidate_evidence)\b/i,/\b(?:graph_domain_scope|graph_runtime|selection_reason|why_included)\b/i];function Mf(i){try{return JSON.stringify(i,null,2)}catch{return String(i)}}function Lf(i){const h=String(i??""),p=h.match(Rf);return(p?h.slice(0,p.index):h).replace(/###\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json)[\s\S]*?(?:```[\s\S]*?```|$)/gi,"").replace(/(?:^|\n)\s*#{0,6}\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json)\b[\s\S]*$/gi,"").split(/\r?\n/g).map(K=>K.trimEnd()).filter(K=>K.trim().length>0).filter(K=>!Tf.some(ee=>ee.test(K))).join(` `).trim()}function If(i,h,p="default"){const D=p==="technical",P=[];P.push("# Assistant conversation export"),P.push(`session_id: ${i||"n/a"}`),P.push(`export_mode: ${p}`),P.push(`exported_at: ${new Date().toISOString()}`),P.push("");for(let z=0;z{L.current&&H.current&&(L.current.scrollTop=L.current.scrollHeight)},[h]),S.useEffect(()=>()=>{re.current!==null&&window.clearTimeout(re.current)},[]);async function oe(le){if(h.length===0)return;const Ce=If(i,h,le),Ae=await Of(Ce);b(le==="technical"?"тех":"чат"),te(Ae?"success":"error"),re.current!==null&&window.clearTimeout(re.current),re.current=window.setTimeout(()=>{te("idle")},2200)}function Se(){if(!L.current)return;const le=L.current,Ce=le.scrollHeight-le.scrollTop-le.clientHeight;H.current=Ce<16}return o.jsx(jn,{className:"assistant-panel-frame",title:"Режим ассистента",children:o.jsxs("div",{className:"assistant-live-shell",children:[o.jsxs("div",{className:"assistant-toolbar",children:[o.jsxs("div",{className:"assistant-toolbar-actions",children:[o.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>{oe("default")},disabled:h.length===0,title:"Экспорт только user-facing чата",children:"Скопировать чат"}),o.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>{oe("technical")},disabled:h.length===0,title:"Технический экспорт с debug payload",children:"Скопировать техчат"}),o.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>ee(),disabled:U&&h.length===0,children:"Сбросить сессию"})]}),o.jsxs("div",{className:"assistant-toolbar-meta",children:[i?o.jsx("span",{className:"status-chip",children:`session: ${i}`}):null,o.jsxs("div",{className:"assistant-toolbar-meta-right",children:[M?o.jsx("span",{className:"assistant-live-status",children:M}):null,Ee==="success"?o.jsxs("span",{className:"assistant-copy-feedback success",children:["Скопировано (",se,")"]}):null,Ee==="error"?o.jsx("span",{className:"assistant-copy-feedback error",children:"Ошибка копирования"}):null]})]}),G?o.jsx("p",{className:"error-text assistant-toolbar-error",children:G}):null]}),o.jsx("div",{ref:L,className:"assistant-chat-list",onScroll:Se,children:h.map(le=>o.jsxs("article",{className:`assistant-msg ${le.role}`,children:[o.jsxs("header",{className:"assistant-msg-head",children:[o.jsx("strong",{children:Af(le.role)}),o.jsx("span",{children:Df(le.created_at)})]}),o.jsx("div",{className:"assistant-msg-body",children:le.text}),le.role==="assistant"&&le.debug?o.jsxs("details",{className:"assistant-debug",children:[o.jsx("summary",{children:"Показать технический разбор"}),o.jsx(Mt,{value:le.debug})]}):null]},le.message_id))}),o.jsxs("div",{className:"assistant-compose",children:[o.jsxs("label",{className:"full-width",children:["Сообщение",o.jsx("textarea",{value:p,onChange:le=>D(le.target.value),rows:4,placeholder:"Введите вопрос к данным компании..."})]}),o.jsxs("div",{className:"button-row assistant-send-row",children:[o.jsxs("label",{className:"checkbox-row",children:[o.jsx("input",{type:"checkbox",checked:P,onChange:le=>z(le.target.checked)}),"Mock-режим"]}),o.jsx("button",{type:"button",className:"assistant-send-btn",onClick:()=>K(),disabled:U||!p.trim(),children:U?"Выполняю...":"Отправить"})]})]})]})})}const Ii={fromLocal:"",toLocal:"",target:"all",mode:"all",useMock:"any",promptContains:"",limit:120},Ko="needs_dialog_policy_fix",lt="__all__",Jo="__live__:",yc="ndc_autoruns_ui_config_v1",xc="ndc-autoruns-save",Ai=["Анализ запроса","Получение данных","Подготовка ответа"],Fi=[{id:"general",label:"Общий контур",domain:"",defaultPrompt:"Генерируй реалистичные живые вопросы бухгалтера по 1С. Добавляй разговорные формулировки и опечатки, но сохраняй бизнес-смысл."}];function zf(i=Fi){return i.reduce((h,p)=>(h[p.id]=p.defaultPrompt,h),{})}const _c={mode:"codex_creative",count:24,personalityId:"general",personalityPrompts:zf(),persistToEvalCases:!0,generatedBy:"manual_reviewer"};function Di(i){const h=String(i??"").trim();return/^\d{4}-\d{2}-\d{2}$/.test(h)?h:""}function $f(i){const h=i.getFullYear(),p=String(i.getMonth()+1).padStart(2,"0"),D=String(i.getDate()).padStart(2,"0"),P=String(i.getHours()).padStart(2,"0"),z=String(i.getMinutes()).padStart(2,"0");return`${h}-${p}-${D}T${P}:${z}`}function Sc(){const i=new Date;return i.setDate(i.getDate()-14),$f(i)}function qo(i){if(!i.trim())return;const h=Date.parse(i);if(Number.isFinite(h))return new Date(h).toISOString()}function mr(i){if(!i)return"нет данных";const h=Date.parse(i);return Number.isFinite(h)?new Date(h).toLocaleString("ru-RU"):i}function Ff(i,h){return h<=0?0:Math.max(0,Math.min(100,Number((i/h*100).toFixed(1))))}function Go(i){return typeof i!="number"?"нет данных":`${i.toFixed(1)}%`}function Uf(i){return i==="assistant_stage1"?"assistant/s1":i==="assistant_stage2"?"assistant/s2":i==="assistant_p0"?"assistant/p0":i}function wc(i){return i==="up"?"Рост":i==="down"?"Регресс":"Без изменений"}function Bf(i,h){return i.find(p=>p.case_id===h)??null}function jc(i){const h=Math.max(1,Math.min(5,Math.round(i)));return`${"●".repeat(h)}${"○".repeat(5-h)}`}function kc(i){return i.length===0?o.jsx("p",{className:"muted",children:"Покрытие доменов пока не сформировано."}):o.jsx("div",{className:"autoruns-coverage-list",children:i.map(h=>{const p=Ff(h.closed_cases,h.total_cases);return o.jsxs("div",{className:"autoruns-coverage-item",children:[o.jsxs("div",{className:"autoruns-coverage-head",children:[o.jsx("strong",{children:h.domain}),o.jsxs("span",{children:[h.closed_cases,"/",h.total_cases," (",p,"%)"]})]}),o.jsx("div",{className:"autoruns-coverage-bar",children:o.jsx("div",{style:{width:`${p}%`}})})]},h.domain)})})}function bo(i){return`${Jo}${i}`}function us(i){return i.startsWith(Jo)}function Cc(i){return i.startsWith(Jo)?i.slice(Jo.length):""}function Dc(i){const h=i.report_summary?.run_timestamp??i.created_at,p=Math.max(0,i.total_cases-i.completed_cases);return{run_id:bo(i.job_id),eval_target:i.eval_target,run_timestamp:h,mode:"single-pass-strict",llm_provider:null,model:null,use_mock:null,analysis_date:i.report_summary?.analysis_date??i.analysis_date??null,prompt_version:null,schema_version:null,suite_id:i.case_set_file,cases_total:i.total_cases,requests_total:null,report_path:`async_job:${i.job_id}`,score_index:i.report_summary?.score_index??null,blocking_failures:0,quality_failures:0,closed_cases:i.completed_cases,open_cases:p,domain_coverage:[{domain:"runtime",total_cases:i.total_cases,closed_cases:i.completed_cases}]}}function Hs(i,h){const p=Dc(i),D=i.cases.map(G=>({case_id:G.case_id,domain:null,query_class:null,status:G.status==="completed"?"closed":G.status==="failed"?"open":"unknown",score_index:null,trace_id:null,reply_type:null,session_id:`${i.run_id}-${G.case_id}`,dialog_available:G.messages.length>0,commented_count:0,latest_annotation_at:null,avg_rating:null,checks:null,metric_subscores:null})),z=h!==lt&&D.some(G=>G.case_id===h)?h:D.length>0?lt:"",K={ok:!0,run:p,coverage:{closed_cases:i.completed_cases,open_cases:Math.max(0,i.total_cases-i.completed_cases),domain_coverage:[{domain:"runtime",total_cases:i.total_cases,closed_cases:i.completed_cases}]},cases:D,annotations_summary:{total:0},report:i.report_summary?{run_id:i.report_summary.run_id,run_timestamp:i.report_summary.run_timestamp,score_index:i.report_summary.score_index,cases_total:i.report_summary.cases_total,analysis_date:i.report_summary.analysis_date??i.analysis_date??null}:{}},ee=[];let U=0;if(z===lt)for(const G of i.cases)for(let L=0;LL.case_id===z)??null;for(let L=0;L<(G?.messages.length??0);L+=1){const H=G?.messages[L];H&&ee.push({...H,message_index:L,case_id:z,case_message_index:L,commented:!1,annotation:null})}}const M={ok:!0,run_id:p.run_id,case_id:z,source:"assistant_session",session_id:z===lt?`${i.run_id}::__all__`:`${i.run_id}-${z}`,messages:ee,decomposition:[],assistant_mode:{status:i.status,completed_cases:i.completed_cases,total_cases:i.total_cases},annotations:[]};return{detail:K,dialog:M,caseId:z}}function Hf({commented:i}){const h=i?"comment-icon-svg commented":"comment-icon-svg";return o.jsxs("svg",{className:h,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[o.jsx("path",{d:"M5 6.5h14v9H11.5l-4.5 3v-3H5z"}),o.jsx("circle",{className:"comment-icon-dot",cx:"9",cy:"11",r:"1.05"}),o.jsx("circle",{className:"comment-icon-dot",cx:"12",cy:"11",r:"1.05"}),o.jsx("circle",{className:"comment-icon-dot",cx:"15",cy:"11",r:"1.05"})]})}function Nc({resolved:i}){return o.jsxs("svg",{className:i?"resolve-icon-svg resolved":"resolve-icon-svg",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[o.jsx("circle",{cx:"8",cy:"8",r:"6.2"}),i?o.jsx("path",{d:"M5.1 8.2 7.2 10.3 11 6.5"}):null]})}function Vf({connection:i,prompts:h,assistantPromptVersion:p,decompositionPromptVersion:D,showAssistantMode:P,showDecompositionMode:z,showProgressMode:K,showCommentsMode:ee,onLog:U}){const[M,G]=S.useState({...Ii,fromLocal:Sc()}),[L,H]=S.useState(""),[re,Ee]=S.useState(null),[te,se]=S.useState(null),[b,oe]=S.useState(null),[Se,le]=S.useState([]),[Ce,Ae]=S.useState("all"),[$e,Qe]=S.useState(!1),[Ze,it]=S.useState(null),[at,mt]=S.useState([]),[We,be]=S.useState(""),[ge,Ne]=S.useState(""),[fe,T]=S.useState(""),[Q,A]=S.useState(Fi),[d,j]=S.useState(_c),[J,ae]=S.useState([]),[ue,ce]=S.useState(""),[ve,he]=S.useState([]),[Z,we]=S.useState(null),[jt,kn]=S.useState(null),[an,un]=S.useState(!1),[Un,Lt]=S.useState(!1),[It,Cn]=S.useState(!1),[Jt,kt]=S.useState(!1),[At,Yt]=S.useState(!1),[Bn,cn]=S.useState(!1),[Hn,dn]=S.useState(!1),[Dt,Ot]=S.useState(!1),[Vn,Ct]=S.useState(""),[Xt,Fe]=S.useState(""),[fn,pn]=S.useState(""),[Or,zt]=S.useState([]),[mn,$t]=S.useState(""),[hn,gn]=S.useState(!1),[Zt,ht]=S.useState(!1),[hr,en]=S.useState(""),[Qn,Nn]=S.useState(""),[Wn,Nt]=S.useState(String(Ii.limit)),[gr,ut]=S.useState(String(_c.count)),[ie,Ke]=S.useState({open:!1,caseId:"",caseMessageIndex:-1,messageIndex:-1,rating:3,comment:"",manualCaseDecision:Ko,annotationAuthor:"manual_reviewer",saving:!1,error:""}),En=S.useRef(!1),ct=S.useRef(null),Ft=S.useMemo(()=>Q.find(a=>a.id===d.personalityId)??Q[0]??Fi[0],[d.personalityId,Q]),q=S.useMemo(()=>J.find(a=>a.generation_id===ue)??J[0]??null,[J,ue]),vn=te?Bf(te.cases,fe):null,Be=S.useMemo(()=>$e?Se.filter(a=>!a.resolved):Se,[Se,$e]),je=Be.find(a=>a.annotation_id===We)??null,Pn=b?.messages.find(a=>a.message_index===ie.messageIndex)??null,Ut=S.useMemo(()=>{if(!b||ie.messageIndex<0)return null;for(let a=ie.messageIndex-1;a>=0;a-=1){const g=b.messages[a];if(g?.role==="user")return g}return null},[ie.messageIndex,b]),vr=S.useMemo(()=>{if(Be.length===0)return null;const a=Be.reduce((g,w)=>g+w.rating,0)/Be.length;return Number(a.toFixed(2))},[Be]),Rn=S.useMemo(()=>{const a=[...re?.items??[]];return Z&&a.unshift(Dc(Z)),ge&&!a.some(g=>g.run_id===ge)&&te?.run&&a.unshift(te.run),a},[Z,re?.items,te?.run,ge]),de=S.useCallback(a=>{U?.(`[autoruns] ${a}`)},[U]);function zr(){let a=0;en(Ai[0]);const g=window.setInterval(()=>{a=Math.min(a+1,Ai.length-1),en(Ai[a])},650);return()=>window.clearInterval(g)}const yr=S.useCallback(()=>{pn(""),zt([]),$t(""),en(""),Nn(""),de("Live-чат ассистента в истории автопрогонов сброшен.")},[de]),xr=S.useCallback(async()=>{const a=mn.trim();if(!a)return;ht(!0),Nn(""),$t(""),zt(w=>[...w,{message_id:`autoruns-live-${Date.now()}`,session_id:fn||"pending",role:"user",text:a,reply_type:null,created_at:new Date().toISOString(),trace_id:null,debug:null}]);const g=zr();try{const w=await Me.sendAssistantMessage({connection:i,prompts:h,userMessage:a,sessionId:fn||void 0,promptVersion:p,useMock:hn});pn(w.session_id),zt(w.conversation),en("Ответ готов"),de(`Live-ответ ассистента получен: trace=${w.debug.trace_id}`)}catch(w){const O=w instanceof Error?w.message:String(w);Nn(O),en("Ошибка ассистента"),de(`Live-чат ассистента: ошибка отправки сообщения: ${O}`)}finally{g(),ht(!1)}},[mn,fn,hn,p,i,de,h]),Kn=S.useCallback(a=>{const g=a.trim();if(!g){Nt(String(M.limit));return}if(!/^\d+$/.test(g)){Nt(String(M.limit));return}const w=Number.parseInt(g,10);if(!Number.isFinite(w)){Nt(String(M.limit));return}const O=Math.max(1,Math.min(500,w));O!==M.limit&&G(Pe=>({...Pe,limit:O})),Nt(String(O))},[M.limit]),_r=S.useCallback(a=>{const g=a.trim();if(!g){ut(String(d.count));return}if(!/^\d+$/.test(g)){ut(String(d.count));return}const w=Number.parseInt(g,10);if(!Number.isFinite(w)){ut(String(d.count));return}const O=Math.max(1,Math.min(200,w));O!==d.count&&j(Pe=>({...Pe,count:O})),ut(String(O))},[d.count]),Tn=S.useCallback(async()=>{Ot(!0);try{const a=await Me.loadAutoRunAnnotations({limit:800,manual_case_decision:Ce});le(a.items),it(a.manual_case_decision_schema??null),mt(a.available_manual_case_decisions??[]),be(g=>a.items.length===0?"":a.items.some(w=>w.annotation_id===g)?g:a.items[0].annotation_id)}catch(a){de(`Annotations load error: ${a instanceof Error?a.message:String(a)}`)}finally{Ot(!1)}},[Ce,de]),_e=S.useCallback(async()=>{kt(!0);try{const a=await Me.loadAutoRunAutogenHistory({limit:180});ae(a.items)}catch(a){de(`Autogen history load error: ${a instanceof Error?a.message:String(a)}`)}finally{kt(!1)}},[de]),$r=S.useCallback(async()=>{try{const g=(await Me.loadAutoRunAutogenPersonalityCatalog()).items.map(w=>({id:String(w.id??"").trim(),label:String(w.label??"").trim(),domain:typeof w.domain=="string"?w.domain.trim():"",defaultPrompt:String(w.default_prompt??"").trim()})).filter(w=>w.id.length>0&&w.label.length>0);if(g.length===0)return;A(g.map(w=>({id:w.id,label:w.label,domain:w.domain||"",defaultPrompt:w.defaultPrompt||"Генерируй реалистичные вопросы бухгалтера по выбранному профилю. Не выдумывай непокрытые возможности."})))}catch(a){de(`Autogen personality catalog load error: ${a instanceof Error?a.message:String(a)}`)}},[de]),dt=S.useCallback(async()=>{Cn(!0);try{const a=await Me.loadAutoRunPostAnalysis({run_id:ge&&!us(ge)?ge:void 0,limit_per_queue:30,annotation_limit:1500,from:qo(M.fromLocal),to:qo(M.toLocal),target:M.target,mode:M.mode,use_mock:M.useMock,prompt_contains:M.promptContains.trim()||void 0});kn(a)}catch(a){de(`Post-analysis load error: ${a instanceof Error?a.message:String(a)}`),kn(null)}finally{Cn(!1)}},[M.fromLocal,M.mode,M.promptContains,M.target,M.toLocal,M.useMock,de,ge]),Fr=S.useCallback(async()=>{un(!0),Fe("");try{const a=d.personalityPrompts[d.personalityId]??"",g=[h.systemPrompt,h.developerPrompt,h.domainPrompt,h.schemaNotes,h.fewShotExamples].join(` `).slice(0,900),w=await Me.generateAutoRunQuestions({mode:d.mode,count:d.count,domain:Ft.domain||void 0,persist_to_eval_cases:d.persistToEvalCases,generated_by:d.generatedBy.trim()||void 0,llm:{llm_provider:i.llmProvider,api_key:i.apiKey,model:i.model,base_url:i.baseUrl,temperature:i.temperature,max_output_tokens:i.maxOutputTokens},context:{llm_provider:i.llmProvider,model:i.model,assistant_prompt_version:p,decomposition_prompt_version:D,prompt_fingerprint:g,autogen_personality_id:Ft.id,autogen_personality_prompt:a.trim()||void 0}});de(`Generated ${w.generation.count} questions (${w.generation.mode}) id=${w.generation.generation_id}`+(w.generation.saved_case_set_file?` saved=${w.generation.saved_case_set_file}`:"")),ce(w.generation.generation_id),he([...w.generation.questions??[]]),await _e()}catch(a){const g=a instanceof Error?a.message:String(a);Fe(`Автогенерация: ${g}`),de(`Autogen generate error: ${g}`)}finally{un(!1)}},[p,d.count,d.generatedBy,d.mode,d.personalityId,d.personalityPrompts,d.persistToEvalCases,i.apiKey,i.baseUrl,i.llmProvider,i.maxOutputTokens,i.model,i.temperature,D,_e,de,h.developerPrompt,h.domainPrompt,h.fewShotExamples,h.schemaNotes,h.systemPrompt,Ft.domain,Ft.id]),Bt=S.useCallback(async(a,g)=>{if(us(a)){const w=Cc(a);if(Z&&Z.job_id===w){const O=Hs(Z,g);Ne(a),T(O.caseId),oe(O.dialog);return}oe(null);return}dn(!0);try{const w=await Me.loadAutoRunCaseDialog(a,g);oe(w)}catch(w){const O=w instanceof Error?w.message:String(w);Fe(`Диалог кейса: ${O}`),oe(null),de(`Dialog load error for ${a}/${g}: ${O}`)}finally{dn(!1)}},[Z,de]),Ht=S.useCallback(async(a,g)=>{if(us(a)){const w=Cc(a);if(Z&&Z.job_id===w){const O=Hs(Z,g??lt);Ne(a),T(O.caseId),se(O.detail),oe(O.dialog);return}Ne(a),T(""),se(null),oe(null);return}cn(!0);try{const w=await Me.loadAutoRunDetail(a);se(w);const O=(g&&(g===lt||w.cases.some(Pe=>Pe.case_id===g))?g:"")||(w.cases.length>0?lt:"")||"";Ne(a),T(O),O?await Bt(a,O):oe(null)}catch(w){const O=w instanceof Error?w.message:String(w);Fe(`Детализация прогона: ${O}`),se(null),oe(null),de(`Run detail load error for ${a}: ${O}`)}finally{cn(!1)}},[Z,Bt,de]),yn=S.useCallback(async a=>{Yt(!0),Fe("");try{const g=await Me.loadAutoRunsHistory({from:qo(M.fromLocal),to:qo(M.toLocal),target:M.target,mode:M.mode,use_mock:M.useMock,prompt_contains:M.promptContains.trim()||void 0,limit:M.limit});if(Ee(g),g.items.length===0){Ne(""),T(""),se(null),oe(null);return}const w=a?.keepSelection??!0,O=a?.preferredRunId??"",Pe=a?.preferredCaseId??"",gt=w&&O&&g.items.some(Vt=>Vt.run_id===O)?O:g.items[0].run_id;await Ht(gt,w?Pe:void 0),dt()}catch(g){const w=g instanceof Error?g.message:String(g);Fe(`История прогонов: ${w}`),de(`History load error: ${w}`)}finally{Yt(!1)}},[M.fromLocal,M.limit,M.mode,M.promptContains,M.target,M.toLocal,M.useMock,dt,Ht,de]),v=S.useCallback(()=>{ct.current!==null&&(window.clearTimeout(ct.current),ct.current=null)},[]),I=S.useCallback(async a=>{try{const g=await Me.loadEvalRunAsyncStatus(a);we(g.job);const w=bo(a);if(ge===w){const O=Hs(g.job,fe||lt);se(O.detail),oe(O.dialog),T(O.caseId)}if(g.job.status==="completed"){v(),Lt(!1);const O=g.job.report_summary?.run_id??g.job.run_id;await yn({keepSelection:!0,preferredRunId:O||ge,preferredCaseId:lt}),await _e(),we(null);return}if(g.job.status==="failed"){v(),Lt(!1),Fe(`Запуск прогонов: ${g.job.error??"неизвестная ошибка"}`),de(`Autogen async run failed: ${g.job.error??"unknown error"}`);return}v(),ct.current=window.setTimeout(()=>{I(a)},500)}catch(g){v(),Lt(!1);const w=g instanceof Error?g.message:String(g);Fe(`Запуск прогонов: ${w}`),de(`Autogen async status error: ${w}`)}},[_e,yn,de,fe,ge,v]),N=S.useCallback(async()=>{v(),Lt(!0),Fe("");try{const a=q;if(!a)throw new Error("История автогенерации пуста. Сначала сгенерируйте пачку вопросов.");const g=ve.map(jr=>jr.trim()).filter(jr=>jr.length>0);if(g.length===0)throw new Error("Нет вопросов для запуска: список пустой после ручного редактирования.");const w=M.useMock==="true",O=Di(L),gt=(await Me.startEvalRunAsync({connection:i,prompts:h,promptVersion:p,mode:"single-pass-strict",caseSetFile:a.saved_case_set_file??void 0,useMock:w,evalTarget:"assistant_stage1",questions:g,analysisDate:O||void 0})).job;we(gt);const Vt=bo(gt.job_id),Gn=Hs(gt,lt);Ne(Vt),T(Gn.caseId),se(Gn.detail),oe(Gn.dialog),de(`Запущен async-прогон job=${gt.job_id}, run_id=${gt.run_id}, вопросов=${g.length}`+(a.saved_case_set_file?`, base_case_set=${a.saved_case_set_file}`:"")+(O?`, analysis_date=${O}`:", analysis_date=current_state")),I(gt.job_id)}catch(a){const g=a instanceof Error?a.message:String(a);Fe(`Запуск прогонов: ${g}`),de(`Autogen run error: ${g}`),Lt(!1)}},[L,p,i,ve,M.useMock,de,I,h,q,v]),pe=S.useCallback(a=>{if(a.role!=="assistant")return;const g=a.case_id??fe,w=a.case_message_index??a.message_index;Ke({open:!0,caseId:g,caseMessageIndex:w,messageIndex:a.message_index,rating:a.annotation?.rating??3,comment:a.annotation?.comment??"",manualCaseDecision:a.annotation?.manual_case_decision??Ko,annotationAuthor:a.annotation?.annotation_author??d.generatedBy,saving:!1,error:""})},[d.generatedBy,fe]),Ur=S.useCallback(a=>{Ke(g=>g.saving&&!a?.force?g:{open:!1,caseId:"",caseMessageIndex:-1,messageIndex:-1,rating:3,comment:"",manualCaseDecision:Ko,annotationAuthor:d.generatedBy,saving:!1,error:""})},[d.generatedBy]),Yo=S.useCallback(async()=>{const a=ge,g=ie.caseId,w=ie.caseMessageIndex;if(!(!a||!g||w<0)){if(us(a)){Ke(O=>({...O,error:"Комментарий можно сохранить после завершения прогона."}));return}if(!ie.comment.trim()){Ke(O=>({...O,error:"Добавьте комментарий."}));return}Ke(O=>({...O,saving:!0,error:""}));try{await Me.saveAutoRunAnnotation({run_id:a,case_id:g,message_index:w,rating:ie.rating,comment:ie.comment.trim(),manual_case_decision:ie.manualCaseDecision,annotation_author:ie.annotationAuthor.trim()||void 0}),Ur({force:!0}),Promise.all([Ht(a,fe),Tn(),dt()]).catch(O=>{const Pe=O instanceof Error?O.message:String(O);Fe(`Обновление после комментария: ${Pe}`),de(`Comment refresh error: ${Pe}`)})}catch(O){Ke(Pe=>({...Pe,saving:!1,error:O instanceof Error?O.message:String(O)}))}}},[Ur,ie.annotationAuthor,ie.caseId,ie.caseMessageIndex,ie.comment,ie.manualCaseDecision,ie.rating,Tn,dt,Ht,de,fe,ge]),Vs=S.useCallback(a=>{le(g=>g.map(w=>w.annotation_id===a.annotation_id?{...w,...a}:w)),oe(g=>g&&{...g,annotations:g.annotations.map(w=>w.annotation_id===a.annotation_id?a:w),messages:g.messages.map(w=>!w.annotation||w.annotation.annotation_id!==a.annotation_id?w:{...w,commented:!0,annotation:a})})},[]),Sr=S.useCallback(async(a,g)=>{if(a.annotation_id){if(us(a.run_id)){Fe("Статус выполнения можно менять только для завершённых прогонов.");return}Ct(a.annotation_id);try{const w=await Me.updateAutoRunAnnotation({annotation_id:a.annotation_id,resolved:g,resolved_by:d.generatedBy||void 0});Vs(w.annotation),dt()}catch(w){const O=w instanceof Error?w.message:String(w);Fe(`Смена статуса кейса: ${O}`),de(`Annotation resolve toggle error: ${O}`)}finally{Ct("")}}},[Vs,d.generatedBy,dt,de]),wr=S.useCallback(async a=>{be(a.annotation_id),await Ht(a.run_id,a.case_id),re?.items.some(g=>g.run_id===a.run_id)||Fe("Комментарий относится к прогону вне текущего фильтра. Детали загружены напрямую.")},[re?.items,Ht]);S.useEffect(()=>{En.current||(En.current=!0,yn({keepSelection:!1}),_e(),$r(),dt())},[_e,$r,yn,dt]),S.useEffect(()=>{En.current&&Tn()},[Ce,Tn]),S.useEffect(()=>{be(a=>Be.length===0?"":Be.some(g=>g.annotation_id===a)?a:Be[0].annotation_id)},[Be]),S.useEffect(()=>{ce(a=>J.length===0?"":a&&J.some(g=>g.generation_id===a)?a:J[0].generation_id)},[J]),S.useEffect(()=>{if(!q){he([]);return}he([...q.questions])},[q?.generation_id]),S.useEffect(()=>{Nt(String(M.limit))},[M.limit]),S.useEffect(()=>{ut(String(d.count))},[d.count]),S.useEffect(()=>{if(!Z)return;const a=bo(Z.job_id);if(ge!==a)return;const g=Hs(Z,fe||lt);se(g.detail),oe(g.dialog),T(g.caseId)},[Z,fe,ge]),S.useEffect(()=>()=>{v()},[v]),S.useEffect(()=>{Q.length!==0&&j(a=>{let g=!1;const w={...a.personalityPrompts};for(const Pe of Q)(typeof w[Pe.id]!="string"||w[Pe.id].trim().length===0)&&(w[Pe.id]=Pe.defaultPrompt,g=!0);let O=a.personalityId;return Q.some(Pe=>Pe.id===a.personalityId)||(O=Q[0].id,g=!0),g?{...a,personalityId:O,personalityPrompts:w}:a})},[Q]),S.useEffect(()=>{const a=localStorage.getItem(yc);if(a)try{const g=JSON.parse(a);if(g.filters){const w=g.filters;G(O=>({...O,...w,limit:typeof w.limit=="number"?Math.max(1,Math.min(500,w.limit)):O.limit}))}typeof g.analysisDate=="string"&&H(Di(g.analysisDate)),g.autoGenSettings&&j(w=>{const O={...w.personalityPrompts},Pe=g.autoGenSettings?.personalityPrompts??{};for(const[Vt,Gn]of Object.entries(Pe))typeof Gn=="string"&&Vt.trim().length>0&&(O[Vt.trim()]=Gn);const gt=typeof g.autoGenSettings?.personalityId=="string"&&g.autoGenSettings.personalityId.trim().length>0?g.autoGenSettings.personalityId.trim():w.personalityId;return{...w,mode:g.autoGenSettings?.mode==="codex_creative"||g.autoGenSettings?.mode==="qwen_seed"?g.autoGenSettings.mode:w.mode,count:typeof g.autoGenSettings?.count=="number"?Math.max(1,Math.min(200,g.autoGenSettings.count)):w.count,personalityId:gt,personalityPrompts:O,persistToEvalCases:typeof g.autoGenSettings?.persistToEvalCases=="boolean"?g.autoGenSettings.persistToEvalCases:w.persistToEvalCases,generatedBy:typeof g.autoGenSettings?.generatedBy=="string"?g.autoGenSettings.generatedBy:w.generatedBy}}),(g.annotationDecisionFilter==="all"||typeof g.annotationDecisionFilter=="string"&&g.annotationDecisionFilter.length>0)&&Ae(g.annotationDecisionFilter),typeof g.hideResolvedAnnotations=="boolean"&&Qe(g.hideResolvedAnnotations)}catch{}},[]);const qn=S.useCallback(()=>{const a={filters:M,analysisDate:L,autoGenSettings:{mode:d.mode,count:d.count,personalityId:d.personalityId,personalityPrompts:d.personalityPrompts,persistToEvalCases:d.persistToEvalCases,generatedBy:d.generatedBy},annotationDecisionFilter:Ce,hideResolvedAnnotations:$e};localStorage.setItem(yc,JSON.stringify(a))},[L,Ce,d,M,$e]);return S.useEffect(()=>{const a=()=>{qn(),de("Сохранены настройки панели автопрогонов.")};return window.addEventListener(xc,a),()=>{window.removeEventListener(xc,a)}},[de,qn]),o.jsxs(jn,{className:"autoruns-frame",title:"",hideHeader:!0,children:[o.jsxs("div",{className:"autoruns-columns",children:[o.jsxs("section",{className:"autoruns-col",children:[o.jsx("div",{className:"autoruns-col-header",children:o.jsx("h3",{children:"Настройки"})}),o.jsx("h4",{children:"Настройки выборки"}),o.jsxs("div",{className:"autoruns-form-grid",children:[o.jsxs("label",{children:["Дата с",o.jsx("input",{type:"datetime-local",value:M.fromLocal,onChange:a=>G(g=>({...g,fromLocal:a.target.value}))})]}),o.jsxs("label",{children:["Дата по",o.jsx("input",{type:"datetime-local",value:M.toLocal,onChange:a=>G(g=>({...g,toLocal:a.target.value}))})]}),o.jsxs("label",{children:["Целевой контур",o.jsxs("select",{value:M.target,onChange:a=>G(g=>({...g,target:a.target.value})),children:[o.jsx("option",{value:"all",children:"все"}),(re?.available.targets??[]).map(a=>o.jsx("option",{value:a,children:a},a))]})]}),o.jsxs("label",{children:["Режим",o.jsxs("select",{value:M.mode,onChange:a=>G(g=>({...g,mode:a.target.value})),children:[o.jsx("option",{value:"all",children:"все"}),(re?.available.modes??[]).map(a=>o.jsx("option",{value:a,children:a},a))]})]}),o.jsxs("label",{children:["Использовать mock",o.jsxs("select",{value:M.useMock,onChange:a=>G(g=>({...g,useMock:a.target.value})),children:[o.jsx("option",{value:"any",children:"любой"}),o.jsx("option",{value:"true",children:"да"}),o.jsx("option",{value:"false",children:"нет"})]})]}),o.jsxs("label",{children:["Лимит",o.jsx("input",{type:"number",min:1,max:500,value:Wn,onChange:a=>{const g=a.target.value;(g===""||/^\d+$/.test(g))&&Nt(g)},onBlur:a=>Kn(a.target.value),onKeyDown:a=>{a.key==="Enter"&&Kn(a.target.value)}})]}),o.jsxs("label",{className:"full-width",children:["Версия промпта содержит",o.jsx("input",{value:M.promptContains,onChange:a=>G(g=>({...g,promptContains:a.target.value})),placeholder:"normalizer_v2_0_2 / address_query_runtime_v1",list:"autoruns-prompt-versions"})]})]}),o.jsx("datalist",{id:"autoruns-prompt-versions",children:(re?.available.prompt_versions??[]).map(a=>o.jsx("option",{value:a},a))}),o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",disabled:At,onClick:()=>{yn({keepSelection:!1})},children:At?"Обновляю...":"Применить"}),o.jsx("button",{type:"button",className:"tab",onClick:()=>{G({...Ii,fromLocal:Sc()}),Fe("")},children:"Сбросить фильтры"})]}),o.jsx("h4",{children:"Контур генерации"}),o.jsxs("div",{className:"autoruns-meta-list",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Провайдер:"}),o.jsx("strong",{children:i.llmProvider})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Модель:"}),o.jsx("strong",{children:i.model||"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Промпт ассистента:"}),o.jsx("strong",{children:p})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Промпт декомпозиции:"}),o.jsx("strong",{children:D})]})]}),o.jsx("h4",{children:"Автогенерация вопросов"}),o.jsx("p",{className:"muted",children:"`qwen_seed` использует текущую LLM-модель из активного контура подключения (та же модель, что и для ответов ассистента)."}),o.jsxs("div",{className:"autoruns-form-grid",children:[o.jsxs("label",{children:["Режим генерации",o.jsxs("select",{value:d.mode,onChange:a=>j(g=>({...g,mode:a.target.value})),children:[o.jsx("option",{value:"codex_creative",children:"codex_creative"}),o.jsx("option",{value:"qwen_seed",children:"qwen_seed"})]})]}),o.jsxs("label",{children:["Кол-во",o.jsx("input",{type:"number",min:1,max:200,value:gr,onChange:a=>{const g=a.target.value;(g===""||/^\d+$/.test(g))&&ut(g)},onBlur:a=>_r(a.target.value),onKeyDown:a=>{a.key==="Enter"&&_r(a.target.value)}})]}),o.jsxs("label",{children:["Личность автогенерации",o.jsx("select",{value:d.personalityId,onChange:a=>j(g=>({...g,personalityId:a.target.value})),children:Q.map(a=>o.jsx("option",{value:a.id,children:a.label},a.id))})]}),o.jsxs("label",{children:["Кто генерирует",o.jsx("input",{value:d.generatedBy,onChange:a=>j(g=>({...g,generatedBy:a.target.value})),placeholder:"manual_reviewer"})]}),o.jsxs("label",{className:"full-width",children:["Промпт личности",o.jsx("textarea",{value:d.personalityPrompts[d.personalityId]??"",onChange:a=>j(g=>({...g,personalityPrompts:{...g.personalityPrompts,[g.personalityId]:a.target.value}})),placeholder:"Текст промпта для выбранной личности автогенерации"})]}),o.jsxs("label",{className:"checkbox-row",children:[o.jsx("input",{type:"checkbox",checked:d.persistToEvalCases,onChange:a=>j(g=>({...g,persistToEvalCases:a.target.checked}))}),"Сохранять кейс-сет в `eval_cases`"]})]}),o.jsxs("div",{className:"autoruns-form-grid",children:[o.jsxs("label",{children:["Дата анализа (срез)",o.jsx("input",{type:"date",value:L,onChange:a=>H(Di(a.target.value))})]}),o.jsx("div",{className:"button-row",children:o.jsx("button",{type:"button",className:"tab",disabled:!L,onClick:()=>H(""),children:"Сбросить дату среза"})})]}),o.jsx("p",{className:"muted",children:"Если дата среза задана, автопрогон анализирует данные на эту дату. Если поле пустое, используется текущее состояние."}),o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",disabled:an,onClick:()=>{Fr()},children:an?"Генерирую...":"Сгенерировать пачку"}),o.jsx("button",{type:"button",className:"tab",disabled:Jt,onClick:()=>{_e()},children:Jt?"Обновляю...":"Обновить историю"}),o.jsx("button",{type:"button",className:"tab",disabled:Un||ve.length===0,onClick:()=>{N()},children:Un?"Запускаю...":"Запустить прогоны"})]}),o.jsx("div",{className:"autoruns-form-grid",children:o.jsxs("label",{className:"full-width",children:["Кейс-сет для запуска",o.jsxs("select",{value:ue,onChange:a=>ce(a.target.value),disabled:J.length===0,children:[J.length===0?o.jsx("option",{value:"",children:"нет генераций"}):null,J.map(a=>o.jsxs("option",{value:a.generation_id,children:[mr(a.created_at)," | ",a.mode," | ",a.count," | ",a.saved_case_set_file??"без файла"]},a.generation_id))]})]})}),o.jsxs("div",{className:"autoruns-generated-questions",children:[o.jsxs("div",{className:"autoruns-generated-questions-head",children:[o.jsxs("strong",{children:["Вопросы к запуску: ",ve.length]}),o.jsx("button",{type:"button",className:"tab",onClick:()=>he([...q?.questions??[]]),disabled:!q,children:"Восстановить"})]}),ve.length===0?o.jsx("p",{className:"muted",children:"Список вопросов пуст. Сгенерируйте пачку или восстановите из выбранной генерации."}):o.jsx("div",{className:"autoruns-generated-questions-list",children:ve.map((a,g)=>o.jsxs("div",{className:"autoruns-generated-question-item",children:[o.jsxs("span",{children:[g+1,". ",a]}),o.jsx("button",{type:"button",className:"autoruns-remove-question-btn",onClick:()=>he(w=>w.filter((O,Pe)=>Pe!==g)),title:"Удалить вопрос из запуска","aria-label":"Удалить вопрос из запуска",children:"X"})]},`${g}-${a.slice(0,24)}`))})]}),o.jsx("p",{className:"muted",children:"Запуск выполняет `assistant_stage1` eval по выбранному кейс-сету."}),o.jsxs("div",{className:"autoruns-autogen-list",children:[Jt?o.jsx("p",{className:"muted",children:"Загружаю историю автогенераций..."}):null,!Jt&&J.length===0?o.jsx("p",{className:"muted",children:"История автогенераций пока пустая."}):null,J.slice(0,30).map(a=>o.jsxs("article",{className:ue===a.generation_id?"autoruns-autogen-item selected":"autoruns-autogen-item",onClick:()=>ce(a.generation_id),children:[o.jsxs("header",{children:[o.jsx("strong",{children:mr(a.created_at)}),o.jsx("span",{children:a.mode})]}),o.jsxs("div",{className:"autoruns-run-meta",children:["id=",a.generation_id," | count=",a.count]}),o.jsxs("div",{className:"autoruns-run-meta",children:["домен=",a.domain??"общий",a.generated_by?` | автор=${a.generated_by}`:""]}),a.saved_case_set_file?o.jsxs("div",{className:"autoruns-run-meta",children:["кейс-сет=",a.saved_case_set_file]}):null,(a.questions??[]).length>0?o.jsx("p",{children:a.questions[0]}):null]},a.generation_id))]}),o.jsxs("details",{className:"autoruns-prompt-details",children:[o.jsx("summary",{children:"Копия активного промпта (только чтение)"}),o.jsxs("label",{children:["Системный",o.jsx("textarea",{readOnly:!0,value:h.systemPrompt})]}),o.jsxs("label",{children:["Разработчика",o.jsx("textarea",{readOnly:!0,value:h.developerPrompt})]}),o.jsxs("label",{children:["Доменный",o.jsx("textarea",{readOnly:!0,value:h.domainPrompt})]}),o.jsxs("label",{children:["Заметки по схеме",o.jsx("textarea",{readOnly:!0,value:h.schemaNotes})]}),o.jsxs("label",{children:["Примеры few-shot",o.jsx("textarea",{readOnly:!0,value:h.fewShotExamples})]})]}),Xt?o.jsx("p",{className:"error-text",children:Xt}):null]}),o.jsxs("section",{className:"autoruns-col",children:[o.jsx("div",{className:"autoruns-col-header",children:o.jsx("h3",{children:"Выдача прогонов"})}),o.jsxs("div",{className:"autoruns-stats-grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Всего"}),o.jsx("strong",{children:(re?.stats.runs_total??0)+(Z?1:0)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Средний score"}),o.jsx("strong",{children:Go(re?.stats.avg_score_index??null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Тренд"}),o.jsx("strong",{children:re?wc(re.stats.trend):"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Блокеры"}),o.jsx("strong",{children:re?.stats.blocking_runs??0})]})]}),o.jsxs("div",{className:"autoruns-run-list",children:[Rn.map(a=>o.jsxs("button",{type:"button",className:ge===a.run_id?"autoruns-run-item selected":"autoruns-run-item",onClick:()=>{Ht(a.run_id)},children:[o.jsxs("div",{className:"autoruns-run-head",children:[o.jsx("strong",{children:mr(a.run_timestamp)}),o.jsx("span",{children:Uf(a.eval_target)})]}),o.jsx("div",{className:"autoruns-run-meta",children:a.run_id}),o.jsxs("div",{className:"autoruns-run-meta",children:["режим=",a.mode??"нет данных"," | mock=",String(a.use_mock)]}),o.jsxs("div",{className:"autoruns-run-meta",children:["analysis_date=",a.analysis_date??"current_state"]}),a.llm_provider||a.model?o.jsxs("div",{className:"autoruns-run-meta",children:["llm=",a.llm_provider??"нет данных"," | модель=",a.model??"нет данных"]}):null,o.jsxs("div",{className:"autoruns-run-meta",children:["промпт=",a.prompt_version??"нет данных"]}),o.jsxs("div",{className:"autoruns-run-foot",children:[o.jsxs("span",{children:["оценка: ",Go(a.score_index)]}),o.jsxs("span",{children:["закрыто/открыто: ",a.closed_cases,"/",a.open_cases]})]}),o.jsxs("div",{className:"autoruns-run-foot",children:[o.jsxs("span",{children:["блокеры: ",a.blocking_failures]}),o.jsxs("span",{children:["качество: ",a.quality_failures]})]})]},a.run_id)),Rn.length===0?o.jsx("p",{className:"muted",children:"За выбранный диапазон прогонов нет."}):null]})]}),o.jsxs("section",{className:"autoruns-col",children:[o.jsxs("div",{className:"autoruns-col-header",children:[o.jsx("h3",{children:"Диалог прогона"}),o.jsxs("div",{className:"autoruns-dialog-toolbar",children:[o.jsxs("label",{children:["Прогон",o.jsx("select",{value:ge,onChange:a=>{const g=a.target.value;Ht(g)},children:Rn.map(a=>o.jsxs("option",{value:a.run_id,children:[mr(a.run_timestamp)," | ",a.run_id]},a.run_id))})]}),o.jsxs("label",{children:["Кейс",o.jsxs("select",{value:fe,onChange:a=>{const g=a.target.value;T(g),ge&&g&&Bt(ge,g)},children:[(te?.cases.length??0)>0?o.jsx("option",{value:lt,children:"ВСЕ кейсы подряд"}):null,(te?.cases??[]).map(a=>o.jsxs("option",{value:a.case_id,children:[a.case_id," | ",a.status]},a.case_id))]})]})]})]}),o.jsxs("div",{className:"autoruns-case-list",children:[(te?.cases.length??0)>0?o.jsxs("button",{type:"button",className:fe===lt?"autoruns-case-item selected":"autoruns-case-item",onClick:()=>{T(lt),ge&&Bt(ge,lt)},children:[o.jsx("span",{children:"ВСЕ кейсы подряд"}),o.jsx("span",{children:te?.cases.length})]},lt):null,(te?.cases??[]).map(a=>o.jsxs("button",{type:"button",className:fe===a.case_id?"autoruns-case-item selected":"autoruns-case-item",onClick:()=>{T(a.case_id),ge&&Bt(ge,a.case_id)},children:[o.jsx("span",{children:a.case_id}),o.jsxs("span",{children:[a.status,a.commented_count>0?` | комм=${a.commented_count}`:""]})]},a.case_id))]}),o.jsxs("div",{className:"autoruns-dialog-view",children:[Hn||Bn?o.jsx("p",{className:"muted",children:"Загружаю диалог..."}):null,!Hn&&!Bn&&(b?.messages.length??0)===0?o.jsx("p",{className:"muted",children:"Диалог для этого прогона не найден."}):null,(b?.messages??[]).map((a,g)=>{const w=a.role==="assistant"?"assistant":"user";return o.jsxs("article",{className:`autoruns-msg ${w}`,children:[o.jsxs("header",{children:[o.jsx("strong",{children:w==="assistant"?"Система":"Модель/вопрос"}),o.jsxs("div",{className:"autoruns-msg-head-actions",children:[a.case_id?o.jsx("span",{className:"autoruns-msg-case-tag",children:a.case_id}):null,o.jsx("span",{children:a.created_at?mr(a.created_at):"нет данных"}),w==="assistant"&&!us(ge)?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:a.commented?"autoruns-comment-icon commented":"autoruns-comment-icon",onClick:()=>pe(a),title:"\\u041a\\u043e\\u043c\\u043c\\u0435\\u043d\\u0442\\u0438\\u0440\\u043e\\u0432\\u0430\\u0442\\u044c \\u043e\\u0442\\u0432\\u0435\\u0442 \\u0441\\u0438\\u0441\\u0442\\u0435\\u043c\\u044b","aria-label":"\\u041a\\u043e\\u043c\\u043c\\u0435\\u043d\\u0442\\u0438\\u0440\\u043e\\u0432\\u0430\\u0442\\u044c \\u043e\\u0442\\u0432\\u0435\\u0442 \\u0441\\u0438\\u0441\\u0442\\u0435\\u043c\\u044b",children:o.jsx(Hf,{commented:a.commented})}),a.annotation?o.jsx("button",{type:"button",className:a.annotation.resolved?"autoruns-resolve-toggle resolved":"autoruns-resolve-toggle",onClick:()=>{Sr(a.annotation,!a.annotation.resolved)},disabled:Vn===a.annotation.annotation_id,title:a.annotation.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный","aria-label":a.annotation.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный",children:o.jsx(Nc,{resolved:a.annotation.resolved})}):null]}):null]})]}),o.jsx("p",{children:a.text}),w==="assistant"&&a.annotation?o.jsxs("div",{className:"autoruns-msg-annotation",children:[o.jsx("strong",{children:jc(a.annotation.rating)}),o.jsx("span",{children:a.annotation.comment}),o.jsxs("span",{className:"muted",children:[a.annotation.manual_case_decision,a.annotation.annotation_author?` | ${a.annotation.annotation_author}`:""]})]}):null,(a.trace_id||a.reply_type)&&o.jsxs("footer",{children:[a.trace_id?o.jsxs("span",{children:["trace=",a.trace_id]}):null,a.reply_type?o.jsxs("span",{children:["reply_type=",a.reply_type]}):null]})]},a.message_id??`${w}-${g}`)})]})]}),P?o.jsx("div",{className:"autoruns-col autoruns-assistant-live-col",children:o.jsx(Ac,{sessionId:fn,conversation:Or,inputValue:mn,onInputChange:$t,useMock:hn,onUseMockChange:gn,onSend:xr,onClear:yr,busy:Zt,statusText:hr,errorMessage:Qn})}):null,z?o.jsxs("section",{className:"autoruns-col",children:[o.jsx("div",{className:"autoruns-col-header",children:o.jsx("h3",{children:"Режим декомпозиции"})}),o.jsxs("div",{className:"autoruns-meta-list",children:[o.jsxs("div",{children:[o.jsx("span",{children:"кейс:"}),o.jsx("strong",{children:vn?.case_id??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"домен:"}),o.jsx("strong",{children:vn?.domain??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"класс запроса:"}),o.jsx("strong",{children:vn?.query_class??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"trace:"}),o.jsx("strong",{children:vn?.trace_id??"нет данных"})]})]}),o.jsx("h4",{children:"Шаги декомпозиции"}),(b?.decomposition.length??0)>0?o.jsx("ol",{className:"autoruns-decomposition-list",children:(b?.decomposition??[]).map((a,g)=>o.jsx("li",{children:a},`${g}-${a.slice(0,24)}`))}):o.jsx("p",{className:"muted",children:"В логах кейса нет явной декомпозиции."})]}):null,K?o.jsxs("section",{className:"autoruns-col",children:[o.jsx("div",{className:"autoruns-col-header",children:o.jsx("h3",{children:"Прогресс / регресс"})}),o.jsxs("div",{className:"autoruns-stats-grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Последний score"}),o.jsx("strong",{children:Go(re?.stats.latest_score_index??null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Предыдущий"}),o.jsx("strong",{children:Go(re?.stats.previous_score_index??null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Тренд"}),o.jsx("strong",{children:re?wc(re.stats.trend):"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Пробелы качества"}),o.jsx("strong",{children:re?.stats.quality_gap_runs??0})]})]}),o.jsx("h4",{children:"Покрытие доменов (история)"}),kc(re?.stats.domain_coverage??[]),o.jsx("h4",{style:{marginTop:14},children:"Покрытие доменов (выбранный прогон)"}),kc(te?.coverage.domain_coverage??[]),o.jsx("h4",{style:{marginTop:14},children:"Очереди фиксов пост-анализа"}),It?o.jsx("p",{className:"muted",children:"Собираю пост-анализ..."}):null,It?null:o.jsx("div",{className:"autoruns-stats-grid",children:Object.entries(jt?.post_analysis.stats.by_queue??{}).map(([a,g])=>o.jsxs("div",{children:[o.jsx("span",{children:a}),o.jsx("strong",{children:g})]},a))}),o.jsxs("div",{className:"autoruns-autogen-list",children:[(jt?.post_analysis.recommended_regression_candidates??[]).slice(0,12).map(a=>o.jsxs("article",{className:"autoruns-autogen-item",children:[o.jsxs("header",{children:[o.jsx("strong",{children:a.manual_case_decision}),o.jsxs("span",{children:[a.rating,"/5"]})]}),o.jsxs("div",{className:"autoruns-run-meta",children:[a.domain??"неизвестно"," / ",a.query_class??"неизвестно"]}),o.jsx("p",{children:a.comment})]},a.annotation_id)),!It&&(jt?.post_analysis.recommended_regression_candidates.length??0)===0?o.jsx("p",{className:"muted",children:"Рекомендованных кандидатов пока нет."}):null]})]}):null,ee?o.jsxs("section",{className:"autoruns-col",children:[o.jsx("div",{className:"autoruns-col-header",children:o.jsx("h3",{children:"Комментарии"})}),o.jsx("h4",{children:"Размеченные ответы"}),o.jsxs("div",{className:"autoruns-comment-filter-row",children:[o.jsxs("label",{children:["Фильтр решений",o.jsxs("select",{value:Ce,onChange:a=>Ae(a.target.value),children:[o.jsx("option",{value:"all",children:"все"}),(at.length>0?at:Ze?.enum??[]).map(a=>o.jsx("option",{value:a,children:String(Ze?.labels?.[a]??a)},a))]})]}),o.jsx("button",{type:"button",className:"tab autoruns-resolved-filter-toggle",onClick:()=>Qe(a=>!a),children:$e?"Показать выполненные":"Скрыть выполненные"})]}),o.jsxs("div",{className:"autoruns-stats-grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Комментариев"}),o.jsx("strong",{children:Be.length})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Средний рейтинг"}),o.jsx("strong",{children:vr===null?"нет данных":`${vr.toFixed(2)} / 5`})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Последний"}),o.jsx("strong",{children:Be.length>0?mr(Be[0].updated_at):"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Статус"}),o.jsx("strong",{children:Dt?"обновляю":"готово"})]})]}),o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",disabled:Dt,onClick:()=>{Tn()},children:Dt?"Обновляю...":"Обновить список"}),o.jsx("button",{type:"button",className:"tab",disabled:It,onClick:()=>{dt()},children:It?"Идет пост-анализ...":"Обновить пост-анализ"})]}),o.jsxs("div",{className:"autoruns-comments-list",children:[Dt?o.jsx("p",{className:"muted",children:"Загружаю комментарии..."}):null,!Dt&&Be.length===0?o.jsx("p",{className:"muted",children:Se.length===0?"Пока нет откомментированных ответов.":"Нет открытых кейсов по текущему фильтру."}):null,Be.map(a=>o.jsxs("article",{className:We===a.annotation_id?"autoruns-comment-item selected":"autoruns-comment-item",onClick:()=>{wr(a)},role:"button",tabIndex:0,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),wr(a))},children:[o.jsxs("div",{className:"autoruns-comment-head",children:[o.jsx("strong",{children:jc(a.rating)}),o.jsxs("div",{className:"autoruns-comment-head-actions",children:[o.jsx("span",{children:mr(a.updated_at)}),o.jsx("button",{type:"button",className:a.resolved?"autoruns-resolve-toggle resolved":"autoruns-resolve-toggle",onClick:g=>{g.preventDefault(),g.stopPropagation(),Sr(a,!a.resolved)},disabled:Vn===a.annotation_id,title:a.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный","aria-label":a.resolved?"Отметить кейс как невыполненный":"Отметить кейс как выполненный",children:o.jsx(Nc,{resolved:a.resolved})})]})]}),o.jsx("div",{className:"autoruns-run-meta",children:a.run_id}),o.jsxs("div",{className:"autoruns-run-meta",children:["case=",a.case_id," | msg=",a.message_index]}),o.jsxs("div",{className:"autoruns-run-meta",children:["decision=",a.manual_case_decision,a.annotation_author?` | author=${a.annotation_author}`:""]}),a.resolved_at?o.jsxs("div",{className:"autoruns-run-meta",children:["выполнено",": ",mr(a.resolved_at),a.resolved_by?` | by=${a.resolved_by}`:""]}):null,a.context.question_text?o.jsxs("p",{children:["Q: ",a.context.question_text]}):null,a.context.answer_text?o.jsxs("p",{children:["A: ",a.context.answer_text]}):null,o.jsx("p",{children:a.comment})]},a.annotation_id))]}),je?o.jsxs(o.Fragment,{children:[o.jsx("h4",{children:"Тех-контекст брака"}),o.jsxs("div",{className:"autoruns-meta-list",children:[o.jsxs("div",{children:[o.jsx("span",{children:"trace:"}),o.jsx("strong",{children:je.technical_context.trace_id??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"reply_type:"}),o.jsx("strong",{children:je.technical_context.reply_type??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"domain:"}),o.jsx("strong",{children:je.technical_context.domain??"нет данных"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"query_class:"}),o.jsx("strong",{children:je.technical_context.query_class??"нет данных"})]})]}),o.jsx("h4",{children:"JSON разбор"}),o.jsx(Mt,{value:{annotation_id:je.annotation_id,run_id:je.run_id,case_id:je.case_id,message_index:je.message_index,rating:je.rating,comment:je.comment,manual_case_decision:je.manual_case_decision,annotation_author:je.annotation_author,resolved:je.resolved,resolved_at:je.resolved_at,resolved_by:je.resolved_by,context:je.context,technical_context:je.technical_context,case_summary:je.case_summary?{case_id:je.case_summary.case_id,domain:je.case_summary.domain,query_class:je.case_summary.query_class,checks:je.case_summary.checks,metric_subscores:je.case_summary.metric_subscores}:null}})]}):null]}):null]}),ie.open?o.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:a=>{a.target===a.currentTarget&&Ur()},children:o.jsxs("div",{className:"autoruns-comment-modal",children:[o.jsx("h3",{children:"Комментарий к ответу системы"}),o.jsx("p",{className:"muted",children:"Оцените ответ по 5-балльной шкале и добавьте комментарий по браку."}),Pn?o.jsxs(o.Fragment,{children:[o.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[o.jsx("summary",{children:"Вопрос пользователя"}),o.jsx("p",{className:"autoruns-comment-quote",children:Ut?.text??"Вопрос в диалоге не найден."})]}),o.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[o.jsx("summary",{children:"Ответ системы"}),o.jsx("p",{className:"autoruns-comment-quote",children:Pn.text})]})]}):null,o.jsx("div",{className:"autoruns-rating-row",role:"group","aria-label":"Рейтинг ответа",children:[1,2,3,4,5].map(a=>o.jsx("button",{type:"button",className:ie.rating>=a?"autoruns-rating-dot active":"autoruns-rating-dot",onClick:()=>Ke(g=>({...g,rating:a})),disabled:ie.saving,"aria-label":`Оценка ${a}`,children:ie.rating>=a?"●":"○"},a))}),o.jsxs("div",{className:"autoruns-form-grid",children:[o.jsxs("label",{children:["Решение по кейсу",o.jsx("select",{value:ie.manualCaseDecision,onChange:a=>Ke(g=>({...g,manualCaseDecision:a.target.value})),disabled:ie.saving,children:(at.length>0?at:Ze?.enum??[Ko]).map(a=>o.jsx("option",{value:a,children:String(Ze?.labels?.[a]??a)},a))})]}),o.jsxs("label",{children:["Автор комментария",o.jsx("input",{value:ie.annotationAuthor,onChange:a=>Ke(g=>({...g,annotationAuthor:a.target.value})),placeholder:"manual_reviewer",disabled:ie.saving})]})]}),o.jsxs("label",{children:["Комментарий",o.jsx("textarea",{value:ie.comment,onChange:a=>Ke(g=>({...g,comment:a.target.value})),placeholder:"Почему ответ бракованный, что именно пошло не так, какие технические детали проверить.",rows:4,disabled:ie.saving})]}),ie.error?o.jsx("p",{className:"error-text",children:ie.error}):null,o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",onClick:()=>{Yo()},disabled:ie.saving,children:ie.saving?"Сохраняю...":"Готово"}),o.jsx("button",{type:"button",className:"tab",onClick:()=>Ur(),disabled:ie.saving,children:"Отмена"})]})]})}):null]})}function Ec({value:i,modelOptions:h,modelsBusy:p,onChange:D,onReloadModels:P,onTestConnection:z,onSaveLocalConfig:K,lastStatus:ee,busy:U}){const M=i.llmProvider==="local",G=h.includes(i.model),[L,H]=S.useState(String(i.temperature)),[re,Ee]=S.useState(String(i.maxOutputTokens));S.useEffect(()=>{H(String(i.temperature))},[i.temperature]),S.useEffect(()=>{Ee(String(i.maxOutputTokens))},[i.maxOutputTokens]);const te=b=>{const oe=b.replace(",",".").trim();if(!oe){H(String(i.temperature));return}const Se=Number(oe);if(!Number.isFinite(Se)){H(String(i.temperature));return}D({...i,temperature:Se}),H(String(Se))},se=b=>{const oe=b.trim();if(!oe){Ee(String(i.maxOutputTokens));return}const Se=Number.parseInt(oe,10);if(!Number.isFinite(Se)||Se<=0){Ee(String(i.maxOutputTokens));return}D({...i,maxOutputTokens:Se}),Ee(String(Se))};return o.jsxs(jn,{title:"LLM Connection",subtitle:"Switch between OpenAI cloud and local OpenAI-compatible server.",actions:o.jsx("span",{className:"status-chip",children:ee||"Status: not checked"}),children:[o.jsxs("div",{className:"grid-two",children:[o.jsxs("label",{children:["Provider",o.jsxs("select",{value:i.llmProvider,onChange:b=>{const oe=b.target.value==="local"?"local":"openai";D({...i,llmProvider:oe,baseUrl:oe==="local"?"http://127.0.0.1:1234/v1":"https://api.openai.com/v1"})},children:[o.jsx("option",{value:"openai",children:"OpenAI (token)"}),o.jsx("option",{value:"local",children:"Local (LM Studio / OpenAI-compatible)"})]})]}),o.jsxs("label",{children:["Model",o.jsxs("select",{value:G?i.model:"__manual__",onChange:b=>{const oe=b.target.value;oe!=="__manual__"&&D({...i,model:oe})},children:[o.jsx("option",{value:"__manual__",children:"Manual input"}),h.map(b=>o.jsx("option",{value:b,children:b},b))]})]}),o.jsxs("label",{children:["Model ID (manual)",o.jsx("input",{value:i.model,onChange:b=>D({...i,model:b.target.value}),placeholder:"qwen2.5-14b-instruct or lmstudio loaded model id"})]}),M?null:o.jsxs("label",{className:"full-width",children:["OpenAI API Key",o.jsx("input",{type:"password",value:i.apiKey,onChange:b=>D({...i,apiKey:b.target.value}),placeholder:"sk-..."})]}),o.jsxs("label",{className:M?"full-width":void 0,children:[M?"Local server base URL":"Base URL",o.jsx("input",{value:i.baseUrl,onChange:b=>D({...i,baseUrl:b.target.value}),placeholder:M?"http://127.0.0.1:1234/v1":"https://api.openai.com/v1"})]}),o.jsxs("label",{children:["Temperature",o.jsx("input",{type:"number",step:"0.1",value:L,onChange:b=>H(b.target.value),onBlur:b=>te(b.target.value),onKeyDown:b=>{b.key==="Enter"&&te(b.target.value)}})]}),o.jsxs("label",{children:["Max output tokens",o.jsx("input",{type:"number",value:re,onChange:b=>Ee(b.target.value),onBlur:b=>se(b.target.value),onKeyDown:b=>{b.key==="Enter"&&se(b.target.value)}})]})]}),o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",onClick:()=>K(),children:"Save local config"}),o.jsx("button",{type:"button",onClick:()=>P(),disabled:U||p,children:p?"Loading models...":"Load model list"}),o.jsx("button",{type:"button",onClick:()=>z(),disabled:U,children:U?"Checking...":"Test connection"})]})]})}function Qf({items:i,onRefresh:h,onOpenTrace:p}){return o.jsx(jn,{title:"История нормализаций",subtitle:"Короткий вопрос, confidence, route hint и статус валидации.",actions:o.jsx("button",{type:"button",onClick:()=>h(),children:"Обновить"}),children:o.jsxs("div",{className:"history-list",children:[i.length===0?o.jsx("p",{className:"muted",children:"История пока пустая."}):null,i.map(D=>o.jsxs("button",{type:"button",className:"history-item",onClick:()=>p(D.trace_id),children:[o.jsxs("div",{className:"history-row",children:[o.jsx("strong",{children:D.route_hint??"route: n/a"}),o.jsx("span",{children:D.validation_passed?"schema: ok":"schema: fail"})]}),o.jsx("p",{children:D.question_short}),o.jsxs("div",{className:"history-row",children:[o.jsx("span",{children:D.model}),o.jsx("span",{children:new Date(D.timestamp).toLocaleString("ru-RU")})]})]},D.trace_id))]})})}function Fn(i){return i==null||i===""?"—":String(i)}function Wf({result:i}){return o.jsx(jn,{title:"Runtime метрики",subtitle:"trace_id, токены, latency и статус валидации.",children:o.jsxs("div",{className:"metrics-grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"trace_id"}),o.jsx("strong",{children:Fn(i?.trace_id)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"request_started_at"}),o.jsx("strong",{children:Fn(i?new Date(Date.now()-i.latency_ms).toISOString():null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"request_finished_at"}),o.jsx("strong",{children:Fn(i?new Date().toISOString():null)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"latency_ms"}),o.jsx("strong",{children:Fn(i?.latency_ms)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"input_tokens"}),o.jsx("strong",{children:Fn(i?.usage?.input_tokens)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"output_tokens"}),o.jsx("strong",{children:Fn(i?.usage?.output_tokens)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"total_tokens"}),o.jsx("strong",{children:Fn(i?.usage?.total_tokens)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"validation_status"}),o.jsx("strong",{children:i?.validation?.passed?"passed":"failed"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"prompt_version"}),o.jsx("strong",{children:Fn(i?.prompt_version)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"schema_version"}),o.jsx("strong",{children:Fn(i?.schema_version)})]})]})})}const Kf={normalized:"Normalized JSON",fragments:"Fragment View",scope:"Scope View",flags:"Flags View",route:"Route Simulation",raw:"Raw model output",validation:"Validation",logs:"Logs"};function qf(i){return i&&typeof i=="object"?i:null}function Gf({tab:i,onTabChange:h,result:p,appLogs:D}){const P=["normalized","fragments","scope","flags","route","raw","validation","logs"],z=qf(p?.normalized),K=String(z?.schema_version??""),ee=K==="normalized_query_v2"||K==="normalized_query_v2_0_1"||K==="normalized_query_v2_0_2",U=ee?{fragments:z?.fragments??[],discarded_fragments:z?.discarded_fragments??[]}:{note:"Fragment View доступен для normalized_query_v2."},M=ee?{message_in_scope:z?.message_in_scope??null,scope_confidence:z?.scope_confidence??null,contains_multiple_tasks:z?.contains_multiple_tasks??null,global_notes:z?.global_notes??null}:{note:"Scope View доступен для normalized_query_v2."},G=ee?Array.isArray(z?.fragments)?(z?.fragments).map(L=>({fragment_id:L.fragment_id??null,domain_relevance:L.domain_relevance??null,candidate_labels:L.candidate_labels??[],execution_readiness:L.execution_readiness??null,clarification_reason:L.clarification_reason??null,soft_assumption_used:L.soft_assumption_used??[],route_status:L.route_status??null,no_route_reason:L.no_route_reason??null,flags:L.flags??{}})):[]:{note:"Flags View доступен для normalized_query_v2."};return o.jsxs(jn,{title:"Выходные данные",subtitle:"Structured output и диагностические вкладки.",children:[o.jsx("div",{className:"tab-row",children:P.map(L=>o.jsx("button",{type:"button",className:i===L?"tab active":"tab",onClick:()=>h(L),children:Kf[L]},L))}),i==="normalized"?o.jsx(Mt,{value:p?.normalized??{note:"Нет данных."}}):null,i==="fragments"?o.jsx(Mt,{value:U}):null,i==="scope"?o.jsx(Mt,{value:M}):null,i==="flags"?o.jsx(Mt,{value:G}):null,i==="route"?o.jsx(Mt,{value:p?.route_hint_summary??{note:"Нет данных."}}):null,i==="raw"?o.jsx(Mt,{value:p?.raw_model_output??{note:"Нет данных."}}):null,i==="validation"?o.jsx(Mt,{value:p?.validation??{note:"Нет данных."}}):null,i==="logs"?o.jsx(Mt,{value:D}):null]})}function Pc({value:i,onChange:h,presets:p,selectedPresetId:D,onSelectPreset:P,onLoadPreset:z,onSavePreset:K,onResetDefaults:ee,onDiffPrevious:U,presetName:M,onPresetNameChange:G,diffSummary:L}){return o.jsxs(jn,{title:"Prompt Manager",subtitle:"Системный, developer и domain уровни управляются отдельно.",children:[o.jsxs("div",{className:"prompt-manager-grid",children:[o.jsxs("label",{children:["Системный prompt",o.jsx("textarea",{value:i.systemPrompt,onChange:H=>h({...i,systemPrompt:H.target.value}),rows:6})]}),o.jsxs("label",{children:["Developer / Instruction prompt",o.jsx("textarea",{value:i.developerPrompt,onChange:H=>h({...i,developerPrompt:H.target.value}),rows:6})]}),o.jsxs("label",{children:["Domain prompt",o.jsx("textarea",{value:i.domainPrompt,onChange:H=>h({...i,domainPrompt:H.target.value}),rows:6})]}),o.jsxs("label",{children:["Schema notes",o.jsx("textarea",{value:i.schemaNotes,onChange:H=>h({...i,schemaNotes:H.target.value}),rows:6})]}),o.jsxs("label",{className:"full-width",children:["Few-shot examples",o.jsx("textarea",{value:i.fewShotExamples,onChange:H=>h({...i,fewShotExamples:H.target.value}),rows:8})]})]}),o.jsxs("div",{className:"button-row",children:[o.jsxs("select",{value:D,onChange:H=>P(H.target.value),children:[o.jsx("option",{value:"",children:"Выберите preset..."}),p.map(H=>o.jsx("option",{value:H.id,children:H.name},H.id))]}),o.jsx("button",{type:"button",onClick:()=>z(),children:"Загрузить preset"}),o.jsx("input",{value:M,onChange:H=>G(H.target.value),placeholder:"Имя для сохранения"}),o.jsx("button",{type:"button",onClick:()=>K(),children:"Сохранить preset"}),o.jsx("button",{type:"button",onClick:()=>U(),children:"Diff с предыдущим"}),o.jsx("button",{type:"button",onClick:()=>ee(),children:"Сбросить к default"})]}),L?o.jsx("p",{className:"diff-summary",children:L}):null]})}function bf({value:i,onChange:h,onApplyBatchFormat:p,onNormalize:D,busy:P,useMock:z,onUseMockChange:K,errorMessage:ee}){return o.jsxs(jn,{title:"Запрос пользователя",subtitle:"NDC semantic front-end: нормализуем, но не отвечаем за бухгалтерскую суть.",children:[o.jsxs("div",{className:"grid-two",children:[o.jsxs("label",{className:"full-width",children:["Raw user question",o.jsx("textarea",{value:i.userQuestion,onChange:U=>h({...i,userQuestion:U.target.value}),rows:6,placeholder:"Например: По каким покупателям у нас на конец июня висят отгрузки без оплаты..."})]}),o.jsxs("label",{className:"full-width",children:["Batch queries (`;` separator)",o.jsx("textarea",{value:i.batchQuestionsRaw,onChange:U=>h({...i,batchQuestionsRaw:U.target.value}),onBlur:()=>p(),rows:8,placeholder:"Вопрос 1; Вопрос 2; Вопрос 3"})]}),o.jsxs("label",{children:["Optional period context",o.jsx("input",{value:i.periodHint,onChange:U=>h({...i,periodHint:U.target.value})})]}),o.jsxs("label",{children:["Optional business context",o.jsx("input",{value:i.businessContext,onChange:U=>h({...i,businessContext:U.target.value})})]}),o.jsxs("label",{children:["Optional expected route (eval)",o.jsx("input",{value:i.expectedRoute,onChange:U=>h({...i,expectedRoute:U.target.value})})]})]}),o.jsxs("div",{className:"button-row",children:[o.jsxs("label",{className:"checkbox-row",children:[o.jsx("input",{type:"checkbox",checked:z,onChange:U=>K(U.target.checked)}),"Mock-режим (без вызова OpenAI)"]}),o.jsx("button",{type:"button",onClick:()=>p(),disabled:P||!i.batchQuestionsRaw.trim(),children:"Применить `;` в переносы"}),o.jsx("button",{type:"button",onClick:()=>D(!1),disabled:P||!i.userQuestion.trim(),children:P?"Нормализуем...":"Normalize"}),o.jsx("button",{type:"button",onClick:()=>D(!0),disabled:P||!i.userQuestion.trim(),children:P?"Сохраняем...":"Normalize + Save as test case"})]}),ee?o.jsx("p",{className:"error-text",children:ee}):null]})}function Jf({runs:i,selectedRunId:h,onSelectRun:p,onStartRun:D,onFinishRun:P,onRefreshRuns:z,onRunEval:K,onCopyEvalReport:ee,evalBusy:U,traceItems:M,evalReport:G}){return o.jsxs(jn,{title:"NDC Run Monitor",subtitle:"Важно: кнопка Запустить run создает только run-сущность. Кнопка eval запускает batch-проверку normalizer v2.0.2.",children:[o.jsxs("div",{className:"button-row",children:[o.jsx("button",{type:"button",onClick:()=>D(),children:"Запустить run"}),o.jsx("button",{type:"button",onClick:()=>P(),disabled:!h,children:"Завершить выбранный run"}),o.jsx("button",{type:"button",onClick:()=>z(),children:"Обновить runs"}),o.jsx("button",{type:"button",onClick:()=>K(),disabled:U,children:U?"Идет eval v2.0.2...":"Запустить eval v2.0.2"})]}),o.jsxs("div",{className:"runtime-stack",children:[o.jsxs("div",{className:"runtime-runs",children:[i.map(L=>o.jsxs("button",{type:"button",className:h===L.runId?"history-item selected":"history-item",onClick:()=>p(L.runId),children:[o.jsxs("div",{className:"history-row",children:[o.jsx("strong",{children:L.status}),o.jsx("span",{children:L.runId})]}),o.jsxs("div",{className:"history-row",children:[o.jsx("span",{children:L.sessionId}),o.jsx("span",{children:new Date(L.updatedAt).toLocaleString("ru-RU")})]})]},L.runId)),i.length===0?o.jsx("p",{className:"muted",children:"Нет активных запусков."}):null]}),o.jsxs("div",{className:"runtime-details",children:[o.jsx("h3",{children:"Trace выбранного run"}),o.jsx(Mt,{value:M}),o.jsxs("div",{className:"eval-report-wrap",children:[o.jsx("h3",{style:{marginTop:12},children:"Отчет eval"}),o.jsx(Mt,{value:G??{note:"Eval пока не запускался"}}),o.jsx("button",{type:"button",className:"copy-cube-button",title:"Скопировать отчет eval",onClick:()=>ee(),children:"⧉"})]})]})]})]})}const Yf={llmProvider:"openai",apiKey:"",model:"gpt-4o-mini",baseUrl:"https://api.openai.com/v1",temperature:0,maxOutputTokens:700},Rc={systemPrompt:"Ты semantic-normalizer для бухгалтерского ассистента NDC. Возвращай только JSON по схеме normalized_query_v2_0_2.",developerPrompt:"Сначала делай decomposition сообщения на task fragments, затем определяй domain scope и route-critical flags. Для каждого fragment заполняй execution_readiness + route_status + no_route_reason. Если fragment routable, не оставляй его в no_route.",domainPrompt:"Контур: данные текущего предприятия в 1С/NDC. In-scope: документы, проводки, взаиморасчеты, остатки, периодное закрытие, аномалии и контрольные проверки. Out-of-scope: общая теория, законы и оффтоп.",schemaNotes:"schema_version: normalized_query_v2_0_2. Строгий JSON без дополнительных полей.",fewShotExamples:"Q: Проверь по поставщикам хвосты и разложи цепочку документов/оплат. => fragment in_scope, flags: multi_entity + chain_explanation. Q: Как вообще по ФСБУ? => out_of_scope/generic_accounting."},Xf={userQuestion:"",batchQuestionsRaw:"",periodHint:"",businessContext:"",expectedRoute:""},Oi={colors:{backgroundRgb:"18, 18, 18",mainSurfaceRgb:"25, 25, 25",horizontalSurfaceRgb:"30, 30, 30",focusSurfaceRgb:"35, 35, 35",activeRgb:"167, 59, 255",activeTextRgb:"240, 240, 240",textMainRgb:"240, 240, 240",textMutedRgb:"166, 166, 166",dangerRgb:"126, 126, 126",scrollbarTrackRgb:"20, 20, 20",scrollbarThumbRgb:"30, 30, 30",scrollbarThumbHoverRgb:"30, 50, 30"},layout:{modeColumnWidthPx:406,modeToggleWidthPx:188}},Tc="ndc_normalizer_session_config_v1",Mc="ndc_autoruns_layout_config_v1",Zf="ndc-autoruns-save",zi=["Анализ запроса","Получение данных","Подготовка ответа"],ep="assistant",$i="normalizer_v2_0_2",Lc="address_query_runtime_v1",tp=["normalized","fragments","scope","flags","route","raw","validation","logs"];function np(i){return`[${new Date().toLocaleTimeString("ru-RU")}] ${i}`}function rp(i,h){if(!h)return"Previous preset is not selected.";const D=["systemPrompt","developerPrompt","domainPrompt","schemaNotes","fewShotExamples"].filter(P=>i[P]!==h[P]).map(P=>`${P}: ${Math.abs(i[P].length-h[P].length)} chars delta`);return D.length===0?"No changes against previous preset.":`Changed fields: ${D.length}. ${D.join(" | ")}`}function sp(){const[i,h]=S.useState(Yf),[p,D]=S.useState(Rc),[P,z]=S.useState(Xf),[K,ee]=S.useState(null),[U,M]=S.useState([]),[G,L]=S.useState([]),[H,re]=S.useState("normalized"),[Ee,te]=S.useState(!1),[se,b]=S.useState(!1),[oe,Se]=S.useState([]),[le,Ce]=S.useState(""),[Ae,$e]=S.useState([]),[Qe,Ze]=S.useState(""),[it,at]=S.useState("NDC custom preset"),[mt,We]=S.useState(null),[be,ge]=S.useState(""),[Ne,fe]=S.useState(!1),[T,Q]=S.useState([]),[A,d]=S.useState(""),[j,J]=S.useState([]),[ae,ue]=S.useState(!1),[ce,ve]=S.useState(null),[he,Z]=S.useState(""),[we,jt]=S.useState(ep),[kn,an]=S.useState(!0),[un,Un]=S.useState(!0),[Lt,It]=S.useState(!0),[Cn,Jt]=S.useState(!0),[kt,At]=S.useState(!0),[Yt,Bn]=S.useState(!0),[cn,Hn]=S.useState(!0),[dn,Dt]=S.useState(!0),[Ot,Vn]=S.useState(!0),[Ct,Xt]=S.useState(!0),[Fe,fn]=S.useState(!0),[pn,Or]=S.useState(!0),[zt,mn]=S.useState(!0),[$t,hn]=S.useState(!0),[gn,Zt]=S.useState(!0),[ht,hr]=S.useState(""),[en,Qn]=S.useState([]),[Nn,Wn]=S.useState(""),[Nt,gr]=S.useState(!1),[ut,ie]=S.useState(""),[Ke,En]=S.useState(""),ct=S.useRef(!1),Ft=S.useRef(!1);S.useEffect(()=>{const v=document.documentElement,{colors:I}=Oi;v.style.setProperty("--rgb-background",I.backgroundRgb),v.style.setProperty("--rgb-surface-main",I.mainSurfaceRgb),v.style.setProperty("--rgb-surface-horizontal",I.horizontalSurfaceRgb),v.style.setProperty("--rgb-surface-focus",I.focusSurfaceRgb),v.style.setProperty("--rgb-active",I.activeRgb),v.style.setProperty("--rgb-active-text",I.activeTextRgb),v.style.setProperty("--rgb-text-main",I.textMainRgb),v.style.setProperty("--rgb-text-muted",I.textMutedRgb),v.style.setProperty("--rgb-danger",I.dangerRgb),v.style.setProperty("--rgb-scrollbar-track",I.scrollbarTrackRgb),v.style.setProperty("--rgb-scrollbar-thumb",I.scrollbarThumbRgb),v.style.setProperty("--rgb-scrollbar-thumb-hover",I.scrollbarThumbHoverRgb),v.style.setProperty("--mode-column-width",`${Oi.layout.modeColumnWidthPx}px`),v.style.setProperty("--mode-toggle-width",`${Oi.layout.modeToggleWidthPx}px`)},[]);const q=v=>{L(I=>[np(v),...I].slice(0,300))};function vn(){let v=0;ie(zi[0]);const I=window.setInterval(()=>{v=Math.min(v+1,zi.length-1),ie(zi[v])},650);return()=>window.clearInterval(I)}S.useEffect(()=>{const v=localStorage.getItem(Tc);if(v)try{const N=JSON.parse(v);h(pe=>({...pe,llmProvider:N.llmProvider==="local"?"local":"openai",model:N.model??pe.model,baseUrl:N.baseUrl??pe.baseUrl,temperature:N.temperature??pe.temperature,maxOutputTokens:N.maxOutputTokens??pe.maxOutputTokens}))}catch{}const I=localStorage.getItem(Mc);if(I)try{const N=JSON.parse(I);(N.uiMode==="assistant"||N.uiMode==="decomposition"||N.uiMode==="autoruns")&&jt(N.uiMode),N.activeTab&&tp.includes(N.activeTab)&&re(N.activeTab),typeof N.showAutorunsAssistantMode=="boolean"&&an(N.showAutorunsAssistantMode),typeof N.showAutorunsDecompositionMode=="boolean"&&Un(N.showAutorunsDecompositionMode),typeof N.showAutorunsProgressMode=="boolean"&&It(N.showAutorunsProgressMode),typeof N.showAutorunsCommentsMode=="boolean"&&Jt(N.showAutorunsCommentsMode),typeof N.showAssistantConnectionMode=="boolean"&&At(N.showAssistantConnectionMode),typeof N.showAssistantPromptMode=="boolean"&&Bn(N.showAssistantPromptMode),typeof N.showAssistantChatMode=="boolean"&&Hn(N.showAssistantChatMode),typeof N.showAssistantSamMode=="boolean"&&Dt(N.showAssistantSamMode),typeof N.showDecompositionConnectionMode=="boolean"&&Vn(N.showDecompositionConnectionMode),typeof N.showDecompositionPromptMode=="boolean"&&Xt(N.showDecompositionPromptMode),typeof N.showDecompositionQueryMode=="boolean"&&fn(N.showDecompositionQueryMode),typeof N.showDecompositionOutputMode=="boolean"&&Or(N.showDecompositionOutputMode),typeof N.showDecompositionMetricsMode=="boolean"&&mn(N.showDecompositionMetricsMode),typeof N.showDecompositionHistoryMode=="boolean"&&hn(N.showDecompositionHistoryMode),typeof N.showDecompositionRuntimeMode=="boolean"&&Zt(N.showDecompositionRuntimeMode),N.prompts&&(D(pe=>({...pe,...N.prompts})),Ft.current=!0)}catch{}Be(),je(),Pn()},[]);async function Be(){try{const v=await Me.loadHistory();M(v.items??[])}catch(v){q(`History load error: ${v instanceof Error?v.message:String(v)}`)}}async function je(){try{const I=(await Me.loadPresets()).presets??[];if($e(I),Ft.current){ct.current=!0;return}if(ct.current)return;const N=I.find(pe=>pe.prompt_version===$i)??I.find(pe=>pe.id==="default-normalizer-v2_0_2");if(!N){ct.current=!0,q(`Preset autoload skipped: ${$i} not found.`);return}Ze(N.id),We(p),D({systemPrompt:N.systemPrompt,developerPrompt:N.developerPrompt,domainPrompt:N.domainPrompt,schemaNotes:N.schemaNotes??"",fewShotExamples:N.fewShotExamples??""}),ct.current=!0,q(`Preset autoloaded: ${N.name} (${N.prompt_version}).`)}catch(v){q(`Presets load error: ${v instanceof Error?v.message:String(v)}`)}}async function Pn(){try{const v=await Me.listRuns();Q(v.items??[])}catch(v){q(`Runs load error: ${v instanceof Error?v.message:String(v)}`)}}function Ut(){localStorage.setItem(Tc,JSON.stringify({model:i.model,llmProvider:i.llmProvider,baseUrl:i.baseUrl,temperature:i.temperature,maxOutputTokens:i.maxOutputTokens})),q("Local config saved (without API key).")}function vr(){localStorage.setItem(Mc,JSON.stringify({uiMode:we,activeTab:H,showAutorunsAssistantMode:kn,showAutorunsDecompositionMode:un,showAutorunsProgressMode:Lt,showAutorunsCommentsMode:Cn,showAssistantConnectionMode:kt,showAssistantPromptMode:Yt,showAssistantChatMode:cn,showAssistantSamMode:dn,showDecompositionConnectionMode:Ot,showDecompositionPromptMode:Ct,showDecompositionQueryMode:Fe,showDecompositionOutputMode:pn,showDecompositionMetricsMode:zt,showDecompositionHistoryMode:$t,showDecompositionRuntimeMode:gn,prompts:p})),window.dispatchEvent(new CustomEvent(Zf)),q("UI layout and prompts saved.")}async function Rn(){te(!0),Z("");try{const v=await Me.testConnection(i);v.provider==="local"?v.model_found===!0?(Ce(`LOCAL OK - ${v.model}`),q(`Local model is available: ${v.model} (catalog size=${v.models_count??"n/a"}).`)):v.model_found===!1?(Ce(`LOCAL OK, model not loaded - ${v.model}`),q(`Local server is reachable, but model '${v.model}' is not in loaded catalog. Use 'Load model list' and select one of loaded models.`)):(Ce(`LOCAL OK (model list unavailable) - ${v.model}`),q("Local server is reachable, but model catalog could not be verified.")):(Ce(`OPENAI OK - ${v.model}`),q(`OpenAI connection ok: ${v.model}`))}catch(v){const I=v instanceof Error?v.message:String(v);Ce("Connection error"),Z(`Test connection: ${I}`),q(`Test connection error: ${I}`)}finally{te(!1)}}async function de(){b(!0);try{const I=(await Me.listModels(i)).models??[];Se(I),I.length>0&&h(N=>N.model&&I.includes(N.model)?N:{...N,model:I[0]}),q(`Model catalog loaded (${i.llmProvider}): ${I.length} items.`)}catch(v){const I=v instanceof Error?v.message:String(v);q(`Load model list error: ${I}`)}finally{b(!1)}}S.useEffect(()=>{Se([])},[i.llmProvider,i.baseUrl]);async function zr(v){te(!0),Z("");try{const I=await Me.normalize({connection:i,prompts:p,promptVersion:"normalizer_v2_0_2",query:{userQuestion:P.userQuestion,periodHint:P.periodHint,businessContext:P.businessContext,expectedRoute:P.expectedRoute},saveAsTestCase:v,useMock:Ne});ee(I),re("normalized"),q(`Normalize done: trace=${I.trace_id}, validation=${I.validation.passed?"passed":"failed"}`),Be()}catch(I){const N=I instanceof Error?I.message:String(I);Z(`Normalize: ${N}`),q(`Normalize error: ${N}`)}finally{te(!1)}}function yr(){const v=Ae.find(I=>I.id===Qe);if(!v){q("Preset is not selected.");return}We(p),D({systemPrompt:v.systemPrompt,developerPrompt:v.developerPrompt,domainPrompt:v.domainPrompt,schemaNotes:v.schemaNotes??"",fewShotExamples:v.fewShotExamples??""}),q(`Preset loaded: ${v.name}`)}async function xr(){try{await Me.savePreset({name:it||"NDC preset",prompt_version:"normalizer_v2_0_2",systemPrompt:p.systemPrompt,developerPrompt:p.developerPrompt,domainPrompt:p.domainPrompt,schemaNotes:p.schemaNotes,fewShotExamples:p.fewShotExamples}),q("Preset saved."),await je()}catch(v){q(`Preset save error: ${v instanceof Error?v.message:String(v)}`)}}function Kn(){D(Rc),q("Prompt panel reset to defaults.")}function _r(){const v=rp(p,mt);ge(v),q(v)}function Tn(){const v=P.batchQuestionsRaw.split(";").map(I=>I.trim()).filter(Boolean).join(` `);v&&(z(I=>({...I,batchQuestionsRaw:v})),q("Batch field formatted: `;` converted to blank-line separators."))}async function _e(v){try{const N=(await Me.loadTrace(v)).trace,pe=N.parsed_normalized_json??null;ee({trace_id:String(N.trace_id??v),ok:!!N.validation_result?.passed,normalized:pe,route_hint_summary:N.route_hint_summary??(pe?{route_hint:pe.route_hint??null,confidence:pe.confidence?.route_hint??null}:null),raw_model_output:N.raw_model_response??{},validation:N.validation_result??{passed:!1,errors:["validation not found"]},usage:N.usage??{input_tokens:0,output_tokens:0,total_tokens:0},latency_ms:Number(N.latency_ms??0),prompt_version:String(N.prompt_version??"unknown"),schema_version:String(N.schema_version??"unknown")}),re("raw"),Z(""),q(`Trace opened: ${v}`)}catch(I){const N=I instanceof Error?I.message:String(I);Z(`Trace: ${N}`),q(`Trace open error ${v}: ${N}`)}}async function $r(){try{const v=await Me.startRun();d(v.run.runId),q(`Run started: ${v.run.runId}`),q("Tip: start run does not execute normalize by itself. Use 'Run eval v2.0.2' button."),await Pn()}catch(v){q(`Run start error: ${v instanceof Error?v.message:String(v)}`)}}async function dt(){if(A)try{await Me.finishRun(A),q(`Run finished: ${A}`),await Pn()}catch(v){q(`Run finish error: ${v instanceof Error?v.message:String(v)}`)}}async function Fr(){ue(!0),Z("");try{q("Starting eval in v2 contour.");const v=P.batchQuestionsRaw.trim()||P.userQuestion.trim();if(!v)throw new Error("Fill batch field or Raw user question first.");const I=await Me.runEval({connection:i,prompts:p,promptVersion:"normalizer_v2_0_2",mode:"single-pass-strict",rawQuestions:v,useMock:Ne});ve(I.report),q("Eval v2.0.2 run finished.");const N=I.report;if(N.run_id&&q(`Eval run id: ${N.run_id}`),N.metrics){const pe=N.metrics;q(`Eval metrics v2.0.2: schema=${pe.schema_validation_pass_rate??"n/a"}%, route_accuracy=${pe.route_resolution_accuracy??"n/a"}%, no_route_precision=${pe.no_route_precision??"n/a"}%, state_consistency=${pe.execution_state_consistency_rate??"n/a"}%`)}await Be()}catch(v){const I=v instanceof Error?v.message:String(v);I.includes("Legacy eval runner supports normalized_query_v1 only")?(ve({status:"plan_only",prompt_version:"normalizer_v2",reason:"backend eval runner is still legacy-v1 only",plan_file:"reports/v2_pilot_eval_plan.md",next_steps:["run cheap mock sanity for schema/fragment/scope","run small real batch (10-15 messages, temperature=0)","run challenge-30 replay with v2 metrics"]}),q("Backend is legacy-only for eval right now. Showing v2 pilot plan.")):(Z(`Eval: ${I}`),q(`Eval run error: ${I}`))}finally{ue(!1)}}async function Bt(){try{const v=JSON.stringify(ce??{},null,2);await navigator.clipboard.writeText(v),q("Eval report copied to clipboard.")}catch(v){q(`Eval report copy error: ${v instanceof Error?v.message:String(v)}`)}}function Ht(){hr(""),Qn([]),Wn(""),ie(""),En(""),q("Assistant session reset.")}async function yn(){const v=Nn.trim();if(!v)return;gr(!0),En(""),Wn(""),Qn(N=>[...N,{message_id:`local-${Date.now()}`,session_id:ht||"pending",role:"user",text:v,reply_type:null,created_at:new Date().toISOString(),trace_id:null,debug:null}]);const I=vn();try{const N=await Me.sendAssistantMessage({connection:i,prompts:p,userMessage:v,sessionId:ht||void 0,promptVersion:Lc,useMock:Ne});hr(N.session_id),Qn(N.conversation),ie("Ответ готов"),q(`Assistant reply received: trace=${N.debug.trace_id}`)}catch(N){const pe=N instanceof Error?N.message:String(N);En(pe),ie("Ошибка ассистента"),q(`Assistant error: ${pe}`)}finally{I(),gr(!1)}}return S.useEffect(()=>{if(!A){J([]);return}Me.runTrace(A).then(v=>J(v.items)).catch(v=>q(`Run trace error: ${v instanceof Error?v.message:String(v)}`))},[A]),o.jsxs("main",{className:`app-root ${we==="assistant"||we==="decomposition"||we==="autoruns"?"app-root-autoruns":""}`,children:[o.jsxs("header",{className:"app-topbar",children:[o.jsxs("div",{className:"mode-switch-row",children:[o.jsx("button",{type:"button",className:we==="assistant"?"tab active":"tab",onClick:()=>jt("assistant"),children:"Ассистент"}),o.jsx("button",{type:"button",className:we==="decomposition"?"tab active":"tab",onClick:()=>jt("decomposition"),children:"Декомпозиция"}),o.jsx("button",{type:"button",className:we==="autoruns"?"tab active":"tab",onClick:()=>jt("autoruns"),children:"История автопрогонов"}),o.jsx("button",{type:"button",className:"tab",onClick:vr,children:"Сохранить"})]}),we==="assistant"?o.jsxs("div",{className:"mode-switch-row mode-switch-row-right",children:[o.jsx("button",{type:"button",className:kt?"tab active":"tab",onClick:()=>At(v=>!v),children:"LLM Connector"}),o.jsx("button",{type:"button",className:Yt?"tab active":"tab",onClick:()=>Bn(v=>!v),children:"Prompt Manager"}),o.jsx("button",{type:"button",className:cn?"tab active":"tab",onClick:()=>Hn(v=>!v),children:"Режим ассистента"}),o.jsx("button",{type:"button",className:dn?"tab active":"tab",onClick:()=>Dt(v=>!v),children:"SAM"})]}):we==="decomposition"?o.jsxs("div",{className:"mode-switch-row mode-switch-row-right",children:[o.jsx("button",{type:"button",className:Ot?"tab active":"tab",onClick:()=>Vn(v=>!v),children:"LLM"}),o.jsx("button",{type:"button",className:Ct?"tab active":"tab",onClick:()=>Xt(v=>!v),children:"Prompt"}),o.jsx("button",{type:"button",className:Fe?"tab active":"tab",onClick:()=>fn(v=>!v),children:"Запрос"}),o.jsx("button",{type:"button",className:pn?"tab active":"tab",onClick:()=>Or(v=>!v),children:"Выход"}),o.jsx("button",{type:"button",className:zt?"tab active":"tab",onClick:()=>mn(v=>!v),children:"Метрики"}),o.jsx("button",{type:"button",className:$t?"tab active":"tab",onClick:()=>hn(v=>!v),children:"История"}),o.jsx("button",{type:"button",className:gn?"tab active":"tab",onClick:()=>Zt(v=>!v),children:"NDC Run Monitor"})]}):we==="autoruns"?o.jsxs("div",{className:"mode-switch-row mode-switch-row-right",children:[o.jsx("button",{type:"button",className:kn?"tab active":"tab",onClick:()=>an(v=>!v),children:"Режим ассистента"}),o.jsx("button",{type:"button",className:un?"tab active":"tab",onClick:()=>Un(v=>!v),children:"Режим декомпозиции"}),o.jsx("button",{type:"button",className:Lt?"tab active":"tab",onClick:()=>It(v=>!v),children:"Прогресс/регресс"}),o.jsx("button",{type:"button",className:Cn?"tab active":"tab",onClick:()=>Jt(v=>!v),children:"Комментарии"})]}):null]}),we==="assistant"?o.jsx("div",{className:"layout-grid layout-grid-mode-columns",children:o.jsxs("div",{className:"mode-columns",children:[kt?o.jsx("div",{className:"mode-col",children:o.jsx(Ec,{value:i,modelOptions:oe,modelsBusy:se,onChange:h,onReloadModels:de,onSaveLocalConfig:Ut,onTestConnection:Rn,lastStatus:le,busy:Ee||Nt})}):null,Yt?o.jsx("div",{className:"mode-col mode-col-wide",children:o.jsx(Pc,{value:p,onChange:D,presets:Ae,selectedPresetId:Qe,onSelectPreset:Ze,onLoadPreset:yr,onSavePreset:xr,onResetDefaults:Kn,onDiffPrevious:_r,presetName:it,onPresetNameChange:at,diffSummary:be})}):null,cn?o.jsx("div",{className:"mode-col mode-col-xwide",children:o.jsx(Ac,{sessionId:ht,conversation:en,inputValue:Nn,onInputChange:Wn,useMock:Ne,onUseMockChange:fe,onSend:yn,onClear:Ht,busy:Nt,statusText:ut,errorMessage:Ke})}):null,dn?o.jsx("div",{className:"mode-col",children:o.jsx(Pf,{sessionId:ht,conversation:en,statusText:ut,errorMessage:Ke,useMock:Ne,appLogs:G})}):null,!kt&&!Yt&&!cn&&!dn?o.jsx("div",{className:"mode-columns-empty",children:"Все панели режима ассистента скрыты. Включите нужные блоки справа в шапке."}):null]})}):we==="decomposition"?o.jsx("div",{className:"layout-grid layout-grid-mode-columns",children:o.jsxs("div",{className:"mode-columns",children:[Ot?o.jsx("div",{className:"mode-col",children:o.jsx(Ec,{value:i,modelOptions:oe,modelsBusy:se,onChange:h,onReloadModels:de,onSaveLocalConfig:Ut,onTestConnection:Rn,lastStatus:le,busy:Ee})}):null,Ct?o.jsx("div",{className:"mode-col mode-col-wide",children:o.jsx(Pc,{value:p,onChange:D,presets:Ae,selectedPresetId:Qe,onSelectPreset:Ze,onLoadPreset:yr,onSavePreset:xr,onResetDefaults:Kn,onDiffPrevious:_r,presetName:it,onPresetNameChange:at,diffSummary:be})}):null,Fe?o.jsx("div",{className:"mode-col",children:o.jsx(bf,{value:P,onChange:z,onApplyBatchFormat:Tn,onNormalize:zr,busy:Ee,useMock:Ne,onUseMockChange:fe,errorMessage:he})}):null,pn?o.jsx("div",{className:"mode-col mode-col-xwide",children:o.jsx(Gf,{tab:H,onTabChange:re,result:K,appLogs:G})}):null,zt?o.jsx("div",{className:"mode-col",children:o.jsx(Wf,{result:K})}):null,$t?o.jsx("div",{className:"mode-col",children:o.jsx(Qf,{items:U,onRefresh:Be,onOpenTrace:_e})}):null,gn?o.jsx("div",{className:"mode-col mode-col-xwide",children:o.jsx(Jf,{runs:T,selectedRunId:A,onSelectRun:d,onStartRun:$r,onFinishRun:dt,onRefreshRuns:Pn,onRunEval:Fr,onCopyEvalReport:Bt,evalBusy:ae,traceItems:j,evalReport:ce})}):null,!Ot&&!Ct&&!Fe&&!pn&&!zt&&!$t&&!gn?o.jsx("div",{className:"mode-columns-empty",children:"Все панели режима декомпозиции скрыты. Включите нужные блоки справа в шапке."}):null]})}):o.jsx("div",{className:"layout-grid layout-grid-autoruns",children:o.jsx(Vf,{connection:i,prompts:p,assistantPromptVersion:Lc,decompositionPromptVersion:$i,showAssistantMode:kn,showDecompositionMode:un,showProgressMode:Lt,showCommentsMode:Cn,onLog:q})})]})}Cf.createRoot(document.getElementById("root")).render(o.jsx(yf.StrictMode,{children:o.jsx(sp,{})}));