diff --git "a/assets/index-cj6FLmrl.js" "b/assets/index-cj6FLmrl.js" deleted file mode 100644--- "a/assets/index-cj6FLmrl.js" +++ /dev/null @@ -1,43 +0,0 @@ -var Sd=Object.defineProperty;var kd=(t,e,n)=>e in t?Sd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ko=(t,e,n)=>kd(t,typeof e!="symbol"?e+"":e,n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const s of l.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(i){if(i.ep)return;i.ep=!0;const l=n(i);fetch(i.href,l)}})();function wd(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Xu={exports:{}},Fi={},$u={exports:{}},D={};/** - * @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 Cr=Symbol.for("react.element"),Id=Symbol.for("react.portal"),xd=Symbol.for("react.fragment"),Cd=Symbol.for("react.strict_mode"),_d=Symbol.for("react.profiler"),Ed=Symbol.for("react.provider"),Td=Symbol.for("react.context"),Pd=Symbol.for("react.forward_ref"),Ld=Symbol.for("react.suspense"),Md=Symbol.for("react.memo"),Fd=Symbol.for("react.lazy"),wo=Symbol.iterator;function zd(t){return t===null||typeof t!="object"?null:(t=wo&&t[wo]||t["@@iterator"],typeof t=="function"?t:null)}var Zu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Qu=Object.assign,Gu={};function An(t,e,n){this.props=t,this.context=e,this.refs=Gu,this.updater=n||Zu}An.prototype.isReactComponent={};An.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=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,t,e,"setState")};An.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function Ku(){}Ku.prototype=An.prototype;function ys(t,e,n){this.props=t,this.context=e,this.refs=Gu,this.updater=n||Zu}var Ss=ys.prototype=new Ku;Ss.constructor=ys;Qu(Ss,An.prototype);Ss.isPureReactComponent=!0;var Io=Array.isArray,Yu=Object.prototype.hasOwnProperty,ks={current:null},Ju={key:!0,ref:!0,__self:!0,__source:!0};function qu(t,e,n){var r,i={},l=null,s=null;if(e!=null)for(r in e.ref!==void 0&&(s=e.ref),e.key!==void 0&&(l=""+e.key),e)Yu.call(e,r)&&!Ju.hasOwnProperty(r)&&(i[r]=e[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1>>1,G=T[$];if(0>>1;$i(Ot,z))Jei(nn,Ot)?(T[$]=nn,T[Je]=z,$=Je):(T[$]=Ot,T[xe]=z,$=xe);else if(Jei(nn,z))T[$]=nn,T[Je]=z,$=Je;else break e}}return A}function i(T,A){var z=T.sortIndex-A.sortIndex;return z!==0?z:T.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;t.unstable_now=function(){return l.now()}}else{var s=Date,o=s.now();t.unstable_now=function(){return s.now()-o}}var u=[],c=[],g=1,f=null,p=3,m=!1,y=!1,S=!1,F=typeof setTimeout=="function"?setTimeout:null,d=typeof clearTimeout=="function"?clearTimeout:null,a=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function h(T){for(var A=n(c);A!==null;){if(A.callback===null)r(c);else if(A.startTime<=T)r(c),A.sortIndex=A.expirationTime,e(u,A);else break;A=n(c)}}function v(T){if(S=!1,h(T),!y)if(n(u)!==null)y=!0,Dt(I);else{var A=n(c);A!==null&&Mr(v,A.startTime-T)}}function I(T,A){y=!1,S&&(S=!1,d(P),P=-1),m=!0;var z=p;try{for(h(A),f=n(u);f!==null&&(!(f.expirationTime>A)||T&&!ve());){var $=f.callback;if(typeof $=="function"){f.callback=null,p=f.priorityLevel;var G=$(f.expirationTime<=A);A=t.unstable_now(),typeof G=="function"?f.callback=G:f===n(u)&&r(u),h(A)}else r(u);f=n(u)}if(f!==null)var tn=!0;else{var xe=n(c);xe!==null&&Mr(v,xe.startTime-A),tn=!1}return tn}finally{f=null,p=z,m=!1}}var x=!1,E=null,P=-1,U=5,N=-1;function ve(){return!(t.unstable_now()-NT||125$?(T.sortIndex=z,e(c,T),n(u)===null&&T===n(c)&&(S?(d(P),P=-1):S=!0,Mr(v,z-$))):(T.sortIndex=G,e(u,T),y||m||(y=!0,Dt(I))),T},t.unstable_shouldYield=ve,t.unstable_wrapCallback=function(T){var A=p;return function(){var z=p;p=A;try{return T.apply(this,arguments)}finally{p=z}}}})(ra);na.exports=ra;var Xd=na.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 $d=_,ze=Xd;function w(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Cl=Object.prototype.hasOwnProperty,Zd=/^[: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]*$/,Co={},_o={};function Qd(t){return Cl.call(_o,t)?!0:Cl.call(Co,t)?!1:Zd.test(t)?_o[t]=!0:(Co[t]=!0,!1)}function Gd(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function Kd(t,e,n,r){if(e===null||typeof e>"u"||Gd(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Ie(t,e,n,r,i,l,s){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=l,this.removeEmptyString=s}var de={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){de[t]=new Ie(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];de[e]=new Ie(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){de[t]=new Ie(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){de[t]=new Ie(t,2,!1,t,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(t){de[t]=new Ie(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){de[t]=new Ie(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){de[t]=new Ie(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){de[t]=new Ie(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){de[t]=new Ie(t,5,!1,t.toLowerCase(),null,!1,!1)});var Is=/[\-:]([a-z])/g;function xs(t){return t[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(t){var e=t.replace(Is,xs);de[e]=new Ie(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Is,xs);de[e]=new Ie(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Is,xs);de[e]=new Ie(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){de[t]=new Ie(t,1,!1,t.toLowerCase(),null,!1,!1)});de.xlinkHref=new Ie("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){de[t]=new Ie(t,1,!1,t.toLowerCase(),null,!0,!0)});function Cs(t,e,n,r){var i=de.hasOwnProperty(e)?de[e]:null;(i!==null?i.type!==0:r||!(2o||i[s]!==l[o]){var u=` -`+i[s].replace(" at new "," at ");return t.displayName&&u.includes("")&&(u=u.replace("",t.displayName)),u}while(1<=s&&0<=o);break}}}finally{qi=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Gn(t):""}function Yd(t){switch(t.tag){case 5:return Gn(t.type);case 16:return Gn("Lazy");case 13:return Gn("Suspense");case 19:return Gn("SuspenseList");case 0:case 2:case 15:return t=bi(t.type,!1),t;case 11:return t=bi(t.type.render,!1),t;case 1:return t=bi(t.type,!0),t;default:return""}}function Pl(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case on:return"Fragment";case sn:return"Portal";case _l:return"Profiler";case _s:return"StrictMode";case El:return"Suspense";case Tl:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case sa:return(t.displayName||"Context")+".Consumer";case la:return(t._context.displayName||"Context")+".Provider";case Es:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Ts:return e=t.displayName||null,e!==null?e:Pl(t.type)||"Memo";case yt:e=t._payload,t=t._init;try{return Pl(t(e))}catch{}}return null}function Jd(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Pl(e);case 8:return e===_s?"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 e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function zt(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function ua(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function qd(t){var e=ua(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,l=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(s){r=""+s,l.call(this,s)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Nr(t){t._valueTracker||(t._valueTracker=qd(t))}function aa(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=ua(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function si(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Ll(t,e){var n=e.checked;return J({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function To(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=zt(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function ca(t,e){e=e.checked,e!=null&&Cs(t,"checked",e,!1)}function Ml(t,e){ca(t,e);var n=zt(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Fl(t,e.type,n):e.hasOwnProperty("defaultValue")&&Fl(t,e.type,zt(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Po(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Fl(t,e,n){(e!=="number"||si(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Kn=Array.isArray;function kn(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=Ar.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function ur(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var qn={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},bd=["Webkit","ms","Moz","O"];Object.keys(qn).forEach(function(t){bd.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),qn[e]=qn[t]})});function pa(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||qn.hasOwnProperty(t)&&qn[t]?(""+e).trim():e+"px"}function ga(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=pa(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var eh=J({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 Al(t,e){if(e){if(eh[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(w(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(w(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(w(61))}if(e.style!=null&&typeof e.style!="object")throw Error(w(62))}}function Rl(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){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 jl=null;function Ps(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Dl=null,wn=null,In=null;function Fo(t){if(t=Tr(t)){if(typeof Dl!="function")throw Error(w(280));var e=t.stateNode;e&&(e=ji(e),Dl(t.stateNode,t.type,e))}}function ma(t){wn?In?In.push(t):In=[t]:wn=t}function va(){if(wn){var t=wn,e=In;if(In=wn=null,Fo(t),e)for(t=0;t>>=0,t===0?32:31-(dh(t)/hh|0)|0}var Rr=64,jr=4194304;function Yn(t){switch(t&-t){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 t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function ci(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,l=t.pingedLanes,s=n&268435455;if(s!==0){var o=s&~i;o!==0?r=Yn(o):(l&=s,l!==0&&(r=Yn(l)))}else s=n&~i,s!==0?r=Yn(s):l!==0&&(r=Yn(l));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,l=e&-e,i>=l||i===16&&(l&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function _r(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Ge(e),t[e]=n}function mh(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=er),Uo=" ",Wo=!1;function Da(t,e){switch(t){case"keyup":return Xh.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Oa(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var un=!1;function Zh(t,e){switch(t){case"compositionend":return Oa(e);case"keypress":return e.which!==32?null:(Wo=!0,Uo);case"textInput":return t=e.data,t===Uo&&Wo?null:t;default:return null}}function Qh(t,e){if(un)return t==="compositionend"||!js&&Da(t,e)?(t=Ra(),Jr=Ns=It=null,un=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=$o(n)}}function Va(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Va(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function Ha(){for(var t=window,e=si();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=si(t.document)}return e}function Ds(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function nf(t){var e=Ha(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&Va(n.ownerDocument.documentElement,n)){if(r!==null&&Ds(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,l=Math.min(r.start,i);r=r.end===void 0?l:Math.min(r.end,i),!t.extend&&l>r&&(i=r,r=l,l=i),i=Zo(n,l);var s=Zo(n,r);i&&s&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==s.node||t.focusOffset!==s.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),l>r?(t.addRange(e),t.extend(s.node,s.offset)):(e.setEnd(s.node,s.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,an=null,Hl=null,nr=null,Xl=!1;function Qo(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Xl||an==null||an!==si(r)||(r=an,"selectionStart"in r&&Ds(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}),nr&&pr(nr,r)||(nr=r,r=fi(Hl,"onSelect"),0hn||(t.current=Yl[hn],Yl[hn]=null,hn--)}function V(t,e){hn++,Yl[hn]=t.current,t.current=e}var Nt={},me=Rt(Nt),Ee=Rt(!1),Gt=Nt;function Pn(t,e){var n=t.type.contextTypes;if(!n)return Nt;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},l;for(l in n)i[l]=e[l];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function Te(t){return t=t.childContextTypes,t!=null}function gi(){X(Ee),X(me)}function eu(t,e,n){if(me.current!==Nt)throw Error(w(168));V(me,e),V(Ee,n)}function qa(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(w(108,Jd(t)||"Unknown",i));return J({},n,r)}function mi(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Nt,Gt=me.current,V(me,t),V(Ee,Ee.current),!0}function tu(t,e,n){var r=t.stateNode;if(!r)throw Error(w(169));n?(t=qa(t,e,Gt),r.__reactInternalMemoizedMergedChildContext=t,X(Ee),X(me),V(me,t)):X(Ee),V(Ee,n)}var ot=null,Di=!1,fl=!1;function ba(t){ot===null?ot=[t]:ot.push(t)}function gf(t){Di=!0,ba(t)}function jt(){if(!fl&&ot!==null){fl=!0;var t=0,e=B;try{var n=ot;for(B=1;t>=s,i-=s,ut=1<<32-Ge(e)+i|n<P?(U=E,E=null):U=E.sibling;var N=p(d,E,h[P],v);if(N===null){E===null&&(E=U);break}t&&E&&N.alternate===null&&e(d,E),a=l(N,a,P),x===null?I=N:x.sibling=N,x=N,E=U}if(P===h.length)return n(d,E),Q&&Ut(d,P),I;if(E===null){for(;PP?(U=E,E=null):U=E.sibling;var ve=p(d,E,N.value,v);if(ve===null){E===null&&(E=U);break}t&&E&&ve.alternate===null&&e(d,E),a=l(ve,a,P),x===null?I=ve:x.sibling=ve,x=ve,E=U}if(N.done)return n(d,E),Q&&Ut(d,P),I;if(E===null){for(;!N.done;P++,N=h.next())N=f(d,N.value,v),N!==null&&(a=l(N,a,P),x===null?I=N:x.sibling=N,x=N);return Q&&Ut(d,P),I}for(E=r(d,E);!N.done;P++,N=h.next())N=m(E,d,P,N.value,v),N!==null&&(t&&N.alternate!==null&&E.delete(N.key===null?P:N.key),a=l(N,a,P),x===null?I=N:x.sibling=N,x=N);return t&&E.forEach(function(W){return e(d,W)}),Q&&Ut(d,P),I}function F(d,a,h,v){if(typeof h=="object"&&h!==null&&h.type===on&&h.key===null&&(h=h.props.children),typeof h=="object"&&h!==null){switch(h.$$typeof){case zr:e:{for(var I=h.key,x=a;x!==null;){if(x.key===I){if(I=h.type,I===on){if(x.tag===7){n(d,x.sibling),a=i(x,h.props.children),a.return=d,d=a;break e}}else if(x.elementType===I||typeof I=="object"&&I!==null&&I.$$typeof===yt&&iu(I)===x.type){n(d,x.sibling),a=i(x,h.props),a.ref=Xn(d,x,h),a.return=d,d=a;break e}n(d,x);break}else e(d,x);x=x.sibling}h.type===on?(a=Qt(h.props.children,d.mode,v,h.key),a.return=d,d=a):(v=li(h.type,h.key,h.props,null,d.mode,v),v.ref=Xn(d,a,h),v.return=d,d=v)}return s(d);case sn:e:{for(x=h.key;a!==null;){if(a.key===x)if(a.tag===4&&a.stateNode.containerInfo===h.containerInfo&&a.stateNode.implementation===h.implementation){n(d,a.sibling),a=i(a,h.children||[]),a.return=d,d=a;break e}else{n(d,a);break}else e(d,a);a=a.sibling}a=wl(h,d.mode,v),a.return=d,d=a}return s(d);case yt:return x=h._init,F(d,a,x(h._payload),v)}if(Kn(h))return y(d,a,h,v);if(Bn(h))return S(d,a,h,v);Hr(d,h)}return typeof h=="string"&&h!==""||typeof h=="number"?(h=""+h,a!==null&&a.tag===6?(n(d,a.sibling),a=i(a,h),a.return=d,d=a):(n(d,a),a=kl(h,d.mode,v),a.return=d,d=a),s(d)):n(d,a)}return F}var Mn=rc(!0),ic=rc(!1),Si=Rt(null),ki=null,gn=null,Ws=null;function Vs(){Ws=gn=ki=null}function Hs(t){var e=Si.current;X(Si),t._currentValue=e}function bl(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function Cn(t,e){ki=t,Ws=gn=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(_e=!0),t.firstContext=null)}function Ue(t){var e=t._currentValue;if(Ws!==t)if(t={context:t,memoizedValue:e,next:null},gn===null){if(ki===null)throw Error(w(308));gn=t,ki.dependencies={lanes:0,firstContext:t}}else gn=gn.next=t;return e}var Xt=null;function Xs(t){Xt===null?Xt=[t]:Xt.push(t)}function lc(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,Xs(e)):(n.next=i.next,i.next=n),e.interleaved=n,ft(t,r)}function ft(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var St=!1;function $s(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function sc(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function ct(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function Pt(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,O&2){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,ft(t,n)}return i=r.interleaved,i===null?(e.next=e,Xs(r)):(e.next=i.next,i.next=e),r.interleaved=e,ft(t,n)}function br(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Ms(t,n)}}function lu(t,e){var n=t.updateQueue,r=t.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=e:l=l.next=e}else i=l=e;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:l,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function wi(t,e,n,r){var i=t.updateQueue;St=!1;var l=i.firstBaseUpdate,s=i.lastBaseUpdate,o=i.shared.pending;if(o!==null){i.shared.pending=null;var u=o,c=u.next;u.next=null,s===null?l=c:s.next=c,s=u;var g=t.alternate;g!==null&&(g=g.updateQueue,o=g.lastBaseUpdate,o!==s&&(o===null?g.firstBaseUpdate=c:o.next=c,g.lastBaseUpdate=u))}if(l!==null){var f=i.baseState;s=0,g=c=u=null,o=l;do{var p=o.lane,m=o.eventTime;if((r&p)===p){g!==null&&(g=g.next={eventTime:m,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var y=t,S=o;switch(p=e,m=n,S.tag){case 1:if(y=S.payload,typeof y=="function"){f=y.call(m,f,p);break e}f=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=S.payload,p=typeof y=="function"?y.call(m,f,p):y,p==null)break e;f=J({},f,p);break e;case 2:St=!0}}o.callback!==null&&o.lane!==0&&(t.flags|=64,p=i.effects,p===null?i.effects=[o]:p.push(o))}else m={eventTime:m,lane:p,tag:o.tag,payload:o.payload,callback:o.callback,next:null},g===null?(c=g=m,u=f):g=g.next=m,s|=p;if(o=o.next,o===null){if(o=i.shared.pending,o===null)break;p=o,o=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(!0);if(g===null&&(u=f),i.baseState=u,i.firstBaseUpdate=c,i.lastBaseUpdate=g,e=i.shared.interleaved,e!==null){i=e;do s|=i.lane,i=i.next;while(i!==e)}else l===null&&(i.shared.lanes=0);Jt|=s,t.lanes=s,t.memoizedState=f}}function su(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=gl.transition;gl.transition={};try{t(!1),e()}finally{B=n,gl.transition=r}}function xc(){return We().memoizedState}function Sf(t,e,n){var r=Mt(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Cc(t))_c(e,n);else if(n=lc(t,e,n,r),n!==null){var i=ke();Ke(n,t,r,i),Ec(n,e,r)}}function kf(t,e,n){var r=Mt(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Cc(t))_c(e,i);else{var l=t.alternate;if(t.lanes===0&&(l===null||l.lanes===0)&&(l=e.lastRenderedReducer,l!==null))try{var s=e.lastRenderedState,o=l(s,n);if(i.hasEagerState=!0,i.eagerState=o,Ye(o,s)){var u=e.interleaved;u===null?(i.next=i,Xs(e)):(i.next=u.next,u.next=i),e.interleaved=i;return}}catch{}finally{}n=lc(t,e,i,r),n!==null&&(i=ke(),Ke(n,t,r,i),Ec(n,e,r))}}function Cc(t){var e=t.alternate;return t===Y||e!==null&&e===Y}function _c(t,e){rr=xi=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function Ec(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Ms(t,n)}}var Ci={readContext:Ue,useCallback:fe,useContext:fe,useEffect:fe,useImperativeHandle:fe,useInsertionEffect:fe,useLayoutEffect:fe,useMemo:fe,useReducer:fe,useRef:fe,useState:fe,useDebugValue:fe,useDeferredValue:fe,useTransition:fe,useMutableSource:fe,useSyncExternalStore:fe,useId:fe,unstable_isNewReconciler:!1},wf={readContext:Ue,useCallback:function(t,e){return be().memoizedState=[t,e===void 0?null:e],t},useContext:Ue,useEffect:uu,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,ti(4194308,4,yc.bind(null,e,t),n)},useLayoutEffect:function(t,e){return ti(4194308,4,t,e)},useInsertionEffect:function(t,e){return ti(4,2,t,e)},useMemo:function(t,e){var n=be();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=be();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=Sf.bind(null,Y,t),[r.memoizedState,t]},useRef:function(t){var e=be();return t={current:t},e.memoizedState=t},useState:ou,useDebugValue:bs,useDeferredValue:function(t){return be().memoizedState=t},useTransition:function(){var t=ou(!1),e=t[0];return t=yf.bind(null,t[1]),be().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=Y,i=be();if(Q){if(n===void 0)throw Error(w(407));n=n()}else{if(n=e(),ue===null)throw Error(w(349));Yt&30||cc(r,e,n)}i.memoizedState=n;var l={value:n,getSnapshot:e};return i.queue=l,uu(hc.bind(null,r,l,t),[t]),r.flags|=2048,Ir(9,dc.bind(null,r,l,n,e),void 0,null),n},useId:function(){var t=be(),e=ue.identifierPrefix;if(Q){var n=at,r=ut;n=(r&~(1<<32-Ge(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=kr++,0<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=s.createElement(n,{is:r.is}):(t=s.createElement(n),n==="select"&&(s=t,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):t=s.createElementNS(t,n),t[et]=e,t[vr]=r,jc(t,e,!1,!1),e.stateNode=t;e:{switch(s=Rl(n,r),n){case"dialog":H("cancel",t),H("close",t),i=r;break;case"iframe":case"object":case"embed":H("load",t),i=r;break;case"video":case"audio":for(i=0;iNn&&(e.flags|=128,r=!0,$n(l,!1),e.lanes=4194304)}else{if(!r)if(t=Ii(s),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),$n(l,!0),l.tail===null&&l.tailMode==="hidden"&&!s.alternate&&!Q)return pe(e),null}else 2*te()-l.renderingStartTime>Nn&&n!==1073741824&&(e.flags|=128,r=!0,$n(l,!1),e.lanes=4194304);l.isBackwards?(s.sibling=e.child,e.child=s):(n=l.last,n!==null?n.sibling=s:e.child=s,l.last=s)}return l.tail!==null?(e=l.tail,l.rendering=e,l.tail=e.sibling,l.renderingStartTime=te(),e.sibling=null,n=K.current,V(K,r?n&1|2:n&1),e):(pe(e),null);case 22:case 23:return lo(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Le&1073741824&&(pe(e),e.subtreeFlags&6&&(e.flags|=8192)):pe(e),null;case 24:return null;case 25:return null}throw Error(w(156,e.tag))}function Lf(t,e){switch(Bs(e),e.tag){case 1:return Te(e.type)&&gi(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Fn(),X(Ee),X(me),Gs(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Qs(e),null;case 13:if(X(K),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(w(340));Ln()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return X(K),null;case 4:return Fn(),null;case 10:return Hs(e.type._context),null;case 22:case 23:return lo(),null;case 24:return null;default:return null}}var $r=!1,ge=!1,Mf=typeof WeakSet=="function"?WeakSet:Set,L=null;function mn(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){q(t,e,r)}else n.current=null}function us(t,e,n){try{n()}catch(r){q(t,e,r)}}var Su=!1;function Ff(t,e){if($l=di,t=Ha(),Ds(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.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,o=-1,u=-1,c=0,g=0,f=t,p=null;t:for(;;){for(var m;f!==n||i!==0&&f.nodeType!==3||(o=s+i),f!==l||r!==0&&f.nodeType!==3||(u=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===t)break t;if(p===n&&++c===i&&(o=s),p===l&&++g===r&&(u=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=o===-1||u===-1?null:{start:o,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Zl={focusedElem:t,selectionRange:n},di=!1,L=e;L!==null;)if(e=L,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,L=t;else for(;L!==null;){e=L;try{var y=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var S=y.memoizedProps,F=y.memoizedState,d=e.stateNode,a=d.getSnapshotBeforeUpdate(e.elementType===e.type?S:$e(e.type,S),F);d.__reactInternalSnapshotBeforeUpdate=a}break;case 3:var h=e.stateNode.containerInfo;h.nodeType===1?h.textContent="":h.nodeType===9&&h.documentElement&&h.removeChild(h.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(w(163))}}catch(v){q(e,e.return,v)}if(t=e.sibling,t!==null){t.return=e.return,L=t;break}L=e.return}return y=Su,Su=!1,y}function ir(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var l=i.destroy;i.destroy=void 0,l!==void 0&&us(e,n,l)}i=i.next}while(i!==r)}}function Ui(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function as(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function Bc(t){var e=t.alternate;e!==null&&(t.alternate=null,Bc(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[et],delete e[vr],delete e[Kl],delete e[ff],delete e[pf])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function Uc(t){return t.tag===5||t.tag===3||t.tag===4}function ku(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Uc(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function cs(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=pi));else if(r!==4&&(t=t.child,t!==null))for(cs(t,e,n),t=t.sibling;t!==null;)cs(t,e,n),t=t.sibling}function ds(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(ds(t,e,n),t=t.sibling;t!==null;)ds(t,e,n),t=t.sibling}var ae=null,Ze=!1;function vt(t,e,n){for(n=n.child;n!==null;)Wc(t,e,n),n=n.sibling}function Wc(t,e,n){if(tt&&typeof tt.onCommitFiberUnmount=="function")try{tt.onCommitFiberUnmount(zi,n)}catch{}switch(n.tag){case 5:ge||mn(n,e);case 6:var r=ae,i=Ze;ae=null,vt(t,e,n),ae=r,Ze=i,ae!==null&&(Ze?(t=ae,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):ae.removeChild(n.stateNode));break;case 18:ae!==null&&(Ze?(t=ae,n=n.stateNode,t.nodeType===8?hl(t.parentNode,n):t.nodeType===1&&hl(t,n),hr(t)):hl(ae,n.stateNode));break;case 4:r=ae,i=Ze,ae=n.stateNode.containerInfo,Ze=!0,vt(t,e,n),ae=r,Ze=i;break;case 0:case 11:case 14:case 15:if(!ge&&(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||l&4)&&us(n,e,s),i=i.next}while(i!==r)}vt(t,e,n);break;case 1:if(!ge&&(mn(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){q(n,e,o)}vt(t,e,n);break;case 21:vt(t,e,n);break;case 22:n.mode&1?(ge=(r=ge)||n.memoizedState!==null,vt(t,e,n),ge=r):vt(t,e,n);break;default:vt(t,e,n)}}function wu(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new Mf),e.forEach(function(r){var i=Uf.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function He(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=s),r&=~l}if(r=i,r=te()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Nf(r/1960))-r,10t?16:t,xt===null)var r=!1;else{if(t=xt,xt=null,Ti=0,O&6)throw Error(w(331));var i=O;for(O|=4,L=t.current;L!==null;){var l=L,s=l.child;if(L.flags&16){var o=l.deletions;if(o!==null){for(var u=0;ute()-ro?Zt(t,0):no|=n),Pe(t,e)}function Kc(t,e){e===0&&(t.mode&1?(e=jr,jr<<=1,!(jr&130023424)&&(jr=4194304)):e=1);var n=ke();t=ft(t,e),t!==null&&(_r(t,e,n),Pe(t,n))}function Bf(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),Kc(t,n)}function Uf(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(w(314))}r!==null&&r.delete(e),Kc(t,n)}var Yc;Yc=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Ee.current)_e=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return _e=!1,Tf(t,e,n);_e=!!(t.flags&131072)}else _e=!1,Q&&e.flags&1048576&&ec(e,yi,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;ni(t,e),t=e.pendingProps;var i=Pn(e,me.current);Cn(e,n),i=Ys(null,e,r,t,i,n);var l=Js();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Te(r)?(l=!0,mi(e)):l=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,$s(e),i.updater=Bi,e.stateNode=i,i._reactInternals=e,ts(e,r,t,n),e=is(null,e,r,!0,l,n)):(e.tag=0,Q&&l&&Os(e),Se(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(ni(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=Vf(r),t=$e(r,t),i){case 0:e=rs(null,e,r,t,n);break e;case 1:e=mu(null,e,r,t,n);break e;case 11:e=pu(null,e,r,t,n);break e;case 14:e=gu(null,e,r,$e(r.type,t),n);break e}throw Error(w(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:$e(r,i),rs(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:$e(r,i),mu(t,e,r,i,n);case 3:e:{if(Nc(e),t===null)throw Error(w(387));r=e.pendingProps,l=e.memoizedState,i=l.element,sc(t,e),wi(e,r,null,n);var s=e.memoizedState;if(r=s.element,l.isDehydrated)if(l={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},e.updateQueue.baseState=l,e.memoizedState=l,e.flags&256){i=zn(Error(w(423)),e),e=vu(t,e,r,n,i);break e}else if(r!==i){i=zn(Error(w(424)),e),e=vu(t,e,r,n,i);break e}else for(Me=Tt(e.stateNode.containerInfo.firstChild),Fe=e,Q=!0,Qe=null,n=ic(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ln(),r===i){e=pt(t,e,n);break e}Se(t,e,r,n)}e=e.child}return e;case 5:return oc(e),t===null&&ql(e),r=e.type,i=e.pendingProps,l=t!==null?t.memoizedProps:null,s=i.children,Ql(r,i)?s=null:l!==null&&Ql(r,l)&&(e.flags|=32),zc(t,e),Se(t,e,s,n),e.child;case 6:return t===null&&ql(e),null;case 13:return Ac(t,e,n);case 4:return Zs(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Mn(e,null,r,n):Se(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:$e(r,i),pu(t,e,r,i,n);case 7:return Se(t,e,e.pendingProps,n),e.child;case 8:return Se(t,e,e.pendingProps.children,n),e.child;case 12:return Se(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,l=e.memoizedProps,s=i.value,V(Si,r._currentValue),r._currentValue=s,l!==null)if(Ye(l.value,s)){if(l.children===i.children&&!Ee.current){e=pt(t,e,n);break e}}else for(l=e.child,l!==null&&(l.return=e);l!==null;){var o=l.dependencies;if(o!==null){s=l.child;for(var u=o.firstContext;u!==null;){if(u.context===r){if(l.tag===1){u=ct(-1,n&-n),u.tag=2;var c=l.updateQueue;if(c!==null){c=c.shared;var g=c.pending;g===null?u.next=u:(u.next=g.next,g.next=u),c.pending=u}}l.lanes|=n,u=l.alternate,u!==null&&(u.lanes|=n),bl(l.return,n,e),o.lanes|=n;break}u=u.next}}else if(l.tag===10)s=l.type===e.type?null:l.child;else if(l.tag===18){if(s=l.return,s===null)throw Error(w(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),bl(s,n,e),s=l.sibling}else s=l.child;if(s!==null)s.return=l;else for(s=l;s!==null;){if(s===e){s=null;break}if(l=s.sibling,l!==null){l.return=s.return,s=l;break}s=s.return}l=s}Se(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,Cn(e,n),i=Ue(i),r=r(i),e.flags|=1,Se(t,e,r,n),e.child;case 14:return r=e.type,i=$e(r,e.pendingProps),i=$e(r.type,i),gu(t,e,r,i,n);case 15:return Mc(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:$e(r,i),ni(t,e),e.tag=1,Te(r)?(t=!0,mi(e)):t=!1,Cn(e,n),Tc(e,r,i),ts(e,r,i,n),is(null,e,r,!0,t,n);case 19:return Rc(t,e,n);case 22:return Fc(t,e,n)}throw Error(w(156,e.tag))};function Jc(t,e){return Ca(t,e)}function Wf(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,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 Oe(t,e,n,r){return new Wf(t,e,n,r)}function oo(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Vf(t){if(typeof t=="function")return oo(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Es)return 11;if(t===Ts)return 14}return 2}function Ft(t,e){var n=t.alternate;return n===null?(n=Oe(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function li(t,e,n,r,i,l){var s=2;if(r=t,typeof t=="function")oo(t)&&(s=1);else if(typeof t=="string")s=5;else e:switch(t){case on:return Qt(n.children,i,l,e);case _s:s=8,i|=8;break;case _l:return t=Oe(12,n,e,i|2),t.elementType=_l,t.lanes=l,t;case El:return t=Oe(13,n,e,i),t.elementType=El,t.lanes=l,t;case Tl:return t=Oe(19,n,e,i),t.elementType=Tl,t.lanes=l,t;case oa:return Vi(n,i,l,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case la:s=10;break e;case sa:s=9;break e;case Es:s=11;break e;case Ts:s=14;break e;case yt:s=16,r=null;break e}throw Error(w(130,t==null?t:typeof t,""))}return e=Oe(s,n,e,i),e.elementType=t,e.type=r,e.lanes=l,e}function Qt(t,e,n,r){return t=Oe(7,t,r,e),t.lanes=n,t}function Vi(t,e,n,r){return t=Oe(22,t,r,e),t.elementType=oa,t.lanes=n,t.stateNode={isHidden:!1},t}function kl(t,e,n){return t=Oe(6,t,null,e),t.lanes=n,t}function wl(t,e,n){return e=Oe(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function Hf(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=tl(0),this.expirationTimes=tl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=tl(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function uo(t,e,n,r,i,l,s,o,u){return t=new Hf(t,e,n,o,u),e===1?(e=1,l===!0&&(e|=8)):e=0,l=Oe(3,null,null,e),t.current=l,l.stateNode=t,l.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},$s(l),t}function Xf(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(td)}catch(t){console.error(t)}}td(),ta.exports=Ne;var Kf=ta.exports,Lu=Kf;xl.createRoot=Lu.createRoot,xl.hydrateRoot=Lu.hydrateRoot;class nd{constructor({startTime:e,endTime:n,energy:r,audioData:i}){this.startTime=e,this.endTime=n,this.energy=r,this.audioData=i,this.isProcessed=!1,this.transcription=""}getDuration(){return this.endTime-this.startTime}isSilence(){return!1}}class rd{constructor(e={}){this.options={sampleRate:16e3,windowSize:1600,minSpeechDuration:.3,silenceThreshold:.8,energyThreshold:.02,smaLength:6,lookbackChunks:3,overlapDuration:.2,maxHistoryLength:10,logger:console.log,...e},this.reset()}log(e,n=null){typeof this.options.logger=="function"&&this.options.logger(e,n)}processAudioData(e,n,r,i,l){if(!e||!e.length)return[];const s=[],o=r>this.options.energyThreshold;if(this.state.recentChunks.push({time:n,energy:r,isSpeech:o}),this.state.recentChunks.length>10&&this.state.recentChunks.shift(),!this.state.inSpeech&&o){let u=this.findSpeechStart(),c=u!==-1?this.state.recentChunks[u].time:n;this.startSpeech(c,r),this.log("Speech start detected",{detectedAt:n.toFixed(2),actualStart:c.toFixed(2),lookbackDiff:(n-c).toFixed(2)})}else if(this.state.inSpeech&&!o){if(this.state.silenceCounter++,this.state.silenceCounter>=this.options.silenceThreshold*10){if(this.state.speechStartTime!==null){const c=n-this.state.speechStartTime,g=this.state.speechEnergies.reduce((f,p)=>f+p,0)/this.state.speechEnergies.length;this.state.speechStats.push({startTime:this.state.speechStartTime,endTime:n,duration:c,avgEnergy:g,energyIntegral:g*c}),this.state.speechStats.length>this.options.maxHistoryLength&&this.state.speechStats.shift()}const u=this.createSegment(this.state.speechStartTime,n,i,this.options.sampleRate);u&&s.push(u),this.startSilence(n)}}else this.state.inSpeech?this.state.speechEnergies.push(r):this.state.silenceEnergies.push(r);return this.updateStats(),s}startSpeech(e,n){this.state.inSpeech=!0,this.state.speechStartTime=e,this.state.silenceCounter=0,this.state.speechEnergies=[n],this.state.silenceStartTime=null}startSilence(e){this.state.inSpeech=!1,this.state.silenceStartTime=e,this.state.speechStartTime=null,this.state.silenceCounter=0,this.state.silenceEnergies=[]}updateStats(){const e={silence:{avgDuration:0,avgEnergy:0,avgEnergyIntegral:0},speech:{avgDuration:0,avgEnergy:0,avgEnergyIntegral:0}};this.state.silenceStats.length>0&&(e.silence={avgDuration:this.average(this.state.silenceStats.map(n=>n.duration)),avgEnergy:this.average(this.state.silenceStats.map(n=>n.avgEnergy)),avgEnergyIntegral:this.average(this.state.silenceStats.map(n=>n.energyIntegral))}),this.state.speechStats.length>0&&(e.speech={avgDuration:this.average(this.state.speechStats.map(n=>n.duration)),avgEnergy:this.average(this.state.speechStats.map(n=>n.avgEnergy)),avgEnergyIntegral:this.average(this.state.speechStats.map(n=>n.energyIntegral))}),this.state.currentStats=e}average(e){return e.reduce((n,r)=>n+r,0)/e.length}getStats(){return this.state.currentStats}reset(){this.state={inSpeech:!1,speechStartTime:null,silenceStartTime:null,silenceCounter:0,recentChunks:[],speechEnergies:[],silenceEnergies:[],speechStats:[],silenceStats:[],currentStats:{silence:{avgDuration:0,avgEnergy:0,avgEnergyIntegral:0},speech:{avgDuration:0,avgEnergy:0,avgEnergyIntegral:0}}}}setThreshold(e){this.options.energyThreshold=e}setSilenceLength(e){this.options.silenceThreshold=e}createSegment(e,n,r,i){const o=Math.floor(.5*i),u=Math.floor(.3*i),c=Math.floor(e*i),g=Math.floor(n*i),f=Math.max(0,c-o),p=Math.min(r.length,g+u);if(f>=r.length||p<=0)return this.log("Invalid segment boundaries",{start:e,end:n,startSample:f,endSample:p,bufferLength:r.length,lookback:.5,overlap:.3}),null;const m=p-f;if(m<=0)return this.log("Invalid segment length",{length:m,start:e,end:n}),null;const y=new Float32Array(m);y.set(r.slice(f,p));const S=new nd({startTime:e-.5,endTime:n+.3,audioData:y,sampleRate:i,energy:this.state.speechEnergies.reduce((F,d)=>F+d,0)/this.state.speechEnergies.length});return this.log("Created segment",{originalStart:e.toFixed(2),originalEnd:n.toFixed(2),finalStart:S.startTime.toFixed(2),finalEnd:S.endTime.toFixed(2),duration:(S.endTime-S.startTime).toFixed(2),samples:m,lookbackSamples:o,overlapSamples:u}),S}findSpeechStart(){const e=this.state.recentChunks;let n=e.length-1;for(;n>=0;){if(!e[n].isSpeech){let r=0;for(;n>=0&&!e[n].isSpeech;)r++,n--;if(r>=3)return n+1}n--}return 0}}const Sn=class Sn{constructor(){if(Sn.instance)return Sn.instance;this.audioContext=null,this.processor=null,this.listeners=new Set,this.initialized=!1,this.parameters={threshold:.02,silenceLength:.8,minSpeechDuration:.3},this.segments=[],this.recordedChunks=[],this.audioBuffer=new Float32Array(0),this.lastProcessedTime=0,this._activeTranscriptions=new Set,this.worker=null,this.language="en",this._nextSegmentId=0,Sn.instance=this}async initialize(e={}){if(!this.initialized)try{this.options=e,this.processor=new rd({sampleRate:e.sampleRate||16e3,onSegmentDetected:this.handleNewSegment.bind(this)}),this.initialized=!0,this.notifyListeners("initialized")}catch(n){throw console.error("Failed to initialize AudioManager:",n),n}}async startAudioContext(){var e;this.audioContext||(this.audioContext=new AudioContext({sampleRate:((e=this.options)==null?void 0:e.sampleRate)||16e3})),this.audioContext.state!=="running"&&await this.audioContext.resume(),this.notifyListeners("audioContextStarted")}processNewChunk(e,n){if(!e||!e.length)return;const r=new Float32Array(this.audioBuffer.length+e.length);r.set(this.audioBuffer),r.set(e,this.audioBuffer.length),this.audioBuffer=r;const i=this.getCurrentTime(),l=this.processor.processAudioData(e,i,n,this.audioBuffer,this.lastProcessedTime);l.length>0&&l.forEach(s=>this.handleNewSegment(s)),this.lastProcessedTime=i}getCurrentTime(){return this.audioContext?this.audioContext.currentTime:0}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(e,n){this.listeners.forEach(r=>r(e,n))}handleNewSegment(e){const n=this.calculateSegmentEnergyIntegral(e),r=e.endTime-e.startTime;if(console.log("Candidate segment detected:",{startTime:e.startTime.toFixed(2),endTime:e.endTime.toFixed(2),duration:r.toFixed(2),energyIntegral:n.toFixed(4),isValidSpeech:r>=this.parameters.minSpeechDuration&&n>=this.parameters.minEnergyIntegral,minDurationRequired:this.parameters.minSpeechDuration,minEnergyIntegralRequired:this.parameters.minEnergyIntegral}),!(r>=this.parameters.minSpeechDuration&&n>=this.parameters.minEnergyIntegral)){console.log("🚫 Filtered out noise segment:",{reason:r!u.isPartOfMerged&&u.endTime>=e.startTime-.5&&u.id!==e.id);if(o.length>0){const u={startTime:Math.min(...o.map(c=>c.startTime),e.startTime),endTime:Math.max(...o.map(c=>c.endTime),e.endTime),id:`merged_${Date.now()}`,isMerged:!0,isProcessed:!1,audioData:this.getMergedAudioData([...o,e]),sampleRate:this.audioContext.sampleRate,originalSegments:[...o,e]};[...o,e].forEach(c=>{c.isPartOfMerged=!0,c.mergedId=u.id}),this.segments.push(u),this.sendForTranscription(u)}else this.sendForTranscription(e);this.notifyListeners("segmentsUpdated",this.segments)}calculateSegmentEnergyIntegral(e){const n=Math.floor(e.startTime*this.audioContext.sampleRate),r=Math.ceil(e.endTime*this.audioContext.sampleRate),i=this.audioBuffer.slice(n,r);let l=0;for(let o=0;os.startTime)),r=Math.max(...e.map(s=>s.endTime)),i=Math.floor(n*this.audioContext.sampleRate),l=Math.ceil(r*this.audioContext.sampleRate);return this.audioBuffer.slice(i,l)}trimSilence(e,n,r=.01,i=.5,l=.3){if(!e||e.length===0)return e;const s=i/2,o=l/2,u=Math.floor(s*n),c=Math.floor(o*n),g=Math.floor(.02*n);let f=u,p=e.length-c-1;for(let m=u;mr){f=Math.max(u,m-g);break}}for(let m=e.length-c-g;m>=u;m-=g){let y=0;for(let S=0;Sr){p=Math.min(e.length-c,m+g*2);break}}return e.slice(f,p)}sendForTranscription(e){if(!this.worker||!e.audioData||e.isPartOfMerged&&!e.isMerged||this._activeTranscriptions.has(e.id))return;e.isProcessed=!0,this._activeTranscriptions.add(e.id);const n=.5,r=.3,i=this.trimSilence(e.audioData,this.audioContext.sampleRate,this.parameters.threshold/2,n,r),l=e.audioData.length/this.audioContext.sampleRate,s=i.length/this.audioContext.sampleRate;console.log("Audio trimming results:",{segmentId:e.id,originalDuration:l.toFixed(2)+"s",trimmedDuration:s.toFixed(2)+"s",reduction:((1-s/l)*100).toFixed(1)+"%",lookbackDuration:n.toFixed(2)+"s",overlapDuration:r.toFixed(2)+"s"}),console.log("Sending for transcription with language:",this.language),this.worker.postMessage({type:"transcribe",data:{audioData:i,language:this.language,segmentId:e.id,isMerged:e.isMerged}})}handleTranscriptionResult({segmentId:e,output:n,isMerged:r}){const i=this.segments.find(l=>l.id===e);if(!i){console.warn("Segment not found:",e);return}i.transcription=n,i.isProcessed=!0,this.notifyListeners("segmentsUpdated",this.segments),console.log("Received transcription result:",{segmentId:e,output:n,isMerged:r})}reset(){this.segments=[],this.recordedChunks=[],this.processor&&this.processor.reset(),this.notifyListeners("reset")}updateParameters(e){var n,r,i,l;Object.assign(this.parameters,e),this.processor&&(e.threshold!==void 0&&((r=(n=this.processor).setThreshold)==null||r.call(n,this.parameters.threshold)),e.silenceLength!==void 0&&((l=(i=this.processor).setSilenceLength)==null||l.call(i,this.parameters.silenceLength)),this.processor.options&&Object.assign(this.processor.options,{minSpeechDuration:this.parameters.minSpeechDuration,energyScale:this.parameters.energyScale,hysteresisRatio:this.parameters.hysteresisRatio,minEnergyIntegral:this.parameters.minEnergyIntegral})),console.log("Updated parameters:",this.parameters)}mergeOverlappingSegments(e){if(!e||e.length<2)return e;const n=[];let r=e[0];for(let i=1;i{const d=S>u,a=d?u:S,h=d?S-u:0;y.forEach(v=>{const I=d?v.startTime-h:v.startTime,x=d?v.endTime-h:v.endTime,E=I/a*F.width,P=x/a*F.width;I<=a&&x>=0&&(m.fillStyle=v.isMerged?"rgba(128, 0, 128, 0.2)":v.isPartOfMerged?"rgba(255, 165, 0, 0.1)":v.isProcessed?"rgba(0, 200, 0, 0.1)":"rgba(255, 200, 0, 0.1)",m.fillRect(E,0,P-E,F.height),m.strokeStyle=v.isMerged?"rgba(128, 0, 128, 0.5)":"rgba(0, 100, 200, 0.5)",m.beginPath(),m.moveTo(E,0),m.lineTo(E,F.height),m.moveTo(P,0),m.lineTo(P,F.height),m.stroke(),m.fillStyle="#666",m.font="10px Arial",m.fillText(`${v.startTime.toFixed(1)}s`,E+2,10))})},[]),f=_.useCallback((m,y,S,F)=>{const d=F>u,a=d?Math.min(y.length,u*e.current.sampleRate):y.length,h=d?y.length-a:0,v=S.height/2,I=S.height/2;m.strokeStyle="#c8c8c8",m.lineWidth=1,m.beginPath();for(let x=0;x{const m=Date.now();if(m-l.current{const d=t.reduce((I,x)=>I+x.length,0),a=new Float32Array(d);let h=0;for(const I of t)a.set(I,h),h+=I.length;const v=d/e.current.sampleRate;S.fillStyle="#f5f5f5",S.fillRect(0,0,y.width,y.height),f(S,a,y,v),g(S,n,v,y),p(S,v,y)})().catch(console.error)},[t,n,g,f]);const p=(m,y,S)=>{const F=y>u,d=F?u:y,a=F?y-u:0;m.fillStyle="#666",m.font="10px Arial";for(let h=0;h<=d;h+=5){const v=h/d*S.width,I=a+h;m.fillText(`${I.toFixed(0)}s`,v,S.height-2)}};return k.jsx("canvas",{ref:i,width:720,height:80,className:"w-full border rounded bg-[#f5f5f5]"})}function Jf({chunks:t,audioContextRef:e,segments:n,threshold:r,processor:i}){var u;const l=(i==null?void 0:i.getStats())||{silence:{avgDuration:0,avgEnergy:0,avgEnergyIntegral:0},speech:{avgDuration:0,avgEnergy:0,avgEnergyIntegral:0}},[s,o]=_.useState(l);return _.useEffect(()=>{const c=setInterval(()=>{i&&o(i.getStats())},100);return()=>clearInterval(c)},[i]),k.jsxs("div",{children:[k.jsx("h3",{className:"text-xs font-semibold mb-2",children:"Audio Stats"}),k.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[k.jsxs("div",{children:[k.jsx("h4",{className:"text-xs font-semibold mb-1",children:"Silence Stats"}),k.jsxs("div",{className:"text-xs space-y-1",children:[k.jsxs("div",{children:["Avg Duration: ",s.silence.avgDuration.toFixed(2),"s"]}),k.jsxs("div",{children:["Avg Energy: ",s.silence.avgEnergy.toFixed(4)]}),k.jsxs("div",{children:["Energy Integral: ",s.silence.avgEnergyIntegral.toFixed(4)]})]})]}),k.jsxs("div",{children:[k.jsx("h4",{className:"text-xs font-semibold mb-1",children:"Speech Stats"}),k.jsxs("div",{className:"text-xs space-y-1",children:[k.jsxs("div",{children:["Avg Duration: ",s.speech.avgDuration.toFixed(2),"s"]}),k.jsxs("div",{children:["Avg Energy: ",s.speech.avgEnergy.toFixed(4)]}),k.jsxs("div",{children:["Energy Integral: ",s.speech.avgEnergyIntegral.toFixed(4)]})]})]})]}),k.jsxs("div",{className:"mt-2 text-xs space-y-1",children:[k.jsxs("div",{children:["Total Segments: ",n.length]}),k.jsxs("div",{children:["Energy Threshold: ",r.toFixed(4)]}),k.jsxs("div",{children:["Buffer Duration: ",(t.length*1600/16e3).toFixed(2),"s"]}),k.jsxs("div",{children:["Sample Rate: ",((u=e.current)==null?void 0:u.sampleRate)||16e3,"Hz"]})]})]})}function qf({className:t,stream:e,threshold:n,onThresholdChange:r,silenceLength:i,onSilenceLengthChange:l,speechHangover:s,onHangoverChange:o,chunks:u=[],audioContextRef:c,segments:g=[],energyScale:f,onEnergyScaleChange:p,hysteresisRatio:m,onHysteresisChange:y,minSpeechDuration:S,onMinSpeechDurationChange:F,processor:d,minEnergyIntegral:a,onMinEnergyIntegralChange:h}){const[v,I]=_.useState(0),[x,E]=_.useState(0),[P,U]=_.useState(0),[N,ve]=_.useState(0);return k.jsxs("div",{className:t,children:[k.jsx("div",{className:"mb-2",children:k.jsx(Yf,{chunks:u,audioContextRef:c,segments:g,onEnergyUpdate:(W,rt,mt,Lr)=>{I(W),E(rt),U(mt),ve(Lr)}})}),k.jsxs("div",{className:"flex gap-4 h-full",children:[k.jsxs("div",{className:"flex-1 p-3 bg-gray-100 dark:bg-gray-800 rounded-lg",children:[k.jsx("h3",{className:"text-xs font-semibold mb-2",children:"Speech Detection Parameters"}),k.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[k.jsxs("div",{className:"flex flex-col",children:[k.jsxs("label",{className:"text-xs mb-1",children:["Energy Threshold: ",n.toFixed(3)]}),k.jsx("input",{type:"range",min:"0.05",max:"1.0",step:"0.01",value:n,onChange:W=>r(parseFloat(W.target.value)),className:"w-full h-4"})]}),k.jsxs("div",{className:"flex flex-col",children:[k.jsxs("label",{className:"text-xs mb-1",children:["Energy Scale: ",f.toFixed(1)]}),k.jsx("input",{type:"range",min:"0.1",max:"2.0",step:"0.1",value:f,onChange:W=>p(parseFloat(W.target.value)),className:"w-full h-4"})]}),k.jsxs("div",{className:"flex flex-col",children:[k.jsxs("label",{className:"text-xs mb-1",children:["Min Silence (s): ",i.toFixed(2)]}),k.jsx("input",{type:"range",min:"0.1",max:"1.0",step:"0.05",value:i,onChange:W=>l(parseFloat(W.target.value)),className:"w-full h-4"})]}),k.jsxs("div",{className:"flex flex-col",children:[k.jsxs("label",{className:"text-xs mb-1",children:["Speech Hangover (s): ",s.toFixed(2)]}),k.jsx("input",{type:"range",min:"0.1",max:"0.5",step:"0.05",value:s,onChange:W=>o(parseFloat(W.target.value)),className:"w-full h-4"})]}),k.jsxs("div",{className:"flex flex-col",children:[k.jsxs("label",{className:"text-xs mb-1",children:["Min Speech (s): ",S.toFixed(2)]}),k.jsx("input",{type:"range",min:"0.05",max:"0.5",step:"0.05",value:S,onChange:W=>F(parseFloat(W.target.value)),className:"w-full h-4"})]}),k.jsxs("div",{className:"flex flex-col",children:[k.jsxs("label",{className:"text-xs mb-1",children:["Hysteresis: ",m.toFixed(2)]}),k.jsx("input",{type:"range",min:"1.0",max:"2.0",step:"0.1",value:m,onChange:W=>y(parseFloat(W.target.value)),className:"w-full h-4"})]}),k.jsxs("div",{className:"flex flex-col",children:[k.jsxs("label",{className:"text-xs mb-1",children:["Min Energy Integral: ",a.toFixed(3)]}),k.jsx("input",{type:"range",min:"5",max:"50",step:"5",value:a,onChange:W=>h(parseFloat(W.target.value)),className:"w-full h-4"})]})]}),k.jsxs("div",{className:"mt-2 text-xs grid grid-cols-4 gap-1",children:[k.jsxs("div",{children:["Current: ",v.toFixed(4)]}),k.jsxs("div",{children:["Avg: ",x.toFixed(4)]}),k.jsxs("div",{children:["Peak: ",P.toFixed(4)]}),k.jsxs("div",{children:["Raw: ",N.toFixed(4)]})]})]}),k.jsx("div",{className:"flex-1 p-3 bg-gray-100 dark:bg-gray-800 rounded-lg",children:k.jsx(Jf,{chunks:u,audioContextRef:c,segments:g,threshold:n,processor:d})})]})]})}function bf(t){const e=t==0?0:Math.floor(Math.log(t)/Math.log(1024));return+(t/Math.pow(1024,e)).toFixed(2)*1+["B","kB","MB","GB","TB"][e]}function ep({text:t,percentage:e,total:n}){return e??(e=0),k.jsx("div",{className:"w-full bg-gray-100 dark:bg-gray-700 text-left rounded-lg overflow-hidden mb-0.5",children:k.jsxs("div",{className:"bg-blue-400 whitespace-nowrap px-1 text-sm",style:{width:`${e}%`},children:[t," (",e.toFixed(2),"%",isNaN(n)?"":` of ${bf(n)}`,")"]})})}const yn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function tp(t){let e="";for(let n=0;n>2],e+=yn[(t[n]&3)<<4|t[n+1]>>4],e+=yn[(t[n+1]&15)<<2|t[n+2]>>6],e+=yn[t[n+2]&63];return t.length%3===2?e=e.substring(0,e.length-1)+"=":t.length%3===1&&(e=e.substring(0,e.length-2)+"=="),e}function np(t){let e=new Uint8Array(256);for(let i=0;i>4,r[l++]=(o&15)<<4|u>>2,r[l++]=(u&3)<<6|c&63}return r}function rp(t,e,n,r){if(["32f","64"].indexOf(e)>-1&&["32f","64"].indexOf(r)>-1){n.set(t);return}Mu(e),Mu(r);let i=op(e,r),l={oldMin:Math.pow(2,parseInt(e,10))/2,newMin:Math.pow(2,parseInt(r,10))/2,oldMax:Math.pow(2,parseInt(e,10))/2-1,newMax:Math.pow(2,parseInt(r,10))/2-1};Fu(e,t,!0);for(let s=0,o=t.length;s0?t=parseInt(t/e.oldMax*e.newMax,10):t=parseInt(t/e.oldMin*e.newMin,10),t}function lp(t,e){return parseInt(t>0?t*e.newMax:t*e.newMin,10)}function sp(t,e){return t>0?t/e.oldMax:t/e.oldMin}function op(t,e){let n=function(r){return r};return t!=e&&(["32f","64"].includes(t)?n=lp:["32f","64"].includes(e)?n=sp:n=ip),n}function Mu(t){if(t!="32f"&&t!="64"&&(parseInt(t,10)<"8"||parseInt(t,10)>"53"))throw new Error("Invalid bit depth.")}function Fu(t,e,n){if(t=="8"){let r=n?-128:128;for(let i=0,l=e.length;i>4,o=s<<4^l;n.push(zu(o,e)),n.push(zu(s,e))}return n}function hp(t){return t>32768?t-65536:t}function vs(t,e){let n=t-e.predicted,r=0;n>=0?r=0:(r=8,n=-n);let i=fo[e.index],l=i>>3;return n>i&&(r|=4,n-=i,l+=i),i>>=1,n>i&&(r|=2,n-=i,l+=i),i>>=1,n>i&&(r|=1,l+=i),fp(r,l,e),r}function fp(t,e,n){t&8?n.predicted-=e:n.predicted+=e,n.predicted<-32768?n.predicted=-32768:n.predicted>32767&&(n.predicted=32767),n.index+=id[t&7],n.index<0?n.index=0:n.index>88&&(n.index=88)}function zu(t,e){let n=0;return t&4&&(n+=e.step),t&2&&(n+=e.step>>1),t&1&&(n+=e.step>>2),n+=e.step>>3,t&8&&(n=-n),e.predicted+=n,e.predicted>32767?e.predicted=32767:e.predicted<-32767&&(e.predicted=-32767),pp(t,e),e.predicted}function pp(t,e){e.index+=id[t],e.index<0?e.index=0:e.index>88&&(e.index=88),e.step=fo[e.index]}function gp(t,e){vs(t,e);let n=[];return n.push(t&255),n.push(t>>8&255),n.push(e.index),n.push(0),n}const mp=[1,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7];function vp(t){let e;t=t==-32768?-32767:t;let n=~t>>8&128;if(n||(t=t*-1),t>32635&&(t=32635),t>=256){let r=mp[t>>8&127],i=t>>r+3&15;e=r<<4|i}else e=t>>4;return e^(n^85)}function yp(t){let e=0;t^=85,t&128&&(t&=-129,e=-1);let n=((t&240)>>4)+4,r=0;return n!=4?r=1<>8&128,e!=0&&(t=-t),t=t+wp,t>Nu&&(t=Nu),n=Ip[t>>7&255],r=t>>n+3&15,i=~(e|n<<4|r),i}function _p(t){let e,n,r,i;return t=~t,e=t&128,n=t>>4&7,r=t&15,i=xp[n]+(r<=0&&u<=127)r+=String.fromCharCode(u);else{let c=0;u>=194&&u<=223?c=1:u>=224&&u<=239?(c=2,t[i]===224&&(l=160),t[i]===237&&(s=159)):u>=240&&u<=244?(c=3,t[i]===240&&(l=144),t[i]===244&&(s=143)):o=!0,u=u&(1<<8-c-1)-1;for(let g=0;gs)&&(o=!0),u=u<<6|t[i]&63,i++;o?r+="�":u<=65535?r+=String.fromCharCode(u):(u-=65536,r+=String.fromCharCode((u>>10&1023)+55296,(u&1023)+56320))}}return r}function sd(t,e,n=0){let r=0,i=t.length;for(;r>6*s)+o,n++;s>0;)e[n]=128|l>>6*(s-1)&63,n++,s--}r++}return n}class Mp{constructor(e,n=!1){this.bits=e,this.offset=Math.ceil(e/8),this.max=Math.pow(2,e)-1,this.min=0,this.unpack=this.unpack_,n&&(this.max=Math.pow(2,e)/2-1,this.min=-this.max-1,this.unpack=this.unpackSigned_)}pack(e,n,r=0){n=this.clamp_(Math.round(n));for(let i=0,l=this.offset;ithis.max?this.max:ethis.max&&(e-=this.max*2+2),e}}class Au{constructor(e,n){this.offset=Math.ceil((e+n)/8),this.ebits=e,this.fbits=n,this.bias=(1<this.biasP2-this.ebitsFbits*2&&(n=n<0?-1/0:1/0);let i=((n=+n)||1/n)<0||n<0?1:0;n=Math.abs(n);let l=Math.min(Math.floor(Math.log(n)/Math.LN2),1023),s=Il(n/Math.pow(2,l)*Math.pow(2,this.fbits));return n!==n?(s=Math.pow(2,this.fbits-1),l=(1<=Math.pow(2,1-this.bias)?(s/Math.pow(2,this.fbits)>=2&&(l=l+1,s=1),l>this.bias?(l=(1<=0;u--){let c=e[u+n].toString(2);l+="00000000".substring(c.length)+c}let s=l.charAt(0)=="1"?-1:1;l=l.substring(1);let o=parseInt(l.substring(0,this.ebits),2);return l=l.substring(this.ebits),o==r?parseInt(l,2)!==0?NaN:s*(1/0):(o===0?(o+=1,i=parseInt(l,2)):i=parseInt("1"+l,2),s*i*this.fbias*Math.pow(2,o-this.bias))}packFloatBits_(e,n,r,i,l){let s=[];s.push(r);for(let f=this.ebits;f>0;f-=1)s[f]=i%2?1:0,i=Math.floor(i/2);let o=s.length;for(let f=this.fbits;f>0;f-=1)s[o+f]=l%2?1:0,l=Math.floor(l/2);let u=s.join(""),c=this.offset+n-1,g=n;for(;c>=n;)e[c]=parseInt(u.substring(0,8),2),u=u.substring(8),c--,g++;return g}}function Il(t){let e=Math.floor(t),n=t-e;return n<.5?e:n>.5||e%2?e+1:e}function En(t,e=0,n=t.length){return Lp(t,e,n)}function re(t){let e=[];return sd(t,e),e}function Ru(t,e,n=0){return sd(t,e,n)}function od(t,e,n,r=0){e=e||{};let i=ud(e.bits,e.fp,e.signed),l=Math.ceil(e.bits/8),s=0,o=r;for(let u=t.length;s16&&(this.fmt.cbSize=this.readUInt16_(e),this.fmt.chunkSize>18&&(this.fmt.validBitsPerSample=this.readUInt16_(e),this.fmt.chunkSize>20&&(this.fmt.dwChannelMask=this.readUInt32(e),this.fmt.subformat=[this.readUInt32(e),this.readUInt32(e),this.readUInt32(e),this.readUInt32(e)])))}readFactChunk_(e){let n=this.findChunk("fact");n&&(this.head=n.chunkData.start,this.fact.chunkId=n.chunkId,this.fact.chunkSize=n.chunkSize,this.fact.dwSampleLength=this.readUInt32(e))}readCueChunk_(e){let n=this.findChunk("cue ");if(n){this.head=n.chunkData.start,this.cue.chunkId=n.chunkId,this.cue.chunkSize=n.chunkSize,this.cue.dwCuePoints=this.readUInt32(e);for(let r=0;r-1&&this.readLISTadtlSubChunks_(r,e):n=="INFO"&&this.readLISTINFOSubChunks_(r,e)}readLISTadtlSubChunks_(e,n){this.head=n.chunkData.start;let r={chunkId:n.chunkId,chunkSize:n.chunkSize,dwName:this.readUInt32(e)};n.chunkId=="ltxt"?(r.dwSampleLength=this.readUInt32(e),r.dwPurposeID=this.readUInt32(e),r.dwCountry=this.readUInt16_(e),r.dwLanguage=this.readUInt16_(e),r.dwDialect=this.readUInt16_(e),r.dwCodePage=this.readUInt16_(e),r.value=""):r.value=this.readZSTR_(e,this.head),this.LIST[this.LIST.length-1].subChunks.push(r)}readLISTINFOSubChunks_(e,n){this.head=n.chunkData.start,this.LIST[this.LIST.length-1].subChunks.push({chunkId:n.chunkId,chunkSize:n.chunkSize,value:this.readZSTR_(e,this.head)})}readJunkChunk_(e){let n=this.findChunk("junk");n&&(this.junk={chunkId:n.chunkId,chunkSize:n.chunkSize,chunkData:[].slice.call(e.slice(n.chunkData.start,n.chunkData.end))})}read_PMXChunk_(e){let n=this.findChunk("_PMX");n&&(this.head=n.chunkData.start,this._PMX.chunkId=n.chunkId,this._PMX.chunkSize=n.chunkSize,this._PMX.value=En(e,this.head,this.head+this._PMX.chunkSize))}readZSTR_(e,n=0){for(let r=n;r16&&(e=e.concat(C(this.fmt.cbSize,this.uInt16))),this.fmt.chunkSize>18&&(e=e.concat(C(this.fmt.validBitsPerSample,this.uInt16))),this.fmt.chunkSize>20&&(e=e.concat(C(this.fmt.dwChannelMask,this.uInt32))),this.fmt.chunkSize>24&&(e=e.concat(C(this.fmt.subformat[0],this.uInt32),C(this.fmt.subformat[1],this.uInt32),C(this.fmt.subformat[2],this.uInt32),C(this.fmt.subformat[3],this.uInt32))),e}getLISTBytes_(){let e=[];for(let n=0;n-1){let r=Xe(e.value,e.value.length);n=n.concat(re(e.chunkId),C(r.length+4+1,this.uInt32),C(e.dwName,this.uInt32),r),n.push(0)}else e.chunkId=="ltxt"&&(n=n.concat(this.getLtxtChunkBytes_(e)));return n}getLtxtChunkBytes_(e){return[].concat(re(e.chunkId),C(e.value.length+20,this.uInt32),C(e.dwName,this.uInt32),C(e.dwSampleLength,this.uInt32),C(e.dwPurposeID,this.uInt32),C(e.dwCountry,this.uInt16),C(e.dwLanguage,this.uInt16),C(e.dwDialect,this.uInt16),C(e.dwCodePage,this.uInt16),Xe(e.value,e.value.length))}get_PMXBytes_(){let e=[];if(this._PMX.chunkId){let n=re(this._PMX.value);this._PMX.chunkSize=n.length,e=e.concat(re(this._PMX.chunkId),C(this._PMX.chunkSize,this.uInt32),n)}return this.enforceByteLen_(e),e}getJunkBytes_(){let e=[];return this.junk.chunkId?e.concat(re(this.junk.chunkId),C(this.junk.chunkData.length,this.uInt32),this.junk.chunkData):(this.enforceByteLen_(e),e)}enforceByteLen_(e){e.length%2&&e.push(0)}}function Rp(t){let e=[];if(t.length>0)if(t[0].constructor!==Number){e=new Float64Array(t[0].length*t.length);for(let n=0,r=t[0].length,i=0;n65535)}function ad(t,e,n){let r=t*(e/8)*n;return!(n<1||r>4294967295)}class Op extends Ap{constructor(){super(),this.bitDepth="0",this.dataType={bits:0,be:!1},this.WAV_AUDIO_FORMATS={4:17,8:1,"8a":6,"8m":7,16:1,24:1,32:1,"32f":3,64:3}}fromScratch(e,n,r,i,l){l=l||{},this.clearHeaders(),this.newWavFile_(e,n,r,i,l)}fromBuffer(e,n=!0){super.fromBuffer(e,n),this.bitDepthFromFmt_(),this.updateDataType_()}toBuffer(){return this.validateWavHeader_(),super.toBuffer()}getSamples(e=!1,n=Float64Array){let r=new n(this.data.samples.length/(this.dataType.bits/8));return Vt(this.data.samples,this.dataType,r,0,this.data.samples.length),!e&&this.fmt.numChannels>1?jp(r,this.fmt.numChannels,n):r}getSample(e){if(e=e*(this.dataType.bits/8),e+this.dataType.bits/8>this.data.samples.length)throw new Error("Range error");return Mi(this.data.samples.slice(e,e+this.dataType.bits/8),this.dataType)}setSample(e,n){if(e=e*(this.dataType.bits/8),e+this.dataType.bits/8>this.data.samples.length)throw new Error("Range error");po(n,this.dataType,this.data.samples,e)}getiXML(){return this.iXML.value}setiXML(e){if(typeof e!="string")throw new TypeError("iXML value must be a string.");this.iXML.value=e,this.iXML.chunkId="iXML"}get_PMX(){return this._PMX.value}set_PMX(e){if(typeof e!="string")throw new TypeError("_PMX value must be a string.");this._PMX.value=e,this._PMX.chunkId="_PMX"}newWavFile_(e,n,r,i,l){l.container||(l.container="RIFF"),this.container=l.container,this.bitDepth=r,i=Rp(i),this.updateDataType_();let s=this.dataType.bits/8;this.data.samples=new Uint8Array(i.length*s),od(i,this.dataType,this.data.samples,0),this.makeWavHeader_(r,e,n,s,this.data.samples.length,l),this.data.chunkId="data",this.data.chunkSize=this.data.samples.length,this.validateWavHeader_()}makeWavHeader_(e,n,r,i,l,s){e=="4"?this.createADPCMHeader_(e,n,r,i,l,s):e=="8a"||e=="8m"?this.createALawMulawHeader_(e,n,r,i,l,s):Object.keys(this.WAV_AUDIO_FORMATS).indexOf(e)==-1||n>2?this.createExtensibleHeader_(e,n,r,i,l,s):this.createPCMHeader_(e,n,r,i,l,s)}createPCMHeader_(e,n,r,i,l,s){this.container=s.container,this.chunkSize=36+l,this.format="WAVE",this.bitDepth=e,this.fmt={chunkId:"fmt ",chunkSize:16,audioFormat:this.WAV_AUDIO_FORMATS[e]||65534,numChannels:n,sampleRate:r,byteRate:n*i*r,blockAlign:n*i,bitsPerSample:parseInt(e,10),cbSize:0,validBitsPerSample:0,dwChannelMask:0,subformat:[]}}createADPCMHeader_(e,n,r,i,l,s){this.createPCMHeader_(e,n,r,i,l,s),this.chunkSize=40+l,this.fmt.chunkSize=20,this.fmt.byteRate=4055,this.fmt.blockAlign=256,this.fmt.bitsPerSample=4,this.fmt.cbSize=2,this.fmt.validBitsPerSample=505,this.fact={chunkId:"fact",chunkSize:4,dwSampleLength:l*2}}createExtensibleHeader_(e,n,r,i,l,s){this.createPCMHeader_(e,n,r,i,l,s),this.chunkSize=60+l,this.fmt.chunkSize=40,this.fmt.bitsPerSample=(parseInt(e,10)-1|7)+1,this.fmt.cbSize=22,this.fmt.validBitsPerSample=parseInt(e,10),this.fmt.dwChannelMask=Bp(n),this.fmt.subformat=[1,1048576,2852126848,1905997824]}createALawMulawHeader_(e,n,r,i,l,s){this.createPCMHeader_(e,n,r,i,l,s),this.chunkSize=40+l,this.fmt.chunkSize=20,this.fmt.cbSize=2,this.fmt.validBitsPerSample=8,this.fact={chunkId:"fact",chunkSize:4,dwSampleLength:l}}bitDepthFromFmt_(){this.fmt.audioFormat===3&&this.fmt.bitsPerSample===32?this.bitDepth="32f":this.fmt.audioFormat===6?this.bitDepth="8a":this.fmt.audioFormat===7?this.bitDepth="8m":this.bitDepth=this.fmt.bitsPerSample.toString()}validateBitDepth_(){if(!this.WAV_AUDIO_FORMATS[this.bitDepth]){if(parseInt(this.bitDepth,10)>8&&parseInt(this.bitDepth,10)<54)return!0;throw new Error("Invalid bit depth.")}return!0}updateDataType_(){this.dataType={bits:(parseInt(this.bitDepth,10)-1|7)+1,fp:this.bitDepth=="32f"||this.bitDepth=="64",signed:this.bitDepth!="8",be:this.container=="RIFX"},["4","8a","8m"].indexOf(this.bitDepth)>-1&&(this.dataType.bits=8,this.dataType.signed=!1)}validateWavHeader_(){if(this.validateBitDepth_(),!Dp(this.fmt.numChannels,this.fmt.bitsPerSample))throw new Error("Invalid number of channels.");if(!ad(this.fmt.numChannels,this.fmt.bitsPerSample,this.fmt.sampleRate))throw new Error("Invalid sample rate.")}}function Bp(t){let e=0;return t===1?e=4:t===2?e=3:t===4?e=51:t===6?e=63:t===8&&(e=1599),e}class Up extends Op{getTag(e){let n=this.getTagIndex_(e);return n.TAG!==null?this.LIST[n.LIST].subChunks[n.TAG].value:null}setTag(e,n){e=Wp(e);let r=this.getTagIndex_(e);r.TAG!==null?(this.LIST[r.LIST].subChunks[r.TAG].chunkSize=n.length+1,this.LIST[r.LIST].subChunks[r.TAG].value=n):r.LIST!==null?this.LIST[r.LIST].subChunks.push({chunkId:e,chunkSize:n.length+1,value:n}):(this.LIST.push({chunkId:"LIST",chunkSize:8+n.length+1,format:"INFO",subChunks:[]}),this.LIST[this.LIST.length-1].subChunks.push({chunkId:e,chunkSize:n.length+1,value:n}))}deleteTag(e){let n=this.getTagIndex_(e);return n.TAG!==null?(this.LIST[n.LIST].subChunks.splice(n.TAG,1),!0):!1}listTags(){let e=this.getLISTIndex("INFO"),n={};if(e!==null)for(let r=0,i=this.LIST[e].subChunks.length;rn.dwSampleOffset&&!r?(this.setCuePoint_(n,i+1),this.setCuePoint_(e[i],i+2),r=!0):this.setCuePoint_(e[i],r?i+2:i+1);r||this.setCuePoint_(n,this.cue.points.length+1)}clearLISTadtl_(){for(let e=0,n=this.LIST.length;ee){let u=new o(r.LPForder||Ou[r.LPFType],n,e/2);Yp(t,l,s,u)}else{let u=new o(r.LPForder||Ou[r.LPFType],e,n/2);Jp(t,l,s,u)}}else cd(t,l,s);return l}function cd(t,e,n){for(let r=0,i=e.length;r=0;i--)e[i]=r.filter(e[i])}function Jp(t,e,n,r){for(let i=0,l=t.length;i=0;i--)t[i]=r.filter(t[i]);cd(t,e,n)}class qp extends Du{toRIFF(){let e=new Float64Array(Qn(this.data.samples.length,this.dataType.bits/8));Vt(this.data.samples,this.dataType,e,0,this.data.samples.length),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,this.bitDepth,e,{container:"RIFF"})}toRIFX(){let e=new Float64Array(Qn(this.data.samples.length,this.dataType.bits/8));Vt(this.data.samples,this.dataType,e,0,this.data.samples.length),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,this.bitDepth,e,{container:"RIFX"})}toIMAADPCM(){if(this.fmt.sampleRate!==8e3)throw new Error("Only 8000 Hz files can be compressed as IMA-ADPCM.");if(this.fmt.numChannels!==1)throw new Error("Only mono files can be compressed as IMA-ADPCM.");{this.assure16Bit_();let e=new Int16Array(Qn(this.data.samples.length,2));Vt(this.data.samples,this.dataType,e,0,this.data.samples.length),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"4",up(e),{container:this.correctContainer_()})}}fromIMAADPCM(e="16"){this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"16",ap(this.data.samples,this.fmt.blockAlign),{container:this.correctContainer_()}),e!="16"&&this.toBitDepth(e)}toALaw(){this.assure16Bit_();let e=new Int16Array(Qn(this.data.samples.length,2));Vt(this.data.samples,this.dataType,e,0,this.data.samples.length),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"8a",Sp(e),{container:this.correctContainer_()})}fromALaw(e="16"){this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"16",kp(this.data.samples),{container:this.correctContainer_()}),e!="16"&&this.toBitDepth(e)}toMuLaw(){this.assure16Bit_();let e=new Int16Array(Qn(this.data.samples.length,2));Vt(this.data.samples,this.dataType,e,0,this.data.samples.length),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"8m",Ep(e),{container:this.correctContainer_()})}fromMuLaw(e="16"){this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,"16",Tp(this.data.samples),{container:this.correctContainer_()}),e!="16"&&this.toBitDepth(e)}toBitDepth(e,n=!0){let r=e,i=this.bitDepth;n||(e!="32f"&&(r=this.dataType.bits.toString()),i=""+this.dataType.bits),this.assureUncompressed_();let l=this.getSamples(!0),s=new Float64Array(l.length);rp(l,i,s,r),this.fromExisting_(this.fmt.numChannels,this.fmt.sampleRate,e,s,{container:this.correctContainer_()})}toSampleRate(e,n){this.validateResample_(e);let r=this.getSamples(),i=[];if(r.constructor===Float64Array)i=Bu(r,this.fmt.sampleRate,e,n);else for(let l=0;l-1)throw new Error("wavefile can't change the sample rate of compressed files.")}else throw new Error("Invalid sample rate.")}assure16Bit_(){this.assureUncompressed_(),this.bitDepth!="16"&&this.toBitDepth("16")}assureUncompressed_(){this.bitDepth=="8a"?this.fromALaw():this.bitDepth=="8m"?this.fromMuLaw():this.bitDepth=="4"&&this.fromIMAADPCM()}correctContainer_(){return this.container=="RF64"?"RIFF":this.container}fromExisting_(e,n,r,i,l){let s=new Du;Object.assign(this.fmt,s.fmt),Object.assign(this.fact,s.fact),Object.assign(this.ds64,s.ds64),Object.assign(this.data,s.data),this.newWavFile_(e,n,r,i,l)}}function Qn(t,e){let n=t/e;return n%2&&n++,n}class Uu extends qp{constructor(e){super(),e&&this.fromBuffer(e)}fromBase64(e){this.fromBuffer(np(e))}toBase64(){return tp(this.toBuffer())}toDataURI(){return"data:audio/wav;base64,"+this.toBase64()}fromDataURI(e){this.fromBase64(e.replace("data:audio/wav;base64,",""))}}function bp({segments:t,worker:e,language:n}){const r=async s=>{if(!s.audioData||s.audioData.length===0){console.error("Invalid segment audio data");return}console.log("Playing segment:",{start:s.startTime.toFixed(2),end:s.endTime.toFixed(2),duration:s.duration.toFixed(2),samples:s.audioData.length,sampleRate:s.sampleRate});try{const o=new Uu;o.fromScratch(1,s.sampleRate,"32f",s.audioData),o.toBitDepth("16");const u=o.toBuffer(),c=new AudioContext,g=await c.decodeAudioData(u.buffer),f=c.createBufferSource();f.buffer=g,f.connect(c.destination),f.start()}catch(o){console.error("Error playing segment:",o)}},i=(s,o)=>{try{const u=new Uu;u.fromScratch(1,s.sampleRate,"32f",s.audioData),u.toBitDepth("16");const c=u.toBuffer(),g=new Blob([c],{type:"audio/wav"}),f=URL.createObjectURL(g),p=document.createElement("a");p.href=f,p.download=`segment_${o}_${s.startTime.toFixed(2)}-${s.endTime.toFixed(2)}.wav`,document.body.appendChild(p),p.click(),document.body.removeChild(p),URL.revokeObjectURL(f)}catch(u){console.error("Error downloading segment:",u)}},l=_.useCallback(s=>{e&&e.postMessage({type:"transcribe",data:{audioData:s.audioData,segmentId:s.id,language:n,isMerged:s.isMerged}})},[e,n]);return k.jsxs("div",{className:"mt-4 p-4 bg-gray-100 dark:bg-gray-800 rounded-lg",children:[k.jsxs("h3",{className:"font-semibold mb-2",children:["Detected Speech Segments (",t.length,")"]}),k.jsx("div",{className:"space-y-2",children:t.map((s,o)=>k.jsxs("div",{className:`flex flex-col p-2 rounded ${s.isMerged?"bg-purple-100 dark:bg-purple-900":"bg-white dark:bg-gray-700"}`,children:[k.jsxs("div",{className:"flex items-center space-x-4",children:[k.jsxs("span",{className:"text-sm",children:[s.isMerged?"🔄 ":"",`Segment ${o+1}: ${s.startTime.toFixed(2)}s - ${s.endTime.toFixed(2)}s (${(s.endTime-s.startTime).toFixed(2)}s)`]}),k.jsx("button",{onClick:()=>r(s),className:"px-2 py-1 bg-blue-500 text-white rounded hover:bg-blue-600",children:"Play"}),k.jsx("button",{onClick:()=>i(s,o+1),className:"px-2 py-1 bg-green-500 text-white rounded hover:bg-green-600",children:"Download"}),k.jsx("button",{onClick:()=>l(s),className:"px-2 py-1 bg-purple-500 text-white rounded hover:bg-purple-600",disabled:s.isProcessed,children:s.isProcessed?"Transcribed":"Transcribe"})]}),s.transcription&&k.jsx("div",{className:"mt-2 ml-4 text-sm",children:typeof s.transcription=="string"?s.transcription:s.transcription.text||s.transcription.toString()})]},s.isMerged?s.id:o))})]})}function eg(t){return t=t.toLowerCase(),(t.match(/\w+.?/g)||[]).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}const Wu={en:"english",zh:"chinese",de:"german",es:"spanish/castilian",ru:"russian",ko:"korean",fr:"french",ja:"japanese",pt:"portuguese",tr:"turkish",pl:"polish",ca:"catalan/valencian",nl:"dutch/flemish",ar:"arabic",sv:"swedish",it:"italian",id:"indonesian",hi:"hindi",fi:"finnish",vi:"vietnamese",he:"hebrew",uk:"ukrainian",el:"greek",ms:"malay",cs:"czech",ro:"romanian/moldavian/moldovan",da:"danish",hu:"hungarian",ta:"tamil",no:"norwegian",th:"thai",ur:"urdu",hr:"croatian",bg:"bulgarian",lt:"lithuanian",la:"latin",mi:"maori",ml:"malayalam",cy:"welsh",sk:"slovak",te:"telugu",fa:"persian",lv:"latvian",bn:"bengali",sr:"serbian",az:"azerbaijani",sl:"slovenian",kn:"kannada",et:"estonian",mk:"macedonian",br:"breton",eu:"basque",is:"icelandic",hy:"armenian",ne:"nepali",mn:"mongolian",bs:"bosnian",kk:"kazakh",sq:"albanian",sw:"swahili",gl:"galician",mr:"marathi",pa:"punjabi/panjabi",si:"sinhala/sinhalese",km:"khmer",sn:"shona",yo:"yoruba",so:"somali",af:"afrikaans",oc:"occitan",ka:"georgian",be:"belarusian",tg:"tajik",sd:"sindhi",gu:"gujarati",am:"amharic",yi:"yiddish",lo:"lao",uz:"uzbek",fo:"faroese",ht:"haitian creole/haitian",ps:"pashto/pushto",tk:"turkmen",nn:"nynorsk",mt:"maltese",sa:"sanskrit",lb:"luxembourgish/letzeburgesch",my:"myanmar/burmese",bo:"tibetan",tl:"tagalog",mg:"malagasy",as:"assamese",tt:"tatar",haw:"hawaiian",ln:"lingala",ha:"hausa",ba:"bashkir",jw:"javanese",su:"sundanese"};function tg({language:t,setLanguage:e,disabled:n}){return k.jsx("select",{className:`border rounded-lg p-2 ${n?"opacity-50 cursor-not-allowed":""}`,value:t,onChange:r=>e(r.target.value),disabled:n,title:n?"Language locked to English for this model":"Select language",children:Object.keys(Wu).map((r,i)=>k.jsx("option",{value:r,children:Object.values(Wu).map(eg)[i]},r))})}const dd={"Whisper Small":"onnx-community/whisper-small","Whisper Base":"onnx-community/whisper-base","Whisper Tiny":"onnx-community/whisper-tiny","Whisper Small En":"onnx-community/whisper-small.en","Whisper Base En":"onnx-community/whisper-base.en","Whisper Tiny En":"onnx-community/whisper-tiny.en","Whisper Base Tr":"ysdede/whisper-base-dsntt1-tr-onnx","Whisper Small Tr":"ysdede/whisper-small-dsntt1-tr-onnx"};function ng({model:t,setModel:e}){return k.jsx("select",{className:"border rounded-lg p-2 mr-2",value:t,onChange:n=>e(n.target.value),children:Object.entries(dd).map(([n,r])=>k.jsx("option",{value:r,children:n},r))})}const rg="data:text/javascript;base64,Y2xhc3MgQXVkaW9Qcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgc3VwZXIoKTsKICAgICAgICB0aGlzLmJ1ZmZlclNpemUgPSAxNjAwOwogICAgICAgIHRoaXMuYnVmZmVyID0gbmV3IEZsb2F0MzJBcnJheSh0aGlzLmJ1ZmZlclNpemUpOwogICAgICAgIHRoaXMuYnVmZmVySW5kZXggPSAwOwogICAgICAgIAogICAgICAgIHRoaXMubWF4VmFsdWVzID0gW107CiAgICAgICAgdGhpcy5zbWFMZW5ndGggPSA2OwogICAgICAgIHRoaXMuc2lsZW5jZUNvdW50ZXIgPSAwOwogICAgICAgIHRoaXMuc2lsZW5jZVRocmVzaG9sZCA9IDg7CiAgICB9CgogICAgY2FsY3VsYXRlTWF4RW5lcmd5KGJ1ZmZlcikgewogICAgICAgIGNvbnN0IG1heEFic1ZhbHVlID0gTWF0aC5tYXgoLi4uQXJyYXkuZnJvbShidWZmZXIpLm1hcChNYXRoLmFicykpOwogICAgICAgIHRoaXMubWF4VmFsdWVzLnB1c2gobWF4QWJzVmFsdWUpOwogICAgICAgIAogICAgICAgIGlmICh0aGlzLm1heFZhbHVlcy5sZW5ndGggPiB0aGlzLnNtYUxlbmd0aCkgewogICAgICAgICAgICB0aGlzLm1heFZhbHVlcy5zaGlmdCgpOwogICAgICAgIH0KICAgICAgICAKICAgICAgICBjb25zdCBzdW0gPSB0aGlzLm1heFZhbHVlcy5yZWR1Y2UoKGFjYywgdmFsKSA9PiBhY2MgKyB2YWwsIDApOwogICAgICAgIHJldHVybiAoc3VtIC8gdGhpcy5tYXhWYWx1ZXMubGVuZ3RoKTsKICAgIH0KCiAgICBwcm9jZXNzKGlucHV0cywgb3V0cHV0cykgewogICAgICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgICAgIGNvbnN0IGNoYW5uZWwgPSBpbnB1dFswXTsKCiAgICAgICAgaWYgKCFjaGFubmVsKSByZXR1cm4gdHJ1ZTsKCiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBjaGFubmVsLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgIHRoaXMuYnVmZmVyW3RoaXMuYnVmZmVySW5kZXgrK10gPSBjaGFubmVsW2ldOwoKICAgICAgICAgICAgaWYgKHRoaXMuYnVmZmVySW5kZXggPj0gdGhpcy5idWZmZXJTaXplKSB7CiAgICAgICAgICAgICAgICBjb25zdCBlbmVyZ3kgPSB0aGlzLmNhbGN1bGF0ZU1heEVuZXJneSh0aGlzLmJ1ZmZlcik7CiAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIHRoaXMucG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgdHlwZTogJ2F1ZGlvX2RhdGEnLAogICAgICAgICAgICAgICAgICAgIGF1ZGlvRGF0YTogdGhpcy5idWZmZXIuc2xpY2UoKSwKICAgICAgICAgICAgICAgICAgICBlbmVyZ3k6IGVuZXJneQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIHRoaXMuYnVmZmVySW5kZXggPSAwOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ2F1ZGlvLXByb2Nlc3NvcicsIEF1ZGlvUHJvY2Vzc29yKTsg",st=16e3,ig=30,Vu=st*ig,lg=100,Hu=2*lg,sg=async t=>{try{const e=t.getAudioTracks()[0];if(!e){console.warn("No audio track found");return}const n=e.getConstraints();console.log("Current constraints:",n);const r={autoGainControl:!1,echoCancellation:!1,noiseSuppression:!1,channelCount:1,sampleRate:st};await e.applyConstraints({advanced:[r]});const i=e.getConstraints();console.log("Automatically unsetting gain!",{audio:!0,initial:n,applied:r,final:i});const l=e.getSettings();console.log("Track settings after constraints:",l)}catch(e){console.warn("Failed to disable auto gain:",e)}};function og(){const t=_.useRef(null),e=_.useRef(null),n=_.useRef(null),r=_.useRef(null),i=_.useRef(null);_.useRef(null);const l=_.useRef(null),s=_.useRef(null);_.useRef(0),_.useRef(0),_.useRef(null);const o=_.useRef([]),[u,c]=_.useState("initialized"),[g,f]=_.useState(""),[p,m]=_.useState([]),[y,S]=_.useState(!1),[F,d]=_.useState(!1),[a,h]=_.useState(.125),[v,I]=_.useState(.6),[x,E]=_.useState(.2),[P,U]=_.useState(2),[N,ve]=_.useState(1.2),[W,rt]=_.useState(.3),[mt,Lr]=_.useState(.3),[Dt,Mr]=_.useState(.4),[T,A]=_.useState(.6),[z,$]=_.useState([]),[G,tn]=_.useState(null),[xe,Ot]=_.useState([]);_.useState("");const[Je,nn]=_.useState(null),[Dn,hd]=_.useState("en"),[mo,Qi]=_.useState(""),[vo,fd]=_.useState([]),[Gi,pd]=_.useState(25),[Ki,gd]=_.useState(Object.values(dd)[0]);_.useEffect(()=>(console.log("Initializing AudioManager"),ee.initialize({sampleRate:st,onSegmentDetected:M=>{Ot(R=>[...R,M])}}).catch(M=>{console.error("Failed to initialize AudioManager:",M)}),ee.updateParameters({threshold:a,silenceLength:v,speechHangover:x,energyScale:P,hysteresisRatio:N,minSpeechDuration:W}),()=>{ee.reset()}),[]);const md=async()=>{try{await ee.startAudioContext();const M=await navigator.mediaDevices.getUserMedia({audio:{autoGainControl:!1,echoCancellation:!1,noiseSuppression:!1,channelCount:1,sampleRate:st}});await sg(M),tn(M),await ee.audioContext.audioWorklet.addModule(rg);const R=ee.audioContext.createMediaStreamSource(M),b=ee.audioContext.createGain();b.gain.value=1;const j=new AudioWorkletNode(ee.audioContext,"audio-processor",{numberOfInputs:1,numberOfOutputs:1,processorOptions:{sampleRate:st}});R.connect(b),b.connect(j),j.port.onmessage=he=>{if(he.data.type==="audio_data"){const Z=he.data.audioData,se=he.data.energy;$(rn=>[...rn,Z]),ee.processNewChunk(Z,se)}},j.connect(ee.audioContext.destination),d(!0),n.current=ee.audioContext}catch(M){console.error("Failed to start audio:",M),M.name==="NotAllowedError"?console.error("Microphone permission denied"):M.name==="NotFoundError"?console.error("No microphone found"):console.error("Error details:",{name:M.name,message:M.message,stack:M.stack})}};_.useEffect(()=>{if(F){console.log("Setting up process interval");let M=0;const R=setInterval(async()=>{const b=Date.now();if(b-M=0&&se>0;Ve--){const ye=j[Ve];if(!(ye instanceof Float32Array))continue;const Bt=Math.min(se,ye.length),On=ye.length-Bt;Z.set(ye.slice(On,On+Bt),se-Bt),se-=Bt}Math.max(...Array.from(Z.slice(0,1e3)).map(Math.abs))>.1&&await ee.processNewChunk(Z),M=b}catch(he){console.error("Error in process interval:",he)}},Hu);return()=>clearInterval(R)}},[F]),_.useEffect(()=>{if(!t.current){t.current=new Worker(new URL("/assets/worker-D60LmNTA.js",import.meta.url),{type:"module"}),ee.setWorker(t.current);const M=R=>{switch(R.data.status){case"loading":c("loading"),f(R.data.data);break;case"initiate":m(Z=>[...Z,R.data]);break;case"progress":m(Z=>Z.map(se=>se.file===R.data.file?{...se,...R.data}:se));break;case"done":m(Z=>Z.filter(se=>se.file!==R.data.file));break;case"ready":c("ready");break;case"start":S(!0);break;case"update":nn(R.data.tps);break;case"complete":S(!1);const b=R.data.output,j=R.data.segmentId,he=R.data.segmentId.startsWith("merged_");fd(Z=>{var Ve,ye,Bt,On;const se={id:j,text:b,timestamp:Date.now(),isMerged:he,containedSegments:he?(ye=(Ve=ee.segments.find(it=>it.id===j))==null?void 0:Ve.originalSegments)==null?void 0:ye.map(it=>it.id):[],isPartOfMerged:!he&&((Bt=ee.segments.find(it=>it.id===j))==null?void 0:Bt.isPartOfMerged),mergedId:he?null:(On=ee.segments.find(it=>it.id===j))==null?void 0:On.mergedId};return[...Z.filter(it=>{var So;return!((So=se.containedSegments)!=null&&So.includes(it.id))}),se]}),ee.handleTranscriptionResult({segmentId:j,output:b,isMerged:he});break}};return t.current.addEventListener("message",M),()=>{t.current.removeEventListener("message",M),t.current.terminate(),t.current=null}}},[]);const Re=_.useCallback((M,R="info")=>{R==="error"?console.error(M):console.log(M)},[]);_.useEffect(()=>{i.current=Re},[Re]),_.useEffect(()=>{if(!r.current){console.log("Creating AudioSegmentProcessor...");const M=(R,b)=>{var j;console.log("AudioProcessor:",R,b),(j=i.current)==null||j.call(i,R,"info")};r.current=new rd({logger:M,sampleRate:st,energyThreshold:a,minSpeechDuration:.1,windowSize:256,minSilenceBetween:v,speechHangover:x}),r.current.log("Test message from initialization",{test:"value"}),Re("AudioSegmentProcessor initialized",{threshold:a,silenceLength:v,hangover:x})}},[]),_.useEffect(()=>{r.current&&(r.current.options.energyThreshold=a,r.current.options.minSilenceBetween=v,r.current.options.speechHangover=x,Re("Updated processor settings",{threshold:a,silenceLength:v,hangover:x}))},[a,v,x]);const vd=_.useCallback(()=>{var M;Re("Reset requested"),e.current&&(e.current.state==="recording"&&e.current.stop(),(M=l.current)==null||M.reset(),setTimeout(()=>{if(u==="ready"&&e.current)try{e.current.start(),Re("Started new recording after reset")}catch(R){Re("Failed to start after reset: "+R.message,"error")}},100))},[u]);_.useEffect(()=>{if(u==="ready"&&F){Re("Starting periodic buffer processing");let M=!0,R=0;const b=setInterval(()=>{if(!(!r.current||!s.current||!M))try{const j=s.current;if(j.length===R)return;const he=15*st;let Z=0;if(xe.length>0){const rn=xe[xe.length-1];Z=Math.floor(rn.endTime*st)}const se=j.slice(Math.max(j.length-he,Z),j.length);if(se.length>0){const Ve=r.current.processAudioData(se,Z/st).map(ye=>new nd(ye));Ve.length>0&&(Re("Created speech segments",{count:Ve.length,segments:Ve.map(ye=>({start:ye.startTime.toFixed(2),end:ye.endTime.toFixed(2),duration:ye.getDuration().toFixed(2)}))}),Ot(ye=>[...ye,...Ve]))}R=j.length}catch(j){Re("Error processing buffer: "+j.message,"error"),console.error("Processing error:",j)}},500);return()=>{M=!1,clearInterval(b)}}},[u,F,xe]),_.useEffect(()=>{e.current&&(e.current.ondataavailable=M=>{M.data.size>0&&$(R=>[...R,M.data])})},[]),_.useEffect(()=>{r.current&&(r.current.options.maxSilenceWithinSpeech=mt,Re("Updated max silence within speech",{value:mt}))},[mt]),_.useEffect(()=>{r.current&&(r.current.options.endingSpeechTolerance=Dt,r.current.options.endingEnergyThreshold=T,Re("Updated ending speech parameters",{tolerance:Dt,threshold:T}))},[Dt,T]),_.useEffect(()=>{r.current&&(r.current.options={...r.current.options,energyThreshold:a,minSilenceBetween:v,speechHangover:x,energyScale:P,hysteresisRatio:N,minSpeechDuration:W})},[a,v,x,P,N,W]),_.useEffect(()=>{const M=ee.subscribe((R,b)=>{switch(R){case"segmentsUpdated":Ot(b.map(j=>({...j,startTime:j.startTime,endTime:j.endTime,isMerged:j.isMerged||!1,isPartOfMerged:j.isPartOfMerged||!1,isProcessed:j.isProcessed||!1,mergedId:j.mergedId,energy:j.energy})));break}});return()=>M()},[]),_.useEffect(()=>()=>{n.current&&n.current.close(),G&&G.getTracks().forEach(M=>M.stop())},[G]),_.useEffect(()=>{const M=vo.filter(R=>R.isMerged||!R.isPartOfMerged).map(R=>R.text);Qi(M.join(` -`))},[vo]),_.useEffect(()=>{ee.updateParameters({minEnergyIntegral:Gi})},[Gi]),_.useEffect(()=>{var M;if(e.current&&F&&!y&&u==="ready")if(z.length>0){const R=new Blob(z,{type:e.current.mimeType}),b=new FileReader;b.onloadend=async()=>{const j=b.result;let Z=(await n.current.decodeAudioData(j)).getChannelData(0);Z.length>Vu&&(Z=Z.slice(-Vu)),t.current.postMessage({type:"transcribe",data:{audioData:Z,language:Dn,segmentId:Date.now().toString()}})},b.readAsArrayBuffer(R)}else(M=e.current)==null||M.requestData()},[u,F,y,z,Dn]);const yo=M=>{console.log("Changing language from",Dn,"to:",M),hd(M),ee.updateLanguage(M)},yd=M=>{gd(M),M.endsWith(".en")&&yo("en")};return k.jsx("div",{className:"flex flex-col min-h-screen max-h-screen w-screen mx-auto text-gray-800 dark:text-gray-200 bg-white dark:bg-gray-900",children:k.jsxs("div",{className:"flex-1 w-full overflow-y-auto scrollbar-thin flex flex-col items-center gap-4 p-4",children:[k.jsxs("div",{className:"flex flex-col items-center mb-2",children:[k.jsx("img",{src:"logo.png",width:"40px",height:"auto",className:"block mb-1"}),k.jsx("h1",{className:"text-xl font-bold",children:"Whisper WebGPU"}),k.jsx("h2",{className:"text-base font-semibold",children:"Real-time in-browser speech recognition"})]}),k.jsxs("div",{className:"flex gap-2 items-center mb-2",children:[!F&&k.jsx("button",{className:"border px-3 py-1 rounded-lg bg-blue-400 text-white hover:bg-blue-500",onClick:md,children:"Start Audio Capture"}),k.jsx(tg,{language:Dn,setLanguage:yo,disabled:Ki.endsWith(".en")}),u==="initialized"&&k.jsxs("div",{className:"flex items-center gap-2",children:[k.jsx(ng,{model:Ki,setModel:yd}),k.jsx("button",{className:"border px-3 py-1 rounded-lg bg-blue-400 text-white hover:bg-blue-500",onClick:()=>{var M;(M=t.current)==null||M.postMessage({type:"load",data:{modelId:Ki}}),c("loading")},children:"Load Model"})]})]}),k.jsxs("div",{className:"flex flex-col w-full max-w-[90vw] gap-4",children:[k.jsx("div",{className:"h-[300px]",children:k.jsx(qf,{className:"w-full h-full rounded-lg",stream:G,threshold:a,onThresholdChange:h,silenceLength:v,onSilenceLengthChange:I,speechHangover:x,onHangoverChange:E,chunks:z,audioContextRef:n,segments:xe,energyScale:P,onEnergyScaleChange:U,hysteresisRatio:N,onHysteresisChange:ve,minSpeechDuration:W,onMinSpeechDurationChange:rt,processor:ee.processor,minEnergyIntegral:Gi,onMinEnergyIntegralChange:pd})}),u==="loading"&&k.jsxs("div",{className:"w-full max-w-[500px] mx-auto p-4",children:[k.jsx("p",{className:"text-center",children:g}),p.map(({file:M,progress:R,total:b},j)=>k.jsx(ep,{text:M,percentage:R,total:b},j))]}),u==="ready"&&k.jsxs("div",{className:"relative w-full h-[240px]",children:[k.jsx("textarea",{value:mo,onChange:M=>Qi(M.target.value),className:`w-full h-full resize-none overflow-y-auto font-mono text-sm - border rounded-lg p-2 bg-white dark:bg-gray-800 - focus:ring-2 focus:ring-blue-500 focus:border-blue-500`,placeholder:"Transcriptions will appear here. You can edit the text..."}),k.jsxs("div",{className:"absolute bottom-2 right-2 flex gap-2",children:[Je&&k.jsxs("span",{className:"px-2 py-1 bg-gray-100 dark:bg-gray-700 rounded text-sm",children:[Je.toFixed(2)," tok/s"]}),k.jsx("button",{onClick:()=>Qi(""),className:"px-2 py-1 text-sm bg-red-500 text-white rounded hover:bg-red-600",children:"Clear"}),k.jsx("button",{onClick:()=>{navigator.clipboard.writeText(mo)},className:"px-2 py-1 text-sm bg-blue-500 text-white rounded hover:bg-blue-600",children:"Copy"}),k.jsx("button",{className:"px-2 py-1 text-sm bg-gray-500 text-white rounded hover:bg-gray-600",onClick:vd,children:"Reset"})]})]})]}),k.jsx("div",{className:"w-full max-w-[90vw] h-[300px] overflow-y-auto",children:k.jsx(bp,{segments:xe,worker:t.current,language:Dn})})]})})}xl.createRoot(document.getElementById("root")).render(k.jsx(Dd.StrictMode,{children:k.jsx(og,{})}));