(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))f(d);new MutationObserver(d=>{for(const m of d)if(m.type==="childList")for(const g of m.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&f(g)}).observe(document,{childList:!0,subtree:!0});function o(d){const m={};return d.integrity&&(m.integrity=d.integrity),d.referrerPolicy&&(m.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?m.credentials="include":d.crossOrigin==="anonymous"?m.credentials="omit":m.credentials="same-origin",m}function f(d){if(d.ep)return;d.ep=!0;const m=o(d);fetch(d.href,m)}})();var Vo={exports:{}},Fr={},Wo={exports:{}},ee={};/** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Qa;function _d(){if(Qa)return ee;Qa=1;var u=Symbol.for("react.element"),a=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),g=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),V=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),R=Symbol.iterator;function O(h){return h===null||typeof h!="object"?null:(h=R&&h[R]||h["@@iterator"],typeof h=="function"?h:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ne=Object.assign,P={};function $(h,S,H){this.props=h,this.context=S,this.refs=P,this.updater=H||b}$.prototype.isReactComponent={},$.prototype.setState=function(h,S){if(typeof h!="object"&&typeof h!="function"&&h!=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,h,S,"setState")},$.prototype.forceUpdate=function(h){this.updater.enqueueForceUpdate(this,h,"forceUpdate")};function X(){}X.prototype=$.prototype;function ce(h,S,H){this.props=h,this.context=S,this.refs=P,this.updater=H||b}var Ce=ce.prototype=new X;Ce.constructor=ce,ne(Ce,$.prototype),Ce.isPureReactComponent=!0;var de=Array.isArray,Pe=Object.prototype.hasOwnProperty,me={current:null},$e={key:!0,ref:!0,__self:!0,__source:!0};function Te(h,S,H){var K,te={},Z=null,fe=null;if(S!=null)for(K in S.ref!==void 0&&(fe=S.ref),S.key!==void 0&&(Z=""+S.key),S)Pe.call(S,K)&&!$e.hasOwnProperty(K)&&(te[K]=S[K]);var oe=arguments.length-2;if(oe===1)te.children=H;else if(1>>1,S=j[h];if(0>>1;hd(te,T))Zd(fe,te)?(j[h]=fe,j[Z]=T,h=Z):(j[h]=te,j[K]=T,h=K);else if(Zd(fe,T))j[h]=fe,j[Z]=T,h=Z;else break e}}return A}function d(j,A){var T=j.sortIndex-A.sortIndex;return T!==0?T:j.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var m=performance;u.unstable_now=function(){return m.now()}}else{var g=Date,k=g.now();u.unstable_now=function(){return g.now()-k}}var C=[],V=[],F=1,R=null,O=3,b=!1,ne=!1,P=!1,$=typeof setTimeout=="function"?setTimeout:null,X=typeof clearTimeout=="function"?clearTimeout:null,ce=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function Ce(j){for(var A=o(V);A!==null;){if(A.callback===null)f(V);else if(A.startTime<=j)f(V),A.sortIndex=A.expirationTime,a(C,A);else break;A=o(V)}}function de(j){if(P=!1,Ce(j),!ne)if(o(C)!==null)ne=!0,ue(Pe);else{var A=o(V);A!==null&&D(de,A.startTime-j)}}function Pe(j,A){ne=!1,P&&(P=!1,X(Te),Te=-1),b=!0;var T=O;try{for(Ce(A),R=o(C);R!==null&&(!(R.expirationTime>A)||j&&!ht());){var h=R.callback;if(typeof h=="function"){R.callback=null,O=R.priorityLevel;var S=h(R.expirationTime<=A);A=u.unstable_now(),typeof S=="function"?R.callback=S:R===o(C)&&f(C),Ce(A)}else f(C);R=o(C)}if(R!==null)var H=!0;else{var K=o(V);K!==null&&D(de,K.startTime-A),H=!1}return H}finally{R=null,O=T,b=!1}}var me=!1,$e=null,Te=-1,Be=5,Ie=-1;function ht(){return!(u.unstable_now()-Iej||125h?(j.sortIndex=T,a(V,j),o(C)===null&&j===o(V)&&(P?(X(Te),Te=-1):P=!0,D(de,T-h))):(j.sortIndex=S,a(C,j),ne||b||(ne=!0,ue(Pe))),j},u.unstable_shouldYield=ht,u.unstable_wrapCallback=function(j){var A=O;return function(){var T=O;O=A;try{return j.apply(this,arguments)}finally{O=T}}}})(qo)),qo}var Ja;function xd(){return Ja||(Ja=1,Qo.exports=Ed()),Qo.exports}/** * @license React * react-dom.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Xa;function Cd(){if(Xa)return at;Xa=1;var u=bo(),a=xd();function o(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"),C=Object.prototype.hasOwnProperty,V=/^[: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]*$/,F={},R={};function O(e){return C.call(R,e)?!0:C.call(F,e)?!1:V.test(e)?R[e]=!0:(F[e]=!0,!1)}function b(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 ne(e,t,n,r){if(t===null||typeof t>"u"||b(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 P(e,t,n,r,i,l,s){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=l,this.removeEmptyString=s}var $={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){$[e]=new P(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];$[t]=new P(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){$[e]=new P(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){$[e]=new P(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){$[e]=new P(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){$[e]=new P(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){$[e]=new P(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){$[e]=new P(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){$[e]=new P(e,5,!1,e.toLowerCase(),null,!1,!1)});var X=/[\-:]([a-z])/g;function ce(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(X,ce);$[t]=new P(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(X,ce);$[t]=new P(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(X,ce);$[t]=new P(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){$[e]=new P(e,1,!1,e.toLowerCase(),null,!1,!1)}),$.xlinkHref=new P("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){$[e]=new P(e,1,!1,e.toLowerCase(),null,!0,!0)});function Ce(e,t,n,r){var i=$.hasOwnProperty(t)?$[t]:null;(i!==null?i.type!==0:r||!(2c||i[s]!==l[c]){var p=` `+i[s].replace(" at new "," at ");return e.displayName&&p.includes("")&&(p=p.replace("",e.displayName)),p}while(1<=s&&0<=c);break}}}finally{H=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?S(e):""}function te(e){switch(e.tag){case 5:return S(e.type);case 16:return S("Lazy");case 13:return S("Suspense");case 19:return S("SuspenseList");case 0:case 2:case 15:return e=K(e.type,!1),e;case 11:return e=K(e.type.render,!1),e;case 1:return e=K(e.type,!0),e;default:return""}}function Z(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 me:return"Portal";case Be:return"Profiler";case Te:return"StrictMode";case Me:return"Suspense";case Le:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ht:return(e.displayName||"Context")+".Consumer";case Ie:return(e._context.displayName||"Context")+".Provider";case Q:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case tt:return t=e.displayName||null,t!==null?t:Z(e.type)||"Memo";case ue:t=e._payload,e=e._init;try{return Z(e(t))}catch{}}return null}function fe(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 Z(t);case 8:return t===Te?"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 oe(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function pe(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Ke(e){var t=pe(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 i=n.get,l=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(s){r=""+s,l.call(this,s)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function xn(e){e._valueTracker||(e._valueTracker=Ke(e))}function Cn(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=pe(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function jt(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 Pn(e,t){var n=t.checked;return T({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ie(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=oe(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 nt(e,t){t=t.checked,t!=null&&Ce(e,"checked",t,!1)}function cn(e,t){nt(e,t);var n=oe(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")?Fe(e,t.type,n):t.hasOwnProperty("defaultValue")&&Fe(e,t.type,oe(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Ee(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 Fe(e,t,n){(t!=="number"||jt(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Oe=Array.isArray;function Ne(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i"+t.valueOf().toString()+"",t=Nn.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function er(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var tr={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},Ec=["Webkit","ms","Moz","O"];Object.keys(tr).forEach(function(e){Ec.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),tr[t]=tr[e]})});function os(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||tr.hasOwnProperty(e)&&tr[e]?(""+t).trim():t+"px"}function ss(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=os(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var xc=T({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 bi(e,t){if(t){if(xc[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(o(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(o(61))}if(t.style!=null&&typeof t.style!="object")throw Error(o(62))}}function el(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 tl=null;function nl(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var rl=null,jn=null,zn=null;function us(e){if(e=Er(e)){if(typeof rl!="function")throw Error(o(280));var t=e.stateNode;t&&(t=ci(t),rl(e.stateNode,e.type,t))}}function as(e){jn?zn?zn.push(e):zn=[e]:jn=e}function cs(){if(jn){var e=jn,t=zn;if(zn=jn=null,us(e),t)for(e=0;e>>=0,e===0?32:31-($c(e)/Ic|0)|0}var qr=64,Gr=4194304;function lr(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 Kr(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,l=e.pingedLanes,s=n&268435455;if(s!==0){var c=s&~i;c!==0?r=lr(c):(l&=s,l!==0&&(r=lr(l)))}else s=n&~i,s!==0?r=lr(s):l!==0&&(r=lr(l));if(r===0)return 0;if(t!==0&&t!==r&&(t&i)===0&&(i=r&-r,l=t&-t,i>=l||i===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 or(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-kt(t),e[t]=n}function Ac(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=hr),Fs=" ",Us=!1;function As(e,t){switch(e){case"keyup":return mf.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bs(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ln=!1;function vf(e,t){switch(e){case"compositionend":return Bs(t);case"keypress":return t.which!==32?null:(Us=!0,Fs);case"textInput":return e=t.data,e===Fs&&Us?null:e;default:return null}}function yf(e,t){if(Ln)return e==="compositionend"||!kl&&As(e,t)?(e=Ls(),br=ml=qt=null,Ln=!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=Ks(n)}}function Js(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Js(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Xs(){for(var e=window,t=jt();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=jt(e.document)}return t}function xl(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 Nf(e){var t=Xs(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Js(n.ownerDocument.documentElement,n)){if(r!==null&&xl(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 i=n.textContent.length,l=Math.min(r.start,i);r=r.end===void 0?l:Math.min(r.end,i),!e.extend&&l>r&&(i=r,r=l,l=i),i=Ys(n,l);var s=Ys(n,r);i&&s&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==s.node||e.focusOffset!==s.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),l>r?(e.addRange(t),e.extend(s.node,s.offset)):(t.setEnd(s.node,s.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,On=null,Cl=null,yr=null,Pl=!1;function Zs(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Pl||On==null||On!==jt(r)||(r=On,"selectionStart"in r&&xl(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}),yr&&vr(yr,r)||(yr=r,r=si(Cl,"onSelect"),0Fn||(e.current=Fl[Fn],Fl[Fn]=null,Fn--)}function he(e,t){Fn++,Fl[Fn]=e.current,e.current=t}var Jt={},Ye=Yt(Jt),it=Yt(!1),pn=Jt;function Un(e,t){var n=e.type.contextTypes;if(!n)return Jt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},l;for(l in n)i[l]=t[l];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function lt(e){return e=e.childContextTypes,e!=null}function fi(){ye(it),ye(Ye)}function pu(e,t,n){if(Ye.current!==Jt)throw Error(o(168));he(Ye,t),he(it,n)}function hu(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(o(108,fe(e)||"Unknown",i));return T({},n,r)}function di(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Jt,pn=Ye.current,he(Ye,e),he(it,it.current),!0}function mu(e,t,n){var r=e.stateNode;if(!r)throw Error(o(169));n?(e=hu(e,t,pn),r.__reactInternalMemoizedMergedChildContext=e,ye(it),ye(Ye),he(Ye,e)):ye(it),he(it,n)}var $t=null,pi=!1,Ul=!1;function gu(e){$t===null?$t=[e]:$t.push(e)}function Uf(e){pi=!0,gu(e)}function Xt(){if(!Ul&&$t!==null){Ul=!0;var e=0,t=ae;try{var n=$t;for(ae=1;e>=s,i-=s,It=1<<32-kt(t)+i|n<Y?(Qe=G,G=null):Qe=G.sibling;var le=E(y,G,w[Y],z);if(le===null){G===null&&(G=Qe);break}e&&G&&le.alternate===null&&t(y,G),v=l(le,v,Y),q===null?W=le:q.sibling=le,q=le,G=Qe}if(Y===w.length)return n(y,G),we&&mn(y,Y),W;if(G===null){for(;YY?(Qe=G,G=null):Qe=G.sibling;var sn=E(y,G,le.value,z);if(sn===null){G===null&&(G=Qe);break}e&&G&&sn.alternate===null&&t(y,G),v=l(sn,v,Y),q===null?W=sn:q.sibling=sn,q=sn,G=Qe}if(le.done)return n(y,G),we&&mn(y,Y),W;if(G===null){for(;!le.done;Y++,le=w.next())le=N(y,le.value,z),le!==null&&(v=l(le,v,Y),q===null?W=le:q.sibling=le,q=le);return we&&mn(y,Y),W}for(G=r(y,G);!le.done;Y++,le=w.next())le=I(G,y,Y,le.value,z),le!==null&&(e&&le.alternate!==null&&G.delete(le.key===null?Y:le.key),v=l(le,v,Y),q===null?W=le:q.sibling=le,q=le);return e&&G.forEach(function(wd){return t(y,wd)}),we&&mn(y,Y),W}function Re(y,v,w,z){if(typeof w=="object"&&w!==null&&w.type===$e&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Pe:e:{for(var W=w.key,q=v;q!==null;){if(q.key===W){if(W=w.type,W===$e){if(q.tag===7){n(y,q.sibling),v=i(q,w.props.children),v.return=y,y=v;break e}}else if(q.elementType===W||typeof W=="object"&&W!==null&&W.$$typeof===ue&&Su(W)===q.type){n(y,q.sibling),v=i(q,w.props),v.ref=xr(y,q,w),v.return=y,y=v;break e}n(y,q);break}else t(y,q);q=q.sibling}w.type===$e?(v=En(w.props.children,y.mode,z,w.key),v.return=y,y=v):(z=Bi(w.type,w.key,w.props,null,y.mode,z),z.ref=xr(y,v,w),z.return=y,y=z)}return s(y);case me:e:{for(q=w.key;v!==null;){if(v.key===q)if(v.tag===4&&v.stateNode.containerInfo===w.containerInfo&&v.stateNode.implementation===w.implementation){n(y,v.sibling),v=i(v,w.children||[]),v.return=y,y=v;break e}else{n(y,v);break}else t(y,v);v=v.sibling}v=Mo(w,y.mode,z),v.return=y,y=v}return s(y);case ue:return q=w._init,Re(y,v,q(w._payload),z)}if(Oe(w))return U(y,v,w,z);if(A(w))return B(y,v,w,z);vi(y,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,v!==null&&v.tag===6?(n(y,v.sibling),v=i(v,w),v.return=y,y=v):(n(y,v),v=Io(w,y.mode,z),v.return=y,y=v),s(y)):n(y,v)}return Re}var Wn=Eu(!0),xu=Eu(!1),yi=Yt(null),wi=null,Hn=null,Ql=null;function ql(){Ql=Hn=wi=null}function Gl(e){var t=yi.current;ye(yi),e._currentValue=t}function Kl(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 Qn(e,t){wi=e,Ql=Hn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(ot=!0),e.firstContext=null)}function vt(e){var t=e._currentValue;if(Ql!==e)if(e={context:e,memoizedValue:t,next:null},Hn===null){if(wi===null)throw Error(o(308));Hn=e,wi.dependencies={lanes:0,firstContext:e}}else Hn=Hn.next=e;return t}var gn=null;function Yl(e){gn===null?gn=[e]:gn.push(e)}function Cu(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,Yl(t)):(n.next=i.next,i.next=n),t.interleaved=n,Ft(e,r)}function Ft(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 Zt=!1;function Jl(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Pu(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 Ut(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function bt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(re&2)!==0){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,Ft(e,n)}return i=r.interleaved,i===null?(t.next=t,Yl(r)):(t.next=i.next,i.next=t),r.interleaved=t,Ft(e,n)}function _i(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,cl(e,n)}}function Nu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,l=null;if(n=n.firstBaseUpdate,n!==null){do{var s={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};l===null?i=l=s:l=l.next=s,n=n.next}while(n!==null);l===null?i=l=t:l=l.next=t}else i=l=t;n={baseState:r.baseState,firstBaseUpdate:i,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 ki(e,t,n,r){var i=e.updateQueue;Zt=!1;var l=i.firstBaseUpdate,s=i.lastBaseUpdate,c=i.shared.pending;if(c!==null){i.shared.pending=null;var p=c,_=p.next;p.next=null,s===null?l=_:s.next=_,s=p;var x=e.alternate;x!==null&&(x=x.updateQueue,c=x.lastBaseUpdate,c!==s&&(c===null?x.firstBaseUpdate=_:c.next=_,x.lastBaseUpdate=p))}if(l!==null){var N=i.baseState;s=0,x=_=p=null,c=l;do{var E=c.lane,I=c.eventTime;if((r&E)===E){x!==null&&(x=x.next={eventTime:I,lane:0,tag:c.tag,payload:c.payload,callback:c.callback,next:null});e:{var U=e,B=c;switch(E=t,I=n,B.tag){case 1:if(U=B.payload,typeof U=="function"){N=U.call(I,N,E);break e}N=U;break e;case 3:U.flags=U.flags&-65537|128;case 0:if(U=B.payload,E=typeof U=="function"?U.call(I,N,E):U,E==null)break e;N=T({},N,E);break e;case 2:Zt=!0}}c.callback!==null&&c.lane!==0&&(e.flags|=64,E=i.effects,E===null?i.effects=[c]:E.push(c))}else I={eventTime:I,lane:E,tag:c.tag,payload:c.payload,callback:c.callback,next:null},x===null?(_=x=I,p=N):x=x.next=I,s|=E;if(c=c.next,c===null){if(c=i.shared.pending,c===null)break;E=c,c=E.next,E.next=null,i.lastBaseUpdate=E,i.shared.pending=null}}while(!0);if(x===null&&(p=N),i.baseState=p,i.firstBaseUpdate=_,i.lastBaseUpdate=x,t=i.shared.interleaved,t!==null){i=t;do s|=i.lane,i=i.next;while(i!==t)}else l===null&&(i.shared.lanes=0);wn|=s,e.lanes=s,e.memoizedState=N}}function ju(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=to.transition;to.transition={};try{e(!1),t()}finally{ae=n,to.transition=r}}function Gu(){return yt().memoizedState}function Wf(e,t,n){var r=rn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ku(e))Yu(t,n);else if(n=Cu(e,t,n,r),n!==null){var i=et();Nt(n,e,r,i),Ju(n,t,r)}}function Hf(e,t,n){var r=rn(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ku(e))Yu(t,i);else{var l=e.alternate;if(e.lanes===0&&(l===null||l.lanes===0)&&(l=t.lastRenderedReducer,l!==null))try{var s=t.lastRenderedState,c=l(s,n);if(i.hasEagerState=!0,i.eagerState=c,St(c,s)){var p=t.interleaved;p===null?(i.next=i,Yl(t)):(i.next=p.next,p.next=i),t.interleaved=i;return}}catch{}finally{}n=Cu(e,t,i,r),n!==null&&(i=et(),Nt(n,e,r,i),Ju(n,t,r))}}function Ku(e){var t=e.alternate;return e===ke||t!==null&&t===ke}function Yu(e,t){jr=xi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ju(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,cl(e,n)}}var Ni={readContext:vt,useCallback:Je,useContext:Je,useEffect:Je,useImperativeHandle:Je,useInsertionEffect:Je,useLayoutEffect:Je,useMemo:Je,useReducer:Je,useRef:Je,useState:Je,useDebugValue:Je,useDeferredValue:Je,useTransition:Je,useMutableSource:Je,useSyncExternalStore:Je,useId:Je,unstable_isNewReconciler:!1},Qf={readContext:vt,useCallback:function(e,t){return Lt().memoizedState=[e,t===void 0?null:t],e},useContext:vt,useEffect:Uu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ci(4194308,4,Vu.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ci(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ci(4,2,e,t)},useMemo:function(e,t){var n=Lt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Lt();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=Wf.bind(null,ke,e),[r.memoizedState,e]},useRef:function(e){var t=Lt();return e={current:e},t.memoizedState=e},useState:Mu,useDebugValue:uo,useDeferredValue:function(e){return Lt().memoizedState=e},useTransition:function(){var e=Mu(!1),t=e[0];return e=Vf.bind(null,e[1]),Lt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ke,i=Lt();if(we){if(n===void 0)throw Error(o(407));n=n()}else{if(n=t(),He===null)throw Error(o(349));(yn&30)!==0||Lu(r,t,n)}i.memoizedState=n;var l={value:n,getSnapshot:t};return i.queue=l,Uu(Du.bind(null,r,l,e),[e]),r.flags|=2048,Tr(9,Ou.bind(null,r,l,n,t),void 0,null),n},useId:function(){var e=Lt(),t=He.identifierPrefix;if(we){var n=Mt,r=It;n=(r&~(1<<32-kt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=zr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=s.createElement(n,{is:r.is}):(e=s.createElement(n),n==="select"&&(s=e,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):e=s.createElementNS(e,n),e[Rt]=t,e[Sr]=r,ga(e,t,!1,!1),t.stateNode=e;e:{switch(s=el(n,r),n){case"dialog":ve("cancel",e),ve("close",e),i=r;break;case"iframe":case"object":case"embed":ve("load",e),i=r;break;case"video":case"audio":for(i=0;iJn&&(t.flags|=128,r=!0,Lr(l,!1),t.lanes=4194304)}else{if(!r)if(e=Si(s),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Lr(l,!0),l.tail===null&&l.tailMode==="hidden"&&!s.alternate&&!we)return Xe(t),null}else 2*ze()-l.renderingStartTime>Jn&&n!==1073741824&&(t.flags|=128,r=!0,Lr(l,!1),t.lanes=4194304);l.isBackwards?(s.sibling=t.child,t.child=s):(n=l.last,n!==null?n.sibling=s:t.child=s,l.last=s)}return l.tail!==null?(t=l.tail,l.rendering=t,l.tail=t.sibling,l.renderingStartTime=ze(),t.sibling=null,n=_e.current,he(_e,r?n&1|2:n&1),t):(Xe(t),null);case 22:case 23:return Oo(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(pt&1073741824)!==0&&(Xe(t),t.subtreeFlags&6&&(t.flags|=8192)):Xe(t),null;case 24:return null;case 25:return null}throw Error(o(156,t.tag))}function bf(e,t){switch(Bl(t),t.tag){case 1:return lt(t.type)&&fi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return qn(),ye(it),ye(Ye),eo(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return Zl(t),null;case 13:if(ye(_e),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Vn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ye(_e),null;case 4:return qn(),null;case 10:return Gl(t.type._context),null;case 22:case 23:return Oo(),null;case 24:return null;default:return null}}var Ti=!1,Ze=!1,ed=typeof WeakSet=="function"?WeakSet:Set,M=null;function Kn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){xe(e,t,r)}else n.current=null}function ko(e,t,n){try{n()}catch(r){xe(e,t,r)}}var wa=!1;function td(e,t){if(Ll=Xr,e=Xs(),xl(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 i=r.anchorOffset,l=r.focusNode;r=r.focusOffset;try{n.nodeType,l.nodeType}catch{n=null;break e}var s=0,c=-1,p=-1,_=0,x=0,N=e,E=null;t:for(;;){for(var I;N!==n||i!==0&&N.nodeType!==3||(c=s+i),N!==l||r!==0&&N.nodeType!==3||(p=s+r),N.nodeType===3&&(s+=N.nodeValue.length),(I=N.firstChild)!==null;)E=N,N=I;for(;;){if(N===e)break t;if(E===n&&++_===i&&(c=s),E===l&&++x===r&&(p=s),(I=N.nextSibling)!==null)break;N=E,E=N.parentNode}N=I}n=c===-1||p===-1?null:{start:c,end:p}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ol={focusedElem:e,selectionRange:n},Xr=!1,M=t;M!==null;)if(t=M,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,M=e;else for(;M!==null;){t=M;try{var U=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(U!==null){var B=U.memoizedProps,Re=U.memoizedState,y=t.stateNode,v=y.getSnapshotBeforeUpdate(t.elementType===t.type?B:xt(t.type,B),Re);y.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(z){xe(t,t.return,z)}if(e=t.sibling,e!==null){e.return=t.return,M=e;break}M=t.return}return U=wa,wa=!1,U}function Or(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var l=i.destroy;i.destroy=void 0,l!==void 0&&ko(t,n,l)}i=i.next}while(i!==r)}}function Li(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 So(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function _a(e){var t=e.alternate;t!==null&&(e.alternate=null,_a(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Rt],delete t[Sr],delete t[Ml],delete t[Mf],delete t[Ff])),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 ka(e){return e.tag===5||e.tag===3||e.tag===4}function Sa(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ka(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 Eo(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=ai));else if(r!==4&&(e=e.child,e!==null))for(Eo(e,t,n),e=e.sibling;e!==null;)Eo(e,t,n),e=e.sibling}function xo(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(xo(e,t,n),e=e.sibling;e!==null;)xo(e,t,n),e=e.sibling}var qe=null,Ct=!1;function en(e,t,n){for(n=n.child;n!==null;)Ea(e,t,n),n=n.sibling}function Ea(e,t,n){if(zt&&typeof zt.onCommitFiberUnmount=="function")try{zt.onCommitFiberUnmount(Qr,n)}catch{}switch(n.tag){case 5:Ze||Kn(n,t);case 6:var r=qe,i=Ct;qe=null,en(e,t,n),qe=r,Ct=i,qe!==null&&(Ct?(e=qe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):qe.removeChild(n.stateNode));break;case 18:qe!==null&&(Ct?(e=qe,n=n.stateNode,e.nodeType===8?Il(e.parentNode,n):e.nodeType===1&&Il(e,n),fr(e)):Il(qe,n.stateNode));break;case 4:r=qe,i=Ct,qe=n.stateNode.containerInfo,Ct=!0,en(e,t,n),qe=r,Ct=i;break;case 0:case 11:case 14:case 15:if(!Ze&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var l=i,s=l.destroy;l=l.tag,s!==void 0&&((l&2)!==0||(l&4)!==0)&&ko(n,t,s),i=i.next}while(i!==r)}en(e,t,n);break;case 1:if(!Ze&&(Kn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(c){xe(n,t,c)}en(e,t,n);break;case 21:en(e,t,n);break;case 22:n.mode&1?(Ze=(r=Ze)||n.memoizedState!==null,en(e,t,n),Ze=r):en(e,t,n);break;default:en(e,t,n)}}function xa(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new ed),t.forEach(function(r){var i=cd.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Pt(e,t){var n=t.deletions;if(n!==null)for(var r=0;ri&&(i=s),r&=~l}if(r=i,r=ze()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*rd(r/1960))-r,10e?16:e,nn===null)var r=!1;else{if(e=nn,nn=null,Mi=0,(re&6)!==0)throw Error(o(331));var i=re;for(re|=4,M=e.current;M!==null;){var l=M,s=l.child;if((M.flags&16)!==0){var c=l.deletions;if(c!==null){for(var p=0;pze()-No?kn(e,0):Po|=n),ut(e,t)}function Ma(e,t){t===0&&((e.mode&1)===0?t=1:(t=Gr,Gr<<=1,(Gr&130023424)===0&&(Gr=4194304)));var n=et();e=Ft(e,t),e!==null&&(or(e,t,n),ut(e,n))}function ad(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ma(e,n)}function cd(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(o(314))}r!==null&&r.delete(t),Ma(e,n)}var Fa;Fa=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||it.current)ot=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return ot=!1,Xf(e,t,n);ot=(e.flags&131072)!==0}else ot=!1,we&&(t.flags&1048576)!==0&&vu(t,mi,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ri(e,t),e=t.pendingProps;var i=Un(t,Ye.current);Qn(t,n),i=ro(null,t,r,e,i,n);var l=io();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,lt(r)?(l=!0,di(t)):l=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Jl(t),i.updater=ji,t.stateNode=i,i._reactInternals=t,co(t,r,e,n),t=mo(null,t,r,!0,l,n)):(t.tag=0,we&&l&&Al(t),be(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ri(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=dd(r),e=xt(r,e),i){case 0:t=ho(null,t,r,e,n);break e;case 1:t=ca(null,t,r,e,n);break e;case 11:t=la(null,t,r,e,n);break e;case 14:t=oa(null,t,r,xt(r.type,e),n);break e}throw Error(o(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:xt(r,i),ho(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:xt(r,i),ca(e,t,r,i,n);case 3:e:{if(fa(t),e===null)throw Error(o(387));r=t.pendingProps,l=t.memoizedState,i=l.element,Pu(e,t),ki(t,r,null,n);var s=t.memoizedState;if(r=s.element,l.isDehydrated)if(l={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=l,t.memoizedState=l,t.flags&256){i=Gn(Error(o(423)),t),t=da(e,t,r,n,i);break e}else if(r!==i){i=Gn(Error(o(424)),t),t=da(e,t,r,n,i);break e}else for(dt=Kt(t.stateNode.containerInfo.firstChild),ft=t,we=!0,Et=null,n=xu(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Vn(),r===i){t=At(e,t,n);break e}be(e,t,r,n)}t=t.child}return t;case 5:return zu(t),e===null&&Wl(t),r=t.type,i=t.pendingProps,l=e!==null?e.memoizedProps:null,s=i.children,Dl(r,i)?s=null:l!==null&&Dl(r,l)&&(t.flags|=32),aa(e,t),be(e,t,s,n),t.child;case 6:return e===null&&Wl(t),null;case 13:return pa(e,t,n);case 4:return Xl(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Wn(t,null,r,n):be(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:xt(r,i),la(e,t,r,i,n);case 7:return be(e,t,t.pendingProps,n),t.child;case 8:return be(e,t,t.pendingProps.children,n),t.child;case 12:return be(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,l=t.memoizedProps,s=i.value,he(yi,r._currentValue),r._currentValue=s,l!==null)if(St(l.value,s)){if(l.children===i.children&&!it.current){t=At(e,t,n);break e}}else for(l=t.child,l!==null&&(l.return=t);l!==null;){var c=l.dependencies;if(c!==null){s=l.child;for(var p=c.firstContext;p!==null;){if(p.context===r){if(l.tag===1){p=Ut(-1,n&-n),p.tag=2;var _=l.updateQueue;if(_!==null){_=_.shared;var x=_.pending;x===null?p.next=p:(p.next=x.next,x.next=p),_.pending=p}}l.lanes|=n,p=l.alternate,p!==null&&(p.lanes|=n),Kl(l.return,n,t),c.lanes|=n;break}p=p.next}}else if(l.tag===10)s=l.type===t.type?null:l.child;else if(l.tag===18){if(s=l.return,s===null)throw Error(o(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Kl(s,n,t),s=l.sibling}else s=l.child;if(s!==null)s.return=l;else for(s=l;s!==null;){if(s===t){s=null;break}if(l=s.sibling,l!==null){l.return=s.return,s=l;break}s=s.return}l=s}be(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,Qn(t,n),i=vt(i),r=r(i),t.flags|=1,be(e,t,r,n),t.child;case 14:return r=t.type,i=xt(r,t.pendingProps),i=xt(r.type,i),oa(e,t,r,i,n);case 15:return sa(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:xt(r,i),Ri(e,t),t.tag=1,lt(r)?(e=!0,di(t)):e=!1,Qn(t,n),Zu(t,r,i),co(t,r,i,n),mo(null,t,r,!0,e,n);case 19:return ma(e,t,n);case 22:return ua(e,t,n)}throw Error(o(156,t.tag))};function Ua(e,t){return ys(e,t)}function fd(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 _t(e,t,n,r){return new fd(e,t,n,r)}function $o(e){return e=e.prototype,!(!e||!e.isReactComponent)}function dd(e){if(typeof e=="function")return $o(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Q)return 11;if(e===tt)return 14}return 2}function on(e,t){var n=e.alternate;return n===null?(n=_t(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 Bi(e,t,n,r,i,l){var s=2;if(r=e,typeof e=="function")$o(e)&&(s=1);else if(typeof e=="string")s=5;else e:switch(e){case $e:return En(n.children,i,l,t);case Te:s=8,i|=8;break;case Be:return e=_t(12,n,t,i|2),e.elementType=Be,e.lanes=l,e;case Me:return e=_t(13,n,t,i),e.elementType=Me,e.lanes=l,e;case Le:return e=_t(19,n,t,i),e.elementType=Le,e.lanes=l,e;case D:return Vi(n,i,l,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Ie:s=10;break e;case ht:s=9;break e;case Q:s=11;break e;case tt:s=14;break e;case ue:s=16,r=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return t=_t(s,n,t,i),t.elementType=e,t.type=r,t.lanes=l,t}function En(e,t,n,r){return e=_t(7,e,r,t),e.lanes=n,e}function Vi(e,t,n,r){return e=_t(22,e,r,t),e.elementType=D,e.lanes=n,e.stateNode={isHidden:!1},e}function Io(e,t,n){return e=_t(6,e,null,t),e.lanes=n,e}function Mo(e,t,n){return t=_t(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function pd(e,t,n,r,i){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=al(0),this.expirationTimes=al(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=al(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Fo(e,t,n,r,i,l,s,c,p){return e=new pd(e,t,n,c,p),t===1?(t=1,l===!0&&(t|=8)):t=0,l=_t(3,null,null,t),e.current=l,l.stateNode=e,l.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Jl(l),e}function hd(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(u)}catch(a){console.error(a)}}return u(),Ho.exports=Cd(),Ho.exports}var ba;function Nd(){if(ba)return Yi;ba=1;var u=Pd();return Yi.createRoot=u.createRoot,Yi.hydrateRoot=u.hydrateRoot,Yi}var jd=Nd();const zd="modulepreload",Rd=function(u,a){return new URL(u,a).href},ec={},tc=function(a,o,f){let d=Promise.resolve();if(o&&o.length>0){let g=function(F){return Promise.all(F.map(R=>Promise.resolve(R).then(O=>({status:"fulfilled",value:O}),O=>({status:"rejected",reason:O}))))};const k=document.getElementsByTagName("link"),C=document.querySelector("meta[property=csp-nonce]"),V=(C==null?void 0:C.nonce)||(C==null?void 0:C.getAttribute("nonce"));d=g(o.map(F=>{if(F=Rd(F,f),F in ec)return;ec[F]=!0;const R=F.endsWith(".css"),O=R?'[rel="stylesheet"]':"";if(!!f)for(let P=k.length-1;P>=0;P--){const $=k[P];if($.href===F&&(!R||$.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${F}"]${O}`))return;const ne=document.createElement("link");if(ne.rel=R?"stylesheet":zd,R||(ne.as="script"),ne.crossOrigin="",ne.href=F,V&&ne.setAttribute("nonce",V),document.head.appendChild(ne),R)return new Promise((P,$)=>{ne.addEventListener("load",P),ne.addEventListener("error",()=>$(new Error(`Unable to preload CSS for ${F}`)))})}))}function m(g){const k=new Event("vite:preloadError",{cancelable:!0});if(k.payload=g,window.dispatchEvent(k),!k.defaultPrevented)throw g}return d.then(g=>{for(const k of g||[])k.status==="rejected"&&m(k.reason);return a().catch(m)})};var Td=Object.defineProperty,fc=u=>{throw TypeError(u)},Ld=(u,a,o)=>a in u?Td(u,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):u[a]=o,J=(u,a,o)=>Ld(u,typeof a!="symbol"?a+"":a,o),dc=(u,a,o)=>a.has(u)||fc("Cannot "+o),Ur=(u,a,o)=>(dc(u,a,"read from private field"),a.get(u)),Od=(u,a,o)=>a.has(u)?fc("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(u):a.set(u,o),Dd=(u,a,o,f)=>(dc(u,a,"write to private field"),a.set(u,o),o),Go=new Intl.Collator(0,{numeric:1}).compare;function pc(u,a,o){return u=u.split("."),a=a.split("."),Go(u[0],a[0])||Go(u[1],a[1])||(a[2]=a.slice(2).join("."),o=/[.-]/.test(u[2]=u.slice(2).join(".")),o==/[.-]/.test(a[2])?Go(u[2],a[2]):o?-1:1)}const $d="host",hc="queue/data",Id="queue/join",nc="upload",Md="login",Ji="config",Fd="info",Ud="runtime",Ad="sleeptime",Bd="heartbeat",Vd="component_server",Wd="reset",Hd="cancel",Qd="app_id",qd="https://gradio-space-api-fetcher-v2.hf.space/api",mc="This application is currently busy. Please try again. ",Zn="Connection errored out. ",an="Could not resolve app config. ",Gd="Could not get space status. ",Kd="Could not get API info. ",es="Space metadata could not be loaded. ",Yd="Invalid URL. A full URL path is required.",Jd="Not authorized to access this space. ",gc="Invalid credentials. Could not login. ",Xd="Login credentials are required to access this space.",Zd="File system access is only available in Node.js environments",vc="Root URL not found in client config",bd="Error uploading file";function ep(u,a,o){return a.startsWith("http://")||a.startsWith("https://")?o?u:a:u+a}async function rc(u,a,o){try{return(await(await fetch(`https://huggingface.co/api/spaces/${u}/jwt`,{headers:{Authorization:`Bearer ${a}`,...o?{Cookie:o}:{}}})).json()).token||!1}catch{return!1}}function tp(u){let a={};return u.forEach(({api_name:o,id:f})=>{o&&(a[o]=f)}),a}async function np(u){const a=this.options.hf_token?{Authorization:`Bearer ${this.options.hf_token}`}:{};if(a["Content-Type"]="application/json",typeof window<"u"&&window.gradio_config&&location.origin!=="http://localhost:9876"){if(window.gradio_config.current_page&&(u=u.substring(0,u.lastIndexOf("/"))),window.gradio_config.dev_mode){let o=Jo(u,this.deep_link?Ji+"?deep_link="+this.deep_link:Ji);const f=await this.fetch(o,{headers:a,credentials:"include"}),d=await ic(f,u,!!this.options.auth);window.gradio_config={...d,current_page:window.gradio_config.current_page}}return window.gradio_config.root=u,{...window.gradio_config}}else if(u){let o=Jo(u,this.deep_link?Ji+"?deep_link="+this.deep_link:Ji);const f=await this.fetch(o,{headers:a,credentials:"include"});return ic(f,u,!!this.options.auth)}throw new Error(an)}async function ic(u,a,o){var f,d;if((u==null?void 0:u.status)===401&&!o){const m=await u.json(),g=(f=m==null?void 0:m.detail)==null?void 0:f.auth_message;throw new Error(g||Xd)}else if((u==null?void 0:u.status)===401&&o)throw new Error(gc);if((u==null?void 0:u.status)===200){let m=await u.json();return m.root=a,(d=m.dependencies)==null||d.forEach((g,k)=>{g.id===void 0&&(g.id=k)}),m}else if((u==null?void 0:u.status)===401)throw new Error(Jd);throw new Error(an)}async function rp(){const{http_protocol:u,host:a}=await Zi(this.app_reference,this.options.hf_token);try{if(this.options.auth){const o=await yc(u,a,this.options.auth,this.fetch,this.options.hf_token);o&&this.set_cookies(o)}}catch(o){throw Error(o.message)}}async function yc(u,a,o,f,d){const m=new FormData;m.append("username",o==null?void 0:o[0]),m.append("password",o==null?void 0:o[1]);let g={};d&&(g.Authorization=`Bearer ${d}`);const k=await f(`${u}//${a}/${Md}`,{headers:g,method:"POST",body:m,credentials:"include"});if(k.status===200)return k.headers.get("set-cookie");throw k.status===401?new Error(gc):new Error(es)}function Ko(u){if(u.startsWith("http")){const{protocol:a,host:o,pathname:f}=new URL(u);return{ws_protocol:a==="https:"?"wss":"ws",http_protocol:a,host:o+(f!=="/"?f:"")}}return{ws_protocol:"wss",http_protocol:"https:",host:new URL(u).host}}const wc=u=>{let a=[];return u.split(/,(?=\s*[^\s=;]+=[^\s=;]+)/).forEach(o=>{const[f,d]=o.split(";")[0].split("=");f&&d&&a.push(`${f.trim()}=${d.trim()}`)}),a},ts=/^[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_\-\.]+$/,ip=/.*hf\.space\/{0,1}.*$/;async function Zi(u,a){const o={};a&&(o.Authorization=`Bearer ${a}`);const f=u.trim().replace(/\/$/,"");if(ts.test(f))try{const d=(await(await fetch(`https://huggingface.co/api/spaces/${f}/${$d}`,{headers:o})).json()).host;return{space_id:u,...Ko(d)}}catch{throw new Error(es)}if(ip.test(f)){const{ws_protocol:d,http_protocol:m,host:g}=Ko(f);return{space_id:g.split("/")[0].replace(".hf.space",""),ws_protocol:d,http_protocol:m,host:g}}return{space_id:!1,...Ko(f)}}const Jo=(...u)=>{try{return u.reduce((a,o)=>(a=a.replace(/\/+$/,""),o=o.replace(/^\/+/,""),new URL(o,a+"/").toString()))}catch{throw new Error(Yd)}};function lp(u,a,o){const f={named_endpoints:{},unnamed_endpoints:{}};return Object.keys(u).forEach(d=>{(d==="named_endpoints"||d==="unnamed_endpoints")&&(f[d]={},Object.entries(u[d]).forEach(([m,{parameters:g,returns:k}])=>{var C,V,F,R;const O=((C=a.dependencies.find(P=>P.api_name===m||P.api_name===m.replace("/","")))==null?void 0:C.id)||o[m.replace("/","")]||-1,b=O!==-1?(V=a.dependencies.find(P=>P.id==O))==null?void 0:V.types:{generator:!1,cancel:!1};if(O!==-1&&((R=(F=a.dependencies.find(P=>P.id==O))==null?void 0:F.inputs)==null?void 0:R.length)!==g.length){const P=a.dependencies.find($=>$.id==O).inputs.map($=>{var X;return(X=a.components.find(ce=>ce.id===$))==null?void 0:X.type});try{P.forEach(($,X)=>{if($==="state"){const ce={component:"state",example:null,parameter_default:null,parameter_has_default:!0,parameter_name:null,hidden:!0};g.splice(X,0,ce)}})}catch($){console.error($)}}const ne=(P,$,X,ce)=>({...P,description:sp(P==null?void 0:P.type,X),type:op(P==null?void 0:P.type,$,X,ce)||""});f[d][m]={parameters:g.map(P=>ne(P,P==null?void 0:P.component,P==null?void 0:P.serializer,"parameter")),returns:k.map(P=>ne(P,P==null?void 0:P.component,P==null?void 0:P.serializer,"return")),type:b}}))}),f}function op(u,a,o,f){if(a==="Api")return u.type;switch(u==null?void 0:u.type){case"string":return"string";case"boolean":return"boolean";case"number":return"number"}if(o==="JSONSerializable"||o==="StringSerializable")return"any";if(o==="ListStringSerializable")return"string[]";if(a==="Image")return f==="parameter"?"Blob | File | Buffer":"string";if(o==="FileSerializable")return(u==null?void 0:u.type)==="array"?f==="parameter"?"(Blob | File | Buffer)[]":"{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}[]":f==="parameter"?"Blob | File | Buffer":"{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}";if(o==="GallerySerializable")return f==="parameter"?"[(Blob | File | Buffer), (string | null)][]":"[{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}, (string | null))][]"}function sp(u,a){return a==="GallerySerializable"?"array of [file, label] tuples":a==="ListStringSerializable"?"array of strings":a==="FileSerializable"?"array of files or single file":u==null?void 0:u.description}function Yo(u,a){switch(u.msg){case"send_data":return{type:"data"};case"send_hash":return{type:"hash"};case"queue_full":return{type:"update",status:{queue:!0,message:mc,stage:"error",code:u.code,success:u.success}};case"heartbeat":return{type:"heartbeat"};case"unexpected_error":return{type:"unexpected_error",status:{queue:!0,message:u.message,session_not_found:u.session_not_found,stage:"error",success:!1}};case"broken_connection":return{type:"broken_connection",status:{queue:!0,message:u.message,stage:"error",success:!1}};case"estimation":return{type:"update",status:{queue:!0,stage:a||"pending",code:u.code,size:u.queue_size,position:u.rank,eta:u.rank_eta,success:u.success}};case"progress":return{type:"update",status:{queue:!0,stage:"pending",code:u.code,progress_data:u.progress_data,success:u.success}};case"log":return{type:"log",data:u};case"process_generating":return{type:"generating",status:{queue:!0,message:u.success?null:u.output.error,stage:u.success?"generating":"error",code:u.code,progress_data:u.progress_data,eta:u.average_duration,changed_state_ids:u.success?u.output.changed_state_ids:void 0},data:u.success?u.output:null};case"process_streaming":return{type:"streaming",status:{queue:!0,message:u.output.error,stage:"streaming",time_limit:u.time_limit,code:u.code,progress_data:u.progress_data,eta:u.eta},data:u.output};case"process_completed":return"error"in u.output?{type:"update",status:{queue:!0,title:u.output.title,message:u.output.error,visible:u.output.visible,duration:u.output.duration,stage:"error",code:u.code,success:u.success}}:{type:"complete",status:{queue:!0,message:u.success?void 0:u.output.error,stage:u.success?"complete":"error",code:u.code,progress_data:u.progress_data,changed_state_ids:u.success?u.output.changed_state_ids:void 0},data:u.success?u.output:null};case"process_starts":return{type:"update",status:{queue:!0,stage:"pending",code:u.code,size:u.rank,position:0,success:u.success,eta:u.eta},original_msg:"process_starts"}}return{type:"none",status:{stage:"error",queue:!0}}}const up=(u=[],a)=>{const o=a?a.parameters:[];if(Array.isArray(u))return a&&o.length>0&&u.length>o.length&&console.warn("Too many arguments provided for the endpoint."),u;const f=[],d=Object.keys(u);return o.forEach((m,g)=>{if(u.hasOwnProperty(m.parameter_name))f[g]=u[m.parameter_name];else if(m.parameter_has_default)f[g]=m.parameter_default;else throw new Error(`No value provided for required parameter: ${m.parameter_name}`)}),d.forEach(m=>{if(!o.some(g=>g.parameter_name===m))throw new Error(`Parameter \`${m}\` is not a valid keyword argument. Please refer to the API for usage.`)}),f.forEach((m,g)=>{if(m===void 0&&!o[g].parameter_has_default)throw new Error(`No value provided for required parameter: ${o[g].parameter_name}`)}),f};async function ap(){if(this.api_info)return this.api_info;const{hf_token:u}=this.options,{config:a}=this,o={"Content-Type":"application/json"};if(u&&(o.Authorization=`Bearer ${u}`),!!a)try{let f,d;if(typeof window<"u"&&window.gradio_api_info)d=window.gradio_api_info;else{if(pc((a==null?void 0:a.version)||"2.0.0","3.30")<0)f=await this.fetch(qd,{method:"POST",body:JSON.stringify({serialize:!1,config:JSON.stringify(a)}),headers:o,credentials:"include"});else{const m=Jo(a.root,this.api_prefix,Fd);f=await this.fetch(m,{headers:o,credentials:"include"})}if(!f.ok)throw new Error(Zn);d=await f.json()}return"api"in d&&(d=d.api),d.named_endpoints["/predict"]&&!d.unnamed_endpoints[0]&&(d.unnamed_endpoints[0]=d.named_endpoints["/predict"]),lp(d,a,this.api_map)}catch(f){throw new Error("Could not get API info. "+f.message)}}async function cp(u,a,o){var f;const d={};(f=this==null?void 0:this.options)!=null&&f.hf_token&&(d.Authorization=`Bearer ${this.options.hf_token}`);const m=1e3,g=[];let k;for(let C=0;C{F.append("files",O)});try{const O=o?`${u}${this.api_prefix}/${nc}?upload_id=${o}`:`${u}${this.api_prefix}/${nc}`;k=await this.fetch(O,{method:"POST",body:F,headers:d,credentials:"include"})}catch(O){throw new Error(Zn+O.message)}if(!k.ok){const O=await k.text();return{error:`HTTP ${k.status}: ${O}`}}const R=await k.json();R&&g.push(...R)}return{files:g}}async function fp(u,a,o,f){let d=(Array.isArray(u)?u:[u]).map(g=>g.blob);const m=d.filter(g=>g.size>(f??1/0));if(m.length)throw new Error(`File size exceeds the maximum allowed size of ${f} bytes: ${m.map(g=>g.name).join(", ")}`);return await Promise.all(await this.upload_files(a,d,o).then(async g=>{if(g.error)throw new Error(g.error);return g.files?g.files.map((k,C)=>new ns({...u[C],path:k,url:`${a}${this.api_prefix}/file=${k}`})):[]}))}class ns{constructor({path:a,url:o,orig_name:f,size:d,blob:m,is_stream:g,mime_type:k,alt_text:C,b64:V}){J(this,"path"),J(this,"url"),J(this,"orig_name"),J(this,"size"),J(this,"blob"),J(this,"is_stream"),J(this,"mime_type"),J(this,"alt_text"),J(this,"b64"),J(this,"meta",{_type:"gradio.FileData"}),this.path=a,this.url=o,this.orig_name=f,this.size=d,this.blob=o?void 0:m,this.is_stream=g,this.mime_type=k,this.alt_text=C,this.b64=V}}class dp{constructor(a,o){J(this,"type"),J(this,"command"),J(this,"meta"),J(this,"fileData"),this.type="command",this.command=a,this.meta=o}}typeof process<"u"&&process.versions&&process.versions.node;function lc(u,a,o){for(;o.length>1;){const d=o.shift();if(typeof d=="string"||typeof d=="number")u=u[d];else throw new Error("Invalid key type")}const f=o.shift();if(typeof f=="string"||typeof f=="number")u[f]=a;else throw new Error("Invalid key type")}async function Xo(u,a=void 0,o=[],f=!1,d=void 0){if(Array.isArray(u)){let m=[];return await Promise.all(u.map(async(g,k)=>{var C;let V=o.slice();V.push(String(k));const F=await Xo(u[k],f?((C=d==null?void 0:d.parameters[k])==null?void 0:C.component)||void 0:a,V,!1,d);m=m.concat(F)})),m}else{if(globalThis.Buffer&&u instanceof globalThis.Buffer||u instanceof Blob)return[{path:o,blob:new Blob([u]),type:a}];if(typeof u=="object"&&u!==null){let m=[];for(const g of Object.keys(u)){const k=[...o,g],C=u[g];m=m.concat(await Xo(C,void 0,k,!1,d))}return m}}return[]}function pp(u,a){var o,f;let d=(f=(o=a==null?void 0:a.dependencies)==null?void 0:o.find(m=>m.id==u))==null?void 0:f.queue;return d!=null?!d:!a.enable_queue}function hp(u,a){return new Promise((o,f)=>{const d=new MessageChannel;d.port1.onmessage=({data:m})=>{d.port1.close(),o(m)},window.parent.postMessage(u,a,[d.port2])})}function Ar(u,a,o,f,d=!1){if(f==="input"&&!d)throw new Error("Invalid code path. Cannot skip state inputs for input.");if(f==="output"&&d)return u;let m=[],g=0;const k=f==="input"?a.inputs:a.outputs;for(let C=0;CR.id===V);if((F==null?void 0:F.type)==="state"){if(d)if(u.length===k.length){const R=u[g];m.push(R),g++}else m.push(null);else{g++;continue}continue}else{const R=u[g];m.push(R),g++}}return m}async function mp(u,a,o){const f=this;await gp(f,a);const d=await Xo(a,void 0,[],!0,o);return(await Promise.all(d.map(async({path:m,blob:g,type:k})=>{if(!g)return{path:m,type:k};const C=await f.upload_files(u,[g]),V=C.files&&C.files[0];return{path:m,file_url:V,type:k,name:typeof File<"u"&&g instanceof File?g==null?void 0:g.name:void 0}}))).forEach(({path:m,file_url:g,type:k,name:C})=>{if(k==="Gallery")lc(a,g,m);else if(g){const V=new ns({path:g,orig_name:C});lc(a,V,m)}}),a}async function gp(u,a){var o,f;if(!((o=u.config)!=null&&o.root||(f=u.config)!=null&&f.root_url))throw new Error(vc);await _c(u,a)}async function _c(u,a,o=[]){for(const f in a)a[f]instanceof dp?await vp(u,a,f):typeof a[f]=="object"&&a[f]!==null&&await _c(u,a[f],[...o,f])}async function vp(u,a,o){var f,d;let m=a[o];const g=((f=u.config)==null?void 0:f.root)||((d=u.config)==null?void 0:d.root_url);if(!g)throw new Error(vc);try{let k,C;if(typeof process<"u"&&process.versions&&process.versions.node){const O=await tc(()=>import("./__vite-browser-external-DYxpcVy9-BIHI7g3E.js"),[],import.meta.url);C=(await tc(async()=>{const{resolve:b}=await import("./__vite-browser-external-DYxpcVy9-BIHI7g3E.js");return{resolve:b}},[],import.meta.url)).resolve(process.cwd(),m.meta.path),k=await O.readFile(C)}else throw new Error(Zd);const V=new Blob([k],{type:"application/octet-stream"}),F=await u.upload_files(g,[V]),R=F.files&&F.files[0];if(R){const O=new ns({path:R,orig_name:m.meta.name||""});a[o]=O}}catch(k){console.error(bd,k)}}async function yp(u,a,o){const f={"Content-Type":"application/json"};this.options.hf_token&&(f.Authorization=`Bearer ${this.options.hf_token}`);try{var d=await this.fetch(u,{method:"POST",body:JSON.stringify(a),headers:{...f,...o},credentials:"include"})}catch{return[{error:Zn},500]}let m,g;try{m=await d.json(),g=d.status}catch(k){m={error:`Could not parse server response: ${k}`},g=500}return[m,g]}async function wp(u,a={}){let o=!1,f=!1;if(!this.config)throw new Error("Could not resolve app config");if(typeof u=="number")this.config.dependencies.find(d=>d.id==u);else{const d=u.replace(/^\//,"");this.config.dependencies.find(m=>m.id==this.api_map[d])}return new Promise(async(d,m)=>{const g=this.submit(u,a,null,null,!0);let k;for await(const C of g)C.type==="data"&&(f&&d(k),o=!0,k=C),C.type==="status"&&(C.stage==="error"&&m(C),C.stage==="complete"&&(f=!0,o&&d(k)))})}async function Br(u,a,o){let f=a==="subdomain"?`https://huggingface.co/api/spaces/by-subdomain/${u}`:`https://huggingface.co/api/spaces/${u}`,d,m;try{if(d=await fetch(f),m=d.status,m!==200)throw new Error;d=await d.json()}catch{o({status:"error",load_status:"error",message:Gd,detail:"NOT_FOUND"});return}if(!d||m!==200)return;const{runtime:{stage:g},id:k}=d;switch(g){case"STOPPED":case"SLEEPING":o({status:"sleeping",load_status:"pending",message:"Space is asleep. Waking it up...",detail:g}),setTimeout(()=>{Br(u,a,o)},1e3);break;case"PAUSED":o({status:"paused",load_status:"error",message:"This space has been paused by the author. If you would like to try this demo, consider duplicating the space.",detail:g,discussions_enabled:await oc(k)});break;case"RUNNING":case"RUNNING_BUILDING":o({status:"running",load_status:"complete",message:"Space is running.",detail:g});break;case"BUILDING":o({status:"building",load_status:"pending",message:"Space is building...",detail:g}),setTimeout(()=>{Br(u,a,o)},1e3);break;case"APP_STARTING":o({status:"starting",load_status:"pending",message:"Space is starting...",detail:g}),setTimeout(()=>{Br(u,a,o)},1e3);break;default:o({status:"space_error",load_status:"error",message:"This space is experiencing an issue.",detail:g,discussions_enabled:await oc(k)});break}}const kc=async(u,a)=>{let o=0;const f=12,d=5e3;return new Promise(m=>{Br(u,ts.test(u)?"space_name":"subdomain",g=>{a(g),g.status==="running"||g.status==="error"||g.status==="paused"||g.status==="space_error"?m():(g.status==="sleeping"||g.status==="building")&&(o{kc(u,a).then(m)},d)):m())})})},_p=/^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;async function oc(u){try{const a=await fetch(`https://huggingface.co/api/spaces/${u}/discussions`,{method:"HEAD"}),o=a.headers.get("x-error-message");return!(!a.ok||o&&_p.test(o))}catch{return!1}}async function kp(u,a){const o={};a&&(o.Authorization=`Bearer ${a}`);try{const f=await fetch(`https://huggingface.co/api/spaces/${u}/${Ud}`,{headers:o});if(f.status!==200)throw new Error("Space hardware could not be obtained.");const{hardware:d}=await f.json();return d.current}catch(f){throw new Error(f.message)}}async function Sp(u,a,o){const f={};o&&(f.Authorization=`Bearer ${o}`);const d={seconds:a};try{const m=await fetch(`https://huggingface.co/api/spaces/${u}/${Ad}`,{method:"POST",headers:{"Content-Type":"application/json",...f},body:JSON.stringify(d)});if(m.status!==200)throw new Error("Could not set sleep timeout on duplicated Space. Please visit *ADD HF LINK TO SETTINGS* to set a timeout manually to reduce billing charges.");return await m.json()}catch(m){throw new Error(m.message)}}const sc=["cpu-basic","cpu-upgrade","cpu-xl","t4-small","t4-medium","a10g-small","a10g-large","a10g-largex2","a10g-largex4","a100-large","zero-a10g","h100","h100x8"];async function Ep(u,a){const{hf_token:o,private:f,hardware:d,timeout:m,auth:g}=a;if(d&&!sc.includes(d))throw new Error(`Invalid hardware type provided. Valid types are: ${sc.map($=>`"${$}"`).join(",")}.`);const{http_protocol:k,host:C}=await Zi(u,o);let V=null;if(g){const $=await yc(k,C,g,fetch);$&&(V=wc($))}const F={Authorization:`Bearer ${o}`,"Content-Type":"application/json",...V?{Cookie:V.join("; ")}:{}},R=(await(await fetch("https://huggingface.co/api/whoami-v2",{headers:F})).json()).name,O=u.split("/")[1],b={repository:`${R}/${O}`};f&&(b.private=!0);let ne;try{d||(ne=await kp(u,o))}catch($){throw Error(es+$.message)}const P=d||ne||"cpu-basic";b.hardware=P;try{const $=await fetch(`https://huggingface.co/api/spaces/${u}/duplicate`,{method:"POST",headers:F,body:JSON.stringify(b)});if($.status===409)try{return await Zo.connect(`${R}/${O}`,a)}catch(ce){throw console.error("Failed to connect Client instance:",ce),ce}else if($.status!==200)throw new Error($.statusText);const X=await $.json();return await Sp(`${R}/${O}`,m||300,o),await Zo.connect(xp(X.url),a)}catch($){throw new Error($)}}function xp(u){const a=/https:\/\/huggingface.co\/spaces\/([^/]+\/[^/]+)/,o=u.match(a);if(o)return o[1]}var un;class Cp extends TransformStream{constructor(a={allowCR:!1}){super({transform:(o,f)=>{for(o=Ur(this,un)+o;;){const d=o.indexOf(` `),m=a.allowCR?o.indexOf("\r"):-1;if(m!==-1&&m!==o.length-1&&(d===-1||d-1>m)){f.enqueue(o.slice(0,m)),o=o.slice(m+1);continue}if(d===-1)break;const g=o[d-1]==="\r"?d-1:d;f.enqueue(o.slice(0,g)),o=o.slice(d+1)}Dd(this,un,o)},flush:o=>{if(Ur(this,un)==="")return;const f=a.allowCR&&Ur(this,un).endsWith("\r")?Ur(this,un).slice(0,-1):Ur(this,un);o.enqueue(f)}}),Od(this,un,"")}}un=new WeakMap;function Pp(u){let a=new TextDecoderStream,o=new Cp({allowCR:!0});return u.pipeThrough(a).pipeThrough(o)}function Np(u){let a=/[:]\s*/.exec(u),o=a&&a.index;if(o)return[u.substring(0,o),u.substring(o+a[0].length)]}function uc(u,a,o){u.get(a)||u.set(a,o)}async function*jp(u,a){if(!u.body)return;let o=Pp(u.body),f,d=o.getReader(),m;for(;;){if(a&&a.aborted)return d.cancel();if(f=await d.read(),f.done)return;if(!f.value){m&&(yield m),m=void 0;continue}let[g,k]=Np(f.value)||[];g&&(g==="data"?(m||(m={}),m[g]=m[g]?m[g]+` `+k:k):g==="event"?(m||(m={}),m[g]=k):g==="id"?(m||(m={}),m[g]=+k||k):g==="retry"&&(m||(m={}),m[g]=+k||void 0))}}async function zp(u,a){let o=new Request(u,a);uc(o.headers,"Accept","text/event-stream"),uc(o.headers,"Content-Type","application/json");let f=await fetch(o);if(!f.ok)throw f;return jp(f,o.signal)}async function Rp(){let{event_callbacks:u,unclosed_events:a,pending_stream_messages:o,stream_status:f,config:d,jwt:m}=this;const g=this;if(!d)throw new Error("Could not resolve app config");f.open=!0;let k=null,C=new URLSearchParams({session_hash:this.session_hash}).toString(),V=new URL(`${d.root}${this.api_prefix}/${hc}?${C}`);if(m&&V.searchParams.set("__sign",m),k=this.stream(V),!k){console.warn("Cannot connect to SSE endpoint: "+V.toString());return}k.onmessage=async function(F){let R=JSON.parse(F.data);if(R.msg==="close_stream"){rs(f,g.abort_controller);return}const O=R.event_id;if(!O)await Promise.all(Object.keys(u).map(b=>u[b](R)));else if(u[O]&&d){R.msg==="process_completed"&&["sse","sse_v1","sse_v2","sse_v2.1","sse_v3"].includes(d.protocol)&&a.delete(O);let b=u[O];typeof window<"u"&&typeof document<"u"?setTimeout(b,0,R):b(R)}else o[O]||(o[O]=[]),o[O].push(R)},k.onerror=async function(F){console.error(F),await Promise.all(Object.keys(u).map(R=>u[R]({msg:"broken_connection",message:Zn})))}}function rs(u,a){u&&(u.open=!1,a==null||a.abort())}function Tp(u,a,o){u[a]?o.data.forEach((f,d)=>{let m=Lp(u[a][d],f);u[a][d]=m,o.data[d]=m}):(u[a]=[],o.data.forEach((f,d)=>{u[a][d]=f}))}function Lp(u,a){return a.forEach(([o,f,d])=>{u=Op(u,f,o,d)}),u}function Op(u,a,o,f){if(a.length===0){if(o==="replace")return f;if(o==="append")return u+f;throw new Error(`Unsupported action: ${o}`)}let d=u;for(let g=0;g{console.warn("Method not implemented.")},onerror:null,onmessage:null,onopen:null,readyState:0,url:u.toString(),withCredentials:!1,CONNECTING:0,OPEN:1,CLOSED:2,addEventListener:()=>{throw new Error("Method not implemented.")},dispatchEvent:()=>{throw new Error("Method not implemented.")},removeEventListener:()=>{throw new Error("Method not implemented.")}};return zp(u,a).then(async f=>{o.readyState=o.OPEN;try{for await(const d of f)o.onmessage&&o.onmessage(d);o.readyState=o.CLOSED}catch(d){o.onerror&&o.onerror(d),o.readyState=o.CLOSED}}).catch(f=>{console.error(f),o.onerror&&o.onerror(f),o.readyState=o.CLOSED}),o}function $p(u,a={},o,f,d){var m;try{let g=function(ie){(d||fe[ie.type])&&F(ie)},k=function(){for(xn=!0;jt.length>0;)jt.shift()({value:void 0,done:!0})},C=function(ie){jt.length>0?jt.shift()(ie):Cn.push(ie)},V=function(ie){C(Ip(ie)),k()},F=function(ie){C({value:ie,done:!1})},R=function(){return Cn.length>0?Promise.resolve(Cn.shift()):new Promise(ie=>jt.push(ie))};const{hf_token:O}=this.options,{fetch:b,app_reference:ne,config:P,session_hash:$,api_info:X,api_map:ce,stream_status:Ce,pending_stream_messages:de,pending_diff_streams:Pe,event_callbacks:me,unclosed_events:$e,post_data:Te,options:Be,api_prefix:Ie}=this,ht=this;if(!X)throw new Error("No API found");if(!P)throw new Error("Could not resolve app config");let{fn_index:Q,endpoint_info:Me,dependency:Le}=Mp(X,u,ce,P),tt=up(a,Me),ue,D,j=P.protocol??"ws",A="",T=()=>A;const h=typeof u=="number"?"/predict":u;let S,H=null,K=!1,te={},Z=typeof window<"u"&&typeof document<"u"?new URLSearchParams(window.location.search).toString():"";const fe=((m=Be==null?void 0:Be.events)==null?void 0:m.reduce((ie,nt)=>(ie[nt]=!0,ie),{}))||{};async function oe(){let ie={},nt={};j==="ws"?(ue&&ue.readyState===0?ue.addEventListener("open",()=>{ue.close()}):ue.close(),ie={fn_index:Q,session_hash:$}):(ie={event_id:H},nt={event_id:H,session_hash:$,fn_index:Q});try{if(!P)throw new Error("Could not resolve app config");"event_id"in nt&&await b(`${P.root}${Ie}/${Hd}`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify(nt)}),await b(`${P.root}${Ie}/${Wd}`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify(ie)})}catch{console.warn("The `/reset` endpoint could not be called. Subsequent endpoint results may be unreliable.")}}const pe=async ie=>{await this._resolve_heartbeat(ie)};async function Ke(ie){if(!P)return;let nt=ie.render_id;P.components=[...P.components.filter(Fe=>Fe.props.rendered_in!==nt),...ie.components],P.dependencies=[...P.dependencies.filter(Fe=>Fe.rendered_in!==nt),...ie.dependencies];const cn=P.components.some(Fe=>Fe.type==="state"),Ee=P.dependencies.some(Fe=>Fe.targets.some(Oe=>Oe[1]==="unload"));P.connect_heartbeat=cn||Ee,await pe(P),g({type:"render",data:ie,endpoint:h,fn_index:Q})}this.handle_blob(P.root,tt,Me).then(async ie=>{var nt;if(S={data:Ar(ie,Le,P.components,"input",!0)||[],event_data:o,fn_index:Q,trigger_id:f},pp(Q,P))g({type:"status",endpoint:h,stage:"pending",queue:!1,fn_index:Q,time:new Date}),Te(`${P.root}${Ie}/run${h.startsWith("/")?h:`/${h}`}${Z?"?"+Z:""}`,{...S,session_hash:$}).then(([Ee,Fe])=>{const Oe=Ee.data;Fe==200?(g({type:"data",endpoint:h,fn_index:Q,data:Ar(Oe,Le,P.components,"output",Be.with_null_state),time:new Date,event_data:o,trigger_id:f}),Ee.render_config&&Ke(Ee.render_config),g({type:"status",endpoint:h,fn_index:Q,stage:"complete",eta:Ee.average_duration,queue:!1,time:new Date})):g({type:"status",stage:"error",endpoint:h,fn_index:Q,message:Ee.error,queue:!1,time:new Date})}).catch(Ee=>{g({type:"status",stage:"error",message:Ee.message,endpoint:h,fn_index:Q,queue:!1,time:new Date})});else if(j=="ws"){const{ws_protocol:Ee,host:Fe}=await Zi(ne,O);g({type:"status",stage:"pending",queue:!0,endpoint:h,fn_index:Q,time:new Date});let Oe=new URL(`${Ee}://${ep(Fe,P.root,!0)}/queue/join${Z?"?"+Z:""}`);this.jwt&&Oe.searchParams.set("__sign",this.jwt),ue=new WebSocket(Oe),ue.onclose=Ne=>{Ne.wasClean||g({type:"status",stage:"error",broken:!0,message:Zn,queue:!0,endpoint:h,fn_index:Q,time:new Date})},ue.onmessage=function(Ne){const Ve=JSON.parse(Ne.data),{type:je,status:ge,data:se}=Yo(Ve,te[Q]);if(je==="update"&&ge&&!K)g({type:"status",endpoint:h,fn_index:Q,time:new Date,...ge}),ge.stage==="error"&&ue.close();else if(je==="hash"){ue.send(JSON.stringify({fn_index:Q,session_hash:$}));return}else je==="data"?ue.send(JSON.stringify({...S,session_hash:$})):je==="complete"?K=ge:je==="log"?g({type:"log",title:se.title,log:se.log,level:se.level,endpoint:h,duration:se.duration,visible:se.visible,fn_index:Q}):je==="generating"&&g({type:"status",time:new Date,...ge,stage:ge==null?void 0:ge.stage,queue:!0,endpoint:h,fn_index:Q});se&&(g({type:"data",time:new Date,data:Ar(se.data,Le,P.components,"output",Be.with_null_state),endpoint:h,fn_index:Q,event_data:o,trigger_id:f}),K&&(g({type:"status",time:new Date,...K,stage:ge==null?void 0:ge.stage,queue:!0,endpoint:h,fn_index:Q}),ue.close()))},pc(P.version||"2.0.0","3.6")<0&&addEventListener("open",()=>ue.send(JSON.stringify({hash:$})))}else if(j=="sse"){g({type:"status",stage:"pending",queue:!0,endpoint:h,fn_index:Q,time:new Date});var cn=new URLSearchParams({fn_index:Q.toString(),session_hash:$}).toString();let Ee=new URL(`${P.root}${Ie}/${hc}?${Z?Z+"&":""}${cn}`);if(this.jwt&&Ee.searchParams.set("__sign",this.jwt),D=this.stream(Ee),!D)return Promise.reject(new Error("Cannot connect to SSE endpoint: "+Ee.toString()));D.onmessage=async function(Fe){const Oe=JSON.parse(Fe.data),{type:Ne,status:Ve,data:je}=Yo(Oe,te[Q]);if(Ne==="update"&&Ve&&!K)g({type:"status",endpoint:h,fn_index:Q,time:new Date,...Ve}),Ve.stage==="error"&&(D==null||D.close(),k());else if(Ne==="data"){let[ge,se]=await Te(`${P.root}${Ie}/queue/data`,{...S,session_hash:$,event_id:H});se!==200&&(g({type:"status",stage:"error",message:Zn,queue:!0,endpoint:h,fn_index:Q,time:new Date}),D==null||D.close(),k())}else Ne==="complete"?K=Ve:Ne==="log"?g({type:"log",title:je.title,log:je.log,level:je.level,endpoint:h,duration:je.duration,visible:je.visible,fn_index:Q}):(Ne==="generating"||Ne==="streaming")&&g({type:"status",time:new Date,...Ve,stage:Ve==null?void 0:Ve.stage,queue:!0,endpoint:h,fn_index:Q});je&&(g({type:"data",time:new Date,data:Ar(je.data,Le,P.components,"output",Be.with_null_state),endpoint:h,fn_index:Q,event_data:o,trigger_id:f}),K&&(g({type:"status",time:new Date,...K,stage:Ve==null?void 0:Ve.stage,queue:!0,endpoint:h,fn_index:Q}),D==null||D.close(),k()))}}else if(j=="sse_v1"||j=="sse_v2"||j=="sse_v2.1"||j=="sse_v3"){g({type:"status",stage:"pending",queue:!0,endpoint:h,fn_index:Q,time:new Date});let Ee="";typeof window<"u"&&typeof document<"u"&&(Ee=(nt=window==null?void 0:window.location)==null?void 0:nt.hostname);const Fe=Ee.includes(".dev.")?`https://moon-${Ee.split(".")[1]}.dev.spaces.huggingface.tech`:"https://huggingface.co";(typeof window<"u"&&typeof document<"u"&&window.parent!=window&&window.supports_zerogpu_headers?hp("zerogpu-headers",Fe):Promise.resolve(null)).then(Oe=>Te(`${P.root}${Ie}/${Id}?${Z}`,{...S,session_hash:$},Oe)).then(async([Oe,Ne])=>{if(Ne===503)g({type:"status",stage:"error",message:mc,queue:!0,endpoint:h,fn_index:Q,time:new Date});else if(Ne===422)g({type:"status",stage:"error",message:Oe.detail,queue:!0,endpoint:h,fn_index:Q,code:"validation_error",time:new Date}),k();else if(Ne!==200)g({type:"status",stage:"error",broken:!1,message:Oe.detail,queue:!0,endpoint:h,fn_index:Q,time:new Date});else{H=Oe.event_id,A=H;let Ve=async function(je){try{const{type:ge,status:se,data:rt,original_msg:bn}=Yo(je,te[Q]);if(ge=="heartbeat")return;if(ge==="update"&&se&&!K)g({type:"status",endpoint:h,fn_index:Q,time:new Date,original_msg:bn,...se});else if(ge==="complete")K=se;else if(ge=="unexpected_error"||ge=="broken_connection"){console.error("Unexpected error",se==null?void 0:se.message);const Nn=ge==="broken_connection";g({type:"status",stage:"error",message:(se==null?void 0:se.message)||"An Unexpected Error Occurred!",queue:!0,endpoint:h,broken:Nn,session_not_found:se==null?void 0:se.session_not_found,fn_index:Q,time:new Date})}else if(ge==="log"){g({type:"log",title:rt.title,log:rt.log,level:rt.level,endpoint:h,duration:rt.duration,visible:rt.visible,fn_index:Q});return}else(ge==="generating"||ge==="streaming")&&(g({type:"status",time:new Date,...se,stage:se==null?void 0:se.stage,queue:!0,endpoint:h,fn_index:Q}),rt&&Le.connection!=="stream"&&["sse_v2","sse_v2.1","sse_v3"].includes(j)&&Tp(Pe,H,rt));rt&&(g({type:"data",time:new Date,data:Ar(rt.data,Le,P.components,"output",Be.with_null_state),endpoint:h,fn_index:Q}),rt.render_config&&await Ke(rt.render_config),K&&(g({type:"status",time:new Date,...K,stage:se==null?void 0:se.stage,queue:!0,endpoint:h,fn_index:Q}),k())),((se==null?void 0:se.stage)==="complete"||(se==null?void 0:se.stage)==="error")&&(me[H]&&delete me[H],H in Pe&&delete Pe[H])}catch(ge){console.error("Unexpected client exception",ge),g({type:"status",stage:"error",message:"An Unexpected Error Occurred!",queue:!0,endpoint:h,fn_index:Q,time:new Date}),["sse_v2","sse_v2.1","sse_v3"].includes(j)&&(rs(Ce,ht.abort_controller),Ce.open=!1,k())}};H in de&&(de[H].forEach(je=>Ve(je)),delete de[H]),me[H]=Ve,$e.add(H),Ce.open||await this.open_stream()}})}});let xn=!1;const Cn=[],jt=[],Pn={[Symbol.asyncIterator]:()=>Pn,next:R,throw:async ie=>(V(ie),R()),return:async()=>(k(),R()),cancel:oe,event_id:T};return Pn}catch(g){throw console.error("Submit function encountered an error:",g),g}}function Ip(u){return{then:(a,o)=>o(u)}}function Mp(u,a,o,f){let d,m,g;if(typeof a=="number")d=a,m=u.unnamed_endpoints[d],g=f.dependencies.find(k=>k.id==a);else{const k=a.replace(/^\//,"");d=o[k],m=u.named_endpoints[a.trim()],g=f.dependencies.find(C=>C.id==o[k])}if(typeof d!="number")throw new Error("There is no endpoint matching that name of fn_index matching that number.");return{fn_index:d,endpoint_info:m,dependency:g}}class Zo{constructor(a,o={events:["data"]}){J(this,"app_reference"),J(this,"options"),J(this,"deep_link",null),J(this,"config"),J(this,"api_prefix",""),J(this,"api_info"),J(this,"api_map",{}),J(this,"session_hash",Math.random().toString(36).substring(2)),J(this,"jwt",!1),J(this,"last_status",{}),J(this,"cookies",null),J(this,"stream_status",{open:!1}),J(this,"closed",!1),J(this,"pending_stream_messages",{}),J(this,"pending_diff_streams",{}),J(this,"event_callbacks",{}),J(this,"unclosed_events",new Set),J(this,"heartbeat_event",null),J(this,"abort_controller",null),J(this,"stream_instance",null),J(this,"current_payload"),J(this,"ws_map",{}),J(this,"view_api"),J(this,"upload_files"),J(this,"upload"),J(this,"handle_blob"),J(this,"post_data"),J(this,"submit"),J(this,"predict"),J(this,"open_stream"),J(this,"resolve_config"),J(this,"resolve_cookies");var f;this.app_reference=a,this.deep_link=((f=o.query_params)==null?void 0:f.deep_link)||null,o.events||(o.events=["data"]),this.options=o,this.current_payload={},this.view_api=ap.bind(this),this.upload_files=cp.bind(this),this.handle_blob=mp.bind(this),this.post_data=yp.bind(this),this.submit=$p.bind(this),this.predict=wp.bind(this),this.open_stream=Rp.bind(this),this.resolve_config=np.bind(this),this.resolve_cookies=rp.bind(this),this.upload=fp.bind(this),this.fetch=this.fetch.bind(this),this.handle_space_success=this.handle_space_success.bind(this),this.stream=this.stream.bind(this)}get_url_config(a=null){if(!this.config)throw new Error(an);a===null&&(a=window.location.href);const o=g=>g.replace(/^\/+|\/+$/g,"");let f=o(new URL(this.config.root).pathname),d=o(new URL(a).pathname),m;return d.startsWith(f)?m=o(d.substring(f.length)):m="",this.get_page_config(m)}get_page_config(a){if(!this.config)throw new Error(an);let o=this.config;return a in o.page||(a=""),{...o,current_page:a,layout:o.page[a].layout,components:o.components.filter(f=>o.page[a].components.includes(f.id)),dependencies:this.config.dependencies.filter(f=>o.page[a].dependencies.includes(f.id))}}fetch(a,o){const f=new Headers((o==null?void 0:o.headers)||{});if(this&&this.cookies&&f.append("Cookie",this.cookies),this&&this.options.headers)for(const d in this.options.headers)f.append(d,this.options.headers[d]);return fetch(a,{...o,headers:f})}stream(a){const o=new Headers;if(this&&this.cookies&&o.append("Cookie",this.cookies),this&&this.options.headers)for(const f in this.options.headers)o.append(f,this.options.headers[f]);return this&&this.options.hf_token&&o.append("Authorization",`Bearer ${this.options.hf_token}`),this.abort_controller=new AbortController,this.stream_instance=Dp(a.toString(),{credentials:"include",headers:o,signal:this.abort_controller.signal}),this.stream_instance}async init(){var a;this.options.auth&&await this.resolve_cookies(),await this._resolve_config().then(({config:o})=>this._resolve_heartbeat(o)),this.api_info=await this.view_api(),this.api_map=tp(((a=this.config)==null?void 0:a.dependencies)||[])}async _resolve_heartbeat(a){if(a&&(this.config=a,this.api_prefix=a.api_prefix||"",this.config&&this.config.connect_heartbeat&&this.config.space_id&&this.options.hf_token&&(this.jwt=await rc(this.config.space_id,this.options.hf_token,this.cookies))),a.space_id&&this.options.hf_token&&(this.jwt=await rc(a.space_id,this.options.hf_token)),this.config&&this.config.connect_heartbeat){const o=new URL(`${this.config.root}${this.api_prefix}/${Bd}/${this.session_hash}`);this.jwt&&o.searchParams.set("__sign",this.jwt),this.heartbeat_event||(this.heartbeat_event=this.stream(o))}}static async connect(a,o={events:["data"]}){const f=new this(a,o);return o.session_hash&&(f.session_hash=o.session_hash),await f.init(),f}async reconnect(){const a=new URL(`${this.config.root}${this.api_prefix}/${Qd}`);let o;try{const f=await this.fetch(a);if(!f.ok)throw new Error;o=(await f.json()).app_id}catch{return"broken"}return o!==this.config.app_id?"changed":"connected"}close(){this.closed=!0,rs(this.stream_status,this.abort_controller)}set_current_payload(a){this.current_payload=a}static async duplicate(a,o={events:["data"]}){return Ep(a,o)}async _resolve_config(){const{http_protocol:a,host:o,space_id:f}=await Zi(this.app_reference,this.options.hf_token),{status_callback:d}=this.options;f&&d&&await kc(f,d);let m;try{let g=`${a}//${o}`;if(m=await this.resolve_config(g),!m)throw new Error(an);return this.config_success(m)}catch(g){if(f&&d)Br(f,ts.test(f)?"space_name":"subdomain",this.handle_space_success);else throw d&&d({status:"error",message:"Could not load this space.",load_status:"error",detail:"NOT_FOUND"}),Error(g)}}async config_success(a){if(this.config=a,this.api_prefix=a.api_prefix||"",this.config.auth_required)return this.prepare_return_obj();try{this.api_info=await this.view_api()}catch(o){console.error(Kd+o.message)}return this.prepare_return_obj()}async handle_space_success(a){var o;if(!this)throw new Error(an);const{status_callback:f}=this.options;if(f&&f(a),a.status==="running")try{if(this.config=await this._resolve_config(),this.api_prefix=((o=this==null?void 0:this.config)==null?void 0:o.api_prefix)||"",!this.config)throw new Error(an);return await this.config_success(this.config)}catch(d){throw f&&f({status:"error",message:"Could not load this space.",load_status:"error",detail:"NOT_FOUND"}),d}}async component_server(a,o,f){var d;if(!this.config)throw new Error(an);const m={},{hf_token:g}=this.options,{session_hash:k}=this;g&&(m.Authorization=`Bearer ${this.options.hf_token}`);let C,V=this.config.components.find(R=>R.id===a);(d=V==null?void 0:V.props)!=null&&d.root_url?C=V.props.root_url:C=this.config.root;let F;if("binary"in f){F=new FormData;for(const R in f.data)R!=="binary"&&F.append(R,f.data[R]);F.set("component_id",a.toString()),F.set("fn_name",o),F.set("session_hash",k)}else F=JSON.stringify({data:f,component_id:a,fn_name:o,session_hash:k}),m["Content-Type"]="application/json";g&&(m.Authorization=`Bearer ${g}`);try{const R=await this.fetch(`${C}${this.api_prefix}/${Vd}/`,{method:"POST",body:F,headers:m,credentials:"include"});if(!R.ok)throw new Error("Could not connect to component server: "+R.statusText);return await R.json()}catch(R){console.warn(R)}}set_cookies(a){this.cookies=wc(a).join("; ")}prepare_return_obj(){return{config:this.config,predict:this.predict,submit:this.submit,view_api:this.view_api,component_server:this.component_server}}async connect_ws(a){return new Promise((o,f)=>{let d;try{d=new WebSocket(a)}catch{this.ws_map[a]="failed";return}this.ws_map[a]="pending",d.onopen=()=>{this.ws_map[a]=d,o()},d.onerror=m=>{console.error("WebSocket error:",m),this.close_ws(a),this.ws_map[a]="failed",o()},d.onclose=()=>{this.ws_map[a]="closed"},d.onmessage=m=>{}})}async send_ws_message(a,o){if(!(a in this.ws_map))await this.connect_ws(a);else if(this.ws_map[a]==="pending"||this.ws_map[a]==="closed"||this.ws_map[a]==="failed")return;const f=this.ws_map[a];f instanceof WebSocket?f.send(JSON.stringify(o)):this.post_data(a,o)}async close_ws(a){if(a in this.ws_map){const o=this.ws_map[a];o instanceof WebSocket&&(o.close(),delete this.ws_map[a])}}}const ac=4;function Sc(){const{origin:u,pathname:a}=window.location,o=a.replace(/\/+$/,"");return!o||o==="/"?u:`${u}${o}`}async function Fp(u){var m;const a=new FormData;a.append("files",u,u.name);const o=await fetch(new URL("gradio_api/upload",Sc()+"/"),{method:"POST",body:a,credentials:"include"});if(!o.ok)throw new Error(`Document upload failed (${o.status}).`);const f=await o.json(),d=typeof f[0]=="string"?f[0]:(m=f[0])==null?void 0:m.path;if(!d)throw new Error("Upload did not return a file path.");return{path:d,orig_name:u.name,size:u.size,mime_type:u.type||void 0,meta:{_type:"gradio.FileData"}}}function Up(u,a){var f,d;const o=new Map;for(const m of u)o.set(m.page_number,m);for(const m of a){const g=o.get(m.page_number);(!g||m.status==="complete"||(((f=m.markdown)==null?void 0:f.length)??0)>=(((d=g.markdown)==null?void 0:d.length)??0))&&o.set(m.page_number,m)}return[...o.values()].sort((m,g)=>m.page_number-g.page_number)}function Ap(u,a){for(let o=1;o<=a;o+=1){const f=u.find(d=>d.page_number===o);if(!f||f.status!=="complete")return o-1}return a}function cc(u,a){var o;return u.length<=1?((o=u[0])==null?void 0:o[a])??"":u.map(f=>` ${f[a]??""}`).join(` --- `)}async function Bp(u){const{fileData:a,modelChoice:o,prompt:f,signal:d,handlers:m}=u,g=await Zo.connect(Sc());let k=[],C=1,V=0,F;for(;V1?`Running pages ${V+1}–${Math.min(C,V+ac)} of ${C}…`:"Running OCR…");const R=g.submit("/run_ocr",{image_path:a,page_index:V,page_count:ac,model_choice:o,prompt:f});let O=!1,b=!1;for await(const P of R){if(d!=null&&d.aborted)throw new DOMException("Aborted","AbortError");if(P.type==="status"){if((P.stage??"")==="error")throw new Error("OCR job failed in the queue.");continue}if(P.type!=="data")continue;b=!0;const X=Array.isArray(P.data)?P.data[0]:P.data;if(!X||typeof X!="object")continue;C=X.total_pages||C,X.page_preview&&(F=X.page_preview),k=Up(k,X.pages??[]),O=!!X.batch_complete;const ce=X.event==="page_start"?`Preparing page ${X.current_page}/${X.total_pages}`:X.event==="stream"?`Streaming page ${X.current_page}/${X.total_pages} · ${X.char_count.toLocaleString()} chars`:X.event==="page_complete"?`Page ${X.current_page}/${X.total_pages} complete`:`Batch complete · ${X.char_count.toLocaleString()} chars`;if(m.onStatus(ce),m.onUpdate({pages:k,markdown:cc(k,"markdown"),renderMarkdown:cc(k,"render_markdown"),preview:F,totalPages:C,currentPage:X.current_page,charCount:k.reduce((Ce,de)=>{var Pe;return Ce+(((Pe=de.markdown)==null?void 0:Pe.length)??0)},0)}),O)break}if(!b)throw new Error("OCR stream closed without data.");const ne=Ap(k,C);if(ne>=C)break;if(!O&&ne===V)throw new Error(`OCR stalled on page ${V+1}.`);V=ne}m.onStatus(`Done · ${k.reduce((R,O)=>{var b;return R+(((b=O.markdown)==null?void 0:b.length)??0)},0).toLocaleString()} chars`)}const is="Tonic/ocr-ebola",Xi="https://tonic-ocr-ebola.hf.space",Vp=`from gradio_client import Client, handle_file client = Client("${is}") job = client.submit( handle_file("form.pdf"), # or a .png / .jpg / .webp 0, # page_index (0-based) 4, # page_count per ZeroGPU lease "OvisOCR2", # or "GLM-OCR" "", # prompt override (empty = model default) api_name="/run_ocr", ) for chunk in job: print(chunk["event"], chunk.get("current_page"), chunk.get("char_count")) if chunk.get("event") == "complete": print(chunk["markdown"][:500]) `,Wp=`import { Client } from "@gradio/client"; const client = await Client.connect("${is}"); const stream = client.submit("/run_ocr", { image_path: file, // File / Blob / FileData page_index: 0, page_count: 4, model_choice: "OvisOCR2", prompt: "", }); for await (const msg of stream) { if (msg.type === "data") console.log(msg.data); } `;function Hp(){const[u,a]=Se.useState(!1),[o,f]=Se.useState("python"),[d,m]=Se.useState(!1),g=Se.useMemo(()=>o==="python"?Vp:Wp,[o]);async function k(){try{await navigator.clipboard.writeText(g),m(!0),window.setTimeout(()=>m(!1),1600)}catch{m(!1)}}return L.jsxs("section",{className:"api-docs",children:[L.jsxs("div",{className:"api-docs-bar",children:[L.jsx("button",{type:"button",className:"btn secondary",onClick:()=>a(C=>!C),children:u?"Hide API":"Use via API"}),L.jsx("a",{className:"api-link",href:`${Xi}/docs`,target:"_blank",rel:"noreferrer",children:"OpenAPI /docs"}),L.jsx("a",{className:"api-link",href:`${Xi}/gradio_api/info`,target:"_blank",rel:"noreferrer",children:"Gradio /gradio_api/info"}),L.jsx("a",{className:"api-link",href:`${Xi}/healthz`,target:"_blank",rel:"noreferrer",children:"/healthz"})]}),u&&L.jsxs("div",{className:"api-panel",children:[L.jsxs("p",{className:"api-lead",children:["Custom Vite UI — Gradio's built-in footer is not shown. Endpoint"," ",L.jsx("code",{children:"/run_ocr"})," streams page batches (events:"," ",L.jsx("code",{children:"page_start"}),", ",L.jsx("code",{children:"stream"}),", ",L.jsx("code",{children:"page_complete"}),","," ",L.jsx("code",{children:"complete"}),"). Prefer ",L.jsx("code",{children:"client.submit"})," over"," ",L.jsx("code",{children:"predict"})," so you receive every chunk."]}),L.jsxs("div",{className:"api-meta",children:[L.jsxs("span",{children:["Space: ",L.jsx("code",{children:is})]}),L.jsxs("span",{children:["URL: ",L.jsx("code",{children:Xi})]})]}),L.jsxs("div",{className:"view-toggle api-tabs",children:[L.jsx("button",{type:"button",className:o==="python"?"active":"",onClick:()=>f("python"),children:"Python"}),L.jsx("button",{type:"button",className:o==="javascript"?"active":"",onClick:()=>f("javascript"),children:"JavaScript"})]}),L.jsxs("div",{className:"api-code-wrap",children:[L.jsx("button",{type:"button",className:"api-copy",onClick:k,children:d?"Copied":"Copy"}),L.jsx("pre",{className:"api-code",children:g})]}),L.jsxs("ul",{className:"api-params",children:[L.jsxs("li",{children:[L.jsx("code",{children:"image_path"})," — uploaded image or PDF"]}),L.jsxs("li",{children:[L.jsx("code",{children:"page_index"})," — 0-based start page (default 0)"]}),L.jsxs("li",{children:[L.jsx("code",{children:"page_count"})," — pages per GPU lease (default 4, max 5)"]}),L.jsxs("li",{children:[L.jsx("code",{children:"model_choice"})," — ",L.jsx("code",{children:"OvisOCR2"})," or ",L.jsx("code",{children:"GLM-OCR"})]}),L.jsxs("li",{children:[L.jsx("code",{children:"prompt"})," — optional override; empty uses the model default"]})]})]})]})}const Qp=[{file:"table-sample.webp",label:"Financial table"},{file:"handwriting-sample.jpg",label:"Handwriting"},{file:"paper-sample.png",label:"Research page"}];function qp(){const[u,a]=Se.useState(null),[o,f]=Se.useState(null),[d,m]=Se.useState("OvisOCR2"),[g,k]=Se.useState(""),[C,V]=Se.useState(!1),[F,R]=Se.useState("Upload a document to begin"),[O,b]=Se.useState(!1),[ne,P]=Se.useState(""),[$,X]=Se.useState(""),[ce,Ce]=Se.useState(null),[de,Pe]=Se.useState([]),[me,$e]=Se.useState("render"),Te=Se.useRef(null),Be=Se.useRef(null),Ie=Se.useRef(null);Se.useEffect(()=>()=>{o&&URL.revokeObjectURL(o)},[o]),Se.useEffect(()=>{const D=Be.current;if(!D||me!=="render")return;let j=!1;return(async()=>{var A,T,h;try{(T=(A=window.MathJax)==null?void 0:A.startup)!=null&&T.promise&&await window.MathJax.startup.promise,!j&&((h=window.MathJax)!=null&&h.typesetPromise)&&await window.MathJax.typesetPromise([D])}catch{}})(),()=>{j=!0}},[$,me]);const ht=Se.useMemo(()=>ce||o,[ce,o]),Q=!!((u==null?void 0:u.type)==="application/pdf"||u!=null&&u.name.toLowerCase().endsWith(".pdf"));function Me(D){o&&URL.revokeObjectURL(o),a(D),f(D&&!D.type.includes("pdf")?URL.createObjectURL(D):null),Ce(null),P(""),X(""),Pe([]),R(D?`Ready · ${D.name}`:"Upload a document to begin")}async function Le(D){const j=await fetch(`./examples/${D}`);if(!j.ok){R(`Example not found: ${D}`);return}const A=await j.blob(),T=new File([A],D,{type:A.type||"application/octet-stream"});Me(T)}async function tt(){var j;if(!u||O)return;(j=Te.current)==null||j.abort();const D=new AbortController;Te.current=D,b(!0),R("Uploading…");try{const A=await Fp(u);await Bp({fileData:A,modelChoice:d,prompt:g,signal:D.signal,handlers:{onStatus:R,onUpdate:T=>{Pe(T.pages),P(T.markdown),X(T.renderMarkdown),T.preview&&Ce(T.preview)}}})}catch(A){A.name==="AbortError"?R("Cancelled"):R(A.message||"OCR failed")}finally{b(!1)}}function ue(){var D;(D=Te.current)==null||D.abort(),b(!1),R("Cancelled")}return L.jsxs("div",{className:"app",children:[L.jsxs("header",{className:"hero",children:[L.jsx("p",{className:"eyebrow",children:"DRC · Contact tracing OCR"}),L.jsx("h1",{children:"OCR Capacity Building as a Service"}),L.jsx("p",{className:"subtitle",children:"Open OCR for Ebola contact-tracing forms — OvisOCR2 and GLM-OCR on ZeroGPU."}),L.jsx("p",{className:"guidance",children:"Upload a page or PDF → choose a model → Run"}),L.jsxs("div",{className:"cta-row",children:[L.jsx("button",{type:"button",className:"btn secondary",onClick:()=>{var D;return(D=Ie.current)==null?void 0:D.click()},disabled:O,children:"Upload"}),L.jsx("input",{ref:Ie,type:"file",accept:"image/png,image/jpeg,image/webp,application/pdf",hidden:!0,onChange:D=>{var j;return Me(((j=D.target.files)==null?void 0:j[0])??null)}}),L.jsx("div",{className:"model-toggle",role:"group","aria-label":"Model",children:["OvisOCR2","GLM-OCR"].map(D=>L.jsx("button",{type:"button",className:d===D?"active":"",onClick:()=>m(D),disabled:O,children:D},D))}),O?L.jsx("button",{type:"button",className:"btn danger",onClick:ue,children:"Cancel"}):L.jsx("button",{type:"button",className:"btn primary",onClick:tt,disabled:!u,children:"Run OCR"})]}),L.jsx("button",{type:"button",className:"prompt-toggle",onClick:()=>V(D=>!D),children:C?"Hide prompt override":"Optional prompt override"}),C&&L.jsx("textarea",{className:"prompt-box",rows:4,value:g,onChange:D=>k(D.target.value),placeholder:"Leave empty to use the model default prompt",disabled:O}),L.jsxs("p",{className:"status","aria-live":"polite",children:[F,de.length>0?` · ${de.filter(D=>D.status==="complete").length}/${de.length||"?"} pages`:""]}),L.jsx(Hp,{})]}),L.jsxs("main",{className:"workspace",children:[L.jsxs("section",{className:"pane preview-pane",children:[L.jsx("div",{className:"pane-label",children:"Document"}),ht&&!Q?L.jsx("img",{src:ht,alt:"Document preview",className:"preview-image"}):u&&Q?L.jsxs("div",{className:"preview-fallback",children:[L.jsx("strong",{children:u.name}),L.jsx("span",{children:"PDF — page previews appear while streaming"}),ce?L.jsx("img",{src:ce,alt:"Current PDF page",className:"preview-image"}):null]}):L.jsx("div",{className:"preview-fallback",children:"Drop a form image or PDF to start"}),L.jsx("div",{className:"examples",children:Qp.map(D=>L.jsx("button",{type:"button",className:"example-chip",onClick:()=>Le(D.file),disabled:O,children:D.label},D.file))})]}),L.jsxs("section",{className:"pane result-pane",children:[L.jsxs("div",{className:"result-toolbar",children:[L.jsx("div",{className:"pane-label",children:"Result"}),L.jsxs("div",{className:"view-toggle",children:[L.jsx("button",{type:"button",className:me==="render"?"active":"",onClick:()=>$e("render"),children:"Rendered"}),L.jsx("button",{type:"button",className:me==="source"?"active":"",onClick:()=>$e("source"),children:"Markdown"})]})]}),me==="source"?L.jsx("pre",{className:"markdown-source",children:ne||"Markdown will stream here."}):L.jsx("div",{ref:Be,className:"markdown-render",dangerouslySetInnerHTML:{__html:$||"

Rendered output will appear here.

"}})]})]})]})}jd.createRoot(document.getElementById("root")).render(L.jsx(Se.StrictMode,{children:L.jsx(qp,{})}));