From b11aa71f9b5e80b914660c6102f07979a2607dc1 Mon Sep 17 00:00:00 2001 From: Ron Meldiner Date: Wed, 8 Jan 2025 11:40:17 -0800 Subject: [PATCH] update --- assets/index-zPuAfFZW.js | 355 +++++++++++++++++++++++++++++++++++++++ index.html | 2 +- 2 files changed, 356 insertions(+), 1 deletion(-) create mode 100644 assets/index-zPuAfFZW.js diff --git a/assets/index-zPuAfFZW.js b/assets/index-zPuAfFZW.js new file mode 100644 index 0000000..da7821c --- /dev/null +++ b/assets/index-zPuAfFZW.js @@ -0,0 +1,355 @@ +var vc=Object.defineProperty;var yc=(e,t,n)=>t in e?vc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Io=(e,t,n)=>yc(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();var eu={exports:{}},so={},tu={exports:{}},N={};/** + * @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 Zn=Symbol.for("react.element"),gc=Symbol.for("react.portal"),wc=Symbol.for("react.fragment"),kc=Symbol.for("react.strict_mode"),Sc=Symbol.for("react.profiler"),_c=Symbol.for("react.provider"),Ec=Symbol.for("react.context"),Cc=Symbol.for("react.forward_ref"),xc=Symbol.for("react.suspense"),Pc=Symbol.for("react.memo"),Ic=Symbol.for("react.lazy"),Vl=Symbol.iterator;function Lc(e){return e===null||typeof e!="object"?null:(e=Vl&&e[Vl]||e["@@iterator"],typeof e=="function"?e:null)}var nu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ru=Object.assign,ou={};function un(e,t,n){this.props=e,this.context=t,this.refs=ou,this.updater=n||nu}un.prototype.isReactComponent={};un.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};un.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function iu(){}iu.prototype=un.prototype;function Ki(e,t,n){this.props=e,this.context=t,this.refs=ou,this.updater=n||nu}var qi=Ki.prototype=new iu;qi.constructor=Ki;ru(qi,un.prototype);qi.isPureReactComponent=!0;var Hl=Array.isArray,lu=Object.prototype.hasOwnProperty,Yi={current:null},su={key:!0,ref:!0,__self:!0,__source:!0};function uu(e,t,n){var r,o={},i=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(i=""+t.key),t)lu.call(t,r)&&!su.hasOwnProperty(r)&&(o[r]=t[r]);var s=arguments.length-2;if(s===1)o.children=n;else if(1>>1,Y=E[H];if(0>>1;Ho(Po,L))gto(ir,Po)?(E[H]=ir,E[gt]=L,H=gt):(E[H]=Po,E[yt]=L,H=yt);else if(gto(ir,L))E[H]=ir,E[gt]=L,H=gt;else break e}}return I}function o(E,I){var L=E.sortIndex-I.sortIndex;return L!==0?L:E.id-I.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,s=l.now();e.unstable_now=function(){return l.now()-s}}var u=[],a=[],h=1,p=null,m=3,k=!1,w=!1,g=!1,z=typeof setTimeout=="function"?setTimeout:null,f=typeof clearTimeout=="function"?clearTimeout:null,c=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function d(E){for(var I=n(a);I!==null;){if(I.callback===null)r(a);else if(I.startTime<=E)r(a),I.sortIndex=I.expirationTime,t(u,I);else break;I=n(a)}}function v(E){if(g=!1,d(E),!w)if(n(u)!==null)w=!0,Co(_);else{var I=n(a);I!==null&&xo(v,I.startTime-E)}}function _(E,I){w=!1,g&&(g=!1,f(P),P=-1),k=!0;var L=m;try{for(d(I),p=n(u);p!==null&&(!(p.expirationTime>I)||E&&!Pe());){var H=p.callback;if(typeof H=="function"){p.callback=null,m=p.priorityLevel;var Y=H(p.expirationTime<=I);I=e.unstable_now(),typeof Y=="function"?p.callback=Y:p===n(u)&&r(u),d(I)}else r(u);p=n(u)}if(p!==null)var or=!0;else{var yt=n(a);yt!==null&&xo(v,yt.startTime-I),or=!1}return or}finally{p=null,m=L,k=!1}}var C=!1,x=null,P=-1,V=5,T=-1;function Pe(){return!(e.unstable_now()-TE||125H?(E.sortIndex=L,t(a,E),n(u)===null&&E===n(a)&&(g?(f(P),P=-1):g=!0,xo(v,L-H))):(E.sortIndex=Y,t(u,E),w||k||(w=!0,Co(_))),E},e.unstable_shouldYield=Pe,e.unstable_wrapCallback=function(E){var I=m;return function(){var L=m;m=I;try{return E.apply(this,arguments)}finally{m=L}}}})(pu);du.exports=pu;var Uc=du.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 $c=ue,ye=Uc;function y(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ei=Object.prototype.hasOwnProperty,Bc=/^[: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]*$/,Ql={},Kl={};function Vc(e){return ei.call(Kl,e)?!0:ei.call(Ql,e)?!1:Bc.test(e)?Kl[e]=!0:(Ql[e]=!0,!1)}function Hc(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Wc(e,t,n,r){if(t===null||typeof t>"u"||Hc(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function se(e,t,n,r,o,i,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=o,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=l}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){b[e]=new se(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];b[t]=new se(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){b[e]=new se(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){b[e]=new se(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){b[e]=new se(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){b[e]=new se(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){b[e]=new se(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){b[e]=new se(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){b[e]=new se(e,5,!1,e.toLowerCase(),null,!1,!1)});var Gi=/[\-:]([a-z])/g;function Ji(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Gi,Ji);b[t]=new se(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Gi,Ji);b[t]=new se(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Gi,Ji);b[t]=new se(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){b[e]=new se(e,1,!1,e.toLowerCase(),null,!1,!1)});b.xlinkHref=new se("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){b[e]=new se(e,1,!1,e.toLowerCase(),null,!0,!0)});function Zi(e,t,n,r){var o=b.hasOwnProperty(t)?b[t]:null;(o!==null?o.type!==0:r||!(2s||o[l]!==i[s]){var u=` +`+o[l].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=l&&0<=s);break}}}finally{To=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?_n(e):""}function Qc(e){switch(e.tag){case 5:return _n(e.type);case 16:return _n("Lazy");case 13:return _n("Suspense");case 19:return _n("SuspenseList");case 0:case 2:case 15:return e=Ro(e.type,!1),e;case 11:return e=Ro(e.type.render,!1),e;case 1:return e=Ro(e.type,!0),e;default:return""}}function oi(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Ot:return"Fragment";case Dt:return"Portal";case ti:return"Profiler";case bi:return"StrictMode";case ni:return"Suspense";case ri:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case vu:return(e.displayName||"Context")+".Consumer";case mu:return(e._context.displayName||"Context")+".Provider";case el:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case tl:return t=e.displayName||null,t!==null?t:oi(e.type)||"Memo";case Je:t=e._payload,e=e._init;try{return oi(e(t))}catch{}}return null}function Kc(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return oi(t);case 8:return t===bi?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function dt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function gu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function qc(e){var t=gu(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var o=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return o.call(this)},set:function(l){r=""+l,i.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ur(e){e._valueTracker||(e._valueTracker=qc(e))}function wu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=gu(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Or(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function ii(e,t){var n=t.checked;return $({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Yl(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=dt(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function ku(e,t){t=t.checked,t!=null&&Zi(e,"checked",t,!1)}function li(e,t){ku(e,t);var n=dt(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?si(e,t.type,n):t.hasOwnProperty("defaultValue")&&si(e,t.type,dt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Xl(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function si(e,t,n){(t!=="number"||Or(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var En=Array.isArray;function qt(e,t,n,r){if(e=e.options,t){t={};for(var o=0;o"+t.valueOf().toString()+"",t=ar.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function On(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Pn={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},Yc=["Webkit","ms","Moz","O"];Object.keys(Pn).forEach(function(e){Yc.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Pn[t]=Pn[e]})});function Cu(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Pn.hasOwnProperty(e)&&Pn[e]?(""+t).trim():t+"px"}function xu(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,o=Cu(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,o):e[n]=o}}var Xc=$({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 ci(e,t){if(t){if(Xc[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(y(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(y(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(y(61))}if(t.style!=null&&typeof t.style!="object")throw Error(y(62))}}function fi(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var di=null;function nl(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var pi=null,Yt=null,Xt=null;function Zl(e){if(e=tr(e)){if(typeof pi!="function")throw Error(y(280));var t=e.stateNode;t&&(t=po(t),pi(e.stateNode,e.type,t))}}function Pu(e){Yt?Xt?Xt.push(e):Xt=[e]:Yt=e}function Iu(){if(Yt){var e=Yt,t=Xt;if(Xt=Yt=null,Zl(e),t)for(e=0;e>>=0,e===0?32:31-(sf(e)/uf|0)|0}var cr=64,fr=4194304;function Cn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function $r(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,o=e.suspendedLanes,i=e.pingedLanes,l=n&268435455;if(l!==0){var s=l&~o;s!==0?r=Cn(s):(i&=l,i!==0&&(r=Cn(i)))}else l=n&~o,l!==0?r=Cn(l):i!==0&&(r=Cn(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&o)&&(o=r&-r,i=t&-t,o>=i||o===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function bn(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Re(t),e[t]=n}function df(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Ln),ss=" ",us=!1;function qu(e,t){switch(e){case"keyup":return $f.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Yu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ft=!1;function Vf(e,t){switch(e){case"compositionend":return Yu(t);case"keypress":return t.which!==32?null:(us=!0,ss);case"textInput":return e=t.data,e===ss&&us?null:e;default:return null}}function Hf(e,t){if(Ft)return e==="compositionend"||!cl&&qu(e,t)?(e=Qu(),Ir=sl=tt=null,Ft=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ds(n)}}function Zu(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Zu(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function bu(){for(var e=window,t=Or();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Or(e.document)}return t}function fl(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Zf(e){var t=bu(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Zu(n.ownerDocument.documentElement,n)){if(r!==null&&fl(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var o=n.textContent.length,i=Math.min(r.start,o);r=r.end===void 0?i:Math.min(r.end,o),!e.extend&&i>r&&(o=r,r=i,i=o),o=ps(n,i);var l=ps(n,r);o&&l&&(e.rangeCount!==1||e.anchorNode!==o.node||e.anchorOffset!==o.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(o.node,o.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,jt=null,wi=null,Tn=null,ki=!1;function hs(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ki||jt==null||jt!==Or(r)||(r=jt,"selectionStart"in r&&fl(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}),Tn&&Vn(Tn,r)||(Tn=r,r=Hr(wi,"onSelect"),0Bt||(e.current=Pi[Bt],Pi[Bt]=null,Bt--)}function M(e,t){Bt++,Pi[Bt]=e.current,e.current=t}var pt={},re=mt(pt),fe=mt(!1),It=pt;function tn(e,t){var n=e.type.contextTypes;if(!n)return pt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var o={},i;for(i in n)o[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function de(e){return e=e.childContextTypes,e!=null}function Qr(){O(fe),O(re)}function Ss(e,t,n){if(re.current!==pt)throw Error(y(168));M(re,t),M(fe,n)}function ua(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var o in r)if(!(o in t))throw Error(y(108,Kc(e)||"Unknown",o));return $({},n,r)}function Kr(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||pt,It=re.current,M(re,e),M(fe,fe.current),!0}function _s(e,t,n){var r=e.stateNode;if(!r)throw Error(y(169));n?(e=ua(e,t,It),r.__reactInternalMemoizedMergedChildContext=e,O(fe),O(re),M(re,e)):O(fe),M(fe,n)}var Be=null,ho=!1,Qo=!1;function aa(e){Be===null?Be=[e]:Be.push(e)}function cd(e){ho=!0,aa(e)}function vt(){if(!Qo&&Be!==null){Qo=!0;var e=0,t=A;try{var n=Be;for(A=1;e>=l,o-=l,Ve=1<<32-Re(t)+o|n<P?(V=x,x=null):V=x.sibling;var T=m(f,x,d[P],v);if(T===null){x===null&&(x=V);break}e&&x&&T.alternate===null&&t(f,x),c=i(T,c,P),C===null?_=T:C.sibling=T,C=T,x=V}if(P===d.length)return n(f,x),F&&wt(f,P),_;if(x===null){for(;PP?(V=x,x=null):V=x.sibling;var Pe=m(f,x,T.value,v);if(Pe===null){x===null&&(x=V);break}e&&x&&Pe.alternate===null&&t(f,x),c=i(Pe,c,P),C===null?_=Pe:C.sibling=Pe,C=Pe,x=V}if(T.done)return n(f,x),F&&wt(f,P),_;if(x===null){for(;!T.done;P++,T=d.next())T=p(f,T.value,v),T!==null&&(c=i(T,c,P),C===null?_=T:C.sibling=T,C=T);return F&&wt(f,P),_}for(x=r(f,x);!T.done;P++,T=d.next())T=k(x,f,P,T.value,v),T!==null&&(e&&T.alternate!==null&&x.delete(T.key===null?P:T.key),c=i(T,c,P),C===null?_=T:C.sibling=T,C=T);return e&&x.forEach(function(fn){return t(f,fn)}),F&&wt(f,P),_}function z(f,c,d,v){if(typeof d=="object"&&d!==null&&d.type===Ot&&d.key===null&&(d=d.props.children),typeof d=="object"&&d!==null){switch(d.$$typeof){case sr:e:{for(var _=d.key,C=c;C!==null;){if(C.key===_){if(_=d.type,_===Ot){if(C.tag===7){n(f,C.sibling),c=o(C,d.props.children),c.return=f,f=c;break e}}else if(C.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===Je&&xs(_)===C.type){n(f,C.sibling),c=o(C,d.props),c.ref=gn(f,C,d),c.return=f,f=c;break e}n(f,C);break}else t(f,C);C=C.sibling}d.type===Ot?(c=Pt(d.props.children,f.mode,v,d.key),c.return=f,f=c):(v=Dr(d.type,d.key,d.props,null,f.mode,v),v.ref=gn(f,c,d),v.return=f,f=v)}return l(f);case Dt:e:{for(C=d.key;c!==null;){if(c.key===C)if(c.tag===4&&c.stateNode.containerInfo===d.containerInfo&&c.stateNode.implementation===d.implementation){n(f,c.sibling),c=o(c,d.children||[]),c.return=f,f=c;break e}else{n(f,c);break}else t(f,c);c=c.sibling}c=bo(d,f.mode,v),c.return=f,f=c}return l(f);case Je:return C=d._init,z(f,c,C(d._payload),v)}if(En(d))return w(f,c,d,v);if(pn(d))return g(f,c,d,v);gr(f,d)}return typeof d=="string"&&d!==""||typeof d=="number"?(d=""+d,c!==null&&c.tag===6?(n(f,c.sibling),c=o(c,d),c.return=f,f=c):(n(f,c),c=Zo(d,f.mode,v),c.return=f,f=c),l(f)):n(f,c)}return z}var rn=pa(!0),ha=pa(!1),Xr=mt(null),Gr=null,Wt=null,ml=null;function vl(){ml=Wt=Gr=null}function yl(e){var t=Xr.current;O(Xr),e._currentValue=t}function Ni(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Jt(e,t){Gr=e,ml=Wt=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ce=!0),e.firstContext=null)}function Ce(e){var t=e._currentValue;if(ml!==e)if(e={context:e,memoizedValue:t,next:null},Wt===null){if(Gr===null)throw Error(y(308));Wt=e,Gr.dependencies={lanes:0,firstContext:e}}else Wt=Wt.next=e;return t}var Et=null;function gl(e){Et===null?Et=[e]:Et.push(e)}function ma(e,t,n,r){var o=t.interleaved;return o===null?(n.next=n,gl(t)):(n.next=o.next,o.next=n),t.interleaved=n,qe(e,r)}function qe(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Ze=!1;function wl(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function va(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function We(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function st(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,R&2){var o=r.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),r.pending=t,qe(e,n)}return o=r.interleaved,o===null?(t.next=t,gl(r)):(t.next=o.next,o.next=t),r.interleaved=t,qe(e,n)}function Nr(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ol(e,n)}}function Ps(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var o=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?o=i=l:i=i.next=l,n=n.next}while(n!==null);i===null?o=i=t:i=i.next=t}else o=i=t;n={baseState:r.baseState,firstBaseUpdate:o,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Jr(e,t,n,r){var o=e.updateQueue;Ze=!1;var i=o.firstBaseUpdate,l=o.lastBaseUpdate,s=o.shared.pending;if(s!==null){o.shared.pending=null;var u=s,a=u.next;u.next=null,l===null?i=a:l.next=a,l=u;var h=e.alternate;h!==null&&(h=h.updateQueue,s=h.lastBaseUpdate,s!==l&&(s===null?h.firstBaseUpdate=a:s.next=a,h.lastBaseUpdate=u))}if(i!==null){var p=o.baseState;l=0,h=a=u=null,s=i;do{var m=s.lane,k=s.eventTime;if((r&m)===m){h!==null&&(h=h.next={eventTime:k,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});e:{var w=e,g=s;switch(m=t,k=n,g.tag){case 1:if(w=g.payload,typeof w=="function"){p=w.call(k,p,m);break e}p=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=g.payload,m=typeof w=="function"?w.call(k,p,m):w,m==null)break e;p=$({},p,m);break e;case 2:Ze=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,m=o.effects,m===null?o.effects=[s]:m.push(s))}else k={eventTime:k,lane:m,tag:s.tag,payload:s.payload,callback:s.callback,next:null},h===null?(a=h=k,u=p):h=h.next=k,l|=m;if(s=s.next,s===null){if(s=o.shared.pending,s===null)break;m=s,s=m.next,m.next=null,o.lastBaseUpdate=m,o.shared.pending=null}}while(!0);if(h===null&&(u=p),o.baseState=u,o.firstBaseUpdate=a,o.lastBaseUpdate=h,t=o.shared.interleaved,t!==null){o=t;do l|=o.lane,o=o.next;while(o!==t)}else i===null&&(o.shared.lanes=0);Tt|=l,e.lanes=l,e.memoizedState=p}}function Is(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=qo.transition;qo.transition={};try{e(!1),t()}finally{A=n,qo.transition=r}}function Aa(){return xe().memoizedState}function hd(e,t,n){var r=at(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ma(e))Da(t,n);else if(n=ma(e,t,n,r),n!==null){var o=ie();ze(n,e,r,o),Oa(n,t,r)}}function md(e,t,n){var r=at(e),o={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ma(e))Da(t,o);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var l=t.lastRenderedState,s=i(l,n);if(o.hasEagerState=!0,o.eagerState=s,Ae(s,l)){var u=t.interleaved;u===null?(o.next=o,gl(t)):(o.next=u.next,u.next=o),t.interleaved=o;return}}catch{}finally{}n=ma(e,t,o,r),n!==null&&(o=ie(),ze(n,e,r,o),Oa(n,t,r))}}function Ma(e){var t=e.alternate;return e===U||t!==null&&t===U}function Da(e,t){Rn=br=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Oa(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ol(e,n)}}var eo={readContext:Ce,useCallback:ee,useContext:ee,useEffect:ee,useImperativeHandle:ee,useInsertionEffect:ee,useLayoutEffect:ee,useMemo:ee,useReducer:ee,useRef:ee,useState:ee,useDebugValue:ee,useDeferredValue:ee,useTransition:ee,useMutableSource:ee,useSyncExternalStore:ee,useId:ee,unstable_isNewReconciler:!1},vd={readContext:Ce,useCallback:function(e,t){return De().memoizedState=[e,t===void 0?null:t],e},useContext:Ce,useEffect:Ns,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Rr(4194308,4,La.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Rr(4194308,4,e,t)},useInsertionEffect:function(e,t){return Rr(4,2,e,t)},useMemo:function(e,t){var n=De();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=De();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=hd.bind(null,U,e),[r.memoizedState,e]},useRef:function(e){var t=De();return e={current:e},t.memoizedState=e},useState:Ls,useDebugValue:Il,useDeferredValue:function(e){return De().memoizedState=e},useTransition:function(){var e=Ls(!1),t=e[0];return e=pd.bind(null,e[1]),De().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=U,o=De();if(F){if(n===void 0)throw Error(y(407));n=n()}else{if(n=t(),G===null)throw Error(y(349));Nt&30||ka(r,t,n)}o.memoizedState=n;var i={value:n,getSnapshot:t};return o.queue=i,Ns(_a.bind(null,r,i,e),[e]),r.flags|=2048,Gn(9,Sa.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=De(),t=G.identifierPrefix;if(F){var n=He,r=Ve;n=(r&~(1<<32-Re(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Yn++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[Oe]=t,e[Qn]=r,Ka(e,t,!1,!1),t.stateNode=e;e:{switch(l=fi(n,r),n){case"dialog":D("cancel",e),D("close",e),o=r;break;case"iframe":case"object":case"embed":D("load",e),o=r;break;case"video":case"audio":for(o=0;osn&&(t.flags|=128,r=!0,wn(i,!1),t.lanes=4194304)}else{if(!r)if(e=Zr(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),wn(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!F)return te(t),null}else 2*W()-i.renderingStartTime>sn&&n!==1073741824&&(t.flags|=128,r=!0,wn(i,!1),t.lanes=4194304);i.isBackwards?(l.sibling=t.child,t.child=l):(n=i.last,n!==null?n.sibling=l:t.child=l,i.last=l)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=W(),t.sibling=null,n=j.current,M(j,r?n&1|2:n&1),t):(te(t),null);case 22:case 23:return Al(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?he&1073741824&&(te(t),t.subtreeFlags&6&&(t.flags|=8192)):te(t),null;case 24:return null;case 25:return null}throw Error(y(156,t.tag))}function Cd(e,t){switch(pl(t),t.tag){case 1:return de(t.type)&&Qr(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return on(),O(fe),O(re),_l(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Sl(t),null;case 13:if(O(j),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(y(340));nn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return O(j),null;case 4:return on(),null;case 10:return yl(t.type._context),null;case 22:case 23:return Al(),null;case 24:return null;default:return null}}var kr=!1,ne=!1,xd=typeof WeakSet=="function"?WeakSet:Set,S=null;function Qt(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){B(e,t,r)}else n.current=null}function ji(e,t,n){try{n()}catch(r){B(e,t,r)}}var $s=!1;function Pd(e,t){if(Si=Br,e=bu(),fl(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var o=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var l=0,s=-1,u=-1,a=0,h=0,p=e,m=null;t:for(;;){for(var k;p!==n||o!==0&&p.nodeType!==3||(s=l+o),p!==i||r!==0&&p.nodeType!==3||(u=l+r),p.nodeType===3&&(l+=p.nodeValue.length),(k=p.firstChild)!==null;)m=p,p=k;for(;;){if(p===e)break t;if(m===n&&++a===o&&(s=l),m===i&&++h===r&&(u=l),(k=p.nextSibling)!==null)break;p=m,m=p.parentNode}p=k}n=s===-1||u===-1?null:{start:s,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(_i={focusedElem:e,selectionRange:n},Br=!1,S=t;S!==null;)if(t=S,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,S=e;else for(;S!==null;){t=S;try{var w=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var g=w.memoizedProps,z=w.memoizedState,f=t.stateNode,c=f.getSnapshotBeforeUpdate(t.elementType===t.type?g:Le(t.type,g),z);f.__reactInternalSnapshotBeforeUpdate=c}break;case 3:var d=t.stateNode.containerInfo;d.nodeType===1?d.textContent="":d.nodeType===9&&d.documentElement&&d.removeChild(d.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(y(163))}}catch(v){B(t,t.return,v)}if(e=t.sibling,e!==null){e.return=t.return,S=e;break}S=t.return}return w=$s,$s=!1,w}function zn(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var o=r=r.next;do{if((o.tag&e)===e){var i=o.destroy;o.destroy=void 0,i!==void 0&&ji(t,n,i)}o=o.next}while(o!==r)}}function yo(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Ui(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Xa(e){var t=e.alternate;t!==null&&(e.alternate=null,Xa(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Oe],delete t[Qn],delete t[xi],delete t[ud],delete t[ad])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Ga(e){return e.tag===5||e.tag===3||e.tag===4}function Bs(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Ga(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function $i(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Wr));else if(r!==4&&(e=e.child,e!==null))for($i(e,t,n),e=e.sibling;e!==null;)$i(e,t,n),e=e.sibling}function Bi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Bi(e,t,n),e=e.sibling;e!==null;)Bi(e,t,n),e=e.sibling}var J=null,Ne=!1;function Ge(e,t,n){for(n=n.child;n!==null;)Ja(e,t,n),n=n.sibling}function Ja(e,t,n){if(Fe&&typeof Fe.onCommitFiberUnmount=="function")try{Fe.onCommitFiberUnmount(uo,n)}catch{}switch(n.tag){case 5:ne||Qt(n,t);case 6:var r=J,o=Ne;J=null,Ge(e,t,n),J=r,Ne=o,J!==null&&(Ne?(e=J,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):J.removeChild(n.stateNode));break;case 18:J!==null&&(Ne?(e=J,n=n.stateNode,e.nodeType===8?Wo(e.parentNode,n):e.nodeType===1&&Wo(e,n),$n(e)):Wo(J,n.stateNode));break;case 4:r=J,o=Ne,J=n.stateNode.containerInfo,Ne=!0,Ge(e,t,n),J=r,Ne=o;break;case 0:case 11:case 14:case 15:if(!ne&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){o=r=r.next;do{var i=o,l=i.destroy;i=i.tag,l!==void 0&&(i&2||i&4)&&ji(n,t,l),o=o.next}while(o!==r)}Ge(e,t,n);break;case 1:if(!ne&&(Qt(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(s){B(n,t,s)}Ge(e,t,n);break;case 21:Ge(e,t,n);break;case 22:n.mode&1?(ne=(r=ne)||n.memoizedState!==null,Ge(e,t,n),ne=r):Ge(e,t,n);break;default:Ge(e,t,n)}}function Vs(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new xd),t.forEach(function(r){var o=Dd.bind(null,e,r);n.has(r)||(n.add(r),r.then(o,o))})}}function Ie(e,t){var n=t.deletions;if(n!==null)for(var r=0;ro&&(o=l),r&=~i}if(r=o,r=W()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Ld(r/1960))-r,10e?16:e,nt===null)var r=!1;else{if(e=nt,nt=null,ro=0,R&6)throw Error(y(331));var o=R;for(R|=4,S=e.current;S!==null;){var i=S,l=i.child;if(S.flags&16){var s=i.deletions;if(s!==null){for(var u=0;uW()-Rl?xt(e,0):Tl|=n),pe(e,t)}function ic(e,t){t===0&&(e.mode&1?(t=fr,fr<<=1,!(fr&130023424)&&(fr=4194304)):t=1);var n=ie();e=qe(e,t),e!==null&&(bn(e,t,n),pe(e,n))}function Md(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),ic(e,n)}function Dd(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(y(314))}r!==null&&r.delete(t),ic(e,n)}var lc;lc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||fe.current)ce=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ce=!1,_d(e,t,n);ce=!!(e.flags&131072)}else ce=!1,F&&t.flags&1048576&&ca(t,Yr,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;zr(e,t),e=t.pendingProps;var o=tn(t,re.current);Jt(t,n),o=Cl(null,t,r,e,o,n);var i=xl();return t.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,de(r)?(i=!0,Kr(t)):i=!1,t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,wl(t),o.updater=vo,t.stateNode=o,o._reactInternals=t,Ri(t,r,e,n),t=Mi(null,t,r,!0,i,n)):(t.tag=0,F&&i&&dl(t),oe(null,t,o,n),t=t.child),t;case 16:r=t.elementType;e:{switch(zr(e,t),e=t.pendingProps,o=r._init,r=o(r._payload),t.type=r,o=t.tag=Fd(r),e=Le(r,e),o){case 0:t=Ai(null,t,r,e,n);break e;case 1:t=Fs(null,t,r,e,n);break e;case 11:t=Ds(null,t,r,e,n);break e;case 14:t=Os(null,t,r,Le(r.type,e),n);break e}throw Error(y(306,r,""))}return t;case 0:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Le(r,o),Ai(e,t,r,o,n);case 1:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Le(r,o),Fs(e,t,r,o,n);case 3:e:{if(Ha(t),e===null)throw Error(y(387));r=t.pendingProps,i=t.memoizedState,o=i.element,va(e,t),Jr(t,r,null,n);var l=t.memoizedState;if(r=l.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){o=ln(Error(y(423)),t),t=js(e,t,r,n,o);break e}else if(r!==o){o=ln(Error(y(424)),t),t=js(e,t,r,n,o);break e}else for(me=lt(t.stateNode.containerInfo.firstChild),ve=t,F=!0,Te=null,n=ha(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(nn(),r===o){t=Ye(e,t,n);break e}oe(e,t,r,n)}t=t.child}return t;case 5:return ya(t),e===null&&Li(t),r=t.type,o=t.pendingProps,i=e!==null?e.memoizedProps:null,l=o.children,Ei(r,o)?l=null:i!==null&&Ei(r,i)&&(t.flags|=32),Va(e,t),oe(e,t,l,n),t.child;case 6:return e===null&&Li(t),null;case 13:return Wa(e,t,n);case 4:return kl(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=rn(t,null,r,n):oe(e,t,r,n),t.child;case 11:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Le(r,o),Ds(e,t,r,o,n);case 7:return oe(e,t,t.pendingProps,n),t.child;case 8:return oe(e,t,t.pendingProps.children,n),t.child;case 12:return oe(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,o=t.pendingProps,i=t.memoizedProps,l=o.value,M(Xr,r._currentValue),r._currentValue=l,i!==null)if(Ae(i.value,l)){if(i.children===o.children&&!fe.current){t=Ye(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var s=i.dependencies;if(s!==null){l=i.child;for(var u=s.firstContext;u!==null;){if(u.context===r){if(i.tag===1){u=We(-1,n&-n),u.tag=2;var a=i.updateQueue;if(a!==null){a=a.shared;var h=a.pending;h===null?u.next=u:(u.next=h.next,h.next=u),a.pending=u}}i.lanes|=n,u=i.alternate,u!==null&&(u.lanes|=n),Ni(i.return,n,t),s.lanes|=n;break}u=u.next}}else if(i.tag===10)l=i.type===t.type?null:i.child;else if(i.tag===18){if(l=i.return,l===null)throw Error(y(341));l.lanes|=n,s=l.alternate,s!==null&&(s.lanes|=n),Ni(l,n,t),l=i.sibling}else l=i.child;if(l!==null)l.return=i;else for(l=i;l!==null;){if(l===t){l=null;break}if(i=l.sibling,i!==null){i.return=l.return,l=i;break}l=l.return}i=l}oe(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,r=t.pendingProps.children,Jt(t,n),o=Ce(o),r=r(o),t.flags|=1,oe(e,t,r,n),t.child;case 14:return r=t.type,o=Le(r,t.pendingProps),o=Le(r.type,o),Os(e,t,r,o,n);case 15:return $a(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Le(r,o),zr(e,t),t.tag=1,de(r)?(e=!0,Kr(t)):e=!1,Jt(t,n),Fa(t,r,o),Ri(t,r,o,n),Mi(null,t,r,!0,e,n);case 19:return Qa(e,t,n);case 22:return Ba(e,t,n)}throw Error(y(156,t.tag))};function sc(e,t){return Mu(e,t)}function Od(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function _e(e,t,n,r){return new Od(e,t,n,r)}function Dl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Fd(e){if(typeof e=="function")return Dl(e)?1:0;if(e!=null){if(e=e.$$typeof,e===el)return 11;if(e===tl)return 14}return 2}function ct(e,t){var n=e.alternate;return n===null?(n=_e(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Dr(e,t,n,r,o,i){var l=2;if(r=e,typeof e=="function")Dl(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case Ot:return Pt(n.children,o,i,t);case bi:l=8,o|=8;break;case ti:return e=_e(12,n,t,o|2),e.elementType=ti,e.lanes=i,e;case ni:return e=_e(13,n,t,o),e.elementType=ni,e.lanes=i,e;case ri:return e=_e(19,n,t,o),e.elementType=ri,e.lanes=i,e;case yu:return wo(n,o,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case mu:l=10;break e;case vu:l=9;break e;case el:l=11;break e;case tl:l=14;break e;case Je:l=16,r=null;break e}throw Error(y(130,e==null?e:typeof e,""))}return t=_e(l,n,t,o),t.elementType=e,t.type=r,t.lanes=i,t}function Pt(e,t,n,r){return e=_e(7,e,r,t),e.lanes=n,e}function wo(e,t,n,r){return e=_e(22,e,r,t),e.elementType=yu,e.lanes=n,e.stateNode={isHidden:!1},e}function Zo(e,t,n){return e=_e(6,e,null,t),e.lanes=n,e}function bo(e,t,n){return t=_e(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function jd(e,t,n,r,o){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ao(0),this.expirationTimes=Ao(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ao(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function Ol(e,t,n,r,o,i,l,s,u){return e=new jd(e,t,n,s,u),t===1?(t=1,i===!0&&(t|=8)):t=0,i=_e(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},wl(i),e}function Ud(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(fc)}catch(e){console.error(e)}}fc(),fu.exports=ge;var Hd=fu.exports,dc,Gs=Hd;dc=Gs.createRoot,Gs.hydrateRoot;const Wd=globalThis.atob,Qd=globalThis.btoa;class bt{static floatTo16BitPCM(t){const n=new ArrayBuffer(t.length*2),r=new DataView(n);let o=0;for(let i=0;ir[Math.floor(Math.random()*r.length)]).join("");return`${t}${o}`}}const Kd=e=>new Promise(t=>setTimeout(()=>t(),e));class pc{constructor(){this.eventHandlers={},this.nextEventHandlers={}}clearEventHandlers(){return this.eventHandlers={},this.nextEventHandlers={},!0}on(t,n){return this.eventHandlers[t]=this.eventHandlers[t]||[],this.eventHandlers[t].push(n),n}onNext(t,n){return this.nextEventHandlers[t]=this.nextEventHandlers[t]||[],this.nextEventHandlers[t].push(n),n}off(t,n){const r=this.eventHandlers[t]||[];if(n){const o=r.indexOf(n);if(o===-1)throw new Error(`Could not turn off specified event listener for "${t}": not found as a listener`);r.splice(o,1)}else delete this.eventHandlers[t];return!0}offNext(t,n){const r=this.nextEventHandlers[t]||[];if(n){const o=r.indexOf(n);if(o===-1)throw new Error(`Could not turn off specified next event listener for "${t}": not found as a listener`);r.splice(o,1)}else delete this.nextEventHandlers[t];return!0}async waitForNext(t,n=null){const r=Date.now();let o;for(this.onNext(t,i=>o=i);!o;){if(n&&Date.now()-r>n)return null;await Kd(1)}return o}dispatch(t,n){const r=[].concat(this.eventHandlers[t]||[]);for(const i of r)i(n);const o=[].concat(this.nextEventHandlers[t]||[]);for(const i of o)i(n);return delete this.nextEventHandlers[t],!0}}class qd extends pc{constructor({url:t,apiKey:n,dangerouslyAllowAPIKeyInBrowser:r,debug:o}={}){if(super(),this.defaultUrl="wss://api.openai.com/v1/realtime",this.url=t||this.defaultUrl,this.apiKey=n||null,this.debug=!!o,this.ws=null,globalThis.document&&this.apiKey&&!r)throw new Error('Can not provide API key in the browser without "dangerouslyAllowAPIKeyInBrowser" set to true')}isConnected(){return!!this.ws}log(...t){const r=[`[Websocket/${new Date().toISOString()}]`].concat(t).map(o=>typeof o=="object"&&o!==null?JSON.stringify(o,null,2):o);return this.debug&&console.log(...r),!0}async connect({model:t}={model:"gpt-4o-realtime-preview-2024-10-01"}){if(!this.apiKey&&this.url===this.defaultUrl&&console.warn(`No apiKey provided for connection to "${this.url}"`),this.isConnected())throw new Error("Already connected");if(globalThis.WebSocket){globalThis.document&&this.apiKey&&console.warn("Warning: Connecting using API key in the browser, this is not recommended");const n=globalThis.WebSocket,r=new n(`${this.url}${t?`?model=${t}`:""}`,["realtime",`openai-insecure-api-key.${this.apiKey}`,"openai-beta.realtime-v1"]);return r.addEventListener("message",o=>{const i=JSON.parse(o.data);this.receive(i.type,i)}),new Promise((o,i)=>{const l=()=>{this.disconnect(r),i(new Error(`Could not connect to "${this.url}"`))};r.addEventListener("error",l),r.addEventListener("open",()=>{this.log(`Connected to "${this.url}"`),r.removeEventListener("error",l),r.addEventListener("error",()=>{this.disconnect(r),this.log(`Error, disconnected from "${this.url}"`),this.dispatch("close",{error:!0})}),r.addEventListener("close",()=>{this.disconnect(r),this.log(`Disconnected from "${this.url}"`),this.dispatch("close",{error:!1})}),this.ws=r,o(!0)})})}else{const o=(await import("ws")).default,i=new o("wss://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview-2024-10-01",[],{finishRequest:l=>{l.setHeader("Authorization",`Bearer ${this.apiKey}`),l.setHeader("OpenAI-Beta","realtime=v1"),l.end()}});return i.on("message",l=>{const s=JSON.parse(l.toString());this.receive(s.type,s)}),new Promise((l,s)=>{const u=()=>{this.disconnect(i),s(new Error(`Could not connect to "${this.url}"`))};i.on("error",u),i.on("open",()=>{this.log(`Connected to "${this.url}"`),i.removeListener("error",u),i.on("error",()=>{this.disconnect(i),this.log(`Error, disconnected from "${this.url}"`),this.dispatch("close",{error:!0})}),i.on("close",()=>{this.disconnect(i),this.log(`Disconnected from "${this.url}"`),this.dispatch("close",{error:!1})}),this.ws=i,l(!0)})})}}disconnect(t){if(!t||this.ws===t)return this.ws&&this.ws.close(),this.ws=null,!0}receive(t,n){return this.log("received:",t,n),this.dispatch(`server.${t}`,n),this.dispatch("server.*",n),!0}send(t,n){if(!this.isConnected())throw new Error("RealtimeAPI is not connected");if(n=n||{},typeof n!="object")throw new Error("data must be an object");const r={event_id:bt.generateId("evt_"),type:t,...n};return this.dispatch(`client.${t}`,r),this.dispatch("client.*",r),this.log("sent:",t,r),this.ws.send(JSON.stringify(r)),!0}}class Yd{constructor(){Io(this,"defaultFrequency",24e3);Io(this,"EventProcessors",{"conversation.item.created":t=>{const{item:n}=t,r=JSON.parse(JSON.stringify(n));if(this.itemLookup[r.id]||(this.itemLookup[r.id]=r,this.items.push(r)),r.formatted={},r.formatted.audio=new Int16Array(0),r.formatted.text="",r.formatted.transcript="",this.queuedSpeechItems[r.id]&&(r.formatted.audio=this.queuedSpeechItems[r.id].audio,delete this.queuedSpeechItems[r.id]),r.content){const o=r.content.filter(i=>["text","input_text"].includes(i.type));for(const i of o)r.formatted.text+=i.text}return this.queuedTranscriptItems[r.id]&&(r.formatted.transcript=this.queuedTranscriptItems.transcript,delete this.queuedTranscriptItems[r.id]),r.type==="message"?r.role==="user"?(r.status="completed",this.queuedInputAudio&&(r.formatted.audio=this.queuedInputAudio,this.queuedInputAudio=null)):r.status="in_progress":r.type==="function_call"?(r.formatted.tool={type:"function",name:r.name,call_id:r.call_id,arguments:""},r.status="in_progress"):r.type==="function_call_output"&&(r.status="completed",r.formatted.output=r.output),{item:r,delta:null}},"conversation.item.truncated":t=>{const{item_id:n,audio_end_ms:r}=t,o=this.itemLookup[n];if(!o)throw new Error(`item.truncated: Item "${n}" not found`);const i=Math.floor(r*this.defaultFrequency/1e3);return o.formatted.transcript="",o.formatted.audio=o.formatted.audio.slice(0,i),{item:o,delta:null}},"conversation.item.deleted":t=>{const{item_id:n}=t,r=this.itemLookup[n];if(!r)throw new Error(`item.deleted: Item "${n}" not found`);delete this.itemLookup[r.id];const o=this.items.indexOf(r);return o>-1&&this.items.splice(o,1),{item:r,delta:null}},"conversation.item.input_audio_transcription.completed":t=>{const{item_id:n,content_index:r,transcript:o}=t,i=this.itemLookup[n],l=o||" ";return i?(i.content[r].transcript=o,i.formatted.transcript=l,{item:i,delta:{transcript:o}}):(this.queuedTranscriptItems[n]={transcript:l},{item:null,delta:null})},"input_audio_buffer.speech_started":t=>{const{item_id:n,audio_start_ms:r}=t;return this.queuedSpeechItems[n]={audio_start_ms:r},{item:null,delta:null}},"input_audio_buffer.speech_stopped":(t,n)=>{const{item_id:r,audio_end_ms:o}=t;this.queuedSpeechItems[r]||(this.queuedSpeechItems[r]={audio_start_ms:o});const i=this.queuedSpeechItems[r];if(i.audio_end_ms=o,n){const l=Math.floor(i.audio_start_ms*this.defaultFrequency/1e3),s=Math.floor(i.audio_end_ms*this.defaultFrequency/1e3);i.audio=n.slice(l,s)}return{item:null,delta:null}},"response.created":t=>{const{response:n}=t;return this.responseLookup[n.id]||(this.responseLookup[n.id]=n,this.responses.push(n)),{item:null,delta:null}},"response.output_item.added":t=>{const{response_id:n,item:r}=t,o=this.responseLookup[n];if(!o)throw new Error(`response.output_item.added: Response "${n}" not found`);return o.output.push(r.id),{item:null,delta:null}},"response.output_item.done":t=>{const{item:n}=t;if(!n)throw new Error('response.output_item.done: Missing "item"');const r=this.itemLookup[n.id];if(!r)throw new Error(`response.output_item.done: Item "${n.id}" not found`);return r.status=n.status,{item:r,delta:null}},"response.content_part.added":t=>{const{item_id:n,part:r}=t,o=this.itemLookup[n];if(!o)throw new Error(`response.content_part.added: Item "${n}" not found`);return o.content.push(r),{item:o,delta:null}},"response.audio_transcript.delta":t=>{const{item_id:n,content_index:r,delta:o}=t,i=this.itemLookup[n];if(!i)throw new Error(`response.audio_transcript.delta: Item "${n}" not found`);return i.content[r].transcript+=o,i.formatted.transcript+=o,{item:i,delta:{transcript:o}}},"response.audio.delta":t=>{const{item_id:n,content_index:r,delta:o}=t,i=this.itemLookup[n];if(!i)throw new Error(`response.audio.delta: Item "${n}" not found`);const l=bt.base64ToArrayBuffer(o),s=new Int16Array(l);return i.formatted.audio=bt.mergeInt16Arrays(i.formatted.audio,s),{item:i,delta:{audio:s}}},"response.text.delta":t=>{const{item_id:n,content_index:r,delta:o}=t,i=this.itemLookup[n];if(!i)throw new Error(`response.text.delta: Item "${n}" not found`);return i.content[r].text+=o,i.formatted.text+=o,{item:i,delta:{text:o}}},"response.function_call_arguments.delta":t=>{const{item_id:n,delta:r}=t,o=this.itemLookup[n];if(!o)throw new Error(`response.function_call_arguments.delta: Item "${n}" not found`);return o.arguments+=r,o.formatted.tool.arguments+=r,{item:o,delta:{arguments:r}}}});this.clear()}clear(){return this.itemLookup={},this.items=[],this.responseLookup={},this.responses=[],this.queuedSpeechItems={},this.queuedTranscriptItems={},this.queuedInputAudio=null,!0}queueInputAudio(t){return this.queuedInputAudio=t,t}processEvent(t,...n){if(!t.event_id)throw console.error(t),new Error('Missing "event_id" on event');if(!t.type)throw console.error(t),new Error('Missing "type" on event');const r=this.EventProcessors[t.type];if(!r)throw new Error(`Missing conversation event processor for "${t.type}"`);return r.call(this,t,...n)}getItem(t){return this.itemLookup[t]||null}getItems(){return this.items.slice()}}class Xd extends pc{constructor({url:t,apiKey:n,dangerouslyAllowAPIKeyInBrowser:r,debug:o}={}){super(),this.defaultSessionConfig={modalities:["text","audio"],instructions:"",voice:"verse",input_audio_format:"pcm16",output_audio_format:"pcm16",input_audio_transcription:null,turn_detection:null,tools:[],tool_choice:"auto",temperature:.8,max_response_output_tokens:4096},this.sessionConfig={},this.transcriptionModels=[{model:"whisper-1"}],this.defaultServerVadConfig={type:"server_vad",threshold:.5,prefix_padding_ms:300,silence_duration_ms:200},this.realtime=new qd({url:t,apiKey:n,dangerouslyAllowAPIKeyInBrowser:r,debug:o}),this.conversation=new Yd,this._resetConfig(),this._addAPIEventHandlers()}_resetConfig(){return this.sessionCreated=!1,this.tools={},this.sessionConfig=JSON.parse(JSON.stringify(this.defaultSessionConfig)),this.inputAudioBuffer=new Int16Array(0),!0}_addAPIEventHandlers(){this.realtime.on("client.*",o=>{const i={time:new Date().toISOString(),source:"client",event:o};this.dispatch("realtime.event",i)}),this.realtime.on("server.*",o=>{const i={time:new Date().toISOString(),source:"server",event:o};this.dispatch("realtime.event",i)}),this.realtime.on("server.session.created",()=>this.sessionCreated=!0);const t=(o,...i)=>{const{item:l,delta:s}=this.conversation.processEvent(o,...i);return{item:l,delta:s}},n=(o,...i)=>{const{item:l,delta:s}=t(o,...i);return l&&this.dispatch("conversation.updated",{item:l,delta:s}),{item:l,delta:s}},r=async o=>{try{const i=JSON.parse(o.arguments),l=this.tools[o.name];if(!l)throw new Error(`Tool "${o.name}" has not been added`);const s=await l.handler(i);this.realtime.send("conversation.item.create",{item:{type:"function_call_output",call_id:o.call_id,output:JSON.stringify(s)}})}catch(i){this.realtime.send("conversation.item.create",{item:{type:"function_call_output",call_id:o.call_id,output:JSON.stringify({error:i.message})}})}this.createResponse()};return this.realtime.on("server.response.created",t),this.realtime.on("server.response.output_item.added",t),this.realtime.on("server.response.content_part.added",t),this.realtime.on("server.input_audio_buffer.speech_started",o=>{t(o),this.dispatch("conversation.interrupted")}),this.realtime.on("server.input_audio_buffer.speech_stopped",o=>t(o,this.inputAudioBuffer)),this.realtime.on("server.conversation.item.created",o=>{const{item:i}=n(o);this.dispatch("conversation.item.appended",{item:i}),i.status==="completed"&&this.dispatch("conversation.item.completed",{item:i})}),this.realtime.on("server.conversation.item.truncated",n),this.realtime.on("server.conversation.item.deleted",n),this.realtime.on("server.conversation.item.input_audio_transcription.completed",n),this.realtime.on("server.response.audio_transcript.delta",n),this.realtime.on("server.response.audio.delta",n),this.realtime.on("server.response.text.delta",n),this.realtime.on("server.response.function_call_arguments.delta",n),this.realtime.on("server.response.output_item.done",async o=>{const{item:i}=n(o);i.status==="completed"&&this.dispatch("conversation.item.completed",{item:i}),i.formatted.tool&&r(i.formatted.tool)}),!0}isConnected(){return this.realtime.isConnected()}reset(){return this.disconnect(),this.clearEventHandlers(),this.realtime.clearEventHandlers(),this._resetConfig(),this._addAPIEventHandlers(),!0}async connect(){if(this.isConnected())throw new Error("Already connected, use .disconnect() first");return await this.realtime.connect(),this.updateSession(),!0}async waitForSessionCreated(){if(!this.isConnected())throw new Error("Not connected, use .connect() first");for(;!this.sessionCreated;)await new Promise(t=>setTimeout(()=>t(),1));return!0}disconnect(){this.sessionCreated=!1,this.realtime.isConnected()&&this.realtime.disconnect(),this.conversation.clear()}getTurnDetectionType(){var t;return((t=this.sessionConfig.turn_detection)==null?void 0:t.type)||null}addTool(t,n){if(!(t!=null&&t.name))throw new Error("Missing tool name in definition");const r=t==null?void 0:t.name;if(this.tools[r])throw new Error(`Tool "${r}" already added. Please use .removeTool("${r}") before trying to add again.`);if(typeof n!="function")throw new Error(`Tool "${r}" handler must be a function`);return this.tools[r]={definition:t,handler:n},this.updateSession(),this.tools[r]}removeTool(t){if(!this.tools[t])throw new Error(`Tool "${t}" does not exist, can not be removed.`);return delete this.tools[t],!0}deleteItem(t){return this.realtime.send("conversation.item.delete",{item_id:t}),!0}updateSession({modalities:t=void 0,instructions:n=void 0,voice:r=void 0,input_audio_format:o=void 0,output_audio_format:i=void 0,input_audio_transcription:l=void 0,turn_detection:s=void 0,tools:u=void 0,tool_choice:a=void 0,temperature:h=void 0,max_response_output_tokens:p=void 0}={}){t!==void 0&&(this.sessionConfig.modalities=t),n!==void 0&&(this.sessionConfig.instructions=n),r!==void 0&&(this.sessionConfig.voice=r),o!==void 0&&(this.sessionConfig.input_audio_format=o),i!==void 0&&(this.sessionConfig.output_audio_format=i),l!==void 0&&(this.sessionConfig.input_audio_transcription=l),s!==void 0&&(this.sessionConfig.turn_detection=s),u!==void 0&&(this.sessionConfig.tools=u),a!==void 0&&(this.sessionConfig.tool_choice=a),h!==void 0&&(this.sessionConfig.temperature=h),p!==void 0&&(this.sessionConfig.max_response_output_tokens=p);const m=[].concat((u||[]).map(w=>{const g={type:"function",...w};if(this.tools[g==null?void 0:g.name])throw new Error(`Tool "${g==null?void 0:g.name}" has already been defined`);return g}),Object.keys(this.tools).map(w=>({type:"function",...this.tools[w].definition}))),k={...this.sessionConfig};return k.tools=m,this.realtime.isConnected()&&this.realtime.send("session.update",{session:k}),!0}sendUserMessageContent(t=[]){if(t.length){for(const n of t)n.type==="input_audio"&&(n.audio instanceof ArrayBuffer||n.audio instanceof Int16Array)&&(n.audio=bt.arrayBufferToBase64(n.audio));this.realtime.send("conversation.item.create",{item:{type:"message",role:"user",content:t}})}return this.createResponse(),!0}appendInputAudio(t){return t.byteLength>0&&(this.realtime.send("input_audio_buffer.append",{audio:bt.arrayBufferToBase64(t)}),this.inputAudioBuffer=bt.mergeInt16Arrays(this.inputAudioBuffer,t)),!0}createResponse(){return this.getTurnDetectionType()===null&&this.inputAudioBuffer.byteLength>0&&(this.realtime.send("input_audio_buffer.commit"),this.conversation.queueInputAudio(this.inputAudioBuffer),this.inputAudioBuffer=new Int16Array(0)),this.realtime.send("response.create"),!0}cancelResponse(t,n=0){if(t){if(t){const r=this.conversation.getItem(t);if(!r)throw new Error(`Could not find item "${t}"`);if(r.type!=="message")throw new Error('Can only cancelResponse messages with type "message"');if(r.role!=="assistant")throw new Error('Can only cancelResponse messages with role "assistant"');this.realtime.send("response.cancel");const o=r.content.findIndex(i=>i.type==="audio");if(o===-1)throw new Error("Could not find audio on item to cancel");return this.realtime.send("conversation.item.truncate",{item_id:t,content_index:o,audio_end_ms:Math.floor(n/this.conversation.defaultFrequency*1e3)}),{item:r}}}else return this.realtime.send("response.cancel"),{item:null}}async waitForNextItem(){const t=await this.waitForNext("conversation.item.appended"),{item:n}=t;return{item:n}}async waitForNextCompletedItem(){const t=await this.waitForNext("conversation.item.completed"),{item:n}=t;return{item:n}}}class St{static floatTo16BitPCM(t){const n=new ArrayBuffer(t.length*2),r=new DataView(n);let o=0;for(let i=0;i>8]),new Uint8Array([n,n>>8,n>>16,n>>24])][t]}pack(t,n){if(n!=null&&n.bitsPerSample)if(n!=null&&n.channels){if(!(n!=null&&n.data))throw new Error('Missing "data"')}else throw new Error('Missing "channels"');else throw new Error('Missing "bitsPerSample"');const{bitsPerSample:r,channels:o,data:i}=n,l=["RIFF",this._packData(1,52),"WAVE","fmt ",this._packData(1,16),this._packData(0,1),this._packData(0,o.length),this._packData(1,t),this._packData(1,t*o.length*r/8),this._packData(0,o.length*r/8),this._packData(0,r),"data",this._packData(1,o[0].length*o.length*r/8),i],s=new Blob(l,{type:"audio/mpeg"}),u=URL.createObjectURL(s);return{blob:s,url:u,channelCount:o.length,sampleRate:t,duration:i.byteLength/(o.length*t*2)}}}globalThis.WavPacker=St;const Js=[4186.01,4434.92,4698.63,4978.03,5274.04,5587.65,5919.91,6271.93,6644.88,7040,7458.62,7902.13],Gd=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],ft=[],$l=[];for(let e=1;e<=8;e++)for(let t=0;tft[t]>lo[0]&&ft[t]ft[t]>lo[0]&&ft[t]=0;d--)if(f>w[d]){g[d]=Math.max(g[d],c);break}}a=g,h=o==="voice"?Zs:ft,p=o==="voice"?Jd:$l}else a=Array.from(r),h=a.map((w,g)=>u*g),p=h.map(w=>`${w.toFixed(2)} Hz`);const m=a.map(w=>Math.max(0,Math.min((w-i)/(l-i),1)));return{values:new Float32Array(m),frequencies:h,labels:p}}constructor(t,n=null){if(this.fftResults=[],n){const{length:r,sampleRate:o}=n,i=new OfflineAudioContext({length:r,sampleRate:o}),l=i.createBufferSource();l.buffer=n;const s=i.createAnalyser();s.fftSize=8192,s.smoothingTimeConstant=.1,l.connect(s);const u=1/60,a=r/o,h=p=>{const m=u*p;m{const k=new Float32Array(s.frequencyBinCount);s.getFloatFrequencyData(k),this.fftResults.push(k),h(p+1)}),p===1?i.startRendering():i.resume()};l.start(0),h(1),this.audio=t,this.context=i,this.analyser=s,this.sampleRate=o,this.audioBuffer=n}else{const r=new AudioContext,o=r.createMediaElementSource(t),i=r.createAnalyser();i.fftSize=8192,i.smoothingTimeConstant=.1,o.connect(i),i.connect(r.destination),this.audio=t,this.context=r,this.analyser=i,this.sampleRate=this.context.sampleRate,this.audioBuffer=null}}getFrequencies(t="frequency",n=-100,r=-30){let o=null;if(this.audioBuffer&&this.fftResults.length){const i=this.audio.currentTime/this.audio.duration,l=Math.min(i*this.fftResults.length|0,this.fftResults.length-1);o=this.fftResults[l]}return rr.getFrequencies(this.analyser,this.sampleRate,o,t,n,r)}async resumeIfSuspended(){return this.context.state==="suspended"&&await this.context.resume(),!0}}globalThis.AudioAnalysis=rr;const Zd=` +class StreamProcessor extends AudioWorkletProcessor { + constructor() { + super(); + this.hasStarted = false; + this.hasInterrupted = false; + this.outputBuffers = []; + this.bufferLength = 128; + this.write = { buffer: new Float32Array(this.bufferLength), trackId: null }; + this.writeOffset = 0; + this.trackSampleOffsets = {}; + this.port.onmessage = (event) => { + if (event.data) { + const payload = event.data; + if (payload.event === 'write') { + const int16Array = payload.buffer; + const float32Array = new Float32Array(int16Array.length); + for (let i = 0; i < int16Array.length; i++) { + float32Array[i] = int16Array[i] / 0x8000; // Convert Int16 to Float32 + } + this.writeData(float32Array, payload.trackId); + } else if ( + payload.event === 'offset' || + payload.event === 'interrupt' + ) { + const requestId = payload.requestId; + const trackId = this.write.trackId; + const offset = this.trackSampleOffsets[trackId] || 0; + this.port.postMessage({ + event: 'offset', + requestId, + trackId, + offset, + }); + if (payload.event === 'interrupt') { + this.hasInterrupted = true; + } + } else { + throw new Error(\`Unhandled event "\${payload.event}"\`); + } + } + }; + } + + writeData(float32Array, trackId = null) { + let { buffer } = this.write; + let offset = this.writeOffset; + for (let i = 0; i < float32Array.length; i++) { + buffer[offset++] = float32Array[i]; + if (offset >= buffer.length) { + this.outputBuffers.push(this.write); + this.write = { buffer: new Float32Array(this.bufferLength), trackId }; + buffer = this.write.buffer; + offset = 0; + } + } + this.writeOffset = offset; + return true; + } + + process(inputs, outputs, parameters) { + const output = outputs[0]; + const outputChannelData = output[0]; + const outputBuffers = this.outputBuffers; + if (this.hasInterrupted) { + this.port.postMessage({ event: 'stop' }); + return false; + } else if (outputBuffers.length) { + this.hasStarted = true; + const { buffer, trackId } = outputBuffers.shift(); + for (let i = 0; i < outputChannelData.length; i++) { + outputChannelData[i] = buffer[i] || 0; + } + if (trackId) { + this.trackSampleOffsets[trackId] = + this.trackSampleOffsets[trackId] || 0; + this.trackSampleOffsets[trackId] += buffer.length; + } + return true; + } else if (this.hasStarted) { + this.port.postMessage({ event: 'stop' }); + return false; + } else { + return true; + } + } +} + +registerProcessor('stream_processor', StreamProcessor); +`,bd=new Blob([Zd],{type:"application/javascript"}),ep=URL.createObjectURL(bd),tp=ep;class hc{constructor({sampleRate:t=44100}={}){this.scriptSrc=tp,this.sampleRate=t,this.context=null,this.stream=null,this.analyser=null,this.trackSampleOffsets={},this.interruptedTrackIds={}}async connect(){this.context=new AudioContext({sampleRate:this.sampleRate}),this.context.state==="suspended"&&await this.context.resume();try{await this.context.audioWorklet.addModule(this.scriptSrc)}catch(n){throw console.error(n),new Error(`Could not add audioWorklet module: ${this.scriptSrc}`)}const t=this.context.createAnalyser();return t.fftSize=8192,t.smoothingTimeConstant=.1,this.analyser=t,!0}getFrequencies(t="frequency",n=-100,r=-30){if(!this.analyser)throw new Error("Not connected, please call .connect() first");return rr.getFrequencies(this.analyser,this.sampleRate,null,t,n,r)}_start(){const t=new AudioWorkletNode(this.context,"stream_processor");return t.connect(this.context.destination),t.port.onmessage=n=>{const{event:r}=n.data;if(r==="stop")t.disconnect(),this.stream=null;else if(r==="offset"){const{requestId:o,trackId:i,offset:l}=n.data,s=l/this.sampleRate;this.trackSampleOffsets[o]={trackId:i,offset:l,currentTime:s}}},this.analyser.disconnect(),t.connect(this.analyser),this.stream=t,!0}add16BitPCM(t,n="default"){if(typeof n!="string")throw new Error("trackId must be a string");if(this.interruptedTrackIds[n])return;this.stream||this._start();let r;if(t instanceof Int16Array)r=t;else if(t instanceof ArrayBuffer)r=new Int16Array(t);else throw new Error("argument must be Int16Array or ArrayBuffer");return this.stream.port.postMessage({event:"write",buffer:r,trackId:n}),r}async getTrackSampleOffset(t=!1){if(!this.stream)return null;const n=crypto.randomUUID();this.stream.port.postMessage({event:t?"interrupt":"offset",requestId:n});let r;for(;!r;)r=this.trackSampleOffsets[n],await new Promise(i=>setTimeout(()=>i(),1));const{trackId:o}=r;return t&&o&&(this.interruptedTrackIds[o]=!0),r}async interrupt(){return this.getTrackSampleOffset(!0)}}globalThis.WavStreamPlayer=hc;const np=` +class AudioProcessor extends AudioWorkletProcessor { + + constructor() { + super(); + this.port.onmessage = this.receive.bind(this); + this.initialize(); + } + + initialize() { + this.foundAudio = false; + this.recording = false; + this.chunks = []; + } + + /** + * Concatenates sampled chunks into channels + * Format is chunk[Left[], Right[]] + */ + readChannelData(chunks, channel = -1, maxChannels = 9) { + let channelLimit; + if (channel !== -1) { + if (chunks[0] && chunks[0].length - 1 < channel) { + throw new Error( + \`Channel \${channel} out of range: max \${chunks[0].length}\` + ); + } + channelLimit = channel + 1; + } else { + channel = 0; + channelLimit = Math.min(chunks[0] ? chunks[0].length : 1, maxChannels); + } + const channels = []; + for (let n = channel; n < channelLimit; n++) { + const length = chunks.reduce((sum, chunk) => { + return sum + chunk[n].length; + }, 0); + const buffers = chunks.map((chunk) => chunk[n]); + const result = new Float32Array(length); + let offset = 0; + for (let i = 0; i < buffers.length; i++) { + result.set(buffers[i], offset); + offset += buffers[i].length; + } + channels[n] = result; + } + return channels; + } + + /** + * Combines parallel audio data into correct format, + * channels[Left[], Right[]] to float32Array[LRLRLRLR...] + */ + formatAudioData(channels) { + if (channels.length === 1) { + // Simple case is only one channel + const float32Array = channels[0].slice(); + const meanValues = channels[0].slice(); + return { float32Array, meanValues }; + } else { + const float32Array = new Float32Array( + channels[0].length * channels.length + ); + const meanValues = new Float32Array(channels[0].length); + for (let i = 0; i < channels[0].length; i++) { + const offset = i * channels.length; + let meanValue = 0; + for (let n = 0; n < channels.length; n++) { + float32Array[offset + n] = channels[n][i]; + meanValue += channels[n][i]; + } + meanValues[i] = meanValue / channels.length; + } + return { float32Array, meanValues }; + } + } + + /** + * Converts 32-bit float data to 16-bit integers + */ + floatTo16BitPCM(float32Array) { + const buffer = new ArrayBuffer(float32Array.length * 2); + const view = new DataView(buffer); + let offset = 0; + for (let i = 0; i < float32Array.length; i++, offset += 2) { + let s = Math.max(-1, Math.min(1, float32Array[i])); + view.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7fff, true); + } + return buffer; + } + + /** + * Retrieves the most recent amplitude values from the audio stream + * @param {number} channel + */ + getValues(channel = -1) { + const channels = this.readChannelData(this.chunks, channel); + const { meanValues } = this.formatAudioData(channels); + return { meanValues, channels }; + } + + /** + * Exports chunks as an audio/wav file + */ + export() { + const channels = this.readChannelData(this.chunks); + const { float32Array, meanValues } = this.formatAudioData(channels); + const audioData = this.floatTo16BitPCM(float32Array); + return { + meanValues: meanValues, + audio: { + bitsPerSample: 16, + channels: channels, + data: audioData, + }, + }; + } + + receive(e) { + const { event, id } = e.data; + let receiptData = {}; + switch (event) { + case 'start': + this.recording = true; + break; + case 'stop': + this.recording = false; + break; + case 'clear': + this.initialize(); + break; + case 'export': + receiptData = this.export(); + break; + case 'read': + receiptData = this.getValues(); + break; + default: + break; + } + // Always send back receipt + this.port.postMessage({ event: 'receipt', id, data: receiptData }); + } + + sendChunk(chunk) { + const channels = this.readChannelData([chunk]); + const { float32Array, meanValues } = this.formatAudioData(channels); + const rawAudioData = this.floatTo16BitPCM(float32Array); + const monoAudioData = this.floatTo16BitPCM(meanValues); + this.port.postMessage({ + event: 'chunk', + data: { + mono: monoAudioData, + raw: rawAudioData, + }, + }); + } + + process(inputList, outputList, parameters) { + // Copy input to output (e.g. speakers) + // Note that this creates choppy sounds with Mac products + const sourceLimit = Math.min(inputList.length, outputList.length); + for (let inputNum = 0; inputNum < sourceLimit; inputNum++) { + const input = inputList[inputNum]; + const output = outputList[inputNum]; + const channelCount = Math.min(input.length, output.length); + for (let channelNum = 0; channelNum < channelCount; channelNum++) { + input[channelNum].forEach((sample, i) => { + output[channelNum][i] = sample; + }); + } + } + const inputs = inputList[0]; + // There's latency at the beginning of a stream before recording starts + // Make sure we actually receive audio data before we start storing chunks + let sliceIndex = 0; + if (!this.foundAudio) { + for (const channel of inputs) { + sliceIndex = 0; // reset for each channel + if (this.foundAudio) { + break; + } + if (channel) { + for (const value of channel) { + if (value !== 0) { + // find only one non-zero entry in any channel + this.foundAudio = true; + break; + } else { + sliceIndex++; + } + } + } + } + } + if (inputs && inputs[0] && this.foundAudio && this.recording) { + // We need to copy the TypedArray, because the \`process\` + // internals will reuse the same buffer to hold each input + const chunk = inputs.map((input) => input.slice(sliceIndex)); + this.chunks.push(chunk); + this.sendChunk(chunk); + } + return true; + } +} + +registerProcessor('audio_processor', AudioProcessor); +`,rp=new Blob([np],{type:"application/javascript"}),op=URL.createObjectURL(rp),ip=op;class lp{constructor({sampleRate:t=44100,outputToSpeakers:n=!1,debug:r=!1}={}){this.scriptSrc=ip,this.sampleRate=t,this.outputToSpeakers=n,this.debug=!!r,this._deviceChangeCallback=null,this._devices=[],this.stream=null,this.processor=null,this.source=null,this.node=null,this.recording=!1,this._lastEventId=0,this.eventReceipts={},this.eventTimeout=5e3,this._chunkProcessor=()=>{},this._chunkProcessorSize=void 0,this._chunkProcessorBuffer={raw:new ArrayBuffer(0),mono:new ArrayBuffer(0)}}static async decode(t,n=44100,r=-1){const o=new AudioContext({sampleRate:n});let i,l;if(t instanceof Blob){if(r!==-1)throw new Error('Can not specify "fromSampleRate" when reading from Blob');l=t,i=await l.arrayBuffer()}else if(t instanceof ArrayBuffer){if(r!==-1)throw new Error('Can not specify "fromSampleRate" when reading from ArrayBuffer');i=t,l=new Blob([i],{type:"audio/wav"})}else{let h,p;if(t instanceof Int16Array){p=t,h=new Float32Array(t.length);for(let g=0;g');if(r===-1)throw new Error('Must specify "fromSampleRate" when reading from Float32Array, In16Array or Array');if(r<3e3)throw new Error('Minimum "fromSampleRate" is 3000 (3kHz)');p||(p=St.floatTo16BitPCM(h));const m={bitsPerSample:16,channels:[h],data:p};l=new St().pack(r,m).blob,i=await l.arrayBuffer()}const s=await o.decodeAudioData(i),u=s.getChannelData(0),a=URL.createObjectURL(l);return{blob:l,url:a,values:u,audioBuffer:s}}log(){return this.debug&&this.log(...arguments),!0}getSampleRate(){return this.sampleRate}getStatus(){return this.processor?this.recording?"recording":"paused":"ended"}async _event(t,n={},r=null){if(r=r||this.processor,!r)throw new Error("Can not send events without recording first");const o={event:t,id:this._lastEventId++,data:n};r.port.postMessage(o);const i=new Date().valueOf();for(;!this.eventReceipts[o.id];){if(new Date().valueOf()-i>this.eventTimeout)throw new Error(`Timeout waiting for "${t}" event`);await new Promise(s=>setTimeout(()=>s(!0),1))}const l=this.eventReceipts[o.id];return delete this.eventReceipts[o.id],l}listenForDeviceChange(t){if(t===null&&this._deviceChangeCallback)navigator.mediaDevices.removeEventListener("devicechange",this._deviceChangeCallback),this._deviceChangeCallback=null;else if(t!==null){let n=0,r=[];const o=l=>l.map(s=>s.deviceId).sort().join(","),i=async()=>{let l=++n;const s=await this.listDevices();l===n&&o(r)!==o(s)&&(r=s,t(s.slice()))};navigator.mediaDevices.addEventListener("devicechange",i),i(),this._deviceChangeCallback=i}return!0}async requestPermission(){const t=await navigator.permissions.query({name:"microphone"});if(t.state==="denied")window.alert("You must grant microphone access to use this feature.");else if(t.state==="prompt")try{(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(o=>o.stop())}catch{window.alert("You must grant microphone access to use this feature.")}return!0}async listDevices(){if(!navigator.mediaDevices||!("enumerateDevices"in navigator.mediaDevices))throw new Error("Could not request user devices");await this.requestPermission();const n=(await navigator.mediaDevices.enumerateDevices()).filter(i=>i.kind==="audioinput"),r=n.findIndex(i=>i.deviceId==="default"),o=[];if(r!==-1){let i=n.splice(r,1)[0],l=n.findIndex(s=>s.groupId===i.groupId);l!==-1&&(i=n.splice(l,1)[0]),i.default=!0,o.push(i)}return o.concat(n)}async begin(t){if(this.processor)throw new Error("Already connected: please call .end() to start a new session");if(!navigator.mediaDevices||!("getUserMedia"in navigator.mediaDevices))throw new Error("Could not request user media");try{const s={audio:!0};t&&(s.audio={deviceId:{exact:t}}),this.stream=await navigator.mediaDevices.getUserMedia(s)}catch{throw new Error("Could not start media stream")}const n=new AudioContext({sampleRate:this.sampleRate}),r=n.createMediaStreamSource(this.stream);try{await n.audioWorklet.addModule(this.scriptSrc)}catch(s){throw console.error(s),new Error(`Could not add audioWorklet module: ${this.scriptSrc}`)}const o=new AudioWorkletNode(n,"audio_processor");o.port.onmessage=s=>{const{event:u,id:a,data:h}=s.data;if(u==="receipt")this.eventReceipts[a]=h;else if(u==="chunk")if(this._chunkProcessorSize){const p=this._chunkProcessorBuffer;this._chunkProcessorBuffer={raw:St.mergeBuffers(p.raw,h.raw),mono:St.mergeBuffers(p.mono,h.mono)},this._chunkProcessorBuffer.mono.byteLength>=this._chunkProcessorSize&&(this._chunkProcessor(this._chunkProcessorBuffer),this._chunkProcessorBuffer={raw:new ArrayBuffer(0),mono:new ArrayBuffer(0)})}else this._chunkProcessor(h)};const i=r.connect(o),l=n.createAnalyser();return l.fftSize=8192,l.smoothingTimeConstant=.1,i.connect(l),this.outputToSpeakers&&(console.warn(`Warning: Output to speakers may affect sound quality, +especially due to system audio feedback preventative measures. +use only for debugging`),l.connect(n.destination)),this.source=r,this.node=i,this.analyser=l,this.processor=o,!0}getFrequencies(t="frequency",n=-100,r=-30){if(!this.processor)throw new Error("Session ended: please call .begin() first");return rr.getFrequencies(this.analyser,this.sampleRate,null,t,n,r)}async pause(){if(this.processor){if(!this.recording)throw new Error("Already paused: please call .record() first")}else throw new Error("Session ended: please call .begin() first");return this._chunkProcessorBuffer.raw.byteLength&&this._chunkProcessor(this._chunkProcessorBuffer),this.log("Pausing ..."),await this._event("stop"),this.recording=!1,!0}async record(t=()=>{},n=8192){if(this.processor){if(this.recording)throw new Error("Already recording: please call .pause() first");if(typeof t!="function")throw new Error("chunkProcessor must be a function")}else throw new Error("Session ended: please call .begin() first");return this._chunkProcessor=t,this._chunkProcessorSize=n,this._chunkProcessorBuffer={raw:new ArrayBuffer(0),mono:new ArrayBuffer(0)},this.log("Recording ..."),await this._event("start"),this.recording=!0,!0}async clear(){if(!this.processor)throw new Error("Session ended: please call .begin() first");return await this._event("clear"),!0}async read(){if(!this.processor)throw new Error("Session ended: please call .begin() first");return this.log("Reading ..."),await this._event("read")}async save(t=!1){if(!this.processor)throw new Error("Session ended: please call .begin() first");if(!t&&this.recording)throw new Error("Currently recording: please call .pause() first, or call .save(true) to force");this.log("Exporting ...");const n=await this._event("export");return new St().pack(this.sampleRate,n.audio)}async end(){if(!this.processor)throw new Error("Session ended: please call .begin() first");const t=this.processor;this.log("Stopping ..."),await this._event("stop"),this.recording=!1,this.stream.getTracks().forEach(l=>l.stop()),this.log("Exporting ...");const r=await this._event("export",{},t);return this.processor.disconnect(),this.source.disconnect(),this.node.disconnect(),this.analyser.disconnect(),this.stream=null,this.processor=null,this.source=null,this.node=null,new St().pack(this.sampleRate,r.audio)}async quit(){return this.listenForDeviceChange(null),this.processor&&await this.end(),!0}}globalThis.WavRecorder=lp;const sp=`System settings: +Tool use: enabled. + +Instructions: +- You are Hermes, Faros AI's technical program manager +- Faros AI is a comprehensive and extensible data and analytics platform for software engineering +- Faros allows customers to leverage game-changing analytics and time-saving automations to improve speed, productivity, quality, engagement, and business outcomes +- Please make sure to respond with a helpful voice via audio +- Be kind, helpful, and courteous +- It is okay to ask the user questions +- Be open to exploration and conversation + +Personality: +- Be upbeat and genuine +- Try speaking quickly as if excited +`,up=e=>{const n=ue.useRef(null),r=ue.useRef(null),[o,i]=ue.useState([]),[l,s]=ue.useState(null),u=()=>{n.current||(n.current=new WebSocket(e),n.current.onopen=()=>{console.log("Connected to WebSocket server"),r.current&&(clearInterval(r.current),r.current=null)},n.current.onmessage=async p=>{const k=JSON.parse(p.data).transcript,w=k.words.map(g=>g.text).join(" ");k.is_final?(i(g=>[...g,{speaker:k.speaker,text:w}]),s(null)):s({speaker:k.speaker,text:w})},n.current.onclose=()=>{console.log("WebSocket closed. Attempting to reconnect..."),n.current=null,a()},n.current.onerror=p=>{var m;console.error("WebSocket error:",p),(m=n.current)==null||m.close()})},a=()=>{r.current||(r.current=window.setInterval(()=>{console.log("Attempting to reconnect to WebSocket..."),u()},3e3))};return ue.useEffect(()=>(u(),()=>{n.current&&n.current.close(),r.current&&clearInterval(r.current)}),[]),{utterances:ue.useMemo(()=>l?[...o,l]:o,[o,l])}},Sn={current:null},Er={current:null};function ap(e,t){const r=e.toLowerCase().replace(/[.,!?]/g,"").split(/\s+/);return t.some(i=>r.includes(i))}const cp=["Organization Engineering Productivity Summary"];async function fp(){const e={};for(const t of cp){const n=await fetch(`https://ap.prod.workflows.faros.ai/api/v1/webhooks/g1HD6rzsPdR4SAIxYzRir/sync?dashboard-name=${encodeURIComponent(t)}`,{method:"GET"});e[t]=await n.json()}return e}function bs(e){return ap(e,["hermes"])}function dp(e){return Object.keys(e).map(t=>{e[t].summary.insights.map(n=>`The following is an insight from the ${t} dashboard, ${n.title} chart: ${n.description}`).join(` +`)}).join(` +`)}function pp(){const{utterances:e}=up("wss://meeting-data.bot.recall.ai/api/v1/transcript"),n=new URLSearchParams(window.location.search).get("wss"),[r,o]=ue.useState("disconnected");Sn.current||(Sn.current=new Xd({url:n||void 0})),Er.current||(Er.current=new hc({sampleRate:24e3}));const i=ue.useRef(!1),l=ue.useCallback(async()=>{const u=await fp();if(console.log(dp(u)),i.current)return;i.current=!0,o("connecting");const a=Sn.current,h=Er.current;if(!(!a||!h))try{await h.connect(),await a.connect(),o("connected"),a.on("error",p=>{console.error(p),o("disconnected")}),a.on("disconnected",()=>{o("disconnected")}),a.updateSession({turn_detection:{type:"server_vad"}})}catch(p){console.error("Connection error:",p),o("disconnected")}},[]),s=n?(()=>{try{return new URL(n),null}catch{return'Invalid URL format for "wss" parameter'}})():'Missing required "wss" parameter in URL';return ue.useEffect(()=>{if(!s){l();const u=Er.current,a=Sn.current;return!a||!u?void 0:(a.updateSession({instructions:sp}),a.on("error",h=>console.error(h)),a.on("conversation.interrupted",async()=>{const h=await u.interrupt();if(h!=null&&h.trackId){const{trackId:p,offset:m}=h;await a.cancelResponse(p,m)}}),a.on("conversation.updated",async({item:h,delta:p})=>{a.conversation.getItems(),p!=null&&p.audio&&u.add16BitPCM(p.audio,h.id)}),()=>{a.reset()})}},[s]),ue.useEffect(()=>{const u=Sn.current;e.length>0&&u&&bs(e[e.length-1].text)&&u.sendUserMessageContent([{type:"input_text",text:e[e.length-1].text}])},[e]),Ue.jsx("div",{className:"app-container",children:Ue.jsxs("div",{className:"status-indicator",children:[Ue.jsx("div",{className:`status-dot ${s?"disconnected":r}`}),Ue.jsxs("div",{className:"status-text",children:[Ue.jsx("div",{className:"status-label",children:s?"Error:":r==="connecting"?"Connecting to:":r==="connected"?"Connected to:":"Failed to connect to:"}),Ue.jsx("div",{className:"status-url",children:e.map((u,a)=>Ue.jsxs("div",{children:[u.speaker,": ",u.text," ",bs(u.text)?"🔔":""]},a))})]})]})})}dc(document.getElementById("root")).render(Ue.jsx(ue.StrictMode,{children:Ue.jsx(pp,{})})); diff --git a/index.html b/index.html index d0326b7..f1ae51d 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ Output Media Demo - +