diff --git a/static/dist/jbot.js b/static/dist/jbot.js index 016288f..a504f21 100644 --- a/static/dist/jbot.js +++ b/static/dist/jbot.js @@ -1,4 +1,4 @@ -import{r as l,j as i,c as sn}from"./client-DS0SU7Jy.js";/** +import{r as l,j as i,c as on}from"./client-DS0SU7Jy.js";/** * react-router v7.15.1 * * Copyright (c) Remix Software Inc. @@ -7,6 +7,6 @@ import{r as l,j as i,c as sn}from"./client-DS0SU7Jy.js";/** * LICENSE.md file in the root directory of this source tree. * * @license MIT - */var bt="popstate";function wt(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function on(e={}){function t(r,a){var u;let s=(u=a.state)==null?void 0:u.masked,{pathname:o,search:d,hash:c}=s||r.location;return Qe("",{pathname:o,search:d,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default",s?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,a){return typeof a=="string"?a:xe(a)}return cn(t,n,null,e)}function T(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function q(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function ln(){return Math.random().toString(36).substring(2,10)}function xt(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Qe(e,t,n=null,r,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?de(t):t,state:n,key:t&&t.key||r||ln(),mask:a}}function xe({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function de(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function cn(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:s=!1}=r,o=a.history,d="POP",c=null,u=m();u==null&&(u=0,o.replaceState({...o.state,idx:u},""));function m(){return(o.state||{idx:null}).idx}function h(){d="POP";let f=m(),v=f==null?null:f-u;u=f,c&&c({action:d,location:b.location,delta:v})}function p(f,v){d="PUSH";let x=wt(f)?f:Qe(b.location,f,v);u=m()+1;let w=xt(x,u),P=b.createHref(x.mask||x);try{o.pushState(w,"",P)}catch(R){if(R instanceof DOMException&&R.name==="DataCloneError")throw R;a.location.assign(P)}s&&c&&c({action:d,location:b.location,delta:1})}function y(f,v){d="REPLACE";let x=wt(f)?f:Qe(b.location,f,v);u=m();let w=xt(x,u),P=b.createHref(x.mask||x);o.replaceState(w,"",P),s&&c&&c({action:d,location:b.location,delta:0})}function g(f){return un(f)}let b={get action(){return d},get location(){return e(a,o)},listen(f){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(bt,h),c=f,()=>{a.removeEventListener(bt,h),c=null}},createHref(f){return t(a,f)},createURL:g,encodeLocation(f){let v=g(f);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:p,replace:y,go(f){return o.go(f)}};return b}function un(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),T(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:xe(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function It(e,t,n="/"){return dn(e,t,n,!1)}function dn(e,t,n,r,a){let s=typeof t=="string"?de(t):t,o=ee(s.pathname||"/",n);if(o==null)return null;let d=hn(e),c=null,u=Sn(o);for(let m=0;c==null&&m{let m={relativePath:u===void 0?o.path||"":u,caseSensitive:o.caseSensitive===!0,childrenIndex:d,route:o};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(r)&&c)return;T(m.relativePath.startsWith(r),`Absolute route path "${m.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),m.relativePath=m.relativePath.slice(r.length)}let h=V([r,m.relativePath]),p=n.concat(m);o.children&&o.children.length>0&&(T(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),_t(o.children,t,p,h,c)),!(o.path==null&&!o.index)&&t.push({path:h,score:wn(h,o.index),routesMeta:p})};return e.forEach((o,d)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))s(o,d);else for(let u of Lt(o.path))s(o,d,!0,u)}),t}function Lt(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return a?[s,""]:[s];let o=Lt(r.join("/")),d=[];return d.push(...o.map(c=>c===""?s:[s,c].join("/"))),a&&d.push(...o),d.map(c=>e.startsWith("/")&&c===""?"/":c)}function fn(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:xn(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var mn=/^:[\w-]+$/,pn=3,gn=2,yn=1,vn=10,bn=-2,Et=e=>e==="*";function wn(e,t){let n=e.split("/"),r=n.length;return n.some(Et)&&(r+=bn),t&&(r+=gn),n.filter(a=>!Et(a)).reduce((a,s)=>a+(mn.test(s)?pn:s===""?yn:vn),r)}function xn(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function En(e,t,n=!1){let{routesMeta:r}=e,a={},s="/",o=[];for(let d=0;d{if(m==="*"){let g=d[p]||"";o=s.slice(0,s.length-g.length).replace(/(.)\/+$/,"$1")}const y=d[p];return h&&!y?u[m]=void 0:u[m]=(y||"").replace(/%2F/g,"/"),u},{}),pathname:s,pathnameBase:o,pattern:e}}function Rn(e,t=!1,n=!0){q(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,d,c,u,m)=>{if(r.push({paramName:d,isOptional:c!=null}),c){let h=m.charAt(u+o.length);return h&&h!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function Sn(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return q(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function ee(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var kn=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Cn(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?de(e):e,s;return n?(n=Bt(n),n.startsWith("/")?s=Rt(n.substring(1),"/"):s=Rt(n,t)):s=t,{pathname:s,search:Mn(r),hash:Tn(a)}}function Rt(e,t){let n=Fe(t).split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function qe(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function Nn(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function $t(e){let t=Nn(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function at(e,t,n,r=!1){let a;typeof e=="string"?a=de(e):(a={...e},T(!a.pathname||!a.pathname.includes("?"),qe("?","pathname","search",a)),T(!a.pathname||!a.pathname.includes("#"),qe("#","pathname","hash",a)),T(!a.search||!a.search.includes("#"),qe("#","search","hash",a)));let s=e===""||a.pathname==="",o=s?"/":a.pathname,d;if(o==null)d=n;else{let h=t.length-1;if(!r&&o.startsWith("..")){let p=o.split("/");for(;p[0]==="..";)p.shift(),h-=1;a.pathname=p.join("/")}d=h>=0?t[h]:"/"}let c=Cn(a,d),u=o&&o!=="/"&&o.endsWith("/"),m=(s||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||m)&&(c.pathname+="/"),c}var Bt=e=>e.replace(/\/\/+/g,"/"),V=e=>Bt(e.join("/")),Fe=e=>e.replace(/\/+$/,""),jn=e=>Fe(e).replace(/^\/*/,"/"),Mn=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Tn=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,An=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Pn(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function In(e){let t=e.map(n=>n.route.path).filter(Boolean);return V(t)||"/"}var Ft=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ot(e,t){let n=e;if(typeof n!="string"||!kn.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(Ft)try{let s=new URL(window.location.href),o=n.startsWith("//")?new URL(s.protocol+n):new URL(n),d=ee(o.pathname,t);o.origin===s.origin&&d!=null?n=d+o.search+o.hash:a=!0}catch{q(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Dt=["POST","PUT","PATCH","DELETE"];new Set(Dt);var _n=["GET",...Dt];new Set(_n);var he=l.createContext(null);he.displayName="DataRouter";var De=l.createContext(null);De.displayName="DataRouterState";var Ut=l.createContext(!1);function Ln(){return l.useContext(Ut)}var Ht=l.createContext({isTransitioning:!1});Ht.displayName="ViewTransition";var $n=l.createContext(new Map);$n.displayName="Fetchers";var Bn=l.createContext(null);Bn.displayName="Await";var z=l.createContext(null);z.displayName="Navigation";var Re=l.createContext(null);Re.displayName="Location";var te=l.createContext({outlet:null,matches:[],isDataRoute:!1});te.displayName="Route";var st=l.createContext(null);st.displayName="RouteError";var zt="REACT_ROUTER_ERROR",Fn="REDIRECT",On="ROUTE_ERROR_RESPONSE";function Dn(e){if(e.startsWith(`${zt}:${Fn}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function Un(e){if(e.startsWith(`${zt}:${On}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new An(t.status,t.statusText,t.data)}catch{}}function Hn(e,{relative:t}={}){T(Se(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:r}=l.useContext(z),{hash:a,pathname:s,search:o}=Ce(e,{relative:t}),d=s;return n!=="/"&&(d=s==="/"?n:V([n,s])),r.createHref({pathname:d,search:o,hash:a})}function Se(){return l.useContext(Re)!=null}function ne(){return T(Se(),"useLocation() may be used only in the context of a component."),l.useContext(Re).location}var Wt="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Vt(e){l.useContext(z).static||l.useLayoutEffect(e)}function ke(){let{isDataRoute:e}=l.useContext(te);return e?tr():zn()}function zn(){T(Se(),"useNavigate() may be used only in the context of a component.");let e=l.useContext(he),{basename:t,navigator:n}=l.useContext(z),{matches:r}=l.useContext(te),{pathname:a}=ne(),s=JSON.stringify($t(r)),o=l.useRef(!1);return Vt(()=>{o.current=!0}),l.useCallback((c,u={})=>{if(q(o.current,Wt),!o.current)return;if(typeof c=="number"){n.go(c);return}let m=at(c,JSON.parse(s),a,u.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:V([t,m.pathname])),(u.replace?n.replace:n.push)(m,u.state,u)},[t,n,s,a,e])}l.createContext(null);function Ce(e,{relative:t}={}){let{matches:n}=l.useContext(te),{pathname:r}=ne(),a=JSON.stringify($t(n));return l.useMemo(()=>at(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function Wn(e,t){return Kt(e,t)}function Kt(e,t,n){var f;T(Se(),"useRoutes() may be used only in the context of a component.");let{navigator:r}=l.useContext(z),{matches:a}=l.useContext(te),s=a[a.length-1],o=s?s.params:{},d=s?s.pathname:"/",c=s?s.pathnameBase:"/",u=s&&s.route;{let v=u&&u.path||"";qt(d,!u||v.endsWith("*")||v.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${d}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. + */var wt="popstate";function xt(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function ln(e={}){function t(r,a){var d;let s=(d=a.state)==null?void 0:d.masked,{pathname:o,search:u,hash:c}=s||r.location;return Ze("",{pathname:o,search:u,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default",s?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,a){return typeof a=="string"?a:Ee(a)}return un(t,n,null,e)}function M(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function q(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function cn(){return Math.random().toString(36).substring(2,10)}function Et(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Ze(e,t,n=null,r,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?he(t):t,state:n,key:t&&t.key||r||cn(),mask:a}}function Ee({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function he(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function un(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:s=!1}=r,o=a.history,u="POP",c=null,d=f();d==null&&(d=0,o.replaceState({...o.state,idx:d},""));function f(){return(o.state||{idx:null}).idx}function h(){u="POP";let m=f(),g=m==null?null:m-d;d=m,c&&c({action:u,location:b.location,delta:g})}function p(m,g){u="PUSH";let x=xt(m)?m:Ze(b.location,m,g);d=f()+1;let w=Et(x,d),P=b.createHref(x.mask||x);try{o.pushState(w,"",P)}catch(R){if(R instanceof DOMException&&R.name==="DataCloneError")throw R;a.location.assign(P)}s&&c&&c({action:u,location:b.location,delta:1})}function v(m,g){u="REPLACE";let x=xt(m)?m:Ze(b.location,m,g);d=f();let w=Et(x,d),P=b.createHref(x.mask||x);o.replaceState(w,"",P),s&&c&&c({action:u,location:b.location,delta:0})}function y(m){return dn(m)}let b={get action(){return u},get location(){return e(a,o)},listen(m){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(wt,h),c=m,()=>{a.removeEventListener(wt,h),c=null}},createHref(m){return t(a,m)},createURL:y,encodeLocation(m){let g=y(m);return{pathname:g.pathname,search:g.search,hash:g.hash}},push:p,replace:v,go(m){return o.go(m)}};return b}function dn(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),M(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:Ee(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Lt(e,t,n="/"){return hn(e,t,n,!1)}function hn(e,t,n,r,a){let s=typeof t=="string"?he(t):t,o=te(s.pathname||"/",n);if(o==null)return null;let u=fn(e),c=null,d=kn(o);for(let f=0;c==null&&f{let f={relativePath:d===void 0?o.path||"":d,caseSensitive:o.caseSensitive===!0,childrenIndex:u,route:o};if(f.relativePath.startsWith("/")){if(!f.relativePath.startsWith(r)&&c)return;M(f.relativePath.startsWith(r),`Absolute route path "${f.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),f.relativePath=f.relativePath.slice(r.length)}let h=V([r,f.relativePath]),p=n.concat(f);o.children&&o.children.length>0&&(M(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),_t(o.children,t,p,h,c)),!(o.path==null&&!o.index)&&t.push({path:h,score:xn(h,o.index),routesMeta:p})};return e.forEach((o,u)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))s(o,u);else for(let d of $t(o.path))s(o,u,!0,d)}),t}function $t(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return a?[s,""]:[s];let o=$t(r.join("/")),u=[];return u.push(...o.map(c=>c===""?s:[s,c].join("/"))),a&&u.push(...o),u.map(c=>e.startsWith("/")&&c===""?"/":c)}function mn(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:En(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var pn=/^:[\w-]+$/,gn=3,yn=2,vn=1,bn=10,wn=-2,Rt=e=>e==="*";function xn(e,t){let n=e.split("/"),r=n.length;return n.some(Rt)&&(r+=wn),t&&(r+=yn),n.filter(a=>!Rt(a)).reduce((a,s)=>a+(pn.test(s)?gn:s===""?vn:bn),r)}function En(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function Rn(e,t,n=!1){let{routesMeta:r}=e,a={},s="/",o=[];for(let u=0;u{if(f==="*"){let y=u[p]||"";o=s.slice(0,s.length-y.length).replace(/(.)\/+$/,"$1")}const v=u[p];return h&&!v?d[f]=void 0:d[f]=(v||"").replace(/%2F/g,"/"),d},{}),pathname:s,pathnameBase:o,pattern:e}}function Sn(e,t=!1,n=!0){q(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,u,c,d,f)=>{if(r.push({paramName:u,isOptional:c!=null}),c){let h=f.charAt(d+o.length);return h&&h!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function kn(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return q(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function te(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var Cn=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Nn(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?he(e):e,s;return n?(n=Ft(n),n.startsWith("/")?s=St(n.substring(1),"/"):s=St(n,t)):s=t,{pathname:s,search:Mn(r),hash:An(a)}}function St(e,t){let n=Oe(t).split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function Ge(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function jn(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Bt(e){let t=jn(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function st(e,t,n,r=!1){let a;typeof e=="string"?a=he(e):(a={...e},M(!a.pathname||!a.pathname.includes("?"),Ge("?","pathname","search",a)),M(!a.pathname||!a.pathname.includes("#"),Ge("#","pathname","hash",a)),M(!a.search||!a.search.includes("#"),Ge("#","search","hash",a)));let s=e===""||a.pathname==="",o=s?"/":a.pathname,u;if(o==null)u=n;else{let h=t.length-1;if(!r&&o.startsWith("..")){let p=o.split("/");for(;p[0]==="..";)p.shift(),h-=1;a.pathname=p.join("/")}u=h>=0?t[h]:"/"}let c=Nn(a,u),d=o&&o!=="/"&&o.endsWith("/"),f=(s||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}var Ft=e=>e.replace(/\/\/+/g,"/"),V=e=>Ft(e.join("/")),Oe=e=>e.replace(/\/+$/,""),Tn=e=>Oe(e).replace(/^\/*/,"/"),Mn=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,An=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Pn=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function In(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Ln(e){let t=e.map(n=>n.route.path).filter(Boolean);return V(t)||"/"}var Ot=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Dt(e,t){let n=e;if(typeof n!="string"||!Cn.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(Ot)try{let s=new URL(window.location.href),o=n.startsWith("//")?new URL(s.protocol+n):new URL(n),u=te(o.pathname,t);o.origin===s.origin&&u!=null?n=u+o.search+o.hash:a=!0}catch{q(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Ut=["POST","PUT","PATCH","DELETE"];new Set(Ut);var _n=["GET",...Ut];new Set(_n);var fe=l.createContext(null);fe.displayName="DataRouter";var Ue=l.createContext(null);Ue.displayName="DataRouterState";var Ht=l.createContext(!1);function $n(){return l.useContext(Ht)}var zt=l.createContext({isTransitioning:!1});zt.displayName="ViewTransition";var Bn=l.createContext(new Map);Bn.displayName="Fetchers";var Fn=l.createContext(null);Fn.displayName="Await";var z=l.createContext(null);z.displayName="Navigation";var Se=l.createContext(null);Se.displayName="Location";var ne=l.createContext({outlet:null,matches:[],isDataRoute:!1});ne.displayName="Route";var ot=l.createContext(null);ot.displayName="RouteError";var Wt="REACT_ROUTER_ERROR",On="REDIRECT",Dn="ROUTE_ERROR_RESPONSE";function Un(e){if(e.startsWith(`${Wt}:${On}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function Hn(e){if(e.startsWith(`${Wt}:${Dn}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Pn(t.status,t.statusText,t.data)}catch{}}function zn(e,{relative:t}={}){M(ke(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:r}=l.useContext(z),{hash:a,pathname:s,search:o}=Ne(e,{relative:t}),u=s;return n!=="/"&&(u=s==="/"?n:V([n,s])),r.createHref({pathname:u,search:o,hash:a})}function ke(){return l.useContext(Se)!=null}function re(){return M(ke(),"useLocation() may be used only in the context of a component."),l.useContext(Se).location}var Vt="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Kt(e){l.useContext(z).static||l.useLayoutEffect(e)}function Ce(){let{isDataRoute:e}=l.useContext(ne);return e?nr():Wn()}function Wn(){M(ke(),"useNavigate() may be used only in the context of a component.");let e=l.useContext(fe),{basename:t,navigator:n}=l.useContext(z),{matches:r}=l.useContext(ne),{pathname:a}=re(),s=JSON.stringify(Bt(r)),o=l.useRef(!1);return Kt(()=>{o.current=!0}),l.useCallback((c,d={})=>{if(q(o.current,Vt),!o.current)return;if(typeof c=="number"){n.go(c);return}let f=st(c,JSON.parse(s),a,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:V([t,f.pathname])),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,s,a,e])}l.createContext(null);function Ne(e,{relative:t}={}){let{matches:n}=l.useContext(ne),{pathname:r}=re(),a=JSON.stringify(Bt(n));return l.useMemo(()=>st(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function Vn(e,t){return Jt(e,t)}function Jt(e,t,n){var m;M(ke(),"useRoutes() may be used only in the context of a component.");let{navigator:r}=l.useContext(z),{matches:a}=l.useContext(ne),s=a[a.length-1],o=s?s.params:{},u=s?s.pathname:"/",c=s?s.pathnameBase:"/",d=s&&s.route;{let g=d&&d.path||"";Gt(u,!d||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${u}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. -Please change the parent to .`)}let m=ne(),h;if(t){let v=typeof t=="string"?de(t):t;T(c==="/"||((f=v.pathname)==null?void 0:f.startsWith(c)),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${v.pathname}" was given in the \`location\` prop.`),h=v}else h=m;let p=h.pathname||"/",y=p;if(c!=="/"){let v=c.replace(/^\//,"").split("/");y="/"+p.replace(/^\//,"").split("/").slice(v.length).join("/")}let g=n&&n.state.matches.length?n.state.matches.map(v=>Object.assign(v,{route:n.manifest[v.route.id]||v.route})):It(e,{pathname:y});q(u||g!=null,`No routes matched location "${h.pathname}${h.search}${h.hash}" `),q(g==null||g[g.length-1].route.element!==void 0||g[g.length-1].route.Component!==void 0||g[g.length-1].route.lazy!==void 0,`Matched leaf route at location "${h.pathname}${h.search}${h.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let b=Gn(g&&g.map(v=>Object.assign({},v,{params:Object.assign({},o,v.params),pathname:V([c,r.encodeLocation?r.encodeLocation(v.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?c:V([c,r.encodeLocation?r.encodeLocation(v.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:v.pathnameBase])})),a,n);return t&&b?l.createElement(Re.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...h},navigationType:"POP"}},b):b}function Vn(){let e=er(),t=Pn(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r},s={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",e),o=l.createElement(l.Fragment,null,l.createElement("p",null,"💿 Hey developer 👋"),l.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",l.createElement("code",{style:s},"ErrorBoundary")," or"," ",l.createElement("code",{style:s},"errorElement")," prop on your route.")),l.createElement(l.Fragment,null,l.createElement("h2",null,"Unexpected Application Error!"),l.createElement("h3",{style:{fontStyle:"italic"}},t),n?l.createElement("pre",{style:a},n):null,o)}var Kn=l.createElement(Vn,null),Jt=class extends l.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=Un(e.digest);n&&(e=n)}let t=e!==void 0?l.createElement(te.Provider,{value:this.props.routeContext},l.createElement(st.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?l.createElement(Jn,{error:e},t):t}};Jt.contextType=Ut;var Ge=new WeakMap;function Jn({children:e,error:t}){let{basename:n}=l.useContext(z);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=Dn(t.digest);if(r){let a=Ge.get(t);if(a)throw a;let s=Ot(r.location,n);if(Ft&&!Ge.get(t))if(s.isExternal||r.reloadDocument)window.location.href=s.absoluteURL||s.to;else{const o=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(s.to,{replace:r.replace}));throw Ge.set(t,o),o}return l.createElement("meta",{httpEquiv:"refresh",content:`0;url=${s.absoluteURL||s.to}`})}}return e}function qn({routeContext:e,match:t,children:n}){let r=l.useContext(he);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),l.createElement(te.Provider,{value:e},n)}function Gn(e,t=[],n){let r=n==null?void 0:n.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let a=e,s=r==null?void 0:r.errors;if(s!=null){let m=a.findIndex(h=>h.route.id&&(s==null?void 0:s[h.route.id])!==void 0);T(m>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(s).join(",")}`),a=a.slice(0,Math.min(a.length,m+1))}let o=!1,d=-1;if(n&&r){o=r.renderFallback;for(let m=0;m=0?a=a.slice(0,d+1):a=[a[0]];break}}}}let c=n==null?void 0:n.onError,u=r&&c?(m,h)=>{var p,y;c(m,{location:r.location,params:((y=(p=r.matches)==null?void 0:p[0])==null?void 0:y.params)??{},pattern:In(r.matches),errorInfo:h})}:void 0;return a.reduceRight((m,h,p)=>{let y,g=!1,b=null,f=null;r&&(y=s&&h.route.id?s[h.route.id]:void 0,b=h.route.errorElement||Kn,o&&(d<0&&p===0?(qt("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),g=!0,f=null):d===p&&(g=!0,f=h.route.hydrateFallbackElement||null)));let v=t.concat(a.slice(0,p+1)),x=()=>{let w;return y?w=b:g?w=f:h.route.Component?w=l.createElement(h.route.Component,null):h.route.element?w=h.route.element:w=m,l.createElement(qn,{match:h,routeContext:{outlet:m,matches:v,isDataRoute:r!=null},children:w})};return r&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?l.createElement(Jt,{location:r.location,revalidation:r.revalidation,component:b,error:y,children:x(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:u}):x()},null)}function ot(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Yn(e){let t=l.useContext(he);return T(t,ot(e)),t}function Xn(e){let t=l.useContext(De);return T(t,ot(e)),t}function Qn(e){let t=l.useContext(te);return T(t,ot(e)),t}function it(e){let t=Qn(e),n=t.matches[t.matches.length-1];return T(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Zn(){return it("useRouteId")}function er(){var r;let e=l.useContext(st),t=Xn("useRouteError"),n=it("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function tr(){let{router:e}=Yn("useNavigate"),t=it("useNavigate"),n=l.useRef(!1);return Vt(()=>{n.current=!0}),l.useCallback(async(a,s={})=>{q(n.current,Wt),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...s}))},[e,t])}var St={};function qt(e,t,n){!t&&!St[e]&&(St[e]=!0,q(!1,n))}l.memo(nr);function nr({routes:e,manifest:t,future:n,state:r,isStatic:a,onError:s}){return Kt(e,void 0,{manifest:t,state:r,isStatic:a,onError:s})}function _e(e){T(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function rr({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:s=!1,useTransitions:o}){T(!Se(),"You cannot render a inside another . You should never have more than one in your app.");let d=e.replace(/^\/*/,"/"),c=l.useMemo(()=>({basename:d,navigator:a,static:s,useTransitions:o,future:{}}),[d,a,s,o]);typeof n=="string"&&(n=de(n));let{pathname:u="/",search:m="",hash:h="",state:p=null,key:y="default",mask:g}=n,b=l.useMemo(()=>{let f=ee(u,d);return f==null?null:{location:{pathname:f,search:m,hash:h,state:p,key:y,mask:g},navigationType:r}},[d,u,m,h,p,y,r,g]);return q(b!=null,` is not able to match the URL "${u}${m}${h}" because it does not start with the basename, so the won't render anything.`),b==null?null:l.createElement(z.Provider,{value:c},l.createElement(Re.Provider,{children:t,value:b}))}function ar({children:e,location:t}){return Wn(Ze(e),t)}function Ze(e,t=[]){let n=[];return l.Children.forEach(e,(r,a)=>{if(!l.isValidElement(r))return;let s=[...t,a];if(r.type===l.Fragment){n.push.apply(n,Ze(r.props.children,s));return}T(r.type===_e,`[${typeof r.type=="string"?r.type:r.type.name}] is not a component. All component children of must be a or `),T(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={id:r.props.id||s.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=Ze(r.props.children,s)),n.push(o)}),n}var Le="get",$e="application/x-www-form-urlencoded";function Ue(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function sr(e){return Ue(e)&&e.tagName.toLowerCase()==="button"}function or(e){return Ue(e)&&e.tagName.toLowerCase()==="form"}function ir(e){return Ue(e)&&e.tagName.toLowerCase()==="input"}function lr(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function cr(e,t){return e.button===0&&(!t||t==="_self")&&!lr(e)}var Ae=null;function ur(){if(Ae===null)try{new FormData(document.createElement("form"),0),Ae=!1}catch{Ae=!0}return Ae}var dr=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ye(e){return e!=null&&!dr.has(e)?(q(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${$e}"`),null):e}function hr(e,t){let n,r,a,s,o;if(or(e)){let d=e.getAttribute("action");r=d?ee(d,t):null,n=e.getAttribute("method")||Le,a=Ye(e.getAttribute("enctype"))||$e,s=new FormData(e)}else if(sr(e)||ir(e)&&(e.type==="submit"||e.type==="image")){let d=e.form;if(d==null)throw new Error('Cannot submit a - {busy && ( + {showCancel && ( )} @@ -147,13 +150,19 @@ export default function App() { const abortRef = useRef(null); const handleCancel = useCallback(() => { + isSpaceDownRef.current = false; + // Stop recorder if actively recording + const phase = voicePhaseRef.current; + if (phase === 'listening' || phase === 'acquiring') { + stopRec().catch(() => {}); + } abortRef.current?.abort(); abortRef.current = null; setVoicePhase('idle'); setVoiceStatus(null); setExprId('idle'); scheduleNext(); - }, [scheduleNext]); + }, [scheduleNext, stopRec]); // Load backend mode from server config on mount useEffect(() => { @@ -192,11 +201,20 @@ export default function App() { return; } + // Race condition guard: user released before mic was ready (fast tap) + if (!isSpaceDownRef.current) { + stopRec().catch(() => {}); // discard the just-acquired recording + setVoicePhase('idle'); + setVoiceStatus(null); + scheduleNext(); + return; + } + // Only show "listening" once the mic is actually recording setExprId('listening'); setVoicePhase('listening'); setVoiceStatus({ type: 'listening', text: '🎙 请讲话 · 松开结束' }); - }, [clearAuto, startRec, scheduleNext]); + }, [clearAuto, startRec, stopRec, scheduleNext]); const handleSpaceUp = useCallback(async () => { if (!isSpaceDownRef.current) return; @@ -364,6 +382,33 @@ export default function App() { }; }, [handleSpaceDown, handleSpaceUp, pick]); + // ── Global mouse/touch fallback — catches release outside button boundary ── + useEffect(() => { + const onUp = () => handleSpaceUp(); + window.addEventListener('mouseup', onUp); + window.addEventListener('touchend', onUp, { passive: true }); + window.addEventListener('touchcancel', onUp, { passive: true }); + return () => { + window.removeEventListener('mouseup', onUp); + window.removeEventListener('touchend', onUp); + window.removeEventListener('touchcancel', onUp); + }; + }, [handleSpaceUp]); + + // ── Safety timeout: auto-cancel if stuck in listening > 60 s ── + const recTimerRef = useRef(null); + useEffect(() => { + if (voicePhase === 'listening') { + recTimerRef.current = setTimeout(() => { + console.warn('[PTT] Auto-stop: max recording time reached'); + handleSpaceUp(); + }, 60_000); + } else { + clearTimeout(recTimerRef.current); + } + return () => clearTimeout(recTimerRef.current); + }, [voicePhase, handleSpaceUp]); + // ── Render ───────────────────────────────────────────────── return (