Prioritize external transcription endpoint over browser Web Speech API
Previously the on-device Web Speech API (Chrome/Edge/Safari) was always preferred, and the configured external transcription endpoint was only used as a fallback when the browser had no speech API at all (Firefox). Flip the priority in Composer.tsx: if a transcription endpoint is configured in Settings, use it for dictation regardless of browser support, since it's generally far more accurate. Fall back to the browser's on-device SpeechRecognition only when no endpoint is set. Update the Settings hint text and README to describe the new behavior. Rebuilt and redeployed to the repo root.
This commit is contained in:
1 parent
c7b653ff6a
commit
ea1aeed1da
6 files changed
+29
-21
No files matched your search
@@ -0,0 +1,60 @@
|
||||
var tf=Object.defineProperty;var nf=(e,t,n)=>t in e?tf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _t=(e,t,n)=>nf(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const i of l)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(l){const i={};return l.integrity&&(i.integrity=l.integrity),l.referrerPolicy&&(i.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?i.credentials="include":l.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(l){if(l.ep)return;l.ep=!0;const i=n(l);fetch(l.href,i)}})();function Pu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Tu={exports:{}},yl={},Ru={exports:{}},O={};/**
|
||||
* @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 ar=Symbol.for("react.element"),rf=Symbol.for("react.portal"),lf=Symbol.for("react.fragment"),of=Symbol.for("react.strict_mode"),sf=Symbol.for("react.profiler"),uf=Symbol.for("react.provider"),af=Symbol.for("react.context"),cf=Symbol.for("react.forward_ref"),ff=Symbol.for("react.suspense"),df=Symbol.for("react.memo"),pf=Symbol.for("react.lazy"),os=Symbol.iterator;function hf(e){return e===null||typeof e!="object"?null:(e=os&&e[os]||e["@@iterator"],typeof e=="function"?e:null)}var Lu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},zu=Object.assign,Iu={};function gn(e,t,n){this.props=e,this.context=t,this.refs=Iu,this.updater=n||Lu}gn.prototype.isReactComponent={};gn.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")};gn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Mu(){}Mu.prototype=gn.prototype;function oo(e,t,n){this.props=e,this.context=t,this.refs=Iu,this.updater=n||Lu}var so=oo.prototype=new Mu;so.constructor=oo;zu(so,gn.prototype);so.isPureReactComponent=!0;var ss=Array.isArray,Ou=Object.prototype.hasOwnProperty,uo={current:null},Du={key:!0,ref:!0,__self:!0,__source:!0};function $u(e,t,n){var r,l={},i=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(i=""+t.key),t)Ou.call(t,r)&&!Du.hasOwnProperty(r)&&(l[r]=t[r]);var s=arguments.length-2;if(s===1)l.children=n;else if(1<s){for(var a=Array(s),c=0;c<s;c++)a[c]=arguments[c+2];l.children=a}if(e&&e.defaultProps)for(r in s=e.defaultProps,s)l[r]===void 0&&(l[r]=s[r]);return{$$typeof:ar,type:e,key:i,ref:o,props:l,_owner:uo.current}}function mf(e,t){return{$$typeof:ar,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function ao(e){return typeof e=="object"&&e!==null&&e.$$typeof===ar}function vf(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var us=/\/+/g;function $l(e,t){return typeof e=="object"&&e!==null&&e.key!=null?vf(""+e.key):t.toString(36)}function Or(e,t,n,r,l){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var o=!1;if(e===null)o=!0;else switch(i){case"string":case"number":o=!0;break;case"object":switch(e.$$typeof){case ar:case rf:o=!0}}if(o)return o=e,l=l(o),e=r===""?"."+$l(o,0):r,ss(l)?(n="",e!=null&&(n=e.replace(us,"$&/")+"/"),Or(l,t,n,"",function(c){return c})):l!=null&&(ao(l)&&(l=mf(l,n+(!l.key||o&&o.key===l.key?"":(""+l.key).replace(us,"$&/")+"/")+e)),t.push(l)),1;if(o=0,r=r===""?".":r+":",ss(e))for(var s=0;s<e.length;s++){i=e[s];var a=r+$l(i,s);o+=Or(i,t,n,a,l)}else if(a=hf(e),typeof a=="function")for(e=a.call(e),s=0;!(i=e.next()).done;)i=i.value,a=r+$l(i,s++),o+=Or(i,t,n,a,l);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return o}function vr(e,t,n){if(e==null)return e;var r=[],l=0;return Or(e,r,"","",function(i){return t.call(n,i,l++)}),r}function gf(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var de={current:null},Dr={transition:null},yf={ReactCurrentDispatcher:de,ReactCurrentBatchConfig:Dr,ReactCurrentOwner:uo};function Uu(){throw Error("act(...) is not supported in production builds of React.")}O.Children={map:vr,forEach:function(e,t,n){vr(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return vr(e,function(){t++}),t},toArray:function(e){return vr(e,function(t){return t})||[]},only:function(e){if(!ao(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};O.Component=gn;O.Fragment=lf;O.Profiler=sf;O.PureComponent=oo;O.StrictMode=of;O.Suspense=ff;O.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=yf;O.act=Uu;O.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=zu({},e.props),l=e.key,i=e.ref,o=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,o=uo.current),t.key!==void 0&&(l=""+t.key),e.type&&e.type.defaultProps)var s=e.type.defaultProps;for(a in t)Ou.call(t,a)&&!Du.hasOwnProperty(a)&&(r[a]=t[a]===void 0&&s!==void 0?s[a]:t[a])}var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){s=Array(a);for(var c=0;c<a;c++)s[c]=arguments[c+2];r.children=s}return{$$typeof:ar,type:e.type,key:l,ref:i,props:r,_owner:o}};O.createContext=function(e){return e={$$typeof:af,_currentValue:e,_currentValue2:e,_threadCount:0,ProviderLine truncated
|
||||
* @license React
|
||||
* react-jsx-runtime.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/var xf=R,Sf=Symbol.for("react.element"),kf=Symbol.for("react.fragment"),jf=Object.prototype.hasOwnProperty,Cf=xf.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ef={key:!0,ref:!0,__self:!0,__source:!0};function Fu(e,t,n){var r,l={},i=null,o=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(o=t.ref);for(r in t)jf.call(t,r)&&!Ef.hasOwnProperty(r)&&(l[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)l[r]===void 0&&(l[r]=t[r]);return{$$typeof:Sf,type:e,key:i,ref:o,props:l,_owner:Cf.current}}yl.Fragment=kf;yl.jsx=Fu;yl.jsxs=Fu;Tu.exports=yl;var u=Tu.exports,Au={exports:{}},Ce={},Vu={exports:{}},Hu={};/**
|
||||
* @license React
|
||||
* scheduler.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/(function(e){function t(E,L){var I=E.length;E.push(L);e:for(;0<I;){var G=I-1>>>1,ee=E[G];if(0<l(ee,L))E[G]=L,E[I]=ee,I=G;else break e}}function n(E){return E.length===0?null:E[0]}function r(E){if(E.length===0)return null;var L=E[0],I=E.pop();if(I!==L){E[0]=I;e:for(var G=0,ee=E.length,hr=ee>>>1;G<hr;){var Et=2*(G+1)-1,Dl=E[Et],Nt=Et+1,mr=E[Nt];if(0>l(Dl,I))Nt<ee&&0>l(mr,Dl)?(E[G]=mr,E[Nt]=I,G=Nt):(E[G]=Dl,E[Et]=I,G=Et);else if(Nt<ee&&0>l(mr,I))E[G]=mr,E[Nt]=I,G=Nt;else break e}}return L}function l(E,L){var I=E.sortIndex-L.sortIndex;return I!==0?I:E.id-L.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var a=[],c=[],p=1,h=null,d=3,y=!1,g=!1,x=!1,z=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(E){for(var L=n(c);L!==null;){if(L.callback===null)r(c);else if(L.startTime<=E)r(c),L.sortIndex=L.expirationTime,t(a,L);else break;L=n(c)}}function w(E){if(x=!1,v(E),!g)if(n(a)!==null)g=!0,U(C);else{var L=n(c);L!==null&&Fe(w,L.startTime-E)}}function C(E,L){g=!1,x&&(x=!1,m(T),T=-1),y=!0;var I=d;try{for(v(L),h=n(a);h!==null&&(!(h.expirationTime>L)||E&&!we());){var G=h.callback;if(typeof G=="function"){h.callback=null,d=h.priorityLevel;var ee=G(h.expirationTime<=L);L=e.unstable_now(),typeof ee=="function"?h.callback=ee:h===n(a)&&r(a),v(L)}else r(a);h=n(a)}if(h!==null)var hr=!0;else{var Et=n(c);Et!==null&&Fe(w,Et.startTime-L),hr=!1}return hr}finally{h=null,d=I,y=!1}}var _=!1,P=null,T=-1,H=5,M=-1;function we(){return!(e.unstable_now()-M<H)}function jt(){if(P!==null){var E=e.unstable_now();M=E;var L=!0;try{L=P(!0,E)}finally{L?Ct():(_=!1,P=null)}}else _=!1}var Ct;if(typeof f=="function")Ct=function(){f(jt)};else if(typeof MessageChannel<"u"){var Sn=new MessageChannel,k=Sn.port2;Sn.port1.onmessage=jt,Ct=function(){k.postMessage(null)}}else Ct=function(){z(jt,0)};function U(E){P=E,_||(_=!0,Ct())}function Fe(E,L){T=z(function(){E(e.unstable_now())},L)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(E){E.callback=null},e.unstable_continueExecution=function(){g||y||(g=!0,U(C))},e.unstable_forceFrameRate=function(E){0>E||125<E?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):H=0<E?Math.floor(1e3/E):5},e.unstable_getCurrentPriorityLevel=function(){return d},e.unstable_getFirstCallbackNode=function(){return n(a)},e.unstable_next=function(E){switch(d){case 1:case 2:case 3:var L=3;break;default:L=d}var I=d;d=L;try{return E()}finally{d=I}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(E,L){switch(E){case 1:case 2:case 3:case 4:case 5:break;default:E=3}var I=d;d=E;try{return L()}finally{d=I}},e.unstable_scheduleCallback=function(E,L,I){var G=e.unstable_now();switch(typeof I=="object"&&I!==null?(I=I.delay,I=typeof I=="number"&&0<I?G+I:G):I=G,E){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=I+ee,E={id:p++,callback:L,priorityLevel:E,startTime:I,expirationTime:ee,sortIndex:-1},I>G?(E.sortIndex=I,t(c,E),n(a)===null&&E===n(c)&&(x?(m(T),T=-1):x=!0,Fe(w,I-G))):(E.sortIndex=ee,t(a,E),g||y||(g=!0,U(C))),E},e.unstable_shouldYield=we,e.unstable_wrapCallback=function(E){var L=d;return function(){var I=d;d=L;try{return E.apply(this,arguments)}finally{d=I}}}})(Hu);Vu.exports=Hu;var Nf=Vu.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 _f=R,je=Nf;function S(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var Bu=new Set,Kn={};function Vt(e,t){an(e,t),an(e+"Capture",t)}function an(e,t){for(Kn[e]=t,e=0;e<t.length;e++)Bu.add(t[e])}var Je=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),pi=Object.prototype.hasOwnProperty,Pf=/^[: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]*$/,as={},cs={};function Tf(e){return pi.call(cs,e)?!0:pi.call(as,e)?!1:Pf.test(e)?cs[e]=!0:(as[e]=!0,!1)}function Rf(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 Lf(e,t,n,r){if(t===null||typeof t>"u"||Rf(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 pe(e,t,n,r,l,i,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=o}var ie={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ie[e]=new pe(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];ie[t]=new pe(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ie[e]=new pe(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ie[e]=new pe(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){ie[e]=new pe(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ie[e]=new pe(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ie[e]=new pe(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ie[e]=new pe(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ie[e]=new pe(e,5,!1,e.toLowerCase(),null,!1,!1)});var co=/[\-:]([a-z])/g;function fo(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(co,fo);ie[t]=new pe(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(co,fo);ie[t]=new pe(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(co,fo);ie[t]=new pe(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ie[e]=new pe(e,1,!1,e.toLowerCase(),null,!1,!1)});ie.xlinkHref=new pe("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ie[e]=new pe(e,1,!1,e.toLowerCase(),null,!0,!0)});function po(e,t,n,r){var l=ie.hasOwnProperty(t)?ie[t]:null;(l!==null?l.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="
Line truncated
|
||||
`+Ul+e}var Fl=!1;function Al(e,t){if(!e||Fl)return"";Fl=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(c){var r=c}Reflect.construct(e,[],t)}else{try{t.call()}catch(c){r=c}e.call(t.prototype)}else{try{throw Error()}catch(c){r=c}e()}}catch(c){if(c&&r&&typeof c.stack=="string"){for(var l=c.stack.split(`
|
||||
`),i=r.stack.split(`
|
||||
`),o=l.length-1,s=i.length-1;1<=o&&0<=s&&l[o]!==i[s];)s--;for(;1<=o&&0<=s;o--,s--)if(l[o]!==i[s]){if(o!==1||s!==1)do if(o--,s--,0>s||l[o]!==i[s]){var a=`
|
||||
`+l[o].replace(" at new "," at ");return e.displayName&&a.includes("<anonymous>")&&(a=a.replace("<anonymous>",e.displayName)),a}while(1<=o&&0<=s);break}}}finally{Fl=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Ln(e):""}function zf(e){switch(e.tag){case 5:return Ln(e.type);case 16:return Ln("Lazy");case 13:return Ln("Suspense");case 19:return Ln("SuspenseList");case 0:case 2:case 15:return e=Al(e.type,!1),e;case 11:return e=Al(e.type.render,!1),e;case 1:return e=Al(e.type,!0),e;default:return""}}function gi(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 Qt:return"Fragment";case Wt:return"Portal";case hi:return"Profiler";case ho:return"StrictMode";case mi:return"Suspense";case vi:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Qu:return(e.displayName||"Context")+".Consumer";case Wu:return(e._context.displayName||"Context")+".Provider";case mo:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case vo:return t=e.displayName||null,t!==null?t:gi(e.type)||"Memo";case lt:t=e._payload,e=e._init;try{return gi(e(t))}catch{}}return null}function If(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 gi(t);case 8:return t===ho?"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 yt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Yu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Mf(e){var t=Yu(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 l=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(o){r=""+o,i.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function yr(e){e._valueTracker||(e._valueTracker=Mf(e))}function Gu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Yu(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Yr(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 yi(e,t){var n=t.checked;return K({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ds(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=yt(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 Xu(e,t){t=t.checked,t!=null&&po(e,"checked",t,!1)}function wi(e,t){Xu(e,t);var n=yt(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")?xi(e,t.type,n):t.hasOwnProperty("defaultValue")&&xi(e,t.type,yt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function ps(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 xi(e,t,n){(t!=="number"||Yr(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var zn=Array.isArray;function nn(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l<n.length;l++)t["$"+n[l]]=!0;for(n=0;n<e.length;n++)l=t.hasOwnProperty("$"+e[n].value),e[n].selected!==l&&(e[n].selected=l),l&&r&&(e[n].defaultSelected=!0)}else{for(n=""+yt(n),t=null,l=0;l<e.length;l++){if(e[l].value===n){e[l].selected=!0,r&&(e[l].defaultSelected=!0);return}t!==null||e[l].disabled||(t=e[l])}t!==null&&(t.selected=!0)}}function Si(e,t){if(t.dang
Line truncated
|
||||
`).replace(Wd,"")}function Nr(e,t,n){if(t=Ds(t),Ds(e)!==t&&n)throw Error(S(425))}function tl(){}var Mi=null,Oi=null;function Di(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var $i=typeof setTimeout=="function"?setTimeout:void 0,Qd=typeof clearTimeout=="function"?clearTimeout:void 0,$s=typeof Promise=="function"?Promise:void 0,Kd=typeof queueMicrotask=="function"?queueMicrotask:typeof $s<"u"?function(e){return $s.resolve(null).then(e).catch(Yd)}:$i;function Yd(e){setTimeout(function(){throw e})}function bl(e,t){var n=t,r=0;do{var l=n.nextSibling;if(e.removeChild(n),l&&l.nodeType===8)if(n=l.data,n==="/$"){if(r===0){e.removeChild(l),Jn(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=l}while(n);Jn(t)}function pt(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function Us(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var wn=Math.random().toString(36).slice(2),Be="__reactFiber$"+wn,nr="__reactProps$"+wn,qe="__reactContainer$"+wn,Ui="__reactEvents$"+wn,Gd="__reactListeners$"+wn,Xd="__reactHandles$"+wn;function Lt(e){var t=e[Be];if(t)return t;for(var n=e.parentNode;n;){if(t=n[qe]||n[Be]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Us(e);e!==null;){if(n=e[Be])return n;e=Us(e)}return t}e=n,n=e.parentNode}return null}function dr(e){return e=e[Be]||e[qe],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Xt(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(S(33))}function jl(e){return e[nr]||null}var Fi=[],Zt=-1;function St(e){return{current:e}}function V(e){0>Zt||(e.current=Fi[Zt],Fi[Zt]=null,Zt--)}function F(e,t){Zt++,Fi[Zt]=e.current,e.current=t}var wt={},ae=St(wt),ve=St(!1),Dt=wt;function cn(e,t){var n=e.type.contextTypes;if(!n)return wt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},i;for(i in n)l[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function ge(e){return e=e.childContextTypes,e!=null}function nl(){V(ve),V(ae)}function Fs(e,t,n){if(ae.current!==wt)throw Error(S(168));F(ae,t),F(ve,n)}function $a(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(S(108,If(e)||"Unknown",l));return K({},n,r)}function rl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||wt,Dt=ae.current,F(ae,e),F(ve,ve.current),!0}function As(e,t,n){var r=e.stateNode;if(!r)throw Error(S(169));n?(e=$a(e,t,Dt),r.__reactInternalMemoizedMergedChildContext=e,V(ve),V(ae),F(ae,e)):V(ve),F(ve,n)}var Ye=null,Cl=!1,ei=!1;function Ua(e){Ye===null?Ye=[e]:Ye.push(e)}function Zd(e){Cl=!0,Ua(e)}function kt(){if(!ei&&Ye!==null){ei=!0;var e=0,t=$;try{var n=Ye;for($=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Ye=null,Cl=!1}catch(l){throw Ye!==null&&(Ye=Ye.slice(e+1)),aa(yo,kt),l}finally{$=t,ei=!1}}return null}var Jt=[],qt=0,ll=null,il=0,Ne=[],_e=0,$t=null,Ge=1,Xe="";function Pt(e,t){Jt[qt++]=il,Jt[qt++]=ll,ll=e,il=t}function Fa(e,t,n){Ne[_e++]=Ge,Ne[_e++]=Xe,Ne[_e++]=$t,$t=e;var r=Ge;e=Xe;var l=32-De(r)-1;r&=~(1<<l),n+=1;var i=32-De(t)+l;if(30<i){var o=l-l%5;i=(r&(1<<o)-1).toString(32),r>>=o,l-=o,Ge=1<<32-De(t)+l|n<<l|r,Xe=i+e}else Ge=1<<i|n<<l|r,Xe=e}function _o(e){e.return!==null&&(Pt(e,1),Fa(e,1,0))}function Po(e){for(;e===ll;)ll=Jt[--qt],Jt[qt]=null,il=Jt[--qt],Jt[qt]=null;for(;e===$t;)$t=Ne[--_e],Ne[_e]=null,Xe=Ne[--_e],Ne[_e]=null,Ge=Ne[--_e],Ne[_e]=null}var ke=null,Se=null,B=!1,Oe=null;function Aa(e,t){var n=Pe(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function Vs(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,ke=e,Se=pt(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ke=e,Se=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=$t!==null?{id:Ge,overflow:Xe}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Pe(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ke=e,Se=null,!0):!1;default:return!1}}function Ai(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Vi(e){if(B){var t=Se;if(t){var n=t;if(!Vs(e,t)){if(Ai(e))throw Error(S(418));t=pt(n.nextSibling);var r=ke;t&&Vs(e,t)?Aa(r,n):(e.flags=e.flags&-4097|2,B=!1,ke=e)}}else{if(Ai(e))throw Error(S(418));e.flags=e.flags&-4097|2,B=!1,ke=e}}}function Hs(e){for(e=e.return;e!==null&&e.t
Line truncated
|
||||
Error generating stack: `+i.message+`
|
||||
`+i.stack}return{value:e,source:t,stack:l,digest:null}}function ii(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Qi(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var ip=typeof WeakMap=="function"?WeakMap:Map;function pc(e,t,n){n=Ze(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){pl||(pl=!0,to=r),Qi(e,t)},n}function hc(e,t,n){n=Ze(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var l=t.value;n.payload=function(){return r(l)},n.callback=function(){Qi(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){Qi(e,t),typeof r!="function"&&(mt===null?mt=new Set([this]):mt.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function Zs(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new ip;var l=new Set;r.set(t,l)}else l=r.get(t),l===void 0&&(l=new Set,r.set(t,l));l.has(n)||(l.add(n),e=wp.bind(null,e,t,n),t.then(e,e))}function Js(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function qs(e,t,n,r,l){return e.mode&1?(e.flags|=65536,e.lanes=l,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Ze(-1,1),t.tag=2,ht(n,t,1))),n.lanes|=1),e)}var op=tt.ReactCurrentOwner,me=!1;function ce(e,t,n,r){t.child=e===null?Ba(t,null,n,r):dn(t,e.child,n,r)}function bs(e,t,n,r,l){n=n.render;var i=t.ref;return sn(t,l),r=Fo(e,t,n,r,i,l),n=Ao(),e!==null&&!me?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,et(e,t,l)):(B&&n&&_o(t),t.flags|=1,ce(e,t,r,l),t.child)}function eu(e,t,n,r,l){if(e===null){var i=n.type;return typeof i=="function"&&!Zo(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,mc(e,t,i,r,l)):(e=Kr(n.type,null,r,t,t.mode,l),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&l)){var o=i.memoizedProps;if(n=n.compare,n=n!==null?n:bn,n(o,r)&&e.ref===t.ref)return et(e,t,l)}return t.flags|=1,e=gt(i,r),e.ref=t.ref,e.return=t,t.child=e}function mc(e,t,n,r,l){if(e!==null){var i=e.memoizedProps;if(bn(i,r)&&e.ref===t.ref)if(me=!1,t.pendingProps=r=i,(e.lanes&l)!==0)e.flags&131072&&(me=!0);else return t.lanes=e.lanes,et(e,t,l)}return Ki(e,t,n,r,l)}function vc(e,t,n){var r=t.pendingProps,l=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},F(tn,xe),xe|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,F(tn,xe),xe|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,F(tn,xe),xe|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,F(tn,xe),xe|=r;return ce(e,t,l,n),t.child}function gc(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Ki(e,t,n,r,l){var i=ge(n)?Dt:ae.current;return i=cn(t,i),sn(t,l),n=Fo(e,t,n,r,i,l),r=Ao(),e!==null&&!me?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,et(e,t,l)):(B&&r&&_o(t),t.flags|=1,ce(e,t,n,l),t.child)}function tu(e,t,n,r,l){if(ge(n)){var i=!0;rl(t)}else i=!1;if(sn(t,l),t.stateNode===null)Br(e,t),dc(t,n,r),Wi(t,n,r,l),r=!0;else if(e===null){var o=t.stateNode,s=t.memoizedProps;o.props=s;var a=o.context,c=n.contextType;typeof c=="object"&&c!==null?c=Re(c):(c=ge(n)?Dt:ae.current,c=cn(t,c));var p=n.getDerivedStateFromProps,h=typeof p=="function"||typeof o.getSnapshotBeforeUpdate=="function";h||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(s!==r||a!==c)&&Xs(t,o,r,c),it=!1;var d=t.memoizedState;o.state=d,ul(t,r,o,l),a=t.memoizedState,s!==r||d!==a||ve.current||it?(typeof p=="function"&&(Bi(t,n,p,r),a=t.memoizedState),(s=it||Gs(t,n,s,r,d,a,c))?(h||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=a),o.props=r,o.state=a,o.context=c,r=s):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,Qa(e,t),s=t.memoizedProps,c=t.type===t.elementType?s:Ie(t.type,s),o.props=c,h=t.pendingProps,d=o.context,a=n.contextType,typeof a=="object"&&a!==null?a=Re(a):(a=ge(n)?Dt:ae.current,a=cn(t,a));var y=n.getDerivedStateFromProps;(p=typeof y=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(s!==h||d!==a)&&Xs(t,o,r,a),it=!1,d=t.memoizedState,o.state=d,ul(t,r,o,l);var g=t.memoizedState;s
Line truncated
|
||||
* @license React
|
||||
* use-sync-external-store-shim.production.js
|
||||
*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/var vn=R;function $p(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Up=typeof Object.is=="function"?Object.is:$p,Fp=vn.useState,Ap=vn.useEffect,Vp=vn.useLayoutEffect,Hp=vn.useDebugValue;function Bp(e,t){var n=t(),r=Fp({inst:{value:n,getSnapshot:t}}),l=r[0].inst,i=r[1];return Vp(function(){l.value=n,l.getSnapshot=t,ai(l)&&i({inst:l})},[e,n,t]),Ap(function(){return ai(l)&&i({inst:l}),e(function(){ai(l)&&i({inst:l})})},[e]),Hp(n),n}function ai(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Up(e,n)}catch{return!0}}function Wp(e,t){return t()}var Qp=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Wp:Bp;Qc.useSyncExternalStore=vn.useSyncExternalStore!==void 0?vn.useSyncExternalStore:Qp;Wc.exports=Qc;var Kp=Wc.exports;/**
|
||||
* @license React
|
||||
* use-sync-external-store-shim/with-selector.production.js
|
||||
*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/var Ml=R,Yp=Kp;function Gp(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Xp=typeof Object.is=="function"?Object.is:Gp,Zp=Yp.useSyncExternalStore,Jp=Ml.useRef,qp=Ml.useEffect,bp=Ml.useMemo,eh=Ml.useDebugValue;Bc.useSyncExternalStoreWithSelector=function(e,t,n,r,l){var i=Jp(null);if(i.current===null){var o={hasValue:!1,value:null};i.current=o}else o=i.current;i=bp(function(){function a(y){if(!c){if(c=!0,p=y,y=r(y),l!==void 0&&o.hasValue){var g=o.value;if(l(g,y))return h=g}return h=y}if(g=h,Xp(p,y))return g;var x=r(y);return l!==void 0&&l(g,x)?(p=y,g):(p=y,h=x)}var c=!1,p,h,d=n===void 0?null:n;return[function(){return a(t())},d===null?void 0:function(){return a(d())}]},[t,n,r,l]);var s=Zp(e,i[0],i[1]);return qp(function(){o.hasValue=!0,o.value=s},[s]),eh(s),s};Hc.exports=Bc;var th=Hc.exports;const nh=Pu(th),Kc={},{useDebugValue:rh}=wf,{useSyncExternalStoreWithSelector:lh}=nh;let gu=!1;const ih=e=>e;function oh(e,t=ih,n){(Kc?"production":void 0)!=="production"&&n&&!gu&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),gu=!0);const r=lh(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return rh(r),r}const sh=e=>{(Kc?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?Dp(e):e,n=(r,l)=>oh(t,r,l);return Object.assign(n,t),n},uh=e=>sh;class Wn extends Error{constructor(n,r,l){super(n);_t(this,"status");_t(this,"body");this.name="HermesError",this.status=r,this.body=l}}function ah(e){let t=e.trim();return t?(/^https?:\/\//i.test(t)||(t=`https://${t}`),t.replace(/\/+$/,"")):""}function yu(e,t){if(e&&typeof e=="object"){const n=e,r=n.error;if(r&&typeof r=="object"){const i=r.message;if(typeof i=="string"&&i)return i}const l=n.error??n.message??n.detail;if(typeof l=="string"&&l)return l}return typeof e=="string"&&e?e:`Request failed (HTTP ${t})`}function wu(e,t){if(Array.isArray(e))return e;if(e&&typeof e=="object"){const n=e;for(const r of t)if(Array.isArray(n[r]))return n[r]}return[]}function Yc(e){if(typeof e=="number")return e>1e12?e:e*1e3;if(typeof e=="string"){const t=Number(e);if(!Number.isNaN(t)&&e.trim()!=="")return t>1e12?t:t*1e3;const n=Date.parse(e);if(!Number.isNaN(n))return n}}function Ir(e){const t=String(e.id??e.session_id??""),n=String(e.title??"").trim(),r=typeof e.input_tokens=="number"?e.input_tokens:void 0,l=typeof e.output_tokens=="number"?e.output_tokens:void 0;return{id:t,title:n||"Untitled",preview:typeof e.preview=="string"?e.preview:void 0,source:typeof e.source=="string"?e.source:void 0,model:typeof e.model=="string"?e.model:void 0,provider:typeof e.provider=="string"?e.provider:void 0,messageCount:typeof e.message_count=="number"?e.message_count:void 0,toolCallCount:typeof e.tool_call_count=="number"?e.tool_call_count:void 0,updatedAt:Yc(e.last_active??e.ended_at??e.started_at),endReason:e.end_reason??null,pinned:!!e.pinned,archived:!!e.archived,costUsd:typeof e.estimated_cost_usd=="number"?e.estimated_cost_usd:void 0,tokens:r!==void 0||l!==void 0?(r??0)+(l??0):void 0}}function ch(e){return typeof e=="string"?e:Array.isArray(e)?e.map(t=>{if(typeof t=="string")return t;if(t&&typeof t=="object"){const n=t;if(typeof n.text=="string")return n.text;if(typeof n.content=="string")return n.content}return""}).join(""):""}function fh(e,t){const n=String(e.role??"assistant"),r=Array.isArray(e.tool_calls)?e.tool_calls.map((i,o)=>{var s,a;return{id:String(i.id??i.call_id??`tc-${t}-${o}`),name:String(((s=i.function)==null?void 0:s.name)??"tool"),preview:typeof((a=i.function)==null?void 0:a.arguments)=="string"?i.function.arguments:void 0,status:"done"}}):[],l=typeof e.reasoning_content=="string"&&e.reasoning_content||typeof e.reasoning=="string"&&e.reasoning||void 0;return{id:String(e.id??`msg-${t}`),role:n,content:ch(e.content)||(typeof e.text=="string"?e.text:""),reasoning:l||void 0,toolCalls:r.length?r:void 0,toolName:typeof e.tool_name=="string"?e.tool_name:void 0,timestamp:Yc(e.timestamp??e.created_at)}}class Gc{constructor(t){_t(this,"baseUrl");_t(this,"apiKey");_t(this,"profile");_t(this,"customHeaders");var n;this.baseUrl=t.sameOrigin?"":ah(t.baseUrl),this.apiKey=t.apiKey,this.profile=((n=t.profile)==null?void 0:n.trim())||void 0,this.customHeaders=t.customHeaders??[]}headers(t){const n={...t};this.apiKey&&(n.Authorization=`Bearer ${this.apiKey}`);for(const{name:r,value:l}of this.customHeaders)r.trim()&&(n[r.trim()]=l);return n}url(t){const n=this.profile?`/p/${encodeURIComponent(this.profile)}`:"";return`${this.baseUrl}${n}${t}`}async request(t,n={}){const{json:r,...l}=n,i=this.headers({Accept:"application/json",...r!==void 0?{"Content-Type":"application/json"}:{},...l.headers??{}});let o;try{o=await fetch(this.uLine truncated
|
||||
`)){if(!z||z.startsWith(":"))continue;const m=z.indexOf(":"),f=m===-1?z:z.slice(0,m);let v=m===-1?"":z.slice(m+1);v.startsWith(" ")&&(v=v.slice(1)),f==="event"?d=v:f==="data"&&y.push(v)}if(!y.length)return;const g=y.join(`
|
||||
`);if(g==="[DONE]"){n("done",{});return}let x=g;try{x=JSON.parse(g)}catch{}n(d,x)};try{for(;;){const{done:h,value:d}=await o.read();if(h)break;a+=s.decode(d,{stream:!0});let y;for(;(y=a.indexOf(`
|
||||
|
||||
`))!==-1;){const g=a.slice(0,y);a=a.slice(y+2),c(g)}}a.trim()&&c(a)}finally{(p=o.releaseLock)==null||p.call(o)}}}const io=2,Rt={connections:[],activeConnectionId:null,speakReplies:!1,ttsVoice:"",showToolCalls:!1,showReasoning:!1,showSystem:!0,transcribeUrl:"",transcribeKey:"",transcribeModel:"whisper-1",mediaBaseUrl:"",mediaPathPrefix:"",prefsVersion:io},Xc="hermes.config.v2";function dh(){try{const e=localStorage.getItem(Xc);if(!e)return{...Rt};const t=JSON.parse(e),n={...Rt,...t,connections:Array.isArray(t.connections)?t.connections:[]};return(t.prefsVersion??1)<io&&(n.showToolCalls=Rt.showToolCalls,n.showReasoning=Rt.showReasoning,n.showSystem=Rt.showSystem,n.prefsVersion=io),n}catch{return{...Rt}}}function Mr(e){localStorage.setItem(Xc,JSON.stringify(e))}function Qn(e){return e.connections.length?e.connections.find(t=>t.id===e.activeConnectionId)??e.connections[0]??null:null}function ph(e){const t=Qn(e);return!!t&&(t.sameOrigin===!0||t.baseUrl.trim().length>0)}function hh(){return`conn-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`}let Rn=null;function mh(e){return new Gc({baseUrl:e.baseUrl,apiKey:e.apiKey,profile:e.profile,sameOrigin:e.sameOrigin,customHeaders:e.customHeaders})}function Ve(e){return e instanceof Wn||e instanceof Error?e.message:String(e)}function rt(e,t,n){return e.map(r=>r.id===t?n(r):r)}const j=uh()((e,t)=>({config:{...Rt},client:null,ready:!1,connectionError:null,capabilities:null,models:[],sessions:[],sessionsLoading:!1,searchQuery:"",activeSessionId:null,session:null,messages:[],sessionLoading:!1,streaming:!1,runId:null,streamError:null,steerLeftover:null,sidebarOpen:!1,showSettings:!1,toast:null,async bootstrap(){const n=dh();e({config:n,ready:!0}),Qn(n)&&await t().connect()},async saveConnection(n){const r=t().config,i=r.connections.some(s=>s.id===n.id)?r.connections.map(s=>s.id===n.id?n:s):[...r.connections,n],o={...r,connections:i,activeConnectionId:n.id};Mr(o),e({config:o}),await t().connect()},async removeConnection(n){var s;const r=t().config,l=r.connections.filter(a=>a.id!==n),i=r.activeConnectionId===n?((s=l[0])==null?void 0:s.id)??null:r.activeConnectionId,o={...r,connections:l,activeConnectionId:i};Mr(o),e({config:o,sessions:[],session:null,messages:[],activeSessionId:null}),Qn(o)&&await t().connect()},async setActiveConnection(n){const r={...t().config,activeConnectionId:n};Mr(r),e({config:r,sessions:[],session:null,messages:[],activeSessionId:null}),await t().connect()},updatePrefs(n){const r={...t().config,...n};Mr(r),e({config:r})},async connect(){const n=Qn(t().config);if(!n||!n.sameOrigin&&!n.baseUrl.trim())return;const r=mh(n);e({client:r,connectionError:null,capabilities:null});try{const l=await r.capabilities();e({capabilities:l}),r.models().then(i=>e({models:i})).catch(()=>{}),await t().loadSessions()}catch(l){e({connectionError:Ve(l),capabilities:null})}},async loadSessions(){const{client:n,searchQuery:r}=t();if(n){e({sessionsLoading:!0});try{const l=await n.listSessions({limit:200}),i=r.trim().toLowerCase(),o=i?l.filter(s=>s.title.toLowerCase().includes(i)):l;e({sessions:o,sessionsLoading:!1})}catch(l){e({sessionsLoading:!1,toast:Ve(l)})}}},setSearch(n){e({searchQuery:n}),t().loadSessions()},async openSession(n){const{client:r}=t();if(r){e({activeSessionId:n,sessionLoading:!0,session:null,messages:[],sidebarOpen:!1,streamError:null});try{const[l,i]=await Promise.all([r.getSession(n).catch(()=>null),r.getMessages(n,{limit:500,order:"oldest"})]);e({session:l??{id:n,title:"Untitled"},messages:i,sessionLoading:!1})}catch(l){e({sessionLoading:!1,toast:Ve(l)})}}},async newSession(){const{client:n}=t();if(n)try{const r=await n.createSession();e({session:r,messages:[],activeSessionId:r.id,sidebarOpen:!1,streamError:null}),await t().loadSessions()}catch(r){e({toast:Ve(r)})}},async renameSession(n,r){var i;const{client:l}=t();if(l)try{await l.updateSession(n,{title:r}),e({sessions:t().sessions.map(o=>o.id===n?{...o,title:r}:o),session:((i=t().session)==null?void 0:i.id)===n?{...t().session,title:r}:t().session})}catch(o){e({toast:Ve(o)})}},async deleteSession(n){const{client:r}=t();if(r)try{await r.deleteSession(n);const l=t().activeSessionId===n;e({sessions:t().sessions.filter(i=>i.id!==n),...l?{activeSessionId:null,session:null,messages:[]}:{}})}catch(l){e({toast:Ve(l)})}},async forkSession(n){const{client:r}=t();if(r)try{const l=await r.forkSession(n);await t().loadSessions(),await t().openSession(l.id)}catch(l){e({toast:Ve(l)})}},async send(n,r){const{client:l,activeSessionId:i,messages:o}=t();if(!l||!i)return;const s=n.trim();if(!s&&!(r!=null&&r.length)||t().streaming)return;const a={id:`local-user-${Date.now()}`,role:"user",content:s,attachments:r,timestamp:Date.now()},c=`local-assistant-${Date.now()}`,p={id:c,role:"assistant",content:"",timestamp:Date.now(),streaming:!0,toolCalls:[]};e({messages:[...o,a,p],streaming:!0,streamError:null,runId:null});let h=s;if(r!=null&&r.length){const d=[];s&&d.push({type:"text",text:s});for(const y of r)d.pu
Line truncated
|
||||
Reference in new issue
Block a user