@nextclaw/ui 0.13.10-beta.1 → 0.13.11-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/dist/assets/{api-DhI2lb1f.js → api-C0F4luAh.js} +6 -6
- package/dist/assets/{app-presenter-provider-BFbrQp8q.js → app-presenter-provider-3K24vYTD.js} +2 -2
- package/dist/assets/{channels-list-page-B6CvmU9T.js → channels-list-page-DT8gjnFw.js} +1 -1
- package/dist/assets/{chat-page-Ch4ShlKB.js → chat-page-By1I_JyH.js} +1 -1
- package/dist/assets/{confirm-dialog-DXRWJ5uB.js → confirm-dialog-a7YIzprP.js} +1 -1
- package/dist/assets/{desktop-update-config-DPk5V1Nl.js → desktop-update-config-CbJZyLND.js} +1 -1
- package/dist/assets/{index-DZoXsgdz.js → index-DBOXf-UA.js} +3 -3
- package/dist/assets/mcp-marketplace-page-C2O8-sSE.js +1 -0
- package/dist/assets/{mcp-marketplace-page-WAgpy0hp.js → mcp-marketplace-page-IhNyQ9Hh.js} +1 -1
- package/dist/assets/{model-config-CixioI5U.js → model-config-Z7oAQmlP.js} +1 -1
- package/dist/assets/{notice-card-BLklZuEa.js → notice-card-DhE1Fafy.js} +1 -1
- package/dist/assets/{provider-scoped-model-input-BbWqk2yz.js → provider-scoped-model-input-BfhiS3GD.js} +1 -1
- package/dist/assets/{providers-list-C_JOSjYd.js → providers-list-DpAMol1o.js} +1 -1
- package/dist/assets/remote-hKy7hvBh.js +1 -0
- package/dist/assets/{runtime-config-page-ByvKO6Yn.js → runtime-config-page-BvLypM3f.js} +1 -1
- package/dist/assets/{search-config-Cl2_NgFY.js → search-config-mD9kAsXy.js} +1 -1
- package/dist/assets/{secrets-config-BkR72J4g.js → secrets-config-Dvd4VEDw.js} +1 -1
- package/dist/assets/{tag-chip-Kib_ljle.js → tag-chip-BFTpu75w.js} +1 -1
- package/dist/index.html +5 -5
- package/package.json +8 -8
- package/src/features/panel-apps/components/panel-app-toolbar.test.tsx +24 -0
- package/src/features/panel-apps/components/panel-app-toolbar.tsx +11 -2
- package/src/features/panel-apps/utils/panel-app-doc-browser.utils.tsx +2 -1
- package/src/shared/hooks/use-config.ts +2 -2
- package/src/shared/lib/api/ncp-session-query-cache.utils.test.ts +35 -0
- package/src/shared/lib/api/ncp-session-query-cache.utils.ts +9 -1
- package/src/shared/lib/api/utils/ncp-session.utils.ts +2 -2
- package/vite.config.ts +8 -0
- package/dist/assets/mcp-marketplace-page-9maf_9fL.js +0 -1
- package/dist/assets/remote-qtmzkte2.js +0 -1
package/dist/assets/{app-presenter-provider-BFbrQp8q.js → app-presenter-provider-3K24vYTD.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{d as e,g as t,i as n,m as r,n as i,o as a,s as o,t as s,y as c}from"./react-Bl8iJUcF.js";import{At as l,Bt as u,Dt as d,Et as f,Ft as p,Lt as m,Mt as h,Nt as g,Ot as _,Pt as v,Qt as y,Vt as b,a as ee,c as te,ct as x,i as ne,jt as re,kt as ie,l as ae,o as oe,pt as se,r as ce,s as le,u as ue,wt as S,zt as C}from"./api-DhI2lb1f.js";import{c as w}from"./dist-T6rf86Nf.js";import{a as de,i as fe,n as pe,o as me,r as he,s as ge,t as _e}from"./confirm-dialog-DXRWJ5uB.js";import{t as ve}from"./arrow-left-CI0Ocu9p.js";import{n as ye,t as be}from"./loader-circle-_edjOFsw.js";import{i as xe,n as Se,r as Ce,t as we,u as Te}from"./tooltip-fs7VQG7d.js";import{t as Ee}from"./key-round-BpM3GZn4.js";import{t as De}from"./plus-zZ2GC_AJ.js";import{t as Oe}from"./refresh-cw-CqfS1EhK.js";import{t as ke}from"./trash-2-Bb8mTTLl.js";import{t as Ae}from"./x-BV4iiea8.js";import{t as T}from"./notice-card-BLklZuEa.js";import{t as je}from"./status-dot-DY0xUUvK.js";import{n as Me,r as Ne,t as Pe}from"./popover-D_pJfOlM.js";import{i as E,r as Fe,t as Ie}from"./tabs-C77i1w90.js";import{a as D,c as Le,f as O,g as Re,h as k,i as ze,l as Be,m as Ve,n as He,o as Ue,p as We,r as Ge,s as Ke,u as qe}from"./doc-browser-context-CP2tI-Br.js";var Je=`modulepreload`,Ye=function(e){return`/`+e},Xe={},Ze=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Ye(t,n),t in Xe)return;Xe[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Je,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},A=c(t(),1),Qe=`popstate`;function $e(e={}){let{initialEntries:t=[`/`],initialIndex:n,v5Compat:r=!1}=e,i;i=t.map((e,t)=>u(e,typeof e==`string`?null:e.state,t===0?`default`:void 0));let a=c(n??i.length-1),o=`POP`,s=null;function c(e){return Math.min(Math.max(e,0),i.length-1)}function l(){return i[a]}function u(e,t=null,n){let r=rt(i?l().pathname:`/`,e,t,n);return M(r.pathname.charAt(0)===`/`,`relative pathnames are not supported in memory history: ${JSON.stringify(e)}`),r}function d(e){return typeof e==`string`?e:N(e)}return{get index(){return a},get action(){return o},get location(){return l()},createHref:d,createURL(e){return new URL(d(e),`http://localhost`)},encodeLocation(e){let t=typeof e==`string`?P(e):e;return{pathname:t.pathname||``,search:t.search||``,hash:t.hash||``}},push(e,t){o=`PUSH`;let n=u(e,t);a+=1,i.splice(a,i.length,n),r&&s&&s({action:o,location:n,delta:1})},replace(e,t){o=`REPLACE`;let n=u(e,t);i[a]=n,r&&s&&s({action:o,location:n,delta:0})},go(e){o=`POP`;let t=c(a+e),n=i[t];a=t,s&&s({action:o,location:n,delta:e})},listen(e){return s=e,()=>{s=null}}}}function et(e={}){function t(e,t){let{pathname:n,search:r,hash:i}=e.location;return rt(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){return typeof t==`string`?t:N(t)}return it(t,n,null,e)}function j(e,t){if(e===!1||e==null)throw Error(t)}function M(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function tt(){return Math.random().toString(36).substring(2,10)}function nt(e,t){return{usr:e.state,key:e.key,idx:t}}function rt(e,t,n=null,r){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?P(t):t,state:n,key:t&&t.key||r||tt()}}function N({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 P(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 it(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=rt(h.location,e,t);n&&n(r,e),l=u()+1;let d=nt(r,l),f=h.createHref(r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=rt(h.location,e,t);n&&n(r,e),l=u();let i=nt(r,l),d=h.createHref(r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return at(e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(Qe,d),c=e,()=>{i.removeEventListener(Qe,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function at(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),j(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:N(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function ot(e,t,n=`/`){return st(e,t,n,!1)}function st(e,t,n,r){let i=F((typeof t==`string`?P(t):t).pathname||`/`,n);if(i==null)return null;let a=lt(e);dt(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=wt(i);o=xt(a[e],t,r)}return o}function ct(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function lt(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;j(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=I([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(j(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),lt(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:yt(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of ut(e.path))a(e,t,!0,n)}),t}function ut(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=ut(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function dt(e){e.sort((e,t)=>e.score===t.score?bt(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var ft=/^:[\w-]+$/,pt=3,mt=2,ht=1,gt=10,_t=-2,vt=e=>e===`*`;function yt(e,t){let n=e.split(`/`),r=n.length;return n.some(vt)&&(r+=_t),t&&(r+=mt),n.filter(e=>!vt(e)).reduce((e,t)=>e+(ft.test(t)?pt:t===``?ht:gt),r)}function bt(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function xt(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=St({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=St({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:I([a,u.pathname]),pathnameBase:Mt(I([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=I([a,u.pathnameBase]))}return o}function St(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Ct(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function Ct(e,t=!1,n=!0){M(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=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n)=>(r.push({paramName:t,isOptional:n!=null}),n?`/?([^\\/]+)?`:`/([^\\/]+)`)).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function wt(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return M(!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 F(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 Tt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Et(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?P(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?Dt(n.substring(1),`/`):Dt(n,t)):a=t,{pathname:a,search:Nt(r),hash:Pt(i)}}function Dt(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Ot(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 <Link to="..."> and the router will parse it for you.`}function kt(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function At(e){let t=kt(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function jt(e,t,n,r=!1){let i;typeof e==`string`?i=P(e):(i={...e},j(!i.pathname||!i.pathname.includes(`?`),Ot(`?`,`pathname`,`search`,i)),j(!i.pathname||!i.pathname.includes(`#`),Ot(`#`,`pathname`,`hash`,i)),j(!i.search||!i.search.includes(`#`),Ot(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=Et(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var I=e=>e.join(`/`).replace(/\/\/+/g,`/`),Mt=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),Nt=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Pt=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,Ft=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 It(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Lt(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var Rt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function zt(e,t){let n=e;if(typeof n!=`string`||!Tt.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Rt)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=F(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{M(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Bt=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Bt);var Vt=[`GET`,...Bt];new Set(Vt);var L=A.createContext(null);L.displayName=`DataRouter`;var Ht=A.createContext(null);Ht.displayName=`DataRouterState`;var Ut=A.createContext(!1),Wt=A.createContext({isTransitioning:!1});Wt.displayName=`ViewTransition`;var Gt=A.createContext(new Map);Gt.displayName=`Fetchers`;var Kt=A.createContext(null);Kt.displayName=`Await`;var R=A.createContext(null);R.displayName=`Navigation`;var qt=A.createContext(null);qt.displayName=`Location`;var z=A.createContext({outlet:null,matches:[],isDataRoute:!1});z.displayName=`Route`;var Jt=A.createContext(null);Jt.displayName=`RouteError`;var Yt=`REACT_ROUTER_ERROR`,Xt=`REDIRECT`,Zt=`ROUTE_ERROR_RESPONSE`;function Qt(e){if(e.startsWith(`${Yt}:${Xt}:{`))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 $t(e){if(e.startsWith(`${Yt}:${Zt}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new Ft(t.status,t.statusText,t.data)}catch{}}function en(e,{relative:t}={}){j(B(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=A.useContext(R),{hash:i,pathname:a,search:o}=sn(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:I([n,a])),r.createHref({pathname:s,search:o,hash:i})}function B(){return A.useContext(qt)!=null}function V(){return j(B(),`useLocation() may be used only in the context of a <Router> component.`),A.useContext(qt).location}var tn=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function nn(e){A.useContext(R).static||A.useLayoutEffect(e)}function rn(){let{isDataRoute:e}=A.useContext(z);return e?En():an()}function an(){j(B(),`useNavigate() may be used only in the context of a <Router> component.`);let e=A.useContext(L),{basename:t,navigator:n}=A.useContext(R),{matches:r}=A.useContext(z),{pathname:i}=V(),a=JSON.stringify(At(r)),o=A.useRef(!1);return nn(()=>{o.current=!0}),A.useCallback((r,s={})=>{if(M(o.current,tn),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=jt(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:I([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}A.createContext(null);function on(){let{matches:e}=A.useContext(z),t=e[e.length-1];return t?t.params:{}}function sn(e,{relative:t}={}){let{matches:n}=A.useContext(z),{pathname:r}=V(),i=JSON.stringify(At(n));return A.useMemo(()=>jt(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function cn(e,t){return ln(e,t)}function ln(e,t,n,r,i){j(B(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:a}=A.useContext(R),{matches:o}=A.useContext(z),s=o[o.length-1],c=s?s.params:{},l=s?s.pathname:`/`,u=s?s.pathnameBase:`/`,d=s&&s.route;{let e=d&&d.path||``;On(l,!d||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${e}">) 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.
|
|
1
|
+
import{d as e,g as t,i as n,m as r,n as i,o as a,s as o,t as s,y as c}from"./react-Bl8iJUcF.js";import{At as l,Bt as u,Dt as d,Et as f,Ft as p,Lt as m,Mt as h,Nt as g,Ot as _,Pt as v,Qt as y,Vt as b,a as ee,c as te,ct as x,i as ne,jt as re,kt as ie,l as ae,o as oe,pt as se,r as ce,s as le,u as ue,wt as S,zt as C}from"./api-C0F4luAh.js";import{c as w}from"./dist-T6rf86Nf.js";import{a as de,i as fe,n as pe,o as me,r as he,s as ge,t as _e}from"./confirm-dialog-a7YIzprP.js";import{t as ve}from"./arrow-left-CI0Ocu9p.js";import{n as ye,t as be}from"./loader-circle-_edjOFsw.js";import{i as xe,n as Se,r as Ce,t as we,u as Te}from"./tooltip-fs7VQG7d.js";import{t as Ee}from"./key-round-BpM3GZn4.js";import{t as De}from"./plus-zZ2GC_AJ.js";import{t as Oe}from"./refresh-cw-CqfS1EhK.js";import{t as ke}from"./trash-2-Bb8mTTLl.js";import{t as Ae}from"./x-BV4iiea8.js";import{t as T}from"./notice-card-DhE1Fafy.js";import{t as je}from"./status-dot-DY0xUUvK.js";import{n as Me,r as Ne,t as Pe}from"./popover-D_pJfOlM.js";import{i as E,r as Fe,t as Ie}from"./tabs-C77i1w90.js";import{a as D,c as Le,f as O,g as Re,h as k,i as ze,l as Be,m as Ve,n as He,o as Ue,p as We,r as Ge,s as Ke,u as qe}from"./doc-browser-context-CP2tI-Br.js";var Je=`modulepreload`,Ye=function(e){return`/`+e},Xe={},Ze=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Ye(t,n),t in Xe)return;Xe[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Je,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},A=c(t(),1),Qe=`popstate`;function $e(e={}){let{initialEntries:t=[`/`],initialIndex:n,v5Compat:r=!1}=e,i;i=t.map((e,t)=>u(e,typeof e==`string`?null:e.state,t===0?`default`:void 0));let a=c(n??i.length-1),o=`POP`,s=null;function c(e){return Math.min(Math.max(e,0),i.length-1)}function l(){return i[a]}function u(e,t=null,n){let r=rt(i?l().pathname:`/`,e,t,n);return M(r.pathname.charAt(0)===`/`,`relative pathnames are not supported in memory history: ${JSON.stringify(e)}`),r}function d(e){return typeof e==`string`?e:N(e)}return{get index(){return a},get action(){return o},get location(){return l()},createHref:d,createURL(e){return new URL(d(e),`http://localhost`)},encodeLocation(e){let t=typeof e==`string`?P(e):e;return{pathname:t.pathname||``,search:t.search||``,hash:t.hash||``}},push(e,t){o=`PUSH`;let n=u(e,t);a+=1,i.splice(a,i.length,n),r&&s&&s({action:o,location:n,delta:1})},replace(e,t){o=`REPLACE`;let n=u(e,t);i[a]=n,r&&s&&s({action:o,location:n,delta:0})},go(e){o=`POP`;let t=c(a+e),n=i[t];a=t,s&&s({action:o,location:n,delta:e})},listen(e){return s=e,()=>{s=null}}}}function et(e={}){function t(e,t){let{pathname:n,search:r,hash:i}=e.location;return rt(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){return typeof t==`string`?t:N(t)}return it(t,n,null,e)}function j(e,t){if(e===!1||e==null)throw Error(t)}function M(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function tt(){return Math.random().toString(36).substring(2,10)}function nt(e,t){return{usr:e.state,key:e.key,idx:t}}function rt(e,t,n=null,r){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?P(t):t,state:n,key:t&&t.key||r||tt()}}function N({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 P(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 it(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=rt(h.location,e,t);n&&n(r,e),l=u()+1;let d=nt(r,l),f=h.createHref(r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=rt(h.location,e,t);n&&n(r,e),l=u();let i=nt(r,l),d=h.createHref(r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return at(e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(Qe,d),c=e,()=>{i.removeEventListener(Qe,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function at(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),j(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:N(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function ot(e,t,n=`/`){return st(e,t,n,!1)}function st(e,t,n,r){let i=F((typeof t==`string`?P(t):t).pathname||`/`,n);if(i==null)return null;let a=lt(e);dt(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=wt(i);o=xt(a[e],t,r)}return o}function ct(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function lt(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;j(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=I([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(j(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),lt(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:yt(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of ut(e.path))a(e,t,!0,n)}),t}function ut(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=ut(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function dt(e){e.sort((e,t)=>e.score===t.score?bt(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var ft=/^:[\w-]+$/,pt=3,mt=2,ht=1,gt=10,_t=-2,vt=e=>e===`*`;function yt(e,t){let n=e.split(`/`),r=n.length;return n.some(vt)&&(r+=_t),t&&(r+=mt),n.filter(e=>!vt(e)).reduce((e,t)=>e+(ft.test(t)?pt:t===``?ht:gt),r)}function bt(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function xt(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=St({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=St({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:I([a,u.pathname]),pathnameBase:Mt(I([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=I([a,u.pathnameBase]))}return o}function St(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Ct(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function Ct(e,t=!1,n=!0){M(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=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n)=>(r.push({paramName:t,isOptional:n!=null}),n?`/?([^\\/]+)?`:`/([^\\/]+)`)).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function wt(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return M(!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 F(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 Tt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Et(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?P(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?Dt(n.substring(1),`/`):Dt(n,t)):a=t,{pathname:a,search:Nt(r),hash:Pt(i)}}function Dt(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Ot(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 <Link to="..."> and the router will parse it for you.`}function kt(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function At(e){let t=kt(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function jt(e,t,n,r=!1){let i;typeof e==`string`?i=P(e):(i={...e},j(!i.pathname||!i.pathname.includes(`?`),Ot(`?`,`pathname`,`search`,i)),j(!i.pathname||!i.pathname.includes(`#`),Ot(`#`,`pathname`,`hash`,i)),j(!i.search||!i.search.includes(`#`),Ot(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=Et(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var I=e=>e.join(`/`).replace(/\/\/+/g,`/`),Mt=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),Nt=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Pt=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,Ft=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 It(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Lt(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var Rt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function zt(e,t){let n=e;if(typeof n!=`string`||!Tt.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Rt)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=F(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{M(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Bt=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Bt);var Vt=[`GET`,...Bt];new Set(Vt);var L=A.createContext(null);L.displayName=`DataRouter`;var Ht=A.createContext(null);Ht.displayName=`DataRouterState`;var Ut=A.createContext(!1),Wt=A.createContext({isTransitioning:!1});Wt.displayName=`ViewTransition`;var Gt=A.createContext(new Map);Gt.displayName=`Fetchers`;var Kt=A.createContext(null);Kt.displayName=`Await`;var R=A.createContext(null);R.displayName=`Navigation`;var qt=A.createContext(null);qt.displayName=`Location`;var z=A.createContext({outlet:null,matches:[],isDataRoute:!1});z.displayName=`Route`;var Jt=A.createContext(null);Jt.displayName=`RouteError`;var Yt=`REACT_ROUTER_ERROR`,Xt=`REDIRECT`,Zt=`ROUTE_ERROR_RESPONSE`;function Qt(e){if(e.startsWith(`${Yt}:${Xt}:{`))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 $t(e){if(e.startsWith(`${Yt}:${Zt}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new Ft(t.status,t.statusText,t.data)}catch{}}function en(e,{relative:t}={}){j(B(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=A.useContext(R),{hash:i,pathname:a,search:o}=sn(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:I([n,a])),r.createHref({pathname:s,search:o,hash:i})}function B(){return A.useContext(qt)!=null}function V(){return j(B(),`useLocation() may be used only in the context of a <Router> component.`),A.useContext(qt).location}var tn=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function nn(e){A.useContext(R).static||A.useLayoutEffect(e)}function rn(){let{isDataRoute:e}=A.useContext(z);return e?En():an()}function an(){j(B(),`useNavigate() may be used only in the context of a <Router> component.`);let e=A.useContext(L),{basename:t,navigator:n}=A.useContext(R),{matches:r}=A.useContext(z),{pathname:i}=V(),a=JSON.stringify(At(r)),o=A.useRef(!1);return nn(()=>{o.current=!0}),A.useCallback((r,s={})=>{if(M(o.current,tn),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=jt(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:I([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}A.createContext(null);function on(){let{matches:e}=A.useContext(z),t=e[e.length-1];return t?t.params:{}}function sn(e,{relative:t}={}){let{matches:n}=A.useContext(z),{pathname:r}=V(),i=JSON.stringify(At(n));return A.useMemo(()=>jt(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function cn(e,t){return ln(e,t)}function ln(e,t,n,r,i){j(B(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:a}=A.useContext(R),{matches:o}=A.useContext(z),s=o[o.length-1],c=s?s.params:{},l=s?s.pathname:`/`,u=s?s.pathnameBase:`/`,d=s&&s.route;{let e=d&&d.path||``;On(l,!d||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${e}">) 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.
|
|
2
2
|
|
|
3
|
-
Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let f=V(),p;if(t){let e=typeof t==`string`?P(t):t;j(u===`/`||e.pathname?.startsWith(u),`When overriding the location using \`<Routes location>\` 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 "${u}" but pathname "${e.pathname}" was given in the \`location\` prop.`),p=e}else p=f;let m=p.pathname||`/`,h=m;if(u!==`/`){let e=u.replace(/^\//,``).split(`/`);h=`/`+m.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let g=ot(e,{pathname:h});M(d||g!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),M(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 "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let _=gn(g&&g.map(e=>Object.assign({},e,{params:Object.assign({},c,e.params),pathname:I([u,a.encodeLocation?a.encodeLocation(e.pathname.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?u:I([u,a.encodeLocation?a.encodeLocation(e.pathnameBase.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),o,n,r,i);return t&&_?A.createElement(qt.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,...p},navigationType:`POP`}},_):_}function un(){let e=Tn(),t=It(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)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=A.createElement(A.Fragment,null,A.createElement(`p`,null,`💿 Hey developer 👋`),A.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,A.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,A.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),A.createElement(A.Fragment,null,A.createElement(`h2`,null,`Unexpected Application Error!`),A.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?A.createElement(`pre`,{style:i},n):null,o)}var dn=A.createElement(un,null),fn=class extends A.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?t.error:e.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`){let t=$t(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:A.createElement(z.Provider,{value:this.props.routeContext},A.createElement(Jt.Provider,{value:e,children:this.props.component}));return this.context?A.createElement(mn,{error:e},t):t}};fn.contextType=Ut;var pn=new WeakMap;function mn({children:e,error:t}){let{basename:n}=A.useContext(R);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=Qt(t.digest);if(e){let r=pn.get(t);if(r)throw r;let i=zt(e.location,n);if(Rt&&!pn.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw pn.set(t,n),n}return A.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function hn({routeContext:e,match:t,children:n}){let r=A.useContext(L);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),A.createElement(z.Provider,{value:e},n)}function gn(e,t=[],n=null,r=null,i=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,o=n?.errors;if(o!=null){let e=a.findIndex(e=>e.route.id&&o?.[e.route.id]!==void 0);j(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(`,`)}`),a=a.slice(0,Math.min(a.length,e+1))}let s=!1,c=-1;if(n)for(let e=0;e<a.length;e++){let t=a[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(c=e),t.route.id){let{loaderData:e,errors:r}=n,i=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!r||r[t.route.id]===void 0);if(t.route.lazy||i){s=!0,a=c>=0?a.slice(0,c+1):[a[0]];break}}}let l=n&&r?(e,t)=>{r(e,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:Lt(n.matches),errorInfo:t})}:void 0;return a.reduceRight((e,r,i)=>{let u,d=!1,f=null,p=null;n&&(u=o&&r.route.id?o[r.route.id]:void 0,f=r.route.errorElement||dn,s&&(c<0&&i===0?(On(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):c===i&&(d=!0,p=r.route.hydrateFallbackElement||null)));let m=t.concat(a.slice(0,i+1)),h=()=>{let t;return t=u?f:d?p:r.route.Component?A.createElement(r.route.Component,null):r.route.element?r.route.element:e,A.createElement(hn,{match:r,routeContext:{outlet:e,matches:m,isDataRoute:n!=null},children:t})};return n&&(r.route.ErrorBoundary||r.route.errorElement||i===0)?A.createElement(fn,{location:n.location,revalidation:n.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function _n(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function vn(e){let t=A.useContext(L);return j(t,_n(e)),t}function yn(e){let t=A.useContext(Ht);return j(t,_n(e)),t}function bn(e){let t=A.useContext(z);return j(t,_n(e)),t}function xn(e){let t=bn(e),n=t.matches[t.matches.length-1];return j(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Sn(){return xn(`useRouteId`)}function Cn(){return yn(`useNavigation`).navigation}function wn(){let{matches:e,loaderData:t}=yn(`useMatches`);return A.useMemo(()=>e.map(e=>ct(e,t)),[e,t])}function Tn(){let e=A.useContext(Jt),t=yn(`useRouteError`),n=xn(`useRouteError`);return e===void 0?t.errors?.[n]:e}function En(){let{router:e}=vn(`useNavigate`),t=xn(`useNavigate`),n=A.useRef(!1);return nn(()=>{n.current=!0}),A.useCallback(async(r,i={})=>{M(n.current,tn),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var Dn={};function On(e,t,n){!t&&!Dn[e]&&(Dn[e]=!0,M(!1,n))}A.useOptimistic,A.memo(kn);function kn({routes:e,future:t,state:n,onError:r}){return ln(e,void 0,n,r,t)}function An({basename:e,children:t,initialEntries:n,initialIndex:r,unstable_useTransitions:i}){let a=A.useRef();a.current??=$e({initialEntries:n,initialIndex:r,v5Compat:!0});let o=a.current,[s,c]=A.useState({action:o.action,location:o.location}),l=A.useCallback(e=>{i===!1?c(e):A.startTransition(()=>c(e))},[i]);return A.useLayoutEffect(()=>o.listen(l),[o,l]),A.createElement(Nn,{basename:e,children:t,location:s.location,navigationType:s.action,navigator:o,unstable_useTransitions:i})}function jn({to:e,replace:t,state:n,relative:r}){j(B(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=A.useContext(R);M(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=A.useContext(z),{pathname:o}=V(),s=rn(),c=jt(e,At(a),o,r===`path`),l=JSON.stringify(c);return A.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function Mn(e){j(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function Nn({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:o}){j(!B(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=A.useMemo(()=>({basename:s,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=P(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`}=n,m=A.useMemo(()=>{let e=F(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p},navigationType:r}},[s,l,u,d,f,p,r]);return M(m!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),m==null?null:A.createElement(R.Provider,{value:c},A.createElement(qt.Provider,{children:t,value:m}))}function Pn({children:e,location:t}){return cn(Fn(e),t)}A.Component;function Fn(e,t=[]){let n=[];return A.Children.forEach(e,(e,r)=>{if(!A.isValidElement(e))return;let i=[...t,r];if(e.type===A.Fragment){n.push.apply(n,Fn(e.props.children,i));return}j(e.type===Mn,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),j(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=Fn(e.props.children,i)),n.push(a)}),n}var In=`get`,Ln=`application/x-www-form-urlencoded`;function Rn(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function zn(e){return Rn(e)&&e.tagName.toLowerCase()===`button`}function Bn(e){return Rn(e)&&e.tagName.toLowerCase()===`form`}function Vn(e){return Rn(e)&&e.tagName.toLowerCase()===`input`}function Hn(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Un(e,t){return e.button===0&&(!t||t===`_self`)&&!Hn(e)}var Wn=null;function Gn(){if(Wn===null)try{new FormData(document.createElement(`form`),0),Wn=!1}catch{Wn=!0}return Wn}var Kn=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function qn(e){return e!=null&&!Kn.has(e)?(M(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ln}"`),null):e}function Jn(e,t){let n,r,i,a,o;if(Bn(e)){let o=e.getAttribute(`action`);r=o?F(o,t):null,n=e.getAttribute(`method`)||In,i=qn(e.getAttribute(`enctype`))||Ln,a=new FormData(e)}else if(zn(e)||Vn(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?F(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||In,i=qn(e.getAttribute(`formenctype`))||qn(o.getAttribute(`enctype`))||Ln,a=new FormData(o,e),!Gn()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(Rn(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=In,r=null,i=Ln,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Yn={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},Xn=/[&><\u2028\u2029]/g;function Zn(e){return e.replace(Xn,e=>Yn[e])}function Qn(e,t){if(e===!1||e==null)throw Error(t)}function $n(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&F(i.pathname,t)===`/`?i.pathname=`${t.replace(/\/$/,``)}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,``)}.${r}`,i}async function er(e,t){if(e.id in t)return t[e.id];try{let n=await Ze(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function tr(e){return e!=null&&typeof e.page==`string`}function nr(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function rr(e,t,n){return cr((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await er(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(nr).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function ir(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function ar(e,t,{includeHydrateFallback:n}={}){return or(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function or(e){return[...new Set(e)]}function sr(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function cr(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!tr(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(sr(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function lr(){let e=A.useContext(L);return Qn(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function ur(){let e=A.useContext(Ht);return Qn(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var dr=A.createContext(void 0);dr.displayName=`FrameworkContext`;function fr(){let e=A.useContext(dr);return Qn(e,`You must render this element inside a <HydratedRouter> element`),e}function pr(e,t){let n=A.useContext(dr),[r,i]=A.useState(!1),[a,o]=A.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=A.useRef(null);A.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),A.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:mr(s,p),onBlur:mr(c,m),onMouseEnter:mr(l,p),onMouseLeave:mr(u,m),onTouchStart:mr(d,p)}]:[a,f,{}]:[!1,f,{}]}function mr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function hr({page:e,...t}){let{router:n}=lr(),r=A.useMemo(()=>ot(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?A.createElement(_r,{page:e,matches:r,...t}):null}function gr(e){let{manifest:t,routeModules:n}=fr(),[r,i]=A.useState([]);return A.useEffect(()=>{let r=!1;return rr(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function _r({page:e,matches:t,...n}){let r=V(),{future:i,manifest:a,routeModules:o}=fr(),{basename:s}=lr(),{loaderData:c,matches:l}=ur(),u=A.useMemo(()=>ir(e,t,l,a,r,`data`),[e,t,l,a,r]),d=A.useMemo(()=>ir(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=A.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=$n(e,s,i.unstable_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.unstable_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=A.useMemo(()=>ar(d,a),[d,a]),m=gr(d);return A.createElement(A.Fragment,null,f.map(e=>A.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>A.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>A.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function vr(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}A.Component;var yr=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{yr&&(window.__reactRouterVersion=`7.13.0`)}catch{}function br({basename:e,children:t,unstable_useTransitions:n,window:r}){let i=A.useRef();i.current??=et({window:r,v5Compat:!0});let a=i.current,[o,s]=A.useState({action:a.action,location:a.location}),c=A.useCallback(e=>{n===!1?s(e):A.startTransition(()=>s(e))},[n]);return A.useLayoutEffect(()=>a.listen(c),[a,c]),A.createElement(Nn,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}function xr({basename:e,children:t,history:n,unstable_useTransitions:r}){let[i,a]=A.useState({action:n.action,location:n.location}),o=A.useCallback(e=>{r===!1?a(e):A.startTransition(()=>a(e))},[r]);return A.useLayoutEffect(()=>n.listen(o),[n,o]),A.createElement(Nn,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,unstable_useTransitions:r})}xr.displayName=`unstable_HistoryRouter`;var Sr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Cr=A.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,state:o,target:s,to:c,preventScrollReset:l,viewTransition:u,unstable_defaultShouldRevalidate:d,...f},p){let{basename:m,unstable_useTransitions:h}=A.useContext(R),g=typeof c==`string`&&Sr.test(c),_=zt(c,m);c=_.to;let v=en(c,{relative:r}),[y,b,ee]=pr(n,f),te=Ar(c,{replace:a,state:o,target:s,preventScrollReset:l,relative:r,viewTransition:u,unstable_defaultShouldRevalidate:d,unstable_useTransitions:h});function x(t){e&&e(t),t.defaultPrevented||te(t)}let ne=A.createElement(`a`,{...f,...ee,href:_.absoluteURL||v,onClick:_.isExternal||i?e:x,ref:vr(p,b),target:s,"data-discover":!g&&t===`render`?`true`:void 0});return y&&!g?A.createElement(A.Fragment,null,ne,A.createElement(hr,{page:v})):ne});Cr.displayName=`Link`;var wr=A.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=sn(a,{relative:c.relative}),d=V(),f=A.useContext(Ht),{navigator:p,basename:m}=A.useContext(R),h=f!=null&&Br(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,_=d.pathname,v=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(_=_.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&m&&(v=F(v,m)||v);let y=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,b=_===g||!r&&_.startsWith(g)&&_.charAt(y)===`/`,ee=v!=null&&(v===g||!r&&v.startsWith(g)&&v.charAt(g.length)===`/`),te={isActive:b,isPending:ee,isTransitioning:h},x=b?e:void 0,ne;ne=typeof n==`function`?n(te):[n,b?`active`:null,ee?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let re=typeof i==`function`?i(te):i;return A.createElement(Cr,{...c,"aria-current":x,className:ne,ref:l,style:re,to:a,viewTransition:o},typeof s==`function`?s(te):s)});wr.displayName=`NavLink`;var Tr=A.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=In,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m)=>{let{unstable_useTransitions:h}=A.useContext(R),g=Nr(),_=Pr(s,{relative:l}),v=o.toLowerCase()===`get`?`get`:`post`,y=typeof s==`string`&&Sr.test(s);return A.createElement(`form`,{ref:m,method:v,action:_,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f});h&&n!==!1?A.startTransition(()=>p()):p()},...p,"data-discover":!y&&e===`render`?`true`:void 0})});Tr.displayName=`Form`;function Er({getKey:e,storageKey:t,...n}){let r=A.useContext(dr),{basename:i}=A.useContext(R),a=V(),o=wn();Rr({getKey:e,storageKey:t});let s=A.useMemo(()=>{if(!r||!e)return null;let t=Lr(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let c=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return A.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${Zn(JSON.stringify(t||Fr))}, ${Zn(JSON.stringify(s))})`}})}Er.displayName=`ScrollRestoration`;function Dr(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Or(e){let t=A.useContext(L);return j(t,Dr(e)),t}function kr(e){let t=A.useContext(Ht);return j(t,Dr(e)),t}function Ar(e,{target:t,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:s,unstable_useTransitions:c}={}){let l=rn(),u=V(),d=sn(e,{relative:a});return A.useCallback(f=>{if(Un(f,t)){f.preventDefault();let t=n===void 0?N(u)===N(d):n,p=()=>l(e,{replace:t,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:s});c?A.startTransition(()=>p()):p()}},[u,l,d,n,r,t,e,i,a,o,s,c])}var jr=0,Mr=()=>`__${String(++jr)}__`;function Nr(){let{router:e}=Or(`useSubmit`),{basename:t}=A.useContext(R),n=Sn(),r=e.fetch,i=e.navigate;return A.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=Jn(e,t);a.navigate===!1?await r(a.fetcherKey||Mr(),n,a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function Pr(e,{relative:t}={}){let{basename:n}=A.useContext(R),r=A.useContext(z);j(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...sn(e||`.`,{relative:t})},o=V();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:I([n,a.pathname])),N(a)}var Fr=`react-router-scroll-positions`,Ir={};function Lr(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:F(e.pathname,n)||e.pathname},t)),i??=e.key,i}function Rr({getKey:e,storageKey:t}={}){let{router:n}=Or(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=kr(`useScrollRestoration`),{basename:a}=A.useContext(R),o=V(),s=wn(),c=Cn();A.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),zr(A.useCallback(()=>{if(c.state===`idle`){let t=Lr(o,s,a,e);Ir[t]=window.scrollY}try{sessionStorage.setItem(t||Fr,JSON.stringify(Ir))}catch(e){M(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(A.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||Fr);e&&(Ir=JSON.parse(e))}catch{}},[t]),A.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(Ir,()=>window.scrollY,e?(t,n)=>Lr(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),A.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{M(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function zr(e,t){let{capture:n}=t||{};A.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function Br(e,{relative:t}={}){let n=A.useContext(Wt);j(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Or(`useViewTransitionState`),i=sn(e,{relative:t});if(!n.isTransitioning)return!1;let a=F(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=F(n.nextLocation.pathname,r)||n.nextLocation.pathname;return St(i.pathname,o)!=null||St(i.pathname,a)!=null}var Vr=w(`AppWindow`,[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]),Hr=w(`BrainCircuit`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M9 13a4.5 4.5 0 0 0 3-4`,key:`10igwf`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M12 13h4`,key:`1ku699`}],[`path`,{d:`M12 18h6a2 2 0 0 1 2 2v1`,key:`105ag5`}],[`path`,{d:`M12 8h8`,key:`1lhi5i`}],[`path`,{d:`M16 8V5a2 2 0 0 1 2-2`,key:`u6izg6`}],[`circle`,{cx:`16`,cy:`13`,r:`.5`,key:`ry7gng`}],[`circle`,{cx:`18`,cy:`3`,r:`.5`,key:`1aiba7`}],[`circle`,{cx:`20`,cy:`21`,r:`.5`,key:`yhc1fs`}],[`circle`,{cx:`20`,cy:`8`,r:`.5`,key:`1e43v0`}]]),Ur=w(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Wr=w(`CircleDashed`,[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]),Gr=w(`CircleHelp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Kr=w(`CirclePause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),qr=w(`EllipsisVertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Jr=w(`Grid3x3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),Yr=w(`Laptop`,[[`path`,{d:`M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16`,key:`tarvll`}]]),Xr=w(`LogOut`,[[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}],[`polyline`,{points:`16 17 21 12 16 7`,key:`1gabdz`}],[`line`,{x1:`21`,x2:`9`,y1:`12`,y2:`12`,key:`1uyos4`}]]),Zr=w(`Radar`,[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`,key:`z3du51`}],[`path`,{d:`M4 6h.01`,key:`oypzma`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`,key:`qzzz0`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`,key:`1yjesh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`,key:`1u2y91`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`m13.41 10.59 5.66-5.66`,key:`mhq4k0`}]]),Qr=w(`RefreshCcw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),$r=w(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),ei=w(`ShieldAlert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),ti=w(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ni=w(`SquareArrowOutUpRight`,[[`path`,{d:`M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6`,key:`y09zxi`}],[`path`,{d:`m21 3-9 9`,key:`mpx6sq`}],[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}]]),ri=w(`Star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),ii=w(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),ai=w(`Unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),oi=w(`Wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`,key:`cbrjhi`}]]);function si(){return b({queryKey:li,queryFn:ee,staleTime:5e3,refetchOnWindowFocus:!0})}var H=r();function U(e){let{label:t,muted:n,value:r}=e;return(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,H.jsx)(`span`,{className:`text-gray-500`,children:t}),(0,H.jsx)(`span`,{className:n?`text-right text-gray-500`:`text-right text-gray-900`,children:r==null||r===``?`-`:String(r)})]})}function ci(){let e=es(),t=si(),r=t.data,a=K(e=>e.actionLabel),o=(0,A.useMemo)(()=>bi(r),[r]),s=!!a,c=r?.runtime?.deviceName?.trim()||r?.settings.deviceName?.trim()||n(`remoteDeviceNameAuto`),u=!!(r?.account.loggedIn&&mi(r)),{hero:m,issueHint:g}=o;return(0,A.useEffect)(()=>{e.remoteAccessManager.syncStatus(r)},[e,r]),t.isLoading&&!r?(0,H.jsx)(`div`,{className:`p-8 text-gray-400`,children:n(`remoteLoading`)}):(0,H.jsxs)(h,{className:`space-y-6`,children:[(0,H.jsx)(re,{title:n(`remotePageTitle`),description:n(`remotePageDescription`)}),(0,H.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,H.jsxs)(f,{children:[(0,H.jsxs)(ie,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,H.jsx)(l,{children:m.title}),(0,H.jsx)(je,{status:m.badgeStatus,label:m.badgeLabel})]}),(0,H.jsx)(_,{children:m.description})]}),(0,H.jsxs)(d,{className:`space-y-5`,children:[(0,H.jsxs)(T,{tone:`neutral`,children:[(0,H.jsx)(U,{label:n(`remoteSignedInAccount`),value:r?.account.email}),(0,H.jsx)(U,{label:n(`remoteDeviceName`),value:c}),(0,H.jsx)(U,{label:n(`remoteConnectionStatus`),value:m.badgeLabel}),(0,H.jsx)(U,{label:n(`remoteLastConnectedAt`),value:r?.runtime?.lastConnectedAt?i(r.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[o.primaryAction?(0,H.jsxs)(p,{onClick:()=>{if(o.primaryAction?.kind===`reauthorize`){e.remoteAccessManager.reauthorizeRemoteAccess(r);return}if(o.primaryAction?.kind===`repair`){e.remoteAccessManager.repairRemoteAccess(r);return}e.remoteAccessManager.enableRemoteAccess(r)},disabled:s,children:[o.primaryAction.showRefreshIcon?(0,H.jsx)(Qr,{className:`mr-2 h-4 w-4`}):null,a||o.primaryAction.label]}):null,(0,H.jsxs)(p,{variant:`outline`,onClick:()=>void e.accountManager.openNextClawWeb(),disabled:s||!u,children:[(0,H.jsx)(ni,{className:`mr-2 h-4 w-4`}),n(`remoteOpenDeviceList`)]}),r?.settings.enabled?(0,H.jsx)(p,{variant:`outline`,onClick:()=>void e.remoteAccessManager.disableRemoteAccess(r),disabled:s,children:n(`remoteDisable`)}):null]}),o.shouldShowIssueHint&&g?(0,H.jsx)(T,{tone:`warning`,title:g.title,description:g.body}):null,(0,H.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`remoteOpenWebHint`)})]})]}),(0,H.jsxs)(f,{children:[(0,H.jsxs)(ie,{children:[(0,H.jsxs)(l,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Yr,{className:`h-4 w-4 text-primary`}),n(`remoteDeviceSectionTitle`)]}),(0,H.jsx)(_,{children:n(`remoteDeviceSectionDescription`)})]}),(0,H.jsxs)(d,{className:`space-y-5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(je,{status:r?.account.loggedIn?`ready`:`inactive`,label:r?.account.loggedIn?n(`remoteAccountConnected`):n(`remoteAccountNotConnected`)}),(0,H.jsx)(je,{status:r?.settings.enabled?`active`:`inactive`,label:r?.settings.enabled?n(`remoteEnabled`):n(`remoteStateDisabled`)}),(0,H.jsx)(je,{status:r?.service.running?`active`:`inactive`,label:r?.service.running?n(`remoteServiceRunning`):n(`remoteServiceStopped`)})]}),(0,H.jsxs)(T,{tone:`neutral`,children:[(0,H.jsx)(U,{label:n(`remoteDeviceName`),value:c}),(0,H.jsx)(U,{label:n(`remoteConnectionStatus`),value:m.badgeLabel}),(0,H.jsx)(U,{label:n(`remoteLastConnectedAt`),value:r?.runtime?.lastConnectedAt?i(r.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,H.jsx)(T,{tone:`neutral`,borderStyle:`dashed`,description:r?.account.loggedIn?n(`remoteOpenWebHint`):n(`remoteStatusNeedsSignInDescription`),className:`text-sm`})]})]})]})]})}var li=[`remote-status`],ui=`https://platform.nextclaw.io`,di=`https://nextclaw-platform-console.pages.dev`,W=async()=>await m.fetchQuery({queryKey:li,queryFn:ee,staleTime:5e3}),G=async()=>(await m.invalidateQueries({queryKey:li}),await W()),fi=(e,t)=>t?.trim()||e?.settings.platformApiBase?.trim()||e?.account.apiBase?.trim()||void 0;function pi(e){let t=e?.trim();if(!t)return;let n;try{n=new URL(t)}catch{return}if(n.hostname===`platform.nextclaw.io`||n.hostname===`nextclaw-platform-console.pages.dev`)return n.origin;if(n.hostname===`ai-gateway-api.nextclaw.io`)return ui;if(n.hostname.includes(`nextclaw-provider-gateway-api`)&&n.hostname.endsWith(`.workers.dev`))return di}var mi=e=>pi(e?.account.apiBase)||pi(e?.settings.platformApiBase)||pi(e?.platformBase)||pi(e?.account.platformBase)||void 0,K=s(e=>({enabled:!1,deviceName:``,platformApiBase:``,advancedOpen:!1,draftTouched:!1,actionLabel:null,doctor:null,setEnabled:t=>e({enabled:t,draftTouched:!0}),setDeviceName:t=>e({deviceName:t,draftTouched:!0}),setPlatformApiBase:t=>e({platformApiBase:t,draftTouched:!0}),setAdvancedOpen:t=>e({advancedOpen:t}),hydrateDraft:({enabled:t,deviceName:n,platformApiBase:r})=>e({enabled:t,deviceName:n,platformApiBase:r,draftTouched:!1}),beginAction:t=>e({actionLabel:t}),finishAction:()=>e({actionLabel:null}),setDoctor:t=>e({doctor:t})})),hi=class{constructor(e){this.params=e,this.syncStatus=e=>{if(!e)return;let t=K.getState();t.draftTouched||t.actionLabel||this.hydrateDraftFromStatus(e)},this.setEnabled=e=>{K.getState().setEnabled(e)},this.setDeviceName=e=>{K.getState().setDeviceName(e)},this.setPlatformApiBase=e=>{K.getState().setPlatformApiBase(e)},this.setAdvancedOpen=e=>{K.getState().setAdvancedOpen(e)},this.enableRemoteAccess=async e=>{let t=e??await G(),n=K.getState(),r=await this.ensureRemoteAccount(t,n.platformApiBase);await this.applyEnabledState(!0,r)},this.disableRemoteAccess=async e=>{let t=e??await G();await this.applyEnabledState(!1,t)},this.repairRemoteAccess=async e=>{let t=e??await G(),r=(await this.ensureRemoteAccount(t)).service.running?`restart`:`start`;await this.runManagedAction({actionLabel:n(r===`restart`?`remoteActionRestarting`:`remoteActionStarting`),job:async()=>{await ce(r);let e=await G();this.hydrateDraftFromStatus(e)},successMessage:n(`remoteServiceRecovered`)})},this.reauthorizeRemoteAccess=async e=>{let t=e??await G(),n=await this.params.accountManager.startBrowserSignInAndWait({status:t,apiBase:K.getState().platformApiBase});await this.repairRemoteAccess(n)},this.saveAdvancedSettings=async e=>{let t=e??await G(),r=K.getState();await this.runManagedAction({actionLabel:n(`remoteActionSavingAdvanced`),job:async()=>{await ue({enabled:r.enabled,deviceName:r.deviceName.trim(),platformApiBase:r.platformApiBase.trim()});let e=await G();this.hydrateDraftFromStatus(e)},successMessage:t.settings.enabled===r.enabled?n(`remoteSettingsSaved`):n(`remoteAdvancedSaved`)})},this.runDoctor=async()=>{await this.runManagedAction({actionLabel:n(`remoteDoctorRunning`),job:async()=>{let e=await ne();K.getState().setDoctor(e)},successMessage:n(`remoteDoctorCompleted`)})},this.startService=async()=>{await this.runServiceAction(`start`,n(`remoteActionStarting`))},this.restartService=async()=>{await this.runServiceAction(`restart`,n(`remoteActionRestarting`))},this.stopService=async()=>{await this.runServiceAction(`stop`,n(`remoteActionStopping`))},this.applyEnabledState=async(e,t)=>{let r=K.getState();await this.runManagedAction({actionLabel:n(e?`remoteActionEnabling`:`remoteActionDisabling`),job:async()=>{await ue({enabled:e,deviceName:r.deviceName.trim(),platformApiBase:r.platformApiBase.trim()});let n=await G();this.hydrateDraftFromStatus(n),e?await ce(n.service.running?`restart`:`start`):t.service.running&&await ce(`restart`);let i=await G();this.hydrateDraftFromStatus(i)},successMessage:n(e?`remoteEnabledReady`:`remoteDisabledDone`)})},this.ensureRemoteAccount=async(e,t)=>e.account.loggedIn?e:await this.params.accountManager.ensureSignedIn({apiBase:t,status:e}),this.runServiceAction=async(e,t)=>{await this.runManagedAction({actionLabel:t,job:async()=>{let t=await ce(e),n=await G();this.hydrateDraftFromStatus(n),C.success(t.message)}})},this.hydrateDraftFromStatus=e=>{K.getState().hydrateDraft({enabled:e.settings.enabled,deviceName:e.settings.deviceName,platformApiBase:e.settings.platformApiBase})},this.runManagedAction=async e=>{let{actionLabel:t,job:r,successMessage:i}=e;K.getState().beginAction(t);try{await r(),i&&C.success(i)}catch(e){let t=e instanceof Error?e.message:n(`error`);throw C.error(t),e}finally{K.getState().finishAction()}}}},gi=[/invalid or expired token/i,/missing bearer token/i,/token expired/i,/token is invalid/i,/run "nextclaw login"/i,/browser sign-in again/i];function _i(e){return e?.runtime?.lastError?.trim()||``}function vi(e){let t=n(`remoteStatusIssueDetailGeneric`),r=_i(e);return r?`${t} (${r})`:t}function yi(e){if(!e?.settings.enabled)return!1;let t=_i(e);return gi.some(e=>e.test(t))}function bi(e){return yi(e)?{hero:{badgeStatus:`warning`,badgeLabel:n(`remoteStateReauthorizationRequired`),title:n(`remoteStatusReauthorizationTitle`),description:n(`remoteStatusReauthorizationDescription`)},primaryAction:{kind:`reauthorize`,label:n(`remoteReauthorizeNow`),showRefreshIcon:!1},issueHint:{title:n(`remoteStatusRecoveryTitle`),body:n(`remoteStatusReauthorizationHint`)},shouldShowIssueHint:!0,requiresReauthorization:!0}:e?.account.loggedIn?e.settings.enabled?e.service.running?e.runtime?.state===`connected`?{hero:{badgeStatus:`ready`,badgeLabel:n(`statusReady`),title:n(`remoteStatusReadyTitle`),description:n(`remoteStatusReadyDescription`)},primaryAction:{kind:`repair`,label:n(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:e.runtime?.state===`connecting`?{hero:{badgeStatus:`active`,badgeLabel:n(`connecting`),title:n(`remoteStatusConnectingTitle`),description:n(`remoteStatusConnectingDescription`)},primaryAction:{kind:`repair`,label:n(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:n(`remoteStateDisconnected`),title:n(`remoteStatusIssueTitle`),description:n(`remoteStatusIssueDescription`)},primaryAction:{kind:`repair`,label:n(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:n(`remoteStatusRecoveryTitle`),body:vi(e)},shouldShowIssueHint:!!(e.settings.enabled&&e.account.loggedIn),requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:n(`remoteServiceStopped`),title:n(`remoteStatusNeedsServiceTitle`),description:n(`remoteStatusNeedsServiceDescription`)},primaryAction:{kind:`repair`,label:n(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:n(`remoteStatusRecoveryTitle`),body:n(`remoteStatusIssueDetailServiceStopped`)},shouldShowIssueHint:!0,requiresReauthorization:!1}:{hero:{badgeStatus:`inactive`,badgeLabel:n(`statusInactive`),title:n(`remoteStatusNeedsEnable`),description:n(`remoteStatusNeedsEnableDescription`)},primaryAction:{kind:`enable`,label:n(`remoteEnableNow`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`setup`,badgeLabel:n(`statusSetup`),title:n(`remoteStatusNeedsSignIn`),description:n(`remoteStatusNeedsSignInDescription`)},primaryAction:{kind:`sign-in-enable`,label:n(`remoteSignInAndEnable`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}}var q=s(e=>({panelOpen:!1,authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500,openPanel:()=>e({panelOpen:!0}),closePanel:()=>e({panelOpen:!1}),beginBrowserAuth:({sessionId:t,verificationUri:n,expiresAt:r,intervalMs:i,statusMessage:a})=>e({panelOpen:!0,authSessionId:t,authVerificationUri:n,authExpiresAt:r,authPollIntervalMs:i,authStatusMessage:a}),updateBrowserAuth:({statusMessage:t,intervalMs:n})=>e(e=>({authStatusMessage:t??e.authStatusMessage,authPollIntervalMs:n??e.authPollIntervalMs})),clearBrowserAuth:()=>e({authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500}),setAuthStatusMessage:t=>e({authStatusMessage:t})}));function xi({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,H.jsx)(`span`,{className:`text-gray-500`,children:e}),(0,H.jsx)(`span`,{className:`text-right text-gray-900`,children:t?.trim()||`-`})]})}function Si(e){let{email:t,username:r,role:i,canSubmitUsername:a,savingUsername:o,usernameDraft:s,onUsernameDraftChange:c,onSubmitUsername:l,onOpenDeviceList:u,onLogout:d}=e;return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(T,{tone:`success`,title:n(`accountPanelSignedInTitle`),description:n(`accountPanelSignedInDescription`)}),(0,H.jsxs)(T,{tone:`neutral`,children:[(0,H.jsx)(xi,{label:n(`remoteAccountEmail`),value:t}),(0,H.jsx)(xi,{label:n(`remoteAccountUsername`),value:r}),(0,H.jsx)(xi,{label:n(`remoteAccountRole`),value:i})]}),r?(0,H.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`remoteAccountUsernameLockedHelp`)}):(0,H.jsxs)(T,{tone:`warning`,title:n(`remoteAccountUsernameRequiredTitle`),description:n(`remoteAccountUsernameRequiredDescription`),children:[(0,H.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,H.jsx)(g,{htmlFor:`account-panel-username`,children:n(`remoteAccountUsername`)}),(0,H.jsx)(v,{id:`account-panel-username`,value:s,onChange:e=>c(e.target.value),placeholder:n(`remoteAccountUsernamePlaceholder`),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1})]}),(0,H.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-3`,children:(0,H.jsx)(p,{disabled:!a,onClick:()=>void l(),children:n(o?`remoteAccountUsernameSaving`:`remoteAccountUsernameSave`)})})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,H.jsxs)(p,{onClick:()=>void u(),children:[(0,H.jsx)(ni,{className:`mr-2 h-4 w-4`}),n(`remoteOpenDeviceList`)]}),(0,H.jsxs)(p,{variant:`outline`,onClick:()=>void d(),children:[(0,H.jsx)(Xr,{className:`mr-2 h-4 w-4`}),n(`remoteLogout`)]})]})]})}function Ci(e){let{authSessionId:t,authExpiresAt:r,authStatusMessage:a,authVerificationUri:o,onStartBrowserSignIn:s,onResumeBrowserSignIn:c}=e;return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(T,{tone:`neutral`,title:n(`accountPanelSignedOutTitle`),description:n(`accountPanelSignedOutDescription`),children:t?(0,H.jsxs)(`div`,{className:`mt-3 border-t border-white/80 pt-3`,children:[(0,H.jsx)(xi,{label:n(`remoteBrowserAuthSession`),value:t}),(0,H.jsx)(xi,{label:n(`remoteBrowserAuthExpiresAt`),value:r?i(r):`-`})]}):null}),a?(0,H.jsx)(`p`,{className:`text-sm text-gray-600`,children:a}):null,(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,H.jsx)(p,{onClick:()=>void s(),children:n(t?`remoteBrowserAuthActionRetry`:`remoteBrowserAuthAction`)}),o?(0,H.jsx)(p,{variant:`outline`,onClick:c,children:n(`remoteBrowserAuthResume`)}):null]})]})}function wi(){let e=es(),t=si(),r=q(e=>e.panelOpen),i=q(e=>e.authSessionId),a=q(e=>e.authVerificationUri),o=q(e=>e.authExpiresAt),s=q(e=>e.authStatusMessage),c=t.data,[l,u]=(0,A.useState)(``),[d,f]=(0,A.useState)(!1);(0,A.useEffect)(()=>{e.accountManager.syncRemoteStatus(c)},[e,c]);let p=!d&&l.trim().length>0&&!c?.account.username;return(0,H.jsx)(pe,{open:r,onOpenChange:t=>t?e.accountManager.openAccountPanel():e.accountManager.closeAccountPanel(),children:(0,H.jsxs)(he,{className:`max-w-xl`,children:[(0,H.jsxs)(me,{children:[(0,H.jsxs)(ge,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Ee,{className:`h-5 w-5 text-primary`}),n(`accountPanelTitle`)]}),(0,H.jsx)(fe,{children:n(`accountPanelDescription`)})]}),c?.account.loggedIn?(0,H.jsx)(Si,{email:c.account.email,username:c.account.username,role:c.account.role,canSubmitUsername:p,savingUsername:d,usernameDraft:l,onUsernameDraftChange:u,onSubmitUsername:async()=>{f(!0);try{await e.accountManager.updateUsername(l)}finally{f(!1)}},onOpenDeviceList:()=>e.accountManager.openNextClawWeb(`/account`),onLogout:()=>e.accountManager.logout()}):(0,H.jsx)(Ci,{authSessionId:i,authExpiresAt:o,authStatusMessage:s,authVerificationUri:a,onStartBrowserSignIn:()=>e.accountManager.startBrowserSignIn(),onResumeBrowserSignIn:()=>e.accountManager.resumeBrowserSignIn()})]})})}function Ti({username:e}){let t=se(),[r,i]=(0,A.useState)(e??``),[a,o]=(0,A.useState)(``),s=r.trim().length>0&&a.length>0&&!t.isPending;return(0,H.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-secondary px-6 py-10`,children:(0,H.jsxs)(f,{hover:!1,className:`w-full max-w-md shadow-card-hover`,children:[(0,H.jsxs)(ie,{children:[(0,H.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.24em] text-gray-500`,children:n(`authBrand`)}),(0,H.jsx)(l,{className:`text-2xl`,children:n(`authLoginTitle`)}),(0,H.jsx)(_,{children:n(`authLoginDescription`)})]}),(0,H.jsx)(d,{children:(0,H.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e?.preventDefault(),s&&t.mutate({username:r.trim(),password:a})},children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:n(`authUsername`)}),(0,H.jsx)(v,{value:r,onChange:e=>i(e.target.value),placeholder:n(`authUsernamePlaceholder`),autoFocus:!0})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:n(`authPassword`)}),(0,H.jsx)(v,{type:`password`,value:a,onChange:e=>o(e.target.value),placeholder:n(`authPasswordPlaceholder`)})]}),(0,H.jsx)(p,{type:`submit`,className:`w-full`,disabled:!s,children:t.isPending?n(`authLoggingIn`):n(`authLoginAction`)})]})})]})})}var Ei=class{constructor(){this.authPollTimerId=null,this.browserSignInCompletion=null,this.openAccountPanel=()=>{q.getState().openPanel()},this.closeAccountPanel=()=>{q.getState().closePanel()},this.syncRemoteStatus=e=>{e?.account.loggedIn&&(this.clearPollTimer(),this.resolveBrowserSignIn(e),q.getState().clearBrowserAuth())},this.ensureSignedIn=async e=>{let t=e?.status??await W();return t.account.loggedIn?t:(this.openAccountPanel(),await this.startBrowserSignInAndWait({apiBase:e?.apiBase,status:t}))},this.startBrowserSignInAndWait=async e=>{let t=this.createBrowserSignInCompletion();return await this.startBrowserSignIn(e),await t},this.startBrowserSignIn=async e=>{try{let t=e?.apiBase,r=await te({apiBase:fi(e?.status??await W(),t)});q.getState().beginBrowserAuth({sessionId:r.sessionId,verificationUri:r.verificationUri,expiresAt:r.expiresAt,intervalMs:r.intervalMs,statusMessage:n(`remoteBrowserAuthWaiting`)}),window.open(r.verificationUri,`_blank`,`noopener,noreferrer`)||q.getState().setAuthStatusMessage(n(`remoteBrowserAuthPopupBlocked`)),this.scheduleBrowserAuthPoll()}catch(e){let t=e instanceof Error?e.message:n(`remoteBrowserAuthStartFailed`);this.rejectBrowserSignIn(e),C.error(`${n(`remoteBrowserAuthStartFailed`)}: ${t}`)}},this.resumeBrowserSignIn=()=>{let e=q.getState().authVerificationUri;e&&window.open(e,`_blank`,`noopener,noreferrer`)},this.logout=async()=>{try{await oe(),this.rejectBrowserSignIn(Error(`Signed out before browser sign-in completed.`)),q.getState().clearBrowserAuth(),await G(),C.success(n(`remoteLogoutSuccess`))}catch(e){let t=e instanceof Error?e.message:n(`remoteLogoutFailed`);C.error(`${n(`remoteLogoutFailed`)}: ${t}`)}},this.updateUsername=async e=>{try{await ae({username:e.trim()}),await G(),C.success(n(`remoteAccountUsernameSetSuccess`))}catch(e){let t=e instanceof Error?e.message:n(`remoteAccountUsernameSetFailed`);C.error(`${n(`remoteAccountUsernameSetFailed`)}: ${t}`)}},this.openNextClawWeb=async(e=`/`)=>{let t=mi(await W());if(!t){C.error(n(`remoteOpenWebUnavailable`));return}let r=new URL(e,`${t.replace(/\/+$/,``)}/`).toString();window.open(r,`_blank`,`noopener,noreferrer`)},this.scheduleBrowserAuthPoll=()=>{this.clearPollTimer();let{authSessionId:e,authPollIntervalMs:t}=q.getState();e&&(this.authPollTimerId=window.setTimeout(async()=>{await this.pollBrowserSignIn()},t))},this.pollBrowserSignIn=async()=>{let e=q.getState();if(e.authSessionId)try{let t=await W(),r=await le({sessionId:e.authSessionId,apiBase:fi(t)});if(r.status===`pending`){q.getState().updateBrowserAuth({statusMessage:n(`remoteBrowserAuthWaiting`),intervalMs:r.nextPollMs??1500}),this.scheduleBrowserAuthPoll();return}if(r.status===`expired`){this.clearPollTimer(),this.rejectBrowserSignIn(Error(r.message||n(`remoteBrowserAuthExpired`))),q.getState().clearBrowserAuth(),C.error(r.message||n(`remoteBrowserAuthExpired`));return}q.getState().setAuthStatusMessage(n(`remoteBrowserAuthCompleted`));let i=await G();this.clearPollTimer(),this.resolveBrowserSignIn(i),q.getState().clearBrowserAuth(),C.success(n(`remoteLoginSuccess`))}catch(e){this.clearPollTimer(),this.rejectBrowserSignIn(e),q.getState().clearBrowserAuth();let t=e instanceof Error?e.message:n(`remoteBrowserAuthPollFailed`);C.error(`${n(`remoteBrowserAuthPollFailed`)}: ${t}`)}},this.clearPollTimer=()=>{this.authPollTimerId!==null&&(window.clearTimeout(this.authPollTimerId),this.authPollTimerId=null)},this.createBrowserSignInCompletion=()=>(this.rejectBrowserSignIn(Error(`Browser sign-in was replaced by a newer request.`)),new Promise((e,t)=>{this.browserSignInCompletion={resolve:e,reject:t}})),this.resolveBrowserSignIn=e=>{let t=this.browserSignInCompletion;t&&(this.browserSignInCompletion=null,t.resolve(e))},this.rejectBrowserSignIn=e=>{let t=this.browserSignInCompletion;t&&(this.browserSignInCompletion=null,t.reject(e instanceof Error?e:Error(String(e))))},this.getBrowserAuthSummary=()=>{let e=q.getState();return{sessionId:e.authSessionId,expiresAt:e.authExpiresAt?i(e.authExpiresAt):`-`}}}};function Di({deletePending:e,entry:t,favoritePending:r,onDelete:i,onOpen:a,onToggleFavorite:o}){let[s,c]=(0,A.useState)(!1),[l,u]=(0,A.useState)(!1),d=t.favorite?n(`panelAppsUnfavorite`):n(`panelAppsFavorite`),f=t.lastOpenedAt?`${n(`panelAppsLastOpened`)} ${ki(t.lastOpenedAt)}`:`${n(`panelAppsUpdated`)} ${ki(t.updatedAt)}`,p=e=>{e.stopPropagation(),o()},m=()=>{c(!1),u(!0)};return(0,H.jsxs)(`div`,{className:`group w-full min-w-0 rounded-lg border border-gray-200 bg-white px-2.5 py-2.5 transition-colors hover:border-amber-200 hover:bg-amber-50/50`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:a,className:`min-w-0 flex-1 text-left`,children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-amber-50 text-base text-amber-700`,children:(0,H.jsx)(Ai,{icon:t.icon,title:t.title})}),(0,H.jsx)(`span`,{className:`block min-w-0 flex-1 truncate text-sm font-medium text-gray-900`,children:t.title})]}),t.description?(0,H.jsx)(`span`,{className:`mt-1.5 block truncate text-xs leading-5 text-gray-600`,children:t.description}):null,(0,H.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] leading-4 text-gray-400`,children:f})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:p,disabled:r,className:`rounded-md p-1.5 text-gray-400 transition-colors hover:bg-white hover:text-amber-500 disabled:opacity-50`,title:d,"aria-label":d,children:(0,H.jsx)(ri,{className:t.favorite?`h-4 w-4 fill-amber-400 text-amber-500`:`h-4 w-4`})}),(0,H.jsxs)(Pe,{open:s,onOpenChange:c,children:[(0,H.jsx)(Ne,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-gray-400 transition-colors hover:bg-white hover:text-gray-700`,"aria-label":n(`panelAppsMoreActions`),disabled:e,children:(0,H.jsx)(qr,{className:`h-4 w-4`})})}),(0,H.jsx)(Me,{align:`end`,className:`w-48 rounded-xl p-1.5`,children:(0,H.jsx)(Oi,{destructive:!0,disabled:e,icon:ke,label:n(`panelAppsDelete`),onClick:m})})]})]})]}),(0,H.jsx)(_e,{open:l,onOpenChange:u,title:n(`panelAppsDeleteConfirmTitle`),description:`${n(`panelAppsDeleteConfirmDescription`)} ${t.fileName}`,confirmLabel:n(`delete`),variant:`destructive`,onConfirm:i,onCancel:()=>void 0})]})}function Oi({destructive:t=!1,disabled:n=!1,icon:r,label:i,onClick:a}){return(0,H.jsxs)(`button`,{type:`button`,className:e(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,t?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),disabled:n,onClick:a,children:[(0,H.jsx)(r,{className:`h-4 w-4 shrink-0`}),(0,H.jsx)(`span`,{children:i})]})}function ki(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=o(a()),r=new Date;return t.toDateString()===r.toDateString()?new Intl.DateTimeFormat(n,{hour:`2-digit`,minute:`2-digit`}).format(t):t.getFullYear()===r.getFullYear()?new Intl.DateTimeFormat(n,{month:`numeric`,day:`numeric`}).format(t):new Intl.DateTimeFormat(n,{year:`2-digit`,month:`numeric`,day:`numeric`}).format(t)}function Ai({icon:e,title:t}){return e?ji(e)?(0,H.jsx)(`img`,{src:e,alt:``,"aria-hidden":`true`,className:`h-5 w-5 rounded-sm object-contain`,title:t}):(0,H.jsx)(`span`,{className:`max-w-6 truncate text-center leading-none`,children:e}):(0,H.jsx)(Vr,{className:`h-4 w-4`})}function ji(e){return e.startsWith(`data:image/`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)}var Mi=[`panel-apps`];function Ni(){return b({queryKey:Mi,queryFn:()=>x.panelApps.listPanelApps(),staleTime:0})}function Pi(){let e=y();return u({mutationFn:({id:e,preferences:t})=>x.panelApps.updatePanelAppPreferences(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:Mi})}})}function Fi(){let e=y();return u({mutationFn:e=>x.panelApps.recordPanelAppOpened(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mi})}})}function Ii(){let e=y();return u({mutationFn:e=>x.panelApps.grantClient(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mi})}})}function Li(){let e=y();return u({mutationFn:e=>x.panelApps.deletePanelApp(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mi})}})}function Ri(e,t){return t===`favorites`?zi(e.filter(e=>e.favorite),`smart`):zi(t===`recent-open`?e.filter(e=>e.lastOpenedAt):e,t)}function zi(e,t){return[...e].sort((e,n)=>Bi(e,n,t))}function Bi(e,t,n){return n===`recent-open`?Wi(e.lastOpenedAt,t.lastOpenedAt)||Vi(e,t):n===`updated`?Wi(e.updatedAt,t.updatedAt)||Vi(e,t):n===`name`?Vi(e,t):Hi(e,t)||Number(t.favorite)-Number(e.favorite)||Vi(e,t)}function Vi(e,t){return e.title.localeCompare(t.title)}function Hi(e,t){return Ui(t)-Ui(e)}function Ui(e){return Math.max(new Date(e.lastOpenedAt??0).getTime(),new Date(e.createdAt).getTime(),new Date(e.updatedAt).getTime())}function Wi(e,t){return new Date(t??0).getTime()-new Date(e??0).getTime()}function Gi({headerContent:e,onOpenPanelApp:t}){let r=Ni(),i=Li(),a=Pi(),o=Fi(),s=Ii(),c=es(),[l,u]=(0,A.useState)(`smart`),d=(0,A.useMemo)(()=>Ri(r.data?.entries??[],l),[r.data?.entries,l]),f=async e=>{if(await p(e))try{t(await o.mutateAsync(e.id))}catch{t(e)}},p=async e=>!e.clientDeclared||e.clientGranted?!0:await c.serviceActionAuthorizationManager.requestAuthorization({panelAppId:e.appId,actions:[{actionId:`nextclaw.client`,actionTitle:n(`panelAppsClientGrantTitle`),actionDescription:n(`panelAppsClientGrantDescription`),risk:`dangerous`}]})?(await s.mutateAsync(e.appId),!0):!1,m=e=>{a.mutate({id:e.id,preferences:{favorite:!e.favorite}})},h=e=>{i.mutate(e.id)};return r.isLoading?(0,H.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:n(`panelAppsLoading`)}):r.isError?(0,H.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:r.error instanceof Error?r.error.message:n(`panelAppsLoadFailed`)}):(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e??(0,H.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:n(`panelAppsTitle`)}),r.data?.panelsPath?(0,H.jsx)(Ce,{delayDuration:250,children:(0,H.jsxs)(we,{children:[(0,H.jsx)(xe,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:`rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-700`,"aria-label":n(`panelAppsTitle`),children:(0,H.jsx)(Gr,{className:`h-3.5 w-3.5`})})}),(0,H.jsx)(Se,{side:`bottom`,className:`max-w-[320px] break-all font-mono text-xs`,children:r.data.panelsPath})]})}):null]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>void r.refetch(),className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:n(`panelAppsRefresh`),"aria-label":n(`panelAppsRefresh`),children:(0,H.jsx)(Oe,{className:`h-3.5 w-3.5`})})]}),(0,H.jsx)(`div`,{className:`border-b border-gray-100 px-3 py-2`,children:(0,H.jsx)(Ie,{value:l,onValueChange:e=>u(e),children:(0,H.jsxs)(Fe,{className:`grid h-auto w-full grid-cols-5 rounded-lg bg-gray-100/70 p-0.5`,children:[(0,H.jsx)(E,{value:`smart`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortSmart`)}),(0,H.jsx)(E,{value:`favorites`,className:`px-2 py-1 text-xs`,children:n(`panelAppsFavorites`)}),(0,H.jsx)(E,{value:`recent-open`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortRecentOpen`)}),(0,H.jsx)(E,{value:`updated`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortUpdated`)}),(0,H.jsx)(E,{value:`name`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortName`)})]})})}),d.length===0?(0,H.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-gray-500`,children:n(`panelAppsEmpty`)}):(0,H.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3`,children:(0,H.jsx)(`div`,{className:`space-y-1.5`,children:d.map(e=>(0,H.jsx)(Di,{entry:e,deletePending:i.isPending,favoritePending:a.isPending,onDelete:()=>h(e),onOpen:()=>void f(e),onToggleFavorite:()=>m(e)},e.id))})})]})}var Ki=class{constructor(e){this.authorizationManager=e,this.handleIframeMessage=({event:e,iframe:t,iframeInstanceId:n,tab:r})=>{this.isBridgeRequest(e.data)&&(!t?.contentWindow||e.source!==t.contentWindow||this.handleBridgeRequest({event:e,iframe:t,iframeInstanceId:n,tab:r},e.data))},this.handleBridgeRequest=async(e,t)=>{try{let n=this.getBridgeContext(t),r=await this.dispatchRequest(n,t);this.postResponse(e,{type:`nextclaw:panel-app-service-actions:response`,requestId:t.requestId,ok:!0,data:r})}catch(n){this.postResponse(e,{type:`nextclaw:panel-app-service-actions:response`,requestId:t.requestId,ok:!1,error:this.toBridgeError(n)})}},this.dispatchRequest=async(e,t)=>{switch(t.method){case`list`:return await x.serviceApps.listServiceActions({bridgeSessionToken:e.token});case`requestGrant`:return await this.confirmAndGrant(e,this.requireActionId(t));case`revokeGrant`:return await x.serviceApps.revokeServiceAction(this.requireActionId(t),{bridgeSessionToken:e.token});case`invoke`:return await this.invokeWithAuthorization(e,t);case`agent.send`:return await this.sendAgentMessageWithAuthorization(e,t);case`agent.generateObject`:return await this.generateAgentObjectWithAuthorization(e,t);default:throw Error(`Unsupported panel bridge method: ${String(t.method)}`)}},this.invokeWithAuthorization=async(e,t)=>{let n=this.requireActionId(t);try{return await x.serviceApps.invokeServiceAction(n,this.readOptionalRecord(t.payload?.input),{bridgeSessionToken:e.token})}catch(r){if(!(r instanceof S)||r.code!==`AUTHORIZATION_REQUIRED`)throw r;return await this.confirmAndGrant(e,n,this.readOptionalRecord(t.payload?.input)),await x.serviceApps.invokeServiceAction(n,this.readOptionalRecord(t.payload?.input),{bridgeSessionToken:e.token})}},this.sendAgentMessageWithAuthorization=async(e,t)=>{try{return await x.panelApps.sendAgentMessage(this.readAgentSendRequest(t),{bridgeSessionToken:e.token})}catch(n){if(!(n instanceof S)||n.code!==`AUTHORIZATION_REQUIRED`)throw n;return await this.confirmAndGrantAgentCapability(e,`agent:send`),await x.panelApps.sendAgentMessage(this.readAgentSendRequest(t),{bridgeSessionToken:e.token})}},this.generateAgentObjectWithAuthorization=async(e,t)=>{try{return await x.panelApps.generateAgentObject(this.readGenerateObjectRequest(t),{bridgeSessionToken:e.token})}catch(n){if(!(n instanceof S)||n.code!==`AUTHORIZATION_REQUIRED`)throw n;return await this.confirmAndGrantAgentCapability(e,`agent:generateObject`),await x.panelApps.generateAgentObject(this.readGenerateObjectRequest(t),{bridgeSessionToken:e.token})}},this.confirmAndGrantAgentCapability=async(e,t)=>{if(!await this.authorizationManager.requestAuthorization({panelAppId:e.appId,actions:[{actionId:t,actionTitle:t===`agent:send`?`Send agent message`:`Generate object`,actionDescription:t===`agent:send`?`Send a message to a NextClaw Agent session.`:`Send context to a NextClaw Agent session and receive a structured object.`,risk:`write`}]}))throw new S({code:`AUTHORIZATION_REJECTED`,message:`Permission rejected for ${t}.`});return await x.panelApps.grantAgentCapability(t,{bridgeSessionToken:e.token})},this.confirmAndGrant=async(e,t,n)=>{let r=await this.listGrantCandidateActions(e,t);if(!await this.authorizationManager.requestAuthorization({panelAppId:e.appId,actions:r.map(e=>({actionId:e.id,actionTitle:e.title,actionDescription:e.description,risk:e.risk})),inputPreview:this.createInputPreview(n)}))throw new S({code:`AUTHORIZATION_REJECTED`,message:`Permission rejected for ${t}.`});let i=await x.serviceApps.grantServiceActions(r.map(e=>e.id),{bridgeSessionToken:e.token}),a=i.grants.find(e=>e.actionId===t)??i.grants[0];if(!a)throw Error(`No permission grant returned for ${t}.`);return a},this.listGrantCandidateActions=async(e,t)=>{let n=await x.serviceApps.listServiceActions({bridgeSessionToken:e.token}),r=n.actions.find(e=>e.id===t);if(r&&r.grantState!==`not-granted`)return[r];let i=n.actions.filter(e=>e.grantState===`not-granted`),a=[...i.filter(e=>e.id===t),...i.filter(e=>e.id!==t)];return a.length>0?a:[{appId:r?.appId??t.split(`.`)[0]??t,description:r?.description,id:t,name:r?.name??t,risk:r?.risk??`dangerous`,title:r?.title}]},this.createInputPreview=e=>{if(!(!e||Object.keys(e).length===0))try{let t=JSON.stringify(e,null,2);return t.length>500?`${t.slice(0,500)}...`:t}catch{return`[unserializable input]`}},this.getBridgeContext=e=>({appId:e.appId,token:e.runtimeToken}),this.requireActionId=e=>{let t=e.payload?.actionId?.trim();if(!t)throw Error(`Panel bridge actionId is required.`);return t},this.readOptionalRecord=e=>{if(e!==void 0)return this.requireRecord(e,`input`)},this.readAgentSendRequest=e=>({payload:this.requireRecord(e.payload?.request,`agent.send request`)}),this.readGenerateObjectRequest=e=>({input:this.requireRecord(e.payload?.input,`generateObject input`)}),this.requireRecord=(e,t)=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`${t} is required.`);return e},this.postResponse=(e,t)=>{e.iframe?.contentWindow?.postMessage(t,`*`)},this.toBridgeError=e=>e instanceof S?{code:e.code,message:e.message,details:e.details}:{message:e instanceof Error?e.message:String(e)},this.isBridgeRequest=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return t.type===`nextclaw:panel-app-service-actions:request`&&typeof t.requestId==`string`&&typeof t.runtimeToken==`string`&&typeof t.appId==`string`&&(t.method===`invoke`||t.method===`agent.send`||t.method===`agent.generateObject`||t.method===`list`||t.method===`requestGrant`||t.method===`revokeGrant`)}}};function qi(){return`service-action-auth-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}var Ji=s((e,t)=>({pending:null,requestAuthorization:async n=>await new Promise(r=>{t().pending?.resolve(!1),e({pending:{id:qi(),...n,resolve:r}})}),resolveAuthorization:n=>{let{pending:r}=t();r&&(r.resolve(n),e({pending:null}))}}));function Yi(){let e=Ji(e=>e.pending),t=Ji(e=>e.resolveAuthorization);return(0,H.jsx)(pe,{open:!!e,onOpenChange:e=>{e||t(!1)},children:(0,H.jsxs)(he,{className:`[&>:last-child]:hidden`,children:[(0,H.jsxs)(me,{children:[(0,H.jsxs)(ge,{className:`flex items-center gap-2`,children:[(0,H.jsx)(ei,{className:`h-4 w-4 text-amber-600`}),n(`serviceActionAuthorizationTitle`)]}),(0,H.jsx)(fe,{children:n(`serviceActionAuthorizationDescription`)})]}),e?(0,H.jsxs)(`div`,{className:`space-y-3 rounded-md border border-gray-100 bg-gray-50 p-3 text-sm`,children:[(0,H.jsx)(Zi,{label:n(`serviceActionAuthorizationSource`),value:e.panelAppId}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`div`,{className:`text-xs font-medium text-gray-500`,children:n(`serviceActionAuthorizationActions`)}),(0,H.jsx)(`div`,{className:`max-h-64 space-y-2 overflow-auto`,children:e.actions.map(e=>(0,H.jsx)(Xi,{action:e},e.actionId))})]}),e.inputPreview?(0,H.jsx)(Zi,{label:n(`serviceActionAuthorizationInput`),value:e.inputPreview}):null]}):null,(0,H.jsxs)(de,{className:`gap-2 sm:gap-0`,children:[(0,H.jsx)(p,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:n(`serviceActionAuthorizationReject`)}),(0,H.jsx)(p,{type:`button`,onClick:()=>t(!0),children:n(`serviceActionAuthorizationAllow`)})]})]})})}function Xi({action:e}){return(0,H.jsxs)(`div`,{className:`space-y-1 rounded border border-gray-200 bg-white px-3 py-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsx)(`div`,{className:`min-w-0 break-words text-xs font-medium text-gray-900`,children:e.actionTitle??e.actionId}),(0,H.jsx)(`div`,{className:`shrink-0 rounded bg-amber-50 px-1.5 py-0.5 text-[11px] font-medium text-amber-700`,children:e.risk??`dangerous`})]}),(0,H.jsx)(`div`,{className:`break-words text-[11px] text-gray-500`,children:e.actionId}),e.actionDescription?(0,H.jsx)(`div`,{className:`break-words text-xs text-gray-600`,children:e.actionDescription}):null]})}function Zi({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`grid grid-cols-[5rem_minmax(0,1fr)] gap-3`,children:[(0,H.jsx)(`div`,{className:`text-xs font-medium text-gray-500`,children:e}),(0,H.jsx)(`div`,{className:`min-w-0 break-words text-xs text-gray-900`,children:t})]})}var Qi=class{constructor(){this.requestAuthorization=async e=>await Ji.getState().requestAuthorization(e)}},$i=[`service-apps`],ea=[`service-actions`],ta=[`service-action-grants`];function na(){return b({queryKey:$i,queryFn:()=>x.serviceApps.listServiceApps()})}function ra(){return b({queryKey:ea,queryFn:()=>x.serviceApps.listServiceActions()})}function ia(){return b({queryKey:ta,queryFn:()=>x.serviceApps.listServiceActionGrants()})}function aa(){let e=y();return u({mutationFn:e=>x.serviceApps.restartServiceApp(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:$i}),e.invalidateQueries({queryKey:ea})])}})}function oa(){let e=y();return u({mutationFn:e=>x.serviceApps.deleteServiceApp(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:$i}),e.invalidateQueries({queryKey:ea}),e.invalidateQueries({queryKey:ta})])}})}function sa(){let e=y();return u({mutationFn:e=>x.serviceApps.discoverServiceAppActions(e),onSuccess:async()=>{await e.invalidateQueries({queryKey:$i})}})}function ca(){let e=y();return u({mutationFn:e=>x.serviceApps.revokeServiceActionGrant(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:ea}),e.invalidateQueries({queryKey:ta})])}})}function la({headerContent:e}){let t=na(),r=ra(),i=ia(),a=oa(),o=aa(),s=sa(),c=ca(),[l,u]=(0,A.useState)({}),d=()=>{t.refetch(),r.refetch(),i.refetch()};if(t.isLoading||r.isLoading||i.isLoading)return(0,H.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:n(`serviceAppsLoading`)});if(t.isError||r.isError||i.isError){let e=t.error??r.error??i.error;return(0,H.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:e instanceof Error?e.message:n(`serviceAppsLoadFailed`)})}let f=t.data?.entries??[],p=r.data?.actions??[],m=i.data?.grants??[],h=e=>{s.mutateAsync(e).then(t=>{u(n=>({...n,[e]:t.actions}))})};return(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3`,children:[(0,H.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:e??(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($r,{className:`h-4 w-4 text-primary`}),(0,H.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:n(`serviceAppsTitle`)})]})}),(0,H.jsx)(Ce,{delayDuration:250,children:(0,H.jsx)(pa,{icon:Oe,label:n(`serviceAppsRefresh`),onClick:d})})]}),f.length===0?(0,H.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-gray-500`,children:n(`serviceAppsEmpty`)}):(0,H.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3`,children:(0,H.jsx)(`div`,{className:`space-y-3`,children:f.map(e=>(0,H.jsx)(ua,{app:e,actions:l[e.id]??p.filter(t=>t.appId===e.id),grants:m,deletePending:a.isPending,isDiscovering:s.isPending,onDiscover:h,onDelete:e=>void a.mutate(e),onRestart:e=>void o.mutate(e),onRevoke:e=>void c.mutate({actionId:e.actionId,caller:e.caller})},e.id))})})]})}function ua({app:e,actions:t,grants:r,deletePending:i,isDiscovering:a,onDiscover:o,onDelete:s,onRestart:c,onRevoke:l}){let[u,d]=(0,A.useState)(!1),[f,p]=(0,A.useState)(!1),m=e.status!==`starting`&&e.status!==`stopped`,h=e.status===`running`||e.status===`failed`,g=()=>{d(!1),p(!0)};return(0,H.jsx)(Ce,{delayDuration:250,children:(0,H.jsxs)(`section`,{className:`rounded-lg border border-gray-200 bg-white p-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.title}),(0,H.jsx)(da,{status:e.status})]}),e.description?(0,H.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-gray-500`,children:e.description}):null,e.lastError?(0,H.jsx)(`div`,{className:`mt-2 rounded bg-rose-50 px-2 py-1 text-xs text-rose-700`,children:e.lastError}):null]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,H.jsx)(pa,{disabled:a||!m,icon:Zr,label:n(`serviceAppsDiscoverActions`),tooltip:n(`serviceAppsDiscoverActionsHint`),onClick:()=>o(e.id)}),(0,H.jsx)(pa,{disabled:!h,icon:ai,label:n(`serviceAppsDisconnectRuntime`),tooltip:n(`serviceAppsDisconnectRuntimeHint`),onClick:()=>c(e.id)}),(0,H.jsxs)(Pe,{open:u,onOpenChange:d,children:[(0,H.jsxs)(we,{children:[(0,H.jsx)(xe,{asChild:!0,children:(0,H.jsx)(Ne,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50`,"aria-label":n(`serviceAppsMoreActions`),disabled:i,children:(0,H.jsx)(qr,{className:`h-3.5 w-3.5`})})})}),(0,H.jsx)(Se,{side:`bottom`,className:`text-xs`,children:n(`serviceAppsMoreActions`)})]}),(0,H.jsx)(Me,{align:`end`,className:`w-48 rounded-xl p-1.5`,children:(0,H.jsx)(ma,{destructive:!0,disabled:i,icon:ke,label:n(`serviceAppsDelete`),onClick:g})})]})]})]}),(0,H.jsx)(ha,{app:e}),(0,H.jsx)(`div`,{className:`mt-3 space-y-1`,children:t.map(e=>(0,H.jsx)(_a,{action:e,grants:r.filter(t=>t.actionId===e.id),onRevoke:l},e.id))}),(0,H.jsx)(_e,{open:f,onOpenChange:p,title:n(`serviceAppsDeleteConfirmTitle`),description:`${n(`serviceAppsDeleteConfirmDescription`)} ${e.title}`,confirmLabel:n(`delete`),variant:`destructive`,onConfirm:()=>s(e.id),onCancel:()=>void 0})]})})}function da({status:t}){let n=fa(t),r=n.icon;return(0,H.jsxs)(we,{children:[(0,H.jsx)(xe,{asChild:!0,children:(0,H.jsxs)(`span`,{className:e(`inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium`,n.className),"aria-label":n.label,children:[(0,H.jsx)(r,{className:e(`h-3 w-3`,n.iconClassName)}),(0,H.jsx)(`span`,{children:n.label})]})}),(0,H.jsx)(Se,{side:`bottom`,className:`text-xs`,children:n.tooltip})]})}function fa(e){switch(e){case`running`:return{className:`bg-emerald-50 text-emerald-700`,icon:Ur,label:n(`serviceAppsStatus_running`),tooltip:n(`serviceAppsStatusHint_running`)};case`starting`:return{className:`bg-blue-50 text-blue-700`,icon:be,iconClassName:`animate-spin`,label:n(`serviceAppsStatus_starting`),tooltip:n(`serviceAppsStatusHint_starting`)};case`failed`:return{className:`bg-rose-50 text-rose-700`,icon:ii,label:n(`serviceAppsStatus_failed`),tooltip:n(`serviceAppsStatusHint_failed`)};case`stopped`:return{className:`bg-gray-100 text-gray-600`,icon:Kr,label:n(`serviceAppsStatus_stopped`),tooltip:n(`serviceAppsStatusHint_stopped`)};default:return{className:`bg-slate-100 text-slate-600`,icon:Wr,label:n(`serviceAppsStatus_idle`),tooltip:n(`serviceAppsStatusHint_idle`)}}}function pa({disabled:e=!1,icon:t,label:n,tooltip:r=n,onClick:i}){return(0,H.jsxs)(we,{children:[(0,H.jsx)(xe,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,onClick:i,disabled:e,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:cursor-not-allowed disabled:text-gray-300 disabled:opacity-60 disabled:hover:bg-transparent`,"aria-label":n,children:(0,H.jsx)(t,{className:`h-3.5 w-3.5`})})}),(0,H.jsx)(Se,{side:`bottom`,className:`max-w-56 text-xs`,children:r})]})}function ma({destructive:t=!1,disabled:n=!1,icon:r,label:i,onClick:a}){return(0,H.jsxs)(`button`,{type:`button`,className:e(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,t?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),disabled:n,onClick:a,children:[(0,H.jsx)(r,{className:`h-4 w-4 shrink-0`}),(0,H.jsx)(`span`,{children:i})]})}function ha({app:e}){let t=[e.command,...e.args??[]].filter(e=>!!e?.trim()).join(` `),r=[{label:n(`serviceAppsCommand`),value:t},{label:n(`serviceAppsCwd`),value:e.cwd},{label:n(`serviceAppsManifest`),value:e.manifestPath},{label:n(`serviceAppsLastStarted`),value:e.lastStartedAt},{label:n(`serviceAppsLastReady`),value:e.lastReadyAt},{label:n(`serviceAppsLastFailed`),value:e.lastFailedAt}].filter(e=>e.value);return r.length===0?null:(0,H.jsx)(`dl`,{className:`mt-3 grid grid-cols-[4.5rem_minmax(0,1fr)] gap-x-2 gap-y-1 border-t border-gray-100 pt-2 text-[11px]`,children:r.map(e=>(0,H.jsx)(ga,{label:e.label,value:e.value},e.label))})}function ga({label:e,value:t}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`dt`,{className:`text-gray-400`,children:e}),(0,H.jsx)(`dd`,{className:`min-w-0 truncate font-mono text-gray-500`,title:t,children:t})]})}function _a({action:e,grants:t,onRevoke:r}){return(0,H.jsxs)(`div`,{className:`rounded bg-gray-50 px-2 py-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(oi,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-xs font-medium text-gray-800`,children:e.title??e.name}),e.description?(0,H.jsx)(`div`,{className:`truncate text-[11px] text-gray-500`,children:e.description}):null]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.runtimeState?(0,H.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-gray-600`,children:n(`serviceAppsRuntimeState_${e.runtimeState}`)}):null,(0,H.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-gray-600`,children:e.risk})]})]}),t.map(e=>(0,H.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2 pl-5`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-gray-500`,children:[(0,H.jsx)(ti,{className:`h-3 w-3 shrink-0 text-emerald-500`}),(0,H.jsxs)(`span`,{className:`truncate`,children:[n(`serviceAppsGrantedTo`),` `,e.caller.appId]})]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:`rounded-md p-1 text-gray-400 transition-colors hover:bg-white hover:text-rose-600`,title:n(`serviceAppsRevokeGrant`),"aria-label":n(`serviceAppsRevokeGrant`),children:(0,H.jsx)(ke,{className:`h-3 w-3`})})]},`${e.caller.surface}:${e.caller.appId}:${e.actionId}`))]})}function va({activeTab:e,onActiveTabChange:t,onOpenPanelApp:r}){let i=(0,H.jsx)(Ie,{value:e,onValueChange:e=>t(e),children:(0,H.jsxs)(Fe,{className:`grid h-auto w-[min(340px,100%)] grid-cols-2 rounded-lg bg-gray-100/70 p-0.5`,children:[(0,H.jsxs)(E,{value:`panel-apps`,className:`gap-1.5 px-2 py-1.5 text-xs`,children:[(0,H.jsx)(Vr,{className:`h-3.5 w-3.5`}),n(`panelAppsTitle`)]}),(0,H.jsxs)(E,{value:`service-apps`,className:`gap-1.5 px-2 py-1.5 text-xs`,children:[(0,H.jsx)($r,{className:`h-3.5 w-3.5`}),n(`serviceAppsTitle`)]})]})});return(0,H.jsx)(`div`,{className:`h-full min-h-0 bg-white`,children:e===`panel-apps`?(0,H.jsx)(Gi,{headerContent:i,onOpenPanelApp:r}):(0,H.jsx)(la,{headerContent:i})})}function ya({onOpenApps:e,onRefresh:t}){return(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:e,className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,children:[(0,H.jsx)(ve,{className:`h-3.5 w-3.5`}),n(`appsTitle`)]}),(0,H.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:n(`panelAppsRefreshCurrent`),"aria-label":n(`panelAppsRefreshCurrent`),children:(0,H.jsx)(Oe,{className:`h-3.5 w-3.5`})})]})}function ba(e){return e.split(`/`).map(e=>e.trim()).filter(e=>e.length>0)}function J(e){let t=e.trim();try{let e=new URL(t);return{authority:e.hostname,pathSegments:ba(e.pathname),pathname:e.pathname,raw:t,scheme:e.protocol.replace(/:$/,``).toLowerCase(),searchParams:e.searchParams}}catch{return{authority:``,pathSegments:ba(t),pathname:t,raw:t,scheme:``,searchParams:new URLSearchParams}}}var xa=class{constructor(e,t){this.routeDefinitions=e,this.options=t,this.resolve=e=>{let t=J(e);return this.findDefinition(t).resolve(t)},this.normalize=e=>this.options.getNormalizedUri(this.resolve(e)),this.areEquivalent=(e,t)=>this.findDefinition(J(e)).areEquivalent?.(e,t)??this.normalize(e)===this.normalize(t),this.findDefinition=e=>{let t=this.routeDefinitions.find(t=>t.match(e));if(!t)throw Error(`Unsupported resource URI: ${e.raw}`);return t}}},Sa=`home`,Ca=`nextclaw://new-tab`,wa=`apps`,Y=`nextclaw://apps`,Ta=`${Y}?tab=service-apps`,Ea=`panel-app`,Da=`panel-apps`;function Oa(e){return e===`panel-apps`||e===`service-apps`}function ka(e=Da){return e===Da?Y:Ta}function Aa(e){try{let t=new URL(e).searchParams.get(`tab`);return Oa(t)?t:Da}catch{return Da}}function ja(e){return ka(Aa(e))}function Ma(e){return`nextclaw://panel-app/${encodeURIComponent(e)}`}function Na(e){return e.startsWith(`data:image/`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)}function Pa(e){let t=e.icon?.trim();if(t)return Na(t)?{type:`url`,url:t}:{type:`text`,value:t}}function Fa(e){return{dedupeKey:`panel-app:${e.id}`,dockIcon:Pa(e),historyPolicy:`managed`,kind:Ea,resourceUri:Ma(e.id),title:e.title,url:e.contentPath}}function Ia(e,t){return e===t||e.startsWith(`${t}?`)||e.startsWith(`${t}/`)}function La(e){let t=e.pathSegments.join(`/`);return Re(t?`/${t}`:`/`,`docs`)}function Ra(e){let t=e.filter(e=>e.trim().length>0).map(e=>encodeURIComponent(decodeURIComponent(e))).join(`/`);return t?`nextclaw://docs/${t}`:`nextclaw://docs`}function za(e){let t=k(e),n=t.startsWith(`/`)?t:(()=>{try{return new URL(e).pathname}catch{return``}})();return n?Ra(n.split(`/`)):`nextclaw://docs`}function X(e){if(e.scheme===`nextclaw`&&e.authority===`panel-app`)return e.pathSegments[0]??``;let[t,n,r,i]=e.pathSegments;return t===`api`&&n===`panel-apps`&&r!==void 0&&r.length>0&&i===`content`?r:``}function Ba(e){return X(e).length>0}function Va(e){let t=X(e);return t?`/api/panel-apps/${encodeURIComponent(decodeURIComponent(t))}/content`:`nextclaw://panel-app`}function Ha(e){let t=X(e);return t?`nextclaw://panel-app/${encodeURIComponent(decodeURIComponent(t))}`:`nextclaw://panel-app`}function Ua(e,t){let n=J(e),r=J(t),i=X(n),a=X(r);return i.length>0&&a.length>0?decodeURIComponent(i)===decodeURIComponent(a):e===t}var Z=[{defaultUrl:()=>Ca,id:`home`,kind:Sa,match:e=>e.raw===Ca,resolve:()=>({historyPolicy:`managed`,kind:Sa,resourceUri:Ca,title:n(`docBrowserHomeTitle`),url:Ca}),areEquivalent:(e,t)=>e===t},{defaultUrl:O,id:`docs-url`,kind:`docs`,match:e=>Ve(e.raw),resolve:e=>{let t=Re(e.raw,`docs`);return{historyPolicy:`managed`,kind:`docs`,resourceUri:za(t),title:n(`docBrowserHelp`),url:t}},areEquivalent:(e,t)=>k(e)===k(t)},{defaultUrl:O,id:`nextclaw-docs`,kind:`docs`,match:e=>e.scheme===`nextclaw`&&e.authority===`docs`,resolve:e=>{let t=La(e);return{historyPolicy:`managed`,kind:`docs`,resourceUri:Ra(e.pathSegments),title:n(`docBrowserHelp`),url:t}},areEquivalent:(e,t)=>k(e)===k(t)},{defaultUrl:()=>Y,id:`apps`,kind:wa,match:e=>Ia(e.raw,Y),resolve:e=>{let t=ja(e.raw);return{dedupeKey:`apps`,historyPolicy:`managed`,kind:wa,resourceUri:t,title:n(t===`nextclaw://apps`?`appsTitle`:`serviceAppsTitle`),url:t}},areEquivalent:(e,t)=>ja(e)===ja(t)},{defaultUrl:()=>`nextclaw://panel-app`,id:`panel-app`,kind:Ea,match:e=>e.scheme===`nextclaw`&&e.authority===`panel-app`||Ba(e),resolve:e=>{let t=Va(e),r=X(e);return{dedupeKey:r?`panel-app:${decodeURIComponent(r)}`:void 0,historyPolicy:`managed`,kind:Ea,resourceUri:Ha(e),title:n(`panelAppsTitle`),url:t}},areEquivalent:Ua},{defaultUrl:()=>`about:blank`,id:`content`,kind:`content`,match:()=>!0,resolve:e=>({historyPolicy:`managed`,kind:`content`,resourceUri:e.raw||`about:blank`,title:We(e.raw,`content`,`Detail`),url:e.raw||`about:blank`}),areEquivalent:(e,t)=>e===t}],Wa=Z.map(e=>({areEquivalent:e.areEquivalent,id:e.id,match:e.match,resolve:e.resolve}));function Ga(){return[{id:`apps`,label:n(`appsTitle`),target:{type:`right-panel-resource`,uri:Y}},{id:`service-apps`,label:n(`serviceAppsTitle`),target:{type:`right-panel-resource`,uri:Ta}},{id:`docs`,label:n(`docBrowserHelp`),target:{options:{newTab:!0},type:`right-panel-resource`,uri:O()}},{id:`skill-marketplace`,label:n(`marketplaceSkillsPageTitle`),target:{path:`/marketplace/skills`,type:`app-route`}}]}var Ka={apps:{accentClassName:`bg-emerald-50 text-emerald-700`,hoverAccentClassName:`group-hover:bg-emerald-100`,icon:(0,H.jsx)(Te,{className:`h-5 w-5`})},"service-apps":{accentClassName:`bg-sky-50 text-sky-700`,hoverAccentClassName:`group-hover:bg-sky-100`,icon:(0,H.jsx)(Jr,{className:`h-5 w-5`})},docs:{accentClassName:`bg-amber-50 text-amber-700`,hoverAccentClassName:`group-hover:bg-amber-100`,icon:(0,H.jsx)(ye,{className:`h-5 w-5`})},"skill-marketplace":{accentClassName:`bg-rose-50 text-rose-700`,hoverAccentClassName:`group-hover:bg-rose-100`,icon:(0,H.jsx)(Hr,{className:`h-5 w-5`})}};function qa(e){return Ka[e.id]??{accentClassName:`bg-gray-50 text-gray-700`,hoverAccentClassName:`group-hover:bg-gray-100`,icon:(0,H.jsx)(Te,{className:`h-5 w-5`})}}function Ja({open:t}){let n=rn(),r=Ga(),i=e=>{if(e.type===`app-route`){n(e.path);return}t(e.uri,e.options)};return(0,H.jsx)(`div`,{className:`h-full overflow-auto bg-background px-4 py-5`,children:(0,H.jsx)(`div`,{className:`mx-auto w-full max-w-[520px]`,children:(0,H.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(76px,1fr))] gap-x-2 gap-y-4`,children:r.map(t=>{let n=qa(t);return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>i(t.target),className:`group flex min-h-[68px] flex-col items-center gap-1.5 rounded-md px-1.5 py-1.5 text-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,H.jsx)(`span`,{className:e(`flex h-10 w-10 shrink-0 items-center justify-center rounded-md transition-colors`,n.accentClassName,n.hoverAccentClassName),children:n.icon}),(0,H.jsx)(`span`,{className:`line-clamp-2 min-w-0 max-w-full text-xs font-medium leading-snug text-gray-700 transition-colors group-hover:text-gray-900`,children:t.label})]},t.id)})})})})}function Ya(e){return e&&Ve(e)?`docs`:`content`}var Xa=class{constructor(){this.resourceUriResolver=new xa(Wa,{getNormalizedUri:e=>e.resourceUri??e.url}),this.resolve=e=>this.resourceUriResolver.resolve(e),this.normalize=e=>this.resourceUriResolver.normalize(e),this.areEquivalent=(e,t)=>this.resourceUriResolver.areEquivalent(e,t),this.resolveOpenTarget=e=>{let{activeTab:t,kind:n,url:r}=e,i=this.resolveRouteDefinition(r,n,t),a=r?.trim()||(!n&&t&&t.kind!==`docs`?t.currentUrl:i.defaultUrl());return i.resolve(J(a))},this.areUrlsEquivalent=(e,t,n,r)=>n===r?this.resolveRouteDefinition(e,n).areEquivalent?.(e,t)??this.areEquivalent(e,t):!1,this.usesManagedHistory=e=>this.resolveRouteDefinition(e.currentUrl,e.kind).resolve(J(e.currentUrl)).historyPolicy===`managed`,this.resolveRouteDefinition=(e,t,n)=>{let r=t??(e?void 0:n?.kind),i=r?Z.find(e=>e.kind===r):void 0;if(i)return i;let a=e?J(e):null,o=a?Z.find(e=>e.match(a)):void 0;if(o)return o;let s=t??n?.kind??Ya(e);return Z.find(e=>e.kind===s)??Z[Z.length-1]}}},Za=wa,Qa=Ea,$a=`panel-apps`,eo=[`allow-scripts`,`allow-forms`,`allow-modals`,`allow-popups`,`allow-popups-to-escape-sandbox`,`allow-downloads`,`allow-pointer-lock`,`allow-presentation`].join(` `);function to(e){return e===`panel-apps`||e===`service-apps`}function no(e=$a){return e===$a?Y:Ta}function ro(e){try{let t=new URL(e).searchParams.get(`tab`);return to(t)?t:$a}catch{return $a}}function io(e){e.open(no(),{kind:Za,title:n(`appsTitle`),dedupeKey:`apps`})}var ao={[Sa]:{getTitle:()=>n(`docBrowserHomeTitle`),renderContent:({open:e})=>(0,H.jsx)(Ja,{open:e})},[Za]:{getTitle:()=>n(`appsTitle`),renderIcon:()=>(0,H.jsx)(Te,{className:`w-4 h-4 text-primary shrink-0`}),renderContent:({currentUrl:e,open:t,openTarget:r})=>(0,H.jsx)(va,{activeTab:ro(e),onActiveTabChange:e=>t(no(e),{activate:!1,kind:Za,title:n(`appsTitle`),dedupeKey:`apps`}),onOpenPanelApp:e=>r(Fa(e))})},[Qa]:{getIframeSandbox:()=>eo,getTitle:e=>e.title||n(`panelAppsTitle`),onIframeMessage:e=>Zo().panelAppBridgeManager.handleIframeMessage(e),renderIcon:()=>(0,H.jsx)(Vr,{className:`w-4 h-4 text-primary shrink-0`}),renderToolbar:({open:e,refreshIframe:t})=>(0,H.jsx)(ya,{onOpenApps:()=>io({open:e}),onRefresh:t})}},oo=`nextclaw://docs`;function so(){return[{builtIn:!0,icon:{type:`builtin`,name:`apps`},id:`apps`,label:n(`appsTitle`),removable:!1,target:{type:`right-panel-resource`,uri:Y}},{builtIn:!0,icon:{type:`builtin`,name:`service-apps`},id:`service-apps`,label:n(`serviceAppsTitle`),removable:!1,target:{type:`right-panel-resource`,uri:Ta}},{builtIn:!0,icon:{type:`builtin`,name:`docs`},id:`docs`,label:n(`docBrowserHelp`),removable:!1,target:{type:`right-panel-resource`,uri:oo}},{builtIn:!0,icon:{type:`builtin`,name:`new-tab`},id:`new-tab`,label:n(`docBrowserHomeTitle`),removable:!1,target:{type:`right-panel-resource`,uri:Ca}}]}var co=[`apps`,`docs`,`new-tab`,`panel-app`,`service-apps`];function lo(e){return!!e&&typeof e==`object`}function uo(e){return co.includes(e)}function fo(e){return!lo(e)||typeof e.type!=`string`?null:e.type===`builtin`&&uo(e.name)?{type:`builtin`,name:e.name}:e.type===`url`&&typeof e.url==`string`&&e.url.trim().length>0?{type:`url`,url:e.url.trim()}:e.type===`text`&&typeof e.value==`string`&&e.value.trim().length>0?{type:`text`,value:e.value.trim()}:null}function po(e){if(!lo(e)||typeof e.id!=`string`||e.id.trim().length===0||typeof e.label!=`string`||e.label.trim().length===0||typeof e.createdAt!=`string`||e.createdAt.trim().length===0||!lo(e.target)||e.target.type!==`right-panel-resource`||typeof e.target.uri!=`string`||e.target.uri.trim().length===0)return null;let t=fo(e.icon);return t?{createdAt:e.createdAt,icon:t,id:e.id.trim(),label:e.label.trim(),target:{type:`right-panel-resource`,uri:e.target.uri.trim()}}:null}function mo(e){if(!Array.isArray(e))return[];let t=new Map;return e.forEach(e=>{let n=po(e);n&&t.set(n.id,n)}),Array.from(t.values())}function ho(e,t){return{createdAt:t,icon:e.icon,id:e.id,label:e.label,target:e.target}}function go(e){return{builtIn:!1,icon:e.icon,id:e.id,label:e.label,removable:!0,target:e.target}}function _o(e,t){let n=new Set(e.map(e=>e.id)),r=new Set(e.map(e=>e.target.uri)),i=t.filter(e=>!n.has(e.id)&&!r.has(e.target.uri)).map(go);return[...e,...i]}var vo=`nextclaw.side-dock.state`,yo=1;function bo(e){return!!e&&typeof e==`object`}var xo=s()(Le(e=>({pinnedItems:[],setPinnedItems:t=>e({pinnedItems:mo(t)})}),{name:vo,version:yo,storage:Ke(()=>window.localStorage),partialize:e=>({pinnedItems:e.pinnedItems}),merge:(e,t)=>{let n=bo(e)?mo(e.pinnedItems):[];return{...t,pinnedItems:n}}})),So={apps:Te,docs:ye,"new-tab":De,"panel-app":Vr,"service-apps":Vr};function Co({icon:e}){if(e.type===`url`)return(0,H.jsx)(`img`,{src:e.url,alt:``,className:`h-5 w-5 rounded object-cover`});if(e.type===`text`)return(0,H.jsx)(`span`,{className:`max-w-7 truncate text-center text-[13px] font-semibold leading-none`,"aria-hidden":`true`,children:e.value});let t=So[e.name];return(0,H.jsx)(t,{className:`h-5 w-5`,"aria-hidden":`true`})}function wo({active:t,item:r,onOpen:i,onUnpin:a}){let{label:o}=r;return(0,H.jsxs)(we,{children:[(0,H.jsxs)(`div`,{className:`group relative`,children:[(0,H.jsx)(xe,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":o,title:o,"data-side-dock-item-id":r.id,onClick:()=>i(r),className:e(`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors`,`hover:bg-primary/10 hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,t?`bg-primary/10 text-primary`:`bg-transparent`),children:(0,H.jsx)(Co,{icon:r.icon})})}),r.removable?(0,H.jsx)(`button`,{type:`button`,"aria-label":n(`sideDockUnpinItem`),title:n(`sideDockUnpinItem`),onClick:e=>{e.stopPropagation(),a(r)},className:`absolute -right-1 -top-1 hidden h-4 w-4 items-center justify-center rounded-full bg-background text-muted-foreground shadow-sm ring-1 ring-border/70 transition-colors hover:bg-muted hover:text-foreground group-hover:flex focus-visible:flex focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,H.jsx)(Ae,{className:`h-3 w-3`,"aria-hidden":`true`})}):null]}),(0,H.jsx)(Se,{side:`left`,children:o})]})}function To(e){return e?.trim()??``}function Eo(e,t,n,r=!1){if(!t||!n)return!1;let i=To(e.target.uri),a=To(n.resourceUri);return a&&a===i||To(n.currentUrl)===i?!0:r?!1:e.id===`docs`&&n.kind===`docs`}function Do(e,t){if(!t)return!1;let n=To(t.resourceUri),r=To(t.currentUrl);return e.some(e=>{let t=To(e.target.uri);return t===n||t===r})}function Oo({manager:e}){let t=xo(e=>e.pinnedItems),{currentTab:n,isOpen:r}=He(),i=_o(so(),t),a=Do(i,n);return(0,H.jsx)(Ce,{delayDuration:250,children:(0,H.jsx)(`aside`,{"data-testid":`side-dock`,className:`z-30 flex h-full w-14 shrink-0 flex-col items-center gap-1 border-l border-border/60 bg-background/95 px-2 py-3`,children:i.map(t=>(0,H.jsx)(wo,{active:Eo(t,r,n,a),item:t,onOpen:e.openItem,onUnpin:t=>e.unpinItem(t.id)},t.id))})})}var ko=`pinned`,Ao=new Set([`apps`,`docs`,`new-tab`,`panel-app`,`service-apps`]);function Q(e){return e.trim()}function jo(e){let t=0;return Array.from(Q(e)).forEach(e=>{t=t*31+e.charCodeAt(0)>>>0}),`${ko}-${Q(e).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``).toLowerCase()||`resource`}-${t.toString(36)}`}function Mo(e){return e?.type===`builtin`&&Ao.has(e.name)?{type:`builtin`,name:e.name}:e?.type===`url`&&e.url.trim().length>0?{type:`url`,url:e.url.trim()}:e?.type===`text`&&e.value.trim().length>0?{type:`text`,value:e.value.trim()}:null}function No(e){return e.kind===`docs`?`docs`:e.kind===`home`?`new-tab`:e.kind===`apps`?e.resourceUri?.includes(`service-apps`)?`service-apps`:`apps`:e.kind===`panel-app`?`panel-app`:`apps`}var Po=class{constructor(e){this.docBrowserManager=e,this.getItems=()=>_o(so(),xo.getState().pinnedItems),this.openItem=e=>{e.target.type===`right-panel-resource`&&this.docBrowserManager.open(e.target.uri,{dockIcon:e.icon,title:e.label})},this.getDockState=e=>{let t=this.getTabResourceUri(e);if(!t)return{canDock:!1,isDocked:!1,removable:!1};let n=this.findItemByUri(t);return{canDock:!0,isDocked:!!n,removable:n?.removable===!0}},this.pinTab=(e,t=new Date().toISOString())=>{let n=this.getTabResourceUri(e);!e||!n||this.findItemByUri(n)||this.pinItem({builtIn:!1,icon:Mo(e.dockIcon)??{type:`builtin`,name:No(e)},id:jo(n),label:e.title.trim()||n,removable:!0,target:{type:`right-panel-resource`,uri:n}},t)},this.unpinTab=e=>{let t=this.getTabResourceUri(e),n=t?this.findItemByUri(t):void 0;n?.removable&&this.unpinItem(n.id)},this.pinItem=(e,t=new Date().toISOString())=>{if(!e.removable)return;let n=Q(e.target.uri);this.setPinnedItems(r=>r.some(t=>t.id===e.id||Q(t.target.uri)===n)?r:[...r,ho({...e,target:{...e.target,uri:n}},t)])},this.unpinItem=e=>{this.setPinnedItems(t=>t.filter(t=>t.id!==e))},this.reorderPinnedItems=e=>{this.setPinnedItems(t=>{let n=new Map(t.map(e=>[e.id,e])),r=e.map(e=>n.get(e)).filter(e=>e!==void 0),i=new Set(r.map(e=>e.id)),a=t.filter(e=>!i.has(e.id));return[...r,...a]})},this.setPinnedItems=e=>{let{pinnedItems:t,setPinnedItems:n}=xo.getState();n(e(t))},this.getTabResourceUri=e=>{let t=e?.resourceUri??e?.currentUrl,n=t?Q(t):``;return n.length>0?n:null},this.findItemByUri=e=>{let t=Q(e);return this.getItems().find(e=>Q(e.target.uri)===t)}}},Fo=new class{constructor(){this.resolveOpenTarget=e=>{let{activeTab:t,kind:r,url:i}=e,a=r??(i?void 0:t?.kind)??(i&&Ve(i)?`docs`:`home`),o=i?.trim()||(!r&&t&&t.kind!==`docs`?t.currentUrl:a===`home`?`nextclaw://new-tab`:a===`docs`?O():`about:blank`),s=a===`docs`?Re(o,`docs`):o;return{historyPolicy:`managed`,kind:a,title:a===`home`?n(`docBrowserHomeTitle`):We(s,a,a===`docs`?n(`docBrowserHelp`):`Detail`),url:s}},this.areUrlsEquivalent=(e,t,n,r)=>n===r?n===`docs`?k(e)===k(t):e===t:!1,this.usesManagedHistory=e=>e.currentUrl!==Be}};function Io(e,t,n){return{...e,tabs:e.tabs.map(e=>e.id===t?n(e):e)}}function Lo(e,t){return Io(e,e.activeTabId,t)}function Ro(e,t){let n=[...e.history.slice(0,e.historyIndex+1),t];return{history:n,historyIndex:n.length-1}}function zo(e,t,n){let r=t.resourceUri??t.url,i=n.resourceUri??n.url;return t.tabId===n.tabId&&t.kind===n.kind&&e.areUrlsEquivalent(r,i,t.kind,n.kind)}function Bo(e,t){return{kind:t.kind,resourceUri:t.resourceUri??t.url,tabId:e,url:t.url}}function $(e,t,n){let r=t.activeHistory[t.activeHistoryIndex];if(r&&zo(e,r,n))return t;let i=[...t.activeHistory.slice(0,t.activeHistoryIndex+1),n];return{...t,activeHistory:i,activeHistoryIndex:i.length-1}}function Vo(e,t,n){for(let r=t.history.length-1;r>=0;--r)if(e.areUrlsEquivalent(t.history[r],n,t.kind,t.kind))return r;return-1}function Ho(e,t,n){let r=t.tabs.find(e=>e.id===n.tabId);if(!r)return t;let i=n.resourceUri??n.url,a=e.resolveOpenTarget({activeTab:r,kind:n.kind,url:i}),o=Vo(e,r,a.url),s=n.resourceUri!==void 0&&n.resourceUri===r.resourceUri;return Io({...t,activeTabId:r.id,isOpen:!0},r.id,e=>({...e,currentUrl:a.url,dedupeKey:a.dedupeKey,dockIcon:a.dockIcon??e.dockIcon,historyIndex:o>=0?o:e.historyIndex,kind:a.kind,resourceUri:a.resourceUri??a.url,title:s?e.title:a.title}))}function Uo(e,t,n,r,i){let a={...t,title:r?.title||n.title||t.title,kind:n.kind,resourceUri:n.resourceUri??n.url,dockIcon:r?.dockIcon??n.dockIcon,dedupeKey:i};return e.areUrlsEquivalent(t.currentUrl,n.url,t.kind,n.kind)?a:{...a,currentUrl:n.url,...Ro(t,n.url),navVersion:t.navVersion+1}}function Wo(e,t){return!e.isOpen&&e.tabs.length===1&&t?.kind===`home`&&t.currentUrl===`nextclaw://new-tab`}function Go(e,t,n,r){let{activate:i,dedupeKey:a,newTab:o,title:s}=r??{},c=a?.trim()||n.dedupeKey,l=t.tabs.find(e=>e.id===t.activeTabId)??t.tabs[0],u=c?t.tabs.find(e=>e.dedupeKey===c):void 0;if(u){let a=Io(t,u.id,t=>Uo(e,t,n,r,c)),o=i!==!1,s=o?u.id:t.activeTabId,l={...a,activeTabId:s,isOpen:!0};return o||u.id===t.activeTabId?$(e,l,Bo(u.id,n)):l}if(o||c||!l||l.kind!==n.kind){let i=Ue(n.url,n.kind,s??n.title,c,n.resourceUri??n.url,r?.dockIcon??n.dockIcon);return Wo(t,l)?{...t,isOpen:!0,tabs:[i],activeTabId:i.id,activeHistory:[D(i)],activeHistoryIndex:0}:$(e,{...t,isOpen:!0,tabs:[...t.tabs,i],activeTabId:i.id},D(i))}return $(e,{...Lo(t,t=>Uo(e,t,n,r,c)),isOpen:!0},Bo(t.activeTabId,n))}function Ko(e,t,n,r){let i=t.tabs.find(e=>e.id===t.activeTabId)??t.tabs[0];return Go(e,t,e.resolveOpenTarget({activeTab:i,kind:r?.kind,url:n}),r)}var qo=class{constructor(e=Fo){this.routeResolver=e,this.setSnapshot=e=>{Ge.getState().setSnapshot(e)},this.open=(e,t)=>{this.setSnapshot(n=>Ko(this.routeResolver,n,e,t))},this.openTarget=(e,t)=>{this.setSnapshot(n=>Go(this.routeResolver,n,e,{...t,dedupeKey:t?.dedupeKey??e.dedupeKey,kind:t?.kind??e.kind,title:t?.title??e.title}))},this.openNewTab=()=>{this.open(void 0,{kind:qe,newTab:!0})},this.close=()=>{this.setSnapshot(e=>({...e,isOpen:!1}))},this.toggleMode=()=>{this.setSnapshot(e=>({...e,mode:e.mode===`floating`?`docked`:`floating`}))},this.navigate=e=>{this.setSnapshot(t=>{if(!t.tabs.length){let e=Ue(O(),`docs`,`Docs`);return{...t,tabs:[e],activeTabId:e.id,isOpen:!0}}let n=Lo(t,t=>{if(!this.routeResolver.usesManagedHistory(t))return t;let n=this.routeResolver.resolveOpenTarget({activeTab:t,url:e});return this.routeResolver.areUrlsEquivalent(t.currentUrl,n.url,t.kind,n.kind)?t:{...t,currentUrl:n.url,dedupeKey:n.dedupeKey,dockIcon:n.dockIcon,...Ro(t,n.url),kind:n.kind,navVersion:t.navVersion+1,resourceUri:n.resourceUri??n.url,title:n.title}}),r=n.tabs.find(e=>e.id===n.activeTabId);return r?$(this.routeResolver,n,D(r)):n})},this.syncUrl=e=>{this.setSnapshot(t=>{if(!t.tabs.length){let e=Ue(O(),`docs`,`Docs`);return{...t,tabs:[e],activeTabId:e.id}}let n=Lo(t,t=>{if(!this.routeResolver.usesManagedHistory(t))return t;let n=this.routeResolver.resolveOpenTarget({activeTab:t,kind:t.kind,url:e});return this.routeResolver.areUrlsEquivalent(t.currentUrl,n.url,t.kind,n.kind)?t:{...t,currentUrl:n.url,dedupeKey:n.dedupeKey,dockIcon:n.dockIcon,...Ro(t,n.url),kind:n.kind,resourceUri:n.resourceUri??n.url,title:n.title}}),r=n.tabs.find(e=>e.id===n.activeTabId);return r?$(this.routeResolver,n,D(r)):n})},this.goBack=()=>{this.setSnapshot(e=>{if(e.activeHistoryIndex<=0)return e;let t=e.activeHistoryIndex-1,n=e.activeHistory[t];return n?Ho(this.routeResolver,{...e,activeHistoryIndex:t},n):e})},this.goForward=()=>{this.setSnapshot(e=>{if(e.activeHistoryIndex>=e.activeHistory.length-1)return e;let t=e.activeHistoryIndex+1,n=e.activeHistory[t];return n?Ho(this.routeResolver,{...e,activeHistoryIndex:t},n):e})},this.closeTab=e=>{this.setSnapshot(t=>{if(t.tabs.length<=1)return{...ze(),isOpen:!1};let n=t.tabs.findIndex(t=>t.id===e);if(n<0)return t;let r=t.tabs.filter(t=>t.id!==e),i=t.activeTabId===e?r[Math.max(0,n-1)]?.id??r[0].id:t.activeTabId,a={...t,tabs:r,activeTabId:i},o=a.activeHistory.filter(t=>t.tabId!==e),s=a.activeHistory.slice(0,a.activeHistoryIndex+1).filter(t=>t.tabId!==e),c=r.find(e=>e.id===i)??r[0],l={...a,activeHistory:o.length>0?o:[D(c)],activeHistoryIndex:Math.min(Math.max(0,s.length-1),Math.max(0,o.length-1))};return t.activeTabId===e?$(this.routeResolver,l,D(c)):l})},this.setActiveTab=e=>{this.setSnapshot(t=>{if(!t.tabs.some(t=>t.id===e))return t;let n=t.tabs.find(t=>t.id===e);return n?$(this.routeResolver,{...t,activeTabId:e,isOpen:!0},D(n)):t})}}},Jo=class{constructor(){this.accountManager=new Ei,this.rightPanelResourceRouteResolver=new Xa,this.docBrowserManager=new qo(this.rightPanelResourceRouteResolver),this.sideDockManager=new Po(this.docBrowserManager),this.serviceActionAuthorizationManager=new Qi,this.panelAppBridgeManager=new Ki(this.serviceActionAuthorizationManager),this.remoteAccessManager=new hi({accountManager:this.accountManager})}},Yo=null;function Xo(){return Yo??=new Jo,Yo}function Zo(){return Xo()}var Qo=(0,A.createContext)(null);function $o({children:e}){let t=(0,A.useMemo)(()=>Xo(),[]);return(0,H.jsx)(Qo.Provider,{value:t,children:e})}function es(){let e=(0,A.useContext)(Qo);if(!e)throw Error(`useAppPresenter must be used inside AppPresenterProvider`);return e}export{Cr as A,ii as C,Ur as D,qr as E,Pn as F,V as I,rn as L,wr as M,jn as N,Hr as O,Mn as P,on as R,oi as S,Qr as T,G as _,xo as a,ci as b,Yi as c,bi as d,yi as f,W as g,li as h,Oo as i,An as j,br as k,Ti as l,K as m,es as n,ao as o,hi as p,Zo as r,io as s,$o as t,wi as u,fi as v,ti as w,si as x,mi as y,Ze as z};
|
|
3
|
+
Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let f=V(),p;if(t){let e=typeof t==`string`?P(t):t;j(u===`/`||e.pathname?.startsWith(u),`When overriding the location using \`<Routes location>\` 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 "${u}" but pathname "${e.pathname}" was given in the \`location\` prop.`),p=e}else p=f;let m=p.pathname||`/`,h=m;if(u!==`/`){let e=u.replace(/^\//,``).split(`/`);h=`/`+m.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let g=ot(e,{pathname:h});M(d||g!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),M(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 "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let _=gn(g&&g.map(e=>Object.assign({},e,{params:Object.assign({},c,e.params),pathname:I([u,a.encodeLocation?a.encodeLocation(e.pathname.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?u:I([u,a.encodeLocation?a.encodeLocation(e.pathnameBase.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),o,n,r,i);return t&&_?A.createElement(qt.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,...p},navigationType:`POP`}},_):_}function un(){let e=Tn(),t=It(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)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=A.createElement(A.Fragment,null,A.createElement(`p`,null,`💿 Hey developer 👋`),A.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,A.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,A.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),A.createElement(A.Fragment,null,A.createElement(`h2`,null,`Unexpected Application Error!`),A.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?A.createElement(`pre`,{style:i},n):null,o)}var dn=A.createElement(un,null),fn=class extends A.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?t.error:e.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`){let t=$t(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:A.createElement(z.Provider,{value:this.props.routeContext},A.createElement(Jt.Provider,{value:e,children:this.props.component}));return this.context?A.createElement(mn,{error:e},t):t}};fn.contextType=Ut;var pn=new WeakMap;function mn({children:e,error:t}){let{basename:n}=A.useContext(R);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=Qt(t.digest);if(e){let r=pn.get(t);if(r)throw r;let i=zt(e.location,n);if(Rt&&!pn.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw pn.set(t,n),n}return A.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function hn({routeContext:e,match:t,children:n}){let r=A.useContext(L);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),A.createElement(z.Provider,{value:e},n)}function gn(e,t=[],n=null,r=null,i=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,o=n?.errors;if(o!=null){let e=a.findIndex(e=>e.route.id&&o?.[e.route.id]!==void 0);j(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(`,`)}`),a=a.slice(0,Math.min(a.length,e+1))}let s=!1,c=-1;if(n)for(let e=0;e<a.length;e++){let t=a[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(c=e),t.route.id){let{loaderData:e,errors:r}=n,i=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!r||r[t.route.id]===void 0);if(t.route.lazy||i){s=!0,a=c>=0?a.slice(0,c+1):[a[0]];break}}}let l=n&&r?(e,t)=>{r(e,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:Lt(n.matches),errorInfo:t})}:void 0;return a.reduceRight((e,r,i)=>{let u,d=!1,f=null,p=null;n&&(u=o&&r.route.id?o[r.route.id]:void 0,f=r.route.errorElement||dn,s&&(c<0&&i===0?(On(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):c===i&&(d=!0,p=r.route.hydrateFallbackElement||null)));let m=t.concat(a.slice(0,i+1)),h=()=>{let t;return t=u?f:d?p:r.route.Component?A.createElement(r.route.Component,null):r.route.element?r.route.element:e,A.createElement(hn,{match:r,routeContext:{outlet:e,matches:m,isDataRoute:n!=null},children:t})};return n&&(r.route.ErrorBoundary||r.route.errorElement||i===0)?A.createElement(fn,{location:n.location,revalidation:n.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function _n(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function vn(e){let t=A.useContext(L);return j(t,_n(e)),t}function yn(e){let t=A.useContext(Ht);return j(t,_n(e)),t}function bn(e){let t=A.useContext(z);return j(t,_n(e)),t}function xn(e){let t=bn(e),n=t.matches[t.matches.length-1];return j(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Sn(){return xn(`useRouteId`)}function Cn(){return yn(`useNavigation`).navigation}function wn(){let{matches:e,loaderData:t}=yn(`useMatches`);return A.useMemo(()=>e.map(e=>ct(e,t)),[e,t])}function Tn(){let e=A.useContext(Jt),t=yn(`useRouteError`),n=xn(`useRouteError`);return e===void 0?t.errors?.[n]:e}function En(){let{router:e}=vn(`useNavigate`),t=xn(`useNavigate`),n=A.useRef(!1);return nn(()=>{n.current=!0}),A.useCallback(async(r,i={})=>{M(n.current,tn),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var Dn={};function On(e,t,n){!t&&!Dn[e]&&(Dn[e]=!0,M(!1,n))}A.useOptimistic,A.memo(kn);function kn({routes:e,future:t,state:n,onError:r}){return ln(e,void 0,n,r,t)}function An({basename:e,children:t,initialEntries:n,initialIndex:r,unstable_useTransitions:i}){let a=A.useRef();a.current??=$e({initialEntries:n,initialIndex:r,v5Compat:!0});let o=a.current,[s,c]=A.useState({action:o.action,location:o.location}),l=A.useCallback(e=>{i===!1?c(e):A.startTransition(()=>c(e))},[i]);return A.useLayoutEffect(()=>o.listen(l),[o,l]),A.createElement(Nn,{basename:e,children:t,location:s.location,navigationType:s.action,navigator:o,unstable_useTransitions:i})}function jn({to:e,replace:t,state:n,relative:r}){j(B(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=A.useContext(R);M(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=A.useContext(z),{pathname:o}=V(),s=rn(),c=jt(e,At(a),o,r===`path`),l=JSON.stringify(c);return A.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function Mn(e){j(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function Nn({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:o}){j(!B(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=A.useMemo(()=>({basename:s,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=P(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`}=n,m=A.useMemo(()=>{let e=F(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p},navigationType:r}},[s,l,u,d,f,p,r]);return M(m!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),m==null?null:A.createElement(R.Provider,{value:c},A.createElement(qt.Provider,{children:t,value:m}))}function Pn({children:e,location:t}){return cn(Fn(e),t)}A.Component;function Fn(e,t=[]){let n=[];return A.Children.forEach(e,(e,r)=>{if(!A.isValidElement(e))return;let i=[...t,r];if(e.type===A.Fragment){n.push.apply(n,Fn(e.props.children,i));return}j(e.type===Mn,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),j(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=Fn(e.props.children,i)),n.push(a)}),n}var In=`get`,Ln=`application/x-www-form-urlencoded`;function Rn(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function zn(e){return Rn(e)&&e.tagName.toLowerCase()===`button`}function Bn(e){return Rn(e)&&e.tagName.toLowerCase()===`form`}function Vn(e){return Rn(e)&&e.tagName.toLowerCase()===`input`}function Hn(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Un(e,t){return e.button===0&&(!t||t===`_self`)&&!Hn(e)}var Wn=null;function Gn(){if(Wn===null)try{new FormData(document.createElement(`form`),0),Wn=!1}catch{Wn=!0}return Wn}var Kn=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function qn(e){return e!=null&&!Kn.has(e)?(M(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ln}"`),null):e}function Jn(e,t){let n,r,i,a,o;if(Bn(e)){let o=e.getAttribute(`action`);r=o?F(o,t):null,n=e.getAttribute(`method`)||In,i=qn(e.getAttribute(`enctype`))||Ln,a=new FormData(e)}else if(zn(e)||Vn(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?F(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||In,i=qn(e.getAttribute(`formenctype`))||qn(o.getAttribute(`enctype`))||Ln,a=new FormData(o,e),!Gn()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(Rn(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=In,r=null,i=Ln,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Yn={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},Xn=/[&><\u2028\u2029]/g;function Zn(e){return e.replace(Xn,e=>Yn[e])}function Qn(e,t){if(e===!1||e==null)throw Error(t)}function $n(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&F(i.pathname,t)===`/`?i.pathname=`${t.replace(/\/$/,``)}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,``)}.${r}`,i}async function er(e,t){if(e.id in t)return t[e.id];try{let n=await Ze(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function tr(e){return e!=null&&typeof e.page==`string`}function nr(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function rr(e,t,n){return cr((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await er(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(nr).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function ir(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function ar(e,t,{includeHydrateFallback:n}={}){return or(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function or(e){return[...new Set(e)]}function sr(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function cr(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!tr(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(sr(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function lr(){let e=A.useContext(L);return Qn(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function ur(){let e=A.useContext(Ht);return Qn(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var dr=A.createContext(void 0);dr.displayName=`FrameworkContext`;function fr(){let e=A.useContext(dr);return Qn(e,`You must render this element inside a <HydratedRouter> element`),e}function pr(e,t){let n=A.useContext(dr),[r,i]=A.useState(!1),[a,o]=A.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=A.useRef(null);A.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),A.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:mr(s,p),onBlur:mr(c,m),onMouseEnter:mr(l,p),onMouseLeave:mr(u,m),onTouchStart:mr(d,p)}]:[a,f,{}]:[!1,f,{}]}function mr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function hr({page:e,...t}){let{router:n}=lr(),r=A.useMemo(()=>ot(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?A.createElement(_r,{page:e,matches:r,...t}):null}function gr(e){let{manifest:t,routeModules:n}=fr(),[r,i]=A.useState([]);return A.useEffect(()=>{let r=!1;return rr(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function _r({page:e,matches:t,...n}){let r=V(),{future:i,manifest:a,routeModules:o}=fr(),{basename:s}=lr(),{loaderData:c,matches:l}=ur(),u=A.useMemo(()=>ir(e,t,l,a,r,`data`),[e,t,l,a,r]),d=A.useMemo(()=>ir(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=A.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=$n(e,s,i.unstable_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.unstable_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=A.useMemo(()=>ar(d,a),[d,a]),m=gr(d);return A.createElement(A.Fragment,null,f.map(e=>A.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>A.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>A.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function vr(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}A.Component;var yr=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{yr&&(window.__reactRouterVersion=`7.13.0`)}catch{}function br({basename:e,children:t,unstable_useTransitions:n,window:r}){let i=A.useRef();i.current??=et({window:r,v5Compat:!0});let a=i.current,[o,s]=A.useState({action:a.action,location:a.location}),c=A.useCallback(e=>{n===!1?s(e):A.startTransition(()=>s(e))},[n]);return A.useLayoutEffect(()=>a.listen(c),[a,c]),A.createElement(Nn,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}function xr({basename:e,children:t,history:n,unstable_useTransitions:r}){let[i,a]=A.useState({action:n.action,location:n.location}),o=A.useCallback(e=>{r===!1?a(e):A.startTransition(()=>a(e))},[r]);return A.useLayoutEffect(()=>n.listen(o),[n,o]),A.createElement(Nn,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,unstable_useTransitions:r})}xr.displayName=`unstable_HistoryRouter`;var Sr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Cr=A.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,state:o,target:s,to:c,preventScrollReset:l,viewTransition:u,unstable_defaultShouldRevalidate:d,...f},p){let{basename:m,unstable_useTransitions:h}=A.useContext(R),g=typeof c==`string`&&Sr.test(c),_=zt(c,m);c=_.to;let v=en(c,{relative:r}),[y,b,ee]=pr(n,f),te=Ar(c,{replace:a,state:o,target:s,preventScrollReset:l,relative:r,viewTransition:u,unstable_defaultShouldRevalidate:d,unstable_useTransitions:h});function x(t){e&&e(t),t.defaultPrevented||te(t)}let ne=A.createElement(`a`,{...f,...ee,href:_.absoluteURL||v,onClick:_.isExternal||i?e:x,ref:vr(p,b),target:s,"data-discover":!g&&t===`render`?`true`:void 0});return y&&!g?A.createElement(A.Fragment,null,ne,A.createElement(hr,{page:v})):ne});Cr.displayName=`Link`;var wr=A.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=sn(a,{relative:c.relative}),d=V(),f=A.useContext(Ht),{navigator:p,basename:m}=A.useContext(R),h=f!=null&&Br(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,_=d.pathname,v=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(_=_.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&m&&(v=F(v,m)||v);let y=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,b=_===g||!r&&_.startsWith(g)&&_.charAt(y)===`/`,ee=v!=null&&(v===g||!r&&v.startsWith(g)&&v.charAt(g.length)===`/`),te={isActive:b,isPending:ee,isTransitioning:h},x=b?e:void 0,ne;ne=typeof n==`function`?n(te):[n,b?`active`:null,ee?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let re=typeof i==`function`?i(te):i;return A.createElement(Cr,{...c,"aria-current":x,className:ne,ref:l,style:re,to:a,viewTransition:o},typeof s==`function`?s(te):s)});wr.displayName=`NavLink`;var Tr=A.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=In,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m)=>{let{unstable_useTransitions:h}=A.useContext(R),g=Nr(),_=Pr(s,{relative:l}),v=o.toLowerCase()===`get`?`get`:`post`,y=typeof s==`string`&&Sr.test(s);return A.createElement(`form`,{ref:m,method:v,action:_,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f});h&&n!==!1?A.startTransition(()=>p()):p()},...p,"data-discover":!y&&e===`render`?`true`:void 0})});Tr.displayName=`Form`;function Er({getKey:e,storageKey:t,...n}){let r=A.useContext(dr),{basename:i}=A.useContext(R),a=V(),o=wn();Rr({getKey:e,storageKey:t});let s=A.useMemo(()=>{if(!r||!e)return null;let t=Lr(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let c=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return A.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${Zn(JSON.stringify(t||Fr))}, ${Zn(JSON.stringify(s))})`}})}Er.displayName=`ScrollRestoration`;function Dr(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Or(e){let t=A.useContext(L);return j(t,Dr(e)),t}function kr(e){let t=A.useContext(Ht);return j(t,Dr(e)),t}function Ar(e,{target:t,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:s,unstable_useTransitions:c}={}){let l=rn(),u=V(),d=sn(e,{relative:a});return A.useCallback(f=>{if(Un(f,t)){f.preventDefault();let t=n===void 0?N(u)===N(d):n,p=()=>l(e,{replace:t,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:s});c?A.startTransition(()=>p()):p()}},[u,l,d,n,r,t,e,i,a,o,s,c])}var jr=0,Mr=()=>`__${String(++jr)}__`;function Nr(){let{router:e}=Or(`useSubmit`),{basename:t}=A.useContext(R),n=Sn(),r=e.fetch,i=e.navigate;return A.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=Jn(e,t);a.navigate===!1?await r(a.fetcherKey||Mr(),n,a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function Pr(e,{relative:t}={}){let{basename:n}=A.useContext(R),r=A.useContext(z);j(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...sn(e||`.`,{relative:t})},o=V();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:I([n,a.pathname])),N(a)}var Fr=`react-router-scroll-positions`,Ir={};function Lr(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:F(e.pathname,n)||e.pathname},t)),i??=e.key,i}function Rr({getKey:e,storageKey:t}={}){let{router:n}=Or(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=kr(`useScrollRestoration`),{basename:a}=A.useContext(R),o=V(),s=wn(),c=Cn();A.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),zr(A.useCallback(()=>{if(c.state===`idle`){let t=Lr(o,s,a,e);Ir[t]=window.scrollY}try{sessionStorage.setItem(t||Fr,JSON.stringify(Ir))}catch(e){M(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(A.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||Fr);e&&(Ir=JSON.parse(e))}catch{}},[t]),A.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(Ir,()=>window.scrollY,e?(t,n)=>Lr(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),A.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{M(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function zr(e,t){let{capture:n}=t||{};A.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function Br(e,{relative:t}={}){let n=A.useContext(Wt);j(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Or(`useViewTransitionState`),i=sn(e,{relative:t});if(!n.isTransitioning)return!1;let a=F(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=F(n.nextLocation.pathname,r)||n.nextLocation.pathname;return St(i.pathname,o)!=null||St(i.pathname,a)!=null}var Vr=w(`AppWindow`,[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]),Hr=w(`BrainCircuit`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M9 13a4.5 4.5 0 0 0 3-4`,key:`10igwf`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M12 13h4`,key:`1ku699`}],[`path`,{d:`M12 18h6a2 2 0 0 1 2 2v1`,key:`105ag5`}],[`path`,{d:`M12 8h8`,key:`1lhi5i`}],[`path`,{d:`M16 8V5a2 2 0 0 1 2-2`,key:`u6izg6`}],[`circle`,{cx:`16`,cy:`13`,r:`.5`,key:`ry7gng`}],[`circle`,{cx:`18`,cy:`3`,r:`.5`,key:`1aiba7`}],[`circle`,{cx:`20`,cy:`21`,r:`.5`,key:`yhc1fs`}],[`circle`,{cx:`20`,cy:`8`,r:`.5`,key:`1e43v0`}]]),Ur=w(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Wr=w(`CircleDashed`,[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]),Gr=w(`CircleHelp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Kr=w(`CirclePause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),qr=w(`EllipsisVertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Jr=w(`Grid3x3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),Yr=w(`Laptop`,[[`path`,{d:`M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16`,key:`tarvll`}]]),Xr=w(`LogOut`,[[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}],[`polyline`,{points:`16 17 21 12 16 7`,key:`1gabdz`}],[`line`,{x1:`21`,x2:`9`,y1:`12`,y2:`12`,key:`1uyos4`}]]),Zr=w(`Radar`,[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`,key:`z3du51`}],[`path`,{d:`M4 6h.01`,key:`oypzma`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`,key:`qzzz0`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`,key:`1yjesh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`,key:`1u2y91`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`m13.41 10.59 5.66-5.66`,key:`mhq4k0`}]]),Qr=w(`RefreshCcw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),$r=w(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),ei=w(`ShieldAlert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),ti=w(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ni=w(`SquareArrowOutUpRight`,[[`path`,{d:`M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6`,key:`y09zxi`}],[`path`,{d:`m21 3-9 9`,key:`mpx6sq`}],[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}]]),ri=w(`Star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),ii=w(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),ai=w(`Unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),oi=w(`Wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`,key:`cbrjhi`}]]);function si(){return b({queryKey:li,queryFn:ee,staleTime:5e3,refetchOnWindowFocus:!0})}var H=r();function U(e){let{label:t,muted:n,value:r}=e;return(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,H.jsx)(`span`,{className:`text-gray-500`,children:t}),(0,H.jsx)(`span`,{className:n?`text-right text-gray-500`:`text-right text-gray-900`,children:r==null||r===``?`-`:String(r)})]})}function ci(){let e=es(),t=si(),r=t.data,a=K(e=>e.actionLabel),o=(0,A.useMemo)(()=>bi(r),[r]),s=!!a,c=r?.runtime?.deviceName?.trim()||r?.settings.deviceName?.trim()||n(`remoteDeviceNameAuto`),u=!!(r?.account.loggedIn&&mi(r)),{hero:m,issueHint:g}=o;return(0,A.useEffect)(()=>{e.remoteAccessManager.syncStatus(r)},[e,r]),t.isLoading&&!r?(0,H.jsx)(`div`,{className:`p-8 text-gray-400`,children:n(`remoteLoading`)}):(0,H.jsxs)(h,{className:`space-y-6`,children:[(0,H.jsx)(re,{title:n(`remotePageTitle`),description:n(`remotePageDescription`)}),(0,H.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,H.jsxs)(f,{children:[(0,H.jsxs)(ie,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,H.jsx)(l,{children:m.title}),(0,H.jsx)(je,{status:m.badgeStatus,label:m.badgeLabel})]}),(0,H.jsx)(_,{children:m.description})]}),(0,H.jsxs)(d,{className:`space-y-5`,children:[(0,H.jsxs)(T,{tone:`neutral`,children:[(0,H.jsx)(U,{label:n(`remoteSignedInAccount`),value:r?.account.email}),(0,H.jsx)(U,{label:n(`remoteDeviceName`),value:c}),(0,H.jsx)(U,{label:n(`remoteConnectionStatus`),value:m.badgeLabel}),(0,H.jsx)(U,{label:n(`remoteLastConnectedAt`),value:r?.runtime?.lastConnectedAt?i(r.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[o.primaryAction?(0,H.jsxs)(p,{onClick:()=>{if(o.primaryAction?.kind===`reauthorize`){e.remoteAccessManager.reauthorizeRemoteAccess(r);return}if(o.primaryAction?.kind===`repair`){e.remoteAccessManager.repairRemoteAccess(r);return}e.remoteAccessManager.enableRemoteAccess(r)},disabled:s,children:[o.primaryAction.showRefreshIcon?(0,H.jsx)(Qr,{className:`mr-2 h-4 w-4`}):null,a||o.primaryAction.label]}):null,(0,H.jsxs)(p,{variant:`outline`,onClick:()=>void e.accountManager.openNextClawWeb(),disabled:s||!u,children:[(0,H.jsx)(ni,{className:`mr-2 h-4 w-4`}),n(`remoteOpenDeviceList`)]}),r?.settings.enabled?(0,H.jsx)(p,{variant:`outline`,onClick:()=>void e.remoteAccessManager.disableRemoteAccess(r),disabled:s,children:n(`remoteDisable`)}):null]}),o.shouldShowIssueHint&&g?(0,H.jsx)(T,{tone:`warning`,title:g.title,description:g.body}):null,(0,H.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`remoteOpenWebHint`)})]})]}),(0,H.jsxs)(f,{children:[(0,H.jsxs)(ie,{children:[(0,H.jsxs)(l,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Yr,{className:`h-4 w-4 text-primary`}),n(`remoteDeviceSectionTitle`)]}),(0,H.jsx)(_,{children:n(`remoteDeviceSectionDescription`)})]}),(0,H.jsxs)(d,{className:`space-y-5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(je,{status:r?.account.loggedIn?`ready`:`inactive`,label:r?.account.loggedIn?n(`remoteAccountConnected`):n(`remoteAccountNotConnected`)}),(0,H.jsx)(je,{status:r?.settings.enabled?`active`:`inactive`,label:r?.settings.enabled?n(`remoteEnabled`):n(`remoteStateDisabled`)}),(0,H.jsx)(je,{status:r?.service.running?`active`:`inactive`,label:r?.service.running?n(`remoteServiceRunning`):n(`remoteServiceStopped`)})]}),(0,H.jsxs)(T,{tone:`neutral`,children:[(0,H.jsx)(U,{label:n(`remoteDeviceName`),value:c}),(0,H.jsx)(U,{label:n(`remoteConnectionStatus`),value:m.badgeLabel}),(0,H.jsx)(U,{label:n(`remoteLastConnectedAt`),value:r?.runtime?.lastConnectedAt?i(r.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,H.jsx)(T,{tone:`neutral`,borderStyle:`dashed`,description:r?.account.loggedIn?n(`remoteOpenWebHint`):n(`remoteStatusNeedsSignInDescription`),className:`text-sm`})]})]})]})]})}var li=[`remote-status`],ui=`https://platform.nextclaw.io`,di=`https://nextclaw-platform-console.pages.dev`,W=async()=>await m.fetchQuery({queryKey:li,queryFn:ee,staleTime:5e3}),G=async()=>(await m.invalidateQueries({queryKey:li}),await W()),fi=(e,t)=>t?.trim()||e?.settings.platformApiBase?.trim()||e?.account.apiBase?.trim()||void 0;function pi(e){let t=e?.trim();if(!t)return;let n;try{n=new URL(t)}catch{return}if(n.hostname===`platform.nextclaw.io`||n.hostname===`nextclaw-platform-console.pages.dev`)return n.origin;if(n.hostname===`ai-gateway-api.nextclaw.io`)return ui;if(n.hostname.includes(`nextclaw-provider-gateway-api`)&&n.hostname.endsWith(`.workers.dev`))return di}var mi=e=>pi(e?.account.apiBase)||pi(e?.settings.platformApiBase)||pi(e?.platformBase)||pi(e?.account.platformBase)||void 0,K=s(e=>({enabled:!1,deviceName:``,platformApiBase:``,advancedOpen:!1,draftTouched:!1,actionLabel:null,doctor:null,setEnabled:t=>e({enabled:t,draftTouched:!0}),setDeviceName:t=>e({deviceName:t,draftTouched:!0}),setPlatformApiBase:t=>e({platformApiBase:t,draftTouched:!0}),setAdvancedOpen:t=>e({advancedOpen:t}),hydrateDraft:({enabled:t,deviceName:n,platformApiBase:r})=>e({enabled:t,deviceName:n,platformApiBase:r,draftTouched:!1}),beginAction:t=>e({actionLabel:t}),finishAction:()=>e({actionLabel:null}),setDoctor:t=>e({doctor:t})})),hi=class{constructor(e){this.params=e,this.syncStatus=e=>{if(!e)return;let t=K.getState();t.draftTouched||t.actionLabel||this.hydrateDraftFromStatus(e)},this.setEnabled=e=>{K.getState().setEnabled(e)},this.setDeviceName=e=>{K.getState().setDeviceName(e)},this.setPlatformApiBase=e=>{K.getState().setPlatformApiBase(e)},this.setAdvancedOpen=e=>{K.getState().setAdvancedOpen(e)},this.enableRemoteAccess=async e=>{let t=e??await G(),n=K.getState(),r=await this.ensureRemoteAccount(t,n.platformApiBase);await this.applyEnabledState(!0,r)},this.disableRemoteAccess=async e=>{let t=e??await G();await this.applyEnabledState(!1,t)},this.repairRemoteAccess=async e=>{let t=e??await G(),r=(await this.ensureRemoteAccount(t)).service.running?`restart`:`start`;await this.runManagedAction({actionLabel:n(r===`restart`?`remoteActionRestarting`:`remoteActionStarting`),job:async()=>{await ce(r);let e=await G();this.hydrateDraftFromStatus(e)},successMessage:n(`remoteServiceRecovered`)})},this.reauthorizeRemoteAccess=async e=>{let t=e??await G(),n=await this.params.accountManager.startBrowserSignInAndWait({status:t,apiBase:K.getState().platformApiBase});await this.repairRemoteAccess(n)},this.saveAdvancedSettings=async e=>{let t=e??await G(),r=K.getState();await this.runManagedAction({actionLabel:n(`remoteActionSavingAdvanced`),job:async()=>{await ue({enabled:r.enabled,deviceName:r.deviceName.trim(),platformApiBase:r.platformApiBase.trim()});let e=await G();this.hydrateDraftFromStatus(e)},successMessage:t.settings.enabled===r.enabled?n(`remoteSettingsSaved`):n(`remoteAdvancedSaved`)})},this.runDoctor=async()=>{await this.runManagedAction({actionLabel:n(`remoteDoctorRunning`),job:async()=>{let e=await ne();K.getState().setDoctor(e)},successMessage:n(`remoteDoctorCompleted`)})},this.startService=async()=>{await this.runServiceAction(`start`,n(`remoteActionStarting`))},this.restartService=async()=>{await this.runServiceAction(`restart`,n(`remoteActionRestarting`))},this.stopService=async()=>{await this.runServiceAction(`stop`,n(`remoteActionStopping`))},this.applyEnabledState=async(e,t)=>{let r=K.getState();await this.runManagedAction({actionLabel:n(e?`remoteActionEnabling`:`remoteActionDisabling`),job:async()=>{await ue({enabled:e,deviceName:r.deviceName.trim(),platformApiBase:r.platformApiBase.trim()});let n=await G();this.hydrateDraftFromStatus(n),e?await ce(n.service.running?`restart`:`start`):t.service.running&&await ce(`restart`);let i=await G();this.hydrateDraftFromStatus(i)},successMessage:n(e?`remoteEnabledReady`:`remoteDisabledDone`)})},this.ensureRemoteAccount=async(e,t)=>e.account.loggedIn?e:await this.params.accountManager.ensureSignedIn({apiBase:t,status:e}),this.runServiceAction=async(e,t)=>{await this.runManagedAction({actionLabel:t,job:async()=>{let t=await ce(e),n=await G();this.hydrateDraftFromStatus(n),C.success(t.message)}})},this.hydrateDraftFromStatus=e=>{K.getState().hydrateDraft({enabled:e.settings.enabled,deviceName:e.settings.deviceName,platformApiBase:e.settings.platformApiBase})},this.runManagedAction=async e=>{let{actionLabel:t,job:r,successMessage:i}=e;K.getState().beginAction(t);try{await r(),i&&C.success(i)}catch(e){let t=e instanceof Error?e.message:n(`error`);throw C.error(t),e}finally{K.getState().finishAction()}}}},gi=[/invalid or expired token/i,/missing bearer token/i,/token expired/i,/token is invalid/i,/run "nextclaw login"/i,/browser sign-in again/i];function _i(e){return e?.runtime?.lastError?.trim()||``}function vi(e){let t=n(`remoteStatusIssueDetailGeneric`),r=_i(e);return r?`${t} (${r})`:t}function yi(e){if(!e?.settings.enabled)return!1;let t=_i(e);return gi.some(e=>e.test(t))}function bi(e){return yi(e)?{hero:{badgeStatus:`warning`,badgeLabel:n(`remoteStateReauthorizationRequired`),title:n(`remoteStatusReauthorizationTitle`),description:n(`remoteStatusReauthorizationDescription`)},primaryAction:{kind:`reauthorize`,label:n(`remoteReauthorizeNow`),showRefreshIcon:!1},issueHint:{title:n(`remoteStatusRecoveryTitle`),body:n(`remoteStatusReauthorizationHint`)},shouldShowIssueHint:!0,requiresReauthorization:!0}:e?.account.loggedIn?e.settings.enabled?e.service.running?e.runtime?.state===`connected`?{hero:{badgeStatus:`ready`,badgeLabel:n(`statusReady`),title:n(`remoteStatusReadyTitle`),description:n(`remoteStatusReadyDescription`)},primaryAction:{kind:`repair`,label:n(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:e.runtime?.state===`connecting`?{hero:{badgeStatus:`active`,badgeLabel:n(`connecting`),title:n(`remoteStatusConnectingTitle`),description:n(`remoteStatusConnectingDescription`)},primaryAction:{kind:`repair`,label:n(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:n(`remoteStateDisconnected`),title:n(`remoteStatusIssueTitle`),description:n(`remoteStatusIssueDescription`)},primaryAction:{kind:`repair`,label:n(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:n(`remoteStatusRecoveryTitle`),body:vi(e)},shouldShowIssueHint:!!(e.settings.enabled&&e.account.loggedIn),requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:n(`remoteServiceStopped`),title:n(`remoteStatusNeedsServiceTitle`),description:n(`remoteStatusNeedsServiceDescription`)},primaryAction:{kind:`repair`,label:n(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:n(`remoteStatusRecoveryTitle`),body:n(`remoteStatusIssueDetailServiceStopped`)},shouldShowIssueHint:!0,requiresReauthorization:!1}:{hero:{badgeStatus:`inactive`,badgeLabel:n(`statusInactive`),title:n(`remoteStatusNeedsEnable`),description:n(`remoteStatusNeedsEnableDescription`)},primaryAction:{kind:`enable`,label:n(`remoteEnableNow`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`setup`,badgeLabel:n(`statusSetup`),title:n(`remoteStatusNeedsSignIn`),description:n(`remoteStatusNeedsSignInDescription`)},primaryAction:{kind:`sign-in-enable`,label:n(`remoteSignInAndEnable`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}}var q=s(e=>({panelOpen:!1,authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500,openPanel:()=>e({panelOpen:!0}),closePanel:()=>e({panelOpen:!1}),beginBrowserAuth:({sessionId:t,verificationUri:n,expiresAt:r,intervalMs:i,statusMessage:a})=>e({panelOpen:!0,authSessionId:t,authVerificationUri:n,authExpiresAt:r,authPollIntervalMs:i,authStatusMessage:a}),updateBrowserAuth:({statusMessage:t,intervalMs:n})=>e(e=>({authStatusMessage:t??e.authStatusMessage,authPollIntervalMs:n??e.authPollIntervalMs})),clearBrowserAuth:()=>e({authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500}),setAuthStatusMessage:t=>e({authStatusMessage:t})}));function xi({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,H.jsx)(`span`,{className:`text-gray-500`,children:e}),(0,H.jsx)(`span`,{className:`text-right text-gray-900`,children:t?.trim()||`-`})]})}function Si(e){let{email:t,username:r,role:i,canSubmitUsername:a,savingUsername:o,usernameDraft:s,onUsernameDraftChange:c,onSubmitUsername:l,onOpenDeviceList:u,onLogout:d}=e;return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(T,{tone:`success`,title:n(`accountPanelSignedInTitle`),description:n(`accountPanelSignedInDescription`)}),(0,H.jsxs)(T,{tone:`neutral`,children:[(0,H.jsx)(xi,{label:n(`remoteAccountEmail`),value:t}),(0,H.jsx)(xi,{label:n(`remoteAccountUsername`),value:r}),(0,H.jsx)(xi,{label:n(`remoteAccountRole`),value:i})]}),r?(0,H.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`remoteAccountUsernameLockedHelp`)}):(0,H.jsxs)(T,{tone:`warning`,title:n(`remoteAccountUsernameRequiredTitle`),description:n(`remoteAccountUsernameRequiredDescription`),children:[(0,H.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,H.jsx)(g,{htmlFor:`account-panel-username`,children:n(`remoteAccountUsername`)}),(0,H.jsx)(v,{id:`account-panel-username`,value:s,onChange:e=>c(e.target.value),placeholder:n(`remoteAccountUsernamePlaceholder`),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1})]}),(0,H.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-3`,children:(0,H.jsx)(p,{disabled:!a,onClick:()=>void l(),children:n(o?`remoteAccountUsernameSaving`:`remoteAccountUsernameSave`)})})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,H.jsxs)(p,{onClick:()=>void u(),children:[(0,H.jsx)(ni,{className:`mr-2 h-4 w-4`}),n(`remoteOpenDeviceList`)]}),(0,H.jsxs)(p,{variant:`outline`,onClick:()=>void d(),children:[(0,H.jsx)(Xr,{className:`mr-2 h-4 w-4`}),n(`remoteLogout`)]})]})]})}function Ci(e){let{authSessionId:t,authExpiresAt:r,authStatusMessage:a,authVerificationUri:o,onStartBrowserSignIn:s,onResumeBrowserSignIn:c}=e;return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(T,{tone:`neutral`,title:n(`accountPanelSignedOutTitle`),description:n(`accountPanelSignedOutDescription`),children:t?(0,H.jsxs)(`div`,{className:`mt-3 border-t border-white/80 pt-3`,children:[(0,H.jsx)(xi,{label:n(`remoteBrowserAuthSession`),value:t}),(0,H.jsx)(xi,{label:n(`remoteBrowserAuthExpiresAt`),value:r?i(r):`-`})]}):null}),a?(0,H.jsx)(`p`,{className:`text-sm text-gray-600`,children:a}):null,(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,H.jsx)(p,{onClick:()=>void s(),children:n(t?`remoteBrowserAuthActionRetry`:`remoteBrowserAuthAction`)}),o?(0,H.jsx)(p,{variant:`outline`,onClick:c,children:n(`remoteBrowserAuthResume`)}):null]})]})}function wi(){let e=es(),t=si(),r=q(e=>e.panelOpen),i=q(e=>e.authSessionId),a=q(e=>e.authVerificationUri),o=q(e=>e.authExpiresAt),s=q(e=>e.authStatusMessage),c=t.data,[l,u]=(0,A.useState)(``),[d,f]=(0,A.useState)(!1);(0,A.useEffect)(()=>{e.accountManager.syncRemoteStatus(c)},[e,c]);let p=!d&&l.trim().length>0&&!c?.account.username;return(0,H.jsx)(pe,{open:r,onOpenChange:t=>t?e.accountManager.openAccountPanel():e.accountManager.closeAccountPanel(),children:(0,H.jsxs)(he,{className:`max-w-xl`,children:[(0,H.jsxs)(me,{children:[(0,H.jsxs)(ge,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Ee,{className:`h-5 w-5 text-primary`}),n(`accountPanelTitle`)]}),(0,H.jsx)(fe,{children:n(`accountPanelDescription`)})]}),c?.account.loggedIn?(0,H.jsx)(Si,{email:c.account.email,username:c.account.username,role:c.account.role,canSubmitUsername:p,savingUsername:d,usernameDraft:l,onUsernameDraftChange:u,onSubmitUsername:async()=>{f(!0);try{await e.accountManager.updateUsername(l)}finally{f(!1)}},onOpenDeviceList:()=>e.accountManager.openNextClawWeb(`/account`),onLogout:()=>e.accountManager.logout()}):(0,H.jsx)(Ci,{authSessionId:i,authExpiresAt:o,authStatusMessage:s,authVerificationUri:a,onStartBrowserSignIn:()=>e.accountManager.startBrowserSignIn(),onResumeBrowserSignIn:()=>e.accountManager.resumeBrowserSignIn()})]})})}function Ti({username:e}){let t=se(),[r,i]=(0,A.useState)(e??``),[a,o]=(0,A.useState)(``),s=r.trim().length>0&&a.length>0&&!t.isPending;return(0,H.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-secondary px-6 py-10`,children:(0,H.jsxs)(f,{hover:!1,className:`w-full max-w-md shadow-card-hover`,children:[(0,H.jsxs)(ie,{children:[(0,H.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.24em] text-gray-500`,children:n(`authBrand`)}),(0,H.jsx)(l,{className:`text-2xl`,children:n(`authLoginTitle`)}),(0,H.jsx)(_,{children:n(`authLoginDescription`)})]}),(0,H.jsx)(d,{children:(0,H.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e?.preventDefault(),s&&t.mutate({username:r.trim(),password:a})},children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:n(`authUsername`)}),(0,H.jsx)(v,{value:r,onChange:e=>i(e.target.value),placeholder:n(`authUsernamePlaceholder`),autoFocus:!0})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:n(`authPassword`)}),(0,H.jsx)(v,{type:`password`,value:a,onChange:e=>o(e.target.value),placeholder:n(`authPasswordPlaceholder`)})]}),(0,H.jsx)(p,{type:`submit`,className:`w-full`,disabled:!s,children:t.isPending?n(`authLoggingIn`):n(`authLoginAction`)})]})})]})})}var Ei=class{constructor(){this.authPollTimerId=null,this.browserSignInCompletion=null,this.openAccountPanel=()=>{q.getState().openPanel()},this.closeAccountPanel=()=>{q.getState().closePanel()},this.syncRemoteStatus=e=>{e?.account.loggedIn&&(this.clearPollTimer(),this.resolveBrowserSignIn(e),q.getState().clearBrowserAuth())},this.ensureSignedIn=async e=>{let t=e?.status??await W();return t.account.loggedIn?t:(this.openAccountPanel(),await this.startBrowserSignInAndWait({apiBase:e?.apiBase,status:t}))},this.startBrowserSignInAndWait=async e=>{let t=this.createBrowserSignInCompletion();return await this.startBrowserSignIn(e),await t},this.startBrowserSignIn=async e=>{try{let t=e?.apiBase,r=await te({apiBase:fi(e?.status??await W(),t)});q.getState().beginBrowserAuth({sessionId:r.sessionId,verificationUri:r.verificationUri,expiresAt:r.expiresAt,intervalMs:r.intervalMs,statusMessage:n(`remoteBrowserAuthWaiting`)}),window.open(r.verificationUri,`_blank`,`noopener,noreferrer`)||q.getState().setAuthStatusMessage(n(`remoteBrowserAuthPopupBlocked`)),this.scheduleBrowserAuthPoll()}catch(e){let t=e instanceof Error?e.message:n(`remoteBrowserAuthStartFailed`);this.rejectBrowserSignIn(e),C.error(`${n(`remoteBrowserAuthStartFailed`)}: ${t}`)}},this.resumeBrowserSignIn=()=>{let e=q.getState().authVerificationUri;e&&window.open(e,`_blank`,`noopener,noreferrer`)},this.logout=async()=>{try{await oe(),this.rejectBrowserSignIn(Error(`Signed out before browser sign-in completed.`)),q.getState().clearBrowserAuth(),await G(),C.success(n(`remoteLogoutSuccess`))}catch(e){let t=e instanceof Error?e.message:n(`remoteLogoutFailed`);C.error(`${n(`remoteLogoutFailed`)}: ${t}`)}},this.updateUsername=async e=>{try{await ae({username:e.trim()}),await G(),C.success(n(`remoteAccountUsernameSetSuccess`))}catch(e){let t=e instanceof Error?e.message:n(`remoteAccountUsernameSetFailed`);C.error(`${n(`remoteAccountUsernameSetFailed`)}: ${t}`)}},this.openNextClawWeb=async(e=`/`)=>{let t=mi(await W());if(!t){C.error(n(`remoteOpenWebUnavailable`));return}let r=new URL(e,`${t.replace(/\/+$/,``)}/`).toString();window.open(r,`_blank`,`noopener,noreferrer`)},this.scheduleBrowserAuthPoll=()=>{this.clearPollTimer();let{authSessionId:e,authPollIntervalMs:t}=q.getState();e&&(this.authPollTimerId=window.setTimeout(async()=>{await this.pollBrowserSignIn()},t))},this.pollBrowserSignIn=async()=>{let e=q.getState();if(e.authSessionId)try{let t=await W(),r=await le({sessionId:e.authSessionId,apiBase:fi(t)});if(r.status===`pending`){q.getState().updateBrowserAuth({statusMessage:n(`remoteBrowserAuthWaiting`),intervalMs:r.nextPollMs??1500}),this.scheduleBrowserAuthPoll();return}if(r.status===`expired`){this.clearPollTimer(),this.rejectBrowserSignIn(Error(r.message||n(`remoteBrowserAuthExpired`))),q.getState().clearBrowserAuth(),C.error(r.message||n(`remoteBrowserAuthExpired`));return}q.getState().setAuthStatusMessage(n(`remoteBrowserAuthCompleted`));let i=await G();this.clearPollTimer(),this.resolveBrowserSignIn(i),q.getState().clearBrowserAuth(),C.success(n(`remoteLoginSuccess`))}catch(e){this.clearPollTimer(),this.rejectBrowserSignIn(e),q.getState().clearBrowserAuth();let t=e instanceof Error?e.message:n(`remoteBrowserAuthPollFailed`);C.error(`${n(`remoteBrowserAuthPollFailed`)}: ${t}`)}},this.clearPollTimer=()=>{this.authPollTimerId!==null&&(window.clearTimeout(this.authPollTimerId),this.authPollTimerId=null)},this.createBrowserSignInCompletion=()=>(this.rejectBrowserSignIn(Error(`Browser sign-in was replaced by a newer request.`)),new Promise((e,t)=>{this.browserSignInCompletion={resolve:e,reject:t}})),this.resolveBrowserSignIn=e=>{let t=this.browserSignInCompletion;t&&(this.browserSignInCompletion=null,t.resolve(e))},this.rejectBrowserSignIn=e=>{let t=this.browserSignInCompletion;t&&(this.browserSignInCompletion=null,t.reject(e instanceof Error?e:Error(String(e))))},this.getBrowserAuthSummary=()=>{let e=q.getState();return{sessionId:e.authSessionId,expiresAt:e.authExpiresAt?i(e.authExpiresAt):`-`}}}};function Di({deletePending:e,entry:t,favoritePending:r,onDelete:i,onOpen:a,onToggleFavorite:o}){let[s,c]=(0,A.useState)(!1),[l,u]=(0,A.useState)(!1),d=t.favorite?n(`panelAppsUnfavorite`):n(`panelAppsFavorite`),f=t.lastOpenedAt?`${n(`panelAppsLastOpened`)} ${ki(t.lastOpenedAt)}`:`${n(`panelAppsUpdated`)} ${ki(t.updatedAt)}`,p=e=>{e.stopPropagation(),o()},m=()=>{c(!1),u(!0)};return(0,H.jsxs)(`div`,{className:`group w-full min-w-0 rounded-lg border border-gray-200 bg-white px-2.5 py-2.5 transition-colors hover:border-amber-200 hover:bg-amber-50/50`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:a,className:`min-w-0 flex-1 text-left`,children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-amber-50 text-base text-amber-700`,children:(0,H.jsx)(Ai,{icon:t.icon,title:t.title})}),(0,H.jsx)(`span`,{className:`block min-w-0 flex-1 truncate text-sm font-medium text-gray-900`,children:t.title})]}),t.description?(0,H.jsx)(`span`,{className:`mt-1.5 block truncate text-xs leading-5 text-gray-600`,children:t.description}):null,(0,H.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] leading-4 text-gray-400`,children:f})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:p,disabled:r,className:`rounded-md p-1.5 text-gray-400 transition-colors hover:bg-white hover:text-amber-500 disabled:opacity-50`,title:d,"aria-label":d,children:(0,H.jsx)(ri,{className:t.favorite?`h-4 w-4 fill-amber-400 text-amber-500`:`h-4 w-4`})}),(0,H.jsxs)(Pe,{open:s,onOpenChange:c,children:[(0,H.jsx)(Ne,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-gray-400 transition-colors hover:bg-white hover:text-gray-700`,"aria-label":n(`panelAppsMoreActions`),disabled:e,children:(0,H.jsx)(qr,{className:`h-4 w-4`})})}),(0,H.jsx)(Me,{align:`end`,className:`w-48 rounded-xl p-1.5`,children:(0,H.jsx)(Oi,{destructive:!0,disabled:e,icon:ke,label:n(`panelAppsDelete`),onClick:m})})]})]})]}),(0,H.jsx)(_e,{open:l,onOpenChange:u,title:n(`panelAppsDeleteConfirmTitle`),description:`${n(`panelAppsDeleteConfirmDescription`)} ${t.fileName}`,confirmLabel:n(`delete`),variant:`destructive`,onConfirm:i,onCancel:()=>void 0})]})}function Oi({destructive:t=!1,disabled:n=!1,icon:r,label:i,onClick:a}){return(0,H.jsxs)(`button`,{type:`button`,className:e(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,t?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),disabled:n,onClick:a,children:[(0,H.jsx)(r,{className:`h-4 w-4 shrink-0`}),(0,H.jsx)(`span`,{children:i})]})}function ki(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=o(a()),r=new Date;return t.toDateString()===r.toDateString()?new Intl.DateTimeFormat(n,{hour:`2-digit`,minute:`2-digit`}).format(t):t.getFullYear()===r.getFullYear()?new Intl.DateTimeFormat(n,{month:`numeric`,day:`numeric`}).format(t):new Intl.DateTimeFormat(n,{year:`2-digit`,month:`numeric`,day:`numeric`}).format(t)}function Ai({icon:e,title:t}){return e?ji(e)?(0,H.jsx)(`img`,{src:e,alt:``,"aria-hidden":`true`,className:`h-5 w-5 rounded-sm object-contain`,title:t}):(0,H.jsx)(`span`,{className:`max-w-6 truncate text-center leading-none`,children:e}):(0,H.jsx)(Vr,{className:`h-4 w-4`})}function ji(e){return e.startsWith(`data:image/`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)}var Mi=[`panel-apps`];function Ni(){return b({queryKey:Mi,queryFn:()=>x.panelApps.listPanelApps(),staleTime:0})}function Pi(){let e=y();return u({mutationFn:({id:e,preferences:t})=>x.panelApps.updatePanelAppPreferences(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:Mi})}})}function Fi(){let e=y();return u({mutationFn:e=>x.panelApps.recordPanelAppOpened(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mi})}})}function Ii(){let e=y();return u({mutationFn:e=>x.panelApps.grantClient(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mi})}})}function Li(){let e=y();return u({mutationFn:e=>x.panelApps.deletePanelApp(e),onSuccess:()=>{e.invalidateQueries({queryKey:Mi})}})}function Ri(e,t){return t===`favorites`?zi(e.filter(e=>e.favorite),`smart`):zi(t===`recent-open`?e.filter(e=>e.lastOpenedAt):e,t)}function zi(e,t){return[...e].sort((e,n)=>Bi(e,n,t))}function Bi(e,t,n){return n===`recent-open`?Wi(e.lastOpenedAt,t.lastOpenedAt)||Vi(e,t):n===`updated`?Wi(e.updatedAt,t.updatedAt)||Vi(e,t):n===`name`?Vi(e,t):Hi(e,t)||Number(t.favorite)-Number(e.favorite)||Vi(e,t)}function Vi(e,t){return e.title.localeCompare(t.title)}function Hi(e,t){return Ui(t)-Ui(e)}function Ui(e){return Math.max(new Date(e.lastOpenedAt??0).getTime(),new Date(e.createdAt).getTime(),new Date(e.updatedAt).getTime())}function Wi(e,t){return new Date(t??0).getTime()-new Date(e??0).getTime()}function Gi({headerContent:e,onOpenPanelApp:t}){let r=Ni(),i=Li(),a=Pi(),o=Fi(),s=Ii(),c=es(),[l,u]=(0,A.useState)(`smart`),d=(0,A.useMemo)(()=>Ri(r.data?.entries??[],l),[r.data?.entries,l]),f=async e=>{if(await p(e))try{t(await o.mutateAsync(e.id))}catch{t(e)}},p=async e=>!e.clientDeclared||e.clientGranted?!0:await c.serviceActionAuthorizationManager.requestAuthorization({panelAppId:e.appId,actions:[{actionId:`nextclaw.client`,actionTitle:n(`panelAppsClientGrantTitle`),actionDescription:n(`panelAppsClientGrantDescription`),risk:`dangerous`}]})?(await s.mutateAsync(e.appId),!0):!1,m=e=>{a.mutate({id:e.id,preferences:{favorite:!e.favorite}})},h=e=>{i.mutate(e.id)};return r.isLoading?(0,H.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:n(`panelAppsLoading`)}):r.isError?(0,H.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:r.error instanceof Error?r.error.message:n(`panelAppsLoadFailed`)}):(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e??(0,H.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:n(`panelAppsTitle`)}),r.data?.panelsPath?(0,H.jsx)(Ce,{delayDuration:250,children:(0,H.jsxs)(we,{children:[(0,H.jsx)(xe,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:`rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-700`,"aria-label":n(`panelAppsTitle`),children:(0,H.jsx)(Gr,{className:`h-3.5 w-3.5`})})}),(0,H.jsx)(Se,{side:`bottom`,className:`max-w-[320px] break-all font-mono text-xs`,children:r.data.panelsPath})]})}):null]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>void r.refetch(),className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:n(`panelAppsRefresh`),"aria-label":n(`panelAppsRefresh`),children:(0,H.jsx)(Oe,{className:`h-3.5 w-3.5`})})]}),(0,H.jsx)(`div`,{className:`border-b border-gray-100 px-3 py-2`,children:(0,H.jsx)(Ie,{value:l,onValueChange:e=>u(e),children:(0,H.jsxs)(Fe,{className:`grid h-auto w-full grid-cols-5 rounded-lg bg-gray-100/70 p-0.5`,children:[(0,H.jsx)(E,{value:`smart`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortSmart`)}),(0,H.jsx)(E,{value:`favorites`,className:`px-2 py-1 text-xs`,children:n(`panelAppsFavorites`)}),(0,H.jsx)(E,{value:`recent-open`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortRecentOpen`)}),(0,H.jsx)(E,{value:`updated`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortUpdated`)}),(0,H.jsx)(E,{value:`name`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortName`)})]})})}),d.length===0?(0,H.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-gray-500`,children:n(`panelAppsEmpty`)}):(0,H.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3`,children:(0,H.jsx)(`div`,{className:`space-y-1.5`,children:d.map(e=>(0,H.jsx)(Di,{entry:e,deletePending:i.isPending,favoritePending:a.isPending,onDelete:()=>h(e),onOpen:()=>void f(e),onToggleFavorite:()=>m(e)},e.id))})})]})}var Ki=class{constructor(e){this.authorizationManager=e,this.handleIframeMessage=({event:e,iframe:t,iframeInstanceId:n,tab:r})=>{this.isBridgeRequest(e.data)&&(!t?.contentWindow||e.source!==t.contentWindow||this.handleBridgeRequest({event:e,iframe:t,iframeInstanceId:n,tab:r},e.data))},this.handleBridgeRequest=async(e,t)=>{try{let n=this.getBridgeContext(t),r=await this.dispatchRequest(n,t);this.postResponse(e,{type:`nextclaw:panel-app-service-actions:response`,requestId:t.requestId,ok:!0,data:r})}catch(n){this.postResponse(e,{type:`nextclaw:panel-app-service-actions:response`,requestId:t.requestId,ok:!1,error:this.toBridgeError(n)})}},this.dispatchRequest=async(e,t)=>{switch(t.method){case`list`:return await x.serviceApps.listServiceActions({bridgeSessionToken:e.token});case`requestGrant`:return await this.confirmAndGrant(e,this.requireActionId(t));case`revokeGrant`:return await x.serviceApps.revokeServiceAction(this.requireActionId(t),{bridgeSessionToken:e.token});case`invoke`:return await this.invokeWithAuthorization(e,t);case`agent.send`:return await this.sendAgentMessageWithAuthorization(e,t);case`agent.generateObject`:return await this.generateAgentObjectWithAuthorization(e,t);default:throw Error(`Unsupported panel bridge method: ${String(t.method)}`)}},this.invokeWithAuthorization=async(e,t)=>{let n=this.requireActionId(t);try{return await x.serviceApps.invokeServiceAction(n,this.readOptionalRecord(t.payload?.input),{bridgeSessionToken:e.token})}catch(r){if(!(r instanceof S)||r.code!==`AUTHORIZATION_REQUIRED`)throw r;return await this.confirmAndGrant(e,n,this.readOptionalRecord(t.payload?.input)),await x.serviceApps.invokeServiceAction(n,this.readOptionalRecord(t.payload?.input),{bridgeSessionToken:e.token})}},this.sendAgentMessageWithAuthorization=async(e,t)=>{try{return await x.panelApps.sendAgentMessage(this.readAgentSendRequest(t),{bridgeSessionToken:e.token})}catch(n){if(!(n instanceof S)||n.code!==`AUTHORIZATION_REQUIRED`)throw n;return await this.confirmAndGrantAgentCapability(e,`agent:send`),await x.panelApps.sendAgentMessage(this.readAgentSendRequest(t),{bridgeSessionToken:e.token})}},this.generateAgentObjectWithAuthorization=async(e,t)=>{try{return await x.panelApps.generateAgentObject(this.readGenerateObjectRequest(t),{bridgeSessionToken:e.token})}catch(n){if(!(n instanceof S)||n.code!==`AUTHORIZATION_REQUIRED`)throw n;return await this.confirmAndGrantAgentCapability(e,`agent:generateObject`),await x.panelApps.generateAgentObject(this.readGenerateObjectRequest(t),{bridgeSessionToken:e.token})}},this.confirmAndGrantAgentCapability=async(e,t)=>{if(!await this.authorizationManager.requestAuthorization({panelAppId:e.appId,actions:[{actionId:t,actionTitle:t===`agent:send`?`Send agent message`:`Generate object`,actionDescription:t===`agent:send`?`Send a message to a NextClaw Agent session.`:`Send context to a NextClaw Agent session and receive a structured object.`,risk:`write`}]}))throw new S({code:`AUTHORIZATION_REJECTED`,message:`Permission rejected for ${t}.`});return await x.panelApps.grantAgentCapability(t,{bridgeSessionToken:e.token})},this.confirmAndGrant=async(e,t,n)=>{let r=await this.listGrantCandidateActions(e,t);if(!await this.authorizationManager.requestAuthorization({panelAppId:e.appId,actions:r.map(e=>({actionId:e.id,actionTitle:e.title,actionDescription:e.description,risk:e.risk})),inputPreview:this.createInputPreview(n)}))throw new S({code:`AUTHORIZATION_REJECTED`,message:`Permission rejected for ${t}.`});let i=await x.serviceApps.grantServiceActions(r.map(e=>e.id),{bridgeSessionToken:e.token}),a=i.grants.find(e=>e.actionId===t)??i.grants[0];if(!a)throw Error(`No permission grant returned for ${t}.`);return a},this.listGrantCandidateActions=async(e,t)=>{let n=await x.serviceApps.listServiceActions({bridgeSessionToken:e.token}),r=n.actions.find(e=>e.id===t);if(r&&r.grantState!==`not-granted`)return[r];let i=n.actions.filter(e=>e.grantState===`not-granted`),a=[...i.filter(e=>e.id===t),...i.filter(e=>e.id!==t)];return a.length>0?a:[{appId:r?.appId??t.split(`.`)[0]??t,description:r?.description,id:t,name:r?.name??t,risk:r?.risk??`dangerous`,title:r?.title}]},this.createInputPreview=e=>{if(!(!e||Object.keys(e).length===0))try{let t=JSON.stringify(e,null,2);return t.length>500?`${t.slice(0,500)}...`:t}catch{return`[unserializable input]`}},this.getBridgeContext=e=>({appId:e.appId,token:e.runtimeToken}),this.requireActionId=e=>{let t=e.payload?.actionId?.trim();if(!t)throw Error(`Panel bridge actionId is required.`);return t},this.readOptionalRecord=e=>{if(e!==void 0)return this.requireRecord(e,`input`)},this.readAgentSendRequest=e=>({payload:this.requireRecord(e.payload?.request,`agent.send request`)}),this.readGenerateObjectRequest=e=>({input:this.requireRecord(e.payload?.input,`generateObject input`)}),this.requireRecord=(e,t)=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`${t} is required.`);return e},this.postResponse=(e,t)=>{e.iframe?.contentWindow?.postMessage(t,`*`)},this.toBridgeError=e=>e instanceof S?{code:e.code,message:e.message,details:e.details}:{message:e instanceof Error?e.message:String(e)},this.isBridgeRequest=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return t.type===`nextclaw:panel-app-service-actions:request`&&typeof t.requestId==`string`&&typeof t.runtimeToken==`string`&&typeof t.appId==`string`&&(t.method===`invoke`||t.method===`agent.send`||t.method===`agent.generateObject`||t.method===`list`||t.method===`requestGrant`||t.method===`revokeGrant`)}}};function qi(){return`service-action-auth-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}var Ji=s((e,t)=>({pending:null,requestAuthorization:async n=>await new Promise(r=>{t().pending?.resolve(!1),e({pending:{id:qi(),...n,resolve:r}})}),resolveAuthorization:n=>{let{pending:r}=t();r&&(r.resolve(n),e({pending:null}))}}));function Yi(){let e=Ji(e=>e.pending),t=Ji(e=>e.resolveAuthorization);return(0,H.jsx)(pe,{open:!!e,onOpenChange:e=>{e||t(!1)},children:(0,H.jsxs)(he,{className:`[&>:last-child]:hidden`,children:[(0,H.jsxs)(me,{children:[(0,H.jsxs)(ge,{className:`flex items-center gap-2`,children:[(0,H.jsx)(ei,{className:`h-4 w-4 text-amber-600`}),n(`serviceActionAuthorizationTitle`)]}),(0,H.jsx)(fe,{children:n(`serviceActionAuthorizationDescription`)})]}),e?(0,H.jsxs)(`div`,{className:`space-y-3 rounded-md border border-gray-100 bg-gray-50 p-3 text-sm`,children:[(0,H.jsx)(Zi,{label:n(`serviceActionAuthorizationSource`),value:e.panelAppId}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`div`,{className:`text-xs font-medium text-gray-500`,children:n(`serviceActionAuthorizationActions`)}),(0,H.jsx)(`div`,{className:`max-h-64 space-y-2 overflow-auto`,children:e.actions.map(e=>(0,H.jsx)(Xi,{action:e},e.actionId))})]}),e.inputPreview?(0,H.jsx)(Zi,{label:n(`serviceActionAuthorizationInput`),value:e.inputPreview}):null]}):null,(0,H.jsxs)(de,{className:`gap-2 sm:gap-0`,children:[(0,H.jsx)(p,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:n(`serviceActionAuthorizationReject`)}),(0,H.jsx)(p,{type:`button`,onClick:()=>t(!0),children:n(`serviceActionAuthorizationAllow`)})]})]})})}function Xi({action:e}){return(0,H.jsxs)(`div`,{className:`space-y-1 rounded border border-gray-200 bg-white px-3 py-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsx)(`div`,{className:`min-w-0 break-words text-xs font-medium text-gray-900`,children:e.actionTitle??e.actionId}),(0,H.jsx)(`div`,{className:`shrink-0 rounded bg-amber-50 px-1.5 py-0.5 text-[11px] font-medium text-amber-700`,children:e.risk??`dangerous`})]}),(0,H.jsx)(`div`,{className:`break-words text-[11px] text-gray-500`,children:e.actionId}),e.actionDescription?(0,H.jsx)(`div`,{className:`break-words text-xs text-gray-600`,children:e.actionDescription}):null]})}function Zi({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`grid grid-cols-[5rem_minmax(0,1fr)] gap-3`,children:[(0,H.jsx)(`div`,{className:`text-xs font-medium text-gray-500`,children:e}),(0,H.jsx)(`div`,{className:`min-w-0 break-words text-xs text-gray-900`,children:t})]})}var Qi=class{constructor(){this.requestAuthorization=async e=>await Ji.getState().requestAuthorization(e)}},$i=[`service-apps`],ea=[`service-actions`],ta=[`service-action-grants`];function na(){return b({queryKey:$i,queryFn:()=>x.serviceApps.listServiceApps()})}function ra(){return b({queryKey:ea,queryFn:()=>x.serviceApps.listServiceActions()})}function ia(){return b({queryKey:ta,queryFn:()=>x.serviceApps.listServiceActionGrants()})}function aa(){let e=y();return u({mutationFn:e=>x.serviceApps.restartServiceApp(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:$i}),e.invalidateQueries({queryKey:ea})])}})}function oa(){let e=y();return u({mutationFn:e=>x.serviceApps.deleteServiceApp(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:$i}),e.invalidateQueries({queryKey:ea}),e.invalidateQueries({queryKey:ta})])}})}function sa(){let e=y();return u({mutationFn:e=>x.serviceApps.discoverServiceAppActions(e),onSuccess:async()=>{await e.invalidateQueries({queryKey:$i})}})}function ca(){let e=y();return u({mutationFn:e=>x.serviceApps.revokeServiceActionGrant(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:ea}),e.invalidateQueries({queryKey:ta})])}})}function la({headerContent:e}){let t=na(),r=ra(),i=ia(),a=oa(),o=aa(),s=sa(),c=ca(),[l,u]=(0,A.useState)({}),d=()=>{t.refetch(),r.refetch(),i.refetch()};if(t.isLoading||r.isLoading||i.isLoading)return(0,H.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:n(`serviceAppsLoading`)});if(t.isError||r.isError||i.isError){let e=t.error??r.error??i.error;return(0,H.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:e instanceof Error?e.message:n(`serviceAppsLoadFailed`)})}let f=t.data?.entries??[],p=r.data?.actions??[],m=i.data?.grants??[],h=e=>{s.mutateAsync(e).then(t=>{u(n=>({...n,[e]:t.actions}))})};return(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3`,children:[(0,H.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:e??(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($r,{className:`h-4 w-4 text-primary`}),(0,H.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:n(`serviceAppsTitle`)})]})}),(0,H.jsx)(Ce,{delayDuration:250,children:(0,H.jsx)(pa,{icon:Oe,label:n(`serviceAppsRefresh`),onClick:d})})]}),f.length===0?(0,H.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-gray-500`,children:n(`serviceAppsEmpty`)}):(0,H.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3`,children:(0,H.jsx)(`div`,{className:`space-y-3`,children:f.map(e=>(0,H.jsx)(ua,{app:e,actions:l[e.id]??p.filter(t=>t.appId===e.id),grants:m,deletePending:a.isPending,isDiscovering:s.isPending,onDiscover:h,onDelete:e=>void a.mutate(e),onRestart:e=>void o.mutate(e),onRevoke:e=>void c.mutate({actionId:e.actionId,caller:e.caller})},e.id))})})]})}function ua({app:e,actions:t,grants:r,deletePending:i,isDiscovering:a,onDiscover:o,onDelete:s,onRestart:c,onRevoke:l}){let[u,d]=(0,A.useState)(!1),[f,p]=(0,A.useState)(!1),m=e.status!==`starting`&&e.status!==`stopped`,h=e.status===`running`||e.status===`failed`,g=()=>{d(!1),p(!0)};return(0,H.jsx)(Ce,{delayDuration:250,children:(0,H.jsxs)(`section`,{className:`rounded-lg border border-gray-200 bg-white p-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.title}),(0,H.jsx)(da,{status:e.status})]}),e.description?(0,H.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-gray-500`,children:e.description}):null,e.lastError?(0,H.jsx)(`div`,{className:`mt-2 rounded bg-rose-50 px-2 py-1 text-xs text-rose-700`,children:e.lastError}):null]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,H.jsx)(pa,{disabled:a||!m,icon:Zr,label:n(`serviceAppsDiscoverActions`),tooltip:n(`serviceAppsDiscoverActionsHint`),onClick:()=>o(e.id)}),(0,H.jsx)(pa,{disabled:!h,icon:ai,label:n(`serviceAppsDisconnectRuntime`),tooltip:n(`serviceAppsDisconnectRuntimeHint`),onClick:()=>c(e.id)}),(0,H.jsxs)(Pe,{open:u,onOpenChange:d,children:[(0,H.jsxs)(we,{children:[(0,H.jsx)(xe,{asChild:!0,children:(0,H.jsx)(Ne,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50`,"aria-label":n(`serviceAppsMoreActions`),disabled:i,children:(0,H.jsx)(qr,{className:`h-3.5 w-3.5`})})})}),(0,H.jsx)(Se,{side:`bottom`,className:`text-xs`,children:n(`serviceAppsMoreActions`)})]}),(0,H.jsx)(Me,{align:`end`,className:`w-48 rounded-xl p-1.5`,children:(0,H.jsx)(ma,{destructive:!0,disabled:i,icon:ke,label:n(`serviceAppsDelete`),onClick:g})})]})]})]}),(0,H.jsx)(ha,{app:e}),(0,H.jsx)(`div`,{className:`mt-3 space-y-1`,children:t.map(e=>(0,H.jsx)(_a,{action:e,grants:r.filter(t=>t.actionId===e.id),onRevoke:l},e.id))}),(0,H.jsx)(_e,{open:f,onOpenChange:p,title:n(`serviceAppsDeleteConfirmTitle`),description:`${n(`serviceAppsDeleteConfirmDescription`)} ${e.title}`,confirmLabel:n(`delete`),variant:`destructive`,onConfirm:()=>s(e.id),onCancel:()=>void 0})]})})}function da({status:t}){let n=fa(t),r=n.icon;return(0,H.jsxs)(we,{children:[(0,H.jsx)(xe,{asChild:!0,children:(0,H.jsxs)(`span`,{className:e(`inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium`,n.className),"aria-label":n.label,children:[(0,H.jsx)(r,{className:e(`h-3 w-3`,n.iconClassName)}),(0,H.jsx)(`span`,{children:n.label})]})}),(0,H.jsx)(Se,{side:`bottom`,className:`text-xs`,children:n.tooltip})]})}function fa(e){switch(e){case`running`:return{className:`bg-emerald-50 text-emerald-700`,icon:Ur,label:n(`serviceAppsStatus_running`),tooltip:n(`serviceAppsStatusHint_running`)};case`starting`:return{className:`bg-blue-50 text-blue-700`,icon:be,iconClassName:`animate-spin`,label:n(`serviceAppsStatus_starting`),tooltip:n(`serviceAppsStatusHint_starting`)};case`failed`:return{className:`bg-rose-50 text-rose-700`,icon:ii,label:n(`serviceAppsStatus_failed`),tooltip:n(`serviceAppsStatusHint_failed`)};case`stopped`:return{className:`bg-gray-100 text-gray-600`,icon:Kr,label:n(`serviceAppsStatus_stopped`),tooltip:n(`serviceAppsStatusHint_stopped`)};default:return{className:`bg-slate-100 text-slate-600`,icon:Wr,label:n(`serviceAppsStatus_idle`),tooltip:n(`serviceAppsStatusHint_idle`)}}}function pa({disabled:e=!1,icon:t,label:n,tooltip:r=n,onClick:i}){return(0,H.jsxs)(we,{children:[(0,H.jsx)(xe,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,onClick:i,disabled:e,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:cursor-not-allowed disabled:text-gray-300 disabled:opacity-60 disabled:hover:bg-transparent`,"aria-label":n,children:(0,H.jsx)(t,{className:`h-3.5 w-3.5`})})}),(0,H.jsx)(Se,{side:`bottom`,className:`max-w-56 text-xs`,children:r})]})}function ma({destructive:t=!1,disabled:n=!1,icon:r,label:i,onClick:a}){return(0,H.jsxs)(`button`,{type:`button`,className:e(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,t?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),disabled:n,onClick:a,children:[(0,H.jsx)(r,{className:`h-4 w-4 shrink-0`}),(0,H.jsx)(`span`,{children:i})]})}function ha({app:e}){let t=[e.command,...e.args??[]].filter(e=>!!e?.trim()).join(` `),r=[{label:n(`serviceAppsCommand`),value:t},{label:n(`serviceAppsCwd`),value:e.cwd},{label:n(`serviceAppsManifest`),value:e.manifestPath},{label:n(`serviceAppsLastStarted`),value:e.lastStartedAt},{label:n(`serviceAppsLastReady`),value:e.lastReadyAt},{label:n(`serviceAppsLastFailed`),value:e.lastFailedAt}].filter(e=>e.value);return r.length===0?null:(0,H.jsx)(`dl`,{className:`mt-3 grid grid-cols-[4.5rem_minmax(0,1fr)] gap-x-2 gap-y-1 border-t border-gray-100 pt-2 text-[11px]`,children:r.map(e=>(0,H.jsx)(ga,{label:e.label,value:e.value},e.label))})}function ga({label:e,value:t}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`dt`,{className:`text-gray-400`,children:e}),(0,H.jsx)(`dd`,{className:`min-w-0 truncate font-mono text-gray-500`,title:t,children:t})]})}function _a({action:e,grants:t,onRevoke:r}){return(0,H.jsxs)(`div`,{className:`rounded bg-gray-50 px-2 py-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(oi,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-xs font-medium text-gray-800`,children:e.title??e.name}),e.description?(0,H.jsx)(`div`,{className:`truncate text-[11px] text-gray-500`,children:e.description}):null]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.runtimeState?(0,H.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-gray-600`,children:n(`serviceAppsRuntimeState_${e.runtimeState}`)}):null,(0,H.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-gray-600`,children:e.risk})]})]}),t.map(e=>(0,H.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2 pl-5`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-gray-500`,children:[(0,H.jsx)(ti,{className:`h-3 w-3 shrink-0 text-emerald-500`}),(0,H.jsxs)(`span`,{className:`truncate`,children:[n(`serviceAppsGrantedTo`),` `,e.caller.appId]})]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:`rounded-md p-1 text-gray-400 transition-colors hover:bg-white hover:text-rose-600`,title:n(`serviceAppsRevokeGrant`),"aria-label":n(`serviceAppsRevokeGrant`),children:(0,H.jsx)(ke,{className:`h-3 w-3`})})]},`${e.caller.surface}:${e.caller.appId}:${e.actionId}`))]})}function va({activeTab:e,onActiveTabChange:t,onOpenPanelApp:r}){let i=(0,H.jsx)(Ie,{value:e,onValueChange:e=>t(e),children:(0,H.jsxs)(Fe,{className:`grid h-auto w-[min(340px,100%)] grid-cols-2 rounded-lg bg-gray-100/70 p-0.5`,children:[(0,H.jsxs)(E,{value:`panel-apps`,className:`gap-1.5 px-2 py-1.5 text-xs`,children:[(0,H.jsx)(Vr,{className:`h-3.5 w-3.5`}),n(`panelAppsTitle`)]}),(0,H.jsxs)(E,{value:`service-apps`,className:`gap-1.5 px-2 py-1.5 text-xs`,children:[(0,H.jsx)($r,{className:`h-3.5 w-3.5`}),n(`serviceAppsTitle`)]})]})});return(0,H.jsx)(`div`,{className:`h-full min-h-0 bg-white`,children:e===`panel-apps`?(0,H.jsx)(Gi,{headerContent:i,onOpenPanelApp:r}):(0,H.jsx)(la,{headerContent:i})})}function ya({appTitle:e,onOpenApps:t,onRefresh:r}){return(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:t,className:`inline-flex shrink-0 items-center rounded-md p-1.5 text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,title:n(`appsTitle`),"aria-label":n(`appsTitle`),children:(0,H.jsx)(ve,{className:`h-3.5 w-3.5`})}),(0,H.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-gray-600`,title:e,children:e}),(0,H.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:n(`panelAppsRefreshCurrent`),"aria-label":n(`panelAppsRefreshCurrent`),children:(0,H.jsx)(Oe,{className:`h-3.5 w-3.5`})})]})}function ba(e){return e.split(`/`).map(e=>e.trim()).filter(e=>e.length>0)}function J(e){let t=e.trim();try{let e=new URL(t);return{authority:e.hostname,pathSegments:ba(e.pathname),pathname:e.pathname,raw:t,scheme:e.protocol.replace(/:$/,``).toLowerCase(),searchParams:e.searchParams}}catch{return{authority:``,pathSegments:ba(t),pathname:t,raw:t,scheme:``,searchParams:new URLSearchParams}}}var xa=class{constructor(e,t){this.routeDefinitions=e,this.options=t,this.resolve=e=>{let t=J(e);return this.findDefinition(t).resolve(t)},this.normalize=e=>this.options.getNormalizedUri(this.resolve(e)),this.areEquivalent=(e,t)=>this.findDefinition(J(e)).areEquivalent?.(e,t)??this.normalize(e)===this.normalize(t),this.findDefinition=e=>{let t=this.routeDefinitions.find(t=>t.match(e));if(!t)throw Error(`Unsupported resource URI: ${e.raw}`);return t}}},Sa=`home`,Ca=`nextclaw://new-tab`,wa=`apps`,Y=`nextclaw://apps`,Ta=`${Y}?tab=service-apps`,Ea=`panel-app`,Da=`panel-apps`;function Oa(e){return e===`panel-apps`||e===`service-apps`}function ka(e=Da){return e===Da?Y:Ta}function Aa(e){try{let t=new URL(e).searchParams.get(`tab`);return Oa(t)?t:Da}catch{return Da}}function ja(e){return ka(Aa(e))}function Ma(e){return`nextclaw://panel-app/${encodeURIComponent(e)}`}function Na(e){return e.startsWith(`data:image/`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)}function Pa(e){let t=e.icon?.trim();if(t)return Na(t)?{type:`url`,url:t}:{type:`text`,value:t}}function Fa(e){return{dedupeKey:`panel-app:${e.id}`,dockIcon:Pa(e),historyPolicy:`managed`,kind:Ea,resourceUri:Ma(e.id),title:e.title,url:e.contentPath}}function Ia(e,t){return e===t||e.startsWith(`${t}?`)||e.startsWith(`${t}/`)}function La(e){let t=e.pathSegments.join(`/`);return Re(t?`/${t}`:`/`,`docs`)}function Ra(e){let t=e.filter(e=>e.trim().length>0).map(e=>encodeURIComponent(decodeURIComponent(e))).join(`/`);return t?`nextclaw://docs/${t}`:`nextclaw://docs`}function za(e){let t=k(e),n=t.startsWith(`/`)?t:(()=>{try{return new URL(e).pathname}catch{return``}})();return n?Ra(n.split(`/`)):`nextclaw://docs`}function X(e){if(e.scheme===`nextclaw`&&e.authority===`panel-app`)return e.pathSegments[0]??``;let[t,n,r,i]=e.pathSegments;return t===`api`&&n===`panel-apps`&&r!==void 0&&r.length>0&&i===`content`?r:``}function Ba(e){return X(e).length>0}function Va(e){let t=X(e);return t?`/api/panel-apps/${encodeURIComponent(decodeURIComponent(t))}/content`:`nextclaw://panel-app`}function Ha(e){let t=X(e);return t?`nextclaw://panel-app/${encodeURIComponent(decodeURIComponent(t))}`:`nextclaw://panel-app`}function Ua(e,t){let n=J(e),r=J(t),i=X(n),a=X(r);return i.length>0&&a.length>0?decodeURIComponent(i)===decodeURIComponent(a):e===t}var Z=[{defaultUrl:()=>Ca,id:`home`,kind:Sa,match:e=>e.raw===Ca,resolve:()=>({historyPolicy:`managed`,kind:Sa,resourceUri:Ca,title:n(`docBrowserHomeTitle`),url:Ca}),areEquivalent:(e,t)=>e===t},{defaultUrl:O,id:`docs-url`,kind:`docs`,match:e=>Ve(e.raw),resolve:e=>{let t=Re(e.raw,`docs`);return{historyPolicy:`managed`,kind:`docs`,resourceUri:za(t),title:n(`docBrowserHelp`),url:t}},areEquivalent:(e,t)=>k(e)===k(t)},{defaultUrl:O,id:`nextclaw-docs`,kind:`docs`,match:e=>e.scheme===`nextclaw`&&e.authority===`docs`,resolve:e=>{let t=La(e);return{historyPolicy:`managed`,kind:`docs`,resourceUri:Ra(e.pathSegments),title:n(`docBrowserHelp`),url:t}},areEquivalent:(e,t)=>k(e)===k(t)},{defaultUrl:()=>Y,id:`apps`,kind:wa,match:e=>Ia(e.raw,Y),resolve:e=>{let t=ja(e.raw);return{dedupeKey:`apps`,historyPolicy:`managed`,kind:wa,resourceUri:t,title:n(t===`nextclaw://apps`?`appsTitle`:`serviceAppsTitle`),url:t}},areEquivalent:(e,t)=>ja(e)===ja(t)},{defaultUrl:()=>`nextclaw://panel-app`,id:`panel-app`,kind:Ea,match:e=>e.scheme===`nextclaw`&&e.authority===`panel-app`||Ba(e),resolve:e=>{let t=Va(e),r=X(e);return{dedupeKey:r?`panel-app:${decodeURIComponent(r)}`:void 0,historyPolicy:`managed`,kind:Ea,resourceUri:Ha(e),title:n(`panelAppsTitle`),url:t}},areEquivalent:Ua},{defaultUrl:()=>`about:blank`,id:`content`,kind:`content`,match:()=>!0,resolve:e=>({historyPolicy:`managed`,kind:`content`,resourceUri:e.raw||`about:blank`,title:We(e.raw,`content`,`Detail`),url:e.raw||`about:blank`}),areEquivalent:(e,t)=>e===t}],Wa=Z.map(e=>({areEquivalent:e.areEquivalent,id:e.id,match:e.match,resolve:e.resolve}));function Ga(){return[{id:`apps`,label:n(`appsTitle`),target:{type:`right-panel-resource`,uri:Y}},{id:`service-apps`,label:n(`serviceAppsTitle`),target:{type:`right-panel-resource`,uri:Ta}},{id:`docs`,label:n(`docBrowserHelp`),target:{options:{newTab:!0},type:`right-panel-resource`,uri:O()}},{id:`skill-marketplace`,label:n(`marketplaceSkillsPageTitle`),target:{path:`/marketplace/skills`,type:`app-route`}}]}var Ka={apps:{accentClassName:`bg-emerald-50 text-emerald-700`,hoverAccentClassName:`group-hover:bg-emerald-100`,icon:(0,H.jsx)(Te,{className:`h-5 w-5`})},"service-apps":{accentClassName:`bg-sky-50 text-sky-700`,hoverAccentClassName:`group-hover:bg-sky-100`,icon:(0,H.jsx)(Jr,{className:`h-5 w-5`})},docs:{accentClassName:`bg-amber-50 text-amber-700`,hoverAccentClassName:`group-hover:bg-amber-100`,icon:(0,H.jsx)(ye,{className:`h-5 w-5`})},"skill-marketplace":{accentClassName:`bg-rose-50 text-rose-700`,hoverAccentClassName:`group-hover:bg-rose-100`,icon:(0,H.jsx)(Hr,{className:`h-5 w-5`})}};function qa(e){return Ka[e.id]??{accentClassName:`bg-gray-50 text-gray-700`,hoverAccentClassName:`group-hover:bg-gray-100`,icon:(0,H.jsx)(Te,{className:`h-5 w-5`})}}function Ja({open:t}){let n=rn(),r=Ga(),i=e=>{if(e.type===`app-route`){n(e.path);return}t(e.uri,e.options)};return(0,H.jsx)(`div`,{className:`h-full overflow-auto bg-background px-4 py-5`,children:(0,H.jsx)(`div`,{className:`mx-auto w-full max-w-[520px]`,children:(0,H.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(76px,1fr))] gap-x-2 gap-y-4`,children:r.map(t=>{let n=qa(t);return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>i(t.target),className:`group flex min-h-[68px] flex-col items-center gap-1.5 rounded-md px-1.5 py-1.5 text-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,H.jsx)(`span`,{className:e(`flex h-10 w-10 shrink-0 items-center justify-center rounded-md transition-colors`,n.accentClassName,n.hoverAccentClassName),children:n.icon}),(0,H.jsx)(`span`,{className:`line-clamp-2 min-w-0 max-w-full text-xs font-medium leading-snug text-gray-700 transition-colors group-hover:text-gray-900`,children:t.label})]},t.id)})})})})}function Ya(e){return e&&Ve(e)?`docs`:`content`}var Xa=class{constructor(){this.resourceUriResolver=new xa(Wa,{getNormalizedUri:e=>e.resourceUri??e.url}),this.resolve=e=>this.resourceUriResolver.resolve(e),this.normalize=e=>this.resourceUriResolver.normalize(e),this.areEquivalent=(e,t)=>this.resourceUriResolver.areEquivalent(e,t),this.resolveOpenTarget=e=>{let{activeTab:t,kind:n,url:r}=e,i=this.resolveRouteDefinition(r,n,t),a=r?.trim()||(!n&&t&&t.kind!==`docs`?t.currentUrl:i.defaultUrl());return i.resolve(J(a))},this.areUrlsEquivalent=(e,t,n,r)=>n===r?this.resolveRouteDefinition(e,n).areEquivalent?.(e,t)??this.areEquivalent(e,t):!1,this.usesManagedHistory=e=>this.resolveRouteDefinition(e.currentUrl,e.kind).resolve(J(e.currentUrl)).historyPolicy===`managed`,this.resolveRouteDefinition=(e,t,n)=>{let r=t??(e?void 0:n?.kind),i=r?Z.find(e=>e.kind===r):void 0;if(i)return i;let a=e?J(e):null,o=a?Z.find(e=>e.match(a)):void 0;if(o)return o;let s=t??n?.kind??Ya(e);return Z.find(e=>e.kind===s)??Z[Z.length-1]}}},Za=wa,Qa=Ea,$a=`panel-apps`,eo=[`allow-scripts`,`allow-forms`,`allow-modals`,`allow-popups`,`allow-popups-to-escape-sandbox`,`allow-downloads`,`allow-pointer-lock`,`allow-presentation`].join(` `);function to(e){return e===`panel-apps`||e===`service-apps`}function no(e=$a){return e===$a?Y:Ta}function ro(e){try{let t=new URL(e).searchParams.get(`tab`);return to(t)?t:$a}catch{return $a}}function io(e){e.open(no(),{kind:Za,title:n(`appsTitle`),dedupeKey:`apps`})}var ao={[Sa]:{getTitle:()=>n(`docBrowserHomeTitle`),renderContent:({open:e})=>(0,H.jsx)(Ja,{open:e})},[Za]:{getTitle:()=>n(`appsTitle`),renderIcon:()=>(0,H.jsx)(Te,{className:`w-4 h-4 text-primary shrink-0`}),renderContent:({currentUrl:e,open:t,openTarget:r})=>(0,H.jsx)(va,{activeTab:ro(e),onActiveTabChange:e=>t(no(e),{activate:!1,kind:Za,title:n(`appsTitle`),dedupeKey:`apps`}),onOpenPanelApp:e=>r(Fa(e))})},[Qa]:{getIframeSandbox:()=>eo,getTitle:e=>e.title||n(`panelAppsTitle`),onIframeMessage:e=>Zo().panelAppBridgeManager.handleIframeMessage(e),renderIcon:()=>(0,H.jsx)(Vr,{className:`w-4 h-4 text-primary shrink-0`}),renderToolbar:({open:e,refreshIframe:t,tab:r})=>(0,H.jsx)(ya,{appTitle:r.title||n(`panelAppsTitle`),onOpenApps:()=>io({open:e}),onRefresh:t})}},oo=`nextclaw://docs`;function so(){return[{builtIn:!0,icon:{type:`builtin`,name:`apps`},id:`apps`,label:n(`appsTitle`),removable:!1,target:{type:`right-panel-resource`,uri:Y}},{builtIn:!0,icon:{type:`builtin`,name:`service-apps`},id:`service-apps`,label:n(`serviceAppsTitle`),removable:!1,target:{type:`right-panel-resource`,uri:Ta}},{builtIn:!0,icon:{type:`builtin`,name:`docs`},id:`docs`,label:n(`docBrowserHelp`),removable:!1,target:{type:`right-panel-resource`,uri:oo}},{builtIn:!0,icon:{type:`builtin`,name:`new-tab`},id:`new-tab`,label:n(`docBrowserHomeTitle`),removable:!1,target:{type:`right-panel-resource`,uri:Ca}}]}var co=[`apps`,`docs`,`new-tab`,`panel-app`,`service-apps`];function lo(e){return!!e&&typeof e==`object`}function uo(e){return co.includes(e)}function fo(e){return!lo(e)||typeof e.type!=`string`?null:e.type===`builtin`&&uo(e.name)?{type:`builtin`,name:e.name}:e.type===`url`&&typeof e.url==`string`&&e.url.trim().length>0?{type:`url`,url:e.url.trim()}:e.type===`text`&&typeof e.value==`string`&&e.value.trim().length>0?{type:`text`,value:e.value.trim()}:null}function po(e){if(!lo(e)||typeof e.id!=`string`||e.id.trim().length===0||typeof e.label!=`string`||e.label.trim().length===0||typeof e.createdAt!=`string`||e.createdAt.trim().length===0||!lo(e.target)||e.target.type!==`right-panel-resource`||typeof e.target.uri!=`string`||e.target.uri.trim().length===0)return null;let t=fo(e.icon);return t?{createdAt:e.createdAt,icon:t,id:e.id.trim(),label:e.label.trim(),target:{type:`right-panel-resource`,uri:e.target.uri.trim()}}:null}function mo(e){if(!Array.isArray(e))return[];let t=new Map;return e.forEach(e=>{let n=po(e);n&&t.set(n.id,n)}),Array.from(t.values())}function ho(e,t){return{createdAt:t,icon:e.icon,id:e.id,label:e.label,target:e.target}}function go(e){return{builtIn:!1,icon:e.icon,id:e.id,label:e.label,removable:!0,target:e.target}}function _o(e,t){let n=new Set(e.map(e=>e.id)),r=new Set(e.map(e=>e.target.uri)),i=t.filter(e=>!n.has(e.id)&&!r.has(e.target.uri)).map(go);return[...e,...i]}var vo=`nextclaw.side-dock.state`,yo=1;function bo(e){return!!e&&typeof e==`object`}var xo=s()(Le(e=>({pinnedItems:[],setPinnedItems:t=>e({pinnedItems:mo(t)})}),{name:vo,version:yo,storage:Ke(()=>window.localStorage),partialize:e=>({pinnedItems:e.pinnedItems}),merge:(e,t)=>{let n=bo(e)?mo(e.pinnedItems):[];return{...t,pinnedItems:n}}})),So={apps:Te,docs:ye,"new-tab":De,"panel-app":Vr,"service-apps":Vr};function Co({icon:e}){if(e.type===`url`)return(0,H.jsx)(`img`,{src:e.url,alt:``,className:`h-5 w-5 rounded object-cover`});if(e.type===`text`)return(0,H.jsx)(`span`,{className:`max-w-7 truncate text-center text-[13px] font-semibold leading-none`,"aria-hidden":`true`,children:e.value});let t=So[e.name];return(0,H.jsx)(t,{className:`h-5 w-5`,"aria-hidden":`true`})}function wo({active:t,item:r,onOpen:i,onUnpin:a}){let{label:o}=r;return(0,H.jsxs)(we,{children:[(0,H.jsxs)(`div`,{className:`group relative`,children:[(0,H.jsx)(xe,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,"aria-label":o,title:o,"data-side-dock-item-id":r.id,onClick:()=>i(r),className:e(`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors`,`hover:bg-primary/10 hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,t?`bg-primary/10 text-primary`:`bg-transparent`),children:(0,H.jsx)(Co,{icon:r.icon})})}),r.removable?(0,H.jsx)(`button`,{type:`button`,"aria-label":n(`sideDockUnpinItem`),title:n(`sideDockUnpinItem`),onClick:e=>{e.stopPropagation(),a(r)},className:`absolute -right-1 -top-1 hidden h-4 w-4 items-center justify-center rounded-full bg-background text-muted-foreground shadow-sm ring-1 ring-border/70 transition-colors hover:bg-muted hover:text-foreground group-hover:flex focus-visible:flex focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,H.jsx)(Ae,{className:`h-3 w-3`,"aria-hidden":`true`})}):null]}),(0,H.jsx)(Se,{side:`left`,children:o})]})}function To(e){return e?.trim()??``}function Eo(e,t,n,r=!1){if(!t||!n)return!1;let i=To(e.target.uri),a=To(n.resourceUri);return a&&a===i||To(n.currentUrl)===i?!0:r?!1:e.id===`docs`&&n.kind===`docs`}function Do(e,t){if(!t)return!1;let n=To(t.resourceUri),r=To(t.currentUrl);return e.some(e=>{let t=To(e.target.uri);return t===n||t===r})}function Oo({manager:e}){let t=xo(e=>e.pinnedItems),{currentTab:n,isOpen:r}=He(),i=_o(so(),t),a=Do(i,n);return(0,H.jsx)(Ce,{delayDuration:250,children:(0,H.jsx)(`aside`,{"data-testid":`side-dock`,className:`z-30 flex h-full w-14 shrink-0 flex-col items-center gap-1 border-l border-border/60 bg-background/95 px-2 py-3`,children:i.map(t=>(0,H.jsx)(wo,{active:Eo(t,r,n,a),item:t,onOpen:e.openItem,onUnpin:t=>e.unpinItem(t.id)},t.id))})})}var ko=`pinned`,Ao=new Set([`apps`,`docs`,`new-tab`,`panel-app`,`service-apps`]);function Q(e){return e.trim()}function jo(e){let t=0;return Array.from(Q(e)).forEach(e=>{t=t*31+e.charCodeAt(0)>>>0}),`${ko}-${Q(e).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``).toLowerCase()||`resource`}-${t.toString(36)}`}function Mo(e){return e?.type===`builtin`&&Ao.has(e.name)?{type:`builtin`,name:e.name}:e?.type===`url`&&e.url.trim().length>0?{type:`url`,url:e.url.trim()}:e?.type===`text`&&e.value.trim().length>0?{type:`text`,value:e.value.trim()}:null}function No(e){return e.kind===`docs`?`docs`:e.kind===`home`?`new-tab`:e.kind===`apps`?e.resourceUri?.includes(`service-apps`)?`service-apps`:`apps`:e.kind===`panel-app`?`panel-app`:`apps`}var Po=class{constructor(e){this.docBrowserManager=e,this.getItems=()=>_o(so(),xo.getState().pinnedItems),this.openItem=e=>{e.target.type===`right-panel-resource`&&this.docBrowserManager.open(e.target.uri,{dockIcon:e.icon,title:e.label})},this.getDockState=e=>{let t=this.getTabResourceUri(e);if(!t)return{canDock:!1,isDocked:!1,removable:!1};let n=this.findItemByUri(t);return{canDock:!0,isDocked:!!n,removable:n?.removable===!0}},this.pinTab=(e,t=new Date().toISOString())=>{let n=this.getTabResourceUri(e);!e||!n||this.findItemByUri(n)||this.pinItem({builtIn:!1,icon:Mo(e.dockIcon)??{type:`builtin`,name:No(e)},id:jo(n),label:e.title.trim()||n,removable:!0,target:{type:`right-panel-resource`,uri:n}},t)},this.unpinTab=e=>{let t=this.getTabResourceUri(e),n=t?this.findItemByUri(t):void 0;n?.removable&&this.unpinItem(n.id)},this.pinItem=(e,t=new Date().toISOString())=>{if(!e.removable)return;let n=Q(e.target.uri);this.setPinnedItems(r=>r.some(t=>t.id===e.id||Q(t.target.uri)===n)?r:[...r,ho({...e,target:{...e.target,uri:n}},t)])},this.unpinItem=e=>{this.setPinnedItems(t=>t.filter(t=>t.id!==e))},this.reorderPinnedItems=e=>{this.setPinnedItems(t=>{let n=new Map(t.map(e=>[e.id,e])),r=e.map(e=>n.get(e)).filter(e=>e!==void 0),i=new Set(r.map(e=>e.id)),a=t.filter(e=>!i.has(e.id));return[...r,...a]})},this.setPinnedItems=e=>{let{pinnedItems:t,setPinnedItems:n}=xo.getState();n(e(t))},this.getTabResourceUri=e=>{let t=e?.resourceUri??e?.currentUrl,n=t?Q(t):``;return n.length>0?n:null},this.findItemByUri=e=>{let t=Q(e);return this.getItems().find(e=>Q(e.target.uri)===t)}}},Fo=new class{constructor(){this.resolveOpenTarget=e=>{let{activeTab:t,kind:r,url:i}=e,a=r??(i?void 0:t?.kind)??(i&&Ve(i)?`docs`:`home`),o=i?.trim()||(!r&&t&&t.kind!==`docs`?t.currentUrl:a===`home`?`nextclaw://new-tab`:a===`docs`?O():`about:blank`),s=a===`docs`?Re(o,`docs`):o;return{historyPolicy:`managed`,kind:a,title:a===`home`?n(`docBrowserHomeTitle`):We(s,a,a===`docs`?n(`docBrowserHelp`):`Detail`),url:s}},this.areUrlsEquivalent=(e,t,n,r)=>n===r?n===`docs`?k(e)===k(t):e===t:!1,this.usesManagedHistory=e=>e.currentUrl!==Be}};function Io(e,t,n){return{...e,tabs:e.tabs.map(e=>e.id===t?n(e):e)}}function Lo(e,t){return Io(e,e.activeTabId,t)}function Ro(e,t){let n=[...e.history.slice(0,e.historyIndex+1),t];return{history:n,historyIndex:n.length-1}}function zo(e,t,n){let r=t.resourceUri??t.url,i=n.resourceUri??n.url;return t.tabId===n.tabId&&t.kind===n.kind&&e.areUrlsEquivalent(r,i,t.kind,n.kind)}function Bo(e,t){return{kind:t.kind,resourceUri:t.resourceUri??t.url,tabId:e,url:t.url}}function $(e,t,n){let r=t.activeHistory[t.activeHistoryIndex];if(r&&zo(e,r,n))return t;let i=[...t.activeHistory.slice(0,t.activeHistoryIndex+1),n];return{...t,activeHistory:i,activeHistoryIndex:i.length-1}}function Vo(e,t,n){for(let r=t.history.length-1;r>=0;--r)if(e.areUrlsEquivalent(t.history[r],n,t.kind,t.kind))return r;return-1}function Ho(e,t,n){let r=t.tabs.find(e=>e.id===n.tabId);if(!r)return t;let i=n.resourceUri??n.url,a=e.resolveOpenTarget({activeTab:r,kind:n.kind,url:i}),o=Vo(e,r,a.url),s=n.resourceUri!==void 0&&n.resourceUri===r.resourceUri;return Io({...t,activeTabId:r.id,isOpen:!0},r.id,e=>({...e,currentUrl:a.url,dedupeKey:a.dedupeKey,dockIcon:a.dockIcon??e.dockIcon,historyIndex:o>=0?o:e.historyIndex,kind:a.kind,resourceUri:a.resourceUri??a.url,title:s?e.title:a.title}))}function Uo(e,t,n,r,i){let a={...t,title:r?.title||n.title||t.title,kind:n.kind,resourceUri:n.resourceUri??n.url,dockIcon:r?.dockIcon??n.dockIcon,dedupeKey:i};return e.areUrlsEquivalent(t.currentUrl,n.url,t.kind,n.kind)?a:{...a,currentUrl:n.url,...Ro(t,n.url),navVersion:t.navVersion+1}}function Wo(e,t){return!e.isOpen&&e.tabs.length===1&&t?.kind===`home`&&t.currentUrl===`nextclaw://new-tab`}function Go(e,t,n,r){let{activate:i,dedupeKey:a,newTab:o,title:s}=r??{},c=a?.trim()||n.dedupeKey,l=t.tabs.find(e=>e.id===t.activeTabId)??t.tabs[0],u=c?t.tabs.find(e=>e.dedupeKey===c):void 0;if(u){let a=Io(t,u.id,t=>Uo(e,t,n,r,c)),o=i!==!1,s=o?u.id:t.activeTabId,l={...a,activeTabId:s,isOpen:!0};return o||u.id===t.activeTabId?$(e,l,Bo(u.id,n)):l}if(o||c||!l||l.kind!==n.kind){let i=Ue(n.url,n.kind,s??n.title,c,n.resourceUri??n.url,r?.dockIcon??n.dockIcon);return Wo(t,l)?{...t,isOpen:!0,tabs:[i],activeTabId:i.id,activeHistory:[D(i)],activeHistoryIndex:0}:$(e,{...t,isOpen:!0,tabs:[...t.tabs,i],activeTabId:i.id},D(i))}return $(e,{...Lo(t,t=>Uo(e,t,n,r,c)),isOpen:!0},Bo(t.activeTabId,n))}function Ko(e,t,n,r){let i=t.tabs.find(e=>e.id===t.activeTabId)??t.tabs[0];return Go(e,t,e.resolveOpenTarget({activeTab:i,kind:r?.kind,url:n}),r)}var qo=class{constructor(e=Fo){this.routeResolver=e,this.setSnapshot=e=>{Ge.getState().setSnapshot(e)},this.open=(e,t)=>{this.setSnapshot(n=>Ko(this.routeResolver,n,e,t))},this.openTarget=(e,t)=>{this.setSnapshot(n=>Go(this.routeResolver,n,e,{...t,dedupeKey:t?.dedupeKey??e.dedupeKey,kind:t?.kind??e.kind,title:t?.title??e.title}))},this.openNewTab=()=>{this.open(void 0,{kind:qe,newTab:!0})},this.close=()=>{this.setSnapshot(e=>({...e,isOpen:!1}))},this.toggleMode=()=>{this.setSnapshot(e=>({...e,mode:e.mode===`floating`?`docked`:`floating`}))},this.navigate=e=>{this.setSnapshot(t=>{if(!t.tabs.length){let e=Ue(O(),`docs`,`Docs`);return{...t,tabs:[e],activeTabId:e.id,isOpen:!0}}let n=Lo(t,t=>{if(!this.routeResolver.usesManagedHistory(t))return t;let n=this.routeResolver.resolveOpenTarget({activeTab:t,url:e});return this.routeResolver.areUrlsEquivalent(t.currentUrl,n.url,t.kind,n.kind)?t:{...t,currentUrl:n.url,dedupeKey:n.dedupeKey,dockIcon:n.dockIcon,...Ro(t,n.url),kind:n.kind,navVersion:t.navVersion+1,resourceUri:n.resourceUri??n.url,title:n.title}}),r=n.tabs.find(e=>e.id===n.activeTabId);return r?$(this.routeResolver,n,D(r)):n})},this.syncUrl=e=>{this.setSnapshot(t=>{if(!t.tabs.length){let e=Ue(O(),`docs`,`Docs`);return{...t,tabs:[e],activeTabId:e.id}}let n=Lo(t,t=>{if(!this.routeResolver.usesManagedHistory(t))return t;let n=this.routeResolver.resolveOpenTarget({activeTab:t,kind:t.kind,url:e});return this.routeResolver.areUrlsEquivalent(t.currentUrl,n.url,t.kind,n.kind)?t:{...t,currentUrl:n.url,dedupeKey:n.dedupeKey,dockIcon:n.dockIcon,...Ro(t,n.url),kind:n.kind,resourceUri:n.resourceUri??n.url,title:n.title}}),r=n.tabs.find(e=>e.id===n.activeTabId);return r?$(this.routeResolver,n,D(r)):n})},this.goBack=()=>{this.setSnapshot(e=>{if(e.activeHistoryIndex<=0)return e;let t=e.activeHistoryIndex-1,n=e.activeHistory[t];return n?Ho(this.routeResolver,{...e,activeHistoryIndex:t},n):e})},this.goForward=()=>{this.setSnapshot(e=>{if(e.activeHistoryIndex>=e.activeHistory.length-1)return e;let t=e.activeHistoryIndex+1,n=e.activeHistory[t];return n?Ho(this.routeResolver,{...e,activeHistoryIndex:t},n):e})},this.closeTab=e=>{this.setSnapshot(t=>{if(t.tabs.length<=1)return{...ze(),isOpen:!1};let n=t.tabs.findIndex(t=>t.id===e);if(n<0)return t;let r=t.tabs.filter(t=>t.id!==e),i=t.activeTabId===e?r[Math.max(0,n-1)]?.id??r[0].id:t.activeTabId,a={...t,tabs:r,activeTabId:i},o=a.activeHistory.filter(t=>t.tabId!==e),s=a.activeHistory.slice(0,a.activeHistoryIndex+1).filter(t=>t.tabId!==e),c=r.find(e=>e.id===i)??r[0],l={...a,activeHistory:o.length>0?o:[D(c)],activeHistoryIndex:Math.min(Math.max(0,s.length-1),Math.max(0,o.length-1))};return t.activeTabId===e?$(this.routeResolver,l,D(c)):l})},this.setActiveTab=e=>{this.setSnapshot(t=>{if(!t.tabs.some(t=>t.id===e))return t;let n=t.tabs.find(t=>t.id===e);return n?$(this.routeResolver,{...t,activeTabId:e,isOpen:!0},D(n)):t})}}},Jo=class{constructor(){this.accountManager=new Ei,this.rightPanelResourceRouteResolver=new Xa,this.docBrowserManager=new qo(this.rightPanelResourceRouteResolver),this.sideDockManager=new Po(this.docBrowserManager),this.serviceActionAuthorizationManager=new Qi,this.panelAppBridgeManager=new Ki(this.serviceActionAuthorizationManager),this.remoteAccessManager=new hi({accountManager:this.accountManager})}},Yo=null;function Xo(){return Yo??=new Jo,Yo}function Zo(){return Xo()}var Qo=(0,A.createContext)(null);function $o({children:e}){let t=(0,A.useMemo)(()=>Xo(),[]);return(0,H.jsx)(Qo.Provider,{value:t,children:e})}function es(){let e=(0,A.useContext)(Qo);if(!e)throw Error(`useAppPresenter must be used inside AppPresenterProvider`);return e}export{Cr as A,ii as C,Ur as D,qr as E,Pn as F,V as I,rn as L,wr as M,jn as N,Hr as O,Mn as P,on as R,oi as S,Qr as T,G as _,xo as a,ci as b,Yi as c,bi as d,yi as f,W as g,li as h,Oo as i,An as j,br as k,Ti as l,K as m,es as n,ao as o,hi as p,Zo as r,io as s,$o as t,wi as u,fi as v,ti as w,si as x,mi as y,Ze as z};
|